diff --git a/services/web/frontend/js/features/ide-react/components/editor/python/pyodide-worker-client.ts b/services/web/frontend/js/features/ide-react/components/editor/python/pyodide-worker-client.ts index 6b099cff6b..c16a745a15 100644 --- a/services/web/frontend/js/features/ide-react/components/editor/python/pyodide-worker-client.ts +++ b/services/web/frontend/js/features/ide-react/components/editor/python/pyodide-worker-client.ts @@ -1,11 +1,12 @@ import type { + OutputStream, ProjectFileData, PyodideWorkerRequest, PyodideWorkerResponse, } from './pyodide-worker-messages' export type OutputCallback = ( - stream: 'stdout' | 'stderr' | 'info', + stream: OutputStream, line: string, fileId: string, executionId: string diff --git a/services/web/frontend/js/features/ide-react/components/editor/python/pyodide-worker-messages.ts b/services/web/frontend/js/features/ide-react/components/editor/python/pyodide-worker-messages.ts index 181d91a5c1..223021fa02 100644 --- a/services/web/frontend/js/features/ide-react/components/editor/python/pyodide-worker-messages.ts +++ b/services/web/frontend/js/features/ide-react/components/editor/python/pyodide-worker-messages.ts @@ -1,3 +1,5 @@ +export type OutputStream = 'stdout' | 'stderr' | 'info' + export type ProjectFileData = { relativePath: string content: string @@ -28,7 +30,7 @@ export type LoadingFailedEvent = { type: 'loading-failed'; error: string } export type OutputLineEvent = { type: 'output-line' - stream: 'stdout' | 'stderr' | 'info' + stream: OutputStream line: string fileId: string executionId: string diff --git a/services/web/frontend/js/features/ide-react/components/editor/python/python-runner.ts b/services/web/frontend/js/features/ide-react/components/editor/python/python-runner.ts index 2b0162ee50..4aa9a12025 100644 --- a/services/web/frontend/js/features/ide-react/components/editor/python/python-runner.ts +++ b/services/web/frontend/js/features/ide-react/components/editor/python/python-runner.ts @@ -4,6 +4,7 @@ import { v4 as uuid } from 'uuid' import { debugConsole } from '@/utils/debugging' import { PyodideWorkerClient } from './pyodide-worker-client' +import type { OutputStream } from './pyodide-worker-messages' const MAX_OUTPUT_LINES = 100 @@ -22,7 +23,7 @@ export type ExecutionContext = { type Listener = () => void export type OutputLine = { - stream: 'stdout' | 'stderr' | 'info' + stream: OutputStream line: string } @@ -208,10 +209,7 @@ export class PythonRunner { } } -function appendCapped( - existing: OutputLine[], - entry: OutputLine -): OutputLine[] { +function appendCapped(existing: OutputLine[], entry: OutputLine): OutputLine[] { const updated = [...existing, entry] return updated.length > MAX_OUTPUT_LINES ? updated.slice(-MAX_OUTPUT_LINES)