@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.
Files changed (43) hide show
  1. package/dist/es/compile/node.d.ts +32 -6
  2. package/dist/es/compile/node.d.ts.map +1 -1
  3. package/dist/es/compile/node.js +112 -28
  4. package/dist/es/compile/text-metrics.d.ts +2 -2
  5. package/dist/es/compile/text-metrics.d.ts.map +1 -1
  6. package/dist/es/index.d.ts +4 -4
  7. package/dist/es/index.d.ts.map +1 -1
  8. package/dist/es/index.js +2 -2
  9. package/dist/es/ir/node.d.ts +286 -6
  10. package/dist/es/ir/node.d.ts.map +1 -1
  11. package/dist/es/ir/node.js +71 -5
  12. package/dist/es/ir/scene.d.ts +376 -16
  13. package/dist/es/ir/scene.d.ts.map +1 -1
  14. package/dist/es/primitive/ellipse.d.ts +2 -0
  15. package/dist/es/primitive/ellipse.d.ts.map +1 -1
  16. package/dist/es/primitive/path.d.ts +4 -0
  17. package/dist/es/primitive/path.d.ts.map +1 -1
  18. package/dist/es/primitive/rect.d.ts +2 -0
  19. package/dist/es/primitive/rect.d.ts.map +1 -1
  20. package/dist/es/primitive/text.d.ts +43 -13
  21. package/dist/es/primitive/text.d.ts.map +1 -1
  22. package/dist/lib/compile/node.cjs +112 -28
  23. package/dist/lib/compile/node.d.ts +32 -6
  24. package/dist/lib/compile/node.d.ts.map +1 -1
  25. package/dist/lib/compile/text-metrics.d.ts +2 -2
  26. package/dist/lib/compile/text-metrics.d.ts.map +1 -1
  27. package/dist/lib/index.cjs +4 -0
  28. package/dist/lib/index.d.ts +4 -4
  29. package/dist/lib/index.d.ts.map +1 -1
  30. package/dist/lib/ir/node.cjs +74 -4
  31. package/dist/lib/ir/node.d.ts +286 -6
  32. package/dist/lib/ir/node.d.ts.map +1 -1
  33. package/dist/lib/ir/scene.d.ts +376 -16
  34. package/dist/lib/ir/scene.d.ts.map +1 -1
  35. package/dist/lib/primitive/ellipse.d.ts +2 -0
  36. package/dist/lib/primitive/ellipse.d.ts.map +1 -1
  37. package/dist/lib/primitive/path.d.ts +4 -0
  38. package/dist/lib/primitive/path.d.ts.map +1 -1
  39. package/dist/lib/primitive/rect.d.ts +2 -0
  40. package/dist/lib/primitive/rect.d.ts.map +1 -1
  41. package/dist/lib/primitive/text.d.ts +43 -13
  42. package/dist/lib/primitive/text.d.ts.map +1 -1
  43. package/package.json +1 -1
@@ -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
- fontSize: z.ZodOptional<z.ZodNumber>;
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
- text?: string | undefined;
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
- text?: string | undefined;
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>;
@@ -1 +1 @@
1
- {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../src/ir/node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAGxC;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,WAAW;;;;;CAKd,CAAC;AAEX,mCAAmC;AACnC,MAAM,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC;AAEpD,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuEpB,CAAC;AAEJ,4CAA4C;AAC5C,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC"}
1
+ {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../src/ir/node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAGxC;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,WAAW;;;;;CAKd,CAAC;AAEX,mCAAmC;AACnC,MAAM,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC;AAEpD;;;;;GAKG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;EAwBpB,CAAC;AAEJ,oCAAoC;AACpC,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAEhD;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAsBxB,CAAC;AAEJ,4BAA4B;AAC5B,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAExD;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAIxB,CAAC;AAEJ,yCAAyC;AACzC,eAAO,MAAM,gBAAgB;;;;CAInB,CAAC;AAEX,kBAAkB;AAClB,MAAM,MAAM,aAAa,GAAG,OAAO,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE7D,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyKpB,CAAC;AAEJ,4CAA4C;AAC5C,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC"}