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 1.95 kB
import{j as u}from"./chunk-QY3QWFKW.js";u();var f=Object.defineProperty,d=(t,e)=>{for(var r in e)f(t,r,{get:e[r],enumerable:!0})},m={};d(m,{IN_NODE:()=>s,getFsBundle:()=>p,instantiateWasm:()=>h,rmdirRecursive:()=>g,startArtifactDownload:()=>c,toPostgresName:()=>b,uuid:()=>y});var s=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",n=new Map;async function c(t){s||n.has(t.toString())||n.set(t.toString(),fetch(t))}var o=new Map;async function h(t,e,r){if(r||o.has(e.toString())){let a=r||o.get(e.toString());return{instance:await WebAssembly.instantiate(a,t),module:a}}if(s){let a=await(await import("fs/promises")).readFile(e),{module:i,instance:l}=await WebAssembly.instantiate(a,t);return o.set(e.toString(),i),{instance:l,module:i}}else{n.has(e.toString())||c(e);let a=await n.get(e.toString()),{module:i,instance:l}=await WebAssembly.instantiateStreaming(a.clone(),t);return o.set(e.toString(),i),{instance:l,module:i}}}async function p(t){return s?(await(await import("fs/promises")).readFile(t)).buffer:(c(t),(await n.get(t.toString())).clone().arrayBuffer())}var y=()=>{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 b(t){let e;return t.startsWith('"')&&t.endsWith('"')?e=t.substring(1,t.length-1):e=t.toLowerCase(),e}function g(t,e){try{let r=t.readdir(e).filter(a=>a!=="."&&a!=="..");for(let a of r){let i=e+"/"+a;try{t.readdir(i),g(t,i)}catch{t.unlink(i)}}t.rmdir(e)}catch{try{t.unlink(e)}catch{}}}export{m as a}; //# sourceMappingURL=chunk-SHISBDX7.js.map