@principal-ai/subsystems-react 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +93 -0
- package/dist/components/ConfigurationSelector.d.ts +35 -0
- package/dist/components/ConfigurationSelector.d.ts.map +1 -0
- package/dist/components/ConfigurationSelector.js +63 -0
- package/dist/components/ConfigurationSelector.js.map +1 -0
- package/dist/components/GraphRenderer.d.ts +295 -0
- package/dist/components/GraphRenderer.d.ts.map +1 -0
- package/dist/components/GraphRenderer.js +2008 -0
- package/dist/components/GraphRenderer.js.map +1 -0
- package/dist/components/MultiCanvasRenderer.d.ts +75 -0
- package/dist/components/MultiCanvasRenderer.d.ts.map +1 -0
- package/dist/components/MultiCanvasRenderer.js +203 -0
- package/dist/components/MultiCanvasRenderer.js.map +1 -0
- package/dist/components/NodeTooltip.d.ts +24 -0
- package/dist/components/NodeTooltip.d.ts.map +1 -0
- package/dist/components/NodeTooltip.js +160 -0
- package/dist/components/NodeTooltip.js.map +1 -0
- package/dist/components/SelectionSidebar.d.ts +18 -0
- package/dist/components/SelectionSidebar.d.ts.map +1 -0
- package/dist/components/SelectionSidebar.js +190 -0
- package/dist/components/SelectionSidebar.js.map +1 -0
- package/dist/components/SequenceDiagramRenderer.d.ts +77 -0
- package/dist/components/SequenceDiagramRenderer.d.ts.map +1 -0
- package/dist/components/SequenceDiagramRenderer.js +604 -0
- package/dist/components/SequenceDiagramRenderer.js.map +1 -0
- package/dist/components/WorkflowSequenceDiagram.d.ts +63 -0
- package/dist/components/WorkflowSequenceDiagram.d.ts.map +1 -0
- package/dist/components/WorkflowSequenceDiagram.js +147 -0
- package/dist/components/WorkflowSequenceDiagram.js.map +1 -0
- package/dist/components/dashboard/DashboardRenderer.d.ts +10 -0
- package/dist/components/dashboard/DashboardRenderer.d.ts.map +1 -0
- package/dist/components/dashboard/DashboardRenderer.js +179 -0
- package/dist/components/dashboard/DashboardRenderer.js.map +1 -0
- package/dist/components/dashboard/MetricPanel.d.ts +10 -0
- package/dist/components/dashboard/MetricPanel.d.ts.map +1 -0
- package/dist/components/dashboard/MetricPanel.js +103 -0
- package/dist/components/dashboard/MetricPanel.js.map +1 -0
- package/dist/components/dashboard/MockDataProvider.d.ts +30 -0
- package/dist/components/dashboard/MockDataProvider.d.ts.map +1 -0
- package/dist/components/dashboard/MockDataProvider.js +270 -0
- package/dist/components/dashboard/MockDataProvider.js.map +1 -0
- package/dist/components/dashboard/components/BarChart.d.ts +10 -0
- package/dist/components/dashboard/components/BarChart.d.ts.map +1 -0
- package/dist/components/dashboard/components/BarChart.js +167 -0
- package/dist/components/dashboard/components/BarChart.js.map +1 -0
- package/dist/components/dashboard/components/LineChart.d.ts +10 -0
- package/dist/components/dashboard/components/LineChart.d.ts.map +1 -0
- package/dist/components/dashboard/components/LineChart.js +141 -0
- package/dist/components/dashboard/components/LineChart.js.map +1 -0
- package/dist/components/dashboard/components/MetricCard.d.ts +9 -0
- package/dist/components/dashboard/components/MetricCard.d.ts.map +1 -0
- package/dist/components/dashboard/components/MetricCard.js +163 -0
- package/dist/components/dashboard/components/MetricCard.js.map +1 -0
- package/dist/components/dashboard/components/SourceLink.d.ts +9 -0
- package/dist/components/dashboard/components/SourceLink.d.ts.map +1 -0
- package/dist/components/dashboard/components/SourceLink.js +39 -0
- package/dist/components/dashboard/components/SourceLink.js.map +1 -0
- package/dist/components/dashboard/components/TimeRangeSelector.d.ts +9 -0
- package/dist/components/dashboard/components/TimeRangeSelector.d.ts.map +1 -0
- package/dist/components/dashboard/components/TimeRangeSelector.js +167 -0
- package/dist/components/dashboard/components/TimeRangeSelector.js.map +1 -0
- package/dist/components/dashboard/components/index.d.ts +6 -0
- package/dist/components/dashboard/components/index.d.ts.map +1 -0
- package/dist/components/dashboard/components/index.js +6 -0
- package/dist/components/dashboard/components/index.js.map +1 -0
- package/dist/components/dashboard/index.d.ts +6 -0
- package/dist/components/dashboard/index.d.ts.map +1 -0
- package/dist/components/dashboard/index.js +8 -0
- package/dist/components/dashboard/index.js.map +1 -0
- package/dist/components/dashboard/types.d.ts +74 -0
- package/dist/components/dashboard/types.d.ts.map +1 -0
- package/dist/components/dashboard/types.js +8 -0
- package/dist/components/dashboard/types.js.map +1 -0
- package/dist/components/session-events/SessionEventFeed.d.ts +34 -0
- package/dist/components/session-events/SessionEventFeed.d.ts.map +1 -0
- package/dist/components/session-events/SessionEventFeed.js +1196 -0
- package/dist/components/session-events/SessionEventFeed.js.map +1 -0
- package/dist/components/session-events/index.d.ts +7 -0
- package/dist/components/session-events/index.d.ts.map +1 -0
- package/dist/components/session-events/index.js +6 -0
- package/dist/components/session-events/index.js.map +1 -0
- package/dist/components/state-view/PipelineView.d.ts +14 -0
- package/dist/components/state-view/PipelineView.d.ts.map +1 -0
- package/dist/components/state-view/PipelineView.js +195 -0
- package/dist/components/state-view/PipelineView.js.map +1 -0
- package/dist/components/state-view/index.d.ts +14 -0
- package/dist/components/state-view/index.d.ts.map +1 -0
- package/dist/components/state-view/index.js +12 -0
- package/dist/components/state-view/index.js.map +1 -0
- package/dist/components/state-view/types.d.ts +188 -0
- package/dist/components/state-view/types.d.ts.map +1 -0
- package/dist/components/state-view/types.js +10 -0
- package/dist/components/state-view/types.js.map +1 -0
- package/dist/components/state-view/useStateView.d.ts +32 -0
- package/dist/components/state-view/useStateView.d.ts.map +1 -0
- package/dist/components/state-view/useStateView.js +129 -0
- package/dist/components/state-view/useStateView.js.map +1 -0
- package/dist/contexts/GraphEditContext.d.ts +20 -0
- package/dist/contexts/GraphEditContext.d.ts.map +1 -0
- package/dist/contexts/GraphEditContext.js +8 -0
- package/dist/contexts/GraphEditContext.js.map +1 -0
- package/dist/contexts/TooltipPortalContext.d.ts +8 -0
- package/dist/contexts/TooltipPortalContext.d.ts.map +1 -0
- package/dist/contexts/TooltipPortalContext.js +8 -0
- package/dist/contexts/TooltipPortalContext.js.map +1 -0
- package/dist/edges/CustomEdge.d.ts +24 -0
- package/dist/edges/CustomEdge.d.ts.map +1 -0
- package/dist/edges/CustomEdge.js +222 -0
- package/dist/edges/CustomEdge.js.map +1 -0
- package/dist/edges/GenericEdge.d.ts +18 -0
- package/dist/edges/GenericEdge.d.ts.map +1 -0
- package/dist/edges/GenericEdge.js +10 -0
- package/dist/edges/GenericEdge.js.map +1 -0
- package/dist/graphify/anchor.d.ts +28 -0
- package/dist/graphify/anchor.d.ts.map +1 -0
- package/dist/graphify/anchor.js +132 -0
- package/dist/graphify/anchor.js.map +1 -0
- package/dist/graphify/consolidated.d.ts +210 -0
- package/dist/graphify/consolidated.d.ts.map +1 -0
- package/dist/graphify/consolidated.js +11 -0
- package/dist/graphify/consolidated.js.map +1 -0
- package/dist/graphify/ids.d.ts +19 -0
- package/dist/graphify/ids.d.ts.map +1 -0
- package/dist/graphify/ids.js +46 -0
- package/dist/graphify/ids.js.map +1 -0
- package/dist/graphify/index.d.ts +18 -0
- package/dist/graphify/index.d.ts.map +1 -0
- package/dist/graphify/index.js +12 -0
- package/dist/graphify/index.js.map +1 -0
- package/dist/graphify/kind.d.ts +23 -0
- package/dist/graphify/kind.d.ts.map +1 -0
- package/dist/graphify/kind.js +77 -0
- package/dist/graphify/kind.js.map +1 -0
- package/dist/graphify/resolve.d.ts +48 -0
- package/dist/graphify/resolve.d.ts.map +1 -0
- package/dist/graphify/resolve.js +83 -0
- package/dist/graphify/resolve.js.map +1 -0
- package/dist/graphify/signature.d.ts +87 -0
- package/dist/graphify/signature.d.ts.map +1 -0
- package/dist/graphify/signature.js +276 -0
- package/dist/graphify/signature.js.map +1 -0
- package/dist/graphify/types.d.ts +141 -0
- package/dist/graphify/types.d.ts.map +1 -0
- package/dist/graphify/types.js +8 -0
- package/dist/graphify/types.js.map +1 -0
- package/dist/hooks/useElkLayout.d.ts +66 -0
- package/dist/hooks/useElkLayout.d.ts.map +1 -0
- package/dist/hooks/useElkLayout.js +136 -0
- package/dist/hooks/useElkLayout.js.map +1 -0
- package/dist/hooks/usePathBasedEvents.d.ts +42 -0
- package/dist/hooks/usePathBasedEvents.d.ts.map +1 -0
- package/dist/hooks/usePathBasedEvents.js +119 -0
- package/dist/hooks/usePathBasedEvents.js.map +1 -0
- package/dist/hooks/useSequenceLayout.d.ts +186 -0
- package/dist/hooks/useSequenceLayout.d.ts.map +1 -0
- package/dist/hooks/useSequenceLayout.js +327 -0
- package/dist/hooks/useSequenceLayout.js.map +1 -0
- package/dist/hooks/useUndoRedo.d.ts +80 -0
- package/dist/hooks/useUndoRedo.d.ts.map +1 -0
- package/dist/hooks/useUndoRedo.js +70 -0
- package/dist/hooks/useUndoRedo.js.map +1 -0
- package/dist/index.d.ts +73 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +51 -0
- package/dist/index.js.map +1 -0
- package/dist/nodes/CustomNode.d.ts +28 -0
- package/dist/nodes/CustomNode.d.ts.map +1 -0
- package/dist/nodes/CustomNode.js +820 -0
- package/dist/nodes/CustomNode.js.map +1 -0
- package/dist/nodes/GenericNode.d.ts +20 -0
- package/dist/nodes/GenericNode.d.ts.map +1 -0
- package/dist/nodes/GenericNode.js +20 -0
- package/dist/nodes/GenericNode.js.map +1 -0
- package/dist/nodes/otel/OtelBoundaryNode.d.ts +55 -0
- package/dist/nodes/otel/OtelBoundaryNode.d.ts.map +1 -0
- package/dist/nodes/otel/OtelBoundaryNode.js +81 -0
- package/dist/nodes/otel/OtelBoundaryNode.js.map +1 -0
- package/dist/nodes/otel/OtelEventNode.d.ts +59 -0
- package/dist/nodes/otel/OtelEventNode.d.ts.map +1 -0
- package/dist/nodes/otel/OtelEventNode.js +82 -0
- package/dist/nodes/otel/OtelEventNode.js.map +1 -0
- package/dist/nodes/otel/OtelResourceNode.d.ts +53 -0
- package/dist/nodes/otel/OtelResourceNode.d.ts.map +1 -0
- package/dist/nodes/otel/OtelResourceNode.js +105 -0
- package/dist/nodes/otel/OtelResourceNode.js.map +1 -0
- package/dist/nodes/otel/OtelScopeNode.d.ts +53 -0
- package/dist/nodes/otel/OtelScopeNode.d.ts.map +1 -0
- package/dist/nodes/otel/OtelScopeNode.js +81 -0
- package/dist/nodes/otel/OtelScopeNode.js.map +1 -0
- package/dist/nodes/otel/OtelSpanConventionNode.d.ts +61 -0
- package/dist/nodes/otel/OtelSpanConventionNode.d.ts.map +1 -0
- package/dist/nodes/otel/OtelSpanConventionNode.js +131 -0
- package/dist/nodes/otel/OtelSpanConventionNode.js.map +1 -0
- package/dist/nodes/otel/index.d.ts +17 -0
- package/dist/nodes/otel/index.d.ts.map +1 -0
- package/dist/nodes/otel/index.js +13 -0
- package/dist/nodes/otel/index.js.map +1 -0
- package/dist/nodes/otel/shared/NodeBadges.d.ts +10 -0
- package/dist/nodes/otel/shared/NodeBadges.d.ts.map +1 -0
- package/dist/nodes/otel/shared/NodeBadges.js +178 -0
- package/dist/nodes/otel/shared/NodeBadges.js.map +1 -0
- package/dist/nodes/otel/shared/NodeContent.d.ts +10 -0
- package/dist/nodes/otel/shared/NodeContent.d.ts.map +1 -0
- package/dist/nodes/otel/shared/NodeContent.js +96 -0
- package/dist/nodes/otel/shared/NodeContent.js.map +1 -0
- package/dist/nodes/otel/shared/index.d.ts +8 -0
- package/dist/nodes/otel/shared/index.d.ts.map +1 -0
- package/dist/nodes/otel/shared/index.js +8 -0
- package/dist/nodes/otel/shared/index.js.map +1 -0
- package/dist/nodes/otel/shared/types.d.ts +129 -0
- package/dist/nodes/otel/shared/types.d.ts.map +1 -0
- package/dist/nodes/otel/shared/types.js +5 -0
- package/dist/nodes/otel/shared/types.js.map +1 -0
- package/dist/nodes/otel/shared/useNodeBehavior.d.ts +42 -0
- package/dist/nodes/otel/shared/useNodeBehavior.d.ts.map +1 -0
- package/dist/nodes/otel/shared/useNodeBehavior.js +61 -0
- package/dist/nodes/otel/shared/useNodeBehavior.js.map +1 -0
- package/dist/pierre/PierreFileView.d.ts +17 -0
- package/dist/pierre/PierreFileView.d.ts.map +1 -0
- package/dist/pierre/PierreFileView.js +46 -0
- package/dist/pierre/PierreFileView.js.map +1 -0
- package/dist/pierre/PierreSnippetView.d.ts +28 -0
- package/dist/pierre/PierreSnippetView.d.ts.map +1 -0
- package/dist/pierre/PierreSnippetView.js +105 -0
- package/dist/pierre/PierreSnippetView.js.map +1 -0
- package/dist/pierre/PierreThroughlineCodeView.d.ts +22 -0
- package/dist/pierre/PierreThroughlineCodeView.d.ts.map +1 -0
- package/dist/pierre/PierreThroughlineCodeView.js +206 -0
- package/dist/pierre/PierreThroughlineCodeView.js.map +1 -0
- package/dist/pierre/constructColors.d.ts +24 -0
- package/dist/pierre/constructColors.d.ts.map +1 -0
- package/dist/pierre/constructColors.js +91 -0
- package/dist/pierre/constructColors.js.map +1 -0
- package/dist/pierre/index.d.ts +12 -0
- package/dist/pierre/index.d.ts.map +1 -0
- package/dist/pierre/index.js +7 -0
- package/dist/pierre/index.js.map +1 -0
- package/dist/pierre/pierreBackground.d.ts +15 -0
- package/dist/pierre/pierreBackground.d.ts.map +1 -0
- package/dist/pierre/pierreBackground.js +31 -0
- package/dist/pierre/pierreBackground.js.map +1 -0
- package/dist/pierre/pierreFileLang.d.ts +27 -0
- package/dist/pierre/pierreFileLang.d.ts.map +1 -0
- package/dist/pierre/pierreFileLang.js +52 -0
- package/dist/pierre/pierreFileLang.js.map +1 -0
- package/dist/pierre/pierreSyntaxTheme.d.ts +11 -0
- package/dist/pierre/pierreSyntaxTheme.d.ts.map +1 -0
- package/dist/pierre/pierreSyntaxTheme.js +20 -0
- package/dist/pierre/pierreSyntaxTheme.js.map +1 -0
- package/dist/pierre/scrollAnchor.d.ts +5 -0
- package/dist/pierre/scrollAnchor.d.ts.map +1 -0
- package/dist/pierre/scrollAnchor.js +9 -0
- package/dist/pierre/scrollAnchor.js.map +1 -0
- package/dist/pierre/sliceSnippet.d.ts +10 -0
- package/dist/pierre/sliceSnippet.d.ts.map +1 -0
- package/dist/pierre/sliceSnippet.js +16 -0
- package/dist/pierre/sliceSnippet.js.map +1 -0
- package/dist/pierre/syntaxTokens.d.ts +11 -0
- package/dist/pierre/syntaxTokens.d.ts.map +1 -0
- package/dist/pierre/syntaxTokens.js +51 -0
- package/dist/pierre/syntaxTokens.js.map +1 -0
- package/dist/stories/Subsystem/ComponentGraph/fixtures.d.ts +8 -0
- package/dist/stories/Subsystem/ComponentGraph/fixtures.d.ts.map +1 -0
- package/dist/stories/Subsystem/ComponentGraph/fixtures.js +116 -0
- package/dist/stories/Subsystem/ComponentGraph/fixtures.js.map +1 -0
- package/dist/subsystem/ComponentDeclaration.d.ts +87 -0
- package/dist/subsystem/ComponentDeclaration.d.ts.map +1 -0
- package/dist/subsystem/ComponentDeclaration.js +374 -0
- package/dist/subsystem/ComponentDeclaration.js.map +1 -0
- package/dist/subsystem/FileDrawer.d.ts +17 -0
- package/dist/subsystem/FileDrawer.d.ts.map +1 -0
- package/dist/subsystem/FileDrawer.js +72 -0
- package/dist/subsystem/FileDrawer.js.map +1 -0
- package/dist/subsystem/GraphLayoutCover.d.ts +20 -0
- package/dist/subsystem/GraphLayoutCover.d.ts.map +1 -0
- package/dist/subsystem/GraphLayoutCover.js +42 -0
- package/dist/subsystem/GraphLayoutCover.js.map +1 -0
- package/dist/subsystem/SubsystemComponentGraph.d.ts +96 -0
- package/dist/subsystem/SubsystemComponentGraph.d.ts.map +1 -0
- package/dist/subsystem/SubsystemComponentGraph.js +1059 -0
- package/dist/subsystem/SubsystemComponentGraph.js.map +1 -0
- package/dist/subsystem/SubsystemFileTree.d.ts +24 -0
- package/dist/subsystem/SubsystemFileTree.d.ts.map +1 -0
- package/dist/subsystem/SubsystemFileTree.js +150 -0
- package/dist/subsystem/SubsystemFileTree.js.map +1 -0
- package/dist/subsystem/declarationRef.d.ts +39 -0
- package/dist/subsystem/declarationRef.d.ts.map +1 -0
- package/dist/subsystem/declarationRef.js +32 -0
- package/dist/subsystem/declarationRef.js.map +1 -0
- package/dist/subsystem/formatDeclaration.d.ts +11 -0
- package/dist/subsystem/formatDeclaration.d.ts.map +1 -0
- package/dist/subsystem/formatDeclaration.js +146 -0
- package/dist/subsystem/formatDeclaration.js.map +1 -0
- package/dist/subsystem/model.d.ts +353 -0
- package/dist/subsystem/model.d.ts.map +1 -0
- package/dist/subsystem/model.js +503 -0
- package/dist/subsystem/model.js.map +1 -0
- package/dist/subsystem/nodes.d.ts +69 -0
- package/dist/subsystem/nodes.d.ts.map +1 -0
- package/dist/subsystem/nodes.js +289 -0
- package/dist/subsystem/nodes.js.map +1 -0
- package/dist/subsystem/paths.d.ts +63 -0
- package/dist/subsystem/paths.d.ts.map +1 -0
- package/dist/subsystem/paths.js +86 -0
- package/dist/subsystem/paths.js.map +1 -0
- package/dist/subsystem/tokenizeComponent.d.ts +20 -0
- package/dist/subsystem/tokenizeComponent.d.ts.map +1 -0
- package/dist/subsystem/tokenizeComponent.js +56 -0
- package/dist/subsystem/tokenizeComponent.js.map +1 -0
- package/dist/subsystem/tokenizeFormatted.d.ts +12 -0
- package/dist/subsystem/tokenizeFormatted.d.ts.map +1 -0
- package/dist/subsystem/tokenizeFormatted.js +13 -0
- package/dist/subsystem/tokenizeFormatted.js.map +1 -0
- package/dist/utils/animationMapping.d.ts +53 -0
- package/dist/utils/animationMapping.d.ts.map +1 -0
- package/dist/utils/animationMapping.js +126 -0
- package/dist/utils/animationMapping.js.map +1 -0
- package/dist/utils/canvasBounds.d.ts +50 -0
- package/dist/utils/canvasBounds.d.ts.map +1 -0
- package/dist/utils/canvasBounds.js +88 -0
- package/dist/utils/canvasBounds.js.map +1 -0
- package/dist/utils/elkLayout.d.ts +137 -0
- package/dist/utils/elkLayout.d.ts.map +1 -0
- package/dist/utils/elkLayout.js +596 -0
- package/dist/utils/elkLayout.js.map +1 -0
- package/dist/utils/graphConverter.d.ts +18 -0
- package/dist/utils/graphConverter.d.ts.map +1 -0
- package/dist/utils/graphConverter.js +114 -0
- package/dist/utils/graphConverter.js.map +1 -0
- package/dist/utils/iconResolver.d.ts +29 -0
- package/dist/utils/iconResolver.d.ts.map +1 -0
- package/dist/utils/iconResolver.js +30 -0
- package/dist/utils/iconResolver.js.map +1 -0
- package/dist/utils/orientationUtils.d.ts +19 -0
- package/dist/utils/orientationUtils.d.ts.map +1 -0
- package/dist/utils/orientationUtils.js +62 -0
- package/dist/utils/orientationUtils.js.map +1 -0
- package/package.json +80 -0
- package/src/components/ConfigurationSelector.tsx +133 -0
- package/src/components/GraphRenderer.tsx +3195 -0
- package/src/components/MultiCanvasRenderer.tsx +295 -0
- package/src/components/NodeTooltip.tsx +279 -0
- package/src/components/PendingChanges.test.tsx +375 -0
- package/src/components/SelectionSidebar.tsx +352 -0
- package/src/components/SequenceDiagramRenderer.tsx +1156 -0
- package/src/components/WorkflowSequenceDiagram.tsx +270 -0
- package/src/components/dashboard/DashboardRenderer.tsx +317 -0
- package/src/components/dashboard/MetricPanel.tsx +254 -0
- package/src/components/dashboard/MockDataProvider.ts +330 -0
- package/src/components/dashboard/components/BarChart.tsx +299 -0
- package/src/components/dashboard/components/LineChart.tsx +279 -0
- package/src/components/dashboard/components/MetricCard.tsx +270 -0
- package/src/components/dashboard/components/SourceLink.tsx +63 -0
- package/src/components/dashboard/components/TimeRangeSelector.tsx +280 -0
- package/src/components/dashboard/components/index.ts +5 -0
- package/src/components/dashboard/index.ts +47 -0
- package/src/components/dashboard/types.ts +126 -0
- package/src/components/session-events/SessionEventFeed.tsx +1797 -0
- package/src/components/session-events/index.ts +13 -0
- package/src/components/state-view/PipelineView.tsx +347 -0
- package/src/components/state-view/index.ts +14 -0
- package/src/components/state-view/types.ts +261 -0
- package/src/components/state-view/useStateView.ts +205 -0
- package/src/contexts/GraphEditContext.tsx +27 -0
- package/src/contexts/TooltipPortalContext.ts +8 -0
- package/src/edges/CustomEdge.tsx +402 -0
- package/src/edges/GenericEdge.tsx +36 -0
- package/src/graphify/anchor.test.ts +124 -0
- package/src/graphify/anchor.ts +160 -0
- package/src/graphify/consolidated.ts +246 -0
- package/src/graphify/ids.ts +48 -0
- package/src/graphify/index.ts +72 -0
- package/src/graphify/kind.test.ts +108 -0
- package/src/graphify/kind.ts +120 -0
- package/src/graphify/resolve.test.ts +89 -0
- package/src/graphify/resolve.ts +115 -0
- package/src/graphify/signature.test.ts +278 -0
- package/src/graphify/signature.ts +354 -0
- package/src/graphify/types.ts +164 -0
- package/src/hooks/useElkLayout.test.ts +134 -0
- package/src/hooks/useElkLayout.ts +191 -0
- package/src/hooks/usePathBasedEvents.ts +192 -0
- package/src/hooks/useSequenceLayout.ts +543 -0
- package/src/hooks/useUndoRedo.ts +144 -0
- package/src/index.ts +341 -0
- package/src/nodes/CustomNode.tsx +1231 -0
- package/src/nodes/GenericNode.tsx +55 -0
- package/src/nodes/otel/OtelBoundaryNode.tsx +224 -0
- package/src/nodes/otel/OtelEventNode.tsx +225 -0
- package/src/nodes/otel/OtelResourceNode.tsx +251 -0
- package/src/nodes/otel/OtelScopeNode.tsx +221 -0
- package/src/nodes/otel/OtelSpanConventionNode.tsx +295 -0
- package/src/nodes/otel/index.ts +23 -0
- package/src/nodes/otel/shared/NodeBadges.tsx +295 -0
- package/src/nodes/otel/shared/NodeContent.tsx +204 -0
- package/src/nodes/otel/shared/index.ts +8 -0
- package/src/nodes/otel/shared/types.ts +138 -0
- package/src/nodes/otel/shared/useNodeBehavior.ts +114 -0
- package/src/pierre/PierreFileView.tsx +81 -0
- package/src/pierre/PierreSnippetView.tsx +184 -0
- package/src/pierre/PierreThroughlineCodeView.tsx +304 -0
- package/src/pierre/constructColors.test.ts +52 -0
- package/src/pierre/constructColors.ts +112 -0
- package/src/pierre/index.ts +18 -0
- package/src/pierre/pierreBackground.ts +33 -0
- package/src/pierre/pierreFileLang.test.ts +26 -0
- package/src/pierre/pierreFileLang.ts +55 -0
- package/src/pierre/pierreSyntaxTheme.ts +23 -0
- package/src/pierre/scrollAnchor.test.ts +13 -0
- package/src/pierre/scrollAnchor.ts +11 -0
- package/src/pierre/sliceSnippet.test.ts +21 -0
- package/src/pierre/sliceSnippet.ts +31 -0
- package/src/pierre/syntaxTokens.test.ts +35 -0
- package/src/pierre/syntaxTokens.ts +60 -0
- package/src/stories/Audit/BoundaryNodes.stories.tsx +385 -0
- package/src/stories/Audit/CanvasEdgeTypes.stories.tsx +1448 -0
- package/src/stories/Audit/CanvasNodeTypes.stories.tsx +1049 -0
- package/src/stories/Audit/ColorPriority.stories.tsx +895 -0
- package/src/stories/Audit/DiamondBadges.stories.tsx +629 -0
- package/src/stories/Audit/NodeDimensionsTesting.stories.tsx +724 -0
- package/src/stories/Audit/NodeFieldsAudit.stories.tsx +996 -0
- package/src/stories/Audit/NodeFontSizeTesting.stories.tsx +715 -0
- package/src/stories/Audit/NodeShapes.stories.tsx +1208 -0
- package/src/stories/Audit/WideNodesTesting.stories.tsx +1045 -0
- package/src/stories/Components/DashboardRenderer.stories.tsx +263 -0
- package/src/stories/Components/GraphRenderer.stories.tsx +3236 -0
- package/src/stories/Components/MultiCanvasRenderer.stories.tsx +370 -0
- package/src/stories/Components/SequenceDiagram.stories.tsx +255 -0
- package/src/stories/Components/StateView.stories.tsx +417 -0
- package/src/stories/Components/TraceViewer.stories.tsx +442 -0
- package/src/stories/Components/WorkflowSequenceDiagram.stories.tsx +802 -0
- package/src/stories/Features/AnimationWorkshop.stories.tsx +727 -0
- package/src/stories/Features/ChangeTypeVisual.stories.tsx +67 -0
- package/src/stories/Features/EventDrivenAnimations.stories.tsx +513 -0
- package/src/stories/Features/MultiConfig.stories.tsx +539 -0
- package/src/stories/Introduction.mdx +34 -0
- package/src/stories/Layout/ElkEdgeRouting.stories.tsx +539 -0
- package/src/stories/Layout/GraphOrientation.stories.tsx +500 -0
- package/src/stories/Layout/MultiDirectionalConnections.stories.tsx +352 -0
- package/src/stories/Nodes/NodeDefinitionComparison.stories.tsx +560 -0
- package/src/stories/Nodes/NodeNameFallbacks.stories.tsx +491 -0
- package/src/stories/Nodes/NumericColors.stories.tsx +440 -0
- package/src/stories/OTEL/EventNameDisplay.stories.tsx +694 -0
- package/src/stories/OTEL/EventNameFallback.stories.tsx +578 -0
- package/src/stories/OTEL/OtelComponents.stories.tsx +422 -0
- package/src/stories/OTEL/OtelNodeTypesPrototype.stories.tsx +806 -0
- package/src/stories/OTEL/RawEventCards.stories.tsx +57 -0
- package/src/stories/OTEL/SpanBadges.stories.tsx +840 -0
- package/src/stories/OTEL/ValidationEventsCanvas.stories.tsx +209 -0
- package/src/stories/Pierre/CodeView.stories.tsx +219 -0
- package/src/stories/RealWorld/BacklogMdCanvases.stories.tsx +721 -0
- package/src/stories/RealWorld/FileCitySequence.stories.tsx +516 -0
- package/src/stories/RealWorld/RealCanvasFiles.stories.tsx +336 -0
- package/src/stories/Subsystem/ComponentDeclarationAudit.stories.tsx +321 -0
- package/src/stories/Subsystem/ComponentGraph/Appearance.stories.tsx +365 -0
- package/src/stories/Subsystem/ComponentGraph/Basics.stories.tsx +137 -0
- package/src/stories/Subsystem/ComponentGraph/Captures.stories.tsx +238 -0
- package/src/stories/Subsystem/ComponentGraph/DetailPanel.stories.tsx +315 -0
- package/src/stories/Subsystem/ComponentGraph/Flows.stories.tsx +239 -0
- package/src/stories/Subsystem/ComponentGraph/FrameworkStereotype.stories.tsx +216 -0
- package/src/stories/Subsystem/ComponentGraph/GraphTitle.stories.tsx +70 -0
- package/src/stories/Subsystem/ComponentGraph/Processes.stories.tsx +68 -0
- package/src/stories/Subsystem/ComponentGraph/Scenarios.stories.tsx +959 -0
- package/src/stories/Subsystem/ComponentGraph/Spotlights.stories.tsx +681 -0
- package/src/stories/Subsystem/ComponentGraph/fixtures.ts +129 -0
- package/src/stories/__traces__/test-run.canvas.json +241 -0
- package/src/stories/data/activity-feed-analytics.dashboard.json +300 -0
- package/src/stories/data/file-city-images-transformed.otel.canvas.json +295 -0
- package/src/stories/data/file-city-workflows.json +269 -0
- package/src/stories/data/graph-converter-test-execution.json +443 -0
- package/src/stories/data/graph-converter-test.workflow.json +105 -0
- package/src/stories/data/graph-converter-validated-execution.json +58 -0
- package/src/stories/data/opencode-session-raw-events.json +273396 -0
- package/src/subsystem/ComponentDeclaration.tsx +643 -0
- package/src/subsystem/FileDrawer.tsx +106 -0
- package/src/subsystem/GraphLayoutCover.tsx +69 -0
- package/src/subsystem/SubsystemComponentGraph.tsx +1644 -0
- package/src/subsystem/SubsystemFileTree.tsx +190 -0
- package/src/subsystem/declarationRef.test.ts +33 -0
- package/src/subsystem/declarationRef.ts +63 -0
- package/src/subsystem/formatDeclaration.ts +174 -0
- package/src/subsystem/model.test.ts +244 -0
- package/src/subsystem/model.ts +850 -0
- package/src/subsystem/nodes.test.ts +56 -0
- package/src/subsystem/nodes.tsx +443 -0
- package/src/subsystem/paths.test.ts +123 -0
- package/src/subsystem/paths.ts +127 -0
- package/src/subsystem/tokenizeComponent.ts +70 -0
- package/src/subsystem/tokenizeFormatted.ts +19 -0
- package/src/utils/animationMapping.ts +166 -0
- package/src/utils/canvasBounds.ts +146 -0
- package/src/utils/elkLayout.test.ts +240 -0
- package/src/utils/elkLayout.ts +779 -0
- package/src/utils/graphConverter.ts +148 -0
- package/src/utils/iconResolver.tsx +53 -0
- package/src/utils/orientationUtils.ts +73 -0
|
@@ -0,0 +1,1059 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* SubsystemComponentGraph — a clickable, read-only React Flow component graph
|
|
4
|
+
* for a subsystem snapshot.
|
|
5
|
+
*
|
|
6
|
+
* Nodes are positioned with ELK auto-layout (layered, minimized crossings,
|
|
7
|
+
* process-aware compound groups). Components sharing a `process` render
|
|
8
|
+
* inside one labeled boundary frame; nodes without one sit outside every
|
|
9
|
+
* boundary. Clicking a component invokes `onSelect`.
|
|
10
|
+
*
|
|
11
|
+
* This is a focused fork of the package's `GraphRenderer` pipeline (same ELK
|
|
12
|
+
* edge routing, delayed fitView, Background/Controls/MiniMap, node/edge type
|
|
13
|
+
* injection, onNodeClick) adapted to the subsystem model — read-only.
|
|
14
|
+
*/
|
|
15
|
+
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
16
|
+
import { ReactFlow, ReactFlowProvider, Background, BackgroundVariant, Controls, useReactFlow, useViewport, applyNodeChanges, } from '@xyflow/react';
|
|
17
|
+
import { useTheme } from '@principal-ade/industry-theme';
|
|
18
|
+
import { ChevronDown, ChevronUp, X } from 'lucide-react';
|
|
19
|
+
import { IndustryMarkdownSlide } from 'themed-markdown';
|
|
20
|
+
import { buildSubsystemGraph, MECHANISM_COLOR, MECHANISM_DESCRIPTIONS, subsystemGraphLayoutKey, } from './model';
|
|
21
|
+
import { SubsystemComponentNode, SubsystemGroupNode, SubsystemEdge, SUBSYSTEM_CALLBACKS, hexWithAlpha, EDGE_DIM_ALPHA, fileMatchForNode, flowElementVisibility } from './nodes';
|
|
22
|
+
import { SubsystemFileTree } from './SubsystemFileTree';
|
|
23
|
+
import { GraphLayoutCover } from './GraphLayoutCover';
|
|
24
|
+
import { ComponentDeclaration } from './ComponentDeclaration';
|
|
25
|
+
import { FileDrawer } from './FileDrawer';
|
|
26
|
+
import { buildRepoGroups, repoAvatarUrl } from './paths';
|
|
27
|
+
/** Cap screen-space edge labels to this fraction of the edge's on-screen length. */
|
|
28
|
+
const EDGE_LABEL_MAX_EDGE_FRACTION = 0.55;
|
|
29
|
+
/** Rough monospace width at fontSize 10 + horizontal padding/border. */
|
|
30
|
+
const EDGE_LABEL_CHAR_PX = 6.2;
|
|
31
|
+
const EDGE_LABEL_PAD_PX = 18;
|
|
32
|
+
const nodeTypes = {
|
|
33
|
+
'subsystem-component': SubsystemComponentNode,
|
|
34
|
+
'subsystem-group': SubsystemGroupNode,
|
|
35
|
+
};
|
|
36
|
+
const edgeTypes = {
|
|
37
|
+
'subsystem-edge': SubsystemEdge,
|
|
38
|
+
};
|
|
39
|
+
// Memoized drawer body: only rebuilds children when the open target changes.
|
|
40
|
+
// Inner re-renders on every viewport pan/zoom and hover; recreating host
|
|
41
|
+
// elements then would churn their readFile closures and flash the file
|
|
42
|
+
// viewer's loading state on each render.
|
|
43
|
+
const FileDrawerContent = memo(function FileDrawerContent({ render, file, startLine, }) {
|
|
44
|
+
return _jsx(_Fragment, { children: render(file, startLine != null ? { startLine } : undefined) });
|
|
45
|
+
});
|
|
46
|
+
const ThroughlineDrawerContent = memo(function ThroughlineDrawerContent({ render, throughline, stepIndex, }) {
|
|
47
|
+
return _jsx(_Fragment, { children: render({ throughline, stepIndex }) });
|
|
48
|
+
});
|
|
49
|
+
function Inner({ components, edges, throughlines, onSelect, onEdgeSelect, measured: _measured, maxNodeWidth, showEdgeLabels, title, hideSidebar, graphTitle, description, canvasOverlay, sidebarExtra, sidebarAfterDescription, renderFileView, renderFileViewer, renderThroughlineViewer, onFileSelect, onVerifyComponent, componentVerification }) {
|
|
50
|
+
const { theme } = useTheme();
|
|
51
|
+
const { fitView } = useReactFlow();
|
|
52
|
+
const viewport = useViewport();
|
|
53
|
+
const [built, setBuilt] = useState({
|
|
54
|
+
nodes: [],
|
|
55
|
+
edges: [],
|
|
56
|
+
});
|
|
57
|
+
const [layoutReady, setLayoutReady] = useState(false);
|
|
58
|
+
const [selected, setSelected] = useState(null);
|
|
59
|
+
/** Bottom drawer: single file or throughline multi-snippet mode. */
|
|
60
|
+
const [drawerTarget, setDrawerTarget] = useState(null);
|
|
61
|
+
// Component the pointer is over (null on leave) → transient tree highlight.
|
|
62
|
+
const [hoveredComponentId, setHoveredComponentId] = useState(null);
|
|
63
|
+
// Throughline focus — selected flow (or step) is full strength; other
|
|
64
|
+
// opened-flow members stay visible but dimmed; everything else is hidden.
|
|
65
|
+
const [focusedThroughlineId, setFocusedThroughlineId] = useState(null);
|
|
66
|
+
// `null` = whole flow focused; a number = that single step's edge focused.
|
|
67
|
+
const [focusedStepIndex, setFocusedStepIndex] = useState(null);
|
|
68
|
+
// Sidebar bottom half: which panel is shown when throughlines exist.
|
|
69
|
+
const [sidebarView, setSidebarView] = useState(() => throughlines?.length ? 'flows' : 'files');
|
|
70
|
+
// Throughline flows the user has expanded (via the title row). Closed by
|
|
71
|
+
// default so a graph with several flows doesn't dump every step list at once.
|
|
72
|
+
const [expandedThroughlines, setExpandedThroughlines] = useState(new Set());
|
|
73
|
+
// Sidebar description visibility. Hidden by default so the files/flows
|
|
74
|
+
// panel gets the vertical room; the title-row toggle reveals it.
|
|
75
|
+
const [descriptionVisible, setDescriptionVisible] = useState(false);
|
|
76
|
+
const [descToggleHover, setDescToggleHover] = useState(false);
|
|
77
|
+
// `true` only when a description exists AND the user opened it.
|
|
78
|
+
const showDesc = !!description && descriptionVisible;
|
|
79
|
+
// Ref mirror of `selected` so the SUBSYSTEM_CALLBACKS click handler (a
|
|
80
|
+
// closure over the effect deps) can toggle without a stale value.
|
|
81
|
+
const selectedRef = useRef(null);
|
|
82
|
+
selectedRef.current = selected;
|
|
83
|
+
// Ref mirror of the open file drawer target for tree-click toggle.
|
|
84
|
+
const openFileRef = useRef(null);
|
|
85
|
+
const openFile = drawerTarget?.kind === 'file' ? drawerTarget.file : null;
|
|
86
|
+
openFileRef.current =
|
|
87
|
+
drawerTarget?.kind === 'file'
|
|
88
|
+
? { file: drawerTarget.file, startLine: drawerTarget.startLine }
|
|
89
|
+
: null;
|
|
90
|
+
const focusedThroughline = useMemo(() => {
|
|
91
|
+
if (drawerTarget?.kind !== 'throughline' || !throughlines)
|
|
92
|
+
return null;
|
|
93
|
+
return throughlines.find((t) => t.id === drawerTarget.throughlineId) ?? null;
|
|
94
|
+
}, [drawerTarget, throughlines]);
|
|
95
|
+
const drawerTitle = useMemo(() => {
|
|
96
|
+
if (!drawerTarget)
|
|
97
|
+
return null;
|
|
98
|
+
if (drawerTarget.kind === 'file')
|
|
99
|
+
return drawerTarget.file;
|
|
100
|
+
const tl = focusedThroughline;
|
|
101
|
+
if (!tl)
|
|
102
|
+
return null;
|
|
103
|
+
if (drawerTarget.stepIndex == null)
|
|
104
|
+
return tl.title;
|
|
105
|
+
const step = tl.steps[drawerTarget.stepIndex];
|
|
106
|
+
if (!step)
|
|
107
|
+
return tl.title;
|
|
108
|
+
const site = `${step.file.split('/').pop() ?? step.file}:${step.line}`;
|
|
109
|
+
return `${tl.title} · ${site}`;
|
|
110
|
+
}, [drawerTarget, focusedThroughline]);
|
|
111
|
+
// Refresh selected component when the components list updates (e.g. verify
|
|
112
|
+
// writes back declarationRef).
|
|
113
|
+
useEffect(() => {
|
|
114
|
+
if (!selected)
|
|
115
|
+
return;
|
|
116
|
+
const fresh = components.find((c) => c.id === selected.id);
|
|
117
|
+
if (fresh && fresh !== selected)
|
|
118
|
+
setSelected(fresh);
|
|
119
|
+
}, [components, selected]);
|
|
120
|
+
// Pass 1: build with estimated widths so React Flow can measure the DOM.
|
|
121
|
+
// The pane stays hidden until Pass 2 completes. Key off layout-affecting
|
|
122
|
+
// fields only — declarationRef updates after verify must not re-run ELK.
|
|
123
|
+
const layoutKey = useMemo(() => subsystemGraphLayoutKey({ components, edges }), [components, edges]);
|
|
124
|
+
const componentsRef = useRef(components);
|
|
125
|
+
const edgesRef = useRef(edges);
|
|
126
|
+
componentsRef.current = components;
|
|
127
|
+
edgesRef.current = edges;
|
|
128
|
+
useEffect(() => {
|
|
129
|
+
let alive = true;
|
|
130
|
+
pass2DoneRef.current = false;
|
|
131
|
+
measuredDimsRef.current = new Map();
|
|
132
|
+
prevMeasuredSigRef.current = '';
|
|
133
|
+
const doc = { components: componentsRef.current, edges: edgesRef.current };
|
|
134
|
+
void buildSubsystemGraph(doc, { maxNodeWidth, showEdgeLabels })
|
|
135
|
+
.then(({ nodes, edges: e }) => {
|
|
136
|
+
if (!alive)
|
|
137
|
+
return;
|
|
138
|
+
setBuilt({ nodes, edges: e });
|
|
139
|
+
setLayoutReady(false);
|
|
140
|
+
})
|
|
141
|
+
.catch((err) => {
|
|
142
|
+
console.warn('[subsystem-graph] initial layout failed:', err);
|
|
143
|
+
if (!alive)
|
|
144
|
+
return;
|
|
145
|
+
// Reveal the cover even on failure so the UI is not stuck forever.
|
|
146
|
+
setBuilt({ nodes: [], edges: [] });
|
|
147
|
+
setLayoutReady(true);
|
|
148
|
+
});
|
|
149
|
+
return () => { alive = false; };
|
|
150
|
+
}, [layoutKey, maxNodeWidth, showEdgeLabels]);
|
|
151
|
+
// Track measured dimensions from React Flow's dimension changes.
|
|
152
|
+
// These arrive as { type: 'dimensions', id, dimensions } in onNodesChange.
|
|
153
|
+
const measuredDimsRef = useRef(new Map());
|
|
154
|
+
const pendingMeasuredRef = useRef(false);
|
|
155
|
+
// Pass 2: once every leaf node has a measured dimension, re-run ELK.
|
|
156
|
+
// Group parents are sized by ELK, not measured — exclude them or pass 2
|
|
157
|
+
// would wait forever for dimensions that never arrive.
|
|
158
|
+
const prevMeasuredSigRef = useRef('');
|
|
159
|
+
const pass2DoneRef = useRef(false);
|
|
160
|
+
const triggerPass2 = useCallback(() => {
|
|
161
|
+
if (pass2DoneRef.current)
|
|
162
|
+
return;
|
|
163
|
+
const dims = measuredDimsRef.current;
|
|
164
|
+
const leafNodes = built.nodes.filter((n) => n.type !== 'subsystem-group');
|
|
165
|
+
if (dims.size < leafNodes.length)
|
|
166
|
+
return;
|
|
167
|
+
const sig = leafNodes.map((n) => `${n.id}:${dims.get(n.id)?.width ?? '?'}`).join(',');
|
|
168
|
+
if (sig.includes('?:'))
|
|
169
|
+
return;
|
|
170
|
+
if (sig === prevMeasuredSigRef.current)
|
|
171
|
+
return;
|
|
172
|
+
prevMeasuredSigRef.current = sig;
|
|
173
|
+
pendingMeasuredRef.current = false;
|
|
174
|
+
pass2DoneRef.current = true;
|
|
175
|
+
const measuredWidths = new Map(leafNodes.map((n) => [n.id, dims.get(n.id).width]));
|
|
176
|
+
const measuredHeights = new Map(leafNodes.map((n) => [n.id, dims.get(n.id).height]));
|
|
177
|
+
let alive = true;
|
|
178
|
+
void buildSubsystemGraph({ components, edges }, { maxNodeWidth, showEdgeLabels, measuredWidths, measuredHeights }).then(({ nodes, edges: e }) => {
|
|
179
|
+
if (!alive)
|
|
180
|
+
return;
|
|
181
|
+
setBuilt({ nodes, edges: e });
|
|
182
|
+
setLayoutReady(true);
|
|
183
|
+
});
|
|
184
|
+
return () => { alive = false; };
|
|
185
|
+
}, [built.nodes, components, edges, maxNodeWidth, showEdgeLabels]);
|
|
186
|
+
// Node components call SUBSYSTEM_CALLBACKS.onSelect on click (their inner
|
|
187
|
+
// onClick stops React Flow propagation), so wire selection + width through it.
|
|
188
|
+
// Lookup from edge id → the authored SubsystemComponentEdge (for onEdgeSelect).
|
|
189
|
+
const edgeById = useMemo(() => new Map(edges.map((e) => [e.id, e])), [edges]);
|
|
190
|
+
// Shared edge-selection logic used by both React Flow's onEdgeClick and the
|
|
191
|
+
// clickable edge label (SUBSYSTEM_CALLBACKS.onEdgeSelect).
|
|
192
|
+
const selectEdge = useCallback((edgeId) => {
|
|
193
|
+
if (selectedEdgeIdRef.current === edgeId) {
|
|
194
|
+
setSelectedEdgeId(null);
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
const src = edgeById.get(edgeId);
|
|
198
|
+
setSelectedEdgeId(edgeId);
|
|
199
|
+
// A direct edge selection on the canvas supersedes any throughline focus.
|
|
200
|
+
setFocusedThroughlineId(null);
|
|
201
|
+
setFocusedStepIndex(null);
|
|
202
|
+
if (src)
|
|
203
|
+
onEdgeSelect?.(src);
|
|
204
|
+
}, [edgeById, onEdgeSelect]);
|
|
205
|
+
useEffect(() => {
|
|
206
|
+
SUBSYSTEM_CALLBACKS.onSelect = (id) => {
|
|
207
|
+
const comp = components.find((c) => c.id === id);
|
|
208
|
+
if (comp) {
|
|
209
|
+
// Clicking the already-selected node unselects it (toggle off).
|
|
210
|
+
// Selection is independent of the file drawer — nodes never open it.
|
|
211
|
+
if (selectedRef.current?.id === comp.id) {
|
|
212
|
+
setSelected(null);
|
|
213
|
+
setSelectedEdgeId(null);
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
setSelected(comp);
|
|
217
|
+
setSelectedEdgeId(null);
|
|
218
|
+
setFocusedThroughlineId(null);
|
|
219
|
+
setFocusedStepIndex(null);
|
|
220
|
+
onSelect?.(id);
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
SUBSYSTEM_CALLBACKS.onEdgeSelect = selectEdge;
|
|
224
|
+
SUBSYSTEM_CALLBACKS.maxNodeWidth = maxNodeWidth;
|
|
225
|
+
SUBSYSTEM_CALLBACKS.onHover = setHoveredComponentId;
|
|
226
|
+
return () => {
|
|
227
|
+
SUBSYSTEM_CALLBACKS.onSelect = undefined;
|
|
228
|
+
SUBSYSTEM_CALLBACKS.onEdgeSelect = undefined;
|
|
229
|
+
SUBSYSTEM_CALLBACKS.maxNodeWidth = undefined;
|
|
230
|
+
SUBSYSTEM_CALLBACKS.onHover = undefined;
|
|
231
|
+
};
|
|
232
|
+
}, [components, onSelect, maxNodeWidth, selectEdge]);
|
|
233
|
+
const { nodes, edges: convertedEdges } = built;
|
|
234
|
+
const xyflowNodesBase = nodes;
|
|
235
|
+
const baseEdges = convertedEdges;
|
|
236
|
+
// When an edge is selected, dim every other edge + its label to focus it.
|
|
237
|
+
const [selectedEdgeId, setSelectedEdgeId] = useState(null);
|
|
238
|
+
// Ref mirror so `selectEdge` (a useCallback over early deps) can toggle
|
|
239
|
+
// without a stale closure value.
|
|
240
|
+
const selectedEdgeIdRef = useRef(null);
|
|
241
|
+
selectedEdgeIdRef.current = selectedEdgeId;
|
|
242
|
+
// Edge ids in throughline focus (an active flow's edge set, or a single
|
|
243
|
+
// step's edge). Used to frame the camera. `null` = no throughline focus.
|
|
244
|
+
const focusEdgeIds = useMemo(() => {
|
|
245
|
+
if (focusedThroughlineId == null || !throughlines)
|
|
246
|
+
return null;
|
|
247
|
+
const tl = throughlines.find((t) => t.id === focusedThroughlineId);
|
|
248
|
+
if (!tl)
|
|
249
|
+
return null;
|
|
250
|
+
if (focusedStepIndex != null) {
|
|
251
|
+
const step = tl.steps[focusedStepIndex];
|
|
252
|
+
return step ? new Set([step.edgeId]) : null;
|
|
253
|
+
}
|
|
254
|
+
return new Set(tl.steps.map((s) => s.edgeId));
|
|
255
|
+
}, [throughlines, focusedThroughlineId, focusedStepIndex]);
|
|
256
|
+
// 1-based step numbers per edge of the selected flow (an edge can appear
|
|
257
|
+
// in more than one step).
|
|
258
|
+
const selectedFlowStepNos = useMemo(() => {
|
|
259
|
+
if (focusedThroughlineId == null || !throughlines)
|
|
260
|
+
return null;
|
|
261
|
+
const tl = throughlines.find((t) => t.id === focusedThroughlineId);
|
|
262
|
+
if (!tl)
|
|
263
|
+
return null;
|
|
264
|
+
const map = new Map();
|
|
265
|
+
tl.steps.forEach((s, i) => {
|
|
266
|
+
const list = map.get(s.edgeId) ?? [];
|
|
267
|
+
list.push(i + 1);
|
|
268
|
+
map.set(s.edgeId, list);
|
|
269
|
+
});
|
|
270
|
+
return map;
|
|
271
|
+
}, [throughlines, focusedThroughlineId]);
|
|
272
|
+
// Union of every expanded (opened) throughline's edges — the visible set.
|
|
273
|
+
const openedEdgeIds = useMemo(() => {
|
|
274
|
+
if (!throughlines || expandedThroughlines.size === 0)
|
|
275
|
+
return null;
|
|
276
|
+
const ids = new Set();
|
|
277
|
+
for (const tl of throughlines) {
|
|
278
|
+
if (!expandedThroughlines.has(tl.id))
|
|
279
|
+
continue;
|
|
280
|
+
for (const s of tl.steps)
|
|
281
|
+
ids.add(s.edgeId);
|
|
282
|
+
}
|
|
283
|
+
return ids.size > 0 ? ids : null;
|
|
284
|
+
}, [throughlines, expandedThroughlines]);
|
|
285
|
+
const endpointsOf = (edgeIds) => {
|
|
286
|
+
if (!edgeIds)
|
|
287
|
+
return null;
|
|
288
|
+
const ids = new Set();
|
|
289
|
+
for (const e of baseEdges) {
|
|
290
|
+
if (!edgeIds.has(e.id))
|
|
291
|
+
continue;
|
|
292
|
+
ids.add(e.source);
|
|
293
|
+
ids.add(e.target);
|
|
294
|
+
}
|
|
295
|
+
return ids.size > 0 ? ids : null;
|
|
296
|
+
};
|
|
297
|
+
const openedNodeIds = useMemo(() => endpointsOf(openedEdgeIds),
|
|
298
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
299
|
+
[baseEdges, openedEdgeIds]);
|
|
300
|
+
// Endpoints of the bright set: the selected step's edge, or the whole flow
|
|
301
|
+
// when no step is focused.
|
|
302
|
+
const brightNodeIds = useMemo(() => endpointsOf(focusEdgeIds),
|
|
303
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
304
|
+
[baseEdges, focusEdgeIds]);
|
|
305
|
+
// Source + target of the focused step/flow (or a canvas-selected edge). If a
|
|
306
|
+
// file is open, those endpoints stay undimmed even when they don't live in
|
|
307
|
+
// that file.
|
|
308
|
+
const focusNodeIds = useMemo(() => {
|
|
309
|
+
if (brightNodeIds)
|
|
310
|
+
return brightNodeIds;
|
|
311
|
+
if (selectedEdgeId) {
|
|
312
|
+
const e = baseEdges.find((x) => x.id === selectedEdgeId);
|
|
313
|
+
if (e)
|
|
314
|
+
return new Set([e.source, e.target]);
|
|
315
|
+
}
|
|
316
|
+
return null;
|
|
317
|
+
}, [baseEdges, brightNodeIds, selectedEdgeId]);
|
|
318
|
+
// While a file is open in the drawer, tag each node with whether its
|
|
319
|
+
// component lives in that file — the node renderer spotlights matches and
|
|
320
|
+
// dims non-matches (mirrors the edge-dimming behavior on selection).
|
|
321
|
+
// Opened-but-unselected members are dimmed; a selected step further dims
|
|
322
|
+
// the rest of its own flow. Nodes not on any opened flow are hidden.
|
|
323
|
+
// `isSelected` rides in data because the node's stopPropagation() keeps
|
|
324
|
+
// React Flow's own selection state from updating.
|
|
325
|
+
const dispNodes = useMemo(() => {
|
|
326
|
+
return xyflowNodesBase.map((n) => {
|
|
327
|
+
// Boundary frames follow their members: hidden when no member is
|
|
328
|
+
// visible, dimmed when members are dimmed. Never selectable.
|
|
329
|
+
if (n.type === 'subsystem-group') {
|
|
330
|
+
const memberIds = (n.data?.region?.memberIds) ?? [];
|
|
331
|
+
const vis = flowElementVisibility({
|
|
332
|
+
inOpened: memberIds.some((id) => openedNodeIds?.has(id) === true),
|
|
333
|
+
inSelected: memberIds.some((id) => brightNodeIds?.has(id) === true),
|
|
334
|
+
anyOpened: openedNodeIds != null,
|
|
335
|
+
anySelected: brightNodeIds != null,
|
|
336
|
+
});
|
|
337
|
+
return {
|
|
338
|
+
...n,
|
|
339
|
+
hidden: vis.hidden,
|
|
340
|
+
selectable: false,
|
|
341
|
+
data: {
|
|
342
|
+
...n.data,
|
|
343
|
+
...(vis.dimmed && { dimmed: true }),
|
|
344
|
+
},
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
const comp = n.data?.component;
|
|
348
|
+
const fileMatch = fileMatchForNode(comp?.file, openFile, focusNodeIds?.has(n.id) === true);
|
|
349
|
+
const isSelected = selected?.id !== undefined && comp?.id === selected.id;
|
|
350
|
+
const vis = flowElementVisibility({
|
|
351
|
+
inOpened: openedNodeIds?.has(n.id) === true,
|
|
352
|
+
inSelected: brightNodeIds?.has(n.id) === true,
|
|
353
|
+
anyOpened: openedNodeIds != null,
|
|
354
|
+
anySelected: brightNodeIds != null,
|
|
355
|
+
});
|
|
356
|
+
if (fileMatch === undefined && !isSelected && !vis.dimmed) {
|
|
357
|
+
const { fileMatch: _f, isSelected: _s, dimmed: _d, ...rest } = n.data;
|
|
358
|
+
return { ...n, hidden: vis.hidden, data: rest };
|
|
359
|
+
}
|
|
360
|
+
return {
|
|
361
|
+
...n,
|
|
362
|
+
hidden: vis.hidden,
|
|
363
|
+
data: {
|
|
364
|
+
...n.data,
|
|
365
|
+
...(fileMatch !== undefined && { fileMatch }),
|
|
366
|
+
...(isSelected && { isSelected }),
|
|
367
|
+
...(vis.dimmed && { dimmed: true }),
|
|
368
|
+
},
|
|
369
|
+
};
|
|
370
|
+
});
|
|
371
|
+
}, [xyflowNodesBase, openFile, selected, focusNodeIds, openedNodeIds, brightNodeIds]);
|
|
372
|
+
const baseNodesKey = useMemo(() => nodes.map((n) => n.id).sort().join(','), [nodes]);
|
|
373
|
+
const baseEdgesKey = useMemo(() => convertedEdges.map((e) => e.id).sort().join(','), [convertedEdges]);
|
|
374
|
+
const dispEdges = useMemo(() => {
|
|
375
|
+
const paint = (e, dimmed) => {
|
|
376
|
+
const markerEnd = e.markerEnd;
|
|
377
|
+
const nextMarker = dimmed && markerEnd && typeof markerEnd === 'object' && typeof markerEnd.color === 'string'
|
|
378
|
+
? { ...markerEnd, color: hexWithAlpha(markerEnd.color, EDGE_DIM_ALPHA) }
|
|
379
|
+
: markerEnd;
|
|
380
|
+
return {
|
|
381
|
+
...e,
|
|
382
|
+
data: { ...e.data, dimmed },
|
|
383
|
+
markerEnd: nextMarker,
|
|
384
|
+
};
|
|
385
|
+
};
|
|
386
|
+
if (openedEdgeIds || focusEdgeIds) {
|
|
387
|
+
return baseEdges.map((e) => {
|
|
388
|
+
const vis = flowElementVisibility({
|
|
389
|
+
inOpened: openedEdgeIds?.has(e.id) === true,
|
|
390
|
+
inSelected: focusEdgeIds?.has(e.id) === true,
|
|
391
|
+
anyOpened: openedEdgeIds != null,
|
|
392
|
+
anySelected: focusEdgeIds != null,
|
|
393
|
+
});
|
|
394
|
+
return { ...paint(e, vis.dimmed), hidden: vis.hidden };
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
if (!selectedEdgeId)
|
|
398
|
+
return baseEdges;
|
|
399
|
+
return baseEdges.map((e) => paint(e, e.id !== selectedEdgeId));
|
|
400
|
+
}, [baseEdges, selectedEdgeId, openedEdgeIds, focusEdgeIds]);
|
|
401
|
+
const onNodesChange = useCallback((changes) => {
|
|
402
|
+
// Capture dimension changes (React Flow's measurement callback).
|
|
403
|
+
// Group parents are ELK-sized — ignore their measurements.
|
|
404
|
+
const groupIds = new Set(dispNodes.filter((n) => n.type === 'subsystem-group').map((n) => n.id));
|
|
405
|
+
for (const ch of changes) {
|
|
406
|
+
if (ch.type === 'dimensions' && ch.dimensions && !groupIds.has(ch.id)) {
|
|
407
|
+
measuredDimsRef.current.set(ch.id, ch.dimensions);
|
|
408
|
+
pendingMeasuredRef.current = true;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
const result = applyNodeChanges(changes, dispNodes);
|
|
412
|
+
// After applying changes, check if we should trigger pass 2.
|
|
413
|
+
if (pendingMeasuredRef.current) {
|
|
414
|
+
// Use microtask so the state update from applyNodeChanges commits first.
|
|
415
|
+
queueMicrotask(() => triggerPass2());
|
|
416
|
+
}
|
|
417
|
+
return result;
|
|
418
|
+
}, [dispNodes, triggerPass2]);
|
|
419
|
+
const onEdgesChange = useCallback((_changes) => dispEdges, [dispEdges]);
|
|
420
|
+
useEffect(() => {
|
|
421
|
+
const t = setTimeout(() => {
|
|
422
|
+
fitView({ padding: 0.1, includeHiddenNodes: false, minZoom: 0.05, maxZoom: 2, duration: 200 });
|
|
423
|
+
}, 200);
|
|
424
|
+
return () => clearTimeout(t);
|
|
425
|
+
}, [baseNodesKey, baseEdgesKey, fitView]);
|
|
426
|
+
// When the file drawer opens or closes the canvas is resized but the
|
|
427
|
+
// camera stays put — no refit/zoom. Spotlight + dimming already convey
|
|
428
|
+
// which nodes belong to the open file.
|
|
429
|
+
const onNodeClick = useCallback((_e, node) => {
|
|
430
|
+
const comp = node.data?.component;
|
|
431
|
+
setSelectedEdgeId(null);
|
|
432
|
+
setFocusedThroughlineId(null);
|
|
433
|
+
setFocusedStepIndex(null);
|
|
434
|
+
if (node.type === 'subsystem-component' && comp) {
|
|
435
|
+
// Clicking the already-selected node unselects it (toggle off).
|
|
436
|
+
// Selection is independent of the file drawer — nodes never open it.
|
|
437
|
+
if (selected?.id === comp.id) {
|
|
438
|
+
setSelected(null);
|
|
439
|
+
return;
|
|
440
|
+
}
|
|
441
|
+
setSelected(comp);
|
|
442
|
+
if (comp.id)
|
|
443
|
+
onSelect?.(comp.id);
|
|
444
|
+
}
|
|
445
|
+
}, [onSelect, selected]);
|
|
446
|
+
// React Flow's edge click → the same shared selection logic as the label.
|
|
447
|
+
const onEdgeClick = useCallback((_e, edge) => {
|
|
448
|
+
selectEdge(edge.id);
|
|
449
|
+
}, [selectEdge]);
|
|
450
|
+
const onPaneClick = useCallback(() => {
|
|
451
|
+
setSelected(null);
|
|
452
|
+
setSelectedEdgeId(null);
|
|
453
|
+
setFocusedThroughlineId(null);
|
|
454
|
+
setFocusedStepIndex(null);
|
|
455
|
+
}, []);
|
|
456
|
+
// Sidebar file trees — one per repo on multi-repo graphs, each under its
|
|
457
|
+
// own owner-avatar header. Clicking a header collapses that repo's tree.
|
|
458
|
+
const repoGroups = useMemo(() => buildRepoGroups(components), [components]);
|
|
459
|
+
const hasThroughlines = useMemo(() => (throughlines?.length ?? 0) > 0, [throughlines]);
|
|
460
|
+
const [collapsedRepos, setCollapsedRepos] = useState(new Set());
|
|
461
|
+
const toggleRepoCollapsed = useCallback((key) => {
|
|
462
|
+
setCollapsedRepos((prev) => {
|
|
463
|
+
const next = new Set(prev);
|
|
464
|
+
if (next.has(key))
|
|
465
|
+
next.delete(key);
|
|
466
|
+
else
|
|
467
|
+
next.add(key);
|
|
468
|
+
return next;
|
|
469
|
+
});
|
|
470
|
+
}, []);
|
|
471
|
+
const treeFiles = useMemo(() => repoGroups.groups.flatMap((g) => g.entries.map((e) => e.file)), [repoGroups]);
|
|
472
|
+
const onTreeSelectFile = useCallback((file) => {
|
|
473
|
+
if (openFileRef.current?.file === file && openFileRef.current.startLine == null) {
|
|
474
|
+
setDrawerTarget(null);
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
setDrawerTarget({ kind: 'file', file });
|
|
478
|
+
onFileSelect?.(file);
|
|
479
|
+
}, [onFileSelect]);
|
|
480
|
+
const onOpenDeclarationFile = useCallback((file, opts) => {
|
|
481
|
+
const startLine = opts?.startLine;
|
|
482
|
+
if (openFileRef.current?.file === file &&
|
|
483
|
+
openFileRef.current.startLine === startLine) {
|
|
484
|
+
setDrawerTarget(null);
|
|
485
|
+
return;
|
|
486
|
+
}
|
|
487
|
+
setDrawerTarget({ kind: 'file', file, startLine });
|
|
488
|
+
onFileSelect?.(file);
|
|
489
|
+
}, [onFileSelect]);
|
|
490
|
+
// Camera helper shared by the throughline interactions: frames the focused
|
|
491
|
+
// edges' endpoint nodes via `fitView({ nodes })`, which uses the store's
|
|
492
|
+
// live positions + measured dims — so the frame always includes BOTH
|
|
493
|
+
// components the edge attaches to (and therefore the edge line between them).
|
|
494
|
+
const fitFocusBounds = useCallback((ids) => {
|
|
495
|
+
const nodeIds = new Set();
|
|
496
|
+
for (const e of baseEdges) {
|
|
497
|
+
if (!ids.has(e.id))
|
|
498
|
+
continue;
|
|
499
|
+
nodeIds.add(e.source);
|
|
500
|
+
nodeIds.add(e.target);
|
|
501
|
+
}
|
|
502
|
+
if (nodeIds.size === 0)
|
|
503
|
+
return;
|
|
504
|
+
fitView({
|
|
505
|
+
nodes: [...nodeIds].map((id) => ({ id })),
|
|
506
|
+
padding: 0.25,
|
|
507
|
+
duration: 300,
|
|
508
|
+
});
|
|
509
|
+
}, [baseEdges, fitView]);
|
|
510
|
+
// Focus an entire flow: hide everything but the flow's nodes and edges, and
|
|
511
|
+
// frame the flow on the canvas. Selection state is cleared — the graph now
|
|
512
|
+
// reads as the narrative. No drawer: the code view only opens on a step
|
|
513
|
+
// click. A stale throughline drawer (from a previously focused flow's step)
|
|
514
|
+
// closes; an explicitly opened file drawer stays.
|
|
515
|
+
const focusThroughlineEdges = useCallback((tl) => {
|
|
516
|
+
setSelected(null);
|
|
517
|
+
setSelectedEdgeId(null);
|
|
518
|
+
setFocusedStepIndex(null);
|
|
519
|
+
setFocusedThroughlineId(tl.id);
|
|
520
|
+
fitFocusBounds(new Set(tl.steps.map((s) => s.edgeId)));
|
|
521
|
+
setDrawerTarget((prev) => (prev?.kind === 'throughline' ? null : prev));
|
|
522
|
+
}, [fitFocusBounds]);
|
|
523
|
+
const clearThroughlineFocus = useCallback(() => {
|
|
524
|
+
setFocusedThroughlineId(null);
|
|
525
|
+
setFocusedStepIndex(null);
|
|
526
|
+
setDrawerTarget((prev) => (prev?.kind === 'throughline' ? null : prev));
|
|
527
|
+
}, []);
|
|
528
|
+
// Focus a single step's edge on the canvas and open/scroll the throughline
|
|
529
|
+
// drawer to that step's snippet.
|
|
530
|
+
const focusThroughlineStep = useCallback((tl, stepIndex) => {
|
|
531
|
+
const step = tl.steps[stepIndex];
|
|
532
|
+
if (!step)
|
|
533
|
+
return;
|
|
534
|
+
setSelected(null);
|
|
535
|
+
setSelectedEdgeId(null);
|
|
536
|
+
setFocusedStepIndex(stepIndex);
|
|
537
|
+
setFocusedThroughlineId(tl.id);
|
|
538
|
+
fitFocusBounds(new Set([step.edgeId]));
|
|
539
|
+
if (renderThroughlineViewer) {
|
|
540
|
+
setDrawerTarget({
|
|
541
|
+
kind: 'throughline',
|
|
542
|
+
throughlineId: tl.id,
|
|
543
|
+
stepIndex,
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
else {
|
|
547
|
+
setDrawerTarget({
|
|
548
|
+
kind: 'file',
|
|
549
|
+
file: step.file,
|
|
550
|
+
startLine: step.line,
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
}, [fitFocusBounds, renderThroughlineViewer]);
|
|
554
|
+
// Arrow keys step through the focused throughline once a step is active
|
|
555
|
+
// (sidebar click or drawer open). Ignores typing targets and chords.
|
|
556
|
+
useEffect(() => {
|
|
557
|
+
if (focusedThroughlineId == null || focusedStepIndex == null || !throughlines) {
|
|
558
|
+
return;
|
|
559
|
+
}
|
|
560
|
+
const tl = throughlines.find((t) => t.id === focusedThroughlineId);
|
|
561
|
+
if (!tl || tl.steps.length === 0)
|
|
562
|
+
return;
|
|
563
|
+
const onKeyDown = (e) => {
|
|
564
|
+
const el = e.target;
|
|
565
|
+
if (el &&
|
|
566
|
+
(el.tagName === 'INPUT' ||
|
|
567
|
+
el.tagName === 'TEXTAREA' ||
|
|
568
|
+
el.tagName === 'SELECT' ||
|
|
569
|
+
el.isContentEditable)) {
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
572
|
+
if (e.metaKey || e.ctrlKey || e.altKey)
|
|
573
|
+
return;
|
|
574
|
+
let next = null;
|
|
575
|
+
if (e.key === 'ArrowDown' || e.key === 'ArrowRight') {
|
|
576
|
+
next = Math.min(tl.steps.length - 1, focusedStepIndex + 1);
|
|
577
|
+
}
|
|
578
|
+
else if (e.key === 'ArrowUp' || e.key === 'ArrowLeft') {
|
|
579
|
+
next = Math.max(0, focusedStepIndex - 1);
|
|
580
|
+
}
|
|
581
|
+
else {
|
|
582
|
+
return;
|
|
583
|
+
}
|
|
584
|
+
if (next === focusedStepIndex)
|
|
585
|
+
return;
|
|
586
|
+
e.preventDefault();
|
|
587
|
+
focusThroughlineStep(tl, next);
|
|
588
|
+
};
|
|
589
|
+
window.addEventListener('keydown', onKeyDown);
|
|
590
|
+
return () => window.removeEventListener('keydown', onKeyDown);
|
|
591
|
+
}, [
|
|
592
|
+
focusedThroughlineId,
|
|
593
|
+
focusedStepIndex,
|
|
594
|
+
throughlines,
|
|
595
|
+
focusThroughlineStep,
|
|
596
|
+
]);
|
|
597
|
+
const toggleThroughlineCollapsed = useCallback((tlId) => {
|
|
598
|
+
setExpandedThroughlines((prev) => {
|
|
599
|
+
const next = new Set(prev);
|
|
600
|
+
if (next.has(tlId))
|
|
601
|
+
next.delete(tlId);
|
|
602
|
+
else
|
|
603
|
+
next.add(tlId);
|
|
604
|
+
return next;
|
|
605
|
+
});
|
|
606
|
+
}, []);
|
|
607
|
+
// Filename-badge clicks on nodes open the drawer through the same path as
|
|
608
|
+
// the declaration panel's file link (toggle + tree sync, no start line).
|
|
609
|
+
useEffect(() => {
|
|
610
|
+
SUBSYSTEM_CALLBACKS.onOpenFile = (componentId) => {
|
|
611
|
+
const comp = components.find((c) => c.id === componentId);
|
|
612
|
+
if (comp?.file)
|
|
613
|
+
onOpenDeclarationFile(comp.file);
|
|
614
|
+
};
|
|
615
|
+
return () => {
|
|
616
|
+
SUBSYSTEM_CALLBACKS.onOpenFile = undefined;
|
|
617
|
+
};
|
|
618
|
+
}, [components, onOpenDeclarationFile]);
|
|
619
|
+
// Detail-panel links: related-name clicks select the matching component —
|
|
620
|
+
// resolved by id, name, or symbol (call labels may carry a trailing `()`).
|
|
621
|
+
const resolveRelatedComponent = useCallback((ref) => {
|
|
622
|
+
const clean = ref.replace(/\(\)$/, '');
|
|
623
|
+
const comp = components.find((c) => c.id === clean ||
|
|
624
|
+
c.name === clean ||
|
|
625
|
+
c.symbol === clean ||
|
|
626
|
+
c.symbol?.replace(/\(\)$/, '') === clean);
|
|
627
|
+
if (!comp || comp.id === selectedRef.current?.id)
|
|
628
|
+
return;
|
|
629
|
+
setSelected(comp);
|
|
630
|
+
setSelectedEdgeId(null);
|
|
631
|
+
setFocusedThroughlineId(null);
|
|
632
|
+
setFocusedStepIndex(null);
|
|
633
|
+
onSelect?.(comp.id);
|
|
634
|
+
}, [components, onSelect]);
|
|
635
|
+
// Edge label data for the overlay (rendered OUTSIDE ReactFlow so the pane
|
|
636
|
+
// doesn't intercept pointer events). Uses ELK-computed label midpoints from
|
|
637
|
+
// the actual edge path (not node-center approximations).
|
|
638
|
+
const edgeLabels = useMemo(() => {
|
|
639
|
+
return dispEdges
|
|
640
|
+
.filter((e) => !e.hidden)
|
|
641
|
+
.map((e) => {
|
|
642
|
+
const d = e.data;
|
|
643
|
+
return {
|
|
644
|
+
id: e.id,
|
|
645
|
+
mechanism: d?.mechanism ?? 'imports',
|
|
646
|
+
dimmed: d?.dimmed === true,
|
|
647
|
+
midX: d?.labelX ?? 0,
|
|
648
|
+
midY: d?.labelY ?? 0,
|
|
649
|
+
pathLength: d?.pathLength ?? 0,
|
|
650
|
+
stepNos: selectedFlowStepNos?.get(e.id),
|
|
651
|
+
};
|
|
652
|
+
});
|
|
653
|
+
}, [dispEdges, selectedFlowStepNos]);
|
|
654
|
+
// Unique source files across components → sidebar file trees.
|
|
655
|
+
const treeFilePaths = treeFiles;
|
|
656
|
+
// The hovered node's file (null when not hovering / file-less component).
|
|
657
|
+
const hoveredFile = useMemo(() => {
|
|
658
|
+
if (!hoveredComponentId)
|
|
659
|
+
return null;
|
|
660
|
+
return components.find((c) => c.id === hoveredComponentId)?.file ?? null;
|
|
661
|
+
}, [components, hoveredComponentId]);
|
|
662
|
+
// Drawer content renderer: prefer the path-keyed viewer; fall back to the
|
|
663
|
+
// legacy component-keyed one via a file → first-component lookup.
|
|
664
|
+
const fileViewer = useMemo(() => {
|
|
665
|
+
if (renderFileViewer)
|
|
666
|
+
return renderFileViewer;
|
|
667
|
+
if (renderFileView) {
|
|
668
|
+
const byFile = new Map(components.filter((c) => c.file).map((c) => [c.file, c]));
|
|
669
|
+
return (file, _opts) => {
|
|
670
|
+
const comp = byFile.get(file);
|
|
671
|
+
return comp ? renderFileView(comp) : null;
|
|
672
|
+
};
|
|
673
|
+
}
|
|
674
|
+
return renderFileViewer;
|
|
675
|
+
}, [renderFileViewer, renderFileView, components]);
|
|
676
|
+
const fileViewerRef = useRef(fileViewer);
|
|
677
|
+
fileViewerRef.current = fileViewer;
|
|
678
|
+
const renderDrawerContent = useCallback((file, opts) => fileViewerRef.current?.(file, opts) ?? null, []);
|
|
679
|
+
const throughlineViewerRef = useRef(renderThroughlineViewer);
|
|
680
|
+
throughlineViewerRef.current = renderThroughlineViewer;
|
|
681
|
+
const renderThroughlineDrawerContent = useCallback((ctx) => throughlineViewerRef.current?.(ctx) ?? null, []);
|
|
682
|
+
return (_jsxs("div", { style: { width: '100%', height: '100%', display: 'flex', flexDirection: 'row' }, children: [!hideSidebar && (title || description || sidebarExtra || sidebarAfterDescription || treeFilePaths.length > 0 || hasThroughlines) && (_jsxs("div", { style: {
|
|
683
|
+
width: 340,
|
|
684
|
+
minWidth: 340,
|
|
685
|
+
borderRight: `1px solid ${theme.colors.border}`,
|
|
686
|
+
background: theme.colors.backgroundSecondary ?? theme.colors.background,
|
|
687
|
+
display: 'flex',
|
|
688
|
+
flexDirection: 'column',
|
|
689
|
+
overflow: 'hidden',
|
|
690
|
+
}, children: [_jsxs("div", { style: {
|
|
691
|
+
flex: showDesc ? 1 : '0 0 auto',
|
|
692
|
+
minHeight: 0,
|
|
693
|
+
overflowY: 'auto',
|
|
694
|
+
padding: '16px',
|
|
695
|
+
display: 'flex',
|
|
696
|
+
flexDirection: 'column',
|
|
697
|
+
gap: 12,
|
|
698
|
+
}, children: [sidebarExtra, (title || description) && (_jsxs("div", { style: { display: 'flex', alignItems: 'flex-start', gap: 8 }, children: [title && (_jsx("h2", { style: {
|
|
699
|
+
margin: 0,
|
|
700
|
+
flex: 1,
|
|
701
|
+
minWidth: 0,
|
|
702
|
+
fontSize: theme.fontSizes[2],
|
|
703
|
+
fontWeight: 600,
|
|
704
|
+
color: theme.colors.text,
|
|
705
|
+
fontFamily: theme.fonts.monospace,
|
|
706
|
+
}, children: title })), description && (_jsx("button", { type: "button", "aria-expanded": descriptionVisible, "aria-label": descriptionVisible ? 'Hide description' : 'Show description', title: descriptionVisible ? 'Hide description' : 'Show description', onMouseEnter: () => setDescToggleHover(true), onMouseLeave: () => setDescToggleHover(false), onClick: () => setDescriptionVisible((v) => !v), style: {
|
|
707
|
+
display: 'inline-flex',
|
|
708
|
+
alignItems: 'center',
|
|
709
|
+
justifyContent: 'center',
|
|
710
|
+
flexShrink: 0,
|
|
711
|
+
width: 22,
|
|
712
|
+
height: 22,
|
|
713
|
+
padding: 0,
|
|
714
|
+
border: 'none',
|
|
715
|
+
borderRadius: 4,
|
|
716
|
+
background: descToggleHover ? theme.colors.border : 'transparent',
|
|
717
|
+
color: descToggleHover ? theme.colors.text : (theme.colors.textMuted ?? theme.colors.textSecondary),
|
|
718
|
+
cursor: 'pointer',
|
|
719
|
+
transition: 'background 120ms ease, color 120ms ease',
|
|
720
|
+
}, children: descriptionVisible ? _jsx(ChevronUp, { size: 14 }) : _jsx(ChevronDown, { size: 14 }) }))] })), description && descriptionVisible && (_jsx("div", { style: { fontSize: theme.fontSizes[0], lineHeight: 1.5 }, children: _jsx(IndustryMarkdownSlide, { content: description, slideIdPrefix: "subsystem-desc", slideIndex: 0, isVisible: true, theme: theme, disableScroll: true, fontSizeScale: 0.9, enableKeyboardScrolling: false, autoFocusOnVisible: false }) })), sidebarAfterDescription] }), (treeFilePaths.length > 0 || hasThroughlines) && (_jsxs("div", { style: {
|
|
721
|
+
...(showDesc ? { height: '50%' } : { flex: 1, minHeight: 0 }),
|
|
722
|
+
minHeight: 160,
|
|
723
|
+
flexShrink: 0,
|
|
724
|
+
borderTop: `1px solid ${theme.colors.border}`,
|
|
725
|
+
display: 'flex',
|
|
726
|
+
flexDirection: 'column',
|
|
727
|
+
overflow: 'hidden',
|
|
728
|
+
}, children: [hasThroughlines && (_jsx("div", { role: "tablist", "aria-label": "Sidebar view", style: {
|
|
729
|
+
display: 'flex',
|
|
730
|
+
width: '100%',
|
|
731
|
+
flexShrink: 0,
|
|
732
|
+
borderBottom: `1px solid ${theme.colors.border}`,
|
|
733
|
+
background: theme.colors.backgroundSecondary ?? theme.colors.background,
|
|
734
|
+
}, children: ['flows', 'files'].map((view) => (_jsx("button", { type: "button", role: "tab", "aria-selected": sidebarView === view, onClick: () => setSidebarView(view), style: {
|
|
735
|
+
flex: 1,
|
|
736
|
+
minWidth: 0,
|
|
737
|
+
padding: '8px 8px',
|
|
738
|
+
border: 'none',
|
|
739
|
+
borderRadius: 0,
|
|
740
|
+
background: sidebarView === view ? theme.colors.background : 'transparent',
|
|
741
|
+
color: sidebarView === view
|
|
742
|
+
? theme.colors.text
|
|
743
|
+
: theme.colors.textSecondary,
|
|
744
|
+
fontSize: theme.fontSizes[1],
|
|
745
|
+
fontFamily: theme.fonts.monospace,
|
|
746
|
+
textTransform: 'capitalize',
|
|
747
|
+
cursor: 'pointer',
|
|
748
|
+
}, children: view }, view))) })), sidebarView === 'flows' && throughlines && throughlines.length > 0 ? (_jsx("div", { style: {
|
|
749
|
+
flex: 1,
|
|
750
|
+
minHeight: 0,
|
|
751
|
+
overflowY: 'auto',
|
|
752
|
+
padding: '0 4px 12px',
|
|
753
|
+
}, children: throughlines.map((tl) => (_jsx(ThroughlineFlow, { throughline: tl, edges: edges, collapsed: !expandedThroughlines.has(tl.id), active: focusedThroughlineId === tl.id ? { stepIndex: focusedStepIndex } : null, onToggleCollapsed: toggleThroughlineCollapsed, onFocusFlow: focusThroughlineEdges, onClearFocus: clearThroughlineFocus, onFocusStep: focusThroughlineStep }, tl.id))) })) : treeFilePaths.length > 0 ? (_jsx(_Fragment, { children: repoGroups.groups.map((group, i) => {
|
|
754
|
+
const groupKey = group.repoKey ?? '__no-repo__';
|
|
755
|
+
const collapsed = collapsedRepos.has(groupKey);
|
|
756
|
+
return (_jsxs("div", { style: {
|
|
757
|
+
flex: collapsed ? '0 0 auto' : 1,
|
|
758
|
+
minHeight: collapsed ? 0 : undefined,
|
|
759
|
+
display: 'flex',
|
|
760
|
+
flexDirection: 'column',
|
|
761
|
+
borderTop: i > 0 ? `1px solid ${theme.colors.border}` : undefined,
|
|
762
|
+
}, children: [repoGroups.multiRepo && (_jsx(RepoGroupHeader, { group: group, collapsed: collapsed, onToggle: () => toggleRepoCollapsed(groupKey) })), !collapsed && (_jsx(SubsystemFileTree, { files: group.entries.map((e) => e.displayPath), selectedFile: selected?.file ?? openFile, hoveredFile: hoveredFile, onSelectFile: onTreeSelectFile, headerless: repoGroups.multiRepo }))] }, groupKey));
|
|
763
|
+
}) })) : null] }))] })), _jsxs("div", { style: { flex: 1, position: 'relative', display: 'flex', flexDirection: 'column', minHeight: 0 }, children: [_jsxs("div", { style: { position: 'relative', flex: 1, minHeight: 0, display: 'flex', flexDirection: 'column' }, children: [showEdgeLabels !== false && (_jsx("div", { style: {
|
|
764
|
+
position: 'absolute',
|
|
765
|
+
inset: 0,
|
|
766
|
+
overflow: 'hidden',
|
|
767
|
+
pointerEvents: 'none',
|
|
768
|
+
zIndex: 5,
|
|
769
|
+
}, children: edgeLabels.map((lbl) => {
|
|
770
|
+
const mechanism = lbl.mechanism;
|
|
771
|
+
const color = MECHANISM_COLOR[mechanism] ?? '#888';
|
|
772
|
+
const verifiable = MECHANISM_DESCRIPTIONS.find(([m]) => m === mechanism)?.[2] ?? true;
|
|
773
|
+
const screenX = lbl.midX * viewport.zoom + viewport.x;
|
|
774
|
+
const screenY = lbl.midY * viewport.zoom + viewport.y;
|
|
775
|
+
const text = lbl.stepNos?.length
|
|
776
|
+
? `${lbl.stepNos.map((n) => `${n}:`).join(' ')} ${lbl.mechanism}`
|
|
777
|
+
: lbl.mechanism;
|
|
778
|
+
// Labels stay readable at full size until they'd exceed a share of
|
|
779
|
+
// the edge's screen length, then shrink with zoom.
|
|
780
|
+
const estWidth = text.length * EDGE_LABEL_CHAR_PX + EDGE_LABEL_PAD_PX;
|
|
781
|
+
const screenEdgeLen = lbl.pathLength * viewport.zoom;
|
|
782
|
+
const scale = lbl.pathLength > 0 && estWidth > 0
|
|
783
|
+
? Math.min(1, (screenEdgeLen * EDGE_LABEL_MAX_EDGE_FRACTION) / estWidth)
|
|
784
|
+
: 1;
|
|
785
|
+
return (_jsx("div", { "data-edge-label": lbl.id, title: verifiable ? undefined : 'Not directly verifiable with graphify', onClick: (e) => {
|
|
786
|
+
e.stopPropagation();
|
|
787
|
+
selectEdge(lbl.id);
|
|
788
|
+
}, style: {
|
|
789
|
+
position: 'absolute',
|
|
790
|
+
left: screenX,
|
|
791
|
+
top: screenY,
|
|
792
|
+
// Center on the flow-space midpoint. Labels live in screen
|
|
793
|
+
// space (fixed size when zoomed out), so top-left anchoring
|
|
794
|
+
// would drift them right/down of the edge as zoom drops.
|
|
795
|
+
transform: `translate(-50%, -50%) scale(${scale})`,
|
|
796
|
+
transformOrigin: 'center center',
|
|
797
|
+
display: 'flex',
|
|
798
|
+
alignItems: 'center',
|
|
799
|
+
fontSize: 10,
|
|
800
|
+
lineHeight: 1,
|
|
801
|
+
fontFamily: theme.fonts.monospace,
|
|
802
|
+
fontWeight: 500,
|
|
803
|
+
color,
|
|
804
|
+
background: 'rgba(21,21,21,0.9)',
|
|
805
|
+
border: verifiable ? `0.5px solid ${color}` : `1px dashed ${color}`,
|
|
806
|
+
borderRadius: verifiable ? 4 : '10px 14px 12px 16px / 14px 10px 16px 12px',
|
|
807
|
+
padding: '3px 8px',
|
|
808
|
+
cursor: 'pointer',
|
|
809
|
+
pointerEvents: 'auto',
|
|
810
|
+
opacity: lbl.dimmed ? 0.15 : 1,
|
|
811
|
+
whiteSpace: 'nowrap',
|
|
812
|
+
}, children: text }, lbl.id));
|
|
813
|
+
}) })), _jsxs(ReactFlow, { nodes: dispNodes, edges: dispEdges, nodeTypes: nodeTypes, edgeTypes: edgeTypes, minZoom: 0.05, maxZoom: 4, onNodeClick: onNodeClick, onEdgeClick: onEdgeClick, onNodesChange: onNodesChange, onEdgesChange: onEdgesChange, proOptions: { hideAttribution: true }, nodesDraggable: false, elementsSelectable: true, selectNodesOnDrag: false, nodesConnectable: false, edgesReconnectable: false, onPaneClick: onPaneClick, panOnDrag: true, panOnScroll: true, zoomOnScroll: false, zoomOnPinch: true, zoomOnDoubleClick: false, style: {
|
|
814
|
+
width: '100%',
|
|
815
|
+
height: '100%',
|
|
816
|
+
flex: 1,
|
|
817
|
+
minHeight: 0,
|
|
818
|
+
background: theme.colors.background,
|
|
819
|
+
}, children: [_jsx(Background, { variant: BackgroundVariant.Dots, gap: 16, size: 1 }), _jsx(Controls, { showZoom: true, showFitView: true, showInteractive: true })] }, `${baseNodesKey}-${baseEdgesKey}`), graphTitle && (_jsx("div", { style: {
|
|
820
|
+
position: 'absolute',
|
|
821
|
+
top: 10,
|
|
822
|
+
left: '50%',
|
|
823
|
+
transform: 'translateX(-50%)',
|
|
824
|
+
zIndex: 6,
|
|
825
|
+
maxWidth: '60%',
|
|
826
|
+
overflow: 'hidden',
|
|
827
|
+
textOverflow: 'ellipsis',
|
|
828
|
+
whiteSpace: 'nowrap',
|
|
829
|
+
padding: '6px 18px',
|
|
830
|
+
fontSize: theme.fontSizes[3],
|
|
831
|
+
fontWeight: 600,
|
|
832
|
+
fontFamily: theme.fonts.monospace,
|
|
833
|
+
color: theme.colors.text,
|
|
834
|
+
background: theme.colors.backgroundSecondary ?? theme.colors.background,
|
|
835
|
+
border: `1px solid ${theme.colors.border}`,
|
|
836
|
+
borderRadius: 6,
|
|
837
|
+
boxShadow: '0 1px 4px rgba(0,0,0,0.25)',
|
|
838
|
+
pointerEvents: 'none',
|
|
839
|
+
}, children: graphTitle })), selected && (_jsx("div", { style: {
|
|
840
|
+
position: 'absolute',
|
|
841
|
+
top: 10,
|
|
842
|
+
right: 10,
|
|
843
|
+
zIndex: 8,
|
|
844
|
+
width: 'min(560px, 70%)',
|
|
845
|
+
maxHeight: '46%',
|
|
846
|
+
overflowY: 'auto',
|
|
847
|
+
background: theme.colors.background,
|
|
848
|
+
border: `1px solid ${theme.colors.border}`,
|
|
849
|
+
borderRadius: 8,
|
|
850
|
+
boxShadow: '0 8px 24px rgba(0,0,0,0.35)',
|
|
851
|
+
}, children: _jsx(ComponentDeclaration, { component: selected, onOpenFile: onOpenDeclarationFile, onRelatedSelect: resolveRelatedComponent, onVerify: onVerifyComponent, verification: componentVerification }) }))] }), _jsx(FileDrawer, { title: drawerTitle, onClose: () => setDrawerTarget(null), children: drawerTarget?.kind === 'throughline' &&
|
|
852
|
+
focusedThroughline &&
|
|
853
|
+
renderThroughlineViewer ? (_jsx(ThroughlineDrawerContent, { render: renderThroughlineDrawerContent, throughline: focusedThroughline, stepIndex: drawerTarget.stepIndex })) : drawerTarget?.kind === 'file' ? (_jsx(FileDrawerContent, { render: renderDrawerContent, file: drawerTarget.file, startLine: drawerTarget.startLine })) : null }), _jsx(GraphLayoutCover, { revealed: layoutReady }), canvasOverlay] })] }));
|
|
854
|
+
}
|
|
855
|
+
/** Sidebar header for one repo's tree: owner avatar + repo name + file count.
|
|
856
|
+
* Clicking toggles the tree's visibility. */
|
|
857
|
+
function RepoGroupHeader({ group, collapsed, onToggle, }) {
|
|
858
|
+
const { theme } = useTheme();
|
|
859
|
+
const avatar = repoAvatarUrl(group.repoKey);
|
|
860
|
+
const label = group.repo ?? 'No repo';
|
|
861
|
+
return (_jsxs("div", { role: "button", "aria-expanded": !collapsed, onClick: (e) => {
|
|
862
|
+
e.stopPropagation();
|
|
863
|
+
onToggle();
|
|
864
|
+
}, title: collapsed ? 'Show files' : 'Hide files', style: {
|
|
865
|
+
display: 'flex',
|
|
866
|
+
alignItems: 'center',
|
|
867
|
+
gap: 8,
|
|
868
|
+
padding: '10px 16px 4px',
|
|
869
|
+
flexShrink: 0,
|
|
870
|
+
cursor: 'pointer',
|
|
871
|
+
userSelect: 'none',
|
|
872
|
+
}, children: [avatar ? (_jsx("img", { src: avatar, alt: "", width: 16, height: 16, loading: "lazy", style: { borderRadius: 4, flexShrink: 0, background: theme.colors.border } })) : group.owner ? (_jsx("span", { style: {
|
|
873
|
+
width: 16,
|
|
874
|
+
height: 16,
|
|
875
|
+
borderRadius: 4,
|
|
876
|
+
flexShrink: 0,
|
|
877
|
+
display: 'inline-flex',
|
|
878
|
+
alignItems: 'center',
|
|
879
|
+
justifyContent: 'center',
|
|
880
|
+
fontSize: 9,
|
|
881
|
+
fontWeight: 700,
|
|
882
|
+
fontFamily: theme.fonts.monospace,
|
|
883
|
+
color: theme.colors.text,
|
|
884
|
+
background: theme.colors.border,
|
|
885
|
+
}, children: group.owner.charAt(0).toUpperCase() })) : null, _jsx("span", { style: {
|
|
886
|
+
fontSize: theme.fontSizes[1],
|
|
887
|
+
fontFamily: theme.fonts.monospace,
|
|
888
|
+
color: theme.colors.text,
|
|
889
|
+
fontWeight: 600,
|
|
890
|
+
overflow: 'hidden',
|
|
891
|
+
textOverflow: 'ellipsis',
|
|
892
|
+
whiteSpace: 'nowrap',
|
|
893
|
+
}, children: label })] }));
|
|
894
|
+
}
|
|
895
|
+
/** One collapsible throughline in the sidebar's flows panel. Clicking the
|
|
896
|
+
* title: closed → open + select; open and unselected → select; open and
|
|
897
|
+
* selected → close + clear focus. The right-aligned close button collapses
|
|
898
|
+
* without selecting. A step row focuses that step's edge. */
|
|
899
|
+
function ThroughlineFlow({ throughline, edges, collapsed, active, onToggleCollapsed, onFocusFlow, onClearFocus, onFocusStep, }) {
|
|
900
|
+
const { theme } = useTheme();
|
|
901
|
+
const muted = theme.colors.textMuted ?? theme.colors.textSecondary;
|
|
902
|
+
const hoverBg = theme.colors.background;
|
|
903
|
+
const edgeById = useMemo(() => new Map(edges.map((e) => [e.id, e])), [edges]);
|
|
904
|
+
const wholeFlowActive = active !== null && active.stepIndex === null;
|
|
905
|
+
const [headerHover, setHeaderHover] = useState(false);
|
|
906
|
+
const [closeHover, setCloseHover] = useState(false);
|
|
907
|
+
const [hoveredStep, setHoveredStep] = useState(null);
|
|
908
|
+
const stepButtonRefs = useRef([]);
|
|
909
|
+
// Keep DOM focus on the active step so the browser focus ring (and
|
|
910
|
+
// subsequent arrow keys) follow arrow navigation, not the originally
|
|
911
|
+
// clicked button.
|
|
912
|
+
useEffect(() => {
|
|
913
|
+
if (active?.stepIndex == null)
|
|
914
|
+
return;
|
|
915
|
+
stepButtonRefs.current[active.stepIndex]?.focus({ preventScroll: true });
|
|
916
|
+
}, [active?.stepIndex]);
|
|
917
|
+
return (_jsxs("div", { style: { margin: '4px 0', borderRadius: 8 }, children: [_jsxs("div", { onMouseEnter: () => setHeaderHover(true), onMouseLeave: () => setHeaderHover(false), style: {
|
|
918
|
+
display: 'flex',
|
|
919
|
+
alignItems: 'center',
|
|
920
|
+
gap: 4,
|
|
921
|
+
borderRadius: 6,
|
|
922
|
+
background: wholeFlowActive || headerHover ? hoverBg : 'transparent',
|
|
923
|
+
transition: 'background 120ms ease',
|
|
924
|
+
}, children: [_jsx("button", { type: "button", onClick: () => {
|
|
925
|
+
if (collapsed) {
|
|
926
|
+
onToggleCollapsed(throughline.id);
|
|
927
|
+
onFocusFlow(throughline);
|
|
928
|
+
}
|
|
929
|
+
else if (active === null) {
|
|
930
|
+
onFocusFlow(throughline);
|
|
931
|
+
}
|
|
932
|
+
else {
|
|
933
|
+
onToggleCollapsed(throughline.id);
|
|
934
|
+
onClearFocus();
|
|
935
|
+
}
|
|
936
|
+
}, style: {
|
|
937
|
+
flex: 1,
|
|
938
|
+
display: 'flex',
|
|
939
|
+
alignItems: 'center',
|
|
940
|
+
minWidth: 0,
|
|
941
|
+
padding: '6px 8px',
|
|
942
|
+
borderRadius: 6,
|
|
943
|
+
border: 'none',
|
|
944
|
+
background: 'transparent',
|
|
945
|
+
textAlign: 'left',
|
|
946
|
+
cursor: 'pointer',
|
|
947
|
+
}, children: _jsx("span", { style: {
|
|
948
|
+
overflow: 'hidden',
|
|
949
|
+
textOverflow: 'ellipsis',
|
|
950
|
+
whiteSpace: 'nowrap',
|
|
951
|
+
fontSize: theme.fontSizes[1],
|
|
952
|
+
fontFamily: theme.fonts.monospace,
|
|
953
|
+
fontWeight: 600,
|
|
954
|
+
color: theme.colors.text,
|
|
955
|
+
}, children: throughline.title }) }), !collapsed && (_jsx("button", { type: "button", "aria-label": `Close ${throughline.title}`, onMouseEnter: () => setCloseHover(true), onMouseLeave: () => setCloseHover(false), onClick: (e) => {
|
|
956
|
+
e.stopPropagation();
|
|
957
|
+
onToggleCollapsed(throughline.id);
|
|
958
|
+
if (active !== null)
|
|
959
|
+
onClearFocus();
|
|
960
|
+
}, style: {
|
|
961
|
+
display: 'inline-flex',
|
|
962
|
+
alignItems: 'center',
|
|
963
|
+
justifyContent: 'center',
|
|
964
|
+
flexShrink: 0,
|
|
965
|
+
width: 22,
|
|
966
|
+
height: 22,
|
|
967
|
+
marginRight: 4,
|
|
968
|
+
padding: 0,
|
|
969
|
+
border: 'none',
|
|
970
|
+
borderRadius: 4,
|
|
971
|
+
background: closeHover ? theme.colors.border : 'transparent',
|
|
972
|
+
color: closeHover ? theme.colors.text : muted,
|
|
973
|
+
cursor: 'pointer',
|
|
974
|
+
transition: 'background 120ms ease, color 120ms ease',
|
|
975
|
+
}, children: _jsx(X, { size: 12, strokeWidth: 2 }) }))] }), !collapsed && (_jsx("div", { style: { display: 'flex', flexDirection: 'column', gap: 1 }, children: throughline.steps.map((step, i) => {
|
|
976
|
+
const edge = edgeById.get(step.edgeId);
|
|
977
|
+
const mech = edge?.mechanism;
|
|
978
|
+
const color = mech ? MECHANISM_COLOR[mech] : muted;
|
|
979
|
+
const stepActive = active !== null && active.stepIndex === i;
|
|
980
|
+
return (_jsxs("button", { ref: (el) => {
|
|
981
|
+
stepButtonRefs.current[i] = el;
|
|
982
|
+
}, type: "button", onMouseEnter: () => setHoveredStep(i), onMouseLeave: () => setHoveredStep(null), onClick: () => onFocusStep(throughline, i), style: {
|
|
983
|
+
display: 'flex',
|
|
984
|
+
alignItems: 'center',
|
|
985
|
+
gap: 8,
|
|
986
|
+
minWidth: 0,
|
|
987
|
+
padding: '4px 8px 4px 12px',
|
|
988
|
+
textAlign: 'left',
|
|
989
|
+
borderRadius: 6,
|
|
990
|
+
border: 'none',
|
|
991
|
+
outline: 'none',
|
|
992
|
+
background: stepActive || hoveredStep === i ? hoverBg : 'transparent',
|
|
993
|
+
cursor: 'pointer',
|
|
994
|
+
transition: 'background 120ms ease',
|
|
995
|
+
}, children: [_jsx("span", { style: {
|
|
996
|
+
flexShrink: 0,
|
|
997
|
+
width: 14,
|
|
998
|
+
fontSize: theme.fontSizes[0] * 0.8,
|
|
999
|
+
fontFamily: theme.fonts.monospace,
|
|
1000
|
+
color: stepActive ? theme.colors.text : muted,
|
|
1001
|
+
}, children: i + 1 }), step.symbol ? (_jsx("span", { style: {
|
|
1002
|
+
flex: 1,
|
|
1003
|
+
minWidth: 0,
|
|
1004
|
+
overflow: 'hidden',
|
|
1005
|
+
textOverflow: 'ellipsis',
|
|
1006
|
+
whiteSpace: 'nowrap',
|
|
1007
|
+
fontSize: theme.fontSizes[0],
|
|
1008
|
+
fontFamily: theme.fonts.monospace,
|
|
1009
|
+
color: stepActive ? theme.colors.text : muted,
|
|
1010
|
+
}, children: step.symbol })) : (_jsxs(_Fragment, { children: [_jsx("span", { style: {
|
|
1011
|
+
flexShrink: 0,
|
|
1012
|
+
width: 74,
|
|
1013
|
+
overflow: 'hidden',
|
|
1014
|
+
textOverflow: 'ellipsis',
|
|
1015
|
+
whiteSpace: 'nowrap',
|
|
1016
|
+
fontSize: theme.fontSizes[0],
|
|
1017
|
+
fontFamily: theme.fonts.monospace,
|
|
1018
|
+
color,
|
|
1019
|
+
}, children: mech ?? step.edgeId }), _jsxs("span", { style: {
|
|
1020
|
+
flex: 1,
|
|
1021
|
+
minWidth: 0,
|
|
1022
|
+
overflow: 'hidden',
|
|
1023
|
+
textOverflow: 'ellipsis',
|
|
1024
|
+
whiteSpace: 'nowrap',
|
|
1025
|
+
fontSize: theme.fontSizes[0],
|
|
1026
|
+
fontFamily: theme.fonts.monospace,
|
|
1027
|
+
color: stepActive ? theme.colors.text : muted,
|
|
1028
|
+
}, children: [step.file.split('/').pop(), _jsxs("span", { style: { opacity: 0.7 }, children: [":", step.line] })] })] }))] }, `${step.edgeId}-${i}`));
|
|
1029
|
+
}) }))] }));
|
|
1030
|
+
}
|
|
1031
|
+
export function SubsystemComponentGraph(props) {
|
|
1032
|
+
const wrapRef = useRef(null);
|
|
1033
|
+
const [size, setSize] = useState(null);
|
|
1034
|
+
// Measure the container so React Flow always has a real, non-zero pixel size
|
|
1035
|
+
// (responsive to the parent; avoids the %→0 blank canvas).
|
|
1036
|
+
useEffect(() => {
|
|
1037
|
+
const el = wrapRef.current;
|
|
1038
|
+
if (!el)
|
|
1039
|
+
return;
|
|
1040
|
+
const update = () => {
|
|
1041
|
+
const rect = el.getBoundingClientRect();
|
|
1042
|
+
if (rect.width > 0 && rect.height > 0)
|
|
1043
|
+
setSize({ w: rect.width, h: rect.height });
|
|
1044
|
+
};
|
|
1045
|
+
update();
|
|
1046
|
+
const ro = new ResizeObserver(update);
|
|
1047
|
+
ro.observe(el);
|
|
1048
|
+
return () => ro.disconnect();
|
|
1049
|
+
}, []);
|
|
1050
|
+
return (_jsx("div", { ref: wrapRef, style: {
|
|
1051
|
+
position: 'relative',
|
|
1052
|
+
width: '100%',
|
|
1053
|
+
height: '100%',
|
|
1054
|
+
minHeight: 0,
|
|
1055
|
+
display: 'flex',
|
|
1056
|
+
flexDirection: 'column',
|
|
1057
|
+
}, children: _jsx("div", { style: { flex: 1, minHeight: 0, display: 'flex', flexDirection: 'column' }, children: _jsx(ReactFlowProvider, { children: _jsx(Inner, { ...props, measured: size }) }) }) }));
|
|
1058
|
+
}
|
|
1059
|
+
//# sourceMappingURL=SubsystemComponentGraph.js.map
|