@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.
- package/dist/LikeC4Diagram.js +3 -1
- package/dist/LikeC4View.js +47 -55
- package/dist/adhoc-editor/ElementsTree.js +2 -6
- package/dist/components/RootContainer.js +19 -18
- package/dist/context/DiagramFeatures.d.ts +1 -1
- package/dist/context/DiagramFeatures.js +5 -0
- package/dist/context/RootContainerContext.d.ts +10 -17
- package/dist/context/RootContainerContext.js +1 -13
- 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/actor/actions.d.ts +115 -0
- package/dist/editor/actor/actions.js +122 -0
- package/dist/editor/{hotkeyActor.d.ts → actor/hotkey.d.ts} +1 -1
- package/dist/editor/{hotkeyActor.js → actor/hotkey.js} +4 -4
- package/dist/editor/actor/machine.d.ts +11 -0
- package/dist/editor/actor/machine.js +22 -0
- package/dist/editor/{editorActor.setup.d.ts → actor/setup.d.ts} +13 -49
- package/dist/editor/{editorActor.setup.js → actor/setup.js} +13 -10
- package/dist/editor/actor/state.editor.d.ts +97 -0
- package/dist/editor/actor/state.editor.js +55 -0
- package/dist/editor/actor/state.sync-queue.d.ts +420 -0
- package/dist/editor/actor/state.sync-queue.js +235 -0
- package/dist/editor/actor/types.d.ts +59 -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 +26 -6
- package/dist/hooks/useDiagram.js +6 -1
- package/dist/hooks/useDiagramCompareLayout.js +1 -1
- package/dist/hooks/useEditorActor.d.ts +4 -0
- package/dist/hooks/useEditorActor.js +26 -0
- package/dist/hooks/useLikeC4ElementsTree.d.ts +3 -2
- package/dist/hooks/useLikeC4ElementsTree.js +3 -1
- package/dist/likec4diagram/DiagramUI.js +8 -4
- package/dist/likec4diagram/DiagramXYFlow.js +12 -12
- package/dist/likec4diagram/state/aligners.js +3 -0
- package/dist/likec4diagram/state/assign.js +1 -1
- 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 +7 -8
- 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/useLayoutConstraints.js +2 -0
- 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/EditorPanel.js +45 -33
- package/dist/navigationpanel/walkthrough/DynamicViewControls.d.ts +61 -61
- 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/custom/nodeTypes.d.ts +4 -5
- package/dist/overlays/relationship-details/custom/nodeTypes.js +25 -24
- package/dist/overlays/relationships-browser/SelectElement.js +2 -2
- package/dist/search/Search.d.ts +6 -3
- package/dist/search/Search.js +60 -71
- package/dist/search/components/ElementsColumn.js +12 -8
- package/dist/search/searchActor.js +30 -26
- package/dist/shadowroot/ShadowRoot.d.ts +7 -6
- package/dist/shadowroot/ShadowRoot.js +59 -20
- package/dist/shadowroot/styles.css.d.ts +10 -2
- package/dist/shadowroot/styles.css.js +33 -36
- package/dist/styles2.js +1 -1
- package/package.json +17 -23
- package/panda.buildinfo.json +15 -15
- 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.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.states.d.ts +0 -9
- package/dist/editor/editorActor.states.js +0 -219
- package/dist/hooks/useOverlaysActor.js +0 -11
- package/dist/hooks/useSearchActor.js +0 -11
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
pending: null,
|
|
12
|
+
syncQueue: [],
|
|
13
|
+
processing: null
|
|
14
|
+
}),
|
|
15
|
+
type: "parallel",
|
|
16
|
+
states: {
|
|
17
|
+
editor,
|
|
18
|
+
syncQueue
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
//#endregion
|
|
22
|
+
export { editorActorLogic };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NonReducibleUnknown, SetupReturn, PromiseActorLogic, EventObject, MetaObject } from 'xstate';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { EditorActorContext, EditorActorEmitedEvent, EditorActorEvent, EditorActorInput, EditorActorStateTag } from './types';
|
|
3
|
+
import { HotkeyActorLogic } from './hotkey';
|
|
4
4
|
import type * as t from '@likec4/core/types';
|
|
5
5
|
export declare namespace EditorCalls {
|
|
6
6
|
type ApplyLatestToManual = (params: {
|
|
@@ -15,6 +15,15 @@ export declare namespace EditorCalls {
|
|
|
15
15
|
updated: t.LayoutedView;
|
|
16
16
|
};
|
|
17
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
|
+
}
|
|
18
27
|
type ExecuteChange = (params: {
|
|
19
28
|
input: ExecuteChange.Input;
|
|
20
29
|
}) => Promise<ExecuteChange.Output>;
|
|
@@ -26,59 +35,14 @@ export declare namespace EditorCalls {
|
|
|
26
35
|
type Output = NonReducibleUnknown;
|
|
27
36
|
}
|
|
28
37
|
}
|
|
29
|
-
export type EditorActorEvent = {
|
|
30
|
-
type: 'sync';
|
|
31
|
-
} | {
|
|
32
|
-
type: 'change';
|
|
33
|
-
change: t.ViewChange;
|
|
34
|
-
} | {
|
|
35
|
-
type: 'edit.start';
|
|
36
|
-
subject: 'node' | 'edge';
|
|
37
|
-
} | {
|
|
38
|
-
type: 'edit.finish';
|
|
39
|
-
wasChanged?: boolean;
|
|
40
|
-
} | {
|
|
41
|
-
type: 'applyLatestToManual';
|
|
42
|
-
} | {
|
|
43
|
-
type: 'synced';
|
|
44
|
-
} | {
|
|
45
|
-
type: 'cancel';
|
|
46
|
-
} | {
|
|
47
|
-
type: 'reset';
|
|
48
|
-
} | HotKeyEvent;
|
|
49
|
-
export type HistorySnapshot = {
|
|
50
|
-
view: t.LayoutedView;
|
|
51
|
-
change: t.ViewChange.SaveViewSnapshot;
|
|
52
|
-
xynodes: Types.Node[];
|
|
53
|
-
xyedges: Types.Edge[];
|
|
54
|
-
synched: boolean;
|
|
55
|
-
};
|
|
56
|
-
export interface EditorActorInput {
|
|
57
|
-
viewId: t.ViewId;
|
|
58
|
-
}
|
|
59
|
-
export interface EditorActorContext {
|
|
60
|
-
viewId: t.ViewId;
|
|
61
|
-
pendingChanges: t.ViewChange[];
|
|
62
|
-
history: ReadonlyArray<HistorySnapshot>;
|
|
63
|
-
/**
|
|
64
|
-
* The state before editing started
|
|
65
|
-
*/
|
|
66
|
-
beforeEditing: HistorySnapshot | null;
|
|
67
|
-
/**
|
|
68
|
-
* The subject of the edit
|
|
69
|
-
*/
|
|
70
|
-
editing: 'node' | 'edge' | null;
|
|
71
|
-
}
|
|
72
|
-
export type EditorActorEmitedEvent = {
|
|
73
|
-
type: 'idle';
|
|
74
|
-
};
|
|
75
38
|
export declare const machine: SetupReturn<EditorActorContext, EditorActorEvent, {
|
|
76
39
|
applyLatest: PromiseActorLogic<EditorCalls.ApplyLatestToManual.Output, EditorCalls.ApplyLatestToManual.Input, EventObject>;
|
|
77
40
|
executeChange: PromiseActorLogic<NonReducibleUnknown, EditorCalls.ExecuteChange.Input, EventObject>;
|
|
41
|
+
applySemanticLayout: PromiseActorLogic<EditorCalls.ApplySemanticLayout.Output, EditorCalls.ApplySemanticLayout.Input, EventObject>;
|
|
78
42
|
hotkey: HotkeyActorLogic;
|
|
79
43
|
}, {
|
|
80
44
|
hotkey: "hotkey";
|
|
81
45
|
}, {}, {
|
|
82
46
|
'has pending': unknown;
|
|
83
47
|
'can undo': unknown;
|
|
84
|
-
}, "500ms" | "
|
|
48
|
+
}, "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,18 @@ 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 || !!context.processing,
|
|
31
|
+
"can undo": ({ context }) => context.history !== null
|
|
29
32
|
}
|
|
30
33
|
});
|
|
31
34
|
//#endregion
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { StopAction, ActionFunction, PromiseActorLogic, EventObject, NonReducibleUnknown } 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
|
+
on: {
|
|
18
|
+
'edit.move.end': {
|
|
19
|
+
target: "#idle";
|
|
20
|
+
actions: ( ActionFunction<EditorActorContext, EditorActorEvent, EditorActorEvent, undefined, never, never, never, "500ms" | "wait-after-edit", never> | ActionFunction<EditorActorContext, EditorActorEvent, EditorActorEvent, undefined, {
|
|
21
|
+
src: "hotkey";
|
|
22
|
+
logic: HotkeyActorLogic;
|
|
23
|
+
id: "hotkey";
|
|
24
|
+
} | {
|
|
25
|
+
src: "applyLatest";
|
|
26
|
+
logic: PromiseActorLogic<import("./setup").EditorCalls.ApplyLatestToManual.Output, import("./setup").EditorCalls.ApplyLatestToManual.Input, EventObject>;
|
|
27
|
+
id: string | undefined;
|
|
28
|
+
} | {
|
|
29
|
+
src: "executeChange";
|
|
30
|
+
logic: PromiseActorLogic<NonReducibleUnknown, import("./setup").EditorCalls.ExecuteChange.Input, EventObject>;
|
|
31
|
+
id: string | undefined;
|
|
32
|
+
} | {
|
|
33
|
+
src: "applySemanticLayout";
|
|
34
|
+
logic: PromiseActorLogic<import("./setup").EditorCalls.ApplySemanticLayout.Output, import("./setup").EditorCalls.ApplySemanticLayout.Input, EventObject>;
|
|
35
|
+
id: string | undefined;
|
|
36
|
+
}, never, never, never, never>)[];
|
|
37
|
+
};
|
|
38
|
+
'edit.move.cancel': {
|
|
39
|
+
target: "#idle";
|
|
40
|
+
actions: ActionFunction<EditorActorContext, {
|
|
41
|
+
type: "edit.move.cancel";
|
|
42
|
+
}, EditorActorEvent, undefined, {
|
|
43
|
+
src: "hotkey";
|
|
44
|
+
logic: HotkeyActorLogic;
|
|
45
|
+
id: "hotkey";
|
|
46
|
+
} | {
|
|
47
|
+
src: "applyLatest";
|
|
48
|
+
logic: PromiseActorLogic<import("./setup").EditorCalls.ApplyLatestToManual.Output, import("./setup").EditorCalls.ApplyLatestToManual.Input, EventObject>;
|
|
49
|
+
id: string | undefined;
|
|
50
|
+
} | {
|
|
51
|
+
src: "executeChange";
|
|
52
|
+
logic: PromiseActorLogic<NonReducibleUnknown, import("./setup").EditorCalls.ExecuteChange.Input, EventObject>;
|
|
53
|
+
id: string | undefined;
|
|
54
|
+
} | {
|
|
55
|
+
src: "applySemanticLayout";
|
|
56
|
+
logic: PromiseActorLogic<import("./setup").EditorCalls.ApplySemanticLayout.Output, import("./setup").EditorCalls.ApplySemanticLayout.Input, EventObject>;
|
|
57
|
+
id: string | undefined;
|
|
58
|
+
}, never, never, never, never>[];
|
|
59
|
+
};
|
|
60
|
+
undo: {
|
|
61
|
+
target: "#idle";
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
id: string;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
on: {
|
|
68
|
+
cancel: {
|
|
69
|
+
target: "#idle";
|
|
70
|
+
};
|
|
71
|
+
'*': {
|
|
72
|
+
actions: ActionFunction<EditorActorContext, EditorActorEvent, EditorActorEvent, undefined, {
|
|
73
|
+
src: "hotkey";
|
|
74
|
+
logic: HotkeyActorLogic;
|
|
75
|
+
id: "hotkey";
|
|
76
|
+
} | {
|
|
77
|
+
src: "applyLatest";
|
|
78
|
+
logic: PromiseActorLogic<import("./setup").EditorCalls.ApplyLatestToManual.Output, import("./setup").EditorCalls.ApplyLatestToManual.Input, EventObject>;
|
|
79
|
+
id: string | undefined;
|
|
80
|
+
} | {
|
|
81
|
+
src: "executeChange";
|
|
82
|
+
logic: PromiseActorLogic<NonReducibleUnknown, import("./setup").EditorCalls.ExecuteChange.Input, EventObject>;
|
|
83
|
+
id: string | undefined;
|
|
84
|
+
} | {
|
|
85
|
+
src: "applySemanticLayout";
|
|
86
|
+
logic: PromiseActorLogic<import("./setup").EditorCalls.ApplySemanticLayout.Output, import("./setup").EditorCalls.ApplySemanticLayout.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" | "wait-after-edit", EditorActorEmitedEvent>;
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import "../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { machine } from "./setup.js";
|
|
3
|
+
import { pushHistory, saveBeforeEditing, scheduleSync } from "./actions.js";
|
|
4
|
+
import { assign } from "xstate";
|
|
5
|
+
//#region src/editor/actor/state.editor.ts
|
|
6
|
+
var to = {
|
|
7
|
+
idle: { target: "#idle" },
|
|
8
|
+
moving: { target: "#moving" }
|
|
9
|
+
};
|
|
10
|
+
var idOf = (t) => ({ id: t.target.substring(1) });
|
|
11
|
+
var stopHotkey = () => machine.stopChild("hotkey");
|
|
12
|
+
var ensureHotKey = () => machine.enqueueActions(({ check, enqueue, self }) => {
|
|
13
|
+
const hasUndo = check("can undo");
|
|
14
|
+
const hotkey = self.getSnapshot().children["hotkey"];
|
|
15
|
+
if (!hasUndo && hotkey) {
|
|
16
|
+
enqueue.stopChild(hotkey);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
if (hasUndo && !hotkey) enqueue.spawnChild("hotkey", { id: "hotkey" });
|
|
20
|
+
});
|
|
21
|
+
/**
|
|
22
|
+
* Idle state, no pending operations
|
|
23
|
+
*/
|
|
24
|
+
var idle = machine.createStateConfig({
|
|
25
|
+
...idOf(to.idle),
|
|
26
|
+
on: { "edit.move.start": { ...to.moving } }
|
|
27
|
+
});
|
|
28
|
+
var moving = machine.createStateConfig({
|
|
29
|
+
...idOf(to.moving),
|
|
30
|
+
entry: [saveBeforeEditing, stopHotkey()],
|
|
31
|
+
on: {
|
|
32
|
+
"edit.move.end": {
|
|
33
|
+
actions: [pushHistory(), scheduleSync()],
|
|
34
|
+
...to.idle
|
|
35
|
+
},
|
|
36
|
+
"edit.move.cancel": {
|
|
37
|
+
actions: [assign({ editing: null })],
|
|
38
|
+
...to.idle
|
|
39
|
+
},
|
|
40
|
+
"undo": { ...to.idle }
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
var editor = machine.createStateConfig({
|
|
44
|
+
initial: "idle",
|
|
45
|
+
states: {
|
|
46
|
+
idle,
|
|
47
|
+
moving
|
|
48
|
+
},
|
|
49
|
+
on: {
|
|
50
|
+
"cancel": { ...to.idle },
|
|
51
|
+
"*": { actions: ensureHotKey() }
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
//#endregion
|
|
55
|
+
export { editor };
|