/** * What the canvas draws, as plain data (#577). * * Two steps, both pure, and the canvas itself runs both: * * 1. {@link canvasSceneInput} builds the scene's elements from the model: * which box holds what, which folded box stands for what, which edges are * drawn at all, and the edges lifted onto a folded box. `graphToElements` * turns exactly this into cytoscape elements. * 2. {@link resolveCanvasScene} decides, for one view and one quick-filter * text, what is on screen: the nodes, the boxes pulled in to hold them, the * containment that holds while both ends are visible, what a folded box's * chip counts, which edges draw and what a lifted edge's count says. * `applyFilter` applies exactly this to the live canvas. * * So a host that draws the canvas's picture somewhere else, a server-side * figure renderer, reads the same decisions rather than restating them. A * restated copy was measured wrong twice in its edge labels alone (#576, #587). * * Positions are deliberately NOT here. Every rebuild, view switch and fold runs * ELK over what is visible, and a saved layout is pinned over the result * afterwards, so a subject the saved layout does not name is wherever ELK put * it; a box's bounds are cytoscape's, derived from its members. Neither can be * restated without the layout engine, and a host drawing an unsaved view * places it by its own rules. * * Imports nothing with a runtime of its own, so it ships on the * runtime-neutral `yarramate/adapter/visual-graph` subpath. */ import type { CanvasEdge, CanvasGraph } from './graph-projection.js'; import { type FoldMembership, type FoldTree } from './fold-tree.js'; import type { NestingKind } from './nesting.js'; /** One node of the scene, carrying what {@link resolveCanvasScene} reads. */ export interface CanvasSceneNode { readonly id: string; /** Matched by the quick filter, with `id` and `kindLabel`. */ readonly name?: string; readonly kindLabel?: string; /** The box the model nests this in, whether or not it is drawn nested. */ readonly parent?: string; /** Drawn folded: everything under it is hidden and its edges lifted to it. */ readonly folded: boolean; /** Everything nested under it, at any depth, over the whole model. */ readonly insideIds: readonly string[]; } /** One edge of the scene: a drawn relationship, or one lifted onto a fold. */ export interface CanvasSceneEdge { readonly id: string; readonly from: string; readonly to: string; /** * Present only on a lifted edge (`lift:` ids): the relationships it stands * for. Such an edge draws while the view selected any of them. */ readonly relationshipIds?: readonly string[]; /** A lifted edge's kind, as its label names it. */ readonly liftedKind?: string; } export interface CanvasSceneInput { readonly nodes: readonly CanvasSceneNode[]; /** * The drawn relationships (nesting-consumed and, unless shown, * responsibility edges already left out), then the lifted edges. */ readonly edges: readonly CanvasSceneEdge[]; /** For the caller's own warnings: nesting conflicts and cycles. */ readonly tree: FoldTree; } export interface CanvasSceneFold { /** Which instances draw folded. Empty or absent draws everything. */ readonly folded?: ReadonlySet; /** From the model frame; without them only view nesting contains anything. */ readonly memberships?: readonly FoldMembership[]; /** Whether responsibility edges are drawn (#557, ADR 0159). */ readonly showResponsibility?: boolean; } /** The drawn relationships: what nesting did not consume, and RACI only if shown. */ export declare function drawnCanvasEdges(graph: Pick, tree: Pick, showResponsibility: boolean): CanvasEdge[]; /** * The scene's elements for a model, before any view narrows them. What * `graphToElements` builds cytoscape elements from. */ export declare function canvasSceneInput(graph: CanvasGraph, nesting: readonly NestingKind[], fold?: CanvasSceneFold): CanvasSceneInput; /** What one view, with one quick-filter text, puts on screen. */ export interface CanvasScene { /** The nodes drawn: matched, surviving the filter, pulled in, not folded away. */ readonly visibleNodeIds: ReadonlySet; /** Of those, the boxes drawn only to hold something the view matched. */ readonly contextNodeIds: ReadonlySet; /** Containment as drawn: a node sits in its box only while both are visible. */ readonly parentOf: ReadonlyMap; /** For each folded node: how many of what it holds this view selected. */ readonly insideCount: ReadonlyMap; /** The edges drawn, lifted ones included. */ readonly visibleEdgeIds: ReadonlySet; /** For each lifted edge: how many of its relationships this view selected. */ readonly liftedCount: ReadonlyMap; /** * Edges between a box and something nested in it, left undrawn: the nesting * already says it (ADR 0147). Whether or not they would otherwise draw. */ readonly impliedEdgeIds: ReadonlySet; /** * What a saved layout names for this view (#578): the matched subjects and * the boxes that hold them, before the filter or a fold hides any. Null * when no view narrows the canvas. */ readonly viewNodeIds: ReadonlySet | null; } /** * What the canvas shows for a view. `matchedIds` is the view's match set, or * null when no view narrows the canvas; it may name relationships as well as * subjects. An edge draws only where the view selected it AND both its ends * are drawn (#579, ADR 0164). */ export declare function resolveCanvasScene(input: Pick, matchedIds: readonly string[] | null, quickFilterText: string): CanvasScene;