protocol.ts (2021B)
1 import type { TreeFormat, TreeFile } from './tree-export.js'; 2 import type { RuntimeStats } from './runtime-backends.js'; 3 import type { BundleHash, ExportInfo } from './bundle.js'; 4 import type { OutputType, ValueView } from './codecs.js'; 5 import type { Trace } from './io.js'; 6 export type RequestId = number & { readonly __requestId: unique symbol }; 7 export interface CatalogueEntry { 8 id: string; title: string; hash: BundleHash; source: string; sourceSha256: string; 9 export: string; arguments: unknown[]; output: OutputType; mode: 'pure' | 'io'; 10 category?: 'Basic Examples' | 'Practical Examples' | 'Language & Runtime Explorations'; 11 environment?: string; 12 presets?: Record<string, { arguments: unknown[]; output: OutputType; mode: 'pure' | 'io' }>; 13 } 14 export type ClientMessage = { type: 'load'; hash: BundleHash; localId?: string } 15 | { type: 'run'; export: string; arguments: unknown; expression?: string; output: OutputType; mode: 'pure' | 'io'; step: boolean } 16 | { type: 'download' } 17 | { type: 'export'; export: string; format: TreeFormat } 18 | { type: 'resume'; id: RequestId; value?: string }; 19 export type WorkerMessage = { type: 'module-exported'; bytes: Uint8Array; hash: BundleHash; manifest: string } 20 | { type: 'module-export-error'; message: string } 21 | { type: 'state'; state: 'running' } 22 | { type: 'state'; state: 'input' | 'step'; id: RequestId } 23 | { type: 'loaded'; hash: BundleHash; exports: ExportInfo[]; nodes: number; metadata: Record<string, string>; source: string | null } 24 | { type: 'trace'; phase: 'before'; event: Trace } 25 | { type: 'trace'; phase: 'after'; event: { step: number; name: string; value: string } } 26 | { type: 'output'; text: string } 27 | { type: 'done'; result: ValueView; stats: RuntimeStats } 28 | { type: 'exported'; hash: BundleHash; export: string; format: TreeFormat; file: TreeFile } 29 | { type: 'downloaded'; hash: BundleHash; bytes: Uint8Array } 30 | { type: 'export-error'; message: string } 31 | { type: 'error'; message: string; fatal?: boolean };