@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,220 +1,207 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file standalone/HuanbanRulegoEditor.ts
|
|
3
|
-
* @description HuanbanRulegoEditor — 零框架依赖,一行代码启动完整编辑器
|
|
4
|
-
*
|
|
5
|
-
* 核心职责:
|
|
6
|
-
* 1. 创建完整 DOM 布局 (工具栏 + 侧边栏 + 画布 + 属性面板)
|
|
7
|
-
* 2. 初始化 LogicFlow 画布 (带 nodeTextDraggable: false 等关键配置)
|
|
8
|
-
* 3. 初始化 EditorCore 数据引擎
|
|
9
|
-
* 4. 渲染 Node-RED 风格的组件侧边栏 (带分类折叠、搜索、拖拽)
|
|
10
|
-
* 5. 提供简洁 API: loadData / exportData / loadComponents / destroy
|
|
11
|
-
*
|
|
12
|
-
* 所有 CSS class 使用 huanban_rulego_editor 前缀, 避免与宿主项目冲突。
|
|
13
|
-
*
|
|
14
|
-
* 使用方式:
|
|
15
|
-
* ```html
|
|
16
|
-
* <div id="editor" style="height:100vh"></div>
|
|
17
|
-
* <script src="editor-core.umd.js"></script>
|
|
18
|
-
* <script>
|
|
19
|
-
* const editor = new RuleGoEditorCore.HuanbanRulegoEditor({
|
|
20
|
-
* container: '#editor',
|
|
21
|
-
* apiBase: 'http://127.0.0.1:9090',
|
|
22
|
-
* onReady: ({ lf, core }) => console.log('就绪'),
|
|
23
|
-
* onNodeClick: (node) => console.log('点击节点', node),
|
|
24
|
-
* })
|
|
25
|
-
* </script>
|
|
26
|
-
* ```
|
|
27
|
-
*
|
|
28
|
-
* @see EditorCore 核心引擎
|
|
29
|
-
* @see DataAdapter 数据转换
|
|
30
|
-
*/
|
|
31
1
|
import LogicFlow from '@logicflow/core';
|
|
32
2
|
import { EditorCore } from '../core/EditorCore';
|
|
33
3
|
import { I18nManager } from '../core/I18nManager';
|
|
4
|
+
import { EditorDockStore } from '../core/editor-dock';
|
|
5
|
+
import type { EditorDockPersistenceState, EditorPersistenceAdapter, EditorPersistenceMigrationContext, EditorPersistenceNamespace } from '../core/editor-dock';
|
|
6
|
+
import { EditorPanelRegistry } from '../core/editor-panel';
|
|
7
|
+
import { RecentComponentsStore } from '../core/recent-components';
|
|
8
|
+
import type { RecentComponentsPersistenceOptions } from '../core/recent-components';
|
|
9
|
+
import { EditorTestCasesStore } from '../core/test-cases';
|
|
10
|
+
import type { EditorTestCasesOptions } from '../core/test-cases';
|
|
11
|
+
import type { EditorPanelPersistenceState } from '../core/editor-panel';
|
|
12
|
+
import { EditorWorkspace } from '../core/EditorWorkspace';
|
|
13
|
+
import { ServerStatusStore } from '../core/server-status';
|
|
14
|
+
import { ConnectionStatusController, ConnectionStatusStore } from '../core/connection-status';
|
|
15
|
+
import type { EditorCapabilities, EditorCapabilitiesOverride, EditorMode } from '../core/editor-capabilities';
|
|
34
16
|
import type { AiProviderOption, EditorOptions } from '../types/editor';
|
|
17
|
+
import type { FieldChangeHandler } from '../core/FieldChangeRegistry';
|
|
35
18
|
import type { RuleChainData } from '../types/rule-chain';
|
|
36
19
|
import type { ComponentDefinition, RawComponentData } from '../types/component';
|
|
37
|
-
import type {
|
|
20
|
+
import type { DiagnosticItem } from '../core/topology-rules';
|
|
21
|
+
import type { ComponentManageDialogTab, SettingsDialogTab } from './editor-dialogs';
|
|
22
|
+
import type { CanvasGridType } from './canvas-view';
|
|
38
23
|
import type { AutoLayoutOptions } from '../core/AutoLayout';
|
|
24
|
+
import { ApiProvider } from '../api/ApiProvider';
|
|
25
|
+
import type { ApiCacheKey } from '../api/types';
|
|
26
|
+
import type { ApiAuthRequiredHandler } from '../api/types';
|
|
27
|
+
import type { EditorActionSource } from '../core/ActionRegistry';
|
|
28
|
+
import { type NodePickerOpenOptions } from './editor-overlays';
|
|
39
29
|
export declare function normalizeComponentsRawPayload(data: unknown): unknown;
|
|
40
30
|
export declare function normalizeComponentsPayload(data: unknown): ComponentDefinition[];
|
|
41
31
|
export declare function applyComponentsRuntimePayloadOptions(opts: Record<string, any>, data: unknown): unknown;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
32
|
+
export type EditorSaveMode = 'builtin' | 'host';
|
|
33
|
+
export type ExternalDataUpdatePolicy = 'replace' | 'preserve-dirty';
|
|
34
|
+
export interface EditorShellPersistenceOptions {
|
|
35
|
+
adapter: EditorPersistenceAdapter;
|
|
36
|
+
namespace: EditorPersistenceNamespace;
|
|
37
|
+
migrateFromVersions?: ReadonlyArray<string | number>;
|
|
38
|
+
dockMigrate?: (state: unknown, context: EditorPersistenceMigrationContext) => EditorDockPersistenceState | null | undefined;
|
|
39
|
+
panelMigrate?: (state: unknown, context: EditorPersistenceMigrationContext) => EditorPanelPersistenceState | null | undefined;
|
|
40
|
+
}
|
|
41
|
+
export interface EditorRecentComponentsOptions {
|
|
42
|
+
persistence?: RecentComponentsPersistenceOptions;
|
|
43
|
+
maxEntries?: number;
|
|
44
|
+
topN?: number;
|
|
45
|
+
halfLifeDays?: number;
|
|
46
|
+
}
|
|
47
|
+
export interface EditorRunTestCasesOptions extends Omit<EditorTestCasesOptions, 'persistence'> {
|
|
48
|
+
persistence?: EditorTestCasesOptions['persistence'];
|
|
49
|
+
}
|
|
50
|
+
export interface EditorSaveResult {
|
|
51
|
+
success: boolean;
|
|
52
|
+
mode: EditorSaveMode;
|
|
53
|
+
data: RuleChainData;
|
|
54
|
+
chainId: string;
|
|
55
|
+
message?: string;
|
|
56
|
+
verified?: boolean;
|
|
57
|
+
error?: unknown;
|
|
58
|
+
}
|
|
59
|
+
export interface EditorSaveConflictContext {
|
|
60
|
+
chainId: string;
|
|
61
|
+
baseline: RuleChainData;
|
|
62
|
+
remote: unknown;
|
|
63
|
+
current: RuleChainData;
|
|
64
|
+
}
|
|
65
|
+
export interface EditorOptionsUpdateResult {
|
|
66
|
+
appliedKeys: string[];
|
|
67
|
+
structuralKeys: string[];
|
|
68
|
+
dataConflict: boolean;
|
|
69
|
+
}
|
|
70
|
+
export type EditorSaveHandlerResult = void | boolean | {
|
|
71
|
+
success?: boolean;
|
|
72
|
+
msg?: string;
|
|
73
|
+
message?: string;
|
|
74
|
+
};
|
|
75
|
+
export type EditorSaveHandler = (data: RuleChainData) => EditorSaveHandlerResult | Promise<EditorSaveHandlerResult>;
|
|
45
76
|
export interface HuanbanRulegoEditorOptions {
|
|
46
|
-
/** 容器 — CSS 选择器字符串 或 DOM 元素 */
|
|
47
77
|
container: string | HTMLElement;
|
|
48
|
-
/** API 基础地址 (如 'http://127.0.0.1:9090/api/v1'),用于 HuanbanRulegoEditor.fetchData */
|
|
49
78
|
apiBase?: string;
|
|
50
|
-
|
|
79
|
+
wsUrl?: string;
|
|
80
|
+
wsBase?: string;
|
|
81
|
+
wsRoot?: string;
|
|
82
|
+
debugWsUrl?: string;
|
|
83
|
+
debugWsBase?: string;
|
|
84
|
+
debugWsOptions?: Record<string, unknown>;
|
|
85
|
+
debugWsMaxReconnects?: number;
|
|
86
|
+
debugWsMaxLifetimeReconnects?: number;
|
|
87
|
+
debugWsReconnectBaseDelayMs?: number;
|
|
88
|
+
debugWsReconnectMaxDelayMs?: number;
|
|
51
89
|
fetchTimeout?: number;
|
|
52
|
-
/**
|
|
53
|
-
* 自定义请求 headers — 用于 API 认证 (如 Bearer Token)
|
|
54
|
-
*
|
|
55
|
-
* 支持两种形式:
|
|
56
|
-
* 1. 静态对象: { Authorization: 'Bearer xxx' }
|
|
57
|
-
* 2. 动态函数: () => ({ Authorization: `Bearer ${localStorage.getItem('token')}` })
|
|
58
|
-
*
|
|
59
|
-
* 所有编辑器内部的 fetch 请求(保存、部署、组件加载等)都会自动携带这些 headers
|
|
60
|
-
*/
|
|
61
90
|
fetchHeaders?: Record<string, string> | (() => Record<string, string>);
|
|
62
|
-
|
|
63
|
-
* 自定义 fetch 函数 — 完全替换原生 fetch
|
|
64
|
-
*
|
|
65
|
-
* 当需要自定义请求逻辑(如统一认证拦截、请求签名、错误重试等)时使用。
|
|
66
|
-
* 函数签名与原生 fetch 一致: (url, init) => Promise<Response>
|
|
67
|
-
*
|
|
68
|
-
* 注意: fetchHeaders 仍会合并到 init.headers 中(如果同时配置了的话)
|
|
69
|
-
*
|
|
70
|
-
* @example
|
|
71
|
-
* customFetch: (url, init) => {
|
|
72
|
-
* init.headers = { ...init.headers, Authorization: `Bearer ${getToken()}` }
|
|
73
|
-
* return fetch(url, init)
|
|
74
|
-
* }
|
|
75
|
-
*/
|
|
91
|
+
apiCacheKey?: ApiCacheKey;
|
|
76
92
|
customFetch?: (url: string, init?: RequestInit) => Promise<Response>;
|
|
77
|
-
/** 允许携带敏感 headers 的 API origin 白名单;默认包含同源和 apiBase origin */
|
|
78
93
|
allowedApiOrigins?: string[];
|
|
79
|
-
/** 请求返回 401/403 时触发,宿主可在此刷新登录态 */
|
|
80
94
|
onAuthExpired?: (response: Response) => void;
|
|
81
|
-
|
|
95
|
+
onApiAuthRequired?: ApiAuthRequiredHandler;
|
|
82
96
|
clearToken?: () => void;
|
|
83
|
-
|
|
97
|
+
enableConnectionStatus?: boolean;
|
|
84
98
|
data?: RuleChainData | null;
|
|
85
|
-
|
|
99
|
+
dataUpdatePolicy?: ExternalDataUpdatePolicy;
|
|
86
100
|
components?: RawComponentData;
|
|
87
|
-
/** AI 供应商预设;兼容 editorOptions.aiProviders */
|
|
88
101
|
aiProviders?: AiProviderOption[];
|
|
89
|
-
/** 运行面板 AI 对话发送到 /rules/{chainId}/v1/chat/completions 的模型名 */
|
|
90
102
|
runChatModel?: string;
|
|
91
|
-
/** 兼容旧集成命名;未设置 runChatModel 时作为运行面板 AI 对话默认模型 */
|
|
92
103
|
defaultChatModel?: string;
|
|
93
|
-
/** Embedding AI 供应商预设;供本地意图识别等 providerType=embedding 字段使用 */
|
|
94
104
|
aiEmbeddingProviders?: AiProviderOption[];
|
|
95
|
-
/** /components 原始载荷,保留 builtins、skillPath 等属性抽屉需要的附加协议 */
|
|
96
105
|
componentsPayload?: unknown;
|
|
97
|
-
/** 兼容历史命名:部分集成方使用 componentPayload 传入 /components 原始载荷 */
|
|
98
106
|
componentPayload?: unknown;
|
|
99
|
-
/** 内置 AI 工具列表;默认从 componentsPayload.builtins['ai/tools'].tools 提取 */
|
|
100
107
|
builtinTools?: any[];
|
|
101
|
-
/** 兼容旧版顶层 tools 字段 */
|
|
102
108
|
tools?: any[];
|
|
103
|
-
/** 后端返回的技能目录路径,用于 skill 内置工具提示 */
|
|
104
109
|
skillPath?: string;
|
|
105
|
-
/** LogicFlow 额外配置 (会与默认配置合并) */
|
|
106
110
|
lfOptions?: Record<string, unknown>;
|
|
107
|
-
/** LogicFlow 插件数组 (不传则自动从全局获取) */
|
|
108
111
|
lfPlugins?: any[];
|
|
109
|
-
/** EditorCore 额外配置 */
|
|
110
112
|
coreOptions?: Partial<EditorOptions>;
|
|
111
|
-
|
|
113
|
+
canvasGridType?: CanvasGridType;
|
|
114
|
+
hideEdgeLabels?: boolean;
|
|
115
|
+
fieldChangeContributions?: Record<string, FieldChangeHandler>;
|
|
116
|
+
persistence?: EditorShellPersistenceOptions;
|
|
117
|
+
recentComponents?: EditorRecentComponentsOptions;
|
|
118
|
+
testCases?: EditorRunTestCasesOptions;
|
|
119
|
+
mode?: EditorMode;
|
|
120
|
+
capabilities?: EditorCapabilitiesOverride;
|
|
121
|
+
disabled?: boolean;
|
|
112
122
|
showToolbar?: boolean;
|
|
113
|
-
/** 工具栏左侧标题 (不设置则不显示标题区域) */
|
|
114
123
|
toolbarTitle?: string;
|
|
115
|
-
/** 是否显示工具栏按钮文字,默认 false;设为 true 时显示图标 + 文字 */
|
|
116
124
|
showToolbarButtonLabels?: boolean;
|
|
117
|
-
/** 工具栏是否只显示图标,默认 true;显式 false 时可显示文字 */
|
|
118
125
|
toolbarIconOnly?: boolean;
|
|
119
|
-
/** 是否显示侧边栏, 默认 true */
|
|
120
126
|
showSidebar?: boolean;
|
|
121
|
-
/** 侧边栏宽度, 默认 220 */
|
|
122
127
|
sidebarWidth?: number;
|
|
123
|
-
/** 侧边栏是否默认收起, 默认 false */
|
|
124
128
|
sidebarCollapsed?: boolean;
|
|
125
|
-
|
|
129
|
+
sidebarVirtualization?: {
|
|
130
|
+
enabled?: boolean;
|
|
131
|
+
threshold?: number;
|
|
132
|
+
itemHeight?: number;
|
|
133
|
+
viewportHeight?: number;
|
|
134
|
+
overscan?: number;
|
|
135
|
+
};
|
|
126
136
|
showInfoButton?: boolean;
|
|
127
|
-
/** 是否在画布右上工具条显示「AI 助手」按钮, 默认 true */
|
|
128
137
|
showAiChatButton?: boolean;
|
|
129
|
-
/** 是否在画布右上工具条显示「调试面板」按钮, 默认 true */
|
|
130
138
|
showDebugConsoleButton?: boolean;
|
|
131
|
-
/** 是否在画布右上工具条显示「清除调试高亮」按钮, 默认 true */
|
|
132
139
|
showClearDebugHighlightButton?: boolean;
|
|
133
|
-
/** 是否在画布右上工具条显示「框选」按钮, 默认 false */
|
|
134
140
|
showSelectionButton?: boolean;
|
|
135
|
-
|
|
141
|
+
showDiagnosticsButton?: boolean;
|
|
136
142
|
showSettingsButton?: boolean;
|
|
137
|
-
/** 编辑器就绪 */
|
|
138
143
|
onReady?: (ctx: {
|
|
139
144
|
lf: LogicFlow;
|
|
140
145
|
core: EditorCore;
|
|
141
146
|
}) => void;
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
147
|
+
saveMode?: EditorSaveMode;
|
|
148
|
+
saveHandler?: EditorSaveHandler;
|
|
149
|
+
onSave?: EditorSaveHandler;
|
|
150
|
+
onSaveRequest?: (data: RuleChainData) => void;
|
|
151
|
+
onSaveSuccess?: (result: EditorSaveResult) => void;
|
|
152
|
+
onSaveError?: (result: EditorSaveResult) => void;
|
|
153
|
+
onSaveConflict?: (ctx: EditorSaveConflictContext) => boolean | Promise<boolean>;
|
|
154
|
+
onExternalDataConflict?: (ctx: {
|
|
155
|
+
current: RuleChainData | null;
|
|
156
|
+
incoming: RuleChainData;
|
|
157
|
+
}) => void;
|
|
153
158
|
onNodeClick?: (data: unknown) => void;
|
|
154
|
-
/** 节点双击 */
|
|
155
159
|
onNodeDbClick?: (data: unknown) => void;
|
|
156
|
-
/** 边点击 */
|
|
157
160
|
onEdgeClick?: (data: unknown) => void;
|
|
158
|
-
/** 数据变化 */
|
|
159
161
|
onChange?: () => void;
|
|
160
|
-
/**
|
|
161
|
-
* 点击「信息」按钮的回调 (slot 概念)
|
|
162
|
-
* 包只提供链数据, 布局渲染由调用方决定
|
|
163
|
-
* @param chainInfo 当前规则链的配置信息 (ruleChain 对象)
|
|
164
|
-
*/
|
|
165
162
|
onInfoClick?: (chainInfo: any) => void;
|
|
166
|
-
/** 劫持默认设置弹窗,供 Vue/React 宿主使用自定义组件化设置页 */
|
|
167
163
|
onSettingsClick?: (ctx: {
|
|
168
164
|
initialTab?: SettingsDialogTab;
|
|
169
165
|
apiBase?: string;
|
|
170
166
|
baseUrl?: string;
|
|
171
167
|
browserConsoleLog?: boolean;
|
|
172
168
|
}) => void;
|
|
173
|
-
/** 内置设置弹窗保存系统设置后触发 */
|
|
174
169
|
onSettingsSubmit?: (data: {
|
|
175
170
|
apiBase: string;
|
|
176
171
|
baseUrl: string;
|
|
177
172
|
browserConsoleLog?: boolean;
|
|
178
173
|
}) => void;
|
|
179
|
-
/** 示例/宿主调试日志是否允许输出到浏览器 console;核心仅在设置弹窗中透传该偏好 */
|
|
180
174
|
browserConsoleLog?: boolean;
|
|
181
|
-
/** 内置设置弹窗点击登录时触发;未提供时仅提示宿主接入 */
|
|
182
175
|
onLoginClick?: () => void;
|
|
183
|
-
/** 是否在工具栏显示「导出」按钮, 默认 true (已有导出功能则显示增强弹窗) */
|
|
184
176
|
showExportDialog?: boolean;
|
|
185
|
-
/** 劫持导出行为, 调用方自行处理; 不设则使用内置弹窗 */
|
|
186
177
|
onExportDSL?: (data: {
|
|
187
178
|
json: string;
|
|
188
179
|
imageDataUrl?: string;
|
|
189
180
|
}) => void;
|
|
190
|
-
/** 劫持导入行为; 不设则使用内置 loadData 导入当前规则链 */
|
|
191
181
|
onImportDSL?: (data: RuleChainData) => void;
|
|
192
|
-
/** 是否在画布右上工具条显示「运行」按钮, 默认 true */
|
|
193
182
|
showRunButton?: boolean;
|
|
194
|
-
/** 劫持运行行为; 不设则使用内置运行 Drawer */
|
|
195
183
|
onRunClick?: (chainId: string) => void;
|
|
196
|
-
/** 是否在工具栏显示「链追溯」按钮, 默认 false */
|
|
197
184
|
showTraceButton?: boolean;
|
|
198
|
-
/** 点击「链追溯」按钮回调,回传当前完整的规则链数据 (用于构建追溯底图) */
|
|
199
185
|
onTraceClick?: (chainInfo: any) => void;
|
|
200
|
-
/** 是否在工具栏显示「组件管理」按钮, 默认 false */
|
|
201
186
|
showComponentManage?: boolean;
|
|
202
|
-
|
|
203
|
-
onComponentManage?: () => void;
|
|
204
|
-
/** 语言设置, 默认 'zh_cn' */
|
|
187
|
+
onComponentManage?: (initialTab?: ComponentManageDialogTab) => void;
|
|
205
188
|
locale?: string;
|
|
206
|
-
/** 初始主题;支持 default/dark/nature/elegant/tech/modern,兼容 light/blue 旧写法 */
|
|
207
189
|
theme?: string;
|
|
208
|
-
/** 劫持语言切换 */
|
|
209
190
|
onLocaleChange?: (locale: string) => void;
|
|
210
|
-
/** 是否在节点 Drawer 中显示调试日志 Tab, 默认 true (有 apiBase 时) */
|
|
211
191
|
showDebugTab?: boolean;
|
|
212
|
-
/** 是否在工具栏显示「部署」按钮, 默认 true */
|
|
213
192
|
showDeployButton?: boolean;
|
|
214
|
-
|
|
193
|
+
showRestartButton?: boolean;
|
|
215
194
|
showReloadButton?: boolean;
|
|
216
|
-
|
|
217
|
-
|
|
195
|
+
onDeploy?: (chainId: string, action: 'start' | 'stop') => void | boolean | {
|
|
196
|
+
success?: boolean;
|
|
197
|
+
msg?: string;
|
|
198
|
+
message?: string;
|
|
199
|
+
} | Promise<void | boolean | {
|
|
200
|
+
success?: boolean;
|
|
201
|
+
msg?: string;
|
|
202
|
+
message?: string;
|
|
203
|
+
}>;
|
|
204
|
+
onRestart?: (chainId: string) => void | boolean | {
|
|
218
205
|
success?: boolean;
|
|
219
206
|
msg?: string;
|
|
220
207
|
message?: string;
|
|
@@ -223,284 +210,167 @@ export interface HuanbanRulegoEditorOptions {
|
|
|
223
210
|
msg?: string;
|
|
224
211
|
message?: string;
|
|
225
212
|
}>;
|
|
226
|
-
|
|
213
|
+
onRestartConfirm?: (context: {
|
|
214
|
+
chainId: string;
|
|
215
|
+
dirty: boolean;
|
|
216
|
+
effects: string[];
|
|
217
|
+
}) => boolean | Promise<boolean>;
|
|
227
218
|
ruleItems?: any[];
|
|
228
|
-
/** 规则链 API 地址 (如 '/rules'), 用于远程加载规则链列表 */
|
|
229
219
|
rulesApi?: string;
|
|
230
|
-
/** 选择规则链后的回调 */
|
|
231
220
|
onSelectRuleChain?: (ruleChain: any) => void;
|
|
232
|
-
/** 劫持删除规则链; 不设则使用内置 API 调用 */
|
|
233
221
|
onDeleteRuleChain?: (chainId: string) => void;
|
|
234
|
-
/** 是否在工具栏显示「运行记录」按钮, 默认 true (有 apiBase 时) */
|
|
235
222
|
showRunHistory?: boolean;
|
|
236
|
-
/** 劫持运行记录; 不设则根据 runHistoryUrl 打开新窗口 */
|
|
237
223
|
onRunHistory?: (chainId: string) => void;
|
|
238
|
-
/** 运行记录页面 URL (支持 {chainId} 占位符), 如 'http://xxx/ui/#/workflow/runs?chainId={chainId}' */
|
|
239
224
|
runHistoryUrl?: string;
|
|
240
225
|
}
|
|
241
226
|
export interface AIAssistantOpenOptions {
|
|
242
|
-
/** 打开后默认从此节点上下文发起对话/调试 */
|
|
243
227
|
fromNodeId?: string;
|
|
244
|
-
/** 仅使用指定节点上下文 */
|
|
245
228
|
onlyThisNode?: boolean;
|
|
246
|
-
/** 宿主或内部入口标识,例如 skills/components/debug */
|
|
247
229
|
section?: string;
|
|
248
230
|
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
* 以及 Node-RED 风格的组件侧边栏。
|
|
254
|
-
*
|
|
255
|
-
* @example
|
|
256
|
-
* ```js
|
|
257
|
-
* const editor = new HuanbanRulegoEditor({
|
|
258
|
-
* container: '#editor',
|
|
259
|
-
* data: ruleChainJSON,
|
|
260
|
-
* components: componentsArray,
|
|
261
|
-
* })
|
|
262
|
-
* ```
|
|
263
|
-
*/
|
|
231
|
+
export interface HuanbanRulegoEditorLoadOptions {
|
|
232
|
+
allowDuplicateWorkspaceTab?: boolean;
|
|
233
|
+
preserveWorkspaceTab?: boolean;
|
|
234
|
+
}
|
|
264
235
|
export declare class HuanbanRulegoEditor {
|
|
265
|
-
/** LogicFlow 画布实例 */
|
|
266
236
|
lf: LogicFlow | null;
|
|
267
|
-
/** EditorCore 数据引擎 */
|
|
268
237
|
core: EditorCore | null;
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
238
|
+
readonly workspace: EditorWorkspace;
|
|
239
|
+
readonly dock: EditorDockStore;
|
|
240
|
+
readonly panels: EditorPanelRegistry;
|
|
241
|
+
readonly serverStatus: ServerStatusStore;
|
|
242
|
+
readonly connectionStatus: ConnectionStatusStore;
|
|
243
|
+
readonly connectionStatusController: ConnectionStatusController;
|
|
244
|
+
readonly apiProvider: ApiProvider;
|
|
245
|
+
capabilities: EditorCapabilities;
|
|
246
|
+
rootEl: HTMLElement | null;
|
|
247
|
+
canvasEl: HTMLElement | null;
|
|
248
|
+
sidebarEl: HTMLElement | null;
|
|
249
|
+
sidebarGroupsEl: HTMLElement | null;
|
|
250
|
+
searchInputEl: HTMLInputElement | null;
|
|
251
|
+
_activeDrawerWrapper: HTMLElement | null;
|
|
252
|
+
_activeModalWrapper: HTMLElement | null;
|
|
275
253
|
private statusNodes;
|
|
276
254
|
private statusEdges;
|
|
277
|
-
/** 状态栏 — 更新时间元素 */
|
|
278
255
|
private statusUpdateTime;
|
|
279
|
-
/** 状态栏 — 运行状态元素 */
|
|
280
256
|
private statusRunState;
|
|
281
|
-
/** 侧边栏是否折叠 */
|
|
282
257
|
private sidebarCollapsed;
|
|
283
|
-
/** 工具栏图标定义;画布浮动工具条需要在 LogicFlow 初始化后重建一次 */
|
|
284
258
|
private toolbarIcons;
|
|
285
259
|
private aiAssistantOpen;
|
|
286
260
|
private aiAssistantUnread;
|
|
261
|
+
private workspaceTabId;
|
|
287
262
|
private savedSnapshotJson;
|
|
263
|
+
private isFlushingPendingDrawer;
|
|
288
264
|
private isLoadingDataIntoCanvas;
|
|
289
|
-
|
|
265
|
+
private diagnosticItems;
|
|
266
|
+
private diagnosticTimer;
|
|
267
|
+
private readyTimer;
|
|
268
|
+
private autoLoadComponentsController;
|
|
269
|
+
private initialDataLoadTimer;
|
|
270
|
+
private initialDataCompletion;
|
|
271
|
+
private initialDataLoaded;
|
|
272
|
+
private componentRebindEligible;
|
|
273
|
+
private destroyed;
|
|
274
|
+
private transportGeneration;
|
|
290
275
|
components: ComponentDefinition[];
|
|
291
|
-
|
|
276
|
+
readonly recentComponents: RecentComponentsStore;
|
|
277
|
+
readonly testCases: EditorTestCasesStore;
|
|
292
278
|
expandedGroups: Set<string>;
|
|
293
|
-
/** 配置 @internal */
|
|
294
279
|
opts: HuanbanRulegoEditorOptions;
|
|
295
|
-
/** 国际化管理器 @internal */
|
|
296
280
|
i18n: I18nManager;
|
|
297
|
-
/** 当前主题标识 @internal */
|
|
298
281
|
_currentTheme: string;
|
|
299
|
-
/** 键盘快捷键清理函数 @internal */
|
|
300
282
|
private _cleanupShortcuts;
|
|
301
|
-
/** 右键菜单清理函数 @internal */
|
|
302
283
|
private _cleanupContextMenu;
|
|
303
|
-
|
|
284
|
+
private _cleanupEdgeLabelQuickEditor;
|
|
304
285
|
private _cleanupBridgeEvents;
|
|
305
|
-
|
|
286
|
+
private _cleanupCoreState;
|
|
287
|
+
private _cleanupConnectionStatus;
|
|
306
288
|
private _cleanupFullscreenState;
|
|
307
|
-
|
|
289
|
+
_themeMenuBindTimer: ReturnType<typeof setTimeout> | null;
|
|
290
|
+
_themeMenuOutsideClickHandler: ((event: MouseEvent) => void) | null;
|
|
308
291
|
_miniMapVisible: boolean;
|
|
309
|
-
/** 内部剪贴板 (用于 Ctrl+C/V 复制粘贴节点) @internal */
|
|
310
292
|
_clipboard: any[];
|
|
311
|
-
/** 自动排版进行中标志 — edge:add 事件检查此标志,跳过弹窗 @internal */
|
|
312
293
|
_isAutoLayouting: boolean;
|
|
313
|
-
/** 数据加载后是否需要自动优化布局 @internal */
|
|
314
294
|
_pendingAutoOptimize: boolean;
|
|
315
295
|
constructor(options: HuanbanRulegoEditorOptions);
|
|
316
|
-
/**
|
|
317
|
-
* 翻译便捷方法 — 从当前语言包获取文本
|
|
318
|
-
* @param key 翻译键 (如 'editor.toolbar.save')
|
|
319
|
-
* @param params 插值变量
|
|
320
|
-
* @returns 翻译后的文本
|
|
321
|
-
*/
|
|
322
296
|
t(key: string, params?: Record<string, string | number>): string;
|
|
323
|
-
/**
|
|
324
|
-
* 切换语言
|
|
325
|
-
* @param locale 语言标识 (zh_cn / en 等)
|
|
326
|
-
*/
|
|
327
297
|
setLocale(locale: string): void;
|
|
328
|
-
/**
|
|
329
|
-
* 切换主题。
|
|
330
|
-
* 供 React/Vue/原生宿主用代码控制主题,与内置主题下拉使用同一套逻辑。
|
|
331
|
-
*/
|
|
332
298
|
setTheme(theme: string): void;
|
|
333
|
-
|
|
299
|
+
registerFieldChangeHandler(name: string, handler: FieldChangeHandler, overwrite?: boolean): void;
|
|
300
|
+
unregisterFieldChangeHandler(name: string): boolean;
|
|
334
301
|
getTheme(): string;
|
|
335
|
-
|
|
336
|
-
* 获取 I18nManager 实例 (供外部扩展语言包)
|
|
337
|
-
*/
|
|
302
|
+
_getTransportGeneration(): number;
|
|
338
303
|
getI18n(): I18nManager;
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
*/
|
|
304
|
+
get runtimeFields(): import("..").RuntimeFieldDictionary | null;
|
|
305
|
+
updateOptions(patch: Partial<Omit<HuanbanRulegoEditorOptions, 'container'>>): EditorOptionsUpdateResult;
|
|
306
|
+
private _syncRuntimeOptionUi;
|
|
343
307
|
toggleMiniMap(): void;
|
|
344
|
-
/**
|
|
345
|
-
* 切换画布节点搜索栏的显示/隐藏
|
|
346
|
-
* 搜索匹配的节点会被高亮并定位
|
|
347
|
-
*/
|
|
348
308
|
toggleNodeSearch(): void;
|
|
349
|
-
/**
|
|
350
|
-
* 在画布中搜索节点 — 匹配节点文本/类型/属性名
|
|
351
|
-
* 匹配节点添加高亮样式,自动聚焦第一个匹配节点
|
|
352
|
-
* @param keyword - 搜索关键词
|
|
353
|
-
* @returns 匹配的节点数量
|
|
354
|
-
* @internal
|
|
355
|
-
*/
|
|
356
309
|
_searchNodes(keyword: string): number;
|
|
357
|
-
/**
|
|
358
|
-
* 清除画布节点搜索高亮
|
|
359
|
-
* @internal
|
|
360
|
-
*/
|
|
361
310
|
_clearNodeSearchHighlight(): void;
|
|
362
|
-
/**
|
|
363
|
-
* 编辑器初始化入口 — 创建 DOM、LogicFlow、EditorCore 并桥接事件
|
|
364
|
-
* 在构造函数中被调用
|
|
365
|
-
*/
|
|
366
311
|
private init;
|
|
312
|
+
private _startInitialDataLoadGate;
|
|
313
|
+
private _bindCoreStateSync;
|
|
314
|
+
private _prepareForChainSwitch;
|
|
367
315
|
private createDOM;
|
|
368
|
-
/** 渲染画布右上浮动工具条;LogicFlow 初始化会清空画布容器,因此 init 后也会调用一次 */
|
|
369
316
|
private _renderCanvasToolbar;
|
|
370
|
-
/** 工具栏按钮点击事件 — 实现已提取到 editor-toolbar.ts */
|
|
371
317
|
private handleToolbarClick;
|
|
372
|
-
/**
|
|
373
|
-
* 更新缩放百分比标签 — 从 LogicFlow 获取当前 transform.SCALE_X
|
|
374
|
-
* @internal
|
|
375
|
-
*/
|
|
376
318
|
_updateZoomLabel(): void;
|
|
377
|
-
/** 获取当前主题标签 (供 createDOM 使用) */
|
|
378
319
|
private _currentThemeLabel;
|
|
379
|
-
/** 事件桥接 — 实现已提取到 editor-events.ts */
|
|
380
320
|
private bridgeEvents;
|
|
381
|
-
/** 渲染侧边栏组件列表 — 实现已提取到 editor-sidebar.ts */
|
|
382
321
|
renderSidebar(): void;
|
|
383
|
-
/** 当前选中的节点/边/正在添加的节点/边 @internal */
|
|
384
322
|
_currentNode: any;
|
|
385
323
|
_currentEdge: any;
|
|
386
324
|
_currentAddNode: any;
|
|
387
325
|
_currentAddEdge: any;
|
|
388
|
-
|
|
326
|
+
_propertyOptionsController?: AbortController;
|
|
327
|
+
_propertyDrawerRequestGeneration: number;
|
|
389
328
|
_operateNodeData: any;
|
|
390
|
-
/** 操作栏关联的连线数据缓存,防止 blank:click 清空 _currentEdge 后丢失引用 @internal */
|
|
391
329
|
_operateEdgeData: any;
|
|
392
|
-
/** 操作栏正在交互标志 — blank:click 检测到此标志时跳过清空 @internal */
|
|
393
330
|
_operateBarInteracting: boolean;
|
|
394
|
-
/** nodeComponents: 组件类型 → 组件定义 @internal */
|
|
395
331
|
_nodeComponents: Record<string, any>;
|
|
396
|
-
/**
|
|
397
|
-
* 处理编辑元素 — 照搬原版 handleEditElement
|
|
398
|
-
* @param fromAdd 是否从拖入/新增触发
|
|
399
|
-
*/
|
|
400
332
|
private _handleEditElement;
|
|
401
|
-
/** @internal 子模块(editor-events)使用 */
|
|
402
333
|
_showNodeOperate(data: any): void;
|
|
403
|
-
/** @internal 子模块(editor-events)使用 */
|
|
404
334
|
_showEdgeOperate(data: any): void;
|
|
405
335
|
private _hideNodeOperate;
|
|
406
|
-
/**
|
|
407
|
-
* 显示节点属性编辑 Drawer
|
|
408
|
-
* 实现已提取到 editor-property-drawers.ts
|
|
409
|
-
*/
|
|
410
336
|
private _showNodePropertyDrawer;
|
|
411
|
-
/**
|
|
412
|
-
* 显示边属性编辑 Drawer
|
|
413
|
-
* 实现已提取到 editor-property-drawers.ts
|
|
414
|
-
*/
|
|
415
337
|
private _showEdgePropertyDrawer;
|
|
416
|
-
/** 关闭 Drawer */
|
|
417
|
-
/** @internal 子模块(editor-property-drawers)使用 */
|
|
418
338
|
_closeDrawer(): void;
|
|
419
|
-
/** 关闭弹窗 */
|
|
420
|
-
/** @internal 子模块(editor-dialogs)使用 */
|
|
421
339
|
_closeModal(): void;
|
|
422
|
-
/** 标记画布存在未保存修改。供事件桥接和属性抽屉复用。 */
|
|
423
|
-
/** @internal */
|
|
424
340
|
_markDirty(reason?: string): void;
|
|
425
|
-
/** 保存或加载完成后记录前端 diff 的基线快照。 */
|
|
426
|
-
/** @internal */
|
|
427
341
|
_markSavedSnapshot(data?: RuleChainData | null): void;
|
|
428
|
-
|
|
429
|
-
/** @internal */
|
|
342
|
+
_getSavedSnapshot(): RuleChainData | null;
|
|
430
343
|
_markSavedSnapshotFromCanvas(): void;
|
|
431
|
-
|
|
344
|
+
private _flushPendingDrawerChanges;
|
|
345
|
+
_syncChainLifecycle(action: 'start' | 'stop'): void;
|
|
346
|
+
private _scheduleTopologyDiagnostics;
|
|
347
|
+
runDiagnostics(): DiagnosticItem[];
|
|
348
|
+
openDiagnostics(): void;
|
|
349
|
+
private _renderDiagnosticsPanel;
|
|
350
|
+
private _applyDiagnosticMarkers;
|
|
432
351
|
private _updateDirtySaveUi;
|
|
433
|
-
/** 打开前端规则链 JSON 变更 diff 弹窗。 */
|
|
434
352
|
showUnsavedDiffDialog(): void;
|
|
435
|
-
/**
|
|
436
|
-
* 显示规则链选择器弹窗 — 支持搜索和分页
|
|
437
|
-
* 实现已提取到 editor-dialogs.ts
|
|
438
|
-
*/
|
|
439
|
-
/** @internal 子模块(editor-toolbar)使用 */
|
|
440
353
|
_showRuleChainSelector(): void;
|
|
441
|
-
/** @internal 子模块(editor-events)使用 */
|
|
442
354
|
updateStatusBar(): void;
|
|
443
|
-
/**
|
|
444
|
-
* 加载组件列表
|
|
445
|
-
* @param components 组件定义数组或 /api/v1/components 分段返回
|
|
446
|
-
*/
|
|
447
355
|
loadComponents(components: RawComponentData): void;
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
* 1. 用 DAG 拓扑排序算法计算每个节点的目标坐标
|
|
458
|
-
* 2. 删除边的 startPoint/endPoint/pointsList,保留 sourceAnchorId/targetAnchorId
|
|
459
|
-
* 3. 用 lf.render() 重新渲染图数据,强制 LogicFlow 从锚点重新计算连线路径
|
|
460
|
-
* 4. 边的文本只保留内容值,位置由 LogicFlow 在新路径上自动计算
|
|
461
|
-
*
|
|
462
|
-
* 为什么不用 moveNode:
|
|
463
|
-
* moveNode 只做坐标平移(startPoint += deltaX),不会重新绑定到锚点,
|
|
464
|
-
* 导致贝塞尔曲线的起止点和控制点错位,连线无法正确连到节点锚点。
|
|
465
|
-
*
|
|
466
|
-
* @param options - 可选排版参数 (层间距、节点间距等)
|
|
467
|
-
*/
|
|
356
|
+
reloadComponents(options?: {
|
|
357
|
+
forceRefresh?: boolean;
|
|
358
|
+
}): Promise<boolean>;
|
|
359
|
+
refreshConnectionStatuses(): void;
|
|
360
|
+
acquireSharedConnectionStatuses(): () => void;
|
|
361
|
+
private _requestConnectionStatuses;
|
|
362
|
+
loadData(data: RuleChainData, options?: HuanbanRulegoEditorLoadOptions): void;
|
|
363
|
+
activateWorkspaceTab(tabId: string): boolean;
|
|
364
|
+
loadImportedData(data: RuleChainData): void;
|
|
468
365
|
autoLayout(options?: AutoLayoutOptions): void;
|
|
469
|
-
/**
|
|
470
|
-
* 更新状态栏中的「更新时间」和「运行状态」
|
|
471
|
-
* @param ruleChain 规则链配置信息 (含 updateTime / disabled 字段)
|
|
472
|
-
* @internal
|
|
473
|
-
*/
|
|
474
366
|
_updateChainStatus(ruleChain?: import('../types/rule-chain').RuleChainConfig | null): void;
|
|
475
|
-
|
|
476
|
-
* 导出当前画布数据为 RuleGo 格式
|
|
477
|
-
* @returns RuleGo 规则链 JSON 数据
|
|
478
|
-
*/
|
|
367
|
+
_updateDeployToolbarAction(ruleChain?: import('../types/rule-chain').RuleChainConfig | null): void;
|
|
479
368
|
exportData(): RuleChainData | null;
|
|
480
|
-
/** 导出并在控制台输出 */
|
|
481
|
-
/** @internal 子模块(editor-toolbar)使用 */
|
|
482
369
|
exportAndLog(): void;
|
|
483
|
-
/** 切换侧边栏折叠/展开 */
|
|
484
370
|
toggleSidebar(): void;
|
|
485
|
-
/** 适应画布 */
|
|
486
371
|
fitView(): void;
|
|
487
|
-
/**
|
|
488
|
-
* 显示导入 DSL 弹窗
|
|
489
|
-
* 实现已提取到 editor-dialogs.ts
|
|
490
|
-
*/
|
|
491
|
-
/** @internal 子模块(editor-toolbar)使用 */
|
|
492
372
|
_showImportDialog(): void;
|
|
493
|
-
/**
|
|
494
|
-
* 显示导出 DSL 弹窗
|
|
495
|
-
* 实现已提取到 editor-dialogs.ts
|
|
496
|
-
*/
|
|
497
|
-
/** @internal 子模块(editor-toolbar)使用 */
|
|
498
373
|
_showExportDialog(): void;
|
|
499
|
-
/**
|
|
500
|
-
* 显示运行面板 Drawer
|
|
501
|
-
* 实现已提取到 editor-dialogs.ts
|
|
502
|
-
*/
|
|
503
|
-
/** @internal 子模块(editor-toolbar)使用 */
|
|
504
374
|
_showRunPanel(options?: {
|
|
505
375
|
fromNodeId?: string;
|
|
506
376
|
onlyThisNode?: boolean;
|
|
@@ -508,97 +378,28 @@ export declare class HuanbanRulegoEditor {
|
|
|
508
378
|
initialTab?: 'response' | 'resp_headers' | 'debug' | 'history' | 'integration';
|
|
509
379
|
section?: string;
|
|
510
380
|
}): void;
|
|
511
|
-
/** @internal 子模块(editor-toolbar)使用 */
|
|
512
381
|
_showSettingsDialog(initialTab?: SettingsDialogTab): void;
|
|
513
|
-
/** 公开打开设置弹窗;Vue/React 包可用该方法保持设置入口协议一致 */
|
|
514
382
|
openSettings(initialTab?: SettingsDialogTab): void;
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
383
|
+
invokeAction(id: string, source?: EditorActionSource): Promise<boolean>;
|
|
384
|
+
openCommandPalette(): void;
|
|
385
|
+
openShortcutHelp(): void;
|
|
386
|
+
startTour(): boolean;
|
|
387
|
+
closeTour(): void;
|
|
388
|
+
openNodePicker(options?: NodePickerOpenOptions): void;
|
|
389
|
+
openComponentDocs(initialType?: string): Promise<void>;
|
|
390
|
+
closeOverlay(): void;
|
|
391
|
+
closeAllOverlays(): void;
|
|
521
392
|
openAiAssistant(options?: AIAssistantOpenOptions): void;
|
|
522
|
-
/** 关闭当前 AI 助手/运行面板 Drawer */
|
|
523
393
|
closeAiAssistant(): void;
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
* 实现已提取到 editor-dialogs.ts
|
|
527
|
-
*/
|
|
528
|
-
/** @internal 子模块(editor-toolbar)使用 */
|
|
529
|
-
_showComponentManage(): void;
|
|
530
|
-
/**
|
|
531
|
-
* 获取当前规则链信息 (公开 API)
|
|
532
|
-
* 调用方可随时获取当前加载的链数据
|
|
533
|
-
* @returns 当前规则链配置对象, 未加载时返回 null
|
|
534
|
-
*/
|
|
394
|
+
_showComponentManage(initialTab?: ComponentManageDialogTab): void;
|
|
395
|
+
openComponentManager(initialTab?: ComponentManageDialogTab): void;
|
|
535
396
|
getChainInfo(): any | null;
|
|
536
|
-
/**
|
|
537
|
-
* 显示链信息 (公开 API)
|
|
538
|
-
* 如果配置了 onInfoClick 回调, 则将链数据传给回调由调用方渲染
|
|
539
|
-
* 如果没有配置回调, 则使用内置的简单 Drawer 展示
|
|
540
|
-
*/
|
|
541
397
|
showChainInfo(): void;
|
|
542
|
-
/**
|
|
543
|
-
* 内置的链信息 Drawer (默认实现)
|
|
544
|
-
* 完整展示规则链信息面板:
|
|
545
|
-
* 1. 基础信息 — ID、名称、根规则链、调试模式、描述
|
|
546
|
-
* 2. 输入定义 — additionalInfo.inputSchema 可视化/JSON 编辑
|
|
547
|
-
* 3. 变量和秘钥 — configuration.vars / configuration.secrets 表格
|
|
548
|
-
* 4. 平台集成 — 同步/异步调用接口 + MCP 集成
|
|
549
|
-
*/
|
|
550
398
|
private _showChainInfoDrawer;
|
|
551
|
-
/** HTML 转义工具方法 */
|
|
552
|
-
/** @internal 子模块(editor-property-drawers)使用 */
|
|
553
399
|
_escapeHtml(text: string): string;
|
|
554
|
-
/** 销毁编辑器 */
|
|
555
400
|
destroy(): void;
|
|
556
|
-
/**
|
|
557
|
-
* 从 API 自动加载组件列表
|
|
558
|
-
* 在 init() 中调用, 当没有传入 components 且有 apiBase 时触发
|
|
559
|
-
* @internal
|
|
560
|
-
*/
|
|
561
401
|
private _autoLoadComponents;
|
|
562
|
-
/**
|
|
563
|
-
* 通用数据请求方法 — 只从真实 API 加载,失败直接 reject。
|
|
564
|
-
*
|
|
565
|
-
* @param apiBase - API 基础地址 (如 'http://127.0.0.1:9090/api/v1')
|
|
566
|
-
* @param path - 请求路径 (如 '/components')
|
|
567
|
-
* @param legacyFallbackFile - 旧版本兼容参数,当前不再读取本地替代数据
|
|
568
|
-
* @param timeout - 超时毫秒数, 默认 5000
|
|
569
|
-
* @param headers - 可选的自定义请求头 (如认证 Token)
|
|
570
|
-
* @returns Promise<any> 解析后的 JSON 数据
|
|
571
|
-
*
|
|
572
|
-
* @example
|
|
573
|
-
* ```js
|
|
574
|
-
* HuanbanRulegoEditor.fetchData('http://api.example.com/api/v1', '/components')
|
|
575
|
-
* .then(data => console.log(data))
|
|
576
|
-
* ```
|
|
577
|
-
*/
|
|
578
402
|
static fetchData(apiBase: string, path: string, legacyFallbackFile?: string, timeout?: number, headers?: Record<string, string>): Promise<unknown>;
|
|
579
|
-
/**
|
|
580
|
-
* 开启/关闭编辑器内部调试日志
|
|
581
|
-
*
|
|
582
|
-
* 调试日志默认关闭,开启后会在控制台输出编辑器内部的事件桥接、
|
|
583
|
-
* 节点注册、画布渲染等详细调试信息。
|
|
584
|
-
*
|
|
585
|
-
* @param enabled - true: 开启调试日志, false: 关闭
|
|
586
|
-
*
|
|
587
|
-
* @example
|
|
588
|
-
* ```js
|
|
589
|
-
* // UMD 用法
|
|
590
|
-
* RuleGoEditorCore.HuanbanRulegoEditor.setDebug(true)
|
|
591
|
-
*
|
|
592
|
-
* // ESM 用法
|
|
593
|
-
* import { HuanbanRulegoEditor } from '@huanban/rulego-editor-core'
|
|
594
|
-
* HuanbanRulegoEditor.setDebug(true)
|
|
595
|
-
* ```
|
|
596
|
-
*/
|
|
597
403
|
static setDebug(enabled: boolean): void;
|
|
598
|
-
/**
|
|
599
|
-
* 查询调试日志是否开启
|
|
600
|
-
* @returns 当前调试模式是否开启
|
|
601
|
-
*/
|
|
602
404
|
static isDebug(): boolean;
|
|
603
405
|
}
|
|
604
|
-
//# sourceMappingURL=HuanbanRulegoEditor.d.ts.map
|