@zenfs/dom 0.2.14 → 0.2.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -59,7 +59,6 @@ export declare const IndexedDB: {
59
59
  readonly create: (options: IndexedDBOptions & Partial<SharedConfig>) => Promise<{
60
60
  _sync?: import("@zenfs/core").FileSystem | undefined;
61
61
  queueDone(): Promise<void>;
62
- metadata(): import("@zenfs/core").FileSystemMetadata;
63
62
  ready(): Promise<void>;
64
63
  renameSync(oldPath: string, newPath: string, cred: import("@zenfs/core").Cred): void;
65
64
  statSync(path: string, cred: import("@zenfs/core").Cred): import("@zenfs/core").Stats;
@@ -71,18 +70,5 @@ export declare const IndexedDB: {
71
70
  readdirSync(path: string, cred: import("@zenfs/core").Cred): string[];
72
71
  linkSync(srcpath: string, dstpath: string, cred: import("@zenfs/core").Cred): void;
73
72
  syncSync(path: string, data: Uint8Array, stats: Readonly<import("@zenfs/core").Stats>): void;
74
- _disableSync?: boolean | undefined;
75
- rename(oldPath: string, newPath: string, cred: import("@zenfs/core").Cred): Promise<void>;
76
- stat(path: string, cred: import("@zenfs/core").Cred): Promise<import("@zenfs/core").Stats>;
77
- openFile(path: string, flag: string, cred: import("@zenfs/core").Cred): Promise<import("@zenfs/core").File>;
78
- createFile(path: string, flag: string, mode: number, cred: import("@zenfs/core").Cred): Promise<import("@zenfs/core").File>;
79
- unlink(path: string, cred: import("@zenfs/core").Cred): Promise<void>;
80
- rmdir(path: string, cred: import("@zenfs/core").Cred): Promise<void>;
81
- mkdir(path: string, mode: number, cred: import("@zenfs/core").Cred): Promise<void>;
82
- readdir(path: string, cred: import("@zenfs/core").Cred): Promise<string[]>;
83
- exists(path: string, cred: import("@zenfs/core").Cred): Promise<boolean>;
84
- existsSync(path: string, cred: import("@zenfs/core").Cred): boolean;
85
- link(srcpath: string, dstpath: string, cred: import("@zenfs/core").Cred): Promise<void>;
86
- sync(path: string, data: Uint8Array, stats: Readonly<import("@zenfs/core").Stats>): Promise<void>;
87
73
  } & StoreFS<IndexedDBStore>>;
88
74
  };
package/dist/IndexedDB.js CHANGED
@@ -30,9 +30,17 @@ export class IndexedDBTransaction extends AsyncTransaction {
30
30
  return wrap(this._idb.delete(key.toString()));
31
31
  }
32
32
  async commit() {
33
+ if (this.done) {
34
+ return;
35
+ }
36
+ this.done = true;
33
37
  this.tx.commit();
34
38
  }
35
39
  async abort() {
40
+ if (this.done) {
41
+ return;
42
+ }
43
+ this.done = true;
36
44
  try {
37
45
  this.tx.abort();
38
46
  }
package/dist/access.d.ts CHANGED
@@ -11,10 +11,9 @@ declare global {
11
11
  export interface WebAccessOptions {
12
12
  handle: FileSystemDirectoryHandle;
13
13
  }
14
- declare const WebAccessFS_base: (abstract new (...args: any[]) => {
14
+ declare const WebAccessFS_base: import("@zenfs/core/mixins/shared.js").Mixin<typeof FileSystem, {
15
15
  _sync?: FileSystem | undefined;
16
16
  queueDone(): Promise<void>;
17
- metadata(): FileSystemMetadata;
18
17
  ready(): Promise<void>;
19
18
  renameSync(oldPath: string, newPath: string, cred: import("@zenfs/core").Cred): void;
20
19
  statSync(path: string, cred: import("@zenfs/core").Cred): Stats;
@@ -26,20 +25,7 @@ declare const WebAccessFS_base: (abstract new (...args: any[]) => {
26
25
  readdirSync(path: string, cred: import("@zenfs/core").Cred): string[];
27
26
  linkSync(srcpath: string, dstpath: string, cred: import("@zenfs/core").Cred): void;
28
27
  syncSync(path: string, data: Uint8Array, stats: Readonly<Stats>): void;
29
- _disableSync?: boolean | undefined;
30
- rename(oldPath: string, newPath: string, cred: import("@zenfs/core").Cred): Promise<void>;
31
- stat(path: string, cred: import("@zenfs/core").Cred): Promise<Stats>;
32
- openFile(path: string, flag: string, cred: import("@zenfs/core").Cred): Promise<import("@zenfs/core").File>;
33
- createFile(path: string, flag: string, mode: number, cred: import("@zenfs/core").Cred): Promise<import("@zenfs/core").File>;
34
- unlink(path: string, cred: import("@zenfs/core").Cred): Promise<void>;
35
- rmdir(path: string, cred: import("@zenfs/core").Cred): Promise<void>;
36
- mkdir(path: string, mode: number, cred: import("@zenfs/core").Cred): Promise<void>;
37
- readdir(path: string, cred: import("@zenfs/core").Cred): Promise<string[]>;
38
- exists(path: string, cred: import("@zenfs/core").Cred): Promise<boolean>;
39
- existsSync(path: string, cred: import("@zenfs/core").Cred): boolean;
40
- link(srcpath: string, dstpath: string, cred: import("@zenfs/core").Cred): Promise<void>;
41
- sync(path: string, data: Uint8Array, stats: Readonly<Stats>): Promise<void>;
42
- }) & typeof FileSystem;
28
+ }>;
43
29
  export declare class WebAccessFS extends WebAccessFS_base {
44
30
  private _handles;
45
31
  /**
@@ -1,2 +1,2 @@
1
- "use strict";var ZenFS_DOM=(()=>{var g=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var W=Object.prototype.hasOwnProperty;var c=(e,t)=>g(e,"name",{value:t,configurable:!0});var Y=(e,t)=>{for(var i in t)g(e,i,{get:t[i],enumerable:!0})},G=(e,t,i,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of U(t))!W.call(e,o)&&o!==i&&g(e,o,{get:()=>t[o],enumerable:!(n=H(t,o))||n.enumerable});return e};var K=e=>G(g({},"__esModule",{value:!0}),e);var Z={};Y(Z,{IndexedDB:()=>j,IndexedDBStore:()=>I,IndexedDBTransaction:()=>h,WebAccess:()=>q,WebAccessFS:()=>p,WebStorage:()=>L,WebStorageStore:()=>T});var ee=ZenFS,{Async:x,AsyncTransaction:te,BigIntStats:ie,BigIntStatsFs:se,Dir:ne,Dirent:oe,Errno:E,ErrnoError:l,Fetch:re,FetchFS:ae,File:ce,FileSystem:P,FileType:le,InMemory:D,InMemoryStore:de,IndexFS:Se,Inode:Ee,LockedFS:ue,Mutex:me,NoSyncFile:fe,Overlay:Oe,OverlayFS:ye,Port:pe,PortFS:Ne,PortFile:he,PreloadFile:M,ReadStream:Ie,Readonly:Te,SimpleAsyncStore:ge,SimpleTransaction:v,Stats:b,StatsCommon:xe,StatsFs:De,StoreFS:F,Sync:be,SyncTransaction:Fe,Transaction:Re,UnlockedOverlayFS:we,WriteStream:Ae,ZenFsType:Pe,_toUnixTimestamp:Me,access:ve,accessSync:_e,appendFile:Ce,appendFileSync:ke,attachFS:Be,checkOptions:Le,chmod:He,chmodSync:Ue,chown:We,chownSync:Ye,close:Ge,closeSync:Ke,configure:Xe,constants:ze,copyFile:Ve,copyFileSync:$e,cp:qe,cpSync:Qe,createReadStream:je,createWriteStream:Ze,decode:_,decodeDirListing:Je,detachFS:et,encode:C,encodeDirListing:tt,errorMessages:it,exists:st,existsSync:nt,fchmod:ot,fchmodSync:rt,fchown:at,fchownSync:ct,fdatasync:lt,fdatasyncSync:dt,flagToMode:St,flagToNumber:Et,flagToString:ut,fs:mt,fstat:ft,fstatSync:Ot,fsync:yt,fsyncSync:pt,ftruncate:Nt,ftruncateSync:ht,futimes:It,futimesSync:Tt,isAppendable:gt,isBackend:xt,isBackendConfig:Dt,isExclusive:bt,isReadable:Ft,isSynchronous:Rt,isTruncating:wt,isWriteable:At,lchmod:Pt,lchmodSync:Mt,lchown:vt,lchownSync:_t,levenshtein:Ct,link:kt,linkSync:Bt,lopenSync:Lt,lstat:Ht,lstatSync:Ut,lutimes:Wt,lutimesSync:Yt,mkdir:Gt,mkdirSync:Kt,mkdirpSync:Xt,mkdtemp:zt,mkdtempSync:Vt,mount:$t,mountObject:qt,mounts:Qt,nop:jt,normalizeMode:Zt,normalizeOptions:Jt,normalizePath:ei,normalizeTime:ti,open:ii,openAsBlob:si,openSync:ni,opendir:oi,opendirSync:ri,parseFlag:ai,promises:ci,randomIno:li,read:di,readFile:Si,readFileSync:Ei,readSync:ui,readdir:mi,readdirSync:fi,readlink:Oi,readlinkSync:yi,readv:pi,readvSync:Ni,realpath:hi,realpathSync:Ii,rename:Ti,renameSync:gi,resolveMountConfig:xi,rm:Di,rmSync:bi,rmdir:Fi,rmdirSync:Ri,rootCred:wi,rootIno:Ai,setImmediate:Pi,size_max:Mi,stat:vi,statSync:_i,statfs:Ci,statfsSync:ki,symlink:Bi,symlinkSync:Li,truncate:Hi,truncateSync:Ui,umount:Wi,unlink:Yi,unlinkSync:Gi,unwatchFile:Ki,utimes:Xi,utimesSync:zi,watch:Vi,watchFile:$i,write:qi,writeFile:Qi,writeFileSync:ji,writeSync:Zi,writev:Ji,writevSync:es}=ZenFS;function X(e,t){let i="",n=0,o=-1,r=0,d="\0";for(let a=0;a<=e.length;++a){if(a<e.length)d=e[a];else{if(d=="/")break;d="/"}if(d=="/"){if(!(o===a-1||r===1))if(r===2){if(i.length<2||n!==2||i.at(-1)!=="."||i.at(-2)!=="."){if(i.length>2){let f=i.lastIndexOf("/");f===-1?(i="",n=0):(i=i.slice(0,f),n=i.length-1-i.lastIndexOf("/")),o=a,r=0;continue}else if(i.length!==0){i="",n=0,o=a,r=0;continue}}t&&(i+=i.length>0?"/..":"..",n=2)}else i.length>0?i+="/"+e.slice(o+1,a):i=e.slice(o+1,a),n=a-o-1;o=a,r=0}else d==="."&&r!==-1?++r:r=-1}return i}c(X,"normalizeString");function z(e){if(!e.length)return".";let t=e.startsWith("/"),i=e.endsWith("/");return e=X(e,!t),e.length?(i&&(e+="/"),t?`/${e}`:e):t?"/":i?"./":"."}c(z,"normalize");function R(...e){if(!e.length)return".";let t=e.join("/");return t?.length?z(t):"."}c(R,"join");function O(e){if(e.length===0)return".";let t=e[0]==="/",i=-1,n=!0;for(let o=e.length-1;o>=1;--o)if(e[o]==="/"){if(!n){i=o;break}}else n=!1;return i===-1?t?"/":".":t&&i===1?"//":e.slice(0,i)}c(O,"dirname");function y(e,t){let i=0,n=-1,o=!0;if(t!==void 0&&t.length>0&&t.length<=e.length){if(t===e)return"";let r=t.length-1,d=-1;for(let a=e.length-1;a>=0;--a)if(e[a]==="/"){if(!o){i=a+1;break}}else d===-1&&(o=!1,d=a+1),r>=0&&(e[a]===t[r]?--r===-1&&(n=a):(r=-1,n=d));return i===n?n=d:n===-1&&(n=e.length),e.slice(i,n)}for(let r=e.length-1;r>=0;--r)if(e[r]==="/"){if(!o){i=r+1;break}}else n===-1&&(o=!1,n=r+1);return n===-1?"":e.slice(i,n)}c(y,"basename");function V(e){switch(e.name){case"IndexSizeError":case"HierarchyRequestError":case"InvalidCharacterError":case"InvalidStateError":case"SyntaxError":case"NamespaceError":case"TypeMismatchError":case"ConstraintError":case"VersionError":case"URLMismatchError":case"InvalidNodeTypeError":return"EINVAL";case"WrongDocumentError":return"EXDEV";case"NoModificationAllowedError":case"InvalidModificationError":case"InvalidAccessError":case"SecurityError":case"NotAllowedError":return"EACCES";case"NotFoundError":return"ENOENT";case"NotSupportedError":return"ENOTSUP";case"InUseAttributeError":return"EBUSY";case"NetworkError":return"ENETDOWN";case"AbortError":return"EINTR";case"QuotaExceededError":return"ENOSPC";case"TimeoutError":return"ETIMEDOUT";case"ReadOnlyError":return"EROFS";case"DataCloneError":case"EncodingError":case"NotReadableError":case"DataError":case"TransactionInactiveError":case"OperationError":case"UnknownError":default:return"EIO"}}c(V,"errnoForDOMException");function u(e,t,i){if(e instanceof l)return e;let n=e instanceof DOMException?E[V(e)]:E.EIO,o=new l(n,e.message,t,i);return o.stack=e.stack,o.cause=e.cause,o}c(u,"convertException");var p=class extends x(P){_handles=new Map;_sync=D.create({name:"accessfs-cache"});constructor(t){super(),this._handles.set("/",t)}metadata(){return{...super.metadata(),name:"WebAccess",noResizableBuffers:!0}}async sync(t,i,n){let o=await this.stat(t);n.mtime!==o.mtime&&await this.writeFile(t,i)}async rename(t,i){try{let n=await this.getHandle(t);if(n instanceof FileSystemDirectoryHandle){let f=await this.readdir(t);if(await this.mkdir(i),f.length==0)await this.unlink(t);else for(let A of f)await this.rename(R(t,A),R(i,A)),await this.unlink(t)}if(!(n instanceof FileSystemFileHandle))return;let o=await n.getFile(),r=await this.getHandle(O(i));if(!(r instanceof FileSystemDirectoryHandle))return;let a=await(await r.getFileHandle(y(i),{create:!0})).createWritable();await a.write(await o.arrayBuffer()),a.close(),await this.unlink(t)}catch(n){throw u(n,t,"rename")}}async writeFile(t,i){if(i.buffer.resizable)throw new l(E.EINVAL,"Resizable buffers can not be written",t,"write");let n=await this.getHandle(O(t));if(!(n instanceof FileSystemDirectoryHandle))return;let r=await(await n.getFileHandle(y(t),{create:!0})).createWritable();await r.write(i),await r.close()}async createFile(t,i){return await this.writeFile(t,new Uint8Array),this.openFile(t,i)}async stat(t){let i=await this.getHandle(t);if(!i)throw l.With("ENOENT",t,"stat");if(i instanceof FileSystemDirectoryHandle)return new b({mode:16895,size:4096});if(i instanceof FileSystemFileHandle){let{lastModified:n,size:o}=await i.getFile();return new b({mode:33279,size:o,mtimeMs:n})}throw new l(E.EBADE,"Handle is not a directory or file",t,"stat")}async openFile(t,i){let n=await this.getHandle(t);if(!(n instanceof FileSystemFileHandle))throw l.With("EISDIR",t,"openFile");try{let o=await n.getFile(),r=new Uint8Array(await o.arrayBuffer()),d=new b({mode:33279,size:o.size,mtimeMs:o.lastModified});return new M(this,t,i,d,r)}catch(o){throw u(o,t,"openFile")}}async unlink(t){let i=await this.getHandle(O(t));if(i instanceof FileSystemDirectoryHandle)try{await i.removeEntry(y(t),{recursive:!0})}catch(n){throw u(n,t,"unlink")}}async link(t){throw l.With("ENOSYS",t,"WebAccessFS.link")}async rmdir(t){return this.unlink(t)}async mkdir(t){if(await this.getHandle(t))throw l.With("EEXIST",t,"mkdir");let n=await this.getHandle(O(t));if(!(n instanceof FileSystemDirectoryHandle))throw l.With("ENOTDIR",t,"mkdir");await n.getDirectoryHandle(y(t),{create:!0})}async readdir(t){let i=await this.getHandle(t);if(!(i instanceof FileSystemDirectoryHandle))throw l.With("ENOTDIR",t,"readdir");let n=[];for await(let o of i.keys())n.push(o);return n}async getHandle(t){if(this._handles.has(t))return this._handles.get(t);let i="/";for(let n of t.split("/").slice(1)){let o=this._handles.get(i);if(!(o instanceof FileSystemDirectoryHandle))throw l.With("ENOTDIR",i,"getHandle");i=R(i,n);try{let r=await o.getDirectoryHandle(n);this._handles.set(i,r)}catch(r){let d=r;if(d.name=="TypeMismatchError")try{let a=await o.getFileHandle(n);this._handles.set(i,a)}catch(a){u(a,i,"getHandle")}if(d.name==="TypeError")throw new l(E.ENOENT,d.message,i,"getHandle");u(d,i,"getHandle")}}return this._handles.get(t)}};c(p,"WebAccessFS");var q={name:"WebAccess",options:{handle:{type:"object",required:!0,description:"The directory handle to use for the root"}},isAvailable(){return typeof FileSystemHandle=="function"},create(e){return new p(e.handle)}};var s;(function(e){e[e.EPERM=1]="EPERM",e[e.ENOENT=2]="ENOENT",e[e.EINTR=4]="EINTR",e[e.EIO=5]="EIO",e[e.ENXIO=6]="ENXIO",e[e.EBADF=9]="EBADF",e[e.EAGAIN=11]="EAGAIN",e[e.ENOMEM=12]="ENOMEM",e[e.EACCES=13]="EACCES",e[e.EFAULT=14]="EFAULT",e[e.ENOTBLK=15]="ENOTBLK",e[e.EBUSY=16]="EBUSY",e[e.EEXIST=17]="EEXIST",e[e.EXDEV=18]="EXDEV",e[e.ENODEV=19]="ENODEV",e[e.ENOTDIR=20]="ENOTDIR",e[e.EISDIR=21]="EISDIR",e[e.EINVAL=22]="EINVAL",e[e.ENFILE=23]="ENFILE",e[e.EMFILE=24]="EMFILE",e[e.ETXTBSY=26]="ETXTBSY",e[e.EFBIG=27]="EFBIG",e[e.ENOSPC=28]="ENOSPC",e[e.ESPIPE=29]="ESPIPE",e[e.EROFS=30]="EROFS",e[e.EMLINK=31]="EMLINK",e[e.EPIPE=32]="EPIPE",e[e.EDOM=33]="EDOM",e[e.ERANGE=34]="ERANGE",e[e.EDEADLK=35]="EDEADLK",e[e.ENAMETOOLONG=36]="ENAMETOOLONG",e[e.ENOLCK=37]="ENOLCK",e[e.ENOSYS=38]="ENOSYS",e[e.ENOTEMPTY=39]="ENOTEMPTY",e[e.ELOOP=40]="ELOOP",e[e.ENOMSG=42]="ENOMSG",e[e.EBADE=52]="EBADE",e[e.EBADR=53]="EBADR",e[e.EXFULL=54]="EXFULL",e[e.ENOANO=55]="ENOANO",e[e.EBADRQC=56]="EBADRQC",e[e.ENOSTR=60]="ENOSTR",e[e.ENODATA=61]="ENODATA",e[e.ETIME=62]="ETIME",e[e.ENOSR=63]="ENOSR",e[e.ENONET=64]="ENONET",e[e.EREMOTE=66]="EREMOTE",e[e.ENOLINK=67]="ENOLINK",e[e.ECOMM=70]="ECOMM",e[e.EPROTO=71]="EPROTO",e[e.EBADMSG=74]="EBADMSG",e[e.EOVERFLOW=75]="EOVERFLOW",e[e.EBADFD=77]="EBADFD",e[e.ESTRPIPE=86]="ESTRPIPE",e[e.ENOTSOCK=88]="ENOTSOCK",e[e.EDESTADDRREQ=89]="EDESTADDRREQ",e[e.EMSGSIZE=90]="EMSGSIZE",e[e.EPROTOTYPE=91]="EPROTOTYPE",e[e.ENOPROTOOPT=92]="ENOPROTOOPT",e[e.EPROTONOSUPPORT=93]="EPROTONOSUPPORT",e[e.ESOCKTNOSUPPORT=94]="ESOCKTNOSUPPORT",e[e.ENOTSUP=95]="ENOTSUP",e[e.ENETDOWN=100]="ENETDOWN",e[e.ENETUNREACH=101]="ENETUNREACH",e[e.ENETRESET=102]="ENETRESET",e[e.ETIMEDOUT=110]="ETIMEDOUT",e[e.ECONNREFUSED=111]="ECONNREFUSED",e[e.EHOSTDOWN=112]="EHOSTDOWN",e[e.EHOSTUNREACH=113]="EHOSTUNREACH",e[e.EALREADY=114]="EALREADY",e[e.EINPROGRESS=115]="EINPROGRESS",e[e.ESTALE=116]="ESTALE",e[e.EREMOTEIO=121]="EREMOTEIO",e[e.EDQUOT=122]="EDQUOT"})(s||(s={}));var B={[s.EPERM]:"Operation not permitted",[s.ENOENT]:"No such file or directory",[s.EINTR]:"Interrupted system call",[s.EIO]:"Input/output error",[s.ENXIO]:"No such device or address",[s.EBADF]:"Bad file descriptor",[s.EAGAIN]:"Resource temporarily unavailable",[s.ENOMEM]:"Cannot allocate memory",[s.EACCES]:"Permission denied",[s.EFAULT]:"Bad address",[s.ENOTBLK]:"Block device required",[s.EBUSY]:"Resource busy or locked",[s.EEXIST]:"File exists",[s.EXDEV]:"Invalid cross-device link",[s.ENODEV]:"No such device",[s.ENOTDIR]:"File is not a directory",[s.EISDIR]:"File is a directory",[s.EINVAL]:"Invalid argument",[s.ENFILE]:"Too many open files in system",[s.EMFILE]:"Too many open files",[s.ETXTBSY]:"Text file busy",[s.EFBIG]:"File is too big",[s.ENOSPC]:"No space left on disk",[s.ESPIPE]:"Illegal seek",[s.EROFS]:"Cannot modify a read-only file system",[s.EMLINK]:"Too many links",[s.EPIPE]:"Broken pipe",[s.EDOM]:"Numerical argument out of domain",[s.ERANGE]:"Numerical result out of range",[s.EDEADLK]:"Resource deadlock would occur",[s.ENAMETOOLONG]:"File name too long",[s.ENOLCK]:"No locks available",[s.ENOSYS]:"Function not implemented",[s.ENOTEMPTY]:"Directory is not empty",[s.ELOOP]:"Too many levels of symbolic links",[s.ENOMSG]:"No message of desired type",[s.EBADE]:"Invalid exchange",[s.EBADR]:"Invalid request descriptor",[s.EXFULL]:"Exchange full",[s.ENOANO]:"No anode",[s.EBADRQC]:"Invalid request code",[s.ENOSTR]:"Device not a stream",[s.ENODATA]:"No data available",[s.ETIME]:"Timer expired",[s.ENOSR]:"Out of streams resources",[s.ENONET]:"Machine is not on the network",[s.EREMOTE]:"Object is remote",[s.ENOLINK]:"Link has been severed",[s.ECOMM]:"Communication error on send",[s.EPROTO]:"Protocol error",[s.EBADMSG]:"Bad message",[s.EOVERFLOW]:"Value too large for defined data type",[s.EBADFD]:"File descriptor in bad state",[s.ESTRPIPE]:"Streams pipe error",[s.ENOTSOCK]:"Socket operation on non-socket",[s.EDESTADDRREQ]:"Destination address required",[s.EMSGSIZE]:"Message too long",[s.EPROTOTYPE]:"Protocol wrong type for socket",[s.ENOPROTOOPT]:"Protocol not available",[s.EPROTONOSUPPORT]:"Protocol not supported",[s.ESOCKTNOSUPPORT]:"Socket type not supported",[s.ENOTSUP]:"Operation is not supported",[s.ENETDOWN]:"Network is down",[s.ENETUNREACH]:"Network is unreachable",[s.ENETRESET]:"Network dropped connection on reset",[s.ETIMEDOUT]:"Connection timed out",[s.ECONNREFUSED]:"Connection refused",[s.EHOSTDOWN]:"Host is down",[s.EHOSTUNREACH]:"No route to host",[s.EALREADY]:"Operation already in progress",[s.EINPROGRESS]:"Operation now in progress",[s.ESTALE]:"Stale file handle",[s.EREMOTEIO]:"Remote I/O error",[s.EDQUOT]:"Disk quota exceeded"},S=class extends Error{static fromJSON(t){let i=new S(t.errno,t.message,t.path,t.syscall);return i.code=t.code,i.stack=t.stack,i}static With(t,i,n){return new S(s[t],B[s[t]],i,n)}constructor(t,i=B[t],n,o=""){super(i),this.errno=t,this.path=n,this.syscall=o,this.code=s[t],this.message=`${this.code}: ${i}${this.path?`, '${this.path}'`:""}`}toString(){return this.message}toJSON(){return{errno:this.errno,code:this.code,path:this.path,stack:this.stack,message:this.message,syscall:this.syscall}}bufferSize(){return 4+JSON.stringify(this.toJSON()).length}};c(S,"ErrnoError");var w=class{constructor(t){this.store=t,this.aborted=!1}async[Symbol.asyncDispose](){this.aborted||await this.commit()}[Symbol.dispose](){this.aborted||this.commitSync()}};c(w,"Transaction");var N=class extends w{getSync(){throw S.With("ENOSYS",void 0,"AsyncTransaction.getSync")}setSync(){throw S.With("ENOSYS",void 0,"AsyncTransaction.setSync")}removeSync(){throw S.With("ENOSYS",void 0,"AsyncTransaction.removeSync")}commitSync(){throw S.With("ENOSYS",void 0,"AsyncTransaction.commitSync")}abortSync(){throw S.With("ENOSYS",void 0,"AsyncTransaction.abortSync")}};c(N,"AsyncTransaction");function m(e){return new Promise((t,i)=>{e.onsuccess=()=>t(e.result),e.onerror=n=>{n.preventDefault(),i(u(e.error))}})}c(m,"wrap");var h=class extends N{constructor(i,n){super(n);this.tx=i;this.store=n;this._idb=i.objectStore(n.name)}_idb;get(i){return m(this._idb.get(i.toString()))}async set(i,n){await m(this._idb.put(n,i.toString()))}remove(i){return m(this._idb.delete(i.toString()))}async commit(){this.tx.commit()}async abort(){try{this.tx.abort()}catch(i){throw u(i)}}};c(h,"IndexedDBTransaction");async function Q(e,t=globalThis.indexedDB){let i=t.open(e);return i.onupgradeneeded=()=>{let o=i.result;o.objectStoreNames.contains(e)&&o.deleteObjectStore(e),o.createObjectStore(e)},await m(i)}c(Q,"createDB");var I=class{constructor(t){this.db=t}sync(){throw new Error("Method not implemented.")}get name(){return this.db.name}clear(){return m(this.db.transaction(this.name,"readwrite").objectStore(this.name).clear())}clearSync(){throw l.With("ENOSYS",void 0,"IndexedDBStore.clearSync")}transaction(){let t=this.db.transaction(this.name,"readwrite");return new h(t,this)}};c(I,"IndexedDBStore");var j={name:"IndexedDB",options:{storeName:{type:"string",required:!1,description:"The name of this file system. You can have multiple IndexedDB file systems operating at once, but each must have a different name."},idbFactory:{type:"object",required:!1,description:"The IDBFactory to use. Defaults to globalThis.indexedDB."}},async isAvailable(e=globalThis.indexedDB){try{if(!(e instanceof IDBFactory))return!1;let t=e.open("__zenfs_test");return await m(t),e.deleteDatabase("__zenfs_test"),!0}catch{return e.deleteDatabase("__zenfs_test"),!1}},async create(e){let t=await Q(e.storeName||"zenfs",e.idbFactory),i=new I(t),n=new(x(F))(i);return e?.disableAsyncCache||(n._sync=D.create({name:"idb-cache"})),n}};var T=class{constructor(t){this._storage=t}get name(){return L.name}clear(){this._storage.clear()}clearSync(){this._storage.clear()}async sync(){}transaction(){return new v(this)}get(t){let i=this._storage.getItem(t.toString());if(typeof i=="string")return C(i)}set(t,i){try{this._storage.setItem(t.toString(),_(i))}catch{throw new l(E.ENOSPC,"Storage is full.")}}delete(t){try{this._storage.removeItem(t.toString())}catch(i){throw new l(E.EIO,"Unable to delete key "+t+": "+i)}}};c(T,"WebStorageStore");var L={name:"WebStorage",options:{storage:{type:"object",required:!1,description:"The Storage to use. Defaults to globalThis.localStorage."}},isAvailable(e=globalThis.localStorage){return e instanceof globalThis.Storage},create({storage:e=globalThis.localStorage}){return new F(new T(e))}};return K(Z);})();
1
+ "use strict";var ZenFS_DOM=(()=>{var g=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var W=Object.prototype.hasOwnProperty;var c=(e,t)=>g(e,"name",{value:t,configurable:!0});var Y=(e,t)=>{for(var i in t)g(e,i,{get:t[i],enumerable:!0})},G=(e,t,i,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of U(t))!W.call(e,o)&&o!==i&&g(e,o,{get:()=>t[o],enumerable:!(n=H(t,o))||n.enumerable});return e};var K=e=>G(g({},"__esModule",{value:!0}),e);var Z={};Y(Z,{IndexedDB:()=>Q,IndexedDBStore:()=>I,IndexedDBTransaction:()=>N,WebAccess:()=>q,WebAccessFS:()=>p,WebStorage:()=>L,WebStorageStore:()=>T});var ee=ZenFS,{Async:x,AsyncTransaction:te,BigIntStats:ie,BigIntStatsFs:se,Dir:ne,Dirent:oe,Errno:E,ErrnoError:l,Fetch:re,FetchFS:ae,File:ce,FileSystem:P,InMemory:b,InMemoryStore:le,Index:de,IndexFS:Se,Inode:Ee,MutexLock:ue,Mutexed:me,NoSyncFile:fe,Overlay:Oe,OverlayFS:ye,Port:pe,PortFS:he,PortFile:Ne,PreloadFile:v,ReadStream:Ie,Readonly:Te,SimpleAsyncStore:ge,SimpleTransaction:M,Stats:D,StatsCommon:xe,StatsFs:be,StoreFS:F,Sync:De,SyncTransaction:Fe,Transaction:Re,UnmutexedOverlayFS:we,WriteStream:Ae,ZenFsType:Pe,_InMemory:ve,_Port:Me,_toUnixTimestamp:_e,access:Ce,accessSync:ke,appendFile:Be,appendFileSync:Le,attachFS:He,checkOptions:Ue,chmod:We,chmodSync:Ye,chown:Ge,chownSync:Ke,close:Xe,closeSync:ze,configure:Ve,configureSingle:$e,constants:qe,copyFile:je,copyFileSync:Qe,cp:Ze,cpSync:Je,createReadStream:et,createWriteStream:tt,decode:_,decodeDirListing:it,detachFS:st,encode:C,encodeDirListing:nt,errorMessages:ot,exists:rt,existsSync:at,fchmod:ct,fchmodSync:lt,fchown:dt,fchownSync:St,fdatasync:Et,fdatasyncSync:ut,flagToMode:mt,flagToNumber:ft,flagToString:Ot,fs:yt,fstat:pt,fstatSync:ht,fsync:Nt,fsyncSync:It,ftruncate:Tt,ftruncateSync:gt,futimes:xt,futimesSync:bt,handleRequest:Dt,isAppendable:Ft,isBackend:Rt,isBackendConfig:wt,isExclusive:At,isReadable:Pt,isSynchronous:vt,isTruncating:Mt,isWriteable:_t,lchmod:Ct,lchmodSync:kt,lchown:Bt,lchownSync:Lt,levenshtein:Ht,link:Ut,linkSync:Wt,lopenSync:Yt,lstat:Gt,lstatSync:Kt,lutimes:Xt,lutimesSync:zt,mkdir:Vt,mkdirSync:$t,mkdirpSync:qt,mkdtemp:jt,mkdtempSync:Qt,mount:Zt,mountObject:Jt,mounts:ei,normalizeMode:ti,normalizeOptions:ii,normalizePath:si,normalizeTime:ni,open:oi,openAsBlob:ri,openSync:ai,opendir:ci,opendirSync:li,parseFlag:di,promises:Si,randomIno:Ei,read:ui,readFile:mi,readFileSync:fi,readSync:Oi,readdir:yi,readdirSync:pi,readlink:hi,readlinkSync:Ni,readv:Ii,readvSync:Ti,realpath:gi,realpathSync:xi,rename:bi,renameSync:Di,resolveMountConfig:Fi,resolveRemoteMount:Ri,rm:wi,rmSync:Ai,rmdir:Pi,rmdirSync:vi,rootCred:Mi,rootIno:_i,setImmediate:Ci,size_max:ki,stat:Bi,statSync:Li,statfs:Hi,statfsSync:Ui,symlink:Wi,symlinkSync:Yi,truncate:Gi,truncateSync:Ki,umount:Xi,unlink:zi,unlinkSync:Vi,unwatchFile:$i,utimes:qi,utimesSync:ji,version:Qi,watch:Zi,watchFile:Ji,write:es,writeFile:ts,writeFileSync:is,writeSync:ss,writev:ns,writevSync:os}=ZenFS;function X(e,t){let i="",n=0,o=-1,r=0,d="\0";for(let a=0;a<=e.length;++a){if(a<e.length)d=e[a];else{if(d=="/")break;d="/"}if(d=="/"){if(!(o===a-1||r===1))if(r===2){if(i.length<2||n!==2||i.at(-1)!=="."||i.at(-2)!=="."){if(i.length>2){let f=i.lastIndexOf("/");f===-1?(i="",n=0):(i=i.slice(0,f),n=i.length-1-i.lastIndexOf("/")),o=a,r=0;continue}else if(i.length!==0){i="",n=0,o=a,r=0;continue}}t&&(i+=i.length>0?"/..":"..",n=2)}else i.length>0?i+="/"+e.slice(o+1,a):i=e.slice(o+1,a),n=a-o-1;o=a,r=0}else d==="."&&r!==-1?++r:r=-1}return i}c(X,"normalizeString");function z(e){if(!e.length)return".";let t=e.startsWith("/"),i=e.endsWith("/");return e=X(e,!t),e.length?(i&&(e+="/"),t?`/${e}`:e):t?"/":i?"./":"."}c(z,"normalize");function R(...e){if(!e.length)return".";let t=e.join("/");return t?.length?z(t):"."}c(R,"join");function O(e){if(e.length===0)return".";let t=e[0]==="/",i=-1,n=!0;for(let o=e.length-1;o>=1;--o)if(e[o]==="/"){if(!n){i=o;break}}else n=!1;return i===-1?t?"/":".":t&&i===1?"//":e.slice(0,i)}c(O,"dirname");function y(e,t){let i=0,n=-1,o=!0;if(t!==void 0&&t.length>0&&t.length<=e.length){if(t===e)return"";let r=t.length-1,d=-1;for(let a=e.length-1;a>=0;--a)if(e[a]==="/"){if(!o){i=a+1;break}}else d===-1&&(o=!1,d=a+1),r>=0&&(e[a]===t[r]?--r===-1&&(n=a):(r=-1,n=d));return i===n?n=d:n===-1&&(n=e.length),e.slice(i,n)}for(let r=e.length-1;r>=0;--r)if(e[r]==="/"){if(!o){i=r+1;break}}else n===-1&&(o=!1,n=r+1);return n===-1?"":e.slice(i,n)}c(y,"basename");function V(e){switch(e.name){case"IndexSizeError":case"HierarchyRequestError":case"InvalidCharacterError":case"InvalidStateError":case"SyntaxError":case"NamespaceError":case"TypeMismatchError":case"ConstraintError":case"VersionError":case"URLMismatchError":case"InvalidNodeTypeError":return"EINVAL";case"WrongDocumentError":return"EXDEV";case"NoModificationAllowedError":case"InvalidModificationError":case"InvalidAccessError":case"SecurityError":case"NotAllowedError":return"EACCES";case"NotFoundError":return"ENOENT";case"NotSupportedError":return"ENOTSUP";case"InUseAttributeError":return"EBUSY";case"NetworkError":return"ENETDOWN";case"AbortError":return"EINTR";case"QuotaExceededError":return"ENOSPC";case"TimeoutError":return"ETIMEDOUT";case"ReadOnlyError":return"EROFS";case"DataCloneError":case"EncodingError":case"NotReadableError":case"DataError":case"TransactionInactiveError":case"OperationError":case"UnknownError":default:return"EIO"}}c(V,"errnoForDOMException");function u(e,t,i){if(e instanceof l)return e;let n=e instanceof DOMException?E[V(e)]:E.EIO,o=new l(n,e.message,t,i);return o.stack=e.stack,o.cause=e.cause,o}c(u,"convertException");var p=class extends x(P){_handles=new Map;_sync=b.create({name:"accessfs-cache"});constructor(t){super(),this._handles.set("/",t)}metadata(){return{...super.metadata(),name:"WebAccess",noResizableBuffers:!0}}async sync(t,i,n){let o=await this.stat(t);n.mtime!==o.mtime&&await this.writeFile(t,i)}async rename(t,i){try{let n=await this.getHandle(t);if(n instanceof FileSystemDirectoryHandle){let f=await this.readdir(t);if(await this.mkdir(i),f.length==0)await this.unlink(t);else for(let A of f)await this.rename(R(t,A),R(i,A)),await this.unlink(t)}if(!(n instanceof FileSystemFileHandle))return;let o=await n.getFile(),r=await this.getHandle(O(i));if(!(r instanceof FileSystemDirectoryHandle))return;let a=await(await r.getFileHandle(y(i),{create:!0})).createWritable();await a.write(await o.arrayBuffer()),a.close(),await this.unlink(t)}catch(n){throw u(n,t,"rename")}}async writeFile(t,i){if(i.buffer.resizable)throw new l(E.EINVAL,"Resizable buffers can not be written",t,"write");let n=await this.getHandle(O(t));if(!(n instanceof FileSystemDirectoryHandle))return;let r=await(await n.getFileHandle(y(t),{create:!0})).createWritable();await r.write(i),await r.close()}async createFile(t,i){return await this.writeFile(t,new Uint8Array),this.openFile(t,i)}async stat(t){let i=await this.getHandle(t);if(!i)throw l.With("ENOENT",t,"stat");if(i instanceof FileSystemDirectoryHandle)return new D({mode:16895,size:4096});if(i instanceof FileSystemFileHandle){let{lastModified:n,size:o}=await i.getFile();return new D({mode:33279,size:o,mtimeMs:n})}throw new l(E.EBADE,"Handle is not a directory or file",t,"stat")}async openFile(t,i){let n=await this.getHandle(t);if(!(n instanceof FileSystemFileHandle))throw l.With("EISDIR",t,"openFile");try{let o=await n.getFile(),r=new Uint8Array(await o.arrayBuffer()),d=new D({mode:33279,size:o.size,mtimeMs:o.lastModified});return new v(this,t,i,d,r)}catch(o){throw u(o,t,"openFile")}}async unlink(t){let i=await this.getHandle(O(t));if(i instanceof FileSystemDirectoryHandle)try{await i.removeEntry(y(t),{recursive:!0})}catch(n){throw u(n,t,"unlink")}}async link(t){throw l.With("ENOSYS",t,"WebAccessFS.link")}async rmdir(t){return this.unlink(t)}async mkdir(t){if(await this.getHandle(t))throw l.With("EEXIST",t,"mkdir");let n=await this.getHandle(O(t));if(!(n instanceof FileSystemDirectoryHandle))throw l.With("ENOTDIR",t,"mkdir");await n.getDirectoryHandle(y(t),{create:!0})}async readdir(t){let i=await this.getHandle(t);if(!(i instanceof FileSystemDirectoryHandle))throw l.With("ENOTDIR",t,"readdir");let n=[];for await(let o of i.keys())n.push(o);return n}async getHandle(t){if(this._handles.has(t))return this._handles.get(t);let i="/";for(let n of t.split("/").slice(1)){let o=this._handles.get(i);if(!(o instanceof FileSystemDirectoryHandle))throw l.With("ENOTDIR",i,"getHandle");i=R(i,n);try{let r=await o.getDirectoryHandle(n);this._handles.set(i,r)}catch(r){let d=r;if(d.name=="TypeMismatchError")try{let a=await o.getFileHandle(n);this._handles.set(i,a)}catch(a){u(a,i,"getHandle")}if(d.name==="TypeError")throw new l(E.ENOENT,d.message,i,"getHandle");u(d,i,"getHandle")}}return this._handles.get(t)}};c(p,"WebAccessFS");var q={name:"WebAccess",options:{handle:{type:"object",required:!0,description:"The directory handle to use for the root"}},isAvailable(){return typeof FileSystemHandle=="function"},create(e){return new p(e.handle)}};var s;(function(e){e[e.EPERM=1]="EPERM",e[e.ENOENT=2]="ENOENT",e[e.EINTR=4]="EINTR",e[e.EIO=5]="EIO",e[e.ENXIO=6]="ENXIO",e[e.EBADF=9]="EBADF",e[e.EAGAIN=11]="EAGAIN",e[e.ENOMEM=12]="ENOMEM",e[e.EACCES=13]="EACCES",e[e.EFAULT=14]="EFAULT",e[e.ENOTBLK=15]="ENOTBLK",e[e.EBUSY=16]="EBUSY",e[e.EEXIST=17]="EEXIST",e[e.EXDEV=18]="EXDEV",e[e.ENODEV=19]="ENODEV",e[e.ENOTDIR=20]="ENOTDIR",e[e.EISDIR=21]="EISDIR",e[e.EINVAL=22]="EINVAL",e[e.ENFILE=23]="ENFILE",e[e.EMFILE=24]="EMFILE",e[e.ETXTBSY=26]="ETXTBSY",e[e.EFBIG=27]="EFBIG",e[e.ENOSPC=28]="ENOSPC",e[e.ESPIPE=29]="ESPIPE",e[e.EROFS=30]="EROFS",e[e.EMLINK=31]="EMLINK",e[e.EPIPE=32]="EPIPE",e[e.EDOM=33]="EDOM",e[e.ERANGE=34]="ERANGE",e[e.EDEADLK=35]="EDEADLK",e[e.ENAMETOOLONG=36]="ENAMETOOLONG",e[e.ENOLCK=37]="ENOLCK",e[e.ENOSYS=38]="ENOSYS",e[e.ENOTEMPTY=39]="ENOTEMPTY",e[e.ELOOP=40]="ELOOP",e[e.ENOMSG=42]="ENOMSG",e[e.EBADE=52]="EBADE",e[e.EBADR=53]="EBADR",e[e.EXFULL=54]="EXFULL",e[e.ENOANO=55]="ENOANO",e[e.EBADRQC=56]="EBADRQC",e[e.ENOSTR=60]="ENOSTR",e[e.ENODATA=61]="ENODATA",e[e.ETIME=62]="ETIME",e[e.ENOSR=63]="ENOSR",e[e.ENONET=64]="ENONET",e[e.EREMOTE=66]="EREMOTE",e[e.ENOLINK=67]="ENOLINK",e[e.ECOMM=70]="ECOMM",e[e.EPROTO=71]="EPROTO",e[e.EBADMSG=74]="EBADMSG",e[e.EOVERFLOW=75]="EOVERFLOW",e[e.EBADFD=77]="EBADFD",e[e.ESTRPIPE=86]="ESTRPIPE",e[e.ENOTSOCK=88]="ENOTSOCK",e[e.EDESTADDRREQ=89]="EDESTADDRREQ",e[e.EMSGSIZE=90]="EMSGSIZE",e[e.EPROTOTYPE=91]="EPROTOTYPE",e[e.ENOPROTOOPT=92]="ENOPROTOOPT",e[e.EPROTONOSUPPORT=93]="EPROTONOSUPPORT",e[e.ESOCKTNOSUPPORT=94]="ESOCKTNOSUPPORT",e[e.ENOTSUP=95]="ENOTSUP",e[e.ENETDOWN=100]="ENETDOWN",e[e.ENETUNREACH=101]="ENETUNREACH",e[e.ENETRESET=102]="ENETRESET",e[e.ETIMEDOUT=110]="ETIMEDOUT",e[e.ECONNREFUSED=111]="ECONNREFUSED",e[e.EHOSTDOWN=112]="EHOSTDOWN",e[e.EHOSTUNREACH=113]="EHOSTUNREACH",e[e.EALREADY=114]="EALREADY",e[e.EINPROGRESS=115]="EINPROGRESS",e[e.ESTALE=116]="ESTALE",e[e.EREMOTEIO=121]="EREMOTEIO",e[e.EDQUOT=122]="EDQUOT"})(s||(s={}));var B={[s.EPERM]:"Operation not permitted",[s.ENOENT]:"No such file or directory",[s.EINTR]:"Interrupted system call",[s.EIO]:"Input/output error",[s.ENXIO]:"No such device or address",[s.EBADF]:"Bad file descriptor",[s.EAGAIN]:"Resource temporarily unavailable",[s.ENOMEM]:"Cannot allocate memory",[s.EACCES]:"Permission denied",[s.EFAULT]:"Bad address",[s.ENOTBLK]:"Block device required",[s.EBUSY]:"Resource busy or locked",[s.EEXIST]:"File exists",[s.EXDEV]:"Invalid cross-device link",[s.ENODEV]:"No such device",[s.ENOTDIR]:"File is not a directory",[s.EISDIR]:"File is a directory",[s.EINVAL]:"Invalid argument",[s.ENFILE]:"Too many open files in system",[s.EMFILE]:"Too many open files",[s.ETXTBSY]:"Text file busy",[s.EFBIG]:"File is too big",[s.ENOSPC]:"No space left on disk",[s.ESPIPE]:"Illegal seek",[s.EROFS]:"Cannot modify a read-only file system",[s.EMLINK]:"Too many links",[s.EPIPE]:"Broken pipe",[s.EDOM]:"Numerical argument out of domain",[s.ERANGE]:"Numerical result out of range",[s.EDEADLK]:"Resource deadlock would occur",[s.ENAMETOOLONG]:"File name too long",[s.ENOLCK]:"No locks available",[s.ENOSYS]:"Function not implemented",[s.ENOTEMPTY]:"Directory is not empty",[s.ELOOP]:"Too many levels of symbolic links",[s.ENOMSG]:"No message of desired type",[s.EBADE]:"Invalid exchange",[s.EBADR]:"Invalid request descriptor",[s.EXFULL]:"Exchange full",[s.ENOANO]:"No anode",[s.EBADRQC]:"Invalid request code",[s.ENOSTR]:"Device not a stream",[s.ENODATA]:"No data available",[s.ETIME]:"Timer expired",[s.ENOSR]:"Out of streams resources",[s.ENONET]:"Machine is not on the network",[s.EREMOTE]:"Object is remote",[s.ENOLINK]:"Link has been severed",[s.ECOMM]:"Communication error on send",[s.EPROTO]:"Protocol error",[s.EBADMSG]:"Bad message",[s.EOVERFLOW]:"Value too large for defined data type",[s.EBADFD]:"File descriptor in bad state",[s.ESTRPIPE]:"Streams pipe error",[s.ENOTSOCK]:"Socket operation on non-socket",[s.EDESTADDRREQ]:"Destination address required",[s.EMSGSIZE]:"Message too long",[s.EPROTOTYPE]:"Protocol wrong type for socket",[s.ENOPROTOOPT]:"Protocol not available",[s.EPROTONOSUPPORT]:"Protocol not supported",[s.ESOCKTNOSUPPORT]:"Socket type not supported",[s.ENOTSUP]:"Operation is not supported",[s.ENETDOWN]:"Network is down",[s.ENETUNREACH]:"Network is unreachable",[s.ENETRESET]:"Network dropped connection on reset",[s.ETIMEDOUT]:"Connection timed out",[s.ECONNREFUSED]:"Connection refused",[s.EHOSTDOWN]:"Host is down",[s.EHOSTUNREACH]:"No route to host",[s.EALREADY]:"Operation already in progress",[s.EINPROGRESS]:"Operation now in progress",[s.ESTALE]:"Stale file handle",[s.EREMOTEIO]:"Remote I/O error",[s.EDQUOT]:"Disk quota exceeded"},S=class extends Error{static fromJSON(t){let i=new S(t.errno,t.message,t.path,t.syscall);return i.code=t.code,i.stack=t.stack,i}static With(t,i,n){return new S(s[t],B[s[t]],i,n)}constructor(t,i=B[t],n,o=""){super(i),this.errno=t,this.path=n,this.syscall=o,this.code=s[t],this.message=`${this.code}: ${i}${this.path?`, '${this.path}'`:""}`}toString(){return this.message}toJSON(){return{errno:this.errno,code:this.code,path:this.path,stack:this.stack,message:this.message,syscall:this.syscall}}bufferSize(){return 4+JSON.stringify(this.toJSON()).length}};c(S,"ErrnoError");Promise.withResolvers??(Promise.withResolvers=function(){let e,t;return{promise:new Promise((n,o)=>{e=n,t=o}),resolve:e,reject:t}});Symbol.dispose??(Symbol.dispose=Symbol("Symbol.dispose"));Symbol.asyncDispose??(Symbol.asyncDispose=Symbol("Symbol.asyncDispose"));var w=class{constructor(t){this.store=t,this.done=!1}async[Symbol.asyncDispose](){this.done||await this.abort()}[Symbol.dispose](){this.done||this.abortSync()}};c(w,"Transaction");var h=class extends w{getSync(){throw S.With("ENOSYS",void 0,"AsyncTransaction.getSync")}setSync(){throw S.With("ENOSYS",void 0,"AsyncTransaction.setSync")}removeSync(){throw S.With("ENOSYS",void 0,"AsyncTransaction.removeSync")}commitSync(){throw S.With("ENOSYS",void 0,"AsyncTransaction.commitSync")}abortSync(){throw S.With("ENOSYS",void 0,"AsyncTransaction.abortSync")}};c(h,"AsyncTransaction");function m(e){return new Promise((t,i)=>{e.onsuccess=()=>t(e.result),e.onerror=n=>{n.preventDefault(),i(u(e.error))}})}c(m,"wrap");var N=class extends h{constructor(i,n){super(n);this.tx=i;this.store=n;this._idb=i.objectStore(n.name)}_idb;get(i){return m(this._idb.get(i.toString()))}async set(i,n){await m(this._idb.put(n,i.toString()))}remove(i){return m(this._idb.delete(i.toString()))}async commit(){this.done||(this.done=!0,this.tx.commit())}async abort(){if(!this.done){this.done=!0;try{this.tx.abort()}catch(i){throw u(i)}}}};c(N,"IndexedDBTransaction");async function j(e,t=globalThis.indexedDB){let i=t.open(e);return i.onupgradeneeded=()=>{let o=i.result;o.objectStoreNames.contains(e)&&o.deleteObjectStore(e),o.createObjectStore(e)},await m(i)}c(j,"createDB");var I=class{constructor(t){this.db=t}sync(){throw new Error("Method not implemented.")}get name(){return this.db.name}clear(){return m(this.db.transaction(this.name,"readwrite").objectStore(this.name).clear())}clearSync(){throw l.With("ENOSYS",void 0,"IndexedDBStore.clearSync")}transaction(){let t=this.db.transaction(this.name,"readwrite");return new N(t,this)}};c(I,"IndexedDBStore");var Q={name:"IndexedDB",options:{storeName:{type:"string",required:!1,description:"The name of this file system. You can have multiple IndexedDB file systems operating at once, but each must have a different name."},idbFactory:{type:"object",required:!1,description:"The IDBFactory to use. Defaults to globalThis.indexedDB."}},async isAvailable(e=globalThis.indexedDB){try{if(!(e instanceof IDBFactory))return!1;let t=e.open("__zenfs_test");return await m(t),e.deleteDatabase("__zenfs_test"),!0}catch{return e.deleteDatabase("__zenfs_test"),!1}},async create(e){let t=await j(e.storeName||"zenfs",e.idbFactory),i=new I(t),n=new(x(F))(i);return e?.disableAsyncCache||(n._sync=b.create({name:"idb-cache"})),n}};var T=class{constructor(t){this._storage=t}get name(){return L.name}clear(){this._storage.clear()}clearSync(){this._storage.clear()}async sync(){}transaction(){return new M(this)}get(t){let i=this._storage.getItem(t.toString());if(typeof i=="string")return C(i)}set(t,i){try{this._storage.setItem(t.toString(),_(i))}catch{throw new l(E.ENOSPC,"Storage is full.")}}delete(t){try{this._storage.removeItem(t.toString())}catch(i){throw new l(E.EIO,"Unable to delete key "+t+": "+i)}}};c(T,"WebStorageStore");var L={name:"WebStorage",options:{storage:{type:"object",required:!1,description:"The Storage to use. Defaults to globalThis.localStorage."}},isAvailable(e=globalThis.localStorage){return e instanceof globalThis.Storage},create({storage:e=globalThis.localStorage}){return new F(new T(e))}};return K(Z);})();
2
2
  //# sourceMappingURL=browser.min.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../src/index.ts", "global-externals:@zenfs/core", "../node_modules/@zenfs/core/dist/emulation/path.js", "../src/utils.ts", "../src/access.ts", "../node_modules/@zenfs/core/dist/error.js", "../node_modules/@zenfs/core/dist/backends/store/store.js", "../src/IndexedDB.ts", "../src/Storage.ts"],
4
- "sourcesContent": ["export * from './access.js';\nexport * from './IndexedDB.js';\nexport * from './Storage.js';\n", "export default ZenFS;\nconst { Async, AsyncTransaction, BigIntStats, BigIntStatsFs, Dir, Dirent, Errno, ErrnoError, Fetch, FetchFS, File, FileSystem, FileType, InMemory, InMemoryStore, IndexFS, Inode, LockedFS, Mutex, NoSyncFile, Overlay, OverlayFS, Port, PortFS, PortFile, PreloadFile, ReadStream, Readonly, SimpleAsyncStore, SimpleTransaction, Stats, StatsCommon, StatsFs, StoreFS, Sync, SyncTransaction, Transaction, UnlockedOverlayFS, WriteStream, ZenFsType, _toUnixTimestamp, access, accessSync, appendFile, appendFileSync, attachFS, checkOptions, chmod, chmodSync, chown, chownSync, close, closeSync, configure, constants, copyFile, copyFileSync, cp, cpSync, createReadStream, createWriteStream, decode, decodeDirListing, detachFS, encode, encodeDirListing, errorMessages, exists, existsSync, fchmod, fchmodSync, fchown, fchownSync, fdatasync, fdatasyncSync, flagToMode, flagToNumber, flagToString, fs, fstat, fstatSync, fsync, fsyncSync, ftruncate, ftruncateSync, futimes, futimesSync, isAppendable, isBackend, isBackendConfig, isExclusive, isReadable, isSynchronous, isTruncating, isWriteable, lchmod, lchmodSync, lchown, lchownSync, levenshtein, link, linkSync, lopenSync, lstat, lstatSync, lutimes, lutimesSync, mkdir, mkdirSync, mkdirpSync, mkdtemp, mkdtempSync, mount, mountObject, mounts, nop, normalizeMode, normalizeOptions, normalizePath, normalizeTime, open, openAsBlob, openSync, opendir, opendirSync, parseFlag, promises, randomIno, read, readFile, readFileSync, readSync, readdir, readdirSync, readlink, readlinkSync, readv, readvSync, realpath, realpathSync, rename, renameSync, resolveMountConfig, rm, rmSync, rmdir, rmdirSync, rootCred, rootIno, setImmediate, size_max, stat, statSync, statfs, statfsSync, symlink, symlinkSync, truncate, truncateSync, umount, unlink, unlinkSync, unwatchFile, utimes, utimesSync, watch, watchFile, write, writeFile, writeFileSync, writeSync, writev, writevSync } = ZenFS;\nexport { Async, AsyncTransaction, BigIntStats, BigIntStatsFs, Dir, Dirent, Errno, ErrnoError, Fetch, FetchFS, File, FileSystem, FileType, InMemory, InMemoryStore, IndexFS, Inode, LockedFS, Mutex, NoSyncFile, Overlay, OverlayFS, Port, PortFS, PortFile, PreloadFile, ReadStream, Readonly, SimpleAsyncStore, SimpleTransaction, Stats, StatsCommon, StatsFs, StoreFS, Sync, SyncTransaction, Transaction, UnlockedOverlayFS, WriteStream, ZenFsType, _toUnixTimestamp, access, accessSync, appendFile, appendFileSync, attachFS, checkOptions, chmod, chmodSync, chown, chownSync, close, closeSync, configure, constants, copyFile, copyFileSync, cp, cpSync, createReadStream, createWriteStream, decode, decodeDirListing, detachFS, encode, encodeDirListing, errorMessages, exists, existsSync, fchmod, fchmodSync, fchown, fchownSync, fdatasync, fdatasyncSync, flagToMode, flagToNumber, flagToString, fs, fstat, fstatSync, fsync, fsyncSync, ftruncate, ftruncateSync, futimes, futimesSync, isAppendable, isBackend, isBackendConfig, isExclusive, isReadable, isSynchronous, isTruncating, isWriteable, lchmod, lchmodSync, lchown, lchownSync, levenshtein, link, linkSync, lopenSync, lstat, lstatSync, lutimes, lutimesSync, mkdir, mkdirSync, mkdirpSync, mkdtemp, mkdtempSync, mount, mountObject, mounts, nop, normalizeMode, normalizeOptions, normalizePath, normalizeTime, open, openAsBlob, openSync, opendir, opendirSync, parseFlag, promises, randomIno, read, readFile, readFileSync, readSync, readdir, readdirSync, readlink, readlinkSync, readv, readvSync, realpath, realpathSync, rename, renameSync, resolveMountConfig, rm, rmSync, rmdir, rmdirSync, rootCred, rootIno, setImmediate, size_max, stat, statSync, statfs, statfsSync, symlink, symlinkSync, truncate, truncateSync, umount, unlink, unlinkSync, unwatchFile, utimes, utimesSync, watch, watchFile, write, writeFile, writeFileSync, writeSync, writev, writevSync };", "/*\nCopyright Joyent, Inc. and other Node contributors.\n\nPermission is hereby granted, free of charge, to any person obtaining a\ncopy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to permit\npersons to whom the Software is furnished to do so, subject to the\nfollowing conditions:\n\nThe above copyright notice and this permission notice shall be included\nin all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\nOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\nNO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\nDAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\nOTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\nUSE OR OTHER DEALINGS IN THE SOFTWARE.\n*/\nexport let cwd = '/';\nexport function cd(path) {\n cwd = resolve(cwd, path);\n}\nexport const sep = '/';\nfunction validateObject(str, name) {\n if (typeof str != 'object') {\n throw new TypeError(`\"${name}\" is not an object`);\n }\n}\n// Resolves . and .. elements in a path with directory names\nexport function normalizeString(path, allowAboveRoot) {\n let res = '';\n let lastSegmentLength = 0;\n let lastSlash = -1;\n let dots = 0;\n let char = '\\x00';\n for (let i = 0; i <= path.length; ++i) {\n if (i < path.length) {\n char = path[i];\n }\n else if (char == '/') {\n break;\n }\n else {\n char = '/';\n }\n if (char == '/') {\n if (lastSlash === i - 1 || dots === 1) {\n // NOOP\n }\n else if (dots === 2) {\n if (res.length < 2 || lastSegmentLength !== 2 || res.at(-1) !== '.' || res.at(-2) !== '.') {\n if (res.length > 2) {\n const lastSlashIndex = res.lastIndexOf('/');\n if (lastSlashIndex === -1) {\n res = '';\n lastSegmentLength = 0;\n }\n else {\n res = res.slice(0, lastSlashIndex);\n lastSegmentLength = res.length - 1 - res.lastIndexOf('/');\n }\n lastSlash = i;\n dots = 0;\n continue;\n }\n else if (res.length !== 0) {\n res = '';\n lastSegmentLength = 0;\n lastSlash = i;\n dots = 0;\n continue;\n }\n }\n if (allowAboveRoot) {\n res += res.length > 0 ? '/..' : '..';\n lastSegmentLength = 2;\n }\n }\n else {\n if (res.length > 0)\n res += '/' + path.slice(lastSlash + 1, i);\n else\n res = path.slice(lastSlash + 1, i);\n lastSegmentLength = i - lastSlash - 1;\n }\n lastSlash = i;\n dots = 0;\n }\n else if (char === '.' && dots !== -1) {\n ++dots;\n }\n else {\n dots = -1;\n }\n }\n return res;\n}\nexport function formatExt(ext) {\n return ext ? `${ext[0] === '.' ? '' : '.'}${ext}` : '';\n}\nexport function resolve(...parts) {\n let resolved = '';\n for (const part of [...parts.reverse(), cwd]) {\n if (!part.length) {\n continue;\n }\n resolved = `${part}/${resolved}`;\n if (part.startsWith('/')) {\n break;\n }\n }\n const absolute = resolved.startsWith('/');\n // At this point the path should be resolved to a full absolute path, but\n // handle relative paths to be safe (might happen when cwd fails)\n // Normalize the path\n resolved = normalizeString(resolved, !absolute);\n if (absolute) {\n return `/${resolved}`;\n }\n return resolved.length ? resolved : '/';\n}\nexport function normalize(path) {\n if (!path.length)\n return '.';\n const isAbsolute = path.startsWith('/');\n const trailingSeparator = path.endsWith('/');\n // Normalize the path\n path = normalizeString(path, !isAbsolute);\n if (!path.length) {\n if (isAbsolute)\n return '/';\n return trailingSeparator ? './' : '.';\n }\n if (trailingSeparator)\n path += '/';\n return isAbsolute ? `/${path}` : path;\n}\nexport function isAbsolute(path) {\n return path.startsWith('/');\n}\nexport function join(...parts) {\n if (!parts.length)\n return '.';\n const joined = parts.join('/');\n if (!joined?.length)\n return '.';\n return normalize(joined);\n}\nexport function relative(from, to) {\n if (from === to)\n return '';\n // Trim leading forward slashes.\n from = resolve(from);\n to = resolve(to);\n if (from === to)\n return '';\n const fromStart = 1;\n const fromEnd = from.length;\n const fromLen = fromEnd - fromStart;\n const toStart = 1;\n const toLen = to.length - toStart;\n // Compare paths to find the longest common path from root\n const length = fromLen < toLen ? fromLen : toLen;\n let lastCommonSep = -1;\n let i = 0;\n for (; i < length; i++) {\n const fromCode = from[fromStart + i];\n if (fromCode !== to[toStart + i])\n break;\n else if (fromCode === '/')\n lastCommonSep = i;\n }\n if (i === length) {\n if (toLen > length) {\n if (to[toStart + i] === '/') {\n // We get here if `from` is the exact base path for `to`.\n // For example: from='/foo/bar'; to='/foo/bar/baz'\n return to.slice(toStart + i + 1);\n }\n if (i === 0) {\n // We get here if `from` is the root\n // For example: from='/'; to='/foo'\n return to.slice(toStart + i);\n }\n }\n else if (fromLen > length) {\n if (from[fromStart + i] === '/') {\n // We get here if `to` is the exact base path for `from`.\n // For example: from='/foo/bar/baz'; to='/foo/bar'\n lastCommonSep = i;\n }\n else if (i === 0) {\n // We get here if `to` is the root.\n // For example: from='/foo/bar'; to='/'\n lastCommonSep = 0;\n }\n }\n }\n let out = '';\n // Generate the relative path based on the path difference between `to`\n // and `from`.\n for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {\n if (i === fromEnd || from[i] === '/') {\n out += out.length === 0 ? '..' : '/..';\n }\n }\n // Lastly, append the rest of the destination (`to`) path that comes after\n // the common path parts.\n return `${out}${to.slice(toStart + lastCommonSep)}`;\n}\nexport function dirname(path) {\n if (path.length === 0)\n return '.';\n const hasRoot = path[0] === '/';\n let end = -1;\n let matchedSlash = true;\n for (let i = path.length - 1; i >= 1; --i) {\n if (path[i] === '/') {\n if (!matchedSlash) {\n end = i;\n break;\n }\n }\n else {\n // We saw the first non-path separator\n matchedSlash = false;\n }\n }\n if (end === -1)\n return hasRoot ? '/' : '.';\n if (hasRoot && end === 1)\n return '//';\n return path.slice(0, end);\n}\nexport function basename(path, suffix) {\n let start = 0;\n let end = -1;\n let matchedSlash = true;\n if (suffix !== undefined && suffix.length > 0 && suffix.length <= path.length) {\n if (suffix === path)\n return '';\n let extIdx = suffix.length - 1;\n let firstNonSlashEnd = -1;\n for (let i = path.length - 1; i >= 0; --i) {\n if (path[i] === '/') {\n // If we reached a path separator that was not part of a set of path\n // separators at the end of the string, stop now\n if (!matchedSlash) {\n start = i + 1;\n break;\n }\n }\n else {\n if (firstNonSlashEnd === -1) {\n // We saw the first non-path separator, remember this index in case\n // we need it if the extension ends up not matching\n matchedSlash = false;\n firstNonSlashEnd = i + 1;\n }\n if (extIdx >= 0) {\n // Try to match the explicit extension\n if (path[i] === suffix[extIdx]) {\n if (--extIdx === -1) {\n // We matched the extension, so mark this as the end of our path\n // component\n end = i;\n }\n }\n else {\n // Extension does not match, so our result is the entire path\n // component\n extIdx = -1;\n end = firstNonSlashEnd;\n }\n }\n }\n }\n if (start === end)\n end = firstNonSlashEnd;\n else if (end === -1)\n end = path.length;\n return path.slice(start, end);\n }\n for (let i = path.length - 1; i >= 0; --i) {\n if (path[i] === '/') {\n // If we reached a path separator that was not part of a set of path\n // separators at the end of the string, stop now\n if (!matchedSlash) {\n start = i + 1;\n break;\n }\n }\n else if (end === -1) {\n // We saw the first non-path separator, mark this as the end of our\n // path component\n matchedSlash = false;\n end = i + 1;\n }\n }\n if (end === -1)\n return '';\n return path.slice(start, end);\n}\nexport function extname(path) {\n let startDot = -1;\n let startPart = 0;\n let end = -1;\n let matchedSlash = true;\n // Track the state of characters (if any) we see before our first dot and\n // after any path separator we find\n let preDotState = 0;\n for (let i = path.length - 1; i >= 0; --i) {\n if (path[i] === '/') {\n // If we reached a path separator that was not part of a set of path\n // separators at the end of the string, stop now\n if (!matchedSlash) {\n startPart = i + 1;\n break;\n }\n continue;\n }\n if (end === -1) {\n // We saw the first non-path separator, mark this as the end of our\n // extension\n matchedSlash = false;\n end = i + 1;\n }\n if (path[i] === '.') {\n // If this is our first dot, mark it as the start of our extension\n if (startDot === -1)\n startDot = i;\n else if (preDotState !== 1)\n preDotState = 1;\n }\n else if (startDot !== -1) {\n // We saw a non-dot and non-path separator before our dot, so we should\n // have a good chance at having a non-empty extension\n preDotState = -1;\n }\n }\n if (startDot === -1 ||\n end === -1 ||\n // We saw a non-dot character immediately before the dot\n preDotState === 0 ||\n // The (right-most) trimmed path component is exactly '..'\n (preDotState === 1 && startDot === end - 1 && startDot === startPart + 1)) {\n return '';\n }\n return path.slice(startDot, end);\n}\nexport function format(pathObject) {\n validateObject(pathObject, 'pathObject');\n const dir = pathObject.dir || pathObject.root;\n const base = pathObject.base || `${pathObject.name || ''}${formatExt(pathObject.ext)}`;\n if (!dir) {\n return base;\n }\n return dir === pathObject.root ? `${dir}${base}` : `${dir}/${base}`;\n}\nexport function parse(path) {\n const isAbsolute = path.startsWith('/');\n const ret = { root: isAbsolute ? '/' : '', dir: '', base: '', ext: '', name: '' };\n if (path.length === 0)\n return ret;\n const start = isAbsolute ? 1 : 0;\n let startDot = -1;\n let startPart = 0;\n let end = -1;\n let matchedSlash = true;\n let i = path.length - 1;\n // Track the state of characters (if any) we see before our first dot and\n // after any path separator we find\n let preDotState = 0;\n // Get non-dir info\n for (; i >= start; --i) {\n if (path[i] === '/') {\n // If we reached a path separator that was not part of a set of path\n // separators at the end of the string, stop now\n if (!matchedSlash) {\n startPart = i + 1;\n break;\n }\n continue;\n }\n if (end === -1) {\n // We saw the first non-path separator, mark this as the end of our\n // extension\n matchedSlash = false;\n end = i + 1;\n }\n if (path[i] === '.') {\n // If this is our first dot, mark it as the start of our extension\n if (startDot === -1)\n startDot = i;\n else if (preDotState !== 1)\n preDotState = 1;\n }\n else if (startDot !== -1) {\n // We saw a non-dot and non-path separator before our dot, so we should\n // have a good chance at having a non-empty extension\n preDotState = -1;\n }\n }\n if (end !== -1) {\n const start = startPart === 0 && isAbsolute ? 1 : startPart;\n if (startDot === -1 ||\n // We saw a non-dot character immediately before the dot\n preDotState === 0 ||\n // The (right-most) trimmed path component is exactly '..'\n (preDotState === 1 && startDot === end - 1 && startDot === startPart + 1)) {\n ret.base = ret.name = path.slice(start, end);\n }\n else {\n ret.name = path.slice(start, startDot);\n ret.base = path.slice(start, end);\n ret.ext = path.slice(startDot, end);\n }\n }\n if (startPart > 0)\n ret.dir = path.slice(0, startPart - 1);\n else if (isAbsolute)\n ret.dir = '/';\n return ret;\n}\n", "import { ErrnoError, Errno } from '@zenfs/core';\n\n/**\n * Converts a DOMException into an Errno\n * @see https://developer.mozilla.org/Web/API/DOMException\n */\nfunction errnoForDOMException(ex: DOMException): keyof typeof Errno {\n\tswitch (ex.name) {\n\t\tcase 'IndexSizeError':\n\t\tcase 'HierarchyRequestError':\n\t\tcase 'InvalidCharacterError':\n\t\tcase 'InvalidStateError':\n\t\tcase 'SyntaxError':\n\t\tcase 'NamespaceError':\n\t\tcase 'TypeMismatchError':\n\t\tcase 'ConstraintError':\n\t\tcase 'VersionError':\n\t\tcase 'URLMismatchError':\n\t\tcase 'InvalidNodeTypeError':\n\t\t\treturn 'EINVAL';\n\t\tcase 'WrongDocumentError':\n\t\t\treturn 'EXDEV';\n\t\tcase 'NoModificationAllowedError':\n\t\tcase 'InvalidModificationError':\n\t\tcase 'InvalidAccessError':\n\t\tcase 'SecurityError':\n\t\tcase 'NotAllowedError':\n\t\t\treturn 'EACCES';\n\t\tcase 'NotFoundError':\n\t\t\treturn 'ENOENT';\n\t\tcase 'NotSupportedError':\n\t\t\treturn 'ENOTSUP';\n\t\tcase 'InUseAttributeError':\n\t\t\treturn 'EBUSY';\n\t\tcase 'NetworkError':\n\t\t\treturn 'ENETDOWN';\n\t\tcase 'AbortError':\n\t\t\treturn 'EINTR';\n\t\tcase 'QuotaExceededError':\n\t\t\treturn 'ENOSPC';\n\t\tcase 'TimeoutError':\n\t\t\treturn 'ETIMEDOUT';\n\t\tcase 'ReadOnlyError':\n\t\t\treturn 'EROFS';\n\t\tcase 'DataCloneError':\n\t\tcase 'EncodingError':\n\t\tcase 'NotReadableError':\n\t\tcase 'DataError':\n\t\tcase 'TransactionInactiveError':\n\t\tcase 'OperationError':\n\t\tcase 'UnknownError':\n\t\tdefault:\n\t\t\treturn 'EIO';\n\t}\n}\n\n/**\n * @internal\n */\nexport type ConvertException = ErrnoError | DOMException | Error;\n\n/**\n * Handles converting errors, then rethrowing them\n * @internal\n */\nexport function convertException(ex: ConvertException, path?: string, syscall?: string): ErrnoError {\n\tif (ex instanceof ErrnoError) {\n\t\treturn ex;\n\t}\n\n\tconst code = ex instanceof DOMException ? Errno[errnoForDOMException(ex)] : Errno.EIO;\n\tconst error = new ErrnoError(code, ex.message, path, syscall);\n\terror.stack = ex.stack!;\n\terror.cause = ex.cause;\n\treturn error;\n}\n", "import type { Backend, FileSystemMetadata } from '@zenfs/core';\nimport { Async, Errno, ErrnoError, FileSystem, InMemory, PreloadFile, Stats } from '@zenfs/core';\nimport { S_IFDIR, S_IFREG } from '@zenfs/core/emulation/constants.js';\nimport { basename, dirname, join } from '@zenfs/core/emulation/path.js';\nimport { convertException, type ConvertException } from './utils.js';\n\ndeclare global {\n\tinterface FileSystemDirectoryHandle {\n\t\t[Symbol.iterator](): IterableIterator<[string, FileSystemHandle]>;\n\t\tentries(): IterableIterator<[string, FileSystemHandle]>;\n\t\tkeys(): IterableIterator<string>;\n\t\tvalues(): IterableIterator<FileSystemHandle>;\n\t}\n}\n\nexport interface WebAccessOptions {\n\thandle: FileSystemDirectoryHandle;\n}\n\nexport class WebAccessFS extends Async(FileSystem) {\n\tprivate _handles: Map<string, FileSystemHandle> = new Map();\n\n\t/**\n\t * @hidden\n\t */\n\t_sync: FileSystem = InMemory.create({ name: 'accessfs-cache' });\n\n\tpublic constructor(handle: FileSystemDirectoryHandle) {\n\t\tsuper();\n\t\tthis._handles.set('/', handle);\n\t}\n\n\tpublic metadata(): FileSystemMetadata {\n\t\treturn {\n\t\t\t...super.metadata(),\n\t\t\tname: 'WebAccess',\n\t\t\tnoResizableBuffers: true,\n\t\t};\n\t}\n\n\tpublic async sync(path: string, data: Uint8Array, stats: Stats): Promise<void> {\n\t\tconst currentStats = await this.stat(path);\n\t\tif (stats.mtime !== currentStats!.mtime) {\n\t\t\tawait this.writeFile(path, data);\n\t\t}\n\t}\n\n\tpublic async rename(oldPath: string, newPath: string): Promise<void> {\n\t\ttry {\n\t\t\tconst handle = await this.getHandle(oldPath);\n\t\t\tif (handle instanceof FileSystemDirectoryHandle) {\n\t\t\t\tconst files = await this.readdir(oldPath);\n\n\t\t\t\tawait this.mkdir(newPath);\n\t\t\t\tif (files.length == 0) {\n\t\t\t\t\tawait this.unlink(oldPath);\n\t\t\t\t} else {\n\t\t\t\t\tfor (const file of files) {\n\t\t\t\t\t\tawait this.rename(join(oldPath, file), join(newPath, file));\n\t\t\t\t\t\tawait this.unlink(oldPath);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!(handle instanceof FileSystemFileHandle)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst oldFile = await handle.getFile(),\n\t\t\t\tdestFolder = await this.getHandle(dirname(newPath));\n\t\t\tif (!(destFolder instanceof FileSystemDirectoryHandle)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst newFile = await destFolder.getFileHandle(basename(newPath), { create: true });\n\t\t\tconst writable = await newFile.createWritable();\n\t\t\tawait writable.write(await oldFile.arrayBuffer());\n\n\t\t\twritable.close();\n\t\t\tawait this.unlink(oldPath);\n\t\t} catch (ex) {\n\t\t\tthrow convertException(ex as ConvertException, oldPath, 'rename');\n\t\t}\n\t}\n\n\tpublic async writeFile(path: string, data: Uint8Array): Promise<void> {\n\t\tif (data.buffer.resizable) {\n\t\t\tthrow new ErrnoError(Errno.EINVAL, 'Resizable buffers can not be written', path, 'write');\n\t\t}\n\n\t\tconst handle = await this.getHandle(dirname(path));\n\t\tif (!(handle instanceof FileSystemDirectoryHandle)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst file = await handle.getFileHandle(basename(path), { create: true });\n\t\tconst writable = await file.createWritable();\n\t\tawait writable.write(data);\n\t\tawait writable.close();\n\t}\n\n\tpublic async createFile(path: string, flag: string): Promise<PreloadFile<this>> {\n\t\tawait this.writeFile(path, new Uint8Array());\n\t\treturn this.openFile(path, flag);\n\t}\n\n\tpublic async stat(path: string): Promise<Stats> {\n\t\tconst handle = await this.getHandle(path);\n\t\tif (!handle) {\n\t\t\tthrow ErrnoError.With('ENOENT', path, 'stat');\n\t\t}\n\t\tif (handle instanceof FileSystemDirectoryHandle) {\n\t\t\treturn new Stats({ mode: 0o777 | S_IFDIR, size: 4096 });\n\t\t}\n\t\tif (handle instanceof FileSystemFileHandle) {\n\t\t\tconst { lastModified, size } = await handle.getFile();\n\t\t\treturn new Stats({ mode: 0o777 | S_IFREG, size, mtimeMs: lastModified });\n\t\t}\n\t\tthrow new ErrnoError(Errno.EBADE, 'Handle is not a directory or file', path, 'stat');\n\t}\n\n\tpublic async openFile(path: string, flag: string): Promise<PreloadFile<this>> {\n\t\tconst handle = await this.getHandle(path);\n\t\tif (!(handle instanceof FileSystemFileHandle)) {\n\t\t\tthrow ErrnoError.With('EISDIR', path, 'openFile');\n\t\t}\n\t\ttry {\n\t\t\tconst file = await handle.getFile();\n\t\t\tconst data = new Uint8Array(await file.arrayBuffer());\n\t\t\tconst stats = new Stats({ mode: 0o777 | S_IFREG, size: file.size, mtimeMs: file.lastModified });\n\t\t\treturn new PreloadFile(this, path, flag, stats, data);\n\t\t} catch (ex) {\n\t\t\tthrow convertException(ex as ConvertException, path, 'openFile');\n\t\t}\n\t}\n\n\tpublic async unlink(path: string): Promise<void> {\n\t\tconst handle = await this.getHandle(dirname(path));\n\t\tif (handle instanceof FileSystemDirectoryHandle) {\n\t\t\ttry {\n\t\t\t\tawait handle.removeEntry(basename(path), { recursive: true });\n\t\t\t} catch (ex) {\n\t\t\t\tthrow convertException(ex as ConvertException, path, 'unlink');\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic async link(srcpath: string): Promise<void> {\n\t\tthrow ErrnoError.With('ENOSYS', srcpath, 'WebAccessFS.link');\n\t}\n\n\tpublic async rmdir(path: string): Promise<void> {\n\t\treturn this.unlink(path);\n\t}\n\n\tpublic async mkdir(path: string): Promise<void> {\n\t\tconst existingHandle = await this.getHandle(path);\n\t\tif (existingHandle) {\n\t\t\tthrow ErrnoError.With('EEXIST', path, 'mkdir');\n\t\t}\n\n\t\tconst handle = await this.getHandle(dirname(path));\n\t\tif (!(handle instanceof FileSystemDirectoryHandle)) {\n\t\t\tthrow ErrnoError.With('ENOTDIR', path, 'mkdir');\n\t\t}\n\t\tawait handle.getDirectoryHandle(basename(path), { create: true });\n\t}\n\n\tpublic async readdir(path: string): Promise<string[]> {\n\t\tconst handle = await this.getHandle(path);\n\t\tif (!(handle instanceof FileSystemDirectoryHandle)) {\n\t\t\tthrow ErrnoError.With('ENOTDIR', path, 'readdir');\n\t\t}\n\t\tconst keys: string[] = [];\n\t\tfor await (const key of handle.keys()) {\n\t\t\tkeys.push(key);\n\t\t}\n\t\treturn keys;\n\t}\n\n\tprotected async getHandle(path: string): Promise<FileSystemHandle> {\n\t\tif (this._handles.has(path)) {\n\t\t\treturn this._handles.get(path)!;\n\t\t}\n\n\t\tlet walked = '/';\n\n\t\tfor (const part of path.split('/').slice(1)) {\n\t\t\tconst handle = this._handles.get(walked);\n\t\t\tif (!(handle instanceof FileSystemDirectoryHandle)) {\n\t\t\t\tthrow ErrnoError.With('ENOTDIR', walked, 'getHandle');\n\t\t\t}\n\t\t\twalked = join(walked, part);\n\n\t\t\ttry {\n\t\t\t\tconst dirHandle = await handle.getDirectoryHandle(part);\n\t\t\t\tthis._handles.set(walked, dirHandle);\n\t\t\t} catch (_ex) {\n\t\t\t\tconst ex = _ex as DOMException;\n\t\t\t\tif (ex.name == 'TypeMismatchError') {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst fileHandle = await handle.getFileHandle(part);\n\t\t\t\t\t\tthis._handles.set(walked, fileHandle);\n\t\t\t\t\t} catch (ex) {\n\t\t\t\t\t\tconvertException(ex as ConvertException, walked, 'getHandle');\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (ex.name === 'TypeError') {\n\t\t\t\t\tthrow new ErrnoError(Errno.ENOENT, ex.message, walked, 'getHandle');\n\t\t\t\t}\n\n\t\t\t\tconvertException(ex, walked, 'getHandle');\n\t\t\t}\n\t\t}\n\n\t\treturn this._handles.get(path)!;\n\t}\n}\n\nexport const WebAccess = {\n\tname: 'WebAccess',\n\n\toptions: {\n\t\thandle: {\n\t\t\ttype: 'object',\n\t\t\trequired: true,\n\t\t\tdescription: 'The directory handle to use for the root',\n\t\t},\n\t},\n\n\tisAvailable(): boolean {\n\t\treturn typeof FileSystemHandle == 'function';\n\t},\n\n\tcreate(options: WebAccessOptions) {\n\t\treturn new WebAccessFS(options.handle);\n\t},\n} as const satisfies Backend<WebAccessFS, WebAccessOptions>;\n", "/**\n * Standard libc error codes. More will be added to this enum and error strings as they are\n * needed.\n * @see https://en.wikipedia.org/wiki/Errno.h\n */\nexport var Errno;\n(function (Errno) {\n /** Operation not permitted */\n Errno[Errno[\"EPERM\"] = 1] = \"EPERM\";\n /** No such file or directory */\n Errno[Errno[\"ENOENT\"] = 2] = \"ENOENT\";\n /** Interrupted system call */\n Errno[Errno[\"EINTR\"] = 4] = \"EINTR\";\n /** Input/output error */\n Errno[Errno[\"EIO\"] = 5] = \"EIO\";\n /** No such device or address */\n Errno[Errno[\"ENXIO\"] = 6] = \"ENXIO\";\n /** Bad file descriptor */\n Errno[Errno[\"EBADF\"] = 9] = \"EBADF\";\n /** Resource temporarily unavailable */\n Errno[Errno[\"EAGAIN\"] = 11] = \"EAGAIN\";\n /** Cannot allocate memory */\n Errno[Errno[\"ENOMEM\"] = 12] = \"ENOMEM\";\n /** Permission denied */\n Errno[Errno[\"EACCES\"] = 13] = \"EACCES\";\n /** Bad address */\n Errno[Errno[\"EFAULT\"] = 14] = \"EFAULT\";\n /** Block device required */\n Errno[Errno[\"ENOTBLK\"] = 15] = \"ENOTBLK\";\n /** Resource busy or locked */\n Errno[Errno[\"EBUSY\"] = 16] = \"EBUSY\";\n /** File exists */\n Errno[Errno[\"EEXIST\"] = 17] = \"EEXIST\";\n /** Invalid cross-device link */\n Errno[Errno[\"EXDEV\"] = 18] = \"EXDEV\";\n /** No such device */\n Errno[Errno[\"ENODEV\"] = 19] = \"ENODEV\";\n /** File is not a directory */\n Errno[Errno[\"ENOTDIR\"] = 20] = \"ENOTDIR\";\n /** File is a directory */\n Errno[Errno[\"EISDIR\"] = 21] = \"EISDIR\";\n /** Invalid argument */\n Errno[Errno[\"EINVAL\"] = 22] = \"EINVAL\";\n /** Too many open files in system */\n Errno[Errno[\"ENFILE\"] = 23] = \"ENFILE\";\n /** Too many open files */\n Errno[Errno[\"EMFILE\"] = 24] = \"EMFILE\";\n /** Text file busy */\n Errno[Errno[\"ETXTBSY\"] = 26] = \"ETXTBSY\";\n /** File is too big */\n Errno[Errno[\"EFBIG\"] = 27] = \"EFBIG\";\n /** No space left on disk */\n Errno[Errno[\"ENOSPC\"] = 28] = \"ENOSPC\";\n /** Illegal seek */\n Errno[Errno[\"ESPIPE\"] = 29] = \"ESPIPE\";\n /** Cannot modify a read-only file system */\n Errno[Errno[\"EROFS\"] = 30] = \"EROFS\";\n /** Too many links */\n Errno[Errno[\"EMLINK\"] = 31] = \"EMLINK\";\n /** Broken pipe */\n Errno[Errno[\"EPIPE\"] = 32] = \"EPIPE\";\n /** Numerical argument out of domain */\n Errno[Errno[\"EDOM\"] = 33] = \"EDOM\";\n /** Numerical result out of range */\n Errno[Errno[\"ERANGE\"] = 34] = \"ERANGE\";\n /** Resource deadlock would occur */\n Errno[Errno[\"EDEADLK\"] = 35] = \"EDEADLK\";\n /** File name too long */\n Errno[Errno[\"ENAMETOOLONG\"] = 36] = \"ENAMETOOLONG\";\n /** No locks available */\n Errno[Errno[\"ENOLCK\"] = 37] = \"ENOLCK\";\n /** Function not implemented */\n Errno[Errno[\"ENOSYS\"] = 38] = \"ENOSYS\";\n /** Directory is not empty */\n Errno[Errno[\"ENOTEMPTY\"] = 39] = \"ENOTEMPTY\";\n /** Too many levels of symbolic links */\n Errno[Errno[\"ELOOP\"] = 40] = \"ELOOP\";\n /** No message of desired type */\n Errno[Errno[\"ENOMSG\"] = 42] = \"ENOMSG\";\n /** Invalid exchange */\n Errno[Errno[\"EBADE\"] = 52] = \"EBADE\";\n /** Invalid request descriptor */\n Errno[Errno[\"EBADR\"] = 53] = \"EBADR\";\n /** Exchange full */\n Errno[Errno[\"EXFULL\"] = 54] = \"EXFULL\";\n /** No anode */\n Errno[Errno[\"ENOANO\"] = 55] = \"ENOANO\";\n /** Invalid request code */\n Errno[Errno[\"EBADRQC\"] = 56] = \"EBADRQC\";\n /** Device not a stream */\n Errno[Errno[\"ENOSTR\"] = 60] = \"ENOSTR\";\n /** No data available */\n Errno[Errno[\"ENODATA\"] = 61] = \"ENODATA\";\n /** Timer expired */\n Errno[Errno[\"ETIME\"] = 62] = \"ETIME\";\n /** Out of streams resources */\n Errno[Errno[\"ENOSR\"] = 63] = \"ENOSR\";\n /** Machine is not on the network */\n Errno[Errno[\"ENONET\"] = 64] = \"ENONET\";\n /** Object is remote */\n Errno[Errno[\"EREMOTE\"] = 66] = \"EREMOTE\";\n /** Link has been severed */\n Errno[Errno[\"ENOLINK\"] = 67] = \"ENOLINK\";\n /** Communication error on send */\n Errno[Errno[\"ECOMM\"] = 70] = \"ECOMM\";\n /** Protocol error */\n Errno[Errno[\"EPROTO\"] = 71] = \"EPROTO\";\n /** Bad message */\n Errno[Errno[\"EBADMSG\"] = 74] = \"EBADMSG\";\n /** Value too large for defined data type */\n Errno[Errno[\"EOVERFLOW\"] = 75] = \"EOVERFLOW\";\n /** File descriptor in bad state */\n Errno[Errno[\"EBADFD\"] = 77] = \"EBADFD\";\n /** Streams pipe error */\n Errno[Errno[\"ESTRPIPE\"] = 86] = \"ESTRPIPE\";\n /** Socket operation on non-socket */\n Errno[Errno[\"ENOTSOCK\"] = 88] = \"ENOTSOCK\";\n /** Destination address required */\n Errno[Errno[\"EDESTADDRREQ\"] = 89] = \"EDESTADDRREQ\";\n /** Message too long */\n Errno[Errno[\"EMSGSIZE\"] = 90] = \"EMSGSIZE\";\n /** Protocol wrong type for socket */\n Errno[Errno[\"EPROTOTYPE\"] = 91] = \"EPROTOTYPE\";\n /** Protocol not available */\n Errno[Errno[\"ENOPROTOOPT\"] = 92] = \"ENOPROTOOPT\";\n /** Protocol not supported */\n Errno[Errno[\"EPROTONOSUPPORT\"] = 93] = \"EPROTONOSUPPORT\";\n /** Socket type not supported */\n Errno[Errno[\"ESOCKTNOSUPPORT\"] = 94] = \"ESOCKTNOSUPPORT\";\n /** Operation is not supported */\n Errno[Errno[\"ENOTSUP\"] = 95] = \"ENOTSUP\";\n /** Network is down */\n Errno[Errno[\"ENETDOWN\"] = 100] = \"ENETDOWN\";\n /** Network is unreachable */\n Errno[Errno[\"ENETUNREACH\"] = 101] = \"ENETUNREACH\";\n /** Network dropped connection on reset */\n Errno[Errno[\"ENETRESET\"] = 102] = \"ENETRESET\";\n /** Connection timed out */\n Errno[Errno[\"ETIMEDOUT\"] = 110] = \"ETIMEDOUT\";\n /** Connection refused */\n Errno[Errno[\"ECONNREFUSED\"] = 111] = \"ECONNREFUSED\";\n /** Host is down */\n Errno[Errno[\"EHOSTDOWN\"] = 112] = \"EHOSTDOWN\";\n /** No route to host */\n Errno[Errno[\"EHOSTUNREACH\"] = 113] = \"EHOSTUNREACH\";\n /** Operation already in progress */\n Errno[Errno[\"EALREADY\"] = 114] = \"EALREADY\";\n /** Operation now in progress */\n Errno[Errno[\"EINPROGRESS\"] = 115] = \"EINPROGRESS\";\n /** Stale file handle */\n Errno[Errno[\"ESTALE\"] = 116] = \"ESTALE\";\n /** Remote I/O error */\n Errno[Errno[\"EREMOTEIO\"] = 121] = \"EREMOTEIO\";\n /** Disk quota exceeded */\n Errno[Errno[\"EDQUOT\"] = 122] = \"EDQUOT\";\n})(Errno || (Errno = {}));\n/**\n * Strings associated with each error code.\n * @internal\n */\nexport const errorMessages = {\n [Errno.EPERM]: 'Operation not permitted',\n [Errno.ENOENT]: 'No such file or directory',\n [Errno.EINTR]: 'Interrupted system call',\n [Errno.EIO]: 'Input/output error',\n [Errno.ENXIO]: 'No such device or address',\n [Errno.EBADF]: 'Bad file descriptor',\n [Errno.EAGAIN]: 'Resource temporarily unavailable',\n [Errno.ENOMEM]: 'Cannot allocate memory',\n [Errno.EACCES]: 'Permission denied',\n [Errno.EFAULT]: 'Bad address',\n [Errno.ENOTBLK]: 'Block device required',\n [Errno.EBUSY]: 'Resource busy or locked',\n [Errno.EEXIST]: 'File exists',\n [Errno.EXDEV]: 'Invalid cross-device link',\n [Errno.ENODEV]: 'No such device',\n [Errno.ENOTDIR]: 'File is not a directory',\n [Errno.EISDIR]: 'File is a directory',\n [Errno.EINVAL]: 'Invalid argument',\n [Errno.ENFILE]: 'Too many open files in system',\n [Errno.EMFILE]: 'Too many open files',\n [Errno.ETXTBSY]: 'Text file busy',\n [Errno.EFBIG]: 'File is too big',\n [Errno.ENOSPC]: 'No space left on disk',\n [Errno.ESPIPE]: 'Illegal seek',\n [Errno.EROFS]: 'Cannot modify a read-only file system',\n [Errno.EMLINK]: 'Too many links',\n [Errno.EPIPE]: 'Broken pipe',\n [Errno.EDOM]: 'Numerical argument out of domain',\n [Errno.ERANGE]: 'Numerical result out of range',\n [Errno.EDEADLK]: 'Resource deadlock would occur',\n [Errno.ENAMETOOLONG]: 'File name too long',\n [Errno.ENOLCK]: 'No locks available',\n [Errno.ENOSYS]: 'Function not implemented',\n [Errno.ENOTEMPTY]: 'Directory is not empty',\n [Errno.ELOOP]: 'Too many levels of symbolic links',\n [Errno.ENOMSG]: 'No message of desired type',\n [Errno.EBADE]: 'Invalid exchange',\n [Errno.EBADR]: 'Invalid request descriptor',\n [Errno.EXFULL]: 'Exchange full',\n [Errno.ENOANO]: 'No anode',\n [Errno.EBADRQC]: 'Invalid request code',\n [Errno.ENOSTR]: 'Device not a stream',\n [Errno.ENODATA]: 'No data available',\n [Errno.ETIME]: 'Timer expired',\n [Errno.ENOSR]: 'Out of streams resources',\n [Errno.ENONET]: 'Machine is not on the network',\n [Errno.EREMOTE]: 'Object is remote',\n [Errno.ENOLINK]: 'Link has been severed',\n [Errno.ECOMM]: 'Communication error on send',\n [Errno.EPROTO]: 'Protocol error',\n [Errno.EBADMSG]: 'Bad message',\n [Errno.EOVERFLOW]: 'Value too large for defined data type',\n [Errno.EBADFD]: 'File descriptor in bad state',\n [Errno.ESTRPIPE]: 'Streams pipe error',\n [Errno.ENOTSOCK]: 'Socket operation on non-socket',\n [Errno.EDESTADDRREQ]: 'Destination address required',\n [Errno.EMSGSIZE]: 'Message too long',\n [Errno.EPROTOTYPE]: 'Protocol wrong type for socket',\n [Errno.ENOPROTOOPT]: 'Protocol not available',\n [Errno.EPROTONOSUPPORT]: 'Protocol not supported',\n [Errno.ESOCKTNOSUPPORT]: 'Socket type not supported',\n [Errno.ENOTSUP]: 'Operation is not supported',\n [Errno.ENETDOWN]: 'Network is down',\n [Errno.ENETUNREACH]: 'Network is unreachable',\n [Errno.ENETRESET]: 'Network dropped connection on reset',\n [Errno.ETIMEDOUT]: 'Connection timed out',\n [Errno.ECONNREFUSED]: 'Connection refused',\n [Errno.EHOSTDOWN]: 'Host is down',\n [Errno.EHOSTUNREACH]: 'No route to host',\n [Errno.EALREADY]: 'Operation already in progress',\n [Errno.EINPROGRESS]: 'Operation now in progress',\n [Errno.ESTALE]: 'Stale file handle',\n [Errno.EREMOTEIO]: 'Remote I/O error',\n [Errno.EDQUOT]: 'Disk quota exceeded',\n};\n/**\n * Represents a ZenFS error. Passed back to applications after a failed\n * call to the ZenFS API.\n */\nexport class ErrnoError extends Error {\n static fromJSON(json) {\n const err = new ErrnoError(json.errno, json.message, json.path, json.syscall);\n err.code = json.code;\n err.stack = json.stack;\n return err;\n }\n static With(code, path, syscall) {\n return new ErrnoError(Errno[code], errorMessages[Errno[code]], path, syscall);\n }\n /**\n * Represents a ZenFS error. Passed back to applications after a failed\n * call to the ZenFS API.\n *\n * Error codes mirror those returned by regular Unix file operations, which is\n * what Node returns.\n * @param type The type of the error.\n * @param message A descriptive error message.\n */\n constructor(errno, message = errorMessages[errno], path, syscall = '') {\n super(message);\n this.errno = errno;\n this.path = path;\n this.syscall = syscall;\n this.code = Errno[errno];\n this.message = `${this.code}: ${message}${this.path ? `, '${this.path}'` : ''}`;\n }\n /**\n * @return A friendly error message.\n */\n toString() {\n return this.message;\n }\n toJSON() {\n return {\n errno: this.errno,\n code: this.code,\n path: this.path,\n stack: this.stack,\n message: this.message,\n syscall: this.syscall,\n };\n }\n /**\n * The size of the API error in buffer-form in bytes.\n */\n bufferSize() {\n // 4 bytes for string length.\n return 4 + JSON.stringify(this.toJSON()).length;\n }\n}\n", "import { ErrnoError } from '../../error.js';\n/**\n * A transaction for a store.\n */\nexport class Transaction {\n constructor(store) {\n this.store = store;\n this.aborted = false;\n }\n async [Symbol.asyncDispose]() {\n if (this.aborted) {\n return;\n }\n await this.commit();\n }\n [Symbol.dispose]() {\n if (this.aborted) {\n return;\n }\n this.commitSync();\n }\n}\n/**\n * Transaction that implements asynchronous operations with synchronous ones\n */\nexport class SyncTransaction extends Transaction {\n async get(ino) {\n return this.getSync(ino);\n }\n async set(ino, data) {\n return this.setSync(ino, data);\n }\n async remove(ino) {\n return this.removeSync(ino);\n }\n async commit() {\n return this.commitSync();\n }\n async abort() {\n return this.abortSync();\n }\n}\n/**\n * Transaction that only supports asynchronous operations\n */\nexport class AsyncTransaction extends Transaction {\n getSync() {\n throw ErrnoError.With('ENOSYS', undefined, 'AsyncTransaction.getSync');\n }\n setSync() {\n throw ErrnoError.With('ENOSYS', undefined, 'AsyncTransaction.setSync');\n }\n removeSync() {\n throw ErrnoError.With('ENOSYS', undefined, 'AsyncTransaction.removeSync');\n }\n commitSync() {\n throw ErrnoError.With('ENOSYS', undefined, 'AsyncTransaction.commitSync');\n }\n abortSync() {\n throw ErrnoError.With('ENOSYS', undefined, 'AsyncTransaction.abortSync');\n }\n}\n", "import type { Store } from '@zenfs/core/backends/store/store.js';\nimport { AsyncTransaction } from '@zenfs/core/backends/store/store.js';\nimport type { Backend, Ino, SharedConfig } from '@zenfs/core';\nimport { Async, ErrnoError, InMemory, StoreFS } from '@zenfs/core';\nimport { convertException, type ConvertException } from './utils.js';\n\nfunction wrap<T>(request: IDBRequest<T>): Promise<T> {\n\treturn new Promise((resolve, reject) => {\n\t\trequest.onsuccess = () => resolve(request.result);\n\t\trequest.onerror = e => {\n\t\t\te.preventDefault();\n\t\t\treject(convertException(request.error!));\n\t\t};\n\t});\n}\n\n/**\n * @hidden\n */\nexport class IndexedDBTransaction extends AsyncTransaction<IndexedDBStore> {\n\tprivate _idb: IDBObjectStore;\n\n\tconstructor(\n\t\tpublic tx: IDBTransaction,\n\t\tpublic store: IndexedDBStore\n\t) {\n\t\tsuper(store);\n\t\tthis._idb = tx.objectStore(store.name);\n\t}\n\n\tpublic get(key: Ino): Promise<Uint8Array> {\n\t\treturn wrap(this._idb.get(key.toString()));\n\t}\n\n\tpublic async set(key: Ino, data: Uint8Array): Promise<void> {\n\t\tawait wrap(this._idb.put(data, key.toString()));\n\t}\n\n\tpublic remove(key: Ino): Promise<void> {\n\t\treturn wrap(this._idb.delete(key.toString()));\n\t}\n\n\tpublic async commit(): Promise<void> {\n\t\tthis.tx.commit();\n\t}\n\n\tpublic async abort(): Promise<void> {\n\t\ttry {\n\t\t\tthis.tx.abort();\n\t\t} catch (e) {\n\t\t\tthrow convertException(e as ConvertException);\n\t\t}\n\t}\n}\n\nasync function createDB(name: string, indexedDB: IDBFactory = globalThis.indexedDB): Promise<IDBDatabase> {\n\tconst req: IDBOpenDBRequest = indexedDB.open(name);\n\n\treq.onupgradeneeded = () => {\n\t\tconst db: IDBDatabase = req.result;\n\t\t// This should never happen; we're at version 1. Why does another database exist?\n\t\tif (db.objectStoreNames.contains(name)) {\n\t\t\tdb.deleteObjectStore(name);\n\t\t}\n\t\tdb.createObjectStore(name);\n\t};\n\n\tconst result = await wrap(req);\n\treturn result;\n}\n\nexport class IndexedDBStore implements Store {\n\tpublic constructor(protected db: IDBDatabase) {}\n\n\tpublic sync(): Promise<void> {\n\t\tthrow new Error('Method not implemented.');\n\t}\n\n\tpublic get name(): string {\n\t\treturn this.db.name;\n\t}\n\n\tpublic clear(): Promise<void> {\n\t\treturn wrap(this.db.transaction(this.name, 'readwrite').objectStore(this.name).clear());\n\t}\n\n\tpublic clearSync(): void {\n\t\tthrow ErrnoError.With('ENOSYS', undefined, 'IndexedDBStore.clearSync');\n\t}\n\n\tpublic transaction(): IndexedDBTransaction {\n\t\tconst tx = this.db.transaction(this.name, 'readwrite');\n\t\treturn new IndexedDBTransaction(tx, this);\n\t}\n}\n\n/**\n * Configuration options for the IndexedDB file system.\n */\nexport interface IndexedDBOptions {\n\t/**\n\t * The name of this file system. You can have multiple IndexedDB file systems operating at once, but each must have a different name.\n\t */\n\tstoreName?: string;\n\n\t/**\n\t * The IDBFactory to use. Defaults to `globalThis.indexedDB`.\n\t */\n\tidbFactory?: IDBFactory;\n}\n\n/**\n * A file system that uses the IndexedDB key value file system.\n */\n\nexport const IndexedDB = {\n\tname: 'IndexedDB',\n\n\toptions: {\n\t\tstoreName: {\n\t\t\ttype: 'string',\n\t\t\trequired: false,\n\t\t\tdescription: 'The name of this file system. You can have multiple IndexedDB file systems operating at once, but each must have a different name.',\n\t\t},\n\t\tidbFactory: {\n\t\t\ttype: 'object',\n\t\t\trequired: false,\n\t\t\tdescription: 'The IDBFactory to use. Defaults to globalThis.indexedDB.',\n\t\t},\n\t},\n\n\tasync isAvailable(idbFactory: IDBFactory = globalThis.indexedDB): Promise<boolean> {\n\t\ttry {\n\t\t\tif (!(idbFactory instanceof IDBFactory)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tconst req = idbFactory.open('__zenfs_test');\n\t\t\tawait wrap(req);\n\t\t\tidbFactory.deleteDatabase('__zenfs_test');\n\t\t\treturn true;\n\t\t} catch (e) {\n\t\t\tidbFactory.deleteDatabase('__zenfs_test');\n\t\t\treturn false;\n\t\t}\n\t},\n\n\tasync create(options: IndexedDBOptions & Partial<SharedConfig>) {\n\t\tconst db = await createDB(options.storeName || 'zenfs', options.idbFactory);\n\t\tconst store = new IndexedDBStore(db);\n\t\tconst fs = new (Async(StoreFS))(store);\n\t\tif (!options?.disableAsyncCache) {\n\t\t\tfs._sync = InMemory.create({ name: 'idb-cache' });\n\t\t}\n\t\treturn fs;\n\t},\n} as const satisfies Backend<StoreFS, IndexedDBOptions>;\n", "import type { Backend, Ino, SimpleSyncStore, Store } from '@zenfs/core';\nimport { ErrnoError, Errno, SimpleTransaction, StoreFS, decode, encode } from '@zenfs/core';\n\n/**\n * A synchronous key-value store backed by Storage.\n */\nexport class WebStorageStore implements Store, SimpleSyncStore {\n\tpublic get name(): string {\n\t\treturn WebStorage.name;\n\t}\n\n\tconstructor(protected _storage: Storage) {}\n\n\tpublic clear(): void {\n\t\tthis._storage.clear();\n\t}\n\n\tpublic clearSync(): void {\n\t\tthis._storage.clear();\n\t}\n\n\tpublic async sync(): Promise<void> {}\n\n\tpublic transaction(): SimpleTransaction {\n\t\t// No need to differentiate.\n\t\treturn new SimpleTransaction(this);\n\t}\n\n\tpublic get(key: Ino): Uint8Array | undefined {\n\t\tconst data = this._storage.getItem(key.toString());\n\t\tif (typeof data != 'string') {\n\t\t\treturn;\n\t\t}\n\n\t\treturn encode(data);\n\t}\n\n\tpublic set(key: Ino, data: Uint8Array): void {\n\t\ttry {\n\t\t\tthis._storage.setItem(key.toString(), decode(data));\n\t\t} catch (e) {\n\t\t\tthrow new ErrnoError(Errno.ENOSPC, 'Storage is full.');\n\t\t}\n\t}\n\n\tpublic delete(key: Ino): void {\n\t\ttry {\n\t\t\tthis._storage.removeItem(key.toString());\n\t\t} catch (e) {\n\t\t\tthrow new ErrnoError(Errno.EIO, 'Unable to delete key ' + key + ': ' + e);\n\t\t}\n\t}\n}\n\n/**\n * Options to pass to the StorageFileSystem\n */\nexport interface WebStorageOptions {\n\t/**\n\t * The Storage to use. Defaults to globalThis.localStorage.\n\t */\n\tstorage?: Storage;\n}\n\n/**\n * A synchronous file system backed by a `Storage` (e.g. localStorage).\n */\nexport const WebStorage = {\n\tname: 'WebStorage',\n\n\toptions: {\n\t\tstorage: {\n\t\t\ttype: 'object',\n\t\t\trequired: false,\n\t\t\tdescription: 'The Storage to use. Defaults to globalThis.localStorage.',\n\t\t},\n\t},\n\n\tisAvailable(storage: Storage = globalThis.localStorage): boolean {\n\t\treturn storage instanceof globalThis.Storage;\n\t},\n\n\tcreate({ storage = globalThis.localStorage }: WebStorageOptions) {\n\t\treturn new StoreFS(new WebStorageStore(storage));\n\t},\n} as const satisfies Backend<StoreFS, WebStorageOptions>;\n"],
5
- "mappings": "gfAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,eAAAE,EAAA,mBAAAC,EAAA,yBAAAC,EAAA,cAAAC,EAAA,gBAAAC,EAAA,eAAAC,EAAA,oBAAAC,ICAA,IAAOC,GAAQ,MACT,CAAE,MAAAC,EAAO,iBAAAC,GAAkB,YAAAC,GAAa,cAAAC,GAAe,IAAAC,GAAK,OAAAC,GAAQ,MAAAC,EAAO,WAAAC,EAAY,MAAAC,GAAO,QAAAC,GAAS,KAAAC,GAAM,WAAAC,EAAY,SAAAC,GAAU,SAAAC,EAAU,cAAAC,GAAe,QAAAC,GAAS,MAAAC,GAAO,SAAAC,GAAU,MAAAC,GAAO,WAAAC,GAAY,QAAAC,GAAS,UAAAC,GAAW,KAAAC,GAAM,OAAAC,GAAQ,SAAAC,GAAU,YAAAC,EAAa,WAAAC,GAAY,SAAAC,GAAU,iBAAAC,GAAkB,kBAAAC,EAAmB,MAAAC,EAAO,YAAAC,GAAa,QAAAC,GAAS,QAAAC,EAAS,KAAAC,GAAM,gBAAAC,GAAiB,YAAAC,GAAa,kBAAAC,GAAmB,YAAAC,GAAa,UAAAC,GAAW,iBAAAC,GAAkB,OAAAC,GAAQ,WAAAC,GAAY,WAAAC,GAAY,eAAAC,GAAgB,SAAAC,GAAU,aAAAC,GAAc,MAAAC,GAAO,UAAAC,GAAW,MAAA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,MAAa,MAAsB,CAAC,CAE7B,aAAiC,CAEvC,OAAO,IAAIC,EAAkB,IAAI,CAClC,CAEO,IAAIC,EAAkC,CAC5C,IAAMC,EAAO,KAAK,SAAS,QAAQD,EAAI,SAAS,CAAC,EACjD,GAAI,OAAOC,GAAQ,SAInB,OAAOC,EAAOD,CAAI,CACnB,CAEO,IAAID,EAAUC,EAAwB,CAC5C,GAAI,CACH,KAAK,SAAS,QAAQD,EAAI,SAAS,EAAGG,EAAOF,CAAI,CAAC,CACnD,MAAE,CACD,MAAM,IAAIG,EAAWC,EAAM,OAAQ,kBAAkB,CACtD,CACD,CAEO,OAAOL,EAAgB,CAC7B,GAAI,CACH,KAAK,SAAS,WAAWA,EAAI,SAAS,CAAC,CACxC,OAASM,EAAP,CACD,MAAM,IAAIF,EAAWC,EAAM,IAAK,wBAA0BL,EAAM,KAAOM,CAAC,CACzE,CACD,CACD,EA9CaC,EAAAX,EAAA,mBA6DN,IAAME,EAAa,CACzB,KAAM,aAEN,QAAS,CACR,QAAS,CACR,KAAM,SACN,SAAU,GACV,YAAa,0DACd,CACD,EAEA,YAAYU,EAAmB,WAAW,aAAuB,CAChE,OAAOA,aAAmB,WAAW,OACtC,EAEA,OAAO,CAAE,QAAAA,EAAU,WAAW,YAAa,EAAsB,CAChE,OAAO,IAAIC,EAAQ,IAAIb,EAAgBY,CAAO,CAAC,CAChD,CACD",
6
- "names": ["src_exports", "__export", "IndexedDB", "IndexedDBStore", "IndexedDBTransaction", "WebAccess", "WebAccessFS", "WebStorage", "WebStorageStore", "core_default", "Async", "AsyncTransaction", "BigIntStats", "BigIntStatsFs", "Dir", "Dirent", "Errno", "ErrnoError", "Fetch", "FetchFS", "File", "FileSystem", "FileType", "InMemory", "InMemoryStore", "IndexFS", "Inode", "LockedFS", "Mutex", "NoSyncFile", "Overlay", "OverlayFS", "Port", "PortFS", "PortFile", "PreloadFile", "ReadStream", "Readonly", "SimpleAsyncStore", "SimpleTransaction", "Stats", "StatsCommon", "StatsFs", "StoreFS", "Sync", "SyncTransaction", "Transaction", "UnlockedOverlayFS", "WriteStream", "ZenFsType", "_toUnixTimestamp", "access", "accessSync", "appendFile", "appendFileSync", "attachFS", "checkOptions", "chmod", "chmodSync", "chown", "chownSync", "close", "closeSync", "configure", "constants", "copyFile", "copyFileSync", "cp", "cpSync", "createReadStream", "createWriteStream", "decode", "decodeDirListing", "detachFS", "encode", "encodeDirListing", "errorMessages", "exists", "existsSync", "fchmod", "fchmodSync", "fchown", "fchownSync", "fdatasync", "fdatasyncSync", "flagToMode", "flagToNumber", "flagToString", "fs", "fstat", "fstatSync", "fsync", "fsyncSync", "ftruncate", "ftruncateSync", "futimes", "futimesSync", "isAppendable", "isBackend", "isBackendConfig", "isExclusive", "isReadable", "isSynchronous", "isTruncating", "isWriteable", "lchmod", "lchmodSync", "lchown", "lchownSync", "levenshtein", "link", "linkSync", "lopenSync", "lstat", "lstatSync", "lutimes", "lutimesSync", "mkdir", "mkdirSync", "mkdirpSync", "mkdtemp", "mkdtempSync", "mount", "mountObject", "mounts", "nop", "normalizeMode", "normalizeOptions", "normalizePath", "normalizeTime", "open", "openAsBlob", "openSync", "opendir", "opendirSync", "parseFlag", "promises", "randomIno", "read", "readFile", "readFileSync", "readSync", "readdir", "readdirSync", "readlink", "readlinkSync", "readv", "readvSync", "realpath", "realpathSync", "rename", "renameSync", "resolveMountConfig", "rm", "rmSync", "rmdir", "rmdirSync", "rootCred", "rootIno", "setImmediate", "size_max", "stat", "statSync", "statfs", "statfsSync", "symlink", "symlinkSync", "truncate", "truncateSync", "umount", "unlink", "unlinkSync", "unwatchFile", "utimes", "utimesSync", "watch", "watchFile", "write", "writeFile", "writeFileSync", "writeSync", "writev", "writevSync", "normalizeString", "path", "allowAboveRoot", "res", "lastSegmentLength", "lastSlash", "dots", "char", "i", "lastSlashIndex", "__name", "normalize", "path", "isAbsolute", "trailingSeparator", "normalizeString", "__name", "join", "parts", "joined", "normalize", "__name", "dirname", "path", "hasRoot", "end", "matchedSlash", "i", "__name", "basename", "suffix", "start", "extIdx", "firstNonSlashEnd", "errnoForDOMException", "ex", "__name", "convertException", "path", "syscall", "ErrnoError", "code", "Errno", "error", "WebAccessFS", "Async", "FileSystem", "InMemory", "handle", "path", "data", "stats", "currentStats", "oldPath", "newPath", "files", "file", "join", "oldFile", "destFolder", "dirname", "writable", "basename", "ex", "convertException", "ErrnoError", "Errno", "flag", "Stats", "lastModified", "size", "PreloadFile", "srcpath", "keys", "key", "walked", "part", "dirHandle", "_ex", "fileHandle", "__name", "WebAccess", "options", "Errno", "errorMessages", "ErrnoError", "json", "err", "code", "path", "syscall", "errno", "message", "__name", "Transaction", "store", "__name", "AsyncTransaction", "Transaction", "ErrnoError", "__name", "wrap", "request", "resolve", "reject", "e", "convertException", "__name", "IndexedDBTransaction", "AsyncTransaction", "tx", "store", "key", "data", "createDB", "name", "indexedDB", "req", "db", "IndexedDBStore", "ErrnoError", "IndexedDB", "idbFactory", "options", "fs", "Async", "StoreFS", "InMemory", "WebStorageStore", "_storage", "WebStorage", "SimpleTransaction", "key", "data", "encode", "decode", "ErrnoError", "Errno", "e", "__name", "storage", "StoreFS"]
3
+ "sources": ["../src/index.ts", "global-externals:@zenfs/core", "../node_modules/@zenfs/core/dist/emulation/path.js", "../src/utils.ts", "../src/access.ts", "../node_modules/@zenfs/core/dist/error.js", "../node_modules/@zenfs/core/dist/polyfills.js", "../node_modules/@zenfs/core/dist/backends/store/store.js", "../src/IndexedDB.ts", "../src/Storage.ts"],
4
+ "sourcesContent": ["export * from './access.js';\nexport * from './IndexedDB.js';\nexport * from './Storage.js';\n", "export default ZenFS;\nconst { Async, AsyncTransaction, BigIntStats, BigIntStatsFs, Dir, Dirent, Errno, ErrnoError, Fetch, FetchFS, File, FileSystem, InMemory, InMemoryStore, Index, IndexFS, Inode, MutexLock, Mutexed, NoSyncFile, Overlay, OverlayFS, Port, PortFS, PortFile, PreloadFile, ReadStream, Readonly, SimpleAsyncStore, SimpleTransaction, Stats, StatsCommon, StatsFs, StoreFS, Sync, SyncTransaction, Transaction, UnmutexedOverlayFS, WriteStream, ZenFsType, _InMemory, _Port, _toUnixTimestamp, access, accessSync, appendFile, appendFileSync, attachFS, checkOptions, chmod, chmodSync, chown, chownSync, close, closeSync, configure, configureSingle, constants, copyFile, copyFileSync, cp, cpSync, createReadStream, createWriteStream, decode, decodeDirListing, detachFS, encode, encodeDirListing, errorMessages, exists, existsSync, fchmod, fchmodSync, fchown, fchownSync, fdatasync, fdatasyncSync, flagToMode, flagToNumber, flagToString, fs, fstat, fstatSync, fsync, fsyncSync, ftruncate, ftruncateSync, futimes, futimesSync, handleRequest, isAppendable, isBackend, isBackendConfig, isExclusive, isReadable, isSynchronous, isTruncating, isWriteable, lchmod, lchmodSync, lchown, lchownSync, levenshtein, link, linkSync, lopenSync, lstat, lstatSync, lutimes, lutimesSync, mkdir, mkdirSync, mkdirpSync, mkdtemp, mkdtempSync, mount, mountObject, mounts, normalizeMode, normalizeOptions, normalizePath, normalizeTime, open, openAsBlob, openSync, opendir, opendirSync, parseFlag, promises, randomIno, read, readFile, readFileSync, readSync, readdir, readdirSync, readlink, readlinkSync, readv, readvSync, realpath, realpathSync, rename, renameSync, resolveMountConfig, resolveRemoteMount, rm, rmSync, rmdir, rmdirSync, rootCred, rootIno, setImmediate, size_max, stat, statSync, statfs, statfsSync, symlink, symlinkSync, truncate, truncateSync, umount, unlink, unlinkSync, unwatchFile, utimes, utimesSync, version, watch, watchFile, write, writeFile, writeFileSync, writeSync, writev, writevSync } = ZenFS;\nexport { Async, AsyncTransaction, BigIntStats, BigIntStatsFs, Dir, Dirent, Errno, ErrnoError, Fetch, FetchFS, File, FileSystem, InMemory, InMemoryStore, Index, IndexFS, Inode, MutexLock, Mutexed, NoSyncFile, Overlay, OverlayFS, Port, PortFS, PortFile, PreloadFile, ReadStream, Readonly, SimpleAsyncStore, SimpleTransaction, Stats, StatsCommon, StatsFs, StoreFS, Sync, SyncTransaction, Transaction, UnmutexedOverlayFS, WriteStream, ZenFsType, _InMemory, _Port, _toUnixTimestamp, access, accessSync, appendFile, appendFileSync, attachFS, checkOptions, chmod, chmodSync, chown, chownSync, close, closeSync, configure, configureSingle, constants, copyFile, copyFileSync, cp, cpSync, createReadStream, createWriteStream, decode, decodeDirListing, detachFS, encode, encodeDirListing, errorMessages, exists, existsSync, fchmod, fchmodSync, fchown, fchownSync, fdatasync, fdatasyncSync, flagToMode, flagToNumber, flagToString, fs, fstat, fstatSync, fsync, fsyncSync, ftruncate, ftruncateSync, futimes, futimesSync, handleRequest, isAppendable, isBackend, isBackendConfig, isExclusive, isReadable, isSynchronous, isTruncating, isWriteable, lchmod, lchmodSync, lchown, lchownSync, levenshtein, link, linkSync, lopenSync, lstat, lstatSync, lutimes, lutimesSync, mkdir, mkdirSync, mkdirpSync, mkdtemp, mkdtempSync, mount, mountObject, mounts, normalizeMode, normalizeOptions, normalizePath, normalizeTime, open, openAsBlob, openSync, opendir, opendirSync, parseFlag, promises, randomIno, read, readFile, readFileSync, readSync, readdir, readdirSync, readlink, readlinkSync, readv, readvSync, realpath, realpathSync, rename, renameSync, resolveMountConfig, resolveRemoteMount, rm, rmSync, rmdir, rmdirSync, rootCred, rootIno, setImmediate, size_max, stat, statSync, statfs, statfsSync, symlink, symlinkSync, truncate, truncateSync, umount, unlink, unlinkSync, unwatchFile, utimes, utimesSync, version, watch, watchFile, write, writeFile, writeFileSync, writeSync, writev, writevSync };", "/*\nCopyright Joyent, Inc. and other Node contributors.\n\nPermission is hereby granted, free of charge, to any person obtaining a\ncopy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to permit\npersons to whom the Software is furnished to do so, subject to the\nfollowing conditions:\n\nThe above copyright notice and this permission notice shall be included\nin all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\nOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\nNO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\nDAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\nOTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\nUSE OR OTHER DEALINGS IN THE SOFTWARE.\n*/\nexport let cwd = '/';\nexport function cd(path) {\n cwd = resolve(cwd, path);\n}\nexport const sep = '/';\nfunction validateObject(str, name) {\n if (typeof str != 'object') {\n throw new TypeError(`\"${name}\" is not an object`);\n }\n}\n// Resolves . and .. elements in a path with directory names\nexport function normalizeString(path, allowAboveRoot) {\n let res = '';\n let lastSegmentLength = 0;\n let lastSlash = -1;\n let dots = 0;\n let char = '\\x00';\n for (let i = 0; i <= path.length; ++i) {\n if (i < path.length) {\n char = path[i];\n }\n else if (char == '/') {\n break;\n }\n else {\n char = '/';\n }\n if (char == '/') {\n if (lastSlash === i - 1 || dots === 1) {\n // NOOP\n }\n else if (dots === 2) {\n if (res.length < 2 || lastSegmentLength !== 2 || res.at(-1) !== '.' || res.at(-2) !== '.') {\n if (res.length > 2) {\n const lastSlashIndex = res.lastIndexOf('/');\n if (lastSlashIndex === -1) {\n res = '';\n lastSegmentLength = 0;\n }\n else {\n res = res.slice(0, lastSlashIndex);\n lastSegmentLength = res.length - 1 - res.lastIndexOf('/');\n }\n lastSlash = i;\n dots = 0;\n continue;\n }\n else if (res.length !== 0) {\n res = '';\n lastSegmentLength = 0;\n lastSlash = i;\n dots = 0;\n continue;\n }\n }\n if (allowAboveRoot) {\n res += res.length > 0 ? '/..' : '..';\n lastSegmentLength = 2;\n }\n }\n else {\n if (res.length > 0)\n res += '/' + path.slice(lastSlash + 1, i);\n else\n res = path.slice(lastSlash + 1, i);\n lastSegmentLength = i - lastSlash - 1;\n }\n lastSlash = i;\n dots = 0;\n }\n else if (char === '.' && dots !== -1) {\n ++dots;\n }\n else {\n dots = -1;\n }\n }\n return res;\n}\nexport function formatExt(ext) {\n return ext ? `${ext[0] === '.' ? '' : '.'}${ext}` : '';\n}\nexport function resolve(...parts) {\n let resolved = '';\n for (const part of [...parts.reverse(), cwd]) {\n if (!part.length) {\n continue;\n }\n resolved = `${part}/${resolved}`;\n if (part.startsWith('/')) {\n break;\n }\n }\n const absolute = resolved.startsWith('/');\n // At this point the path should be resolved to a full absolute path, but\n // handle relative paths to be safe (might happen when cwd fails)\n // Normalize the path\n resolved = normalizeString(resolved, !absolute);\n if (absolute) {\n return `/${resolved}`;\n }\n return resolved.length ? resolved : '/';\n}\nexport function normalize(path) {\n if (!path.length)\n return '.';\n const isAbsolute = path.startsWith('/');\n const trailingSeparator = path.endsWith('/');\n // Normalize the path\n path = normalizeString(path, !isAbsolute);\n if (!path.length) {\n if (isAbsolute)\n return '/';\n return trailingSeparator ? './' : '.';\n }\n if (trailingSeparator)\n path += '/';\n return isAbsolute ? `/${path}` : path;\n}\nexport function isAbsolute(path) {\n return path.startsWith('/');\n}\nexport function join(...parts) {\n if (!parts.length)\n return '.';\n const joined = parts.join('/');\n if (!joined?.length)\n return '.';\n return normalize(joined);\n}\nexport function relative(from, to) {\n if (from === to)\n return '';\n // Trim leading forward slashes.\n from = resolve(from);\n to = resolve(to);\n if (from === to)\n return '';\n const fromStart = 1;\n const fromEnd = from.length;\n const fromLen = fromEnd - fromStart;\n const toStart = 1;\n const toLen = to.length - toStart;\n // Compare paths to find the longest common path from root\n const length = fromLen < toLen ? fromLen : toLen;\n let lastCommonSep = -1;\n let i = 0;\n for (; i < length; i++) {\n const fromCode = from[fromStart + i];\n if (fromCode !== to[toStart + i])\n break;\n else if (fromCode === '/')\n lastCommonSep = i;\n }\n if (i === length) {\n if (toLen > length) {\n if (to[toStart + i] === '/') {\n // We get here if `from` is the exact base path for `to`.\n // For example: from='/foo/bar'; to='/foo/bar/baz'\n return to.slice(toStart + i + 1);\n }\n if (i === 0) {\n // We get here if `from` is the root\n // For example: from='/'; to='/foo'\n return to.slice(toStart + i);\n }\n }\n else if (fromLen > length) {\n if (from[fromStart + i] === '/') {\n // We get here if `to` is the exact base path for `from`.\n // For example: from='/foo/bar/baz'; to='/foo/bar'\n lastCommonSep = i;\n }\n else if (i === 0) {\n // We get here if `to` is the root.\n // For example: from='/foo/bar'; to='/'\n lastCommonSep = 0;\n }\n }\n }\n let out = '';\n // Generate the relative path based on the path difference between `to`\n // and `from`.\n for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {\n if (i === fromEnd || from[i] === '/') {\n out += out.length === 0 ? '..' : '/..';\n }\n }\n // Lastly, append the rest of the destination (`to`) path that comes after\n // the common path parts.\n return `${out}${to.slice(toStart + lastCommonSep)}`;\n}\nexport function dirname(path) {\n if (path.length === 0)\n return '.';\n const hasRoot = path[0] === '/';\n let end = -1;\n let matchedSlash = true;\n for (let i = path.length - 1; i >= 1; --i) {\n if (path[i] === '/') {\n if (!matchedSlash) {\n end = i;\n break;\n }\n }\n else {\n // We saw the first non-path separator\n matchedSlash = false;\n }\n }\n if (end === -1)\n return hasRoot ? '/' : '.';\n if (hasRoot && end === 1)\n return '//';\n return path.slice(0, end);\n}\nexport function basename(path, suffix) {\n let start = 0;\n let end = -1;\n let matchedSlash = true;\n if (suffix !== undefined && suffix.length > 0 && suffix.length <= path.length) {\n if (suffix === path)\n return '';\n let extIdx = suffix.length - 1;\n let firstNonSlashEnd = -1;\n for (let i = path.length - 1; i >= 0; --i) {\n if (path[i] === '/') {\n // If we reached a path separator that was not part of a set of path\n // separators at the end of the string, stop now\n if (!matchedSlash) {\n start = i + 1;\n break;\n }\n }\n else {\n if (firstNonSlashEnd === -1) {\n // We saw the first non-path separator, remember this index in case\n // we need it if the extension ends up not matching\n matchedSlash = false;\n firstNonSlashEnd = i + 1;\n }\n if (extIdx >= 0) {\n // Try to match the explicit extension\n if (path[i] === suffix[extIdx]) {\n if (--extIdx === -1) {\n // We matched the extension, so mark this as the end of our path\n // component\n end = i;\n }\n }\n else {\n // Extension does not match, so our result is the entire path\n // component\n extIdx = -1;\n end = firstNonSlashEnd;\n }\n }\n }\n }\n if (start === end)\n end = firstNonSlashEnd;\n else if (end === -1)\n end = path.length;\n return path.slice(start, end);\n }\n for (let i = path.length - 1; i >= 0; --i) {\n if (path[i] === '/') {\n // If we reached a path separator that was not part of a set of path\n // separators at the end of the string, stop now\n if (!matchedSlash) {\n start = i + 1;\n break;\n }\n }\n else if (end === -1) {\n // We saw the first non-path separator, mark this as the end of our\n // path component\n matchedSlash = false;\n end = i + 1;\n }\n }\n if (end === -1)\n return '';\n return path.slice(start, end);\n}\nexport function extname(path) {\n let startDot = -1;\n let startPart = 0;\n let end = -1;\n let matchedSlash = true;\n // Track the state of characters (if any) we see before our first dot and\n // after any path separator we find\n let preDotState = 0;\n for (let i = path.length - 1; i >= 0; --i) {\n if (path[i] === '/') {\n // If we reached a path separator that was not part of a set of path\n // separators at the end of the string, stop now\n if (!matchedSlash) {\n startPart = i + 1;\n break;\n }\n continue;\n }\n if (end === -1) {\n // We saw the first non-path separator, mark this as the end of our\n // extension\n matchedSlash = false;\n end = i + 1;\n }\n if (path[i] === '.') {\n // If this is our first dot, mark it as the start of our extension\n if (startDot === -1)\n startDot = i;\n else if (preDotState !== 1)\n preDotState = 1;\n }\n else if (startDot !== -1) {\n // We saw a non-dot and non-path separator before our dot, so we should\n // have a good chance at having a non-empty extension\n preDotState = -1;\n }\n }\n if (startDot === -1 ||\n end === -1 ||\n // We saw a non-dot character immediately before the dot\n preDotState === 0 ||\n // The (right-most) trimmed path component is exactly '..'\n (preDotState === 1 && startDot === end - 1 && startDot === startPart + 1)) {\n return '';\n }\n return path.slice(startDot, end);\n}\nexport function format(pathObject) {\n validateObject(pathObject, 'pathObject');\n const dir = pathObject.dir || pathObject.root;\n const base = pathObject.base || `${pathObject.name || ''}${formatExt(pathObject.ext)}`;\n if (!dir) {\n return base;\n }\n return dir === pathObject.root ? `${dir}${base}` : `${dir}/${base}`;\n}\nexport function parse(path) {\n const isAbsolute = path.startsWith('/');\n const ret = { root: isAbsolute ? '/' : '', dir: '', base: '', ext: '', name: '' };\n if (path.length === 0)\n return ret;\n const start = isAbsolute ? 1 : 0;\n let startDot = -1;\n let startPart = 0;\n let end = -1;\n let matchedSlash = true;\n let i = path.length - 1;\n // Track the state of characters (if any) we see before our first dot and\n // after any path separator we find\n let preDotState = 0;\n // Get non-dir info\n for (; i >= start; --i) {\n if (path[i] === '/') {\n // If we reached a path separator that was not part of a set of path\n // separators at the end of the string, stop now\n if (!matchedSlash) {\n startPart = i + 1;\n break;\n }\n continue;\n }\n if (end === -1) {\n // We saw the first non-path separator, mark this as the end of our\n // extension\n matchedSlash = false;\n end = i + 1;\n }\n if (path[i] === '.') {\n // If this is our first dot, mark it as the start of our extension\n if (startDot === -1)\n startDot = i;\n else if (preDotState !== 1)\n preDotState = 1;\n }\n else if (startDot !== -1) {\n // We saw a non-dot and non-path separator before our dot, so we should\n // have a good chance at having a non-empty extension\n preDotState = -1;\n }\n }\n if (end !== -1) {\n const start = startPart === 0 && isAbsolute ? 1 : startPart;\n if (startDot === -1 ||\n // We saw a non-dot character immediately before the dot\n preDotState === 0 ||\n // The (right-most) trimmed path component is exactly '..'\n (preDotState === 1 && startDot === end - 1 && startDot === startPart + 1)) {\n ret.base = ret.name = path.slice(start, end);\n }\n else {\n ret.name = path.slice(start, startDot);\n ret.base = path.slice(start, end);\n ret.ext = path.slice(startDot, end);\n }\n }\n if (startPart > 0)\n ret.dir = path.slice(0, startPart - 1);\n else if (isAbsolute)\n ret.dir = '/';\n return ret;\n}\n", "import { ErrnoError, Errno } from '@zenfs/core';\n\n/**\n * Converts a DOMException into an Errno\n * @see https://developer.mozilla.org/Web/API/DOMException\n */\nfunction errnoForDOMException(ex: DOMException): keyof typeof Errno {\n\tswitch (ex.name) {\n\t\tcase 'IndexSizeError':\n\t\tcase 'HierarchyRequestError':\n\t\tcase 'InvalidCharacterError':\n\t\tcase 'InvalidStateError':\n\t\tcase 'SyntaxError':\n\t\tcase 'NamespaceError':\n\t\tcase 'TypeMismatchError':\n\t\tcase 'ConstraintError':\n\t\tcase 'VersionError':\n\t\tcase 'URLMismatchError':\n\t\tcase 'InvalidNodeTypeError':\n\t\t\treturn 'EINVAL';\n\t\tcase 'WrongDocumentError':\n\t\t\treturn 'EXDEV';\n\t\tcase 'NoModificationAllowedError':\n\t\tcase 'InvalidModificationError':\n\t\tcase 'InvalidAccessError':\n\t\tcase 'SecurityError':\n\t\tcase 'NotAllowedError':\n\t\t\treturn 'EACCES';\n\t\tcase 'NotFoundError':\n\t\t\treturn 'ENOENT';\n\t\tcase 'NotSupportedError':\n\t\t\treturn 'ENOTSUP';\n\t\tcase 'InUseAttributeError':\n\t\t\treturn 'EBUSY';\n\t\tcase 'NetworkError':\n\t\t\treturn 'ENETDOWN';\n\t\tcase 'AbortError':\n\t\t\treturn 'EINTR';\n\t\tcase 'QuotaExceededError':\n\t\t\treturn 'ENOSPC';\n\t\tcase 'TimeoutError':\n\t\t\treturn 'ETIMEDOUT';\n\t\tcase 'ReadOnlyError':\n\t\t\treturn 'EROFS';\n\t\tcase 'DataCloneError':\n\t\tcase 'EncodingError':\n\t\tcase 'NotReadableError':\n\t\tcase 'DataError':\n\t\tcase 'TransactionInactiveError':\n\t\tcase 'OperationError':\n\t\tcase 'UnknownError':\n\t\tdefault:\n\t\t\treturn 'EIO';\n\t}\n}\n\n/**\n * @internal\n */\nexport type ConvertException = ErrnoError | DOMException | Error;\n\n/**\n * Handles converting errors, then rethrowing them\n * @internal\n */\nexport function convertException(ex: ConvertException, path?: string, syscall?: string): ErrnoError {\n\tif (ex instanceof ErrnoError) {\n\t\treturn ex;\n\t}\n\n\tconst code = ex instanceof DOMException ? Errno[errnoForDOMException(ex)] : Errno.EIO;\n\tconst error = new ErrnoError(code, ex.message, path, syscall);\n\terror.stack = ex.stack!;\n\terror.cause = ex.cause;\n\treturn error;\n}\n", "import type { Backend, FileSystemMetadata } from '@zenfs/core';\nimport { Async, Errno, ErrnoError, FileSystem, InMemory, PreloadFile, Stats } from '@zenfs/core';\nimport { S_IFDIR, S_IFREG } from '@zenfs/core/emulation/constants.js';\nimport { basename, dirname, join } from '@zenfs/core/emulation/path.js';\nimport { convertException, type ConvertException } from './utils.js';\n\ndeclare global {\n\tinterface FileSystemDirectoryHandle {\n\t\t[Symbol.iterator](): IterableIterator<[string, FileSystemHandle]>;\n\t\tentries(): IterableIterator<[string, FileSystemHandle]>;\n\t\tkeys(): IterableIterator<string>;\n\t\tvalues(): IterableIterator<FileSystemHandle>;\n\t}\n}\n\nexport interface WebAccessOptions {\n\thandle: FileSystemDirectoryHandle;\n}\n\nexport class WebAccessFS extends Async(FileSystem) {\n\tprivate _handles: Map<string, FileSystemHandle> = new Map();\n\n\t/**\n\t * @hidden\n\t */\n\t_sync: FileSystem = InMemory.create({ name: 'accessfs-cache' });\n\n\tpublic constructor(handle: FileSystemDirectoryHandle) {\n\t\tsuper();\n\t\tthis._handles.set('/', handle);\n\t}\n\n\tpublic metadata(): FileSystemMetadata {\n\t\treturn {\n\t\t\t...super.metadata(),\n\t\t\tname: 'WebAccess',\n\t\t\tnoResizableBuffers: true,\n\t\t};\n\t}\n\n\tpublic async sync(path: string, data: Uint8Array, stats: Stats): Promise<void> {\n\t\tconst currentStats = await this.stat(path);\n\t\tif (stats.mtime !== currentStats!.mtime) {\n\t\t\tawait this.writeFile(path, data);\n\t\t}\n\t}\n\n\tpublic async rename(oldPath: string, newPath: string): Promise<void> {\n\t\ttry {\n\t\t\tconst handle = await this.getHandle(oldPath);\n\t\t\tif (handle instanceof FileSystemDirectoryHandle) {\n\t\t\t\tconst files = await this.readdir(oldPath);\n\n\t\t\t\tawait this.mkdir(newPath);\n\t\t\t\tif (files.length == 0) {\n\t\t\t\t\tawait this.unlink(oldPath);\n\t\t\t\t} else {\n\t\t\t\t\tfor (const file of files) {\n\t\t\t\t\t\tawait this.rename(join(oldPath, file), join(newPath, file));\n\t\t\t\t\t\tawait this.unlink(oldPath);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!(handle instanceof FileSystemFileHandle)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst oldFile = await handle.getFile(),\n\t\t\t\tdestFolder = await this.getHandle(dirname(newPath));\n\t\t\tif (!(destFolder instanceof FileSystemDirectoryHandle)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst newFile = await destFolder.getFileHandle(basename(newPath), { create: true });\n\t\t\tconst writable = await newFile.createWritable();\n\t\t\tawait writable.write(await oldFile.arrayBuffer());\n\n\t\t\twritable.close();\n\t\t\tawait this.unlink(oldPath);\n\t\t} catch (ex) {\n\t\t\tthrow convertException(ex as ConvertException, oldPath, 'rename');\n\t\t}\n\t}\n\n\tpublic async writeFile(path: string, data: Uint8Array): Promise<void> {\n\t\tif (data.buffer.resizable) {\n\t\t\tthrow new ErrnoError(Errno.EINVAL, 'Resizable buffers can not be written', path, 'write');\n\t\t}\n\n\t\tconst handle = await this.getHandle(dirname(path));\n\t\tif (!(handle instanceof FileSystemDirectoryHandle)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst file = await handle.getFileHandle(basename(path), { create: true });\n\t\tconst writable = await file.createWritable();\n\t\tawait writable.write(data);\n\t\tawait writable.close();\n\t}\n\n\tpublic async createFile(path: string, flag: string): Promise<PreloadFile<this>> {\n\t\tawait this.writeFile(path, new Uint8Array());\n\t\treturn this.openFile(path, flag);\n\t}\n\n\tpublic async stat(path: string): Promise<Stats> {\n\t\tconst handle = await this.getHandle(path);\n\t\tif (!handle) {\n\t\t\tthrow ErrnoError.With('ENOENT', path, 'stat');\n\t\t}\n\t\tif (handle instanceof FileSystemDirectoryHandle) {\n\t\t\treturn new Stats({ mode: 0o777 | S_IFDIR, size: 4096 });\n\t\t}\n\t\tif (handle instanceof FileSystemFileHandle) {\n\t\t\tconst { lastModified, size } = await handle.getFile();\n\t\t\treturn new Stats({ mode: 0o777 | S_IFREG, size, mtimeMs: lastModified });\n\t\t}\n\t\tthrow new ErrnoError(Errno.EBADE, 'Handle is not a directory or file', path, 'stat');\n\t}\n\n\tpublic async openFile(path: string, flag: string): Promise<PreloadFile<this>> {\n\t\tconst handle = await this.getHandle(path);\n\t\tif (!(handle instanceof FileSystemFileHandle)) {\n\t\t\tthrow ErrnoError.With('EISDIR', path, 'openFile');\n\t\t}\n\t\ttry {\n\t\t\tconst file = await handle.getFile();\n\t\t\tconst data = new Uint8Array(await file.arrayBuffer());\n\t\t\tconst stats = new Stats({ mode: 0o777 | S_IFREG, size: file.size, mtimeMs: file.lastModified });\n\t\t\treturn new PreloadFile(this, path, flag, stats, data);\n\t\t} catch (ex) {\n\t\t\tthrow convertException(ex as ConvertException, path, 'openFile');\n\t\t}\n\t}\n\n\tpublic async unlink(path: string): Promise<void> {\n\t\tconst handle = await this.getHandle(dirname(path));\n\t\tif (handle instanceof FileSystemDirectoryHandle) {\n\t\t\ttry {\n\t\t\t\tawait handle.removeEntry(basename(path), { recursive: true });\n\t\t\t} catch (ex) {\n\t\t\t\tthrow convertException(ex as ConvertException, path, 'unlink');\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic async link(srcpath: string): Promise<void> {\n\t\tthrow ErrnoError.With('ENOSYS', srcpath, 'WebAccessFS.link');\n\t}\n\n\tpublic async rmdir(path: string): Promise<void> {\n\t\treturn this.unlink(path);\n\t}\n\n\tpublic async mkdir(path: string): Promise<void> {\n\t\tconst existingHandle = await this.getHandle(path);\n\t\tif (existingHandle) {\n\t\t\tthrow ErrnoError.With('EEXIST', path, 'mkdir');\n\t\t}\n\n\t\tconst handle = await this.getHandle(dirname(path));\n\t\tif (!(handle instanceof FileSystemDirectoryHandle)) {\n\t\t\tthrow ErrnoError.With('ENOTDIR', path, 'mkdir');\n\t\t}\n\t\tawait handle.getDirectoryHandle(basename(path), { create: true });\n\t}\n\n\tpublic async readdir(path: string): Promise<string[]> {\n\t\tconst handle = await this.getHandle(path);\n\t\tif (!(handle instanceof FileSystemDirectoryHandle)) {\n\t\t\tthrow ErrnoError.With('ENOTDIR', path, 'readdir');\n\t\t}\n\t\tconst keys: string[] = [];\n\t\tfor await (const key of handle.keys()) {\n\t\t\tkeys.push(key);\n\t\t}\n\t\treturn keys;\n\t}\n\n\tprotected async getHandle(path: string): Promise<FileSystemHandle> {\n\t\tif (this._handles.has(path)) {\n\t\t\treturn this._handles.get(path)!;\n\t\t}\n\n\t\tlet walked = '/';\n\n\t\tfor (const part of path.split('/').slice(1)) {\n\t\t\tconst handle = this._handles.get(walked);\n\t\t\tif (!(handle instanceof FileSystemDirectoryHandle)) {\n\t\t\t\tthrow ErrnoError.With('ENOTDIR', walked, 'getHandle');\n\t\t\t}\n\t\t\twalked = join(walked, part);\n\n\t\t\ttry {\n\t\t\t\tconst dirHandle = await handle.getDirectoryHandle(part);\n\t\t\t\tthis._handles.set(walked, dirHandle);\n\t\t\t} catch (_ex) {\n\t\t\t\tconst ex = _ex as DOMException;\n\t\t\t\tif (ex.name == 'TypeMismatchError') {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst fileHandle = await handle.getFileHandle(part);\n\t\t\t\t\t\tthis._handles.set(walked, fileHandle);\n\t\t\t\t\t} catch (ex) {\n\t\t\t\t\t\tconvertException(ex as ConvertException, walked, 'getHandle');\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (ex.name === 'TypeError') {\n\t\t\t\t\tthrow new ErrnoError(Errno.ENOENT, ex.message, walked, 'getHandle');\n\t\t\t\t}\n\n\t\t\t\tconvertException(ex, walked, 'getHandle');\n\t\t\t}\n\t\t}\n\n\t\treturn this._handles.get(path)!;\n\t}\n}\n\nexport const WebAccess = {\n\tname: 'WebAccess',\n\n\toptions: {\n\t\thandle: {\n\t\t\ttype: 'object',\n\t\t\trequired: true,\n\t\t\tdescription: 'The directory handle to use for the root',\n\t\t},\n\t},\n\n\tisAvailable(): boolean {\n\t\treturn typeof FileSystemHandle == 'function';\n\t},\n\n\tcreate(options: WebAccessOptions) {\n\t\treturn new WebAccessFS(options.handle);\n\t},\n} as const satisfies Backend<WebAccessFS, WebAccessOptions>;\n", "/**\n * Standard libc error codes. More will be added to this enum and error strings as they are\n * needed.\n * @see https://en.wikipedia.org/wiki/Errno.h\n */\nexport var Errno;\n(function (Errno) {\n /** Operation not permitted */\n Errno[Errno[\"EPERM\"] = 1] = \"EPERM\";\n /** No such file or directory */\n Errno[Errno[\"ENOENT\"] = 2] = \"ENOENT\";\n /** Interrupted system call */\n Errno[Errno[\"EINTR\"] = 4] = \"EINTR\";\n /** Input/output error */\n Errno[Errno[\"EIO\"] = 5] = \"EIO\";\n /** No such device or address */\n Errno[Errno[\"ENXIO\"] = 6] = \"ENXIO\";\n /** Bad file descriptor */\n Errno[Errno[\"EBADF\"] = 9] = \"EBADF\";\n /** Resource temporarily unavailable */\n Errno[Errno[\"EAGAIN\"] = 11] = \"EAGAIN\";\n /** Cannot allocate memory */\n Errno[Errno[\"ENOMEM\"] = 12] = \"ENOMEM\";\n /** Permission denied */\n Errno[Errno[\"EACCES\"] = 13] = \"EACCES\";\n /** Bad address */\n Errno[Errno[\"EFAULT\"] = 14] = \"EFAULT\";\n /** Block device required */\n Errno[Errno[\"ENOTBLK\"] = 15] = \"ENOTBLK\";\n /** Resource busy or locked */\n Errno[Errno[\"EBUSY\"] = 16] = \"EBUSY\";\n /** File exists */\n Errno[Errno[\"EEXIST\"] = 17] = \"EEXIST\";\n /** Invalid cross-device link */\n Errno[Errno[\"EXDEV\"] = 18] = \"EXDEV\";\n /** No such device */\n Errno[Errno[\"ENODEV\"] = 19] = \"ENODEV\";\n /** File is not a directory */\n Errno[Errno[\"ENOTDIR\"] = 20] = \"ENOTDIR\";\n /** File is a directory */\n Errno[Errno[\"EISDIR\"] = 21] = \"EISDIR\";\n /** Invalid argument */\n Errno[Errno[\"EINVAL\"] = 22] = \"EINVAL\";\n /** Too many open files in system */\n Errno[Errno[\"ENFILE\"] = 23] = \"ENFILE\";\n /** Too many open files */\n Errno[Errno[\"EMFILE\"] = 24] = \"EMFILE\";\n /** Text file busy */\n Errno[Errno[\"ETXTBSY\"] = 26] = \"ETXTBSY\";\n /** File is too big */\n Errno[Errno[\"EFBIG\"] = 27] = \"EFBIG\";\n /** No space left on disk */\n Errno[Errno[\"ENOSPC\"] = 28] = \"ENOSPC\";\n /** Illegal seek */\n Errno[Errno[\"ESPIPE\"] = 29] = \"ESPIPE\";\n /** Cannot modify a read-only file system */\n Errno[Errno[\"EROFS\"] = 30] = \"EROFS\";\n /** Too many links */\n Errno[Errno[\"EMLINK\"] = 31] = \"EMLINK\";\n /** Broken pipe */\n Errno[Errno[\"EPIPE\"] = 32] = \"EPIPE\";\n /** Numerical argument out of domain */\n Errno[Errno[\"EDOM\"] = 33] = \"EDOM\";\n /** Numerical result out of range */\n Errno[Errno[\"ERANGE\"] = 34] = \"ERANGE\";\n /** Resource deadlock would occur */\n Errno[Errno[\"EDEADLK\"] = 35] = \"EDEADLK\";\n /** File name too long */\n Errno[Errno[\"ENAMETOOLONG\"] = 36] = \"ENAMETOOLONG\";\n /** No locks available */\n Errno[Errno[\"ENOLCK\"] = 37] = \"ENOLCK\";\n /** Function not implemented */\n Errno[Errno[\"ENOSYS\"] = 38] = \"ENOSYS\";\n /** Directory is not empty */\n Errno[Errno[\"ENOTEMPTY\"] = 39] = \"ENOTEMPTY\";\n /** Too many levels of symbolic links */\n Errno[Errno[\"ELOOP\"] = 40] = \"ELOOP\";\n /** No message of desired type */\n Errno[Errno[\"ENOMSG\"] = 42] = \"ENOMSG\";\n /** Invalid exchange */\n Errno[Errno[\"EBADE\"] = 52] = \"EBADE\";\n /** Invalid request descriptor */\n Errno[Errno[\"EBADR\"] = 53] = \"EBADR\";\n /** Exchange full */\n Errno[Errno[\"EXFULL\"] = 54] = \"EXFULL\";\n /** No anode */\n Errno[Errno[\"ENOANO\"] = 55] = \"ENOANO\";\n /** Invalid request code */\n Errno[Errno[\"EBADRQC\"] = 56] = \"EBADRQC\";\n /** Device not a stream */\n Errno[Errno[\"ENOSTR\"] = 60] = \"ENOSTR\";\n /** No data available */\n Errno[Errno[\"ENODATA\"] = 61] = \"ENODATA\";\n /** Timer expired */\n Errno[Errno[\"ETIME\"] = 62] = \"ETIME\";\n /** Out of streams resources */\n Errno[Errno[\"ENOSR\"] = 63] = \"ENOSR\";\n /** Machine is not on the network */\n Errno[Errno[\"ENONET\"] = 64] = \"ENONET\";\n /** Object is remote */\n Errno[Errno[\"EREMOTE\"] = 66] = \"EREMOTE\";\n /** Link has been severed */\n Errno[Errno[\"ENOLINK\"] = 67] = \"ENOLINK\";\n /** Communication error on send */\n Errno[Errno[\"ECOMM\"] = 70] = \"ECOMM\";\n /** Protocol error */\n Errno[Errno[\"EPROTO\"] = 71] = \"EPROTO\";\n /** Bad message */\n Errno[Errno[\"EBADMSG\"] = 74] = \"EBADMSG\";\n /** Value too large for defined data type */\n Errno[Errno[\"EOVERFLOW\"] = 75] = \"EOVERFLOW\";\n /** File descriptor in bad state */\n Errno[Errno[\"EBADFD\"] = 77] = \"EBADFD\";\n /** Streams pipe error */\n Errno[Errno[\"ESTRPIPE\"] = 86] = \"ESTRPIPE\";\n /** Socket operation on non-socket */\n Errno[Errno[\"ENOTSOCK\"] = 88] = \"ENOTSOCK\";\n /** Destination address required */\n Errno[Errno[\"EDESTADDRREQ\"] = 89] = \"EDESTADDRREQ\";\n /** Message too long */\n Errno[Errno[\"EMSGSIZE\"] = 90] = \"EMSGSIZE\";\n /** Protocol wrong type for socket */\n Errno[Errno[\"EPROTOTYPE\"] = 91] = \"EPROTOTYPE\";\n /** Protocol not available */\n Errno[Errno[\"ENOPROTOOPT\"] = 92] = \"ENOPROTOOPT\";\n /** Protocol not supported */\n Errno[Errno[\"EPROTONOSUPPORT\"] = 93] = \"EPROTONOSUPPORT\";\n /** Socket type not supported */\n Errno[Errno[\"ESOCKTNOSUPPORT\"] = 94] = \"ESOCKTNOSUPPORT\";\n /** Operation is not supported */\n Errno[Errno[\"ENOTSUP\"] = 95] = \"ENOTSUP\";\n /** Network is down */\n Errno[Errno[\"ENETDOWN\"] = 100] = \"ENETDOWN\";\n /** Network is unreachable */\n Errno[Errno[\"ENETUNREACH\"] = 101] = \"ENETUNREACH\";\n /** Network dropped connection on reset */\n Errno[Errno[\"ENETRESET\"] = 102] = \"ENETRESET\";\n /** Connection timed out */\n Errno[Errno[\"ETIMEDOUT\"] = 110] = \"ETIMEDOUT\";\n /** Connection refused */\n Errno[Errno[\"ECONNREFUSED\"] = 111] = \"ECONNREFUSED\";\n /** Host is down */\n Errno[Errno[\"EHOSTDOWN\"] = 112] = \"EHOSTDOWN\";\n /** No route to host */\n Errno[Errno[\"EHOSTUNREACH\"] = 113] = \"EHOSTUNREACH\";\n /** Operation already in progress */\n Errno[Errno[\"EALREADY\"] = 114] = \"EALREADY\";\n /** Operation now in progress */\n Errno[Errno[\"EINPROGRESS\"] = 115] = \"EINPROGRESS\";\n /** Stale file handle */\n Errno[Errno[\"ESTALE\"] = 116] = \"ESTALE\";\n /** Remote I/O error */\n Errno[Errno[\"EREMOTEIO\"] = 121] = \"EREMOTEIO\";\n /** Disk quota exceeded */\n Errno[Errno[\"EDQUOT\"] = 122] = \"EDQUOT\";\n})(Errno || (Errno = {}));\n/**\n * Strings associated with each error code.\n * @internal\n */\nexport const errorMessages = {\n [Errno.EPERM]: 'Operation not permitted',\n [Errno.ENOENT]: 'No such file or directory',\n [Errno.EINTR]: 'Interrupted system call',\n [Errno.EIO]: 'Input/output error',\n [Errno.ENXIO]: 'No such device or address',\n [Errno.EBADF]: 'Bad file descriptor',\n [Errno.EAGAIN]: 'Resource temporarily unavailable',\n [Errno.ENOMEM]: 'Cannot allocate memory',\n [Errno.EACCES]: 'Permission denied',\n [Errno.EFAULT]: 'Bad address',\n [Errno.ENOTBLK]: 'Block device required',\n [Errno.EBUSY]: 'Resource busy or locked',\n [Errno.EEXIST]: 'File exists',\n [Errno.EXDEV]: 'Invalid cross-device link',\n [Errno.ENODEV]: 'No such device',\n [Errno.ENOTDIR]: 'File is not a directory',\n [Errno.EISDIR]: 'File is a directory',\n [Errno.EINVAL]: 'Invalid argument',\n [Errno.ENFILE]: 'Too many open files in system',\n [Errno.EMFILE]: 'Too many open files',\n [Errno.ETXTBSY]: 'Text file busy',\n [Errno.EFBIG]: 'File is too big',\n [Errno.ENOSPC]: 'No space left on disk',\n [Errno.ESPIPE]: 'Illegal seek',\n [Errno.EROFS]: 'Cannot modify a read-only file system',\n [Errno.EMLINK]: 'Too many links',\n [Errno.EPIPE]: 'Broken pipe',\n [Errno.EDOM]: 'Numerical argument out of domain',\n [Errno.ERANGE]: 'Numerical result out of range',\n [Errno.EDEADLK]: 'Resource deadlock would occur',\n [Errno.ENAMETOOLONG]: 'File name too long',\n [Errno.ENOLCK]: 'No locks available',\n [Errno.ENOSYS]: 'Function not implemented',\n [Errno.ENOTEMPTY]: 'Directory is not empty',\n [Errno.ELOOP]: 'Too many levels of symbolic links',\n [Errno.ENOMSG]: 'No message of desired type',\n [Errno.EBADE]: 'Invalid exchange',\n [Errno.EBADR]: 'Invalid request descriptor',\n [Errno.EXFULL]: 'Exchange full',\n [Errno.ENOANO]: 'No anode',\n [Errno.EBADRQC]: 'Invalid request code',\n [Errno.ENOSTR]: 'Device not a stream',\n [Errno.ENODATA]: 'No data available',\n [Errno.ETIME]: 'Timer expired',\n [Errno.ENOSR]: 'Out of streams resources',\n [Errno.ENONET]: 'Machine is not on the network',\n [Errno.EREMOTE]: 'Object is remote',\n [Errno.ENOLINK]: 'Link has been severed',\n [Errno.ECOMM]: 'Communication error on send',\n [Errno.EPROTO]: 'Protocol error',\n [Errno.EBADMSG]: 'Bad message',\n [Errno.EOVERFLOW]: 'Value too large for defined data type',\n [Errno.EBADFD]: 'File descriptor in bad state',\n [Errno.ESTRPIPE]: 'Streams pipe error',\n [Errno.ENOTSOCK]: 'Socket operation on non-socket',\n [Errno.EDESTADDRREQ]: 'Destination address required',\n [Errno.EMSGSIZE]: 'Message too long',\n [Errno.EPROTOTYPE]: 'Protocol wrong type for socket',\n [Errno.ENOPROTOOPT]: 'Protocol not available',\n [Errno.EPROTONOSUPPORT]: 'Protocol not supported',\n [Errno.ESOCKTNOSUPPORT]: 'Socket type not supported',\n [Errno.ENOTSUP]: 'Operation is not supported',\n [Errno.ENETDOWN]: 'Network is down',\n [Errno.ENETUNREACH]: 'Network is unreachable',\n [Errno.ENETRESET]: 'Network dropped connection on reset',\n [Errno.ETIMEDOUT]: 'Connection timed out',\n [Errno.ECONNREFUSED]: 'Connection refused',\n [Errno.EHOSTDOWN]: 'Host is down',\n [Errno.EHOSTUNREACH]: 'No route to host',\n [Errno.EALREADY]: 'Operation already in progress',\n [Errno.EINPROGRESS]: 'Operation now in progress',\n [Errno.ESTALE]: 'Stale file handle',\n [Errno.EREMOTEIO]: 'Remote I/O error',\n [Errno.EDQUOT]: 'Disk quota exceeded',\n};\n/**\n * Represents a ZenFS error. Passed back to applications after a failed\n * call to the ZenFS API.\n */\nexport class ErrnoError extends Error {\n static fromJSON(json) {\n const err = new ErrnoError(json.errno, json.message, json.path, json.syscall);\n err.code = json.code;\n err.stack = json.stack;\n return err;\n }\n static With(code, path, syscall) {\n return new ErrnoError(Errno[code], errorMessages[Errno[code]], path, syscall);\n }\n /**\n * Represents a ZenFS error. Passed back to applications after a failed\n * call to the ZenFS API.\n *\n * Error codes mirror those returned by regular Unix file operations, which is\n * what Node returns.\n * @param type The type of the error.\n * @param message A descriptive error message.\n */\n constructor(errno, message = errorMessages[errno], path, syscall = '') {\n super(message);\n this.errno = errno;\n this.path = path;\n this.syscall = syscall;\n this.code = Errno[errno];\n this.message = `${this.code}: ${message}${this.path ? `, '${this.path}'` : ''}`;\n }\n /**\n * @return A friendly error message.\n */\n toString() {\n return this.message;\n }\n toJSON() {\n return {\n errno: this.errno,\n code: this.code,\n path: this.path,\n stack: this.stack,\n message: this.message,\n syscall: this.syscall,\n };\n }\n /**\n * The size of the API error in buffer-form in bytes.\n */\n bufferSize() {\n // 4 bytes for string length.\n return 4 + JSON.stringify(this.toJSON()).length;\n }\n}\n", "// eslint-disable-next-line @typescript-eslint/unbound-method\nPromise.withResolvers ?? (Promise.withResolvers = function () {\n let _resolve, \n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n _reject;\n const promise = new Promise((resolve, reject) => {\n _resolve = resolve;\n _reject = reject;\n });\n return { promise, resolve: _resolve, reject: _reject };\n});\n/*\n A polyfill for when these symbols are undefined.\n For some reason, NodeJS does not polyfill them in a VM context.\n Since jest uses a VM context for ESM, these need to be here.\n*/\n// @ts-expect-error 2540\nSymbol['dispose'] ?? (Symbol['dispose'] = Symbol('Symbol.dispose'));\n// @ts-expect-error 2540\nSymbol['asyncDispose'] ?? (Symbol['asyncDispose'] = Symbol('Symbol.asyncDispose'));\nexport {};\n", "import { ErrnoError } from '../../error.js';\nimport '../../polyfills.js';\n/**\n * A transaction for a store.\n */\nexport class Transaction {\n constructor(store) {\n this.store = store;\n /**\n * Whether the transaction was commited or aborted\n */\n this.done = false;\n }\n async [Symbol.asyncDispose]() {\n if (this.done) {\n return;\n }\n await this.abort();\n }\n [Symbol.dispose]() {\n if (this.done) {\n return;\n }\n this.abortSync();\n }\n}\n/**\n * Transaction that implements asynchronous operations with synchronous ones\n */\nexport class SyncTransaction extends Transaction {\n /* eslint-disable @typescript-eslint/require-await */\n async get(ino) {\n return this.getSync(ino);\n }\n async set(ino, data) {\n return this.setSync(ino, data);\n }\n async remove(ino) {\n return this.removeSync(ino);\n }\n async commit() {\n return this.commitSync();\n }\n async abort() {\n return this.abortSync();\n }\n}\n/**\n * Transaction that only supports asynchronous operations\n */\nexport class AsyncTransaction extends Transaction {\n getSync() {\n throw ErrnoError.With('ENOSYS', undefined, 'AsyncTransaction.getSync');\n }\n setSync() {\n throw ErrnoError.With('ENOSYS', undefined, 'AsyncTransaction.setSync');\n }\n removeSync() {\n throw ErrnoError.With('ENOSYS', undefined, 'AsyncTransaction.removeSync');\n }\n commitSync() {\n throw ErrnoError.With('ENOSYS', undefined, 'AsyncTransaction.commitSync');\n }\n abortSync() {\n throw ErrnoError.With('ENOSYS', undefined, 'AsyncTransaction.abortSync');\n }\n}\n", "import type { Store } from '@zenfs/core/backends/store/store.js';\nimport { AsyncTransaction } from '@zenfs/core/backends/store/store.js';\nimport type { Backend, Ino, SharedConfig } from '@zenfs/core';\nimport { Async, ErrnoError, InMemory, StoreFS } from '@zenfs/core';\nimport { convertException, type ConvertException } from './utils.js';\n\nfunction wrap<T>(request: IDBRequest<T>): Promise<T> {\n\treturn new Promise((resolve, reject) => {\n\t\trequest.onsuccess = () => resolve(request.result);\n\t\trequest.onerror = e => {\n\t\t\te.preventDefault();\n\t\t\treject(convertException(request.error!));\n\t\t};\n\t});\n}\n\n/**\n * @hidden\n */\nexport class IndexedDBTransaction extends AsyncTransaction<IndexedDBStore> {\n\tprivate _idb: IDBObjectStore;\n\n\tconstructor(\n\t\tpublic tx: IDBTransaction,\n\t\tpublic store: IndexedDBStore\n\t) {\n\t\tsuper(store);\n\t\tthis._idb = tx.objectStore(store.name);\n\t}\n\n\tpublic get(key: Ino): Promise<Uint8Array> {\n\t\treturn wrap(this._idb.get(key.toString()));\n\t}\n\n\tpublic async set(key: Ino, data: Uint8Array): Promise<void> {\n\t\tawait wrap(this._idb.put(data, key.toString()));\n\t}\n\n\tpublic remove(key: Ino): Promise<void> {\n\t\treturn wrap(this._idb.delete(key.toString()));\n\t}\n\n\tpublic async commit(): Promise<void> {\n\t\tif (this.done) {\n\t\t\treturn;\n\t\t}\n\t\tthis.done = true;\n\t\tthis.tx.commit();\n\t}\n\n\tpublic async abort(): Promise<void> {\n\t\tif (this.done) {\n\t\t\treturn;\n\t\t}\n\t\tthis.done = true;\n\t\ttry {\n\t\t\tthis.tx.abort();\n\t\t} catch (e) {\n\t\t\tthrow convertException(e as ConvertException);\n\t\t}\n\t}\n}\n\nasync function createDB(name: string, indexedDB: IDBFactory = globalThis.indexedDB): Promise<IDBDatabase> {\n\tconst req: IDBOpenDBRequest = indexedDB.open(name);\n\n\treq.onupgradeneeded = () => {\n\t\tconst db: IDBDatabase = req.result;\n\t\t// This should never happen; we're at version 1. Why does another database exist?\n\t\tif (db.objectStoreNames.contains(name)) {\n\t\t\tdb.deleteObjectStore(name);\n\t\t}\n\t\tdb.createObjectStore(name);\n\t};\n\n\tconst result = await wrap(req);\n\treturn result;\n}\n\nexport class IndexedDBStore implements Store {\n\tpublic constructor(protected db: IDBDatabase) {}\n\n\tpublic sync(): Promise<void> {\n\t\tthrow new Error('Method not implemented.');\n\t}\n\n\tpublic get name(): string {\n\t\treturn this.db.name;\n\t}\n\n\tpublic clear(): Promise<void> {\n\t\treturn wrap(this.db.transaction(this.name, 'readwrite').objectStore(this.name).clear());\n\t}\n\n\tpublic clearSync(): void {\n\t\tthrow ErrnoError.With('ENOSYS', undefined, 'IndexedDBStore.clearSync');\n\t}\n\n\tpublic transaction(): IndexedDBTransaction {\n\t\tconst tx = this.db.transaction(this.name, 'readwrite');\n\t\treturn new IndexedDBTransaction(tx, this);\n\t}\n}\n\n/**\n * Configuration options for the IndexedDB file system.\n */\nexport interface IndexedDBOptions {\n\t/**\n\t * The name of this file system. You can have multiple IndexedDB file systems operating at once, but each must have a different name.\n\t */\n\tstoreName?: string;\n\n\t/**\n\t * The IDBFactory to use. Defaults to `globalThis.indexedDB`.\n\t */\n\tidbFactory?: IDBFactory;\n}\n\n/**\n * A file system that uses the IndexedDB key value file system.\n */\n\nexport const IndexedDB = {\n\tname: 'IndexedDB',\n\n\toptions: {\n\t\tstoreName: {\n\t\t\ttype: 'string',\n\t\t\trequired: false,\n\t\t\tdescription: 'The name of this file system. You can have multiple IndexedDB file systems operating at once, but each must have a different name.',\n\t\t},\n\t\tidbFactory: {\n\t\t\ttype: 'object',\n\t\t\trequired: false,\n\t\t\tdescription: 'The IDBFactory to use. Defaults to globalThis.indexedDB.',\n\t\t},\n\t},\n\n\tasync isAvailable(idbFactory: IDBFactory = globalThis.indexedDB): Promise<boolean> {\n\t\ttry {\n\t\t\tif (!(idbFactory instanceof IDBFactory)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tconst req = idbFactory.open('__zenfs_test');\n\t\t\tawait wrap(req);\n\t\t\tidbFactory.deleteDatabase('__zenfs_test');\n\t\t\treturn true;\n\t\t} catch (e) {\n\t\t\tidbFactory.deleteDatabase('__zenfs_test');\n\t\t\treturn false;\n\t\t}\n\t},\n\n\tasync create(options: IndexedDBOptions & Partial<SharedConfig>) {\n\t\tconst db = await createDB(options.storeName || 'zenfs', options.idbFactory);\n\t\tconst store = new IndexedDBStore(db);\n\t\tconst fs = new (Async(StoreFS))(store);\n\t\tif (!options?.disableAsyncCache) {\n\t\t\tfs._sync = InMemory.create({ name: 'idb-cache' });\n\t\t}\n\t\treturn fs;\n\t},\n} as const satisfies Backend<StoreFS, IndexedDBOptions>;\n", "import type { Backend, Ino, SimpleSyncStore, Store } from '@zenfs/core';\nimport { ErrnoError, Errno, SimpleTransaction, StoreFS, decode, encode } from '@zenfs/core';\n\n/**\n * A synchronous key-value store backed by Storage.\n */\nexport class WebStorageStore implements Store, SimpleSyncStore {\n\tpublic get name(): string {\n\t\treturn WebStorage.name;\n\t}\n\n\tconstructor(protected _storage: Storage) {}\n\n\tpublic clear(): void {\n\t\tthis._storage.clear();\n\t}\n\n\tpublic clearSync(): void {\n\t\tthis._storage.clear();\n\t}\n\n\tpublic async sync(): Promise<void> {}\n\n\tpublic transaction(): SimpleTransaction {\n\t\t// No need to differentiate.\n\t\treturn new SimpleTransaction(this);\n\t}\n\n\tpublic get(key: Ino): Uint8Array | undefined {\n\t\tconst data = this._storage.getItem(key.toString());\n\t\tif (typeof data != 'string') {\n\t\t\treturn;\n\t\t}\n\n\t\treturn encode(data);\n\t}\n\n\tpublic set(key: Ino, data: Uint8Array): void {\n\t\ttry {\n\t\t\tthis._storage.setItem(key.toString(), decode(data));\n\t\t} catch (e) {\n\t\t\tthrow new ErrnoError(Errno.ENOSPC, 'Storage is full.');\n\t\t}\n\t}\n\n\tpublic delete(key: Ino): void {\n\t\ttry {\n\t\t\tthis._storage.removeItem(key.toString());\n\t\t} catch (e) {\n\t\t\tthrow new ErrnoError(Errno.EIO, 'Unable to delete key ' + key + ': ' + e);\n\t\t}\n\t}\n}\n\n/**\n * Options to pass to the StorageFileSystem\n */\nexport interface WebStorageOptions {\n\t/**\n\t * The Storage to use. Defaults to globalThis.localStorage.\n\t */\n\tstorage?: Storage;\n}\n\n/**\n * A synchronous file system backed by a `Storage` (e.g. localStorage).\n */\nexport const WebStorage = {\n\tname: 'WebStorage',\n\n\toptions: {\n\t\tstorage: {\n\t\t\ttype: 'object',\n\t\t\trequired: false,\n\t\t\tdescription: 'The Storage to use. Defaults to globalThis.localStorage.',\n\t\t},\n\t},\n\n\tisAvailable(storage: Storage = globalThis.localStorage): boolean {\n\t\treturn storage instanceof globalThis.Storage;\n\t},\n\n\tcreate({ storage = globalThis.localStorage }: WebStorageOptions) {\n\t\treturn new StoreFS(new WebStorageStore(storage));\n\t},\n} as const satisfies Backend<StoreFS, WebStorageOptions>;\n"],
5
+ "mappings": "gfAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,eAAAE,EAAA,mBAAAC,EAAA,yBAAAC,EAAA,cAAAC,EAAA,gBAAAC,EAAA,eAAAC,EAAA,oBAAAC,ICAA,IAAOC,GAAQ,MACT,CAAE,MAAAC,EAAO,iBAAAC,GAAkB,YAAAC,GAAa,cAAAC,GAAe,IAAAC,GAAK,OAAAC,GAAQ,MAAAC,EAAO,WAAAC,EAAY,MAAAC,GAAO,QAAAC,GAAS,KAAAC,GAAM,WAAAC,EAAY,SAAAC,EAAU,cAAAC,GAAe,MAAAC,GAAO,QAAAC,GAAS,MAAAC,GAAO,UAAAC,GAAW,QAAAC,GAAS,WAAAC,GAAY,QAAAC,GAAS,UAAAC,GAAW,KAAAC,GAAM,OAAAC,GAAQ,SAAAC,GAAU,YAAAC,EAA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P,CACD,MAAM,IAAIF,EAAWC,EAAM,IAAK,wBAA0BL,EAAM,KAAOM,CAAC,CACzE,CACD,CACD,EA9CaC,EAAAX,EAAA,mBA6DN,IAAME,EAAa,CACzB,KAAM,aAEN,QAAS,CACR,QAAS,CACR,KAAM,SACN,SAAU,GACV,YAAa,0DACd,CACD,EAEA,YAAYU,EAAmB,WAAW,aAAuB,CAChE,OAAOA,aAAmB,WAAW,OACtC,EAEA,OAAO,CAAE,QAAAA,EAAU,WAAW,YAAa,EAAsB,CAChE,OAAO,IAAIC,EAAQ,IAAIb,EAAgBY,CAAO,CAAC,CAChD,CACD",
6
+ "names": ["src_exports", "__export", "IndexedDB", "IndexedDBStore", "IndexedDBTransaction", "WebAccess", "WebAccessFS", "WebStorage", "WebStorageStore", "core_default", "Async", "AsyncTransaction", "BigIntStats", "BigIntStatsFs", "Dir", "Dirent", "Errno", "ErrnoError", "Fetch", "FetchFS", "File", "FileSystem", "InMemory", "InMemoryStore", "Index", "IndexFS", "Inode", "MutexLock", "Mutexed", "NoSyncFile", "Overlay", "OverlayFS", "Port", "PortFS", "PortFile", "PreloadFile", "ReadStream", "Readonly", "SimpleAsyncStore", "SimpleTransaction", "Stats", "StatsCommon", "StatsFs", "StoreFS", "Sync", "SyncTransaction", "Transaction", "UnmutexedOverlayFS", "WriteStream", "ZenFsType", "_InMemory", "_Port", "_toUnixTimestamp", "access", "accessSync", "appendFile", "appendFileSync", "attachFS", "checkOptions", "chmod", "chmodSync", "chown", "chownSync", "close", "closeSync", "configure", "configureSingle", "constants", "copyFile", "copyFileSync", "cp", "cpSync", "createReadStream", "createWriteStream", "decode", "decodeDirListing", "detachFS", "encode", "encodeDirListing", "errorMessages", "exists", "existsSync", "fchmod", "fchmodSync", "fchown", "fchownSync", "fdatasync", "fdatasyncSync", "flagToMode", "flagToNumber", "flagToString", "fs", "fstat", "fstatSync", "fsync", "fsyncSync", "ftruncate", "ftruncateSync", "futimes", "futimesSync", "handleRequest", "isAppendable", "isBackend", "isBackendConfig", "isExclusive", "isReadable", "isSynchronous", "isTruncating", "isWriteable", "lchmod", "lchmodSync", "lchown", "lchownSync", "levenshtein", "link", "linkSync", "lopenSync", "lstat", "lstatSync", "lutimes", "lutimesSync", "mkdir", "mkdirSync", "mkdirpSync", "mkdtemp", "mkdtempSync", "mount", "mountObject", "mounts", "normalizeMode", "normalizeOptions", "normalizePath", "normalizeTime", "open", "openAsBlob", "openSync", "opendir", "opendirSync", "parseFlag", "promises", "randomIno", "read", "readFile", "readFileSync", "readSync", "readdir", "readdirSync", "readlink", "readlinkSync", "readv", "readvSync", "realpath", "realpathSync", "rename", "renameSync", "resolveMountConfig", "resolveRemoteMount", "rm", "rmSync", "rmdir", "rmdirSync", "rootCred", "rootIno", "setImmediate", "size_max", "stat", "statSync", "statfs", "statfsSync", "symlink", "symlinkSync", "truncate", "truncateSync", "umount", "unlink", "unlinkSync", "unwatchFile", "utimes", "utimesSync", "version", "watch", "watchFile", "write", "writeFile", "writeFileSync", "writeSync", "writev", "writevSync", "normalizeString", "path", "allowAboveRoot", "res", "lastSegmentLength", "lastSlash", "dots", "char", "i", "lastSlashIndex", "__name", "normalize", "path", "isAbsolute", "trailingSeparator", "normalizeString", "__name", "join", "parts", "joined", "normalize", "__name", "dirname", "path", "hasRoot", "end", "matchedSlash", "i", "__name", "basename", "suffix", "start", "extIdx", "firstNonSlashEnd", "errnoForDOMException", "ex", "__name", "convertException", "path", "syscall", "ErrnoError", "code", "Errno", "error", "WebAccessFS", "Async", "FileSystem", "InMemory", "handle", "path", "data", "stats", "currentStats", "oldPath", "newPath", "files", "file", "join", "oldFile", "destFolder", "dirname", "writable", "basename", "ex", "convertException", "ErrnoError", "Errno", "flag", "Stats", "lastModified", "size", "PreloadFile", "srcpath", "keys", "key", "walked", "part", "dirHandle", "_ex", "fileHandle", "__name", "WebAccess", "options", "Errno", "errorMessages", "ErrnoError", "json", "err", "code", "path", "syscall", "errno", "message", "__name", "_resolve", "_reject", "resolve", "reject", "Transaction", "store", "__name", "AsyncTransaction", "Transaction", "ErrnoError", "__name", "wrap", "request", "resolve", "reject", "e", "convertException", "__name", "IndexedDBTransaction", "AsyncTransaction", "tx", "store", "key", "data", "createDB", "name", "indexedDB", "req", "db", "IndexedDBStore", "ErrnoError", "IndexedDB", "idbFactory", "options", "fs", "Async", "StoreFS", "InMemory", "WebStorageStore", "_storage", "WebStorage", "SimpleTransaction", "key", "data", "encode", "decode", "ErrnoError", "Errno", "e", "__name", "storage", "StoreFS"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zenfs/dom",
3
- "version": "0.2.14",
3
+ "version": "0.2.15",
4
4
  "description": "DOM backends for ZenFS",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -45,10 +45,10 @@
45
45
  "eslint": "^8.36.0",
46
46
  "prettier": "^3.2.5",
47
47
  "typedoc": "^0.25.1",
48
- "typescript": "5.2.2"
48
+ "typescript": "^5.4.5"
49
49
  },
50
50
  "peerDependencies": {
51
- "@zenfs/core": ">=0.12.10"
51
+ "@zenfs/core": ">=0.17.1"
52
52
  },
53
53
  "keywords": [
54
54
  "filesystem",
package/src/IndexedDB.ts CHANGED
@@ -41,10 +41,18 @@ export class IndexedDBTransaction extends AsyncTransaction<IndexedDBStore> {
41
41
  }
42
42
 
43
43
  public async commit(): Promise<void> {
44
+ if (this.done) {
45
+ return;
46
+ }
47
+ this.done = true;
44
48
  this.tx.commit();
45
49
  }
46
50
 
47
51
  public async abort(): Promise<void> {
52
+ if (this.done) {
53
+ return;
54
+ }
55
+ this.done = true;
48
56
  try {
49
57
  this.tx.abort();
50
58
  } catch (e) {