@ai-ecoverse/slicc-kernel 1.143.3 → 1.143.5

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
@@ -7982,7 +7982,7 @@ function satisfies(version, range2) {
7982
7982
  }
7983
7983
 
7984
7984
  // src/version.ts
7985
- var KERNEL_VERSION = true ? "1.143.3" : "0.0.0-dev";
7985
+ var KERNEL_VERSION = true ? "1.143.5" : "0.0.0-dev";
7986
7986
  var OS_RELEASE = "6.0.0-slicc";
7987
7987
  function procVersion() {
7988
7988
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -10506,22 +10506,22 @@ function noted(watch, note) {
10506
10506
  if (watch.overflowed) return;
10507
10507
  if (watch.notes.length >= WATCH_NOTES_LIMIT) {
10508
10508
  watch.overflowed = true;
10509
- watch.notes.push({ overflow: true });
10509
+ watch.notes.push({ overflow: true, seq: note.seq });
10510
10510
  } else watch.notes.push(note);
10511
10511
  watch.wake?.();
10512
10512
  }
10513
- function route(watch, type, path) {
10514
- for (const root of watch.roots) if (routed(watch, root, type, path)) return;
10513
+ function route(watch, type, path, seq2) {
10514
+ for (const root of watch.roots) if (routed(watch, root, type, path, seq2)) return;
10515
10515
  }
10516
- function routed(watch, root, type, path) {
10516
+ function routed(watch, root, type, path, seq2) {
10517
10517
  if (path === root || type === "rename" && root !== "/" && under3(root, path)) {
10518
- noted(watch, { type, filename: watch.names.get(root) ?? baseOf3(root) });
10519
- if (type === "rename") noted(watch, { ended: true });
10518
+ noted(watch, { type, filename: watch.names.get(root) ?? baseOf3(root), seq: seq2 });
10519
+ if (type === "rename") noted(watch, { ended: true, seq: seq2 });
10520
10520
  return true;
10521
10521
  }
10522
- if (parentOf7(path) === root) noted(watch, { type, filename: baseOf3(path) });
10522
+ if (parentOf7(path) === root) noted(watch, { type, filename: baseOf3(path), seq: seq2 });
10523
10523
  else if (watch.recursive && under3(path, root)) {
10524
- noted(watch, { type, filename: path.slice(root === "/" ? 1 : root.length + 1) });
10524
+ noted(watch, { type, filename: path.slice(root === "/" ? 1 : root.length + 1), seq: seq2 });
10525
10525
  } else return false;
10526
10526
  return true;
10527
10527
  }
@@ -10535,6 +10535,7 @@ var FsWatchers = class {
10535
10535
  typed = /* @__PURE__ */ new Set();
10536
10536
  taps = [];
10537
10537
  reals = /* @__PURE__ */ new Map();
10538
+ seq = 0;
10538
10539
  reshapes = [];
10539
10540
  onReshape(listener) {
10540
10541
  this.reshapes.push(listener);
@@ -10594,7 +10595,7 @@ var FsWatchers = class {
10594
10595
  const notes = watch.notes.splice(0);
10595
10596
  watch.overflowed = false;
10596
10597
  if (watch.ended) this.typed.delete(watch);
10597
- return notes.length === 0 && watch.ended ? [{ ended: true }] : notes;
10598
+ return notes.length === 0 && watch.ended ? [{ ended: true, seq: this.seq }] : notes;
10598
10599
  }
10599
10600
  };
10600
10601
  }
@@ -10611,10 +10612,11 @@ var FsWatchers = class {
10611
10612
  if (this.typed.size === 0) return;
10612
10613
  for (const path of paths) {
10613
10614
  const at = normalizePath(path);
10614
- for (const watch of [...this.typed]) route(watch, type, at);
10615
+ const seq2 = ++this.seq;
10616
+ for (const watch of [...this.typed]) route(watch, type, at, seq2);
10615
10617
  }
10616
10618
  }
10617
- moved(from, to) {
10619
+ moved(from, to, seq2 = ++this.seq) {
10618
10620
  const source = normalizePath(from);
10619
10621
  const target = normalizePath(to);
10620
10622
  const followed2 = /* @__PURE__ */ new Set();
@@ -10630,17 +10632,25 @@ var FsWatchers = class {
10630
10632
  watch.names = names2;
10631
10633
  watch.roots = [...new Set(roots)];
10632
10634
  if (main === source) {
10633
- noted(watch, { type: "rename", filename: names2.get(target), moved: true });
10635
+ noted(watch, {
10636
+ type: "rename",
10637
+ filename: names2.get(target),
10638
+ moved: true,
10639
+ seq: seq2
10640
+ });
10634
10641
  }
10635
10642
  }
10636
10643
  return followed2;
10637
10644
  }
10638
10645
  renamed(from, to) {
10639
- const followed2 = this.moved(from, to);
10646
+ const first = ++this.seq;
10647
+ const followed2 = this.moved(from, to, first);
10640
10648
  if (this.typed.size === 0) return;
10641
- for (const path of [from, to]) {
10649
+ for (const [i, path] of [from, to].entries()) {
10642
10650
  const at = normalizePath(path);
10643
- for (const watch of [...this.typed]) if (!followed2.has(watch)) route(watch, "rename", at);
10651
+ const seq2 = i === 0 ? first : ++this.seq;
10652
+ for (const watch of [...this.typed])
10653
+ if (!followed2.has(watch)) route(watch, "rename", at, seq2);
10644
10654
  }
10645
10655
  }
10646
10656
  changed(...paths) {
@@ -10705,10 +10715,11 @@ var FsWatchers = class {
10705
10715
  const real = await realOf(at);
10706
10716
  const paths = real === at ? [at] : [at, real];
10707
10717
  this.report(paths);
10708
- if (done4) for (const type of types(fresh2)) this.emit(type, paths);
10718
+ if (done4) for (const type of types(fresh2, args)) this.emit(type, paths);
10709
10719
  }
10710
10720
  };
10711
10721
  const written2 = (fresh2) => fresh2 ? ["rename", "change"] : ["change"];
10722
+ const overwritten = (fresh2, args) => fresh2 || args[1].length === 0 ? written2(fresh2) : ["change", "change"];
10712
10723
  const reshaping = (run2) => async (...args) => {
10713
10724
  this.reshaped();
10714
10725
  try {
@@ -10718,7 +10729,7 @@ var FsWatchers = class {
10718
10729
  }
10719
10730
  };
10720
10731
  const overrides = {
10721
- writeFile: content(fs.writeFile.bind(fs), written2),
10732
+ writeFile: content(fs.writeFile.bind(fs), overwritten),
10722
10733
  ...fs.createExclusive ? { createExclusive: content(fs.createExclusive.bind(fs), () => ["rename"]) } : {},
10723
10734
  ...fs.copyFile ? {
10724
10735
  copyFile: (from, to, options) => content(
@@ -32163,42 +32174,47 @@ function nodeTransport(options = {}) {
32163
32174
  var TERMINATED = "the kernel is terminated";
32164
32175
  var EXIT_GRACE_MS = 50;
32165
32176
  var WARM_IDLE_MS = 3e4;
32166
- function warmPool(make, live, idleMs = WARM_IDLE_MS) {
32167
- let spare;
32177
+ var MAX_WARM_WORKERS = 64;
32178
+ function warmPool(make, live, idleMs = WARM_IDLE_MS, size = 1) {
32179
+ const spares = [];
32168
32180
  let idle2;
32169
32181
  let closed = false;
32170
32182
  const drop = (worker) => {
32171
- if (spare !== worker) return;
32172
- spare = void 0;
32183
+ const at = spares.indexOf(worker);
32184
+ if (at < 0) return;
32185
+ spares.splice(at, 1);
32186
+ if (spares.length > 0) return;
32173
32187
  clearTimeout(idle2);
32174
32188
  live.delete(kill);
32175
32189
  };
32176
32190
  const kill = () => {
32177
- const worker = spare;
32178
- if (!worker) return;
32179
- drop(worker);
32180
- void worker.terminate();
32191
+ for (const worker of [...spares]) {
32192
+ drop(worker);
32193
+ void worker.terminate();
32194
+ }
32181
32195
  };
32182
32196
  const fill2 = () => {
32183
- if (closed || spare) return;
32184
- let worker;
32185
- try {
32186
- worker = make();
32187
- } catch {
32188
- closed = true;
32189
- return;
32197
+ while (!closed && spares.length < size) {
32198
+ let worker;
32199
+ try {
32200
+ worker = make();
32201
+ } catch {
32202
+ closed = true;
32203
+ return;
32204
+ }
32205
+ worker.unref();
32206
+ worker.once("error", () => drop(worker));
32207
+ worker.once("exit", () => drop(worker));
32208
+ spares.push(worker);
32209
+ live.add(kill);
32190
32210
  }
32191
- worker.unref();
32192
- worker.once("error", () => drop(worker));
32193
- worker.once("exit", () => drop(worker));
32194
- spare = worker;
32195
- live.add(kill);
32211
+ clearTimeout(idle2);
32196
32212
  idle2 = setTimeout(kill, idleMs);
32197
32213
  idle2.unref?.();
32198
32214
  };
32199
32215
  return {
32200
32216
  take() {
32201
- const worker = spare;
32217
+ const worker = spares[0];
32202
32218
  if (worker) {
32203
32219
  drop(worker);
32204
32220
  worker.removeAllListeners("error");
@@ -32214,12 +32230,23 @@ function warmPool(make, live, idleMs = WARM_IDLE_MS) {
32214
32230
  }
32215
32231
  };
32216
32232
  }
32233
+ function sparesOf(options) {
32234
+ if (options.warmWorker === false) return 0;
32235
+ const n = options.warmWorkers ?? 1;
32236
+ if (typeof n !== "number" || !Number.isInteger(n) || n < 0 || n > MAX_WARM_WORKERS) {
32237
+ throw new TypeError(
32238
+ `createNodeKernel: warmWorkers must be an integer from 0 to ${MAX_WARM_WORKERS}`
32239
+ );
32240
+ }
32241
+ return n;
32242
+ }
32217
32243
  function processWorker(file, workerData) {
32218
32244
  return new Worker(file, { env: workerEnv(), ...workerData ? { workerData } : {} });
32219
32245
  }
32220
32246
  function warmPoolOf(options, file, workerData, live) {
32221
- if (options.warmWorker === false) return void 0;
32222
- return warmPool(() => processWorker(file, workerData), live);
32247
+ const size = sparesOf(options);
32248
+ if (size === 0) return void 0;
32249
+ return warmPool(() => processWorker(file, workerData), live, WARM_IDLE_MS, size);
32223
32250
  }
32224
32251
  function nodeWorker(file, live, closed, workerData, take) {
32225
32252
  const errors = /* @__PURE__ */ new Set();
@@ -32454,6 +32481,7 @@ async function createNodeKernel(options = {}) {
32454
32481
  export {
32455
32482
  KernelCallError,
32456
32483
  KernelGoneError,
32484
+ MAX_WARM_WORKERS,
32457
32485
  WARM_IDLE_MS,
32458
32486
  attachKernel,
32459
32487
  createNodeKernel,
@@ -32461,6 +32489,7 @@ export {
32461
32489
  memoryRoot,
32462
32490
  nodeTransport,
32463
32491
  serveHostfsPort,
32492
+ sparesOf,
32464
32493
  warmPool
32465
32494
  };
32466
32495
  //# sourceMappingURL=node.js.map