@ai-ecoverse/slicc-kernel 1.64.2 → 1.65.1
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 +7 -1
- package/dist/index.js.map +2 -2
- package/dist/kernel-worker.js +314 -95
- package/dist/kernel-worker.js.map +4 -4
- package/dist/node-process-worker.js +362 -187
- package/dist/node-process-worker.js.map +4 -4
- package/dist/node.js +297 -76
- package/dist/node.js.map +4 -4
- package/dist/process-worker.js +362 -187
- package/dist/process-worker.js.map +4 -4
- package/package.json +1 -1
|
@@ -1165,16 +1165,16 @@ var init_cred = __esm({
|
|
|
1165
1165
|
});
|
|
1166
1166
|
|
|
1167
1167
|
// src/realm/sync-fs-wire.ts
|
|
1168
|
-
function parseSyncFsUsage(
|
|
1169
|
-
const u =
|
|
1168
|
+
function parseSyncFsUsage(json2) {
|
|
1169
|
+
const u = json2;
|
|
1170
1170
|
if (!u || typeof u.quota !== "number" || typeof u.usage !== "number") return null;
|
|
1171
1171
|
return { quota: u.quota, usage: u.usage };
|
|
1172
1172
|
}
|
|
1173
1173
|
function syncError(code2, label) {
|
|
1174
1174
|
return Object.assign(new Error(`${code2}: ${label}`), { code: code2 });
|
|
1175
1175
|
}
|
|
1176
|
-
function parseSyncFsStat(
|
|
1177
|
-
const s =
|
|
1176
|
+
function parseSyncFsStat(json2) {
|
|
1177
|
+
const s = json2;
|
|
1178
1178
|
if (!s || typeof s.isFile !== "boolean" || typeof s.isDirectory !== "boolean" || typeof s.size !== "number") {
|
|
1179
1179
|
return null;
|
|
1180
1180
|
}
|
|
@@ -2013,11 +2013,11 @@ var init_wasi_memory = __esm({
|
|
|
2013
2013
|
return at;
|
|
2014
2014
|
}
|
|
2015
2015
|
putStrings(list, ptrs, buf) {
|
|
2016
|
-
const
|
|
2016
|
+
const encoder5 = new TextEncoder();
|
|
2017
2017
|
const v = this.view();
|
|
2018
2018
|
let at = buf;
|
|
2019
2019
|
list.forEach((s, i) => {
|
|
2020
|
-
const b =
|
|
2020
|
+
const b = encoder5.encode(s);
|
|
2021
2021
|
v.setUint32(ptrs + i * 4, at, true);
|
|
2022
2022
|
this.bytes(at, b.length).set(b);
|
|
2023
2023
|
v.setUint8(at + b.length, 0);
|
|
@@ -2025,12 +2025,12 @@ var init_wasi_memory = __esm({
|
|
|
2025
2025
|
});
|
|
2026
2026
|
}
|
|
2027
2027
|
putSizes(list, countPtr, sizePtr) {
|
|
2028
|
-
const
|
|
2028
|
+
const encoder5 = new TextEncoder();
|
|
2029
2029
|
const v = this.view();
|
|
2030
2030
|
v.setUint32(countPtr, list.length, true);
|
|
2031
2031
|
v.setUint32(
|
|
2032
2032
|
sizePtr,
|
|
2033
|
-
list.reduce((n, s) => n +
|
|
2033
|
+
list.reduce((n, s) => n + encoder5.encode(s).length + 1, 0),
|
|
2034
2034
|
true
|
|
2035
2035
|
);
|
|
2036
2036
|
}
|
|
@@ -3746,14 +3746,32 @@ var init_js_kernel = __esm({
|
|
|
3746
3746
|
const result = await this.call(req);
|
|
3747
3747
|
return result.ok && result.kind === "bytes" ? result.bytes : new Uint8Array(0);
|
|
3748
3748
|
}
|
|
3749
|
-
async blocking(req, signal) {
|
|
3749
|
+
async blocking(req, signal, track) {
|
|
3750
3750
|
for (; ; ) {
|
|
3751
|
-
const id = await this.
|
|
3751
|
+
const id = await this.submit(req, track);
|
|
3752
3752
|
const result = await this.settled(id, signal);
|
|
3753
3753
|
if (result.ok) return result;
|
|
3754
3754
|
if (result.errno !== "EINTR") throw new JsCallError(result.errno, req.op);
|
|
3755
3755
|
}
|
|
3756
3756
|
}
|
|
3757
|
+
acks = [];
|
|
3758
|
+
ack(id) {
|
|
3759
|
+
this.acks.push(id);
|
|
3760
|
+
}
|
|
3761
|
+
async submit(req, track) {
|
|
3762
|
+
const ack = this.acks;
|
|
3763
|
+
this.acks = [];
|
|
3764
|
+
const r = await this.transport.call({
|
|
3765
|
+
op: "async-submit",
|
|
3766
|
+
req,
|
|
3767
|
+
...ack.length > 0 ? { ack } : {}
|
|
3768
|
+
});
|
|
3769
|
+
const id = r.ok && r.kind === "json" ? r.json : void 0;
|
|
3770
|
+
if (id !== void 0) track?.(id);
|
|
3771
|
+
this.deliver();
|
|
3772
|
+
if (id === void 0) throw new JsCallError(r.ok ? "EIO" : r.errno, "async-submit");
|
|
3773
|
+
return id;
|
|
3774
|
+
}
|
|
3757
3775
|
async settled(id, signal) {
|
|
3758
3776
|
for (; ; ) {
|
|
3759
3777
|
const seen = Atomics.load(this.header, SAB_I_ASYNC);
|
|
@@ -3955,6 +3973,165 @@ var init_js_children = __esm({
|
|
|
3955
3973
|
}
|
|
3956
3974
|
});
|
|
3957
3975
|
|
|
3976
|
+
// src/process/js/js-io.ts
|
|
3977
|
+
function typeOf(info) {
|
|
3978
|
+
if (info.meta && "dir" in info.meta) return "directory";
|
|
3979
|
+
if (info.meta && "device" in info.meta) return "device";
|
|
3980
|
+
if (info.tty || info.kind === "tty") return "tty";
|
|
3981
|
+
if (info.kind === "socket") return "socket";
|
|
3982
|
+
return info.kind === "file" ? "file" : "pipe";
|
|
3983
|
+
}
|
|
3984
|
+
function device(info) {
|
|
3985
|
+
return info.meta && "device" in info.meta ? info.meta : void 0;
|
|
3986
|
+
}
|
|
3987
|
+
function readDevice(info, max, random) {
|
|
3988
|
+
if (typeOf(info) === "directory") throw new JsCallError("EISDIR", "read");
|
|
3989
|
+
const dev = device(info);
|
|
3990
|
+
if (!dev) return void 0;
|
|
3991
|
+
if (dev.access === "write") throw new JsCallError("EBADF", "read");
|
|
3992
|
+
if (dev.device === "null") return new Uint8Array(0);
|
|
3993
|
+
const out = new Uint8Array(Math.min(max, CHUNK));
|
|
3994
|
+
if (dev.device === "urandom") random(out);
|
|
3995
|
+
return out;
|
|
3996
|
+
}
|
|
3997
|
+
function writeDevice(info) {
|
|
3998
|
+
if (typeOf(info) === "directory") throw new JsCallError("EISDIR", "write");
|
|
3999
|
+
const dev = device(info);
|
|
4000
|
+
if (!dev) return false;
|
|
4001
|
+
if (dev.access === "read") throw new JsCallError("EBADF", "write");
|
|
4002
|
+
if (dev.device === "full") throw new JsCallError("ENOSPC", "write");
|
|
4003
|
+
return true;
|
|
4004
|
+
}
|
|
4005
|
+
function brokenPipe(err, info) {
|
|
4006
|
+
return err instanceof JsCallError && err.code === "EPIPE" && typeOf(info) !== "socket";
|
|
4007
|
+
}
|
|
4008
|
+
function written(r, fallback) {
|
|
4009
|
+
return r.ok && r.kind === "json" && typeof r.json === "number" ? r.json : fallback;
|
|
4010
|
+
}
|
|
4011
|
+
function joined(parts, length) {
|
|
4012
|
+
if (parts.length === 1) return parts[0];
|
|
4013
|
+
const out = new Uint8Array(length);
|
|
4014
|
+
let at = 0;
|
|
4015
|
+
for (const part of parts) {
|
|
4016
|
+
out.set(part, at);
|
|
4017
|
+
at += part.length;
|
|
4018
|
+
}
|
|
4019
|
+
return out;
|
|
4020
|
+
}
|
|
4021
|
+
function fileWrite(fd, append, offset, body) {
|
|
4022
|
+
return append ? { op: "fd-write", fd, body } : { op: "fd-pwrite", fd, offset, body };
|
|
4023
|
+
}
|
|
4024
|
+
function isExclusive(o) {
|
|
4025
|
+
return o.create === true && o.exclusive === true;
|
|
4026
|
+
}
|
|
4027
|
+
function absent(err) {
|
|
4028
|
+
if (err instanceof JsCallError && err.code === "ENOENT") return void 0;
|
|
4029
|
+
throw err;
|
|
4030
|
+
}
|
|
4031
|
+
function checkOpen(abs, o, existing) {
|
|
4032
|
+
if (existing && isExclusive(o)) throw new JsCallError("EEXIST", abs);
|
|
4033
|
+
if (!existing && !o.create) throw new JsCallError("ENOENT", abs);
|
|
4034
|
+
if (existing?.isDirectory) throw new JsCallError("EISDIR", abs);
|
|
4035
|
+
}
|
|
4036
|
+
function flagsOf(o) {
|
|
4037
|
+
const write2 = o.write || o.append || o.truncate;
|
|
4038
|
+
const access = write2 ? o.read ? O_RDWR3 : O_WRONLY3 : 0;
|
|
4039
|
+
return access | (o.append ? O_APPEND3 : 0);
|
|
4040
|
+
}
|
|
4041
|
+
function openRequest(abs, o) {
|
|
4042
|
+
return {
|
|
4043
|
+
op: "fd-open-vfs",
|
|
4044
|
+
path: abs,
|
|
4045
|
+
flags: flagsOf(o),
|
|
4046
|
+
position: 0,
|
|
4047
|
+
...isExclusive(o) ? { exclusive: true } : o.create ? { create: true } : { existing: true },
|
|
4048
|
+
...o.truncate ? { truncate: true } : {}
|
|
4049
|
+
};
|
|
4050
|
+
}
|
|
4051
|
+
function index2(n, what) {
|
|
4052
|
+
if (!Number.isSafeInteger(n) || n < 0) throw new JsCallError("EINVAL", what);
|
|
4053
|
+
}
|
|
4054
|
+
var CHUNK, MAX_IO, O_WRONLY3, O_RDWR3, O_APPEND3;
|
|
4055
|
+
var init_js_io = __esm({
|
|
4056
|
+
"src/process/js/js-io.ts"() {
|
|
4057
|
+
"use strict";
|
|
4058
|
+
init_js_kernel();
|
|
4059
|
+
CHUNK = 64 * 1024;
|
|
4060
|
+
MAX_IO = 1024 * 1024;
|
|
4061
|
+
O_WRONLY3 = 1;
|
|
4062
|
+
O_RDWR3 = 2;
|
|
4063
|
+
O_APPEND3 = 1024;
|
|
4064
|
+
}
|
|
4065
|
+
});
|
|
4066
|
+
|
|
4067
|
+
// src/process/js/js-exit.ts
|
|
4068
|
+
function json(r) {
|
|
4069
|
+
return r.ok && r.kind === "json" ? r.json : void 0;
|
|
4070
|
+
}
|
|
4071
|
+
function restoreMode(lane, { terminal, fd, termios }) {
|
|
4072
|
+
const open = json(lane({ op: "fd-list" })) ?? [];
|
|
4073
|
+
const on = open.filter((entry) => entry.terminal === terminal);
|
|
4074
|
+
const at = (on.find((entry) => entry.fd === fd) ?? on[0])?.fd;
|
|
4075
|
+
if (at !== void 0) {
|
|
4076
|
+
lane({ op: "tty-set", fd: at, termios });
|
|
4077
|
+
return;
|
|
4078
|
+
}
|
|
4079
|
+
const opened = json(lane({ op: "fd-open-tty", name: terminal }));
|
|
4080
|
+
if (typeof opened !== "number") return;
|
|
4081
|
+
lane({ op: "tty-set", fd: opened, termios });
|
|
4082
|
+
lane({ op: "fd-close", fd: opened });
|
|
4083
|
+
}
|
|
4084
|
+
function writeOut(lane, fd, data) {
|
|
4085
|
+
let at = 0;
|
|
4086
|
+
while (at < data.length) {
|
|
4087
|
+
const body = data.subarray(at, at + MAX_IO);
|
|
4088
|
+
const r = lane({ op: "fd-write", fd, body });
|
|
4089
|
+
if (!r.ok && r.errno === "EINTR") continue;
|
|
4090
|
+
if (!r.ok) return false;
|
|
4091
|
+
const n = written(r, body.length);
|
|
4092
|
+
if (n <= 0) return false;
|
|
4093
|
+
at += n;
|
|
4094
|
+
}
|
|
4095
|
+
return true;
|
|
4096
|
+
}
|
|
4097
|
+
function progress(result, len) {
|
|
4098
|
+
if (!result) return len;
|
|
4099
|
+
if (result.ok) return written(result, len);
|
|
4100
|
+
return result.errno === "EINTR" ? 0 : -1;
|
|
4101
|
+
}
|
|
4102
|
+
function settled(lane, writes) {
|
|
4103
|
+
const inFlight = writes.filter((w) => w.op !== void 0);
|
|
4104
|
+
const out = /* @__PURE__ */ new Map();
|
|
4105
|
+
if (inFlight.length === 0) return out;
|
|
4106
|
+
const r = lane({ op: "async-settle", ids: inFlight.map((w) => w.op) });
|
|
4107
|
+
const results = r.ok && r.kind === "json" ? r.json : [];
|
|
4108
|
+
inFlight.forEach((w, i) => {
|
|
4109
|
+
const result = results[i];
|
|
4110
|
+
out.set(w, progress(result, w.len));
|
|
4111
|
+
});
|
|
4112
|
+
return out;
|
|
4113
|
+
}
|
|
4114
|
+
function exitAtOnce(lane, writes, modes, status2) {
|
|
4115
|
+
const done = settled(lane, writes);
|
|
4116
|
+
const broken = /* @__PURE__ */ new Set();
|
|
4117
|
+
for (const w of writes) {
|
|
4118
|
+
const sent = done.get(w);
|
|
4119
|
+
if (sent === -1) broken.add(w.fd);
|
|
4120
|
+
if (broken.has(w.fd)) continue;
|
|
4121
|
+
if (!writeOut(lane, w.fd, w.data.subarray(w.at + (sent ?? 0)))) broken.add(w.fd);
|
|
4122
|
+
}
|
|
4123
|
+
for (const mode of modes) restoreMode(lane, mode);
|
|
4124
|
+
lane({ op: "proc-exit", status: status2 & 255 });
|
|
4125
|
+
const parked = new Int32Array(new SharedArrayBuffer(4));
|
|
4126
|
+
for (; ; ) Atomics.wait(parked, 0, 0);
|
|
4127
|
+
}
|
|
4128
|
+
var init_js_exit = __esm({
|
|
4129
|
+
"src/process/js/js-exit.ts"() {
|
|
4130
|
+
"use strict";
|
|
4131
|
+
init_js_io();
|
|
4132
|
+
}
|
|
4133
|
+
});
|
|
4134
|
+
|
|
3958
4135
|
// src/process/js/js-fetch.ts
|
|
3959
4136
|
function withoutFragment(url) {
|
|
3960
4137
|
url.hash = "";
|
|
@@ -4187,7 +4364,7 @@ function fetchOp(kernel) {
|
|
|
4187
4364
|
let r;
|
|
4188
4365
|
try {
|
|
4189
4366
|
signal.throwIfAborted();
|
|
4190
|
-
r = await kernel.blocking({ op: "net-read", handle, max:
|
|
4367
|
+
r = await kernel.blocking({ op: "net-read", handle, max: CHUNK2 }, signal);
|
|
4191
4368
|
} catch (err) {
|
|
4192
4369
|
settle();
|
|
4193
4370
|
await close(handle);
|
|
@@ -4276,12 +4453,12 @@ function fetchOp(kernel) {
|
|
|
4276
4453
|
}
|
|
4277
4454
|
};
|
|
4278
4455
|
}
|
|
4279
|
-
var
|
|
4456
|
+
var CHUNK2, MAX_REDIRECTS, NULL_BODY, REDIRECTS, BODY_HEADERS, DECODED, CREDENTIALS, OVER, TOKEN, QUOTABLE, SPACE, BASE64, SLICE;
|
|
4280
4457
|
var init_js_fetch = __esm({
|
|
4281
4458
|
"src/process/js/js-fetch.ts"() {
|
|
4282
4459
|
"use strict";
|
|
4283
4460
|
init_js_kernel();
|
|
4284
|
-
|
|
4461
|
+
CHUNK2 = 64 * 1024;
|
|
4285
4462
|
MAX_REDIRECTS = 20;
|
|
4286
4463
|
NULL_BODY = /* @__PURE__ */ new Set([101, 103, 204, 205, 304]);
|
|
4287
4464
|
REDIRECTS = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]);
|
|
@@ -4303,97 +4480,6 @@ var init_js_fetch = __esm({
|
|
|
4303
4480
|
}
|
|
4304
4481
|
});
|
|
4305
4482
|
|
|
4306
|
-
// src/process/js/js-io.ts
|
|
4307
|
-
function typeOf(info) {
|
|
4308
|
-
if (info.meta && "dir" in info.meta) return "directory";
|
|
4309
|
-
if (info.meta && "device" in info.meta) return "device";
|
|
4310
|
-
if (info.tty || info.kind === "tty") return "tty";
|
|
4311
|
-
if (info.kind === "socket") return "socket";
|
|
4312
|
-
return info.kind === "file" ? "file" : "pipe";
|
|
4313
|
-
}
|
|
4314
|
-
function device(info) {
|
|
4315
|
-
return info.meta && "device" in info.meta ? info.meta : void 0;
|
|
4316
|
-
}
|
|
4317
|
-
function readDevice(info, max, random) {
|
|
4318
|
-
if (typeOf(info) === "directory") throw new JsCallError("EISDIR", "read");
|
|
4319
|
-
const dev = device(info);
|
|
4320
|
-
if (!dev) return void 0;
|
|
4321
|
-
if (dev.access === "write") throw new JsCallError("EBADF", "read");
|
|
4322
|
-
if (dev.device === "null") return new Uint8Array(0);
|
|
4323
|
-
const out = new Uint8Array(Math.min(max, CHUNK2));
|
|
4324
|
-
if (dev.device === "urandom") random(out);
|
|
4325
|
-
return out;
|
|
4326
|
-
}
|
|
4327
|
-
function writeDevice(info) {
|
|
4328
|
-
if (typeOf(info) === "directory") throw new JsCallError("EISDIR", "write");
|
|
4329
|
-
const dev = device(info);
|
|
4330
|
-
if (!dev) return false;
|
|
4331
|
-
if (dev.access === "read") throw new JsCallError("EBADF", "write");
|
|
4332
|
-
if (dev.device === "full") throw new JsCallError("ENOSPC", "write");
|
|
4333
|
-
return true;
|
|
4334
|
-
}
|
|
4335
|
-
function brokenPipe(err, info) {
|
|
4336
|
-
return err instanceof JsCallError && err.code === "EPIPE" && typeOf(info) !== "socket";
|
|
4337
|
-
}
|
|
4338
|
-
function written(r, fallback) {
|
|
4339
|
-
return r.ok && r.kind === "json" && typeof r.json === "number" ? r.json : fallback;
|
|
4340
|
-
}
|
|
4341
|
-
function joined(parts, length) {
|
|
4342
|
-
if (parts.length === 1) return parts[0];
|
|
4343
|
-
const out = new Uint8Array(length);
|
|
4344
|
-
let at = 0;
|
|
4345
|
-
for (const part of parts) {
|
|
4346
|
-
out.set(part, at);
|
|
4347
|
-
at += part.length;
|
|
4348
|
-
}
|
|
4349
|
-
return out;
|
|
4350
|
-
}
|
|
4351
|
-
function fileWrite(fd, append, offset, body) {
|
|
4352
|
-
return append ? { op: "fd-write", fd, body } : { op: "fd-pwrite", fd, offset, body };
|
|
4353
|
-
}
|
|
4354
|
-
function isExclusive(o) {
|
|
4355
|
-
return o.create === true && o.exclusive === true;
|
|
4356
|
-
}
|
|
4357
|
-
function absent(err) {
|
|
4358
|
-
if (err instanceof JsCallError && err.code === "ENOENT") return void 0;
|
|
4359
|
-
throw err;
|
|
4360
|
-
}
|
|
4361
|
-
function checkOpen(abs, o, existing) {
|
|
4362
|
-
if (existing && isExclusive(o)) throw new JsCallError("EEXIST", abs);
|
|
4363
|
-
if (!existing && !o.create) throw new JsCallError("ENOENT", abs);
|
|
4364
|
-
if (existing?.isDirectory) throw new JsCallError("EISDIR", abs);
|
|
4365
|
-
}
|
|
4366
|
-
function flagsOf(o) {
|
|
4367
|
-
const write2 = o.write || o.append || o.truncate;
|
|
4368
|
-
const access = write2 ? o.read ? O_RDWR3 : O_WRONLY3 : 0;
|
|
4369
|
-
return access | (o.append ? O_APPEND3 : 0);
|
|
4370
|
-
}
|
|
4371
|
-
function openRequest(abs, o) {
|
|
4372
|
-
return {
|
|
4373
|
-
op: "fd-open-vfs",
|
|
4374
|
-
path: abs,
|
|
4375
|
-
flags: flagsOf(o),
|
|
4376
|
-
position: 0,
|
|
4377
|
-
...isExclusive(o) ? { exclusive: true } : o.create ? { create: true } : { existing: true },
|
|
4378
|
-
...o.truncate ? { truncate: true } : {}
|
|
4379
|
-
};
|
|
4380
|
-
}
|
|
4381
|
-
function index2(n, what) {
|
|
4382
|
-
if (!Number.isSafeInteger(n) || n < 0) throw new JsCallError("EINVAL", what);
|
|
4383
|
-
}
|
|
4384
|
-
var CHUNK2, MAX_IO, O_WRONLY3, O_RDWR3, O_APPEND3;
|
|
4385
|
-
var init_js_io = __esm({
|
|
4386
|
-
"src/process/js/js-io.ts"() {
|
|
4387
|
-
"use strict";
|
|
4388
|
-
init_js_kernel();
|
|
4389
|
-
CHUNK2 = 64 * 1024;
|
|
4390
|
-
MAX_IO = 1024 * 1024;
|
|
4391
|
-
O_WRONLY3 = 1;
|
|
4392
|
-
O_RDWR3 = 2;
|
|
4393
|
-
O_APPEND3 = 1024;
|
|
4394
|
-
}
|
|
4395
|
-
});
|
|
4396
|
-
|
|
4397
4483
|
// src/process/js/js-net.ts
|
|
4398
4484
|
function errnoName(errno2) {
|
|
4399
4485
|
const found = Object.entries(E).find(([, n]) => n === errno2);
|
|
@@ -4535,6 +4621,67 @@ var init_js_net = __esm({
|
|
|
4535
4621
|
}
|
|
4536
4622
|
});
|
|
4537
4623
|
|
|
4624
|
+
// src/process/js/js-run.ts
|
|
4625
|
+
function stdioOf(how) {
|
|
4626
|
+
if (how === void 0) return "pipe";
|
|
4627
|
+
if (!STDIO3.has(how)) throw new JsCallError("EINVAL", "run");
|
|
4628
|
+
return how;
|
|
4629
|
+
}
|
|
4630
|
+
function limit(value2) {
|
|
4631
|
+
if (value2 === void 0 || value2 === Number.POSITIVE_INFINITY) return value2;
|
|
4632
|
+
if (!(value2 >= 0)) throw new JsCallError("EINVAL", "run");
|
|
4633
|
+
return value2;
|
|
4634
|
+
}
|
|
4635
|
+
function decodeRun(bytes, stdout, stderr) {
|
|
4636
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
4637
|
+
const size = view.getUint32(0, true);
|
|
4638
|
+
const outcome = JSON.parse(new TextDecoder().decode(bytes.subarray(4, 4 + size)));
|
|
4639
|
+
const out = bytes.slice(4 + size, 4 + size + outcome.out);
|
|
4640
|
+
const err = bytes.slice(4 + size + outcome.out, 4 + size + outcome.out + outcome.err);
|
|
4641
|
+
return {
|
|
4642
|
+
pid: outcome.pid,
|
|
4643
|
+
status: outcome.status,
|
|
4644
|
+
...outcome.signal !== void 0 ? { signal: outcome.signal } : {},
|
|
4645
|
+
...stdout === "pipe" ? { stdout: out } : {},
|
|
4646
|
+
...stderr === "pipe" ? { stderr: err } : {},
|
|
4647
|
+
...outcome.error ? { error: outcome.error } : {}
|
|
4648
|
+
};
|
|
4649
|
+
}
|
|
4650
|
+
function runSync(kernel, d, o) {
|
|
4651
|
+
const [file] = o.argv;
|
|
4652
|
+
if (file === void 0) throw new JsCallError("EINVAL", "run");
|
|
4653
|
+
const stdout = stdioOf(o.stdout);
|
|
4654
|
+
const stderr = stdioOf(o.stderr);
|
|
4655
|
+
const input = typeof o.input === "string" ? encoder2.encode(o.input) : o.input;
|
|
4656
|
+
const maxBuffer = limit(o.maxBuffer);
|
|
4657
|
+
const timeout = limit(o.timeout);
|
|
4658
|
+
const bytes = kernel.bytes({
|
|
4659
|
+
op: "proc-run",
|
|
4660
|
+
file,
|
|
4661
|
+
argv: [...o.argv],
|
|
4662
|
+
env: { ...o.env ?? d.env },
|
|
4663
|
+
cwd: o.cwd === void 0 ? d.cwd : d.resolve(o.cwd),
|
|
4664
|
+
stdin: stdioOf(o.stdin),
|
|
4665
|
+
...input ? { input } : {},
|
|
4666
|
+
stdout,
|
|
4667
|
+
stderr,
|
|
4668
|
+
...maxBuffer !== void 0 && maxBuffer !== Number.POSITIVE_INFINITY ? { maxBuffer } : {},
|
|
4669
|
+
...maxBuffer === Number.POSITIVE_INFINITY ? { maxBuffer: Number.MAX_SAFE_INTEGER } : {},
|
|
4670
|
+
...timeout !== void 0 && timeout !== Number.POSITIVE_INFINITY ? { timeoutMs: timeout } : {},
|
|
4671
|
+
killSignal: d.signal(o.killSignal ?? "SIGTERM")
|
|
4672
|
+
});
|
|
4673
|
+
return decodeRun(bytes, stdout, stderr);
|
|
4674
|
+
}
|
|
4675
|
+
var encoder2, STDIO3;
|
|
4676
|
+
var init_js_run = __esm({
|
|
4677
|
+
"src/process/js/js-run.ts"() {
|
|
4678
|
+
"use strict";
|
|
4679
|
+
init_js_kernel();
|
|
4680
|
+
encoder2 = new TextEncoder();
|
|
4681
|
+
STDIO3 = /* @__PURE__ */ new Set(["pipe", "ignore", "inherit"]);
|
|
4682
|
+
}
|
|
4683
|
+
});
|
|
4684
|
+
|
|
4538
4685
|
// src/realm/sync-sab-bridge.ts
|
|
4539
4686
|
function createSyncSabTransport(sab, port3, deps = {}) {
|
|
4540
4687
|
const views = sabViews(sab);
|
|
@@ -4614,7 +4761,7 @@ function createSyncFsSabBridge(transport, opts = {}) {
|
|
|
4614
4761
|
if (r.ok && r.kind === "bytes") return r.bytes;
|
|
4615
4762
|
throw errnoError("EIO", path);
|
|
4616
4763
|
}
|
|
4617
|
-
function
|
|
4764
|
+
function json2(req, path) {
|
|
4618
4765
|
const r = run(req, path);
|
|
4619
4766
|
if (r.ok && r.kind === "json") return r.json;
|
|
4620
4767
|
throw errnoError("EIO", path);
|
|
@@ -4642,31 +4789,31 @@ function createSyncFsSabBridge(transport, opts = {}) {
|
|
|
4642
4789
|
return {
|
|
4643
4790
|
...io({}),
|
|
4644
4791
|
pinned: (handle) => io({ handle }),
|
|
4645
|
-
kept: (handle) =>
|
|
4792
|
+
kept: (handle) => json2({ op: "kept", path: "/", handle }, "/") === true,
|
|
4646
4793
|
keptStat: (handle) => {
|
|
4647
|
-
const s = parseSyncFsStat(
|
|
4794
|
+
const s = parseSyncFsStat(json2({ op: "stat", path: "/", handle }, "/"));
|
|
4648
4795
|
if (!s) throw errnoError("EIO", "/");
|
|
4649
4796
|
return s;
|
|
4650
4797
|
},
|
|
4651
4798
|
stat: (path) => {
|
|
4652
|
-
const s = parseSyncFsStat(
|
|
4799
|
+
const s = parseSyncFsStat(json2({ op: "stat", path }, path));
|
|
4653
4800
|
if (!s) throw errnoError("EIO", path);
|
|
4654
4801
|
return s;
|
|
4655
4802
|
},
|
|
4656
4803
|
lstat: (path) => {
|
|
4657
|
-
const s = parseSyncFsStat(
|
|
4804
|
+
const s = parseSyncFsStat(json2({ op: "lstat", path }, path));
|
|
4658
4805
|
if (!s) throw errnoError("EIO", path);
|
|
4659
4806
|
return s;
|
|
4660
4807
|
},
|
|
4661
4808
|
readdir: (path) => {
|
|
4662
|
-
const list =
|
|
4809
|
+
const list = json2({ op: "readdir", path }, path);
|
|
4663
4810
|
if (!Array.isArray(list) || !list.every((s) => typeof s === "string")) {
|
|
4664
4811
|
throw errnoError("EIO", path);
|
|
4665
4812
|
}
|
|
4666
4813
|
return list;
|
|
4667
4814
|
},
|
|
4668
4815
|
readdirStat: (path) => {
|
|
4669
|
-
const list =
|
|
4816
|
+
const list = json2({ op: "readdir-stat", path }, path);
|
|
4670
4817
|
if (!Array.isArray(list)) throw errnoError("EIO", path);
|
|
4671
4818
|
return list.map((entry) => {
|
|
4672
4819
|
if (!Array.isArray(entry) || typeof entry[0] !== "string") throw errnoError("EIO", path);
|
|
@@ -4677,7 +4824,7 @@ function createSyncFsSabBridge(transport, opts = {}) {
|
|
|
4677
4824
|
});
|
|
4678
4825
|
},
|
|
4679
4826
|
exists: (path) => {
|
|
4680
|
-
const v =
|
|
4827
|
+
const v = json2({ op: "exists", path }, path);
|
|
4681
4828
|
if (typeof v !== "boolean") throw errnoError("EIO", path);
|
|
4682
4829
|
return v;
|
|
4683
4830
|
},
|
|
@@ -4703,7 +4850,7 @@ function createSyncFsSabBridge(transport, opts = {}) {
|
|
|
4703
4850
|
run({ op: "symlink", path: linkPath, arg2: target }, linkPath);
|
|
4704
4851
|
},
|
|
4705
4852
|
readlink: (path) => {
|
|
4706
|
-
const target =
|
|
4853
|
+
const target = json2({ op: "readlink", path }, path);
|
|
4707
4854
|
if (typeof target !== "string") throw errnoError("EIO", path);
|
|
4708
4855
|
return target;
|
|
4709
4856
|
},
|
|
@@ -4733,11 +4880,11 @@ function createSyncFsSabBridge(transport, opts = {}) {
|
|
|
4733
4880
|
},
|
|
4734
4881
|
hold: (path, held, open, handle, want = 0) => {
|
|
4735
4882
|
const mode = (held ? 1 : 0) | (open ? 2 : 0);
|
|
4736
|
-
if (mode === 3) return
|
|
4883
|
+
if (mode === 3) return json2({ op: "hold", path, mode: mode | want }, path);
|
|
4737
4884
|
run({ op: "hold", path, mode, ...handle !== void 0 ? { handle } : {} }, path);
|
|
4738
4885
|
return void 0;
|
|
4739
4886
|
},
|
|
4740
|
-
statfs: (path = "/") => parseSyncFsUsage(
|
|
4887
|
+
statfs: (path = "/") => parseSyncFsUsage(json2({ op: "statfs", path }, path))
|
|
4741
4888
|
};
|
|
4742
4889
|
}
|
|
4743
4890
|
var init_sync_sab_bridge = __esm({
|
|
@@ -4763,7 +4910,7 @@ function syncOps(kernel, shared) {
|
|
|
4763
4910
|
infos.set(fd, got);
|
|
4764
4911
|
return got;
|
|
4765
4912
|
};
|
|
4766
|
-
const read2 = (fd, max =
|
|
4913
|
+
const read2 = (fd, max = CHUNK) => {
|
|
4767
4914
|
index2(max, "read");
|
|
4768
4915
|
const emulated = readDevice(info(fd), max, shared.random);
|
|
4769
4916
|
if (emulated) return emulated;
|
|
@@ -4771,7 +4918,7 @@ function syncOps(kernel, shared) {
|
|
|
4771
4918
|
return r.ok && r.kind === "bytes" ? r.bytes : new Uint8Array(0);
|
|
4772
4919
|
};
|
|
4773
4920
|
const write2 = (fd, data) => {
|
|
4774
|
-
const bytes = typeof data === "string" ?
|
|
4921
|
+
const bytes = typeof data === "string" ? encoder3.encode(data) : data;
|
|
4775
4922
|
const i = info(fd);
|
|
4776
4923
|
if (writeDevice(i)) return;
|
|
4777
4924
|
let at = 0;
|
|
@@ -4914,14 +5061,14 @@ function syncPathOps(kernel, resolve, statOf, open) {
|
|
|
4914
5061
|
writeFile(path, data) {
|
|
4915
5062
|
const file = open(path, { write: true, create: true, truncate: true });
|
|
4916
5063
|
try {
|
|
4917
|
-
file.write(0, typeof data === "string" ?
|
|
5064
|
+
file.write(0, typeof data === "string" ? encoder3.encode(data) : data);
|
|
4918
5065
|
} finally {
|
|
4919
5066
|
file.close();
|
|
4920
5067
|
}
|
|
4921
5068
|
}
|
|
4922
5069
|
};
|
|
4923
5070
|
}
|
|
4924
|
-
var
|
|
5071
|
+
var encoder3, JsSyncKernel;
|
|
4925
5072
|
var init_js_sync = __esm({
|
|
4926
5073
|
"src/process/js/js-sync.ts"() {
|
|
4927
5074
|
"use strict";
|
|
@@ -4930,7 +5077,7 @@ var init_js_sync = __esm({
|
|
|
4930
5077
|
init_sync_sab_bridge();
|
|
4931
5078
|
init_js_io();
|
|
4932
5079
|
init_js_kernel();
|
|
4933
|
-
|
|
5080
|
+
encoder3 = new TextEncoder();
|
|
4934
5081
|
JsSyncKernel = class {
|
|
4935
5082
|
lane;
|
|
4936
5083
|
kernel;
|
|
@@ -5038,7 +5185,8 @@ function ttyOps(kernel) {
|
|
|
5038
5185
|
await back.catch(() => void 0);
|
|
5039
5186
|
}
|
|
5040
5187
|
};
|
|
5041
|
-
|
|
5188
|
+
const modes = () => [...saved].reverse().map(([terminal, { fd, termios }]) => ({ terminal, fd, termios }));
|
|
5189
|
+
return { tty, restore, modes };
|
|
5042
5190
|
}
|
|
5043
5191
|
var BRKINT, INPCK, ISTRIP, ICRNL, IXON, ONLCR, CS8, ISIG, ICANON, ECHO, IEXTEN, VTIME, VMIN;
|
|
5044
5192
|
var init_js_tty = __esm({
|
|
@@ -5129,14 +5277,14 @@ function websocketOp(kernel) {
|
|
|
5129
5277
|
finish();
|
|
5130
5278
|
};
|
|
5131
5279
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
5132
|
-
let
|
|
5280
|
+
let settled2 = false;
|
|
5133
5281
|
let readDone = false;
|
|
5134
5282
|
const release = () => {
|
|
5135
|
-
if (!
|
|
5283
|
+
if (!settled2 || !readDone || freed) return;
|
|
5136
5284
|
finish();
|
|
5137
5285
|
};
|
|
5138
5286
|
kernel.blocking({ op: "net-ws-wait", handle }, stop.signal).then((r) => {
|
|
5139
|
-
|
|
5287
|
+
settled2 = true;
|
|
5140
5288
|
settle(r.json);
|
|
5141
5289
|
release();
|
|
5142
5290
|
}).catch(lose);
|
|
@@ -5184,7 +5332,7 @@ function websocketOp(kernel) {
|
|
|
5184
5332
|
async write(chunk, controller) {
|
|
5185
5333
|
stop.signal.throwIfAborted();
|
|
5186
5334
|
const send = async (body) => {
|
|
5187
|
-
if (
|
|
5335
|
+
if (settled2) throw new JsCallError("EPIPE", "the websocket is closed");
|
|
5188
5336
|
return await kernel.json({ op: "net-ws-send", handle, ...body });
|
|
5189
5337
|
};
|
|
5190
5338
|
let buffered = await send(typeof chunk === "string" ? { text: chunk } : { body: chunk });
|
|
@@ -5244,6 +5392,41 @@ function resolvePath(cwd, path) {
|
|
|
5244
5392
|
}
|
|
5245
5393
|
return `/${parts.join("/")}`;
|
|
5246
5394
|
}
|
|
5395
|
+
function writer(kernel, info, pid) {
|
|
5396
|
+
const writes = /* @__PURE__ */ new Set();
|
|
5397
|
+
const sendAll = async (fd, data, i, w, signal) => {
|
|
5398
|
+
while (w.at < data.length) {
|
|
5399
|
+
const body = data.subarray(w.at, w.at + MAX_IO);
|
|
5400
|
+
w.len = body.length;
|
|
5401
|
+
try {
|
|
5402
|
+
w.at += signal ? await sendSome(kernel, fd, body, signal) : written(
|
|
5403
|
+
await kernel.blocking({ op: "fd-write", fd, body }, void 0, (id) => {
|
|
5404
|
+
if (w.op !== void 0) kernel.ack(w.op);
|
|
5405
|
+
w.op = id;
|
|
5406
|
+
}),
|
|
5407
|
+
body.length
|
|
5408
|
+
);
|
|
5409
|
+
if (w.op !== void 0) kernel.ack(w.op);
|
|
5410
|
+
w.op = void 0;
|
|
5411
|
+
} catch (err) {
|
|
5412
|
+
if (brokenPipe(err, i)) await kernel.call({ op: "proc-kill", pid, sig: SIG.PIPE });
|
|
5413
|
+
throw err;
|
|
5414
|
+
}
|
|
5415
|
+
}
|
|
5416
|
+
};
|
|
5417
|
+
const writeAll = async (fd, data, signal) => {
|
|
5418
|
+
const w = { fd, data, at: 0, len: 0 };
|
|
5419
|
+
if (!signal) writes.add(w);
|
|
5420
|
+
try {
|
|
5421
|
+
const i = await info(fd);
|
|
5422
|
+
if (writeDevice(i)) return;
|
|
5423
|
+
await sendAll(fd, data, i, w, signal);
|
|
5424
|
+
} finally {
|
|
5425
|
+
writes.delete(w);
|
|
5426
|
+
}
|
|
5427
|
+
};
|
|
5428
|
+
return { writes, writeAll };
|
|
5429
|
+
}
|
|
5247
5430
|
function createContext(o) {
|
|
5248
5431
|
const { kernel } = o;
|
|
5249
5432
|
const infos = /* @__PURE__ */ new Map();
|
|
@@ -5268,36 +5451,23 @@ function createContext(o) {
|
|
|
5268
5451
|
infos.set(fd, got);
|
|
5269
5452
|
return got;
|
|
5270
5453
|
};
|
|
5271
|
-
const read2 = async (fd, max =
|
|
5454
|
+
const read2 = async (fd, max = CHUNK, signal) => {
|
|
5272
5455
|
index2(max, "read");
|
|
5273
5456
|
const emulated = readDevice(await info(fd), max, random);
|
|
5274
5457
|
if (emulated) return emulated;
|
|
5275
5458
|
return readPipe(kernel, fd, Math.min(max, MAX_IO), signal);
|
|
5276
5459
|
};
|
|
5277
|
-
const writeAll =
|
|
5278
|
-
const i = await info(fd);
|
|
5279
|
-
if (writeDevice(i)) return;
|
|
5280
|
-
let at = 0;
|
|
5281
|
-
while (at < data.length) {
|
|
5282
|
-
const body = data.subarray(at, at + MAX_IO);
|
|
5283
|
-
try {
|
|
5284
|
-
at += signal ? await sendSome(kernel, fd, body, signal) : written(await kernel.blocking({ op: "fd-write", fd, body }), body.length);
|
|
5285
|
-
} catch (err) {
|
|
5286
|
-
if (brokenPipe(err, i)) await kernel.call({ op: "proc-kill", pid: o.pid, sig: SIG.PIPE });
|
|
5287
|
-
throw err;
|
|
5288
|
-
}
|
|
5289
|
-
}
|
|
5290
|
-
};
|
|
5460
|
+
const { writes, writeAll } = writer(kernel, info, o.pid);
|
|
5291
5461
|
const write2 = (fd, data) => {
|
|
5292
|
-
const bytes = typeof data === "string" ?
|
|
5462
|
+
const bytes = typeof data === "string" ? encoder4.encode(data) : data;
|
|
5293
5463
|
let settle;
|
|
5294
|
-
const
|
|
5295
|
-
pending.add(
|
|
5464
|
+
const settled2 = new Promise((resolve2) => settle = resolve2);
|
|
5465
|
+
pending.add(settled2);
|
|
5296
5466
|
return (async () => {
|
|
5297
5467
|
try {
|
|
5298
5468
|
await writeAll(fd, bytes);
|
|
5299
5469
|
} finally {
|
|
5300
|
-
pending.delete(
|
|
5470
|
+
pending.delete(settled2);
|
|
5301
5471
|
settle();
|
|
5302
5472
|
}
|
|
5303
5473
|
})();
|
|
@@ -5330,14 +5500,17 @@ function createContext(o) {
|
|
|
5330
5500
|
return handle.file;
|
|
5331
5501
|
};
|
|
5332
5502
|
const fs = pathOps(kernel, resolve, statOf, open);
|
|
5333
|
-
const
|
|
5334
|
-
|
|
5335
|
-
resolve,
|
|
5336
|
-
random,
|
|
5337
|
-
infos,
|
|
5338
|
-
handles
|
|
5339
|
-
});
|
|
5503
|
+
const lane = o.lane ?? laneOf(void 0);
|
|
5504
|
+
const syncKernel = new JsSyncKernel(lane, kernel, unwind);
|
|
5340
5505
|
const terminal = ttyOps(kernel);
|
|
5506
|
+
const sync = {
|
|
5507
|
+
...syncOps(syncKernel, { pid: o.pid, resolve, random, infos, handles }),
|
|
5508
|
+
run: (options) => runSync(syncKernel, { env: o.env, cwd: o.cwd, resolve, signal: signalNumber }, options),
|
|
5509
|
+
exit: (status2 = 0) => {
|
|
5510
|
+
exiting ??= status2 & 255;
|
|
5511
|
+
return exitAtOnce(lane, [...writes], terminal.modes(), exiting);
|
|
5512
|
+
}
|
|
5513
|
+
};
|
|
5341
5514
|
const io = { read: read2, send: writeAll, close: (fd) => ctx.close(fd) };
|
|
5342
5515
|
const children = childOps(kernel, io, { env: o.env, cwd: o.cwd, signal: signalNumber });
|
|
5343
5516
|
const strays = o.strays ?? { exception: /* @__PURE__ */ new Set(), rejection: /* @__PURE__ */ new Set() };
|
|
@@ -5511,24 +5684,26 @@ function pathOps(kernel, resolve, statOf, open) {
|
|
|
5511
5684
|
async writeFile(path, data) {
|
|
5512
5685
|
const file = await open(path, { write: true, create: true, truncate: true });
|
|
5513
5686
|
try {
|
|
5514
|
-
await file.write(0, typeof data === "string" ?
|
|
5687
|
+
await file.write(0, typeof data === "string" ? encoder4.encode(data) : data);
|
|
5515
5688
|
} finally {
|
|
5516
5689
|
await file.close();
|
|
5517
5690
|
}
|
|
5518
5691
|
}
|
|
5519
5692
|
};
|
|
5520
5693
|
}
|
|
5521
|
-
var JsExit,
|
|
5694
|
+
var JsExit, encoder4;
|
|
5522
5695
|
var init_js_context = __esm({
|
|
5523
5696
|
"src/process/js/js-context.ts"() {
|
|
5524
5697
|
"use strict";
|
|
5525
5698
|
init_signals();
|
|
5526
5699
|
init_sync_fs_wire();
|
|
5527
5700
|
init_js_children();
|
|
5701
|
+
init_js_exit();
|
|
5528
5702
|
init_js_fetch();
|
|
5529
5703
|
init_js_io();
|
|
5530
5704
|
init_js_kernel();
|
|
5531
5705
|
init_js_net();
|
|
5706
|
+
init_js_run();
|
|
5532
5707
|
init_js_sync();
|
|
5533
5708
|
init_js_tty();
|
|
5534
5709
|
init_js_websocket();
|
|
@@ -5540,7 +5715,7 @@ var init_js_context = __esm({
|
|
|
5540
5715
|
this.status = status2;
|
|
5541
5716
|
}
|
|
5542
5717
|
};
|
|
5543
|
-
|
|
5718
|
+
encoder4 = new TextEncoder();
|
|
5544
5719
|
}
|
|
5545
5720
|
});
|
|
5546
5721
|
|
|
@@ -8411,7 +8586,7 @@ function createSocketKernel(deps) {
|
|
|
8411
8586
|
if (!r.ok) throw new SyscallError(r.errno);
|
|
8412
8587
|
return r;
|
|
8413
8588
|
};
|
|
8414
|
-
const
|
|
8589
|
+
const json2 = (req) => {
|
|
8415
8590
|
const r = call2(req);
|
|
8416
8591
|
return r.ok && r.kind === "json" ? r.json : void 0;
|
|
8417
8592
|
};
|
|
@@ -8451,9 +8626,9 @@ function createSocketKernel(deps) {
|
|
|
8451
8626
|
return stream.fd;
|
|
8452
8627
|
};
|
|
8453
8628
|
return {
|
|
8454
|
-
socket: (domain, nonblock, cloexec) => guard(() => install(
|
|
8629
|
+
socket: (domain, nonblock, cloexec) => guard(() => install(json2({ op: "sock-open", domain }), nonblock, cloexec)),
|
|
8455
8630
|
socketpair: (domain, nonblock, cloexec) => guard(() => {
|
|
8456
|
-
const [a, b] =
|
|
8631
|
+
const [a, b] = json2({ op: "sock-pair", domain });
|
|
8457
8632
|
let first;
|
|
8458
8633
|
try {
|
|
8459
8634
|
first = install(a, nonblock, cloexec);
|
|
@@ -8488,7 +8663,7 @@ function createSocketKernel(deps) {
|
|
|
8488
8663
|
fd: listener.sliccKernelFd,
|
|
8489
8664
|
nonblock: (listener.flags & O_NONBLOCK2) !== 0
|
|
8490
8665
|
};
|
|
8491
|
-
const got =
|
|
8666
|
+
const got = json2(req);
|
|
8492
8667
|
return { fd: install(got.fd, nonblock, cloexec), peer: got.peer };
|
|
8493
8668
|
}),
|
|
8494
8669
|
connect: (fd, addr) => guard(() => {
|
|
@@ -8502,10 +8677,10 @@ function createSocketKernel(deps) {
|
|
|
8502
8677
|
});
|
|
8503
8678
|
}),
|
|
8504
8679
|
shutdown: (fd, how) => guard(() => done({ op: "sock-shutdown", fd: kfd(fd), how })),
|
|
8505
|
-
name: (fd, peer) => guard(() =>
|
|
8506
|
-
getopt: (fd, level, name2) => guard(() => ({ value:
|
|
8680
|
+
name: (fd, peer) => guard(() => json2({ op: "sock-name", fd: kfd(fd), peer })),
|
|
8681
|
+
getopt: (fd, level, name2) => guard(() => ({ value: json2({ op: "sock-getopt", fd: kfd(fd), level, name: name2 }) })),
|
|
8507
8682
|
setopt: (fd, level, name2, value2) => guard(() => done({ op: "sock-setopt", fd: kfd(fd), level, name: name2, value: value2 })),
|
|
8508
|
-
resolve: (name2, family = 4) => guard(() =>
|
|
8683
|
+
resolve: (name2, family = 4) => guard(() => json2({ op: "sock-resolve", name: name2, family })),
|
|
8509
8684
|
send: (fd, bytes, flags) => guard(() => {
|
|
8510
8685
|
const stream = socketAt(fd);
|
|
8511
8686
|
const nonblock = flags.dontwait === true || (stream.flags & O_NONBLOCK2) !== 0;
|
|
@@ -8923,7 +9098,7 @@ function kernelSys(transport) {
|
|
|
8923
9098
|
if (!r.ok) throw new SyscallError(r.errno);
|
|
8924
9099
|
return r;
|
|
8925
9100
|
};
|
|
8926
|
-
const
|
|
9101
|
+
const json2 = (r) => r.ok && r.kind === "json" ? r.json : void 0;
|
|
8927
9102
|
return {
|
|
8928
9103
|
read(fd, max, opts) {
|
|
8929
9104
|
const flags = {
|
|
@@ -8940,20 +9115,20 @@ function kernelSys(transport) {
|
|
|
8940
9115
|
body: bytes,
|
|
8941
9116
|
...opts?.nonblock ? { nonblock: true } : {}
|
|
8942
9117
|
};
|
|
8943
|
-
const n =
|
|
9118
|
+
const n = json2(call2(req, `fd-write ${fd}`));
|
|
8944
9119
|
return typeof n === "number" ? n : bytes.length;
|
|
8945
9120
|
},
|
|
8946
9121
|
close(fd) {
|
|
8947
9122
|
call2({ op: "fd-close", fd }, `fd-close ${fd}`);
|
|
8948
9123
|
},
|
|
8949
9124
|
pipe() {
|
|
8950
|
-
return
|
|
9125
|
+
return json2(call2({ op: "fd-pipe" }, "fd-pipe"));
|
|
8951
9126
|
},
|
|
8952
9127
|
poll(fd) {
|
|
8953
|
-
return
|
|
9128
|
+
return json2(call2({ op: "fd-poll", fd }, `fd-poll ${fd}`));
|
|
8954
9129
|
},
|
|
8955
9130
|
openVfs(path, flags, position, opts) {
|
|
8956
|
-
return
|
|
9131
|
+
return json2(
|
|
8957
9132
|
call2(
|
|
8958
9133
|
{
|
|
8959
9134
|
op: "fd-open-vfs",
|
|
@@ -8973,7 +9148,7 @@ function kernelSys(transport) {
|
|
|
8973
9148
|
);
|
|
8974
9149
|
},
|
|
8975
9150
|
seek(fd, offset, whence) {
|
|
8976
|
-
return
|
|
9151
|
+
return json2(call2({ op: "fd-seek", fd, offset, whence }, `fd-seek ${fd}`));
|
|
8977
9152
|
},
|
|
8978
9153
|
flush(fd) {
|
|
8979
9154
|
call2({ op: "fd-flush", fd }, `fd-flush ${fd}`);
|
|
@@ -8983,64 +9158,64 @@ function kernelSys(transport) {
|
|
|
8983
9158
|
return r.ok && r.kind === "bytes" ? r.bytes : new Uint8Array(0);
|
|
8984
9159
|
},
|
|
8985
9160
|
pwrite(fd, bytes, at) {
|
|
8986
|
-
return
|
|
9161
|
+
return json2(
|
|
8987
9162
|
call2({ op: "fd-pwrite", fd, offset: at, body: bytes }, `fd-pwrite ${fd}`)
|
|
8988
9163
|
);
|
|
8989
9164
|
},
|
|
8990
9165
|
isatty(fd) {
|
|
8991
|
-
return
|
|
9166
|
+
return json2(call2({ op: "fd-info", fd }, `fd-info ${fd}`))?.tty === true;
|
|
8992
9167
|
},
|
|
8993
9168
|
ttyName(fd) {
|
|
8994
|
-
return
|
|
9169
|
+
return json2(call2({ op: "fd-info", fd }, `fd-info ${fd}`))?.name;
|
|
8995
9170
|
},
|
|
8996
9171
|
kind(fd) {
|
|
8997
|
-
return
|
|
9172
|
+
return json2(call2({ op: "fd-info", fd }, `fd-info ${fd}`))?.kind;
|
|
8998
9173
|
},
|
|
8999
9174
|
heldMeta(fd) {
|
|
9000
|
-
return
|
|
9175
|
+
return json2(call2({ op: "fd-info", fd }, `fd-info ${fd}`)).meta;
|
|
9001
9176
|
},
|
|
9002
9177
|
access(fd) {
|
|
9003
|
-
return
|
|
9178
|
+
return json2(call2({ op: "fd-info", fd }, `fd-info ${fd}`)).access;
|
|
9004
9179
|
},
|
|
9005
9180
|
size(fd) {
|
|
9006
|
-
return
|
|
9181
|
+
return json2(call2({ op: "fd-vfs-stat", fd }, `fd-vfs-stat ${fd}`)).size;
|
|
9007
9182
|
},
|
|
9008
9183
|
ttyNames() {
|
|
9009
|
-
return
|
|
9184
|
+
return json2(call2({ op: "fd-tty-names" }, "fd-tty-names"));
|
|
9010
9185
|
},
|
|
9011
9186
|
ttyOwner(name2) {
|
|
9012
|
-
return
|
|
9187
|
+
return json2(call2({ op: "fd-tty-owner", name: name2 }, `fd-tty-owner ${name2}`));
|
|
9013
9188
|
},
|
|
9014
9189
|
openTty(name2) {
|
|
9015
9190
|
const req = name2 === void 0 ? { op: "fd-open-tty" } : { op: "fd-open-tty", name: name2 };
|
|
9016
|
-
return
|
|
9191
|
+
return json2(call2(req, `fd-open-tty ${name2 ?? ""}`));
|
|
9017
9192
|
},
|
|
9018
9193
|
tcgets(fd) {
|
|
9019
|
-
return
|
|
9194
|
+
return json2(call2({ op: "tty-get", fd }, `tty-get ${fd}`));
|
|
9020
9195
|
},
|
|
9021
9196
|
tcsets(fd, termios, flush) {
|
|
9022
9197
|
call2({ op: "tty-set", fd, termios, ...flush ? { flush } : {} }, `tty-set ${fd}`);
|
|
9023
9198
|
},
|
|
9024
9199
|
winsize(fd) {
|
|
9025
|
-
return
|
|
9200
|
+
return json2(call2({ op: "tty-winsz", fd }, `tty-winsz ${fd}`));
|
|
9026
9201
|
},
|
|
9027
9202
|
openPty() {
|
|
9028
|
-
return
|
|
9203
|
+
return json2(call2({ op: "pty-open" }, "pty-open"));
|
|
9029
9204
|
},
|
|
9030
9205
|
openPts(n, noctty) {
|
|
9031
|
-
return
|
|
9206
|
+
return json2(call2({ op: "pty-slave-open", n, noctty }, `pty-slave-open ${n}`));
|
|
9032
9207
|
},
|
|
9033
9208
|
ptyNumbers() {
|
|
9034
|
-
return
|
|
9209
|
+
return json2(call2({ op: "pty-list" }, "pty-list"));
|
|
9035
9210
|
},
|
|
9036
9211
|
procList() {
|
|
9037
|
-
return
|
|
9212
|
+
return json2(call2({ op: "proc-list" }, "proc-list"));
|
|
9038
9213
|
},
|
|
9039
9214
|
mountList() {
|
|
9040
|
-
return
|
|
9215
|
+
return json2(call2({ op: "mount-list" }, "mount-list"));
|
|
9041
9216
|
},
|
|
9042
9217
|
ptyNumber(fd) {
|
|
9043
|
-
return
|
|
9218
|
+
return json2(call2({ op: "pty-number", fd }, `pty-number ${fd}`));
|
|
9044
9219
|
},
|
|
9045
9220
|
ptyLock(fd, lock) {
|
|
9046
9221
|
call2({ op: "pty-lock", fd, lock }, `pty-lock ${fd}`);
|
|
@@ -9164,8 +9339,8 @@ async function runWasmProcess(init, port3, deps = {}) {
|
|
|
9164
9339
|
}
|
|
9165
9340
|
};
|
|
9166
9341
|
const sys = kernelSys(transport);
|
|
9167
|
-
const
|
|
9168
|
-
const say = (fd) => (text) => sys.write(fd,
|
|
9342
|
+
const encoder5 = new TextEncoder();
|
|
9343
|
+
const say = (fd) => (text) => sys.write(fd, encoder5.encode(`${text}
|
|
9169
9344
|
`));
|
|
9170
9345
|
let ready;
|
|
9171
9346
|
let failed5;
|