@ai-ecoverse/slicc-kernel 1.26.6 → 1.28.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/README.md +62 -4
- package/dist/driver-worker.js +1 -1
- package/dist/driver-worker.js.map +1 -1
- package/dist/index.js +221 -12
- package/dist/index.js.map +4 -4
- package/dist/kernel-worker.js +634 -51
- package/dist/kernel-worker.js.map +4 -4
- package/dist/node-driver-worker.js +1 -1
- package/dist/node-driver-worker.js.map +1 -1
- package/dist/node-process-worker.js +89 -20
- package/dist/node-process-worker.js.map +4 -4
- package/dist/node.js +547 -49
- package/dist/node.js.map +4 -4
- package/dist/process-worker.js +89 -20
- package/dist/process-worker.js.map +4 -4
- package/dist/testing.js +223 -0
- package/dist/testing.js.map +7 -0
- package/package.json +4 -3
package/dist/process-worker.js
CHANGED
|
@@ -2955,6 +2955,7 @@ function createSocketKernel(deps) {
|
|
|
2955
2955
|
name: (fd, peer) => guard(() => json({ op: "sock-name", fd: kfd(fd), peer })),
|
|
2956
2956
|
getopt: (fd, level, name) => guard(() => ({ value: json({ op: "sock-getopt", fd: kfd(fd), level, name }) })),
|
|
2957
2957
|
setopt: (fd, level, name, value2) => guard(() => done({ op: "sock-setopt", fd: kfd(fd), level, name, value: value2 })),
|
|
2958
|
+
resolve: (name, family = 4) => guard(() => json({ op: "sock-resolve", name, family })),
|
|
2958
2959
|
send: (fd, bytes, flags) => guard(() => {
|
|
2959
2960
|
const stream = socketAt(fd);
|
|
2960
2961
|
const nonblock = flags.dontwait === true || (stream.flags & O_NONBLOCK) !== 0;
|
|
@@ -6341,6 +6342,67 @@ var init_wasix_process = __esm({
|
|
|
6341
6342
|
}
|
|
6342
6343
|
});
|
|
6343
6344
|
|
|
6345
|
+
// src/kernel/net/routes.ts
|
|
6346
|
+
function ipv4Bytes(text) {
|
|
6347
|
+
const parts = text.split(".");
|
|
6348
|
+
if (parts.length !== 4 || !parts.every((p) => /^\d{1,3}$/.test(p))) return void 0;
|
|
6349
|
+
const bytes = parts.map(Number);
|
|
6350
|
+
return bytes.every((b) => b <= 255) ? bytes : void 0;
|
|
6351
|
+
}
|
|
6352
|
+
function ipv6Groups(text) {
|
|
6353
|
+
if (!text.includes(":")) return void 0;
|
|
6354
|
+
let canonical;
|
|
6355
|
+
try {
|
|
6356
|
+
canonical = new URL(`http://[${text}]/`).hostname.slice(1, -1);
|
|
6357
|
+
} catch {
|
|
6358
|
+
return void 0;
|
|
6359
|
+
}
|
|
6360
|
+
const [head, tail] = canonical.split("::");
|
|
6361
|
+
const part = (s) => s ? s.split(":").map((h) => Number.parseInt(h, 16)) : [];
|
|
6362
|
+
const front = part(head);
|
|
6363
|
+
const back = part(tail);
|
|
6364
|
+
return tail === void 0 ? front : [...front, ...new Array(8 - front.length - back.length).fill(0), ...back];
|
|
6365
|
+
}
|
|
6366
|
+
function toBits(values, width) {
|
|
6367
|
+
return values.reduce((acc, v) => acc << BigInt(width) | BigInt(v), 0n);
|
|
6368
|
+
}
|
|
6369
|
+
function addressBits(host) {
|
|
6370
|
+
const v4 = ipv4Bytes(host);
|
|
6371
|
+
if (v4) return { v6: false, bits: toBits(v4, 8) };
|
|
6372
|
+
const v6 = ipv6Groups(host);
|
|
6373
|
+
return v6 ? { v6: true, bits: toBits(v6, 16) } : void 0;
|
|
6374
|
+
}
|
|
6375
|
+
function parsePrefix(text) {
|
|
6376
|
+
const parts = text.trim().split("/");
|
|
6377
|
+
if (parts.length > 2) return void 0;
|
|
6378
|
+
const [address = "", size] = parts;
|
|
6379
|
+
const parsed = addressBits(address);
|
|
6380
|
+
if (!parsed) return void 0;
|
|
6381
|
+
const max = parsed.v6 ? 128 : 32;
|
|
6382
|
+
const length = size === void 0 ? max : /^\d{1,3}$/.test(size) ? Number(size) : -1;
|
|
6383
|
+
if (length < 0 || length > max) return void 0;
|
|
6384
|
+
return { ...parsed, length };
|
|
6385
|
+
}
|
|
6386
|
+
var HOST_ADDRESS, RESERVED;
|
|
6387
|
+
var init_routes = __esm({
|
|
6388
|
+
"src/kernel/net/routes.ts"() {
|
|
6389
|
+
"use strict";
|
|
6390
|
+
init_loopback_names();
|
|
6391
|
+
HOST_ADDRESS = HOST_LOOPBACK_ADDRESS.join(".");
|
|
6392
|
+
RESERVED = [
|
|
6393
|
+
"0.0.0.0/8",
|
|
6394
|
+
"127.0.0.0/8",
|
|
6395
|
+
"169.254.0.0/16",
|
|
6396
|
+
"224.0.0.0/4",
|
|
6397
|
+
"240.0.0.0/4",
|
|
6398
|
+
"::/96",
|
|
6399
|
+
"::ffff:0:0/96",
|
|
6400
|
+
"fe80::/10",
|
|
6401
|
+
"ff00::/8"
|
|
6402
|
+
].map((p) => parsePrefix(p));
|
|
6403
|
+
}
|
|
6404
|
+
});
|
|
6405
|
+
|
|
6344
6406
|
// src/process/wasi/wasix-sockets.ts
|
|
6345
6407
|
function readAddr(view, ptr) {
|
|
6346
6408
|
const tag = view.getUint8(ptr);
|
|
@@ -6382,25 +6444,27 @@ function writeAddr(view, ptr, addr) {
|
|
|
6382
6444
|
);
|
|
6383
6445
|
return;
|
|
6384
6446
|
}
|
|
6385
|
-
view.setUint8(ptr, INET4);
|
|
6386
6447
|
view.setUint16(ptr + 2, addr.port, true);
|
|
6448
|
+
const groups = ipv4(addr.host) ? void 0 : ipv6Groups(addr.host);
|
|
6449
|
+
if (groups) {
|
|
6450
|
+
view.setUint8(ptr, INET6);
|
|
6451
|
+
groups.forEach((g, i) => void view.setUint16(ptr + 4 + i * 2, g));
|
|
6452
|
+
return;
|
|
6453
|
+
}
|
|
6454
|
+
view.setUint8(ptr, INET4);
|
|
6387
6455
|
const octets = ipv4(addr.host) ?? [127, 0, 0, 1];
|
|
6388
6456
|
octets.forEach((b, i) => void view.setUint8(ptr + 4 + i, b));
|
|
6389
6457
|
}
|
|
6458
|
+
function ipBytes(host) {
|
|
6459
|
+
const groups = ipv4(host) ? void 0 : ipv6Groups(host);
|
|
6460
|
+
return groups ? groups.flatMap((g) => [g >> 8, g & 255]) : ipv4(host);
|
|
6461
|
+
}
|
|
6390
6462
|
function ipv4(host) {
|
|
6391
6463
|
const parts = host.split(".");
|
|
6392
6464
|
if (parts.length !== 4) return void 0;
|
|
6393
6465
|
const bytes = parts.map((p) => /^\d{1,3}$/.test(p) ? Number(p) : Number.NaN);
|
|
6394
6466
|
return bytes.every((b) => b >= 0 && b <= 255) ? bytes : void 0;
|
|
6395
6467
|
}
|
|
6396
|
-
function resolveName(name) {
|
|
6397
|
-
if (name === "localhost" || name === "localhost.localdomain" || name === "ip6-localhost") {
|
|
6398
|
-
return [127, 0, 0, 1];
|
|
6399
|
-
}
|
|
6400
|
-
if (name === "::1") return [127, 0, 0, 1];
|
|
6401
|
-
if (name.toLowerCase() === HOST_LOOPBACK) return [...HOST_LOOPBACK_ADDRESS];
|
|
6402
|
-
return ipv4(name);
|
|
6403
|
-
}
|
|
6404
6468
|
function wasixSocketImports(host, preview1) {
|
|
6405
6469
|
const { mem, fds, o } = host;
|
|
6406
6470
|
const call2 = (req) => o.kernel.call(req);
|
|
@@ -6492,14 +6556,19 @@ function wasixSocketImports(host, preview1) {
|
|
|
6492
6556
|
sock_set_opt_time: (fd) => void socket(fd),
|
|
6493
6557
|
sock_send_file: () => E.NOSYS,
|
|
6494
6558
|
resolve: (name, len, _port, addrs, naddrs, out) => {
|
|
6495
|
-
const
|
|
6496
|
-
|
|
6559
|
+
const found = call2({ op: "sock-resolve", name: mem.string(name, len), family: 0 });
|
|
6560
|
+
const ips = found.map(ipBytes).filter((ip) => ip !== void 0);
|
|
6561
|
+
if (ips.length === 0) throw new WasiError("ENOENT");
|
|
6497
6562
|
if (naddrs < 1) throw new WasiError("EINVAL");
|
|
6498
6563
|
const view = mem.view();
|
|
6499
|
-
|
|
6500
|
-
view.
|
|
6501
|
-
|
|
6502
|
-
|
|
6564
|
+
const count = Math.min(ips.length, naddrs);
|
|
6565
|
+
new Uint8Array(view.buffer, addrs, ADDR_IP_SIZE * count).fill(0);
|
|
6566
|
+
for (let i = 0; i < count; i++) {
|
|
6567
|
+
const at = addrs + i * ADDR_IP_SIZE;
|
|
6568
|
+
view.setUint8(at, ips[i].length === 4 ? INET4 : INET6);
|
|
6569
|
+
new Uint8Array(view.buffer, at + 2, ips[i].length).set(ips[i]);
|
|
6570
|
+
}
|
|
6571
|
+
view.setUint32(out, count, true);
|
|
6503
6572
|
}
|
|
6504
6573
|
};
|
|
6505
6574
|
}
|
|
@@ -6507,7 +6576,7 @@ var INET4, INET6, UNIX, STREAM, ADDR_IP_SIZE, LOOPBACK, OPTIONS;
|
|
|
6507
6576
|
var init_wasix_sockets = __esm({
|
|
6508
6577
|
"src/process/wasi/wasix-sockets.ts"() {
|
|
6509
6578
|
"use strict";
|
|
6510
|
-
|
|
6579
|
+
init_routes();
|
|
6511
6580
|
init_wasi_abi();
|
|
6512
6581
|
init_wasi_files();
|
|
6513
6582
|
INET4 = 1;
|
|
@@ -7016,7 +7085,7 @@ function firstOther(foreign) {
|
|
|
7016
7085
|
function accepted(imp, scope2) {
|
|
7017
7086
|
const { module, name, kind } = imp;
|
|
7018
7087
|
if (module === PREVIEW1 || module === WASIX) return true;
|
|
7019
|
-
if (!
|
|
7088
|
+
if (!RESERVED2.has(module) && (scope2.extended || scope2.wasi && kind === "function")) return true;
|
|
7020
7089
|
if (scope2.pie && (module === "GOT.mem" || module === "GOT.func")) return true;
|
|
7021
7090
|
if (scope2.pie && module === "env" && kind !== "memory") return true;
|
|
7022
7091
|
if (kind === "memory" && scope2.memory?.module === module && scope2.memory.name === name)
|
|
@@ -7044,7 +7113,7 @@ function unsupportedImport(module, memory, extended = false, foreign = {}) {
|
|
|
7044
7113
|
}
|
|
7045
7114
|
function linkImports(module, preview1, wasix, memory, threads, program = {}, foreign, slicc = {}) {
|
|
7046
7115
|
for (const ns of Object.keys(program)) {
|
|
7047
|
-
if (
|
|
7116
|
+
if (RESERVED2.has(ns) || ns === SLICC)
|
|
7048
7117
|
throw new Error(`the imports module may not define ${ns}`);
|
|
7049
7118
|
}
|
|
7050
7119
|
const imports = {
|
|
@@ -7352,7 +7421,7 @@ async function runWasiThread(init, port) {
|
|
|
7352
7421
|
throw e;
|
|
7353
7422
|
}
|
|
7354
7423
|
}
|
|
7355
|
-
var TRAPPED, PREVIEW1, WASIX, SLICC,
|
|
7424
|
+
var TRAPPED, PREVIEW1, WASIX, SLICC, RESERVED2, noErrno, FALLBACK_MAXIMUM_PAGES, LinkSync, DL_GEN, BACKTRACE_FRAMES;
|
|
7356
7425
|
var init_wasi_runtime = __esm({
|
|
7357
7426
|
"src/process/wasi/wasi-runtime.ts"() {
|
|
7358
7427
|
"use strict";
|
|
@@ -7378,7 +7447,7 @@ var init_wasi_runtime = __esm({
|
|
|
7378
7447
|
PREVIEW1 = "wasi_snapshot_preview1";
|
|
7379
7448
|
WASIX = "wasix_32v1";
|
|
7380
7449
|
SLICC = "slicc";
|
|
7381
|
-
|
|
7450
|
+
RESERVED2 = RESERVED_NAMESPACES;
|
|
7382
7451
|
noErrno = (key) => `imports ${key}: its result cannot carry ENOSYS, and this host does not provide it`;
|
|
7383
7452
|
FALLBACK_MAXIMUM_PAGES = 32768;
|
|
7384
7453
|
LinkSync = class {
|