wasm-idle 1.1.2 → 1.2.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 +134 -82
- 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 +1 -1
- 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-FMHDKUN6.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 +23 -2
- package/dist/playground/lldbSession.js +278 -58
- 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 +8 -1
- package/dist/playground/python.js +81 -6
- 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/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/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/wasmRustVersion.d.ts +26 -38
- package/dist/playground/wasmRustVersion.js +25 -40
- 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 +57 -22
- 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/package.json +55 -11
- 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
package/dist/playground/lua.js
CHANGED
|
@@ -5,6 +5,8 @@ import { flushBufferedEof, flushQueuedStdin, resetBufferedStdin } from './stdinB
|
|
|
5
5
|
import { createWasmIdleSharedBuffer } from './sharedBuffer';
|
|
6
6
|
import { WorkerSession } from './workerSession';
|
|
7
7
|
import { reportWorkerInputReady, reportWorkerProgress } from './workerProgress';
|
|
8
|
+
import { LuaDebugMailbox } from './luaDebug';
|
|
9
|
+
import { requireSharedArrayBuffer } from './sharedBuffer';
|
|
8
10
|
const OUTPUT_ENCODER = new TextEncoder();
|
|
9
11
|
const abortReason = (signal, phase, label) => signal.reason !== undefined
|
|
10
12
|
? signal.reason
|
|
@@ -27,6 +29,7 @@ class Lua {
|
|
|
27
29
|
exit = true;
|
|
28
30
|
moduleUrl = '';
|
|
29
31
|
oncompilerdiagnostic;
|
|
32
|
+
ondebug;
|
|
30
33
|
waitingForInput = false;
|
|
31
34
|
pendingEof = false;
|
|
32
35
|
activeOperation = null;
|
|
@@ -38,6 +41,14 @@ class Lua {
|
|
|
38
41
|
workerIdentity = '';
|
|
39
42
|
disposeCancellation;
|
|
40
43
|
workerSession;
|
|
44
|
+
debugMailbox = new LuaDebugMailbox();
|
|
45
|
+
debugEnabled = false;
|
|
46
|
+
debugPaused = false;
|
|
47
|
+
debugPath = 'main.lua';
|
|
48
|
+
debugFrames = [];
|
|
49
|
+
selectedDebugFrame = 1;
|
|
50
|
+
evaluationId = 0;
|
|
51
|
+
pendingEvaluations = new Map();
|
|
41
52
|
constructor(dialect = LUA_DIALECT) {
|
|
42
53
|
this.dialect = dialect;
|
|
43
54
|
this.label = dialect.label;
|
|
@@ -55,6 +66,7 @@ class Lua {
|
|
|
55
66
|
this.exit = true;
|
|
56
67
|
this.waitingForInput = false;
|
|
57
68
|
this.pendingEof = false;
|
|
69
|
+
this.finishDebug();
|
|
58
70
|
}
|
|
59
71
|
});
|
|
60
72
|
}
|
|
@@ -82,6 +94,11 @@ class Lua {
|
|
|
82
94
|
cleanups: [],
|
|
83
95
|
explicitStdin: false
|
|
84
96
|
};
|
|
97
|
+
operation.cleanups.push(() => {
|
|
98
|
+
if (operation.timer !== undefined)
|
|
99
|
+
clearTimeout(operation.timer);
|
|
100
|
+
operation.timer = undefined;
|
|
101
|
+
});
|
|
85
102
|
this.activeOperation = operation;
|
|
86
103
|
return operation;
|
|
87
104
|
}
|
|
@@ -110,6 +127,8 @@ class Lua {
|
|
|
110
127
|
}
|
|
111
128
|
releaseBeforeSession(operation, reason) {
|
|
112
129
|
const outcome = operation.cancelled ? operation.cancellationReason : reason;
|
|
130
|
+
if (operation.phase === 'execute')
|
|
131
|
+
this.finishDebug();
|
|
113
132
|
this.releaseOperation(operation);
|
|
114
133
|
this.cleanupOperation(operation);
|
|
115
134
|
return outcome;
|
|
@@ -197,13 +216,12 @@ class Lua {
|
|
|
197
216
|
bindOperationTimeout(operation, timeoutMs) {
|
|
198
217
|
if (!this.isOperationActive(operation))
|
|
199
218
|
return;
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
});
|
|
219
|
+
if (operation.timer !== undefined)
|
|
220
|
+
clearTimeout(operation.timer);
|
|
221
|
+
operation.timerStartedAt = Date.now();
|
|
222
|
+
operation.timeoutRemainingMs = timeoutMs;
|
|
205
223
|
try {
|
|
206
|
-
|
|
224
|
+
operation.timer = setTimeout(() => {
|
|
207
225
|
if (!this.isOperationActive(operation))
|
|
208
226
|
return;
|
|
209
227
|
const label = operation.phase === 'startup' ? 'startup' : 'execution';
|
|
@@ -214,12 +232,152 @@ class Lua {
|
|
|
214
232
|
}));
|
|
215
233
|
}, timeoutMs);
|
|
216
234
|
if (operation.cleanedUp)
|
|
217
|
-
clearTimeout(
|
|
235
|
+
clearTimeout(operation.timer);
|
|
218
236
|
}
|
|
219
237
|
catch (error) {
|
|
220
238
|
this.cancelOperation(operation, error);
|
|
221
239
|
}
|
|
222
240
|
}
|
|
241
|
+
pauseDebugTimeout() {
|
|
242
|
+
const operation = this.activeOperation;
|
|
243
|
+
if (!operation || operation.timer === undefined)
|
|
244
|
+
return;
|
|
245
|
+
clearTimeout(operation.timer);
|
|
246
|
+
operation.timer = undefined;
|
|
247
|
+
operation.timeoutRemainingMs = Math.max(1, (operation.timeoutRemainingMs ?? 1) -
|
|
248
|
+
(Date.now() - (operation.timerStartedAt ?? Date.now())));
|
|
249
|
+
}
|
|
250
|
+
finishDebug() {
|
|
251
|
+
const wasEnabled = this.debugEnabled;
|
|
252
|
+
this.debugEnabled = false;
|
|
253
|
+
this.debugPaused = false;
|
|
254
|
+
this.debugFrames = [];
|
|
255
|
+
this.debugMailbox.close();
|
|
256
|
+
for (const pending of this.pendingEvaluations.values()) {
|
|
257
|
+
clearTimeout(pending.timer);
|
|
258
|
+
pending.reject(new Error('Lua debugger is no longer paused.'));
|
|
259
|
+
}
|
|
260
|
+
this.pendingEvaluations.clear();
|
|
261
|
+
if (wasEnabled) {
|
|
262
|
+
try {
|
|
263
|
+
this.ondebug?.({ type: 'stop' });
|
|
264
|
+
}
|
|
265
|
+
catch (error) {
|
|
266
|
+
console.error('Lua debugger stop listener failed', error);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
handleDebugEvent(event) {
|
|
271
|
+
if (!this.debugEnabled)
|
|
272
|
+
return;
|
|
273
|
+
if (event.type === 'evaluate') {
|
|
274
|
+
const pending = this.pendingEvaluations.get(event.id);
|
|
275
|
+
if (!pending)
|
|
276
|
+
return;
|
|
277
|
+
this.pendingEvaluations.delete(event.id);
|
|
278
|
+
clearTimeout(pending.timer);
|
|
279
|
+
if (event.error)
|
|
280
|
+
pending.reject(new Error(event.error));
|
|
281
|
+
else
|
|
282
|
+
pending.resolve(event.value ?? 'nil');
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
this.debugPaused = true;
|
|
286
|
+
this.pauseDebugTimeout();
|
|
287
|
+
this.selectedDebugFrame = 1;
|
|
288
|
+
this.debugFrames = event.frames.map((frame, index) => ({
|
|
289
|
+
...frame,
|
|
290
|
+
id: index + 1,
|
|
291
|
+
sourcePath: `/workspace/${frame.sourcePath}`
|
|
292
|
+
}));
|
|
293
|
+
this.ondebug?.({
|
|
294
|
+
type: 'pause',
|
|
295
|
+
line: event.line,
|
|
296
|
+
reason: event.reason,
|
|
297
|
+
sourcePath: `/workspace/${event.sourcePath}`,
|
|
298
|
+
frameId: 1,
|
|
299
|
+
locals: this.debugFrames[0]?.locals ?? [],
|
|
300
|
+
callStack: this.debugFrames.map(({ locals: _locals, ...frame }) => frame)
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
debugCommand(command) {
|
|
304
|
+
if (!this.debugEnabled || !this.debugPaused)
|
|
305
|
+
throw new Error('Lua debugger is not paused.');
|
|
306
|
+
this.debugMailbox.send(`${command === 'stepInto' ? 'STEP' : command === 'nextLine' ? 'OVER' : command === 'stepOut' ? 'OUT' : 'RUN'}\n`);
|
|
307
|
+
this.debugPaused = false;
|
|
308
|
+
this.debugFrames = [];
|
|
309
|
+
for (const pending of this.pendingEvaluations.values()) {
|
|
310
|
+
clearTimeout(pending.timer);
|
|
311
|
+
pending.reject(new Error('Lua debugger resumed.'));
|
|
312
|
+
}
|
|
313
|
+
this.pendingEvaluations.clear();
|
|
314
|
+
const operation = this.activeOperation;
|
|
315
|
+
if (operation)
|
|
316
|
+
this.bindOperationTimeout(operation, operation.timeoutRemainingMs ?? 1);
|
|
317
|
+
this.ondebug?.({ type: 'resume', command });
|
|
318
|
+
}
|
|
319
|
+
setBreakpoints(lines, sourcePath) {
|
|
320
|
+
if (!this.debugEnabled)
|
|
321
|
+
return;
|
|
322
|
+
if (sourcePath && sourcePath.replace(/^\/workspace\//u, '') !== this.debugPath)
|
|
323
|
+
return;
|
|
324
|
+
const next = [
|
|
325
|
+
...new Set(lines.filter((line) => Number.isSafeInteger(line) && line > 0))
|
|
326
|
+
].slice(0, 1024);
|
|
327
|
+
this.debugMailbox.send(`DELB * 0\n${next.map((line) => `SETB ${this.debugPath} ${line}\n`).join('')}`);
|
|
328
|
+
}
|
|
329
|
+
debugEvaluate(expression) {
|
|
330
|
+
if (!this.debugEnabled || !this.debugPaused)
|
|
331
|
+
return Promise.reject(new Error('Lua debugger is not paused.'));
|
|
332
|
+
if (this.selectedDebugFrame !== 1)
|
|
333
|
+
return Promise.reject(new Error('Lua evaluation currently supports the top frame only.'));
|
|
334
|
+
if (!expression || expression.length > 4096 || this.pendingEvaluations.size >= 64) {
|
|
335
|
+
return Promise.reject(new RangeError('Lua debugger expression limit exceeded.'));
|
|
336
|
+
}
|
|
337
|
+
const id = ++this.evaluationId;
|
|
338
|
+
return new Promise((resolve, reject) => {
|
|
339
|
+
const timer = setTimeout(() => {
|
|
340
|
+
this.pendingEvaluations.delete(id);
|
|
341
|
+
reject(new Error('Lua debugger evaluation timed out.'));
|
|
342
|
+
}, 5000);
|
|
343
|
+
this.pendingEvaluations.set(id, { resolve, reject, timer });
|
|
344
|
+
try {
|
|
345
|
+
this.debugMailbox.send(`EXEC return (${expression.replace(/[\r\n]/gu, '\f')}) --{stack=${this.selectedDebugFrame},requestId=${id},metatostring=false,maxlevel=2,maxnum=25,maxlength=1024}\n`);
|
|
346
|
+
}
|
|
347
|
+
catch (error) {
|
|
348
|
+
clearTimeout(timer);
|
|
349
|
+
this.pendingEvaluations.delete(id);
|
|
350
|
+
reject(error);
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
async debugScopes(frameId = this.selectedDebugFrame) {
|
|
355
|
+
this.selectedDebugFrame = frameId;
|
|
356
|
+
return this.debugFrameScopes(frameId);
|
|
357
|
+
}
|
|
358
|
+
async debugFrameScopes(frameId) {
|
|
359
|
+
if (!this.debugPaused)
|
|
360
|
+
return [];
|
|
361
|
+
const frame = this.debugFrames[frameId - 1];
|
|
362
|
+
return frame
|
|
363
|
+
? [
|
|
364
|
+
{
|
|
365
|
+
name: 'Locals',
|
|
366
|
+
variablesReference: frameId,
|
|
367
|
+
expensive: false,
|
|
368
|
+
namedVariables: frame.locals.length,
|
|
369
|
+
variables: frame.locals
|
|
370
|
+
}
|
|
371
|
+
]
|
|
372
|
+
: [];
|
|
373
|
+
}
|
|
374
|
+
async debugFrameName(frameId) {
|
|
375
|
+
return this.debugPaused ? (this.debugFrames[frameId - 1]?.functionName ?? null) : null;
|
|
376
|
+
}
|
|
377
|
+
async debugVariables(reference, start = 0, count) {
|
|
378
|
+
const variables = this.debugPaused ? (this.debugFrames[reference - 1]?.locals ?? []) : [];
|
|
379
|
+
return variables.slice(start, count === undefined ? undefined : start + count);
|
|
380
|
+
}
|
|
223
381
|
resetExplicitStdinState() {
|
|
224
382
|
this.pendingInput = [];
|
|
225
383
|
this.pendingEof = false;
|
|
@@ -429,6 +587,19 @@ class Lua {
|
|
|
429
587
|
maxTotalBytes: Math.min(workspaceLimits?.maxTotalBytes ?? DEFAULT_WORKSPACE_LIMITS.maxTotalBytes, limits.maxWorkspaceBytes)
|
|
430
588
|
});
|
|
431
589
|
stdin = options.stdin;
|
|
590
|
+
const debugMode = options.debugMode ?? (options.debug ? 'mobdebug' : 'none');
|
|
591
|
+
if (!['none', 'trace', 'mobdebug'].includes(debugMode)) {
|
|
592
|
+
throw new RuntimeConfigurationError('Lua debugging uses the MobDebug backend.');
|
|
593
|
+
}
|
|
594
|
+
if (!prepare && debugMode !== 'none') {
|
|
595
|
+
if (this.runtimeId !== 'LUA')
|
|
596
|
+
throw new RuntimeConfigurationError(`${this.label} source debugging is not supported.`);
|
|
597
|
+
requireSharedArrayBuffer('Lua debugging');
|
|
598
|
+
this.debugEnabled = true;
|
|
599
|
+
this.debugPaused = false;
|
|
600
|
+
this.debugPath = workspace.activePath ?? this.dialect.defaultActivePath;
|
|
601
|
+
this.debugMailbox.reset();
|
|
602
|
+
}
|
|
432
603
|
if (!this.isOperationActive(activeOperation) || signal?.aborted) {
|
|
433
604
|
return Promise.reject(this.releaseBeforeSession(activeOperation, `${this.label} execution cancelled`));
|
|
434
605
|
}
|
|
@@ -469,6 +640,7 @@ class Lua {
|
|
|
469
640
|
this.exit = true;
|
|
470
641
|
this.waitingForInput = false;
|
|
471
642
|
this.pendingEof = false;
|
|
643
|
+
this.finishDebug();
|
|
472
644
|
this.workerSession.complete(operation);
|
|
473
645
|
this.releaseOperation(activeOperation);
|
|
474
646
|
this.cleanupOperation(activeOperation);
|
|
@@ -496,7 +668,11 @@ class Lua {
|
|
|
496
668
|
if (!ownsRun())
|
|
497
669
|
return;
|
|
498
670
|
try {
|
|
499
|
-
const { output, results, error, buffer, diagnostic, progress } = event.data;
|
|
671
|
+
const { output, results, error, buffer, diagnostic, progress, luaDebug, debugCommandConsumed } = event.data;
|
|
672
|
+
if (debugCommandConsumed)
|
|
673
|
+
this.debugMailbox.flush();
|
|
674
|
+
if (luaDebug)
|
|
675
|
+
this.handleDebugEvent(luaDebug);
|
|
500
676
|
if (buffer && !hasExplicitStdin) {
|
|
501
677
|
this.waitingForInput = true;
|
|
502
678
|
if (!prepare) {
|
|
@@ -569,6 +745,10 @@ class Lua {
|
|
|
569
745
|
stdin,
|
|
570
746
|
activePath: workspace.activePath,
|
|
571
747
|
workspaceFiles: workspace.workspaceFiles,
|
|
748
|
+
debug: this.debugEnabled,
|
|
749
|
+
debugBuffer: this.debugEnabled ? this.debugMailbox.buffer : undefined,
|
|
750
|
+
breakpoints: options.breakpoints ?? [],
|
|
751
|
+
pauseOnEntry: options.pauseOnEntry !== false,
|
|
572
752
|
log: _log
|
|
573
753
|
});
|
|
574
754
|
}
|
|
@@ -595,6 +775,7 @@ class Lua {
|
|
|
595
775
|
this.waitingForInput = false;
|
|
596
776
|
this.pendingEof = false;
|
|
597
777
|
this.exit = true;
|
|
778
|
+
this.finishDebug();
|
|
598
779
|
this.workerSession.terminate(reason);
|
|
599
780
|
this.cleanupOperation(operation);
|
|
600
781
|
}
|
|
@@ -611,6 +792,7 @@ class Lua {
|
|
|
611
792
|
}
|
|
612
793
|
this.waitingForInput = false;
|
|
613
794
|
this.pendingEof = false;
|
|
795
|
+
this.finishDebug();
|
|
614
796
|
this.uid += 1;
|
|
615
797
|
this.workerSession.terminate(reason);
|
|
616
798
|
this.exit = true;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DebugCommandMailbox as LuaDebugMailbox, readDebugCommand as readLuaDebugCommand } from './debugMailbox';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DebugCommandMailbox as LuaDebugMailbox, readDebugCommand as readLuaDebugCommand } from './debugMailbox';
|
package/dist/playground/nim.d.ts
CHANGED
package/dist/playground/nim.js
CHANGED
|
@@ -2,6 +2,14 @@ import { resolveNimRuntimeAssetConfig } from './assets';
|
|
|
2
2
|
import { StaticWorkerRuntimeSandbox } from './staticWorkerRuntime';
|
|
3
3
|
import { RuntimeConfigurationError, preflightNimRuntimeAssets, snapshotNimRuntimePreflightProfile } from '@wasm-idle/core';
|
|
4
4
|
class Nim extends StaticWorkerRuntimeSandbox {
|
|
5
|
+
run(...args) {
|
|
6
|
+
const options = args[5] || {};
|
|
7
|
+
const debugMode = options.debugMode || (options.debug ? 'trace' : 'none');
|
|
8
|
+
if (debugMode !== 'none') {
|
|
9
|
+
return Promise.reject(new RuntimeConfigurationError('Nim debugging requires a debug-capable compiler producer. The packaged Nim runtime uses LLVM 8 release builds and does not return a DWARF artifact for LLDB.', { runtimeId: 'NIM' }));
|
|
10
|
+
}
|
|
11
|
+
return super.run(...args);
|
|
12
|
+
}
|
|
5
13
|
constructor() {
|
|
6
14
|
super({
|
|
7
15
|
displayName: 'Nim',
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { WorkerAssetBridge } from './assetBridge';
|
|
2
|
+
import { CompiledLldbSandbox } from './compiledLldb';
|
|
2
3
|
import type { RuntimeAssetCache } from './runtimeAssetCache';
|
|
3
|
-
import type { DebugCommand
|
|
4
|
+
import type { DebugCommand } from './options';
|
|
4
5
|
import { type PlaygroundRuntimeAssets } from './assets';
|
|
5
6
|
import type { SandboxExecutionOptions } from './options';
|
|
6
7
|
import type { Sandbox, SandboxProgress } from './sandbox';
|
|
8
|
+
import { type DebugSourceBreakpoint } from '@wasm-idle/core';
|
|
7
9
|
export type ObjectiveCSandboxLanguage = 'OBJC' | 'OBJECTIVECXX';
|
|
8
|
-
declare class ObjectiveC implements Sandbox {
|
|
10
|
+
declare class ObjectiveC extends CompiledLldbSandbox implements Sandbox {
|
|
9
11
|
language: ObjectiveCSandboxLanguage;
|
|
10
|
-
output?: (data: string) => void;
|
|
11
|
-
ondebug?: (event: DebugSessionEvent) => void;
|
|
12
12
|
worker?: Worker;
|
|
13
13
|
buffer: import("./sharedBuffer").WasmIdleSharedBuffer;
|
|
14
14
|
debugBuffer: import("./sharedBuffer").WasmIdleSharedBuffer;
|
|
@@ -34,8 +34,9 @@ declare class ObjectiveC implements Sandbox {
|
|
|
34
34
|
eof(): void;
|
|
35
35
|
private flushPendingInput;
|
|
36
36
|
run(code: string, prepare: boolean, log?: boolean, prog?: SandboxProgress, args?: string[], options?: SandboxExecutionOptions): Promise<boolean | string>;
|
|
37
|
-
debugCommand(command: DebugCommand): void;
|
|
38
|
-
setBreakpoints(lines: number[]): void;
|
|
37
|
+
debugCommand(command: DebugCommand): Promise<void> | undefined;
|
|
38
|
+
setBreakpoints(lines: number[], sourcePath?: string): Promise<void> | undefined;
|
|
39
|
+
setSourceBreakpoints(breakpoints: DebugSourceBreakpoint[], sourcePath?: string): Promise<any>;
|
|
39
40
|
debugEvaluate(expression: string): Promise<string>;
|
|
40
41
|
kill(): void;
|
|
41
42
|
terminate(): void;
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { WorkerAssetBridge } from './assetBridge';
|
|
2
|
+
import { CompiledLldbSandbox } from './compiledLldb';
|
|
2
3
|
import { resolveObjectiveCRuntimeAssetConfig, resolveRuntimeAssetConfig } from './assets';
|
|
3
4
|
import { resolveSandboxExecutionArgs } from './options';
|
|
4
5
|
import { createWasmIdleSharedBuffer, requireSharedArrayBuffer } from './sharedBuffer';
|
|
5
6
|
import { WorkerSession } from './workerSession';
|
|
6
7
|
import { reportWorkerInputReady } from './workerProgress';
|
|
7
8
|
import { bufferedSequence, flushBufferedEof, flushQueuedStdin, resetBufferedStdin, waitForBufferedSequenceChange } from './stdinBuffer';
|
|
8
|
-
import { AssetTooLargeError, RuntimeConfigurationError, createRuntimeAssetsKey, resolveExecutionLimits } from '@wasm-idle/core';
|
|
9
|
+
import { AssetTooLargeError, RuntimeConfigurationError, assertDebugBreakpointSupport, createRuntimeAssetsKey, normalizeDebugSourceBreakpoints, resolveExecutionLimits } from '@wasm-idle/core';
|
|
9
10
|
const debugBreakpointBufferInts = 1028;
|
|
10
11
|
const objectiveCAssetsKey = (assets) => createRuntimeAssetsKey({ objectivec: assets }) || '';
|
|
11
|
-
class ObjectiveC {
|
|
12
|
+
class ObjectiveC extends CompiledLldbSandbox {
|
|
12
13
|
language;
|
|
13
|
-
output;
|
|
14
|
-
ondebug;
|
|
15
14
|
worker = null;
|
|
16
15
|
buffer = createWasmIdleSharedBuffer(4096);
|
|
17
16
|
debugBuffer = createWasmIdleSharedBuffer(Int32Array.BYTES_PER_ELEMENT * debugBreakpointBufferInts);
|
|
@@ -51,6 +50,7 @@ class ObjectiveC {
|
|
|
51
50
|
}
|
|
52
51
|
});
|
|
53
52
|
constructor(language = 'OBJC') {
|
|
53
|
+
super();
|
|
54
54
|
this.language = language;
|
|
55
55
|
}
|
|
56
56
|
setRuntimeAssetCache(cache) {
|
|
@@ -70,6 +70,7 @@ class ObjectiveC {
|
|
|
70
70
|
return Promise.reject(error);
|
|
71
71
|
}
|
|
72
72
|
return this.workerSession.load(async (resolve, reject, operation) => {
|
|
73
|
+
this.configureLldb(runtimeAssets, options);
|
|
73
74
|
this.log = log;
|
|
74
75
|
this.pendingInput = [];
|
|
75
76
|
this.waitingForInput = false;
|
|
@@ -140,11 +141,19 @@ class ObjectiveC {
|
|
|
140
141
|
});
|
|
141
142
|
}
|
|
142
143
|
write(input) {
|
|
144
|
+
if (this.lldbSession) {
|
|
145
|
+
void this.lldbSession.write(input);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
143
148
|
this.pendingInput.push(input);
|
|
144
149
|
this.pendingEof = false;
|
|
145
150
|
this.flushPendingInput();
|
|
146
151
|
}
|
|
147
152
|
eof() {
|
|
153
|
+
if (this.lldbSession) {
|
|
154
|
+
void this.lldbSession.eof();
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
148
157
|
this.pendingEof = true;
|
|
149
158
|
this.flushPendingInput();
|
|
150
159
|
}
|
|
@@ -162,15 +171,26 @@ class ObjectiveC {
|
|
|
162
171
|
}
|
|
163
172
|
}
|
|
164
173
|
run(code, prepare, log = this.log, prog, args = [], options = {}) {
|
|
165
|
-
|
|
174
|
+
const debugMode = options.debugMode || (options.debug ? 'trace' : 'none');
|
|
175
|
+
if (debugMode !== 'none' && debugMode !== 'trace' && debugMode !== 'lldb') {
|
|
176
|
+
return Promise.reject(new Error(`Objective-C does not support ${debugMode} debugging.`));
|
|
177
|
+
}
|
|
178
|
+
if (debugMode !== 'none')
|
|
166
179
|
requireSharedArrayBuffer('Objective-C debugging');
|
|
180
|
+
if (debugMode === 'lldb') {
|
|
181
|
+
this.prepareLldb(options, this.language === 'OBJECTIVECXX' ? 'main.mm' : 'main.m');
|
|
182
|
+
}
|
|
183
|
+
else
|
|
184
|
+
this.lldbPending = false;
|
|
167
185
|
this.exit = false;
|
|
168
186
|
return new Promise((resolve, reject) => {
|
|
169
187
|
if (!this.worker)
|
|
170
188
|
return reject('Worker not loaded');
|
|
171
189
|
const operation = this.workerSession.beginRun(this.worker, reject);
|
|
172
190
|
const { compileArgs, programArgs } = resolveSandboxExecutionArgs(this.language, args, options);
|
|
173
|
-
|
|
191
|
+
if (debugMode !== 'lldb') {
|
|
192
|
+
this.setBreakpoints(debugMode === 'trace' ? [...(options.breakpoints || [])] : []);
|
|
193
|
+
}
|
|
174
194
|
const interrupt = new Uint8Array(this.interruptBuffer);
|
|
175
195
|
const _uid = ++this.uid;
|
|
176
196
|
const handler = (event) => {
|
|
@@ -182,7 +202,33 @@ class ObjectiveC {
|
|
|
182
202
|
return reject('Worker not loaded');
|
|
183
203
|
if (_uid !== this.uid)
|
|
184
204
|
return (this.worker.onmessage = null);
|
|
185
|
-
const { output, results, log, error, buffer, progress, debugEvent } = event.data;
|
|
205
|
+
const { output, results, log, error, buffer, progress, debugEvent, lldbArtifact } = event.data;
|
|
206
|
+
if (lldbArtifact) {
|
|
207
|
+
const worker = this.worker;
|
|
208
|
+
const completion = this.startLldb(lldbArtifact, options, programArgs, this.pendingInput, this.pendingEof);
|
|
209
|
+
this.pendingEof = false;
|
|
210
|
+
if (this.workerSession.release(worker)) {
|
|
211
|
+
this.assetBridge?.dispose();
|
|
212
|
+
this.assetBridge = null;
|
|
213
|
+
delete this.worker;
|
|
214
|
+
}
|
|
215
|
+
void completion.then((result) => {
|
|
216
|
+
if (!this.workerSession.isActive(operation))
|
|
217
|
+
return;
|
|
218
|
+
this.elapse = Date.now() - this.begin;
|
|
219
|
+
this.exit = true;
|
|
220
|
+
this.workerSession.complete(operation);
|
|
221
|
+
resolve(result);
|
|
222
|
+
}, (sessionError) => {
|
|
223
|
+
if (!this.workerSession.isActive(operation))
|
|
224
|
+
return;
|
|
225
|
+
this.elapse = Date.now() - this.begin;
|
|
226
|
+
this.exit = true;
|
|
227
|
+
this.workerSession.complete(operation);
|
|
228
|
+
reject(sessionError);
|
|
229
|
+
});
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
186
232
|
if (buffer) {
|
|
187
233
|
this.waitingForInput = true;
|
|
188
234
|
if (!prepare) {
|
|
@@ -195,6 +241,7 @@ class ObjectiveC {
|
|
|
195
241
|
if (debugEvent)
|
|
196
242
|
this.ondebug?.(debugEvent);
|
|
197
243
|
if (results) {
|
|
244
|
+
this.lldbPending = false;
|
|
198
245
|
this.elapse = Date.now() - this.begin;
|
|
199
246
|
this.exit = true;
|
|
200
247
|
this.waitingForInput = false;
|
|
@@ -206,6 +253,7 @@ class ObjectiveC {
|
|
|
206
253
|
if (log)
|
|
207
254
|
console.log(log);
|
|
208
255
|
if (error) {
|
|
256
|
+
this.lldbPending = false;
|
|
209
257
|
this.elapse = Date.now() - this.begin;
|
|
210
258
|
this.waitingForInput = false;
|
|
211
259
|
this.pendingEof = false;
|
|
@@ -232,23 +280,31 @@ class ObjectiveC {
|
|
|
232
280
|
log,
|
|
233
281
|
compileArgs,
|
|
234
282
|
programArgs,
|
|
283
|
+
cVersion: options.cVersion,
|
|
284
|
+
cppVersion: options.cppVersion,
|
|
285
|
+
gnuExtensions: options.objectivecGnuExtensions,
|
|
235
286
|
activePath: options.activePath ||
|
|
236
287
|
(this.language === 'OBJECTIVECXX' ? 'main.mm' : undefined),
|
|
237
288
|
workspaceFiles: options.workspaceFiles,
|
|
238
|
-
|
|
289
|
+
debugMode,
|
|
290
|
+
debug: debugMode === 'trace',
|
|
239
291
|
breakpoints: [...(options.breakpoints || [])],
|
|
240
292
|
pauseOnEntry: !!options.pauseOnEntry
|
|
241
293
|
});
|
|
242
294
|
});
|
|
243
295
|
}
|
|
244
296
|
debugCommand(command) {
|
|
297
|
+
if (this.lldbPending)
|
|
298
|
+
return super.debugCommand(command);
|
|
245
299
|
const control = new Int32Array(this.debugBuffer);
|
|
246
300
|
Atomics.store(control, 1, command === 'stepInto' ? 2 : command === 'nextLine' ? 3 : command === 'stepOut' ? 4 : 1);
|
|
247
301
|
Atomics.add(control, 0, 1);
|
|
248
302
|
Atomics.notify(control, 0);
|
|
249
303
|
this.ondebug?.({ type: 'resume', command });
|
|
250
304
|
}
|
|
251
|
-
setBreakpoints(lines) {
|
|
305
|
+
setBreakpoints(lines, sourcePath) {
|
|
306
|
+
if (this.lldbPending)
|
|
307
|
+
return super.setBreakpoints(lines, sourcePath);
|
|
252
308
|
const control = new Int32Array(this.debugBuffer);
|
|
253
309
|
const next = [...new Set(lines.filter((line) => Number.isInteger(line) && line > 0))]
|
|
254
310
|
.sort((left, right) => left - right)
|
|
@@ -259,7 +315,16 @@ class ObjectiveC {
|
|
|
259
315
|
Atomics.store(control, 3, next.length);
|
|
260
316
|
Atomics.add(control, 2, 1);
|
|
261
317
|
}
|
|
318
|
+
async setSourceBreakpoints(breakpoints, sourcePath) {
|
|
319
|
+
if (this.lldbPending)
|
|
320
|
+
return super.setSourceBreakpoints(breakpoints, sourcePath);
|
|
321
|
+
const values = normalizeDebugSourceBreakpoints(breakpoints);
|
|
322
|
+
assertDebugBreakpointSupport(values, {});
|
|
323
|
+
this.setBreakpoints(values.filter((value) => value.enabled !== false).map((value) => value.line), sourcePath);
|
|
324
|
+
}
|
|
262
325
|
async debugEvaluate(expression) {
|
|
326
|
+
if (this.lldbPending)
|
|
327
|
+
return super.debugEvaluate(expression);
|
|
263
328
|
if (!this.worker)
|
|
264
329
|
throw new Error('Worker not loaded');
|
|
265
330
|
resetBufferedStdin(this.watchResultBuffer);
|
|
@@ -276,6 +341,7 @@ class ObjectiveC {
|
|
|
276
341
|
this.terminate();
|
|
277
342
|
}
|
|
278
343
|
terminate() {
|
|
344
|
+
void this.stopLldb();
|
|
279
345
|
this.waitingForInput = false;
|
|
280
346
|
this.pendingEof = false;
|
|
281
347
|
this.uid += 1;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { DebugSourceBreakpoints, ExecutionLimits, WorkspaceLimits } from '@wasm-idle/core';
|
|
2
|
-
export type { DebugArrayElementKind, DebugCommand, DebugDataBreakpoint, DebugDataBreakpointAccessType, DebugDataBreakpointInfo, DebugDataBreakpointInfoArguments, DebugFrame, DebugMemory, DebugPauseReason, DebugResolvedBreakpoint, DebugResolvedDataBreakpoint, DebugSessionCapabilities, DebugSessionEvent, DebugScope, DebugSourceBreakpoints, DebugStructFieldMetadata, DebugVariable, DebugVariableKind, DebugVariableMetadata, DebugWriteMemoryResult } from '@wasm-idle/core';
|
|
1
|
+
import type { DebugSourceBreakpoints, DebugSteppingOptions, ExecutionLimits, WorkspaceLimits } from '@wasm-idle/core';
|
|
2
|
+
export type { DebugArrayElementKind, DebugCommand, DebugEvaluateOptions, DebugEvaluateResult, DebugSourceBreakpoint, DebugSteppingOptions, DebugVariablePresentationHint, DebugDataBreakpoint, DebugDataBreakpointAccessType, DebugDataBreakpointInfo, DebugDataBreakpointInfoArguments, DebugFrame, DebugMemory, DebugPauseReason, DebugResolvedBreakpoint, DebugResolvedDataBreakpoint, DebugSessionCapabilities, DebugSessionEvent, DebugScope, DebugSourceBreakpoints, DebugStructFieldMetadata, DebugVariable, DebugVariableKind, DebugVariableMetadata, DebugWriteMemoryResult } from '@wasm-idle/core';
|
|
3
3
|
export type CompilerDiagnosticSeverity = 'error' | 'warning' | 'other';
|
|
4
4
|
export interface CompilerDiagnostic {
|
|
5
5
|
fileName?: string | null;
|
|
@@ -9,8 +9,9 @@ export interface CompilerDiagnostic {
|
|
|
9
9
|
severity: CompilerDiagnosticSeverity;
|
|
10
10
|
message: string;
|
|
11
11
|
}
|
|
12
|
+
export type RustOptimizationProfile = 'interactive' | 'speed' | 'size';
|
|
12
13
|
export type RustTargetTriple = 'wasm32-wasip1' | 'wasm32-wasip2' | 'wasm32-wasip3';
|
|
13
|
-
export type BrowserDebugMode = 'none' | 'trace' | 'lldb';
|
|
14
|
+
export type BrowserDebugMode = 'none' | 'trace' | 'lldb' | 'mobdebug' | 'tracepoint';
|
|
14
15
|
export type GoTarget = 'wasip1/wasm' | 'wasip2/wasm' | 'wasip3/wasm' | 'js/wasm';
|
|
15
16
|
export type TinyGoTarget = 'wasm' | 'wasip1' | 'wasip2' | 'wasip3';
|
|
16
17
|
export type OcamlBackend = 'js' | 'wasm';
|
|
@@ -24,12 +25,13 @@ export interface SandboxExecutionOptions {
|
|
|
24
25
|
/** Overrides instance/global persistent asset caching for this operation. */
|
|
25
26
|
persistentCache?: import('@wasm-idle/core').RuntimeAssetCacheOptions;
|
|
26
27
|
debugMode?: BrowserDebugMode;
|
|
27
|
-
/** @deprecated Use debugMode. true
|
|
28
|
+
/** @deprecated Use debugMode. true follows the language's compatibility backend. */
|
|
28
29
|
debug?: boolean;
|
|
29
30
|
/** Keep the final run alive until the host explicitly stops or disposes it. */
|
|
30
31
|
interactive?: boolean;
|
|
31
32
|
breakpoints?: number[];
|
|
32
33
|
sourceBreakpoints?: DebugSourceBreakpoints[];
|
|
34
|
+
debugSteppingOptions?: DebugSteppingOptions;
|
|
33
35
|
pauseOnEntry?: boolean;
|
|
34
36
|
stdin?: string;
|
|
35
37
|
signal?: AbortSignal;
|
|
@@ -44,7 +46,11 @@ export interface SandboxExecutionOptions {
|
|
|
44
46
|
env?: Record<string, string>;
|
|
45
47
|
cppVersion?: string;
|
|
46
48
|
cVersion?: string;
|
|
49
|
+
/** Select GNU dialects for each C/C++ source unit in the Objective-C worker. */
|
|
50
|
+
objectivecGnuExtensions?: boolean;
|
|
47
51
|
rustTargetTriple?: RustTargetTriple;
|
|
52
|
+
/** Optimizes the Rust user program while retaining overflow checks and debug assertions. */
|
|
53
|
+
rustOptimizationProfile?: RustOptimizationProfile;
|
|
48
54
|
goTarget?: GoTarget;
|
|
49
55
|
tinygoTarget?: TinyGoTarget;
|
|
50
56
|
ocamlBackend?: OcamlBackend;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DebugCommand, DebugSessionEvent, SandboxExecutionOptions } from './options';
|
|
1
|
+
import type { DebugCommand, DebugSessionEvent, DebugVariable, SandboxExecutionOptions } from './options';
|
|
2
2
|
import { WorkerAssetBridge } from './assetBridge';
|
|
3
3
|
import { RuntimeAssetCache } from './runtimeAssetCache';
|
|
4
4
|
import { type PlaygroundRuntimeAssets } from './assets';
|
|
@@ -17,6 +17,10 @@ declare class Python implements Sandbox {
|
|
|
17
17
|
debugBuffer: import("./sharedBuffer").WasmIdleSharedBuffer;
|
|
18
18
|
watchBuffer: import("./sharedBuffer").WasmIdleSharedBuffer;
|
|
19
19
|
watchResultBuffer: import("./sharedBuffer").WasmIdleSharedBuffer;
|
|
20
|
+
private pausedVariablesReference;
|
|
21
|
+
private inspectionController;
|
|
22
|
+
private inspectionFailure;
|
|
23
|
+
private inspectionQueue;
|
|
20
24
|
interruptBuffer: import("./sharedBuffer").WasmIdleSharedBuffer;
|
|
21
25
|
pendingInput: string[];
|
|
22
26
|
begin: number;
|
|
@@ -56,7 +60,10 @@ declare class Python implements Sandbox {
|
|
|
56
60
|
run(code: string, prepare: boolean, _log?: boolean, _prog?: SandboxProgress, _args?: string[], options?: SandboxExecutionOptions): Promise<boolean | string>;
|
|
57
61
|
debugCommand(command: DebugCommand): void;
|
|
58
62
|
setBreakpoints(lines: number[]): void;
|
|
63
|
+
private setInspectionPause;
|
|
64
|
+
private inspect;
|
|
59
65
|
debugEvaluate(expression: string): Promise<string>;
|
|
66
|
+
debugVariables(reference: number, start?: number, count?: number): Promise<DebugVariable[]>;
|
|
60
67
|
kill(): void;
|
|
61
68
|
terminate(reason?: unknown): void;
|
|
62
69
|
clear(): Promise<void>;
|