@retikz/core 0.1.0-alpha.1 → 0.1.0-alpha.2
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/dist/es/compile/node.d.ts +32 -6
- package/dist/es/compile/node.d.ts.map +1 -1
- package/dist/es/compile/node.js +112 -28
- package/dist/es/compile/text-metrics.d.ts +2 -2
- package/dist/es/compile/text-metrics.d.ts.map +1 -1
- package/dist/es/index.d.ts +4 -4
- package/dist/es/index.d.ts.map +1 -1
- package/dist/es/index.js +2 -2
- package/dist/es/ir/node.d.ts +286 -6
- package/dist/es/ir/node.d.ts.map +1 -1
- package/dist/es/ir/node.js +71 -5
- package/dist/es/ir/scene.d.ts +376 -16
- package/dist/es/ir/scene.d.ts.map +1 -1
- package/dist/es/primitive/ellipse.d.ts +2 -0
- package/dist/es/primitive/ellipse.d.ts.map +1 -1
- package/dist/es/primitive/path.d.ts +4 -0
- package/dist/es/primitive/path.d.ts.map +1 -1
- package/dist/es/primitive/rect.d.ts +2 -0
- package/dist/es/primitive/rect.d.ts.map +1 -1
- package/dist/es/primitive/text.d.ts +43 -13
- package/dist/es/primitive/text.d.ts.map +1 -1
- package/dist/lib/compile/node.cjs +112 -28
- package/dist/lib/compile/node.d.ts +32 -6
- package/dist/lib/compile/node.d.ts.map +1 -1
- package/dist/lib/compile/text-metrics.d.ts +2 -2
- package/dist/lib/compile/text-metrics.d.ts.map +1 -1
- package/dist/lib/index.cjs +4 -0
- package/dist/lib/index.d.ts +4 -4
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/ir/node.cjs +74 -4
- package/dist/lib/ir/node.d.ts +286 -6
- package/dist/lib/ir/node.d.ts.map +1 -1
- package/dist/lib/ir/scene.d.ts +376 -16
- package/dist/lib/ir/scene.d.ts.map +1 -1
- package/dist/lib/primitive/ellipse.d.ts +2 -0
- package/dist/lib/primitive/ellipse.d.ts.map +1 -1
- package/dist/lib/primitive/path.d.ts +4 -0
- package/dist/lib/primitive/path.d.ts.map +1 -1
- package/dist/lib/primitive/rect.d.ts +2 -0
- package/dist/lib/primitive/rect.d.ts.map +1 -1
- package/dist/lib/primitive/text.d.ts +43 -13
- package/dist/lib/primitive/text.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Position } from '../geometry/point';
|
|
2
2
|
import { Rect, RectAnchor } from '../geometry/rect';
|
|
3
3
|
import { IRNode, NodeShape } from '../ir';
|
|
4
|
-
import { ScenePrimitive } from '../primitive';
|
|
4
|
+
import { ScenePrimitive, TextLine } from '../primitive';
|
|
5
5
|
import { TextMeasurer } from './text-metrics';
|
|
6
6
|
export type NodeLayout = {
|
|
7
7
|
/** 节点 id(如 IR Node 提供);其他位置可通过 id 引用本节点 */
|
|
@@ -22,20 +22,46 @@ export type NodeLayout = {
|
|
|
22
22
|
rotateDeg: number;
|
|
23
23
|
/** 外边距(user units,≥ 0);path 附着到形状外扩 margin 的虚拟边界上 */
|
|
24
24
|
margin: number;
|
|
25
|
-
/**
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
/**
|
|
26
|
+
* 节点文本行;undefined 表示无文本,否则非空数组。
|
|
27
|
+
* 每行可带覆盖样式(fill / opacity / fontSize / fontFamily / fontWeight / fontStyle);
|
|
28
|
+
* 未覆盖的字段在 emit 阶段不写出,由下游走 TextPrim 块级默认。
|
|
29
|
+
*/
|
|
30
|
+
lines?: Array<TextLine>;
|
|
31
|
+
/** 文本块宽度(user units)= max(per-line measureText.width) */
|
|
28
32
|
textWidth: number;
|
|
29
|
-
/**
|
|
33
|
+
/** 文本块高度(user units)≈ lines × lineHeight */
|
|
30
34
|
textHeight: number;
|
|
31
|
-
/**
|
|
35
|
+
/** 文本对齐(已映射到 SVG textAnchor 三态);emit 时透传给 TextPrim.align */
|
|
36
|
+
align: 'start' | 'middle' | 'end';
|
|
37
|
+
/** 行高(user units),已应用默认值;emit 时透传给 TextPrim.lineHeight */
|
|
38
|
+
lineHeight: number;
|
|
39
|
+
/** 文本字号(user units),已应用默认值 */
|
|
32
40
|
fontSize: number;
|
|
41
|
+
/** 字体族;CSS font-family;emit 时透传给 TextPrim */
|
|
42
|
+
fontFamily?: string;
|
|
43
|
+
/** 字重;emit 时透传给 TextPrim */
|
|
44
|
+
fontWeight?: string | number;
|
|
45
|
+
/** 字形:normal / italic / oblique;emit 时透传给 TextPrim */
|
|
46
|
+
fontStyle?: 'normal' | 'italic' | 'oblique';
|
|
33
47
|
/** 节点背景色,CSS 颜色字符串;emit 时用 'transparent' 兜底 */
|
|
34
48
|
fill?: string;
|
|
49
|
+
/** 节点填充透明度 0~1;透传 shape primitive */
|
|
50
|
+
fillOpacity?: number;
|
|
35
51
|
/** 节点边框色,CSS 颜色字符串;emit 时用 'currentColor' 兜底 */
|
|
36
52
|
stroke?: string;
|
|
53
|
+
/** 节点描边透明度 0~1;TikZ `draw opacity`,透传 shape primitive */
|
|
54
|
+
strokeOpacity?: number;
|
|
37
55
|
/** 节点边框宽度(user units);emit 时用 1 兜底 */
|
|
38
56
|
strokeWidth?: number;
|
|
57
|
+
/** SVG stroke-dasharray 字符串;compile 已把 dashed / dotted 预设解析为具体 pattern */
|
|
58
|
+
strokeDasharray?: string;
|
|
59
|
+
/** rectangle shape 的圆角半径(user units);非 rect shape 该字段无效 */
|
|
60
|
+
roundedCorners?: number;
|
|
61
|
+
/** 文字颜色;emit 时透传给 TextPrim.fill,兜底 'currentColor' */
|
|
62
|
+
textColor?: string;
|
|
63
|
+
/** 整节点透明度 0~1;emit 时同时挂 shape 与 text primitive */
|
|
64
|
+
opacity?: number;
|
|
39
65
|
};
|
|
40
66
|
/**
|
|
41
67
|
* 取节点 shape 在 toward 方向上的"附着点"——path 端点贴边用。
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../src/compile/node.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../src/compile/node.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,KAAK,EAAc,MAAM,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AA8BnD,MAAM,MAAM,UAAU,GAAG;IACvB,2CAA2C;IAC3C,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,8CAA8C;IAC9C,KAAK,EAAE,SAAS,CAAC;IACjB;;;;;;;;OAQG;IACH,IAAI,EAAE,IAAI,CAAC;IACX,gDAAgD;IAChD,SAAS,EAAE,MAAM,CAAC;IAClB,qDAAqD;IACrD,MAAM,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;IACxB,yDAAyD;IACzD,SAAS,EAAE,MAAM,CAAC;IAClB,4CAA4C;IAC5C,UAAU,EAAE,MAAM,CAAC;IACnB,4DAA4D;IAC5D,KAAK,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;IAClC,0DAA0D;IAC1D,UAAU,EAAE,MAAM,CAAC;IACnB,8BAA8B;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,6CAA6C;IAC7C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,4BAA4B;IAC5B,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC7B,sDAAsD;IACtD,SAAS,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;IAC5C,+CAA+C;IAC/C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qCAAqC;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gDAAgD;IAChD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,yDAAyD;IACzD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,sCAAsC;IACtC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0EAA0E;IAC1E,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,2DAA2D;IAC3D,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,qDAAqD;IACrD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kDAAkD;IAClD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAsCF;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,UAAU,EAAE,QAAQ,QAAQ,KAAG,QAYtE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,QAAQ,GAAI,QAAQ,UAAU,EAAE,MAAM,UAAU,KAAG,QAW/D,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,UAAU,EAAE,UAAU,MAAM,KAAG,QActE,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,GACrB,MAAM,MAAM,EACZ,aAAa,YAAY,EACzB,WAAW,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,KACjC,UAgJF,CAAC;AAsEF;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,GAC7B,QAAQ,UAAU,EAClB,OAAO,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,KAC3B,KAAK,CAAC,cAAc,CAoDtB,CAAC"}
|
package/dist/es/compile/node.js
CHANGED
|
@@ -6,8 +6,21 @@ import { resolvePosition } from "./position.js";
|
|
|
6
6
|
//#region src/compile/node.ts
|
|
7
7
|
var DEFAULT_FONT_SIZE = 14;
|
|
8
8
|
var DEFAULT_PADDING = 8;
|
|
9
|
+
var DEFAULT_LINE_HEIGHT_FACTOR = 1.2;
|
|
9
10
|
var DEG_TO_RAD = Math.PI / 180;
|
|
10
11
|
var SQRT2 = Math.SQRT2;
|
|
12
|
+
/** dashed 预设:SVG stroke-dasharray "4 2"——4 px 实线 + 2 px 间隙循环 */
|
|
13
|
+
var DASHED_PATTERN = "4 2";
|
|
14
|
+
/** dotted 预设:SVG stroke-dasharray "1 2"——1 px 圆点 + 2 px 间隙 */
|
|
15
|
+
var DOTTED_PATTERN = "1 2";
|
|
16
|
+
/** 解析 dashed / dotted / dashArray 优先级:dashArray > dashed > dotted */
|
|
17
|
+
var resolveDashArray = (dashArray, dashed, dotted) => {
|
|
18
|
+
if (dashArray !== void 0) return dashArray;
|
|
19
|
+
if (dashed) return DASHED_PATTERN;
|
|
20
|
+
if (dotted) return DOTTED_PATTERN;
|
|
21
|
+
};
|
|
22
|
+
/** IR `align` ('left' | 'center' | 'right') → SVG textAnchor ('start' | 'middle' | 'end') */
|
|
23
|
+
var alignToTextAnchor = (a) => a === "left" ? "start" : a === "right" ? "end" : "middle";
|
|
11
24
|
/** 由 layout 构造的 Rect(带 margin 扩张) */
|
|
12
25
|
var rectOf = (layout, marginAdd) => ({
|
|
13
26
|
x: layout.rect.x,
|
|
@@ -90,14 +103,52 @@ var angleBoundaryOf = (layout, angleDeg) => {
|
|
|
90
103
|
* - 透传 margin / 样式属性
|
|
91
104
|
*/
|
|
92
105
|
var layoutNode = (node, measureText, nodeIndex) => {
|
|
93
|
-
const
|
|
94
|
-
const
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
const
|
|
100
|
-
const
|
|
106
|
+
const sx = node.xScale ?? node.scale ?? 1;
|
|
107
|
+
const sy = node.yScale ?? node.scale ?? 1;
|
|
108
|
+
const fontScale = Math.min(sx, sy);
|
|
109
|
+
const baseFontSize = node.font?.size ?? DEFAULT_FONT_SIZE;
|
|
110
|
+
const fontSize = baseFontSize * fontScale;
|
|
111
|
+
const fontFamily = node.font?.family;
|
|
112
|
+
const fontWeight = node.font?.weight;
|
|
113
|
+
const fontStyle = node.font?.style;
|
|
114
|
+
const xSep = (node.innerXSep ?? node.padding ?? DEFAULT_PADDING) * sx;
|
|
115
|
+
const ySep = (node.innerYSep ?? node.padding ?? DEFAULT_PADDING) * sy;
|
|
116
|
+
const outerSep = (node.outerSep ?? node.margin ?? 0) * Math.max(sx, sy);
|
|
117
|
+
const lineHeight = (node.lineHeight ?? baseFontSize * DEFAULT_LINE_HEIGHT_FACTOR) * sy;
|
|
118
|
+
const align = alignToTextAnchor(node.align ?? "center");
|
|
119
|
+
const rawLines = node.text === void 0 ? void 0 : typeof node.text === "string" ? [node.text] : node.text;
|
|
120
|
+
let textWidth = 0;
|
|
121
|
+
let textHeight = 0;
|
|
122
|
+
let lines;
|
|
123
|
+
if (rawLines) {
|
|
124
|
+
lines = rawLines.map((spec) => {
|
|
125
|
+
const isObj = typeof spec !== "string";
|
|
126
|
+
const text = isObj ? spec.text : spec;
|
|
127
|
+
const lineFont = isObj ? spec.font : void 0;
|
|
128
|
+
const m = measureText(text, {
|
|
129
|
+
size: lineFont?.size ?? fontSize,
|
|
130
|
+
family: lineFont?.family ?? fontFamily,
|
|
131
|
+
weight: lineFont?.weight ?? fontWeight,
|
|
132
|
+
style: lineFont?.style ?? fontStyle
|
|
133
|
+
});
|
|
134
|
+
if (m.width > textWidth) textWidth = m.width;
|
|
135
|
+
const out = { text };
|
|
136
|
+
if (isObj) {
|
|
137
|
+
if (spec.fill !== void 0) out.fill = spec.fill;
|
|
138
|
+
if (spec.opacity !== void 0) out.opacity = spec.opacity;
|
|
139
|
+
if (lineFont?.size !== void 0) out.fontSize = lineFont.size;
|
|
140
|
+
if (lineFont?.family !== void 0) out.fontFamily = lineFont.family;
|
|
141
|
+
if (lineFont?.weight !== void 0) out.fontWeight = lineFont.weight;
|
|
142
|
+
if (lineFont?.style !== void 0) out.fontStyle = lineFont.style;
|
|
143
|
+
}
|
|
144
|
+
return out;
|
|
145
|
+
});
|
|
146
|
+
textHeight = lines.length * lineHeight;
|
|
147
|
+
}
|
|
148
|
+
const minW = node.minimumWidth ?? node.minimumSize ?? 0;
|
|
149
|
+
const minH = node.minimumHeight ?? node.minimumSize ?? 0;
|
|
150
|
+
const innerHalfW = Math.max(textWidth / 2 + xSep, xSep, minW / 2);
|
|
151
|
+
const innerHalfH = Math.max(textHeight / 2 + ySep, ySep, minH / 2);
|
|
101
152
|
const shape = node.shape ?? "rectangle";
|
|
102
153
|
let boundsHalfW;
|
|
103
154
|
let boundsHalfH;
|
|
@@ -135,14 +186,25 @@ var layoutNode = (node, measureText, nodeIndex) => {
|
|
|
135
186
|
rotate: rotateDeg * DEG_TO_RAD
|
|
136
187
|
},
|
|
137
188
|
rotateDeg,
|
|
138
|
-
margin:
|
|
139
|
-
|
|
140
|
-
textWidth
|
|
141
|
-
textHeight
|
|
189
|
+
margin: outerSep,
|
|
190
|
+
lines,
|
|
191
|
+
textWidth,
|
|
192
|
+
textHeight,
|
|
193
|
+
align,
|
|
194
|
+
lineHeight,
|
|
142
195
|
fontSize,
|
|
196
|
+
fontFamily,
|
|
197
|
+
fontWeight,
|
|
198
|
+
fontStyle,
|
|
143
199
|
fill: node.fill,
|
|
200
|
+
fillOpacity: node.fillOpacity,
|
|
144
201
|
stroke: node.stroke,
|
|
145
|
-
|
|
202
|
+
strokeOpacity: node.drawOpacity,
|
|
203
|
+
strokeWidth: node.strokeWidth,
|
|
204
|
+
strokeDasharray: resolveDashArray(node.dashArray, node.dashed, node.dotted),
|
|
205
|
+
roundedCorners: node.roundedCorners,
|
|
206
|
+
textColor: node.textColor,
|
|
207
|
+
opacity: node.opacity
|
|
146
208
|
};
|
|
147
209
|
};
|
|
148
210
|
/** rectangle shape 的 RectPrim */
|
|
@@ -156,8 +218,13 @@ var emitRectShape = (layout, round) => {
|
|
|
156
218
|
width: round(layout.rect.width),
|
|
157
219
|
height: round(layout.rect.height),
|
|
158
220
|
fill: layout.fill ?? "transparent",
|
|
221
|
+
fillOpacity: layout.fillOpacity,
|
|
159
222
|
stroke: layout.stroke ?? "currentColor",
|
|
160
|
-
|
|
223
|
+
strokeOpacity: layout.strokeOpacity,
|
|
224
|
+
strokeWidth: layout.strokeWidth ?? 1,
|
|
225
|
+
strokeDasharray: layout.strokeDasharray,
|
|
226
|
+
cornerRadius: layout.roundedCorners,
|
|
227
|
+
opacity: layout.opacity
|
|
161
228
|
};
|
|
162
229
|
};
|
|
163
230
|
/** circle / ellipse shape 的 EllipsePrim(圆形 rx=ry) */
|
|
@@ -168,8 +235,12 @@ var emitEllipseShape = (layout, round) => ({
|
|
|
168
235
|
rx: round(layout.rect.width / 2),
|
|
169
236
|
ry: round(layout.rect.height / 2),
|
|
170
237
|
fill: layout.fill ?? "transparent",
|
|
238
|
+
fillOpacity: layout.fillOpacity,
|
|
171
239
|
stroke: layout.stroke ?? "currentColor",
|
|
172
|
-
|
|
240
|
+
strokeOpacity: layout.strokeOpacity,
|
|
241
|
+
strokeWidth: layout.strokeWidth ?? 1,
|
|
242
|
+
strokeDasharray: layout.strokeDasharray,
|
|
243
|
+
opacity: layout.opacity
|
|
173
244
|
});
|
|
174
245
|
/** diamond shape 的 PathPrim(4 顶点 + Z 闭合) */
|
|
175
246
|
var emitDiamondShape = (layout, round) => {
|
|
@@ -182,8 +253,12 @@ var emitDiamondShape = (layout, round) => {
|
|
|
182
253
|
type: "path",
|
|
183
254
|
d: `M ${round(e[0])} ${round(e[1])} L ${round(n[0])} ${round(n[1])} L ${round(w[0])} ${round(w[1])} L ${round(s[0])} ${round(s[1])} Z`,
|
|
184
255
|
fill: layout.fill ?? "transparent",
|
|
256
|
+
fillOpacity: layout.fillOpacity,
|
|
185
257
|
stroke: layout.stroke ?? "currentColor",
|
|
186
|
-
|
|
258
|
+
strokeOpacity: layout.strokeOpacity,
|
|
259
|
+
strokeWidth: layout.strokeWidth ?? 1,
|
|
260
|
+
strokeDasharray: layout.strokeDasharray,
|
|
261
|
+
opacity: layout.opacity
|
|
187
262
|
};
|
|
188
263
|
};
|
|
189
264
|
/**
|
|
@@ -209,18 +284,27 @@ var emitNodePrimitives = (layout, round) => {
|
|
|
209
284
|
break;
|
|
210
285
|
}
|
|
211
286
|
const inner = [shapePrim];
|
|
212
|
-
if (layout.
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
287
|
+
if (layout.lines) {
|
|
288
|
+
const halfBlockW = layout.textWidth / 2;
|
|
289
|
+
const xOffset = layout.align === "start" ? -halfBlockW : layout.align === "end" ? halfBlockW : 0;
|
|
290
|
+
inner.push({
|
|
291
|
+
type: "text",
|
|
292
|
+
x: round(layout.rect.x + xOffset),
|
|
293
|
+
y: round(layout.rect.y),
|
|
294
|
+
lines: layout.lines,
|
|
295
|
+
fontSize: layout.fontSize,
|
|
296
|
+
fontFamily: layout.fontFamily,
|
|
297
|
+
fontWeight: layout.fontWeight,
|
|
298
|
+
fontStyle: layout.fontStyle,
|
|
299
|
+
align: layout.align,
|
|
300
|
+
baseline: "middle",
|
|
301
|
+
lineHeight: round(layout.lineHeight),
|
|
302
|
+
fill: layout.textColor ?? "currentColor",
|
|
303
|
+
opacity: layout.opacity,
|
|
304
|
+
measuredWidth: round(layout.textWidth),
|
|
305
|
+
measuredHeight: round(layout.textHeight)
|
|
306
|
+
});
|
|
307
|
+
}
|
|
224
308
|
if (layout.rotateDeg === 0) return inner;
|
|
225
309
|
return [{
|
|
226
310
|
type: "group",
|
|
@@ -6,8 +6,8 @@ export type FontSpec = {
|
|
|
6
6
|
size: number;
|
|
7
7
|
/** 字重;可以是 'normal' / 'bold' / 100~900 数字等 */
|
|
8
8
|
weight?: string | number;
|
|
9
|
-
/** 字形:normal
|
|
10
|
-
style?: 'normal' | 'italic';
|
|
9
|
+
/** 字形:normal / italic / oblique */
|
|
10
|
+
style?: 'normal' | 'italic' | 'oblique';
|
|
11
11
|
};
|
|
12
12
|
/** 文字度量结果:宽高 + 可选的基线 ascent/descent */
|
|
13
13
|
export type TextMetrics = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text-metrics.d.ts","sourceRoot":"","sources":["../../../src/compile/text-metrics.ts"],"names":[],"mappings":"AAAA,iCAAiC;AACjC,MAAM,MAAM,QAAQ,GAAG;IACrB,oCAAoC;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,qBAAqB;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,6CAA6C;IAC7C,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,
|
|
1
|
+
{"version":3,"file":"text-metrics.d.ts","sourceRoot":"","sources":["../../../src/compile/text-metrics.ts"],"names":[],"mappings":"AAAA,iCAAiC;AACjC,MAAM,MAAM,QAAQ,GAAG;IACrB,oCAAoC;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,qBAAqB;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,6CAA6C;IAC7C,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,mCAAmC;IACnC,KAAK,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;CACzC,CAAC;AAEF,uCAAuC;AACvC,MAAM,MAAM,WAAW,GAAG;IACxB,uBAAuB;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,6CAA6C;IAC7C,MAAM,EAAE,MAAM,CAAC;IACf,iCAAiC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iCAAiC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,KAAK,WAAW,CAAC;AAEzE,uCAAuC;AACvC,eAAO,MAAM,gBAAgB,EAAE,YAG7B,CAAC"}
|
package/dist/es/index.d.ts
CHANGED
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
*
|
|
7
7
|
* 本包零 React、零 DOM 依赖。
|
|
8
8
|
*/
|
|
9
|
-
export { PositionSchema, PolarPositionSchema, TargetSchema, MoveStepSchema, LineStepSchema, FoldStepSchema, CycleStepSchema, StepSchema, NodeSchema, PathSchema, ChildSchema, SceneSchema, CURRENT_IR_VERSION, } from './ir';
|
|
10
|
-
export type { IRPosition, IRTarget, IRMoveStep, IRLineStep, IRFoldStep, IRCycleStep, IRStep, IRNode, IRPath, IRChild, IR, ArrowShape, NodeShape, } from './ir';
|
|
11
|
-
export { ARROW_SHAPES, NODE_SHAPES } from './ir';
|
|
12
|
-
export type { ScenePrimitive, RectPrim, EllipsePrim, TextPrim, PathPrim, GroupPrim, ViewBox, Scene, } from './primitive';
|
|
9
|
+
export { PositionSchema, PolarPositionSchema, TargetSchema, MoveStepSchema, LineStepSchema, FoldStepSchema, CycleStepSchema, StepSchema, NodeSchema, FontSchema, NodeTextSchema, LineSpecSchema, PathSchema, ChildSchema, SceneSchema, CURRENT_IR_VERSION, } from './ir';
|
|
10
|
+
export type { IRPosition, IRTarget, IRMoveStep, IRLineStep, IRFoldStep, IRCycleStep, IRStep, IRNode, IRFont, IRLineSpec, IRPath, IRChild, IR, ArrowShape, NodeShape, NodeTextAlign, } from './ir';
|
|
11
|
+
export { ARROW_SHAPES, NODE_SHAPES, NODE_TEXT_ALIGNS } from './ir';
|
|
12
|
+
export type { ScenePrimitive, RectPrim, EllipsePrim, TextPrim, TextLine, PathPrim, GroupPrim, ViewBox, Scene, } from './primitive';
|
|
13
13
|
export type { FontSpec, TextMetrics, TextMeasurer, CompileOptions, } from './compile';
|
|
14
14
|
export { fallbackMeasurer, compileToScene } from './compile';
|
|
15
15
|
export type { WayItem, WayDSL, WayCycle, WayVia } from './parsers';
|
package/dist/es/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,YAAY,EACZ,cAAc,EACd,cAAc,EACd,cAAc,EACd,eAAe,EACf,UAAU,EACV,UAAU,EACV,UAAU,EACV,WAAW,EACX,WAAW,EACX,kBAAkB,GACnB,MAAM,MAAM,CAAC;AACd,YAAY,EACV,UAAU,EACV,QAAQ,EACR,UAAU,EACV,UAAU,EACV,UAAU,EACV,WAAW,EACX,MAAM,EACN,MAAM,EACN,MAAM,EACN,OAAO,EACP,EAAE,EACF,UAAU,EACV,SAAS,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,YAAY,EACZ,cAAc,EACd,cAAc,EACd,cAAc,EACd,eAAe,EACf,UAAU,EACV,UAAU,EACV,UAAU,EACV,cAAc,EACd,cAAc,EACd,UAAU,EACV,WAAW,EACX,WAAW,EACX,kBAAkB,GACnB,MAAM,MAAM,CAAC;AACd,YAAY,EACV,UAAU,EACV,QAAQ,EACR,UAAU,EACV,UAAU,EACV,UAAU,EACV,WAAW,EACX,MAAM,EACN,MAAM,EACN,MAAM,EACN,UAAU,EACV,MAAM,EACN,OAAO,EACP,EAAE,EACF,UAAU,EACV,SAAS,EACT,aAAa,GACd,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,MAAM,CAAC;AAGnE,YAAY,EACV,cAAc,EACd,QAAQ,EACR,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,OAAO,EACP,KAAK,GACN,MAAM,aAAa,CAAC;AAGrB,YAAY,EACV,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,cAAc,GACf,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAG7D,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAI9C,YAAY,EACV,QAAQ,EACR,IAAI,EACJ,UAAU,EACV,MAAM,EACN,YAAY,EACZ,OAAO,EACP,aAAa,EACb,OAAO,EACP,aAAa,EACb,aAAa,GACd,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAGxF,YAAY,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC"}
|
package/dist/es/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { ARROW_SHAPES } from "./ir/path/arrow.js";
|
|
|
4
4
|
import { TargetSchema } from "./ir/path/target.js";
|
|
5
5
|
import { CycleStepSchema, FoldStepSchema, LineStepSchema, MoveStepSchema, StepSchema } from "./ir/path/step.js";
|
|
6
6
|
import { PathSchema } from "./ir/path/path.js";
|
|
7
|
-
import { NODE_SHAPES, NodeSchema } from "./ir/node.js";
|
|
7
|
+
import { FontSchema, LineSpecSchema, NODE_SHAPES, NODE_TEXT_ALIGNS, NodeSchema, NodeTextSchema } from "./ir/node.js";
|
|
8
8
|
import { CURRENT_IR_VERSION, ChildSchema, SceneSchema } from "./ir/scene.js";
|
|
9
9
|
import { RECT_ANCHORS, rect } from "./geometry/rect.js";
|
|
10
10
|
import { circle } from "./geometry/circle.js";
|
|
@@ -15,4 +15,4 @@ import { compileToScene } from "./compile/compile.js";
|
|
|
15
15
|
import { DrawWay, parseWay } from "./parsers/parseWay.js";
|
|
16
16
|
import { polar } from "./geometry/polar.js";
|
|
17
17
|
import { point } from "./geometry/point.js";
|
|
18
|
-
export { ARROW_SHAPES, CURRENT_IR_VERSION, ChildSchema, CycleStepSchema, DrawWay, FoldStepSchema, LineStepSchema, MoveStepSchema, NODE_SHAPES, NodeSchema, PathSchema, PolarPositionSchema, PositionSchema, RECT_ANCHORS, SceneSchema, StepSchema, TargetSchema, circle, compileToScene, diamond, ellipse, fallbackMeasurer, parseWay, point, polar, rect };
|
|
18
|
+
export { ARROW_SHAPES, CURRENT_IR_VERSION, ChildSchema, CycleStepSchema, DrawWay, FoldStepSchema, FontSchema, LineSpecSchema, LineStepSchema, MoveStepSchema, NODE_SHAPES, NODE_TEXT_ALIGNS, NodeSchema, NodeTextSchema, PathSchema, PolarPositionSchema, PositionSchema, RECT_ANCHORS, SceneSchema, StepSchema, TargetSchema, circle, compileToScene, diamond, ellipse, fallbackMeasurer, parseWay, point, polar, rect };
|
package/dist/es/ir/node.d.ts
CHANGED
|
@@ -23,6 +23,140 @@ export declare const NODE_SHAPES: {
|
|
|
23
23
|
};
|
|
24
24
|
/** 节点形状字面量类型,由 `NODE_SHAPES` 派生 */
|
|
25
25
|
export type NodeShape = ValueOf<typeof NODE_SHAPES>;
|
|
26
|
+
/**
|
|
27
|
+
* 节点字体规格——family / size / weight / style 全部可选;
|
|
28
|
+
* 单字段透传到 SVG `<text>` 的 `font-*` 属性 / `font-size`。
|
|
29
|
+
*
|
|
30
|
+
* 取代 alpha.1 的标量 `fontSize` 字段(已删)。
|
|
31
|
+
*/
|
|
32
|
+
export declare const FontSchema: z.ZodObject<{
|
|
33
|
+
family: z.ZodOptional<z.ZodString>;
|
|
34
|
+
size: z.ZodOptional<z.ZodNumber>;
|
|
35
|
+
weight: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["normal", "bold"]>, z.ZodNumber]>>;
|
|
36
|
+
style: z.ZodOptional<z.ZodEnum<["normal", "italic", "oblique"]>>;
|
|
37
|
+
}, "strip", z.ZodTypeAny, {
|
|
38
|
+
family?: string | undefined;
|
|
39
|
+
size?: number | undefined;
|
|
40
|
+
weight?: number | "normal" | "bold" | undefined;
|
|
41
|
+
style?: "normal" | "italic" | "oblique" | undefined;
|
|
42
|
+
}, {
|
|
43
|
+
family?: string | undefined;
|
|
44
|
+
size?: number | undefined;
|
|
45
|
+
weight?: number | "normal" | "bold" | undefined;
|
|
46
|
+
style?: "normal" | "italic" | "oblique" | undefined;
|
|
47
|
+
}>;
|
|
48
|
+
/** 节点字体规格(IR 层)——所有字段可选,编译期解析默认值 */
|
|
49
|
+
export type IRFont = z.infer<typeof FontSchema>;
|
|
50
|
+
/**
|
|
51
|
+
* 单行文本规格——纯字符串走块级默认样式;对象形式可对该行覆盖 fill / opacity / font。
|
|
52
|
+
*
|
|
53
|
+
* 行级覆盖只生效于本行的 `<tspan>`:
|
|
54
|
+
* - `fill`:仅这一行颜色
|
|
55
|
+
* - `opacity`:仅这一行 0~1 透明度
|
|
56
|
+
* - `font`:family / size / weight / style 任意子集;未填字段继承块级 font
|
|
57
|
+
*
|
|
58
|
+
* 块级 `align` / `lineHeight` 不可被行覆盖(多行块整体属性)。
|
|
59
|
+
*/
|
|
60
|
+
export declare const LineSpecSchema: z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
61
|
+
text: z.ZodString;
|
|
62
|
+
fill: z.ZodOptional<z.ZodString>;
|
|
63
|
+
opacity: z.ZodOptional<z.ZodNumber>;
|
|
64
|
+
font: z.ZodOptional<z.ZodObject<{
|
|
65
|
+
family: z.ZodOptional<z.ZodString>;
|
|
66
|
+
size: z.ZodOptional<z.ZodNumber>;
|
|
67
|
+
weight: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["normal", "bold"]>, z.ZodNumber]>>;
|
|
68
|
+
style: z.ZodOptional<z.ZodEnum<["normal", "italic", "oblique"]>>;
|
|
69
|
+
}, "strip", z.ZodTypeAny, {
|
|
70
|
+
family?: string | undefined;
|
|
71
|
+
size?: number | undefined;
|
|
72
|
+
weight?: number | "normal" | "bold" | undefined;
|
|
73
|
+
style?: "normal" | "italic" | "oblique" | undefined;
|
|
74
|
+
}, {
|
|
75
|
+
family?: string | undefined;
|
|
76
|
+
size?: number | undefined;
|
|
77
|
+
weight?: number | "normal" | "bold" | undefined;
|
|
78
|
+
style?: "normal" | "italic" | "oblique" | undefined;
|
|
79
|
+
}>>;
|
|
80
|
+
}, "strip", z.ZodTypeAny, {
|
|
81
|
+
text: string;
|
|
82
|
+
fill?: string | undefined;
|
|
83
|
+
opacity?: number | undefined;
|
|
84
|
+
font?: {
|
|
85
|
+
family?: string | undefined;
|
|
86
|
+
size?: number | undefined;
|
|
87
|
+
weight?: number | "normal" | "bold" | undefined;
|
|
88
|
+
style?: "normal" | "italic" | "oblique" | undefined;
|
|
89
|
+
} | undefined;
|
|
90
|
+
}, {
|
|
91
|
+
text: string;
|
|
92
|
+
fill?: string | undefined;
|
|
93
|
+
opacity?: number | undefined;
|
|
94
|
+
font?: {
|
|
95
|
+
family?: string | undefined;
|
|
96
|
+
size?: number | undefined;
|
|
97
|
+
weight?: number | "normal" | "bold" | undefined;
|
|
98
|
+
style?: "normal" | "italic" | "oblique" | undefined;
|
|
99
|
+
} | undefined;
|
|
100
|
+
}>]>;
|
|
101
|
+
/** 行规格 IR 类型(string 或对象) */
|
|
102
|
+
export type IRLineSpec = z.infer<typeof LineSpecSchema>;
|
|
103
|
+
/**
|
|
104
|
+
* 节点文本——单行字符串或非空多行数组(每元素一个 LineSpec):
|
|
105
|
+
* - `'Hello'` 等价于 `[{ text: 'Hello' }]`,按一行渲染
|
|
106
|
+
* - `['Line 1', 'Line 2']` 两行无样式覆盖
|
|
107
|
+
* - `[{ text: 'Heading', fill: 'red', font: { weight: 'bold' } }, 'body']` 混排
|
|
108
|
+
*
|
|
109
|
+
* 选 `Array<LineSpec>` 而非 `'\n'` 字符串:JSON 友好(无 escape);行级覆盖天然落字段。
|
|
110
|
+
*/
|
|
111
|
+
export declare const NodeTextSchema: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
112
|
+
text: z.ZodString;
|
|
113
|
+
fill: z.ZodOptional<z.ZodString>;
|
|
114
|
+
opacity: z.ZodOptional<z.ZodNumber>;
|
|
115
|
+
font: z.ZodOptional<z.ZodObject<{
|
|
116
|
+
family: z.ZodOptional<z.ZodString>;
|
|
117
|
+
size: z.ZodOptional<z.ZodNumber>;
|
|
118
|
+
weight: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["normal", "bold"]>, z.ZodNumber]>>;
|
|
119
|
+
style: z.ZodOptional<z.ZodEnum<["normal", "italic", "oblique"]>>;
|
|
120
|
+
}, "strip", z.ZodTypeAny, {
|
|
121
|
+
family?: string | undefined;
|
|
122
|
+
size?: number | undefined;
|
|
123
|
+
weight?: number | "normal" | "bold" | undefined;
|
|
124
|
+
style?: "normal" | "italic" | "oblique" | undefined;
|
|
125
|
+
}, {
|
|
126
|
+
family?: string | undefined;
|
|
127
|
+
size?: number | undefined;
|
|
128
|
+
weight?: number | "normal" | "bold" | undefined;
|
|
129
|
+
style?: "normal" | "italic" | "oblique" | undefined;
|
|
130
|
+
}>>;
|
|
131
|
+
}, "strip", z.ZodTypeAny, {
|
|
132
|
+
text: string;
|
|
133
|
+
fill?: string | undefined;
|
|
134
|
+
opacity?: number | undefined;
|
|
135
|
+
font?: {
|
|
136
|
+
family?: string | undefined;
|
|
137
|
+
size?: number | undefined;
|
|
138
|
+
weight?: number | "normal" | "bold" | undefined;
|
|
139
|
+
style?: "normal" | "italic" | "oblique" | undefined;
|
|
140
|
+
} | undefined;
|
|
141
|
+
}, {
|
|
142
|
+
text: string;
|
|
143
|
+
fill?: string | undefined;
|
|
144
|
+
opacity?: number | undefined;
|
|
145
|
+
font?: {
|
|
146
|
+
family?: string | undefined;
|
|
147
|
+
size?: number | undefined;
|
|
148
|
+
weight?: number | "normal" | "bold" | undefined;
|
|
149
|
+
style?: "normal" | "italic" | "oblique" | undefined;
|
|
150
|
+
} | undefined;
|
|
151
|
+
}>]>, "many">]>;
|
|
152
|
+
/** 节点文本对齐(多行内文本对齐)——TikZ `align=` 同义词 */
|
|
153
|
+
export declare const NODE_TEXT_ALIGNS: {
|
|
154
|
+
readonly left: "left";
|
|
155
|
+
readonly center: "center";
|
|
156
|
+
readonly right: "right";
|
|
157
|
+
};
|
|
158
|
+
/** 多行文本对齐字面量类型 */
|
|
159
|
+
export type NodeTextAlign = ValueOf<typeof NODE_TEXT_ALIGNS>;
|
|
26
160
|
export declare const NodeSchema: z.ZodObject<{
|
|
27
161
|
type: z.ZodLiteral<"node">;
|
|
28
162
|
id: z.ZodOptional<z.ZodString>;
|
|
@@ -34,13 +168,91 @@ export declare const NodeSchema: z.ZodObject<{
|
|
|
34
168
|
}>>;
|
|
35
169
|
position: z.ZodUnion<[z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>, z.ZodType<import('./position').PolarPosition, z.ZodTypeDef, import('./position').PolarPosition>]>;
|
|
36
170
|
rotate: z.ZodOptional<z.ZodNumber>;
|
|
37
|
-
text: z.ZodOptional<z.ZodString
|
|
171
|
+
text: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
172
|
+
text: z.ZodString;
|
|
173
|
+
fill: z.ZodOptional<z.ZodString>;
|
|
174
|
+
opacity: z.ZodOptional<z.ZodNumber>;
|
|
175
|
+
font: z.ZodOptional<z.ZodObject<{
|
|
176
|
+
family: z.ZodOptional<z.ZodString>;
|
|
177
|
+
size: z.ZodOptional<z.ZodNumber>;
|
|
178
|
+
weight: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["normal", "bold"]>, z.ZodNumber]>>;
|
|
179
|
+
style: z.ZodOptional<z.ZodEnum<["normal", "italic", "oblique"]>>;
|
|
180
|
+
}, "strip", z.ZodTypeAny, {
|
|
181
|
+
family?: string | undefined;
|
|
182
|
+
size?: number | undefined;
|
|
183
|
+
weight?: number | "normal" | "bold" | undefined;
|
|
184
|
+
style?: "normal" | "italic" | "oblique" | undefined;
|
|
185
|
+
}, {
|
|
186
|
+
family?: string | undefined;
|
|
187
|
+
size?: number | undefined;
|
|
188
|
+
weight?: number | "normal" | "bold" | undefined;
|
|
189
|
+
style?: "normal" | "italic" | "oblique" | undefined;
|
|
190
|
+
}>>;
|
|
191
|
+
}, "strip", z.ZodTypeAny, {
|
|
192
|
+
text: string;
|
|
193
|
+
fill?: string | undefined;
|
|
194
|
+
opacity?: number | undefined;
|
|
195
|
+
font?: {
|
|
196
|
+
family?: string | undefined;
|
|
197
|
+
size?: number | undefined;
|
|
198
|
+
weight?: number | "normal" | "bold" | undefined;
|
|
199
|
+
style?: "normal" | "italic" | "oblique" | undefined;
|
|
200
|
+
} | undefined;
|
|
201
|
+
}, {
|
|
202
|
+
text: string;
|
|
203
|
+
fill?: string | undefined;
|
|
204
|
+
opacity?: number | undefined;
|
|
205
|
+
font?: {
|
|
206
|
+
family?: string | undefined;
|
|
207
|
+
size?: number | undefined;
|
|
208
|
+
weight?: number | "normal" | "bold" | undefined;
|
|
209
|
+
style?: "normal" | "italic" | "oblique" | undefined;
|
|
210
|
+
} | undefined;
|
|
211
|
+
}>]>, "many">]>>;
|
|
212
|
+
align: z.ZodOptional<z.ZodNativeEnum<{
|
|
213
|
+
readonly left: "left";
|
|
214
|
+
readonly center: "center";
|
|
215
|
+
readonly right: "right";
|
|
216
|
+
}>>;
|
|
217
|
+
lineHeight: z.ZodOptional<z.ZodNumber>;
|
|
38
218
|
fill: z.ZodOptional<z.ZodString>;
|
|
219
|
+
fillOpacity: z.ZodOptional<z.ZodNumber>;
|
|
39
220
|
stroke: z.ZodOptional<z.ZodString>;
|
|
221
|
+
drawOpacity: z.ZodOptional<z.ZodNumber>;
|
|
40
222
|
strokeWidth: z.ZodOptional<z.ZodNumber>;
|
|
223
|
+
dashed: z.ZodOptional<z.ZodBoolean>;
|
|
224
|
+
dotted: z.ZodOptional<z.ZodBoolean>;
|
|
225
|
+
dashArray: z.ZodOptional<z.ZodString>;
|
|
226
|
+
roundedCorners: z.ZodOptional<z.ZodNumber>;
|
|
227
|
+
minimumWidth: z.ZodOptional<z.ZodNumber>;
|
|
228
|
+
minimumHeight: z.ZodOptional<z.ZodNumber>;
|
|
229
|
+
minimumSize: z.ZodOptional<z.ZodNumber>;
|
|
230
|
+
scale: z.ZodOptional<z.ZodNumber>;
|
|
231
|
+
xScale: z.ZodOptional<z.ZodNumber>;
|
|
232
|
+
yScale: z.ZodOptional<z.ZodNumber>;
|
|
233
|
+
textColor: z.ZodOptional<z.ZodString>;
|
|
234
|
+
opacity: z.ZodOptional<z.ZodNumber>;
|
|
235
|
+
innerXSep: z.ZodOptional<z.ZodNumber>;
|
|
236
|
+
innerYSep: z.ZodOptional<z.ZodNumber>;
|
|
237
|
+
outerSep: z.ZodOptional<z.ZodNumber>;
|
|
41
238
|
padding: z.ZodOptional<z.ZodNumber>;
|
|
42
239
|
margin: z.ZodOptional<z.ZodNumber>;
|
|
43
|
-
|
|
240
|
+
font: z.ZodOptional<z.ZodObject<{
|
|
241
|
+
family: z.ZodOptional<z.ZodString>;
|
|
242
|
+
size: z.ZodOptional<z.ZodNumber>;
|
|
243
|
+
weight: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["normal", "bold"]>, z.ZodNumber]>>;
|
|
244
|
+
style: z.ZodOptional<z.ZodEnum<["normal", "italic", "oblique"]>>;
|
|
245
|
+
}, "strip", z.ZodTypeAny, {
|
|
246
|
+
family?: string | undefined;
|
|
247
|
+
size?: number | undefined;
|
|
248
|
+
weight?: number | "normal" | "bold" | undefined;
|
|
249
|
+
style?: "normal" | "italic" | "oblique" | undefined;
|
|
250
|
+
}, {
|
|
251
|
+
family?: string | undefined;
|
|
252
|
+
size?: number | undefined;
|
|
253
|
+
weight?: number | "normal" | "bold" | undefined;
|
|
254
|
+
style?: "normal" | "italic" | "oblique" | undefined;
|
|
255
|
+
}>>;
|
|
44
256
|
}, "strip", z.ZodTypeAny, {
|
|
45
257
|
type: "node";
|
|
46
258
|
position: [number, number] | import('./position').PolarPosition;
|
|
@@ -48,12 +260,46 @@ export declare const NodeSchema: z.ZodObject<{
|
|
|
48
260
|
shape?: "diamond" | "circle" | "rectangle" | "ellipse" | undefined;
|
|
49
261
|
stroke?: string | undefined;
|
|
50
262
|
strokeWidth?: number | undefined;
|
|
263
|
+
text?: string | (string | {
|
|
264
|
+
text: string;
|
|
265
|
+
fill?: string | undefined;
|
|
266
|
+
opacity?: number | undefined;
|
|
267
|
+
font?: {
|
|
268
|
+
family?: string | undefined;
|
|
269
|
+
size?: number | undefined;
|
|
270
|
+
weight?: number | "normal" | "bold" | undefined;
|
|
271
|
+
style?: "normal" | "italic" | "oblique" | undefined;
|
|
272
|
+
} | undefined;
|
|
273
|
+
})[] | undefined;
|
|
274
|
+
opacity?: number | undefined;
|
|
275
|
+
font?: {
|
|
276
|
+
family?: string | undefined;
|
|
277
|
+
size?: number | undefined;
|
|
278
|
+
weight?: number | "normal" | "bold" | undefined;
|
|
279
|
+
style?: "normal" | "italic" | "oblique" | undefined;
|
|
280
|
+
} | undefined;
|
|
51
281
|
id?: string | undefined;
|
|
52
282
|
rotate?: number | undefined;
|
|
53
|
-
|
|
283
|
+
align?: "left" | "center" | "right" | undefined;
|
|
284
|
+
lineHeight?: number | undefined;
|
|
285
|
+
fillOpacity?: number | undefined;
|
|
286
|
+
drawOpacity?: number | undefined;
|
|
287
|
+
dashed?: boolean | undefined;
|
|
288
|
+
dotted?: boolean | undefined;
|
|
289
|
+
dashArray?: string | undefined;
|
|
290
|
+
roundedCorners?: number | undefined;
|
|
291
|
+
minimumWidth?: number | undefined;
|
|
292
|
+
minimumHeight?: number | undefined;
|
|
293
|
+
minimumSize?: number | undefined;
|
|
294
|
+
scale?: number | undefined;
|
|
295
|
+
xScale?: number | undefined;
|
|
296
|
+
yScale?: number | undefined;
|
|
297
|
+
textColor?: string | undefined;
|
|
298
|
+
innerXSep?: number | undefined;
|
|
299
|
+
innerYSep?: number | undefined;
|
|
300
|
+
outerSep?: number | undefined;
|
|
54
301
|
padding?: number | undefined;
|
|
55
302
|
margin?: number | undefined;
|
|
56
|
-
fontSize?: number | undefined;
|
|
57
303
|
}, {
|
|
58
304
|
type: "node";
|
|
59
305
|
position: [number, number] | import('./position').PolarPosition;
|
|
@@ -61,12 +307,46 @@ export declare const NodeSchema: z.ZodObject<{
|
|
|
61
307
|
shape?: "diamond" | "circle" | "rectangle" | "ellipse" | undefined;
|
|
62
308
|
stroke?: string | undefined;
|
|
63
309
|
strokeWidth?: number | undefined;
|
|
310
|
+
text?: string | (string | {
|
|
311
|
+
text: string;
|
|
312
|
+
fill?: string | undefined;
|
|
313
|
+
opacity?: number | undefined;
|
|
314
|
+
font?: {
|
|
315
|
+
family?: string | undefined;
|
|
316
|
+
size?: number | undefined;
|
|
317
|
+
weight?: number | "normal" | "bold" | undefined;
|
|
318
|
+
style?: "normal" | "italic" | "oblique" | undefined;
|
|
319
|
+
} | undefined;
|
|
320
|
+
})[] | undefined;
|
|
321
|
+
opacity?: number | undefined;
|
|
322
|
+
font?: {
|
|
323
|
+
family?: string | undefined;
|
|
324
|
+
size?: number | undefined;
|
|
325
|
+
weight?: number | "normal" | "bold" | undefined;
|
|
326
|
+
style?: "normal" | "italic" | "oblique" | undefined;
|
|
327
|
+
} | undefined;
|
|
64
328
|
id?: string | undefined;
|
|
65
329
|
rotate?: number | undefined;
|
|
66
|
-
|
|
330
|
+
align?: "left" | "center" | "right" | undefined;
|
|
331
|
+
lineHeight?: number | undefined;
|
|
332
|
+
fillOpacity?: number | undefined;
|
|
333
|
+
drawOpacity?: number | undefined;
|
|
334
|
+
dashed?: boolean | undefined;
|
|
335
|
+
dotted?: boolean | undefined;
|
|
336
|
+
dashArray?: string | undefined;
|
|
337
|
+
roundedCorners?: number | undefined;
|
|
338
|
+
minimumWidth?: number | undefined;
|
|
339
|
+
minimumHeight?: number | undefined;
|
|
340
|
+
minimumSize?: number | undefined;
|
|
341
|
+
scale?: number | undefined;
|
|
342
|
+
xScale?: number | undefined;
|
|
343
|
+
yScale?: number | undefined;
|
|
344
|
+
textColor?: string | undefined;
|
|
345
|
+
innerXSep?: number | undefined;
|
|
346
|
+
innerYSep?: number | undefined;
|
|
347
|
+
outerSep?: number | undefined;
|
|
67
348
|
padding?: number | undefined;
|
|
68
349
|
margin?: number | undefined;
|
|
69
|
-
fontSize?: number | undefined;
|
|
70
350
|
}>;
|
|
71
351
|
/** 节点:可定位的形状容器(矩形 / 圆 / 椭圆 / 菱形)+ 可选文本标签 */
|
|
72
352
|
export type IRNode = z.infer<typeof NodeSchema>;
|