@ai-ecoverse/slicc-kernel 1.110.3 → 1.110.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
@@ -6494,7 +6494,7 @@ function satisfies(version, range2) {
6494
6494
  }
6495
6495
 
6496
6496
  // src/version.ts
6497
- var KERNEL_VERSION = true ? "1.110.3" : "0.0.0-dev";
6497
+ var KERNEL_VERSION = true ? "1.110.5" : "0.0.0-dev";
6498
6498
  var OS_RELEASE = "6.0.0-slicc";
6499
6499
  function procVersion() {
6500
6500
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -2515,7 +2515,7 @@ var KERNEL_VERSION, OS_RELEASE;
2515
2515
  var init_version = __esm({
2516
2516
  "src/version.ts"() {
2517
2517
  "use strict";
2518
- KERNEL_VERSION = true ? "1.110.3" : "0.0.0-dev";
2518
+ KERNEL_VERSION = true ? "1.110.5" : "0.0.0-dev";
2519
2519
  OS_RELEASE = "6.0.0-slicc";
2520
2520
  }
2521
2521
  });
@@ -10082,6 +10082,14 @@ function importsContext({
10082
10082
  }
10083
10083
  return void 0;
10084
10084
  };
10085
+ const sizedOf = (fd) => {
10086
+ const e = host.fds.get(fd);
10087
+ if (e.type === "file") return { path: e.file.path, size: e.file.size() };
10088
+ if (e.type === "kernel" && host.fds.kind(fd, e) === "file") {
10089
+ return call2({ op: "fd-vfs-stat", fd });
10090
+ }
10091
+ return { path: pathOf(fd) };
10092
+ };
10085
10093
  const requirePath = (fd) => {
10086
10094
  const path = pathOf(fd);
10087
10095
  if (path === void 0) throw new WasiError("EBADF");
@@ -10112,19 +10120,19 @@ function importsContext({
10112
10120
  },
10113
10121
  fstat(fd) {
10114
10122
  const e = host.fds.get(fd);
10115
- const path = pathOf(fd);
10123
+ const { path, size } = sizedOf(fd);
10116
10124
  if (path === void 0) {
10117
10125
  const kind = e.type === "device" ? "device" : "stream";
10118
10126
  return { kind, mode: kind === "device" ? 8630 : 4480, ...live(), size: 0 };
10119
10127
  }
10120
- host.fds.flushPath(path);
10128
+ if (size === void 0) host.fds.flushPath(path);
10121
10129
  const s = fs.stat(path);
10122
10130
  return {
10123
10131
  kind: s.isDirectory ? "dir" : "file",
10124
10132
  path,
10125
10133
  mode: s.mode ?? (s.isDirectory ? 16877 : 33188),
10126
10134
  ...s.uid !== void 0 && s.gid !== void 0 ? { uid: s.uid, gid: s.gid } : live(),
10127
- size: s.size,
10135
+ size: size ?? s.size,
10128
10136
  ...s.ino !== void 0 ? { ino: s.ino } : {},
10129
10137
  ...s.mtimeMs !== void 0 ? { mtimeMs: s.mtimeMs } : {}
10130
10138
  };
@@ -14486,12 +14494,13 @@ function fetchOp(kernel) {
14486
14494
  throw signal.aborted ? signal.reason : failed3(err);
14487
14495
  }
14488
14496
  };
14489
- const body = (handle, signal) => {
14497
+ const body = (handle, request) => {
14498
+ const { signal } = request;
14490
14499
  let aborted;
14491
14500
  const settle = () => {
14492
14501
  if (aborted) signal.removeEventListener("abort", aborted);
14493
14502
  };
14494
- return new ReadableStream(
14503
+ const stream = new ReadableStream(
14495
14504
  {
14496
14505
  start(controller) {
14497
14506
  aborted = () => {
@@ -14526,8 +14535,10 @@ function fetchOp(kernel) {
14526
14535
  },
14527
14536
  { highWaterMark: 0 }
14528
14537
  );
14538
+ keptRequests.set(stream, request);
14539
+ return stream;
14529
14540
  };
14530
- const respond = (head, method, redirected, encoded, signal) => {
14541
+ const respond = (head, method, redirected, encoded, request) => {
14531
14542
  if (head.status < 200 || head.status > 599) {
14532
14543
  void close(head.handle);
14533
14544
  throw failed3(new JsCallError("EPROTO", `status ${head.status}`));
@@ -14535,7 +14546,7 @@ function fetchOp(kernel) {
14535
14546
  const empty = method === "HEAD" || NULL_BODY.has(head.status);
14536
14547
  if (empty) void close(head.handle);
14537
14548
  const headers = new Headers(head.headers);
14538
- let stream = empty ? null : body(head.handle, signal);
14549
+ let stream = empty ? null : body(head.handle, request);
14539
14550
  const coding = headers.get("content-encoding")?.trim().toLowerCase();
14540
14551
  if (stream && encoded && coding && DECODED.has(coding)) {
14541
14552
  const format = coding === "deflate" ? "deflate" : "gzip";
@@ -14543,6 +14554,7 @@ function fetchOp(kernel) {
14543
14554
  new DecompressionStream(format)
14544
14555
  );
14545
14556
  headers.delete("content-length");
14557
+ keptRequests.set(stream, request);
14546
14558
  }
14547
14559
  const response = new Response(stream, {
14548
14560
  status: head.status,
@@ -14588,7 +14600,7 @@ function fetchOp(kernel) {
14588
14600
  const follow2 = known.manualRedirects && REDIRECTS.has(head.status) && location !== void 0 && request.redirect !== "manual";
14589
14601
  if (!follow2) {
14590
14602
  const redirected = hops > 0 || head.redirected === true;
14591
- return respond(head, hop.method, redirected, known.encodedBodies, signal);
14603
+ return respond(head, hop.method, redirected, known.encodedBodies, request);
14592
14604
  }
14593
14605
  await close(head.handle);
14594
14606
  if (request.redirect === "error") throw failed3(new Error("unexpected redirect"));
@@ -14597,7 +14609,7 @@ function fetchOp(kernel) {
14597
14609
  }
14598
14610
  };
14599
14611
  }
14600
- var CHUNK2, MAX_REDIRECTS, NULL_BODY, REDIRECTS, BODY_HEADERS, DECODED, CREDENTIALS, BAD_PORTS, OVER, TOKEN, QUOTABLE, SPACE, BASE64, SLICE;
14612
+ var CHUNK2, MAX_REDIRECTS, keptRequests, NULL_BODY, REDIRECTS, BODY_HEADERS, DECODED, CREDENTIALS, BAD_PORTS, OVER, TOKEN, QUOTABLE, SPACE, BASE64, SLICE;
14601
14613
  var init_js_fetch = __esm({
14602
14614
  "src/process/js/js-fetch.ts"() {
14603
14615
  "use strict";
@@ -14605,6 +14617,7 @@ var init_js_fetch = __esm({
14605
14617
  init_js_kernel();
14606
14618
  CHUNK2 = 64 * 1024;
14607
14619
  MAX_REDIRECTS = 20;
14620
+ keptRequests = /* @__PURE__ */ new WeakMap();
14608
14621
  NULL_BODY = /* @__PURE__ */ new Set([101, 103, 204, 205, 304]);
14609
14622
  REDIRECTS = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]);
14610
14623
  BODY_HEADERS = /* @__PURE__ */ new Set([