mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 17:19:37 +02:00
Extract OutputStream type for python runner streams
GitOrigin-RevId: 9a26c847ec7daa4cd446e9fec0407e64e6f40916
This commit is contained in:
committed by
Copybot
parent
09af91a936
commit
3a232c44eb
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user