@depup/electric-sql__pglite 0.4.0-depup.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +176 -0
- package/README.md +25 -0
- package/changes.json +5 -0
- package/dist/age/index.cjs +2 -0
- package/dist/age/index.cjs.map +1 -0
- package/dist/age/index.d.cts +11 -0
- package/dist/age/index.d.ts +11 -0
- package/dist/age/index.js +2 -0
- package/dist/age/index.js.map +1 -0
- package/dist/age.tar.gz +0 -0
- package/dist/amcheck.tar.gz +0 -0
- package/dist/auto_explain.tar.gz +0 -0
- package/dist/bloom.tar.gz +0 -0
- package/dist/btree_gin.tar.gz +0 -0
- package/dist/btree_gist.tar.gz +0 -0
- package/dist/chunk-AI6QGAXS.js +9 -0
- package/dist/chunk-AI6QGAXS.js.map +1 -0
- package/dist/chunk-F4GETNPB.js +2 -0
- package/dist/chunk-F4GETNPB.js.map +1 -0
- package/dist/chunk-IFMZIE5T.js +3 -0
- package/dist/chunk-IFMZIE5T.js.map +1 -0
- package/dist/chunk-QDPEV33M.js +2 -0
- package/dist/chunk-QDPEV33M.js.map +1 -0
- package/dist/chunk-QY3QWFKW.js +2 -0
- package/dist/chunk-QY3QWFKW.js.map +1 -0
- package/dist/citext.tar.gz +0 -0
- package/dist/contrib/amcheck.cjs +2 -0
- package/dist/contrib/amcheck.cjs.map +1 -0
- package/dist/contrib/amcheck.d.cts +10 -0
- package/dist/contrib/amcheck.d.ts +10 -0
- package/dist/contrib/amcheck.js +2 -0
- package/dist/contrib/amcheck.js.map +1 -0
- package/dist/contrib/auto_explain.cjs +2 -0
- package/dist/contrib/auto_explain.cjs.map +1 -0
- package/dist/contrib/auto_explain.d.cts +10 -0
- package/dist/contrib/auto_explain.d.ts +10 -0
- package/dist/contrib/auto_explain.js +2 -0
- package/dist/contrib/auto_explain.js.map +1 -0
- package/dist/contrib/bloom.cjs +2 -0
- package/dist/contrib/bloom.cjs.map +1 -0
- package/dist/contrib/bloom.d.cts +10 -0
- package/dist/contrib/bloom.d.ts +10 -0
- package/dist/contrib/bloom.js +2 -0
- package/dist/contrib/bloom.js.map +1 -0
- package/dist/contrib/btree_gin.cjs +2 -0
- package/dist/contrib/btree_gin.cjs.map +1 -0
- package/dist/contrib/btree_gin.d.cts +10 -0
- package/dist/contrib/btree_gin.d.ts +10 -0
- package/dist/contrib/btree_gin.js +2 -0
- package/dist/contrib/btree_gin.js.map +1 -0
- package/dist/contrib/btree_gist.cjs +2 -0
- package/dist/contrib/btree_gist.cjs.map +1 -0
- package/dist/contrib/btree_gist.d.cts +10 -0
- package/dist/contrib/btree_gist.d.ts +10 -0
- package/dist/contrib/btree_gist.js +2 -0
- package/dist/contrib/btree_gist.js.map +1 -0
- package/dist/contrib/citext.cjs +2 -0
- package/dist/contrib/citext.cjs.map +1 -0
- package/dist/contrib/citext.d.cts +10 -0
- package/dist/contrib/citext.d.ts +10 -0
- package/dist/contrib/citext.js +2 -0
- package/dist/contrib/citext.js.map +1 -0
- package/dist/contrib/cube.cjs +2 -0
- package/dist/contrib/cube.cjs.map +1 -0
- package/dist/contrib/cube.d.cts +10 -0
- package/dist/contrib/cube.d.ts +10 -0
- package/dist/contrib/cube.js +2 -0
- package/dist/contrib/cube.js.map +1 -0
- package/dist/contrib/dict_int.cjs +2 -0
- package/dist/contrib/dict_int.cjs.map +1 -0
- package/dist/contrib/dict_int.d.cts +10 -0
- package/dist/contrib/dict_int.d.ts +10 -0
- package/dist/contrib/dict_int.js +2 -0
- package/dist/contrib/dict_int.js.map +1 -0
- package/dist/contrib/dict_xsyn.cjs +2 -0
- package/dist/contrib/dict_xsyn.cjs.map +1 -0
- package/dist/contrib/dict_xsyn.d.cts +10 -0
- package/dist/contrib/dict_xsyn.d.ts +10 -0
- package/dist/contrib/dict_xsyn.js +2 -0
- package/dist/contrib/dict_xsyn.js.map +1 -0
- package/dist/contrib/earthdistance.cjs +2 -0
- package/dist/contrib/earthdistance.cjs.map +1 -0
- package/dist/contrib/earthdistance.d.cts +10 -0
- package/dist/contrib/earthdistance.d.ts +10 -0
- package/dist/contrib/earthdistance.js +2 -0
- package/dist/contrib/earthdistance.js.map +1 -0
- package/dist/contrib/file_fdw.cjs +2 -0
- package/dist/contrib/file_fdw.cjs.map +1 -0
- package/dist/contrib/file_fdw.d.cts +10 -0
- package/dist/contrib/file_fdw.d.ts +10 -0
- package/dist/contrib/file_fdw.js +2 -0
- package/dist/contrib/file_fdw.js.map +1 -0
- package/dist/contrib/fuzzystrmatch.cjs +2 -0
- package/dist/contrib/fuzzystrmatch.cjs.map +1 -0
- package/dist/contrib/fuzzystrmatch.d.cts +10 -0
- package/dist/contrib/fuzzystrmatch.d.ts +10 -0
- package/dist/contrib/fuzzystrmatch.js +2 -0
- package/dist/contrib/fuzzystrmatch.js.map +1 -0
- package/dist/contrib/hstore.cjs +2 -0
- package/dist/contrib/hstore.cjs.map +1 -0
- package/dist/contrib/hstore.d.cts +10 -0
- package/dist/contrib/hstore.d.ts +10 -0
- package/dist/contrib/hstore.js +2 -0
- package/dist/contrib/hstore.js.map +1 -0
- package/dist/contrib/intarray.cjs +2 -0
- package/dist/contrib/intarray.cjs.map +1 -0
- package/dist/contrib/intarray.d.cts +10 -0
- package/dist/contrib/intarray.d.ts +10 -0
- package/dist/contrib/intarray.js +2 -0
- package/dist/contrib/intarray.js.map +1 -0
- package/dist/contrib/isn.cjs +2 -0
- package/dist/contrib/isn.cjs.map +1 -0
- package/dist/contrib/isn.d.cts +10 -0
- package/dist/contrib/isn.d.ts +10 -0
- package/dist/contrib/isn.js +2 -0
- package/dist/contrib/isn.js.map +1 -0
- package/dist/contrib/lo.cjs +2 -0
- package/dist/contrib/lo.cjs.map +1 -0
- package/dist/contrib/lo.d.cts +10 -0
- package/dist/contrib/lo.d.ts +10 -0
- package/dist/contrib/lo.js +2 -0
- package/dist/contrib/lo.js.map +1 -0
- package/dist/contrib/ltree.cjs +2 -0
- package/dist/contrib/ltree.cjs.map +1 -0
- package/dist/contrib/ltree.d.cts +10 -0
- package/dist/contrib/ltree.d.ts +10 -0
- package/dist/contrib/ltree.js +2 -0
- package/dist/contrib/ltree.js.map +1 -0
- package/dist/contrib/pageinspect.cjs +2 -0
- package/dist/contrib/pageinspect.cjs.map +1 -0
- package/dist/contrib/pageinspect.d.cts +10 -0
- package/dist/contrib/pageinspect.d.ts +10 -0
- package/dist/contrib/pageinspect.js +2 -0
- package/dist/contrib/pageinspect.js.map +1 -0
- package/dist/contrib/pg_buffercache.cjs +2 -0
- package/dist/contrib/pg_buffercache.cjs.map +1 -0
- package/dist/contrib/pg_buffercache.d.cts +10 -0
- package/dist/contrib/pg_buffercache.d.ts +10 -0
- package/dist/contrib/pg_buffercache.js +2 -0
- package/dist/contrib/pg_buffercache.js.map +1 -0
- package/dist/contrib/pg_freespacemap.cjs +2 -0
- package/dist/contrib/pg_freespacemap.cjs.map +1 -0
- package/dist/contrib/pg_freespacemap.d.cts +10 -0
- package/dist/contrib/pg_freespacemap.d.ts +10 -0
- package/dist/contrib/pg_freespacemap.js +2 -0
- package/dist/contrib/pg_freespacemap.js.map +1 -0
- package/dist/contrib/pg_surgery.cjs +2 -0
- package/dist/contrib/pg_surgery.cjs.map +1 -0
- package/dist/contrib/pg_surgery.d.cts +10 -0
- package/dist/contrib/pg_surgery.d.ts +10 -0
- package/dist/contrib/pg_surgery.js +2 -0
- package/dist/contrib/pg_surgery.js.map +1 -0
- package/dist/contrib/pg_trgm.cjs +2 -0
- package/dist/contrib/pg_trgm.cjs.map +1 -0
- package/dist/contrib/pg_trgm.d.cts +10 -0
- package/dist/contrib/pg_trgm.d.ts +10 -0
- package/dist/contrib/pg_trgm.js +2 -0
- package/dist/contrib/pg_trgm.js.map +1 -0
- package/dist/contrib/pg_visibility.cjs +2 -0
- package/dist/contrib/pg_visibility.cjs.map +1 -0
- package/dist/contrib/pg_visibility.d.cts +10 -0
- package/dist/contrib/pg_visibility.d.ts +10 -0
- package/dist/contrib/pg_visibility.js +2 -0
- package/dist/contrib/pg_visibility.js.map +1 -0
- package/dist/contrib/pg_walinspect.cjs +2 -0
- package/dist/contrib/pg_walinspect.cjs.map +1 -0
- package/dist/contrib/pg_walinspect.d.cts +10 -0
- package/dist/contrib/pg_walinspect.d.ts +10 -0
- package/dist/contrib/pg_walinspect.js +2 -0
- package/dist/contrib/pg_walinspect.js.map +1 -0
- package/dist/contrib/pgcrypto.cjs +2 -0
- package/dist/contrib/pgcrypto.cjs.map +1 -0
- package/dist/contrib/pgcrypto.d.cts +10 -0
- package/dist/contrib/pgcrypto.d.ts +10 -0
- package/dist/contrib/pgcrypto.js +2 -0
- package/dist/contrib/pgcrypto.js.map +1 -0
- package/dist/contrib/seg.cjs +2 -0
- package/dist/contrib/seg.cjs.map +1 -0
- package/dist/contrib/seg.d.cts +10 -0
- package/dist/contrib/seg.d.ts +10 -0
- package/dist/contrib/seg.js +2 -0
- package/dist/contrib/seg.js.map +1 -0
- package/dist/contrib/tablefunc.cjs +2 -0
- package/dist/contrib/tablefunc.cjs.map +1 -0
- package/dist/contrib/tablefunc.d.cts +10 -0
- package/dist/contrib/tablefunc.d.ts +10 -0
- package/dist/contrib/tablefunc.js +2 -0
- package/dist/contrib/tablefunc.js.map +1 -0
- package/dist/contrib/tcn.cjs +2 -0
- package/dist/contrib/tcn.cjs.map +1 -0
- package/dist/contrib/tcn.d.cts +10 -0
- package/dist/contrib/tcn.d.ts +10 -0
- package/dist/contrib/tcn.js +2 -0
- package/dist/contrib/tcn.js.map +1 -0
- package/dist/contrib/tsm_system_rows.cjs +2 -0
- package/dist/contrib/tsm_system_rows.cjs.map +1 -0
- package/dist/contrib/tsm_system_rows.d.cts +10 -0
- package/dist/contrib/tsm_system_rows.d.ts +10 -0
- package/dist/contrib/tsm_system_rows.js +2 -0
- package/dist/contrib/tsm_system_rows.js.map +1 -0
- package/dist/contrib/tsm_system_time.cjs +2 -0
- package/dist/contrib/tsm_system_time.cjs.map +1 -0
- package/dist/contrib/tsm_system_time.d.cts +10 -0
- package/dist/contrib/tsm_system_time.d.ts +10 -0
- package/dist/contrib/tsm_system_time.js +2 -0
- package/dist/contrib/tsm_system_time.js.map +1 -0
- package/dist/contrib/unaccent.cjs +2 -0
- package/dist/contrib/unaccent.cjs.map +1 -0
- package/dist/contrib/unaccent.d.cts +10 -0
- package/dist/contrib/unaccent.d.ts +10 -0
- package/dist/contrib/unaccent.js +2 -0
- package/dist/contrib/unaccent.js.map +1 -0
- package/dist/contrib/uuid_ossp.cjs +2 -0
- package/dist/contrib/uuid_ossp.cjs.map +1 -0
- package/dist/contrib/uuid_ossp.d.cts +10 -0
- package/dist/contrib/uuid_ossp.d.ts +10 -0
- package/dist/contrib/uuid_ossp.js +2 -0
- package/dist/contrib/uuid_ossp.js.map +1 -0
- package/dist/cube.tar.gz +0 -0
- package/dist/dict_int.tar.gz +0 -0
- package/dist/dict_xsyn.tar.gz +0 -0
- package/dist/earthdistance.tar.gz +0 -0
- package/dist/file_fdw.tar.gz +0 -0
- package/dist/fs/base.cjs +3 -0
- package/dist/fs/base.cjs.map +1 -0
- package/dist/fs/base.d.cts +1 -0
- package/dist/fs/base.d.ts +1 -0
- package/dist/fs/base.js +2 -0
- package/dist/fs/base.js.map +1 -0
- package/dist/fs/nodefs.cjs +3 -0
- package/dist/fs/nodefs.cjs.map +1 -0
- package/dist/fs/nodefs.d.cts +12 -0
- package/dist/fs/nodefs.d.ts +12 -0
- package/dist/fs/nodefs.js +2 -0
- package/dist/fs/nodefs.js.map +1 -0
- package/dist/fs/opfs-ahp.cjs +5 -0
- package/dist/fs/opfs-ahp.cjs.map +1 -0
- package/dist/fs/opfs-ahp.d.cts +112 -0
- package/dist/fs/opfs-ahp.d.ts +112 -0
- package/dist/fs/opfs-ahp.js +4 -0
- package/dist/fs/opfs-ahp.js.map +1 -0
- package/dist/fuzzystrmatch.tar.gz +0 -0
- package/dist/hstore.tar.gz +0 -0
- package/dist/index.cjs +14 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +372 -0
- package/dist/index.d.ts +372 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/initdb.js +16 -0
- package/dist/initdb.wasm +0 -0
- package/dist/intarray.tar.gz +0 -0
- package/dist/isn.tar.gz +0 -0
- package/dist/live/index.cjs +133 -0
- package/dist/live/index.cjs.map +1 -0
- package/dist/live/index.d.cts +149 -0
- package/dist/live/index.d.ts +149 -0
- package/dist/live/index.js +133 -0
- package/dist/live/index.js.map +1 -0
- package/dist/lo.tar.gz +0 -0
- package/dist/ltree.tar.gz +0 -0
- package/dist/pageinspect.tar.gz +0 -0
- package/dist/passwordcheck.tar.gz +0 -0
- package/dist/pg_buffercache.tar.gz +0 -0
- package/dist/pg_freespacemap.tar.gz +0 -0
- package/dist/pg_hashids/index.cjs +2 -0
- package/dist/pg_hashids/index.cjs.map +1 -0
- package/dist/pg_hashids/index.d.cts +11 -0
- package/dist/pg_hashids/index.d.ts +11 -0
- package/dist/pg_hashids/index.js +2 -0
- package/dist/pg_hashids/index.js.map +1 -0
- package/dist/pg_hashids.tar.gz +0 -0
- package/dist/pg_ivm/index.cjs +2 -0
- package/dist/pg_ivm/index.cjs.map +1 -0
- package/dist/pg_ivm/index.d.cts +11 -0
- package/dist/pg_ivm/index.d.ts +11 -0
- package/dist/pg_ivm/index.js +2 -0
- package/dist/pg_ivm/index.js.map +1 -0
- package/dist/pg_ivm.tar.gz +0 -0
- package/dist/pg_surgery.tar.gz +0 -0
- package/dist/pg_textsearch/index.cjs +2 -0
- package/dist/pg_textsearch/index.cjs.map +1 -0
- package/dist/pg_textsearch/index.d.cts +11 -0
- package/dist/pg_textsearch/index.d.ts +11 -0
- package/dist/pg_textsearch/index.js +2 -0
- package/dist/pg_textsearch/index.js.map +1 -0
- package/dist/pg_textsearch.tar.gz +0 -0
- package/dist/pg_trgm.tar.gz +0 -0
- package/dist/pg_uuidv7/index.cjs +2 -0
- package/dist/pg_uuidv7/index.cjs.map +1 -0
- package/dist/pg_uuidv7/index.d.cts +11 -0
- package/dist/pg_uuidv7/index.d.ts +11 -0
- package/dist/pg_uuidv7/index.js +2 -0
- package/dist/pg_uuidv7/index.js.map +1 -0
- package/dist/pg_uuidv7.tar.gz +0 -0
- package/dist/pg_visibility.tar.gz +0 -0
- package/dist/pg_walinspect.tar.gz +0 -0
- package/dist/pgcrypto.tar.gz +0 -0
- package/dist/pglite-SIPwY9Cm.d.cts +1092 -0
- package/dist/pglite-SIPwY9Cm.d.ts +1092 -0
- package/dist/pglite.cjs +3 -0
- package/dist/pglite.data +0 -0
- package/dist/pglite.js +16 -0
- package/dist/pglite.wasm +0 -0
- package/dist/pgtap/index.cjs +2 -0
- package/dist/pgtap/index.cjs.map +1 -0
- package/dist/pgtap/index.d.cts +11 -0
- package/dist/pgtap/index.d.ts +11 -0
- package/dist/pgtap/index.js +2 -0
- package/dist/pgtap/index.js.map +1 -0
- package/dist/pgtap.tar.gz +0 -0
- package/dist/postgres_fdw.tar.gz +0 -0
- package/dist/seg.tar.gz +0 -0
- package/dist/tablefunc.tar.gz +0 -0
- package/dist/tcn.tar.gz +0 -0
- package/dist/templating.cjs +2 -0
- package/dist/templating.cjs.map +1 -0
- package/dist/templating.d.cts +69 -0
- package/dist/templating.d.ts +69 -0
- package/dist/templating.js +2 -0
- package/dist/templating.js.map +1 -0
- package/dist/tsm_system_rows.tar.gz +0 -0
- package/dist/tsm_system_time.tar.gz +0 -0
- package/dist/unaccent.tar.gz +0 -0
- package/dist/uuid-ossp.tar.gz +0 -0
- package/dist/vector/index.cjs +2 -0
- package/dist/vector/index.cjs.map +1 -0
- package/dist/vector/index.d.cts +11 -0
- package/dist/vector/index.d.ts +11 -0
- package/dist/vector/index.js +2 -0
- package/dist/vector/index.js.map +1 -0
- package/dist/vector.tar.gz +0 -0
- package/dist/worker/index.cjs +9 -0
- package/dist/worker/index.cjs.map +1 -0
- package/dist/worker/index.d.cts +128 -0
- package/dist/worker/index.d.ts +128 -0
- package/dist/worker/index.js +2 -0
- package/dist/worker/index.js.map +1 -0
- package/package.json +254 -0
package/dist/pglite.wasm
ADDED
|
Binary file
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var s=Object.defineProperty;var o=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var u=(t,e)=>{for(var r in e)s(t,r,{get:e[r],enumerable:!0})},f=(t,e,r,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of p(e))!c.call(t,n)&&n!==r&&s(t,n,{get:()=>e[n],enumerable:!(a=o(e,n))||a.enumerable});return t};var m=t=>f(s({},"__esModule",{value:!0}),t);var x={};u(x,{pgtap:()=>g});module.exports=m(x);var l=()=>typeof document>"u"?new URL(`file:${__filename}`).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href,i=l();var d=async(t,e)=>({emscriptenOpts:e,bundlePath:new URL("../pgtap.tar.gz",i)}),g={name:"pgtap",setup:d};0&&(module.exports={pgtap});
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/pgtap/index.ts","../../../../node_modules/.pnpm/tsup@8.3.0_@microsoft+api-extractor@7.47.7_@types+node@20.16.11__postcss@8.4.47_tsx@4.19.2_typescript@5.6.3/node_modules/tsup/assets/cjs_shims.js"],"sourcesContent":["import type {\n Extension,\n ExtensionSetupResult,\n PGliteInterface,\n} from '../interface'\n\nconst setup = async (_pg: PGliteInterface, emscriptenOpts: any) => {\n return {\n emscriptenOpts,\n bundlePath: new URL('../../release/pgtap.tar.gz', import.meta.url),\n } satisfies ExtensionSetupResult\n}\n\nexport const pgtap = {\n name: 'pgtap',\n setup,\n} satisfies Extension\n","// Shim globals in cjs bundle\n// There's a weird bug that esbuild will always inject importMetaUrl\n// if we export it as `const importMetaUrl = ... __filename ...`\n// But using a function will not cause this issue\n\nconst getImportMetaUrl = () =>\n typeof document === 'undefined'\n ? new URL(`file:${__filename}`).href\n : (document.currentScript && document.currentScript.src) ||\n new URL('main.js', document.baseURI).href\n\nexport const importMetaUrl = /* @__PURE__ */ getImportMetaUrl()\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,WAAAE,IAAA,eAAAC,EAAAH,GCKA,IAAMI,EAAmB,IACvB,OAAO,SAAa,IAChB,IAAI,IAAI,QAAQ,UAAU,EAAE,EAAE,KAC7B,SAAS,eAAiB,SAAS,cAAc,KAClD,IAAI,IAAI,UAAW,SAAS,OAAO,EAAE,KAE9BC,EAAgCD,EAAiB,EDL9D,IAAME,EAAQ,MAAOC,EAAsBC,KAClC,CACL,eAAAA,EACA,WAAY,IAAI,IAAI,6BAA8BC,CAAe,CACnE,GAGWC,EAAQ,CACnB,KAAM,QACN,MAAAJ,CACF","names":["pgtap_exports","__export","pgtap","__toCommonJS","getImportMetaUrl","importMetaUrl","setup","_pg","emscriptenOpts","importMetaUrl","pgtap"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/pgtap/index.ts"],"sourcesContent":["import type {\n Extension,\n ExtensionSetupResult,\n PGliteInterface,\n} from '../interface'\n\nconst setup = async (_pg: PGliteInterface, emscriptenOpts: any) => {\n return {\n emscriptenOpts,\n bundlePath: new URL('../../release/pgtap.tar.gz', import.meta.url),\n } satisfies ExtensionSetupResult\n}\n\nexport const pgtap = {\n name: 'pgtap',\n setup,\n} satisfies Extension\n"],"mappings":"yCAAAA,IAMA,IAAMC,EAAQ,MAAOC,EAAsBC,KAClC,CACL,eAAAA,EACA,WAAY,IAAI,IAAI,6BAA8B,YAAY,GAAG,CACnE,GAGWC,EAAQ,CACnB,KAAM,QACN,MAAAH,CACF","names":["init_esm_shims","setup","_pg","emscriptenOpts","pgtap"]}
|
|
Binary file
|
|
Binary file
|
package/dist/seg.tar.gz
ADDED
|
Binary file
|
|
Binary file
|
package/dist/tcn.tar.gz
ADDED
|
Binary file
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var l=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var m=(t,r)=>{for(var e in r)l(t,e,{get:r[e],enumerable:!0})},g=(t,r,e,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of T(r))!c.call(t,a)&&a!==e&&l(t,a,{get:()=>r[a],enumerable:!(n=u(r,a))||n.enumerable});return t};var f=t=>g(l({},"__esModule",{value:!0}),t);var d={};m(d,{identifier:()=>w,query:()=>S,raw:()=>h,sql:()=>y});module.exports=f(d);var o={part:"part",container:"container"};function s(t,r,...e){let n=t.length-1,a=e.length-1;if(a!==-1){if(a===0){t[n]=t[n]+e[0]+r;return}t[n]=t[n]+e[0],t.push(...e.slice(1,a)),t.push(e[a]+r)}}function y(t,...r){let e=[t[0]];e.raw=[t.raw[0]];let n=[];for(let a=0;a<r.length;a++){let p=r[a],i=a+1;if(p?._templateType===o.part){s(e,t[i],p.str),s(e.raw,t.raw[i],p.str);continue}if(p?._templateType===o.container){s(e,t[i],...p.strings),s(e.raw,t.raw[i],...p.strings.raw),n.push(...p.values);continue}e.push(t[i]),e.raw.push(t.raw[i]),n.push(p)}return{_templateType:"container",strings:e,values:n}}function w(t,...r){return{_templateType:"part",str:`"${String.raw(t,...r)}"`}}function h(t,...r){return{_templateType:"part",str:String.raw(t,...r)}}function S(t,...r){let{strings:e,values:n}=y(t,...r);return{query:[e[0],...n.flatMap((a,p)=>[`$${p+1}`,e[p+1]])].join(""),params:n}}0&&(module.exports={identifier,query,raw,sql});
|
|
2
|
+
//# sourceMappingURL=templating.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/templating.ts"],"sourcesContent":["const TemplateType = {\n part: 'part',\n container: 'container',\n} as const\n\ninterface TemplatePart {\n _templateType: typeof TemplateType.part\n str: string\n}\n\ninterface TemplateContainer {\n _templateType: typeof TemplateType.container\n strings: TemplateStringsArray\n values: any[]\n}\n\ninterface TemplatedQuery {\n query: string\n params: any[]\n}\n\nfunction addToLastAndPushWithSuffix(\n arr: string[],\n suffix: string,\n ...values: string[]\n) {\n const lastArrIdx = arr.length - 1\n const lastValIdx = values.length - 1\n\n // no-op\n if (lastValIdx === -1) return\n\n // overwrite last element\n if (lastValIdx === 0) {\n arr[lastArrIdx] = arr[lastArrIdx] + values[0] + suffix\n return\n }\n\n // sandwich values between array and suffix\n arr[lastArrIdx] = arr[lastArrIdx] + values[0]\n arr.push(...values.slice(1, lastValIdx))\n arr.push(values[lastValIdx] + suffix)\n}\n\n/**\n * Templating utility that allows nesting multiple SQL strings without\n * losing the automatic parametrization capabilities of {@link query}.\n *\n * @example\n * ```ts\n * query`SELECT * FROM tale ${withFilter ? sql`WHERE foo = ${fooVar}` : sql``}`\n * // > { query: 'SELECT * FROM tale WHERE foo = $1', params: [fooVar] }\n * // or\n * // > { query: 'SELECT * FROM tale', params: [] }\n * ```\n */\nexport function sql(\n strings: TemplateStringsArray,\n ...values: any[]\n): TemplateContainer {\n const parsedStrings = [strings[0]] as string[] & {\n raw: string[]\n }\n parsedStrings.raw = [strings.raw[0]]\n\n const parsedValues: any[] = []\n for (let i = 0; i < values.length; i++) {\n const value = values[i]\n const nextStringIdx = i + 1\n\n // if value is a template tag, collapse into last string\n if (value?._templateType === TemplateType.part) {\n addToLastAndPushWithSuffix(\n parsedStrings,\n strings[nextStringIdx],\n value.str,\n )\n addToLastAndPushWithSuffix(\n parsedStrings.raw,\n strings.raw[nextStringIdx],\n value.str,\n )\n continue\n }\n\n // if value is an output of this method, append in place\n if (value?._templateType === TemplateType.container) {\n addToLastAndPushWithSuffix(\n parsedStrings,\n strings[nextStringIdx],\n ...value.strings,\n )\n addToLastAndPushWithSuffix(\n parsedStrings.raw,\n strings.raw[nextStringIdx],\n ...value.strings.raw,\n )\n parsedValues.push(...value.values)\n continue\n }\n\n // otherwise keep reconstructing\n parsedStrings.push(strings[nextStringIdx])\n parsedStrings.raw.push(strings.raw[nextStringIdx])\n parsedValues.push(value)\n }\n\n return {\n _templateType: 'container',\n strings: parsedStrings,\n values: parsedValues,\n }\n}\n\n/**\n * Allows adding identifiers into a query template string without\n * parametrizing them. This method will automatically escape identifiers.\n *\n * @example\n * ```ts\n * query`SELECT * FROM ${identifier`foo`} WHERE ${identifier`id`} = ${id}`\n * // > { query: 'SELECT * FROM \"foo\" WHERE \"id\" = $1', params: [id] }\n * ```\n */\nexport function identifier(\n strings: TemplateStringsArray,\n ...values: any[]\n): TemplatePart {\n return {\n _templateType: 'part',\n str: `\"${String.raw(strings, ...values)}\"`,\n }\n}\n\n/**\n * Allows adding raw strings into a query template string without\n * parametrizing or modifying them in any way.\n *\n * @example\n * ```ts\n * query`SELECT * FROM foo ${raw`WHERE id = ${2+3}`}`\n * // > { query: 'SELECT * FROM foo WHERE id = 5', params: [] }\n * ```\n */\n\nexport function raw(\n strings: TemplateStringsArray,\n ...values: any[]\n): TemplatePart {\n return {\n _templateType: 'part',\n str: String.raw(strings, ...values),\n }\n}\n\n/**\n * Generates a parametrized query from a templated query string, assigning\n * the provided values to the appropriate named parameters.\n *\n * You can use templating helpers like {@link identifier} and {@link raw} to\n * add identifiers and raw strings to the query without making them parameters,\n * and you can use {@link sql} to nest multiple queries and create utilities.\n *\n * @example\n * ```ts\n * query`SELECT * FROM ${identifier`foo`} WHERE id = ${id} and name = ${name}`\n * // > { query: 'SELECT * FROM \"foo\" WHERE id = $1 and name = $2', params: [id, name] }\n * ```\n */\nexport function query(\n strings: TemplateStringsArray,\n ...values: any[]\n): TemplatedQuery {\n const { strings: queryStringParts, values: params } = sql(strings, ...values)\n return {\n query: [\n queryStringParts[0],\n ...params.flatMap((_, idx) => [`$${idx + 1}`, queryStringParts[idx + 1]]),\n ].join(''),\n params: params,\n }\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gBAAAE,EAAA,UAAAC,EAAA,QAAAC,EAAA,QAAAC,IAAA,eAAAC,EAAAN,GAAA,IAAMO,EAAe,CACnB,KAAM,OACN,UAAW,WACb,EAkBA,SAASC,EACPC,EACAC,KACGC,EACH,CACA,IAAMC,EAAaH,EAAI,OAAS,EAC1BI,EAAaF,EAAO,OAAS,EAGnC,GAAIE,IAAe,GAGnB,IAAIA,IAAe,EAAG,CACpBJ,EAAIG,CAAU,EAAIH,EAAIG,CAAU,EAAID,EAAO,CAAC,EAAID,EAChD,MACF,CAGAD,EAAIG,CAAU,EAAIH,EAAIG,CAAU,EAAID,EAAO,CAAC,EAC5CF,EAAI,KAAK,GAAGE,EAAO,MAAM,EAAGE,CAAU,CAAC,EACvCJ,EAAI,KAAKE,EAAOE,CAAU,EAAIH,CAAM,EACtC,CAcO,SAASI,EACdC,KACGJ,EACgB,CACnB,IAAMK,EAAgB,CAACD,EAAQ,CAAC,CAAC,EAGjCC,EAAc,IAAM,CAACD,EAAQ,IAAI,CAAC,CAAC,EAEnC,IAAME,EAAsB,CAAC,EAC7B,QAASC,EAAI,EAAGA,EAAIP,EAAO,OAAQO,IAAK,CACtC,IAAMC,EAAQR,EAAOO,CAAC,EAChBE,EAAgBF,EAAI,EAG1B,GAAIC,GAAO,gBAAkBZ,EAAa,KAAM,CAC9CC,EACEQ,EACAD,EAAQK,CAAa,EACrBD,EAAM,GACR,EACAX,EACEQ,EAAc,IACdD,EAAQ,IAAIK,CAAa,EACzBD,EAAM,GACR,EACA,QACF,CAGA,GAAIA,GAAO,gBAAkBZ,EAAa,UAAW,CACnDC,EACEQ,EACAD,EAAQK,CAAa,EACrB,GAAGD,EAAM,OACX,EACAX,EACEQ,EAAc,IACdD,EAAQ,IAAIK,CAAa,EACzB,GAAGD,EAAM,QAAQ,GACnB,EACAF,EAAa,KAAK,GAAGE,EAAM,MAAM,EACjC,QACF,CAGAH,EAAc,KAAKD,EAAQK,CAAa,CAAC,EACzCJ,EAAc,IAAI,KAAKD,EAAQ,IAAIK,CAAa,CAAC,EACjDH,EAAa,KAAKE,CAAK,CACzB,CAEA,MAAO,CACL,cAAe,YACf,QAASH,EACT,OAAQC,CACV,CACF,CAYO,SAASI,EACdN,KACGJ,EACW,CACd,MAAO,CACL,cAAe,OACf,IAAK,IAAI,OAAO,IAAII,EAAS,GAAGJ,CAAM,CAAC,GACzC,CACF,CAaO,SAASW,EACdP,KACGJ,EACW,CACd,MAAO,CACL,cAAe,OACf,IAAK,OAAO,IAAII,EAAS,GAAGJ,CAAM,CACpC,CACF,CAgBO,SAASY,EACdR,KACGJ,EACa,CAChB,GAAM,CAAE,QAASa,EAAkB,OAAQC,CAAO,EAAIX,EAAIC,EAAS,GAAGJ,CAAM,EAC5E,MAAO,CACL,MAAO,CACLa,EAAiB,CAAC,EAClB,GAAGC,EAAO,QAAQ,CAACC,EAAGC,IAAQ,CAAC,IAAIA,EAAM,CAAC,GAAIH,EAAiBG,EAAM,CAAC,CAAC,CAAC,CAC1E,EAAE,KAAK,EAAE,EACT,OAAQF,CACV,CACF","names":["templating_exports","__export","identifier","query","raw","sql","__toCommonJS","TemplateType","addToLastAndPushWithSuffix","arr","suffix","values","lastArrIdx","lastValIdx","sql","strings","parsedStrings","parsedValues","i","value","nextStringIdx","identifier","raw","query","queryStringParts","params","_","idx"]}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
declare const TemplateType: {
|
|
2
|
+
readonly part: "part";
|
|
3
|
+
readonly container: "container";
|
|
4
|
+
};
|
|
5
|
+
interface TemplatePart {
|
|
6
|
+
_templateType: typeof TemplateType.part;
|
|
7
|
+
str: string;
|
|
8
|
+
}
|
|
9
|
+
interface TemplateContainer {
|
|
10
|
+
_templateType: typeof TemplateType.container;
|
|
11
|
+
strings: TemplateStringsArray;
|
|
12
|
+
values: any[];
|
|
13
|
+
}
|
|
14
|
+
interface TemplatedQuery {
|
|
15
|
+
query: string;
|
|
16
|
+
params: any[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Templating utility that allows nesting multiple SQL strings without
|
|
20
|
+
* losing the automatic parametrization capabilities of {@link query}.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* query`SELECT * FROM tale ${withFilter ? sql`WHERE foo = ${fooVar}` : sql``}`
|
|
25
|
+
* // > { query: 'SELECT * FROM tale WHERE foo = $1', params: [fooVar] }
|
|
26
|
+
* // or
|
|
27
|
+
* // > { query: 'SELECT * FROM tale', params: [] }
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
declare function sql(strings: TemplateStringsArray, ...values: any[]): TemplateContainer;
|
|
31
|
+
/**
|
|
32
|
+
* Allows adding identifiers into a query template string without
|
|
33
|
+
* parametrizing them. This method will automatically escape identifiers.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* query`SELECT * FROM ${identifier`foo`} WHERE ${identifier`id`} = ${id}`
|
|
38
|
+
* // > { query: 'SELECT * FROM "foo" WHERE "id" = $1', params: [id] }
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
declare function identifier(strings: TemplateStringsArray, ...values: any[]): TemplatePart;
|
|
42
|
+
/**
|
|
43
|
+
* Allows adding raw strings into a query template string without
|
|
44
|
+
* parametrizing or modifying them in any way.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* query`SELECT * FROM foo ${raw`WHERE id = ${2+3}`}`
|
|
49
|
+
* // > { query: 'SELECT * FROM foo WHERE id = 5', params: [] }
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
declare function raw(strings: TemplateStringsArray, ...values: any[]): TemplatePart;
|
|
53
|
+
/**
|
|
54
|
+
* Generates a parametrized query from a templated query string, assigning
|
|
55
|
+
* the provided values to the appropriate named parameters.
|
|
56
|
+
*
|
|
57
|
+
* You can use templating helpers like {@link identifier} and {@link raw} to
|
|
58
|
+
* add identifiers and raw strings to the query without making them parameters,
|
|
59
|
+
* and you can use {@link sql} to nest multiple queries and create utilities.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* query`SELECT * FROM ${identifier`foo`} WHERE id = ${id} and name = ${name}`
|
|
64
|
+
* // > { query: 'SELECT * FROM "foo" WHERE id = $1 and name = $2', params: [id, name] }
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
declare function query(strings: TemplateStringsArray, ...values: any[]): TemplatedQuery;
|
|
68
|
+
|
|
69
|
+
export { identifier, query, raw, sql };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
declare const TemplateType: {
|
|
2
|
+
readonly part: "part";
|
|
3
|
+
readonly container: "container";
|
|
4
|
+
};
|
|
5
|
+
interface TemplatePart {
|
|
6
|
+
_templateType: typeof TemplateType.part;
|
|
7
|
+
str: string;
|
|
8
|
+
}
|
|
9
|
+
interface TemplateContainer {
|
|
10
|
+
_templateType: typeof TemplateType.container;
|
|
11
|
+
strings: TemplateStringsArray;
|
|
12
|
+
values: any[];
|
|
13
|
+
}
|
|
14
|
+
interface TemplatedQuery {
|
|
15
|
+
query: string;
|
|
16
|
+
params: any[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Templating utility that allows nesting multiple SQL strings without
|
|
20
|
+
* losing the automatic parametrization capabilities of {@link query}.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* query`SELECT * FROM tale ${withFilter ? sql`WHERE foo = ${fooVar}` : sql``}`
|
|
25
|
+
* // > { query: 'SELECT * FROM tale WHERE foo = $1', params: [fooVar] }
|
|
26
|
+
* // or
|
|
27
|
+
* // > { query: 'SELECT * FROM tale', params: [] }
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
declare function sql(strings: TemplateStringsArray, ...values: any[]): TemplateContainer;
|
|
31
|
+
/**
|
|
32
|
+
* Allows adding identifiers into a query template string without
|
|
33
|
+
* parametrizing them. This method will automatically escape identifiers.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* query`SELECT * FROM ${identifier`foo`} WHERE ${identifier`id`} = ${id}`
|
|
38
|
+
* // > { query: 'SELECT * FROM "foo" WHERE "id" = $1', params: [id] }
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
declare function identifier(strings: TemplateStringsArray, ...values: any[]): TemplatePart;
|
|
42
|
+
/**
|
|
43
|
+
* Allows adding raw strings into a query template string without
|
|
44
|
+
* parametrizing or modifying them in any way.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* query`SELECT * FROM foo ${raw`WHERE id = ${2+3}`}`
|
|
49
|
+
* // > { query: 'SELECT * FROM foo WHERE id = 5', params: [] }
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
declare function raw(strings: TemplateStringsArray, ...values: any[]): TemplatePart;
|
|
53
|
+
/**
|
|
54
|
+
* Generates a parametrized query from a templated query string, assigning
|
|
55
|
+
* the provided values to the appropriate named parameters.
|
|
56
|
+
*
|
|
57
|
+
* You can use templating helpers like {@link identifier} and {@link raw} to
|
|
58
|
+
* add identifiers and raw strings to the query without making them parameters,
|
|
59
|
+
* and you can use {@link sql} to nest multiple queries and create utilities.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* query`SELECT * FROM ${identifier`foo`} WHERE id = ${id} and name = ${name}`
|
|
64
|
+
* // > { query: 'SELECT * FROM "foo" WHERE id = $1 and name = $2', params: [id, name] }
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
declare function query(strings: TemplateStringsArray, ...values: any[]): TemplatedQuery;
|
|
68
|
+
|
|
69
|
+
export { identifier, query, raw, sql };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var o=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var p=(t,e)=>{for(var r in e)o(t,r,{get:e[r],enumerable:!0})},f=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of a(e))!u.call(t,n)&&n!==r&&o(t,n,{get:()=>e[n],enumerable:!(s=i(e,n))||s.enumerable});return t};var m=t=>f(o({},"__esModule",{value:!0}),t);var R={};p(R,{vector:()=>x});module.exports=m(R);var l=()=>typeof document>"u"?new URL(`file:${__filename}`).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href,c=l();var d=async(t,e)=>({emscriptenOpts:e,bundlePath:new URL("../vector.tar.gz",c)}),x={name:"pgvector",setup:d};0&&(module.exports={vector});
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/vector/index.ts","../../../../node_modules/.pnpm/tsup@8.3.0_@microsoft+api-extractor@7.47.7_@types+node@20.16.11__postcss@8.4.47_tsx@4.19.2_typescript@5.6.3/node_modules/tsup/assets/cjs_shims.js"],"sourcesContent":["import type {\n Extension,\n ExtensionSetupResult,\n PGliteInterface,\n} from '../interface'\n\nconst setup = async (_pg: PGliteInterface, emscriptenOpts: any) => {\n return {\n emscriptenOpts,\n bundlePath: new URL('../../release/vector.tar.gz', import.meta.url),\n } satisfies ExtensionSetupResult\n}\n\nexport const vector = {\n name: 'pgvector',\n setup,\n} satisfies Extension\n","// Shim globals in cjs bundle\n// There's a weird bug that esbuild will always inject importMetaUrl\n// if we export it as `const importMetaUrl = ... __filename ...`\n// But using a function will not cause this issue\n\nconst getImportMetaUrl = () =>\n typeof document === 'undefined'\n ? new URL(`file:${__filename}`).href\n : (document.currentScript && document.currentScript.src) ||\n new URL('main.js', document.baseURI).href\n\nexport const importMetaUrl = /* @__PURE__ */ getImportMetaUrl()\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,YAAAE,IAAA,eAAAC,EAAAH,GCKA,IAAMI,EAAmB,IACvB,OAAO,SAAa,IAChB,IAAI,IAAI,QAAQ,UAAU,EAAE,EAAE,KAC7B,SAAS,eAAiB,SAAS,cAAc,KAClD,IAAI,IAAI,UAAW,SAAS,OAAO,EAAE,KAE9BC,EAAgCD,EAAiB,EDL9D,IAAME,EAAQ,MAAOC,EAAsBC,KAClC,CACL,eAAAA,EACA,WAAY,IAAI,IAAI,8BAA+BC,CAAe,CACpE,GAGWC,EAAS,CACpB,KAAM,WACN,MAAAJ,CACF","names":["vector_exports","__export","vector","__toCommonJS","getImportMetaUrl","importMetaUrl","setup","_pg","emscriptenOpts","importMetaUrl","vector"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/vector/index.ts"],"sourcesContent":["import type {\n Extension,\n ExtensionSetupResult,\n PGliteInterface,\n} from '../interface'\n\nconst setup = async (_pg: PGliteInterface, emscriptenOpts: any) => {\n return {\n emscriptenOpts,\n bundlePath: new URL('../../release/vector.tar.gz', import.meta.url),\n } satisfies ExtensionSetupResult\n}\n\nexport const vector = {\n name: 'pgvector',\n setup,\n} satisfies Extension\n"],"mappings":"yCAAAA,IAMA,IAAMC,EAAQ,MAAOC,EAAsBC,KAClC,CACL,eAAAA,EACA,WAAY,IAAI,IAAI,8BAA+B,YAAY,GAAG,CACpE,GAGWC,EAAS,CACpB,KAAM,WACN,MAAAH,CACF","names":["init_esm_shims","setup","_pg","emscriptenOpts","vector"]}
|
|
Binary file
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";var pe=Object.defineProperty;var qe=Object.getOwnPropertyDescriptor;var ze=Object.getOwnPropertyNames;var $e=Object.prototype.hasOwnProperty;var Me=e=>{throw TypeError(e)};var je=(e,r)=>{for(var t in r)pe(e,t,{get:r[t],enumerable:!0})},He=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of ze(r))!$e.call(e,i)&&i!==t&&pe(e,i,{get:()=>r[i],enumerable:!(n=qe(r,i))||n.enumerable});return e};var Ye=e=>He(pe({},"__esModule",{value:!0}),e);var de=(e,r,t)=>r.has(e)||Me("Cannot "+t);var a=(e,r,t)=>(de(e,r,"read from private field"),t?t.call(e):r.get(e)),p=(e,r,t)=>r.has(e)?Me("Cannot add the same private member more than once"):r instanceof WeakSet?r.add(e):r.set(e,t),d=(e,r,t,n)=>(de(e,r,"write to private field"),n?n.call(e,t):r.set(e,t),t),c=(e,r,t)=>(de(e,r,"access private method"),t);var ye=(e,r,t,n)=>({set _(i){d(e,r,i,t)},get _(){return a(e,r,n)}});var zt={};je(zt,{LeaderChangedError:()=>le,PGliteWorker:()=>Ee,worker:()=>Qt});module.exports=Ye(zt);var Ke=()=>typeof document>"u"?new URL(`file:${__filename}`).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href,P=Ke();var ke={part:"part",container:"container"};function te(e,r,...t){let n=e.length-1,i=t.length-1;if(i!==-1){if(i===0){e[n]=e[n]+t[0]+r;return}e[n]=e[n]+t[0],e.push(...t.slice(1,i)),e.push(t[i]+r)}}function Je(e,...r){let t=[e[0]];t.raw=[e.raw[0]];let n=[];for(let i=0;i<r.length;i++){let s=r[i],o=i+1;if(s?._templateType===ke.part){te(t,e[o],s.str),te(t.raw,e.raw[o],s.str);continue}if(s?._templateType===ke.container){te(t,e[o],...s.strings),te(t.raw,e.raw[o],...s.strings.raw),n.push(...s.values);continue}t.push(e[o]),t.raw.push(e.raw[o]),n.push(s)}return{_templateType:"container",strings:t,values:n}}function me(e,...r){let{strings:t,values:n}=Je(e,...r);return{query:[t[0],...n.flatMap((i,s)=>[`$${s+1}`,t[s+1]])].join(""),params:n}}var Xe=globalThis.JSON.parse,Ze=globalThis.JSON.stringify,Ie=16,Le=17;var Ce=20,et=21,tt=23;var he=25,rt=26;var ve=114;var nt=700,st=701;var at=1042,it=1043,ot=1082;var ct=1114,Oe=1184;var lt=3802;var ut={string:{to:he,from:[he,it,at],serialize:e=>{if(typeof e=="string")return e;if(typeof e=="number")return e.toString();throw new Error("Invalid input for string type")},parse:e=>e},number:{to:0,from:[et,tt,rt,nt,st],serialize:e=>e.toString(),parse:e=>+e},bigint:{to:Ce,from:[Ce],serialize:e=>e.toString(),parse:e=>{let r=BigInt(e);return r<Number.MIN_SAFE_INTEGER||r>Number.MAX_SAFE_INTEGER?r:Number(r)}},json:{to:ve,from:[ve,lt],serialize:e=>typeof e=="string"?e:Ze(e),parse:e=>Xe(e)},boolean:{to:Ie,from:[Ie],serialize:e=>{if(typeof e!="boolean")throw new Error("Invalid input for boolean type");return e?"t":"f"},parse:e=>e==="t"},date:{to:Oe,from:[ot,ct,Oe],serialize:e=>{if(typeof e=="string")return e;if(typeof e=="number")return new Date(e).toISOString();if(e instanceof Date)return e.toISOString();throw new Error("Invalid input for date type")},parse:e=>new Date(e)},bytea:{to:Le,from:[Le],serialize:e=>{if(!(e instanceof Uint8Array))throw new Error("Invalid input for bytea type");return"\\x"+Array.from(e).map(r=>r.toString(16).padStart(2,"0")).join("")},parse:e=>{let r=e.slice(2);return Uint8Array.from({length:r.length/2},(t,n)=>parseInt(r.substring(n*2,(n+1)*2),16))}}},ge=pt(ut),Ue=ge.parsers,Ne=ge.serializers;function be(e,r,t){if(e===null)return null;let n=t?.[r]??ge.parsers[r];return n?n(e,r):e}function pt(e){return Object.keys(e).reduce(({parsers:r,serializers:t},n)=>{let{to:i,from:s,serialize:o,parse:u}=e[n];return t[i]=o,t[n]=o,r[n]=u,Array.isArray(s)?s.forEach(l=>{r[l]=u,t[l]=o}):(r[s]=u,t[s]=o),{parsers:r,serializers:t}},{parsers:{},serializers:{}})}var dt=/\\/g,yt=/"/g;function mt(e){return e.replace(dt,"\\\\").replace(yt,'\\"')}function we(e,r,t){if(Array.isArray(e)===!1)return e;if(!e.length)return"{}";let n=e[0],i=t===1020?";":",";return Array.isArray(n)?`{${e.map(s=>we(s,r,t)).join(i)}}`:`{${e.map(s=>(s===void 0&&(s=null),s===null?"null":'"'+mt(r?r(s):s.toString())+'"')).join(i)}}`}var fe={i:0,char:null,str:"",quoted:!1,last:0,p:null};function _e(e,r,t){return fe.i=fe.last=0,We(fe,e,r,t)[0]}function We(e,r,t,n){let i=[],s=n===1020?";":",";for(;e.i<r.length;e.i++){if(e.char=r[e.i],e.quoted)e.char==="\\"?e.str+=r[++e.i]:e.char==='"'?(i.push(t?t(e.str):e.str),e.str="",e.quoted=r[e.i+1]==='"',e.last=e.i+2):e.str+=e.char;else if(e.char==='"')e.quoted=!0;else if(e.char==="{")e.last=++e.i,i.push(We(e,r,t,n));else if(e.char==="}"){e.quoted=!1,e.last<e.i&&i.push(t?t(r.slice(e.last,e.i)):r.slice(e.last,e.i)),e.last=e.i+1;break}else e.char===s&&e.p!=="}"&&e.p!=='"'&&(i.push(t?t(r.slice(e.last,e.i)):r.slice(e.last,e.i)),e.last=e.i+1);e.p=e.char}return e.last<e.i&&i.push(t?t(r.slice(e.last,e.i+1)):r.slice(e.last,e.i+1)),i}function Pe(e,r,t,n){let i=[],s={rows:[],fields:[]},o=0,u={...r,...t?.parsers};return e.forEach(l=>{switch(l.name){case"rowDescription":{let m=l;s.fields=m.fields.map(y=>({name:y.name,dataTypeID:y.dataTypeID}));break}case"dataRow":{if(!s)break;let m=l;t?.rowMode==="array"?s.rows.push(m.fields.map((y,T)=>be(y,s.fields[T].dataTypeID,u))):s.rows.push(Object.fromEntries(m.fields.map((y,T)=>[s.fields[T].name,be(y,s.fields[T].dataTypeID,u)])));break}case"commandComplete":{o+=ft(l),i.push({...s,affectedRows:o,...n?{blob:n}:{}}),s={rows:[],fields:[]};break}}}),i.length===0&&i.push({affectedRows:0,rows:[],fields:[]}),i}function ft(e){let r=e.text.split(" ");switch(r[0]){case"INSERT":return parseInt(r[2],10);case"UPDATE":case"DELETE":case"COPY":case"MERGE":return parseInt(r[1],10);default:return 0}}function xe(e){let r=e.find(t=>t.name==="parameterDescription");return r?r.dataTypeIDs:[]}function W(e){let r=e.length;for(let t=e.length-1;t>=0;t--){let n=e.charCodeAt(t);n>127&&n<=2047?r++:n>2047&&n<=65535&&(r+=2),n>=56320&&n<=57343&&t--}return r}var b,w,F,ne,Q,A,re,G,Ge,L=class{constructor(r=256){this.size=r;p(this,A);p(this,b);p(this,w,5);p(this,F,!1);p(this,ne,new TextEncoder);p(this,Q,0);d(this,b,c(this,A,re).call(this,r))}addInt32(r){return c(this,A,G).call(this,4),a(this,b).setInt32(a(this,w),r,a(this,F)),d(this,w,a(this,w)+4),this}addInt16(r){return c(this,A,G).call(this,2),a(this,b).setInt16(a(this,w),r,a(this,F)),d(this,w,a(this,w)+2),this}addCString(r){return r&&this.addString(r),c(this,A,G).call(this,1),a(this,b).setUint8(a(this,w),0),ye(this,w)._++,this}addString(r=""){let t=W(r);return c(this,A,G).call(this,t),a(this,ne).encodeInto(r,new Uint8Array(a(this,b).buffer,a(this,w))),d(this,w,a(this,w)+t),this}add(r){return c(this,A,G).call(this,r.byteLength),new Uint8Array(a(this,b).buffer).set(new Uint8Array(r),a(this,w)),d(this,w,a(this,w)+r.byteLength),this}flush(r){let t=c(this,A,Ge).call(this,r);return d(this,w,5),d(this,b,c(this,A,re).call(this,this.size)),new Uint8Array(t)}};b=new WeakMap,w=new WeakMap,F=new WeakMap,ne=new WeakMap,Q=new WeakMap,A=new WeakSet,re=function(r){return new DataView(new ArrayBuffer(r))},G=function(r){if(a(this,b).byteLength-a(this,w)<r){let n=a(this,b).buffer,i=n.byteLength+(n.byteLength>>1)+r;d(this,b,c(this,A,re).call(this,i)),new Uint8Array(a(this,b).buffer).set(new Uint8Array(n))}},Ge=function(r){if(r){a(this,b).setUint8(a(this,Q),r);let t=a(this,w)-(a(this,Q)+1);a(this,b).setInt32(a(this,Q)+1,t,a(this,F))}return a(this,b).buffer.slice(r?0:5,a(this,w))};var g=new L,ht=e=>{g.addInt16(3).addInt16(0);for(let n of Object.keys(e))g.addCString(n).addCString(e[n]);g.addCString("client_encoding").addCString("UTF8");let r=g.addCString("").flush(),t=r.byteLength+4;return new L().addInt32(t).add(r).flush()},gt=()=>{let e=new DataView(new ArrayBuffer(8));return e.setInt32(0,8,!1),e.setInt32(4,80877103,!1),new Uint8Array(e.buffer)},bt=e=>g.addCString(e).flush(112),wt=(e,r)=>(g.addCString(e).addInt32(W(r)).addString(r),g.flush(112)),Pt=e=>g.addString(e).flush(112),xt=e=>g.addCString(e).flush(81),Tt=[],At=e=>{let r=e.name??"";r.length>63&&(console.error("Warning! Postgres only supports 63 characters for query names."),console.error("You supplied %s (%s)",r,r.length),console.error("This can cause conflicts and silent errors executing queries"));let t=g.addCString(r).addCString(e.text).addInt16(e.types?.length??0);return e.types?.forEach(n=>t.addInt32(n)),g.flush(80)},V=new L;var Rt=(e,r)=>{for(let t=0;t<e.length;t++){let n=r?r(e[t],t):e[t];if(n===null)g.addInt16(0),V.addInt32(-1);else if(n instanceof ArrayBuffer||ArrayBuffer.isView(n)){let i=ArrayBuffer.isView(n)?n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength):n;g.addInt16(1),V.addInt32(i.byteLength),V.add(i)}else g.addInt16(0),V.addInt32(W(n)),V.addString(n)}},Et=(e={})=>{let r=e.portal??"",t=e.statement??"",n=e.binary??!1,i=e.values??Tt,s=i.length;return g.addCString(r).addCString(t),g.addInt16(s),Rt(i,e.valueMapper),g.addInt16(s),g.add(V.flush()),g.addInt16(n?1:0),g.flush(66)},St=new Uint8Array([69,0,0,0,9,0,0,0,0,0]),Bt=e=>{if(!e||!e.portal&&!e.rows)return St;let r=e.portal??"",t=e.rows??0,n=W(r),i=4+n+1+4,s=new DataView(new ArrayBuffer(1+i));return s.setUint8(0,69),s.setInt32(1,i,!1),new TextEncoder().encodeInto(r,new Uint8Array(s.buffer,5)),s.setUint8(n+5,0),s.setUint32(s.byteLength-4,t,!1),new Uint8Array(s.buffer)},Dt=(e,r)=>{let t=new DataView(new ArrayBuffer(16));return t.setInt32(0,16,!1),t.setInt16(4,1234,!1),t.setInt16(6,5678,!1),t.setInt32(8,e,!1),t.setInt32(12,r,!1),new Uint8Array(t.buffer)},Te=(e,r)=>{let t=new L;return t.addCString(r),t.flush(e)},Mt=g.addCString("P").flush(68),kt=g.addCString("S").flush(68),It=e=>e.name?Te(68,`${e.type}${e.name??""}`):e.type==="P"?Mt:kt,Lt=e=>{let r=`${e.type}${e.name??""}`;return Te(67,r)},Ct=e=>g.add(e).flush(100),vt=e=>Te(102,e),se=e=>new Uint8Array([e,0,0,0,4]),Ot=se(72),Ut=se(83),Nt=se(88),_t=se(99),R={startup:ht,password:bt,requestSsl:gt,sendSASLInitialResponseMessage:wt,sendSCRAMClientFinalMessage:Pt,query:xt,parse:At,bind:Et,execute:Bt,describe:It,close:Lt,flush:()=>Ot,sync:()=>Ut,end:()=>Nt,copyData:Ct,copyDone:()=>_t,copyFail:vt,cancel:Dt};var C=class extends Error{constructor(t,n,i){super(t);this.length=n;this.name=i}};var mr=new ArrayBuffer(0);var Gt=1,Ft=4,Zr=Gt+Ft,en=new ArrayBuffer(0);function ae(e){let r=e.e;return r.query=e.query,r.params=e.params,r.queryOptions=e.options,r}var $,I,f,S,ie,v,Ae,oe=class{constructor(){p(this,f);this.serializers={...Ne};this.parsers={...Ue};p(this,$,!1);p(this,I,!1)}async _initArrayTypes({force:r=!1}={}){if(a(this,$)&&!r)return;d(this,$,!0);let t=await this.query(`
|
|
2
|
+
SELECT b.oid, b.typarray
|
|
3
|
+
FROM pg_catalog.pg_type a
|
|
4
|
+
LEFT JOIN pg_catalog.pg_type b ON b.oid = a.typelem
|
|
5
|
+
WHERE a.typcategory = 'A'
|
|
6
|
+
GROUP BY b.oid, b.typarray
|
|
7
|
+
ORDER BY b.oid
|
|
8
|
+
`);for(let n of t.rows)this.serializers[n.typarray]=i=>we(i,this.serializers[n.oid],n.typarray),this.parsers[n.typarray]=i=>_e(i,this.parsers[n.oid],n.typarray)}async refreshArrayTypes(){await this._initArrayTypes({force:!0})}async query(r,t,n){return await this._checkReady(),await this._runExclusiveTransaction(async()=>await c(this,f,ie).call(this,r,t,n))}async sql(r,...t){let{query:n,params:i}=me(r,...t);return await this.query(n,i)}async exec(r,t){return await this._checkReady(),await this._runExclusiveTransaction(async()=>await c(this,f,v).call(this,r,t))}async describeQuery(r,t){let n=[];try{await c(this,f,S).call(this,R.parse({text:r,types:t?.paramTypes}),t),n=await c(this,f,S).call(this,R.describe({type:"S"}),t)}catch(l){throw l instanceof C?ae({e:l,options:t,params:void 0,query:r}):l}finally{n.push(...await c(this,f,S).call(this,R.sync(),t))}let i=n.find(l=>l.name==="parameterDescription"),s=n.find(l=>l.name==="rowDescription"),o=i?.dataTypeIDs.map(l=>({dataTypeID:l,serializer:this.serializers[l]}))??[],u=s?.fields.map(l=>({name:l.name,dataTypeID:l.dataTypeID,parser:this.parsers[l.dataTypeID]}))??[];return{queryParams:o,resultFields:u}}async transaction(r){return await this._checkReady(),await this._runExclusiveTransaction(async()=>{await c(this,f,v).call(this,"BEGIN"),d(this,I,!0);let t=!1,n=()=>{if(t)throw new Error("Transaction is closed")},i={query:async(s,o,u)=>(n(),await c(this,f,ie).call(this,s,o,u)),sql:async(s,...o)=>{let{query:u,params:l}=me(s,...o);return await c(this,f,ie).call(this,u,l)},exec:async(s,o)=>(n(),await c(this,f,v).call(this,s,o)),rollback:async()=>{n(),await c(this,f,v).call(this,"ROLLBACK"),t=!0},listen:async(s,o)=>(n(),await this.listen(s,o,i)),get closed(){return t}};try{let s=await r(i);return t||(t=!0,await c(this,f,v).call(this,"COMMIT")),d(this,I,!1),s}catch(s){throw t||await c(this,f,v).call(this,"ROLLBACK"),d(this,I,!1),s}})}async runExclusive(r){return await this._runExclusiveQuery(r)}};$=new WeakMap,I=new WeakMap,f=new WeakSet,S=async function(r,t={}){return await this.execProtocolStream(r,{...t,syncToFs:!1})},ie=async function(r,t=[],n){return await this._runExclusiveQuery(async()=>{c(this,f,Ae).call(this,"runQuery",r,t,n),await this._handleBlob(n?.blob);let i=[];try{let o=await c(this,f,S).call(this,R.parse({text:r,types:n?.paramTypes}),n),u=xe(await c(this,f,S).call(this,R.describe({type:"S"}),n)),l=t.map((m,y)=>{let T=u[y];if(m==null)return null;let E=n?.serializers?.[T]??this.serializers[T];return E?E(m):m.toString()});i=[...o,...await c(this,f,S).call(this,R.bind({values:l}),n),...await c(this,f,S).call(this,R.describe({type:"P"}),n),...await c(this,f,S).call(this,R.execute({}),n)]}catch(o){throw o instanceof C?ae({e:o,options:n,params:t,query:r}):o}finally{i.push(...await c(this,f,S).call(this,R.sync(),n))}await this._cleanupBlob(),a(this,I)||await this.syncToFs();let s=await this._getWrittenBlob();return Pe(i,this.parsers,n,s)[0]})},v=async function(r,t){return await this._runExclusiveQuery(async()=>{c(this,f,Ae).call(this,"runExec",r,t),await this._handleBlob(t?.blob);let n=[];try{n=await c(this,f,S).call(this,R.query(r),t)}catch(s){throw s instanceof C?ae({e:s,options:t,params:void 0,query:r}):s}finally{n.push(...await c(this,f,S).call(this,R.sync(),t))}this._cleanupBlob(),a(this,I)||await this.syncToFs();let i=await this._getWrittenBlob();return Pe(n,this.parsers,t,i)})},Ae=function(...r){this.debug>0&&console.log(...r)};var Bn=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string";var Re=()=>{if(globalThis.crypto?.randomUUID)return globalThis.crypto.randomUUID();let e=new Uint8Array(16);if(globalThis.crypto?.getRandomValues)globalThis.crypto.getRandomValues(e);else for(let t=0;t<e.length;t++)e[t]=Math.floor(Math.random()*256);e[6]=e[6]&15|64,e[8]=e[8]&63|128;let r=[];return e.forEach(t=>{r.push(t.toString(16).padStart(2,"0"))}),r.slice(0,4).join("")+"-"+r.slice(4,6).join("")+"-"+r.slice(6,8).join("")+"-"+r.slice(8,10).join("")+"-"+r.slice(10).join("")};function Fe(e){let r;return e.startsWith('"')&&e.endsWith('"')?r=e.substring(1,e.length-1):r=e.toLowerCase(),r}var q,j,H,z,Y,B,O,U,D,K,J,X,N,k,Z,M,_,ee,ue,h,Qe,ce,x,Ve,Be=class Be extends oe{constructor(t,n){super();p(this,h);p(this,q);p(this,j,0);p(this,H,!1);p(this,z,!1);p(this,Y,!1);p(this,B,new EventTarget);p(this,O);p(this,U,!1);p(this,D);p(this,K);p(this,J);p(this,X);p(this,N);p(this,k);p(this,Z);p(this,M,new Map);p(this,_,new Set);p(this,ee);p(this,ue,[]);d(this,D,t),d(this,O,Re()),d(this,ee,n?.extensions??{}),d(this,J,new Promise(i=>{a(this,D).addEventListener("message",s=>{if(s.data.type==="here")i();else throw new Error("Invalid message")},{once:!0})})),d(this,X,new Promise(i=>{let s=o=>{o.data.type==="ready"&&(d(this,K,o.data.id),a(this,D).removeEventListener("message",s),i())};a(this,D).addEventListener("message",s)})),d(this,q,c(this,h,Qe).call(this,n))}static async create(t,n){let i=new Be(t,n);return await a(i,q),i}get waitReady(){return new Promise(t=>{a(this,q).then(()=>{a(this,U)?t():t(new Promise(n=>{a(this,B).addEventListener("connected",()=>{n()})}))})})}get debug(){return a(this,j)}get ready(){return a(this,H)}get closed(){return a(this,z)}get isLeader(){return a(this,Y)}async close(){var t;a(this,z)||(d(this,z,!0),a(this,N)?.close(),a(this,k)?.close(),(t=a(this,Z))==null||t.call(this),a(this,D).terminate())}async[Symbol.asyncDispose](){await this.close()}async execProtocolRaw(t){return await c(this,h,x).call(this,"execProtocolRaw",t)}async execProtocol(t){return await c(this,h,x).call(this,"execProtocol",t)}async execProtocolStream(t){return await c(this,h,x).call(this,"execProtocolStream",t)}async execProtocolRawStream(t,n){await c(this,h,x).call(this,"execProtocolRawStream",t,n)}async syncToFs(){await c(this,h,x).call(this,"syncToFs")}async listen(t,n,i){let s=Fe(t),o=i??this;return a(this,M).has(s)||a(this,M).set(s,new Set),a(this,M).get(s).add(n),await o.exec(`LISTEN ${t}`),async u=>{await this.unlisten(s,n,u)}}async unlisten(t,n,i){await this.waitReady;let s=i??this;n?a(this,M).get(t)?.delete(n):a(this,M).delete(t),a(this,M).get(t)?.size===0&&await s.exec(`UNLISTEN ${t}`)}onNotification(t){return a(this,_).add(t),()=>{a(this,_).delete(t)}}offNotification(t){a(this,_).delete(t)}async dumpDataDir(t){return await c(this,h,x).call(this,"dumpDataDir",t)}onLeaderChange(t){return a(this,B).addEventListener("leader-change",t),()=>{a(this,B).removeEventListener("leader-change",t)}}offLeaderChange(t){a(this,B).removeEventListener("leader-change",t)}async _handleBlob(t){await c(this,h,x).call(this,"_handleBlob",t)}async _getWrittenBlob(){return await c(this,h,x).call(this,"_getWrittenBlob")}async _cleanupBlob(){await c(this,h,x).call(this,"_cleanupBlob")}async _checkReady(){await this.waitReady}async _runExclusiveQuery(t){await c(this,h,x).call(this,"_acquireQueryLock");try{return await t()}finally{await c(this,h,x).call(this,"_releaseQueryLock")}}async _runExclusiveTransaction(t){await c(this,h,x).call(this,"_acquireTransactionLock");try{return await t()}finally{await c(this,h,x).call(this,"_releaseTransactionLock")}}};q=new WeakMap,j=new WeakMap,H=new WeakMap,z=new WeakMap,Y=new WeakMap,B=new WeakMap,O=new WeakMap,U=new WeakMap,D=new WeakMap,K=new WeakMap,J=new WeakMap,X=new WeakMap,N=new WeakMap,k=new WeakMap,Z=new WeakMap,M=new WeakMap,_=new WeakMap,ee=new WeakMap,ue=new WeakMap,h=new WeakSet,Qe=async function(t={}){for(let[l,m]of Object.entries(a(this,ee))){if(m instanceof URL)throw new Error("URL extensions are not supported on the client side of a worker");{let y=await m.setup(this,{},!0);if(y.emscriptenOpts&&console.warn(`PGlite extension ${l} returned emscriptenOpts, these are not supported on the client side of a worker`),y.namespaceObj){let T=this;T[l]=y.namespaceObj}y.bundlePath&&console.warn(`PGlite extension ${l} returned bundlePath, this is not supported on the client side of a worker`),y.init&&await y.init(),y.close&&a(this,ue).push(y.close)}}await a(this,J);let{extensions:n,...i}=t;a(this,D).postMessage({type:"init",options:i}),await a(this,X);let s=`pglite-tab-close:${a(this,O)}`;d(this,Z,await Se(s));let o=`pglite-broadcast:${a(this,K)}`;d(this,N,new BroadcastChannel(o));let u=`pglite-tab:${a(this,O)}`;d(this,k,new BroadcastChannel(u)),a(this,N).addEventListener("message",async l=>{l.data.type==="leader-here"?(d(this,U,!1),a(this,B).dispatchEvent(new Event("leader-change")),c(this,h,ce).call(this)):l.data.type==="notify"&&c(this,h,Ve).call(this,l.data.channel,l.data.payload)}),a(this,k).addEventListener("message",async l=>{l.data.type==="connected"&&(d(this,U,!0),a(this,B).dispatchEvent(new Event("connected")),d(this,j,await c(this,h,x).call(this,"getDebugLevel")),d(this,H,!0))}),a(this,D).addEventListener("message",async l=>{l.data.type==="leader-now"&&(d(this,Y,!0),a(this,B).dispatchEvent(new Event("leader-change")))}),c(this,h,ce).call(this),this._initArrayTypes()},ce=async function(){a(this,U)||(a(this,N).postMessage({type:"tab-here",id:a(this,O)}),setTimeout(()=>c(this,h,ce).call(this),16))},x=async function(t,...n){let i=Re(),s={type:"rpc-call",callId:i,method:t,args:n};return a(this,k).postMessage(s),await new Promise((o,u)=>{let l=T=>{if(T.data.callId!==i)return;y();let E=T.data;if(E.type==="rpc-return")o(E.result);else if(E.type==="rpc-error"){let De=new Error(E.error.message);Object.assign(De,E.error),u(De)}else u(new Error("Invalid message"))},m=()=>{y(),u(new le)},y=()=>{a(this,k).removeEventListener("message",l),a(this,B).removeEventListener("leader-change",m)};a(this,B).addEventListener("leader-change",m),a(this,k).addEventListener("message",l)})},Ve=function(t,n){let i=a(this,M).get(t);if(i)for(let s of i)queueMicrotask(()=>s(n));for(let s of a(this,_))queueMicrotask(()=>s(t,n))};var Ee=Be;async function Qt({init:e}){postMessage({type:"here"});let r=await new Promise(m=>{addEventListener("message",y=>{y.data.type==="init"&&m(y.data.options)},{once:!0})}),t=r.id??`${P}:${r.dataDir??""}`;postMessage({type:"ready",id:t});let n=`pglite-election-lock:${t}`,i=`pglite-broadcast:${t}`,s=new BroadcastChannel(i),o=new Set;await Se(n);let u=e(r);s.onmessage=async m=>{let y=m.data;switch(y.type){case"tab-here":Vt(y.id,await u,o);break}},s.postMessage({type:"leader-here",id:t}),postMessage({type:"leader-now"}),(await u).onNotification((m,y)=>{s.postMessage({type:"notify",channel:m,payload:y})})}function Vt(e,r,t){if(t.has(e))return;t.add(e);let n=`pglite-tab:${e}`,i=`pglite-tab-close:${e}`,s=new BroadcastChannel(n);navigator.locks.request(i,()=>new Promise(u=>{s.close(),t.delete(e),u()}));let o=qt(e,r);s.addEventListener("message",async u=>{let l=u.data;switch(l.type){case"rpc-call":{await r.waitReady;let{callId:m,method:y,args:T}=l;try{let E=await o[y](...T);s.postMessage({type:"rpc-return",callId:m,result:E})}catch(E){console.error(E),s.postMessage({type:"rpc-error",callId:m,error:{message:E.message}})}break}}}),s.postMessage({type:"connected"})}function qt(e,r){let t=null,n=null,i=`pglite-tab-close:${e}`;return Se(i).then(()=>{n&&r.exec("ROLLBACK"),t?.(),n?.()}),{async getDebugLevel(){return r.debug},async close(){await r.close()},async execProtocol(s){let{messages:o,data:u}=await r.execProtocol(s);if(u.byteLength!==u.buffer.byteLength){let l=new ArrayBuffer(u.byteLength),m=new Uint8Array(l);return m.set(u),{messages:o,data:m}}else return{messages:o,data:u}},async execProtocolStream(s){return await r.execProtocolStream(s)},async execProtocolRawStream(s,o){return await r.execProtocolRawStream(s,o)},async execProtocolRaw(s){let o=await r.execProtocolRaw(s);if(o.byteLength!==o.buffer.byteLength){let u=new ArrayBuffer(o.byteLength),l=new Uint8Array(u);return l.set(o),l}else return o},async dumpDataDir(s){return await r.dumpDataDir(s)},async syncToFs(){return await r.syncToFs()},async _handleBlob(s){return await r._handleBlob(s)},async _getWrittenBlob(){return await r._getWrittenBlob()},async _cleanupBlob(){return await r._cleanupBlob()},async _checkReady(){return await r._checkReady()},async _acquireQueryLock(){return new Promise(s=>{r._runExclusiveQuery(()=>new Promise(o=>{t=o,s()}))})},async _releaseQueryLock(){t?.(),t=null},async _acquireTransactionLock(){return new Promise(s=>{r._runExclusiveTransaction(()=>new Promise(o=>{n=o,s()}))})},async _releaseTransactionLock(){n?.(),n=null}}}var le=class extends Error{constructor(){super("Leader changed, pending operation in indeterminate state")}};async function Se(e){let r;return await new Promise(t=>{navigator.locks.request(e,()=>new Promise(n=>{r=n,t()}))}),r}0&&(module.exports={LeaderChangedError,PGliteWorker,worker});
|
|
9
|
+
//# sourceMappingURL=index.cjs.map
|