@componentor/fs 2.0.10 → 2.0.12

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 CHANGED
@@ -250,6 +250,35 @@ fs.promises.flush(): Promise<void> // Flush pending writes
250
250
  fs.promises.purge(): Promise<void> // Clear all caches
251
251
  ```
252
252
 
253
+ ### Streams API
254
+
255
+ ```typescript
256
+ // Create a readable stream (Web Streams API)
257
+ fs.createReadStream(path: string, options?: {
258
+ start?: number, // Byte offset to start reading
259
+ end?: number, // Byte offset to stop reading
260
+ highWaterMark?: number // Chunk size (default: 64KB)
261
+ }): ReadableStream<Uint8Array>
262
+
263
+ // Create a writable stream (Web Streams API)
264
+ fs.createWriteStream(path: string, options?: {
265
+ start?: number, // Byte offset to start writing
266
+ flush?: boolean // Flush on close (default: true)
267
+ }): WritableStream<Uint8Array>
268
+
269
+ // Example: Stream a file
270
+ const stream = fs.createReadStream('/large-file.bin');
271
+ for await (const chunk of stream) {
272
+ console.log('Read chunk:', chunk.length, 'bytes');
273
+ }
274
+
275
+ // Example: Write with streams
276
+ const writable = fs.createWriteStream('/output.bin');
277
+ const writer = writable.getWriter();
278
+ await writer.write(new Uint8Array([1, 2, 3]));
279
+ await writer.close();
280
+ ```
281
+
253
282
  ### Path Utilities
254
283
 
255
284
  ```typescript
@@ -323,36 +352,36 @@ await git.commit({
323
352
 
324
353
  ```
325
354
  ┌─────────────────────────────────────────────────────────────┐
326
- │ Main Thread
327
- │ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────┐
328
- │ │ Sync API │ │ Async API │ │ Path Utilities │
329
- │ │ readFileSync│ │ promises. │ │ join, dirname, etc. │
330
- │ │writeFileSync│ │ readFile │ └─────────────────────┘
331
- │ └──────┬──────┘ └──────┬──────┘
332
- │ │ │
355
+ │ Main Thread
356
+ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────┐
357
+ │ │ Sync API │ │ Async API │ │ Path Utilities │
358
+ │ │ readFileSync│ │ promises. │ │ join, dirname, etc. │
359
+ │ │writeFileSync│ │ readFile │ └─────────────────────┘
360
+ │ └──────┬──────┘ └──────┬──────┘
361
+ │ │ │
333
362
  │ │ Atomics.wait │ postMessage │
334
363
  │ │ (Tier 1) │ (Tier 2) │
335
364
  └─────────┼────────────────┼──────────────────────────────────┘
336
365
  │ │
337
366
  ▼ ▼
338
367
  ┌─────────────────────────────────────────────────────────────┐
339
- │ Web Worker
368
+ │ Web Worker
340
369
  │ ┌────────────────────────────────────────────────────────┐ │
341
370
  │ │ OPFS Kernel │ │
342
- │ │ ┌──────────────┐ ┌──────────────┐ ┌─────────────┐ │ │
343
- │ │ │ Sync Handle │ │ Directory │ │ navigator │ │ │
344
- │ │ │ Cache │ │ Cache │ │ .locks │ │ │
345
- │ │ │ (100 max) │ │ │ │ (cross-tab) │ │ │
346
- │ │ └──────────────┘ └──────────────┘ └─────────────┘ │ │
371
+ │ │ ┌──────────────┐ ┌──────────────┐ ┌─────────────┐ │ │
372
+ │ │ │ Sync Handle │ │ Directory │ │ navigator │ │ │
373
+ │ │ │ Cache │ │ Cache │ │ .locks │ │ │
374
+ │ │ │ (100 max) │ │ │ │ (cross-tab) │ │ │
375
+ │ │ └──────────────┘ └──────────────┘ └─────────────┘ │ │
347
376
  │ └────────────────────────────────────────────────────────┘ │
348
- │ │
349
- └────────────────────────────┼─────────────────────────────────┘
377
+ │ │
378
+ └────────────────────────────┼────────────────────────────────┘
350
379
 
351
380
 
352
381
  ┌─────────────────────────────────────────────────────────────┐
353
- │ OPFS
354
- │ Origin Private File System
355
- │ (Browser Storage API)
382
+ │ OPFS
383
+ │ Origin Private File System
384
+ │ (Browser Storage API)
356
385
  └─────────────────────────────────────────────────────────────┘
357
386
  ```
358
387
 
@@ -378,7 +407,7 @@ await git.commit({
378
407
  | `open` / `FileHandle` | ✅ | ✅ | ❌ | ❌ |
379
408
  | `opendir` / `Dir` | ✅ | ✅ | ❌ | ❌ |
380
409
  | `mkdtemp` | ✅ | ✅ | ❌ | ❌ |
381
- | Streams | ✅ | | ❌ | ❌ |
410
+ | Streams | ✅ | | ❌ | ❌ |
382
411
 
383
412
  ### Performance Tiers
384
413
 
@@ -446,6 +475,11 @@ Another tab or operation has the file open. The library uses `navigator.locks` t
446
475
 
447
476
  ## Changelog
448
477
 
478
+ ### v2.0.11 (2026)
479
+
480
+ **Document streams API:**
481
+ - Update readme about available streams API
482
+
449
483
  ### v2.0.7 (2025)
450
484
 
451
485
  **High-Performance Handle Caching with `readwrite-unsafe`:**
package/dist/index.cjs CHANGED
@@ -1927,9 +1927,14 @@ var OPFSFileSystem = class _OPFSFileSystem {
1927
1927
  // --- Async Promises API ---
1928
1928
  // When Tier 1 sync kernel is available, use it for better performance (wrapped in Promise)
1929
1929
  // Otherwise fall back to async worker
1930
+ // Operations NOT implemented in the sync kernel - must use async worker
1931
+ static ASYNC_ONLY_OPS = /* @__PURE__ */ new Set([
1932
+ "releaseAllHandles",
1933
+ "releaseHandle"
1934
+ ]);
1930
1935
  // Helper: Use sync kernel if available (in worker context), otherwise async worker
1931
1936
  async fastCall(type, filePath, payload) {
1932
- if (this.syncKernelReady) {
1937
+ if (this.syncKernelReady && !_OPFSFileSystem.ASYNC_ONLY_OPS.has(type)) {
1933
1938
  if (isWorkerContext) {
1934
1939
  return Promise.resolve(this.syncCallTier1(type, filePath, payload));
1935
1940
  } else {