1import{F as e}from"./FacadeVFS-d1ZDvud7.js";import{j as t,S as a,k as s,n as i,p as c,D as n,F as r,r as o,G as l,H as h,I as d}from"./worker.js";const m=4096,p=o|l|h|d;class u extends e{log=null;#e;#t;#a=new Map;#s=new Map;#i=new Set;#c=new Map;static async create(e,t){const a=new u(e,t);return await a.isReady(),a}constructor(e,t){super(e,t),this.#e=e}jOpen(e,i,c,n){try{const s=e?this.#n(e):Math.random().toString(36);let r=this.#s.get(s);if(!r&&c&t){if(!(this.getSize()<this.getCapacity()))throw new Error("cannot create file");[r]=this.#i.keys(),this.#r(r,s,c)}if(!r)throw new Error("file not found");const o={path:s,flags:c,accessHandle:r};return this.#c.set(i,o),n.setInt32(0,c,!0),a}catch(e){return console.error(e.message),s}}jClose(e){const t=this.#c.get(e);return t&&(t.accessHandle.flush(),this.#c.delete(e),t.flags&i&&this.#o(t.path)),a}jRead(e,t,s){const i=this.#c.get(e).accessHandle.read(t.subarray(),{at:m+s});return i<t.byteLength?(t.fill(0,i,t.byteLength),c):a}jWrite(e,t,s){return this.#c.get(e).accessHandle.write(t.subarray(),{at:m+s})===t.byteLength?a:n}jTruncate(e,t){return this.#c.get(e).accessHandle.truncate(m+t),a}jSync(e,t){return this.#c.get(e).accessHandle.flush(),a}jFileSize(e,t){const s=this.#c.get(e).accessHandle.getSize()-m;return t.setBigInt64(0,BigInt(s),!0),a}jSectorSize(e){return 4096}jDeviceCharacteristics(e){return r}jAccess(e,t,s){const i=this.#n(e);return s.setInt32(0,this.#s.has(i)?1:0,!0),a}jDelete(e,t){const s=this.#n(e);return this.#o(s),a}async close(){await this.#l()}async isReady(){if(!this.#t){let e=await navigator.storage.getDirectory();for(const t of this.#e.split("/"))t&&(e=await e.getDirectoryHandle(t,{create:!0}));this.#t=e,await this.#h(),0===this.getCapacity()&&await this.addCapacity(6)}return!0}getSize(){return this.#s.size}getCapacity(){return this.#a.size}async addCapacity(e){for(let t=0;t<e;++t){const e=Math.random().toString(36).replace("0.",""),t=await this.#t.getFileHandle(e,{create:!0}),a=await t.createSyncAccessHandle();this.#a.set(a,e),this.#r(a,"",0)}return e}async removeCapacity(e){let t=0;
1for(const a of Array.from(this.#i)){if(t==e||this.getSize()===this.getCapacity())return t;const s=this.#a.get(a);await a.close(),await this.#t.removeEntry(s),this.#a.delete(a),this.#i.delete(a),++t}return t}async#h(){const e=[];for await(const[t,a]of this.#t)"file"===a.kind&&e.push([t,a]);await Promise.all(e.map(async([e,t])=>{const a=await t.createSyncAccessHandle();this.#a.set(a,e);const s=this.#d(a);s?this.#s.set(s,a):this.#i.add(a)}))}#l(){for(const e of this.#a.keys())e.close();this.#a.clear(),this.#s.clear(),this.#i.clear()}#d(e){const t=new Uint8Array(516);e.read(t,{at:0});const a=new DataView(t.buffer,t.byteOffset).getUint32(512);if(t[0]&&(a&i||0===(a&p)))return console.warn(`Remove file with unexpected flags ${a.toString(16)}`),this.#r(e,"",0),"";const s=new Uint32Array(2);e.read(s,{at:516});const c=this.#m(t);if(s.every((e,t)=>e===c[t])){const a=t.findIndex(e=>0===e);return 0===a&&e.truncate(m),(new TextDecoder).decode(t.subarray(0,a))}return console.warn("Disassociating file with bad digest."),this.#r(e,"",0),""}#r(e,t,a){const s=new Uint8Array(516);if((new TextEncoder).encodeInto(t,s).written>=512)throw new Error("path too long");new DataView(s.buffer,s.byteOffset).setUint32(512,a);const i=this.#m(s);e.write(s,{at:0}),e.write(i,{at:516}),e.flush(),t?(this.#s.set(t,e),this.#i.delete(e)):(e.truncate(m),this.#i.add(e))}#m(e){if(!e[0])return new Uint32Array([4274806656,2899230775]);let t=3735928559,a=1103547991;for(const s of e)t=Math.imul(t^s,2654435761),a=Math.imul(a^s,1597334677);return t=Math.imul(t^t>>>16,2246822507)^Math.imul(a^a>>>13,3266489909),a=Math.imul(a^a>>>16,2246822507)^Math.imul(t^t>>>13,3266489909),new Uint32Array([t>>>0,a>>>0])}#n(e){return("string"==typeof e?new URL(e,"file://localhost/"):e).pathname}#o(e){const t=this.#s.get(e);t&&(this.#s.delete(e),this.#r(t,"",0))}}export{u as AccessHandlePoolVFS}; 2//# sourceMappingURL=AccessHandlePoolVFS-BPUHfZME.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.