@ai-ecoverse/slicc-kernel 1.61.0 → 1.61.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/dist/node.js CHANGED
@@ -1349,8 +1349,8 @@ function openWebSocket(Socket, request, withHeaders) {
1349
1349
  reject(error);
1350
1350
  };
1351
1351
  const abort = () => {
1352
- socket.close(1e3, "aborted");
1353
1352
  fail3(signal.reason);
1353
+ socket.close(1e3, "aborted");
1354
1354
  };
1355
1355
  signal.addEventListener("abort", abort, { once: true });
1356
1356
  socket.addEventListener("open", () => {
@@ -1374,12 +1374,12 @@ function openWebSocket(Socket, request, withHeaders) {
1374
1374
  });
1375
1375
  socket.addEventListener("error", () => {
1376
1376
  if (open || settled) return;
1377
+ fail3(unopened(url, 1006));
1378
+ queue.end({ code: 1006, reason: "" });
1377
1379
  try {
1378
1380
  socket.close();
1379
1381
  } catch {
1380
1382
  }
1381
- queue.end({ code: 1006, reason: "" });
1382
- fail3(unopened(url, 1006));
1383
1383
  });
1384
1384
  socket.addEventListener("close", (event) => {
1385
1385
  queue.end({ code: event.code, reason: event.reason });
@@ -3542,7 +3542,7 @@ var UnlinkedKeeper = class {
3542
3542
  async linkedName(hidden) {
3543
3543
  if (!mayLink(this.fs, hidden)) return;
3544
3544
  const st = await this.fs.lstat(hidden).catch(() => void 0);
3545
- if (!st || (st.nlink ?? 1) < 2) return;
3545
+ if (st?.nlink === void 0) return;
3546
3546
  const id2 = `${st.dev ?? 0}:${st.ino}`;
3547
3547
  this.linked.set(hidden, id2);
3548
3548
  this.links.set(id2, (this.links.get(id2) ?? 0) + 1);
@@ -6370,6 +6370,12 @@ async function keptOr(entry, path, handle) {
6370
6370
  const kept = entry.unlinked?.(path);
6371
6371
  return kept && !await entry.fs.exists(path) ? kept.hidden : path;
6372
6372
  }
6373
+ async function keptStat(entry, req) {
6374
+ const hidden = entry.keptFor?.(req.handle ?? -1)?.hidden;
6375
+ if (hidden === void 0)
6376
+ return { ok: false, errno: "ENOENT", message: "the handle keeps no file" };
6377
+ return json2(statJson(await entry.fs.stat(hidden)));
6378
+ }
6373
6379
  async function owned(entry, own, req, path, target) {
6374
6380
  const source = target === path ? void 0 : path;
6375
6381
  if (UNLINKING_OPS.has(req.op) && await linkedElsewhere(entry.fs, target, source)) {
@@ -6384,6 +6390,7 @@ async function dispatchSyncFs(req) {
6384
6390
  try {
6385
6391
  const path = fs.resolvePath(cwd, req.path);
6386
6392
  if (req.op === "kept") return json2(entry.keptFor?.(req.handle ?? -1) !== void 0);
6393
+ if (req.op === "stat" && req.handle !== void 0) return await keptStat(entry, req);
6387
6394
  if (req.op === "statfs") return json2(await entry.statfs?.(path) ?? await storageUsage());
6388
6395
  if (req.op === "hold") {
6389
6396
  const [on, open] = [((req.mode ?? 0) & 1) === 1, ((req.mode ?? 0) & 2) === 2];
@@ -9924,6 +9931,12 @@ var VfsNodes = class {
9924
9931
  async identify(path) {
9925
9932
  return this.byPath.has(path) || !mayLink(this.fs, path) ? void 0 : this.identity(path);
9926
9933
  }
9934
+ async flushLinked(path) {
9935
+ if (this.byId.size === 0 || !mayLink(this.fs, path)) return;
9936
+ const id2 = await this.identity(path);
9937
+ const node = id2 === void 0 ? void 0 : this.byId.get(id2);
9938
+ if (node) await node.serial(() => node.flush());
9939
+ }
9927
9940
  async linked(from, to) {
9928
9941
  const node = this.byPath.get(from);
9929
9942
  if (!node || node.orphaned) return;
@@ -10128,6 +10141,7 @@ function keepingOpen(fs, nodes) {
10128
10141
  const source = fs.resolvePath("/", from);
10129
10142
  const at = await (follow2 ? nodes.targetKey(source) : nodes.entryKey(source));
10130
10143
  await nodes.flush(at);
10144
+ await nodes.flushLinked(at);
10131
10145
  const key = await nodes.entryKey(fs.resolvePath("/", to));
10132
10146
  await nodes.onEntry(key, () => fs.link(from, to, follow2));
10133
10147
  await nodes.linked(at, key);