@scelar/nodepod 1.0.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/LICENSE +43 -0
- package/README.md +240 -0
- package/dist/child_process-BJOMsZje.js +8233 -0
- package/dist/child_process-BJOMsZje.js.map +1 -0
- package/dist/child_process-Cj8vOcuc.cjs +7434 -0
- package/dist/child_process-Cj8vOcuc.cjs.map +1 -0
- package/dist/index-Cb1Cgdnd.js +35308 -0
- package/dist/index-Cb1Cgdnd.js.map +1 -0
- package/dist/index-DsMGS-xc.cjs +37195 -0
- package/dist/index-DsMGS-xc.cjs.map +1 -0
- package/dist/index.cjs +65 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.mjs +59 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +95 -0
- package/src/__tests__/smoke.test.ts +11 -0
- package/src/constants/cdn-urls.ts +18 -0
- package/src/constants/config.ts +236 -0
- package/src/cross-origin.ts +26 -0
- package/src/engine-factory.ts +176 -0
- package/src/engine-types.ts +56 -0
- package/src/helpers/byte-encoding.ts +39 -0
- package/src/helpers/digest.ts +9 -0
- package/src/helpers/event-loop.ts +96 -0
- package/src/helpers/wasm-cache.ts +133 -0
- package/src/iframe-sandbox.ts +141 -0
- package/src/index.ts +192 -0
- package/src/isolation-helpers.ts +148 -0
- package/src/memory-volume.ts +941 -0
- package/src/module-transformer.ts +368 -0
- package/src/packages/archive-extractor.ts +248 -0
- package/src/packages/browser-bundler.ts +284 -0
- package/src/packages/installer.ts +396 -0
- package/src/packages/registry-client.ts +131 -0
- package/src/packages/version-resolver.ts +411 -0
- package/src/polyfills/assert.ts +384 -0
- package/src/polyfills/async_hooks.ts +144 -0
- package/src/polyfills/buffer.ts +628 -0
- package/src/polyfills/child_process.ts +2288 -0
- package/src/polyfills/chokidar.ts +336 -0
- package/src/polyfills/cluster.ts +106 -0
- package/src/polyfills/console.ts +136 -0
- package/src/polyfills/constants.ts +123 -0
- package/src/polyfills/crypto.ts +885 -0
- package/src/polyfills/dgram.ts +87 -0
- package/src/polyfills/diagnostics_channel.ts +76 -0
- package/src/polyfills/dns.ts +134 -0
- package/src/polyfills/domain.ts +68 -0
- package/src/polyfills/esbuild.ts +854 -0
- package/src/polyfills/events.ts +276 -0
- package/src/polyfills/fs.ts +2888 -0
- package/src/polyfills/fsevents.ts +79 -0
- package/src/polyfills/http.ts +1449 -0
- package/src/polyfills/http2.ts +199 -0
- package/src/polyfills/https.ts +76 -0
- package/src/polyfills/inspector.ts +62 -0
- package/src/polyfills/lightningcss.ts +105 -0
- package/src/polyfills/module.ts +191 -0
- package/src/polyfills/net.ts +353 -0
- package/src/polyfills/os.ts +238 -0
- package/src/polyfills/path.ts +206 -0
- package/src/polyfills/perf_hooks.ts +102 -0
- package/src/polyfills/process.ts +690 -0
- package/src/polyfills/punycode.ts +159 -0
- package/src/polyfills/querystring.ts +93 -0
- package/src/polyfills/quic.ts +118 -0
- package/src/polyfills/readdirp.ts +229 -0
- package/src/polyfills/readline.ts +692 -0
- package/src/polyfills/repl.ts +134 -0
- package/src/polyfills/rollup.ts +119 -0
- package/src/polyfills/sea.ts +33 -0
- package/src/polyfills/sqlite.ts +78 -0
- package/src/polyfills/stream.ts +1620 -0
- package/src/polyfills/string_decoder.ts +25 -0
- package/src/polyfills/tailwindcss-oxide.ts +309 -0
- package/src/polyfills/test.ts +197 -0
- package/src/polyfills/timers.ts +32 -0
- package/src/polyfills/tls.ts +105 -0
- package/src/polyfills/trace_events.ts +50 -0
- package/src/polyfills/tty.ts +71 -0
- package/src/polyfills/url.ts +174 -0
- package/src/polyfills/util.ts +559 -0
- package/src/polyfills/v8.ts +126 -0
- package/src/polyfills/vm.ts +132 -0
- package/src/polyfills/volume-registry.ts +15 -0
- package/src/polyfills/wasi.ts +44 -0
- package/src/polyfills/worker_threads.ts +326 -0
- package/src/polyfills/ws.ts +595 -0
- package/src/polyfills/zlib.ts +881 -0
- package/src/request-proxy.ts +716 -0
- package/src/script-engine.ts +3375 -0
- package/src/sdk/nodepod-fs.ts +93 -0
- package/src/sdk/nodepod-process.ts +86 -0
- package/src/sdk/nodepod-terminal.ts +350 -0
- package/src/sdk/nodepod.ts +509 -0
- package/src/sdk/types.ts +70 -0
- package/src/shell/commands/bun.ts +121 -0
- package/src/shell/commands/directory.ts +297 -0
- package/src/shell/commands/file-ops.ts +525 -0
- package/src/shell/commands/git.ts +2142 -0
- package/src/shell/commands/node.ts +80 -0
- package/src/shell/commands/npm.ts +198 -0
- package/src/shell/commands/pm-types.ts +45 -0
- package/src/shell/commands/pnpm.ts +82 -0
- package/src/shell/commands/search.ts +264 -0
- package/src/shell/commands/shell-env.ts +352 -0
- package/src/shell/commands/text-processing.ts +1152 -0
- package/src/shell/commands/yarn.ts +84 -0
- package/src/shell/shell-builtins.ts +19 -0
- package/src/shell/shell-helpers.ts +250 -0
- package/src/shell/shell-interpreter.ts +514 -0
- package/src/shell/shell-parser.ts +429 -0
- package/src/shell/shell-types.ts +85 -0
- package/src/syntax-transforms.ts +561 -0
- package/src/threading/engine-worker.ts +64 -0
- package/src/threading/inline-worker.ts +372 -0
- package/src/threading/offload-types.ts +112 -0
- package/src/threading/offload-worker.ts +383 -0
- package/src/threading/offload.ts +271 -0
- package/src/threading/process-context.ts +92 -0
- package/src/threading/process-handle.ts +275 -0
- package/src/threading/process-manager.ts +956 -0
- package/src/threading/process-worker-entry.ts +854 -0
- package/src/threading/shared-vfs.ts +352 -0
- package/src/threading/sync-channel.ts +135 -0
- package/src/threading/task-queue.ts +177 -0
- package/src/threading/vfs-bridge.ts +231 -0
- package/src/threading/worker-pool.ts +233 -0
- package/src/threading/worker-protocol.ts +358 -0
- package/src/threading/worker-vfs.ts +218 -0
- package/src/types/externals.d.ts +38 -0
- package/src/types/fs-streams.ts +142 -0
- package/src/types/manifest.ts +17 -0
- package/src/worker-sandbox.ts +90 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// ProcessContext — per-process execution state.
|
|
2
|
+
// Replaces module-level mutable state (the old `let _xxx` in child_process, fs, etc.).
|
|
3
|
+
// One active context on main thread; each worker gets its own.
|
|
4
|
+
|
|
5
|
+
import type { MemoryVolume } from "../memory-volume";
|
|
6
|
+
|
|
7
|
+
// --- I/O interfaces ---
|
|
8
|
+
|
|
9
|
+
export interface ProcessWriter {
|
|
10
|
+
write(data: string): void;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface ProcessReader {
|
|
14
|
+
on(event: string, cb: (...args: unknown[]) => void): void;
|
|
15
|
+
emit(event: string, ...args: unknown[]): void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// --- ProcessContext ---
|
|
19
|
+
|
|
20
|
+
export interface ProcessContext {
|
|
21
|
+
pid: number;
|
|
22
|
+
cwd: string;
|
|
23
|
+
env: Record<string, string>;
|
|
24
|
+
|
|
25
|
+
stdoutSink: ((text: string) => void) | null;
|
|
26
|
+
stderrSink: ((text: string) => void) | null;
|
|
27
|
+
liveStdin: { emit: (e: string, ...a: unknown[]) => void } | null;
|
|
28
|
+
abortController: AbortController;
|
|
29
|
+
|
|
30
|
+
volume: MemoryVolume;
|
|
31
|
+
|
|
32
|
+
refCount: number;
|
|
33
|
+
drainListeners: Set<() => void>;
|
|
34
|
+
|
|
35
|
+
termCols: (() => number) | null;
|
|
36
|
+
termRows: (() => number) | null;
|
|
37
|
+
|
|
38
|
+
fdCounter: number;
|
|
39
|
+
openFiles: Map<number, OpenFileEntry>;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface OpenFileEntry {
|
|
43
|
+
filePath: string;
|
|
44
|
+
cursor: number;
|
|
45
|
+
mode: string;
|
|
46
|
+
data: Uint8Array;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// --- Factory ---
|
|
50
|
+
|
|
51
|
+
let _nextPid = 100;
|
|
52
|
+
|
|
53
|
+
export function createProcessContext(opts: {
|
|
54
|
+
volume: MemoryVolume;
|
|
55
|
+
cwd?: string;
|
|
56
|
+
env?: Record<string, string>;
|
|
57
|
+
pid?: number;
|
|
58
|
+
}): ProcessContext {
|
|
59
|
+
return {
|
|
60
|
+
pid: opts.pid ?? _nextPid++,
|
|
61
|
+
cwd: opts.cwd ?? "/",
|
|
62
|
+
env: opts.env ?? {},
|
|
63
|
+
|
|
64
|
+
stdoutSink: null,
|
|
65
|
+
stderrSink: null,
|
|
66
|
+
liveStdin: null,
|
|
67
|
+
abortController: new AbortController(),
|
|
68
|
+
|
|
69
|
+
volume: opts.volume,
|
|
70
|
+
|
|
71
|
+
refCount: 0,
|
|
72
|
+
drainListeners: new Set(),
|
|
73
|
+
|
|
74
|
+
termCols: null,
|
|
75
|
+
termRows: null,
|
|
76
|
+
|
|
77
|
+
fdCounter: 3,
|
|
78
|
+
openFiles: new Map(),
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// --- Active context (main-thread inline mode) ---
|
|
83
|
+
|
|
84
|
+
let _activeContext: ProcessContext | null = null;
|
|
85
|
+
|
|
86
|
+
export function getActiveContext(): ProcessContext | null {
|
|
87
|
+
return _activeContext;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function setActiveContext(ctx: ProcessContext | null): void {
|
|
91
|
+
_activeContext = ctx;
|
|
92
|
+
}
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
// ProcessHandle — per-process main-thread state.
|
|
2
|
+
// Tracks lifecycle, routes I/O, emits events for each spawned worker.
|
|
3
|
+
|
|
4
|
+
import { EventEmitter } from "../polyfills/events";
|
|
5
|
+
import type {
|
|
6
|
+
MainToWorkerMessage,
|
|
7
|
+
WorkerToMainMessage,
|
|
8
|
+
SpawnConfig,
|
|
9
|
+
MainToWorker_Init,
|
|
10
|
+
MainToWorker_Exec,
|
|
11
|
+
} from "./worker-protocol";
|
|
12
|
+
|
|
13
|
+
/* ------------------------------------------------------------------ */
|
|
14
|
+
/* ProcessHandle */
|
|
15
|
+
/* ------------------------------------------------------------------ */
|
|
16
|
+
|
|
17
|
+
export type ProcessState = "starting" | "running" | "exited";
|
|
18
|
+
|
|
19
|
+
export class ProcessHandle extends EventEmitter {
|
|
20
|
+
readonly pid: number;
|
|
21
|
+
readonly worker: Worker;
|
|
22
|
+
readonly command: string;
|
|
23
|
+
readonly args: string[];
|
|
24
|
+
readonly parentPid?: number;
|
|
25
|
+
|
|
26
|
+
private _state: ProcessState = "starting";
|
|
27
|
+
private _exitCode: number | undefined;
|
|
28
|
+
private _stdout = "";
|
|
29
|
+
private _stderr = "";
|
|
30
|
+
|
|
31
|
+
// When > 0, "exit" is deferred — children still running, output keeps flowing
|
|
32
|
+
private _exitHoldCount = 0;
|
|
33
|
+
private _deferredExit: { exitCode: number; stdout: string; stderr: string } | null = null;
|
|
34
|
+
|
|
35
|
+
// Same deferral for "shell-done" in persistent mode
|
|
36
|
+
private _shellDoneHoldCount = 0;
|
|
37
|
+
private _deferredShellDone: { exitCode: number; stdout: string; stderr: string } | null = null;
|
|
38
|
+
|
|
39
|
+
// When > 0, worker is blocked on Atomics.wait() — stdin can't be delivered via postMessage
|
|
40
|
+
private _syncBlockedCount = 0;
|
|
41
|
+
|
|
42
|
+
get workerExited(): boolean { return this._deferredExit !== null || this._state === "exited"; }
|
|
43
|
+
get shellCommandDone(): boolean { return this._deferredShellDone !== null; }
|
|
44
|
+
get syncBlocked(): boolean { return this._syncBlockedCount > 0; }
|
|
45
|
+
holdSync(): void { this._syncBlockedCount++; }
|
|
46
|
+
releaseSync(): void { this._syncBlockedCount = Math.max(0, this._syncBlockedCount - 1); }
|
|
47
|
+
|
|
48
|
+
get stdout(): string { return this._stdout; }
|
|
49
|
+
get stderr(): string { return this._stderr; }
|
|
50
|
+
|
|
51
|
+
get state(): ProcessState { return this._state; }
|
|
52
|
+
get exitCode(): number | undefined { return this._exitCode; }
|
|
53
|
+
|
|
54
|
+
constructor(worker: Worker, config: SpawnConfig) {
|
|
55
|
+
super();
|
|
56
|
+
this.pid = config.snapshot ? Math.floor(Math.random() * 90000) + 10000 : 0; // will be set properly
|
|
57
|
+
this.worker = worker;
|
|
58
|
+
this.command = config.command;
|
|
59
|
+
this.args = config.args;
|
|
60
|
+
this.parentPid = config.parentPid;
|
|
61
|
+
|
|
62
|
+
this._setupWorkerListeners();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
_setPid(pid: number): void {
|
|
66
|
+
(this as any).pid = pid;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
postMessage(msg: MainToWorkerMessage, transfer?: Transferable[]): void {
|
|
70
|
+
this.worker.postMessage(msg, transfer ?? []);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
init(initMsg: MainToWorker_Init): void {
|
|
74
|
+
const transfer: Transferable[] = [];
|
|
75
|
+
if (initMsg.snapshot.data.byteLength > 0) {
|
|
76
|
+
transfer.push(initMsg.snapshot.data);
|
|
77
|
+
}
|
|
78
|
+
this.postMessage(initMsg, transfer);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
exec(execMsg: MainToWorker_Exec): void {
|
|
82
|
+
this.postMessage(execMsg);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
sendStdin(data: string): void {
|
|
86
|
+
// Forward to children via ProcessManager
|
|
87
|
+
this.emit("stdin-forward", data);
|
|
88
|
+
|
|
89
|
+
// Skip postMessage if blocked on Atomics.wait() or already exited
|
|
90
|
+
if (!this.workerExited && !this.syncBlocked) {
|
|
91
|
+
this.postMessage({ type: "stdin", data });
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
kill(signal: string = "SIGTERM"): void {
|
|
96
|
+
this.postMessage({ type: "signal", signal });
|
|
97
|
+
this.emit("signal", signal);
|
|
98
|
+
if (signal === "SIGKILL") {
|
|
99
|
+
this._terminate(137);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
resize(cols: number, rows: number): void {
|
|
104
|
+
this.postMessage({ type: "resize", cols, rows });
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
holdExit(): void {
|
|
108
|
+
this._exitHoldCount++;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
releaseExit(): void {
|
|
112
|
+
this._exitHoldCount = Math.max(0, this._exitHoldCount - 1);
|
|
113
|
+
if (this._exitHoldCount === 0 && this._deferredExit) {
|
|
114
|
+
const { exitCode, stdout, stderr } = this._deferredExit;
|
|
115
|
+
this._deferredExit = null;
|
|
116
|
+
this._state = "exited";
|
|
117
|
+
this._exitCode = exitCode;
|
|
118
|
+
this.emit("exit", exitCode, stdout, stderr);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
holdShellDone(): void {
|
|
123
|
+
this._shellDoneHoldCount++;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
releaseShellDone(): void {
|
|
127
|
+
this._shellDoneHoldCount = Math.max(0, this._shellDoneHoldCount - 1);
|
|
128
|
+
if (this._shellDoneHoldCount === 0 && this._deferredShellDone) {
|
|
129
|
+
const { exitCode, stdout, stderr } = this._deferredShellDone;
|
|
130
|
+
this._deferredShellDone = null;
|
|
131
|
+
this.emit("shell-done", exitCode, stdout, stderr);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
private _terminate(exitCode: number = 1): void {
|
|
136
|
+
if (this._state === "exited") return;
|
|
137
|
+
this._state = "exited";
|
|
138
|
+
this._exitCode = exitCode;
|
|
139
|
+
this._deferredExit = null;
|
|
140
|
+
this._exitHoldCount = 0;
|
|
141
|
+
try { this.worker.terminate(); } catch {
|
|
142
|
+
/* ignore */
|
|
143
|
+
}
|
|
144
|
+
this.emit("exit", exitCode, this._stdout, this._stderr);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
private _setupWorkerListeners(): void {
|
|
148
|
+
this.worker.addEventListener("message", (ev: MessageEvent) => {
|
|
149
|
+
const msg = ev.data as WorkerToMainMessage;
|
|
150
|
+
if (!msg || !msg.type) return;
|
|
151
|
+
|
|
152
|
+
switch (msg.type) {
|
|
153
|
+
case "ready":
|
|
154
|
+
this._state = "running";
|
|
155
|
+
this.emit("ready");
|
|
156
|
+
break;
|
|
157
|
+
|
|
158
|
+
case "stdout":
|
|
159
|
+
this._stdout += msg.data;
|
|
160
|
+
this.emit("stdout", msg.data);
|
|
161
|
+
break;
|
|
162
|
+
|
|
163
|
+
case "stderr":
|
|
164
|
+
this._stderr += msg.data;
|
|
165
|
+
this.emit("stderr", msg.data);
|
|
166
|
+
break;
|
|
167
|
+
|
|
168
|
+
case "exit": {
|
|
169
|
+
const stdout = msg.stdout || this._stdout;
|
|
170
|
+
const stderr = msg.stderr || this._stderr;
|
|
171
|
+
this._stdout = stdout;
|
|
172
|
+
this._stderr = stderr;
|
|
173
|
+
if (this._exitHoldCount > 0) {
|
|
174
|
+
// Children still running — defer exit, keep output flowing
|
|
175
|
+
this._deferredExit = { exitCode: msg.exitCode, stdout, stderr };
|
|
176
|
+
this.emit("worker-done", msg.exitCode);
|
|
177
|
+
} else {
|
|
178
|
+
this._state = "exited";
|
|
179
|
+
this._exitCode = msg.exitCode;
|
|
180
|
+
this.emit("exit", msg.exitCode, stdout, stderr);
|
|
181
|
+
}
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
case "console":
|
|
186
|
+
this.emit("console", msg.method, msg.args);
|
|
187
|
+
break;
|
|
188
|
+
|
|
189
|
+
case "vfs-write":
|
|
190
|
+
this.emit("vfs-write", msg.path, msg.content, msg.isDirectory);
|
|
191
|
+
break;
|
|
192
|
+
|
|
193
|
+
case "vfs-delete":
|
|
194
|
+
this.emit("vfs-delete", msg.path);
|
|
195
|
+
break;
|
|
196
|
+
|
|
197
|
+
case "vfs-read":
|
|
198
|
+
this.emit("vfs-read", msg.requestId, msg.path);
|
|
199
|
+
break;
|
|
200
|
+
|
|
201
|
+
case "spawn-request":
|
|
202
|
+
this.emit("spawn-request", msg);
|
|
203
|
+
break;
|
|
204
|
+
|
|
205
|
+
case "fork-request":
|
|
206
|
+
this.emit("fork-request", msg);
|
|
207
|
+
break;
|
|
208
|
+
|
|
209
|
+
case "workerthread-request":
|
|
210
|
+
this.emit("workerthread-request", msg);
|
|
211
|
+
break;
|
|
212
|
+
|
|
213
|
+
case "ipc-message":
|
|
214
|
+
this.emit("ipc-message", msg);
|
|
215
|
+
break;
|
|
216
|
+
|
|
217
|
+
case "spawn-sync":
|
|
218
|
+
this.emit("spawn-sync", msg);
|
|
219
|
+
break;
|
|
220
|
+
|
|
221
|
+
case "server-listen":
|
|
222
|
+
this.emit("server-listen", msg.port, msg.hostname);
|
|
223
|
+
break;
|
|
224
|
+
|
|
225
|
+
case "server-close":
|
|
226
|
+
this.emit("server-close", msg.port);
|
|
227
|
+
break;
|
|
228
|
+
|
|
229
|
+
case "http-request":
|
|
230
|
+
this.emit("http-request", msg);
|
|
231
|
+
break;
|
|
232
|
+
|
|
233
|
+
case "http-response":
|
|
234
|
+
this.emit("http-response", msg);
|
|
235
|
+
break;
|
|
236
|
+
|
|
237
|
+
case "shell-done": {
|
|
238
|
+
const sd = msg as any;
|
|
239
|
+
if (this._shellDoneHoldCount > 0) {
|
|
240
|
+
this._deferredShellDone = { exitCode: sd.exitCode, stdout: sd.stdout, stderr: sd.stderr };
|
|
241
|
+
} else {
|
|
242
|
+
this.emit("shell-done", sd.exitCode, sd.stdout, sd.stderr);
|
|
243
|
+
}
|
|
244
|
+
break;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
case "cwd-change":
|
|
248
|
+
this.emit("cwd-change", msg.cwd);
|
|
249
|
+
break;
|
|
250
|
+
|
|
251
|
+
case "stdin-raw-status":
|
|
252
|
+
this.emit("stdin-raw-status", msg.isRaw);
|
|
253
|
+
break;
|
|
254
|
+
|
|
255
|
+
case "ws-frame":
|
|
256
|
+
this.emit("ws-frame", msg);
|
|
257
|
+
break;
|
|
258
|
+
|
|
259
|
+
case "error":
|
|
260
|
+
this.emit("worker-error", msg.message, msg.stack);
|
|
261
|
+
break;
|
|
262
|
+
|
|
263
|
+
default:
|
|
264
|
+
break;
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
this.worker.addEventListener("error", (ev: ErrorEvent) => {
|
|
269
|
+
this.emit("worker-error", ev.message, undefined);
|
|
270
|
+
if (this._state !== "exited") {
|
|
271
|
+
this._terminate(1);
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
}
|