@componentor/fs 3.0.3 → 3.0.4
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 +42 -3
- package/dist/index.js +1547 -5
- 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/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
|
@@ -368,6 +368,33 @@ constants.O_TRUNC // 512
|
|
|
368
368
|
constants.O_APPEND // 1024
|
|
369
369
|
```
|
|
370
370
|
|
|
371
|
+
## Maintenance Helpers
|
|
372
|
+
|
|
373
|
+
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.
|
|
374
|
+
|
|
375
|
+
```typescript
|
|
376
|
+
import { unpackToOPFS, loadFromOPFS, repairVFS } from '@componentor/fs';
|
|
377
|
+
|
|
378
|
+
// Export VFS contents to real OPFS files (clears existing OPFS files first)
|
|
379
|
+
const { files, directories } = await unpackToOPFS('/my-app');
|
|
380
|
+
|
|
381
|
+
// Rebuild VFS from real OPFS files (deletes .vfs.bin, creates fresh VFS)
|
|
382
|
+
const { files, directories } = await loadFromOPFS('/my-app');
|
|
383
|
+
|
|
384
|
+
// Attempt to recover files from a corrupt VFS binary
|
|
385
|
+
const { recovered, lost, entries } = await repairVFS('/my-app');
|
|
386
|
+
console.log(`Recovered ${recovered} entries, lost ${lost}`);
|
|
387
|
+
for (const entry of entries) {
|
|
388
|
+
console.log(` ${entry.type} ${entry.path} (${entry.size} bytes)`);
|
|
389
|
+
}
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
| Function | Description |
|
|
393
|
+
|----------|-------------|
|
|
394
|
+
| `unpackToOPFS(root?)` | Read all files from VFS, write to real OPFS paths |
|
|
395
|
+
| `loadFromOPFS(root?)` | Read all OPFS files, create fresh VFS with their contents |
|
|
396
|
+
| `repairVFS(root?)` | Scan corrupt `.vfs.bin` for recoverable inodes, rebuild fresh VFS |
|
|
397
|
+
|
|
371
398
|
## isomorphic-git Integration
|
|
372
399
|
|
|
373
400
|
```typescript
|
|
@@ -419,8 +446,8 @@ await git.commit({
|
|
|
419
446
|
│ ┌────────────────────────────────────────────────────────────┐ │
|
|
420
447
|
│ │ VFS Engine │ │
|
|
421
448
|
│ │ ┌──────────────────┐ ┌─────────────┐ ┌──────────────┐ │ │
|
|
422
|
-
│ │ │ VFS Binary File
|
|
423
|
-
│ │ │ (.vfs.bin OPFS)
|
|
449
|
+
│ │ │ VFS Binary File │ │ Inode/Path │ │ Block Data │ │ │
|
|
450
|
+
│ │ │ (.vfs.bin OPFS) │ │ Table │ │ Region │ │ │
|
|
424
451
|
│ │ └──────────────────┘ └─────────────┘ └──────────────┘ │ │
|
|
425
452
|
│ └────────────────────────────────────────────────────────────┘ │
|
|
426
453
|
│ │ │
|
|
@@ -481,6 +508,18 @@ Make sure `opfsSync` is enabled (it's `true` by default). Files are mirrored to
|
|
|
481
508
|
|
|
482
509
|
## Changelog
|
|
483
510
|
|
|
511
|
+
### v3.0.4 (2026)
|
|
512
|
+
|
|
513
|
+
**Features:**
|
|
514
|
+
- Add `unpackToOPFS(root?)` — export all VFS contents to real OPFS files
|
|
515
|
+
- Add `loadFromOPFS(root?)` — rebuild VFS from real OPFS files (deletes and recreates `.vfs.bin`)
|
|
516
|
+
- Add `repairVFS(root?)` — scan corrupt VFS binary for recoverable inodes and rebuild a clean VFS
|
|
517
|
+
- Add `VFSEngine.exportAll()` for extracting all files/dirs/symlinks with their data
|
|
518
|
+
|
|
519
|
+
**Bug Fixes:**
|
|
520
|
+
- VFS corruption detection on init — validates magic, version, block size, inode count, section offsets, file size, and root directory existence
|
|
521
|
+
- Release sync access handle on init failure (previously leaked, blocking re-acquisition)
|
|
522
|
+
|
|
484
523
|
### v3.0.3 (2026)
|
|
485
524
|
|
|
486
525
|
**Features:**
|
|
@@ -548,7 +587,7 @@ git clone https://github.com/componentor/fs
|
|
|
548
587
|
cd fs
|
|
549
588
|
npm install
|
|
550
589
|
npm run build # Build the library
|
|
551
|
-
npm test # Run unit tests (
|
|
590
|
+
npm test # Run unit tests (97 tests)
|
|
552
591
|
npm run benchmark:open # Run benchmarks in browser
|
|
553
592
|
```
|
|
554
593
|
|