@likec4/diagram 1.56.0 → 1.57.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 (82) hide show
  1. package/dist/LikeC4Diagram.js +3 -1
  2. package/dist/LikeC4View.js +47 -55
  3. package/dist/adhoc-editor/ElementsTree.js +2 -6
  4. package/dist/components/RootContainer.js +19 -18
  5. package/dist/context/DiagramFeatures.d.ts +1 -1
  6. package/dist/context/DiagramFeatures.js +5 -0
  7. package/dist/context/RootContainerContext.d.ts +10 -17
  8. package/dist/context/RootContainerContext.js +1 -13
  9. package/dist/custom/index.d.ts +1 -1
  10. package/dist/custom/index.js +1 -2
  11. package/dist/editor/LikeC4EditorCallbacks.d.ts +5 -0
  12. package/dist/editor/actor/actions.d.ts +115 -0
  13. package/dist/editor/actor/actions.js +122 -0
  14. package/dist/editor/{hotkeyActor.d.ts → actor/hotkey.d.ts} +1 -1
  15. package/dist/editor/{hotkeyActor.js → actor/hotkey.js} +4 -4
  16. package/dist/editor/actor/machine.d.ts +11 -0
  17. package/dist/editor/actor/machine.js +22 -0
  18. package/dist/editor/{editorActor.setup.d.ts → actor/setup.d.ts} +13 -49
  19. package/dist/editor/{editorActor.setup.js → actor/setup.js} +13 -10
  20. package/dist/editor/actor/state.editor.d.ts +97 -0
  21. package/dist/editor/actor/state.editor.js +55 -0
  22. package/dist/editor/actor/state.sync-queue.d.ts +420 -0
  23. package/dist/editor/actor/state.sync-queue.js +235 -0
  24. package/dist/editor/actor/types.d.ts +59 -0
  25. package/dist/editor/actor/types.js +5 -0
  26. package/dist/editor/applyChangesToManualLayout.js +1 -1
  27. package/dist/editor/index.d.ts +2 -1
  28. package/dist/editor/useEditorActorLogic.d.ts +8 -2
  29. package/dist/editor/useEditorActorLogic.js +26 -6
  30. package/dist/hooks/useDiagram.js +6 -1
  31. package/dist/hooks/useDiagramCompareLayout.js +1 -1
  32. package/dist/hooks/useEditorActor.d.ts +4 -0
  33. package/dist/hooks/useEditorActor.js +26 -0
  34. package/dist/hooks/useLikeC4ElementsTree.d.ts +3 -2
  35. package/dist/hooks/useLikeC4ElementsTree.js +3 -1
  36. package/dist/likec4diagram/DiagramUI.js +8 -4
  37. package/dist/likec4diagram/DiagramXYFlow.js +12 -12
  38. package/dist/likec4diagram/state/aligners.js +3 -0
  39. package/dist/likec4diagram/state/assign.js +1 -1
  40. package/dist/likec4diagram/state/diagram-api.d.ts +16 -0
  41. package/dist/likec4diagram/state/diagram-api.js +13 -7
  42. package/dist/likec4diagram/state/machine.actions.js +7 -8
  43. package/dist/likec4diagram/state/machine.d.ts +1 -1
  44. package/dist/likec4diagram/state/machine.setup.js +1 -1
  45. package/dist/likec4diagram/state/types.d.ts +1 -1
  46. package/dist/likec4diagram/state/utils.d.ts +1 -1
  47. package/dist/likec4diagram/useLayoutConstraints.js +2 -0
  48. package/dist/navigationpanel/controls/ToggleReadonly.js +4 -2
  49. package/dist/navigationpanel/editorpanel/ApplySemanticLayout.d.ts +4 -0
  50. package/dist/navigationpanel/editorpanel/ApplySemanticLayout.js +36 -0
  51. package/dist/navigationpanel/editorpanel/EditorPanel.js +45 -33
  52. package/dist/navigationpanel/walkthrough/DynamicViewControls.d.ts +61 -61
  53. package/dist/overlays/overlay/Overlay.d.ts +16 -0
  54. package/dist/overlays/overlay/Overlay.js +50 -52
  55. package/dist/overlays/overlaysActor.js +28 -27
  56. package/dist/overlays/relationship-details/custom/nodeTypes.d.ts +4 -5
  57. package/dist/overlays/relationship-details/custom/nodeTypes.js +25 -24
  58. package/dist/overlays/relationships-browser/SelectElement.js +2 -2
  59. package/dist/search/Search.d.ts +6 -3
  60. package/dist/search/Search.js +60 -71
  61. package/dist/search/components/ElementsColumn.js +12 -8
  62. package/dist/search/searchActor.js +30 -26
  63. package/dist/shadowroot/ShadowRoot.d.ts +7 -6
  64. package/dist/shadowroot/ShadowRoot.js +59 -20
  65. package/dist/shadowroot/styles.css.d.ts +10 -2
  66. package/dist/shadowroot/styles.css.js +33 -36
  67. package/dist/styles2.js +1 -1
  68. package/package.json +17 -23
  69. package/panda.buildinfo.json +15 -15
  70. package/src/styles-font.css +114 -0
  71. package/src/styles-min.css +2 -0
  72. package/src/styles-xyflow.css +1 -0
  73. package/src/styles.css +3 -0
  74. package/styles-min.css +1 -1
  75. package/styles.css +1 -1
  76. package/dist/bundle/index.d.ts +0 -1
  77. package/dist/editor/editorActor.actions.d.ts +0 -153
  78. package/dist/editor/editorActor.actions.js +0 -133
  79. package/dist/editor/editorActor.states.d.ts +0 -9
  80. package/dist/editor/editorActor.states.js +0 -219
  81. package/dist/hooks/useOverlaysActor.js +0 -11
  82. package/dist/hooks/useSearchActor.js +0 -11
@@ -1 +0,0 @@
1
- export * from '../index';
@@ -1,153 +0,0 @@
1
- import { ViewChange } from '@likec4/core/types';
2
- import { ActionFunction, CancelAction, PromiseActorLogic, EventObject, NonReducibleUnknown, StopAction } from 'xstate';
3
- import { EditorActorContext, EditorActorEvent, EditorActorEmitedEvent } from './editorActor.setup';
4
- import { HotkeyActorLogic } from './hotkeyActor';
5
- export declare const raiseSync: () => ActionFunction<EditorActorContext, EditorActorEvent, EditorActorEvent, undefined, never, never, never, "500ms" | "waitBeforeSync", never>;
6
- export declare const cancelSync: () => CancelAction<EditorActorContext, EditorActorEvent, undefined, EditorActorEvent>;
7
- export declare const reschedule: (delay?: number) => ActionFunction<EditorActorContext, EditorActorEvent, EditorActorEvent, undefined, never, never, never, "500ms" | "waitBeforeSync", never>;
8
- type LayoutChanges = ViewChange.ResetManualLayout | ViewChange.SaveViewSnapshot;
9
- export declare const isLayoutChange: (change: ViewChange) => change is LayoutChanges;
10
- export declare const withoutSnapshotChanges: (data: ViewChange[]) => (ViewChange.ChangeElementStyle | ViewChange.ChangeAutoLayout)[];
11
- export declare const saveStateBeforeEdit: () => ActionFunction<EditorActorContext, EditorActorEvent, EditorActorEvent, undefined, {
12
- src: "hotkey";
13
- logic: HotkeyActorLogic;
14
- id: "hotkey";
15
- } | {
16
- src: "applyLatest";
17
- logic: PromiseActorLogic<import("./editorActor.setup").EditorCalls.ApplyLatestToManual.Output, import("./editorActor.setup").EditorCalls.ApplyLatestToManual.Input, EventObject>;
18
- id: string | undefined;
19
- } | {
20
- src: "executeChange";
21
- logic: PromiseActorLogic<NonReducibleUnknown, import("./editorActor.setup").EditorCalls.ExecuteChange.Input, EventObject>;
22
- id: string | undefined;
23
- }, never, never, never, never>;
24
- export declare const startEditing: () => ActionFunction<EditorActorContext, EditorActorEvent, EditorActorEvent, undefined, {
25
- src: "hotkey";
26
- logic: HotkeyActorLogic;
27
- id: "hotkey";
28
- } | {
29
- src: "applyLatest";
30
- logic: PromiseActorLogic<import("./editorActor.setup").EditorCalls.ApplyLatestToManual.Output, import("./editorActor.setup").EditorCalls.ApplyLatestToManual.Input, EventObject>;
31
- id: string | undefined;
32
- } | {
33
- src: "executeChange";
34
- logic: PromiseActorLogic<NonReducibleUnknown, import("./editorActor.setup").EditorCalls.ExecuteChange.Input, EventObject>;
35
- id: string | undefined;
36
- }, never, {
37
- type: "has pending";
38
- params: unknown;
39
- } | {
40
- type: "can undo";
41
- params: unknown;
42
- }, "500ms" | "waitBeforeSync", EditorActorEmitedEvent>;
43
- export declare const stopHotkey: () => StopAction<EditorActorContext, EditorActorEvent, undefined, EditorActorEvent>;
44
- export declare const ensureHotKey: () => ActionFunction<EditorActorContext, EditorActorEvent, EditorActorEvent, undefined, {
45
- src: "hotkey";
46
- logic: HotkeyActorLogic;
47
- id: "hotkey";
48
- } | {
49
- src: "applyLatest";
50
- logic: PromiseActorLogic<import("./editorActor.setup").EditorCalls.ApplyLatestToManual.Output, import("./editorActor.setup").EditorCalls.ApplyLatestToManual.Input, EventObject>;
51
- id: string | undefined;
52
- } | {
53
- src: "executeChange";
54
- logic: PromiseActorLogic<NonReducibleUnknown, import("./editorActor.setup").EditorCalls.ExecuteChange.Input, EventObject>;
55
- id: string | undefined;
56
- }, never, {
57
- type: "has pending";
58
- params: unknown;
59
- } | {
60
- type: "can undo";
61
- params: unknown;
62
- }, "500ms" | "waitBeforeSync", EditorActorEmitedEvent>;
63
- export declare const pushHistory: () => ActionFunction<EditorActorContext, EditorActorEvent, EditorActorEvent, undefined, {
64
- src: "hotkey";
65
- logic: HotkeyActorLogic;
66
- id: "hotkey";
67
- } | {
68
- src: "applyLatest";
69
- logic: PromiseActorLogic<import("./editorActor.setup").EditorCalls.ApplyLatestToManual.Output, import("./editorActor.setup").EditorCalls.ApplyLatestToManual.Input, EventObject>;
70
- id: string | undefined;
71
- } | {
72
- src: "executeChange";
73
- logic: PromiseActorLogic<NonReducibleUnknown, import("./editorActor.setup").EditorCalls.ExecuteChange.Input, EventObject>;
74
- id: string | undefined;
75
- }, never, never, never, never>;
76
- export declare const stopEditing: () => ActionFunction<EditorActorContext, EditorActorEvent, EditorActorEvent, undefined, {
77
- src: "hotkey";
78
- logic: HotkeyActorLogic;
79
- id: "hotkey";
80
- } | {
81
- src: "applyLatest";
82
- logic: PromiseActorLogic<import("./editorActor.setup").EditorCalls.ApplyLatestToManual.Output, import("./editorActor.setup").EditorCalls.ApplyLatestToManual.Input, EventObject>;
83
- id: string | undefined;
84
- } | {
85
- src: "executeChange";
86
- logic: PromiseActorLogic<NonReducibleUnknown, import("./editorActor.setup").EditorCalls.ExecuteChange.Input, EventObject>;
87
- id: string | undefined;
88
- }, never, {
89
- type: "has pending";
90
- params: unknown;
91
- } | {
92
- type: "can undo";
93
- params: unknown;
94
- }, "500ms" | "waitBeforeSync", EditorActorEmitedEvent>;
95
- export declare const markHistoryAsSynched: () => ActionFunction<EditorActorContext, EditorActorEvent, EditorActorEvent, undefined, {
96
- src: "hotkey";
97
- logic: HotkeyActorLogic;
98
- id: "hotkey";
99
- } | {
100
- src: "applyLatest";
101
- logic: PromiseActorLogic<import("./editorActor.setup").EditorCalls.ApplyLatestToManual.Output, import("./editorActor.setup").EditorCalls.ApplyLatestToManual.Input, EventObject>;
102
- id: string | undefined;
103
- } | {
104
- src: "executeChange";
105
- logic: PromiseActorLogic<NonReducibleUnknown, import("./editorActor.setup").EditorCalls.ExecuteChange.Input, EventObject>;
106
- id: string | undefined;
107
- }, never, never, never, never>;
108
- export declare const popHistory: () => ActionFunction<EditorActorContext, EditorActorEvent, EditorActorEvent, undefined, {
109
- src: "hotkey";
110
- logic: HotkeyActorLogic;
111
- id: "hotkey";
112
- } | {
113
- src: "applyLatest";
114
- logic: PromiseActorLogic<import("./editorActor.setup").EditorCalls.ApplyLatestToManual.Output, import("./editorActor.setup").EditorCalls.ApplyLatestToManual.Input, EventObject>;
115
- id: string | undefined;
116
- } | {
117
- src: "executeChange";
118
- logic: PromiseActorLogic<NonReducibleUnknown, import("./editorActor.setup").EditorCalls.ExecuteChange.Input, EventObject>;
119
- id: string | undefined;
120
- }, never, never, never, never>;
121
- export declare const undo: () => ActionFunction<EditorActorContext, EditorActorEvent, EditorActorEvent, undefined, {
122
- src: "hotkey";
123
- logic: HotkeyActorLogic;
124
- id: "hotkey";
125
- } | {
126
- src: "applyLatest";
127
- logic: PromiseActorLogic<import("./editorActor.setup").EditorCalls.ApplyLatestToManual.Output, import("./editorActor.setup").EditorCalls.ApplyLatestToManual.Input, EventObject>;
128
- id: string | undefined;
129
- } | {
130
- src: "executeChange";
131
- logic: PromiseActorLogic<NonReducibleUnknown, import("./editorActor.setup").EditorCalls.ExecuteChange.Input, EventObject>;
132
- id: string | undefined;
133
- }, never, {
134
- type: "has pending";
135
- params: unknown;
136
- } | {
137
- type: "can undo";
138
- params: unknown;
139
- }, "500ms" | "waitBeforeSync", EditorActorEmitedEvent>;
140
- export declare const addSnapshotToPendingChanges: () => ActionFunction<EditorActorContext, EditorActorEvent, EditorActorEvent, undefined, {
141
- src: "hotkey";
142
- logic: HotkeyActorLogic;
143
- id: "hotkey";
144
- } | {
145
- src: "applyLatest";
146
- logic: PromiseActorLogic<import("./editorActor.setup").EditorCalls.ApplyLatestToManual.Output, import("./editorActor.setup").EditorCalls.ApplyLatestToManual.Input, EventObject>;
147
- id: string | undefined;
148
- } | {
149
- src: "executeChange";
150
- logic: PromiseActorLogic<NonReducibleUnknown, import("./editorActor.setup").EditorCalls.ExecuteChange.Input, EventObject>;
151
- id: string | undefined;
152
- }, never, never, never, never>;
153
- export {};
@@ -1,133 +0,0 @@
1
- import "../_virtual/_rolldown/runtime.js";
2
- import { createViewChange } from "../likec4diagram/state/createViewChange.js";
3
- import { machine } from "./editorActor.setup.js";
4
- import { filter, isNot, last, omit } from "remeda";
5
- //#region src/editor/editorActor.actions.ts
6
- /**
7
- * Actually this is DiagramActorRef
8
- * But we can't use it here due to circular type inference
9
- */
10
- var diagramActorRef = (system) => {
11
- return system.get("diagram");
12
- };
13
- /**
14
- * Actually this is DiagramActorRef
15
- * But we can't use it here due to circular type inference
16
- */
17
- var getDiagramContext = function(system) {
18
- return system.get("diagram").getSnapshot().context;
19
- };
20
- var raiseSync = () => machine.raise({ type: "sync" }, {
21
- delay: 200,
22
- id: "sync"
23
- });
24
- var cancelSync = () => machine.cancel("sync");
25
- var reschedule = (delay = 350) => machine.raise(({ event }) => event, { delay });
26
- var isLayoutChange = (change) => change.op === "reset-manual-layout" || change.op === "save-view-snapshot";
27
- var withoutSnapshotChanges = filter(isNot(isLayoutChange));
28
- var saveStateBeforeEdit = () => machine.assign(({ system }) => {
29
- const parentContext = getDiagramContext(system);
30
- return { beforeEditing: {
31
- xynodes: parentContext.xynodes.map(({ measured, data, ...n }) => ({
32
- ...omit(n, [
33
- "selected",
34
- "dragging",
35
- "resizing"
36
- ]),
37
- data: omit(data, ["dimmed", "hovered"]),
38
- measured,
39
- initialWidth: measured?.width ?? n.width ?? n.initialWidth,
40
- initialHeight: measured?.height ?? n.height ?? n.initialHeight
41
- })),
42
- xyedges: parentContext.xyedges.map(({ data, ...e }) => ({
43
- ...omit(e, ["selected"]),
44
- data: omit(data, [
45
- "active",
46
- "dimmed",
47
- "hovered"
48
- ])
49
- })),
50
- change: createViewChange(parentContext),
51
- view: parentContext.view,
52
- synched: false
53
- } };
54
- });
55
- var startEditing = () => machine.enqueueActions(({ enqueue, event }) => {
56
- enqueue(saveStateBeforeEdit());
57
- if (event.type === "edit.start") enqueue.assign({ editing: event.subject });
58
- });
59
- var stopHotkey = () => machine.stopChild("hotkey");
60
- var ensureHotKey = () => machine.enqueueActions(({ check, enqueue, self }) => {
61
- const hasUndo = check("can undo");
62
- const hotkey = self.getSnapshot().children["hotkey"];
63
- if (!hasUndo && hotkey) {
64
- enqueue.stopChild(hotkey);
65
- return;
66
- }
67
- if (hasUndo && !hotkey) enqueue.spawnChild("hotkey", { id: "hotkey" });
68
- });
69
- var pushHistory = () => machine.assign(({ context }) => {
70
- const snapshot = context.beforeEditing;
71
- if (!snapshot) return { editing: null };
72
- const history = [...context.history, snapshot];
73
- if (history.length > 50) history.shift();
74
- return {
75
- beforeEditing: null,
76
- editing: null,
77
- history
78
- };
79
- });
80
- var stopEditing = () => machine.enqueueActions(({ event, enqueue }) => {
81
- if (event.type === "edit.finish" && event.wasChanged) {
82
- enqueue(pushHistory());
83
- enqueue(raiseSync());
84
- return;
85
- }
86
- enqueue.assign({
87
- beforeEditing: null,
88
- editing: null
89
- });
90
- });
91
- var markHistoryAsSynched = () => machine.assign(({ context }) => {
92
- return {
93
- beforeEditing: context.beforeEditing && context.beforeEditing.synched === false ? {
94
- ...context.beforeEditing,
95
- synched: true
96
- } : context.beforeEditing,
97
- history: context.history.map((i) => ({
98
- ...i,
99
- synched: true
100
- }))
101
- };
102
- });
103
- var popHistory = () => machine.assign(({ context }) => {
104
- if (context.history.length <= 1) return { history: [] };
105
- return { history: context.history.slice(0, context.history.length - 1) };
106
- });
107
- var undo = () => machine.enqueueActions(({ context, enqueue, system }) => {
108
- const lastHistoryItem = last(context.history);
109
- if (!lastHistoryItem) return;
110
- enqueue(cancelSync());
111
- enqueue(popHistory());
112
- enqueue(ensureHotKey());
113
- const diagramActor = diagramActorRef(system);
114
- enqueue.sendTo(diagramActor, {
115
- type: "update.view",
116
- view: lastHistoryItem.view,
117
- xyedges: lastHistoryItem.xyedges,
118
- xynodes: lastHistoryItem.xynodes,
119
- source: "editor"
120
- });
121
- enqueue.assign({ pendingChanges: [] });
122
- if (lastHistoryItem.synched) enqueue.raise({
123
- type: "change",
124
- change: lastHistoryItem.change
125
- }, { delay: 50 });
126
- else enqueue(raiseSync());
127
- });
128
- var addSnapshotToPendingChanges = () => machine.assign(({ context, system }) => {
129
- const change = createViewChange(getDiagramContext(system));
130
- return { pendingChanges: [...withoutSnapshotChanges(context.pendingChanges), change] };
131
- });
132
- //#endregion
133
- export { addSnapshotToPendingChanges, cancelSync, ensureHotKey, isLayoutChange, markHistoryAsSynched, pushHistory, reschedule, saveStateBeforeEdit, startEditing, stopEditing, stopHotkey, undo, withoutSnapshotChanges };
@@ -1,9 +0,0 @@
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> {
5
- }
6
- export declare const editorActorLogic: EditorActorLogic;
7
- export type EditorActorSnapshot = SnapshotFrom<EditorActorLogic>;
8
- export interface EditorActorRef extends ActorRef<EditorActorSnapshot, EditorActorEvent, EditorActorEmitedEvent> {
9
- }
@@ -1,219 +0,0 @@
1
- import "../_virtual/_rolldown/runtime.js";
2
- import { machine } from "./editorActor.setup.js";
3
- import { addSnapshotToPendingChanges, cancelSync, ensureHotKey, isLayoutChange, markHistoryAsSynched, pushHistory, reschedule, saveStateBeforeEdit, startEditing, stopEditing, stopHotkey, undo, withoutSnapshotChanges } from "./editorActor.actions.js";
4
- import { find } from "remeda";
5
- import { assign, enqueueActions, log, sendTo } from "xstate";
6
- //#region src/editor/editorActor.states.ts
7
- /**
8
- * Actually this is DiagramActorRef
9
- * But we can't use it here due to circular type inference
10
- */
11
- var diagramActorRef = function(params) {
12
- return params.system.get("diagram");
13
- };
14
- var to = {
15
- idle: { target: "#idle" },
16
- editing: { target: "#editing" },
17
- afterEdit: { target: "#afterEdit" },
18
- pending: { target: "#pending" },
19
- applyLatestToManual: { target: "#applyLatestToManual" },
20
- executeChanges: { target: "#executeChanges" }
21
- };
22
- /**
23
- * Idle state, no pending operations
24
- */
25
- var idle = machine.createStateConfig({
26
- id: "idle",
27
- on: {
28
- "sync": { ...to.pending },
29
- "edit.start": { ...to.editing }
30
- }
31
- });
32
- /**
33
- * Edit state, some operation is in progress, come to this state from idle
34
- */
35
- var editing = machine.createStateConfig({
36
- id: "editing",
37
- tags: "pending",
38
- entry: [startEditing(), cancelSync()],
39
- on: {
40
- change: {
41
- actions: stopEditing(),
42
- ...to.executeChanges
43
- },
44
- "edit.finish": {
45
- actions: stopEditing(),
46
- ...to.afterEdit
47
- },
48
- "undo": {
49
- actions: stopEditing(),
50
- ...to.idle
51
- }
52
- }
53
- });
54
- /**
55
- * Syncing state, some edits are not yet synced
56
- */
57
- var pending = machine.createStateConfig({
58
- id: "pending",
59
- tags: ["pending"],
60
- entry: ensureHotKey(),
61
- on: {
62
- "sync": {
63
- reenter: true,
64
- ...to.pending
65
- },
66
- "edit.start": {
67
- actions: [addSnapshotToPendingChanges()],
68
- ...to.editing
69
- }
70
- },
71
- after: { "waitBeforeSync": {
72
- actions: [addSnapshotToPendingChanges()],
73
- ...to.executeChanges
74
- } }
75
- });
76
- /**
77
- * Decide where to go next
78
- */
79
- var afterEdit = machine.createStateConfig({
80
- id: "afterEdit",
81
- always: [{
82
- guard: "has pending",
83
- ...to.pending
84
- }, { ...to.idle }]
85
- });
86
- /**
87
- * Syncing state, some edits are not yet synced
88
- */
89
- var applyLatestToManual = machine.createStateConfig({
90
- id: "applyLatestToManual",
91
- entry: [cancelSync(), saveStateBeforeEdit()],
92
- initial: "call",
93
- states: {
94
- call: { invoke: {
95
- src: "applyLatest",
96
- input: ({ context }) => {
97
- const current = context.beforeEditing?.change.layout;
98
- return {
99
- current: current && current._layout === "manual" ? current : void 0,
100
- viewId: context.viewId
101
- };
102
- },
103
- onDone: {
104
- actions: sendTo(diagramActorRef, ({ event }) => ({
105
- type: "update.view",
106
- view: event.output.updated
107
- }), { delay: 10 }),
108
- target: "wait"
109
- },
110
- onError: {
111
- actions: [assign({
112
- beforeEditing: null,
113
- pendingChanges: []
114
- }), ({ event }) => {
115
- console.error(event.error);
116
- }],
117
- ...to.idle
118
- }
119
- } },
120
- wait: {
121
- entry: pushHistory(),
122
- on: { "*": { actions: [log(({ event }) => `wait received unexpected event: ${event.type}`), reschedule(500)] } },
123
- after: { "500ms": {
124
- actions: [addSnapshotToPendingChanges(), ensureHotKey()],
125
- ...to.executeChanges
126
- } }
127
- }
128
- }
129
- });
130
- /**
131
- * Calls `executeChange` to save the snapshot
132
- */
133
- var executeChanges = machine.createStateConfig({
134
- id: "executeChanges",
135
- entry: [assign(({ event, context }) => {
136
- if (event.type === "change") {
137
- if (isLayoutChange(event.change)) return { pendingChanges: [...withoutSnapshotChanges(context.pendingChanges), event.change] };
138
- if (!context.pendingChanges.includes(event.change)) return { pendingChanges: [...context.pendingChanges, event.change] };
139
- }
140
- return {};
141
- }), cancelSync()],
142
- invoke: {
143
- src: "executeChange",
144
- input: ({ context }) => ({
145
- changes: context.pendingChanges,
146
- viewId: context.viewId
147
- }),
148
- onDone: {
149
- actions: enqueueActions(({ context, event, enqueue }) => {
150
- const snapshot = find(context.pendingChanges, (c) => c.op === "save-view-snapshot");
151
- if (snapshot) enqueue.sendTo(diagramActorRef, {
152
- type: "update.view-bounds",
153
- bounds: snapshot.layout.bounds
154
- });
155
- enqueue.assign({ pendingChanges: [] });
156
- }),
157
- ...to.idle
158
- },
159
- onError: {
160
- actions: assign(({ event }) => {
161
- console.error("executeChanges onError", { error: event.error });
162
- return { pendingChanges: [] };
163
- }),
164
- ...to.idle
165
- }
166
- }
167
- });
168
- var editorActorLogic = machine.createMachine({
169
- id: "editor",
170
- context: ({ input }) => ({
171
- viewId: input.viewId,
172
- beforeEditing: null,
173
- editing: null,
174
- pendingChanges: [],
175
- history: []
176
- }),
177
- initial: "idle",
178
- states: {
179
- idle,
180
- editing,
181
- pending,
182
- afterEdit,
183
- applyLatestToManual,
184
- executeChanges
185
- },
186
- on: {
187
- cancel: {
188
- actions: [cancelSync(), assign({
189
- editing: null,
190
- beforeEditing: null,
191
- pendingChanges: []
192
- })],
193
- ...to.idle
194
- },
195
- synced: { actions: markHistoryAsSynched() },
196
- undo: {
197
- guard: "can undo",
198
- actions: undo(),
199
- ...to.idle
200
- },
201
- change: { ...to.executeChanges },
202
- "applyLatestToManual": { ...to.applyLatestToManual },
203
- reset: {
204
- actions: [
205
- cancelSync(),
206
- assign({
207
- history: [],
208
- editing: null,
209
- beforeEditing: null,
210
- pendingChanges: []
211
- }),
212
- stopHotkey()
213
- ],
214
- ...to.idle
215
- }
216
- }
217
- });
218
- //#endregion
219
- export { editorActorLogic };
@@ -1,11 +0,0 @@
1
- import "../_virtual/_rolldown/runtime.js";
2
- import { selectDiagramActor, useDiagramSnapshot } from "./useDiagram.js";
3
- //#region src/hooks/useOverlaysActor.ts
4
- var select = selectDiagramActor((s) => {
5
- return s.children.overlays;
6
- });
7
- function useOverlaysActorRef() {
8
- return useDiagramSnapshot(select, Object.is);
9
- }
10
- //#endregion
11
- export { useOverlaysActorRef };
@@ -1,11 +0,0 @@
1
- import "../_virtual/_rolldown/runtime.js";
2
- import { selectDiagramActor, useDiagramSnapshot } from "./useDiagram.js";
3
- //#region src/hooks/useSearchActor.ts
4
- var select = selectDiagramActor((s) => {
5
- return s.children.search ?? null;
6
- });
7
- function useSearchActorRef() {
8
- return useDiagramSnapshot(select, Object.is);
9
- }
10
- //#endregion
11
- export { useSearchActorRef };