feat(editor): compile-diagnostics seam — publish raw build output for editor markers
This commit is contained in:
parent
55bc03d281
commit
7c3b1c6e24
|
|
@ -1,6 +1,7 @@
|
||||||
import { useState, useCallback, useRef, useEffect } from 'react';
|
import { useState, useCallback, useRef, useEffect } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { registerEditorCommand } from '../../lib/editorCommands';
|
import { registerEditorCommand } from '../../lib/editorCommands';
|
||||||
|
import { publishCompileOutput } from '../../lib/intellisenseRegistry';
|
||||||
import { useEditorStore, chipFileGroupId } from '../../store/useEditorStore';
|
import { useEditorStore, chipFileGroupId } from '../../store/useEditorStore';
|
||||||
import { useSimulatorStore, piRerunScript } from '../../store/useSimulatorStore';
|
import { useSimulatorStore, piRerunScript } from '../../store/useSimulatorStore';
|
||||||
import { decideEngine } from '../../lib/instantEngine';
|
import { decideEngine } from '../../lib/instantEngine';
|
||||||
|
|
@ -594,6 +595,13 @@ export const EditorToolbar = ({
|
||||||
const resultLogs = parseCompileResult(result, boardLabel, boardTarget, lastStreamedLen > 0);
|
const resultLogs = parseCompileResult(result, boardLabel, boardTarget, lastStreamedLen > 0);
|
||||||
setCompileLogs((prev: CompilationLog[]) => [...prev, ...resultLogs]);
|
setCompileLogs((prev: CompilationLog[]) => [...prev, ...resultLogs]);
|
||||||
|
|
||||||
|
// Intellisense seam: hand the raw compiler text to the overlay so it
|
||||||
|
// can paint file:line markers in the editor. Empty string clears the
|
||||||
|
// markers after a successful build. No-op in OSS.
|
||||||
|
publishCompileOutput(
|
||||||
|
result.success ? '' : [result.stderr, result.error].filter(Boolean).join('\n'),
|
||||||
|
);
|
||||||
|
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
const program = result.hex_content ?? result.binary_content ?? null;
|
const program = result.hex_content ?? result.binary_content ?? null;
|
||||||
if (program && activeBoardId) {
|
if (program && activeBoardId) {
|
||||||
|
|
|
||||||
|
|
@ -43,3 +43,27 @@ function run(impl: IntellisenseImpl, monaco: unknown): void {
|
||||||
console.warn('[oss] intellisense impl threw:', err);
|
console.warn('[oss] intellisense impl threw:', err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compile-diagnostics seam. The editor toolbar publishes the raw compiler
|
||||||
|
* output after every build (empty string on success, to clear); with the
|
||||||
|
* pro overlay loaded, its sink parses gcc/mpy positions out of the text
|
||||||
|
* and paints Monaco markers on the affected lines. Inert in OSS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
type CompileOutputSink = (raw: string) => void;
|
||||||
|
|
||||||
|
let _compileSink: CompileOutputSink | null = null;
|
||||||
|
|
||||||
|
export function installCompileDiagnosticsSink(sink: CompileOutputSink | null): void {
|
||||||
|
_compileSink = sink;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function publishCompileOutput(raw: string): void {
|
||||||
|
try {
|
||||||
|
_compileSink?.(raw);
|
||||||
|
} catch (err) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.warn('[oss] compile-diagnostics sink threw:', err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue