UNPKG

@electric-sql/pglite

Version:

PGlite is a WASM Postgres build packaged into a TypeScript client library that enables you to run Postgres in the browser, Node.js and Bun, with no need to install any other dependencies. It is only 3.7mb gzipped.

2 lines 2.17 kB
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