Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@electric-sql/pglite

Package Overview
Dependencies
Maintainers
3
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@electric-sql/pglite - npm Package Compare versions

Comparing version 0.2.13 to 0.2.14

dist/chunk-5L6BPGXX.js

2

dist/contrib/adminpack.d.ts

@@ -1,2 +0,2 @@

import { d as PGliteInterface } from '../pglite-DnNPQGYh.js';
import { d as PGliteInterface } from '../pglite-CCwqaSmq.js';

@@ -3,0 +3,0 @@ declare const adminpack: {

@@ -1,2 +0,2 @@

import{i as e}from"../chunk-MPW3RCU6.js";e();var t=async(n,s)=>({bundlePath:new URL("../adminpack.tar.gz",import.meta.url)}),p={name:"adminpack",setup:t};export{p as adminpack};
import{j as e}from"../chunk-BTBUZ646.js";e();var t=async(n,s)=>({bundlePath:new URL("../adminpack.tar.gz",import.meta.url)}),p={name:"adminpack",setup:t};export{p as adminpack};
//# sourceMappingURL=adminpack.js.map

@@ -1,2 +0,2 @@

import { d as PGliteInterface } from '../pglite-DnNPQGYh.js';
import { d as PGliteInterface } from '../pglite-CCwqaSmq.js';

@@ -3,0 +3,0 @@ declare const amcheck: {

@@ -1,2 +0,2 @@

import{i as e}from"../chunk-MPW3RCU6.js";e();var t=async(n,s)=>({bundlePath:new URL("../amcheck.tar.gz",import.meta.url)}),c={name:"amcheck",setup:t};export{c as amcheck};
import{j as e}from"../chunk-BTBUZ646.js";e();var t=async(n,s)=>({bundlePath:new URL("../amcheck.tar.gz",import.meta.url)}),c={name:"amcheck",setup:t};export{c as amcheck};
//# sourceMappingURL=amcheck.js.map

@@ -1,2 +0,2 @@

import { d as PGliteInterface } from '../pglite-DnNPQGYh.js';
import { d as PGliteInterface } from '../pglite-CCwqaSmq.js';

@@ -3,0 +3,0 @@ declare const auto_explain: {

@@ -1,2 +0,2 @@

import{i as e}from"../chunk-MPW3RCU6.js";e();var t=async(n,s)=>({bundlePath:new URL("../auto_explain.tar.gz",import.meta.url)}),o={name:"auto_explain",setup:t};export{o as auto_explain};
import{j as e}from"../chunk-BTBUZ646.js";e();var t=async(n,s)=>({bundlePath:new URL("../auto_explain.tar.gz",import.meta.url)}),o={name:"auto_explain",setup:t};export{o as auto_explain};
//# sourceMappingURL=auto_explain.js.map

@@ -1,2 +0,2 @@

import { d as PGliteInterface } from '../pglite-DnNPQGYh.js';
import { d as PGliteInterface } from '../pglite-CCwqaSmq.js';

@@ -3,0 +3,0 @@ declare const bloom: {

@@ -1,2 +0,2 @@

import{i as e}from"../chunk-MPW3RCU6.js";e();var t=async(n,s)=>({bundlePath:new URL("../bloom.tar.gz",import.meta.url)}),r={name:"bloom",setup:t};export{r as bloom};
import{j as e}from"../chunk-BTBUZ646.js";e();var t=async(n,s)=>({bundlePath:new URL("../bloom.tar.gz",import.meta.url)}),r={name:"bloom",setup:t};export{r as bloom};
//# sourceMappingURL=bloom.js.map

@@ -1,2 +0,2 @@

import { d as PGliteInterface } from '../pglite-DnNPQGYh.js';
import { d as PGliteInterface } from '../pglite-CCwqaSmq.js';

@@ -3,0 +3,0 @@ declare const btree_gin: {

@@ -1,2 +0,2 @@

import{i as e}from"../chunk-MPW3RCU6.js";e();var t=async(n,s)=>({bundlePath:new URL("../btree_gin.tar.gz",import.meta.url)}),a={name:"btree_gin",setup:t};export{a as btree_gin};
import{j as e}from"../chunk-BTBUZ646.js";e();var t=async(n,s)=>({bundlePath:new URL("../btree_gin.tar.gz",import.meta.url)}),a={name:"btree_gin",setup:t};export{a as btree_gin};
//# sourceMappingURL=btree_gin.js.map

@@ -1,2 +0,2 @@

import { d as PGliteInterface } from '../pglite-DnNPQGYh.js';
import { d as PGliteInterface } from '../pglite-CCwqaSmq.js';

@@ -3,0 +3,0 @@ declare const btree_gist: {

@@ -1,2 +0,2 @@

import{i as e}from"../chunk-MPW3RCU6.js";e();var t=async(s,n)=>({bundlePath:new URL("../btree_gist.tar.gz",import.meta.url)}),a={name:"btree_gist",setup:t};export{a as btree_gist};
import{j as e}from"../chunk-BTBUZ646.js";e();var t=async(s,n)=>({bundlePath:new URL("../btree_gist.tar.gz",import.meta.url)}),a={name:"btree_gist",setup:t};export{a as btree_gist};
//# sourceMappingURL=btree_gist.js.map

@@ -1,2 +0,2 @@

import { d as PGliteInterface } from '../pglite-DnNPQGYh.js';
import { d as PGliteInterface } from '../pglite-CCwqaSmq.js';

@@ -3,0 +3,0 @@ declare const citext: {

@@ -1,2 +0,2 @@

import{i as e}from"../chunk-MPW3RCU6.js";e();var t=async(n,s)=>({bundlePath:new URL("../citext.tar.gz",import.meta.url)}),a={name:"citext",setup:t};export{a as citext};
import{j as e}from"../chunk-BTBUZ646.js";e();var t=async(n,s)=>({bundlePath:new URL("../citext.tar.gz",import.meta.url)}),a={name:"citext",setup:t};export{a as citext};
//# sourceMappingURL=citext.js.map

@@ -1,2 +0,2 @@

import { d as PGliteInterface } from '../pglite-DnNPQGYh.js';
import { d as PGliteInterface } from '../pglite-CCwqaSmq.js';

@@ -3,0 +3,0 @@ declare const cube: {

@@ -1,2 +0,2 @@

import{i as e}from"../chunk-MPW3RCU6.js";e();var t=async(n,s)=>({bundlePath:new URL("../cube.tar.gz",import.meta.url)}),a={name:"cube",setup:t};export{a as cube};
import{j as e}from"../chunk-BTBUZ646.js";e();var t=async(n,s)=>({bundlePath:new URL("../cube.tar.gz",import.meta.url)}),a={name:"cube",setup:t};export{a as cube};
//# sourceMappingURL=cube.js.map

@@ -1,2 +0,2 @@

import { d as PGliteInterface } from '../pglite-DnNPQGYh.js';
import { d as PGliteInterface } from '../pglite-CCwqaSmq.js';

@@ -3,0 +3,0 @@ declare const earthdistance: {

@@ -1,2 +0,2 @@

import{i as e}from"../chunk-MPW3RCU6.js";e();var t=async(n,s)=>({bundlePath:new URL("../earthdistance.tar.gz",import.meta.url)}),r={name:"earthdistance",setup:t};export{r as earthdistance};
import{j as e}from"../chunk-BTBUZ646.js";e();var t=async(n,s)=>({bundlePath:new URL("../earthdistance.tar.gz",import.meta.url)}),r={name:"earthdistance",setup:t};export{r as earthdistance};
//# sourceMappingURL=earthdistance.js.map

@@ -1,2 +0,2 @@

import { d as PGliteInterface } from '../pglite-DnNPQGYh.js';
import { d as PGliteInterface } from '../pglite-CCwqaSmq.js';

@@ -3,0 +3,0 @@ declare const fuzzystrmatch: {

@@ -1,2 +0,2 @@

import{i as t}from"../chunk-MPW3RCU6.js";t();var e=async(s,n)=>({bundlePath:new URL("../fuzzystrmatch.tar.gz",import.meta.url)}),i={name:"fuzzystrmatch",setup:e};export{i as fuzzystrmatch};
import{j as t}from"../chunk-BTBUZ646.js";t();var e=async(s,n)=>({bundlePath:new URL("../fuzzystrmatch.tar.gz",import.meta.url)}),i={name:"fuzzystrmatch",setup:e};export{i as fuzzystrmatch};
//# sourceMappingURL=fuzzystrmatch.js.map

@@ -1,2 +0,2 @@

import { d as PGliteInterface } from '../pglite-DnNPQGYh.js';
import { d as PGliteInterface } from '../pglite-CCwqaSmq.js';

@@ -3,0 +3,0 @@ declare const hstore: {

@@ -1,2 +0,2 @@

import{i as e}from"../chunk-MPW3RCU6.js";e();var t=async(s,n)=>({bundlePath:new URL("../hstore.tar.gz",import.meta.url)}),o={name:"hstore",setup:t};export{o as hstore};
import{j as e}from"../chunk-BTBUZ646.js";e();var t=async(s,n)=>({bundlePath:new URL("../hstore.tar.gz",import.meta.url)}),o={name:"hstore",setup:t};export{o as hstore};
//# sourceMappingURL=hstore.js.map

@@ -1,2 +0,2 @@

import { d as PGliteInterface } from '../pglite-DnNPQGYh.js';
import { d as PGliteInterface } from '../pglite-CCwqaSmq.js';

@@ -3,0 +3,0 @@ declare const isn: {

@@ -1,2 +0,2 @@

import{i as e}from"../chunk-MPW3RCU6.js";e();var t=async(n,s)=>({bundlePath:new URL("../isn.tar.gz",import.meta.url)}),a={name:"isn",setup:t};export{a as isn};
import{j as e}from"../chunk-BTBUZ646.js";e();var t=async(n,s)=>({bundlePath:new URL("../isn.tar.gz",import.meta.url)}),a={name:"isn",setup:t};export{a as isn};
//# sourceMappingURL=isn.js.map

@@ -1,2 +0,2 @@

import { d as PGliteInterface } from '../pglite-DnNPQGYh.js';
import { d as PGliteInterface } from '../pglite-CCwqaSmq.js';

@@ -3,0 +3,0 @@ declare const lo: {

@@ -1,2 +0,2 @@

import{i as e}from"../chunk-MPW3RCU6.js";e();var t=async(n,s)=>({bundlePath:new URL("../lo.tar.gz",import.meta.url)}),r={name:"lo",setup:t};export{r as lo};
import{j as e}from"../chunk-BTBUZ646.js";e();var t=async(n,s)=>({bundlePath:new URL("../lo.tar.gz",import.meta.url)}),r={name:"lo",setup:t};export{r as lo};
//# sourceMappingURL=lo.js.map

@@ -1,2 +0,2 @@

import { d as PGliteInterface } from '../pglite-DnNPQGYh.js';
import { d as PGliteInterface } from '../pglite-CCwqaSmq.js';

@@ -3,0 +3,0 @@ declare const ltree: {

@@ -1,2 +0,2 @@

import{i as e}from"../chunk-MPW3RCU6.js";e();var t=async(n,s)=>({bundlePath:new URL("../ltree.tar.gz",import.meta.url)}),a={name:"ltree",setup:t};export{a as ltree};
import{j as e}from"../chunk-BTBUZ646.js";e();var t=async(n,s)=>({bundlePath:new URL("../ltree.tar.gz",import.meta.url)}),a={name:"ltree",setup:t};export{a as ltree};
//# sourceMappingURL=ltree.js.map

@@ -1,2 +0,2 @@

import { d as PGliteInterface } from '../pglite-DnNPQGYh.js';
import { d as PGliteInterface } from '../pglite-CCwqaSmq.js';

@@ -3,0 +3,0 @@ declare const pg_trgm: {

@@ -1,2 +0,2 @@

import{i as e}from"../chunk-MPW3RCU6.js";e();var t=async(n,s)=>({bundlePath:new URL("../pg_trgm.tar.gz",import.meta.url)}),p={name:"pg_trgm",setup:t};export{p as pg_trgm};
import{j as e}from"../chunk-BTBUZ646.js";e();var t=async(n,s)=>({bundlePath:new URL("../pg_trgm.tar.gz",import.meta.url)}),p={name:"pg_trgm",setup:t};export{p as pg_trgm};
//# sourceMappingURL=pg_trgm.js.map

@@ -1,2 +0,2 @@

import { d as PGliteInterface } from '../pglite-DnNPQGYh.js';
import { d as PGliteInterface } from '../pglite-CCwqaSmq.js';

@@ -3,0 +3,0 @@ declare const seg: {

@@ -1,2 +0,2 @@

import{i as e}from"../chunk-MPW3RCU6.js";e();var t=async(s,n)=>({bundlePath:new URL("../seg.tar.gz",import.meta.url)}),a={name:"seg",setup:t};export{a as seg};
import{j as e}from"../chunk-BTBUZ646.js";e();var t=async(s,n)=>({bundlePath:new URL("../seg.tar.gz",import.meta.url)}),a={name:"seg",setup:t};export{a as seg};
//# sourceMappingURL=seg.js.map

@@ -1,2 +0,2 @@

import { d as PGliteInterface } from '../pglite-DnNPQGYh.js';
import { d as PGliteInterface } from '../pglite-CCwqaSmq.js';

@@ -3,0 +3,0 @@ declare const tablefunc: {

@@ -1,2 +0,2 @@

import{i as e}from"../chunk-MPW3RCU6.js";e();var t=async(n,s)=>({bundlePath:new URL("../tablefunc.tar.gz",import.meta.url)}),r={name:"tablefunc",setup:t};export{r as tablefunc};
import{j as e}from"../chunk-BTBUZ646.js";e();var t=async(n,s)=>({bundlePath:new URL("../tablefunc.tar.gz",import.meta.url)}),r={name:"tablefunc",setup:t};export{r as tablefunc};
//# sourceMappingURL=tablefunc.js.map

@@ -1,2 +0,2 @@

import { d as PGliteInterface } from '../pglite-DnNPQGYh.js';
import { d as PGliteInterface } from '../pglite-CCwqaSmq.js';

@@ -3,0 +3,0 @@ declare const tcn: {

@@ -1,2 +0,2 @@

import{i as e}from"../chunk-MPW3RCU6.js";e();var t=async(n,s)=>({bundlePath:new URL("../tcn.tar.gz",import.meta.url)}),a={name:"tcn",setup:t};export{a as tcn};
import{j as e}from"../chunk-BTBUZ646.js";e();var t=async(n,s)=>({bundlePath:new URL("../tcn.tar.gz",import.meta.url)}),a={name:"tcn",setup:t};export{a as tcn};
//# sourceMappingURL=tcn.js.map

@@ -1,2 +0,2 @@

import { d as PGliteInterface } from '../pglite-DnNPQGYh.js';
import { d as PGliteInterface } from '../pglite-CCwqaSmq.js';

@@ -3,0 +3,0 @@ declare const tsm_system_rows: {

@@ -1,2 +0,2 @@

import{i as e}from"../chunk-MPW3RCU6.js";e();var t=async(s,n)=>({bundlePath:new URL("../tsm_system_rows.tar.gz",import.meta.url)}),o={name:"tsm_system_rows",setup:t};export{o as tsm_system_rows};
import{j as e}from"../chunk-BTBUZ646.js";e();var t=async(s,n)=>({bundlePath:new URL("../tsm_system_rows.tar.gz",import.meta.url)}),o={name:"tsm_system_rows",setup:t};export{o as tsm_system_rows};
//# sourceMappingURL=tsm_system_rows.js.map

@@ -1,2 +0,2 @@

import { d as PGliteInterface } from '../pglite-DnNPQGYh.js';
import { d as PGliteInterface } from '../pglite-CCwqaSmq.js';

@@ -3,0 +3,0 @@ declare const tsm_system_time: {

@@ -1,2 +0,2 @@

import{i as e}from"../chunk-MPW3RCU6.js";e();var t=async(s,n)=>({bundlePath:new URL("../tsm_system_time.tar.gz",import.meta.url)}),r={name:"tsm_system_time",setup:t};export{r as tsm_system_time};
import{j as e}from"../chunk-BTBUZ646.js";e();var t=async(s,n)=>({bundlePath:new URL("../tsm_system_time.tar.gz",import.meta.url)}),r={name:"tsm_system_time",setup:t};export{r as tsm_system_time};
//# sourceMappingURL=tsm_system_time.js.map

@@ -1,2 +0,2 @@

import { d as PGliteInterface } from '../pglite-DnNPQGYh.js';
import { d as PGliteInterface } from '../pglite-CCwqaSmq.js';

@@ -3,0 +3,0 @@ declare const uuid_ossp: {

@@ -1,2 +0,2 @@

import{i as e}from"../chunk-MPW3RCU6.js";e();var t=async(s,n)=>({bundlePath:new URL("../uuid-ossp.tar.gz",import.meta.url)}),o={name:"uuid-ossp",setup:t};export{o as uuid_ossp};
import{j as e}from"../chunk-BTBUZ646.js";e();var t=async(s,n)=>({bundlePath:new URL("../uuid-ossp.tar.gz",import.meta.url)}),o={name:"uuid-ossp",setup:t};export{o as uuid_ossp};
//# sourceMappingURL=uuid_ossp.js.map

@@ -1,2 +0,2 @@

import { E as EmscriptenBuiltinFilesystem, b as PGlite, c as PostgresMod } from '../pglite-DnNPQGYh.js';
import { E as EmscriptenBuiltinFilesystem, b as PGlite, c as PostgresMod } from '../pglite-CCwqaSmq.js';

@@ -3,0 +3,0 @@ declare class NodeFS extends EmscriptenBuiltinFilesystem {

@@ -1,2 +0,2 @@

import{d as i,e as p}from"../chunk-GMYUOGPV.js";import{i as n}from"../chunk-MPW3RCU6.js";n();import*as s from"fs";import*as o from"path";var m=class extends p{constructor(t){super(t),this.rootDir=o.resolve(t),s.existsSync(o.join(this.rootDir))||s.mkdirSync(this.rootDir)}async init(t,e){return this.pg=t,{emscriptenOpts:{...e,preRun:[...e.preRun||[],r=>{let c=r.FS.filesystems.NODEFS;r.FS.mkdir(i),r.FS.mount(c,{root:this.rootDir},i)}]}}}async closeFs(){this.pg.Module.FS.quit()}};export{m as NodeFS};
import{d as i,e as p}from"../chunk-J3WW5J5P.js";import{j as n}from"../chunk-BTBUZ646.js";n();import*as s from"fs";import*as o from"path";var m=class extends p{constructor(t){super(t),this.rootDir=o.resolve(t),s.existsSync(o.join(this.rootDir))||s.mkdirSync(this.rootDir)}async init(t,e){return this.pg=t,{emscriptenOpts:{...e,preRun:[...e.preRun||[],r=>{let c=r.FS.filesystems.NODEFS;r.FS.mkdir(i),r.FS.mount(c,{root:this.rootDir},i)}]}}}async closeFs(){this.pg.Module.FS.quit()}};export{m as NodeFS};
//# sourceMappingURL=nodefs.js.map

@@ -1,2 +0,2 @@

import { u as BaseFilesystem, b as PGlite, c as PostgresMod, v as FsStats } from '../pglite-DnNPQGYh.js';
import { v as BaseFilesystem, b as PGlite, c as PostgresMod, w as FsStats } from '../pglite-CCwqaSmq.js';

@@ -3,0 +3,0 @@ interface OpfsAhpOptions {

@@ -1,4 +0,4 @@

import{f as B,g as z}from"../chunk-GMYUOGPV.js";import{d as s,e as g,f as E,g as r,h as _,i as R}from"../chunk-MPW3RCU6.js";R();var $="state.txt",G="data",T={DIR:16384,FILE:32768},H,v,F,M,y,b,m,x,P,D,S,n,C,O,k,w,f,I,W,j,L=class extends B{constructor(e,{initialPoolSize:t=1e3,maintainedPoolSize:o=100,debug:i=!1}={}){super(e,{debug:i});g(this,n);g(this,H);g(this,v);g(this,F);g(this,M);g(this,y);g(this,b,new Map);g(this,m,new Map);g(this,x,0);g(this,P,new Map);g(this,D,new Map);this.lastCheckpoint=0;this.checkpointInterval=1e3*60;this.poolCounter=0;g(this,S,new Set);this.initialPoolSize=t,this.maintainedPoolSize=o}async init(e,t){return await r(this,n,C).call(this),super.init(e,t)}async syncToFs(e=!1){await this.maybeCheckpointState(),await this.maintainPool(),e||this.flush()}async closeFs(){for(let e of s(this,m).values())e.close();s(this,y).flush(),s(this,y).close(),this.pg.Module.FS.quit()}async maintainPool(e){e=e||this.maintainedPoolSize;let t=e-this.state.pool.length,o=[];for(let i=0;i<t;i++)o.push(new Promise(async c=>{++this.poolCounter;let a=`${(Date.now()-1704063600).toString(16).padStart(8,"0")}-${this.poolCounter.toString(16).padStart(8,"0")}`,h=await s(this,F).getFileHandle(a,{create:!0}),d=await h.createSyncAccessHandle();s(this,b).set(a,h),s(this,m).set(a,d),r(this,n,k).call(this,{opp:"createPoolFile",args:[a]}),this.state.pool.push(a),c()}));for(let i=0;i>t;i--)o.push(new Promise(async c=>{let a=this.state.pool.pop();r(this,n,k).call(this,{opp:"deletePoolFile",args:[a]});let h=s(this,b).get(a);s(this,m).get(a)?.close(),await s(this,F).removeEntry(h.name),s(this,b).delete(a),s(this,m).delete(a),c()}));await Promise.all(o)}_createPoolFileState(e){this.state.pool.push(e)}_deletePoolFileState(e){let t=this.state.pool.indexOf(e);t>-1&&this.state.pool.splice(t,1)}async maybeCheckpointState(){Date.now()-this.lastCheckpoint>this.checkpointInterval&&await this.checkpointState()}async checkpointState(){let e=new TextEncoder().encode(JSON.stringify(this.state));s(this,y).truncate(0),s(this,y).write(e,{at:0}),s(this,y).flush(),this.lastCheckpoint=Date.now()}flush(){for(let e of s(this,S))try{e.flush()}catch{}s(this,S).clear()}chmod(e,t){r(this,n,O).call(this,{opp:"chmod",args:[e,t]},()=>{this._chmodState(e,t)})}_chmodState(e,t){let o=r(this,n,f).call(this,e);o.mode=t}close(e){let t=r(this,n,I).call(this,e);s(this,P).delete(e),s(this,D).delete(t)}fstat(e){let t=r(this,n,I).call(this,e);return this.lstat(t)}lstat(e){let t=r(this,n,f).call(this,e),o=t.type==="file"?s(this,m).get(t.backingFilename).getSize():0,i=4096;return{dev:0,ino:0,mode:t.mode,nlink:1,uid:0,gid:0,rdev:0,size:o,blksize:i,blocks:Math.ceil(o/i),atime:t.lastModified,mtime:t.lastModified,ctime:t.lastModified}}mkdir(e,t){r(this,n,O).call(this,{opp:"mkdir",args:[e,t]},()=>{this._mkdirState(e,t)})}_mkdirState(e,t){let o=r(this,n,w).call(this,e),i=o.pop(),c=[],a=this.state.root;for(let d of o){if(c.push(e),!Object.prototype.hasOwnProperty.call(a.children,d))if(t?.recursive)this.mkdir(c.join("/"));else throw new p("ENOENT","No such file or directory");if(a.children[d].type!=="directory")throw new p("ENOTDIR","Not a directory");a=a.children[d]}if(Object.prototype.hasOwnProperty.call(a.children,i))throw new p("EEXIST","File exists");let h={type:"directory",lastModified:Date.now(),mode:t?.mode||T.DIR,children:{}};a.children[i]=h}open(e,t,o){if(r(this,n,f).call(this,e).type!=="file")throw new p("EISDIR","Is a directory");let c=r(this,n,W).call(this);return s(this,P).set(c,e),s(this,D).set(e,c),c}readdir(e){let t=r(this,n,f).call(this,e);if(t.type!=="directory")throw new p("ENOTDIR","Not a directory");return Object.keys(t.children)}read(e,t,o,i,c){let a=r(this,n,I).call(this,e),h=r(this,n,f).call(this,a);if(h.type!=="file")throw new p("EISDIR","Is a directory");return s(this,m).get(h.backingFilename).read(new Uint8Array(t.buffer,o,i),{at:c})}rename(e,t){r(this,n,O).call(this,{opp:"rename",args:[e,t]},()=>{this._renameState(e,t,!0)})}_renameState(e,t,o=!1){let i=r(this,n,w).call(this,e),c=i.pop(),a=r(this,n,f).call(this,i.join("/"));if(!Object.prototype.hasOwnProperty.call(a.children,c))throw new p("ENOENT","No such file or directory");let h=r(this,n,w).call(this,t),d=h.pop(),l=r(this,n,f).call(this,h.join("/"));if(o&&Object.prototype.hasOwnProperty.call(l.children,d)){let u=l.children[d];s(this,m).get(u.backingFilename).truncate(0),this.state.pool.push(u.backingFilename)}l.children[d]=a.children[c],delete a.children[c]}rmdir(e){r(this,n,O).call(this,{opp:"rmdir",args:[e]},()=>{this._rmdirState(e)})}_rmdirState(e){let t=r(this,n,w).call(this,e),o=t.pop(),i=r(this,n,f).call(this,t.join("/"));if(!Object.prototype.hasOwnProperty.call(i.children,o))throw new p("ENOENT","No such file or directory");let c=i.children[o];if(c.type!=="directory")throw new p("ENOTDIR","Not a directory");if(Object.keys(c.children).length>0)throw new p("ENOTEMPTY","Directory not empty");delete i.children[o]}truncate(e,t=0){let o=r(this,n,f).call(this,e);if(o.type!=="file")throw new p("EISDIR","Is a directory");let i=s(this,m).get(o.backingFilename);if(!i)throw new p("ENOENT","No such file or directory");i.truncate(t),s(this,S).add(i)}unlink(e){r(this,n,O).call(this,{opp:"unlink",args:[e]},()=>{this._unlinkState(e,!0)})}_unlinkState(e,t=!1){let o=r(this,n,w).call(this,e),i=o.pop(),c=r(this,n,f).call(this,o.join("/"));if(!Object.prototype.hasOwnProperty.call(c.children,i))throw new p("ENOENT","No such file or directory");let a=c.children[i];if(a.type!=="file")throw new p("EISDIR","Is a directory");if(delete c.children[i],t){let h=s(this,m).get(a.backingFilename);h?.truncate(0),s(this,S).add(h),s(this,D).has(e)&&(s(this,P).delete(s(this,D).get(e)),s(this,D).delete(e))}this.state.pool.push(a.backingFilename)}utimes(e,t,o){r(this,n,O).call(this,{opp:"utimes",args:[e,t,o]},()=>{this._utimesState(e,t,o)})}_utimesState(e,t,o){let i=r(this,n,f).call(this,e);i.lastModified=o}writeFile(e,t,o){let i=r(this,n,w).call(this,e),c=i.pop(),a=r(this,n,f).call(this,i.join("/"));if(Object.prototype.hasOwnProperty.call(a.children,c)){let l=a.children[c];l.lastModified=Date.now(),r(this,n,k).call(this,{opp:"setLastModified",args:[e,l.lastModified]})}else{if(this.state.pool.length===0)throw new Error("No more file handles available in the pool");let l={type:"file",lastModified:Date.now(),mode:o?.mode||T.FILE,backingFilename:this.state.pool.pop()};a.children[c]=l,r(this,n,k).call(this,{opp:"createFileNode",args:[e,l]})}let h=a.children[c],d=s(this,m).get(h.backingFilename);t.length>0&&(d.write(typeof t=="string"?new TextEncoder().encode(t):new Uint8Array(t),{at:0}),e.startsWith("/pg_wal")&&s(this,S).add(d))}_createFileNodeState(e,t){let o=r(this,n,w).call(this,e),i=o.pop(),c=r(this,n,f).call(this,o.join("/"));c.children[i]=t;let a=this.state.pool.indexOf(t.backingFilename);return a>-1&&this.state.pool.splice(a,1),t}_setLastModifiedState(e,t){let o=r(this,n,f).call(this,e);o.lastModified=t}write(e,t,o,i,c){let a=r(this,n,I).call(this,e),h=r(this,n,f).call(this,a);if(h.type!=="file")throw new p("EISDIR","Is a directory");let d=s(this,m).get(h.backingFilename);if(!d)throw new p("EBADF","Bad file descriptor");let l=d.write(new Uint8Array(t,o,i),{at:c});return a.startsWith("/pg_wal")&&s(this,S).add(d),l}};H=new WeakMap,v=new WeakMap,F=new WeakMap,M=new WeakMap,y=new WeakMap,b=new WeakMap,m=new WeakMap,x=new WeakMap,P=new WeakMap,D=new WeakMap,S=new WeakMap,n=new WeakSet,C=async function(){E(this,H,await navigator.storage.getDirectory()),E(this,v,await r(this,n,j).call(this,this.dataDir,{create:!0})),E(this,F,await r(this,n,j).call(this,G,{from:s(this,v),create:!0})),E(this,M,await s(this,v).getFileHandle($,{create:!0})),E(this,y,await s(this,M).createSyncAccessHandle());let e=new ArrayBuffer(s(this,y).getSize());s(this,y).read(e,{at:0});let t,o=new TextDecoder().decode(e).split(`
import{f as B,g as z}from"../chunk-J3WW5J5P.js";import{e as s,f as g,g as E,h as r,i as _,j as R}from"../chunk-BTBUZ646.js";R();var $="state.txt",G="data",T={DIR:16384,FILE:32768},H,v,F,M,y,b,m,x,P,D,S,n,C,O,k,w,f,I,W,j,L=class extends B{constructor(e,{initialPoolSize:t=1e3,maintainedPoolSize:o=100,debug:i=!1}={}){super(e,{debug:i});g(this,n);g(this,H);g(this,v);g(this,F);g(this,M);g(this,y);g(this,b,new Map);g(this,m,new Map);g(this,x,0);g(this,P,new Map);g(this,D,new Map);this.lastCheckpoint=0;this.checkpointInterval=1e3*60;this.poolCounter=0;g(this,S,new Set);this.initialPoolSize=t,this.maintainedPoolSize=o}async init(e,t){return await r(this,n,C).call(this),super.init(e,t)}async syncToFs(e=!1){await this.maybeCheckpointState(),await this.maintainPool(),e||this.flush()}async closeFs(){for(let e of s(this,m).values())e.close();s(this,y).flush(),s(this,y).close(),this.pg.Module.FS.quit()}async maintainPool(e){e=e||this.maintainedPoolSize;let t=e-this.state.pool.length,o=[];for(let i=0;i<t;i++)o.push(new Promise(async c=>{++this.poolCounter;let a=`${(Date.now()-1704063600).toString(16).padStart(8,"0")}-${this.poolCounter.toString(16).padStart(8,"0")}`,h=await s(this,F).getFileHandle(a,{create:!0}),d=await h.createSyncAccessHandle();s(this,b).set(a,h),s(this,m).set(a,d),r(this,n,k).call(this,{opp:"createPoolFile",args:[a]}),this.state.pool.push(a),c()}));for(let i=0;i>t;i--)o.push(new Promise(async c=>{let a=this.state.pool.pop();r(this,n,k).call(this,{opp:"deletePoolFile",args:[a]});let h=s(this,b).get(a);s(this,m).get(a)?.close(),await s(this,F).removeEntry(h.name),s(this,b).delete(a),s(this,m).delete(a),c()}));await Promise.all(o)}_createPoolFileState(e){this.state.pool.push(e)}_deletePoolFileState(e){let t=this.state.pool.indexOf(e);t>-1&&this.state.pool.splice(t,1)}async maybeCheckpointState(){Date.now()-this.lastCheckpoint>this.checkpointInterval&&await this.checkpointState()}async checkpointState(){let e=new TextEncoder().encode(JSON.stringify(this.state));s(this,y).truncate(0),s(this,y).write(e,{at:0}),s(this,y).flush(),this.lastCheckpoint=Date.now()}flush(){for(let e of s(this,S))try{e.flush()}catch{}s(this,S).clear()}chmod(e,t){r(this,n,O).call(this,{opp:"chmod",args:[e,t]},()=>{this._chmodState(e,t)})}_chmodState(e,t){let o=r(this,n,f).call(this,e);o.mode=t}close(e){let t=r(this,n,I).call(this,e);s(this,P).delete(e),s(this,D).delete(t)}fstat(e){let t=r(this,n,I).call(this,e);return this.lstat(t)}lstat(e){let t=r(this,n,f).call(this,e),o=t.type==="file"?s(this,m).get(t.backingFilename).getSize():0,i=4096;return{dev:0,ino:0,mode:t.mode,nlink:1,uid:0,gid:0,rdev:0,size:o,blksize:i,blocks:Math.ceil(o/i),atime:t.lastModified,mtime:t.lastModified,ctime:t.lastModified}}mkdir(e,t){r(this,n,O).call(this,{opp:"mkdir",args:[e,t]},()=>{this._mkdirState(e,t)})}_mkdirState(e,t){let o=r(this,n,w).call(this,e),i=o.pop(),c=[],a=this.state.root;for(let d of o){if(c.push(e),!Object.prototype.hasOwnProperty.call(a.children,d))if(t?.recursive)this.mkdir(c.join("/"));else throw new p("ENOENT","No such file or directory");if(a.children[d].type!=="directory")throw new p("ENOTDIR","Not a directory");a=a.children[d]}if(Object.prototype.hasOwnProperty.call(a.children,i))throw new p("EEXIST","File exists");let h={type:"directory",lastModified:Date.now(),mode:t?.mode||T.DIR,children:{}};a.children[i]=h}open(e,t,o){if(r(this,n,f).call(this,e).type!=="file")throw new p("EISDIR","Is a directory");let c=r(this,n,W).call(this);return s(this,P).set(c,e),s(this,D).set(e,c),c}readdir(e){let t=r(this,n,f).call(this,e);if(t.type!=="directory")throw new p("ENOTDIR","Not a directory");return Object.keys(t.children)}read(e,t,o,i,c){let a=r(this,n,I).call(this,e),h=r(this,n,f).call(this,a);if(h.type!=="file")throw new p("EISDIR","Is a directory");return s(this,m).get(h.backingFilename).read(new Uint8Array(t.buffer,o,i),{at:c})}rename(e,t){r(this,n,O).call(this,{opp:"rename",args:[e,t]},()=>{this._renameState(e,t,!0)})}_renameState(e,t,o=!1){let i=r(this,n,w).call(this,e),c=i.pop(),a=r(this,n,f).call(this,i.join("/"));if(!Object.prototype.hasOwnProperty.call(a.children,c))throw new p("ENOENT","No such file or directory");let h=r(this,n,w).call(this,t),d=h.pop(),l=r(this,n,f).call(this,h.join("/"));if(o&&Object.prototype.hasOwnProperty.call(l.children,d)){let u=l.children[d];s(this,m).get(u.backingFilename).truncate(0),this.state.pool.push(u.backingFilename)}l.children[d]=a.children[c],delete a.children[c]}rmdir(e){r(this,n,O).call(this,{opp:"rmdir",args:[e]},()=>{this._rmdirState(e)})}_rmdirState(e){let t=r(this,n,w).call(this,e),o=t.pop(),i=r(this,n,f).call(this,t.join("/"));if(!Object.prototype.hasOwnProperty.call(i.children,o))throw new p("ENOENT","No such file or directory");let c=i.children[o];if(c.type!=="directory")throw new p("ENOTDIR","Not a directory");if(Object.keys(c.children).length>0)throw new p("ENOTEMPTY","Directory not empty");delete i.children[o]}truncate(e,t=0){let o=r(this,n,f).call(this,e);if(o.type!=="file")throw new p("EISDIR","Is a directory");let i=s(this,m).get(o.backingFilename);if(!i)throw new p("ENOENT","No such file or directory");i.truncate(t),s(this,S).add(i)}unlink(e){r(this,n,O).call(this,{opp:"unlink",args:[e]},()=>{this._unlinkState(e,!0)})}_unlinkState(e,t=!1){let o=r(this,n,w).call(this,e),i=o.pop(),c=r(this,n,f).call(this,o.join("/"));if(!Object.prototype.hasOwnProperty.call(c.children,i))throw new p("ENOENT","No such file or directory");let a=c.children[i];if(a.type!=="file")throw new p("EISDIR","Is a directory");if(delete c.children[i],t){let h=s(this,m).get(a.backingFilename);h?.truncate(0),s(this,S).add(h),s(this,D).has(e)&&(s(this,P).delete(s(this,D).get(e)),s(this,D).delete(e))}this.state.pool.push(a.backingFilename)}utimes(e,t,o){r(this,n,O).call(this,{opp:"utimes",args:[e,t,o]},()=>{this._utimesState(e,t,o)})}_utimesState(e,t,o){let i=r(this,n,f).call(this,e);i.lastModified=o}writeFile(e,t,o){let i=r(this,n,w).call(this,e),c=i.pop(),a=r(this,n,f).call(this,i.join("/"));if(Object.prototype.hasOwnProperty.call(a.children,c)){let l=a.children[c];l.lastModified=Date.now(),r(this,n,k).call(this,{opp:"setLastModified",args:[e,l.lastModified]})}else{if(this.state.pool.length===0)throw new Error("No more file handles available in the pool");let l={type:"file",lastModified:Date.now(),mode:o?.mode||T.FILE,backingFilename:this.state.pool.pop()};a.children[c]=l,r(this,n,k).call(this,{opp:"createFileNode",args:[e,l]})}let h=a.children[c],d=s(this,m).get(h.backingFilename);t.length>0&&(d.write(typeof t=="string"?new TextEncoder().encode(t):new Uint8Array(t),{at:0}),e.startsWith("/pg_wal")&&s(this,S).add(d))}_createFileNodeState(e,t){let o=r(this,n,w).call(this,e),i=o.pop(),c=r(this,n,f).call(this,o.join("/"));c.children[i]=t;let a=this.state.pool.indexOf(t.backingFilename);return a>-1&&this.state.pool.splice(a,1),t}_setLastModifiedState(e,t){let o=r(this,n,f).call(this,e);o.lastModified=t}write(e,t,o,i,c){let a=r(this,n,I).call(this,e),h=r(this,n,f).call(this,a);if(h.type!=="file")throw new p("EISDIR","Is a directory");let d=s(this,m).get(h.backingFilename);if(!d)throw new p("EBADF","Bad file descriptor");let l=d.write(new Uint8Array(t,o,i),{at:c});return a.startsWith("/pg_wal")&&s(this,S).add(d),l}};H=new WeakMap,v=new WeakMap,F=new WeakMap,M=new WeakMap,y=new WeakMap,b=new WeakMap,m=new WeakMap,x=new WeakMap,P=new WeakMap,D=new WeakMap,S=new WeakMap,n=new WeakSet,C=async function(){E(this,H,await navigator.storage.getDirectory()),E(this,v,await r(this,n,j).call(this,this.dataDir,{create:!0})),E(this,F,await r(this,n,j).call(this,G,{from:s(this,v),create:!0})),E(this,M,await s(this,v).getFileHandle($,{create:!0})),E(this,y,await s(this,M).createSyncAccessHandle());let e=new ArrayBuffer(s(this,y).getSize());s(this,y).read(e,{at:0});let t,o=new TextDecoder().decode(e).split(`
`),i=!1;try{t=JSON.parse(o[0])}catch{t={root:{type:"directory",lastModified:Date.now(),mode:T.DIR,children:{}},pool:[]},s(this,y).truncate(0),s(this,y).write(new TextEncoder().encode(JSON.stringify(t)),{at:0}),i=!0}this.state=t;let c=o.slice(1).filter(Boolean).map(l=>JSON.parse(l));for(let l of c){let u=`_${l.opp}State`;if(typeof this[u]=="function")try{this[u].bind(this)(...l.args)}catch(N){console.warn("Error applying OPFS AHP WAL entry",l,N)}}let a=[],h=async l=>{if(l.type==="file")try{let u=await s(this,F).getFileHandle(l.backingFilename),N=await u.createSyncAccessHandle();s(this,b).set(l.backingFilename,u),s(this,m).set(l.backingFilename,N)}catch(u){console.error("Error opening file handle for node",l,u)}else for(let u of Object.values(l.children))a.push(h(u))};await h(this.state.root);let d=[];for(let l of this.state.pool)d.push(new Promise(async u=>{s(this,b).has(l)&&console.warn("File handle already exists for pool file",l);let N=await s(this,F).getFileHandle(l),U=await N.createSyncAccessHandle();s(this,b).set(l,N),s(this,m).set(l,U),u()}));await Promise.all([...a,...d]),await this.maintainPool(i?this.initialPoolSize:this.maintainedPoolSize)},O=function(e,t){let o=r(this,n,k).call(this,e);try{t()}catch(i){throw s(this,y).truncate(o),i}},k=function(e){let t=JSON.stringify(e),o=new TextEncoder().encode(`
${t}`),i=s(this,y).getSize();return s(this,y).write(o,{at:i}),s(this,S).add(s(this,y)),i},w=function(e){return e.split("/").filter(Boolean)},f=function(e,t){let o=r(this,n,w).call(this,e),i=t||this.state.root;for(let c of o){if(i.type!=="directory")throw new p("ENOTDIR","Not a directory");if(!Object.prototype.hasOwnProperty.call(i.children,c))throw new p("ENOENT","No such file or directory");i=i.children[c]}return i},I=function(e){let t=s(this,P).get(e);if(!t)throw new p("EBADF","Bad file descriptor");return t},W=function(){let e=++_(this,x)._;for(;s(this,P).has(e);)_(this,x)._++;return e},j=async function(e,t){let o=r(this,n,w).call(this,e),i=t?.from||s(this,H);for(let c of o)i=await i.getDirectoryHandle(c,{create:t?.create});return i};var p=class extends Error{constructor(A,e){super(e),typeof A=="number"?this.code=A:typeof A=="string"&&(this.code=z[A])}};export{L as OpfsAhpFS};
//# sourceMappingURL=opfs-ahp.js.map

@@ -1,3 +0,3 @@

import { B as BackendMessage$1, P as Parser$1, Q as QueryOptions, R as Results, M as Mode, a as BufferParameter, E as EmscriptenBuiltinFilesystem, b as PGlite, c as PostgresMod, d as PGliteInterface, T as Transaction } from './pglite-DnNPQGYh.js';
export { D as DebugLevel, s as DescribeQueryResult, o as DumpDataDirResult, g as ExecProtocolOptions, n as ExecProtocolResult, j as Extension, k as ExtensionNamespace, i as ExtensionSetup, h as ExtensionSetupResult, l as Extensions, F as FilesystemType, I as InitializedExtensions, q as PGliteInterfaceExtensions, p as PGliteOptions, f as ParserOptions, r as Row, e as RowMode, S as SerializerOptions, m as messages, t as types } from './pglite-DnNPQGYh.js';
import { B as BackendMessage$1, P as Parser$1, Q as QueryOptions, R as Results, M as Mode, a as BufferParameter, E as EmscriptenBuiltinFilesystem, b as PGlite, c as PostgresMod, d as PGliteInterface, T as Transaction } from './pglite-CCwqaSmq.js';
export { D as DebugLevel, u as DescribeQueryResult, o as DumpDataDirResult, g as ExecProtocolOptions, n as ExecProtocolResult, j as Extension, k as ExtensionNamespace, i as ExtensionSetup, h as ExtensionSetupResult, l as Extensions, F as FilesystemType, I as InitializedExtensions, r as PGliteInterfaceExtensions, q as PGliteOptions, f as ParserOptions, s as Row, e as RowMode, S as SerializerOptions, m as messages, p as postgresMod, t as types } from './pglite-CCwqaSmq.js';

@@ -4,0 +4,0 @@ /**

@@ -1,2 +0,2 @@

import { R as Results, d as PGliteInterface } from '../pglite-DnNPQGYh.js';
import { R as Results, d as PGliteInterface } from '../pglite-CCwqaSmq.js';

@@ -8,2 +8,4 @@ interface LiveQueryOptions<T = {

params?: any[] | null;
offset?: number;
limit?: number;
callback?: (results: Results<T>) => void;

@@ -92,7 +94,15 @@ signal?: AbortSignal;

}
interface LiveQueryResults<T> extends Results<T> {
totalCount?: number;
offset?: number;
limit?: number;
}
interface LiveQuery<T> {
initialResults: Results<T>;
subscribe: (callback: (results: Results<T>) => void) => void;
unsubscribe: (callback?: (results: Results<T>) => void) => Promise<void>;
refresh: () => Promise<void>;
initialResults: LiveQueryResults<T>;
subscribe: (callback: (results: LiveQueryResults<T>) => void) => void;
unsubscribe: (callback?: (results: LiveQueryResults<T>) => void) => Promise<void>;
refresh: (options?: {
offset?: number;
limit?: number;
}) => Promise<void>;
}

@@ -137,6 +147,6 @@ interface LiveChanges<T = {

};
type PGliteWithLive = PGliteInterface<{
live: typeof live;
}>;
type PGliteWithLive = PGliteInterface & {
live: LiveNamespace;
};
export { type Change, type LiveChanges, type LiveNamespace, type LiveQuery, type PGliteWithLive, live };
export { type Change, type LiveChanges, type LiveNamespace, type LiveQuery, type LiveQueryResults, type PGliteWithLive, live };

@@ -1,19 +0,26 @@

import{u as I,v as O}from"../chunk-JSQ47LU7.js";import{i as C}from"../chunk-MPW3RCU6.js";C();var F=5,M=async(o,$)=>{let m=new Set,L={async query(e,d,a){let u;typeof e!="string"&&(u=e.signal,d=e.params,a=e.callback,e=e.query);let l=a?[a]:[],n=I().replace(/-/g,""),t=!1,f,R,g=async()=>{await o.transaction(async r=>{let _=await O(o,e,d,r);await r.query(`CREATE OR REPLACE TEMP VIEW live_query_${n}_view AS ${_}`),R=await P(r,`live_query_${n}_view`),await D(r,R,m),await r.exec(`
PREPARE live_query_${n}_get AS
SELECT * FROM live_query_${n}_view;
`),f=await r.query(`EXECUTE live_query_${n}_get;`)})};await g();let v=async(r=0)=>{if(l.length!==0){try{f=await o.query(`EXECUTE live_query_${n}_get;`)}catch(_){if(_.message===`prepared statement "live_query_${n}_get" does not exist`){if(r>F)throw _;await g(),v(r+1)}else throw _}N(l,f)}},S=await Promise.all(R.map(r=>o.listen(`table_change__${r.schema_name}__${r.table_name}`,async()=>{v()}))),h=r=>{if(t)throw new Error("Live query is no longer active and cannot be subscribed to");l.push(r)},p=async r=>{r?l=l.filter(_=>_!==_):l=[],l.length===0&&(t=!0,await Promise.all(S.map(_=>_())),await o.exec(`
DROP VIEW IF EXISTS live_query_${n}_view;
DEALLOCATE live_query_${n}_get;
`))};return u?.aborted?await p():u?.addEventListener("abort",()=>{p()},{once:!0}),N(l,f),{initialResults:f,subscribe:h,unsubscribe:p,refresh:v}},async changes(e,d,a,u){let l;if(typeof e!="string"&&(l=e.signal,d=e.params,a=e.key,u=e.callback,e=e.query),!a)throw new Error("key is required for changes queries");let n=u?[u]:[],t=I().replace(/-/g,""),f=!1,R,g=1,v,S=async()=>{await o.transaction(async i=>{let T=await O(o,e,d,i);await i.query(`CREATE OR REPLACE TEMP VIEW live_query_${t}_view AS ${T}`),R=await P(i,`live_query_${t}_view`),await D(i,R,m);let c=[...(await i.query(`
import{u as I,v as C,w as O}from"../chunk-5L6BPGXX.js";import{j as P}from"../chunk-BTBUZ646.js";P();var M=5,U=async(l,w)=>{let g=new Set,h={async query(e,$,s){let v,c,r;if(typeof e!="string"&&(v=e.signal,$=e.params,s=e.callback,c=e.offset,r=e.limit,e=e.query),c===void 0!=(r===void 0))throw new Error("offset and limit must be provided together");let a=c!==void 0&&r!==void 0,d;if(a&&(typeof c!="number"||isNaN(c)||typeof r!="number"||isNaN(r)))throw new Error("offset and limit must be numbers");let u=s?[s]:[],_=I().replace(/-/g,""),f=!1,T,y,N=async()=>{await l.transaction(async t=>{let i=$&&$.length>0?await C(l,e,$,t):e;await t.exec(`CREATE OR REPLACE TEMP VIEW live_query_${_}_view AS ${i}`),y=await q(t,`live_query_${_}_view`),await F(t,y,g),a?(await t.exec(`
PREPARE live_query_${_}_get(int, int) AS
SELECT * FROM live_query_${_}_view
LIMIT $1 OFFSET $2;
`),await t.exec(`
PREPARE live_query_${_}_get_total_count AS
SELECT COUNT(*) FROM live_query_${_}_view;
`),d=(await t.query(`EXECUTE live_query_${_}_get_total_count;`)).rows[0].count,T={...await t.query(`EXECUTE live_query_${_}_get(${r}, ${c});`),offset:c,limit:r,totalCount:d}):(await t.exec(`
PREPARE live_query_${_}_get AS
SELECT * FROM live_query_${_}_view;
`),T=await t.query(`EXECUTE live_query_${_}_get;`))})};await N();let A=O(async({offset:t,limit:i}={})=>{if(!a&&(t!==void 0||i!==void 0))throw new Error("offset and limit cannot be provided for non-windowed queries");if(t&&(typeof t!="number"||isNaN(t))||i&&(typeof i!="number"||isNaN(i)))throw new Error("offset and limit must be numbers");c=t??c,r=i??r;let m=async(E=0)=>{if(u.length!==0){try{a?T={...await l.query(`EXECUTE live_query_${_}_get(${r}, ${c});`),offset:c,limit:r,totalCount:d}:T=await l.query(`EXECUTE live_query_${_}_get;`)}catch(n){let p=n.message;if(p.startsWith(`prepared statement "live_query_${_}`)&&p.endsWith("does not exist")){if(E>M)throw n;await N(),m(E+1)}else throw n}if(S(u,T),a){let n=(await l.query(`EXECUTE live_query_${_}_get_total_count;`)).rows[0].count;n!==d&&(console.log("newTotalCount",n),d=n,A())}}};await m()}),R=await Promise.all(y.map(t=>l.listen(`table_change__${t.schema_name}__${t.table_name}`,async()=>{A()}))),L=t=>{if(f)throw new Error("Live query is no longer active and cannot be subscribed to");u.push(t)},o=async t=>{t?u=u.filter(i=>i!==i):u=[],u.length===0&&(f=!0,await Promise.all(R.map(i=>i())),await l.exec(`
DROP VIEW IF EXISTS live_query_${_}_view;
DEALLOCATE live_query_${_}_get;
`))};return v?.aborted?await o():v?.addEventListener("abort",()=>{o()},{once:!0}),S(u,T),{initialResults:T,subscribe:L,unsubscribe:o,refresh:A}},async changes(e,$,s,v){let c;if(typeof e!="string"&&(c=e.signal,$=e.params,s=e.key,v=e.callback,e=e.query),!s)throw new Error("key is required for changes queries");let r=v?[v]:[],a=I().replace(/-/g,""),d=!1,u,_=1,f,T=async()=>{await l.transaction(async o=>{let t=await C(l,e,$,o);await o.query(`CREATE OR REPLACE TEMP VIEW live_query_${a}_view AS ${t}`),u=await q(o,`live_query_${a}_view`),await F(o,u,g);let i=[...(await o.query(`
SELECT column_name, data_type, udt_name
FROM information_schema.columns
WHERE table_name = 'live_query_${t}_view'
`)).rows,{column_name:"__after__",data_type:"integer"}];await i.exec(`
CREATE TEMP TABLE live_query_${t}_state1 (LIKE live_query_${t}_view INCLUDING ALL);
CREATE TEMP TABLE live_query_${t}_state2 (LIKE live_query_${t}_view INCLUDING ALL);
`);for(let A of[1,2]){let E=A===1?2:1;await i.exec(`
PREPARE live_query_${t}_diff${A} AS
WHERE table_name = 'live_query_${a}_view'
`)).rows,{column_name:"__after__",data_type:"integer"}];await o.exec(`
CREATE TEMP TABLE live_query_${a}_state1 (LIKE live_query_${a}_view INCLUDING ALL);
CREATE TEMP TABLE live_query_${a}_state2 (LIKE live_query_${a}_view INCLUDING ALL);
`);for(let m of[1,2]){let E=m===1?2:1;await o.exec(`
PREPARE live_query_${a}_diff${m} AS
WITH
prev AS (SELECT LAG("${a}") OVER () as __after__, * FROM live_query_${t}_state${E}),
curr AS (SELECT LAG("${a}") OVER () as __after__, * FROM live_query_${t}_state${A}),
prev AS (SELECT LAG("${s}") OVER () as __after__, * FROM live_query_${a}_state${E}),
curr AS (SELECT LAG("${s}") OVER () as __after__, * FROM live_query_${a}_state${m}),
data_diff AS (

@@ -23,8 +30,8 @@ -- INSERT operations: Include all columns

'INSERT' AS __op__,
${c.map(({column_name:s})=>`curr."${s}" AS "${s}"`).join(`,
${i.map(({column_name:n})=>`curr."${n}" AS "${n}"`).join(`,
`)},
ARRAY[]::text[] AS __changed_columns__
FROM curr
LEFT JOIN prev ON curr.${a} = prev.${a}
WHERE prev.${a} IS NULL
LEFT JOIN prev ON curr.${s} = prev.${s}
WHERE prev.${s} IS NULL
UNION ALL

@@ -34,8 +41,8 @@ -- DELETE operations: Include only the primary key

'DELETE' AS __op__,
${c.map(({column_name:s,data_type:w,udt_name:b})=>s===a?`prev."${s}" AS "${s}"`:`NULL${w==="USER-DEFINED"?`::${b}`:""} AS "${s}"`).join(`,
${i.map(({column_name:n,data_type:p,udt_name:b})=>n===s?`prev."${n}" AS "${n}"`:`NULL${p==="USER-DEFINED"?`::${b}`:""} AS "${n}"`).join(`,
`)},
ARRAY[]::text[] AS __changed_columns__
FROM prev
LEFT JOIN curr ON prev.${a} = curr.${a}
WHERE curr.${a} IS NULL
LEFT JOIN curr ON prev.${s} = curr.${s}
WHERE curr.${s} IS NULL
UNION ALL

@@ -45,32 +52,34 @@ -- UPDATE operations: Include only changed columns

'UPDATE' AS __op__,
${c.map(({column_name:s,data_type:w,udt_name:b})=>s===a?`curr."${s}" AS "${s}"`:`CASE
WHEN curr."${s}" IS DISTINCT FROM prev."${s}"
THEN curr."${s}"
ELSE NULL${w==="USER-DEFINED"?`::${b}`:""}
END AS "${s}"`).join(`,
${i.map(({column_name:n,data_type:p,udt_name:b})=>n===s?`curr."${n}" AS "${n}"`:`CASE
WHEN curr."${n}" IS DISTINCT FROM prev."${n}"
THEN curr."${n}"
ELSE NULL${p==="USER-DEFINED"?`::${b}`:""}
END AS "${n}"`).join(`,
`)},
ARRAY(SELECT unnest FROM unnest(ARRAY[${c.filter(({column_name:s})=>s!==a).map(({column_name:s})=>`CASE
WHEN curr."${s}" IS DISTINCT FROM prev."${s}"
THEN '${s}'
ARRAY(SELECT unnest FROM unnest(ARRAY[${i.filter(({column_name:n})=>n!==s).map(({column_name:n})=>`CASE
WHEN curr."${n}" IS DISTINCT FROM prev."${n}"
THEN '${n}'
ELSE NULL
END`).join(", ")}]) WHERE unnest IS NOT NULL) AS __changed_columns__
FROM curr
INNER JOIN prev ON curr.${a} = prev.${a}
INNER JOIN prev ON curr.${s} = prev.${s}
WHERE NOT (curr IS NOT DISTINCT FROM prev)
)
SELECT * FROM data_diff;
`)}})};await S();let h=async()=>{if(n.length===0&&v)return;let i=!1;for(let T=0;T<5;T++)try{await o.transaction(async c=>{await c.exec(`
INSERT INTO live_query_${t}_state${g}
SELECT * FROM live_query_${t}_view;
`),v=await c.query(`EXECUTE live_query_${t}_diff${g};`),g=g===1?2:1,await c.exec(`
TRUNCATE live_query_${t}_state${g};
`)});break}catch(c){if(c.message===`relation "live_query_${t}_state${g}" does not exist`){i=!0,await S();continue}else throw c}q(n,[...i?[{__op__:"RESET"}]:[],...v.rows])},p=await Promise.all(R.map(i=>o.listen(`table_change__${i.schema_name}__${i.table_name}`,async()=>h()))),r=i=>{if(f)throw new Error("Live query is no longer active and cannot be subscribed to");n.push(i)},_=async i=>{i?n=n.filter(T=>T!==T):n=[],n.length===0&&(f=!0,await Promise.all(p.map(T=>T())),await o.exec(`
DROP VIEW IF EXISTS live_query_${t}_view;
DROP TABLE IF EXISTS live_query_${t}_state1;
DROP TABLE IF EXISTS live_query_${t}_state2;
DEALLOCATE live_query_${t}_diff1;
DEALLOCATE live_query_${t}_diff2;
`))};return l?.aborted?await _():l?.addEventListener("abort",()=>{_()},{once:!0}),await h(),{fields:v.fields.filter(i=>!["__after__","__op__","__changed_columns__"].includes(i.name)),initialChanges:v.rows,subscribe:r,unsubscribe:_,refresh:h}},async incrementalQuery(e,d,a,u){let l;if(typeof e!="string"&&(l=e.signal,d=e.params,a=e.key,u=e.callback,e=e.query),!a)throw new Error("key is required for incremental queries");let n=u?[u]:[],t=new Map,f=new Map,R=[],g=!0,{fields:v,unsubscribe:S,refresh:h}=await L.changes(e,d,a,_=>{for(let T of _){let{__op__:c,__changed_columns__:A,...E}=T;switch(c){case"RESET":t.clear(),f.clear();break;case"INSERT":t.set(E[a],E),f.set(E.__after__,E[a]);break;case"DELETE":{let s=t.get(E[a]);t.delete(E[a]),s.__after__!==null&&f.delete(s.__after__);break}case"UPDATE":{let s={...t.get(E[a])??{}};for(let w of A)s[w]=E[w],w==="__after__"&&f.set(E.__after__,E[a]);t.set(E[a],s);break}}}let y=[],i=null;for(let T=0;T<t.size;T++){let c=f.get(i),A=t.get(c);if(!A)break;let E={...A};delete E.__after__,y.push(E),i=c}R=y,g||N(n,{rows:y,fields:v})});g=!1,N(n,{rows:R,fields:v});let p=_=>{n.push(_)},r=async _=>{_?n=n.filter(y=>y!==y):n=[],n.length===0&&await S()};return l?.aborted?await r():l?.addEventListener("abort",()=>{r()},{once:!0}),{initialResults:{rows:R,fields:v},subscribe:p,unsubscribe:r,refresh:h}}};return{namespaceObj:L}},j={name:"Live Queries",setup:M};async function P(o,$){let m=new Map;async function L(e){let d=await o.query(`
`)}})};await T();let y=O(async()=>{if(r.length===0&&f)return;let o=!1;for(let t=0;t<5;t++)try{await l.transaction(async i=>{await i.exec(`
INSERT INTO live_query_${a}_state${_}
SELECT * FROM live_query_${a}_view;
`),f=await i.query(`EXECUTE live_query_${a}_diff${_};`),_=_===1?2:1,await i.exec(`
TRUNCATE live_query_${a}_state${_};
`)});break}catch(i){if(i.message===`relation "live_query_${a}_state${_}" does not exist`){o=!0,await T();continue}else throw i}D(r,[...o?[{__op__:"RESET"}]:[],...f.rows])}),N=await Promise.all(u.map(o=>l.listen(`table_change__${o.schema_name}__${o.table_name}`,async()=>y()))),A=o=>{if(d)throw new Error("Live query is no longer active and cannot be subscribed to");r.push(o)},R=async o=>{o?r=r.filter(t=>t!==t):r=[],r.length===0&&(d=!0,await Promise.all(N.map(t=>t())),await l.exec(`
DROP VIEW IF EXISTS live_query_${a}_view;
DROP TABLE IF EXISTS live_query_${a}_state1;
DROP TABLE IF EXISTS live_query_${a}_state2;
DEALLOCATE live_query_${a}_diff1;
DEALLOCATE live_query_${a}_diff2;
`))};return c?.aborted?await R():c?.addEventListener("abort",()=>{R()},{once:!0}),await y(),{fields:f.fields.filter(o=>!["__after__","__op__","__changed_columns__"].includes(o.name)),initialChanges:f.rows,subscribe:A,unsubscribe:R,refresh:y}},async incrementalQuery(e,$,s,v){let c;if(typeof e!="string"&&(c=e.signal,$=e.params,s=e.key,v=e.callback,e=e.query),!s)throw new Error("key is required for incremental queries");let r=v?[v]:[],a=new Map,d=new Map,u=[],_=!0,{fields:f,unsubscribe:T,refresh:y}=await h.changes(e,$,s,R=>{for(let t of R){let{__op__:i,__changed_columns__:m,...E}=t;switch(i){case"RESET":a.clear(),d.clear();break;case"INSERT":a.set(E[s],E),d.set(E.__after__,E[s]);break;case"DELETE":{let n=a.get(E[s]);a.delete(E[s]),n.__after__!==null&&d.delete(n.__after__);break}case"UPDATE":{let n={...a.get(E[s])??{}};for(let p of m)n[p]=E[p],p==="__after__"&&d.set(E.__after__,E[s]);a.set(E[s],n);break}}}let L=[],o=null;for(let t=0;t<a.size;t++){let i=d.get(o),m=a.get(i);if(!m)break;let E={...m};delete E.__after__,L.push(E),o=i}u=L,_||S(r,{rows:L,fields:f})});_=!1,S(r,{rows:u,fields:f});let N=R=>{r.push(R)},A=async R=>{R?r=r.filter(L=>L!==L):r=[],r.length===0&&await T()};return c?.aborted?await A():c?.addEventListener("abort",()=>{A()},{once:!0}),{initialResults:{rows:u,fields:f},subscribe:N,unsubscribe:A,refresh:y}}};return{namespaceObj:h}},j={name:"Live Queries",setup:U};async function q(l,w){return(await l.query(`
WITH RECURSIVE view_dependencies AS (
-- Base case: Get the initial view's dependencies
SELECT DISTINCT
cl.relname AS table_name,
cl.relname AS dependent_name,
n.nspname AS schema_name,

@@ -83,7 +92,29 @@ cl.relkind = 'v' AS is_view

WHERE
r.ev_class = (
SELECT oid FROM pg_class WHERE relname = $1 AND relkind = 'v'
r.ev_class = (
SELECT oid FROM pg_class WHERE relname = $1 AND relkind = 'v'
)
AND d.deptype = 'n'
UNION ALL
-- Recursive case: Traverse dependencies for views
SELECT DISTINCT
cl.relname AS dependent_name,
n.nspname AS schema_name,
cl.relkind = 'v' AS is_view
FROM view_dependencies vd
JOIN pg_rewrite r ON vd.dependent_name = (
SELECT relname FROM pg_class WHERE oid = r.ev_class AND relkind = 'v'
)
AND d.deptype = 'n';
`,[e]);for(let a of d.rows)if(a.table_name!==e&&!a.is_view){let u=`"${a.schema_name}"."${a.table_name}"`;m.has(u)||m.set(u,{table_name:a.table_name,schema_name:a.schema_name})}else a.is_view&&await L(a.table_name)}return await L($),Array.from(m.values())}async function D(o,$,m){let L=$.filter(e=>!m.has(`${e.schema_name}_${e.table_name}`)).map(e=>`
JOIN pg_depend d ON r.oid = d.objid
JOIN pg_class cl ON d.refobjid = cl.oid
JOIN pg_namespace n ON cl.relnamespace = n.oid
WHERE d.deptype = 'n'
)
SELECT DISTINCT
dependent_name AS table_name,
schema_name
FROM view_dependencies
WHERE NOT is_view; -- Exclude intermediate views
`,[w])).rows.map(h=>({table_name:h.table_name,schema_name:h.schema_name}))}async function F(l,w,g){let h=w.filter(e=>!g.has(`${e.schema_name}_${e.table_name}`)).map(e=>`
CREATE OR REPLACE FUNCTION "_notify_${e.schema_name}_${e.table_name}"() RETURNS TRIGGER AS $$

@@ -99,3 +130,3 @@ BEGIN

`).join(`
`);L.trim()!==""&&await o.exec(L),$.map(e=>m.add(`${e.schema_name}_${e.table_name}`))}var N=(o,$)=>{for(let m of o)m($)},q=(o,$)=>{for(let m of o)m($)};export{j as live};
`);h.trim()!==""&&await l.exec(h),w.map(e=>g.add(`${e.schema_name}_${e.table_name}`))}var S=(l,w)=>{for(let g of l)g(w)},D=(l,w)=>{for(let g of l)g(w)};export{j as live};
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

import{a,b,c,d}from"./chunk-PZ27VTCT.js";import"./chunk-MPW3RCU6.js";export{b as identifier,d as query,c as raw,a as sql};
import{a,b,c,d}from"./chunk-STOZMFXW.js";import"./chunk-BTBUZ646.js";export{b as identifier,d as query,c as raw,a as sql};
//# sourceMappingURL=templating.js.map

@@ -1,2 +0,2 @@

import { d as PGliteInterface } from '../pglite-DnNPQGYh.js';
import { d as PGliteInterface } from '../pglite-CCwqaSmq.js';

@@ -3,0 +3,0 @@ declare const vector: {

@@ -1,2 +0,2 @@

import{i as e}from"../chunk-MPW3RCU6.js";e();var n=async(s,t)=>({emscriptenOpts:t,bundlePath:new URL("../vector.tar.gz",import.meta.url)}),o={name:"pgvector",setup:n};export{o as vector};
import{j as e}from"../chunk-BTBUZ646.js";e();var n=async(s,t)=>({emscriptenOpts:t,bundlePath:new URL("../vector.tar.gz",import.meta.url)}),o={name:"pgvector",setup:n};export{o as vector};
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

import { p as PGliteOptions, w as BasePGlite, d as PGliteInterface, q as PGliteInterfaceExtensions, D as DebugLevel, n as ExecProtocolResult, b as PGlite } from '../pglite-DnNPQGYh.js';
import { q as PGliteOptions, x as BasePGlite, d as PGliteInterface, r as PGliteInterfaceExtensions, D as DebugLevel, n as ExecProtocolResult, b as PGlite } from '../pglite-CCwqaSmq.js';

@@ -3,0 +3,0 @@ type PGliteWorkerOptions = PGliteOptions & {

@@ -1,2 +0,2 @@

import{a as j}from"../chunk-4ZP5PNUC.js";import{u as U}from"../chunk-JSQ47LU7.js";import"../chunk-PZ27VTCT.js";import{d as t,e as l,f as u,g as p,i as Q}from"../chunk-MPW3RCU6.js";Q();var W,_,B,M,C,m,L,b,k,T,A,O,x,v,G,P,R,I,$,o,H,D,w,K,F=class F extends j{constructor(e,r){super();l(this,o);l(this,W);l(this,_,0);l(this,B,!1);l(this,M,!1);l(this,C,!1);l(this,m,new EventTarget);l(this,L);l(this,b,!1);l(this,k);l(this,T);l(this,A);l(this,O);l(this,x);l(this,v);l(this,G);l(this,P,new Map);l(this,R,new Set);l(this,I);l(this,$,[]);u(this,k,e),u(this,L,U()),u(this,I,r?.extensions??{}),u(this,A,new Promise(d=>{t(this,k).addEventListener("message",s=>{if(s.data.type==="here")d();else throw new Error("Invalid message")},{once:!0})})),u(this,O,new Promise(d=>{let s=a=>{a.data.type==="ready"&&(u(this,T,a.data.id),t(this,k).removeEventListener("message",s),d())};t(this,k).addEventListener("message",s)})),u(this,W,p(this,o,H).call(this,r))}static async create(e,r){let d=new F(e,r);return await t(d,W),d}get waitReady(){return new Promise(e=>{t(this,W).then(()=>{t(this,b)?e():e(new Promise(r=>{t(this,m).addEventListener("connected",()=>{r()})}))})})}get debug(){return t(this,_)}get ready(){return t(this,B)}get closed(){return t(this,M)}get isLeader(){return t(this,C)}async close(){var e;t(this,M)||(u(this,M,!0),t(this,x)?.close(),t(this,v)?.close(),(e=t(this,G))==null||e.call(this),t(this,k).terminate())}async[Symbol.asyncDispose](){await this.close()}async execProtocolRaw(e){return await p(this,o,w).call(this,"execProtocolRaw",e)}async execProtocol(e){return await p(this,o,w).call(this,"execProtocol",e)}async syncToFs(){await p(this,o,w).call(this,"syncToFs")}async listen(e,r){return await this.waitReady,t(this,P).has(e)||t(this,P).set(e,new Set),t(this,P).get(e)?.add(r),await this.exec(`LISTEN ${e}`),async()=>{await this.unlisten(e,r)}}async unlisten(e,r){await this.waitReady,r?t(this,P).get(e)?.delete(r):t(this,P).delete(e),t(this,P).get(e)?.size===0&&await this.exec(`UNLISTEN ${e}`)}onNotification(e){return t(this,R).add(e),()=>{t(this,R).delete(e)}}offNotification(e){t(this,R).delete(e)}async dumpDataDir(){return await p(this,o,w).call(this,"dumpDataDir")}onLeaderChange(e){return t(this,m).addEventListener("leader-change",e),()=>{t(this,m).removeEventListener("leader-change",e)}}offLeaderChange(e){t(this,m).removeEventListener("leader-change",e)}async _handleBlob(e){await p(this,o,w).call(this,"_handleBlob",e)}async _getWrittenBlob(){return await p(this,o,w).call(this,"_getWrittenBlob")}async _cleanupBlob(){await p(this,o,w).call(this,"_cleanupBlob")}async _checkReady(){await this.waitReady}async _runExclusiveQuery(e){await p(this,o,w).call(this,"_acquireQueryLock");try{return await e()}finally{await p(this,o,w).call(this,"_releaseQueryLock")}}async _runExclusiveTransaction(e){await p(this,o,w).call(this,"_acquireTransactionLock");try{return await e()}finally{await p(this,o,w).call(this,"_releaseTransactionLock")}}};W=new WeakMap,_=new WeakMap,B=new WeakMap,M=new WeakMap,C=new WeakMap,m=new WeakMap,L=new WeakMap,b=new WeakMap,k=new WeakMap,T=new WeakMap,A=new WeakMap,O=new WeakMap,x=new WeakMap,v=new WeakMap,G=new WeakMap,P=new WeakMap,R=new WeakMap,I=new WeakMap,$=new WeakMap,o=new WeakSet,H=async function(e={}){for(let[n,y]of Object.entries(t(this,I))){if(y instanceof URL)throw new Error("URL extensions are not supported on the client side of a worker");{let c=await y.setup(this,{},!0);if(c.emscriptenOpts&&console.warn(`PGlite extension ${n} returned emscriptenOpts, these are not supported on the client side of a worker`),c.namespaceObj){let E=this;E[n]=c.namespaceObj}c.bundlePath&&console.warn(`PGlite extension ${n} returned bundlePath, this is not supported on the client side of a worker`),c.init&&await c.init(),c.close&&t(this,$).push(c.close)}}await t(this,A);let{extensions:r,...d}=e;t(this,k).postMessage({type:"init",options:d}),await t(this,O);let s=`pglite-tab-close:${t(this,L)}`;u(this,G,await N(s));let a=`pglite-broadcast:${t(this,T)}`;u(this,x,new BroadcastChannel(a));let h=`pglite-tab:${t(this,L)}`;u(this,v,new BroadcastChannel(h)),t(this,x).addEventListener("message",async n=>{n.data.type==="leader-here"?(u(this,b,!1),t(this,m).dispatchEvent(new Event("leader-change")),p(this,o,D).call(this)):n.data.type==="notify"&&p(this,o,K).call(this,n.data.channel,n.data.payload)}),t(this,v).addEventListener("message",async n=>{n.data.type==="connected"&&(u(this,b,!0),t(this,m).dispatchEvent(new Event("connected")),u(this,_,await p(this,o,w).call(this,"getDebugLevel")),u(this,B,!0))}),t(this,k).addEventListener("message",async n=>{n.data.type==="leader-now"&&(u(this,C,!0),t(this,m).dispatchEvent(new Event("leader-change")))}),p(this,o,D).call(this),this._initArrayTypes()},D=async function(){t(this,b)||(t(this,x).postMessage({type:"tab-here",id:t(this,L)}),setTimeout(()=>p(this,o,D).call(this),16))},w=async function(e,...r){let d=U(),s={type:"rpc-call",callId:d,method:e,args:r};return t(this,v).postMessage(s),await new Promise((a,h)=>{let n=E=>{if(E.data.callId!==d)return;c();let f=E.data;if(f.type==="rpc-return")a(f.result);else if(f.type==="rpc-error"){let S=new Error(f.error.message);Object.assign(S,f.error),h(S)}else h(new Error("Invalid message"))},y=()=>{c(),h(new q)},c=()=>{t(this,v).removeEventListener("message",n),t(this,m).removeEventListener("leader-change",y)};t(this,m).addEventListener("leader-change",y),t(this,v).addEventListener("message",n)})},K=function(e,r){let d=t(this,P).get(e);if(d)for(let s of d)queueMicrotask(()=>s(r));for(let s of t(this,R))queueMicrotask(()=>s(e,r))};var z=F;async function te({init:g}){postMessage({type:"here"});let i=await new Promise(y=>{addEventListener("message",c=>{c.data.type==="init"&&y(c.data.options)},{once:!0})}),e=i.id??`${import.meta.url}:${i.dataDir??""}`;postMessage({type:"ready",id:e});let r=`pglite-election-lock:${e}`,d=`pglite-broadcast:${e}`,s=new BroadcastChannel(d),a=new Set;await N(r);let h=g(i);s.onmessage=async y=>{let c=y.data;switch(c.type){case"tab-here":J(c.id,await h,a);break}},s.postMessage({type:"leader-here",id:e}),postMessage({type:"leader-now"}),(await h).onNotification((y,c)=>{s.postMessage({type:"notify",channel:y,payload:c})})}function J(g,i,e){if(e.has(g))return;e.add(g);let r=`pglite-tab:${g}`,d=`pglite-tab-close:${g}`,s=new BroadcastChannel(r);navigator.locks.request(d,()=>new Promise(h=>{s.close(),e.delete(g),h()}));let a=V(g,i);s.addEventListener("message",async h=>{let n=h.data;switch(n.type){case"rpc-call":{await i.waitReady;let{callId:y,method:c,args:E}=n;try{let f=await a[c](...E);s.postMessage({type:"rpc-return",callId:y,result:f})}catch(f){console.error(f),s.postMessage({type:"rpc-error",callId:y,error:{message:f.message}})}break}}}),s.postMessage({type:"connected"})}function V(g,i){let e=null,r=null,d=`pglite-tab-close:${g}`;return N(d).then(()=>{r&&i.exec("ROLLBACK"),e?.(),r?.()}),{async getDebugLevel(){return i.debug},async close(){await i.close()},async execProtocol(s){let{messages:a,data:h}=await i.execProtocol(s);if(h.byteLength!==h.buffer.byteLength){let n=new ArrayBuffer(h.byteLength),y=new Uint8Array(n);return y.set(h),{messages:a,data:y}}else return{messages:a,data:h}},async execProtocolRaw(s){let a=await i.execProtocolRaw(s);if(a.byteLength!==a.buffer.byteLength){let h=new ArrayBuffer(a.byteLength),n=new Uint8Array(h);return n.set(a),n}else return a},async dumpDataDir(){return await i.dumpDataDir()},async syncToFs(){return await i.syncToFs()},async _handleBlob(s){return await i._handleBlob(s)},async _getWrittenBlob(){return await i._getWrittenBlob()},async _cleanupBlob(){return await i._cleanupBlob()},async _checkReady(){return await i._checkReady()},async _acquireQueryLock(){return new Promise(s=>{i._runExclusiveQuery(()=>new Promise(a=>{e=a,s()}))})},async _releaseQueryLock(){e?.(),e=null},async _acquireTransactionLock(){return new Promise(s=>{i._runExclusiveTransaction(()=>new Promise(a=>{r=a,s()}))})},async _releaseTransactionLock(){r?.(),r=null}}}var q=class extends Error{constructor(){super("Leader changed, pending operation in indeterminate state")}};async function N(g){let i;return await new Promise(e=>{navigator.locks.request(g,()=>new Promise(r=>{i=r,e()}))}),i}export{q as LeaderChangedError,z as PGliteWorker,te as worker};
import{a as j}from"../chunk-Y4PL6ZOT.js";import{u as U}from"../chunk-5L6BPGXX.js";import"../chunk-STOZMFXW.js";import{e as t,f as l,g as u,h as p,j as Q}from"../chunk-BTBUZ646.js";Q();var W,_,B,M,C,m,L,b,k,T,A,O,x,v,G,P,R,I,$,o,H,D,w,K,F=class F extends j{constructor(e,r){super();l(this,o);l(this,W);l(this,_,0);l(this,B,!1);l(this,M,!1);l(this,C,!1);l(this,m,new EventTarget);l(this,L);l(this,b,!1);l(this,k);l(this,T);l(this,A);l(this,O);l(this,x);l(this,v);l(this,G);l(this,P,new Map);l(this,R,new Set);l(this,I);l(this,$,[]);u(this,k,e),u(this,L,U()),u(this,I,r?.extensions??{}),u(this,A,new Promise(d=>{t(this,k).addEventListener("message",s=>{if(s.data.type==="here")d();else throw new Error("Invalid message")},{once:!0})})),u(this,O,new Promise(d=>{let s=a=>{a.data.type==="ready"&&(u(this,T,a.data.id),t(this,k).removeEventListener("message",s),d())};t(this,k).addEventListener("message",s)})),u(this,W,p(this,o,H).call(this,r))}static async create(e,r){let d=new F(e,r);return await t(d,W),d}get waitReady(){return new Promise(e=>{t(this,W).then(()=>{t(this,b)?e():e(new Promise(r=>{t(this,m).addEventListener("connected",()=>{r()})}))})})}get debug(){return t(this,_)}get ready(){return t(this,B)}get closed(){return t(this,M)}get isLeader(){return t(this,C)}async close(){var e;t(this,M)||(u(this,M,!0),t(this,x)?.close(),t(this,v)?.close(),(e=t(this,G))==null||e.call(this),t(this,k).terminate())}async[Symbol.asyncDispose](){await this.close()}async execProtocolRaw(e){return await p(this,o,w).call(this,"execProtocolRaw",e)}async execProtocol(e){return await p(this,o,w).call(this,"execProtocol",e)}async syncToFs(){await p(this,o,w).call(this,"syncToFs")}async listen(e,r){return await this.waitReady,t(this,P).has(e)||t(this,P).set(e,new Set),t(this,P).get(e)?.add(r),await this.exec(`LISTEN ${e}`),async()=>{await this.unlisten(e,r)}}async unlisten(e,r){await this.waitReady,r?t(this,P).get(e)?.delete(r):t(this,P).delete(e),t(this,P).get(e)?.size===0&&await this.exec(`UNLISTEN ${e}`)}onNotification(e){return t(this,R).add(e),()=>{t(this,R).delete(e)}}offNotification(e){t(this,R).delete(e)}async dumpDataDir(){return await p(this,o,w).call(this,"dumpDataDir")}onLeaderChange(e){return t(this,m).addEventListener("leader-change",e),()=>{t(this,m).removeEventListener("leader-change",e)}}offLeaderChange(e){t(this,m).removeEventListener("leader-change",e)}async _handleBlob(e){await p(this,o,w).call(this,"_handleBlob",e)}async _getWrittenBlob(){return await p(this,o,w).call(this,"_getWrittenBlob")}async _cleanupBlob(){await p(this,o,w).call(this,"_cleanupBlob")}async _checkReady(){await this.waitReady}async _runExclusiveQuery(e){await p(this,o,w).call(this,"_acquireQueryLock");try{return await e()}finally{await p(this,o,w).call(this,"_releaseQueryLock")}}async _runExclusiveTransaction(e){await p(this,o,w).call(this,"_acquireTransactionLock");try{return await e()}finally{await p(this,o,w).call(this,"_releaseTransactionLock")}}};W=new WeakMap,_=new WeakMap,B=new WeakMap,M=new WeakMap,C=new WeakMap,m=new WeakMap,L=new WeakMap,b=new WeakMap,k=new WeakMap,T=new WeakMap,A=new WeakMap,O=new WeakMap,x=new WeakMap,v=new WeakMap,G=new WeakMap,P=new WeakMap,R=new WeakMap,I=new WeakMap,$=new WeakMap,o=new WeakSet,H=async function(e={}){for(let[n,y]of Object.entries(t(this,I))){if(y instanceof URL)throw new Error("URL extensions are not supported on the client side of a worker");{let c=await y.setup(this,{},!0);if(c.emscriptenOpts&&console.warn(`PGlite extension ${n} returned emscriptenOpts, these are not supported on the client side of a worker`),c.namespaceObj){let E=this;E[n]=c.namespaceObj}c.bundlePath&&console.warn(`PGlite extension ${n} returned bundlePath, this is not supported on the client side of a worker`),c.init&&await c.init(),c.close&&t(this,$).push(c.close)}}await t(this,A);let{extensions:r,...d}=e;t(this,k).postMessage({type:"init",options:d}),await t(this,O);let s=`pglite-tab-close:${t(this,L)}`;u(this,G,await N(s));let a=`pglite-broadcast:${t(this,T)}`;u(this,x,new BroadcastChannel(a));let h=`pglite-tab:${t(this,L)}`;u(this,v,new BroadcastChannel(h)),t(this,x).addEventListener("message",async n=>{n.data.type==="leader-here"?(u(this,b,!1),t(this,m).dispatchEvent(new Event("leader-change")),p(this,o,D).call(this)):n.data.type==="notify"&&p(this,o,K).call(this,n.data.channel,n.data.payload)}),t(this,v).addEventListener("message",async n=>{n.data.type==="connected"&&(u(this,b,!0),t(this,m).dispatchEvent(new Event("connected")),u(this,_,await p(this,o,w).call(this,"getDebugLevel")),u(this,B,!0))}),t(this,k).addEventListener("message",async n=>{n.data.type==="leader-now"&&(u(this,C,!0),t(this,m).dispatchEvent(new Event("leader-change")))}),p(this,o,D).call(this),this._initArrayTypes()},D=async function(){t(this,b)||(t(this,x).postMessage({type:"tab-here",id:t(this,L)}),setTimeout(()=>p(this,o,D).call(this),16))},w=async function(e,...r){let d=U(),s={type:"rpc-call",callId:d,method:e,args:r};return t(this,v).postMessage(s),await new Promise((a,h)=>{let n=E=>{if(E.data.callId!==d)return;c();let f=E.data;if(f.type==="rpc-return")a(f.result);else if(f.type==="rpc-error"){let S=new Error(f.error.message);Object.assign(S,f.error),h(S)}else h(new Error("Invalid message"))},y=()=>{c(),h(new q)},c=()=>{t(this,v).removeEventListener("message",n),t(this,m).removeEventListener("leader-change",y)};t(this,m).addEventListener("leader-change",y),t(this,v).addEventListener("message",n)})},K=function(e,r){let d=t(this,P).get(e);if(d)for(let s of d)queueMicrotask(()=>s(r));for(let s of t(this,R))queueMicrotask(()=>s(e,r))};var z=F;async function te({init:g}){postMessage({type:"here"});let i=await new Promise(y=>{addEventListener("message",c=>{c.data.type==="init"&&y(c.data.options)},{once:!0})}),e=i.id??`${import.meta.url}:${i.dataDir??""}`;postMessage({type:"ready",id:e});let r=`pglite-election-lock:${e}`,d=`pglite-broadcast:${e}`,s=new BroadcastChannel(d),a=new Set;await N(r);let h=g(i);s.onmessage=async y=>{let c=y.data;switch(c.type){case"tab-here":J(c.id,await h,a);break}},s.postMessage({type:"leader-here",id:e}),postMessage({type:"leader-now"}),(await h).onNotification((y,c)=>{s.postMessage({type:"notify",channel:y,payload:c})})}function J(g,i,e){if(e.has(g))return;e.add(g);let r=`pglite-tab:${g}`,d=`pglite-tab-close:${g}`,s=new BroadcastChannel(r);navigator.locks.request(d,()=>new Promise(h=>{s.close(),e.delete(g),h()}));let a=V(g,i);s.addEventListener("message",async h=>{let n=h.data;switch(n.type){case"rpc-call":{await i.waitReady;let{callId:y,method:c,args:E}=n;try{let f=await a[c](...E);s.postMessage({type:"rpc-return",callId:y,result:f})}catch(f){console.error(f),s.postMessage({type:"rpc-error",callId:y,error:{message:f.message}})}break}}}),s.postMessage({type:"connected"})}function V(g,i){let e=null,r=null,d=`pglite-tab-close:${g}`;return N(d).then(()=>{r&&i.exec("ROLLBACK"),e?.(),r?.()}),{async getDebugLevel(){return i.debug},async close(){await i.close()},async execProtocol(s){let{messages:a,data:h}=await i.execProtocol(s);if(h.byteLength!==h.buffer.byteLength){let n=new ArrayBuffer(h.byteLength),y=new Uint8Array(n);return y.set(h),{messages:a,data:y}}else return{messages:a,data:h}},async execProtocolRaw(s){let a=await i.execProtocolRaw(s);if(a.byteLength!==a.buffer.byteLength){let h=new ArrayBuffer(a.byteLength),n=new Uint8Array(h);return n.set(a),n}else return a},async dumpDataDir(){return await i.dumpDataDir()},async syncToFs(){return await i.syncToFs()},async _handleBlob(s){return await i._handleBlob(s)},async _getWrittenBlob(){return await i._getWrittenBlob()},async _cleanupBlob(){return await i._cleanupBlob()},async _checkReady(){return await i._checkReady()},async _acquireQueryLock(){return new Promise(s=>{i._runExclusiveQuery(()=>new Promise(a=>{e=a,s()}))})},async _releaseQueryLock(){e?.(),e=null},async _acquireTransactionLock(){return new Promise(s=>{i._runExclusiveTransaction(()=>new Promise(a=>{r=a,s()}))})},async _releaseTransactionLock(){r?.(),r=null}}}var q=class extends Error{constructor(){super("Leader changed, pending operation in indeterminate state")}};async function N(g){let i;return await new Promise(e=>{navigator.locks.request(g,()=>new Promise(r=>{i=r,e()}))}),i}export{q as LeaderChangedError,z as PGliteWorker,te as worker};
//# sourceMappingURL=index.js.map
{
"name": "@electric-sql/pglite",
"version": "0.2.13",
"version": "0.2.14",
"private": false,

@@ -5,0 +5,0 @@ "publishConfig": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc