@zenfs/dom 0.2.4 → 0.2.5

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.
package/dist/access.js CHANGED
@@ -45,8 +45,7 @@ export class WebAccessFS extends Async(FileSystem) {
45
45
  }
46
46
  const newFile = await destFolder.getFileHandle(basename(newPath), { create: true });
47
47
  const writable = await newFile.createWritable();
48
- const buffer = await oldFile.arrayBuffer();
49
- await writable.write(buffer);
48
+ await writable.write(await oldFile.arrayBuffer());
50
49
  writable.close();
51
50
  await this.unlink(oldPath);
52
51
  }
@@ -83,12 +82,18 @@ export class WebAccessFS extends Async(FileSystem) {
83
82
  }
84
83
  async openFile(path, flag) {
85
84
  const handle = await this.getHandle(path);
86
- if (handle instanceof FileSystemFileHandle) {
85
+ if (!(handle instanceof FileSystemFileHandle)) {
86
+ throw ApiError.With('EISDIR', path, 'openFile');
87
+ }
88
+ try {
87
89
  const file = await handle.getFile();
88
90
  const data = new Uint8Array(await file.arrayBuffer());
89
91
  const stats = new Stats({ mode: 0o777 | FileType.FILE, size: file.size, mtimeMs: file.lastModified });
90
92
  return new PreloadFile(this, path, flag, stats, data);
91
93
  }
94
+ catch (ex) {
95
+ throw convertException(ex, path, 'openFile');
96
+ }
92
97
  }
93
98
  async unlink(path) {
94
99
  const handle = await this.getHandle(dirname(path));
@@ -113,9 +118,10 @@ export class WebAccessFS extends Async(FileSystem) {
113
118
  throw ApiError.With('EEXIST', path, 'mkdir');
114
119
  }
115
120
  const handle = await this.getHandle(dirname(path));
116
- if (handle instanceof FileSystemDirectoryHandle) {
117
- await handle.getDirectoryHandle(basename(path), { create: true });
121
+ if (!(handle instanceof FileSystemDirectoryHandle)) {
122
+ throw ApiError.With('ENOTDIR', path, 'mkdir');
118
123
  }
124
+ await handle.getDirectoryHandle(basename(path), { create: true });
119
125
  }
120
126
  async readdir(path) {
121
127
  const handle = await this.getHandle(path);
@@ -1,2 +1,2 @@
1
- var ZenFS_DOM=(()=>{var F=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var a=(r,e)=>F(r,"name",{value:e,configurable:!0});var $=(r,e)=>{for(var t in e)F(r,t,{get:e[t],enumerable:!0})},R=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of W(e))!U.call(r,i)&&i!==t&&F(r,i,{get:()=>e[i],enumerable:!(n=C(e,i))||n.enumerable});return r};var j=r=>R(F({},"__esModule",{value:!0}),r);var X={};$(X,{IndexedDB:()=>P,IndexedDBStore:()=>u,IndexedDBTransaction:()=>b,WebAccess:()=>V,WebAccessFS:()=>h,WebStorage:()=>z,WebStorageStore:()=>w});var Q=ZenFS,{ActionType:G,ApiError:l,Async:T,AsyncIndexFS:J,AsyncStoreFS:v,BigIntStats:K,BigIntStatsFs:ee,Dir:te,Dirent:re,ErrorCode:d,File:ne,FileIndex:ie,FileSystem:A,FileType:I,InMemory:H,InMemoryStore:se,IndexDirInode:oe,IndexFS:ae,IndexFileInode:ce,IndexInode:le,Inode:de,LockedFS:fe,Mutex:ue,NoSyncFile:me,Overlay:ye,OverlayFS:Se,PreloadFile:O,ReadStream:ge,Readonly:pe,SimpleSyncTransaction:N,Stats:x,StatsCommon:he,StatsFs:be,Sync:we,SyncIndexFS:Ee,SyncStoreFS:B,UnlockedOverlayFS:Fe,WriteStream:Ie,_toUnixTimestamp:xe,access:De,accessSync:ke,appendFile:Te,appendFileSync:ve,checkOptions:Ae,chmod:He,chmodSync:Oe,chown:Ne,chownSync:Be,close:Me,closeSync:_e,configure:Pe,constants:ze,copyFile:Ce,copyFileSync:We,cp:Ue,cpSync:$e,createBackend:Re,createReadStream:je,createWriteStream:Le,decode:M,decodeDirListing:qe,encode:_,encodeDirListing:Ye,errorMessages:Ve,exists:Xe,existsSync:Ze,fchmod:Qe,fchmodSync:Ge,fchown:Je,fchownSync:Ke,fdatasync:et,fdatasyncSync:tt,flagToMode:rt,flagToNumber:nt,flagToString:it,fs:st,fstat:ot,fstatSync:at,fsync:ct,fsyncSync:lt,ftruncate:dt,ftruncateSync:ft,futimes:ut,futimesSync:mt,isAppendable:yt,isBackend:St,isBackendConfig:gt,isExclusive:pt,isReadable:ht,isSynchronous:bt,isTruncating:wt,isWriteable:Et,lchmod:Ft,lchmodSync:It,lchown:xt,lchownSync:Dt,levenshtein:kt,link:Tt,linkSync:vt,lopenSync:At,lstat:Ht,lstatSync:Ot,lutimes:Nt,lutimesSync:Bt,mkdir:Mt,mkdirSync:_t,mkdirpSync:Pt,mkdtemp:zt,mkdtempSync:Ct,mount:Wt,mountMapping:Ut,mounts:$t,nop:Rt,normalizeMode:jt,normalizeOptions:Lt,normalizePath:qt,normalizeTime:Yt,open:Vt,openAsBlob:Xt,openSync:Zt,opendir:Qt,opendirSync:Gt,parseFlag:Jt,pathExistsAction:Kt,pathNotExistsAction:er,promises:tr,randomIno:rr,read:nr,readFile:ir,readFileSync:sr,readSync:or,readdir:ar,readdirSync:cr,readlink:lr,readlinkSync:dr,readv:fr,readvSync:ur,realpath:mr,realpathSync:yr,rename:Sr,renameSync:gr,resolveMountConfig:pr,rm:hr,rmSync:br,rmdir:wr,rmdirSync:Er,rootCred:Fr,rootIno:Ir,setImmediate:xr,size_max:Dr,stat:kr,statSync:Tr,statfs:vr,statfsSync:Ar,symlink:Hr,symlinkSync:Or,truncate:Nr,truncateSync:Br,umount:Mr,unlink:_r,unlinkSync:Pr,unwatchFile:zr,utimes:Cr,utimesSync:Wr,watch:Ur,watchFile:$r,write:Rr,writeFile:jr,writeFileSync:Lr,writeSync:qr,writev:Yr,writevSync:Vr}=ZenFS;function y(r,e){if(typeof r!="string")throw new TypeError(`"${e}" is not a string`)}a(y,"validateString");function L(r,e){let t="",n=0,i=-1,s=0,c="\0";for(let o=0;o<=r.length;++o){if(o<r.length)c=r[o];else{if(c=="/")break;c="/"}if(c=="/"){if(!(i===o-1||s===1))if(s===2){if(t.length<2||n!==2||t.at(-1)!=="."||t.at(-2)!=="."){if(t.length>2){let E=t.lastIndexOf("/");E===-1?(t="",n=0):(t=t.slice(0,E),n=t.length-1-t.lastIndexOf("/")),i=o,s=0;continue}else if(t.length!==0){t="",n=0,i=o,s=0;continue}}e&&(t+=t.length>0?"/..":"..",n=2)}else t.length>0?t+="/"+r.slice(i+1,o):t=r.slice(i+1,o),n=o-i-1;i=o,s=0}else c==="."&&s!==-1?++s:s=-1}return t}a(L,"normalizeString");function q(r){if(y(r,"path"),r.length===0)return".";let e=r[0]==="/",t=r.at(-1)==="/";return r=L(r,!e),r.length===0?e?"/":t?"./":".":(t&&(r+="/"),e?`/${r}`:r)}a(q,"normalize");function S(...r){if(r.length===0)return".";let e;for(let t=0;t<r.length;++t){let n=r[t];y(n,"path"),n.length>0&&(e===void 0?e=n:e+=`/${n}`)}return e===void 0?".":q(e)}a(S,"join");function g(r){if(y(r,"path"),r.length===0)return".";let e=r[0]==="/",t=-1,n=!0;for(let i=r.length-1;i>=1;--i)if(r[i]==="/"){if(!n){t=i;break}}else n=!1;return t===-1?e?"/":".":e&&t===1?"//":r.slice(0,t)}a(g,"dirname");function p(r,e){e!==void 0&&y(e,"ext"),y(r,"path");let t=0,n=-1,i=!0;if(e!==void 0&&e.length>0&&e.length<=r.length){if(e===r)return"";let s=e.length-1,c=-1;for(let o=r.length-1;o>=0;--o)if(r[o]==="/"){if(!i){t=o+1;break}}else c===-1&&(i=!1,c=o+1),s>=0&&(r[o]===e[s]?--s===-1&&(n=o):(s=-1,n=c));return t===n?n=c:n===-1&&(n=r.length),r.slice(t,n)}for(let s=r.length-1;s>=0;--s)if(r[s]==="/"){if(!i){t=s+1;break}}else n===-1&&(i=!1,n=s+1);return n===-1?"":r.slice(t,n)}a(p,"basename");function Y(r){switch(r.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"}}a(Y,"errnoForDOMException");function f(r,e,t){if(r instanceof l)return r;let n=r instanceof DOMException?d[Y(r)]:d.EIO,i=new l(n,r.message,e,t);return i.stack=r.stack,i.cause=r.cause,i}a(f,"convertException");var h=class extends T(A){_handles=new Map;_sync;constructor({handle:e}){super(),this._handles.set("/",e),this._sync=H.create({name:"accessfs-cache"})}metadata(){return{...super.metadata(),name:"WebAccess"}}async sync(e,t,n){let i=await this.stat(e);n.mtime!==i.mtime&&await this.writeFile(e,t)}async rename(e,t){try{let n=await this.getHandle(e);if(n instanceof FileSystemDirectoryHandle){let D=await this.readdir(e);if(await this.mkdir(t),D.length==0)await this.unlink(e);else for(let k of D)await this.rename(S(e,k),S(t,k)),await this.unlink(e)}if(!(n instanceof FileSystemFileHandle))return;let i=await n.getFile(),s=await this.getHandle(g(t));if(!(s instanceof FileSystemDirectoryHandle))return;let o=await(await s.getFileHandle(p(t),{create:!0})).createWritable(),E=await i.arrayBuffer();await o.write(E),o.close(),await this.unlink(e)}catch(n){throw f(n,e,"rename")}}async writeFile(e,t){let n=await this.getHandle(g(e));if(!(n instanceof FileSystemDirectoryHandle))return;let s=await(await n.getFileHandle(p(e),{create:!0})).createWritable();await s.write(t),await s.close()}async createFile(e,t){return await this.writeFile(e,new Uint8Array),this.openFile(e,t)}async stat(e){let t=await this.getHandle(e);if(!t)throw l.With("ENOENT",e,"stat");if(t instanceof FileSystemDirectoryHandle)return new x({mode:511|I.DIRECTORY,size:4096});if(t instanceof FileSystemFileHandle){let{lastModified:n,size:i}=await t.getFile();return new x({mode:511|I.FILE,size:i,mtimeMs:n})}}async openFile(e,t){let n=await this.getHandle(e);if(n instanceof FileSystemFileHandle){let i=await n.getFile(),s=new Uint8Array(await i.arrayBuffer()),c=new x({mode:511|I.FILE,size:i.size,mtimeMs:i.lastModified});return new O(this,e,t,c,s)}}async unlink(e){let t=await this.getHandle(g(e));if(t instanceof FileSystemDirectoryHandle)try{await t.removeEntry(p(e),{recursive:!0})}catch(n){throw f(n,e,"unlink")}}async link(e){throw l.With("ENOSYS",e,"WebAccessFS.link")}async rmdir(e){return this.unlink(e)}async mkdir(e){if(await this.getHandle(e))throw l.With("EEXIST",e,"mkdir");let n=await this.getHandle(g(e));n instanceof FileSystemDirectoryHandle&&await n.getDirectoryHandle(p(e),{create:!0})}async readdir(e){let t=await this.getHandle(e);if(!(t instanceof FileSystemDirectoryHandle))throw l.With("ENOTDIR",e,"readdir");let n=[];for await(let i of t.keys())n.push(S(e,i));return n}async getHandle(e){if(this._handles.has(e))return this._handles.get(e);let t="/";for(let n of e.split("/").slice(1)){let i=this._handles.get(t);if(!(i instanceof FileSystemDirectoryHandle))throw l.With("ENOTDIR",t,"getHandle");t=S(t,n);try{let s=await i.getDirectoryHandle(n);this._handles.set(t,s)}catch(s){if(s.name=="TypeMismatchError")try{let c=await i.getFileHandle(n);this._handles.set(t,c)}catch(c){f(c,t,"getHandle")}if(s.name==="TypeError")throw new l(d.ENOENT,s.message,t,"getHandle");f(s,t,"getHandle")}}return this._handles.get(e)}};a(h,"WebAccessFS");var V={name:"WebAccess",options:{handle:{type:"object",required:!0,description:"The directory handle to use for the root"}},isAvailable(){return typeof FileSystemHandle=="function"},create(r){return new h(r)}};function m(r){return new Promise((e,t)=>{r.onsuccess=()=>e(r.result),r.onerror=n=>{n.preventDefault(),t(f(r.error))}})}a(m,"wrap");var b=class{constructor(e,t){this.tx=e;this.store=t}get(e){return m(this.store.get(e.toString()))}async put(e,t,n){return await m(this.store[n?"put":"add"](t,e.toString())),!0}remove(e){return m(this.store.delete(e.toString()))}async commit(){}async abort(){try{this.tx.abort()}catch(e){throw f(e)}}};a(b,"IndexedDBTransaction");var u=class{constructor(e,t){this.db=e;this.storeName=t}static async create(e,t=globalThis.indexedDB){let n=t.open(e,1);n.onupgradeneeded=()=>{let s=n.result;s.objectStoreNames.contains(e)&&s.deleteObjectStore(e),s.createObjectStore(e)};let i=await m(n);return new u(i,e)}get name(){return P.name+":"+this.storeName}clear(){return m(this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).clear())}beginTransaction(){let e=this.db.transaction(this.storeName,"readwrite");return new b(e,e.objectStore(this.storeName))}};a(u,"IndexedDBStore");var P={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."},cacheSize:{type:"number",required:!1,description:"The size of the inode cache. Defaults to 100. A size of 0 or below disables caching."},idbFactory:{type:"object",required:!1,description:"The IDBFactory to use. Defaults to globalThis.indexedDB."}},async isAvailable(r=globalThis.indexedDB){try{if(!(r instanceof IDBFactory))return!1;let e=r.open("__zenfs_test");return await m(e),r.deleteDatabase("__zenfs_test"),!0}catch{return r.deleteDatabase("__zenfs_test"),!1}},create(r){let e=u.create(r.storeName||"zenfs",r.idbFactory);return new v({...r,store:e})}};var w=class{constructor(e){this._storage=e}get name(){return z.name}clear(){this._storage.clear()}beginTransaction(){return new N(this)}get(e){let t=this._storage.getItem(e.toString());if(typeof t=="string")return _(t)}put(e,t,n){try{return!n&&this._storage.getItem(e.toString())!==null?!1:(this._storage.setItem(e.toString(),M(t)),!0)}catch{throw new l(d.ENOSPC,"Storage is full.")}}remove(e){try{this._storage.removeItem(e.toString())}catch(t){throw new l(d.EIO,"Unable to delete key "+e+": "+t)}}};a(w,"WebStorageStore");var z={name:"WebStorage",options:{storage:{type:"object",required:!1,description:"The Storage to use. Defaults to globalThis.localStorage."}},isAvailable(r=globalThis.localStorage){return r instanceof globalThis.Storage},create({storage:r=globalThis.localStorage}){return new B({store:new w(r)})}};return j(X);})();
1
+ var ZenFS_DOM=(()=>{var F=Object.defineProperty;var z=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var a=(r,e)=>F(r,"name",{value:e,configurable:!0});var R=(r,e)=>{for(var t in e)F(r,t,{get:e[t],enumerable:!0})},U=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of W(e))!C.call(r,i)&&i!==t&&F(r,i,{get:()=>e[i],enumerable:!(n=z(e,i))||n.enumerable});return r};var $=r=>U(F({},"__esModule",{value:!0}),r);var V={};R(V,{IndexedDB:()=>_,IndexedDBStore:()=>u,IndexedDBTransaction:()=>w,WebAccess:()=>Y,WebAccessFS:()=>b,WebStorage:()=>P,WebStorageStore:()=>E});var Z=ZenFS,{ActionType:Q,ApiError:l,Async:k,AsyncIndexFS:G,AsyncStoreFS:T,BigIntStats:J,BigIntStatsFs:K,Dir:ee,Dirent:te,ErrorCode:f,File:re,FileIndex:ne,FileSystem:v,FileType:I,InMemory:A,InMemoryStore:ie,IndexDirInode:oe,IndexFS:se,IndexFileInode:ae,IndexInode:ce,Inode:le,LockedFS:de,Mutex:fe,NoSyncFile:ue,Overlay:me,OverlayFS:ye,PreloadFile:H,ReadStream:Se,Readonly:ge,SimpleSyncTransaction:O,Stats:x,StatsCommon:pe,StatsFs:he,Sync:be,SyncIndexFS:we,SyncStoreFS:N,UnlockedOverlayFS:Ee,WriteStream:Fe,_toUnixTimestamp:Ie,access:xe,accessSync:De,appendFile:ke,appendFileSync:Te,checkOptions:ve,chmod:Ae,chmodSync:He,chown:Oe,chownSync:Ne,close:Be,closeSync:Me,configure:_e,constants:Pe,copyFile:ze,copyFileSync:We,cp:Ce,cpSync:Re,createBackend:Ue,createReadStream:$e,createWriteStream:je,decode:B,decodeDirListing:Le,encode:M,encodeDirListing:qe,errorMessages:Ye,exists:Ve,existsSync:Xe,fchmod:Ze,fchmodSync:Qe,fchown:Ge,fchownSync:Je,fdatasync:Ke,fdatasyncSync:et,flagToMode:tt,flagToNumber:rt,flagToString:nt,fs:it,fstat:ot,fstatSync:st,fsync:at,fsyncSync:ct,ftruncate:lt,ftruncateSync:dt,futimes:ft,futimesSync:ut,isAppendable:mt,isBackend:yt,isBackendConfig:St,isExclusive:gt,isReadable:pt,isSynchronous:ht,isTruncating:bt,isWriteable:wt,lchmod:Et,lchmodSync:Ft,lchown:It,lchownSync:xt,levenshtein:Dt,link:kt,linkSync:Tt,lopenSync:vt,lstat:At,lstatSync:Ht,lutimes:Ot,lutimesSync:Nt,mkdir:Bt,mkdirSync:Mt,mkdirpSync:_t,mkdtemp:Pt,mkdtempSync:zt,mount:Wt,mountMapping:Ct,mounts:Rt,nop:Ut,normalizeMode:$t,normalizeOptions:jt,normalizePath:Lt,normalizeTime:qt,open:Yt,openAsBlob:Vt,openSync:Xt,opendir:Zt,opendirSync:Qt,parseFlag:Gt,pathExistsAction:Jt,pathNotExistsAction:Kt,promises:er,randomIno:tr,read:rr,readFile:nr,readFileSync:ir,readSync:or,readdir:sr,readdirSync:ar,readlink:cr,readlinkSync:lr,readv:dr,readvSync:fr,realpath:ur,realpathSync:mr,rename:yr,renameSync:Sr,resolveMountConfig:gr,rm:pr,rmSync:hr,rmdir:br,rmdirSync:wr,rootCred:Er,rootIno:Fr,setImmediate:Ir,size_max:xr,stat:Dr,statSync:kr,statfs:Tr,statfsSync:vr,symlink:Ar,symlinkSync:Hr,truncate:Or,truncateSync:Nr,umount:Br,unlink:Mr,unlinkSync:_r,unwatchFile:Pr,utimes:zr,utimesSync:Wr,watch:Cr,watchFile:Rr,write:Ur,writeFile:$r,writeFileSync:jr,writeSync:Lr,writev:qr,writevSync:Yr}=ZenFS;function S(r,e){if(typeof r!="string")throw new TypeError(`"${e}" is not a string`)}a(S,"validateString");function j(r,e){let t="",n=0,i=-1,o=0,c="\0";for(let s=0;s<=r.length;++s){if(s<r.length)c=r[s];else{if(c=="/")break;c="/"}if(c=="/"){if(!(i===s-1||o===1))if(o===2){if(t.length<2||n!==2||t.at(-1)!=="."||t.at(-2)!=="."){if(t.length>2){let y=t.lastIndexOf("/");y===-1?(t="",n=0):(t=t.slice(0,y),n=t.length-1-t.lastIndexOf("/")),i=s,o=0;continue}else if(t.length!==0){t="",n=0,i=s,o=0;continue}}e&&(t+=t.length>0?"/..":"..",n=2)}else t.length>0?t+="/"+r.slice(i+1,s):t=r.slice(i+1,s),n=s-i-1;i=s,o=0}else c==="."&&o!==-1?++o:o=-1}return t}a(j,"normalizeString");function L(r){if(S(r,"path"),r.length===0)return".";let e=r[0]==="/",t=r.at(-1)==="/";return r=j(r,!e),r.length===0?e?"/":t?"./":".":(t&&(r+="/"),e?`/${r}`:r)}a(L,"normalize");function g(...r){if(r.length===0)return".";let e;for(let t=0;t<r.length;++t){let n=r[t];S(n,"path"),n.length>0&&(e===void 0?e=n:e+=`/${n}`)}return e===void 0?".":L(e)}a(g,"join");function p(r){if(S(r,"path"),r.length===0)return".";let e=r[0]==="/",t=-1,n=!0;for(let i=r.length-1;i>=1;--i)if(r[i]==="/"){if(!n){t=i;break}}else n=!1;return t===-1?e?"/":".":e&&t===1?"//":r.slice(0,t)}a(p,"dirname");function h(r,e){e!==void 0&&S(e,"ext"),S(r,"path");let t=0,n=-1,i=!0;if(e!==void 0&&e.length>0&&e.length<=r.length){if(e===r)return"";let o=e.length-1,c=-1;for(let s=r.length-1;s>=0;--s)if(r[s]==="/"){if(!i){t=s+1;break}}else c===-1&&(i=!1,c=s+1),o>=0&&(r[s]===e[o]?--o===-1&&(n=s):(o=-1,n=c));return t===n?n=c:n===-1&&(n=r.length),r.slice(t,n)}for(let o=r.length-1;o>=0;--o)if(r[o]==="/"){if(!i){t=o+1;break}}else n===-1&&(i=!1,n=o+1);return n===-1?"":r.slice(t,n)}a(h,"basename");function q(r){switch(r.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"}}a(q,"errnoForDOMException");function d(r,e,t){if(r instanceof l)return r;let n=r instanceof DOMException?f[q(r)]:f.EIO,i=new l(n,r.message,e,t);return i.stack=r.stack,i.cause=r.cause,i}a(d,"convertException");var b=class extends k(v){_handles=new Map;_sync;constructor({handle:e}){super(),this._handles.set("/",e),this._sync=A.create({name:"accessfs-cache"})}metadata(){return{...super.metadata(),name:"WebAccess"}}async sync(e,t,n){let i=await this.stat(e);n.mtime!==i.mtime&&await this.writeFile(e,t)}async rename(e,t){try{let n=await this.getHandle(e);if(n instanceof FileSystemDirectoryHandle){let y=await this.readdir(e);if(await this.mkdir(t),y.length==0)await this.unlink(e);else for(let D of y)await this.rename(g(e,D),g(t,D)),await this.unlink(e)}if(!(n instanceof FileSystemFileHandle))return;let i=await n.getFile(),o=await this.getHandle(p(t));if(!(o instanceof FileSystemDirectoryHandle))return;let s=await(await o.getFileHandle(h(t),{create:!0})).createWritable();await s.write(await i.arrayBuffer()),s.close(),await this.unlink(e)}catch(n){throw d(n,e,"rename")}}async writeFile(e,t){let n=await this.getHandle(p(e));if(!(n instanceof FileSystemDirectoryHandle))return;let o=await(await n.getFileHandle(h(e),{create:!0})).createWritable();await o.write(t),await o.close()}async createFile(e,t){return await this.writeFile(e,new Uint8Array),this.openFile(e,t)}async stat(e){let t=await this.getHandle(e);if(!t)throw l.With("ENOENT",e,"stat");if(t instanceof FileSystemDirectoryHandle)return new x({mode:511|I.DIRECTORY,size:4096});if(t instanceof FileSystemFileHandle){let{lastModified:n,size:i}=await t.getFile();return new x({mode:511|I.FILE,size:i,mtimeMs:n})}}async openFile(e,t){let n=await this.getHandle(e);if(!(n instanceof FileSystemFileHandle))throw l.With("EISDIR",e,"openFile");try{let i=await n.getFile(),o=new Uint8Array(await i.arrayBuffer()),c=new x({mode:511|I.FILE,size:i.size,mtimeMs:i.lastModified});return new H(this,e,t,c,o)}catch(i){throw d(i,e,"openFile")}}async unlink(e){let t=await this.getHandle(p(e));if(t instanceof FileSystemDirectoryHandle)try{await t.removeEntry(h(e),{recursive:!0})}catch(n){throw d(n,e,"unlink")}}async link(e){throw l.With("ENOSYS",e,"WebAccessFS.link")}async rmdir(e){return this.unlink(e)}async mkdir(e){if(await this.getHandle(e))throw l.With("EEXIST",e,"mkdir");let n=await this.getHandle(p(e));if(!(n instanceof FileSystemDirectoryHandle))throw l.With("ENOTDIR",e,"mkdir");await n.getDirectoryHandle(h(e),{create:!0})}async readdir(e){let t=await this.getHandle(e);if(!(t instanceof FileSystemDirectoryHandle))throw l.With("ENOTDIR",e,"readdir");let n=[];for await(let i of t.keys())n.push(g(e,i));return n}async getHandle(e){if(this._handles.has(e))return this._handles.get(e);let t="/";for(let n of e.split("/").slice(1)){let i=this._handles.get(t);if(!(i instanceof FileSystemDirectoryHandle))throw l.With("ENOTDIR",t,"getHandle");t=g(t,n);try{let o=await i.getDirectoryHandle(n);this._handles.set(t,o)}catch(o){if(o.name=="TypeMismatchError")try{let c=await i.getFileHandle(n);this._handles.set(t,c)}catch(c){d(c,t,"getHandle")}if(o.name==="TypeError")throw new l(f.ENOENT,o.message,t,"getHandle");d(o,t,"getHandle")}}return this._handles.get(e)}};a(b,"WebAccessFS");var Y={name:"WebAccess",options:{handle:{type:"object",required:!0,description:"The directory handle to use for the root"}},isAvailable(){return typeof FileSystemHandle=="function"},create(r){return new b(r)}};function m(r){return new Promise((e,t)=>{r.onsuccess=()=>e(r.result),r.onerror=n=>{n.preventDefault(),t(d(r.error))}})}a(m,"wrap");var w=class{constructor(e,t){this.tx=e;this.store=t}get(e){return m(this.store.get(e.toString()))}async put(e,t,n){return await m(this.store[n?"put":"add"](t,e.toString())),!0}remove(e){return m(this.store.delete(e.toString()))}async commit(){}async abort(){try{this.tx.abort()}catch(e){throw d(e)}}};a(w,"IndexedDBTransaction");var u=class{constructor(e,t){this.db=e;this.storeName=t}static async create(e,t=globalThis.indexedDB){let n=t.open(e,1);n.onupgradeneeded=()=>{let o=n.result;o.objectStoreNames.contains(e)&&o.deleteObjectStore(e),o.createObjectStore(e)};let i=await m(n);return new u(i,e)}get name(){return _.name+":"+this.storeName}clear(){return m(this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).clear())}beginTransaction(){let e=this.db.transaction(this.storeName,"readwrite");return new w(e,e.objectStore(this.storeName))}};a(u,"IndexedDBStore");var _={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."},cacheSize:{type:"number",required:!1,description:"The size of the inode cache. Defaults to 100. A size of 0 or below disables caching."},idbFactory:{type:"object",required:!1,description:"The IDBFactory to use. Defaults to globalThis.indexedDB."}},async isAvailable(r=globalThis.indexedDB){try{if(!(r instanceof IDBFactory))return!1;let e=r.open("__zenfs_test");return await m(e),r.deleteDatabase("__zenfs_test"),!0}catch{return r.deleteDatabase("__zenfs_test"),!1}},create(r){let e=u.create(r.storeName||"zenfs",r.idbFactory);return new T({...r,store:e})}};var E=class{constructor(e){this._storage=e}get name(){return P.name}clear(){this._storage.clear()}beginTransaction(){return new O(this)}get(e){let t=this._storage.getItem(e.toString());if(typeof t=="string")return M(t)}put(e,t,n){try{return!n&&this._storage.getItem(e.toString())!==null?!1:(this._storage.setItem(e.toString(),B(t)),!0)}catch{throw new l(f.ENOSPC,"Storage is full.")}}remove(e){try{this._storage.removeItem(e.toString())}catch(t){throw new l(f.EIO,"Unable to delete key "+e+": "+t)}}};a(E,"WebStorageStore");var P={name:"WebStorage",options:{storage:{type:"object",required:!1,description:"The Storage to use. Defaults to globalThis.localStorage."}},isAvailable(r=globalThis.localStorage){return r instanceof globalThis.Storage},create({storage:r=globalThis.localStorage}){return new N({store:new E(r)})}};return $(V);})();
2
2
  //# sourceMappingURL=browser.min.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/index.ts", "global-externals:@zenfs/core", "../node_modules/@zenfs/core/dist/emulation/path.js", "../src/utils.ts", "../src/access.ts", "../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 { ActionType, ApiError, Async, AsyncIndexFS, AsyncStoreFS, BigIntStats, BigIntStatsFs, Dir, Dirent, ErrorCode, File, FileIndex, FileSystem, FileType, InMemory, InMemoryStore, IndexDirInode, IndexFS, IndexFileInode, IndexInode, Inode, LockedFS, Mutex, NoSyncFile, Overlay, OverlayFS, PreloadFile, ReadStream, Readonly, SimpleSyncTransaction, Stats, StatsCommon, StatsFs, Sync, SyncIndexFS, SyncStoreFS, UnlockedOverlayFS, WriteStream, _toUnixTimestamp, access, accessSync, appendFile, appendFileSync, checkOptions, chmod, chmodSync, chown, chownSync, close, closeSync, configure, constants, copyFile, copyFileSync, cp, cpSync, createBackend, createReadStream, createWriteStream, decode, decodeDirListing, 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, mountMapping, mounts, nop, normalizeMode, normalizeOptions, normalizePath, normalizeTime, open, openAsBlob, openSync, opendir, opendirSync, parseFlag, pathExistsAction, pathNotExistsAction, 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 { ActionType, ApiError, Async, AsyncIndexFS, AsyncStoreFS, BigIntStats, BigIntStatsFs, Dir, Dirent, ErrorCode, File, FileIndex, FileSystem, FileType, InMemory, InMemoryStore, IndexDirInode, IndexFS, IndexFileInode, IndexInode, Inode, LockedFS, Mutex, NoSyncFile, Overlay, OverlayFS, PreloadFile, ReadStream, Readonly, SimpleSyncTransaction, Stats, StatsCommon, StatsFs, Sync, SyncIndexFS, SyncStoreFS, UnlockedOverlayFS, WriteStream, _toUnixTimestamp, access, accessSync, appendFile, appendFileSync, checkOptions, chmod, chmodSync, chown, chownSync, close, closeSync, configure, constants, copyFile, copyFileSync, cp, cpSync, createBackend, createReadStream, createWriteStream, decode, decodeDirListing, 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, mountMapping, mounts, nop, normalizeMode, normalizeOptions, normalizePath, normalizeTime, open, openAsBlob, openSync, opendir, opendirSync, parseFlag, pathExistsAction, pathNotExistsAction, 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 validateString(str, name) {\n if (typeof str != 'string') {\n throw new TypeError(`\"${name}\" is not a string`);\n }\n}\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(...args) {\n let resolved = '';\n let absolute = false;\n for (let i = args.length - 1; i >= -1 && !absolute; i--) {\n const path = i >= 0 ? args[i] : cwd;\n validateString(path, `paths[${i}]`);\n // Skip empty entries\n if (!path.length) {\n continue;\n }\n resolved = `${path}/${resolved}`;\n absolute = path[0] == '/';\n }\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 > 0 ? resolved : '/';\n}\nexport function normalize(path) {\n validateString(path, 'path');\n if (path.length === 0)\n return '.';\n const isAbsolute = path[0] === '/';\n const trailingSeparator = path.at(-1) === '/';\n // Normalize the path\n path = normalizeString(path, !isAbsolute);\n if (path.length === 0) {\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 validateString(path, 'path');\n return path.length > 0 && path[0] === '/';\n}\nexport function join(...args) {\n if (args.length === 0)\n return '.';\n let joined;\n for (let i = 0; i < args.length; ++i) {\n const arg = args[i];\n validateString(arg, 'path');\n if (arg.length > 0) {\n if (joined === undefined)\n joined = arg;\n else\n joined += `/${arg}`;\n }\n }\n if (joined === undefined)\n return '.';\n return normalize(joined);\n}\nexport function relative(from, to) {\n validateString(from, 'from');\n validateString(to, '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 validateString(path, '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 if (suffix !== undefined)\n validateString(suffix, 'ext');\n validateString(path, 'path');\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 validateString(path, '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 validateString(path, 'path');\n const isAbsolute = path[0] === '/';\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 { ApiError, ErrorCode } from '@zenfs/core';\n\n/**\n * Converts a DOMException into an ErrorCode\n * @see https://developer.mozilla.org/Web/API/DOMException\n */\nfunction errnoForDOMException(ex: DOMException): keyof typeof ErrorCode {\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 * Handles converting errors, then rethrowing them\n */\nexport function convertException(ex: Error | ApiError | DOMException, path?: string, syscall?: string): ApiError {\n\tif (ex instanceof ApiError) {\n\t\treturn ex;\n\t}\n\n\tconst code = ex instanceof DOMException ? ErrorCode[errnoForDOMException(ex)] : ErrorCode.EIO;\n\tconst error = new ApiError(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 { ApiError, Async, ErrorCode, FileSystem, FileType, InMemory, PreloadFile, Stats } from '@zenfs/core';\nimport { basename, dirname, join } from '@zenfs/core/emulation/path.js';\nimport { 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;\n\n\tpublic constructor({ handle }: WebAccessOptions) {\n\t\tsuper();\n\t\tthis._handles.set('/', handle);\n\t\tthis._sync = InMemory.create({ name: 'accessfs-cache' });\n\t}\n\n\tpublic metadata(): FileSystemMetadata {\n\t\treturn {\n\t\t\t...super.metadata(),\n\t\t\tname: 'WebAccess',\n\t\t};\n\t}\n\n\tpublic async sync(p: string, data: Uint8Array, stats: Stats): Promise<void> {\n\t\tconst currentStats = await this.stat(p);\n\t\tif (stats.mtime !== currentStats!.mtime) {\n\t\t\tawait this.writeFile(p, 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\tconst buffer = await oldFile.arrayBuffer();\n\t\t\tawait writable.write(buffer);\n\n\t\t\twritable.close();\n\t\t\tawait this.unlink(oldPath);\n\t\t} catch (ex) {\n\t\t\tthrow convertException(ex, oldPath, 'rename');\n\t\t}\n\t}\n\n\tpublic async writeFile(fname: string, data: Uint8Array): Promise<void> {\n\t\tconst handle = await this.getHandle(dirname(fname));\n\t\tif (!(handle instanceof FileSystemDirectoryHandle)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst file = await handle.getFileHandle(basename(fname), { 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 ApiError.With('ENOENT', path, 'stat');\n\t\t}\n\t\tif (handle instanceof FileSystemDirectoryHandle) {\n\t\t\treturn new Stats({ mode: 0o777 | FileType.DIRECTORY, 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 | FileType.FILE, size, mtimeMs: lastModified });\n\t\t}\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\tconst file = await handle.getFile();\n\t\t\tconst data = new Uint8Array(await file.arrayBuffer());\n\t\t\tconst stats = new Stats({ mode: 0o777 | FileType.FILE, size: file.size, mtimeMs: file.lastModified });\n\t\t\treturn new PreloadFile(this, path, flag, stats, data);\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, path, 'unlink');\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic async link(srcpath: string): Promise<void> {\n\t\tthrow ApiError.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 ApiError.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\tawait handle.getDirectoryHandle(basename(path), { create: true });\n\t\t}\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 ApiError.With('ENOTDIR', path, 'readdir');\n\t\t}\n\t\tconst _keys: string[] = [];\n\t\tfor await (const key of handle.keys()) {\n\t\t\t_keys.push(join(path, 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 ApiError.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\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, 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 ApiError(ErrorCode.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);\n\t},\n} as const satisfies Backend;\n", "import type { AsyncStore, AsyncStoreOptions, AsyncTransaction, Backend, Ino } from '@zenfs/core';\nimport { AsyncStoreFS } from '@zenfs/core';\nimport { 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 implements AsyncTransaction {\n\tconstructor(\n\t\tpublic tx: IDBTransaction,\n\t\tpublic store: IDBObjectStore\n\t) {}\n\n\tpublic get(key: Ino): Promise<Uint8Array> {\n\t\treturn wrap<Uint8Array>(this.store.get(key.toString()));\n\t}\n\n\t/**\n\t * @todo return false when add has a key conflict (no error)\n\t */\n\tpublic async put(key: Ino, data: Uint8Array, overwrite: boolean): Promise<boolean> {\n\t\tawait wrap(this.store[overwrite ? 'put' : 'add'](data, key.toString()));\n\t\treturn true;\n\t}\n\n\tpublic remove(key: Ino): Promise<void> {\n\t\treturn wrap(this.store.delete(key.toString()));\n\t}\n\n\tpublic async commit(): Promise<void> {\n\t\treturn;\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);\n\t\t}\n\t}\n}\n\nexport class IndexedDBStore implements AsyncStore {\n\tpublic static async create(storeName: string, indexedDB: IDBFactory = globalThis.indexedDB): Promise<IndexedDBStore> {\n\t\tconst req: IDBOpenDBRequest = indexedDB.open(storeName, 1);\n\n\t\treq.onupgradeneeded = () => {\n\t\t\tconst db: IDBDatabase = req.result;\n\t\t\t// This should never happen; we're at version 1. Why does another database exist?\n\t\t\tif (db.objectStoreNames.contains(storeName)) {\n\t\t\t\tdb.deleteObjectStore(storeName);\n\t\t\t}\n\t\t\tdb.createObjectStore(storeName);\n\t\t};\n\n\t\tconst result = await wrap(req);\n\t\treturn new IndexedDBStore(result, storeName);\n\t}\n\n\tconstructor(\n\t\tprotected db: IDBDatabase,\n\t\tprotected storeName: string\n\t) {}\n\n\tpublic get name(): string {\n\t\treturn IndexedDB.name + ':' + this.storeName;\n\t}\n\n\tpublic clear(): Promise<void> {\n\t\treturn wrap(this.db.transaction(this.storeName, 'readwrite').objectStore(this.storeName).clear());\n\t}\n\n\tpublic beginTransaction(): IndexedDBTransaction {\n\t\tconst tx = this.db.transaction(this.storeName, 'readwrite');\n\t\treturn new IndexedDBTransaction(tx, tx.objectStore(this.storeName));\n\t}\n}\n\n/**\n * Configuration options for the IndexedDB file system.\n */\nexport interface IndexedDBOptions extends Omit<AsyncStoreOptions, 'store'> {\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\tcacheSize: {\n\t\t\ttype: 'number',\n\t\t\trequired: false,\n\t\t\tdescription: 'The size of the inode cache. Defaults to 100. A size of 0 or below disables caching.',\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\tcreate(options: IndexedDBOptions) {\n\t\tconst store = IndexedDBStore.create(options.storeName || 'zenfs', options.idbFactory);\n\t\tconst fs = new AsyncStoreFS({ ...options, store });\n\t\treturn fs;\n\t},\n} as const satisfies Backend;\n", "import type { Backend, Ino, SimpleSyncStore, SyncStore } from '@zenfs/core';\nimport { ApiError, ErrorCode, SimpleSyncTransaction, SyncStoreFS, decode, encode } from '@zenfs/core';\n\n/**\n * A synchronous key-value store backed by Storage.\n */\nexport class WebStorageStore implements SyncStore, 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 beginTransaction(): SimpleSyncTransaction {\n\t\t// No need to differentiate.\n\t\treturn new SimpleSyncTransaction(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 put(key: Ino, data: Uint8Array, overwrite: boolean): boolean {\n\t\ttry {\n\t\t\tif (!overwrite && this._storage.getItem(key.toString()) !== null) {\n\t\t\t\t// Don't want to overwrite the key!\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tthis._storage.setItem(key.toString(), decode(data));\n\t\t\treturn true;\n\t\t} catch (e) {\n\t\t\tthrow new ApiError(ErrorCode.ENOSPC, 'Storage is full.');\n\t\t}\n\t}\n\n\tpublic remove(key: Ino): void {\n\t\ttry {\n\t\t\tthis._storage.removeItem(key.toString());\n\t\t} catch (e) {\n\t\t\tthrow new ApiError(ErrorCode.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 SyncStoreFS({ store: new WebStorageStore(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YAAsBC,EAAmB,CAAnB,cAAAA,CAAoB,CAJ1C,IAAW,MAAe,CACzB,OAAOC,EAAW,IACnB,CAIO,OAAc,CACpB,KAAK,SAAS,MAAM,CACrB,CAEO,kBAA0C,CAEhD,OAAO,IAAIC,EAAsB,IAAI,CACtC,CAEO,IAAIC,EAAkC,CAC5C,IAAMC,EAAO,KAAK,SAAS,QAAQD,EAAI,SAAS,CAAC,EACjD,GAAI,OAAOC,GAAQ,SAInB,OAAOC,EAAOD,CAAI,CACnB,CAEO,IAAID,EAAUC,EAAkBE,EAA6B,CACnE,GAAI,CACH,MAAI,CAACA,GAAa,KAAK,SAAS,QAAQH,EAAI,SAAS,CAAC,IAAM,KAEpD,IAER,KAAK,SAAS,QAAQA,EAAI,SAAS,EAAGI,EAAOH,CAAI,CAAC,EAC3C,GACR,MAAE,CACD,MAAM,IAAII,EAASC,EAAU,OAAQ,kBAAkB,CACxD,CACD,CAEO,OAAON,EAAgB,CAC7B,GAAI,CACH,KAAK,SAAS,WAAWA,EAAI,SAAS,CAAC,CACxC,OAASO,EAAP,CACD,MAAM,IAAIF,EAASC,EAAU,IAAK,wBAA0BN,EAAM,KAAOO,CAAC,CAC3E,CACD,CACD,EA7CaC,EAAAZ,EAAA,mBA4DN,IAAME,EAAa,CACzB,KAAM,aAEN,QAAS,CACR,QAAS,CACR,KAAM,SACN,SAAU,GACV,YAAa,0DACd,CACD,EAEA,YAAYW,EAAmB,WAAW,aAAuB,CAChE,OAAOA,aAAmB,WAAW,OACtC,EAEA,OAAO,CAAE,QAAAA,EAAU,WAAW,YAAa,EAAsB,CAChE,OAAO,IAAIC,EAAY,CAAE,MAAO,IAAId,EAAgBa,CAAO,CAAE,CAAC,CAC/D,CACD",
6
- "names": ["src_exports", "__export", "IndexedDB", "IndexedDBStore", "IndexedDBTransaction", "WebAccess", "WebAccessFS", "WebStorage", "WebStorageStore", "core_default", "ActionType", "ApiError", "Async", "AsyncIndexFS", "AsyncStoreFS", "BigIntStats", "BigIntStatsFs", "Dir", "Dirent", "ErrorCode", "File", "FileIndex", "FileSystem", "FileType", "InMemory", "InMemoryStore", "IndexDirInode", "IndexFS", "IndexFileInode", "IndexInode", "Inode", "LockedFS", "Mutex", "NoSyncFile", "Overlay", "OverlayFS", "PreloadFile", "ReadStream", "Readonly", "SimpleSyncTransaction", "Stats", "StatsCommon", "StatsFs", "Sync", "SyncIndexFS", "SyncStoreFS", "UnlockedOverlayFS", "WriteStream", "_toUnixTimestamp", "access", "accessSync", "appendFile", "appendFileSync", "checkOptions", "chmod", "chmodSync", "chown", "chownSync", "close", "closeSync", "configure", "constants", "copyFile", "copyFileSync", "cp", "cpSync", "createBackend", "createReadStream", "createWriteStream", "decode", "decodeDirListing", "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", "mountMapping", "mounts", "nop", "normalizeMode", "normalizeOptions", "normalizePath", "normalizeTime", "open", "openAsBlob", "openSync", "opendir", "opendirSync", "parseFlag", "pathExistsAction", "pathNotExistsAction", "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", "validateString", "str", "name", "__name", "normalizeString", "path", "allowAboveRoot", "res", "lastSegmentLength", "lastSlash", "dots", "char", "i", "lastSlashIndex", "__name", "normalize", "path", "validateString", "isAbsolute", "trailingSeparator", "normalizeString", "__name", "join", "args", "joined", "i", "arg", "validateString", "normalize", "__name", "dirname", "path", "validateString", "hasRoot", "end", "matchedSlash", "__name", "basename", "suffix", "start", "extIdx", "firstNonSlashEnd", "i", "errnoForDOMException", "ex", "__name", "convertException", "path", "syscall", "ApiError", "code", "ErrorCode", "error", "WebAccessFS", "Async", "FileSystem", "handle", "InMemory", "p", "data", "stats", "currentStats", "oldPath", "newPath", "files", "file", "join", "oldFile", "destFolder", "dirname", "writable", "basename", "buffer", "ex", "convertException", "fname", "path", "flag", "ApiError", "Stats", "FileType", "lastModified", "size", "PreloadFile", "srcpath", "_keys", "key", "walked", "part", "dirHandle", "fileHandle", "ErrorCode", "__name", "WebAccess", "options", "wrap", "request", "resolve", "reject", "e", "convertException", "__name", "IndexedDBTransaction", "tx", "store", "key", "data", "overwrite", "IndexedDBStore", "db", "storeName", "indexedDB", "req", "result", "IndexedDB", "idbFactory", "options", "AsyncStoreFS", "WebStorageStore", "_storage", "WebStorage", "SimpleSyncTransaction", "key", "data", "encode", "overwrite", "decode", "ApiError", "ErrorCode", "e", "__name", "storage", "SyncStoreFS"]
4
+ "sourcesContent": ["export * from './access.js';\nexport * from './IndexedDB.js';\nexport * from './Storage.js';\n", "export default ZenFS;\nconst { ActionType, ApiError, Async, AsyncIndexFS, AsyncStoreFS, BigIntStats, BigIntStatsFs, Dir, Dirent, ErrorCode, File, FileIndex, FileSystem, FileType, InMemory, InMemoryStore, IndexDirInode, IndexFS, IndexFileInode, IndexInode, Inode, LockedFS, Mutex, NoSyncFile, Overlay, OverlayFS, PreloadFile, ReadStream, Readonly, SimpleSyncTransaction, Stats, StatsCommon, StatsFs, Sync, SyncIndexFS, SyncStoreFS, UnlockedOverlayFS, WriteStream, _toUnixTimestamp, access, accessSync, appendFile, appendFileSync, checkOptions, chmod, chmodSync, chown, chownSync, close, closeSync, configure, constants, copyFile, copyFileSync, cp, cpSync, createBackend, createReadStream, createWriteStream, decode, decodeDirListing, 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, mountMapping, mounts, nop, normalizeMode, normalizeOptions, normalizePath, normalizeTime, open, openAsBlob, openSync, opendir, opendirSync, parseFlag, pathExistsAction, pathNotExistsAction, 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 { ActionType, ApiError, Async, AsyncIndexFS, AsyncStoreFS, BigIntStats, BigIntStatsFs, Dir, Dirent, ErrorCode, File, FileIndex, FileSystem, FileType, InMemory, InMemoryStore, IndexDirInode, IndexFS, IndexFileInode, IndexInode, Inode, LockedFS, Mutex, NoSyncFile, Overlay, OverlayFS, PreloadFile, ReadStream, Readonly, SimpleSyncTransaction, Stats, StatsCommon, StatsFs, Sync, SyncIndexFS, SyncStoreFS, UnlockedOverlayFS, WriteStream, _toUnixTimestamp, access, accessSync, appendFile, appendFileSync, checkOptions, chmod, chmodSync, chown, chownSync, close, closeSync, configure, constants, copyFile, copyFileSync, cp, cpSync, createBackend, createReadStream, createWriteStream, decode, decodeDirListing, 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, mountMapping, mounts, nop, normalizeMode, normalizeOptions, normalizePath, normalizeTime, open, openAsBlob, openSync, opendir, opendirSync, parseFlag, pathExistsAction, pathNotExistsAction, 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 validateString(str, name) {\n if (typeof str != 'string') {\n throw new TypeError(`\"${name}\" is not a string`);\n }\n}\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(...args) {\n let resolved = '';\n let absolute = false;\n for (let i = args.length - 1; i >= -1 && !absolute; i--) {\n const path = i >= 0 ? args[i] : cwd;\n validateString(path, `paths[${i}]`);\n // Skip empty entries\n if (!path.length) {\n continue;\n }\n resolved = `${path}/${resolved}`;\n absolute = path[0] == '/';\n }\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 > 0 ? resolved : '/';\n}\nexport function normalize(path) {\n validateString(path, 'path');\n if (path.length === 0)\n return '.';\n const isAbsolute = path[0] === '/';\n const trailingSeparator = path.at(-1) === '/';\n // Normalize the path\n path = normalizeString(path, !isAbsolute);\n if (path.length === 0) {\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 validateString(path, 'path');\n return path.length > 0 && path[0] === '/';\n}\nexport function join(...args) {\n if (args.length === 0)\n return '.';\n let joined;\n for (let i = 0; i < args.length; ++i) {\n const arg = args[i];\n validateString(arg, 'path');\n if (arg.length > 0) {\n if (joined === undefined)\n joined = arg;\n else\n joined += `/${arg}`;\n }\n }\n if (joined === undefined)\n return '.';\n return normalize(joined);\n}\nexport function relative(from, to) {\n validateString(from, 'from');\n validateString(to, '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 validateString(path, '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 if (suffix !== undefined)\n validateString(suffix, 'ext');\n validateString(path, 'path');\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 validateString(path, '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 validateString(path, 'path');\n const isAbsolute = path[0] === '/';\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 { ApiError, ErrorCode } from '@zenfs/core';\n\n/**\n * Converts a DOMException into an ErrorCode\n * @see https://developer.mozilla.org/Web/API/DOMException\n */\nfunction errnoForDOMException(ex: DOMException): keyof typeof ErrorCode {\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 * Handles converting errors, then rethrowing them\n */\nexport function convertException(ex: Error | ApiError | DOMException, path?: string, syscall?: string): ApiError {\n\tif (ex instanceof ApiError) {\n\t\treturn ex;\n\t}\n\n\tconst code = ex instanceof DOMException ? ErrorCode[errnoForDOMException(ex)] : ErrorCode.EIO;\n\tconst error = new ApiError(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 { ApiError, Async, ErrorCode, FileSystem, FileType, InMemory, PreloadFile, Stats } from '@zenfs/core';\nimport { basename, dirname, join } from '@zenfs/core/emulation/path.js';\nimport { 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;\n\n\tpublic constructor({ handle }: WebAccessOptions) {\n\t\tsuper();\n\t\tthis._handles.set('/', handle);\n\t\tthis._sync = InMemory.create({ name: 'accessfs-cache' });\n\t}\n\n\tpublic metadata(): FileSystemMetadata {\n\t\treturn {\n\t\t\t...super.metadata(),\n\t\t\tname: 'WebAccess',\n\t\t};\n\t}\n\n\tpublic async sync(p: string, data: Uint8Array, stats: Stats): Promise<void> {\n\t\tconst currentStats = await this.stat(p);\n\t\tif (stats.mtime !== currentStats!.mtime) {\n\t\t\tawait this.writeFile(p, 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, oldPath, 'rename');\n\t\t}\n\t}\n\n\tpublic async writeFile(fname: string, data: Uint8Array): Promise<void> {\n\t\tconst handle = await this.getHandle(dirname(fname));\n\t\tif (!(handle instanceof FileSystemDirectoryHandle)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst file = await handle.getFileHandle(basename(fname), { 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 ApiError.With('ENOENT', path, 'stat');\n\t\t}\n\t\tif (handle instanceof FileSystemDirectoryHandle) {\n\t\t\treturn new Stats({ mode: 0o777 | FileType.DIRECTORY, 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 | FileType.FILE, size, mtimeMs: lastModified });\n\t\t}\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 ApiError.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 | FileType.FILE, 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, 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, path, 'unlink');\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic async link(srcpath: string): Promise<void> {\n\t\tthrow ApiError.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 ApiError.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 ApiError.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 ApiError.With('ENOTDIR', path, 'readdir');\n\t\t}\n\t\tconst _keys: string[] = [];\n\t\tfor await (const key of handle.keys()) {\n\t\t\t_keys.push(join(path, 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 ApiError.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\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, 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 ApiError(ErrorCode.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);\n\t},\n} as const satisfies Backend;\n", "import type { AsyncStore, AsyncStoreOptions, AsyncTransaction, Backend, Ino } from '@zenfs/core';\nimport { AsyncStoreFS } from '@zenfs/core';\nimport { 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 implements AsyncTransaction {\n\tconstructor(\n\t\tpublic tx: IDBTransaction,\n\t\tpublic store: IDBObjectStore\n\t) {}\n\n\tpublic get(key: Ino): Promise<Uint8Array> {\n\t\treturn wrap<Uint8Array>(this.store.get(key.toString()));\n\t}\n\n\t/**\n\t * @todo return false when add has a key conflict (no error)\n\t */\n\tpublic async put(key: Ino, data: Uint8Array, overwrite: boolean): Promise<boolean> {\n\t\tawait wrap(this.store[overwrite ? 'put' : 'add'](data, key.toString()));\n\t\treturn true;\n\t}\n\n\tpublic remove(key: Ino): Promise<void> {\n\t\treturn wrap(this.store.delete(key.toString()));\n\t}\n\n\tpublic async commit(): Promise<void> {\n\t\treturn;\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);\n\t\t}\n\t}\n}\n\nexport class IndexedDBStore implements AsyncStore {\n\tpublic static async create(storeName: string, indexedDB: IDBFactory = globalThis.indexedDB): Promise<IndexedDBStore> {\n\t\tconst req: IDBOpenDBRequest = indexedDB.open(storeName, 1);\n\n\t\treq.onupgradeneeded = () => {\n\t\t\tconst db: IDBDatabase = req.result;\n\t\t\t// This should never happen; we're at version 1. Why does another database exist?\n\t\t\tif (db.objectStoreNames.contains(storeName)) {\n\t\t\t\tdb.deleteObjectStore(storeName);\n\t\t\t}\n\t\t\tdb.createObjectStore(storeName);\n\t\t};\n\n\t\tconst result = await wrap(req);\n\t\treturn new IndexedDBStore(result, storeName);\n\t}\n\n\tconstructor(\n\t\tprotected db: IDBDatabase,\n\t\tprotected storeName: string\n\t) {}\n\n\tpublic get name(): string {\n\t\treturn IndexedDB.name + ':' + this.storeName;\n\t}\n\n\tpublic clear(): Promise<void> {\n\t\treturn wrap(this.db.transaction(this.storeName, 'readwrite').objectStore(this.storeName).clear());\n\t}\n\n\tpublic beginTransaction(): IndexedDBTransaction {\n\t\tconst tx = this.db.transaction(this.storeName, 'readwrite');\n\t\treturn new IndexedDBTransaction(tx, tx.objectStore(this.storeName));\n\t}\n}\n\n/**\n * Configuration options for the IndexedDB file system.\n */\nexport interface IndexedDBOptions extends Omit<AsyncStoreOptions, 'store'> {\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\tcacheSize: {\n\t\t\ttype: 'number',\n\t\t\trequired: false,\n\t\t\tdescription: 'The size of the inode cache. Defaults to 100. A size of 0 or below disables caching.',\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\tcreate(options: IndexedDBOptions) {\n\t\tconst store = IndexedDBStore.create(options.storeName || 'zenfs', options.idbFactory);\n\t\tconst fs = new AsyncStoreFS({ ...options, store });\n\t\treturn fs;\n\t},\n} as const satisfies Backend;\n", "import type { Backend, Ino, SimpleSyncStore, SyncStore } from '@zenfs/core';\nimport { ApiError, ErrorCode, SimpleSyncTransaction, SyncStoreFS, decode, encode } from '@zenfs/core';\n\n/**\n * A synchronous key-value store backed by Storage.\n */\nexport class WebStorageStore implements SyncStore, 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 beginTransaction(): SimpleSyncTransaction {\n\t\t// No need to differentiate.\n\t\treturn new SimpleSyncTransaction(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 put(key: Ino, data: Uint8Array, overwrite: boolean): boolean {\n\t\ttry {\n\t\t\tif (!overwrite && this._storage.getItem(key.toString()) !== null) {\n\t\t\t\t// Don't want to overwrite the key!\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tthis._storage.setItem(key.toString(), decode(data));\n\t\t\treturn true;\n\t\t} catch (e) {\n\t\t\tthrow new ApiError(ErrorCode.ENOSPC, 'Storage is full.');\n\t\t}\n\t}\n\n\tpublic remove(key: Ino): void {\n\t\ttry {\n\t\t\tthis._storage.removeItem(key.toString());\n\t\t} catch (e) {\n\t\t\tthrow new ApiError(ErrorCode.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 SyncStoreFS({ store: new WebStorageStore(storage) });\n\t},\n} as const satisfies Backend;\n"],
5
+ "mappings": "meAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,eAAAE,EAAA,mBAAAC,EAAA,yBAAAC,EAAA,cAAAC,EAAA,gBAAAC,EAAA,eAAAC,EAAA,oBAAAC,ICAA,IAAOC,EAAQ,MACT,CAAE,WAAAC,EAAY,SAAAC,EAAU,MAAAC,EAAO,aAAAC,EAAc,aAAAC,EAAc,YAAAC,EAAa,cAAAC,EAAe,IAAAC,GAAK,OAAAC,GAAQ,UAAAC,EAAW,KAAAC,GAAM,UAAAC,GAAW,WAAAC,EAAY,SAAAC,EAAU,SAAAC,EAAU,cAAAC,GAAe,cAAAC,GAAe,QAAAC,GAAS,eAAAC,GAAgB,WAAAC,GAAY,MAAAC,GAAO,SAAAC,GAAU,MAAAC,GAAO,WAAAC,GAAY,QAAAC,GAAS,UAAAC,GAAW,YAAAC,EAAa,WAAAC,GAAY,SAAAC,GAAU,sBAAAC,EAAuB,MAAAC,EAAO,YAAAC,GAAa,QAAAC,GAAS,KAAAC,GAAM,YAAAC,GAAa,YAAAC,EAAa,k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M,IAAII,EAASC,EAAU,OAAQ,kBAAkB,CACxD,CACD,CAEO,OAAON,EAAgB,CAC7B,GAAI,CACH,KAAK,SAAS,WAAWA,EAAI,SAAS,CAAC,CACxC,OAASO,EAAP,CACD,MAAM,IAAIF,EAASC,EAAU,IAAK,wBAA0BN,EAAM,KAAOO,CAAC,CAC3E,CACD,CACD,EA7CaC,EAAAZ,EAAA,mBA4DN,IAAME,EAAa,CACzB,KAAM,aAEN,QAAS,CACR,QAAS,CACR,KAAM,SACN,SAAU,GACV,YAAa,0DACd,CACD,EAEA,YAAYW,EAAmB,WAAW,aAAuB,CAChE,OAAOA,aAAmB,WAAW,OACtC,EAEA,OAAO,CAAE,QAAAA,EAAU,WAAW,YAAa,EAAsB,CAChE,OAAO,IAAIC,EAAY,CAAE,MAAO,IAAId,EAAgBa,CAAO,CAAE,CAAC,CAC/D,CACD",
6
+ "names": ["src_exports", "__export", "IndexedDB", "IndexedDBStore", "IndexedDBTransaction", "WebAccess", "WebAccessFS", "WebStorage", "WebStorageStore", "core_default", "ActionType", "ApiError", "Async", "AsyncIndexFS", "AsyncStoreFS", "BigIntStats", "BigIntStatsFs", "Dir", "Dirent", "ErrorCode", "File", "FileIndex", "FileSystem", "FileType", "InMemory", "InMemoryStore", "IndexDirInode", "IndexFS", "IndexFileInode", "IndexInode", "Inode", "LockedFS", "Mutex", "NoSyncFile", "Overlay", "OverlayFS", "PreloadFile", "ReadStream", "Readonly", "SimpleSyncTransaction", "Stats", "StatsCommon", "StatsFs", "Sync", "SyncIndexFS", "SyncStoreFS", "UnlockedOverlayFS", "WriteStream", "_toUnixTimestamp", "access", "accessSync", "appendFile", "appendFileSync", "checkOptions", "chmod", "chmodSync", "chown", "chownSync", "close", "closeSync", "configure", "constants", "copyFile", "copyFileSync", "cp", "cpSync", "createBackend", "createReadStream", "createWriteStream", "decode", "decodeDirListing", "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", "mountMapping", "mounts", "nop", "normalizeMode", "normalizeOptions", "normalizePath", "normalizeTime", "open", "openAsBlob", "openSync", "opendir", "opendirSync", "parseFlag", "pathExistsAction", "pathNotExistsAction", "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", "validateString", "str", "name", "__name", "normalizeString", "path", "allowAboveRoot", "res", "lastSegmentLength", "lastSlash", "dots", "char", "i", "lastSlashIndex", "__name", "normalize", "path", "validateString", "isAbsolute", "trailingSeparator", "normalizeString", "__name", "join", "args", "joined", "i", "arg", "validateString", "normalize", "__name", "dirname", "path", "validateString", "hasRoot", "end", "matchedSlash", "__name", "basename", "suffix", "start", "extIdx", "firstNonSlashEnd", "i", "errnoForDOMException", "ex", "__name", "convertException", "path", "syscall", "ApiError", "code", "ErrorCode", "error", "WebAccessFS", "Async", "FileSystem", "handle", "InMemory", "p", "data", "stats", "currentStats", "oldPath", "newPath", "files", "file", "join", "oldFile", "destFolder", "dirname", "writable", "basename", "ex", "convertException", "fname", "path", "flag", "ApiError", "Stats", "FileType", "lastModified", "size", "PreloadFile", "srcpath", "_keys", "key", "walked", "part", "dirHandle", "fileHandle", "ErrorCode", "__name", "WebAccess", "options", "wrap", "request", "resolve", "reject", "e", "convertException", "__name", "IndexedDBTransaction", "tx", "store", "key", "data", "overwrite", "IndexedDBStore", "db", "storeName", "indexedDB", "req", "result", "IndexedDB", "idbFactory", "options", "AsyncStoreFS", "WebStorageStore", "_storage", "WebStorage", "SimpleSyncTransaction", "key", "data", "encode", "overwrite", "decode", "ApiError", "ErrorCode", "e", "__name", "storage", "SyncStoreFS"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zenfs/dom",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "description": "DOM backends for ZenFS",
5
5
  "main": "dist/index.js",
6
6
  "types": "src/index.ts",
package/src/access.ts CHANGED
@@ -70,8 +70,7 @@ export class WebAccessFS extends Async(FileSystem) {
70
70
  }
71
71
  const newFile = await destFolder.getFileHandle(basename(newPath), { create: true });
72
72
  const writable = await newFile.createWritable();
73
- const buffer = await oldFile.arrayBuffer();
74
- await writable.write(buffer);
73
+ await writable.write(await oldFile.arrayBuffer());
75
74
 
76
75
  writable.close();
77
76
  await this.unlink(oldPath);
@@ -113,11 +112,16 @@ export class WebAccessFS extends Async(FileSystem) {
113
112
 
114
113
  public async openFile(path: string, flag: string): Promise<PreloadFile<this>> {
115
114
  const handle = await this.getHandle(path);
116
- if (handle instanceof FileSystemFileHandle) {
115
+ if (!(handle instanceof FileSystemFileHandle)) {
116
+ throw ApiError.With('EISDIR', path, 'openFile');
117
+ }
118
+ try {
117
119
  const file = await handle.getFile();
118
120
  const data = new Uint8Array(await file.arrayBuffer());
119
121
  const stats = new Stats({ mode: 0o777 | FileType.FILE, size: file.size, mtimeMs: file.lastModified });
120
122
  return new PreloadFile(this, path, flag, stats, data);
123
+ } catch (ex) {
124
+ throw convertException(ex, path, 'openFile');
121
125
  }
122
126
  }
123
127
 
@@ -147,9 +151,10 @@ export class WebAccessFS extends Async(FileSystem) {
147
151
  }
148
152
 
149
153
  const handle = await this.getHandle(dirname(path));
150
- if (handle instanceof FileSystemDirectoryHandle) {
151
- await handle.getDirectoryHandle(basename(path), { create: true });
154
+ if (!(handle instanceof FileSystemDirectoryHandle)) {
155
+ throw ApiError.With('ENOTDIR', path, 'mkdir');
152
156
  }
157
+ await handle.getDirectoryHandle(basename(path), { create: true });
153
158
  }
154
159
 
155
160
  public async readdir(path: string): Promise<string[]> {