@ai-ecoverse/slicc-kernel 1.47.3 → 1.48.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 +10 -0
- package/dist/kernel-worker.js +1 -0
- package/dist/kernel-worker.js.map +2 -2
- package/dist/node-process-worker.js +82 -9
- package/dist/node-process-worker.js.map +4 -4
- package/dist/node.js +1 -0
- package/dist/node.js.map +2 -2
- package/dist/process-worker.js +82 -9
- package/dist/process-worker.js.map +4 -4
- package/package.json +2 -2
|
@@ -5460,6 +5460,75 @@ var init_wasi_poll = __esm({
|
|
|
5460
5460
|
}
|
|
5461
5461
|
});
|
|
5462
5462
|
|
|
5463
|
+
// src/process/wasi/wasi-termios.ts
|
|
5464
|
+
function writeTermios(mem, ptr, termios) {
|
|
5465
|
+
mem.bytes(ptr, OSPEED + 4).fill(0);
|
|
5466
|
+
const v = mem.view();
|
|
5467
|
+
v.setUint32(ptr, termios.c_iflag, true);
|
|
5468
|
+
v.setUint32(ptr + 4, termios.c_oflag, true);
|
|
5469
|
+
v.setUint32(ptr + 8, termios.c_cflag, true);
|
|
5470
|
+
v.setUint32(ptr + 12, termios.c_lflag, true);
|
|
5471
|
+
for (let i = 0; i < NCCS; i++) v.setUint8(ptr + C_CC + i, termios.c_cc[i] ?? 0);
|
|
5472
|
+
v.setUint8(ptr + C_LINE, 0);
|
|
5473
|
+
v.setUint32(ptr + ISPEED, B38400, true);
|
|
5474
|
+
v.setUint32(ptr + OSPEED, B38400, true);
|
|
5475
|
+
}
|
|
5476
|
+
function readTermios(mem, ptr) {
|
|
5477
|
+
const v = mem.view();
|
|
5478
|
+
return {
|
|
5479
|
+
c_iflag: v.getUint32(ptr, true),
|
|
5480
|
+
c_oflag: v.getUint32(ptr + 4, true),
|
|
5481
|
+
c_cflag: v.getUint32(ptr + 8, true),
|
|
5482
|
+
c_lflag: v.getUint32(ptr + 12, true),
|
|
5483
|
+
c_cc: Array.from({ length: NCCS }, (_, i) => v.getUint8(ptr + C_CC + i))
|
|
5484
|
+
};
|
|
5485
|
+
}
|
|
5486
|
+
function sliccTty(mem, fds, kernel) {
|
|
5487
|
+
const { sys } = kernel;
|
|
5488
|
+
const terminal = (fd) => {
|
|
5489
|
+
const e = fds.find(fd);
|
|
5490
|
+
if (!e) throw new WasiError("EBADF");
|
|
5491
|
+
if (e.type !== "kernel" || fds.kind(fd, e) !== "tty") throw new WasiError("ENOTTY");
|
|
5492
|
+
return fd;
|
|
5493
|
+
};
|
|
5494
|
+
const needs = (value2) => {
|
|
5495
|
+
if (value2 === void 0) throw new WasiError("ENOTTY");
|
|
5496
|
+
return value2;
|
|
5497
|
+
};
|
|
5498
|
+
const setAttr = (fd, actions, ptr) => {
|
|
5499
|
+
if (actions < 0 || actions > TCSAFLUSH) throw new WasiError("EINVAL");
|
|
5500
|
+
const at = terminal(fd);
|
|
5501
|
+
needs(sys.tcsets);
|
|
5502
|
+
sys.tcsets?.(at, readTermios(mem, ptr));
|
|
5503
|
+
};
|
|
5504
|
+
const size = (fd, ptr) => {
|
|
5505
|
+
const [rows, cols] = needs(sys.winsize?.(terminal(fd)));
|
|
5506
|
+
mem.bytes(ptr, 8).fill(0);
|
|
5507
|
+
const v = mem.view();
|
|
5508
|
+
v.setUint16(ptr, rows, true);
|
|
5509
|
+
v.setUint16(ptr + 2, cols, true);
|
|
5510
|
+
};
|
|
5511
|
+
return {
|
|
5512
|
+
tcgetattr: (fd, ptr) => void writeTermios(mem, ptr, needs(sys.tcgets?.(terminal(fd)))),
|
|
5513
|
+
tcsetattr: (fd, actions, ptr) => void setAttr(fd, actions, ptr),
|
|
5514
|
+
winsize: (fd, ptr) => void size(fd, ptr)
|
|
5515
|
+
};
|
|
5516
|
+
}
|
|
5517
|
+
var NCCS, C_LINE, C_CC, ISPEED, OSPEED, B38400, TCSAFLUSH;
|
|
5518
|
+
var init_wasi_termios = __esm({
|
|
5519
|
+
"src/process/wasi/wasi-termios.ts"() {
|
|
5520
|
+
"use strict";
|
|
5521
|
+
init_wasi_files();
|
|
5522
|
+
NCCS = 32;
|
|
5523
|
+
C_LINE = 16;
|
|
5524
|
+
C_CC = 17;
|
|
5525
|
+
ISPEED = 52;
|
|
5526
|
+
OSPEED = 56;
|
|
5527
|
+
B38400 = 15;
|
|
5528
|
+
TCSAFLUSH = 2;
|
|
5529
|
+
}
|
|
5530
|
+
});
|
|
5531
|
+
|
|
5463
5532
|
// src/process/wasi/wasi-host.ts
|
|
5464
5533
|
function filetypeOf(s) {
|
|
5465
5534
|
if (!s) return FILETYPE.UNKNOWN;
|
|
@@ -5529,6 +5598,7 @@ var init_wasi_host = __esm({
|
|
|
5529
5598
|
init_wasi_files();
|
|
5530
5599
|
init_wasi_memory();
|
|
5531
5600
|
init_wasi_poll();
|
|
5601
|
+
init_wasi_termios();
|
|
5532
5602
|
WasiExit = class extends Error {
|
|
5533
5603
|
code;
|
|
5534
5604
|
constructor(code2) {
|
|
@@ -5587,6 +5657,9 @@ var init_wasi_host = __esm({
|
|
|
5587
5657
|
const umask = this.o.kernel.call({ op: "proc-umask" });
|
|
5588
5658
|
if (umask !== DEFAULT_UMASK) this.o.fs.chmod(path, mode & ~umask);
|
|
5589
5659
|
}
|
|
5660
|
+
sliccTtyImports() {
|
|
5661
|
+
return wrap(sliccTty(this.mem, this.fds, this.o.kernel));
|
|
5662
|
+
}
|
|
5590
5663
|
sliccFsImports() {
|
|
5591
5664
|
const { mem, fds } = this;
|
|
5592
5665
|
const at = (dirfd, p, l) => fds.resolve(dirfd, mem.string(p, l));
|
|
@@ -7929,11 +8002,7 @@ var init_wasix_host = __esm({
|
|
|
7929
8002
|
v.setUint8(ptr + 16, isTty(0));
|
|
7930
8003
|
v.setUint8(ptr + 17, isTty(1));
|
|
7931
8004
|
v.setUint8(ptr + 18, isTty(2));
|
|
7932
|
-
if (fd === void 0)
|
|
7933
|
-
v.setUint32(ptr, 80, true);
|
|
7934
|
-
v.setUint32(ptr + 4, 24, true);
|
|
7935
|
-
return;
|
|
7936
|
-
}
|
|
8005
|
+
if (fd === void 0) throw new WasiError("ENOTTY");
|
|
7937
8006
|
const [rows, cols] = host.o.kernel.sys.winsize?.(fd) ?? [24, 80];
|
|
7938
8007
|
const termios = host.o.kernel.sys.tcgets?.(fd);
|
|
7939
8008
|
v.setUint32(ptr, cols, true);
|
|
@@ -8082,15 +8151,16 @@ function unsupportedImport(module, memory, extended = false, foreign = {}) {
|
|
|
8082
8151
|
}
|
|
8083
8152
|
return void 0;
|
|
8084
8153
|
}
|
|
8085
|
-
function linkImports(module, preview1, wasix, memory, threads, program = {}, foreign, slicc = {}, sliccFs = {}) {
|
|
8154
|
+
function linkImports(module, preview1, wasix, memory, threads, program = {}, foreign, slicc = {}, sliccFs = {}, sliccTty2 = {}) {
|
|
8086
8155
|
for (const ns of Object.keys(program)) {
|
|
8087
|
-
if (RESERVED2.has(ns) || ns === SLICC || ns === SLICC_FS)
|
|
8156
|
+
if (RESERVED2.has(ns) || ns === SLICC || ns === SLICC_FS || ns === SLICC_TTY)
|
|
8088
8157
|
throw new Error(`the imports module may not define ${ns}`);
|
|
8089
8158
|
}
|
|
8090
8159
|
const imports = {
|
|
8091
8160
|
...program,
|
|
8092
8161
|
[SLICC]: { ...slicc },
|
|
8093
8162
|
[SLICC_FS]: { ...sliccFs },
|
|
8163
|
+
[SLICC_TTY]: { ...sliccTty2 },
|
|
8094
8164
|
[PREVIEW1]: preview1,
|
|
8095
8165
|
...wasix ? { [WASIX]: { ...wasix } } : {},
|
|
8096
8166
|
...threads ? { wasi: { "thread-spawn": (arg) => threads.spawn(arg) } } : {}
|
|
@@ -8219,6 +8289,7 @@ async function instantiate(host, module, memory, threads, {
|
|
|
8219
8289
|
);
|
|
8220
8290
|
const slicc = traced(stats, "slicc", host.sliccImports());
|
|
8221
8291
|
const sliccFs = traced(stats, "slicc_fs", host.sliccFsImports());
|
|
8292
|
+
const sliccTty2 = traced(stats, "slicc_tty", host.sliccTtyImports());
|
|
8222
8293
|
const hostImports = linkImports(
|
|
8223
8294
|
module,
|
|
8224
8295
|
preview1,
|
|
@@ -8228,7 +8299,8 @@ async function instantiate(host, module, memory, threads, {
|
|
|
8228
8299
|
extra,
|
|
8229
8300
|
foreign,
|
|
8230
8301
|
slicc,
|
|
8231
|
-
sliccFs
|
|
8302
|
+
sliccFs,
|
|
8303
|
+
sliccTty2
|
|
8232
8304
|
);
|
|
8233
8305
|
const imports = sync ? merge(hostImports, sync.linker.mainImports(module)) : hostImports;
|
|
8234
8306
|
instance = await WebAssembly.instantiate(module, imports);
|
|
@@ -8435,7 +8507,7 @@ async function runWasiThread(init, port3) {
|
|
|
8435
8507
|
throw e;
|
|
8436
8508
|
}
|
|
8437
8509
|
}
|
|
8438
|
-
var TRAPPED, PREVIEW1, WASIX, SLICC, SIGNAL_CALLBACK, takeDefault, SLICC_FS, RESERVED2, importsSigactionHook, noErrno, FALLBACK_MAXIMUM_PAGES, LinkSync, DL_GEN, BACKTRACE_FRAMES;
|
|
8510
|
+
var TRAPPED, PREVIEW1, WASIX, SLICC, SIGNAL_CALLBACK, takeDefault, SLICC_FS, SLICC_TTY, RESERVED2, importsSigactionHook, noErrno, FALLBACK_MAXIMUM_PAGES, LinkSync, DL_GEN, BACKTRACE_FRAMES;
|
|
8439
8511
|
var init_wasi_runtime = __esm({
|
|
8440
8512
|
"src/process/wasi/wasi-runtime.ts"() {
|
|
8441
8513
|
"use strict";
|
|
@@ -8468,6 +8540,7 @@ var init_wasi_runtime = __esm({
|
|
|
8468
8540
|
if (defaultAction(sig) === "terminate") throw new WasiExit(128 + sig);
|
|
8469
8541
|
};
|
|
8470
8542
|
SLICC_FS = "slicc_fs";
|
|
8543
|
+
SLICC_TTY = "slicc_tty";
|
|
8471
8544
|
RESERVED2 = RESERVED_NAMESPACES;
|
|
8472
8545
|
importsSigactionHook = (module) => WebAssembly.Module.imports(module).some((i) => i.module === SLICC && i.name === "sigaction_set");
|
|
8473
8546
|
noErrno = (key) => `imports ${key}: its result cannot carry ENOSYS, and this host does not provide it`;
|