@ai-ecoverse/slicc-kernel 1.117.3 → 1.117.4

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
@@ -4119,6 +4119,7 @@ var READ_ATTEMPTS = 3;
4119
4119
  var MAX_LINKS5 = 40;
4120
4120
  var CHECK_MS = 1e3;
4121
4121
  var ABSENT_MS = 2;
4122
+ var GLANCE_MS = 2;
4122
4123
  var ABSENT_NAMES = 4096;
4123
4124
  var FILE_HANDLES = 4096;
4124
4125
  var STALE = /* @__PURE__ */ new Set(["NotFoundError", "TypeMismatchError"]);
@@ -4255,7 +4256,7 @@ var OpfsFs = class {
4255
4256
  changes = 0;
4256
4257
  replacing = Promise.resolve();
4257
4258
  replacements = 0;
4258
- snapshots = /* @__PURE__ */ new WeakMap();
4259
+ glances = /* @__PURE__ */ new WeakMap();
4259
4260
  found = /* @__PURE__ */ new WeakMap();
4260
4261
  checked = /* @__PURE__ */ new WeakMap();
4261
4262
  channel;
@@ -4509,7 +4510,7 @@ var OpfsFs = class {
4509
4510
  if (handle.kind !== "file") return handle;
4510
4511
  if (looked) {
4511
4512
  this.found.set(handle, performance.now());
4512
- this.snapshots.delete(handle);
4513
+ this.glances.delete(handle);
4513
4514
  }
4514
4515
  this.files.delete(path);
4515
4516
  if (this.files.size >= FILE_HANDLES)
@@ -4543,14 +4544,15 @@ var OpfsFs = class {
4543
4544
  const fresh2 = cached && performance.now() - (this.found.get(cached) ?? -CHECK_MS) < CHECK_MS;
4544
4545
  if (cached && !fresh2) this.files.delete(path);
4545
4546
  if (cached && fresh2) {
4547
+ if (this.glanced(cached)) return this.remember(path, cached);
4546
4548
  try {
4547
- this.snapshots.set(cached, await cached.getFile());
4549
+ await this.glance(cached);
4548
4550
  return this.remember(path, cached);
4549
4551
  } catch (err) {
4550
4552
  if (!STALE.has(err?.name))
4551
4553
  throw translate(err, path, "read");
4552
4554
  this.files.delete(path);
4553
- this.snapshots.delete(cached);
4555
+ this.glances.delete(cached);
4554
4556
  }
4555
4557
  }
4556
4558
  const kept = this.dirs.get(path);
@@ -4743,11 +4745,25 @@ var OpfsFs = class {
4743
4745
  if (this.dirTimes.get(path) === ms) this.dirTimes.delete(path);
4744
4746
  }
4745
4747
  }
4748
+ glanced(handle) {
4749
+ const seen = this.glances.get(handle);
4750
+ const fresh2 = seen && seen.changes === this.changes && performance.now() - seen.at < GLANCE_MS;
4751
+ return fresh2 ? seen.file : void 0;
4752
+ }
4753
+ async glance(handle) {
4754
+ const at = performance.now();
4755
+ const before = this.changes;
4756
+ const file = await handle.getFile();
4757
+ if (before === this.changes) this.glances.set(handle, { at, file, changes: before });
4758
+ else this.glances.delete(handle);
4759
+ return file;
4760
+ }
4761
+ wrote(handle) {
4762
+ this.changes++;
4763
+ this.glances.delete(handle);
4764
+ }
4746
4765
  async snapshot(handle) {
4747
- const taken = this.snapshots.get(handle);
4748
- if (!taken) return handle.getFile();
4749
- this.snapshots.delete(handle);
4750
- return taken;
4766
+ return this.glanced(handle) ?? this.glance(handle);
4751
4767
  }
4752
4768
  async statOf(path, handle, meta, touched) {
4753
4769
  const directory = handle.kind === "directory";
@@ -4882,9 +4898,11 @@ var OpfsFs = class {
4882
4898
  async pwrite(path, offset, bytes) {
4883
4899
  const [handle, , target] = await this.fileFor(path);
4884
4900
  await this.counting(target);
4901
+ this.wrote(handle);
4885
4902
  try {
4886
4903
  await this.retrying(path, () => positioned(handle, (io) => io.write(offset, bytes)), true);
4887
4904
  } finally {
4905
+ this.wrote(handle);
4888
4906
  await this.recounting(handle, target);
4889
4907
  }
4890
4908
  this.written(target);
@@ -4895,9 +4913,11 @@ var OpfsFs = class {
4895
4913
  const resolve2 = this.ranged || this.remote?.watched();
4896
4914
  const target = resolve2 || this.counted.length > 0 ? (await this.locate(path, true)).path : path;
4897
4915
  await this.counting(target);
4916
+ this.wrote(handle);
4898
4917
  try {
4899
4918
  await this.retrying(path, () => positioned(handle, (io) => io.truncate(size)), true);
4900
4919
  } finally {
4920
+ this.wrote(handle);
4901
4921
  await this.recounting(handle, target);
4902
4922
  }
4903
4923
  this.written(target);
@@ -4917,9 +4937,12 @@ var OpfsFs = class {
4917
4937
  throw translate(err, path, "write", false);
4918
4938
  }),
4919
4939
  close: async () => {
4940
+ this.wrote(handle);
4920
4941
  await writable2.close().catch((err) => {
4942
+ this.wrote(handle);
4921
4943
  throw translate(err, path, "commit", false);
4922
4944
  });
4945
+ this.wrote(handle);
4923
4946
  this.committed(target);
4924
4947
  }
4925
4948
  };
@@ -4966,6 +4989,7 @@ var OpfsFs = class {
4966
4989
  if (!existed) await this.stampNew(target, owner, false);
4967
4990
  if (!existed && content.length === 0) return;
4968
4991
  let writable2;
4992
+ this.wrote(file);
4969
4993
  try {
4970
4994
  writable2 = await file.createWritable();
4971
4995
  await writable2.write(content);
@@ -4973,6 +4997,8 @@ var OpfsFs = class {
4973
4997
  } catch (err) {
4974
4998
  await writable2?.abort().catch(() => void 0);
4975
4999
  throw translate(err, path, "commit", false);
5000
+ } finally {
5001
+ this.wrote(file);
4976
5002
  }
4977
5003
  this.committed(target);
4978
5004
  }
@@ -5226,7 +5252,7 @@ var OpfsFs = class {
5226
5252
  }
5227
5253
  async modified(path) {
5228
5254
  const handle = await this.handle(path);
5229
- return handle.kind === "file" ? (await handle.getFile()).lastModified : 0;
5255
+ return handle.kind === "file" ? (await this.snapshot(handle)).lastModified : 0;
5230
5256
  }
5231
5257
  async explicitTimes(path) {
5232
5258
  const timed2 = [];
@@ -6656,7 +6682,7 @@ function satisfies(version, range2) {
6656
6682
  }
6657
6683
 
6658
6684
  // src/version.ts
6659
- var KERNEL_VERSION = true ? "1.117.3" : "0.0.0-dev";
6685
+ var KERNEL_VERSION = true ? "1.117.4" : "0.0.0-dev";
6660
6686
  var OS_RELEASE = "6.0.0-slicc";
6661
6687
  function procVersion() {
6662
6688
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC