import { __name } from "../_virtual/_rolldown/runtime.mjs"; import { BaseEdge, BaseEdgeData, BaseEdgeProps, BaseNode, BaseNodeData, BaseNodeProps, NonOptional } from "../base/types.mjs"; import { FunctionComponent } from "react"; import { XYPosition } from "@xyflow/system"; import { AutoLayoutDirection, BBox, DeploymentFqn, DiagramEdge, DiagramNode, DiagramNodeDriftReason, DynamicViewFlow, ExclusiveUnion, Fqn, IconUrl, MarkdownOrString, NonEmptyReadonlyArray, StepPath, ViewId } from "@likec4/core/types"; import { Simplify } from "type-fest"; //#region src/likec4diagram/types.d.ts export declare namespace Types { type LeafNodeData = Simplify> & { /** * View layout direction, used by DefaultHandles to position node handles */ viewLayoutDir?: AutoLayoutDirection | undefined; /** * View this node belongs to */ viewId: ViewId; isMultiple?: boolean | undefined; icon: string | null; drifts: NonEmptyReadonlyArray | null; }>; /** * Represents element from logical model */ type ElementNodeData = Simplify; /** * Represents element from deployment model */ type DeploymentElementNodeData = Simplify; type SequenceActorNodePort = { id: string; cx: number; cy: number; height: number; type: 'target' | 'source'; position: 'left' | 'right' | 'top' | 'bottom'; hidden?: boolean; }; type SequenceActorNodeData = Simplify; viewHeight: number; }>; /** * Represents subflow area in the diagram * `try` and `alt` flows have special handling in the diagram */ type SequenceSubflowData = LeafNodeData & { flowId: StepPath; title: string | undefined; /** * This is first subflow in current flow */ isFirst?: boolean | undefined; /** * This is last subflow in current flow */ isLast?: boolean | undefined; collapsed: boolean; } & ({ flowType: Exclude; } | SequenceSubflowData.AltOrTry); namespace SequenceSubflowData { type AltOrTry = { flowType: 'try' | 'alt'; headerHeight: number; }; } /** * @deprecated Use {@link SequenceSubflowData} instead */ type SequenceParallelAreaData = Simplify; type CompoundNodeData = Simplify> & { /** * View layout direction, used by DefaultHandles to position node handles */ viewLayoutDir?: AutoLayoutDirection | undefined; /** * View this node belongs to */ viewId: ViewId; depth: number; icon?: IconUrl; drifts: NonEmptyReadonlyArray | null; }>; type CompoundElementNodeData = Simplify; type CompoundDeploymentNodeData = Simplify; type ViewGroupNodeData = Simplify; /** * Represents a leaf element rendered as a compact circle in "graph" display variant. * Shares {@link LeafNodeData}'s geometry fields (x/y/width/height/style) with the other * leaf node types, even though "graph" mode renders a fixed-size circle instead - this * keeps generic node utilities (bounds, drifts, notes, etc.) working across all node types. */ type GraphElementNodeData = Simplify; type ElementNode = BaseNode; type DeploymentElementNode = BaseNode; type GraphElementNode = BaseNode; type SequenceActorNode = BaseNode; type SequenceParallelArea = BaseNode; type SequenceSubflowArea = BaseNode; type CompoundElementNode = BaseNode; type CompoundDeploymentNode = BaseNode; type ViewGroupNode = BaseNode; type AnyNode = ElementNode | DeploymentElementNode | CompoundElementNode | CompoundDeploymentNode | ViewGroupNode | SequenceActorNode | SequenceParallelArea | SequenceSubflowArea | GraphElementNode; type NodeType = AnyNode['type']; type NodeData = ExclusiveUnion<{ ElementNodeData: ElementNodeData; DeploymentElementNodeData: DeploymentElementNodeData; CompoundElementNodeData: CompoundElementNodeData; CompoundDeploymentNodeData: CompoundDeploymentNodeData; ViewGroupNodeData: ViewGroupNodeData; SequenceActorNodeData: SequenceActorNodeData; SequenceParallelAreaData: SequenceParallelAreaData; SequenceSubflowAreaData: SequenceSubflowData; GraphElementNodeData: GraphElementNodeData; }>; type Node = Extract; type NodeProps = BaseNodeProps>; type RelationshipEdgeData = Simplify> & { notes: MarkdownOrString | null; labelXY: XYPosition | null; isLabelCustomized?: boolean | undefined; controlPoints: XYPosition[] | undefined | null; /** * When dynamic view in "diagram" variant * Edges are RelationshipEdgeData - stepnum is used to determine the step number * (backward compatibility) */ stepnum?: number; }>; type SequenceStepEdgeData = Simplify> & { id: StepPath; state?: 'processed' | 'active' | 'skipped' | 'pending' | null; stepnum: number; parentFlow: null | { id: StepPath; type: DynamicViewFlow.SubFlowType; }; notes: MarkdownOrString | null; labelXY: XYPosition | null; labelBBox: BBox; isLabelCustomized?: boolean | undefined; controlPoints: XYPosition[] | undefined | null; }>; type RelationshipEdge = BaseEdge; type SequenceStepEdge = BaseEdge; type AnyEdge = RelationshipEdge | SequenceStepEdge; type EdgeType = AnyEdge['type']; type Edge = Extract; type EdgeProps = BaseEdgeProps>; type EdgeData = ExclusiveUnion<{ RelationshipEdgeData: RelationshipEdgeData; SequenceStepEdgeData: SequenceStepEdgeData; }>; type NodeRenderer = FunctionComponent>; type NodeRenderers = { [T in NodeType]: NodeRenderer; }; type EdgeRenderer = FunctionComponent>; type EdgeRenderers = { [T in EdgeType]: EdgeRenderer; }; } //#endregion