@kiberon-labs/behave-graph-flow 1.0.0 → 2.0.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/.fallowrc.json +16 -0
- package/.storybook/main.ts +32 -0
- package/.storybook/preview.ts +16 -0
- package/.storybook/styles.css +10 -0
- package/.storybook/vscode.css +814 -0
- package/.turbo/turbo-build.log +7 -0
- package/LICENSE +6 -0
- package/README.md +2 -2
- package/data/Polynomial.json +510 -0
- package/data/sequence.json +337 -0
- package/data/trigger-event.json +241 -0
- package/data/variable-change.json +210 -0
- package/dist/entry.css +4 -0
- package/dist/index.css +39 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.ts +2282 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14873 -0
- package/dist/index.js.map +1 -0
- package/docs/notifications.md +246 -0
- package/docs/protocol.md +679 -0
- package/docs/specifics.md +191 -0
- package/package.json +85 -21
- package/postcss.config.ts +3 -4
- package/src/annotations/index.ts +32 -0
- package/src/components/FloatingToolbar/index.module.css +45 -0
- package/src/components/FloatingToolbar/index.tsx +256 -0
- package/src/components/Flow.tsx +276 -75
- package/src/components/contextMenus/NodePicker.module.css +274 -0
- package/src/components/contextMenus/NodePicker.tsx +481 -0
- package/src/components/contextMenus/edge.tsx +108 -0
- package/src/components/contextMenus/node.tsx +155 -0
- package/src/components/contextMenus/selection.tsx +77 -0
- package/src/components/controls/any/index.tsx +8 -0
- package/src/components/controls/boolean/index.tsx +13 -0
- package/src/components/controls/colorPicker/InputPopover.module.css +100 -0
- package/src/components/controls/colorPicker/InputPopover.tsx +31 -0
- package/src/components/controls/colorPicker/index.module.css +18 -0
- package/src/components/controls/colorPicker/index.tsx +61 -0
- package/src/components/controls/number/index.tsx +35 -0
- package/src/components/controls/string/index.tsx +16 -0
- package/src/components/edges/index.tsx +469 -0
- package/src/components/edges/offsetBezier.ts +134 -0
- package/src/components/hotKeys.tsx +20 -0
- package/src/components/layoutController/index.module.css +10 -0
- package/src/components/layoutController/index.tsx +117 -0
- package/src/components/layoutController/utils.ts +205 -0
- package/src/components/menubar/defaults.tsx +480 -0
- package/src/components/menubar/index.tsx +49 -0
- package/src/components/menubar/menuItem.module.css +16 -0
- package/src/components/menubar/menuItem.tsx +32 -0
- package/src/components/nodes/behave/Node.module.css +23 -0
- package/src/components/nodes/behave/Node.tsx +176 -0
- package/src/components/nodes/behave/NodeContainer.module.css +87 -0
- package/src/components/nodes/behave/NodeContainer.tsx +46 -0
- package/src/components/nodes/behave/index.tsx +14 -0
- package/src/components/nodes/comment/FormatToolbar.tsx +118 -0
- package/src/components/nodes/comment/comment.tsx +103 -0
- package/src/components/nodes/comment/styles.module.css +150 -0
- package/src/components/nodes/group/index.tsx +109 -0
- package/src/components/nodes/wrapper/index.tsx +73 -0
- package/src/components/nodes/wrapper/styles.module.css +113 -0
- package/src/components/notifications/NotificationProvider.tsx +81 -0
- package/src/components/notifications/index.ts +2 -0
- package/src/components/notifications/utils.ts +71 -0
- package/src/components/panels/alignment/index.module.css +20 -0
- package/src/components/panels/alignment/index.tsx +244 -0
- package/src/components/panels/base/index.tsx +5 -0
- package/src/components/panels/base/styles.module.css +12 -0
- package/src/components/panels/conversation/index.module.css +151 -0
- package/src/components/panels/conversation/index.tsx +162 -0
- package/src/components/panels/events/CustomEventsEditor.tsx +384 -0
- package/src/components/panels/events/EditEventPanel.tsx +315 -0
- package/src/components/panels/events/ManageEventsPanel.tsx +98 -0
- package/src/components/panels/events/index.tsx +23 -0
- package/src/components/panels/events/styles.module.css +236 -0
- package/src/components/panels/history/index.tsx +92 -0
- package/src/components/panels/history/styles.module.css +106 -0
- package/src/components/panels/keymaps/index.module.css +78 -0
- package/src/components/panels/keymaps/index.tsx +167 -0
- package/src/components/panels/layers/index.tsx +240 -0
- package/src/components/panels/layers/styles.module.css +110 -0
- package/src/components/panels/legend/index.module.css +6 -0
- package/src/components/panels/legend/index.tsx +76 -0
- package/src/components/panels/logs/index.module.css +212 -0
- package/src/components/panels/logs/index.tsx +288 -0
- package/src/components/panels/nodeInputs/InputControl.tsx +63 -0
- package/src/components/panels/nodeInputs/InputsGroup.tsx +64 -0
- package/src/components/panels/nodeInputs/MultipleNodesView.tsx +37 -0
- package/src/components/panels/nodeInputs/NodeSettings.tsx +92 -0
- package/src/components/panels/nodeInputs/NodeTitleEditor.tsx +125 -0
- package/src/components/panels/nodeInputs/OutputsGroup.tsx +65 -0
- package/src/components/panels/nodeInputs/SocketGenerators.tsx +32 -0
- package/src/components/panels/nodeInputs/index.module.css +284 -0
- package/src/components/panels/nodeInputs/index.tsx +339 -0
- package/src/components/panels/nodeInputs/useNodeHandlers.ts +76 -0
- package/src/components/panels/nodeInputs/useNodeInputsData.ts +173 -0
- package/src/components/panels/nodePicker/index.tsx +115 -0
- package/src/components/panels/panel/index.module.css +66 -0
- package/src/components/panels/panel/index.tsx +88 -0
- package/src/components/panels/search/index.module.css +66 -0
- package/src/components/panels/search/index.tsx +215 -0
- package/src/components/panels/systemSettings/index.tsx +206 -0
- package/src/components/panels/systemSettings/styles.module.css +11 -0
- package/src/components/panels/traces/GridLines.tsx +38 -0
- package/src/components/panels/traces/TimeGrid.tsx +48 -0
- package/src/components/panels/traces/TraceLane.tsx +62 -0
- package/src/components/panels/traces/TraceTooltip.tsx +22 -0
- package/src/components/panels/traces/TracesHeader.tsx +56 -0
- package/src/components/panels/traces/index.module.css +166 -0
- package/src/components/panels/traces/index.tsx +294 -0
- package/src/components/panels/traces/types.ts +48 -0
- package/src/components/panels/traces/useDerivedSpans.ts +212 -0
- package/src/components/panels/traces/utils.ts +25 -0
- package/src/components/panels/variables/CreateVariableScreen.tsx +162 -0
- package/src/components/panels/variables/ManageVariablesScreen.tsx +144 -0
- package/src/components/panels/variables/index.tsx +125 -0
- package/src/components/panels/variables/styles.module.css +236 -0
- package/src/components/primitives/icon.module.css +45 -0
- package/src/components/primitives/icon.tsx +38 -0
- package/src/components/sockets/input/index.tsx +76 -0
- package/src/components/sockets/input/styles.module.css +27 -0
- package/src/components/sockets/output/index.tsx +61 -0
- package/src/components/sockets/output/styles.module.css +27 -0
- package/src/css/prosemirror.css +57 -0
- package/src/css/rc-dock.css +112 -0
- package/src/css/rc-menu.css +100 -0
- package/src/css/vars.css +14 -0
- package/src/css/vscode.css +13 -0
- package/src/entry.css +4 -0
- package/src/generators/CustomEventOnTriggeredGenerator.tsx +85 -0
- package/src/generators/SequenceGenerator.tsx +104 -0
- package/src/generators/SwitchOnIntegerGenerator.tsx +256 -0
- package/src/generators/SwitchOnStringGenerator.tsx +263 -0
- package/src/generators/registerDefaultGenerators.ts +34 -0
- package/src/hooks/useBehaveGraphFlow.ts +17 -16
- package/src/hooks/useDetachNodes.ts +39 -0
- package/src/hooks/useFlowHandlers.ts +115 -29
- package/src/hooks/useWasdPan.ts +188 -0
- package/src/index.css +146 -0
- package/src/index.ts +36 -18
- package/src/layout/dagre.tsx +119 -0
- package/src/layout/elk.ts +200 -0
- package/src/plugin/alignment/index.ts +81 -0
- package/src/plugin/docs/index.tsx +299 -0
- package/src/plugin/docs/panel/index.tsx +200 -0
- package/src/plugin/docs/panel/styles.module.css +174 -0
- package/src/plugin/graphrunner/actions.ts +253 -0
- package/src/plugin/graphrunner/buttons.tsx +87 -0
- package/src/plugin/graphrunner/client.ts +704 -0
- package/src/plugin/graphrunner/index.tsx +255 -0
- package/src/plugin/graphrunner/panel.tsx +386 -0
- package/src/plugin/graphrunner/runner.ts +358 -0
- package/src/plugin/graphrunner/session.ts +243 -0
- package/src/plugin/graphrunner/store.ts +206 -0
- package/src/plugin/graphrunner/styles.module.css +211 -0
- package/src/plugin/graphrunner/transport.ts +224 -0
- package/src/plugin/graphrunner/types.ts +672 -0
- package/src/plugin/graphrunner-local/execution-utils.ts +457 -0
- package/src/plugin/graphrunner-local/index.tsx +166 -0
- package/src/plugin/graphrunner-local/panel.tsx +231 -0
- package/src/plugin/graphrunner-local/store.ts +41 -0
- package/src/plugin/graphrunner-local/styles.module.css +101 -0
- package/src/plugin/graphrunner-local/transport.ts +1372 -0
- package/src/plugin/graphrunner-local/types.ts +10 -0
- package/src/plugin/graphrunner-webworker/graph-executor.worker.ts +633 -0
- package/src/plugin/graphrunner-webworker/index.tsx +146 -0
- package/src/plugin/graphrunner-webworker/panel.tsx +173 -0
- package/src/plugin/graphrunner-webworker/store.ts +89 -0
- package/src/plugin/graphrunner-webworker/types.ts +17 -0
- package/src/plugin/graphrunner-webworker/worker-transport.ts +123 -0
- package/src/plugin/realtime/realtimeRunner.ts +570 -0
- package/src/specifics/CustomEventOnTriggeredSpecific.tsx +92 -0
- package/src/specifics/CustomEventTriggerSpecific.tsx +141 -0
- package/src/specifics/VariableGetSpecific.tsx +110 -0
- package/src/specifics/VariableSetSpecific.tsx +110 -0
- package/src/specifics/registerDefaultSpecifics.ts +5 -0
- package/src/store/actions.tsx +698 -0
- package/src/store/chat.ts +73 -0
- package/src/store/controls.tsx +62 -0
- package/src/store/documentation.tsx +69 -0
- package/src/store/events.tsx +116 -0
- package/src/store/flow.tsx +245 -0
- package/src/store/graphRunnerClient.ts +110 -0
- package/src/store/hotKeys.tsx +323 -0
- package/src/store/layers.ts +259 -0
- package/src/store/legend.tsx +76 -0
- package/src/store/logs.ts +28 -0
- package/src/store/menubar.ts +41 -0
- package/src/store/refs.ts +84 -0
- package/src/store/registry.ts +43 -0
- package/src/store/selection.ts +22 -0
- package/src/store/settings.ts +99 -0
- package/src/store/socketGenerator.tsx +54 -0
- package/src/store/specific.tsx +75 -0
- package/src/store/specs.tsx +35 -0
- package/src/store/tabs.ts +278 -0
- package/src/store/toolbar.tsx +45 -0
- package/src/store/traces.ts +240 -0
- package/src/store/variables.ts +37 -0
- package/src/system/graph.ts +134 -0
- package/src/system/index.ts +3 -0
- package/src/system/notifications.ts +98 -0
- package/src/system/plugin.ts +27 -0
- package/src/system/provider.tsx +22 -0
- package/src/system/pubsub.ts +323 -0
- package/src/system/system.ts +223 -0
- package/src/system/tabLoader.tsx +265 -0
- package/src/system/undoRedo.ts +103 -0
- package/src/transformers/Uigraph.ts +60 -0
- package/src/transformers/behaveToFlow.ts +16 -4
- package/src/transformers/flowToBehave.ts +32 -12
- package/src/types/NodeMetadata.ts +27 -0
- package/src/types/graph.ts +49 -0
- package/src/types/nodes.ts +45 -0
- package/src/types.ts +16 -0
- package/src/util/colors.ts +1 -29
- package/src/util/downloadJson.ts +18 -0
- package/src/util/extractNodeMetadata.ts +16 -0
- package/src/util/getPickerFilters.ts +1 -1
- package/src/util/isBehaveNode.ts +6 -0
- package/src/util/isValidConnection.ts +28 -15
- package/src/util/mergeSockets.ts +29 -0
- package/src/util/serializeVariables.ts +66 -0
- package/src/util/sockets.ts +43 -0
- package/stories/apex/layoutController/example-graph.worker.ts +39 -0
- package/stories/apex/layoutController/index.stories.tsx +48 -0
- package/stories/apex/layoutController/webworker.stories.tsx +103 -0
- package/stories/apex/menubar/menubar.stories.tsx +19 -0
- package/stories/components/colorpicker/index.stories.tsx +20 -0
- package/stories/components/contextMenus/edge.stories.tsx +32 -0
- package/stories/components/contextMenus/node.stories.tsx +26 -0
- package/stories/components/contextMenus/nodePicker.stories.tsx +115 -0
- package/stories/components/controls/any/index.stories.tsx +19 -0
- package/stories/components/controls/boolean/index.stories.tsx +19 -0
- package/stories/components/controls/colorPicker/index.stories.tsx +49 -0
- package/stories/components/controls/number/index.stories.tsx +19 -0
- package/stories/components/controls/string/index.stories.tsx +19 -0
- package/stories/components/nodes/behaveNode.stories.tsx +108 -0
- package/stories/components/nodes/comment.stories.tsx +106 -0
- package/stories/components/panels/alignment.stories.tsx +24 -0
- package/stories/components/panels/events.stories.tsx +38 -0
- package/stories/components/panels/graphRunner.stories.tsx +317 -0
- package/stories/components/panels/history.stories.tsx +37 -0
- package/stories/components/panels/keymaps.stories.tsx +21 -0
- package/stories/components/panels/legend.stories.tsx +37 -0
- package/stories/components/panels/logs.stories.tsx +24 -0
- package/stories/components/panels/nodeInputs.stories.tsx +21 -0
- package/stories/components/panels/nodePicker.stories.tsx +37 -0
- package/stories/components/panels/panel.stories.tsx +39 -0
- package/stories/components/panels/search.stories.tsx +24 -0
- package/stories/components/panels/systemSettings.stories.tsx +26 -0
- package/stories/components/panels/traces.stories.tsx +225 -0
- package/stories/components/panels/variables.stories.tsx +24 -0
- package/stories/defaults/defaultStoryProvider.tsx +167 -0
- package/stories/defaults/systemGenerator.ts +38 -0
- package/tests/components/edges/offsetBezier.test.ts +51 -0
- package/tests/components/layoutController/utils.test.ts +68 -0
- package/tests/components/panels/traces/utils.test.ts +52 -0
- package/tests/flowToBehave.test.ts +26 -4
- package/tests/notifications.test.ts +87 -0
- package/tests/saveLoad.test.ts +372 -0
- package/tests/util/calculateNewEdge.test.ts +98 -0
- package/tests/util/getSocketsByNodeTypeAndHandleType.test.ts +31 -0
- package/tests/util/hasPositionMetaData.test.ts +33 -0
- package/tests/util/isBehaveNode.test.ts +22 -0
- package/tests/util/isHandleConnected.test.ts +37 -0
- package/tests/util/mergeSockets.test.ts +43 -0
- package/tests/visual/README.md +64 -0
- package/tests/visual/__screenshots__/panels.visual.test.tsx/panel-alignment-chromium-win32.png +0 -0
- package/tests/visual/__screenshots__/panels.visual.test.tsx/panel-conversation-chromium-win32.png +0 -0
- package/tests/visual/__screenshots__/panels.visual.test.tsx/panel-events-chromium-win32.png +0 -0
- package/tests/visual/__screenshots__/panels.visual.test.tsx/panel-history-chromium-win32.png +0 -0
- package/tests/visual/__screenshots__/panels.visual.test.tsx/panel-keymaps-chromium-win32.png +0 -0
- package/tests/visual/__screenshots__/panels.visual.test.tsx/panel-layers-chromium-win32.png +0 -0
- package/tests/visual/__screenshots__/panels.visual.test.tsx/panel-legend-chromium-win32.png +0 -0
- package/tests/visual/__screenshots__/panels.visual.test.tsx/panel-logs-chromium-win32.png +0 -0
- package/tests/visual/__screenshots__/panels.visual.test.tsx/panel-nodeInputs-chromium-win32.png +0 -0
- package/tests/visual/__screenshots__/panels.visual.test.tsx/panel-nodePicker-chromium-win32.png +0 -0
- package/tests/visual/__screenshots__/panels.visual.test.tsx/panel-panel-chromium-win32.png +0 -0
- package/tests/visual/__screenshots__/panels.visual.test.tsx/panel-search-chromium-win32.png +0 -0
- package/tests/visual/__screenshots__/panels.visual.test.tsx/panel-systemSettings-chromium-win32.png +0 -0
- package/tests/visual/__screenshots__/panels.visual.test.tsx/panel-traces-chromium-win32.png +0 -0
- package/tests/visual/__screenshots__/panels.visual.test.tsx/panel-variables-chromium-win32.png +0 -0
- package/tests/visual/panels.visual.test.tsx +76 -0
- package/tsconfig.base.json +39 -0
- package/tsconfig.json +18 -59
- package/tsconfig.prod.json +23 -0
- package/tsdown.config.ts +15 -3
- package/typedoc.json +7 -7
- package/vite.config.js +7 -0
- package/vitest.config.ts +5 -2
- package/vitest.visual.config.ts +48 -0
- package/src/components/AutoSizeInput.tsx +0 -65
- package/src/components/Controls.tsx +0 -87
- package/src/components/InputSocket.tsx +0 -142
- package/src/components/Node.tsx +0 -68
- package/src/components/NodeContainer.tsx +0 -46
- package/src/components/NodePicker.tsx +0 -77
- package/src/components/OutputSocket.tsx +0 -58
- package/src/components/modals/ClearModal.tsx +0 -40
- package/src/components/modals/HelpModal.tsx +0 -36
- package/src/components/modals/LoadModal.tsx +0 -96
- package/src/components/modals/Modal.tsx +0 -64
- package/src/components/modals/SaveModal.tsx +0 -60
- package/src/hooks/useCustomNodeTypes.tsx +0 -31
- package/src/hooks/useGraphRunner.ts +0 -104
- package/src/hooks/useMergeMap.ts +0 -14
- package/src/hooks/useNodeSpecJson.ts +0 -20
- package/src/hooks/useQueriableDefinitions.ts +0 -22
- package/src/styles.css +0 -8
- package/tailwind.config.ts +0 -19
- package/tests/tsconfig.json +0 -10
- /package/src/{types.d.ts → types-declarations.d.ts} +0 -0
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
import { applyDagreLayout } from '@/layout/dagre';
|
|
2
|
+
import { applyElkLayout } from '@/layout/elk';
|
|
3
|
+
import type { System } from '@/system';
|
|
4
|
+
import { create } from 'zustand';
|
|
5
|
+
|
|
6
|
+
type Handler = (e?: KeyboardEvent) => any;
|
|
7
|
+
|
|
8
|
+
export type HotkeyStore = {
|
|
9
|
+
keymap: Record<string, string | string[]>;
|
|
10
|
+
handlers: Record<string, Handler>;
|
|
11
|
+
descriptions: Record<string, string>;
|
|
12
|
+
register(val: {
|
|
13
|
+
action: string;
|
|
14
|
+
trigger: string | string[];
|
|
15
|
+
description?: string;
|
|
16
|
+
handler?: Handler;
|
|
17
|
+
}): void;
|
|
18
|
+
registerDescription(action: string, description: string): void;
|
|
19
|
+
registerHandler(action: string, handler: Handler): void;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const hotKeyStoreFactory = (sys: System) =>
|
|
23
|
+
create<HotkeyStore>((set) => ({
|
|
24
|
+
keymap: {
|
|
25
|
+
SELECT_ALL: 'ctrl+a',
|
|
26
|
+
DUPLICATE: ['command+d', 'ctrl+d'],
|
|
27
|
+
GROUP: 'ctrl+g',
|
|
28
|
+
SAVE: 'ctrl+s',
|
|
29
|
+
FIND: ['ctrl+f', 'command+f'],
|
|
30
|
+
AUTO_LAYOUT: 'shift+alt+f',
|
|
31
|
+
COPY: ['command+c', 'ctrl+c'],
|
|
32
|
+
PASTE: ['command+v', 'ctrl+v'],
|
|
33
|
+
DELETE: ['delete', 'del', 'backspace'],
|
|
34
|
+
UNDO: ['command+z', 'ctrl+z'],
|
|
35
|
+
REDO: ['command+shift+z', 'ctrl+shift+z'],
|
|
36
|
+
SAVE_VIEWPORT: [
|
|
37
|
+
'command+1',
|
|
38
|
+
'command+2',
|
|
39
|
+
'command+3',
|
|
40
|
+
'command+4',
|
|
41
|
+
'command+5',
|
|
42
|
+
'command+6',
|
|
43
|
+
'command+7',
|
|
44
|
+
'command+8',
|
|
45
|
+
'command+9',
|
|
46
|
+
'ctrl+1',
|
|
47
|
+
'ctrl+2',
|
|
48
|
+
'ctrl+3',
|
|
49
|
+
'ctrl+4',
|
|
50
|
+
'ctrl+5',
|
|
51
|
+
'ctrl+6',
|
|
52
|
+
'ctrl+7',
|
|
53
|
+
'ctrl+8',
|
|
54
|
+
'ctrl+9'
|
|
55
|
+
],
|
|
56
|
+
RECALL_VIEWPORT: ['1', '2', '3', '4', '5', '6', '7', '8', '9'],
|
|
57
|
+
ZOOM_IN: ['ctrl+plus', 'command+plus'],
|
|
58
|
+
ZOOM_OUT: ['command+-', 'ctrl+-'],
|
|
59
|
+
ZOOM_RESET: 'ctrl+0',
|
|
60
|
+
TOGGLE_GRID: ['command+shift+g', 'ctrl+shift+g'],
|
|
61
|
+
TOGGLE_MINIMAP: ['command+shift+m', 'ctrl+shift+m'],
|
|
62
|
+
TOGGLE_SNAP_GRID: ['command+shift+s', 'ctrl+shift+s'],
|
|
63
|
+
FIT_VIEW: ['f'],
|
|
64
|
+
TRACE_DOWNSTREAM: 'ctrl+shift+right',
|
|
65
|
+
TRACE_UPSTREAM: 'ctrl+shift+left'
|
|
66
|
+
},
|
|
67
|
+
descriptions: {
|
|
68
|
+
TRACE_DOWNSTREAM: 'Trace Downstream',
|
|
69
|
+
TRACE_UPSTREAM: 'Trace Upstream',
|
|
70
|
+
AUTO_LAYOUT: 'Auto Layout',
|
|
71
|
+
COPY: 'Copy',
|
|
72
|
+
PASTE: 'Paste',
|
|
73
|
+
DELETE: 'Delete',
|
|
74
|
+
UNDO: 'Undo',
|
|
75
|
+
REDO: 'Redo',
|
|
76
|
+
SELECT_ALL: 'Select All',
|
|
77
|
+
DUPLICATE: 'Duplicate',
|
|
78
|
+
GROUP: 'Group',
|
|
79
|
+
SAVE: 'Save',
|
|
80
|
+
FIND: 'Find',
|
|
81
|
+
FIT_VIEW: 'Fit View',
|
|
82
|
+
ZOOM_IN: 'Zoom In',
|
|
83
|
+
ZOOM_OUT: 'Zoom Out',
|
|
84
|
+
ZOOM_RESET: 'Zoom Reset',
|
|
85
|
+
TOGGLE_GRID: 'Toggle Grid',
|
|
86
|
+
TOGGLE_MINIMAP: 'Toggle Minimap',
|
|
87
|
+
TOGGLE_SNAP_GRID: 'Toggle Snap Grid',
|
|
88
|
+
SAVE_VIEWPORT: 'Save Viewport',
|
|
89
|
+
RECALL_VIEWPORT: 'Recall Viewport'
|
|
90
|
+
},
|
|
91
|
+
handlers: {
|
|
92
|
+
SAVE: (event) => {
|
|
93
|
+
if (event) {
|
|
94
|
+
event.preventDefault();
|
|
95
|
+
event.stopPropagation();
|
|
96
|
+
}
|
|
97
|
+
sys.actionStore.getState().actions.save();
|
|
98
|
+
},
|
|
99
|
+
|
|
100
|
+
GROUP: () => {
|
|
101
|
+
sys.actionStore.getState().actions.groupNodes();
|
|
102
|
+
},
|
|
103
|
+
|
|
104
|
+
COPY: (event) => {
|
|
105
|
+
if (event) {
|
|
106
|
+
event.preventDefault();
|
|
107
|
+
event.stopPropagation();
|
|
108
|
+
}
|
|
109
|
+
sys.actionStore.getState().actions.copySelectionToClipboard();
|
|
110
|
+
},
|
|
111
|
+
PASTE: async (event) => {
|
|
112
|
+
if (event) {
|
|
113
|
+
event.preventDefault();
|
|
114
|
+
event.stopPropagation();
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
await sys.actionStore.getState().actions.pasteFromClipboard();
|
|
118
|
+
},
|
|
119
|
+
TRACE_UPSTREAM: (event) => {
|
|
120
|
+
if (event) {
|
|
121
|
+
event.preventDefault();
|
|
122
|
+
event.stopPropagation();
|
|
123
|
+
const selection = sys.selectionStore.getState().selectedNodeId;
|
|
124
|
+
if (!selection) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
sys.actionStore.getState().actions.traceUpstream(selection);
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
TRACE_DOWNSTREAM: (event) => {
|
|
131
|
+
if (event) {
|
|
132
|
+
event.preventDefault();
|
|
133
|
+
event.stopPropagation();
|
|
134
|
+
const selection = sys.selectionStore.getState().selectedNodeId;
|
|
135
|
+
if (!selection) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
sys.actionStore.getState().actions.traceDownstream(selection);
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
FIT_VIEW: (event) => {
|
|
142
|
+
if (event) {
|
|
143
|
+
event.preventDefault();
|
|
144
|
+
const reactFlowInstance = sys.refStore.getState().getRef('reactflow');
|
|
145
|
+
reactFlowInstance?.fitView({
|
|
146
|
+
padding: 0.2,
|
|
147
|
+
includeHiddenNodes: true
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
|
|
152
|
+
TOGGLE_SNAP_GRID: (event) => {
|
|
153
|
+
if (event) {
|
|
154
|
+
event.preventDefault();
|
|
155
|
+
const settings = sys.systemSettings.getState();
|
|
156
|
+
settings.setSnapGrid(!settings.snapGrid);
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
TOGGLE_GRID: (event) => {
|
|
160
|
+
if (event) {
|
|
161
|
+
event.preventDefault();
|
|
162
|
+
const settings = sys.systemSettings.getState();
|
|
163
|
+
settings.setShowGrid(!settings.showGrid);
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
SAVE_VIEWPORT: (event) => {
|
|
167
|
+
if (event) {
|
|
168
|
+
event?.preventDefault();
|
|
169
|
+
const reactFlowInstance = sys.refStore.getState().getRef('reactflow');
|
|
170
|
+
const graph = sys.graph;
|
|
171
|
+
if (reactFlowInstance) {
|
|
172
|
+
const currentViewport = reactFlowInstance.getViewport();
|
|
173
|
+
const key = event.key; // Get pressed key (e.g., '1', '2', etc.)
|
|
174
|
+
const viewportIndex = parseInt(key) - 1; // Calculate 0-based index
|
|
175
|
+
|
|
176
|
+
if (viewportIndex >= 0 && viewportIndex < 9) {
|
|
177
|
+
graph.setViewport(viewportIndex, currentViewport);
|
|
178
|
+
sys.notifications.info(`Saved viewport ${viewportIndex + 1}`);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
RECALL_VIEWPORT: (event) => {
|
|
184
|
+
if (event) {
|
|
185
|
+
event.preventDefault();
|
|
186
|
+
const key = event.key;
|
|
187
|
+
const graph = sys.graph;
|
|
188
|
+
const reactFlowInstance = sys.refStore.getState().getRef('reactflow');
|
|
189
|
+
|
|
190
|
+
const viewportIndex = parseInt(key) - 1;
|
|
191
|
+
|
|
192
|
+
if (viewportIndex >= 0 && viewportIndex < 9 && reactFlowInstance) {
|
|
193
|
+
const viewport = graph.viewports[viewportIndex];
|
|
194
|
+
if (!viewport) {
|
|
195
|
+
sys.pubsub.publish('missingViewPort', {
|
|
196
|
+
index: viewportIndex
|
|
197
|
+
});
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
reactFlowInstance.setViewport(viewport);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
SELECT_ALL: (event) => {
|
|
205
|
+
if (event) {
|
|
206
|
+
event.stopPropagation();
|
|
207
|
+
event.preventDefault();
|
|
208
|
+
sys.nodeStore.getState().setNodes((nodes) => {
|
|
209
|
+
return nodes.map((x) => {
|
|
210
|
+
return {
|
|
211
|
+
...x,
|
|
212
|
+
selected: true
|
|
213
|
+
};
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
ZOOM_IN: (event) => {
|
|
219
|
+
if (event) {
|
|
220
|
+
event.stopPropagation();
|
|
221
|
+
event.preventDefault();
|
|
222
|
+
sys.refStore
|
|
223
|
+
.getState()
|
|
224
|
+
.getRef('reactflow')
|
|
225
|
+
?.zoomIn({ duration: 300 });
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
ZOOM_OUT: (event) => {
|
|
229
|
+
if (event) {
|
|
230
|
+
event.preventDefault();
|
|
231
|
+
event.stopPropagation();
|
|
232
|
+
sys.refStore
|
|
233
|
+
.getState()
|
|
234
|
+
.getRef('reactflow')
|
|
235
|
+
?.zoomOut({ duration: 300 });
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
RESET_ZOOM: (event) => {
|
|
239
|
+
if (event) {
|
|
240
|
+
event.preventDefault();
|
|
241
|
+
event.stopPropagation();
|
|
242
|
+
const reactflow = sys.refStore.getState().getRef('reactflow');
|
|
243
|
+
|
|
244
|
+
if (!reactflow) return;
|
|
245
|
+
|
|
246
|
+
const existing = reactflow.getViewport();
|
|
247
|
+
reactflow.setViewport({ ...existing, zoom: 1 });
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
AUTO_LAYOUT: (event) => {
|
|
251
|
+
if (event) {
|
|
252
|
+
event.preventDefault();
|
|
253
|
+
event.stopPropagation();
|
|
254
|
+
|
|
255
|
+
switch (sys.systemSettings.getState().layoutType) {
|
|
256
|
+
case 'Dagre':
|
|
257
|
+
applyDagreLayout(sys);
|
|
258
|
+
break;
|
|
259
|
+
case 'Elk - Layered':
|
|
260
|
+
applyElkLayout(sys, 'org.eclipse.elk.layered');
|
|
261
|
+
break;
|
|
262
|
+
case 'Elk - Force':
|
|
263
|
+
applyElkLayout(sys, 'org.eclipse.elk.force');
|
|
264
|
+
break;
|
|
265
|
+
case 'Elk - Rect':
|
|
266
|
+
applyElkLayout(sys, 'org.eclipse.elk.rectpacking');
|
|
267
|
+
break;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
UNDO: (event) => {
|
|
272
|
+
if (event) {
|
|
273
|
+
event.preventDefault();
|
|
274
|
+
sys.undoManager.undo();
|
|
275
|
+
}
|
|
276
|
+
},
|
|
277
|
+
REDO: (event) => {
|
|
278
|
+
if (event) {
|
|
279
|
+
event.preventDefault();
|
|
280
|
+
sys.undoManager.redo();
|
|
281
|
+
}
|
|
282
|
+
},
|
|
283
|
+
FIND: (event) => {
|
|
284
|
+
if (event) {
|
|
285
|
+
event.preventDefault();
|
|
286
|
+
sys.tabStore.getState().openTab('find');
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
},
|
|
290
|
+
|
|
291
|
+
register(val) {
|
|
292
|
+
set((s) => ({
|
|
293
|
+
handlers: {
|
|
294
|
+
...s.handlers,
|
|
295
|
+
...(val.handler ? { [val.action]: val.handler } : {})
|
|
296
|
+
},
|
|
297
|
+
keymap: {
|
|
298
|
+
...s.keymap,
|
|
299
|
+
[val.action]: val.trigger
|
|
300
|
+
},
|
|
301
|
+
descriptions: {
|
|
302
|
+
...s.descriptions,
|
|
303
|
+
...(val.description ? { [val.action]: val.description } : {})
|
|
304
|
+
}
|
|
305
|
+
}));
|
|
306
|
+
},
|
|
307
|
+
registerHandler(name, handler) {
|
|
308
|
+
set((s) => ({
|
|
309
|
+
handlers: {
|
|
310
|
+
...s.handlers,
|
|
311
|
+
[name]: handler
|
|
312
|
+
}
|
|
313
|
+
}));
|
|
314
|
+
},
|
|
315
|
+
registerDescription(name, desc) {
|
|
316
|
+
set((s) => ({
|
|
317
|
+
descriptions: {
|
|
318
|
+
...s.descriptions,
|
|
319
|
+
[name]: desc
|
|
320
|
+
}
|
|
321
|
+
}));
|
|
322
|
+
}
|
|
323
|
+
}));
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import type { System } from '@/system';
|
|
2
|
+
import { create } from 'zustand';
|
|
3
|
+
|
|
4
|
+
const DEFAULT_LAYER_ID = 'default';
|
|
5
|
+
const DEFAULT_LAYER_NAME = 'Default';
|
|
6
|
+
|
|
7
|
+
export type Layer = {
|
|
8
|
+
id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
visible: boolean;
|
|
11
|
+
opacity: number;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type SerializedLayers = {
|
|
15
|
+
defaultLayerId: string;
|
|
16
|
+
layers: Layer[];
|
|
17
|
+
nodeLayers: Record<string, string>;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type LayerStore = {
|
|
21
|
+
defaultLayerId: string;
|
|
22
|
+
layers: Record<string, Layer>;
|
|
23
|
+
nodeLayers: Record<string, string>;
|
|
24
|
+
createLayer: (name: string) => string;
|
|
25
|
+
renameLayer: (layerId: string, name: string) => void;
|
|
26
|
+
setLayerVisibility: (layerId: string, visible: boolean) => void;
|
|
27
|
+
setLayerOpacity: (layerId: string, opacity: number) => void;
|
|
28
|
+
removeLayer: (layerId: string) => void;
|
|
29
|
+
setNodeLayer: (nodeId: string, layerId: string) => void;
|
|
30
|
+
clearNodeLayer: (nodeId: string) => void;
|
|
31
|
+
getNodeLayer: (nodeId: string) => Layer;
|
|
32
|
+
serialize: () => SerializedLayers;
|
|
33
|
+
deserialize: (serialized?: SerializedLayers) => void;
|
|
34
|
+
pruneNodeAssignments: (nodeIds: string[]) => void;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const clampOpacity = (opacity: number): number => {
|
|
38
|
+
if (Number.isNaN(opacity)) return 1;
|
|
39
|
+
return Math.max(0, Math.min(1, opacity));
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const createDefaultLayer = (): Layer => ({
|
|
43
|
+
id: DEFAULT_LAYER_ID,
|
|
44
|
+
name: DEFAULT_LAYER_NAME,
|
|
45
|
+
visible: true,
|
|
46
|
+
opacity: 1
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const createLayerId = (): string => {
|
|
50
|
+
const suffix = Math.random().toString(36).slice(2, 8);
|
|
51
|
+
return `layer-${Date.now()}-${suffix}`;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const layerStoreFactory = (system: System) => {
|
|
55
|
+
const store = create<LayerStore>((set, get) => ({
|
|
56
|
+
defaultLayerId: DEFAULT_LAYER_ID,
|
|
57
|
+
layers: {
|
|
58
|
+
[DEFAULT_LAYER_ID]: createDefaultLayer()
|
|
59
|
+
},
|
|
60
|
+
nodeLayers: {},
|
|
61
|
+
|
|
62
|
+
createLayer: (name) => {
|
|
63
|
+
const normalized = name.trim() || 'Layer';
|
|
64
|
+
const id = createLayerId();
|
|
65
|
+
set((state) => ({
|
|
66
|
+
layers: {
|
|
67
|
+
...state.layers,
|
|
68
|
+
[id]: {
|
|
69
|
+
id,
|
|
70
|
+
name: normalized,
|
|
71
|
+
visible: true,
|
|
72
|
+
opacity: 1
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}));
|
|
76
|
+
return id;
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
renameLayer: (layerId, name) => {
|
|
80
|
+
const normalized = name.trim();
|
|
81
|
+
if (!normalized) return;
|
|
82
|
+
set((state) => {
|
|
83
|
+
const existing = state.layers[layerId];
|
|
84
|
+
if (!existing) return state;
|
|
85
|
+
return {
|
|
86
|
+
layers: {
|
|
87
|
+
...state.layers,
|
|
88
|
+
[layerId]: {
|
|
89
|
+
...existing,
|
|
90
|
+
name: normalized
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
});
|
|
95
|
+
},
|
|
96
|
+
|
|
97
|
+
setLayerVisibility: (layerId, visible) => {
|
|
98
|
+
set((state) => {
|
|
99
|
+
const existing = state.layers[layerId];
|
|
100
|
+
if (!existing) return state;
|
|
101
|
+
return {
|
|
102
|
+
layers: {
|
|
103
|
+
...state.layers,
|
|
104
|
+
[layerId]: {
|
|
105
|
+
...existing,
|
|
106
|
+
visible
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
});
|
|
111
|
+
},
|
|
112
|
+
|
|
113
|
+
setLayerOpacity: (layerId, opacity) => {
|
|
114
|
+
const safeOpacity = clampOpacity(opacity);
|
|
115
|
+
set((state) => {
|
|
116
|
+
const existing = state.layers[layerId];
|
|
117
|
+
if (!existing) return state;
|
|
118
|
+
return {
|
|
119
|
+
layers: {
|
|
120
|
+
...state.layers,
|
|
121
|
+
[layerId]: {
|
|
122
|
+
...existing,
|
|
123
|
+
opacity: safeOpacity
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
});
|
|
128
|
+
},
|
|
129
|
+
|
|
130
|
+
removeLayer: (layerId) => {
|
|
131
|
+
set((state) => {
|
|
132
|
+
if (layerId === state.defaultLayerId) return state;
|
|
133
|
+
if (!state.layers[layerId]) return state;
|
|
134
|
+
|
|
135
|
+
const nextLayers = { ...state.layers };
|
|
136
|
+
delete nextLayers[layerId];
|
|
137
|
+
|
|
138
|
+
const nextNodeLayers: Record<string, string> = {};
|
|
139
|
+
Object.entries(state.nodeLayers).forEach(([nodeId, mappedLayerId]) => {
|
|
140
|
+
nextNodeLayers[nodeId] =
|
|
141
|
+
mappedLayerId === layerId ? state.defaultLayerId : mappedLayerId;
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
return {
|
|
145
|
+
layers: nextLayers,
|
|
146
|
+
nodeLayers: nextNodeLayers
|
|
147
|
+
};
|
|
148
|
+
});
|
|
149
|
+
},
|
|
150
|
+
|
|
151
|
+
setNodeLayer: (nodeId, layerId) => {
|
|
152
|
+
set((state) => {
|
|
153
|
+
const resolvedLayerId = state.layers[layerId]
|
|
154
|
+
? layerId
|
|
155
|
+
: state.defaultLayerId;
|
|
156
|
+
|
|
157
|
+
return {
|
|
158
|
+
nodeLayers: {
|
|
159
|
+
...state.nodeLayers,
|
|
160
|
+
[nodeId]: resolvedLayerId
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
});
|
|
164
|
+
},
|
|
165
|
+
|
|
166
|
+
clearNodeLayer: (nodeId) => {
|
|
167
|
+
set((state) => {
|
|
168
|
+
const next = { ...state.nodeLayers };
|
|
169
|
+
delete next[nodeId];
|
|
170
|
+
return {
|
|
171
|
+
nodeLayers: next
|
|
172
|
+
};
|
|
173
|
+
});
|
|
174
|
+
},
|
|
175
|
+
|
|
176
|
+
getNodeLayer: (nodeId) => {
|
|
177
|
+
const state = get();
|
|
178
|
+
const mappedLayerId = state.nodeLayers[nodeId] ?? state.defaultLayerId;
|
|
179
|
+
return state.layers[mappedLayerId] ?? state.layers[state.defaultLayerId]!;
|
|
180
|
+
},
|
|
181
|
+
|
|
182
|
+
serialize: () => {
|
|
183
|
+
const state = get();
|
|
184
|
+
return {
|
|
185
|
+
defaultLayerId: state.defaultLayerId,
|
|
186
|
+
layers: Object.values(state.layers),
|
|
187
|
+
nodeLayers: { ...state.nodeLayers }
|
|
188
|
+
};
|
|
189
|
+
},
|
|
190
|
+
|
|
191
|
+
deserialize: (serialized) => {
|
|
192
|
+
const baseDefaultLayer = createDefaultLayer();
|
|
193
|
+
if (!serialized) {
|
|
194
|
+
set({
|
|
195
|
+
defaultLayerId: DEFAULT_LAYER_ID,
|
|
196
|
+
layers: { [DEFAULT_LAYER_ID]: baseDefaultLayer },
|
|
197
|
+
nodeLayers: {}
|
|
198
|
+
});
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
const requestedDefault = serialized.defaultLayerId || DEFAULT_LAYER_ID;
|
|
203
|
+
const nextLayers: Record<string, Layer> = {
|
|
204
|
+
[DEFAULT_LAYER_ID]: baseDefaultLayer
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
for (const candidate of serialized.layers ?? []) {
|
|
208
|
+
if (!candidate?.id) continue;
|
|
209
|
+
nextLayers[candidate.id] = {
|
|
210
|
+
id: candidate.id,
|
|
211
|
+
name: candidate.name?.trim() || candidate.id,
|
|
212
|
+
visible: candidate.visible !== false,
|
|
213
|
+
opacity: clampOpacity(candidate.opacity)
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const defaultLayerId = nextLayers[requestedDefault]
|
|
218
|
+
? requestedDefault
|
|
219
|
+
: DEFAULT_LAYER_ID;
|
|
220
|
+
|
|
221
|
+
const nextNodeLayers: Record<string, string> = {};
|
|
222
|
+
Object.entries(serialized.nodeLayers ?? {}).forEach(
|
|
223
|
+
([nodeId, mapped]) => {
|
|
224
|
+
nextNodeLayers[nodeId] = nextLayers[mapped] ? mapped : defaultLayerId;
|
|
225
|
+
}
|
|
226
|
+
);
|
|
227
|
+
|
|
228
|
+
set({
|
|
229
|
+
defaultLayerId,
|
|
230
|
+
layers: nextLayers,
|
|
231
|
+
nodeLayers: nextNodeLayers
|
|
232
|
+
});
|
|
233
|
+
},
|
|
234
|
+
|
|
235
|
+
pruneNodeAssignments: (nodeIds) => {
|
|
236
|
+
const valid = new Set(nodeIds);
|
|
237
|
+
set((state) => {
|
|
238
|
+
const nextNodeLayers: Record<string, string> = {};
|
|
239
|
+
Object.entries(state.nodeLayers).forEach(([nodeId, mapped]) => {
|
|
240
|
+
if (!valid.has(nodeId)) return;
|
|
241
|
+
nextNodeLayers[nodeId] = state.layers[mapped]
|
|
242
|
+
? mapped
|
|
243
|
+
: state.defaultLayerId;
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
return {
|
|
247
|
+
nodeLayers: nextNodeLayers
|
|
248
|
+
};
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
}));
|
|
252
|
+
|
|
253
|
+
system.nodeStore.subscribe((nodeState) => {
|
|
254
|
+
const nodeIds = nodeState.nodes.map((node) => node.id);
|
|
255
|
+
store.getState().pruneNodeAssignments(nodeIds);
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
return store;
|
|
259
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Cube,
|
|
3
|
+
Droplet,
|
|
4
|
+
EaseCurveControlPoints,
|
|
5
|
+
Hashtag,
|
|
6
|
+
InputOutput,
|
|
7
|
+
SelectPoint3d,
|
|
8
|
+
Text
|
|
9
|
+
} from 'iconoir-react';
|
|
10
|
+
import { create } from 'zustand';
|
|
11
|
+
|
|
12
|
+
export type LegendStore = {
|
|
13
|
+
icons: Record<string, React.ComponentType>;
|
|
14
|
+
defaultIcon: React.ComponentType;
|
|
15
|
+
valueTypeColors: Record<string, string>;
|
|
16
|
+
categoryColors: Record<string, string>;
|
|
17
|
+
setIcon: (key: string, icon: React.ComponentType) => void;
|
|
18
|
+
setValueTypeColor: (key: string, color: string) => void;
|
|
19
|
+
setCategoryColor: (key: string, color: string) => void;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const legendStoreFactory = () =>
|
|
23
|
+
create<LegendStore>((set) => ({
|
|
24
|
+
// store the component references (not instantiated elements)
|
|
25
|
+
defaultIcon: SelectPoint3d,
|
|
26
|
+
categoryColors: {
|
|
27
|
+
Event: '#f14445',
|
|
28
|
+
Logic: '#16a34a',
|
|
29
|
+
Variable: '#a855f7',
|
|
30
|
+
Query: '#a855f7',
|
|
31
|
+
Action: '#0891b2',
|
|
32
|
+
Flow: '#6c727e',
|
|
33
|
+
Effect: '#84cc16',
|
|
34
|
+
Time: '#6c727e',
|
|
35
|
+
None: '#6c727e'
|
|
36
|
+
},
|
|
37
|
+
valueTypeColors: {
|
|
38
|
+
flow: '#ffffff',
|
|
39
|
+
number: '#16a34a',
|
|
40
|
+
float: '#16a34a',
|
|
41
|
+
integer: '#84cc16',
|
|
42
|
+
boolean: '#0891b2',
|
|
43
|
+
string: '#a855f7',
|
|
44
|
+
object: '#f97316'
|
|
45
|
+
},
|
|
46
|
+
icons: {
|
|
47
|
+
color: Droplet,
|
|
48
|
+
curve: EaseCurveControlPoints,
|
|
49
|
+
string: Text,
|
|
50
|
+
boolean: InputOutput,
|
|
51
|
+
float: Hashtag,
|
|
52
|
+
integer: Hashtag,
|
|
53
|
+
object: Cube
|
|
54
|
+
},
|
|
55
|
+
setIcon: (key: string, icon: React.ComponentType) =>
|
|
56
|
+
set((state) => ({
|
|
57
|
+
icons: {
|
|
58
|
+
...state.icons,
|
|
59
|
+
[key]: icon
|
|
60
|
+
}
|
|
61
|
+
})),
|
|
62
|
+
setValueTypeColor: (key: string, color: string) =>
|
|
63
|
+
set((state) => ({
|
|
64
|
+
valueTypeColors: {
|
|
65
|
+
...state.valueTypeColors,
|
|
66
|
+
[key]: color
|
|
67
|
+
}
|
|
68
|
+
})),
|
|
69
|
+
setCategoryColor: (key: string, color: string) =>
|
|
70
|
+
set((state) => ({
|
|
71
|
+
categoryColors: {
|
|
72
|
+
...state.categoryColors,
|
|
73
|
+
[key]: color
|
|
74
|
+
}
|
|
75
|
+
}))
|
|
76
|
+
}));
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { LogSeverity } from '@kiberon-labs/behave-graph';
|
|
2
|
+
import { create } from 'zustand';
|
|
3
|
+
|
|
4
|
+
interface ILogMessage {
|
|
5
|
+
message: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface ILog {
|
|
9
|
+
data: ILogMessage;
|
|
10
|
+
time: Date;
|
|
11
|
+
type: LogSeverity;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type LogStore = {
|
|
15
|
+
logs: ILog[];
|
|
16
|
+
append: (log: ILog) => void;
|
|
17
|
+
clear: () => void;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const logStoreFactory = () =>
|
|
21
|
+
create<LogStore>((set) => ({
|
|
22
|
+
logs: [],
|
|
23
|
+
append: (log: ILog) =>
|
|
24
|
+
set((state) => {
|
|
25
|
+
return { logs: [...state.logs, log] };
|
|
26
|
+
}),
|
|
27
|
+
clear: () => set(() => ({ logs: [] }))
|
|
28
|
+
}));
|