@likec4/diagram 1.44.0 → 1.46.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.
Files changed (270) hide show
  1. package/bundle/index.js +18847 -17876
  2. package/dist/LikeC4Diagram.d.ts +1 -1
  3. package/dist/LikeC4Diagram.js +15 -12
  4. package/dist/LikeC4Diagram.props.d.ts +13 -20
  5. package/dist/LikeC4ProjectsProvider.js +8 -4
  6. package/dist/LikeC4Styles.js +0 -3
  7. package/dist/LikeC4View.d.ts +3 -3
  8. package/dist/LikeC4View.js +8 -8
  9. package/dist/ReactLikeC4.d.ts +3 -6
  10. package/dist/StaticLikeC4Diagram.js +0 -2
  11. package/dist/base/Base.d.ts +1 -1
  12. package/dist/base/updateEdges.js +25 -15
  13. package/dist/base/updateNodes.d.ts +14 -0
  14. package/dist/base/updateNodes.js +51 -18
  15. package/dist/base-primitives/Markdown.d.ts +30 -4
  16. package/dist/base-primitives/Markdown.js +3 -2
  17. package/dist/base-primitives/NodeHandles.d.ts +2 -1
  18. package/dist/base-primitives/NodeHandles.js +22 -18
  19. package/dist/base-primitives/compound/CompoundActionButton.d.ts +3 -2
  20. package/dist/base-primitives/compound/CompoundActionButton.js +1 -1
  21. package/dist/base-primitives/compound/CompoundDetailsButton.d.ts +3 -2
  22. package/dist/base-primitives/compound/CompoundDetailsButton.js +1 -1
  23. package/dist/base-primitives/edge/EdgeActionButton.d.ts +3 -2
  24. package/dist/base-primitives/edge/EdgeActionButton.js +1 -1
  25. package/dist/base-primitives/edge/EdgeContainer.d.ts +1 -1
  26. package/dist/base-primitives/edge/EdgeContainer.js +6 -4
  27. package/dist/base-primitives/edge/EdgeLabel.d.ts +2 -2
  28. package/dist/base-primitives/edge/EdgeLabel.js +16 -16
  29. package/dist/base-primitives/edge/EdgeLabelContainer.d.ts +1 -1
  30. package/dist/base-primitives/edge/EdgeLabelContainer.js +5 -4
  31. package/dist/base-primitives/edge/EdgePath.js +27 -12
  32. package/dist/base-primitives/element/ElementActionButtons.d.ts +3 -2
  33. package/dist/base-primitives/element/ElementActionButtons.js +3 -3
  34. package/dist/base-primitives/element/ElementData.d.ts +3 -3
  35. package/dist/base-primitives/element/ElementData.js +13 -7
  36. package/dist/base-primitives/element/ElementDetailsButton.d.ts +3 -2
  37. package/dist/base-primitives/element/ElementDetailsButton.js +4 -1
  38. package/dist/base-primitives/element/ElementShape.js +5 -5
  39. package/dist/base-primitives/element/ElementTags.d.ts +6 -4
  40. package/dist/components/ErrorFallback.js +1 -1
  41. package/dist/components/Link.js +2 -2
  42. package/dist/context/DiagramEventHandlers.js +0 -1
  43. package/dist/context/DiagramFeatures.d.ts +2 -1
  44. package/dist/context/DiagramFeatures.js +1 -0
  45. package/dist/context/EnsureMantine.js +2 -1
  46. package/dist/context/IconRenderer.js +6 -6
  47. package/dist/context/TagStylesContext.js +1 -1
  48. package/dist/custom/hooks.d.ts +2 -2
  49. package/dist/custom/index.js +1 -1
  50. package/dist/editor/LikeC4EditorProvider.d.ts +22 -0
  51. package/dist/editor/LikeC4EditorProvider.js +12 -0
  52. package/dist/editor/__tests__/fixture.d.ts +205 -0
  53. package/dist/editor/applyChangesToManualLayout.d.ts +8 -0
  54. package/dist/editor/applyChangesToManualLayout.js +182 -0
  55. package/dist/editor/editorActor.actions.d.ts +201 -0
  56. package/dist/editor/editorActor.actions.js +149 -0
  57. package/dist/editor/editorActor.d.ts +653 -0
  58. package/dist/editor/editorActor.js +324 -0
  59. package/dist/editor/hotkeyActor.d.ts +7 -0
  60. package/dist/editor/hotkeyActor.js +19 -0
  61. package/dist/editor/index.d.ts +3 -2
  62. package/dist/editor/useEditorActorLogic.d.ts +565 -0
  63. package/dist/editor/useEditorActorLogic.js +54 -0
  64. package/dist/hooks/index.d.ts +2 -1
  65. package/dist/hooks/safeContext.d.ts +3 -2
  66. package/dist/hooks/safeContext.js +7 -4
  67. package/dist/hooks/useDiagram.d.ts +4 -2
  68. package/dist/hooks/useDiagram.js +19 -8
  69. package/dist/hooks/useDiagramCompareLayout.d.ts +8 -0
  70. package/dist/hooks/useDiagramCompareLayout.js +29 -4
  71. package/dist/hooks/useLikeC4Project.d.ts +6 -1
  72. package/dist/hooks/useLikeC4Project.js +14 -2
  73. package/dist/hooks/useMediaPrint.d.ts +6 -0
  74. package/dist/index.d.ts +1 -0
  75. package/dist/index.js +1 -0
  76. package/dist/likec4diagram/DiagramXYFlow.js +11 -7
  77. package/dist/likec4diagram/custom/edges/EdgeDrifts.d.ts +6 -0
  78. package/dist/likec4diagram/custom/edges/EdgeDrifts.js +34 -0
  79. package/dist/likec4diagram/custom/edges/RelationshipEdge.js +90 -54
  80. package/dist/likec4diagram/custom/edges/SequenceStepEdge.js +3 -1
  81. package/dist/likec4diagram/custom/edges/edges.css.d.ts +0 -1
  82. package/dist/likec4diagram/custom/edges/edges.css.js +30 -24
  83. package/dist/likec4diagram/custom/edges/useControlPoints.js +5 -5
  84. package/dist/likec4diagram/custom/edges/useRelationshipEdgePath.js +5 -5
  85. package/dist/likec4diagram/custom/nodes/ElementActions.js +2 -2
  86. package/dist/likec4diagram/custom/nodes/NodeDrifts.d.ts +6 -0
  87. package/dist/likec4diagram/custom/nodes/{ElementNodeDrifts.js → NodeDrifts.js} +12 -13
  88. package/dist/likec4diagram/custom/nodes/SequenceActorNode.js +4 -2
  89. package/dist/likec4diagram/custom/nodes/index.d.ts +1 -0
  90. package/dist/likec4diagram/custom/nodes/nodes.js +61 -23
  91. package/dist/likec4diagram/custom/nodes/toolbar/ElementToolbar.js +2 -2
  92. package/dist/likec4diagram/custom/nodes/toolbar/_shared.js +2 -2
  93. package/dist/likec4diagram/relationship-popover/RelationshipPopover.js +128 -15
  94. package/dist/likec4diagram/relationship-popover/actor.d.ts +1 -1
  95. package/dist/likec4diagram/state/DiagramActorProvider.d.ts +2 -2
  96. package/dist/likec4diagram/state/DiagramActorProvider.js +63 -72
  97. package/dist/likec4diagram/state/assign.d.ts +14 -7
  98. package/dist/likec4diagram/state/assign.js +28 -200
  99. package/dist/likec4diagram/state/createViewChange.js +23 -30
  100. package/dist/likec4diagram/state/diagram-api.d.ts +20 -6
  101. package/dist/likec4diagram/state/diagram-api.js +58 -52
  102. package/dist/likec4diagram/state/hotkeyActor.d.ts +1 -8
  103. package/dist/likec4diagram/state/hotkeyActor.js +13 -17
  104. package/dist/likec4diagram/state/machine.actions.d.ts +1127 -864
  105. package/dist/likec4diagram/state/machine.actions.js +316 -296
  106. package/dist/likec4diagram/state/machine.actions.layout.d.ts +641 -0
  107. package/dist/likec4diagram/state/machine.actions.layout.js +141 -0
  108. package/dist/likec4diagram/state/machine.d.ts +18 -3712
  109. package/dist/likec4diagram/state/machine.js +64 -73
  110. package/dist/likec4diagram/state/machine.setup.d.ts +80 -26
  111. package/dist/likec4diagram/state/machine.setup.js +44 -7
  112. package/dist/likec4diagram/state/machine.state.initializing.d.ts +58 -17
  113. package/dist/likec4diagram/state/machine.state.initializing.js +14 -14
  114. package/dist/likec4diagram/state/machine.state.navigating.d.ts +5 -108
  115. package/dist/likec4diagram/state/machine.state.navigating.js +187 -35
  116. package/dist/likec4diagram/state/machine.state.ready.d.ts +2997 -2598
  117. package/dist/likec4diagram/state/machine.state.ready.focused.d.ts +710 -0
  118. package/dist/likec4diagram/state/machine.state.ready.focused.js +98 -0
  119. package/dist/likec4diagram/state/machine.state.ready.idle.d.ts +540 -0
  120. package/dist/likec4diagram/state/machine.state.ready.idle.js +105 -0
  121. package/dist/likec4diagram/state/machine.state.ready.js +95 -347
  122. package/dist/likec4diagram/state/machine.state.ready.printing.d.ts +140 -0
  123. package/dist/likec4diagram/state/machine.state.ready.printing.js +40 -0
  124. package/dist/likec4diagram/state/machine.state.ready.walkthrough.d.ts +684 -0
  125. package/dist/likec4diagram/state/machine.state.ready.walkthrough.js +190 -0
  126. package/dist/likec4diagram/state/mediaPrintActor.d.ts +12 -0
  127. package/dist/likec4diagram/state/mediaPrintActor.js +18 -0
  128. package/dist/likec4diagram/state/types.d.ts +11 -9
  129. package/dist/likec4diagram/state/utils.d.ts +44 -5
  130. package/dist/likec4diagram/state/utils.js +62 -6
  131. package/dist/likec4diagram/types.d.ts +8 -13
  132. package/dist/likec4diagram/ui/notation/NotationPanel.css.js +5 -2
  133. package/dist/likec4diagram/ui/notation/NotationPanel.js +3 -3
  134. package/dist/likec4diagram/useLayoutConstraints.js +104 -103
  135. package/dist/likec4diagram/xyflow-diagram/diagram-view.js +12 -15
  136. package/dist/likec4diagram/xyflow-sequence/sequence-layout.js +11 -8
  137. package/dist/navigationpanel/NavigationPanel.js +11 -10
  138. package/dist/navigationpanel/NavigationPanelDropdown.js +7 -7
  139. package/dist/navigationpanel/_common.js +1 -1
  140. package/dist/navigationpanel/actor.d.ts +4 -204
  141. package/dist/navigationpanel/actor.js +1 -1
  142. package/dist/navigationpanel/comparepanel/CompareActionsMenu.d.ts +3 -1
  143. package/dist/navigationpanel/comparepanel/CompareActionsMenu.js +40 -14
  144. package/dist/navigationpanel/comparepanel/ComparePanelControls.js +6 -4
  145. package/dist/navigationpanel/comparepanel/LayoutTypeSwitcher.js +2 -2
  146. package/dist/navigationpanel/controls/DetailsControls.js +2 -2
  147. package/dist/navigationpanel/controls/LayoutWarning.js +2 -1
  148. package/dist/navigationpanel/controls/NavigationButtons.js +2 -2
  149. package/dist/navigationpanel/controls/OpenSource.js +1 -1
  150. package/dist/navigationpanel/controls/SearchControl.js +2 -2
  151. package/dist/navigationpanel/controls/ToggleReadonly.js +32 -19
  152. package/dist/navigationpanel/dropdown/ProjectsMenu.js +1 -1
  153. package/dist/navigationpanel/editorpanel/CenterCamera.js +1 -1
  154. package/dist/navigationpanel/editorpanel/ChangeAutoLayoutButton.js +1 -1
  155. package/dist/navigationpanel/editorpanel/ManualLayoutToolsButton.js +9 -9
  156. package/dist/navigationpanel/editorpanel/ToggleReadonly.js +1 -1
  157. package/dist/navigationpanel/walkthrough/ActiveWalkthroughControls.js +3 -3
  158. package/dist/navigationpanel/walkthrough/DynamicViewControls.d.ts +9 -9
  159. package/dist/navigationpanel/walkthrough/DynamicViewControls.js +1 -1
  160. package/dist/navigationpanel/walkthrough/WalkthroughPanel.js +4 -3
  161. package/dist/overlays/Overlays.js +24 -12
  162. package/dist/overlays/element-details/ElementDetailsCard.css.js +3 -3
  163. package/dist/overlays/element-details/ElementDetailsCard.js +4 -4
  164. package/dist/overlays/element-details/MetadataValue.d.ts +2 -1
  165. package/dist/overlays/element-details/MetadataValue.js +4 -6
  166. package/dist/overlays/element-details/TabPanelDeployments.js +3 -3
  167. package/dist/overlays/element-details/TabPanelRelationships.js +12 -7
  168. package/dist/overlays/element-details/TabPanelStructure.js +1 -1
  169. package/dist/overlays/element-details/actor.d.ts +8 -83
  170. package/dist/overlays/element-details/actor.js +0 -8
  171. package/dist/overlays/overlay/Overlay.js +10 -10
  172. package/dist/overlays/overlaysActor.d.ts +7 -392
  173. package/dist/overlays/overlaysActor.js +73 -49
  174. package/dist/overlays/relationship-details/RelationshipDetails.js +3 -3
  175. package/dist/overlays/relationship-details/SelectEdge.js +2 -2
  176. package/dist/overlays/relationship-details/_types.d.ts +3 -4
  177. package/dist/overlays/relationship-details/actor.d.ts +6 -562
  178. package/dist/overlays/relationship-details/actor.js +1 -0
  179. package/dist/overlays/relationship-details/custom/ElementActions.js +3 -3
  180. package/dist/overlays/relationship-details/layout-to-xyflow.js +3 -5
  181. package/dist/overlays/relationship-details/layout.d.ts +3 -3
  182. package/dist/overlays/relationship-details/layout.js +4 -4
  183. package/dist/overlays/relationships-browser/RelationshipsBrowser.js +3 -3
  184. package/dist/overlays/relationships-browser/SelectElement.js +2 -2
  185. package/dist/overlays/relationships-browser/_types.d.ts +2 -3
  186. package/dist/overlays/relationships-browser/actor.d.ts +7 -739
  187. package/dist/overlays/relationships-browser/custom/ElementActions.js +3 -3
  188. package/dist/overlays/relationships-browser/layout.d.ts +2 -2
  189. package/dist/overlays/relationships-browser/layout.js +3 -3
  190. package/dist/overlays/relationships-browser/useViewToNodesEdges.js +0 -3
  191. package/dist/overlays/types.d.ts +12 -13
  192. package/dist/search/components/ElementsColumn.js +7 -3
  193. package/dist/search/components/PickView.js +3 -1
  194. package/dist/search/components/SearchByTags.js +1 -1
  195. package/dist/search/components/SearchInput.js +1 -1
  196. package/dist/search/components/ViewsColum.d.ts +3 -1
  197. package/dist/search/components/ViewsColum.js +13 -7
  198. package/dist/search/components/_shared.css.d.ts +1 -1
  199. package/dist/search/searchActor.d.ts +3 -66
  200. package/dist/shadowroot/ShadowRoot.d.ts +5 -7
  201. package/dist/shadowroot/ShadowRoot.js +7 -5
  202. package/dist/shadowroot/styles.css.js +6 -1
  203. package/dist/styles.css2.js +1 -1
  204. package/dist/utils/index.d.ts +2 -2
  205. package/dist/utils/view-bounds.js +7 -6
  206. package/dist/utils/xyflow.d.ts +6 -5
  207. package/dist/utils/xyflow.js +26 -57
  208. package/package.json +24 -23
  209. package/panda.buildinfo.json +65 -71
  210. package/styles-min.css +1 -1
  211. package/styles.css +1 -1
  212. package/dist/base-primitives/edge/edge.css.d.ts +0 -4
  213. package/dist/base-primitives/edge/edge.css.js +0 -71
  214. package/dist/editor/LikeC4EditorContext.d.ts +0 -21
  215. package/dist/likec4diagram/custom/nodes/ElementNodeDrifts.d.ts +0 -4
  216. package/dist/likec4diagram/state/syncManualLayoutActor.d.ts +0 -280
  217. package/dist/likec4diagram/state/syncManualLayoutActor.js +0 -248
  218. package/dist/utils/vector.d.ts +0 -81
  219. package/dist/utils/vector.js +0 -120
  220. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.35.0_react@19.2.1}/node_modules/@tabler/icons-react/dist/esm/createReactComponent.js +0 -0
  221. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.35.0_react@19.2.1}/node_modules/@tabler/icons-react/dist/esm/defaultAttributes.js +0 -0
  222. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.35.0_react@19.2.1}/node_modules/@tabler/icons-react/dist/esm/icons/IconAlertTriangle.js +0 -0
  223. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.35.0_react@19.2.1}/node_modules/@tabler/icons-react/dist/esm/icons/IconArrowDownRight.js +0 -0
  224. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.35.0_react@19.2.1}/node_modules/@tabler/icons-react/dist/esm/icons/IconArrowLeft.js +0 -0
  225. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.35.0_react@19.2.1}/node_modules/@tabler/icons-react/dist/esm/icons/IconArrowRight.js +0 -0
  226. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.35.0_react@19.2.1}/node_modules/@tabler/icons-react/dist/esm/icons/IconBolt.js +0 -0
  227. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.35.0_react@19.2.1}/node_modules/@tabler/icons-react/dist/esm/icons/IconBrowser.js +0 -0
  228. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.35.0_react@19.2.1}/node_modules/@tabler/icons-react/dist/esm/icons/IconCheck.js +0 -0
  229. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.35.0_react@19.2.1}/node_modules/@tabler/icons-react/dist/esm/icons/IconChevronDown.js +0 -0
  230. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.35.0_react@19.2.1}/node_modules/@tabler/icons-react/dist/esm/icons/IconChevronLeft.js +0 -0
  231. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.35.0_react@19.2.1}/node_modules/@tabler/icons-react/dist/esm/icons/IconChevronRight.js +0 -0
  232. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.35.0_react@19.2.1}/node_modules/@tabler/icons-react/dist/esm/icons/IconCopy.js +0 -0
  233. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.35.0_react@19.2.1}/node_modules/@tabler/icons-react/dist/esm/icons/IconCylinder.js +0 -0
  234. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.35.0_react@19.2.1}/node_modules/@tabler/icons-react/dist/esm/icons/IconDeviceMobile.js +0 -0
  235. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.35.0_react@19.2.1}/node_modules/@tabler/icons-react/dist/esm/icons/IconDirectionSignFilled.js +0 -0
  236. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.35.0_react@19.2.1}/node_modules/@tabler/icons-react/dist/esm/icons/IconExternalLink.js +0 -0
  237. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.35.0_react@19.2.1}/node_modules/@tabler/icons-react/dist/esm/icons/IconFileSymlink.js +0 -0
  238. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.35.0_react@19.2.1}/node_modules/@tabler/icons-react/dist/esm/icons/IconFocusCentered.js +0 -0
  239. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.35.0_react@19.2.1}/node_modules/@tabler/icons-react/dist/esm/icons/IconFolderFilled.js +0 -0
  240. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.35.0_react@19.2.1}/node_modules/@tabler/icons-react/dist/esm/icons/IconHelpCircle.js +0 -0
  241. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.35.0_react@19.2.1}/node_modules/@tabler/icons-react/dist/esm/icons/IconId.js +0 -0
  242. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.35.0_react@19.2.1}/node_modules/@tabler/icons-react/dist/esm/icons/IconInfoCircle.js +0 -0
  243. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.35.0_react@19.2.1}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutAlignBottom.js +0 -0
  244. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.35.0_react@19.2.1}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutAlignCenter.js +0 -0
  245. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.35.0_react@19.2.1}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutAlignLeft.js +0 -0
  246. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.35.0_react@19.2.1}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutAlignMiddle.js +0 -0
  247. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.35.0_react@19.2.1}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutAlignRight.js +0 -0
  248. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.35.0_react@19.2.1}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutAlignTop.js +0 -0
  249. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.35.0_react@19.2.1}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutBoardSplit.js +0 -0
  250. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.35.0_react@19.2.1}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutCollage.js +0 -0
  251. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.35.0_react@19.2.1}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutDashboard.js +0 -0
  252. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.35.0_react@19.2.1}/node_modules/@tabler/icons-react/dist/esm/icons/IconLink.js +0 -0
  253. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.35.0_react@19.2.1}/node_modules/@tabler/icons-react/dist/esm/icons/IconLock.js +0 -0
  254. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.35.0_react@19.2.1}/node_modules/@tabler/icons-react/dist/esm/icons/IconLockOpen2.js +0 -0
  255. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.35.0_react@19.2.1}/node_modules/@tabler/icons-react/dist/esm/icons/IconPlayerPlayFilled.js +0 -0
  256. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.35.0_react@19.2.1}/node_modules/@tabler/icons-react/dist/esm/icons/IconPlayerSkipBackFilled.js +0 -0
  257. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.35.0_react@19.2.1}/node_modules/@tabler/icons-react/dist/esm/icons/IconPlayerSkipForwardFilled.js +0 -0
  258. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.35.0_react@19.2.1}/node_modules/@tabler/icons-react/dist/esm/icons/IconPlayerStopFilled.js +0 -0
  259. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.35.0_react@19.2.1}/node_modules/@tabler/icons-react/dist/esm/icons/IconRectangularPrism.js +0 -0
  260. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.35.0_react@19.2.1}/node_modules/@tabler/icons-react/dist/esm/icons/IconReorder.js +0 -0
  261. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.35.0_react@19.2.1}/node_modules/@tabler/icons-react/dist/esm/icons/IconRouteOff.js +0 -0
  262. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.35.0_react@19.2.1}/node_modules/@tabler/icons-react/dist/esm/icons/IconSearch.js +0 -0
  263. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.35.0_react@19.2.1}/node_modules/@tabler/icons-react/dist/esm/icons/IconSelector.js +0 -0
  264. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.35.0_react@19.2.1}/node_modules/@tabler/icons-react/dist/esm/icons/IconStack2.js +0 -0
  265. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.35.0_react@19.2.1}/node_modules/@tabler/icons-react/dist/esm/icons/IconStarFilled.js +0 -0
  266. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.35.0_react@19.2.1}/node_modules/@tabler/icons-react/dist/esm/icons/IconTarget.js +0 -0
  267. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.35.0_react@19.2.1}/node_modules/@tabler/icons-react/dist/esm/icons/IconTransform.js +0 -0
  268. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.35.0_react@19.2.1}/node_modules/@tabler/icons-react/dist/esm/icons/IconUser.js +0 -0
  269. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.35.0_react@19.2.1}/node_modules/@tabler/icons-react/dist/esm/icons/IconX.js +0 -0
  270. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.35.0_react@19.2.1}/node_modules/@tabler/icons-react/dist/esm/icons/IconZoomScan.js +0 -0
@@ -1,13 +1,13 @@
1
1
  import { DiagramView, DynamicViewDisplayVariant, WhereOperator } from '@likec4/core/types';
2
2
  import { PropsWithChildren } from 'react';
3
- import { ViewPadding } from '../../LikeC4Diagram.props';
3
+ import { ViewPaddings } from '../../LikeC4Diagram.props';
4
4
  export declare function DiagramActorProvider({ view, zoomable, pannable, nodesDraggable, nodesSelectable, fitViewPadding, where, children, dynamicViewVariant: _defaultVariant, }: PropsWithChildren<{
5
5
  view: DiagramView;
6
6
  zoomable: boolean;
7
7
  pannable: boolean;
8
8
  nodesDraggable: boolean;
9
9
  nodesSelectable: boolean;
10
- fitViewPadding: ViewPadding;
10
+ fitViewPadding: ViewPaddings;
11
11
  where: WhereOperator | null;
12
12
  dynamicViewVariant: DynamicViewDisplayVariant | undefined;
13
13
  }>): import("react/jsx-runtime").JSX.Element;
@@ -1,19 +1,19 @@
1
- import { jsxs, jsx } from 'react/jsx-runtime';
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
2
  import { useRafEffect } from '@react-hookz/web';
3
3
  import { useActorRef, useSelector } from '@xstate/react';
4
4
  import { useStoreApi } from '@xyflow/react';
5
5
  import { shallowEqual } from 'fast-equals';
6
- import { useState, useEffect, memo, useRef } from 'react';
7
- import { isNullish } from 'remeda';
6
+ import { useRef, useState, useEffect, memo } from 'react';
7
+ import { omitBy, isNullish } from 'remeda';
8
8
  import { ErrorBoundary } from '../../components/ErrorFallback.js';
9
9
  import { useDiagramEventHandlers } from '../../context/DiagramEventHandlers.js';
10
10
  import { useEnabledFeatures, DiagramFeatures } from '../../context/DiagramFeatures.js';
11
11
  import { CurrentViewModelContext } from '../../context/LikeC4ModelContext.js';
12
- import { DiagramActorContextProvider, useDiagram } from '../../hooks/safeContext.js';
13
- import { useOnDiagramEvent } from '../../hooks/useDiagram.js';
12
+ import { useEditorActorLogic } from '../../editor/useEditorActorLogic.js';
13
+ import { DiagramActorContextProvider, DiagramApiContextProvider, useDiagram } from '../../hooks/safeContext.js';
14
+ import { useOnDiagramEvent, useDiagramContext } from '../../hooks/useDiagram.js';
14
15
  import { useLikeC4Model } from '../../hooks/useLikeC4Model.js';
15
16
  import { useUpdateEffect } from '../../hooks/useUpdateEffect.js';
16
- import { convertToXYFlow } from '../convert-to-xyflow.js';
17
17
  import { makeDiagramApi } from './diagram-api.js';
18
18
  import { diagramMachine } from './machine.js';
19
19
  import { DiagramToggledFeaturesPersistence } from './persistence.js';
@@ -30,8 +30,13 @@ function DiagramActorProvider({
30
30
  dynamicViewVariant: _defaultVariant
31
31
  }) {
32
32
  const xystore = useStoreApi();
33
- const actorRef = useActorRef(
34
- diagramMachine,
33
+ const editorActor = useEditorActorLogic(view.id);
34
+ const actor = useActorRef(
35
+ diagramMachine.provide({
36
+ actors: {
37
+ editorActor
38
+ }
39
+ }),
35
40
  {
36
41
  id: `diagram`,
37
42
  systemId: "diagram",
@@ -44,55 +49,61 @@ function DiagramActorProvider({
44
49
  fitViewPadding,
45
50
  nodesDraggable,
46
51
  nodesSelectable,
52
+ where,
47
53
  dynamicViewVariant: _defaultVariant
48
54
  }
49
55
  }
50
56
  );
57
+ const actorRef = useRef(actor);
58
+ if (actorRef.current !== actor) {
59
+ console.warn("DiagramMachine actor instance changed", {
60
+ context: {
61
+ previous: actorRef.current.getSnapshot().context,
62
+ current: actor.getSnapshot().context
63
+ }
64
+ });
65
+ actorRef.current = actor;
66
+ }
51
67
  const [api, setApi] = useState(() => makeDiagramApi(actorRef));
52
68
  useEffect(() => {
53
69
  setApi((api2) => {
54
- if (api2.actor === actorRef) return api2;
70
+ if (api2.ref === actorRef) {
71
+ return api2;
72
+ }
73
+ console.warn(
74
+ "DiagramMachine actorRef changed, creating new DiagramApi instance, this should not happen during the lifetime of the actor"
75
+ );
55
76
  return makeDiagramApi(actorRef);
56
77
  });
57
78
  }, [actorRef]);
58
- if (api.actor !== actorRef) {
59
- console.warn("DiagramApi instance changed, this should not happen during the lifetime of the actor");
60
- }
61
79
  const features = useEnabledFeatures();
62
80
  useEffect(
63
- () => actorRef.send({ type: "update.features", features }),
64
- [features, actorRef]
81
+ () => actor.send({ type: "update.features", features }),
82
+ [features, actor]
65
83
  );
66
84
  useEffect(
67
- () => actorRef.send({
85
+ () => actor.send({
68
86
  type: "update.inputs",
69
- inputs: { zoomable, pannable, fitViewPadding, nodesDraggable, nodesSelectable }
87
+ inputs: { zoomable, where, pannable, fitViewPadding, nodesDraggable, nodesSelectable }
70
88
  }),
71
- [zoomable, pannable, fitViewPadding, actorRef, nodesDraggable, nodesSelectable]
89
+ [zoomable, where, pannable, fitViewPadding, actor, nodesDraggable, nodesSelectable]
72
90
  );
73
91
  useUpdateEffect(() => {
74
92
  if (!_defaultVariant) return;
75
- actorRef.send({ type: "switch.dynamicViewVariant", variant: _defaultVariant });
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
- ] }),
93
+ actor.send({ type: "switch.dynamicViewVariant", variant: _defaultVariant });
94
+ }, [_defaultVariant, actor]);
95
+ useRafEffect(
96
+ () => actor.send({ type: "update.view", view, source: "external" }),
97
+ [actor, view]
98
+ );
99
+ return /* @__PURE__ */ jsx(DiagramActorContextProvider, { value: actor, children: /* @__PURE__ */ jsxs(DiagramApiContextProvider, { value: api, children: [
100
+ /* @__PURE__ */ jsx(ErrorBoundary, { children: /* @__PURE__ */ jsx(CurrentViewModelProvider, { actorRef: actor, children }) }),
90
101
  /* @__PURE__ */ jsx(DiagramActorEventListener, {})
91
- ] });
102
+ ] }) });
92
103
  }
93
104
  const selectFromActor = ({ context }) => {
94
105
  let toggledFeatures = context.toggledFeatures;
95
- const hasDrifts = context.view.drifts != null;
106
+ const hasDrifts = context.view.drifts != null && context.view.drifts.length > 0;
96
107
  const enableCompareWithLatest = context.features.enableCompareWithLatest && (toggledFeatures.enableCompareWithLatest ?? false) && isNullish(context.activeWalkthrough) && hasDrifts;
97
108
  const enableReadOnly = context.features.enableReadOnly || toggledFeatures.enableReadOnly || !!context.activeWalkthrough || context.dynamicViewVariant === "sequence" && context.view._type === "dynamic" || enableCompareWithLatest && context.view._layout === "auto";
98
109
  if (toggledFeatures.enableReadOnly !== enableReadOnly || toggledFeatures.enableCompareWithLatest !== enableCompareWithLatest) {
@@ -116,62 +127,42 @@ function CurrentViewModelProvider({ children, actorRef }) {
116
127
  selectFromActor,
117
128
  compareSelected
118
129
  );
119
- useUpdateEffect(() => {
120
- DiagramToggledFeaturesPersistence.write(toggledFeatures);
121
- }, [toggledFeatures]);
122
130
  const likec4model = useLikeC4Model();
123
131
  const viewmodel = likec4model.findView(viewId);
124
132
  return /* @__PURE__ */ jsx(CurrentViewModelContext.Provider, { value: viewmodel, children: /* @__PURE__ */ jsx(DiagramFeatures, { overrides: toggledFeatures, children }) });
125
133
  }
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
134
  const DiagramActorEventListener = memo(() => {
140
135
  const diagram = useDiagram();
141
136
  const {
142
137
  onNavigateTo,
143
138
  onOpenSource,
144
- onChange,
139
+ // onChange,
145
140
  onLayoutTypeChange,
146
141
  handlersRef
147
142
  } = useDiagramEventHandlers();
148
143
  useOnDiagramEvent("openSource", ({ params }) => onOpenSource?.(params));
149
144
  useOnDiagramEvent("navigateTo", ({ viewId }) => onNavigateTo?.(viewId));
150
- useOnDiagramEvent("onChange", ({ change }) => onChange?.({ change }));
151
145
  useOnDiagramEvent("onLayoutTypeChange", ({ layoutType }) => {
152
146
  onLayoutTypeChange?.(layoutType);
153
147
  });
154
- const wasEmitted = useRef(false);
155
- useEffect(() => {
156
- if (wasEmitted.current) return;
157
- let subscription = diagram.actor.on(
158
- "initialized",
159
- ({ instance: xyflow }) => {
160
- try {
161
- handlersRef.current.onInitialized?.({ diagram, xyflow });
162
- } catch (error) {
163
- console.error(error);
164
- } finally {
165
- wasEmitted.current = true;
166
- subscription?.unsubscribe();
167
- subscription = null;
168
- }
148
+ useOnDiagramEvent(
149
+ "initialized",
150
+ ({ instance: xyflow }) => {
151
+ try {
152
+ handlersRef.current.onInitialized?.({ diagram, xyflow });
153
+ } catch (error) {
154
+ console.error(error);
169
155
  }
170
- );
171
- return () => {
172
- subscription?.unsubscribe();
173
- };
174
- }, [diagram]);
156
+ },
157
+ { once: true }
158
+ );
159
+ const toggledFeatures = useDiagramContext(
160
+ (ctx) => ctx.toggledFeatures,
161
+ shallowEqual
162
+ );
163
+ useUpdateEffect(() => {
164
+ DiagramToggledFeaturesPersistence.write(omitBy(toggledFeatures, isNullish));
165
+ }, [toggledFeatures]);
175
166
  return null;
176
167
  });
177
168
 
@@ -1,4 +1,4 @@
1
- import { XYPoint } from '@likec4/core';
1
+ import { LayoutedView, XYPoint } from '@likec4/core';
2
2
  import { NodeLookup } from '@xyflow/system';
3
3
  import { Types } from '../types';
4
4
  import { ActionArg, Context as DiagramContext } from './machine.setup';
@@ -8,12 +8,19 @@ export declare function lastClickedNode(params: {
8
8
  node: Types.Node;
9
9
  };
10
10
  }): DiagramContext['lastClickedNode'];
11
- export declare function mergeXYNodesEdges({ context, event }: ActionArg): Partial<DiagramContext>;
12
- export declare function focusNodesEdges(params: ActionArg): Partial<DiagramContext>;
13
- export declare function updateNavigationHistory({ context, event }: ActionArg): Partial<DiagramContext>;
14
- export declare function navigateBack({ context }: ActionArg): Partial<DiagramContext>;
15
- export declare function navigateForward({ context }: ActionArg): Partial<DiagramContext>;
11
+ export declare function mergeXYNodesEdges(context: Pick<DiagramContext, 'xynodes' | 'xyedges' | 'view'>, event: {
12
+ view: LayoutedView;
13
+ xynodes: Types.Node[];
14
+ xyedges: Types.Edge[];
15
+ }): {
16
+ xynodes: Types.Node[];
17
+ xyedges: Types.Edge[];
18
+ view: LayoutedView;
19
+ };
20
+ export declare function focusNodesEdges(context: DiagramContext): {
21
+ xynodes: Types.Node<"element" | "deployment" | "compound-element" | "compound-deployment" | "view-group" | "seq-actor" | "seq-parallel">[];
22
+ xyedges: Types.Edge<"relationship" | "seq-step">[];
23
+ } | null;
16
24
  export declare function updateNodeData({ context, event }: ActionArg): Partial<DiagramContext>;
17
25
  export declare function updateEdgeData({ context, event }: ActionArg): Partial<DiagramContext>;
18
26
  export declare function resetEdgeControlPoints(nodeLookup: NodeLookup, edge: Types.Edge): [XYPoint] | [XYPoint, XYPoint];
19
- export declare function updateActiveWalkthrough({ context }: ActionArg): Partial<DiagramContext>;
@@ -1,72 +1,38 @@
1
- import { nonNullable, invariant } from '@likec4/core';
1
+ import { nonNullable } from '@likec4/core';
2
+ import { vector } from '@likec4/core/geometry';
2
3
  import { getNodeDimensions } from '@xyflow/system';
3
4
  import { deepEqual } from 'fast-equals';
4
- import { mergeDeep, omit } from 'remeda';
5
+ import { mergeDeep } from 'remeda';
5
6
  import { assertEvent } from 'xstate';
6
- import { vector } from '../../utils/vector.js';
7
7
  import { getNodeCenter } from '../../utils/xyflow.js';
8
- import { SeqParallelAreaColor } from '../xyflow-sequence/const.js';
8
+ import { updateNodes } from '../../base/updateNodes.js';
9
+ import { updateEdges } from '../../base/updateEdges.js';
9
10
  import { Base } from '../../base/Base.js';
10
11
 
11
- function mergeXYNodesEdges({ context, event }) {
12
- assertEvent(event, "update.view");
12
+ function mergeXYNodesEdges(context, event) {
13
13
  const nextView = event.view;
14
- const isSameView = context.view.id === nextView.id;
15
- const currentNodes = context.xynodes;
16
- const xynodes = event.xynodes.map((update) => {
17
- const existing = currentNodes.find((n) => n.id === update.id);
18
- if (existing) {
19
- if (existing === update) {
20
- return existing;
21
- }
22
- const { width: existingWidth, height: existingHeight } = getNodeDimensions(existing);
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)) {
24
- return existing;
25
- }
26
- return {
27
- ...omit(existing, ["measured", "parentId", "hidden"]),
28
- ...update,
29
- // Force dimensions from update
30
- width: update.initialWidth,
31
- height: update.initialHeight
32
- };
33
- }
34
- return update;
35
- });
36
- let xyedges = event.xyedges;
37
- if (isSameView && (!nextView.drifts || nextView.drifts.length === 0)) {
38
- const currentEdges = context.xyedges;
39
- xyedges = event.xyedges.map((update) => {
40
- const existing = currentEdges.find((n) => n.id === update.id);
41
- if (existing === update) {
42
- return existing;
43
- }
44
- if (existing && existing.type === update.type) {
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)) {
46
- return existing;
47
- }
48
- return {
49
- ...omit(existing, ["hidden", "sourceHandle", "targetHandle"]),
50
- ...update,
51
- data: {
52
- ...existing.data,
53
- ...update.data
54
- }
55
- };
56
- }
57
- return update;
58
- });
14
+ const currentView = context.view;
15
+ const isSameView = currentView.id === nextView.id;
16
+ const isDynamicViewUpdate = nextView._type === "dynamic" && nextView.variant === "sequence";
17
+ if (isDynamicViewUpdate) {
18
+ return {
19
+ xynodes: event.xynodes,
20
+ xyedges: event.xyedges,
21
+ view: nextView
22
+ };
59
23
  }
24
+ const xynodes = updateNodes(context.xynodes, event.xynodes);
25
+ const xyedges = isSameView ? updateEdges(context.xyedges, event.xyedges) : event.xyedges;
60
26
  return {
61
27
  xynodes,
62
28
  xyedges,
63
29
  view: nextView
64
30
  };
65
31
  }
66
- function focusNodesEdges(params) {
67
- const { xynodes: _xynodes, xyedges: _xyedges, focusedNode } = params.context;
32
+ function focusNodesEdges(context) {
33
+ const { xynodes: _xynodes, xyedges: _xyedges, focusedNode } = context;
68
34
  if (!focusedNode) {
69
- return {};
35
+ return null;
70
36
  }
71
37
  const focused = /* @__PURE__ */ new Set([focusedNode]);
72
38
  const xyedges = _xyedges.map((edge) => {
@@ -88,126 +54,7 @@ function focusNodesEdges(params) {
88
54
  xyedges
89
55
  };
90
56
  }
91
- function updateNavigationHistory({ context, event }) {
92
- assertEvent(event, "update.view");
93
- let {
94
- navigationHistory: {
95
- currentIndex,
96
- history
97
- },
98
- lastOnNavigate,
99
- viewport
100
- } = context;
101
- const stepCurrent = history[currentIndex];
102
- if (!stepCurrent) {
103
- return {
104
- navigationHistory: {
105
- currentIndex: 0,
106
- history: [
107
- {
108
- viewId: event.view.id,
109
- fromNode: null,
110
- viewport: { ...viewport }
111
- }
112
- ]
113
- }
114
- };
115
- }
116
- if (stepCurrent.viewId !== event.view.id) {
117
- if (!lastOnNavigate) {
118
- const stepBack = currentIndex > 0 ? nonNullable(history[currentIndex - 1]) : null;
119
- if (stepBack && stepBack.viewId === event.view.id) {
120
- return {
121
- navigationHistory: {
122
- currentIndex: currentIndex - 1,
123
- history
124
- },
125
- lastOnNavigate: {
126
- fromView: stepCurrent.viewId,
127
- toView: stepBack.viewId,
128
- fromNode: stepCurrent.fromNode
129
- }
130
- };
131
- }
132
- const stepForward = currentIndex < history.length - 1 ? nonNullable(history[currentIndex + 1]) : null;
133
- if (stepForward && stepForward.viewId === event.view.id) {
134
- return {
135
- navigationHistory: {
136
- currentIndex: currentIndex + 1,
137
- history
138
- },
139
- lastOnNavigate: {
140
- fromView: stepCurrent.viewId,
141
- toView: stepForward.viewId,
142
- fromNode: stepForward.fromNode
143
- }
144
- };
145
- }
146
- }
147
- history = [
148
- ...history.slice(0, currentIndex + 1),
149
- {
150
- viewId: event.view.id,
151
- fromNode: lastOnNavigate?.fromNode ?? null,
152
- viewport: { ...viewport }
153
- }
154
- ];
155
- currentIndex = history.length - 1;
156
- return {
157
- navigationHistory: {
158
- currentIndex,
159
- history
160
- }
161
- };
162
- }
163
- return {};
164
- }
165
- function navigateBack({ context }) {
166
- const {
167
- navigationHistory: {
168
- currentIndex,
169
- history
170
- }
171
- } = context;
172
- invariant(currentIndex > 0, "Cannot navigate back");
173
- const stepCurrent = history[currentIndex];
174
- const stepBack = history[currentIndex - 1];
175
- return {
176
- navigationHistory: {
177
- currentIndex: currentIndex - 1,
178
- history
179
- },
180
- lastOnNavigate: {
181
- fromView: stepCurrent.viewId,
182
- toView: stepBack.viewId,
183
- fromNode: stepCurrent.fromNode
184
- }
185
- };
186
- }
187
- function navigateForward({ context }) {
188
- const {
189
- navigationHistory: {
190
- currentIndex,
191
- history
192
- }
193
- } = context;
194
- invariant(currentIndex < history.length - 1, "Cannot navigate forward");
195
- const stepCurrent = history[currentIndex];
196
- const stepForward = history[currentIndex + 1];
197
- return {
198
- navigationHistory: {
199
- currentIndex: currentIndex + 1,
200
- history
201
- },
202
- lastOnNavigate: {
203
- fromView: stepCurrent.viewId,
204
- toView: stepForward.viewId,
205
- fromNode: stepForward.fromNode
206
- }
207
- };
208
- }
209
57
  function updateNodeData({ context, event }) {
210
- console.log("updateNodeData called", event);
211
58
  assertEvent(event, "update.nodeData");
212
59
  const xynodes = context.xynodes.map((node) => {
213
60
  if (node.id !== event.nodeId) {
@@ -257,37 +104,18 @@ function resetEdgeControlPoints(nodeLookup, edge) {
257
104
  const loopSize = 80;
258
105
  const centerOfTopBoundary = vector(0, source.height || 0).multiply(-0.5).add(sourceCenter);
259
106
  return [
260
- centerOfTopBoundary.add(vector(-loopSize / 2.5, -loopSize)),
261
- centerOfTopBoundary.add(vector(loopSize / 2.5, -loopSize))
107
+ centerOfTopBoundary.add(vector(-loopSize / 2.5, -loopSize)).round().toObject(),
108
+ centerOfTopBoundary.add(vector(loopSize / 2.5, -loopSize)).round().toObject()
262
109
  ];
263
110
  }
264
111
  const sourceToTargetVector = targetCenter.subtract(sourceCenter);
265
112
  const sourceBorderPoint = getBorderPointOnVector(source, sourceCenter, sourceToTargetVector);
266
113
  const targetBorderPoint = getBorderPointOnVector(target, targetCenter, sourceToTargetVector.multiply(-1));
267
- return [sourceBorderPoint.add(targetBorderPoint.subtract(sourceBorderPoint).multiply(0.4))];
268
- }
269
- function updateActiveWalkthrough({ context }) {
270
- const { stepId, parallelPrefix } = nonNullable(context.activeWalkthrough, "activeWalkthrough is null");
271
- const step = nonNullable(context.xyedges.find((x) => x.id === stepId));
272
- return {
273
- xyedges: context.xyedges.map((edge) => {
274
- const active = stepId === edge.id || !!parallelPrefix && edge.id.startsWith(parallelPrefix);
275
- return Base.setData(edge, {
276
- active,
277
- dimmed: stepId !== edge.id
278
- });
279
- }),
280
- xynodes: context.xynodes.map((node) => {
281
- const dimmed = step.source !== node.id && step.target !== node.id;
282
- if (node.type === "seq-parallel") {
283
- return Base.setData(node, {
284
- color: parallelPrefix === node.data.parallelPrefix ? SeqParallelAreaColor.active : SeqParallelAreaColor.default,
285
- dimmed
286
- });
287
- }
288
- return Base.setDimmed(node, dimmed);
289
- })
290
- };
114
+ const sourceToTarget = targetBorderPoint.subtract(sourceBorderPoint);
115
+ return [
116
+ sourceBorderPoint.add(sourceToTarget.multiply(0.4)).round().toObject(),
117
+ sourceBorderPoint.add(sourceToTarget.multiply(0.6)).round().toObject()
118
+ ];
291
119
  }
292
120
 
293
- export { focusNodesEdges, mergeXYNodesEdges, navigateBack, navigateForward, resetEdgeControlPoints, updateActiveWalkthrough, updateEdgeData, updateNavigationHistory, updateNodeData };
121
+ export { focusNodesEdges, mergeXYNodesEdges, resetEdgeControlPoints, updateEdgeData, updateNodeData };
@@ -1,5 +1,5 @@
1
1
  import { getNodeDimensions } from '@xyflow/system';
2
- import { indexBy, map, omit, hasAtLeast } from 'remeda';
2
+ import { map, omit, hasAtLeast } from 'remeda';
3
3
  import { calcViewBounds } from '../../utils/view-bounds.js';
4
4
  import { isSamePoint, bezierControlPoints } from '../../utils/xyflow.js';
5
5
 
@@ -13,42 +13,40 @@ function createViewChange(parentContext) {
13
13
  ...view
14
14
  },
15
15
  xynodes,
16
- xyedges,
17
16
  xystore
18
17
  } = parentContext;
19
- const { nodeLookup } = xystore.getState();
18
+ const { nodeLookup, edgeLookup } = xystore.getState();
20
19
  const movedNodes = /* @__PURE__ */ new Set();
21
- const xynodesLookup = indexBy(xynodes, (n) => n.data.id);
22
- const xyedgesLookup = indexBy(xyedges, (e) => e.data.id);
23
20
  const nodes = map(view.nodes, (node) => {
24
- const xynode = xynodesLookup[node.id];
25
- if (!xynode) {
21
+ const internal = nodeLookup.get(node.id);
22
+ if (!internal) {
23
+ console.error(`Internal node not found for ${node.id}`);
26
24
  return node;
27
25
  }
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;
26
+ const xynodedata = xynodes.find((n) => n.id === node.id)?.data ?? internal.data;
27
+ const position = internal.internals.positionAbsolute;
28
+ const { width, height } = getNodeDimensions(internal);
29
+ const isChanged = !isSamePoint(position, node) || node.width !== width || node.height !== height;
30
+ if (isChanged) {
31
+ movedNodes.add(node.id);
33
32
  }
34
- movedNodes.add(xynode.id);
35
33
  return {
36
34
  ...node,
37
- shape: xynode.data.shape,
38
- color: xynode.data.color,
35
+ shape: xynodedata.shape,
36
+ color: xynodedata.color,
39
37
  style: {
40
- ...node.style,
41
- ...xynode.data.style
38
+ ...xynodedata.style
42
39
  },
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)
40
+ x: Math.floor(position.x),
41
+ y: Math.floor(position.y),
42
+ width: Math.ceil(width),
43
+ height: Math.ceil(height)
47
44
  };
48
45
  });
49
46
  const edges = map(view.edges, (edge) => {
50
- const xyedge = xyedgesLookup[edge.id];
47
+ const xyedge = edgeLookup.get(edge.id);
51
48
  if (!xyedge) {
49
+ console.error(`Internal edge not found for ${edge.id}`);
52
50
  return edge;
53
51
  }
54
52
  const data = xyedge.data;
@@ -58,17 +56,11 @@ function createViewChange(parentContext) {
58
56
  controlPoints = bezierControlPoints(data.points);
59
57
  }
60
58
  const _updated = {
61
- ...omit(edge, ["controlPoints"]),
59
+ ...omit(edge, ["controlPoints", "labelBBox"]),
62
60
  points: data.points
63
61
  };
64
- if (data.labelXY && data.labelBBox) {
65
- _updated.labelBBox = {
66
- ...data.labelBBox,
67
- ...data.labelXY
68
- };
69
- }
70
62
  if (data.labelBBox) {
71
- _updated.labelBBox ??= data.labelBBox;
63
+ _updated.labelBBox = data.labelBBox;
72
64
  }
73
65
  if (hasAtLeast(controlPoints, 1)) {
74
66
  _updated.controlPoints = controlPoints;
@@ -77,6 +69,7 @@ function createViewChange(parentContext) {
77
69
  });
78
70
  const snapshot = {
79
71
  ...view,
72
+ _layout: "manual",
80
73
  bounds: calcViewBounds({ nodes, edges }),
81
74
  nodes,
82
75
  edges