opfs-worker 2.0.0 → 2.1.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.
Files changed (134) hide show
  1. package/README.md +64 -428
  2. package/dist/BaseOPFS-BusBkyJX.js +2114 -0
  3. package/dist/BaseOPFS-BusBkyJX.js.map +1 -0
  4. package/dist/BaseOPFS-CYwrD7-q.cjs +4 -0
  5. package/dist/BaseOPFS-CYwrD7-q.cjs.map +1 -0
  6. package/dist/OPFSAsync-B2dR-2VR.cjs +2 -0
  7. package/dist/OPFSAsync-B2dR-2VR.cjs.map +1 -0
  8. package/dist/OPFSAsync-CO44W23e.js +124 -0
  9. package/dist/OPFSAsync-CO44W23e.js.map +1 -0
  10. package/dist/OPFSFacade-CEaSqTut.js +308 -0
  11. package/dist/OPFSFacade-CEaSqTut.js.map +1 -0
  12. package/dist/OPFSFacade-hrNXCn6w.cjs +2 -0
  13. package/dist/OPFSFacade-hrNXCn6w.cjs.map +1 -0
  14. package/dist/OPFSSync-BPrNtvFS.cjs +2 -0
  15. package/dist/OPFSSync-BPrNtvFS.cjs.map +1 -0
  16. package/dist/OPFSSync-D7obTsl3.js +208 -0
  17. package/dist/OPFSSync-D7obTsl3.js.map +1 -0
  18. package/dist/assets/dedicated.worker-DW6UqFo0.js.map +1 -0
  19. package/dist/{OPFSWorker.d.ts → core/BaseOPFS.d.ts} +53 -292
  20. package/dist/core/BaseOPFS.d.ts.map +1 -0
  21. package/dist/core/OPFSAsync.d.ts +55 -0
  22. package/dist/core/OPFSAsync.d.ts.map +1 -0
  23. package/dist/core/OPFSSync.d.ts +54 -0
  24. package/dist/core/OPFSSync.d.ts.map +1 -0
  25. package/dist/createOPFSAsync-DdhJYoC0.js +10 -0
  26. package/dist/createOPFSAsync-DdhJYoC0.js.map +1 -0
  27. package/dist/createOPFSAsync-DyWpvmL-.cjs +2 -0
  28. package/dist/createOPFSAsync-DyWpvmL-.cjs.map +1 -0
  29. package/dist/createOPFSDedicated-BwTc0NV5.js +2407 -0
  30. package/dist/createOPFSDedicated-BwTc0NV5.js.map +1 -0
  31. package/dist/createOPFSDedicated-CEeRexom.cjs +2357 -0
  32. package/dist/createOPFSDedicated-CEeRexom.cjs.map +1 -0
  33. package/dist/createOPFSShared-BSFWsoLe.js +23 -0
  34. package/dist/createOPFSShared-BSFWsoLe.js.map +1 -0
  35. package/dist/createOPFSShared-BoCft_BS.cjs +2 -0
  36. package/dist/createOPFSShared-BoCft_BS.cjs.map +1 -0
  37. package/dist/dedicated.worker.js +2355 -0
  38. package/dist/dedicated.worker.js.map +1 -0
  39. package/dist/{OPFSFacade.d.ts → facade/OPFSFacade.d.ts} +51 -25
  40. package/dist/facade/OPFSFacade.d.ts.map +1 -0
  41. package/dist/facade/createOPFSAsync.d.ts +16 -0
  42. package/dist/facade/createOPFSAsync.d.ts.map +1 -0
  43. package/dist/facade/createOPFSDedicated.d.ts +17 -0
  44. package/dist/facade/createOPFSDedicated.d.ts.map +1 -0
  45. package/dist/facade/createOPFSShared.d.ts +24 -0
  46. package/dist/facade/createOPFSShared.d.ts.map +1 -0
  47. package/dist/index.async.cjs +2 -0
  48. package/dist/index.async.cjs.map +1 -0
  49. package/dist/index.async.d.ts +10 -0
  50. package/dist/index.async.d.ts.map +1 -0
  51. package/dist/index.async.js +55 -0
  52. package/dist/index.async.js.map +1 -0
  53. package/dist/index.cjs +1 -2477
  54. package/dist/index.cjs.map +1 -1
  55. package/dist/index.d.ts +17 -3
  56. package/dist/index.d.ts.map +1 -1
  57. package/dist/index.js +61 -2828
  58. package/dist/index.js.map +1 -1
  59. package/dist/index.pure.cjs +1 -1
  60. package/dist/index.pure.cjs.map +1 -1
  61. package/dist/index.pure.d.ts +3 -1
  62. package/dist/index.pure.d.ts.map +1 -1
  63. package/dist/index.pure.js +50 -1053
  64. package/dist/index.pure.js.map +1 -1
  65. package/dist/index.sharedworker.cjs +2 -0
  66. package/dist/index.sharedworker.cjs.map +1 -0
  67. package/dist/index.sharedworker.d.ts +11 -0
  68. package/dist/index.sharedworker.d.ts.map +1 -0
  69. package/dist/index.sharedworker.js +55 -0
  70. package/dist/index.sharedworker.js.map +1 -0
  71. package/dist/index.sync.cjs +2 -0
  72. package/dist/index.sync.cjs.map +1 -0
  73. package/dist/index.sync.d.ts +11 -0
  74. package/dist/index.sync.d.ts.map +1 -0
  75. package/dist/index.sync.js +55 -0
  76. package/dist/index.sync.js.map +1 -0
  77. package/dist/shared.worker.js +2240 -0
  78. package/dist/shared.worker.js.map +1 -0
  79. package/dist/types.d.ts +42 -4
  80. package/dist/types.d.ts.map +1 -1
  81. package/dist/worker/createDedicatedWorker.d.ts +30 -0
  82. package/dist/worker/createDedicatedWorker.d.ts.map +1 -0
  83. package/dist/worker/createSharedWorker.d.ts +37 -0
  84. package/dist/worker/createSharedWorker.d.ts.map +1 -0
  85. package/dist/worker/dedicated.worker.d.ts +2 -0
  86. package/dist/worker/dedicated.worker.d.ts.map +1 -0
  87. package/dist/worker/shared.worker.d.ts +2 -0
  88. package/dist/worker/shared.worker.d.ts.map +1 -0
  89. package/docs/api/backend.md +36 -0
  90. package/docs/api/create.md +82 -0
  91. package/docs/api/facade.md +53 -0
  92. package/docs/choosing-a-mode.md +41 -0
  93. package/docs/file-descriptors.md +46 -605
  94. package/docs/guides/async.md +36 -0
  95. package/docs/guides/dedicated.md +76 -0
  96. package/docs/guides/hashing.md +34 -0
  97. package/docs/guides/pure.md +46 -0
  98. package/docs/guides/sharedworker.md +57 -0
  99. package/docs/guides/streaming.md +185 -0
  100. package/docs/guides/watching.md +35 -0
  101. package/docs/migration.md +41 -0
  102. package/docs/types.md +105 -153
  103. package/package.json +53 -4
  104. package/src/{OPFSWorker.ts → core/BaseOPFS.ts} +159 -629
  105. package/src/core/OPFSAsync.ts +248 -0
  106. package/src/core/OPFSSync.ts +460 -0
  107. package/src/{OPFSFacade.ts → facade/OPFSFacade.ts} +134 -58
  108. package/src/facade/createOPFSAsync.ts +22 -0
  109. package/src/facade/createOPFSDedicated.ts +23 -0
  110. package/src/facade/createOPFSShared.ts +30 -0
  111. package/src/index.async.ts +11 -0
  112. package/src/index.pure.ts +3 -2
  113. package/src/index.sharedworker.ts +12 -0
  114. package/src/index.sync.ts +12 -0
  115. package/src/index.ts +37 -8
  116. package/src/types.ts +45 -4
  117. package/src/worker/createDedicatedWorker.ts +74 -0
  118. package/src/worker/createSharedWorker.ts +67 -0
  119. package/src/worker/dedicated.worker.ts +13 -0
  120. package/src/worker/shared.worker.ts +17 -0
  121. package/dist/OPFSFacade.d.ts.map +0 -1
  122. package/dist/OPFSWorker.d.ts.map +0 -1
  123. package/dist/assets/worker.entry-DUlEoroc.js.map +0 -1
  124. package/dist/createOPFSWorker.d.ts +0 -17
  125. package/dist/createOPFSWorker.d.ts.map +0 -1
  126. package/dist/helpers-DNj8ZoMu.cjs +0 -4
  127. package/dist/helpers-DNj8ZoMu.cjs.map +0 -1
  128. package/dist/helpers-WY2jfbOT.js +0 -1427
  129. package/dist/helpers-WY2jfbOT.js.map +0 -1
  130. package/dist/worker.entry.d.ts +0 -2
  131. package/dist/worker.entry.d.ts.map +0 -1
  132. package/docs/api-reference.md +0 -815
  133. package/src/createOPFSWorker.ts +0 -57
  134. package/src/worker.entry.ts +0 -6
@@ -1,40 +1,20 @@
1
- import type { DirentData, FileOpenOptions, FileStat, OPFSOptions, RenameOptions, WatchOptions } from './types';
1
+ import type { DirentData, FileStat, ImportFilesEntries, ImportFilesProgress, ImportFilesResult, OPFSOptions, RenameOptions, WatchEvent, WatchOptions, WatchSnapshot } from '../types';
2
2
  /**
3
- * OPFS (Origin Private File System) File System implementation
4
- *
5
- * This class provides a high-level interface for working with the browser's
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 OPFSWorker();
12
- * await fs.writeFile('/data/config.json', new TextEncoder().encode(JSON.stringify({ theme: 'dark' })));
13
- * const config = await fs.readFile('/data/config.json');
14
- * ```
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}.
15
6
  */
16
- export declare class OPFSWorker {
7
+ export declare abstract class BaseOPFS {
17
8
  /** Root directory handle for the file system */
18
- private root;
9
+ protected root: FileSystemDirectoryHandle;
19
10
  /** Map of watched paths and options */
20
- private watchers;
11
+ protected watchers: Map<string, WatchSnapshot>;
21
12
  /** Promise to prevent concurrent mount operations */
22
- private mountingPromise;
13
+ protected mountingPromise: Promise<boolean> | null;
23
14
  /** BroadcastChannel instance for sending events */
24
- private broadcastChannel;
15
+ protected broadcastChannel: BroadcastChannel | null;
25
16
  /** Configuration options */
26
- private options;
27
- /** Shared sync handles per path (OPFS allows only one handle per file) */
28
- private openHandles;
29
- /** Map of open file descriptors to their metadata */
30
- private openFiles;
31
- /** Next available file descriptor number */
32
- private nextFd;
33
- /**
34
- * Get file info by descriptor with validation
35
- * @private
36
- */
37
- private _getFileDescriptor;
17
+ protected options: Required<OPFSOptions>;
38
18
  /**
39
19
  * Notify about internal changes to the file system
40
20
  *
@@ -43,39 +23,21 @@ export declare class OPFSWorker {
43
23
  *
44
24
  * @param event - The event describing the change
45
25
  */
46
- private notifyChange;
47
- /**
48
- * Creates a new OPFSWorker instance
49
- *
50
- * @param options - Optional configuration options
51
- * @param options.root - Root path for the file system (default: '/')
52
- * @param options.watchInterval - Polling interval in milliseconds for file watching
53
- * @param options.hashAlgorithm - Hash algorithm for file hashing
54
- * @param options.maxFileSize - Maximum file size for hashing in bytes (default: 50MB)
55
- * @throws {OPFSError} If OPFS is not supported in the current browser
56
- */
26
+ protected notifyChange(event: Omit<WatchEvent, 'timestamp' | 'hash' | 'namespace'>): Promise<void>;
57
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>;
58
36
  /**
59
- * Initialize the file system within a given directory
60
- *
61
- * This method sets up the root directory for all subsequent operations.
62
- * If no root is specified, it will use the OPFS root directory.
63
- *
64
- * @returns Promise that resolves to true if initialization was successful
65
- * @throws {OPFSError} If initialization fails
66
- *
67
- * @example
68
- * ```typescript
69
- * const fs = new OPFSWorker();
70
- *
71
- * // Use OPFS root (default)
72
- * await fs.mount();
73
- *
74
- * // Use custom directory
75
- * await fs.mount('/my-app');
76
- * ```
37
+ * Initialize the file system within a given directory.
38
+ * If no root is specified, uses the OPFS root directory.
77
39
  */
78
- private mount;
40
+ protected mount(): Promise<boolean>;
79
41
  /**
80
42
  * Update configuration options
81
43
  *
@@ -105,7 +67,7 @@ export declare class OPFSWorker {
105
67
  * const docsDir2 = await fs.getDirectoryHandle(['users', 'john', 'documents'], true);
106
68
  * ```
107
69
  */
108
- private getDirectoryHandle;
70
+ protected getDirectoryHandle(path: string | string[], create?: boolean, from?: FileSystemDirectoryHandle | null): Promise<FileSystemDirectoryHandle>;
109
71
  /**
110
72
  * Get a file handle from a path
111
73
  *
@@ -125,7 +87,7 @@ export declare class OPFSWorker {
125
87
  * const fileHandle2 = await fs.getFileHandle(['config', 'settings.json'], true);
126
88
  * ```
127
89
  */
128
- private getFileHandle;
90
+ protected getFileHandle(path: string | string[], create?: boolean, _from?: FileSystemDirectoryHandle | null): Promise<FileSystemFileHandle>;
129
91
  /**
130
92
  * Get a complete index of all files and directories in the file system
131
93
  *
@@ -146,72 +108,6 @@ export declare class OPFSWorker {
146
108
  * ```
147
109
  */
148
110
  index(): Promise<Map<string, FileStat>>;
149
- /**
150
- * Read a file from the file system
151
- *
152
- * Reads the contents of a file and returns it as binary data.
153
- *
154
- * @param path - The path to the file to read
155
- * @returns Promise that resolves to the file contents as Uint8Array
156
- * @throws {FileNotFoundError} If the file does not exist
157
- * @throws {OPFSError} If reading the file fails
158
- *
159
- * @example
160
- * ```typescript
161
- * // Read as binary data
162
- * const content = await fs.readFile('/config/settings.json');
163
- *
164
- * // Read binary file
165
- * const binaryData = await fs.readFile('/images/logo.png');
166
- * ```
167
- */
168
- readFile(path: string): Promise<Uint8Array>;
169
- /**
170
- * Write data to a file
171
- *
172
- * Creates or overwrites a file with the specified binary data. If the file already
173
- * exists, it will be truncated before writing.
174
- *
175
- * @param path - The path to the file to write
176
- * @param data - The binary data to write to the file (Uint8Array or ArrayBuffer)
177
- * @returns Promise that resolves when the write operation is complete
178
- * @throws {OPFSError} If writing the file fails
179
- *
180
- * @example
181
- * ```typescript
182
- * // Write binary data
183
- * const binaryData = new Uint8Array([1, 2, 3, 4, 5]);
184
- * await fs.writeFile('/data/binary.dat', binaryData);
185
- *
186
- * // Write from ArrayBuffer
187
- * const arrayBuffer = new ArrayBuffer(10);
188
- * await fs.writeFile('/data/buffer.dat', arrayBuffer);
189
- * ```
190
- */
191
- writeFile(path: string, data: Uint8Array | ArrayBuffer): Promise<void>;
192
- /**
193
- * Append data to a file
194
- *
195
- * Adds binary data to the end of an existing file. If the file doesn't exist,
196
- * it will be created.
197
- *
198
- * @param path - The path to the file to append to
199
- * @param data - The binary data to append to the file (Uint8Array or ArrayBuffer)
200
- * @returns Promise that resolves when the append operation is complete
201
- * @throws {OPFSError} If appending to the file fails
202
- *
203
- * @example
204
- * ```typescript
205
- * // Append binary data
206
- * const additionalData = new Uint8Array([6, 7, 8]);
207
- * await fs.appendFile('/data/binary.dat', additionalData);
208
- *
209
- * // Append from ArrayBuffer
210
- * const arrayBuffer = new ArrayBuffer(5);
211
- * await fs.appendFile('/data/buffer.dat', arrayBuffer);
212
- * ```
213
- */
214
- appendFile(path: string, data: Uint8Array | ArrayBuffer): Promise<void>;
215
111
  /**
216
112
  * Create a directory
217
113
  *
@@ -443,190 +339,55 @@ export declare class OPFSWorker {
443
339
  */
444
340
  unwatch(path: string): void;
445
341
  /**
446
- * Open a file and return a file descriptor
447
- *
448
- * @param path - The path to the file to open
449
- * @param options - Options for opening the file
450
- * @param options.create - Whether to create the file if it doesn't exist (default: false)
451
- * @param options.exclusive - If true and create is true, fails if file already exists (default: false)
452
- * Note: This is best-effort in OPFS, not fully atomic due to browser limitations
453
- * @param options.truncate - Whether to truncate the file to zero length (default: false)
454
- * @returns Promise that resolves to a file descriptor number
455
- * @throws {OPFSError} If opening the file fails
456
- *
457
- * @example
458
- * ```typescript
459
- * // Open existing file for reading
460
- * const fd = await fs.open('/data/config.json');
461
- *
462
- * // Create new file for writing
463
- * const fd = await fs.open('/data/new.txt', { create: true });
464
- *
465
- * // Create file exclusively (fails if exists)
466
- * const fd = await fs.open('/data/unique.txt', { create: true, exclusive: true });
467
- *
468
- * // Open and truncate file
469
- * const fd = await fs.open('/data/log.txt', { create: true, truncate: true });
470
- * ```
471
- */
472
- open(path: string, options?: FileOpenOptions): Promise<number>;
473
- /**
474
- * Internal method to open a file (without locking)
342
+ * Read a file as a `Blob` without copying its bytes into memory.
475
343
  *
476
- * Multiple FDs for the same path share one sync access handle (OPFS limit),
477
- * with independent per-FD positions similar to Node.js.
478
- * @private
479
- */
480
- private _openFile;
481
- /**
482
- * Close a file descriptor
344
+ * OPFS hands back a disk-backed `File`, so the browser can stream it on
345
+ * demand pass it to `URL.createObjectURL()` for `<video>` / `<audio>` /
346
+ * `<img>` and only the played range is actually read. Structured clone keeps
347
+ * the reference intact when the file system runs in a worker.
483
348
  *
484
- * @param fd - The file descriptor to close
485
- * @returns Promise that resolves when the file descriptor is closed
486
- * @throws {OPFSError} If the file descriptor is invalid or closing fails
349
+ * @param path - Path to the file
350
+ * @returns Lazy `File` handle backed by OPFS storage
351
+ * @throws {OPFSError} If the path is missing or is a directory
487
352
  *
488
353
  * @example
489
354
  * ```typescript
490
- * const fd = await fs.open('/data/file.txt');
491
- * // ... use the file descriptor ...
492
- * await fs.close(fd);
355
+ * const blob = await fs.readBlob('/media/clip.mp4');
356
+ * video.src = URL.createObjectURL(blob);
493
357
  * ```
494
358
  */
495
- close(fd: number): Promise<void>;
359
+ readBlob(path: string): Promise<Blob>;
496
360
  /**
497
- * Read data from a file descriptor
498
- *
499
- * @param fd - The file descriptor to read from
500
- * @param buffer - The buffer to read data into
501
- * @param offset - The offset in the buffer to start writing at
502
- * @param length - The number of bytes to read
503
- * @param position - The position in the file to read from (null for current position)
504
- * @returns Promise that resolves to the number of bytes read and the modified buffer
505
- * @throws {OPFSError} If the file descriptor is invalid or reading fails
361
+ * Bulk-import files from `[path, data]` entries (strings, bytes, Blobs, or Files).
362
+ * Each entry is written via {@link writeStream} so large Blobs/Files are not
363
+ * fully buffered in memory.
506
364
  *
507
- * @note This method uses Comlink.transfer() to efficiently pass the buffer as a Transferable Object,
508
- * ensuring zero-copy performance across Web Worker boundaries.
509
- *
510
- * @example
511
- * ```typescript
512
- * const fd = await fs.open('/data/file.txt');
513
- * const buffer = new Uint8Array(1024);
514
- * const { bytesRead, buffer: modifiedBuffer } = await fs.read(fd, buffer, 0, 1024, null);
515
- * console.log(`Read ${bytesRead} bytes`);
516
- * // Use modifiedBuffer which contains the actual data
517
- * await fs.close(fd);
518
- * ```
519
- */
520
- read(fd: number, buffer: Uint8Array, offset: number, length: number, position: number | null | undefined): Promise<{
521
- bytesRead: number;
522
- buffer: Uint8Array;
523
- }>;
524
- /**
525
- * Write data to a file descriptor
526
- *
527
- * @param fd - The file descriptor to write to
528
- * @param buffer - The buffer containing data to write
529
- * @param offset - The offset in the buffer to start reading from (default: 0)
530
- * @param length - The number of bytes to write (default: entire buffer)
531
- * @param position - The position in the file to write to (null/undefined for current position)
532
- * @param emitEvent - Whether to emit a change event (default: true)
533
- * @returns Promise that resolves to the number of bytes written
534
- * @throws {OPFSError} If the file descriptor is invalid or writing fails
535
- *
536
- * @example
537
- * ```typescript
538
- * const fd = await fs.open('/data/file.txt', { create: true });
539
- * const data = new TextEncoder().encode('Hello, World!');
540
- * const bytesWritten = await fs.write(fd, data, 0, data.length, null);
541
- * console.log(`Wrote ${bytesWritten} bytes`);
542
- * await fs.close(fd);
543
- * ```
544
- */
545
- write(fd: number, buffer: Uint8Array, offset?: number, length?: number, position?: number | null | undefined, emitEvent?: boolean): Promise<number>;
546
- /**
547
- * Get file status information by file descriptor
365
+ * Accepts an array of tuples, a `Map`, or any iterable of `[path, data]` pairs.
548
366
  *
549
- * @param fd - The file descriptor
550
- * @returns Promise that resolves to FileStat object
551
- * @throws {OPFSError} If the file descriptor is invalid
367
+ * @param entries - Files to write
368
+ * @param onProgress - Per-chunk progress with path, index, and byte counts
369
+ * @returns Written paths, count, and total bytes
370
+ * @throws {OPFSError} If a write fails
552
371
  *
553
372
  * @example
554
373
  * ```typescript
555
- * const fd = await fs.open('/data/file.txt');
556
- * const stats = await fs.fstat(fd);
557
- * console.log(`File size: ${stats.size} bytes`);
558
- * console.log(`Last modified: ${stats.mtime}`);
559
- *
560
- * // If hashing is enabled, hash will be included
561
- * if (stats.hash) {
562
- * console.log(`Hash: ${stats.hash}`);
563
- * }
564
- * ```
565
- */
566
- fstat(fd: number): Promise<FileStat>;
567
- /**
568
- * Truncate file to specified size
569
- *
570
- * @param fd - The file descriptor
571
- * @param size - The new size of the file (default: 0)
572
- * @returns Promise that resolves when truncation is complete
573
- * @throws {OPFSError} If the file descriptor is invalid or truncation fails
374
+ * const result = await fs.importFiles([
375
+ * ['/config.json', JSON.stringify({ theme: 'dark' })],
376
+ * ['/data/binary.dat', new Uint8Array([1, 2, 3, 4])],
377
+ * ['/upload.txt', fileFromInput],
378
+ * ], (p) => console.log(`${p.path}: ${p.bytesWritten}/${p.bytesTotal}`));
574
379
  *
575
- * @example
576
- * ```typescript
577
- * const fd = await fs.open('/data/file.txt', { create: true });
578
- * await fs.truncate(fd, 100); // Truncate to 100 bytes
380
+ * console.log(result.count, result.bytesWritten, result.paths);
579
381
  * ```
580
382
  */
581
- ftruncate(fd: number, size?: number): Promise<void>;
383
+ importFiles(entries: ImportFilesEntries, onProgress?: (progress: ImportFilesProgress) => unknown): Promise<ImportFilesResult>;
582
384
  /**
583
- * Synchronize file data to storage (fsync equivalent)
584
- *
585
- * @param fd - The file descriptor
586
- * @returns Promise that resolves when synchronization is complete
587
- * @throws {OPFSError} If the file descriptor is invalid or sync fails
588
- *
589
- * @example
590
- * ```typescript
591
- * const fd = await fs.open('/data/file.txt', { create: true });
592
- * await fs.write(fd, data);
593
- * await fs.fsync(fd); // Ensure data is written to storage
594
- * ```
385
+ * @deprecated Use {@link importFiles} instead.
595
386
  */
596
- fsync(fd: number): Promise<void>;
387
+ createIndex(entries: ImportFilesEntries): Promise<void>;
597
388
  /**
598
389
  * Dispose of resources and clean up the file system instance
599
- *
600
- * This method should be called when the file system instance is no longer needed
601
- * to properly clean up resources like the broadcast channel and watch timers.
602
390
  */
603
391
  dispose(): void;
604
- /**
605
- * Synchronize the file system with external data
606
- *
607
- * Syncs the file system with an array of entries containing paths and data.
608
- * This is useful for importing data from external sources or syncing with remote data.
609
- *
610
- * @param entries - Array of [path, data] tuples to sync
611
- * @returns Promise that resolves when synchronization is complete
612
- * @throws {OPFSError} If the synchronization fails
613
- *
614
- * @example
615
- * ```typescript
616
- * // Sync with external data
617
- * const entries: [string, string | Uint8Array | Blob][] = [
618
- * ['/config.json', JSON.stringify({ theme: 'dark' })],
619
- * ['/data/binary.dat', new Uint8Array([1, 2, 3, 4])],
620
- * ['/upload.txt', new Blob(['file content'], { type: 'text/plain' })]
621
- * ];
622
- *
623
- * // Sync without clearing existing files
624
- * await fs.sync(entries);
625
- *
626
- * // Clean file system and then sync
627
- * await fs.sync(entries, { cleanBefore: true });
628
- * ```
629
- */
630
- createIndex(entries: [string, string | Uint8Array | Blob][]): Promise<void>;
631
392
  }
632
- //# sourceMappingURL=OPFSWorker.d.ts.map
393
+ //# sourceMappingURL=BaseOPFS.d.ts.map
@@ -0,0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AmB,KAAK,OAAO,GACxD,OAAO,CAAC,iBAAiB,CAAC;IAiD7B;;OAEG;IACG,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAK7D;;OAEG;IACH,OAAO,IAAI,IAAI;CAQlB"}
@@ -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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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=OP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AE,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,10 @@
1
+ import { O as o } from "./OPFSFacade-CEaSqTut.js";
2
+ import { O as n } from "./OPFSAsync-CO44W23e.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-DdhJYoC0.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createOPFSAsync-DdhJYoC0.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;"}
@@ -0,0 +1,2 @@
1
+ "use strict";const c=require("./OPFSFacade-hrNXCn6w.cjs"),n=require("./OPFSAsync-B2dR-2VR.cjs");function r(s){const e=new n.OPFSAsync(s);return new c.OPFSFacade({fs:e,dispose:()=>e.dispose()})}exports.createOPFSAsync=r;
2
+ //# sourceMappingURL=createOPFSAsync-DyWpvmL-.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createOPFSAsync-DyWpvmL-.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"}