@ai-ecoverse/slicc-kernel 1.47.1 → 1.47.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.
- package/README.md +3 -2
- package/dist/kernel-worker.js +31 -3
- package/dist/kernel-worker.js.map +2 -2
- package/dist/node-process-worker.js +63 -2
- package/dist/node-process-worker.js.map +3 -3
- package/dist/node.js +31 -3
- package/dist/node.js.map +2 -2
- package/dist/process-worker.js +63 -2
- package/dist/process-worker.js.map +3 -3
- package/package.json +1 -1
package/dist/process-worker.js
CHANGED
|
@@ -5482,6 +5482,7 @@ function kernelFiletype(kind) {
|
|
|
5482
5482
|
case "device":
|
|
5483
5483
|
return { filetype: FILETYPE.CHARACTER_DEVICE, seeks: true };
|
|
5484
5484
|
case "socket":
|
|
5485
|
+
case "stream":
|
|
5485
5486
|
return { filetype: FILETYPE.SOCKET_STREAM, seeks: false };
|
|
5486
5487
|
case "file":
|
|
5487
5488
|
return { filetype: FILETYPE.REGULAR_FILE, seeks: true };
|
|
@@ -8889,6 +8890,58 @@ function rewrite(hop, status2, location) {
|
|
|
8889
8890
|
body: toGet ? void 0 : hop.body
|
|
8890
8891
|
};
|
|
8891
8892
|
}
|
|
8893
|
+
function isHex(byte) {
|
|
8894
|
+
return byte !== void 0 && /^[0-9A-Fa-f]$/.test(String.fromCharCode(byte));
|
|
8895
|
+
}
|
|
8896
|
+
function percentDecode(input) {
|
|
8897
|
+
const bytes = new TextEncoder().encode(input);
|
|
8898
|
+
const out = new Uint8Array(bytes.length);
|
|
8899
|
+
let at = 0;
|
|
8900
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
8901
|
+
const byte = bytes[i];
|
|
8902
|
+
if (byte === 37 && isHex(bytes[i + 1]) && isHex(bytes[i + 2])) {
|
|
8903
|
+
out[at++] = Number.parseInt(
|
|
8904
|
+
String.fromCharCode(bytes[i + 1], bytes[i + 2]),
|
|
8905
|
+
16
|
|
8906
|
+
);
|
|
8907
|
+
i += 2;
|
|
8908
|
+
} else out[at++] = byte;
|
|
8909
|
+
}
|
|
8910
|
+
return out.subarray(0, at);
|
|
8911
|
+
}
|
|
8912
|
+
function latin1(bytes) {
|
|
8913
|
+
let text = "";
|
|
8914
|
+
for (let at = 0; at < bytes.length; at += SLICE) {
|
|
8915
|
+
text += String.fromCharCode(...bytes.subarray(at, at + SLICE));
|
|
8916
|
+
}
|
|
8917
|
+
return text;
|
|
8918
|
+
}
|
|
8919
|
+
function dataResponse(request) {
|
|
8920
|
+
const url = withoutFragment(new URL(request.url));
|
|
8921
|
+
const rest2 = url.slice("data:".length);
|
|
8922
|
+
const comma = rest2.indexOf(",");
|
|
8923
|
+
if (comma < 0) throw failed2(new JsCallError("EINVAL", "a data: URL without a comma"));
|
|
8924
|
+
let type = rest2.slice(0, comma).replace(/^[\t\n\f\r ]+|[\t\n\f\r ]+$/g, "");
|
|
8925
|
+
let body = percentDecode(rest2.slice(comma + 1));
|
|
8926
|
+
const base642 = BASE64.exec(type);
|
|
8927
|
+
if (base642) {
|
|
8928
|
+
type = type.slice(0, base642.index).replace(/[\t\n\f\r ]+$/, "");
|
|
8929
|
+
let binary;
|
|
8930
|
+
try {
|
|
8931
|
+
binary = atob(latin1(body));
|
|
8932
|
+
} catch {
|
|
8933
|
+
throw failed2(new JsCallError("EINVAL", "a data: URL whose base64 does not decode"));
|
|
8934
|
+
}
|
|
8935
|
+
body = Uint8Array.from(binary, (c) => c.charCodeAt(0));
|
|
8936
|
+
}
|
|
8937
|
+
if (type.startsWith(";")) type = `text/plain${type}`;
|
|
8938
|
+
if (!MIME.test(type)) type = "text/plain;charset=US-ASCII";
|
|
8939
|
+
const response = new Response(body, {
|
|
8940
|
+
status: 200,
|
|
8941
|
+
headers: { "content-type": type }
|
|
8942
|
+
});
|
|
8943
|
+
return withMeta(response, url, false);
|
|
8944
|
+
}
|
|
8892
8945
|
function withMeta(response, url, redirected) {
|
|
8893
8946
|
const clone = response.clone.bind(response);
|
|
8894
8947
|
Object.defineProperty(response, "url", { value: url });
|
|
@@ -9037,6 +9090,11 @@ function fetchOp(kernel) {
|
|
|
9037
9090
|
const request = new Request(input, init);
|
|
9038
9091
|
const { signal } = request;
|
|
9039
9092
|
signal.throwIfAborted();
|
|
9093
|
+
const { protocol } = new URL(request.url);
|
|
9094
|
+
if (protocol === "data:") return dataResponse(request);
|
|
9095
|
+
if (protocol !== "http:" && protocol !== "https:") {
|
|
9096
|
+
throw failed2(new JsCallError("EPROTONOSUPPORT", protocol));
|
|
9097
|
+
}
|
|
9040
9098
|
const known = await traitsOf().catch((err) => {
|
|
9041
9099
|
throw failed2(err);
|
|
9042
9100
|
});
|
|
@@ -9069,7 +9127,7 @@ function fetchOp(kernel) {
|
|
|
9069
9127
|
}
|
|
9070
9128
|
};
|
|
9071
9129
|
}
|
|
9072
|
-
var CHUNK, MAX_REDIRECTS, NULL_BODY, REDIRECTS, BODY_HEADERS, DECODED, CREDENTIALS, OVER;
|
|
9130
|
+
var CHUNK, MAX_REDIRECTS, NULL_BODY, REDIRECTS, BODY_HEADERS, DECODED, CREDENTIALS, OVER, MIME, BASE64, SLICE;
|
|
9073
9131
|
var init_js_fetch = __esm({
|
|
9074
9132
|
"src/process/js/js-fetch.ts"() {
|
|
9075
9133
|
"use strict";
|
|
@@ -9088,6 +9146,9 @@ var init_js_fetch = __esm({
|
|
|
9088
9146
|
DECODED = /* @__PURE__ */ new Set(["gzip", "x-gzip", "deflate"]);
|
|
9089
9147
|
CREDENTIALS = /* @__PURE__ */ new Set(["authorization", "proxy-authorization", "cookie", "cookie2"]);
|
|
9090
9148
|
OVER = /* @__PURE__ */ Symbol("over");
|
|
9149
|
+
MIME = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+(?:[\t ]*;.*)?$/s;
|
|
9150
|
+
BASE64 = /; *base64$/i;
|
|
9151
|
+
SLICE = 32768;
|
|
9091
9152
|
}
|
|
9092
9153
|
});
|
|
9093
9154
|
|
|
@@ -9590,7 +9651,7 @@ function ttyOps(kernel) {
|
|
|
9590
9651
|
}
|
|
9591
9652
|
};
|
|
9592
9653
|
const restore = async () => {
|
|
9593
|
-
for (const [fd, original] of [...saved]) {
|
|
9654
|
+
for (const [fd, original] of [...saved].reverse()) {
|
|
9594
9655
|
saved.delete(fd);
|
|
9595
9656
|
await setAttr(fd, original).catch(() => void 0);
|
|
9596
9657
|
}
|