@likec4/diagram 1.55.1 → 1.57.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 (384) hide show
  1. package/dist/LikeC4Diagram.js +150 -194
  2. package/dist/LikeC4ModelProvider.js +13 -9
  3. package/dist/LikeC4ProjectsOverview.js +24 -30
  4. package/dist/LikeC4ProjectsProvider.js +33 -26
  5. package/dist/LikeC4Styles.js +40 -57
  6. package/dist/LikeC4View.js +148 -196
  7. package/dist/ReactLikeC4.js +43 -65
  8. package/dist/StaticLikeC4Diagram.js +36 -41
  9. package/dist/_virtual/_rolldown/runtime.js +17 -0
  10. package/dist/adhoc-editor/EditorPanel.js +102 -101
  11. package/dist/adhoc-editor/ElementsTree.js +109 -139
  12. package/dist/adhoc-editor/LikeC4AdHocViewEditor.js +77 -70
  13. package/dist/adhoc-editor/components/Tree.d.ts +2 -2
  14. package/dist/adhoc-editor/components/Tree.js +205 -288
  15. package/dist/adhoc-editor/hooks.js +28 -23
  16. package/dist/adhoc-editor/index.js +2 -1
  17. package/dist/adhoc-editor/state/ActorProvider.js +33 -36
  18. package/dist/adhoc-editor/state/actor.editor.js +148 -186
  19. package/dist/adhoc-editor/state/actor.js +12 -14
  20. package/dist/adhoc-editor/state/actor.layouter.js +49 -65
  21. package/dist/adhoc-editor/state/actor.types.js +19 -23
  22. package/dist/adhoc-editor/state/panel.js +112 -127
  23. package/dist/adhoc-editor/state/utils.js +22 -29
  24. package/dist/adhoc-editor/useElementsTree.js +89 -121
  25. package/dist/base/Background.js +26 -29
  26. package/dist/base/Base.js +34 -41
  27. package/dist/base/BaseXYFlow.js +135 -165
  28. package/dist/base/const.js +18 -19
  29. package/dist/base/updateEdges.js +38 -57
  30. package/dist/base/updateNodes.js +46 -65
  31. package/dist/base-primitives/Markdown.d.ts +1 -1
  32. package/dist/base-primitives/Markdown.js +32 -47
  33. package/dist/base-primitives/NodeHandles.js +39 -49
  34. package/dist/base-primitives/compound/CompoundActionButton.js +49 -69
  35. package/dist/base-primitives/compound/CompoundDetailsButton.js +39 -64
  36. package/dist/base-primitives/compound/CompoundNodeContainer.js +46 -66
  37. package/dist/base-primitives/compound/CompoundTitle.js +15 -12
  38. package/dist/base-primitives/compound/actionbtns.css.js +9 -18
  39. package/dist/base-primitives/edge/EdgeActionButton.js +17 -19
  40. package/dist/base-primitives/edge/EdgeContainer.js +29 -48
  41. package/dist/base-primitives/edge/EdgeLabel.js +44 -65
  42. package/dist/base-primitives/edge/EdgeLabelContainer.js +35 -73
  43. package/dist/base-primitives/edge/EdgeMarkers.js +157 -215
  44. package/dist/base-primitives/edge/EdgePath.js +62 -115
  45. package/dist/base-primitives/element/ElementActionButtons.js +92 -81
  46. package/dist/base-primitives/element/ElementData.js +107 -126
  47. package/dist/base-primitives/element/ElementDetailsButton.js +78 -98
  48. package/dist/base-primitives/element/ElementNodeContainer.js +51 -82
  49. package/dist/base-primitives/element/ElementShape.js +331 -317
  50. package/dist/base-primitives/element/ElementTags.d.ts +1 -1
  51. package/dist/base-primitives/element/ElementTags.js +133 -193
  52. package/dist/base-primitives/memoEdge.js +11 -10
  53. package/dist/base-primitives/memoNode.js +16 -20
  54. package/dist/components/ErrorFallback.js +111 -75
  55. package/dist/components/GithubIcon.js +14 -16
  56. package/dist/components/Link.js +99 -113
  57. package/dist/components/Logo.js +38 -41
  58. package/dist/components/NavigationLink.js +15 -23
  59. package/dist/components/NavigationPanel.js +26 -47
  60. package/dist/components/PortalToContainer.js +16 -10
  61. package/dist/components/RootContainer.js +36 -31
  62. package/dist/components/SearchControl.css.js +65 -75
  63. package/dist/components/SearchControl.js +36 -14
  64. package/dist/components/ViewNotFound.js +22 -29
  65. package/dist/context/CurrentViewModelProvider.js +11 -9
  66. package/dist/context/DefaultMantineProvider.js +45 -72
  67. package/dist/context/DiagramEventHandlers.js +43 -48
  68. package/dist/context/DiagramFeatures.d.ts +1 -1
  69. package/dist/context/DiagramFeatures.js +78 -69
  70. package/dist/context/EnsureMantine.js +13 -16
  71. package/dist/context/FramerMotionConfig.js +17 -11
  72. package/dist/context/IconRenderer.js +90 -106
  73. package/dist/context/LikeC4ModelContext.js +14 -10
  74. package/dist/context/LikeC4ProjectsContext.js +7 -6
  75. package/dist/context/RootContainerContext.d.ts +9 -19
  76. package/dist/context/RootContainerContext.js +14 -28
  77. package/dist/context/TagStylesContext.js +49 -57
  78. package/dist/custom/customNodes.js +224 -28
  79. package/dist/custom/index.d.ts +1 -1
  80. package/dist/custom/index.js +40 -40
  81. package/dist/editor/LikeC4EditorCallbacks.d.ts +5 -0
  82. package/dist/editor/LikeC4EditorCallbacks.js +4 -2
  83. package/dist/editor/LikeC4EditorProvider.js +32 -7
  84. package/dist/editor/actor/actions.d.ts +115 -0
  85. package/dist/editor/actor/actions.js +122 -0
  86. package/dist/editor/{hotkeyActor.d.ts → actor/hotkey.d.ts} +1 -1
  87. package/dist/editor/actor/hotkey.js +20 -0
  88. package/dist/editor/actor/machine.d.ts +11 -0
  89. package/dist/editor/actor/machine.js +22 -0
  90. package/dist/editor/{editorActor.setup.d.ts → actor/setup.d.ts} +13 -49
  91. package/dist/editor/actor/setup.js +35 -0
  92. package/dist/editor/actor/state.editor.d.ts +97 -0
  93. package/dist/editor/actor/state.editor.js +55 -0
  94. package/dist/editor/actor/state.sync-queue.d.ts +420 -0
  95. package/dist/editor/actor/state.sync-queue.js +235 -0
  96. package/dist/editor/actor/types.d.ts +59 -0
  97. package/dist/editor/actor/types.js +5 -0
  98. package/dist/editor/applyChangesToManualLayout.js +144 -163
  99. package/dist/editor/index.d.ts +2 -1
  100. package/dist/editor/useEditorActorLogic.d.ts +8 -2
  101. package/dist/editor/useEditorActorLogic.js +51 -43
  102. package/dist/hooks/safeContext.js +17 -17
  103. package/dist/hooks/useCallbackRef.js +18 -11
  104. package/dist/hooks/useCurrentView.js +16 -7
  105. package/dist/hooks/useCurrentViewModel.js +14 -9
  106. package/dist/hooks/useDiagram.js +60 -37
  107. package/dist/hooks/useDiagramCompareLayout.js +77 -81
  108. package/dist/hooks/useEditorActor.d.ts +4 -0
  109. package/dist/hooks/useEditorActor.js +26 -0
  110. package/dist/hooks/useId.js +8 -6
  111. package/dist/hooks/useLikeC4ElementsTree.d.ts +3 -2
  112. package/dist/hooks/useLikeC4ElementsTree.js +24 -21
  113. package/dist/hooks/useLikeC4Model.js +21 -20
  114. package/dist/hooks/useLikeC4Project.js +40 -29
  115. package/dist/hooks/useLikeC4Styles.js +6 -6
  116. package/dist/hooks/useMantinePortalProps.js +10 -6
  117. package/dist/hooks/useSetState.js +21 -19
  118. package/dist/hooks/useUpdateEffect.js +18 -29
  119. package/dist/hooks/useXYFlow.js +13 -15
  120. package/dist/index.js +24 -23
  121. package/dist/likec4diagram/DiagramUI.js +37 -37
  122. package/dist/likec4diagram/DiagramXYFlow.js +215 -224
  123. package/dist/likec4diagram/convert-to-xyflow.js +21 -22
  124. package/dist/likec4diagram/custom/edges/EdgeDrifts.js +22 -32
  125. package/dist/likec4diagram/custom/edges/RelationshipEdge.js +275 -372
  126. package/dist/likec4diagram/custom/edges/SequenceStepEdge.js +71 -75
  127. package/dist/likec4diagram/custom/edges/edges.css.js +41 -47
  128. package/dist/likec4diagram/custom/edges/useControlPoints.js +52 -56
  129. package/dist/likec4diagram/custom/edges/useRelationshipEdgePath.js +54 -76
  130. package/dist/likec4diagram/custom/index.js +17 -17
  131. package/dist/likec4diagram/custom/nodes/CompoundActions.js +19 -26
  132. package/dist/likec4diagram/custom/nodes/ElementActions.js +131 -82
  133. package/dist/likec4diagram/custom/nodes/NodeDrifts.js +20 -26
  134. package/dist/likec4diagram/custom/nodes/NodeNotes.js +215 -273
  135. package/dist/likec4diagram/custom/nodes/SequenceActorNode.js +131 -147
  136. package/dist/likec4diagram/custom/nodes/nodes.js +135 -146
  137. package/dist/likec4diagram/custom/nodes/toolbar/ColorButton.js +155 -159
  138. package/dist/likec4diagram/custom/nodes/toolbar/CompoundToolbar.js +58 -86
  139. package/dist/likec4diagram/custom/nodes/toolbar/ElementToolbar.js +108 -164
  140. package/dist/likec4diagram/custom/nodes/toolbar/Toolbar.js +56 -68
  141. package/dist/likec4diagram/custom/nodes/toolbar/_shared.d.ts +3 -6
  142. package/dist/likec4diagram/custom/nodes/toolbar/_shared.js +97 -102
  143. package/dist/likec4diagram/custom/nodes/toolbar/styles.css.js +13 -13
  144. package/dist/likec4diagram/custom/nodes/toolbar/types.js +6 -5
  145. package/dist/likec4diagram/custom/nodes/toolbar/useHandlers.js +36 -41
  146. package/dist/likec4diagram/relationship-popover/RelationshipPopover.js +510 -541
  147. package/dist/likec4diagram/relationship-popover/actor.js +113 -152
  148. package/dist/likec4diagram/relationship-popover/components.js +39 -43
  149. package/dist/likec4diagram/state/DiagramActorProvider.js +135 -136
  150. package/dist/likec4diagram/state/aligners.js +286 -360
  151. package/dist/likec4diagram/state/assign.js +84 -108
  152. package/dist/likec4diagram/state/createViewChange.js +72 -92
  153. package/dist/likec4diagram/state/diagram-api.d.ts +16 -0
  154. package/dist/likec4diagram/state/diagram-api.js +230 -152
  155. package/dist/likec4diagram/state/hotkeyActor.js +54 -45
  156. package/dist/likec4diagram/state/machine.actions.js +708 -821
  157. package/dist/likec4diagram/state/machine.actions.layout.js +154 -183
  158. package/dist/likec4diagram/state/machine.d.ts +1 -1
  159. package/dist/likec4diagram/state/machine.js +113 -134
  160. package/dist/likec4diagram/state/machine.setup.js +104 -113
  161. package/dist/likec4diagram/state/machine.state.initializing.js +54 -54
  162. package/dist/likec4diagram/state/machine.state.navigating.js +192 -227
  163. package/dist/likec4diagram/state/machine.state.ready.focused.js +72 -88
  164. package/dist/likec4diagram/state/machine.state.ready.idle.js +79 -98
  165. package/dist/likec4diagram/state/machine.state.ready.js +126 -202
  166. package/dist/likec4diagram/state/machine.state.ready.printing.js +38 -39
  167. package/dist/likec4diagram/state/machine.state.ready.walkthrough.js +153 -193
  168. package/dist/likec4diagram/state/mediaPrintActor.js +20 -16
  169. package/dist/likec4diagram/state/persistence.js +20 -21
  170. package/dist/likec4diagram/state/types.d.ts +1 -1
  171. package/dist/likec4diagram/state/utils.d.ts +1 -1
  172. package/dist/likec4diagram/state/utils.js +131 -162
  173. package/dist/likec4diagram/ui/LayoutDriftFrame.js +53 -64
  174. package/dist/likec4diagram/ui/notation/NotationPanel.css.js +58 -80
  175. package/dist/likec4diagram/ui/notation/NotationPanel.js +183 -214
  176. package/dist/likec4diagram/useLayoutConstraints.js +388 -433
  177. package/dist/likec4diagram/xyflow-diagram/diagram-view.js +216 -227
  178. package/dist/likec4diagram/xyflow-sequence/const.js +11 -7
  179. package/dist/likec4diagram/xyflow-sequence/sequence-layout.js +177 -180
  180. package/dist/navigationpanel/NavigationPanel.js +113 -123
  181. package/dist/navigationpanel/NavigationPanelControls.js +124 -150
  182. package/dist/navigationpanel/NavigationPanelDropdown.js +365 -477
  183. package/dist/navigationpanel/_common.d.ts +4 -10
  184. package/dist/navigationpanel/_common.js +57 -70
  185. package/dist/navigationpanel/actor.js +153 -236
  186. package/dist/navigationpanel/comparepanel/CompareActionsMenu.js +66 -83
  187. package/dist/navigationpanel/comparepanel/ComparePanel.js +135 -164
  188. package/dist/navigationpanel/comparepanel/ComparePanelControls.js +50 -58
  189. package/dist/navigationpanel/comparepanel/DriftsSummary.js +207 -254
  190. package/dist/navigationpanel/comparepanel/LayoutTypeSwitcher.js +33 -35
  191. package/dist/navigationpanel/controls/DetailsControls.js +219 -246
  192. package/dist/navigationpanel/controls/LayoutWarning.js +89 -100
  193. package/dist/navigationpanel/controls/LogoButton.js +46 -70
  194. package/dist/navigationpanel/controls/NavigationButtons.js +35 -52
  195. package/dist/navigationpanel/controls/OpenSource.js +27 -25
  196. package/dist/navigationpanel/controls/SearchControl.js +50 -61
  197. package/dist/navigationpanel/controls/ToggleReadonly.js +86 -81
  198. package/dist/navigationpanel/dropdown/ProjectsMenu.js +69 -87
  199. package/dist/navigationpanel/editorpanel/ApplySemanticLayout.d.ts +4 -0
  200. package/dist/navigationpanel/editorpanel/ApplySemanticLayout.js +36 -0
  201. package/dist/navigationpanel/editorpanel/CenterCamera.js +17 -13
  202. package/dist/navigationpanel/editorpanel/ChangeAutoLayoutButton.js +182 -154
  203. package/dist/navigationpanel/editorpanel/EditorPanel.js +59 -45
  204. package/dist/navigationpanel/editorpanel/ManualLayoutToolsButton.js +122 -173
  205. package/dist/navigationpanel/editorpanel/ToggleReadonly.js +20 -13
  206. package/dist/navigationpanel/editorpanel/_common.d.ts +3 -6
  207. package/dist/navigationpanel/editorpanel/_common.js +13 -13
  208. package/dist/navigationpanel/editorpanel/styles.js +58 -75
  209. package/dist/navigationpanel/hooks.js +35 -29
  210. package/dist/navigationpanel/styles.css.js +20 -28
  211. package/dist/navigationpanel/walkthrough/ActiveWalkthroughControls.js +107 -134
  212. package/dist/navigationpanel/walkthrough/DynamicViewControls.d.ts +65 -65
  213. package/dist/navigationpanel/walkthrough/DynamicViewControls.js +105 -120
  214. package/dist/navigationpanel/walkthrough/WalkthroughPanel.js +75 -83
  215. package/dist/overlays/Overlays.js +94 -112
  216. package/dist/overlays/element-details/ElementDetails.js +22 -28
  217. package/dist/overlays/element-details/ElementDetailsCard.css.js +198 -221
  218. package/dist/overlays/element-details/ElementDetailsCard.js +517 -499
  219. package/dist/overlays/element-details/MetadataValue.js +210 -250
  220. package/dist/overlays/element-details/TabPanelDeployments.css.js +40 -60
  221. package/dist/overlays/element-details/TabPanelDeployments.js +185 -178
  222. package/dist/overlays/element-details/TabPanelRelationships.css.js +63 -71
  223. package/dist/overlays/element-details/TabPanelRelationships.js +155 -140
  224. package/dist/overlays/element-details/TabPanelStructure.css.js +29 -33
  225. package/dist/overlays/element-details/TabPanelStructure.js +93 -93
  226. package/dist/overlays/element-details/actor.js +45 -55
  227. package/dist/overlays/element-details/actorContext.js +12 -10
  228. package/dist/overlays/overlay/Overlay.d.ts +16 -0
  229. package/dist/overlays/overlay/Overlay.js +102 -151
  230. package/dist/overlays/overlaysActor.js +215 -265
  231. package/dist/overlays/relationship-details/RelationshipDetails.js +270 -253
  232. package/dist/overlays/relationship-details/SelectEdge.css.js +62 -74
  233. package/dist/overlays/relationship-details/SelectEdge.js +146 -126
  234. package/dist/overlays/relationship-details/actor.js +242 -303
  235. package/dist/overlays/relationship-details/compute.js +109 -135
  236. package/dist/overlays/relationship-details/custom/ElementActions.js +43 -56
  237. package/dist/overlays/relationship-details/custom/edgeTypes.js +43 -49
  238. package/dist/overlays/relationship-details/custom/nodeTypes.d.ts +4 -5
  239. package/dist/overlays/relationship-details/custom/nodeTypes.js +96 -121
  240. package/dist/overlays/relationship-details/hooks.js +44 -38
  241. package/dist/overlays/relationship-details/layout-to-xyflow.js +119 -141
  242. package/dist/overlays/relationship-details/layout.js +275 -304
  243. package/dist/overlays/relationships-browser/RelationshipsBrowser.js +319 -321
  244. package/dist/overlays/relationships-browser/SelectElement.css.js +18 -21
  245. package/dist/overlays/relationships-browser/SelectElement.js +192 -218
  246. package/dist/overlays/relationships-browser/actor.js +364 -462
  247. package/dist/overlays/relationships-browser/const.js +7 -6
  248. package/dist/overlays/relationships-browser/custom/ElementActions.js +60 -63
  249. package/dist/overlays/relationships-browser/custom/EmptyNode.js +25 -29
  250. package/dist/overlays/relationships-browser/custom/edgeTypes.js +66 -99
  251. package/dist/overlays/relationships-browser/custom/nodeTypes.js +98 -123
  252. package/dist/overlays/relationships-browser/hooks.js +49 -51
  253. package/dist/overlays/relationships-browser/layout.js +413 -465
  254. package/dist/overlays/relationships-browser/useViewToNodesEdges.js +141 -157
  255. package/dist/projects-overview/ProjectsOverview.js +56 -55
  256. package/dist/projects-overview/ProjectsOverviewXY.js +105 -94
  257. package/dist/projects-overview/actor.js +252 -345
  258. package/dist/projects-overview/context.js +8 -7
  259. package/dist/projects-overview/custom/edgeTypes.js +22 -21
  260. package/dist/projects-overview/custom/nodeTypes.js +38 -42
  261. package/dist/projects-overview/hooks.js +9 -9
  262. package/dist/projects-overview/layouted-to-xyflow.js +46 -42
  263. package/dist/projects-overview/panel/ProjectsOverviewPanel.js +7 -9
  264. package/dist/projects-overview/persistence.js +22 -22
  265. package/dist/search/Search.d.ts +6 -3
  266. package/dist/search/Search.js +189 -182
  267. package/dist/search/SearchContext.js +16 -15
  268. package/dist/search/XStateSearchAdapter.js +68 -62
  269. package/dist/search/components/ElementsColumn.css.js +50 -68
  270. package/dist/search/components/ElementsColumn.js +253 -291
  271. package/dist/search/components/PickView.js +116 -140
  272. package/dist/search/components/SearchByTags.js +76 -94
  273. package/dist/search/components/SearchInput.js +187 -209
  274. package/dist/search/components/ViewsColum.js +151 -141
  275. package/dist/search/components/ViewsColumn.css.js +12 -26
  276. package/dist/search/components/_shared.css.js +127 -153
  277. package/dist/search/components/styles.css.js +47 -53
  278. package/dist/search/components/utils.js +44 -47
  279. package/dist/search/hooks.js +10 -10
  280. package/dist/search/searchActor.js +97 -128
  281. package/dist/shadowroot/ShadowRoot.d.ts +7 -6
  282. package/dist/shadowroot/ShadowRoot.js +106 -79
  283. package/dist/shadowroot/styles.css.d.ts +10 -2
  284. package/dist/shadowroot/styles.css.js +56 -69
  285. package/dist/styles-font2.js +4 -0
  286. package/dist/styles2.js +4 -0
  287. package/dist/utils/index.js +5 -0
  288. package/dist/utils/roundDpr.js +19 -15
  289. package/dist/utils/view-bounds.js +48 -55
  290. package/dist/utils/xyflow.js +143 -113
  291. package/package.json +18 -25
  292. package/panda.buildinfo.json +15 -15
  293. package/src/styles-font.css +114 -0
  294. package/src/styles-min.css +2 -0
  295. package/src/styles-xyflow.css +1 -0
  296. package/src/styles.css +3 -0
  297. package/styles-font.css +1 -1
  298. package/styles-min.css +1 -1
  299. package/styles-xyflow.css +1 -1
  300. package/styles.css +1 -1
  301. package/dist/_virtual/_commonjsHelpers.js +0 -3
  302. package/dist/_virtual/assign-f10db67b.cjs.js +0 -3
  303. package/dist/_virtual/log-30abbb83.cjs.js +0 -3
  304. package/dist/_virtual/raise-f051f097.cjs.js +0 -3
  305. package/dist/_virtual/store-cfe7da62.cjs.js +0 -3
  306. package/dist/_virtual/xstate-actions.cjs.js +0 -5
  307. package/dist/_virtual/xstate-actions.cjs2.js +0 -3
  308. package/dist/_virtual/xstate-dev.cjs.js +0 -3
  309. package/dist/_virtual/xstate-guards.cjs.js +0 -5
  310. package/dist/_virtual/xstate-guards.cjs2.js +0 -3
  311. package/dist/_virtual/xstate-store-react.cjs.js +0 -5
  312. package/dist/_virtual/xstate-store-react.cjs2.js +0 -3
  313. package/dist/bundle/index.d.ts +0 -1
  314. package/dist/editor/editorActor.actions.d.ts +0 -153
  315. package/dist/editor/editorActor.actions.js +0 -149
  316. package/dist/editor/editorActor.setup.js +0 -38
  317. package/dist/editor/editorActor.states.d.ts +0 -9
  318. package/dist/editor/editorActor.states.js +0 -273
  319. package/dist/editor/hotkeyActor.js +0 -19
  320. package/dist/hooks/useOverlaysActor.js +0 -10
  321. package/dist/hooks/useSearchActor.js +0 -10
  322. package/dist/node_modules/.pnpm/@tabler_icons-react@3.40.0_react@19.2.4/node_modules/@tabler/icons-react/dist/esm/createReactComponent.js +0 -41
  323. package/dist/node_modules/.pnpm/@tabler_icons-react@3.40.0_react@19.2.4/node_modules/@tabler/icons-react/dist/esm/defaultAttributes.js +0 -30
  324. package/dist/node_modules/.pnpm/@tabler_icons-react@3.40.0_react@19.2.4/node_modules/@tabler/icons-react/dist/esm/icons/IconAlertTriangle.js +0 -14
  325. package/dist/node_modules/.pnpm/@tabler_icons-react@3.40.0_react@19.2.4/node_modules/@tabler/icons-react/dist/esm/icons/IconArrowDownRight.js +0 -14
  326. package/dist/node_modules/.pnpm/@tabler_icons-react@3.40.0_react@19.2.4/node_modules/@tabler/icons-react/dist/esm/icons/IconArrowLeft.js +0 -14
  327. package/dist/node_modules/.pnpm/@tabler_icons-react@3.40.0_react@19.2.4/node_modules/@tabler/icons-react/dist/esm/icons/IconArrowRight.js +0 -14
  328. package/dist/node_modules/.pnpm/@tabler_icons-react@3.40.0_react@19.2.4/node_modules/@tabler/icons-react/dist/esm/icons/IconBolt.js +0 -14
  329. package/dist/node_modules/.pnpm/@tabler_icons-react@3.40.0_react@19.2.4/node_modules/@tabler/icons-react/dist/esm/icons/IconBrowser.js +0 -14
  330. package/dist/node_modules/.pnpm/@tabler_icons-react@3.40.0_react@19.2.4/node_modules/@tabler/icons-react/dist/esm/icons/IconCheck.js +0 -14
  331. package/dist/node_modules/.pnpm/@tabler_icons-react@3.40.0_react@19.2.4/node_modules/@tabler/icons-react/dist/esm/icons/IconChevronDown.js +0 -14
  332. package/dist/node_modules/.pnpm/@tabler_icons-react@3.40.0_react@19.2.4/node_modules/@tabler/icons-react/dist/esm/icons/IconChevronLeft.js +0 -14
  333. package/dist/node_modules/.pnpm/@tabler_icons-react@3.40.0_react@19.2.4/node_modules/@tabler/icons-react/dist/esm/icons/IconChevronRight.js +0 -14
  334. package/dist/node_modules/.pnpm/@tabler_icons-react@3.40.0_react@19.2.4/node_modules/@tabler/icons-react/dist/esm/icons/IconCopy.js +0 -14
  335. package/dist/node_modules/.pnpm/@tabler_icons-react@3.40.0_react@19.2.4/node_modules/@tabler/icons-react/dist/esm/icons/IconCylinder.js +0 -14
  336. package/dist/node_modules/.pnpm/@tabler_icons-react@3.40.0_react@19.2.4/node_modules/@tabler/icons-react/dist/esm/icons/IconDeviceMobile.js +0 -14
  337. package/dist/node_modules/.pnpm/@tabler_icons-react@3.40.0_react@19.2.4/node_modules/@tabler/icons-react/dist/esm/icons/IconDirectionSignFilled.js +0 -14
  338. package/dist/node_modules/.pnpm/@tabler_icons-react@3.40.0_react@19.2.4/node_modules/@tabler/icons-react/dist/esm/icons/IconExternalLink.js +0 -14
  339. package/dist/node_modules/.pnpm/@tabler_icons-react@3.40.0_react@19.2.4/node_modules/@tabler/icons-react/dist/esm/icons/IconFileSymlink.js +0 -14
  340. package/dist/node_modules/.pnpm/@tabler_icons-react@3.40.0_react@19.2.4/node_modules/@tabler/icons-react/dist/esm/icons/IconFileText.js +0 -14
  341. package/dist/node_modules/.pnpm/@tabler_icons-react@3.40.0_react@19.2.4/node_modules/@tabler/icons-react/dist/esm/icons/IconFocusCentered.js +0 -14
  342. package/dist/node_modules/.pnpm/@tabler_icons-react@3.40.0_react@19.2.4/node_modules/@tabler/icons-react/dist/esm/icons/IconFolderFilled.js +0 -14
  343. package/dist/node_modules/.pnpm/@tabler_icons-react@3.40.0_react@19.2.4/node_modules/@tabler/icons-react/dist/esm/icons/IconHelpCircle.js +0 -14
  344. package/dist/node_modules/.pnpm/@tabler_icons-react@3.40.0_react@19.2.4/node_modules/@tabler/icons-react/dist/esm/icons/IconId.js +0 -14
  345. package/dist/node_modules/.pnpm/@tabler_icons-react@3.40.0_react@19.2.4/node_modules/@tabler/icons-react/dist/esm/icons/IconInfoCircle.js +0 -14
  346. package/dist/node_modules/.pnpm/@tabler_icons-react@3.40.0_react@19.2.4/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutAlignBottom.js +0 -14
  347. package/dist/node_modules/.pnpm/@tabler_icons-react@3.40.0_react@19.2.4/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutAlignCenter.js +0 -14
  348. package/dist/node_modules/.pnpm/@tabler_icons-react@3.40.0_react@19.2.4/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutAlignLeft.js +0 -14
  349. package/dist/node_modules/.pnpm/@tabler_icons-react@3.40.0_react@19.2.4/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutAlignMiddle.js +0 -14
  350. package/dist/node_modules/.pnpm/@tabler_icons-react@3.40.0_react@19.2.4/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutAlignRight.js +0 -14
  351. package/dist/node_modules/.pnpm/@tabler_icons-react@3.40.0_react@19.2.4/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutAlignTop.js +0 -14
  352. package/dist/node_modules/.pnpm/@tabler_icons-react@3.40.0_react@19.2.4/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutBoardSplit.js +0 -14
  353. package/dist/node_modules/.pnpm/@tabler_icons-react@3.40.0_react@19.2.4/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutCollage.js +0 -14
  354. package/dist/node_modules/.pnpm/@tabler_icons-react@3.40.0_react@19.2.4/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutDashboard.js +0 -14
  355. package/dist/node_modules/.pnpm/@tabler_icons-react@3.40.0_react@19.2.4/node_modules/@tabler/icons-react/dist/esm/icons/IconLink.js +0 -14
  356. package/dist/node_modules/.pnpm/@tabler_icons-react@3.40.0_react@19.2.4/node_modules/@tabler/icons-react/dist/esm/icons/IconLock.js +0 -14
  357. package/dist/node_modules/.pnpm/@tabler_icons-react@3.40.0_react@19.2.4/node_modules/@tabler/icons-react/dist/esm/icons/IconLockOpen2.js +0 -14
  358. package/dist/node_modules/.pnpm/@tabler_icons-react@3.40.0_react@19.2.4/node_modules/@tabler/icons-react/dist/esm/icons/IconPlayerPlayFilled.js +0 -14
  359. package/dist/node_modules/.pnpm/@tabler_icons-react@3.40.0_react@19.2.4/node_modules/@tabler/icons-react/dist/esm/icons/IconPlayerSkipBackFilled.js +0 -14
  360. package/dist/node_modules/.pnpm/@tabler_icons-react@3.40.0_react@19.2.4/node_modules/@tabler/icons-react/dist/esm/icons/IconPlayerSkipForwardFilled.js +0 -14
  361. package/dist/node_modules/.pnpm/@tabler_icons-react@3.40.0_react@19.2.4/node_modules/@tabler/icons-react/dist/esm/icons/IconPlayerStopFilled.js +0 -14
  362. package/dist/node_modules/.pnpm/@tabler_icons-react@3.40.0_react@19.2.4/node_modules/@tabler/icons-react/dist/esm/icons/IconRectangularPrism.js +0 -14
  363. package/dist/node_modules/.pnpm/@tabler_icons-react@3.40.0_react@19.2.4/node_modules/@tabler/icons-react/dist/esm/icons/IconReorder.js +0 -14
  364. package/dist/node_modules/.pnpm/@tabler_icons-react@3.40.0_react@19.2.4/node_modules/@tabler/icons-react/dist/esm/icons/IconRouteOff.js +0 -14
  365. package/dist/node_modules/.pnpm/@tabler_icons-react@3.40.0_react@19.2.4/node_modules/@tabler/icons-react/dist/esm/icons/IconSearch.js +0 -14
  366. package/dist/node_modules/.pnpm/@tabler_icons-react@3.40.0_react@19.2.4/node_modules/@tabler/icons-react/dist/esm/icons/IconSelector.js +0 -14
  367. package/dist/node_modules/.pnpm/@tabler_icons-react@3.40.0_react@19.2.4/node_modules/@tabler/icons-react/dist/esm/icons/IconStack2.js +0 -14
  368. package/dist/node_modules/.pnpm/@tabler_icons-react@3.40.0_react@19.2.4/node_modules/@tabler/icons-react/dist/esm/icons/IconStarFilled.js +0 -14
  369. package/dist/node_modules/.pnpm/@tabler_icons-react@3.40.0_react@19.2.4/node_modules/@tabler/icons-react/dist/esm/icons/IconTarget.js +0 -14
  370. package/dist/node_modules/.pnpm/@tabler_icons-react@3.40.0_react@19.2.4/node_modules/@tabler/icons-react/dist/esm/icons/IconTransform.js +0 -14
  371. package/dist/node_modules/.pnpm/@tabler_icons-react@3.40.0_react@19.2.4/node_modules/@tabler/icons-react/dist/esm/icons/IconTrash.js +0 -14
  372. package/dist/node_modules/.pnpm/@tabler_icons-react@3.40.0_react@19.2.4/node_modules/@tabler/icons-react/dist/esm/icons/IconUser.js +0 -14
  373. package/dist/node_modules/.pnpm/@tabler_icons-react@3.40.0_react@19.2.4/node_modules/@tabler/icons-react/dist/esm/icons/IconX.js +0 -14
  374. package/dist/node_modules/.pnpm/@tabler_icons-react@3.40.0_react@19.2.4/node_modules/@tabler/icons-react/dist/esm/icons/IconZoomScan.js +0 -14
  375. package/dist/node_modules/.pnpm/@xstate_store@3.17.1_react@19.2.4/node_modules/@xstate/store/dist/store-cfe7da62.cjs.js +0 -761
  376. package/dist/node_modules/.pnpm/@xstate_store@3.17.1_react@19.2.4/node_modules/@xstate/store/react/dist/xstate-store-react.cjs.js +0 -180
  377. package/dist/node_modules/.pnpm/xstate@5.30.0/node_modules/xstate/actions/dist/xstate-actions.cjs.js +0 -37
  378. package/dist/node_modules/.pnpm/xstate@5.30.0/node_modules/xstate/dev/dist/xstate-dev.cjs.js +0 -59
  379. package/dist/node_modules/.pnpm/xstate@5.30.0/node_modules/xstate/dist/assign-f10db67b.cjs.js +0 -140
  380. package/dist/node_modules/.pnpm/xstate@5.30.0/node_modules/xstate/dist/log-30abbb83.cjs.js +0 -401
  381. package/dist/node_modules/.pnpm/xstate@5.30.0/node_modules/xstate/dist/raise-f051f097.cjs.js +0 -2830
  382. package/dist/node_modules/.pnpm/xstate@5.30.0/node_modules/xstate/guards/dist/xstate-guards.cjs.js +0 -26
  383. package/dist/styles-font.css2.js +0 -3
  384. package/dist/styles.css2.js +0 -3
@@ -1,478 +1,426 @@
1
- import { computeRelationshipsView, treeFromElements } from '@likec4/core/compute-view';
2
- import { useMemo } from 'react';
3
- import dagre from '@dagrejs/dagre';
4
- import { preferSummary, exact } from '@likec4/core/types';
5
- import { toArray, invariant, ifind, nonNullable, DefaultMap } from '@likec4/core/utils';
6
- import { pipe, concat, map, groupBy, prop, forEachObj, filter, mapToObj, omit, find, only, unique, tap, reduce, sortBy } from 'remeda';
7
- import { useLikeC4Model } from '../../hooks/useLikeC4Model.js';
8
-
9
- const Sizes = {
10
- dagre: {
11
- ranksep: 60,
12
- nodesep: 35,
13
- edgesep: 25
14
- },
15
- edgeLabel: {
16
- width: 140,
17
- height: 10,
18
- minlen: 1,
19
- weight: 1
20
- },
21
- emptyNodeOffset: 120,
22
- nodeWidth: 330,
23
- nodeHeight: 180,
24
- compound: {
25
- labelHeight: 2,
26
- paddingTop: 50,
27
- paddingBottom: 32
28
- }
1
+ import "../../_virtual/_rolldown/runtime.js";
2
+ import { useLikeC4Model } from "../../hooks/useLikeC4Model.js";
3
+ import { useMemo } from "react";
4
+ import { concat, filter, find, forEachObj, groupBy, map, mapToObj, omit, only, pipe, prop, reduce, sortBy, tap, unique } from "remeda";
5
+ import { DefaultMap, ifind, invariant, nonNullable, toArray } from "@likec4/core/utils";
6
+ import { computeRelationshipsView, treeFromElements } from "@likec4/core/compute-view";
7
+ import dagre from "@dagrejs/dagre";
8
+ import { exact, preferSummary } from "@likec4/core/types";
9
+ //#region src/overlays/relationships-browser/layout.ts
10
+ /**
11
+ * All constants related to the layout
12
+ */
13
+ var Sizes = {
14
+ dagre: {
15
+ ranksep: 60,
16
+ nodesep: 35,
17
+ edgesep: 25
18
+ },
19
+ edgeLabel: {
20
+ width: 140,
21
+ height: 10,
22
+ minlen: 1,
23
+ weight: 1
24
+ },
25
+ emptyNodeOffset: 120,
26
+ nodeWidth: 330,
27
+ nodeHeight: 180,
28
+ spacerHeight: 0,
29
+ compound: {
30
+ labelHeight: 2,
31
+ paddingTop: 50,
32
+ paddingBottom: 32
33
+ }
29
34
  };
30
35
  function createGraph() {
31
- const g = new dagre.graphlib.Graph({
32
- directed: true,
33
- compound: true,
34
- multigraph: true
35
- });
36
- g.setGraph({
37
- ...Sizes.dagre,
38
- rankdir: "LR"
39
- });
40
- g.setDefaultEdgeLabel(() => ({ ...Sizes.edgeLabel }));
41
- g.setDefaultNodeLabel(() => ({}));
42
- return g;
36
+ const g = new dagre.graphlib.Graph({
37
+ directed: true,
38
+ compound: true,
39
+ multigraph: true
40
+ });
41
+ g.setGraph({
42
+ ...Sizes.dagre,
43
+ rankdir: "LR"
44
+ });
45
+ g.setDefaultEdgeLabel(() => ({ ...Sizes.edgeLabel }));
46
+ g.setDefaultNodeLabel(() => ({}));
47
+ return g;
43
48
  }
44
- const PortSuffix = "-port";
49
+ var PortSuffix = "-port";
45
50
  function createNodes(column, elements, g) {
46
- const graphNodes = new DefaultMap((key) => ({
47
- id: `${column}-${key}`,
48
- portId: `${column}-${key}`
49
- }));
50
- const tree = treeFromElements(elements);
51
- for (const element of tree.sorted) {
52
- const isCompound = tree.children(element).length > 0;
53
- const fqn = element.id;
54
- const id = `${column}-${fqn}`;
55
- const portId = isCompound ? `${id}${PortSuffix}` : id;
56
- graphNodes.set(fqn, {
57
- id,
58
- portId
59
- });
60
- g.setNode(id, {
61
- column,
62
- element,
63
- isCompound,
64
- portId,
65
- inPorts: [],
66
- outPorts: [],
67
- width: Sizes.nodeWidth,
68
- height: Sizes.nodeHeight
69
- });
70
- if (isCompound) {
71
- g.setNode(portId, {
72
- element,
73
- portId,
74
- isCompound,
75
- inPorts: [],
76
- outPorts: [],
77
- width: Sizes.nodeWidth - Sizes.dagre.ranksep,
78
- height: Sizes.compound.labelHeight
79
- });
80
- g.setParent(portId, id);
81
- }
82
- const parent = tree.parent(element);
83
- if (parent) {
84
- g.setParent(id, `${column}-${parent.id}`);
85
- }
86
- }
87
- return {
88
- ...tree,
89
- byId: (id) => {
90
- const element = tree.byId(id);
91
- const graph = graphNodes.get(element.id);
92
- return {
93
- element,
94
- graph
95
- };
96
- },
97
- graphNodes
98
- };
51
+ const graphNodes = new DefaultMap((key) => ({
52
+ id: `${column}-${key}`,
53
+ portId: `${column}-${key}`
54
+ }));
55
+ const tree = treeFromElements(elements);
56
+ for (const element of tree.sorted) {
57
+ const isCompound = tree.children(element).length > 0;
58
+ const fqn = element.id;
59
+ const id = `${column}-${fqn}`;
60
+ const portId = isCompound ? `${id}${PortSuffix}` : id;
61
+ graphNodes.set(fqn, {
62
+ id,
63
+ portId
64
+ });
65
+ g.setNode(id, {
66
+ column,
67
+ element,
68
+ isCompound,
69
+ portId,
70
+ inPorts: [],
71
+ outPorts: [],
72
+ width: Sizes.nodeWidth,
73
+ height: Sizes.nodeHeight
74
+ });
75
+ if (isCompound) {
76
+ g.setNode(portId, {
77
+ element,
78
+ portId,
79
+ isCompound,
80
+ inPorts: [],
81
+ outPorts: [],
82
+ width: Sizes.nodeWidth - Sizes.dagre.ranksep,
83
+ height: Sizes.compound.labelHeight
84
+ });
85
+ g.setParent(portId, id);
86
+ }
87
+ const parent = tree.parent(element);
88
+ if (parent) g.setParent(id, `${column}-${parent.id}`);
89
+ }
90
+ return {
91
+ ...tree,
92
+ byId: (id) => {
93
+ const element = tree.byId(id);
94
+ return {
95
+ element,
96
+ graph: graphNodes.get(element.id)
97
+ };
98
+ },
99
+ graphNodes
100
+ };
99
101
  }
102
+ /**
103
+ * Apply dagre layout to the graph
104
+ * And return a function to get node bounds for xyflow
105
+ */
100
106
  function applyDagreLayout(g) {
101
- dagre.layout(g, {
102
- // disableOptimalOrderHeuristic: true,
103
- });
104
- return (nodeId) => {
105
- const node = g.node(nodeId);
106
- const { x, y, width, height } = node;
107
- return {
108
- position: {
109
- x: x - Math.round(width / 2),
110
- y: y - Math.round(height / 2)
111
- },
112
- width,
113
- height
114
- };
115
- };
107
+ dagre.layout(g, {});
108
+ return (nodeId) => {
109
+ const { x, y, width, height } = g.node(nodeId);
110
+ return {
111
+ position: {
112
+ x: x - Math.round(width / 2),
113
+ y: y - Math.round(height / 2)
114
+ },
115
+ width,
116
+ height
117
+ };
118
+ };
116
119
  }
117
120
  var LayoutRelationshipsViewResult;
118
- ((LayoutRelationshipsViewResult2) => {
119
- LayoutRelationshipsViewResult2.Empty = "@empty";
121
+ (function(_LayoutRelationshipsViewResult) {
122
+ _LayoutRelationshipsViewResult.Empty = "@empty";
120
123
  })(LayoutRelationshipsViewResult || (LayoutRelationshipsViewResult = {}));
121
124
  function layoutRelationshipsView(data, scope) {
122
- const g = createGraph();
123
- const incomers = createNodes("incomers", data.incomers, g), subjects = createNodes("subjects", data.subjects, g), outgoers = createNodes("outgoers", data.outgoers, g);
124
- const edges = [];
125
- pipe(
126
- concat(
127
- pipe(
128
- toArray(data.incoming),
129
- map((r) => ({
130
- id: r.source.id,
131
- sourceFqn: r.source.id,
132
- targetFqn: r.target.id,
133
- source: incomers.byId(r.source.id).graph,
134
- target: subjects.byId(r.target.id).graph,
135
- relation: r
136
- }))
137
- ),
138
- pipe(
139
- toArray(data.outgoing),
140
- map((r) => ({
141
- id: r.target.id,
142
- sourceFqn: r.source.id,
143
- targetFqn: r.target.id,
144
- source: subjects.byId(r.source.id).graph,
145
- target: outgoers.byId(r.target.id).graph,
146
- relation: r
147
- }))
148
- )
149
- ),
150
- map((r) => ({
151
- ...r,
152
- expr: `${r.source.id}->${r.target.id}`
153
- })),
154
- // Group if same source and target
155
- groupBy(prop("expr")),
156
- forEachObj((grouped) => {
157
- const source = grouped[0].source;
158
- const target = grouped[0].target;
159
- const name = grouped[0].expr;
160
- g.node(source.id).outPorts.push(target.id);
161
- g.node(target.id).inPorts.push(source.id);
162
- g.setEdge(source.portId, target.portId, {
163
- ...Sizes.edgeLabel
164
- }, name);
165
- edges.push({
166
- name,
167
- sourceFqn: grouped[0].sourceFqn,
168
- targetFqn: grouped[0].targetFqn,
169
- source: source.id,
170
- sourceHandle: source.id + "_out" + (g.node(source.id).outPorts.length - 1),
171
- target: target.id,
172
- targetHandle: target.id + "_in" + (g.node(target.id).inPorts.length - 1),
173
- relations: map(grouped, prop("relation"))
174
- });
175
- })
176
- );
177
- for (const subjectNode of subjects.graphNodes.values()) {
178
- const nodeId = subjectNode.id;
179
- const node = g.node(nodeId);
180
- if (node.isCompound) {
181
- continue;
182
- }
183
- const edgeCount2 = Math.max(g.inEdges(nodeId)?.length ?? 0, g.outEdges(nodeId)?.length ?? 0);
184
- if (edgeCount2 > 2) {
185
- node.height = node.height + (edgeCount2 - 3) * 14;
186
- }
187
- }
188
- const nodeIds = [
189
- ...incomers.graphNodes.values(),
190
- ...subjects.graphNodes.values(),
191
- ...outgoers.graphNodes.values()
192
- ];
193
- if (incomers.graphNodes.size == 0) {
194
- const id = "incomers-empty";
195
- g.setNode(id, {
196
- column: "incomers",
197
- element: null,
198
- isCompound: false,
199
- portId: id,
200
- inPorts: [],
201
- outPorts: [],
202
- width: Sizes.nodeWidth,
203
- height: Sizes.nodeHeight
204
- });
205
- for (const subjectNode of subjects.graphNodes.values()) {
206
- g.setEdge(id, subjectNode.portId);
207
- }
208
- nodeIds.push({
209
- id,
210
- portId: id
211
- });
212
- }
213
- if (outgoers.graphNodes.size == 0) {
214
- const id = "outgoers-empty";
215
- g.setNode(id, {
216
- column: "outgoers",
217
- element: null,
218
- isCompound: false,
219
- portId: id,
220
- inPorts: [],
221
- outPorts: [],
222
- width: Sizes.nodeWidth,
223
- height: Sizes.nodeHeight
224
- });
225
- for (const subjectNode of subjects.graphNodes.values()) {
226
- g.setEdge(subjectNode.portId, id);
227
- }
228
- nodeIds.push({
229
- id,
230
- portId: id
231
- });
232
- }
233
- const edgeCount = g.edgeCount();
234
- if (edgeCount > 10) {
235
- for (const edge of g.edges()) {
236
- g.setEdge(edge, {
237
- ...Sizes.edgeLabel,
238
- width: edgeCount > 25 ? 800 : 400
239
- });
240
- }
241
- }
242
- const dagreBounds = applyDagreLayout(g);
243
- const _calculatedNodeBounds = pipe(
244
- nodeIds,
245
- // Compound nodes have different portId
246
- filter((n) => n.id === n.portId),
247
- mapToObj((n) => [n.id, dagreBounds(n.id)])
248
- );
249
- function nodeBounds(nodeId) {
250
- return _calculatedNodeBounds[nodeId] ??= pipe(
251
- g.children(nodeId) ?? [],
252
- filter((id) => !id.endsWith(PortSuffix)),
253
- map((id) => nodeBounds(id)),
254
- tap((bounds) => {
255
- invariant(bounds.length > 0, `Node ${nodeId} has no nested nodes`);
256
- }),
257
- reduce((acc, bounds) => {
258
- return {
259
- minY: Math.min(acc.minY, bounds.position.y),
260
- maxY: Math.max(acc.maxY, bounds.position.y + bounds.height)
261
- };
262
- }, { minY: Infinity, maxY: -Infinity }),
263
- ({ minY: minY2, maxY }) => {
264
- const {
265
- position: { x },
266
- width
267
- } = dagreBounds(nodeId);
268
- minY2 = minY2 - Sizes.compound.paddingTop;
269
- maxY = maxY + Sizes.compound.paddingBottom;
270
- return {
271
- position: {
272
- x,
273
- y: minY2
274
- },
275
- width,
276
- height: maxY - minY2
277
- };
278
- }
279
- );
280
- }
281
- function nodeLevel(nodeId) {
282
- const parent = g.parent(nodeId);
283
- if (parent) {
284
- return nodeLevel(parent) + 1;
285
- }
286
- return 0;
287
- }
288
- function nodeDepth(nodeId) {
289
- const children = g.children(nodeId) ?? [];
290
- if (children.length === 0) {
291
- return 0;
292
- }
293
- return 1 + Math.max(...children.map(nodeDepth));
294
- }
295
- const sortedPorts = (nodeId, type, ports) => {
296
- return pipe(
297
- ports,
298
- map((port, index) => {
299
- return {
300
- port: nodeId + "_" + type + index,
301
- topY: nodeBounds(port).position.y
302
- };
303
- }),
304
- sortBy(prop("topY")),
305
- map(prop("port"))
306
- );
307
- };
308
- let minX = 0;
309
- let minY = 0;
310
- const [subject] = [...subjects.root];
311
- invariant(subject, "Subjects should not be empty");
312
- let subjectBounds = nodeBounds(subjects.graphNodes.get(subject.id).id);
313
- const nodes = nodeIds.map(({ id }) => {
314
- const { element, inPorts, outPorts, column } = g.node(id);
315
- let { position, width, height } = nodeBounds(id);
316
- if (!element) {
317
- height = Math.min(subjectBounds.height, 300);
318
- position.y = subjectBounds.position.y + subjectBounds.height / 2 - height / 2;
319
- if (column === "incomers") {
320
- width = subjectBounds.position.x - Sizes.emptyNodeOffset - position.x;
321
- } else {
322
- const rightX = position.x + width;
323
- position.x = subjectBounds.position.x + subjectBounds.width + Sizes.emptyNodeOffset;
324
- width = rightX - position.x;
325
- }
326
- return {
327
- id,
328
- parent: null,
329
- x: position.x,
330
- y: position.y,
331
- title: "empty node",
332
- description: null,
333
- technology: null,
334
- tags: [],
335
- links: [],
336
- color: "muted",
337
- shape: "rectangle",
338
- style: {
339
- border: "dashed",
340
- opacity: 50
341
- },
342
- kind: LayoutRelationshipsViewResult.Empty,
343
- level: 0,
344
- labelBBox: {
345
- x: position.x,
346
- y: position.y,
347
- width,
348
- height
349
- },
350
- children: [],
351
- width,
352
- height,
353
- column,
354
- ports: {
355
- in: [],
356
- out: []
357
- },
358
- existsInCurrentView: false
359
- };
360
- }
361
- const parentId = g.parent(id);
362
- const children = (g.children(id) ?? []).filter((c) => !c.endsWith(PortSuffix));
363
- minX = Math.min(minX, position.x);
364
- minY = Math.min(minY, position.y);
365
- const navigateTo = scope ? ifind(element.scopedViews(), (v) => v.id !== scope.id)?.id ?? null : null;
366
- const inheritFromNode = scope?.findNodeWithElement(element.id);
367
- const scopedAncestor = scope && !inheritFromNode ? ifind(element.ancestors(), (a) => !!scope.findNodeWithElement(a.id))?.id : null;
368
- const inheritFromNodeOrAncestor = inheritFromNode ?? (scopedAncestor && scope?.findNodeWithElement(scopedAncestor));
369
- return {
370
- id,
371
- parent: parentId ?? null,
372
- x: position.x,
373
- y: position.y,
374
- title: element.title,
375
- description: preferSummary(element.$element) ?? null,
376
- technology: element.technology,
377
- tags: [...element.tags],
378
- links: null,
379
- color: inheritFromNodeOrAncestor?.color ?? element.color,
380
- shape: inheritFromNode?.shape ?? element.shape,
381
- icon: inheritFromNode?.icon ?? element.icon ?? "none",
382
- modelRef: element.id,
383
- kind: element.kind,
384
- level: nodeLevel(id),
385
- labelBBox: {
386
- x: position.x,
387
- y: position.y,
388
- width,
389
- height
390
- },
391
- style: omit({
392
- ...(inheritFromNode ?? inheritFromNodeOrAncestor)?.style,
393
- ...element.$element.style
394
- }, ["color", "shape", "icon"]),
395
- navigateTo,
396
- ...children.length > 0 && { depth: nodeDepth(id) },
397
- children,
398
- width,
399
- height,
400
- column,
401
- ports: {
402
- in: sortedPorts(id, "in", inPorts),
403
- out: sortedPorts(id, "out", outPorts)
404
- },
405
- existsInCurrentView: !!inheritFromNode
406
- };
407
- });
408
- return {
409
- subjectExistsInScope: !scope || scope.includesElement(subject.id),
410
- bounds: {
411
- x: Math.min(minX, 0),
412
- y: Math.min(minY, 0),
413
- width: g.graph().width ?? 100,
414
- height: g.graph().height ?? 100
415
- },
416
- nodes,
417
- edges: g.edges().reduce((acc, e) => {
418
- const edge = g.edge(e);
419
- const ename = e.name;
420
- if (!ename) {
421
- return acc;
422
- }
423
- const {
424
- name,
425
- source,
426
- sourceFqn,
427
- target,
428
- targetFqn,
429
- relations,
430
- sourceHandle,
431
- targetHandle
432
- } = nonNullable(find(edges, (e2) => e2.name === ename));
433
- const onlyRelation = only(relations);
434
- const label = onlyRelation?.title ?? "untitled";
435
- const isMultiple = relations.length > 1;
436
- const navigateTo = only(unique(relations.flatMap((r) => r.navigateTo?.id ? r.navigateTo.id : [])));
437
- acc.push(exact({
438
- id: name,
439
- sourceFqn,
440
- source,
441
- sourceHandle,
442
- targetFqn,
443
- target,
444
- targetHandle,
445
- label: isMultiple ? `${relations.length} relationships` : label,
446
- navigateTo,
447
- color: onlyRelation?.color ?? "gray",
448
- existsInCurrentView: !scope || relations.every((r) => scope.includesRelation(r.id)),
449
- points: edge.points.map((p) => [p.x, p.y]),
450
- line: onlyRelation?.line ?? "dashed",
451
- head: onlyRelation?.head,
452
- tail: onlyRelation?.tail,
453
- relations: relations.map((r) => r.id),
454
- parent: null
455
- }));
456
- return acc;
457
- }, [])
458
- };
125
+ const g = createGraph();
126
+ const incomers = createNodes("incomers", data.incomers, g);
127
+ const subjects = createNodes("subjects", data.subjects, g);
128
+ const outgoers = createNodes("outgoers", data.outgoers, g);
129
+ const edges = [];
130
+ pipe(concat(pipe(toArray(data.incoming), map((r) => ({
131
+ id: r.source.id,
132
+ sourceFqn: r.source.id,
133
+ targetFqn: r.target.id,
134
+ source: incomers.byId(r.source.id).graph,
135
+ target: subjects.byId(r.target.id).graph,
136
+ relation: r
137
+ }))), pipe(toArray(data.outgoing), map((r) => ({
138
+ id: r.target.id,
139
+ sourceFqn: r.source.id,
140
+ targetFqn: r.target.id,
141
+ source: subjects.byId(r.source.id).graph,
142
+ target: outgoers.byId(r.target.id).graph,
143
+ relation: r
144
+ })))), map((r) => ({
145
+ ...r,
146
+ expr: `${r.source.id}->${r.target.id}`
147
+ })), groupBy(prop("expr")), forEachObj((grouped) => {
148
+ const source = grouped[0].source;
149
+ const target = grouped[0].target;
150
+ const name = grouped[0].expr;
151
+ g.node(source.id).outPorts.push(target.id);
152
+ g.node(target.id).inPorts.push(source.id);
153
+ g.setEdge(source.portId, target.portId, { ...Sizes.edgeLabel }, name);
154
+ edges.push({
155
+ name,
156
+ sourceFqn: grouped[0].sourceFqn,
157
+ targetFqn: grouped[0].targetFqn,
158
+ source: source.id,
159
+ sourceHandle: source.id + "_out" + (g.node(source.id).outPorts.length - 1),
160
+ target: target.id,
161
+ targetHandle: target.id + "_in" + (g.node(target.id).inPorts.length - 1),
162
+ relations: map(grouped, prop("relation"))
163
+ });
164
+ }));
165
+ for (const subjectNode of subjects.graphNodes.values()) {
166
+ const nodeId = subjectNode.id;
167
+ const node = g.node(nodeId);
168
+ if (node.isCompound) continue;
169
+ const edgeCount = Math.max(g.inEdges(nodeId)?.length ?? 0, g.outEdges(nodeId)?.length ?? 0);
170
+ if (edgeCount > 2) node.height = node.height + (edgeCount - 3) * 14;
171
+ }
172
+ const nodeIds = [
173
+ ...incomers.graphNodes.values(),
174
+ ...subjects.graphNodes.values(),
175
+ ...outgoers.graphNodes.values()
176
+ ];
177
+ if (incomers.graphNodes.size == 0) {
178
+ const id = "incomers-empty";
179
+ g.setNode(id, {
180
+ column: "incomers",
181
+ element: null,
182
+ isCompound: false,
183
+ portId: id,
184
+ inPorts: [],
185
+ outPorts: [],
186
+ width: Sizes.nodeWidth,
187
+ height: Sizes.nodeHeight
188
+ });
189
+ for (const subjectNode of subjects.graphNodes.values()) g.setEdge(id, subjectNode.portId);
190
+ nodeIds.push({
191
+ id,
192
+ portId: id
193
+ });
194
+ }
195
+ if (outgoers.graphNodes.size == 0) {
196
+ const id = "outgoers-empty";
197
+ g.setNode(id, {
198
+ column: "outgoers",
199
+ element: null,
200
+ isCompound: false,
201
+ portId: id,
202
+ inPorts: [],
203
+ outPorts: [],
204
+ width: Sizes.nodeWidth,
205
+ height: Sizes.nodeHeight
206
+ });
207
+ for (const subjectNode of subjects.graphNodes.values()) g.setEdge(subjectNode.portId, id);
208
+ nodeIds.push({
209
+ id,
210
+ portId: id
211
+ });
212
+ }
213
+ const edgeCount = g.edgeCount();
214
+ if (edgeCount > 10) for (const edge of g.edges()) g.setEdge(edge, {
215
+ ...Sizes.edgeLabel,
216
+ width: edgeCount > 25 ? 800 : 400
217
+ });
218
+ const dagreBounds = applyDagreLayout(g);
219
+ const _calculatedNodeBounds = pipe(nodeIds, filter((n) => n.id === n.portId), mapToObj((n) => [n.id, dagreBounds(n.id)]));
220
+ function nodeBounds(nodeId) {
221
+ return _calculatedNodeBounds[nodeId] ??= pipe(g.children(nodeId) ?? [], filter((id) => !id.endsWith(PortSuffix)), map((id) => nodeBounds(id)), tap((bounds) => {
222
+ invariant(bounds.length > 0, `Node ${nodeId} has no nested nodes`);
223
+ }), reduce((acc, bounds) => {
224
+ return {
225
+ minY: Math.min(acc.minY, bounds.position.y),
226
+ maxY: Math.max(acc.maxY, bounds.position.y + bounds.height)
227
+ };
228
+ }, {
229
+ minY: Infinity,
230
+ maxY: -Infinity
231
+ }), ({ minY, maxY }) => {
232
+ const { position: { x }, width } = dagreBounds(nodeId);
233
+ minY = minY - Sizes.compound.paddingTop;
234
+ maxY = maxY + Sizes.compound.paddingBottom;
235
+ return {
236
+ position: {
237
+ x,
238
+ y: minY
239
+ },
240
+ width,
241
+ height: maxY - minY
242
+ };
243
+ });
244
+ }
245
+ function nodeLevel(nodeId) {
246
+ const parent = g.parent(nodeId);
247
+ if (parent) return nodeLevel(parent) + 1;
248
+ return 0;
249
+ }
250
+ function nodeDepth(nodeId) {
251
+ const children = g.children(nodeId) ?? [];
252
+ if (children.length === 0) return 0;
253
+ return 1 + Math.max(...children.map(nodeDepth));
254
+ }
255
+ const sortedPorts = (nodeId, type, ports) => {
256
+ return pipe(ports, map((port, index) => {
257
+ return {
258
+ port: nodeId + "_" + type + index,
259
+ topY: nodeBounds(port).position.y
260
+ };
261
+ }), sortBy(prop("topY")), map(prop("port")));
262
+ };
263
+ let minX = 0;
264
+ let minY = 0;
265
+ const [subject] = [...subjects.root];
266
+ invariant(subject, "Subjects should not be empty");
267
+ let subjectBounds = nodeBounds(subjects.graphNodes.get(subject.id).id);
268
+ const nodes = nodeIds.map(({ id }) => {
269
+ const { element, inPorts, outPorts, column } = g.node(id);
270
+ let { position, width, height } = nodeBounds(id);
271
+ if (!element) {
272
+ height = Math.min(subjectBounds.height, 300);
273
+ position.y = subjectBounds.position.y + subjectBounds.height / 2 - height / 2;
274
+ if (column === "incomers") width = subjectBounds.position.x - Sizes.emptyNodeOffset - position.x;
275
+ else {
276
+ const rightX = position.x + width;
277
+ position.x = subjectBounds.position.x + subjectBounds.width + Sizes.emptyNodeOffset;
278
+ width = rightX - position.x;
279
+ }
280
+ return {
281
+ id,
282
+ parent: null,
283
+ x: position.x,
284
+ y: position.y,
285
+ title: "empty node",
286
+ description: null,
287
+ technology: null,
288
+ tags: [],
289
+ links: [],
290
+ color: "muted",
291
+ shape: "rectangle",
292
+ style: {
293
+ border: "dashed",
294
+ opacity: 50
295
+ },
296
+ kind: LayoutRelationshipsViewResult.Empty,
297
+ level: 0,
298
+ labelBBox: {
299
+ x: position.x,
300
+ y: position.y,
301
+ width,
302
+ height
303
+ },
304
+ children: [],
305
+ width,
306
+ height,
307
+ column,
308
+ ports: {
309
+ in: [],
310
+ out: []
311
+ },
312
+ existsInCurrentView: false
313
+ };
314
+ }
315
+ const parentId = g.parent(id);
316
+ const children = (g.children(id) ?? []).filter((c) => !c.endsWith(PortSuffix));
317
+ minX = Math.min(minX, position.x);
318
+ minY = Math.min(minY, position.y);
319
+ const navigateTo = scope ? ifind(element.scopedViews(), (v) => v.id !== scope.id)?.id ?? null : null;
320
+ const inheritFromNode = scope?.findNodeWithElement(element.id);
321
+ const scopedAncestor = scope && !inheritFromNode ? ifind(element.ancestors(), (a) => !!scope.findNodeWithElement(a.id))?.id : null;
322
+ const inheritFromNodeOrAncestor = inheritFromNode ?? (scopedAncestor && scope?.findNodeWithElement(scopedAncestor));
323
+ return {
324
+ id,
325
+ parent: parentId ?? null,
326
+ x: position.x,
327
+ y: position.y,
328
+ title: element.title,
329
+ description: preferSummary(element.$element) ?? null,
330
+ technology: element.technology,
331
+ tags: [...element.tags],
332
+ links: null,
333
+ color: inheritFromNodeOrAncestor?.color ?? element.color,
334
+ shape: inheritFromNode?.shape ?? element.shape,
335
+ icon: inheritFromNode?.icon ?? element.icon ?? "none",
336
+ modelRef: element.id,
337
+ kind: element.kind,
338
+ level: nodeLevel(id),
339
+ labelBBox: {
340
+ x: position.x,
341
+ y: position.y,
342
+ width,
343
+ height
344
+ },
345
+ style: omit({
346
+ ...(inheritFromNode ?? inheritFromNodeOrAncestor)?.style,
347
+ ...element.$element.style
348
+ }, [
349
+ "color",
350
+ "shape",
351
+ "icon"
352
+ ]),
353
+ navigateTo,
354
+ ...children.length > 0 && { depth: nodeDepth(id) },
355
+ children,
356
+ width,
357
+ height,
358
+ column,
359
+ ports: {
360
+ in: sortedPorts(id, "in", inPorts),
361
+ out: sortedPorts(id, "out", outPorts)
362
+ },
363
+ existsInCurrentView: !!inheritFromNode
364
+ };
365
+ });
366
+ return {
367
+ subjectExistsInScope: !scope || scope.includesElement(subject.id),
368
+ bounds: {
369
+ x: Math.min(minX, 0),
370
+ y: Math.min(minY, 0),
371
+ width: g.graph().width ?? 100,
372
+ height: g.graph().height ?? 100
373
+ },
374
+ nodes,
375
+ edges: g.edges().reduce((acc, e) => {
376
+ const edge = g.edge(e);
377
+ const ename = e.name;
378
+ if (!ename) return acc;
379
+ const { name, source, sourceFqn, target, targetFqn, relations, sourceHandle, targetHandle } = nonNullable(find(edges, (e) => e.name === ename));
380
+ const onlyRelation = only(relations);
381
+ const label = onlyRelation?.title ?? "untitled";
382
+ const isMultiple = relations.length > 1;
383
+ const navigateTo = only(unique(relations.flatMap((r) => r.navigateTo?.id ? r.navigateTo.id : [])));
384
+ acc.push(exact({
385
+ id: name,
386
+ sourceFqn,
387
+ source,
388
+ sourceHandle,
389
+ targetFqn,
390
+ target,
391
+ targetHandle,
392
+ label: isMultiple ? `${relations.length} relationships` : label,
393
+ navigateTo,
394
+ color: onlyRelation?.color ?? "gray",
395
+ existsInCurrentView: !scope || relations.every((r) => scope.includesRelation(r.id)),
396
+ points: edge.points.map((p) => [p.x, p.y]),
397
+ line: onlyRelation?.line ?? "dashed",
398
+ head: onlyRelation?.head,
399
+ tail: onlyRelation?.tail,
400
+ relations: relations.map((r) => r.id),
401
+ parent: null
402
+ }));
403
+ return acc;
404
+ }, [])
405
+ };
459
406
  }
460
407
  function useRelationshipsView(subject, viewId, scope) {
461
- const model = useLikeC4Model();
462
- return useMemo(() => {
463
- const view = viewId ? model.findView(viewId) : null;
464
- const data = layoutRelationshipsView(
465
- computeRelationshipsView(subject, model, viewId, scope),
466
- scope === "view" ? view : null
467
- );
468
- if (view && (scope === "global" || !data.subjectExistsInScope)) {
469
- data.edges = data.edges.map((edge) => {
470
- edge.existsInCurrentView = edge.relations.every((r) => view.includesRelation(r));
471
- return edge;
472
- });
473
- }
474
- return Object.assign(data, { subject });
475
- }, [model, subject, viewId, scope, computeRelationshipsView]);
408
+ const model = useLikeC4Model();
409
+ return useMemo(() => {
410
+ const view = viewId ? model.findView(viewId) : null;
411
+ const data = layoutRelationshipsView(computeRelationshipsView(subject, model, viewId, scope), scope === "view" ? view : null);
412
+ if (view && (scope === "global" || !data.subjectExistsInScope)) data.edges = data.edges.map((edge) => {
413
+ edge.existsInCurrentView = edge.relations.every((r) => view.includesRelation(r));
414
+ return edge;
415
+ });
416
+ return Object.assign(data, { subject });
417
+ }, [
418
+ model,
419
+ subject,
420
+ viewId,
421
+ scope,
422
+ computeRelationshipsView
423
+ ]);
476
424
  }
477
-
478
- export { LayoutRelationshipsViewResult, layoutRelationshipsView, useRelationshipsView };
425
+ //#endregion
426
+ export { LayoutRelationshipsViewResult, useRelationshipsView };