UNPKG

@hydro-project/hydroscope

Version:

React-based graph visualization library for Hydro dataflow programs

107 lines 3.48 kB
/** * @fileoverview ReactFlow Bridge - Converts VisualizationState to ReactFlow format * * This bridge converts VisualizationState to ReactFlow's expected data structures. * ReactFlow only sees unified edges (hyperedges are included transparently). */ import type { VisualizationState } from '../core/VisualizationState'; import { Edge as ReactFlowEdge } from '@xyflow/react'; export interface ReactFlowNode { id: string; type: 'standard' | 'container'; position: { x: number; y: number; }; data: { label: string; style: string; collapsed?: boolean; width?: number; height?: number; [key: string]: any; }; style?: { width?: number; height?: number; }; parentId?: string; connectable?: boolean; extent?: 'parent' | [[number, number], [number, number]]; } export interface ReactFlowData { nodes: ReactFlowNode[]; edges: ReactFlowEdge[]; } export declare class ReactFlowBridge { private colorPalette; private edgeStyleConfig?; /** * Set the color palette for node styling */ setColorPalette(palette: string): void; /** * Set the edge style configuration */ setEdgeStyleConfig(config: any): void; /** * Main conversion method: Convert VisualizationState to ReactFlow format * This is the primary public interface, symmetric with ELKBridge.layoutVisState() */ convertVisState(visState: VisualizationState): ReactFlowData; /** * Convert positioned VisState data to ReactFlow format * TRUST ELK: Use ELK's hierarchical layout results completely */ private visStateToReactFlow; /** * CANONICAL PATTERN: Convert nodes to flat ReactFlow nodes (no hierarchy) */ private convertNodesToFlat; /** * CANONICAL PATTERN: Convert containers to flat ReactFlow nodes (no hierarchy) */ private convertContainersToFlat; /** * CANONICAL PATTERN: Convert edges using simple source/target mapping */ private convertEdgesToFlat; /** * Build parent-child relationship map * NOTE: VisualizationState should provide this logic via getParentChildMap() */ private buildParentMap; /** * Sort containers by hierarchy level to ensure parents are processed before children */ private sortContainersByHierarchy; /** * Convert containers to ReactFlow container nodes using ELK layout positions * TRUST ELK: Use ELK's hierarchical positioning completely */ private convertContainersFromELK; /** * Convert regular nodes to ReactFlow standard nodes using ELK layout positions * TRUST ELK: Use ELK's hierarchical positioning completely */ private convertNodesFromELK; /** * Convert regular edges to ReactFlow edges */ private convertEdges; /** * Get edge handles for ReactFlow bridge (moved from VisualizationState) * This is ReactFlow-specific logic for handle assignment * For discrete strategy: intelligently choose handles based on node positions * Prefer: inputs at top or left, outputs at bottom or right */ getEdgeHandles(visState: VisualizationState, edgeId: string): { sourceHandle?: string; targetHandle?: string; }; /** * Extract custom properties from graph elements */ private extractCustomProperties; } //# sourceMappingURL=ReactFlowBridge.d.ts.map