ice-entity-designer 0.0.22 → 0.0.24
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 +85 -0
- package/dist/index.cjs +3 -3
- package/dist/index.mjs +3 -3
- package/dist/index.umd.js +3 -3
- package/dist/react.cjs +3 -3
- package/dist/react.mjs +3 -3
- package/dist/types/flow/FlowDesigner.d.mts +23 -5
- package/dist/types/flow/FlowDesigner.d.ts +23 -5
- package/dist/types/ice-render/ICE.d.mts +55 -0
- package/dist/types/ice-render/ICE.d.ts +55 -0
- package/dist/types/ice-render/cross-platform/Path2DRecorder.d.mts +76 -0
- package/dist/types/ice-render/cross-platform/Path2DRecorder.d.ts +76 -0
- package/dist/types/ice-render/cross-platform/PolyfillPath2D.d.mts +8 -18
- package/dist/types/ice-render/cross-platform/PolyfillPath2D.d.ts +8 -18
- package/dist/types/ice-render/event/DOMEventDispatcher.d.mts +9 -2
- package/dist/types/ice-render/event/DOMEventDispatcher.d.ts +9 -2
- package/dist/types/ice-render/export/SvgExporter.d.mts +54 -0
- package/dist/types/ice-render/export/SvgExporter.d.ts +54 -0
- package/dist/types/ice-render/graphic/ICEComponent.d.mts +31 -1
- package/dist/types/ice-render/graphic/ICEComponent.d.ts +31 -1
- package/dist/types/ice-render/graphic/ICEPath.d.mts +7 -0
- package/dist/types/ice-render/graphic/ICEPath.d.ts +7 -0
- package/dist/types/ice-render/graphic/link/ICEPolyLine.d.mts +17 -0
- package/dist/types/ice-render/graphic/link/ICEPolyLine.d.ts +17 -0
- package/dist/types/ice-render/graphic/text/ICEText.d.mts +21 -0
- package/dist/types/ice-render/graphic/text/ICEText.d.ts +21 -0
- package/dist/types/ice-render/index.d.mts +2 -0
- package/dist/types/ice-render/index.d.ts +2 -0
- package/dist/types/index.d.mts +8 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/uml/UmlClass.d.mts +46 -0
- package/dist/types/uml/UmlClass.d.ts +46 -0
- package/dist/types/uml/UmlDesigner.d.mts +53 -0
- package/dist/types/uml/UmlDesigner.d.ts +53 -0
- package/dist/types/uml/UmlRelation.d.mts +63 -0
- package/dist/types/uml/UmlRelation.d.ts +63 -0
- package/dist/types/uml/uml_text.d.mts +33 -0
- package/dist/types/uml/uml_text.d.ts +33 -0
- package/package.json +1 -1
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file SVG 导出
|
|
3
|
+
*
|
|
4
|
+
* 引擎的渲染是 canvas 光栅化的,但**几何描述一直都在**:`Path2DRecorder` 让每个路径组件都持有
|
|
5
|
+
* 自己的命令流(见 cross-platform/Path2DRecorder.ts),于是同一份场景可以再输出一份矢量。
|
|
6
|
+
*
|
|
7
|
+
* 导出器刻意**镜像渲染器的口径**,而不是另起一套:
|
|
8
|
+
* - 绘制顺序 = 渲染队列的顺序(`flattenTree` 后按 `state.zIndex` 稳定排序),工具层默认不导出;
|
|
9
|
+
* - 每个组件的变换 = `composeMatrix()`(本地 → 世界),整体再套一层「世界 → 视图」矩阵,
|
|
10
|
+
* 与 `applyTransformToCtx()` 的 `viewport · composed` 完全对应;
|
|
11
|
+
* - 填充/描边 = `state.fill` / `state.stroke` + `props.style` 与 `state.style` 合并后的键
|
|
12
|
+
* (state 覆盖 props,与 `applyStyleToCtx()` 同序);
|
|
13
|
+
* - 透明度 = `getEffectiveOpacity()`(自身 × 祖先),与画布的 `globalAlpha` 同一口径;
|
|
14
|
+
* - 裁剪 = 祖先链上所有 `clipChildren` 的世界包围盒,与 `__applyAncestorClips()` 一致。
|
|
15
|
+
*
|
|
16
|
+
* 已支持:任意 `ICEPath` 家族(矩形/圆角矩形/椭圆/自定义形状/折线/贝塞尔/组自身背景)、
|
|
17
|
+
* 文本(多行、水平/垂直对齐、换行后的行)、图片(含圆形裁剪)、线性/径向渐变、虚线、
|
|
18
|
+
* 视口或内容自适应尺寸、透明背景。
|
|
19
|
+
*
|
|
20
|
+
* 暂未支持(有意留白,都会在文档里写明):
|
|
21
|
+
* - 阴影(canvas 的 shadow* → SVG 需要 filter,且模糊半径语义不完全等价);
|
|
22
|
+
* - 雪碧图切图(`sx/sy/sw/sh`)与 `fillRule` 的奇偶填充差异;
|
|
23
|
+
* - 蚂蚁线动画(导出的是**静态瞬间**,只保留当前 dash 相位)。
|
|
24
|
+
*
|
|
25
|
+
* 文本的**字形度量**在 canvas 与 SVG 之间不可能逐像素一致(字体回退、行高、基线定义不同),
|
|
26
|
+
* 因此导出器用 `text-anchor` / `dominant-baseline` 表达对齐,而不是把测出来的宽度写死;
|
|
27
|
+
* 左对齐(默认)与画布逐字对齐,居中/右对齐按锚点对齐、宽度由渲染方自己定。
|
|
28
|
+
*/
|
|
29
|
+
export type SvgExportOptions = {
|
|
30
|
+
/** 导出范围:`content`(默认,按内容包围盒紧凑裁切)或 `viewport`(当前画布视口) */
|
|
31
|
+
area?: 'content' | 'viewport';
|
|
32
|
+
/** `area: 'content'` 时的四周留白,默认 0 */
|
|
33
|
+
padding?: number;
|
|
34
|
+
/** 缩放倍数,默认 1(内容模式下按世界尺寸 1:1) */
|
|
35
|
+
scale?: number;
|
|
36
|
+
/** 背景色;默认不铺背景(透明) */
|
|
37
|
+
background?: string | null;
|
|
38
|
+
/** 是否把工具层(控制面板、对齐辅助线)也导出,默认 false */
|
|
39
|
+
includeTools?: boolean;
|
|
40
|
+
/** 坐标保留小数位,默认 2(避免 `d` 属性里出现一长串浮点噪声) */
|
|
41
|
+
precision?: number;
|
|
42
|
+
};
|
|
43
|
+
export type SvgExportResult = {
|
|
44
|
+
svg: string;
|
|
45
|
+
width: number;
|
|
46
|
+
height: number;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* 导出场景为 SVG 字符串。
|
|
50
|
+
*
|
|
51
|
+
* @param target ICE 实例(导出整幅画布)或任意组件(导出它的子树)
|
|
52
|
+
*/
|
|
53
|
+
export declare function exportSvg(target: any, options?: SvgExportOptions): string;
|
|
54
|
+
export declare function exportSvgResult(target: any, options?: SvgExportOptions): SvgExportResult;
|
|
@@ -10,6 +10,30 @@ import EventBus from '../event/EventBus.mjs';
|
|
|
10
10
|
import ICEEventTarget from '../event/ICEEventTarget.mjs';
|
|
11
11
|
import ICEBoundingBox from '../geometry/ICEBoundingBox.mjs';
|
|
12
12
|
import ICE from '../ICE.mjs';
|
|
13
|
+
/**
|
|
14
|
+
* 阴影简写预设:style.shadow: 'sm' | 'md' | 'lg' 一行搞定浮起效果,
|
|
15
|
+
* 对应展开为 shadowColor / shadowBlur / shadowOffsetX / shadowOffsetY。
|
|
16
|
+
*/
|
|
17
|
+
export declare const SHADOW_PRESETS: {
|
|
18
|
+
sm: {
|
|
19
|
+
shadowColor: string;
|
|
20
|
+
shadowBlur: number;
|
|
21
|
+
shadowOffsetX: number;
|
|
22
|
+
shadowOffsetY: number;
|
|
23
|
+
};
|
|
24
|
+
md: {
|
|
25
|
+
shadowColor: string;
|
|
26
|
+
shadowBlur: number;
|
|
27
|
+
shadowOffsetX: number;
|
|
28
|
+
shadowOffsetY: number;
|
|
29
|
+
};
|
|
30
|
+
lg: {
|
|
31
|
+
shadowColor: string;
|
|
32
|
+
shadowBlur: number;
|
|
33
|
+
shadowOffsetX: number;
|
|
34
|
+
shadowOffsetY: number;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
13
37
|
declare abstract class ICEComponent extends ICEEventTarget {
|
|
14
38
|
ice: ICE;
|
|
15
39
|
root: any;
|
|
@@ -298,7 +322,13 @@ declare abstract class ICEComponent extends ICEEventTarget {
|
|
|
298
322
|
*
|
|
299
323
|
* 顶层组件直接返回(绝大多数组件没有祖先,热路径上不做遍历);非法值按 1 处理。
|
|
300
324
|
*/
|
|
301
|
-
|
|
325
|
+
/**
|
|
326
|
+
* 有效不透明度 = 自身 `state.opacity` × 所有祖先的 `state.opacity`(默认 1)。
|
|
327
|
+
*
|
|
328
|
+
* 渲染把相乘的结果叠到 `ctx.globalAlpha` 上(祖先的 opacity 不会自动继承,组件是逐个绘制的)。
|
|
329
|
+
* 公开出来是因为**离屏与 SVG 导出必须用同一口径**,否则导出的图会比画布亮/暗一截。
|
|
330
|
+
*/
|
|
331
|
+
getEffectiveOpacity(): number;
|
|
302
332
|
/**
|
|
303
333
|
* 世界坐标点是否落在某个「裁剪祖先」的盒子之外。
|
|
304
334
|
*
|
|
@@ -10,6 +10,30 @@ import EventBus from '../event/EventBus';
|
|
|
10
10
|
import ICEEventTarget from '../event/ICEEventTarget';
|
|
11
11
|
import ICEBoundingBox from '../geometry/ICEBoundingBox';
|
|
12
12
|
import ICE from '../ICE';
|
|
13
|
+
/**
|
|
14
|
+
* 阴影简写预设:style.shadow: 'sm' | 'md' | 'lg' 一行搞定浮起效果,
|
|
15
|
+
* 对应展开为 shadowColor / shadowBlur / shadowOffsetX / shadowOffsetY。
|
|
16
|
+
*/
|
|
17
|
+
export declare const SHADOW_PRESETS: {
|
|
18
|
+
sm: {
|
|
19
|
+
shadowColor: string;
|
|
20
|
+
shadowBlur: number;
|
|
21
|
+
shadowOffsetX: number;
|
|
22
|
+
shadowOffsetY: number;
|
|
23
|
+
};
|
|
24
|
+
md: {
|
|
25
|
+
shadowColor: string;
|
|
26
|
+
shadowBlur: number;
|
|
27
|
+
shadowOffsetX: number;
|
|
28
|
+
shadowOffsetY: number;
|
|
29
|
+
};
|
|
30
|
+
lg: {
|
|
31
|
+
shadowColor: string;
|
|
32
|
+
shadowBlur: number;
|
|
33
|
+
shadowOffsetX: number;
|
|
34
|
+
shadowOffsetY: number;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
13
37
|
declare abstract class ICEComponent extends ICEEventTarget {
|
|
14
38
|
ice: ICE;
|
|
15
39
|
root: any;
|
|
@@ -298,7 +322,13 @@ declare abstract class ICEComponent extends ICEEventTarget {
|
|
|
298
322
|
*
|
|
299
323
|
* 顶层组件直接返回(绝大多数组件没有祖先,热路径上不做遍历);非法值按 1 处理。
|
|
300
324
|
*/
|
|
301
|
-
|
|
325
|
+
/**
|
|
326
|
+
* 有效不透明度 = 自身 `state.opacity` × 所有祖先的 `state.opacity`(默认 1)。
|
|
327
|
+
*
|
|
328
|
+
* 渲染把相乘的结果叠到 `ctx.globalAlpha` 上(祖先的 opacity 不会自动继承,组件是逐个绘制的)。
|
|
329
|
+
* 公开出来是因为**离屏与 SVG 导出必须用同一口径**,否则导出的图会比画布亮/暗一截。
|
|
330
|
+
*/
|
|
331
|
+
getEffectiveOpacity(): number;
|
|
302
332
|
/**
|
|
303
333
|
* 世界坐标点是否落在某个「裁剪祖先」的盒子之外。
|
|
304
334
|
*
|
|
@@ -6,6 +6,13 @@ import ICEComponent from './ICEComponent.mjs';
|
|
|
6
6
|
*/
|
|
7
7
|
declare abstract class ICEPath extends ICEComponent {
|
|
8
8
|
path2D: any;
|
|
9
|
+
/**
|
|
10
|
+
* 确保路径命令流是最新的。
|
|
11
|
+
*
|
|
12
|
+
* 画布通道里由 `doRender()` 在 dirty 时重建;但**导出 / 服务端出图没有渲染循环**
|
|
13
|
+
* (Node 里连 canvas 都没有),此时必须显式建一次,否则命令流是空的、导出出来一片空白。
|
|
14
|
+
*/
|
|
15
|
+
ensurePathBuilt(): void;
|
|
9
16
|
/**
|
|
10
17
|
* @cfg
|
|
11
18
|
* {
|
|
@@ -6,6 +6,13 @@ import ICEComponent from './ICEComponent';
|
|
|
6
6
|
*/
|
|
7
7
|
declare abstract class ICEPath extends ICEComponent {
|
|
8
8
|
path2D: any;
|
|
9
|
+
/**
|
|
10
|
+
* 确保路径命令流是最新的。
|
|
11
|
+
*
|
|
12
|
+
* 画布通道里由 `doRender()` 在 dirty 时重建;但**导出 / 服务端出图没有渲染循环**
|
|
13
|
+
* (Node 里连 canvas 都没有),此时必须显式建一次,否则命令流是空的、导出出来一片空白。
|
|
14
|
+
*/
|
|
15
|
+
ensurePathBuilt(): void;
|
|
9
16
|
/**
|
|
10
17
|
* @cfg
|
|
11
18
|
* {
|
|
@@ -251,6 +251,23 @@ declare class ICEPolyLine extends ICEDotPath {
|
|
|
251
251
|
* `__measureLabelBoxForBounds()`(盒子计算不应留下渲染副作用)。
|
|
252
252
|
*/
|
|
253
253
|
private __labelMetrics;
|
|
254
|
+
/**
|
|
255
|
+
* 连线标签的**渲染信息**(公开口径):位置、尺寸、字体与配色。
|
|
256
|
+
*
|
|
257
|
+
* 与 `drawLabel()` / `__labelMetrics()` 同源 —— 画布怎么画,导出(SVG)就怎么描述。
|
|
258
|
+
* 连线标签是画布 `fillText` 出来的,不像节点标题那样是独立的 ICEText 子组件,
|
|
259
|
+
* 所以导出器必须显式问它,否则「是/否」「条件」这类标签会在导出里凭空消失。
|
|
260
|
+
*/
|
|
261
|
+
getLabelRenderInfo(): {
|
|
262
|
+
text: string;
|
|
263
|
+
x: number;
|
|
264
|
+
y: number;
|
|
265
|
+
halfW: number;
|
|
266
|
+
halfH: number;
|
|
267
|
+
fontSize: number;
|
|
268
|
+
fillStyle: string;
|
|
269
|
+
backgroundColor: string;
|
|
270
|
+
} | null;
|
|
254
271
|
/** `__localBox()` 专用包装:算完把 `ctx.font` 恢复 —— 盒子计算不该改变渲染状态。 */
|
|
255
272
|
private __measureLabelBoxForBounds;
|
|
256
273
|
/**
|
|
@@ -251,6 +251,23 @@ declare class ICEPolyLine extends ICEDotPath {
|
|
|
251
251
|
* `__measureLabelBoxForBounds()`(盒子计算不应留下渲染副作用)。
|
|
252
252
|
*/
|
|
253
253
|
private __labelMetrics;
|
|
254
|
+
/**
|
|
255
|
+
* 连线标签的**渲染信息**(公开口径):位置、尺寸、字体与配色。
|
|
256
|
+
*
|
|
257
|
+
* 与 `drawLabel()` / `__labelMetrics()` 同源 —— 画布怎么画,导出(SVG)就怎么描述。
|
|
258
|
+
* 连线标签是画布 `fillText` 出来的,不像节点标题那样是独立的 ICEText 子组件,
|
|
259
|
+
* 所以导出器必须显式问它,否则「是/否」「条件」这类标签会在导出里凭空消失。
|
|
260
|
+
*/
|
|
261
|
+
getLabelRenderInfo(): {
|
|
262
|
+
text: string;
|
|
263
|
+
x: number;
|
|
264
|
+
y: number;
|
|
265
|
+
halfW: number;
|
|
266
|
+
halfH: number;
|
|
267
|
+
fontSize: number;
|
|
268
|
+
fillStyle: string;
|
|
269
|
+
backgroundColor: string;
|
|
270
|
+
} | null;
|
|
254
271
|
/** `__localBox()` 专用包装:算完把 `ctx.font` 恢复 —— 盒子计算不该改变渲染状态。 */
|
|
255
272
|
private __measureLabelBoxForBounds;
|
|
256
273
|
/**
|
|
@@ -91,6 +91,15 @@ declare class ICEText extends ICEComponent {
|
|
|
91
91
|
width: any;
|
|
92
92
|
height: any;
|
|
93
93
|
};
|
|
94
|
+
/**
|
|
95
|
+
* 多行文本的行距系数。
|
|
96
|
+
*
|
|
97
|
+
* 为什么不能直接用 `actualBoundingBoxAscent + Descent`(字形墨迹高度)当行距:
|
|
98
|
+
* 墨迹只覆盖「有笔画的部分」,拉丁字母的 cap-height 比 em 小得多 —— 14px Tahoma 的
|
|
99
|
+
* 墨迹高 ≈ 12px,拿它当行距时中文(墨迹接近满 em)会**上下叠在一起**,看起来像文字被压扁。
|
|
100
|
+
* 按字号 × 1.35 取行距更接近系统的自然行高,同时保证 ≥ 墨迹高度(不会挤)。
|
|
101
|
+
*/
|
|
102
|
+
private static readonly LINE_HEIGHT_RATIO;
|
|
94
103
|
/**
|
|
95
104
|
* @method measureText
|
|
96
105
|
*
|
|
@@ -126,6 +135,18 @@ declare class ICEText extends ICEComponent {
|
|
|
126
135
|
private __applyMeasuredSize;
|
|
127
136
|
/** DOM 降级测量:line-height 归一为 1,减少 leading 干扰(旧环境/小程序)。 */
|
|
128
137
|
private __measureByDOM;
|
|
138
|
+
/**
|
|
139
|
+
* 文本的**渲染行布局**:每一行的内容与基线坐标(组件本地坐标)。
|
|
140
|
+
*
|
|
141
|
+
* 画布渲染与 SVG 导出共用这一份口径 —— 两处各算一遍必然漂移(改了对齐公式忘了另一处,
|
|
142
|
+
* 表现为「导出的文字整体偏移」)。返回的 `x` 是**文字左边缘**(左/居中/右对齐都按画布公式算好),
|
|
143
|
+
* `y` 是 baseline 位置。
|
|
144
|
+
*/
|
|
145
|
+
getRenderLines(): Array<{
|
|
146
|
+
text: string;
|
|
147
|
+
x: number;
|
|
148
|
+
y: number;
|
|
149
|
+
}>;
|
|
129
150
|
/**
|
|
130
151
|
* @method doRender
|
|
131
152
|
* @overwrite
|
|
@@ -91,6 +91,15 @@ declare class ICEText extends ICEComponent {
|
|
|
91
91
|
width: any;
|
|
92
92
|
height: any;
|
|
93
93
|
};
|
|
94
|
+
/**
|
|
95
|
+
* 多行文本的行距系数。
|
|
96
|
+
*
|
|
97
|
+
* 为什么不能直接用 `actualBoundingBoxAscent + Descent`(字形墨迹高度)当行距:
|
|
98
|
+
* 墨迹只覆盖「有笔画的部分」,拉丁字母的 cap-height 比 em 小得多 —— 14px Tahoma 的
|
|
99
|
+
* 墨迹高 ≈ 12px,拿它当行距时中文(墨迹接近满 em)会**上下叠在一起**,看起来像文字被压扁。
|
|
100
|
+
* 按字号 × 1.35 取行距更接近系统的自然行高,同时保证 ≥ 墨迹高度(不会挤)。
|
|
101
|
+
*/
|
|
102
|
+
private static readonly LINE_HEIGHT_RATIO;
|
|
94
103
|
/**
|
|
95
104
|
* @method measureText
|
|
96
105
|
*
|
|
@@ -126,6 +135,18 @@ declare class ICEText extends ICEComponent {
|
|
|
126
135
|
private __applyMeasuredSize;
|
|
127
136
|
/** DOM 降级测量:line-height 归一为 1,减少 leading 干扰(旧环境/小程序)。 */
|
|
128
137
|
private __measureByDOM;
|
|
138
|
+
/**
|
|
139
|
+
* 文本的**渲染行布局**:每一行的内容与基线坐标(组件本地坐标)。
|
|
140
|
+
*
|
|
141
|
+
* 画布渲染与 SVG 导出共用这一份口径 —— 两处各算一遍必然漂移(改了对齐公式忘了另一处,
|
|
142
|
+
* 表现为「导出的文字整体偏移」)。返回的 `x` 是**文字左边缘**(左/居中/右对齐都按画布公式算好),
|
|
143
|
+
* `y` 是 baseline 位置。
|
|
144
|
+
*/
|
|
145
|
+
getRenderLines(): Array<{
|
|
146
|
+
text: string;
|
|
147
|
+
x: number;
|
|
148
|
+
y: number;
|
|
149
|
+
}>;
|
|
129
150
|
/**
|
|
130
151
|
* @method doRender
|
|
131
152
|
* @overwrite
|
|
@@ -49,6 +49,8 @@ export { default as ICELayeredLayout } from './layout/ICELayeredLayout.mjs';
|
|
|
49
49
|
export { default as ICETheme, baseTokens, DEFAULT_THEME, DARK_THEME, registerTheme, setTheme, getTheme, STYLE_PRESETS, } from './theme/ICETheme.mjs';
|
|
50
50
|
export { default as ICE } from './ICE.mjs';
|
|
51
51
|
export { default as CanvasRenderer } from './renderer/CanvasRenderer.mjs';
|
|
52
|
+
export { exportSvg, exportSvgResult } from './export/SvgExporter.mjs';
|
|
53
|
+
export type { SvgExportOptions, SvgExportResult } from './export/SvgExporter.mjs';
|
|
52
54
|
export { default as PluginHost } from './plugin/PluginHost.mjs';
|
|
53
55
|
export type { ICEPlugin, ICEPluginTool, ICERenderHook, ICERenderFrame } from './plugin/PluginHost.mjs';
|
|
54
56
|
export { default as Serializer, SERIALIZATION_VERSION } from './persistence/Serializer.mjs';
|
|
@@ -49,6 +49,8 @@ export { default as ICELayeredLayout } from './layout/ICELayeredLayout';
|
|
|
49
49
|
export { default as ICETheme, baseTokens, DEFAULT_THEME, DARK_THEME, registerTheme, setTheme, getTheme, STYLE_PRESETS, } from './theme/ICETheme';
|
|
50
50
|
export { default as ICE } from './ICE';
|
|
51
51
|
export { default as CanvasRenderer } from './renderer/CanvasRenderer';
|
|
52
|
+
export { exportSvg, exportSvgResult } from './export/SvgExporter';
|
|
53
|
+
export type { SvgExportOptions, SvgExportResult } from './export/SvgExporter';
|
|
52
54
|
export { default as PluginHost } from './plugin/PluginHost';
|
|
53
55
|
export type { ICEPlugin, ICEPluginTool, ICERenderHook, ICERenderFrame } from './plugin/PluginHost';
|
|
54
56
|
export { default as Serializer, SERIALIZATION_VERSION } from './persistence/Serializer';
|
package/dist/types/index.d.mts
CHANGED
|
@@ -25,6 +25,14 @@ export { validateBpmn } from './bpmn/bpmn_validate.mjs';
|
|
|
25
25
|
export type { BpmnIssue } from './bpmn/bpmn_validate.mjs';
|
|
26
26
|
export { toBpmnXml, fromBpmnXml } from './bpmn/bpmn_xml.mjs';
|
|
27
27
|
export type { BpmnImportResult } from './bpmn/bpmn_xml.mjs';
|
|
28
|
+
export { default as UmlClass } from './uml/UmlClass.mjs';
|
|
29
|
+
export type { UmlClassKind } from './uml/UmlClass.mjs';
|
|
30
|
+
export { default as UmlRelation, UML_RELATION_KINDS, UML_RELATION_STYLE } from './uml/UmlRelation.mjs';
|
|
31
|
+
export type { UmlRelationKind, UmlMarker } from './uml/UmlRelation.mjs';
|
|
32
|
+
export { default as UmlDesigner } from './uml/UmlDesigner.mjs';
|
|
33
|
+
export type { UmlIssue } from './uml/UmlDesigner.mjs';
|
|
34
|
+
export { toPlantUml, fromPlantUml, arrowOf, detectUmlDialect } from './uml/uml_text.mjs';
|
|
35
|
+
export type { UmlTextImportResult } from './uml/uml_text.mjs';
|
|
28
36
|
/**
|
|
29
37
|
* 引擎内核(ice-render)在构建时已被打包进本包,这里一并导出。
|
|
30
38
|
*
|
package/dist/types/index.d.ts
CHANGED
|
@@ -25,6 +25,14 @@ export { validateBpmn } from './bpmn/bpmn_validate';
|
|
|
25
25
|
export type { BpmnIssue } from './bpmn/bpmn_validate';
|
|
26
26
|
export { toBpmnXml, fromBpmnXml } from './bpmn/bpmn_xml';
|
|
27
27
|
export type { BpmnImportResult } from './bpmn/bpmn_xml';
|
|
28
|
+
export { default as UmlClass } from './uml/UmlClass';
|
|
29
|
+
export type { UmlClassKind } from './uml/UmlClass';
|
|
30
|
+
export { default as UmlRelation, UML_RELATION_KINDS, UML_RELATION_STYLE } from './uml/UmlRelation';
|
|
31
|
+
export type { UmlRelationKind, UmlMarker } from './uml/UmlRelation';
|
|
32
|
+
export { default as UmlDesigner } from './uml/UmlDesigner';
|
|
33
|
+
export type { UmlIssue } from './uml/UmlDesigner';
|
|
34
|
+
export { toPlantUml, fromPlantUml, arrowOf, detectUmlDialect } from './uml/uml_text';
|
|
35
|
+
export type { UmlTextImportResult } from './uml/uml_text';
|
|
28
36
|
/**
|
|
29
37
|
* 引擎内核(ice-render)在构建时已被打包进本包,这里一并导出。
|
|
30
38
|
*
|
|
@@ -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
|
+
import { ICEGroup, ICEPolyLine, ICERect, ICEText } from '../ice-render/index.mjs';
|
|
9
|
+
export declare type UmlClassKind = 'class' | 'interface' | 'enum';
|
|
10
|
+
/**
|
|
11
|
+
* @class UmlClass UML 类图的类框(三段式:类名 / 属性 / 方法)
|
|
12
|
+
*
|
|
13
|
+
* 与 ER 的 `Entity` 同一套做法:**复合组件** —— 类名、属性、方法、分隔线都是按 state
|
|
14
|
+
* 派生的内部子组件(`hasDerivedChildren() === true`),不写进文档、载入时重建。
|
|
15
|
+
*
|
|
16
|
+
* 与 Entity 的三点差异(这也是它值得单独做域包的原因):
|
|
17
|
+
* - 三段式:类名带(含构造型)+ 属性区 + 方法区,分隔线两条;
|
|
18
|
+
* - 成员是**自由文本**(`- id: string`、`+ pay(): void`),可见性/静态/泛型都由文本表达 ——
|
|
19
|
+
* 这是 UML 工具与文本格式(PlantUML/Mermaid)通行的做法,也让 AI 生成不必学一套结构化语法;
|
|
20
|
+
* - **高度随成员自动增长**,不允许成员画出框外。
|
|
21
|
+
*/
|
|
22
|
+
export default class UmlClass extends ICEGroup {
|
|
23
|
+
/** 稳定类型标识(判型/序列化都用它,不要用 constructor.name:打包会被 mangle) */
|
|
24
|
+
static readonly typeId = "UmlClass";
|
|
25
|
+
protected stereotypeComponent: ICEText | null;
|
|
26
|
+
protected nameComponent: ICEText | null;
|
|
27
|
+
protected headerBackgroundComponent: ICERect | null;
|
|
28
|
+
protected memberComponents: ICEText[];
|
|
29
|
+
protected dividerComponents: ICEPolyLine[];
|
|
30
|
+
/** 内部子组件由 state 派生 → 不参与序列化 */
|
|
31
|
+
hasDerivedChildren(): boolean;
|
|
32
|
+
constructor(props?: any);
|
|
33
|
+
protected static arrangeParam(props: any): any;
|
|
34
|
+
/** 只需要重建内部排版的 state 键(拖动位置不该触发重建) */
|
|
35
|
+
private static readonly __layoutKeys;
|
|
36
|
+
setState(patch: any): void;
|
|
37
|
+
/** 应用层(属性面板 / DSL)改成员走这里,语义与 FlowNode.applyPatch 一致 */
|
|
38
|
+
applyPatch(patch?: any): void;
|
|
39
|
+
/**
|
|
40
|
+
* 按 state 重建三段式排版,并把**内容高度**写回自身(成员不会被画出框外)。
|
|
41
|
+
*
|
|
42
|
+
* 高度用 `this.state.height = h` 直接写:`setState()` 会再次触发重建,形成循环。
|
|
43
|
+
*/
|
|
44
|
+
protected syncCompartments(): void;
|
|
45
|
+
private __clearDerivedChildren;
|
|
46
|
+
}
|
|
@@ -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
|
+
import { ICEGroup, ICEPolyLine, ICERect, ICEText } from '../ice-render/index';
|
|
9
|
+
export declare type UmlClassKind = 'class' | 'interface' | 'enum';
|
|
10
|
+
/**
|
|
11
|
+
* @class UmlClass UML 类图的类框(三段式:类名 / 属性 / 方法)
|
|
12
|
+
*
|
|
13
|
+
* 与 ER 的 `Entity` 同一套做法:**复合组件** —— 类名、属性、方法、分隔线都是按 state
|
|
14
|
+
* 派生的内部子组件(`hasDerivedChildren() === true`),不写进文档、载入时重建。
|
|
15
|
+
*
|
|
16
|
+
* 与 Entity 的三点差异(这也是它值得单独做域包的原因):
|
|
17
|
+
* - 三段式:类名带(含构造型)+ 属性区 + 方法区,分隔线两条;
|
|
18
|
+
* - 成员是**自由文本**(`- id: string`、`+ pay(): void`),可见性/静态/泛型都由文本表达 ——
|
|
19
|
+
* 这是 UML 工具与文本格式(PlantUML/Mermaid)通行的做法,也让 AI 生成不必学一套结构化语法;
|
|
20
|
+
* - **高度随成员自动增长**,不允许成员画出框外。
|
|
21
|
+
*/
|
|
22
|
+
export default class UmlClass extends ICEGroup {
|
|
23
|
+
/** 稳定类型标识(判型/序列化都用它,不要用 constructor.name:打包会被 mangle) */
|
|
24
|
+
static readonly typeId = "UmlClass";
|
|
25
|
+
protected stereotypeComponent: ICEText | null;
|
|
26
|
+
protected nameComponent: ICEText | null;
|
|
27
|
+
protected headerBackgroundComponent: ICERect | null;
|
|
28
|
+
protected memberComponents: ICEText[];
|
|
29
|
+
protected dividerComponents: ICEPolyLine[];
|
|
30
|
+
/** 内部子组件由 state 派生 → 不参与序列化 */
|
|
31
|
+
hasDerivedChildren(): boolean;
|
|
32
|
+
constructor(props?: any);
|
|
33
|
+
protected static arrangeParam(props: any): any;
|
|
34
|
+
/** 只需要重建内部排版的 state 键(拖动位置不该触发重建) */
|
|
35
|
+
private static readonly __layoutKeys;
|
|
36
|
+
setState(patch: any): void;
|
|
37
|
+
/** 应用层(属性面板 / DSL)改成员走这里,语义与 FlowNode.applyPatch 一致 */
|
|
38
|
+
applyPatch(patch?: any): void;
|
|
39
|
+
/**
|
|
40
|
+
* 按 state 重建三段式排版,并把**内容高度**写回自身(成员不会被画出框外)。
|
|
41
|
+
*
|
|
42
|
+
* 高度用 `this.state.height = h` 直接写:`setState()` 会再次触发重建,形成循环。
|
|
43
|
+
*/
|
|
44
|
+
protected syncCompartments(): void;
|
|
45
|
+
private __clearDerivedChildren;
|
|
46
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
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 { UmlRelationKind } from './UmlRelation.mjs';
|
|
10
|
+
export declare type UmlIssue = {
|
|
11
|
+
level: 'error' | 'warning';
|
|
12
|
+
message: string;
|
|
13
|
+
id?: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* @class UmlDesigner UML 类图设计器(域包 = 形状 + 应用层 + 校验 + 互操作 + 文档)
|
|
17
|
+
*
|
|
18
|
+
* 它是 `FlowDesigner` 的**薄扩展**,只做四件事,其余(选择、增删改、连线、撤销重做、
|
|
19
|
+
* 快照存取、适应视图、订阅)全部继承:
|
|
20
|
+
*
|
|
21
|
+
* 1. 建 UML 图元(`UmlClass` / `UmlRelation`)而不是流程图的 FlowNode/FlowEdge;
|
|
22
|
+
* 2. 节点/连线的**类型过滤**换成 UML 类型;
|
|
23
|
+
* 3. UML **语义校验**(重名类、悬空关系、继承环)。
|
|
24
|
+
*
|
|
25
|
+
* 之所以能这么薄:类框是复合组件(内部三段由 state 派生),关系是折线(标记进路径点集),
|
|
26
|
+
* 快照直接复用引擎序列化(typeId 注册表 + hasDerivedChildren)。
|
|
27
|
+
*/
|
|
28
|
+
export default class UmlDesigner extends FlowDesigner {
|
|
29
|
+
constructor(ice: any);
|
|
30
|
+
/** 只认 UML 类框(继承来的 FlowNode 过滤换掉) */
|
|
31
|
+
get nodes(): any[];
|
|
32
|
+
/** 只认 UML 关系线 */
|
|
33
|
+
get edges(): any[];
|
|
34
|
+
/** 建一个类/接口/枚举(`createNode` 的 UML 语义版本) */
|
|
35
|
+
createClass(props?: any): any;
|
|
36
|
+
/** 建一条 UML 关系(继承 / 实现 / 关联 / 聚合 / 组合 / 依赖) */
|
|
37
|
+
createRelation(props?: any): any;
|
|
38
|
+
/** 改关系种类:记法(线型 + 端点标记 + 填充)随之一并更新 */
|
|
39
|
+
setRelationKind(id: string, relationKind: UmlRelationKind): any;
|
|
40
|
+
/** 关系种类清单(属性面板/DSL 共用同一份词汇表) */
|
|
41
|
+
get relationKinds(): string[];
|
|
42
|
+
/**
|
|
43
|
+
* UML 语义校验(结构之外的部分):
|
|
44
|
+
* - 类名重复(同一张图里两个类无法区分);
|
|
45
|
+
* - 关系两端必须都还在(删除类时引擎会级联删关系,这里是防御性的);
|
|
46
|
+
* - 继承/实现的**成环**(A 继承 B、B 又继承 A —— 类型系统不成立)。
|
|
47
|
+
*/
|
|
48
|
+
validateUml(): UmlIssue[];
|
|
49
|
+
/** 关系记法的可读描述(属性面板/文档共用,避免三处各写一份文案) */
|
|
50
|
+
static describeRelationKind(kind: UmlRelationKind): string;
|
|
51
|
+
/** 端口点:与 FlowDesigner 的插槽语义一致(T/R/B/L/C),这里按 UML 常用左右出发 */
|
|
52
|
+
private __portPoint;
|
|
53
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
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 { UmlRelationKind } from './UmlRelation';
|
|
10
|
+
export declare type UmlIssue = {
|
|
11
|
+
level: 'error' | 'warning';
|
|
12
|
+
message: string;
|
|
13
|
+
id?: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* @class UmlDesigner UML 类图设计器(域包 = 形状 + 应用层 + 校验 + 互操作 + 文档)
|
|
17
|
+
*
|
|
18
|
+
* 它是 `FlowDesigner` 的**薄扩展**,只做四件事,其余(选择、增删改、连线、撤销重做、
|
|
19
|
+
* 快照存取、适应视图、订阅)全部继承:
|
|
20
|
+
*
|
|
21
|
+
* 1. 建 UML 图元(`UmlClass` / `UmlRelation`)而不是流程图的 FlowNode/FlowEdge;
|
|
22
|
+
* 2. 节点/连线的**类型过滤**换成 UML 类型;
|
|
23
|
+
* 3. UML **语义校验**(重名类、悬空关系、继承环)。
|
|
24
|
+
*
|
|
25
|
+
* 之所以能这么薄:类框是复合组件(内部三段由 state 派生),关系是折线(标记进路径点集),
|
|
26
|
+
* 快照直接复用引擎序列化(typeId 注册表 + hasDerivedChildren)。
|
|
27
|
+
*/
|
|
28
|
+
export default class UmlDesigner extends FlowDesigner {
|
|
29
|
+
constructor(ice: any);
|
|
30
|
+
/** 只认 UML 类框(继承来的 FlowNode 过滤换掉) */
|
|
31
|
+
get nodes(): any[];
|
|
32
|
+
/** 只认 UML 关系线 */
|
|
33
|
+
get edges(): any[];
|
|
34
|
+
/** 建一个类/接口/枚举(`createNode` 的 UML 语义版本) */
|
|
35
|
+
createClass(props?: any): any;
|
|
36
|
+
/** 建一条 UML 关系(继承 / 实现 / 关联 / 聚合 / 组合 / 依赖) */
|
|
37
|
+
createRelation(props?: any): any;
|
|
38
|
+
/** 改关系种类:记法(线型 + 端点标记 + 填充)随之一并更新 */
|
|
39
|
+
setRelationKind(id: string, relationKind: UmlRelationKind): any;
|
|
40
|
+
/** 关系种类清单(属性面板/DSL 共用同一份词汇表) */
|
|
41
|
+
get relationKinds(): string[];
|
|
42
|
+
/**
|
|
43
|
+
* UML 语义校验(结构之外的部分):
|
|
44
|
+
* - 类名重复(同一张图里两个类无法区分);
|
|
45
|
+
* - 关系两端必须都还在(删除类时引擎会级联删关系,这里是防御性的);
|
|
46
|
+
* - 继承/实现的**成环**(A 继承 B、B 又继承 A —— 类型系统不成立)。
|
|
47
|
+
*/
|
|
48
|
+
validateUml(): UmlIssue[];
|
|
49
|
+
/** 关系记法的可读描述(属性面板/文档共用,避免三处各写一份文案) */
|
|
50
|
+
static describeRelationKind(kind: UmlRelationKind): string;
|
|
51
|
+
/** 端口点:与 FlowDesigner 的插槽语义一致(T/R/B/L/C),这里按 UML 常用左右出发 */
|
|
52
|
+
private __portPoint;
|
|
53
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
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 { ICEPolyLine } from '../ice-render/index.mjs';
|
|
9
|
+
/** UML 类图里的六种关系(记法见下方 STYLE_BY_KIND) */
|
|
10
|
+
export declare const UML_RELATION_KINDS: readonly ["inheritance", "realization", "association", "aggregation", "composition", "dependency"];
|
|
11
|
+
export declare type UmlRelationKind = (typeof UML_RELATION_KINDS)[number];
|
|
12
|
+
/** 端点标记种类 */
|
|
13
|
+
export declare type UmlMarker = 'none' | 'triangle' | 'diamond' | 'open';
|
|
14
|
+
declare type UmlRelationStyle = {
|
|
15
|
+
marker: UmlMarker;
|
|
16
|
+
/** 标记画在哪一端:整体(owner)一侧 / 目标(被继承、被依赖)一侧 */
|
|
17
|
+
markerEnd: 'start' | 'end';
|
|
18
|
+
filled: boolean;
|
|
19
|
+
dashed: boolean;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* 六种关系的**记法**(UML 2.5 规范):
|
|
23
|
+
*
|
|
24
|
+
* | 关系 | 线型 | 端点 |
|
|
25
|
+
* |---|---|---|
|
|
26
|
+
* | 继承 generalization | 实线 | 空心三角,指向父类 |
|
|
27
|
+
* | 实现 realization | 虚线 | 空心三角,指向接口 |
|
|
28
|
+
* | 关联 association | 实线 | 无 |
|
|
29
|
+
* | 聚合 aggregation | 实线 | **空心菱形**,在整体一侧 |
|
|
30
|
+
* | 组合 composition | 实线 | **实心菱形**,在整体一侧 |
|
|
31
|
+
* | 依赖 dependency | 虚线 | 开放箭头,指向被依赖方 |
|
|
32
|
+
*/
|
|
33
|
+
export declare const UML_RELATION_STYLE: Record<UmlRelationKind, UmlRelationStyle>;
|
|
34
|
+
/**
|
|
35
|
+
* @class UmlRelation UML 类图的关系线
|
|
36
|
+
*
|
|
37
|
+
* 复用引擎的折线(`ICEPolyLine`):插槽吸附、正交/贝塞尔路由、标签、跟随宿主都是现成的。
|
|
38
|
+
* 这里只补 UML 特有的一件事 —— **端点标记**(三角/菱形/开放箭头)。
|
|
39
|
+
*
|
|
40
|
+
* 关键实现选择:标记**作为路径点插进 dots**(而不是画上去的装饰),因此
|
|
41
|
+
* - 描边/填充走引擎既有通道(空心/实心天然可分);
|
|
42
|
+
* - SVG 导出**自动带上**标记(导出器读的是同一条命令流);
|
|
43
|
+
* - 包围盒、命中检测也跟着正确。
|
|
44
|
+
*/
|
|
45
|
+
export default class UmlRelation extends ICEPolyLine {
|
|
46
|
+
static readonly typeId = "UmlRelation";
|
|
47
|
+
constructor(props?: any);
|
|
48
|
+
protected static arrangeParam(props: any): any;
|
|
49
|
+
setState(patch: any): void;
|
|
50
|
+
/** 属性面板/DSL 改关系种类走这里 */
|
|
51
|
+
applyPatch(patch?: any): void;
|
|
52
|
+
/** 把记法写进 state:线型、端点、填充、标记种类 */
|
|
53
|
+
private __applyNotation;
|
|
54
|
+
/**
|
|
55
|
+
* @overwrite
|
|
56
|
+
* 端点标记:按记法把三角/菱形/开放箭头的顶点插进 dots(因此它们是**路径的一部分**)。
|
|
57
|
+
*
|
|
58
|
+
* 引擎原生只支持三角(`doCalcArrowPoints()` 返回两个底角),这里对菱形做同样的展开:
|
|
59
|
+
* 菱形的四个顶点 = 端点 P、两个腰点、远端顶点 —— 闭合后就是一个菱形。
|
|
60
|
+
*/
|
|
61
|
+
protected calcArrowPoints(): void;
|
|
62
|
+
}
|
|
63
|
+
export {};
|