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

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 (107) hide show
  1. package/dist/es/compile/compile.js +3 -3
  2. package/dist/es/compile/node.d.ts +32 -6
  3. package/dist/es/compile/node.d.ts.map +1 -1
  4. package/dist/es/compile/node.js +112 -28
  5. package/dist/es/compile/path.d.ts +3 -2
  6. package/dist/es/compile/path.d.ts.map +1 -1
  7. package/dist/es/compile/path.js +333 -14
  8. package/dist/es/compile/text-metrics.d.ts +2 -2
  9. package/dist/es/compile/text-metrics.d.ts.map +1 -1
  10. package/dist/es/geometry/arc.d.ts +34 -0
  11. package/dist/es/geometry/arc.d.ts.map +1 -0
  12. package/dist/es/geometry/arc.js +53 -0
  13. package/dist/es/geometry/bend.d.ts +18 -0
  14. package/dist/es/geometry/bend.d.ts.map +1 -0
  15. package/dist/es/geometry/bend.js +29 -0
  16. package/dist/es/geometry/index.d.ts +3 -0
  17. package/dist/es/geometry/index.d.ts.map +1 -1
  18. package/dist/es/geometry/segment.d.ts +38 -0
  19. package/dist/es/geometry/segment.d.ts.map +1 -0
  20. package/dist/es/geometry/segment.js +82 -0
  21. package/dist/es/index.d.ts +6 -6
  22. package/dist/es/index.d.ts.map +1 -1
  23. package/dist/es/index.js +5 -4
  24. package/dist/es/ir/node.d.ts +286 -6
  25. package/dist/es/ir/node.d.ts.map +1 -1
  26. package/dist/es/ir/node.js +71 -5
  27. package/dist/es/ir/path/path.d.ts +625 -15
  28. package/dist/es/ir/path/path.d.ts.map +1 -1
  29. package/dist/es/ir/path/path.js +22 -0
  30. package/dist/es/ir/path/step.d.ts +872 -20
  31. package/dist/es/ir/path/step.d.ts.map +1 -1
  32. package/dist/es/ir/path/step.js +86 -4
  33. package/dist/es/ir/path/target.d.ts +32 -2
  34. package/dist/es/ir/path/target.d.ts.map +1 -1
  35. package/dist/es/ir/path/target.js +7 -3
  36. package/dist/es/ir/scene.d.ts +1836 -52
  37. package/dist/es/ir/scene.d.ts.map +1 -1
  38. package/dist/es/parsers/index.d.ts +1 -0
  39. package/dist/es/parsers/index.d.ts.map +1 -1
  40. package/dist/es/parsers/parseTargetSugar.d.ts +3 -0
  41. package/dist/es/parsers/parseTargetSugar.d.ts.map +1 -0
  42. package/dist/es/parsers/parseTargetSugar.js +31 -0
  43. package/dist/es/parsers/parseWay.d.ts +131 -22
  44. package/dist/es/parsers/parseWay.d.ts.map +1 -1
  45. package/dist/es/parsers/parseWay.js +149 -17
  46. package/dist/es/primitive/ellipse.d.ts +2 -0
  47. package/dist/es/primitive/ellipse.d.ts.map +1 -1
  48. package/dist/es/primitive/path.d.ts +4 -0
  49. package/dist/es/primitive/path.d.ts.map +1 -1
  50. package/dist/es/primitive/rect.d.ts +2 -0
  51. package/dist/es/primitive/rect.d.ts.map +1 -1
  52. package/dist/es/primitive/text.d.ts +43 -13
  53. package/dist/es/primitive/text.d.ts.map +1 -1
  54. package/dist/lib/compile/compile.cjs +3 -3
  55. package/dist/lib/compile/node.cjs +112 -28
  56. package/dist/lib/compile/node.d.ts +32 -6
  57. package/dist/lib/compile/node.d.ts.map +1 -1
  58. package/dist/lib/compile/path.cjs +333 -14
  59. package/dist/lib/compile/path.d.ts +3 -2
  60. package/dist/lib/compile/path.d.ts.map +1 -1
  61. package/dist/lib/compile/text-metrics.d.ts +2 -2
  62. package/dist/lib/compile/text-metrics.d.ts.map +1 -1
  63. package/dist/lib/geometry/arc.cjs +55 -0
  64. package/dist/lib/geometry/arc.d.ts +34 -0
  65. package/dist/lib/geometry/arc.d.ts.map +1 -0
  66. package/dist/lib/geometry/bend.cjs +29 -0
  67. package/dist/lib/geometry/bend.d.ts +18 -0
  68. package/dist/lib/geometry/bend.d.ts.map +1 -0
  69. package/dist/lib/geometry/index.d.ts +3 -0
  70. package/dist/lib/geometry/index.d.ts.map +1 -1
  71. package/dist/lib/geometry/segment.cjs +88 -0
  72. package/dist/lib/geometry/segment.d.ts +38 -0
  73. package/dist/lib/geometry/segment.d.ts.map +1 -0
  74. package/dist/lib/index.cjs +16 -0
  75. package/dist/lib/index.d.ts +6 -6
  76. package/dist/lib/index.d.ts.map +1 -1
  77. package/dist/lib/ir/node.cjs +74 -4
  78. package/dist/lib/ir/node.d.ts +286 -6
  79. package/dist/lib/ir/node.d.ts.map +1 -1
  80. package/dist/lib/ir/path/path.cjs +22 -0
  81. package/dist/lib/ir/path/path.d.ts +625 -15
  82. package/dist/lib/ir/path/path.d.ts.map +1 -1
  83. package/dist/lib/ir/path/step.cjs +93 -3
  84. package/dist/lib/ir/path/step.d.ts +872 -20
  85. package/dist/lib/ir/path/step.d.ts.map +1 -1
  86. package/dist/lib/ir/path/target.cjs +8 -2
  87. package/dist/lib/ir/path/target.d.ts +32 -2
  88. package/dist/lib/ir/path/target.d.ts.map +1 -1
  89. package/dist/lib/ir/scene.d.ts +1836 -52
  90. package/dist/lib/ir/scene.d.ts.map +1 -1
  91. package/dist/lib/parsers/index.d.ts +1 -0
  92. package/dist/lib/parsers/index.d.ts.map +1 -1
  93. package/dist/lib/parsers/parseTargetSugar.cjs +31 -0
  94. package/dist/lib/parsers/parseTargetSugar.d.ts +3 -0
  95. package/dist/lib/parsers/parseTargetSugar.d.ts.map +1 -0
  96. package/dist/lib/parsers/parseWay.cjs +149 -17
  97. package/dist/lib/parsers/parseWay.d.ts +131 -22
  98. package/dist/lib/parsers/parseWay.d.ts.map +1 -1
  99. package/dist/lib/primitive/ellipse.d.ts +2 -0
  100. package/dist/lib/primitive/ellipse.d.ts.map +1 -1
  101. package/dist/lib/primitive/path.d.ts +4 -0
  102. package/dist/lib/primitive/path.d.ts.map +1 -1
  103. package/dist/lib/primitive/rect.d.ts +2 -0
  104. package/dist/lib/primitive/rect.d.ts.map +1 -1
  105. package/dist/lib/primitive/text.d.ts +43 -13
  106. package/dist/lib/primitive/text.d.ts.map +1 -1
  107. package/package.json +1 -1
@@ -0,0 +1,38 @@
1
+ import { Position } from './point';
2
+ export type SegmentSample = {
3
+ /** t 处的点坐标 */
4
+ point: Position;
5
+ /** t 处的切线方向(单位向量;零向量时回退到 [1, 0]) */
6
+ tangent: Position;
7
+ };
8
+ /** 直线段 from → to */
9
+ export declare const lineSegmentSample: (from: Position, to: Position, t: number) => SegmentSample;
10
+ /**
11
+ * 二次贝塞尔 from → control → to。
12
+ * P(t) = (1-t)²·P0 + 2(1-t)t·P1 + t²·P2
13
+ * P'(t) = 2(1-t)(P1-P0) + 2t(P2-P1)
14
+ */
15
+ export declare const quadSegmentSample: (from: Position, control: Position, to: Position, t: number) => SegmentSample;
16
+ /**
17
+ * 三次贝塞尔 from → c1 → c2 → to。
18
+ * P'(t) = 3(1-t)²(P1-P0) + 6(1-t)t(P2-P1) + 3t²(P3-P2)
19
+ */
20
+ export declare const cubicSegmentSample: (from: Position, c1: Position, c2: Position, to: Position, t: number) => SegmentSample;
21
+ /**
22
+ * 折角段 from → corner → to。
23
+ * t∈[0, 0.5] 走第一段(参数 2t);t∈(0.5, 1] 走第二段(参数 2t-1)。
24
+ * t=0.5 落在 corner,切线取第一段方向(与"靠近 prev 一侧"一致)。
25
+ */
26
+ export declare const foldSegmentSample: (from: Position, corner: Position, to: Position, t: number) => SegmentSample;
27
+ /**
28
+ * 弧段(与 ir/path arc 同约定,角度单位为度)。
29
+ * 切线沿"扫描方向"——endAngle ≥ startAngle 时为 (-sin, cos),否则反向。
30
+ */
31
+ export declare const arcSegmentSample: (center: Position, radius: number, startAngleDeg: number, endAngleDeg: number, t: number) => SegmentSample;
32
+ /**
33
+ * 整圆——从 0°(east)开始,与 compile/path circlePath 输出方向(右→左→右,sweep=1)一致。
34
+ */
35
+ export declare const circleSegmentSample: (center: Position, radius: number, t: number) => SegmentSample;
36
+ /** 整椭圆——参数化 (rx·cos(2πt), ry·sin(2πt)) */
37
+ export declare const ellipseSegmentSample: (center: Position, rx: number, ry: number, t: number) => SegmentSample;
38
+ //# sourceMappingURL=segment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"segment.d.ts","sourceRoot":"","sources":["../../../src/geometry/segment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAuBxC,MAAM,MAAM,aAAa,GAAG;IAC1B,cAAc;IACd,KAAK,EAAE,QAAQ,CAAC;IAChB,oCAAoC;IACpC,OAAO,EAAE,QAAQ,CAAC;CACnB,CAAC;AAQF,oBAAoB;AACpB,eAAO,MAAM,iBAAiB,GAC5B,MAAM,QAAQ,EACd,IAAI,QAAQ,EACZ,GAAG,MAAM,KACR,aAGD,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAC5B,MAAM,QAAQ,EACd,SAAS,QAAQ,EACjB,IAAI,QAAQ,EACZ,GAAG,MAAM,KACR,aASF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAC7B,MAAM,QAAQ,EACd,IAAI,QAAQ,EACZ,IAAI,QAAQ,EACZ,IAAI,QAAQ,EACZ,GAAG,MAAM,KACR,aAqBF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAC5B,MAAM,QAAQ,EACd,QAAQ,QAAQ,EAChB,IAAI,QAAQ,EACZ,GAAG,MAAM,KACR,aAGF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,gBAAgB,GAC3B,QAAQ,QAAQ,EAChB,QAAQ,MAAM,EACd,eAAe,MAAM,EACrB,aAAa,MAAM,EACnB,GAAG,MAAM,KACR,aAUF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,GAC9B,QAAQ,QAAQ,EAChB,QAAQ,MAAM,EACd,GAAG,MAAM,KACR,aASF,CAAC;AAEF,0CAA0C;AAC1C,eAAO,MAAM,oBAAoB,GAC/B,QAAQ,QAAQ,EAChB,IAAI,MAAM,EACV,IAAI,MAAM,EACV,GAAG,MAAM,KACR,aASF,CAAC"}
@@ -0,0 +1,82 @@
1
+ //#region src/geometry/segment.ts
2
+ var DEG_TO_RAD = Math.PI / 180;
3
+ var normalize = (v) => {
4
+ const len = Math.hypot(v[0], v[1]);
5
+ if (len === 0) return [1, 0];
6
+ return [v[0] / len, v[1] / len];
7
+ };
8
+ /** 直线段 from → to */
9
+ var lineSegmentSample = (from, to, t) => ({
10
+ point: [from[0] + (to[0] - from[0]) * t, from[1] + (to[1] - from[1]) * t],
11
+ tangent: normalize([to[0] - from[0], to[1] - from[1]])
12
+ });
13
+ /**
14
+ * 二次贝塞尔 from → control → to。
15
+ * P(t) = (1-t)²·P0 + 2(1-t)t·P1 + t²·P2
16
+ * P'(t) = 2(1-t)(P1-P0) + 2t(P2-P1)
17
+ */
18
+ var quadSegmentSample = (from, control, to, t) => {
19
+ const u = 1 - t;
20
+ return {
21
+ point: [u * u * from[0] + 2 * u * t * control[0] + t * t * to[0], u * u * from[1] + 2 * u * t * control[1] + t * t * to[1]],
22
+ tangent: normalize([2 * u * (control[0] - from[0]) + 2 * t * (to[0] - control[0]), 2 * u * (control[1] - from[1]) + 2 * t * (to[1] - control[1])])
23
+ };
24
+ };
25
+ /**
26
+ * 三次贝塞尔 from → c1 → c2 → to。
27
+ * P'(t) = 3(1-t)²(P1-P0) + 6(1-t)t(P2-P1) + 3t²(P3-P2)
28
+ */
29
+ var cubicSegmentSample = (from, c1, c2, to, t) => {
30
+ const u = 1 - t;
31
+ return {
32
+ point: [u * u * u * from[0] + 3 * u * u * t * c1[0] + 3 * u * t * t * c2[0] + t * t * t * to[0], u * u * u * from[1] + 3 * u * u * t * c1[1] + 3 * u * t * t * c2[1] + t * t * t * to[1]],
33
+ tangent: normalize([3 * u * u * (c1[0] - from[0]) + 6 * u * t * (c2[0] - c1[0]) + 3 * t * t * (to[0] - c2[0]), 3 * u * u * (c1[1] - from[1]) + 6 * u * t * (c2[1] - c1[1]) + 3 * t * t * (to[1] - c2[1])])
34
+ };
35
+ };
36
+ /**
37
+ * 折角段 from → corner → to。
38
+ * t∈[0, 0.5] 走第一段(参数 2t);t∈(0.5, 1] 走第二段(参数 2t-1)。
39
+ * t=0.5 落在 corner,切线取第一段方向(与"靠近 prev 一侧"一致)。
40
+ */
41
+ var foldSegmentSample = (from, corner, to, t) => {
42
+ if (t <= .5) return lineSegmentSample(from, corner, t * 2);
43
+ return lineSegmentSample(corner, to, t * 2 - 1);
44
+ };
45
+ /**
46
+ * 弧段(与 ir/path arc 同约定,角度单位为度)。
47
+ * 切线沿"扫描方向"——endAngle ≥ startAngle 时为 (-sin, cos),否则反向。
48
+ */
49
+ var arcSegmentSample = (center, radius, startAngleDeg, endAngleDeg, t) => {
50
+ const rad = (startAngleDeg + t * (endAngleDeg - startAngleDeg)) * DEG_TO_RAD;
51
+ const cos = Math.cos(rad);
52
+ const sin = Math.sin(rad);
53
+ const sweepSign = endAngleDeg >= startAngleDeg ? 1 : -1;
54
+ return {
55
+ point: [center[0] + radius * cos, center[1] + radius * sin],
56
+ tangent: normalize([-sin * sweepSign, cos * sweepSign])
57
+ };
58
+ };
59
+ /**
60
+ * 整圆——从 0°(east)开始,与 compile/path circlePath 输出方向(右→左→右,sweep=1)一致。
61
+ */
62
+ var circleSegmentSample = (center, radius, t) => {
63
+ const rad = t * 360 * DEG_TO_RAD;
64
+ const cos = Math.cos(rad);
65
+ const sin = Math.sin(rad);
66
+ return {
67
+ point: [center[0] + radius * cos, center[1] + radius * sin],
68
+ tangent: normalize([-sin, cos])
69
+ };
70
+ };
71
+ /** 整椭圆——参数化 (rx·cos(2πt), ry·sin(2πt)) */
72
+ var ellipseSegmentSample = (center, rx, ry, t) => {
73
+ const rad = t * 360 * DEG_TO_RAD;
74
+ const cos = Math.cos(rad);
75
+ const sin = Math.sin(rad);
76
+ return {
77
+ point: [center[0] + rx * cos, center[1] + ry * sin],
78
+ tangent: normalize([-rx * sin, ry * cos])
79
+ };
80
+ };
81
+ //#endregion
82
+ export { arcSegmentSample, circleSegmentSample, cubicSegmentSample, ellipseSegmentSample, foldSegmentSample, lineSegmentSample, quadSegmentSample };
@@ -6,14 +6,14 @@
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, RelTargetSchema, RelAccumulateTargetSchema, MoveStepSchema, LineStepSchema, FoldStepSchema, CycleStepSchema, CurveStepSchema, CubicStepSchema, BendStepSchema, ArcStepSchema, CirclePathStepSchema, EllipsePathStepSchema, ControlPointSchema, StepLabelSchema, StepSchema, NodeSchema, FontSchema, NodeTextSchema, LineSpecSchema, PathSchema, ChildSchema, SceneSchema, CURRENT_IR_VERSION, } from './ir';
10
+ export type { IRPosition, IRTarget, IRRelTarget, IRRelAccumulateTarget, IRMoveStep, IRLineStep, IRFoldStep, IRCycleStep, IRCurveStep, IRCubicStep, IRBendStep, IRArcStep, IRCirclePathStep, IREllipsePathStep, IRControlPoint, IRStepLabel, 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
- export type { WayItem, WayDSL, WayCycle, WayVia } from './parsers';
16
- export { parseWay, DrawWay } from './parsers';
15
+ export type { WayItem, WayDSL, WayCycle, WayVia, WayRelItem, WayLabel, WayLabelOp, } from './parsers';
16
+ export { parseWay, DrawWay, parseTargetSugar } from './parsers';
17
17
  export type { Position, Rect, RectAnchor, Circle, CircleAnchor, Ellipse, EllipseAnchor, Diamond, DiamondAnchor, PolarPosition, } from './geometry';
18
18
  export { point, rect, circle, ellipse, diamond, RECT_ANCHORS, polar } from './geometry';
19
19
  export type { ValueOf } from './types';
@@ -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,GACV,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AAGjD,YAAY,EACV,cAAc,EACd,QAAQ,EACR,WAAW,EACX,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"}
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,eAAe,EACf,yBAAyB,EACzB,cAAc,EACd,cAAc,EACd,cAAc,EACd,eAAe,EACf,eAAe,EACf,eAAe,EACf,cAAc,EACd,aAAa,EACb,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,EAClB,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,WAAW,EACX,qBAAqB,EACrB,UAAU,EACV,UAAU,EACV,UAAU,EACV,WAAW,EACX,WAAW,EACX,WAAW,EACX,UAAU,EACV,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,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,EACV,OAAO,EACP,MAAM,EACN,QAAQ,EACR,MAAM,EACN,UAAU,EACV,QAAQ,EACR,UAAU,GACX,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAIhE,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
@@ -1,10 +1,10 @@
1
1
  import { PositionSchema } from "./ir/position/position.js";
2
2
  import { PolarPositionSchema } from "./ir/position/polar-position.js";
3
3
  import { ARROW_SHAPES } from "./ir/path/arrow.js";
4
- import { TargetSchema } from "./ir/path/target.js";
5
- import { CycleStepSchema, FoldStepSchema, LineStepSchema, MoveStepSchema, StepSchema } from "./ir/path/step.js";
4
+ import { RelAccumulateTargetSchema, RelTargetSchema, TargetSchema } from "./ir/path/target.js";
5
+ import { ArcStepSchema, BendStepSchema, CirclePathStepSchema, ControlPointSchema, CubicStepSchema, CurveStepSchema, CycleStepSchema, EllipsePathStepSchema, FoldStepSchema, LineStepSchema, MoveStepSchema, StepLabelSchema, 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";
@@ -12,7 +12,8 @@ import { diamond } from "./geometry/diamond.js";
12
12
  import { ellipse } from "./geometry/ellipse.js";
13
13
  import { fallbackMeasurer } from "./compile/text-metrics.js";
14
14
  import { compileToScene } from "./compile/compile.js";
15
+ import { parseTargetSugar } from "./parsers/parseTargetSugar.js";
15
16
  import { DrawWay, parseWay } from "./parsers/parseWay.js";
16
17
  import { polar } from "./geometry/polar.js";
17
18
  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 };
19
+ export { ARROW_SHAPES, ArcStepSchema, BendStepSchema, CURRENT_IR_VERSION, ChildSchema, CirclePathStepSchema, ControlPointSchema, CubicStepSchema, CurveStepSchema, CycleStepSchema, DrawWay, EllipsePathStepSchema, FoldStepSchema, FontSchema, LineSpecSchema, LineStepSchema, MoveStepSchema, NODE_SHAPES, NODE_TEXT_ALIGNS, NodeSchema, NodeTextSchema, PathSchema, PolarPositionSchema, PositionSchema, RECT_ANCHORS, RelAccumulateTargetSchema, RelTargetSchema, SceneSchema, StepLabelSchema, StepSchema, TargetSchema, circle, compileToScene, diamond, ellipse, fallbackMeasurer, parseTargetSugar, parseWay, point, polar, rect };
@@ -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,39 +168,185 @@ 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;
47
259
  fill?: string | undefined;
260
+ text?: string | (string | {
261
+ text: string;
262
+ fill?: string | undefined;
263
+ opacity?: number | undefined;
264
+ font?: {
265
+ family?: string | undefined;
266
+ size?: number | undefined;
267
+ weight?: number | "normal" | "bold" | undefined;
268
+ style?: "normal" | "italic" | "oblique" | undefined;
269
+ } | undefined;
270
+ })[] | undefined;
48
271
  shape?: "diamond" | "circle" | "rectangle" | "ellipse" | undefined;
49
272
  stroke?: string | undefined;
50
273
  strokeWidth?: number | undefined;
274
+ opacity?: number | undefined;
275
+ fillOpacity?: number | undefined;
276
+ drawOpacity?: number | undefined;
277
+ font?: {
278
+ family?: string | undefined;
279
+ size?: number | undefined;
280
+ weight?: number | "normal" | "bold" | undefined;
281
+ style?: "normal" | "italic" | "oblique" | undefined;
282
+ } | undefined;
51
283
  id?: string | undefined;
52
284
  rotate?: number | undefined;
53
- text?: string | undefined;
285
+ align?: "left" | "right" | "center" | undefined;
286
+ lineHeight?: 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;
60
306
  fill?: string | undefined;
307
+ text?: string | (string | {
308
+ text: string;
309
+ fill?: string | undefined;
310
+ opacity?: number | undefined;
311
+ font?: {
312
+ family?: string | undefined;
313
+ size?: number | undefined;
314
+ weight?: number | "normal" | "bold" | undefined;
315
+ style?: "normal" | "italic" | "oblique" | undefined;
316
+ } | undefined;
317
+ })[] | undefined;
61
318
  shape?: "diamond" | "circle" | "rectangle" | "ellipse" | undefined;
62
319
  stroke?: string | undefined;
63
320
  strokeWidth?: number | undefined;
321
+ opacity?: number | undefined;
322
+ fillOpacity?: number | undefined;
323
+ drawOpacity?: number | undefined;
324
+ font?: {
325
+ family?: string | undefined;
326
+ size?: number | undefined;
327
+ weight?: number | "normal" | "bold" | undefined;
328
+ style?: "normal" | "italic" | "oblique" | undefined;
329
+ } | undefined;
64
330
  id?: string | undefined;
65
331
  rotate?: number | undefined;
66
- text?: string | undefined;
332
+ align?: "left" | "right" | "center" | undefined;
333
+ lineHeight?: 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"}
@@ -23,19 +23,85 @@ var NODE_SHAPES = {
23
23
  ellipse: "ellipse",
24
24
  diamond: "diamond"
25
25
  };
26
+ /**
27
+ * 节点字体规格——family / size / weight / style 全部可选;
28
+ * 单字段透传到 SVG `<text>` 的 `font-*` 属性 / `font-size`。
29
+ *
30
+ * 取代 alpha.1 的标量 `fontSize` 字段(已删)。
31
+ */
32
+ var FontSchema = z.object({
33
+ family: z.string().optional().describe("CSS font-family string, e.g. \"serif\", \"monospace\", \"Inter, sans-serif\""),
34
+ size: z.number().positive().optional().describe("Font size in user units; falls back to the renderer default when omitted"),
35
+ weight: z.union([z.enum(["normal", "bold"]), z.number()]).optional().describe("CSS font-weight: keyword `normal` / `bold` or numeric 100..900"),
36
+ style: z.enum([
37
+ "normal",
38
+ "italic",
39
+ "oblique"
40
+ ]).optional().describe("CSS font-style")
41
+ }).describe("Font properties for the node text label; all fields optional, nested object form (replaces the alpha.1 `fontSize` scalar).");
42
+ /**
43
+ * 单行文本规格——纯字符串走块级默认样式;对象形式可对该行覆盖 fill / opacity / font。
44
+ *
45
+ * 行级覆盖只生效于本行的 `<tspan>`:
46
+ * - `fill`:仅这一行颜色
47
+ * - `opacity`:仅这一行 0~1 透明度
48
+ * - `font`:family / size / weight / style 任意子集;未填字段继承块级 font
49
+ *
50
+ * 块级 `align` / `lineHeight` 不可被行覆盖(多行块整体属性)。
51
+ */
52
+ var LineSpecSchema = z.union([z.string(), z.object({
53
+ text: z.string().describe("Line content"),
54
+ fill: z.string().optional().describe("Per-line text color; overrides block default"),
55
+ opacity: z.number().min(0).max(1).optional().describe("Per-line opacity 0..1"),
56
+ font: FontSchema.optional().describe("Per-line font overrides; missing fields inherit from block-level `font`")
57
+ })]).describe("Single line of text: bare string for default styling, or an object with per-line `fill` / `opacity` / `font` overrides.");
58
+ /**
59
+ * 节点文本——单行字符串或非空多行数组(每元素一个 LineSpec):
60
+ * - `'Hello'` 等价于 `[{ text: 'Hello' }]`,按一行渲染
61
+ * - `['Line 1', 'Line 2']` 两行无样式覆盖
62
+ * - `[{ text: 'Heading', fill: 'red', font: { weight: 'bold' } }, 'body']` 混排
63
+ *
64
+ * 选 `Array<LineSpec>` 而非 `'\n'` 字符串:JSON 友好(无 escape);行级覆盖天然落字段。
65
+ */
66
+ var NodeTextSchema = z.union([z.string(), z.array(LineSpecSchema).min(1)]).describe("Text label rendered inside the node: a single string for one line, or a non-empty array of line specs (string for default, object for per-line overrides).");
67
+ /** 节点文本对齐(多行内文本对齐)——TikZ `align=` 同义词 */
68
+ var NODE_TEXT_ALIGNS = {
69
+ left: "left",
70
+ center: "center",
71
+ right: "right"
72
+ };
26
73
  var NodeSchema = z.object({
27
74
  type: z.literal("node").describe("Discriminator marking this child as a node"),
28
75
  id: z.string().min(1).optional().describe("Optional unique id; required if any path needs to reference this node by string"),
29
76
  shape: z.nativeEnum(NODE_SHAPES).optional().describe("Node visual shape; defaults to `rectangle`. The boundary fully contains text + padding (circumscribed for circle / ellipse / diamond)."),
30
77
  position: z.union([PositionSchema, PolarPositionSchema]).describe("Center point of the node content box; Cartesian [x, y] or polar (resolved at compile time)"),
31
78
  rotate: z.number().optional().describe("Rotation in degrees around the node center; positive = clockwise (matches TikZ rotate=...)"),
32
- text: z.string().optional().describe("Text label rendered inside the node; omit for an empty node"),
79
+ text: NodeTextSchema.optional(),
80
+ align: z.nativeEnum(NODE_TEXT_ALIGNS).optional().describe("Multi-line text alignment within the text block; `left` / `center` / `right`. Defaults to `center` (matches TikZ)."),
81
+ lineHeight: z.number().positive().optional().describe("Line height in user units; falls back to `font.size × 1.2` when omitted."),
33
82
  fill: z.string().optional().describe("Background color of the node shape; any CSS color (e.g. \"lightblue\", \"#fafafa\", \"rgba(...)\")"),
83
+ fillOpacity: z.number().min(0).max(1).optional().describe("Fill opacity 0..1; affects only the shape fill, leaves stroke / text alone."),
34
84
  stroke: z.string().optional().describe("Border color of the node shape; any CSS color. Defaults to currentColor when omitted"),
85
+ drawOpacity: z.number().min(0).max(1).optional().describe("Stroke opacity 0..1 (TikZ `draw opacity`); affects only the border."),
35
86
  strokeWidth: z.number().optional().describe("Border width in user units; defaults to 1 when omitted"),
36
- padding: z.number().optional().describe("Inner padding in user units between the text content and the node border"),
37
- margin: z.number().nonnegative().optional().describe("Outer margin in user units: distance between the visual border and where paths attach. Lines stop this far from the border. Defaults to 0."),
38
- fontSize: z.number().optional().describe("Text font size in user units; defaults to a fixed size for now (TikZ font sizes will be supported later)")
87
+ dashed: z.boolean().optional().describe("Border style preset: dashed line (TikZ `dashed`); compiled to a default dash pattern. `dashArray` takes precedence."),
88
+ dotted: z.boolean().optional().describe("Border style preset: dotted line (TikZ `dotted`); compiled to a default dot pattern. `dashArray` and `dashed` take precedence."),
89
+ dashArray: z.string().optional().describe("Explicit SVG stroke-dasharray value (e.g. \"4 2\"); overrides `dashed` / `dotted`."),
90
+ roundedCorners: z.number().nonnegative().optional().describe("Corner radius in user units; only effective on `rectangle` shape (rx / ry on `<rect>`)."),
91
+ minimumWidth: z.number().nonnegative().optional().describe("Minimum visual border width in user units; floors the bounding box width."),
92
+ minimumHeight: z.number().nonnegative().optional().describe("Minimum visual border height in user units; floors the bounding box height."),
93
+ minimumSize: z.number().nonnegative().optional().describe("Symmetric alias for `minimumWidth` + `minimumHeight`; axis-specific fields take precedence."),
94
+ scale: z.number().positive().optional().describe("Uniform scale factor; multiplies all node dimensions (border, padding, text, fontSize) at layout time. Affects path attachment positions."),
95
+ xScale: z.number().positive().optional().describe("Horizontal scale factor; overrides `scale` for the X axis."),
96
+ yScale: z.number().positive().optional().describe("Vertical scale factor; overrides `scale` for the Y axis."),
97
+ textColor: z.string().optional().describe("Text label color; any CSS color. Defaults to `currentColor`."),
98
+ opacity: z.number().min(0).max(1).optional().describe("Whole-node opacity 0..1; applies uniformly to shape and text."),
99
+ innerXSep: z.number().nonnegative().optional().describe("Inner horizontal padding from text to border in user units. Falls back to `padding` then default."),
100
+ innerYSep: z.number().nonnegative().optional().describe("Inner vertical padding from text to border in user units. Falls back to `padding` then default."),
101
+ 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
+ padding: z.number().nonnegative().optional().describe("Symmetric inner padding (alias for `innerXSep` + `innerYSep`); axis-specific fields take precedence."),
103
+ 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.")
39
105
  }).describe("Node primitive: a positioned, optionally textual shape (rectangle / circle / ellipse / diamond)");
40
106
  //#endregion
41
- export { NODE_SHAPES, NodeSchema };
107
+ export { FontSchema, LineSpecSchema, NODE_SHAPES, NODE_TEXT_ALIGNS, NodeSchema, NodeTextSchema };