wasm-idle 1.1.0 → 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 +267 -112
- package/dist/container/bash-profile.d.ts +80 -0
- package/dist/container/bash-profile.js +328 -0
- package/dist/container/binding.d.ts +39 -0
- package/dist/container/binding.js +331 -0
- package/dist/container/clang-runtime.d.ts +42 -0
- package/dist/container/clang-runtime.js +561 -0
- package/dist/container/client.d.ts +14 -0
- package/dist/container/client.js +185 -0
- package/dist/container/explorer.d.ts +31 -0
- package/dist/container/explorer.js +112 -0
- 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/container/protocol.d.ts +84 -0
- package/dist/container/protocol.js +28 -0
- package/dist/container/runtime-adapter.d.ts +75 -0
- package/dist/container/runtime-adapter.js +537 -0
- package/dist/container/shell-control.d.ts +49 -0
- package/dist/container/shell-control.js +360 -0
- package/dist/container/workspace.d.ts +12 -0
- package/dist/container/workspace.js +29 -0
- package/dist/index.d.ts +1 -1
- package/dist/playground/assetBridge.js +111 -33
- package/dist/playground/assets.d.ts +10 -2
- package/dist/playground/c3.js +22 -0
- package/dist/playground/c3Memory.d.ts +19 -0
- package/dist/playground/c3Memory.js +117 -0
- package/dist/playground/cachedClang.js +143 -34
- package/dist/playground/clang.d.ts +5 -1
- package/dist/playground/clang.js +61 -5
- package/dist/playground/clangAssetIntegrity.js +6 -6
- package/dist/playground/clangWorkerProtocol.d.ts +12 -1
- package/dist/playground/cobol.d.ts +3 -0
- package/dist/playground/cobol.js +10 -1
- package/dist/playground/commonlispAssets.d.ts +2 -2
- package/dist/playground/compiledArtifactCache.d.ts +3 -1
- package/dist/playground/compiledArtifactCache.js +31 -5
- package/dist/playground/compiledLldb.d.ts +41 -0
- package/dist/playground/compiledLldb.js +167 -0
- package/dist/playground/d.d.ts +10 -2
- package/dist/playground/d.js +161 -14
- 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/dotnet.js +6 -8
- package/dist/playground/fortran.d.ts +3 -0
- package/dist/playground/fortran.js +10 -1
- package/dist/playground/go.js +23 -7
- package/dist/playground/goDebugInstrumentation.js +207 -97
- 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 +162 -5
- 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.d.ts +9 -0
- package/dist/playground/javaRuntimeErrors.js +93 -0
- package/dist/playground/lean4Assets.d.ts +1 -25
- package/dist/playground/lean4Assets.js +2 -123
- package/dist/playground/lfortran.js +10 -0
- 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 +30 -0
- package/dist/playground/objectivec.d.ts +10 -6
- package/dist/playground/objectivec.js +85 -10
- package/dist/playground/options.d.ts +12 -4
- package/dist/playground/python.d.ts +8 -1
- package/dist/playground/python.js +89 -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/runtimeAssetCache.d.ts +1 -32
- package/dist/playground/runtimeAssetCache.js +1 -193
- package/dist/playground/runtimeSession.d.ts +2 -2
- package/dist/playground/runtimeSession.js +11 -11
- package/dist/playground/rust.d.ts +10 -0
- package/dist/playground/rust.js +230 -51
- package/dist/playground/sandbox.d.ts +8 -1
- package/dist/playground/staticStdinRing.d.ts +2 -1
- package/dist/playground/staticStdinRing.js +21 -10
- package/dist/playground/staticWorkerRuntime.d.ts +15 -1
- package/dist/playground/staticWorkerRuntime.js +127 -19
- package/dist/playground/stdinBuffer.d.ts +1 -1
- package/dist/playground/stdinBuffer.js +19 -2
- package/dist/playground/tinygo.d.ts +3 -0
- package/dist/playground/tinygo.js +88 -6
- package/dist/playground/typescript.js +8 -0
- package/dist/playground/v.d.ts +6 -2
- package/dist/playground/v.js +76 -13
- package/dist/playground/wasmAwkVersion.d.ts +13 -13
- package/dist/playground/wasmAwkVersion.js +4 -4
- package/dist/playground/wasmBqnVersion.d.ts +2 -2
- package/dist/playground/wasmBqnVersion.js +2 -2
- package/dist/playground/wasmC3Version.d.ts +2 -2
- package/dist/playground/wasmC3Version.js +2 -2
- package/dist/playground/wasmClojureScriptVersion.d.ts +2 -2
- package/dist/playground/wasmClojureScriptVersion.js +2 -2
- package/dist/playground/wasmCommonLispVersion.d.ts +2 -2
- package/dist/playground/wasmCommonLispVersion.js +2 -2
- package/dist/playground/wasmDIntegrity.d.ts +5 -5
- package/dist/playground/wasmDIntegrity.js +5 -5
- package/dist/playground/wasmDVersion.d.ts +16 -1
- package/dist/playground/wasmDVersion.js +16 -1
- package/dist/playground/wasmDebugVersion.d.ts +1 -1
- package/dist/playground/wasmDebugVersion.js +1 -1
- package/dist/playground/wasmForthVersion.d.ts +2 -2
- package/dist/playground/wasmForthVersion.js +2 -2
- package/dist/playground/wasmGleamVersion.d.ts +2 -2
- package/dist/playground/wasmGleamVersion.js +2 -2
- package/dist/playground/wasmGrainVersion.d.ts +2 -2
- package/dist/playground/wasmGrainVersion.js +2 -2
- package/dist/playground/wasmJVersion.d.ts +2 -2
- package/dist/playground/wasmJVersion.js +2 -2
- package/dist/playground/wasmJanetVersion.js +2 -2
- package/dist/playground/wasmJuliaVersion.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/wasmNimVersion.d.ts +9 -9
- package/dist/playground/wasmNimVersion.js +6 -6
- package/dist/playground/wasmOcamlVersion.d.ts +2 -2
- package/dist/playground/wasmOcamlVersion.js +1 -1
- package/dist/playground/wasmPascalVersion.js +2 -2
- package/dist/playground/wasmPerlVersion.js +2 -2
- package/dist/playground/wasmPrologVersion.d.ts +2 -2
- package/dist/playground/wasmPrologVersion.js +2 -2
- package/dist/playground/wasmReScriptVersion.d.ts +2 -2
- package/dist/playground/wasmReScriptVersion.js +2 -2
- package/dist/playground/wasmRustVersion.d.ts +26 -38
- package/dist/playground/wasmRustVersion.js +25 -40
- package/dist/playground/wasmTclVersion.d.ts +4 -4
- package/dist/playground/wasmTclVersion.js +2 -2
- package/dist/playground/wasmTinyGoVersion.d.ts +14 -14
- package/dist/playground/wasmTinyGoVersion.js +14 -14
- package/dist/playground/wasmTypeScriptVersion.d.ts +5 -5
- package/dist/playground/wasmTypeScriptVersion.js +5 -5
- package/dist/playground/worker/cachedClangCompile.js +52 -4
- package/dist/playground/worker/cachedClangExecute.js +6 -5
- package/dist/playground/worker/clang.js +33 -11
- package/dist/playground/worker/cobol.js +3 -3
- package/dist/playground/worker/d.js +63 -7
- package/dist/playground/worker/fortran.js +3 -3
- package/dist/playground/worker/go.js +16 -5
- package/dist/playground/worker/haskell.js +10 -7
- package/dist/playground/worker/java.js +263 -45
- 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 +15 -3
- package/dist/playground/worker/php.js +15 -9
- package/dist/playground/worker/python.js +102 -30
- package/dist/playground/worker/pythonExecution.js +17 -1
- package/dist/playground/worker/pythonWorkspaceFiles.d.ts +6 -0
- package/dist/playground/worker/pythonWorkspaceFiles.js +26 -0
- package/dist/playground/worker/pythonWorkspaceImports.d.ts +4 -0
- package/dist/playground/worker/pythonWorkspaceImports.js +129 -0
- package/dist/playground/worker/r.js +13 -6
- 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 +38 -3
- package/dist/playground/worker/sqlite.js +4 -3
- package/dist/playground/worker/tinygo.js +11 -3
- package/dist/playground/worker/typescript.js +2 -3
- package/dist/playground/worker/v.js +32 -7
- package/dist/playground/worker/wat.js +2 -3
- package/dist/playground/worker/zig.js +20 -6
- package/dist/playground/workerSession.d.ts +1 -28
- package/dist/playground/workerSession.js +1 -164
- package/dist/playground/zig.js +4 -0
- package/package.json +66 -15
- package/dist/playground/worker/python.runtime.cases.d.ts +0 -1
- package/dist/playground/worker/python.runtime.cases.js +0 -374
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { waitForBufferedStdin } from '../stdinBuffer';
|
|
2
|
+
import { normalizeLldbWorkspacePath } from '../lldbSourcePath';
|
|
2
3
|
import { loadVerifiedDOuterAssets, snapshotDOuterAssetConfig } from '../dOuterAssets';
|
|
3
|
-
import { createRuntimeAssetsKey, verifyRuntimeAssetIntegrity } from '@wasm-idle/core';
|
|
4
|
+
import { createRuntimeAssetsKey, requestRuntimeWasmModule, verifyRuntimeAssetIntegrity } from '@wasm-idle/core';
|
|
4
5
|
let stdinBufferD = null;
|
|
5
6
|
let runtimeConfig = null;
|
|
6
7
|
let loadedRuntimeKey = '';
|
|
7
8
|
let runtimePromise = null;
|
|
8
9
|
let compiledArtifact = null;
|
|
9
10
|
let compiledCacheKey = '';
|
|
11
|
+
let compilerModulePorts;
|
|
10
12
|
async function loadRuntime(config) {
|
|
11
13
|
const snapshot = snapshotDOuterAssetConfig(config);
|
|
12
14
|
const runtimeKey = createRuntimeAssetsKey({ d: snapshot });
|
|
@@ -53,10 +55,23 @@ async function loadRuntime(config) {
|
|
|
53
55
|
const runtimeBaseUrl = new URL('./', manifestUrl);
|
|
54
56
|
runtimeBaseUrl.search = manifestUrl.search;
|
|
55
57
|
return {
|
|
58
|
+
compilerProvenance: manifest.compiler?.ldc2?.integrity
|
|
59
|
+
? {
|
|
60
|
+
name: 'ldc',
|
|
61
|
+
version: manifest.version,
|
|
62
|
+
binarySha256: manifest.compiler.ldc2.integrity.uncompressedSha256
|
|
63
|
+
}
|
|
64
|
+
: undefined,
|
|
56
65
|
compiler: await factory({
|
|
57
66
|
runtimeBaseUrl: runtimeBaseUrl.href,
|
|
58
67
|
manifest,
|
|
59
|
-
verifyRuntimeAssetIntegrity
|
|
68
|
+
verifyRuntimeAssetIntegrity,
|
|
69
|
+
compileModule(kind, bytes, signal) {
|
|
70
|
+
const port = compilerModulePorts?.[kind];
|
|
71
|
+
return port
|
|
72
|
+
? requestRuntimeWasmModule(Uint8Array.from(bytes), port, { signal })
|
|
73
|
+
: WebAssembly.compile(Uint8Array.from(bytes).buffer);
|
|
74
|
+
}
|
|
60
75
|
}),
|
|
61
76
|
executeBrowserDArtifact: module.executeBrowserDArtifact
|
|
62
77
|
};
|
|
@@ -87,8 +102,9 @@ function normalizeDiagnostic(diagnostic) {
|
|
|
87
102
|
};
|
|
88
103
|
}
|
|
89
104
|
self.onmessage = async (event) => {
|
|
90
|
-
const { load, moduleUrl: nextModuleUrl, manifestUrl: nextManifestUrl, outerIntegrity, buffer, code, prepare, args = [], stdin, fileName = 'main.d', log } = event.data;
|
|
105
|
+
const { load, moduleUrl: nextModuleUrl, manifestUrl: nextManifestUrl, outerIntegrity, buffer, code, prepare, args = [], compileArgs: requestedCompileArgs = [], stdin, fileName = 'main.d', log, debugMode } = event.data;
|
|
91
106
|
try {
|
|
107
|
+
const compileArgs = [...requestedCompileArgs];
|
|
92
108
|
if (load) {
|
|
93
109
|
runtimeConfig = snapshotDOuterAssetConfig({
|
|
94
110
|
moduleUrl: nextModuleUrl,
|
|
@@ -102,10 +118,26 @@ self.onmessage = async (event) => {
|
|
|
102
118
|
return;
|
|
103
119
|
}
|
|
104
120
|
stdinBufferD = new Int32Array(buffer);
|
|
121
|
+
compilerModulePorts = event.data.compilerModulePorts;
|
|
105
122
|
if (!runtimeConfig)
|
|
106
123
|
throw new Error('D runtime has not been loaded');
|
|
107
124
|
const runtime = await loadRuntime(runtimeConfig);
|
|
108
|
-
const
|
|
125
|
+
const lldb = debugMode === 'lldb';
|
|
126
|
+
const sourcePath = normalizeLldbWorkspacePath(fileName);
|
|
127
|
+
const compilerFileName = sourcePath.split('/').at(-1) || 'main.d';
|
|
128
|
+
// Debugger requirements take precedence over user optimization and DWARF flags.
|
|
129
|
+
const compilerArgs = [
|
|
130
|
+
...compileArgs,
|
|
131
|
+
...(lldb
|
|
132
|
+
? [
|
|
133
|
+
'-g',
|
|
134
|
+
'-O0',
|
|
135
|
+
'-dwarf-version=4',
|
|
136
|
+
`--fdebug-prefix-map=/work/${compilerFileName}=/workspace/${sourcePath}`
|
|
137
|
+
]
|
|
138
|
+
: [])
|
|
139
|
+
];
|
|
140
|
+
const compileCacheKey = JSON.stringify([debugMode || 'none', fileName, code, compilerArgs]);
|
|
109
141
|
if (!compiledArtifact || compiledCacheKey !== compileCacheKey) {
|
|
110
142
|
if (log) {
|
|
111
143
|
console.log(`[wasm-idle:d-worker] compile start prepare=${String(prepare)} file=${fileName} bytes=${code.length}`);
|
|
@@ -115,6 +147,7 @@ self.onmessage = async (event) => {
|
|
|
115
147
|
fileName,
|
|
116
148
|
target: 'wasm32-wasi',
|
|
117
149
|
log,
|
|
150
|
+
compileArgs: compilerArgs,
|
|
118
151
|
onProgress(progress) {
|
|
119
152
|
postMessage({ progress });
|
|
120
153
|
}
|
|
@@ -146,6 +179,30 @@ self.onmessage = async (event) => {
|
|
|
146
179
|
postMessage({ results: true });
|
|
147
180
|
return;
|
|
148
181
|
}
|
|
182
|
+
if (lldb) {
|
|
183
|
+
if (!runtime.compilerProvenance)
|
|
184
|
+
throw new Error('D LLDB debugging requires verified compiler provenance.');
|
|
185
|
+
if (!compiledArtifact.bytes)
|
|
186
|
+
throw new Error('D LLDB debugging requires the compiler to return WebAssembly bytes.');
|
|
187
|
+
const bytes = new Uint8Array(compiledArtifact.bytes);
|
|
188
|
+
const sha256 = async (value) => Array.from(new Uint8Array(await crypto.subtle.digest('SHA-256', new Uint8Array(value))), (byte) => byte.toString(16).padStart(2, '0')).join('');
|
|
189
|
+
const contentSha256 = await sha256(new TextEncoder().encode(code));
|
|
190
|
+
const path = `/workspace/${sourcePath}`;
|
|
191
|
+
postMessage({
|
|
192
|
+
lldbArtifact: {
|
|
193
|
+
bytes,
|
|
194
|
+
descriptor: {
|
|
195
|
+
kind: 'dwarf',
|
|
196
|
+
sourceRoot: '/workspace',
|
|
197
|
+
moduleSha256: await sha256(bytes),
|
|
198
|
+
files: [{ path, contentSha256 }],
|
|
199
|
+
compiler: runtime.compilerProvenance
|
|
200
|
+
},
|
|
201
|
+
sources: [{ path, content: code, contentSha256 }]
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
149
206
|
const hasInitialStdin = typeof stdin === 'string';
|
|
150
207
|
let initialStdin = hasInitialStdin ? stdin : null;
|
|
151
208
|
const execution = await runtime.executeBrowserDArtifact(compiledArtifact, {
|
|
@@ -185,9 +242,8 @@ self.onmessage = async (event) => {
|
|
|
185
242
|
}
|
|
186
243
|
});
|
|
187
244
|
if (execution.exitCode !== 0) {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
: `D program exited with code ${execution.exitCode}`);
|
|
245
|
+
// stderr was already streamed to the terminal above.
|
|
246
|
+
throw new Error(`D program exited with code ${execution.exitCode}`);
|
|
191
247
|
}
|
|
192
248
|
postMessage({ results: true });
|
|
193
249
|
}
|
|
@@ -250,10 +250,10 @@ self.onmessage = async (event) => {
|
|
|
250
250
|
postMessage({ load: true });
|
|
251
251
|
}
|
|
252
252
|
catch (error) {
|
|
253
|
-
postMessage({ error: error
|
|
253
|
+
postMessage({ error: error?.message || String(error) });
|
|
254
254
|
}
|
|
255
255
|
}
|
|
256
|
-
else if (typeof log === 'boolean' &&
|
|
256
|
+
else if (code === '' || (typeof log === 'boolean' && code === undefined)) {
|
|
257
257
|
if (clang)
|
|
258
258
|
clang.log = log;
|
|
259
259
|
if (typeof code === 'string')
|
|
@@ -286,7 +286,7 @@ self.onmessage = async (event) => {
|
|
|
286
286
|
postMessage({ results: true });
|
|
287
287
|
}
|
|
288
288
|
catch (error) {
|
|
289
|
-
postMessage({ error: error
|
|
289
|
+
postMessage({ error: error?.message || String(error) });
|
|
290
290
|
}
|
|
291
291
|
}
|
|
292
292
|
};
|
|
@@ -210,6 +210,7 @@ function createGoDebugHost(options) {
|
|
|
210
210
|
}
|
|
211
211
|
self.onmessage = async (event) => {
|
|
212
212
|
const { load, compilerUrl: nextCompilerUrl, manifestUrl: nextManifestUrl, runtimeLimits, buffer, debugBuffer, code, prepare, args = [], stdin, target = 'wasip1/wasm', log, debug = false, breakpoints = [], pauseOnEntry = false } = event.data;
|
|
213
|
+
let abandonedJsWasmRun = false;
|
|
213
214
|
try {
|
|
214
215
|
if (load) {
|
|
215
216
|
compilerUrl = nextCompilerUrl;
|
|
@@ -344,8 +345,16 @@ self.onmessage = async (event) => {
|
|
|
344
345
|
}
|
|
345
346
|
});
|
|
346
347
|
}
|
|
348
|
+
catch (error) {
|
|
349
|
+
// wasm_exec.js runs js/wasm programs on this worker's event loop, so a rejected
|
|
350
|
+
// run (such as an expired runtime deadline) may still be running here.
|
|
351
|
+
abandonedJsWasmRun = effectiveTarget === 'js/wasm';
|
|
352
|
+
throw error;
|
|
353
|
+
}
|
|
347
354
|
finally {
|
|
348
|
-
|
|
355
|
+
// The abandoned program may still call the hook until the host discards this worker.
|
|
356
|
+
if (!abandonedJsWasmRun)
|
|
357
|
+
restoreGoDebugHost?.();
|
|
349
358
|
}
|
|
350
359
|
if (log) {
|
|
351
360
|
console.log(`[wasm-idle:go-worker] wasi run complete exitCode=${String(execution?.exitCode)}`);
|
|
@@ -354,9 +363,8 @@ self.onmessage = async (event) => {
|
|
|
354
363
|
throw new Error('Go program did not return an execution result');
|
|
355
364
|
}
|
|
356
365
|
if (execution.exitCode !== 0) {
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
: `Go program exited with code ${execution.exitCode}`);
|
|
366
|
+
// stderr was already streamed to the terminal above.
|
|
367
|
+
throw new Error(`Go program exited with code ${execution.exitCode}`);
|
|
360
368
|
}
|
|
361
369
|
postMessage({ results: true });
|
|
362
370
|
}
|
|
@@ -364,6 +372,9 @@ self.onmessage = async (event) => {
|
|
|
364
372
|
if (log) {
|
|
365
373
|
console.error('[wasm-idle:go-worker] failed', error);
|
|
366
374
|
}
|
|
367
|
-
postMessage({
|
|
375
|
+
postMessage({
|
|
376
|
+
error: error?.message || String(error),
|
|
377
|
+
...(abandonedJsWasmRun ? { fatal: true } : {})
|
|
378
|
+
});
|
|
368
379
|
}
|
|
369
380
|
};
|
|
@@ -99,7 +99,7 @@ function outputLine(line) {
|
|
|
99
99
|
postMessage({ output: line.endsWith('\n') ? line : `${line}\n` });
|
|
100
100
|
}
|
|
101
101
|
function remapDiagnosticPath(line) {
|
|
102
|
-
const match = /^(.*?)(
|
|
102
|
+
const match = /^(.*?)(:(?:\d+:\d+(?:-\d+)?|\(\d+,\d+\)-\(\d+,\d+\)):\s+(?:error|warning):)/i.exec(line);
|
|
103
103
|
if (!match)
|
|
104
104
|
return line;
|
|
105
105
|
const workspacePath = activeDiagnosticPaths?.get(match[1]);
|
|
@@ -264,10 +264,12 @@ export function parseHaskellDiagnostics(output) {
|
|
|
264
264
|
const diagnostics = [];
|
|
265
265
|
const lines = output.split(/\r\n|\r|\n/);
|
|
266
266
|
for (let index = 0; index < lines.length; index += 1) {
|
|
267
|
-
|
|
267
|
+
// GHC locations are `l:c`, `l:c-c`, or `(l,c)-(l,c)`.
|
|
268
|
+
const match = /^(.*?):(?:(\d+):(\d+)(?:-\d+)?|\((\d+),(\d+)\)-\(\d+,\d+\)):\s+(error|warning):\s*(.*)$/i.exec(lines[index]);
|
|
268
269
|
if (!match)
|
|
269
270
|
continue;
|
|
270
|
-
|
|
271
|
+
// GHC 9.6+ prefixes the message with tags such as `[GHC-88464] [-Wunused-top-binds]`.
|
|
272
|
+
let message = match[7].replace(/^(?:\[(?:GHC-\d+|-W[^\]]*)\]\s*)*/, '').trim();
|
|
271
273
|
if (!message) {
|
|
272
274
|
for (const extraLine of lines.slice(index + 1)) {
|
|
273
275
|
const trimmed = extraLine.trim();
|
|
@@ -279,9 +281,9 @@ export function parseHaskellDiagnostics(output) {
|
|
|
279
281
|
}
|
|
280
282
|
diagnostics.push({
|
|
281
283
|
fileName: match[1] || null,
|
|
282
|
-
lineNumber: Math.max(1, Number(match[2] || 1)),
|
|
283
|
-
columnNumber: Math.max(1, Number(match[3] || 1)),
|
|
284
|
-
severity: match[
|
|
284
|
+
lineNumber: Math.max(1, Number(match[2] || match[4] || 1)),
|
|
285
|
+
columnNumber: Math.max(1, Number(match[3] || match[5] || 1)),
|
|
286
|
+
severity: match[6].toLowerCase() === 'warning' ? 'warning' : 'error',
|
|
285
287
|
message: message || lines[index]
|
|
286
288
|
});
|
|
287
289
|
}
|
|
@@ -447,7 +449,8 @@ self.onmessage = async (event) => {
|
|
|
447
449
|
for (const diagnostic of parseHaskellDiagnostics(stderrText)) {
|
|
448
450
|
postMessage({ diagnostic });
|
|
449
451
|
}
|
|
450
|
-
|
|
452
|
+
// The host stderr callback already streamed stderrText to the terminal.
|
|
453
|
+
throw new Error(formatError(error), { cause: error });
|
|
451
454
|
}
|
|
452
455
|
finally {
|
|
453
456
|
activeStderrCollector = null;
|