@componentor/fs 3.0.3 → 3.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -3
- package/dist/index.js +1559 -11
- package/dist/index.js.map +1 -1
- package/dist/workers/server.worker.js +88 -13
- package/dist/workers/server.worker.js.map +1 -1
- package/dist/workers/service.worker.js +1 -2
- package/dist/workers/service.worker.js.map +1 -1
- package/dist/workers/sync-relay.worker.js +103 -20
- package/dist/workers/sync-relay.worker.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -82,6 +82,7 @@ const fs = new VFSFileSystem({
|
|
|
82
82
|
strictPermissions: false, // Enforce Unix permissions (default: false)
|
|
83
83
|
sabSize: 4194304, // SharedArrayBuffer size in bytes (default: 4MB)
|
|
84
84
|
debug: false, // Enable debug logging (default: false)
|
|
85
|
+
swScope: undefined, // Custom service worker scope (default: auto-scoped per root)
|
|
85
86
|
});
|
|
86
87
|
```
|
|
87
88
|
|
|
@@ -368,6 +369,33 @@ constants.O_TRUNC // 512
|
|
|
368
369
|
constants.O_APPEND // 1024
|
|
369
370
|
```
|
|
370
371
|
|
|
372
|
+
## Maintenance Helpers
|
|
373
|
+
|
|
374
|
+
Standalone utilities for VFS maintenance, recovery, and migration. Must be called from a Worker context (sync access handle requirement). Close any running `VFSFileSystem` instance first.
|
|
375
|
+
|
|
376
|
+
```typescript
|
|
377
|
+
import { unpackToOPFS, loadFromOPFS, repairVFS } from '@componentor/fs';
|
|
378
|
+
|
|
379
|
+
// Export VFS contents to real OPFS files (clears existing OPFS files first)
|
|
380
|
+
const { files, directories } = await unpackToOPFS('/my-app');
|
|
381
|
+
|
|
382
|
+
// Rebuild VFS from real OPFS files (deletes .vfs.bin, creates fresh VFS)
|
|
383
|
+
const { files, directories } = await loadFromOPFS('/my-app');
|
|
384
|
+
|
|
385
|
+
// Attempt to recover files from a corrupt VFS binary
|
|
386
|
+
const { recovered, lost, entries } = await repairVFS('/my-app');
|
|
387
|
+
console.log(`Recovered ${recovered} entries, lost ${lost}`);
|
|
388
|
+
for (const entry of entries) {
|
|
389
|
+
console.log(` ${entry.type} ${entry.path} (${entry.size} bytes)`);
|
|
390
|
+
}
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
| Function | Description |
|
|
394
|
+
|----------|-------------|
|
|
395
|
+
| `unpackToOPFS(root?)` | Read all files from VFS, write to real OPFS paths |
|
|
396
|
+
| `loadFromOPFS(root?)` | Read all OPFS files, create fresh VFS with their contents |
|
|
397
|
+
| `repairVFS(root?)` | Scan corrupt `.vfs.bin` for recoverable inodes, rebuild fresh VFS |
|
|
398
|
+
|
|
371
399
|
## isomorphic-git Integration
|
|
372
400
|
|
|
373
401
|
```typescript
|
|
@@ -419,8 +447,8 @@ await git.commit({
|
|
|
419
447
|
│ ┌────────────────────────────────────────────────────────────┐ │
|
|
420
448
|
│ │ VFS Engine │ │
|
|
421
449
|
│ │ ┌──────────────────┐ ┌─────────────┐ ┌──────────────┐ │ │
|
|
422
|
-
│ │ │ VFS Binary File
|
|
423
|
-
│ │ │ (.vfs.bin OPFS)
|
|
450
|
+
│ │ │ VFS Binary File │ │ Inode/Path │ │ Block Data │ │ │
|
|
451
|
+
│ │ │ (.vfs.bin OPFS) │ │ Table │ │ Region │ │ │
|
|
424
452
|
│ │ └──────────────────┘ └─────────────┘ └──────────────┘ │ │
|
|
425
453
|
│ └────────────────────────────────────────────────────────────┘ │
|
|
426
454
|
│ │ │
|
|
@@ -481,6 +509,26 @@ Make sure `opfsSync` is enabled (it's `true` by default). Files are mirrored to
|
|
|
481
509
|
|
|
482
510
|
## Changelog
|
|
483
511
|
|
|
512
|
+
### v3.0.5 (2026)
|
|
513
|
+
|
|
514
|
+
**Fixes:**
|
|
515
|
+
- Scope the internal service worker by default so it won't collide with the host application's own service worker
|
|
516
|
+
- Remove unnecessary `clients.claim()` from the service worker — it only acts as a MessagePort broker and never needs to control pages
|
|
517
|
+
- Namespace leader lock, BroadcastChannel, and SW scope by `root` so multiple `VFSFileSystem` instances with different roots don't collide
|
|
518
|
+
- Add `swScope` config option for custom service worker scope override
|
|
519
|
+
|
|
520
|
+
### v3.0.4 (2026)
|
|
521
|
+
|
|
522
|
+
**Features:**
|
|
523
|
+
- Add `unpackToOPFS(root?)` — export all VFS contents to real OPFS files
|
|
524
|
+
- Add `loadFromOPFS(root?)` — rebuild VFS from real OPFS files (deletes and recreates `.vfs.bin`)
|
|
525
|
+
- Add `repairVFS(root?)` — scan corrupt VFS binary for recoverable inodes and rebuild a clean VFS
|
|
526
|
+
- Add `VFSEngine.exportAll()` for extracting all files/dirs/symlinks with their data
|
|
527
|
+
|
|
528
|
+
**Bug Fixes:**
|
|
529
|
+
- VFS corruption detection on init — validates magic, version, block size, inode count, section offsets, file size, and root directory existence
|
|
530
|
+
- Release sync access handle on init failure (previously leaked, blocking re-acquisition)
|
|
531
|
+
|
|
484
532
|
### v3.0.3 (2026)
|
|
485
533
|
|
|
486
534
|
**Features:**
|
|
@@ -548,7 +596,7 @@ git clone https://github.com/componentor/fs
|
|
|
548
596
|
cd fs
|
|
549
597
|
npm install
|
|
550
598
|
npm run build # Build the library
|
|
551
|
-
npm test # Run unit tests (
|
|
599
|
+
npm test # Run unit tests (97 tests)
|
|
552
600
|
npm run benchmark:open # Run benchmarks in browser
|
|
553
601
|
```
|
|
554
602
|
|