@likec4/diagram 1.43.0 → 1.44.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/bundle/index.js +5746 -4674
- package/dist/LikeC4Diagram.d.ts +1 -1
- package/dist/LikeC4Diagram.js +13 -10
- package/dist/LikeC4Diagram.props.d.ts +16 -7
- package/dist/LikeC4ProjectsProvider.js +1 -1
- package/dist/LikeC4View.d.ts +5 -0
- package/dist/LikeC4View.js +22 -11
- package/dist/ReactLikeC4.js +2 -2
- package/dist/StaticLikeC4Diagram.js +1 -1
- package/dist/_virtual/_commonjsHelpers.js +3 -0
- package/dist/_virtual/assign-dea9f7c8.cjs.js +3 -0
- package/dist/_virtual/log-ec8d4df4.cjs.js +3 -0
- package/dist/_virtual/raise-da5b247f.cjs.js +3 -0
- package/dist/_virtual/xstate-actions.cjs.js +5 -0
- package/dist/_virtual/xstate-actions.cjs2.js +3 -0
- package/dist/_virtual/xstate-dev.cjs.js +3 -0
- package/dist/_virtual/xstate-guards.cjs.js +5 -0
- package/dist/_virtual/xstate-guards.cjs2.js +3 -0
- package/dist/base/Background.d.ts +2 -1
- package/dist/base/Background.js +11 -2
- package/dist/base/Base.d.ts +28 -0
- package/dist/base/BaseXYFlow.d.ts +5 -5
- package/dist/base/BaseXYFlow.js +38 -44
- package/dist/base/index.d.ts +6 -2
- package/dist/base/types.d.ts +1 -28
- package/dist/base/updateEdges.js +4 -3
- package/dist/base/updateNodes.js +3 -2
- package/dist/base-primitives/compound/CompoundActionButton.js +1 -1
- package/dist/base-primitives/compound/CompoundDetailsButton.js +1 -1
- package/dist/base-primitives/edge/EdgeActionButton.js +1 -1
- package/dist/base-primitives/edge/EdgeContainer.d.ts +1 -1
- package/dist/base-primitives/edge/EdgeContainer.js +4 -0
- package/dist/base-primitives/edge/EdgeLabel.d.ts +1 -0
- package/dist/base-primitives/edge/EdgeLabel.js +2 -0
- package/dist/base-primitives/edge/EdgeLabelContainer.d.ts +1 -1
- package/dist/base-primitives/edge/EdgeLabelContainer.js +4 -0
- package/dist/base-primitives/edge/EdgePath.d.ts +4 -0
- package/dist/base-primitives/edge/EdgePath.js +9 -5
- package/dist/base-primitives/element/ElementActionButtons.d.ts +3 -2
- package/dist/base-primitives/element/ElementActionButtons.js +1 -1
- package/dist/base-primitives/element/ElementDetailsButton.js +2 -5
- package/dist/base-primitives/element/ElementNodeContainer.css.js +15 -27
- package/dist/base-primitives/element/ElementTags.js +2 -1
- package/dist/base-primitives/memoEdge.js +4 -2
- package/dist/base-primitives/memoNode.d.ts +1 -1
- package/dist/base-primitives/memoNode.js +3 -3
- package/dist/components/ErrorFallback.js +52 -35
- package/dist/components/Link.js +2 -2
- package/dist/context/DiagramEventHandlers.js +2 -1
- package/dist/context/DiagramFeatures.d.ts +24 -6
- package/dist/context/DiagramFeatures.js +28 -56
- package/dist/context/IconRenderer.js +6 -6
- package/dist/context/LikeC4ModelContext.js +3 -10
- package/dist/context/TagStylesContext.js +2 -18
- package/dist/context/index.d.ts +1 -1
- package/dist/custom/customNodes.js +3 -2
- package/dist/custom/hooks.d.ts +1 -1
- package/dist/custom/index.d.ts +1 -1
- package/dist/custom/index.js +4 -4
- package/dist/editor/LikeC4EditorContext.d.ts +21 -0
- package/dist/editor/index.d.ts +2 -0
- package/dist/hooks/index.d.ts +2 -1
- package/dist/hooks/safeContext.d.ts +6 -3
- package/dist/hooks/safeContext.js +10 -3
- package/dist/hooks/useCallbackRef.d.ts +1 -0
- package/dist/hooks/useCallbackRef.js +13 -0
- package/dist/hooks/useCurrentView.d.ts +11 -0
- package/dist/hooks/{useCurrentViewId.js → useCurrentView.js} +7 -3
- package/dist/hooks/useCurrentViewModel.js +4 -1
- package/dist/hooks/useDiagram.d.ts +7 -113
- package/dist/hooks/useDiagram.js +7 -127
- package/dist/hooks/useDiagramCompareLayout.d.ts +35 -0
- package/dist/hooks/useDiagramCompareLayout.js +60 -0
- package/dist/hooks/useUpdateEffect.js +2 -4
- package/dist/hooks/useXYFlow.d.ts +1 -0
- package/dist/hooks/useXYFlow.js +4 -7
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -3
- package/dist/likec4diagram/DiagramUI.js +14 -7
- package/dist/likec4diagram/DiagramXYFlow.d.ts +2 -2
- package/dist/likec4diagram/DiagramXYFlow.js +54 -51
- package/dist/likec4diagram/convert-to-xyflow.d.ts +0 -1
- package/dist/likec4diagram/custom/edges/RelationshipEdge.js +249 -220
- package/dist/likec4diagram/custom/edges/SequenceStepEdge.js +7 -2
- package/dist/likec4diagram/custom/edges/edges.css.js +3 -4
- package/dist/likec4diagram/custom/edges/useControlPoints.d.ts +8 -0
- package/dist/likec4diagram/custom/edges/useControlPoints.js +58 -0
- package/dist/likec4diagram/custom/edges/useRelationshipEdgePath.d.ts +7 -0
- package/dist/likec4diagram/custom/edges/useRelationshipEdgePath.js +60 -0
- package/dist/likec4diagram/custom/edges/utils.d.ts +0 -12
- package/dist/likec4diagram/custom/nodes/CompoundActions.js +4 -1
- package/dist/likec4diagram/custom/nodes/ElementActions.d.ts +2 -1
- package/dist/likec4diagram/custom/nodes/ElementActions.js +15 -10
- package/dist/likec4diagram/custom/nodes/ElementNodeDrifts.d.ts +4 -0
- package/dist/likec4diagram/custom/nodes/ElementNodeDrifts.js +46 -0
- package/dist/likec4diagram/custom/nodes/SequenceActorNode.js +4 -1
- package/dist/likec4diagram/custom/nodes/nodes.d.ts +9 -1
- package/dist/likec4diagram/custom/nodes/nodes.js +13 -9
- package/dist/likec4diagram/custom/nodes/toolbar/ColorButton.d.ts +1 -1
- package/dist/likec4diagram/custom/nodes/toolbar/ColorButton.js +1 -1
- package/dist/likec4diagram/custom/nodes/toolbar/CompoundToolbar.js +2 -1
- package/dist/likec4diagram/custom/nodes/toolbar/ElementToolbar.js +4 -3
- package/dist/likec4diagram/custom/nodes/toolbar/_shared.d.ts +1 -11
- package/dist/likec4diagram/custom/nodes/toolbar/_shared.js +7 -51
- package/dist/likec4diagram/custom/nodes/toolbar/types.d.ts +5 -0
- package/dist/likec4diagram/custom/nodes/toolbar/types.js +7 -0
- package/dist/likec4diagram/custom/nodes/toolbar/useHandlers.d.ts +8 -0
- package/dist/likec4diagram/custom/nodes/toolbar/useHandlers.js +44 -0
- package/dist/likec4diagram/relationship-popover/RelationshipPopover.js +5 -7
- package/dist/likec4diagram/state/DiagramActorProvider.d.ts +3 -2
- package/dist/likec4diagram/state/DiagramActorProvider.js +96 -70
- package/dist/likec4diagram/state/assign.d.ts +4 -2
- package/dist/likec4diagram/state/assign.js +39 -103
- package/dist/likec4diagram/state/createViewChange.d.ts +3 -0
- package/dist/likec4diagram/state/createViewChange.js +90 -0
- package/dist/likec4diagram/state/diagram-api.d.ts +113 -0
- package/dist/likec4diagram/state/diagram-api.js +134 -0
- package/dist/likec4diagram/state/hotkeyActor.d.ts +7 -0
- package/dist/likec4diagram/state/hotkeyActor.js +17 -1
- package/dist/likec4diagram/state/machine.actions.d.ts +2099 -0
- package/dist/likec4diagram/state/machine.actions.js +735 -0
- package/dist/likec4diagram/state/machine.d.ts +3717 -0
- package/dist/likec4diagram/state/machine.js +141 -0
- package/dist/likec4diagram/state/machine.setup.d.ts +284 -0
- package/dist/likec4diagram/state/machine.setup.js +71 -0
- package/dist/likec4diagram/state/machine.state.initializing.d.ts +183 -0
- package/dist/likec4diagram/state/machine.state.initializing.js +55 -0
- package/dist/likec4diagram/state/machine.state.navigating.d.ts +117 -0
- package/dist/likec4diagram/state/machine.state.navigating.js +45 -0
- package/dist/likec4diagram/state/machine.state.ready.d.ts +3666 -0
- package/dist/likec4diagram/state/machine.state.ready.js +437 -0
- package/dist/likec4diagram/state/syncManualLayoutActor.d.ts +220 -63
- package/dist/likec4diagram/state/syncManualLayoutActor.js +218 -143
- package/dist/likec4diagram/state/types.d.ts +4 -7
- package/dist/likec4diagram/state/utils.d.ts +4 -2
- package/dist/likec4diagram/state/utils.js +4 -1
- package/dist/likec4diagram/types.d.ts +6 -1
- package/dist/likec4diagram/ui/LayoutDriftFrame.d.ts +2 -0
- package/dist/likec4diagram/ui/LayoutDriftFrame.js +66 -0
- package/dist/likec4diagram/ui/index.d.ts +1 -0
- package/dist/likec4diagram/ui/notation/NotationPanel.js +5 -4
- package/dist/likec4diagram/useLayoutConstraints.d.ts +10 -5
- package/dist/likec4diagram/useLayoutConstraints.js +225 -54
- package/dist/likec4diagram/xyflow-diagram/diagram-view.d.ts +0 -1
- package/dist/likec4diagram/xyflow-diagram/diagram-view.js +15 -15
- package/dist/navigationpanel/NavigationPanel.js +11 -7
- package/dist/navigationpanel/NavigationPanelControls.d.ts +2 -1
- package/dist/navigationpanel/NavigationPanelControls.js +23 -17
- package/dist/navigationpanel/NavigationPanelDropdown.d.ts +2 -1
- package/dist/navigationpanel/NavigationPanelDropdown.js +62 -42
- package/dist/navigationpanel/_common.d.ts +1 -1
- package/dist/navigationpanel/_common.js +4 -2
- package/dist/navigationpanel/actor.d.ts +11 -7
- package/dist/navigationpanel/actor.js +5 -4
- package/dist/navigationpanel/comparepanel/CompareActionsMenu.d.ts +3 -0
- package/dist/navigationpanel/comparepanel/CompareActionsMenu.js +59 -0
- package/dist/navigationpanel/comparepanel/ComparePanel.d.ts +2 -0
- package/dist/navigationpanel/comparepanel/ComparePanel.js +42 -0
- package/dist/navigationpanel/comparepanel/ComparePanelControls.d.ts +1 -0
- package/dist/navigationpanel/comparepanel/ComparePanelControls.js +60 -0
- package/dist/navigationpanel/comparepanel/LayoutTypeSwitcher.d.ts +5 -0
- package/dist/navigationpanel/comparepanel/LayoutTypeSwitcher.js +38 -0
- package/dist/navigationpanel/comparepanel/index.d.ts +1 -0
- package/dist/navigationpanel/controls/{ViewDetailsCard.d.ts → DetailsControls.d.ts} +1 -1
- package/dist/navigationpanel/controls/{ViewDetailsCard.js → DetailsControls.js} +18 -14
- package/dist/navigationpanel/controls/LayoutWarning.d.ts +2 -0
- package/dist/navigationpanel/controls/LayoutWarning.js +102 -0
- package/dist/navigationpanel/controls/NavigationButtons.js +4 -3
- package/dist/navigationpanel/controls/OpenSource.js +2 -2
- package/dist/navigationpanel/controls/SearchControl.d.ts +2 -1
- package/dist/navigationpanel/controls/SearchControl.js +15 -17
- package/dist/navigationpanel/controls/ToggleReadonly.d.ts +1 -1
- package/dist/navigationpanel/controls/ToggleReadonly.js +19 -16
- package/dist/navigationpanel/controls/index.d.ts +2 -1
- package/dist/navigationpanel/dropdown/ProjectsMenu.d.ts +2 -2
- package/dist/navigationpanel/dropdown/ProjectsMenu.js +5 -5
- package/dist/navigationpanel/editorpanel/CenterCamera.js +5 -2
- package/dist/navigationpanel/editorpanel/ChangeAutoLayoutButton.d.ts +1 -1
- package/dist/navigationpanel/editorpanel/ChangeAutoLayoutButton.js +21 -20
- package/dist/navigationpanel/editorpanel/EditorPanel.js +3 -3
- package/dist/navigationpanel/editorpanel/ManualLayoutToolsButton.d.ts +2 -2
- package/dist/navigationpanel/editorpanel/ManualLayoutToolsButton.js +16 -13
- package/dist/navigationpanel/editorpanel/ToggleReadonly.d.ts +1 -0
- package/dist/navigationpanel/editorpanel/ToggleReadonly.js +15 -0
- package/dist/navigationpanel/styles.css.d.ts +2 -2
- package/dist/navigationpanel/styles.css.js +4 -4
- package/dist/navigationpanel/walkthrough/ActiveWalkthroughControls.js +14 -8
- package/dist/navigationpanel/walkthrough/DynamicViewControls.d.ts +10 -10
- package/dist/navigationpanel/walkthrough/DynamicViewControls.js +31 -14
- package/dist/navigationpanel/walkthrough/WalkthroughPanel.d.ts +2 -1
- package/dist/navigationpanel/walkthrough/WalkthroughPanel.js +66 -49
- package/dist/node_modules/.pnpm/xstate@5.24.0_patch_hash_3a1bd6d012ec67bf6e38a00c3226d1be77089442f83aeb6e424b00ca2a11d21c/node_modules/xstate/actions/dist/xstate-actions.cjs.js +37 -0
- package/dist/node_modules/.pnpm/xstate@5.24.0_patch_hash_3a1bd6d012ec67bf6e38a00c3226d1be77089442f83aeb6e424b00ca2a11d21c/node_modules/xstate/dev/dist/xstate-dev.cjs.js +59 -0
- package/dist/node_modules/.pnpm/xstate@5.24.0_patch_hash_3a1bd6d012ec67bf6e38a00c3226d1be77089442f83aeb6e424b00ca2a11d21c/node_modules/xstate/dist/assign-dea9f7c8.cjs.js +140 -0
- package/dist/node_modules/.pnpm/xstate@5.24.0_patch_hash_3a1bd6d012ec67bf6e38a00c3226d1be77089442f83aeb6e424b00ca2a11d21c/node_modules/xstate/dist/log-ec8d4df4.cjs.js +401 -0
- package/dist/node_modules/.pnpm/xstate@5.24.0_patch_hash_3a1bd6d012ec67bf6e38a00c3226d1be77089442f83aeb6e424b00ca2a11d21c/node_modules/xstate/dist/raise-da5b247f.cjs.js +2716 -0
- package/dist/node_modules/.pnpm/xstate@5.24.0_patch_hash_3a1bd6d012ec67bf6e38a00c3226d1be77089442f83aeb6e424b00ca2a11d21c/node_modules/xstate/guards/dist/xstate-guards.cjs.js +26 -0
- package/dist/overlays/element-details/ElementDetails.js +7 -7
- package/dist/overlays/element-details/ElementDetailsCard.js +7 -5
- package/dist/overlays/element-details/MetadataValue.js +2 -2
- package/dist/overlays/element-details/TabPanelDeployments.js +6 -4
- package/dist/overlays/element-details/TabPanelRelationships.js +3 -3
- package/dist/overlays/element-details/TabPanelStructure.js +1 -1
- package/dist/overlays/element-details/actor.d.ts +3 -2
- package/dist/overlays/overlaysActor.d.ts +304 -62
- package/dist/overlays/overlaysActor.js +132 -131
- package/dist/overlays/relationship-details/RelationshipDetails.js +4 -3
- package/dist/overlays/relationship-details/SelectEdge.js +2 -2
- package/dist/overlays/relationship-details/actor.d.ts +14 -2
- package/dist/overlays/relationship-details/actor.js +17 -3
- package/dist/overlays/relationship-details/custom/ElementActions.js +8 -5
- package/dist/overlays/relationship-details/custom/edgeTypes.js +4 -1
- package/dist/overlays/relationship-details/custom/nodeTypes.js +4 -1
- package/dist/overlays/relationship-details/hooks.js +1 -1
- package/dist/overlays/relationships-browser/RelationshipsBrowser.js +6 -4
- package/dist/overlays/relationships-browser/SelectElement.js +2 -2
- package/dist/overlays/relationships-browser/actor.d.ts +239 -173
- package/dist/overlays/relationships-browser/actor.js +132 -110
- package/dist/overlays/relationships-browser/custom/ElementActions.js +44 -37
- package/dist/overlays/relationships-browser/custom/edgeTypes.js +4 -1
- package/dist/overlays/relationships-browser/custom/nodeTypes.js +4 -1
- package/dist/overlays/relationships-browser/hooks.js +7 -6
- package/dist/search/Search.js +2 -1
- package/dist/search/components/ElementsColumn.js +5 -3
- package/dist/search/components/PickView.js +1 -1
- package/dist/search/components/SearchByTags.js +21 -44
- package/dist/search/components/SearchInput.js +1 -1
- package/dist/search/components/ViewsColum.js +6 -4
- package/dist/shadowroot/ShadowRoot.js +1 -1
- package/dist/styles.css2.js +1 -1
- package/dist/utils/index.d.ts +4 -4
- package/dist/utils/vector.d.ts +78 -21
- package/dist/utils/vector.js +91 -24
- package/dist/utils/view-bounds.d.ts +8 -0
- package/dist/utils/view-bounds.js +57 -0
- package/dist/utils/xyflow.d.ts +49 -7
- package/dist/utils/xyflow.js +63 -11
- package/package.json +19 -18
- package/panda.buildinfo.json +107 -66
- package/styles-min.css +1 -1
- package/styles.css +1 -1
- package/dist/hooks/useCurrentViewId.d.ts +0 -6
- package/dist/likec4diagram/custom/edges/utils.js +0 -23
- package/dist/likec4diagram/state/diagram-machine.d.ts +0 -2590
- package/dist/likec4diagram/state/diagram-machine.js +0 -1180
- package/dist/navigationpanel/editorpanel/LayoutDriftNotification.d.ts +0 -1
- package/dist/navigationpanel/editorpanel/LayoutDriftNotification.js +0 -56
- package/dist/utils/get-view-bounds.d.ts +0 -3
- package/dist/utils/get-view-bounds.js +0 -14
- /package/dist/base/{types.js → Base.js} +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/createReactComponent.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/defaultAttributes.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconAlertTriangle.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconArrowDownRight.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconArrowLeft.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconArrowRight.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconBolt.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconBrowser.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconCheck.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconChevronDown.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconChevronLeft.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconChevronRight.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconCopy.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconCylinder.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconDeviceMobile.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconDirectionSignFilled.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconExternalLink.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconFileSymlink.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconFocusCentered.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconFolderFilled.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconHelpCircle.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconId.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconInfoCircle.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutAlignBottom.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutAlignCenter.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutAlignLeft.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutAlignMiddle.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutAlignRight.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutAlignTop.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutBoardSplit.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutCollage.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutDashboard.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconLink.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconLock.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconLockOpen2.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconPlayerPlayFilled.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconPlayerSkipBackFilled.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconPlayerSkipForwardFilled.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconPlayerStopFilled.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconRectangularPrism.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconReorder.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconRouteOff.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconSearch.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconSelector.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconStack2.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconStarFilled.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconTarget.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconTransform.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconUser.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconX.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconZoomScan.js +0 -0
|
@@ -1,52 +1,37 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import {
|
|
2
|
+
import { useRafEffect } from '@react-hookz/web';
|
|
3
3
|
import { useActorRef, useSelector } from '@xstate/react';
|
|
4
4
|
import { useStoreApi } from '@xyflow/react';
|
|
5
|
-
import { shallowEqual
|
|
6
|
-
import {
|
|
5
|
+
import { shallowEqual } from 'fast-equals';
|
|
6
|
+
import { useState, useEffect, memo, useRef } from 'react';
|
|
7
|
+
import { isNullish } from 'remeda';
|
|
7
8
|
import { ErrorBoundary } from '../../components/ErrorFallback.js';
|
|
8
9
|
import { useDiagramEventHandlers } from '../../context/DiagramEventHandlers.js';
|
|
9
10
|
import { useEnabledFeatures, DiagramFeatures } from '../../context/DiagramFeatures.js';
|
|
10
11
|
import { CurrentViewModelContext } from '../../context/LikeC4ModelContext.js';
|
|
11
|
-
import { DiagramActorContextProvider } from '../../hooks/safeContext.js';
|
|
12
|
-
import {
|
|
12
|
+
import { DiagramActorContextProvider, useDiagram } from '../../hooks/safeContext.js';
|
|
13
|
+
import { useOnDiagramEvent } from '../../hooks/useDiagram.js';
|
|
13
14
|
import { useLikeC4Model } from '../../hooks/useLikeC4Model.js';
|
|
14
15
|
import { useUpdateEffect } from '../../hooks/useUpdateEffect.js';
|
|
15
16
|
import { convertToXYFlow } from '../convert-to-xyflow.js';
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
17
|
+
import { makeDiagramApi } from './diagram-api.js';
|
|
18
|
+
import { diagramMachine } from './machine.js';
|
|
19
|
+
import { DiagramToggledFeaturesPersistence } from './persistence.js';
|
|
18
20
|
|
|
19
|
-
const selectDynamicViewVariant = (state) => {
|
|
20
|
-
return state.context.dynamicViewVariant;
|
|
21
|
-
};
|
|
22
21
|
function DiagramActorProvider({
|
|
23
22
|
view,
|
|
24
23
|
zoomable,
|
|
25
24
|
pannable,
|
|
26
|
-
|
|
25
|
+
nodesDraggable,
|
|
27
26
|
nodesSelectable,
|
|
27
|
+
fitViewPadding,
|
|
28
28
|
where,
|
|
29
29
|
children,
|
|
30
30
|
dynamicViewVariant: _defaultVariant
|
|
31
31
|
}) {
|
|
32
|
-
const { handlersRef } = useDiagramEventHandlers();
|
|
33
32
|
const xystore = useStoreApi();
|
|
34
|
-
const machineRef = useRef(null);
|
|
35
|
-
if (!machineRef.current) {
|
|
36
|
-
machineRef.current = diagramMachine.provide({
|
|
37
|
-
actors: {
|
|
38
|
-
syncManualLayoutActorLogic: syncManualLayoutActorLogic.provide({
|
|
39
|
-
actions: {
|
|
40
|
-
"trigger:OnChange": ((_, params) => {
|
|
41
|
-
handlersRef.current.onChange?.(params);
|
|
42
|
-
})
|
|
43
|
-
}
|
|
44
|
-
})
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
33
|
const actorRef = useActorRef(
|
|
49
|
-
|
|
34
|
+
diagramMachine,
|
|
50
35
|
{
|
|
51
36
|
id: `diagram`,
|
|
52
37
|
systemId: "diagram",
|
|
@@ -57,96 +42,137 @@ function DiagramActorProvider({
|
|
|
57
42
|
zoomable,
|
|
58
43
|
pannable,
|
|
59
44
|
fitViewPadding,
|
|
45
|
+
nodesDraggable,
|
|
60
46
|
nodesSelectable,
|
|
61
47
|
dynamicViewVariant: _defaultVariant
|
|
62
48
|
}
|
|
63
49
|
}
|
|
64
50
|
);
|
|
51
|
+
const [api, setApi] = useState(() => makeDiagramApi(actorRef));
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
setApi((api2) => {
|
|
54
|
+
if (api2.actor === actorRef) return api2;
|
|
55
|
+
return makeDiagramApi(actorRef);
|
|
56
|
+
});
|
|
57
|
+
}, [actorRef]);
|
|
58
|
+
if (api.actor !== actorRef) {
|
|
59
|
+
console.warn("DiagramApi instance changed, this should not happen during the lifetime of the actor");
|
|
60
|
+
}
|
|
65
61
|
const features = useEnabledFeatures();
|
|
66
|
-
useCustomCompareEffect(
|
|
67
|
-
() => {
|
|
68
|
-
actorRef.send({ type: "update.features", features });
|
|
69
|
-
},
|
|
70
|
-
[features],
|
|
71
|
-
shallowEqual
|
|
72
|
-
);
|
|
73
62
|
useEffect(
|
|
74
|
-
() => {
|
|
75
|
-
|
|
76
|
-
},
|
|
77
|
-
[zoomable, pannable, fitViewPadding, nodesSelectable]
|
|
63
|
+
() => actorRef.send({ type: "update.features", features }),
|
|
64
|
+
[features, actorRef]
|
|
78
65
|
);
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
66
|
+
useEffect(
|
|
67
|
+
() => actorRef.send({
|
|
68
|
+
type: "update.inputs",
|
|
69
|
+
inputs: { zoomable, pannable, fitViewPadding, nodesDraggable, nodesSelectable }
|
|
70
|
+
}),
|
|
71
|
+
[zoomable, pannable, fitViewPadding, actorRef, nodesDraggable, nodesSelectable]
|
|
83
72
|
);
|
|
84
|
-
useRafEffect(() => {
|
|
85
|
-
actorRef.send({
|
|
86
|
-
type: "update.view",
|
|
87
|
-
...update
|
|
88
|
-
});
|
|
89
|
-
}, [actorRef, update]);
|
|
90
73
|
useUpdateEffect(() => {
|
|
91
74
|
if (!_defaultVariant) return;
|
|
92
75
|
actorRef.send({ type: "switch.dynamicViewVariant", variant: _defaultVariant });
|
|
93
|
-
}, [_defaultVariant]);
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
/* @__PURE__ */
|
|
76
|
+
}, [_defaultVariant, actorRef]);
|
|
77
|
+
console.debug("Render DiagramActorProvider for view", view.id);
|
|
78
|
+
return /* @__PURE__ */ jsxs(DiagramActorContextProvider, { value: api, children: [
|
|
79
|
+
/* @__PURE__ */ jsxs(ErrorBoundary, { children: [
|
|
80
|
+
/* @__PURE__ */ jsx(
|
|
81
|
+
DiagramXYFlowSyncProvider,
|
|
82
|
+
{
|
|
83
|
+
view,
|
|
84
|
+
where,
|
|
85
|
+
actorRef
|
|
86
|
+
}
|
|
87
|
+
),
|
|
88
|
+
/* @__PURE__ */ jsx(CurrentViewModelProvider, { actorRef, children })
|
|
89
|
+
] }),
|
|
90
|
+
/* @__PURE__ */ jsx(DiagramActorEventListener, {})
|
|
97
91
|
] });
|
|
98
92
|
}
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
93
|
+
const selectFromActor = ({ context }) => {
|
|
94
|
+
let toggledFeatures = context.toggledFeatures;
|
|
95
|
+
const hasDrifts = context.view.drifts != null;
|
|
96
|
+
const enableCompareWithLatest = context.features.enableCompareWithLatest && (toggledFeatures.enableCompareWithLatest ?? false) && isNullish(context.activeWalkthrough) && hasDrifts;
|
|
97
|
+
const enableReadOnly = context.features.enableReadOnly || toggledFeatures.enableReadOnly || !!context.activeWalkthrough || context.dynamicViewVariant === "sequence" && context.view._type === "dynamic" || enableCompareWithLatest && context.view._layout === "auto";
|
|
98
|
+
if (toggledFeatures.enableReadOnly !== enableReadOnly || toggledFeatures.enableCompareWithLatest !== enableCompareWithLatest) {
|
|
99
|
+
toggledFeatures = {
|
|
100
|
+
...toggledFeatures,
|
|
101
|
+
enableCompareWithLatest,
|
|
102
|
+
enableReadOnly
|
|
107
103
|
};
|
|
108
104
|
}
|
|
109
105
|
return {
|
|
110
|
-
|
|
111
|
-
|
|
106
|
+
toggledFeatures,
|
|
107
|
+
viewId: context.view.id
|
|
112
108
|
};
|
|
113
109
|
};
|
|
110
|
+
const compareSelected = (a, b) => {
|
|
111
|
+
return a.viewId === b.viewId && shallowEqual(a.toggledFeatures, b.toggledFeatures);
|
|
112
|
+
};
|
|
114
113
|
function CurrentViewModelProvider({ children, actorRef }) {
|
|
115
|
-
const { viewId, toggledFeatures } = useSelector(
|
|
114
|
+
const { viewId, toggledFeatures } = useSelector(
|
|
115
|
+
actorRef,
|
|
116
|
+
selectFromActor,
|
|
117
|
+
compareSelected
|
|
118
|
+
);
|
|
119
|
+
useUpdateEffect(() => {
|
|
120
|
+
DiagramToggledFeaturesPersistence.write(toggledFeatures);
|
|
121
|
+
}, [toggledFeatures]);
|
|
116
122
|
const likec4model = useLikeC4Model();
|
|
117
123
|
const viewmodel = likec4model.findView(viewId);
|
|
118
124
|
return /* @__PURE__ */ jsx(CurrentViewModelContext.Provider, { value: viewmodel, children: /* @__PURE__ */ jsx(DiagramFeatures, { overrides: toggledFeatures, children }) });
|
|
119
125
|
}
|
|
120
|
-
|
|
126
|
+
const selectFromActor2 = (state) => {
|
|
127
|
+
return state.context.dynamicViewVariant;
|
|
128
|
+
};
|
|
129
|
+
function DiagramXYFlowSyncProvider({ view, where, actorRef }) {
|
|
130
|
+
const dynamicViewVariant = useSelector(actorRef, selectFromActor2);
|
|
131
|
+
useRafEffect(() => {
|
|
132
|
+
actorRef.send({
|
|
133
|
+
type: "update.view",
|
|
134
|
+
...convertToXYFlow({ view, where, dynamicViewVariant })
|
|
135
|
+
});
|
|
136
|
+
}, [view, where, dynamicViewVariant, actorRef]);
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
const DiagramActorEventListener = memo(() => {
|
|
121
140
|
const diagram = useDiagram();
|
|
122
141
|
const {
|
|
123
142
|
onNavigateTo,
|
|
124
143
|
onOpenSource,
|
|
144
|
+
onChange,
|
|
145
|
+
onLayoutTypeChange,
|
|
125
146
|
handlersRef
|
|
126
147
|
} = useDiagramEventHandlers();
|
|
127
148
|
useOnDiagramEvent("openSource", ({ params }) => onOpenSource?.(params));
|
|
128
149
|
useOnDiagramEvent("navigateTo", ({ viewId }) => onNavigateTo?.(viewId));
|
|
150
|
+
useOnDiagramEvent("onChange", ({ change }) => onChange?.({ change }));
|
|
151
|
+
useOnDiagramEvent("onLayoutTypeChange", ({ layoutType }) => {
|
|
152
|
+
onLayoutTypeChange?.(layoutType);
|
|
153
|
+
});
|
|
129
154
|
const wasEmitted = useRef(false);
|
|
130
155
|
useEffect(() => {
|
|
131
156
|
if (wasEmitted.current) return;
|
|
132
|
-
let subscription =
|
|
157
|
+
let subscription = diagram.actor.on(
|
|
133
158
|
"initialized",
|
|
134
159
|
({ instance: xyflow }) => {
|
|
135
160
|
try {
|
|
136
161
|
handlersRef.current.onInitialized?.({ diagram, xyflow });
|
|
137
162
|
} catch (error) {
|
|
138
163
|
console.error(error);
|
|
164
|
+
} finally {
|
|
165
|
+
wasEmitted.current = true;
|
|
166
|
+
subscription?.unsubscribe();
|
|
167
|
+
subscription = null;
|
|
139
168
|
}
|
|
140
|
-
wasEmitted.current = true;
|
|
141
|
-
subscription?.unsubscribe();
|
|
142
|
-
subscription = null;
|
|
143
169
|
}
|
|
144
170
|
);
|
|
145
171
|
return () => {
|
|
146
172
|
subscription?.unsubscribe();
|
|
147
173
|
};
|
|
148
|
-
}, [
|
|
174
|
+
}, [diagram]);
|
|
149
175
|
return null;
|
|
150
|
-
}
|
|
176
|
+
});
|
|
151
177
|
|
|
152
178
|
export { DiagramActorProvider };
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { XYPoint } from '@likec4/core';
|
|
2
|
+
import { NodeLookup } from '@xyflow/system';
|
|
1
3
|
import { Types } from '../types';
|
|
2
|
-
import { ActionArg, Context as DiagramContext } from './
|
|
4
|
+
import { ActionArg, Context as DiagramContext } from './machine.setup';
|
|
3
5
|
export declare function lastClickedNode(params: {
|
|
4
6
|
context: DiagramContext;
|
|
5
7
|
event: {
|
|
@@ -13,5 +15,5 @@ export declare function navigateBack({ context }: ActionArg): Partial<DiagramCon
|
|
|
13
15
|
export declare function navigateForward({ context }: ActionArg): Partial<DiagramContext>;
|
|
14
16
|
export declare function updateNodeData({ context, event }: ActionArg): Partial<DiagramContext>;
|
|
15
17
|
export declare function updateEdgeData({ context, event }: ActionArg): Partial<DiagramContext>;
|
|
16
|
-
export declare function resetEdgeControlPoints(
|
|
18
|
+
export declare function resetEdgeControlPoints(nodeLookup: NodeLookup, edge: Types.Edge): [XYPoint] | [XYPoint, XYPoint];
|
|
17
19
|
export declare function updateActiveWalkthrough({ context }: ActionArg): Partial<DiagramContext>;
|
|
@@ -1,27 +1,13 @@
|
|
|
1
1
|
import { nonNullable, invariant } from '@likec4/core';
|
|
2
2
|
import { getNodeDimensions } from '@xyflow/system';
|
|
3
3
|
import { deepEqual } from 'fast-equals';
|
|
4
|
-
import {
|
|
4
|
+
import { mergeDeep, omit } from 'remeda';
|
|
5
5
|
import { assertEvent } from 'xstate';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { vector } from '../../utils/vector.js';
|
|
7
|
+
import { getNodeCenter } from '../../utils/xyflow.js';
|
|
8
8
|
import { SeqParallelAreaColor } from '../xyflow-sequence/const.js';
|
|
9
|
+
import { Base } from '../../base/Base.js';
|
|
9
10
|
|
|
10
|
-
function lastClickedNode(params) {
|
|
11
|
-
const { lastClickedNode: lastClickedNode2 } = params.context;
|
|
12
|
-
if (!lastClickedNode2 || lastClickedNode2.id !== params.event.node.id) {
|
|
13
|
-
return {
|
|
14
|
-
id: params.event.node.id,
|
|
15
|
-
clicks: 1,
|
|
16
|
-
timestamp: Date.now()
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
return {
|
|
20
|
-
id: lastClickedNode2.id,
|
|
21
|
-
clicks: lastClickedNode2.clicks + 1,
|
|
22
|
-
timestamp: Date.now()
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
11
|
function mergeXYNodesEdges({ context, event }) {
|
|
26
12
|
assertEvent(event, "update.view");
|
|
27
13
|
const nextView = event.view;
|
|
@@ -30,35 +16,37 @@ function mergeXYNodesEdges({ context, event }) {
|
|
|
30
16
|
const xynodes = event.xynodes.map((update) => {
|
|
31
17
|
const existing = currentNodes.find((n) => n.id === update.id);
|
|
32
18
|
if (existing) {
|
|
19
|
+
if (existing === update) {
|
|
20
|
+
return existing;
|
|
21
|
+
}
|
|
33
22
|
const { width: existingWidth, height: existingHeight } = getNodeDimensions(existing);
|
|
34
23
|
if (deepEqual(existing.type, update.type) && deepEqual(existingWidth, update.initialWidth) && deepEqual(existingHeight, update.initialHeight) && deepEqual(existing.hidden ?? false, update.hidden ?? false) && deepEqual(existing.position, update.position) && deepEqual(existing.data, update.data) && deepEqual(existing.parentId ?? null, update.parentId ?? null)) {
|
|
35
24
|
return existing;
|
|
36
25
|
}
|
|
37
26
|
return {
|
|
38
|
-
...omit(existing, ["measured", "parentId"]),
|
|
27
|
+
...omit(existing, ["measured", "parentId", "hidden"]),
|
|
39
28
|
...update,
|
|
40
29
|
// Force dimensions from update
|
|
41
30
|
width: update.initialWidth,
|
|
42
|
-
height: update.initialHeight
|
|
43
|
-
data: {
|
|
44
|
-
...existing.data,
|
|
45
|
-
...update.data
|
|
46
|
-
}
|
|
31
|
+
height: update.initialHeight
|
|
47
32
|
};
|
|
48
33
|
}
|
|
49
34
|
return update;
|
|
50
35
|
});
|
|
51
36
|
let xyedges = event.xyedges;
|
|
52
|
-
if (isSameView && !nextView.
|
|
37
|
+
if (isSameView && (!nextView.drifts || nextView.drifts.length === 0)) {
|
|
53
38
|
const currentEdges = context.xyedges;
|
|
54
39
|
xyedges = event.xyedges.map((update) => {
|
|
55
40
|
const existing = currentEdges.find((n) => n.id === update.id);
|
|
41
|
+
if (existing === update) {
|
|
42
|
+
return existing;
|
|
43
|
+
}
|
|
56
44
|
if (existing && existing.type === update.type) {
|
|
57
45
|
if (deepEqual(existing.hidden ?? false, update.hidden ?? false) && deepEqual(existing.data, update.data) && deepEqual(existing.source, update.source) && deepEqual(existing.target, update.target) && deepEqual(existing.sourceHandle, update.sourceHandle) && deepEqual(existing.targetHandle, update.targetHandle)) {
|
|
58
46
|
return existing;
|
|
59
47
|
}
|
|
60
48
|
return {
|
|
61
|
-
...omit(existing, ["sourceHandle", "targetHandle"]),
|
|
49
|
+
...omit(existing, ["hidden", "sourceHandle", "targetHandle"]),
|
|
62
50
|
...update,
|
|
63
51
|
data: {
|
|
64
52
|
...existing.data,
|
|
@@ -69,23 +57,6 @@ function mergeXYNodesEdges({ context, event }) {
|
|
|
69
57
|
return update;
|
|
70
58
|
});
|
|
71
59
|
}
|
|
72
|
-
if (!isSameView) {
|
|
73
|
-
for (const node of xynodes) {
|
|
74
|
-
node.data = {
|
|
75
|
-
...node.data,
|
|
76
|
-
dimmed: false,
|
|
77
|
-
hovered: false
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
for (const edge of xyedges) {
|
|
81
|
-
edge.data = {
|
|
82
|
-
...edge.data,
|
|
83
|
-
dimmed: false,
|
|
84
|
-
hovered: false,
|
|
85
|
-
active: false
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
60
|
return {
|
|
90
61
|
xynodes,
|
|
91
62
|
xyedges,
|
|
@@ -236,6 +207,7 @@ function navigateForward({ context }) {
|
|
|
236
207
|
};
|
|
237
208
|
}
|
|
238
209
|
function updateNodeData({ context, event }) {
|
|
210
|
+
console.log("updateNodeData called", event);
|
|
239
211
|
assertEvent(event, "update.nodeData");
|
|
240
212
|
const xynodes = context.xynodes.map((node) => {
|
|
241
213
|
if (node.id !== event.nodeId) {
|
|
@@ -269,66 +241,30 @@ function updateEdgeData({ context, event }) {
|
|
|
269
241
|
});
|
|
270
242
|
return { xyedges };
|
|
271
243
|
}
|
|
272
|
-
function
|
|
273
|
-
const
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
if (!source || !target) {
|
|
292
|
-
return [];
|
|
293
|
-
}
|
|
294
|
-
const sourceCenter = getNodeCenter(source, xynodes);
|
|
295
|
-
const targetCenter = getNodeCenter(target, xynodes);
|
|
296
|
-
if (!sourceCenter || !targetCenter) {
|
|
297
|
-
return [];
|
|
298
|
-
}
|
|
299
|
-
if (source === target) {
|
|
300
|
-
const loopSize = 80;
|
|
301
|
-
const centerOfTopBoundary = new VectorImpl(0, source.height || 0).mul(-0.5).add(sourceCenter);
|
|
302
|
-
return [
|
|
303
|
-
centerOfTopBoundary.add(new VectorImpl(-loopSize / 2.5, -loopSize)),
|
|
304
|
-
centerOfTopBoundary.add(new VectorImpl(loopSize / 2.5, -loopSize))
|
|
305
|
-
];
|
|
306
|
-
}
|
|
307
|
-
const sourceToTargetVector = targetCenter.sub(sourceCenter);
|
|
308
|
-
const sourceBorderPoint = getBorderPointOnVector(source, sourceCenter, sourceToTargetVector);
|
|
309
|
-
const targetBorderPoint = getBorderPointOnVector(target, targetCenter, sourceToTargetVector.mul(-1));
|
|
310
|
-
return [sourceBorderPoint.add(targetBorderPoint.sub(sourceBorderPoint).mul(0.3))];
|
|
311
|
-
}
|
|
312
|
-
function getBorderPointOnVector(node, nodeCenter, v) {
|
|
313
|
-
const xScale = (node.width || 0) / 2 / v.x;
|
|
314
|
-
const yScale = (node.height || 0) / 2 / v.y;
|
|
315
|
-
const scale = Math.min(Math.abs(xScale), Math.abs(yScale));
|
|
316
|
-
return vector(v).mul(scale).add(nodeCenter);
|
|
244
|
+
function getBorderPointOnVector(node, nodeCenter, v) {
|
|
245
|
+
const dimensions = getNodeDimensions(node);
|
|
246
|
+
const xScale = dimensions.width / 2 / v.x;
|
|
247
|
+
const yScale = dimensions.height / 2 / v.y;
|
|
248
|
+
const scale = Math.min(Math.abs(xScale), Math.abs(yScale));
|
|
249
|
+
return vector(v).multiply(scale).add(nodeCenter);
|
|
250
|
+
}
|
|
251
|
+
function resetEdgeControlPoints(nodeLookup, edge) {
|
|
252
|
+
const source = nonNullable(nodeLookup.get(edge.source), `Source node ${edge.source} not found`);
|
|
253
|
+
const target = nonNullable(nodeLookup.get(edge.target), `Target node ${edge.target} not found`);
|
|
254
|
+
const sourceCenter = vector(getNodeCenter(source));
|
|
255
|
+
const targetCenter = vector(getNodeCenter(target));
|
|
256
|
+
if (source === target) {
|
|
257
|
+
const loopSize = 80;
|
|
258
|
+
const centerOfTopBoundary = vector(0, source.height || 0).multiply(-0.5).add(sourceCenter);
|
|
259
|
+
return [
|
|
260
|
+
centerOfTopBoundary.add(vector(-loopSize / 2.5, -loopSize)),
|
|
261
|
+
centerOfTopBoundary.add(vector(loopSize / 2.5, -loopSize))
|
|
262
|
+
];
|
|
317
263
|
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
}
|
|
323
|
-
return {
|
|
324
|
-
...edge,
|
|
325
|
-
data: {
|
|
326
|
-
...edge.data,
|
|
327
|
-
controlPoints: getControlPointForEdge(edge)
|
|
328
|
-
}
|
|
329
|
-
};
|
|
330
|
-
})
|
|
331
|
-
};
|
|
264
|
+
const sourceToTargetVector = targetCenter.subtract(sourceCenter);
|
|
265
|
+
const sourceBorderPoint = getBorderPointOnVector(source, sourceCenter, sourceToTargetVector);
|
|
266
|
+
const targetBorderPoint = getBorderPointOnVector(target, targetCenter, sourceToTargetVector.multiply(-1));
|
|
267
|
+
return [sourceBorderPoint.add(targetBorderPoint.subtract(sourceBorderPoint).multiply(0.4))];
|
|
332
268
|
}
|
|
333
269
|
function updateActiveWalkthrough({ context }) {
|
|
334
270
|
const { stepId, parallelPrefix } = nonNullable(context.activeWalkthrough, "activeWalkthrough is null");
|
|
@@ -354,4 +290,4 @@ function updateActiveWalkthrough({ context }) {
|
|
|
354
290
|
};
|
|
355
291
|
}
|
|
356
292
|
|
|
357
|
-
export { focusNodesEdges,
|
|
293
|
+
export { focusNodesEdges, mergeXYNodesEdges, navigateBack, navigateForward, resetEdgeControlPoints, updateActiveWalkthrough, updateEdgeData, updateNavigationHistory, updateNodeData };
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { getNodeDimensions } from '@xyflow/system';
|
|
2
|
+
import { indexBy, map, omit, hasAtLeast } from 'remeda';
|
|
3
|
+
import { calcViewBounds } from '../../utils/view-bounds.js';
|
|
4
|
+
import { isSamePoint, bezierControlPoints } from '../../utils/xyflow.js';
|
|
5
|
+
|
|
6
|
+
function createViewChange(parentContext) {
|
|
7
|
+
const {
|
|
8
|
+
view: {
|
|
9
|
+
drifts: _1,
|
|
10
|
+
// Ignore drifts from view
|
|
11
|
+
_layout: _2,
|
|
12
|
+
// Ignore layout type from view
|
|
13
|
+
...view
|
|
14
|
+
},
|
|
15
|
+
xynodes,
|
|
16
|
+
xyedges,
|
|
17
|
+
xystore
|
|
18
|
+
} = parentContext;
|
|
19
|
+
const { nodeLookup } = xystore.getState();
|
|
20
|
+
const movedNodes = /* @__PURE__ */ new Set();
|
|
21
|
+
const xynodesLookup = indexBy(xynodes, (n) => n.data.id);
|
|
22
|
+
const xyedgesLookup = indexBy(xyedges, (e) => e.data.id);
|
|
23
|
+
const nodes = map(view.nodes, (node) => {
|
|
24
|
+
const xynode = xynodesLookup[node.id];
|
|
25
|
+
if (!xynode) {
|
|
26
|
+
return node;
|
|
27
|
+
}
|
|
28
|
+
const internal = nodeLookup.get(xynode.id);
|
|
29
|
+
const dimensions = getNodeDimensions(internal);
|
|
30
|
+
const isChanged = !isSamePoint(internal.internals.positionAbsolute, node) || node.width !== dimensions.width || node.height !== dimensions.height || node.shape !== xynode.data.shape || node.color !== xynode.data.color || node.style.border !== xynode.data.style.border || node.style.opacity !== xynode.data.style.opacity;
|
|
31
|
+
if (!isChanged) {
|
|
32
|
+
return node;
|
|
33
|
+
}
|
|
34
|
+
movedNodes.add(xynode.id);
|
|
35
|
+
return {
|
|
36
|
+
...node,
|
|
37
|
+
shape: xynode.data.shape,
|
|
38
|
+
color: xynode.data.color,
|
|
39
|
+
style: {
|
|
40
|
+
...node.style,
|
|
41
|
+
...xynode.data.style
|
|
42
|
+
},
|
|
43
|
+
x: Math.floor(internal.internals.positionAbsolute.x),
|
|
44
|
+
y: Math.floor(internal.internals.positionAbsolute.y),
|
|
45
|
+
width: Math.ceil(dimensions.width),
|
|
46
|
+
height: Math.ceil(dimensions.height)
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
|
+
const edges = map(view.edges, (edge) => {
|
|
50
|
+
const xyedge = xyedgesLookup[edge.id];
|
|
51
|
+
if (!xyedge) {
|
|
52
|
+
return edge;
|
|
53
|
+
}
|
|
54
|
+
const data = xyedge.data;
|
|
55
|
+
let controlPoints = data.controlPoints ?? [];
|
|
56
|
+
const sourceOrTargetMoved = movedNodes.has(xyedge.source) || movedNodes.has(xyedge.target);
|
|
57
|
+
if (controlPoints.length === 0 && sourceOrTargetMoved) {
|
|
58
|
+
controlPoints = bezierControlPoints(data.points);
|
|
59
|
+
}
|
|
60
|
+
const _updated = {
|
|
61
|
+
...omit(edge, ["controlPoints"]),
|
|
62
|
+
points: data.points
|
|
63
|
+
};
|
|
64
|
+
if (data.labelXY && data.labelBBox) {
|
|
65
|
+
_updated.labelBBox = {
|
|
66
|
+
...data.labelBBox,
|
|
67
|
+
...data.labelXY
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
if (data.labelBBox) {
|
|
71
|
+
_updated.labelBBox ??= data.labelBBox;
|
|
72
|
+
}
|
|
73
|
+
if (hasAtLeast(controlPoints, 1)) {
|
|
74
|
+
_updated.controlPoints = controlPoints;
|
|
75
|
+
}
|
|
76
|
+
return _updated;
|
|
77
|
+
});
|
|
78
|
+
const snapshot = {
|
|
79
|
+
...view,
|
|
80
|
+
bounds: calcViewBounds({ nodes, edges }),
|
|
81
|
+
nodes,
|
|
82
|
+
edges
|
|
83
|
+
};
|
|
84
|
+
return {
|
|
85
|
+
op: "save-view-snapshot",
|
|
86
|
+
layout: snapshot
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export { createViewChange };
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { DynamicViewDisplayVariant, NodeNotation as ElementNotation, ViewChange } from '@likec4/core/types';
|
|
2
|
+
import { PartialDeep } from 'type-fest';
|
|
3
|
+
import { FeatureName } from '../../context/DiagramFeatures';
|
|
4
|
+
import { OpenSourceParams } from '../../LikeC4Diagram.props';
|
|
5
|
+
import { Types } from '../types';
|
|
6
|
+
import { AlignmentMode } from './aligners';
|
|
7
|
+
import { DiagramActorEvent, DiagramActorRef, DiagramActorSnapshot, DiagramContext } from './types';
|
|
8
|
+
import type * as t from '@likec4/core/types';
|
|
9
|
+
type Any = t.aux.Any;
|
|
10
|
+
type Unknown = t.aux.UnknownLayouted;
|
|
11
|
+
type ViewId<A> = t.aux.ViewId<A>;
|
|
12
|
+
type Fqn<A> = t.aux.Fqn<A>;
|
|
13
|
+
type NodeId = t.aux.NodeId;
|
|
14
|
+
type EdgeId = t.aux.EdgeId;
|
|
15
|
+
export interface DiagramApi<A extends Any = Unknown> {
|
|
16
|
+
readonly actor: DiagramActorRef;
|
|
17
|
+
/**
|
|
18
|
+
* @warning Do not use in render phase
|
|
19
|
+
*/
|
|
20
|
+
readonly currentView: t.DiagramView<A>;
|
|
21
|
+
/**
|
|
22
|
+
* Send event to diagram actor
|
|
23
|
+
*/
|
|
24
|
+
send(event: DiagramActorEvent): void;
|
|
25
|
+
/**
|
|
26
|
+
* Navigate to view
|
|
27
|
+
*/
|
|
28
|
+
navigateTo(viewId: ViewId<A>, fromNode?: NodeId): void;
|
|
29
|
+
/**
|
|
30
|
+
* Navigate back or forward in history
|
|
31
|
+
*/
|
|
32
|
+
navigate(direction: 'back' | 'forward'): void;
|
|
33
|
+
/**
|
|
34
|
+
* Fit diagram to view
|
|
35
|
+
*/
|
|
36
|
+
fitDiagram(duration?: number): void;
|
|
37
|
+
/**
|
|
38
|
+
* Open relationships browser
|
|
39
|
+
*/
|
|
40
|
+
openRelationshipsBrowser(fqn: Fqn<A>): void;
|
|
41
|
+
/**
|
|
42
|
+
* If running in editor, trigger opening source file
|
|
43
|
+
*/
|
|
44
|
+
openSource(params: OpenSourceParams<A>): void;
|
|
45
|
+
/**
|
|
46
|
+
* Open element details card
|
|
47
|
+
*/
|
|
48
|
+
openElementDetails(fqn: Fqn<A>, fromNode?: NodeId): void;
|
|
49
|
+
openRelationshipDetails(...params: [edgeId: EdgeId] | [source: Fqn<A>, target: Fqn<A>]): void;
|
|
50
|
+
updateNodeData(nodeId: NodeId, data: PartialDeep<Types.NodeData>): void;
|
|
51
|
+
updateEdgeData(edgeId: EdgeId, data: PartialDeep<Types.EdgeData>): void;
|
|
52
|
+
/**
|
|
53
|
+
* Start editing, either node or edge
|
|
54
|
+
*/
|
|
55
|
+
startEditing(subject: 'node' | 'edge'): void;
|
|
56
|
+
/**
|
|
57
|
+
* Stop editing
|
|
58
|
+
* @param wasChanged - whether there were changes made during editing
|
|
59
|
+
* @default false
|
|
60
|
+
*/
|
|
61
|
+
stopEditing(wasChanged?: boolean): void;
|
|
62
|
+
/**
|
|
63
|
+
* Undo last editing operation
|
|
64
|
+
* @returns true if there was something to undo
|
|
65
|
+
*/
|
|
66
|
+
undoEditing(): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Align nodes
|
|
69
|
+
*/
|
|
70
|
+
align(mode: AlignmentMode): void;
|
|
71
|
+
/**
|
|
72
|
+
* Reset edge control points
|
|
73
|
+
*/
|
|
74
|
+
resetEdgeControlPoints(): void;
|
|
75
|
+
/**
|
|
76
|
+
* Focus node
|
|
77
|
+
*/
|
|
78
|
+
focusNode(nodeId: NodeId): void;
|
|
79
|
+
/**
|
|
80
|
+
* @warning Do not use in render phase
|
|
81
|
+
*/
|
|
82
|
+
getSnapshot(): DiagramActorSnapshot;
|
|
83
|
+
/**
|
|
84
|
+
* @warning Do not use in render phase
|
|
85
|
+
*/
|
|
86
|
+
getContext(): DiagramContext;
|
|
87
|
+
/**
|
|
88
|
+
* @warning Do not use in render phase
|
|
89
|
+
*/
|
|
90
|
+
findDiagramNode(xynodeId: string): t.DiagramNode<A> | null;
|
|
91
|
+
/**
|
|
92
|
+
* @warning Do not use in render phase
|
|
93
|
+
*/
|
|
94
|
+
findEdge(xyedgeId: string): Types.Edge | null;
|
|
95
|
+
/**
|
|
96
|
+
* @warning Do not use in render phase
|
|
97
|
+
*/
|
|
98
|
+
findDiagramEdge(xyedgeId: string): t.DiagramEdge<A> | null;
|
|
99
|
+
startWalkthrough(): void;
|
|
100
|
+
walkthroughStep(direction?: 'next' | 'previous'): void;
|
|
101
|
+
stopWalkthrough(): void;
|
|
102
|
+
toggleFeature(feature: FeatureName, forceValue?: boolean): void;
|
|
103
|
+
highlightNotation(notation: ElementNotation, kind?: string): void;
|
|
104
|
+
unhighlightNotation(): void;
|
|
105
|
+
openSearch(searchValue?: string): void;
|
|
106
|
+
triggerChange(viewChange: ViewChange): void;
|
|
107
|
+
/**
|
|
108
|
+
* Switch dynamic view display variant
|
|
109
|
+
*/
|
|
110
|
+
switchDynamicViewVariant(variant: DynamicViewDisplayVariant): void;
|
|
111
|
+
}
|
|
112
|
+
export declare function makeDiagramApi<A extends Any = Unknown>(actor: DiagramActorRef): DiagramApi<A>;
|
|
113
|
+
export {};
|