@componentor/fs 3.0.0 → 3.0.2
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 +15 -0
- package/dist/workers/opfs-sync.worker.js +2 -2
- package/dist/workers/opfs-sync.worker.js.map +1 -1
- package/dist/workers/server.worker.js +7 -4
- package/dist/workers/server.worker.js.map +1 -1
- package/dist/workers/sync-relay.worker.js +30 -7
- package/dist/workers/sync-relay.worker.js.map +1 -1
- package/package.json +1 -1
|
@@ -456,7 +456,9 @@ var VFSEngine = class {
|
|
|
456
456
|
resolvePath(path, depth = 0) {
|
|
457
457
|
if (depth > MAX_SYMLINK_DEPTH) return void 0;
|
|
458
458
|
const idx = this.pathIndex.get(path);
|
|
459
|
-
if (idx === void 0)
|
|
459
|
+
if (idx === void 0) {
|
|
460
|
+
return this.resolvePathComponents(path, true, depth);
|
|
461
|
+
}
|
|
460
462
|
const inode = this.readInode(idx);
|
|
461
463
|
if (inode.type === INODE_TYPE.SYMLINK) {
|
|
462
464
|
const target = decoder.decode(this.readData(inode.firstBlock, inode.blockCount, inode.size));
|
|
@@ -466,7 +468,8 @@ var VFSEngine = class {
|
|
|
466
468
|
return idx;
|
|
467
469
|
}
|
|
468
470
|
/** Resolve symlinks in intermediate path components */
|
|
469
|
-
resolvePathComponents(path, followLast = true) {
|
|
471
|
+
resolvePathComponents(path, followLast = true, depth = 0) {
|
|
472
|
+
if (depth > MAX_SYMLINK_DEPTH) return void 0;
|
|
470
473
|
const parts = path.split("/").filter(Boolean);
|
|
471
474
|
let current = "/";
|
|
472
475
|
for (let i = 0; i < parts.length; i++) {
|
|
@@ -479,11 +482,11 @@ var VFSEngine = class {
|
|
|
479
482
|
const target = decoder.decode(this.readData(inode.firstBlock, inode.blockCount, inode.size));
|
|
480
483
|
const resolved = target.startsWith("/") ? target : this.resolveRelative(current, target);
|
|
481
484
|
if (isLast) {
|
|
482
|
-
return this.
|
|
485
|
+
return this.resolvePathComponents(resolved, true, depth + 1);
|
|
483
486
|
}
|
|
484
487
|
const remaining = parts.slice(i + 1).join("/");
|
|
485
488
|
const newPath = resolved + (remaining ? "/" + remaining : "");
|
|
486
|
-
return this.resolvePathComponents(newPath, followLast);
|
|
489
|
+
return this.resolvePathComponents(newPath, followLast, depth + 1);
|
|
487
490
|
}
|
|
488
491
|
}
|
|
489
492
|
return this.pathIndex.get(current);
|
|
@@ -1556,6 +1559,10 @@ function handleRequest(reqTabId, buffer) {
|
|
|
1556
1559
|
case OP.SYMLINK: {
|
|
1557
1560
|
const target = data ? new TextDecoder().decode(data) : "";
|
|
1558
1561
|
result = engine.symlink(target, path);
|
|
1562
|
+
if (opfsSyncEnabled && result.status === 0) {
|
|
1563
|
+
syncOp = op;
|
|
1564
|
+
syncPath = path;
|
|
1565
|
+
}
|
|
1559
1566
|
break;
|
|
1560
1567
|
}
|
|
1561
1568
|
case OP.READLINK:
|
|
@@ -1861,9 +1868,25 @@ function notifyOPFSSync(op, path, newPath) {
|
|
|
1861
1868
|
case OP.COPY:
|
|
1862
1869
|
case OP.LINK: {
|
|
1863
1870
|
const result = engine.read(path);
|
|
1864
|
-
if (result.status === 0
|
|
1865
|
-
|
|
1866
|
-
|
|
1871
|
+
if (result.status === 0) {
|
|
1872
|
+
if (result.data && result.data.byteLength > 0) {
|
|
1873
|
+
const buf = result.data.buffer.byteLength === result.data.byteLength ? result.data.buffer : result.data.slice().buffer;
|
|
1874
|
+
opfsSyncPort.postMessage({ op: "write", path, data: buf, ts }, [buf]);
|
|
1875
|
+
} else {
|
|
1876
|
+
opfsSyncPort.postMessage({ op: "write", path, data: new ArrayBuffer(0), ts });
|
|
1877
|
+
}
|
|
1878
|
+
}
|
|
1879
|
+
break;
|
|
1880
|
+
}
|
|
1881
|
+
case OP.SYMLINK: {
|
|
1882
|
+
const result = engine.read(path);
|
|
1883
|
+
if (result.status === 0) {
|
|
1884
|
+
if (result.data && result.data.byteLength > 0) {
|
|
1885
|
+
const buf = result.data.buffer.byteLength === result.data.byteLength ? result.data.buffer : result.data.slice().buffer;
|
|
1886
|
+
opfsSyncPort.postMessage({ op: "write", path, data: buf, ts }, [buf]);
|
|
1887
|
+
} else {
|
|
1888
|
+
opfsSyncPort.postMessage({ op: "write", path, data: new ArrayBuffer(0), ts });
|
|
1889
|
+
}
|
|
1867
1890
|
}
|
|
1868
1891
|
break;
|
|
1869
1892
|
}
|