@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.
Files changed (208) hide show
  1. package/dist/LikeC4Diagram.js +3 -1
  2. package/dist/LikeC4View.js +47 -55
  3. package/dist/adhoc-editor/EditorPanel.d.ts +1 -1
  4. package/dist/adhoc-editor/ElementsTree.d.ts +1 -1
  5. package/dist/adhoc-editor/ElementsTree.js +2 -6
  6. package/dist/adhoc-editor/LikeC4AdHocViewEditor.d.ts +1 -1
  7. package/dist/adhoc-editor/components/Tree.d.ts +5 -5
  8. package/dist/adhoc-editor/state/ActorProvider.d.ts +1 -1
  9. package/dist/adhoc-editor/state/panel.d.ts +1 -1
  10. package/dist/adhoc-editor/viewrules/ViewRulesPanel.d.ts +1 -1
  11. package/dist/base/BaseXYFlow.d.ts +1 -1
  12. package/dist/base-primitives/Markdown.d.ts +1 -1
  13. package/dist/base-primitives/NodeHandles.d.ts +1 -1
  14. package/dist/base-primitives/compound/CompoundActionButton.d.ts +1 -1
  15. package/dist/base-primitives/compound/CompoundDetailsButton.d.ts +1 -1
  16. package/dist/base-primitives/compound/CompoundNodeContainer.d.ts +1 -1
  17. package/dist/base-primitives/compound/CompoundTitle.d.ts +1 -1
  18. package/dist/base-primitives/compound/actionbtns.css.d.ts +1 -1
  19. package/dist/base-primitives/edge/EdgeActionButton.d.ts +1 -1
  20. package/dist/base-primitives/edge/EdgeContainer.d.ts +1 -1
  21. package/dist/base-primitives/edge/EdgeLabelContainer.d.ts +1 -1
  22. package/dist/base-primitives/edge/EdgeMarkers.d.ts +8 -8
  23. package/dist/base-primitives/element/ElementActionButtons.d.ts +1 -1
  24. package/dist/base-primitives/element/ElementData.d.ts +2 -2
  25. package/dist/base-primitives/element/ElementDetailsButton.d.ts +1 -1
  26. package/dist/base-primitives/element/ElementShape.d.ts +1 -1
  27. package/dist/base-primitives/element/ElementTags.d.ts +1 -1
  28. package/dist/base-primitives/element/ElementTags.js +1 -3
  29. package/dist/components/ErrorFallback.d.ts +2 -2
  30. package/dist/components/NavigationPanel.d.ts +2 -2
  31. package/dist/components/PortalToContainer.d.ts +1 -1
  32. package/dist/components/RootContainer.d.ts +1 -1
  33. package/dist/components/RootContainer.js +19 -18
  34. package/dist/components/SearchControl.d.ts +2 -2
  35. package/dist/components/ViewNotFound.d.ts +2 -2
  36. package/dist/context/CurrentViewModelProvider.d.ts +1 -1
  37. package/dist/context/DefaultMantineProvider.d.ts +1 -1
  38. package/dist/context/DiagramEventHandlers.d.ts +1 -1
  39. package/dist/context/DiagramFeatures.d.ts +1 -1
  40. package/dist/context/DiagramFeatures.js +5 -0
  41. package/dist/context/EnsureMantine.d.ts +1 -1
  42. package/dist/context/FramerMotionConfig.d.ts +3 -3
  43. package/dist/context/FramerMotionConfig.js +2 -2
  44. package/dist/context/IconRenderer.d.ts +2 -2
  45. package/dist/context/IconRenderer.js +32 -12
  46. package/dist/context/LikeC4ModelContext.d.ts +1 -1
  47. package/dist/context/RootContainerContext.d.ts +10 -17
  48. package/dist/context/RootContainerContext.js +1 -13
  49. package/dist/context/ShadowRootContext.d.ts +3 -0
  50. package/dist/context/ShadowRootContext.js +5 -0
  51. package/dist/context/TagStylesContext.d.ts +2 -1
  52. package/dist/context/TagStylesContext.js +5 -7
  53. package/dist/custom/index.d.ts +1 -1
  54. package/dist/custom/index.js +1 -2
  55. package/dist/editor/LikeC4EditorCallbacks.d.ts +5 -0
  56. package/dist/editor/LikeC4EditorProvider.d.ts +2 -2
  57. package/dist/editor/actor/actions.d.ts +174 -0
  58. package/dist/editor/actor/actions.js +188 -0
  59. package/dist/editor/{hotkeyActor.d.ts → actor/hotkey.d.ts} +2 -2
  60. package/dist/editor/{hotkeyActor.js → actor/hotkey.js} +11 -4
  61. package/dist/editor/{editorActor.states.d.ts → actor/machine.d.ts} +5 -3
  62. package/dist/editor/actor/machine.js +23 -0
  63. package/dist/editor/actor/setup.d.ts +55 -0
  64. package/dist/editor/{editorActor.setup.js → actor/setup.js} +14 -10
  65. package/dist/editor/actor/state.editor.d.ts +147 -0
  66. package/dist/editor/actor/state.editor.js +56 -0
  67. package/dist/editor/actor/state.sync-queue.d.ts +612 -0
  68. package/dist/editor/actor/state.sync-queue.js +272 -0
  69. package/dist/editor/actor/types.d.ts +64 -0
  70. package/dist/editor/actor/types.js +5 -0
  71. package/dist/editor/applyChangesToManualLayout.js +1 -1
  72. package/dist/editor/index.d.ts +2 -1
  73. package/dist/editor/useEditorActorLogic.d.ts +8 -2
  74. package/dist/editor/useEditorActorLogic.js +39 -7
  75. package/dist/hooks/useDiagram.js +6 -1
  76. package/dist/hooks/useDiagramCompareLayout.js +1 -1
  77. package/dist/hooks/useEditorActor.d.ts +9 -0
  78. package/dist/hooks/useEditorActor.js +27 -0
  79. package/dist/hooks/useLikeC4ElementsTree.d.ts +3 -2
  80. package/dist/hooks/useLikeC4ElementsTree.js +3 -1
  81. package/dist/index.d.ts +2 -0
  82. package/dist/index.js +3 -1
  83. package/dist/likec4diagram/DiagramUI.d.ts +1 -1
  84. package/dist/likec4diagram/DiagramUI.js +8 -4
  85. package/dist/likec4diagram/DiagramXYFlow.js +26 -14
  86. package/dist/likec4diagram/custom/edges/EdgeDrifts.d.ts +1 -1
  87. package/dist/likec4diagram/custom/edges/RelationshipEdge.js +127 -14
  88. package/dist/likec4diagram/custom/edges/SequenceStepEdge.d.ts +1 -1
  89. package/dist/likec4diagram/custom/edges/edges.css.d.ts +1 -0
  90. package/dist/likec4diagram/custom/edges/edges.css.js +5 -1
  91. package/dist/likec4diagram/custom/nodes/CompoundActions.d.ts +1 -1
  92. package/dist/likec4diagram/custom/nodes/ElementActions.d.ts +2 -2
  93. package/dist/likec4diagram/custom/nodes/NodeDrifts.d.ts +1 -1
  94. package/dist/likec4diagram/custom/nodes/NodeNotes.d.ts +1 -1
  95. package/dist/likec4diagram/custom/nodes/SequenceActorNode.d.ts +2 -2
  96. package/dist/likec4diagram/custom/nodes/nodes.d.ts +7 -7
  97. package/dist/likec4diagram/custom/nodes/toolbar/ColorButton.d.ts +3 -3
  98. package/dist/likec4diagram/custom/nodes/toolbar/CompoundToolbar.d.ts +2 -2
  99. package/dist/likec4diagram/custom/nodes/toolbar/ElementToolbar.d.ts +2 -2
  100. package/dist/likec4diagram/custom/nodes/toolbar/Toolbar.d.ts +1 -1
  101. package/dist/likec4diagram/custom/nodes/toolbar/_shared.d.ts +3 -3
  102. package/dist/likec4diagram/relationship-popover/RelationshipPopover.d.ts +1 -1
  103. package/dist/likec4diagram/relationship-popover/components.d.ts +2 -2
  104. package/dist/likec4diagram/state/DiagramActorProvider.d.ts +1 -1
  105. package/dist/likec4diagram/state/aligners.js +3 -0
  106. package/dist/likec4diagram/state/assign.js +1 -1
  107. package/dist/likec4diagram/state/createViewChange.js +1 -0
  108. package/dist/likec4diagram/state/diagram-api.d.ts +16 -0
  109. package/dist/likec4diagram/state/diagram-api.js +13 -7
  110. package/dist/likec4diagram/state/machine.actions.js +10 -10
  111. package/dist/likec4diagram/state/machine.d.ts +1 -1
  112. package/dist/likec4diagram/state/machine.setup.js +1 -1
  113. package/dist/likec4diagram/state/types.d.ts +1 -1
  114. package/dist/likec4diagram/state/utils.d.ts +1 -1
  115. package/dist/likec4diagram/types.d.ts +2 -0
  116. package/dist/likec4diagram/ui/LayoutDriftFrame.d.ts +1 -1
  117. package/dist/likec4diagram/ui/notation/NotationPanel.d.ts +1 -1
  118. package/dist/likec4diagram/useLayoutConstraints.js +2 -0
  119. package/dist/likec4diagram/xyflow-diagram/diagram-view.js +4 -2
  120. package/dist/likec4diagram/xyflow-sequence/sequence-layout.js +1 -0
  121. package/dist/navigationpanel/NavigationPanel.d.ts +1 -1
  122. package/dist/navigationpanel/NavigationPanelControls.d.ts +1 -1
  123. package/dist/navigationpanel/NavigationPanelDropdown.d.ts +1 -1
  124. package/dist/navigationpanel/NavigationPanelDropdown.js +2 -2
  125. package/dist/navigationpanel/_common.d.ts +2 -2
  126. package/dist/navigationpanel/comparepanel/CompareActionsMenu.d.ts +1 -1
  127. package/dist/navigationpanel/comparepanel/ComparePanel.d.ts +1 -1
  128. package/dist/navigationpanel/comparepanel/ComparePanelControls.d.ts +1 -1
  129. package/dist/navigationpanel/comparepanel/DriftsSummary.d.ts +1 -1
  130. package/dist/navigationpanel/comparepanel/LayoutTypeSwitcher.d.ts +1 -1
  131. package/dist/navigationpanel/controls/DetailsControls.d.ts +1 -1
  132. package/dist/navigationpanel/controls/LayoutWarning.d.ts +1 -1
  133. package/dist/navigationpanel/controls/LogoButton.d.ts +1 -1
  134. package/dist/navigationpanel/controls/NavigationButtons.d.ts +1 -1
  135. package/dist/navigationpanel/controls/OpenSource.d.ts +1 -1
  136. package/dist/navigationpanel/controls/SearchControl.d.ts +1 -1
  137. package/dist/navigationpanel/controls/ToggleReadonly.d.ts +1 -1
  138. package/dist/navigationpanel/controls/ToggleReadonly.js +4 -2
  139. package/dist/navigationpanel/editorpanel/ApplySemanticLayout.d.ts +4 -0
  140. package/dist/navigationpanel/editorpanel/ApplySemanticLayout.js +36 -0
  141. package/dist/navigationpanel/editorpanel/CenterCamera.d.ts +1 -1
  142. package/dist/navigationpanel/editorpanel/ChangeAutoLayoutButton.d.ts +1 -1
  143. package/dist/navigationpanel/editorpanel/EditorPanel.d.ts +1 -1
  144. package/dist/navigationpanel/editorpanel/EditorPanel.js +45 -33
  145. package/dist/navigationpanel/editorpanel/ManualLayoutToolsButton.d.ts +1 -1
  146. package/dist/navigationpanel/editorpanel/ToggleReadonly.d.ts +1 -1
  147. package/dist/navigationpanel/styles.css.d.ts +1 -1
  148. package/dist/navigationpanel/walkthrough/ActiveWalkthroughControls.d.ts +1 -1
  149. package/dist/navigationpanel/walkthrough/DynamicViewControls.d.ts +62 -62
  150. package/dist/navigationpanel/walkthrough/WalkthroughPanel.d.ts +1 -1
  151. package/dist/overlays/Overlays.d.ts +1 -1
  152. package/dist/overlays/element-details/ElementDetails.d.ts +1 -1
  153. package/dist/overlays/element-details/ElementDetailsCard.d.ts +1 -1
  154. package/dist/overlays/element-details/MetadataValue.d.ts +2 -2
  155. package/dist/overlays/element-details/TabPanelRelationships.d.ts +1 -1
  156. package/dist/overlays/element-details/TabPanelStructure.d.ts +2 -2
  157. package/dist/overlays/overlay/Overlay.d.ts +16 -0
  158. package/dist/overlays/overlay/Overlay.js +50 -52
  159. package/dist/overlays/overlaysActor.js +28 -27
  160. package/dist/overlays/relationship-details/RelationshipDetails.d.ts +1 -1
  161. package/dist/overlays/relationship-details/SelectEdge.d.ts +1 -1
  162. package/dist/overlays/relationship-details/custom/ElementActions.d.ts +1 -1
  163. package/dist/overlays/relationship-details/custom/nodeTypes.d.ts +4 -5
  164. package/dist/overlays/relationship-details/custom/nodeTypes.js +25 -24
  165. package/dist/overlays/relationships-browser/RelationshipsBrowser.d.ts +1 -1
  166. package/dist/overlays/relationships-browser/SelectElement.d.ts +1 -1
  167. package/dist/overlays/relationships-browser/SelectElement.js +2 -2
  168. package/dist/overlays/relationships-browser/custom/ElementActions.d.ts +1 -1
  169. package/dist/overlays/relationships-browser/custom/EmptyNode.d.ts +1 -1
  170. package/dist/overlays/relationships-browser/custom/nodeTypes.d.ts +4 -4
  171. package/dist/projects-overview/ProjectsOverview.d.ts +1 -1
  172. package/dist/projects-overview/custom/nodeTypes.d.ts +1 -1
  173. package/dist/projects-overview/panel/ProjectsOverviewPanel.d.ts +1 -1
  174. package/dist/search/Search.d.ts +6 -3
  175. package/dist/search/Search.js +60 -71
  176. package/dist/search/XStateSearchAdapter.d.ts +1 -1
  177. package/dist/search/components/ElementsColumn.d.ts +1 -1
  178. package/dist/search/components/ElementsColumn.js +12 -8
  179. package/dist/search/components/PickView.d.ts +1 -1
  180. package/dist/search/components/SearchByTags.d.ts +1 -1
  181. package/dist/search/components/SearchInput.d.ts +1 -1
  182. package/dist/search/components/ViewsColum.d.ts +3 -3
  183. package/dist/search/components/_shared.css.d.ts +1 -1
  184. package/dist/search/searchActor.js +30 -26
  185. package/dist/shadowroot/ShadowRoot.d.ts +6 -6
  186. package/dist/shadowroot/ShadowRoot.js +68 -23
  187. package/dist/shadowroot/index.d.ts +1 -0
  188. package/dist/shadowroot/styles.d.ts +13 -0
  189. package/dist/shadowroot/styles.js +60 -0
  190. package/dist/styles2.js +1 -1
  191. package/package.json +33 -40
  192. package/panda.buildinfo.json +19 -22
  193. package/src/styles-font.css +114 -0
  194. package/src/styles-min.css +2 -0
  195. package/src/styles-xyflow.css +1 -0
  196. package/src/styles.css +3 -0
  197. package/styles-min.css +1 -1
  198. package/styles-xyflow.css +1 -1
  199. package/styles.css +1 -1
  200. package/dist/bundle/index.d.ts +0 -1
  201. package/dist/editor/editorActor.actions.d.ts +0 -153
  202. package/dist/editor/editorActor.actions.js +0 -133
  203. package/dist/editor/editorActor.setup.d.ts +0 -84
  204. package/dist/editor/editorActor.states.js +0 -219
  205. package/dist/hooks/useOverlaysActor.js +0 -11
  206. package/dist/hooks/useSearchActor.js +0 -11
  207. package/dist/shadowroot/styles.css.d.ts +0 -4
  208. package/dist/shadowroot/styles.css.js +0 -62
@@ -1,8 +1,8 @@
1
- import "../_virtual/_rolldown/runtime.js";
1
+ import "../../_virtual/_rolldown/runtime.js";
2
2
  import { getHotkeyHandler } from "@mantine/hooks";
3
3
  import { fromCallback } from "xstate";
4
- //#region src/editor/hotkeyActor.ts
5
- var hotkeyActorLogic = fromCallback(({ sendBack }) => {
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 { hotkeyActorLogic };
27
+ export { hotkey };
@@ -1,7 +1,9 @@
1
1
  import { ActorRef, SnapshotFrom, StateMachine } from 'xstate';
2
- import { EditorActorContext, EditorActorEmitedEvent, EditorActorEvent, EditorActorInput } from './editorActor.setup';
3
- export type { EditorActorContext, EditorActorEmitedEvent, EditorActorEvent, EditorActorInput, } from './editorActor.setup';
4
- export interface EditorActorLogic extends StateMachine<EditorActorContext, EditorActorEvent, any, any, any, any, any, 'idle' | 'editing' | 'pending' | 'afterEdit' | 'applyLatestToManual' | 'executeChanges', any, EditorActorInput, any, EditorActorEmitedEvent, any, any> {
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 "../_virtual/_rolldown/runtime.js";
2
- import { hotkeyActorLogic } from "./hotkeyActor.js";
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
- hotkey: hotkeyActorLogic
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.pendingChanges.length > 0,
28
- "can undo": ({ context }) => context.history.length > 0
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 };