import type { FullObject, InterpreterContext } from "@hylimo/core"; import type { Size, Stroke, FontFamilyConfig, DiagramConfig } from "@hylimo/diagram-common"; import type { SubsetFontKey } from "../font/fontManager.js"; import { FontManager } from "../font/fontManager.js"; import type { TextLayoutResult } from "../font/textLayouter.js"; import { TextLayouter } from "../font/textLayouter.js"; import type { LayoutedDiagram } from "../diagramLayoutResult.js"; import type { LayoutConfig, LayoutElement, SizeConstraints } from "../layoutElement.js"; import { LayoutCache } from "./layoutCache.js"; import type { StretchMode } from "../elements/pathLayoutConfig.js"; import { Layout } from "./layout.js"; import type { SubsettedFont } from "../font/fontFamily.js"; /** * Key of the text cache */ interface TextCacheKey { /** * the max width provided to layout */ maxWidth: number; /** * The styles of the spans the text consists of */ spans: Record[]; } /** * Cache key for path layouting */ interface PathCacheKey { /** * The path to layout */ path: string; /** * The stroke required for layouting */ stroke: Stroke | undefined; /** * The size constraints */ constraints: SizeConstraints; /** * The stretch mode */ stretch: StretchMode; } /** * Cache entry of layouted paths */ export interface LayoutedPath { /** * The layouted path */ path: string; /** * The size of the layouted path */ size: Size; } /** * The root element of the layout with the layout */ export declare class LayoutWithRoot { readonly root: LayoutElement; readonly layout: Layout; readonly fontFamilies: FontFamilyConfig[]; /** * Creates a new layout with root * * @param root - The root element of the layout * @param layout - The layout * @param fontFamilies - The fonts root uses */ constructor(root: LayoutElement, layout: Layout, fontFamilies: FontFamilyConfig[]); } /** * Performs layout, generates a model as a result */ export declare class LayoutEngine { /** * The class used to mark prediction elements */ static readonly PREDICTION_CLASS = "prediction-element"; /** * Lookup for layout configs */ readonly layoutConfigs: Map; /** * Text layout engine */ readonly textLayouter: TextLayouter; /** * Cache used for text layouting */ readonly textCache: LayoutCache; /** * Cache for path layouting */ readonly pathCache: LayoutCache; /** * Cache for subsetted fonts */ readonly subsetFontCache: LayoutCache>; /** * Used to get fonts */ readonly fontManager: FontManager; /** * Creates a new layout engine */ constructor(); /** * Creates a layout for a root element * * @param element the element to layout * @param styles the styles to use * @param fonts the fonts to use * @param context the context to use * @returns the layout with the LayoutElement created for {@link element} */ createLayout(element: FullObject, styles: FullObject, fonts: FullObject, context: InterpreterContext): LayoutWithRoot; /** * Layouts a diagram defined using syncscript * * @param layoutWithRoot the layout with the root element * @param config the configuration to use * @param predictionMode whether to use prediction mode * @returns the layouted diagram */ layout({ root, layout, fontFamilies }: LayoutWithRoot, config: DiagramConfig, predictionMode: boolean): Promise; /** * Hides all non-prediction elements * These are all direct children of the root element without the class {@link LayoutEngine.PREDICTION_CLASS} * * @param root the root element */ private collapseNonPredictionElements; /** * Collapses an element and all its children * * @param element the element to collapse */ private collapseElementRecursively; /** * Starts the next iteration for each cache */ nextCacheGeneration(): void; /** * Generates the subsetted font data * * @param layout the layout to use * @returns the subsetted font data */ private generateSubsettedFontData; /** * Layouts the root element * First measures the element, then layouts it * * @param layout the layout to use * @param layoutElement the element to layout * @returns the layouted canvas child element */ private layoutElement; /** * Initializes the fonts for the layout * Also handles font related caching * * @param layoutElement the root layout element * @param fontFamilies the font families to initialize * @param layout the layout to use * @param diagramConfig the diagram config */ private initFonts; } export {}; //# sourceMappingURL=layoutEngine.d.ts.map