/** * HostEngine — the integration point WS-3 (plugins), WS-4 (i18n), and * WS-5 (ANOVA, as a plugin) were each built for but never actually wired * into. This is that wiring. * * Responsibilities: * - Owns one PluginRegistry and one I18nManager. * - Loads plugins (register + optional async init(engine)). * - Collects formula definitions from every enabled plugin's * 'registerFormula' hook into a single formula table. * - Evaluates formulas by name, dispatching beforeFormulaEval / * afterFormulaEval / onFormulaError hooks around the call, and * localizing any thrown error via the formula's declared errorCodeMap. */ import { PluginRegistry } from '../plugins/registry.js'; import type { IPlugin } from '../plugins/types.js'; import { I18nManager } from '../i18n/manager.js'; import type { I18nOptions, Language, LanguageCatalog } from '../i18n/types.js'; export declare class HostEngine { readonly plugins: PluginRegistry; readonly i18n: I18nManager; private formulas; constructor(i18nOptions?: Partial); /** * Register a language's strings with the engine's i18n manager. * Thin passthrough kept on HostEngine so callers don't need to reach * into `engine.i18n` for the most common setup step. */ registerLanguage(lang: Language, strings: LanguageCatalog): void; /** * Register a plugin, run its optional init(engine), and refresh the * formula table so any formulas it declares become immediately callable. * Rethrows whatever PluginRegistry.register or the plugin's own init * throws — a failed load leaves the engine's formula table unchanged * (refreshFormulas runs only after both steps succeed). */ loadPlugin(plugin: IPlugin): Promise; /** * Unregister a plugin (running its destroy() first, if present) and * refresh the formula table so its formulas stop being callable. */ unloadPlugin(name: string, force?: boolean): Promise; enablePlugin(name: string): void; disablePlugin(name: string): void; /** * Re-run 'registerFormula' across every currently enabled plugin and * rebuild the formula table from scratch. Called automatically by * loadPlugin/unloadPlugin/enablePlugin/disablePlugin — exposed publicly * for callers who mutate the registry directly (via engine.plugins) and * need to sync afterward. */ refreshFormulas(): void; hasFormula(name: string): boolean; listFormulaNames(): string[]; /** Localized display name for a registered formula, falling back to the * bare formula name if it declared no labelKey or the key has no * translation for the current language. */ getFormulaLabel(name: string): string; /** * Evaluate a registered formula by name. Dispatches beforeFormulaEval * before the call and afterFormulaEval after a successful call, both * via the plugin registry's sync hook dispatch. On failure, dispatches * onFormulaError with a LOCALIZED FormulaEngineError (never the raw * error) and throws that same localized error to the caller. */ evalFormula(name: string, ...args: any[]): any; private localizeError; }