@electric-sql/pglite
Advanced tools
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
| import{j as g}from"./chunk-QY3QWFKW.js";g();var d=Object.defineProperty,f=(t,e)=>{for(var r in e)d(t,r,{get:e[r],enumerable:!0})},p={};f(p,{IN_NODE:()=>s,WASM_PREFIX:()=>m,getFsBundle:()=>w,instantiateWasm:()=>b,pgliteProc:()=>y,rmdirRecursive:()=>u,startArtifactDownload:()=>c,toPostgresName:()=>v,uuid:()=>S});function h(){let t=process.type;return t==="renderer"||t==="worker"||t==="service-worker"}var s=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string"&&!h(),m="/pglite",y=globalThis&&typeof globalThis.process<"u"?globalThis.process:{exitCode:void 0},a=new Map;async function c(t){s||a.has(t.toString())||a.set(t.toString(),fetch(t))}var o=new Map;async function b(t,e,r){if(r||o.has(e.toString())){let i=r||o.get(e.toString());return{instance:await WebAssembly.instantiate(i,t),module:i}}if(s){let i=await(await import("fs/promises")).readFile(e),{module:n,instance:l}=await WebAssembly.instantiate(i,t);return o.set(e.toString(),n),{instance:l,module:n}}else{a.has(e.toString())||c(e);let i=await a.get(e.toString()),{module:n,instance:l}=await WebAssembly.instantiateStreaming(i.clone(),t);return o.set(e.toString(),n),{instance:l,module:n}}}async function w(t){return s?(await(await import("fs/promises")).readFile(t)).buffer:(c(t),(await a.get(t.toString())).clone().arrayBuffer())}var S=()=>{if(globalThis.crypto?.randomUUID)return globalThis.crypto.randomUUID();let t=new Uint8Array(16);if(globalThis.crypto?.getRandomValues)globalThis.crypto.getRandomValues(t);else for(let r=0;r<t.length;r++)t[r]=Math.floor(Math.random()*256);t[6]=t[6]&15|64,t[8]=t[8]&63|128;let e=[];return t.forEach(r=>{e.push(r.toString(16).padStart(2,"0"))}),e.slice(0,4).join("")+"-"+e.slice(4,6).join("")+"-"+e.slice(6,8).join("")+"-"+e.slice(8,10).join("")+"-"+e.slice(10).join("")};function v(t){let e;return t.startsWith('"')&&t.endsWith('"')?e=t.substring(1,t.length-1):e=t.toLowerCase(),e}function u(t,e){try{let r=t.readdir(e).filter(i=>i!=="."&&i!=="..");for(let i of r){let n=e+"/"+i;try{t.readdir(n),u(t,n)}catch{t.unlink(n)}}t.rmdir(e)}catch{try{t.unlink(e)}catch{}}}export{p as a}; | ||
| //# sourceMappingURL=chunk-NNS5RQRF.js.map |
| {"version":3,"sources":["../../pglite-utils/src/utils.ts"],"sourcesContent":["// Electron exposes a Node-like `process` in its renderer/worker/service-worker\n// contexts, which must use the browser fs path. Its main and utility processes\n// are real Node environments (#813).\nfunction isElectronWebContext(): boolean {\n const type = (process as { type?: string }).type\n return type === 'renderer' || type === 'worker' || type === 'service-worker'\n}\n\nexport const IN_NODE =\n typeof process === 'object' &&\n typeof process.versions === 'object' &&\n typeof process.versions.node === 'string' &&\n !isElectronWebContext()\n\nexport const WASM_PREFIX = '/pglite'\n\nexport const pgliteProc =\n globalThis && typeof globalThis.process !== 'undefined'\n ? globalThis.process\n : { exitCode: undefined }\n\nconst artifactDownloadPromises = new Map<string, Promise<Response>>()\n\nexport async function startArtifactDownload(url: URL) {\n if (IN_NODE || artifactDownloadPromises.has(url.toString())) {\n return\n }\n artifactDownloadPromises.set(url.toString(), fetch(url))\n}\n\n// This is a global cache of the Wasm modules to avoid having to re-download or\n// compile them on subsequent calls.\nconst cachedWasmModules = new Map<string, WebAssembly.Module>()\n\nexport async function instantiateWasm(\n imports: WebAssembly.Imports,\n moduleUrl: URL,\n module?: WebAssembly.Module,\n): Promise<{\n instance: WebAssembly.Instance\n module: WebAssembly.Module\n}> {\n if (module || cachedWasmModules.has(moduleUrl.toString())) {\n const mod = module || cachedWasmModules.get(moduleUrl.toString())!\n return {\n instance: await WebAssembly.instantiate(mod, imports),\n module: mod,\n }\n }\n if (IN_NODE) {\n const fs = await import('fs/promises')\n const buffer = await fs.readFile(moduleUrl)\n const { module: newModule, instance } = await WebAssembly.instantiate(\n buffer,\n imports,\n )\n cachedWasmModules.set(moduleUrl.toString(), newModule)\n return {\n instance,\n module: newModule,\n }\n } else {\n if (!artifactDownloadPromises.has(moduleUrl.toString())) {\n startArtifactDownload(moduleUrl)\n // wasmDownloadPromises.set(moduleUrl, fetch(moduleUrl))\n }\n const response = await artifactDownloadPromises.get(moduleUrl.toString())\n const { module: newModule, instance } =\n await WebAssembly.instantiateStreaming(response!.clone(), imports)\n cachedWasmModules.set(moduleUrl.toString(), newModule)\n return {\n instance,\n module: newModule,\n }\n }\n}\n\nexport async function getFsBundle(fsBundleUrl: URL): Promise<ArrayBuffer> {\n if (IN_NODE) {\n const fs = await import('fs/promises')\n const fileData = await fs.readFile(fsBundleUrl)\n return fileData.buffer\n } else {\n startArtifactDownload(fsBundleUrl)\n const response = await artifactDownloadPromises.get(fsBundleUrl.toString())\n return response!.clone().arrayBuffer()\n }\n}\n\nexport const uuid = (): string => {\n // best case, `crypto.randomUUID` is available\n if (globalThis.crypto?.randomUUID) {\n return globalThis.crypto.randomUUID()\n }\n\n const bytes = new Uint8Array(16)\n\n if (globalThis.crypto?.getRandomValues) {\n // `crypto.getRandomValues` is available even in non-secure contexts\n globalThis.crypto.getRandomValues(bytes)\n } else {\n // fallback to Math.random, if the Crypto API is completely missing\n for (let i = 0; i < bytes.length; i++) {\n bytes[i] = Math.floor(Math.random() * 256)\n }\n }\n\n bytes[6] = (bytes[6] & 0x0f) | 0x40 // Set the 4 most significant bits to 0100\n bytes[8] = (bytes[8] & 0x3f) | 0x80 // Set the 2 most significant bits to 10\n\n const hexValues: string[] = []\n bytes.forEach((byte) => {\n hexValues.push(byte.toString(16).padStart(2, '0'))\n })\n\n return (\n hexValues.slice(0, 4).join('') +\n '-' +\n hexValues.slice(4, 6).join('') +\n '-' +\n hexValues.slice(6, 8).join('') +\n '-' +\n hexValues.slice(8, 10).join('') +\n '-' +\n hexValues.slice(10).join('')\n )\n}\n\n/**\n * Postgresql handles quoted names as CaseSensitive and unquoted as lower case.\n * If input is quoted, returns an unquoted string (same casing)\n * If input is unquoted, returns a lower-case string\n */\nexport function toPostgresName(input: string): string {\n let output\n if (input.startsWith('\"') && input.endsWith('\"')) {\n // Postgres sensitive case\n output = input.substring(1, input.length - 1)\n } else {\n // Postgres case insensitive - all to lower\n output = input.toLowerCase()\n }\n return output\n}\n\ninterface MinimalFS {\n readdir(path: string): string[]\n unlink(path: string): void\n rmdir(path: string): void\n}\n\nexport function rmdirRecursive(fs: MinimalFS, path: string) {\n try {\n // If readdir succeeds it's a directory\n const entries = fs.readdir(path).filter((n: any) => n !== '.' && n !== '..')\n for (const name of entries) {\n const child = path + '/' + name\n // Recurse or unlink depending on whether child is a directory\n try {\n fs.readdir(child)\n rmdirRecursive(fs, child)\n } catch (e) {\n // readdir failed => not a directory\n fs.unlink(child)\n }\n }\n fs.rmdir(path)\n } catch (e) {\n // not a directory: try unlink\n try {\n fs.unlink(path)\n } catch (_) {\n /* ignore if already gone */\n }\n }\n}\n"],"mappings":"kIAAAA,EAAA,CAAA,EAAAC,EAAAD,EAAA,CAAA,QAAA,IAAAE,EAAA,YAAA,IAAAC,EAAA,YAAA,IAAAC,EAAA,gBAAA,IAAAC,EAAA,WAAA,IAAAC,EAAA,eAAA,IAAAC,EAAA,sBAAA,IAAAC,EAAA,eAAA,IAAAC,EAAA,KAAA,IAAAC,CAAAA,CAAAA,EAGA,SAASC,GAAgC,CACvC,IAAMC,EAAQ,QAA8B,KAC5C,OAAOA,IAAS,YAAcA,IAAS,UAAYA,IAAS,gBAC9D,CAEO,IAAMV,EACX,OAAO,SAAY,UACnB,OAAO,QAAQ,UAAa,UAC5B,OAAO,QAAQ,SAAS,MAAS,UACjC,CAACS,EAAqB,EAEXR,EAAc,UAEdG,EACX,YAAc,OAAO,WAAW,QAAY,IACxC,WAAW,QACX,CAAE,SAAU,MAAU,EAEtBO,EAA2B,IAAI,IAErC,eAAsBL,EAAsBM,EAAU,CAChDZ,GAAWW,EAAyB,IAAIC,EAAI,SAAS,CAAC,GAG1DD,EAAyB,IAAIC,EAAI,SAAS,EAAG,MAAMA,CAAG,CAAC,CACzD,CAIA,IAAMC,EAAoB,IAAI,IAE9B,eAAsBV,EACpBW,EACAC,EACAC,EAIC,CACD,GAAIA,GAAUH,EAAkB,IAAIE,EAAU,SAAS,CAAC,EAAG,CACzD,IAAME,EAAMD,GAAUH,EAAkB,IAAIE,EAAU,SAAS,CAAC,EAChE,MAAO,CACL,SAAU,MAAM,YAAY,YAAYE,EAAKH,CAAO,EACpD,OAAQG,CACV,CACF,CACA,GAAIjB,EAAS,CAEX,IAAMkB,EAAS,MADJ,KAAM,QAAO,aAAa,GACb,SAASH,CAAS,EACpC,CAAE,OAAQI,EAAW,SAAAC,CAAS,EAAI,MAAM,YAAY,YACxDF,EACAJ,CACF,EACA,OAAAD,EAAkB,IAAIE,EAAU,SAAS,EAAGI,CAAS,EAC9C,CACL,SAAAC,EACA,OAAQD,CACV,CACF,KAAO,CACAR,EAAyB,IAAII,EAAU,SAAS,CAAC,GACpDT,EAAsBS,CAAS,EAGjC,IAAMM,EAAW,MAAMV,EAAyB,IAAII,EAAU,SAAS,CAAC,EAClE,CAAE,OAAQI,EAAW,SAAAC,CAAS,EAClC,MAAM,YAAY,qBAAqBC,EAAU,MAAM,EAAGP,CAAO,EACnE,OAAAD,EAAkB,IAAIE,EAAU,SAAS,EAAGI,CAAS,EAC9C,CACL,SAAAC,EACA,OAAQD,CACV,CACF,CACF,CAEA,eAAsBjB,EAAYoB,EAAwC,CACxE,OAAItB,GAEe,MADN,KAAM,QAAO,aAAa,GACX,SAASsB,CAAW,GAC9B,QAEhBhB,EAAsBgB,CAAW,GAChB,MAAMX,EAAyB,IAAIW,EAAY,SAAS,CAAC,GACzD,MAAM,EAAE,YAAY,EAEzC,CAEO,IAAMd,EAAO,IAAc,CAEhC,GAAI,WAAW,QAAQ,WACrB,OAAO,WAAW,OAAO,WAAW,EAGtC,IAAMe,EAAQ,IAAI,WAAW,EAAE,EAE/B,GAAI,WAAW,QAAQ,gBAErB,WAAW,OAAO,gBAAgBA,CAAK,MAGvC,SAASC,EAAI,EAAGA,EAAID,EAAM,OAAQC,IAChCD,EAAMC,CAAC,EAAI,KAAK,MAAM,KAAK,OAAO,EAAI,GAAG,EAI7CD,EAAM,CAAC,EAAKA,EAAM,CAAC,EAAI,GAAQ,GAC/BA,EAAM,CAAC,EAAKA,EAAM,CAAC,EAAI,GAAQ,IAE/B,IAAME,EAAsB,CAAC,EAC7B,OAAAF,EAAM,QAASG,GAAS,CACtBD,EAAU,KAAKC,EAAK,SAAS,EAAE,EAAE,SAAS,EAAG,GAAG,CAAC,CACnD,CAAC,EAGCD,EAAU,MAAM,EAAG,CAAC,EAAE,KAAK,EAAE,EAC7B,IACAA,EAAU,MAAM,EAAG,CAAC,EAAE,KAAK,EAAE,EAC7B,IACAA,EAAU,MAAM,EAAG,CAAC,EAAE,KAAK,EAAE,EAC7B,IACAA,EAAU,MAAM,EAAG,EAAE,EAAE,KAAK,EAAE,EAC9B,IACAA,EAAU,MAAM,EAAE,EAAE,KAAK,EAAE,CAE/B,EAOO,SAASlB,EAAeoB,EAAuB,CACpD,IAAIC,EACJ,OAAID,EAAM,WAAW,GAAG,GAAKA,EAAM,SAAS,GAAG,EAE7CC,EAASD,EAAM,UAAU,EAAGA,EAAM,OAAS,CAAC,EAG5CC,EAASD,EAAM,YAAY,EAEtBC,CACT,CAQO,SAASvB,EAAewB,EAAeC,EAAc,CAC1D,GAAI,CAEF,IAAMC,EAAUF,EAAG,QAAQC,CAAI,EAAE,OAAQE,GAAWA,IAAM,KAAOA,IAAM,IAAI,EAC3E,QAAWC,KAAQF,EAAS,CAC1B,IAAMG,EAAQJ,EAAO,IAAMG,EAE3B,GAAI,CACFJ,EAAG,QAAQK,CAAK,EAChB7B,EAAewB,EAAIK,CAAK,CAC1B,MAAY,CAEVL,EAAG,OAAOK,CAAK,CACjB,CACF,CACAL,EAAG,MAAMC,CAAI,CACf,MAAY,CAEV,GAAI,CACFD,EAAG,OAAOC,CAAI,CAChB,MAAY,CAEZ,CACF,CACF","names":["utils_exports","__export","IN_NODE","WASM_PREFIX","getFsBundle","instantiateWasm","pgliteProc","rmdirRecursive","startArtifactDownload","toPostgresName","uuid","isElectronWebContext","type","artifactDownloadPromises","url","cachedWasmModules","imports","moduleUrl","module","mod","buffer","newModule","instance","response","fsBundleUrl","bytes","i","hexValues","byte","input","output","fs","path","entries","n","name","child"]} |
| declare const Modes: { | ||
| readonly text: 0; | ||
| readonly binary: 1; | ||
| }; | ||
| type Mode = (typeof Modes)[keyof typeof Modes]; | ||
| type BufferParameter = ArrayBuffer | ArrayBufferView; | ||
| type MessageName = 'parseComplete' | 'bindComplete' | 'closeComplete' | 'noData' | 'portalSuspended' | 'replicationStart' | 'emptyQuery' | 'copyDone' | 'copyData' | 'rowDescription' | 'parameterDescription' | 'parameterStatus' | 'backendKeyData' | 'notification' | 'readyForQuery' | 'commandComplete' | 'dataRow' | 'copyInResponse' | 'copyOutResponse' | 'authenticationOk' | 'authenticationMD5Password' | 'authenticationCleartextPassword' | 'authenticationSASL' | 'authenticationSASLContinue' | 'authenticationSASLFinal' | 'error' | 'notice'; | ||
| type BackendMessage = { | ||
| name: MessageName; | ||
| length: number; | ||
| }; | ||
| declare const parseComplete: BackendMessage; | ||
| declare const bindComplete: BackendMessage; | ||
| declare const closeComplete: BackendMessage; | ||
| declare const noData: BackendMessage; | ||
| declare const portalSuspended: BackendMessage; | ||
| declare const replicationStart: BackendMessage; | ||
| declare const emptyQuery: BackendMessage; | ||
| declare const copyDone: BackendMessage; | ||
| declare class AuthenticationOk implements BackendMessage { | ||
| readonly length: number; | ||
| readonly name = "authenticationOk"; | ||
| constructor(length: number); | ||
| } | ||
| declare class AuthenticationCleartextPassword implements BackendMessage { | ||
| readonly length: number; | ||
| readonly name = "authenticationCleartextPassword"; | ||
| constructor(length: number); | ||
| } | ||
| declare class AuthenticationMD5Password implements BackendMessage { | ||
| readonly length: number; | ||
| readonly salt: Uint8Array; | ||
| readonly name = "authenticationMD5Password"; | ||
| constructor(length: number, salt: Uint8Array); | ||
| } | ||
| declare class AuthenticationSASL implements BackendMessage { | ||
| readonly length: number; | ||
| readonly mechanisms: string[]; | ||
| readonly name = "authenticationSASL"; | ||
| constructor(length: number, mechanisms: string[]); | ||
| } | ||
| declare class AuthenticationSASLContinue implements BackendMessage { | ||
| readonly length: number; | ||
| readonly data: string; | ||
| readonly name = "authenticationSASLContinue"; | ||
| constructor(length: number, data: string); | ||
| } | ||
| declare class AuthenticationSASLFinal implements BackendMessage { | ||
| readonly length: number; | ||
| readonly data: string; | ||
| readonly name = "authenticationSASLFinal"; | ||
| constructor(length: number, data: string); | ||
| } | ||
| type AuthenticationMessage = AuthenticationOk | AuthenticationCleartextPassword | AuthenticationMD5Password | AuthenticationSASL | AuthenticationSASLContinue | AuthenticationSASLFinal; | ||
| interface NoticeOrError { | ||
| message: string | undefined; | ||
| severity: string | undefined; | ||
| code: string | undefined; | ||
| detail: string | undefined; | ||
| hint: string | undefined; | ||
| position: string | undefined; | ||
| internalPosition: string | undefined; | ||
| internalQuery: string | undefined; | ||
| where: string | undefined; | ||
| schema: string | undefined; | ||
| table: string | undefined; | ||
| column: string | undefined; | ||
| dataType: string | undefined; | ||
| constraint: string | undefined; | ||
| file: string | undefined; | ||
| line: string | undefined; | ||
| routine: string | undefined; | ||
| } | ||
| declare class DatabaseError extends Error implements NoticeOrError { | ||
| readonly length: number; | ||
| readonly name: MessageName; | ||
| severity: string | undefined; | ||
| code: string | undefined; | ||
| detail: string | undefined; | ||
| hint: string | undefined; | ||
| position: string | undefined; | ||
| internalPosition: string | undefined; | ||
| internalQuery: string | undefined; | ||
| where: string | undefined; | ||
| schema: string | undefined; | ||
| table: string | undefined; | ||
| column: string | undefined; | ||
| dataType: string | undefined; | ||
| constraint: string | undefined; | ||
| file: string | undefined; | ||
| line: string | undefined; | ||
| routine: string | undefined; | ||
| constructor(message: string, length: number, name: MessageName); | ||
| } | ||
| declare class CopyDataMessage implements BackendMessage { | ||
| readonly length: number; | ||
| readonly chunk: Uint8Array; | ||
| readonly name = "copyData"; | ||
| constructor(length: number, chunk: Uint8Array); | ||
| } | ||
| declare class CopyResponse implements BackendMessage { | ||
| readonly length: number; | ||
| readonly name: MessageName; | ||
| readonly binary: boolean; | ||
| readonly columnTypes: number[]; | ||
| constructor(length: number, name: MessageName, binary: boolean, columnCount: number); | ||
| } | ||
| declare class Field { | ||
| readonly name: string; | ||
| readonly tableID: number; | ||
| readonly columnID: number; | ||
| readonly dataTypeID: number; | ||
| readonly dataTypeSize: number; | ||
| readonly dataTypeModifier: number; | ||
| readonly format: Mode; | ||
| constructor(name: string, tableID: number, columnID: number, dataTypeID: number, dataTypeSize: number, dataTypeModifier: number, format: Mode); | ||
| } | ||
| declare class RowDescriptionMessage implements BackendMessage { | ||
| readonly length: number; | ||
| readonly fieldCount: number; | ||
| readonly name: MessageName; | ||
| readonly fields: Field[]; | ||
| constructor(length: number, fieldCount: number); | ||
| } | ||
| declare class ParameterDescriptionMessage implements BackendMessage { | ||
| readonly length: number; | ||
| readonly parameterCount: number; | ||
| readonly name: MessageName; | ||
| readonly dataTypeIDs: number[]; | ||
| constructor(length: number, parameterCount: number); | ||
| } | ||
| declare class ParameterStatusMessage implements BackendMessage { | ||
| readonly length: number; | ||
| readonly parameterName: string; | ||
| readonly parameterValue: string; | ||
| readonly name: MessageName; | ||
| constructor(length: number, parameterName: string, parameterValue: string); | ||
| } | ||
| declare class BackendKeyDataMessage implements BackendMessage { | ||
| readonly length: number; | ||
| readonly processID: number; | ||
| readonly secretKey: number; | ||
| readonly name: MessageName; | ||
| constructor(length: number, processID: number, secretKey: number); | ||
| } | ||
| declare class NotificationResponseMessage implements BackendMessage { | ||
| readonly length: number; | ||
| readonly processId: number; | ||
| readonly channel: string; | ||
| readonly payload: string; | ||
| readonly name: MessageName; | ||
| constructor(length: number, processId: number, channel: string, payload: string); | ||
| } | ||
| declare class ReadyForQueryMessage implements BackendMessage { | ||
| readonly length: number; | ||
| readonly status: string; | ||
| readonly name: MessageName; | ||
| constructor(length: number, status: string); | ||
| } | ||
| declare class CommandCompleteMessage implements BackendMessage { | ||
| readonly length: number; | ||
| readonly text: string; | ||
| readonly name: MessageName; | ||
| constructor(length: number, text: string); | ||
| } | ||
| declare class DataRowMessage implements BackendMessage { | ||
| length: number; | ||
| fields: (string | null)[]; | ||
| readonly fieldCount: number; | ||
| readonly name: MessageName; | ||
| constructor(length: number, fields: (string | null)[]); | ||
| } | ||
| declare class NoticeMessage implements BackendMessage, NoticeOrError { | ||
| readonly length: number; | ||
| readonly message: string | undefined; | ||
| constructor(length: number, message: string | undefined); | ||
| readonly name = "notice"; | ||
| severity: string | undefined; | ||
| code: string | undefined; | ||
| detail: string | undefined; | ||
| hint: string | undefined; | ||
| position: string | undefined; | ||
| internalPosition: string | undefined; | ||
| internalQuery: string | undefined; | ||
| where: string | undefined; | ||
| schema: string | undefined; | ||
| table: string | undefined; | ||
| column: string | undefined; | ||
| dataType: string | undefined; | ||
| constraint: string | undefined; | ||
| file: string | undefined; | ||
| line: string | undefined; | ||
| routine: string | undefined; | ||
| } | ||
| type messages_AuthenticationCleartextPassword = AuthenticationCleartextPassword; | ||
| declare const messages_AuthenticationCleartextPassword: typeof AuthenticationCleartextPassword; | ||
| type messages_AuthenticationMD5Password = AuthenticationMD5Password; | ||
| declare const messages_AuthenticationMD5Password: typeof AuthenticationMD5Password; | ||
| type messages_AuthenticationMessage = AuthenticationMessage; | ||
| type messages_AuthenticationOk = AuthenticationOk; | ||
| declare const messages_AuthenticationOk: typeof AuthenticationOk; | ||
| type messages_AuthenticationSASL = AuthenticationSASL; | ||
| declare const messages_AuthenticationSASL: typeof AuthenticationSASL; | ||
| type messages_AuthenticationSASLContinue = AuthenticationSASLContinue; | ||
| declare const messages_AuthenticationSASLContinue: typeof AuthenticationSASLContinue; | ||
| type messages_AuthenticationSASLFinal = AuthenticationSASLFinal; | ||
| declare const messages_AuthenticationSASLFinal: typeof AuthenticationSASLFinal; | ||
| type messages_BackendKeyDataMessage = BackendKeyDataMessage; | ||
| declare const messages_BackendKeyDataMessage: typeof BackendKeyDataMessage; | ||
| type messages_BackendMessage = BackendMessage; | ||
| type messages_CommandCompleteMessage = CommandCompleteMessage; | ||
| declare const messages_CommandCompleteMessage: typeof CommandCompleteMessage; | ||
| type messages_CopyDataMessage = CopyDataMessage; | ||
| declare const messages_CopyDataMessage: typeof CopyDataMessage; | ||
| type messages_CopyResponse = CopyResponse; | ||
| declare const messages_CopyResponse: typeof CopyResponse; | ||
| type messages_DataRowMessage = DataRowMessage; | ||
| declare const messages_DataRowMessage: typeof DataRowMessage; | ||
| type messages_DatabaseError = DatabaseError; | ||
| declare const messages_DatabaseError: typeof DatabaseError; | ||
| type messages_Field = Field; | ||
| declare const messages_Field: typeof Field; | ||
| type messages_MessageName = MessageName; | ||
| type messages_NoticeMessage = NoticeMessage; | ||
| declare const messages_NoticeMessage: typeof NoticeMessage; | ||
| type messages_NotificationResponseMessage = NotificationResponseMessage; | ||
| declare const messages_NotificationResponseMessage: typeof NotificationResponseMessage; | ||
| type messages_ParameterDescriptionMessage = ParameterDescriptionMessage; | ||
| declare const messages_ParameterDescriptionMessage: typeof ParameterDescriptionMessage; | ||
| type messages_ParameterStatusMessage = ParameterStatusMessage; | ||
| declare const messages_ParameterStatusMessage: typeof ParameterStatusMessage; | ||
| type messages_ReadyForQueryMessage = ReadyForQueryMessage; | ||
| declare const messages_ReadyForQueryMessage: typeof ReadyForQueryMessage; | ||
| type messages_RowDescriptionMessage = RowDescriptionMessage; | ||
| declare const messages_RowDescriptionMessage: typeof RowDescriptionMessage; | ||
| declare const messages_bindComplete: typeof bindComplete; | ||
| declare const messages_closeComplete: typeof closeComplete; | ||
| declare const messages_copyDone: typeof copyDone; | ||
| declare const messages_emptyQuery: typeof emptyQuery; | ||
| declare const messages_noData: typeof noData; | ||
| declare const messages_parseComplete: typeof parseComplete; | ||
| declare const messages_portalSuspended: typeof portalSuspended; | ||
| declare const messages_replicationStart: typeof replicationStart; | ||
| declare namespace messages { | ||
| export { messages_AuthenticationCleartextPassword as AuthenticationCleartextPassword, messages_AuthenticationMD5Password as AuthenticationMD5Password, type messages_AuthenticationMessage as AuthenticationMessage, messages_AuthenticationOk as AuthenticationOk, messages_AuthenticationSASL as AuthenticationSASL, messages_AuthenticationSASLContinue as AuthenticationSASLContinue, messages_AuthenticationSASLFinal as AuthenticationSASLFinal, messages_BackendKeyDataMessage as BackendKeyDataMessage, type messages_BackendMessage as BackendMessage, messages_CommandCompleteMessage as CommandCompleteMessage, messages_CopyDataMessage as CopyDataMessage, messages_CopyResponse as CopyResponse, messages_DataRowMessage as DataRowMessage, messages_DatabaseError as DatabaseError, messages_Field as Field, type messages_MessageName as MessageName, messages_NoticeMessage as NoticeMessage, messages_NotificationResponseMessage as NotificationResponseMessage, messages_ParameterDescriptionMessage as ParameterDescriptionMessage, messages_ParameterStatusMessage as ParameterStatusMessage, messages_ReadyForQueryMessage as ReadyForQueryMessage, messages_RowDescriptionMessage as RowDescriptionMessage, messages_bindComplete as bindComplete, messages_closeComplete as closeComplete, messages_copyDone as copyDone, messages_emptyQuery as emptyQuery, messages_noData as noData, messages_parseComplete as parseComplete, messages_portalSuspended as portalSuspended, messages_replicationStart as replicationStart }; | ||
| } | ||
| type IDBFS = Emscripten.FileSystemType & { | ||
| quit: () => void; | ||
| dbs: Record<string, IDBDatabase>; | ||
| }; | ||
| type FS = typeof FS & { | ||
| filesystems: { | ||
| MEMFS: Emscripten.FileSystemType; | ||
| NODEFS: Emscripten.FileSystemType; | ||
| IDBFS: IDBFS; | ||
| }; | ||
| quit: () => void; | ||
| }; | ||
| interface PostgresMod extends Omit<EmscriptenModule, 'preInit' | 'preRun' | 'postRun'> { | ||
| preInit: Array<{ | ||
| (mod: PostgresMod): void; | ||
| }>; | ||
| preRun: Array<{ | ||
| (mod: PostgresMod): void; | ||
| }>; | ||
| postRun: Array<{ | ||
| (mod: PostgresMod): void; | ||
| }>; | ||
| thisProgram: string; | ||
| stdin: (() => number | null) | null; | ||
| FS: FS; | ||
| wasmMemory: WebAssembly.Memory; | ||
| PROXYFS: Emscripten.FileSystemType; | ||
| WASM_PREFIX: string; | ||
| pg_extensions: Record<string, Promise<Blob | null>>; | ||
| UTF8ToString: (ptr: number, maxBytesToRead?: number) => string; | ||
| stringToUTF8OnStack: (s: string) => number; | ||
| _pgl_set_system_fn: (system_fn: number) => void; | ||
| _pgl_set_popen_fn: (popen_fn: number) => void; | ||
| _pgl_set_pclose_fn: (pclose_fn: number) => void; | ||
| _pgl_set_rw_cbs: (read_cb: number, write_cb: number) => void; | ||
| _pgl_set_pipe_fn: (pipe_fn: number) => number; | ||
| _pgl_freopen: (filepath: number, mode: number, stream: number) => number; | ||
| _pgl_pq_flush: () => void; | ||
| _fopen: (path: number, mode: number) => number; | ||
| _fclose: (stream: number) => number; | ||
| _fflush: (stream: number) => void; | ||
| _pgl_proc_exit: (code: number) => number; | ||
| addFunction: (cb: (ptr: any, length: number) => void, signature: string) => number; | ||
| removeFunction: (f: number) => void; | ||
| callMain: (args?: string[]) => number; | ||
| _PostgresMainLoopOnce: () => void; | ||
| _PostgresMainLongJmp: () => void; | ||
| _PostgresSendReadyForQueryIfNecessary: () => void; | ||
| _ProcessStartupPacket: (Port: number, ssl_done: boolean, gss_done: boolean) => number; | ||
| _IsTransactionBlock: () => number; | ||
| _pgl_setPGliteActive: (newValue: number) => number; | ||
| _pgl_startPGlite: () => void; | ||
| _pgl_getMyProcPort: () => number; | ||
| _pgl_sendConnData: () => void; | ||
| ENV: any; | ||
| PGLITE_ENV: any; | ||
| _emscripten_force_exit: (status: number) => void; | ||
| _pgl_run_atexit_funcs: () => void; | ||
| _pq_buffer_remaining_data: () => number; | ||
| _pgl_getPGliteExitStatus: () => number; | ||
| _pgl_setPGliteExitStatus: (status: number) => number; | ||
| } | ||
| type PostgresFactory<T extends PostgresMod = PostgresMod> = (moduleOverrides?: Partial<T>) => Promise<T>; | ||
| declare const _default: PostgresFactory<PostgresMod>; | ||
| type postgresMod_FS = FS; | ||
| type postgresMod_PostgresMod = PostgresMod; | ||
| declare namespace postgresMod { | ||
| export { type postgresMod_FS as FS, type postgresMod_PostgresMod as PostgresMod, _default as default }; | ||
| } | ||
| type DumpTarCompressionOptions = 'none' | 'gzip' | 'auto'; | ||
| type FsType = 'nodefs' | 'idbfs' | 'memoryfs' | 'opfs-ahp'; | ||
| /** | ||
| * Filesystem interface. | ||
| * All virtual filesystems that are compatible with PGlite must implement | ||
| * this interface. | ||
| */ | ||
| interface Filesystem { | ||
| /** | ||
| * Initiate the filesystem and return the options to pass to the emscripten module. | ||
| */ | ||
| init(pg: PGlite, emscriptenOptions: Partial<PostgresMod>): Promise<{ | ||
| emscriptenOpts: Partial<PostgresMod>; | ||
| }>; | ||
| /** | ||
| * Sync the filesystem to any underlying storage. | ||
| */ | ||
| syncToFs(relaxedDurability?: boolean): Promise<void>; | ||
| /** | ||
| * Sync the filesystem from any underlying storage. | ||
| */ | ||
| initialSyncFs(): Promise<void>; | ||
| /** | ||
| * Dump the PGDATA dir from the filesystem to a gzipped tarball. | ||
| */ | ||
| dumpTar(dbname: string, compression?: DumpTarCompressionOptions): Promise<File | Blob>; | ||
| /** | ||
| * Close the filesystem. | ||
| */ | ||
| closeFs(): Promise<void>; | ||
| } | ||
| /** | ||
| * Base class for all emscripten built-in filesystems. | ||
| */ | ||
| declare class EmscriptenBuiltinFilesystem implements Filesystem { | ||
| protected dataDir?: string; | ||
| protected pg?: PGlite; | ||
| constructor(dataDir?: string); | ||
| init(pg: PGlite, emscriptenOptions: Partial<PostgresMod>): Promise<{ | ||
| emscriptenOpts: Partial<PostgresMod>; | ||
| }>; | ||
| syncToFs(_relaxedDurability?: boolean): Promise<void>; | ||
| initialSyncFs(): Promise<void>; | ||
| closeFs(): Promise<void>; | ||
| dumpTar(dbname: string, compression?: DumpTarCompressionOptions): Promise<Blob | File>; | ||
| } | ||
| /** | ||
| * Abstract base class for all custom virtual filesystems. | ||
| * Each custom filesystem needs to implement an interface similar to the NodeJS FS API. | ||
| */ | ||
| declare abstract class BaseFilesystem implements Filesystem { | ||
| protected dataDir?: string; | ||
| protected pg?: PGlite; | ||
| readonly debug: boolean; | ||
| constructor(dataDir?: string, { debug }?: { | ||
| debug?: boolean; | ||
| }); | ||
| syncToFs(_relaxedDurability?: boolean): Promise<void>; | ||
| initialSyncFs(): Promise<void>; | ||
| closeFs(): Promise<void>; | ||
| dumpTar(dbname: string, compression?: DumpTarCompressionOptions): Promise<Blob | File>; | ||
| init(pg: PGlite, emscriptenOptions: Partial<PostgresMod>): Promise<{ | ||
| emscriptenOpts: Partial<PostgresMod>; | ||
| }>; | ||
| abstract chmod(path: string, mode: number): void; | ||
| abstract close(fd: number): void; | ||
| abstract fstat(fd: number): FsStats; | ||
| abstract lstat(path: string): FsStats; | ||
| abstract mkdir(path: string, options?: { | ||
| recursive?: boolean; | ||
| mode?: number; | ||
| }): void; | ||
| abstract open(path: string, flags?: string, mode?: number): number; | ||
| abstract readdir(path: string): string[]; | ||
| abstract read(fd: number, buffer: Uint8Array, // Buffer to read into | ||
| offset: number, // Offset in buffer to start writing to | ||
| length: number, // Number of bytes to read | ||
| position: number): number; | ||
| abstract rename(oldPath: string, newPath: string): void; | ||
| abstract rmdir(path: string): void; | ||
| abstract truncate(path: string, len: number): void; | ||
| abstract unlink(path: string): void; | ||
| abstract utimes(path: string, atime: number, mtime: number): void; | ||
| abstract writeFile(path: string, data: string | Uint8Array, options?: { | ||
| encoding?: string; | ||
| mode?: number; | ||
| flag?: string; | ||
| }): void; | ||
| abstract write(fd: number, buffer: Uint8Array, // Buffer to read from | ||
| offset: number, // Offset in buffer to start reading from | ||
| length: number, // Number of bytes to write | ||
| position: number): number; | ||
| } | ||
| type FsStats = { | ||
| dev: number; | ||
| ino: number; | ||
| mode: number; | ||
| nlink: number; | ||
| uid: number; | ||
| gid: number; | ||
| rdev: number; | ||
| size: number; | ||
| blksize: number; | ||
| blocks: number; | ||
| atime: number; | ||
| mtime: number; | ||
| ctime: number; | ||
| }; | ||
| declare const ERRNO_CODES: { | ||
| readonly EBADF: 8; | ||
| readonly EBADFD: 127; | ||
| readonly EEXIST: 20; | ||
| readonly EINVAL: 28; | ||
| readonly EISDIR: 31; | ||
| readonly ENODEV: 43; | ||
| readonly ENOENT: 44; | ||
| readonly ENOTDIR: 54; | ||
| readonly ENOTEMPTY: 55; | ||
| }; | ||
| type FilesystemType = 'nodefs' | 'idbfs' | 'memoryfs'; | ||
| type DebugLevel = 0 | 1 | 2 | 3 | 4 | 5; | ||
| type RowMode = 'array' | 'object'; | ||
| interface ParserOptions { | ||
| [pgType: number]: (value: string) => any; | ||
| } | ||
| interface SerializerOptions { | ||
| [pgType: number]: (value: any) => string; | ||
| } | ||
| interface QueryOptions { | ||
| rowMode?: RowMode; | ||
| parsers?: ParserOptions; | ||
| serializers?: SerializerOptions; | ||
| blob?: Blob | File; | ||
| onNotice?: (notice: NoticeMessage) => void; | ||
| paramTypes?: number[]; | ||
| } | ||
| interface ExecProtocolOptions { | ||
| syncToFs?: boolean; | ||
| throwOnError?: boolean; | ||
| onNotice?: (notice: NoticeMessage) => void; | ||
| } | ||
| interface ExecProtocolOptionsStream { | ||
| syncToFs?: boolean; | ||
| onRawData: (data: Uint8Array) => void; | ||
| } | ||
| interface ExtensionSetupResult<TNamespace = any> { | ||
| emscriptenOpts?: any; | ||
| namespaceObj?: TNamespace; | ||
| bundlePath?: URL; | ||
| sharedPreloadLibraries?: string[]; | ||
| init?: () => Promise<void>; | ||
| close?: () => Promise<void>; | ||
| } | ||
| type ExtensionSetup<TNamespace = any> = (pg: PGliteInterface, emscriptenOpts: any, clientOnly?: boolean) => Promise<ExtensionSetupResult<TNamespace>>; | ||
| interface Extension<TNamespace = any> { | ||
| name: string; | ||
| setup: ExtensionSetup<TNamespace>; | ||
| } | ||
| type ExtensionNamespace<T> = T extends Extension<infer TNamespace> ? TNamespace : any; | ||
| type Extensions = { | ||
| [namespace: string]: Extension | URL; | ||
| }; | ||
| type InitializedExtensions<TExtensions extends Extensions = Extensions> = { | ||
| [K in keyof TExtensions]: ExtensionNamespace<TExtensions[K]>; | ||
| }; | ||
| interface ExecProtocolResult { | ||
| messages: BackendMessage[]; | ||
| data: Uint8Array; | ||
| } | ||
| interface DumpDataDirResult { | ||
| tarball: Uint8Array; | ||
| extension: '.tar' | '.tgz'; | ||
| filename: string; | ||
| } | ||
| interface PGliteOptions<TExtensions extends Extensions = Extensions> { | ||
| noInitDb?: boolean; | ||
| dataDir?: string; | ||
| username?: string; | ||
| database?: string; | ||
| fs?: Filesystem; | ||
| debug?: DebugLevel; | ||
| relaxedDurability?: boolean; | ||
| extensions?: TExtensions; | ||
| loadDataDir?: Blob | File; | ||
| icuDataDir?: Blob | File; | ||
| initialMemory?: number; | ||
| pgliteWasmModule?: WebAssembly.Module; | ||
| initdbWasmModule?: WebAssembly.Module; | ||
| fsBundle?: Blob | File; | ||
| parsers?: ParserOptions; | ||
| serializers?: SerializerOptions; | ||
| startParams?: string[]; | ||
| initDbStartParams?: string[]; | ||
| postgresqlconf?: string[] | string; | ||
| } | ||
| type PGliteInterface<T extends Extensions = Extensions> = InitializedExtensions<T> & { | ||
| readonly waitReady: Promise<void>; | ||
| readonly debug: DebugLevel; | ||
| readonly ready: boolean; | ||
| readonly closed: boolean; | ||
| close(): Promise<void>; | ||
| query<T>(query: string, params?: any[], options?: QueryOptions): Promise<Results<T>>; | ||
| sql<T>(sqlStrings: TemplateStringsArray, ...params: any[]): Promise<Results<T>>; | ||
| exec(query: string, options?: QueryOptions): Promise<Array<Results>>; | ||
| describeQuery(query: string): Promise<DescribeQueryResult>; | ||
| transaction<T>(callback: (tx: Transaction) => Promise<T>): Promise<T>; | ||
| execProtocolRaw(message: Uint8Array, options?: ExecProtocolOptions): Promise<Uint8Array>; | ||
| execProtocolRawStream(message: Uint8Array, options?: ExecProtocolOptionsStream): Promise<void>; | ||
| execProtocol(message: Uint8Array, options?: ExecProtocolOptions): Promise<ExecProtocolResult>; | ||
| runExclusive<T>(fn: () => Promise<T>): Promise<T>; | ||
| listen(channel: string, callback: (payload: string) => void, tx?: Transaction): Promise<(tx?: Transaction) => Promise<void>>; | ||
| unlisten(channel: string, callback?: (payload: string) => void, tx?: Transaction): Promise<void>; | ||
| onNotification(callback: (channel: string, payload: string) => void): () => void; | ||
| offNotification(callback: (channel: string, payload: string) => void): void; | ||
| dumpDataDir(compression?: DumpTarCompressionOptions): Promise<File | Blob>; | ||
| refreshArrayTypes(): Promise<void>; | ||
| }; | ||
| type PGliteInterfaceExtensions<E> = E extends Extensions ? { | ||
| [K in keyof E]: E[K] extends Extension ? Awaited<ReturnType<E[K]['setup']>>['namespaceObj'] extends infer N ? N extends undefined | null | void ? never : N : never : never; | ||
| } : Record<string, never>; | ||
| type Row<T = { | ||
| [key: string]: any; | ||
| }> = T; | ||
| type Results<T = { | ||
| [key: string]: any; | ||
| }> = { | ||
| rows: Row<T>[]; | ||
| affectedRows?: number; | ||
| /** | ||
| * The command of the query that was run, e.g. "SELECT", "INSERT", "CREATE". | ||
| */ | ||
| command?: string; | ||
| /** | ||
| * The number of rows reported by the command tag, e.g. the rows returned | ||
| * by a SELECT or changed by an UPDATE. Unlike `affectedRows` this is per statement | ||
| * and not cumulative across a multi-statement query. | ||
| */ | ||
| rowCount?: number; | ||
| fields: { | ||
| name: string; | ||
| dataTypeID: number; | ||
| }[]; | ||
| blob?: Blob; | ||
| }; | ||
| interface Transaction { | ||
| query<T>(query: string, params?: any[], options?: QueryOptions): Promise<Results<T>>; | ||
| sql<T>(sqlStrings: TemplateStringsArray, ...params: any[]): Promise<Results<T>>; | ||
| exec(query: string, options?: QueryOptions): Promise<Array<Results>>; | ||
| rollback(): Promise<void>; | ||
| listen(channel: string, callback: (payload: string) => void): Promise<(tx?: Transaction) => Promise<void>>; | ||
| get closed(): boolean; | ||
| } | ||
| type DescribeQueryResult = { | ||
| queryParams: { | ||
| dataTypeID: number; | ||
| serializer: Serializer; | ||
| }[]; | ||
| resultFields: { | ||
| name: string; | ||
| dataTypeID: number; | ||
| parser: Parser; | ||
| }[]; | ||
| }; | ||
| declare const BOOL = 16; | ||
| declare const BYTEA = 17; | ||
| declare const CHAR = 18; | ||
| declare const INT8 = 20; | ||
| declare const INT2 = 21; | ||
| declare const INT4 = 23; | ||
| declare const REGPROC = 24; | ||
| declare const TEXT = 25; | ||
| declare const OID = 26; | ||
| declare const TID = 27; | ||
| declare const XID = 28; | ||
| declare const CID = 29; | ||
| declare const JSON = 114; | ||
| declare const XML = 142; | ||
| declare const PG_NODE_TREE = 194; | ||
| declare const SMGR = 210; | ||
| declare const PATH = 602; | ||
| declare const POLYGON = 604; | ||
| declare const CIDR = 650; | ||
| declare const FLOAT4 = 700; | ||
| declare const FLOAT8 = 701; | ||
| declare const ABSTIME = 702; | ||
| declare const RELTIME = 703; | ||
| declare const TINTERVAL = 704; | ||
| declare const CIRCLE = 718; | ||
| declare const MACADDR8 = 774; | ||
| declare const MONEY = 790; | ||
| declare const MACADDR = 829; | ||
| declare const INET = 869; | ||
| declare const ACLITEM = 1033; | ||
| declare const BPCHAR = 1042; | ||
| declare const VARCHAR = 1043; | ||
| declare const DATE = 1082; | ||
| declare const TIME = 1083; | ||
| declare const TIMESTAMP = 1114; | ||
| declare const TIMESTAMPTZ = 1184; | ||
| declare const INTERVAL = 1186; | ||
| declare const TIMETZ = 1266; | ||
| declare const BIT = 1560; | ||
| declare const VARBIT = 1562; | ||
| declare const NUMERIC = 1700; | ||
| declare const REFCURSOR = 1790; | ||
| declare const REGPROCEDURE = 2202; | ||
| declare const REGOPER = 2203; | ||
| declare const REGOPERATOR = 2204; | ||
| declare const REGCLASS = 2205; | ||
| declare const REGTYPE = 2206; | ||
| declare const UUID = 2950; | ||
| declare const TXID_SNAPSHOT = 2970; | ||
| declare const PG_LSN = 3220; | ||
| declare const PG_NDISTINCT = 3361; | ||
| declare const PG_DEPENDENCIES = 3402; | ||
| declare const TSVECTOR = 3614; | ||
| declare const TSQUERY = 3615; | ||
| declare const GTSVECTOR = 3642; | ||
| declare const REGCONFIG = 3734; | ||
| declare const REGDICTIONARY = 3769; | ||
| declare const JSONB = 3802; | ||
| declare const REGNAMESPACE = 4089; | ||
| declare const REGROLE = 4096; | ||
| declare const types: { | ||
| string: { | ||
| to: number; | ||
| from: number[]; | ||
| serialize: (x: string | number | Date) => string; | ||
| parse: (x: string) => string; | ||
| }; | ||
| number: { | ||
| to: number; | ||
| from: number[]; | ||
| serialize: (x: number) => string; | ||
| parse: (x: string) => number; | ||
| }; | ||
| bigint: { | ||
| to: number; | ||
| from: number[]; | ||
| serialize: (x: bigint) => string; | ||
| parse: (x: string) => number | bigint; | ||
| }; | ||
| json: { | ||
| to: number; | ||
| from: number[]; | ||
| serialize: (x: any) => string; | ||
| parse: (x: string) => any; | ||
| }; | ||
| boolean: { | ||
| to: number; | ||
| from: number[]; | ||
| serialize: (x: boolean | number | string) => "t" | "f"; | ||
| parse: (x: string) => x is "t"; | ||
| }; | ||
| date: { | ||
| to: number; | ||
| from: number[]; | ||
| serialize: (x: Date | string | number) => string; | ||
| parse: (x: string | number) => Date; | ||
| }; | ||
| bytea: { | ||
| to: number; | ||
| from: number[]; | ||
| serialize: (x: Uint8Array) => string; | ||
| parse: (x: string) => Uint8Array; | ||
| }; | ||
| }; | ||
| type Parser = (x: string, typeId?: number) => any; | ||
| type Serializer = (x: any) => string; | ||
| type TypeHandler = { | ||
| to: number; | ||
| from: number | number[]; | ||
| serialize: Serializer; | ||
| parse: Parser; | ||
| }; | ||
| type TypeHandlers = { | ||
| [key: string]: TypeHandler; | ||
| }; | ||
| declare const parsers: { | ||
| [key: string]: (x: string, typeId?: number) => any; | ||
| [key: number]: (x: string, typeId?: number) => any; | ||
| }; | ||
| declare const serializers: { | ||
| [key: string]: Serializer; | ||
| [key: number]: Serializer; | ||
| }; | ||
| declare function parseType(x: string | null, type: number, parsers?: ParserOptions): any; | ||
| declare function arraySerializer(xs: any, serializer: Serializer | undefined, typarray: number): string; | ||
| declare function arrayParser(x: string, parser: Parser, typarray: number): any; | ||
| declare const types$1_ABSTIME: typeof ABSTIME; | ||
| declare const types$1_ACLITEM: typeof ACLITEM; | ||
| declare const types$1_BIT: typeof BIT; | ||
| declare const types$1_BOOL: typeof BOOL; | ||
| declare const types$1_BPCHAR: typeof BPCHAR; | ||
| declare const types$1_BYTEA: typeof BYTEA; | ||
| declare const types$1_CHAR: typeof CHAR; | ||
| declare const types$1_CID: typeof CID; | ||
| declare const types$1_CIDR: typeof CIDR; | ||
| declare const types$1_CIRCLE: typeof CIRCLE; | ||
| declare const types$1_DATE: typeof DATE; | ||
| declare const types$1_FLOAT4: typeof FLOAT4; | ||
| declare const types$1_FLOAT8: typeof FLOAT8; | ||
| declare const types$1_GTSVECTOR: typeof GTSVECTOR; | ||
| declare const types$1_INET: typeof INET; | ||
| declare const types$1_INT2: typeof INT2; | ||
| declare const types$1_INT4: typeof INT4; | ||
| declare const types$1_INT8: typeof INT8; | ||
| declare const types$1_INTERVAL: typeof INTERVAL; | ||
| declare const types$1_JSON: typeof JSON; | ||
| declare const types$1_JSONB: typeof JSONB; | ||
| declare const types$1_MACADDR: typeof MACADDR; | ||
| declare const types$1_MACADDR8: typeof MACADDR8; | ||
| declare const types$1_MONEY: typeof MONEY; | ||
| declare const types$1_NUMERIC: typeof NUMERIC; | ||
| declare const types$1_OID: typeof OID; | ||
| declare const types$1_PATH: typeof PATH; | ||
| declare const types$1_PG_DEPENDENCIES: typeof PG_DEPENDENCIES; | ||
| declare const types$1_PG_LSN: typeof PG_LSN; | ||
| declare const types$1_PG_NDISTINCT: typeof PG_NDISTINCT; | ||
| declare const types$1_PG_NODE_TREE: typeof PG_NODE_TREE; | ||
| declare const types$1_POLYGON: typeof POLYGON; | ||
| type types$1_Parser = Parser; | ||
| declare const types$1_REFCURSOR: typeof REFCURSOR; | ||
| declare const types$1_REGCLASS: typeof REGCLASS; | ||
| declare const types$1_REGCONFIG: typeof REGCONFIG; | ||
| declare const types$1_REGDICTIONARY: typeof REGDICTIONARY; | ||
| declare const types$1_REGNAMESPACE: typeof REGNAMESPACE; | ||
| declare const types$1_REGOPER: typeof REGOPER; | ||
| declare const types$1_REGOPERATOR: typeof REGOPERATOR; | ||
| declare const types$1_REGPROC: typeof REGPROC; | ||
| declare const types$1_REGPROCEDURE: typeof REGPROCEDURE; | ||
| declare const types$1_REGROLE: typeof REGROLE; | ||
| declare const types$1_REGTYPE: typeof REGTYPE; | ||
| declare const types$1_RELTIME: typeof RELTIME; | ||
| declare const types$1_SMGR: typeof SMGR; | ||
| type types$1_Serializer = Serializer; | ||
| declare const types$1_TEXT: typeof TEXT; | ||
| declare const types$1_TID: typeof TID; | ||
| declare const types$1_TIME: typeof TIME; | ||
| declare const types$1_TIMESTAMP: typeof TIMESTAMP; | ||
| declare const types$1_TIMESTAMPTZ: typeof TIMESTAMPTZ; | ||
| declare const types$1_TIMETZ: typeof TIMETZ; | ||
| declare const types$1_TINTERVAL: typeof TINTERVAL; | ||
| declare const types$1_TSQUERY: typeof TSQUERY; | ||
| declare const types$1_TSVECTOR: typeof TSVECTOR; | ||
| declare const types$1_TXID_SNAPSHOT: typeof TXID_SNAPSHOT; | ||
| type types$1_TypeHandler = TypeHandler; | ||
| type types$1_TypeHandlers = TypeHandlers; | ||
| declare const types$1_UUID: typeof UUID; | ||
| declare const types$1_VARBIT: typeof VARBIT; | ||
| declare const types$1_VARCHAR: typeof VARCHAR; | ||
| declare const types$1_XID: typeof XID; | ||
| declare const types$1_XML: typeof XML; | ||
| declare const types$1_arrayParser: typeof arrayParser; | ||
| declare const types$1_arraySerializer: typeof arraySerializer; | ||
| declare const types$1_parseType: typeof parseType; | ||
| declare const types$1_parsers: typeof parsers; | ||
| declare const types$1_serializers: typeof serializers; | ||
| declare const types$1_types: typeof types; | ||
| declare namespace types$1 { | ||
| export { types$1_ABSTIME as ABSTIME, types$1_ACLITEM as ACLITEM, types$1_BIT as BIT, types$1_BOOL as BOOL, types$1_BPCHAR as BPCHAR, types$1_BYTEA as BYTEA, types$1_CHAR as CHAR, types$1_CID as CID, types$1_CIDR as CIDR, types$1_CIRCLE as CIRCLE, types$1_DATE as DATE, types$1_FLOAT4 as FLOAT4, types$1_FLOAT8 as FLOAT8, types$1_GTSVECTOR as GTSVECTOR, types$1_INET as INET, types$1_INT2 as INT2, types$1_INT4 as INT4, types$1_INT8 as INT8, types$1_INTERVAL as INTERVAL, types$1_JSON as JSON, types$1_JSONB as JSONB, types$1_MACADDR as MACADDR, types$1_MACADDR8 as MACADDR8, types$1_MONEY as MONEY, types$1_NUMERIC as NUMERIC, types$1_OID as OID, types$1_PATH as PATH, types$1_PG_DEPENDENCIES as PG_DEPENDENCIES, types$1_PG_LSN as PG_LSN, types$1_PG_NDISTINCT as PG_NDISTINCT, types$1_PG_NODE_TREE as PG_NODE_TREE, types$1_POLYGON as POLYGON, type types$1_Parser as Parser, types$1_REFCURSOR as REFCURSOR, types$1_REGCLASS as REGCLASS, types$1_REGCONFIG as REGCONFIG, types$1_REGDICTIONARY as REGDICTIONARY, types$1_REGNAMESPACE as REGNAMESPACE, types$1_REGOPER as REGOPER, types$1_REGOPERATOR as REGOPERATOR, types$1_REGPROC as REGPROC, types$1_REGPROCEDURE as REGPROCEDURE, types$1_REGROLE as REGROLE, types$1_REGTYPE as REGTYPE, types$1_RELTIME as RELTIME, types$1_SMGR as SMGR, type types$1_Serializer as Serializer, types$1_TEXT as TEXT, types$1_TID as TID, types$1_TIME as TIME, types$1_TIMESTAMP as TIMESTAMP, types$1_TIMESTAMPTZ as TIMESTAMPTZ, types$1_TIMETZ as TIMETZ, types$1_TINTERVAL as TINTERVAL, types$1_TSQUERY as TSQUERY, types$1_TSVECTOR as TSVECTOR, types$1_TXID_SNAPSHOT as TXID_SNAPSHOT, type types$1_TypeHandler as TypeHandler, type types$1_TypeHandlers as TypeHandlers, types$1_UUID as UUID, types$1_VARBIT as VARBIT, types$1_VARCHAR as VARCHAR, types$1_XID as XID, types$1_XML as XML, types$1_arrayParser as arrayParser, types$1_arraySerializer as arraySerializer, types$1_parseType as parseType, types$1_parsers as parsers, types$1_serializers as serializers, types$1_types as types }; | ||
| } | ||
| declare abstract class BasePGlite implements Pick<PGliteInterface, 'query' | 'sql' | 'exec' | 'transaction'> { | ||
| #private; | ||
| serializers: Record<number | string, Serializer>; | ||
| parsers: Record<number | string, Parser>; | ||
| abstract debug: DebugLevel; | ||
| /** | ||
| * Execute a postgres wire protocol message | ||
| * @param message The postgres wire protocol message to execute | ||
| * @returns The result of the query | ||
| */ | ||
| abstract execProtocol(message: Uint8Array, { syncToFs, onNotice }: ExecProtocolOptions): Promise<ExecProtocolResult>; | ||
| /** | ||
| * Execute a postgres wire protocol message | ||
| * @param message The postgres wire protocol message to execute | ||
| * @returns The parsed results of the query | ||
| */ | ||
| abstract execProtocolStream(message: Uint8Array, { syncToFs, onNotice }: ExecProtocolOptions): Promise<BackendMessage[]>; | ||
| /** | ||
| * Execute a postgres wire protocol message directly without wrapping the response. | ||
| * Only use if `execProtocol()` doesn't suite your needs. | ||
| * | ||
| * **Warning:** This bypasses PGlite's protocol wrappers that manage error/notice messages, | ||
| * transactions, and notification listeners. Only use if you need to bypass these wrappers and | ||
| * don't intend to use the above features. | ||
| * | ||
| * @param message The postgres wire protocol message to execute | ||
| * @returns The direct message data response produced by Postgres | ||
| */ | ||
| abstract execProtocolRaw(message: Uint8Array, { syncToFs }: ExecProtocolOptions): Promise<Uint8Array>; | ||
| /** | ||
| * Execute a postgres wire protocol message directly without wrapping the response. | ||
| * Only use if `execProtocol()` doesn't suite your needs. | ||
| * | ||
| * **Warning:** This bypasses PGlite's protocol wrappers that manage error/notice messages, | ||
| * transactions, and notification listeners. Only use if you need to bypass these wrappers and | ||
| * don't intend to use the above features. | ||
| * | ||
| * @param message The postgres wire protocol message to execute | ||
| * @param options.onRawData Callback to receive streaming data | ||
| */ | ||
| abstract execProtocolRawStream(message: Uint8Array, { syncToFs, onRawData }: ExecProtocolOptionsStream): Promise<void>; | ||
| /** | ||
| * Sync the database to the filesystem | ||
| * @returns Promise that resolves when the database is synced to the filesystem | ||
| */ | ||
| abstract syncToFs(): Promise<void>; | ||
| /** | ||
| * Handle a file attached to the current query | ||
| * @param file The file to handle | ||
| */ | ||
| abstract _handleBlob(blob?: File | Blob): Promise<void>; | ||
| /** | ||
| * Get the written file | ||
| */ | ||
| abstract _getWrittenBlob(): Promise<File | Blob | undefined>; | ||
| /** | ||
| * Cleanup the current file | ||
| */ | ||
| abstract _cleanupBlob(): Promise<void>; | ||
| abstract _checkReady(): Promise<void>; | ||
| abstract _runExclusiveQuery<T>(fn: () => Promise<T>): Promise<T>; | ||
| abstract _runExclusiveTransaction<T>(fn: () => Promise<T>): Promise<T>; | ||
| /** | ||
| * Listen for notifications on a channel | ||
| */ | ||
| abstract listen(channel: string, callback: (payload: string) => void, tx?: Transaction): Promise<(tx?: Transaction) => Promise<void>>; | ||
| /** | ||
| * Initialize the array types | ||
| * The oid if the type of an element and the typarray is the oid of the type of the | ||
| * array. | ||
| * We extract these from the database then create the serializers/parsers for | ||
| * each type. | ||
| * This should be called at the end of #init() in the implementing class. | ||
| */ | ||
| _initArrayTypes({ force }?: { | ||
| force?: boolean | undefined; | ||
| }): Promise<void>; | ||
| /** | ||
| * Re-syncs the array types from the database | ||
| * This is useful if you add a new type to the database and want to use it, otherwise pglite won't recognize it. | ||
| */ | ||
| refreshArrayTypes(): Promise<void>; | ||
| /** | ||
| * Execute a single SQL statement | ||
| * This uses the "Extended Query" postgres wire protocol message. | ||
| * @param query The query to execute | ||
| * @param params Optional parameters for the query | ||
| * @returns The result of the query | ||
| */ | ||
| query<T>(query: string, params?: any[], options?: QueryOptions): Promise<Results<T>>; | ||
| /** | ||
| * Execute a single SQL statement like with {@link PGlite.query}, but with a | ||
| * templated statement where template values will be treated as parameters. | ||
| * | ||
| * You can use helpers from `/template` to further format the query with | ||
| * identifiers, raw SQL, and nested statements. | ||
| * | ||
| * This uses the "Extended Query" postgres wire protocol message. | ||
| * | ||
| * @param query The query to execute with parameters as template values | ||
| * @returns The result of the query | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * const results = await db.sql`SELECT * FROM ${identifier`foo`} WHERE id = ${id}` | ||
| * ``` | ||
| */ | ||
| sql<T>(sqlStrings: TemplateStringsArray, ...params: any[]): Promise<Results<T>>; | ||
| /** | ||
| * Execute a SQL query, this can have multiple statements. | ||
| * This uses the "Simple Query" postgres wire protocol message. | ||
| * @param query The query to execute | ||
| * @returns The result of the query | ||
| */ | ||
| exec(query: string, options?: QueryOptions): Promise<Array<Results>>; | ||
| /** | ||
| * Describe a query | ||
| * @param query The query to describe | ||
| * @returns A description of the result types for the query | ||
| */ | ||
| describeQuery(query: string, options?: QueryOptions): Promise<DescribeQueryResult>; | ||
| /** | ||
| * Execute a transaction | ||
| * @param callback A callback function that takes a transaction object | ||
| * @returns The result of the transaction | ||
| */ | ||
| transaction<T>(callback: (tx: Transaction) => Promise<T>): Promise<T>; | ||
| /** | ||
| * Run a function exclusively, no other transactions or queries will be allowed | ||
| * while the function is running. | ||
| * This is useful when working with the execProtocol methods as they are not blocked, | ||
| * and do not block the locks used by transactions and queries. | ||
| * @param fn The function to run | ||
| * @returns The result of the function | ||
| */ | ||
| runExclusive<T>(fn: () => Promise<T>): Promise<T>; | ||
| } | ||
| declare class PGlite extends BasePGlite implements PGliteInterface, AsyncDisposable { | ||
| #private; | ||
| fs?: Filesystem; | ||
| protected mod?: PostgresMod; | ||
| private readonly POSTGRES_MAIN_LONGJMP; | ||
| private readonly PGLITE_EXIT_ALIVE; | ||
| get ENV(): any; | ||
| readonly dataDir?: string; | ||
| readonly waitReady: Promise<void>; | ||
| readonly debug: DebugLevel; | ||
| static readonly paths: { | ||
| readonly PG_ROOT: "/pglite"; | ||
| readonly PGDATA: string; | ||
| readonly ICU_DATA_PATH: string; | ||
| readonly INITDB_EXE_PATH: string; | ||
| readonly POSTGRES_EXE_PATH: string; | ||
| }; | ||
| static readonly DEFAULT_RECV_BUF_SIZE: number; | ||
| static readonly MAX_BUFFER_SIZE: number; | ||
| externalCommandStreamFd: number | null; | ||
| static readonly defaultStartParams: string[]; | ||
| /** | ||
| * Create a new PGlite instance | ||
| * @param dataDir The directory to store the database files | ||
| * Prefix with idb:// to use indexeddb filesystem in the browser | ||
| * Use memory:// to use in-memory filesystem | ||
| * @param options PGlite options | ||
| */ | ||
| constructor(dataDir?: string, options?: PGliteOptions); | ||
| /** | ||
| * Create a new PGlite instance | ||
| * @param options PGlite options including the data directory | ||
| */ | ||
| constructor(options?: PGliteOptions); | ||
| /** | ||
| * Create a new PGlite instance with extensions on the Typescript interface | ||
| * (The main constructor does enable extensions, however due to the limitations | ||
| * of Typescript, the extensions are not available on the instance interface) | ||
| * @param options PGlite options including the data directory | ||
| * @returns A promise that resolves to the PGlite instance when it's ready. | ||
| */ | ||
| static create<O extends PGliteOptions>(options?: O): Promise<PGlite & PGliteInterfaceExtensions<O['extensions']>>; | ||
| /** | ||
| * Create a new PGlite instance with extensions on the Typescript interface | ||
| * (The main constructor does enable extensions, however due to the limitations | ||
| * of Typescript, the extensions are not available on the instance interface) | ||
| * @param dataDir The directory to store the database files | ||
| * Prefix with idb:// to use indexeddb filesystem in the browser | ||
| * Use memory:// to use in-memory filesystem | ||
| * @param options PGlite options | ||
| * @returns A promise that resolves to the PGlite instance when it's ready. | ||
| */ | ||
| static create<O extends PGliteOptions>(dataDir?: string, options?: O): Promise<PGlite & PGliteInterfaceExtensions<O['extensions']>>; | ||
| handleExternalCmd(cmd: string, mode: string): number; | ||
| /** | ||
| * The Postgres Emscripten Module | ||
| */ | ||
| get Module(): PostgresMod; | ||
| /** | ||
| * The ready state of the database | ||
| */ | ||
| get ready(): boolean; | ||
| /** | ||
| * The closed state of the database | ||
| */ | ||
| get closed(): boolean; | ||
| /** | ||
| * Close the database | ||
| * @returns A promise that resolves when the database is closed | ||
| */ | ||
| close(): Promise<void>; | ||
| /** | ||
| * Close the database when the object exits scope | ||
| * Stage 3 ECMAScript Explicit Resource Management | ||
| * https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-2.html#using-declarations-and-explicit-resource-management | ||
| */ | ||
| [Symbol.asyncDispose](): Promise<void>; | ||
| /** | ||
| * Handle a file attached to the current query | ||
| * @param file The file to handle | ||
| */ | ||
| _handleBlob(blob?: File | Blob): Promise<void>; | ||
| /** | ||
| * Cleanup the current file | ||
| */ | ||
| _cleanupBlob(): Promise<void>; | ||
| /** | ||
| * Get the written blob from the current query | ||
| * @returns The written blob | ||
| */ | ||
| _getWrittenBlob(): Promise<Blob | undefined>; | ||
| /** | ||
| * Wait for the database to be ready | ||
| */ | ||
| _checkReady(): Promise<void>; | ||
| /** | ||
| * Execute a postgres wire protocol synchronously | ||
| * @param message The postgres wire protocol message to execute | ||
| * @returns The direct message data response produced by Postgres | ||
| */ | ||
| execProtocolRawSync(message: Uint8Array): Uint8Array; | ||
| /** | ||
| * Execute a postgres wire protocol message directly without wrapping the response. | ||
| * Only use if `execProtocol()` doesn't suite your needs. | ||
| * | ||
| * **Warning:** This bypasses PGlite's protocol wrappers that manage error/notice messages, | ||
| * transactions, and notification listeners. Only use if you need to bypass these wrappers and | ||
| * don't intend to use the above features. | ||
| * | ||
| * @param message The postgres wire protocol message to execute | ||
| * @returns The direct message data response produced by Postgres | ||
| */ | ||
| execProtocolRaw(message: Uint8Array, { syncToFs }?: ExecProtocolOptions): Promise<Uint8Array>; | ||
| /** | ||
| * Execute a postgres wire protocol message directly without wrapping the response. | ||
| * Only use if `execProtocol()` doesn't suite your needs. | ||
| * | ||
| * **Warning:** This bypasses PGlite's protocol wrappers that manage error/notice messages, | ||
| * transactions, and notification listeners. Only use if you need to bypass these wrappers and | ||
| * don't intend to use the above features. | ||
| * | ||
| * @param message The postgres wire protocol message to execute | ||
| * @param options.onRawData Callback to receive results as streaming data | ||
| */ | ||
| execProtocolRawStream(message: Uint8Array, { syncToFs, onRawData }: ExecProtocolOptionsStream): Promise<void>; | ||
| /** | ||
| * Execute a postgres wire protocol message | ||
| * @param message The postgres wire protocol message to execute | ||
| * @returns The result of the query | ||
| */ | ||
| execProtocol(message: Uint8Array, { syncToFs, throwOnError, onNotice, }?: ExecProtocolOptions): Promise<ExecProtocolResult>; | ||
| /** | ||
| * Execute a postgres wire protocol message | ||
| * @param message The postgres wire protocol message to execute | ||
| * @returns The parsed results of the query | ||
| */ | ||
| execProtocolStream(message: Uint8Array, { syncToFs, throwOnError, onNotice }?: ExecProtocolOptions): Promise<BackendMessage[]>; | ||
| /** | ||
| * Check if the database is in a transaction | ||
| * @returns True if the database is in a transaction, false otherwise | ||
| */ | ||
| isInTransaction(): boolean; | ||
| /** | ||
| * Perform any sync operations implemented by the filesystem, this is | ||
| * run after every query to ensure that the filesystem is synced. | ||
| */ | ||
| syncToFs(): Promise<void>; | ||
| /** | ||
| * Listen for a notification | ||
| * @param channel The channel to listen on | ||
| * @param callback The callback to call when a notification is received | ||
| */ | ||
| listen(channel: string, callback: (payload: string) => void, tx?: Transaction): Promise<(tx?: Transaction) => Promise<void>>; | ||
| /** | ||
| * Stop listening for a notification | ||
| * @param channel The channel to stop listening on | ||
| * @param callback The callback to remove | ||
| */ | ||
| unlisten(channel: string, callback?: (payload: string) => void, tx?: Transaction): Promise<void>; | ||
| /** | ||
| * Listen to notifications | ||
| * @param callback The callback to call when a notification is received | ||
| */ | ||
| onNotification(callback: (channel: string, payload: string) => void): () => void; | ||
| /** | ||
| * Stop listening to notifications | ||
| * @param callback The callback to remove | ||
| */ | ||
| offNotification(callback: (channel: string, payload: string) => void): void; | ||
| /** | ||
| * Dump the PGDATA dir from the filesystem to a gzipped tarball. | ||
| * @param compression The compression options to use - 'gzip', 'auto', 'none' | ||
| * @returns The tarball as a File object where available, and fallback to a Blob | ||
| */ | ||
| dumpDataDir(compression?: DumpTarCompressionOptions): Promise<File | Blob>; | ||
| /** | ||
| * Run a function in a mutex that's exclusive to queries | ||
| * @param fn The query to run | ||
| * @returns The result of the query | ||
| */ | ||
| _runExclusiveQuery<T>(fn: () => Promise<T>): Promise<T>; | ||
| /** | ||
| * Run a function in a mutex that's exclusive to transactions | ||
| * @param fn The function to run | ||
| * @returns The result of the function | ||
| */ | ||
| _runExclusiveTransaction<T>(fn: () => Promise<T>): Promise<T>; | ||
| clone(): Promise<PGliteInterface>; | ||
| _runExclusiveListen<T>(fn: () => Promise<T>): Promise<T>; | ||
| callMain(args: string[]): number; | ||
| copyToFS(filePath: string, data: Uint8Array, mode?: number): void; | ||
| } | ||
| export { type FsType as A, type BackendMessage as B, type Filesystem as C, type DebugLevel as D, EmscriptenBuiltinFilesystem as E, type FilesystemType as F, ERRNO_CODES as G, type InitializedExtensions as I, type Mode as M, type Parser as P, type QueryOptions as Q, type Results as R, type SerializerOptions as S, type Transaction as T, type BufferParameter as a, PGlite as b, type PostgresMod as c, type PGliteInterface as d, type RowMode as e, type ParserOptions as f, type ExecProtocolOptions as g, type ExecProtocolOptionsStream as h, type ExtensionSetupResult as i, type ExtensionSetup as j, type Extension as k, type ExtensionNamespace as l, messages as m, type Extensions as n, type ExecProtocolResult as o, postgresMod as p, type DumpDataDirResult as q, type PGliteOptions as r, type PGliteInterfaceExtensions as s, types$1 as t, type Row as u, type DescribeQueryResult as v, BaseFilesystem as w, type FsStats as x, BasePGlite as y, type DumpTarCompressionOptions as z }; |
| declare const Modes: { | ||
| readonly text: 0; | ||
| readonly binary: 1; | ||
| }; | ||
| type Mode = (typeof Modes)[keyof typeof Modes]; | ||
| type BufferParameter = ArrayBuffer | ArrayBufferView; | ||
| type MessageName = 'parseComplete' | 'bindComplete' | 'closeComplete' | 'noData' | 'portalSuspended' | 'replicationStart' | 'emptyQuery' | 'copyDone' | 'copyData' | 'rowDescription' | 'parameterDescription' | 'parameterStatus' | 'backendKeyData' | 'notification' | 'readyForQuery' | 'commandComplete' | 'dataRow' | 'copyInResponse' | 'copyOutResponse' | 'authenticationOk' | 'authenticationMD5Password' | 'authenticationCleartextPassword' | 'authenticationSASL' | 'authenticationSASLContinue' | 'authenticationSASLFinal' | 'error' | 'notice'; | ||
| type BackendMessage = { | ||
| name: MessageName; | ||
| length: number; | ||
| }; | ||
| declare const parseComplete: BackendMessage; | ||
| declare const bindComplete: BackendMessage; | ||
| declare const closeComplete: BackendMessage; | ||
| declare const noData: BackendMessage; | ||
| declare const portalSuspended: BackendMessage; | ||
| declare const replicationStart: BackendMessage; | ||
| declare const emptyQuery: BackendMessage; | ||
| declare const copyDone: BackendMessage; | ||
| declare class AuthenticationOk implements BackendMessage { | ||
| readonly length: number; | ||
| readonly name = "authenticationOk"; | ||
| constructor(length: number); | ||
| } | ||
| declare class AuthenticationCleartextPassword implements BackendMessage { | ||
| readonly length: number; | ||
| readonly name = "authenticationCleartextPassword"; | ||
| constructor(length: number); | ||
| } | ||
| declare class AuthenticationMD5Password implements BackendMessage { | ||
| readonly length: number; | ||
| readonly salt: Uint8Array; | ||
| readonly name = "authenticationMD5Password"; | ||
| constructor(length: number, salt: Uint8Array); | ||
| } | ||
| declare class AuthenticationSASL implements BackendMessage { | ||
| readonly length: number; | ||
| readonly mechanisms: string[]; | ||
| readonly name = "authenticationSASL"; | ||
| constructor(length: number, mechanisms: string[]); | ||
| } | ||
| declare class AuthenticationSASLContinue implements BackendMessage { | ||
| readonly length: number; | ||
| readonly data: string; | ||
| readonly name = "authenticationSASLContinue"; | ||
| constructor(length: number, data: string); | ||
| } | ||
| declare class AuthenticationSASLFinal implements BackendMessage { | ||
| readonly length: number; | ||
| readonly data: string; | ||
| readonly name = "authenticationSASLFinal"; | ||
| constructor(length: number, data: string); | ||
| } | ||
| type AuthenticationMessage = AuthenticationOk | AuthenticationCleartextPassword | AuthenticationMD5Password | AuthenticationSASL | AuthenticationSASLContinue | AuthenticationSASLFinal; | ||
| interface NoticeOrError { | ||
| message: string | undefined; | ||
| severity: string | undefined; | ||
| code: string | undefined; | ||
| detail: string | undefined; | ||
| hint: string | undefined; | ||
| position: string | undefined; | ||
| internalPosition: string | undefined; | ||
| internalQuery: string | undefined; | ||
| where: string | undefined; | ||
| schema: string | undefined; | ||
| table: string | undefined; | ||
| column: string | undefined; | ||
| dataType: string | undefined; | ||
| constraint: string | undefined; | ||
| file: string | undefined; | ||
| line: string | undefined; | ||
| routine: string | undefined; | ||
| } | ||
| declare class DatabaseError extends Error implements NoticeOrError { | ||
| readonly length: number; | ||
| readonly name: MessageName; | ||
| severity: string | undefined; | ||
| code: string | undefined; | ||
| detail: string | undefined; | ||
| hint: string | undefined; | ||
| position: string | undefined; | ||
| internalPosition: string | undefined; | ||
| internalQuery: string | undefined; | ||
| where: string | undefined; | ||
| schema: string | undefined; | ||
| table: string | undefined; | ||
| column: string | undefined; | ||
| dataType: string | undefined; | ||
| constraint: string | undefined; | ||
| file: string | undefined; | ||
| line: string | undefined; | ||
| routine: string | undefined; | ||
| constructor(message: string, length: number, name: MessageName); | ||
| } | ||
| declare class CopyDataMessage implements BackendMessage { | ||
| readonly length: number; | ||
| readonly chunk: Uint8Array; | ||
| readonly name = "copyData"; | ||
| constructor(length: number, chunk: Uint8Array); | ||
| } | ||
| declare class CopyResponse implements BackendMessage { | ||
| readonly length: number; | ||
| readonly name: MessageName; | ||
| readonly binary: boolean; | ||
| readonly columnTypes: number[]; | ||
| constructor(length: number, name: MessageName, binary: boolean, columnCount: number); | ||
| } | ||
| declare class Field { | ||
| readonly name: string; | ||
| readonly tableID: number; | ||
| readonly columnID: number; | ||
| readonly dataTypeID: number; | ||
| readonly dataTypeSize: number; | ||
| readonly dataTypeModifier: number; | ||
| readonly format: Mode; | ||
| constructor(name: string, tableID: number, columnID: number, dataTypeID: number, dataTypeSize: number, dataTypeModifier: number, format: Mode); | ||
| } | ||
| declare class RowDescriptionMessage implements BackendMessage { | ||
| readonly length: number; | ||
| readonly fieldCount: number; | ||
| readonly name: MessageName; | ||
| readonly fields: Field[]; | ||
| constructor(length: number, fieldCount: number); | ||
| } | ||
| declare class ParameterDescriptionMessage implements BackendMessage { | ||
| readonly length: number; | ||
| readonly parameterCount: number; | ||
| readonly name: MessageName; | ||
| readonly dataTypeIDs: number[]; | ||
| constructor(length: number, parameterCount: number); | ||
| } | ||
| declare class ParameterStatusMessage implements BackendMessage { | ||
| readonly length: number; | ||
| readonly parameterName: string; | ||
| readonly parameterValue: string; | ||
| readonly name: MessageName; | ||
| constructor(length: number, parameterName: string, parameterValue: string); | ||
| } | ||
| declare class BackendKeyDataMessage implements BackendMessage { | ||
| readonly length: number; | ||
| readonly processID: number; | ||
| readonly secretKey: number; | ||
| readonly name: MessageName; | ||
| constructor(length: number, processID: number, secretKey: number); | ||
| } | ||
| declare class NotificationResponseMessage implements BackendMessage { | ||
| readonly length: number; | ||
| readonly processId: number; | ||
| readonly channel: string; | ||
| readonly payload: string; | ||
| readonly name: MessageName; | ||
| constructor(length: number, processId: number, channel: string, payload: string); | ||
| } | ||
| declare class ReadyForQueryMessage implements BackendMessage { | ||
| readonly length: number; | ||
| readonly status: string; | ||
| readonly name: MessageName; | ||
| constructor(length: number, status: string); | ||
| } | ||
| declare class CommandCompleteMessage implements BackendMessage { | ||
| readonly length: number; | ||
| readonly text: string; | ||
| readonly name: MessageName; | ||
| constructor(length: number, text: string); | ||
| } | ||
| declare class DataRowMessage implements BackendMessage { | ||
| length: number; | ||
| fields: (string | null)[]; | ||
| readonly fieldCount: number; | ||
| readonly name: MessageName; | ||
| constructor(length: number, fields: (string | null)[]); | ||
| } | ||
| declare class NoticeMessage implements BackendMessage, NoticeOrError { | ||
| readonly length: number; | ||
| readonly message: string | undefined; | ||
| constructor(length: number, message: string | undefined); | ||
| readonly name = "notice"; | ||
| severity: string | undefined; | ||
| code: string | undefined; | ||
| detail: string | undefined; | ||
| hint: string | undefined; | ||
| position: string | undefined; | ||
| internalPosition: string | undefined; | ||
| internalQuery: string | undefined; | ||
| where: string | undefined; | ||
| schema: string | undefined; | ||
| table: string | undefined; | ||
| column: string | undefined; | ||
| dataType: string | undefined; | ||
| constraint: string | undefined; | ||
| file: string | undefined; | ||
| line: string | undefined; | ||
| routine: string | undefined; | ||
| } | ||
| type messages_AuthenticationCleartextPassword = AuthenticationCleartextPassword; | ||
| declare const messages_AuthenticationCleartextPassword: typeof AuthenticationCleartextPassword; | ||
| type messages_AuthenticationMD5Password = AuthenticationMD5Password; | ||
| declare const messages_AuthenticationMD5Password: typeof AuthenticationMD5Password; | ||
| type messages_AuthenticationMessage = AuthenticationMessage; | ||
| type messages_AuthenticationOk = AuthenticationOk; | ||
| declare const messages_AuthenticationOk: typeof AuthenticationOk; | ||
| type messages_AuthenticationSASL = AuthenticationSASL; | ||
| declare const messages_AuthenticationSASL: typeof AuthenticationSASL; | ||
| type messages_AuthenticationSASLContinue = AuthenticationSASLContinue; | ||
| declare const messages_AuthenticationSASLContinue: typeof AuthenticationSASLContinue; | ||
| type messages_AuthenticationSASLFinal = AuthenticationSASLFinal; | ||
| declare const messages_AuthenticationSASLFinal: typeof AuthenticationSASLFinal; | ||
| type messages_BackendKeyDataMessage = BackendKeyDataMessage; | ||
| declare const messages_BackendKeyDataMessage: typeof BackendKeyDataMessage; | ||
| type messages_BackendMessage = BackendMessage; | ||
| type messages_CommandCompleteMessage = CommandCompleteMessage; | ||
| declare const messages_CommandCompleteMessage: typeof CommandCompleteMessage; | ||
| type messages_CopyDataMessage = CopyDataMessage; | ||
| declare const messages_CopyDataMessage: typeof CopyDataMessage; | ||
| type messages_CopyResponse = CopyResponse; | ||
| declare const messages_CopyResponse: typeof CopyResponse; | ||
| type messages_DataRowMessage = DataRowMessage; | ||
| declare const messages_DataRowMessage: typeof DataRowMessage; | ||
| type messages_DatabaseError = DatabaseError; | ||
| declare const messages_DatabaseError: typeof DatabaseError; | ||
| type messages_Field = Field; | ||
| declare const messages_Field: typeof Field; | ||
| type messages_MessageName = MessageName; | ||
| type messages_NoticeMessage = NoticeMessage; | ||
| declare const messages_NoticeMessage: typeof NoticeMessage; | ||
| type messages_NotificationResponseMessage = NotificationResponseMessage; | ||
| declare const messages_NotificationResponseMessage: typeof NotificationResponseMessage; | ||
| type messages_ParameterDescriptionMessage = ParameterDescriptionMessage; | ||
| declare const messages_ParameterDescriptionMessage: typeof ParameterDescriptionMessage; | ||
| type messages_ParameterStatusMessage = ParameterStatusMessage; | ||
| declare const messages_ParameterStatusMessage: typeof ParameterStatusMessage; | ||
| type messages_ReadyForQueryMessage = ReadyForQueryMessage; | ||
| declare const messages_ReadyForQueryMessage: typeof ReadyForQueryMessage; | ||
| type messages_RowDescriptionMessage = RowDescriptionMessage; | ||
| declare const messages_RowDescriptionMessage: typeof RowDescriptionMessage; | ||
| declare const messages_bindComplete: typeof bindComplete; | ||
| declare const messages_closeComplete: typeof closeComplete; | ||
| declare const messages_copyDone: typeof copyDone; | ||
| declare const messages_emptyQuery: typeof emptyQuery; | ||
| declare const messages_noData: typeof noData; | ||
| declare const messages_parseComplete: typeof parseComplete; | ||
| declare const messages_portalSuspended: typeof portalSuspended; | ||
| declare const messages_replicationStart: typeof replicationStart; | ||
| declare namespace messages { | ||
| export { messages_AuthenticationCleartextPassword as AuthenticationCleartextPassword, messages_AuthenticationMD5Password as AuthenticationMD5Password, type messages_AuthenticationMessage as AuthenticationMessage, messages_AuthenticationOk as AuthenticationOk, messages_AuthenticationSASL as AuthenticationSASL, messages_AuthenticationSASLContinue as AuthenticationSASLContinue, messages_AuthenticationSASLFinal as AuthenticationSASLFinal, messages_BackendKeyDataMessage as BackendKeyDataMessage, type messages_BackendMessage as BackendMessage, messages_CommandCompleteMessage as CommandCompleteMessage, messages_CopyDataMessage as CopyDataMessage, messages_CopyResponse as CopyResponse, messages_DataRowMessage as DataRowMessage, messages_DatabaseError as DatabaseError, messages_Field as Field, type messages_MessageName as MessageName, messages_NoticeMessage as NoticeMessage, messages_NotificationResponseMessage as NotificationResponseMessage, messages_ParameterDescriptionMessage as ParameterDescriptionMessage, messages_ParameterStatusMessage as ParameterStatusMessage, messages_ReadyForQueryMessage as ReadyForQueryMessage, messages_RowDescriptionMessage as RowDescriptionMessage, messages_bindComplete as bindComplete, messages_closeComplete as closeComplete, messages_copyDone as copyDone, messages_emptyQuery as emptyQuery, messages_noData as noData, messages_parseComplete as parseComplete, messages_portalSuspended as portalSuspended, messages_replicationStart as replicationStart }; | ||
| } | ||
| type IDBFS = Emscripten.FileSystemType & { | ||
| quit: () => void; | ||
| dbs: Record<string, IDBDatabase>; | ||
| }; | ||
| type FS = typeof FS & { | ||
| filesystems: { | ||
| MEMFS: Emscripten.FileSystemType; | ||
| NODEFS: Emscripten.FileSystemType; | ||
| IDBFS: IDBFS; | ||
| }; | ||
| quit: () => void; | ||
| }; | ||
| interface PostgresMod extends Omit<EmscriptenModule, 'preInit' | 'preRun' | 'postRun'> { | ||
| preInit: Array<{ | ||
| (mod: PostgresMod): void; | ||
| }>; | ||
| preRun: Array<{ | ||
| (mod: PostgresMod): void; | ||
| }>; | ||
| postRun: Array<{ | ||
| (mod: PostgresMod): void; | ||
| }>; | ||
| thisProgram: string; | ||
| stdin: (() => number | null) | null; | ||
| FS: FS; | ||
| wasmMemory: WebAssembly.Memory; | ||
| PROXYFS: Emscripten.FileSystemType; | ||
| WASM_PREFIX: string; | ||
| pg_extensions: Record<string, Promise<Blob | null>>; | ||
| UTF8ToString: (ptr: number, maxBytesToRead?: number) => string; | ||
| stringToUTF8OnStack: (s: string) => number; | ||
| _pgl_set_system_fn: (system_fn: number) => void; | ||
| _pgl_set_popen_fn: (popen_fn: number) => void; | ||
| _pgl_set_pclose_fn: (pclose_fn: number) => void; | ||
| _pgl_set_rw_cbs: (read_cb: number, write_cb: number) => void; | ||
| _pgl_set_pipe_fn: (pipe_fn: number) => number; | ||
| _pgl_freopen: (filepath: number, mode: number, stream: number) => number; | ||
| _pgl_pq_flush: () => void; | ||
| _fopen: (path: number, mode: number) => number; | ||
| _fclose: (stream: number) => number; | ||
| _fflush: (stream: number) => void; | ||
| _pgl_proc_exit: (code: number) => number; | ||
| addFunction: (cb: (ptr: any, length: number) => void, signature: string) => number; | ||
| removeFunction: (f: number) => void; | ||
| callMain: (args?: string[]) => number; | ||
| _PostgresMainLoopOnce: () => void; | ||
| _PostgresMainLongJmp: () => void; | ||
| _PostgresSendReadyForQueryIfNecessary: () => void; | ||
| _ProcessStartupPacket: (Port: number, ssl_done: boolean, gss_done: boolean) => number; | ||
| _IsTransactionBlock: () => number; | ||
| _pgl_setPGliteActive: (newValue: number) => number; | ||
| _pgl_startPGlite: () => void; | ||
| _pgl_getMyProcPort: () => number; | ||
| _pgl_sendConnData: () => void; | ||
| ENV: any; | ||
| PGLITE_ENV: any; | ||
| _emscripten_force_exit: (status: number) => void; | ||
| _pgl_run_atexit_funcs: () => void; | ||
| _pq_buffer_remaining_data: () => number; | ||
| _pgl_getPGliteExitStatus: () => number; | ||
| _pgl_setPGliteExitStatus: (status: number) => number; | ||
| } | ||
| type PostgresFactory<T extends PostgresMod = PostgresMod> = (moduleOverrides?: Partial<T>) => Promise<T>; | ||
| declare const _default: PostgresFactory<PostgresMod>; | ||
| type postgresMod_FS = FS; | ||
| type postgresMod_PostgresMod = PostgresMod; | ||
| declare namespace postgresMod { | ||
| export { type postgresMod_FS as FS, type postgresMod_PostgresMod as PostgresMod, _default as default }; | ||
| } | ||
| type DumpTarCompressionOptions = 'none' | 'gzip' | 'auto'; | ||
| type FsType = 'nodefs' | 'idbfs' | 'memoryfs' | 'opfs-ahp'; | ||
| /** | ||
| * Filesystem interface. | ||
| * All virtual filesystems that are compatible with PGlite must implement | ||
| * this interface. | ||
| */ | ||
| interface Filesystem { | ||
| /** | ||
| * Initiate the filesystem and return the options to pass to the emscripten module. | ||
| */ | ||
| init(pg: PGlite, emscriptenOptions: Partial<PostgresMod>): Promise<{ | ||
| emscriptenOpts: Partial<PostgresMod>; | ||
| }>; | ||
| /** | ||
| * Sync the filesystem to any underlying storage. | ||
| */ | ||
| syncToFs(relaxedDurability?: boolean): Promise<void>; | ||
| /** | ||
| * Sync the filesystem from any underlying storage. | ||
| */ | ||
| initialSyncFs(): Promise<void>; | ||
| /** | ||
| * Dump the PGDATA dir from the filesystem to a gzipped tarball. | ||
| */ | ||
| dumpTar(dbname: string, compression?: DumpTarCompressionOptions): Promise<File | Blob>; | ||
| /** | ||
| * Close the filesystem. | ||
| */ | ||
| closeFs(): Promise<void>; | ||
| } | ||
| /** | ||
| * Base class for all emscripten built-in filesystems. | ||
| */ | ||
| declare class EmscriptenBuiltinFilesystem implements Filesystem { | ||
| protected dataDir?: string; | ||
| protected pg?: PGlite; | ||
| constructor(dataDir?: string); | ||
| init(pg: PGlite, emscriptenOptions: Partial<PostgresMod>): Promise<{ | ||
| emscriptenOpts: Partial<PostgresMod>; | ||
| }>; | ||
| syncToFs(_relaxedDurability?: boolean): Promise<void>; | ||
| initialSyncFs(): Promise<void>; | ||
| closeFs(): Promise<void>; | ||
| dumpTar(dbname: string, compression?: DumpTarCompressionOptions): Promise<Blob | File>; | ||
| } | ||
| /** | ||
| * Abstract base class for all custom virtual filesystems. | ||
| * Each custom filesystem needs to implement an interface similar to the NodeJS FS API. | ||
| */ | ||
| declare abstract class BaseFilesystem implements Filesystem { | ||
| protected dataDir?: string; | ||
| protected pg?: PGlite; | ||
| readonly debug: boolean; | ||
| constructor(dataDir?: string, { debug }?: { | ||
| debug?: boolean; | ||
| }); | ||
| syncToFs(_relaxedDurability?: boolean): Promise<void>; | ||
| initialSyncFs(): Promise<void>; | ||
| closeFs(): Promise<void>; | ||
| dumpTar(dbname: string, compression?: DumpTarCompressionOptions): Promise<Blob | File>; | ||
| init(pg: PGlite, emscriptenOptions: Partial<PostgresMod>): Promise<{ | ||
| emscriptenOpts: Partial<PostgresMod>; | ||
| }>; | ||
| abstract chmod(path: string, mode: number): void; | ||
| abstract close(fd: number): void; | ||
| abstract fstat(fd: number): FsStats; | ||
| abstract lstat(path: string): FsStats; | ||
| abstract mkdir(path: string, options?: { | ||
| recursive?: boolean; | ||
| mode?: number; | ||
| }): void; | ||
| abstract open(path: string, flags?: string, mode?: number): number; | ||
| abstract readdir(path: string): string[]; | ||
| abstract read(fd: number, buffer: Uint8Array, // Buffer to read into | ||
| offset: number, // Offset in buffer to start writing to | ||
| length: number, // Number of bytes to read | ||
| position: number): number; | ||
| abstract rename(oldPath: string, newPath: string): void; | ||
| abstract rmdir(path: string): void; | ||
| abstract truncate(path: string, len: number): void; | ||
| abstract unlink(path: string): void; | ||
| abstract utimes(path: string, atime: number, mtime: number): void; | ||
| abstract writeFile(path: string, data: string | Uint8Array, options?: { | ||
| encoding?: string; | ||
| mode?: number; | ||
| flag?: string; | ||
| }): void; | ||
| abstract write(fd: number, buffer: Uint8Array, // Buffer to read from | ||
| offset: number, // Offset in buffer to start reading from | ||
| length: number, // Number of bytes to write | ||
| position: number): number; | ||
| } | ||
| type FsStats = { | ||
| dev: number; | ||
| ino: number; | ||
| mode: number; | ||
| nlink: number; | ||
| uid: number; | ||
| gid: number; | ||
| rdev: number; | ||
| size: number; | ||
| blksize: number; | ||
| blocks: number; | ||
| atime: number; | ||
| mtime: number; | ||
| ctime: number; | ||
| }; | ||
| declare const ERRNO_CODES: { | ||
| readonly EBADF: 8; | ||
| readonly EBADFD: 127; | ||
| readonly EEXIST: 20; | ||
| readonly EINVAL: 28; | ||
| readonly EISDIR: 31; | ||
| readonly ENODEV: 43; | ||
| readonly ENOENT: 44; | ||
| readonly ENOTDIR: 54; | ||
| readonly ENOTEMPTY: 55; | ||
| }; | ||
| type FilesystemType = 'nodefs' | 'idbfs' | 'memoryfs'; | ||
| type DebugLevel = 0 | 1 | 2 | 3 | 4 | 5; | ||
| type RowMode = 'array' | 'object'; | ||
| interface ParserOptions { | ||
| [pgType: number]: (value: string) => any; | ||
| } | ||
| interface SerializerOptions { | ||
| [pgType: number]: (value: any) => string; | ||
| } | ||
| interface QueryOptions { | ||
| rowMode?: RowMode; | ||
| parsers?: ParserOptions; | ||
| serializers?: SerializerOptions; | ||
| blob?: Blob | File; | ||
| onNotice?: (notice: NoticeMessage) => void; | ||
| paramTypes?: number[]; | ||
| } | ||
| interface ExecProtocolOptions { | ||
| syncToFs?: boolean; | ||
| throwOnError?: boolean; | ||
| onNotice?: (notice: NoticeMessage) => void; | ||
| } | ||
| interface ExecProtocolOptionsStream { | ||
| syncToFs?: boolean; | ||
| onRawData: (data: Uint8Array) => void; | ||
| } | ||
| interface ExtensionSetupResult<TNamespace = any> { | ||
| emscriptenOpts?: any; | ||
| namespaceObj?: TNamespace; | ||
| bundlePath?: URL; | ||
| sharedPreloadLibraries?: string[]; | ||
| init?: () => Promise<void>; | ||
| close?: () => Promise<void>; | ||
| } | ||
| type ExtensionSetup<TNamespace = any> = (pg: PGliteInterface, emscriptenOpts: any, clientOnly?: boolean) => Promise<ExtensionSetupResult<TNamespace>>; | ||
| interface Extension<TNamespace = any> { | ||
| name: string; | ||
| setup: ExtensionSetup<TNamespace>; | ||
| } | ||
| type ExtensionNamespace<T> = T extends Extension<infer TNamespace> ? TNamespace : any; | ||
| type Extensions = { | ||
| [namespace: string]: Extension | URL; | ||
| }; | ||
| type InitializedExtensions<TExtensions extends Extensions = Extensions> = { | ||
| [K in keyof TExtensions]: ExtensionNamespace<TExtensions[K]>; | ||
| }; | ||
| interface ExecProtocolResult { | ||
| messages: BackendMessage[]; | ||
| data: Uint8Array; | ||
| } | ||
| interface DumpDataDirResult { | ||
| tarball: Uint8Array; | ||
| extension: '.tar' | '.tgz'; | ||
| filename: string; | ||
| } | ||
| interface PGliteOptions<TExtensions extends Extensions = Extensions> { | ||
| noInitDb?: boolean; | ||
| dataDir?: string; | ||
| username?: string; | ||
| database?: string; | ||
| fs?: Filesystem; | ||
| debug?: DebugLevel; | ||
| relaxedDurability?: boolean; | ||
| extensions?: TExtensions; | ||
| loadDataDir?: Blob | File; | ||
| icuDataDir?: Blob | File; | ||
| initialMemory?: number; | ||
| pgliteWasmModule?: WebAssembly.Module; | ||
| initdbWasmModule?: WebAssembly.Module; | ||
| fsBundle?: Blob | File; | ||
| parsers?: ParserOptions; | ||
| serializers?: SerializerOptions; | ||
| startParams?: string[]; | ||
| initDbStartParams?: string[]; | ||
| postgresqlconf?: string[] | string; | ||
| } | ||
| type PGliteInterface<T extends Extensions = Extensions> = InitializedExtensions<T> & { | ||
| readonly waitReady: Promise<void>; | ||
| readonly debug: DebugLevel; | ||
| readonly ready: boolean; | ||
| readonly closed: boolean; | ||
| close(): Promise<void>; | ||
| query<T>(query: string, params?: any[], options?: QueryOptions): Promise<Results<T>>; | ||
| sql<T>(sqlStrings: TemplateStringsArray, ...params: any[]): Promise<Results<T>>; | ||
| exec(query: string, options?: QueryOptions): Promise<Array<Results>>; | ||
| describeQuery(query: string): Promise<DescribeQueryResult>; | ||
| transaction<T>(callback: (tx: Transaction) => Promise<T>): Promise<T>; | ||
| execProtocolRaw(message: Uint8Array, options?: ExecProtocolOptions): Promise<Uint8Array>; | ||
| execProtocolRawStream(message: Uint8Array, options?: ExecProtocolOptionsStream): Promise<void>; | ||
| execProtocol(message: Uint8Array, options?: ExecProtocolOptions): Promise<ExecProtocolResult>; | ||
| runExclusive<T>(fn: () => Promise<T>): Promise<T>; | ||
| listen(channel: string, callback: (payload: string) => void, tx?: Transaction): Promise<(tx?: Transaction) => Promise<void>>; | ||
| unlisten(channel: string, callback?: (payload: string) => void, tx?: Transaction): Promise<void>; | ||
| onNotification(callback: (channel: string, payload: string) => void): () => void; | ||
| offNotification(callback: (channel: string, payload: string) => void): void; | ||
| dumpDataDir(compression?: DumpTarCompressionOptions): Promise<File | Blob>; | ||
| refreshArrayTypes(): Promise<void>; | ||
| }; | ||
| type PGliteInterfaceExtensions<E> = E extends Extensions ? { | ||
| [K in keyof E]: E[K] extends Extension ? Awaited<ReturnType<E[K]['setup']>>['namespaceObj'] extends infer N ? N extends undefined | null | void ? never : N : never : never; | ||
| } : Record<string, never>; | ||
| type Row<T = { | ||
| [key: string]: any; | ||
| }> = T; | ||
| type Results<T = { | ||
| [key: string]: any; | ||
| }> = { | ||
| rows: Row<T>[]; | ||
| affectedRows?: number; | ||
| /** | ||
| * The command of the query that was run, e.g. "SELECT", "INSERT", "CREATE". | ||
| */ | ||
| command?: string; | ||
| /** | ||
| * The number of rows reported by the command tag, e.g. the rows returned | ||
| * by a SELECT or changed by an UPDATE. Unlike `affectedRows` this is per statement | ||
| * and not cumulative across a multi-statement query. | ||
| */ | ||
| rowCount?: number; | ||
| fields: { | ||
| name: string; | ||
| dataTypeID: number; | ||
| }[]; | ||
| blob?: Blob; | ||
| }; | ||
| interface Transaction { | ||
| query<T>(query: string, params?: any[], options?: QueryOptions): Promise<Results<T>>; | ||
| sql<T>(sqlStrings: TemplateStringsArray, ...params: any[]): Promise<Results<T>>; | ||
| exec(query: string, options?: QueryOptions): Promise<Array<Results>>; | ||
| rollback(): Promise<void>; | ||
| listen(channel: string, callback: (payload: string) => void): Promise<(tx?: Transaction) => Promise<void>>; | ||
| get closed(): boolean; | ||
| } | ||
| type DescribeQueryResult = { | ||
| queryParams: { | ||
| dataTypeID: number; | ||
| serializer: Serializer; | ||
| }[]; | ||
| resultFields: { | ||
| name: string; | ||
| dataTypeID: number; | ||
| parser: Parser; | ||
| }[]; | ||
| }; | ||
| declare const BOOL = 16; | ||
| declare const BYTEA = 17; | ||
| declare const CHAR = 18; | ||
| declare const INT8 = 20; | ||
| declare const INT2 = 21; | ||
| declare const INT4 = 23; | ||
| declare const REGPROC = 24; | ||
| declare const TEXT = 25; | ||
| declare const OID = 26; | ||
| declare const TID = 27; | ||
| declare const XID = 28; | ||
| declare const CID = 29; | ||
| declare const JSON = 114; | ||
| declare const XML = 142; | ||
| declare const PG_NODE_TREE = 194; | ||
| declare const SMGR = 210; | ||
| declare const PATH = 602; | ||
| declare const POLYGON = 604; | ||
| declare const CIDR = 650; | ||
| declare const FLOAT4 = 700; | ||
| declare const FLOAT8 = 701; | ||
| declare const ABSTIME = 702; | ||
| declare const RELTIME = 703; | ||
| declare const TINTERVAL = 704; | ||
| declare const CIRCLE = 718; | ||
| declare const MACADDR8 = 774; | ||
| declare const MONEY = 790; | ||
| declare const MACADDR = 829; | ||
| declare const INET = 869; | ||
| declare const ACLITEM = 1033; | ||
| declare const BPCHAR = 1042; | ||
| declare const VARCHAR = 1043; | ||
| declare const DATE = 1082; | ||
| declare const TIME = 1083; | ||
| declare const TIMESTAMP = 1114; | ||
| declare const TIMESTAMPTZ = 1184; | ||
| declare const INTERVAL = 1186; | ||
| declare const TIMETZ = 1266; | ||
| declare const BIT = 1560; | ||
| declare const VARBIT = 1562; | ||
| declare const NUMERIC = 1700; | ||
| declare const REFCURSOR = 1790; | ||
| declare const REGPROCEDURE = 2202; | ||
| declare const REGOPER = 2203; | ||
| declare const REGOPERATOR = 2204; | ||
| declare const REGCLASS = 2205; | ||
| declare const REGTYPE = 2206; | ||
| declare const UUID = 2950; | ||
| declare const TXID_SNAPSHOT = 2970; | ||
| declare const PG_LSN = 3220; | ||
| declare const PG_NDISTINCT = 3361; | ||
| declare const PG_DEPENDENCIES = 3402; | ||
| declare const TSVECTOR = 3614; | ||
| declare const TSQUERY = 3615; | ||
| declare const GTSVECTOR = 3642; | ||
| declare const REGCONFIG = 3734; | ||
| declare const REGDICTIONARY = 3769; | ||
| declare const JSONB = 3802; | ||
| declare const REGNAMESPACE = 4089; | ||
| declare const REGROLE = 4096; | ||
| declare const types: { | ||
| string: { | ||
| to: number; | ||
| from: number[]; | ||
| serialize: (x: string | number | Date) => string; | ||
| parse: (x: string) => string; | ||
| }; | ||
| number: { | ||
| to: number; | ||
| from: number[]; | ||
| serialize: (x: number) => string; | ||
| parse: (x: string) => number; | ||
| }; | ||
| bigint: { | ||
| to: number; | ||
| from: number[]; | ||
| serialize: (x: bigint) => string; | ||
| parse: (x: string) => number | bigint; | ||
| }; | ||
| json: { | ||
| to: number; | ||
| from: number[]; | ||
| serialize: (x: any) => string; | ||
| parse: (x: string) => any; | ||
| }; | ||
| boolean: { | ||
| to: number; | ||
| from: number[]; | ||
| serialize: (x: boolean | number | string) => "t" | "f"; | ||
| parse: (x: string) => x is "t"; | ||
| }; | ||
| date: { | ||
| to: number; | ||
| from: number[]; | ||
| serialize: (x: Date | string | number) => string; | ||
| parse: (x: string | number) => Date; | ||
| }; | ||
| bytea: { | ||
| to: number; | ||
| from: number[]; | ||
| serialize: (x: Uint8Array) => string; | ||
| parse: (x: string) => Uint8Array; | ||
| }; | ||
| }; | ||
| type Parser = (x: string, typeId?: number) => any; | ||
| type Serializer = (x: any) => string; | ||
| type TypeHandler = { | ||
| to: number; | ||
| from: number | number[]; | ||
| serialize: Serializer; | ||
| parse: Parser; | ||
| }; | ||
| type TypeHandlers = { | ||
| [key: string]: TypeHandler; | ||
| }; | ||
| declare const parsers: { | ||
| [key: string]: (x: string, typeId?: number) => any; | ||
| [key: number]: (x: string, typeId?: number) => any; | ||
| }; | ||
| declare const serializers: { | ||
| [key: string]: Serializer; | ||
| [key: number]: Serializer; | ||
| }; | ||
| declare function parseType(x: string | null, type: number, parsers?: ParserOptions): any; | ||
| declare function arraySerializer(xs: any, serializer: Serializer | undefined, typarray: number): string; | ||
| declare function arrayParser(x: string, parser: Parser, typarray: number): any; | ||
| declare const types$1_ABSTIME: typeof ABSTIME; | ||
| declare const types$1_ACLITEM: typeof ACLITEM; | ||
| declare const types$1_BIT: typeof BIT; | ||
| declare const types$1_BOOL: typeof BOOL; | ||
| declare const types$1_BPCHAR: typeof BPCHAR; | ||
| declare const types$1_BYTEA: typeof BYTEA; | ||
| declare const types$1_CHAR: typeof CHAR; | ||
| declare const types$1_CID: typeof CID; | ||
| declare const types$1_CIDR: typeof CIDR; | ||
| declare const types$1_CIRCLE: typeof CIRCLE; | ||
| declare const types$1_DATE: typeof DATE; | ||
| declare const types$1_FLOAT4: typeof FLOAT4; | ||
| declare const types$1_FLOAT8: typeof FLOAT8; | ||
| declare const types$1_GTSVECTOR: typeof GTSVECTOR; | ||
| declare const types$1_INET: typeof INET; | ||
| declare const types$1_INT2: typeof INT2; | ||
| declare const types$1_INT4: typeof INT4; | ||
| declare const types$1_INT8: typeof INT8; | ||
| declare const types$1_INTERVAL: typeof INTERVAL; | ||
| declare const types$1_JSON: typeof JSON; | ||
| declare const types$1_JSONB: typeof JSONB; | ||
| declare const types$1_MACADDR: typeof MACADDR; | ||
| declare const types$1_MACADDR8: typeof MACADDR8; | ||
| declare const types$1_MONEY: typeof MONEY; | ||
| declare const types$1_NUMERIC: typeof NUMERIC; | ||
| declare const types$1_OID: typeof OID; | ||
| declare const types$1_PATH: typeof PATH; | ||
| declare const types$1_PG_DEPENDENCIES: typeof PG_DEPENDENCIES; | ||
| declare const types$1_PG_LSN: typeof PG_LSN; | ||
| declare const types$1_PG_NDISTINCT: typeof PG_NDISTINCT; | ||
| declare const types$1_PG_NODE_TREE: typeof PG_NODE_TREE; | ||
| declare const types$1_POLYGON: typeof POLYGON; | ||
| type types$1_Parser = Parser; | ||
| declare const types$1_REFCURSOR: typeof REFCURSOR; | ||
| declare const types$1_REGCLASS: typeof REGCLASS; | ||
| declare const types$1_REGCONFIG: typeof REGCONFIG; | ||
| declare const types$1_REGDICTIONARY: typeof REGDICTIONARY; | ||
| declare const types$1_REGNAMESPACE: typeof REGNAMESPACE; | ||
| declare const types$1_REGOPER: typeof REGOPER; | ||
| declare const types$1_REGOPERATOR: typeof REGOPERATOR; | ||
| declare const types$1_REGPROC: typeof REGPROC; | ||
| declare const types$1_REGPROCEDURE: typeof REGPROCEDURE; | ||
| declare const types$1_REGROLE: typeof REGROLE; | ||
| declare const types$1_REGTYPE: typeof REGTYPE; | ||
| declare const types$1_RELTIME: typeof RELTIME; | ||
| declare const types$1_SMGR: typeof SMGR; | ||
| type types$1_Serializer = Serializer; | ||
| declare const types$1_TEXT: typeof TEXT; | ||
| declare const types$1_TID: typeof TID; | ||
| declare const types$1_TIME: typeof TIME; | ||
| declare const types$1_TIMESTAMP: typeof TIMESTAMP; | ||
| declare const types$1_TIMESTAMPTZ: typeof TIMESTAMPTZ; | ||
| declare const types$1_TIMETZ: typeof TIMETZ; | ||
| declare const types$1_TINTERVAL: typeof TINTERVAL; | ||
| declare const types$1_TSQUERY: typeof TSQUERY; | ||
| declare const types$1_TSVECTOR: typeof TSVECTOR; | ||
| declare const types$1_TXID_SNAPSHOT: typeof TXID_SNAPSHOT; | ||
| type types$1_TypeHandler = TypeHandler; | ||
| type types$1_TypeHandlers = TypeHandlers; | ||
| declare const types$1_UUID: typeof UUID; | ||
| declare const types$1_VARBIT: typeof VARBIT; | ||
| declare const types$1_VARCHAR: typeof VARCHAR; | ||
| declare const types$1_XID: typeof XID; | ||
| declare const types$1_XML: typeof XML; | ||
| declare const types$1_arrayParser: typeof arrayParser; | ||
| declare const types$1_arraySerializer: typeof arraySerializer; | ||
| declare const types$1_parseType: typeof parseType; | ||
| declare const types$1_parsers: typeof parsers; | ||
| declare const types$1_serializers: typeof serializers; | ||
| declare const types$1_types: typeof types; | ||
| declare namespace types$1 { | ||
| export { types$1_ABSTIME as ABSTIME, types$1_ACLITEM as ACLITEM, types$1_BIT as BIT, types$1_BOOL as BOOL, types$1_BPCHAR as BPCHAR, types$1_BYTEA as BYTEA, types$1_CHAR as CHAR, types$1_CID as CID, types$1_CIDR as CIDR, types$1_CIRCLE as CIRCLE, types$1_DATE as DATE, types$1_FLOAT4 as FLOAT4, types$1_FLOAT8 as FLOAT8, types$1_GTSVECTOR as GTSVECTOR, types$1_INET as INET, types$1_INT2 as INT2, types$1_INT4 as INT4, types$1_INT8 as INT8, types$1_INTERVAL as INTERVAL, types$1_JSON as JSON, types$1_JSONB as JSONB, types$1_MACADDR as MACADDR, types$1_MACADDR8 as MACADDR8, types$1_MONEY as MONEY, types$1_NUMERIC as NUMERIC, types$1_OID as OID, types$1_PATH as PATH, types$1_PG_DEPENDENCIES as PG_DEPENDENCIES, types$1_PG_LSN as PG_LSN, types$1_PG_NDISTINCT as PG_NDISTINCT, types$1_PG_NODE_TREE as PG_NODE_TREE, types$1_POLYGON as POLYGON, type types$1_Parser as Parser, types$1_REFCURSOR as REFCURSOR, types$1_REGCLASS as REGCLASS, types$1_REGCONFIG as REGCONFIG, types$1_REGDICTIONARY as REGDICTIONARY, types$1_REGNAMESPACE as REGNAMESPACE, types$1_REGOPER as REGOPER, types$1_REGOPERATOR as REGOPERATOR, types$1_REGPROC as REGPROC, types$1_REGPROCEDURE as REGPROCEDURE, types$1_REGROLE as REGROLE, types$1_REGTYPE as REGTYPE, types$1_RELTIME as RELTIME, types$1_SMGR as SMGR, type types$1_Serializer as Serializer, types$1_TEXT as TEXT, types$1_TID as TID, types$1_TIME as TIME, types$1_TIMESTAMP as TIMESTAMP, types$1_TIMESTAMPTZ as TIMESTAMPTZ, types$1_TIMETZ as TIMETZ, types$1_TINTERVAL as TINTERVAL, types$1_TSQUERY as TSQUERY, types$1_TSVECTOR as TSVECTOR, types$1_TXID_SNAPSHOT as TXID_SNAPSHOT, type types$1_TypeHandler as TypeHandler, type types$1_TypeHandlers as TypeHandlers, types$1_UUID as UUID, types$1_VARBIT as VARBIT, types$1_VARCHAR as VARCHAR, types$1_XID as XID, types$1_XML as XML, types$1_arrayParser as arrayParser, types$1_arraySerializer as arraySerializer, types$1_parseType as parseType, types$1_parsers as parsers, types$1_serializers as serializers, types$1_types as types }; | ||
| } | ||
| declare abstract class BasePGlite implements Pick<PGliteInterface, 'query' | 'sql' | 'exec' | 'transaction'> { | ||
| #private; | ||
| serializers: Record<number | string, Serializer>; | ||
| parsers: Record<number | string, Parser>; | ||
| abstract debug: DebugLevel; | ||
| /** | ||
| * Execute a postgres wire protocol message | ||
| * @param message The postgres wire protocol message to execute | ||
| * @returns The result of the query | ||
| */ | ||
| abstract execProtocol(message: Uint8Array, { syncToFs, onNotice }: ExecProtocolOptions): Promise<ExecProtocolResult>; | ||
| /** | ||
| * Execute a postgres wire protocol message | ||
| * @param message The postgres wire protocol message to execute | ||
| * @returns The parsed results of the query | ||
| */ | ||
| abstract execProtocolStream(message: Uint8Array, { syncToFs, onNotice }: ExecProtocolOptions): Promise<BackendMessage[]>; | ||
| /** | ||
| * Execute a postgres wire protocol message directly without wrapping the response. | ||
| * Only use if `execProtocol()` doesn't suite your needs. | ||
| * | ||
| * **Warning:** This bypasses PGlite's protocol wrappers that manage error/notice messages, | ||
| * transactions, and notification listeners. Only use if you need to bypass these wrappers and | ||
| * don't intend to use the above features. | ||
| * | ||
| * @param message The postgres wire protocol message to execute | ||
| * @returns The direct message data response produced by Postgres | ||
| */ | ||
| abstract execProtocolRaw(message: Uint8Array, { syncToFs }: ExecProtocolOptions): Promise<Uint8Array>; | ||
| /** | ||
| * Execute a postgres wire protocol message directly without wrapping the response. | ||
| * Only use if `execProtocol()` doesn't suite your needs. | ||
| * | ||
| * **Warning:** This bypasses PGlite's protocol wrappers that manage error/notice messages, | ||
| * transactions, and notification listeners. Only use if you need to bypass these wrappers and | ||
| * don't intend to use the above features. | ||
| * | ||
| * @param message The postgres wire protocol message to execute | ||
| * @param options.onRawData Callback to receive streaming data | ||
| */ | ||
| abstract execProtocolRawStream(message: Uint8Array, { syncToFs, onRawData }: ExecProtocolOptionsStream): Promise<void>; | ||
| /** | ||
| * Sync the database to the filesystem | ||
| * @returns Promise that resolves when the database is synced to the filesystem | ||
| */ | ||
| abstract syncToFs(): Promise<void>; | ||
| /** | ||
| * Handle a file attached to the current query | ||
| * @param file The file to handle | ||
| */ | ||
| abstract _handleBlob(blob?: File | Blob): Promise<void>; | ||
| /** | ||
| * Get the written file | ||
| */ | ||
| abstract _getWrittenBlob(): Promise<File | Blob | undefined>; | ||
| /** | ||
| * Cleanup the current file | ||
| */ | ||
| abstract _cleanupBlob(): Promise<void>; | ||
| abstract _checkReady(): Promise<void>; | ||
| abstract _runExclusiveQuery<T>(fn: () => Promise<T>): Promise<T>; | ||
| abstract _runExclusiveTransaction<T>(fn: () => Promise<T>): Promise<T>; | ||
| /** | ||
| * Listen for notifications on a channel | ||
| */ | ||
| abstract listen(channel: string, callback: (payload: string) => void, tx?: Transaction): Promise<(tx?: Transaction) => Promise<void>>; | ||
| /** | ||
| * Initialize the array types | ||
| * The oid if the type of an element and the typarray is the oid of the type of the | ||
| * array. | ||
| * We extract these from the database then create the serializers/parsers for | ||
| * each type. | ||
| * This should be called at the end of #init() in the implementing class. | ||
| */ | ||
| _initArrayTypes({ force }?: { | ||
| force?: boolean | undefined; | ||
| }): Promise<void>; | ||
| /** | ||
| * Re-syncs the array types from the database | ||
| * This is useful if you add a new type to the database and want to use it, otherwise pglite won't recognize it. | ||
| */ | ||
| refreshArrayTypes(): Promise<void>; | ||
| /** | ||
| * Execute a single SQL statement | ||
| * This uses the "Extended Query" postgres wire protocol message. | ||
| * @param query The query to execute | ||
| * @param params Optional parameters for the query | ||
| * @returns The result of the query | ||
| */ | ||
| query<T>(query: string, params?: any[], options?: QueryOptions): Promise<Results<T>>; | ||
| /** | ||
| * Execute a single SQL statement like with {@link PGlite.query}, but with a | ||
| * templated statement where template values will be treated as parameters. | ||
| * | ||
| * You can use helpers from `/template` to further format the query with | ||
| * identifiers, raw SQL, and nested statements. | ||
| * | ||
| * This uses the "Extended Query" postgres wire protocol message. | ||
| * | ||
| * @param query The query to execute with parameters as template values | ||
| * @returns The result of the query | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * const results = await db.sql`SELECT * FROM ${identifier`foo`} WHERE id = ${id}` | ||
| * ``` | ||
| */ | ||
| sql<T>(sqlStrings: TemplateStringsArray, ...params: any[]): Promise<Results<T>>; | ||
| /** | ||
| * Execute a SQL query, this can have multiple statements. | ||
| * This uses the "Simple Query" postgres wire protocol message. | ||
| * @param query The query to execute | ||
| * @returns The result of the query | ||
| */ | ||
| exec(query: string, options?: QueryOptions): Promise<Array<Results>>; | ||
| /** | ||
| * Describe a query | ||
| * @param query The query to describe | ||
| * @returns A description of the result types for the query | ||
| */ | ||
| describeQuery(query: string, options?: QueryOptions): Promise<DescribeQueryResult>; | ||
| /** | ||
| * Execute a transaction | ||
| * @param callback A callback function that takes a transaction object | ||
| * @returns The result of the transaction | ||
| */ | ||
| transaction<T>(callback: (tx: Transaction) => Promise<T>): Promise<T>; | ||
| /** | ||
| * Run a function exclusively, no other transactions or queries will be allowed | ||
| * while the function is running. | ||
| * This is useful when working with the execProtocol methods as they are not blocked, | ||
| * and do not block the locks used by transactions and queries. | ||
| * @param fn The function to run | ||
| * @returns The result of the function | ||
| */ | ||
| runExclusive<T>(fn: () => Promise<T>): Promise<T>; | ||
| } | ||
| declare class PGlite extends BasePGlite implements PGliteInterface, AsyncDisposable { | ||
| #private; | ||
| fs?: Filesystem; | ||
| protected mod?: PostgresMod; | ||
| private readonly POSTGRES_MAIN_LONGJMP; | ||
| private readonly PGLITE_EXIT_ALIVE; | ||
| get ENV(): any; | ||
| readonly dataDir?: string; | ||
| readonly waitReady: Promise<void>; | ||
| readonly debug: DebugLevel; | ||
| static readonly paths: { | ||
| readonly PG_ROOT: "/pglite"; | ||
| readonly PGDATA: string; | ||
| readonly ICU_DATA_PATH: string; | ||
| readonly INITDB_EXE_PATH: string; | ||
| readonly POSTGRES_EXE_PATH: string; | ||
| }; | ||
| static readonly DEFAULT_RECV_BUF_SIZE: number; | ||
| static readonly MAX_BUFFER_SIZE: number; | ||
| externalCommandStreamFd: number | null; | ||
| static readonly defaultStartParams: string[]; | ||
| /** | ||
| * Create a new PGlite instance | ||
| * @param dataDir The directory to store the database files | ||
| * Prefix with idb:// to use indexeddb filesystem in the browser | ||
| * Use memory:// to use in-memory filesystem | ||
| * @param options PGlite options | ||
| */ | ||
| constructor(dataDir?: string, options?: PGliteOptions); | ||
| /** | ||
| * Create a new PGlite instance | ||
| * @param options PGlite options including the data directory | ||
| */ | ||
| constructor(options?: PGliteOptions); | ||
| /** | ||
| * Create a new PGlite instance with extensions on the Typescript interface | ||
| * (The main constructor does enable extensions, however due to the limitations | ||
| * of Typescript, the extensions are not available on the instance interface) | ||
| * @param options PGlite options including the data directory | ||
| * @returns A promise that resolves to the PGlite instance when it's ready. | ||
| */ | ||
| static create<O extends PGliteOptions>(options?: O): Promise<PGlite & PGliteInterfaceExtensions<O['extensions']>>; | ||
| /** | ||
| * Create a new PGlite instance with extensions on the Typescript interface | ||
| * (The main constructor does enable extensions, however due to the limitations | ||
| * of Typescript, the extensions are not available on the instance interface) | ||
| * @param dataDir The directory to store the database files | ||
| * Prefix with idb:// to use indexeddb filesystem in the browser | ||
| * Use memory:// to use in-memory filesystem | ||
| * @param options PGlite options | ||
| * @returns A promise that resolves to the PGlite instance when it's ready. | ||
| */ | ||
| static create<O extends PGliteOptions>(dataDir?: string, options?: O): Promise<PGlite & PGliteInterfaceExtensions<O['extensions']>>; | ||
| handleExternalCmd(cmd: string, mode: string): number; | ||
| /** | ||
| * The Postgres Emscripten Module | ||
| */ | ||
| get Module(): PostgresMod; | ||
| /** | ||
| * The ready state of the database | ||
| */ | ||
| get ready(): boolean; | ||
| /** | ||
| * The closed state of the database | ||
| */ | ||
| get closed(): boolean; | ||
| /** | ||
| * Close the database | ||
| * @returns A promise that resolves when the database is closed | ||
| */ | ||
| close(): Promise<void>; | ||
| /** | ||
| * Close the database when the object exits scope | ||
| * Stage 3 ECMAScript Explicit Resource Management | ||
| * https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-2.html#using-declarations-and-explicit-resource-management | ||
| */ | ||
| [Symbol.asyncDispose](): Promise<void>; | ||
| /** | ||
| * Handle a file attached to the current query | ||
| * @param file The file to handle | ||
| */ | ||
| _handleBlob(blob?: File | Blob): Promise<void>; | ||
| /** | ||
| * Cleanup the current file | ||
| */ | ||
| _cleanupBlob(): Promise<void>; | ||
| /** | ||
| * Get the written blob from the current query | ||
| * @returns The written blob | ||
| */ | ||
| _getWrittenBlob(): Promise<Blob | undefined>; | ||
| /** | ||
| * Wait for the database to be ready | ||
| */ | ||
| _checkReady(): Promise<void>; | ||
| /** | ||
| * Execute a postgres wire protocol synchronously | ||
| * @param message The postgres wire protocol message to execute | ||
| * @returns The direct message data response produced by Postgres | ||
| */ | ||
| execProtocolRawSync(message: Uint8Array): Uint8Array; | ||
| /** | ||
| * Execute a postgres wire protocol message directly without wrapping the response. | ||
| * Only use if `execProtocol()` doesn't suite your needs. | ||
| * | ||
| * **Warning:** This bypasses PGlite's protocol wrappers that manage error/notice messages, | ||
| * transactions, and notification listeners. Only use if you need to bypass these wrappers and | ||
| * don't intend to use the above features. | ||
| * | ||
| * @param message The postgres wire protocol message to execute | ||
| * @returns The direct message data response produced by Postgres | ||
| */ | ||
| execProtocolRaw(message: Uint8Array, { syncToFs }?: ExecProtocolOptions): Promise<Uint8Array>; | ||
| /** | ||
| * Execute a postgres wire protocol message directly without wrapping the response. | ||
| * Only use if `execProtocol()` doesn't suite your needs. | ||
| * | ||
| * **Warning:** This bypasses PGlite's protocol wrappers that manage error/notice messages, | ||
| * transactions, and notification listeners. Only use if you need to bypass these wrappers and | ||
| * don't intend to use the above features. | ||
| * | ||
| * @param message The postgres wire protocol message to execute | ||
| * @param options.onRawData Callback to receive results as streaming data | ||
| */ | ||
| execProtocolRawStream(message: Uint8Array, { syncToFs, onRawData }: ExecProtocolOptionsStream): Promise<void>; | ||
| /** | ||
| * Execute a postgres wire protocol message | ||
| * @param message The postgres wire protocol message to execute | ||
| * @returns The result of the query | ||
| */ | ||
| execProtocol(message: Uint8Array, { syncToFs, throwOnError, onNotice, }?: ExecProtocolOptions): Promise<ExecProtocolResult>; | ||
| /** | ||
| * Execute a postgres wire protocol message | ||
| * @param message The postgres wire protocol message to execute | ||
| * @returns The parsed results of the query | ||
| */ | ||
| execProtocolStream(message: Uint8Array, { syncToFs, throwOnError, onNotice }?: ExecProtocolOptions): Promise<BackendMessage[]>; | ||
| /** | ||
| * Check if the database is in a transaction | ||
| * @returns True if the database is in a transaction, false otherwise | ||
| */ | ||
| isInTransaction(): boolean; | ||
| /** | ||
| * Perform any sync operations implemented by the filesystem, this is | ||
| * run after every query to ensure that the filesystem is synced. | ||
| */ | ||
| syncToFs(): Promise<void>; | ||
| /** | ||
| * Listen for a notification | ||
| * @param channel The channel to listen on | ||
| * @param callback The callback to call when a notification is received | ||
| */ | ||
| listen(channel: string, callback: (payload: string) => void, tx?: Transaction): Promise<(tx?: Transaction) => Promise<void>>; | ||
| /** | ||
| * Stop listening for a notification | ||
| * @param channel The channel to stop listening on | ||
| * @param callback The callback to remove | ||
| */ | ||
| unlisten(channel: string, callback?: (payload: string) => void, tx?: Transaction): Promise<void>; | ||
| /** | ||
| * Listen to notifications | ||
| * @param callback The callback to call when a notification is received | ||
| */ | ||
| onNotification(callback: (channel: string, payload: string) => void): () => void; | ||
| /** | ||
| * Stop listening to notifications | ||
| * @param callback The callback to remove | ||
| */ | ||
| offNotification(callback: (channel: string, payload: string) => void): void; | ||
| /** | ||
| * Dump the PGDATA dir from the filesystem to a gzipped tarball. | ||
| * @param compression The compression options to use - 'gzip', 'auto', 'none' | ||
| * @returns The tarball as a File object where available, and fallback to a Blob | ||
| */ | ||
| dumpDataDir(compression?: DumpTarCompressionOptions): Promise<File | Blob>; | ||
| /** | ||
| * Run a function in a mutex that's exclusive to queries | ||
| * @param fn The query to run | ||
| * @returns The result of the query | ||
| */ | ||
| _runExclusiveQuery<T>(fn: () => Promise<T>): Promise<T>; | ||
| /** | ||
| * Run a function in a mutex that's exclusive to transactions | ||
| * @param fn The function to run | ||
| * @returns The result of the function | ||
| */ | ||
| _runExclusiveTransaction<T>(fn: () => Promise<T>): Promise<T>; | ||
| clone(): Promise<PGliteInterface>; | ||
| _runExclusiveListen<T>(fn: () => Promise<T>): Promise<T>; | ||
| callMain(args: string[]): number; | ||
| copyToFS(filePath: string, data: Uint8Array, mode?: number): void; | ||
| } | ||
| export { type FsType as A, type BackendMessage as B, type Filesystem as C, type DebugLevel as D, EmscriptenBuiltinFilesystem as E, type FilesystemType as F, ERRNO_CODES as G, type InitializedExtensions as I, type Mode as M, type Parser as P, type QueryOptions as Q, type Results as R, type SerializerOptions as S, type Transaction as T, type BufferParameter as a, PGlite as b, type PostgresMod as c, type PGliteInterface as d, type RowMode as e, type ParserOptions as f, type ExecProtocolOptions as g, type ExecProtocolOptionsStream as h, type ExtensionSetupResult as i, type ExtensionSetup as j, type Extension as k, type ExtensionNamespace as l, messages as m, type Extensions as n, type ExecProtocolResult as o, postgresMod as p, type DumpDataDirResult as q, type PGliteOptions as r, type PGliteInterfaceExtensions as s, types$1 as t, type Row as u, type DescribeQueryResult as v, BaseFilesystem as w, type FsStats as x, BasePGlite as y, type DumpTarCompressionOptions as z }; |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.cjs'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.cjs'; | ||
@@ -3,0 +3,0 @@ declare const amcheck: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.js'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.js'; | ||
@@ -3,0 +3,0 @@ declare const amcheck: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.cjs'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.cjs'; | ||
@@ -3,0 +3,0 @@ declare const auto_explain: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.js'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.js'; | ||
@@ -3,0 +3,0 @@ declare const auto_explain: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.cjs'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.cjs'; | ||
@@ -3,0 +3,0 @@ declare const bloom: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.js'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.js'; | ||
@@ -3,0 +3,0 @@ declare const bloom: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.cjs'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.cjs'; | ||
@@ -3,0 +3,0 @@ declare const btree_gin: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.js'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.js'; | ||
@@ -3,0 +3,0 @@ declare const btree_gin: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.cjs'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.cjs'; | ||
@@ -3,0 +3,0 @@ declare const btree_gist: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.js'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.js'; | ||
@@ -3,0 +3,0 @@ declare const btree_gist: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.cjs'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.cjs'; | ||
@@ -3,0 +3,0 @@ declare const citext: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.js'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.js'; | ||
@@ -3,0 +3,0 @@ declare const citext: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.cjs'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.cjs'; | ||
@@ -3,0 +3,0 @@ declare const cube: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.js'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.js'; | ||
@@ -3,0 +3,0 @@ declare const cube: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.cjs'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.cjs'; | ||
@@ -3,0 +3,0 @@ declare const dict_int: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.js'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.js'; | ||
@@ -3,0 +3,0 @@ declare const dict_int: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.cjs'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.cjs'; | ||
@@ -3,0 +3,0 @@ declare const dict_xsyn: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.js'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.js'; | ||
@@ -3,0 +3,0 @@ declare const dict_xsyn: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.cjs'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.cjs'; | ||
@@ -3,0 +3,0 @@ declare const earthdistance: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.js'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.js'; | ||
@@ -3,0 +3,0 @@ declare const earthdistance: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.cjs'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.cjs'; | ||
@@ -3,0 +3,0 @@ declare const file_fdw: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.js'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.js'; | ||
@@ -3,0 +3,0 @@ declare const file_fdw: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.cjs'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.cjs'; | ||
@@ -3,0 +3,0 @@ declare const fuzzystrmatch: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.js'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.js'; | ||
@@ -3,0 +3,0 @@ declare const fuzzystrmatch: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.cjs'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.cjs'; | ||
@@ -3,0 +3,0 @@ declare const hstore: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.js'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.js'; | ||
@@ -3,0 +3,0 @@ declare const hstore: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.cjs'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.cjs'; | ||
@@ -3,0 +3,0 @@ declare const intarray: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.js'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.js'; | ||
@@ -3,0 +3,0 @@ declare const intarray: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.cjs'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.cjs'; | ||
@@ -3,0 +3,0 @@ declare const isn: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.js'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.js'; | ||
@@ -3,0 +3,0 @@ declare const isn: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.cjs'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.cjs'; | ||
@@ -3,0 +3,0 @@ declare const lo: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.js'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.js'; | ||
@@ -3,0 +3,0 @@ declare const lo: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.cjs'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.cjs'; | ||
@@ -3,0 +3,0 @@ declare const ltree: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.js'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.js'; | ||
@@ -3,0 +3,0 @@ declare const ltree: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.cjs'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.cjs'; | ||
@@ -3,0 +3,0 @@ declare const moddatetime: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.js'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.js'; | ||
@@ -3,0 +3,0 @@ declare const moddatetime: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.cjs'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.cjs'; | ||
@@ -3,0 +3,0 @@ declare const pageinspect: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.js'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.js'; | ||
@@ -3,0 +3,0 @@ declare const pageinspect: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.cjs'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.cjs'; | ||
@@ -3,0 +3,0 @@ declare const pg_buffercache: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.js'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.js'; | ||
@@ -3,0 +3,0 @@ declare const pg_buffercache: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.cjs'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.cjs'; | ||
@@ -3,0 +3,0 @@ declare const pg_freespacemap: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.js'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.js'; | ||
@@ -3,0 +3,0 @@ declare const pg_freespacemap: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.cjs'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.cjs'; | ||
@@ -3,0 +3,0 @@ declare const pg_stat_statements: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.js'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.js'; | ||
@@ -3,0 +3,0 @@ declare const pg_stat_statements: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.cjs'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.cjs'; | ||
@@ -3,0 +3,0 @@ declare const pg_surgery: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.js'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.js'; | ||
@@ -3,0 +3,0 @@ declare const pg_surgery: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.cjs'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.cjs'; | ||
@@ -3,0 +3,0 @@ declare const pg_trgm: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.js'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.js'; | ||
@@ -3,0 +3,0 @@ declare const pg_trgm: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.cjs'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.cjs'; | ||
@@ -3,0 +3,0 @@ declare const pg_visibility: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.js'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.js'; | ||
@@ -3,0 +3,0 @@ declare const pg_visibility: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.cjs'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.cjs'; | ||
@@ -3,0 +3,0 @@ declare const pg_walinspect: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.js'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.js'; | ||
@@ -3,0 +3,0 @@ declare const pg_walinspect: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.cjs'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.cjs'; | ||
@@ -3,0 +3,0 @@ declare const pgcrypto: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.js'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.js'; | ||
@@ -3,0 +3,0 @@ declare const pgcrypto: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.cjs'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.cjs'; | ||
@@ -3,0 +3,0 @@ declare const seg: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.js'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.js'; | ||
@@ -3,0 +3,0 @@ declare const seg: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.cjs'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.cjs'; | ||
@@ -3,0 +3,0 @@ declare const tablefunc: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.js'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.js'; | ||
@@ -3,0 +3,0 @@ declare const tablefunc: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.cjs'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.cjs'; | ||
@@ -3,0 +3,0 @@ declare const tcn: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.js'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.js'; | ||
@@ -3,0 +3,0 @@ declare const tcn: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.cjs'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.cjs'; | ||
@@ -3,0 +3,0 @@ declare const tsm_system_rows: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.js'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.js'; | ||
@@ -3,0 +3,0 @@ declare const tsm_system_rows: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.cjs'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.cjs'; | ||
@@ -3,0 +3,0 @@ declare const tsm_system_time: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.js'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.js'; | ||
@@ -3,0 +3,0 @@ declare const tsm_system_time: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.cjs'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.cjs'; | ||
@@ -3,0 +3,0 @@ declare const unaccent: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.js'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.js'; | ||
@@ -3,0 +3,0 @@ declare const unaccent: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.cjs'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.cjs'; | ||
@@ -3,0 +3,0 @@ declare const uuid_ossp: { |
@@ -1,2 +0,2 @@ | ||
| import { d as PGliteInterface } from '../pglite-DIqDo27J.js'; | ||
| import { d as PGliteInterface } from '../pglite-BdeXTuy6.js'; | ||
@@ -3,0 +3,0 @@ declare const uuid_ossp: { |
@@ -1,1 +0,1 @@ | ||
| export { w as BaseFilesystem, G as ERRNO_CODES, E as EmscriptenBuiltinFilesystem, C as Filesystem, x as FsStats, A as FsType } from '../pglite-DIqDo27J.cjs'; | ||
| export { w as BaseFilesystem, G as ERRNO_CODES, E as EmscriptenBuiltinFilesystem, C as Filesystem, x as FsStats, A as FsType } from '../pglite-BdeXTuy6.cjs'; |
@@ -1,1 +0,1 @@ | ||
| export { w as BaseFilesystem, G as ERRNO_CODES, E as EmscriptenBuiltinFilesystem, C as Filesystem, x as FsStats, A as FsType } from '../pglite-DIqDo27J.js'; | ||
| export { w as BaseFilesystem, G as ERRNO_CODES, E as EmscriptenBuiltinFilesystem, C as Filesystem, x as FsStats, A as FsType } from '../pglite-BdeXTuy6.js'; |
+1
-1
@@ -1,2 +0,2 @@ | ||
| import{i as a,j as b,k as c}from"../chunk-TDKVRJ2S.js";import"../chunk-VVBUWNGP.js";import"../chunk-QY3QWFKW.js";export{b as BaseFilesystem,c as ERRNO_CODES,a as EmscriptenBuiltinFilesystem}; | ||
| import{i as a,j as b,k as c}from"../chunk-IFSHUC46.js";import"../chunk-NNS5RQRF.js";import"../chunk-QY3QWFKW.js";export{b as BaseFilesystem,c as ERRNO_CODES,a as EmscriptenBuiltinFilesystem}; | ||
| //# sourceMappingURL=base.js.map |
@@ -1,2 +0,2 @@ | ||
| import { E as EmscriptenBuiltinFilesystem, b as PGlite, c as PostgresMod } from '../pglite-DIqDo27J.cjs'; | ||
| import { E as EmscriptenBuiltinFilesystem, b as PGlite, c as PostgresMod } from '../pglite-BdeXTuy6.cjs'; | ||
@@ -3,0 +3,0 @@ declare class NodeFS extends EmscriptenBuiltinFilesystem { |
@@ -1,2 +0,2 @@ | ||
| import { E as EmscriptenBuiltinFilesystem, b as PGlite, c as PostgresMod } from '../pglite-DIqDo27J.js'; | ||
| import { E as EmscriptenBuiltinFilesystem, b as PGlite, c as PostgresMod } from '../pglite-BdeXTuy6.js'; | ||
@@ -3,0 +3,0 @@ declare class NodeFS extends EmscriptenBuiltinFilesystem { |
@@ -1,2 +0,2 @@ | ||
| import{d as i,i as p}from"../chunk-TDKVRJ2S.js";import"../chunk-VVBUWNGP.js";import{j as n}from"../chunk-QY3QWFKW.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,i as p}from"../chunk-IFSHUC46.js";import"../chunk-NNS5RQRF.js";import{j as n}from"../chunk-QY3QWFKW.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 { w as BaseFilesystem, b as PGlite, c as PostgresMod, x as FsStats } from '../pglite-DIqDo27J.cjs'; | ||
| import { w as BaseFilesystem, b as PGlite, c as PostgresMod, x as FsStats } from '../pglite-BdeXTuy6.cjs'; | ||
@@ -3,0 +3,0 @@ interface OpfsAhpOptions { |
@@ -1,2 +0,2 @@ | ||
| import { w as BaseFilesystem, b as PGlite, c as PostgresMod, x as FsStats } from '../pglite-DIqDo27J.js'; | ||
| import { w as BaseFilesystem, b as PGlite, c as PostgresMod, x as FsStats } from '../pglite-BdeXTuy6.js'; | ||
@@ -3,0 +3,0 @@ interface OpfsAhpOptions { |
@@ -1,4 +0,4 @@ | ||
| import{j as B,k as z}from"../chunk-TDKVRJ2S.js";import"../chunk-VVBUWNGP.js";import{e as s,f as g,g as E,h as r,i as _,j as R}from"../chunk-QY3QWFKW.js";R();var $="state.txt",G="data",T={DIR:16384,FILE:32768},H,v,F,M,y,b,m,x,P,D,S,n,C,O,k,w,f,I,W,j,L=class extends B{constructor(e,{initialPoolSize:t=1e3,maintainedPoolSize:o=100,debug:i=!1}={}){super(e,{debug:i});g(this,n);g(this,H);g(this,v);g(this,F);g(this,M);g(this,y);g(this,b,new Map);g(this,m,new Map);g(this,x,0);g(this,P,new Map);g(this,D,new Map);this.lastCheckpoint=0;this.checkpointInterval=1e3*60;this.poolCounter=0;g(this,S,new Set);this.initialPoolSize=t,this.maintainedPoolSize=o}async init(e,t){return await r(this,n,C).call(this),super.init(e,t)}async syncToFs(e=!1){await this.maybeCheckpointState(),await this.maintainPool(),e||this.flush()}async closeFs(){for(let e of s(this,m).values())e.close();s(this,y).flush(),s(this,y).close(),this.pg.Module.FS.quit()}async maintainPool(e){e=e||this.maintainedPoolSize;let t=e-this.state.pool.length,o=[];for(let i=0;i<t;i++)o.push(new Promise(async c=>{++this.poolCounter;let a=`${(Date.now()-1704063600).toString(16).padStart(8,"0")}-${this.poolCounter.toString(16).padStart(8,"0")}`,h=await s(this,F).getFileHandle(a,{create:!0}),d=await h.createSyncAccessHandle();s(this,b).set(a,h),s(this,m).set(a,d),r(this,n,k).call(this,{opp:"createPoolFile",args:[a]}),this.state.pool.push(a),c()}));for(let i=0;i>t;i--)o.push(new Promise(async c=>{let a=this.state.pool.pop();r(this,n,k).call(this,{opp:"deletePoolFile",args:[a]});let h=s(this,b).get(a);s(this,m).get(a)?.close(),await s(this,F).removeEntry(h.name),s(this,b).delete(a),s(this,m).delete(a),c()}));await Promise.all(o)}_createPoolFileState(e){this.state.pool.push(e)}_deletePoolFileState(e){let t=this.state.pool.indexOf(e);t>-1&&this.state.pool.splice(t,1)}async maybeCheckpointState(){Date.now()-this.lastCheckpoint>this.checkpointInterval&&await this.checkpointState()}async checkpointState(){let e=new TextEncoder().encode(JSON.stringify(this.state));s(this,y).truncate(0),s(this,y).write(e,{at:0}),s(this,y).flush(),this.lastCheckpoint=Date.now()}flush(){for(let e of s(this,S))try{e.flush()}catch{}s(this,S).clear()}chmod(e,t){r(this,n,O).call(this,{opp:"chmod",args:[e,t]},()=>{this._chmodState(e,t)})}_chmodState(e,t){let o=r(this,n,f).call(this,e);o.mode=t}close(e){let t=r(this,n,I).call(this,e);s(this,P).delete(e),s(this,D).delete(t)}fstat(e){let t=r(this,n,I).call(this,e);return this.lstat(t)}lstat(e){let t=r(this,n,f).call(this,e),o=t.type==="file"?s(this,m).get(t.backingFilename).getSize():0,i=4096;return{dev:0,ino:0,mode:t.mode,nlink:1,uid:0,gid:0,rdev:0,size:o,blksize:i,blocks:Math.ceil(o/i),atime:t.lastModified,mtime:t.lastModified,ctime:t.lastModified}}mkdir(e,t){r(this,n,O).call(this,{opp:"mkdir",args:[e,t]},()=>{this._mkdirState(e,t)})}_mkdirState(e,t){let o=r(this,n,w).call(this,e),i=o.pop(),c=[],a=this.state.root;for(let d of o){if(c.push(e),!Object.prototype.hasOwnProperty.call(a.children,d))if(t?.recursive)this.mkdir(c.join("/"));else throw new p("ENOENT","No such file or directory");if(a.children[d].type!=="directory")throw new p("ENOTDIR","Not a directory");a=a.children[d]}if(Object.prototype.hasOwnProperty.call(a.children,i))throw new p("EEXIST","File exists");let h={type:"directory",lastModified:Date.now(),mode:t?.mode||T.DIR,children:{}};a.children[i]=h}open(e,t,o){if(r(this,n,f).call(this,e).type!=="file")throw new p("EISDIR","Is a directory");let c=r(this,n,W).call(this);return s(this,P).set(c,e),s(this,D).set(e,c),c}readdir(e){let t=r(this,n,f).call(this,e);if(t.type!=="directory")throw new p("ENOTDIR","Not a directory");return Object.keys(t.children)}read(e,t,o,i,c){let a=r(this,n,I).call(this,e),h=r(this,n,f).call(this,a);if(h.type!=="file")throw new p("EISDIR","Is a directory");return s(this,m).get(h.backingFilename).read(new Uint8Array(t.buffer,o,i),{at:c})}rename(e,t){r(this,n,O).call(this,{opp:"rename",args:[e,t]},()=>{this._renameState(e,t,!0)})}_renameState(e,t,o=!1){let i=r(this,n,w).call(this,e),c=i.pop(),a=r(this,n,f).call(this,i.join("/"));if(!Object.prototype.hasOwnProperty.call(a.children,c))throw new p("ENOENT","No such file or directory");let h=r(this,n,w).call(this,t),d=h.pop(),l=r(this,n,f).call(this,h.join("/"));if(o&&Object.prototype.hasOwnProperty.call(l.children,d)){let u=l.children[d];s(this,m).get(u.backingFilename).truncate(0),this.state.pool.push(u.backingFilename)}l.children[d]=a.children[c],delete a.children[c]}rmdir(e){r(this,n,O).call(this,{opp:"rmdir",args:[e]},()=>{this._rmdirState(e)})}_rmdirState(e){let t=r(this,n,w).call(this,e),o=t.pop(),i=r(this,n,f).call(this,t.join("/"));if(!Object.prototype.hasOwnProperty.call(i.children,o))throw new p("ENOENT","No such file or directory");let c=i.children[o];if(c.type!=="directory")throw new p("ENOTDIR","Not a directory");if(Object.keys(c.children).length>0)throw new p("ENOTEMPTY","Directory not empty");delete i.children[o]}truncate(e,t=0){let o=r(this,n,f).call(this,e);if(o.type!=="file")throw new p("EISDIR","Is a directory");let i=s(this,m).get(o.backingFilename);if(!i)throw new p("ENOENT","No such file or directory");i.truncate(t),s(this,S).add(i)}unlink(e){r(this,n,O).call(this,{opp:"unlink",args:[e]},()=>{this._unlinkState(e,!0)})}_unlinkState(e,t=!1){let o=r(this,n,w).call(this,e),i=o.pop(),c=r(this,n,f).call(this,o.join("/"));if(!Object.prototype.hasOwnProperty.call(c.children,i))throw new p("ENOENT","No such file or directory");let a=c.children[i];if(a.type!=="file")throw new p("EISDIR","Is a directory");if(delete c.children[i],t){let h=s(this,m).get(a.backingFilename);h?.truncate(0),s(this,S).add(h),s(this,D).has(e)&&(s(this,P).delete(s(this,D).get(e)),s(this,D).delete(e))}this.state.pool.push(a.backingFilename)}utimes(e,t,o){r(this,n,O).call(this,{opp:"utimes",args:[e,t,o]},()=>{this._utimesState(e,t,o)})}_utimesState(e,t,o){let i=r(this,n,f).call(this,e);i.lastModified=o}writeFile(e,t,o){let i=r(this,n,w).call(this,e),c=i.pop(),a=r(this,n,f).call(this,i.join("/"));if(Object.prototype.hasOwnProperty.call(a.children,c)){let l=a.children[c];l.lastModified=Date.now(),r(this,n,k).call(this,{opp:"setLastModified",args:[e,l.lastModified]})}else{if(this.state.pool.length===0)throw new Error("No more file handles available in the pool");let l={type:"file",lastModified:Date.now(),mode:o?.mode||T.FILE,backingFilename:this.state.pool.pop()};a.children[c]=l,r(this,n,k).call(this,{opp:"createFileNode",args:[e,l]})}let h=a.children[c],d=s(this,m).get(h.backingFilename);t.length>0&&(d.write(typeof t=="string"?new TextEncoder().encode(t):new Uint8Array(t),{at:0}),e.startsWith("/pg_wal")&&s(this,S).add(d))}_createFileNodeState(e,t){let o=r(this,n,w).call(this,e),i=o.pop(),c=r(this,n,f).call(this,o.join("/"));c.children[i]=t;let a=this.state.pool.indexOf(t.backingFilename);return a>-1&&this.state.pool.splice(a,1),t}_setLastModifiedState(e,t){let o=r(this,n,f).call(this,e);o.lastModified=t}write(e,t,o,i,c){let a=r(this,n,I).call(this,e),h=r(this,n,f).call(this,a);if(h.type!=="file")throw new p("EISDIR","Is a directory");let d=s(this,m).get(h.backingFilename);if(!d)throw new p("EBADF","Bad file descriptor");let l=d.write(new Uint8Array(t,o,i),{at:c});return a.startsWith("/pg_wal")&&s(this,S).add(d),l}};H=new WeakMap,v=new WeakMap,F=new WeakMap,M=new WeakMap,y=new WeakMap,b=new WeakMap,m=new WeakMap,x=new WeakMap,P=new WeakMap,D=new WeakMap,S=new WeakMap,n=new WeakSet,C=async function(){E(this,H,await navigator.storage.getDirectory()),E(this,v,await r(this,n,j).call(this,this.dataDir,{create:!0})),E(this,F,await r(this,n,j).call(this,G,{from:s(this,v),create:!0})),E(this,M,await s(this,v).getFileHandle($,{create:!0})),E(this,y,await s(this,M).createSyncAccessHandle());let e=new ArrayBuffer(s(this,y).getSize());s(this,y).read(e,{at:0});let t,o=new TextDecoder().decode(e).split(` | ||
| import{j as B,k as z}from"../chunk-IFSHUC46.js";import"../chunk-NNS5RQRF.js";import{e as s,f as g,g as E,h as r,i as _,j as R}from"../chunk-QY3QWFKW.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 |
+2
-2
@@ -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-DIqDo27J.cjs'; | ||
| export { D as DebugLevel, v as DescribeQueryResult, q as DumpDataDirResult, g as ExecProtocolOptions, h as ExecProtocolOptionsStream, o as ExecProtocolResult, k as Extension, l as ExtensionNamespace, j as ExtensionSetup, i as ExtensionSetupResult, n as Extensions, F as FilesystemType, I as InitializedExtensions, s as PGliteInterfaceExtensions, r as PGliteOptions, f as ParserOptions, u as Row, e as RowMode, S as SerializerOptions, m as messages, p as postgresMod, t as types } from './pglite-DIqDo27J.cjs'; | ||
| 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-BdeXTuy6.cjs'; | ||
| export { D as DebugLevel, v as DescribeQueryResult, q as DumpDataDirResult, g as ExecProtocolOptions, h as ExecProtocolOptionsStream, o as ExecProtocolResult, k as Extension, l as ExtensionNamespace, j as ExtensionSetup, i as ExtensionSetupResult, n as Extensions, F as FilesystemType, I as InitializedExtensions, s as PGliteInterfaceExtensions, r as PGliteOptions, f as ParserOptions, u as Row, e as RowMode, S as SerializerOptions, m as messages, p as postgresMod, t as types } from './pglite-BdeXTuy6.cjs'; | ||
@@ -4,0 +4,0 @@ /** |
+2
-2
@@ -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-DIqDo27J.js'; | ||
| export { D as DebugLevel, v as DescribeQueryResult, q as DumpDataDirResult, g as ExecProtocolOptions, h as ExecProtocolOptionsStream, o as ExecProtocolResult, k as Extension, l as ExtensionNamespace, j as ExtensionSetup, i as ExtensionSetupResult, n as Extensions, F as FilesystemType, I as InitializedExtensions, s as PGliteInterfaceExtensions, r as PGliteOptions, f as ParserOptions, u as Row, e as RowMode, S as SerializerOptions, m as messages, p as postgresMod, t as types } from './pglite-DIqDo27J.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-BdeXTuy6.js'; | ||
| export { D as DebugLevel, v as DescribeQueryResult, q as DumpDataDirResult, g as ExecProtocolOptions, h as ExecProtocolOptionsStream, o as ExecProtocolResult, k as Extension, l as ExtensionNamespace, j as ExtensionSetup, i as ExtensionSetupResult, n as Extensions, F as FilesystemType, I as InitializedExtensions, s as PGliteInterfaceExtensions, r as PGliteOptions, f as ParserOptions, u as Row, e as RowMode, S as SerializerOptions, m as messages, p as postgresMod, t as types } from './pglite-BdeXTuy6.js'; | ||
@@ -4,0 +4,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
| "use strict";var we=Object.create;var Q=Object.defineProperty;var Ae=Object.getOwnPropertyDescriptor;var Te=Object.getOwnPropertyNames;var Se=Object.getPrototypeOf,Re=Object.prototype.hasOwnProperty;var oe=e=>{throw TypeError(e)};var Ie=(e,t)=>{for(var n in t)Q(e,n,{get:t[n],enumerable:!0})},ue=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Te(t))!Re.call(e,r)&&r!==n&&Q(e,r,{get:()=>t[r],enumerable:!(s=Ae(t,r))||s.enumerable});return e};var ce=(e,t,n)=>(n=e!=null?we(Se(e)):{},ue(t||!e||!e.__esModule?Q(n,"default",{value:e,enumerable:!0}):n,e)),Ne=e=>ue(Q({},"__esModule",{value:!0}),e);var te=(e,t,n)=>t.has(e)||oe("Cannot "+n);var c=(e,t,n)=>(te(e,t,"read from private field"),n?n.call(e):t.get(e)),M=(e,t,n)=>t.has(e)?oe("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),N=(e,t,n,s)=>(te(e,t,"write to private field"),s?s.call(e,n):t.set(e,n),n),L=(e,t,n)=>(te(e,t,"access private method"),n);var ne=(e,t,n,s)=>({set _(r){N(e,t,r,n)},get _(){return c(e,t,s)}});var Nt={};Ie(Nt,{live:()=>Rt});module.exports=Ne(Nt);function U(e){let t=e.length;for(let n=e.length-1;n>=0;n--){let s=e.charCodeAt(n);s>127&&s<=2047?t++:s>2047&&s<=65535&&(t+=2),s>=56320&&s<=57343&&n--}return t}var A,T,k,H,V,R,W,F,le,x=class{constructor(t=256){this.size=t;M(this,R);M(this,A);M(this,T,5);M(this,k,!1);M(this,H,new TextEncoder);M(this,V,0);N(this,A,L(this,R,W).call(this,t))}addInt32(t){return L(this,R,F).call(this,4),c(this,A).setInt32(c(this,T),t,c(this,k)),N(this,T,c(this,T)+4),this}addInt16(t){return L(this,R,F).call(this,2),c(this,A).setInt16(c(this,T),t,c(this,k)),N(this,T,c(this,T)+2),this}addCString(t){return t&&this.addString(t),L(this,R,F).call(this,1),c(this,A).setUint8(c(this,T),0),ne(this,T)._++,this}addString(t=""){let n=U(t);return L(this,R,F).call(this,n),c(this,H).encodeInto(t,new Uint8Array(c(this,A).buffer,c(this,T))),N(this,T,c(this,T)+n),this}add(t){return L(this,R,F).call(this,t.byteLength),new Uint8Array(c(this,A).buffer).set(new Uint8Array(t),c(this,T)),N(this,T,c(this,T)+t.byteLength),this}flush(t){let n=L(this,R,le).call(this,t);return N(this,T,5),N(this,A,L(this,R,W).call(this,this.size)),new Uint8Array(n)}};A=new WeakMap,T=new WeakMap,k=new WeakMap,H=new WeakMap,V=new WeakMap,R=new WeakSet,W=function(t){return new DataView(new ArrayBuffer(t))},F=function(t){if(c(this,A).byteLength-c(this,T)<t){let s=c(this,A).buffer,r=s.byteLength+(s.byteLength>>1)+t;N(this,A,L(this,R,W).call(this,r)),new Uint8Array(c(this,A).buffer).set(new Uint8Array(s))}},le=function(t){if(t){c(this,A).setUint8(c(this,V),t);let n=c(this,T)-(c(this,V)+1);c(this,A).setInt32(c(this,V)+1,n,c(this,k))}return c(this,A).buffer.slice(t?0:5,c(this,T))};var g=new x,ve=e=>{g.addInt16(3).addInt16(0);for(let s of Object.keys(e))g.addCString(s).addCString(e[s]);g.addCString("client_encoding").addCString("UTF8");let t=g.addCString("").flush(),n=t.byteLength+4;return new x().addInt32(n).add(t).flush()},Ce=()=>{let e=new DataView(new ArrayBuffer(8));return e.setInt32(0,8,!1),e.setInt32(4,80877103,!1),new Uint8Array(e.buffer)},Le=e=>g.addCString(e).flush(112),De=(e,t)=>(g.addCString(e).addInt32(U(t)).addString(t),g.flush(112)),Oe=e=>g.addString(e).flush(112),Me=e=>g.addCString(e).flush(81),Be=[],Pe=e=>{let t=e.name??"";t.length>63&&(console.error("Warning! Postgres only supports 63 characters for query names."),console.error("You supplied %s (%s)",t,t.length),console.error("This can cause conflicts and silent errors executing queries"));let n=g.addCString(t).addCString(e.text).addInt16(e.types?.length??0);return e.types?.forEach(s=>n.addInt32(s)),g.flush(80)},q=new x;var xe=(e,t)=>{for(let n=0;n<e.length;n++){let s=t?t(e[n],n):e[n];if(s===null)g.addInt16(0),q.addInt32(-1);else if(s instanceof ArrayBuffer||ArrayBuffer.isView(s)){let r=ArrayBuffer.isView(s)?s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength):s;g.addInt16(1),q.addInt32(r.byteLength),q.add(r)}else g.addInt16(0),q.addInt32(U(s)),q.addString(s)}},$e=(e={})=>{let t=e.portal??"",n=e.statement??"",s=e.binary??!1,r=e.values??Be,a=r.length;return g.addCString(t).addCString(n),g.addInt16(a),xe(r,e.valueMapper),g.addInt16(a),g.add(q.flush()),g.addInt16(s?1:0),g.flush(66)},Ue=new Uint8Array([69,0,0,0,9,0,0,0,0,0]),Fe=e=>{if(!e||!e.portal&&!e.rows)return Ue;let t=e.portal??"",n=e.rows??0,s=U(t),r=4+s+1+4,a=new DataView(new ArrayBuffer(1+r));return a.setUint8(0,69),a.setInt32(1,r,!1),new TextEncoder().encodeInto(t,new Uint8Array(a.buffer,5)),a.setUint8(s+5,0),a.setUint32(a.byteLength-4,n,!1),new Uint8Array(a.buffer)},ke=(e,t)=>{let n=new DataView(new ArrayBuffer(16));return n.setInt32(0,16,!1),n.setInt16(4,1234,!1),n.setInt16(6,5678,!1),n.setInt32(8,e,!1),n.setInt32(12,t,!1),new Uint8Array(n.buffer)},re=(e,t)=>{let n=new x;return n.addCString(t),n.flush(e)},Ve=g.addCString("P").flush(68),qe=g.addCString("S").flush(68),Ge=e=>e.name?re(68,`${e.type}${e.name??""}`):e.type==="P"?Ve:qe,je=e=>{let t=`${e.type}${e.name??""}`;return re(67,t)},Qe=e=>g.add(e).flush(100),We=e=>re(102,e),X=e=>new Uint8Array([e,0,0,0,4]),He=X(72),Xe=X(83),ze=X(88),Je=X(99),G={startup:ve,password:Le,requestSsl:Ce,sendSASLInitialResponseMessage:De,sendSCRAMClientFinalMessage:Oe,query:Me,parse:Pe,bind:$e,execute:Fe,describe:Ge,close:je,flush:()=>He,sync:()=>Xe,end:()=>ze,copyData:Qe,copyDone:()=>Je,copyFail:We,cancel:ke};var qt=new ArrayBuffer(0);var Ke=1,Ze=4,Cn=Ke+Ze,Ln=new ArrayBuffer(0);var et=globalThis.JSON.parse,tt=globalThis.JSON.stringify,de=16,pe=17;var fe=20,nt=21,rt=23;var z=25,st=26;var me=114;var it=700,at=701;var ot=1042,ut=1043,ct=1082;var lt=1114,ye=1184;var dt=3802;var pt={string:{to:z,from:[z,ut,ot],serialize:e=>e instanceof Date?e.toISOString():e.toString(),parse:e=>e},number:{to:0,from:[nt,rt,st,it,at],serialize:e=>e.toString(),parse:e=>+e},bigint:{to:fe,from:[fe],serialize:e=>e.toString(),parse:e=>{let t=BigInt(e);return t<Number.MIN_SAFE_INTEGER||t>Number.MAX_SAFE_INTEGER?t:Number(t)}},json:{to:me,from:[me,dt],serialize:e=>typeof e=="string"?e:tt(e,(t,n)=>typeof n=="bigint"?n.toString():n),parse:e=>et(e)},boolean:{to:de,from:[de],serialize:e=>{if(typeof e=="boolean")return e?"t":"f";if(typeof e=="number"){if(e===1)return"t";if(e===0)return"f"}else if(typeof e=="string"){let t=e.trim().toLowerCase();if(["true","t","yes","y","on","1"].includes(t))return"t";if(["false","f","no","n","off","0"].includes(t))return"f"}throw new Error("Invalid input for boolean type")},parse:e=>e==="t"},date:{to:ye,from:[ct,lt,ye],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:pe,from:[pe],serialize:e=>{if(!(e instanceof Uint8Array))throw new Error("Invalid input for bytea type");return"\\x"+Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")},parse:e=>{let t=e.slice(2);return Uint8Array.from({length:t.length/2},(n,s)=>parseInt(t.substring(s*2,(s+1)*2),16))}}},he=ft(pt),Fn=he.parsers,kn=he.serializers;function ft(e){return Object.keys(e).reduce(({parsers:t,serializers:n},s)=>{let{to:r,from:a,serialize:i,parse:b}=e[s];return n[r]=i,n[s]=i,t[s]=b,Array.isArray(a)?a.forEach(y=>{t[y]=b,n[y]=i}):(t[a]=b,n[a]=i),{parsers:t,serializers:n}},{parsers:{},serializers:{}})}function ge(e){let t=e.find(n=>n.name==="parameterDescription");return t?t.dataTypeIDs:[]}async function se(e,t,n,s){if(!n||n.length===0)return t;s=s??e;let r=[];try{await e.execProtocol(G.parse({text:t}),{syncToFs:!1}),r.push(...(await e.execProtocol(G.describe({type:"S"}),{syncToFs:!1})).messages)}finally{r.push(...(await e.execProtocol(G.sync(),{syncToFs:!1})).messages)}let a=ge(r),i=t.replace(/\$([0-9]+)/g,(y,l)=>"%"+l+"$L");return(await s.query(`SELECT format($1, ${n.map((y,l)=>`$${l+2}`).join(", ")}) as query`,[i,...n],{paramTypes:[z,...a]})).rows[0].query}function ie(e){let t,n=!1,s=async()=>{if(!t){n=!1;return}n=!0;let{args:r,resolve:a,reject:i}=t;t=void 0;try{let b=await e(...r);a(b)}catch(b){i(b)}finally{s()}};return async(...r)=>{t&&t.resolve(void 0);let a=new Promise((i,b)=>{t={args:r,resolve:i,reject:b}});return n||s(),a}}var mt=Object.defineProperty,yt=(e,t)=>{for(var n in t)mt(e,n,{get:t[n],enumerable:!0})},Y={};yt(Y,{IN_NODE:()=>K,WASM_PREFIX:()=>gt,getFsBundle:()=>Et,instantiateWasm:()=>_t,pgliteProc:()=>bt,rmdirRecursive:()=>be,startArtifactDownload:()=>ae,toPostgresName:()=>At,uuid:()=>wt});function ht(){let e=process.type;return e==="renderer"||e==="worker"||e==="service-worker"}var K=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string"&&!ht(),gt="/pglite",j=new Map;async function ae(e){K||j.has(e.toString())||j.set(e.toString(),fetch(e))}var J=new Map,bt=globalThis&&typeof globalThis.process<"u"?globalThis.process:{exitCode:void 0};async function _t(e,t,n){if(n||J.has(t.toString())){let s=n||J.get(t.toString());return{instance:await WebAssembly.instantiate(s,e),module:s}}if(K){let s=await(await import("fs/promises")).readFile(t),{module:r,instance:a}=await WebAssembly.instantiate(s,e);return J.set(t.toString(),r),{instance:a,module:r}}else{j.has(t.toString())||ae(t);let s=await j.get(t.toString()),{module:r,instance:a}=await WebAssembly.instantiateStreaming(s.clone(),e);return J.set(t.toString(),r),{instance:a,module:r}}}async function Et(e){return K?(await(await import("fs/promises")).readFile(e)).buffer:(ae(e),(await j.get(e.toString())).clone().arrayBuffer())}var wt=()=>{if(globalThis.crypto?.randomUUID)return globalThis.crypto.randomUUID();let e=new Uint8Array(16);if(globalThis.crypto?.getRandomValues)globalThis.crypto.getRandomValues(e);else for(let n=0;n<e.length;n++)e[n]=Math.floor(Math.random()*256);e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=[];return e.forEach(n=>{t.push(n.toString(16).padStart(2,"0"))}),t.slice(0,4).join("")+"-"+t.slice(4,6).join("")+"-"+t.slice(6,8).join("")+"-"+t.slice(8,10).join("")+"-"+t.slice(10).join("")};function At(e){let t;return e.startsWith('"')&&e.endsWith('"')?t=e.substring(1,e.length-1):t=e.toLowerCase(),t}function be(e,t){try{let n=e.readdir(t).filter(s=>s!=="."&&s!=="..");for(let s of n){let r=t+"/"+s;try{e.readdir(r),be(e,r)}catch{e.unlink(r)}}e.rmdir(t)}catch{try{e.unlink(t)}catch{}}}var Tt=5,St=async(e,t)=>{let n=new Set,s={async query(r,a,i){let b,y,l;if(typeof r!="string"&&(b=r.signal,a=r.params,i=r.callback,y=r.offset,l=r.limit,r=r.query),y===void 0!=(l===void 0))throw new Error("offset and limit must be provided together");let o=y!==void 0&&l!==void 0,S;if(o&&(typeof y!="number"||isNaN(y)||typeof l!="number"||isNaN(l)))throw new Error("offset and limit must be numbers");let _=i?[i]:[],m=Y.uuid().replace(/-/g,""),D=!1,I,B,$=async()=>{await e.transaction(async u=>{let p=a&&a.length>0?await se(e,r,a,u):r;await u.exec(`CREATE OR REPLACE TEMP VIEW live_query_${m}_view AS ${p}`);let E=await _e(u,`live_query_${m}_view`);await Ee(u,E,n),o?(await u.exec(` | ||
| "use strict";var we=Object.create;var Q=Object.defineProperty;var Ae=Object.getOwnPropertyDescriptor;var Te=Object.getOwnPropertyNames;var Se=Object.getPrototypeOf,Re=Object.prototype.hasOwnProperty;var oe=e=>{throw TypeError(e)};var Ie=(e,t)=>{for(var n in t)Q(e,n,{get:t[n],enumerable:!0})},ue=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Te(t))!Re.call(e,r)&&r!==n&&Q(e,r,{get:()=>t[r],enumerable:!(s=Ae(t,r))||s.enumerable});return e};var ce=(e,t,n)=>(n=e!=null?we(Se(e)):{},ue(t||!e||!e.__esModule?Q(n,"default",{value:e,enumerable:!0}):n,e)),Ne=e=>ue(Q({},"__esModule",{value:!0}),e);var te=(e,t,n)=>t.has(e)||oe("Cannot "+n);var c=(e,t,n)=>(te(e,t,"read from private field"),n?n.call(e):t.get(e)),M=(e,t,n)=>t.has(e)?oe("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),N=(e,t,n,s)=>(te(e,t,"write to private field"),s?s.call(e,n):t.set(e,n),n),L=(e,t,n)=>(te(e,t,"access private method"),n);var ne=(e,t,n,s)=>({set _(r){N(e,t,r,n)},get _(){return c(e,t,s)}});var Nt={};Ie(Nt,{live:()=>Rt});module.exports=Ne(Nt);function U(e){let t=e.length;for(let n=e.length-1;n>=0;n--){let s=e.charCodeAt(n);s>127&&s<=2047?t++:s>2047&&s<=65535&&(t+=2),s>=56320&&s<=57343&&n--}return t}var A,T,k,H,V,R,W,F,le,x=class{constructor(t=256){this.size=t;M(this,R);M(this,A);M(this,T,5);M(this,k,!1);M(this,H,new TextEncoder);M(this,V,0);N(this,A,L(this,R,W).call(this,t))}addInt32(t){return L(this,R,F).call(this,4),c(this,A).setInt32(c(this,T),t,c(this,k)),N(this,T,c(this,T)+4),this}addInt16(t){return L(this,R,F).call(this,2),c(this,A).setInt16(c(this,T),t,c(this,k)),N(this,T,c(this,T)+2),this}addCString(t){return t&&this.addString(t),L(this,R,F).call(this,1),c(this,A).setUint8(c(this,T),0),ne(this,T)._++,this}addString(t=""){let n=U(t);return L(this,R,F).call(this,n),c(this,H).encodeInto(t,new Uint8Array(c(this,A).buffer,c(this,T))),N(this,T,c(this,T)+n),this}add(t){return L(this,R,F).call(this,t.byteLength),new Uint8Array(c(this,A).buffer).set(new Uint8Array(t),c(this,T)),N(this,T,c(this,T)+t.byteLength),this}flush(t){let n=L(this,R,le).call(this,t);return N(this,T,5),N(this,A,L(this,R,W).call(this,this.size)),new Uint8Array(n)}};A=new WeakMap,T=new WeakMap,k=new WeakMap,H=new WeakMap,V=new WeakMap,R=new WeakSet,W=function(t){return new DataView(new ArrayBuffer(t))},F=function(t){if(c(this,A).byteLength-c(this,T)<t){let s=c(this,A).buffer,r=s.byteLength+(s.byteLength>>1)+t;N(this,A,L(this,R,W).call(this,r)),new Uint8Array(c(this,A).buffer).set(new Uint8Array(s))}},le=function(t){if(t){c(this,A).setUint8(c(this,V),t);let n=c(this,T)-(c(this,V)+1);c(this,A).setInt32(c(this,V)+1,n,c(this,k))}return c(this,A).buffer.slice(t?0:5,c(this,T))};var g=new x,ve=e=>{g.addInt16(3).addInt16(0);for(let s of Object.keys(e))g.addCString(s).addCString(e[s]);g.addCString("client_encoding").addCString("UTF8");let t=g.addCString("").flush(),n=t.byteLength+4;return new x().addInt32(n).add(t).flush()},Ce=()=>{let e=new DataView(new ArrayBuffer(8));return e.setInt32(0,8,!1),e.setInt32(4,80877103,!1),new Uint8Array(e.buffer)},Le=e=>g.addCString(e).flush(112),De=(e,t)=>(g.addCString(e).addInt32(U(t)).addString(t),g.flush(112)),Oe=e=>g.addString(e).flush(112),Me=e=>g.addCString(e).flush(81),Be=[],Pe=e=>{let t=e.name??"";t.length>63&&(console.error("Warning! Postgres only supports 63 characters for query names."),console.error("You supplied %s (%s)",t,t.length),console.error("This can cause conflicts and silent errors executing queries"));let n=g.addCString(t).addCString(e.text).addInt16(e.types?.length??0);return e.types?.forEach(s=>n.addInt32(s)),g.flush(80)},q=new x;var xe=(e,t)=>{for(let n=0;n<e.length;n++){let s=t?t(e[n],n):e[n];if(s===null)g.addInt16(0),q.addInt32(-1);else if(s instanceof ArrayBuffer||ArrayBuffer.isView(s)){let r=ArrayBuffer.isView(s)?s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength):s;g.addInt16(1),q.addInt32(r.byteLength),q.add(r)}else g.addInt16(0),q.addInt32(U(s)),q.addString(s)}},$e=(e={})=>{let t=e.portal??"",n=e.statement??"",s=e.binary??!1,r=e.values??Be,a=r.length;return g.addCString(t).addCString(n),g.addInt16(a),xe(r,e.valueMapper),g.addInt16(a),g.add(q.flush()),g.addInt16(s?1:0),g.flush(66)},Ue=new Uint8Array([69,0,0,0,9,0,0,0,0,0]),Fe=e=>{if(!e||!e.portal&&!e.rows)return Ue;let t=e.portal??"",n=e.rows??0,s=U(t),r=4+s+1+4,a=new DataView(new ArrayBuffer(1+r));return a.setUint8(0,69),a.setInt32(1,r,!1),new TextEncoder().encodeInto(t,new Uint8Array(a.buffer,5)),a.setUint8(s+5,0),a.setUint32(a.byteLength-4,n,!1),new Uint8Array(a.buffer)},ke=(e,t)=>{let n=new DataView(new ArrayBuffer(16));return n.setInt32(0,16,!1),n.setInt16(4,1234,!1),n.setInt16(6,5678,!1),n.setInt32(8,e,!1),n.setInt32(12,t,!1),new Uint8Array(n.buffer)},re=(e,t)=>{let n=new x;return n.addCString(t),n.flush(e)},Ve=g.addCString("P").flush(68),qe=g.addCString("S").flush(68),Ge=e=>e.name?re(68,`${e.type}${e.name??""}`):e.type==="P"?Ve:qe,je=e=>{let t=`${e.type}${e.name??""}`;return re(67,t)},Qe=e=>g.add(e).flush(100),We=e=>re(102,e),X=e=>new Uint8Array([e,0,0,0,4]),He=X(72),Xe=X(83),ze=X(88),Je=X(99),G={startup:ve,password:Le,requestSsl:Ce,sendSASLInitialResponseMessage:De,sendSCRAMClientFinalMessage:Oe,query:Me,parse:Pe,bind:$e,execute:Fe,describe:Ge,close:je,flush:()=>He,sync:()=>Xe,end:()=>ze,copyData:Qe,copyDone:()=>Je,copyFail:We,cancel:ke};var qt=new ArrayBuffer(0);var Ke=1,Ze=4,Cn=Ke+Ze,Ln=new ArrayBuffer(0);var et=globalThis.JSON.parse,tt=globalThis.JSON.stringify,de=16,pe=17;var fe=20,nt=21,rt=23;var z=25,st=26;var me=114;var it=700,at=701;var ot=1042,ut=1043,ct=1082;var lt=1114,ye=1184;var dt=3802;var pt={string:{to:z,from:[z,ut,ot],serialize:e=>e instanceof Date?e.toISOString():e.toString(),parse:e=>e},number:{to:0,from:[nt,rt,st,it,at],serialize:e=>e.toString(),parse:e=>+e},bigint:{to:fe,from:[fe],serialize:e=>e.toString(),parse:e=>{let t=BigInt(e);return t<Number.MIN_SAFE_INTEGER||t>Number.MAX_SAFE_INTEGER?t:Number(t)}},json:{to:me,from:[me,dt],serialize:e=>typeof e=="string"?e:tt(e,(t,n)=>typeof n=="bigint"?n.toString():n),parse:e=>et(e)},boolean:{to:de,from:[de],serialize:e=>{if(typeof e=="boolean")return e?"t":"f";if(typeof e=="number"){if(e===1)return"t";if(e===0)return"f"}else if(typeof e=="string"){let t=e.trim().toLowerCase();if(["true","t","yes","y","on","1"].includes(t))return"t";if(["false","f","no","n","off","0"].includes(t))return"f"}throw new Error("Invalid input for boolean type")},parse:e=>e==="t"},date:{to:ye,from:[ct,lt,ye],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:pe,from:[pe],serialize:e=>{if(!(e instanceof Uint8Array))throw new Error("Invalid input for bytea type");return"\\x"+Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")},parse:e=>{let t=e.slice(2);return Uint8Array.from({length:t.length/2},(n,s)=>parseInt(t.substring(s*2,(s+1)*2),16))}}},he=ft(pt),Fn=he.parsers,kn=he.serializers;function ft(e){return Object.keys(e).reduce(({parsers:t,serializers:n},s)=>{let{to:r,from:a,serialize:i,parse:b}=e[s];return n[r]=i,n[s]=i,t[s]=b,Array.isArray(a)?a.forEach(y=>{t[y]=b,n[y]=i}):(t[a]=b,n[a]=i),{parsers:t,serializers:n}},{parsers:{},serializers:{}})}function ge(e){let t=e.find(n=>n.name==="parameterDescription");return t?t.dataTypeIDs:[]}async function se(e,t,n,s){if(!n||n.length===0)return t;s=s??e;let r=[];try{await e.execProtocol(G.parse({text:t}),{syncToFs:!1}),r.push(...(await e.execProtocol(G.describe({type:"S"}),{syncToFs:!1})).messages)}finally{r.push(...(await e.execProtocol(G.sync(),{syncToFs:!1})).messages)}let a=ge(r),i=t.replace(/\$([0-9]+)/g,(y,l)=>"%"+l+"$L");return(await s.query(`SELECT format($1, ${n.map((y,l)=>`$${l+2}`).join(", ")}) as query`,[i,...n],{paramTypes:[z,...a]})).rows[0].query}function ie(e){let t,n=!1,s=async()=>{if(!t){n=!1;return}n=!0;let{args:r,resolve:a,reject:i}=t;t=void 0;try{let b=await e(...r);a(b)}catch(b){i(b)}finally{s()}};return async(...r)=>{t&&t.resolve(void 0);let a=new Promise((i,b)=>{t={args:r,resolve:i,reject:b}});return n||s(),a}}var mt=Object.defineProperty,yt=(e,t)=>{for(var n in t)mt(e,n,{get:t[n],enumerable:!0})},Y={};yt(Y,{IN_NODE:()=>K,WASM_PREFIX:()=>gt,getFsBundle:()=>Et,instantiateWasm:()=>_t,pgliteProc:()=>bt,rmdirRecursive:()=>be,startArtifactDownload:()=>ae,toPostgresName:()=>At,uuid:()=>wt});function ht(){let e=process.type;return e==="renderer"||e==="worker"||e==="service-worker"}var K=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string"&&!ht(),gt="/pglite",bt=globalThis&&typeof globalThis.process<"u"?globalThis.process:{exitCode:void 0},j=new Map;async function ae(e){K||j.has(e.toString())||j.set(e.toString(),fetch(e))}var J=new Map;async function _t(e,t,n){if(n||J.has(t.toString())){let s=n||J.get(t.toString());return{instance:await WebAssembly.instantiate(s,e),module:s}}if(K){let s=await(await import("fs/promises")).readFile(t),{module:r,instance:a}=await WebAssembly.instantiate(s,e);return J.set(t.toString(),r),{instance:a,module:r}}else{j.has(t.toString())||ae(t);let s=await j.get(t.toString()),{module:r,instance:a}=await WebAssembly.instantiateStreaming(s.clone(),e);return J.set(t.toString(),r),{instance:a,module:r}}}async function Et(e){return K?(await(await import("fs/promises")).readFile(e)).buffer:(ae(e),(await j.get(e.toString())).clone().arrayBuffer())}var wt=()=>{if(globalThis.crypto?.randomUUID)return globalThis.crypto.randomUUID();let e=new Uint8Array(16);if(globalThis.crypto?.getRandomValues)globalThis.crypto.getRandomValues(e);else for(let n=0;n<e.length;n++)e[n]=Math.floor(Math.random()*256);e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=[];return e.forEach(n=>{t.push(n.toString(16).padStart(2,"0"))}),t.slice(0,4).join("")+"-"+t.slice(4,6).join("")+"-"+t.slice(6,8).join("")+"-"+t.slice(8,10).join("")+"-"+t.slice(10).join("")};function At(e){let t;return e.startsWith('"')&&e.endsWith('"')?t=e.substring(1,e.length-1):t=e.toLowerCase(),t}function be(e,t){try{let n=e.readdir(t).filter(s=>s!=="."&&s!=="..");for(let s of n){let r=t+"/"+s;try{e.readdir(r),be(e,r)}catch{e.unlink(r)}}e.rmdir(t)}catch{try{e.unlink(t)}catch{}}}var Tt=5,St=async(e,t)=>{let n=new Set,s={async query(r,a,i){let b,y,l;if(typeof r!="string"&&(b=r.signal,a=r.params,i=r.callback,y=r.offset,l=r.limit,r=r.query),y===void 0!=(l===void 0))throw new Error("offset and limit must be provided together");let o=y!==void 0&&l!==void 0,S;if(o&&(typeof y!="number"||isNaN(y)||typeof l!="number"||isNaN(l)))throw new Error("offset and limit must be numbers");let _=i?[i]:[],m=Y.uuid().replace(/-/g,""),D=!1,I,B,$=async()=>{await e.transaction(async u=>{let p=a&&a.length>0?await se(e,r,a,u):r;await u.exec(`CREATE OR REPLACE TEMP VIEW live_query_${m}_view AS ${p}`);let E=await _e(u,`live_query_${m}_view`);await Ee(u,E,n),o?(await u.exec(` | ||
| PREPARE live_query_${m}_get(int, int) AS | ||
@@ -3,0 +3,0 @@ SELECT * FROM live_query_${m}_view |
@@ -1,2 +0,2 @@ | ||
| import { R as Results, d as PGliteInterface } from '../pglite-DIqDo27J.cjs'; | ||
| import { R as Results, d as PGliteInterface } from '../pglite-BdeXTuy6.cjs'; | ||
@@ -3,0 +3,0 @@ interface LiveQueryOptions<T = { |
@@ -1,2 +0,2 @@ | ||
| import { R as Results, d as PGliteInterface } from '../pglite-DIqDo27J.js'; | ||
| import { R as Results, d as PGliteInterface } from '../pglite-BdeXTuy6.js'; | ||
@@ -3,0 +3,0 @@ interface LiveQueryOptions<T = { |
@@ -1,2 +0,2 @@ | ||
| import{a as O,b as C}from"../chunk-RYDTTX3G.js";import"../chunk-2BOC2OMW.js";import{a as I}from"../chunk-VVBUWNGP.js";import{j as P}from"../chunk-QY3QWFKW.js";P();var M=5,U=async(E,y)=>{let p=new Set,g={async query(e,$,a){let m,c,_;if(typeof e!="string"&&(m=e.signal,$=e.params,a=e.callback,c=e.offset,_=e.limit,e=e.query),c===void 0!=(_===void 0))throw new Error("offset and limit must be provided together");let t=c!==void 0&&_!==void 0,T;if(t&&(typeof c!="number"||isNaN(c)||typeof _!="number"||isNaN(_)))throw new Error("offset and limit must be numbers");let d=a?[a]:[],o=I.uuid().replace(/-/g,""),A=!1,v,h,S=async()=>{await E.transaction(async i=>{let s=$&&$.length>0?await O(E,e,$,i):e;await i.exec(`CREATE OR REPLACE TEMP VIEW live_query_${o}_view AS ${s}`);let u=await q(i,`live_query_${o}_view`);await F(i,u,p),t?(await i.exec(` | ||
| import{a as O,b as C}from"../chunk-RYDTTX3G.js";import"../chunk-2BOC2OMW.js";import{a as I}from"../chunk-NNS5RQRF.js";import{j as P}from"../chunk-QY3QWFKW.js";P();var M=5,U=async(E,y)=>{let p=new Set,g={async query(e,$,a){let m,c,_;if(typeof e!="string"&&(m=e.signal,$=e.params,a=e.callback,c=e.offset,_=e.limit,e=e.query),c===void 0!=(_===void 0))throw new Error("offset and limit must be provided together");let t=c!==void 0&&_!==void 0,T;if(t&&(typeof c!="number"||isNaN(c)||typeof _!="number"||isNaN(_)))throw new Error("offset and limit must be numbers");let d=a?[a]:[],o=I.uuid().replace(/-/g,""),A=!1,v,h,S=async()=>{await E.transaction(async i=>{let s=$&&$.length>0?await O(E,e,$,i):e;await i.exec(`CREATE OR REPLACE TEMP VIEW live_query_${o}_view AS ${s}`);let u=await q(i,`live_query_${o}_view`);await F(i,u,p),t?(await i.exec(` | ||
| PREPARE live_query_${o}_get(int, int) AS | ||
@@ -3,0 +3,0 @@ SELECT * FROM live_query_${o}_view |
@@ -8,3 +8,3 @@ "use strict";var Ke=Object.create;var se=Object.defineProperty;var Je=Object.getOwnPropertyDescriptor;var Xe=Object.getOwnPropertyNames;var Ze=Object.getPrototypeOf,et=Object.prototype.hasOwnProperty;var Ie=e=>{throw TypeError(e)};var tt=(e,r)=>{for(var t in r)se(e,t,{get:r[t],enumerable:!0})},Le=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of Xe(r))!et.call(e,a)&&a!==t&&se(e,a,{get:()=>r[a],enumerable:!(n=Je(r,a))||n.enumerable});return e};var Ce=(e,r,t)=>(t=e!=null?Ke(Ze(e)):{},Le(r||!e||!e.__esModule?se(t,"default",{value:e,enumerable:!0}):t,e)),rt=e=>Le(se({},"__esModule",{value:!0}),e);var ge=(e,r,t)=>r.has(e)||Ie("Cannot "+t);var i=(e,r,t)=>(ge(e,r,"read from private field"),t?t.call(e):r.get(e)),d=(e,r,t)=>r.has(e)?Ie("Cannot add the same private member more than once"):r instanceof WeakSet?r.add(e):r.set(e,t),y=(e,r,t,n)=>(ge(e,r,"write to private field"),n?n.call(e,t):r.set(e,t),t),c=(e,r,t)=>(ge(e,r,"access private method"),t);var be=(e,r,t,n)=>({set _(a){y(e,r,a,t)},get _(){return i(e,r,n)}});var ir={};tt(ir,{LeaderChangedError:()=>he,PGliteWorker:()=>De,worker:()=>nr});module.exports=rt(ir);var nt=()=>typeof document>"u"?new URL(`file:${__filename}`).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href,T=nt();var Oe={part:"part",container:"container"};function ae(e,r,...t){let n=e.length-1,a=t.length-1;if(a!==-1){if(a===0){e[n]=e[n]+t[0]+r;return}e[n]=e[n]+t[0],e.push(...t.slice(1,a)),e.push(t[a]+r)}}function st(e,...r){let t=[e[0]];t.raw=[e.raw[0]];let n=[];for(let a=0;a<r.length;a++){let s=r[a],o=a+1;if(s?._templateType===Oe.part){ae(t,e[o],s.str),ae(t.raw,e.raw[o],s.str);continue}if(s?._templateType===Oe.container){ae(t,e[o],...s.strings),ae(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 we(e,...r){let{strings:t,values:n}=st(e,...r);return{query:[t[0],...n.flatMap((a,s)=>[`$${s+1}`,t[s+1]])].join(""),params:n}}var at=globalThis.JSON.parse,it=globalThis.JSON.stringify,ve=16,Ue=17;var Ne=20,ot=21,ct=23;var _e=25,lt=26;var We=114;var ut=700,pt=701;var dt=1042,yt=1043,mt=1082;var ht=1114,Ge=1184;var ft=3802;var gt={string:{to:_e,from:[_e,yt,dt],serialize:e=>e instanceof Date?e.toISOString():e.toString(),parse:e=>e},number:{to:0,from:[ot,ct,lt,ut,pt],serialize:e=>e.toString(),parse:e=>+e},bigint:{to:Ne,from:[Ne],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:We,from:[We,ft],serialize:e=>typeof e=="string"?e:it(e,(r,t)=>typeof t=="bigint"?t.toString():t),parse:e=>at(e)},boolean:{to:ve,from:[ve],serialize:e=>{if(typeof e=="boolean")return e?"t":"f";if(typeof e=="number"){if(e===1)return"t";if(e===0)return"f"}else if(typeof e=="string"){let r=e.trim().toLowerCase();if(["true","t","yes","y","on","1"].includes(r))return"t";if(["false","f","no","n","off","0"].includes(r))return"f"}throw new Error("Invalid input for boolean type")},parse:e=>e==="t"},date:{to:Ge,from:[mt,ht,Ge],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:Ue,from:[Ue],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))}}},xe=bt(gt),Fe=xe.parsers,Ve=xe.serializers;function Te(e,r,t){if(e===null)return null;let n=t?.[r]??xe.parsers[r];return n?n(e,r):e}function bt(e){return Object.keys(e).reduce(({parsers:r,serializers:t},n)=>{let{to:a,from:s,serialize:o,parse:u}=e[n];return t[a]=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 wt=/\\/g,Pt=/"/g;function xt(e){return e.replace(wt,"\\\\").replace(Pt,'\\"')}function Ae(e,r,t){if(Array.isArray(e)===!1)return e;if(!e.length)return"{}";let n=e[0],a=t===1020?";":",";return Array.isArray(n)?`{${e.map(s=>Ae(s,r,t)).join(a)}}`:`{${e.map(s=>(s===void 0&&(s=null),s===null?"null":'"'+xt(r?r(s):s.toString())+'"')).join(a)}}`}var Pe={i:0,char:null,str:"",quoted:!1,last:0,p:null};function Qe(e,r,t){return Pe.i=Pe.last=0,qe(Pe,e,r,t)[0]}function qe(e,r,t,n){let a=[],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==='"'?(a.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,a.push(qe(e,r,t,n));else if(e.char==="}"){if(e.last<e.i){let o=r.slice(e.last,e.i);o==="NULL"&&!e.quoted?a.push(null):a.push(t?t(o):o)}e.quoted=!1,e.last=e.i+1;break}else if(e.char===s&&e.p!=="}"&&e.p!=='"'){let o=r.slice(e.last,e.i);o==="NULL"&&!e.quoted?a.push(null):a.push(t?t(o):o),e.last=e.i+1}e.p=e.char}return e.last<e.i&&a.push(t?t(r.slice(e.last,e.i+1)):r.slice(e.last,e.i+1)),a}function Ee(e,r,t,n){let a=[],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(p=>({name:p.name,dataTypeID:p.dataTypeID}));break}case"dataRow":{if(!s)break;let m=l;t?.rowMode==="array"?s.rows.push(m.fields.map((p,b)=>Te(p,s.fields[b].dataTypeID,u))):s.rows.push(Object.fromEntries(m.fields.map((p,b)=>[s.fields[b].name,Te(p,s.fields[b].dataTypeID,u)])));break}case"commandComplete":{let p=l.text.split(" "),b=p[0],w=parseInt(p[p.length-1],10);switch(b){case"INSERT":case"UPDATE":case"DELETE":case"COPY":case"MERGE":o+=w;break}let W={...s,command:b,affectedRows:o};Number.isNaN(w)||(W.rowCount=w),n&&(W.blob=n),a.push(W),s={rows:[],fields:[]};break}}}),a.length===0&&a.push({affectedRows:0,rows:[],fields:[]}),a}function ze(e){let r=e.find(t=>t.name==="parameterDescription");return r?r.dataTypeIDs:[]}function G(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 P,x,V,oe,Q,E,ie,F,je,L=class{constructor(r=256){this.size=r;d(this,E);d(this,P);d(this,x,5);d(this,V,!1);d(this,oe,new TextEncoder);d(this,Q,0);y(this,P,c(this,E,ie).call(this,r))}addInt32(r){return c(this,E,F).call(this,4),i(this,P).setInt32(i(this,x),r,i(this,V)),y(this,x,i(this,x)+4),this}addInt16(r){return c(this,E,F).call(this,2),i(this,P).setInt16(i(this,x),r,i(this,V)),y(this,x,i(this,x)+2),this}addCString(r){return r&&this.addString(r),c(this,E,F).call(this,1),i(this,P).setUint8(i(this,x),0),be(this,x)._++,this}addString(r=""){let t=G(r);return c(this,E,F).call(this,t),i(this,oe).encodeInto(r,new Uint8Array(i(this,P).buffer,i(this,x))),y(this,x,i(this,x)+t),this}add(r){return c(this,E,F).call(this,r.byteLength),new Uint8Array(i(this,P).buffer).set(new Uint8Array(r),i(this,x)),y(this,x,i(this,x)+r.byteLength),this}flush(r){let t=c(this,E,je).call(this,r);return y(this,x,5),y(this,P,c(this,E,ie).call(this,this.size)),new Uint8Array(t)}};P=new WeakMap,x=new WeakMap,V=new WeakMap,oe=new WeakMap,Q=new WeakMap,E=new WeakSet,ie=function(r){return new DataView(new ArrayBuffer(r))},F=function(r){if(i(this,P).byteLength-i(this,x)<r){let n=i(this,P).buffer,a=n.byteLength+(n.byteLength>>1)+r;y(this,P,c(this,E,ie).call(this,a)),new Uint8Array(i(this,P).buffer).set(new Uint8Array(n))}},je=function(r){if(r){i(this,P).setUint8(i(this,Q),r);let t=i(this,x)-(i(this,Q)+1);i(this,P).setInt32(i(this,Q)+1,t,i(this,V))}return i(this,P).buffer.slice(r?0:5,i(this,x))};var g=new L,Tt=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()},At=()=>{let e=new DataView(new ArrayBuffer(8));return e.setInt32(0,8,!1),e.setInt32(4,80877103,!1),new Uint8Array(e.buffer)},Et=e=>g.addCString(e).flush(112),Rt=(e,r)=>(g.addCString(e).addInt32(G(r)).addString(r),g.flush(112)),St=e=>g.addString(e).flush(112),Bt=e=>g.addCString(e).flush(81),Dt=[],kt=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)},q=new L;var Mt=(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),q.addInt32(-1);else if(n instanceof ArrayBuffer||ArrayBuffer.isView(n)){let a=ArrayBuffer.isView(n)?n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength):n;g.addInt16(1),q.addInt32(a.byteLength),q.add(a)}else g.addInt16(0),q.addInt32(G(n)),q.addString(n)}},It=(e={})=>{let r=e.portal??"",t=e.statement??"",n=e.binary??!1,a=e.values??Dt,s=a.length;return g.addCString(r).addCString(t),g.addInt16(s),Mt(a,e.valueMapper),g.addInt16(s),g.add(q.flush()),g.addInt16(n?1:0),g.flush(66)},Lt=new Uint8Array([69,0,0,0,9,0,0,0,0,0]),Ct=e=>{if(!e||!e.portal&&!e.rows)return Lt;let r=e.portal??"",t=e.rows??0,n=G(r),a=4+n+1+4,s=new DataView(new ArrayBuffer(1+a));return s.setUint8(0,69),s.setInt32(1,a,!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)},Ot=(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)},Re=(e,r)=>{let t=new L;return t.addCString(r),t.flush(e)},vt=g.addCString("P").flush(68),Ut=g.addCString("S").flush(68),Nt=e=>e.name?Re(68,`${e.type}${e.name??""}`):e.type==="P"?vt:Ut,_t=e=>{let r=`${e.type}${e.name??""}`;return Re(67,r)},Wt=e=>g.add(e).flush(100),Gt=e=>Re(102,e),ce=e=>new Uint8Array([e,0,0,0,4]),Ft=ce(72),Vt=ce(83),Qt=ce(88),qt=ce(99),R={startup:Tt,password:Et,requestSsl:At,sendSASLInitialResponseMessage:Rt,sendSCRAMClientFinalMessage:St,query:Bt,parse:kt,bind:It,execute:Ct,describe:Nt,close:_t,flush:()=>Ft,sync:()=>Vt,end:()=>Qt,copyData:Wt,copyDone:()=>qt,copyFail:Gt,cancel:Ot};var C=class extends Error{constructor(t,n,a){super(t);this.length=n;this.name=a}};var kr=new ArrayBuffer(0);var jt=1,$t=4,hn=jt+$t,fn=new ArrayBuffer(0);function le(e){let r=e.e;return r.query=e.query,r.params=e.params,r.queryOptions=e.options,r}var $,I,h,S,ue,O,Se,pe=class{constructor(){d(this,h);this.serializers={...Ve};this.parsers={...Fe};d(this,$,!1);d(this,I,!1)}async _initArrayTypes({force:r=!1}={}){if(i(this,$)&&!r)return;y(this,$,!0);let t=await this.query(` | ||
| ORDER BY b.oid | ||
| `);for(let n of t.rows)this.serializers[n.typarray]=a=>Ae(a,this.serializers[n.oid],n.typarray),this.parsers[n.typarray]=a=>Qe(a,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,h,ue).call(this,r,t,n))}async sql(r,...t){let{query:n,params:a}=we(r,...t);return await this.query(n,a)}async exec(r,t){return await this._checkReady(),await this._runExclusiveTransaction(async()=>await c(this,h,O).call(this,r,t))}async describeQuery(r,t){let n=[];try{await c(this,h,S).call(this,R.parse({text:r,types:t?.paramTypes}),t),n=await c(this,h,S).call(this,R.describe({type:"S"}),t)}catch(l){throw l instanceof C?le({e:l,options:t,params:void 0,query:r}):l}finally{n.push(...await c(this,h,S).call(this,R.sync(),t))}let a=n.find(l=>l.name==="parameterDescription"),s=n.find(l=>l.name==="rowDescription"),o=a?.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,h,O).call(this,"BEGIN"),y(this,I,!0);let t=!1,n=()=>{if(t)throw new Error("Transaction is closed")},a={query:async(s,o,u)=>(n(),await c(this,h,ue).call(this,s,o,u)),sql:async(s,...o)=>{n();let{query:u,params:l}=we(s,...o);return await c(this,h,ue).call(this,u,l)},exec:async(s,o)=>(n(),await c(this,h,O).call(this,s,o)),rollback:async()=>{n(),await c(this,h,O).call(this,"ROLLBACK"),t=!0},listen:async(s,o)=>(n(),await this.listen(s,o,a)),get closed(){return t}};try{let s=await r(a);return t||(t=!0,await c(this,h,O).call(this,"COMMIT")),y(this,I,!1),s}catch(s){throw t||(t=!0,await c(this,h,O).call(this,"ROLLBACK")),y(this,I,!1),s}})}async runExclusive(r){return await this._runExclusiveQuery(r)}};$=new WeakMap,I=new WeakMap,h=new WeakSet,S=async function(r,t={}){return await this.execProtocolStream(r,{...t,syncToFs:!1})},ue=async function(r,t=[],n){return await this._runExclusiveQuery(async()=>{c(this,h,Se).call(this,"runQuery",r,t,n),await this._handleBlob(n?.blob);let a=[];try{let o=await c(this,h,S).call(this,R.parse({text:r,types:n?.paramTypes}),n),u=ze(await c(this,h,S).call(this,R.describe({type:"S"}),n)),l=t.map((m,p)=>{let b=u[p];if(m==null)return null;let w=n?.serializers?.[b]??this.serializers[b];return w?w(m):m.toString()});a=[...o,...await c(this,h,S).call(this,R.bind({values:l}),n),...await c(this,h,S).call(this,R.describe({type:"P"}),n),...await c(this,h,S).call(this,R.execute({}),n)]}catch(o){throw o instanceof C?le({e:o,options:n,params:t,query:r}):o}finally{a.push(...await c(this,h,S).call(this,R.sync(),n))}await this._cleanupBlob(),i(this,I)||await this.syncToFs();let s=await this._getWrittenBlob();return Ee(a,this.parsers,n,s)[0]})},O=async function(r,t){return await this._runExclusiveQuery(async()=>{c(this,h,Se).call(this,"runExec",r,t),await this._handleBlob(t?.blob);let n=[];try{n=await c(this,h,S).call(this,R.query(r),t)}catch(s){throw s instanceof C?le({e:s,options:t,params:void 0,query:r}):s}finally{n.push(...await c(this,h,S).call(this,R.sync(),t))}this._cleanupBlob(),i(this,I)||await this.syncToFs();let a=await this._getWrittenBlob();return Ee(n,this.parsers,t,a)})},Se=function(...r){this.debug>0&&console.log(...r)};var Ht=Object.defineProperty,Yt=(e,r)=>{for(var t in r)Ht(e,t,{get:r[t],enumerable:!0})},Y={};Yt(Y,{IN_NODE:()=>ye,WASM_PREFIX:()=>Jt,getFsBundle:()=>er,instantiateWasm:()=>Zt,pgliteProc:()=>Xt,rmdirRecursive:()=>$e,startArtifactDownload:()=>Be,toPostgresName:()=>rr,uuid:()=>tr});function Kt(){let e=process.type;return e==="renderer"||e==="worker"||e==="service-worker"}var ye=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string"&&!Kt(),Jt="/pglite",H=new Map;async function Be(e){ye||H.has(e.toString())||H.set(e.toString(),fetch(e))}var de=new Map,Xt=globalThis&&typeof globalThis.process<"u"?globalThis.process:{exitCode:void 0};async function Zt(e,r,t){if(t||de.has(r.toString())){let n=t||de.get(r.toString());return{instance:await WebAssembly.instantiate(n,e),module:n}}if(ye){let n=await(await import("fs/promises")).readFile(r),{module:a,instance:s}=await WebAssembly.instantiate(n,e);return de.set(r.toString(),a),{instance:s,module:a}}else{H.has(r.toString())||Be(r);let n=await H.get(r.toString()),{module:a,instance:s}=await WebAssembly.instantiateStreaming(n.clone(),e);return de.set(r.toString(),a),{instance:s,module:a}}}async function er(e){return ye?(await(await import("fs/promises")).readFile(e)).buffer:(Be(e),(await H.get(e.toString())).clone().arrayBuffer())}var tr=()=>{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 rr(e){let r;return e.startsWith('"')&&e.endsWith('"')?r=e.substring(1,e.length-1):r=e.toLowerCase(),r}function $e(e,r){try{let t=e.readdir(r).filter(n=>n!=="."&&n!=="..");for(let n of t){let a=r+"/"+n;try{e.readdir(a),$e(e,a)}catch{e.unlink(a)}}e.rmdir(r)}catch{try{e.unlink(r)}catch{}}}var z,K,J,j,X,B,v,U,D,Z,ee,te,N,M,re,k,_,ne,fe,f,He,me,A,Ye,Me=class Me extends pe{constructor(t,n){super();d(this,f);d(this,z);d(this,K,0);d(this,J,!1);d(this,j,!1);d(this,X,!1);d(this,B,new EventTarget);d(this,v);d(this,U,!1);d(this,D);d(this,Z);d(this,ee);d(this,te);d(this,N);d(this,M);d(this,re);d(this,k,new Map);d(this,_,new Set);d(this,ne);d(this,fe,[]);y(this,D,t),y(this,v,Y.uuid()),y(this,ne,n?.extensions??{}),y(this,ee,new Promise(a=>{i(this,D).addEventListener("message",s=>{if(s.data.type==="here")a();else throw new Error("Invalid message")},{once:!0})})),y(this,te,new Promise(a=>{let s=o=>{o.data.type==="ready"&&(y(this,Z,o.data.id),i(this,D).removeEventListener("message",s),a())};i(this,D).addEventListener("message",s)})),y(this,z,c(this,f,He).call(this,n))}static async create(t,n){let a=new Me(t,n);return await i(a,z),a}get waitReady(){return new Promise(t=>{i(this,z).then(()=>{i(this,U)?t():t(new Promise(n=>{i(this,B).addEventListener("connected",()=>{n()})}))})})}get debug(){return i(this,K)}get ready(){return i(this,J)}get closed(){return i(this,j)}get isLeader(){return i(this,X)}async close(){var t;i(this,j)||(y(this,j,!0),i(this,N)?.close(),i(this,M)?.close(),(t=i(this,re))==null||t.call(this),i(this,D).terminate())}async[Symbol.asyncDispose](){await this.close()}async execProtocolRaw(t){return await c(this,f,A).call(this,"execProtocolRaw",t)}async execProtocol(t){return await c(this,f,A).call(this,"execProtocol",t)}async execProtocolStream(t){return await c(this,f,A).call(this,"execProtocolStream",t)}async execProtocolRawStream(t,n){await c(this,f,A).call(this,"execProtocolRawStream",t,n)}async syncToFs(){await c(this,f,A).call(this,"syncToFs")}async listen(t,n,a){let s=Y.toPostgresName(t),o=a??this;return i(this,k).has(s)||i(this,k).set(s,new Set),i(this,k).get(s).add(n),await o.exec(`LISTEN ${t}`),async u=>{await this.unlisten(s,n,u)}}async unlisten(t,n,a){await this.waitReady;let s=a??this;n?i(this,k).get(t)?.delete(n):i(this,k).delete(t),i(this,k).get(t)?.size===0&&await s.exec(`UNLISTEN ${t}`)}onNotification(t){return i(this,_).add(t),()=>{i(this,_).delete(t)}}offNotification(t){i(this,_).delete(t)}async dumpDataDir(t){return await c(this,f,A).call(this,"dumpDataDir",t)}onLeaderChange(t){return i(this,B).addEventListener("leader-change",t),()=>{i(this,B).removeEventListener("leader-change",t)}}offLeaderChange(t){i(this,B).removeEventListener("leader-change",t)}async _handleBlob(t){await c(this,f,A).call(this,"_handleBlob",t)}async _getWrittenBlob(){return await c(this,f,A).call(this,"_getWrittenBlob")}async _cleanupBlob(){await c(this,f,A).call(this,"_cleanupBlob")}async _checkReady(){await this.waitReady}async _runExclusiveQuery(t){await c(this,f,A).call(this,"_acquireQueryLock");try{return await t()}finally{await c(this,f,A).call(this,"_releaseQueryLock")}}async _runExclusiveTransaction(t){await c(this,f,A).call(this,"_acquireTransactionLock");try{return await t()}finally{await c(this,f,A).call(this,"_releaseTransactionLock")}}};z=new WeakMap,K=new WeakMap,J=new WeakMap,j=new WeakMap,X=new WeakMap,B=new WeakMap,v=new WeakMap,U=new WeakMap,D=new WeakMap,Z=new WeakMap,ee=new WeakMap,te=new WeakMap,N=new WeakMap,M=new WeakMap,re=new WeakMap,k=new WeakMap,_=new WeakMap,ne=new WeakMap,fe=new WeakMap,f=new WeakSet,He=async function(t={}){for(let[l,m]of Object.entries(i(this,ne))){if(m instanceof URL)throw new Error("URL extensions are not supported on the client side of a worker");{let p=await m.setup(this,{},!0);if(p.emscriptenOpts&&console.warn(`PGlite extension ${l} returned emscriptenOpts, these are not supported on the client side of a worker`),p.namespaceObj){let b=this;b[l]=p.namespaceObj}p.bundlePath&&console.warn(`PGlite extension ${l} returned bundlePath, this is not supported on the client side of a worker`),p.init&&await p.init(),p.close&&i(this,fe).push(p.close)}}await i(this,ee);let{extensions:n,...a}=t;i(this,D).postMessage({type:"init",options:a}),await i(this,te);let s=`pglite-tab-close:${i(this,v)}`;y(this,re,await ke(s));let o=`pglite-broadcast:${i(this,Z)}`;y(this,N,new BroadcastChannel(o));let u=`pglite-tab:${i(this,v)}`;y(this,M,new BroadcastChannel(u)),i(this,N).addEventListener("message",async l=>{l.data.type==="leader-here"?(y(this,U,!1),i(this,B).dispatchEvent(new Event("leader-change")),c(this,f,me).call(this)):l.data.type==="notify"&&c(this,f,Ye).call(this,l.data.channel,l.data.payload)}),i(this,M).addEventListener("message",async l=>{l.data.type==="connected"&&(y(this,U,!0),i(this,B).dispatchEvent(new Event("connected")),y(this,K,await c(this,f,A).call(this,"getDebugLevel")),y(this,J,!0))}),i(this,D).addEventListener("message",async l=>{l.data.type==="leader-now"&&(y(this,X,!0),i(this,B).dispatchEvent(new Event("leader-change")))}),c(this,f,me).call(this),this._initArrayTypes()},me=async function(){i(this,U)||(i(this,N).postMessage({type:"tab-here",id:i(this,v)}),setTimeout(()=>c(this,f,me).call(this),16))},A=async function(t,...n){let a=Y.uuid(),s={type:"rpc-call",callId:a,method:t,args:n};return i(this,M).postMessage(s),await new Promise((o,u)=>{let l=b=>{if(b.data.callId!==a)return;p();let w=b.data;if(w.type==="rpc-return")o(w.result);else if(w.type==="rpc-error"){let W=new Error(w.error.message);Object.assign(W,w.error),u(W)}else u(new Error("Invalid message"))},m=()=>{p(),u(new he)},p=()=>{i(this,M).removeEventListener("message",l),i(this,B).removeEventListener("leader-change",m)};i(this,B).addEventListener("leader-change",m),i(this,M).addEventListener("message",l)})},Ye=function(t,n){let a=i(this,k).get(t);if(a)for(let s of a)queueMicrotask(()=>s(n));for(let s of i(this,_))queueMicrotask(()=>s(t,n))};var De=Me;async function nr({init:e}){postMessage({type:"here"});let r=await new Promise(m=>{addEventListener("message",p=>{p.data.type==="init"&&m(p.data.options)},{once:!0})}),t=r.id??`${T}:${r.dataDir??""}`;postMessage({type:"ready",id:t});let n=`pglite-election-lock:${t}`,a=`pglite-broadcast:${t}`,s=new BroadcastChannel(a),o=new Set;await ke(n);let u=e(r);s.onmessage=async m=>{let p=m.data;switch(p.type){case"tab-here":sr(p.id,await u,o);break}},s.postMessage({type:"leader-here",id:t}),postMessage({type:"leader-now"}),(await u).onNotification((m,p)=>{s.postMessage({type:"notify",channel:m,payload:p})})}function sr(e,r,t){if(t.has(e))return;t.add(e);let n=`pglite-tab:${e}`,a=`pglite-tab-close:${e}`,s=new BroadcastChannel(n);navigator.locks.request(a,()=>new Promise(u=>{s.close(),t.delete(e),u()}));let o=ar(e,r);s.addEventListener("message",async u=>{let l=u.data;switch(l.type){case"rpc-call":{await r.waitReady;let{callId:m,method:p,args:b}=l;try{let w=await o[p](...b);s.postMessage({type:"rpc-return",callId:m,result:w})}catch(w){console.error(w),s.postMessage({type:"rpc-error",callId:m,error:{message:w.message}})}break}}}),s.postMessage({type:"connected"})}function ar(e,r){let t=null,n=null,a=`pglite-tab-close:${e}`;return ke(a).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 he=class extends Error{constructor(){super("Leader changed, pending operation in indeterminate state")}};async function ke(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}); | ||
| `);for(let n of t.rows)this.serializers[n.typarray]=a=>Ae(a,this.serializers[n.oid],n.typarray),this.parsers[n.typarray]=a=>Qe(a,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,h,ue).call(this,r,t,n))}async sql(r,...t){let{query:n,params:a}=we(r,...t);return await this.query(n,a)}async exec(r,t){return await this._checkReady(),await this._runExclusiveTransaction(async()=>await c(this,h,O).call(this,r,t))}async describeQuery(r,t){let n=[];try{await c(this,h,S).call(this,R.parse({text:r,types:t?.paramTypes}),t),n=await c(this,h,S).call(this,R.describe({type:"S"}),t)}catch(l){throw l instanceof C?le({e:l,options:t,params:void 0,query:r}):l}finally{n.push(...await c(this,h,S).call(this,R.sync(),t))}let a=n.find(l=>l.name==="parameterDescription"),s=n.find(l=>l.name==="rowDescription"),o=a?.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,h,O).call(this,"BEGIN"),y(this,I,!0);let t=!1,n=()=>{if(t)throw new Error("Transaction is closed")},a={query:async(s,o,u)=>(n(),await c(this,h,ue).call(this,s,o,u)),sql:async(s,...o)=>{n();let{query:u,params:l}=we(s,...o);return await c(this,h,ue).call(this,u,l)},exec:async(s,o)=>(n(),await c(this,h,O).call(this,s,o)),rollback:async()=>{n(),await c(this,h,O).call(this,"ROLLBACK"),t=!0},listen:async(s,o)=>(n(),await this.listen(s,o,a)),get closed(){return t}};try{let s=await r(a);return t||(t=!0,await c(this,h,O).call(this,"COMMIT")),y(this,I,!1),s}catch(s){throw t||(t=!0,await c(this,h,O).call(this,"ROLLBACK")),y(this,I,!1),s}})}async runExclusive(r){return await this._runExclusiveQuery(r)}};$=new WeakMap,I=new WeakMap,h=new WeakSet,S=async function(r,t={}){return await this.execProtocolStream(r,{...t,syncToFs:!1})},ue=async function(r,t=[],n){return await this._runExclusiveQuery(async()=>{c(this,h,Se).call(this,"runQuery",r,t,n),await this._handleBlob(n?.blob);let a=[];try{let o=await c(this,h,S).call(this,R.parse({text:r,types:n?.paramTypes}),n),u=ze(await c(this,h,S).call(this,R.describe({type:"S"}),n)),l=t.map((m,p)=>{let b=u[p];if(m==null)return null;let w=n?.serializers?.[b]??this.serializers[b];return w?w(m):m.toString()});a=[...o,...await c(this,h,S).call(this,R.bind({values:l}),n),...await c(this,h,S).call(this,R.describe({type:"P"}),n),...await c(this,h,S).call(this,R.execute({}),n)]}catch(o){throw o instanceof C?le({e:o,options:n,params:t,query:r}):o}finally{a.push(...await c(this,h,S).call(this,R.sync(),n))}await this._cleanupBlob(),i(this,I)||await this.syncToFs();let s=await this._getWrittenBlob();return Ee(a,this.parsers,n,s)[0]})},O=async function(r,t){return await this._runExclusiveQuery(async()=>{c(this,h,Se).call(this,"runExec",r,t),await this._handleBlob(t?.blob);let n=[];try{n=await c(this,h,S).call(this,R.query(r),t)}catch(s){throw s instanceof C?le({e:s,options:t,params:void 0,query:r}):s}finally{n.push(...await c(this,h,S).call(this,R.sync(),t))}this._cleanupBlob(),i(this,I)||await this.syncToFs();let a=await this._getWrittenBlob();return Ee(n,this.parsers,t,a)})},Se=function(...r){this.debug>0&&console.log(...r)};var Ht=Object.defineProperty,Yt=(e,r)=>{for(var t in r)Ht(e,t,{get:r[t],enumerable:!0})},Y={};Yt(Y,{IN_NODE:()=>ye,WASM_PREFIX:()=>Jt,getFsBundle:()=>er,instantiateWasm:()=>Zt,pgliteProc:()=>Xt,rmdirRecursive:()=>$e,startArtifactDownload:()=>Be,toPostgresName:()=>rr,uuid:()=>tr});function Kt(){let e=process.type;return e==="renderer"||e==="worker"||e==="service-worker"}var ye=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string"&&!Kt(),Jt="/pglite",Xt=globalThis&&typeof globalThis.process<"u"?globalThis.process:{exitCode:void 0},H=new Map;async function Be(e){ye||H.has(e.toString())||H.set(e.toString(),fetch(e))}var de=new Map;async function Zt(e,r,t){if(t||de.has(r.toString())){let n=t||de.get(r.toString());return{instance:await WebAssembly.instantiate(n,e),module:n}}if(ye){let n=await(await import("fs/promises")).readFile(r),{module:a,instance:s}=await WebAssembly.instantiate(n,e);return de.set(r.toString(),a),{instance:s,module:a}}else{H.has(r.toString())||Be(r);let n=await H.get(r.toString()),{module:a,instance:s}=await WebAssembly.instantiateStreaming(n.clone(),e);return de.set(r.toString(),a),{instance:s,module:a}}}async function er(e){return ye?(await(await import("fs/promises")).readFile(e)).buffer:(Be(e),(await H.get(e.toString())).clone().arrayBuffer())}var tr=()=>{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 rr(e){let r;return e.startsWith('"')&&e.endsWith('"')?r=e.substring(1,e.length-1):r=e.toLowerCase(),r}function $e(e,r){try{let t=e.readdir(r).filter(n=>n!=="."&&n!=="..");for(let n of t){let a=r+"/"+n;try{e.readdir(a),$e(e,a)}catch{e.unlink(a)}}e.rmdir(r)}catch{try{e.unlink(r)}catch{}}}var z,K,J,j,X,B,v,U,D,Z,ee,te,N,M,re,k,_,ne,fe,f,He,me,A,Ye,Me=class Me extends pe{constructor(t,n){super();d(this,f);d(this,z);d(this,K,0);d(this,J,!1);d(this,j,!1);d(this,X,!1);d(this,B,new EventTarget);d(this,v);d(this,U,!1);d(this,D);d(this,Z);d(this,ee);d(this,te);d(this,N);d(this,M);d(this,re);d(this,k,new Map);d(this,_,new Set);d(this,ne);d(this,fe,[]);y(this,D,t),y(this,v,Y.uuid()),y(this,ne,n?.extensions??{}),y(this,ee,new Promise(a=>{i(this,D).addEventListener("message",s=>{if(s.data.type==="here")a();else throw new Error("Invalid message")},{once:!0})})),y(this,te,new Promise(a=>{let s=o=>{o.data.type==="ready"&&(y(this,Z,o.data.id),i(this,D).removeEventListener("message",s),a())};i(this,D).addEventListener("message",s)})),y(this,z,c(this,f,He).call(this,n))}static async create(t,n){let a=new Me(t,n);return await i(a,z),a}get waitReady(){return new Promise(t=>{i(this,z).then(()=>{i(this,U)?t():t(new Promise(n=>{i(this,B).addEventListener("connected",()=>{n()})}))})})}get debug(){return i(this,K)}get ready(){return i(this,J)}get closed(){return i(this,j)}get isLeader(){return i(this,X)}async close(){var t;i(this,j)||(y(this,j,!0),i(this,N)?.close(),i(this,M)?.close(),(t=i(this,re))==null||t.call(this),i(this,D).terminate())}async[Symbol.asyncDispose](){await this.close()}async execProtocolRaw(t){return await c(this,f,A).call(this,"execProtocolRaw",t)}async execProtocol(t){return await c(this,f,A).call(this,"execProtocol",t)}async execProtocolStream(t){return await c(this,f,A).call(this,"execProtocolStream",t)}async execProtocolRawStream(t,n){await c(this,f,A).call(this,"execProtocolRawStream",t,n)}async syncToFs(){await c(this,f,A).call(this,"syncToFs")}async listen(t,n,a){let s=Y.toPostgresName(t),o=a??this;return i(this,k).has(s)||i(this,k).set(s,new Set),i(this,k).get(s).add(n),await o.exec(`LISTEN ${t}`),async u=>{await this.unlisten(s,n,u)}}async unlisten(t,n,a){await this.waitReady;let s=a??this;n?i(this,k).get(t)?.delete(n):i(this,k).delete(t),i(this,k).get(t)?.size===0&&await s.exec(`UNLISTEN ${t}`)}onNotification(t){return i(this,_).add(t),()=>{i(this,_).delete(t)}}offNotification(t){i(this,_).delete(t)}async dumpDataDir(t){return await c(this,f,A).call(this,"dumpDataDir",t)}onLeaderChange(t){return i(this,B).addEventListener("leader-change",t),()=>{i(this,B).removeEventListener("leader-change",t)}}offLeaderChange(t){i(this,B).removeEventListener("leader-change",t)}async _handleBlob(t){await c(this,f,A).call(this,"_handleBlob",t)}async _getWrittenBlob(){return await c(this,f,A).call(this,"_getWrittenBlob")}async _cleanupBlob(){await c(this,f,A).call(this,"_cleanupBlob")}async _checkReady(){await this.waitReady}async _runExclusiveQuery(t){await c(this,f,A).call(this,"_acquireQueryLock");try{return await t()}finally{await c(this,f,A).call(this,"_releaseQueryLock")}}async _runExclusiveTransaction(t){await c(this,f,A).call(this,"_acquireTransactionLock");try{return await t()}finally{await c(this,f,A).call(this,"_releaseTransactionLock")}}};z=new WeakMap,K=new WeakMap,J=new WeakMap,j=new WeakMap,X=new WeakMap,B=new WeakMap,v=new WeakMap,U=new WeakMap,D=new WeakMap,Z=new WeakMap,ee=new WeakMap,te=new WeakMap,N=new WeakMap,M=new WeakMap,re=new WeakMap,k=new WeakMap,_=new WeakMap,ne=new WeakMap,fe=new WeakMap,f=new WeakSet,He=async function(t={}){for(let[l,m]of Object.entries(i(this,ne))){if(m instanceof URL)throw new Error("URL extensions are not supported on the client side of a worker");{let p=await m.setup(this,{},!0);if(p.emscriptenOpts&&console.warn(`PGlite extension ${l} returned emscriptenOpts, these are not supported on the client side of a worker`),p.namespaceObj){let b=this;b[l]=p.namespaceObj}p.bundlePath&&console.warn(`PGlite extension ${l} returned bundlePath, this is not supported on the client side of a worker`),p.init&&await p.init(),p.close&&i(this,fe).push(p.close)}}await i(this,ee);let{extensions:n,...a}=t;i(this,D).postMessage({type:"init",options:a}),await i(this,te);let s=`pglite-tab-close:${i(this,v)}`;y(this,re,await ke(s));let o=`pglite-broadcast:${i(this,Z)}`;y(this,N,new BroadcastChannel(o));let u=`pglite-tab:${i(this,v)}`;y(this,M,new BroadcastChannel(u)),i(this,N).addEventListener("message",async l=>{l.data.type==="leader-here"?(y(this,U,!1),i(this,B).dispatchEvent(new Event("leader-change")),c(this,f,me).call(this)):l.data.type==="notify"&&c(this,f,Ye).call(this,l.data.channel,l.data.payload)}),i(this,M).addEventListener("message",async l=>{l.data.type==="connected"&&(y(this,U,!0),i(this,B).dispatchEvent(new Event("connected")),y(this,K,await c(this,f,A).call(this,"getDebugLevel")),y(this,J,!0))}),i(this,D).addEventListener("message",async l=>{l.data.type==="leader-now"&&(y(this,X,!0),i(this,B).dispatchEvent(new Event("leader-change")))}),c(this,f,me).call(this),this._initArrayTypes()},me=async function(){i(this,U)||(i(this,N).postMessage({type:"tab-here",id:i(this,v)}),setTimeout(()=>c(this,f,me).call(this),16))},A=async function(t,...n){let a=Y.uuid(),s={type:"rpc-call",callId:a,method:t,args:n};return i(this,M).postMessage(s),await new Promise((o,u)=>{let l=b=>{if(b.data.callId!==a)return;p();let w=b.data;if(w.type==="rpc-return")o(w.result);else if(w.type==="rpc-error"){let W=new Error(w.error.message);Object.assign(W,w.error),u(W)}else u(new Error("Invalid message"))},m=()=>{p(),u(new he)},p=()=>{i(this,M).removeEventListener("message",l),i(this,B).removeEventListener("leader-change",m)};i(this,B).addEventListener("leader-change",m),i(this,M).addEventListener("message",l)})},Ye=function(t,n){let a=i(this,k).get(t);if(a)for(let s of a)queueMicrotask(()=>s(n));for(let s of i(this,_))queueMicrotask(()=>s(t,n))};var De=Me;async function nr({init:e}){postMessage({type:"here"});let r=await new Promise(m=>{addEventListener("message",p=>{p.data.type==="init"&&m(p.data.options)},{once:!0})}),t=r.id??`${T}:${r.dataDir??""}`;postMessage({type:"ready",id:t});let n=`pglite-election-lock:${t}`,a=`pglite-broadcast:${t}`,s=new BroadcastChannel(a),o=new Set;await ke(n);let u=e(r);s.onmessage=async m=>{let p=m.data;switch(p.type){case"tab-here":sr(p.id,await u,o);break}},s.postMessage({type:"leader-here",id:t}),postMessage({type:"leader-now"}),(await u).onNotification((m,p)=>{s.postMessage({type:"notify",channel:m,payload:p})})}function sr(e,r,t){if(t.has(e))return;t.add(e);let n=`pglite-tab:${e}`,a=`pglite-tab-close:${e}`,s=new BroadcastChannel(n);navigator.locks.request(a,()=>new Promise(u=>{s.close(),t.delete(e),u()}));let o=ar(e,r);s.addEventListener("message",async u=>{let l=u.data;switch(l.type){case"rpc-call":{await r.waitReady;let{callId:m,method:p,args:b}=l;try{let w=await o[p](...b);s.postMessage({type:"rpc-return",callId:m,result:w})}catch(w){console.error(w),s.postMessage({type:"rpc-error",callId:m,error:{message:w.message}})}break}}}),s.postMessage({type:"connected"})}function ar(e,r){let t=null,n=null,a=`pglite-tab-close:${e}`;return ke(a).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 he=class extends Error{constructor(){super("Leader changed, pending operation in indeterminate state")}};async function ke(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}); | ||
| //# sourceMappingURL=index.cjs.map |
@@ -1,2 +0,2 @@ | ||
| import { n as Extensions, r as PGliteOptions, y as BasePGlite, d as PGliteInterface, s as PGliteInterfaceExtensions, D as DebugLevel, o as ExecProtocolResult, B as BackendMessage, T as Transaction, z as DumpTarCompressionOptions, b as PGlite } from '../pglite-DIqDo27J.cjs'; | ||
| import { n as Extensions, r as PGliteOptions, y as BasePGlite, d as PGliteInterface, s as PGliteInterfaceExtensions, D as DebugLevel, o as ExecProtocolResult, B as BackendMessage, T as Transaction, z as DumpTarCompressionOptions, b as PGlite } from '../pglite-BdeXTuy6.cjs'; | ||
@@ -3,0 +3,0 @@ type PGliteWorkerOptions<E extends Extensions = Extensions> = PGliteOptions<E> & { |
@@ -1,2 +0,2 @@ | ||
| import { n as Extensions, r as PGliteOptions, y as BasePGlite, d as PGliteInterface, s as PGliteInterfaceExtensions, D as DebugLevel, o as ExecProtocolResult, B as BackendMessage, T as Transaction, z as DumpTarCompressionOptions, b as PGlite } from '../pglite-DIqDo27J.js'; | ||
| import { n as Extensions, r as PGliteOptions, y as BasePGlite, d as PGliteInterface, s as PGliteInterfaceExtensions, D as DebugLevel, o as ExecProtocolResult, B as BackendMessage, T as Transaction, z as DumpTarCompressionOptions, b as PGlite } from '../pglite-BdeXTuy6.js'; | ||
@@ -3,0 +3,0 @@ type PGliteWorkerOptions<E extends Extensions = Extensions> = PGliteOptions<E> & { |
@@ -1,2 +0,2 @@ | ||
| import{a as j}from"../chunk-JDT7TZ73.js";import"../chunk-2BOC2OMW.js";import{a as I}from"../chunk-VVBUWNGP.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,R,v,G,k,E,D,S,i,H,U,g,K,q=class q extends j{constructor(e,r){super();p(this,i);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,A);p(this,_);p(this,O);p(this,R);p(this,v);p(this,G);p(this,k,new Map);p(this,E,new Set);p(this,D);p(this,S,[]);u(this,P,e),u(this,x,I.uuid()),u(this,D,r?.extensions??{}),u(this,_,new Promise(o=>{t(this,P).addEventListener("message",s=>{if(s.data.type==="here")o();else throw new Error("Invalid message")},{once:!0})})),u(this,O,new Promise(o=>{let s=a=>{a.data.type==="ready"&&(u(this,A,a.data.id),t(this,P).removeEventListener("message",s),o())};t(this,P).addEventListener("message",s)})),u(this,W,h(this,i,H).call(this,r))}static async create(e,r){let o=new q(e,r);return await t(o,W),o}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,R)?.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,i,g).call(this,"execProtocolRaw",e)}async execProtocol(e){return await h(this,i,g).call(this,"execProtocol",e)}async execProtocolStream(e){return await h(this,i,g).call(this,"execProtocolStream",e)}async execProtocolRawStream(e,r){await h(this,i,g).call(this,"execProtocolRawStream",e,r)}async syncToFs(){await h(this,i,g).call(this,"syncToFs")}async listen(e,r,o){let s=I.toPostgresName(e),a=o??this;return t(this,k).has(s)||t(this,k).set(s,new Set),t(this,k).get(s).add(r),await a.exec(`LISTEN ${e}`),async l=>{await this.unlisten(s,r,l)}}async unlisten(e,r,o){await this.waitReady;let s=o??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,E).add(e),()=>{t(this,E).delete(e)}}offNotification(e){t(this,E).delete(e)}async dumpDataDir(e){return await h(this,i,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,i,g).call(this,"_handleBlob",e)}async _getWrittenBlob(){return await h(this,i,g).call(this,"_getWrittenBlob")}async _cleanupBlob(){await h(this,i,g).call(this,"_cleanupBlob")}async _checkReady(){await this.waitReady}async _runExclusiveQuery(e){await h(this,i,g).call(this,"_acquireQueryLock");try{return await e()}finally{await h(this,i,g).call(this,"_releaseQueryLock")}}async _runExclusiveTransaction(e){await h(this,i,g).call(this,"_acquireTransactionLock");try{return await e()}finally{await h(this,i,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,A=new WeakMap,_=new WeakMap,O=new WeakMap,R=new WeakMap,v=new WeakMap,G=new WeakMap,k=new WeakMap,E=new WeakMap,D=new WeakMap,S=new WeakMap,i=new WeakSet,H=async function(e={}){for(let[c,y]of Object.entries(t(this,D))){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 ${c} returned emscriptenOpts, these are not supported on the client side of a worker`),d.namespaceObj){let b=this;b[c]=d.namespaceObj}d.bundlePath&&console.warn(`PGlite extension ${c} returned bundlePath, this is not supported on the client side of a worker`),d.init&&await d.init(),d.close&&t(this,S).push(d.close)}}await t(this,_);let{extensions:r,...o}=e;t(this,P).postMessage({type:"init",options:o}),await t(this,O);let s=`pglite-tab-close:${t(this,x)}`;u(this,G,await N(s));let a=`pglite-broadcast:${t(this,A)}`;u(this,R,new BroadcastChannel(a));let l=`pglite-tab:${t(this,x)}`;u(this,v,new BroadcastChannel(l)),t(this,R).addEventListener("message",async c=>{c.data.type==="leader-here"?(u(this,L,!1),t(this,w).dispatchEvent(new Event("leader-change")),h(this,i,U).call(this)):c.data.type==="notify"&&h(this,i,K).call(this,c.data.channel,c.data.payload)}),t(this,v).addEventListener("message",async c=>{c.data.type==="connected"&&(u(this,L,!0),t(this,w).dispatchEvent(new Event("connected")),u(this,T,await h(this,i,g).call(this,"getDebugLevel")),u(this,C,!0))}),t(this,P).addEventListener("message",async c=>{c.data.type==="leader-now"&&(u(this,B,!0),t(this,w).dispatchEvent(new Event("leader-change")))}),h(this,i,U).call(this),this._initArrayTypes()},U=async function(){t(this,L)||(t(this,R).postMessage({type:"tab-here",id:t(this,x)}),setTimeout(()=>h(this,i,U).call(this),16))},g=async function(e,...r){let o=I.uuid(),s={type:"rpc-call",callId:o,method:e,args:r};return t(this,v).postMessage(s),await new Promise((a,l)=>{let c=b=>{if(b.data.callId!==o)return;d();let f=b.data;if(f.type==="rpc-return")a(f.result);else if(f.type==="rpc-error"){let F=new Error(f.error.message);Object.assign(F,f.error),l(F)}else l(new Error("Invalid message"))},y=()=>{d(),l(new $)},d=()=>{t(this,v).removeEventListener("message",c),t(this,w).removeEventListener("leader-change",y)};t(this,w).addEventListener("leader-change",y),t(this,v).addEventListener("message",c)})},K=function(e,r){let o=t(this,k).get(e);if(o)for(let s of o)queueMicrotask(()=>s(r));for(let s of t(this,E))queueMicrotask(()=>s(e,r))};var z=q;async function te({init:m}){postMessage({type:"here"});let n=await new Promise(y=>{addEventListener("message",d=>{d.data.type==="init"&&y(d.data.options)},{once:!0})}),e=n.id??`${import.meta.url}:${n.dataDir??""}`;postMessage({type:"ready",id:e});let r=`pglite-election-lock:${e}`,o=`pglite-broadcast:${e}`,s=new BroadcastChannel(o),a=new Set;await N(r);let l=m(n);s.onmessage=async y=>{let d=y.data;switch(d.type){case"tab-here":J(d.id,await l,a);break}},s.postMessage({type:"leader-here",id:e}),postMessage({type:"leader-now"}),(await l).onNotification((y,d)=>{s.postMessage({type:"notify",channel:y,payload:d})})}function J(m,n,e){if(e.has(m))return;e.add(m);let r=`pglite-tab:${m}`,o=`pglite-tab-close:${m}`,s=new BroadcastChannel(r);navigator.locks.request(o,()=>new Promise(l=>{s.close(),e.delete(m),l()}));let a=V(m,n);s.addEventListener("message",async l=>{let c=l.data;switch(c.type){case"rpc-call":{await n.waitReady;let{callId:y,method:d,args:b}=c;try{let f=await a[d](...b);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(m,n){let e=null,r=null,o=`pglite-tab-close:${m}`;return N(o).then(()=>{r&&n.exec("ROLLBACK"),e?.(),r?.()}),{async getDebugLevel(){return n.debug},async close(){await n.close()},async execProtocol(s){let{messages:a,data:l}=await n.execProtocol(s);if(l.byteLength!==l.buffer.byteLength){let c=new ArrayBuffer(l.byteLength),y=new Uint8Array(c);return y.set(l),{messages:a,data:y}}else return{messages:a,data:l}},async execProtocolStream(s){return await n.execProtocolStream(s)},async execProtocolRawStream(s,a){return await n.execProtocolRawStream(s,a)},async execProtocolRaw(s){let a=await n.execProtocolRaw(s);if(a.byteLength!==a.buffer.byteLength){let l=new ArrayBuffer(a.byteLength),c=new Uint8Array(l);return c.set(a),c}else return a},async dumpDataDir(s){return await n.dumpDataDir(s)},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(a=>{e=a,s()}))})},async _releaseQueryLock(){e?.(),e=null},async _acquireTransactionLock(){return new Promise(s=>{n._runExclusiveTransaction(()=>new Promise(a=>{r=a,s()}))})},async _releaseTransactionLock(){r?.(),r=null}}}var $=class extends Error{constructor(){super("Leader changed, pending operation in indeterminate state")}};async function N(m){let n;return await new Promise(e=>{navigator.locks.request(m,()=>new Promise(r=>{n=r,e()}))}),n}export{$ as LeaderChangedError,z as PGliteWorker,te as worker}; | ||
| import{a as j}from"../chunk-JDT7TZ73.js";import"../chunk-2BOC2OMW.js";import{a as I}from"../chunk-NNS5RQRF.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,R,v,G,k,E,D,S,i,H,U,g,K,q=class q extends j{constructor(e,r){super();p(this,i);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,A);p(this,_);p(this,O);p(this,R);p(this,v);p(this,G);p(this,k,new Map);p(this,E,new Set);p(this,D);p(this,S,[]);u(this,P,e),u(this,x,I.uuid()),u(this,D,r?.extensions??{}),u(this,_,new Promise(o=>{t(this,P).addEventListener("message",s=>{if(s.data.type==="here")o();else throw new Error("Invalid message")},{once:!0})})),u(this,O,new Promise(o=>{let s=a=>{a.data.type==="ready"&&(u(this,A,a.data.id),t(this,P).removeEventListener("message",s),o())};t(this,P).addEventListener("message",s)})),u(this,W,h(this,i,H).call(this,r))}static async create(e,r){let o=new q(e,r);return await t(o,W),o}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,R)?.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,i,g).call(this,"execProtocolRaw",e)}async execProtocol(e){return await h(this,i,g).call(this,"execProtocol",e)}async execProtocolStream(e){return await h(this,i,g).call(this,"execProtocolStream",e)}async execProtocolRawStream(e,r){await h(this,i,g).call(this,"execProtocolRawStream",e,r)}async syncToFs(){await h(this,i,g).call(this,"syncToFs")}async listen(e,r,o){let s=I.toPostgresName(e),a=o??this;return t(this,k).has(s)||t(this,k).set(s,new Set),t(this,k).get(s).add(r),await a.exec(`LISTEN ${e}`),async l=>{await this.unlisten(s,r,l)}}async unlisten(e,r,o){await this.waitReady;let s=o??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,E).add(e),()=>{t(this,E).delete(e)}}offNotification(e){t(this,E).delete(e)}async dumpDataDir(e){return await h(this,i,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,i,g).call(this,"_handleBlob",e)}async _getWrittenBlob(){return await h(this,i,g).call(this,"_getWrittenBlob")}async _cleanupBlob(){await h(this,i,g).call(this,"_cleanupBlob")}async _checkReady(){await this.waitReady}async _runExclusiveQuery(e){await h(this,i,g).call(this,"_acquireQueryLock");try{return await e()}finally{await h(this,i,g).call(this,"_releaseQueryLock")}}async _runExclusiveTransaction(e){await h(this,i,g).call(this,"_acquireTransactionLock");try{return await e()}finally{await h(this,i,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,A=new WeakMap,_=new WeakMap,O=new WeakMap,R=new WeakMap,v=new WeakMap,G=new WeakMap,k=new WeakMap,E=new WeakMap,D=new WeakMap,S=new WeakMap,i=new WeakSet,H=async function(e={}){for(let[c,y]of Object.entries(t(this,D))){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 ${c} returned emscriptenOpts, these are not supported on the client side of a worker`),d.namespaceObj){let b=this;b[c]=d.namespaceObj}d.bundlePath&&console.warn(`PGlite extension ${c} returned bundlePath, this is not supported on the client side of a worker`),d.init&&await d.init(),d.close&&t(this,S).push(d.close)}}await t(this,_);let{extensions:r,...o}=e;t(this,P).postMessage({type:"init",options:o}),await t(this,O);let s=`pglite-tab-close:${t(this,x)}`;u(this,G,await N(s));let a=`pglite-broadcast:${t(this,A)}`;u(this,R,new BroadcastChannel(a));let l=`pglite-tab:${t(this,x)}`;u(this,v,new BroadcastChannel(l)),t(this,R).addEventListener("message",async c=>{c.data.type==="leader-here"?(u(this,L,!1),t(this,w).dispatchEvent(new Event("leader-change")),h(this,i,U).call(this)):c.data.type==="notify"&&h(this,i,K).call(this,c.data.channel,c.data.payload)}),t(this,v).addEventListener("message",async c=>{c.data.type==="connected"&&(u(this,L,!0),t(this,w).dispatchEvent(new Event("connected")),u(this,T,await h(this,i,g).call(this,"getDebugLevel")),u(this,C,!0))}),t(this,P).addEventListener("message",async c=>{c.data.type==="leader-now"&&(u(this,B,!0),t(this,w).dispatchEvent(new Event("leader-change")))}),h(this,i,U).call(this),this._initArrayTypes()},U=async function(){t(this,L)||(t(this,R).postMessage({type:"tab-here",id:t(this,x)}),setTimeout(()=>h(this,i,U).call(this),16))},g=async function(e,...r){let o=I.uuid(),s={type:"rpc-call",callId:o,method:e,args:r};return t(this,v).postMessage(s),await new Promise((a,l)=>{let c=b=>{if(b.data.callId!==o)return;d();let f=b.data;if(f.type==="rpc-return")a(f.result);else if(f.type==="rpc-error"){let F=new Error(f.error.message);Object.assign(F,f.error),l(F)}else l(new Error("Invalid message"))},y=()=>{d(),l(new $)},d=()=>{t(this,v).removeEventListener("message",c),t(this,w).removeEventListener("leader-change",y)};t(this,w).addEventListener("leader-change",y),t(this,v).addEventListener("message",c)})},K=function(e,r){let o=t(this,k).get(e);if(o)for(let s of o)queueMicrotask(()=>s(r));for(let s of t(this,E))queueMicrotask(()=>s(e,r))};var z=q;async function te({init:m}){postMessage({type:"here"});let n=await new Promise(y=>{addEventListener("message",d=>{d.data.type==="init"&&y(d.data.options)},{once:!0})}),e=n.id??`${import.meta.url}:${n.dataDir??""}`;postMessage({type:"ready",id:e});let r=`pglite-election-lock:${e}`,o=`pglite-broadcast:${e}`,s=new BroadcastChannel(o),a=new Set;await N(r);let l=m(n);s.onmessage=async y=>{let d=y.data;switch(d.type){case"tab-here":J(d.id,await l,a);break}},s.postMessage({type:"leader-here",id:e}),postMessage({type:"leader-now"}),(await l).onNotification((y,d)=>{s.postMessage({type:"notify",channel:y,payload:d})})}function J(m,n,e){if(e.has(m))return;e.add(m);let r=`pglite-tab:${m}`,o=`pglite-tab-close:${m}`,s=new BroadcastChannel(r);navigator.locks.request(o,()=>new Promise(l=>{s.close(),e.delete(m),l()}));let a=V(m,n);s.addEventListener("message",async l=>{let c=l.data;switch(c.type){case"rpc-call":{await n.waitReady;let{callId:y,method:d,args:b}=c;try{let f=await a[d](...b);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(m,n){let e=null,r=null,o=`pglite-tab-close:${m}`;return N(o).then(()=>{r&&n.exec("ROLLBACK"),e?.(),r?.()}),{async getDebugLevel(){return n.debug},async close(){await n.close()},async execProtocol(s){let{messages:a,data:l}=await n.execProtocol(s);if(l.byteLength!==l.buffer.byteLength){let c=new ArrayBuffer(l.byteLength),y=new Uint8Array(c);return y.set(l),{messages:a,data:y}}else return{messages:a,data:l}},async execProtocolStream(s){return await n.execProtocolStream(s)},async execProtocolRawStream(s,a){return await n.execProtocolRawStream(s,a)},async execProtocolRaw(s){let a=await n.execProtocolRaw(s);if(a.byteLength!==a.buffer.byteLength){let l=new ArrayBuffer(a.byteLength),c=new Uint8Array(l);return c.set(a),c}else return a},async dumpDataDir(s){return await n.dumpDataDir(s)},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(a=>{e=a,s()}))})},async _releaseQueryLock(){e?.(),e=null},async _acquireTransactionLock(){return new Promise(s=>{n._runExclusiveTransaction(()=>new Promise(a=>{r=a,s()}))})},async _releaseTransactionLock(){r?.(),r=null}}}var $=class extends Error{constructor(){super("Leader changed, pending operation in indeterminate state")}};async function N(m){let n;return await new Promise(e=>{navigator.locks.request(m,()=>new Promise(r=>{n=r,e()}))}),n}export{$ as LeaderChangedError,z as PGliteWorker,te as worker}; | ||
| //# sourceMappingURL=index.js.map |
+2
-2
| { | ||
| "name": "@electric-sql/pglite", | ||
| "version": "0.5.5", | ||
| "version": "0.5.6", | ||
| "private": false, | ||
@@ -138,3 +138,3 @@ "publishConfig": { | ||
| "@electric-sql/pg-protocol": "0.0.4", | ||
| "@electric-sql/pglite-utils": "0.0.3" | ||
| "@electric-sql/pglite-utils": "0.0.4" | ||
| }, | ||
@@ -141,0 +141,0 @@ "browser": { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
| import{j as g}from"./chunk-QY3QWFKW.js";g();var d=Object.defineProperty,f=(t,e)=>{for(var r in e)d(t,r,{get:e[r],enumerable:!0})},p={};f(p,{IN_NODE:()=>s,WASM_PREFIX:()=>m,getFsBundle:()=>w,instantiateWasm:()=>b,pgliteProc:()=>y,rmdirRecursive:()=>u,startArtifactDownload:()=>c,toPostgresName:()=>v,uuid:()=>S});function h(){let t=process.type;return t==="renderer"||t==="worker"||t==="service-worker"}var s=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string"&&!h(),m="/pglite",a=new Map;async function c(t){s||a.has(t.toString())||a.set(t.toString(),fetch(t))}var o=new Map,y=globalThis&&typeof globalThis.process<"u"?globalThis.process:{exitCode:void 0};async function b(t,e,r){if(r||o.has(e.toString())){let i=r||o.get(e.toString());return{instance:await WebAssembly.instantiate(i,t),module:i}}if(s){let i=await(await import("fs/promises")).readFile(e),{module:n,instance:l}=await WebAssembly.instantiate(i,t);return o.set(e.toString(),n),{instance:l,module:n}}else{a.has(e.toString())||c(e);let i=await a.get(e.toString()),{module:n,instance:l}=await WebAssembly.instantiateStreaming(i.clone(),t);return o.set(e.toString(),n),{instance:l,module:n}}}async function w(t){return s?(await(await import("fs/promises")).readFile(t)).buffer:(c(t),(await a.get(t.toString())).clone().arrayBuffer())}var S=()=>{if(globalThis.crypto?.randomUUID)return globalThis.crypto.randomUUID();let t=new Uint8Array(16);if(globalThis.crypto?.getRandomValues)globalThis.crypto.getRandomValues(t);else for(let r=0;r<t.length;r++)t[r]=Math.floor(Math.random()*256);t[6]=t[6]&15|64,t[8]=t[8]&63|128;let e=[];return t.forEach(r=>{e.push(r.toString(16).padStart(2,"0"))}),e.slice(0,4).join("")+"-"+e.slice(4,6).join("")+"-"+e.slice(6,8).join("")+"-"+e.slice(8,10).join("")+"-"+e.slice(10).join("")};function v(t){let e;return t.startsWith('"')&&t.endsWith('"')?e=t.substring(1,t.length-1):e=t.toLowerCase(),e}function u(t,e){try{let r=t.readdir(e).filter(i=>i!=="."&&i!=="..");for(let i of r){let n=e+"/"+i;try{t.readdir(n),u(t,n)}catch{t.unlink(n)}}t.rmdir(e)}catch{try{t.unlink(e)}catch{}}}export{p as a}; | ||
| //# sourceMappingURL=chunk-VVBUWNGP.js.map |
| {"version":3,"sources":["../../pglite-utils/src/utils.ts"],"sourcesContent":["// Electron exposes a Node-like `process` in its renderer/worker/service-worker\n// contexts, which must use the browser fs path. Its main and utility processes\n// are real Node environments (#813).\nfunction isElectronWebContext(): boolean {\n const type = (process as { type?: string }).type\n return type === 'renderer' || type === 'worker' || type === 'service-worker'\n}\n\nexport const IN_NODE =\n typeof process === 'object' &&\n typeof process.versions === 'object' &&\n typeof process.versions.node === 'string' &&\n !isElectronWebContext()\n\nexport const WASM_PREFIX = '/pglite'\n\nconst artifactDownloadPromises = new Map<string, Promise<Response>>()\n\nexport async function startArtifactDownload(url: URL) {\n if (IN_NODE || artifactDownloadPromises.has(url.toString())) {\n return\n }\n artifactDownloadPromises.set(url.toString(), fetch(url))\n}\n\n// This is a global cache of the Wasm modules to avoid having to re-download or\n// compile them on subsequent calls.\nconst cachedWasmModules = new Map<string, WebAssembly.Module>()\n\nexport const pgliteProc =\n globalThis && typeof globalThis.process !== 'undefined'\n ? globalThis.process\n : { exitCode: undefined }\n\nexport async function instantiateWasm(\n imports: WebAssembly.Imports,\n moduleUrl: URL,\n module?: WebAssembly.Module,\n): Promise<{\n instance: WebAssembly.Instance\n module: WebAssembly.Module\n}> {\n if (module || cachedWasmModules.has(moduleUrl.toString())) {\n const mod = module || cachedWasmModules.get(moduleUrl.toString())!\n return {\n instance: await WebAssembly.instantiate(mod, imports),\n module: mod,\n }\n }\n if (IN_NODE) {\n const fs = await import('fs/promises')\n const buffer = await fs.readFile(moduleUrl)\n const { module: newModule, instance } = await WebAssembly.instantiate(\n buffer,\n imports,\n )\n cachedWasmModules.set(moduleUrl.toString(), newModule)\n return {\n instance,\n module: newModule,\n }\n } else {\n if (!artifactDownloadPromises.has(moduleUrl.toString())) {\n startArtifactDownload(moduleUrl)\n // wasmDownloadPromises.set(moduleUrl, fetch(moduleUrl))\n }\n const response = await artifactDownloadPromises.get(moduleUrl.toString())\n const { module: newModule, instance } =\n await WebAssembly.instantiateStreaming(response!.clone(), imports)\n cachedWasmModules.set(moduleUrl.toString(), newModule)\n return {\n instance,\n module: newModule,\n }\n }\n}\n\nexport async function getFsBundle(fsBundleUrl: URL): Promise<ArrayBuffer> {\n if (IN_NODE) {\n const fs = await import('fs/promises')\n const fileData = await fs.readFile(fsBundleUrl)\n return fileData.buffer\n } else {\n startArtifactDownload(fsBundleUrl)\n const response = await artifactDownloadPromises.get(fsBundleUrl.toString())\n return response!.clone().arrayBuffer()\n }\n}\n\nexport const uuid = (): string => {\n // best case, `crypto.randomUUID` is available\n if (globalThis.crypto?.randomUUID) {\n return globalThis.crypto.randomUUID()\n }\n\n const bytes = new Uint8Array(16)\n\n if (globalThis.crypto?.getRandomValues) {\n // `crypto.getRandomValues` is available even in non-secure contexts\n globalThis.crypto.getRandomValues(bytes)\n } else {\n // fallback to Math.random, if the Crypto API is completely missing\n for (let i = 0; i < bytes.length; i++) {\n bytes[i] = Math.floor(Math.random() * 256)\n }\n }\n\n bytes[6] = (bytes[6] & 0x0f) | 0x40 // Set the 4 most significant bits to 0100\n bytes[8] = (bytes[8] & 0x3f) | 0x80 // Set the 2 most significant bits to 10\n\n const hexValues: string[] = []\n bytes.forEach((byte) => {\n hexValues.push(byte.toString(16).padStart(2, '0'))\n })\n\n return (\n hexValues.slice(0, 4).join('') +\n '-' +\n hexValues.slice(4, 6).join('') +\n '-' +\n hexValues.slice(6, 8).join('') +\n '-' +\n hexValues.slice(8, 10).join('') +\n '-' +\n hexValues.slice(10).join('')\n )\n}\n\n/**\n * Postgresql handles quoted names as CaseSensitive and unquoted as lower case.\n * If input is quoted, returns an unquoted string (same casing)\n * If input is unquoted, returns a lower-case string\n */\nexport function toPostgresName(input: string): string {\n let output\n if (input.startsWith('\"') && input.endsWith('\"')) {\n // Postgres sensitive case\n output = input.substring(1, input.length - 1)\n } else {\n // Postgres case insensitive - all to lower\n output = input.toLowerCase()\n }\n return output\n}\n\ninterface MinimalFS {\n readdir(path: string): string[]\n unlink(path: string): void\n rmdir(path: string): void\n}\n\nexport function rmdirRecursive(fs: MinimalFS, path: string) {\n try {\n // If readdir succeeds it's a directory\n const entries = fs.readdir(path).filter((n: any) => n !== '.' && n !== '..')\n for (const name of entries) {\n const child = path + '/' + name\n // Recurse or unlink depending on whether child is a directory\n try {\n fs.readdir(child)\n rmdirRecursive(fs, child)\n } catch (e) {\n // readdir failed => not a directory\n fs.unlink(child)\n }\n }\n fs.rmdir(path)\n } catch (e) {\n // not a directory: try unlink\n try {\n fs.unlink(path)\n } catch (_) {\n /* ignore if already gone */\n }\n }\n}\n"],"mappings":"kIAAAA,EAAA,CAAA,EAAAC,EAAAD,EAAA,CAAA,QAAA,IAAAE,EAAA,YAAA,IAAAC,EAAA,YAAA,IAAAC,EAAA,gBAAA,IAAAC,EAAA,WAAA,IAAAC,EAAA,eAAA,IAAAC,EAAA,sBAAA,IAAAC,EAAA,eAAA,IAAAC,EAAA,KAAA,IAAAC,CAAAA,CAAAA,EAGA,SAASC,GAAgC,CACvC,IAAMC,EAAQ,QAA8B,KAC5C,OAAOA,IAAS,YAAcA,IAAS,UAAYA,IAAS,gBAC9D,CAEO,IAAMV,EACX,OAAO,SAAY,UACnB,OAAO,QAAQ,UAAa,UAC5B,OAAO,QAAQ,SAAS,MAAS,UACjC,CAACS,EAAqB,EAEXR,EAAc,UAErBU,EAA2B,IAAI,IAErC,eAAsBL,EAAsBM,EAAU,CAChDZ,GAAWW,EAAyB,IAAIC,EAAI,SAAS,CAAC,GAG1DD,EAAyB,IAAIC,EAAI,SAAS,EAAG,MAAMA,CAAG,CAAC,CACzD,CAIA,IAAMC,EAAoB,IAAI,IAEjBT,EACX,YAAc,OAAO,WAAW,QAAY,IACxC,WAAW,QACX,CAAE,SAAU,MAAU,EAE5B,eAAsBD,EACpBW,EACAC,EACAC,EAIC,CACD,GAAIA,GAAUH,EAAkB,IAAIE,EAAU,SAAS,CAAC,EAAG,CACzD,IAAME,EAAMD,GAAUH,EAAkB,IAAIE,EAAU,SAAS,CAAC,EAChE,MAAO,CACL,SAAU,MAAM,YAAY,YAAYE,EAAKH,CAAO,EACpD,OAAQG,CACV,CACF,CACA,GAAIjB,EAAS,CAEX,IAAMkB,EAAS,MADJ,KAAM,QAAO,aAAa,GACb,SAASH,CAAS,EACpC,CAAE,OAAQI,EAAW,SAAAC,CAAS,EAAI,MAAM,YAAY,YACxDF,EACAJ,CACF,EACA,OAAAD,EAAkB,IAAIE,EAAU,SAAS,EAAGI,CAAS,EAC9C,CACL,SAAAC,EACA,OAAQD,CACV,CACF,KAAO,CACAR,EAAyB,IAAII,EAAU,SAAS,CAAC,GACpDT,EAAsBS,CAAS,EAGjC,IAAMM,EAAW,MAAMV,EAAyB,IAAII,EAAU,SAAS,CAAC,EAClE,CAAE,OAAQI,EAAW,SAAAC,CAAS,EAClC,MAAM,YAAY,qBAAqBC,EAAU,MAAM,EAAGP,CAAO,EACnE,OAAAD,EAAkB,IAAIE,EAAU,SAAS,EAAGI,CAAS,EAC9C,CACL,SAAAC,EACA,OAAQD,CACV,CACF,CACF,CAEA,eAAsBjB,EAAYoB,EAAwC,CACxE,OAAItB,GAEe,MADN,KAAM,QAAO,aAAa,GACX,SAASsB,CAAW,GAC9B,QAEhBhB,EAAsBgB,CAAW,GAChB,MAAMX,EAAyB,IAAIW,EAAY,SAAS,CAAC,GACzD,MAAM,EAAE,YAAY,EAEzC,CAEO,IAAMd,EAAO,IAAc,CAEhC,GAAI,WAAW,QAAQ,WACrB,OAAO,WAAW,OAAO,WAAW,EAGtC,IAAMe,EAAQ,IAAI,WAAW,EAAE,EAE/B,GAAI,WAAW,QAAQ,gBAErB,WAAW,OAAO,gBAAgBA,CAAK,MAGvC,SAASC,EAAI,EAAGA,EAAID,EAAM,OAAQC,IAChCD,EAAMC,CAAC,EAAI,KAAK,MAAM,KAAK,OAAO,EAAI,GAAG,EAI7CD,EAAM,CAAC,EAAKA,EAAM,CAAC,EAAI,GAAQ,GAC/BA,EAAM,CAAC,EAAKA,EAAM,CAAC,EAAI,GAAQ,IAE/B,IAAME,EAAsB,CAAC,EAC7B,OAAAF,EAAM,QAASG,GAAS,CACtBD,EAAU,KAAKC,EAAK,SAAS,EAAE,EAAE,SAAS,EAAG,GAAG,CAAC,CACnD,CAAC,EAGCD,EAAU,MAAM,EAAG,CAAC,EAAE,KAAK,EAAE,EAC7B,IACAA,EAAU,MAAM,EAAG,CAAC,EAAE,KAAK,EAAE,EAC7B,IACAA,EAAU,MAAM,EAAG,CAAC,EAAE,KAAK,EAAE,EAC7B,IACAA,EAAU,MAAM,EAAG,EAAE,EAAE,KAAK,EAAE,EAC9B,IACAA,EAAU,MAAM,EAAE,EAAE,KAAK,EAAE,CAE/B,EAOO,SAASlB,EAAeoB,EAAuB,CACpD,IAAIC,EACJ,OAAID,EAAM,WAAW,GAAG,GAAKA,EAAM,SAAS,GAAG,EAE7CC,EAASD,EAAM,UAAU,EAAGA,EAAM,OAAS,CAAC,EAG5CC,EAASD,EAAM,YAAY,EAEtBC,CACT,CAQO,SAASvB,EAAewB,EAAeC,EAAc,CAC1D,GAAI,CAEF,IAAMC,EAAUF,EAAG,QAAQC,CAAI,EAAE,OAAQE,GAAWA,IAAM,KAAOA,IAAM,IAAI,EAC3E,QAAWC,KAAQF,EAAS,CAC1B,IAAMG,EAAQJ,EAAO,IAAMG,EAE3B,GAAI,CACFJ,EAAG,QAAQK,CAAK,EAChB7B,EAAewB,EAAIK,CAAK,CAC1B,MAAY,CAEVL,EAAG,OAAOK,CAAK,CACjB,CACF,CACAL,EAAG,MAAMC,CAAI,CACf,MAAY,CAEV,GAAI,CACFD,EAAG,OAAOC,CAAI,CAChB,MAAY,CAEZ,CACF,CACF","names":["utils_exports","__export","IN_NODE","WASM_PREFIX","getFsBundle","instantiateWasm","pgliteProc","rmdirRecursive","startArtifactDownload","toPostgresName","uuid","isElectronWebContext","type","artifactDownloadPromises","url","cachedWasmModules","imports","moduleUrl","module","mod","buffer","newModule","instance","response","fsBundleUrl","bytes","i","hexValues","byte","input","output","fs","path","entries","n","name","child"]} |
| declare const Modes: { | ||
| readonly text: 0; | ||
| readonly binary: 1; | ||
| }; | ||
| type Mode = (typeof Modes)[keyof typeof Modes]; | ||
| type BufferParameter = ArrayBuffer | ArrayBufferView; | ||
| type MessageName = 'parseComplete' | 'bindComplete' | 'closeComplete' | 'noData' | 'portalSuspended' | 'replicationStart' | 'emptyQuery' | 'copyDone' | 'copyData' | 'rowDescription' | 'parameterDescription' | 'parameterStatus' | 'backendKeyData' | 'notification' | 'readyForQuery' | 'commandComplete' | 'dataRow' | 'copyInResponse' | 'copyOutResponse' | 'authenticationOk' | 'authenticationMD5Password' | 'authenticationCleartextPassword' | 'authenticationSASL' | 'authenticationSASLContinue' | 'authenticationSASLFinal' | 'error' | 'notice'; | ||
| type BackendMessage = { | ||
| name: MessageName; | ||
| length: number; | ||
| }; | ||
| declare const parseComplete: BackendMessage; | ||
| declare const bindComplete: BackendMessage; | ||
| declare const closeComplete: BackendMessage; | ||
| declare const noData: BackendMessage; | ||
| declare const portalSuspended: BackendMessage; | ||
| declare const replicationStart: BackendMessage; | ||
| declare const emptyQuery: BackendMessage; | ||
| declare const copyDone: BackendMessage; | ||
| declare class AuthenticationOk implements BackendMessage { | ||
| readonly length: number; | ||
| readonly name = "authenticationOk"; | ||
| constructor(length: number); | ||
| } | ||
| declare class AuthenticationCleartextPassword implements BackendMessage { | ||
| readonly length: number; | ||
| readonly name = "authenticationCleartextPassword"; | ||
| constructor(length: number); | ||
| } | ||
| declare class AuthenticationMD5Password implements BackendMessage { | ||
| readonly length: number; | ||
| readonly salt: Uint8Array; | ||
| readonly name = "authenticationMD5Password"; | ||
| constructor(length: number, salt: Uint8Array); | ||
| } | ||
| declare class AuthenticationSASL implements BackendMessage { | ||
| readonly length: number; | ||
| readonly mechanisms: string[]; | ||
| readonly name = "authenticationSASL"; | ||
| constructor(length: number, mechanisms: string[]); | ||
| } | ||
| declare class AuthenticationSASLContinue implements BackendMessage { | ||
| readonly length: number; | ||
| readonly data: string; | ||
| readonly name = "authenticationSASLContinue"; | ||
| constructor(length: number, data: string); | ||
| } | ||
| declare class AuthenticationSASLFinal implements BackendMessage { | ||
| readonly length: number; | ||
| readonly data: string; | ||
| readonly name = "authenticationSASLFinal"; | ||
| constructor(length: number, data: string); | ||
| } | ||
| type AuthenticationMessage = AuthenticationOk | AuthenticationCleartextPassword | AuthenticationMD5Password | AuthenticationSASL | AuthenticationSASLContinue | AuthenticationSASLFinal; | ||
| interface NoticeOrError { | ||
| message: string | undefined; | ||
| severity: string | undefined; | ||
| code: string | undefined; | ||
| detail: string | undefined; | ||
| hint: string | undefined; | ||
| position: string | undefined; | ||
| internalPosition: string | undefined; | ||
| internalQuery: string | undefined; | ||
| where: string | undefined; | ||
| schema: string | undefined; | ||
| table: string | undefined; | ||
| column: string | undefined; | ||
| dataType: string | undefined; | ||
| constraint: string | undefined; | ||
| file: string | undefined; | ||
| line: string | undefined; | ||
| routine: string | undefined; | ||
| } | ||
| declare class DatabaseError extends Error implements NoticeOrError { | ||
| readonly length: number; | ||
| readonly name: MessageName; | ||
| severity: string | undefined; | ||
| code: string | undefined; | ||
| detail: string | undefined; | ||
| hint: string | undefined; | ||
| position: string | undefined; | ||
| internalPosition: string | undefined; | ||
| internalQuery: string | undefined; | ||
| where: string | undefined; | ||
| schema: string | undefined; | ||
| table: string | undefined; | ||
| column: string | undefined; | ||
| dataType: string | undefined; | ||
| constraint: string | undefined; | ||
| file: string | undefined; | ||
| line: string | undefined; | ||
| routine: string | undefined; | ||
| constructor(message: string, length: number, name: MessageName); | ||
| } | ||
| declare class CopyDataMessage implements BackendMessage { | ||
| readonly length: number; | ||
| readonly chunk: Uint8Array; | ||
| readonly name = "copyData"; | ||
| constructor(length: number, chunk: Uint8Array); | ||
| } | ||
| declare class CopyResponse implements BackendMessage { | ||
| readonly length: number; | ||
| readonly name: MessageName; | ||
| readonly binary: boolean; | ||
| readonly columnTypes: number[]; | ||
| constructor(length: number, name: MessageName, binary: boolean, columnCount: number); | ||
| } | ||
| declare class Field { | ||
| readonly name: string; | ||
| readonly tableID: number; | ||
| readonly columnID: number; | ||
| readonly dataTypeID: number; | ||
| readonly dataTypeSize: number; | ||
| readonly dataTypeModifier: number; | ||
| readonly format: Mode; | ||
| constructor(name: string, tableID: number, columnID: number, dataTypeID: number, dataTypeSize: number, dataTypeModifier: number, format: Mode); | ||
| } | ||
| declare class RowDescriptionMessage implements BackendMessage { | ||
| readonly length: number; | ||
| readonly fieldCount: number; | ||
| readonly name: MessageName; | ||
| readonly fields: Field[]; | ||
| constructor(length: number, fieldCount: number); | ||
| } | ||
| declare class ParameterDescriptionMessage implements BackendMessage { | ||
| readonly length: number; | ||
| readonly parameterCount: number; | ||
| readonly name: MessageName; | ||
| readonly dataTypeIDs: number[]; | ||
| constructor(length: number, parameterCount: number); | ||
| } | ||
| declare class ParameterStatusMessage implements BackendMessage { | ||
| readonly length: number; | ||
| readonly parameterName: string; | ||
| readonly parameterValue: string; | ||
| readonly name: MessageName; | ||
| constructor(length: number, parameterName: string, parameterValue: string); | ||
| } | ||
| declare class BackendKeyDataMessage implements BackendMessage { | ||
| readonly length: number; | ||
| readonly processID: number; | ||
| readonly secretKey: number; | ||
| readonly name: MessageName; | ||
| constructor(length: number, processID: number, secretKey: number); | ||
| } | ||
| declare class NotificationResponseMessage implements BackendMessage { | ||
| readonly length: number; | ||
| readonly processId: number; | ||
| readonly channel: string; | ||
| readonly payload: string; | ||
| readonly name: MessageName; | ||
| constructor(length: number, processId: number, channel: string, payload: string); | ||
| } | ||
| declare class ReadyForQueryMessage implements BackendMessage { | ||
| readonly length: number; | ||
| readonly status: string; | ||
| readonly name: MessageName; | ||
| constructor(length: number, status: string); | ||
| } | ||
| declare class CommandCompleteMessage implements BackendMessage { | ||
| readonly length: number; | ||
| readonly text: string; | ||
| readonly name: MessageName; | ||
| constructor(length: number, text: string); | ||
| } | ||
| declare class DataRowMessage implements BackendMessage { | ||
| length: number; | ||
| fields: (string | null)[]; | ||
| readonly fieldCount: number; | ||
| readonly name: MessageName; | ||
| constructor(length: number, fields: (string | null)[]); | ||
| } | ||
| declare class NoticeMessage implements BackendMessage, NoticeOrError { | ||
| readonly length: number; | ||
| readonly message: string | undefined; | ||
| constructor(length: number, message: string | undefined); | ||
| readonly name = "notice"; | ||
| severity: string | undefined; | ||
| code: string | undefined; | ||
| detail: string | undefined; | ||
| hint: string | undefined; | ||
| position: string | undefined; | ||
| internalPosition: string | undefined; | ||
| internalQuery: string | undefined; | ||
| where: string | undefined; | ||
| schema: string | undefined; | ||
| table: string | undefined; | ||
| column: string | undefined; | ||
| dataType: string | undefined; | ||
| constraint: string | undefined; | ||
| file: string | undefined; | ||
| line: string | undefined; | ||
| routine: string | undefined; | ||
| } | ||
| type messages_AuthenticationCleartextPassword = AuthenticationCleartextPassword; | ||
| declare const messages_AuthenticationCleartextPassword: typeof AuthenticationCleartextPassword; | ||
| type messages_AuthenticationMD5Password = AuthenticationMD5Password; | ||
| declare const messages_AuthenticationMD5Password: typeof AuthenticationMD5Password; | ||
| type messages_AuthenticationMessage = AuthenticationMessage; | ||
| type messages_AuthenticationOk = AuthenticationOk; | ||
| declare const messages_AuthenticationOk: typeof AuthenticationOk; | ||
| type messages_AuthenticationSASL = AuthenticationSASL; | ||
| declare const messages_AuthenticationSASL: typeof AuthenticationSASL; | ||
| type messages_AuthenticationSASLContinue = AuthenticationSASLContinue; | ||
| declare const messages_AuthenticationSASLContinue: typeof AuthenticationSASLContinue; | ||
| type messages_AuthenticationSASLFinal = AuthenticationSASLFinal; | ||
| declare const messages_AuthenticationSASLFinal: typeof AuthenticationSASLFinal; | ||
| type messages_BackendKeyDataMessage = BackendKeyDataMessage; | ||
| declare const messages_BackendKeyDataMessage: typeof BackendKeyDataMessage; | ||
| type messages_BackendMessage = BackendMessage; | ||
| type messages_CommandCompleteMessage = CommandCompleteMessage; | ||
| declare const messages_CommandCompleteMessage: typeof CommandCompleteMessage; | ||
| type messages_CopyDataMessage = CopyDataMessage; | ||
| declare const messages_CopyDataMessage: typeof CopyDataMessage; | ||
| type messages_CopyResponse = CopyResponse; | ||
| declare const messages_CopyResponse: typeof CopyResponse; | ||
| type messages_DataRowMessage = DataRowMessage; | ||
| declare const messages_DataRowMessage: typeof DataRowMessage; | ||
| type messages_DatabaseError = DatabaseError; | ||
| declare const messages_DatabaseError: typeof DatabaseError; | ||
| type messages_Field = Field; | ||
| declare const messages_Field: typeof Field; | ||
| type messages_MessageName = MessageName; | ||
| type messages_NoticeMessage = NoticeMessage; | ||
| declare const messages_NoticeMessage: typeof NoticeMessage; | ||
| type messages_NotificationResponseMessage = NotificationResponseMessage; | ||
| declare const messages_NotificationResponseMessage: typeof NotificationResponseMessage; | ||
| type messages_ParameterDescriptionMessage = ParameterDescriptionMessage; | ||
| declare const messages_ParameterDescriptionMessage: typeof ParameterDescriptionMessage; | ||
| type messages_ParameterStatusMessage = ParameterStatusMessage; | ||
| declare const messages_ParameterStatusMessage: typeof ParameterStatusMessage; | ||
| type messages_ReadyForQueryMessage = ReadyForQueryMessage; | ||
| declare const messages_ReadyForQueryMessage: typeof ReadyForQueryMessage; | ||
| type messages_RowDescriptionMessage = RowDescriptionMessage; | ||
| declare const messages_RowDescriptionMessage: typeof RowDescriptionMessage; | ||
| declare const messages_bindComplete: typeof bindComplete; | ||
| declare const messages_closeComplete: typeof closeComplete; | ||
| declare const messages_copyDone: typeof copyDone; | ||
| declare const messages_emptyQuery: typeof emptyQuery; | ||
| declare const messages_noData: typeof noData; | ||
| declare const messages_parseComplete: typeof parseComplete; | ||
| declare const messages_portalSuspended: typeof portalSuspended; | ||
| declare const messages_replicationStart: typeof replicationStart; | ||
| declare namespace messages { | ||
| export { messages_AuthenticationCleartextPassword as AuthenticationCleartextPassword, messages_AuthenticationMD5Password as AuthenticationMD5Password, type messages_AuthenticationMessage as AuthenticationMessage, messages_AuthenticationOk as AuthenticationOk, messages_AuthenticationSASL as AuthenticationSASL, messages_AuthenticationSASLContinue as AuthenticationSASLContinue, messages_AuthenticationSASLFinal as AuthenticationSASLFinal, messages_BackendKeyDataMessage as BackendKeyDataMessage, type messages_BackendMessage as BackendMessage, messages_CommandCompleteMessage as CommandCompleteMessage, messages_CopyDataMessage as CopyDataMessage, messages_CopyResponse as CopyResponse, messages_DataRowMessage as DataRowMessage, messages_DatabaseError as DatabaseError, messages_Field as Field, type messages_MessageName as MessageName, messages_NoticeMessage as NoticeMessage, messages_NotificationResponseMessage as NotificationResponseMessage, messages_ParameterDescriptionMessage as ParameterDescriptionMessage, messages_ParameterStatusMessage as ParameterStatusMessage, messages_ReadyForQueryMessage as ReadyForQueryMessage, messages_RowDescriptionMessage as RowDescriptionMessage, messages_bindComplete as bindComplete, messages_closeComplete as closeComplete, messages_copyDone as copyDone, messages_emptyQuery as emptyQuery, messages_noData as noData, messages_parseComplete as parseComplete, messages_portalSuspended as portalSuspended, messages_replicationStart as replicationStart }; | ||
| } | ||
| type IDBFS = Emscripten.FileSystemType & { | ||
| quit: () => void; | ||
| dbs: Record<string, IDBDatabase>; | ||
| }; | ||
| type FS = typeof FS & { | ||
| filesystems: { | ||
| MEMFS: Emscripten.FileSystemType; | ||
| NODEFS: Emscripten.FileSystemType; | ||
| IDBFS: IDBFS; | ||
| }; | ||
| quit: () => void; | ||
| }; | ||
| interface PostgresMod extends Omit<EmscriptenModule, 'preInit' | 'preRun' | 'postRun'> { | ||
| preInit: Array<{ | ||
| (mod: PostgresMod): void; | ||
| }>; | ||
| preRun: Array<{ | ||
| (mod: PostgresMod): void; | ||
| }>; | ||
| postRun: Array<{ | ||
| (mod: PostgresMod): void; | ||
| }>; | ||
| thisProgram: string; | ||
| stdin: (() => number | null) | null; | ||
| FS: FS; | ||
| wasmMemory: WebAssembly.Memory; | ||
| PROXYFS: Emscripten.FileSystemType; | ||
| WASM_PREFIX: string; | ||
| pg_extensions: Record<string, Promise<Blob | null>>; | ||
| UTF8ToString: (ptr: number, maxBytesToRead?: number) => string; | ||
| stringToUTF8OnStack: (s: string) => number; | ||
| _pgl_set_system_fn: (system_fn: number) => void; | ||
| _pgl_set_popen_fn: (popen_fn: number) => void; | ||
| _pgl_set_pclose_fn: (pclose_fn: number) => void; | ||
| _pgl_set_rw_cbs: (read_cb: number, write_cb: number) => void; | ||
| _pgl_set_pipe_fn: (pipe_fn: number) => number; | ||
| _pgl_freopen: (filepath: number, mode: number, stream: number) => number; | ||
| _pgl_pq_flush: () => void; | ||
| _fopen: (path: number, mode: number) => number; | ||
| _fclose: (stream: number) => number; | ||
| _fflush: (stream: number) => void; | ||
| _pgl_proc_exit: (code: number) => number; | ||
| addFunction: (cb: (ptr: any, length: number) => void, signature: string) => number; | ||
| removeFunction: (f: number) => void; | ||
| callMain: (args?: string[]) => number; | ||
| _PostgresMainLoopOnce: () => void; | ||
| _PostgresMainLongJmp: () => void; | ||
| _PostgresSendReadyForQueryIfNecessary: () => void; | ||
| _ProcessStartupPacket: (Port: number, ssl_done: boolean, gss_done: boolean) => number; | ||
| _IsTransactionBlock: () => number; | ||
| _pgl_setPGliteActive: (newValue: number) => number; | ||
| _pgl_startPGlite: () => void; | ||
| _pgl_getMyProcPort: () => number; | ||
| _pgl_sendConnData: () => void; | ||
| ENV: any; | ||
| PGLITE_ENV: any; | ||
| _emscripten_force_exit: (status: number) => void; | ||
| _pgl_run_atexit_funcs: () => void; | ||
| _pq_buffer_remaining_data: () => number; | ||
| } | ||
| type PostgresFactory<T extends PostgresMod = PostgresMod> = (moduleOverrides?: Partial<T>) => Promise<T>; | ||
| declare const _default: PostgresFactory<PostgresMod>; | ||
| type postgresMod_FS = FS; | ||
| type postgresMod_PostgresMod = PostgresMod; | ||
| declare namespace postgresMod { | ||
| export { type postgresMod_FS as FS, type postgresMod_PostgresMod as PostgresMod, _default as default }; | ||
| } | ||
| type DumpTarCompressionOptions = 'none' | 'gzip' | 'auto'; | ||
| type FsType = 'nodefs' | 'idbfs' | 'memoryfs' | 'opfs-ahp'; | ||
| /** | ||
| * Filesystem interface. | ||
| * All virtual filesystems that are compatible with PGlite must implement | ||
| * this interface. | ||
| */ | ||
| interface Filesystem { | ||
| /** | ||
| * Initiate the filesystem and return the options to pass to the emscripten module. | ||
| */ | ||
| init(pg: PGlite, emscriptenOptions: Partial<PostgresMod>): Promise<{ | ||
| emscriptenOpts: Partial<PostgresMod>; | ||
| }>; | ||
| /** | ||
| * Sync the filesystem to any underlying storage. | ||
| */ | ||
| syncToFs(relaxedDurability?: boolean): Promise<void>; | ||
| /** | ||
| * Sync the filesystem from any underlying storage. | ||
| */ | ||
| initialSyncFs(): Promise<void>; | ||
| /** | ||
| * Dump the PGDATA dir from the filesystem to a gzipped tarball. | ||
| */ | ||
| dumpTar(dbname: string, compression?: DumpTarCompressionOptions): Promise<File | Blob>; | ||
| /** | ||
| * Close the filesystem. | ||
| */ | ||
| closeFs(): Promise<void>; | ||
| } | ||
| /** | ||
| * Base class for all emscripten built-in filesystems. | ||
| */ | ||
| declare class EmscriptenBuiltinFilesystem implements Filesystem { | ||
| protected dataDir?: string; | ||
| protected pg?: PGlite; | ||
| constructor(dataDir?: string); | ||
| init(pg: PGlite, emscriptenOptions: Partial<PostgresMod>): Promise<{ | ||
| emscriptenOpts: Partial<PostgresMod>; | ||
| }>; | ||
| syncToFs(_relaxedDurability?: boolean): Promise<void>; | ||
| initialSyncFs(): Promise<void>; | ||
| closeFs(): Promise<void>; | ||
| dumpTar(dbname: string, compression?: DumpTarCompressionOptions): Promise<Blob | File>; | ||
| } | ||
| /** | ||
| * Abstract base class for all custom virtual filesystems. | ||
| * Each custom filesystem needs to implement an interface similar to the NodeJS FS API. | ||
| */ | ||
| declare abstract class BaseFilesystem implements Filesystem { | ||
| protected dataDir?: string; | ||
| protected pg?: PGlite; | ||
| readonly debug: boolean; | ||
| constructor(dataDir?: string, { debug }?: { | ||
| debug?: boolean; | ||
| }); | ||
| syncToFs(_relaxedDurability?: boolean): Promise<void>; | ||
| initialSyncFs(): Promise<void>; | ||
| closeFs(): Promise<void>; | ||
| dumpTar(dbname: string, compression?: DumpTarCompressionOptions): Promise<Blob | File>; | ||
| init(pg: PGlite, emscriptenOptions: Partial<PostgresMod>): Promise<{ | ||
| emscriptenOpts: Partial<PostgresMod>; | ||
| }>; | ||
| abstract chmod(path: string, mode: number): void; | ||
| abstract close(fd: number): void; | ||
| abstract fstat(fd: number): FsStats; | ||
| abstract lstat(path: string): FsStats; | ||
| abstract mkdir(path: string, options?: { | ||
| recursive?: boolean; | ||
| mode?: number; | ||
| }): void; | ||
| abstract open(path: string, flags?: string, mode?: number): number; | ||
| abstract readdir(path: string): string[]; | ||
| abstract read(fd: number, buffer: Uint8Array, // Buffer to read into | ||
| offset: number, // Offset in buffer to start writing to | ||
| length: number, // Number of bytes to read | ||
| position: number): number; | ||
| abstract rename(oldPath: string, newPath: string): void; | ||
| abstract rmdir(path: string): void; | ||
| abstract truncate(path: string, len: number): void; | ||
| abstract unlink(path: string): void; | ||
| abstract utimes(path: string, atime: number, mtime: number): void; | ||
| abstract writeFile(path: string, data: string | Uint8Array, options?: { | ||
| encoding?: string; | ||
| mode?: number; | ||
| flag?: string; | ||
| }): void; | ||
| abstract write(fd: number, buffer: Uint8Array, // Buffer to read from | ||
| offset: number, // Offset in buffer to start reading from | ||
| length: number, // Number of bytes to write | ||
| position: number): number; | ||
| } | ||
| type FsStats = { | ||
| dev: number; | ||
| ino: number; | ||
| mode: number; | ||
| nlink: number; | ||
| uid: number; | ||
| gid: number; | ||
| rdev: number; | ||
| size: number; | ||
| blksize: number; | ||
| blocks: number; | ||
| atime: number; | ||
| mtime: number; | ||
| ctime: number; | ||
| }; | ||
| declare const ERRNO_CODES: { | ||
| readonly EBADF: 8; | ||
| readonly EBADFD: 127; | ||
| readonly EEXIST: 20; | ||
| readonly EINVAL: 28; | ||
| readonly EISDIR: 31; | ||
| readonly ENODEV: 43; | ||
| readonly ENOENT: 44; | ||
| readonly ENOTDIR: 54; | ||
| readonly ENOTEMPTY: 55; | ||
| }; | ||
| type FilesystemType = 'nodefs' | 'idbfs' | 'memoryfs'; | ||
| type DebugLevel = 0 | 1 | 2 | 3 | 4 | 5; | ||
| type RowMode = 'array' | 'object'; | ||
| interface ParserOptions { | ||
| [pgType: number]: (value: string) => any; | ||
| } | ||
| interface SerializerOptions { | ||
| [pgType: number]: (value: any) => string; | ||
| } | ||
| interface QueryOptions { | ||
| rowMode?: RowMode; | ||
| parsers?: ParserOptions; | ||
| serializers?: SerializerOptions; | ||
| blob?: Blob | File; | ||
| onNotice?: (notice: NoticeMessage) => void; | ||
| paramTypes?: number[]; | ||
| } | ||
| interface ExecProtocolOptions { | ||
| syncToFs?: boolean; | ||
| throwOnError?: boolean; | ||
| onNotice?: (notice: NoticeMessage) => void; | ||
| } | ||
| interface ExecProtocolOptionsStream { | ||
| syncToFs?: boolean; | ||
| onRawData: (data: Uint8Array) => void; | ||
| } | ||
| interface ExtensionSetupResult<TNamespace = any> { | ||
| emscriptenOpts?: any; | ||
| namespaceObj?: TNamespace; | ||
| bundlePath?: URL; | ||
| sharedPreloadLibraries?: string[]; | ||
| init?: () => Promise<void>; | ||
| close?: () => Promise<void>; | ||
| } | ||
| type ExtensionSetup<TNamespace = any> = (pg: PGliteInterface, emscriptenOpts: any, clientOnly?: boolean) => Promise<ExtensionSetupResult<TNamespace>>; | ||
| interface Extension<TNamespace = any> { | ||
| name: string; | ||
| setup: ExtensionSetup<TNamespace>; | ||
| } | ||
| type ExtensionNamespace<T> = T extends Extension<infer TNamespace> ? TNamespace : any; | ||
| type Extensions = { | ||
| [namespace: string]: Extension | URL; | ||
| }; | ||
| type InitializedExtensions<TExtensions extends Extensions = Extensions> = { | ||
| [K in keyof TExtensions]: ExtensionNamespace<TExtensions[K]>; | ||
| }; | ||
| interface ExecProtocolResult { | ||
| messages: BackendMessage[]; | ||
| data: Uint8Array; | ||
| } | ||
| interface DumpDataDirResult { | ||
| tarball: Uint8Array; | ||
| extension: '.tar' | '.tgz'; | ||
| filename: string; | ||
| } | ||
| interface PGliteOptions<TExtensions extends Extensions = Extensions> { | ||
| noInitDb?: boolean; | ||
| dataDir?: string; | ||
| username?: string; | ||
| database?: string; | ||
| fs?: Filesystem; | ||
| debug?: DebugLevel; | ||
| relaxedDurability?: boolean; | ||
| extensions?: TExtensions; | ||
| loadDataDir?: Blob | File; | ||
| icuDataDir?: Blob | File; | ||
| initialMemory?: number; | ||
| pgliteWasmModule?: WebAssembly.Module; | ||
| initdbWasmModule?: WebAssembly.Module; | ||
| fsBundle?: Blob | File; | ||
| parsers?: ParserOptions; | ||
| serializers?: SerializerOptions; | ||
| startParams?: string[]; | ||
| initDbStartParams?: string[]; | ||
| postgresqlconf?: string[] | string; | ||
| } | ||
| type PGliteInterface<T extends Extensions = Extensions> = InitializedExtensions<T> & { | ||
| readonly waitReady: Promise<void>; | ||
| readonly debug: DebugLevel; | ||
| readonly ready: boolean; | ||
| readonly closed: boolean; | ||
| close(): Promise<void>; | ||
| query<T>(query: string, params?: any[], options?: QueryOptions): Promise<Results<T>>; | ||
| sql<T>(sqlStrings: TemplateStringsArray, ...params: any[]): Promise<Results<T>>; | ||
| exec(query: string, options?: QueryOptions): Promise<Array<Results>>; | ||
| describeQuery(query: string): Promise<DescribeQueryResult>; | ||
| transaction<T>(callback: (tx: Transaction) => Promise<T>): Promise<T>; | ||
| execProtocolRaw(message: Uint8Array, options?: ExecProtocolOptions): Promise<Uint8Array>; | ||
| execProtocolRawStream(message: Uint8Array, options?: ExecProtocolOptionsStream): Promise<void>; | ||
| execProtocol(message: Uint8Array, options?: ExecProtocolOptions): Promise<ExecProtocolResult>; | ||
| runExclusive<T>(fn: () => Promise<T>): Promise<T>; | ||
| listen(channel: string, callback: (payload: string) => void, tx?: Transaction): Promise<(tx?: Transaction) => Promise<void>>; | ||
| unlisten(channel: string, callback?: (payload: string) => void, tx?: Transaction): Promise<void>; | ||
| onNotification(callback: (channel: string, payload: string) => void): () => void; | ||
| offNotification(callback: (channel: string, payload: string) => void): void; | ||
| dumpDataDir(compression?: DumpTarCompressionOptions): Promise<File | Blob>; | ||
| refreshArrayTypes(): Promise<void>; | ||
| }; | ||
| type PGliteInterfaceExtensions<E> = E extends Extensions ? { | ||
| [K in keyof E]: E[K] extends Extension ? Awaited<ReturnType<E[K]['setup']>>['namespaceObj'] extends infer N ? N extends undefined | null | void ? never : N : never : never; | ||
| } : Record<string, never>; | ||
| type Row<T = { | ||
| [key: string]: any; | ||
| }> = T; | ||
| type Results<T = { | ||
| [key: string]: any; | ||
| }> = { | ||
| rows: Row<T>[]; | ||
| affectedRows?: number; | ||
| /** | ||
| * The command of the query that was run, e.g. "SELECT", "INSERT", "CREATE". | ||
| */ | ||
| command?: string; | ||
| /** | ||
| * The number of rows reported by the command tag, e.g. the rows returned | ||
| * by a SELECT or changed by an UPDATE. Unlike `affectedRows` this is per statement | ||
| * and not cumulative across a multi-statement query. | ||
| */ | ||
| rowCount?: number; | ||
| fields: { | ||
| name: string; | ||
| dataTypeID: number; | ||
| }[]; | ||
| blob?: Blob; | ||
| }; | ||
| interface Transaction { | ||
| query<T>(query: string, params?: any[], options?: QueryOptions): Promise<Results<T>>; | ||
| sql<T>(sqlStrings: TemplateStringsArray, ...params: any[]): Promise<Results<T>>; | ||
| exec(query: string, options?: QueryOptions): Promise<Array<Results>>; | ||
| rollback(): Promise<void>; | ||
| listen(channel: string, callback: (payload: string) => void): Promise<(tx?: Transaction) => Promise<void>>; | ||
| get closed(): boolean; | ||
| } | ||
| type DescribeQueryResult = { | ||
| queryParams: { | ||
| dataTypeID: number; | ||
| serializer: Serializer; | ||
| }[]; | ||
| resultFields: { | ||
| name: string; | ||
| dataTypeID: number; | ||
| parser: Parser; | ||
| }[]; | ||
| }; | ||
| declare const BOOL = 16; | ||
| declare const BYTEA = 17; | ||
| declare const CHAR = 18; | ||
| declare const INT8 = 20; | ||
| declare const INT2 = 21; | ||
| declare const INT4 = 23; | ||
| declare const REGPROC = 24; | ||
| declare const TEXT = 25; | ||
| declare const OID = 26; | ||
| declare const TID = 27; | ||
| declare const XID = 28; | ||
| declare const CID = 29; | ||
| declare const JSON = 114; | ||
| declare const XML = 142; | ||
| declare const PG_NODE_TREE = 194; | ||
| declare const SMGR = 210; | ||
| declare const PATH = 602; | ||
| declare const POLYGON = 604; | ||
| declare const CIDR = 650; | ||
| declare const FLOAT4 = 700; | ||
| declare const FLOAT8 = 701; | ||
| declare const ABSTIME = 702; | ||
| declare const RELTIME = 703; | ||
| declare const TINTERVAL = 704; | ||
| declare const CIRCLE = 718; | ||
| declare const MACADDR8 = 774; | ||
| declare const MONEY = 790; | ||
| declare const MACADDR = 829; | ||
| declare const INET = 869; | ||
| declare const ACLITEM = 1033; | ||
| declare const BPCHAR = 1042; | ||
| declare const VARCHAR = 1043; | ||
| declare const DATE = 1082; | ||
| declare const TIME = 1083; | ||
| declare const TIMESTAMP = 1114; | ||
| declare const TIMESTAMPTZ = 1184; | ||
| declare const INTERVAL = 1186; | ||
| declare const TIMETZ = 1266; | ||
| declare const BIT = 1560; | ||
| declare const VARBIT = 1562; | ||
| declare const NUMERIC = 1700; | ||
| declare const REFCURSOR = 1790; | ||
| declare const REGPROCEDURE = 2202; | ||
| declare const REGOPER = 2203; | ||
| declare const REGOPERATOR = 2204; | ||
| declare const REGCLASS = 2205; | ||
| declare const REGTYPE = 2206; | ||
| declare const UUID = 2950; | ||
| declare const TXID_SNAPSHOT = 2970; | ||
| declare const PG_LSN = 3220; | ||
| declare const PG_NDISTINCT = 3361; | ||
| declare const PG_DEPENDENCIES = 3402; | ||
| declare const TSVECTOR = 3614; | ||
| declare const TSQUERY = 3615; | ||
| declare const GTSVECTOR = 3642; | ||
| declare const REGCONFIG = 3734; | ||
| declare const REGDICTIONARY = 3769; | ||
| declare const JSONB = 3802; | ||
| declare const REGNAMESPACE = 4089; | ||
| declare const REGROLE = 4096; | ||
| declare const types: { | ||
| string: { | ||
| to: number; | ||
| from: number[]; | ||
| serialize: (x: string | number | Date) => string; | ||
| parse: (x: string) => string; | ||
| }; | ||
| number: { | ||
| to: number; | ||
| from: number[]; | ||
| serialize: (x: number) => string; | ||
| parse: (x: string) => number; | ||
| }; | ||
| bigint: { | ||
| to: number; | ||
| from: number[]; | ||
| serialize: (x: bigint) => string; | ||
| parse: (x: string) => number | bigint; | ||
| }; | ||
| json: { | ||
| to: number; | ||
| from: number[]; | ||
| serialize: (x: any) => string; | ||
| parse: (x: string) => any; | ||
| }; | ||
| boolean: { | ||
| to: number; | ||
| from: number[]; | ||
| serialize: (x: boolean | number | string) => "t" | "f"; | ||
| parse: (x: string) => x is "t"; | ||
| }; | ||
| date: { | ||
| to: number; | ||
| from: number[]; | ||
| serialize: (x: Date | string | number) => string; | ||
| parse: (x: string | number) => Date; | ||
| }; | ||
| bytea: { | ||
| to: number; | ||
| from: number[]; | ||
| serialize: (x: Uint8Array) => string; | ||
| parse: (x: string) => Uint8Array; | ||
| }; | ||
| }; | ||
| type Parser = (x: string, typeId?: number) => any; | ||
| type Serializer = (x: any) => string; | ||
| type TypeHandler = { | ||
| to: number; | ||
| from: number | number[]; | ||
| serialize: Serializer; | ||
| parse: Parser; | ||
| }; | ||
| type TypeHandlers = { | ||
| [key: string]: TypeHandler; | ||
| }; | ||
| declare const parsers: { | ||
| [key: string]: (x: string, typeId?: number) => any; | ||
| [key: number]: (x: string, typeId?: number) => any; | ||
| }; | ||
| declare const serializers: { | ||
| [key: string]: Serializer; | ||
| [key: number]: Serializer; | ||
| }; | ||
| declare function parseType(x: string | null, type: number, parsers?: ParserOptions): any; | ||
| declare function arraySerializer(xs: any, serializer: Serializer | undefined, typarray: number): string; | ||
| declare function arrayParser(x: string, parser: Parser, typarray: number): any; | ||
| declare const types$1_ABSTIME: typeof ABSTIME; | ||
| declare const types$1_ACLITEM: typeof ACLITEM; | ||
| declare const types$1_BIT: typeof BIT; | ||
| declare const types$1_BOOL: typeof BOOL; | ||
| declare const types$1_BPCHAR: typeof BPCHAR; | ||
| declare const types$1_BYTEA: typeof BYTEA; | ||
| declare const types$1_CHAR: typeof CHAR; | ||
| declare const types$1_CID: typeof CID; | ||
| declare const types$1_CIDR: typeof CIDR; | ||
| declare const types$1_CIRCLE: typeof CIRCLE; | ||
| declare const types$1_DATE: typeof DATE; | ||
| declare const types$1_FLOAT4: typeof FLOAT4; | ||
| declare const types$1_FLOAT8: typeof FLOAT8; | ||
| declare const types$1_GTSVECTOR: typeof GTSVECTOR; | ||
| declare const types$1_INET: typeof INET; | ||
| declare const types$1_INT2: typeof INT2; | ||
| declare const types$1_INT4: typeof INT4; | ||
| declare const types$1_INT8: typeof INT8; | ||
| declare const types$1_INTERVAL: typeof INTERVAL; | ||
| declare const types$1_JSON: typeof JSON; | ||
| declare const types$1_JSONB: typeof JSONB; | ||
| declare const types$1_MACADDR: typeof MACADDR; | ||
| declare const types$1_MACADDR8: typeof MACADDR8; | ||
| declare const types$1_MONEY: typeof MONEY; | ||
| declare const types$1_NUMERIC: typeof NUMERIC; | ||
| declare const types$1_OID: typeof OID; | ||
| declare const types$1_PATH: typeof PATH; | ||
| declare const types$1_PG_DEPENDENCIES: typeof PG_DEPENDENCIES; | ||
| declare const types$1_PG_LSN: typeof PG_LSN; | ||
| declare const types$1_PG_NDISTINCT: typeof PG_NDISTINCT; | ||
| declare const types$1_PG_NODE_TREE: typeof PG_NODE_TREE; | ||
| declare const types$1_POLYGON: typeof POLYGON; | ||
| type types$1_Parser = Parser; | ||
| declare const types$1_REFCURSOR: typeof REFCURSOR; | ||
| declare const types$1_REGCLASS: typeof REGCLASS; | ||
| declare const types$1_REGCONFIG: typeof REGCONFIG; | ||
| declare const types$1_REGDICTIONARY: typeof REGDICTIONARY; | ||
| declare const types$1_REGNAMESPACE: typeof REGNAMESPACE; | ||
| declare const types$1_REGOPER: typeof REGOPER; | ||
| declare const types$1_REGOPERATOR: typeof REGOPERATOR; | ||
| declare const types$1_REGPROC: typeof REGPROC; | ||
| declare const types$1_REGPROCEDURE: typeof REGPROCEDURE; | ||
| declare const types$1_REGROLE: typeof REGROLE; | ||
| declare const types$1_REGTYPE: typeof REGTYPE; | ||
| declare const types$1_RELTIME: typeof RELTIME; | ||
| declare const types$1_SMGR: typeof SMGR; | ||
| type types$1_Serializer = Serializer; | ||
| declare const types$1_TEXT: typeof TEXT; | ||
| declare const types$1_TID: typeof TID; | ||
| declare const types$1_TIME: typeof TIME; | ||
| declare const types$1_TIMESTAMP: typeof TIMESTAMP; | ||
| declare const types$1_TIMESTAMPTZ: typeof TIMESTAMPTZ; | ||
| declare const types$1_TIMETZ: typeof TIMETZ; | ||
| declare const types$1_TINTERVAL: typeof TINTERVAL; | ||
| declare const types$1_TSQUERY: typeof TSQUERY; | ||
| declare const types$1_TSVECTOR: typeof TSVECTOR; | ||
| declare const types$1_TXID_SNAPSHOT: typeof TXID_SNAPSHOT; | ||
| type types$1_TypeHandler = TypeHandler; | ||
| type types$1_TypeHandlers = TypeHandlers; | ||
| declare const types$1_UUID: typeof UUID; | ||
| declare const types$1_VARBIT: typeof VARBIT; | ||
| declare const types$1_VARCHAR: typeof VARCHAR; | ||
| declare const types$1_XID: typeof XID; | ||
| declare const types$1_XML: typeof XML; | ||
| declare const types$1_arrayParser: typeof arrayParser; | ||
| declare const types$1_arraySerializer: typeof arraySerializer; | ||
| declare const types$1_parseType: typeof parseType; | ||
| declare const types$1_parsers: typeof parsers; | ||
| declare const types$1_serializers: typeof serializers; | ||
| declare const types$1_types: typeof types; | ||
| declare namespace types$1 { | ||
| export { types$1_ABSTIME as ABSTIME, types$1_ACLITEM as ACLITEM, types$1_BIT as BIT, types$1_BOOL as BOOL, types$1_BPCHAR as BPCHAR, types$1_BYTEA as BYTEA, types$1_CHAR as CHAR, types$1_CID as CID, types$1_CIDR as CIDR, types$1_CIRCLE as CIRCLE, types$1_DATE as DATE, types$1_FLOAT4 as FLOAT4, types$1_FLOAT8 as FLOAT8, types$1_GTSVECTOR as GTSVECTOR, types$1_INET as INET, types$1_INT2 as INT2, types$1_INT4 as INT4, types$1_INT8 as INT8, types$1_INTERVAL as INTERVAL, types$1_JSON as JSON, types$1_JSONB as JSONB, types$1_MACADDR as MACADDR, types$1_MACADDR8 as MACADDR8, types$1_MONEY as MONEY, types$1_NUMERIC as NUMERIC, types$1_OID as OID, types$1_PATH as PATH, types$1_PG_DEPENDENCIES as PG_DEPENDENCIES, types$1_PG_LSN as PG_LSN, types$1_PG_NDISTINCT as PG_NDISTINCT, types$1_PG_NODE_TREE as PG_NODE_TREE, types$1_POLYGON as POLYGON, type types$1_Parser as Parser, types$1_REFCURSOR as REFCURSOR, types$1_REGCLASS as REGCLASS, types$1_REGCONFIG as REGCONFIG, types$1_REGDICTIONARY as REGDICTIONARY, types$1_REGNAMESPACE as REGNAMESPACE, types$1_REGOPER as REGOPER, types$1_REGOPERATOR as REGOPERATOR, types$1_REGPROC as REGPROC, types$1_REGPROCEDURE as REGPROCEDURE, types$1_REGROLE as REGROLE, types$1_REGTYPE as REGTYPE, types$1_RELTIME as RELTIME, types$1_SMGR as SMGR, type types$1_Serializer as Serializer, types$1_TEXT as TEXT, types$1_TID as TID, types$1_TIME as TIME, types$1_TIMESTAMP as TIMESTAMP, types$1_TIMESTAMPTZ as TIMESTAMPTZ, types$1_TIMETZ as TIMETZ, types$1_TINTERVAL as TINTERVAL, types$1_TSQUERY as TSQUERY, types$1_TSVECTOR as TSVECTOR, types$1_TXID_SNAPSHOT as TXID_SNAPSHOT, type types$1_TypeHandler as TypeHandler, type types$1_TypeHandlers as TypeHandlers, types$1_UUID as UUID, types$1_VARBIT as VARBIT, types$1_VARCHAR as VARCHAR, types$1_XID as XID, types$1_XML as XML, types$1_arrayParser as arrayParser, types$1_arraySerializer as arraySerializer, types$1_parseType as parseType, types$1_parsers as parsers, types$1_serializers as serializers, types$1_types as types }; | ||
| } | ||
| declare abstract class BasePGlite implements Pick<PGliteInterface, 'query' | 'sql' | 'exec' | 'transaction'> { | ||
| #private; | ||
| serializers: Record<number | string, Serializer>; | ||
| parsers: Record<number | string, Parser>; | ||
| abstract debug: DebugLevel; | ||
| /** | ||
| * Execute a postgres wire protocol message | ||
| * @param message The postgres wire protocol message to execute | ||
| * @returns The result of the query | ||
| */ | ||
| abstract execProtocol(message: Uint8Array, { syncToFs, onNotice }: ExecProtocolOptions): Promise<ExecProtocolResult>; | ||
| /** | ||
| * Execute a postgres wire protocol message | ||
| * @param message The postgres wire protocol message to execute | ||
| * @returns The parsed results of the query | ||
| */ | ||
| abstract execProtocolStream(message: Uint8Array, { syncToFs, onNotice }: ExecProtocolOptions): Promise<BackendMessage[]>; | ||
| /** | ||
| * Execute a postgres wire protocol message directly without wrapping the response. | ||
| * Only use if `execProtocol()` doesn't suite your needs. | ||
| * | ||
| * **Warning:** This bypasses PGlite's protocol wrappers that manage error/notice messages, | ||
| * transactions, and notification listeners. Only use if you need to bypass these wrappers and | ||
| * don't intend to use the above features. | ||
| * | ||
| * @param message The postgres wire protocol message to execute | ||
| * @returns The direct message data response produced by Postgres | ||
| */ | ||
| abstract execProtocolRaw(message: Uint8Array, { syncToFs }: ExecProtocolOptions): Promise<Uint8Array>; | ||
| /** | ||
| * Execute a postgres wire protocol message directly without wrapping the response. | ||
| * Only use if `execProtocol()` doesn't suite your needs. | ||
| * | ||
| * **Warning:** This bypasses PGlite's protocol wrappers that manage error/notice messages, | ||
| * transactions, and notification listeners. Only use if you need to bypass these wrappers and | ||
| * don't intend to use the above features. | ||
| * | ||
| * @param message The postgres wire protocol message to execute | ||
| * @param options.onRawData Callback to receive streaming data | ||
| */ | ||
| abstract execProtocolRawStream(message: Uint8Array, { syncToFs, onRawData }: ExecProtocolOptionsStream): Promise<void>; | ||
| /** | ||
| * Sync the database to the filesystem | ||
| * @returns Promise that resolves when the database is synced to the filesystem | ||
| */ | ||
| abstract syncToFs(): Promise<void>; | ||
| /** | ||
| * Handle a file attached to the current query | ||
| * @param file The file to handle | ||
| */ | ||
| abstract _handleBlob(blob?: File | Blob): Promise<void>; | ||
| /** | ||
| * Get the written file | ||
| */ | ||
| abstract _getWrittenBlob(): Promise<File | Blob | undefined>; | ||
| /** | ||
| * Cleanup the current file | ||
| */ | ||
| abstract _cleanupBlob(): Promise<void>; | ||
| abstract _checkReady(): Promise<void>; | ||
| abstract _runExclusiveQuery<T>(fn: () => Promise<T>): Promise<T>; | ||
| abstract _runExclusiveTransaction<T>(fn: () => Promise<T>): Promise<T>; | ||
| /** | ||
| * Listen for notifications on a channel | ||
| */ | ||
| abstract listen(channel: string, callback: (payload: string) => void, tx?: Transaction): Promise<(tx?: Transaction) => Promise<void>>; | ||
| /** | ||
| * Initialize the array types | ||
| * The oid if the type of an element and the typarray is the oid of the type of the | ||
| * array. | ||
| * We extract these from the database then create the serializers/parsers for | ||
| * each type. | ||
| * This should be called at the end of #init() in the implementing class. | ||
| */ | ||
| _initArrayTypes({ force }?: { | ||
| force?: boolean | undefined; | ||
| }): Promise<void>; | ||
| /** | ||
| * Re-syncs the array types from the database | ||
| * This is useful if you add a new type to the database and want to use it, otherwise pglite won't recognize it. | ||
| */ | ||
| refreshArrayTypes(): Promise<void>; | ||
| /** | ||
| * Execute a single SQL statement | ||
| * This uses the "Extended Query" postgres wire protocol message. | ||
| * @param query The query to execute | ||
| * @param params Optional parameters for the query | ||
| * @returns The result of the query | ||
| */ | ||
| query<T>(query: string, params?: any[], options?: QueryOptions): Promise<Results<T>>; | ||
| /** | ||
| * Execute a single SQL statement like with {@link PGlite.query}, but with a | ||
| * templated statement where template values will be treated as parameters. | ||
| * | ||
| * You can use helpers from `/template` to further format the query with | ||
| * identifiers, raw SQL, and nested statements. | ||
| * | ||
| * This uses the "Extended Query" postgres wire protocol message. | ||
| * | ||
| * @param query The query to execute with parameters as template values | ||
| * @returns The result of the query | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * const results = await db.sql`SELECT * FROM ${identifier`foo`} WHERE id = ${id}` | ||
| * ``` | ||
| */ | ||
| sql<T>(sqlStrings: TemplateStringsArray, ...params: any[]): Promise<Results<T>>; | ||
| /** | ||
| * Execute a SQL query, this can have multiple statements. | ||
| * This uses the "Simple Query" postgres wire protocol message. | ||
| * @param query The query to execute | ||
| * @returns The result of the query | ||
| */ | ||
| exec(query: string, options?: QueryOptions): Promise<Array<Results>>; | ||
| /** | ||
| * Describe a query | ||
| * @param query The query to describe | ||
| * @returns A description of the result types for the query | ||
| */ | ||
| describeQuery(query: string, options?: QueryOptions): Promise<DescribeQueryResult>; | ||
| /** | ||
| * Execute a transaction | ||
| * @param callback A callback function that takes a transaction object | ||
| * @returns The result of the transaction | ||
| */ | ||
| transaction<T>(callback: (tx: Transaction) => Promise<T>): Promise<T>; | ||
| /** | ||
| * Run a function exclusively, no other transactions or queries will be allowed | ||
| * while the function is running. | ||
| * This is useful when working with the execProtocol methods as they are not blocked, | ||
| * and do not block the locks used by transactions and queries. | ||
| * @param fn The function to run | ||
| * @returns The result of the function | ||
| */ | ||
| runExclusive<T>(fn: () => Promise<T>): Promise<T>; | ||
| } | ||
| declare class PGlite extends BasePGlite implements PGliteInterface, AsyncDisposable { | ||
| #private; | ||
| fs?: Filesystem; | ||
| protected mod?: PostgresMod; | ||
| private readonly POSTGRES_MAIN_LONGJMP; | ||
| get ENV(): any; | ||
| readonly dataDir?: string; | ||
| readonly waitReady: Promise<void>; | ||
| readonly debug: DebugLevel; | ||
| static readonly paths: { | ||
| readonly PG_ROOT: "/pglite"; | ||
| readonly PGDATA: string; | ||
| readonly ICU_DATA_PATH: string; | ||
| readonly INITDB_EXE_PATH: string; | ||
| readonly POSTGRES_EXE_PATH: string; | ||
| }; | ||
| static readonly DEFAULT_RECV_BUF_SIZE: number; | ||
| static readonly MAX_BUFFER_SIZE: number; | ||
| externalCommandStreamFd: number | null; | ||
| static readonly defaultStartParams: string[]; | ||
| /** | ||
| * Create a new PGlite instance | ||
| * @param dataDir The directory to store the database files | ||
| * Prefix with idb:// to use indexeddb filesystem in the browser | ||
| * Use memory:// to use in-memory filesystem | ||
| * @param options PGlite options | ||
| */ | ||
| constructor(dataDir?: string, options?: PGliteOptions); | ||
| /** | ||
| * Create a new PGlite instance | ||
| * @param options PGlite options including the data directory | ||
| */ | ||
| constructor(options?: PGliteOptions); | ||
| /** | ||
| * Create a new PGlite instance with extensions on the Typescript interface | ||
| * (The main constructor does enable extensions, however due to the limitations | ||
| * of Typescript, the extensions are not available on the instance interface) | ||
| * @param options PGlite options including the data directory | ||
| * @returns A promise that resolves to the PGlite instance when it's ready. | ||
| */ | ||
| static create<O extends PGliteOptions>(options?: O): Promise<PGlite & PGliteInterfaceExtensions<O['extensions']>>; | ||
| /** | ||
| * Create a new PGlite instance with extensions on the Typescript interface | ||
| * (The main constructor does enable extensions, however due to the limitations | ||
| * of Typescript, the extensions are not available on the instance interface) | ||
| * @param dataDir The directory to store the database files | ||
| * Prefix with idb:// to use indexeddb filesystem in the browser | ||
| * Use memory:// to use in-memory filesystem | ||
| * @param options PGlite options | ||
| * @returns A promise that resolves to the PGlite instance when it's ready. | ||
| */ | ||
| static create<O extends PGliteOptions>(dataDir?: string, options?: O): Promise<PGlite & PGliteInterfaceExtensions<O['extensions']>>; | ||
| handleExternalCmd(cmd: string, mode: string): number; | ||
| /** | ||
| * The Postgres Emscripten Module | ||
| */ | ||
| get Module(): PostgresMod; | ||
| /** | ||
| * The ready state of the database | ||
| */ | ||
| get ready(): boolean; | ||
| /** | ||
| * The closed state of the database | ||
| */ | ||
| get closed(): boolean; | ||
| /** | ||
| * Close the database | ||
| * @returns A promise that resolves when the database is closed | ||
| */ | ||
| close(): Promise<void>; | ||
| /** | ||
| * Close the database when the object exits scope | ||
| * Stage 3 ECMAScript Explicit Resource Management | ||
| * https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-2.html#using-declarations-and-explicit-resource-management | ||
| */ | ||
| [Symbol.asyncDispose](): Promise<void>; | ||
| /** | ||
| * Handle a file attached to the current query | ||
| * @param file The file to handle | ||
| */ | ||
| _handleBlob(blob?: File | Blob): Promise<void>; | ||
| /** | ||
| * Cleanup the current file | ||
| */ | ||
| _cleanupBlob(): Promise<void>; | ||
| /** | ||
| * Get the written blob from the current query | ||
| * @returns The written blob | ||
| */ | ||
| _getWrittenBlob(): Promise<Blob | undefined>; | ||
| /** | ||
| * Wait for the database to be ready | ||
| */ | ||
| _checkReady(): Promise<void>; | ||
| /** | ||
| * Execute a postgres wire protocol synchronously | ||
| * @param message The postgres wire protocol message to execute | ||
| * @returns The direct message data response produced by Postgres | ||
| */ | ||
| execProtocolRawSync(message: Uint8Array): Uint8Array; | ||
| /** | ||
| * Execute a postgres wire protocol message directly without wrapping the response. | ||
| * Only use if `execProtocol()` doesn't suite your needs. | ||
| * | ||
| * **Warning:** This bypasses PGlite's protocol wrappers that manage error/notice messages, | ||
| * transactions, and notification listeners. Only use if you need to bypass these wrappers and | ||
| * don't intend to use the above features. | ||
| * | ||
| * @param message The postgres wire protocol message to execute | ||
| * @returns The direct message data response produced by Postgres | ||
| */ | ||
| execProtocolRaw(message: Uint8Array, { syncToFs }?: ExecProtocolOptions): Promise<Uint8Array>; | ||
| /** | ||
| * Execute a postgres wire protocol message directly without wrapping the response. | ||
| * Only use if `execProtocol()` doesn't suite your needs. | ||
| * | ||
| * **Warning:** This bypasses PGlite's protocol wrappers that manage error/notice messages, | ||
| * transactions, and notification listeners. Only use if you need to bypass these wrappers and | ||
| * don't intend to use the above features. | ||
| * | ||
| * @param message The postgres wire protocol message to execute | ||
| * @param options.onRawData Callback to receive results as streaming data | ||
| */ | ||
| execProtocolRawStream(message: Uint8Array, { syncToFs, onRawData }: ExecProtocolOptionsStream): Promise<void>; | ||
| /** | ||
| * Execute a postgres wire protocol message | ||
| * @param message The postgres wire protocol message to execute | ||
| * @returns The result of the query | ||
| */ | ||
| execProtocol(message: Uint8Array, { syncToFs, throwOnError, onNotice, }?: ExecProtocolOptions): Promise<ExecProtocolResult>; | ||
| /** | ||
| * Execute a postgres wire protocol message | ||
| * @param message The postgres wire protocol message to execute | ||
| * @returns The parsed results of the query | ||
| */ | ||
| execProtocolStream(message: Uint8Array, { syncToFs, throwOnError, onNotice }?: ExecProtocolOptions): Promise<BackendMessage[]>; | ||
| /** | ||
| * Check if the database is in a transaction | ||
| * @returns True if the database is in a transaction, false otherwise | ||
| */ | ||
| isInTransaction(): boolean; | ||
| /** | ||
| * Perform any sync operations implemented by the filesystem, this is | ||
| * run after every query to ensure that the filesystem is synced. | ||
| */ | ||
| syncToFs(): Promise<void>; | ||
| /** | ||
| * Listen for a notification | ||
| * @param channel The channel to listen on | ||
| * @param callback The callback to call when a notification is received | ||
| */ | ||
| listen(channel: string, callback: (payload: string) => void, tx?: Transaction): Promise<(tx?: Transaction) => Promise<void>>; | ||
| /** | ||
| * Stop listening for a notification | ||
| * @param channel The channel to stop listening on | ||
| * @param callback The callback to remove | ||
| */ | ||
| unlisten(channel: string, callback?: (payload: string) => void, tx?: Transaction): Promise<void>; | ||
| /** | ||
| * Listen to notifications | ||
| * @param callback The callback to call when a notification is received | ||
| */ | ||
| onNotification(callback: (channel: string, payload: string) => void): () => void; | ||
| /** | ||
| * Stop listening to notifications | ||
| * @param callback The callback to remove | ||
| */ | ||
| offNotification(callback: (channel: string, payload: string) => void): void; | ||
| /** | ||
| * Dump the PGDATA dir from the filesystem to a gzipped tarball. | ||
| * @param compression The compression options to use - 'gzip', 'auto', 'none' | ||
| * @returns The tarball as a File object where available, and fallback to a Blob | ||
| */ | ||
| dumpDataDir(compression?: DumpTarCompressionOptions): Promise<File | Blob>; | ||
| /** | ||
| * Run a function in a mutex that's exclusive to queries | ||
| * @param fn The query to run | ||
| * @returns The result of the query | ||
| */ | ||
| _runExclusiveQuery<T>(fn: () => Promise<T>): Promise<T>; | ||
| /** | ||
| * Run a function in a mutex that's exclusive to transactions | ||
| * @param fn The function to run | ||
| * @returns The result of the function | ||
| */ | ||
| _runExclusiveTransaction<T>(fn: () => Promise<T>): Promise<T>; | ||
| clone(): Promise<PGliteInterface>; | ||
| _runExclusiveListen<T>(fn: () => Promise<T>): Promise<T>; | ||
| callMain(args: string[]): number; | ||
| copyToFS(filePath: string, data: Uint8Array, mode?: number): void; | ||
| } | ||
| export { type FsType as A, type BackendMessage as B, type Filesystem as C, type DebugLevel as D, EmscriptenBuiltinFilesystem as E, type FilesystemType as F, ERRNO_CODES as G, type InitializedExtensions as I, type Mode as M, type Parser as P, type QueryOptions as Q, type Results as R, type SerializerOptions as S, type Transaction as T, type BufferParameter as a, PGlite as b, type PostgresMod as c, type PGliteInterface as d, type RowMode as e, type ParserOptions as f, type ExecProtocolOptions as g, type ExecProtocolOptionsStream as h, type ExtensionSetupResult as i, type ExtensionSetup as j, type Extension as k, type ExtensionNamespace as l, messages as m, type Extensions as n, type ExecProtocolResult as o, postgresMod as p, type DumpDataDirResult as q, type PGliteOptions as r, type PGliteInterfaceExtensions as s, types$1 as t, type Row as u, type DescribeQueryResult as v, BaseFilesystem as w, type FsStats as x, BasePGlite as y, type DumpTarCompressionOptions as z }; |
| declare const Modes: { | ||
| readonly text: 0; | ||
| readonly binary: 1; | ||
| }; | ||
| type Mode = (typeof Modes)[keyof typeof Modes]; | ||
| type BufferParameter = ArrayBuffer | ArrayBufferView; | ||
| type MessageName = 'parseComplete' | 'bindComplete' | 'closeComplete' | 'noData' | 'portalSuspended' | 'replicationStart' | 'emptyQuery' | 'copyDone' | 'copyData' | 'rowDescription' | 'parameterDescription' | 'parameterStatus' | 'backendKeyData' | 'notification' | 'readyForQuery' | 'commandComplete' | 'dataRow' | 'copyInResponse' | 'copyOutResponse' | 'authenticationOk' | 'authenticationMD5Password' | 'authenticationCleartextPassword' | 'authenticationSASL' | 'authenticationSASLContinue' | 'authenticationSASLFinal' | 'error' | 'notice'; | ||
| type BackendMessage = { | ||
| name: MessageName; | ||
| length: number; | ||
| }; | ||
| declare const parseComplete: BackendMessage; | ||
| declare const bindComplete: BackendMessage; | ||
| declare const closeComplete: BackendMessage; | ||
| declare const noData: BackendMessage; | ||
| declare const portalSuspended: BackendMessage; | ||
| declare const replicationStart: BackendMessage; | ||
| declare const emptyQuery: BackendMessage; | ||
| declare const copyDone: BackendMessage; | ||
| declare class AuthenticationOk implements BackendMessage { | ||
| readonly length: number; | ||
| readonly name = "authenticationOk"; | ||
| constructor(length: number); | ||
| } | ||
| declare class AuthenticationCleartextPassword implements BackendMessage { | ||
| readonly length: number; | ||
| readonly name = "authenticationCleartextPassword"; | ||
| constructor(length: number); | ||
| } | ||
| declare class AuthenticationMD5Password implements BackendMessage { | ||
| readonly length: number; | ||
| readonly salt: Uint8Array; | ||
| readonly name = "authenticationMD5Password"; | ||
| constructor(length: number, salt: Uint8Array); | ||
| } | ||
| declare class AuthenticationSASL implements BackendMessage { | ||
| readonly length: number; | ||
| readonly mechanisms: string[]; | ||
| readonly name = "authenticationSASL"; | ||
| constructor(length: number, mechanisms: string[]); | ||
| } | ||
| declare class AuthenticationSASLContinue implements BackendMessage { | ||
| readonly length: number; | ||
| readonly data: string; | ||
| readonly name = "authenticationSASLContinue"; | ||
| constructor(length: number, data: string); | ||
| } | ||
| declare class AuthenticationSASLFinal implements BackendMessage { | ||
| readonly length: number; | ||
| readonly data: string; | ||
| readonly name = "authenticationSASLFinal"; | ||
| constructor(length: number, data: string); | ||
| } | ||
| type AuthenticationMessage = AuthenticationOk | AuthenticationCleartextPassword | AuthenticationMD5Password | AuthenticationSASL | AuthenticationSASLContinue | AuthenticationSASLFinal; | ||
| interface NoticeOrError { | ||
| message: string | undefined; | ||
| severity: string | undefined; | ||
| code: string | undefined; | ||
| detail: string | undefined; | ||
| hint: string | undefined; | ||
| position: string | undefined; | ||
| internalPosition: string | undefined; | ||
| internalQuery: string | undefined; | ||
| where: string | undefined; | ||
| schema: string | undefined; | ||
| table: string | undefined; | ||
| column: string | undefined; | ||
| dataType: string | undefined; | ||
| constraint: string | undefined; | ||
| file: string | undefined; | ||
| line: string | undefined; | ||
| routine: string | undefined; | ||
| } | ||
| declare class DatabaseError extends Error implements NoticeOrError { | ||
| readonly length: number; | ||
| readonly name: MessageName; | ||
| severity: string | undefined; | ||
| code: string | undefined; | ||
| detail: string | undefined; | ||
| hint: string | undefined; | ||
| position: string | undefined; | ||
| internalPosition: string | undefined; | ||
| internalQuery: string | undefined; | ||
| where: string | undefined; | ||
| schema: string | undefined; | ||
| table: string | undefined; | ||
| column: string | undefined; | ||
| dataType: string | undefined; | ||
| constraint: string | undefined; | ||
| file: string | undefined; | ||
| line: string | undefined; | ||
| routine: string | undefined; | ||
| constructor(message: string, length: number, name: MessageName); | ||
| } | ||
| declare class CopyDataMessage implements BackendMessage { | ||
| readonly length: number; | ||
| readonly chunk: Uint8Array; | ||
| readonly name = "copyData"; | ||
| constructor(length: number, chunk: Uint8Array); | ||
| } | ||
| declare class CopyResponse implements BackendMessage { | ||
| readonly length: number; | ||
| readonly name: MessageName; | ||
| readonly binary: boolean; | ||
| readonly columnTypes: number[]; | ||
| constructor(length: number, name: MessageName, binary: boolean, columnCount: number); | ||
| } | ||
| declare class Field { | ||
| readonly name: string; | ||
| readonly tableID: number; | ||
| readonly columnID: number; | ||
| readonly dataTypeID: number; | ||
| readonly dataTypeSize: number; | ||
| readonly dataTypeModifier: number; | ||
| readonly format: Mode; | ||
| constructor(name: string, tableID: number, columnID: number, dataTypeID: number, dataTypeSize: number, dataTypeModifier: number, format: Mode); | ||
| } | ||
| declare class RowDescriptionMessage implements BackendMessage { | ||
| readonly length: number; | ||
| readonly fieldCount: number; | ||
| readonly name: MessageName; | ||
| readonly fields: Field[]; | ||
| constructor(length: number, fieldCount: number); | ||
| } | ||
| declare class ParameterDescriptionMessage implements BackendMessage { | ||
| readonly length: number; | ||
| readonly parameterCount: number; | ||
| readonly name: MessageName; | ||
| readonly dataTypeIDs: number[]; | ||
| constructor(length: number, parameterCount: number); | ||
| } | ||
| declare class ParameterStatusMessage implements BackendMessage { | ||
| readonly length: number; | ||
| readonly parameterName: string; | ||
| readonly parameterValue: string; | ||
| readonly name: MessageName; | ||
| constructor(length: number, parameterName: string, parameterValue: string); | ||
| } | ||
| declare class BackendKeyDataMessage implements BackendMessage { | ||
| readonly length: number; | ||
| readonly processID: number; | ||
| readonly secretKey: number; | ||
| readonly name: MessageName; | ||
| constructor(length: number, processID: number, secretKey: number); | ||
| } | ||
| declare class NotificationResponseMessage implements BackendMessage { | ||
| readonly length: number; | ||
| readonly processId: number; | ||
| readonly channel: string; | ||
| readonly payload: string; | ||
| readonly name: MessageName; | ||
| constructor(length: number, processId: number, channel: string, payload: string); | ||
| } | ||
| declare class ReadyForQueryMessage implements BackendMessage { | ||
| readonly length: number; | ||
| readonly status: string; | ||
| readonly name: MessageName; | ||
| constructor(length: number, status: string); | ||
| } | ||
| declare class CommandCompleteMessage implements BackendMessage { | ||
| readonly length: number; | ||
| readonly text: string; | ||
| readonly name: MessageName; | ||
| constructor(length: number, text: string); | ||
| } | ||
| declare class DataRowMessage implements BackendMessage { | ||
| length: number; | ||
| fields: (string | null)[]; | ||
| readonly fieldCount: number; | ||
| readonly name: MessageName; | ||
| constructor(length: number, fields: (string | null)[]); | ||
| } | ||
| declare class NoticeMessage implements BackendMessage, NoticeOrError { | ||
| readonly length: number; | ||
| readonly message: string | undefined; | ||
| constructor(length: number, message: string | undefined); | ||
| readonly name = "notice"; | ||
| severity: string | undefined; | ||
| code: string | undefined; | ||
| detail: string | undefined; | ||
| hint: string | undefined; | ||
| position: string | undefined; | ||
| internalPosition: string | undefined; | ||
| internalQuery: string | undefined; | ||
| where: string | undefined; | ||
| schema: string | undefined; | ||
| table: string | undefined; | ||
| column: string | undefined; | ||
| dataType: string | undefined; | ||
| constraint: string | undefined; | ||
| file: string | undefined; | ||
| line: string | undefined; | ||
| routine: string | undefined; | ||
| } | ||
| type messages_AuthenticationCleartextPassword = AuthenticationCleartextPassword; | ||
| declare const messages_AuthenticationCleartextPassword: typeof AuthenticationCleartextPassword; | ||
| type messages_AuthenticationMD5Password = AuthenticationMD5Password; | ||
| declare const messages_AuthenticationMD5Password: typeof AuthenticationMD5Password; | ||
| type messages_AuthenticationMessage = AuthenticationMessage; | ||
| type messages_AuthenticationOk = AuthenticationOk; | ||
| declare const messages_AuthenticationOk: typeof AuthenticationOk; | ||
| type messages_AuthenticationSASL = AuthenticationSASL; | ||
| declare const messages_AuthenticationSASL: typeof AuthenticationSASL; | ||
| type messages_AuthenticationSASLContinue = AuthenticationSASLContinue; | ||
| declare const messages_AuthenticationSASLContinue: typeof AuthenticationSASLContinue; | ||
| type messages_AuthenticationSASLFinal = AuthenticationSASLFinal; | ||
| declare const messages_AuthenticationSASLFinal: typeof AuthenticationSASLFinal; | ||
| type messages_BackendKeyDataMessage = BackendKeyDataMessage; | ||
| declare const messages_BackendKeyDataMessage: typeof BackendKeyDataMessage; | ||
| type messages_BackendMessage = BackendMessage; | ||
| type messages_CommandCompleteMessage = CommandCompleteMessage; | ||
| declare const messages_CommandCompleteMessage: typeof CommandCompleteMessage; | ||
| type messages_CopyDataMessage = CopyDataMessage; | ||
| declare const messages_CopyDataMessage: typeof CopyDataMessage; | ||
| type messages_CopyResponse = CopyResponse; | ||
| declare const messages_CopyResponse: typeof CopyResponse; | ||
| type messages_DataRowMessage = DataRowMessage; | ||
| declare const messages_DataRowMessage: typeof DataRowMessage; | ||
| type messages_DatabaseError = DatabaseError; | ||
| declare const messages_DatabaseError: typeof DatabaseError; | ||
| type messages_Field = Field; | ||
| declare const messages_Field: typeof Field; | ||
| type messages_MessageName = MessageName; | ||
| type messages_NoticeMessage = NoticeMessage; | ||
| declare const messages_NoticeMessage: typeof NoticeMessage; | ||
| type messages_NotificationResponseMessage = NotificationResponseMessage; | ||
| declare const messages_NotificationResponseMessage: typeof NotificationResponseMessage; | ||
| type messages_ParameterDescriptionMessage = ParameterDescriptionMessage; | ||
| declare const messages_ParameterDescriptionMessage: typeof ParameterDescriptionMessage; | ||
| type messages_ParameterStatusMessage = ParameterStatusMessage; | ||
| declare const messages_ParameterStatusMessage: typeof ParameterStatusMessage; | ||
| type messages_ReadyForQueryMessage = ReadyForQueryMessage; | ||
| declare const messages_ReadyForQueryMessage: typeof ReadyForQueryMessage; | ||
| type messages_RowDescriptionMessage = RowDescriptionMessage; | ||
| declare const messages_RowDescriptionMessage: typeof RowDescriptionMessage; | ||
| declare const messages_bindComplete: typeof bindComplete; | ||
| declare const messages_closeComplete: typeof closeComplete; | ||
| declare const messages_copyDone: typeof copyDone; | ||
| declare const messages_emptyQuery: typeof emptyQuery; | ||
| declare const messages_noData: typeof noData; | ||
| declare const messages_parseComplete: typeof parseComplete; | ||
| declare const messages_portalSuspended: typeof portalSuspended; | ||
| declare const messages_replicationStart: typeof replicationStart; | ||
| declare namespace messages { | ||
| export { messages_AuthenticationCleartextPassword as AuthenticationCleartextPassword, messages_AuthenticationMD5Password as AuthenticationMD5Password, type messages_AuthenticationMessage as AuthenticationMessage, messages_AuthenticationOk as AuthenticationOk, messages_AuthenticationSASL as AuthenticationSASL, messages_AuthenticationSASLContinue as AuthenticationSASLContinue, messages_AuthenticationSASLFinal as AuthenticationSASLFinal, messages_BackendKeyDataMessage as BackendKeyDataMessage, type messages_BackendMessage as BackendMessage, messages_CommandCompleteMessage as CommandCompleteMessage, messages_CopyDataMessage as CopyDataMessage, messages_CopyResponse as CopyResponse, messages_DataRowMessage as DataRowMessage, messages_DatabaseError as DatabaseError, messages_Field as Field, type messages_MessageName as MessageName, messages_NoticeMessage as NoticeMessage, messages_NotificationResponseMessage as NotificationResponseMessage, messages_ParameterDescriptionMessage as ParameterDescriptionMessage, messages_ParameterStatusMessage as ParameterStatusMessage, messages_ReadyForQueryMessage as ReadyForQueryMessage, messages_RowDescriptionMessage as RowDescriptionMessage, messages_bindComplete as bindComplete, messages_closeComplete as closeComplete, messages_copyDone as copyDone, messages_emptyQuery as emptyQuery, messages_noData as noData, messages_parseComplete as parseComplete, messages_portalSuspended as portalSuspended, messages_replicationStart as replicationStart }; | ||
| } | ||
| type IDBFS = Emscripten.FileSystemType & { | ||
| quit: () => void; | ||
| dbs: Record<string, IDBDatabase>; | ||
| }; | ||
| type FS = typeof FS & { | ||
| filesystems: { | ||
| MEMFS: Emscripten.FileSystemType; | ||
| NODEFS: Emscripten.FileSystemType; | ||
| IDBFS: IDBFS; | ||
| }; | ||
| quit: () => void; | ||
| }; | ||
| interface PostgresMod extends Omit<EmscriptenModule, 'preInit' | 'preRun' | 'postRun'> { | ||
| preInit: Array<{ | ||
| (mod: PostgresMod): void; | ||
| }>; | ||
| preRun: Array<{ | ||
| (mod: PostgresMod): void; | ||
| }>; | ||
| postRun: Array<{ | ||
| (mod: PostgresMod): void; | ||
| }>; | ||
| thisProgram: string; | ||
| stdin: (() => number | null) | null; | ||
| FS: FS; | ||
| wasmMemory: WebAssembly.Memory; | ||
| PROXYFS: Emscripten.FileSystemType; | ||
| WASM_PREFIX: string; | ||
| pg_extensions: Record<string, Promise<Blob | null>>; | ||
| UTF8ToString: (ptr: number, maxBytesToRead?: number) => string; | ||
| stringToUTF8OnStack: (s: string) => number; | ||
| _pgl_set_system_fn: (system_fn: number) => void; | ||
| _pgl_set_popen_fn: (popen_fn: number) => void; | ||
| _pgl_set_pclose_fn: (pclose_fn: number) => void; | ||
| _pgl_set_rw_cbs: (read_cb: number, write_cb: number) => void; | ||
| _pgl_set_pipe_fn: (pipe_fn: number) => number; | ||
| _pgl_freopen: (filepath: number, mode: number, stream: number) => number; | ||
| _pgl_pq_flush: () => void; | ||
| _fopen: (path: number, mode: number) => number; | ||
| _fclose: (stream: number) => number; | ||
| _fflush: (stream: number) => void; | ||
| _pgl_proc_exit: (code: number) => number; | ||
| addFunction: (cb: (ptr: any, length: number) => void, signature: string) => number; | ||
| removeFunction: (f: number) => void; | ||
| callMain: (args?: string[]) => number; | ||
| _PostgresMainLoopOnce: () => void; | ||
| _PostgresMainLongJmp: () => void; | ||
| _PostgresSendReadyForQueryIfNecessary: () => void; | ||
| _ProcessStartupPacket: (Port: number, ssl_done: boolean, gss_done: boolean) => number; | ||
| _IsTransactionBlock: () => number; | ||
| _pgl_setPGliteActive: (newValue: number) => number; | ||
| _pgl_startPGlite: () => void; | ||
| _pgl_getMyProcPort: () => number; | ||
| _pgl_sendConnData: () => void; | ||
| ENV: any; | ||
| PGLITE_ENV: any; | ||
| _emscripten_force_exit: (status: number) => void; | ||
| _pgl_run_atexit_funcs: () => void; | ||
| _pq_buffer_remaining_data: () => number; | ||
| } | ||
| type PostgresFactory<T extends PostgresMod = PostgresMod> = (moduleOverrides?: Partial<T>) => Promise<T>; | ||
| declare const _default: PostgresFactory<PostgresMod>; | ||
| type postgresMod_FS = FS; | ||
| type postgresMod_PostgresMod = PostgresMod; | ||
| declare namespace postgresMod { | ||
| export { type postgresMod_FS as FS, type postgresMod_PostgresMod as PostgresMod, _default as default }; | ||
| } | ||
| type DumpTarCompressionOptions = 'none' | 'gzip' | 'auto'; | ||
| type FsType = 'nodefs' | 'idbfs' | 'memoryfs' | 'opfs-ahp'; | ||
| /** | ||
| * Filesystem interface. | ||
| * All virtual filesystems that are compatible with PGlite must implement | ||
| * this interface. | ||
| */ | ||
| interface Filesystem { | ||
| /** | ||
| * Initiate the filesystem and return the options to pass to the emscripten module. | ||
| */ | ||
| init(pg: PGlite, emscriptenOptions: Partial<PostgresMod>): Promise<{ | ||
| emscriptenOpts: Partial<PostgresMod>; | ||
| }>; | ||
| /** | ||
| * Sync the filesystem to any underlying storage. | ||
| */ | ||
| syncToFs(relaxedDurability?: boolean): Promise<void>; | ||
| /** | ||
| * Sync the filesystem from any underlying storage. | ||
| */ | ||
| initialSyncFs(): Promise<void>; | ||
| /** | ||
| * Dump the PGDATA dir from the filesystem to a gzipped tarball. | ||
| */ | ||
| dumpTar(dbname: string, compression?: DumpTarCompressionOptions): Promise<File | Blob>; | ||
| /** | ||
| * Close the filesystem. | ||
| */ | ||
| closeFs(): Promise<void>; | ||
| } | ||
| /** | ||
| * Base class for all emscripten built-in filesystems. | ||
| */ | ||
| declare class EmscriptenBuiltinFilesystem implements Filesystem { | ||
| protected dataDir?: string; | ||
| protected pg?: PGlite; | ||
| constructor(dataDir?: string); | ||
| init(pg: PGlite, emscriptenOptions: Partial<PostgresMod>): Promise<{ | ||
| emscriptenOpts: Partial<PostgresMod>; | ||
| }>; | ||
| syncToFs(_relaxedDurability?: boolean): Promise<void>; | ||
| initialSyncFs(): Promise<void>; | ||
| closeFs(): Promise<void>; | ||
| dumpTar(dbname: string, compression?: DumpTarCompressionOptions): Promise<Blob | File>; | ||
| } | ||
| /** | ||
| * Abstract base class for all custom virtual filesystems. | ||
| * Each custom filesystem needs to implement an interface similar to the NodeJS FS API. | ||
| */ | ||
| declare abstract class BaseFilesystem implements Filesystem { | ||
| protected dataDir?: string; | ||
| protected pg?: PGlite; | ||
| readonly debug: boolean; | ||
| constructor(dataDir?: string, { debug }?: { | ||
| debug?: boolean; | ||
| }); | ||
| syncToFs(_relaxedDurability?: boolean): Promise<void>; | ||
| initialSyncFs(): Promise<void>; | ||
| closeFs(): Promise<void>; | ||
| dumpTar(dbname: string, compression?: DumpTarCompressionOptions): Promise<Blob | File>; | ||
| init(pg: PGlite, emscriptenOptions: Partial<PostgresMod>): Promise<{ | ||
| emscriptenOpts: Partial<PostgresMod>; | ||
| }>; | ||
| abstract chmod(path: string, mode: number): void; | ||
| abstract close(fd: number): void; | ||
| abstract fstat(fd: number): FsStats; | ||
| abstract lstat(path: string): FsStats; | ||
| abstract mkdir(path: string, options?: { | ||
| recursive?: boolean; | ||
| mode?: number; | ||
| }): void; | ||
| abstract open(path: string, flags?: string, mode?: number): number; | ||
| abstract readdir(path: string): string[]; | ||
| abstract read(fd: number, buffer: Uint8Array, // Buffer to read into | ||
| offset: number, // Offset in buffer to start writing to | ||
| length: number, // Number of bytes to read | ||
| position: number): number; | ||
| abstract rename(oldPath: string, newPath: string): void; | ||
| abstract rmdir(path: string): void; | ||
| abstract truncate(path: string, len: number): void; | ||
| abstract unlink(path: string): void; | ||
| abstract utimes(path: string, atime: number, mtime: number): void; | ||
| abstract writeFile(path: string, data: string | Uint8Array, options?: { | ||
| encoding?: string; | ||
| mode?: number; | ||
| flag?: string; | ||
| }): void; | ||
| abstract write(fd: number, buffer: Uint8Array, // Buffer to read from | ||
| offset: number, // Offset in buffer to start reading from | ||
| length: number, // Number of bytes to write | ||
| position: number): number; | ||
| } | ||
| type FsStats = { | ||
| dev: number; | ||
| ino: number; | ||
| mode: number; | ||
| nlink: number; | ||
| uid: number; | ||
| gid: number; | ||
| rdev: number; | ||
| size: number; | ||
| blksize: number; | ||
| blocks: number; | ||
| atime: number; | ||
| mtime: number; | ||
| ctime: number; | ||
| }; | ||
| declare const ERRNO_CODES: { | ||
| readonly EBADF: 8; | ||
| readonly EBADFD: 127; | ||
| readonly EEXIST: 20; | ||
| readonly EINVAL: 28; | ||
| readonly EISDIR: 31; | ||
| readonly ENODEV: 43; | ||
| readonly ENOENT: 44; | ||
| readonly ENOTDIR: 54; | ||
| readonly ENOTEMPTY: 55; | ||
| }; | ||
| type FilesystemType = 'nodefs' | 'idbfs' | 'memoryfs'; | ||
| type DebugLevel = 0 | 1 | 2 | 3 | 4 | 5; | ||
| type RowMode = 'array' | 'object'; | ||
| interface ParserOptions { | ||
| [pgType: number]: (value: string) => any; | ||
| } | ||
| interface SerializerOptions { | ||
| [pgType: number]: (value: any) => string; | ||
| } | ||
| interface QueryOptions { | ||
| rowMode?: RowMode; | ||
| parsers?: ParserOptions; | ||
| serializers?: SerializerOptions; | ||
| blob?: Blob | File; | ||
| onNotice?: (notice: NoticeMessage) => void; | ||
| paramTypes?: number[]; | ||
| } | ||
| interface ExecProtocolOptions { | ||
| syncToFs?: boolean; | ||
| throwOnError?: boolean; | ||
| onNotice?: (notice: NoticeMessage) => void; | ||
| } | ||
| interface ExecProtocolOptionsStream { | ||
| syncToFs?: boolean; | ||
| onRawData: (data: Uint8Array) => void; | ||
| } | ||
| interface ExtensionSetupResult<TNamespace = any> { | ||
| emscriptenOpts?: any; | ||
| namespaceObj?: TNamespace; | ||
| bundlePath?: URL; | ||
| sharedPreloadLibraries?: string[]; | ||
| init?: () => Promise<void>; | ||
| close?: () => Promise<void>; | ||
| } | ||
| type ExtensionSetup<TNamespace = any> = (pg: PGliteInterface, emscriptenOpts: any, clientOnly?: boolean) => Promise<ExtensionSetupResult<TNamespace>>; | ||
| interface Extension<TNamespace = any> { | ||
| name: string; | ||
| setup: ExtensionSetup<TNamespace>; | ||
| } | ||
| type ExtensionNamespace<T> = T extends Extension<infer TNamespace> ? TNamespace : any; | ||
| type Extensions = { | ||
| [namespace: string]: Extension | URL; | ||
| }; | ||
| type InitializedExtensions<TExtensions extends Extensions = Extensions> = { | ||
| [K in keyof TExtensions]: ExtensionNamespace<TExtensions[K]>; | ||
| }; | ||
| interface ExecProtocolResult { | ||
| messages: BackendMessage[]; | ||
| data: Uint8Array; | ||
| } | ||
| interface DumpDataDirResult { | ||
| tarball: Uint8Array; | ||
| extension: '.tar' | '.tgz'; | ||
| filename: string; | ||
| } | ||
| interface PGliteOptions<TExtensions extends Extensions = Extensions> { | ||
| noInitDb?: boolean; | ||
| dataDir?: string; | ||
| username?: string; | ||
| database?: string; | ||
| fs?: Filesystem; | ||
| debug?: DebugLevel; | ||
| relaxedDurability?: boolean; | ||
| extensions?: TExtensions; | ||
| loadDataDir?: Blob | File; | ||
| icuDataDir?: Blob | File; | ||
| initialMemory?: number; | ||
| pgliteWasmModule?: WebAssembly.Module; | ||
| initdbWasmModule?: WebAssembly.Module; | ||
| fsBundle?: Blob | File; | ||
| parsers?: ParserOptions; | ||
| serializers?: SerializerOptions; | ||
| startParams?: string[]; | ||
| initDbStartParams?: string[]; | ||
| postgresqlconf?: string[] | string; | ||
| } | ||
| type PGliteInterface<T extends Extensions = Extensions> = InitializedExtensions<T> & { | ||
| readonly waitReady: Promise<void>; | ||
| readonly debug: DebugLevel; | ||
| readonly ready: boolean; | ||
| readonly closed: boolean; | ||
| close(): Promise<void>; | ||
| query<T>(query: string, params?: any[], options?: QueryOptions): Promise<Results<T>>; | ||
| sql<T>(sqlStrings: TemplateStringsArray, ...params: any[]): Promise<Results<T>>; | ||
| exec(query: string, options?: QueryOptions): Promise<Array<Results>>; | ||
| describeQuery(query: string): Promise<DescribeQueryResult>; | ||
| transaction<T>(callback: (tx: Transaction) => Promise<T>): Promise<T>; | ||
| execProtocolRaw(message: Uint8Array, options?: ExecProtocolOptions): Promise<Uint8Array>; | ||
| execProtocolRawStream(message: Uint8Array, options?: ExecProtocolOptionsStream): Promise<void>; | ||
| execProtocol(message: Uint8Array, options?: ExecProtocolOptions): Promise<ExecProtocolResult>; | ||
| runExclusive<T>(fn: () => Promise<T>): Promise<T>; | ||
| listen(channel: string, callback: (payload: string) => void, tx?: Transaction): Promise<(tx?: Transaction) => Promise<void>>; | ||
| unlisten(channel: string, callback?: (payload: string) => void, tx?: Transaction): Promise<void>; | ||
| onNotification(callback: (channel: string, payload: string) => void): () => void; | ||
| offNotification(callback: (channel: string, payload: string) => void): void; | ||
| dumpDataDir(compression?: DumpTarCompressionOptions): Promise<File | Blob>; | ||
| refreshArrayTypes(): Promise<void>; | ||
| }; | ||
| type PGliteInterfaceExtensions<E> = E extends Extensions ? { | ||
| [K in keyof E]: E[K] extends Extension ? Awaited<ReturnType<E[K]['setup']>>['namespaceObj'] extends infer N ? N extends undefined | null | void ? never : N : never : never; | ||
| } : Record<string, never>; | ||
| type Row<T = { | ||
| [key: string]: any; | ||
| }> = T; | ||
| type Results<T = { | ||
| [key: string]: any; | ||
| }> = { | ||
| rows: Row<T>[]; | ||
| affectedRows?: number; | ||
| /** | ||
| * The command of the query that was run, e.g. "SELECT", "INSERT", "CREATE". | ||
| */ | ||
| command?: string; | ||
| /** | ||
| * The number of rows reported by the command tag, e.g. the rows returned | ||
| * by a SELECT or changed by an UPDATE. Unlike `affectedRows` this is per statement | ||
| * and not cumulative across a multi-statement query. | ||
| */ | ||
| rowCount?: number; | ||
| fields: { | ||
| name: string; | ||
| dataTypeID: number; | ||
| }[]; | ||
| blob?: Blob; | ||
| }; | ||
| interface Transaction { | ||
| query<T>(query: string, params?: any[], options?: QueryOptions): Promise<Results<T>>; | ||
| sql<T>(sqlStrings: TemplateStringsArray, ...params: any[]): Promise<Results<T>>; | ||
| exec(query: string, options?: QueryOptions): Promise<Array<Results>>; | ||
| rollback(): Promise<void>; | ||
| listen(channel: string, callback: (payload: string) => void): Promise<(tx?: Transaction) => Promise<void>>; | ||
| get closed(): boolean; | ||
| } | ||
| type DescribeQueryResult = { | ||
| queryParams: { | ||
| dataTypeID: number; | ||
| serializer: Serializer; | ||
| }[]; | ||
| resultFields: { | ||
| name: string; | ||
| dataTypeID: number; | ||
| parser: Parser; | ||
| }[]; | ||
| }; | ||
| declare const BOOL = 16; | ||
| declare const BYTEA = 17; | ||
| declare const CHAR = 18; | ||
| declare const INT8 = 20; | ||
| declare const INT2 = 21; | ||
| declare const INT4 = 23; | ||
| declare const REGPROC = 24; | ||
| declare const TEXT = 25; | ||
| declare const OID = 26; | ||
| declare const TID = 27; | ||
| declare const XID = 28; | ||
| declare const CID = 29; | ||
| declare const JSON = 114; | ||
| declare const XML = 142; | ||
| declare const PG_NODE_TREE = 194; | ||
| declare const SMGR = 210; | ||
| declare const PATH = 602; | ||
| declare const POLYGON = 604; | ||
| declare const CIDR = 650; | ||
| declare const FLOAT4 = 700; | ||
| declare const FLOAT8 = 701; | ||
| declare const ABSTIME = 702; | ||
| declare const RELTIME = 703; | ||
| declare const TINTERVAL = 704; | ||
| declare const CIRCLE = 718; | ||
| declare const MACADDR8 = 774; | ||
| declare const MONEY = 790; | ||
| declare const MACADDR = 829; | ||
| declare const INET = 869; | ||
| declare const ACLITEM = 1033; | ||
| declare const BPCHAR = 1042; | ||
| declare const VARCHAR = 1043; | ||
| declare const DATE = 1082; | ||
| declare const TIME = 1083; | ||
| declare const TIMESTAMP = 1114; | ||
| declare const TIMESTAMPTZ = 1184; | ||
| declare const INTERVAL = 1186; | ||
| declare const TIMETZ = 1266; | ||
| declare const BIT = 1560; | ||
| declare const VARBIT = 1562; | ||
| declare const NUMERIC = 1700; | ||
| declare const REFCURSOR = 1790; | ||
| declare const REGPROCEDURE = 2202; | ||
| declare const REGOPER = 2203; | ||
| declare const REGOPERATOR = 2204; | ||
| declare const REGCLASS = 2205; | ||
| declare const REGTYPE = 2206; | ||
| declare const UUID = 2950; | ||
| declare const TXID_SNAPSHOT = 2970; | ||
| declare const PG_LSN = 3220; | ||
| declare const PG_NDISTINCT = 3361; | ||
| declare const PG_DEPENDENCIES = 3402; | ||
| declare const TSVECTOR = 3614; | ||
| declare const TSQUERY = 3615; | ||
| declare const GTSVECTOR = 3642; | ||
| declare const REGCONFIG = 3734; | ||
| declare const REGDICTIONARY = 3769; | ||
| declare const JSONB = 3802; | ||
| declare const REGNAMESPACE = 4089; | ||
| declare const REGROLE = 4096; | ||
| declare const types: { | ||
| string: { | ||
| to: number; | ||
| from: number[]; | ||
| serialize: (x: string | number | Date) => string; | ||
| parse: (x: string) => string; | ||
| }; | ||
| number: { | ||
| to: number; | ||
| from: number[]; | ||
| serialize: (x: number) => string; | ||
| parse: (x: string) => number; | ||
| }; | ||
| bigint: { | ||
| to: number; | ||
| from: number[]; | ||
| serialize: (x: bigint) => string; | ||
| parse: (x: string) => number | bigint; | ||
| }; | ||
| json: { | ||
| to: number; | ||
| from: number[]; | ||
| serialize: (x: any) => string; | ||
| parse: (x: string) => any; | ||
| }; | ||
| boolean: { | ||
| to: number; | ||
| from: number[]; | ||
| serialize: (x: boolean | number | string) => "t" | "f"; | ||
| parse: (x: string) => x is "t"; | ||
| }; | ||
| date: { | ||
| to: number; | ||
| from: number[]; | ||
| serialize: (x: Date | string | number) => string; | ||
| parse: (x: string | number) => Date; | ||
| }; | ||
| bytea: { | ||
| to: number; | ||
| from: number[]; | ||
| serialize: (x: Uint8Array) => string; | ||
| parse: (x: string) => Uint8Array; | ||
| }; | ||
| }; | ||
| type Parser = (x: string, typeId?: number) => any; | ||
| type Serializer = (x: any) => string; | ||
| type TypeHandler = { | ||
| to: number; | ||
| from: number | number[]; | ||
| serialize: Serializer; | ||
| parse: Parser; | ||
| }; | ||
| type TypeHandlers = { | ||
| [key: string]: TypeHandler; | ||
| }; | ||
| declare const parsers: { | ||
| [key: string]: (x: string, typeId?: number) => any; | ||
| [key: number]: (x: string, typeId?: number) => any; | ||
| }; | ||
| declare const serializers: { | ||
| [key: string]: Serializer; | ||
| [key: number]: Serializer; | ||
| }; | ||
| declare function parseType(x: string | null, type: number, parsers?: ParserOptions): any; | ||
| declare function arraySerializer(xs: any, serializer: Serializer | undefined, typarray: number): string; | ||
| declare function arrayParser(x: string, parser: Parser, typarray: number): any; | ||
| declare const types$1_ABSTIME: typeof ABSTIME; | ||
| declare const types$1_ACLITEM: typeof ACLITEM; | ||
| declare const types$1_BIT: typeof BIT; | ||
| declare const types$1_BOOL: typeof BOOL; | ||
| declare const types$1_BPCHAR: typeof BPCHAR; | ||
| declare const types$1_BYTEA: typeof BYTEA; | ||
| declare const types$1_CHAR: typeof CHAR; | ||
| declare const types$1_CID: typeof CID; | ||
| declare const types$1_CIDR: typeof CIDR; | ||
| declare const types$1_CIRCLE: typeof CIRCLE; | ||
| declare const types$1_DATE: typeof DATE; | ||
| declare const types$1_FLOAT4: typeof FLOAT4; | ||
| declare const types$1_FLOAT8: typeof FLOAT8; | ||
| declare const types$1_GTSVECTOR: typeof GTSVECTOR; | ||
| declare const types$1_INET: typeof INET; | ||
| declare const types$1_INT2: typeof INT2; | ||
| declare const types$1_INT4: typeof INT4; | ||
| declare const types$1_INT8: typeof INT8; | ||
| declare const types$1_INTERVAL: typeof INTERVAL; | ||
| declare const types$1_JSON: typeof JSON; | ||
| declare const types$1_JSONB: typeof JSONB; | ||
| declare const types$1_MACADDR: typeof MACADDR; | ||
| declare const types$1_MACADDR8: typeof MACADDR8; | ||
| declare const types$1_MONEY: typeof MONEY; | ||
| declare const types$1_NUMERIC: typeof NUMERIC; | ||
| declare const types$1_OID: typeof OID; | ||
| declare const types$1_PATH: typeof PATH; | ||
| declare const types$1_PG_DEPENDENCIES: typeof PG_DEPENDENCIES; | ||
| declare const types$1_PG_LSN: typeof PG_LSN; | ||
| declare const types$1_PG_NDISTINCT: typeof PG_NDISTINCT; | ||
| declare const types$1_PG_NODE_TREE: typeof PG_NODE_TREE; | ||
| declare const types$1_POLYGON: typeof POLYGON; | ||
| type types$1_Parser = Parser; | ||
| declare const types$1_REFCURSOR: typeof REFCURSOR; | ||
| declare const types$1_REGCLASS: typeof REGCLASS; | ||
| declare const types$1_REGCONFIG: typeof REGCONFIG; | ||
| declare const types$1_REGDICTIONARY: typeof REGDICTIONARY; | ||
| declare const types$1_REGNAMESPACE: typeof REGNAMESPACE; | ||
| declare const types$1_REGOPER: typeof REGOPER; | ||
| declare const types$1_REGOPERATOR: typeof REGOPERATOR; | ||
| declare const types$1_REGPROC: typeof REGPROC; | ||
| declare const types$1_REGPROCEDURE: typeof REGPROCEDURE; | ||
| declare const types$1_REGROLE: typeof REGROLE; | ||
| declare const types$1_REGTYPE: typeof REGTYPE; | ||
| declare const types$1_RELTIME: typeof RELTIME; | ||
| declare const types$1_SMGR: typeof SMGR; | ||
| type types$1_Serializer = Serializer; | ||
| declare const types$1_TEXT: typeof TEXT; | ||
| declare const types$1_TID: typeof TID; | ||
| declare const types$1_TIME: typeof TIME; | ||
| declare const types$1_TIMESTAMP: typeof TIMESTAMP; | ||
| declare const types$1_TIMESTAMPTZ: typeof TIMESTAMPTZ; | ||
| declare const types$1_TIMETZ: typeof TIMETZ; | ||
| declare const types$1_TINTERVAL: typeof TINTERVAL; | ||
| declare const types$1_TSQUERY: typeof TSQUERY; | ||
| declare const types$1_TSVECTOR: typeof TSVECTOR; | ||
| declare const types$1_TXID_SNAPSHOT: typeof TXID_SNAPSHOT; | ||
| type types$1_TypeHandler = TypeHandler; | ||
| type types$1_TypeHandlers = TypeHandlers; | ||
| declare const types$1_UUID: typeof UUID; | ||
| declare const types$1_VARBIT: typeof VARBIT; | ||
| declare const types$1_VARCHAR: typeof VARCHAR; | ||
| declare const types$1_XID: typeof XID; | ||
| declare const types$1_XML: typeof XML; | ||
| declare const types$1_arrayParser: typeof arrayParser; | ||
| declare const types$1_arraySerializer: typeof arraySerializer; | ||
| declare const types$1_parseType: typeof parseType; | ||
| declare const types$1_parsers: typeof parsers; | ||
| declare const types$1_serializers: typeof serializers; | ||
| declare const types$1_types: typeof types; | ||
| declare namespace types$1 { | ||
| export { types$1_ABSTIME as ABSTIME, types$1_ACLITEM as ACLITEM, types$1_BIT as BIT, types$1_BOOL as BOOL, types$1_BPCHAR as BPCHAR, types$1_BYTEA as BYTEA, types$1_CHAR as CHAR, types$1_CID as CID, types$1_CIDR as CIDR, types$1_CIRCLE as CIRCLE, types$1_DATE as DATE, types$1_FLOAT4 as FLOAT4, types$1_FLOAT8 as FLOAT8, types$1_GTSVECTOR as GTSVECTOR, types$1_INET as INET, types$1_INT2 as INT2, types$1_INT4 as INT4, types$1_INT8 as INT8, types$1_INTERVAL as INTERVAL, types$1_JSON as JSON, types$1_JSONB as JSONB, types$1_MACADDR as MACADDR, types$1_MACADDR8 as MACADDR8, types$1_MONEY as MONEY, types$1_NUMERIC as NUMERIC, types$1_OID as OID, types$1_PATH as PATH, types$1_PG_DEPENDENCIES as PG_DEPENDENCIES, types$1_PG_LSN as PG_LSN, types$1_PG_NDISTINCT as PG_NDISTINCT, types$1_PG_NODE_TREE as PG_NODE_TREE, types$1_POLYGON as POLYGON, type types$1_Parser as Parser, types$1_REFCURSOR as REFCURSOR, types$1_REGCLASS as REGCLASS, types$1_REGCONFIG as REGCONFIG, types$1_REGDICTIONARY as REGDICTIONARY, types$1_REGNAMESPACE as REGNAMESPACE, types$1_REGOPER as REGOPER, types$1_REGOPERATOR as REGOPERATOR, types$1_REGPROC as REGPROC, types$1_REGPROCEDURE as REGPROCEDURE, types$1_REGROLE as REGROLE, types$1_REGTYPE as REGTYPE, types$1_RELTIME as RELTIME, types$1_SMGR as SMGR, type types$1_Serializer as Serializer, types$1_TEXT as TEXT, types$1_TID as TID, types$1_TIME as TIME, types$1_TIMESTAMP as TIMESTAMP, types$1_TIMESTAMPTZ as TIMESTAMPTZ, types$1_TIMETZ as TIMETZ, types$1_TINTERVAL as TINTERVAL, types$1_TSQUERY as TSQUERY, types$1_TSVECTOR as TSVECTOR, types$1_TXID_SNAPSHOT as TXID_SNAPSHOT, type types$1_TypeHandler as TypeHandler, type types$1_TypeHandlers as TypeHandlers, types$1_UUID as UUID, types$1_VARBIT as VARBIT, types$1_VARCHAR as VARCHAR, types$1_XID as XID, types$1_XML as XML, types$1_arrayParser as arrayParser, types$1_arraySerializer as arraySerializer, types$1_parseType as parseType, types$1_parsers as parsers, types$1_serializers as serializers, types$1_types as types }; | ||
| } | ||
| declare abstract class BasePGlite implements Pick<PGliteInterface, 'query' | 'sql' | 'exec' | 'transaction'> { | ||
| #private; | ||
| serializers: Record<number | string, Serializer>; | ||
| parsers: Record<number | string, Parser>; | ||
| abstract debug: DebugLevel; | ||
| /** | ||
| * Execute a postgres wire protocol message | ||
| * @param message The postgres wire protocol message to execute | ||
| * @returns The result of the query | ||
| */ | ||
| abstract execProtocol(message: Uint8Array, { syncToFs, onNotice }: ExecProtocolOptions): Promise<ExecProtocolResult>; | ||
| /** | ||
| * Execute a postgres wire protocol message | ||
| * @param message The postgres wire protocol message to execute | ||
| * @returns The parsed results of the query | ||
| */ | ||
| abstract execProtocolStream(message: Uint8Array, { syncToFs, onNotice }: ExecProtocolOptions): Promise<BackendMessage[]>; | ||
| /** | ||
| * Execute a postgres wire protocol message directly without wrapping the response. | ||
| * Only use if `execProtocol()` doesn't suite your needs. | ||
| * | ||
| * **Warning:** This bypasses PGlite's protocol wrappers that manage error/notice messages, | ||
| * transactions, and notification listeners. Only use if you need to bypass these wrappers and | ||
| * don't intend to use the above features. | ||
| * | ||
| * @param message The postgres wire protocol message to execute | ||
| * @returns The direct message data response produced by Postgres | ||
| */ | ||
| abstract execProtocolRaw(message: Uint8Array, { syncToFs }: ExecProtocolOptions): Promise<Uint8Array>; | ||
| /** | ||
| * Execute a postgres wire protocol message directly without wrapping the response. | ||
| * Only use if `execProtocol()` doesn't suite your needs. | ||
| * | ||
| * **Warning:** This bypasses PGlite's protocol wrappers that manage error/notice messages, | ||
| * transactions, and notification listeners. Only use if you need to bypass these wrappers and | ||
| * don't intend to use the above features. | ||
| * | ||
| * @param message The postgres wire protocol message to execute | ||
| * @param options.onRawData Callback to receive streaming data | ||
| */ | ||
| abstract execProtocolRawStream(message: Uint8Array, { syncToFs, onRawData }: ExecProtocolOptionsStream): Promise<void>; | ||
| /** | ||
| * Sync the database to the filesystem | ||
| * @returns Promise that resolves when the database is synced to the filesystem | ||
| */ | ||
| abstract syncToFs(): Promise<void>; | ||
| /** | ||
| * Handle a file attached to the current query | ||
| * @param file The file to handle | ||
| */ | ||
| abstract _handleBlob(blob?: File | Blob): Promise<void>; | ||
| /** | ||
| * Get the written file | ||
| */ | ||
| abstract _getWrittenBlob(): Promise<File | Blob | undefined>; | ||
| /** | ||
| * Cleanup the current file | ||
| */ | ||
| abstract _cleanupBlob(): Promise<void>; | ||
| abstract _checkReady(): Promise<void>; | ||
| abstract _runExclusiveQuery<T>(fn: () => Promise<T>): Promise<T>; | ||
| abstract _runExclusiveTransaction<T>(fn: () => Promise<T>): Promise<T>; | ||
| /** | ||
| * Listen for notifications on a channel | ||
| */ | ||
| abstract listen(channel: string, callback: (payload: string) => void, tx?: Transaction): Promise<(tx?: Transaction) => Promise<void>>; | ||
| /** | ||
| * Initialize the array types | ||
| * The oid if the type of an element and the typarray is the oid of the type of the | ||
| * array. | ||
| * We extract these from the database then create the serializers/parsers for | ||
| * each type. | ||
| * This should be called at the end of #init() in the implementing class. | ||
| */ | ||
| _initArrayTypes({ force }?: { | ||
| force?: boolean | undefined; | ||
| }): Promise<void>; | ||
| /** | ||
| * Re-syncs the array types from the database | ||
| * This is useful if you add a new type to the database and want to use it, otherwise pglite won't recognize it. | ||
| */ | ||
| refreshArrayTypes(): Promise<void>; | ||
| /** | ||
| * Execute a single SQL statement | ||
| * This uses the "Extended Query" postgres wire protocol message. | ||
| * @param query The query to execute | ||
| * @param params Optional parameters for the query | ||
| * @returns The result of the query | ||
| */ | ||
| query<T>(query: string, params?: any[], options?: QueryOptions): Promise<Results<T>>; | ||
| /** | ||
| * Execute a single SQL statement like with {@link PGlite.query}, but with a | ||
| * templated statement where template values will be treated as parameters. | ||
| * | ||
| * You can use helpers from `/template` to further format the query with | ||
| * identifiers, raw SQL, and nested statements. | ||
| * | ||
| * This uses the "Extended Query" postgres wire protocol message. | ||
| * | ||
| * @param query The query to execute with parameters as template values | ||
| * @returns The result of the query | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * const results = await db.sql`SELECT * FROM ${identifier`foo`} WHERE id = ${id}` | ||
| * ``` | ||
| */ | ||
| sql<T>(sqlStrings: TemplateStringsArray, ...params: any[]): Promise<Results<T>>; | ||
| /** | ||
| * Execute a SQL query, this can have multiple statements. | ||
| * This uses the "Simple Query" postgres wire protocol message. | ||
| * @param query The query to execute | ||
| * @returns The result of the query | ||
| */ | ||
| exec(query: string, options?: QueryOptions): Promise<Array<Results>>; | ||
| /** | ||
| * Describe a query | ||
| * @param query The query to describe | ||
| * @returns A description of the result types for the query | ||
| */ | ||
| describeQuery(query: string, options?: QueryOptions): Promise<DescribeQueryResult>; | ||
| /** | ||
| * Execute a transaction | ||
| * @param callback A callback function that takes a transaction object | ||
| * @returns The result of the transaction | ||
| */ | ||
| transaction<T>(callback: (tx: Transaction) => Promise<T>): Promise<T>; | ||
| /** | ||
| * Run a function exclusively, no other transactions or queries will be allowed | ||
| * while the function is running. | ||
| * This is useful when working with the execProtocol methods as they are not blocked, | ||
| * and do not block the locks used by transactions and queries. | ||
| * @param fn The function to run | ||
| * @returns The result of the function | ||
| */ | ||
| runExclusive<T>(fn: () => Promise<T>): Promise<T>; | ||
| } | ||
| declare class PGlite extends BasePGlite implements PGliteInterface, AsyncDisposable { | ||
| #private; | ||
| fs?: Filesystem; | ||
| protected mod?: PostgresMod; | ||
| private readonly POSTGRES_MAIN_LONGJMP; | ||
| get ENV(): any; | ||
| readonly dataDir?: string; | ||
| readonly waitReady: Promise<void>; | ||
| readonly debug: DebugLevel; | ||
| static readonly paths: { | ||
| readonly PG_ROOT: "/pglite"; | ||
| readonly PGDATA: string; | ||
| readonly ICU_DATA_PATH: string; | ||
| readonly INITDB_EXE_PATH: string; | ||
| readonly POSTGRES_EXE_PATH: string; | ||
| }; | ||
| static readonly DEFAULT_RECV_BUF_SIZE: number; | ||
| static readonly MAX_BUFFER_SIZE: number; | ||
| externalCommandStreamFd: number | null; | ||
| static readonly defaultStartParams: string[]; | ||
| /** | ||
| * Create a new PGlite instance | ||
| * @param dataDir The directory to store the database files | ||
| * Prefix with idb:// to use indexeddb filesystem in the browser | ||
| * Use memory:// to use in-memory filesystem | ||
| * @param options PGlite options | ||
| */ | ||
| constructor(dataDir?: string, options?: PGliteOptions); | ||
| /** | ||
| * Create a new PGlite instance | ||
| * @param options PGlite options including the data directory | ||
| */ | ||
| constructor(options?: PGliteOptions); | ||
| /** | ||
| * Create a new PGlite instance with extensions on the Typescript interface | ||
| * (The main constructor does enable extensions, however due to the limitations | ||
| * of Typescript, the extensions are not available on the instance interface) | ||
| * @param options PGlite options including the data directory | ||
| * @returns A promise that resolves to the PGlite instance when it's ready. | ||
| */ | ||
| static create<O extends PGliteOptions>(options?: O): Promise<PGlite & PGliteInterfaceExtensions<O['extensions']>>; | ||
| /** | ||
| * Create a new PGlite instance with extensions on the Typescript interface | ||
| * (The main constructor does enable extensions, however due to the limitations | ||
| * of Typescript, the extensions are not available on the instance interface) | ||
| * @param dataDir The directory to store the database files | ||
| * Prefix with idb:// to use indexeddb filesystem in the browser | ||
| * Use memory:// to use in-memory filesystem | ||
| * @param options PGlite options | ||
| * @returns A promise that resolves to the PGlite instance when it's ready. | ||
| */ | ||
| static create<O extends PGliteOptions>(dataDir?: string, options?: O): Promise<PGlite & PGliteInterfaceExtensions<O['extensions']>>; | ||
| handleExternalCmd(cmd: string, mode: string): number; | ||
| /** | ||
| * The Postgres Emscripten Module | ||
| */ | ||
| get Module(): PostgresMod; | ||
| /** | ||
| * The ready state of the database | ||
| */ | ||
| get ready(): boolean; | ||
| /** | ||
| * The closed state of the database | ||
| */ | ||
| get closed(): boolean; | ||
| /** | ||
| * Close the database | ||
| * @returns A promise that resolves when the database is closed | ||
| */ | ||
| close(): Promise<void>; | ||
| /** | ||
| * Close the database when the object exits scope | ||
| * Stage 3 ECMAScript Explicit Resource Management | ||
| * https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-2.html#using-declarations-and-explicit-resource-management | ||
| */ | ||
| [Symbol.asyncDispose](): Promise<void>; | ||
| /** | ||
| * Handle a file attached to the current query | ||
| * @param file The file to handle | ||
| */ | ||
| _handleBlob(blob?: File | Blob): Promise<void>; | ||
| /** | ||
| * Cleanup the current file | ||
| */ | ||
| _cleanupBlob(): Promise<void>; | ||
| /** | ||
| * Get the written blob from the current query | ||
| * @returns The written blob | ||
| */ | ||
| _getWrittenBlob(): Promise<Blob | undefined>; | ||
| /** | ||
| * Wait for the database to be ready | ||
| */ | ||
| _checkReady(): Promise<void>; | ||
| /** | ||
| * Execute a postgres wire protocol synchronously | ||
| * @param message The postgres wire protocol message to execute | ||
| * @returns The direct message data response produced by Postgres | ||
| */ | ||
| execProtocolRawSync(message: Uint8Array): Uint8Array; | ||
| /** | ||
| * Execute a postgres wire protocol message directly without wrapping the response. | ||
| * Only use if `execProtocol()` doesn't suite your needs. | ||
| * | ||
| * **Warning:** This bypasses PGlite's protocol wrappers that manage error/notice messages, | ||
| * transactions, and notification listeners. Only use if you need to bypass these wrappers and | ||
| * don't intend to use the above features. | ||
| * | ||
| * @param message The postgres wire protocol message to execute | ||
| * @returns The direct message data response produced by Postgres | ||
| */ | ||
| execProtocolRaw(message: Uint8Array, { syncToFs }?: ExecProtocolOptions): Promise<Uint8Array>; | ||
| /** | ||
| * Execute a postgres wire protocol message directly without wrapping the response. | ||
| * Only use if `execProtocol()` doesn't suite your needs. | ||
| * | ||
| * **Warning:** This bypasses PGlite's protocol wrappers that manage error/notice messages, | ||
| * transactions, and notification listeners. Only use if you need to bypass these wrappers and | ||
| * don't intend to use the above features. | ||
| * | ||
| * @param message The postgres wire protocol message to execute | ||
| * @param options.onRawData Callback to receive results as streaming data | ||
| */ | ||
| execProtocolRawStream(message: Uint8Array, { syncToFs, onRawData }: ExecProtocolOptionsStream): Promise<void>; | ||
| /** | ||
| * Execute a postgres wire protocol message | ||
| * @param message The postgres wire protocol message to execute | ||
| * @returns The result of the query | ||
| */ | ||
| execProtocol(message: Uint8Array, { syncToFs, throwOnError, onNotice, }?: ExecProtocolOptions): Promise<ExecProtocolResult>; | ||
| /** | ||
| * Execute a postgres wire protocol message | ||
| * @param message The postgres wire protocol message to execute | ||
| * @returns The parsed results of the query | ||
| */ | ||
| execProtocolStream(message: Uint8Array, { syncToFs, throwOnError, onNotice }?: ExecProtocolOptions): Promise<BackendMessage[]>; | ||
| /** | ||
| * Check if the database is in a transaction | ||
| * @returns True if the database is in a transaction, false otherwise | ||
| */ | ||
| isInTransaction(): boolean; | ||
| /** | ||
| * Perform any sync operations implemented by the filesystem, this is | ||
| * run after every query to ensure that the filesystem is synced. | ||
| */ | ||
| syncToFs(): Promise<void>; | ||
| /** | ||
| * Listen for a notification | ||
| * @param channel The channel to listen on | ||
| * @param callback The callback to call when a notification is received | ||
| */ | ||
| listen(channel: string, callback: (payload: string) => void, tx?: Transaction): Promise<(tx?: Transaction) => Promise<void>>; | ||
| /** | ||
| * Stop listening for a notification | ||
| * @param channel The channel to stop listening on | ||
| * @param callback The callback to remove | ||
| */ | ||
| unlisten(channel: string, callback?: (payload: string) => void, tx?: Transaction): Promise<void>; | ||
| /** | ||
| * Listen to notifications | ||
| * @param callback The callback to call when a notification is received | ||
| */ | ||
| onNotification(callback: (channel: string, payload: string) => void): () => void; | ||
| /** | ||
| * Stop listening to notifications | ||
| * @param callback The callback to remove | ||
| */ | ||
| offNotification(callback: (channel: string, payload: string) => void): void; | ||
| /** | ||
| * Dump the PGDATA dir from the filesystem to a gzipped tarball. | ||
| * @param compression The compression options to use - 'gzip', 'auto', 'none' | ||
| * @returns The tarball as a File object where available, and fallback to a Blob | ||
| */ | ||
| dumpDataDir(compression?: DumpTarCompressionOptions): Promise<File | Blob>; | ||
| /** | ||
| * Run a function in a mutex that's exclusive to queries | ||
| * @param fn The query to run | ||
| * @returns The result of the query | ||
| */ | ||
| _runExclusiveQuery<T>(fn: () => Promise<T>): Promise<T>; | ||
| /** | ||
| * Run a function in a mutex that's exclusive to transactions | ||
| * @param fn The function to run | ||
| * @returns The result of the function | ||
| */ | ||
| _runExclusiveTransaction<T>(fn: () => Promise<T>): Promise<T>; | ||
| clone(): Promise<PGliteInterface>; | ||
| _runExclusiveListen<T>(fn: () => Promise<T>): Promise<T>; | ||
| callMain(args: string[]): number; | ||
| copyToFS(filePath: string, data: Uint8Array, mode?: number): void; | ||
| } | ||
| export { type FsType as A, type BackendMessage as B, type Filesystem as C, type DebugLevel as D, EmscriptenBuiltinFilesystem as E, type FilesystemType as F, ERRNO_CODES as G, type InitializedExtensions as I, type Mode as M, type Parser as P, type QueryOptions as Q, type Results as R, type SerializerOptions as S, type Transaction as T, type BufferParameter as a, PGlite as b, type PostgresMod as c, type PGliteInterface as d, type RowMode as e, type ParserOptions as f, type ExecProtocolOptions as g, type ExecProtocolOptionsStream as h, type ExtensionSetupResult as i, type ExtensionSetup as j, type Extension as k, type ExtensionNamespace as l, messages as m, type Extensions as n, type ExecProtocolResult as o, postgresMod as p, type DumpDataDirResult as q, type PGliteOptions as r, type PGliteInterfaceExtensions as s, types$1 as t, type Row as u, type DescribeQueryResult as v, BaseFilesystem as w, type FsStats as x, BasePGlite as y, type DumpTarCompressionOptions as z }; |
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 too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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 too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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 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 too big to display
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 too big to display
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Mixed license
LicensePackage contains multiple licenses.
Unidentified License
LicenseSomething that seems like a license was found, but its contents could not be matched with a known license.
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 5 instances
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
25435011
0.06%12933
0.19%20
-16.67%2
Infinity%80
-20%