2 lines
8.3 KiB
JavaScript
2 lines
8.3 KiB
JavaScript
|
|
import{a as j}from"../chunk-F2DQ4FIK.js";import{u as U,x as z}from"../chunk-3WWIVTCY.js";import"../chunk-F4GETNPB.js";import{e as t,f as p,g as u,h,j as Q}from"../chunk-QY3QWFKW.js";Q();var W,T,C,M,B,w,x,L,P,_,A,O,E,v,G,k,b,I,$,c,K,D,g,J,q=class q extends j{constructor(e,r){super();p(this,c);p(this,W);p(this,T,0);p(this,C,!1);p(this,M,!1);p(this,B,!1);p(this,w,new EventTarget);p(this,x);p(this,L,!1);p(this,P);p(this,_);p(this,A);p(this,O);p(this,E);p(this,v);p(this,G);p(this,k,new Map);p(this,b,new Set);p(this,I);p(this,$,[]);u(this,P,e),u(this,x,U()),u(this,I,r?.extensions??{}),u(this,A,new Promise(a=>{t(this,P).addEventListener("message",s=>{if(s.data.type==="here")a();else throw new Error("Invalid message")},{once:!0})})),u(this,O,new Promise(a=>{let s=n=>{n.data.type==="ready"&&(u(this,_,n.data.id),t(this,P).removeEventListener("message",s),a())};t(this,P).addEventListener("message",s)})),u(this,W,h(this,c,K).call(this,r))}static async create(e,r){let a=new q(e,r);return await t(a,W),a}get waitReady(){return new Promise(e=>{t(this,W).then(()=>{t(this,L)?e():e(new Promise(r=>{t(this,w).addEventListener("connected",()=>{r()})}))})})}get debug(){return t(this,T)}get ready(){return t(this,C)}get closed(){return t(this,M)}get isLeader(){return t(this,B)}async close(){var e;t(this,M)||(u(this,M,!0),t(this,E)?.close(),t(this,v)?.close(),(e=t(this,G))==null||e.call(this),t(this,P).terminate())}async[Symbol.asyncDispose](){await this.close()}async execProtocolRaw(e){return await h(this,c,g).call(this,"execProtocolRaw",e)}async execProtocol(e){return await h(this,c,g).call(this,"execProtocol",e)}async execProtocolStream(e){return await h(this,c,g).call(this,"execProtocolStream",e)}async syncToFs(){await h(this,c,g).call(this,"syncToFs")}async listen(e,r,a){let s=z(e),n=a??this;return t(this,k).has(s)||t(this,k).set(s,new Set),t(this,k).get(s).add(r),await n.exec(`LISTEN ${e}`),async l=>{await this.unlisten(s,r,l)}}async unlisten(e,r,a){await this.waitReady;let s=a??this;r?t(this,k).get(e)?.delete(r):t(this,k).delete(e),t(this,k).get(e)?.size===0&&await s.exec(`UNLISTEN ${e}`)}onNotification(e){return t(this,b).add(e),()=>{t(this,b).delete(e)}}offNotification(e){t(this,b).delete(e)}async dumpDataDir(e){return await h(this,c,g).call(this,"dumpDataDir",e)}onLeaderChange(e){return t(this,w).addEventListener("leader-change",e),()=>{t(this,w).removeEventListener("leader-change",e)}}offLeaderChange(e){t(this,w).removeEventListener("leader-change",e)}async _handleBlob(e){await h(this,c,g).call(this,"_handleBlob",e)}async _getWrittenBlob(){return await h(this,c,g).call(this,"_getWrittenBlob")}async _cleanupBlob(){await h(this,c,g).call(this,"_cleanupBlob")}async _checkReady(){await this.waitReady}async _runExclusiveQuery(e){await h(this,c,g).call(this,"_acquireQueryLock");try{return await e()}finally{await h(this,c,g).call(this,"_releaseQueryLock")}}async _runExclusiveTransaction(e){await h(this,c,g).call(this,"_acquireTransactionLock");try{return await e()}finally{await h(this,c,g).call(this,"_releaseTransactionLock")}}};W=new WeakMap,T=new WeakMap,C=new WeakMap,M=new WeakMap,B=new WeakMap,w=new WeakMap,x=new WeakMap,L=new WeakMap,P=new WeakMap,_=new WeakMap,A=new WeakMap,O=new WeakMap,E=new WeakMap,v=new WeakMap,G=new WeakMap,k=new WeakMap,b=new WeakMap,I=new WeakMap,$=new WeakMap,c=new WeakSet,K=async function(e={}){for(let[o,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 d=await y.setup(this,{},!0);if(d.emscriptenOpts&&console.warn(`PGlite extension ${o} returned emscriptenOpts, these are not supported on the client side of a worker`),d.namespaceObj){let R=this;R[o]=d.namespaceObj}d.bundlePath&&console.warn(`PGlite extension ${o} returned bundlePath, this is not supported on the client side of a worker`),d.init&&await d.init(),d.close&&t(this,$).push(d.close)}}await t(this,A);let{extensions:r,...a}=e;t(this,P).postMessage({type:"init",options:a}),await t(this,O);let s=`pglite-tab-close:${t(this,x)}`;u(this,G,await N(s));let n=`pglite-broad
|
||
|
|
//# sourceMappingURL=index.js.map
|