@huanban/rulego-editor-core 1.3.18 → 1.4.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/README.md +153 -2
- package/assets/images/discovery-dark.svg +1 -0
- package/assets/images/discovery.svg +1 -0
- package/assets/images/nacos-dark.svg +1 -0
- package/assets/images/nacos.svg +1 -0
- package/assets/theme-icons/ant-blue/discovery-dark.svg +1 -0
- package/assets/theme-icons/ant-blue/discovery.svg +1 -0
- package/assets/theme-icons/ant-blue/nacos-dark.svg +1 -0
- package/assets/theme-icons/ant-blue/nacos.svg +1 -0
- package/assets/theme-icons/apple/discovery-dark.svg +1 -0
- package/assets/theme-icons/apple/discovery.svg +1 -0
- package/assets/theme-icons/apple/nacos-dark.svg +1 -0
- package/assets/theme-icons/apple/nacos.svg +1 -0
- package/assets/theme-icons/colorful/discovery-dark.svg +1 -0
- package/assets/theme-icons/colorful/discovery.svg +1 -0
- package/assets/theme-icons/colorful/nacos-dark.svg +1 -0
- package/assets/theme-icons/colorful/nacos.svg +1 -0
- package/assets/theme-icons/dark/discovery-dark.svg +1 -0
- package/assets/theme-icons/dark/discovery.svg +1 -0
- package/assets/theme-icons/dark/nacos-dark.svg +1 -0
- package/assets/theme-icons/dark/nacos.svg +1 -0
- package/assets/theme-icons/default/discovery-dark.svg +1 -0
- package/assets/theme-icons/default/discovery.svg +1 -0
- package/assets/theme-icons/default/nacos-dark.svg +1 -0
- package/assets/theme-icons/default/nacos.svg +1 -0
- package/assets/theme-icons/elegant/discovery-dark.svg +1 -0
- package/assets/theme-icons/elegant/discovery.svg +1 -0
- package/assets/theme-icons/elegant/nacos-dark.svg +1 -0
- package/assets/theme-icons/elegant/nacos.svg +1 -0
- package/assets/theme-icons/github/discovery-dark.svg +1 -0
- package/assets/theme-icons/github/discovery.svg +1 -0
- package/assets/theme-icons/github/nacos-dark.svg +1 -0
- package/assets/theme-icons/github/nacos.svg +1 -0
- package/assets/theme-icons/icon-theme-manifest.json +30 -14
- package/assets/theme-icons/icon-theme-overview.svg +1599 -1287
- package/assets/theme-icons/material/discovery-dark.svg +1 -0
- package/assets/theme-icons/material/discovery.svg +1 -0
- package/assets/theme-icons/material/nacos-dark.svg +1 -0
- package/assets/theme-icons/material/nacos.svg +1 -0
- package/assets/theme-icons/modern/discovery-dark.svg +1 -0
- package/assets/theme-icons/modern/discovery.svg +1 -0
- package/assets/theme-icons/modern/nacos-dark.svg +1 -0
- package/assets/theme-icons/modern/nacos.svg +1 -0
- package/assets/theme-icons/nature/discovery-dark.svg +1 -0
- package/assets/theme-icons/nature/discovery.svg +1 -0
- package/assets/theme-icons/nature/nacos-dark.svg +1 -0
- package/assets/theme-icons/nature/nacos.svg +1 -0
- package/assets/theme-icons/tailwind/discovery-dark.svg +1 -0
- package/assets/theme-icons/tailwind/discovery.svg +1 -0
- package/assets/theme-icons/tailwind/nacos-dark.svg +1 -0
- package/assets/theme-icons/tailwind/nacos.svg +1 -0
- package/assets/theme-icons/tech/discovery-dark.svg +1 -0
- package/assets/theme-icons/tech/discovery.svg +1 -0
- package/assets/theme-icons/tech/nacos-dark.svg +1 -0
- package/assets/theme-icons/tech/nacos.svg +1 -0
- package/assets/theme-icons/vscode/discovery-dark.svg +1 -0
- package/assets/theme-icons/vscode/discovery.svg +1 -0
- package/assets/theme-icons/vscode/nacos-dark.svg +1 -0
- package/assets/theme-icons/vscode/nacos.svg +1 -0
- package/dist/ai/copilot-markdown.d.ts +40 -0
- package/dist/ai/copilot-transport.d.ts +39 -0
- package/dist/api/AIManager.d.ts +5 -4
- package/dist/api/ApiProvider.d.ts +17 -69
- package/dist/api/ComponentCatalogCache.d.ts +27 -0
- package/dist/api/DebugSocketClient.d.ts +18 -25
- package/dist/api/RuleChainAPI.d.ts +24 -145
- package/dist/api/StreamParser.d.ts +0 -10
- package/dist/api/index.d.ts +4 -14
- package/dist/api/response-utils.d.ts +4 -22
- package/dist/api/types.d.ts +44 -179
- package/dist/chunks/editor-core-code-editor-CRki2wA_.js +512 -0
- package/dist/chunks/editor-core-default-components-BjF65lar.js +9448 -0
- package/dist/chunks/editor-core-dialogs-CkFLaC8Q.js +17176 -0
- package/dist/chunks/editor-core-icons-BqeFofNA.js +668 -0
- package/dist/chunks/editor-core-json-diff-RHsPeX-w.js +199 -0
- package/dist/chunks/editor-core-locales-i6o28vm2.js +4159 -0
- package/dist/chunks/editor-core-node-patches-BJTT3TuX.js +8060 -0
- package/dist/chunks/editor-core-node-views-BOaPVdmN.js +1288 -0
- package/dist/chunks/editor-core-property-drawers-lLsBIoCa.js +8035 -0
- package/dist/chunks/editor-core-standalone-CHXk3ukc.js +11270 -0
- package/dist/chunks/editor-core-styles-C1TbLgCK.js +8841 -0
- package/dist/chunks/vendor-logicflow-core-runtime-Cp6IBEjB.js +217 -0
- package/dist/chunks/vendor-logicflow-shared-C7YynLDn.js +4 -0
- package/dist/chunks/xlsx-BopDBbWb.js +24176 -0
- package/dist/core/ActionRegistry.d.ts +47 -0
- package/dist/core/AutoLayout.d.ts +1 -48
- package/dist/core/ComponentDocService.d.ts +28 -0
- package/dist/core/ComponentRegistry.d.ts +1 -125
- package/dist/core/DataAdapter.d.ts +4 -89
- package/dist/core/DiagnosticService.d.ts +15 -0
- package/dist/core/EditorCore.d.ts +22 -212
- package/dist/core/EditorWorkspace.d.ts +111 -0
- package/dist/core/EventBus.d.ts +0 -86
- package/dist/core/ExplorerTreeStore.d.ts +43 -0
- package/dist/core/FieldCapabilityRegistry.d.ts +16 -0
- package/dist/core/FieldChangeRegistry.d.ts +48 -0
- package/dist/core/HistoryManager.d.ts +0 -123
- package/dist/core/I18nManager.d.ts +0 -120
- package/dist/core/Optimizations.d.ts +0 -14
- package/dist/core/OptionSourceRegistry.d.ts +38 -0
- package/dist/core/RuleChainChatManager.d.ts +0 -37
- package/dist/core/RuleChainValidator.d.ts +0 -79
- package/dist/core/StateStore.d.ts +4 -140
- package/dist/core/ThemeManager.d.ts +0 -141
- package/dist/core/ValidationEngine.d.ts +0 -103
- package/dist/core/component-palette.d.ts +20 -0
- package/dist/core/component-payload.d.ts +0 -9
- package/dist/core/connection-status.d.ts +77 -0
- package/dist/core/context-menu-position.d.ts +27 -0
- package/dist/core/cron-schedule.d.ts +85 -0
- package/dist/core/debug-panel.d.ts +6 -0
- package/dist/core/editor-capabilities.d.ts +95 -0
- package/dist/core/editor-dock.d.ts +100 -0
- package/dist/core/editor-panel.d.ts +68 -0
- package/dist/core/explorer-tree.d.ts +27 -0
- package/dist/core/field-protocol.d.ts +32 -0
- package/dist/core/foundation-tokens.d.ts +38 -0
- package/dist/core/graph-operations.d.ts +34 -0
- package/dist/core/hover-tools.d.ts +26 -0
- package/dist/core/index.d.ts +68 -16
- package/dist/core/infer-run-input.d.ts +11 -0
- package/dist/core/key-value-editor.d.ts +6 -0
- package/dist/core/overlay-layers.d.ts +28 -0
- package/dist/core/recent-components.d.ts +51 -0
- package/dist/core/run-guard.d.ts +7 -0
- package/dist/core/runtime-field-dictionary.d.ts +68 -0
- package/dist/core/runtime-limits.d.ts +0 -5
- package/dist/core/save-conflict.d.ts +4 -0
- package/dist/core/server-status.d.ts +34 -0
- package/dist/core/simple-array.d.ts +4 -0
- package/dist/core/table-protocol.d.ts +36 -0
- package/dist/core/table-spreadsheet.d.ts +3 -0
- package/dist/core/test-cases.d.ts +54 -0
- package/dist/core/toolbar-icons.d.ts +4 -0
- package/dist/core/topology-rules.d.ts +17 -0
- package/dist/core/virtual-window.d.ts +20 -0
- package/dist/core/workspace-tab-actions.d.ts +13 -0
- package/dist/defaults/components.d.ts +0 -9
- package/dist/defaults/index.d.ts +0 -15
- package/dist/defaults/locale-en-US.d.ts +0 -24
- package/dist/defaults/locale-zh-CN.d.ts +0 -39
- package/dist/defaults/official-component-fallbacks.d.ts +0 -8
- package/dist/extensions/ClipboardExtension.d.ts +0 -23
- package/dist/extensions/KeyboardExtension.d.ts +0 -17
- package/dist/extensions/MenuExtension.d.ts +0 -23
- package/dist/iconRegistry.d.ts +0 -22
- package/dist/index.cjs +11320 -0
- package/dist/index.d.ts +25 -47
- package/dist/index.esm.js +1123 -99614
- package/dist/index.umd.js +3380 -1471
- package/dist/models/BaseNodeModel.d.ts +0 -32
- package/dist/models/index.d.ts +0 -1
- package/dist/nodes/AgentOrchestrationNode.d.ts +0 -24
- package/dist/nodes/GroupNode.d.ts +0 -38
- package/dist/nodes/HeadlessHtmlNode.d.ts +0 -16
- package/dist/nodes/SwitchNode.d.ts +0 -22
- package/dist/nodes/UnknownNodeModel.d.ts +0 -19
- package/dist/standalone/HuanbanRulegoEditor.d.ts +202 -401
- package/dist/standalone/ai-model-policy.d.ts +0 -1
- package/dist/standalone/ai-providers.d.ts +0 -1
- package/dist/standalone/auth-fetch.d.ts +2 -46
- package/dist/standalone/browser-assets.d.ts +0 -8
- package/dist/standalone/canvas-view.d.ts +6 -0
- package/dist/standalone/code-editor-language-loaders.d.ts +2 -0
- package/dist/standalone/code-editor-language-loaders.legacy.d.ts +7 -0
- package/dist/standalone/code-editor.d.ts +3 -87
- package/dist/standalone/connection-status-binding.d.ts +8 -0
- package/dist/standalone/custom-nodes.d.ts +0 -26
- package/dist/standalone/drawer-unsaved-guard.d.ts +2 -9
- package/dist/standalone/edge-label-quick-editor.d.ts +2 -0
- package/dist/standalone/editor-actions.d.ts +4 -0
- package/dist/standalone/editor-chain-info.d.ts +5 -38
- package/dist/standalone/editor-context-menu.d.ts +0 -21
- package/dist/standalone/editor-debug-ws.d.ts +37 -145
- package/dist/standalone/editor-delete.d.ts +0 -1
- package/dist/standalone/editor-dialogs.d.ts +16 -66
- package/dist/standalone/editor-events.d.ts +0 -27
- package/dist/standalone/editor-overlays.d.ts +14 -0
- package/dist/standalone/editor-property-drawers.d.ts +13 -71
- package/dist/standalone/editor-route-settings.d.ts +7 -55
- package/dist/standalone/editor-sidebar.d.ts +0 -18
- package/dist/standalone/editor-styles.d.ts +0 -11
- package/dist/standalone/editor-toast.d.ts +1 -2
- package/dist/standalone/editor-toolbar.d.ts +5 -80
- package/dist/standalone/editor-tour.d.ts +7 -0
- package/dist/standalone/editor-trace-overlay.d.ts +0 -5
- package/dist/standalone/full-json-dialog.d.ts +5 -1
- package/dist/standalone/group-node.d.ts +1 -51
- package/dist/standalone/icon-utils.d.ts +0 -20
- package/dist/standalone/index.d.ts +10 -7
- package/dist/standalone/json-diff.d.ts +0 -1
- package/dist/standalone/keyboard-events.d.ts +0 -1
- package/dist/standalone/layout-scheduler.d.ts +0 -6
- package/dist/standalone/lifecycle.d.ts +0 -5
- package/dist/standalone/logger.d.ts +0 -32
- package/dist/standalone/models-dev-catalog.d.ts +0 -1
- package/dist/standalone/node-copy.d.ts +7 -4
- package/dist/standalone/node-definitions.d.ts +0 -63
- package/dist/standalone/node-identity.d.ts +0 -1
- package/dist/standalone/node-theme.d.ts +8 -0
- package/dist/standalone/node-views-data.d.ts +0 -20
- package/dist/standalone/official-node-view-patches.d.ts +1 -14
- package/dist/standalone/outline-style.d.ts +7 -0
- package/dist/standalone/run-history-format.d.ts +0 -1
- package/dist/standalone/security-utils.d.ts +1 -5
- package/dist/standalone/shared-node-manager.d.ts +31 -0
- package/dist/standalone/themes.d.ts +0 -48
- package/dist/tools/tool-editor.d.ts +0 -1
- package/dist/types/component.d.ts +105 -87
- package/dist/types/editor.d.ts +16 -169
- package/dist/types/events.d.ts +30 -107
- package/dist/types/index.d.ts +3 -10
- package/dist/types/rule-chain.d.ts +0 -90
- package/dist/utils/GraphUtils.d.ts +0 -10
- package/dist/utils/helpers.d.ts +0 -80
- package/dist/utils/index.d.ts +0 -5
- package/dist/utils/pinyin-search.d.ts +0 -57
- package/dist/utils/relation-utils.d.ts +0 -1
- package/dist/utils/textUtils.d.ts +0 -12
- package/dist/version.d.ts +2 -3
- package/dist/xlsx-qn1xoUuv.cjs +105 -0
- package/package.json +19 -5
- package/vite-chunks.d.ts +11 -0
- package/vite-chunks.mjs +120 -0
- package/dist/index.cjs.js +0 -9515
|
@@ -1,67 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file core/EditorCore.ts
|
|
3
|
-
* @description 编辑器核心引擎 — 整合所有子系统的主入口
|
|
4
|
-
*
|
|
5
|
-
* EditorCore 是整个编辑器的中枢, 它:
|
|
6
|
-
* 1. 持有并协调所有子系统 (StateStore, EventBus, ComponentRegistry 等)
|
|
7
|
-
* 2. 管理 LogicFlow 实例的生命周期 (初始化 / 数据加载 / 事件桥接)
|
|
8
|
-
* 3. 提供统一的 API 供框架适配层 (Vue/React/原生 JS) 调用
|
|
9
|
-
* 4. 不包含任何框架特定代码 (无 Vue ref, 无 React useState)
|
|
10
|
-
*
|
|
11
|
-
* 框架适配层职责:
|
|
12
|
-
* - 将 EditorCore 的状态/事件桥接到框架的响应式系统
|
|
13
|
-
* - 渲染 UI 组件 (工具栏、侧边栏、属性面板)
|
|
14
|
-
* - 处理 DOM 挂载/卸载生命周期
|
|
15
|
-
*
|
|
16
|
-
* 使用方式 (原生 JS):
|
|
17
|
-
* ```typescript
|
|
18
|
-
* import { EditorCore } from '@huanban/rulego-editor-core'
|
|
19
|
-
*
|
|
20
|
-
* const editor = new EditorCore({
|
|
21
|
-
* container: document.getElementById('editor'),
|
|
22
|
-
* url: 'http://127.0.0.1:9090', // 通过 url 参数传入实际地址
|
|
23
|
-
* })
|
|
24
|
-
*
|
|
25
|
-
* // 初始化 (DOM 就绪后)
|
|
26
|
-
* editor.init(lfInstance)
|
|
27
|
-
*
|
|
28
|
-
* // 加载规则链数据
|
|
29
|
-
* editor.loadData(ruleChainData)
|
|
30
|
-
*
|
|
31
|
-
* // 导出数据
|
|
32
|
-
* const data = editor.exportData(lfGraphData, getNodeModelById)
|
|
33
|
-
*
|
|
34
|
-
* // 监听事件
|
|
35
|
-
* editor.on('node:click', (data) => { ... })
|
|
36
|
-
*
|
|
37
|
-
* // 销毁
|
|
38
|
-
* editor.destroy()
|
|
39
|
-
* ```
|
|
40
|
-
*
|
|
41
|
-
* 使用方式 (Vue 适配层):
|
|
42
|
-
* ```typescript
|
|
43
|
-
* // 在 @huanban/editor-vue 的 composable 中
|
|
44
|
-
* import { EditorCore } from '@huanban/rulego-editor-core'
|
|
45
|
-
*
|
|
46
|
-
* export function useEditorCore(options) {
|
|
47
|
-
* const core = new EditorCore(options)
|
|
48
|
-
* // 将 core.store 桥接到 Vue 的 reactive/ref
|
|
49
|
-
* // 将 core.eventBus 桥接到 Vue 的 emit
|
|
50
|
-
* return core
|
|
51
|
-
* }
|
|
52
|
-
* ```
|
|
53
|
-
*
|
|
54
|
-
* @see StateStore 状态管理
|
|
55
|
-
* @see EventBus 事件总线
|
|
56
|
-
* @see ComponentRegistry 组件注册表
|
|
57
|
-
* @see DataAdapter 数据格式转换
|
|
58
|
-
* @see HistoryManager 撤销/重做
|
|
59
|
-
* @see ValidationEngine 图验证
|
|
60
|
-
* @see ThemeManager 主题管理
|
|
61
|
-
* @see I18nManager 国际化
|
|
62
|
-
*
|
|
63
|
-
* @see 原版 RuleGoEditor.vue — 所有 initLf / save / deleteSelects 逻辑的来源
|
|
64
|
-
*/
|
|
65
1
|
import { StateStore } from './StateStore';
|
|
66
2
|
import { EventBus } from './EventBus';
|
|
67
3
|
import { DataAdapter } from './DataAdapter';
|
|
@@ -75,199 +11,73 @@ import type { EditorOptions, EditorInternalData, EditorPlugin } from '../types/e
|
|
|
75
11
|
import type { EditorEventMap, EditorEventName } from '../types/events';
|
|
76
12
|
import type { RuleChainData, RuleChainConfig, RuleNodeConfig, RuleConnectionConfig } from '../types/rule-chain';
|
|
77
13
|
import type { ComponentDefinition, ComponentGroup, RawComponentData } from '../types/component';
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
14
|
+
import { ActionRegistry } from './ActionRegistry';
|
|
15
|
+
import type { EditorActionContext, EditorActionSource, EditorSelectionSnapshot } from './ActionRegistry';
|
|
16
|
+
import { FieldCapabilityRegistry } from './FieldCapabilityRegistry';
|
|
17
|
+
import { OptionSourceRegistry } from './OptionSourceRegistry';
|
|
18
|
+
import { FieldChangeRegistry } from './FieldChangeRegistry';
|
|
19
|
+
import { DiagnosticService } from './DiagnosticService';
|
|
20
|
+
import type { DiagnosticItem } from './topology-rules';
|
|
21
|
+
import { ComponentDocService } from './ComponentDocService';
|
|
22
|
+
import { RuntimeFieldDictionary } from './runtime-field-dictionary';
|
|
85
23
|
interface CoreState extends Record<string, unknown> {
|
|
86
|
-
/** 编辑器是否已就绪 */
|
|
87
24
|
isReady: boolean;
|
|
88
|
-
/** 数据是否已修改 (有未保存的更改) */
|
|
89
25
|
isDirty: boolean;
|
|
90
|
-
/** 是否正在加载 */
|
|
91
26
|
isLoading: boolean;
|
|
92
|
-
/** 当前选中的节点数据 */
|
|
93
27
|
selectedNode: RuleNodeConfig | null;
|
|
94
|
-
/** 当前选中的边数据 */
|
|
95
28
|
selectedEdge: RuleConnectionConfig | null;
|
|
96
|
-
/** 规则链配置 */
|
|
97
29
|
ruleChain: RuleChainConfig | null;
|
|
98
|
-
/** 组件注册表 (type => definition 映射) */
|
|
99
30
|
nodeComponents: Record<string, ComponentDefinition>;
|
|
100
|
-
/** 按分类分组的组件列表 */
|
|
101
31
|
componentGroups: ComponentGroup[];
|
|
102
|
-
/** 当前正在编辑的节点视图定义 */
|
|
103
32
|
currentNodeView: ComponentDefinition | null;
|
|
104
|
-
/** 当前正在编辑的节点配置数据 */
|
|
105
33
|
currentNodeModel: Record<string, unknown>;
|
|
106
|
-
/** 当前正在编辑的边配置数据 */
|
|
107
34
|
currentEdgeModel: Record<string, unknown>;
|
|
108
|
-
/** 是否可以撤销 */
|
|
109
35
|
canUndo: boolean;
|
|
110
|
-
/** 是否可以重做 */
|
|
111
36
|
canRedo: boolean;
|
|
112
37
|
}
|
|
113
|
-
/**
|
|
114
|
-
* 编辑器核心引擎
|
|
115
|
-
*
|
|
116
|
-
* 生命周期:
|
|
117
|
-
* 1. constructor — 创建所有子系统
|
|
118
|
-
* 2. init() — 初始化 LogicFlow, 加载组件, 注册事件
|
|
119
|
-
* 3. loadData() — 加载规则链数据并渲染
|
|
120
|
-
* 4. exportData() — 从画布导出数据
|
|
121
|
-
* 5. destroy() — 销毁所有资源
|
|
122
|
-
*/
|
|
123
38
|
export declare class EditorCore {
|
|
124
|
-
/** 状态容器 — 编辑器的全局状态 */
|
|
125
39
|
readonly store: StateStore<CoreState>;
|
|
126
|
-
/** 事件总线 — 编辑器级别的事件 */
|
|
127
40
|
readonly eventBus: EventBus;
|
|
128
|
-
/** 数据适配器 — RuleGo JSON ↔ LogicFlow 格式转换 */
|
|
129
41
|
readonly dataAdapter: DataAdapter;
|
|
130
|
-
/** 组件注册表 — 管理可用的节点组件 */
|
|
131
42
|
readonly componentRegistry: ComponentRegistry;
|
|
132
|
-
/** 历史管理器 — 撤销/重做 */
|
|
133
43
|
readonly history: HistoryManager;
|
|
134
|
-
/** 验证引擎 — 图合法性检查 */
|
|
135
44
|
readonly validation: ValidationEngine;
|
|
136
|
-
/** 主题管理器 — 多主题切换 */
|
|
137
45
|
readonly theme: ThemeManager;
|
|
138
|
-
/** 国际化 — 多语言支持 */
|
|
139
46
|
readonly i18n: I18nManager;
|
|
140
|
-
|
|
47
|
+
readonly actions: ActionRegistry;
|
|
48
|
+
readonly fieldCapabilities: FieldCapabilityRegistry;
|
|
49
|
+
readonly optionSources: OptionSourceRegistry;
|
|
50
|
+
readonly fieldChanges: FieldChangeRegistry;
|
|
51
|
+
readonly diagnostics: DiagnosticService;
|
|
52
|
+
readonly documents: ComponentDocService;
|
|
53
|
+
readonly runtimeFields: RuntimeFieldDictionary;
|
|
141
54
|
private options;
|
|
142
|
-
/** 内部运行时数据 (计数器、常量配置等) */
|
|
143
55
|
private internalData;
|
|
144
|
-
/** LogicFlow 实例引用 (由外部传入或在 init 时创建) */
|
|
145
56
|
private lfInstance;
|
|
146
|
-
/** 已安装的插件列表 */
|
|
147
57
|
private plugins;
|
|
148
|
-
/** 是否已初始化 */
|
|
149
58
|
private initialized;
|
|
150
|
-
/** 语言变更取消监听 */
|
|
151
59
|
private disposeLocaleChange;
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
*
|
|
155
|
-
* @param options - 编辑器配置选项
|
|
156
|
-
* @see EditorOptions 完整的配置说明
|
|
157
|
-
*/
|
|
60
|
+
private disposeThemeChange;
|
|
61
|
+
private fieldChangeContributionHandlers;
|
|
158
62
|
constructor(options: EditorOptions);
|
|
159
|
-
/**
|
|
160
|
-
* 初始化编辑器
|
|
161
|
-
*
|
|
162
|
-
* 这个方法在 DOM 容器准备好之后调用 (框架适配层的 mounted/useEffect 中)。
|
|
163
|
-
* 它负责:
|
|
164
|
-
* 1. 保存 LogicFlow 实例引用
|
|
165
|
-
* 2. 应用初始主题
|
|
166
|
-
* 3. 通知插件
|
|
167
|
-
* 4. 触发 editor:ready 事件
|
|
168
|
-
*
|
|
169
|
-
* @param lfInstance - 外部创建的 LogicFlow 实例 (可选)
|
|
170
|
-
*/
|
|
171
63
|
init(lfInstance?: unknown): void;
|
|
172
|
-
/**
|
|
173
|
-
* 销毁编辑器, 释放所有资源
|
|
174
|
-
*
|
|
175
|
-
* 必须在组件卸载时调用 (框架适配层的 unmounted/useEffect cleanup 中)
|
|
176
|
-
*/
|
|
177
64
|
destroy(): void;
|
|
178
|
-
/**
|
|
179
|
-
* 加载组件定义并同步组件映射、分组状态。
|
|
180
|
-
*
|
|
181
|
-
* 框架适配层应优先使用该入口;直接操作 componentRegistry 只会更新注册表,
|
|
182
|
-
* 不会自动通知 React/Vue/DOM UI 订阅的 componentGroups。
|
|
183
|
-
*
|
|
184
|
-
* @param components - 组件定义列表,通常来自 /api/v1/components 或 options.components
|
|
185
|
-
* @returns 按分类分组后的组件列表
|
|
186
|
-
*/
|
|
187
65
|
loadComponents(components: RawComponentData): ComponentGroup[];
|
|
188
|
-
/**
|
|
189
|
-
* 增量注册组件定义并同步组件分组状态。
|
|
190
|
-
*
|
|
191
|
-
* @param components - 需要追加或覆盖的组件定义
|
|
192
|
-
* @param overwrite - 已存在 type 时是否覆盖
|
|
193
|
-
* @returns 按分类分组后的组件列表
|
|
194
|
-
*/
|
|
195
66
|
registerComponents(components: ComponentDefinition[], overwrite?: boolean): ComponentGroup[];
|
|
196
67
|
private syncComponentState;
|
|
197
68
|
private localizeComponentGroups;
|
|
198
|
-
/**
|
|
199
|
-
* 加载规则链数据并渲染到画布
|
|
200
|
-
*
|
|
201
|
-
* 转换流程:
|
|
202
|
-
* RuleChainData → DataAdapter.adapterIn → LogicFlow.render
|
|
203
|
-
*
|
|
204
|
-
* @param ruleChainData - RuleGo 规则链 JSON 数据
|
|
205
|
-
* @see DataAdapter.adapterIn 数据转换详情
|
|
206
|
-
*/
|
|
207
69
|
loadData(ruleChainData: RuleChainData): void;
|
|
208
|
-
/**
|
|
209
|
-
* 从画布导出 RuleGo 格式数据 (用于保存)
|
|
210
|
-
*
|
|
211
|
-
* 转换流程:
|
|
212
|
-
* LogicFlow.getGraphData → DataAdapter.adapterOut → RuleChainData
|
|
213
|
-
*
|
|
214
|
-
* @param lfGraphData - LogicFlow 当前图数据
|
|
215
|
-
* @param getNodeModelById - LogicFlow 节点查询函数
|
|
216
|
-
* @returns RuleGo 格式的规则链数据
|
|
217
|
-
* @see DataAdapter.adapterOut 数据转换详情
|
|
218
|
-
*/
|
|
219
70
|
exportData(lfGraphData: LFGraphData, getNodeModelById: (id: string) => LFNodeData | null): RuleChainData;
|
|
220
|
-
/**
|
|
221
|
-
* 验证当前图数据
|
|
222
|
-
*
|
|
223
|
-
* @param lfGraphData - LogicFlow 当前图数据
|
|
224
|
-
* @returns 验证结果
|
|
225
|
-
* @see ValidationEngine.validate
|
|
226
|
-
*/
|
|
227
71
|
validateGraph(lfGraphData: LFGraphData): import("./ValidationEngine").ValidationResult;
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
*
|
|
231
|
-
* @param event - 事件名
|
|
232
|
-
* @param handler - 事件处理函数
|
|
233
|
-
* @returns 取消监听函数
|
|
234
|
-
* @see EditorEventMap 所有可监听事件及其载荷类型
|
|
235
|
-
*/
|
|
72
|
+
validateTopology(lfGraphData: LFGraphData): DiagnosticItem[];
|
|
73
|
+
invokeAction(id: string, runtime: EditorActionContext['runtime'], selection?: EditorSelectionSnapshot, source?: EditorActionSource, extra?: Record<string, unknown>): Promise<boolean>;
|
|
236
74
|
on<K extends EditorEventName>(event: K, handler: (payload: EditorEventMap[K]) => void): () => void;
|
|
237
|
-
/**
|
|
238
|
-
* 触发编辑器事件
|
|
239
|
-
*
|
|
240
|
-
* @param event - 事件名
|
|
241
|
-
* @param args - 事件载荷
|
|
242
|
-
*/
|
|
243
75
|
emit<K extends EditorEventName>(event: K, ...args: EditorEventMap[K] extends void ? [] : [EditorEventMap[K]]): void;
|
|
244
|
-
/**
|
|
245
|
-
* 安装插件
|
|
246
|
-
*
|
|
247
|
-
* 插件可以在编辑器生命周期的各个阶段注入自定义逻辑:
|
|
248
|
-
* - onInit: 编辑器初始化后
|
|
249
|
-
* - beforeDataLoad: 数据加载前 (可修改数据)
|
|
250
|
-
* - beforeDataSave: 数据保存前 (可修改数据)
|
|
251
|
-
* - onDestroy: 编辑器销毁前
|
|
252
|
-
*
|
|
253
|
-
* @param plugin - 插件实例
|
|
254
|
-
* @see EditorPlugin 插件接口
|
|
255
|
-
*/
|
|
256
76
|
use(plugin: EditorPlugin): void;
|
|
257
|
-
/**
|
|
258
|
-
* 获取内部运行时数据 (只读)
|
|
259
|
-
* 主要供 DataAdapter 和框架适配层使用
|
|
260
|
-
*/
|
|
261
77
|
getInternalData(): Readonly<EditorInternalData>;
|
|
262
|
-
/**
|
|
263
|
-
* 获取 LogicFlow 实例引用
|
|
264
|
-
* 供框架适配层在需要直接操作 LogicFlow 时使用
|
|
265
|
-
*/
|
|
266
78
|
getLfInstance(): unknown;
|
|
267
|
-
/**
|
|
268
|
-
* 获取编辑器配置选项
|
|
269
|
-
*/
|
|
270
79
|
getOptions(): Readonly<EditorOptions>;
|
|
80
|
+
updateOptions(patch: Partial<Omit<EditorOptions, 'container'>>): void;
|
|
81
|
+
private toProviderFieldOptions;
|
|
271
82
|
}
|
|
272
83
|
export {};
|
|
273
|
-
//# sourceMappingURL=EditorCore.d.ts.map
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import type { RuleChainData } from '../types/rule-chain';
|
|
2
|
+
export interface EditorWorkspaceTab {
|
|
3
|
+
id: string;
|
|
4
|
+
chainId: string;
|
|
5
|
+
title: string;
|
|
6
|
+
data: RuleChainData | null;
|
|
7
|
+
savedData: RuleChainData | null;
|
|
8
|
+
isDirty: boolean;
|
|
9
|
+
isLoading: boolean;
|
|
10
|
+
readonly: boolean;
|
|
11
|
+
pinned?: boolean;
|
|
12
|
+
metadata?: Record<string, unknown>;
|
|
13
|
+
}
|
|
14
|
+
export interface EditorWorkspaceState extends Record<string, unknown> {
|
|
15
|
+
tabs: EditorWorkspaceTab[];
|
|
16
|
+
activeTabId: string | null;
|
|
17
|
+
}
|
|
18
|
+
export interface OpenWorkspaceTabInput {
|
|
19
|
+
chainId?: string;
|
|
20
|
+
title?: string;
|
|
21
|
+
data?: RuleChainData | null;
|
|
22
|
+
savedData?: RuleChainData | null;
|
|
23
|
+
isLoading?: boolean;
|
|
24
|
+
readonly?: boolean;
|
|
25
|
+
pinned?: boolean;
|
|
26
|
+
metadata?: Record<string, unknown>;
|
|
27
|
+
allowDuplicate?: boolean;
|
|
28
|
+
activate?: boolean;
|
|
29
|
+
}
|
|
30
|
+
export type WorkspaceCloseDecision = 'save' | 'discard' | 'keep-editing' | 'cancel';
|
|
31
|
+
export type WorkspaceCloseResultReason = 'decision-required' | 'cancelled' | 'discarded' | 'saved' | 'save-unavailable' | 'save-failed' | 'conflict' | 'readonly' | 'busy' | 'destroyed';
|
|
32
|
+
export interface WorkspaceSaveResponse {
|
|
33
|
+
success: boolean;
|
|
34
|
+
data?: RuleChainData | null;
|
|
35
|
+
conflict?: boolean;
|
|
36
|
+
remoteData?: RuleChainData | null;
|
|
37
|
+
error?: unknown;
|
|
38
|
+
}
|
|
39
|
+
export type WorkspaceSaveOutcome = {
|
|
40
|
+
status: 'saved';
|
|
41
|
+
data?: RuleChainData | null;
|
|
42
|
+
} | {
|
|
43
|
+
status: 'failed';
|
|
44
|
+
error?: unknown;
|
|
45
|
+
} | {
|
|
46
|
+
status: 'conflict';
|
|
47
|
+
remoteData?: RuleChainData | null;
|
|
48
|
+
error?: unknown;
|
|
49
|
+
};
|
|
50
|
+
export type WorkspaceSaveHandlerResult = WorkspaceSaveOutcome | WorkspaceSaveResponse | boolean | void;
|
|
51
|
+
export type WorkspaceSaveHandler = (data: RuleChainData | null, tab: EditorWorkspaceTab) => WorkspaceSaveHandlerResult | PromiseLike<WorkspaceSaveHandlerResult>;
|
|
52
|
+
type WorkspaceSyncSaveHandler = (data: RuleChainData | null, tab: EditorWorkspaceTab) => WorkspaceSaveHandlerResult;
|
|
53
|
+
export interface CloseWorkspaceTabOptions {
|
|
54
|
+
discard?: boolean;
|
|
55
|
+
decision?: WorkspaceCloseDecision;
|
|
56
|
+
save?: WorkspaceSyncSaveHandler;
|
|
57
|
+
}
|
|
58
|
+
export interface CloseWorkspaceTabDecisionOptions extends Omit<CloseWorkspaceTabOptions, 'save'> {
|
|
59
|
+
save?: WorkspaceSaveHandler;
|
|
60
|
+
}
|
|
61
|
+
export interface CloseWorkspaceTabResult {
|
|
62
|
+
closed: boolean;
|
|
63
|
+
requiresConfirmation: boolean;
|
|
64
|
+
tab: EditorWorkspaceTab | null;
|
|
65
|
+
decision?: WorkspaceCloseDecision;
|
|
66
|
+
reason?: WorkspaceCloseResultReason;
|
|
67
|
+
saveResult?: WorkspaceSaveOutcome;
|
|
68
|
+
}
|
|
69
|
+
export type WorkspaceConflictResolution = 'keep-local' | 'use-remote' | 'cancel';
|
|
70
|
+
export interface WorkspaceConflictResult {
|
|
71
|
+
resolved: boolean;
|
|
72
|
+
tab: EditorWorkspaceTab | null;
|
|
73
|
+
}
|
|
74
|
+
export type WorkspaceListener = (state: Readonly<EditorWorkspaceState>, previousState: Readonly<EditorWorkspaceState>) => void;
|
|
75
|
+
export declare class EditorWorkspace {
|
|
76
|
+
private readonly store;
|
|
77
|
+
private nextId;
|
|
78
|
+
private destroyed;
|
|
79
|
+
constructor(initial?: {
|
|
80
|
+
tabs?: OpenWorkspaceTabInput[];
|
|
81
|
+
activeTabId?: string | null;
|
|
82
|
+
});
|
|
83
|
+
getState(): Readonly<EditorWorkspaceState>;
|
|
84
|
+
getTabs(): EditorWorkspaceTab[];
|
|
85
|
+
getTab(tabId: string): EditorWorkspaceTab | null;
|
|
86
|
+
getActiveTab(): EditorWorkspaceTab | null;
|
|
87
|
+
subscribe(listener: WorkspaceListener): () => void;
|
|
88
|
+
openTab(input?: OpenWorkspaceTabInput): EditorWorkspaceTab;
|
|
89
|
+
activateTab(tabId: string): boolean;
|
|
90
|
+
renameTab(tabId: string, title: string): boolean;
|
|
91
|
+
togglePinned(tabId: string): boolean;
|
|
92
|
+
getCloseOtherTabIds(tabId: string): string[];
|
|
93
|
+
getCloseRightTabIds(tabId: string): string[];
|
|
94
|
+
setDraft(tabId: string, data: RuleChainData | null): EditorWorkspaceTab | null;
|
|
95
|
+
updateRuleChainLifecycle(tabId: string, disabled: boolean): EditorWorkspaceTab | null;
|
|
96
|
+
markSaved(tabId: string, data?: RuleChainData | null): EditorWorkspaceTab | null;
|
|
97
|
+
setLoading(tabId: string, isLoading: boolean): boolean;
|
|
98
|
+
closeTab(tabId: string, options?: CloseWorkspaceTabOptions): CloseWorkspaceTabResult;
|
|
99
|
+
closeTabWithDecision(tabId: string, options?: CloseWorkspaceTabDecisionOptions): Promise<CloseWorkspaceTabResult>;
|
|
100
|
+
private closeTabSync;
|
|
101
|
+
private resolveCloseDecision;
|
|
102
|
+
private prepareSave;
|
|
103
|
+
private saveAndClose;
|
|
104
|
+
private normalizeSaveResult;
|
|
105
|
+
private finishSave;
|
|
106
|
+
private saveFailure;
|
|
107
|
+
private removeTab;
|
|
108
|
+
resolveSaveConflict(tabId: string, resolution: WorkspaceConflictResolution, remoteData?: RuleChainData | null): WorkspaceConflictResult;
|
|
109
|
+
destroy(): void;
|
|
110
|
+
}
|
|
111
|
+
export {};
|
package/dist/core/EventBus.d.ts
CHANGED
|
@@ -1,101 +1,15 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file EventBus.ts
|
|
3
|
-
* @description 类型安全的事件总线
|
|
4
|
-
*
|
|
5
|
-
* 基于 EditorEventMap 提供强类型的事件发布/订阅。
|
|
6
|
-
* 与 LogicFlow 的 eventCenter 分工:
|
|
7
|
-
* - LogicFlow eventCenter: 处理画布级别的原生事件 (node:click, edge:add 等)
|
|
8
|
-
* - EventBus: 处理编辑器业务级别的事件 (editor:save, history:change 等)
|
|
9
|
-
*
|
|
10
|
-
* 特性:
|
|
11
|
-
* - 强类型: 事件名和负载类型在编译期绑定
|
|
12
|
-
* - 一次性监听: once() 方法只触发一次
|
|
13
|
-
* - 安全清理: destroy() 清除所有监听器
|
|
14
|
-
* - 调试模式: 可选事件追踪日志
|
|
15
|
-
*/
|
|
16
1
|
import type { EditorEventMap, EditorEventName } from '../types/events';
|
|
17
|
-
/**
|
|
18
|
-
* 事件监听器函数类型
|
|
19
|
-
*/
|
|
20
2
|
type Listener<T> = (payload: T) => void;
|
|
21
|
-
/**
|
|
22
|
-
* 类型安全的事件总线
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```typescript
|
|
26
|
-
* const bus = new EventBus()
|
|
27
|
-
*
|
|
28
|
-
* // 订阅事件 (有类型提示)
|
|
29
|
-
* bus.on('node:click', (payload) => {
|
|
30
|
-
* // payload 的类型自动推断为 NodeEventPayload
|
|
31
|
-
* console.log(payload.id, payload.type)
|
|
32
|
-
* })
|
|
33
|
-
*
|
|
34
|
-
* // 触发事件
|
|
35
|
-
* bus.emit('node:click', { id: 'node_1', type: 'simple-node', ... })
|
|
36
|
-
*
|
|
37
|
-
* // 取消订阅
|
|
38
|
-
* const off = bus.on('editor:save', handler)
|
|
39
|
-
* off() // 取消
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
3
|
export declare class EventBus {
|
|
43
|
-
/** 事件监听器映射: 事件名 => 监听器列表 */
|
|
44
4
|
private listeners;
|
|
45
|
-
/** 是否启用调试模式 */
|
|
46
5
|
private debug;
|
|
47
|
-
/**
|
|
48
|
-
* 创建事件总线
|
|
49
|
-
* @param debug - 是否启用调试日志 (默认: false)
|
|
50
|
-
*/
|
|
51
6
|
constructor(debug?: boolean);
|
|
52
|
-
/**
|
|
53
|
-
* 订阅事件
|
|
54
|
-
*
|
|
55
|
-
* @param event - 事件名称
|
|
56
|
-
* @param callback - 事件回调函数
|
|
57
|
-
* @returns 取消订阅的函数
|
|
58
|
-
*/
|
|
59
7
|
on<E extends EditorEventName>(event: E, callback: Listener<EditorEventMap[E]>): () => void;
|
|
60
|
-
/**
|
|
61
|
-
* 一次性订阅事件 (只触发一次后自动取消)
|
|
62
|
-
*
|
|
63
|
-
* @param event - 事件名称
|
|
64
|
-
* @param callback - 事件回调函数
|
|
65
|
-
* @returns 取消订阅的函数
|
|
66
|
-
*/
|
|
67
8
|
once<E extends EditorEventName>(event: E, callback: Listener<EditorEventMap[E]>): () => void;
|
|
68
|
-
/**
|
|
69
|
-
* 取消订阅事件
|
|
70
|
-
*
|
|
71
|
-
* @param event - 事件名称
|
|
72
|
-
* @param callback - 要移除的回调函数
|
|
73
|
-
*/
|
|
74
9
|
off<E extends EditorEventName>(event: E, callback: Listener<EditorEventMap[E]>): void;
|
|
75
|
-
/**
|
|
76
|
-
* 触发事件,通知所有订阅者
|
|
77
|
-
*
|
|
78
|
-
* @param event - 事件名称
|
|
79
|
-
* @param payload - 事件负载数据
|
|
80
|
-
*/
|
|
81
10
|
emit<E extends EditorEventName>(event: E, ...args: EditorEventMap[E] extends void ? [] : [EditorEventMap[E]]): void;
|
|
82
|
-
/**
|
|
83
|
-
* 移除指定事件的所有监听器
|
|
84
|
-
*
|
|
85
|
-
* @param event - 事件名称 (不传则移除所有事件的监听器)
|
|
86
|
-
*/
|
|
87
11
|
removeAll(event?: EditorEventName): void;
|
|
88
|
-
/**
|
|
89
|
-
* 获取指定事件的监听器数量 (用于调试)
|
|
90
|
-
*
|
|
91
|
-
* @param event - 事件名称
|
|
92
|
-
* @returns 监听器数量
|
|
93
|
-
*/
|
|
94
12
|
listenerCount(event: EditorEventName): number;
|
|
95
|
-
/**
|
|
96
|
-
* 销毁事件总线, 清除所有监听器
|
|
97
|
-
*/
|
|
98
13
|
destroy(): void;
|
|
99
14
|
}
|
|
100
15
|
export {};
|
|
101
|
-
//# sourceMappingURL=EventBus.d.ts.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { WorkflowItem } from '../api/types';
|
|
2
|
+
import { type ExplorerTreeLabels, type ExplorerTreeNode } from './explorer-tree';
|
|
3
|
+
import { type EditorStatePersistenceOptions } from './editor-dock';
|
|
4
|
+
export interface ExplorerTreePersistenceState {
|
|
5
|
+
expandedKeys: string[];
|
|
6
|
+
}
|
|
7
|
+
export interface ExplorerTreeStoreOptions {
|
|
8
|
+
workflows?: readonly WorkflowItem[];
|
|
9
|
+
keyword?: string;
|
|
10
|
+
activeChainId?: string;
|
|
11
|
+
labels?: Partial<ExplorerTreeLabels>;
|
|
12
|
+
smallTreeMax?: number;
|
|
13
|
+
persistence?: EditorStatePersistenceOptions<ExplorerTreePersistenceState>;
|
|
14
|
+
}
|
|
15
|
+
export interface ExplorerTreeState extends Record<string, unknown> {
|
|
16
|
+
tree: ExplorerTreeNode[];
|
|
17
|
+
keyword: string;
|
|
18
|
+
activeChainId: string;
|
|
19
|
+
rememberedExpandedKeys: string[];
|
|
20
|
+
forcedExpandedKeys: string[];
|
|
21
|
+
expandedKeys: string[];
|
|
22
|
+
}
|
|
23
|
+
export declare class ExplorerTreeStore {
|
|
24
|
+
private readonly store;
|
|
25
|
+
private readonly labels?;
|
|
26
|
+
private readonly smallTreeMax;
|
|
27
|
+
private readonly persistence;
|
|
28
|
+
private workflows;
|
|
29
|
+
private seeded;
|
|
30
|
+
private destroyed;
|
|
31
|
+
constructor(options?: ExplorerTreeStoreOptions);
|
|
32
|
+
getState(): ExplorerTreeState;
|
|
33
|
+
subscribe(listener: (state: ExplorerTreeState, previous: ExplorerTreeState) => void): () => void;
|
|
34
|
+
setWorkflows(workflows: readonly WorkflowItem[]): void;
|
|
35
|
+
setKeyword(keyword: string): void;
|
|
36
|
+
setActiveChainId(chainId: string): void;
|
|
37
|
+
setExpanded(key: string, expanded: boolean): boolean;
|
|
38
|
+
toggleExpanded(key: string): boolean;
|
|
39
|
+
destroy(): void;
|
|
40
|
+
private rebuild;
|
|
41
|
+
private resolveRememberedKeys;
|
|
42
|
+
private resolveForcedKeys;
|
|
43
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ComponentDefinition, ComponentFieldOption } from '../types/component';
|
|
2
|
+
export interface FieldCapabilityContext {
|
|
3
|
+
aiProviders?: ComponentFieldOption[];
|
|
4
|
+
aiEmbeddingProviders?: ComponentFieldOption[];
|
|
5
|
+
[key: string]: unknown;
|
|
6
|
+
}
|
|
7
|
+
export type FieldCapabilityHandler = (component: ComponentDefinition, params: Record<string, unknown>, context: FieldCapabilityContext) => void;
|
|
8
|
+
export declare class FieldCapabilityRegistry {
|
|
9
|
+
private handlers;
|
|
10
|
+
constructor();
|
|
11
|
+
register(name: string, handler: FieldCapabilityHandler, overwrite?: boolean): void;
|
|
12
|
+
unregister(name: string): boolean;
|
|
13
|
+
clear(): void;
|
|
14
|
+
apply(component: ComponentDefinition, context?: FieldCapabilityContext): ComponentDefinition;
|
|
15
|
+
private registerBuiltinCapabilities;
|
|
16
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { ComponentField } from '../types/component';
|
|
2
|
+
export interface FieldChangeResolveContext {
|
|
3
|
+
configuration: Readonly<Record<string, unknown>>;
|
|
4
|
+
currentNodeId?: string;
|
|
5
|
+
graphNodes?: Array<{
|
|
6
|
+
id: string;
|
|
7
|
+
name?: string;
|
|
8
|
+
type?: string;
|
|
9
|
+
}>;
|
|
10
|
+
requestKey?: string;
|
|
11
|
+
signal?: AbortSignal;
|
|
12
|
+
[key: string]: unknown;
|
|
13
|
+
}
|
|
14
|
+
export interface FieldChangeContext extends Omit<FieldChangeResolveContext, 'signal'> {
|
|
15
|
+
field: ComponentField;
|
|
16
|
+
signal: AbortSignal;
|
|
17
|
+
}
|
|
18
|
+
export interface FieldChangeResult {
|
|
19
|
+
patch?: Record<string, unknown>;
|
|
20
|
+
remove?: readonly string[];
|
|
21
|
+
}
|
|
22
|
+
export type FieldChangeHandler = (value: unknown, configuration: Readonly<Record<string, unknown>>, context: FieldChangeContext) => FieldChangeResult | void | Promise<FieldChangeResult | void>;
|
|
23
|
+
export type FieldChangeExecutionStatus = 'skipped' | 'applied' | 'aborted';
|
|
24
|
+
export interface FieldChangeExecutionResult extends FieldChangeResult {
|
|
25
|
+
status: FieldChangeExecutionStatus;
|
|
26
|
+
handlerName?: string;
|
|
27
|
+
generation: number;
|
|
28
|
+
}
|
|
29
|
+
export declare class FieldChangeHandlerNotFoundError extends Error {
|
|
30
|
+
readonly handlerName: string;
|
|
31
|
+
constructor(handlerName: string);
|
|
32
|
+
}
|
|
33
|
+
export declare function getFieldChangeHandlerName(field: ComponentField): string | undefined;
|
|
34
|
+
export declare class FieldChangeRegistry {
|
|
35
|
+
private handlers;
|
|
36
|
+
private active;
|
|
37
|
+
private generation;
|
|
38
|
+
private abortHandlerExecutions;
|
|
39
|
+
register(name: string, handler: FieldChangeHandler, overwrite?: boolean): void;
|
|
40
|
+
unregister(name: string): boolean;
|
|
41
|
+
has(name: string): boolean;
|
|
42
|
+
resolve(name: string): FieldChangeHandler | undefined;
|
|
43
|
+
private requestKey;
|
|
44
|
+
execute(field: ComponentField, value: unknown, context: FieldChangeResolveContext): Promise<FieldChangeExecutionResult>;
|
|
45
|
+
abort(requestKey: string): boolean;
|
|
46
|
+
abortAll(): void;
|
|
47
|
+
clear(): void;
|
|
48
|
+
}
|