@ai-ecoverse/slicc-kernel 1.168.0 → 1.169.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 +29 -25
- package/dist/index.js +39 -223
- package/dist/index.js.map +4 -4
- package/dist/kernel-worker.js +140 -11
- package/dist/kernel-worker.js.map +4 -4
- package/dist/meta.js.map +1 -1
- package/dist/node-process-worker.cjs +3 -1
- package/dist/node-process-worker.cjs.map +2 -2
- package/dist/node-process-worker.js +3 -1
- package/dist/node-process-worker.js.map +2 -2
- package/dist/node.js +141 -12
- package/dist/node.js.map +4 -4
- package/dist/process-worker.js +3 -1
- package/dist/process-worker.js.map +2 -2
- package/dist/types/index.d.ts +0 -1
- package/dist/types/kernel/package-swaps.d.ts +25 -0
- package/dist/types/kernel/proc-info.d.ts +6 -0
- package/dist/types/kernel/replacing.d.ts +1 -0
- package/dist/types/launcher.d.ts +2 -0
- package/package.json +2 -3
- package/dist/types/local-proxy-transport.d.ts +0 -39
package/dist/index.js
CHANGED
|
@@ -217,14 +217,14 @@ function bodyOf(source, head, method) {
|
|
|
217
217
|
}
|
|
218
218
|
return counted(source, size);
|
|
219
219
|
}
|
|
220
|
-
function stream(
|
|
220
|
+
function stream(chunks2, socket, signal) {
|
|
221
221
|
return new ReadableStream({
|
|
222
222
|
start(controller) {
|
|
223
223
|
signal?.addEventListener("abort", () => controller.error(signal.reason), { once: true });
|
|
224
224
|
},
|
|
225
225
|
async pull(controller) {
|
|
226
226
|
try {
|
|
227
|
-
const next = await
|
|
227
|
+
const next = await chunks2.next();
|
|
228
228
|
if (next.done) {
|
|
229
229
|
controller.close();
|
|
230
230
|
socket.close();
|
|
@@ -274,9 +274,9 @@ async function loopbackFetch(dial, input, options) {
|
|
|
274
274
|
if (!raw) throw errorWithCode("ECONNRESET: the connection closed before a response");
|
|
275
275
|
head = parseHead(raw);
|
|
276
276
|
} while (head.status >= 100 && head.status < 200);
|
|
277
|
-
const
|
|
278
|
-
if (!
|
|
279
|
-
return new Response(
|
|
277
|
+
const chunks2 = bodyOf(source, head, request.method);
|
|
278
|
+
if (!chunks2) socket.close();
|
|
279
|
+
return new Response(chunks2 ? stream(chunks2, socket, options.signal) : null, {
|
|
280
280
|
status: head.status,
|
|
281
281
|
statusText: head.statusText,
|
|
282
282
|
headers: head.headers
|
|
@@ -1063,7 +1063,7 @@ function sendableClose(code) {
|
|
|
1063
1063
|
function blockedReason(url, e) {
|
|
1064
1064
|
const name = e?.name;
|
|
1065
1065
|
if (name === "SecurityError" && url.startsWith("ws:")) {
|
|
1066
|
-
return `${url}: ws:// is blocked from an https page; use wss
|
|
1066
|
+
return `${url}: ws:// is blocked from an https page; use wss://, or link a slicc CLI (npx sliccy@next)`;
|
|
1067
1067
|
}
|
|
1068
1068
|
return `${url}: ${e instanceof Error ? e.message : String(e)}`;
|
|
1069
1069
|
}
|
|
@@ -1186,7 +1186,7 @@ function requestBody(request) {
|
|
|
1186
1186
|
return request.body ? { body: request.body } : {};
|
|
1187
1187
|
}
|
|
1188
1188
|
function fetchTransport(options = {}) {
|
|
1189
|
-
const
|
|
1189
|
+
const send = options.fetch ?? globalThis.fetch.bind(globalThis);
|
|
1190
1190
|
const Socket = options.webSocket === true ? globalThis.WebSocket : options.webSocket || void 0;
|
|
1191
1191
|
const headers = options.webSocketHeaders === true;
|
|
1192
1192
|
const redirect = options.redirect ?? "follow";
|
|
@@ -1203,7 +1203,7 @@ function fetchTransport(options = {}) {
|
|
|
1203
1203
|
async fetch(request) {
|
|
1204
1204
|
let response;
|
|
1205
1205
|
try {
|
|
1206
|
-
response = await
|
|
1206
|
+
response = await send(request.url, {
|
|
1207
1207
|
method: request.method,
|
|
1208
1208
|
headers: joinHeaders(request.headers),
|
|
1209
1209
|
...requestBody(request),
|
|
@@ -1700,10 +1700,10 @@ async function holdLock(locks) {
|
|
|
1700
1700
|
await granted.promise;
|
|
1701
1701
|
return { name, release: () => held.resolve() };
|
|
1702
1702
|
}
|
|
1703
|
-
function concat(
|
|
1704
|
-
const out = new Uint8Array(
|
|
1703
|
+
function concat(chunks2) {
|
|
1704
|
+
const out = new Uint8Array(chunks2.reduce((n, c) => n + c.length, 0));
|
|
1705
1705
|
let at = 0;
|
|
1706
|
-
for (const chunk of
|
|
1706
|
+
for (const chunk of chunks2) {
|
|
1707
1707
|
out.set(chunk, at);
|
|
1708
1708
|
at += chunk.length;
|
|
1709
1709
|
}
|
|
@@ -1753,8 +1753,8 @@ var Channel = class {
|
|
|
1753
1753
|
}
|
|
1754
1754
|
request(call, handlers = {}) {
|
|
1755
1755
|
const id = ++this.nextId;
|
|
1756
|
-
const { failure:
|
|
1757
|
-
if (
|
|
1756
|
+
const { failure: failure2 } = this;
|
|
1757
|
+
if (failure2) return { id, done: Promise.reject(failure2) };
|
|
1758
1758
|
const done = new Promise((resolve, reject) => {
|
|
1759
1759
|
this.pending.set(id, { resolve, reject, ...handlers });
|
|
1760
1760
|
this.port.postMessage({ ...call, id });
|
|
@@ -1919,10 +1919,10 @@ function endedOf(done, signal) {
|
|
|
1919
1919
|
}
|
|
1920
1920
|
async function runOn(channel, argv, opts) {
|
|
1921
1921
|
const { onStdout, onStderr, ...rest } = opts;
|
|
1922
|
-
const
|
|
1922
|
+
const chunks2 = { 1: [], 2: [] };
|
|
1923
1923
|
const live = { 1: new TextDecoder(), 2: new TextDecoder() };
|
|
1924
1924
|
const tee = (fd, on) => (bytes) => {
|
|
1925
|
-
|
|
1925
|
+
chunks2[fd].push(bytes);
|
|
1926
1926
|
on?.(live[fd].decode(bytes, { stream: true }));
|
|
1927
1927
|
};
|
|
1928
1928
|
const child = await spawnOn(channel, argv, {
|
|
@@ -1931,7 +1931,7 @@ async function runOn(channel, argv, opts) {
|
|
|
1931
1931
|
onStderr: tee(2, onStderr)
|
|
1932
1932
|
});
|
|
1933
1933
|
const { status, signal } = await child.ended;
|
|
1934
|
-
const text = (fd) => new TextDecoder().decode(concat(
|
|
1934
|
+
const text = (fd) => new TextDecoder().decode(concat(chunks2[fd]));
|
|
1935
1935
|
return {
|
|
1936
1936
|
pid: child.pid,
|
|
1937
1937
|
status,
|
|
@@ -1960,7 +1960,7 @@ async function terminalOn(channel, argv, opts) {
|
|
|
1960
1960
|
);
|
|
1961
1961
|
done.catch(started.reject);
|
|
1962
1962
|
const pid = await started.promise;
|
|
1963
|
-
const
|
|
1963
|
+
const send = (action) => void channel.call({ op: "terminal", terminal: id, ...action }).catch(() => void 0);
|
|
1964
1964
|
return {
|
|
1965
1965
|
pid,
|
|
1966
1966
|
exited: done,
|
|
@@ -1972,10 +1972,10 @@ async function terminalOn(channel, argv, opts) {
|
|
|
1972
1972
|
listener = next;
|
|
1973
1973
|
if (next) for (const bytes of backlog.splice(0)) next(bytes);
|
|
1974
1974
|
},
|
|
1975
|
-
write: (data) =>
|
|
1976
|
-
resize: (cols, rows) =>
|
|
1977
|
-
signal: (name) =>
|
|
1978
|
-
close: () =>
|
|
1975
|
+
write: (data) => send({ action: "write", bytes: bytesOf2(data) }),
|
|
1976
|
+
resize: (cols, rows) => send({ action: "resize", cols, rows }),
|
|
1977
|
+
signal: (name) => send({ action: "signal", signal: name }),
|
|
1978
|
+
close: () => send({ action: "close" })
|
|
1979
1979
|
};
|
|
1980
1980
|
}
|
|
1981
1981
|
function fsOn(channel) {
|
|
@@ -2111,187 +2111,6 @@ async function attachKernel(port, options = {}) {
|
|
|
2111
2111
|
};
|
|
2112
2112
|
}
|
|
2113
2113
|
|
|
2114
|
-
// src/local-proxy-transport.ts
|
|
2115
|
-
var PATH = "/api/fetch-proxy";
|
|
2116
|
-
var RAW_CONTENT_TYPE = "application/vnd.slicc.raw-fetch";
|
|
2117
|
-
var MAX_HEAD = 1024 * 1024;
|
|
2118
|
-
var MAX_REQUEST_BODY2 = 64 * 1024 * 1024;
|
|
2119
|
-
var PERMISSIONS = ["loopback-network", "local-network-access"];
|
|
2120
|
-
var LOOPBACK_PAGE = /^(127\.\d+\.\d+\.\d+|localhost|\[::1\])$/;
|
|
2121
|
-
var failure2 = (message, status = 502) => Object.assign(new Error(`local proxy: ${message}`), { status });
|
|
2122
|
-
function encodeHead(url, method, headers) {
|
|
2123
|
-
return JSON.stringify({ url, method, headers }).replace(
|
|
2124
|
-
/[\u007f-]/g,
|
|
2125
|
-
(c) => `\\u${c.charCodeAt(0).toString(16).padStart(4, "0")}`
|
|
2126
|
-
);
|
|
2127
|
-
}
|
|
2128
|
-
function hopHeaders(options, extra) {
|
|
2129
|
-
return new Headers({ "X-Bridge-Token": options.key, ...extra });
|
|
2130
|
-
}
|
|
2131
|
-
function send(options) {
|
|
2132
|
-
return options.fetch ?? globalThis.fetch.bind(globalThis);
|
|
2133
|
-
}
|
|
2134
|
-
async function refusalMessage(response) {
|
|
2135
|
-
const text = await response.text().catch(() => "");
|
|
2136
|
-
try {
|
|
2137
|
-
const parsed = JSON.parse(text);
|
|
2138
|
-
if (typeof parsed.error === "string") return parsed.error;
|
|
2139
|
-
} catch {
|
|
2140
|
-
}
|
|
2141
|
-
return text || response.statusText || `answered ${response.status}`;
|
|
2142
|
-
}
|
|
2143
|
-
async function refusal(response) {
|
|
2144
|
-
return failure2(await refusalMessage(response), response.ok ? 502 : response.status);
|
|
2145
|
-
}
|
|
2146
|
-
async function permission(permissions) {
|
|
2147
|
-
if (!permissions) return "unknown";
|
|
2148
|
-
for (const name of PERMISSIONS) {
|
|
2149
|
-
try {
|
|
2150
|
-
return (await permissions.query({ name })).state;
|
|
2151
|
-
} catch {
|
|
2152
|
-
}
|
|
2153
|
-
}
|
|
2154
|
-
return "unknown";
|
|
2155
|
-
}
|
|
2156
|
-
function isHead(value) {
|
|
2157
|
-
const head = value;
|
|
2158
|
-
return !!head && typeof head.status === "number" && typeof head.statusText === "string" && Array.isArray(head.headers) && head.headers.every(
|
|
2159
|
-
(pair) => Array.isArray(pair) && pair.length === 2 && typeof pair[0] === "string" && typeof pair[1] === "string"
|
|
2160
|
-
);
|
|
2161
|
-
}
|
|
2162
|
-
function concat2(a, b) {
|
|
2163
|
-
const out = new Uint8Array(a.byteLength + b.byteLength);
|
|
2164
|
-
out.set(a);
|
|
2165
|
-
out.set(b, a.byteLength);
|
|
2166
|
-
return out;
|
|
2167
|
-
}
|
|
2168
|
-
async function readHead(reader, idleMs) {
|
|
2169
|
-
let buffer = new Uint8Array(0);
|
|
2170
|
-
for (; ; ) {
|
|
2171
|
-
if (buffer.byteLength >= 4) {
|
|
2172
|
-
const length = new DataView(buffer.buffer, buffer.byteOffset, 4).getUint32(0);
|
|
2173
|
-
if (length > MAX_HEAD) throw failure2(`response head of ${length} bytes`);
|
|
2174
|
-
if (buffer.byteLength >= 4 + length) {
|
|
2175
|
-
let head;
|
|
2176
|
-
try {
|
|
2177
|
-
head = JSON.parse(new TextDecoder().decode(buffer.subarray(4, 4 + length)));
|
|
2178
|
-
} catch {
|
|
2179
|
-
}
|
|
2180
|
-
if (!isHead(head)) throw failure2("malformed response head");
|
|
2181
|
-
return { head, rest: buffer.subarray(4 + length) };
|
|
2182
|
-
}
|
|
2183
|
-
}
|
|
2184
|
-
const next = await readWithin(reader, idleMs);
|
|
2185
|
-
if (next.done) throw failure2("closed before the response head");
|
|
2186
|
-
buffer = concat2(buffer, next.value);
|
|
2187
|
-
}
|
|
2188
|
-
}
|
|
2189
|
-
async function* chunks2(rest, reader, idleMs) {
|
|
2190
|
-
try {
|
|
2191
|
-
if (rest.byteLength > 0) yield rest;
|
|
2192
|
-
for (let next = await readWithin(reader, idleMs); !next.done; next = await readWithin(reader, idleMs)) {
|
|
2193
|
-
if (next.value.byteLength > 0) yield next.value;
|
|
2194
|
-
}
|
|
2195
|
-
} finally {
|
|
2196
|
-
await reader.cancel().catch(() => void 0);
|
|
2197
|
-
}
|
|
2198
|
-
}
|
|
2199
|
-
async function checkLocalProxy(options) {
|
|
2200
|
-
const onLoopback = LOOPBACK_PAGE.test(globalThis.location?.hostname ?? "");
|
|
2201
|
-
const permissions = onLoopback ? void 0 : options.permissions ?? globalThis.navigator?.permissions;
|
|
2202
|
-
if (await permission(permissions) === "denied") return { state: "blocked" };
|
|
2203
|
-
let response;
|
|
2204
|
-
try {
|
|
2205
|
-
response = await send(options)(new URL(PATH, options.url), {
|
|
2206
|
-
method: "POST",
|
|
2207
|
-
headers: hopHeaders(options, { "X-Slicc-Raw-Probe": "1" }),
|
|
2208
|
-
credentials: "omit",
|
|
2209
|
-
mode: "cors"
|
|
2210
|
-
});
|
|
2211
|
-
} catch {
|
|
2212
|
-
const now = await permission(permissions);
|
|
2213
|
-
if (now === "denied") return { state: "blocked" };
|
|
2214
|
-
return {
|
|
2215
|
-
state: "unreachable",
|
|
2216
|
-
permission: now === "granted" || now === "prompt" ? now : "unknown"
|
|
2217
|
-
};
|
|
2218
|
-
}
|
|
2219
|
-
if (!response.ok) {
|
|
2220
|
-
return { state: "refused", status: response.status, error: await refusalMessage(response) };
|
|
2221
|
-
}
|
|
2222
|
-
const reply = await response.json().catch(() => null);
|
|
2223
|
-
if (!reply || typeof reply.rawFetch !== "number" || reply.rawFetch < 1 || typeof reply.requestBodyStreaming !== "boolean" || typeof reply.maxRequestBodyBytes !== "number") {
|
|
2224
|
-
return { state: "incompatible" };
|
|
2225
|
-
}
|
|
2226
|
-
return {
|
|
2227
|
-
state: "ready",
|
|
2228
|
-
probe: {
|
|
2229
|
-
rawFetch: reply.rawFetch,
|
|
2230
|
-
requestBodyStreaming: reply.requestBodyStreaming,
|
|
2231
|
-
maxRequestBodyBytes: reply.maxRequestBodyBytes,
|
|
2232
|
-
...typeof reply.kernelTunnel === "number" ? { kernelTunnel: reply.kernelTunnel } : {},
|
|
2233
|
-
...typeof reply.kernelPort === "number" ? { kernelPort: reply.kernelPort } : {},
|
|
2234
|
-
...typeof reply.cdp === "number" ? { cdp: reply.cdp } : {}
|
|
2235
|
-
}
|
|
2236
|
-
};
|
|
2237
|
-
}
|
|
2238
|
-
async function probeLocalProxy(options) {
|
|
2239
|
-
const status = await checkLocalProxy(options);
|
|
2240
|
-
return status.state === "ready" ? status.probe : null;
|
|
2241
|
-
}
|
|
2242
|
-
function localProxyTransport(options) {
|
|
2243
|
-
const endpoint = new URL(PATH, options.url);
|
|
2244
|
-
return {
|
|
2245
|
-
traits: {
|
|
2246
|
-
manualRedirects: true,
|
|
2247
|
-
encodedBodies: false,
|
|
2248
|
-
maxRequestBody: options.maxRequestBody ?? MAX_REQUEST_BODY2
|
|
2249
|
-
},
|
|
2250
|
-
async fetch(request) {
|
|
2251
|
-
let response;
|
|
2252
|
-
try {
|
|
2253
|
-
response = await send(options)(endpoint, {
|
|
2254
|
-
method: "POST",
|
|
2255
|
-
headers: hopHeaders(options, {
|
|
2256
|
-
"X-Slicc-Raw-Request": encodeHead(request.url, request.method, request.headers)
|
|
2257
|
-
}),
|
|
2258
|
-
...request.body ? { body: request.body } : {},
|
|
2259
|
-
signal: request.signal,
|
|
2260
|
-
credentials: "omit",
|
|
2261
|
-
mode: "cors"
|
|
2262
|
-
});
|
|
2263
|
-
} catch (e) {
|
|
2264
|
-
if (request.signal.aborted) throw e;
|
|
2265
|
-
throw failure2(`${endpoint.origin} is unreachable or refuses this origin`);
|
|
2266
|
-
}
|
|
2267
|
-
const type = response.headers.get("content-type") ?? "";
|
|
2268
|
-
if (response.status !== 200 || !type.startsWith(RAW_CONTENT_TYPE) || !response.body) {
|
|
2269
|
-
throw await refusal(response);
|
|
2270
|
-
}
|
|
2271
|
-
const reader = response.body.getReader();
|
|
2272
|
-
const idleMs = options.bodyIdleMs ?? BODY_IDLE_MS;
|
|
2273
|
-
let framed;
|
|
2274
|
-
try {
|
|
2275
|
-
framed = await readHead(reader, idleMs);
|
|
2276
|
-
} catch (e) {
|
|
2277
|
-
await reader.cancel().catch(() => void 0);
|
|
2278
|
-
throw e;
|
|
2279
|
-
}
|
|
2280
|
-
const body = chunks2(framed.rest, reader, idleMs);
|
|
2281
|
-
return {
|
|
2282
|
-
status: framed.head.status,
|
|
2283
|
-
statusText: framed.head.statusText,
|
|
2284
|
-
headers: framed.head.headers,
|
|
2285
|
-
body,
|
|
2286
|
-
cancel: async () => {
|
|
2287
|
-
await body.return(void 0);
|
|
2288
|
-
await reader.cancel().catch(() => void 0);
|
|
2289
|
-
}
|
|
2290
|
-
};
|
|
2291
|
-
}
|
|
2292
|
-
};
|
|
2293
|
-
}
|
|
2294
|
-
|
|
2295
2114
|
// src/mount/driver.ts
|
|
2296
2115
|
function fsError2(code, message = code) {
|
|
2297
2116
|
return Object.assign(new Error(message), { code });
|
|
@@ -2313,7 +2132,7 @@ function serveHostfsPort(port, transport) {
|
|
|
2313
2132
|
});
|
|
2314
2133
|
handles.clear();
|
|
2315
2134
|
};
|
|
2316
|
-
const
|
|
2135
|
+
const send = (reply, transfer = []) => port.postMessage(reply, transfer);
|
|
2317
2136
|
const pending = /* @__PURE__ */ new Set();
|
|
2318
2137
|
const track = (work) => {
|
|
2319
2138
|
pending.add(work);
|
|
@@ -2333,7 +2152,7 @@ function serveHostfsPort(port, transport) {
|
|
|
2333
2152
|
data
|
|
2334
2153
|
}) => {
|
|
2335
2154
|
const { id, op } = data;
|
|
2336
|
-
if (op === "ping") return
|
|
2155
|
+
if (op === "ping") return send({ id, pong: true });
|
|
2337
2156
|
if (op === "bye") return stop();
|
|
2338
2157
|
if (op === "cleanup")
|
|
2339
2158
|
return void Promise.allSettled([...pending]).then(() => answer(data.name, data.body)).catch(() => {
|
|
@@ -2345,12 +2164,12 @@ function serveHostfsPort(port, transport) {
|
|
|
2345
2164
|
try {
|
|
2346
2165
|
await transport.watch(
|
|
2347
2166
|
stop2.signal,
|
|
2348
|
-
(event) =>
|
|
2349
|
-
() =>
|
|
2167
|
+
(event) => send({ id, event }),
|
|
2168
|
+
() => send({ id, open: true })
|
|
2350
2169
|
);
|
|
2351
|
-
|
|
2170
|
+
send({ id, end: true });
|
|
2352
2171
|
} catch (err) {
|
|
2353
|
-
|
|
2172
|
+
send({ id, error: errorOf2(err) });
|
|
2354
2173
|
} finally {
|
|
2355
2174
|
watches.delete(id);
|
|
2356
2175
|
}
|
|
@@ -2367,18 +2186,18 @@ function serveHostfsPort(port, transport) {
|
|
|
2367
2186
|
)
|
|
2368
2187
|
);
|
|
2369
2188
|
const bytes = read.slice();
|
|
2370
|
-
return
|
|
2189
|
+
return send({ id, bytes }, [bytes.buffer]);
|
|
2371
2190
|
}
|
|
2372
2191
|
if (op === "write") {
|
|
2373
2192
|
await track(
|
|
2374
2193
|
transport.write(data.fh, data.offset, data.bytes)
|
|
2375
2194
|
);
|
|
2376
|
-
return
|
|
2195
|
+
return send({ id });
|
|
2377
2196
|
}
|
|
2378
2197
|
if (op !== "call") throw fsError2("EINVAL", `unknown hostfs port op ${op}`);
|
|
2379
|
-
|
|
2198
|
+
send({ id, result: await answer(data.name, data.body) });
|
|
2380
2199
|
} catch (err) {
|
|
2381
|
-
|
|
2200
|
+
send({ id, error: errorOf2(err) });
|
|
2382
2201
|
}
|
|
2383
2202
|
};
|
|
2384
2203
|
const stop = () => {
|
|
@@ -2662,7 +2481,7 @@ async function createKernel(options = {}) {
|
|
|
2662
2481
|
const worker = new Worker(url, { type: "module", name: "slicc-kernel" });
|
|
2663
2482
|
const pending = /* @__PURE__ */ new Map();
|
|
2664
2483
|
let nextId = 0;
|
|
2665
|
-
let
|
|
2484
|
+
let failure2;
|
|
2666
2485
|
const dials = dialer((req) => call(req));
|
|
2667
2486
|
const files = fileWatches(
|
|
2668
2487
|
(req) => request(req),
|
|
@@ -2679,7 +2498,7 @@ async function createKernel(options = {}) {
|
|
|
2679
2498
|
facades.close();
|
|
2680
2499
|
sealed.close();
|
|
2681
2500
|
approvals.close();
|
|
2682
|
-
|
|
2501
|
+
failure2 = error;
|
|
2683
2502
|
bridge?.close();
|
|
2684
2503
|
uplinks?.close();
|
|
2685
2504
|
for (const call2 of pending.values()) call2.reject(error);
|
|
@@ -2739,7 +2558,7 @@ async function createKernel(options = {}) {
|
|
|
2739
2558
|
});
|
|
2740
2559
|
function request(req, handlers = {}) {
|
|
2741
2560
|
const id = ++nextId;
|
|
2742
|
-
if (
|
|
2561
|
+
if (failure2) return { id, done: Promise.reject(failure2) };
|
|
2743
2562
|
const done = new Promise((resolve, reject) => {
|
|
2744
2563
|
pending.set(id, { resolve, reject, ...handlers });
|
|
2745
2564
|
worker.postMessage({ ...req, id });
|
|
@@ -2761,7 +2580,7 @@ async function createKernel(options = {}) {
|
|
|
2761
2580
|
);
|
|
2762
2581
|
done.catch(started.reject);
|
|
2763
2582
|
const pid = await started.promise;
|
|
2764
|
-
const
|
|
2583
|
+
const send = (action) => void call({ op: "terminal", terminal: id, ...action }).catch(() => void 0);
|
|
2765
2584
|
return {
|
|
2766
2585
|
pid,
|
|
2767
2586
|
exited: quiet(done.then((r) => endedOf2(r).status)),
|
|
@@ -2773,13 +2592,13 @@ async function createKernel(options = {}) {
|
|
|
2773
2592
|
listener = next;
|
|
2774
2593
|
if (next) for (const bytes of backlog.splice(0)) next(bytes);
|
|
2775
2594
|
},
|
|
2776
|
-
write: (data) =>
|
|
2595
|
+
write: (data) => send({
|
|
2777
2596
|
action: "write",
|
|
2778
2597
|
bytes: typeof data === "string" ? new TextEncoder().encode(data) : data
|
|
2779
2598
|
}),
|
|
2780
|
-
resize: (cols, rows) =>
|
|
2781
|
-
signal: (name) =>
|
|
2782
|
-
close: () =>
|
|
2599
|
+
resize: (cols, rows) => send({ action: "resize", cols, rows }),
|
|
2600
|
+
signal: (name) => send({ action: "signal", signal: name }),
|
|
2601
|
+
close: () => send({ action: "close" })
|
|
2783
2602
|
};
|
|
2784
2603
|
}
|
|
2785
2604
|
const { dial } = dials;
|
|
@@ -2822,11 +2641,8 @@ export {
|
|
|
2822
2641
|
KernelCallError,
|
|
2823
2642
|
KernelGoneError,
|
|
2824
2643
|
attachKernel,
|
|
2825
|
-
checkLocalProxy,
|
|
2826
2644
|
createKernel,
|
|
2827
2645
|
fetchTransport,
|
|
2828
|
-
localProxyTransport,
|
|
2829
|
-
probeLocalProxy,
|
|
2830
2646
|
serveHostfsPort
|
|
2831
2647
|
};
|
|
2832
2648
|
//# sourceMappingURL=index.js.map
|