@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
@@ -1,13 +1,14 @@
1
1
  import { applyEdgeChanges, applyNodeChanges } from '@xyflow/react';
2
2
  import { DefaultFeatures } from '../../context/DiagramFeatures.js';
3
- import { updateNavigationHistory, updateEdgeData, updateNodeData } from './assign.js';
4
- import { stopSyncLayout, cancelFitDiagram, emitOnLayoutTypeChange, emitOnChange, assignDynamicViewVariant, updateFeatures, ensureOverlaysActorState, ensureSearchActorState, updateInputs, updateView, xyflow, resetLastClickedNode, emitEdgeClick, assignLastClickedNode, emitNodeClick, emitPaneClick } from './machine.actions.js';
3
+ import { updateEdgeData, updateNodeData } from './assign.js';
4
+ import { emitOnLayoutTypeChange, emitOnChange, updateFeatures, updateInputs, assignDynamicViewVariant, stopSyncLayout } from './machine.actions.js';
5
5
  import { machine } from './machine.setup.js';
6
6
  import { isReady, initializing } from './machine.state.initializing.js';
7
7
  import { navigating } from './machine.state.navigating.js';
8
8
  import { ready } from './machine.state.ready.js';
9
9
  import { DiagramToggledFeaturesPersistence } from './persistence.js';
10
10
  import { x as xstateActions_cjsExports } from '../../_virtual/xstate-actions.cjs.js';
11
+ import { cancelFitDiagram } from './machine.actions.layout.js';
11
12
 
12
13
  const _diagramMachine = machine.createMachine({
13
14
  initial: "initializing",
@@ -29,7 +30,7 @@ const _diagramMachine = machine.createMachine({
29
30
  lastClickedNode: null,
30
31
  focusedNode: null,
31
32
  activeElementDetails: null,
32
- viewportBeforeFocus: null,
33
+ viewportBefore: null,
33
34
  viewportOnManualLayout: null,
34
35
  viewportOnAutoLayout: null,
35
36
  navigationHistory: {
@@ -45,96 +46,81 @@ const _diagramMachine = machine.createMachine({
45
46
  initializing,
46
47
  isReady,
47
48
  ready,
48
- navigating
49
+ navigating,
50
+ final: {
51
+ type: "final",
52
+ entry: [
53
+ stopSyncLayout(),
54
+ cancelFitDiagram(),
55
+ xstateActions_cjsExports.stopChild("hotkey"),
56
+ xstateActions_cjsExports.stopChild("overlays"),
57
+ xstateActions_cjsExports.stopChild("search"),
58
+ xstateActions_cjsExports.stopChild("mediaPrint"),
59
+ xstateActions_cjsExports.assign({
60
+ xyflow: null,
61
+ xystore: null,
62
+ xyedges: [],
63
+ xynodes: [],
64
+ initialized: {
65
+ xydata: false,
66
+ xyflow: false
67
+ }
68
+ })
69
+ ]
70
+ }
49
71
  },
50
72
  on: {
51
- "xyflow.paneClick": {
52
- actions: [
53
- resetLastClickedNode(),
54
- emitPaneClick()
55
- ]
56
- },
57
- "xyflow.nodeClick": {
58
- actions: [
59
- assignLastClickedNode(),
60
- emitNodeClick()
61
- ]
62
- },
63
- "xyflow.edgeClick": {
64
- actions: [
65
- resetLastClickedNode(),
66
- emitEdgeClick()
67
- ]
68
- },
69
- "xyflow.applyNodeChanges": {
70
- actions: xstateActions_cjsExports.assign({
71
- xynodes: ({ context, event }) => applyNodeChanges(event.changes, context.xynodes)
72
- })
73
- },
74
- "xyflow.applyEdgeChanges": {
75
- actions: xstateActions_cjsExports.assign({
76
- xyedges: ({ context, event }) => applyEdgeChanges(event.changes, context.xyedges)
77
- })
78
- },
79
- "xyflow.viewportMoved": {
80
- actions: xstateActions_cjsExports.assign({
81
- viewportChangedManually: (({ event }) => event.manually),
82
- viewport: (({ event }) => event.viewport)
83
- })
84
- },
85
- "fitDiagram": {
86
- guard: "enabled: FitView",
87
- actions: xyflow.fitDiagram()
88
- },
89
73
  "update.nodeData": {
90
74
  actions: xstateActions_cjsExports.assign(updateNodeData)
91
75
  },
92
76
  "update.edgeData": {
93
77
  actions: xstateActions_cjsExports.assign(updateEdgeData)
94
78
  },
95
- "update.view": {
96
- actions: [
97
- xstateActions_cjsExports.assign(updateNavigationHistory),
98
- updateView()
99
- ]
79
+ "switch.dynamicViewVariant": {
80
+ actions: assignDynamicViewVariant()
100
81
  },
101
82
  "update.inputs": {
102
83
  actions: updateInputs()
103
84
  },
104
- "update.features": {
105
- actions: [
106
- updateFeatures(),
107
- ensureOverlaysActorState(),
108
- ensureSearchActorState()
109
- ]
85
+ "update.view-bounds": {
86
+ actions: xstateActions_cjsExports.assign(({ context, event }) => {
87
+ return {
88
+ view: {
89
+ ...context.view,
90
+ bounds: event.bounds
91
+ }
92
+ };
93
+ })
110
94
  },
111
- "switch.dynamicViewVariant": {
112
- actions: assignDynamicViewVariant()
95
+ "update.features": {
96
+ actions: updateFeatures()
113
97
  },
114
98
  "emit.onChange": {
115
99
  actions: emitOnChange()
116
100
  },
117
101
  "emit.onLayoutTypeChange": {
118
102
  actions: emitOnLayoutTypeChange()
103
+ },
104
+ "xyflow.applyNodeChanges": {
105
+ actions: xstateActions_cjsExports.assign({
106
+ xynodes: ({ context, event }) => applyNodeChanges(event.changes, context.xynodes)
107
+ })
108
+ },
109
+ "xyflow.applyEdgeChanges": {
110
+ actions: xstateActions_cjsExports.assign({
111
+ xyedges: ({ context, event }) => applyEdgeChanges(event.changes, context.xyedges)
112
+ })
113
+ },
114
+ "xyflow.viewportMoved": {
115
+ actions: xstateActions_cjsExports.assign(({ event, context }) => ({
116
+ viewportChangedManually: context.viewportChangedManually || event.manually,
117
+ viewport: event.viewport
118
+ }))
119
+ },
120
+ "destroy": {
121
+ target: ".final"
119
122
  }
120
- },
121
- exit: [
122
- stopSyncLayout(),
123
- cancelFitDiagram(),
124
- xstateActions_cjsExports.stopChild("hotkey"),
125
- xstateActions_cjsExports.stopChild("overlays"),
126
- xstateActions_cjsExports.stopChild("search"),
127
- xstateActions_cjsExports.assign({
128
- xyflow: null,
129
- xystore: null,
130
- xyedges: [],
131
- xynodes: [],
132
- initialized: {
133
- xydata: false,
134
- xyflow: false
135
- }
136
- })
137
- ]
123
+ }
138
124
  });
139
125
  const diagramMachine = _diagramMachine;
140
126
 
@@ -3,22 +3,35 @@ import { DiagramEdge, DiagramNode, DiagramView, DynamicViewDisplayVariant, EdgeI
3
3
  import { EdgeChange, NodeChange, Rect, Viewport } from '@xyflow/system';
4
4
  import { MouseEvent } from 'react';
5
5
  import { PartialDeep } from 'type-fest';
6
- import { EnabledFeatures, FeatureName } from '../../context/DiagramFeatures';
6
+ import { EnabledFeatures, TogglableFeature } from '../../context/DiagramFeatures';
7
7
  import { XYFlowInstance, XYStoreApi } from '../../hooks/useXYFlow';
8
- import { OpenSourceParams, ViewPadding } from '../../LikeC4Diagram.props';
8
+ import { OpenSourceParams, ViewPaddings } from '../../LikeC4Diagram.props';
9
9
  import { Types } from '../types';
10
10
  import { AlignmentMode } from './aligners';
11
11
  import { HotKeyEvent, HotkeyActorLogic } from './hotkeyActor';
12
+ import { MediaPrintEvent, MediaPrintActorLogic } from './mediaPrintActor';
12
13
  import { SetupReturn, NonReducibleUnknown, MetaObject } from 'xstate';
13
14
  import { SyncLayoutActorLogic } from './syncManualLayoutActor';
14
15
  import { OverlaysActorLogic } from '../../overlays/overlaysActor';
15
16
  import { SearchActorLogic } from '../../search/searchActor';
17
+ /**
18
+ * Navigation history entry represents a current view state,
19
+ * including viewport, focused node, dynamic view variant, etc.
20
+ */
21
+ export interface NavigationHistoryEntry {
22
+ viewId: ViewId;
23
+ viewport: Viewport;
24
+ viewportChangedManually: boolean;
25
+ viewportBefore?: null | {
26
+ wasChangedManually: boolean;
27
+ value: Viewport;
28
+ };
29
+ focusedNode?: NodeId | null;
30
+ dynamicViewVariant?: DynamicViewDisplayVariant | null;
31
+ activeWalkthrough?: null | StepEdgeId;
32
+ }
16
33
  export interface NavigationHistory {
17
- history: ReadonlyArray<{
18
- viewId: ViewId;
19
- fromNode: NodeId | null;
20
- viewport: Viewport;
21
- }>;
34
+ history: ReadonlyArray<NavigationHistoryEntry>;
22
35
  currentIndex: number;
23
36
  }
24
37
  export interface Input {
@@ -28,10 +41,12 @@ export interface Input {
28
41
  pannable: boolean;
29
42
  nodesDraggable: boolean;
30
43
  nodesSelectable: boolean;
31
- fitViewPadding: ViewPadding;
44
+ fitViewPadding: ViewPaddings;
32
45
  dynamicViewVariant?: DynamicViewDisplayVariant | undefined;
33
46
  }
34
- export type ToggledFeatures = Partial<EnabledFeatures>;
47
+ export type ToggledFeatures = {
48
+ [P in `enable${TogglableFeature}`]?: boolean;
49
+ };
35
50
  export interface Context extends Input {
36
51
  xynodes: Types.Node[];
37
52
  xyedges: Types.Edge[];
@@ -43,6 +58,15 @@ export interface Context extends Input {
43
58
  };
44
59
  viewport: Viewport;
45
60
  viewportChangedManually: boolean;
61
+ /**
62
+ * Viewport before entering focus mode, walkthrough or printing
63
+ */
64
+ viewportBefore: null | {
65
+ wasChangedManually: boolean;
66
+ value: Viewport;
67
+ };
68
+ viewportOnManualLayout: null | Viewport;
69
+ viewportOnAutoLayout: null | Viewport;
46
70
  lastOnNavigate: null | {
47
71
  fromView: ViewId;
48
72
  toView: ViewId;
@@ -61,9 +85,6 @@ export interface Context extends Input {
61
85
  nodeRect?: Rect | null;
62
86
  nodeRectScreen?: Rect | null;
63
87
  };
64
- viewportBeforeFocus: null | Viewport;
65
- viewportOnManualLayout: null | Viewport;
66
- viewportOnAutoLayout: null | Viewport;
67
88
  xyflow: XYFlowInstance | null;
68
89
  dynamicViewVariant: DynamicViewDisplayVariant;
69
90
  activeWalkthrough: null | {
@@ -71,7 +92,7 @@ export interface Context extends Input {
71
92
  parallelPrefix: string | null;
72
93
  };
73
94
  }
74
- export type Events = HotKeyEvent | {
95
+ export type Events = HotKeyEvent | MediaPrintEvent | {
75
96
  type: 'xyflow.init';
76
97
  instance: XYFlowInstance;
77
98
  } | {
@@ -113,6 +134,14 @@ export type Events = HotKeyEvent | {
113
134
  type: 'xyflow.edgeMouseLeave';
114
135
  edge: Types.Edge;
115
136
  event: MouseEvent;
137
+ } | {
138
+ type: 'xyflow.fitDiagram';
139
+ duration?: number;
140
+ bounds?: BBox;
141
+ } | {
142
+ type: 'xyflow.setViewport';
143
+ duration?: number;
144
+ viewport: Viewport;
116
145
  } | {
117
146
  type: 'update.nodeData';
118
147
  nodeId: NodeId;
@@ -126,16 +155,16 @@ export type Events = HotKeyEvent | {
126
155
  view: DiagramView;
127
156
  xynodes: Types.Node[];
128
157
  xyedges: Types.Edge[];
158
+ source?: 'internal' | 'external';
159
+ } | {
160
+ type: 'update.view-bounds';
161
+ bounds: BBox;
129
162
  } | {
130
163
  type: 'update.inputs';
131
164
  inputs: Partial<Omit<Input, 'view' | 'xystore' | 'dynamicViewVariant'>>;
132
165
  } | {
133
166
  type: 'update.features';
134
167
  features: EnabledFeatures;
135
- } | {
136
- type: 'fitDiagram';
137
- duration?: number;
138
- bounds?: BBox;
139
168
  } | ({
140
169
  type: 'open.source';
141
170
  } & OpenSourceParams) | {
@@ -198,7 +227,7 @@ export type Events = HotKeyEvent | {
198
227
  type: 'tag.unhighlight';
199
228
  } | {
200
229
  type: 'toggle.feature';
201
- feature: FeatureName;
230
+ feature: TogglableFeature;
202
231
  forceValue?: boolean;
203
232
  } | {
204
233
  type: 'emit.onChange';
@@ -206,6 +235,8 @@ export type Events = HotKeyEvent | {
206
235
  } | {
207
236
  type: 'emit.onLayoutTypeChange';
208
237
  layoutType: LayoutType;
238
+ } | {
239
+ type: 'destroy';
209
240
  };
210
241
  export type EmittedEvents = {
211
242
  type: 'initialized';
@@ -253,16 +284,19 @@ export type ActionArg = {
253
284
  context: Context;
254
285
  event: Events;
255
286
  };
287
+ export declare const deriveToggledFeatures: (context: Context) => Required<ToggledFeatures>;
256
288
  export declare const machine: SetupReturn<Context, Events, {
257
289
  syncManualLayoutActorLogic: SyncLayoutActorLogic;
258
290
  hotkeyActorLogic: HotkeyActorLogic;
259
291
  overlaysActorLogic: OverlaysActorLogic;
260
292
  searchActorLogic: SearchActorLogic;
293
+ mediaPrintActorLogic: MediaPrintActorLogic;
261
294
  }, {
262
295
  syncLayout: "syncManualLayoutActorLogic";
263
296
  hotkey: "hotkeyActorLogic";
264
297
  overlays: "overlaysActorLogic";
265
298
  search: "searchActorLogic";
299
+ mediaPrint: "mediaPrintActorLogic";
266
300
  }, {}, {
267
301
  isReady: unknown;
268
302
  'enabled: FitView': unknown;
@@ -271,7 +305,9 @@ export declare const machine: SetupReturn<Context, Events, {
271
305
  'enabled: RelationshipDetails': unknown;
272
306
  'enabled: Search': unknown;
273
307
  'enabled: ElementDetails': unknown;
308
+ 'enabled: OpenSource': unknown;
274
309
  'enabled: DynamicViewWalkthrough': unknown;
310
+ 'enabled: Overlays': unknown;
275
311
  'not readonly': unknown;
276
312
  'is dynamic view': unknown;
277
313
  'is another view': unknown;
@@ -282,3 +318,10 @@ export declare const machine: SetupReturn<Context, Events, {
282
318
  'click: node has connections': unknown;
283
319
  'click: selected edge': unknown;
284
320
  }, never, string, Input, NonReducibleUnknown, EmittedEvents, MetaObject>;
321
+ export declare const targetState: {
322
+ idle: string;
323
+ focused: string;
324
+ walkthrough: string;
325
+ printing: string;
326
+ navigating: string;
327
+ };
@@ -1,11 +1,23 @@
1
1
  import { nonexhaustive } from '@likec4/core';
2
+ import { isTruthy } from 'remeda';
2
3
  import { setup, assertEvent } from 'xstate';
3
4
  import { overlaysActorLogic } from '../../overlays/overlaysActor.js';
4
5
  import { searchActorLogic } from '../../search/searchActor.js';
5
6
  import { hotkeyActorLogic } from './hotkeyActor.js';
7
+ import { mediaPrintActorLogic } from './mediaPrintActor.js';
6
8
  import { syncManualLayoutActorLogic } from './syncManualLayoutActor.js';
7
9
 
8
- const isReadOnly = (context) => (context.features.enableReadOnly || context.toggledFeatures.enableReadOnly === true) && (context.view._type !== "dynamic" || context.dynamicViewVariant !== "sequence");
10
+ const deriveToggledFeatures = (context) => {
11
+ let toggledFeatures = context.toggledFeatures;
12
+ const hasActiveWalkthrough = isTruthy(context.activeWalkthrough);
13
+ const enableCompareWithLatest = context.features.enableCompareWithLatest && (toggledFeatures.enableCompareWithLatest ?? false) && isTruthy(context.view._layout) && !hasActiveWalkthrough;
14
+ const enableReadOnly = context.features.enableReadOnly || (toggledFeatures.enableReadOnly ?? false) || hasActiveWalkthrough || context.dynamicViewVariant === "sequence" && context.view._type === "dynamic" || enableCompareWithLatest && context.view._layout === "auto";
15
+ return {
16
+ enableCompareWithLatest,
17
+ enableReadOnly
18
+ };
19
+ };
20
+ const isReadOnly = (context) => deriveToggledFeatures(context).enableReadOnly;
9
21
  const machine = setup({
10
22
  types: {
11
23
  context: {},
@@ -18,17 +30,20 @@ const machine = setup({
18
30
  syncManualLayoutActorLogic,
19
31
  hotkeyActorLogic,
20
32
  overlaysActorLogic,
21
- searchActorLogic
33
+ searchActorLogic,
34
+ mediaPrintActorLogic
22
35
  },
23
36
  guards: {
24
37
  "isReady": ({ context }) => context.initialized.xydata && context.initialized.xyflow,
25
38
  "enabled: FitView": ({ context }) => context.features.enableFitView,
26
- "enabled: FocusMode": ({ context }) => (context.toggledFeatures.enableFocusMode ?? context.features.enableFocusMode) === true && isReadOnly(context),
39
+ "enabled: FocusMode": ({ context }) => context.features.enableFocusMode && isReadOnly(context),
27
40
  "enabled: Readonly": ({ context }) => isReadOnly(context),
28
41
  "enabled: RelationshipDetails": ({ context }) => context.features.enableRelationshipDetails,
29
42
  "enabled: Search": ({ context }) => context.features.enableSearch,
30
43
  "enabled: ElementDetails": ({ context }) => context.features.enableElementDetails,
31
- "enabled: DynamicViewWalkthrough": ({ context }) => isReadOnly(context) && context.features.enableDynamicViewWalkthrough,
44
+ "enabled: OpenSource": ({ context }) => context.features.enableVscode,
45
+ "enabled: DynamicViewWalkthrough": ({ context }) => context.features.enableDynamicViewWalkthrough,
46
+ "enabled: Overlays": ({ context }) => context.features.enableElementDetails || context.features.enableRelationshipBrowser || context.features.enableRelationshipDetails,
32
47
  "not readonly": ({ context }) => !isReadOnly(context),
33
48
  "is dynamic view": ({ context }) => context.view._type === "dynamic",
34
49
  "is another view": ({ context, event }) => {
@@ -67,5 +82,12 @@ const machine = setup({
67
82
  }
68
83
  }
69
84
  });
85
+ const targetState = {
86
+ idle: "#idle",
87
+ focused: "#focused",
88
+ walkthrough: "#walkthrough",
89
+ printing: "#printing",
90
+ navigating: "#navigating"
91
+ };
70
92
 
71
- export { machine };
93
+ export { deriveToggledFeatures, machine, targetState };
@@ -5,6 +5,7 @@ import { SyncLayoutActorLogic } from './syncManualLayoutActor';
5
5
  import { HotkeyActorLogic } from './hotkeyActor';
6
6
  import { OverlaysActorLogic } from '../../overlays/overlaysActor';
7
7
  import { SearchActorLogic } from '../../search/searchActor';
8
+ import { MediaPrintActorLogic } from './mediaPrintActor';
8
9
  import { DiagramView } from '@likec4/core';
9
10
  /**
10
11
  * To be in `initializing` state, the diagram must wait for two events:
@@ -40,6 +41,11 @@ export declare const initializing: {
40
41
  logic: SearchActorLogic;
41
42
  id: "search";
42
43
  };
44
+ mediaPrintActorLogic: {
45
+ src: "mediaPrintActorLogic";
46
+ logic: MediaPrintActorLogic;
47
+ id: "mediaPrint";
48
+ };
43
49
  }>, never, never, never, never>;
44
50
  target: string;
45
51
  };
@@ -49,6 +55,7 @@ export declare const initializing: {
49
55
  view: DiagramView;
50
56
  xynodes: import("../types").Types.Node[];
51
57
  xyedges: import("../types").Types.Edge[];
58
+ source?: "internal" | "external";
52
59
  }, Events, undefined, Values<{
53
60
  syncManualLayoutActorLogic: {
54
61
  src: "syncManualLayoutActorLogic";
@@ -70,6 +77,11 @@ export declare const initializing: {
70
77
  logic: SearchActorLogic;
71
78
  id: "search";
72
79
  };
80
+ mediaPrintActorLogic: {
81
+ src: "mediaPrintActorLogic";
82
+ logic: MediaPrintActorLogic;
83
+ id: "mediaPrint";
84
+ };
73
85
  }>, never, never, never, never>;
74
86
  target: string;
75
87
  };
@@ -104,6 +116,11 @@ export declare const isReady: {
104
116
  logic: SearchActorLogic;
105
117
  id: "search";
106
118
  };
119
+ mediaPrintActorLogic: {
120
+ src: "mediaPrintActorLogic";
121
+ logic: MediaPrintActorLogic;
122
+ id: "mediaPrint";
123
+ };
107
124
  }>, never, Values<{
108
125
  isReady: {
109
126
  type: "isReady";
@@ -133,10 +150,18 @@ export declare const isReady: {
133
150
  type: "enabled: ElementDetails";
134
151
  params: unknown;
135
152
  };
153
+ "enabled: OpenSource": {
154
+ type: "enabled: OpenSource";
155
+ params: unknown;
156
+ };
136
157
  "enabled: DynamicViewWalkthrough": {
137
158
  type: "enabled: DynamicViewWalkthrough";
138
159
  params: unknown;
139
160
  };
161
+ "enabled: Overlays": {
162
+ type: "enabled: Overlays";
163
+ params: unknown;
164
+ };
140
165
  "not readonly": {
141
166
  type: "not readonly";
142
167
  params: unknown;
@@ -1,4 +1,5 @@
1
- import { xyflow, ensureSyncLayout, emitInitialized } from './machine.actions.js';
1
+ import { emitInitialized } from './machine.actions.js';
2
+ import { fitDiagram } from './machine.actions.layout.js';
2
3
  import { machine } from './machine.setup.js';
3
4
  import { x as xstateActions_cjsExports } from '../../_virtual/xstate-actions.cjs.js';
4
5
 
@@ -32,18 +33,17 @@ const isReady = machine.createStateConfig({
32
33
  always: [{
33
34
  guard: "isReady",
34
35
  actions: [
35
- xyflow.fitDiagram({ duration: 0 }),
36
+ fitDiagram({ duration: 0 }),
36
37
  xstateActions_cjsExports.assign(({ context }) => ({
37
38
  navigationHistory: {
38
39
  currentIndex: 0,
39
40
  history: [{
40
41
  viewId: context.view.id,
41
- fromNode: null,
42
- viewport: { ...context.xyflow.getViewport() }
42
+ viewport: { ...context.xyflow.getViewport() },
43
+ viewportChangedManually: false
43
44
  }]
44
45
  }
45
46
  })),
46
- ensureSyncLayout(),
47
47
  emitInitialized()
48
48
  ],
49
49
  target: "ready"
@@ -1,10 +1,5 @@
1
- import { CancelAction, ActionFunction, Values } from 'xstate';
2
- import { Context, Events, EmittedEvents } from './machine.setup';
3
- import { DiagramView } from '@likec4/core';
4
- import { SyncLayoutActorLogic } from './syncManualLayoutActor';
5
- import { HotkeyActorLogic } from './hotkeyActor';
6
- import { OverlaysActorLogic } from '../../overlays/overlaysActor';
7
- import { SearchActorLogic } from '../../search/searchActor';
1
+ import { CancelAction } from 'xstate';
2
+ import { Context, Events } from './machine.setup';
8
3
  /**
9
4
  * State for handling navigation to a different view.
10
5
  * Closes overlays and search, stops sync layout and fit diagram actions,
@@ -12,106 +7,8 @@ import { SearchActorLogic } from '../../search/searchActor';
12
7
  */
13
8
  export declare const navigating: {
14
9
  id: string;
15
- entry: CancelAction<Context, Events, undefined, Events>[];
16
- on: {
17
- 'update.view': {
18
- actions: ActionFunction<Context, {
19
- type: "update.view";
20
- view: DiagramView;
21
- xynodes: import("../types").Types.Node[];
22
- xyedges: import("../types").Types.Edge[];
23
- }, Events, undefined, Values<{
24
- syncManualLayoutActorLogic: {
25
- src: "syncManualLayoutActorLogic";
26
- logic: SyncLayoutActorLogic;
27
- id: "syncLayout";
28
- };
29
- hotkeyActorLogic: {
30
- src: "hotkeyActorLogic";
31
- logic: HotkeyActorLogic;
32
- id: "hotkey";
33
- };
34
- overlaysActorLogic: {
35
- src: "overlaysActorLogic";
36
- logic: OverlaysActorLogic;
37
- id: "overlays";
38
- };
39
- searchActorLogic: {
40
- src: "searchActorLogic";
41
- logic: SearchActorLogic;
42
- id: "search";
43
- };
44
- }>, never, Values<{
45
- isReady: {
46
- type: "isReady";
47
- params: unknown;
48
- };
49
- "enabled: FitView": {
50
- type: "enabled: FitView";
51
- params: unknown;
52
- };
53
- "enabled: FocusMode": {
54
- type: "enabled: FocusMode";
55
- params: unknown;
56
- };
57
- "enabled: Readonly": {
58
- type: "enabled: Readonly";
59
- params: unknown;
60
- };
61
- "enabled: RelationshipDetails": {
62
- type: "enabled: RelationshipDetails";
63
- params: unknown;
64
- };
65
- "enabled: Search": {
66
- type: "enabled: Search";
67
- params: unknown;
68
- };
69
- "enabled: ElementDetails": {
70
- type: "enabled: ElementDetails";
71
- params: unknown;
72
- };
73
- "enabled: DynamicViewWalkthrough": {
74
- type: "enabled: DynamicViewWalkthrough";
75
- params: unknown;
76
- };
77
- "not readonly": {
78
- type: "not readonly";
79
- params: unknown;
80
- };
81
- "is dynamic view": {
82
- type: "is dynamic view";
83
- params: unknown;
84
- };
85
- "is another view": {
86
- type: "is another view";
87
- params: unknown;
88
- };
89
- "click: node has modelFqn": {
90
- type: "click: node has modelFqn";
91
- params: unknown;
92
- };
93
- "click: selected node": {
94
- type: "click: selected node";
95
- params: unknown;
96
- };
97
- "click: same node": {
98
- type: "click: same node";
99
- params: unknown;
100
- };
101
- "click: focused node": {
102
- type: "click: focused node";
103
- params: unknown;
104
- };
105
- "click: node has connections": {
106
- type: "click: node has connections";
107
- params: unknown;
108
- };
109
- "click: selected edge": {
110
- type: "click: selected edge";
111
- params: unknown;
112
- };
113
- }>, never, EmittedEvents>;
114
- target: string;
115
- };
10
+ always: {
11
+ target: string;
12
+ actions: CancelAction<Context, Events, undefined, Events>[];
116
13
  };
117
14
  };