import type { CstResult, ExecutableExpression, InterpretationResult, InterpreterModule, RuntimeError } from "@hylimo/core"; import { Interpreter, Parser } from "@hylimo/core"; import { LayoutEngine, LayoutWithRoot } from "./layout/engine/layoutEngine.js"; import type { DiagramConfig } from "@hylimo/diagram-common"; import type { LayoutedDiagram } from "./layout/diagramLayoutResult.js"; /** * All errors that can occur during rendering of a diagram */ export interface RenderErrors extends Pick { /** * Errors that occurred during the interpretation */ interpreterErrors: RuntimeError[]; /** * Errors that occurred during the layouting */ layoutErrors: Error[]; } /** * The result of rendering a diagram */ export interface RenderResult { /** * All errors combined */ errors: RenderErrors; /** * The final layouted diagram */ layoutedDiagram?: LayoutedDiagram; } /** * Render result with a generic result type and errors * * @template T the result type * @template E the error type */ export interface RenderResultBase { /** * All errors combined */ errors: RenderErrors | (RenderErrors & E); /** * The result, if present */ result?: T; } /** * A diagram engine that can render a diagram from source code and config using a parser, interpreter, and a layout engine */ export declare class DiagramEngine { /** * The parser to use */ protected readonly parser: Parser; /** * The interpreter to use */ protected readonly interpreter: Interpreter; /** * The layout engine to use */ protected readonly layoutEngine: LayoutEngine; /** * Creates a new DiagramEngine * * @param additionalInterpreterModules additional modules to use in the interpreter * @param maxExecutionSteps the maximum number of execution steps */ constructor(additionalInterpreterModules: InterpreterModule[], maxExecutionSteps: number); /** * Renders a diagram * * @param source the source to execute * @param config additional config * @param predictionMode whether to use prediction mode * @returns the render result including the potential diagram and all errors */ render(source: string, config: DiagramConfig, predictionMode?: boolean): Promise; /** * Renders a diagram internally with a customizable final step * * @param source the source to execute * @param config additional config * @param generateResult function to generate the final result from the layout with root * @returns the render result including the potential diagram and all errors */ protected renderInternal(source: string, config: DiagramConfig, generateResult: (layoutWithRoot: LayoutWithRoot) => Promise>): Promise>; /** * Generates a complete RenderErrors object from partial errors * * @param errors the partial errors * @returns the complete RenderErrors object */ protected generateErrors(errors: Partial): RenderErrors; /** * Executes the given expressions * Also generates and adds expressions for the given config * * @param expressions the expressions to execute * @param config the config to use * @returns the interpretation result */ execute(expressions: ExecutableExpression[], config: DiagramConfig): InterpretationResult; /** * Converts the config to a list of executable expressions * * @param config the config to convert * @returns the expressions setting the config */ convertConfig(config: DiagramConfig): ExecutableExpression[]; } //# sourceMappingURL=diagramEngine.d.ts.map