import type { SqliteWasmDatabase } from "../database/sqlite/index.js"; import { type StateCommitChange } from "../hooks/create-hooks.js"; import type { LixPlugin } from "../plugin/lix-plugin.js"; import type { Call } from "./functions/function-registry.js"; import type { LixHooks } from "../hooks/create-hooks.js"; import type { openLix } from "../lix/open-lix.js"; import { type FunctionRegistry } from "./functions/function-registry.js"; import type { PreprocessorFn } from "./preprocessor/types.js"; export type EngineEvent = { type: "state_commit"; payload: { changes: StateCommitChange[]; }; }; export type BootArgs = { providePlugins?: LixPlugin[]; providePluginsRaw?: string[]; account?: Parameters[0]["account"]; keyValues?: Parameters[0]["keyValues"]; }; export type BootEnv = { sqlite: SqliteWasmDatabase; emit: (ev: EngineEvent) => void; args: BootArgs; }; /** * Engine context bound to a live SQLite connection. * * Internal to the engine: used by deterministic helpers and the engine * function router. Not exposed as a value to app code, but the type is * exported for internal module boundaries. */ export type LixEngine = { sqlite: SqliteWasmDatabase; hooks: LixHooks; /** Return all loaded plugins synchronously */ getAllPluginsSync: () => LixPlugin[]; /** Query preprocessor shared across executeSync + explain flows */ preprocessQuery: PreprocessorFn; /** * Stable runtime-only cache token. * * Each engine instance gets a unique object that survives for the lifetime of * the engine. Use it when you need to memoise values in a WeakMap without * holding on to the whole engine: * * @example * ```ts * const rngState = new WeakMap(); * * function randomSync(engine: LixEngine) { * let state = rngState.get(engine.runtimeCacheRef); * if (!state) { * state = seedRng(); * rngState.set(engine.runtimeCacheRef, state); * } * return state.next(); * } * ``` */ runtimeCacheRef: object; /** Execute raw SQL synchronously against the engine-controlled SQLite connection */ executeSync: (args: { sql: string; parameters?: Readonly; /** * Selects the preprocessing pipeline to run before executing the query. * * - `full` (default): run the entire rewrite pipeline. * - `vtable-select-only`: keep cache population and vtable rewrites. * - `none`: bypass preprocessing entirely. */ preprocessMode?: "full" | "vtable-select-only" | "none"; }) => { rows: any[]; }; /** Invoke an engine function (router) */ call: Call; /** * Register a new engine helper function. * * Prefer registering helpers during engine boot so they are available to * both SQL rewrites and application-level calls. */ registerFunction: FunctionRegistry["register"]; /** Enumerate registered engine helper functions. */ listFunctions: FunctionRegistry["list"]; }; export declare function boot(env: BootEnv): Promise; //# sourceMappingURL=boot.d.ts.map