PageSourceSearch

https://app.usemotion.com/chunks/worker_chunk_IDBBatchAtomicVFS_4fa574d2.js

js usemotion.com collected 2026-09-24 08:32:53 UTC 13,545 bytes, 1 lines download raw bytes

1import{F}from"./worker_chunk_FacadeVFS_f2ad7999.js";import{S as I,a as c,b as j,c as A,d as S,e as M,f as y,g as L,h as T,i as O,j as N,k as Q,l as D,m as B,n as q,o as W,p as K,q as U,r as p,s as H,t as z,u as k,v as V,w as $,x as G,y as Y,z as X,A as J,B as Z,C,D as ee,E as te,F as se}from"../entry/worker_WASQLiteDB.worker_fa9597bd.js";const m={mode:"shared"},re={ifAvailable:!0,mode:"shared"},v={ifAvailable:!0,mode:"exclusive"},ae=["exclusive","shared","shared+hint"],_=f=>class extends f{#t={lockPolicy:"exclusive",lockTimeout:1/0};#e=new Map;constructor(e,r,s){if(super(e,r,s),Object.assign(this.#t,s),ae.indexOf(this.#t.lockPolicy)===-1)throw new Error(`WebLocksMixin: invalid lock mode: ${s.lockPolicy}`)}async jLock(e,r){try{if(!this.#e.has(e)){const a={baseName:this.getFilename(e),type:I,writeHint:!1};this.#e.set(e,a)}const s=this.#e.get(e);if(r<=s.type)return c;switch(this.#t.lockPolicy){case"exclusive":return await this.#a(s,r);case"shared":case"shared+hint":return await this.#i(s,r)}}catch(s){return console.error("WebLocksMixin: lock error",s),j}}async jUnlock(e,r){try{const s=this.#e.get(e);if(!(r<s?.type))return c;switch(this.#t.lockPolicy){case"exclusive":return await this.#r(s,r);case"shared":case"shared+hint":return await this.#o(s,r)}}catch(s){return console.error("WebLocksMixin: unlock error",s),A}}async jCheckReservedLock(e,r){try{const s=this.#e.get(e);switch(this.#t.lockPolicy){case"exclusive":return this.#n(s,r);case"shared":case"shared+hint":return await this.#c(s,r)}}catch(s){return console.error("WebLocksMixin: check reserved lock error",s),S}return r.setInt32(0,0,!0),c}jFileControl(e,r,s){const t=this.#e.get(e)??(this.jLock(e,I),this.#e.get(e));return r===_.WRITE_HINT_OP_CODE&&this.#t.lockPolicy==="shared+hint"&&(t.writeHint=!0),M}async#a(e,r){if(!e.access){if(!await this.#s(e,"access"))return y;console.assert(!!e.access)}return e.type=r,c}#r(e,r){return r===I&&(e.access?.(),console.assert(!e.access)),e.type=r,c}#n(e,r){return r.setInt32(0,0,!0),c}async#i(e,r){switch(e.type){case I:switch(r){case O:if(e.writeHint&&!await this.#s(e,"hint"))return y;if(!await this.#s(e,"gate",m))return e.hint?.(),y;await this.#s(e,"access",m),e.gate(),console.assert(!e.gate),console.assert(!!e.access),console.assert(!e.reserved);break;default:throw new Error("unsupported lock transition")}break;case O:switch(r){case L:if(this.#t.lockPolicy==="shared+hint"&&!e.hint&&!await this.#s(e,"hint",v))return y;if(!await this.#s(e,"reserved",v))return e.hint?.(),y;e.access(),console.assert(!e.gate),console.assert(!e.access),console.assert(!!e.reserved);break;case T:if(!await this.#s(e,"gate"))return y;if(e.access(),!await this.#s(e,"access"))return e.gate(),y;console.assert(!!e.gate),console.assert(!!e.access),console.assert(!e.reserved);break;default:throw new Error("unsupported lock transition")}break;case L:switch(r){case T:if(!await this.#s(e,"gate"))return y;if(!await this.#s(e,"access"))return e.gate(),y;console.assert(!!e.gate),console.assert(!!e.access),console.assert(!!e.reserved);break;default:throw new Error("unsupported lock transition")}break}return e.type=r,c}async#o(e,r){if(r===I)e.access?.(),e.gate?.(),e.reserved?.(),e.hint?.(),e.writeHint=!1,console.assert(!e.access),console.assert(!e.gate),console.assert(!e.reserved),console.assert(!e.hint);else switch(e.type){case T:e.access(),await this.#s(e,"access",m),e.gate(),e.reserved?.(),e.hint?.(),console.assert(!!e.access),console.assert(!e.gate),console.assert(!e.reserved);break;case L:await this.#s(e,"access",m),e.reserved(),e.hint?.(),console.assert(!!e.access),console.assert(!e.gate),console.assert(!e.reserved);break}return e.type=r,c}async#c(e,r){return await this.#s(e,"reserved",re)?(e.reserved(),r.setInt32(0,0,!0)):r.setInt32(0,1,!0),c}#s(e,r,s={}){return console.assert(!e[r]),new Promise(t=>{if(!s.ifAvailable&&this.#t.lockTimeout<1/0){const i=new AbortController;s=Object.assign({},s,{signal:i.signal}),setTimeout(()=>{i.abort(),t?.(!1)},this.#t.lockTimeout)}const a=`lock##${e.baseName}##${r}`;navigator.locks.request(a,s,i=>{if(i)return new Promise(n=>{e[r]=()=>{n(),e[r]=null},t(!0),t=null});e[r]=null,t(!1),t=null}).catch(i=>{if(i.name!=="AbortError")throw i})})}};_.WRITE_HINT_OP_CODE=-9999;const ne=new Set(["TransactionInactiveError","InvalidStateError"]);class ie{path;flags;metadata;fileSize=0;needsMetadataSync=!1;rollback=null;changedPages=new Set;synchronous="full";txOptions={durability:"strict"};constructor(e,r,s){this.path=e,this.flags=r,this.metadata=s}}class P extends _(F){mapIdToFile=new Map;lastError=null;log=null;#t;#e;static async create(e,r,s){const t=new P(e,r,s);return await t.isReady(),t}constructor(e,r,s={}){super(e,r,s),this.#t=this.#a(s.idbName??e)}async#a(e){this.#e=await R.create(e)}close(){this.#e.close()}async isReady(){await super.isReady(),await this.#t}getFilename(e){const r=this.mapIdToFile.get(e).path;return`IDB(${this.name}):${r}`}async jOpen(e,r,s,t){try{const i=new URL(e||Math.random().toString(36).slice(2),"file://").pathname;let n=await this.#e.q(({metadata:o})=>o.get(i));
1if(!n&&s&N&&(n={name:i,fileSize:0,version:0},await this.#e.q(({metadata:o})=>o.put(n),"rw")),!n)throw new Error(`File ${i} not found`);const l=new ie(i,s,n);return this.mapIdToFile.set(r,l),t.setInt32(0,s,!0),c}catch(a){return this.lastError=a,Q}}async jDelete(e,r){try{const t=new URL(e,"file://").pathname;return this.#e.q(({metadata:a,blocks:i})=>{const n=IDBKeyRange.bound([t,-1/0],[t,1/0]);i.delete(n),a.delete(t)},"rw"),r&&await this.#e.sync(!1),c}catch(s){return this.lastError=s,D}}async jAccess(e,r,s){try{const a=new URL(e,"file://").pathname,i=await this.#e.q(({metadata:n})=>n.get(a));return s.setInt32(0,i?1:0,!0),c}catch(t){return this.lastError=t,B}}async jClose(e){try{const r=this.mapIdToFile.get(e);return this.mapIdToFile.delete(e),r.flags&q&&await this.#e.q(({metadata:s,blocks:t})=>{s.delete(r.path),t.delete(IDBKeyRange.bound([r.path,0],[r.path,1/0]))},"rw"),r.needsMetadataSync&&this.#e.q(({metadata:s})=>s.put(r.metadata),"rw"),await this.#e.sync(r.synchronous==="full"),c}catch(r){return this.lastError=r,W}}async jRead(e,r,s){try{const t=this.mapIdToFile.get(e);let a=0;for(;a<r.byteLength;){const i=s+a,n=await this.#e.q(({blocks:u})=>{const d=IDBKeyRange.bound([t.path,-i],[t.path,1/0]);return u.get(d)});if(!n||n.data.byteLength-n.offset<=i)return r.fill(0,a),K;const l=r.subarray(a),o=i+n.offset,h=Math.min(Math.max(n.data.byteLength-o,0),l.byteLength);l.set(n.data.subarray(o,o+h)),a+=h}return c}catch(t){return this.lastError=t,U}}jWrite(e,r,s){try{const t=this.mapIdToFile.get(e);if(t.flags&p&&!t.rollback){const l=Object.assign({pendingVersion:t.metadata.version-1},t.metadata);this.#e.q(({metadata:o})=>o.put(l),"rw",t.txOptions),t.rollback=Object.assign({},t.metadata),t.metadata.version--}t.flags&p&&t.changedPages.add(s);const a=r.slice(),i=t.metadata.version;if(!(s<t.metadata.fileSize)||t.flags&p||t.flags&H){const l={path:t.path,offset:-s,version:i,data:r.slice()};this.#e.q(({blocks:o})=>{o.put(l),t.changedPages.add(s)},"rw",t.txOptions)}else this.#e.q(async({blocks:l})=>{const o=IDBKeyRange.bound([t.path,-s],[t.path,1/0]),h=await l.get(o);h.data.subarray(s+h.offset).set(a),l.put(h)},"rw",t.txOptions);return t.metadata.fileSize<s+r.length&&(t.metadata.fileSize=s+r.length,t.needsMetadataSync=!0),c}catch(t){return this.lastError=t,z}}jTruncate(e,r){try{const s=this.mapIdToFile.get(e);return r<s.metadata.fileSize&&(this.#e.q(({blocks:t})=>{const a=IDBKeyRange.bound([s.path,-1/0],[s.path,-r,1/0]);t.delete(a)},"rw",s.txOptions),s.metadata.fileSize=r,s.needsMetadataSync=!0),c}catch(s){return this.lastError=s,k}}async jSync(e,r){try{const s=this.mapIdToFile.get(e);return s.needsMetadataSync&&(this.#e.q(({metadata:t})=>t.put(s.metadata),"rw",s.txOptions),s.needsMetadataSync=!1),s.flags&p?s.synchronous==="full"&&await this.#e.sync(!0):await this.#e.sync(s.synchronous==="full"),c}catch(s){return this.lastError=s,V}}jFileSize(e,r){try{const s=this.mapIdToFile.get(e);return r.setBigInt64(0,BigInt(s.metadata.fileSize),!0),c}catch(s){return this.lastError=s,$}}async jLock(e,r){const s=this.mapIdToFile.get(e),t=await super.jLock(e,r);return r===O&&(s.metadata=await this.#e.q(async({metadata:a,blocks:i})=>{const n=await a.get(s.path);return n.pendingVersion&&(console.warn(`removing failed transaction ${n.pendingVersion}`),await new Promise((l,o)=>{const h=IDBKeyRange.bound([n.name,-1/0],[n.name,1/0]),u=i.openCursor(h);u.onsuccess=()=>{const d=u.result;d?(d.value.version<n.version&&d.delete(),d.continue()):l()},u.onerror=()=>o(u.error)}),delete n.pendingVersion,a.put(n)),n},"rw",s.txOptions)),t}async jUnlock(e,r){if(r===I){const s=this.mapIdToFile.get(e);await this.#e.sync(s.synchronous==="full")}return super.jUnlock(e,r)}jFileControl(e,r,s){try{const t=this.mapIdToFile.get(e);switch(r){case Z:const a=x(s,4),i=x(s,8);this.log?.("xFileControl",t.path,"PRAGMA",a,i);const n=o=>{const h=new TextEncoder().encode(o),u=this._module._sqlite3_malloc(h.byteLength);return this._module.HEAPU8.subarray(u,u+h.byteLength).set(h),s.setUint32(0,u,!0),C};switch(a.toLowerCase()){case"page_size":if(t.flags&p&&i&&t.metadata.fileSize)return C;break;case"synchronous":if(i)switch(i.toLowerCase()){case"0":case"off":t.synchronous="off",t.txOptions={durability:"relaxed"};break;case"1":case"normal":t.synchronous="normal",t.txOptions={durability:"relaxed"};break;case"2":case"3":case"full":case"extra":t.synchronous="full",t.txOptions={durability:"strict"};break}break;case"write_hint":return super.jFileControl(e,_.WRITE_HINT_OP_CODE,null)}break;case J:if(this.log?.("xFileControl",t.path,"SYNC"),t.rollback){const o=Object.assign({},t.metadata),h=t.rollback.fileSize;this.#e.q(({metadata:u,blocks:d})=>{u.put(o);for(const g of t.changedPages)if(g<h){const w=IDBKeyRange.bound([t.path,-g,o.version],[t.path,-g,1/0],!0);d.delete(w)}t.changedPages.clear()},"rw",t.txOptions),t.needsMetadataSync=!1,t.rollback=null}break;case X:return this.log?.("xFileControl",t.path,"BEGIN_ATOMIC_WRITE"),c;case Y:return this.log?.("xFileControl",t.path,"COMMIT_ATOMIC_WRITE"),c;case G:this.log?.("xFileControl",t.path,"ROLLBACK_ATOMIC_WRITE"),t.metadata=t.rollback;const l=Object.assign({},t.metadata);return this.#e.q(({metadata:o,blocks:h})=>{o.put(l);for(const u of t.changedPages)h.delete([t.path,-u,l.version-1]);t.changedPages.clear()},"rw",t.txOptions),t.needsMetadataSync=!1,t.rollback=null,c}}catch(t){return this.lastError=t,ee}return super.jFileControl(e,r,s)}jDeviceCharacteristics(e){return 0|te|se}jGetLastError(e){if(this.lastError){console.error(this.lastError);const r=e.subarray(0,e.byteLength-1),{written:s}=new TextEncoder().encodeInto(this.lastError.message,r);e[s]=0}return c}}function x(f,e){const r=f.getUint32(e,!0);if(r){const s=new Uint8Array(f.buffer,r);
1return new TextDecoder().decode(s.subarray(0,s.indexOf(0)))}return null}class R{#t;#e=null;#a=Promise.resolve();#r=null;#n=new WeakSet;log=null;static async create(e){const r=await new Promise((s,t)=>{const a=indexedDB.open(e,6);a.onupgradeneeded=async i=>{const n=a.result;switch(i.oldVersion&&console.log(`Upgrading IndexedDB from version ${i.oldVersion}`),i.oldVersion){case 0:n.createObjectStore("blocks",{keyPath:["path","offset","version"]}).createIndex("version",["path","version"]);case 5:const l=a.transaction;l.objectStore("blocks").deleteIndex("version");const h=n.createObjectStore("metadata",{keyPath:"name"});await new Promise((u,d)=>{let g={};const w=l.objectStore("blocks").openCursor();w.onsuccess=()=>{const b=w.result;if(b){const E=b.value;typeof E.offset!="number"||E.path===g.path&&E.offset===g.offset?b.delete():E.offset===0&&(h.put({name:E.path,fileSize:E.fileSize,version:E.version}),delete E.fileSize,b.update(E)),g=E,b.continue()}else u()},w.onerror=()=>d(w.error)});break}},a.onsuccess=()=>s(a.result),a.onerror=()=>t(a.error)});return new R(r)}constructor(e){this.#t=e}close(){this.#t.close()}q(e,r="ro",s={}){const t=r==="ro"?"readonly":"readwrite",a=Object.assign({durability:"default"},s);return this.#e=(this.#e||Promise.resolve()).then(()=>this.#i(e,t,a)),this.#e}async#i(e,r,s){let t;this.#r&&this.#n.has(this.#r.transaction)&&this.#r.transaction.mode>=r&&this.#r.transaction.durability===s.durability&&(t=this.#r.transaction,this.#r.readyState==="pending"&&await new Promise(a=>{this.#r.addEventListener("success",a,{once:!0}),this.#r.addEventListener("error",a,{once:!0})}));for(let a=0;a<2;++a){t||(await this.#a,t=this.#t.transaction(this.#t.objectStoreNames,r,s),this.log?.("IDBTransaction open",r),this.#n.add(t),this.#a=new Promise((i,n)=>{t.addEventListener("complete",()=>{this.log?.("IDBTransaction complete"),this.#n.delete(t),i()}),t.addEventListener("abort",()=>{this.#n.delete(t),n(new Error("transaction aborted"))})}));try{const i=[...t.objectStoreNames].map(n=>[n,this.proxyStoreOrIndex(t.objectStore(n))]);return await e(Object.fromEntries(i))}catch(i){if(!a&&ne.has(i.name)){this.log?.(`${i.name}, retrying`),t=null;continue}throw i}}}proxyStoreOrIndex(e){return new Proxy(e,{get:(r,s,t)=>{const a=Reflect.get(r,s,t);return typeof a=="function"?(...i)=>{const n=Reflect.apply(a,r,i);return n instanceof IDBRequest&&!s.endsWith("Cursor")?(this.#r=n,n.addEventListener("error",()=>{console.error(n.error),n.transaction.abort()},{once:!0}),oe(n)):n}:a}})}async sync(e){this.#e&&(await this.#e,e&&await this.#a,this.reset())}reset(){this.#e=null,this.#a=Promise.resolve(),this.#r=null}}function oe(f){return new Promise((e,r)=>{f.onsuccess=()=>e(f.result),f.onerror=()=>r(f.error)})}export{P as IDBBatchAtomicVFS,R as IDBContext};

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.