opfs-worker 1.3.2 → 2.1.0
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/README.md +64 -458
- package/dist/BaseOPFS-BPw9AIQ-.cjs +4 -0
- package/dist/BaseOPFS-BPw9AIQ-.cjs.map +1 -0
- package/dist/BaseOPFS-Cylz6ijk.js +2036 -0
- package/dist/BaseOPFS-Cylz6ijk.js.map +1 -0
- package/dist/OPFSAsync-BKSAJJeh.js +124 -0
- package/dist/OPFSAsync-BKSAJJeh.js.map +1 -0
- package/dist/OPFSAsync-s2P7y3sw.cjs +2 -0
- package/dist/OPFSAsync-s2P7y3sw.cjs.map +1 -0
- package/dist/OPFSFacade-DePnNRgt.cjs +2 -0
- package/dist/OPFSFacade-DePnNRgt.cjs.map +1 -0
- package/dist/OPFSFacade-XohWlHuu.js +281 -0
- package/dist/OPFSFacade-XohWlHuu.js.map +1 -0
- package/dist/OPFSSync-C7KBepe_.cjs +2 -0
- package/dist/OPFSSync-C7KBepe_.cjs.map +1 -0
- package/dist/OPFSSync-CsSQkpk5.js +208 -0
- package/dist/OPFSSync-CsSQkpk5.js.map +1 -0
- package/dist/assets/dedicated.worker-nY3tK4zi.js.map +1 -0
- package/dist/{worker.d.ts → core/BaseOPFS.d.ts} +34 -300
- package/dist/core/BaseOPFS.d.ts.map +1 -0
- package/dist/core/OPFSAsync.d.ts +55 -0
- package/dist/core/OPFSAsync.d.ts.map +1 -0
- package/dist/core/OPFSSync.d.ts +54 -0
- package/dist/core/OPFSSync.d.ts.map +1 -0
- package/dist/createOPFSAsync-BwKDmHsy.cjs +2 -0
- package/dist/createOPFSAsync-BwKDmHsy.cjs.map +1 -0
- package/dist/createOPFSAsync-Y4Mg6qte.js +10 -0
- package/dist/createOPFSAsync-Y4Mg6qte.js.map +1 -0
- package/dist/createOPFSDedicated-CsnV6MLP.js +2333 -0
- package/dist/createOPFSDedicated-CsnV6MLP.js.map +1 -0
- package/dist/createOPFSDedicated-pKTRWLdz.cjs +2283 -0
- package/dist/createOPFSDedicated-pKTRWLdz.cjs.map +1 -0
- package/dist/createOPFSShared-CGdd__PH.js +23 -0
- package/dist/createOPFSShared-CGdd__PH.js.map +1 -0
- package/dist/createOPFSShared-CskROt7U.cjs +2 -0
- package/dist/createOPFSShared-CskROt7U.cjs.map +1 -0
- package/dist/dedicated.worker.js +2281 -0
- package/dist/dedicated.worker.js.map +1 -0
- package/dist/{facade.d.ts → facade/OPFSFacade.d.ts} +35 -10
- package/dist/facade/OPFSFacade.d.ts.map +1 -0
- package/dist/facade/createOPFSAsync.d.ts +16 -0
- package/dist/facade/createOPFSAsync.d.ts.map +1 -0
- package/dist/facade/createOPFSDedicated.d.ts +17 -0
- package/dist/facade/createOPFSDedicated.d.ts.map +1 -0
- package/dist/facade/createOPFSShared.d.ts +24 -0
- package/dist/facade/createOPFSShared.d.ts.map +1 -0
- package/dist/index.async.cjs +2 -0
- package/dist/index.async.cjs.map +1 -0
- package/dist/index.async.d.ts +10 -0
- package/dist/index.async.d.ts.map +1 -0
- package/dist/index.async.js +55 -0
- package/dist/index.async.js.map +1 -0
- package/dist/index.cjs +1 -2466
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +15 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +61 -2799
- package/dist/index.js.map +1 -1
- package/dist/index.pure.cjs +2 -0
- package/dist/index.pure.cjs.map +1 -0
- package/dist/index.pure.d.ts +8 -0
- package/dist/index.pure.d.ts.map +1 -0
- package/dist/index.pure.js +53 -0
- package/dist/index.pure.js.map +1 -0
- package/dist/index.sharedworker.cjs +2 -0
- package/dist/index.sharedworker.cjs.map +1 -0
- package/dist/index.sharedworker.d.ts +11 -0
- package/dist/index.sharedworker.d.ts.map +1 -0
- package/dist/index.sharedworker.js +55 -0
- package/dist/index.sharedworker.js.map +1 -0
- package/dist/index.sync.cjs +2 -0
- package/dist/index.sync.cjs.map +1 -0
- package/dist/index.sync.d.ts +11 -0
- package/dist/index.sync.d.ts.map +1 -0
- package/dist/index.sync.js +55 -0
- package/dist/index.sync.js.map +1 -0
- package/dist/shared.worker.js +2166 -0
- package/dist/shared.worker.js.map +1 -0
- package/dist/types.d.ts +9 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/helpers.d.ts +11 -1
- package/dist/utils/helpers.d.ts.map +1 -1
- package/dist/worker/createDedicatedWorker.d.ts +30 -0
- package/dist/worker/createDedicatedWorker.d.ts.map +1 -0
- package/dist/worker/createSharedWorker.d.ts +37 -0
- package/dist/worker/createSharedWorker.d.ts.map +1 -0
- package/dist/worker/dedicated.worker.d.ts +2 -0
- package/dist/worker/dedicated.worker.d.ts.map +1 -0
- package/dist/worker/shared.worker.d.ts +2 -0
- package/dist/worker/shared.worker.d.ts.map +1 -0
- package/docs/README.md +30 -0
- package/docs/api/backend.md +36 -0
- package/docs/api/create.md +82 -0
- package/docs/api/facade.md +52 -0
- package/docs/choosing-a-mode.md +41 -0
- package/docs/file-descriptors.md +695 -0
- package/docs/guides/async.md +36 -0
- package/docs/guides/dedicated.md +76 -0
- package/docs/guides/hashing.md +34 -0
- package/docs/guides/pure.md +46 -0
- package/docs/guides/sharedworker.md +57 -0
- package/docs/guides/streaming.md +51 -0
- package/docs/guides/watching.md +35 -0
- package/docs/migration.md +41 -0
- package/docs/types.md +246 -0
- package/package.json +55 -10
- package/src/core/BaseOPFS.ts +951 -0
- package/src/core/OPFSAsync.ts +248 -0
- package/src/core/OPFSSync.ts +460 -0
- package/src/facade/OPFSFacade.ts +489 -0
- package/src/facade/createOPFSAsync.ts +22 -0
- package/src/facade/createOPFSDedicated.ts +23 -0
- package/src/facade/createOPFSShared.ts +30 -0
- package/src/index.async.ts +11 -0
- package/src/index.pure.ts +8 -0
- package/src/index.sharedworker.ts +12 -0
- package/src/index.sync.ts +12 -0
- package/src/index.ts +44 -0
- package/src/types.ts +103 -0
- package/src/utils/encoder.ts +205 -0
- package/src/utils/errors.ts +297 -0
- package/src/utils/helpers.ts +465 -0
- package/src/worker/createDedicatedWorker.ts +74 -0
- package/src/worker/createSharedWorker.ts +67 -0
- package/src/worker/dedicated.worker.ts +13 -0
- package/src/worker/shared.worker.ts +17 -0
- package/dist/assets/worker-1Wh1cr7P.js.map +0 -1
- package/dist/assets/worker-BeJaVyBV.js.map +0 -1
- package/dist/assets/worker-DYYLzR1Y.js.map +0 -1
- package/dist/facade.d.ts.map +0 -1
- package/dist/helpers-BuGfPAg0.js +0 -1439
- package/dist/helpers-BuGfPAg0.js.map +0 -1
- package/dist/helpers-CF7A2WQG.cjs +0 -4
- package/dist/helpers-CF7A2WQG.cjs.map +0 -1
- package/dist/helpers-CIiblZ8d.cjs +0 -4
- package/dist/helpers-CIiblZ8d.cjs.map +0 -1
- package/dist/helpers-CKOebsbw.js +0 -1423
- package/dist/helpers-CKOebsbw.js.map +0 -1
- package/dist/helpers-Ca2c767K.js +0 -1427
- package/dist/helpers-Ca2c767K.js.map +0 -1
- package/dist/helpers-Dwc92hv9.cjs +0 -4
- package/dist/helpers-Dwc92hv9.cjs.map +0 -1
- package/dist/raw.cjs +0 -2
- package/dist/raw.cjs.map +0 -1
- package/dist/raw.d.ts +0 -13
- package/dist/raw.d.ts.map +0 -1
- package/dist/raw.js +0 -1001
- package/dist/raw.js.map +0 -1
- package/dist/worker.d.ts.map +0 -1
|
@@ -1,39 +1,20 @@
|
|
|
1
|
-
import type { DirentData,
|
|
1
|
+
import type { DirentData, FileStat, OPFSOptions, RenameOptions, WatchEvent, WatchOptions, WatchSnapshot } from '../types';
|
|
2
2
|
/**
|
|
3
|
-
* OPFS (
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* Origin Private File System API, offering file and directory operations
|
|
7
|
-
* similar to Node.js fs module.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```typescript
|
|
11
|
-
* const fs = new OPFSFileSystem();
|
|
12
|
-
* await fs.init('/my-app');
|
|
13
|
-
* await fs.writeFile('/data/config.json', JSON.stringify({ theme: 'dark' }));
|
|
14
|
-
* const config = await fs.readFile('/data/config.json');
|
|
15
|
-
* ```
|
|
3
|
+
* Shared OPFS logic (directories, meta, watch, high-level helpers).
|
|
4
|
+
* File I/O backends implement {@link readFile}, {@link writeFile}, {@link appendFile},
|
|
5
|
+
* and {@link writeStream}.
|
|
16
6
|
*/
|
|
17
|
-
export declare class
|
|
7
|
+
export declare abstract class BaseOPFS {
|
|
18
8
|
/** Root directory handle for the file system */
|
|
19
|
-
|
|
9
|
+
protected root: FileSystemDirectoryHandle;
|
|
20
10
|
/** Map of watched paths and options */
|
|
21
|
-
|
|
11
|
+
protected watchers: Map<string, WatchSnapshot>;
|
|
22
12
|
/** Promise to prevent concurrent mount operations */
|
|
23
|
-
|
|
13
|
+
protected mountingPromise: Promise<boolean> | null;
|
|
24
14
|
/** BroadcastChannel instance for sending events */
|
|
25
|
-
|
|
15
|
+
protected broadcastChannel: BroadcastChannel | null;
|
|
26
16
|
/** Configuration options */
|
|
27
|
-
|
|
28
|
-
/** Map of open file descriptors to their metadata */
|
|
29
|
-
private openFiles;
|
|
30
|
-
/** Next available file descriptor number */
|
|
31
|
-
private nextFd;
|
|
32
|
-
/**
|
|
33
|
-
* Get file info by descriptor with validation
|
|
34
|
-
* @private
|
|
35
|
-
*/
|
|
36
|
-
private _getFileDescriptor;
|
|
17
|
+
protected options: Required<OPFSOptions>;
|
|
37
18
|
/**
|
|
38
19
|
* Notify about internal changes to the file system
|
|
39
20
|
*
|
|
@@ -42,39 +23,21 @@ export declare class OPFSWorker {
|
|
|
42
23
|
*
|
|
43
24
|
* @param event - The event describing the change
|
|
44
25
|
*/
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Creates a new OPFSFileSystem instance
|
|
48
|
-
*
|
|
49
|
-
* @param options - Optional configuration options
|
|
50
|
-
* @param options.root - Root path for the file system (default: '/')
|
|
51
|
-
* @param options.watchInterval - Polling interval in milliseconds for file watching
|
|
52
|
-
* @param options.hashAlgorithm - Hash algorithm for file hashing
|
|
53
|
-
* @param options.maxFileSize - Maximum file size for hashing in bytes (default: 50MB)
|
|
54
|
-
* @throws {OPFSError} If OPFS is not supported in the current browser
|
|
55
|
-
*/
|
|
26
|
+
protected notifyChange(event: Omit<WatchEvent, 'timestamp' | 'hash' | 'namespace'>): Promise<void>;
|
|
56
27
|
constructor(options?: OPFSOptions);
|
|
28
|
+
/** Read file contents as bytes */
|
|
29
|
+
abstract readFile(path: string): Promise<Uint8Array>;
|
|
30
|
+
/** Create or overwrite a file with binary data */
|
|
31
|
+
abstract writeFile(path: string, data: Uint8Array | ArrayBuffer): Promise<void>;
|
|
32
|
+
/** Append binary data to a file */
|
|
33
|
+
abstract appendFile(path: string, data: Uint8Array | ArrayBuffer): Promise<void>;
|
|
34
|
+
/** Create or overwrite a file from a byte stream */
|
|
35
|
+
abstract writeStream(path: string, stream: ReadableStream<Uint8Array>, onProgress?: (bytesWritten: number) => unknown): Promise<number>;
|
|
57
36
|
/**
|
|
58
|
-
* Initialize the file system within a given directory
|
|
59
|
-
*
|
|
60
|
-
* This method sets up the root directory for all subsequent operations.
|
|
61
|
-
* If no root is specified, it will use the OPFS root directory.
|
|
62
|
-
*
|
|
63
|
-
* @returns Promise that resolves to true if initialization was successful
|
|
64
|
-
* @throws {OPFSError} If initialization fails
|
|
65
|
-
*
|
|
66
|
-
* @example
|
|
67
|
-
* ```typescript
|
|
68
|
-
* const fs = new OPFSFileSystem();
|
|
69
|
-
*
|
|
70
|
-
* // Use OPFS root (default)
|
|
71
|
-
* await fs.mount();
|
|
72
|
-
*
|
|
73
|
-
* // Use custom directory
|
|
74
|
-
* await fs.mount('/my-app');
|
|
75
|
-
* ```
|
|
37
|
+
* Initialize the file system within a given directory.
|
|
38
|
+
* If no root is specified, uses the OPFS root directory.
|
|
76
39
|
*/
|
|
77
|
-
|
|
40
|
+
protected mount(): Promise<boolean>;
|
|
78
41
|
/**
|
|
79
42
|
* Update configuration options
|
|
80
43
|
*
|
|
@@ -104,7 +67,7 @@ export declare class OPFSWorker {
|
|
|
104
67
|
* const docsDir2 = await fs.getDirectoryHandle(['users', 'john', 'documents'], true);
|
|
105
68
|
* ```
|
|
106
69
|
*/
|
|
107
|
-
|
|
70
|
+
protected getDirectoryHandle(path: string | string[], create?: boolean, from?: FileSystemDirectoryHandle | null): Promise<FileSystemDirectoryHandle>;
|
|
108
71
|
/**
|
|
109
72
|
* Get a file handle from a path
|
|
110
73
|
*
|
|
@@ -124,7 +87,7 @@ export declare class OPFSWorker {
|
|
|
124
87
|
* const fileHandle2 = await fs.getFileHandle(['config', 'settings.json'], true);
|
|
125
88
|
* ```
|
|
126
89
|
*/
|
|
127
|
-
|
|
90
|
+
protected getFileHandle(path: string | string[], create?: boolean, _from?: FileSystemDirectoryHandle | null): Promise<FileSystemFileHandle>;
|
|
128
91
|
/**
|
|
129
92
|
* Get a complete index of all files and directories in the file system
|
|
130
93
|
*
|
|
@@ -145,72 +108,6 @@ export declare class OPFSWorker {
|
|
|
145
108
|
* ```
|
|
146
109
|
*/
|
|
147
110
|
index(): Promise<Map<string, FileStat>>;
|
|
148
|
-
/**
|
|
149
|
-
* Read a file from the file system
|
|
150
|
-
*
|
|
151
|
-
* Reads the contents of a file and returns it as binary data.
|
|
152
|
-
*
|
|
153
|
-
* @param path - The path to the file to read
|
|
154
|
-
* @returns Promise that resolves to the file contents as Uint8Array
|
|
155
|
-
* @throws {FileNotFoundError} If the file does not exist
|
|
156
|
-
* @throws {OPFSError} If reading the file fails
|
|
157
|
-
*
|
|
158
|
-
* @example
|
|
159
|
-
* ```typescript
|
|
160
|
-
* // Read as binary data
|
|
161
|
-
* const content = await fs.readFile('/config/settings.json');
|
|
162
|
-
*
|
|
163
|
-
* // Read binary file
|
|
164
|
-
* const binaryData = await fs.readFile('/images/logo.png');
|
|
165
|
-
* ```
|
|
166
|
-
*/
|
|
167
|
-
readFile(path: string): Promise<Uint8Array>;
|
|
168
|
-
/**
|
|
169
|
-
* Write data to a file
|
|
170
|
-
*
|
|
171
|
-
* Creates or overwrites a file with the specified binary data. If the file already
|
|
172
|
-
* exists, it will be truncated before writing.
|
|
173
|
-
*
|
|
174
|
-
* @param path - The path to the file to write
|
|
175
|
-
* @param data - The binary data to write to the file (Uint8Array or ArrayBuffer)
|
|
176
|
-
* @returns Promise that resolves when the write operation is complete
|
|
177
|
-
* @throws {OPFSError} If writing the file fails
|
|
178
|
-
*
|
|
179
|
-
* @example
|
|
180
|
-
* ```typescript
|
|
181
|
-
* // Write binary data
|
|
182
|
-
* const binaryData = new Uint8Array([1, 2, 3, 4, 5]);
|
|
183
|
-
* await fs.writeFile('/data/binary.dat', binaryData);
|
|
184
|
-
*
|
|
185
|
-
* // Write from ArrayBuffer
|
|
186
|
-
* const arrayBuffer = new ArrayBuffer(10);
|
|
187
|
-
* await fs.writeFile('/data/buffer.dat', arrayBuffer);
|
|
188
|
-
* ```
|
|
189
|
-
*/
|
|
190
|
-
writeFile(path: string, data: Uint8Array | ArrayBuffer): Promise<void>;
|
|
191
|
-
/**
|
|
192
|
-
* Append data to a file
|
|
193
|
-
*
|
|
194
|
-
* Adds binary data to the end of an existing file. If the file doesn't exist,
|
|
195
|
-
* it will be created.
|
|
196
|
-
*
|
|
197
|
-
* @param path - The path to the file to append to
|
|
198
|
-
* @param data - The binary data to append to the file (Uint8Array or ArrayBuffer)
|
|
199
|
-
* @returns Promise that resolves when the append operation is complete
|
|
200
|
-
* @throws {OPFSError} If appending to the file fails
|
|
201
|
-
*
|
|
202
|
-
* @example
|
|
203
|
-
* ```typescript
|
|
204
|
-
* // Append binary data
|
|
205
|
-
* const additionalData = new Uint8Array([6, 7, 8]);
|
|
206
|
-
* await fs.appendFile('/data/binary.dat', additionalData);
|
|
207
|
-
*
|
|
208
|
-
* // Append from ArrayBuffer
|
|
209
|
-
* const arrayBuffer = new ArrayBuffer(5);
|
|
210
|
-
* await fs.appendFile('/data/buffer.dat', arrayBuffer);
|
|
211
|
-
* ```
|
|
212
|
-
*/
|
|
213
|
-
appendFile(path: string, data: Uint8Array | ArrayBuffer): Promise<void>;
|
|
214
111
|
/**
|
|
215
112
|
* Create a directory
|
|
216
113
|
*
|
|
@@ -442,187 +339,24 @@ export declare class OPFSWorker {
|
|
|
442
339
|
*/
|
|
443
340
|
unwatch(path: string): void;
|
|
444
341
|
/**
|
|
445
|
-
*
|
|
342
|
+
* Bulk-create files from `[path, data]` entries (strings, bytes, or Blobs).
|
|
446
343
|
*
|
|
447
|
-
* @param
|
|
448
|
-
* @
|
|
449
|
-
* @param options.create - Whether to create the file if it doesn't exist (default: false)
|
|
450
|
-
* @param options.exclusive - If true and create is true, fails if file already exists (default: false)
|
|
451
|
-
* Note: This is best-effort in OPFS, not fully atomic due to browser limitations
|
|
452
|
-
* @param options.truncate - Whether to truncate the file to zero length (default: false)
|
|
453
|
-
* @returns Promise that resolves to a file descriptor number
|
|
454
|
-
* @throws {OPFSError} If opening the file fails
|
|
344
|
+
* @param entries - Array of `[path, data]` tuples
|
|
345
|
+
* @throws {OPFSError} If a write fails
|
|
455
346
|
*
|
|
456
347
|
* @example
|
|
457
348
|
* ```typescript
|
|
458
|
-
*
|
|
459
|
-
*
|
|
460
|
-
*
|
|
461
|
-
*
|
|
462
|
-
*
|
|
463
|
-
*
|
|
464
|
-
* // Create file exclusively (fails if exists)
|
|
465
|
-
* const fd = await fs.open('/data/unique.txt', { create: true, exclusive: true });
|
|
466
|
-
*
|
|
467
|
-
* // Open and truncate file
|
|
468
|
-
* const fd = await fs.open('/data/log.txt', { create: true, truncate: true });
|
|
469
|
-
* ```
|
|
470
|
-
*/
|
|
471
|
-
open(path: string, options?: FileOpenOptions): Promise<number>;
|
|
472
|
-
/**
|
|
473
|
-
* Internal method to open a file (without locking)
|
|
474
|
-
* @private
|
|
475
|
-
*/
|
|
476
|
-
private _openFile;
|
|
477
|
-
/**
|
|
478
|
-
* Close a file descriptor
|
|
479
|
-
*
|
|
480
|
-
* @param fd - The file descriptor to close
|
|
481
|
-
* @returns Promise that resolves when the file descriptor is closed
|
|
482
|
-
* @throws {OPFSError} If the file descriptor is invalid or closing fails
|
|
483
|
-
*
|
|
484
|
-
* @example
|
|
485
|
-
* ```typescript
|
|
486
|
-
* const fd = await fs.open('/data/file.txt');
|
|
487
|
-
* // ... use the file descriptor ...
|
|
488
|
-
* await fs.close(fd);
|
|
489
|
-
* ```
|
|
490
|
-
*/
|
|
491
|
-
close(fd: number): Promise<void>;
|
|
492
|
-
/**
|
|
493
|
-
* Read data from a file descriptor
|
|
494
|
-
*
|
|
495
|
-
* @param fd - The file descriptor to read from
|
|
496
|
-
* @param buffer - The buffer to read data into
|
|
497
|
-
* @param offset - The offset in the buffer to start writing at
|
|
498
|
-
* @param length - The number of bytes to read
|
|
499
|
-
* @param position - The position in the file to read from (null for current position)
|
|
500
|
-
* @returns Promise that resolves to the number of bytes read and the modified buffer
|
|
501
|
-
* @throws {OPFSError} If the file descriptor is invalid or reading fails
|
|
502
|
-
*
|
|
503
|
-
* @note This method uses Comlink.transfer() to efficiently pass the buffer as a Transferable Object,
|
|
504
|
-
* ensuring zero-copy performance across Web Worker boundaries.
|
|
505
|
-
*
|
|
506
|
-
* @example
|
|
507
|
-
* ```typescript
|
|
508
|
-
* const fd = await fs.open('/data/file.txt');
|
|
509
|
-
* const buffer = new Uint8Array(1024);
|
|
510
|
-
* const { bytesRead, buffer: modifiedBuffer } = await fs.read(fd, buffer, 0, 1024, null);
|
|
511
|
-
* console.log(`Read ${bytesRead} bytes`);
|
|
512
|
-
* // Use modifiedBuffer which contains the actual data
|
|
513
|
-
* await fs.close(fd);
|
|
514
|
-
* ```
|
|
515
|
-
*/
|
|
516
|
-
read(fd: number, buffer: Uint8Array, offset: number, length: number, position: number | null | undefined): Promise<{
|
|
517
|
-
bytesRead: number;
|
|
518
|
-
buffer: Uint8Array;
|
|
519
|
-
}>;
|
|
520
|
-
/**
|
|
521
|
-
* Write data to a file descriptor
|
|
522
|
-
*
|
|
523
|
-
* @param fd - The file descriptor to write to
|
|
524
|
-
* @param buffer - The buffer containing data to write
|
|
525
|
-
* @param offset - The offset in the buffer to start reading from (default: 0)
|
|
526
|
-
* @param length - The number of bytes to write (default: entire buffer)
|
|
527
|
-
* @param position - The position in the file to write to (null/undefined for current position)
|
|
528
|
-
* @param emitEvent - Whether to emit a change event (default: true)
|
|
529
|
-
* @returns Promise that resolves to the number of bytes written
|
|
530
|
-
* @throws {OPFSError} If the file descriptor is invalid or writing fails
|
|
531
|
-
*
|
|
532
|
-
* @example
|
|
533
|
-
* ```typescript
|
|
534
|
-
* const fd = await fs.open('/data/file.txt', { create: true });
|
|
535
|
-
* const data = new TextEncoder().encode('Hello, World!');
|
|
536
|
-
* const bytesWritten = await fs.write(fd, data, 0, data.length, null);
|
|
537
|
-
* console.log(`Wrote ${bytesWritten} bytes`);
|
|
538
|
-
* await fs.close(fd);
|
|
539
|
-
* ```
|
|
540
|
-
*/
|
|
541
|
-
write(fd: number, buffer: Uint8Array, offset?: number, length?: number, position?: number | null | undefined, emitEvent?: boolean): Promise<number>;
|
|
542
|
-
/**
|
|
543
|
-
* Get file status information by file descriptor
|
|
544
|
-
*
|
|
545
|
-
* @param fd - The file descriptor
|
|
546
|
-
* @returns Promise that resolves to FileStat object
|
|
547
|
-
* @throws {OPFSError} If the file descriptor is invalid
|
|
548
|
-
*
|
|
549
|
-
* @example
|
|
550
|
-
* ```typescript
|
|
551
|
-
* const fd = await fs.open('/data/file.txt');
|
|
552
|
-
* const stats = await fs.fstat(fd);
|
|
553
|
-
* console.log(`File size: ${stats.size} bytes`);
|
|
554
|
-
* console.log(`Last modified: ${stats.mtime}`);
|
|
555
|
-
*
|
|
556
|
-
* // If hashing is enabled, hash will be included
|
|
557
|
-
* if (stats.hash) {
|
|
558
|
-
* console.log(`Hash: ${stats.hash}`);
|
|
559
|
-
* }
|
|
560
|
-
* ```
|
|
561
|
-
*/
|
|
562
|
-
fstat(fd: number): Promise<FileStat>;
|
|
563
|
-
/**
|
|
564
|
-
* Truncate file to specified size
|
|
565
|
-
*
|
|
566
|
-
* @param fd - The file descriptor
|
|
567
|
-
* @param size - The new size of the file (default: 0)
|
|
568
|
-
* @returns Promise that resolves when truncation is complete
|
|
569
|
-
* @throws {OPFSError} If the file descriptor is invalid or truncation fails
|
|
570
|
-
*
|
|
571
|
-
* @example
|
|
572
|
-
* ```typescript
|
|
573
|
-
* const fd = await fs.open('/data/file.txt', { create: true });
|
|
574
|
-
* await fs.truncate(fd, 100); // Truncate to 100 bytes
|
|
575
|
-
* ```
|
|
576
|
-
*/
|
|
577
|
-
ftruncate(fd: number, size?: number): Promise<void>;
|
|
578
|
-
/**
|
|
579
|
-
* Synchronize file data to storage (fsync equivalent)
|
|
580
|
-
*
|
|
581
|
-
* @param fd - The file descriptor
|
|
582
|
-
* @returns Promise that resolves when synchronization is complete
|
|
583
|
-
* @throws {OPFSError} If the file descriptor is invalid or sync fails
|
|
584
|
-
*
|
|
585
|
-
* @example
|
|
586
|
-
* ```typescript
|
|
587
|
-
* const fd = await fs.open('/data/file.txt', { create: true });
|
|
588
|
-
* await fs.write(fd, data);
|
|
589
|
-
* await fs.fsync(fd); // Ensure data is written to storage
|
|
349
|
+
* await fs.createIndex([
|
|
350
|
+
* ['/config.json', JSON.stringify({ theme: 'dark' })],
|
|
351
|
+
* ['/data/binary.dat', new Uint8Array([1, 2, 3, 4])],
|
|
352
|
+
* ['/upload.txt', new Blob(['file content'], { type: 'text/plain' })],
|
|
353
|
+
* ]);
|
|
590
354
|
* ```
|
|
591
355
|
*/
|
|
592
|
-
|
|
356
|
+
createIndex(entries: [string, string | Uint8Array | Blob][]): Promise<void>;
|
|
593
357
|
/**
|
|
594
358
|
* Dispose of resources and clean up the file system instance
|
|
595
|
-
*
|
|
596
|
-
* This method should be called when the file system instance is no longer needed
|
|
597
|
-
* to properly clean up resources like the broadcast channel and watch timers.
|
|
598
359
|
*/
|
|
599
360
|
dispose(): void;
|
|
600
|
-
/**
|
|
601
|
-
* Synchronize the file system with external data
|
|
602
|
-
*
|
|
603
|
-
* Syncs the file system with an array of entries containing paths and data.
|
|
604
|
-
* This is useful for importing data from external sources or syncing with remote data.
|
|
605
|
-
*
|
|
606
|
-
* @param entries - Array of [path, data] tuples to sync
|
|
607
|
-
* @returns Promise that resolves when synchronization is complete
|
|
608
|
-
* @throws {OPFSError} If the synchronization fails
|
|
609
|
-
*
|
|
610
|
-
* @example
|
|
611
|
-
* ```typescript
|
|
612
|
-
* // Sync with external data
|
|
613
|
-
* const entries: [string, string | Uint8Array | Blob][] = [
|
|
614
|
-
* ['/config.json', JSON.stringify({ theme: 'dark' })],
|
|
615
|
-
* ['/data/binary.dat', new Uint8Array([1, 2, 3, 4])],
|
|
616
|
-
* ['/upload.txt', new Blob(['file content'], { type: 'text/plain' })]
|
|
617
|
-
* ];
|
|
618
|
-
*
|
|
619
|
-
* // Sync without clearing existing files
|
|
620
|
-
* await fs.sync(entries);
|
|
621
|
-
*
|
|
622
|
-
* // Clean file system and then sync
|
|
623
|
-
* await fs.sync(entries, { cleanBefore: true });
|
|
624
|
-
* ```
|
|
625
|
-
*/
|
|
626
|
-
createIndex(entries: [string, string | Uint8Array | Blob][]): Promise<void>;
|
|
627
361
|
}
|
|
628
|
-
//# sourceMappingURL=
|
|
362
|
+
//# sourceMappingURL=BaseOPFS.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseOPFS.d.ts","sourceRoot":"","sources":["../../src/core/BaseOPFS.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { BaseOPFS } from './BaseOPFS';
|
|
2
|
+
import type { FileOpenOptions, FileStat } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Async OPFS backend using the promise-based File System API
|
|
5
|
+
* (`getFile()` / `createWritable()`).
|
|
6
|
+
*
|
|
7
|
+
* Unlike `OPFSSync`, it does not require a dedicated worker: it works on the
|
|
8
|
+
* main thread and inside any worker type (including SharedWorker).
|
|
9
|
+
*
|
|
10
|
+
* Requirements and limitations:
|
|
11
|
+
* - Writing needs `FileSystemFileHandle.createWritable()` — Chrome, Firefox, Safari 26+.
|
|
12
|
+
* Reading works in older Safari too.
|
|
13
|
+
* - No file descriptors / positional I/O: `open`, `read`, `write`, `close`,
|
|
14
|
+
* `fstat`, `ftruncate` and `fsync` always throw `OperationNotSupportedError`.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* import { OPFSAsync } from 'opfs-worker/pure';
|
|
19
|
+
* // or: 'opfs-worker' / 'opfs-worker/async'
|
|
20
|
+
*
|
|
21
|
+
* const fs = new OPFSAsync({ root: '/my-app' });
|
|
22
|
+
* await fs.writeFile('/config.json', new TextEncoder().encode('{}'));
|
|
23
|
+
* const config = await fs.readFile('/config.json');
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare class OPFSAsync extends BaseOPFS {
|
|
27
|
+
readFile(path: string): Promise<Uint8Array>;
|
|
28
|
+
writeFile(path: string, data: Uint8Array | ArrayBuffer): Promise<void>;
|
|
29
|
+
appendFile(path: string, data: Uint8Array | ArrayBuffer): Promise<void>;
|
|
30
|
+
writeStream(path: string, stream: ReadableStream<Uint8Array>, onProgress?: (bytesWritten: number) => unknown): Promise<number>;
|
|
31
|
+
/**
|
|
32
|
+
* Open a writable stream, run the write callback and commit via close().
|
|
33
|
+
* Aborts the stream (discarding the swap file) if the callback fails.
|
|
34
|
+
* @private
|
|
35
|
+
*/
|
|
36
|
+
private _writeStream;
|
|
37
|
+
/** @throws {OperationNotSupportedError} Always — no FD support in the async backend */
|
|
38
|
+
open(_path: string, _options?: FileOpenOptions): Promise<number>;
|
|
39
|
+
/** @throws {OperationNotSupportedError} Always — no FD support in the async backend */
|
|
40
|
+
close(_fd: number): Promise<void>;
|
|
41
|
+
/** @throws {OperationNotSupportedError} Always — no FD support in the async backend */
|
|
42
|
+
read(_fd: number, _buffer: Uint8Array, _offset: number, _length: number, _position: number | null | undefined): Promise<{
|
|
43
|
+
bytesRead: number;
|
|
44
|
+
buffer: Uint8Array;
|
|
45
|
+
}>;
|
|
46
|
+
/** @throws {OperationNotSupportedError} Always — no FD support in the async backend */
|
|
47
|
+
write(_fd: number, _buffer: Uint8Array, _offset?: number, _length?: number, _position?: number | null | undefined, _emitEvent?: boolean): Promise<number>;
|
|
48
|
+
/** @throws {OperationNotSupportedError} Always — no FD support in the async backend */
|
|
49
|
+
fstat(_fd: number): Promise<FileStat>;
|
|
50
|
+
/** @throws {OperationNotSupportedError} Always — no FD support in the async backend */
|
|
51
|
+
ftruncate(_fd: number, _size?: number): Promise<void>;
|
|
52
|
+
/** @throws {OperationNotSupportedError} Always — no FD support in the async backend */
|
|
53
|
+
fsync(_fd: number): Promise<void>;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=OPFSAsync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OPFSAsync.d.ts","sourceRoot":"","sources":["../../src/core/OPFSAsync.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAKtC,OAAO,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAI1D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,SAAU,SAAQ,QAAQ;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAqB3C,SAAS,CACX,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,UAAU,GAAG,WAAW,GAC/B,OAAO,CAAC,IAAI,CAAC;IA0BV,UAAU,CACZ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,UAAU,GAAG,WAAW,GAC/B,OAAO,CAAC,IAAI,CAAC;IA4BV,WAAW,CACb,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,EAClC,UAAU,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,GAC/C,OAAO,CAAC,MAAM,CAAC;IAoDlB;;;;OAIG;YACW,YAAY;IAuB1B,uFAAuF;IACjF,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC;IAItE,uFAAuF;IACjF,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIvC,uFAAuF;IACjF,IAAI,CACN,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,UAAU,EACnB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GACrC,OAAO,CAAC;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,UAAU,CAAA;KAAE,CAAC;IAIrD,uFAAuF;IACjF,KAAK,CACP,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,UAAU,EACnB,OAAO,CAAC,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,MAAM,EAChB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACrC,UAAU,CAAC,EAAE,OAAO,GACrB,OAAO,CAAC,MAAM,CAAC;IAIlB,uFAAuF;IACjF,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAI3C,uFAAuF;IACjF,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI3D,uFAAuF;IACjF,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAG1C"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { BaseOPFS } from './BaseOPFS';
|
|
2
|
+
import type { FileOpenOptions, FileStat, OPFSOptions } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Sync OPFS backend using `FileSystemSyncAccessHandle` (dedicated worker only).
|
|
5
|
+
*
|
|
6
|
+
* Provides high-level file I/O and Node-like file descriptors.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { OPFSSync } from 'opfs-worker/pure';
|
|
11
|
+
*
|
|
12
|
+
* const fs = new OPFSSync();
|
|
13
|
+
* await fs.writeFile('/data/config.json', new TextEncoder().encode(JSON.stringify({ theme: 'dark' })));
|
|
14
|
+
* const config = await fs.readFile('/data/config.json');
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare class OPFSSync extends BaseOPFS {
|
|
18
|
+
/** Shared sync handles per path (OPFS allows only one handle per file) */
|
|
19
|
+
private openHandles;
|
|
20
|
+
/** Map of open file descriptors to their metadata */
|
|
21
|
+
private openFiles;
|
|
22
|
+
/** Next available file descriptor number */
|
|
23
|
+
private nextFd;
|
|
24
|
+
constructor(options?: OPFSOptions);
|
|
25
|
+
/**
|
|
26
|
+
* Get file info by descriptor with validation
|
|
27
|
+
* @private
|
|
28
|
+
*/
|
|
29
|
+
private _getFileDescriptor;
|
|
30
|
+
readFile(path: string): Promise<Uint8Array>;
|
|
31
|
+
writeFile(path: string, data: Uint8Array | ArrayBuffer): Promise<void>;
|
|
32
|
+
appendFile(path: string, data: Uint8Array | ArrayBuffer): Promise<void>;
|
|
33
|
+
writeStream(path: string, stream: ReadableStream<Uint8Array>, onProgress?: (bytesWritten: number) => unknown): Promise<number>;
|
|
34
|
+
open(path: string, options?: FileOpenOptions): Promise<number>;
|
|
35
|
+
/**
|
|
36
|
+
* Internal method to open a file (without locking)
|
|
37
|
+
*
|
|
38
|
+
* Multiple FDs for the same path share one sync access handle (OPFS limit),
|
|
39
|
+
* with independent per-FD positions — similar to Node.js.
|
|
40
|
+
* @private
|
|
41
|
+
*/
|
|
42
|
+
private _openFile;
|
|
43
|
+
close(fd: number): Promise<void>;
|
|
44
|
+
read(fd: number, buffer: Uint8Array, offset: number, length: number, position: number | null | undefined): Promise<{
|
|
45
|
+
bytesRead: number;
|
|
46
|
+
buffer: Uint8Array;
|
|
47
|
+
}>;
|
|
48
|
+
write(fd: number, buffer: Uint8Array, offset?: number, length?: number, position?: number | null | undefined, emitEvent?: boolean): Promise<number>;
|
|
49
|
+
fstat(fd: number): Promise<FileStat>;
|
|
50
|
+
ftruncate(fd: number, size?: number): Promise<void>;
|
|
51
|
+
fsync(fd: number): Promise<void>;
|
|
52
|
+
dispose(): void;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=OPFSSync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OPFSSync.d.ts","sourceRoot":"","sources":["../../src/core/OPFSSync.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAoBtC,OAAO,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvE;;;;;;;;;;;;;GAaG;AACH,qBAAa,QAAS,SAAQ,QAAQ;IAClC,0EAA0E;IAC1E,OAAO,CAAC,WAAW,CAId;IAEL,qDAAqD;IACrD,OAAO,CAAC,SAAS,CAKZ;IAEL,4CAA4C;IAC5C,OAAO,CAAC,MAAM,CAAK;gBAEP,OAAO,CAAC,EAAE,WAAW;IAIjC;;;OAGG;IACH,OAAO,CAAC,kBAAkB;IAUpB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IA+B3C,SAAS,CACX,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,UAAU,GAAG,WAAW,GAC/B,OAAO,CAAC,IAAI,CAAC;IAqBV,UAAU,CACZ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,UAAU,GAAG,WAAW,GAC/B,OAAO,CAAC,IAAI,CAAC;IAsBV,WAAW,CACb,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,EAClC,UAAU,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,GAC/C,OAAO,CAAC,MAAM,CAAC;IAwDZ,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC;IAwCpE;;;;;;OAMG;YACW,SAAS;IAuCjB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAoBhC,IAAI,CACN,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GACpC,OAAO,CAAC;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,UAAU,CAAA;KAAE,CAAC;IAmC/C,KAAK,CACP,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,UAAU,EAClB,MAAM,GAAE,MAAU,EAClB,MAAM,CAAC,EAAE,MAAM,EACf,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACpC,SAAS,GAAE,OAAc,GAC1B,OAAO,CAAC,MAAM,CAAC;IAoCZ,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAOpC,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,GAAE,MAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAwBtD,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAW7B,OAAO,IAAI,IAAI;CAY3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createOPFSAsync-BwKDmHsy.cjs","sources":["../src/facade/createOPFSAsync.ts"],"sourcesContent":["import { OPFSFacade } from './OPFSFacade';\nimport { OPFSAsync } from '../core/OPFSAsync';\n\nimport type { OPFSOptions } from '../types';\n\n/**\n * Async mode: Node-like `fs` API over the promise-based File System API,\n * without any worker.\n *\n * Prefer importing from `opfs-worker/async` when you care about bundle size\n * (avoids the inlined dedicated worker). Importing from `opfs-worker` works too.\n *\n * Writing requires `FileSystemFileHandle.createWritable()` — Chrome, Firefox,\n * Safari 26+. File descriptors (`open`/`read`/`write`/...) are not supported\n * and throw `OperationNotSupportedError` — use `createOPFSDedicated` from `opfs-worker`\n * or `opfs-worker/sync` for positional I/O.\n */\nexport function createOPFSAsync(options?: OPFSOptions): OPFSFacade {\n const fs = new OPFSAsync(options);\n\n return new OPFSFacade({ fs, dispose: () => fs.dispose() });\n}\n"],"names":["createOPFSAsync","options","fs","OPFSAsync","OPFSFacade"],"mappings":"gGAiBO,SAASA,EAAgBC,EAAmC,CAC/D,MAAMC,EAAK,IAAIC,EAAAA,UAAUF,CAAO,EAEhC,OAAO,IAAIG,EAAAA,WAAW,CAAE,GAAAF,EAAI,QAAS,IAAMA,EAAG,QAAA,EAAW,CAC7D"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { O as o } from "./OPFSFacade-XohWlHuu.js";
|
|
2
|
+
import { O as n } from "./OPFSAsync-BKSAJJeh.js";
|
|
3
|
+
function t(e) {
|
|
4
|
+
const s = new n(e);
|
|
5
|
+
return new o({ fs: s, dispose: () => s.dispose() });
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
t as c
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=createOPFSAsync-Y4Mg6qte.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createOPFSAsync-Y4Mg6qte.js","sources":["../src/facade/createOPFSAsync.ts"],"sourcesContent":["import { OPFSFacade } from './OPFSFacade';\nimport { OPFSAsync } from '../core/OPFSAsync';\n\nimport type { OPFSOptions } from '../types';\n\n/**\n * Async mode: Node-like `fs` API over the promise-based File System API,\n * without any worker.\n *\n * Prefer importing from `opfs-worker/async` when you care about bundle size\n * (avoids the inlined dedicated worker). Importing from `opfs-worker` works too.\n *\n * Writing requires `FileSystemFileHandle.createWritable()` — Chrome, Firefox,\n * Safari 26+. File descriptors (`open`/`read`/`write`/...) are not supported\n * and throw `OperationNotSupportedError` — use `createOPFSDedicated` from `opfs-worker`\n * or `opfs-worker/sync` for positional I/O.\n */\nexport function createOPFSAsync(options?: OPFSOptions): OPFSFacade {\n const fs = new OPFSAsync(options);\n\n return new OPFSFacade({ fs, dispose: () => fs.dispose() });\n}\n"],"names":["createOPFSAsync","options","fs","OPFSAsync","OPFSFacade"],"mappings":";;AAiBO,SAASA,EAAgBC,GAAmC;AAC/D,QAAMC,IAAK,IAAIC,EAAUF,CAAO;AAEhC,SAAO,IAAIG,EAAW,EAAE,IAAAF,GAAI,SAAS,MAAMA,EAAG,QAAA,GAAW;AAC7D;"}
|