@volter/tabnode 0.5.8 → 0.5.9
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/dist/assets/{runtime-worker-Cl9uKRen.js → runtime-worker-CezP_cM0.js} +10 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.mjs +19 -3
- package/dist/node-process-host.d.ts +2 -0
- package/dist/process-tokens.d.ts +2 -0
- package/package.json +1 -1
- package/src/index.ts +5 -1
- package/src/node-process-host.ts +2 -1
- package/src/process-tokens.ts +16 -0
- package/src/shims/child_process.ts +11 -2
- package/src/shims/process.ts +2 -1
|
@@ -6771,6 +6771,11 @@ function __recordRun(token, run) {
|
|
|
6771
6771
|
if (runs.get(token) === run) runs.delete(token);
|
|
6772
6772
|
};
|
|
6773
6773
|
}
|
|
6774
|
+
const terminations = /* @__PURE__ */ new Map();
|
|
6775
|
+
function __recordTermination(process2, signal) {
|
|
6776
|
+
const token = tokensByProcess.get(process2);
|
|
6777
|
+
if (token !== void 0) terminations.set(token, signal);
|
|
6778
|
+
}
|
|
6774
6779
|
function __runFor(token) {
|
|
6775
6780
|
return runs.get(token);
|
|
6776
6781
|
}
|
|
@@ -26825,6 +26830,7 @@ function createProcess(options) {
|
|
|
26825
26830
|
return true;
|
|
26826
26831
|
}
|
|
26827
26832
|
if (__substrateIgnoredSignals.has(name)) return true;
|
|
26833
|
+
__recordTermination(proc, name);
|
|
26828
26834
|
proc.exit(128 + __substrateSignals[name]);
|
|
26829
26835
|
return true;
|
|
26830
26836
|
},
|
|
@@ -70835,6 +70841,7 @@ function startChildRun(request) {
|
|
|
70835
70841
|
let finished = false;
|
|
70836
70842
|
let started = false;
|
|
70837
70843
|
let killedBy = null;
|
|
70844
|
+
let hosted = false;
|
|
70838
70845
|
const initialStdin = [];
|
|
70839
70846
|
let flushingInput;
|
|
70840
70847
|
const flushStdin = () => {
|
|
@@ -70915,6 +70922,7 @@ function startChildRun(request) {
|
|
|
70915
70922
|
let outcome;
|
|
70916
70923
|
try {
|
|
70917
70924
|
const processHost = admittedNode ? nodeProcessHostFor(token) : void 0;
|
|
70925
|
+
hosted = processHost !== void 0;
|
|
70918
70926
|
const env = { ...request.env };
|
|
70919
70927
|
delete env[PROCESS_TOKEN_ENV];
|
|
70920
70928
|
outcome = processHost ? await runHostedNode(processHost, {
|
|
@@ -70943,7 +70951,7 @@ function startChildRun(request) {
|
|
|
70943
70951
|
}
|
|
70944
70952
|
if (outcome.stdout.length > streamedOut) (_a4 = request.stdout) == null ? void 0 : _a4.call(request, outcome.stdout.slice(streamedOut));
|
|
70945
70953
|
if (outcome.stderr.length > streamedErr) (_b3 = request.stderr) == null ? void 0 : _b3.call(request, outcome.stderr.slice(streamedErr));
|
|
70946
|
-
end(outcome.exitCode, null);
|
|
70954
|
+
end(outcome.exitCode, outcome.signal ?? null);
|
|
70947
70955
|
})();
|
|
70948
70956
|
};
|
|
70949
70957
|
_activeForkedChildren += 1;
|
|
@@ -70954,6 +70962,7 @@ function startChildRun(request) {
|
|
|
70954
70962
|
pid,
|
|
70955
70963
|
kill(signal) {
|
|
70956
70964
|
if (finished) return UV_ESRCH;
|
|
70965
|
+
if (hosted && signal !== "SIGKILL" && signal !== "SIGSTOP" && signalPid(pid, signal)) return 0;
|
|
70957
70966
|
killedBy = signal;
|
|
70958
70967
|
controller.abort(signal);
|
|
70959
70968
|
__releaseOwnedServers(token, false);
|
package/dist/index.d.ts
CHANGED
|
@@ -57,6 +57,8 @@ export interface RunResult {
|
|
|
57
57
|
stdout: string;
|
|
58
58
|
stderr: string;
|
|
59
59
|
exitCode: number;
|
|
60
|
+
/** The signal whose default action ended the run's guest, as Node reports a process a signal ended. */
|
|
61
|
+
signal?: string;
|
|
60
62
|
}
|
|
61
63
|
export interface RunOptions {
|
|
62
64
|
cwd?: string;
|
package/dist/index.mjs
CHANGED
|
@@ -6480,6 +6480,16 @@ function __recordRun(token, run) {
|
|
|
6480
6480
|
if (runs.get(token) === run) runs.delete(token);
|
|
6481
6481
|
};
|
|
6482
6482
|
}
|
|
6483
|
+
const terminations = /* @__PURE__ */ new Map();
|
|
6484
|
+
function __recordTermination(process2, signal) {
|
|
6485
|
+
const token = tokensByProcess.get(process2);
|
|
6486
|
+
if (token !== void 0) terminations.set(token, signal);
|
|
6487
|
+
}
|
|
6488
|
+
function __takeTermination(token) {
|
|
6489
|
+
const signal = terminations.get(token);
|
|
6490
|
+
terminations.delete(token);
|
|
6491
|
+
return signal;
|
|
6492
|
+
}
|
|
6483
6493
|
function __tokenForProcess(process2) {
|
|
6484
6494
|
return tokensByProcess.get(process2) ?? null;
|
|
6485
6495
|
}
|
|
@@ -27008,6 +27018,7 @@ function createProcess(options) {
|
|
|
27008
27018
|
return true;
|
|
27009
27019
|
}
|
|
27010
27020
|
if (__substrateIgnoredSignals.has(name)) return true;
|
|
27021
|
+
__recordTermination(proc, name);
|
|
27011
27022
|
proc.exit(128 + __substrateSignals[name]);
|
|
27012
27023
|
return true;
|
|
27013
27024
|
},
|
|
@@ -30527,6 +30538,7 @@ function startChildRun(request) {
|
|
|
30527
30538
|
let finished = false;
|
|
30528
30539
|
let started2 = false;
|
|
30529
30540
|
let killedBy = null;
|
|
30541
|
+
let hosted = false;
|
|
30530
30542
|
const initialStdin = [];
|
|
30531
30543
|
let flushingInput;
|
|
30532
30544
|
const flushStdin = () => {
|
|
@@ -30607,6 +30619,7 @@ function startChildRun(request) {
|
|
|
30607
30619
|
let outcome;
|
|
30608
30620
|
try {
|
|
30609
30621
|
const processHost = admittedNode ? nodeProcessHostFor(token) : void 0;
|
|
30622
|
+
hosted = processHost !== void 0;
|
|
30610
30623
|
const env = { ...request.env };
|
|
30611
30624
|
delete env[PROCESS_TOKEN_ENV];
|
|
30612
30625
|
outcome = processHost ? await runHostedNode(processHost, {
|
|
@@ -30635,7 +30648,7 @@ function startChildRun(request) {
|
|
|
30635
30648
|
}
|
|
30636
30649
|
if (outcome.stdout.length > streamedOut) (_a3 = request.stdout) == null ? void 0 : _a3.call(request, outcome.stdout.slice(streamedOut));
|
|
30637
30650
|
if (outcome.stderr.length > streamedErr) (_b2 = request.stderr) == null ? void 0 : _b2.call(request, outcome.stderr.slice(streamedErr));
|
|
30638
|
-
end(outcome.exitCode, null);
|
|
30651
|
+
end(outcome.exitCode, outcome.signal ?? null);
|
|
30639
30652
|
})();
|
|
30640
30653
|
};
|
|
30641
30654
|
_activeForkedChildren += 1;
|
|
@@ -30646,6 +30659,7 @@ function startChildRun(request) {
|
|
|
30646
30659
|
pid,
|
|
30647
30660
|
kill(signal) {
|
|
30648
30661
|
if (finished) return UV_ESRCH;
|
|
30662
|
+
if (hosted && signal !== "SIGKILL" && signal !== "SIGSTOP" && signalPid(pid, signal)) return 0;
|
|
30649
30663
|
killedBy = signal;
|
|
30650
30664
|
controller.abort(signal);
|
|
30651
30665
|
__releaseOwnedServers(token, false);
|
|
@@ -35695,7 +35709,7 @@ class WorkerRuntime {
|
|
|
35695
35709
|
this.worker = new Worker(
|
|
35696
35710
|
new URL(
|
|
35697
35711
|
/* @vite-ignore */
|
|
35698
|
-
"/assets/runtime-worker-
|
|
35712
|
+
"/assets/runtime-worker-CezP_cM0.js",
|
|
35699
35713
|
import.meta.url
|
|
35700
35714
|
),
|
|
35701
35715
|
{ type: "module" }
|
|
@@ -38401,10 +38415,12 @@ function createContainer(options) {
|
|
|
38401
38415
|
runCommand(command, { cwd: runOptions == null ? void 0 : runOptions.cwd, env: runOptions == null ? void 0 : runOptions.env, stdin: typeof (runOptions == null ? void 0 : runOptions.stdin) === "string" ? runOptions.stdin : void 0, processToken, vfs: vfs2 }, (error, stdout, stderr) => {
|
|
38402
38416
|
var _a3;
|
|
38403
38417
|
releaseRunStreams(processToken);
|
|
38418
|
+
const terminatedBy = __takeTermination(processToken);
|
|
38404
38419
|
resolve2({
|
|
38405
38420
|
stdout: String(stdout),
|
|
38406
38421
|
stderr: String(stderr),
|
|
38407
|
-
exitCode: ((_a3 = runOptions == null ? void 0 : runOptions.signal) == null ? void 0 : _a3.aborted) ? 143 : error ? error.code ?? 1 : 0
|
|
38422
|
+
exitCode: ((_a3 = runOptions == null ? void 0 : runOptions.signal) == null ? void 0 : _a3.aborted) ? 143 : error ? error.code ?? 1 : 0,
|
|
38423
|
+
...terminatedBy ? { signal: terminatedBy } : {}
|
|
38408
38424
|
});
|
|
38409
38425
|
});
|
|
38410
38426
|
});
|
|
@@ -21,10 +21,12 @@ export interface NodeProcessLaunch {
|
|
|
21
21
|
}[];
|
|
22
22
|
}
|
|
23
23
|
export interface NodeProcessHost {
|
|
24
|
+
/** `signal` names the signal whose default action ended the process, as Node's exit event does. */
|
|
24
25
|
run(launch: NodeProcessLaunch): Promise<{
|
|
25
26
|
stdout: string;
|
|
26
27
|
stderr: string;
|
|
27
28
|
exitCode: number;
|
|
29
|
+
signal?: string;
|
|
28
30
|
}>;
|
|
29
31
|
}
|
|
30
32
|
export declare function nodeProcessHostInstalled(): boolean;
|
package/dist/process-tokens.d.ts
CHANGED
|
@@ -44,6 +44,8 @@ export declare function enterRun<T>(token: ProcessToken, fn: () => T): T;
|
|
|
44
44
|
* releasing twice is harmless, as a run ends once.
|
|
45
45
|
*/
|
|
46
46
|
export declare function __recordRun(token: ProcessToken, run: OwnedRun): () => void;
|
|
47
|
+
export declare function __recordTermination(process: Process, signal: string): void;
|
|
48
|
+
export declare function __takeTermination(token: ProcessToken): string | undefined;
|
|
47
49
|
/** Bound guest globals retain their actual process across native await turns. */
|
|
48
50
|
export declare function __tokenForProcess(process: Process): ProcessToken | null;
|
|
49
51
|
/** The run recorded under this name, while it lasts. */
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -58,7 +58,7 @@ import { __adoptHandle, ownerOf, type OwnedHandle } from './node-lib/binding/han
|
|
|
58
58
|
import { listenerOnPort } from './node-lib/binding/tcp_wrap';
|
|
59
59
|
import { nativeStreamOwnerPid } from './native-stream-owner';
|
|
60
60
|
|
|
61
|
-
import { __currentProcessToken, __runFor, __signalOwnedProcess, __stopOwnedProcess, runPid, processByPid } from './process-tokens';
|
|
61
|
+
import { __currentProcessToken, __runFor, __signalOwnedProcess, __takeTermination, __stopOwnedProcess, runPid, processByPid } from './process-tokens';
|
|
62
62
|
export { runPid, processByPid };
|
|
63
63
|
export { createProcessRegistryScope, installProcessRegistry, ownerProcessRegistryScope, ownerProcessTable } from './process-tokens';
|
|
64
64
|
export { installNodeProcessHost, nodeProcessHostInstalled } from './node-process-host';
|
|
@@ -72,6 +72,8 @@ export interface RunResult {
|
|
|
72
72
|
stdout: string;
|
|
73
73
|
stderr: string;
|
|
74
74
|
exitCode: number;
|
|
75
|
+
/** The signal whose default action ended the run's guest, as Node reports a process a signal ended. */
|
|
76
|
+
signal?: string;
|
|
75
77
|
}
|
|
76
78
|
|
|
77
79
|
export interface RunOptions {
|
|
@@ -198,10 +200,12 @@ export function createContainer(options?: ContainerOptions): {
|
|
|
198
200
|
// piped, as it does in a Node shell.
|
|
199
201
|
runCommand(command, { cwd: runOptions?.cwd, env: runOptions?.env, stdin: typeof runOptions?.stdin === 'string' ? runOptions.stdin : undefined, processToken, vfs }, (error, stdout, stderr) => {
|
|
200
202
|
releaseRunStreams(processToken);
|
|
203
|
+
const terminatedBy = __takeTermination(processToken);
|
|
201
204
|
resolve({
|
|
202
205
|
stdout: String(stdout),
|
|
203
206
|
stderr: String(stderr),
|
|
204
207
|
exitCode: runOptions?.signal?.aborted ? 143 : error ? (error.code ?? 1) : 0,
|
|
208
|
+
...(terminatedBy ? { signal: terminatedBy } : {}),
|
|
205
209
|
});
|
|
206
210
|
});
|
|
207
211
|
});
|
package/src/node-process-host.ts
CHANGED
|
@@ -20,7 +20,8 @@ export interface NodeProcessLaunch {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export interface NodeProcessHost {
|
|
23
|
-
|
|
23
|
+
/** `signal` names the signal whose default action ended the process, as Node's exit event does. */
|
|
24
|
+
run(launch: NodeProcessLaunch): Promise<{ stdout: string; stderr: string; exitCode: number; signal?: string }>;
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
let host: NodeProcessHost | undefined;
|
package/src/process-tokens.ts
CHANGED
|
@@ -78,6 +78,22 @@ export function __recordRun(token: ProcessToken, run: OwnedRun): () => void {
|
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
/**
|
|
82
|
+
* The signal whose default action ended a run's guest, kept under the run's
|
|
83
|
+
* name until the run reports its result: Node reports such a process as ended
|
|
84
|
+
* by that signal, not by the exit code its default action implies.
|
|
85
|
+
*/
|
|
86
|
+
const terminations = new Map<ProcessToken, string>();
|
|
87
|
+
export function __recordTermination(process: Process, signal: string): void {
|
|
88
|
+
const token = tokensByProcess.get(process);
|
|
89
|
+
if (token !== undefined) terminations.set(token, signal);
|
|
90
|
+
}
|
|
91
|
+
export function __takeTermination(token: ProcessToken): string | undefined {
|
|
92
|
+
const signal = terminations.get(token);
|
|
93
|
+
terminations.delete(token);
|
|
94
|
+
return signal;
|
|
95
|
+
}
|
|
96
|
+
|
|
81
97
|
/** Bound guest globals retain their actual process across native await turns. */
|
|
82
98
|
export function __tokenForProcess(process: Process): ProcessToken | null {
|
|
83
99
|
return tokensByProcess.get(process) ?? null;
|
|
@@ -60,7 +60,7 @@ import { __substrateExecPath, __substrateProgramName, __substrateLineFor, __subs
|
|
|
60
60
|
|
|
61
61
|
import { __substrateChildren, __onUncaughtException, __reportUncaughtException } from './process';
|
|
62
62
|
|
|
63
|
-
import { PROCESS_TOKEN_ENV, __recordRun, __runFor, __currentProcessToken, __lastLaunchedToken, __setLastLaunchedToken, __stopOwnedProcess, enterRun, mintPid, setRunPid, runPid, forgetRunPid, type ProcessToken } from '../process-tokens';
|
|
63
|
+
import { PROCESS_TOKEN_ENV, __recordRun, __runFor, __currentProcessToken, __lastLaunchedToken, __setLastLaunchedToken, __stopOwnedProcess, enterRun, mintPid, setRunPid, runPid, forgetRunPid, signalPid, type ProcessToken } from '../process-tokens';
|
|
64
64
|
/** The host's own `process`, where it has one that emits, taken as the shim loads and before any guest's takes the global name. */
|
|
65
65
|
const __hostProcess: { on(event: string, listener: (reason: unknown) => void): unknown; off(event: string, listener: (reason: unknown) => void): unknown } | null =
|
|
66
66
|
typeof process !== 'undefined' && process !== null && typeof (process as { on?: unknown }).on === 'function' && typeof (process as { off?: unknown }).off === 'function'
|
|
@@ -1399,6 +1399,7 @@ interface CommandOutcome {
|
|
|
1399
1399
|
stdout: string;
|
|
1400
1400
|
stderr: string;
|
|
1401
1401
|
exitCode: number;
|
|
1402
|
+
signal?: string;
|
|
1402
1403
|
}
|
|
1403
1404
|
|
|
1404
1405
|
/** What a caller gives one run of a command line. */
|
|
@@ -1726,6 +1727,8 @@ function startChildRun(request: RunRequest): StartedRun {
|
|
|
1726
1727
|
let finished = false;
|
|
1727
1728
|
let started = false;
|
|
1728
1729
|
let killedBy: string | null = null;
|
|
1730
|
+
// Whether the child runs on the process host, in a realm of its own.
|
|
1731
|
+
let hosted = false;
|
|
1729
1732
|
/** What the parent wrote to the child's fd 0 before the command began. */
|
|
1730
1733
|
const initialStdin: Uint8Array[] = [];
|
|
1731
1734
|
|
|
@@ -1812,6 +1815,7 @@ function startChildRun(request: RunRequest): StartedRun {
|
|
|
1812
1815
|
let outcome: CommandOutcome;
|
|
1813
1816
|
try {
|
|
1814
1817
|
const processHost = admittedNode ? nodeProcessHostFor(token) : undefined;
|
|
1818
|
+
hosted = processHost !== undefined;
|
|
1815
1819
|
const env = { ...request.env };
|
|
1816
1820
|
delete env[PROCESS_TOKEN_ENV];
|
|
1817
1821
|
outcome = processHost ? await runHostedNode(processHost, {
|
|
@@ -1837,7 +1841,7 @@ function startChildRun(request: RunRequest): StartedRun {
|
|
|
1837
1841
|
// its own as it went, and only what it has not already sent is left.
|
|
1838
1842
|
if (outcome.stdout.length > streamedOut) request.stdout?.(outcome.stdout.slice(streamedOut));
|
|
1839
1843
|
if (outcome.stderr.length > streamedErr) request.stderr?.(outcome.stderr.slice(streamedErr));
|
|
1840
|
-
end(outcome.exitCode, null);
|
|
1844
|
+
end(outcome.exitCode, outcome.signal ?? null);
|
|
1841
1845
|
})();
|
|
1842
1846
|
};
|
|
1843
1847
|
|
|
@@ -1850,6 +1854,11 @@ function startChildRun(request: RunRequest): StartedRun {
|
|
|
1850
1854
|
pid,
|
|
1851
1855
|
kill(signal: string): number {
|
|
1852
1856
|
if (finished) return UV_ESRCH;
|
|
1857
|
+
// A child in a realm of its own takes a catchable signal as a machine's
|
|
1858
|
+
// process does: its listeners run, else its default action ends it, and
|
|
1859
|
+
// it ends by its own outcome. Only when nothing there receives it does
|
|
1860
|
+
// the parent end it here.
|
|
1861
|
+
if (hosted && signal !== 'SIGKILL' && signal !== 'SIGSTOP' && signalPid(pid, signal)) return 0;
|
|
1853
1862
|
killedBy = signal;
|
|
1854
1863
|
controller.abort(signal);
|
|
1855
1864
|
__releaseOwnedServers(token, false);
|
package/src/shims/process.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { Readable } from '../node-lib/stream-module';
|
|
|
10
10
|
import { loadNodeLibFor } from '../node-lib/load';
|
|
11
11
|
import { constantsBinding } from './constants';
|
|
12
12
|
import ttyWrapBinding from '../node-lib/binding/tty_wrap';
|
|
13
|
-
import { mintPid, pidIsLive, signalPid } from '../process-tokens';
|
|
13
|
+
import { mintPid, pidIsLive, signalPid, __recordTermination } from '../process-tokens';
|
|
14
14
|
import { NODE_LTS_VERSION, nodeVersions } from '../node-lib/node-versions';
|
|
15
15
|
import { freemem as osFreemem } from './os';
|
|
16
16
|
|
|
@@ -584,6 +584,7 @@ export function createProcess(options?: {
|
|
|
584
584
|
return true;
|
|
585
585
|
}
|
|
586
586
|
if (__substrateIgnoredSignals.has(name)) return true;
|
|
587
|
+
__recordTermination(proc as never, name);
|
|
587
588
|
proc.exit(128 + __substrateSignals[name]);
|
|
588
589
|
return true;
|
|
589
590
|
},
|