ice-entity-designer 0.0.19 → 0.0.21

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 (39) hide show
  1. package/README.md +51 -2
  2. package/dist/index.cjs +2 -2
  3. package/dist/index.mjs +2 -2
  4. package/dist/index.umd.js +2 -2
  5. package/dist/react.cjs +3 -3
  6. package/dist/react.mjs +3 -3
  7. package/dist/types/designer/EntityDesigner.d.mts +1 -1
  8. package/dist/types/designer/EntityDesigner.d.ts +1 -1
  9. package/dist/types/er-component/Entity.d.mts +5 -0
  10. package/dist/types/er-component/Entity.d.ts +5 -0
  11. package/dist/types/er-component/Relation.d.mts +2 -0
  12. package/dist/types/er-component/Relation.d.ts +2 -0
  13. package/dist/types/flow/FlowDesigner.d.mts +44 -14
  14. package/dist/types/flow/FlowDesigner.d.ts +44 -14
  15. package/dist/types/flow/FlowEdge.d.mts +2 -15
  16. package/dist/types/flow/FlowEdge.d.ts +2 -15
  17. package/dist/types/flow/FlowNode.d.mts +5 -15
  18. package/dist/types/flow/FlowNode.d.ts +5 -15
  19. package/dist/types/ice-render/graphic/ICEComponent.d.mts +12 -0
  20. package/dist/types/ice-render/graphic/ICEComponent.d.ts +12 -0
  21. package/dist/types/ice-render/index.d.mts +2 -0
  22. package/dist/types/ice-render/index.d.ts +2 -0
  23. package/dist/types/index.d.mts +2 -2
  24. package/dist/types/index.d.ts +2 -2
  25. package/dist/types/react/FlowDesignerCanvas.d.mts +14 -0
  26. package/dist/types/react/FlowDesignerCanvas.d.ts +14 -0
  27. package/dist/types/react/context.d.mts +18 -1
  28. package/dist/types/react/context.d.ts +18 -1
  29. package/dist/types/react/index.d.mts +8 -1
  30. package/dist/types/react/index.d.ts +8 -1
  31. package/dist/types/react/reportLoadError.d.mts +8 -0
  32. package/dist/types/react/reportLoadError.d.ts +8 -0
  33. package/dist/types/react/session.d.mts +22 -1
  34. package/dist/types/react/session.d.ts +22 -1
  35. package/dist/types/react/types.d.mts +59 -1
  36. package/dist/types/react/types.d.ts +59 -1
  37. package/dist/types/utils/project_codec.d.mts +66 -0
  38. package/dist/types/utils/project_codec.d.ts +66 -0
  39. package/package.json +1 -1
@@ -66,7 +66,7 @@ export default class EntityDesigner {
66
66
  * @returns 载入报告(创建数量、被跳过的未知类型)
67
67
  */
68
68
  loadProject(json: string): ProjectLoadReport;
69
- private __componentBaseSnapshot;
69
+ /** 节点快照由共享 codec 的字段定义驱动(写与校验同一份定义,见 utils/project_codec.ts) */
70
70
  private __entitySnapshot;
71
71
  private __slotPoint;
72
72
  private __relationSnapshot;
@@ -66,7 +66,7 @@ export default class EntityDesigner {
66
66
  * @returns 载入报告(创建数量、被跳过的未知类型)
67
67
  */
68
68
  loadProject(json: string): ProjectLoadReport;
69
- private __componentBaseSnapshot;
69
+ /** 节点快照由共享 codec 的字段定义驱动(写与校验同一份定义,见 utils/project_codec.ts) */
70
70
  private __entitySnapshot;
71
71
  private __slotPoint;
72
72
  private __relationSnapshot;
@@ -37,6 +37,11 @@ export default class Entity extends ICEGroup {
37
37
  * 属性名默认不会被压缩,子类也会继承这个值。
38
38
  */
39
39
  static readonly typeId = "Entity";
40
+ /**
41
+ * 表头背景 / 标题 / 分隔线 / 字段文本都是由 entityName、fields、各 style 派生的内部子组件,
42
+ * 构造函数会按 state 重建 → 不参与引擎序列化(避免往返重复挂载)。
43
+ */
44
+ hasDerivedChildren(): boolean;
40
45
  protected entityNameComponent: ICEText;
41
46
  protected headerBackgroundComponent: ICERect;
42
47
  protected deviderLine: ICEPolyLine;
@@ -37,6 +37,11 @@ export default class Entity extends ICEGroup {
37
37
  * 属性名默认不会被压缩,子类也会继承这个值。
38
38
  */
39
39
  static readonly typeId = "Entity";
40
+ /**
41
+ * 表头背景 / 标题 / 分隔线 / 字段文本都是由 entityName、fields、各 style 派生的内部子组件,
42
+ * 构造函数会按 state 重建 → 不参与引擎序列化(避免往返重复挂载)。
43
+ */
44
+ hasDerivedChildren(): boolean;
40
45
  protected entityNameComponent: ICEText;
41
46
  protected headerBackgroundComponent: ICERect;
42
47
  protected deviderLine: ICEPolyLine;
@@ -21,6 +21,8 @@ export default class Relation extends ICEVisioLink {
21
21
  * 下游打包会 mangle 类名(实测 webpack 生产构建下 Relation → `Br`),基于类名的判断会静默失效。
22
22
  */
23
23
  static readonly typeId = "Relation";
24
+ /** 连线没有子组件;声明派生以保证引擎序列化只持久化自身 state */
25
+ hasDerivedChildren(): boolean;
24
26
  constructor(props?: any);
25
27
  /**
26
28
  * 根据关系类型推断箭头方向,默认指向 FK 所在的一端。
@@ -21,6 +21,8 @@ export default class Relation extends ICEVisioLink {
21
21
  * 下游打包会 mangle 类名(实测 webpack 生产构建下 Relation → `Br`),基于类名的判断会静默失效。
22
22
  */
23
23
  static readonly typeId = "Relation";
24
+ /** 连线没有子组件;声明派生以保证引擎序列化只持久化自身 state */
25
+ hasDerivedChildren(): boolean;
24
26
  constructor(props?: any);
25
27
  /**
26
28
  * 根据关系类型推断箭头方向,默认指向 FK 所在的一端。
@@ -1,20 +1,21 @@
1
+ import type { ICE } from '../ice-render/index.mjs';
2
+ import type { FlowNodeKind } from './FlowNode.mjs';
1
3
  /**
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.
4
+ * 流程图文档。
6
5
  *
6
+ * **直接复用引擎的序列化机制**:`scene` 是引擎 `Serializer` 的原生产物
7
+ * (`{ version, childNodes }`,只去掉 createTime/lastModifyTime 这类每次都会变的时间戳)。
8
+ * 于是「组件 state 上的一切」(含应用层自定义 `data`)自动往返,新字段不需要在任何清单里登记,
9
+ * 容错(未注册类型跳过 + unknownTypes)、版本迁移也全部沿用引擎那一套。
7
10
  */
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
11
  export declare type FlowSnapshot = {
14
- version: number;
12
+ version: 2;
15
13
  kind: 'flowchart';
16
- nodes: FlowNodeSnapshot[];
17
- edges: FlowEdgeSnapshot[];
14
+ scene: {
15
+ /** 引擎的序列化格式版本(SERIALIZATION_VERSION) */
16
+ version: number;
17
+ childNodes: any[];
18
+ };
18
19
  };
19
20
  /** load() 的载入报告 */
20
21
  export declare type FlowLoadReport = {
@@ -51,6 +52,19 @@ export default class FlowDesigner {
51
52
  private __maxHistory;
52
53
  private __listeners;
53
54
  private __mousedownHandler;
55
+ /** 画布拖拽节点时会话:BEFORE_MOVE 记一次历史,mouseup 结束会话 */
56
+ private __moveSession;
57
+ private __moveEmitQueued;
58
+ /**
59
+ * 节点在画布上被拖动(引擎 `setPosition()` → BEFORE_MOVE/AFTER_MOVE)。
60
+ *
61
+ * 这两个事件是**每一步移动都触发**的,所以:BEFORE_MOVE 只在会话内第一次记历史
62
+ * (此时 `setState` 还没执行,记下的是拖拽前的位置),AFTER_MOVE 按帧合并后广播,
63
+ * 避免拖动过程中每帧都序列化整个流程。
64
+ */
65
+ private __beforeMoveHandler;
66
+ private __afterMoveHandler;
67
+ private __mouseupHandler;
54
68
  constructor(ice: ICE);
55
69
  get nodes(): any[];
56
70
  get edges(): any[];
@@ -61,6 +75,12 @@ export default class FlowDesigner {
61
75
  */
62
76
  subscribe(listener: (snapshot: string, designer: FlowDesigner) => void): () => void;
63
77
  private __emitChange;
78
+ /** 订阅节点的拖拽事件:拖动是画布侧的行为,designer 需要感知才能广播与记历史 */
79
+ private __attachNodeListeners;
80
+ private __detachNodeListeners;
81
+ private __onBeforeMove;
82
+ private __onAfterMove;
83
+ private __endMoveSession;
64
84
  select(id: string | null): this;
65
85
  /** 没有给坐标时,按已有节点包围盒的下方网格错开摆放,避免新建节点互相压住 */
66
86
  private __defaultPlacement;
@@ -75,13 +95,23 @@ export default class FlowDesigner {
75
95
  clear(): void;
76
96
  serialize(): string;
77
97
  toSnapshot(): FlowSnapshot;
98
+ /** 引擎 Serializer / Deserializer:ice 未 init 时 ice.serializer 不存在,这里按需构造(两者无状态) */
99
+ private __serializer;
100
+ private __deserializer;
78
101
  /**
79
- * 载入流程图快照(整体替换当前流程)。
102
+ * 载入流程图文档(整体替换当前流程)。
103
+ *
104
+ * 支持两种格式:
105
+ * - **v2(当前)**:`scene` 为引擎序列化产物 → 直接交给引擎 `Deserializer` 重建,
106
+ * 未注册类型会被跳过并记入报告的 `skipped`(沿用引擎的容错语义);
107
+ * - **v1(历史)**:`nodes` / `edges` 数组 → 走兼容读取路径(迁移,不再作为写出格式)。
80
108
  *
81
109
  * @throws 结构非法时抛错;此时当前流程与历史栈都不会被改动。
82
110
  */
83
111
  load(json: string): FlowLoadReport;
84
- /** 用快照数据重建整张流程图(不发变更广播,由调用方决定广播时机) */
112
+ /** v2:把引擎序列化产物交给引擎 Deserializer 重建(容错、类型分派全部复用引擎实现) */
113
+ private __applyEngineScene;
114
+ /** v1(历史格式)兼容读取:由 nodes / edges 数组重建(迁移路径,不参与写出) */
85
115
  private __clearAndBuild;
86
116
  /** 把整个流程缩放到画布可视区内 */
87
117
  fitViewport(padding?: number): void;
@@ -1,20 +1,21 @@
1
+ import type { ICE } from '../ice-render/index';
2
+ import type { FlowNodeKind } from './FlowNode';
1
3
  /**
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.
4
+ * 流程图文档。
6
5
  *
6
+ * **直接复用引擎的序列化机制**:`scene` 是引擎 `Serializer` 的原生产物
7
+ * (`{ version, childNodes }`,只去掉 createTime/lastModifyTime 这类每次都会变的时间戳)。
8
+ * 于是「组件 state 上的一切」(含应用层自定义 `data`)自动往返,新字段不需要在任何清单里登记,
9
+ * 容错(未注册类型跳过 + unknownTypes)、版本迁移也全部沿用引擎那一套。
7
10
  */
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
11
  export declare type FlowSnapshot = {
14
- version: number;
12
+ version: 2;
15
13
  kind: 'flowchart';
16
- nodes: FlowNodeSnapshot[];
17
- edges: FlowEdgeSnapshot[];
14
+ scene: {
15
+ /** 引擎的序列化格式版本(SERIALIZATION_VERSION) */
16
+ version: number;
17
+ childNodes: any[];
18
+ };
18
19
  };
19
20
  /** load() 的载入报告 */
20
21
  export declare type FlowLoadReport = {
@@ -51,6 +52,19 @@ export default class FlowDesigner {
51
52
  private __maxHistory;
52
53
  private __listeners;
53
54
  private __mousedownHandler;
55
+ /** 画布拖拽节点时会话:BEFORE_MOVE 记一次历史,mouseup 结束会话 */
56
+ private __moveSession;
57
+ private __moveEmitQueued;
58
+ /**
59
+ * 节点在画布上被拖动(引擎 `setPosition()` → BEFORE_MOVE/AFTER_MOVE)。
60
+ *
61
+ * 这两个事件是**每一步移动都触发**的,所以:BEFORE_MOVE 只在会话内第一次记历史
62
+ * (此时 `setState` 还没执行,记下的是拖拽前的位置),AFTER_MOVE 按帧合并后广播,
63
+ * 避免拖动过程中每帧都序列化整个流程。
64
+ */
65
+ private __beforeMoveHandler;
66
+ private __afterMoveHandler;
67
+ private __mouseupHandler;
54
68
  constructor(ice: ICE);
55
69
  get nodes(): any[];
56
70
  get edges(): any[];
@@ -61,6 +75,12 @@ export default class FlowDesigner {
61
75
  */
62
76
  subscribe(listener: (snapshot: string, designer: FlowDesigner) => void): () => void;
63
77
  private __emitChange;
78
+ /** 订阅节点的拖拽事件:拖动是画布侧的行为,designer 需要感知才能广播与记历史 */
79
+ private __attachNodeListeners;
80
+ private __detachNodeListeners;
81
+ private __onBeforeMove;
82
+ private __onAfterMove;
83
+ private __endMoveSession;
64
84
  select(id: string | null): this;
65
85
  /** 没有给坐标时,按已有节点包围盒的下方网格错开摆放,避免新建节点互相压住 */
66
86
  private __defaultPlacement;
@@ -75,13 +95,23 @@ export default class FlowDesigner {
75
95
  clear(): void;
76
96
  serialize(): string;
77
97
  toSnapshot(): FlowSnapshot;
98
+ /** 引擎 Serializer / Deserializer:ice 未 init 时 ice.serializer 不存在,这里按需构造(两者无状态) */
99
+ private __serializer;
100
+ private __deserializer;
78
101
  /**
79
- * 载入流程图快照(整体替换当前流程)。
102
+ * 载入流程图文档(整体替换当前流程)。
103
+ *
104
+ * 支持两种格式:
105
+ * - **v2(当前)**:`scene` 为引擎序列化产物 → 直接交给引擎 `Deserializer` 重建,
106
+ * 未注册类型会被跳过并记入报告的 `skipped`(沿用引擎的容错语义);
107
+ * - **v1(历史)**:`nodes` / `edges` 数组 → 走兼容读取路径(迁移,不再作为写出格式)。
80
108
  *
81
109
  * @throws 结构非法时抛错;此时当前流程与历史栈都不会被改动。
82
110
  */
83
111
  load(json: string): FlowLoadReport;
84
- /** 用快照数据重建整张流程图(不发变更广播,由调用方决定广播时机) */
112
+ /** v2:把引擎序列化产物交给引擎 Deserializer 重建(容错、类型分派全部复用引擎实现) */
113
+ private __applyEngineScene;
114
+ /** v1(历史格式)兼容读取:由 nodes / edges 数组重建(迁移路径,不参与写出) */
85
115
  private __clearAndBuild;
86
116
  /** 把整个流程缩放到画布可视区内 */
87
117
  fitViewport(padding?: number): void;
@@ -8,19 +8,6 @@
8
8
  import { ICEVisioLink } from '../ice-render/index.mjs';
9
9
  /** 连线端点所在的插槽位置(上 / 右 / 下 / 左 / 中心) */
10
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
11
  /**
25
12
  * @class FlowEdge 流程图连线
26
13
  *
@@ -29,7 +16,7 @@ export declare type FlowEdgeSnapshot = {
29
16
  */
30
17
  export default class FlowEdge extends ICEVisioLink {
31
18
  static readonly typeId = "FlowEdge";
19
+ /** 连线没有子组件;声明派生可保证将来即使加了内部装饰也不会被重复序列化 */
20
+ hasDerivedChildren(): boolean;
32
21
  constructor(props?: any);
33
- /** 流程快照用的纯数据 */
34
- toFlowObject(): FlowEdgeSnapshot;
35
22
  }
@@ -8,19 +8,6 @@
8
8
  import { ICEVisioLink } from '../ice-render/index';
9
9
  /** 连线端点所在的插槽位置(上 / 右 / 下 / 左 / 中心) */
10
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
11
  /**
25
12
  * @class FlowEdge 流程图连线
26
13
  *
@@ -29,7 +16,7 @@ export declare type FlowEdgeSnapshot = {
29
16
  */
30
17
  export default class FlowEdge extends ICEVisioLink {
31
18
  static readonly typeId = "FlowEdge";
19
+ /** 连线没有子组件;声明派生可保证将来即使加了内部装饰也不会被重复序列化 */
20
+ hasDerivedChildren(): boolean;
32
21
  constructor(props?: any);
33
- /** 流程快照用的纯数据 */
34
- toFlowObject(): FlowEdgeSnapshot;
35
22
  }
@@ -19,19 +19,6 @@ export declare type FlowNodePreset = {
19
19
  };
20
20
  /** 各类型节点的默认尺寸与配色(同时作为属性面板的预设) */
21
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
22
  /**
36
23
  * @class FlowNode 流程图节点
37
24
  *
@@ -44,11 +31,14 @@ export default class FlowNode extends ICEGroup {
44
31
  static readonly typeId = "FlowNode";
45
32
  protected shapeComponent: any;
46
33
  protected labelComponent: any;
34
+ /**
35
+ * 内部子组件(形状 + 标题)由 kind/尺寸/配色派生,构造函数会重建 →
36
+ * 不参与引擎序列化(否则往返会重复挂载,且子组件 zIndex 抖动,见 ICEComponent.hasDerivedChildren)。
37
+ */
38
+ hasDerivedChildren(): boolean;
47
39
  constructor(props?: any);
48
40
  /** 按当前 kind / 尺寸 / 配色重建形状与标题(切换类型或改样式时调用) */
49
41
  private __buildShape;
50
42
  /** 改节点属性(标题 / 类型 / 配色 / 尺寸),必要时重建形状 */
51
43
  applyPatch(patch?: Record<string, any>): this;
52
- /** 流程快照用的纯数据 */
53
- toFlowObject(): FlowNodeSnapshot;
54
44
  }
@@ -19,19 +19,6 @@ export declare type FlowNodePreset = {
19
19
  };
20
20
  /** 各类型节点的默认尺寸与配色(同时作为属性面板的预设) */
21
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
22
  /**
36
23
  * @class FlowNode 流程图节点
37
24
  *
@@ -44,11 +31,14 @@ export default class FlowNode extends ICEGroup {
44
31
  static readonly typeId = "FlowNode";
45
32
  protected shapeComponent: any;
46
33
  protected labelComponent: any;
34
+ /**
35
+ * 内部子组件(形状 + 标题)由 kind/尺寸/配色派生,构造函数会重建 →
36
+ * 不参与引擎序列化(否则往返会重复挂载,且子组件 zIndex 抖动,见 ICEComponent.hasDerivedChildren)。
37
+ */
38
+ hasDerivedChildren(): boolean;
47
39
  constructor(props?: any);
48
40
  /** 按当前 kind / 尺寸 / 配色重建形状与标题(切换类型或改样式时调用) */
49
41
  private __buildShape;
50
42
  /** 改节点属性(标题 / 类型 / 配色 / 尺寸),必要时重建形状 */
51
43
  applyPatch(patch?: Record<string, any>): this;
52
- /** 流程快照用的纯数据 */
53
- toFlowObject(): FlowNodeSnapshot;
54
44
  }
@@ -337,6 +337,18 @@ declare abstract class ICEComponent extends ICEEventTarget {
337
337
  protected doRender(): void;
338
338
  /** 判断两个边界盒是否在视觉上重合(用于避免重复绘制几乎相同的 min/max 框)。 */
339
339
  private __areBoundingBoxesNearlyEqual;
340
+ /**
341
+ * 内部子组件是否为「由自身 state 派生」的。
342
+ *
343
+ * 复合组件(构造时按 state 建立内部子组件的组件,如「卡片 = 底框 + 标题」)应当返回 true:
344
+ * 这些子组件在反序列化时会被构造函数重建,序列化它们只会造成**重复挂载**
345
+ * (先由构造函数建一份、再由 Deserializer 挂一份)、并且子组件的自动 zIndex 每次都会变,
346
+ * 让同一份数据的两次序列化结果不稳定。返回 true 后,Serializer / Deserializer 都会跳过
347
+ * 该组件的 childNodes —— 只持久化它自己的 state(真相源),子组件视为派生结果。
348
+ *
349
+ * 默认为 false(普通容器/叶子组件的子节点是「真数据」,必须序列化)。
350
+ */
351
+ hasDerivedChildren(): boolean;
340
352
  /**
341
353
  * 获取组件的最小包围盒,此盒子的变换矩阵与组件自身完全相同。
342
354
  * 此方法需要在 render() 之后调用,组件没有渲染时无法计算最小包围盒。
@@ -337,6 +337,18 @@ declare abstract class ICEComponent extends ICEEventTarget {
337
337
  protected doRender(): void;
338
338
  /** 判断两个边界盒是否在视觉上重合(用于避免重复绘制几乎相同的 min/max 框)。 */
339
339
  private __areBoundingBoxesNearlyEqual;
340
+ /**
341
+ * 内部子组件是否为「由自身 state 派生」的。
342
+ *
343
+ * 复合组件(构造时按 state 建立内部子组件的组件,如「卡片 = 底框 + 标题」)应当返回 true:
344
+ * 这些子组件在反序列化时会被构造函数重建,序列化它们只会造成**重复挂载**
345
+ * (先由构造函数建一份、再由 Deserializer 挂一份)、并且子组件的自动 zIndex 每次都会变,
346
+ * 让同一份数据的两次序列化结果不稳定。返回 true 后,Serializer / Deserializer 都会跳过
347
+ * 该组件的 childNodes —— 只持久化它自己的 state(真相源),子组件视为派生结果。
348
+ *
349
+ * 默认为 false(普通容器/叶子组件的子节点是「真数据」,必须序列化)。
350
+ */
351
+ hasDerivedChildren(): boolean;
340
352
  /**
341
353
  * 获取组件的最小包围盒,此盒子的变换矩阵与组件自身完全相同。
342
354
  * 此方法需要在 render() 之后调用,组件没有渲染时无法计算最小包围盒。
@@ -51,5 +51,7 @@ export { default as ICE } from './ICE.mjs';
51
51
  export { default as CanvasRenderer } from './renderer/CanvasRenderer.mjs';
52
52
  export { default as PluginHost } from './plugin/PluginHost.mjs';
53
53
  export type { ICEPlugin, ICEPluginTool, ICERenderHook, ICERenderFrame } from './plugin/PluginHost.mjs';
54
+ export { default as Serializer, SERIALIZATION_VERSION } from './persistence/Serializer.mjs';
55
+ export { default as Deserializer, SERIALIZATION_MIGRATIONS } from './persistence/Deserializer.mjs';
54
56
  export { buildAccessibilityTree } from './a11y/accessibility.mjs';
55
57
  export type { ICEAccessibleNode, ICEAccessibleRole, ICEAccessibilityOptions } from './a11y/accessibility.mjs';
@@ -51,5 +51,7 @@ export { default as ICE } from './ICE';
51
51
  export { default as CanvasRenderer } from './renderer/CanvasRenderer';
52
52
  export { default as PluginHost } from './plugin/PluginHost';
53
53
  export type { ICEPlugin, ICEPluginTool, ICERenderHook, ICERenderFrame } from './plugin/PluginHost';
54
+ export { default as Serializer, SERIALIZATION_VERSION } from './persistence/Serializer';
55
+ export { default as Deserializer, SERIALIZATION_MIGRATIONS } from './persistence/Deserializer';
54
56
  export { buildAccessibilityTree } from './a11y/accessibility';
55
57
  export type { ICEAccessibleNode, ICEAccessibleRole, ICEAccessibilityOptions } from './a11y/accessibility';
@@ -14,9 +14,9 @@ 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
16
  export { default as FlowNode, FLOW_NODE_KINDS } from './flow/FlowNode.mjs';
17
- export type { FlowNodeKind, FlowNodePreset, FlowNodeSnapshot } from './flow/FlowNode.mjs';
17
+ export type { FlowNodeKind, FlowNodePreset } from './flow/FlowNode.mjs';
18
18
  export { default as FlowEdge } from './flow/FlowEdge.mjs';
19
- export type { FlowPort, FlowEdgeSnapshot } from './flow/FlowEdge.mjs';
19
+ export type { FlowPort } from './flow/FlowEdge.mjs';
20
20
  export { default as FlowDesigner, validateFlowSnapshot } from './flow/FlowDesigner.mjs';
21
21
  export type { FlowSnapshot, FlowLoadReport, FlowSnapshotValidationResult } from './flow/FlowDesigner.mjs';
22
22
  export { FlowDiamond, FlowParallelogram } from './flow/flow_shapes.mjs';
@@ -14,9 +14,9 @@ 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
16
  export { default as FlowNode, FLOW_NODE_KINDS } from './flow/FlowNode';
17
- export type { FlowNodeKind, FlowNodePreset, FlowNodeSnapshot } from './flow/FlowNode';
17
+ export type { FlowNodeKind, FlowNodePreset } from './flow/FlowNode';
18
18
  export { default as FlowEdge } from './flow/FlowEdge';
19
- export type { FlowPort, FlowEdgeSnapshot } from './flow/FlowEdge';
19
+ export type { FlowPort } from './flow/FlowEdge';
20
20
  export { default as FlowDesigner, validateFlowSnapshot } from './flow/FlowDesigner';
21
21
  export type { FlowSnapshot, FlowLoadReport, FlowSnapshotValidationResult } from './flow/FlowDesigner';
22
22
  export { FlowDiamond, FlowParallelogram } from './flow/flow_shapes';
@@ -0,0 +1,14 @@
1
+ import type { FlowDesignerCanvasProps } from './types.mjs';
2
+ /**
3
+ * <FlowDesignerCanvas> —— 在 React 中承载流程图编辑器的画布组件。
4
+ *
5
+ * 与 <EntityDesignerCanvas> 同构:挂载创建 ICE + FlowDesigner 会话、卸载销毁;
6
+ * 支持受控 value / 非受控 defaultValue、onChange(含画布拖拽节点)、onError 与命令式 ref。
7
+ *
8
+ * ```tsx
9
+ * const ref = useRef<FlowDesignerHandle>(null);
10
+ * <FlowDesignerCanvas ref={ref} defaultValue={flowJson} onChange={({ snapshot }) => save(snapshot)} />
11
+ * ```
12
+ */
13
+ declare const FlowDesignerCanvas: import("react").ForwardRefExoticComponent<FlowDesignerCanvasProps & import("react").RefAttributes<any>>;
14
+ export default FlowDesignerCanvas;
@@ -0,0 +1,14 @@
1
+ import type { FlowDesignerCanvasProps } from './types';
2
+ /**
3
+ * <FlowDesignerCanvas> —— 在 React 中承载流程图编辑器的画布组件。
4
+ *
5
+ * 与 <EntityDesignerCanvas> 同构:挂载创建 ICE + FlowDesigner 会话、卸载销毁;
6
+ * 支持受控 value / 非受控 defaultValue、onChange(含画布拖拽节点)、onError 与命令式 ref。
7
+ *
8
+ * ```tsx
9
+ * const ref = useRef<FlowDesignerHandle>(null);
10
+ * <FlowDesignerCanvas ref={ref} defaultValue={flowJson} onChange={({ snapshot }) => save(snapshot)} />
11
+ * ```
12
+ */
13
+ declare const FlowDesignerCanvas: import("react").ForwardRefExoticComponent<FlowDesignerCanvasProps & import("react").RefAttributes<any>>;
14
+ export default FlowDesignerCanvas;
@@ -1,4 +1,4 @@
1
- import type { EntityDesigner } from '../index.mjs';
1
+ import type { EntityDesigner, FlowDesigner } from '../index.mjs';
2
2
  /**
3
3
  * React 绑定层上下文:承载当前画布对应的 EntityDesigner 实例。
4
4
  * 由 <EntityDesignerCanvas>(或 <EntityDesignerProvider>)提供,供子树内的 useEntityDesigner() 读取。
@@ -23,3 +23,20 @@ export declare function EntityDesignerProvider(props: EntityDesignerProviderProp
23
23
  * 只能在 <EntityDesignerCanvas> / <EntityDesignerProvider> 的子树中使用;未就绪或不在树中时返回 null。
24
24
  */
25
25
  export declare function useEntityDesigner(): EntityDesigner | null;
26
+ /**
27
+ * 流程图上下文:承载当前画布对应的 FlowDesigner 实例。
28
+ * 由 <FlowDesignerCanvas>(或 <FlowDesignerProvider>)提供,供子树内的 useFlowDesigner() 读取。
29
+ */
30
+ export declare const FlowDesignerContext: import("react").Context<FlowDesigner>;
31
+ export declare type FlowDesignerProviderProps = {
32
+ /** 要共享的 FlowDesigner 实例(通常来自 createFlowSession) */
33
+ designer: FlowDesigner | null;
34
+ children?: any;
35
+ };
36
+ /** 手动提供流程图上下文。适用于「自己创建会话」的场景。 */
37
+ export declare function FlowDesignerProvider(props: FlowDesignerProviderProps): import("react").FunctionComponentElement<import("react").ProviderProps<FlowDesigner>>;
38
+ /**
39
+ * 读取当前画布的 FlowDesigner 实例。
40
+ * 只能在 <FlowDesignerCanvas> / <FlowDesignerProvider> 的子树中使用;未就绪或不在树中时返回 null。
41
+ */
42
+ export declare function useFlowDesigner(): FlowDesigner | null;
@@ -1,4 +1,4 @@
1
- import type { EntityDesigner } from '../index';
1
+ import type { EntityDesigner, FlowDesigner } from '../index';
2
2
  /**
3
3
  * React 绑定层上下文:承载当前画布对应的 EntityDesigner 实例。
4
4
  * 由 <EntityDesignerCanvas>(或 <EntityDesignerProvider>)提供,供子树内的 useEntityDesigner() 读取。
@@ -23,3 +23,20 @@ export declare function EntityDesignerProvider(props: EntityDesignerProviderProp
23
23
  * 只能在 <EntityDesignerCanvas> / <EntityDesignerProvider> 的子树中使用;未就绪或不在树中时返回 null。
24
24
  */
25
25
  export declare function useEntityDesigner(): EntityDesigner | null;
26
+ /**
27
+ * 流程图上下文:承载当前画布对应的 FlowDesigner 实例。
28
+ * 由 <FlowDesignerCanvas>(或 <FlowDesignerProvider>)提供,供子树内的 useFlowDesigner() 读取。
29
+ */
30
+ export declare const FlowDesignerContext: import("react").Context<FlowDesigner>;
31
+ export declare type FlowDesignerProviderProps = {
32
+ /** 要共享的 FlowDesigner 实例(通常来自 createFlowSession) */
33
+ designer: FlowDesigner | null;
34
+ children?: any;
35
+ };
36
+ /** 手动提供流程图上下文。适用于「自己创建会话」的场景。 */
37
+ export declare function FlowDesignerProvider(props: FlowDesignerProviderProps): import("react").FunctionComponentElement<import("react").ProviderProps<FlowDesigner>>;
38
+ /**
39
+ * 读取当前画布的 FlowDesigner 实例。
40
+ * 只能在 <FlowDesignerCanvas> / <FlowDesignerProvider> 的子树中使用;未就绪或不在树中时返回 null。
41
+ */
42
+ export declare function useFlowDesigner(): FlowDesigner | null;
@@ -14,4 +14,11 @@ export type { EntityDesignerProviderProps } from './context.mjs';
14
14
  export { createDesignerSession, shouldApplyControlledValue } from './session.mjs';
15
15
  export type { DesignerSession, DesignerSessionOptions } from './session.mjs';
16
16
  export type { EntityDesignerCanvasProps, EntityDesignerChangePayload, EntityDesignerHandle } from './types.mjs';
17
- export { Entity, Relation, toSchemaObject, toSchemaString, validateSchema } from '../index.mjs';
17
+ export { default as FlowDesignerCanvas } from './FlowDesignerCanvas.mjs';
18
+ export { FlowDesignerContext, FlowDesignerProvider, useFlowDesigner } from './context.mjs';
19
+ export type { FlowDesignerProviderProps } from './context.mjs';
20
+ export { createFlowSession } from './session.mjs';
21
+ export type { FlowSession, FlowSessionOptions } from './session.mjs';
22
+ export type { FlowDesignerCanvasProps, FlowDesignerChangePayload, FlowDesignerHandle } from './types.mjs';
23
+ export { Entity, Relation, FlowNode, FlowEdge, FlowDesigner, FLOW_NODE_KINDS, toSchemaObject, toSchemaString, validateSchema, } from '../index.mjs';
24
+ export type { FlowNodeKind, FlowNodePreset, FlowPort, FlowSnapshot, FlowLoadReport } from '../index.mjs';
@@ -14,4 +14,11 @@ export type { EntityDesignerProviderProps } from './context';
14
14
  export { createDesignerSession, shouldApplyControlledValue } from './session';
15
15
  export type { DesignerSession, DesignerSessionOptions } from './session';
16
16
  export type { EntityDesignerCanvasProps, EntityDesignerChangePayload, EntityDesignerHandle } from './types';
17
- export { Entity, Relation, toSchemaObject, toSchemaString, validateSchema } from '../index';
17
+ export { default as FlowDesignerCanvas } from './FlowDesignerCanvas';
18
+ export { FlowDesignerContext, FlowDesignerProvider, useFlowDesigner } from './context';
19
+ export type { FlowDesignerProviderProps } from './context';
20
+ export { createFlowSession } from './session';
21
+ export type { FlowSession, FlowSessionOptions } from './session';
22
+ export type { FlowDesignerCanvasProps, FlowDesignerChangePayload, FlowDesignerHandle } from './types';
23
+ export { Entity, Relation, FlowNode, FlowEdge, FlowDesigner, FLOW_NODE_KINDS, toSchemaObject, toSchemaString, validateSchema, } from '../index';
24
+ export type { FlowNodeKind, FlowNodePreset, FlowPort, FlowSnapshot, FlowLoadReport } from '../index';
@@ -0,0 +1,8 @@
1
+ import type { EntityDesignerErrorPayload } from './types.mjs';
2
+ /**
3
+ * 载入快照失败时上报给 onError(默认 console.error)。
4
+ *
5
+ * React 绑定层的两处 loadProject / load 都走这里兜底:非法 / 版本不兼容的快照
6
+ * 只会被上报,不会把异常抛进 React 渲染树(挂载期抛错会直接崩掉整棵子树)。
7
+ */
8
+ export declare function reportLoadError(handler: ((payload: EntityDesignerErrorPayload) => void) | undefined, phase: EntityDesignerErrorPayload['phase'], snapshot: string, error: unknown): void;
@@ -0,0 +1,8 @@
1
+ import type { EntityDesignerErrorPayload } from './types';
2
+ /**
3
+ * 载入快照失败时上报给 onError(默认 console.error)。
4
+ *
5
+ * React 绑定层的两处 loadProject / load 都走这里兜底:非法 / 版本不兼容的快照
6
+ * 只会被上报,不会把异常抛进 React 渲染树(挂载期抛错会直接崩掉整棵子树)。
7
+ */
8
+ export declare function reportLoadError(handler: ((payload: EntityDesignerErrorPayload) => void) | undefined, phase: EntityDesignerErrorPayload['phase'], snapshot: string, error: unknown): void;
@@ -1,4 +1,4 @@
1
- import { EntityDesigner } from '../index.mjs';
1
+ import { EntityDesigner, FlowDesigner } from '../index.mjs';
2
2
  export declare type DesignerSessionOptions = {
3
3
  /** 渲染模式,默认 dirty-rect */
4
4
  renderMode?: 'dirty-rect' | 'full';
@@ -28,3 +28,24 @@ export declare function createDesignerSession(canvas: any, options?: DesignerSes
28
28
  * 此时 lastApplied 已经等于该值,因此这里返回 false,避免「onChange → setState → 再 loadProject」的回环。
29
29
  */
30
30
  export declare function shouldApplyControlledValue(value: string | undefined, lastApplied: string | null | undefined): boolean;
31
+ export declare type FlowSessionOptions = {
32
+ /** 渲染模式,默认 dirty-rect */
33
+ renderMode?: 'dirty-rect' | 'full';
34
+ /** 初始流程图快照,等价于 load(initialFlow) */
35
+ initialFlow?: string;
36
+ /** 流程变更回调(含画布拖动节点) */
37
+ onChange?: (snapshot: string) => void;
38
+ };
39
+ export declare type FlowSession = {
40
+ ice: any;
41
+ designer: FlowDesigner;
42
+ /** 销毁会话:退订 + dispose designer + destroy ICE(可重复调用) */
43
+ destroy(): void;
44
+ };
45
+ /**
46
+ * 在给定的 canvas 元素上创建「ICE + FlowDesigner」会话。
47
+ *
48
+ * 与 createDesignerSession 同构:挂载即初始化、卸载即销毁;ICE.init() 幂等、
49
+ * ICE.destroy() 会解绑全局监听与事件总线,因此 StrictMode 双挂载不会累积监听。
50
+ */
51
+ export declare function createFlowSession(canvas: any, options?: FlowSessionOptions): FlowSession;