@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.
@@ -2491,7 +2491,7 @@ var KERNEL_VERSION, OS_RELEASE;
2491
2491
  var init_version = __esm({
2492
2492
  "src/version.ts"() {
2493
2493
  "use strict";
2494
- KERNEL_VERSION = true ? "1.106.2" : "0.0.0-dev";
2494
+ KERNEL_VERSION = true ? "1.106.3" : "0.0.0-dev";
2495
2495
  OS_RELEASE = "6.0.0-slicc";
2496
2496
  }
2497
2497
  });
@@ -13129,7 +13129,11 @@ function modeOf(mode) {
13129
13129
  function callError(result, op) {
13130
13130
  const { errno: errno2, message: message2 } = result;
13131
13131
  const detailed = typeof message2 === "string" && message2 !== errno2 && DETAILED.has(op);
13132
- return new JsCallError(errno2, detailed ? `${op}: ${message2}` : op);
13132
+ return new JsCallError(
13133
+ errno2,
13134
+ detailed ? `${op}: ${message2}` : op,
13135
+ detailed ? message2 : void 0
13136
+ );
13133
13137
  }
13134
13138
  function untilAborted(work, signal) {
13135
13139
  if (!signal) return work;
@@ -13156,10 +13160,12 @@ var init_js_kernel = __esm({
13156
13160
  init_async_sab();
13157
13161
  JsCallError = class extends Error {
13158
13162
  code;
13159
- constructor(code2, what) {
13163
+ detail;
13164
+ constructor(code2, what, detail) {
13160
13165
  super(`${what}: ${code2}`);
13161
13166
  this.name = "JsCallError";
13162
13167
  this.code = code2;
13168
+ this.detail = detail;
13163
13169
  }
13164
13170
  };
13165
13171
  DETAILED = /* @__PURE__ */ new Set([
@@ -14074,6 +14080,29 @@ var init_js_exit = __esm({
14074
14080
  });
14075
14081
 
14076
14082
  // src/process/js/js-fetch.ts
14083
+ function cut(err) {
14084
+ if (!(err instanceof JsCallError) || err.code !== "EIO") return err;
14085
+ return Object.assign(new Error("other side closed"), {
14086
+ name: "SocketError",
14087
+ code: "UND_ERR_SOCKET"
14088
+ });
14089
+ }
14090
+ function givenNames(given) {
14091
+ if (given === void 0 || given instanceof Headers) return [];
14092
+ const pairs = Array.isArray(given) ? given : Object.entries(given);
14093
+ return pairs.map((pair) => String(pair[0]).toLowerCase());
14094
+ }
14095
+ function inOrder(headers, given) {
14096
+ const all = new Map(headers);
14097
+ const out = [];
14098
+ for (const name2 of [...givenNames(given), ...all.keys()]) {
14099
+ const value2 = all.get(name2);
14100
+ if (value2 === void 0) continue;
14101
+ all.delete(name2);
14102
+ out.push([name2, value2]);
14103
+ }
14104
+ return out;
14105
+ }
14077
14106
  function withoutFragment(url) {
14078
14107
  url.hash = "";
14079
14108
  return url.href;
@@ -14100,9 +14129,7 @@ function checkUrl(url) {
14100
14129
  if (protocol !== "http:" && protocol !== "https:") {
14101
14130
  throw failed3(new JsCallError("EPROTONOSUPPORT", protocol));
14102
14131
  }
14103
- if (badPort(parsed) && !local2(url)) {
14104
- throw failed3(Object.assign(new Error("bad port"), { code: "EACCES" }));
14105
- }
14132
+ if (badPort(parsed)) throw failed3(new Error("bad port"));
14106
14133
  }
14107
14134
  function rewrite(hop, status2, location) {
14108
14135
  const next2 = new URL(location, hop.url);
@@ -14374,7 +14401,7 @@ function fetchOp(kernel) {
14374
14401
  } catch (err) {
14375
14402
  settle();
14376
14403
  await close(handle);
14377
- throw signal.aborted ? signal.reason : new TypeError("terminated", { cause: err });
14404
+ throw signal.aborted ? signal.reason : new TypeError("terminated", { cause: cut(err) });
14378
14405
  }
14379
14406
  const bytes = r.ok && r.kind === "bytes" ? r.bytes : new Uint8Array(0);
14380
14407
  if (bytes.length > 0) {
@@ -14444,7 +14471,7 @@ function fetchOp(kernel) {
14444
14471
  let hop = {
14445
14472
  url,
14446
14473
  method: request.method,
14447
- headers: [...request.headers],
14474
+ headers: inOrder(request.headers, init?.headers),
14448
14475
  body: bytes,
14449
14476
  ...streamed && request.body ? { stream: request.body } : {}
14450
14477
  };
@@ -14457,8 +14484,7 @@ function fetchOp(kernel) {
14457
14484
  return respond(head, hop.method, redirected, known.encodedBodies, signal);
14458
14485
  }
14459
14486
  await close(head.handle);
14460
- if (request.redirect === "error")
14461
- throw failed3(new JsCallError("EREDIRECT", "unexpected redirect"));
14487
+ if (request.redirect === "error") throw failed3(new Error("unexpected redirect"));
14462
14488
  if (hops >= MAX_REDIRECTS) throw failed3(new JsCallError("ELOOP", hop.url));
14463
14489
  [hop, known] = await redirect(hop, head.status, location, known);
14464
14490
  }
@@ -15353,6 +15379,12 @@ var init_js_tty = __esm({
15353
15379
  function failed4(err) {
15354
15380
  return new TypeError("websocket failed", { cause: err });
15355
15381
  }
15382
+ function openError(err) {
15383
+ if (!(err instanceof JsCallError) || err.detail === void 0) return err;
15384
+ const prefix = `${err.code}: `;
15385
+ const message2 = err.detail.startsWith(prefix) ? err.detail.slice(prefix.length) : err.detail;
15386
+ return Object.assign(new Error(message2), { code: err.code });
15387
+ }
15356
15388
  function socketUrl(input) {
15357
15389
  const url = new URL(input);
15358
15390
  if (url.protocol === "http:") url.protocol = "ws:";
@@ -15394,7 +15426,7 @@ function websocketOp(kernel) {
15394
15426
  protocol = (r.ok && r.kind === "json" ? r.json : {}).protocol;
15395
15427
  } catch (err) {
15396
15428
  await free();
15397
- throw signal.aborted ? signal.reason : failed4(err);
15429
+ throw signal.aborted ? signal.reason : failed4(openError(err));
15398
15430
  }
15399
15431
  let settle;
15400
15432
  let lose;