@likec4/diagram 1.43.0 → 1.45.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 (349) hide show
  1. package/bundle/index.js +14727 -13166
  2. package/dist/LikeC4Diagram.d.ts +1 -1
  3. package/dist/LikeC4Diagram.js +14 -9
  4. package/dist/LikeC4Diagram.props.d.ts +25 -15
  5. package/dist/LikeC4ProjectsProvider.js +1 -1
  6. package/dist/LikeC4Styles.js +0 -3
  7. package/dist/LikeC4View.d.ts +8 -3
  8. package/dist/LikeC4View.js +29 -14
  9. package/dist/ReactLikeC4.d.ts +2 -2
  10. package/dist/ReactLikeC4.js +2 -2
  11. package/dist/StaticLikeC4Diagram.js +1 -1
  12. package/dist/_virtual/_commonjsHelpers.js +3 -0
  13. package/dist/_virtual/assign-dea9f7c8.cjs.js +3 -0
  14. package/dist/_virtual/log-ec8d4df4.cjs.js +3 -0
  15. package/dist/_virtual/raise-da5b247f.cjs.js +3 -0
  16. package/dist/_virtual/xstate-actions.cjs.js +5 -0
  17. package/dist/_virtual/xstate-actions.cjs2.js +3 -0
  18. package/dist/_virtual/xstate-dev.cjs.js +3 -0
  19. package/dist/_virtual/xstate-guards.cjs.js +5 -0
  20. package/dist/_virtual/xstate-guards.cjs2.js +3 -0
  21. package/dist/base/Background.d.ts +2 -1
  22. package/dist/base/Background.js +11 -2
  23. package/dist/base/Base.d.ts +28 -0
  24. package/dist/base/BaseXYFlow.d.ts +5 -5
  25. package/dist/base/BaseXYFlow.js +38 -44
  26. package/dist/base/index.d.ts +6 -2
  27. package/dist/base/types.d.ts +1 -28
  28. package/dist/base/updateEdges.js +25 -14
  29. package/dist/base/updateNodes.d.ts +14 -0
  30. package/dist/base/updateNodes.js +51 -17
  31. package/dist/base-primitives/Markdown.d.ts +30 -4
  32. package/dist/base-primitives/Markdown.js +3 -2
  33. package/dist/base-primitives/compound/CompoundActionButton.d.ts +3 -2
  34. package/dist/base-primitives/compound/CompoundActionButton.js +1 -1
  35. package/dist/base-primitives/compound/CompoundDetailsButton.d.ts +3 -2
  36. package/dist/base-primitives/compound/CompoundDetailsButton.js +1 -1
  37. package/dist/base-primitives/edge/EdgeActionButton.d.ts +3 -2
  38. package/dist/base-primitives/edge/EdgeActionButton.js +1 -1
  39. package/dist/base-primitives/edge/EdgeContainer.d.ts +1 -1
  40. package/dist/base-primitives/edge/EdgeContainer.js +8 -1
  41. package/dist/base-primitives/edge/EdgeLabel.d.ts +3 -2
  42. package/dist/base-primitives/edge/EdgeLabel.js +2 -0
  43. package/dist/base-primitives/edge/EdgeLabelContainer.d.ts +1 -1
  44. package/dist/base-primitives/edge/EdgeLabelContainer.js +4 -0
  45. package/dist/base-primitives/edge/EdgePath.d.ts +4 -0
  46. package/dist/base-primitives/edge/EdgePath.js +29 -5
  47. package/dist/base-primitives/element/ElementActionButtons.d.ts +6 -4
  48. package/dist/base-primitives/element/ElementActionButtons.js +3 -3
  49. package/dist/base-primitives/element/ElementData.d.ts +3 -3
  50. package/dist/base-primitives/element/ElementData.js +13 -7
  51. package/dist/base-primitives/element/ElementDetailsButton.d.ts +3 -2
  52. package/dist/base-primitives/element/ElementDetailsButton.js +5 -5
  53. package/dist/base-primitives/element/ElementNodeContainer.css.js +15 -27
  54. package/dist/base-primitives/element/ElementShape.js +5 -5
  55. package/dist/base-primitives/element/ElementTags.d.ts +6 -4
  56. package/dist/base-primitives/element/ElementTags.js +2 -1
  57. package/dist/base-primitives/memoEdge.js +4 -2
  58. package/dist/base-primitives/memoNode.d.ts +1 -1
  59. package/dist/base-primitives/memoNode.js +3 -3
  60. package/dist/components/ErrorFallback.js +52 -35
  61. package/dist/components/Link.js +2 -2
  62. package/dist/context/DiagramEventHandlers.js +2 -1
  63. package/dist/context/DiagramFeatures.d.ts +25 -6
  64. package/dist/context/DiagramFeatures.js +28 -56
  65. package/dist/context/IconRenderer.js +6 -6
  66. package/dist/context/LikeC4ModelContext.js +3 -10
  67. package/dist/context/TagStylesContext.js +3 -19
  68. package/dist/context/index.d.ts +1 -1
  69. package/dist/custom/customNodes.js +3 -2
  70. package/dist/custom/hooks.d.ts +3 -3
  71. package/dist/custom/index.d.ts +1 -1
  72. package/dist/custom/index.js +5 -5
  73. package/dist/editor/LikeC4EditorContext.d.ts +21 -0
  74. package/dist/editor/index.d.ts +2 -0
  75. package/dist/hooks/index.d.ts +4 -2
  76. package/dist/hooks/safeContext.d.ts +6 -3
  77. package/dist/hooks/safeContext.js +10 -3
  78. package/dist/hooks/useCallbackRef.d.ts +1 -0
  79. package/dist/hooks/useCallbackRef.js +13 -0
  80. package/dist/hooks/useCurrentView.d.ts +11 -0
  81. package/dist/hooks/{useCurrentViewId.js → useCurrentView.js} +7 -3
  82. package/dist/hooks/useCurrentViewModel.js +4 -1
  83. package/dist/hooks/useDiagram.d.ts +7 -113
  84. package/dist/hooks/useDiagram.js +7 -127
  85. package/dist/hooks/useDiagramCompareLayout.d.ts +35 -0
  86. package/dist/hooks/useDiagramCompareLayout.js +65 -0
  87. package/dist/hooks/useLikeC4Project.d.ts +6 -1
  88. package/dist/hooks/useLikeC4Project.js +14 -2
  89. package/dist/hooks/useMediaPrint.d.ts +6 -0
  90. package/dist/hooks/useUpdateEffect.js +2 -4
  91. package/dist/hooks/useXYFlow.d.ts +1 -0
  92. package/dist/hooks/useXYFlow.js +4 -7
  93. package/dist/index.d.ts +2 -2
  94. package/dist/index.js +4 -3
  95. package/dist/likec4diagram/DiagramUI.js +14 -7
  96. package/dist/likec4diagram/DiagramXYFlow.d.ts +2 -2
  97. package/dist/likec4diagram/DiagramXYFlow.js +60 -52
  98. package/dist/likec4diagram/convert-to-xyflow.d.ts +0 -1
  99. package/dist/likec4diagram/custom/edges/EdgeDrifts.d.ts +6 -0
  100. package/dist/likec4diagram/custom/edges/EdgeDrifts.js +38 -0
  101. package/dist/likec4diagram/custom/edges/RelationshipEdge.js +256 -217
  102. package/dist/likec4diagram/custom/edges/SequenceStepEdge.js +9 -2
  103. package/dist/likec4diagram/custom/edges/edges.css.js +3 -4
  104. package/dist/likec4diagram/custom/edges/useControlPoints.d.ts +8 -0
  105. package/dist/likec4diagram/custom/edges/useControlPoints.js +58 -0
  106. package/dist/likec4diagram/custom/edges/useRelationshipEdgePath.d.ts +7 -0
  107. package/dist/likec4diagram/custom/edges/useRelationshipEdgePath.js +60 -0
  108. package/dist/likec4diagram/custom/edges/utils.d.ts +0 -12
  109. package/dist/likec4diagram/custom/nodes/CompoundActions.js +4 -1
  110. package/dist/likec4diagram/custom/nodes/ElementActions.d.ts +2 -1
  111. package/dist/likec4diagram/custom/nodes/ElementActions.js +15 -10
  112. package/dist/likec4diagram/custom/nodes/NodeDrifts.d.ts +6 -0
  113. package/dist/likec4diagram/custom/nodes/NodeDrifts.js +50 -0
  114. package/dist/likec4diagram/custom/nodes/SequenceActorNode.js +7 -2
  115. package/dist/likec4diagram/custom/nodes/index.d.ts +1 -0
  116. package/dist/likec4diagram/custom/nodes/nodes.d.ts +9 -1
  117. package/dist/likec4diagram/custom/nodes/nodes.js +74 -29
  118. package/dist/likec4diagram/custom/nodes/toolbar/ColorButton.d.ts +1 -1
  119. package/dist/likec4diagram/custom/nodes/toolbar/ColorButton.js +1 -1
  120. package/dist/likec4diagram/custom/nodes/toolbar/CompoundToolbar.js +2 -1
  121. package/dist/likec4diagram/custom/nodes/toolbar/ElementToolbar.js +4 -3
  122. package/dist/likec4diagram/custom/nodes/toolbar/_shared.d.ts +1 -11
  123. package/dist/likec4diagram/custom/nodes/toolbar/_shared.js +7 -51
  124. package/dist/likec4diagram/custom/nodes/toolbar/types.d.ts +5 -0
  125. package/dist/likec4diagram/custom/nodes/toolbar/types.js +7 -0
  126. package/dist/likec4diagram/custom/nodes/toolbar/useHandlers.d.ts +8 -0
  127. package/dist/likec4diagram/custom/nodes/toolbar/useHandlers.js +44 -0
  128. package/dist/likec4diagram/relationship-popover/RelationshipPopover.js +8 -10
  129. package/dist/likec4diagram/relationship-popover/actor.d.ts +1 -1
  130. package/dist/likec4diagram/state/DiagramActorProvider.d.ts +4 -3
  131. package/dist/likec4diagram/state/DiagramActorProvider.js +95 -70
  132. package/dist/likec4diagram/state/assign.d.ts +13 -7
  133. package/dist/likec4diagram/state/assign.js +43 -282
  134. package/dist/likec4diagram/state/createViewChange.d.ts +3 -0
  135. package/dist/likec4diagram/state/createViewChange.js +79 -0
  136. package/dist/likec4diagram/state/diagram-api.d.ts +109 -0
  137. package/dist/likec4diagram/state/diagram-api.js +126 -0
  138. package/dist/likec4diagram/state/machine.actions.d.ts +1783 -0
  139. package/dist/likec4diagram/state/machine.actions.js +644 -0
  140. package/dist/likec4diagram/state/machine.actions.layout.d.ts +579 -0
  141. package/dist/likec4diagram/state/machine.actions.layout.js +129 -0
  142. package/dist/likec4diagram/state/machine.d.ts +22 -0
  143. package/dist/likec4diagram/state/machine.js +127 -0
  144. package/dist/likec4diagram/state/machine.setup.d.ts +327 -0
  145. package/dist/likec4diagram/state/machine.setup.js +93 -0
  146. package/dist/likec4diagram/state/machine.state.initializing.d.ts +208 -0
  147. package/dist/likec4diagram/state/machine.state.initializing.js +55 -0
  148. package/dist/likec4diagram/state/machine.state.navigating.d.ts +14 -0
  149. package/dist/likec4diagram/state/machine.state.navigating.js +178 -0
  150. package/dist/likec4diagram/state/machine.state.ready.d.ts +3131 -0
  151. package/dist/likec4diagram/state/machine.state.ready.focused.d.ts +386 -0
  152. package/dist/likec4diagram/state/machine.state.ready.focused.js +85 -0
  153. package/dist/likec4diagram/state/machine.state.ready.idle.d.ts +474 -0
  154. package/dist/likec4diagram/state/machine.state.ready.idle.js +96 -0
  155. package/dist/likec4diagram/state/machine.state.ready.js +262 -0
  156. package/dist/likec4diagram/state/machine.state.ready.printing.d.ts +128 -0
  157. package/dist/likec4diagram/state/machine.state.ready.printing.js +40 -0
  158. package/dist/likec4diagram/state/machine.state.ready.walkthrough.d.ts +511 -0
  159. package/dist/likec4diagram/state/machine.state.ready.walkthrough.js +177 -0
  160. package/dist/likec4diagram/state/mediaPrintActor.d.ts +12 -0
  161. package/dist/likec4diagram/state/mediaPrintActor.js +18 -0
  162. package/dist/likec4diagram/state/syncManualLayoutActor.d.ts +31 -108
  163. package/dist/likec4diagram/state/syncManualLayoutActor.js +278 -142
  164. package/dist/likec4diagram/state/types.d.ts +7 -12
  165. package/dist/likec4diagram/state/utils.d.ts +19 -4
  166. package/dist/likec4diagram/state/utils.js +47 -4
  167. package/dist/likec4diagram/types.d.ts +8 -8
  168. package/dist/likec4diagram/ui/LayoutDriftFrame.d.ts +2 -0
  169. package/dist/likec4diagram/ui/LayoutDriftFrame.js +66 -0
  170. package/dist/likec4diagram/ui/index.d.ts +1 -0
  171. package/dist/likec4diagram/ui/notation/NotationPanel.css.js +5 -2
  172. package/dist/likec4diagram/ui/notation/NotationPanel.js +5 -4
  173. package/dist/likec4diagram/useLayoutConstraints.d.ts +10 -5
  174. package/dist/likec4diagram/useLayoutConstraints.js +237 -61
  175. package/dist/likec4diagram/xyflow-diagram/diagram-view.d.ts +0 -1
  176. package/dist/likec4diagram/xyflow-diagram/diagram-view.js +14 -17
  177. package/dist/likec4diagram/xyflow-sequence/sequence-layout.js +11 -8
  178. package/dist/navigationpanel/NavigationPanel.js +16 -8
  179. package/dist/navigationpanel/NavigationPanelControls.d.ts +2 -1
  180. package/dist/navigationpanel/NavigationPanelControls.js +23 -17
  181. package/dist/navigationpanel/NavigationPanelDropdown.d.ts +2 -1
  182. package/dist/navigationpanel/NavigationPanelDropdown.js +62 -42
  183. package/dist/navigationpanel/_common.d.ts +1 -1
  184. package/dist/navigationpanel/_common.js +4 -2
  185. package/dist/navigationpanel/actor.d.ts +9 -205
  186. package/dist/navigationpanel/actor.js +6 -5
  187. package/dist/navigationpanel/comparepanel/CompareActionsMenu.d.ts +3 -0
  188. package/dist/navigationpanel/comparepanel/CompareActionsMenu.js +59 -0
  189. package/dist/navigationpanel/comparepanel/ComparePanel.d.ts +2 -0
  190. package/dist/navigationpanel/comparepanel/ComparePanel.js +42 -0
  191. package/dist/navigationpanel/comparepanel/ComparePanelControls.d.ts +1 -0
  192. package/dist/navigationpanel/comparepanel/ComparePanelControls.js +60 -0
  193. package/dist/navigationpanel/comparepanel/LayoutTypeSwitcher.d.ts +5 -0
  194. package/dist/navigationpanel/comparepanel/LayoutTypeSwitcher.js +38 -0
  195. package/dist/navigationpanel/comparepanel/index.d.ts +1 -0
  196. package/dist/navigationpanel/controls/{ViewDetailsCard.d.ts → DetailsControls.d.ts} +1 -1
  197. package/dist/navigationpanel/controls/{ViewDetailsCard.js → DetailsControls.js} +18 -14
  198. package/dist/navigationpanel/controls/LayoutWarning.d.ts +2 -0
  199. package/dist/navigationpanel/controls/LayoutWarning.js +102 -0
  200. package/dist/navigationpanel/controls/NavigationButtons.js +4 -3
  201. package/dist/navigationpanel/controls/OpenSource.js +2 -2
  202. package/dist/navigationpanel/controls/SearchControl.d.ts +2 -1
  203. package/dist/navigationpanel/controls/SearchControl.js +15 -17
  204. package/dist/navigationpanel/controls/ToggleReadonly.d.ts +1 -1
  205. package/dist/navigationpanel/controls/ToggleReadonly.js +26 -18
  206. package/dist/navigationpanel/controls/index.d.ts +2 -1
  207. package/dist/navigationpanel/dropdown/ProjectsMenu.d.ts +2 -2
  208. package/dist/navigationpanel/dropdown/ProjectsMenu.js +5 -5
  209. package/dist/navigationpanel/editorpanel/CenterCamera.js +5 -2
  210. package/dist/navigationpanel/editorpanel/ChangeAutoLayoutButton.d.ts +1 -1
  211. package/dist/navigationpanel/editorpanel/ChangeAutoLayoutButton.js +21 -20
  212. package/dist/navigationpanel/editorpanel/EditorPanel.js +3 -3
  213. package/dist/navigationpanel/editorpanel/ManualLayoutToolsButton.d.ts +2 -2
  214. package/dist/navigationpanel/editorpanel/ManualLayoutToolsButton.js +16 -13
  215. package/dist/navigationpanel/editorpanel/ToggleReadonly.d.ts +1 -0
  216. package/dist/navigationpanel/editorpanel/ToggleReadonly.js +15 -0
  217. package/dist/navigationpanel/styles.css.d.ts +2 -2
  218. package/dist/navigationpanel/styles.css.js +4 -4
  219. package/dist/navigationpanel/walkthrough/ActiveWalkthroughControls.js +14 -8
  220. package/dist/navigationpanel/walkthrough/DynamicViewControls.d.ts +66 -66
  221. package/dist/navigationpanel/walkthrough/DynamicViewControls.js +31 -14
  222. package/dist/navigationpanel/walkthrough/WalkthroughPanel.d.ts +2 -1
  223. package/dist/navigationpanel/walkthrough/WalkthroughPanel.js +68 -50
  224. package/dist/node_modules/.pnpm/xstate@5.24.0_patch_hash_3a1bd6d012ec67bf6e38a00c3226d1be77089442f83aeb6e424b00ca2a11d21c/node_modules/xstate/actions/dist/xstate-actions.cjs.js +37 -0
  225. package/dist/node_modules/.pnpm/xstate@5.24.0_patch_hash_3a1bd6d012ec67bf6e38a00c3226d1be77089442f83aeb6e424b00ca2a11d21c/node_modules/xstate/dev/dist/xstate-dev.cjs.js +59 -0
  226. package/dist/node_modules/.pnpm/xstate@5.24.0_patch_hash_3a1bd6d012ec67bf6e38a00c3226d1be77089442f83aeb6e424b00ca2a11d21c/node_modules/xstate/dist/assign-dea9f7c8.cjs.js +140 -0
  227. package/dist/node_modules/.pnpm/xstate@5.24.0_patch_hash_3a1bd6d012ec67bf6e38a00c3226d1be77089442f83aeb6e424b00ca2a11d21c/node_modules/xstate/dist/log-ec8d4df4.cjs.js +401 -0
  228. package/dist/node_modules/.pnpm/xstate@5.24.0_patch_hash_3a1bd6d012ec67bf6e38a00c3226d1be77089442f83aeb6e424b00ca2a11d21c/node_modules/xstate/dist/raise-da5b247f.cjs.js +2716 -0
  229. package/dist/node_modules/.pnpm/xstate@5.24.0_patch_hash_3a1bd6d012ec67bf6e38a00c3226d1be77089442f83aeb6e424b00ca2a11d21c/node_modules/xstate/guards/dist/xstate-guards.cjs.js +26 -0
  230. package/dist/overlays/element-details/ElementDetails.js +7 -7
  231. package/dist/overlays/element-details/ElementDetailsCard.css.js +3 -3
  232. package/dist/overlays/element-details/ElementDetailsCard.js +7 -5
  233. package/dist/overlays/element-details/MetadataValue.d.ts +2 -1
  234. package/dist/overlays/element-details/MetadataValue.js +2 -2
  235. package/dist/overlays/element-details/TabPanelDeployments.js +6 -4
  236. package/dist/overlays/element-details/TabPanelRelationships.js +3 -3
  237. package/dist/overlays/element-details/TabPanelStructure.js +1 -1
  238. package/dist/overlays/element-details/actor.d.ts +8 -82
  239. package/dist/overlays/element-details/actor.js +0 -8
  240. package/dist/overlays/overlay/Overlay.js +10 -10
  241. package/dist/overlays/overlaysActor.d.ts +7 -150
  242. package/dist/overlays/overlaysActor.js +183 -161
  243. package/dist/overlays/relationship-details/RelationshipDetails.js +4 -3
  244. package/dist/overlays/relationship-details/SelectEdge.js +2 -2
  245. package/dist/overlays/relationship-details/_types.d.ts +3 -4
  246. package/dist/overlays/relationship-details/actor.d.ts +6 -550
  247. package/dist/overlays/relationship-details/actor.js +18 -3
  248. package/dist/overlays/relationship-details/custom/ElementActions.js +8 -5
  249. package/dist/overlays/relationship-details/custom/edgeTypes.js +4 -1
  250. package/dist/overlays/relationship-details/custom/nodeTypes.js +4 -1
  251. package/dist/overlays/relationship-details/hooks.js +1 -1
  252. package/dist/overlays/relationship-details/layout-to-xyflow.js +3 -5
  253. package/dist/overlays/relationship-details/layout.d.ts +3 -3
  254. package/dist/overlays/relationship-details/layout.js +4 -4
  255. package/dist/overlays/relationships-browser/RelationshipsBrowser.js +6 -4
  256. package/dist/overlays/relationships-browser/SelectElement.js +2 -2
  257. package/dist/overlays/relationships-browser/_types.d.ts +2 -3
  258. package/dist/overlays/relationships-browser/actor.d.ts +7 -673
  259. package/dist/overlays/relationships-browser/actor.js +132 -110
  260. package/dist/overlays/relationships-browser/custom/ElementActions.js +44 -37
  261. package/dist/overlays/relationships-browser/custom/edgeTypes.js +4 -1
  262. package/dist/overlays/relationships-browser/custom/nodeTypes.js +4 -1
  263. package/dist/overlays/relationships-browser/hooks.js +7 -6
  264. package/dist/overlays/relationships-browser/layout.d.ts +2 -2
  265. package/dist/overlays/relationships-browser/layout.js +3 -3
  266. package/dist/overlays/relationships-browser/useViewToNodesEdges.js +0 -3
  267. package/dist/overlays/types.d.ts +12 -13
  268. package/dist/search/Search.js +2 -1
  269. package/dist/search/components/ElementsColumn.js +5 -3
  270. package/dist/search/components/PickView.js +1 -1
  271. package/dist/search/components/SearchByTags.js +21 -44
  272. package/dist/search/components/SearchInput.js +1 -1
  273. package/dist/search/components/ViewsColum.js +6 -4
  274. package/dist/search/components/_shared.css.d.ts +1 -1
  275. package/dist/search/searchActor.d.ts +3 -66
  276. package/dist/shadowroot/ShadowRoot.d.ts +5 -7
  277. package/dist/shadowroot/ShadowRoot.js +8 -6
  278. package/dist/styles.css2.js +1 -1
  279. package/dist/utils/index.d.ts +4 -4
  280. package/dist/utils/vector.d.ts +83 -21
  281. package/dist/utils/vector.js +98 -24
  282. package/dist/utils/view-bounds.d.ts +8 -0
  283. package/dist/utils/view-bounds.js +58 -0
  284. package/dist/utils/xyflow.d.ts +52 -8
  285. package/dist/utils/xyflow.js +31 -11
  286. package/package.json +26 -24
  287. package/panda.buildinfo.json +124 -71
  288. package/styles-min.css +1 -1
  289. package/styles.css +1 -1
  290. package/dist/hooks/useCurrentViewId.d.ts +0 -6
  291. package/dist/likec4diagram/custom/edges/utils.js +0 -23
  292. package/dist/likec4diagram/state/diagram-machine.d.ts +0 -2590
  293. package/dist/likec4diagram/state/diagram-machine.js +0 -1180
  294. package/dist/navigationpanel/editorpanel/LayoutDriftNotification.d.ts +0 -1
  295. package/dist/navigationpanel/editorpanel/LayoutDriftNotification.js +0 -56
  296. package/dist/utils/get-view-bounds.d.ts +0 -3
  297. package/dist/utils/get-view-bounds.js +0 -14
  298. /package/dist/base/{types.js → Base.js} +0 -0
  299. /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
  300. /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
  301. /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
  302. /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
  303. /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
  304. /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
  305. /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
  306. /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
  307. /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
  308. /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
  309. /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
  310. /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
  311. /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
  312. /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
  313. /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
  314. /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
  315. /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
  316. /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
  317. /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
  318. /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
  319. /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
  320. /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
  321. /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
  322. /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
  323. /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
  324. /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
  325. /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
  326. /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
  327. /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
  328. /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
  329. /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
  330. /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
  331. /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
  332. /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
  333. /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
  334. /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
  335. /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
  336. /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
  337. /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
  338. /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
  339. /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
  340. /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
  341. /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
  342. /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
  343. /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
  344. /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
  345. /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
  346. /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
  347. /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
  348. /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
  349. /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
@@ -0,0 +1,18 @@
1
+ import { fromCallback } from 'xstate';
2
+
3
+ const mediaPrintActorLogic = fromCallback(({ sendBack }) => {
4
+ const beforePrint = () => {
5
+ sendBack({ type: "media.print.on" });
6
+ };
7
+ const afterPrint = () => {
8
+ sendBack({ type: "media.print.off" });
9
+ };
10
+ window.addEventListener("beforeprint", beforePrint);
11
+ window.addEventListener("afterprint", afterPrint);
12
+ return () => {
13
+ window.removeEventListener("beforeprint", beforePrint);
14
+ window.removeEventListener("afterprint", afterPrint);
15
+ };
16
+ });
17
+
18
+ export { mediaPrintActorLogic };
@@ -1,123 +1,46 @@
1
- import { ViewChange, ViewId } from '@likec4/core/types';
2
- import { ActorLogicFrom, ActorRef, MachineSnapshot, StateMachine, NonReducibleUnknown, EventObject, MetaObject, ActorRefFromLogic, AnyActorLogic, ConditionalRequired, InputFrom, RequiredLogicInput, IsNotNever, AnyActorRef, StateValue, AnyEventObject, ActionFunction } from 'xstate';
3
- import { Context as DiagramContext, Events as DiagramEvents } from './diagram-machine';
1
+ import { LayoutedView, ViewChange, ViewId } from '@likec4/core/types';
2
+ import { ActorRef, MachineSnapshot, StateMachine } from 'xstate';
3
+ import { Types } from '../types';
4
4
  export type Input = {
5
- /**
6
- * Actually this is DiagramActorRef
7
- * But we can't use it here due to circular type inference
8
- */
9
- parent: ActorRef<MachineSnapshot<DiagramContext, DiagramEvents, any, any, any, any, any, any>, DiagramEvents, any>;
10
5
  viewId: ViewId;
11
6
  };
12
- export type Context = Readonly<Input & {}>;
7
+ type HistorySnapshot = {
8
+ view: LayoutedView;
9
+ change: ViewChange.SaveViewSnapshot;
10
+ xynodes: Types.Node[];
11
+ xyedges: Types.Edge[];
12
+ synched: boolean;
13
+ };
14
+ export type Context = Readonly<Input & {
15
+ history: ReadonlyArray<HistorySnapshot>;
16
+ beforeEditing: HistorySnapshot | null;
17
+ editing: 'node' | 'edge' | null;
18
+ }>;
13
19
  export type Events = {
14
20
  type: 'sync';
15
21
  } | {
16
22
  type: 'synced';
23
+ } | {
24
+ type: 'editing.start';
25
+ subject: 'node' | 'edge';
26
+ } | {
27
+ type: 'editing.stop';
28
+ wasChanged?: boolean;
17
29
  } | {
18
30
  type: 'cancel';
31
+ } | {
32
+ type: 'undo';
19
33
  } | {
20
34
  type: 'stop';
21
35
  };
22
- declare const _syncManualLayoutActorLogic: StateMachine<Readonly<Input>, Events, {}, never, {
23
- type: "trigger:OnChange";
24
- params: {
25
- change: ViewChange;
26
- };
27
- }, {
28
- type: "same view";
29
- params: unknown;
30
- }, "timeout", "stopped" | "synced" | "pending" | "idle" | "paused", "pending" | "ready", Input, NonReducibleUnknown, EventObject, MetaObject, {
31
- readonly initial: "idle";
32
- readonly context: ({ input }: {
33
- spawn: {
34
- <TSrc extends never>(logic: TSrc, ...[options]: never): ActorRefFromLogic<never>;
35
- <TLogic extends AnyActorLogic>(src: TLogic, ...[options]: ConditionalRequired<[options?: {
36
- id?: never;
37
- systemId?: string;
38
- input?: InputFrom<TLogic>;
39
- syncSnapshot?: boolean;
40
- } & { [K in RequiredLogicInput<TLogic>]: unknown; }], IsNotNever<RequiredLogicInput<TLogic>>>): ActorRefFromLogic<TLogic>;
41
- };
42
- input: Input;
43
- self: ActorRef<MachineSnapshot<Readonly<Input>, Events, Record<string, AnyActorRef | undefined>, StateValue, string, unknown, any, any>, Events, AnyEventObject>;
44
- }) => {
45
- /**
46
- * Actually this is DiagramActorRef
47
- * But we can't use it here due to circular type inference
48
- */
49
- parent: ActorRef<MachineSnapshot<DiagramContext, DiagramEvents, any, any, any, any, any, any>, DiagramEvents, any>;
50
- viewId: ViewId;
51
- };
52
- readonly states: {
53
- readonly idle: {
54
- readonly tags: "ready";
55
- readonly on: {
56
- readonly sync: {
57
- readonly target: "pending";
58
- };
59
- };
60
- };
61
- readonly paused: {
62
- readonly tags: "pending";
63
- readonly on: {
64
- readonly sync: {
65
- readonly target: "pending";
66
- };
67
- };
68
- };
69
- readonly pending: {
70
- readonly tags: "pending";
71
- readonly on: {
72
- readonly sync: {
73
- readonly target: "pending";
74
- readonly reenter: true;
75
- };
76
- readonly cancel: {
77
- readonly target: "paused";
78
- };
79
- };
80
- readonly after: {
81
- readonly timeout: readonly [{
82
- readonly guard: "same view";
83
- readonly actions: {
84
- readonly type: "trigger:OnChange";
85
- readonly params: ({ context }: {
86
- context: Readonly<Input>;
87
- event: Events;
88
- }) => {
89
- change: ViewChange.SaveManualLayout;
90
- };
91
- };
92
- readonly target: "synced";
93
- }, {
94
- readonly target: "stopped";
95
- }];
96
- };
97
- };
98
- readonly synced: {
99
- readonly tags: "ready";
100
- readonly on: {
101
- readonly sync: {
102
- readonly target: "pending";
103
- };
104
- };
105
- };
106
- readonly stopped: {
107
- readonly entry: ActionFunction<Readonly<Input>, Events, Events, undefined, never, never, never, never, never>;
108
- readonly type: "final";
109
- };
110
- };
111
- readonly on: {
112
- readonly synced: {
113
- readonly target: ".synced";
114
- };
115
- readonly stop: {
116
- readonly target: ".stopped";
117
- };
118
- };
119
- }>;
120
- export interface SyncLayoutActorLogic extends ActorLogicFrom<typeof _syncManualLayoutActorLogic> {
36
+ type Tags = 'pending' | 'ready';
37
+ /**
38
+ * Here is a trick to reduce inference types
39
+ */
40
+ export interface SyncLayoutActorLogic extends StateMachine<Context, Events, {}, any, any, any, any, any, Tags, Input, any, any, any, any> {
41
+ }
42
+ export type SyncLayoutActorSnapshot = MachineSnapshot<Context, Events, {}, never, Tags, never, {}, {}>;
43
+ export interface SyncLayoutActorRef extends ActorRef<SyncLayoutActorSnapshot, Events> {
121
44
  }
122
45
  export declare const syncManualLayoutActorLogic: SyncLayoutActorLogic;
123
46
  export {};
@@ -1,92 +1,303 @@
1
- import { getNodeDimensions, getBoundsOfRects, boxToRect } from '@xyflow/system';
2
- import { reduce, hasAtLeast } from 'remeda';
3
- import { setup, assign } from 'xstate';
4
- import { isSamePoint, bezierControlPoints } from '../../utils/xyflow.js';
1
+ import { getHotkeyHandler } from '@mantine/hooks';
2
+ import { last, omit } from 'remeda';
3
+ import { setup, assign, stopChild, fromCallback, assertEvent } from 'xstate';
4
+ import { createViewChange } from './createViewChange.js';
5
5
 
6
- const _syncManualLayoutActorLogic = setup({
6
+ const undoHotKeyActorLogic = fromCallback(({ sendBack }) => {
7
+ const ctrlZHandler = getHotkeyHandler([
8
+ ["mod + z", (event) => {
9
+ event.stopPropagation();
10
+ sendBack({ type: "undo" });
11
+ }, {
12
+ preventDefault: true
13
+ }]
14
+ ]);
15
+ document.body.addEventListener("keydown", ctrlZHandler, { capture: true });
16
+ return () => {
17
+ document.body.removeEventListener("keydown", ctrlZHandler, { capture: true });
18
+ };
19
+ });
20
+ const diagramActorRef = function(system) {
21
+ return system.get("diagram");
22
+ };
23
+ const syncManualLayout = setup({
7
24
  types: {
8
25
  context: {},
9
26
  input: {},
10
27
  events: {},
11
- tags: ""
28
+ tags: "",
29
+ children: {}
12
30
  },
13
31
  delays: {
14
32
  "timeout": 2e3
15
33
  },
16
- actions: {
17
- "trigger:OnChange": (_, _params) => {
18
- }
19
- },
20
34
  guards: {
21
- "same view": ({ context }) => context.parent.getSnapshot().context.view.id === context.viewId
35
+ "can undo": ({ context }) => context.history.length > 0
36
+ },
37
+ actors: {
38
+ undoHotKeyActorLogic
22
39
  }
23
- }).createMachine({
24
- initial: "idle",
25
- context: ({ input }) => ({
26
- ...input
27
- }),
28
- states: {
29
- idle: {
30
- tags: "ready",
31
- on: {
32
- sync: {
33
- target: "pending"
34
- }
40
+ });
41
+ const raiseSync = syncManualLayout.raise({ type: "sync" }, { delay: 300, id: "sync" });
42
+ const cancelSync = syncManualLayout.cancel("sync");
43
+ const startEditing = syncManualLayout.enqueueActions(({ check, enqueue, system, event, self, context }) => {
44
+ assertEvent(event, "editing.start");
45
+ const parentContext = diagramActorRef(system).getSnapshot().context;
46
+ enqueue.assign({
47
+ editing: event.subject,
48
+ beforeEditing: {
49
+ xynodes: parentContext.xynodes.map(
50
+ ({ measured, style, ...n }) => ({
51
+ ...omit(n, ["selected", "dragging", "resizing"]),
52
+ data: omit(n.data, ["dimmed", "hovered"]),
53
+ initialWidth: measured?.width ?? n.width ?? n.initialWidth,
54
+ initialHeight: measured?.height ?? n.height ?? n.initialHeight
55
+ })
56
+ ),
57
+ xyedges: parentContext.xyedges.map(
58
+ (e) => ({
59
+ ...omit(e, ["selected"]),
60
+ data: omit(e.data, ["active", "dimmed", "hovered"])
61
+ })
62
+ ),
63
+ change: createViewChange(parentContext),
64
+ view: parentContext.view,
65
+ synched: false
66
+ }
67
+ });
68
+ });
69
+ const ensureHotKey = syncManualLayout.enqueueActions(({ check, context, enqueue, self }) => {
70
+ const hasUndo = context.history.length > 0;
71
+ const undoHotKey = self.getSnapshot().children["undoHotKey"];
72
+ if (undoHotKey && !hasUndo) {
73
+ enqueue.stopChild(undoHotKey);
74
+ return;
75
+ }
76
+ if (!undoHotKey && hasUndo) {
77
+ enqueue.spawnChild("undoHotKeyActorLogic", {
78
+ id: "undoHotKey"
79
+ });
80
+ }
81
+ });
82
+ const pushHistory = syncManualLayout.assign(({ context }) => {
83
+ const snapshot = context.beforeEditing;
84
+ if (!snapshot) {
85
+ return {
86
+ editing: null
87
+ };
88
+ }
89
+ return {
90
+ beforeEditing: null,
91
+ editing: null,
92
+ history: [
93
+ ...context.history,
94
+ snapshot
95
+ ]
96
+ };
97
+ });
98
+ const stopEditing = syncManualLayout.enqueueActions(({ event, enqueue }) => {
99
+ assertEvent(event, ["editing.stop", "cancel", "undo"]);
100
+ if (event.type === "editing.stop" && event.wasChanged) {
101
+ enqueue(pushHistory);
102
+ enqueue(ensureHotKey);
103
+ enqueue(raiseSync);
104
+ return;
105
+ }
106
+ enqueue.assign({
107
+ beforeEditing: null,
108
+ editing: null
109
+ });
110
+ });
111
+ const markHistoryAsSynched = syncManualLayout.assign(({ context, event }) => {
112
+ assertEvent(event, "synced");
113
+ return {
114
+ history: context.history.map((i) => ({
115
+ ...i,
116
+ synched: true
117
+ }))
118
+ };
119
+ });
120
+ const popHistory = syncManualLayout.assign(({ context }) => {
121
+ if (context.history.length === 0 || context.history.length === 1) {
122
+ return {
123
+ history: []
124
+ };
125
+ }
126
+ return {
127
+ history: context.history.slice(0, context.history.length - 1)
128
+ };
129
+ });
130
+ const undo = syncManualLayout.enqueueActions(({ context, enqueue, system }) => {
131
+ enqueue(cancelSync);
132
+ const lastHistoryItem = last(context.history);
133
+ if (!lastHistoryItem) {
134
+ return;
135
+ }
136
+ enqueue(popHistory);
137
+ enqueue(ensureHotKey);
138
+ const diagramActor = diagramActorRef(system);
139
+ enqueue.sendTo(diagramActor, {
140
+ type: "update.view",
141
+ view: lastHistoryItem.view,
142
+ xyedges: lastHistoryItem.xyedges,
143
+ xynodes: lastHistoryItem.xynodes,
144
+ source: "internal"
145
+ });
146
+ if (lastHistoryItem.synched) {
147
+ enqueue.sendTo(
148
+ diagramActor,
149
+ {
150
+ type: "emit.onChange",
151
+ change: lastHistoryItem.change
35
152
  }
153
+ );
154
+ } else {
155
+ enqueue(raiseSync);
156
+ }
157
+ });
158
+ const emitOnChange = syncManualLayout.enqueueActions(({ context, enqueue, system }) => {
159
+ enqueue(cancelSync);
160
+ const diagramActor = diagramActorRef(system);
161
+ const parentContext = diagramActor.getSnapshot().context;
162
+ const change = createViewChange(parentContext);
163
+ enqueue.sendTo(diagramActor, {
164
+ type: "update.view-bounds",
165
+ bounds: change.layout.bounds
166
+ });
167
+ enqueue.sendTo(diagramActor, {
168
+ type: "emit.onChange",
169
+ change
170
+ });
171
+ });
172
+ const idle = syncManualLayout.createStateConfig({
173
+ tags: "ready",
174
+ on: {
175
+ sync: {
176
+ target: "pending"
36
177
  },
37
- paused: {
38
- tags: "pending",
39
- on: {
40
- sync: {
41
- target: "pending"
42
- }
43
- }
178
+ "editing.start": {
179
+ actions: startEditing,
180
+ target: "editing"
181
+ }
182
+ }
183
+ });
184
+ const editing = syncManualLayout.createStateConfig({
185
+ entry: [
186
+ cancelSync
187
+ ],
188
+ on: {
189
+ cancel: {
190
+ actions: stopEditing,
191
+ target: "idle"
44
192
  },
45
- pending: {
46
- tags: "pending",
47
- on: {
48
- sync: {
49
- target: "pending",
50
- reenter: true
51
- },
52
- cancel: {
53
- target: "paused"
54
- }
55
- },
56
- after: {
57
- "timeout": [{
58
- guard: "same view",
59
- actions: {
60
- type: "trigger:OnChange",
61
- params: ({ context }) => {
62
- const change = createViewChange(context.parent.getSnapshot().context);
63
- return { change };
64
- }
65
- },
66
- target: "synced"
67
- }, {
68
- target: "stopped"
69
- }]
70
- }
193
+ "editing.stop": {
194
+ actions: stopEditing,
195
+ target: "idle"
196
+ },
197
+ undo: {
198
+ actions: stopEditing,
199
+ target: "idle"
71
200
  },
72
201
  synced: {
73
- tags: "ready",
74
- on: {
75
- sync: {
76
- target: "pending"
77
- }
78
- }
202
+ actions: [
203
+ markHistoryAsSynched
204
+ ]
205
+ }
206
+ }
207
+ });
208
+ const pending = syncManualLayout.createStateConfig({
209
+ tags: "pending",
210
+ on: {
211
+ cancel: {
212
+ actions: cancelSync,
213
+ target: "idle"
214
+ },
215
+ sync: {
216
+ target: "pending",
217
+ reenter: true
218
+ },
219
+ "editing.start": {
220
+ target: "paused",
221
+ actions: startEditing
222
+ }
223
+ },
224
+ after: {
225
+ "timeout": {
226
+ target: "idle",
227
+ actions: emitOnChange
228
+ }
229
+ }
230
+ });
231
+ const paused = syncManualLayout.createStateConfig({
232
+ tags: "pending",
233
+ entry: [
234
+ cancelSync
235
+ ],
236
+ on: {
237
+ cancel: {
238
+ actions: stopEditing,
239
+ target: "idle"
240
+ },
241
+ "editing.stop": {
242
+ actions: stopEditing,
243
+ target: "pending"
244
+ },
245
+ undo: {
246
+ actions: stopEditing,
247
+ target: "idle"
79
248
  },
80
- "stopped": {
81
- entry: assign({
82
- parent: null
83
- }),
249
+ // When external sync is done while editing, we just mark history as synced
250
+ // but go to editing state (that does not return to pending)
251
+ synced: {
252
+ actions: [
253
+ markHistoryAsSynched
254
+ ],
255
+ target: "editing"
256
+ }
257
+ }
258
+ });
259
+ const _syncManualLayoutActorLogic = syncManualLayout.createMachine({
260
+ initial: "idle",
261
+ context: ({ input }) => ({
262
+ ...input,
263
+ history: [],
264
+ beforeEditing: null,
265
+ editing: null
266
+ }),
267
+ states: {
268
+ idle,
269
+ editing,
270
+ pending,
271
+ paused,
272
+ stopped: {
273
+ entry: [
274
+ assign({
275
+ beforeEditing: null,
276
+ history: []
277
+ }),
278
+ stopChild("undoHotKey")
279
+ ],
84
280
  type: "final"
85
281
  }
86
282
  },
87
283
  on: {
284
+ cancel: {
285
+ actions: [
286
+ cancelSync
287
+ ],
288
+ target: ".idle"
289
+ },
88
290
  synced: {
89
- target: ".synced"
291
+ actions: [
292
+ markHistoryAsSynched,
293
+ cancelSync
294
+ ],
295
+ target: ".idle"
296
+ },
297
+ undo: {
298
+ guard: "can undo",
299
+ actions: undo,
300
+ target: ".idle"
90
301
  },
91
302
  stop: {
92
303
  target: ".stopped"
@@ -94,80 +305,5 @@ const _syncManualLayoutActorLogic = setup({
94
305
  }
95
306
  });
96
307
  const syncManualLayoutActorLogic = _syncManualLayoutActorLogic;
97
- function createViewChange(parentContext) {
98
- const { view, xystore, xyflow } = parentContext;
99
- const { nodeLookup } = xystore.getState();
100
- const movedNodes = /* @__PURE__ */ new Set();
101
- let bounds;
102
- const nodes = reduce([...nodeLookup.values()], (acc, node) => {
103
- const dimensions = getNodeDimensions(node);
104
- if (!isSamePoint(node.internals.positionAbsolute, node.data) || node.initialWidth !== dimensions.width || node.initialHeight !== dimensions.height) {
105
- movedNodes.add(node.id);
106
- }
107
- const rect = acc[node.id] = {
108
- isCompound: node.type !== "element" && node.type !== "deployment",
109
- x: Math.floor(node.internals.positionAbsolute.x),
110
- y: Math.floor(node.internals.positionAbsolute.y),
111
- width: Math.ceil(dimensions.width),
112
- height: Math.ceil(dimensions.height)
113
- };
114
- bounds = bounds ? getBoundsOfRects(bounds, rect) : rect;
115
- return acc;
116
- }, {});
117
- const edges = reduce(xyflow?.getEdges() ?? [], (acc, { source, target, data }) => {
118
- let controlPoints = data.controlPoints ?? [];
119
- const sourceOrTargetMoved = movedNodes.has(source) || movedNodes.has(target);
120
- if (controlPoints.length === 0 && sourceOrTargetMoved) {
121
- controlPoints = bezierControlPoints(data);
122
- }
123
- if (data.points.length === 0 && controlPoints.length === 0) {
124
- return acc;
125
- }
126
- const _updated = acc[data.id] = {
127
- points: data.points
128
- };
129
- if (data.labelXY && data.labelBBox) {
130
- _updated.labelBBox = {
131
- ...data.labelBBox,
132
- ...data.labelXY
133
- };
134
- }
135
- if (data.labelBBox) {
136
- _updated.labelBBox ??= data.labelBBox;
137
- }
138
- if (hasAtLeast(controlPoints, 1)) {
139
- _updated.controlPoints = controlPoints;
140
- }
141
- const allX = [
142
- ...data.points.map((p) => p[0]),
143
- ...controlPoints.map((p) => p.x),
144
- ..._updated.labelBBox ? [_updated.labelBBox.x, _updated.labelBBox.x + _updated.labelBBox.width] : []
145
- ];
146
- const allY = [
147
- ...data.points.map((p) => p[1]),
148
- ...controlPoints.map((p) => p.y),
149
- ..._updated.labelBBox ? [_updated.labelBBox.y, _updated.labelBBox.y + _updated.labelBBox.height] : []
150
- ];
151
- const rect = boxToRect({
152
- x: Math.floor(Math.min(...allX)),
153
- y: Math.floor(Math.min(...allY)),
154
- x2: Math.ceil(Math.max(...allX)),
155
- y2: Math.ceil(Math.max(...allY))
156
- });
157
- bounds = bounds ? getBoundsOfRects(bounds, rect) : rect;
158
- return acc;
159
- }, {});
160
- bounds ??= view.bounds;
161
- return {
162
- op: "save-manual-layout",
163
- layout: {
164
- hash: view.hash,
165
- autoLayout: view.autoLayout,
166
- nodes,
167
- edges,
168
- ...bounds
169
- }
170
- };
171
- }
172
308
 
173
309
  export { syncManualLayoutActorLogic };
@@ -1,22 +1,17 @@
1
- import { ActorRefFromLogic, ActorSystem, EventFromLogic, SnapshotFrom } from 'xstate';
1
+ import { ActorSystem } from 'xstate';
2
2
  import { OverlaysActorRef } from '../../overlays/overlaysActor';
3
3
  import { SearchActorRef } from '../../search/searchActor';
4
- import { DiagramMachineLogic } from './diagram-machine';
5
- import { SyncLayoutActorLogic } from './syncManualLayoutActor';
4
+ import { DiagramMachineRef } from './machine';
5
+ import { SyncLayoutActorRef } from './syncManualLayoutActor';
6
6
  export type System = ActorSystem<{
7
7
  actors: {
8
- diagram: ActorRefFromLogic<DiagramMachineLogic>;
8
+ diagram: DiagramMachineRef;
9
9
  overlays: OverlaysActorRef;
10
10
  search: SearchActorRef;
11
+ syncLayout: SyncLayoutActorRef;
11
12
  };
12
13
  }>;
13
- export interface DiagramActorRef extends ActorRefFromLogic<DiagramMachineLogic> {
14
+ export interface DiagramActorRef extends DiagramMachineRef {
14
15
  system: System;
15
16
  }
16
- export type DiagramActorSnapshot = SnapshotFrom<DiagramMachineLogic>;
17
- export type DiagramActorEvent = EventFromLogic<DiagramMachineLogic>;
18
- export type { Context as DiagramContext, EmittedEvents as DiagramEmittedEvents, } from './diagram-machine';
19
- export type SyncLayoutActorRef = Omit<ActorRefFromLogic<SyncLayoutActorLogic>, 'system'> & {
20
- system: System;
21
- };
22
- export type SyncLayoutActorSnapshot = SnapshotFrom<SyncLayoutActorLogic>;
17
+ export type { DiagramContext, DiagramEmittedEvents, DiagramEvents, DiagramMachineSnapshot as DiagramActorSnapshot, } from './machine';
@@ -1,12 +1,17 @@
1
- import { DiagramEdge, DiagramNode, BBox } from '@likec4/core/types';
1
+ import { DiagramEdge, DiagramNode, DiagramView, BBox } from '@likec4/core/types';
2
+ import { Viewport } from '@xyflow/system';
2
3
  import { ActorSystem } from 'xstate';
3
4
  import { OverlaysActorRef } from '../../overlays/overlaysActor';
4
5
  import { SearchActorRef } from '../../search/searchActor';
5
- import { Context } from './diagram-machine';
6
+ import { Types } from '../types';
7
+ import { Context } from './machine.setup';
8
+ import { SyncLayoutActorRef } from './syncManualLayoutActor';
6
9
  import { DiagramActorRef } from './types';
10
+ import { Fqn, DeploymentFqn } from '@likec4/core';
7
11
  export declare function typedSystem(system: ActorSystem<any>): {
12
+ readonly syncLayoutActorRef: SyncLayoutActorRef | null;
8
13
  readonly overlaysActorRef: OverlaysActorRef | null;
9
- readonly diagramActorRef: DiagramActorRef | null;
14
+ readonly diagramActorRef: DiagramActorRef;
10
15
  readonly searchActorRef: SearchActorRef | null;
11
16
  };
12
17
  export declare function findDiagramNode(ctx: Context, xynodeId: string): DiagramNode | null;
@@ -21,5 +26,15 @@ export declare function activeSequenceBounds(params: {
21
26
  context: Context;
22
27
  }): {
23
28
  bounds: BBox;
24
- duration?: number;
29
+ duration: number;
30
+ };
31
+ export declare function nodeRef(node: Types.Node): Fqn | DeploymentFqn | null;
32
+ export declare function findCorrespondingNode(context: Pick<Context, 'lastOnNavigate' | 'xynodes'>, event: {
33
+ view: DiagramView;
34
+ xynodes: Types.Node[];
35
+ }): {
36
+ fromNode: Types.Node<"element" | "deployment" | "compound-element" | "compound-deployment" | "view-group" | "seq-actor" | "seq-parallel"> | null | undefined;
37
+ toNode: Types.Node<"element" | "deployment" | "compound-element" | "compound-deployment" | "view-group" | "seq-actor" | "seq-parallel"> | null | undefined;
25
38
  };
39
+ export declare function calcViewportForBounds(context: Pick<Context, 'xystore' | 'xyflow' | 'fitViewPadding'>, bounds: BBox): Viewport;
40
+ export declare function parseAsNumber(value: string | number | undefined): number;