@likec4/diagram 1.58.0 → 1.59.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.
- package/dist/LikeC4Diagram.js +1 -1
- package/dist/LikeC4Diagram.props.d.ts +1 -1
- package/dist/LikeC4Styles.js +1 -1
- package/dist/LikeC4View.js +2 -2
- package/dist/ReactLikeC4.d.ts +1 -1
- package/dist/base/Base.d.ts +3 -2
- package/dist/base/Base.js +14 -26
- package/dist/base/BaseXYFlow.d.ts +2 -1
- package/dist/base/BaseXYFlow.js +63 -4
- package/dist/base/keyboardZoom.d.ts +3 -0
- package/dist/base/keyboardZoom.js +20 -0
- package/dist/base/updateEdges.js +7 -16
- package/dist/base/updateNodes.js +3 -9
- package/dist/base-primitives/compound/CompoundActionButton.d.ts +2 -1
- package/dist/base-primitives/compound/CompoundActionButton.js +5 -2
- package/dist/base-primitives/compound/CompoundDetailsButton.d.ts +2 -1
- package/dist/base-primitives/compound/CompoundDetailsButton.js +5 -2
- package/dist/base-primitives/compound/CompoundTitle.d.ts +7 -1
- package/dist/base-primitives/compound/CompoundTitle.js +2 -1
- package/dist/base-primitives/compound/actionbtns.css.d.ts +1 -1
- package/dist/base-primitives/edge/EdgeActionButton.d.ts +2 -1
- package/dist/base-primitives/edge/EdgeActionButton.js +2 -1
- package/dist/base-primitives/edge/EdgeContainer.d.ts +1 -1
- package/dist/base-primitives/edge/EdgeContainer.js +4 -2
- package/dist/base-primitives/edge/EdgeLabel.d.ts +2 -0
- package/dist/base-primitives/edge/EdgeLabel.js +2 -5
- package/dist/base-primitives/element/ElementActionButtons.d.ts +1 -0
- package/dist/base-primitives/element/ElementActionButtons.js +4 -1
- package/dist/base-primitives/element/ElementData.d.ts +3 -1
- package/dist/base-primitives/element/ElementData.js +2 -1
- package/dist/base-primitives/element/ElementDetailsButton.d.ts +2 -1
- package/dist/base-primitives/element/ElementDetailsButton.js +5 -2
- package/dist/base-primitives/element/ElementNodeContainer.js +1 -1
- package/dist/base-primitives/element/ElementShape.js +3 -0
- package/dist/components/ErrorFallback.js +3 -5
- package/dist/components/Link.js +6 -6
- package/dist/components/NavigationPanel.js +1 -1
- package/dist/components/SearchControl.css.js +11 -11
- package/dist/context/TagStylesContext.d.ts +3 -3
- package/dist/context/TagStylesContext.js +16 -16
- package/dist/custom/index.d.ts +1 -0
- package/dist/custom/index.js +3 -2
- package/dist/editor/actor/actions.js +1 -1
- package/dist/editor/actor/machine.d.ts +4 -6
- package/dist/editor/actor/setup.d.ts +16 -2
- package/dist/editor/actor/setup.js +5 -4
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/safeContext.d.ts +156 -3
- package/dist/hooks/safeContext.js +60 -12
- package/dist/hooks/useCurrentViewModel.js +1 -1
- package/dist/hooks/useDiagram.d.ts +8 -0
- package/dist/hooks/useDiagram.js +9 -2
- package/dist/hooks/useEditorActor.js +1 -1
- package/dist/hooks/useLikeC4ElementsTree.js +1 -1
- package/dist/hooks/useLikeC4Model.js +1 -1
- package/dist/hooks/useXYFlow.d.ts +1 -0
- package/dist/hooks/useXYFlow.js +5 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/likec4diagram/DiagramUI.js +19 -6
- package/dist/likec4diagram/DiagramXYFlow.js +39 -14
- package/dist/likec4diagram/convert-to-xyflow.d.ts +3 -5
- package/dist/likec4diagram/convert-to-xyflow.js +29 -10
- package/dist/likec4diagram/custom/edges/RelationshipEdge.js +13 -4
- package/dist/likec4diagram/custom/edges/SequenceStepEdge.js +11 -4
- package/dist/likec4diagram/custom/edges/edges.css.js +1 -1
- package/dist/likec4diagram/custom/index.d.ts +2 -1
- package/dist/likec4diagram/custom/index.js +5 -3
- package/dist/likec4diagram/custom/nodes/CompoundActions.js +1 -0
- package/dist/likec4diagram/custom/nodes/ElementActions.d.ts +2 -2
- package/dist/likec4diagram/custom/nodes/ElementActions.js +13 -3
- package/dist/likec4diagram/custom/nodes/NodeNotes.js +0 -4
- package/dist/likec4diagram/custom/nodes/SequenceActorNode.js +32 -19
- package/dist/likec4diagram/custom/nodes/SequenceSubFlow.d.ts +2 -0
- package/dist/likec4diagram/custom/nodes/SequenceSubFlow.js +234 -0
- package/dist/likec4diagram/custom/nodes/index.d.ts +1 -0
- package/dist/likec4diagram/custom/nodes/nodes.js +20 -5
- package/dist/likec4diagram/custom/nodes/toolbar/ColorButton.js +1 -1
- package/dist/likec4diagram/custom/nodes/toolbar/_shared.js +1 -1
- package/dist/likec4diagram/relationship-popover/RelationshipPopover.js +15 -14
- package/dist/likec4diagram/relationship-popover/components.d.ts +1 -1
- package/dist/likec4diagram/state/DiagramActorProvider.js +11 -20
- package/dist/likec4diagram/state/aligners.js +1 -1
- package/dist/likec4diagram/state/assign.d.ts +1 -1
- package/dist/likec4diagram/state/assign.js +1 -1
- package/dist/likec4diagram/state/createViewChange.js +1 -1
- package/dist/likec4diagram/state/diagram-api.d.ts +18 -10
- package/dist/likec4diagram/state/diagram-api.js +333 -229
- package/dist/likec4diagram/state/machine.actions.d.ts +1026 -332
- package/dist/likec4diagram/state/machine.actions.js +115 -44
- package/dist/likec4diagram/state/machine.actions.layout.d.ts +123 -51
- package/dist/likec4diagram/state/machine.actions.layout.js +40 -33
- package/dist/likec4diagram/state/machine.d.ts +154 -16
- package/dist/likec4diagram/state/machine.js +5 -41
- package/dist/likec4diagram/state/machine.setup.d.ts +84 -19
- package/dist/likec4diagram/state/machine.setup.js +65 -12
- package/dist/likec4diagram/state/machine.state.initializing.d.ts +59 -33
- package/dist/likec4diagram/state/machine.state.navigating.js +7 -3
- package/dist/likec4diagram/state/machine.state.ready.d.ts +1540 -476
- package/dist/likec4diagram/state/machine.state.ready.focused.d.ts +294 -53
- package/dist/likec4diagram/state/machine.state.ready.focused.js +3 -3
- package/dist/likec4diagram/state/machine.state.ready.idle.d.ts +264 -73
- package/dist/likec4diagram/state/machine.state.ready.idle.js +31 -6
- package/dist/likec4diagram/state/machine.state.ready.js +22 -16
- package/dist/likec4diagram/state/machine.state.ready.printing.d.ts +23 -9
- package/dist/likec4diagram/state/machine.state.ready.walkthrough.d.ts +288 -84
- package/dist/likec4diagram/state/machine.state.ready.walkthrough.js +135 -66
- package/dist/likec4diagram/state/types.d.ts +4 -2
- package/dist/likec4diagram/state/utils.d.ts +7 -0
- package/dist/likec4diagram/state/utils.js +36 -34
- package/dist/likec4diagram/types.d.ts +47 -3
- package/dist/likec4diagram/ui/FloatingSequenceActors.d.ts +6 -0
- package/dist/likec4diagram/ui/FloatingSequenceActors.js +155 -0
- package/dist/likec4diagram/ui/LayoutDriftFrame.js +2 -2
- package/dist/likec4diagram/ui/index.d.ts +2 -0
- package/dist/likec4diagram/ui/notation/NotationPanel.css.js +5 -5
- package/dist/likec4diagram/ui/sequence-outline/SequenceOutlinePanel.d.ts +2 -0
- package/dist/likec4diagram/ui/sequence-outline/SequenceOutlinePanel.js +519 -0
- package/dist/likec4diagram/ui/sequence-outline/state.d.ts +36 -0
- package/dist/likec4diagram/ui/sequence-outline/state.js +55 -0
- package/dist/likec4diagram/xyflow-diagram/diagram-view.d.ts +1 -1
- package/dist/likec4diagram/xyflow-diagram/diagram-view.js +112 -60
- package/dist/likec4diagram/xyflow-sequence/_types.d.ts +55 -5
- package/dist/likec4diagram/xyflow-sequence/const.d.ts +5 -5
- package/dist/likec4diagram/xyflow-sequence/const.js +4 -4
- package/dist/likec4diagram/xyflow-sequence/layouter.d.ts +30 -6
- package/dist/likec4diagram/xyflow-sequence/layouter.js +561 -0
- package/dist/likec4diagram/xyflow-sequence/{sequence-layout.d.ts → sequence-view-to-xy.d.ts} +8 -2
- package/dist/likec4diagram/xyflow-sequence/{sequence-layout.js → sequence-view-to-xy.js} +111 -14
- package/dist/likec4diagram/xyflow-sequence/sequence-view.d.ts +2 -7
- package/dist/likec4diagram/xyflow-sequence/sequence-view.js +144 -0
- package/dist/likec4diagram/xyflow-sequence/utils.d.ts +9 -1
- package/dist/likec4diagram/xyflow-sequence/utils.js +96 -0
- package/dist/navigationpanel/NavigationPanel.d.ts +5 -2
- package/dist/navigationpanel/NavigationPanel.js +58 -59
- package/dist/navigationpanel/NavigationPanelDropdown.js +45 -38
- package/dist/navigationpanel/_common.js +2 -2
- package/dist/navigationpanel/actor.actions.d.ts +19 -0
- package/dist/navigationpanel/actor.actions.js +45 -0
- package/dist/navigationpanel/actor.d.ts +34 -96
- package/dist/navigationpanel/actor.js +21 -84
- package/dist/navigationpanel/actor.setup.d.ts +98 -0
- package/dist/navigationpanel/actor.setup.js +31 -0
- package/dist/navigationpanel/comparepanel/DriftsSummary.js +4 -5
- package/dist/navigationpanel/controls/DetailsControls.js +7 -8
- package/dist/navigationpanel/dropdown/ProjectsMenu.js +1 -1
- package/dist/navigationpanel/editorpanel/styles.js +8 -8
- package/dist/navigationpanel/hooks.d.ts +20 -5
- package/dist/navigationpanel/hooks.js +4 -18
- package/dist/navigationpanel/styles.css.d.ts +1 -1
- package/dist/navigationpanel/walkthrough/ActiveWalkthroughControls.js +2 -2
- package/dist/navigationpanel/walkthrough/DynamicViewControls.d.ts +4 -4
- package/dist/navigationpanel/walkthrough/DynamicViewControls.js +23 -25
- package/dist/navigationpanel/walkthrough/WalkthroughPanel.js +5 -5
- package/dist/overlays/Overlays.d.ts +4 -2
- package/dist/overlays/Overlays.js +10 -10
- package/dist/overlays/element-details/ElementDetailsCard.css.js +17 -17
- package/dist/overlays/element-details/MetadataValue.js +15 -15
- package/dist/overlays/element-details/TabPanelDeployments.css.js +5 -5
- package/dist/overlays/element-details/TabPanelRelationships.css.js +11 -11
- package/dist/overlays/element-details/TabPanelRelationships.js +1 -1
- package/dist/overlays/element-details/TabPanelStructure.css.js +2 -2
- package/dist/overlays/element-details/TabPanelStructure.js +1 -1
- package/dist/overlays/element-details/actor.d.ts +2 -3
- package/dist/overlays/hooks.d.ts +28 -0
- package/dist/overlays/hooks.js +5 -0
- package/dist/overlays/overlay/Overlay.js +34 -25
- package/dist/overlays/overlaysActor.js +0 -1
- package/dist/overlays/relationship-details/custom/nodeTypes.js +1 -1
- package/dist/overlays/relationship-details/layout.js +1 -1
- package/dist/overlays/relationships-browser/SelectElement.css.js +2 -2
- package/dist/overlays/relationships-browser/actor.js +79 -78
- package/dist/overlays/relationships-browser/custom/nodeTypes.js +1 -1
- package/dist/overlays/relationships-browser/hooks.js +1 -1
- package/dist/overlays/relationships-browser/layout.js +2 -2
- package/dist/projects-overview/actor.js +4 -4
- package/dist/search/Search.js +1 -1
- package/dist/search/components/ElementsColumn.css.js +2 -2
- package/dist/search/components/ViewsColum.js +1 -1
- package/dist/search/components/_shared.css.d.ts +1 -1
- package/dist/search/components/_shared.css.js +23 -23
- package/dist/search/components/styles.css.js +4 -4
- package/dist/shadowroot/ShadowRoot.d.ts +1 -1
- package/dist/shadowroot/ShadowRoot.js +76 -28
- package/dist/styles2.js +1 -1
- package/dist/utils/defineActors.d.ts +21 -0
- package/dist/utils/defineActors.js +13 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +5 -4
- package/dist/utils/readableText.d.ts +11 -0
- package/dist/utils/readableText.js +18 -0
- package/package.json +18 -30
- package/panda.buildinfo.json +267 -288
- package/styles-min.css +1 -1
- package/styles.css +1 -1
- package/adhoc-editor/package.json +0 -4
- package/dist/adhoc-editor/EditorPanel.d.ts +0 -1
- package/dist/adhoc-editor/EditorPanel.js +0 -106
- package/dist/adhoc-editor/ElementsTree.d.ts +0 -2
- package/dist/adhoc-editor/ElementsTree.js +0 -112
- package/dist/adhoc-editor/LikeC4AdHocViewEditor.d.ts +0 -4
- package/dist/adhoc-editor/LikeC4AdHocViewEditor.js +0 -83
- package/dist/adhoc-editor/components/Tree.d.ts +0 -48
- package/dist/adhoc-editor/components/Tree.js +0 -213
- package/dist/adhoc-editor/hooks.d.ts +0 -14
- package/dist/adhoc-editor/hooks.js +0 -34
- package/dist/adhoc-editor/index.d.ts +0 -2
- package/dist/adhoc-editor/index.js +0 -2
- package/dist/adhoc-editor/state/ActorProvider.d.ts +0 -5
- package/dist/adhoc-editor/state/ActorProvider.js +0 -37
- package/dist/adhoc-editor/state/actor.d.ts +0 -13
- package/dist/adhoc-editor/state/actor.editor.d.ts +0 -56
- package/dist/adhoc-editor/state/actor.editor.js +0 -167
- package/dist/adhoc-editor/state/actor.js +0 -14
- package/dist/adhoc-editor/state/actor.layouter.d.ts +0 -51
- package/dist/adhoc-editor/state/actor.layouter.js +0 -54
- package/dist/adhoc-editor/state/actor.types.d.ts +0 -63
- package/dist/adhoc-editor/state/actor.types.js +0 -25
- package/dist/adhoc-editor/state/panel.d.ts +0 -95
- package/dist/adhoc-editor/state/panel.js +0 -124
- package/dist/adhoc-editor/state/utils.d.ts +0 -17
- package/dist/adhoc-editor/state/utils.js +0 -25
- package/dist/adhoc-editor/useElementsTree.d.ts +0 -18
- package/dist/adhoc-editor/useElementsTree.js +0 -98
- package/dist/adhoc-editor/viewrules/ViewRulesPanel.d.ts +0 -6
- package/dist/context/ShadowRootContext.d.ts +0 -3
- package/dist/context/ShadowRootContext.js +0 -5
- package/dist/shadowroot/styles.d.ts +0 -13
- package/dist/shadowroot/styles.js +0 -60
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
import "../../_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { MinZoom } from "../../base/const.js";
|
|
3
3
|
import { calcEdgeBounds } from "../../utils/view-bounds.js";
|
|
4
|
-
import { activeSequenceBounds, focusedBounds, viewBounds } from "./utils.js";
|
|
5
|
-
import { machine } from "./machine.setup.js";
|
|
4
|
+
import { activeSequenceBounds, focusedBounds, getEdgeBounds, viewBounds } from "./utils.js";
|
|
5
|
+
import { isActiveSequenceWalkthrough, machine } from "./machine.setup.js";
|
|
6
6
|
import { getNodesBounds, getViewportForBounds } from "@xyflow/react";
|
|
7
7
|
import { BBox, invariant, isNonEmptyArray, nonNullable } from "@likec4/core";
|
|
8
8
|
import { assertEvent } from "xstate";
|
|
9
9
|
//#region src/likec4diagram/state/machine.actions.layout.ts
|
|
10
|
+
var calcMaxZoom = (context, transform = [
|
|
11
|
+
0,
|
|
12
|
+
0,
|
|
13
|
+
1
|
|
14
|
+
]) => {
|
|
15
|
+
const [, , zoom] = transform;
|
|
16
|
+
if (isActiveSequenceWalkthrough(context)) return Math.max(zoom, 1.4);
|
|
17
|
+
return Math.max(zoom, 1);
|
|
18
|
+
};
|
|
10
19
|
var setViewport = (params) => machine.createAction(({ context, event }) => {
|
|
11
20
|
let viewport;
|
|
12
21
|
let duration;
|
|
@@ -49,18 +58,16 @@ var centerOnNodeOrEdge = () => machine.raise(({ context, event }) => {
|
|
|
49
58
|
if ("edgeId" in event) {
|
|
50
59
|
const edge = xystate.edgeLookup.get(event.edgeId);
|
|
51
60
|
if (!edge) return { type: "noop" };
|
|
52
|
-
|
|
53
|
-
const targetNode = xystate.nodeLookup.get(edge.target);
|
|
54
|
-
if (!sourceNode || !targetNode) return { type: "noop" };
|
|
55
|
-
const bounds = getNodesBounds([sourceNode, targetNode], xystate);
|
|
56
|
-
const edgeBounds = calcEdgeBounds({
|
|
61
|
+
let bounds = calcEdgeBounds({
|
|
57
62
|
points: edge.data.points,
|
|
58
63
|
controlPoints: edge.data.controlPoints && isNonEmptyArray(edge.data.controlPoints) ? edge.data.controlPoints : null,
|
|
59
64
|
labelBBox: edge.data.labelBBox ?? null
|
|
60
65
|
});
|
|
66
|
+
const edgeBounds = getEdgeBounds(edge, xystate);
|
|
67
|
+
if (edgeBounds) bounds = BBox.merge(bounds, edgeBounds);
|
|
61
68
|
return {
|
|
62
69
|
type: "xyflow.fitDiagram",
|
|
63
|
-
bounds
|
|
70
|
+
bounds
|
|
64
71
|
};
|
|
65
72
|
}
|
|
66
73
|
const node = xystate.nodeLookup.get(event.nodeId);
|
|
@@ -70,6 +77,26 @@ var centerOnNodeOrEdge = () => machine.raise(({ context, event }) => {
|
|
|
70
77
|
bounds: getNodesBounds([node], xystate)
|
|
71
78
|
};
|
|
72
79
|
});
|
|
80
|
+
function fitBoundsInViewport(context, bounds, duration) {
|
|
81
|
+
let { width, height, panZoom, transform } = nonNullable(context.xystore).getState();
|
|
82
|
+
let left = void 0;
|
|
83
|
+
if (isActiveSequenceWalkthrough(context)) {
|
|
84
|
+
left = context.activeWalkthrough.outlinePanelWidth;
|
|
85
|
+
width -= left;
|
|
86
|
+
}
|
|
87
|
+
const maxZoom = calcMaxZoom(context, transform);
|
|
88
|
+
const viewport = getViewportForBounds(bounds, width, height, MinZoom, maxZoom, context.fitViewPadding);
|
|
89
|
+
viewport.x = Math.round(viewport.x);
|
|
90
|
+
viewport.y = Math.round(viewport.y);
|
|
91
|
+
if (left !== void 0) viewport.x += left;
|
|
92
|
+
const animationProps = duration > 0 ? {
|
|
93
|
+
duration,
|
|
94
|
+
interpolate: "smooth"
|
|
95
|
+
} : void 0;
|
|
96
|
+
panZoom?.setViewport(viewport, animationProps).catch((err) => {
|
|
97
|
+
console.error("Error during fitDiagram panZoom setViewport", { err });
|
|
98
|
+
});
|
|
99
|
+
}
|
|
73
100
|
var fitDiagram = (params) => machine.createAction(({ context, event }) => {
|
|
74
101
|
let bounds;
|
|
75
102
|
let duration;
|
|
@@ -82,32 +109,12 @@ var fitDiagram = (params) => machine.createAction(({ context, event }) => {
|
|
|
82
109
|
}
|
|
83
110
|
bounds ??= viewBounds(context);
|
|
84
111
|
duration ??= 450;
|
|
85
|
-
|
|
86
|
-
const maxZoom = Math.max(1, transform[2]);
|
|
87
|
-
const viewport = getViewportForBounds(bounds, width, height, MinZoom, maxZoom, context.fitViewPadding);
|
|
88
|
-
viewport.x = Math.round(viewport.x);
|
|
89
|
-
viewport.y = Math.round(viewport.y);
|
|
90
|
-
const animationProps = duration > 0 ? {
|
|
91
|
-
duration,
|
|
92
|
-
interpolate: "smooth"
|
|
93
|
-
} : void 0;
|
|
94
|
-
panZoom?.setViewport(viewport, animationProps).catch((err) => {
|
|
95
|
-
console.error("Error during fitDiagram panZoom setViewport", { err });
|
|
96
|
-
});
|
|
112
|
+
fitBoundsInViewport(context, bounds, duration);
|
|
97
113
|
});
|
|
98
|
-
var fitFocusedBounds = () => machine.createAction(({ context }) => {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
viewport.x = Math.round(viewport.x);
|
|
103
|
-
viewport.y = Math.round(viewport.y);
|
|
104
|
-
const animationProps = duration > 0 ? {
|
|
105
|
-
duration,
|
|
106
|
-
interpolate: "smooth"
|
|
107
|
-
} : void 0;
|
|
108
|
-
panZoom?.setViewport(viewport, animationProps).catch((err) => {
|
|
109
|
-
console.error("Error during fitFocusedBounds panZoom setViewport", { err });
|
|
110
|
-
});
|
|
114
|
+
var fitFocusedBounds = (params) => machine.createAction(({ context }) => {
|
|
115
|
+
let { bounds, duration = 450 } = !!context.activeWalkthrough ? activeSequenceBounds({ context }) : focusedBounds({ context });
|
|
116
|
+
duration = params?.duration ?? duration;
|
|
117
|
+
fitBoundsInViewport(context, bounds, duration);
|
|
111
118
|
});
|
|
112
119
|
var DEFAULT_DELAY = 30;
|
|
113
120
|
var raiseSetViewport = (params) => {
|
|
@@ -1,23 +1,161 @@
|
|
|
1
|
-
import { ActorRef,
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { ActorRef, SnapshotFrom, StateValueFrom, StateMachine, ActorRefFromLogic, NonReducibleUnknown, MetaObject } from 'xstate';
|
|
2
|
+
import { BaseEditorActorRef } from '../../editor/actor/setup';
|
|
3
|
+
import { NavigationPanelActorRef, NavigationPanelActorLogic } from '../../navigationpanel/actor';
|
|
4
|
+
import { OverlaysActorRef, OverlaysActorLogic } from '../../overlays/overlaysActor';
|
|
5
|
+
import { SearchActorRef, SearchActorLogic } from '../../search/searchActor';
|
|
6
|
+
import { BaseDiagramMachineLogic, EmittedEvents as DiagramEmittedEvents, Events as DiagramEvents, Context as DiagramContext, Input } from './machine.setup';
|
|
7
|
+
import { HotkeyActorLogic } from './hotkeyActor';
|
|
8
|
+
import { MediaPrintActorLogic } from './mediaPrintActor';
|
|
9
|
+
import { EditorActorLogic } from '../../editor';
|
|
10
|
+
declare const _diagramMachine: StateMachine<DiagramContext, DiagramEvents, {
|
|
11
|
+
search?: ActorRefFromLogic<SearchActorLogic>;
|
|
12
|
+
hotkey?: ActorRefFromLogic<HotkeyActorLogic>;
|
|
13
|
+
overlays?: ActorRefFromLogic<OverlaysActorLogic>;
|
|
14
|
+
mediaPrint?: ActorRefFromLogic<MediaPrintActorLogic>;
|
|
15
|
+
editor?: ActorRefFromLogic<EditorActorLogic>;
|
|
16
|
+
navigationPanel?: ActorRefFromLogic<NavigationPanelActorLogic>;
|
|
17
|
+
}, {
|
|
18
|
+
src: "search";
|
|
19
|
+
logic: SearchActorLogic;
|
|
20
|
+
id: "search";
|
|
21
|
+
} | {
|
|
22
|
+
src: "hotkey";
|
|
23
|
+
logic: HotkeyActorLogic;
|
|
24
|
+
id: "hotkey";
|
|
25
|
+
} | {
|
|
26
|
+
src: "overlays";
|
|
27
|
+
logic: OverlaysActorLogic;
|
|
28
|
+
id: "overlays";
|
|
29
|
+
} | {
|
|
30
|
+
src: "mediaPrint";
|
|
31
|
+
logic: MediaPrintActorLogic;
|
|
32
|
+
id: "mediaPrint";
|
|
33
|
+
} | {
|
|
34
|
+
src: "editor";
|
|
35
|
+
logic: EditorActorLogic;
|
|
36
|
+
id: "editor";
|
|
37
|
+
} | {
|
|
38
|
+
src: "navigationPanel";
|
|
39
|
+
logic: NavigationPanelActorLogic;
|
|
40
|
+
id: "navigationPanel";
|
|
41
|
+
}, never, {
|
|
42
|
+
type: "isReady";
|
|
43
|
+
params: unknown;
|
|
44
|
+
} | {
|
|
45
|
+
type: "enabled: Editor";
|
|
46
|
+
params: unknown;
|
|
47
|
+
} | {
|
|
48
|
+
type: "enabled: FitView";
|
|
49
|
+
params: unknown;
|
|
50
|
+
} | {
|
|
51
|
+
type: "enabled: FocusMode";
|
|
52
|
+
params: unknown;
|
|
53
|
+
} | {
|
|
54
|
+
type: "enabled: Readonly";
|
|
55
|
+
params: unknown;
|
|
56
|
+
} | {
|
|
57
|
+
type: "enabled: RelationshipDetails";
|
|
58
|
+
params: unknown;
|
|
59
|
+
} | {
|
|
60
|
+
type: "enabled: Search";
|
|
61
|
+
params: unknown;
|
|
62
|
+
} | {
|
|
63
|
+
type: "enabled: ElementDetails";
|
|
64
|
+
params: unknown;
|
|
65
|
+
} | {
|
|
66
|
+
type: "enabled: OpenSource";
|
|
67
|
+
params: unknown;
|
|
68
|
+
} | {
|
|
69
|
+
type: "enabled: DynamicViewWalkthrough";
|
|
70
|
+
params: unknown;
|
|
71
|
+
} | {
|
|
72
|
+
type: "enabled: NavigationPanel";
|
|
73
|
+
params: unknown;
|
|
74
|
+
} | {
|
|
75
|
+
type: "focus.node: autoUnfocus";
|
|
76
|
+
params: unknown;
|
|
77
|
+
} | {
|
|
78
|
+
type: "enabled: Overlays";
|
|
79
|
+
params: unknown;
|
|
80
|
+
} | {
|
|
81
|
+
type: "not readonly";
|
|
82
|
+
params: unknown;
|
|
83
|
+
} | {
|
|
84
|
+
type: "is dynamic view";
|
|
85
|
+
params: unknown;
|
|
86
|
+
} | {
|
|
87
|
+
type: "is dynamic view in sequence variant";
|
|
88
|
+
params: unknown;
|
|
89
|
+
} | {
|
|
90
|
+
type: "is same view";
|
|
91
|
+
params: unknown;
|
|
92
|
+
} | {
|
|
93
|
+
type: "is another view";
|
|
94
|
+
params: unknown;
|
|
95
|
+
} | {
|
|
96
|
+
type: "click: node has modelFqn";
|
|
97
|
+
params: unknown;
|
|
98
|
+
} | {
|
|
99
|
+
type: "click: selected node";
|
|
100
|
+
params: unknown;
|
|
101
|
+
} | {
|
|
102
|
+
type: "click: same node";
|
|
103
|
+
params: unknown;
|
|
104
|
+
} | {
|
|
105
|
+
type: "click: focused node";
|
|
106
|
+
params: unknown;
|
|
107
|
+
} | {
|
|
108
|
+
type: "click: node.type = seq-subflow";
|
|
109
|
+
params: unknown;
|
|
110
|
+
} | {
|
|
111
|
+
type: "click: node has connections";
|
|
112
|
+
params: unknown;
|
|
113
|
+
} | {
|
|
114
|
+
type: "click: selected edge";
|
|
115
|
+
params: unknown;
|
|
116
|
+
} | {
|
|
117
|
+
type: "click: active walkthrough step";
|
|
118
|
+
params: unknown;
|
|
119
|
+
}, never, "final" | "isReady" | "navigating" | "initializing" | {
|
|
120
|
+
ready: "idle" | "walkthrough" | "focused" | "printing";
|
|
121
|
+
}, string, Input, NonReducibleUnknown, DiagramEmittedEvents, MetaObject, {
|
|
122
|
+
states: {
|
|
123
|
+
readonly initializing: {};
|
|
124
|
+
readonly isReady: {};
|
|
125
|
+
readonly ready: {
|
|
126
|
+
states: {
|
|
127
|
+
idle: {
|
|
128
|
+
id: string;
|
|
129
|
+
};
|
|
130
|
+
focused: {
|
|
131
|
+
id: string;
|
|
132
|
+
};
|
|
133
|
+
walkthrough: {
|
|
134
|
+
id: string;
|
|
135
|
+
};
|
|
136
|
+
printing: {
|
|
137
|
+
id: string;
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
readonly navigating: {
|
|
142
|
+
id: string;
|
|
143
|
+
};
|
|
144
|
+
readonly final: {};
|
|
145
|
+
};
|
|
146
|
+
}>;
|
|
147
|
+
export interface DiagramMachineLogic extends BaseDiagramMachineLogic<{
|
|
10
148
|
overlays: OverlaysActorRef | undefined;
|
|
11
149
|
search: SearchActorRef | undefined;
|
|
12
|
-
editor:
|
|
13
|
-
|
|
150
|
+
editor: BaseEditorActorRef | undefined;
|
|
151
|
+
navigationPanel: NavigationPanelActorRef | undefined;
|
|
152
|
+
}, StateValueFrom<typeof _diagramMachine>> {
|
|
14
153
|
}
|
|
154
|
+
/**
|
|
155
|
+
* Here is a trick to reduce inference types
|
|
156
|
+
*/
|
|
15
157
|
export declare const diagramMachine: DiagramMachineLogic;
|
|
16
|
-
export type DiagramMachineSnapshot =
|
|
17
|
-
overlays: OverlaysActorRef | undefined;
|
|
18
|
-
search: SearchActorRef | undefined;
|
|
19
|
-
editor: EditorActorRef | undefined;
|
|
20
|
-
}, any, any, any, {}, {}>;
|
|
158
|
+
export type DiagramMachineSnapshot = SnapshotFrom<DiagramMachineLogic>;
|
|
21
159
|
export interface DiagramMachineRef extends ActorRef<DiagramMachineSnapshot, DiagramEvents, DiagramEmittedEvents> {
|
|
22
160
|
}
|
|
23
161
|
export type { DiagramContext, DiagramEmittedEvents, DiagramEvents, };
|
|
@@ -1,55 +1,19 @@
|
|
|
1
1
|
import "../../_virtual/_rolldown/runtime.js";
|
|
2
|
-
import {
|
|
3
|
-
import { machine } from "./machine.setup.js";
|
|
2
|
+
import { Context, machine } from "./machine.setup.js";
|
|
4
3
|
import { updateEdgeData, updateNodeData } from "./assign.js";
|
|
5
4
|
import { cancelFitDiagram, raiseUpdateView } from "./machine.actions.layout.js";
|
|
6
5
|
import { assignDynamicViewVariant, emitOnLayoutTypeChange, stopEditorActor, triggerChange, updateFeatures, updateInputs } from "./machine.actions.js";
|
|
7
6
|
import { initializing, isReady } from "./machine.state.initializing.js";
|
|
8
7
|
import { navigating } from "./machine.state.navigating.js";
|
|
9
8
|
import { ready } from "./machine.state.ready.js";
|
|
10
|
-
import { DiagramToggledFeaturesPersistence } from "./persistence.js";
|
|
11
9
|
import { applyEdgeChanges, applyNodeChanges } from "@xyflow/react";
|
|
12
10
|
import { assign, stopChild } from "xstate/actions";
|
|
11
|
+
/**
|
|
12
|
+
* Here is a trick to reduce inference types
|
|
13
|
+
*/
|
|
13
14
|
var diagramMachine = machine.createMachine({
|
|
14
15
|
initial: "initializing",
|
|
15
|
-
context:
|
|
16
|
-
...input,
|
|
17
|
-
xyedges: [],
|
|
18
|
-
xynodes: [],
|
|
19
|
-
features: {
|
|
20
|
-
...DefaultFeatures,
|
|
21
|
-
...input.features
|
|
22
|
-
},
|
|
23
|
-
toggledFeatures: DiagramToggledFeaturesPersistence.read() ?? {
|
|
24
|
-
enableReadOnly: true,
|
|
25
|
-
enableCompareWithLatest: false
|
|
26
|
-
},
|
|
27
|
-
initialized: {
|
|
28
|
-
xydata: false,
|
|
29
|
-
xyflow: false
|
|
30
|
-
},
|
|
31
|
-
viewportChangedManually: false,
|
|
32
|
-
lastOnNavigate: null,
|
|
33
|
-
lastClickedNode: null,
|
|
34
|
-
focusedNode: null,
|
|
35
|
-
autoUnfocusTimer: false,
|
|
36
|
-
activeElementDetails: null,
|
|
37
|
-
viewportBefore: null,
|
|
38
|
-
viewportOnManualLayout: null,
|
|
39
|
-
viewportOnAutoLayout: null,
|
|
40
|
-
navigationHistory: {
|
|
41
|
-
currentIndex: 0,
|
|
42
|
-
history: []
|
|
43
|
-
},
|
|
44
|
-
viewport: {
|
|
45
|
-
x: 0,
|
|
46
|
-
y: 0,
|
|
47
|
-
zoom: 1
|
|
48
|
-
},
|
|
49
|
-
xyflow: null,
|
|
50
|
-
dynamicViewVariant: input.dynamicViewVariant ?? (input.view._type === "dynamic" ? input.view.variant : "diagram") ?? "diagram",
|
|
51
|
-
activeWalkthrough: null
|
|
52
|
-
}),
|
|
16
|
+
context: Context,
|
|
53
17
|
states: {
|
|
54
18
|
initializing,
|
|
55
19
|
isReady,
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { BBox } from '@likec4/core/geometry';
|
|
2
|
-
import { DiagramEdge, DiagramNode, DiagramView, DynamicViewDisplayVariant, EdgeId, Fqn, LayoutType, NodeId, NodeNotation as ElementNotation,
|
|
2
|
+
import { DiagramEdge, DiagramNode, DiagramView, DynamicViewDisplayVariant, EdgeId, Fqn, LayoutedDynamicView, LayoutType, NodeId, NodeNotation as ElementNotation, StepPath, ViewChange, ViewId, WhereOperator } from '@likec4/core/types';
|
|
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 { ActorRefFromLogic, StateMachine, StateValue, SetupReturn, NonReducibleUnknown, MetaObject } from 'xstate';
|
|
6
7
|
import { EnabledFeatures, TogglableFeature } from '../../context/DiagramFeatures';
|
|
7
8
|
import { XYFlowInstance, XYStoreApi } from '../../hooks/useXYFlow';
|
|
8
9
|
import { OpenSourceParams, ViewPaddings } from '../../LikeC4Diagram.props';
|
|
@@ -10,10 +11,10 @@ import { Types } from '../types';
|
|
|
10
11
|
import { AlignmentMode } from './aligners';
|
|
11
12
|
import { HotKeyEvent, HotkeyActorLogic } from './hotkeyActor';
|
|
12
13
|
import { MediaPrintEvent, MediaPrintActorLogic } from './mediaPrintActor';
|
|
13
|
-
import { SetupReturn, NonReducibleUnknown, MetaObject } from 'xstate';
|
|
14
14
|
import { OverlaysActorLogic } from '../../overlays/overlaysActor';
|
|
15
15
|
import { SearchActorLogic } from '../../search/searchActor';
|
|
16
16
|
import { EditorActorLogic } from '../../editor';
|
|
17
|
+
import { NavigationPanelActorLogic } from '../../navigationpanel/actor';
|
|
17
18
|
/**
|
|
18
19
|
* Navigation history entry represents a current view state,
|
|
19
20
|
* including viewport, focused node, dynamic view variant, etc.
|
|
@@ -28,7 +29,7 @@ export interface NavigationHistoryEntry {
|
|
|
28
29
|
};
|
|
29
30
|
focusedNode?: NodeId | null;
|
|
30
31
|
dynamicViewVariant?: DynamicViewDisplayVariant | null;
|
|
31
|
-
activeWalkthrough?: null |
|
|
32
|
+
activeWalkthrough?: null | StepPath;
|
|
32
33
|
}
|
|
33
34
|
export interface NavigationHistory {
|
|
34
35
|
history: ReadonlyArray<NavigationHistoryEntry>;
|
|
@@ -92,10 +93,17 @@ export interface Context extends Input {
|
|
|
92
93
|
xyflow: XYFlowInstance | null;
|
|
93
94
|
dynamicViewVariant: DynamicViewDisplayVariant;
|
|
94
95
|
activeWalkthrough: null | {
|
|
95
|
-
stepId:
|
|
96
|
-
|
|
96
|
+
stepId: StepPath;
|
|
97
|
+
activeFlow: StepPath | null;
|
|
98
|
+
outlinePanelWidth: number;
|
|
99
|
+
};
|
|
100
|
+
collapsedSequenceFlows: {
|
|
101
|
+
[flowId: StepPath]: boolean;
|
|
97
102
|
};
|
|
98
103
|
}
|
|
104
|
+
export declare function Context({ input }: {
|
|
105
|
+
input: Input;
|
|
106
|
+
}): Context;
|
|
99
107
|
export type Events = HotKeyEvent | MediaPrintEvent | {
|
|
100
108
|
type: 'xyflow.init';
|
|
101
109
|
instance: XYFlowInstance;
|
|
@@ -124,10 +132,10 @@ export type Events = HotKeyEvent | MediaPrintEvent | {
|
|
|
124
132
|
type: 'xyflow.resized';
|
|
125
133
|
} | {
|
|
126
134
|
type: 'xyflow.nodeMouseEnter';
|
|
127
|
-
node: Types.Node;
|
|
135
|
+
node: Types.Node | NodeId;
|
|
128
136
|
} | {
|
|
129
137
|
type: 'xyflow.nodeMouseLeave';
|
|
130
|
-
node: Types.Node;
|
|
138
|
+
node: Types.Node | NodeId;
|
|
131
139
|
} | {
|
|
132
140
|
type: 'xyflow.edgeMouseEnter';
|
|
133
141
|
edge: Types.Edge;
|
|
@@ -152,6 +160,8 @@ export type Events = HotKeyEvent | MediaPrintEvent | {
|
|
|
152
160
|
type: 'xyflow.centerViewport';
|
|
153
161
|
edgeId: EdgeId;
|
|
154
162
|
duration?: number;
|
|
163
|
+
} | {
|
|
164
|
+
type: 'xyflow.resetSelection';
|
|
155
165
|
} | {
|
|
156
166
|
type: 'update.nodeData';
|
|
157
167
|
nodeId: NodeId;
|
|
@@ -226,12 +236,28 @@ export type Events = HotKeyEvent | MediaPrintEvent | {
|
|
|
226
236
|
variant: DynamicViewDisplayVariant;
|
|
227
237
|
} | {
|
|
228
238
|
type: 'walkthrough.start';
|
|
229
|
-
stepId?:
|
|
239
|
+
stepId?: StepPath | undefined;
|
|
230
240
|
} | {
|
|
231
241
|
type: 'walkthrough.step';
|
|
232
|
-
direction: 'next' | '
|
|
242
|
+
direction: 'next' | 'prev';
|
|
243
|
+
stepId?: never;
|
|
244
|
+
} | {
|
|
245
|
+
type: 'walkthrough.step';
|
|
246
|
+
stepId: StepPath;
|
|
247
|
+
direction?: never;
|
|
233
248
|
} | {
|
|
234
249
|
type: 'walkthrough.end';
|
|
250
|
+
} | {
|
|
251
|
+
type: 'sequence.flow.collapse';
|
|
252
|
+
flowId: StepPath;
|
|
253
|
+
} | {
|
|
254
|
+
type: 'sequence.flow.expand';
|
|
255
|
+
flowId: StepPath;
|
|
256
|
+
} | {
|
|
257
|
+
type: 'sequence.flow.toggle';
|
|
258
|
+
flowId: StepPath;
|
|
259
|
+
} | {
|
|
260
|
+
type: 'sequence.walkthrough.end';
|
|
235
261
|
} | {
|
|
236
262
|
type: 'highlight.node';
|
|
237
263
|
nodeId: NodeId;
|
|
@@ -297,6 +323,7 @@ export type EmittedEvents = {
|
|
|
297
323
|
} | {
|
|
298
324
|
type: 'walkthroughStep';
|
|
299
325
|
edge: Types.Edge;
|
|
326
|
+
stepId: StepPath;
|
|
300
327
|
} | {
|
|
301
328
|
type: 'walkthroughStopped';
|
|
302
329
|
} | {
|
|
@@ -308,18 +335,35 @@ export type ActionArg = {
|
|
|
308
335
|
event: Events;
|
|
309
336
|
};
|
|
310
337
|
export declare const deriveToggledFeatures: (context: Context) => Required<ToggledFeatures>;
|
|
338
|
+
export declare function isActiveSequenceWalkthrough(context: Context): context is Context & {
|
|
339
|
+
view: LayoutedDynamicView & {
|
|
340
|
+
flow: NonNullable<LayoutedDynamicView['flow']>;
|
|
341
|
+
};
|
|
342
|
+
dynamicViewVariant: 'sequence';
|
|
343
|
+
activeWalkthrough: NonNullable<Context['activeWalkthrough']>;
|
|
344
|
+
};
|
|
345
|
+
declare const actors: {
|
|
346
|
+
hotkey: HotkeyActorLogic;
|
|
347
|
+
overlays: OverlaysActorLogic;
|
|
348
|
+
search: SearchActorLogic;
|
|
349
|
+
mediaPrint: MediaPrintActorLogic;
|
|
350
|
+
editor: EditorActorLogic;
|
|
351
|
+
navigationPanel: NavigationPanelActorLogic;
|
|
352
|
+
};
|
|
311
353
|
export declare const machine: SetupReturn<Context, Events, {
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
354
|
+
hotkey: HotkeyActorLogic;
|
|
355
|
+
overlays: OverlaysActorLogic;
|
|
356
|
+
search: SearchActorLogic;
|
|
357
|
+
mediaPrint: MediaPrintActorLogic;
|
|
358
|
+
editor: EditorActorLogic;
|
|
359
|
+
navigationPanel: NavigationPanelActorLogic;
|
|
317
360
|
}, {
|
|
318
|
-
hotkey: "
|
|
319
|
-
overlays: "
|
|
320
|
-
search: "
|
|
321
|
-
mediaPrint: "
|
|
322
|
-
editor: "
|
|
361
|
+
hotkey: "hotkey";
|
|
362
|
+
overlays: "overlays";
|
|
363
|
+
search: "search";
|
|
364
|
+
mediaPrint: "mediaPrint";
|
|
365
|
+
editor: "editor";
|
|
366
|
+
navigationPanel: "navigationPanel";
|
|
323
367
|
}, {}, {
|
|
324
368
|
isReady: unknown;
|
|
325
369
|
'enabled: Editor': unknown;
|
|
@@ -331,20 +375,40 @@ export declare const machine: SetupReturn<Context, Events, {
|
|
|
331
375
|
'enabled: ElementDetails': unknown;
|
|
332
376
|
'enabled: OpenSource': unknown;
|
|
333
377
|
'enabled: DynamicViewWalkthrough': unknown;
|
|
378
|
+
'enabled: NavigationPanel': unknown;
|
|
334
379
|
'focus.node: autoUnfocus': unknown;
|
|
335
380
|
'enabled: Overlays': unknown;
|
|
336
381
|
'not readonly': unknown;
|
|
337
382
|
'is dynamic view': unknown;
|
|
383
|
+
'is dynamic view in sequence variant': unknown;
|
|
338
384
|
'is same view': unknown;
|
|
339
385
|
'is another view': unknown;
|
|
340
386
|
'click: node has modelFqn': unknown;
|
|
341
387
|
'click: selected node': unknown;
|
|
342
388
|
'click: same node': unknown;
|
|
343
389
|
'click: focused node': unknown;
|
|
390
|
+
'click: node.type = seq-subflow': unknown;
|
|
344
391
|
'click: node has connections': unknown;
|
|
345
392
|
'click: selected edge': unknown;
|
|
346
393
|
'click: active walkthrough step': unknown;
|
|
347
394
|
}, never, string, Input, NonReducibleUnknown, EmittedEvents, MetaObject>;
|
|
395
|
+
type ChildrenActors = typeof actors;
|
|
396
|
+
type ActorLogicMap = {
|
|
397
|
+
[K in keyof ChildrenActors]: ActorRefFromLogic<ChildrenActors[K]> | undefined;
|
|
398
|
+
};
|
|
399
|
+
type ChildrenActor = {
|
|
400
|
+
[K in keyof ChildrenActors]: {
|
|
401
|
+
id: K;
|
|
402
|
+
logic: ChildrenActors[K];
|
|
403
|
+
src: K;
|
|
404
|
+
};
|
|
405
|
+
}[keyof ChildrenActors];
|
|
406
|
+
/**
|
|
407
|
+
* Here is a trick to reduce inference types
|
|
408
|
+
*/
|
|
409
|
+
export interface BaseDiagramMachineLogic<Actors extends Partial<ActorLogicMap> = ActorLogicMap, State extends StateValue = never> extends StateMachine<Context, Events, Actors & Omit<ActorLogicMap, keyof Actors>, ChildrenActor, never, never, never, State, never, Input, never, EmittedEvents, never, never> {
|
|
410
|
+
}
|
|
411
|
+
export type BaseDiagramActorRef = ActorRefFromLogic<BaseDiagramMachineLogic>;
|
|
348
412
|
export declare const targetState: {
|
|
349
413
|
idle: string;
|
|
350
414
|
focused: string;
|
|
@@ -369,3 +433,4 @@ export declare const to: {
|
|
|
369
433
|
target: string;
|
|
370
434
|
};
|
|
371
435
|
};
|
|
436
|
+
export {};
|
|
@@ -1,14 +1,59 @@
|
|
|
1
1
|
import "../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { DefaultFeatures } from "../../context/DiagramFeatures.js";
|
|
3
|
+
import { defineActors } from "../../utils/defineActors.js";
|
|
2
4
|
import { editorActorLogic } from "../../editor/actor/machine.js";
|
|
5
|
+
import { navigationPanelActorLogic } from "../../navigationpanel/actor.js";
|
|
3
6
|
import { overlaysActorLogic } from "../../overlays/overlaysActor.js";
|
|
4
7
|
import { searchActorLogic } from "../../search/searchActor.js";
|
|
5
8
|
import { hotkeyActorLogic } from "./hotkeyActor.js";
|
|
6
9
|
import { mediaPrintActorLogic } from "./mediaPrintActor.js";
|
|
10
|
+
import { DiagramToggledFeaturesPersistence } from "./persistence.js";
|
|
7
11
|
import { isTruthy, mapValues } from "remeda";
|
|
8
|
-
import { nonexhaustive } from "@likec4/core";
|
|
12
|
+
import { hasProp, isDynamicView, nonexhaustive } from "@likec4/core";
|
|
9
13
|
import "@likec4/core/geometry";
|
|
10
14
|
import { assertEvent, setup } from "xstate";
|
|
11
15
|
//#region src/likec4diagram/state/machine.setup.ts
|
|
16
|
+
function Context({ input }) {
|
|
17
|
+
return {
|
|
18
|
+
...input,
|
|
19
|
+
xynodes: [],
|
|
20
|
+
xyedges: [],
|
|
21
|
+
features: {
|
|
22
|
+
...DefaultFeatures,
|
|
23
|
+
...input.features
|
|
24
|
+
},
|
|
25
|
+
toggledFeatures: DiagramToggledFeaturesPersistence.read() ?? {
|
|
26
|
+
enableReadOnly: true,
|
|
27
|
+
enableCompareWithLatest: false
|
|
28
|
+
},
|
|
29
|
+
initialized: {
|
|
30
|
+
xydata: false,
|
|
31
|
+
xyflow: false
|
|
32
|
+
},
|
|
33
|
+
viewportChangedManually: false,
|
|
34
|
+
lastOnNavigate: null,
|
|
35
|
+
lastClickedNode: null,
|
|
36
|
+
focusedNode: null,
|
|
37
|
+
autoUnfocusTimer: false,
|
|
38
|
+
activeElementDetails: null,
|
|
39
|
+
viewportBefore: null,
|
|
40
|
+
viewportOnManualLayout: null,
|
|
41
|
+
viewportOnAutoLayout: null,
|
|
42
|
+
navigationHistory: {
|
|
43
|
+
currentIndex: 0,
|
|
44
|
+
history: []
|
|
45
|
+
},
|
|
46
|
+
viewport: {
|
|
47
|
+
x: 0,
|
|
48
|
+
y: 0,
|
|
49
|
+
zoom: 1
|
|
50
|
+
},
|
|
51
|
+
xyflow: null,
|
|
52
|
+
dynamicViewVariant: input.dynamicViewVariant ?? (input.view._type === "dynamic" ? input.view.variant : "diagram") ?? "diagram",
|
|
53
|
+
activeWalkthrough: null,
|
|
54
|
+
collapsedSequenceFlows: {}
|
|
55
|
+
};
|
|
56
|
+
}
|
|
12
57
|
var deriveToggledFeatures = (context) => {
|
|
13
58
|
let toggledFeatures = context.toggledFeatures;
|
|
14
59
|
const hasActiveWalkthrough = isTruthy(context.activeWalkthrough);
|
|
@@ -19,6 +64,9 @@ var deriveToggledFeatures = (context) => {
|
|
|
19
64
|
};
|
|
20
65
|
};
|
|
21
66
|
var isReadOnly = (context) => deriveToggledFeatures(context).enableReadOnly;
|
|
67
|
+
function isActiveSequenceWalkthrough(context) {
|
|
68
|
+
return isDynamicView(context.view) && context.dynamicViewVariant === "sequence" && !!context.activeWalkthrough && hasProp(context.view, "flow");
|
|
69
|
+
}
|
|
22
70
|
var machine = setup({
|
|
23
71
|
types: {
|
|
24
72
|
context: {},
|
|
@@ -27,13 +75,14 @@ var machine = setup({
|
|
|
27
75
|
events: {},
|
|
28
76
|
emitted: {}
|
|
29
77
|
},
|
|
30
|
-
actors: {
|
|
31
|
-
hotkeyActorLogic,
|
|
32
|
-
overlaysActorLogic,
|
|
33
|
-
searchActorLogic,
|
|
34
|
-
mediaPrintActorLogic,
|
|
35
|
-
|
|
36
|
-
|
|
78
|
+
actors: defineActors({
|
|
79
|
+
hotkey: hotkeyActorLogic,
|
|
80
|
+
overlays: overlaysActorLogic,
|
|
81
|
+
search: searchActorLogic,
|
|
82
|
+
mediaPrint: mediaPrintActorLogic,
|
|
83
|
+
editor: editorActorLogic,
|
|
84
|
+
navigationPanel: navigationPanelActorLogic
|
|
85
|
+
}),
|
|
37
86
|
guards: {
|
|
38
87
|
"isReady": ({ context }) => context.initialized.xydata && context.initialized.xyflow,
|
|
39
88
|
"enabled: Editor": ({ context }) => context.features.enableEditor,
|
|
@@ -45,6 +94,7 @@ var machine = setup({
|
|
|
45
94
|
"enabled: ElementDetails": ({ context }) => context.features.enableElementDetails,
|
|
46
95
|
"enabled: OpenSource": ({ context }) => context.features.enableVscode,
|
|
47
96
|
"enabled: DynamicViewWalkthrough": ({ context }) => context.features.enableDynamicViewWalkthrough,
|
|
97
|
+
"enabled: NavigationPanel": ({ context }) => context.features.enableControls,
|
|
48
98
|
"focus.node: autoUnfocus": ({ event }) => {
|
|
49
99
|
assertEvent(event, "focus.node");
|
|
50
100
|
return event.autoUnfocus === true;
|
|
@@ -52,6 +102,7 @@ var machine = setup({
|
|
|
52
102
|
"enabled: Overlays": ({ context }) => context.features.enableElementDetails || context.features.enableRelationshipBrowser || context.features.enableRelationshipDetails,
|
|
53
103
|
"not readonly": ({ context }) => !isReadOnly(context),
|
|
54
104
|
"is dynamic view": ({ context }) => context.view._type === "dynamic",
|
|
105
|
+
"is dynamic view in sequence variant": ({ context }) => context.view._type === "dynamic" && context.dynamicViewVariant === "sequence",
|
|
55
106
|
"is same view": ({ context, event }) => {
|
|
56
107
|
assertEvent(event, ["update.view", "navigate.to"]);
|
|
57
108
|
if (event.type === "update.view") return context.view.id === event.view.id;
|
|
@@ -80,6 +131,10 @@ var machine = setup({
|
|
|
80
131
|
assertEvent(event, "xyflow.nodeClick");
|
|
81
132
|
return context.focusedNode === event.node.id;
|
|
82
133
|
},
|
|
134
|
+
"click: node.type = seq-subflow": ({ event }) => {
|
|
135
|
+
assertEvent(event, "xyflow.nodeClick");
|
|
136
|
+
return event.node.type === "seq-subflow";
|
|
137
|
+
},
|
|
83
138
|
"click: node has connections": ({ context, event }) => {
|
|
84
139
|
assertEvent(event, "xyflow.nodeClick");
|
|
85
140
|
return context.xyedges.some((e) => e.source === event.node.id || e.target === event.node.id);
|
|
@@ -90,9 +145,7 @@ var machine = setup({
|
|
|
90
145
|
},
|
|
91
146
|
"click: active walkthrough step": ({ context, event }) => {
|
|
92
147
|
assertEvent(event, ["xyflow.edgeClick", "xyflow.edgeDoubleClick"]);
|
|
93
|
-
|
|
94
|
-
const { stepId } = context.activeWalkthrough;
|
|
95
|
-
return event.edge.id === stepId;
|
|
148
|
+
return event.edge.data.id === context.activeWalkthrough?.stepId;
|
|
96
149
|
}
|
|
97
150
|
}
|
|
98
151
|
});
|
|
@@ -105,4 +158,4 @@ var targetState = {
|
|
|
105
158
|
};
|
|
106
159
|
var to = mapValues(targetState, (id) => ({ target: id }));
|
|
107
160
|
//#endregion
|
|
108
|
-
export { deriveToggledFeatures, machine, targetState, to };
|
|
161
|
+
export { Context, deriveToggledFeatures, isActiveSequenceWalkthrough, machine, targetState, to };
|