Extract OutputStream type for python runner streams

GitOrigin-RevId: 9a26c847ec7daa4cd446e9fec0407e64e6f40916
This commit is contained in:
Domagoj Kriskovic
2026-04-22 13:30:21 +02:00
committed by Copybot
parent 09af91a936
commit 3a232c44eb
3 changed files with 8 additions and 7 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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)