/** * Layout pipeline. * * Takes a DiagramDef and produces a fully resolved DiagramLayout: where * every connector ends up (including routed ones), where every label * lands (with collision flagging), and which Note leader lines target * which fixed pixel coords. * * Has no dependency on React. The Diagram component consumes the * output of `resolveDiagram(def)` and only handles the SVG mapping. */ import type { NormalizedConnectorDef, NormalizedDiagramDef, NormalizedNodeDef, NormalizedNoteDef, NormalizedRegionDef } from '../types.js'; import type { GridLayout } from '../geometry/grid.js'; import { type Pixel } from '../geometry/connector-path.js'; import type { IntPt } from '../geometry/router.js'; import type { PlacementDiagnostic } from '../gg/diagnostics.js'; import type { NodeLabelResult } from './node-label.js'; import type { ConnectorLabelResult } from './connector-label.js'; import type { RegionLabelResult } from './region-label.js'; import type { NoteLayout, LeaderTarget } from './note-layout.js'; export interface ResolvedConnector { conn: NormalizedConnectorDef; /** Router-supplied waypoints (only set when the direct line crosses a node) */ pixelWaypoints?: Pixel[]; /** Grid-intersection points along a routed path (used for usage counting) */ intersections: IntPt[]; /** True when the line could neither go direct nor be routed */ lineError: boolean; labelResult?: ConnectorLabelResult; /** * Overlap-split rotation applied at the FROM-end's pulled-back point, * in radians. Set when this connector is one of an exactly-2 pair * sharing the same unordered endpoint pair; absent otherwise. The * Connector component and the connector-label placer both feed this * back into `resolveConnectorPath` so the rendered SVG and the label * layout agree on where the line actually sits. */ fromAngleOffset?: number; /** Same as `fromAngleOffset`, for the TO-end. */ toAngleOffset?: number; } export interface ResolvedNote { note: NormalizedNoteDef; layout: NoteLayout; targets: LeaderTarget[]; } export interface ResolvedRegion { region: NormalizedRegionDef; labelResult: RegionLabelResult | null; } export interface DiagramLayout { layout: GridLayout; nodeMap: Map; connectors: ResolvedConnector[]; notes: ResolvedNote[]; regions: ResolvedRegion[]; /** Node id → label placement (only present when the node has a label) */ nodeLabelByNodeId: Map; /** Placement / layout feedback for AI agents and humans. Empty when * every label fit cleanly and every connector routed successfully. */ diagnostics: PlacementDiagnostic[]; } /** * Resolve a DiagramDef into a DiagramLayout. Steps: * 1. Lay out connectors (direct lines or routed) and accumulate their segments * 2. Lay out notes (fixed cells; their rects act as labels for later steps) * 3. Place node labels in connector-count order (most-connected first) * 4. Place connector labels (skipping each connector's own segments) * 5. Place region labels last (they're background) */ export declare function resolveDiagram(def: NormalizedDiagramDef): DiagramLayout; //# sourceMappingURL=pipeline.d.ts.map