@likec4/diagram 1.56.0 → 1.58.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 +3 -1
- package/dist/LikeC4View.js +47 -55
- package/dist/adhoc-editor/EditorPanel.d.ts +1 -1
- package/dist/adhoc-editor/ElementsTree.d.ts +1 -1
- package/dist/adhoc-editor/ElementsTree.js +2 -6
- package/dist/adhoc-editor/LikeC4AdHocViewEditor.d.ts +1 -1
- package/dist/adhoc-editor/components/Tree.d.ts +5 -5
- package/dist/adhoc-editor/state/ActorProvider.d.ts +1 -1
- package/dist/adhoc-editor/state/panel.d.ts +1 -1
- package/dist/adhoc-editor/viewrules/ViewRulesPanel.d.ts +1 -1
- package/dist/base/BaseXYFlow.d.ts +1 -1
- package/dist/base-primitives/Markdown.d.ts +1 -1
- package/dist/base-primitives/NodeHandles.d.ts +1 -1
- package/dist/base-primitives/compound/CompoundActionButton.d.ts +1 -1
- package/dist/base-primitives/compound/CompoundDetailsButton.d.ts +1 -1
- package/dist/base-primitives/compound/CompoundNodeContainer.d.ts +1 -1
- package/dist/base-primitives/compound/CompoundTitle.d.ts +1 -1
- package/dist/base-primitives/compound/actionbtns.css.d.ts +1 -1
- package/dist/base-primitives/edge/EdgeActionButton.d.ts +1 -1
- package/dist/base-primitives/edge/EdgeContainer.d.ts +1 -1
- package/dist/base-primitives/edge/EdgeLabelContainer.d.ts +1 -1
- package/dist/base-primitives/edge/EdgeMarkers.d.ts +8 -8
- package/dist/base-primitives/element/ElementActionButtons.d.ts +1 -1
- package/dist/base-primitives/element/ElementData.d.ts +2 -2
- package/dist/base-primitives/element/ElementDetailsButton.d.ts +1 -1
- package/dist/base-primitives/element/ElementShape.d.ts +1 -1
- package/dist/base-primitives/element/ElementTags.d.ts +1 -1
- package/dist/base-primitives/element/ElementTags.js +1 -3
- package/dist/components/ErrorFallback.d.ts +2 -2
- package/dist/components/NavigationPanel.d.ts +2 -2
- package/dist/components/PortalToContainer.d.ts +1 -1
- package/dist/components/RootContainer.d.ts +1 -1
- package/dist/components/RootContainer.js +19 -18
- package/dist/components/SearchControl.d.ts +2 -2
- package/dist/components/ViewNotFound.d.ts +2 -2
- package/dist/context/CurrentViewModelProvider.d.ts +1 -1
- package/dist/context/DefaultMantineProvider.d.ts +1 -1
- package/dist/context/DiagramEventHandlers.d.ts +1 -1
- package/dist/context/DiagramFeatures.d.ts +1 -1
- package/dist/context/DiagramFeatures.js +5 -0
- package/dist/context/EnsureMantine.d.ts +1 -1
- package/dist/context/FramerMotionConfig.d.ts +3 -3
- package/dist/context/FramerMotionConfig.js +2 -2
- package/dist/context/IconRenderer.d.ts +2 -2
- package/dist/context/IconRenderer.js +32 -12
- package/dist/context/LikeC4ModelContext.d.ts +1 -1
- package/dist/context/RootContainerContext.d.ts +10 -17
- package/dist/context/RootContainerContext.js +1 -13
- package/dist/context/ShadowRootContext.d.ts +3 -0
- package/dist/context/ShadowRootContext.js +5 -0
- package/dist/context/TagStylesContext.d.ts +2 -1
- package/dist/context/TagStylesContext.js +5 -7
- package/dist/custom/index.d.ts +1 -1
- package/dist/custom/index.js +1 -2
- package/dist/editor/LikeC4EditorCallbacks.d.ts +5 -0
- package/dist/editor/LikeC4EditorProvider.d.ts +2 -2
- package/dist/editor/actor/actions.d.ts +174 -0
- package/dist/editor/actor/actions.js +188 -0
- package/dist/editor/{hotkeyActor.d.ts → actor/hotkey.d.ts} +2 -2
- package/dist/editor/{hotkeyActor.js → actor/hotkey.js} +11 -4
- package/dist/editor/{editorActor.states.d.ts → actor/machine.d.ts} +5 -3
- package/dist/editor/actor/machine.js +23 -0
- package/dist/editor/actor/setup.d.ts +55 -0
- package/dist/editor/{editorActor.setup.js → actor/setup.js} +14 -10
- package/dist/editor/actor/state.editor.d.ts +147 -0
- package/dist/editor/actor/state.editor.js +56 -0
- package/dist/editor/actor/state.sync-queue.d.ts +612 -0
- package/dist/editor/actor/state.sync-queue.js +272 -0
- package/dist/editor/actor/types.d.ts +64 -0
- package/dist/editor/actor/types.js +5 -0
- package/dist/editor/applyChangesToManualLayout.js +1 -1
- package/dist/editor/index.d.ts +2 -1
- package/dist/editor/useEditorActorLogic.d.ts +8 -2
- package/dist/editor/useEditorActorLogic.js +39 -7
- package/dist/hooks/useDiagram.js +6 -1
- package/dist/hooks/useDiagramCompareLayout.js +1 -1
- package/dist/hooks/useEditorActor.d.ts +9 -0
- package/dist/hooks/useEditorActor.js +27 -0
- package/dist/hooks/useLikeC4ElementsTree.d.ts +3 -2
- package/dist/hooks/useLikeC4ElementsTree.js +3 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -1
- package/dist/likec4diagram/DiagramUI.d.ts +1 -1
- package/dist/likec4diagram/DiagramUI.js +8 -4
- package/dist/likec4diagram/DiagramXYFlow.js +26 -14
- package/dist/likec4diagram/custom/edges/EdgeDrifts.d.ts +1 -1
- package/dist/likec4diagram/custom/edges/RelationshipEdge.js +127 -14
- package/dist/likec4diagram/custom/edges/SequenceStepEdge.d.ts +1 -1
- package/dist/likec4diagram/custom/edges/edges.css.d.ts +1 -0
- package/dist/likec4diagram/custom/edges/edges.css.js +5 -1
- package/dist/likec4diagram/custom/nodes/CompoundActions.d.ts +1 -1
- package/dist/likec4diagram/custom/nodes/ElementActions.d.ts +2 -2
- package/dist/likec4diagram/custom/nodes/NodeDrifts.d.ts +1 -1
- package/dist/likec4diagram/custom/nodes/NodeNotes.d.ts +1 -1
- package/dist/likec4diagram/custom/nodes/SequenceActorNode.d.ts +2 -2
- package/dist/likec4diagram/custom/nodes/nodes.d.ts +7 -7
- package/dist/likec4diagram/custom/nodes/toolbar/ColorButton.d.ts +3 -3
- package/dist/likec4diagram/custom/nodes/toolbar/CompoundToolbar.d.ts +2 -2
- package/dist/likec4diagram/custom/nodes/toolbar/ElementToolbar.d.ts +2 -2
- package/dist/likec4diagram/custom/nodes/toolbar/Toolbar.d.ts +1 -1
- package/dist/likec4diagram/custom/nodes/toolbar/_shared.d.ts +3 -3
- package/dist/likec4diagram/relationship-popover/RelationshipPopover.d.ts +1 -1
- package/dist/likec4diagram/relationship-popover/components.d.ts +2 -2
- package/dist/likec4diagram/state/DiagramActorProvider.d.ts +1 -1
- package/dist/likec4diagram/state/aligners.js +3 -0
- package/dist/likec4diagram/state/assign.js +1 -1
- package/dist/likec4diagram/state/createViewChange.js +1 -0
- package/dist/likec4diagram/state/diagram-api.d.ts +16 -0
- package/dist/likec4diagram/state/diagram-api.js +13 -7
- package/dist/likec4diagram/state/machine.actions.js +10 -10
- package/dist/likec4diagram/state/machine.d.ts +1 -1
- package/dist/likec4diagram/state/machine.setup.js +1 -1
- package/dist/likec4diagram/state/types.d.ts +1 -1
- package/dist/likec4diagram/state/utils.d.ts +1 -1
- package/dist/likec4diagram/types.d.ts +2 -0
- package/dist/likec4diagram/ui/LayoutDriftFrame.d.ts +1 -1
- package/dist/likec4diagram/ui/notation/NotationPanel.d.ts +1 -1
- package/dist/likec4diagram/useLayoutConstraints.js +2 -0
- package/dist/likec4diagram/xyflow-diagram/diagram-view.js +4 -2
- package/dist/likec4diagram/xyflow-sequence/sequence-layout.js +1 -0
- package/dist/navigationpanel/NavigationPanel.d.ts +1 -1
- package/dist/navigationpanel/NavigationPanelControls.d.ts +1 -1
- package/dist/navigationpanel/NavigationPanelDropdown.d.ts +1 -1
- package/dist/navigationpanel/NavigationPanelDropdown.js +2 -2
- package/dist/navigationpanel/_common.d.ts +2 -2
- package/dist/navigationpanel/comparepanel/CompareActionsMenu.d.ts +1 -1
- package/dist/navigationpanel/comparepanel/ComparePanel.d.ts +1 -1
- package/dist/navigationpanel/comparepanel/ComparePanelControls.d.ts +1 -1
- package/dist/navigationpanel/comparepanel/DriftsSummary.d.ts +1 -1
- package/dist/navigationpanel/comparepanel/LayoutTypeSwitcher.d.ts +1 -1
- package/dist/navigationpanel/controls/DetailsControls.d.ts +1 -1
- package/dist/navigationpanel/controls/LayoutWarning.d.ts +1 -1
- package/dist/navigationpanel/controls/LogoButton.d.ts +1 -1
- package/dist/navigationpanel/controls/NavigationButtons.d.ts +1 -1
- package/dist/navigationpanel/controls/OpenSource.d.ts +1 -1
- package/dist/navigationpanel/controls/SearchControl.d.ts +1 -1
- package/dist/navigationpanel/controls/ToggleReadonly.d.ts +1 -1
- package/dist/navigationpanel/controls/ToggleReadonly.js +4 -2
- package/dist/navigationpanel/editorpanel/ApplySemanticLayout.d.ts +4 -0
- package/dist/navigationpanel/editorpanel/ApplySemanticLayout.js +36 -0
- package/dist/navigationpanel/editorpanel/CenterCamera.d.ts +1 -1
- package/dist/navigationpanel/editorpanel/ChangeAutoLayoutButton.d.ts +1 -1
- package/dist/navigationpanel/editorpanel/EditorPanel.d.ts +1 -1
- package/dist/navigationpanel/editorpanel/EditorPanel.js +45 -33
- package/dist/navigationpanel/editorpanel/ManualLayoutToolsButton.d.ts +1 -1
- package/dist/navigationpanel/editorpanel/ToggleReadonly.d.ts +1 -1
- package/dist/navigationpanel/styles.css.d.ts +1 -1
- package/dist/navigationpanel/walkthrough/ActiveWalkthroughControls.d.ts +1 -1
- package/dist/navigationpanel/walkthrough/DynamicViewControls.d.ts +62 -62
- package/dist/navigationpanel/walkthrough/WalkthroughPanel.d.ts +1 -1
- package/dist/overlays/Overlays.d.ts +1 -1
- package/dist/overlays/element-details/ElementDetails.d.ts +1 -1
- package/dist/overlays/element-details/ElementDetailsCard.d.ts +1 -1
- package/dist/overlays/element-details/MetadataValue.d.ts +2 -2
- package/dist/overlays/element-details/TabPanelRelationships.d.ts +1 -1
- package/dist/overlays/element-details/TabPanelStructure.d.ts +2 -2
- package/dist/overlays/overlay/Overlay.d.ts +16 -0
- package/dist/overlays/overlay/Overlay.js +50 -52
- package/dist/overlays/overlaysActor.js +28 -27
- package/dist/overlays/relationship-details/RelationshipDetails.d.ts +1 -1
- package/dist/overlays/relationship-details/SelectEdge.d.ts +1 -1
- package/dist/overlays/relationship-details/custom/ElementActions.d.ts +1 -1
- package/dist/overlays/relationship-details/custom/nodeTypes.d.ts +4 -5
- package/dist/overlays/relationship-details/custom/nodeTypes.js +25 -24
- package/dist/overlays/relationships-browser/RelationshipsBrowser.d.ts +1 -1
- package/dist/overlays/relationships-browser/SelectElement.d.ts +1 -1
- package/dist/overlays/relationships-browser/SelectElement.js +2 -2
- package/dist/overlays/relationships-browser/custom/ElementActions.d.ts +1 -1
- package/dist/overlays/relationships-browser/custom/EmptyNode.d.ts +1 -1
- package/dist/overlays/relationships-browser/custom/nodeTypes.d.ts +4 -4
- package/dist/projects-overview/ProjectsOverview.d.ts +1 -1
- package/dist/projects-overview/custom/nodeTypes.d.ts +1 -1
- package/dist/projects-overview/panel/ProjectsOverviewPanel.d.ts +1 -1
- package/dist/search/Search.d.ts +6 -3
- package/dist/search/Search.js +60 -71
- package/dist/search/XStateSearchAdapter.d.ts +1 -1
- package/dist/search/components/ElementsColumn.d.ts +1 -1
- package/dist/search/components/ElementsColumn.js +12 -8
- package/dist/search/components/PickView.d.ts +1 -1
- package/dist/search/components/SearchByTags.d.ts +1 -1
- package/dist/search/components/SearchInput.d.ts +1 -1
- package/dist/search/components/ViewsColum.d.ts +3 -3
- package/dist/search/components/_shared.css.d.ts +1 -1
- package/dist/search/searchActor.js +30 -26
- package/dist/shadowroot/ShadowRoot.d.ts +6 -6
- package/dist/shadowroot/ShadowRoot.js +68 -23
- package/dist/shadowroot/index.d.ts +1 -0
- package/dist/shadowroot/styles.d.ts +13 -0
- package/dist/shadowroot/styles.js +60 -0
- package/dist/styles2.js +1 -1
- package/package.json +33 -40
- package/panda.buildinfo.json +19 -22
- package/src/styles-font.css +114 -0
- package/src/styles-min.css +2 -0
- package/src/styles-xyflow.css +1 -0
- package/src/styles.css +3 -0
- package/styles-min.css +1 -1
- package/styles-xyflow.css +1 -1
- package/styles.css +1 -1
- package/dist/bundle/index.d.ts +0 -1
- package/dist/editor/editorActor.actions.d.ts +0 -153
- package/dist/editor/editorActor.actions.js +0 -133
- package/dist/editor/editorActor.setup.d.ts +0 -84
- package/dist/editor/editorActor.states.js +0 -219
- package/dist/hooks/useOverlaysActor.js +0 -11
- package/dist/hooks/useSearchActor.js +0 -11
- package/dist/shadowroot/styles.css.d.ts +0 -4
- package/dist/shadowroot/styles.css.js +0 -62
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import "
|
|
1
|
+
import "../../_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { getHotkeyHandler } from "@mantine/hooks";
|
|
3
3
|
import { fromCallback } from "xstate";
|
|
4
|
-
//#region src/editor/
|
|
5
|
-
var
|
|
4
|
+
//#region src/editor/actor/hotkey.ts
|
|
5
|
+
var hotkey = fromCallback(({ sendBack }) => {
|
|
6
6
|
const ctrlZHandler = getHotkeyHandler([[
|
|
7
7
|
"mod + z",
|
|
8
8
|
(event) => {
|
|
@@ -10,6 +10,13 @@ var hotkeyActorLogic = fromCallback(({ sendBack }) => {
|
|
|
10
10
|
sendBack({ type: "undo" });
|
|
11
11
|
},
|
|
12
12
|
{ preventDefault: true }
|
|
13
|
+
], [
|
|
14
|
+
"mod + shift + z",
|
|
15
|
+
(event) => {
|
|
16
|
+
event.stopPropagation();
|
|
17
|
+
sendBack({ type: "redo" });
|
|
18
|
+
},
|
|
19
|
+
{ preventDefault: true }
|
|
13
20
|
]]);
|
|
14
21
|
document.body.addEventListener("keydown", ctrlZHandler, { capture: true });
|
|
15
22
|
return () => {
|
|
@@ -17,4 +24,4 @@ var hotkeyActorLogic = fromCallback(({ sendBack }) => {
|
|
|
17
24
|
};
|
|
18
25
|
});
|
|
19
26
|
//#endregion
|
|
20
|
-
export {
|
|
27
|
+
export { hotkey };
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { ActorRef, SnapshotFrom, StateMachine } from 'xstate';
|
|
2
|
-
import { EditorActorContext, EditorActorEmitedEvent, EditorActorEvent, EditorActorInput } from './
|
|
3
|
-
export
|
|
4
|
-
|
|
2
|
+
import { EditorActorContext, EditorActorEmitedEvent, EditorActorEvent, EditorActorInput, EditorActorStateTag } from './types';
|
|
3
|
+
export interface EditorActorLogic extends StateMachine<EditorActorContext, EditorActorEvent, any, any, any, any, any, {
|
|
4
|
+
editor: 'idle' | 'moving';
|
|
5
|
+
syncQueue: 'idle' | 'pending' | 'suspended' | 'process';
|
|
6
|
+
}, EditorActorStateTag, EditorActorInput, any, EditorActorEmitedEvent, any, any> {
|
|
5
7
|
}
|
|
6
8
|
export declare const editorActorLogic: EditorActorLogic;
|
|
7
9
|
export type EditorActorSnapshot = SnapshotFrom<EditorActorLogic>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import "../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { machine } from "./setup.js";
|
|
3
|
+
import { editor } from "./state.editor.js";
|
|
4
|
+
import { syncQueue } from "./state.sync-queue.js";
|
|
5
|
+
var editorActorLogic = machine.createMachine({
|
|
6
|
+
id: "editor",
|
|
7
|
+
context: ({ input }) => ({
|
|
8
|
+
viewId: input.viewId,
|
|
9
|
+
editing: null,
|
|
10
|
+
history: null,
|
|
11
|
+
redo: null,
|
|
12
|
+
pending: null,
|
|
13
|
+
syncQueue: [],
|
|
14
|
+
processing: null
|
|
15
|
+
}),
|
|
16
|
+
type: "parallel",
|
|
17
|
+
states: {
|
|
18
|
+
editor,
|
|
19
|
+
syncQueue
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
//#endregion
|
|
23
|
+
export { editorActorLogic };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { EditorActorContext, EditorActorEmitedEvent, EditorActorEvent, EditorActorInput, EditorActorStateTag } from './types';
|
|
2
|
+
import { SetupReturn, PromiseActorLogic, EventObject, NonReducibleUnknown, MetaObject } from 'xstate';
|
|
3
|
+
import { HotkeyActorLogic } from './hotkey';
|
|
4
|
+
import type * as t from '@likec4/core/types';
|
|
5
|
+
export declare namespace EditorCalls {
|
|
6
|
+
type ApplyLatestToManual = (params: {
|
|
7
|
+
input: ApplyLatestToManual.Input;
|
|
8
|
+
}) => Promise<ApplyLatestToManual.Output>;
|
|
9
|
+
namespace ApplyLatestToManual {
|
|
10
|
+
type Input = {
|
|
11
|
+
viewId: t.ViewId;
|
|
12
|
+
current: t.LayoutedView | undefined;
|
|
13
|
+
};
|
|
14
|
+
type Output = {
|
|
15
|
+
updated: t.LayoutedView;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
type ApplySemanticLayout = (params: {
|
|
19
|
+
input: ApplySemanticLayout.Input;
|
|
20
|
+
}) => Promise<ApplySemanticLayout.Output>;
|
|
21
|
+
namespace ApplySemanticLayout {
|
|
22
|
+
type Input = {
|
|
23
|
+
viewId: t.ViewId;
|
|
24
|
+
};
|
|
25
|
+
type Output = {};
|
|
26
|
+
}
|
|
27
|
+
type ExecuteChange = (params: {
|
|
28
|
+
input: ExecuteChange.Input;
|
|
29
|
+
}) => Promise<ExecuteChange.Output>;
|
|
30
|
+
namespace ExecuteChange {
|
|
31
|
+
type Input = {
|
|
32
|
+
viewId: t.ViewId;
|
|
33
|
+
changes: t.ViewChange[];
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Returns the changes that were applied to the view
|
|
37
|
+
*/
|
|
38
|
+
type Output = {
|
|
39
|
+
requested: t.ViewChange[];
|
|
40
|
+
applied: t.ViewChange[];
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export declare const machine: SetupReturn<EditorActorContext, EditorActorEvent, {
|
|
45
|
+
applyLatest: PromiseActorLogic<EditorCalls.ApplyLatestToManual.Output, EditorCalls.ApplyLatestToManual.Input, EventObject>;
|
|
46
|
+
executeChange: PromiseActorLogic<EditorCalls.ExecuteChange.Output, EditorCalls.ExecuteChange.Input, EventObject>;
|
|
47
|
+
applySemanticLayout: PromiseActorLogic<EditorCalls.ApplySemanticLayout.Output, EditorCalls.ApplySemanticLayout.Input, EventObject>;
|
|
48
|
+
hotkey: HotkeyActorLogic;
|
|
49
|
+
}, {
|
|
50
|
+
hotkey: "hotkey";
|
|
51
|
+
}, {}, {
|
|
52
|
+
'has pending': unknown;
|
|
53
|
+
'can undo': unknown;
|
|
54
|
+
'can redo': unknown;
|
|
55
|
+
}, "500ms" | "wait-after-edit", EditorActorStateTag, EditorActorInput, NonReducibleUnknown, EditorActorEmitedEvent, MetaObject>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "
|
|
2
|
-
import {
|
|
1
|
+
import "../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { hotkey } from "./hotkey.js";
|
|
3
3
|
import { fromPromise, setup } from "xstate";
|
|
4
4
|
var machine = setup({
|
|
5
5
|
types: {
|
|
@@ -8,11 +8,7 @@ var machine = setup({
|
|
|
8
8
|
emitted: {},
|
|
9
9
|
input: {},
|
|
10
10
|
children: {},
|
|
11
|
-
tags:
|
|
12
|
-
},
|
|
13
|
-
delays: {
|
|
14
|
-
"500ms": 500,
|
|
15
|
-
"waitBeforeSync": 1e3
|
|
11
|
+
tags: ""
|
|
16
12
|
},
|
|
17
13
|
actors: {
|
|
18
14
|
applyLatest: fromPromise(() => {
|
|
@@ -21,11 +17,19 @@ var machine = setup({
|
|
|
21
17
|
executeChange: fromPromise(() => {
|
|
22
18
|
throw new Error("Not implemented");
|
|
23
19
|
}),
|
|
24
|
-
|
|
20
|
+
applySemanticLayout: fromPromise(() => {
|
|
21
|
+
throw new Error("Not implemented");
|
|
22
|
+
}),
|
|
23
|
+
hotkey
|
|
24
|
+
},
|
|
25
|
+
delays: {
|
|
26
|
+
"500ms": 500,
|
|
27
|
+
"wait-after-edit": 1e3
|
|
25
28
|
},
|
|
26
29
|
guards: {
|
|
27
|
-
"has pending": ({ context }) => context.
|
|
28
|
-
"can undo": ({ context }) => context.history
|
|
30
|
+
"has pending": ({ context }) => context.syncQueue.length > 0,
|
|
31
|
+
"can undo": ({ context }) => context.history !== null,
|
|
32
|
+
"can redo": ({ context }) => context.redo !== null
|
|
29
33
|
}
|
|
30
34
|
});
|
|
31
35
|
//#endregion
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { StopAction, ActionFunction, PromiseActorLogic, EventObject } from 'xstate';
|
|
2
|
+
import { EditorActorContext, EditorActorEvent, EditorActorEmitedEvent } from './types';
|
|
3
|
+
import { HotkeyActorLogic } from './hotkey';
|
|
4
|
+
export declare const editor: {
|
|
5
|
+
initial: string;
|
|
6
|
+
states: {
|
|
7
|
+
idle: {
|
|
8
|
+
on: {
|
|
9
|
+
'edit.move.start': {
|
|
10
|
+
target: "#moving";
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
id: string;
|
|
14
|
+
};
|
|
15
|
+
moving: {
|
|
16
|
+
entry: StopAction<EditorActorContext, EditorActorEvent, undefined, EditorActorEvent>[];
|
|
17
|
+
exit: ActionFunction<EditorActorContext, EditorActorEvent, EditorActorEvent, undefined, {
|
|
18
|
+
src: "hotkey";
|
|
19
|
+
logic: HotkeyActorLogic;
|
|
20
|
+
id: "hotkey";
|
|
21
|
+
} | {
|
|
22
|
+
src: "applyLatest";
|
|
23
|
+
logic: PromiseActorLogic<import("./setup").EditorCalls.ApplyLatestToManual.Output, import("./setup").EditorCalls.ApplyLatestToManual.Input, EventObject>;
|
|
24
|
+
id: string | undefined;
|
|
25
|
+
} | {
|
|
26
|
+
src: "executeChange";
|
|
27
|
+
logic: PromiseActorLogic<import("./setup").EditorCalls.ExecuteChange.Output, import("./setup").EditorCalls.ExecuteChange.Input, EventObject>;
|
|
28
|
+
id: string | undefined;
|
|
29
|
+
} | {
|
|
30
|
+
src: "applySemanticLayout";
|
|
31
|
+
logic: PromiseActorLogic<import("./setup").EditorCalls.ApplySemanticLayout.Output, import("./setup").EditorCalls.ApplySemanticLayout.Input, EventObject>;
|
|
32
|
+
id: string | undefined;
|
|
33
|
+
}, never, {
|
|
34
|
+
type: "has pending";
|
|
35
|
+
params: unknown;
|
|
36
|
+
} | {
|
|
37
|
+
type: "can undo";
|
|
38
|
+
params: unknown;
|
|
39
|
+
} | {
|
|
40
|
+
type: "can redo";
|
|
41
|
+
params: unknown;
|
|
42
|
+
}, "500ms" | "wait-after-edit", EditorActorEmitedEvent>[];
|
|
43
|
+
on: {
|
|
44
|
+
'edit.move.end': {
|
|
45
|
+
target: "#idle";
|
|
46
|
+
actions: ActionFunction<EditorActorContext, EditorActorEvent, EditorActorEvent, undefined, {
|
|
47
|
+
src: "hotkey";
|
|
48
|
+
logic: HotkeyActorLogic;
|
|
49
|
+
id: "hotkey";
|
|
50
|
+
} | {
|
|
51
|
+
src: "applyLatest";
|
|
52
|
+
logic: PromiseActorLogic<import("./setup").EditorCalls.ApplyLatestToManual.Output, import("./setup").EditorCalls.ApplyLatestToManual.Input, EventObject>;
|
|
53
|
+
id: string | undefined;
|
|
54
|
+
} | {
|
|
55
|
+
src: "executeChange";
|
|
56
|
+
logic: PromiseActorLogic<import("./setup").EditorCalls.ExecuteChange.Output, import("./setup").EditorCalls.ExecuteChange.Input, EventObject>;
|
|
57
|
+
id: string | undefined;
|
|
58
|
+
} | {
|
|
59
|
+
src: "applySemanticLayout";
|
|
60
|
+
logic: PromiseActorLogic<import("./setup").EditorCalls.ApplySemanticLayout.Output, import("./setup").EditorCalls.ApplySemanticLayout.Input, EventObject>;
|
|
61
|
+
id: string | undefined;
|
|
62
|
+
}, never, {
|
|
63
|
+
type: "has pending";
|
|
64
|
+
params: unknown;
|
|
65
|
+
} | {
|
|
66
|
+
type: "can undo";
|
|
67
|
+
params: unknown;
|
|
68
|
+
} | {
|
|
69
|
+
type: "can redo";
|
|
70
|
+
params: unknown;
|
|
71
|
+
}, "500ms" | "wait-after-edit", EditorActorEmitedEvent>;
|
|
72
|
+
};
|
|
73
|
+
'edit.move.cancel': {
|
|
74
|
+
target: "#idle";
|
|
75
|
+
actions: ActionFunction<EditorActorContext, EditorActorEvent, EditorActorEvent, undefined, {
|
|
76
|
+
src: "hotkey";
|
|
77
|
+
logic: HotkeyActorLogic;
|
|
78
|
+
id: "hotkey";
|
|
79
|
+
} | {
|
|
80
|
+
src: "applyLatest";
|
|
81
|
+
logic: PromiseActorLogic<import("./setup").EditorCalls.ApplyLatestToManual.Output, import("./setup").EditorCalls.ApplyLatestToManual.Input, EventObject>;
|
|
82
|
+
id: string | undefined;
|
|
83
|
+
} | {
|
|
84
|
+
src: "executeChange";
|
|
85
|
+
logic: PromiseActorLogic<import("./setup").EditorCalls.ExecuteChange.Output, import("./setup").EditorCalls.ExecuteChange.Input, EventObject>;
|
|
86
|
+
id: string | undefined;
|
|
87
|
+
} | {
|
|
88
|
+
src: "applySemanticLayout";
|
|
89
|
+
logic: PromiseActorLogic<import("./setup").EditorCalls.ApplySemanticLayout.Output, import("./setup").EditorCalls.ApplySemanticLayout.Input, EventObject>;
|
|
90
|
+
id: string | undefined;
|
|
91
|
+
}, never, never, never, never>;
|
|
92
|
+
};
|
|
93
|
+
cancel: {
|
|
94
|
+
target: "#idle";
|
|
95
|
+
actions: ActionFunction<EditorActorContext, EditorActorEvent, EditorActorEvent, undefined, {
|
|
96
|
+
src: "hotkey";
|
|
97
|
+
logic: HotkeyActorLogic;
|
|
98
|
+
id: "hotkey";
|
|
99
|
+
} | {
|
|
100
|
+
src: "applyLatest";
|
|
101
|
+
logic: PromiseActorLogic<import("./setup").EditorCalls.ApplyLatestToManual.Output, import("./setup").EditorCalls.ApplyLatestToManual.Input, EventObject>;
|
|
102
|
+
id: string | undefined;
|
|
103
|
+
} | {
|
|
104
|
+
src: "executeChange";
|
|
105
|
+
logic: PromiseActorLogic<import("./setup").EditorCalls.ExecuteChange.Output, import("./setup").EditorCalls.ExecuteChange.Input, EventObject>;
|
|
106
|
+
id: string | undefined;
|
|
107
|
+
} | {
|
|
108
|
+
src: "applySemanticLayout";
|
|
109
|
+
logic: PromiseActorLogic<import("./setup").EditorCalls.ApplySemanticLayout.Output, import("./setup").EditorCalls.ApplySemanticLayout.Input, EventObject>;
|
|
110
|
+
id: string | undefined;
|
|
111
|
+
}, never, never, never, never>;
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
id: string;
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
on: {
|
|
118
|
+
'*': {
|
|
119
|
+
actions: ActionFunction<EditorActorContext, EditorActorEvent, EditorActorEvent, undefined, {
|
|
120
|
+
src: "hotkey";
|
|
121
|
+
logic: HotkeyActorLogic;
|
|
122
|
+
id: "hotkey";
|
|
123
|
+
} | {
|
|
124
|
+
src: "applyLatest";
|
|
125
|
+
logic: PromiseActorLogic<import("./setup").EditorCalls.ApplyLatestToManual.Output, import("./setup").EditorCalls.ApplyLatestToManual.Input, EventObject>;
|
|
126
|
+
id: string | undefined;
|
|
127
|
+
} | {
|
|
128
|
+
src: "executeChange";
|
|
129
|
+
logic: PromiseActorLogic<import("./setup").EditorCalls.ExecuteChange.Output, import("./setup").EditorCalls.ExecuteChange.Input, EventObject>;
|
|
130
|
+
id: string | undefined;
|
|
131
|
+
} | {
|
|
132
|
+
src: "applySemanticLayout";
|
|
133
|
+
logic: PromiseActorLogic<import("./setup").EditorCalls.ApplySemanticLayout.Output, import("./setup").EditorCalls.ApplySemanticLayout.Input, EventObject>;
|
|
134
|
+
id: string | undefined;
|
|
135
|
+
}, never, {
|
|
136
|
+
type: "has pending";
|
|
137
|
+
params: unknown;
|
|
138
|
+
} | {
|
|
139
|
+
type: "can undo";
|
|
140
|
+
params: unknown;
|
|
141
|
+
} | {
|
|
142
|
+
type: "can redo";
|
|
143
|
+
params: unknown;
|
|
144
|
+
}, "500ms" | "wait-after-edit", EditorActorEmitedEvent>;
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import "../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { machine } from "./setup.js";
|
|
3
|
+
import { pushHistory, saveBeforeEditing } from "./actions.js";
|
|
4
|
+
//#region src/editor/actor/state.editor.ts
|
|
5
|
+
var to = {
|
|
6
|
+
idle: { target: "#idle" },
|
|
7
|
+
moving: { target: "#moving" }
|
|
8
|
+
};
|
|
9
|
+
var idOf = (t) => ({ id: t.target.substring(1) });
|
|
10
|
+
var stopHotkey = () => machine.stopChild("hotkey");
|
|
11
|
+
var ensureHotKey = () => machine.enqueueActions(({ check, enqueue, self }) => {
|
|
12
|
+
const hasUndo = check("can undo") || check("can redo");
|
|
13
|
+
const hotkey = self.getSnapshot().children["hotkey"];
|
|
14
|
+
if (!hasUndo && hotkey) {
|
|
15
|
+
enqueue.stopChild(hotkey);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (hasUndo && !hotkey) enqueue.spawnChild("hotkey", { id: "hotkey" });
|
|
19
|
+
});
|
|
20
|
+
/**
|
|
21
|
+
* Idle state, no pending operations
|
|
22
|
+
*/
|
|
23
|
+
var idle = machine.createStateConfig({
|
|
24
|
+
...idOf(to.idle),
|
|
25
|
+
on: { "edit.move.start": { ...to.moving } }
|
|
26
|
+
});
|
|
27
|
+
var clearEditing = () => machine.assign({ editing: null });
|
|
28
|
+
var moving = machine.createStateConfig({
|
|
29
|
+
...idOf(to.moving),
|
|
30
|
+
entry: [saveBeforeEditing(), stopHotkey()],
|
|
31
|
+
exit: [ensureHotKey()],
|
|
32
|
+
on: {
|
|
33
|
+
"edit.move.end": {
|
|
34
|
+
actions: pushHistory(),
|
|
35
|
+
...to.idle
|
|
36
|
+
},
|
|
37
|
+
"edit.move.cancel": {
|
|
38
|
+
actions: clearEditing(),
|
|
39
|
+
...to.idle
|
|
40
|
+
},
|
|
41
|
+
"cancel": {
|
|
42
|
+
actions: clearEditing(),
|
|
43
|
+
...to.idle
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
var editor = machine.createStateConfig({
|
|
48
|
+
initial: "idle",
|
|
49
|
+
states: {
|
|
50
|
+
idle,
|
|
51
|
+
moving
|
|
52
|
+
},
|
|
53
|
+
on: { "*": { actions: ensureHotKey() } }
|
|
54
|
+
});
|
|
55
|
+
//#endregion
|
|
56
|
+
export { editor };
|