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,31 +1,31 @@
|
|
|
1
|
-
import { createContainerWorkerClient } from './client';
|
|
1
|
+
import { createContainerWorkerClient } from './client.js';
|
|
2
2
|
const copyFiles = (files) => files.map((file) => ({
|
|
3
3
|
path: file.path,
|
|
4
4
|
content: typeof file.content === 'string' ? file.content : Uint8Array.from(file.content)
|
|
5
5
|
}));
|
|
6
6
|
const bytes = (content) => typeof content === 'string' ? new TextEncoder().encode(content) : content;
|
|
7
7
|
const equal = (left, right) => {
|
|
8
|
+
if (left === right)
|
|
9
|
+
return true;
|
|
8
10
|
const a = bytes(left), b = bytes(right);
|
|
9
11
|
return a.length === b.length && a.every((byte, index) => byte === b[index]);
|
|
10
12
|
};
|
|
11
|
-
function sameFiles(left, right) {
|
|
12
|
-
return (left.length === right.length &&
|
|
13
|
-
left.every((file) => {
|
|
14
|
-
const other = right.find((candidate) => candidate.path === file.path);
|
|
15
|
-
return other && equal(file.content, other.content);
|
|
16
|
-
}));
|
|
17
|
-
}
|
|
18
13
|
/** Existing Terminal/Debug controls use this facade; every execution belongs to the owner Container. */
|
|
19
14
|
export function createContainerPlaygroundBinding(runtimeAssets, options) {
|
|
15
|
+
if (!options.workerFactory && !options.clientFactory)
|
|
16
|
+
throw new TypeError('A container owner workerFactory is required');
|
|
20
17
|
let client, disposed = false;
|
|
21
18
|
const sandboxes = new Map();
|
|
22
19
|
const published = new Map();
|
|
23
20
|
const changes = new Set();
|
|
24
21
|
const queues = new Map();
|
|
22
|
+
const reads = new Map();
|
|
23
|
+
const readQueues = new Map();
|
|
25
24
|
let shellOutput;
|
|
26
25
|
let shellError;
|
|
27
26
|
let shellConnection;
|
|
28
27
|
let requestedShellLanguage;
|
|
28
|
+
let terminalExecution = false;
|
|
29
29
|
const decoders = new Map();
|
|
30
30
|
const decoder = (key) => {
|
|
31
31
|
let value = decoders.get(key);
|
|
@@ -43,7 +43,8 @@ export function createContainerPlaygroundBinding(runtimeAssets, options) {
|
|
|
43
43
|
createContainerWorkerClient({
|
|
44
44
|
runtimeAssets,
|
|
45
45
|
applicationRootURL: options.applicationRootURL,
|
|
46
|
-
workspaceId: options.workspaceId
|
|
46
|
+
workspaceId: options.workspaceId,
|
|
47
|
+
workerFactory: options.workerFactory
|
|
47
48
|
});
|
|
48
49
|
client.onEvent((event) => {
|
|
49
50
|
if (event.name === 'workspace') {
|
|
@@ -77,6 +78,18 @@ export function createContainerPlaygroundBinding(runtimeAssets, options) {
|
|
|
77
78
|
});
|
|
78
79
|
return client;
|
|
79
80
|
};
|
|
81
|
+
const cleanupOwner = async (method, args = []) => {
|
|
82
|
+
if (!client || disposed)
|
|
83
|
+
return;
|
|
84
|
+
try {
|
|
85
|
+
await client.call(method, args);
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
// Terminal cleanup can race the parent disposing the complete owner.
|
|
89
|
+
if (!disposed)
|
|
90
|
+
throw error;
|
|
91
|
+
}
|
|
92
|
+
};
|
|
80
93
|
const syncWorkspace = (language, files) => {
|
|
81
94
|
const snapshot = copyFiles(files);
|
|
82
95
|
const previous = queues.get(language) ?? Promise.resolve();
|
|
@@ -84,14 +97,36 @@ export function createContainerPlaygroundBinding(runtimeAssets, options) {
|
|
|
84
97
|
.catch(() => { })
|
|
85
98
|
.then(async () => {
|
|
86
99
|
const baseline = published.get(language);
|
|
87
|
-
if (baseline
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
snapshot
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
100
|
+
if (baseline) {
|
|
101
|
+
const before = new Map(baseline.map((file) => [file.path, file]));
|
|
102
|
+
const changed = [];
|
|
103
|
+
const expected = [];
|
|
104
|
+
for (const file of snapshot) {
|
|
105
|
+
const previous = before.get(file.path);
|
|
106
|
+
before.delete(file.path);
|
|
107
|
+
if (previous && equal(previous.content, file.content))
|
|
108
|
+
continue;
|
|
109
|
+
changed.push(file);
|
|
110
|
+
if (previous)
|
|
111
|
+
expected.push(previous);
|
|
112
|
+
}
|
|
113
|
+
expected.push(...before.values());
|
|
114
|
+
if (!changed.length && !expected.length)
|
|
115
|
+
return;
|
|
116
|
+
await connection().call('syncWorkspaceDelta', [
|
|
117
|
+
language,
|
|
118
|
+
changed,
|
|
119
|
+
expected,
|
|
120
|
+
snapshot.map((file) => ({
|
|
121
|
+
path: file.path,
|
|
122
|
+
bytes: bytes(file.content).byteLength
|
|
123
|
+
}))
|
|
124
|
+
]);
|
|
125
|
+
}
|
|
126
|
+
else
|
|
127
|
+
await connection().call('syncWorkspace', [language, snapshot, undefined]);
|
|
128
|
+
// snapshot already owns its bytes, including while queued behind another write.
|
|
129
|
+
published.set(language, snapshot);
|
|
95
130
|
});
|
|
96
131
|
queues.set(language, next);
|
|
97
132
|
return next;
|
|
@@ -104,7 +139,10 @@ export function createContainerPlaygroundBinding(runtimeAssets, options) {
|
|
|
104
139
|
const language = requestedShellLanguage ?? options.getLanguage?.() ?? 'CPP';
|
|
105
140
|
await queues.get(language)?.catch(() => { });
|
|
106
141
|
await connection().call('shellStart', [
|
|
107
|
-
{
|
|
142
|
+
{
|
|
143
|
+
cwd: `/workspace/${language}`,
|
|
144
|
+
env: { PS1: '\\[\\e[1;34m\\]\\w\\[\\e[0m\\] $ ' }
|
|
145
|
+
}
|
|
108
146
|
]);
|
|
109
147
|
})());
|
|
110
148
|
},
|
|
@@ -121,11 +159,29 @@ export function createContainerPlaygroundBinding(runtimeAssets, options) {
|
|
|
121
159
|
await connection().call('shellInterrupt');
|
|
122
160
|
},
|
|
123
161
|
async dispose() {
|
|
124
|
-
|
|
125
|
-
await client.call('shellDispose');
|
|
162
|
+
await cleanupOwner('shellDispose');
|
|
126
163
|
}
|
|
127
164
|
};
|
|
128
165
|
const binding = {
|
|
166
|
+
async beginTerminalExecution() {
|
|
167
|
+
if (terminalExecution || !shellConnection || disposed)
|
|
168
|
+
return;
|
|
169
|
+
// A shell unavailable without cross-origin isolation must not block batch Run.
|
|
170
|
+
try {
|
|
171
|
+
await shellConnection;
|
|
172
|
+
}
|
|
173
|
+
catch {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
await connection().call('shellSuspend');
|
|
177
|
+
terminalExecution = true;
|
|
178
|
+
},
|
|
179
|
+
async endTerminalExecution() {
|
|
180
|
+
if (!terminalExecution)
|
|
181
|
+
return;
|
|
182
|
+
terminalExecution = false;
|
|
183
|
+
await cleanupOwner('shellResume');
|
|
184
|
+
},
|
|
129
185
|
async setShellDirectory(language) {
|
|
130
186
|
if (!/^[A-Z][A-Z0-9_]*$/.test(language))
|
|
131
187
|
throw new TypeError('Invalid shell language');
|
|
@@ -165,7 +221,7 @@ export function createContainerPlaygroundBinding(runtimeAssets, options) {
|
|
|
165
221
|
}
|
|
166
222
|
},
|
|
167
223
|
async clear() {
|
|
168
|
-
await
|
|
224
|
+
await cleanupOwner('clear', [language]);
|
|
169
225
|
},
|
|
170
226
|
async restart() {
|
|
171
227
|
await invoke('restart');
|
|
@@ -177,8 +233,7 @@ export function createContainerPlaygroundBinding(runtimeAssets, options) {
|
|
|
177
233
|
await invoke('stop');
|
|
178
234
|
},
|
|
179
235
|
async dispose() {
|
|
180
|
-
|
|
181
|
-
await invoke('clear');
|
|
236
|
+
await cleanupOwner('clear', [language]);
|
|
182
237
|
},
|
|
183
238
|
write(text) {
|
|
184
239
|
void invoke('write', [text]).catch((error) => shellError?.(error));
|
|
@@ -191,7 +246,10 @@ export function createContainerPlaygroundBinding(runtimeAssets, options) {
|
|
|
191
246
|
'debugCommand',
|
|
192
247
|
'debugPause',
|
|
193
248
|
'setBreakpoints',
|
|
249
|
+
'setSourceBreakpoints',
|
|
194
250
|
'debugEvaluate',
|
|
251
|
+
'debugEvaluateValue',
|
|
252
|
+
'debugSetSteppingOptions',
|
|
195
253
|
'debugVariables',
|
|
196
254
|
'debugScopes',
|
|
197
255
|
'debugFrameScopes',
|
|
@@ -215,8 +273,32 @@ export function createContainerPlaygroundBinding(runtimeAssets, options) {
|
|
|
215
273
|
async cancelPrewarm() { },
|
|
216
274
|
syncWorkspace,
|
|
217
275
|
async readWorkspace(language) {
|
|
218
|
-
|
|
219
|
-
|
|
276
|
+
const previous = readQueues.get(language);
|
|
277
|
+
const next = (async () => {
|
|
278
|
+
await previous?.catch(() => { });
|
|
279
|
+
await queues.get(language)?.catch(() => { });
|
|
280
|
+
const baseline = reads.get(language);
|
|
281
|
+
const delta = await connection().call('readWorkspaceDelta', [language, baseline?.revision]);
|
|
282
|
+
if (disposed)
|
|
283
|
+
throw new Error('Container playground has been disposed');
|
|
284
|
+
const files = new Map(delta.reset ? [] : baseline?.files);
|
|
285
|
+
for (const path of delta.deleted)
|
|
286
|
+
files.delete(path);
|
|
287
|
+
for (const file of delta.files)
|
|
288
|
+
files.set(file.path, file);
|
|
289
|
+
reads.set(language, { revision: delta.revision, files });
|
|
290
|
+
// Match the owner's sorted directory traversal after incremental additions.
|
|
291
|
+
return copyFiles([...files.values()].sort((left, right) => {
|
|
292
|
+
const a = left.path.split('/'), b = right.path.split('/');
|
|
293
|
+
for (let index = 0; index < Math.min(a.length, b.length); index++) {
|
|
294
|
+
if (a[index] !== b[index])
|
|
295
|
+
return a[index] < b[index] ? -1 : 1;
|
|
296
|
+
}
|
|
297
|
+
return a.length - b.length;
|
|
298
|
+
}));
|
|
299
|
+
})();
|
|
300
|
+
readQueues.set(language, next);
|
|
301
|
+
return await next;
|
|
220
302
|
},
|
|
221
303
|
async listWorkspaceFiles() {
|
|
222
304
|
return await connection().call('listWorkspaceFiles');
|
|
@@ -239,6 +321,8 @@ export function createContainerPlaygroundBinding(runtimeAssets, options) {
|
|
|
239
321
|
return;
|
|
240
322
|
disposed = true;
|
|
241
323
|
changes.clear();
|
|
324
|
+
reads.clear();
|
|
325
|
+
readQueues.clear();
|
|
242
326
|
await client?.dispose();
|
|
243
327
|
}
|
|
244
328
|
};
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import type { Container } from '@wasm-idle/container';
|
|
2
|
-
import { type SandboxExecutionOptions } from '../options';
|
|
1
|
+
import type { Container, HostCommandInvocation } from '@wasm-idle/container';
|
|
2
|
+
import { type SandboxExecutionOptions } from '../playground/options.js';
|
|
3
3
|
import type { ProgressLike } from '@wasm-idle/core';
|
|
4
|
-
import type { ContainerWorkerEvent } from './protocol';
|
|
5
|
-
import type { WebsiteRuntimeAdapter } from './runtime-adapter';
|
|
4
|
+
import type { ContainerWorkerEvent } from './protocol.js';
|
|
5
|
+
import type { WebsiteRuntimeAdapter } from './runtime-adapter.js';
|
|
6
6
|
type Profile = {
|
|
7
7
|
container: Container;
|
|
8
|
-
|
|
8
|
+
sysrootProfile?: 'full' | 'c-base-v1';
|
|
9
|
+
prepareCommand(invocation: HostCommandInvocation, signal: AbortSignal): Promise<void>;
|
|
10
|
+
prepareClang?(profile: 'c' | 'full', signal: AbortSignal): Promise<readonly string[]>;
|
|
9
11
|
};
|
|
10
12
|
/** The Run button uses the same real Clang command and artifacts as Bash. Debug uses its qualified backend. */
|
|
11
|
-
export declare class
|
|
13
|
+
export declare class ContainerClangRuntime {
|
|
12
14
|
#private;
|
|
13
15
|
private readonly profile;
|
|
14
16
|
private readonly files;
|
|
@@ -16,6 +18,8 @@ export declare class WebsiteClangRuntime {
|
|
|
16
18
|
constructor(profile: Profile, files: WebsiteRuntimeAdapter, emit: (event: ContainerWorkerEvent) => void);
|
|
17
19
|
private queue;
|
|
18
20
|
private key;
|
|
21
|
+
private currentProgram;
|
|
22
|
+
private spawn;
|
|
19
23
|
private drain;
|
|
20
24
|
private success;
|
|
21
25
|
private headerKey;
|
|
@@ -35,4 +39,4 @@ export declare class WebsiteClangRuntime {
|
|
|
35
39
|
}[];
|
|
36
40
|
dispose(): Promise<void>;
|
|
37
41
|
}
|
|
38
|
-
export {};
|
|
42
|
+
export { ContainerClangRuntime as WebsiteClangRuntime };
|