@ai-ecoverse/slicc-kernel 1.111.0 → 1.113.0

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
@@ -4099,6 +4099,8 @@ var S_ISGID3 = 1024;
4099
4099
  var READ_ATTEMPTS = 3;
4100
4100
  var MAX_LINKS5 = 40;
4101
4101
  var CHECK_MS = 1e3;
4102
+ var ABSENT_MS = 2;
4103
+ var ABSENT_NAMES = 4096;
4102
4104
  var FILE_HANDLES = 4096;
4103
4105
  var STALE = /* @__PURE__ */ new Set(["NotFoundError", "TypeMismatchError"]);
4104
4106
  var EXECUTABLE = /\/node_modules\/(?:@[^/]+\/)?[^/]+\/bin\//;
@@ -4229,6 +4231,8 @@ var OpfsFs = class {
4229
4231
  meta;
4230
4232
  dirs = new PathMap();
4231
4233
  files = new PathMap();
4234
+ absent = new PathMap();
4235
+ changes = 0;
4232
4236
  snapshots = /* @__PURE__ */ new WeakMap();
4233
4237
  found = /* @__PURE__ */ new WeakMap();
4234
4238
  checked = /* @__PURE__ */ new WeakMap();
@@ -4467,8 +4471,14 @@ var OpfsFs = class {
4467
4471
  return true;
4468
4472
  }
4469
4473
  forget(path) {
4474
+ this.changes++;
4470
4475
  this.dirs.deleteTree(path);
4471
4476
  this.files.deleteTree(path);
4477
+ this.absent.deleteTree(path);
4478
+ }
4479
+ missed(path) {
4480
+ if (this.absent.size >= ABSENT_NAMES) this.absent.clear();
4481
+ this.absent.set(path, performance.now());
4472
4482
  }
4473
4483
  remember(path, handle, looked = false) {
4474
4484
  if (handle.kind !== "file") return handle;
@@ -4518,8 +4528,15 @@ var OpfsFs = class {
4518
4528
  this.snapshots.delete(cached);
4519
4529
  }
4520
4530
  }
4531
+ const kept = this.dirs.get(path);
4532
+ if (kept && await this.current(path, kept)) return kept;
4533
+ const gone = this.absent.get(path);
4534
+ if (gone !== void 0 && performance.now() - gone < ABSENT_MS) {
4535
+ throw translate({ name: "NotFoundError" }, path);
4536
+ }
4537
+ const seen = this.changes;
4521
4538
  const [dir, name2] = await this.parent(path);
4522
- const known = this.dirs.has(path);
4539
+ const known = kept !== void 0;
4523
4540
  return this.inDir(dir, async (parent) => {
4524
4541
  const [first, second] = known ? ["directory", "file"] : ["file", "directory"];
4525
4542
  try {
@@ -4529,7 +4546,9 @@ var OpfsFs = class {
4529
4546
  }
4530
4547
  return this.remember(path, await this.child(parent, name2, second), true);
4531
4548
  }).catch((err) => {
4532
- throw translate(err, path);
4549
+ const error = translate(err, path);
4550
+ if (error.code === "ENOENT" && seen === this.changes) this.missed(path);
4551
+ throw error;
4533
4552
  });
4534
4553
  }
4535
4554
  real(path) {
@@ -4656,7 +4675,9 @@ var OpfsFs = class {
4656
4675
  }
4657
4676
  flushing = {};
4658
4677
  touch(now, ...dirs) {
4678
+ this.changes++;
4659
4679
  for (const dir of dirs) {
4680
+ this.absent.deleteTree(dir);
4660
4681
  this.dirTimes.set(dir, now);
4661
4682
  this.dirDirty.add(dir);
4662
4683
  }
@@ -6510,7 +6531,7 @@ function satisfies(version, range2) {
6510
6531
  }
6511
6532
 
6512
6533
  // src/version.ts
6513
- var KERNEL_VERSION = true ? "1.111.0" : "0.0.0-dev";
6534
+ var KERNEL_VERSION = true ? "1.113.0" : "0.0.0-dev";
6514
6535
  var OS_RELEASE = "6.0.0-slicc";
6515
6536
  function procVersion() {
6516
6537
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -14644,6 +14665,7 @@ var Resolver = class {
14644
14665
  own;
14645
14666
  cache = /* @__PURE__ */ new Map();
14646
14667
  pending = /* @__PURE__ */ new Map();
14668
+ hosts;
14647
14669
  constructor(options) {
14648
14670
  this.uplink = options.uplink;
14649
14671
  this.routes = options.routes;
@@ -14651,6 +14673,14 @@ var Resolver = class {
14651
14673
  this.timeoutMs = options.timeoutMs ?? RESOLVE_TIMEOUT_MS;
14652
14674
  this.log = options.log ?? ((message3) => console.warn(message3));
14653
14675
  this.own = ownNames(options.hostname ?? DEFAULT_HOSTNAME);
14676
+ this.hosts = options.hosts;
14677
+ }
14678
+ async fromFile(key, family) {
14679
+ const listed = (await this.hosts?.().catch(() => void 0))?.get(key);
14680
+ if (!listed) return void 0;
14681
+ const v4 = listed.filter((a) => ipv4Bytes(a) !== void 0);
14682
+ const v6 = listed.filter((a) => ipv4Bytes(a) === void 0);
14683
+ return family === 4 ? v4 : family === 6 ? v6 : [...v4, ...v6];
14654
14684
  }
14655
14685
  async resolve(name2, family, blocking) {
14656
14686
  const key = name2.toLowerCase().replace(/\.$/, "");
@@ -14659,6 +14689,8 @@ var Resolver = class {
14659
14689
  const v4 = family !== 6 && local ? [local] : [];
14660
14690
  return family === 4 ? v4 : [...v4, key];
14661
14691
  }
14692
+ const listed = this.hosts ? await this.fromFile(key, family) : void 0;
14693
+ if (listed?.length) return listed;
14662
14694
  if (local) {
14663
14695
  const six = loopbackName(key, this.own) ? ["::1"] : [];
14664
14696
  return family === 6 ? six : family === 4 ? [local] : [local, ...six];
@@ -19060,6 +19092,43 @@ var JobTable = class {
19060
19092
  }
19061
19093
  };
19062
19094
 
19095
+ // src/kernel/net/hosts-file.ts
19096
+ var HOSTS_PATH = "/etc/hosts";
19097
+ function parseHosts(text) {
19098
+ const table = /* @__PURE__ */ new Map();
19099
+ for (const raw of text.split("\n")) {
19100
+ const [address, ...names] = raw.replace(/#.*/, "").trim().split(/\s+/);
19101
+ if (!address || names.length === 0) continue;
19102
+ if (ipv4Bytes(address) === void 0 && ipv6Groups(address) === void 0) continue;
19103
+ for (const name2 of names) {
19104
+ const key = name2.toLowerCase().replace(/\.$/, "");
19105
+ const known = table.get(key) ?? [];
19106
+ if (!known.includes(address)) known.push(address);
19107
+ table.set(key, known);
19108
+ }
19109
+ }
19110
+ return table;
19111
+ }
19112
+ function hostsReader(fs, path = HOSTS_PATH) {
19113
+ let stamp = "";
19114
+ let table;
19115
+ return async () => {
19116
+ const st = await fs.stat(path).catch(() => void 0);
19117
+ if (!st?.isFile) {
19118
+ stamp = "";
19119
+ table = void 0;
19120
+ return void 0;
19121
+ }
19122
+ const now = `${st.ino}:${st.size}:${st.mtime.getTime()}`;
19123
+ if (now === stamp && table) return table;
19124
+ const text = await fs.readFile(path).catch(() => void 0);
19125
+ if (text === void 0) return void 0;
19126
+ stamp = now;
19127
+ table = parseHosts(text);
19128
+ return table;
19129
+ };
19130
+ }
19131
+
19063
19132
  // src/kernel/net/redirect-hops.ts
19064
19133
  var HELD_MS = 3e4;
19065
19134
  var HELD_MAX = 64;
@@ -22500,7 +22569,12 @@ var Launcher = class {
22500
22569
  this.uplink = options.uplink;
22501
22570
  this.routes = new Routes(options.uplink?.traits.ipv6 === true);
22502
22571
  if (options.uplink?.routes) this.routes.set(options.uplink.routes);
22503
- this.resolver = new Resolver({ uplink: options.uplink, routes: this.routes, hostname });
22572
+ this.resolver = new Resolver({
22573
+ uplink: options.uplink,
22574
+ routes: this.routes,
22575
+ hostname,
22576
+ hosts: hostsReader(this.base)
22577
+ });
22504
22578
  if (options.uplink) this.net.useUplink({ uplink: options.uplink, routes: this.routes });
22505
22579
  enableNetwork(this.net, {
22506
22580
  transport: this.transport,