@ai-ecoverse/slicc-kernel 1.134.0 → 1.134.3

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
@@ -5635,14 +5635,14 @@ var OpfsFs = class {
5635
5635
  const staged = resolvePath(parent.path, staging);
5636
5636
  const place = async () => {
5637
5637
  this.forget(destination);
5638
- const timed2 = await this.explicitTimes(source.path);
5638
+ const copies = /* @__PURE__ */ new Map();
5639
5639
  const root = { ino: inodeOf(source.path), ...moving };
5640
5640
  const owned4 = lock ? { lock } : {};
5641
5641
  const first = copying ? await this.intend({ from: source.path, to: staged, root, ...owned4 }) : void 0;
5642
5642
  const second = copying && swap ? await this.intend({ from: staged, to: destination, replace: true, root, ...owned4 }) : void 0;
5643
5643
  const moved2 = await this.replacingTarget(
5644
5644
  targetStat !== null,
5645
- () => this.place(source.handle, dir, staging)
5645
+ () => this.place(source.handle, dir, staging, copies)
5646
5646
  ).catch(async (err) => {
5647
5647
  if (first) await this.rollBack(staged, source.path, [first, second]);
5648
5648
  throw err;
@@ -5656,15 +5656,13 @@ var OpfsFs = class {
5656
5656
  await this.meta.update(source.path, () => left);
5657
5657
  }
5658
5658
  if (first) await this.meta.update(first, () => void 0);
5659
- let copied = !moved2;
5660
5659
  if (swap) {
5661
5660
  const hidden = await dir.getDirectoryHandle(staging);
5662
- const placed = await this.place(hidden, dir, name2);
5661
+ const placed = await this.place(hidden, dir, name2, copies);
5663
5662
  if (!placed) await dir.removeEntry(staging, { recursive: true });
5664
- copied ||= !placed;
5665
5663
  }
5666
5664
  if (second) await this.meta.update(second, () => void 0);
5667
- if (copied) await this.restamp(destination, timed2);
5665
+ await this.restamp(destination, copies);
5668
5666
  this.changed(source.path, destination);
5669
5667
  this.touch(Date.now(), parentOf4(source.path), parent.path);
5670
5668
  };
@@ -5827,15 +5825,21 @@ var OpfsFs = class {
5827
5825
  let writable2;
5828
5826
  let handle;
5829
5827
  try {
5830
- const [made2, existed, at] = await this.fileFor(destination);
5831
- handle = made2;
5832
- target = at;
5833
- if (!existed && !created4) {
5834
- created4 = true;
5835
- await this.stampNew(target, options.owner, false);
5828
+ const kept = created4 ? this.files.get(destination) : void 0;
5829
+ if (kept) {
5830
+ if (options.owner?.fifo || options.owner?.socket) throw fsError("ENXIO", to);
5831
+ handle = kept;
5832
+ } else {
5833
+ const [made2, existed, at] = await this.fileFor(destination);
5834
+ handle = made2;
5835
+ target = at;
5836
+ if (!existed && !created4) {
5837
+ created4 = true;
5838
+ await this.stampNew(target, options.owner, false);
5839
+ }
5840
+ const [entry] = await this.meta.get([target]);
5841
+ if (entry?.fifo || entry?.socket) throw fsError("ENXIO", to);
5836
5842
  }
5837
- const [entry] = await this.meta.get([target]);
5838
- if (entry?.fifo || entry?.socket) throw fsError("ENXIO", to);
5839
5843
  this.wrote(handle);
5840
5844
  writable2 = await handle.createWritable();
5841
5845
  await writable2.write(file);
@@ -5875,22 +5879,17 @@ var OpfsFs = class {
5875
5879
  const handle = await this.handle(path);
5876
5880
  return handle.kind === "file" ? (await this.snapshot(handle)).lastModified : 0;
5877
5881
  }
5878
- async explicitTimes(path) {
5879
- const timed2 = [];
5880
- for (const entry of await this.meta.under(path)) {
5881
- if (entry.mtimeFor === void 0 || entry.link !== void 0) continue;
5882
- const current = await this.modified(entry.path).catch(() => void 0);
5883
- if (current === entry.mtimeFor) timed2.push(entry.path.slice(path.length));
5884
- }
5885
- return timed2;
5886
- }
5887
- async restamp(path, timed2) {
5888
- for (const rest2 of timed2) {
5889
- const mtimeFor = await this.modified(path + rest2);
5882
+ async restamp(path, copies) {
5883
+ if (copies.size === 0) return;
5884
+ const copied = [...copies];
5885
+ const entries = await this.meta.get(copied.map(([rest2]) => path + rest2));
5886
+ for (const [i, [rest2, { before, made: made2 }]] of copied.entries()) {
5887
+ if (entries[i]?.mtimeFor !== before) continue;
5888
+ const mtimeFor = (await this.io(made2.getFile())).lastModified;
5890
5889
  await this.meta.update(path + rest2, (entry) => entry && { ...entry, mtimeFor });
5891
5890
  }
5892
5891
  }
5893
- async place(handle, dir, name2) {
5892
+ async place(handle, dir, name2, copies) {
5894
5893
  const move = handle.move;
5895
5894
  if (move) this.others++;
5896
5895
  const moved2 = await move?.call(handle, dir, name2).then(
@@ -5900,7 +5899,7 @@ var OpfsFs = class {
5900
5899
  if (moved2) return true;
5901
5900
  const before = this.fileMoves;
5902
5901
  try {
5903
- await this.copy(handle, dir, name2);
5902
+ await this.copy(handle, dir, name2, copies);
5904
5903
  } catch (err) {
5905
5904
  if (handle.kind === "directory" && this.fileMoves === before) {
5906
5905
  await this.io(dir.removeEntry(name2, { recursive: true }));
@@ -5910,7 +5909,7 @@ var OpfsFs = class {
5910
5909
  return false;
5911
5910
  }
5912
5911
  fileMoves = 0;
5913
- async copy(handle, dir, name2) {
5912
+ async copy(handle, dir, name2, copies, rest2 = "") {
5914
5913
  if (handle.kind === "file" && movable(handle)) {
5915
5914
  this.others++;
5916
5915
  const moved2 = await handle.move?.(dir, name2).then(
@@ -5925,13 +5924,17 @@ var OpfsFs = class {
5925
5924
  if (handle.kind === "file") {
5926
5925
  const made2 = await this.io(dir.getFileHandle(name2, { create: true }));
5927
5926
  const writable2 = await this.io(made2.createWritable());
5928
- await writable2.write(await this.io(handle.getFile()));
5927
+ const file = await this.io(handle.getFile());
5928
+ await writable2.write(file);
5929
5929
  await writable2.close();
5930
+ copies?.set(rest2, { before: copies.get(rest2)?.before ?? file.lastModified, made: made2 });
5930
5931
  return;
5931
5932
  }
5932
5933
  const target = await this.io(dir.getDirectoryHandle(name2, { create: true }));
5933
5934
  this.others++;
5934
- for await (const child of handle.values()) await this.copy(child, target, child.name);
5935
+ for await (const child of handle.values()) {
5936
+ await this.copy(child, target, child.name, copies, `${rest2}/${child.name}`);
5937
+ }
5935
5938
  }
5936
5939
  async symlink(target, path, owner) {
5937
5940
  const parent = await this.locate(parentOf4(path), true);
@@ -7464,7 +7467,7 @@ function satisfies(version, range2) {
7464
7467
  }
7465
7468
 
7466
7469
  // src/version.ts
7467
- var KERNEL_VERSION = true ? "1.134.0" : "0.0.0-dev";
7470
+ var KERNEL_VERSION = true ? "1.134.3" : "0.0.0-dev";
7468
7471
  var OS_RELEASE = "6.0.0-slicc";
7469
7472
  function procVersion() {
7470
7473
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -24618,6 +24621,9 @@ var WasmMemories = class {
24618
24621
  const source = this.learned ? "learned" : ceiling === void 0 ? "none" : "default";
24619
24622
  return { live: this.live, ceiling: ceiling ?? 0, source };
24620
24623
  }
24624
+ started() {
24625
+ this.progress();
24626
+ }
24621
24627
  ended() {
24622
24628
  this.live = Math.max(0, this.live - 1);
24623
24629
  this.progress();
@@ -28002,6 +28008,7 @@ var Launcher = class {
28002
28008
  });
28003
28009
  const counted3 = (handle2) => {
28004
28010
  void handle2.exited.finally(() => this.memories.ended());
28011
+ void Promise.resolve(handle2.ready).then(() => this.memories.started());
28005
28012
  return handle2;
28006
28013
  };
28007
28014
  if (!this.memories.near()) {
@@ -30653,6 +30660,7 @@ async function createNodeKernel(options = {}) {
30653
30660
  ...options.sealed ? { sealed: options.sealed } : {},
30654
30661
  ...options.clipboard ? { clipboard: options.clipboard } : {},
30655
30662
  ...options.approve ? { approve: options.approve } : {},
30663
+ ...options.wasmMemories ? { wasmMemories: options.wasmMemories } : {},
30656
30664
  cron: { lock: cronLock(root), ...options.cron?.clock ? { clock: options.cron.clock } : {} }
30657
30665
  });
30658
30666
  await launcher.prepare();