/** * Public, embedder-friendly entry point for Emception. * * The historical `boot()` and `bootInWorker()` exports return a grab-bag of * internal classes (`ToolRunner`, `MiniShell`, `TTYBridge`, `WorkerClient`) * which is great for the bundled IDE but overwhelming for an LMS course * widget that just wants to "compile and run this C file". * * `createEmception()` is the small, stable surface for those embedders: * * import { createEmception } from '@gameguild/emception-browser'; * * const em = await createEmception({ * container: document.getElementById('terminal')!, * manifestUrl: '/cdn/manifest.json', * }); * * await em.workspace.writeFile('/home/user/main.c', 'int main(){return 0;}'); * const result = await em.run('clang', ['/home/user/main.c', '-o', '/home/user/a.wasm']); * console.log(result.exitCode, result.stdout, result.stderr); * * em.dispose(); * * The implementation is a thin façade over `bootInWorker()`. The richer * `boot()` / `bootInWorker()` exports remain available for advanced use. */ import type { EmceptionAPI, RunOptions, ToolResult } from 'emception'; import type { CanvasAPI } from './canvas.js'; import { WorkerClient } from './worker-client.js'; /** * Default manifest URL used when `manifestUrl` is omitted. Points at the * matching `@gameguild/emception-toolchain` package on jsDelivr so a host can * boot emception with zero configuration: * * await createEmception({ container: el }); // uses DEFAULT_MANIFEST_URL * * Override `manifestUrl` only when self-hosting the same versioned artifacts. */ export { DEFAULT_MANIFEST_URL } from './manifest.js'; export interface CreateEmceptionOptions { /** * Optional. Either an HTMLElement to mount a new xterm.js Terminal into, * or an existing `Terminal` instance to reuse (advanced). * * Required when `tty` is `'xterm'` (the default). Ignored when `tty` * is `'none'`. */ container?: HTMLElement | import('@xterm/xterm').Terminal; /** * Terminal binding. Defaults to `'xterm'` when `container` * is provided, `'none'` otherwise. * * - `'xterm'` — mount or reuse an xterm.js Terminal in `container`. * - `'none'` — no terminal; stdout/stderr go to `onStdout` / `onStderr` * callbacks. Useful for headless / batch / SSR-friendly use cases * like an LMS auto-grader running tests in a web worker. */ tty?: 'xterm' | 'none'; /** Headless stdout sink. Only used when `tty: 'none'`. */ onStdout?: (text: string) => void; /** Headless stderr sink. Only used when `tty: 'none'`. */ onStderr?: (text: string) => void; /** * URL of a self-hosted manifest produced by `npm run build:manifest`. * * If omitted, falls back to {@link DEFAULT_MANIFEST_URL}, which pins the * matching `@gameguild/emception-toolchain` version on jsDelivr. */ manifestUrl?: string; } export type BrowserStdin = RunOptions['stdin'] | (() => number | null | Promise); export type BrowserRunOptions = Omit & { /** Browser byte reader used by interactive terminal programs. */ stdin?: BrowserStdin; }; export interface BrowserEmceptionAPI extends Omit { run(cmd: string, argv?: string[], opts?: BrowserRunOptions): Promise; /** Browser-owned canvas build/runtime boundary. */ readonly canvas: CanvasAPI; } export declare function createEmception(opts?: CreateEmceptionOptions): Promise; /** * Build an {@link EmceptionAPI} façade on top of an already-booted * {@link WorkerClient}. Exposed for hosts (e.g. the bundled IDE) that boot * the worker themselves via {@link bootInWorker} and need the same * high-level surface that {@link createEmception} returns. */ export declare function wrapWorkerClient(client: WorkerClient): BrowserEmceptionAPI; //# sourceMappingURL=createEmception.d.ts.map