@componentor/fs 3.0.1 → 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.
@@ -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) return 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.resolvePath(resolved);
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:
@@ -1871,6 +1878,18 @@ function notifyOPFSSync(op, path, newPath) {
1871
1878
  }
1872
1879
  break;
1873
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
+ }
1890
+ }
1891
+ break;
1892
+ }
1874
1893
  case OP.UNLINK:
1875
1894
  case OP.RMDIR:
1876
1895
  opfsSyncPort.postMessage({ op: "delete", path, ts });