TreasureTrails/node_modules/@electric-sql/pglite/dist/fs/opfs-ahp.cjs

4 lines
24 KiB
JavaScript
Raw Permalink Normal View History

2026-03-18 09:02:21 -05:00
"use strict";var Ge=Object.create;var $=Object.defineProperty;var Be=Object.getOwnPropertyDescriptor;var We=Object.getOwnPropertyNames;var qe=Object.getPrototypeOf,Ye=Object.prototype.hasOwnProperty;var Se=e=>{throw TypeError(e)};var Xe=(e,t)=>()=>(e&&(t=e(e=0)),t);var H=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Je=(e,t)=>{for(var r in t)$(e,r,{get:t[r],enumerable:!0})},we=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of We(t))!Ye.call(e,o)&&o!==r&&$(e,o,{get:()=>t[o],enumerable:!(n=Be(t,o))||n.enumerable});return e};var ie=(e,t,r)=>(r=e!=null?Ge(qe(e)):{},we(t||!e||!e.__esModule?$(r,"default",{value:e,enumerable:!0}):r,e)),Ke=e=>we($({},"__esModule",{value:!0}),e);var oe=(e,t,r)=>t.has(e)||Se("Cannot "+r);var d=(e,t,r)=>(oe(e,t,"read from private field"),r?r.call(e):t.get(e)),N=(e,t,r)=>t.has(e)?Se("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),z=(e,t,r,n)=>(oe(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r),p=(e,t,r)=>(oe(e,t,"access private method"),r);var se=(e,t,r,n)=>({set _(o){z(e,t,o,r)},get _(){return d(e,t,n)}});var y=Xe(()=>{"use strict"});var B=H((Ct,F)=>{"use strict";y();var be=9007199254740991,Fe=function(e){return e}();function $e(e){return e===Fe}function Pe(e){return typeof e=="string"||Object.prototype.toString.call(e)=="[object String]"}function Ve(e){return Object.prototype.toString.call(e)=="[object Date]"}function V(e){return e!==null&&typeof e=="object"}function Z(e){return typeof e=="function"}function Ze(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=be}function Qe(e){return Object.prototype.toString.call(e)=="[object Array]"}function Ne(e){return V(e)&&!Z(e)&&Ze(e.length)}function ae(e){return Object.prototype.toString.call(e)=="[object ArrayBuffer]"}function et(e,t){return Array.prototype.map.call(e,t)}function tt(e,t){var r=Fe;return Z(t)&&Array.prototype.every.call(e,function(n,o,i){var s=t(n,o,i);return s&&(r=n),!s}),r}function rt(e){return Object.assign.apply(null,arguments)}function Ee(e){var t,r,n;if(Pe(e)){for(r=e.length,n=new Uint8Array(r),t=0;t<r;t++)n[t]=e.charCodeAt(t)&255;return n}return ae(e)?new Uint8Array(e):V(e)&&ae(e.buffer)?new Uint8Array(e.buffer):Ne(e)?new Uint8Array(e):V(e)&&Z(e.toString)?Ee(e.toString()):new Uint8Array}F.exports.MAX_SAFE_INTEGER=be;F.exports.isUndefined=$e;F.exports.isString=Pe;F.exports.isObject=V;F.exports.isDateTime=Ve;F.exports.isFunction=Z;F.exports.isArray=Qe;F.exports.isArrayLike=Ne;F.exports.isArrayBuffer=ae;F.exports.map=et;F.exports.find=tt;F.exports.extend=rt;F.exports.toUint8Array=Ee});var W=H((Ht,Ae)=>{"use strict";y();var ce="\0";Ae.exports={NULL_CHAR:ce,TMAGIC:"ustar"+ce+"00",OLDGNU_MAGIC:"ustar "+ce,REGTYPE:0,LNKTYPE:1,SYMTYPE:2,CHRTYPE:3,BLKTYPE:4,DIRTYPE:5,FIFOTYPE:6,CONTTYPE:7,TSUID:parseInt("4000",8),TSGID:parseInt("2000",8),TSVTX:parseInt("1000",8),TUREAD:parseInt("0400",8),TUWRITE:parseInt("0200",8),TUEXEC:parseInt("0100",8),TGREAD:parseInt("0040",8),TGWRITE:parseInt("0020",8),TGEXEC:parseInt("0010",8),TOREAD:parseInt("0004",8),TOWRITE:parseInt("0002",8),TOEXEC:parseInt("0001",8),TPERMALL:parseInt("0777",8),TPERMMASK:parseInt("0777",8)}});var le=H((jt,P)=>{"use strict";y();var Te=B(),g=W(),nt=512,de=g.TPERMALL,ve=0,xe=0,ue=[["name",100,0,function(e,t){return q(e[t[0]],t[1])},function(e,t,r){return _(e.slice(t,t+r[1]))}],["mode",8,100,function(e,t){var r=e[t[0]]||de;return r=r&g.TPERMMASK,L(r,t[1],de)},function(e,t,r){var n=v(e.slice(t,t+r[1]));return n&=g.TPERMMASK,n}],["uid",8,108,function(e,t){return L(e[t[0]],t[1],ve)},function(e,t,r){return v(e.slice(t,t+r[1]))}],["gid",8,116,function(e,t){return L(e[t[0]],t[1],xe)},function(e,t,r){return v(e.slice(t,t+r[1]))}],["size",12,124,function(e,t){return L(e.data.length,t[1])},function(e,t,r){return v(e.slice(t,t+r[1]))}],["modifyTime",12,136,function(e,t){return Q(e[t[0]],t[1])},function(e,t,r){return ee(e.slice(t,t+r[1]))}],["checksum",8,148,function(e,t){return" "},function(e,t,r){return v(e.slice(t,t+r[1]))}],["type",1,156,function(e,t){return""+(parseInt(e[t[0]],10)||0)%8},function(
`),i=!1;try{n=JSON.parse(o[0])}catch{n={root:{type:"directory",lastModified:Date.now(),mode:fe.DIR,children:{}},pool:[]},d(this,S).truncate(0),d(this,S).write(new TextEncoder().encode(JSON.stringify(n)),{at:0}),i=!0}this.state=n;let s=o.slice(1).filter(Boolean).map(m=>JSON.parse(m));for(let m of s){let h=`_${m.opp}State`;if(typeof this[h]=="function")try{this[h].bind(this)(...m.args)}catch(D){console.warn("Error applying OPFS AHP WAL entry",m,D)}}let a=[],c=async m=>{if(m.type==="file")try{let h=await d(this,I).getFileHandle(m.backingFilename),D=await h.createSyncAccessHandle();d(this,x).set(m.backingFilename,h),d(this,b).set(m.backingFilename,D)}catch(h){console.error("Error opening file handle for node",m,h)}else for(let h of Object.values(m.children))a.push(c(h))};await c(this.state.root);let u=[];for(let m of this.state.pool)u.push(new Promise(async h=>{d(this,x).has(m)&&console.warn("File handle already exists for pool file",m);let D=await d(this,I).getFileHandle(m),je=await D.createSyncAccessHandle();d(this,x).set(m,D),d(this,b).set(m,je),h()}));await Promise.all([...a,...u]),await this.maintainPool(i?this.initialPoolSize:this.maintainedPoolSize)},R=function(r,n){let o=p(this,l,j).call(this,r);try{n()}catch(i){throw d(this,S).truncate(o),i}},j=function(r){let n=JSON.stringify(r),o=new TextEncoder().encode(`
${n}`),i=d(this,S).getSize();return d(this,S).write(o,{at:i}),d(this,T).add(d(this,S)),i},A=function(r){return r.split("/").filter(Boolean)},w=function(r,n){let o=p(this,l,A).call(this,r),i=n||this.state.root;for(let s of o){if(i.type!=="directory")throw new f("ENOTDIR","Not a directory");if(!Object.prototype.hasOwnProperty.call(i.children,s))throw new f("ENOENT","No such file or directory");i=i.children[s]}return i},Y=function(r){let n=d(this,M).get(r);if(!n)throw new f("EBADF","Bad file descriptor");return n},Le=function(){let r=++se(this,K)._;for(;d(this,M).has(r);)se(this,K)._++;return r},ge=async function(r,n){let o=p(this,l,A).call(this,r),i=n?.from||d(this,X);for(let s of o)i=await i.getDirectoryHandle(s,{create:n?.create});return i};var f=class extends Error{constructor(t,r){super(r),typeof t=="number"?this.code=t:typeof t=="string"&&(this.code=ne[t])}};0&&(module.exports={OpfsAhpFS});
//# sourceMappingURL=opfs-ahp.cjs.map