@retikz/core 0.1.0-alpha.3 → 0.1.0-alpha.4

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 (57) hide show
  1. package/dist/es/compile/compile.d.ts +6 -0
  2. package/dist/es/compile/compile.d.ts.map +1 -1
  3. package/dist/es/compile/compile.js +30 -1
  4. package/dist/es/compile/node.d.ts +23 -2
  5. package/dist/es/compile/node.d.ts.map +1 -1
  6. package/dist/es/compile/node.js +94 -4
  7. package/dist/es/compile/position.d.ts +8 -5
  8. package/dist/es/compile/position.d.ts.map +1 -1
  9. package/dist/es/compile/position.js +32 -5
  10. package/dist/es/index.d.ts +2 -2
  11. package/dist/es/index.d.ts.map +1 -1
  12. package/dist/es/index.js +4 -2
  13. package/dist/es/ir/coordinate.d.ts +57 -0
  14. package/dist/es/ir/coordinate.d.ts.map +1 -0
  15. package/dist/es/ir/coordinate.js +27 -0
  16. package/dist/es/ir/index.d.ts +1 -0
  17. package/dist/es/ir/index.d.ts.map +1 -1
  18. package/dist/es/ir/node.d.ts +264 -5
  19. package/dist/es/ir/node.d.ts.map +1 -1
  20. package/dist/es/ir/node.js +28 -3
  21. package/dist/es/ir/position/at-position.d.ts +50 -0
  22. package/dist/es/ir/position/at-position.d.ts.map +1 -0
  23. package/dist/es/ir/position/at-position.js +30 -0
  24. package/dist/es/ir/position/index.d.ts +1 -0
  25. package/dist/es/ir/position/index.d.ts.map +1 -1
  26. package/dist/es/ir/scene.d.ts +551 -15
  27. package/dist/es/ir/scene.d.ts.map +1 -1
  28. package/dist/es/ir/scene.js +6 -1
  29. package/dist/lib/compile/compile.cjs +30 -1
  30. package/dist/lib/compile/compile.d.ts +6 -0
  31. package/dist/lib/compile/compile.d.ts.map +1 -1
  32. package/dist/lib/compile/node.cjs +94 -4
  33. package/dist/lib/compile/node.d.ts +23 -2
  34. package/dist/lib/compile/node.d.ts.map +1 -1
  35. package/dist/lib/compile/position.cjs +32 -5
  36. package/dist/lib/compile/position.d.ts +8 -5
  37. package/dist/lib/compile/position.d.ts.map +1 -1
  38. package/dist/lib/index.cjs +6 -0
  39. package/dist/lib/index.d.ts +2 -2
  40. package/dist/lib/index.d.ts.map +1 -1
  41. package/dist/lib/ir/coordinate.cjs +27 -0
  42. package/dist/lib/ir/coordinate.d.ts +57 -0
  43. package/dist/lib/ir/coordinate.d.ts.map +1 -0
  44. package/dist/lib/ir/index.d.ts +1 -0
  45. package/dist/lib/ir/index.d.ts.map +1 -1
  46. package/dist/lib/ir/node.cjs +28 -2
  47. package/dist/lib/ir/node.d.ts +264 -5
  48. package/dist/lib/ir/node.d.ts.map +1 -1
  49. package/dist/lib/ir/position/at-position.cjs +31 -0
  50. package/dist/lib/ir/position/at-position.d.ts +50 -0
  51. package/dist/lib/ir/position/at-position.d.ts.map +1 -0
  52. package/dist/lib/ir/position/index.d.ts +1 -0
  53. package/dist/lib/ir/position/index.d.ts.map +1 -1
  54. package/dist/lib/ir/scene.cjs +6 -1
  55. package/dist/lib/ir/scene.d.ts +551 -15
  56. package/dist/lib/ir/scene.d.ts.map +1 -1
  57. package/package.json +1 -1
@@ -157,6 +157,75 @@ export declare const NODE_TEXT_ALIGNS: {
157
157
  };
158
158
  /** 多行文本对齐字面量类型 */
159
159
  export type NodeTextAlign = ValueOf<typeof NODE_TEXT_ALIGNS>;
160
+ /**
161
+ * 节点附属标签(label)——TikZ `[label=above:foo]` / `[label={[red]30:foo}]` 同义。
162
+ *
163
+ * 一个 Node 可挂多个 label(数组形态);label 自身不参与 viewBox(视觉外延少时可接受)。
164
+ *
165
+ * `position` 接受两种形态:
166
+ * - 8 方向枚举(`above` / `right` / `above-left` ...):标签贴在 node 该方向边界外
167
+ * - 数字角度:以 node 中心为原点,按该角度方向投射;约定与 polar 一致(0° = +x,90° = +y 屏幕下方)
168
+ *
169
+ * 默认 `position = 'above'`,`distance = 4`(user units,标签与 node 边界的距离)。
170
+ */
171
+ export declare const NodeLabelSchema: z.ZodObject<{
172
+ text: z.ZodString;
173
+ position: z.ZodOptional<z.ZodUnion<[z.ZodNativeEnum<{
174
+ readonly above: "above";
175
+ readonly below: "below";
176
+ readonly left: "left";
177
+ readonly right: "right";
178
+ readonly 'above-left': "above-left";
179
+ readonly 'above-right': "above-right";
180
+ readonly 'below-left': "below-left";
181
+ readonly 'below-right': "below-right";
182
+ }>, z.ZodNumber]>>;
183
+ distance: z.ZodOptional<z.ZodNumber>;
184
+ textColor: z.ZodOptional<z.ZodString>;
185
+ opacity: z.ZodOptional<z.ZodNumber>;
186
+ font: z.ZodOptional<z.ZodObject<{
187
+ family: z.ZodOptional<z.ZodString>;
188
+ size: z.ZodOptional<z.ZodNumber>;
189
+ weight: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["normal", "bold"]>, z.ZodNumber]>>;
190
+ style: z.ZodOptional<z.ZodEnum<["normal", "italic", "oblique"]>>;
191
+ }, "strip", z.ZodTypeAny, {
192
+ family?: string | undefined;
193
+ size?: number | undefined;
194
+ weight?: number | "normal" | "bold" | undefined;
195
+ style?: "normal" | "italic" | "oblique" | undefined;
196
+ }, {
197
+ family?: string | undefined;
198
+ size?: number | undefined;
199
+ weight?: number | "normal" | "bold" | undefined;
200
+ style?: "normal" | "italic" | "oblique" | undefined;
201
+ }>>;
202
+ }, "strip", z.ZodTypeAny, {
203
+ text: string;
204
+ distance?: number | undefined;
205
+ position?: number | "above" | "below" | "left" | "right" | "above-left" | "above-right" | "below-left" | "below-right" | undefined;
206
+ opacity?: number | undefined;
207
+ font?: {
208
+ family?: string | undefined;
209
+ size?: number | undefined;
210
+ weight?: number | "normal" | "bold" | undefined;
211
+ style?: "normal" | "italic" | "oblique" | undefined;
212
+ } | undefined;
213
+ textColor?: string | undefined;
214
+ }, {
215
+ text: string;
216
+ distance?: number | undefined;
217
+ position?: number | "above" | "below" | "left" | "right" | "above-left" | "above-right" | "below-left" | "below-right" | undefined;
218
+ opacity?: number | undefined;
219
+ font?: {
220
+ family?: string | undefined;
221
+ size?: number | undefined;
222
+ weight?: number | "normal" | "bold" | undefined;
223
+ style?: "normal" | "italic" | "oblique" | undefined;
224
+ } | undefined;
225
+ textColor?: string | undefined;
226
+ }>;
227
+ /** Node label IR 类型——单条 label 的字段集 */
228
+ export type IRNodeLabel = z.infer<typeof NodeLabelSchema>;
160
229
  export declare const NodeSchema: z.ZodObject<{
161
230
  type: z.ZodLiteral<"node">;
162
231
  id: z.ZodOptional<z.ZodString>;
@@ -166,7 +235,28 @@ export declare const NodeSchema: z.ZodObject<{
166
235
  readonly ellipse: "ellipse";
167
236
  readonly diamond: "diamond";
168
237
  }>>;
169
- position: z.ZodUnion<[z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>, z.ZodType<import('./position').PolarPosition, z.ZodTypeDef, import('./position').PolarPosition>]>;
238
+ position: z.ZodUnion<[z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>, z.ZodType<import('./position').PolarPosition, z.ZodTypeDef, import('./position').PolarPosition>, z.ZodObject<{
239
+ direction: z.ZodNativeEnum<{
240
+ readonly above: "above";
241
+ readonly below: "below";
242
+ readonly left: "left";
243
+ readonly right: "right";
244
+ readonly 'above-left': "above-left";
245
+ readonly 'above-right': "above-right";
246
+ readonly 'below-left': "below-left";
247
+ readonly 'below-right': "below-right";
248
+ }>;
249
+ of: z.ZodString;
250
+ distance: z.ZodOptional<z.ZodNumber>;
251
+ }, "strip", z.ZodTypeAny, {
252
+ direction: "above" | "below" | "left" | "right" | "above-left" | "above-right" | "below-left" | "below-right";
253
+ of: string;
254
+ distance?: number | undefined;
255
+ }, {
256
+ direction: "above" | "below" | "left" | "right" | "above-left" | "above-right" | "below-left" | "below-right";
257
+ of: string;
258
+ distance?: number | undefined;
259
+ }>]>;
170
260
  rotate: z.ZodOptional<z.ZodNumber>;
171
261
  text: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodObject<{
172
262
  text: z.ZodString;
@@ -253,9 +343,124 @@ export declare const NodeSchema: z.ZodObject<{
253
343
  weight?: number | "normal" | "bold" | undefined;
254
344
  style?: "normal" | "italic" | "oblique" | undefined;
255
345
  }>>;
346
+ label: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
347
+ text: z.ZodString;
348
+ position: z.ZodOptional<z.ZodUnion<[z.ZodNativeEnum<{
349
+ readonly above: "above";
350
+ readonly below: "below";
351
+ readonly left: "left";
352
+ readonly right: "right";
353
+ readonly 'above-left': "above-left";
354
+ readonly 'above-right': "above-right";
355
+ readonly 'below-left': "below-left";
356
+ readonly 'below-right': "below-right";
357
+ }>, z.ZodNumber]>>;
358
+ distance: z.ZodOptional<z.ZodNumber>;
359
+ textColor: z.ZodOptional<z.ZodString>;
360
+ opacity: z.ZodOptional<z.ZodNumber>;
361
+ font: z.ZodOptional<z.ZodObject<{
362
+ family: z.ZodOptional<z.ZodString>;
363
+ size: z.ZodOptional<z.ZodNumber>;
364
+ weight: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["normal", "bold"]>, z.ZodNumber]>>;
365
+ style: z.ZodOptional<z.ZodEnum<["normal", "italic", "oblique"]>>;
366
+ }, "strip", z.ZodTypeAny, {
367
+ family?: string | undefined;
368
+ size?: number | undefined;
369
+ weight?: number | "normal" | "bold" | undefined;
370
+ style?: "normal" | "italic" | "oblique" | undefined;
371
+ }, {
372
+ family?: string | undefined;
373
+ size?: number | undefined;
374
+ weight?: number | "normal" | "bold" | undefined;
375
+ style?: "normal" | "italic" | "oblique" | undefined;
376
+ }>>;
377
+ }, "strip", z.ZodTypeAny, {
378
+ text: string;
379
+ distance?: number | undefined;
380
+ position?: number | "above" | "below" | "left" | "right" | "above-left" | "above-right" | "below-left" | "below-right" | undefined;
381
+ opacity?: number | undefined;
382
+ font?: {
383
+ family?: string | undefined;
384
+ size?: number | undefined;
385
+ weight?: number | "normal" | "bold" | undefined;
386
+ style?: "normal" | "italic" | "oblique" | undefined;
387
+ } | undefined;
388
+ textColor?: string | undefined;
389
+ }, {
390
+ text: string;
391
+ distance?: number | undefined;
392
+ position?: number | "above" | "below" | "left" | "right" | "above-left" | "above-right" | "below-left" | "below-right" | undefined;
393
+ opacity?: number | undefined;
394
+ font?: {
395
+ family?: string | undefined;
396
+ size?: number | undefined;
397
+ weight?: number | "normal" | "bold" | undefined;
398
+ style?: "normal" | "italic" | "oblique" | undefined;
399
+ } | undefined;
400
+ textColor?: string | undefined;
401
+ }>, z.ZodArray<z.ZodObject<{
402
+ text: z.ZodString;
403
+ position: z.ZodOptional<z.ZodUnion<[z.ZodNativeEnum<{
404
+ readonly above: "above";
405
+ readonly below: "below";
406
+ readonly left: "left";
407
+ readonly right: "right";
408
+ readonly 'above-left': "above-left";
409
+ readonly 'above-right': "above-right";
410
+ readonly 'below-left': "below-left";
411
+ readonly 'below-right': "below-right";
412
+ }>, z.ZodNumber]>>;
413
+ distance: z.ZodOptional<z.ZodNumber>;
414
+ textColor: z.ZodOptional<z.ZodString>;
415
+ opacity: z.ZodOptional<z.ZodNumber>;
416
+ font: z.ZodOptional<z.ZodObject<{
417
+ family: z.ZodOptional<z.ZodString>;
418
+ size: z.ZodOptional<z.ZodNumber>;
419
+ weight: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["normal", "bold"]>, z.ZodNumber]>>;
420
+ style: z.ZodOptional<z.ZodEnum<["normal", "italic", "oblique"]>>;
421
+ }, "strip", z.ZodTypeAny, {
422
+ family?: string | undefined;
423
+ size?: number | undefined;
424
+ weight?: number | "normal" | "bold" | undefined;
425
+ style?: "normal" | "italic" | "oblique" | undefined;
426
+ }, {
427
+ family?: string | undefined;
428
+ size?: number | undefined;
429
+ weight?: number | "normal" | "bold" | undefined;
430
+ style?: "normal" | "italic" | "oblique" | undefined;
431
+ }>>;
432
+ }, "strip", z.ZodTypeAny, {
433
+ text: string;
434
+ distance?: number | undefined;
435
+ position?: number | "above" | "below" | "left" | "right" | "above-left" | "above-right" | "below-left" | "below-right" | undefined;
436
+ opacity?: number | undefined;
437
+ font?: {
438
+ family?: string | undefined;
439
+ size?: number | undefined;
440
+ weight?: number | "normal" | "bold" | undefined;
441
+ style?: "normal" | "italic" | "oblique" | undefined;
442
+ } | undefined;
443
+ textColor?: string | undefined;
444
+ }, {
445
+ text: string;
446
+ distance?: number | undefined;
447
+ position?: number | "above" | "below" | "left" | "right" | "above-left" | "above-right" | "below-left" | "below-right" | undefined;
448
+ opacity?: number | undefined;
449
+ font?: {
450
+ family?: string | undefined;
451
+ size?: number | undefined;
452
+ weight?: number | "normal" | "bold" | undefined;
453
+ style?: "normal" | "italic" | "oblique" | undefined;
454
+ } | undefined;
455
+ textColor?: string | undefined;
456
+ }>, "many">]>>;
256
457
  }, "strip", z.ZodTypeAny, {
257
458
  type: "node";
258
- position: [number, number] | import('./position').PolarPosition;
459
+ position: [number, number] | import('./position').PolarPosition | {
460
+ direction: "above" | "below" | "left" | "right" | "above-left" | "above-right" | "below-left" | "below-right";
461
+ of: string;
462
+ distance?: number | undefined;
463
+ };
259
464
  fill?: string | undefined;
260
465
  text?: string | (string | {
261
466
  text: string;
@@ -268,6 +473,31 @@ export declare const NodeSchema: z.ZodObject<{
268
473
  style?: "normal" | "italic" | "oblique" | undefined;
269
474
  } | undefined;
270
475
  })[] | undefined;
476
+ label?: {
477
+ text: string;
478
+ distance?: number | undefined;
479
+ position?: number | "above" | "below" | "left" | "right" | "above-left" | "above-right" | "below-left" | "below-right" | undefined;
480
+ opacity?: number | undefined;
481
+ font?: {
482
+ family?: string | undefined;
483
+ size?: number | undefined;
484
+ weight?: number | "normal" | "bold" | undefined;
485
+ style?: "normal" | "italic" | "oblique" | undefined;
486
+ } | undefined;
487
+ textColor?: string | undefined;
488
+ } | {
489
+ text: string;
490
+ distance?: number | undefined;
491
+ position?: number | "above" | "below" | "left" | "right" | "above-left" | "above-right" | "below-left" | "below-right" | undefined;
492
+ opacity?: number | undefined;
493
+ font?: {
494
+ family?: string | undefined;
495
+ size?: number | undefined;
496
+ weight?: number | "normal" | "bold" | undefined;
497
+ style?: "normal" | "italic" | "oblique" | undefined;
498
+ } | undefined;
499
+ textColor?: string | undefined;
500
+ }[] | undefined;
271
501
  shape?: "diamond" | "circle" | "rectangle" | "ellipse" | undefined;
272
502
  stroke?: string | undefined;
273
503
  strokeWidth?: number | undefined;
@@ -280,6 +510,7 @@ export declare const NodeSchema: z.ZodObject<{
280
510
  weight?: number | "normal" | "bold" | undefined;
281
511
  style?: "normal" | "italic" | "oblique" | undefined;
282
512
  } | undefined;
513
+ textColor?: string | undefined;
283
514
  id?: string | undefined;
284
515
  rotate?: number | undefined;
285
516
  align?: "left" | "right" | "center" | undefined;
@@ -294,7 +525,6 @@ export declare const NodeSchema: z.ZodObject<{
294
525
  scale?: number | undefined;
295
526
  xScale?: number | undefined;
296
527
  yScale?: number | undefined;
297
- textColor?: string | undefined;
298
528
  innerXSep?: number | undefined;
299
529
  innerYSep?: number | undefined;
300
530
  outerSep?: number | undefined;
@@ -302,7 +532,11 @@ export declare const NodeSchema: z.ZodObject<{
302
532
  margin?: number | undefined;
303
533
  }, {
304
534
  type: "node";
305
- position: [number, number] | import('./position').PolarPosition;
535
+ position: [number, number] | import('./position').PolarPosition | {
536
+ direction: "above" | "below" | "left" | "right" | "above-left" | "above-right" | "below-left" | "below-right";
537
+ of: string;
538
+ distance?: number | undefined;
539
+ };
306
540
  fill?: string | undefined;
307
541
  text?: string | (string | {
308
542
  text: string;
@@ -315,6 +549,31 @@ export declare const NodeSchema: z.ZodObject<{
315
549
  style?: "normal" | "italic" | "oblique" | undefined;
316
550
  } | undefined;
317
551
  })[] | undefined;
552
+ label?: {
553
+ text: string;
554
+ distance?: number | undefined;
555
+ position?: number | "above" | "below" | "left" | "right" | "above-left" | "above-right" | "below-left" | "below-right" | undefined;
556
+ opacity?: number | undefined;
557
+ font?: {
558
+ family?: string | undefined;
559
+ size?: number | undefined;
560
+ weight?: number | "normal" | "bold" | undefined;
561
+ style?: "normal" | "italic" | "oblique" | undefined;
562
+ } | undefined;
563
+ textColor?: string | undefined;
564
+ } | {
565
+ text: string;
566
+ distance?: number | undefined;
567
+ position?: number | "above" | "below" | "left" | "right" | "above-left" | "above-right" | "below-left" | "below-right" | undefined;
568
+ opacity?: number | undefined;
569
+ font?: {
570
+ family?: string | undefined;
571
+ size?: number | undefined;
572
+ weight?: number | "normal" | "bold" | undefined;
573
+ style?: "normal" | "italic" | "oblique" | undefined;
574
+ } | undefined;
575
+ textColor?: string | undefined;
576
+ }[] | undefined;
318
577
  shape?: "diamond" | "circle" | "rectangle" | "ellipse" | undefined;
319
578
  stroke?: string | undefined;
320
579
  strokeWidth?: number | undefined;
@@ -327,6 +586,7 @@ export declare const NodeSchema: z.ZodObject<{
327
586
  weight?: number | "normal" | "bold" | undefined;
328
587
  style?: "normal" | "italic" | "oblique" | undefined;
329
588
  } | undefined;
589
+ textColor?: string | undefined;
330
590
  id?: string | undefined;
331
591
  rotate?: number | undefined;
332
592
  align?: "left" | "right" | "center" | undefined;
@@ -341,7 +601,6 @@ export declare const NodeSchema: z.ZodObject<{
341
601
  scale?: number | undefined;
342
602
  xScale?: number | undefined;
343
603
  yScale?: number | undefined;
344
- textColor?: string | undefined;
345
604
  innerXSep?: number | undefined;
346
605
  innerYSep?: number | undefined;
347
606
  outerSep?: number | undefined;
@@ -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;;;;;GAKG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;EAwBpB,CAAC;AAEJ,oCAAoC;AACpC,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,K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;;;;;;;;;;;EA+KpB,CAAC;AAEJ,4CAA4C;AAC5C,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import { PositionSchema } from "./position/position.js";
2
2
  import { PolarPositionSchema } from "./position/polar-position.js";
3
+ import { AT_DIRECTIONS, AtPositionSchema } from "./position/at-position.js";
3
4
  import { z } from "zod";
4
5
  //#region src/ir/node.ts
5
6
  /**
@@ -70,11 +71,34 @@ var NODE_TEXT_ALIGNS = {
70
71
  center: "center",
71
72
  right: "right"
72
73
  };
74
+ /**
75
+ * 节点附属标签(label)——TikZ `[label=above:foo]` / `[label={[red]30:foo}]` 同义。
76
+ *
77
+ * 一个 Node 可挂多个 label(数组形态);label 自身不参与 viewBox(视觉外延少时可接受)。
78
+ *
79
+ * `position` 接受两种形态:
80
+ * - 8 方向枚举(`above` / `right` / `above-left` ...):标签贴在 node 该方向边界外
81
+ * - 数字角度:以 node 中心为原点,按该角度方向投射;约定与 polar 一致(0° = +x,90° = +y 屏幕下方)
82
+ *
83
+ * 默认 `position = 'above'`,`distance = 4`(user units,标签与 node 边界的距离)。
84
+ */
85
+ var NodeLabelSchema = z.object({
86
+ text: z.string().describe("Label text content; rendered as a single line."),
87
+ position: z.union([z.nativeEnum(AT_DIRECTIONS), z.number()]).optional().describe("Placement around the node border: 8-direction enum (above / right / above-left / ...) or numeric angle in degrees (`label=30:foo` for radial placement). Default `above`. Numeric uses the polar convention (0° = +x, 90° = +y, screen-down)."),
88
+ distance: z.number().nonnegative().optional().describe("Gap between the node border and the label center, in user units. Default 4."),
89
+ textColor: z.string().optional().describe("Label text color; falls back to currentColor."),
90
+ opacity: z.number().min(0).max(1).optional().describe("Label-only opacity 0..1; multiplied with the node opacity if both are set."),
91
+ font: FontSchema.optional().describe("Label font overrides; missing fields inherit from the parent node font, then renderer defaults.")
92
+ }).describe("Extra text attached around a node border. Multiple labels supported via array form on `Node.label`.");
73
93
  var NodeSchema = z.object({
74
94
  type: z.literal("node").describe("Discriminator marking this child as a node"),
75
95
  id: z.string().min(1).optional().describe("Optional unique id; required if any path needs to reference this node by string"),
76
96
  shape: z.nativeEnum(NODE_SHAPES).optional().describe("Node visual shape; defaults to `rectangle`. The boundary fully contains text + padding (circumscribed for circle / ellipse / diamond)."),
77
- position: z.union([PositionSchema, PolarPositionSchema]).describe("Center point of the node content box; Cartesian [x, y] or polar (resolved at compile time)"),
97
+ position: z.union([
98
+ PositionSchema,
99
+ PolarPositionSchema,
100
+ AtPositionSchema
101
+ ]).describe("Center point of the node content box; Cartesian [x, y], polar, or relative-to-another-node (`at`-style with `direction` / `of` / `distance?`). All non-Cartesian forms resolve at compile time."),
78
102
  rotate: z.number().optional().describe("Rotation in degrees around the node center; positive = clockwise (matches TikZ rotate=...)"),
79
103
  text: NodeTextSchema.optional(),
80
104
  align: z.nativeEnum(NODE_TEXT_ALIGNS).optional().describe("Multi-line text alignment within the text block; `left` / `center` / `right`. Defaults to `center` (matches TikZ)."),
@@ -101,7 +125,8 @@ var NodeSchema = z.object({
101
125
  outerSep: z.number().nonnegative().optional().describe("Outer margin from border to path attachment point in user units; does NOT change the visible border. Falls back to `margin`."),
102
126
  padding: z.number().nonnegative().optional().describe("Symmetric inner padding (alias for `innerXSep` + `innerYSep`); axis-specific fields take precedence."),
103
127
  margin: z.number().nonnegative().optional().describe("Symmetric outer margin (alias for `outerSep`); axis-specific field takes precedence."),
104
- font: FontSchema.optional().describe("Font spec for the inner text label (family / size / weight / style); all fields optional, all fall back to renderer defaults.")
128
+ font: FontSchema.optional().describe("Font spec for the inner text label (family / size / weight / style); all fields optional, all fall back to renderer defaults."),
129
+ label: z.union([NodeLabelSchema, z.array(NodeLabelSchema)]).optional().describe("Extra label(s) attached around the node border (TikZ `[label=above:foo]`); single object or array form. Compiled into one TextPrim per label, positioned by `position` direction / angle and `distance`.")
105
130
  }).describe("Node primitive: a positioned, optionally textual shape (rectangle / circle / ellipse / diamond)");
106
131
  //#endregion
107
- export { FontSchema, LineSpecSchema, NODE_SHAPES, NODE_TEXT_ALIGNS, NodeSchema, NodeTextSchema };
132
+ export { FontSchema, LineSpecSchema, NODE_SHAPES, NODE_TEXT_ALIGNS, NodeLabelSchema, NodeSchema, NodeTextSchema };
@@ -0,0 +1,50 @@
1
+ import { z } from 'zod';
2
+ import { ValueOf } from '../../types';
3
+ /**
4
+ * 节点相对方向常量。8 方向(4 主向 + 4 对角),按视觉语义:
5
+ * - above: y 减小(视觉上方)
6
+ * - below: y 增大(视觉下方)
7
+ * - left: x 减小(视觉左方)
8
+ * - right: x 增大(视觉右方)
9
+ * - 4 对角:两轴各 1/√2 单位向量分量(对角距离与 distance 等长)
10
+ *
11
+ * 与 TikZ `positioning` library 的 `above of` / `right of` / `above right of` 对齐
12
+ * (TikZ y 向上、retikz y 向下,但 `above` 视觉语义在两边一致——视觉上方)。
13
+ */
14
+ export declare const AT_DIRECTIONS: {
15
+ readonly above: "above";
16
+ readonly below: "below";
17
+ readonly left: "left";
18
+ readonly right: "right";
19
+ readonly 'above-left': "above-left";
20
+ readonly 'above-right': "above-right";
21
+ readonly 'below-left': "below-left";
22
+ readonly 'below-right': "below-right";
23
+ };
24
+ /** at 方向字面量类型;由 `AT_DIRECTIONS` 派生 */
25
+ export type AtDirection = ValueOf<typeof AT_DIRECTIONS>;
26
+ export declare const AtPositionSchema: z.ZodObject<{
27
+ direction: z.ZodNativeEnum<{
28
+ readonly above: "above";
29
+ readonly below: "below";
30
+ readonly left: "left";
31
+ readonly right: "right";
32
+ readonly 'above-left': "above-left";
33
+ readonly 'above-right': "above-right";
34
+ readonly 'below-left': "below-left";
35
+ readonly 'below-right': "below-right";
36
+ }>;
37
+ of: z.ZodString;
38
+ distance: z.ZodOptional<z.ZodNumber>;
39
+ }, "strip", z.ZodTypeAny, {
40
+ direction: "above" | "below" | "left" | "right" | "above-left" | "above-right" | "below-left" | "below-right";
41
+ of: string;
42
+ distance?: number | undefined;
43
+ }, {
44
+ direction: "above" | "below" | "left" | "right" | "above-left" | "above-right" | "below-left" | "below-right";
45
+ of: string;
46
+ distance?: number | undefined;
47
+ }>;
48
+ /** 相对定位的 IR 类型——`{ direction, of, distance? }`,与 `IRPosition` / `PolarPosition` 在 union 里平级 */
49
+ export type IRAtPosition = z.infer<typeof AtPositionSchema>;
50
+ //# sourceMappingURL=at-position.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"at-position.d.ts","sourceRoot":"","sources":["../../../../src/ir/position/at-position.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C;;;;;;;;;;GAUG;AACH,eAAO,MAAM,aAAa;;;;;;;;;CAShB,CAAC;AAEX,sCAAsC;AACtC,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,aAAa,CAAC,CAAC;AAExD,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;EAuB1B,CAAC;AAEJ,+FAA+F;AAC/F,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { z } from "zod";
2
+ //#region src/ir/position/at-position.ts
3
+ /**
4
+ * 节点相对方向常量。8 方向(4 主向 + 4 对角),按视觉语义:
5
+ * - above: y 减小(视觉上方)
6
+ * - below: y 增大(视觉下方)
7
+ * - left: x 减小(视觉左方)
8
+ * - right: x 增大(视觉右方)
9
+ * - 4 对角:两轴各 1/√2 单位向量分量(对角距离与 distance 等长)
10
+ *
11
+ * 与 TikZ `positioning` library 的 `above of` / `right of` / `above right of` 对齐
12
+ * (TikZ y 向上、retikz y 向下,但 `above` 视觉语义在两边一致——视觉上方)。
13
+ */
14
+ var AT_DIRECTIONS = {
15
+ above: "above",
16
+ below: "below",
17
+ left: "left",
18
+ right: "right",
19
+ "above-left": "above-left",
20
+ "above-right": "above-right",
21
+ "below-left": "below-left",
22
+ "below-right": "below-right"
23
+ };
24
+ var AtPositionSchema = z.object({
25
+ direction: z.nativeEnum(AT_DIRECTIONS).describe("Direction from the referenced node toward this node, in visual convention (above = visually upward, screen y-)."),
26
+ of: z.string().min(1).describe("Id of the referenced node or coordinate; must be defined earlier in the IR (forward references rejected, mirroring polar `origin` and string targets)."),
27
+ distance: z.number().positive().optional().describe("Distance from the referenced node center to this node center in user units. Falls back to the Tikz `nodeDistance` compile-time context, then to 1.")
28
+ }).describe("Relative position: place this node at `direction` direction from `of`, `distance` away. Mirrors TikZ `[<direction>=<distance> of <id>]` from the positioning library.");
29
+ //#endregion
30
+ export { AT_DIRECTIONS, AtPositionSchema };
@@ -1,3 +1,4 @@
1
1
  export * from './position';
2
2
  export * from './polar-position';
3
+ export * from './at-position';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ir/position/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ir/position/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC"}