/** * Canonical parse-check. * * Loads the REAL `hyperscript.org` engine headlessly (parse-only needs no DOM) * and exposes a validate function that NEVER throws. The engine has two failure * channels: `parse().errors` COLLECTS grammar errors, but the tokenizer THROWS * on an unknown character (e.g. a leaked non-ASCII surface โ†’ `Unknown token: เน€`) * and the `js` command's `new Function` throws on invalid JavaScript. Both * throws are folded into the returned array so callers have one contract โ€” * check `.length === 0`, never wrap in try/catch expecting invalidity to throw. * * Self-contained on purpose: node builtins + `hyperscript.org` only, no * `@lokascript/*` or `@hyperfixi/*` imports, so the package stays extraction-ready. */ /** Parse `src` on the canonical engine; returns error messages (empty = valid). Never throws. */ type CanonicalValidate = (src: string) => string[]; interface ParseCheckReport { /** 'input' = English source before translating; 'output' = English produced from a foreign source. */ stage: 'input' | 'output'; /** The invalid English hyperscript. */ code: string; /** Canonical parser error messages (first line each). */ errors: string[]; /** Source locale of the translate call ('en' for stage 'input'). */ from: string; /** Target locale ('en' for stage 'output'; '*' for an aggregated input check). */ to: string; } /** * Load (once, module-cached) the canonical validator. Resolve `hyperscript.org`, * then import the sibling prebuilt `_hyperscript.esm.js` by file URL. Rejects if * the package cannot be loaded or does not expose `parse()`. */ declare function loadValidator(): Promise; /** Convenience: load (cached) and validate in one call. */ declare function validateHyperscript(src: string): Promise; /** Multi-line human-readable rendering of a report (head line + one ` - ` line each). */ declare function formatParseCheckReport(r: ParseCheckReport): string; /** Default warn printer; dedupes by `r.code` per process. Returns true if it printed. */ declare function warnInvalidOnce(r: ParseCheckReport): boolean; /** @internal test hook โ€” clears the per-process warn-dedupe set. */ declare function __resetParseCheckWarnings(): void; export { __resetParseCheckWarnings, formatParseCheckReport, loadValidator, validateHyperscript, warnInvalidOnce }; export type { CanonicalValidate, ParseCheckReport };