font update
This commit is contained in:
1 parent
f754cafbe4
commit
17731364bd
66 files changed
+10342
-76
No files matched your search
@@ -0,0 +1 @@
|
||||
const m=(w,...t)=>postMessage({type:w,payload:t}),Q=function(){const w=function(...e){throw new Error(e.join(" "))};globalThis.window===globalThis?w("This code cannot run from the main thread.","Load it as a Worker from a separate Worker."):navigator?.storage?.getDirectory||w("This API requires navigator.storage.getDirectory.");const t=Object.create(null);t.verbose=1;const v={0:console.error.bind(console),1:console.warn.bind(console),2:console.log.bind(console)},A=(e,...s)=>{t.verbose>e&&v[e]("OPFS asyncer:",...s)},g=(...e)=>A(2,...e),S=(...e)=>A(1,...e),h=(...e)=>A(0,...e),E=Object.create(null),I=new Set,k=function(e,s){const n=new URL(e,"file://irrelevant").pathname;return s?n.split("/").filter(o=>!!o):n},x=async function(s,n=!1){const o=k(s,!0),a=o.pop();let i=t.rootDir;for(const r of o)r&&(i=await i.getDirectoryHandle(r,{create:!!n}));return[i,a]},R=async e=>{if(e.syncHandle){g("Closing sync handle for",e.filenameAbs);const s=e.syncHandle;return delete e.syncHandle,delete e.xLock,I.delete(e.fid),s.close()}},F=async e=>{try{await R(e)}catch(s){S("closeSyncHandleNoThrow() ignoring:",s,e)}},D=async()=>{if(I.size)for(const e of I){const s=E[e];await F(s),g("Auto-unlocked",e,s.filenameAbs)}},T=async e=>{if(e.releaseImplicitLocks&&I.has(e.fid))return F(e)};class b extends Error{constructor(s,...n){super([...n,": "+s.name+":",s.message].join(" "),{cause:s}),this.name="GetSyncHandleError"}}b.convertRc=(e,s)=>{if(e instanceof b){if(e.cause.name==="NoModificationAllowedError"||e.cause.name==="DOMException"&&e.cause.message.indexOf("Access Handles cannot")===0)return t.sq3Codes.SQLITE_BUSY;if(e.cause.name==="NotFoundError")return t.sq3Codes.SQLITE_CANTOPEN}else if(e?.name==="NotFoundError")return t.sq3Codes.SQLITE_CANTOPEN;return s};const O=async(e,s)=>{if(!e.syncHandle){const n=performance.now();g("Acquiring sync handle for",e.filenameAbs);const o=6,a=t.asyncIdleWaitTime*2;let i=1,r=a;for(;;r=a*++i)try{e.syncHandle=await e.fileHandle.createSyncAccessHandle();break}catch(c){if(i===o)throw new b(c,"Error getting sync handle for",s+"().",o,"attempts failed.",e.filenameAbs);S("Error getting sync handle for",s+"(). Waiting",r,"ms and trying again.",e.filenameAbs,c),Atomics.wait(t.sabOPView,t.opIds.retry,0,r)}g("Got",s+"() sync handle for",e.filenameAbs,"in",performance.now()-n,"ms"),e.xLock||(I.add(e.fid),g("Acquired implicit lock for",s+"()",e.fid,e.filenameAbs))}return e.syncHandle},d=(e,s)=>{g(e+"() => notify(",s,")"),Atomics.store(t.sabOPView,t.opIds.rc,s),Atomics.notify(t.sabOPView,t.opIds.rc)},H=function(e,s){s.readOnly&&w(e+"(): File is read-only: "+s.filenameAbs)};let L=!1;const _={"opfs-async-shutdown":async()=>{L=!0,d("opfs-async-shutdown",0)},mkdir:async e=>{let s=0;try{await x(e+"/filepart",!0)}catch(n){t.s11n.storeException(2,n),s=t.sq3Codes.SQLITE_IOERR}d("mkdir",s)},xAccess:async e=>{let s=0;try{const[n,o]=await x(e);await n.getFileHandle(o)}catch(n){t.s11n.storeException(2,n),s=t.sq3Codes.SQLITE_IOERR}d("xAccess",s)},xClose:async function(e){const s="xClose";I.delete(e);const n=E[e];let o=0;if(n){if(delete E[e],await R(n),n.deleteOnClose)try{await n.dirHandle.removeEntry(n.filenamePart)}catch(a){S("Ignoring dirHandle.removeEntry() failure of",n,a)}}else t.s11n.serialize(),o=t.sq3Codes.SQLITE_NOTFOUND;d(s,o)},xDelete:async function(...e){const s=await _.xDeleteNoWait(...e);d("xDelete",s)},xDeleteNoWait:async function(e,s=0,n=!1){let o=0;try{for(;e;){const[a,i]=await x(e,!1);if(!i||(await a.removeEntry(i,{recursive:n}),s!==4660))break;n=!1,e=k(e,!0),e.pop(),e=e.join("/")}}catch(a){t.s11n.storeException(2,a),o=t.sq3Codes.SQLITE_IOERR_DELETE}return o},xFileSize:async function(e){const s=E[e];let n=0;try{const o=await(await O(s,"xFileSize")).getSize();t.s11n.serialize(Number(o))}catch(o){t.s11n.storeException(1,o),n=b.convertRc(o,t.sq3Codes.SQLITE_IOERR)}await T(s),d("xFileSize",n)},xLock:async function(e,s){const n=E[e];let o=0;const a=n.xLock;if(n.xLock=s,!n.syncHandle)try{await O(n,"xLock"),I.delete(e)}catch(i){t.s11n.storeException(1,i),o=b.convertRc(i,t.sq3Codes.SQLITE_IOERR_LOCK),n.xLock=a}d("xLock",o)},xOpen:async function(e,s,n,o){const a="xOpen",i=t.sq3Codes.SQLITE_OPEN_CREATE&n;try{let r,c;try{[r,c]=await x(s,!!i)}catch(f){t.s11n.storeException(1,f),d(a,t.sq3Codes.SQLITE_NOTFOUND);return}if(t.opfsFlags.OPFS_UNLINK_BEFORE_OPEN&o)try{await r.removeEntry(c)}catch{}const y=await r.getFileHandle(c,{create:i}),l=Object.assign(Object.create(null),{fid:e,filenameAbs:s,filenamePart:c,dirHandle:r,fileHandle:y,sabView:t.sabFileBufView,readOnly:!i&&!!(t.sq3Codes.SQLITE_OPEN_READONLY&n),deleteOnClose:!!(t.sq3Codes.SQLITE_OPEN_DELETEONCLOSE&n)});l.releaseImplicitLocks=o&t.opfsFlags.OPFS_UNLOCK_ASAP||t.opfsFlags.defaultUnlockAsap,E[e]=l,d(a,0)}catch(r){h(a,r),t.s11n.storeException(1,r),d(a,t.sq3Codes.SQLITE_IOERR)}},xRead:async function(e,s,n){let o=0,a;const i=E[e];try{a=(await O(i,"xRead")).read(i.sabView.subarray(0,s),{at:Number(n)}),a<s&&(i.sabView.fill(0,a,s),o=t.sq3Codes.SQLITE_IOERR_SHORT_READ)}catch(r){Line truncated
|
||||
Reference in new issue
Block a user