ice-entity-designer 0.0.18 → 0.0.19

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.
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Copyright (c) 2022 大漠穷秋.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import type { ICE } from '../ice-render/index.mjs';
9
+ import type { FlowNodeKind } from './FlowNode.mjs';
10
+ import type { FlowEdgeSnapshot } from './FlowEdge.mjs';
11
+ import type { FlowNodeSnapshot } from './FlowNode.mjs';
12
+ /** 流程图快照:只含流程图自身的语义数据,跨版本可读 */
13
+ export declare type FlowSnapshot = {
14
+ version: number;
15
+ kind: 'flowchart';
16
+ nodes: FlowNodeSnapshot[];
17
+ edges: FlowEdgeSnapshot[];
18
+ };
19
+ /** load() 的载入报告 */
20
+ export declare type FlowLoadReport = {
21
+ /** 是否真的发生了一次载入(空值 / 非流程图快照为 false) */
22
+ loaded: boolean;
23
+ nodes: number;
24
+ edges: number;
25
+ /** 因 typeId 不匹配被跳过的节点/连线 */
26
+ skipped: string[];
27
+ };
28
+ export declare type FlowSnapshotValidationResult = {
29
+ valid: boolean;
30
+ errors: string[];
31
+ };
32
+ /**
33
+ * 校验流程图快照结构。
34
+ *
35
+ * 契约与 IED 的项目快照一致:**serialize() 的产物必须永远能通过本校验**,
36
+ * 因此只校验加载器需要的结构,可选值(颜色 / 尺寸 / 端口)缺省即合法。
37
+ */
38
+ export declare function validateFlowSnapshot(data: any): FlowSnapshotValidationResult;
39
+ /**
40
+ * @class FlowDesigner 流程图应用层
41
+ *
42
+ * 与 EntityDesigner 同构:在通用图元之上把「建节点 / 连线 / 选中 / 增删改 /
43
+ * 撤销重做 / 快照存取」串成闭环。不改变引擎语义,也不依赖具体页面框架。
44
+ */
45
+ export default class FlowDesigner {
46
+ ice: ICE;
47
+ selectedId: string | null;
48
+ private __undoStack;
49
+ private __redoStack;
50
+ private __historyEnabled;
51
+ private __maxHistory;
52
+ private __listeners;
53
+ private __mousedownHandler;
54
+ constructor(ice: ICE);
55
+ get nodes(): any[];
56
+ get edges(): any[];
57
+ get selected(): any;
58
+ /**
59
+ * 订阅流程变更(增删改 / 连线 / 载入 / undo / redo 之后触发)。
60
+ * 回调参数是当前流程的快照(与 serialize() 一致)。
61
+ */
62
+ subscribe(listener: (snapshot: string, designer: FlowDesigner) => void): () => void;
63
+ private __emitChange;
64
+ select(id: string | null): this;
65
+ /** 没有给坐标时,按已有节点包围盒的下方网格错开摆放,避免新建节点互相压住 */
66
+ private __defaultPlacement;
67
+ createNode(kind: FlowNodeKind, props?: any): any;
68
+ /** 由节点的插槽位置算出连线端点(引擎按插槽吸附,端点需要给出初始坐标) */
69
+ private __slotPoint;
70
+ createEdge(props?: any): any;
71
+ updateNode(id: string, patch: Record<string, any>): any;
72
+ updateEdge(id: string, patch: Record<string, any>): any;
73
+ /** 删除节点(连带删除挂在它两端的连线)或删除一条连线 */
74
+ remove(id: string): void;
75
+ clear(): void;
76
+ serialize(): string;
77
+ toSnapshot(): FlowSnapshot;
78
+ /**
79
+ * 载入流程图快照(整体替换当前流程)。
80
+ *
81
+ * @throws 结构非法时抛错;此时当前流程与历史栈都不会被改动。
82
+ */
83
+ load(json: string): FlowLoadReport;
84
+ /** 用快照数据重建整张流程图(不发变更广播,由调用方决定广播时机) */
85
+ private __clearAndBuild;
86
+ /** 把整个流程缩放到画布可视区内 */
87
+ fitViewport(padding?: number): void;
88
+ canUndo(): boolean;
89
+ canRedo(): boolean;
90
+ captureHistory(): void;
91
+ /** 清空撤销/重做栈(用于「载入示例」这类不该占用历史的初始化操作) */
92
+ resetHistory(): void;
93
+ private __captureHistory;
94
+ private __applySnapshot;
95
+ /**
96
+ * 撤销:先记账(把当前状态压入 redo、从 undo 弹出目标),再回放目标快照,
97
+ * 最后统一广播 —— 顺序很关键:若先广播再记账,订阅方(属性面板 / 工具条按钮)
98
+ * 读到的会是旧栈状态,出现「canRedo() 为 true 但按钮仍 disabled」这类不一致。
99
+ */
100
+ undo(): void;
101
+ redo(): void;
102
+ private __handleMouseDown;
103
+ dispose(): void;
104
+ }
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Copyright (c) 2022 大漠穷秋.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import type { ICE } from '../ice-render/index';
9
+ import type { FlowNodeKind } from './FlowNode';
10
+ import type { FlowEdgeSnapshot } from './FlowEdge';
11
+ import type { FlowNodeSnapshot } from './FlowNode';
12
+ /** 流程图快照:只含流程图自身的语义数据,跨版本可读 */
13
+ export declare type FlowSnapshot = {
14
+ version: number;
15
+ kind: 'flowchart';
16
+ nodes: FlowNodeSnapshot[];
17
+ edges: FlowEdgeSnapshot[];
18
+ };
19
+ /** load() 的载入报告 */
20
+ export declare type FlowLoadReport = {
21
+ /** 是否真的发生了一次载入(空值 / 非流程图快照为 false) */
22
+ loaded: boolean;
23
+ nodes: number;
24
+ edges: number;
25
+ /** 因 typeId 不匹配被跳过的节点/连线 */
26
+ skipped: string[];
27
+ };
28
+ export declare type FlowSnapshotValidationResult = {
29
+ valid: boolean;
30
+ errors: string[];
31
+ };
32
+ /**
33
+ * 校验流程图快照结构。
34
+ *
35
+ * 契约与 IED 的项目快照一致:**serialize() 的产物必须永远能通过本校验**,
36
+ * 因此只校验加载器需要的结构,可选值(颜色 / 尺寸 / 端口)缺省即合法。
37
+ */
38
+ export declare function validateFlowSnapshot(data: any): FlowSnapshotValidationResult;
39
+ /**
40
+ * @class FlowDesigner 流程图应用层
41
+ *
42
+ * 与 EntityDesigner 同构:在通用图元之上把「建节点 / 连线 / 选中 / 增删改 /
43
+ * 撤销重做 / 快照存取」串成闭环。不改变引擎语义,也不依赖具体页面框架。
44
+ */
45
+ export default class FlowDesigner {
46
+ ice: ICE;
47
+ selectedId: string | null;
48
+ private __undoStack;
49
+ private __redoStack;
50
+ private __historyEnabled;
51
+ private __maxHistory;
52
+ private __listeners;
53
+ private __mousedownHandler;
54
+ constructor(ice: ICE);
55
+ get nodes(): any[];
56
+ get edges(): any[];
57
+ get selected(): any;
58
+ /**
59
+ * 订阅流程变更(增删改 / 连线 / 载入 / undo / redo 之后触发)。
60
+ * 回调参数是当前流程的快照(与 serialize() 一致)。
61
+ */
62
+ subscribe(listener: (snapshot: string, designer: FlowDesigner) => void): () => void;
63
+ private __emitChange;
64
+ select(id: string | null): this;
65
+ /** 没有给坐标时,按已有节点包围盒的下方网格错开摆放,避免新建节点互相压住 */
66
+ private __defaultPlacement;
67
+ createNode(kind: FlowNodeKind, props?: any): any;
68
+ /** 由节点的插槽位置算出连线端点(引擎按插槽吸附,端点需要给出初始坐标) */
69
+ private __slotPoint;
70
+ createEdge(props?: any): any;
71
+ updateNode(id: string, patch: Record<string, any>): any;
72
+ updateEdge(id: string, patch: Record<string, any>): any;
73
+ /** 删除节点(连带删除挂在它两端的连线)或删除一条连线 */
74
+ remove(id: string): void;
75
+ clear(): void;
76
+ serialize(): string;
77
+ toSnapshot(): FlowSnapshot;
78
+ /**
79
+ * 载入流程图快照(整体替换当前流程)。
80
+ *
81
+ * @throws 结构非法时抛错;此时当前流程与历史栈都不会被改动。
82
+ */
83
+ load(json: string): FlowLoadReport;
84
+ /** 用快照数据重建整张流程图(不发变更广播,由调用方决定广播时机) */
85
+ private __clearAndBuild;
86
+ /** 把整个流程缩放到画布可视区内 */
87
+ fitViewport(padding?: number): void;
88
+ canUndo(): boolean;
89
+ canRedo(): boolean;
90
+ captureHistory(): void;
91
+ /** 清空撤销/重做栈(用于「载入示例」这类不该占用历史的初始化操作) */
92
+ resetHistory(): void;
93
+ private __captureHistory;
94
+ private __applySnapshot;
95
+ /**
96
+ * 撤销:先记账(把当前状态压入 redo、从 undo 弹出目标),再回放目标快照,
97
+ * 最后统一广播 —— 顺序很关键:若先广播再记账,订阅方(属性面板 / 工具条按钮)
98
+ * 读到的会是旧栈状态,出现「canRedo() 为 true 但按钮仍 disabled」这类不一致。
99
+ */
100
+ undo(): void;
101
+ redo(): void;
102
+ private __handleMouseDown;
103
+ dispose(): void;
104
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Copyright (c) 2022 大漠穷秋.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import { ICEVisioLink } from '../ice-render/index.mjs';
9
+ /** 连线端点所在的插槽位置(上 / 右 / 下 / 左 / 中心) */
10
+ export declare type FlowPort = 'T' | 'R' | 'B' | 'L' | 'C';
11
+ /** 连线在快照里的纯数据 */
12
+ export declare type FlowEdgeSnapshot = {
13
+ id: string;
14
+ typeId: string;
15
+ sourceId: string | null;
16
+ targetId: string | null;
17
+ sourcePort: FlowPort | null;
18
+ targetPort: FlowPort | null;
19
+ label: string;
20
+ linkShape: string;
21
+ startPoint: number[];
22
+ endPoint: number[];
23
+ };
24
+ /**
25
+ * @class FlowEdge 流程图连线
26
+ *
27
+ * 复用引擎的 Visio 连线(正交折线 / 贝塞尔),带标签与箭头,并通过 `links` 挂在
28
+ * 两端节点的插槽上 —— 节点被拖动时连线自动跟随重新布线。
29
+ */
30
+ export default class FlowEdge extends ICEVisioLink {
31
+ static readonly typeId = "FlowEdge";
32
+ constructor(props?: any);
33
+ /** 流程快照用的纯数据 */
34
+ toFlowObject(): FlowEdgeSnapshot;
35
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Copyright (c) 2022 大漠穷秋.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import { ICEVisioLink } from '../ice-render/index';
9
+ /** 连线端点所在的插槽位置(上 / 右 / 下 / 左 / 中心) */
10
+ export declare type FlowPort = 'T' | 'R' | 'B' | 'L' | 'C';
11
+ /** 连线在快照里的纯数据 */
12
+ export declare type FlowEdgeSnapshot = {
13
+ id: string;
14
+ typeId: string;
15
+ sourceId: string | null;
16
+ targetId: string | null;
17
+ sourcePort: FlowPort | null;
18
+ targetPort: FlowPort | null;
19
+ label: string;
20
+ linkShape: string;
21
+ startPoint: number[];
22
+ endPoint: number[];
23
+ };
24
+ /**
25
+ * @class FlowEdge 流程图连线
26
+ *
27
+ * 复用引擎的 Visio 连线(正交折线 / 贝塞尔),带标签与箭头,并通过 `links` 挂在
28
+ * 两端节点的插槽上 —— 节点被拖动时连线自动跟随重新布线。
29
+ */
30
+ export default class FlowEdge extends ICEVisioLink {
31
+ static readonly typeId = "FlowEdge";
32
+ constructor(props?: any);
33
+ /** 流程快照用的纯数据 */
34
+ toFlowObject(): FlowEdgeSnapshot;
35
+ }
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Copyright (c) 2022 大漠穷秋.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import { ICEGroup } from '../ice-render/index.mjs';
9
+ /** 流程图节点类型:起止 / 处理 / 判定 / 输入输出 */
10
+ export declare type FlowNodeKind = 'terminator' | 'process' | 'decision' | 'io';
11
+ export declare type FlowNodePreset = {
12
+ label: string;
13
+ width: number;
14
+ height: number;
15
+ fill: string;
16
+ stroke: string;
17
+ radius?: number;
18
+ shape: 'rect' | 'diamond' | 'parallelogram';
19
+ };
20
+ /** 各类型节点的默认尺寸与配色(同时作为属性面板的预设) */
21
+ export declare const FLOW_NODE_KINDS: Record<FlowNodeKind, FlowNodePreset>;
22
+ /** 流程图节点在快照里的纯数据(不含引擎内部状态) */
23
+ export declare type FlowNodeSnapshot = {
24
+ id: string;
25
+ typeId: string;
26
+ kind: FlowNodeKind;
27
+ title: string;
28
+ left: number;
29
+ top: number;
30
+ width: number;
31
+ height: number;
32
+ fillColor: string;
33
+ strokeColor: string;
34
+ };
35
+ /**
36
+ * @class FlowNode 流程图节点
37
+ *
38
+ * 一个不可见的容器(ICEGroup)里放「形状 + 居中标题」:容器只负责定位、拖拽与命中,
39
+ * 形状由子组件绘制,因此菱形 / 平行四边形这类非矩形轮廓也能正确渲染,
40
+ * 而节点的 width/height 始终就是它的包围盒(连线插槽、布局都按它算)。
41
+ */
42
+ export default class FlowNode extends ICEGroup {
43
+ /** 稳定的类型标识(下游打包会 mangle 类名,判型不要用 constructor.name) */
44
+ static readonly typeId = "FlowNode";
45
+ protected shapeComponent: any;
46
+ protected labelComponent: any;
47
+ constructor(props?: any);
48
+ /** 按当前 kind / 尺寸 / 配色重建形状与标题(切换类型或改样式时调用) */
49
+ private __buildShape;
50
+ /** 改节点属性(标题 / 类型 / 配色 / 尺寸),必要时重建形状 */
51
+ applyPatch(patch?: Record<string, any>): this;
52
+ /** 流程快照用的纯数据 */
53
+ toFlowObject(): FlowNodeSnapshot;
54
+ }
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Copyright (c) 2022 大漠穷秋.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import { ICEGroup } from '../ice-render/index';
9
+ /** 流程图节点类型:起止 / 处理 / 判定 / 输入输出 */
10
+ export declare type FlowNodeKind = 'terminator' | 'process' | 'decision' | 'io';
11
+ export declare type FlowNodePreset = {
12
+ label: string;
13
+ width: number;
14
+ height: number;
15
+ fill: string;
16
+ stroke: string;
17
+ radius?: number;
18
+ shape: 'rect' | 'diamond' | 'parallelogram';
19
+ };
20
+ /** 各类型节点的默认尺寸与配色(同时作为属性面板的预设) */
21
+ export declare const FLOW_NODE_KINDS: Record<FlowNodeKind, FlowNodePreset>;
22
+ /** 流程图节点在快照里的纯数据(不含引擎内部状态) */
23
+ export declare type FlowNodeSnapshot = {
24
+ id: string;
25
+ typeId: string;
26
+ kind: FlowNodeKind;
27
+ title: string;
28
+ left: number;
29
+ top: number;
30
+ width: number;
31
+ height: number;
32
+ fillColor: string;
33
+ strokeColor: string;
34
+ };
35
+ /**
36
+ * @class FlowNode 流程图节点
37
+ *
38
+ * 一个不可见的容器(ICEGroup)里放「形状 + 居中标题」:容器只负责定位、拖拽与命中,
39
+ * 形状由子组件绘制,因此菱形 / 平行四边形这类非矩形轮廓也能正确渲染,
40
+ * 而节点的 width/height 始终就是它的包围盒(连线插槽、布局都按它算)。
41
+ */
42
+ export default class FlowNode extends ICEGroup {
43
+ /** 稳定的类型标识(下游打包会 mangle 类名,判型不要用 constructor.name) */
44
+ static readonly typeId = "FlowNode";
45
+ protected shapeComponent: any;
46
+ protected labelComponent: any;
47
+ constructor(props?: any);
48
+ /** 按当前 kind / 尺寸 / 配色重建形状与标题(切换类型或改样式时调用) */
49
+ private __buildShape;
50
+ /** 改节点属性(标题 / 类型 / 配色 / 尺寸),必要时重建形状 */
51
+ applyPatch(patch?: Record<string, any>): this;
52
+ /** 流程快照用的纯数据 */
53
+ toFlowObject(): FlowNodeSnapshot;
54
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Copyright (c) 2022 大漠穷秋.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import { ICEPath } from '../ice-render/index.mjs';
9
+ /** 判定节点:菱形 */
10
+ export declare class FlowDiamond extends ICEPath {
11
+ static readonly typeId = "FlowDiamond";
12
+ protected createPathObject(): any;
13
+ }
14
+ /** 输入 / 输出节点:平行四边形 */
15
+ export declare class FlowParallelogram extends ICEPath {
16
+ static readonly typeId = "FlowParallelogram";
17
+ protected createPathObject(): any;
18
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Copyright (c) 2022 大漠穷秋.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import { ICEPath } from '../ice-render/index';
9
+ /** 判定节点:菱形 */
10
+ export declare class FlowDiamond extends ICEPath {
11
+ static readonly typeId = "FlowDiamond";
12
+ protected createPathObject(): any;
13
+ }
14
+ /** 输入 / 输出节点:平行四边形 */
15
+ export declare class FlowParallelogram extends ICEPath {
16
+ static readonly typeId = "FlowParallelogram";
17
+ protected createPathObject(): any;
18
+ }
@@ -13,6 +13,13 @@ export type { ProjectLoadReport, ProjectLoadSkippedNode } from './designer/Entit
13
13
  export { toSchemaObject, toSchemaString } from './utils/serialization_util.mjs';
14
14
  export { validateSchema } from './utils/schema_validator.mjs';
15
15
  export { PROJECT_SCHEMA_VERSION, validateProjectSnapshot } from './utils/project_schema.mjs';
16
+ export { default as FlowNode, FLOW_NODE_KINDS } from './flow/FlowNode.mjs';
17
+ export type { FlowNodeKind, FlowNodePreset, FlowNodeSnapshot } from './flow/FlowNode.mjs';
18
+ export { default as FlowEdge } from './flow/FlowEdge.mjs';
19
+ export type { FlowPort, FlowEdgeSnapshot } from './flow/FlowEdge.mjs';
20
+ export { default as FlowDesigner, validateFlowSnapshot } from './flow/FlowDesigner.mjs';
21
+ export type { FlowSnapshot, FlowLoadReport, FlowSnapshotValidationResult } from './flow/FlowDesigner.mjs';
22
+ export { FlowDiamond, FlowParallelogram } from './flow/flow_shapes.mjs';
16
23
  /**
17
24
  * 引擎内核(ice-render)在构建时已被打包进本包,这里一并导出。
18
25
  *
@@ -13,6 +13,13 @@ export type { ProjectLoadReport, ProjectLoadSkippedNode } from './designer/Entit
13
13
  export { toSchemaObject, toSchemaString } from './utils/serialization_util';
14
14
  export { validateSchema } from './utils/schema_validator';
15
15
  export { PROJECT_SCHEMA_VERSION, validateProjectSnapshot } from './utils/project_schema';
16
+ export { default as FlowNode, FLOW_NODE_KINDS } from './flow/FlowNode';
17
+ export type { FlowNodeKind, FlowNodePreset, FlowNodeSnapshot } from './flow/FlowNode';
18
+ export { default as FlowEdge } from './flow/FlowEdge';
19
+ export type { FlowPort, FlowEdgeSnapshot } from './flow/FlowEdge';
20
+ export { default as FlowDesigner, validateFlowSnapshot } from './flow/FlowDesigner';
21
+ export type { FlowSnapshot, FlowLoadReport, FlowSnapshotValidationResult } from './flow/FlowDesigner';
22
+ export { FlowDiamond, FlowParallelogram } from './flow/flow_shapes';
16
23
  /**
17
24
  * 引擎内核(ice-render)在构建时已被打包进本包,这里一并导出。
18
25
  *
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "author": "大漠穷秋",
3
3
  "name": "ice-entity-designer",
4
- "version": "0.0.18",
4
+ "version": "0.0.19",
5
5
  "description": "An entity designer based on ice-render.",
6
6
  "repository": {
7
7
  "type": "git",