wasm-idle 1.1.2 → 1.3.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 +211 -91
- package/dist/container/bash-profile.d.ts +80 -0
- package/dist/container/bash-profile.js +328 -0
- package/dist/{playground/container → container}/binding.d.ts +21 -8
- package/dist/{playground/container → container}/binding.js +109 -25
- package/dist/{playground/container → container}/clang-runtime.d.ts +11 -7
- package/dist/container/clang-runtime.js +561 -0
- package/dist/container/client.d.ts +14 -0
- package/dist/{playground/container → container}/client.js +2 -6
- package/dist/{playground/container → container}/explorer.d.ts +1 -1
- package/dist/container/index.d.ts +11 -0
- package/dist/container/index.js +11 -0
- package/dist/container/owner-worker.d.ts +19 -0
- package/dist/container/owner-worker.js +464 -0
- package/dist/{playground/container → container}/protocol.d.ts +12 -1
- package/dist/{playground/container → container}/runtime-adapter.d.ts +13 -11
- package/dist/{playground/container → container}/runtime-adapter.js +104 -41
- package/dist/{playground/container → container}/shell-control.d.ts +2 -2
- package/dist/{playground/container → container}/shell-control.js +93 -36
- package/dist/{playground/container → container}/workspace.d.ts +5 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/dist/playground/assetBridge.js +5 -2
- package/dist/playground/assets.d.ts +8 -0
- package/dist/playground/clang.d.ts +5 -1
- package/dist/playground/clang.js +61 -5
- package/dist/playground/compiledLldb.d.ts +41 -0
- package/dist/playground/compiledLldb.js +167 -0
- package/dist/playground/d.d.ts +4 -1
- package/dist/playground/d.js +78 -9
- package/dist/playground/debugDeadline.d.ts +12 -0
- package/dist/playground/debugDeadline.js +34 -0
- package/dist/playground/debugMailbox.d.ts +12 -0
- package/dist/playground/debugMailbox.js +77 -0
- package/dist/playground/go.js +9 -4
- package/dist/playground/goDebugInstrumentation.js +24 -44
- package/dist/playground/java-debug-HUZVAK4F.js +124 -0
- package/dist/playground/java-debug-notices.txt +492 -0
- package/dist/playground/java.d.ts +17 -1
- package/dist/playground/java.js +159 -3
- package/dist/playground/javaDebug.d.ts +62 -0
- package/dist/playground/javaDebug.js +305 -0
- package/dist/playground/javaDebugBridge.d.ts +6 -0
- package/dist/playground/javaDebugBridge.js +250 -0
- package/dist/playground/javaDebugSource.d.ts +9 -0
- package/dist/playground/javaDebugSource.js +4 -0
- package/dist/playground/javaRuntimeErrors.js +34 -1
- package/dist/playground/lean4Assets.d.ts +1 -25
- package/dist/playground/lean4Assets.js +2 -123
- package/dist/playground/lfortranAssets.d.ts +2 -2
- package/dist/playground/lldbSession.d.ts +24 -2
- package/dist/playground/lldbSession.js +322 -59
- package/dist/playground/lldbSourcePath.d.ts +2 -0
- package/dist/playground/lldbSourcePath.js +9 -0
- package/dist/playground/lua.d.ts +20 -1
- package/dist/playground/lua.js +190 -8
- package/dist/playground/luaDebug.d.ts +1 -0
- package/dist/playground/luaDebug.js +1 -0
- package/dist/playground/nim.d.ts +1 -0
- package/dist/playground/nim.js +8 -0
- package/dist/playground/objectivec.d.ts +7 -6
- package/dist/playground/objectivec.js +75 -9
- package/dist/playground/options.d.ts +10 -4
- package/dist/playground/python.d.ts +11 -1
- package/dist/playground/python.js +203 -8
- package/dist/playground/pythonCompileOptions.d.ts +49 -0
- package/dist/playground/pythonCompileOptions.js +40 -0
- package/dist/playground/ruby.d.ts +10 -1
- package/dist/playground/ruby.js +66 -1
- package/dist/playground/rubyDebug.d.ts +21 -0
- package/dist/playground/rubyDebug.js +128 -0
- package/dist/playground/rust.d.ts +5 -1
- package/dist/playground/rust.js +128 -46
- package/dist/playground/sandbox.d.ts +8 -1
- package/dist/playground/staticRuntimeModuleVersion.d.ts +1 -1
- package/dist/playground/staticRuntimeModuleVersion.js +1 -1
- package/dist/playground/staticWorkerRuntime.js +8 -2
- package/dist/playground/stdinBuffer.d.ts +1 -1
- package/dist/playground/stdinBuffer.js +19 -2
- package/dist/playground/tinygo.js +7 -0
- package/dist/playground/typescript.js +8 -0
- package/dist/playground/v.d.ts +3 -2
- package/dist/playground/v.js +66 -12
- package/dist/playground/wasmC3Version.d.ts +2 -2
- package/dist/playground/wasmC3Version.js +2 -2
- package/dist/playground/wasmDebugVersion.d.ts +1 -1
- package/dist/playground/wasmDebugVersion.js +1 -1
- package/dist/playground/wasmLean4Version.d.ts +1 -110
- package/dist/playground/wasmLean4Version.js +2 -111
- package/dist/playground/wasmLfortranVersion.d.ts +2 -2
- package/dist/playground/wasmLfortranVersion.js +2 -2
- package/dist/playground/wasmLuaVersion.d.ts +1 -1
- package/dist/playground/wasmLuaVersion.js +1 -1
- package/dist/playground/wasmPrologVersion.d.ts +17 -17
- package/dist/playground/wasmPrologVersion.js +16 -16
- package/dist/playground/wasmRustVersion.d.ts +26 -38
- package/dist/playground/wasmRustVersion.js +25 -40
- package/dist/playground/wasmTypeScriptVersion.d.ts +3 -3
- package/dist/playground/wasmTypeScriptVersion.js +3 -3
- package/dist/playground/worker/clang.js +1 -1
- package/dist/playground/worker/cobol.js +1 -1
- package/dist/playground/worker/d.js +51 -2
- package/dist/playground/worker/fortran.js +1 -1
- package/dist/playground/worker/java.js +188 -35
- package/dist/playground/worker/javaDebugEvaluator.d.ts +16 -0
- package/dist/playground/worker/javaDebugEvaluator.js +44 -0
- package/dist/playground/worker/javaDebugRuntime.d.ts +24 -0
- package/dist/playground/worker/javaDebugRuntime.js +315 -0
- package/dist/playground/worker/javaOutput.d.ts +11 -0
- package/dist/playground/worker/javaOutput.js +54 -0
- package/dist/playground/worker/lua.js +13 -0
- package/dist/playground/worker/python.js +81 -23
- package/dist/playground/worker/pythonCompile.d.ts +4 -0
- package/dist/playground/worker/pythonCompile.js +122 -0
- package/dist/playground/worker/ruby.js +13 -0
- package/dist/playground/worker/rubyDebugPreview.d.ts +2 -0
- package/dist/playground/worker/rubyDebugPreview.js +80 -0
- package/dist/playground/worker/rubyTracepoint.d.ts +16 -0
- package/dist/playground/worker/rubyTracepoint.js +162 -0
- package/dist/playground/worker/rust.js +4 -1
- package/dist/playground/worker/v.js +30 -5
- package/dist/playground/zig.js +4 -0
- package/dist/pythonCompiler.d.ts +8 -0
- package/dist/pythonCompiler.js +52 -0
- package/package.json +76 -28
- package/dist/playground/container/ContainerExplorer.svelte +0 -307
- package/dist/playground/container/ContainerExplorer.svelte.d.ts +0 -14
- package/dist/playground/container/clang-runtime.js +0 -343
- package/dist/playground/container/client.d.ts +0 -15
- package/dist/playground/container/owner.worker.d.ts +0 -1
- package/dist/playground/container/owner.worker.js +0 -390
- package/dist/playground/container/release.d.ts +0 -31
- package/dist/playground/container/release.js +0 -612
- /package/dist/{playground/container → container}/explorer.js +0 -0
- /package/dist/{playground/container → container}/protocol.js +0 -0
- /package/dist/{playground/container → container}/workspace.js +0 -0
|
@@ -1,343 +0,0 @@
|
|
|
1
|
-
import { resolveSandboxExecutionArgs } from '../options';
|
|
2
|
-
/** The Run button uses the same real Clang command and artifacts as Bash. Debug uses its qualified backend. */
|
|
3
|
-
export class WebsiteClangRuntime {
|
|
4
|
-
profile;
|
|
5
|
-
files;
|
|
6
|
-
emit;
|
|
7
|
-
#active = new Map();
|
|
8
|
-
#prepared = new Map();
|
|
9
|
-
#input = new Map();
|
|
10
|
-
#header;
|
|
11
|
-
constructor(profile, files, emit) {
|
|
12
|
-
this.profile = profile;
|
|
13
|
-
this.files = files;
|
|
14
|
-
this.emit = emit;
|
|
15
|
-
}
|
|
16
|
-
queue(language) {
|
|
17
|
-
let value = this.#input.get(language);
|
|
18
|
-
if (!value)
|
|
19
|
-
this.#input.set(language, (value = { chunks: [], size: 0, eof: false }));
|
|
20
|
-
return value;
|
|
21
|
-
}
|
|
22
|
-
key(language, code, args, options) {
|
|
23
|
-
return JSON.stringify([
|
|
24
|
-
language,
|
|
25
|
-
code,
|
|
26
|
-
args,
|
|
27
|
-
options.cppVersion,
|
|
28
|
-
options.cVersion,
|
|
29
|
-
options.compileArgs,
|
|
30
|
-
options.activePath,
|
|
31
|
-
options.env,
|
|
32
|
-
options.workspaceFiles
|
|
33
|
-
]);
|
|
34
|
-
}
|
|
35
|
-
async drain(process, language, requestId, diagnostics = false, quiet = false) {
|
|
36
|
-
const output = async (stream, stderr) => {
|
|
37
|
-
const reader = stream.getReader(), decoder = new TextDecoder();
|
|
38
|
-
let pending = '';
|
|
39
|
-
try {
|
|
40
|
-
for (;;) {
|
|
41
|
-
const { value, done } = await reader.read();
|
|
42
|
-
const text = done ? decoder.decode() : decoder.decode(value, { stream: true });
|
|
43
|
-
if (text && !quiet)
|
|
44
|
-
this.emit({ language, name: 'output', data: text, requestId });
|
|
45
|
-
if (stderr && diagnostics) {
|
|
46
|
-
pending += text;
|
|
47
|
-
const lines = pending.split('\n');
|
|
48
|
-
pending = lines.pop() ?? '';
|
|
49
|
-
for (const line of lines) {
|
|
50
|
-
const match = /^(.*?):(\d+):(\d+): (fatal error|error|warning|note): (.*)$/.exec(line);
|
|
51
|
-
if (match)
|
|
52
|
-
this.emit({
|
|
53
|
-
language,
|
|
54
|
-
name: 'diagnostic',
|
|
55
|
-
requestId,
|
|
56
|
-
data: {
|
|
57
|
-
fileName: match[1].replace(`/workspace/${language}/`, '/workspace/'),
|
|
58
|
-
lineNumber: Number(match[2]),
|
|
59
|
-
columnNumber: Number(match[3]),
|
|
60
|
-
severity: match[4].includes('error')
|
|
61
|
-
? 'error'
|
|
62
|
-
: match[4] === 'warning'
|
|
63
|
-
? 'warning'
|
|
64
|
-
: 'other',
|
|
65
|
-
message: match[5]
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
if (pending.length > 65536)
|
|
70
|
-
pending = '';
|
|
71
|
-
}
|
|
72
|
-
if (done)
|
|
73
|
-
break;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
finally {
|
|
77
|
-
reader.releaseLock();
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
const [result] = await Promise.all([
|
|
81
|
-
process.exited,
|
|
82
|
-
output(process.stdout, false),
|
|
83
|
-
output(process.stderr, true)
|
|
84
|
-
]);
|
|
85
|
-
return result;
|
|
86
|
-
}
|
|
87
|
-
success(result, signal) {
|
|
88
|
-
if (signal.aborted)
|
|
89
|
-
throw signal.reason ?? new DOMException('Command cancelled', 'AbortError');
|
|
90
|
-
if (result.reason !== 'exited')
|
|
91
|
-
throw new Error(`Container command ended with ${result.reason}`);
|
|
92
|
-
return result.code === 0;
|
|
93
|
-
}
|
|
94
|
-
headerKey(language, code, compileArgs, options, cwd, standard) {
|
|
95
|
-
// A textual prefix and the fixed system headers are the only admitted inputs.
|
|
96
|
-
// Custom arguments, environment paths, or workspace headers can alter declarations.
|
|
97
|
-
if (language !== 'CPP' ||
|
|
98
|
-
compileArgs.length ||
|
|
99
|
-
Object.keys(options.env ?? {}).length ||
|
|
100
|
-
options.workspaceFiles?.some((file) => file.path !== options.activePath && !/\.(?:c|cc|cpp|cxx|wasm)$/i.test(file.path)))
|
|
101
|
-
return;
|
|
102
|
-
let rest = code.replace(/^\uFEFF/, '');
|
|
103
|
-
for (;;) {
|
|
104
|
-
rest = rest.replace(/^\s+/, '');
|
|
105
|
-
if (rest.startsWith('//')) {
|
|
106
|
-
const end = rest.indexOf('\n');
|
|
107
|
-
if (end < 0 || rest.slice(0, end).trimEnd().endsWith('\\'))
|
|
108
|
-
return;
|
|
109
|
-
rest = rest.slice(end + 1);
|
|
110
|
-
}
|
|
111
|
-
else if (rest.startsWith('/*')) {
|
|
112
|
-
const end = rest.indexOf('*/', 2);
|
|
113
|
-
if (end < 0)
|
|
114
|
-
return;
|
|
115
|
-
rest = rest.slice(end + 2);
|
|
116
|
-
}
|
|
117
|
-
else
|
|
118
|
-
break;
|
|
119
|
-
}
|
|
120
|
-
if (!/^#[ \t]*include[ \t]*<bits\/stdc\+\+\.h>/.test(rest))
|
|
121
|
-
return;
|
|
122
|
-
return JSON.stringify([cwd, standard, '-fno-exceptions']);
|
|
123
|
-
}
|
|
124
|
-
discardHeader() {
|
|
125
|
-
if (!this.#header)
|
|
126
|
-
return;
|
|
127
|
-
try {
|
|
128
|
-
this.profile.container.fs.unlink(this.#header.path);
|
|
129
|
-
}
|
|
130
|
-
catch {
|
|
131
|
-
/* Already removed. */
|
|
132
|
-
}
|
|
133
|
-
this.#header = undefined;
|
|
134
|
-
}
|
|
135
|
-
async prepare(language, code, args, options, signal, progress, requestId) {
|
|
136
|
-
if (this.#active.has(language))
|
|
137
|
-
throw new Error(`${language} already has an active command`);
|
|
138
|
-
const input = this.files.inputs(language, code, options);
|
|
139
|
-
const cwd = this.files.directory(language), artifact = `${cwd}/program.wasm`;
|
|
140
|
-
const job = { language, phase: 'prepare', signal };
|
|
141
|
-
this.#active.set(language, job);
|
|
142
|
-
this.#prepared.delete(language);
|
|
143
|
-
try {
|
|
144
|
-
progress?.report?.({
|
|
145
|
-
kind: 'activity',
|
|
146
|
-
phase: 'initializing',
|
|
147
|
-
label: 'Preparing the Clang toolchain'
|
|
148
|
-
});
|
|
149
|
-
await this.profile.prepareCommand({ path: '/usr/local/bin/clang' }, signal);
|
|
150
|
-
const { compileArgs } = resolveSandboxExecutionArgs(language, args, options);
|
|
151
|
-
const standard = language === 'CPP'
|
|
152
|
-
? (options.cppVersion ?? 'CPP20').replace(/^CPP/, 'c++').toLowerCase()
|
|
153
|
-
: options.cVersion?.toLowerCase();
|
|
154
|
-
// An opaque response file or -x override can select C++ for a C editor.
|
|
155
|
-
// Keep its default source mode C while enabling the C++ driver's link libraries.
|
|
156
|
-
const override = compileArgs.some((arg) => arg.startsWith('@') || arg.startsWith('-x'));
|
|
157
|
-
const common = [
|
|
158
|
-
...(language === 'CPP' || override ? ['--driver-mode=g++'] : []),
|
|
159
|
-
...(language === 'C' && override ? ['-x', 'c'] : []),
|
|
160
|
-
...(standard ? [`-std=${standard}`] : []),
|
|
161
|
-
'-fno-color-diagnostics',
|
|
162
|
-
'-fno-exceptions',
|
|
163
|
-
...compileArgs
|
|
164
|
-
];
|
|
165
|
-
const compile = async (argv, quiet = false) => {
|
|
166
|
-
job.process = await this.profile.container.spawn('clang', argv, {
|
|
167
|
-
cwd,
|
|
168
|
-
signal,
|
|
169
|
-
env: options.env
|
|
170
|
-
});
|
|
171
|
-
const drained = this.drain(job.process, language, requestId, !quiet, quiet);
|
|
172
|
-
await job.process.stdin.getWriter().close();
|
|
173
|
-
const result = await drained;
|
|
174
|
-
if (job.stopped)
|
|
175
|
-
throw new DOMException('Command cancelled', 'AbortError');
|
|
176
|
-
return this.success(result, signal);
|
|
177
|
-
};
|
|
178
|
-
const headerKey = this.headerKey(language, input.code, compileArgs, input.options, cwd, standard);
|
|
179
|
-
if (headerKey && this.#header?.key !== headerKey)
|
|
180
|
-
this.discardHeader();
|
|
181
|
-
let header = headerKey === this.#header?.key ? this.#header : undefined;
|
|
182
|
-
if (header) {
|
|
183
|
-
// Restore owned bytes instead of trusting a writable temporary file.
|
|
184
|
-
try {
|
|
185
|
-
try {
|
|
186
|
-
this.profile.container.fs.unlink(header.path);
|
|
187
|
-
}
|
|
188
|
-
catch {
|
|
189
|
-
/* Already removed. */
|
|
190
|
-
}
|
|
191
|
-
this.profile.container.fs.writeFile(header.path, header.bytes);
|
|
192
|
-
}
|
|
193
|
-
catch {
|
|
194
|
-
this.discardHeader();
|
|
195
|
-
header = undefined;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
let okay = await compile([
|
|
199
|
-
...common,
|
|
200
|
-
...(header ? ['-include-pch', header.path] : []),
|
|
201
|
-
input.options.activePath,
|
|
202
|
-
'-lc-printscan-long-double',
|
|
203
|
-
'-o',
|
|
204
|
-
artifact
|
|
205
|
-
]);
|
|
206
|
-
if (header && okay)
|
|
207
|
-
progress?.set?.(95, 'Compiled with precompiled <bits/stdc++.h>');
|
|
208
|
-
else if (header) {
|
|
209
|
-
this.discardHeader();
|
|
210
|
-
okay = await compile([
|
|
211
|
-
...common,
|
|
212
|
-
input.options.activePath,
|
|
213
|
-
'-lc-printscan-long-double',
|
|
214
|
-
'-o',
|
|
215
|
-
artifact
|
|
216
|
-
]);
|
|
217
|
-
}
|
|
218
|
-
if (okay && headerKey && !this.#header) {
|
|
219
|
-
const path = `/tmp/wasm-idle-stdcpp-${crypto.randomUUID()}.pch`;
|
|
220
|
-
try {
|
|
221
|
-
if (await compile([
|
|
222
|
-
...common,
|
|
223
|
-
'-c',
|
|
224
|
-
'-x',
|
|
225
|
-
'c++-header',
|
|
226
|
-
'/usr/share/wasm-sysroot/include/bits/stdc++.h',
|
|
227
|
-
'-o',
|
|
228
|
-
path
|
|
229
|
-
], true)) {
|
|
230
|
-
const bytes = this.profile.container.fs.readFile(path);
|
|
231
|
-
if (bytes.byteLength > 0 && bytes.byteLength <= 32 * 1024 * 1024)
|
|
232
|
-
this.#header = { key: headerKey, path, bytes };
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
catch (error) {
|
|
236
|
-
if (signal.aborted || job.stopped)
|
|
237
|
-
throw error;
|
|
238
|
-
}
|
|
239
|
-
finally {
|
|
240
|
-
if (this.#header?.path !== path) {
|
|
241
|
-
try {
|
|
242
|
-
this.profile.container.fs.unlink(path);
|
|
243
|
-
}
|
|
244
|
-
catch {
|
|
245
|
-
/* No usable header. */
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
if (okay)
|
|
251
|
-
this.#prepared.set(language, this.key(language, input.code, args, options));
|
|
252
|
-
return okay;
|
|
253
|
-
}
|
|
254
|
-
finally {
|
|
255
|
-
if (this.#active.get(language) === job)
|
|
256
|
-
this.#active.delete(language);
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
async run(language, code, args, options, signal, progress, requestId) {
|
|
260
|
-
const input = this.files.inputs(language, code, options);
|
|
261
|
-
if (this.#prepared.get(language) !== this.key(language, input.code, args, options) &&
|
|
262
|
-
!(await this.prepare(language, code, args, options, signal, progress, requestId)))
|
|
263
|
-
return false;
|
|
264
|
-
const cwd = this.files.directory(language), job = { language, phase: 'run', signal };
|
|
265
|
-
if (this.#active.has(language))
|
|
266
|
-
throw new Error(`${language} already has an active command`);
|
|
267
|
-
this.#active.set(language, job);
|
|
268
|
-
try {
|
|
269
|
-
const { programArgs } = resolveSandboxExecutionArgs(language, args, options);
|
|
270
|
-
job.process = await this.profile.container.spawn('wasm-run', [`${cwd}/program.wasm`, ...programArgs], { cwd, signal, env: options.env });
|
|
271
|
-
job.writer = job.process.stdin.getWriter();
|
|
272
|
-
progress?.report?.({
|
|
273
|
-
kind: 'ready',
|
|
274
|
-
state: 'running',
|
|
275
|
-
reason: 'started',
|
|
276
|
-
label: 'Container program started'
|
|
277
|
-
});
|
|
278
|
-
const drained = this.drain(job.process, language, requestId);
|
|
279
|
-
if (options.stdin !== undefined) {
|
|
280
|
-
await job.writer.write(new TextEncoder().encode(options.stdin));
|
|
281
|
-
await job.writer.close();
|
|
282
|
-
}
|
|
283
|
-
else
|
|
284
|
-
await this.flush(language);
|
|
285
|
-
return this.success(await drained, signal);
|
|
286
|
-
}
|
|
287
|
-
finally {
|
|
288
|
-
job.writer?.releaseLock();
|
|
289
|
-
this.#input.delete(language);
|
|
290
|
-
if (this.#active.get(language) === job)
|
|
291
|
-
this.#active.delete(language);
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
async flush(language) {
|
|
295
|
-
const writer = this.#active.get(language)?.writer;
|
|
296
|
-
if (!writer)
|
|
297
|
-
return;
|
|
298
|
-
const queue = this.queue(language);
|
|
299
|
-
for (const text of queue.chunks.splice(0)) {
|
|
300
|
-
const bytes = new TextEncoder().encode(text);
|
|
301
|
-
await writer.write(bytes);
|
|
302
|
-
queue.size -= bytes.byteLength;
|
|
303
|
-
}
|
|
304
|
-
if (queue.eof) {
|
|
305
|
-
queue.eof = false;
|
|
306
|
-
await writer.close();
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
async write(language, text) {
|
|
310
|
-
const q = this.queue(language);
|
|
311
|
-
q.size += new TextEncoder().encode(text).length;
|
|
312
|
-
if (q.size > 8 * 1024 * 1024)
|
|
313
|
-
throw new Error('Pending stdin exceeds its limit');
|
|
314
|
-
q.chunks.push(text);
|
|
315
|
-
await this.flush(language);
|
|
316
|
-
}
|
|
317
|
-
async eof(language) {
|
|
318
|
-
this.queue(language).eof = true;
|
|
319
|
-
await this.flush(language);
|
|
320
|
-
}
|
|
321
|
-
async stop(language) {
|
|
322
|
-
this.#input.delete(language);
|
|
323
|
-
const job = this.#active.get(language);
|
|
324
|
-
if (job)
|
|
325
|
-
job.stopped = true;
|
|
326
|
-
await job?.process?.terminate();
|
|
327
|
-
}
|
|
328
|
-
clear(language) {
|
|
329
|
-
this.#input.delete(language);
|
|
330
|
-
}
|
|
331
|
-
inspect() {
|
|
332
|
-
return [...this.#active.values()].map((job) => ({
|
|
333
|
-
language: job.language,
|
|
334
|
-
phase: job.phase,
|
|
335
|
-
pid: job.process?.pid,
|
|
336
|
-
filesystem: 'live'
|
|
337
|
-
}));
|
|
338
|
-
}
|
|
339
|
-
async dispose() {
|
|
340
|
-
await Promise.allSettled([...this.#active.keys()].map((language) => this.stop(language)));
|
|
341
|
-
this.discardHeader();
|
|
342
|
-
}
|
|
343
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { type ContainerWorkerCallOptions, type ContainerWorkerEvent, type ContainerWorkerInitialization } from './protocol';
|
|
2
|
-
export interface ContainerWorkerClient {
|
|
3
|
-
call<T = unknown>(method: string, args?: unknown[], options?: ContainerWorkerCallOptions): Promise<T>;
|
|
4
|
-
onEvent(listener: (event: ContainerWorkerEvent) => void): () => void;
|
|
5
|
-
dispose(): Promise<void>;
|
|
6
|
-
}
|
|
7
|
-
type OwnerWorker = Pick<Worker, 'postMessage' | 'addEventListener' | 'removeEventListener' | 'terminate'>;
|
|
8
|
-
interface ClientOptions extends ContainerWorkerInitialization {
|
|
9
|
-
/** Injection is used only by deterministic transport tests. */
|
|
10
|
-
workerFactory?: () => OwnerWorker;
|
|
11
|
-
initializationTimeoutMs?: number;
|
|
12
|
-
cleanupDeadlineMs?: number;
|
|
13
|
-
}
|
|
14
|
-
export declare function createContainerWorkerClient(options: ClientOptions): ContainerWorkerClient;
|
|
15
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|