@dotdo/pglite 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/copy-assets.js +63 -0
- package/dist/{chunk-5U7S5PTI.js → chunk-CEDUAATT.js} +2 -2
- package/dist/{chunk-5U7S5PTI.js.map → chunk-CEDUAATT.js.map} +1 -1
- package/dist/{chunk-I55HERVV.js → chunk-RJSXXGBE.js} +2 -2
- package/dist/index.cjs +7 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/live/index.cjs +5 -5
- package/dist/live/index.cjs.map +1 -1
- package/dist/live/index.js +1 -1
- package/dist/pglite.cjs +1 -1
- package/dist/pglite.js +2 -2
- package/dist/pglite.wasm +0 -0
- package/dist/worker/index.cjs +2 -2
- package/dist/worker/index.cjs.map +1 -1
- package/dist/worker/index.js +1 -1
- package/package.json +6 -2
- /package/dist/{chunk-I55HERVV.js.map → chunk-RJSXXGBE.js.map} +0 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Copy PGLite WASM and data files to your project for Cloudflare Workers.
|
|
4
|
+
*
|
|
5
|
+
* Usage: npx @dotdo/pglite copy-assets [destination]
|
|
6
|
+
*
|
|
7
|
+
* This copies pglite.wasm and pglite.data to your project so Wrangler can
|
|
8
|
+
* use them as static imports with the CompiledWasm rule.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { promises as fs } from 'fs'
|
|
12
|
+
import path from 'path'
|
|
13
|
+
import { fileURLToPath } from 'url'
|
|
14
|
+
|
|
15
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
16
|
+
const distDir = path.join(__dirname, '..', 'dist')
|
|
17
|
+
|
|
18
|
+
async function main() {
|
|
19
|
+
const destArg = process.argv[2] || './pglite-assets'
|
|
20
|
+
const destDir = path.resolve(process.cwd(), destArg)
|
|
21
|
+
|
|
22
|
+
console.log(`Copying PGLite assets to ${destDir}...`)
|
|
23
|
+
|
|
24
|
+
// Create destination directory
|
|
25
|
+
await fs.mkdir(destDir, { recursive: true })
|
|
26
|
+
|
|
27
|
+
// Copy files (WASM, data, and pre-patched JS for Workers)
|
|
28
|
+
const files = ['pglite.wasm', 'pglite.data', 'pglite.js']
|
|
29
|
+
for (const file of files) {
|
|
30
|
+
const src = path.join(distDir, file)
|
|
31
|
+
const dest = path.join(destDir, file)
|
|
32
|
+
await fs.copyFile(src, dest)
|
|
33
|
+
const stat = await fs.stat(dest)
|
|
34
|
+
console.log(` ${file} (${(stat.size / 1024 / 1024).toFixed(1)} MB)`)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
console.log(`
|
|
38
|
+
Done! Add these to your wrangler.toml:
|
|
39
|
+
|
|
40
|
+
[[rules]]
|
|
41
|
+
type = "CompiledWasm"
|
|
42
|
+
globs = ["**/*.wasm"]
|
|
43
|
+
|
|
44
|
+
[[rules]]
|
|
45
|
+
type = "Data"
|
|
46
|
+
globs = ["**/*.data"]
|
|
47
|
+
|
|
48
|
+
Then import in your worker:
|
|
49
|
+
|
|
50
|
+
import pgliteWasm from './${path.relative(process.cwd(), destDir)}/pglite.wasm'
|
|
51
|
+
import pgliteData from './${path.relative(process.cwd(), destDir)}/pglite.data'
|
|
52
|
+
|
|
53
|
+
const pg = await PGlite.create({
|
|
54
|
+
wasmModule: pgliteWasm,
|
|
55
|
+
fsBundle: new Blob([pgliteData]),
|
|
56
|
+
})
|
|
57
|
+
`)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
main().catch((err) => {
|
|
61
|
+
console.error('Error:', err.message)
|
|
62
|
+
process.exit(1)
|
|
63
|
+
})
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as ae,e as s,f as h,g as d,h as p,i as oe,j as y}from"./chunk-VCBR6USK.js";var hr={};ae(hr,{ABSTIME:()=>Ct,ACLITEM:()=>vt,BIT:()=>jt,BOOL:()=>be,BPCHAR:()=>_e,BYTEA:()=>ge,CHAR:()=>wt,CID:()=>St,CIDR:()=>Et,CIRCLE:()=>Nt,DATE:()=>He,FLOAT4:()=>je,FLOAT8:()=>Qe,GTSVECTOR:()=>sr,INET:()=>Vt,INT2:()=>Fe,INT4:()=>Ge,INT8:()=>we,INTERVAL:()=>Gt,JSON:()=>Ae,JSONB:()=>Ye,MACADDR:()=>Ot,MACADDR8:()=>Lt,MONEY:()=>kt,NUMERIC:()=>_t,OID:()=>We,PATH:()=>Mt,PG_DEPENDENCIES:()=>tr,PG_LSN:()=>Zt,PG_NDISTINCT:()=>er,PG_NODE_TREE:()=>It,POLYGON:()=>Tt,REFCURSOR:()=>zt,REGCLASS:()=>$t,REGCONFIG:()=>ir,REGDICTIONARY:()=>ar,REGNAMESPACE:()=>or,REGOPER:()=>qt,REGOPERATOR:()=>Yt,REGPROC:()=>At,REGPROCEDURE:()=>Ht,REGROLE:()=>ur,REGTYPE:()=>Kt,RELTIME:()=>Pt,SMGR:()=>Rt,TEXT:()=>V,TID:()=>Bt,TIME:()=>Ft,TIMESTAMP:()=>qe,TIMESTAMPTZ:()=>Be,TIMETZ:()=>Wt,TINTERVAL:()=>Ut,TSQUERY:()=>nr,TSVECTOR:()=>rr,TXID_SNAPSHOT:()=>Xt,UUID:()=>Jt,VARBIT:()=>Qt,VARCHAR:()=>ze,XID:()=>xt,XML:()=>Dt,arrayParser:()=>yr,arraySerializer:()=>Ke,parseType:()=>ue,parsers:()=>lr,serializers:()=>cr,types:()=>$e});y();var bt=globalThis.JSON.parse,gt=globalThis.JSON.stringify,be=16,ge=17,wt=18,we=20,Fe=21,Ge=23,At=24,V=25,We=26,Bt=27,xt=28,St=29,Ae=114,Dt=142,It=194,Rt=210,Mt=602,Tt=604,Et=650,je=700,Qe=701,Ct=702,Pt=703,Ut=704,Nt=718,Lt=774,kt=790,Ot=829,Vt=869,vt=1033,_e=1042,ze=1043,He=1082,Ft=1083,qe=1114,Be=1184,Gt=1186,Wt=1266,jt=1560,Qt=1562,_t=1700,zt=1790,Ht=2202,qt=2203,Yt=2204,$t=2205,Kt=2206,Jt=2950,Xt=2970,Zt=3220,er=3361,tr=3402,rr=3614,nr=3615,sr=3642,ir=3734,ar=3769,Ye=3802,or=4089,ur=4096,$e={string:{to:V,from:[V,ze,_e],serialize:e=>{if(typeof e=="string")return e;if(typeof e=="number")return e.toString();throw new Error("Invalid input for string type")},parse:e=>e},number:{to:0,from:[Fe,Ge,We,je,Qe],serialize:e=>e.toString(),parse:e=>+e},bigint:{to:we,from:[we],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:Ae,from:[Ae,Ye],serialize:e=>typeof e=="string"?e:gt(e),parse:e=>bt(e)},boolean:{to:be,from:[be],serialize:e=>{if(typeof e!="boolean")throw new Error("Invalid input for boolean type");return e?"t":"f"},parse:e=>e==="t"},date:{to:Be,from:[He,qe,Be],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:ge,from:[ge],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},(r,n)=>parseInt(t.substring(n*2,(n+1)*2),16))}}},xe=pr($e),lr=xe.parsers,cr=xe.serializers;function ue(e,t,r){if(e===null)return null;let n=r?.[t]??xe.parsers[t];return n?n(e,t):e}function pr(e){return Object.keys(e).reduce(({parsers:t,serializers:r},n)=>{let{to:i,from:a,serialize:u,parse:f}=e[n];return r[i]=u,r[n]=u,t[n]=f,Array.isArray(a)?a.forEach(c=>{t[c]=f,r[c]=u}):(t[a]=f,r[a]=u),{parsers:t,serializers:r}},{parsers:{},serializers:{}})}var dr=/\\/g,fr=/"/g;function mr(e){return e.replace(dr,"\\\\").replace(fr,'\\"')}function Ke(e,t,r){if(Array.isArray(e)===!1)return e;if(!e.length)return"{}";let n=e[0],i=r===1020?";":",";return Array.isArray(n)?`{${e.map(a=>Ke(a,t,r)).join(i)}}`:`{${e.map(a=>(a===void 0&&(a=null),a===null?"null":'"'+mr(t?t(a):a.toString())+'"')).join(i)}}`}var he={i:0,char:null,str:"",quoted:!1,last:0,p:null};function yr(e,t,r){return he.i=he.last=0,Je(he,e,t,r)[0]}function Je(e,t,r,n){let i=[],a=n===1020?";":",";for(;e.i<t.length;e.i++){if(e.char=t[e.i],e.quoted)e.char==="\\"?e.str+=t[++e.i]:e.char==='"'?(i.push(r?r(e.str):e.str),e.str="",e.quoted=t[e.i+1]==='"',e.last=e.i+2):e.str+=e.char;else if(e.char==='"')e.quoted=!0;else if(e.char==="{")e.last=++e.i,i.push(Je(e,t,r,n));else if(e.char==="}"){e.quoted=!1,e.last<e.i&&i.push(r?r(t.slice(e.last,e.i)):t.slice(e.last,e.i)),e.last=e.i+1;break}else e.char===a&&e.p!=="}"&&e.p!=='"'&&(i.push(r?r(t.slice(e.last,e.i)):t.slice(e.last,e.i)),e.last=e.i+1);e.p=e.char}return e.last<e.i&&i.push(r?r(t.slice(e.last,e.i+1)):t.slice(e.last,e.i+1)),i}var wr={};ae(wr,{parseDescribeStatementResults:()=>Se,parseResults:()=>br});y();function br(e,t,r,n){let i=[],a={rows:[],fields:[]},u=0,f={...t,...r?.parsers};return e.forEach(c=>{switch(c.name){case"rowDescription":{let R=c;a.fields=R.fields.map(E=>({name:E.name,dataTypeID:E.dataTypeID}));break}case"dataRow":{if(!a)break;let R=c;r?.rowMode==="array"?a.rows.push(R.fields.map((E,ie)=>ue(E,a.fields[ie].dataTypeID,f))):a.rows.push(Object.fromEntries(R.fields.map((E,ie)=>[a.fields[ie].name,ue(E,a.fields[ie].dataTypeID,f)])));break}case"commandComplete":{u+=gr(c),i.push({...a,affectedRows:u,...n?{blob:n}:{}}),a={rows:[],fields:[]};break}}}),i.length===0&&i.push({affectedRows:0,rows:[],fields:[]}),i}function gr(e){let t=e.text.split(" ");switch(t[0]){case"INSERT":return parseInt(t[2],10);case"UPDATE":case"DELETE":case"COPY":case"MERGE":return parseInt(t[1],10);default:return 0}}function Se(e){let t=e.find(r=>r.name==="parameterDescription");return t?t.dataTypeIDs:[]}var Ue={};ae(Ue,{AuthenticationCleartextPassword:()=>F,AuthenticationMD5Password:()=>G,AuthenticationOk:()=>v,AuthenticationSASL:()=>W,AuthenticationSASLContinue:()=>j,AuthenticationSASLFinal:()=>Q,BackendKeyDataMessage:()=>K,CommandCompleteMessage:()=>Z,CopyDataMessage:()=>_,CopyResponse:()=>z,DataRowMessage:()=>ee,DatabaseError:()=>C,Field:()=>H,NoticeMessage:()=>te,NotificationResponseMessage:()=>J,ParameterDescriptionMessage:()=>Y,ParameterStatusMessage:()=>$,ReadyForQueryMessage:()=>X,RowDescriptionMessage:()=>q,bindComplete:()=>Ie,closeComplete:()=>Re,copyDone:()=>Pe,emptyQuery:()=>Ce,noData:()=>Me,parseComplete:()=>De,portalSuspended:()=>Te,replicationStart:()=>Ee});y();var De={name:"parseComplete",length:5},Ie={name:"bindComplete",length:5},Re={name:"closeComplete",length:5},Me={name:"noData",length:5},Te={name:"portalSuspended",length:5},Ee={name:"replicationStart",length:4},Ce={name:"emptyQuery",length:4},Pe={name:"copyDone",length:4},v=class{constructor(t){this.length=t;this.name="authenticationOk"}},F=class{constructor(t){this.length=t;this.name="authenticationCleartextPassword"}},G=class{constructor(t,r){this.length=t;this.salt=r;this.name="authenticationMD5Password"}},W=class{constructor(t,r){this.length=t;this.mechanisms=r;this.name="authenticationSASL"}},j=class{constructor(t,r){this.length=t;this.data=r;this.name="authenticationSASLContinue"}},Q=class{constructor(t,r){this.length=t;this.data=r;this.name="authenticationSASLFinal"}},C=class extends Error{constructor(r,n,i){super(r);this.length=n;this.name=i}},_=class{constructor(t,r){this.length=t;this.chunk=r;this.name="copyData"}},z=class{constructor(t,r,n,i){this.length=t;this.name=r;this.binary=n;this.columnTypes=new Array(i)}},H=class{constructor(t,r,n,i,a,u,f){this.name=t;this.tableID=r;this.columnID=n;this.dataTypeID=i;this.dataTypeSize=a;this.dataTypeModifier=u;this.format=f}},q=class{constructor(t,r){this.length=t;this.fieldCount=r;this.name="rowDescription";this.fields=new Array(this.fieldCount)}},Y=class{constructor(t,r){this.length=t;this.parameterCount=r;this.name="parameterDescription";this.dataTypeIDs=new Array(this.parameterCount)}},$=class{constructor(t,r,n){this.length=t;this.parameterName=r;this.parameterValue=n;this.name="parameterStatus"}},K=class{constructor(t,r,n){this.length=t;this.processID=r;this.secretKey=n;this.name="backendKeyData"}},J=class{constructor(t,r,n,i){this.length=t;this.processId=r;this.channel=n;this.payload=i;this.name="notification"}},X=class{constructor(t,r){this.length=t;this.status=r;this.name="readyForQuery"}},Z=class{constructor(t,r){this.length=t;this.text=r;this.name="commandComplete"}},ee=class{constructor(t,r){this.length=t;this.fields=r;this.name="dataRow";this.fieldCount=r.length}},te=class{constructor(t,r){this.length=t;this.message=r;this.name="notice"}};var zr={};ae(zr,{Parser:()=>ye,messages:()=>Ue,serialize:()=>O});y();y();y();y();function P(e){let t=e.length;for(let r=e.length-1;r>=0;r--){let n=e.charCodeAt(r);n>127&&n<=2047?t++:n>2047&&n<=65535&&(t+=2),n>=56320&&n<=57343&&r--}return t}var b,g,N,ce,L,B,le,U,Xe,T=class{constructor(t=256){this.size=t;h(this,B);h(this,b);h(this,g,5);h(this,N,!1);h(this,ce,new TextEncoder);h(this,L,0);d(this,b,p(this,B,le).call(this,t))}addInt32(t){return p(this,B,U).call(this,4),s(this,b).setInt32(s(this,g),t,s(this,N)),d(this,g,s(this,g)+4),this}addInt16(t){return p(this,B,U).call(this,2),s(this,b).setInt16(s(this,g),t,s(this,N)),d(this,g,s(this,g)+2),this}addCString(t){return t&&this.addString(t),p(this,B,U).call(this,1),s(this,b).setUint8(s(this,g),0),oe(this,g)._++,this}addString(t=""){let r=P(t);return p(this,B,U).call(this,r),s(this,ce).encodeInto(t,new Uint8Array(s(this,b).buffer,s(this,g))),d(this,g,s(this,g)+r),this}add(t){return p(this,B,U).call(this,t.byteLength),new Uint8Array(s(this,b).buffer).set(new Uint8Array(t),s(this,g)),d(this,g,s(this,g)+t.byteLength),this}flush(t){let r=p(this,B,Xe).call(this,t);return d(this,g,5),d(this,b,p(this,B,le).call(this,this.size)),new Uint8Array(r)}};b=new WeakMap,g=new WeakMap,N=new WeakMap,ce=new WeakMap,L=new WeakMap,B=new WeakSet,le=function(t){return new DataView(new ArrayBuffer(t))},U=function(t){if(s(this,b).byteLength-s(this,g)<t){let n=s(this,b).buffer,i=n.byteLength+(n.byteLength>>1)+t;d(this,b,p(this,B,le).call(this,i)),new Uint8Array(s(this,b).buffer).set(new Uint8Array(n))}},Xe=function(t){if(t){s(this,b).setUint8(s(this,L),t);let r=s(this,g)-(s(this,L)+1);s(this,b).setInt32(s(this,L)+1,r,s(this,N))}return s(this,b).buffer.slice(t?0:5,s(this,g))};var m=new T,Ar=e=>{m.addInt16(3).addInt16(0);for(let n of Object.keys(e))m.addCString(n).addCString(e[n]);m.addCString("client_encoding").addCString("UTF8");let t=m.addCString("").flush(),r=t.byteLength+4;return new T().addInt32(r).add(t.buffer).flush()},Br=()=>{let e=new DataView(new ArrayBuffer(8));return e.setInt32(0,8,!1),e.setInt32(4,80877103,!1),new Uint8Array(e.buffer)},xr=e=>m.addCString(e).flush(112),Sr=(e,t)=>(m.addCString(e).addInt32(P(t)).addString(t),m.flush(112)),Dr=e=>m.addString(e).flush(112),Ir=e=>m.addCString(e).flush(81),Rr=[],Mr=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 r=m.addCString(t).addCString(e.text).addInt16(e.types?.length??0);return e.types?.forEach(n=>r.addInt32(n)),m.flush(80)},k=new T;var Tr=(e,t)=>{for(let r=0;r<e.length;r++){let n=t?t(e[r],r):e[r];if(n===null)m.addInt16(0),k.addInt32(-1);else if(n instanceof ArrayBuffer||ArrayBuffer.isView(n)){let i=ArrayBuffer.isView(n)?n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength):n;m.addInt16(1),k.addInt32(i.byteLength),k.add(i)}else m.addInt16(0),k.addInt32(P(n)),k.addString(n)}},Er=(e={})=>{let t=e.portal??"",r=e.statement??"",n=e.binary??!1,i=e.values??Rr,a=i.length;return m.addCString(t).addCString(r),m.addInt16(a),Tr(i,e.valueMapper),m.addInt16(a),m.add(k.flush().buffer),m.addInt16(n?1:0),m.flush(66)},Cr=new Uint8Array([69,0,0,0,9,0,0,0,0,0]),Pr=e=>{if(!e||!e.portal&&!e.rows)return Cr;let t=e.portal??"",r=e.rows??0,n=P(t),i=4+n+1+4,a=new DataView(new ArrayBuffer(1+i));return a.setUint8(0,69),a.setInt32(1,i,!1),new TextEncoder().encodeInto(t,new Uint8Array(a.buffer,5)),a.setUint8(n+5,0),a.setUint32(a.byteLength-4,r,!1),new Uint8Array(a.buffer)},Ur=(e,t)=>{let r=new DataView(new ArrayBuffer(16));return r.setInt32(0,16,!1),r.setInt16(4,1234,!1),r.setInt16(6,5678,!1),r.setInt32(8,e,!1),r.setInt32(12,t,!1),new Uint8Array(r.buffer)},Ne=(e,t)=>{let r=new T;return r.addCString(t),r.flush(e)},Nr=m.addCString("P").flush(68),Lr=m.addCString("S").flush(68),kr=e=>e.name?Ne(68,`${e.type}${e.name??""}`):e.type==="P"?Nr:Lr,Or=e=>{let t=`${e.type}${e.name??""}`;return Ne(67,t)},Vr=e=>m.add(e).flush(100),vr=e=>Ne(102,e),pe=e=>new Uint8Array([e,0,0,0,4]),Fr=pe(72),Gr=pe(83),Wr=pe(88),jr=pe(99),O={startup:Ar,password:xr,requestSsl:Br,sendSASLInitialResponseMessage:Sr,sendSCRAMClientFinalMessage:Dr,query:Ir,parse:Mr,bind:Er,execute:Pr,describe:kr,close:Or,flush:()=>Fr,sync:()=>Gr,end:()=>Wr,copyData:Vr,copyDone:()=>jr,copyFail:vr,cancel:Ur};y();y();var Le={text:0,binary:1};y();var Qr=new ArrayBuffer(0),M,w,fe,me,re,de=class{constructor(t=0){h(this,M,new DataView(Qr));h(this,w);h(this,fe,"utf-8");h(this,me,new TextDecoder(s(this,fe)));h(this,re,!1);d(this,w,t)}setBuffer(t,r){d(this,w,t),d(this,M,new DataView(r))}int16(){let t=s(this,M).getInt16(s(this,w),s(this,re));return d(this,w,s(this,w)+2),t}byte(){let t=s(this,M).getUint8(s(this,w));return oe(this,w)._++,t}int32(){let t=s(this,M).getInt32(s(this,w),s(this,re));return d(this,w,s(this,w)+4),t}string(t){return s(this,me).decode(this.bytes(t))}cstring(){let t=s(this,w),r=t;for(;s(this,M).getUint8(r++)!==0;);let n=this.string(r-t-1);return d(this,w,r),n}bytes(t){let r=s(this,M).buffer.slice(s(this,w),s(this,w)+t);return d(this,w,s(this,w)+t),new Uint8Array(r)}};M=new WeakMap,w=new WeakMap,fe=new WeakMap,me=new WeakMap,re=new WeakMap;var ke=1,_r=4,Ze=ke+_r,et=new ArrayBuffer(0);var A,x,S,o,l,tt,rt,nt,st,it,at,ot,Oe,ut,lt,ct,pt,dt,ft,mt,yt,Ve,ye=class{constructor(){h(this,l);h(this,A,new DataView(et));h(this,x,0);h(this,S,0);h(this,o,new de)}parse(t,r){p(this,l,tt).call(this,ArrayBuffer.isView(t)?t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength):t);let n=s(this,S)+s(this,x),i=s(this,S);for(;i+Ze<=n;){let a=s(this,A).getUint8(i),u=s(this,A).getUint32(i+ke,!1),f=ke+u;if(f+i<=n&&u>0){let c=p(this,l,rt).call(this,i+Ze,a,u,s(this,A).buffer);r(c),i+=f}else break}i===n?(d(this,A,new DataView(et)),d(this,x,0),d(this,S,0)):(d(this,x,n-i),d(this,S,i))}};A=new WeakMap,x=new WeakMap,S=new WeakMap,o=new WeakMap,l=new WeakSet,tt=function(t){if(s(this,x)>0){let r=s(this,x)+t.byteLength;if(r+s(this,S)>s(this,A).byteLength){let i;if(r<=s(this,A).byteLength&&s(this,S)>=s(this,x))i=s(this,A).buffer;else{let a=s(this,A).byteLength*2;for(;r>=a;)a*=2;i=new ArrayBuffer(a)}new Uint8Array(i).set(new Uint8Array(s(this,A).buffer,s(this,S),s(this,x))),d(this,A,new DataView(i)),d(this,S,0)}new Uint8Array(s(this,A).buffer).set(new Uint8Array(t),s(this,S)+s(this,x)),d(this,x,r)}else d(this,A,new DataView(t)),d(this,S,0),d(this,x,t.byteLength)},rt=function(t,r,n,i){switch(r){case 50:return Ie;case 49:return De;case 51:return Re;case 110:return Me;case 115:return Te;case 99:return Pe;case 87:return Ee;case 73:return Ce;case 68:return p(this,l,dt).call(this,t,n,i);case 67:return p(this,l,st).call(this,t,n,i);case 90:return p(this,l,nt).call(this,t,n,i);case 65:return p(this,l,ut).call(this,t,n,i);case 82:return p(this,l,yt).call(this,t,n,i);case 83:return p(this,l,ft).call(this,t,n,i);case 75:return p(this,l,mt).call(this,t,n,i);case 69:return p(this,l,Ve).call(this,t,n,i,"error");case 78:return p(this,l,Ve).call(this,t,n,i,"notice");case 84:return p(this,l,lt).call(this,t,n,i);case 116:return p(this,l,pt).call(this,t,n,i);case 71:return p(this,l,at).call(this,t,n,i);case 72:return p(this,l,ot).call(this,t,n,i);case 100:return p(this,l,it).call(this,t,n,i);default:return new C("received invalid response: "+r.toString(16),n,"error")}},nt=function(t,r,n){s(this,o).setBuffer(t,n);let i=s(this,o).string(1);return new X(r,i)},st=function(t,r,n){s(this,o).setBuffer(t,n);let i=s(this,o).cstring();return new Z(r,i)},it=function(t,r,n){let i=n.slice(t,t+(r-4));return new _(r,new Uint8Array(i))},at=function(t,r,n){return p(this,l,Oe).call(this,t,r,n,"copyInResponse")},ot=function(t,r,n){return p(this,l,Oe).call(this,t,r,n,"copyOutResponse")},Oe=function(t,r,n,i){s(this,o).setBuffer(t,n);let a=s(this,o).byte()!==0,u=s(this,o).int16(),f=new z(r,i,a,u);for(let c=0;c<u;c++)f.columnTypes[c]=s(this,o).int16();return f},ut=function(t,r,n){s(this,o).setBuffer(t,n);let i=s(this,o).int32(),a=s(this,o).cstring(),u=s(this,o).cstring();return new J(r,i,a,u)},lt=function(t,r,n){s(this,o).setBuffer(t,n);let i=s(this,o).int16(),a=new q(r,i);for(let u=0;u<i;u++)a.fields[u]=p(this,l,ct).call(this);return a},ct=function(){let t=s(this,o).cstring(),r=s(this,o).int32(),n=s(this,o).int16(),i=s(this,o).int32(),a=s(this,o).int16(),u=s(this,o).int32(),f=s(this,o).int16()===0?Le.text:Le.binary;return new H(t,r,n,i,a,u,f)},pt=function(t,r,n){s(this,o).setBuffer(t,n);let i=s(this,o).int16(),a=new Y(r,i);for(let u=0;u<i;u++)a.dataTypeIDs[u]=s(this,o).int32();return a},dt=function(t,r,n){s(this,o).setBuffer(t,n);let i=s(this,o).int16(),a=new Array(i);for(let u=0;u<i;u++){let f=s(this,o).int32();a[u]=f===-1?null:s(this,o).string(f)}return new ee(r,a)},ft=function(t,r,n){s(this,o).setBuffer(t,n);let i=s(this,o).cstring(),a=s(this,o).cstring();return new $(r,i,a)},mt=function(t,r,n){s(this,o).setBuffer(t,n);let i=s(this,o).int32(),a=s(this,o).int32();return new K(r,i,a)},yt=function(t,r,n){s(this,o).setBuffer(t,n);let i=s(this,o).int32();switch(i){case 0:return new v(r);case 3:return new F(r);case 5:return new G(r,s(this,o).bytes(4));case 10:{let a=[];for(;;){let u=s(this,o).cstring();if(u.length===0)return new W(r,a);a.push(u)}}case 11:return new j(r,s(this,o).string(r-8));case 12:return new Q(r,s(this,o).string(r-8));default:throw new Error("Unknown authenticationOk message type "+i)}},Ve=function(t,r,n,i){s(this,o).setBuffer(t,n);let a={},u=s(this,o).string(1);for(;u!=="\0";)a[u]=s(this,o).cstring(),u=s(this,o).string(1);let f=a.M,c=i==="notice"?new te(r,f):new C(f,r,i);return c.severity=a.S,c.code=a.C,c.detail=a.D,c.hint=a.H,c.position=a.P,c.internalPosition=a.p,c.internalQuery=a.q,c.where=a.W,c.schema=a.s,c.table=a.t,c.column=a.c,c.dataType=a.d,c.constraint=a.n,c.file=a.F,c.line=a.L,c.routine=a.R,c};y();var ve=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",se;function ht(){try{return new URL("./pglite.wasm",import.meta.url)}catch{throw new Error("Cannot resolve WASM URL. In Cloudflare Workers, you must provide wasmModule option.")}}function Hr(){try{return new URL("./pglite.data",import.meta.url)}catch{throw new Error("Cannot resolve fsBundle URL. In Cloudflare Workers, you must provide fsBundle option.")}}async function En(){if(ve||se)return;let e=ht();se=fetch(e)}var ne;async function Cn(e,t){if(t||ne)return{instance:await WebAssembly.instantiate(t||ne,e),module:t||ne};let r=ht();if(ve){let i=await(await import("fs/promises")).readFile(r),{module:a,instance:u}=await WebAssembly.instantiate(i,e);return ne=a,{instance:u,module:a}}else{se||(se=fetch(r));let n=await se,{module:i,instance:a}=await WebAssembly.instantiateStreaming(n,e);return ne=i,{instance:a,module:i}}}async function Pn(){let e=Hr();return ve?(await(await import("fs/promises")).readFile(e)).buffer:(await fetch(e)).arrayBuffer()}var Un=()=>{if(globalThis.crypto?.randomUUID)return globalThis.crypto.randomUUID();let e=new Uint8Array(16);if(globalThis.crypto?.getRandomValues)globalThis.crypto.getRandomValues(e);else for(let r=0;r<e.length;r++)e[r]=Math.floor(Math.random()*256);e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=[];return e.forEach(r=>{t.push(r.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("")};async function Nn(e,t,r,n){if(!r||r.length===0)return t;n=n??e;let i=[];try{await e.execProtocol(O.parse({text:t}),{syncToFs:!1}),i.push(...(await e.execProtocol(O.describe({type:"S"}),{syncToFs:!1})).messages)}finally{i.push(...(await e.execProtocol(O.sync(),{syncToFs:!1})).messages)}let a=Se(i),u=t.replace(/\$([0-9]+)/g,(c,R)=>"%"+R+"L");return(await n.query(`SELECT format($1, ${r.map((c,R)=>`$${R+2}`).join(", ")}) as query`,[u,...r],{paramTypes:[V,...a]})).rows[0].query}function Ln(e){let t,r=!1,n=async()=>{if(!t){r=!1;return}r=!0;let{args:i,resolve:a,reject:u}=t;t=void 0;try{let f=await e(...i);a(f)}catch(f){u(f)}finally{n()}};return async(...i)=>{t&&t.resolve(void 0);let a=new Promise((u,f)=>{t={args:i,resolve:u,reject:f}});return r||n(),a}}function kn(e){let t;return e.startsWith('"')&&e.endsWith('"')?t=e.substring(1,e.length-1):t=e.toLowerCase(),t}export{lr as a,cr as b,Ke as c,yr as d,hr as e,br as f,Se as g,wr as h,O as i,C as j,J as k,Z as l,te as m,Ue as n,ye as o,zr as p,ve as q,En as r,Cn as s,Pn as t,Un as u,Nn as v,Ln as w,kn as x};
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{b as ae,e as s,f as h,g as d,h as p,i as oe,j as y}from"./chunk-VCBR6USK.js";var hr={};ae(hr,{ABSTIME:()=>Ct,ACLITEM:()=>Ft,BIT:()=>_t,BOOL:()=>be,BPCHAR:()=>Qe,BYTEA:()=>ge,CHAR:()=>wt,CID:()=>St,CIDR:()=>Et,CIRCLE:()=>Lt,DATE:()=>He,FLOAT4:()=>_e,FLOAT8:()=>je,GTSVECTOR:()=>sr,INET:()=>Vt,INT2:()=>ve,INT4:()=>Ge,INT8:()=>we,INTERVAL:()=>Gt,JSON:()=>Ae,JSONB:()=>Ye,MACADDR:()=>kt,MACADDR8:()=>Nt,MONEY:()=>Ot,NUMERIC:()=>Qt,OID:()=>We,PATH:()=>Mt,PG_DEPENDENCIES:()=>tr,PG_LSN:()=>Zt,PG_NDISTINCT:()=>er,PG_NODE_TREE:()=>It,POLYGON:()=>Tt,REFCURSOR:()=>zt,REGCLASS:()=>$t,REGCONFIG:()=>ir,REGDICTIONARY:()=>ar,REGNAMESPACE:()=>or,REGOPER:()=>qt,REGOPERATOR:()=>Yt,REGPROC:()=>At,REGPROCEDURE:()=>Ht,REGROLE:()=>ur,REGTYPE:()=>Kt,RELTIME:()=>Pt,SMGR:()=>Rt,TEXT:()=>V,TID:()=>Bt,TIME:()=>vt,TIMESTAMP:()=>qe,TIMESTAMPTZ:()=>Be,TIMETZ:()=>Wt,TINTERVAL:()=>Ut,TSQUERY:()=>nr,TSVECTOR:()=>rr,TXID_SNAPSHOT:()=>Xt,UUID:()=>Jt,VARBIT:()=>jt,VARCHAR:()=>ze,XID:()=>xt,XML:()=>Dt,arrayParser:()=>yr,arraySerializer:()=>Ke,parseType:()=>ue,parsers:()=>lr,serializers:()=>cr,types:()=>$e});y();var bt=globalThis.JSON.parse,gt=globalThis.JSON.stringify,be=16,ge=17,wt=18,we=20,ve=21,Ge=23,At=24,V=25,We=26,Bt=27,xt=28,St=29,Ae=114,Dt=142,It=194,Rt=210,Mt=602,Tt=604,Et=650,_e=700,je=701,Ct=702,Pt=703,Ut=704,Lt=718,Nt=774,Ot=790,kt=829,Vt=869,Ft=1033,Qe=1042,ze=1043,He=1082,vt=1083,qe=1114,Be=1184,Gt=1186,Wt=1266,_t=1560,jt=1562,Qt=1700,zt=1790,Ht=2202,qt=2203,Yt=2204,$t=2205,Kt=2206,Jt=2950,Xt=2970,Zt=3220,er=3361,tr=3402,rr=3614,nr=3615,sr=3642,ir=3734,ar=3769,Ye=3802,or=4089,ur=4096,$e={string:{to:V,from:[V,ze,Qe],serialize:e=>{if(typeof e=="string")return e;if(typeof e=="number")return e.toString();throw new Error("Invalid input for string type")},parse:e=>e},number:{to:0,from:[ve,Ge,We,_e,je],serialize:e=>e.toString(),parse:e=>+e},bigint:{to:we,from:[we],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:Ae,from:[Ae,Ye],serialize:e=>typeof e=="string"?e:gt(e),parse:e=>bt(e)},boolean:{to:be,from:[be],serialize:e=>{if(typeof e!="boolean")throw new Error("Invalid input for boolean type");return e?"t":"f"},parse:e=>e==="t"},date:{to:Be,from:[He,qe,Be],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:ge,from:[ge],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},(r,n)=>parseInt(t.substring(n*2,(n+1)*2),16))}}},xe=pr($e),lr=xe.parsers,cr=xe.serializers;function ue(e,t,r){if(e===null)return null;let n=r?.[t]??xe.parsers[t];return n?n(e,t):e}function pr(e){return Object.keys(e).reduce(({parsers:t,serializers:r},n)=>{let{to:i,from:a,serialize:u,parse:f}=e[n];return r[i]=u,r[n]=u,t[n]=f,Array.isArray(a)?a.forEach(c=>{t[c]=f,r[c]=u}):(t[a]=f,r[a]=u),{parsers:t,serializers:r}},{parsers:{},serializers:{}})}var dr=/\\/g,fr=/"/g;function mr(e){return e.replace(dr,"\\\\").replace(fr,'\\"')}function Ke(e,t,r){if(Array.isArray(e)===!1)return e;if(!e.length)return"{}";let n=e[0],i=r===1020?";":",";return Array.isArray(n)?`{${e.map(a=>Ke(a,t,r)).join(i)}}`:`{${e.map(a=>(a===void 0&&(a=null),a===null?"null":'"'+mr(t?t(a):a.toString())+'"')).join(i)}}`}var he={i:0,char:null,str:"",quoted:!1,last:0,p:null};function yr(e,t,r){return he.i=he.last=0,Je(he,e,t,r)[0]}function Je(e,t,r,n){let i=[],a=n===1020?";":",";for(;e.i<t.length;e.i++){if(e.char=t[e.i],e.quoted)e.char==="\\"?e.str+=t[++e.i]:e.char==='"'?(i.push(r?r(e.str):e.str),e.str="",e.quoted=t[e.i+1]==='"',e.last=e.i+2):e.str+=e.char;else if(e.char==='"')e.quoted=!0;else if(e.char==="{")e.last=++e.i,i.push(Je(e,t,r,n));else if(e.char==="}"){e.quoted=!1,e.last<e.i&&i.push(r?r(t.slice(e.last,e.i)):t.slice(e.last,e.i)),e.last=e.i+1;break}else e.char===a&&e.p!=="}"&&e.p!=='"'&&(i.push(r?r(t.slice(e.last,e.i)):t.slice(e.last,e.i)),e.last=e.i+1);e.p=e.char}return e.last<e.i&&i.push(r?r(t.slice(e.last,e.i+1)):t.slice(e.last,e.i+1)),i}var wr={};ae(wr,{parseDescribeStatementResults:()=>Se,parseResults:()=>br});y();function br(e,t,r,n){let i=[],a={rows:[],fields:[]},u=0,f={...t,...r?.parsers};return e.forEach(c=>{switch(c.name){case"rowDescription":{let R=c;a.fields=R.fields.map(E=>({name:E.name,dataTypeID:E.dataTypeID}));break}case"dataRow":{if(!a)break;let R=c;r?.rowMode==="array"?a.rows.push(R.fields.map((E,ie)=>ue(E,a.fields[ie].dataTypeID,f))):a.rows.push(Object.fromEntries(R.fields.map((E,ie)=>[a.fields[ie].name,ue(E,a.fields[ie].dataTypeID,f)])));break}case"commandComplete":{u+=gr(c),i.push({...a,affectedRows:u,...n?{blob:n}:{}}),a={rows:[],fields:[]};break}}}),i.length===0&&i.push({affectedRows:0,rows:[],fields:[]}),i}function gr(e){let t=e.text.split(" ");switch(t[0]){case"INSERT":return parseInt(t[2],10);case"UPDATE":case"DELETE":case"COPY":case"MERGE":return parseInt(t[1],10);default:return 0}}function Se(e){let t=e.find(r=>r.name==="parameterDescription");return t?t.dataTypeIDs:[]}var Ue={};ae(Ue,{AuthenticationCleartextPassword:()=>v,AuthenticationMD5Password:()=>G,AuthenticationOk:()=>F,AuthenticationSASL:()=>W,AuthenticationSASLContinue:()=>_,AuthenticationSASLFinal:()=>j,BackendKeyDataMessage:()=>K,CommandCompleteMessage:()=>Z,CopyDataMessage:()=>Q,CopyResponse:()=>z,DataRowMessage:()=>ee,DatabaseError:()=>C,Field:()=>H,NoticeMessage:()=>te,NotificationResponseMessage:()=>J,ParameterDescriptionMessage:()=>Y,ParameterStatusMessage:()=>$,ReadyForQueryMessage:()=>X,RowDescriptionMessage:()=>q,bindComplete:()=>Ie,closeComplete:()=>Re,copyDone:()=>Pe,emptyQuery:()=>Ce,noData:()=>Me,parseComplete:()=>De,portalSuspended:()=>Te,replicationStart:()=>Ee});y();var De={name:"parseComplete",length:5},Ie={name:"bindComplete",length:5},Re={name:"closeComplete",length:5},Me={name:"noData",length:5},Te={name:"portalSuspended",length:5},Ee={name:"replicationStart",length:4},Ce={name:"emptyQuery",length:4},Pe={name:"copyDone",length:4},F=class{constructor(t){this.length=t;this.name="authenticationOk"}},v=class{constructor(t){this.length=t;this.name="authenticationCleartextPassword"}},G=class{constructor(t,r){this.length=t;this.salt=r;this.name="authenticationMD5Password"}},W=class{constructor(t,r){this.length=t;this.mechanisms=r;this.name="authenticationSASL"}},_=class{constructor(t,r){this.length=t;this.data=r;this.name="authenticationSASLContinue"}},j=class{constructor(t,r){this.length=t;this.data=r;this.name="authenticationSASLFinal"}},C=class extends Error{constructor(r,n,i){super(r);this.length=n;this.name=i}},Q=class{constructor(t,r){this.length=t;this.chunk=r;this.name="copyData"}},z=class{constructor(t,r,n,i){this.length=t;this.name=r;this.binary=n;this.columnTypes=new Array(i)}},H=class{constructor(t,r,n,i,a,u,f){this.name=t;this.tableID=r;this.columnID=n;this.dataTypeID=i;this.dataTypeSize=a;this.dataTypeModifier=u;this.format=f}},q=class{constructor(t,r){this.length=t;this.fieldCount=r;this.name="rowDescription";this.fields=new Array(this.fieldCount)}},Y=class{constructor(t,r){this.length=t;this.parameterCount=r;this.name="parameterDescription";this.dataTypeIDs=new Array(this.parameterCount)}},$=class{constructor(t,r,n){this.length=t;this.parameterName=r;this.parameterValue=n;this.name="parameterStatus"}},K=class{constructor(t,r,n){this.length=t;this.processID=r;this.secretKey=n;this.name="backendKeyData"}},J=class{constructor(t,r,n,i){this.length=t;this.processId=r;this.channel=n;this.payload=i;this.name="notification"}},X=class{constructor(t,r){this.length=t;this.status=r;this.name="readyForQuery"}},Z=class{constructor(t,r){this.length=t;this.text=r;this.name="commandComplete"}},ee=class{constructor(t,r){this.length=t;this.fields=r;this.name="dataRow";this.fieldCount=r.length}},te=class{constructor(t,r){this.length=t;this.message=r;this.name="notice"}};var zr={};ae(zr,{Parser:()=>ye,messages:()=>Ue,serialize:()=>k});y();y();y();y();function P(e){let t=e.length;for(let r=e.length-1;r>=0;r--){let n=e.charCodeAt(r);n>127&&n<=2047?t++:n>2047&&n<=65535&&(t+=2),n>=56320&&n<=57343&&r--}return t}var b,g,L,ce,N,B,le,U,Xe,T=class{constructor(t=256){this.size=t;h(this,B);h(this,b);h(this,g,5);h(this,L,!1);h(this,ce,new TextEncoder);h(this,N,0);d(this,b,p(this,B,le).call(this,t))}addInt32(t){return p(this,B,U).call(this,4),s(this,b).setInt32(s(this,g),t,s(this,L)),d(this,g,s(this,g)+4),this}addInt16(t){return p(this,B,U).call(this,2),s(this,b).setInt16(s(this,g),t,s(this,L)),d(this,g,s(this,g)+2),this}addCString(t){return t&&this.addString(t),p(this,B,U).call(this,1),s(this,b).setUint8(s(this,g),0),oe(this,g)._++,this}addString(t=""){let r=P(t);return p(this,B,U).call(this,r),s(this,ce).encodeInto(t,new Uint8Array(s(this,b).buffer,s(this,g))),d(this,g,s(this,g)+r),this}add(t){return p(this,B,U).call(this,t.byteLength),new Uint8Array(s(this,b).buffer).set(new Uint8Array(t),s(this,g)),d(this,g,s(this,g)+t.byteLength),this}flush(t){let r=p(this,B,Xe).call(this,t);return d(this,g,5),d(this,b,p(this,B,le).call(this,this.size)),new Uint8Array(r)}};b=new WeakMap,g=new WeakMap,L=new WeakMap,ce=new WeakMap,N=new WeakMap,B=new WeakSet,le=function(t){return new DataView(new ArrayBuffer(t))},U=function(t){if(s(this,b).byteLength-s(this,g)<t){let n=s(this,b).buffer,i=n.byteLength+(n.byteLength>>1)+t;d(this,b,p(this,B,le).call(this,i)),new Uint8Array(s(this,b).buffer).set(new Uint8Array(n))}},Xe=function(t){if(t){s(this,b).setUint8(s(this,N),t);let r=s(this,g)-(s(this,N)+1);s(this,b).setInt32(s(this,N)+1,r,s(this,L))}return s(this,b).buffer.slice(t?0:5,s(this,g))};var m=new T,Ar=e=>{m.addInt16(3).addInt16(0);for(let n of Object.keys(e))m.addCString(n).addCString(e[n]);m.addCString("client_encoding").addCString("UTF8");let t=m.addCString("").flush(),r=t.byteLength+4;return new T().addInt32(r).add(t.buffer).flush()},Br=()=>{let e=new DataView(new ArrayBuffer(8));return e.setInt32(0,8,!1),e.setInt32(4,80877103,!1),new Uint8Array(e.buffer)},xr=e=>m.addCString(e).flush(112),Sr=(e,t)=>(m.addCString(e).addInt32(P(t)).addString(t),m.flush(112)),Dr=e=>m.addString(e).flush(112),Ir=e=>m.addCString(e).flush(81),Rr=[],Mr=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 r=m.addCString(t).addCString(e.text).addInt16(e.types?.length??0);return e.types?.forEach(n=>r.addInt32(n)),m.flush(80)},O=new T;var Tr=(e,t)=>{for(let r=0;r<e.length;r++){let n=t?t(e[r],r):e[r];if(n===null)m.addInt16(0),O.addInt32(-1);else if(n instanceof ArrayBuffer||ArrayBuffer.isView(n)){let i=ArrayBuffer.isView(n)?n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength):n;m.addInt16(1),O.addInt32(i.byteLength),O.add(i)}else m.addInt16(0),O.addInt32(P(n)),O.addString(n)}},Er=(e={})=>{let t=e.portal??"",r=e.statement??"",n=e.binary??!1,i=e.values??Rr,a=i.length;return m.addCString(t).addCString(r),m.addInt16(a),Tr(i,e.valueMapper),m.addInt16(a),m.add(O.flush().buffer),m.addInt16(n?1:0),m.flush(66)},Cr=new Uint8Array([69,0,0,0,9,0,0,0,0,0]),Pr=e=>{if(!e||!e.portal&&!e.rows)return Cr;let t=e.portal??"",r=e.rows??0,n=P(t),i=4+n+1+4,a=new DataView(new ArrayBuffer(1+i));return a.setUint8(0,69),a.setInt32(1,i,!1),new TextEncoder().encodeInto(t,new Uint8Array(a.buffer,5)),a.setUint8(n+5,0),a.setUint32(a.byteLength-4,r,!1),new Uint8Array(a.buffer)},Ur=(e,t)=>{let r=new DataView(new ArrayBuffer(16));return r.setInt32(0,16,!1),r.setInt16(4,1234,!1),r.setInt16(6,5678,!1),r.setInt32(8,e,!1),r.setInt32(12,t,!1),new Uint8Array(r.buffer)},Le=(e,t)=>{let r=new T;return r.addCString(t),r.flush(e)},Lr=m.addCString("P").flush(68),Nr=m.addCString("S").flush(68),Or=e=>e.name?Le(68,`${e.type}${e.name??""}`):e.type==="P"?Lr:Nr,kr=e=>{let t=`${e.type}${e.name??""}`;return Le(67,t)},Vr=e=>m.add(e).flush(100),Fr=e=>Le(102,e),pe=e=>new Uint8Array([e,0,0,0,4]),vr=pe(72),Gr=pe(83),Wr=pe(88),_r=pe(99),k={startup:Ar,password:xr,requestSsl:Br,sendSASLInitialResponseMessage:Sr,sendSCRAMClientFinalMessage:Dr,query:Ir,parse:Mr,bind:Er,execute:Pr,describe:Or,close:kr,flush:()=>vr,sync:()=>Gr,end:()=>Wr,copyData:Vr,copyDone:()=>_r,copyFail:Fr,cancel:Ur};y();y();var Ne={text:0,binary:1};y();var jr=new ArrayBuffer(0),M,w,fe,me,re,de=class{constructor(t=0){h(this,M,new DataView(jr));h(this,w);h(this,fe,"utf-8");h(this,me,new TextDecoder(s(this,fe)));h(this,re,!1);d(this,w,t)}setBuffer(t,r){d(this,w,t),d(this,M,new DataView(r))}int16(){let t=s(this,M).getInt16(s(this,w),s(this,re));return d(this,w,s(this,w)+2),t}byte(){let t=s(this,M).getUint8(s(this,w));return oe(this,w)._++,t}int32(){let t=s(this,M).getInt32(s(this,w),s(this,re));return d(this,w,s(this,w)+4),t}string(t){return s(this,me).decode(this.bytes(t))}cstring(){let t=s(this,w),r=t;for(;s(this,M).getUint8(r++)!==0;);let n=this.string(r-t-1);return d(this,w,r),n}bytes(t){let r=s(this,M).buffer.slice(s(this,w),s(this,w)+t);return d(this,w,s(this,w)+t),new Uint8Array(r)}};M=new WeakMap,w=new WeakMap,fe=new WeakMap,me=new WeakMap,re=new WeakMap;var Oe=1,Qr=4,Ze=Oe+Qr,et=new ArrayBuffer(0);var A,x,S,o,l,tt,rt,nt,st,it,at,ot,ke,ut,lt,ct,pt,dt,ft,mt,yt,Ve,ye=class{constructor(){h(this,l);h(this,A,new DataView(et));h(this,x,0);h(this,S,0);h(this,o,new de)}parse(t,r){p(this,l,tt).call(this,ArrayBuffer.isView(t)?t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength):t);let n=s(this,S)+s(this,x),i=s(this,S);for(;i+Ze<=n;){let a=s(this,A).getUint8(i),u=s(this,A).getUint32(i+Oe,!1),f=Oe+u;if(f+i<=n&&u>0){let c=p(this,l,rt).call(this,i+Ze,a,u,s(this,A).buffer);r(c),i+=f}else break}i===n?(d(this,A,new DataView(et)),d(this,x,0),d(this,S,0)):(d(this,x,n-i),d(this,S,i))}};A=new WeakMap,x=new WeakMap,S=new WeakMap,o=new WeakMap,l=new WeakSet,tt=function(t){if(s(this,x)>0){let r=s(this,x)+t.byteLength;if(r+s(this,S)>s(this,A).byteLength){let i;if(r<=s(this,A).byteLength&&s(this,S)>=s(this,x))i=s(this,A).buffer;else{let a=s(this,A).byteLength*2;for(;r>=a;)a*=2;i=new ArrayBuffer(a)}new Uint8Array(i).set(new Uint8Array(s(this,A).buffer,s(this,S),s(this,x))),d(this,A,new DataView(i)),d(this,S,0)}new Uint8Array(s(this,A).buffer).set(new Uint8Array(t),s(this,S)+s(this,x)),d(this,x,r)}else d(this,A,new DataView(t)),d(this,S,0),d(this,x,t.byteLength)},rt=function(t,r,n,i){switch(r){case 50:return Ie;case 49:return De;case 51:return Re;case 110:return Me;case 115:return Te;case 99:return Pe;case 87:return Ee;case 73:return Ce;case 68:return p(this,l,dt).call(this,t,n,i);case 67:return p(this,l,st).call(this,t,n,i);case 90:return p(this,l,nt).call(this,t,n,i);case 65:return p(this,l,ut).call(this,t,n,i);case 82:return p(this,l,yt).call(this,t,n,i);case 83:return p(this,l,ft).call(this,t,n,i);case 75:return p(this,l,mt).call(this,t,n,i);case 69:return p(this,l,Ve).call(this,t,n,i,"error");case 78:return p(this,l,Ve).call(this,t,n,i,"notice");case 84:return p(this,l,lt).call(this,t,n,i);case 116:return p(this,l,pt).call(this,t,n,i);case 71:return p(this,l,at).call(this,t,n,i);case 72:return p(this,l,ot).call(this,t,n,i);case 100:return p(this,l,it).call(this,t,n,i);default:return new C("received invalid response: "+r.toString(16),n,"error")}},nt=function(t,r,n){s(this,o).setBuffer(t,n);let i=s(this,o).string(1);return new X(r,i)},st=function(t,r,n){s(this,o).setBuffer(t,n);let i=s(this,o).cstring();return new Z(r,i)},it=function(t,r,n){let i=n.slice(t,t+(r-4));return new Q(r,new Uint8Array(i))},at=function(t,r,n){return p(this,l,ke).call(this,t,r,n,"copyInResponse")},ot=function(t,r,n){return p(this,l,ke).call(this,t,r,n,"copyOutResponse")},ke=function(t,r,n,i){s(this,o).setBuffer(t,n);let a=s(this,o).byte()!==0,u=s(this,o).int16(),f=new z(r,i,a,u);for(let c=0;c<u;c++)f.columnTypes[c]=s(this,o).int16();return f},ut=function(t,r,n){s(this,o).setBuffer(t,n);let i=s(this,o).int32(),a=s(this,o).cstring(),u=s(this,o).cstring();return new J(r,i,a,u)},lt=function(t,r,n){s(this,o).setBuffer(t,n);let i=s(this,o).int16(),a=new q(r,i);for(let u=0;u<i;u++)a.fields[u]=p(this,l,ct).call(this);return a},ct=function(){let t=s(this,o).cstring(),r=s(this,o).int32(),n=s(this,o).int16(),i=s(this,o).int32(),a=s(this,o).int16(),u=s(this,o).int32(),f=s(this,o).int16()===0?Ne.text:Ne.binary;return new H(t,r,n,i,a,u,f)},pt=function(t,r,n){s(this,o).setBuffer(t,n);let i=s(this,o).int16(),a=new Y(r,i);for(let u=0;u<i;u++)a.dataTypeIDs[u]=s(this,o).int32();return a},dt=function(t,r,n){s(this,o).setBuffer(t,n);let i=s(this,o).int16(),a=new Array(i);for(let u=0;u<i;u++){let f=s(this,o).int32();a[u]=f===-1?null:s(this,o).string(f)}return new ee(r,a)},ft=function(t,r,n){s(this,o).setBuffer(t,n);let i=s(this,o).cstring(),a=s(this,o).cstring();return new $(r,i,a)},mt=function(t,r,n){s(this,o).setBuffer(t,n);let i=s(this,o).int32(),a=s(this,o).int32();return new K(r,i,a)},yt=function(t,r,n){s(this,o).setBuffer(t,n);let i=s(this,o).int32();switch(i){case 0:return new F(r);case 3:return new v(r);case 5:return new G(r,s(this,o).bytes(4));case 10:{let a=[];for(;;){let u=s(this,o).cstring();if(u.length===0)return new W(r,a);a.push(u)}}case 11:return new _(r,s(this,o).string(r-8));case 12:return new j(r,s(this,o).string(r-8));default:throw new Error("Unknown authenticationOk message type "+i)}},Ve=function(t,r,n,i){s(this,o).setBuffer(t,n);let a={},u=s(this,o).string(1);for(;u!=="\0";)a[u]=s(this,o).cstring(),u=s(this,o).string(1);let f=a.M,c=i==="notice"?new te(r,f):new C(f,r,i);return c.severity=a.S,c.code=a.C,c.detail=a.D,c.hint=a.H,c.position=a.P,c.internalPosition=a.p,c.internalQuery=a.q,c.where=a.W,c.schema=a.s,c.table=a.t,c.column=a.c,c.dataType=a.d,c.constraint=a.n,c.file=a.F,c.line=a.L,c.routine=a.R,c};y();var Fe=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string"&&typeof globalThis.caches>"u",En=typeof globalThis.caches<"u"&&typeof globalThis.HTMLRewriter<"u",se;function ht(){try{return new URL("./pglite.wasm","")}catch{throw new Error("Cannot resolve WASM URL. In Cloudflare Workers, you must provide wasmModule option.")}}function Hr(){try{return new URL("./pglite.data","")}catch{throw new Error("Cannot resolve fsBundle URL. In Cloudflare Workers, you must provide fsBundle option.")}}async function Cn(){if(Fe||se)return;let e=ht();se=fetch(e)}var ne;async function Pn(e,t){if(t||ne)return{instance:await WebAssembly.instantiate(t||ne,e),module:t||ne};let r=ht();if(Fe){let i=await(await import("fs/promises")).readFile(r),{module:a,instance:u}=await WebAssembly.instantiate(i,e);return ne=a,{instance:u,module:a}}else{se||(se=fetch(r));let n=await se,{module:i,instance:a}=await WebAssembly.instantiateStreaming(n,e);return ne=i,{instance:a,module:i}}}async function Un(){let e=Hr();return Fe?(await(await import("fs/promises")).readFile(e)).buffer:(await fetch(e)).arrayBuffer()}var Ln=()=>{if(globalThis.crypto?.randomUUID)return globalThis.crypto.randomUUID();let e=new Uint8Array(16);if(globalThis.crypto?.getRandomValues)globalThis.crypto.getRandomValues(e);else for(let r=0;r<e.length;r++)e[r]=Math.floor(Math.random()*256);e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=[];return e.forEach(r=>{t.push(r.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("")};async function Nn(e,t,r,n){if(!r||r.length===0)return t;n=n??e;let i=[];try{await e.execProtocol(k.parse({text:t}),{syncToFs:!1}),i.push(...(await e.execProtocol(k.describe({type:"S"}),{syncToFs:!1})).messages)}finally{i.push(...(await e.execProtocol(k.sync(),{syncToFs:!1})).messages)}let a=Se(i),u=t.replace(/\$([0-9]+)/g,(c,R)=>"%"+R+"L");return(await n.query(`SELECT format($1, ${r.map((c,R)=>`$${R+2}`).join(", ")}) as query`,[u,...r],{paramTypes:[V,...a]})).rows[0].query}function On(e){let t,r=!1,n=async()=>{if(!t){r=!1;return}r=!0;let{args:i,resolve:a,reject:u}=t;t=void 0;try{let f=await e(...i);a(f)}catch(f){u(f)}finally{n()}};return async(...i)=>{t&&t.resolve(void 0);let a=new Promise((u,f)=>{t={args:i,resolve:u,reject:f}});return r||n(),a}}function kn(e){let t;return e.startsWith('"')&&e.endsWith('"')?t=e.substring(1,e.length-1):t=e.toLowerCase(),t}export{lr as a,cr as b,Ke as c,yr as d,hr as e,br as f,Se as g,wr as h,k as i,C as j,J as k,Z as l,te as m,Ue as n,ye as o,zr as p,Fe as q,Cn as r,Pn as s,Un as t,Ln as u,Nn as v,On as w,kn as x};
|
|
2
|
+
//# sourceMappingURL=chunk-CEDUAATT.js.map
|