import type { CheckBrowserResult } from "../browser.js"; import type { StructuredError } from "../errors/structured-errors.js"; export interface EdictQuickJSOptions { /** Override the default bundle path (dist/edict-quickjs-check.js) */ bundlePath?: string; /** Pass the IIFE bundle source directly (avoids readFileSync — use in fs-free environments) */ bundleSource?: string; /** Memory limit in bytes (default: 256MB) */ memoryLimit?: number; /** Stack size in bytes (default: 1MB) */ maxStackSize?: number; } /** Result of compiling via QuickJS. */ export interface QuickJSCompileResult { ok: boolean; /** WASM bytes (only when ok === true) */ wasm?: Uint8Array; errors: StructuredError[]; } /** * Self-hosted Edict compiler running inside QuickJS-WASM. * * Supports two modes: * - **Check-only** (default): phases 1–3 — schema validation, name resolution, * type checking, effect checking. Uses the lightweight check bundle (~365 KB). * - **Full compile**: phases 1–5 — check + WASM codegen via the pure-JS WASM * encoder. Uses the full bundle (~860 KB). Create with `EdictQuickJS.createFull()`. * * Usage: * const edict = await EdictQuickJS.createFull(); * const result = edict.compile({ kind: "module", ... }); * console.log(result.ok, result.wasm); * edict.dispose(); */ export declare class EdictQuickJS { private readonly rt; private readonly vm; private readonly hasCompile; private disposed; private constructor(); /** * Create a new EdictQuickJS instance with check-only capability (phases 1-3). * Uses the lightweight check bundle. */ static create(options?: EdictQuickJSOptions): Promise; /** * Create a new EdictQuickJS instance with full compile capability (phases 1-5). * Uses the full bundle with WASM codegen. */ static createFull(options?: EdictQuickJSOptions): Promise; private static _create; /** * Run the check pipeline (phases 1–3) on an Edict AST. * Returns structured result — never throws. */ check(ast: unknown): CheckBrowserResult; /** * Run the full compile pipeline (phases 1–5) on an Edict AST. * Returns WASM bytes on success, structured errors on failure. * Requires the full bundle — create with `EdictQuickJS.createFull()`. */ compile(ast: unknown): QuickJSCompileResult; /** * Execute WASM bytes using the pure-JS interpreter inside QuickJS. * Requires the full bundle — create with `EdictQuickJS.createFull()`. * * @param wasm - WASM binary bytes * @param options - Entry function name and step limit */ run(wasm: Uint8Array, options?: QuickJSRunOptions): QuickJSRunResult; /** * Compile an Edict AST and immediately execute the resulting WASM, * all within the QuickJS sandbox. * * This is the full self-hosted loop: JSON AST → check → compile → execute. * Requires the full bundle — create with `EdictQuickJS.createFull()`. */ compileAndRun(ast: unknown, options?: QuickJSRunOptions): QuickJSRunResult; /** * Dispose the QuickJS context and runtime. * Must be called when done to free WASM memory. */ dispose(): void; } /** Options for interpreted WASM execution inside QuickJS. */ export interface QuickJSRunOptions { /** Function to call (default: "main") */ entryFn?: string; /** Max instructions before aborting (default: 10_000_000) */ maxSteps?: number; } /** Result of interpreted WASM execution inside QuickJS. */ export interface QuickJSRunResult { ok: boolean; output: string; exitCode: number; returnValue?: number; errors: StructuredError[]; } //# sourceMappingURL=edict-quickjs.d.ts.map