ice-entity-designer 0.0.21 → 0.0.23

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 (43) hide show
  1. package/README.md +96 -1
  2. package/dist/index.cjs +3 -3
  3. package/dist/index.mjs +3 -3
  4. package/dist/index.umd.js +3 -3
  5. package/dist/react.cjs +3 -3
  6. package/dist/react.mjs +3 -3
  7. package/dist/types/bpmn/BpmnDesigner.d.mts +50 -0
  8. package/dist/types/bpmn/BpmnDesigner.d.ts +50 -0
  9. package/dist/types/bpmn/bpmn_shapes.d.mts +61 -0
  10. package/dist/types/bpmn/bpmn_shapes.d.ts +61 -0
  11. package/dist/types/bpmn/bpmn_validate.d.mts +24 -0
  12. package/dist/types/bpmn/bpmn_validate.d.ts +24 -0
  13. package/dist/types/bpmn/bpmn_xml.d.mts +46 -0
  14. package/dist/types/bpmn/bpmn_xml.d.ts +46 -0
  15. package/dist/types/flow/FlowDesigner.d.mts +23 -1
  16. package/dist/types/flow/FlowDesigner.d.ts +23 -1
  17. package/dist/types/flow/FlowEdge.d.mts +8 -0
  18. package/dist/types/flow/FlowEdge.d.ts +8 -0
  19. package/dist/types/flow/FlowNode.d.mts +40 -3
  20. package/dist/types/flow/FlowNode.d.ts +40 -3
  21. package/dist/types/ice-render/ICE.d.mts +36 -0
  22. package/dist/types/ice-render/ICE.d.ts +36 -0
  23. package/dist/types/ice-render/cross-platform/Path2DRecorder.d.mts +76 -0
  24. package/dist/types/ice-render/cross-platform/Path2DRecorder.d.ts +76 -0
  25. package/dist/types/ice-render/cross-platform/PolyfillPath2D.d.mts +8 -18
  26. package/dist/types/ice-render/cross-platform/PolyfillPath2D.d.ts +8 -18
  27. package/dist/types/ice-render/export/SvgExporter.d.mts +54 -0
  28. package/dist/types/ice-render/export/SvgExporter.d.ts +54 -0
  29. package/dist/types/ice-render/graphic/ICEComponent.d.mts +29 -7
  30. package/dist/types/ice-render/graphic/ICEComponent.d.ts +29 -7
  31. package/dist/types/ice-render/graphic/ICEPath.d.mts +7 -0
  32. package/dist/types/ice-render/graphic/ICEPath.d.ts +7 -0
  33. package/dist/types/ice-render/graphic/container/ICEGroup.d.mts +10 -0
  34. package/dist/types/ice-render/graphic/container/ICEGroup.d.ts +10 -0
  35. package/dist/types/ice-render/graphic/link/ICEPolyLine.d.mts +17 -0
  36. package/dist/types/ice-render/graphic/link/ICEPolyLine.d.ts +17 -0
  37. package/dist/types/ice-render/graphic/text/ICEText.d.mts +21 -0
  38. package/dist/types/ice-render/graphic/text/ICEText.d.ts +21 -0
  39. package/dist/types/ice-render/index.d.mts +2 -0
  40. package/dist/types/ice-render/index.d.ts +2 -0
  41. package/dist/types/index.d.mts +5 -0
  42. package/dist/types/index.d.ts +5 -0
  43. package/package.json +1 -1
@@ -0,0 +1,50 @@
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 FlowDesigner from '../flow/FlowDesigner.mjs';
9
+ import type { BpmnIssue } from './bpmn_validate.mjs';
10
+ /**
11
+ * BPMN 设计器:`FlowDesigner` 的薄扩展,只补两件 BPMN 特有的事:
12
+ *
13
+ * 1. **顺序流上的条件/默认标记**(BPMN 记法要求):标记是「派生装饰」,
14
+ * 放在 `ice.toolNodes`(工具层)里 —— 工具层不参与引擎序列化(我们上轮验证过),
15
+ * 所以文档仍然是纯粹的业务模型,标记由 `flowType/condition/isDefault` 推出来。
16
+ * 2. **BPMN 语义校验**:`validate()` 直接复用 `validateBpmn()`。
17
+ *
18
+ * 其余能力(建节点/连线、选择、增删改、撤销重做、快照存取、适应视图、订阅)
19
+ * 全部继承自 `FlowDesigner` —— 沿用同一套机制,不再造第二份。
20
+ */
21
+ export default class BpmnDesigner extends FlowDesigner {
22
+ private __markers;
23
+ private __markerSyncing;
24
+ private __nesting;
25
+ constructor(ice: any);
26
+ /** BPMN 语义校验(事件/网关/池/连通性等,见 bpmn_validate.ts) */
27
+ validateBpmn(): BpmnIssue[];
28
+ /**
29
+ * 建节点:除常规流程元素外,**自动按几何把节点嵌进池/泳道**(用引擎的容器能力)。
30
+ *
31
+ * 为什么要真嵌套:外层容器(池)被拖动时,引擎的矩阵组合会让内部泳道与泳道里的节点
32
+ * 一起移动 —— 这正是「拖动池子,里面的东西跟着走」的正确实现;扁平结构做不到。
33
+ *
34
+ * 归属规则:取「面积最小的、包住节点中心的容器」(泳道比池小 → 优先落在泳道里)。
35
+ * 子组件坐标是**父容器左上角**为原点,因此嵌套时要做一次坐标换算。
36
+ */
37
+ createNode(kind: any, props?: any): any;
38
+ /** 把(已经在 ice 根上的)节点嵌进最内层容器 */
39
+ private __nestByGeometry;
40
+ /**
41
+ * 容器的**内容区**(扣掉名称带)。
42
+ *
43
+ * 池的名称带在顶部、泳道在左侧,名称带属于标题区、不该被内部元素压住;
44
+ * 所以归属判定按内容区算,否则泳道会盖住池标题。
45
+ */
46
+ private __contentBox;
47
+ /** 顺序流的条件/默认标记:按需创建、原位更新(放在工具层,不污染文档) */
48
+ syncFlowMarkers(): void;
49
+ dispose(): void;
50
+ }
@@ -0,0 +1,50 @@
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 FlowDesigner from '../flow/FlowDesigner';
9
+ import type { BpmnIssue } from './bpmn_validate';
10
+ /**
11
+ * BPMN 设计器:`FlowDesigner` 的薄扩展,只补两件 BPMN 特有的事:
12
+ *
13
+ * 1. **顺序流上的条件/默认标记**(BPMN 记法要求):标记是「派生装饰」,
14
+ * 放在 `ice.toolNodes`(工具层)里 —— 工具层不参与引擎序列化(我们上轮验证过),
15
+ * 所以文档仍然是纯粹的业务模型,标记由 `flowType/condition/isDefault` 推出来。
16
+ * 2. **BPMN 语义校验**:`validate()` 直接复用 `validateBpmn()`。
17
+ *
18
+ * 其余能力(建节点/连线、选择、增删改、撤销重做、快照存取、适应视图、订阅)
19
+ * 全部继承自 `FlowDesigner` —— 沿用同一套机制,不再造第二份。
20
+ */
21
+ export default class BpmnDesigner extends FlowDesigner {
22
+ private __markers;
23
+ private __markerSyncing;
24
+ private __nesting;
25
+ constructor(ice: any);
26
+ /** BPMN 语义校验(事件/网关/池/连通性等,见 bpmn_validate.ts) */
27
+ validateBpmn(): BpmnIssue[];
28
+ /**
29
+ * 建节点:除常规流程元素外,**自动按几何把节点嵌进池/泳道**(用引擎的容器能力)。
30
+ *
31
+ * 为什么要真嵌套:外层容器(池)被拖动时,引擎的矩阵组合会让内部泳道与泳道里的节点
32
+ * 一起移动 —— 这正是「拖动池子,里面的东西跟着走」的正确实现;扁平结构做不到。
33
+ *
34
+ * 归属规则:取「面积最小的、包住节点中心的容器」(泳道比池小 → 优先落在泳道里)。
35
+ * 子组件坐标是**父容器左上角**为原点,因此嵌套时要做一次坐标换算。
36
+ */
37
+ createNode(kind: any, props?: any): any;
38
+ /** 把(已经在 ice 根上的)节点嵌进最内层容器 */
39
+ private __nestByGeometry;
40
+ /**
41
+ * 容器的**内容区**(扣掉名称带)。
42
+ *
43
+ * 池的名称带在顶部、泳道在左侧,名称带属于标题区、不该被内部元素压住;
44
+ * 所以归属判定按内容区算,否则泳道会盖住池标题。
45
+ */
46
+ private __contentBox;
47
+ /** 顺序流的条件/默认标记:按需创建、原位更新(放在工具层,不污染文档) */
48
+ syncFlowMarkers(): void;
49
+ dispose(): void;
50
+ }
@@ -0,0 +1,61 @@
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
+ * 事件(圆):开始 / 中间 / 结束 + 触发类型图标。
11
+ *
12
+ * state.eventKind: 'start' | 'intermediate' | 'end'
13
+ * state.trigger: 'none' | 'message' | 'timer' | 'error' | 'terminate'
14
+ */
15
+ export declare class BpmnEventShape extends ICEPath {
16
+ static readonly typeId = "BpmnEventShape";
17
+ protected createPathObject(): any;
18
+ }
19
+ /** 网关(菱形 + 内部符号):排他 × / 并行 + / 包容 ○ / 事件网关(五边形) */
20
+ export declare class BpmnGatewayShape extends ICEPath {
21
+ static readonly typeId = "BpmnGatewayShape";
22
+ protected createPathObject(): any;
23
+ }
24
+ /** 任务类型角标(左上角小图标,尺寸固定 12×12,由节点定位) */
25
+ export declare class BpmnTaskIcon extends ICEPath {
26
+ static readonly typeId = "BpmnTaskIcon";
27
+ protected createPathObject(): any;
28
+ }
29
+ /** 子流程折叠标记(底部居中的「+」小方块) */
30
+ export declare class BpmnSubprocessMarker extends ICEPath {
31
+ static readonly typeId = "BpmnSubprocessMarker";
32
+ protected createPathObject(): any;
33
+ }
34
+ /** 数据对象:右上角折角矩形 */
35
+ export declare class BpmnDataObjectShape extends ICEPath {
36
+ static readonly typeId = "BpmnDataObjectShape";
37
+ protected createPathObject(): any;
38
+ }
39
+ /**
40
+ * 文本注释:**完整矩形** + 左侧内嵌的括号竖线(bpmn.io / Camunda 的标准画法)。
41
+ *
42
+ * 曾经画成「左括号 + 上下两条线、右侧开口」—— 那样右侧没有边框,看起来像个残缺的框;
43
+ * BPMN 2.0 的文本注释是闭合矩形,左侧竖线只是括号装饰,四条边都要有。
44
+ */
45
+ export declare class BpmnAnnotationShape extends ICEPath {
46
+ static readonly typeId = "BpmnAnnotationShape";
47
+ protected createPathObject(): any;
48
+ }
49
+ /**
50
+ * 泳道 / 池:矩形 + 名称带分隔线。
51
+ * `band` = 'left'(横向泳道,默认)| 'top'(池标题带)
52
+ */
53
+ export declare class BpmnLaneShape extends ICEPath {
54
+ static readonly typeId = "BpmnLaneShape";
55
+ protected createPathObject(): any;
56
+ }
57
+ /** 顺序流上的条件/默认标记(小菱形 / 斜杠),尺寸固定 14×14 */
58
+ export declare class BpmnFlowMarker extends ICEPath {
59
+ static readonly typeId = "BpmnFlowMarker";
60
+ protected createPathObject(): any;
61
+ }
@@ -0,0 +1,61 @@
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
+ * 事件(圆):开始 / 中间 / 结束 + 触发类型图标。
11
+ *
12
+ * state.eventKind: 'start' | 'intermediate' | 'end'
13
+ * state.trigger: 'none' | 'message' | 'timer' | 'error' | 'terminate'
14
+ */
15
+ export declare class BpmnEventShape extends ICEPath {
16
+ static readonly typeId = "BpmnEventShape";
17
+ protected createPathObject(): any;
18
+ }
19
+ /** 网关(菱形 + 内部符号):排他 × / 并行 + / 包容 ○ / 事件网关(五边形) */
20
+ export declare class BpmnGatewayShape extends ICEPath {
21
+ static readonly typeId = "BpmnGatewayShape";
22
+ protected createPathObject(): any;
23
+ }
24
+ /** 任务类型角标(左上角小图标,尺寸固定 12×12,由节点定位) */
25
+ export declare class BpmnTaskIcon extends ICEPath {
26
+ static readonly typeId = "BpmnTaskIcon";
27
+ protected createPathObject(): any;
28
+ }
29
+ /** 子流程折叠标记(底部居中的「+」小方块) */
30
+ export declare class BpmnSubprocessMarker extends ICEPath {
31
+ static readonly typeId = "BpmnSubprocessMarker";
32
+ protected createPathObject(): any;
33
+ }
34
+ /** 数据对象:右上角折角矩形 */
35
+ export declare class BpmnDataObjectShape extends ICEPath {
36
+ static readonly typeId = "BpmnDataObjectShape";
37
+ protected createPathObject(): any;
38
+ }
39
+ /**
40
+ * 文本注释:**完整矩形** + 左侧内嵌的括号竖线(bpmn.io / Camunda 的标准画法)。
41
+ *
42
+ * 曾经画成「左括号 + 上下两条线、右侧开口」—— 那样右侧没有边框,看起来像个残缺的框;
43
+ * BPMN 2.0 的文本注释是闭合矩形,左侧竖线只是括号装饰,四条边都要有。
44
+ */
45
+ export declare class BpmnAnnotationShape extends ICEPath {
46
+ static readonly typeId = "BpmnAnnotationShape";
47
+ protected createPathObject(): any;
48
+ }
49
+ /**
50
+ * 泳道 / 池:矩形 + 名称带分隔线。
51
+ * `band` = 'left'(横向泳道,默认)| 'top'(池标题带)
52
+ */
53
+ export declare class BpmnLaneShape extends ICEPath {
54
+ static readonly typeId = "BpmnLaneShape";
55
+ protected createPathObject(): any;
56
+ }
57
+ /** 顺序流上的条件/默认标记(小菱形 / 斜杠),尺寸固定 14×14 */
58
+ export declare class BpmnFlowMarker extends ICEPath {
59
+ static readonly typeId = "BpmnFlowMarker";
60
+ protected createPathObject(): any;
61
+ }
@@ -0,0 +1,24 @@
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
+ /**
9
+ * BPMN 2.0 语义校验(记法之外的那一层)。
10
+ *
11
+ * 只做「结构正确性」检查,不涉及具体引擎的扩展属性;返回问题列表供属性面板/工具条展示。
12
+ * 与 ER 侧的 `validateSchema()` 同一形态(`{ level, code, message, componentId }`)。
13
+ *
14
+ * 约定:**容器归属按几何判定**——节点落在哪个池/泳道矩形内就属于它。
15
+ * (真实 BPMN 里泳道是 `<laneSet>` 的显式归属;我们不做重父级,导出 XML 时按几何归类,
16
+ * 这样拖拽体验与文档模型都简单,且不会出现「跨容器拖动导致连线错乱」。)
17
+ */
18
+ export declare type BpmnIssue = {
19
+ level: 'error' | 'warning';
20
+ code: string;
21
+ message: string;
22
+ componentId?: string;
23
+ };
24
+ export declare function validateBpmn(designer: any): BpmnIssue[];
@@ -0,0 +1,24 @@
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
+ /**
9
+ * BPMN 2.0 语义校验(记法之外的那一层)。
10
+ *
11
+ * 只做「结构正确性」检查,不涉及具体引擎的扩展属性;返回问题列表供属性面板/工具条展示。
12
+ * 与 ER 侧的 `validateSchema()` 同一形态(`{ level, code, message, componentId }`)。
13
+ *
14
+ * 约定:**容器归属按几何判定**——节点落在哪个池/泳道矩形内就属于它。
15
+ * (真实 BPMN 里泳道是 `<laneSet>` 的显式归属;我们不做重父级,导出 XML 时按几何归类,
16
+ * 这样拖拽体验与文档模型都简单,且不会出现「跨容器拖动导致连线错乱」。)
17
+ */
18
+ export declare type BpmnIssue = {
19
+ level: 'error' | 'warning';
20
+ code: string;
21
+ message: string;
22
+ componentId?: string;
23
+ };
24
+ export declare function validateBpmn(designer: any): BpmnIssue[];
@@ -0,0 +1,46 @@
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
+ /**
9
+ * BPMN 2.0 XML 互操作(`<definitions>` / `<process>` / `<collaboration>` / DI 布局)。
10
+ *
11
+ * 覆盖范围(与我们支持的元素一一对应,够和 Camunda / Flowable / bpmn.io 互通):
12
+ * - 协作:`<collaboration><participant>`(池)、`<laneSet><lane>`(泳道)、`<messageFlow>`
13
+ * - 流程:`<startEvent>` / `<endEvent>` / `<intermediateThrowEvent>`、`<task>`(含
14
+ * `userTask` / `serviceTask` / `scriptTask` / `sendTask` / `receiveTask` / `manualTask`)、
15
+ * `<exclusiveGateway>` / `<parallelGateway>` / `<inclusiveGateway>` / `<eventBasedGateway>`、
16
+ * `<subProcess>`、`<dataObjectReference>`、`<textAnnotation>`
17
+ * - 连线:`<sequenceFlow>`(带 `<conditionExpression>` 与 `default` 属性)、`<messageFlow>`、
18
+ * `<association>`
19
+ * - 图形:`<bpmndi:BPMNDiagram><bpmndi:BPMNPlane>` + `<bpmndi:BPMNShape><dc:Bounds>` /
20
+ * `<bpmndi:BPMNEdge><di:waypoint>`
21
+ *
22
+ * 未识别的元素/属性会被忽略(导入时计入 `warnings`),不会让整份文件打不开 ——
23
+ * 与引擎 `Deserializer` 的容错语义保持一致。
24
+ */
25
+ import type FlowDesigner from '../flow/FlowDesigner.mjs';
26
+ export declare type BpmnImportResult = {
27
+ nodes: number;
28
+ edges: number;
29
+ warnings: string[];
30
+ };
31
+ /**
32
+ * 导出 BPMN 2.0 XML。
33
+ *
34
+ * 容器归属按几何判定:节点落在哪个池矩形内就归到该池的 `<process>`;
35
+ * 池与池之间的连线导出为 `<messageFlow>`(并放进 `<collaboration>`),
36
+ * 池内部的顺序流导出为该 process 的 `<sequenceFlow>`。
37
+ */
38
+ export declare function toBpmnXml(designer: FlowDesigner, options?: {
39
+ name?: string;
40
+ }): string;
41
+ /**
42
+ * 导入 BPMN 2.0 XML(覆盖范围见文件头注释)。
43
+ *
44
+ * 需要 `DOMParser`(浏览器 / jsdom 提供)。无法识别的元素会被忽略并计入 `warnings`。
45
+ */
46
+ export declare function fromBpmnXml(xml: string, designer: FlowDesigner): BpmnImportResult;
@@ -0,0 +1,46 @@
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
+ /**
9
+ * BPMN 2.0 XML 互操作(`<definitions>` / `<process>` / `<collaboration>` / DI 布局)。
10
+ *
11
+ * 覆盖范围(与我们支持的元素一一对应,够和 Camunda / Flowable / bpmn.io 互通):
12
+ * - 协作:`<collaboration><participant>`(池)、`<laneSet><lane>`(泳道)、`<messageFlow>`
13
+ * - 流程:`<startEvent>` / `<endEvent>` / `<intermediateThrowEvent>`、`<task>`(含
14
+ * `userTask` / `serviceTask` / `scriptTask` / `sendTask` / `receiveTask` / `manualTask`)、
15
+ * `<exclusiveGateway>` / `<parallelGateway>` / `<inclusiveGateway>` / `<eventBasedGateway>`、
16
+ * `<subProcess>`、`<dataObjectReference>`、`<textAnnotation>`
17
+ * - 连线:`<sequenceFlow>`(带 `<conditionExpression>` 与 `default` 属性)、`<messageFlow>`、
18
+ * `<association>`
19
+ * - 图形:`<bpmndi:BPMNDiagram><bpmndi:BPMNPlane>` + `<bpmndi:BPMNShape><dc:Bounds>` /
20
+ * `<bpmndi:BPMNEdge><di:waypoint>`
21
+ *
22
+ * 未识别的元素/属性会被忽略(导入时计入 `warnings`),不会让整份文件打不开 ——
23
+ * 与引擎 `Deserializer` 的容错语义保持一致。
24
+ */
25
+ import type FlowDesigner from '../flow/FlowDesigner';
26
+ export declare type BpmnImportResult = {
27
+ nodes: number;
28
+ edges: number;
29
+ warnings: string[];
30
+ };
31
+ /**
32
+ * 导出 BPMN 2.0 XML。
33
+ *
34
+ * 容器归属按几何判定:节点落在哪个池矩形内就归到该池的 `<process>`;
35
+ * 池与池之间的连线导出为 `<messageFlow>`(并放进 `<collaboration>`),
36
+ * 池内部的顺序流导出为该 process 的 `<sequenceFlow>`。
37
+ */
38
+ export declare function toBpmnXml(designer: FlowDesigner, options?: {
39
+ name?: string;
40
+ }): string;
41
+ /**
42
+ * 导入 BPMN 2.0 XML(覆盖范围见文件头注释)。
43
+ *
44
+ * 需要 `DOMParser`(浏览器 / jsdom 提供)。无法识别的元素会被忽略并计入 `warnings`。
45
+ */
46
+ export declare function fromBpmnXml(xml: string, designer: FlowDesigner): BpmnImportResult;
@@ -1,4 +1,4 @@
1
- import type { ICE } from '../ice-render/index.mjs';
1
+ import type { ICE, SvgExportOptions } from '../ice-render/index.mjs';
2
2
  import type { FlowNodeKind } from './FlowNode.mjs';
3
3
  /**
4
4
  * 流程图文档。
@@ -68,6 +68,13 @@ export default class FlowDesigner {
68
68
  constructor(ice: ICE);
69
69
  get nodes(): any[];
70
70
  get edges(): any[];
71
+ /**
72
+ * 递归展开场景树(容器型节点 —— 如 BPMN 的池/泳道 —— 里面的子节点同样算流程的一部分)。
73
+ *
74
+ * 扁平场景(纯流程图/ER)与旧行为完全一致;嵌套场景下 nodes/edges 才看得到后代节点,
75
+ * 校验、统计、快照、连线端点查找都因此无需特判。
76
+ */
77
+ protected __flatten(): any[];
71
78
  get selected(): any;
72
79
  /**
73
80
  * 订阅流程变更(增删改 / 连线 / 载入 / undo / redo 之后触发)。
@@ -116,6 +123,21 @@ export default class FlowDesigner {
116
123
  /** 把整个流程缩放到画布可视区内 */
117
124
  fitViewport(padding?: number): void;
118
125
  canUndo(): boolean;
126
+ /**
127
+ * 把当前流程图导出为 **SVG 矢量图**(打印、进设计工具、服务端出图都走它)。
128
+ *
129
+ * 与画布截图(`toDataURL`)的区别:这是矢量,放大不糊、可以再编辑;导出与画布**同一口径**
130
+ * (绘制顺序、世界矩阵、样式合并、透明度、裁剪、虚线、渐变、阴影),因此"所见即所导"。
131
+ *
132
+ * ```js
133
+ * const svg = designer.toSvg(); // 内容自适应、透明背景
134
+ * const svg = designer.toSvg({ background: '#fff', padding: 16 });
135
+ * const svg = designer.toSvg({ area: 'viewport' }); // 当前视口所见即所得
136
+ * ```
137
+ *
138
+ * 具体实现复用引擎的 `exportSvg(this.ice, options)` —— 应用层不另造一套导出。
139
+ */
140
+ toSvg(options?: SvgExportOptions): string;
119
141
  canRedo(): boolean;
120
142
  captureHistory(): void;
121
143
  /** 清空撤销/重做栈(用于「载入示例」这类不该占用历史的初始化操作) */
@@ -1,4 +1,4 @@
1
- import type { ICE } from '../ice-render/index';
1
+ import type { ICE, SvgExportOptions } from '../ice-render/index';
2
2
  import type { FlowNodeKind } from './FlowNode';
3
3
  /**
4
4
  * 流程图文档。
@@ -68,6 +68,13 @@ export default class FlowDesigner {
68
68
  constructor(ice: ICE);
69
69
  get nodes(): any[];
70
70
  get edges(): any[];
71
+ /**
72
+ * 递归展开场景树(容器型节点 —— 如 BPMN 的池/泳道 —— 里面的子节点同样算流程的一部分)。
73
+ *
74
+ * 扁平场景(纯流程图/ER)与旧行为完全一致;嵌套场景下 nodes/edges 才看得到后代节点,
75
+ * 校验、统计、快照、连线端点查找都因此无需特判。
76
+ */
77
+ protected __flatten(): any[];
71
78
  get selected(): any;
72
79
  /**
73
80
  * 订阅流程变更(增删改 / 连线 / 载入 / undo / redo 之后触发)。
@@ -116,6 +123,21 @@ export default class FlowDesigner {
116
123
  /** 把整个流程缩放到画布可视区内 */
117
124
  fitViewport(padding?: number): void;
118
125
  canUndo(): boolean;
126
+ /**
127
+ * 把当前流程图导出为 **SVG 矢量图**(打印、进设计工具、服务端出图都走它)。
128
+ *
129
+ * 与画布截图(`toDataURL`)的区别:这是矢量,放大不糊、可以再编辑;导出与画布**同一口径**
130
+ * (绘制顺序、世界矩阵、样式合并、透明度、裁剪、虚线、渐变、阴影),因此"所见即所导"。
131
+ *
132
+ * ```js
133
+ * const svg = designer.toSvg(); // 内容自适应、透明背景
134
+ * const svg = designer.toSvg({ background: '#fff', padding: 16 });
135
+ * const svg = designer.toSvg({ area: 'viewport' }); // 当前视口所见即所得
136
+ * ```
137
+ *
138
+ * 具体实现复用引擎的 `exportSvg(this.ice, options)` —— 应用层不另造一套导出。
139
+ */
140
+ toSvg(options?: SvgExportOptions): string;
119
141
  canRedo(): boolean;
120
142
  captureHistory(): void;
121
143
  /** 清空撤销/重做栈(用于「载入示例」这类不该占用历史的初始化操作) */
@@ -19,4 +19,12 @@ export default class FlowEdge extends ICEVisioLink {
19
19
  /** 连线没有子组件;声明派生可保证将来即使加了内部装饰也不会被重复序列化 */
20
20
  hasDerivedChildren(): boolean;
21
21
  constructor(props?: any);
22
+ /**
23
+ * 改连线属性,并按 BPMN 语义重算派生样式(线型 / 虚线 / 箭头)。
24
+ *
25
+ * - sequence:实线 + 实心箭头
26
+ * - message:虚线 + 空心箭头(跨参与者通信)
27
+ * - association:点线 + 无箭头
28
+ */
29
+ applyPatch(patch?: Record<string, any>): this;
22
30
  }
@@ -19,4 +19,12 @@ export default class FlowEdge extends ICEVisioLink {
19
19
  /** 连线没有子组件;声明派生可保证将来即使加了内部装饰也不会被重复序列化 */
20
20
  hasDerivedChildren(): boolean;
21
21
  constructor(props?: any);
22
+ /**
23
+ * 改连线属性,并按 BPMN 语义重算派生样式(线型 / 虚线 / 箭头)。
24
+ *
25
+ * - sequence:实线 + 实心箭头
26
+ * - message:虚线 + 空心箭头(跨参与者通信)
27
+ * - association:点线 + 无箭头
28
+ */
29
+ applyPatch(patch?: Record<string, any>): this;
22
30
  }
@@ -6,8 +6,18 @@
6
6
  *
7
7
  */
8
8
  import { ICEGroup } from '../ice-render/index.mjs';
9
- /** 流程图节点类型:起止 / 处理 / 判定 / 输入输出 */
10
- export declare type FlowNodeKind = 'terminator' | 'process' | 'decision' | 'io';
9
+ /**
10
+ * 节点类型词汇表。
11
+ *
12
+ * - 流程图:`terminator` / `process` / `decision` / `io`
13
+ * - BPMN 2.0:`bpmnEvent` / `bpmnTask` / `bpmnGateway` / `bpmnSubprocess` /
14
+ * `bpmnDataObject` / `bpmnAnnotation` / `bpmnPool` / `bpmnLane`
15
+ *
16
+ * BPMN 复用同一套节点/连线/历史/快照机制(都是 `FlowNode`),语义差异由 `kind`
17
+ * 与 BPMN 专属属性(eventKind / trigger / gatewayType / taskType / band)承载,
18
+ * 因此文档、React 绑定、DSL 都不需要第二套实现。
19
+ */
20
+ export declare type FlowNodeKind = 'terminator' | 'process' | 'decision' | 'io' | 'bpmnEvent' | 'bpmnTask' | 'bpmnGateway' | 'bpmnSubprocess' | 'bpmnDataObject' | 'bpmnAnnotation' | 'bpmnPool' | 'bpmnLane';
11
21
  export declare type FlowNodePreset = {
12
22
  label: string;
13
23
  width: number;
@@ -15,7 +25,25 @@ export declare type FlowNodePreset = {
15
25
  fill: string;
16
26
  stroke: string;
17
27
  radius?: number;
18
- shape: 'rect' | 'diamond' | 'parallelogram';
28
+ shape: 'rect' | 'diamond' | 'parallelogram' | 'event' | 'gateway' | 'dataObject' | 'annotation' | 'lane';
29
+ /** 外框线宽(BPMN 结束事件用粗圈) */
30
+ lineWidth?: number;
31
+ /** 虚线(注释框) */
32
+ lineDash?: number[];
33
+ /** 名称带:泳道在左、池在顶 */
34
+ band?: 'left' | 'top';
35
+ bandSize?: number;
36
+ /** 标题摆放:居中(图元)或左上(池/泳道/注释) */
37
+ labelPlacement?: 'center' | 'top-left';
38
+ /** 背景透明(泳道用:相邻泳道共享边界时,填充会盖住邻居的边框) */
39
+ transparent?: boolean;
40
+ /** 默认的任务类型角标(bpmnTask 用) */
41
+ taskType?: string;
42
+ /** 默认事件种类 / 触发(bpmnEvent 用) */
43
+ eventKind?: string;
44
+ trigger?: string;
45
+ /** 默认网关类型(bpmnGateway 用) */
46
+ gatewayType?: string;
19
47
  };
20
48
  /** 各类型节点的默认尺寸与配色(同时作为属性面板的预设) */
21
49
  export declare const FLOW_NODE_KINDS: Record<FlowNodeKind, FlowNodePreset>;
@@ -31,6 +59,8 @@ export default class FlowNode extends ICEGroup {
31
59
  static readonly typeId = "FlowNode";
32
60
  protected shapeComponent: any;
33
61
  protected labelComponent: any;
62
+ /** BPMN 装饰件(任务角标 / 子流程标记),随形状一起重建 */
63
+ protected decorationComponents: any[];
34
64
  /**
35
65
  * 内部子组件(形状 + 标题)由 kind/尺寸/配色派生,构造函数会重建 →
36
66
  * 不参与引擎序列化(否则往返会重复挂载,且子组件 zIndex 抖动,见 ICEComponent.hasDerivedChildren)。
@@ -39,6 +69,13 @@ export default class FlowNode extends ICEGroup {
39
69
  constructor(props?: any);
40
70
  /** 按当前 kind / 尺寸 / 配色重建形状与标题(切换类型或改样式时调用) */
41
71
  private __buildShape;
72
+ /**
73
+ * BPMN 装饰件(任务类型角标、子流程折叠标记)。
74
+ *
75
+ * 它们与形状/标题一样由节点 state 派生,因此不需要单独序列化
76
+ * (见 hasDerivedChildren:整个内部子树都是派生的)。
77
+ */
78
+ private __buildDecorations;
42
79
  /** 改节点属性(标题 / 类型 / 配色 / 尺寸),必要时重建形状 */
43
80
  applyPatch(patch?: Record<string, any>): this;
44
81
  }
@@ -6,8 +6,18 @@
6
6
  *
7
7
  */
8
8
  import { ICEGroup } from '../ice-render/index';
9
- /** 流程图节点类型:起止 / 处理 / 判定 / 输入输出 */
10
- export declare type FlowNodeKind = 'terminator' | 'process' | 'decision' | 'io';
9
+ /**
10
+ * 节点类型词汇表。
11
+ *
12
+ * - 流程图:`terminator` / `process` / `decision` / `io`
13
+ * - BPMN 2.0:`bpmnEvent` / `bpmnTask` / `bpmnGateway` / `bpmnSubprocess` /
14
+ * `bpmnDataObject` / `bpmnAnnotation` / `bpmnPool` / `bpmnLane`
15
+ *
16
+ * BPMN 复用同一套节点/连线/历史/快照机制(都是 `FlowNode`),语义差异由 `kind`
17
+ * 与 BPMN 专属属性(eventKind / trigger / gatewayType / taskType / band)承载,
18
+ * 因此文档、React 绑定、DSL 都不需要第二套实现。
19
+ */
20
+ export declare type FlowNodeKind = 'terminator' | 'process' | 'decision' | 'io' | 'bpmnEvent' | 'bpmnTask' | 'bpmnGateway' | 'bpmnSubprocess' | 'bpmnDataObject' | 'bpmnAnnotation' | 'bpmnPool' | 'bpmnLane';
11
21
  export declare type FlowNodePreset = {
12
22
  label: string;
13
23
  width: number;
@@ -15,7 +25,25 @@ export declare type FlowNodePreset = {
15
25
  fill: string;
16
26
  stroke: string;
17
27
  radius?: number;
18
- shape: 'rect' | 'diamond' | 'parallelogram';
28
+ shape: 'rect' | 'diamond' | 'parallelogram' | 'event' | 'gateway' | 'dataObject' | 'annotation' | 'lane';
29
+ /** 外框线宽(BPMN 结束事件用粗圈) */
30
+ lineWidth?: number;
31
+ /** 虚线(注释框) */
32
+ lineDash?: number[];
33
+ /** 名称带:泳道在左、池在顶 */
34
+ band?: 'left' | 'top';
35
+ bandSize?: number;
36
+ /** 标题摆放:居中(图元)或左上(池/泳道/注释) */
37
+ labelPlacement?: 'center' | 'top-left';
38
+ /** 背景透明(泳道用:相邻泳道共享边界时,填充会盖住邻居的边框) */
39
+ transparent?: boolean;
40
+ /** 默认的任务类型角标(bpmnTask 用) */
41
+ taskType?: string;
42
+ /** 默认事件种类 / 触发(bpmnEvent 用) */
43
+ eventKind?: string;
44
+ trigger?: string;
45
+ /** 默认网关类型(bpmnGateway 用) */
46
+ gatewayType?: string;
19
47
  };
20
48
  /** 各类型节点的默认尺寸与配色(同时作为属性面板的预设) */
21
49
  export declare const FLOW_NODE_KINDS: Record<FlowNodeKind, FlowNodePreset>;
@@ -31,6 +59,8 @@ export default class FlowNode extends ICEGroup {
31
59
  static readonly typeId = "FlowNode";
32
60
  protected shapeComponent: any;
33
61
  protected labelComponent: any;
62
+ /** BPMN 装饰件(任务角标 / 子流程标记),随形状一起重建 */
63
+ protected decorationComponents: any[];
34
64
  /**
35
65
  * 内部子组件(形状 + 标题)由 kind/尺寸/配色派生,构造函数会重建 →
36
66
  * 不参与引擎序列化(否则往返会重复挂载,且子组件 zIndex 抖动,见 ICEComponent.hasDerivedChildren)。
@@ -39,6 +69,13 @@ export default class FlowNode extends ICEGroup {
39
69
  constructor(props?: any);
40
70
  /** 按当前 kind / 尺寸 / 配色重建形状与标题(切换类型或改样式时调用) */
41
71
  private __buildShape;
72
+ /**
73
+ * BPMN 装饰件(任务类型角标、子流程折叠标记)。
74
+ *
75
+ * 它们与形状/标题一样由节点 state 派生,因此不需要单独序列化
76
+ * (见 hasDerivedChildren:整个内部子树都是派生的)。
77
+ */
78
+ private __buildDecorations;
42
79
  /** 改节点属性(标题 / 类型 / 配色 / 尺寸),必要时重建形状 */
43
80
  applyPatch(patch?: Record<string, any>): this;
44
81
  }