@likec4/diagram 1.44.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 (134) hide show
  1. package/bundle/index.js +18160 -17671
  2. package/dist/LikeC4Diagram.js +7 -5
  3. package/dist/LikeC4Diagram.props.d.ts +9 -8
  4. package/dist/LikeC4Styles.js +0 -3
  5. package/dist/LikeC4View.d.ts +3 -3
  6. package/dist/LikeC4View.js +7 -3
  7. package/dist/ReactLikeC4.d.ts +2 -2
  8. package/dist/base/Base.d.ts +1 -1
  9. package/dist/base/updateEdges.js +25 -15
  10. package/dist/base/updateNodes.d.ts +14 -0
  11. package/dist/base/updateNodes.js +51 -18
  12. package/dist/base-primitives/Markdown.d.ts +30 -4
  13. package/dist/base-primitives/Markdown.js +3 -2
  14. package/dist/base-primitives/compound/CompoundActionButton.d.ts +3 -2
  15. package/dist/base-primitives/compound/CompoundDetailsButton.d.ts +3 -2
  16. package/dist/base-primitives/edge/EdgeActionButton.d.ts +3 -2
  17. package/dist/base-primitives/edge/EdgeContainer.d.ts +1 -1
  18. package/dist/base-primitives/edge/EdgeContainer.js +4 -1
  19. package/dist/base-primitives/edge/EdgeLabel.d.ts +2 -2
  20. package/dist/base-primitives/edge/EdgePath.js +24 -4
  21. package/dist/base-primitives/element/ElementActionButtons.d.ts +3 -2
  22. package/dist/base-primitives/element/ElementActionButtons.js +2 -2
  23. package/dist/base-primitives/element/ElementData.d.ts +3 -3
  24. package/dist/base-primitives/element/ElementData.js +13 -7
  25. package/dist/base-primitives/element/ElementDetailsButton.d.ts +3 -2
  26. package/dist/base-primitives/element/ElementDetailsButton.js +3 -0
  27. package/dist/base-primitives/element/ElementShape.js +5 -5
  28. package/dist/base-primitives/element/ElementTags.d.ts +6 -4
  29. package/dist/context/DiagramFeatures.d.ts +1 -0
  30. package/dist/context/TagStylesContext.js +1 -1
  31. package/dist/custom/hooks.d.ts +2 -2
  32. package/dist/custom/index.js +1 -1
  33. package/dist/hooks/index.d.ts +2 -1
  34. package/dist/hooks/useDiagramCompareLayout.js +7 -2
  35. package/dist/hooks/useLikeC4Project.d.ts +6 -1
  36. package/dist/hooks/useLikeC4Project.js +14 -2
  37. package/dist/hooks/useMediaPrint.d.ts +6 -0
  38. package/dist/likec4diagram/DiagramXYFlow.js +11 -6
  39. package/dist/likec4diagram/custom/edges/EdgeDrifts.d.ts +6 -0
  40. package/dist/likec4diagram/custom/edges/EdgeDrifts.js +38 -0
  41. package/dist/likec4diagram/custom/edges/RelationshipEdge.js +24 -14
  42. package/dist/likec4diagram/custom/edges/SequenceStepEdge.js +3 -1
  43. package/dist/likec4diagram/custom/edges/useControlPoints.js +3 -3
  44. package/dist/likec4diagram/custom/edges/useRelationshipEdgePath.js +5 -5
  45. package/dist/likec4diagram/custom/nodes/NodeDrifts.d.ts +6 -0
  46. package/dist/likec4diagram/custom/nodes/{ElementNodeDrifts.js → NodeDrifts.js} +8 -4
  47. package/dist/likec4diagram/custom/nodes/SequenceActorNode.js +4 -2
  48. package/dist/likec4diagram/custom/nodes/index.d.ts +1 -0
  49. package/dist/likec4diagram/custom/nodes/nodes.js +64 -23
  50. package/dist/likec4diagram/relationship-popover/RelationshipPopover.js +3 -3
  51. package/dist/likec4diagram/relationship-popover/actor.d.ts +1 -1
  52. package/dist/likec4diagram/state/DiagramActorProvider.d.ts +2 -2
  53. package/dist/likec4diagram/state/DiagramActorProvider.js +0 -1
  54. package/dist/likec4diagram/state/assign.d.ts +10 -6
  55. package/dist/likec4diagram/state/assign.js +17 -192
  56. package/dist/likec4diagram/state/createViewChange.js +15 -26
  57. package/dist/likec4diagram/state/diagram-api.d.ts +2 -6
  58. package/dist/likec4diagram/state/diagram-api.js +2 -10
  59. package/dist/likec4diagram/state/hotkeyActor.d.ts +0 -7
  60. package/dist/likec4diagram/state/hotkeyActor.js +1 -17
  61. package/dist/likec4diagram/state/machine.actions.d.ts +430 -746
  62. package/dist/likec4diagram/state/machine.actions.js +193 -284
  63. package/dist/likec4diagram/state/machine.actions.layout.d.ts +579 -0
  64. package/dist/likec4diagram/state/machine.actions.layout.js +129 -0
  65. package/dist/likec4diagram/state/machine.d.ts +17 -3712
  66. package/dist/likec4diagram/state/machine.js +59 -73
  67. package/dist/likec4diagram/state/machine.setup.d.ts +61 -18
  68. package/dist/likec4diagram/state/machine.setup.js +27 -5
  69. package/dist/likec4diagram/state/machine.state.initializing.d.ts +25 -0
  70. package/dist/likec4diagram/state/machine.state.initializing.js +5 -5
  71. package/dist/likec4diagram/state/machine.state.navigating.d.ts +5 -108
  72. package/dist/likec4diagram/state/machine.state.navigating.js +167 -34
  73. package/dist/likec4diagram/state/machine.state.ready.d.ts +2316 -2851
  74. package/dist/likec4diagram/state/machine.state.ready.focused.d.ts +386 -0
  75. package/dist/likec4diagram/state/machine.state.ready.focused.js +85 -0
  76. package/dist/likec4diagram/state/machine.state.ready.idle.d.ts +474 -0
  77. package/dist/likec4diagram/state/machine.state.ready.idle.js +96 -0
  78. package/dist/likec4diagram/state/machine.state.ready.js +144 -319
  79. package/dist/likec4diagram/state/machine.state.ready.printing.d.ts +128 -0
  80. package/dist/likec4diagram/state/machine.state.ready.printing.js +40 -0
  81. package/dist/likec4diagram/state/machine.state.ready.walkthrough.d.ts +511 -0
  82. package/dist/likec4diagram/state/machine.state.ready.walkthrough.js +177 -0
  83. package/dist/likec4diagram/state/mediaPrintActor.d.ts +12 -0
  84. package/dist/likec4diagram/state/mediaPrintActor.js +18 -0
  85. package/dist/likec4diagram/state/syncManualLayoutActor.d.ts +6 -240
  86. package/dist/likec4diagram/state/syncManualLayoutActor.js +150 -89
  87. package/dist/likec4diagram/state/types.d.ts +5 -7
  88. package/dist/likec4diagram/state/utils.d.ts +15 -2
  89. package/dist/likec4diagram/state/utils.js +43 -3
  90. package/dist/likec4diagram/types.d.ts +8 -13
  91. package/dist/likec4diagram/ui/notation/NotationPanel.css.js +5 -2
  92. package/dist/likec4diagram/useLayoutConstraints.js +107 -102
  93. package/dist/likec4diagram/xyflow-diagram/diagram-view.js +12 -15
  94. package/dist/likec4diagram/xyflow-sequence/sequence-layout.js +11 -8
  95. package/dist/navigationpanel/NavigationPanel.js +5 -1
  96. package/dist/navigationpanel/actor.d.ts +4 -204
  97. package/dist/navigationpanel/actor.js +1 -1
  98. package/dist/navigationpanel/controls/ToggleReadonly.js +8 -3
  99. package/dist/navigationpanel/walkthrough/DynamicViewControls.d.ts +66 -66
  100. package/dist/navigationpanel/walkthrough/WalkthroughPanel.js +4 -3
  101. package/dist/overlays/element-details/ElementDetailsCard.css.js +3 -3
  102. package/dist/overlays/element-details/MetadataValue.d.ts +2 -1
  103. package/dist/overlays/element-details/actor.d.ts +8 -83
  104. package/dist/overlays/element-details/actor.js +0 -8
  105. package/dist/overlays/overlay/Overlay.js +10 -10
  106. package/dist/overlays/overlaysActor.d.ts +7 -392
  107. package/dist/overlays/overlaysActor.js +67 -46
  108. package/dist/overlays/relationship-details/_types.d.ts +3 -4
  109. package/dist/overlays/relationship-details/actor.d.ts +6 -562
  110. package/dist/overlays/relationship-details/actor.js +1 -0
  111. package/dist/overlays/relationship-details/layout-to-xyflow.js +3 -5
  112. package/dist/overlays/relationship-details/layout.d.ts +3 -3
  113. package/dist/overlays/relationship-details/layout.js +4 -4
  114. package/dist/overlays/relationships-browser/_types.d.ts +2 -3
  115. package/dist/overlays/relationships-browser/actor.d.ts +7 -739
  116. package/dist/overlays/relationships-browser/layout.d.ts +2 -2
  117. package/dist/overlays/relationships-browser/layout.js +3 -3
  118. package/dist/overlays/relationships-browser/useViewToNodesEdges.js +0 -3
  119. package/dist/overlays/types.d.ts +12 -13
  120. package/dist/search/components/_shared.css.d.ts +1 -1
  121. package/dist/search/searchActor.d.ts +3 -66
  122. package/dist/shadowroot/ShadowRoot.d.ts +5 -7
  123. package/dist/shadowroot/ShadowRoot.js +7 -5
  124. package/dist/styles.css2.js +1 -1
  125. package/dist/utils/vector.d.ts +5 -0
  126. package/dist/utils/vector.js +7 -0
  127. package/dist/utils/view-bounds.js +7 -6
  128. package/dist/utils/xyflow.d.ts +4 -2
  129. package/dist/utils/xyflow.js +18 -50
  130. package/package.json +19 -18
  131. package/panda.buildinfo.json +17 -5
  132. package/styles-min.css +1 -1
  133. package/styles.css +1 -1
  134. package/dist/likec4diagram/custom/nodes/ElementNodeDrifts.d.ts +0 -4
@@ -143,7 +143,7 @@ const RelationshipPopover = memo(() => {
143
143
  ) });
144
144
  });
145
145
  const getEdgeLabelElement = (edgeId, container) => {
146
- return container?.querySelector(`.likec4-edge-label[data-edge-id="${edgeId}"]`) ?? null;
146
+ return container?.querySelector(`.likec4-edge-label[data-edge-id="${edgeId}"]`) ?? container?.querySelector(`.react-flow__edge[data-id="${edgeId}"] .edge-center-point`) ?? null;
147
147
  };
148
148
  const POPOVER_PADDING = 8;
149
149
  const RelationshipPopoverInternal = ({
@@ -397,7 +397,7 @@ const Relationship = forwardRef(({
397
397
  /* @__PURE__ */ jsx(Label, { children: "technology" }),
398
398
  /* @__PURE__ */ jsx(Text, { size: "xs", className: css({ userSelect: "all" }), children: r.technology })
399
399
  ] }),
400
- r.description.nonEmpty && /* @__PURE__ */ jsxs(Fragment$1, { children: [
400
+ r.summary.nonEmpty && /* @__PURE__ */ jsxs(Fragment$1, { children: [
401
401
  /* @__PURE__ */ jsx(Label, { children: "description" }),
402
402
  /* @__PURE__ */ jsx(
403
403
  Box,
@@ -411,7 +411,7 @@ const Relationship = forwardRef(({
411
411
  _dark: "mantine.colors.dark[4]"
412
412
  }
413
413
  },
414
- children: /* @__PURE__ */ jsx(Markdown, { value: r.description, fontSize: "sm" })
414
+ children: /* @__PURE__ */ jsx(Markdown, { value: r.summary, fontSize: "sm" })
415
415
  }
416
416
  )
417
417
  ] }),
@@ -57,7 +57,7 @@ declare const _actorLogic: StateMachine<RelationshipPopoverActorContext, Relatio
57
57
  params: unknown;
58
58
  };
59
59
  }>, "open timeout" | "close timeout" | "long idle", "idle" | "opening" | {
60
- active: "opened" | "hovered" | "closing";
60
+ active: "hovered" | "opened" | "closing";
61
61
  }, "opened", NonReducibleUnknown, NonReducibleUnknown, EventObject, MetaObject, {
62
62
  readonly id: "breadcrumbs";
63
63
  readonly context: () => {
@@ -1,13 +1,13 @@
1
1
  import { DiagramView, DynamicViewDisplayVariant, WhereOperator } from '@likec4/core/types';
2
2
  import { PropsWithChildren } from 'react';
3
- import { ViewPadding } from '../../LikeC4Diagram.props';
3
+ import { ViewPaddings } from '../../LikeC4Diagram.props';
4
4
  export declare function DiagramActorProvider({ view, zoomable, pannable, nodesDraggable, nodesSelectable, fitViewPadding, where, children, dynamicViewVariant: _defaultVariant, }: PropsWithChildren<{
5
5
  view: DiagramView;
6
6
  zoomable: boolean;
7
7
  pannable: boolean;
8
8
  nodesDraggable: boolean;
9
9
  nodesSelectable: boolean;
10
- fitViewPadding: ViewPadding;
10
+ fitViewPadding: ViewPaddings;
11
11
  where: WhereOperator | null;
12
12
  dynamicViewVariant: DynamicViewDisplayVariant | undefined;
13
13
  }>): import("react/jsx-runtime").JSX.Element;
@@ -74,7 +74,6 @@ function DiagramActorProvider({
74
74
  if (!_defaultVariant) return;
75
75
  actorRef.send({ type: "switch.dynamicViewVariant", variant: _defaultVariant });
76
76
  }, [_defaultVariant, actorRef]);
77
- console.debug("Render DiagramActorProvider for view", view.id);
78
77
  return /* @__PURE__ */ jsxs(DiagramActorContextProvider, { value: api, children: [
79
78
  /* @__PURE__ */ jsxs(ErrorBoundary, { children: [
80
79
  /* @__PURE__ */ jsx(
@@ -1,4 +1,4 @@
1
- import { XYPoint } from '@likec4/core';
1
+ import { LayoutedView, XYPoint } from '@likec4/core';
2
2
  import { NodeLookup } from '@xyflow/system';
3
3
  import { Types } from '../types';
4
4
  import { ActionArg, Context as DiagramContext } from './machine.setup';
@@ -8,12 +8,16 @@ export declare function lastClickedNode(params: {
8
8
  node: Types.Node;
9
9
  };
10
10
  }): DiagramContext['lastClickedNode'];
11
- export declare function mergeXYNodesEdges({ context, event }: ActionArg): Partial<DiagramContext>;
11
+ export declare function mergeXYNodesEdges(context: Pick<DiagramContext, 'xynodes' | 'xyedges' | 'view'>, event: {
12
+ view: LayoutedView;
13
+ xynodes: Types.Node[];
14
+ xyedges: Types.Edge[];
15
+ }): {
16
+ xynodes: Types.Node[];
17
+ xyedges: Types.Edge[];
18
+ view: LayoutedView;
19
+ };
12
20
  export declare function focusNodesEdges(params: ActionArg): Partial<DiagramContext>;
13
- export declare function updateNavigationHistory({ context, event }: ActionArg): Partial<DiagramContext>;
14
- export declare function navigateBack({ context }: ActionArg): Partial<DiagramContext>;
15
- export declare function navigateForward({ context }: ActionArg): Partial<DiagramContext>;
16
21
  export declare function updateNodeData({ context, event }: ActionArg): Partial<DiagramContext>;
17
22
  export declare function updateEdgeData({ context, event }: ActionArg): Partial<DiagramContext>;
18
23
  export declare function resetEdgeControlPoints(nodeLookup: NodeLookup, edge: Types.Edge): [XYPoint] | [XYPoint, XYPoint];
19
- export declare function updateActiveWalkthrough({ context }: ActionArg): Partial<DiagramContext>;
@@ -1,62 +1,28 @@
1
- import { nonNullable, invariant } from '@likec4/core';
1
+ import { nonNullable } from '@likec4/core';
2
2
  import { getNodeDimensions } from '@xyflow/system';
3
3
  import { deepEqual } from 'fast-equals';
4
- import { mergeDeep, omit } from 'remeda';
4
+ import { mergeDeep } from 'remeda';
5
5
  import { assertEvent } from 'xstate';
6
6
  import { vector } from '../../utils/vector.js';
7
7
  import { getNodeCenter } from '../../utils/xyflow.js';
8
- import { SeqParallelAreaColor } from '../xyflow-sequence/const.js';
8
+ import { updateNodes } from '../../base/updateNodes.js';
9
+ import { updateEdges } from '../../base/updateEdges.js';
9
10
  import { Base } from '../../base/Base.js';
10
11
 
11
- function mergeXYNodesEdges({ context, event }) {
12
- assertEvent(event, "update.view");
12
+ function mergeXYNodesEdges(context, event) {
13
13
  const nextView = event.view;
14
- const isSameView = context.view.id === nextView.id;
15
- const currentNodes = context.xynodes;
16
- const xynodes = event.xynodes.map((update) => {
17
- const existing = currentNodes.find((n) => n.id === update.id);
18
- if (existing) {
19
- if (existing === update) {
20
- return existing;
21
- }
22
- const { width: existingWidth, height: existingHeight } = getNodeDimensions(existing);
23
- if (deepEqual(existing.type, update.type) && deepEqual(existingWidth, update.initialWidth) && deepEqual(existingHeight, update.initialHeight) && deepEqual(existing.hidden ?? false, update.hidden ?? false) && deepEqual(existing.position, update.position) && deepEqual(existing.data, update.data) && deepEqual(existing.parentId ?? null, update.parentId ?? null)) {
24
- return existing;
25
- }
26
- return {
27
- ...omit(existing, ["measured", "parentId", "hidden"]),
28
- ...update,
29
- // Force dimensions from update
30
- width: update.initialWidth,
31
- height: update.initialHeight
32
- };
33
- }
34
- return update;
35
- });
36
- let xyedges = event.xyedges;
37
- if (isSameView && (!nextView.drifts || nextView.drifts.length === 0)) {
38
- const currentEdges = context.xyedges;
39
- xyedges = event.xyedges.map((update) => {
40
- const existing = currentEdges.find((n) => n.id === update.id);
41
- if (existing === update) {
42
- return existing;
43
- }
44
- if (existing && existing.type === update.type) {
45
- if (deepEqual(existing.hidden ?? false, update.hidden ?? false) && deepEqual(existing.data, update.data) && deepEqual(existing.source, update.source) && deepEqual(existing.target, update.target) && deepEqual(existing.sourceHandle, update.sourceHandle) && deepEqual(existing.targetHandle, update.targetHandle)) {
46
- return existing;
47
- }
48
- return {
49
- ...omit(existing, ["hidden", "sourceHandle", "targetHandle"]),
50
- ...update,
51
- data: {
52
- ...existing.data,
53
- ...update.data
54
- }
55
- };
56
- }
57
- return update;
58
- });
14
+ const currentView = context.view;
15
+ const isSameView = currentView.id === nextView.id;
16
+ const isDynamicViewUpdate = nextView._type === "dynamic" && nextView.variant === "sequence";
17
+ if (isDynamicViewUpdate) {
18
+ return {
19
+ xynodes: event.xynodes,
20
+ xyedges: event.xyedges,
21
+ view: nextView
22
+ };
59
23
  }
24
+ const xynodes = updateNodes(context.xynodes, event.xynodes);
25
+ const xyedges = isSameView ? updateEdges(context.xyedges, event.xyedges) : event.xyedges;
60
26
  return {
61
27
  xynodes,
62
28
  xyedges,
@@ -88,124 +54,6 @@ function focusNodesEdges(params) {
88
54
  xyedges
89
55
  };
90
56
  }
91
- function updateNavigationHistory({ context, event }) {
92
- assertEvent(event, "update.view");
93
- let {
94
- navigationHistory: {
95
- currentIndex,
96
- history
97
- },
98
- lastOnNavigate,
99
- viewport
100
- } = context;
101
- const stepCurrent = history[currentIndex];
102
- if (!stepCurrent) {
103
- return {
104
- navigationHistory: {
105
- currentIndex: 0,
106
- history: [
107
- {
108
- viewId: event.view.id,
109
- fromNode: null,
110
- viewport: { ...viewport }
111
- }
112
- ]
113
- }
114
- };
115
- }
116
- if (stepCurrent.viewId !== event.view.id) {
117
- if (!lastOnNavigate) {
118
- const stepBack = currentIndex > 0 ? nonNullable(history[currentIndex - 1]) : null;
119
- if (stepBack && stepBack.viewId === event.view.id) {
120
- return {
121
- navigationHistory: {
122
- currentIndex: currentIndex - 1,
123
- history
124
- },
125
- lastOnNavigate: {
126
- fromView: stepCurrent.viewId,
127
- toView: stepBack.viewId,
128
- fromNode: stepCurrent.fromNode
129
- }
130
- };
131
- }
132
- const stepForward = currentIndex < history.length - 1 ? nonNullable(history[currentIndex + 1]) : null;
133
- if (stepForward && stepForward.viewId === event.view.id) {
134
- return {
135
- navigationHistory: {
136
- currentIndex: currentIndex + 1,
137
- history
138
- },
139
- lastOnNavigate: {
140
- fromView: stepCurrent.viewId,
141
- toView: stepForward.viewId,
142
- fromNode: stepForward.fromNode
143
- }
144
- };
145
- }
146
- }
147
- history = [
148
- ...history.slice(0, currentIndex + 1),
149
- {
150
- viewId: event.view.id,
151
- fromNode: lastOnNavigate?.fromNode ?? null,
152
- viewport: { ...viewport }
153
- }
154
- ];
155
- currentIndex = history.length - 1;
156
- return {
157
- navigationHistory: {
158
- currentIndex,
159
- history
160
- }
161
- };
162
- }
163
- return {};
164
- }
165
- function navigateBack({ context }) {
166
- const {
167
- navigationHistory: {
168
- currentIndex,
169
- history
170
- }
171
- } = context;
172
- invariant(currentIndex > 0, "Cannot navigate back");
173
- const stepCurrent = history[currentIndex];
174
- const stepBack = history[currentIndex - 1];
175
- return {
176
- navigationHistory: {
177
- currentIndex: currentIndex - 1,
178
- history
179
- },
180
- lastOnNavigate: {
181
- fromView: stepCurrent.viewId,
182
- toView: stepBack.viewId,
183
- fromNode: stepCurrent.fromNode
184
- }
185
- };
186
- }
187
- function navigateForward({ context }) {
188
- const {
189
- navigationHistory: {
190
- currentIndex,
191
- history
192
- }
193
- } = context;
194
- invariant(currentIndex < history.length - 1, "Cannot navigate forward");
195
- const stepCurrent = history[currentIndex];
196
- const stepForward = history[currentIndex + 1];
197
- return {
198
- navigationHistory: {
199
- currentIndex: currentIndex + 1,
200
- history
201
- },
202
- lastOnNavigate: {
203
- fromView: stepCurrent.viewId,
204
- toView: stepForward.viewId,
205
- fromNode: stepForward.fromNode
206
- }
207
- };
208
- }
209
57
  function updateNodeData({ context, event }) {
210
58
  console.log("updateNodeData called", event);
211
59
  assertEvent(event, "update.nodeData");
@@ -266,28 +114,5 @@ function resetEdgeControlPoints(nodeLookup, edge) {
266
114
  const targetBorderPoint = getBorderPointOnVector(target, targetCenter, sourceToTargetVector.multiply(-1));
267
115
  return [sourceBorderPoint.add(targetBorderPoint.subtract(sourceBorderPoint).multiply(0.4))];
268
116
  }
269
- function updateActiveWalkthrough({ context }) {
270
- const { stepId, parallelPrefix } = nonNullable(context.activeWalkthrough, "activeWalkthrough is null");
271
- const step = nonNullable(context.xyedges.find((x) => x.id === stepId));
272
- return {
273
- xyedges: context.xyedges.map((edge) => {
274
- const active = stepId === edge.id || !!parallelPrefix && edge.id.startsWith(parallelPrefix);
275
- return Base.setData(edge, {
276
- active,
277
- dimmed: stepId !== edge.id
278
- });
279
- }),
280
- xynodes: context.xynodes.map((node) => {
281
- const dimmed = step.source !== node.id && step.target !== node.id;
282
- if (node.type === "seq-parallel") {
283
- return Base.setData(node, {
284
- color: parallelPrefix === node.data.parallelPrefix ? SeqParallelAreaColor.active : SeqParallelAreaColor.default,
285
- dimmed
286
- });
287
- }
288
- return Base.setDimmed(node, dimmed);
289
- })
290
- };
291
- }
292
117
 
293
- export { focusNodesEdges, mergeXYNodesEdges, navigateBack, navigateForward, resetEdgeControlPoints, updateActiveWalkthrough, updateEdgeData, updateNavigationHistory, updateNodeData };
118
+ export { focusNodesEdges, mergeXYNodesEdges, resetEdgeControlPoints, updateEdgeData, updateNodeData };
@@ -1,5 +1,5 @@
1
1
  import { getNodeDimensions } from '@xyflow/system';
2
- import { indexBy, map, omit, hasAtLeast } from 'remeda';
2
+ import { map, omit, hasAtLeast } from 'remeda';
3
3
  import { calcViewBounds } from '../../utils/view-bounds.js';
4
4
  import { isSamePoint, bezierControlPoints } from '../../utils/xyflow.js';
5
5
 
@@ -12,33 +12,27 @@ function createViewChange(parentContext) {
12
12
  // Ignore layout type from view
13
13
  ...view
14
14
  },
15
- xynodes,
16
- xyedges,
17
15
  xystore
18
16
  } = parentContext;
19
- const { nodeLookup } = xystore.getState();
17
+ const { nodeLookup, edgeLookup } = xystore.getState();
20
18
  const movedNodes = /* @__PURE__ */ new Set();
21
- const xynodesLookup = indexBy(xynodes, (n) => n.data.id);
22
- const xyedgesLookup = indexBy(xyedges, (e) => e.data.id);
23
19
  const nodes = map(view.nodes, (node) => {
24
- const xynode = xynodesLookup[node.id];
25
- if (!xynode) {
20
+ const internal = nodeLookup.get(node.id);
21
+ if (!internal) {
22
+ console.error(`Internal node not found for ${node.id}`);
26
23
  return node;
27
24
  }
28
- const internal = nodeLookup.get(xynode.id);
29
25
  const dimensions = getNodeDimensions(internal);
30
- const isChanged = !isSamePoint(internal.internals.positionAbsolute, node) || node.width !== dimensions.width || node.height !== dimensions.height || node.shape !== xynode.data.shape || node.color !== xynode.data.color || node.style.border !== xynode.data.style.border || node.style.opacity !== xynode.data.style.opacity;
31
- if (!isChanged) {
32
- return node;
26
+ const isChanged = !isSamePoint(internal.internals.positionAbsolute, node) || node.width !== dimensions.width || node.height !== dimensions.height;
27
+ if (isChanged) {
28
+ movedNodes.add(node.id);
33
29
  }
34
- movedNodes.add(xynode.id);
35
30
  return {
36
31
  ...node,
37
- shape: xynode.data.shape,
38
- color: xynode.data.color,
32
+ shape: internal.data.shape,
33
+ color: internal.data.color,
39
34
  style: {
40
- ...node.style,
41
- ...xynode.data.style
35
+ ...internal.data.style
42
36
  },
43
37
  x: Math.floor(internal.internals.positionAbsolute.x),
44
38
  y: Math.floor(internal.internals.positionAbsolute.y),
@@ -47,8 +41,9 @@ function createViewChange(parentContext) {
47
41
  };
48
42
  });
49
43
  const edges = map(view.edges, (edge) => {
50
- const xyedge = xyedgesLookup[edge.id];
44
+ const xyedge = edgeLookup.get(edge.id);
51
45
  if (!xyedge) {
46
+ console.error(`Internal edge not found for ${edge.id}`);
52
47
  return edge;
53
48
  }
54
49
  const data = xyedge.data;
@@ -58,17 +53,11 @@ function createViewChange(parentContext) {
58
53
  controlPoints = bezierControlPoints(data.points);
59
54
  }
60
55
  const _updated = {
61
- ...omit(edge, ["controlPoints"]),
56
+ ...omit(edge, ["controlPoints", "labelBBox"]),
62
57
  points: data.points
63
58
  };
64
- if (data.labelXY && data.labelBBox) {
65
- _updated.labelBBox = {
66
- ...data.labelBBox,
67
- ...data.labelXY
68
- };
69
- }
70
59
  if (data.labelBBox) {
71
- _updated.labelBBox ??= data.labelBBox;
60
+ _updated.labelBBox = data.labelBBox;
72
61
  }
73
62
  if (hasAtLeast(controlPoints, 1)) {
74
63
  _updated.controlPoints = controlPoints;
@@ -4,7 +4,7 @@ import { FeatureName } from '../../context/DiagramFeatures';
4
4
  import { OpenSourceParams } from '../../LikeC4Diagram.props';
5
5
  import { Types } from '../types';
6
6
  import { AlignmentMode } from './aligners';
7
- import { DiagramActorEvent, DiagramActorRef, DiagramActorSnapshot, DiagramContext } from './types';
7
+ import { DiagramActorRef, DiagramContext, DiagramEvents } from './types';
8
8
  import type * as t from '@likec4/core/types';
9
9
  type Any = t.aux.Any;
10
10
  type Unknown = t.aux.UnknownLayouted;
@@ -21,7 +21,7 @@ export interface DiagramApi<A extends Any = Unknown> {
21
21
  /**
22
22
  * Send event to diagram actor
23
23
  */
24
- send(event: DiagramActorEvent): void;
24
+ send(event: DiagramEvents): void;
25
25
  /**
26
26
  * Navigate to view
27
27
  */
@@ -76,10 +76,6 @@ export interface DiagramApi<A extends Any = Unknown> {
76
76
  * Focus node
77
77
  */
78
78
  focusNode(nodeId: NodeId): void;
79
- /**
80
- * @warning Do not use in render phase
81
- */
82
- getSnapshot(): DiagramActorSnapshot;
83
79
  /**
84
80
  * @warning Do not use in render phase
85
81
  */
@@ -16,7 +16,7 @@ function makeDiagramApi(actor) {
16
16
  actor.send({ type: `navigate.${direction}` });
17
17
  },
18
18
  fitDiagram: (duration = 350) => {
19
- actor.send({ type: "fitDiagram", duration });
19
+ actor.send({ type: "xyflow.fitDiagram", duration });
20
20
  },
21
21
  openRelationshipsBrowser: (fqn) => {
22
22
  actor.send({ type: "open.relationshipsBrowser", fqn });
@@ -38,11 +38,7 @@ function makeDiagramApi(actor) {
38
38
  actor.send({ type: "update.nodeData", nodeId, data });
39
39
  },
40
40
  updateEdgeData: (edgeId, data) => {
41
- actor.send({
42
- type: "update.edgeData",
43
- edgeId,
44
- data
45
- });
41
+ actor.send({ type: "update.edgeData", edgeId, data });
46
42
  },
47
43
  startEditing: (subject) => {
48
44
  const syncActor = typedSystem(actor.system).syncLayoutActorRef;
@@ -78,10 +74,6 @@ function makeDiagramApi(actor) {
78
74
  get currentView() {
79
75
  return actor.getSnapshot().context.view;
80
76
  },
81
- /**
82
- * @warning Do not use in render phase
83
- */
84
- getSnapshot: () => actor.getSnapshot(),
85
77
  /**
86
78
  * @warning Do not use in render phase
87
79
  */
@@ -5,10 +5,3 @@ export type HotKeyEvent = {
5
5
  export interface HotkeyActorLogic extends CallbackActorLogic<AnyEventObject, NonReducibleUnknown, HotKeyEvent> {
6
6
  }
7
7
  export declare const hotkeyActorLogic: HotkeyActorLogic;
8
- type UndoEvent = {
9
- type: 'undo';
10
- };
11
- export interface UndoHotKeyActorLogic extends CallbackActorLogic<AnyEventObject, NonReducibleUnknown, UndoEvent> {
12
- }
13
- export declare const undoHotKeyActorLogic: UndoHotKeyActorLogic;
14
- export {};
@@ -5,7 +5,6 @@ const hotkeyActorLogic = fromCallback(({ sendBack }) => {
5
5
  const escHandler = getHotkeyHandler([
6
6
  ["Escape", (event) => {
7
7
  event.stopPropagation();
8
- console.log("Escape karsarsey pressed");
9
8
  sendBack({ type: "key.esc" });
10
9
  }, {
11
10
  preventDefault: true
@@ -32,20 +31,5 @@ const hotkeyActorLogic = fromCallback(({ sendBack }) => {
32
31
  document.body.removeEventListener("keydown", arrowshandler, { capture: true });
33
32
  };
34
33
  });
35
- const undoHotKeyActorLogic = fromCallback(({ sendBack }) => {
36
- const ctrlZHandler = getHotkeyHandler([
37
- ["mod + z", (event) => {
38
- console.log("Undo hotkey pressed");
39
- event.stopPropagation();
40
- sendBack({ type: "undo" });
41
- }, {
42
- preventDefault: true
43
- }]
44
- ]);
45
- document.body.addEventListener("keydown", ctrlZHandler, { capture: true });
46
- return () => {
47
- document.body.removeEventListener("keydown", ctrlZHandler, { capture: true });
48
- };
49
- });
50
34
 
51
- export { hotkeyActorLogic, undoHotKeyActorLogic };
35
+ export { hotkeyActorLogic };