@ai-ecoverse/slicc-kernel 1.110.0 → 1.110.1

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.
@@ -5204,7 +5204,7 @@ var KERNEL_VERSION, OS_RELEASE;
5204
5204
  var init_version = __esm({
5205
5205
  "src/version.ts"() {
5206
5206
  "use strict";
5207
- KERNEL_VERSION = true ? "1.110.0" : "0.0.0-dev";
5207
+ KERNEL_VERSION = true ? "1.110.1" : "0.0.0-dev";
5208
5208
  OS_RELEASE = "6.0.0-slicc";
5209
5209
  }
5210
5210
  });
package/dist/node.js CHANGED
@@ -4083,6 +4083,8 @@ var S_ISGID3 = 1024;
4083
4083
  var READ_ATTEMPTS = 3;
4084
4084
  var MAX_LINKS5 = 40;
4085
4085
  var CHECK_MS = 1e3;
4086
+ var FILE_HANDLES = 4096;
4087
+ var STALE = /* @__PURE__ */ new Set(["NotFoundError", "TypeMismatchError"]);
4086
4088
  var EXECUTABLE = /\/node_modules\/(?:@[^/]+\/)?[^/]+\/bin\//;
4087
4089
  var ERRNO_BY_DOM_ERROR = {
4088
4090
  NotFoundError: "ENOENT",
@@ -4204,6 +4206,9 @@ var OpfsFs = class {
4204
4206
  root;
4205
4207
  meta;
4206
4208
  dirs = new PathMap();
4209
+ files = new PathMap();
4210
+ snapshots = /* @__PURE__ */ new WeakMap();
4211
+ found = /* @__PURE__ */ new WeakMap();
4207
4212
  checked = /* @__PURE__ */ new WeakMap();
4208
4213
  channel;
4209
4214
  remote;
@@ -4441,6 +4446,19 @@ var OpfsFs = class {
4441
4446
  }
4442
4447
  forget(path) {
4443
4448
  this.dirs.deleteTree(path);
4449
+ this.files.deleteTree(path);
4450
+ }
4451
+ remember(path, handle, looked = false) {
4452
+ if (handle.kind !== "file") return handle;
4453
+ if (looked) {
4454
+ this.found.set(handle, performance.now());
4455
+ this.snapshots.delete(handle);
4456
+ }
4457
+ this.files.delete(path);
4458
+ if (this.files.size >= FILE_HANDLES)
4459
+ this.files.delete(this.files.keys().next().value);
4460
+ this.files.set(path, handle);
4461
+ return handle;
4444
4462
  }
4445
4463
  async inDir(path, op) {
4446
4464
  const dir = await this.dir(path);
@@ -4464,16 +4482,30 @@ var OpfsFs = class {
4464
4482
  }
4465
4483
  async handle(path) {
4466
4484
  if (split(path).length === 0) return this.root;
4485
+ const cached = this.files.get(path);
4486
+ const fresh2 = cached && performance.now() - (this.found.get(cached) ?? -CHECK_MS) < CHECK_MS;
4487
+ if (cached && !fresh2) this.files.delete(path);
4488
+ if (cached && fresh2) {
4489
+ try {
4490
+ this.snapshots.set(cached, await cached.getFile());
4491
+ return this.remember(path, cached);
4492
+ } catch (err) {
4493
+ if (!STALE.has(err?.name))
4494
+ throw translate(err, path, "read");
4495
+ this.files.delete(path);
4496
+ this.snapshots.delete(cached);
4497
+ }
4498
+ }
4467
4499
  const [dir, name2] = await this.parent(path);
4468
4500
  const known = this.dirs.has(path);
4469
4501
  return this.inDir(dir, async (parent) => {
4470
4502
  const [first, second] = known ? ["directory", "file"] : ["file", "directory"];
4471
4503
  try {
4472
- return await this.child(parent, name2, first);
4504
+ return this.remember(path, await this.child(parent, name2, first), true);
4473
4505
  } catch (err) {
4474
4506
  if (err?.name !== "TypeMismatchError") throw err;
4475
4507
  }
4476
- return this.child(parent, name2, second);
4508
+ return this.remember(path, await this.child(parent, name2, second), true);
4477
4509
  }).catch((err) => {
4478
4510
  throw translate(err, path);
4479
4511
  });
@@ -4616,9 +4648,15 @@ var OpfsFs = class {
4616
4648
  if (this.dirTimes.get(path) === ms) this.dirTimes.delete(path);
4617
4649
  }
4618
4650
  }
4651
+ async snapshot(handle) {
4652
+ const taken = this.snapshots.get(handle);
4653
+ if (!taken) return handle.getFile();
4654
+ this.snapshots.delete(handle);
4655
+ return taken;
4656
+ }
4619
4657
  async statOf(path, handle, meta, touched) {
4620
4658
  const directory = handle.kind === "directory";
4621
- const file = directory ? void 0 : await handle.getFile();
4659
+ const file = directory ? void 0 : await this.snapshot(handle);
4622
4660
  const modified = file?.lastModified ?? 0;
4623
4661
  const kept = meta?.mtimeMs !== void 0 && meta.mtimeFor === modified ? meta.mtimeMs : modified;
4624
4662
  const mtime = touched ?? kept;
@@ -6435,7 +6473,7 @@ function satisfies(version, range2) {
6435
6473
  }
6436
6474
 
6437
6475
  // src/version.ts
6438
- var KERNEL_VERSION = true ? "1.110.0" : "0.0.0-dev";
6476
+ var KERNEL_VERSION = true ? "1.110.1" : "0.0.0-dev";
6439
6477
  var OS_RELEASE = "6.0.0-slicc";
6440
6478
  function procVersion() {
6441
6479
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -24335,6 +24373,7 @@ var MemoryFile = class {
24335
24373
  this.parent = parent;
24336
24374
  }
24337
24375
  async getFile() {
24376
+ if (this.parent.removed || this.parent.children.get(this.name) !== this) fail2("NotFoundError");
24338
24377
  return new File(this.data.blobs, this.name, { lastModified: this.lastModified });
24339
24378
  }
24340
24379
  async createWritable({ keepExistingData = false } = {}) {