@electric-sql/pglite
Advanced tools
Comparing version 0.2.12 to 0.2.13
@@ -1,2 +0,2 @@ | ||
import { d as PGliteInterface } from '../pglite-BvWM7BTQ.js'; | ||
import { d as PGliteInterface } from '../pglite-DnNPQGYh.js'; | ||
@@ -3,0 +3,0 @@ declare const adminpack: { |
@@ -1,2 +0,2 @@ | ||
import{i as e}from"../chunk-Y3AVQXKT.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{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}; | ||
//# sourceMappingURL=adminpack.js.map |
@@ -1,2 +0,2 @@ | ||
import { d as PGliteInterface } from '../pglite-BvWM7BTQ.js'; | ||
import { d as PGliteInterface } from '../pglite-DnNPQGYh.js'; | ||
@@ -3,0 +3,0 @@ declare const amcheck: { |
@@ -1,2 +0,2 @@ | ||
import{i as e}from"../chunk-Y3AVQXKT.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{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}; | ||
//# sourceMappingURL=amcheck.js.map |
@@ -1,2 +0,2 @@ | ||
import { d as PGliteInterface } from '../pglite-BvWM7BTQ.js'; | ||
import { d as PGliteInterface } from '../pglite-DnNPQGYh.js'; | ||
@@ -3,0 +3,0 @@ declare const auto_explain: { |
@@ -1,2 +0,2 @@ | ||
import{i as e}from"../chunk-Y3AVQXKT.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{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}; | ||
//# sourceMappingURL=auto_explain.js.map |
@@ -1,2 +0,2 @@ | ||
import { d as PGliteInterface } from '../pglite-BvWM7BTQ.js'; | ||
import { d as PGliteInterface } from '../pglite-DnNPQGYh.js'; | ||
@@ -3,0 +3,0 @@ declare const bloom: { |
@@ -1,2 +0,2 @@ | ||
import{i as e}from"../chunk-Y3AVQXKT.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{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}; | ||
//# sourceMappingURL=bloom.js.map |
@@ -1,2 +0,2 @@ | ||
import { d as PGliteInterface } from '../pglite-BvWM7BTQ.js'; | ||
import { d as PGliteInterface } from '../pglite-DnNPQGYh.js'; | ||
@@ -3,0 +3,0 @@ declare const btree_gin: { |
@@ -1,2 +0,2 @@ | ||
import{i as e}from"../chunk-Y3AVQXKT.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{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}; | ||
//# sourceMappingURL=btree_gin.js.map |
@@ -1,2 +0,2 @@ | ||
import { d as PGliteInterface } from '../pglite-BvWM7BTQ.js'; | ||
import { d as PGliteInterface } from '../pglite-DnNPQGYh.js'; | ||
@@ -3,0 +3,0 @@ declare const btree_gist: { |
@@ -1,2 +0,2 @@ | ||
import{i as e}from"../chunk-Y3AVQXKT.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{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}; | ||
//# sourceMappingURL=btree_gist.js.map |
@@ -1,2 +0,2 @@ | ||
import { d as PGliteInterface } from '../pglite-BvWM7BTQ.js'; | ||
import { d as PGliteInterface } from '../pglite-DnNPQGYh.js'; | ||
@@ -3,0 +3,0 @@ declare const citext: { |
@@ -1,2 +0,2 @@ | ||
import{i as e}from"../chunk-Y3AVQXKT.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{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}; | ||
//# sourceMappingURL=citext.js.map |
@@ -1,2 +0,2 @@ | ||
import { d as PGliteInterface } from '../pglite-BvWM7BTQ.js'; | ||
import { d as PGliteInterface } from '../pglite-DnNPQGYh.js'; | ||
@@ -3,0 +3,0 @@ declare const cube: { |
@@ -1,2 +0,2 @@ | ||
import{i as e}from"../chunk-Y3AVQXKT.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{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}; | ||
//# sourceMappingURL=cube.js.map |
@@ -1,2 +0,2 @@ | ||
import { d as PGliteInterface } from '../pglite-BvWM7BTQ.js'; | ||
import { d as PGliteInterface } from '../pglite-DnNPQGYh.js'; | ||
@@ -3,0 +3,0 @@ declare const earthdistance: { |
@@ -1,2 +0,2 @@ | ||
import{i as e}from"../chunk-Y3AVQXKT.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{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}; | ||
//# sourceMappingURL=earthdistance.js.map |
@@ -1,2 +0,2 @@ | ||
import { d as PGliteInterface } from '../pglite-BvWM7BTQ.js'; | ||
import { d as PGliteInterface } from '../pglite-DnNPQGYh.js'; | ||
@@ -3,0 +3,0 @@ declare const fuzzystrmatch: { |
@@ -1,2 +0,2 @@ | ||
import{i as t}from"../chunk-Y3AVQXKT.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{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}; | ||
//# sourceMappingURL=fuzzystrmatch.js.map |
@@ -1,2 +0,2 @@ | ||
import { d as PGliteInterface } from '../pglite-BvWM7BTQ.js'; | ||
import { d as PGliteInterface } from '../pglite-DnNPQGYh.js'; | ||
@@ -3,0 +3,0 @@ declare const hstore: { |
@@ -1,2 +0,2 @@ | ||
import{i as e}from"../chunk-Y3AVQXKT.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{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}; | ||
//# sourceMappingURL=hstore.js.map |
@@ -1,2 +0,2 @@ | ||
import { d as PGliteInterface } from '../pglite-BvWM7BTQ.js'; | ||
import { d as PGliteInterface } from '../pglite-DnNPQGYh.js'; | ||
@@ -3,0 +3,0 @@ declare const isn: { |
@@ -1,2 +0,2 @@ | ||
import{i as e}from"../chunk-Y3AVQXKT.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{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}; | ||
//# sourceMappingURL=isn.js.map |
@@ -1,2 +0,2 @@ | ||
import { d as PGliteInterface } from '../pglite-BvWM7BTQ.js'; | ||
import { d as PGliteInterface } from '../pglite-DnNPQGYh.js'; | ||
@@ -3,0 +3,0 @@ declare const lo: { |
@@ -1,2 +0,2 @@ | ||
import{i as e}from"../chunk-Y3AVQXKT.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{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}; | ||
//# sourceMappingURL=lo.js.map |
@@ -1,2 +0,2 @@ | ||
import { d as PGliteInterface } from '../pglite-BvWM7BTQ.js'; | ||
import { d as PGliteInterface } from '../pglite-DnNPQGYh.js'; | ||
@@ -3,0 +3,0 @@ declare const ltree: { |
@@ -1,2 +0,2 @@ | ||
import{i as e}from"../chunk-Y3AVQXKT.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{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}; | ||
//# sourceMappingURL=ltree.js.map |
@@ -1,2 +0,2 @@ | ||
import { d as PGliteInterface } from '../pglite-BvWM7BTQ.js'; | ||
import { d as PGliteInterface } from '../pglite-DnNPQGYh.js'; | ||
@@ -3,0 +3,0 @@ declare const pg_trgm: { |
@@ -1,2 +0,2 @@ | ||
import{i as e}from"../chunk-Y3AVQXKT.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{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}; | ||
//# sourceMappingURL=pg_trgm.js.map |
@@ -1,2 +0,2 @@ | ||
import { d as PGliteInterface } from '../pglite-BvWM7BTQ.js'; | ||
import { d as PGliteInterface } from '../pglite-DnNPQGYh.js'; | ||
@@ -3,0 +3,0 @@ declare const seg: { |
@@ -1,2 +0,2 @@ | ||
import{i as e}from"../chunk-Y3AVQXKT.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{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}; | ||
//# sourceMappingURL=seg.js.map |
@@ -1,2 +0,2 @@ | ||
import { d as PGliteInterface } from '../pglite-BvWM7BTQ.js'; | ||
import { d as PGliteInterface } from '../pglite-DnNPQGYh.js'; | ||
@@ -3,0 +3,0 @@ declare const tablefunc: { |
@@ -1,2 +0,2 @@ | ||
import{i as e}from"../chunk-Y3AVQXKT.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{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}; | ||
//# sourceMappingURL=tablefunc.js.map |
@@ -1,2 +0,2 @@ | ||
import { d as PGliteInterface } from '../pglite-BvWM7BTQ.js'; | ||
import { d as PGliteInterface } from '../pglite-DnNPQGYh.js'; | ||
@@ -3,0 +3,0 @@ declare const tcn: { |
@@ -1,2 +0,2 @@ | ||
import{i as e}from"../chunk-Y3AVQXKT.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{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}; | ||
//# sourceMappingURL=tcn.js.map |
@@ -1,2 +0,2 @@ | ||
import { d as PGliteInterface } from '../pglite-BvWM7BTQ.js'; | ||
import { d as PGliteInterface } from '../pglite-DnNPQGYh.js'; | ||
@@ -3,0 +3,0 @@ declare const tsm_system_rows: { |
@@ -1,2 +0,2 @@ | ||
import{i as e}from"../chunk-Y3AVQXKT.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{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}; | ||
//# sourceMappingURL=tsm_system_rows.js.map |
@@ -1,2 +0,2 @@ | ||
import { d as PGliteInterface } from '../pglite-BvWM7BTQ.js'; | ||
import { d as PGliteInterface } from '../pglite-DnNPQGYh.js'; | ||
@@ -3,0 +3,0 @@ declare const tsm_system_time: { |
@@ -1,2 +0,2 @@ | ||
import{i as e}from"../chunk-Y3AVQXKT.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{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}; | ||
//# sourceMappingURL=tsm_system_time.js.map |
@@ -1,2 +0,2 @@ | ||
import { d as PGliteInterface } from '../pglite-BvWM7BTQ.js'; | ||
import { d as PGliteInterface } from '../pglite-DnNPQGYh.js'; | ||
@@ -3,0 +3,0 @@ declare const uuid_ossp: { |
@@ -1,2 +0,2 @@ | ||
import{i as e}from"../chunk-Y3AVQXKT.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{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}; | ||
//# sourceMappingURL=uuid_ossp.js.map |
@@ -1,2 +0,2 @@ | ||
import { E as EmscriptenBuiltinFilesystem, b as PGlite, c as PostgresMod } from '../pglite-BvWM7BTQ.js'; | ||
import { E as EmscriptenBuiltinFilesystem, b as PGlite, c as PostgresMod } from '../pglite-DnNPQGYh.js'; | ||
@@ -3,0 +3,0 @@ declare class NodeFS extends EmscriptenBuiltinFilesystem { |
@@ -1,2 +0,2 @@ | ||
import{d as i,e as p}from"../chunk-RBN4KMJ6.js";import{i as n}from"../chunk-Y3AVQXKT.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-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}; | ||
//# sourceMappingURL=nodefs.js.map |
@@ -1,2 +0,2 @@ | ||
import { q as BaseFilesystem, b as PGlite, c as PostgresMod, r as FsStats } from '../pglite-BvWM7BTQ.js'; | ||
import { u as BaseFilesystem, b as PGlite, c as PostgresMod, v as FsStats } from '../pglite-DnNPQGYh.js'; | ||
@@ -3,0 +3,0 @@ interface OpfsAhpOptions { |
@@ -1,4 +0,4 @@ | ||
import{f as B,g as z}from"../chunk-RBN4KMJ6.js";import{d as s,e as g,f as E,g as r,h as _,i as R}from"../chunk-Y3AVQXKT.js";R();var $="state.txt",G="data",T={DIR:16384,FILE:32768},H,v,O,M,y,b,m,x,F,P,S,n,C,D,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,O);g(this,M);g(this,y);g(this,b,new Map);g(this,m,new Map);g(this,x,0);g(this,F,new Map);g(this,P,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,O).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 h.remove().then(()=>{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,D).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,F).delete(e),s(this,P).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,D).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,F).set(c,e),s(this,P).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,D).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,D).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,D).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,P).has(e)&&(s(this,F).delete(s(this,P).get(e)),s(this,P).delete(e))}this.state.pool.push(a.backingFilename)}utimes(e,t,o){r(this,n,D).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,O=new WeakMap,M=new WeakMap,y=new WeakMap,b=new WeakMap,m=new WeakMap,x=new WeakMap,F=new WeakMap,P=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,O,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,O).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,O).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)},D=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,F).get(e);if(!t)throw new p("EBADF","Bad file descriptor");return t},W=function(){let e=++_(this,x)._;for(;s(this,F).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}; | ||
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(` | ||
`),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-BvWM7BTQ.js'; | ||
export { D as DebugLevel, l as DumpDataDirResult, g as ExecProtocolOptions, j as Extension, i as ExtensionSetup, h as ExtensionSetupResult, k as Extensions, F as FilesystemType, o as PGliteInterfaceExtensions, n as PGliteOptions, f as ParserOptions, p as Row, e as RowMode, m as messages, t as types } from './pglite-BvWM7BTQ.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-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'; | ||
@@ -4,0 +4,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
import{a as Ee,b as re,c as z,d as v,e as V}from"./chunk-RBN4KMJ6.js";import{a as me}from"./chunk-NMYRYYP2.js";import"./chunk-EL7DUS2A.js";import{a as ne,b as oe,c as ae,d as le,e as ce,f as _e,g as J,h as Fe,m as Te,p as Se,q as ue,r as de,s as pe,t as fe,u as Me,v as Oe}from"./chunk-IZM3GSNN.js";import{c as ve,d as n,e as p,f as y,g as B,i as f}from"./chunk-Y3AVQXKT.js";f();f();f();var Ne=new Error("timeout while waiting for mutex to become available"),Ue=new Error("mutex already locked"),Ae=new Error("request for lock canceled"),Re=function(i,t,e,s){function o(r){return r instanceof e?r:new e(function(c){c(r)})}return new(e||(e=Promise))(function(r,c){function m(u){try{d(s.next(u))}catch(a){c(a)}}function l(u){try{d(s.throw(u))}catch(a){c(a)}}function d(u){u.done?r(u.value):o(u.value).then(m,l)}d((s=s.apply(i,t||[])).next())})},Z=class{constructor(t,e=Ae){this._value=t,this._cancelError=e,this._weightedQueues=[],this._weightedWaiters=[]}acquire(t=1){if(t<=0)throw new Error(`invalid weight ${t}: must be positive`);return new Promise((e,s)=>{this._weightedQueues[t-1]||(this._weightedQueues[t-1]=[]),this._weightedQueues[t-1].push({resolve:e,reject:s}),this._dispatch()})}runExclusive(t,e=1){return Re(this,void 0,void 0,function*(){let[s,o]=yield this.acquire(e);try{return yield t(s)}finally{o()}})}waitForUnlock(t=1){if(t<=0)throw new Error(`invalid weight ${t}: must be positive`);return new Promise(e=>{this._weightedWaiters[t-1]||(this._weightedWaiters[t-1]=[]),this._weightedWaiters[t-1].push(e),this._dispatch()})}isLocked(){return this._value<=0}getValue(){return this._value}setValue(t){this._value=t,this._dispatch()}release(t=1){if(t<=0)throw new Error(`invalid weight ${t}: must be positive`);this._value+=t,this._dispatch()}cancel(){this._weightedQueues.forEach(t=>t.forEach(e=>e.reject(this._cancelError))),this._weightedQueues=[]}_dispatch(){var t;for(let e=this._value;e>0;e--){let s=(t=this._weightedQueues[e-1])===null||t===void 0?void 0:t.shift();if(!s)continue;let o=this._value,r=e;this._value-=e,e=this._value+1,s.resolve([o,this._newReleaser(r)])}this._drainUnlockWaiters()}_newReleaser(t){let e=!1;return()=>{e||(e=!0,this.release(t))}}_drainUnlockWaiters(){for(let t=this._value;t>0;t--)this._weightedWaiters[t-1]&&(this._weightedWaiters[t-1].forEach(e=>e()),this._weightedWaiters[t-1]=[])}},De=function(i,t,e,s){function o(r){return r instanceof e?r:new e(function(c){c(r)})}return new(e||(e=Promise))(function(r,c){function m(u){try{d(s.next(u))}catch(a){c(a)}}function l(u){try{d(s.throw(u))}catch(a){c(a)}}function d(u){u.done?r(u.value):o(u.value).then(m,l)}d((s=s.apply(i,t||[])).next())})},M=class{constructor(t){this._semaphore=new Z(1,t)}acquire(){return De(this,void 0,void 0,function*(){let[,t]=yield this._semaphore.acquire();return t})}runExclusive(t){return this._semaphore.runExclusive(()=>t())}isLocked(){return this._semaphore.isLocked()}waitForUnlock(){return this._semaphore.waitForUnlock()}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}};f();import Be from"./postgres.js";var ye=Be;f();f();var L=class extends V{async init(t,e){return this.pg=t,{emscriptenOpts:{...e,preRun:[...e.preRun||[],o=>{let r=o.FS.filesystems.IDBFS;o.FS.mkdir("/pglite"),o.FS.mkdir(`/pglite/${this.dataDir}`),o.FS.mount(r,{},`/pglite/${this.dataDir}`),o.FS.symlink(`/pglite/${this.dataDir}`,v)}]}}}initialSyncFs(){return new Promise((t,e)=>{this.pg.Module.FS.syncfs(!0,s=>{s?e(s):t()})})}syncToFs(t){return new Promise((e,s)=>{this.pg.Module.FS.syncfs(!1,o=>{o?s(o):e()})})}async closeFs(){let t=this.pg.Module.FS.filesystems.IDBFS.dbs[this.dataDir];t&&t.close(),this.pg.Module.FS.quit()}};f();var q=class extends V{async closeFs(){this.pg.Module.FS.quit()}};function he(i){let t;if(i?.startsWith("file://")){if(i=i.slice(7),!i)throw new Error("Invalid dataDir, must be a valid path");t="nodefs"}else i?.startsWith("idb://")?(i=i.slice(6),t="idbfs"):i?.startsWith("opfs-ahp://")?(i=i.slice(11),t="opfs-ahp"):!i||i?.startsWith("memory://")?t="memoryfs":t="nodefs";return{dataDir:i,fsType:t}}async function ge(i,t){let e;if(i&&t==="nodefs"){let{NodeFS:s}=await import("./fs/nodefs.js");e=new s(i)}else if(i&&t==="idbfs")e=new L(i);else if(i&&t==="opfs-ahp"){let{OpfsAhpFS:s}=await import("./fs/opfs-ahp.js");e=new s(i)}else e=new q;return e}f();var we=ve(Ee(),1);async function ee(i){if(ue){let t=await import("fs"),e=await import("zlib"),{Writable:s}=await import("stream"),{pipeline:o}=await import("stream/promises");if(!t.existsSync(i))throw new Error(`Extension bundle not found: ${i}`);let r=e.createGunzip(),c=[];return await o(t.createReadStream(i),r,new s({write(m,l,d){c.push(m),d()}})),new Blob(c)}else{let t=await fetch(i.toString());if(!t.ok||!t.body)return null;if(t.headers.get("Content-Encoding")==="gzip")return t.blob();{let e=new DecompressionStream("gzip");return new Response(t.body.pipeThrough(e)).blob()}}}async function be(i,t){for(let e in i.pg_extensions){let s;try{s=await i.pg_extensions[e]}catch(o){console.error("Failed to fetch extension:",e,o);continue}if(s){let o=new Uint8Array(await s.arrayBuffer());Ie(i,e,o,t)}else console.error("Could not get binary data for extension:",e)}}function Ie(i,t,e,s){we.default.untar(e).forEach(r=>{if(!r.name.startsWith(".")){let c=i.WASM_PREFIX+"/"+r.name;if(r.name.endsWith(".so")){let m=(...d)=>{s("pgfs:ext OK",c,d)},l=(...d)=>{s("pgfs:ext FAIL",c,d)};i.FS.createPreloadedFile(ke(c),r.name.split("/").pop().slice(0,-3),r.data,!0,!0,m,l,!1)}else i.FS.writeFile(c,r.data)}})}function ke(i){let t=i.lastIndexOf("/");return t>0?i.slice(0,t):i}var I,O,A,k,N,K,X,Y,U,$,C,Q,R,F,w,D,P,Pe,W,te=class te extends me{constructor(e={},s={}){super();p(this,P);p(this,I,!1);p(this,O,!1);p(this,A,!1);p(this,k,!1);p(this,N,!1);p(this,K,new M);p(this,X,new M);p(this,Y,new M);p(this,U,!1);this.debug=0;p(this,$);p(this,C,[]);p(this,Q,new J);p(this,R);p(this,F);p(this,w,new Map);p(this,D,new Set);typeof e=="string"?s={dataDir:e,...s}:s=e,this.dataDir=s.dataDir,s?.debug!==void 0&&(this.debug=s.debug),s?.relaxedDurability!==void 0&&y(this,N,s.relaxedDurability),y(this,$,s.extensions??{}),this.waitReady=B(this,P,Pe).call(this,s??{})}static async create(e,s){let o=typeof e=="string"?{dataDir:e,...s??{}}:e??{},r=new te(o);return await r.waitReady,r}get Module(){return this.mod}get ready(){return n(this,I)&&!n(this,O)&&!n(this,A)}get closed(){return n(this,A)}async close(){await this._checkReady(),y(this,O,!0);for(let e of n(this,C))await e();try{await this.execProtocol(ne.end()),this.mod._pg_shutdown()}catch(e){let s=e;if(!(s.name==="ExitStatus"&&s.status===0))throw e}await this.fs.closeFs(),y(this,A,!0),y(this,O,!1)}async[Symbol.asyncDispose](){await this.close()}async _handleBlob(e){y(this,R,e?await e.arrayBuffer():void 0)}async _cleanupBlob(){y(this,R,void 0)}async _getWrittenBlob(){if(!n(this,F))return;let e=new Blob(n(this,F));return y(this,F,void 0),e}async _checkReady(){if(n(this,O))throw new Error("PGlite is closing");if(n(this,A))throw new Error("PGlite is closed");n(this,I)||await this.waitReady}async execProtocolRaw(e,{syncToFs:s=!0}={}){let o=e.length,r=this.mod;r._interactive_write(o),r.HEAPU8.set(e,1),r._interactive_one();let c=o+2,m=c+r._interactive_read(),l=r.HEAPU8.subarray(c,m);return s&&await this.syncToFs(),l}async execProtocol(e,{syncToFs:s=!0,throwOnError:o=!0,onNotice:r}={}){let c=await this.execProtocolRaw(e,{syncToFs:s}),m=[];return n(this,Q).parse(c,l=>{if(l instanceof oe){if(y(this,Q,new J),o)throw l}else if(l instanceof ce)this.debug>0&&console.warn(l),r&&r(l);else if(l instanceof le)switch(l.text){case"BEGIN":y(this,k,!0);break;case"COMMIT":case"ROLLBACK":y(this,k,!1);break}else if(l instanceof ae){let d=n(this,w).get(l.channel);d&&d.forEach(u=>{queueMicrotask(()=>u(l.payload))}),n(this,D).forEach(u=>{queueMicrotask(()=>u(l.channel,l.payload))})}m.push([l,c])}),m}isInTransaction(){return n(this,k)}async syncToFs(){if(n(this,U))return;y(this,U,!0);let e=async()=>{await n(this,Y).runExclusive(async()=>{y(this,U,!1),await this.fs.syncToFs(n(this,N))})};n(this,N)?e():await e()}async listen(e,s){return n(this,w).has(e)||n(this,w).set(e,new Set),n(this,w).get(e).add(s),await this.exec(`LISTEN "${e}"`),async()=>{await this.unlisten(e,s)}}async unlisten(e,s){s?(n(this,w).get(e)?.delete(s),n(this,w).get(e)?.size===0&&(await this.exec(`UNLISTEN "${e}"`),n(this,w).delete(e))):(await this.exec(`UNLISTEN "${e}"`),n(this,w).delete(e))}onNotification(e){return n(this,D).add(e),()=>{n(this,D).delete(e)}}offNotification(e){n(this,D).delete(e)}async dumpDataDir(e){let s=this.dataDir?.split("/").pop()??"pgdata";return this.fs.dumpTar(s,e)}_runExclusiveQuery(e){return n(this,K).runExclusive(e)}_runExclusiveTransaction(e){return n(this,X).runExclusive(e)}};I=new WeakMap,O=new WeakMap,A=new WeakMap,k=new WeakMap,N=new WeakMap,K=new WeakMap,X=new WeakMap,Y=new WeakMap,U=new WeakMap,$=new WeakMap,C=new WeakMap,Q=new WeakMap,R=new WeakMap,F=new WeakMap,w=new WeakMap,D=new WeakMap,P=new WeakSet,Pe=async function(e){if(e.fs)this.fs=e.fs;else{let{dataDir:a,fsType:h}=he(e.dataDir);this.fs=await ge(a,h)}let s={},o=[],r=[`PGDATA=${v}`,`PREFIX=${z}`,`PGUSER=${e.username??"postgres"}`,`PGDATABASE=${e.database??"template1"}`,"MODE=REACT","REPL=N",...this.debug?["-d",this.debug.toString()]:[]];e.wasmModule||de();let c=e.fsBundle?e.fsBundle.arrayBuffer():fe(),m;c.then(a=>{m=a});let l={WASM_PREFIX:z,arguments:r,INITIAL_MEMORY:e.initialMemory,noExitRuntime:!0,...this.debug>0?{print:console.info,printErr:console.error}:{print:()=>{},printErr:()=>{}},instantiateWasm:(a,h)=>(pe(a,e.wasmModule).then(({instance:g,module:b})=>{h(g,b)}),{}),getPreloadedPackage:(a,h)=>{if(a==="postgres.data"){if(m.byteLength!==h)throw new Error(`Invalid FS bundle size: ${m.byteLength} !== ${h}`);return m}throw new Error(`Unknown package: ${a}`)},preRun:[a=>{let h=a.FS.makedev(64,0),g={open:b=>{},close:b=>{},read:(b,G,T,S,x)=>{let se=n(this,R);if(!se)throw new Error("No /dev/blob File or Blob provided to read from");let H=new Uint8Array(se);if(x>=H.length)return 0;let ie=Math.min(H.length-x,S);for(let j=0;j<ie;j++)G[T+j]=H[x+j];return ie},write:(b,G,T,S,x)=>(n(this,F)??y(this,F,[]),n(this,F).push(G.slice(T,T+S)),S),llseek:(b,G,T)=>{let S=n(this,R);if(!S)throw new Error("No /dev/blob File or Blob provided to llseek");let x=G;if(T===1?x+=b.position:T===2&&(x=new Uint8Array(S).length),x<0)throw new a.FS.ErrnoError(28);return x}};a.FS.registerDevice(h,g),a.FS.mkdev("/dev/blob",h)}]},{emscriptenOpts:d}=await this.fs.init(this,l);l=d;for(let[a,h]of Object.entries(n(this,$)))if(h instanceof URL)s[a]=ee(h);else{let g=await h.setup(this,l);if(g.emscriptenOpts&&(l=g.emscriptenOpts),g.namespaceObj){let b=this;b[a]=g.namespaceObj}g.bundlePath&&(s[a]=ee(g.bundlePath)),g.init&&o.push(g.init),g.close&&n(this,C).push(g.close)}if(l.pg_extensions=s,await c,this.mod=await ye(l),await this.fs.initialSyncFs(),e.loadDataDir){if(this.mod.FS.analyzePath(v+"/PG_VERSION").exists)throw new Error("Database already exists, cannot load from tarball");B(this,P,W).call(this,"pglite: loading data from tarball"),await re(this.mod.FS,e.loadDataDir,v)}this.mod.FS.analyzePath(v+"/PG_VERSION").exists?B(this,P,W).call(this,"pglite: found DB, resuming"):B(this,P,W).call(this,"pglite: no db"),await be(this.mod,(...a)=>B(this,P,W).call(this,...a));let u=this.mod._pg_initdb();if(!u)throw new Error("INITDB failed to return value");if(u&1)throw new Error("INITDB failed");if(u&2){let a=e.username??"postgres",h=e.database??"template1";if(u&4){if(!(u&12))throw new Error("Invalid db/user combination")}else if(h!=="template1"&&a!=="postgres")throw new Error("INITDB created a new datadir, but an alternative db/user was requested")}await this.syncToFs(),y(this,I,!0),await this.exec("SET search_path TO public;"),await this._initArrayTypes();for(let a of o)await a()},W=function(...e){this.debug>0&&console.log(...e)};var xe=te;f();export{L as IdbFs,q as MemoryFS,M as Mutex,xe as PGlite,Oe as formatQuery,_e as messages,Se as parse,Fe as protocol,Te as types,Me as uuid}; | ||
import{a as ce}from"./chunk-4ZP5PNUC.js";import{e as ve,h as _e,i as re,j as ne,k as oe,l as ae,m as le,n as Te,o as J,p as Fe,q as ue,r as de,s as pe,t as fe,u as Re,v as Me}from"./chunk-JSQ47LU7.js";import{a as Se,b as me,c as j,d as P,e as V}from"./chunk-GMYUOGPV.js";import"./chunk-PZ27VTCT.js";import{c as Pe,d as n,e as p,f as y,g as I,i as f}from"./chunk-MPW3RCU6.js";f();f();f();var ke=new Error("timeout while waiting for mutex to become available"),Ge=new Error("mutex already locked"),Oe=new Error("request for lock canceled"),De=function(i,t,e,s){function o(r){return r instanceof e?r:new e(function(c){c(r)})}return new(e||(e=Promise))(function(r,c){function m(u){try{d(s.next(u))}catch(a){c(a)}}function l(u){try{d(s.throw(u))}catch(a){c(a)}}function d(u){u.done?r(u.value):o(u.value).then(m,l)}d((s=s.apply(i,t||[])).next())})},Z=class{constructor(t,e=Oe){this._value=t,this._cancelError=e,this._weightedQueues=[],this._weightedWaiters=[]}acquire(t=1){if(t<=0)throw new Error(`invalid weight ${t}: must be positive`);return new Promise((e,s)=>{this._weightedQueues[t-1]||(this._weightedQueues[t-1]=[]),this._weightedQueues[t-1].push({resolve:e,reject:s}),this._dispatch()})}runExclusive(t,e=1){return De(this,void 0,void 0,function*(){let[s,o]=yield this.acquire(e);try{return yield t(s)}finally{o()}})}waitForUnlock(t=1){if(t<=0)throw new Error(`invalid weight ${t}: must be positive`);return new Promise(e=>{this._weightedWaiters[t-1]||(this._weightedWaiters[t-1]=[]),this._weightedWaiters[t-1].push(e),this._dispatch()})}isLocked(){return this._value<=0}getValue(){return this._value}setValue(t){this._value=t,this._dispatch()}release(t=1){if(t<=0)throw new Error(`invalid weight ${t}: must be positive`);this._value+=t,this._dispatch()}cancel(){this._weightedQueues.forEach(t=>t.forEach(e=>e.reject(this._cancelError))),this._weightedQueues=[]}_dispatch(){var t;for(let e=this._value;e>0;e--){let s=(t=this._weightedQueues[e-1])===null||t===void 0?void 0:t.shift();if(!s)continue;let o=this._value,r=e;this._value-=e,e=this._value+1,s.resolve([o,this._newReleaser(r)])}this._drainUnlockWaiters()}_newReleaser(t){let e=!1;return()=>{e||(e=!0,this.release(t))}}_drainUnlockWaiters(){for(let t=this._value;t>0;t--)this._weightedWaiters[t-1]&&(this._weightedWaiters[t-1].forEach(e=>e()),this._weightedWaiters[t-1]=[])}},Ae=function(i,t,e,s){function o(r){return r instanceof e?r:new e(function(c){c(r)})}return new(e||(e=Promise))(function(r,c){function m(u){try{d(s.next(u))}catch(a){c(a)}}function l(u){try{d(s.throw(u))}catch(a){c(a)}}function d(u){u.done?r(u.value):o(u.value).then(m,l)}d((s=s.apply(i,t||[])).next())})},R=class{constructor(t){this._semaphore=new Z(1,t)}acquire(){return Ae(this,void 0,void 0,function*(){let[,t]=yield this._semaphore.acquire();return t})}runExclusive(t){return this._semaphore.runExclusive(()=>t())}isLocked(){return this._semaphore.isLocked()}waitForUnlock(){return this._semaphore.waitForUnlock()}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}};f();var ye=Pe(Se(),1);async function ee(i){if(ue){let t=await import("fs"),e=await import("zlib"),{Writable:s}=await import("stream"),{pipeline:o}=await import("stream/promises");if(!t.existsSync(i))throw new Error(`Extension bundle not found: ${i}`);let r=e.createGunzip(),c=[];return await o(t.createReadStream(i),r,new s({write(m,l,d){c.push(m),d()}})),new Blob(c)}else{let t=await fetch(i.toString());if(!t.ok||!t.body)return null;if(t.headers.get("Content-Encoding")==="gzip")return t.blob();{let e=new DecompressionStream("gzip");return new Response(t.body.pipeThrough(e)).blob()}}}async function he(i,t){for(let e in i.pg_extensions){let s;try{s=await i.pg_extensions[e]}catch(o){console.error("Failed to fetch extension:",e,o);continue}if(s){let o=new Uint8Array(await s.arrayBuffer());Ie(i,e,o,t)}else console.error("Could not get binary data for extension:",e)}}function Ie(i,t,e,s){ye.default.untar(e).forEach(r=>{if(!r.name.startsWith(".")){let c=i.WASM_PREFIX+"/"+r.name;if(r.name.endsWith(".so")){let m=(...d)=>{s("pgfs:ext OK",c,d)},l=(...d)=>{s("pgfs:ext FAIL",c,d)};i.FS.createPreloadedFile(Be(c),r.name.split("/").pop().slice(0,-3),r.data,!0,!0,m,l,!1)}else i.FS.writeFile(c,r.data)}})}function Be(i){let t=i.lastIndexOf("/");return t>0?i.slice(0,t):i}f();f();var q=class extends V{async init(t,e){return this.pg=t,{emscriptenOpts:{...e,preRun:[...e.preRun||[],o=>{let r=o.FS.filesystems.IDBFS;o.FS.mkdir("/pglite"),o.FS.mkdir(`/pglite/${this.dataDir}`),o.FS.mount(r,{},`/pglite/${this.dataDir}`),o.FS.symlink(`/pglite/${this.dataDir}`,P)}]}}}initialSyncFs(){return new Promise((t,e)=>{this.pg.Module.FS.syncfs(!0,s=>{s?e(s):t()})})}syncToFs(t){return new Promise((e,s)=>{this.pg.Module.FS.syncfs(!1,o=>{o?s(o):e()})})}async closeFs(){let t=this.pg.Module.FS.filesystems.IDBFS.dbs[this.dataDir];t&&t.close(),this.pg.Module.FS.quit()}};f();var L=class extends V{async closeFs(){this.pg.Module.FS.quit()}};function xe(i){let t;if(i?.startsWith("file://")){if(i=i.slice(7),!i)throw new Error("Invalid dataDir, must be a valid path");t="nodefs"}else i?.startsWith("idb://")?(i=i.slice(6),t="idbfs"):i?.startsWith("opfs-ahp://")?(i=i.slice(11),t="opfs-ahp"):!i||i?.startsWith("memory://")?t="memoryfs":t="nodefs";return{dataDir:i,fsType:t}}async function ge(i,t){let e;if(i&&t==="nodefs"){let{NodeFS:s}=await import("./fs/nodefs.js");e=new s(i)}else if(i&&t==="idbfs")e=new q(i);else if(i&&t==="opfs-ahp"){let{OpfsAhpFS:s}=await import("./fs/opfs-ahp.js");e=new s(i)}else e=new L;return e}f();import Ne from"./postgres.js";var we=Ne;var B,M,O,N,k,K,X,Y,G,z,$,C,D,T,g,A,E,Ee,W,te=class te extends ce{constructor(e={},s={}){super();p(this,E);p(this,B,!1);p(this,M,!1);p(this,O,!1);p(this,N,!1);p(this,k,!1);p(this,K,new R);p(this,X,new R);p(this,Y,new R);p(this,G,!1);this.debug=0;p(this,z);p(this,$,[]);p(this,C,new J);p(this,D);p(this,T);p(this,g,new Map);p(this,A,new Set);typeof e=="string"?s={dataDir:e,...s}:s=e,this.dataDir=s.dataDir,s.parsers!==void 0&&(this.parsers={...this.parsers,...s.parsers}),s.serializers!==void 0&&(this.serializers={...this.serializers,...s.serializers}),s?.debug!==void 0&&(this.debug=s.debug),s?.relaxedDurability!==void 0&&y(this,k,s.relaxedDurability),y(this,z,s.extensions??{}),this.waitReady=I(this,E,Ee).call(this,s??{})}static async create(e,s){let o=typeof e=="string"?{dataDir:e,...s??{}}:e??{},r=new te(o);return await r.waitReady,r}get Module(){return this.mod}get ready(){return n(this,B)&&!n(this,M)&&!n(this,O)}get closed(){return n(this,O)}async close(){await this._checkReady(),y(this,M,!0);for(let e of n(this,$))await e();try{await this.execProtocol(re.end()),this.mod._pg_shutdown()}catch(e){let s=e;if(!(s.name==="ExitStatus"&&s.status===0))throw e}await this.fs.closeFs(),y(this,O,!0),y(this,M,!1)}async[Symbol.asyncDispose](){await this.close()}async _handleBlob(e){y(this,D,e?await e.arrayBuffer():void 0)}async _cleanupBlob(){y(this,D,void 0)}async _getWrittenBlob(){if(!n(this,T))return;let e=new Blob(n(this,T));return y(this,T,void 0),e}async _checkReady(){if(n(this,M))throw new Error("PGlite is closing");if(n(this,O))throw new Error("PGlite is closed");n(this,B)||await this.waitReady}async execProtocolRaw(e,{syncToFs:s=!0}={}){let o=e.length,r=this.mod;r._interactive_write(o),r.HEAPU8.set(e,1),r._interactive_one();let c=o+2,m=c+r._interactive_read(),l=r.HEAPU8.subarray(c,m);return s&&await this.syncToFs(),l}async execProtocol(e,{syncToFs:s=!0,throwOnError:o=!0,onNotice:r}={}){let c=await this.execProtocolRaw(e,{syncToFs:s}),m=[];return n(this,C).parse(c,l=>{if(l instanceof ne){if(y(this,C,new J),o)throw l}else if(l instanceof le)this.debug>0&&console.warn(l),r&&r(l);else if(l instanceof ae)switch(l.text){case"BEGIN":y(this,N,!0);break;case"COMMIT":case"ROLLBACK":y(this,N,!1);break}else if(l instanceof oe){let d=n(this,g).get(l.channel);d&&d.forEach(u=>{queueMicrotask(()=>u(l.payload))}),n(this,A).forEach(u=>{queueMicrotask(()=>u(l.channel,l.payload))})}m.push(l)}),{messages:m,data:c}}isInTransaction(){return n(this,N)}async syncToFs(){if(n(this,G))return;y(this,G,!0);let e=async()=>{await n(this,Y).runExclusive(async()=>{y(this,G,!1),await this.fs.syncToFs(n(this,k))})};n(this,k)?e():await e()}async listen(e,s){return n(this,g).has(e)||n(this,g).set(e,new Set),n(this,g).get(e).add(s),await this.exec(`LISTEN "${e}"`),async()=>{await this.unlisten(e,s)}}async unlisten(e,s){s?(n(this,g).get(e)?.delete(s),n(this,g).get(e)?.size===0&&(await this.exec(`UNLISTEN "${e}"`),n(this,g).delete(e))):(await this.exec(`UNLISTEN "${e}"`),n(this,g).delete(e))}onNotification(e){return n(this,A).add(e),()=>{n(this,A).delete(e)}}offNotification(e){n(this,A).delete(e)}async dumpDataDir(e){let s=this.dataDir?.split("/").pop()??"pgdata";return this.fs.dumpTar(s,e)}_runExclusiveQuery(e){return n(this,K).runExclusive(e)}_runExclusiveTransaction(e){return n(this,X).runExclusive(e)}};B=new WeakMap,M=new WeakMap,O=new WeakMap,N=new WeakMap,k=new WeakMap,K=new WeakMap,X=new WeakMap,Y=new WeakMap,G=new WeakMap,z=new WeakMap,$=new WeakMap,C=new WeakMap,D=new WeakMap,T=new WeakMap,g=new WeakMap,A=new WeakMap,E=new WeakSet,Ee=async function(e){if(e.fs)this.fs=e.fs;else{let{dataDir:a,fsType:h}=xe(e.dataDir);this.fs=await ge(a,h)}let s={},o=[],r=[`PGDATA=${P}`,`PREFIX=${j}`,`PGUSER=${e.username??"postgres"}`,`PGDATABASE=${e.database??"template1"}`,"MODE=REACT","REPL=N",...this.debug?["-d",this.debug.toString()]:[]];e.wasmModule||de();let c=e.fsBundle?e.fsBundle.arrayBuffer():fe(),m;c.then(a=>{m=a});let l={WASM_PREFIX:j,arguments:r,INITIAL_MEMORY:e.initialMemory,noExitRuntime:!0,...this.debug>0?{print:console.info,printErr:console.error}:{print:()=>{},printErr:()=>{}},instantiateWasm:(a,h)=>(pe(a,e.wasmModule).then(({instance:x,module:w})=>{h(x,w)}),{}),getPreloadedPackage:(a,h)=>{if(a==="postgres.data"){if(m.byteLength!==h)throw new Error(`Invalid FS bundle size: ${m.byteLength} !== ${h}`);return m}throw new Error(`Unknown package: ${a}`)},preRun:[a=>{let h=a.FS.makedev(64,0),x={open:w=>{},close:w=>{},read:(w,U,F,S,b)=>{let se=n(this,D);if(!se)throw new Error("No /dev/blob File or Blob provided to read from");let H=new Uint8Array(se);if(b>=H.length)return 0;let ie=Math.min(H.length-b,S);for(let Q=0;Q<ie;Q++)U[F+Q]=H[b+Q];return ie},write:(w,U,F,S,b)=>(n(this,T)??y(this,T,[]),n(this,T).push(U.slice(F,F+S)),S),llseek:(w,U,F)=>{let S=n(this,D);if(!S)throw new Error("No /dev/blob File or Blob provided to llseek");let b=U;if(F===1?b+=w.position:F===2&&(b=new Uint8Array(S).length),b<0)throw new a.FS.ErrnoError(28);return b}};a.FS.registerDevice(h,x),a.FS.mkdev("/dev/blob",h)}]},{emscriptenOpts:d}=await this.fs.init(this,l);l=d;for(let[a,h]of Object.entries(n(this,z)))if(h instanceof URL)s[a]=ee(h);else{let x=await h.setup(this,l);if(x.emscriptenOpts&&(l=x.emscriptenOpts),x.namespaceObj){let w=this;w[a]=x.namespaceObj}x.bundlePath&&(s[a]=ee(x.bundlePath)),x.init&&o.push(x.init),x.close&&n(this,$).push(x.close)}if(l.pg_extensions=s,await c,this.mod=await we(l),await this.fs.initialSyncFs(),e.loadDataDir){if(this.mod.FS.analyzePath(P+"/PG_VERSION").exists)throw new Error("Database already exists, cannot load from tarball");I(this,E,W).call(this,"pglite: loading data from tarball"),await me(this.mod.FS,e.loadDataDir,P)}this.mod.FS.analyzePath(P+"/PG_VERSION").exists?I(this,E,W).call(this,"pglite: found DB, resuming"):I(this,E,W).call(this,"pglite: no db"),await he(this.mod,(...a)=>I(this,E,W).call(this,...a));let u=this.mod._pg_initdb();if(!u)throw new Error("INITDB failed to return value");if(u&1)throw new Error("INITDB failed");if(u&2){let a=e.username??"postgres",h=e.database??"template1";if(u&4){if(!(u&12))throw new Error("Invalid db/user combination")}else if(h!=="template1"&&a!=="postgres")throw new Error("INITDB created a new datadir, but an alternative db/user was requested")}await this.syncToFs(),y(this,B,!0),await this.exec("SET search_path TO public;"),await this._initArrayTypes();for(let a of o)await a()},W=function(...e){this.debug>0&&console.log(...e)};var be=te;f();export{q as IdbFs,L as MemoryFS,R as Mutex,be as PGlite,Me as formatQuery,Te as messages,_e as parse,Fe as protocol,ve as types,Re as uuid}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,3 +0,29 @@ | ||
import { R as Results, d as PGliteInterface } from '../pglite-BvWM7BTQ.js'; | ||
import { R as Results, d as PGliteInterface } from '../pglite-DnNPQGYh.js'; | ||
interface LiveQueryOptions<T = { | ||
[key: string]: any; | ||
}> { | ||
query: string; | ||
params?: any[] | null; | ||
callback?: (results: Results<T>) => void; | ||
signal?: AbortSignal; | ||
} | ||
interface LiveChangesOptions<T = { | ||
[key: string]: any; | ||
}> { | ||
query: string; | ||
params?: any[] | null; | ||
key: string; | ||
callback?: (changes: Array<Change<T>>) => void; | ||
signal?: AbortSignal; | ||
} | ||
interface LiveIncrementalQueryOptions<T = { | ||
[key: string]: any; | ||
}> { | ||
query: string; | ||
params?: any[] | null; | ||
key: string; | ||
callback?: (results: Results<T>) => void; | ||
signal?: AbortSignal; | ||
} | ||
interface LiveNamespace { | ||
@@ -14,4 +40,13 @@ /** | ||
[key: string]: any; | ||
}>(query: string, params: any[] | undefined | null, callback: (results: Results<T>) => void): Promise<LiveQueryReturn<T>>; | ||
}>(query: string, params?: any[] | null, callback?: (results: Results<T>) => void): Promise<LiveQuery<T>>; | ||
/** | ||
* Create a live query | ||
* @param options - The options to pass to the query | ||
* @returns A promise that resolves to an object with the initial results, | ||
* an unsubscribe function, and a refresh function | ||
*/ | ||
query<T = { | ||
[key: string]: any; | ||
}>(options: LiveQueryOptions<T>): Promise<LiveQuery<T>>; | ||
/** | ||
* Create a live query that returns the changes to the query results | ||
@@ -26,4 +61,13 @@ * @param query - The query to run | ||
[key: string]: any; | ||
}>(query: string, params: any[] | undefined | null, key: string, callback: (changes: Array<Change<T>>) => void): Promise<LiveChangesReturn<T>>; | ||
}>(query: string, params: any[] | undefined | null, key: string, callback?: (changes: Array<Change<T>>) => void): Promise<LiveChanges<T>>; | ||
/** | ||
* Create a live query that returns the changes to the query results | ||
* @param options - The options to pass to the query | ||
* @returns A promise that resolves to an object with the initial changes, | ||
* an unsubscribe function, and a refresh function | ||
*/ | ||
changes<T = { | ||
[key: string]: any; | ||
}>(options: LiveChangesOptions<T>): Promise<LiveChanges<T>>; | ||
/** | ||
* Create a live query with incremental updates | ||
@@ -38,10 +82,20 @@ * @param query - The query to run | ||
[key: string]: any; | ||
}>(query: string, params: any[] | undefined | null, key: string, callback: (results: Results<T>) => void): Promise<LiveQueryReturn<T>>; | ||
}>(query: string, params: any[] | undefined | null, key: string, callback?: (results: Results<T>) => void): Promise<LiveQuery<T>>; | ||
/** | ||
* Create a live query with incremental updates | ||
* @param options - The options to pass to the query | ||
* @returns A promise that resolves to an object with the initial results, | ||
* an unsubscribe function, and a refresh function | ||
*/ | ||
incrementalQuery<T = { | ||
[key: string]: any; | ||
}>(options: LiveIncrementalQueryOptions<T>): Promise<LiveQuery<T>>; | ||
} | ||
interface LiveQueryReturn<T> { | ||
interface LiveQuery<T> { | ||
initialResults: Results<T>; | ||
unsubscribe: () => Promise<void>; | ||
subscribe: (callback: (results: Results<T>) => void) => void; | ||
unsubscribe: (callback?: (results: Results<T>) => void) => Promise<void>; | ||
refresh: () => Promise<void>; | ||
} | ||
interface LiveChangesReturn<T = { | ||
interface LiveChanges<T = { | ||
[key: string]: any; | ||
@@ -54,3 +108,4 @@ }> { | ||
initialChanges: Array<Change<T>>; | ||
unsubscribe: () => Promise<void>; | ||
subscribe: (callback: (changes: Array<Change<T>>) => void) => void; | ||
unsubscribe: (callback?: (changes: Array<Change<T>>) => void) => Promise<void>; | ||
refresh: () => Promise<void>; | ||
@@ -84,6 +139,6 @@ } | ||
}; | ||
type PGliteWithLive = PGliteInterface & { | ||
live: LiveNamespace; | ||
}; | ||
type PGliteWithLive = PGliteInterface<{ | ||
live: typeof live; | ||
}>; | ||
export { type Change, type LiveChangesReturn, type LiveNamespace, type LiveQueryReturn, type PGliteWithLive, live }; | ||
export { type Change, type LiveChanges, type LiveNamespace, type LiveQuery, type PGliteWithLive, live }; |
@@ -1,19 +0,19 @@ | ||
import{u as d,v as g}from"../chunk-IZM3GSNN.js";import{i as I}from"../chunk-Y3AVQXKT.js";I();var h=5,C=async(E,v)=>{let f=new Set,A={async query(r,p,t){let c=d().replace(/-/g,""),e,o,l=async()=>{await E.transaction(async n=>{let T=await g(E,r,p,n);await n.query(`CREATE OR REPLACE TEMP VIEW live_query_${c}_view AS ${T}`),o=await w(n,`live_query_${c}_view`),await O(n,o,f),await n.exec(` | ||
PREPARE live_query_${c}_get AS | ||
SELECT * FROM live_query_${c}_view; | ||
`),e=await n.query(`EXECUTE live_query_${c}_get;`)})};await l();let u=async(n=0)=>{try{e=await E.query(`EXECUTE live_query_${c}_get;`)}catch(T){if(T.message===`prepared statement "live_query_${c}_get" does not exist`){if(n>h)throw T;await l(),u(n+1)}else throw T}t(e)},m=await Promise.all(o.map(n=>E.listen(`table_change__${n.schema_name}__${n.table_name}`,async()=>{u()}))),y=async()=>{await Promise.all(m.map(n=>n())),await E.exec(` | ||
DROP VIEW IF EXISTS live_query_${c}_view; | ||
DEALLOCATE live_query_${c}_get; | ||
`)};return t(e),{initialResults:e,unsubscribe:y,refresh:u}},async changes(r,p,t,c){let e=d().replace(/-/g,""),o,l=1,u,m=async()=>{await E.transaction(async s=>{let R=await g(E,r,p,s);await s.query(`CREATE OR REPLACE TEMP VIEW live_query_${e}_view AS ${R}`),o=await w(s,`live_query_${e}_view`),await O(s,o,f);let _=[...(await s.query(` | ||
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(` | ||
SELECT column_name, data_type, udt_name | ||
FROM information_schema.columns | ||
WHERE table_name = 'live_query_${e}_view' | ||
`)).rows,{column_name:"__after__",data_type:"integer"}];await s.exec(` | ||
CREATE TEMP TABLE live_query_${e}_state1 (LIKE live_query_${e}_view INCLUDING ALL); | ||
CREATE TEMP TABLE live_query_${e}_state2 (LIKE live_query_${e}_view INCLUDING ALL); | ||
`);for(let $ of[1,2]){let i=$===1?2:1;await s.exec(` | ||
PREPARE live_query_${e}_diff${$} AS | ||
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 | ||
WITH | ||
prev AS (SELECT LAG("${t}") OVER () as __after__, * FROM live_query_${e}_state${i}), | ||
curr AS (SELECT LAG("${t}") OVER () as __after__, * FROM live_query_${e}_state${$}), | ||
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}), | ||
data_diff AS ( | ||
@@ -23,8 +23,8 @@ -- INSERT operations: Include all columns | ||
'INSERT' AS __op__, | ||
${_.map(({column_name:a})=>`curr."${a}" AS "${a}"`).join(`, | ||
${c.map(({column_name:s})=>`curr."${s}" AS "${s}"`).join(`, | ||
`)}, | ||
ARRAY[]::text[] AS __changed_columns__ | ||
FROM curr | ||
LEFT JOIN prev ON curr.${t} = prev.${t} | ||
WHERE prev.${t} IS NULL | ||
LEFT JOIN prev ON curr.${a} = prev.${a} | ||
WHERE prev.${a} IS NULL | ||
UNION ALL | ||
@@ -34,8 +34,8 @@ -- DELETE operations: Include only the primary key | ||
'DELETE' AS __op__, | ||
${_.map(({column_name:a,data_type:L,udt_name:N})=>a===t?`prev."${a}" AS "${a}"`:`NULL${L==="USER-DEFINED"?`::${N}`:""} AS "${a}"`).join(`, | ||
${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(`, | ||
`)}, | ||
ARRAY[]::text[] AS __changed_columns__ | ||
FROM prev | ||
LEFT JOIN curr ON prev.${t} = curr.${t} | ||
WHERE curr.${t} IS NULL | ||
LEFT JOIN curr ON prev.${a} = curr.${a} | ||
WHERE curr.${a} IS NULL | ||
UNION ALL | ||
@@ -45,32 +45,34 @@ -- UPDATE operations: Include only changed columns | ||
'UPDATE' AS __op__, | ||
${_.map(({column_name:a,data_type:L,udt_name:N})=>a===t?`curr."${a}" AS "${a}"`:`CASE | ||
WHEN curr."${a}" IS DISTINCT FROM prev."${a}" | ||
THEN curr."${a}" | ||
ELSE NULL${L==="USER-DEFINED"?`::${N}`:""} | ||
END AS "${a}"`).join(`, | ||
${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(`, | ||
`)}, | ||
ARRAY(SELECT unnest FROM unnest(ARRAY[${_.filter(({column_name:a})=>a!==t).map(({column_name:a})=>`CASE | ||
WHEN curr."${a}" IS DISTINCT FROM prev."${a}" | ||
THEN '${a}' | ||
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}' | ||
ELSE NULL | ||
END`).join(", ")}]) WHERE unnest IS NOT NULL) AS __changed_columns__ | ||
FROM curr | ||
INNER JOIN prev ON curr.${t} = prev.${t} | ||
INNER JOIN prev ON curr.${a} = prev.${a} | ||
WHERE NOT (curr IS NOT DISTINCT FROM prev) | ||
) | ||
SELECT * FROM data_diff; | ||
`)}})};await m();let y=async()=>{let s=!1;for(let R=0;R<5;R++)try{await E.transaction(async _=>{await _.exec(` | ||
DELETE FROM live_query_${e}_state${l}; | ||
INSERT INTO live_query_${e}_state${l} | ||
SELECT * FROM live_query_${e}_view; | ||
`),u=await _.query(`EXECUTE live_query_${e}_diff${l};`)});break}catch(_){if(_.message===`relation "live_query_${e}_state${l}" does not exist`){s=!0,await m();continue}else throw _}l=l===1?2:1,c([...s?[{__op__:"RESET"}]:[],...u.rows])},n=await Promise.all(o.map(s=>E.listen(`table_change__${s.schema_name}__${s.table_name}`,async()=>y()))),T=async()=>{await Promise.all(n.map(s=>s())),await E.exec(` | ||
DROP VIEW IF EXISTS live_query_${e}_view; | ||
DROP TABLE IF EXISTS live_query_${e}_state1; | ||
DROP TABLE IF EXISTS live_query_${e}_state2; | ||
DEALLOCATE live_query_${e}_diff1; | ||
DEALLOCATE live_query_${e}_diff2; | ||
`)};return await y(),{fields:u.fields.filter(s=>!["__after__","__op__","__changed_columns__"].includes(s.name)),initialChanges:u.rows,unsubscribe:T,refresh:y}},async incrementalQuery(r,p,t,c){let e=new Map,o=new Map,l=[],u=!0,{fields:m,unsubscribe:y,refresh:n}=await A.changes(r,p,t,T=>{for(let R of T){let{__op__:_,__changed_columns__:$,...i}=R;switch(_){case"RESET":e.clear(),o.clear();break;case"INSERT":e.set(i[t],i),o.set(i.__after__,i[t]);break;case"DELETE":{let a=e.get(i[t]);e.delete(i[t]),o.delete(a.__after__);break}case"UPDATE":{let a={...e.get(i[t])??{}};for(let L of $)a[L]=i[L],L==="__after__"&&o.set(i.__after__,i[t]);e.set(i[t],a);break}}}let S=[],s=null;for(let R=0;R<e.size;R++){let _=o.get(s),$=e.get(_);if(!$)break;let i={...$};delete i.__after__,S.push(i),s=_}l=S,u||c({rows:S,fields:m})});return u=!1,c({rows:l,fields:m}),{initialResults:{rows:l,fields:m},unsubscribe:y,refresh:n}}};return{namespaceObj:A}},b={name:"Live Queries",setup:C};async function w(E,v){return(await E.query(` | ||
`)}})};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(` | ||
SELECT DISTINCT | ||
cl.relname AS table_name, | ||
n.nspname AS schema_name | ||
n.nspname AS schema_name, | ||
cl.relkind = 'v' AS is_view | ||
FROM pg_rewrite r | ||
@@ -85,14 +87,14 @@ JOIN pg_depend d ON r.oid = d.objid | ||
AND d.deptype = 'n'; | ||
`,[v])).rows.filter(f=>f.table_name!==v)}async function O(E,v,f){let A=v.filter(r=>!f.has(`${r.schema_name}_${r.table_name}`)).map(r=>` | ||
CREATE OR REPLACE FUNCTION "_notify_${r.schema_name}_${r.table_name}"() RETURNS TRIGGER AS $$ | ||
`,[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=>` | ||
CREATE OR REPLACE FUNCTION "_notify_${e.schema_name}_${e.table_name}"() RETURNS TRIGGER AS $$ | ||
BEGIN | ||
PERFORM pg_notify('table_change__${r.schema_name}__${r.table_name}', ''); | ||
PERFORM pg_notify('table_change__${e.schema_name}__${e.table_name}', ''); | ||
RETURN NULL; | ||
END; | ||
$$ LANGUAGE plpgsql; | ||
CREATE OR REPLACE TRIGGER "_notify_trigger_${r.schema_name}_${r.table_name}" | ||
AFTER INSERT OR UPDATE OR DELETE ON "${r.schema_name}"."${r.table_name}" | ||
FOR EACH STATEMENT EXECUTE FUNCTION "_notify_${r.schema_name}_${r.table_name}"(); | ||
CREATE OR REPLACE TRIGGER "_notify_trigger_${e.schema_name}_${e.table_name}" | ||
AFTER INSERT OR UPDATE OR DELETE ON "${e.schema_name}"."${e.table_name}" | ||
FOR EACH STATEMENT EXECUTE FUNCTION "_notify_${e.schema_name}_${e.table_name}"(); | ||
`).join(` | ||
`);A.trim()!==""&&await E.exec(A),v.map(r=>f.add(`${r.schema_name}_${r.table_name}`))}export{b as live}; | ||
`);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}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import{a,b,c,d}from"./chunk-EL7DUS2A.js";import"./chunk-Y3AVQXKT.js";export{b as identifier,d as query,c as raw,a as sql}; | ||
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}; | ||
//# sourceMappingURL=templating.js.map |
@@ -1,2 +0,2 @@ | ||
import { d as PGliteInterface } from '../pglite-BvWM7BTQ.js'; | ||
import { d as PGliteInterface } from '../pglite-DnNPQGYh.js'; | ||
@@ -3,0 +3,0 @@ declare const vector: { |
@@ -1,2 +0,2 @@ | ||
import{i as e}from"../chunk-Y3AVQXKT.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{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}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import { n as PGliteOptions, s as BasePGlite, d as PGliteInterface, o as PGliteInterfaceExtensions, D as DebugLevel, B as BackendMessage, b as PGlite } from '../pglite-BvWM7BTQ.js'; | ||
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'; | ||
@@ -62,3 +62,3 @@ type PGliteWorkerOptions = PGliteOptions & { | ||
*/ | ||
execProtocol(message: Uint8Array): Promise<Array<[BackendMessage, Uint8Array]>>; | ||
execProtocol(message: Uint8Array): Promise<ExecProtocolResult>; | ||
/** | ||
@@ -65,0 +65,0 @@ * Sync the database to the filesystem |
@@ -1,2 +0,2 @@ | ||
import{a as j}from"../chunk-NMYRYYP2.js";import"../chunk-EL7DUS2A.js";import{u as U}from"../chunk-IZM3GSNN.js";import{d as t,e as l,f as y,g as h,i as Q}from"../chunk-Y3AVQXKT.js";Q();var W,B,_,M,A,m,L,b,k,C,T,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,B,0);l(this,_,!1);l(this,M,!1);l(this,A,!1);l(this,m,new EventTarget);l(this,L);l(this,b,!1);l(this,k);l(this,C);l(this,T);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,$,[]);y(this,k,e),y(this,L,U()),y(this,I,r?.extensions??{}),y(this,T,new Promise(d=>{t(this,k).addEventListener("message",s=>{if(s.data.type==="here")d();else throw new Error("Invalid message")},{once:!0})})),y(this,O,new Promise(d=>{let s=c=>{c.data.type==="ready"&&(y(this,C,c.data.id),t(this,k).removeEventListener("message",s),d())};t(this,k).addEventListener("message",s)})),y(this,W,h(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,B)}get ready(){return t(this,_)}get closed(){return t(this,M)}get isLeader(){return t(this,A)}async close(){var e;t(this,M)||(y(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 h(this,o,w).call(this,"execProtocolRaw",e)}async execProtocol(e){return await h(this,o,w).call(this,"execProtocol",e)}async syncToFs(){await h(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 h(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 h(this,o,w).call(this,"_handleBlob",e)}async _getWrittenBlob(){return await h(this,o,w).call(this,"_getWrittenBlob")}async _cleanupBlob(){await h(this,o,w).call(this,"_cleanupBlob")}async _checkReady(){await this.waitReady}async _runExclusiveQuery(e){await h(this,o,w).call(this,"_acquireQueryLock");try{return await e()}finally{await h(this,o,w).call(this,"_releaseQueryLock")}}async _runExclusiveTransaction(e){await h(this,o,w).call(this,"_acquireTransactionLock");try{return await e()}finally{await h(this,o,w).call(this,"_releaseTransactionLock")}}};W=new WeakMap,B=new WeakMap,_=new WeakMap,M=new WeakMap,A=new WeakMap,m=new WeakMap,L=new WeakMap,b=new WeakMap,k=new WeakMap,C=new WeakMap,T=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[i,u]of Object.entries(t(this,I))){if(u instanceof URL)throw new Error("URL extensions are not supported on the client side of a worker");{let a=await u.setup(this,{},!0);if(a.emscriptenOpts&&console.warn(`PGlite extension ${i} returned emscriptenOpts, these are not supported on the client side of a worker`),a.namespaceObj){let E=this;E[i]=a.namespaceObj}a.bundlePath&&console.warn(`PGlite extension ${i} returned bundlePath, this is not supported on the client side of a worker`),a.init&&await a.init(),a.close&&t(this,$).push(a.close)}}await t(this,T);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)}`;y(this,G,await N(s));let c=`pglite-broadcast:${t(this,C)}`;y(this,x,new BroadcastChannel(c));let p=`pglite-tab:${t(this,L)}`;y(this,v,new BroadcastChannel(p)),t(this,x).addEventListener("message",async i=>{i.data.type==="leader-here"?(y(this,b,!1),t(this,m).dispatchEvent(new Event("leader-change")),h(this,o,D).call(this)):i.data.type==="notify"&&h(this,o,K).call(this,i.data.channel,i.data.payload)}),t(this,v).addEventListener("message",async i=>{i.data.type==="connected"&&(y(this,b,!0),t(this,m).dispatchEvent(new Event("connected")),y(this,B,await h(this,o,w).call(this,"getDebugLevel")),y(this,_,!0))}),t(this,k).addEventListener("message",async i=>{i.data.type==="leader-now"&&(y(this,A,!0),t(this,m).dispatchEvent(new Event("leader-change")))}),h(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(()=>h(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((c,p)=>{let i=E=>{if(E.data.callId!==d)return;a();let f=E.data;if(f.type==="rpc-return")c(f.result);else if(f.type==="rpc-error"){let S=new Error(f.error.message);Object.assign(S,f.error),p(S)}else p(new Error("Invalid message"))},u=()=>{a(),p(new q)},a=()=>{t(this,v).removeEventListener("message",i),t(this,m).removeEventListener("leader-change",u)};t(this,m).addEventListener("leader-change",u),t(this,v).addEventListener("message",i)})},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 n=await new Promise(u=>{addEventListener("message",a=>{a.data.type==="init"&&u(a.data.options)},{once:!0})}),e=n.id??`${import.meta.url}:${n.dataDir??""}`;postMessage({type:"ready",id:e});let r=`pglite-election-lock:${e}`,d=`pglite-broadcast:${e}`,s=new BroadcastChannel(d),c=new Set;await N(r);let p=g(n);s.onmessage=async u=>{let a=u.data;switch(a.type){case"tab-here":J(a.id,await p,c);break}},s.postMessage({type:"leader-here",id:e}),postMessage({type:"leader-now"}),(await p).onNotification((u,a)=>{s.postMessage({type:"notify",channel:u,payload:a})})}function J(g,n,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(p=>{s.close(),e.delete(g),p()}));let c=V(g,n);s.addEventListener("message",async p=>{let i=p.data;switch(i.type){case"rpc-call":{await n.waitReady;let{callId:u,method:a,args:E}=i;try{let f=await c[a](...E);s.postMessage({type:"rpc-return",callId:u,result:f})}catch(f){console.error(f),s.postMessage({type:"rpc-error",callId:u,error:{message:f.message}})}break}}}),s.postMessage({type:"connected"})}function V(g,n){let e=null,r=null,d=`pglite-tab-close:${g}`;return N(d).then(()=>{r&&n.exec("ROLLBACK"),e?.(),r?.()}),{async getDebugLevel(){return n.debug},async close(){await n.close()},async execProtocol(s){return(await n.execProtocol(s)).map(([p,i])=>{if(i.byteLength!==i.buffer.byteLength){let u=new ArrayBuffer(i.byteLength),a=new Uint8Array(u);return a.set(i),[p,a]}else return[p,i]})},async execProtocolRaw(s){let c=await n.execProtocolRaw(s);if(c.byteLength!==c.buffer.byteLength){let p=new ArrayBuffer(c.byteLength),i=new Uint8Array(p);return i.set(c),i}else return c},async dumpDataDir(){return await n.dumpDataDir()},async syncToFs(){return await n.syncToFs()},async _handleBlob(s){return await n._handleBlob(s)},async _getWrittenBlob(){return await n._getWrittenBlob()},async _cleanupBlob(){return await n._cleanupBlob()},async _checkReady(){return await n._checkReady()},async _acquireQueryLock(){return new Promise(s=>{n._runExclusiveQuery(()=>new Promise(c=>{e=c,s()}))})},async _releaseQueryLock(){e?.(),e=null},async _acquireTransactionLock(){return new Promise(s=>{n._runExclusiveTransaction(()=>new Promise(c=>{r=c,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 n;return await new Promise(e=>{navigator.locks.request(g,()=>new Promise(r=>{n=r,e()}))}),n}export{q as LeaderChangedError,z as PGliteWorker,te as worker}; | ||
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}; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@electric-sql/pglite", | ||
"version": "0.2.12", | ||
"version": "0.2.13", | ||
"private": false, | ||
@@ -23,40 +23,40 @@ "publishConfig": { | ||
".": { | ||
"types": "./dist/index.d.ts", | ||
"import": "./dist/index.js", | ||
"require": "./dist/index.cjs", | ||
"types": "./dist/index.d.ts" | ||
"require": "./dist/index.cjs" | ||
}, | ||
"./template": { | ||
"types": "./dist/templating.d.ts", | ||
"import": "./dist/templating.js", | ||
"require": "./dist/templating.cjs", | ||
"types": "./dist/templating.d.ts" | ||
"require": "./dist/templating.cjs" | ||
}, | ||
"./live": { | ||
"types": "./dist/live/index.d.ts", | ||
"import": "./dist/live/index.js", | ||
"require": "./dist/live/index.cjs", | ||
"types": "./dist/live/index.d.ts" | ||
"require": "./dist/live/index.cjs" | ||
}, | ||
"./worker": { | ||
"types": "./dist/worker/index.d.ts", | ||
"import": "./dist/worker/index.js", | ||
"require": "./dist/worker/index.cjs", | ||
"types": "./dist/worker/index.d.ts" | ||
"require": "./dist/worker/index.cjs" | ||
}, | ||
"./vector": { | ||
"types": "./dist/vector/index.d.ts", | ||
"import": "./dist/vector/index.js", | ||
"require": "./dist/vector/index.cjs", | ||
"types": "./dist/vector/index.d.ts" | ||
"require": "./dist/vector/index.cjs" | ||
}, | ||
"./nodefs": { | ||
"types": "./dist/fs/nodefs.d.ts", | ||
"import": "./dist/fs/nodefs.js", | ||
"require": "./dist/fs/nodefs.cjs", | ||
"types": "./dist/fs/nodefs.d.ts" | ||
"require": "./dist/fs/nodefs.cjs" | ||
}, | ||
"./opfs-ahp": { | ||
"types": "./dist/fs/opfs-ahp.d.ts", | ||
"import": "./dist/fs/opfs-ahp.js", | ||
"require": "./dist/fs/opfs-ahp.cjs", | ||
"types": "./dist/fs/opfs-ahp.d.ts" | ||
"require": "./dist/fs/opfs-ahp.cjs" | ||
}, | ||
"./contrib/*": { | ||
"types": "./dist/contrib/*.d.ts", | ||
"import": "./dist/contrib/*.js", | ||
"require": "./dist/contrib/*.cjs", | ||
"types": "./dist/contrib/*.d.ts" | ||
"require": "./dist/contrib/*.cjs" | ||
} | ||
@@ -76,14 +76,13 @@ }, | ||
"@types/emscripten": "^1.39.13", | ||
"@types/node": "^20.11.18", | ||
"@types/node": "^20.16.11", | ||
"@types/node-fetch": "^2.6.11", | ||
"async-mutex": "^0.4.1", | ||
"buffer": "^6.0.3", | ||
"bun": "^1.1.18", | ||
"bun": "^1.1.30", | ||
"concurrently": "^8.2.2", | ||
"http-server": "^14.1.1", | ||
"playwright": "^1.42.1", | ||
"serve": "^14.2.3", | ||
"playwright": "^1.48.0", | ||
"tinytar": "^0.1.0", | ||
"vitest": "^2.0.5", | ||
"@electric-sql/pg-protocol": "0.0.1" | ||
"vitest": "^2.1.2", | ||
"@electric-sql/pg-protocol": "0.0.2" | ||
}, | ||
@@ -90,0 +89,0 @@ "browser": { |
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 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 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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 49 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17064754
12
15156
6
71