opfs-worker 1.2.0 → 1.2.1

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/facade.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { DirentData, Encoding, FileOpenOptions, FileStat, OPFSOptions, RenameOptions, WatchOptions } from './types';
1
+ import type { DirentData, Encoding, FileOpenOptions, FileStat, OPFSOptions, PathLike, RenameOptions, WatchOptions } from './types';
2
2
  /**
3
3
  * Facade class that provides a clean interface for communicating with the OPFS worker
4
4
  * while hiding Comlink implementation details.
@@ -17,73 +17,73 @@ export declare class OPFSFileSystem {
17
17
  /**
18
18
  * Read a file from the file system
19
19
  */
20
- readFile(path: string, encoding: 'binary'): Promise<Uint8Array>;
21
- readFile(path: string, encoding: Encoding): Promise<string>;
22
- readFile(path: string, encoding?: Encoding | 'binary'): Promise<string | Uint8Array>;
20
+ readFile(path: PathLike, encoding: 'binary'): Promise<Uint8Array>;
21
+ readFile(path: PathLike, encoding: Encoding): Promise<string>;
22
+ readFile(path: PathLike, encoding?: Encoding | 'binary'): Promise<string | Uint8Array>;
23
23
  /**
24
24
  * Write data to a file
25
25
  */
26
- writeFile(path: string, data: string | Uint8Array | ArrayBuffer, encoding?: Encoding): Promise<void>;
26
+ writeFile(path: PathLike, data: string | Uint8Array | ArrayBuffer, encoding?: Encoding): Promise<void>;
27
27
  /**
28
28
  * Append data to a file
29
29
  */
30
- appendFile(path: string, data: string | Uint8Array | ArrayBuffer, encoding?: Encoding): Promise<void>;
30
+ appendFile(path: PathLike, data: string | Uint8Array | ArrayBuffer, encoding?: Encoding): Promise<void>;
31
31
  /**
32
32
  * Create a directory
33
33
  */
34
- mkdir(path: string, options?: {
34
+ mkdir(path: PathLike, options?: {
35
35
  recursive?: boolean;
36
36
  }): Promise<void>;
37
37
  /**
38
38
  * Get file or directory statistics
39
39
  */
40
- stat(path: string): Promise<FileStat>;
40
+ stat(path: PathLike): Promise<FileStat>;
41
41
  /**
42
42
  * Read a directory's contents
43
43
  */
44
- readDir(path: string): Promise<DirentData[]>;
44
+ readDir(path: PathLike): Promise<DirentData[]>;
45
45
  /**
46
46
  * Check if a file or directory exists
47
47
  */
48
- exists(path: string): Promise<boolean>;
48
+ exists(path: PathLike): Promise<boolean>;
49
49
  /**
50
50
  * Clear all contents of a directory without removing the directory itself
51
51
  */
52
- clear(path?: string): Promise<void>;
52
+ clear(path?: PathLike): Promise<void>;
53
53
  /**
54
54
  * Remove files and directories
55
55
  */
56
- remove(path: string, options?: {
56
+ remove(path: PathLike, options?: {
57
57
  recursive?: boolean;
58
58
  force?: boolean;
59
59
  }): Promise<void>;
60
60
  /**
61
61
  * Resolve a path to an absolute path
62
62
  */
63
- realpath(path: string): Promise<string>;
63
+ realpath(path: PathLike): Promise<string>;
64
64
  /**
65
65
  * Rename a file or directory
66
66
  */
67
- rename(oldPath: string, newPath: string, options?: RenameOptions): Promise<void>;
67
+ rename(oldPath: PathLike, newPath: PathLike, options?: RenameOptions): Promise<void>;
68
68
  /**
69
69
  * Copy files and directories
70
70
  */
71
- copy(source: string, destination: string, options?: {
71
+ copy(source: PathLike, destination: PathLike, options?: {
72
72
  recursive?: boolean;
73
73
  overwrite?: boolean;
74
74
  }): Promise<void>;
75
75
  /**
76
76
  * Start watching a file or directory for changes
77
77
  */
78
- watch(path: string, options?: WatchOptions): () => void;
78
+ watch(path: PathLike, options?: WatchOptions): () => void;
79
79
  /**
80
80
  * Stop watching a previously watched path
81
81
  */
82
- unwatch(path: string): void;
82
+ unwatch(path: PathLike): void;
83
83
  /**
84
84
  * Open a file and return a file descriptor
85
85
  */
86
- open(path: string, options?: FileOpenOptions): Promise<number>;
86
+ open(path: PathLike, options?: FileOpenOptions): Promise<number>;
87
87
  /**
88
88
  * Close a file descriptor
89
89
  */
@@ -122,20 +122,20 @@ export declare class OPFSFileSystem {
122
122
  /**
123
123
  * Synchronize the file system with external data
124
124
  */
125
- sync(entries: [string, string | Uint8Array | Blob][], options?: {
125
+ sync(entries: [PathLike, string | Uint8Array | Blob][], options?: {
126
126
  cleanBefore?: boolean;
127
127
  }): Promise<void>;
128
128
  /**
129
129
  * Read a file as text with automatic encoding detection
130
130
  */
131
- readText(path: string, encoding?: Encoding): Promise<string>;
131
+ readText(path: PathLike, encoding?: Encoding): Promise<string>;
132
132
  /**
133
133
  * Write text to a file with specified encoding
134
134
  */
135
- writeText(path: string, text: string, encoding?: Encoding): Promise<void>;
135
+ writeText(path: PathLike, text: string, encoding?: Encoding): Promise<void>;
136
136
  /**
137
137
  * Append text to a file with specified encoding
138
138
  */
139
- appendText(path: string, text: string, encoding?: Encoding): Promise<void>;
139
+ appendText(path: PathLike, text: string, encoding?: Encoding): Promise<void>;
140
140
  }
141
141
  //# sourceMappingURL=facade.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"facade.d.ts","sourceRoot":"","sources":["../src/facade.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACR,UAAU,EACV,QAAQ,EACR,eAAe,EACf,QAAQ,EACR,WAAW,EAEX,aAAa,EACb,YAAY,EACf,MAAM,SAAS,CAAC;AAEjB;;;GAGG;AACH,qBAAa,cAAc;;gBAGX,OAAO,CAAC,EAAE,WAAW;IAiBjC;;OAEG;IACG,UAAU,CAAC,OAAO,EAAE,WAAW;IAIrC;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAI7C;;OAEG;IACG,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAC/D,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC;IAC3D,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC,MAAM,GAAG,UAAU,CAAC;IAiB1F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CAAC,QAAQ,CAAC;IAI1C;;OAEG;IACG,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIzD;;OAEG;IACG,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAItC;;OAEG;IACH,OAAO;IAIP;;OAEG;IACG,IAAI,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAAC,EAAE,EAAE,OAAO,CAAC,EAAE;QAAE,WAAW,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAMjH;;OAEG;IACG,QAAQ,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,GAAE,QAAkB,GAAG,OAAO,CAAC,MAAM,CAAC;IAO7E;;OAEG;IACG,SAAS,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,GAAE,QAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAO1F;;OAEG;IACG,UAAU,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,GAAE,QAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;CAM9F"}
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("comlink"),e=require("./helpers-TAynP0fb.cjs"),c=`/**
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("comlink"),e=require("./helpers-TAynP0fb.cjs"),l=`/**
2
2
  * @license
3
3
  * Copyright 2019 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
@@ -2342,5 +2342,5 @@ class es {
2342
2342
  }
2343
2343
  typeof globalThis < "u" && globalThis.constructor.name === "DedicatedWorkerGlobalScope" && K(new es());
2344
2344
  //# sourceMappingURL=worker-CLvhwwfc.js.map
2345
- `,h=typeof self<"u"&&self.Blob&&new Blob(["URL.revokeObjectURL(import.meta.url);",c],{type:"text/javascript;charset=utf-8"});function d(s){let n;try{if(n=h&&(self.URL||self.webkitURL).createObjectURL(h),!n)throw"";const t=new Worker(n,{type:"module",name:s?.name});return t.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(n)}),t}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(c),{type:"module",name:s?.name})}}class l{#n;constructor(n){const t=f.wrap(new d);this.#n=t,n&&(n.broadcastChannel&&n.broadcastChannel instanceof BroadcastChannel&&(n.broadcastChannel=n.broadcastChannel.name),this.setOptions(n))}async setOptions(n){return this.#n.setOptions(n)}async index(){return this.#n.index()}async readFile(n,t){const r=await this.#n.readFile(n);return t||(t=e.isBinaryFileExtension(n)?"binary":"utf-8"),t==="binary"?r:e.decodeBuffer(r,t)}async writeFile(n,t,r){r||(r=typeof t!="string"||e.isBinaryFileExtension(n)?"binary":"utf-8");const i=typeof t=="string"?e.encodeString(t,r):t instanceof Uint8Array?t:new Uint8Array(t);return this.#n.writeFile(n,i)}async appendFile(n,t,r){r||(r=typeof t!="string"||e.isBinaryFileExtension(n)?"binary":"utf-8");const i=typeof t=="string"?e.encodeString(t,r):t instanceof Uint8Array?t:new Uint8Array(t);return this.#n.appendFile(n,i)}async mkdir(n,t){return this.#n.mkdir(n,t)}async stat(n){return this.#n.stat(n)}async readDir(n){return this.#n.readDir(n)}async exists(n){return this.#n.exists(n)}async clear(n){return this.#n.clear(n)}async remove(n,t){return this.#n.remove(n,t)}async realpath(n){return this.#n.realpath(n)}async rename(n,t,r){return this.#n.rename(n,t,r)}async copy(n,t,r){return this.#n.copy(n,t,r)}watch(n,t){return this.#n.watch(n,t),()=>this.unwatch(n)}unwatch(n){this.#n.unwatch(n)}async open(n,t){return this.#n.open(n,t)}async close(n){return this.#n.close(n)}async read(n,t,r,i,o){const{bytesRead:a,buffer:p}=await this.#n.read(n,new Uint8Array(i),0,i,o);return a>0&&t.set(p.subarray(0,a),r),{bytesRead:a,buffer:t}}async write(n,t,r,i,o,a){return this.#n.write(n,t,r,i,o,a)}async fstat(n){return this.#n.fstat(n)}async ftruncate(n,t){return this.#n.ftruncate(n,t)}async fsync(n){return this.#n.fsync(n)}dispose(){this.#n.dispose()}async sync(n,t){return this.#n.sync(n,t)}async readText(n,t="utf-8"){const r=await this.#n.readFile(n);return e.decodeBuffer(r,t)}async writeText(n,t,r="utf-8"){const i=e.encodeString(t,r);return this.#n.writeFile(n,i)}async appendText(n,t,r="utf-8"){const i=e.encodeString(t,r);return this.#n.appendFile(n,i)}}function u(s){return new l(s)}exports.BINARY_FILE_EXTENSIONS=e.BINARY_FILE_EXTENSIONS;exports.DirectoryNotFoundError=e.DirectoryNotFoundError;exports.FileNotFoundError=e.FileNotFoundError;exports.OPFSError=e.OPFSError;exports.OPFSNotMountedError=e.OPFSNotMountedError;exports.OPFSNotSupportedError=e.OPFSNotSupportedError;exports.PathError=e.PathError;exports.PermissionError=e.PermissionError;exports.StorageError=e.StorageError;exports.TimeoutError=e.TimeoutError;exports.basename=e.basename;exports.buffersEqual=e.buffersEqual;exports.calculateFileHash=e.calculateFileHash;exports.calculateReadLength=e.calculateReadLength;exports.checkOPFSSupport=e.checkOPFSSupport;exports.convertBlobToUint8Array=e.convertBlobToUint8Array;exports.createBuffer=e.createBuffer;exports.createFDError=e.createFDError;exports.createSyncHandleSafe=e.createSyncHandleSafe;exports.decodeBuffer=e.decodeBuffer;exports.dirname=e.dirname;exports.encodeString=e.encodeString;exports.extname=e.extname;exports.isBinaryFileExtension=e.isBinaryFileExtension;exports.isPathExcluded=e.isPathExcluded;exports.joinPath=e.joinPath;exports.mapDomError=e.mapDomError;exports.matchMinimatch=e.matchMinimatch;exports.normalizeMinimatch=e.normalizeMinimatch;exports.normalizePath=e.normalizePath;exports.removeEntry=e.removeEntry;exports.resolvePath=e.resolvePath;exports.safeCloseSyncHandle=e.safeCloseSyncHandle;exports.splitPath=e.splitPath;exports.validateReadWriteArgs=e.validateReadWriteArgs;exports.withLock=e.withLock;exports.OPFSFileSystem=l;exports.createWorker=u;
2345
+ `,c=typeof self<"u"&&self.Blob&&new Blob(["URL.revokeObjectURL(import.meta.url);",l],{type:"text/javascript;charset=utf-8"});function u(o){let n;try{if(n=c&&(self.URL||self.webkitURL).createObjectURL(c),!n)throw"";const t=new Worker(n,{type:"module",name:o?.name});return t.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(n)}),t}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(l),{type:"module",name:o?.name})}}function s(o){return o instanceof URL?o.pathname:o}class p{#n;constructor(n){const t=d.wrap(new u);this.#n=t,n&&(n.broadcastChannel&&n.broadcastChannel instanceof BroadcastChannel&&(n.broadcastChannel=n.broadcastChannel.name),this.setOptions(n))}async setOptions(n){return this.#n.setOptions(n)}async index(){return this.#n.index()}async readFile(n,t){const r=s(n),i=await this.#n.readFile(r);return t||(t=e.isBinaryFileExtension(r)?"binary":"utf-8"),t==="binary"?i:e.decodeBuffer(i,t)}async writeFile(n,t,r){const i=s(n);r||(r=typeof t!="string"||e.isBinaryFileExtension(i)?"binary":"utf-8");const a=typeof t=="string"?e.encodeString(t,r):t instanceof Uint8Array?t:new Uint8Array(t);return this.#n.writeFile(i,a)}async appendFile(n,t,r){const i=s(n);r||(r=typeof t!="string"||e.isBinaryFileExtension(i)?"binary":"utf-8");const a=typeof t=="string"?e.encodeString(t,r):t instanceof Uint8Array?t:new Uint8Array(t);return this.#n.appendFile(i,a)}async mkdir(n,t){const r=s(n);return this.#n.mkdir(r,t)}async stat(n){const t=s(n);return this.#n.stat(t)}async readDir(n){const t=s(n);return this.#n.readDir(t)}async exists(n){const t=s(n);return this.#n.exists(t)}async clear(n){const t=n?s(n):void 0;return this.#n.clear(t)}async remove(n,t){const r=s(n);return this.#n.remove(r,t)}async realpath(n){const t=s(n);return this.#n.realpath(t)}async rename(n,t,r){const i=s(n),a=s(t);return this.#n.rename(i,a,r)}async copy(n,t,r){const i=s(n),a=s(t);return this.#n.copy(i,a,r)}watch(n,t){const r=s(n);return this.#n.watch(r,t),()=>this.unwatch(r)}unwatch(n){const t=s(n);this.#n.unwatch(t)}async open(n,t){const r=s(n);return this.#n.open(r,t)}async close(n){return this.#n.close(n)}async read(n,t,r,i,a){const{bytesRead:h,buffer:f}=await this.#n.read(n,new Uint8Array(i),0,i,a);return h>0&&t.set(f.subarray(0,h),r),{bytesRead:h,buffer:t}}async write(n,t,r,i,a,h){return this.#n.write(n,t,r,i,a,h)}async fstat(n){return this.#n.fstat(n)}async ftruncate(n,t){return this.#n.ftruncate(n,t)}async fsync(n){return this.#n.fsync(n)}dispose(){this.#n.dispose()}async sync(n,t){const r=n.map(([i,a])=>[s(i),a]);return this.#n.sync(r,t)}async readText(n,t="utf-8"){const r=s(n),i=await this.#n.readFile(r);return e.decodeBuffer(i,t)}async writeText(n,t,r="utf-8"){const i=s(n),a=e.encodeString(t,r);return this.#n.writeFile(i,a)}async appendText(n,t,r="utf-8"){const i=s(n),a=e.encodeString(t,r);return this.#n.appendFile(i,a)}}function m(o){return new p(o)}exports.BINARY_FILE_EXTENSIONS=e.BINARY_FILE_EXTENSIONS;exports.DirectoryNotFoundError=e.DirectoryNotFoundError;exports.FileNotFoundError=e.FileNotFoundError;exports.OPFSError=e.OPFSError;exports.OPFSNotMountedError=e.OPFSNotMountedError;exports.OPFSNotSupportedError=e.OPFSNotSupportedError;exports.PathError=e.PathError;exports.PermissionError=e.PermissionError;exports.StorageError=e.StorageError;exports.TimeoutError=e.TimeoutError;exports.basename=e.basename;exports.buffersEqual=e.buffersEqual;exports.calculateFileHash=e.calculateFileHash;exports.calculateReadLength=e.calculateReadLength;exports.checkOPFSSupport=e.checkOPFSSupport;exports.convertBlobToUint8Array=e.convertBlobToUint8Array;exports.createBuffer=e.createBuffer;exports.createFDError=e.createFDError;exports.createSyncHandleSafe=e.createSyncHandleSafe;exports.decodeBuffer=e.decodeBuffer;exports.dirname=e.dirname;exports.encodeString=e.encodeString;exports.extname=e.extname;exports.isBinaryFileExtension=e.isBinaryFileExtension;exports.isPathExcluded=e.isPathExcluded;exports.joinPath=e.joinPath;exports.mapDomError=e.mapDomError;exports.matchMinimatch=e.matchMinimatch;exports.normalizeMinimatch=e.normalizeMinimatch;exports.normalizePath=e.normalizePath;exports.removeEntry=e.removeEntry;exports.resolvePath=e.resolvePath;exports.safeCloseSyncHandle=e.safeCloseSyncHandle;exports.splitPath=e.splitPath;exports.validateReadWriteArgs=e.validateReadWriteArgs;exports.withLock=e.withLock;exports.OPFSFileSystem=p;exports.createWorker=m;
2346
2346
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/facade.ts","../src/index.ts"],"sourcesContent":["import { wrap } from 'comlink';\n\nimport { decodeBuffer, encodeString, isBinaryFileExtension } from './utils/encoder';\nimport WorkerCtor from './worker?worker&inline';\n\nimport type {\n DirentData,\n Encoding,\n FileOpenOptions,\n FileStat,\n OPFSOptions,\n RemoteOPFSWorker,\n RenameOptions,\n WatchOptions\n} from './types';\n\n/**\n * Facade class that provides a clean interface for communicating with the OPFS worker\n * while hiding Comlink implementation details.\n */\nexport class OPFSFileSystem {\n #worker: RemoteOPFSWorker;\n\n constructor(options?: OPFSOptions) {\n const wrapped = wrap<RemoteOPFSWorker>(new WorkerCtor());\n\n this.#worker = wrapped;\n\n // Set up options if provided\n if (options) {\n // We can't pass a BroadcastChannel instance to the worker, so we need to convert it to a string first\n if (options.broadcastChannel && options.broadcastChannel instanceof BroadcastChannel) {\n options.broadcastChannel = options.broadcastChannel.name;\n }\n\n // Initialize options asynchronously\n void this.setOptions(options);\n }\n }\n\n /**\n * Update configuration options\n */\n async setOptions(options: OPFSOptions) {\n return this.#worker.setOptions(options);\n }\n\n /**\n * Get a complete index of all files and directories in the file system\n */\n async index(): Promise<Map<string, FileStat>> {\n return this.#worker.index();\n }\n\n /**\n * Read a file from the file system\n */\n async readFile(path: string, encoding: 'binary'): Promise<Uint8Array>;\n async readFile(path: string, encoding: Encoding): Promise<string>;\n async readFile(path: string, encoding?: Encoding | 'binary'): Promise<string | Uint8Array>;\n async readFile(\n path: string,\n encoding?: any\n ): Promise<string | Uint8Array> {\n // Get binary data from worker\n const buffer = await this.#worker.readFile(path);\n\n // If no encoding specified, auto-detect based on file extension\n if (!encoding) {\n encoding = isBinaryFileExtension(path) ? 'binary' : 'utf-8';\n }\n\n // Return binary data or decode to string\n return (encoding === 'binary') ? buffer : decodeBuffer(buffer, encoding);\n }\n\n /**\n * Write data to a file\n */\n async writeFile(\n path: string,\n data: string | Uint8Array | ArrayBuffer,\n encoding?: Encoding\n ): Promise<void> {\n // If no encoding specified, auto-detect based on file extension\n if (!encoding) {\n encoding = (typeof data !== 'string' || isBinaryFileExtension(path)) ? 'binary' : 'utf-8';\n }\n\n // Convert data to Uint8Array\n const buffer = typeof data === 'string'\n ? encodeString(data, encoding)\n : (data instanceof Uint8Array ? data : new Uint8Array(data));\n\n return this.#worker.writeFile(path, buffer);\n }\n\n /**\n * Append data to a file\n */\n async appendFile(\n path: string,\n data: string | Uint8Array | ArrayBuffer,\n encoding?: Encoding\n ): Promise<void> {\n // If no encoding specified, auto-detect based on file extension\n if (!encoding) {\n encoding = (typeof data !== 'string' || isBinaryFileExtension(path)) ? 'binary' : 'utf-8';\n }\n\n // Convert data to Uint8Array\n const buffer = typeof data === 'string'\n ? encodeString(data, encoding)\n : (data instanceof Uint8Array ? data : new Uint8Array(data));\n\n return this.#worker.appendFile(path, buffer);\n }\n\n /**\n * Create a directory\n */\n async mkdir(path: string, options?: { recursive?: boolean }): Promise<void> {\n return this.#worker.mkdir(path, options);\n }\n\n /**\n * Get file or directory statistics\n */\n async stat(path: string): Promise<FileStat> {\n return this.#worker.stat(path);\n }\n\n /**\n * Read a directory's contents\n */\n async readDir(path: string): Promise<DirentData[]> {\n return this.#worker.readDir(path);\n }\n\n /**\n * Check if a file or directory exists\n */\n async exists(path: string): Promise<boolean> {\n return this.#worker.exists(path);\n }\n\n /**\n * Clear all contents of a directory without removing the directory itself\n */\n async clear(path?: string): Promise<void> {\n return this.#worker.clear(path);\n }\n\n /**\n * Remove files and directories\n */\n async remove(path: string, options?: { recursive?: boolean; force?: boolean }): Promise<void> {\n return this.#worker.remove(path, options);\n }\n\n /**\n * Resolve a path to an absolute path\n */\n async realpath(path: string): Promise<string> {\n return this.#worker.realpath(path);\n }\n\n /**\n * Rename a file or directory\n */\n async rename(oldPath: string, newPath: string, options?: RenameOptions): Promise<void> {\n return this.#worker.rename(oldPath, newPath, options);\n }\n\n /**\n * Copy files and directories\n */\n async copy(source: string, destination: string, options?: { recursive?: boolean; overwrite?: boolean }): Promise<void> {\n return this.#worker.copy(source, destination, options);\n }\n\n /**\n * Start watching a file or directory for changes\n */\n watch(path: string, options?: WatchOptions): () => void {\n void this.#worker.watch(path, options);\n\n return () => this.unwatch(path);\n }\n\n /**\n * Stop watching a previously watched path\n */\n unwatch(path: string) {\n void this.#worker.unwatch(path);\n }\n\n /**\n * Open a file and return a file descriptor\n */\n async open(path: string, options?: FileOpenOptions): Promise<number> {\n return this.#worker.open(path, options);\n }\n\n /**\n * Close a file descriptor\n */\n async close(fd: number): Promise<void> {\n return this.#worker.close(fd);\n }\n\n /**\n * Read data from a file descriptor\n * \n * This method requires special handling due to Comlink transfer requirements.\n * The buffer is transferred to the worker and back, so the original buffer\n * becomes unusable after the call.\n */\n async read(\n fd: number,\n buffer: Uint8Array,\n offset: number,\n length: number,\n position?: number | null | undefined\n ): Promise<{ bytesRead: number; buffer: Uint8Array }> {\n const { bytesRead, buffer: transferred } = await this.#worker.read(\n fd,\n // Temp buffer to preserve the original buffer\n new Uint8Array(length),\n 0,\n length,\n position\n );\n\n // Copy the data from the transferred buffer to the original buffer\n if (bytesRead > 0) {\n buffer.set(transferred.subarray(0, bytesRead), offset);\n }\n\n return { bytesRead, buffer };\n }\n\n /**\n * Write data to a file descriptor\n */\n async write(\n fd: number,\n buffer: Uint8Array,\n offset?: number,\n length?: number,\n position?: number | null | undefined,\n emitEvent?: boolean\n ): Promise<number> {\n return this.#worker.write(fd, buffer, offset, length, position, emitEvent);\n }\n\n /**\n * Get file status information by file descriptor\n */\n async fstat(fd: number): Promise<FileStat> {\n return this.#worker.fstat(fd);\n }\n\n /**\n * Truncate file to specified size\n */\n async ftruncate(fd: number, size?: number): Promise<void> {\n return this.#worker.ftruncate(fd, size);\n }\n\n /**\n * Synchronize file data to storage (fsync equivalent)\n */\n async fsync(fd: number): Promise<void> {\n return this.#worker.fsync(fd);\n }\n\n /**\n * Dispose of resources and clean up the file system instance\n */\n dispose() {\n void this.#worker.dispose();\n }\n\n /**\n * Synchronize the file system with external data\n */\n async sync(entries: [string, string | Uint8Array | Blob][], options?: { cleanBefore?: boolean }): Promise<void> {\n return this.#worker.sync(entries, options);\n }\n\n /**\n * Read a file as text with automatic encoding detection\n */\n async readText(path: string, encoding: Encoding = 'utf-8'): Promise<string> {\n const buffer = await this.#worker.readFile(path);\n\n return decodeBuffer(buffer, encoding);\n }\n\n /**\n * Write text to a file with specified encoding\n */\n async writeText(path: string, text: string, encoding: Encoding = 'utf-8'): Promise<void> {\n const buffer = encodeString(text, encoding);\n\n return this.#worker.writeFile(path, buffer);\n }\n\n /**\n * Append text to a file with specified encoding\n */\n async appendText(path: string, text: string, encoding: Encoding = 'utf-8'): Promise<void> {\n const buffer = encodeString(text, encoding);\n\n return this.#worker.appendFile(path, buffer);\n }\n}\n","import { OPFSFileSystem } from './facade';\n\nimport type { OPFSOptions } from './types';\n\nexport * from './types';\nexport * from './utils/errors';\nexport * from './utils/helpers';\nexport * from './utils/encoder';\nexport * from './facade';\n\n/**\n * Creates a new file system instance with inline worker\n * @param options - Optional configuration options\n * @returns Promise resolving to the file system interface\n */\nexport function createWorker(\n options?: OPFSOptions\n): OPFSFileSystem {\n return new OPFSFileSystem(options);\n}\n"],"names":["OPFSFileSystem","#worker","options","wrapped","wrap","WorkerCtor","path","encoding","buffer","isBinaryFileExtension","decodeBuffer","data","encodeString","oldPath","newPath","source","destination","fd","offset","length","position","bytesRead","transferred","emitEvent","size","entries","text","createWorker"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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EAAcnB,EAAqB,QAAwB,CACrF,MAAMC,EAASI,EAAAA,aAAac,EAAMnB,CAAQ,EAE1C,OAAO,KAAKN,GAAQ,UAAUK,EAAME,CAAM,CAC9C,CAKA,MAAM,WAAWF,EAAcoB,EAAcnB,EAAqB,QAAwB,CACtF,MAAMC,EAASI,EAAAA,aAAac,EAAMnB,CAAQ,EAE1C,OAAO,KAAKN,GAAQ,WAAWK,EAAME,CAAM,CAC/C,CACJ,CC9SO,SAASmB,EACZzB,EACc,CACd,OAAO,IAAIF,EAAeE,CAAO,CACrC"}
1
+ {"version":3,"file":"index.cjs","sources":["../src/facade.ts","../src/index.ts"],"sourcesContent":["import { wrap } from 'comlink';\n\nimport { decodeBuffer, encodeString, isBinaryFileExtension } from './utils/encoder';\nimport WorkerCtor from './worker?worker&inline';\n\nimport type {\n DirentData,\n Encoding,\n FileOpenOptions,\n FileStat,\n OPFSOptions,\n PathLike,\n RemoteOPFSWorker,\n RenameOptions,\n WatchOptions\n} from './types';\n\n/**\n * Utility function to convert a PathLike to a string path\n * If it's a URI, extracts the pathname; otherwise returns the string as-is\n */\nfunction normalizePath(path: PathLike): string {\n if (path instanceof URL) {\n return path.pathname;\n }\n\n return path;\n}\n\n/**\n * Facade class that provides a clean interface for communicating with the OPFS worker\n * while hiding Comlink implementation details.\n */\nexport class OPFSFileSystem {\n #worker: RemoteOPFSWorker;\n\n constructor(options?: OPFSOptions) {\n const wrapped = wrap<RemoteOPFSWorker>(new WorkerCtor());\n\n this.#worker = wrapped;\n\n // Set up options if provided\n if (options) {\n // We can't pass a BroadcastChannel instance to the worker, so we need to convert it to a string first\n if (options.broadcastChannel && options.broadcastChannel instanceof BroadcastChannel) {\n options.broadcastChannel = options.broadcastChannel.name;\n }\n\n // Initialize options asynchronously\n void this.setOptions(options);\n }\n }\n\n /**\n * Update configuration options\n */\n async setOptions(options: OPFSOptions) {\n return this.#worker.setOptions(options);\n }\n\n /**\n * Get a complete index of all files and directories in the file system\n */\n async index(): Promise<Map<string, FileStat>> {\n return this.#worker.index();\n }\n\n /**\n * Read a file from the file system\n */\n async readFile(path: PathLike, encoding: 'binary'): Promise<Uint8Array>;\n async readFile(path: PathLike, encoding: Encoding): Promise<string>;\n async readFile(path: PathLike, encoding?: Encoding | 'binary'): Promise<string | Uint8Array>;\n async readFile(\n path: PathLike,\n encoding?: any\n ): Promise<string | Uint8Array> {\n const normalizedPath = normalizePath(path);\n // Get binary data from worker\n const buffer = await this.#worker.readFile(normalizedPath);\n\n // If no encoding specified, auto-detect based on file extension\n if (!encoding) {\n encoding = isBinaryFileExtension(normalizedPath) ? 'binary' : 'utf-8';\n }\n\n // Return binary data or decode to string\n return (encoding === 'binary') ? buffer : decodeBuffer(buffer, encoding);\n }\n\n /**\n * Write data to a file\n */\n async writeFile(\n path: PathLike,\n data: string | Uint8Array | ArrayBuffer,\n encoding?: Encoding\n ): Promise<void> {\n const normalizedPath = normalizePath(path);\n\n // If no encoding specified, auto-detect based on file extension\n if (!encoding) {\n encoding = (typeof data !== 'string' || isBinaryFileExtension(normalizedPath)) ? 'binary' : 'utf-8';\n }\n\n // Convert data to Uint8Array\n const buffer = typeof data === 'string'\n ? encodeString(data, encoding)\n : (data instanceof Uint8Array ? data : new Uint8Array(data));\n\n return this.#worker.writeFile(normalizedPath, buffer);\n }\n\n /**\n * Append data to a file\n */\n async appendFile(\n path: PathLike,\n data: string | Uint8Array | ArrayBuffer,\n encoding?: Encoding\n ): Promise<void> {\n const normalizedPath = normalizePath(path);\n\n // If no encoding specified, auto-detect based on file extension\n if (!encoding) {\n encoding = (typeof data !== 'string' || isBinaryFileExtension(normalizedPath)) ? 'binary' : 'utf-8';\n }\n\n // Convert data to Uint8Array\n const buffer = typeof data === 'string'\n ? encodeString(data, encoding)\n : (data instanceof Uint8Array ? data : new Uint8Array(data));\n\n return this.#worker.appendFile(normalizedPath, buffer);\n }\n\n /**\n * Create a directory\n */\n async mkdir(path: PathLike, options?: { recursive?: boolean }): Promise<void> {\n const normalizedPath = normalizePath(path);\n\n return this.#worker.mkdir(normalizedPath, options);\n }\n\n /**\n * Get file or directory statistics\n */\n async stat(path: PathLike): Promise<FileStat> {\n const normalizedPath = normalizePath(path);\n\n return this.#worker.stat(normalizedPath);\n }\n\n /**\n * Read a directory's contents\n */\n async readDir(path: PathLike): Promise<DirentData[]> {\n const normalizedPath = normalizePath(path);\n\n return this.#worker.readDir(normalizedPath);\n }\n\n /**\n * Check if a file or directory exists\n */\n async exists(path: PathLike): Promise<boolean> {\n const normalizedPath = normalizePath(path);\n\n return this.#worker.exists(normalizedPath);\n }\n\n /**\n * Clear all contents of a directory without removing the directory itself\n */\n async clear(path?: PathLike): Promise<void> {\n const normalizedPath = path ? normalizePath(path) : undefined;\n\n return this.#worker.clear(normalizedPath);\n }\n\n /**\n * Remove files and directories\n */\n async remove(path: PathLike, options?: { recursive?: boolean; force?: boolean }): Promise<void> {\n const normalizedPath = normalizePath(path);\n\n return this.#worker.remove(normalizedPath, options);\n }\n\n /**\n * Resolve a path to an absolute path\n */\n async realpath(path: PathLike): Promise<string> {\n const normalizedPath = normalizePath(path);\n\n return this.#worker.realpath(normalizedPath);\n }\n\n /**\n * Rename a file or directory\n */\n async rename(oldPath: PathLike, newPath: PathLike, options?: RenameOptions): Promise<void> {\n const normalizedOldPath = normalizePath(oldPath);\n const normalizedNewPath = normalizePath(newPath);\n\n return this.#worker.rename(normalizedOldPath, normalizedNewPath, options);\n }\n\n /**\n * Copy files and directories\n */\n async copy(source: PathLike, destination: PathLike, options?: { recursive?: boolean; overwrite?: boolean }): Promise<void> {\n const normalizedSource = normalizePath(source);\n const normalizedDestination = normalizePath(destination);\n\n return this.#worker.copy(normalizedSource, normalizedDestination, options);\n }\n\n /**\n * Start watching a file or directory for changes\n */\n watch(path: PathLike, options?: WatchOptions): () => void {\n const normalizedPath = normalizePath(path);\n\n void this.#worker.watch(normalizedPath, options);\n\n return () => this.unwatch(normalizedPath);\n }\n\n /**\n * Stop watching a previously watched path\n */\n unwatch(path: PathLike) {\n const normalizedPath = normalizePath(path);\n\n void this.#worker.unwatch(normalizedPath);\n }\n\n /**\n * Open a file and return a file descriptor\n */\n async open(path: PathLike, options?: FileOpenOptions): Promise<number> {\n const normalizedPath = normalizePath(path);\n\n return this.#worker.open(normalizedPath, options);\n }\n\n /**\n * Close a file descriptor\n */\n async close(fd: number): Promise<void> {\n return this.#worker.close(fd);\n }\n\n /**\n * Read data from a file descriptor\n * \n * This method requires special handling due to Comlink transfer requirements.\n * The buffer is transferred to the worker and back, so the original buffer\n * becomes unusable after the call.\n */\n async read(\n fd: number,\n buffer: Uint8Array,\n offset: number,\n length: number,\n position?: number | null | undefined\n ): Promise<{ bytesRead: number; buffer: Uint8Array }> {\n const { bytesRead, buffer: transferred } = await this.#worker.read(\n fd,\n // Temp buffer to preserve the original buffer\n new Uint8Array(length),\n 0,\n length,\n position\n );\n\n // Copy the data from the transferred buffer to the original buffer\n if (bytesRead > 0) {\n buffer.set(transferred.subarray(0, bytesRead), offset);\n }\n\n return { bytesRead, buffer };\n }\n\n /**\n * Write data to a file descriptor\n */\n async write(\n fd: number,\n buffer: Uint8Array,\n offset?: number,\n length?: number,\n position?: number | null | undefined,\n emitEvent?: boolean\n ): Promise<number> {\n return this.#worker.write(fd, buffer, offset, length, position, emitEvent);\n }\n\n /**\n * Get file status information by file descriptor\n */\n async fstat(fd: number): Promise<FileStat> {\n return this.#worker.fstat(fd);\n }\n\n /**\n * Truncate file to specified size\n */\n async ftruncate(fd: number, size?: number): Promise<void> {\n return this.#worker.ftruncate(fd, size);\n }\n\n /**\n * Synchronize file data to storage (fsync equivalent)\n */\n async fsync(fd: number): Promise<void> {\n return this.#worker.fsync(fd);\n }\n\n /**\n * Dispose of resources and clean up the file system instance\n */\n dispose() {\n void this.#worker.dispose();\n }\n\n /**\n * Synchronize the file system with external data\n */\n async sync(entries: [PathLike, string | Uint8Array | Blob][], options?: { cleanBefore?: boolean }): Promise<void> {\n const normalizedEntries = entries.map(([path, data]) => [normalizePath(path), data] as [string, string | Uint8Array | Blob]);\n\n return this.#worker.sync(normalizedEntries, options);\n }\n\n /**\n * Read a file as text with automatic encoding detection\n */\n async readText(path: PathLike, encoding: Encoding = 'utf-8'): Promise<string> {\n const normalizedPath = normalizePath(path);\n const buffer = await this.#worker.readFile(normalizedPath);\n\n return decodeBuffer(buffer, encoding);\n }\n\n /**\n * Write text to a file with specified encoding\n */\n async writeText(path: PathLike, text: string, encoding: Encoding = 'utf-8'): Promise<void> {\n const normalizedPath = normalizePath(path);\n const buffer = encodeString(text, encoding);\n\n return this.#worker.writeFile(normalizedPath, buffer);\n }\n\n /**\n * Append text to a file with specified encoding\n */\n async appendText(path: PathLike, text: string, encoding: Encoding = 'utf-8'): Promise<void> {\n const normalizedPath = normalizePath(path);\n const buffer = encodeString(text, encoding);\n\n return this.#worker.appendFile(normalizedPath, buffer);\n }\n}\n","import { OPFSFileSystem } from './facade';\n\nimport type { OPFSOptions } from './types';\n\nexport * from './types';\nexport * from './utils/errors';\nexport * from './utils/helpers';\nexport * from './utils/encoder';\nexport * from './facade';\n\n/**\n * Creates a new file system instance with inline worker\n * @param options - Optional configuration options\n * @returns Promise resolving to the file system interface\n */\nexport function createWorker(\n options?: OPFSOptions\n): OPFSFileSystem {\n return new OPFSFileSystem(options);\n}\n"],"names":["normalizePath","path","OPFSFileSystem","#worker","options","wrapped","wrap","WorkerCtor","encoding","normalizedPath","buffer","isBinaryFileExtension","decodeBuffer","data","encodeString","oldPath","newPath","normalizedOldPath","normalizedNewPath","source","destination","normalizedSource","normalizedDestination","fd","offset","length","position","bytesRead","transferred","emitEvent","size","entries","normalizedEntries","text","createWorker"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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C1C,CAKA,MAAM,MAAMP,EAA2B,CACnC,OAAO,KAAKpB,GAAQ,MAAMoB,CAAE,CAChC,CAKA,SAAU,CACD,KAAKpB,GAAQ,QAAA,CACtB,CAKA,MAAM,KAAK4B,EAAmD3B,EAAoD,CAC9G,MAAM4B,EAAoBD,EAAQ,IAAI,CAAC,CAAC9B,EAAMY,CAAI,IAAM,CAACb,EAAcC,CAAI,EAAGY,CAAI,CAAyC,EAE3H,OAAO,KAAKV,GAAQ,KAAK6B,EAAmB5B,CAAO,CACvD,CAKA,MAAM,SAASH,EAAgBO,EAAqB,QAA0B,CAC1E,MAAMC,EAAiBT,EAAcC,CAAI,EACnCS,EAAS,MAAM,KAAKP,GAAQ,SAASM,CAAc,EAEzD,OAAOG,EAAAA,aAAaF,EAAQF,CAAQ,CACxC,CAKA,MAAM,UAAUP,EAAgBgC,EAAczB,EAAqB,QAAwB,CACvF,MAAMC,EAAiBT,EAAcC,CAAI,EACnCS,EAASI,EAAAA,aAAamB,EAAMzB,CAAQ,EAE1C,OAAO,KAAKL,GAAQ,UAAUM,EAAgBC,CAAM,CACxD,CAKA,MAAM,WAAWT,EAAgBgC,EAAczB,EAAqB,QAAwB,CACxF,MAAMC,EAAiBT,EAAcC,CAAI,EACnCS,EAASI,EAAAA,aAAamB,EAAMzB,CAAQ,EAE1C,OAAO,KAAKL,GAAQ,WAAWM,EAAgBC,CAAM,CACzD,CACJ,CC/VO,SAASwB,EACZ9B,EACc,CACd,OAAO,IAAIF,EAAeE,CAAO,CACrC"}
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import { wrap as d } from "comlink";
2
- import { i as h, d as c, e as a } from "./helpers-CkNHswLp.js";
3
- import { E, D as x, F as S, O as F, b as P, a as O, P as A, c as T, S as I, T as $, h as R, v as C, u as _, B as N, g as D, x as k, t as M, f as L, C as j, k as W, q as z, p as U, j as H, m as B, o as G, l as q, n as V, y as Y, r as X, A as Z, s as J, z as K, w as Q } from "./helpers-CkNHswLp.js";
4
- const p = `/**
1
+ import { wrap as u } from "comlink";
2
+ import { i as c, d as l, e as h } from "./helpers-CkNHswLp.js";
3
+ import { E as x, D as S, F as P, O as F, b as O, a as A, P as T, c as I, S as R, T as $, h as C, v as _, u as N, B as D, g as z, x as k, t as M, f as L, C as j, k as W, q as U, p as H, j as B, m as G, o as q, l as V, n as Y, y as X, r as Z, A as J, s as K, z as Q, w as nn } from "./helpers-CkNHswLp.js";
4
+ const f = `/**
5
5
  * @license
6
6
  * Copyright 2019 Google LLC
7
7
  * SPDX-License-Identifier: Apache-2.0
@@ -2345,32 +2345,35 @@ class es {
2345
2345
  }
2346
2346
  typeof globalThis < "u" && globalThis.constructor.name === "DedicatedWorkerGlobalScope" && K(new es());
2347
2347
  //# sourceMappingURL=worker-CLvhwwfc.js.map
2348
- `, l = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", p], { type: "text/javascript;charset=utf-8" });
2349
- function u(s) {
2348
+ `, p = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", f], { type: "text/javascript;charset=utf-8" });
2349
+ function m(a) {
2350
2350
  let n;
2351
2351
  try {
2352
- if (n = l && (self.URL || self.webkitURL).createObjectURL(l), !n) throw "";
2352
+ if (n = p && (self.URL || self.webkitURL).createObjectURL(p), !n) throw "";
2353
2353
  const t = new Worker(n, {
2354
2354
  type: "module",
2355
- name: s?.name
2355
+ name: a?.name
2356
2356
  });
2357
2357
  return t.addEventListener("error", () => {
2358
2358
  (self.URL || self.webkitURL).revokeObjectURL(n);
2359
2359
  }), t;
2360
2360
  } catch {
2361
2361
  return new Worker(
2362
- "data:text/javascript;charset=utf-8," + encodeURIComponent(p),
2362
+ "data:text/javascript;charset=utf-8," + encodeURIComponent(f),
2363
2363
  {
2364
2364
  type: "module",
2365
- name: s?.name
2365
+ name: a?.name
2366
2366
  }
2367
2367
  );
2368
2368
  }
2369
2369
  }
2370
+ function s(a) {
2371
+ return a instanceof URL ? a.pathname : a;
2372
+ }
2370
2373
  class w {
2371
2374
  #n;
2372
2375
  constructor(n) {
2373
- const t = d(new u());
2376
+ const t = u(new m());
2374
2377
  this.#n = t, n && (n.broadcastChannel && n.broadcastChannel instanceof BroadcastChannel && (n.broadcastChannel = n.broadcastChannel.name), this.setOptions(n));
2375
2378
  }
2376
2379
  /**
@@ -2386,96 +2389,110 @@ class w {
2386
2389
  return this.#n.index();
2387
2390
  }
2388
2391
  async readFile(n, t) {
2389
- const e = await this.#n.readFile(n);
2390
- return t || (t = h(n) ? "binary" : "utf-8"), t === "binary" ? e : c(e, t);
2392
+ const e = s(n), r = await this.#n.readFile(e);
2393
+ return t || (t = c(e) ? "binary" : "utf-8"), t === "binary" ? r : l(r, t);
2391
2394
  }
2392
2395
  /**
2393
2396
  * Write data to a file
2394
2397
  */
2395
2398
  async writeFile(n, t, e) {
2396
- e || (e = typeof t != "string" || h(n) ? "binary" : "utf-8");
2397
- const r = typeof t == "string" ? a(t, e) : t instanceof Uint8Array ? t : new Uint8Array(t);
2398
- return this.#n.writeFile(n, r);
2399
+ const r = s(n);
2400
+ e || (e = typeof t != "string" || c(r) ? "binary" : "utf-8");
2401
+ const i = typeof t == "string" ? h(t, e) : t instanceof Uint8Array ? t : new Uint8Array(t);
2402
+ return this.#n.writeFile(r, i);
2399
2403
  }
2400
2404
  /**
2401
2405
  * Append data to a file
2402
2406
  */
2403
2407
  async appendFile(n, t, e) {
2404
- e || (e = typeof t != "string" || h(n) ? "binary" : "utf-8");
2405
- const r = typeof t == "string" ? a(t, e) : t instanceof Uint8Array ? t : new Uint8Array(t);
2406
- return this.#n.appendFile(n, r);
2408
+ const r = s(n);
2409
+ e || (e = typeof t != "string" || c(r) ? "binary" : "utf-8");
2410
+ const i = typeof t == "string" ? h(t, e) : t instanceof Uint8Array ? t : new Uint8Array(t);
2411
+ return this.#n.appendFile(r, i);
2407
2412
  }
2408
2413
  /**
2409
2414
  * Create a directory
2410
2415
  */
2411
2416
  async mkdir(n, t) {
2412
- return this.#n.mkdir(n, t);
2417
+ const e = s(n);
2418
+ return this.#n.mkdir(e, t);
2413
2419
  }
2414
2420
  /**
2415
2421
  * Get file or directory statistics
2416
2422
  */
2417
2423
  async stat(n) {
2418
- return this.#n.stat(n);
2424
+ const t = s(n);
2425
+ return this.#n.stat(t);
2419
2426
  }
2420
2427
  /**
2421
2428
  * Read a directory's contents
2422
2429
  */
2423
2430
  async readDir(n) {
2424
- return this.#n.readDir(n);
2431
+ const t = s(n);
2432
+ return this.#n.readDir(t);
2425
2433
  }
2426
2434
  /**
2427
2435
  * Check if a file or directory exists
2428
2436
  */
2429
2437
  async exists(n) {
2430
- return this.#n.exists(n);
2438
+ const t = s(n);
2439
+ return this.#n.exists(t);
2431
2440
  }
2432
2441
  /**
2433
2442
  * Clear all contents of a directory without removing the directory itself
2434
2443
  */
2435
2444
  async clear(n) {
2436
- return this.#n.clear(n);
2445
+ const t = n ? s(n) : void 0;
2446
+ return this.#n.clear(t);
2437
2447
  }
2438
2448
  /**
2439
2449
  * Remove files and directories
2440
2450
  */
2441
2451
  async remove(n, t) {
2442
- return this.#n.remove(n, t);
2452
+ const e = s(n);
2453
+ return this.#n.remove(e, t);
2443
2454
  }
2444
2455
  /**
2445
2456
  * Resolve a path to an absolute path
2446
2457
  */
2447
2458
  async realpath(n) {
2448
- return this.#n.realpath(n);
2459
+ const t = s(n);
2460
+ return this.#n.realpath(t);
2449
2461
  }
2450
2462
  /**
2451
2463
  * Rename a file or directory
2452
2464
  */
2453
2465
  async rename(n, t, e) {
2454
- return this.#n.rename(n, t, e);
2466
+ const r = s(n), i = s(t);
2467
+ return this.#n.rename(r, i, e);
2455
2468
  }
2456
2469
  /**
2457
2470
  * Copy files and directories
2458
2471
  */
2459
2472
  async copy(n, t, e) {
2460
- return this.#n.copy(n, t, e);
2473
+ const r = s(n), i = s(t);
2474
+ return this.#n.copy(r, i, e);
2461
2475
  }
2462
2476
  /**
2463
2477
  * Start watching a file or directory for changes
2464
2478
  */
2465
2479
  watch(n, t) {
2466
- return this.#n.watch(n, t), () => this.unwatch(n);
2480
+ const e = s(n);
2481
+ return this.#n.watch(e, t), () => this.unwatch(e);
2467
2482
  }
2468
2483
  /**
2469
2484
  * Stop watching a previously watched path
2470
2485
  */
2471
2486
  unwatch(n) {
2472
- this.#n.unwatch(n);
2487
+ const t = s(n);
2488
+ this.#n.unwatch(t);
2473
2489
  }
2474
2490
  /**
2475
2491
  * Open a file and return a file descriptor
2476
2492
  */
2477
2493
  async open(n, t) {
2478
- return this.#n.open(n, t);
2494
+ const e = s(n);
2495
+ return this.#n.open(e, t);
2479
2496
  }
2480
2497
  /**
2481
2498
  * Close a file descriptor
@@ -2490,22 +2507,22 @@ class w {
2490
2507
  * The buffer is transferred to the worker and back, so the original buffer
2491
2508
  * becomes unusable after the call.
2492
2509
  */
2493
- async read(n, t, e, r, o) {
2494
- const { bytesRead: i, buffer: f } = await this.#n.read(
2510
+ async read(n, t, e, r, i) {
2511
+ const { bytesRead: o, buffer: d } = await this.#n.read(
2495
2512
  n,
2496
2513
  // Temp buffer to preserve the original buffer
2497
2514
  new Uint8Array(r),
2498
2515
  0,
2499
2516
  r,
2500
- o
2517
+ i
2501
2518
  );
2502
- return i > 0 && t.set(f.subarray(0, i), e), { bytesRead: i, buffer: t };
2519
+ return o > 0 && t.set(d.subarray(0, o), e), { bytesRead: o, buffer: t };
2503
2520
  }
2504
2521
  /**
2505
2522
  * Write data to a file descriptor
2506
2523
  */
2507
- async write(n, t, e, r, o, i) {
2508
- return this.#n.write(n, t, e, r, o, i);
2524
+ async write(n, t, e, r, i, o) {
2525
+ return this.#n.write(n, t, e, r, i, o);
2509
2526
  }
2510
2527
  /**
2511
2528
  * Get file status information by file descriptor
@@ -2535,71 +2552,72 @@ class w {
2535
2552
  * Synchronize the file system with external data
2536
2553
  */
2537
2554
  async sync(n, t) {
2538
- return this.#n.sync(n, t);
2555
+ const e = n.map(([r, i]) => [s(r), i]);
2556
+ return this.#n.sync(e, t);
2539
2557
  }
2540
2558
  /**
2541
2559
  * Read a file as text with automatic encoding detection
2542
2560
  */
2543
2561
  async readText(n, t = "utf-8") {
2544
- const e = await this.#n.readFile(n);
2545
- return c(e, t);
2562
+ const e = s(n), r = await this.#n.readFile(e);
2563
+ return l(r, t);
2546
2564
  }
2547
2565
  /**
2548
2566
  * Write text to a file with specified encoding
2549
2567
  */
2550
2568
  async writeText(n, t, e = "utf-8") {
2551
- const r = a(t, e);
2552
- return this.#n.writeFile(n, r);
2569
+ const r = s(n), i = h(t, e);
2570
+ return this.#n.writeFile(r, i);
2553
2571
  }
2554
2572
  /**
2555
2573
  * Append text to a file with specified encoding
2556
2574
  */
2557
2575
  async appendText(n, t, e = "utf-8") {
2558
- const r = a(t, e);
2559
- return this.#n.appendFile(n, r);
2576
+ const r = s(n), i = h(t, e);
2577
+ return this.#n.appendFile(r, i);
2560
2578
  }
2561
2579
  }
2562
- function g(s) {
2563
- return new w(s);
2580
+ function b(a) {
2581
+ return new w(a);
2564
2582
  }
2565
2583
  export {
2566
- E as BINARY_FILE_EXTENSIONS,
2567
- x as DirectoryNotFoundError,
2568
- S as FileNotFoundError,
2584
+ x as BINARY_FILE_EXTENSIONS,
2585
+ S as DirectoryNotFoundError,
2586
+ P as FileNotFoundError,
2569
2587
  F as OPFSError,
2570
2588
  w as OPFSFileSystem,
2571
- P as OPFSNotMountedError,
2572
- O as OPFSNotSupportedError,
2573
- A as PathError,
2574
- T as PermissionError,
2575
- I as StorageError,
2589
+ O as OPFSNotMountedError,
2590
+ A as OPFSNotSupportedError,
2591
+ T as PathError,
2592
+ I as PermissionError,
2593
+ R as StorageError,
2576
2594
  $ as TimeoutError,
2577
- R as basename,
2578
- C as buffersEqual,
2579
- _ as calculateFileHash,
2580
- N as calculateReadLength,
2581
- D as checkOPFSSupport,
2595
+ C as basename,
2596
+ _ as buffersEqual,
2597
+ N as calculateFileHash,
2598
+ D as calculateReadLength,
2599
+ z as checkOPFSSupport,
2582
2600
  k as convertBlobToUint8Array,
2583
2601
  M as createBuffer,
2584
2602
  L as createFDError,
2585
2603
  j as createSyncHandleSafe,
2586
- g as createWorker,
2587
- c as decodeBuffer,
2604
+ b as createWorker,
2605
+ l as decodeBuffer,
2588
2606
  W as dirname,
2589
- a as encodeString,
2590
- z as extname,
2591
- h as isBinaryFileExtension,
2592
- U as isPathExcluded,
2593
- H as joinPath,
2594
- B as mapDomError,
2595
- G as matchMinimatch,
2596
- q as normalizeMinimatch,
2597
- V as normalizePath,
2598
- Y as removeEntry,
2599
- X as resolvePath,
2600
- Z as safeCloseSyncHandle,
2601
- J as splitPath,
2602
- K as validateReadWriteArgs,
2603
- Q as withLock
2607
+ h as encodeString,
2608
+ U as extname,
2609
+ c as isBinaryFileExtension,
2610
+ H as isPathExcluded,
2611
+ B as joinPath,
2612
+ G as mapDomError,
2613
+ q as matchMinimatch,
2614
+ V as normalizeMinimatch,
2615
+ Y as normalizePath,
2616
+ X as removeEntry,
2617
+ Z as resolvePath,
2618
+ J as safeCloseSyncHandle,
2619
+ K as splitPath,
2620
+ Q as validateReadWriteArgs,
2621
+ nn as withLock
2604
2622
  };
2605
2623
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/facade.ts","../src/index.ts"],"sourcesContent":["import { wrap } from 'comlink';\n\nimport { decodeBuffer, encodeString, isBinaryFileExtension } from './utils/encoder';\nimport WorkerCtor from './worker?worker&inline';\n\nimport type {\n DirentData,\n Encoding,\n FileOpenOptions,\n FileStat,\n OPFSOptions,\n RemoteOPFSWorker,\n RenameOptions,\n WatchOptions\n} from './types';\n\n/**\n * Facade class that provides a clean interface for communicating with the OPFS worker\n * while hiding Comlink implementation details.\n */\nexport class OPFSFileSystem {\n #worker: RemoteOPFSWorker;\n\n constructor(options?: OPFSOptions) {\n const wrapped = wrap<RemoteOPFSWorker>(new WorkerCtor());\n\n this.#worker = wrapped;\n\n // Set up options if provided\n if (options) {\n // We can't pass a BroadcastChannel instance to the worker, so we need to convert it to a string first\n if (options.broadcastChannel && options.broadcastChannel instanceof BroadcastChannel) {\n options.broadcastChannel = options.broadcastChannel.name;\n }\n\n // Initialize options asynchronously\n void this.setOptions(options);\n }\n }\n\n /**\n * Update configuration options\n */\n async setOptions(options: OPFSOptions) {\n return this.#worker.setOptions(options);\n }\n\n /**\n * Get a complete index of all files and directories in the file system\n */\n async index(): Promise<Map<string, FileStat>> {\n return this.#worker.index();\n }\n\n /**\n * Read a file from the file system\n */\n async readFile(path: string, encoding: 'binary'): Promise<Uint8Array>;\n async readFile(path: string, encoding: Encoding): Promise<string>;\n async readFile(path: string, encoding?: Encoding | 'binary'): Promise<string | Uint8Array>;\n async readFile(\n path: string,\n encoding?: any\n ): Promise<string | Uint8Array> {\n // Get binary data from worker\n const buffer = await this.#worker.readFile(path);\n\n // If no encoding specified, auto-detect based on file extension\n if (!encoding) {\n encoding = isBinaryFileExtension(path) ? 'binary' : 'utf-8';\n }\n\n // Return binary data or decode to string\n return (encoding === 'binary') ? buffer : decodeBuffer(buffer, encoding);\n }\n\n /**\n * Write data to a file\n */\n async writeFile(\n path: string,\n data: string | Uint8Array | ArrayBuffer,\n encoding?: Encoding\n ): Promise<void> {\n // If no encoding specified, auto-detect based on file extension\n if (!encoding) {\n encoding = (typeof data !== 'string' || isBinaryFileExtension(path)) ? 'binary' : 'utf-8';\n }\n\n // Convert data to Uint8Array\n const buffer = typeof data === 'string'\n ? encodeString(data, encoding)\n : (data instanceof Uint8Array ? data : new Uint8Array(data));\n\n return this.#worker.writeFile(path, buffer);\n }\n\n /**\n * Append data to a file\n */\n async appendFile(\n path: string,\n data: string | Uint8Array | ArrayBuffer,\n encoding?: Encoding\n ): Promise<void> {\n // If no encoding specified, auto-detect based on file extension\n if (!encoding) {\n encoding = (typeof data !== 'string' || isBinaryFileExtension(path)) ? 'binary' : 'utf-8';\n }\n\n // Convert data to Uint8Array\n const buffer = typeof data === 'string'\n ? encodeString(data, encoding)\n : (data instanceof Uint8Array ? data : new Uint8Array(data));\n\n return this.#worker.appendFile(path, buffer);\n }\n\n /**\n * Create a directory\n */\n async mkdir(path: string, options?: { recursive?: boolean }): Promise<void> {\n return this.#worker.mkdir(path, options);\n }\n\n /**\n * Get file or directory statistics\n */\n async stat(path: string): Promise<FileStat> {\n return this.#worker.stat(path);\n }\n\n /**\n * Read a directory's contents\n */\n async readDir(path: string): Promise<DirentData[]> {\n return this.#worker.readDir(path);\n }\n\n /**\n * Check if a file or directory exists\n */\n async exists(path: string): Promise<boolean> {\n return this.#worker.exists(path);\n }\n\n /**\n * Clear all contents of a directory without removing the directory itself\n */\n async clear(path?: string): Promise<void> {\n return this.#worker.clear(path);\n }\n\n /**\n * Remove files and directories\n */\n async remove(path: string, options?: { recursive?: boolean; force?: boolean }): Promise<void> {\n return this.#worker.remove(path, options);\n }\n\n /**\n * Resolve a path to an absolute path\n */\n async realpath(path: string): Promise<string> {\n return this.#worker.realpath(path);\n }\n\n /**\n * Rename a file or directory\n */\n async rename(oldPath: string, newPath: string, options?: RenameOptions): Promise<void> {\n return this.#worker.rename(oldPath, newPath, options);\n }\n\n /**\n * Copy files and directories\n */\n async copy(source: string, destination: string, options?: { recursive?: boolean; overwrite?: boolean }): Promise<void> {\n return this.#worker.copy(source, destination, options);\n }\n\n /**\n * Start watching a file or directory for changes\n */\n watch(path: string, options?: WatchOptions): () => void {\n void this.#worker.watch(path, options);\n\n return () => this.unwatch(path);\n }\n\n /**\n * Stop watching a previously watched path\n */\n unwatch(path: string) {\n void this.#worker.unwatch(path);\n }\n\n /**\n * Open a file and return a file descriptor\n */\n async open(path: string, options?: FileOpenOptions): Promise<number> {\n return this.#worker.open(path, options);\n }\n\n /**\n * Close a file descriptor\n */\n async close(fd: number): Promise<void> {\n return this.#worker.close(fd);\n }\n\n /**\n * Read data from a file descriptor\n * \n * This method requires special handling due to Comlink transfer requirements.\n * The buffer is transferred to the worker and back, so the original buffer\n * becomes unusable after the call.\n */\n async read(\n fd: number,\n buffer: Uint8Array,\n offset: number,\n length: number,\n position?: number | null | undefined\n ): Promise<{ bytesRead: number; buffer: Uint8Array }> {\n const { bytesRead, buffer: transferred } = await this.#worker.read(\n fd,\n // Temp buffer to preserve the original buffer\n new Uint8Array(length),\n 0,\n length,\n position\n );\n\n // Copy the data from the transferred buffer to the original buffer\n if (bytesRead > 0) {\n buffer.set(transferred.subarray(0, bytesRead), offset);\n }\n\n return { bytesRead, buffer };\n }\n\n /**\n * Write data to a file descriptor\n */\n async write(\n fd: number,\n buffer: Uint8Array,\n offset?: number,\n length?: number,\n position?: number | null | undefined,\n emitEvent?: boolean\n ): Promise<number> {\n return this.#worker.write(fd, buffer, offset, length, position, emitEvent);\n }\n\n /**\n * Get file status information by file descriptor\n */\n async fstat(fd: number): Promise<FileStat> {\n return this.#worker.fstat(fd);\n }\n\n /**\n * Truncate file to specified size\n */\n async ftruncate(fd: number, size?: number): Promise<void> {\n return this.#worker.ftruncate(fd, size);\n }\n\n /**\n * Synchronize file data to storage (fsync equivalent)\n */\n async fsync(fd: number): Promise<void> {\n return this.#worker.fsync(fd);\n }\n\n /**\n * Dispose of resources and clean up the file system instance\n */\n dispose() {\n void this.#worker.dispose();\n }\n\n /**\n * Synchronize the file system with external data\n */\n async sync(entries: [string, string | Uint8Array | Blob][], options?: { cleanBefore?: boolean }): Promise<void> {\n return this.#worker.sync(entries, options);\n }\n\n /**\n * Read a file as text with automatic encoding detection\n */\n async readText(path: string, encoding: Encoding = 'utf-8'): Promise<string> {\n const buffer = await this.#worker.readFile(path);\n\n return decodeBuffer(buffer, encoding);\n }\n\n /**\n * Write text to a file with specified encoding\n */\n async writeText(path: string, text: string, encoding: Encoding = 'utf-8'): Promise<void> {\n const buffer = encodeString(text, encoding);\n\n return this.#worker.writeFile(path, buffer);\n }\n\n /**\n * Append text to a file with specified encoding\n */\n async appendText(path: string, text: string, encoding: Encoding = 'utf-8'): Promise<void> {\n const buffer = encodeString(text, encoding);\n\n return this.#worker.appendFile(path, buffer);\n }\n}\n","import { OPFSFileSystem } from './facade';\n\nimport type { OPFSOptions } from './types';\n\nexport * from './types';\nexport * from './utils/errors';\nexport * from './utils/helpers';\nexport * from './utils/encoder';\nexport * from './facade';\n\n/**\n * Creates a new file system instance with inline worker\n * @param options - Optional configuration options\n * @returns Promise resolving to the file system interface\n */\nexport function createWorker(\n options?: OPFSOptions\n): OPFSFileSystem {\n return new OPFSFileSystem(options);\n}\n"],"names":["OPFSFileSystem","#worker","options","wrapped","wrap","WorkerCtor","path","encoding","buffer","isBinaryFileExtension","decodeBuffer","data","encodeString","oldPath","newPath","source","destination","fd","offset","length","position","bytesRead","transferred","emitEvent","size","entries","text","createWorker"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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WAAO,KAAKN,GAAQ,UAAUK,GAAME,CAAM;AAAA,EAC9C;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,WAAWF,GAAcoB,GAAcnB,IAAqB,SAAwB;AACtF,UAAMC,IAASI,EAAac,GAAMnB,CAAQ;AAE1C,WAAO,KAAKN,GAAQ,WAAWK,GAAME,CAAM;AAAA,EAC/C;AACJ;AC9SO,SAASmB,EACZzB,GACc;AACd,SAAO,IAAIF,EAAeE,CAAO;AACrC;"}
1
+ {"version":3,"file":"index.js","sources":["../src/facade.ts","../src/index.ts"],"sourcesContent":["import { wrap } from 'comlink';\n\nimport { decodeBuffer, encodeString, isBinaryFileExtension } from './utils/encoder';\nimport WorkerCtor from './worker?worker&inline';\n\nimport type {\n DirentData,\n Encoding,\n FileOpenOptions,\n FileStat,\n OPFSOptions,\n PathLike,\n RemoteOPFSWorker,\n RenameOptions,\n WatchOptions\n} from './types';\n\n/**\n * Utility function to convert a PathLike to a string path\n * If it's a URI, extracts the pathname; otherwise returns the string as-is\n */\nfunction normalizePath(path: PathLike): string {\n if (path instanceof URL) {\n return path.pathname;\n }\n\n return path;\n}\n\n/**\n * Facade class that provides a clean interface for communicating with the OPFS worker\n * while hiding Comlink implementation details.\n */\nexport class OPFSFileSystem {\n #worker: RemoteOPFSWorker;\n\n constructor(options?: OPFSOptions) {\n const wrapped = wrap<RemoteOPFSWorker>(new WorkerCtor());\n\n this.#worker = wrapped;\n\n // Set up options if provided\n if (options) {\n // We can't pass a BroadcastChannel instance to the worker, so we need to convert it to a string first\n if (options.broadcastChannel && options.broadcastChannel instanceof BroadcastChannel) {\n options.broadcastChannel = options.broadcastChannel.name;\n }\n\n // Initialize options asynchronously\n void this.setOptions(options);\n }\n }\n\n /**\n * Update configuration options\n */\n async setOptions(options: OPFSOptions) {\n return this.#worker.setOptions(options);\n }\n\n /**\n * Get a complete index of all files and directories in the file system\n */\n async index(): Promise<Map<string, FileStat>> {\n return this.#worker.index();\n }\n\n /**\n * Read a file from the file system\n */\n async readFile(path: PathLike, encoding: 'binary'): Promise<Uint8Array>;\n async readFile(path: PathLike, encoding: Encoding): Promise<string>;\n async readFile(path: PathLike, encoding?: Encoding | 'binary'): Promise<string | Uint8Array>;\n async readFile(\n path: PathLike,\n encoding?: any\n ): Promise<string | Uint8Array> {\n const normalizedPath = normalizePath(path);\n // Get binary data from worker\n const buffer = await this.#worker.readFile(normalizedPath);\n\n // If no encoding specified, auto-detect based on file extension\n if (!encoding) {\n encoding = isBinaryFileExtension(normalizedPath) ? 'binary' : 'utf-8';\n }\n\n // Return binary data or decode to string\n return (encoding === 'binary') ? buffer : decodeBuffer(buffer, encoding);\n }\n\n /**\n * Write data to a file\n */\n async writeFile(\n path: PathLike,\n data: string | Uint8Array | ArrayBuffer,\n encoding?: Encoding\n ): Promise<void> {\n const normalizedPath = normalizePath(path);\n\n // If no encoding specified, auto-detect based on file extension\n if (!encoding) {\n encoding = (typeof data !== 'string' || isBinaryFileExtension(normalizedPath)) ? 'binary' : 'utf-8';\n }\n\n // Convert data to Uint8Array\n const buffer = typeof data === 'string'\n ? encodeString(data, encoding)\n : (data instanceof Uint8Array ? data : new Uint8Array(data));\n\n return this.#worker.writeFile(normalizedPath, buffer);\n }\n\n /**\n * Append data to a file\n */\n async appendFile(\n path: PathLike,\n data: string | Uint8Array | ArrayBuffer,\n encoding?: Encoding\n ): Promise<void> {\n const normalizedPath = normalizePath(path);\n\n // If no encoding specified, auto-detect based on file extension\n if (!encoding) {\n encoding = (typeof data !== 'string' || isBinaryFileExtension(normalizedPath)) ? 'binary' : 'utf-8';\n }\n\n // Convert data to Uint8Array\n const buffer = typeof data === 'string'\n ? encodeString(data, encoding)\n : (data instanceof Uint8Array ? data : new Uint8Array(data));\n\n return this.#worker.appendFile(normalizedPath, buffer);\n }\n\n /**\n * Create a directory\n */\n async mkdir(path: PathLike, options?: { recursive?: boolean }): Promise<void> {\n const normalizedPath = normalizePath(path);\n\n return this.#worker.mkdir(normalizedPath, options);\n }\n\n /**\n * Get file or directory statistics\n */\n async stat(path: PathLike): Promise<FileStat> {\n const normalizedPath = normalizePath(path);\n\n return this.#worker.stat(normalizedPath);\n }\n\n /**\n * Read a directory's contents\n */\n async readDir(path: PathLike): Promise<DirentData[]> {\n const normalizedPath = normalizePath(path);\n\n return this.#worker.readDir(normalizedPath);\n }\n\n /**\n * Check if a file or directory exists\n */\n async exists(path: PathLike): Promise<boolean> {\n const normalizedPath = normalizePath(path);\n\n return this.#worker.exists(normalizedPath);\n }\n\n /**\n * Clear all contents of a directory without removing the directory itself\n */\n async clear(path?: PathLike): Promise<void> {\n const normalizedPath = path ? normalizePath(path) : undefined;\n\n return this.#worker.clear(normalizedPath);\n }\n\n /**\n * Remove files and directories\n */\n async remove(path: PathLike, options?: { recursive?: boolean; force?: boolean }): Promise<void> {\n const normalizedPath = normalizePath(path);\n\n return this.#worker.remove(normalizedPath, options);\n }\n\n /**\n * Resolve a path to an absolute path\n */\n async realpath(path: PathLike): Promise<string> {\n const normalizedPath = normalizePath(path);\n\n return this.#worker.realpath(normalizedPath);\n }\n\n /**\n * Rename a file or directory\n */\n async rename(oldPath: PathLike, newPath: PathLike, options?: RenameOptions): Promise<void> {\n const normalizedOldPath = normalizePath(oldPath);\n const normalizedNewPath = normalizePath(newPath);\n\n return this.#worker.rename(normalizedOldPath, normalizedNewPath, options);\n }\n\n /**\n * Copy files and directories\n */\n async copy(source: PathLike, destination: PathLike, options?: { recursive?: boolean; overwrite?: boolean }): Promise<void> {\n const normalizedSource = normalizePath(source);\n const normalizedDestination = normalizePath(destination);\n\n return this.#worker.copy(normalizedSource, normalizedDestination, options);\n }\n\n /**\n * Start watching a file or directory for changes\n */\n watch(path: PathLike, options?: WatchOptions): () => void {\n const normalizedPath = normalizePath(path);\n\n void this.#worker.watch(normalizedPath, options);\n\n return () => this.unwatch(normalizedPath);\n }\n\n /**\n * Stop watching a previously watched path\n */\n unwatch(path: PathLike) {\n const normalizedPath = normalizePath(path);\n\n void this.#worker.unwatch(normalizedPath);\n }\n\n /**\n * Open a file and return a file descriptor\n */\n async open(path: PathLike, options?: FileOpenOptions): Promise<number> {\n const normalizedPath = normalizePath(path);\n\n return this.#worker.open(normalizedPath, options);\n }\n\n /**\n * Close a file descriptor\n */\n async close(fd: number): Promise<void> {\n return this.#worker.close(fd);\n }\n\n /**\n * Read data from a file descriptor\n * \n * This method requires special handling due to Comlink transfer requirements.\n * The buffer is transferred to the worker and back, so the original buffer\n * becomes unusable after the call.\n */\n async read(\n fd: number,\n buffer: Uint8Array,\n offset: number,\n length: number,\n position?: number | null | undefined\n ): Promise<{ bytesRead: number; buffer: Uint8Array }> {\n const { bytesRead, buffer: transferred } = await this.#worker.read(\n fd,\n // Temp buffer to preserve the original buffer\n new Uint8Array(length),\n 0,\n length,\n position\n );\n\n // Copy the data from the transferred buffer to the original buffer\n if (bytesRead > 0) {\n buffer.set(transferred.subarray(0, bytesRead), offset);\n }\n\n return { bytesRead, buffer };\n }\n\n /**\n * Write data to a file descriptor\n */\n async write(\n fd: number,\n buffer: Uint8Array,\n offset?: number,\n length?: number,\n position?: number | null | undefined,\n emitEvent?: boolean\n ): Promise<number> {\n return this.#worker.write(fd, buffer, offset, length, position, emitEvent);\n }\n\n /**\n * Get file status information by file descriptor\n */\n async fstat(fd: number): Promise<FileStat> {\n return this.#worker.fstat(fd);\n }\n\n /**\n * Truncate file to specified size\n */\n async ftruncate(fd: number, size?: number): Promise<void> {\n return this.#worker.ftruncate(fd, size);\n }\n\n /**\n * Synchronize file data to storage (fsync equivalent)\n */\n async fsync(fd: number): Promise<void> {\n return this.#worker.fsync(fd);\n }\n\n /**\n * Dispose of resources and clean up the file system instance\n */\n dispose() {\n void this.#worker.dispose();\n }\n\n /**\n * Synchronize the file system with external data\n */\n async sync(entries: [PathLike, string | Uint8Array | Blob][], options?: { cleanBefore?: boolean }): Promise<void> {\n const normalizedEntries = entries.map(([path, data]) => [normalizePath(path), data] as [string, string | Uint8Array | Blob]);\n\n return this.#worker.sync(normalizedEntries, options);\n }\n\n /**\n * Read a file as text with automatic encoding detection\n */\n async readText(path: PathLike, encoding: Encoding = 'utf-8'): Promise<string> {\n const normalizedPath = normalizePath(path);\n const buffer = await this.#worker.readFile(normalizedPath);\n\n return decodeBuffer(buffer, encoding);\n }\n\n /**\n * Write text to a file with specified encoding\n */\n async writeText(path: PathLike, text: string, encoding: Encoding = 'utf-8'): Promise<void> {\n const normalizedPath = normalizePath(path);\n const buffer = encodeString(text, encoding);\n\n return this.#worker.writeFile(normalizedPath, buffer);\n }\n\n /**\n * Append text to a file with specified encoding\n */\n async appendText(path: PathLike, text: string, encoding: Encoding = 'utf-8'): Promise<void> {\n const normalizedPath = normalizePath(path);\n const buffer = encodeString(text, encoding);\n\n return this.#worker.appendFile(normalizedPath, buffer);\n }\n}\n","import { OPFSFileSystem } from './facade';\n\nimport type { OPFSOptions } from './types';\n\nexport * from './types';\nexport * from './utils/errors';\nexport * from './utils/helpers';\nexport * from './utils/encoder';\nexport * from './facade';\n\n/**\n * Creates a new file system instance with inline worker\n * @param options - Optional configuration options\n * @returns Promise resolving to the file system interface\n */\nexport function createWorker(\n options?: OPFSOptions\n): OPFSFileSystem {\n return new OPFSFileSystem(options);\n}\n"],"names":["normalizePath","path","OPFSFileSystem","#worker","options","wrapped","wrap","WorkerCtor","encoding","normalizedPath","buffer","isBinaryFileExtension","decodeBuffer","data","encodeString","oldPath","newPath","normalizedOldPath","normalizedNewPath","source","destination","normalizedSource","normalizedDestination","fd","offset","length","position","bytesRead","transferred","emitEvent","size","entries","normalizedEntries","text","createWorker"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AASM,CAAc;AAEzD,WAAOG,EAAaF,GAAQF,CAAQ;AAAA,EACxC;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,UAAUP,GAAgBgC,GAAczB,IAAqB,SAAwB;AACvF,UAAMC,IAAiBT,EAAcC,CAAI,GACnCS,IAASI,EAAamB,GAAMzB,CAAQ;AAE1C,WAAO,KAAKL,GAAQ,UAAUM,GAAgBC,CAAM;AAAA,EACxD;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,WAAWT,GAAgBgC,GAAczB,IAAqB,SAAwB;AACxF,UAAMC,IAAiBT,EAAcC,CAAI,GACnCS,IAASI,EAAamB,GAAMzB,CAAQ;AAE1C,WAAO,KAAKL,GAAQ,WAAWM,GAAgBC,CAAM;AAAA,EACzD;AACJ;AC/VO,SAASwB,EACZ9B,GACc;AACd,SAAO,IAAIF,EAAeE,CAAO;AACrC;"}
package/dist/types.d.ts CHANGED
@@ -1,5 +1,9 @@
1
1
  import type { OPFSWorker } from './worker';
2
2
  import type { Remote } from 'comlink';
3
+ /**
4
+ * Type for paths that can be either a string or URI
5
+ */
6
+ export type PathLike = string | URL;
3
7
  export type Kind = 'file' | 'directory';
4
8
  export type Encoding = 'ascii' | 'utf8' | 'utf-8' | 'utf16le' | 'utf-16le' | 'ucs2' | 'ucs-2' | 'base64' | 'latin1' | 'hex' | 'binary';
5
9
  export interface FileStat {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEtC,MAAM,MAAM,IAAI,GAAG,MAAM,GAAG,WAAW,CAAC;AAExC,MAAM,MAAM,QAAQ,GAAG,OAAO,GAC1B,MAAM,GACN,OAAO,GACP,SAAS,GACT,UAAU,GACV,MAAM,GACN,OAAO,GACP,QAAQ,GACR,QAAQ,GACR,KA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AE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,aAAa;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;CACrB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opfs-worker",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "A robust TypeScript library for working with Origin Private File System (OPFS) through Web Workers",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",