← Public packages
@kentcdodds/world-builder
Build a shared 3D voxel world with friends and your AI agents, live.
public/powersync/MemoryVFS-DVJL5F8j.js
2 lines · 1.6 KB · JavaScriptimport{F as e}from"./FacadeVFS-d1ZDvud7.js";import{j as t,k as a,S as s,n,p as i}from"./worker.js";class r extends e{mapNameToFile=new Map;mapIdToFile=new Map;static async create(e,t){const a=new r(e,t);return await a.isReady(),a}constructor(e,t){super(e,t)}close(){for(const e of this.mapIdToFile.keys())this.jClose(e)}jOpen(e,n,i,r){const o=new URL(e||Math.random().toString(36).slice(2),"file://").pathname;let m=this.mapNameToFile.get(o);if(!m){if(!(i&t))return a;m={pathname:o,flags:i,size:0,data:new ArrayBuffer(0)},this.mapNameToFile.set(o,m)}return this.mapIdToFile.set(n,m),r.setInt32(0,i,!0),s}jClose(e){const t=this.mapIdToFile.get(e);return this.mapIdToFile.delete(e),t.flags&n&&this.mapNameToFile.delete(t.pathname),s}jRead(e,t,a){const n=this.mapIdToFile.get(e),r=Math.min(a,n.size),o=Math.min(a+t.byteLength,n.size)-r;return o&&t.set(new Uint8Array(n.data,r,o)),o<t.byteLength?(t.fill(0,o),i):s}jWrite(e,t,a){const n=this.mapIdToFile.get(e);if(a+t.byteLength>n.data.byteLength){const e=Math.max(a+t.byteLength,2*n.data.byteLength),s=new ArrayBuffer(e);new Uint8Array(s).set(new Uint8Array(n.data,0,n.size)),n.data=s}return new Uint8Array(n.data,a,t.byteLength).set(t.subarray()),n.size=Math.max(n.size,a+t.byteLength),s}jTruncate(e,t){const a=this.mapIdToFile.get(e);return a.size=Math.min(a.size,t),s}jFileSize(e,t){const a=this.mapIdToFile.get(e);return t.setBigInt64(0,BigInt(a.size),!0),s}jDelete(e,t){const a=new URL(e,"file://").pathname;return this.mapNameToFile.delete(a),s}jAccess(e,t,a){const n=new URL(e,"file://").pathname,i=this.mapNameToFile.get(n);return a.setInt32(0,i?1:0,!0),s}}export{r as MemoryVFS};
//# sourceMappingURL=MemoryVFS-DVJL5F8j.js.map