@componentor/fs 3.0.47 → 3.0.49

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/dist/index.js CHANGED
@@ -2924,14 +2924,7 @@ var VFSFileSystem = class {
2924
2924
  }
2925
2925
  };
2926
2926
  mc.port1.start();
2927
- const oldPort = this.brokerControlPort;
2928
2927
  this.brokerControlPort = mc.port1;
2929
- if (oldPort) {
2930
- try {
2931
- oldPort.close();
2932
- } catch {
2933
- }
2934
- }
2935
2928
  }).catch((err) => {
2936
2929
  console.warn("[VFS] SW broker unavailable, single-tab only:", err.message);
2937
2930
  });
@@ -4961,6 +4954,7 @@ var VFSEngine = class {
4961
4954
  this.writeInode(existingIdx, inode);
4962
4955
  tInode = this.debug ? performance.now() : 0;
4963
4956
  } else {
4957
+ if (this.isImplicitDirectory(path)) return { status: CODE_TO_STATUS.EISDIR };
4964
4958
  const mode = DEFAULT_FILE_MODE & ~(this.umask & 511);
4965
4959
  this.createInode(path, INODE_TYPE.FILE, mode, data.byteLength, data);
4966
4960
  tAlloc = this.debug ? performance.now() : 0;
@@ -5250,15 +5244,33 @@ var VFSEngine = class {
5250
5244
  newPath = this.normalizePath(newPath);
5251
5245
  const idx = this.pathIndex.get(oldPath);
5252
5246
  if (idx === void 0) return { status: CODE_TO_STATUS.ENOENT };
5247
+ if (oldPath === newPath) return { status: 0 };
5253
5248
  const parentStatus = this.ensureParent(newPath);
5254
5249
  if (parentStatus !== 0) return { status: parentStatus };
5255
5250
  const existingIdx = this.pathIndex.get(newPath);
5256
- if (existingIdx !== void 0) {
5257
- const existingInode = this.readInode(existingIdx);
5258
- this.freeBlockRange(existingInode.firstBlock, existingInode.blockCount);
5259
- existingInode.type = INODE_TYPE.FREE;
5260
- this.writeInode(existingIdx, existingInode);
5261
- this.pathIndex.delete(newPath);
5251
+ const targetIsImplicitDir = existingIdx === void 0 && this.isImplicitDirectory(newPath);
5252
+ if (existingIdx !== void 0 || targetIsImplicitDir) {
5253
+ let cleanDescendants = targetIsImplicitDir;
5254
+ if (existingIdx !== void 0) {
5255
+ const existingInode = this.readInode(existingIdx);
5256
+ cleanDescendants = existingInode.type === INODE_TYPE.DIRECTORY;
5257
+ this.freeBlockRange(existingInode.firstBlock, existingInode.blockCount);
5258
+ existingInode.type = INODE_TYPE.FREE;
5259
+ this.writeInode(existingIdx, existingInode);
5260
+ this.pathIndex.delete(newPath);
5261
+ if (existingIdx < this.freeInodeHint) this.freeInodeHint = existingIdx;
5262
+ }
5263
+ if (cleanDescendants) {
5264
+ for (const desc of this.getAllDescendants(newPath)) {
5265
+ const descIdx = this.pathIndex.get(desc);
5266
+ const descInode = this.readInode(descIdx);
5267
+ this.freeBlockRange(descInode.firstBlock, descInode.blockCount);
5268
+ descInode.type = INODE_TYPE.FREE;
5269
+ this.writeInode(descIdx, descInode);
5270
+ this.pathIndex.delete(desc);
5271
+ if (descIdx < this.freeInodeHint) this.freeInodeHint = descIdx;
5272
+ }
5273
+ }
5262
5274
  }
5263
5275
  const inode = this.readInode(idx);
5264
5276
  const { offset: pathOff, length: pathLen } = this.appendPath(newPath);
@@ -5362,7 +5374,7 @@ var VFSEngine = class {
5362
5374
  if (srcIdx === void 0) return { status: CODE_TO_STATUS.ENOENT };
5363
5375
  const srcInode = this.readInode(srcIdx);
5364
5376
  if (srcInode.type === INODE_TYPE.DIRECTORY) return { status: CODE_TO_STATUS.EISDIR };
5365
- if (flags & 1 && this.pathIndex.has(destPath)) {
5377
+ if (flags & 1 && (this.pathIndex.has(destPath) || this.isImplicitDirectory(destPath))) {
5366
5378
  return { status: CODE_TO_STATUS.EEXIST };
5367
5379
  }
5368
5380
  if (srcPath === destPath) return { status: 0 };
@@ -5471,7 +5483,9 @@ var VFSEngine = class {
5471
5483
  // ---- SYMLINK ----
5472
5484
  symlink(target, linkPath) {
5473
5485
  linkPath = this.normalizePath(linkPath);
5474
- if (this.pathIndex.has(linkPath)) return { status: CODE_TO_STATUS.EEXIST };
5486
+ if (this.pathIndex.has(linkPath) || this.isImplicitDirectory(linkPath)) {
5487
+ return { status: CODE_TO_STATUS.EEXIST };
5488
+ }
5475
5489
  const parentStatus = this.ensureParent(linkPath);
5476
5490
  if (parentStatus !== 0) return { status: parentStatus };
5477
5491
  const targetBytes = encoder10.encode(target);
@@ -5497,7 +5511,9 @@ var VFSEngine = class {
5497
5511
  if (srcIdx === void 0) return { status: CODE_TO_STATUS.ENOENT };
5498
5512
  const srcInode = this.readInode(srcIdx);
5499
5513
  if (srcInode.type === INODE_TYPE.DIRECTORY) return { status: CODE_TO_STATUS.EPERM };
5500
- if (this.pathIndex.has(newPath)) return { status: CODE_TO_STATUS.EEXIST };
5514
+ if (this.pathIndex.has(newPath) || this.isImplicitDirectory(newPath)) {
5515
+ return { status: CODE_TO_STATUS.EEXIST };
5516
+ }
5501
5517
  const result = this.copy(existingPath, newPath);
5502
5518
  if (result.status !== 0) return result;
5503
5519
  srcInode.nlink++;