@blueking/flow-canvas 0.0.1-beta.3 → 0.0.1-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +37 -1
  2. package/dist/index.cjs.js +1 -1
  3. package/dist/index.d.ts +808 -33
  4. package/dist/index.esm.js +1 -1
  5. package/dist/style.css +1 -1
  6. package/package.json +2 -2
  7. package/dist/core/apply-command.d.ts +0 -11
  8. package/dist/core/editor.d.ts +0 -50
  9. package/dist/core/errors.d.ts +0 -6
  10. package/dist/core/history.d.ts +0 -15
  11. package/dist/core/plugin-manager.d.ts +0 -58
  12. package/dist/plugins/clipboard.d.ts +0 -9
  13. package/dist/plugins/connection-validator.d.ts +0 -3
  14. package/dist/plugins/minimap.d.ts +0 -7
  15. package/dist/plugins/selection.d.ts +0 -7
  16. package/dist/plugins/snapline.d.ts +0 -6
  17. package/dist/runtime/canvas-api.d.ts +0 -25
  18. package/dist/runtime/canvas-runtime-core.vue.d.ts +0 -31
  19. package/dist/runtime/event-bridge.d.ts +0 -28
  20. package/dist/runtime/graph-bridge.d.ts +0 -127
  21. package/dist/runtime/overlay-manager.d.ts +0 -3
  22. package/dist/runtime/shape-registry.d.ts +0 -8
  23. package/dist/runtime/use-edge-delete-tool.d.ts +0 -11
  24. package/dist/runtime/use-node-hover.d.ts +0 -10
  25. package/dist/runtime/use-port-visibility.d.ts +0 -15
  26. package/dist/shell/canvas-layout.vue.d.ts +0 -35
  27. package/dist/shell/canvas-node-palette.vue.d.ts +0 -10
  28. package/dist/shell/canvas-toolbar.vue.d.ts +0 -11
  29. package/dist/shell/default-node.vue.d.ts +0 -4
  30. package/dist/shell/default-schema.d.ts +0 -39
  31. package/dist/shell/node-actions-toolbar.vue.d.ts +0 -22
  32. package/dist/shell/node-quick-add-popover.vue.d.ts +0 -36
  33. package/dist/shell/toolbar-items.d.ts +0 -15
  34. package/dist/types/api.d.ts +0 -104
  35. package/dist/types/command.d.ts +0 -160
  36. package/dist/types/flow-model.d.ts +0 -46
  37. package/dist/types/history.d.ts +0 -18
  38. package/dist/types/overlay.d.ts +0 -3
  39. package/dist/types/plugin.d.ts +0 -64
  40. package/dist/types/schema.d.ts +0 -80
  41. package/dist/utils/path.d.ts +0 -7
  42. package/dist/utils/uuid.d.ts +0 -1
@@ -1,160 +0,0 @@
1
- import type { FlowNodeModel, FlowEdgeModel, FlowEdgeLabelModel, FlowModel } from './flow-model';
2
- export type CanvasCommand = {
3
- type: 'node.add';
4
- node: FlowNodeModel;
5
- } | {
6
- type: 'node.move';
7
- nodeId: string;
8
- position: {
9
- x: number;
10
- y: number;
11
- };
12
- } | {
13
- type: 'node.remove';
14
- nodeId: string;
15
- } | {
16
- type: 'node.update';
17
- nodeId: string;
18
- patch: Partial<Omit<FlowNodeModel, 'id' | 'payload' | 'extensions'>>;
19
- } | {
20
- type: 'node.set-payload';
21
- nodeId: string;
22
- path: string[];
23
- value: unknown;
24
- } | {
25
- type: 'node.set-extensions';
26
- nodeId: string;
27
- path: string[];
28
- value: unknown;
29
- } | {
30
- type: 'edge.add';
31
- edge: FlowEdgeModel;
32
- } | {
33
- type: 'edge.remove';
34
- edgeId: string;
35
- } | {
36
- type: 'edge.reconnect';
37
- edgeId: string;
38
- source?: {
39
- nodeId: string;
40
- portId?: string;
41
- };
42
- target?: {
43
- nodeId: string;
44
- portId?: string;
45
- };
46
- } | {
47
- type: 'edge.update';
48
- edgeId: string;
49
- patch: Partial<Omit<FlowEdgeModel, 'id' | 'payload' | 'extensions'>>;
50
- } | {
51
- type: 'edge.set-payload';
52
- edgeId: string;
53
- path: string[];
54
- value: unknown;
55
- } | {
56
- type: 'edge.label.update';
57
- edgeId: string;
58
- labelId: string;
59
- patch: Partial<FlowEdgeLabelModel>;
60
- } | {
61
- type: 'model.set-meta';
62
- path: string[];
63
- value: unknown;
64
- };
65
- export type CommandSource = 'user:drag' | 'user:keyboard' | 'user:toolbar' | 'user:quick-add' | 'user:panel' | 'plugin' | 'system' | 'system:replace';
66
- export interface CommandEnvelope {
67
- id: string;
68
- label?: string;
69
- source: CommandSource;
70
- timestamp: number;
71
- commands: CanvasCommand[];
72
- }
73
- export interface CommandExecutionResult {
74
- status: 'applied' | 'rejected' | 'invalid';
75
- envelope: Readonly<CommandEnvelope>;
76
- flowModel?: FlowModel;
77
- error?: CommandExecutionError;
78
- }
79
- export interface CommandExecutionError {
80
- code: 'plugin_rejected' | 'validation_failed' | 'constraint_violated';
81
- reason: string;
82
- source: string;
83
- details?: unknown;
84
- }
85
- export interface CommandRejection {
86
- rejected: true;
87
- reason: string;
88
- code?: string;
89
- }
90
- export interface CommandPreview {
91
- previewFlowModel(commands?: CanvasCommand[]): FlowModel;
92
- }
93
- export interface FlowModelChangeEvent {
94
- flowModel: Readonly<FlowModel>;
95
- prevFlowModel: Readonly<FlowModel>;
96
- envelope: Readonly<CommandEnvelope>;
97
- source: CommandSource;
98
- }
99
- export type ScreenPosition = {
100
- x: number;
101
- y: number;
102
- };
103
- export type CanvasPosition = {
104
- x: number;
105
- y: number;
106
- };
107
- export type CanvasUiEvent = {
108
- type: 'node.click';
109
- nodeId: string;
110
- } | {
111
- type: 'node.dblclick';
112
- nodeId: string;
113
- } | {
114
- type: 'node.contextmenu';
115
- nodeId: string;
116
- position: ScreenPosition;
117
- } | {
118
- type: 'node.quick-add';
119
- nodeId: string;
120
- position: ScreenPosition;
121
- } | {
122
- type: 'edge.click';
123
- edgeId: string;
124
- } | {
125
- type: 'edge.label.click';
126
- edgeId: string;
127
- labelId: string;
128
- } | {
129
- type: 'blank.click';
130
- position: CanvasPosition;
131
- } | {
132
- type: 'blank.contextmenu';
133
- position: ScreenPosition;
134
- } | {
135
- type: 'selection.change';
136
- nodeIds: string[];
137
- edgeIds: string[];
138
- } | {
139
- type: 'node.action.delete';
140
- nodeId: string;
141
- } | {
142
- type: 'node.action.copy';
143
- sourceNodeId: string;
144
- newNodeId: string;
145
- } | {
146
- type: 'node.action.copy-insert';
147
- sourceNodeId: string;
148
- newNodeId: string;
149
- } | {
150
- type: 'node.action.disconnect';
151
- nodeId: string;
152
- edgeIds: string[];
153
- } | {
154
- type: 'node.action.debug';
155
- nodeId: string;
156
- } | {
157
- type: 'node.action.quick-insert';
158
- sourceNodeId: string;
159
- newNodeId: string;
160
- };
@@ -1,46 +0,0 @@
1
- export interface FlowModel {
2
- version?: '1.0';
3
- nodes: Record<string, FlowNodeModel>;
4
- edges: Record<string, FlowEdgeModel>;
5
- meta?: Record<string, unknown>;
6
- extensions?: Record<string, unknown>;
7
- }
8
- export interface FlowNodeModel {
9
- id: string;
10
- type: string;
11
- position: {
12
- x: number;
13
- y: number;
14
- };
15
- label?: string;
16
- ports?: FlowPortModel[];
17
- payload?: Record<string, unknown>;
18
- extensions?: Record<string, unknown>;
19
- }
20
- export interface FlowEdgeModel {
21
- id: string;
22
- type?: string;
23
- source: {
24
- nodeId: string;
25
- portId?: string;
26
- };
27
- target: {
28
- nodeId: string;
29
- portId?: string;
30
- };
31
- labels?: FlowEdgeLabelModel[];
32
- payload?: Record<string, unknown>;
33
- extensions?: Record<string, unknown>;
34
- }
35
- export interface FlowPortModel {
36
- id: string;
37
- group: 'top' | 'right' | 'bottom' | 'left' | string;
38
- x6PortConfig?: Record<string, unknown>;
39
- }
40
- export interface FlowEdgeLabelModel {
41
- id: string;
42
- text?: string;
43
- position?: number;
44
- payload?: Record<string, unknown>;
45
- }
46
- export declare function createEmptyFlowModel(): FlowModel;
@@ -1,18 +0,0 @@
1
- import type { Ref } from 'vue';
2
- import type { FlowModel } from './flow-model';
3
- import type { CommandEnvelope } from './command';
4
- export interface CanvasHistory {
5
- execute(envelope: CommandEnvelope): FlowModel;
6
- undo(): FlowModel | null;
7
- redo(): FlowModel | null;
8
- readonly canUndo: Ref<boolean>;
9
- readonly canRedo: Ref<boolean>;
10
- readonly undoStack: readonly CommandEnvelope[];
11
- readonly redoStack: readonly CommandEnvelope[];
12
- clear(): void;
13
- createSnapshot(): FlowModel;
14
- replaceFlowModel(model: FlowModel): void;
15
- }
16
- export interface CanvasHistoryOptions {
17
- maxHistorySize?: number;
18
- }
@@ -1,3 +0,0 @@
1
- export interface OverlayManager {
2
- getNodeScreenRect(nodeId: string): DOMRect | null;
3
- }
@@ -1,64 +0,0 @@
1
- import type { Component } from 'vue';
2
- import type { Ref } from 'vue';
3
- import type { FlowNodeModel, FlowEdgeModel, FlowModel } from './flow-model';
4
- import type { CommandEnvelope, CommandPreview, CommandRejection, CommandExecutionResult, CanvasUiEvent, ScreenPosition } from './command';
5
- import type { CanvasSchema, CanvasMode } from './schema';
6
- import type { CanvasHistory } from './history';
7
- import type { CanvasApi } from './api';
8
- import type { OverlayManager } from './overlay';
9
- import type { CanvasToolbarItem } from './api';
10
- import type { Graph } from '@antv/x6';
11
- export interface EditorPluginContext {
12
- flowModel: Readonly<Ref<FlowModel>>;
13
- history: CanvasHistory;
14
- schema: CanvasSchema;
15
- mode: Ref<CanvasMode>;
16
- executeCommand(envelope: CommandEnvelope): CommandExecutionResult;
17
- }
18
- export interface RuntimePluginContext extends EditorPluginContext {
19
- api: CanvasApi;
20
- overlay: OverlayManager;
21
- graph: Graph;
22
- }
23
- export interface CanvasSelection {
24
- nodeIds: string[];
25
- edgeIds: string[];
26
- }
27
- export interface NodeDecoration {
28
- className?: string;
29
- badge?: {
30
- text: string;
31
- color: string;
32
- };
33
- borderColor?: string;
34
- }
35
- export interface EdgeDecoration {
36
- className?: string;
37
- strokeColor?: string;
38
- }
39
- export interface ContextMenuItem {
40
- id: string;
41
- label: string;
42
- icon?: Component | string;
43
- disabled?: boolean;
44
- action: () => void;
45
- children?: ContextMenuItem[];
46
- }
47
- export interface CanvasPlugin {
48
- name: string;
49
- priority?: number;
50
- install?(ctx: EditorPluginContext): void;
51
- attachRuntime?(ctx: RuntimePluginContext): void;
52
- detachRuntime?(): void;
53
- dispose?(): void;
54
- transformCommand?(envelope: Readonly<CommandEnvelope>, preview: CommandPreview, ctx: EditorPluginContext): CommandEnvelope | CommandRejection | null;
55
- afterCommand?(envelope: Readonly<CommandEnvelope>, prevModel: Readonly<FlowModel>, newModel: Readonly<FlowModel>, ctx: EditorPluginContext): void;
56
- onUiEvent?(event: CanvasUiEvent, ctx: RuntimePluginContext): void;
57
- onSelectionChange?(selection: CanvasSelection, ctx: RuntimePluginContext): void;
58
- onKeyboardShortcut?(event: KeyboardEvent, ctx: RuntimePluginContext): boolean;
59
- onBlankContextMenu?(position: ScreenPosition, ctx: RuntimePluginContext): ContextMenuItem[] | void;
60
- decorateNode?(node: FlowNodeModel, ctx: EditorPluginContext): NodeDecoration | void;
61
- decorateEdge?(edge: FlowEdgeModel, ctx: EditorPluginContext): EdgeDecoration | void;
62
- provideToolbarItems?(ctx: EditorPluginContext): CanvasToolbarItem[];
63
- extendApi?(api: CanvasApi, ctx: RuntimePluginContext): Record<string, Function>;
64
- }
@@ -1,80 +0,0 @@
1
- import type { Component } from 'vue';
2
- import type { FlowNodeModel, FlowEdgeModel, FlowPortModel } from './flow-model';
3
- import type { CanvasApi } from './api';
4
- import type { FlowModel } from './flow-model';
5
- import type { CanvasHistory } from './history';
6
- export type CanvasMode = 'edit' | 'readonly' | 'thumbnail';
7
- export interface CanvasSchema {
8
- nodeTypes: Record<string, CanvasNodeDefinition>;
9
- edgeTypes?: Record<string, CanvasEdgeDefinition>;
10
- defaultEdgeType?: string;
11
- }
12
- export interface NodeBehaviorConfig {
13
- showActions?: boolean;
14
- showPorts?: boolean;
15
- draggable?: boolean;
16
- selectable?: boolean;
17
- deletable?: boolean;
18
- connectable?: boolean;
19
- copyable?: boolean;
20
- disconnectable?: boolean;
21
- debuggable?: boolean;
22
- deleteDisabled?: boolean;
23
- copyDisabled?: boolean;
24
- copyInsertDisabled?: boolean;
25
- disconnectDisabled?: boolean;
26
- debugDisabled?: boolean;
27
- /** 逐节点控制右侧"+"快捷添加按钮是否显示,默认跟随全局配置 */
28
- quickAddEnabled?: boolean;
29
- /** 快捷操作工具栏的位置偏移(px),相对于默认位置(节点右下角) */
30
- actionsOffset?: {
31
- x?: number;
32
- y?: number;
33
- };
34
- }
35
- export interface CanvasNodeDefinition {
36
- component: Component;
37
- getSize: (node: FlowNodeModel) => {
38
- width: number;
39
- height: number;
40
- };
41
- getPorts?: (node: FlowNodeModel) => FlowPortModel[];
42
- getBehavior?: (node: FlowNodeModel, ctx: CanvasCallbackContext) => NodeBehaviorConfig;
43
- x6CellConfig?: Record<string, unknown>;
44
- }
45
- export interface EdgeRenderState {
46
- selected: boolean;
47
- highlighted: boolean;
48
- hovered: boolean;
49
- }
50
- export interface EdgeStyle {
51
- stroke?: string;
52
- strokeWidth?: number;
53
- strokeDasharray?: string;
54
- }
55
- export interface CanvasEdgeDefinition {
56
- router?: string | {
57
- name: string;
58
- args?: Record<string, unknown>;
59
- };
60
- connector?: string | {
61
- name: string;
62
- args?: Record<string, unknown>;
63
- };
64
- /** 根据边模型和渲染状态(selected/highlighted/hovered)返回边的视觉样式 */
65
- style?: (edge: FlowEdgeModel, state: EdgeRenderState) => EdgeStyle;
66
- /**
67
- * @experimental 边标签的自定义渲染组件。
68
- * 当前版本尚未完整实现(X6 边标签基于 SVG,集成 Vue 组件需要 HTML overlay 方案)。
69
- * 如需自定义标签样式,建议通过 x6EdgeConfig.defaultLabel 配置 X6 原生标签 markup。
70
- */
71
- labelRenderer?: Component;
72
- labelDraggable?: boolean;
73
- x6EdgeConfig?: Record<string, unknown>;
74
- }
75
- export interface CanvasCallbackContext {
76
- api: CanvasApi;
77
- flowModel: FlowModel;
78
- history: CanvasHistory;
79
- mode: CanvasMode;
80
- }
@@ -1,7 +0,0 @@
1
- /**
2
- * Immutable path-based set on a plain object.
3
- * - Empty path replaces the root value (must be object or undefined).
4
- * - Auto-creates intermediate objects for missing keys.
5
- * - `undefined` value deletes the leaf key.
6
- */
7
- export declare function setByPath(root: Record<string, unknown> | undefined, path: string[], value: unknown): Record<string, unknown> | undefined;
@@ -1 +0,0 @@
1
- export declare function generateId(): string;