@ai-ecoverse/slicc-kernel 1.106.2 → 1.106.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.
@@ -5006,7 +5006,7 @@ var KERNEL_VERSION, OS_RELEASE;
5006
5006
  var init_version = __esm({
5007
5007
  "src/version.ts"() {
5008
5008
  "use strict";
5009
- KERNEL_VERSION = true ? "1.106.2" : "0.0.0-dev";
5009
+ KERNEL_VERSION = true ? "1.106.3" : "0.0.0-dev";
5010
5010
  OS_RELEASE = "6.0.0-slicc";
5011
5011
  }
5012
5012
  });
@@ -5028,7 +5028,11 @@ function modeOf(mode) {
5028
5028
  function callError(result, op) {
5029
5029
  const { errno: errno2, message: message2 } = result;
5030
5030
  const detailed = typeof message2 === "string" && message2 !== errno2 && DETAILED.has(op);
5031
- return new JsCallError(errno2, detailed ? `${op}: ${message2}` : op);
5031
+ return new JsCallError(
5032
+ errno2,
5033
+ detailed ? `${op}: ${message2}` : op,
5034
+ detailed ? message2 : void 0
5035
+ );
5032
5036
  }
5033
5037
  function untilAborted(work, signal) {
5034
5038
  if (!signal) return work;
@@ -5055,10 +5059,12 @@ var init_js_kernel = __esm({
5055
5059
  init_async_sab();
5056
5060
  JsCallError = class extends Error {
5057
5061
  code;
5058
- constructor(code2, what) {
5062
+ detail;
5063
+ constructor(code2, what, detail) {
5059
5064
  super(`${what}: ${code2}`);
5060
5065
  this.name = "JsCallError";
5061
5066
  this.code = code2;
5067
+ this.detail = detail;
5062
5068
  }
5063
5069
  };
5064
5070
  DETAILED = /* @__PURE__ */ new Set([
@@ -5973,6 +5979,29 @@ var init_js_exit = __esm({
5973
5979
  });
5974
5980
 
5975
5981
  // src/process/js/js-fetch.ts
5982
+ function cut(err) {
5983
+ if (!(err instanceof JsCallError) || err.code !== "EIO") return err;
5984
+ return Object.assign(new Error("other side closed"), {
5985
+ name: "SocketError",
5986
+ code: "UND_ERR_SOCKET"
5987
+ });
5988
+ }
5989
+ function givenNames(given) {
5990
+ if (given === void 0 || given instanceof Headers) return [];
5991
+ const pairs = Array.isArray(given) ? given : Object.entries(given);
5992
+ return pairs.map((pair) => String(pair[0]).toLowerCase());
5993
+ }
5994
+ function inOrder(headers, given) {
5995
+ const all = new Map(headers);
5996
+ const out = [];
5997
+ for (const name2 of [...givenNames(given), ...all.keys()]) {
5998
+ const value2 = all.get(name2);
5999
+ if (value2 === void 0) continue;
6000
+ all.delete(name2);
6001
+ out.push([name2, value2]);
6002
+ }
6003
+ return out;
6004
+ }
5976
6005
  function withoutFragment(url) {
5977
6006
  url.hash = "";
5978
6007
  return url.href;
@@ -5999,9 +6028,7 @@ function checkUrl(url) {
5999
6028
  if (protocol !== "http:" && protocol !== "https:") {
6000
6029
  throw failed(new JsCallError("EPROTONOSUPPORT", protocol));
6001
6030
  }
6002
- if (badPort(parsed) && !local2(url)) {
6003
- throw failed(Object.assign(new Error("bad port"), { code: "EACCES" }));
6004
- }
6031
+ if (badPort(parsed)) throw failed(new Error("bad port"));
6005
6032
  }
6006
6033
  function rewrite(hop, status2, location) {
6007
6034
  const next2 = new URL(location, hop.url);
@@ -6273,7 +6300,7 @@ function fetchOp(kernel) {
6273
6300
  } catch (err) {
6274
6301
  settle();
6275
6302
  await close(handle);
6276
- throw signal.aborted ? signal.reason : new TypeError("terminated", { cause: err });
6303
+ throw signal.aborted ? signal.reason : new TypeError("terminated", { cause: cut(err) });
6277
6304
  }
6278
6305
  const bytes = r.ok && r.kind === "bytes" ? r.bytes : new Uint8Array(0);
6279
6306
  if (bytes.length > 0) {
@@ -6343,7 +6370,7 @@ function fetchOp(kernel) {
6343
6370
  let hop = {
6344
6371
  url,
6345
6372
  method: request.method,
6346
- headers: [...request.headers],
6373
+ headers: inOrder(request.headers, init?.headers),
6347
6374
  body: bytes,
6348
6375
  ...streamed && request.body ? { stream: request.body } : {}
6349
6376
  };
@@ -6356,8 +6383,7 @@ function fetchOp(kernel) {
6356
6383
  return respond(head, hop.method, redirected, known.encodedBodies, signal);
6357
6384
  }
6358
6385
  await close(head.handle);
6359
- if (request.redirect === "error")
6360
- throw failed(new JsCallError("EREDIRECT", "unexpected redirect"));
6386
+ if (request.redirect === "error") throw failed(new Error("unexpected redirect"));
6361
6387
  if (hops >= MAX_REDIRECTS) throw failed(new JsCallError("ELOOP", hop.url));
6362
6388
  [hop, known] = await redirect(hop, head.status, location, known);
6363
6389
  }
@@ -10462,6 +10488,12 @@ var init_js_tty = __esm({
10462
10488
  function failed4(err) {
10463
10489
  return new TypeError("websocket failed", { cause: err });
10464
10490
  }
10491
+ function openError(err) {
10492
+ if (!(err instanceof JsCallError) || err.detail === void 0) return err;
10493
+ const prefix = `${err.code}: `;
10494
+ const message2 = err.detail.startsWith(prefix) ? err.detail.slice(prefix.length) : err.detail;
10495
+ return Object.assign(new Error(message2), { code: err.code });
10496
+ }
10465
10497
  function socketUrl(input) {
10466
10498
  const url = new URL(input);
10467
10499
  if (url.protocol === "http:") url.protocol = "ws:";
@@ -10503,7 +10535,7 @@ function websocketOp(kernel) {
10503
10535
  protocol = (r.ok && r.kind === "json" ? r.json : {}).protocol;
10504
10536
  } catch (err) {
10505
10537
  await free();
10506
- throw signal.aborted ? signal.reason : failed4(err);
10538
+ throw signal.aborted ? signal.reason : failed4(openError(err));
10507
10539
  }
10508
10540
  let settle;
10509
10541
  let lose;