import type { PlotInstruction, WorkspaceFile } from 'numbl'; // Message protocol between the app and the numbl web worker — a minimal // version of numbl's own numbl-worker protocol (which is not published on // npm): one "run" request in, streamed output/drawnow messages out, ending // with "done" or "error". /** A raw file placed into the run's virtual file system. */ export interface VfsFile { /** Project-relative path ('scripts/demo.m' → /project) or an absolute * VFS path such as '/system/mip/...'. */ path: string; content: Uint8Array; } export interface RunRequest { type: 'run'; /** Source of the file being run (possibly unsaved editor contents). */ code: string; /** Project-relative path of the file being run. */ mainFileName: string; /** Every project + system file, as bytes, for the virtual file system. */ vfsFiles: VfsFile[]; /** Every other project + system .m file, as text, callable as functions. */ workspaceFiles: WorkspaceFile[]; /** Extra search paths (e.g. the mip core package directory). */ searchPaths?: string[]; } export interface VfsChanges { created: { path: string; content: Uint8Array }[]; modified: { path: string; content: Uint8Array }[]; deleted: string[]; } export type WorkerResponse = | { type: 'output'; text: string } | { type: 'drawnow'; plotInstructions: PlotInstruction[] } | { type: 'done'; plotInstructions: PlotInstruction[]; vfsChanges?: VfsChanges } | { type: 'error'; message: string; vfsChanges?: VfsChanges };