@retikz/core 0.2.0-alpha.1 → 0.2.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 (101) hide show
  1. package/dist/es/compile/compile.d.ts +8 -1
  2. package/dist/es/compile/compile.d.ts.map +1 -1
  3. package/dist/es/compile/compile.js +21 -6
  4. package/dist/es/compile/node.d.ts +15 -10
  5. package/dist/es/compile/node.d.ts.map +1 -1
  6. package/dist/es/compile/node.js +44 -181
  7. package/dist/es/compile/path/index.js +1 -1
  8. package/dist/es/compile/path/label.d.ts +1 -1
  9. package/dist/es/compile/path/label.d.ts.map +1 -1
  10. package/dist/es/compile/path/label.js +17 -4
  11. package/dist/es/compile/scope.d.ts.map +1 -1
  12. package/dist/es/compile/scope.js +3 -1
  13. package/dist/es/compile/style.d.ts +46 -0
  14. package/dist/es/compile/style.d.ts.map +1 -0
  15. package/dist/es/compile/style.js +259 -0
  16. package/dist/es/index.d.ts +4 -2
  17. package/dist/es/index.d.ts.map +1 -1
  18. package/dist/es/index.js +5 -3
  19. package/dist/es/ir/node.d.ts +19 -12
  20. package/dist/es/ir/node.d.ts.map +1 -1
  21. package/dist/es/ir/node.js +2 -1
  22. package/dist/es/ir/path/path.d.ts +531 -0
  23. package/dist/es/ir/path/path.d.ts.map +1 -1
  24. package/dist/es/ir/path/path.js +1 -0
  25. package/dist/es/ir/path/step.d.ts +834 -0
  26. package/dist/es/ir/path/step.d.ts.map +1 -1
  27. package/dist/es/ir/path/step.js +5 -1
  28. package/dist/es/ir/scope.d.ts +3493 -3
  29. package/dist/es/ir/scope.d.ts.map +1 -1
  30. package/dist/es/ir/scope.js +64 -4
  31. package/dist/es/shapes/_shared.d.ts +7 -0
  32. package/dist/es/shapes/_shared.d.ts.map +1 -0
  33. package/dist/es/shapes/_shared.js +11 -0
  34. package/dist/es/shapes/circle.d.ts +8 -0
  35. package/dist/es/shapes/circle.d.ts.map +1 -0
  36. package/dist/es/shapes/circle.js +33 -0
  37. package/dist/es/shapes/diamond.d.ts +8 -0
  38. package/dist/es/shapes/diamond.d.ts.map +1 -0
  39. package/dist/es/shapes/diamond.js +65 -0
  40. package/dist/es/shapes/ellipse.d.ts +8 -0
  41. package/dist/es/shapes/ellipse.d.ts.map +1 -0
  42. package/dist/es/shapes/ellipse.js +45 -0
  43. package/dist/es/shapes/index.d.ts +14 -0
  44. package/dist/es/shapes/index.d.ts.map +1 -0
  45. package/dist/es/shapes/index.js +15 -0
  46. package/dist/es/shapes/rectangle.d.ts +8 -0
  47. package/dist/es/shapes/rectangle.d.ts.map +1 -0
  48. package/dist/es/shapes/rectangle.js +40 -0
  49. package/dist/es/shapes/types.d.ts +44 -0
  50. package/dist/es/shapes/types.d.ts.map +1 -0
  51. package/dist/lib/compile/compile.cjs +23 -8
  52. package/dist/lib/compile/compile.d.ts +8 -1
  53. package/dist/lib/compile/compile.d.ts.map +1 -1
  54. package/dist/lib/compile/node.cjs +44 -181
  55. package/dist/lib/compile/node.d.ts +15 -10
  56. package/dist/lib/compile/node.d.ts.map +1 -1
  57. package/dist/lib/compile/path/index.cjs +1 -1
  58. package/dist/lib/compile/path/label.cjs +17 -4
  59. package/dist/lib/compile/path/label.d.ts +1 -1
  60. package/dist/lib/compile/path/label.d.ts.map +1 -1
  61. package/dist/lib/compile/scope.cjs +3 -1
  62. package/dist/lib/compile/scope.d.ts.map +1 -1
  63. package/dist/lib/compile/style.cjs +262 -0
  64. package/dist/lib/compile/style.d.ts +46 -0
  65. package/dist/lib/compile/style.d.ts.map +1 -0
  66. package/dist/lib/index.cjs +10 -1
  67. package/dist/lib/index.d.ts +4 -2
  68. package/dist/lib/index.d.ts.map +1 -1
  69. package/dist/lib/ir/node.cjs +2 -1
  70. package/dist/lib/ir/node.d.ts +19 -12
  71. package/dist/lib/ir/node.d.ts.map +1 -1
  72. package/dist/lib/ir/path/path.cjs +1 -0
  73. package/dist/lib/ir/path/path.d.ts +531 -0
  74. package/dist/lib/ir/path/path.d.ts.map +1 -1
  75. package/dist/lib/ir/path/step.cjs +5 -1
  76. package/dist/lib/ir/path/step.d.ts +834 -0
  77. package/dist/lib/ir/path/step.d.ts.map +1 -1
  78. package/dist/lib/ir/scope.cjs +67 -3
  79. package/dist/lib/ir/scope.d.ts +3493 -3
  80. package/dist/lib/ir/scope.d.ts.map +1 -1
  81. package/dist/lib/shapes/_shared.cjs +11 -0
  82. package/dist/lib/shapes/_shared.d.ts +7 -0
  83. package/dist/lib/shapes/_shared.d.ts.map +1 -0
  84. package/dist/lib/shapes/circle.cjs +33 -0
  85. package/dist/lib/shapes/circle.d.ts +8 -0
  86. package/dist/lib/shapes/circle.d.ts.map +1 -0
  87. package/dist/lib/shapes/diamond.cjs +65 -0
  88. package/dist/lib/shapes/diamond.d.ts +8 -0
  89. package/dist/lib/shapes/diamond.d.ts.map +1 -0
  90. package/dist/lib/shapes/ellipse.cjs +45 -0
  91. package/dist/lib/shapes/ellipse.d.ts +8 -0
  92. package/dist/lib/shapes/ellipse.d.ts.map +1 -0
  93. package/dist/lib/shapes/index.cjs +14 -0
  94. package/dist/lib/shapes/index.d.ts +14 -0
  95. package/dist/lib/shapes/index.d.ts.map +1 -0
  96. package/dist/lib/shapes/rectangle.cjs +40 -0
  97. package/dist/lib/shapes/rectangle.d.ts +8 -0
  98. package/dist/lib/shapes/rectangle.d.ts.map +1 -0
  99. package/dist/lib/shapes/types.d.ts +44 -0
  100. package/dist/lib/shapes/types.d.ts.map +1 -0
  101. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../../../src/ir/scope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmGrB,CAAC"}
@@ -1,6 +1,47 @@
1
+ import { FontSchema } from "./font.js";
2
+ import { ArrowDetailSchema } from "./path/arrow.js";
3
+ import { PathSchema } from "./path/path.js";
4
+ import { NodeSchema } from "./node.js";
1
5
  import { TransformSchema } from "./transform.js";
2
6
  import { z } from "zod";
3
7
  //#region src/ir/scope.ts
8
+ /**
9
+ * every node 默认样式 schema
10
+ * @description 从 NodeSchema 派生,排除实例专属字段(type / id / position / text / label);
11
+ * 含形状 / 间距 / scale / rotate / color 等所有可作默认的 node 样式字段
12
+ */
13
+ var NodeDefaultSchema = NodeSchema.omit({
14
+ type: true,
15
+ id: true,
16
+ position: true,
17
+ text: true,
18
+ label: true
19
+ }).strict();
20
+ /**
21
+ * every path 默认样式 schema
22
+ * @description 从 PathSchema 派生,排除 type / children / arrow / arrowDetail(arrow 走独立 arrowDefault 通道,免双入口)
23
+ */
24
+ var PathDefaultSchema = PathSchema.omit({
25
+ type: true,
26
+ children: true,
27
+ arrow: true,
28
+ arrowDetail: true
29
+ }).strict();
30
+ /**
31
+ * every label 默认样式 schema(node label 与 step label 共享)
32
+ * @description 单通道双宿主:node-label 跟 node.color、step-label 跟 path.color;本 schema 只定义可继承的 label 样式字段
33
+ */
34
+ var LabelDefaultSchema = z.object({
35
+ color: z.string().optional().describe("Master color for labels in this scope; textColor falls back to it."),
36
+ textColor: z.string().optional().describe("Default text color for node labels and step labels in this scope."),
37
+ opacity: z.number().min(0).max(1).optional().describe("Default label opacity 0..1."),
38
+ font: FontSchema.optional().describe("Default label font (family / size / weight / style); per-field fallback.")
39
+ }).strict().describe("Default style applied to every label (node label + step label) in this scope (TikZ `every label`). All fields optional; unknown keys are rejected.");
40
+ /**
41
+ * every arrow 默认样式 schema
42
+ * @description 直接复用 ArrowDetailSchema(shape / scale / length / width / color / fill / opacity / lineWidth + start / end)
43
+ */
44
+ var ArrowDefaultSchema = ArrowDetailSchema;
4
45
  /** schema 注册顺序:scene.ts import 时由 __registerChildSchema 一次性回灌;之后只读 */
5
46
  var childSchemaRef = null;
6
47
  /**
@@ -11,19 +52,38 @@ var __registerChildSchema = (schema) => {
11
52
  childSchemaRef = schema;
12
53
  };
13
54
  /**
14
- * Scope schema:4 IRScope 字段
55
+ * Scope schema:容器 + 局部 transform + 样式默认挂点
15
56
  * @description 直接 `z.object` 让 ChildSchema discriminatedUnion 能识别 `type` 鉴别字段;
16
- * children 字段内部用 z.lazy 引用 ChildSchema 实现递归,避免直接 `z.lazy(() => z.object(...))` 让外层 union 拒识 type
57
+ * children 字段内部用 z.lazy 引用 ChildSchema 实现递归,避免直接 `z.lazy(() => z.object(...))` 让外层 union 拒识 type
58
+ * alpha.2 加:① 级联 graphic state(color + stroke / fill / strokeWidth / opacity / fillOpacity / drawOpacity);
59
+ * ② 四通道 every-X 默认(nodeDefault / pathDefault / labelDefault / arrowDefault);③ resetStyle 继承屏障。
17
60
  */
18
61
  var ScopeSchema = z.object({
19
62
  type: z.literal("scope").describe("Discriminator marking this child as a scope container."),
20
63
  id: z.string().min(1).optional().describe("Optional reference id; when set, the scope registers a synthetic rectangle bbox node in the **parent** namespace frame so paths / positions can target the scope as a whole. scope.id always registers in the parent frame, regardless of `localNamespace` (it is the external handle)."),
21
64
  localNamespace: z.boolean().optional().describe("When true, the scope creates a local namespace boundary — child node / coordinate / nested-scope ids registered inside do NOT propagate to the parent namespace; external lookups cannot see them. Default false (matches TikZ pgf default: child ids flow up to global). scope.id itself always registers in the parent frame regardless of this flag."),
22
65
  transforms: z.array(TransformSchema).optional().describe("Local transforms applied to all scope children; array order = application order (first element applied innermost, matching Scene `GroupPrim.transforms` / SVG transform list). Supports 6 variants; the 4 translate variants are lowered to Cartesian translate at compile time."),
66
+ color: z.string().optional().describe("Cascading master color for all elements in this scope (TikZ scope `color=`). Stroke / fill / text of inner elements default to it unless individually overridden; cascades into edge labels and arrows."),
67
+ stroke: z.string().optional().describe("Cascading default stroke color for inner nodes and paths; overrides the cascading master color for the stroke channel."),
68
+ fill: z.string().optional().describe("Cascading default fill color for inner nodes and paths."),
69
+ strokeWidth: z.number().optional().describe("Cascading default stroke width (user units) for inner nodes and paths."),
70
+ opacity: z.number().min(0).max(1).optional().describe("Cascading default whole-element opacity 0..1. Replaces (does NOT compound across nested scopes — TikZ default)."),
71
+ fillOpacity: z.number().min(0).max(1).optional().describe("Cascading default fill opacity 0..1 for inner nodes and paths."),
72
+ drawOpacity: z.number().min(0).max(1).optional().describe("Cascading default stroke opacity 0..1 (TikZ `draw opacity`) for inner nodes and paths."),
73
+ nodeDefault: NodeDefaultSchema.optional().describe("Default style applied to every node in this scope (TikZ `every node`). Flat channel, independent from the other defaults."),
74
+ pathDefault: PathDefaultSchema.optional().describe("Default style applied to every path in this scope (TikZ `every path`); arrows use the separate arrowDefault channel."),
75
+ labelDefault: LabelDefaultSchema.optional().describe("Default style applied to every label (node label + step label) in this scope (TikZ `every label`)."),
76
+ arrowDefault: ArrowDefaultSchema.optional().describe("Default style applied to every arrow in this scope (TikZ `every arrow`)."),
77
+ resetStyle: z.union([z.boolean(), z.array(z.enum([
78
+ "node",
79
+ "path",
80
+ "label",
81
+ "arrow"
82
+ ]))]).optional().describe("Inheritance barrier: drop the outer scope cascade + every-X defaults for the listed channels (or all when true), falling back to the built-in baseline. Only cuts the scope-inheritance axis; labels / arrows still follow their host path / node resolved color (structural relation, not scope inheritance)."),
23
83
  children: z.array(z.lazy(() => {
24
84
  if (!childSchemaRef) throw new Error("ScopeSchema: ChildSchema not registered yet; ensure scene.ts loaded");
25
85
  return childSchemaRef;
26
86
  })).describe("Scope children: nested nodes / paths / coordinates / scopes. Recursive via the parent ChildSchema (registered late to break the IRChild <-> IRScope cycle).")
27
- }).describe("Scope container: groups child IR elements and applies local transforms. Corresponds to TikZ `\\begin{scope}` (with optional `local bounding box=id` when id is set, and `name prefix`-like isolation when localNamespace is true).");
87
+ }).describe("Scope container: groups child IR elements, applies local transforms, and acts as a style-default anchor (cascading graphic state + every-X defaults + resetStyle barrier). Corresponds to TikZ `\\begin{scope}`.");
28
88
  //#endregion
29
- export { ScopeSchema, __registerChildSchema };
89
+ export { ArrowDefaultSchema, LabelDefaultSchema, NodeDefaultSchema, PathDefaultSchema, ScopeSchema, __registerChildSchema };
@@ -0,0 +1,7 @@
1
+ import { RectAnchor } from '../geometry/rect';
2
+ /**
3
+ * 把任意字符串收窄为合法 RectAnchor,否则 undefined
4
+ * @description 内置 4 shape 的 anchor 只认这 9 名;不在集合内返回 undefined,由 `anchorOf` 抛 Unknown anchor
5
+ */
6
+ export declare const asRectAnchor: (name: string) => RectAnchor | undefined;
7
+ //# sourceMappingURL=_shared.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_shared.d.ts","sourceRoot":"","sources":["../../../src/shapes/_shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAKjE;;;GAGG;AACH,eAAO,MAAM,YAAY,GAAI,MAAM,MAAM,KAAG,UAAU,GAAG,SACK,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { RECT_ANCHORS } from "../geometry/rect.js";
2
+ //#region src/shapes/_shared.ts
3
+ /** RECT_ANCHORS 的 9 个合法 anchor 名集合(成员校验用) */
4
+ var RECT_ANCHOR_SET = new Set(Object.values(RECT_ANCHORS));
5
+ /**
6
+ * 把任意字符串收窄为合法 RectAnchor,否则 undefined
7
+ * @description 内置 4 shape 的 anchor 只认这 9 名;不在集合内返回 undefined,由 `anchorOf` 抛 Unknown anchor
8
+ */
9
+ var asRectAnchor = (name) => RECT_ANCHOR_SET.has(name) ? name : void 0;
10
+ //#endregion
11
+ export { asRectAnchor };
@@ -0,0 +1,8 @@
1
+ import { ShapeDefinition } from './types';
2
+ /**
3
+ * circle 注册项
4
+ * @description circumscribe = 内框对角线/2(两轴相等);几何走 circle 数学层;
5
+ * emit 复用 `ellipse.emit`(circle = rx=ry 的 ellipse),与旧 circle→`emitEllipseShape` 等价
6
+ */
7
+ export declare const circle: ShapeDefinition;
8
+ //# sourceMappingURL=circle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"circle.d.ts","sourceRoot":"","sources":["../../../src/shapes/circle.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAK/C;;;;GAIG;AACH,eAAO,MAAM,MAAM,EAAE,eAWpB,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { circle as circle$1 } from "../geometry/circle.js";
2
+ import { asRectAnchor } from "./_shared.js";
3
+ import { ellipse } from "./ellipse.js";
4
+ //#region src/shapes/circle.ts
5
+ /** 外接框 Rect → Circle(radius = 半宽;circle 外接框宽=高) */
6
+ var toCircle = (r) => ({
7
+ x: r.x,
8
+ y: r.y,
9
+ radius: r.width / 2,
10
+ rotate: r.rotate
11
+ });
12
+ /**
13
+ * circle 注册项
14
+ * @description circumscribe = 内框对角线/2(两轴相等);几何走 circle 数学层;
15
+ * emit 复用 `ellipse.emit`(circle = rx=ry 的 ellipse),与旧 circle→`emitEllipseShape` 等价
16
+ */
17
+ var circle = {
18
+ circumscribe: (hw, hh) => {
19
+ const r = Math.sqrt(hw * hw + hh * hh);
20
+ return {
21
+ halfWidth: r,
22
+ halfHeight: r
23
+ };
24
+ },
25
+ boundaryPoint: (r, toward) => circle$1.boundaryPoint(toCircle(r), toward),
26
+ anchor: (r, name) => {
27
+ const a = asRectAnchor(name);
28
+ return a ? circle$1.anchor(toCircle(r), a) : void 0;
29
+ },
30
+ emit: (r, style, round) => ellipse.emit(r, style, round)
31
+ };
32
+ //#endregion
33
+ export { circle };
@@ -0,0 +1,8 @@
1
+ import { ShapeDefinition } from './types';
2
+ /**
3
+ * diamond 注册项
4
+ * @description circumscribe = 内框 ×2(内框 4 顶点落在菱形 4 边上);几何由外接框半轴派生;
5
+ * emit 在**轴对齐空间**取 4 顶点出 PathPrim(rotate 由外层 group 施加),与旧 `emitDiamondShape(unrotated(...))` 等价
6
+ */
7
+ export declare const diamond: ShapeDefinition;
8
+ //# sourceMappingURL=diamond.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diamond.d.ts","sourceRoot":"","sources":["../../../src/shapes/diamond.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAW/C;;;;GAIG;AACH,eAAO,MAAM,OAAO,EAAE,eA+BrB,CAAC"}
@@ -0,0 +1,65 @@
1
+ import { asRectAnchor } from "./_shared.js";
2
+ import { diamond as diamond$1 } from "../geometry/diamond.js";
3
+ //#region src/shapes/diamond.ts
4
+ /** 外接框 Rect → Diamond(halfA/halfB = 半宽/半高;顶点在 ±halfA / ±halfB) */
5
+ var toDiamond = (r) => ({
6
+ x: r.x,
7
+ y: r.y,
8
+ halfA: r.width / 2,
9
+ halfB: r.height / 2,
10
+ rotate: r.rotate
11
+ });
12
+ /**
13
+ * diamond 注册项
14
+ * @description circumscribe = 内框 ×2(内框 4 顶点落在菱形 4 边上);几何由外接框半轴派生;
15
+ * emit 在**轴对齐空间**取 4 顶点出 PathPrim(rotate 由外层 group 施加),与旧 `emitDiamondShape(unrotated(...))` 等价
16
+ */
17
+ var diamond = {
18
+ circumscribe: (hw, hh) => ({
19
+ halfWidth: hw * 2,
20
+ halfHeight: hh * 2
21
+ }),
22
+ boundaryPoint: (r, toward) => diamond$1.boundaryPoint(toDiamond(r), toward),
23
+ anchor: (r, name) => {
24
+ const a = asRectAnchor(name);
25
+ return a ? diamond$1.anchor(toDiamond(r), a) : void 0;
26
+ },
27
+ *emit(r, style, round) {
28
+ const d = toDiamond(r);
29
+ const e = diamond$1.anchor(d, "east");
30
+ const n = diamond$1.anchor(d, "north");
31
+ const w = diamond$1.anchor(d, "west");
32
+ const s = diamond$1.anchor(d, "south");
33
+ yield {
34
+ type: "path",
35
+ commands: [
36
+ {
37
+ kind: "move",
38
+ to: [round(e[0]), round(e[1])]
39
+ },
40
+ {
41
+ kind: "line",
42
+ to: [round(n[0]), round(n[1])]
43
+ },
44
+ {
45
+ kind: "line",
46
+ to: [round(w[0]), round(w[1])]
47
+ },
48
+ {
49
+ kind: "line",
50
+ to: [round(s[0]), round(s[1])]
51
+ },
52
+ { kind: "close" }
53
+ ],
54
+ fill: style.fill ?? "transparent",
55
+ fillOpacity: style.fillOpacity,
56
+ stroke: style.stroke ?? "currentColor",
57
+ strokeOpacity: style.strokeOpacity,
58
+ strokeWidth: style.strokeWidth ?? 1,
59
+ dashPattern: style.dashPattern,
60
+ opacity: style.opacity
61
+ };
62
+ }
63
+ };
64
+ //#endregion
65
+ export { diamond };
@@ -0,0 +1,8 @@
1
+ import { ShapeDefinition } from './types';
2
+ /**
3
+ * ellipse 注册项
4
+ * @description circumscribe = 内框 ×√2(内框 4 顶点落在椭圆周上);几何由外接框半轴派生;
5
+ * emit 出 EllipsePrim,与旧 `emitEllipseShape` 逐字段等价
6
+ */
7
+ export declare const ellipse: ShapeDefinition;
8
+ //# sourceMappingURL=ellipse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ellipse.d.ts","sourceRoot":"","sources":["../../../src/shapes/ellipse.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAW/C;;;;GAIG;AACH,eAAO,MAAM,OAAO,EAAE,eAuBrB,CAAC"}
@@ -0,0 +1,45 @@
1
+ import { ellipse as ellipse$1 } from "../geometry/ellipse.js";
2
+ import { asRectAnchor } from "./_shared.js";
3
+ //#region src/shapes/ellipse.ts
4
+ /** 外接框 Rect → Ellipse(rx/ry = 半宽/半高) */
5
+ var toEllipse = (r) => ({
6
+ x: r.x,
7
+ y: r.y,
8
+ rx: r.width / 2,
9
+ ry: r.height / 2,
10
+ rotate: r.rotate
11
+ });
12
+ /**
13
+ * ellipse 注册项
14
+ * @description circumscribe = 内框 ×√2(内框 4 顶点落在椭圆周上);几何由外接框半轴派生;
15
+ * emit 出 EllipsePrim,与旧 `emitEllipseShape` 逐字段等价
16
+ */
17
+ var ellipse = {
18
+ circumscribe: (hw, hh) => ({
19
+ halfWidth: hw * Math.SQRT2,
20
+ halfHeight: hh * Math.SQRT2
21
+ }),
22
+ boundaryPoint: (r, toward) => ellipse$1.boundaryPoint(toEllipse(r), toward),
23
+ anchor: (r, name) => {
24
+ const a = asRectAnchor(name);
25
+ return a ? ellipse$1.anchor(toEllipse(r), a) : void 0;
26
+ },
27
+ *emit(r, style, round) {
28
+ yield {
29
+ type: "ellipse",
30
+ cx: round(r.x),
31
+ cy: round(r.y),
32
+ rx: round(r.width / 2),
33
+ ry: round(r.height / 2),
34
+ fill: style.fill ?? "transparent",
35
+ fillOpacity: style.fillOpacity,
36
+ stroke: style.stroke ?? "currentColor",
37
+ strokeOpacity: style.strokeOpacity,
38
+ strokeWidth: style.strokeWidth ?? 1,
39
+ dashPattern: style.dashPattern,
40
+ opacity: style.opacity
41
+ };
42
+ }
43
+ };
44
+ //#endregion
45
+ export { ellipse };
@@ -0,0 +1,14 @@
1
+ import { BuiltinShapeName } from '../ir/node';
2
+ import { circle } from './circle';
3
+ import { diamond } from './diamond';
4
+ import { ellipse } from './ellipse';
5
+ import { rectangle } from './rectangle';
6
+ import { ShapeDefinition } from './types';
7
+ /** 内置 4 shape 注册项;与 `CompileOptions.shapes` 合并时被同名注入覆盖 */
8
+ export declare const BUILTIN_SHAPES: Record<BuiltinShapeName, ShapeDefinition>;
9
+ export { rectangle, circle, ellipse, diamond };
10
+ export type { ShapeDefinition, ShapeStyle } from './types';
11
+ export type { Rect } from '../geometry/rect';
12
+ export type { Position } from '../geometry/point';
13
+ export { worldToLocal, localToWorld } from '../geometry/_transform';
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/shapes/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,0DAA0D;AAC1D,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,gBAAgB,EAAE,eAAe,CAKpE,CAAC;AAEF,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AAC/C,YAAY,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE3D,YAAY,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC7C,YAAY,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC"}
@@ -0,0 +1,15 @@
1
+ import "../geometry/_transform.js";
2
+ import { ellipse } from "./ellipse.js";
3
+ import { circle } from "./circle.js";
4
+ import { diamond } from "./diamond.js";
5
+ import { rectangle } from "./rectangle.js";
6
+ //#region src/shapes/index.ts
7
+ /** 内置 4 shape 注册项;与 `CompileOptions.shapes` 合并时被同名注入覆盖 */
8
+ var BUILTIN_SHAPES = {
9
+ rectangle,
10
+ circle,
11
+ ellipse,
12
+ diamond
13
+ };
14
+ //#endregion
15
+ export { BUILTIN_SHAPES };
@@ -0,0 +1,8 @@
1
+ import { ShapeDefinition } from './types';
2
+ /**
3
+ * rectangle 注册项
4
+ * @description circumscribe = identity(视觉边界 = 内框);boundaryPoint / anchor 直接走 rect 数学层;
5
+ * emit 出 RectPrim(圆角走 cornerRadius),与旧 `emitRectShape` 逐字段等价
6
+ */
7
+ export declare const rectangle: ShapeDefinition;
8
+ //# sourceMappingURL=rectangle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rectangle.d.ts","sourceRoot":"","sources":["../../../src/shapes/rectangle.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C;;;;GAIG;AACH,eAAO,MAAM,SAAS,EAAE,eA0BvB,CAAC"}
@@ -0,0 +1,40 @@
1
+ import { rect } from "../geometry/rect.js";
2
+ import { asRectAnchor } from "./_shared.js";
3
+ //#region src/shapes/rectangle.ts
4
+ /**
5
+ * rectangle 注册项
6
+ * @description circumscribe = identity(视觉边界 = 内框);boundaryPoint / anchor 直接走 rect 数学层;
7
+ * emit 出 RectPrim(圆角走 cornerRadius),与旧 `emitRectShape` 逐字段等价
8
+ */
9
+ var rectangle = {
10
+ circumscribe: (hw, hh) => ({
11
+ halfWidth: hw,
12
+ halfHeight: hh
13
+ }),
14
+ boundaryPoint: (r, toward) => rect.boundaryPoint(r, toward),
15
+ anchor: (r, name) => {
16
+ const a = asRectAnchor(name);
17
+ return a ? rect.anchor(r, a) : void 0;
18
+ },
19
+ *emit(r, style, round) {
20
+ const halfW = r.width / 2;
21
+ const halfH = r.height / 2;
22
+ yield {
23
+ type: "rect",
24
+ x: round(r.x - halfW),
25
+ y: round(r.y - halfH),
26
+ width: round(r.width),
27
+ height: round(r.height),
28
+ fill: style.fill ?? "transparent",
29
+ fillOpacity: style.fillOpacity,
30
+ stroke: style.stroke ?? "currentColor",
31
+ strokeOpacity: style.strokeOpacity,
32
+ strokeWidth: style.strokeWidth ?? 1,
33
+ dashPattern: style.dashPattern,
34
+ cornerRadius: style.roundedCorners,
35
+ opacity: style.opacity
36
+ };
37
+ }
38
+ };
39
+ //#endregion
40
+ export { rectangle };
@@ -0,0 +1,44 @@
1
+ import { Position } from '../geometry/point';
2
+ import { Rect } from '../geometry/rect';
3
+ import { ScenePrimitive } from '../primitive';
4
+ /**
5
+ * emit 需要的视觉样式子集
6
+ * @description 从 NodeLayout 的样式字段收敛(不含几何 / 文本);独立 type,不耦合内部 NodeLayout。
7
+ * 字段名与 NodeLayout 样式字段一致(单一词汇表)。
8
+ */
9
+ export type ShapeStyle = {
10
+ fill?: string;
11
+ fillOpacity?: number;
12
+ stroke?: string;
13
+ strokeOpacity?: number;
14
+ strokeWidth?: number;
15
+ dashPattern?: Array<number>;
16
+ roundedCorners?: number;
17
+ opacity?: number;
18
+ };
19
+ /**
20
+ * 一个 shape 的可注册定义:外接 / 边界 / anchor / emit 四件事
21
+ * @description plain object(factory 友好:`createPolygonShape(6)` 这类普通函数返回它即可);含函数、
22
+ * **不进 IR**,走 `CompileOptions.shapes` 运行时注入。内置 4 shape 也是注册项(无内置特权)。
23
+ *
24
+ * 坐标语义两套,第三方最易写错:
25
+ * - `boundaryPoint` / `anchor` 收**带 `rotate` 的 Rect**——用 re-export 的 `worldToLocal` / `localToWorld` 写局部系几何。
26
+ * - `emit` 收**轴对齐 Rect(rotate=0)**——旋转由编译器在外层 `GroupPrim` 统一施加。
27
+ */
28
+ export type ShapeDefinition = {
29
+ /**
30
+ * 外接:内容半轴(text + padding)→ 外接框半轴。
31
+ * @description rectangle: identity;circle: √(hw²+hh²) 两轴相等;ellipse: ×√2;diamond: ×2。
32
+ */
33
+ circumscribe: (innerHalfWidth: number, innerHalfHeight: number) => {
34
+ halfWidth: number;
35
+ halfHeight: number;
36
+ };
37
+ /** 中心 → toward 射线 ∩ 边界(rect 带 rotate)。 */
38
+ boundaryPoint: (rect: Rect, toward: Position) => Position;
39
+ /** 命名 anchor 世界坐标;shape 不认识的名字返回 `undefined`(调用方据此抛清晰错误)。 */
40
+ anchor: (rect: Rect, name: string) => Position | undefined;
41
+ /** 视觉 primitive,**轴对齐空间**(rotate 由编译器外层 GroupPrim 统一施加)。 */
42
+ emit: (rect: Rect, style: ShapeStyle, round: (n: number) => number) => Iterable<ScenePrimitive>;
43
+ };
44
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/shapes/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC5B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B;;;OAGG;IACH,YAAY,EAAE,CACZ,cAAc,EAAE,MAAM,EACtB,eAAe,EAAE,MAAM,KACpB;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/C,0CAA0C;IAC1C,aAAa,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,KAAK,QAAQ,CAAC;IAC1D,6DAA6D;IAC7D,MAAM,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,KAAK,QAAQ,GAAG,SAAS,CAAC;IAC3D,4DAA4D;IAC5D,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,KAAK,QAAQ,CAAC,cAAc,CAAC,CAAC;CACjG,CAAC"}
@@ -1,11 +1,13 @@
1
1
  const require_rect = require("../geometry/rect.cjs");
2
+ const require_index = require("../shapes/index.cjs");
2
3
  const require_name_stack = require("./name-stack.cjs");
3
4
  const require_scope = require("./scope.cjs");
4
5
  const require_position = require("./position.cjs");
5
6
  const require_node = require("./node.cjs");
6
7
  const require_text_metrics = require("./text-metrics.cjs");
7
- const require_index = require("./path/index.cjs");
8
+ const require_index$1 = require("./path/index.cjs");
8
9
  const require_precision = require("./precision.cjs");
10
+ const require_style = require("./style.cjs");
9
11
  const require_layout = require("./layout.cjs");
10
12
  //#region src/compile/compile.ts
11
13
  /**
@@ -15,7 +17,8 @@ const require_layout = require("./layout.cjs");
15
17
  */
16
18
  var zeroSizeRectAt = (id, [cx, cy]) => ({
17
19
  id,
18
- shape: "rectangle",
20
+ shapeName: "rectangle",
21
+ shapeDef: require_index.BUILTIN_SHAPES.rectangle,
19
22
  rect: {
20
23
  x: cx,
21
24
  y: cy,
@@ -83,6 +86,17 @@ var compileToScene = (ir, options = {}) => {
83
86
  const round = require_precision.makeRound(options.precision ?? 2);
84
87
  const nodeDistance = options.nodeDistance;
85
88
  const onWarn = options.onWarn ?? defaultWarnDispatcher;
89
+ const effectiveShapes = options.shapes ? {
90
+ ...require_index.BUILTIN_SHAPES,
91
+ ...options.shapes
92
+ } : require_index.BUILTIN_SHAPES;
93
+ if (options.shapes) {
94
+ for (const name of Object.keys(options.shapes)) if (Object.prototype.hasOwnProperty.call(require_index.BUILTIN_SHAPES, name)) onWarn({
95
+ code: "SHAPE_OVERRIDES_BUILTIN",
96
+ message: `Injected shape '${name}' overrides the built-in shape of the same name.`,
97
+ path: `options.shapes.${name}`
98
+ });
99
+ }
86
100
  const primitives = [];
87
101
  const nameStack = new require_name_stack.NameStack({ onDuplicate: (info) => onWarn(formatDuplicateWarning(info)) });
88
102
  const allPoints = [];
@@ -97,7 +111,7 @@ var compileToScene = (ir, options = {}) => {
97
111
  nameStack.enterLookupPhase();
98
112
  try {
99
113
  for (const item of pending) {
100
- const result = require_index.emitPathPrimitive(item.path, nameStack, round, measureText, {
114
+ const result = require_index$1.emitPathPrimitive(item.path, nameStack, round, measureText, {
101
115
  onWarn,
102
116
  irPath: item.irPath,
103
117
  scopeChain: item.scopeChain
@@ -120,12 +134,13 @@ var compileToScene = (ir, options = {}) => {
120
134
  * @param locatorPrefix IR locator 前缀(如 `''` 表示顶层、`children[2].scope.` 表示某 scope 内)
121
135
  * @param layoutsAccumulator 当前 scope 子树所有"实体"layout(node / coordinate / 嵌套 scope.id synthetic)累积——专给上层 scope.id bbox 计算用;顶层调用传一个共享数组(用得着就用,丢弃也不影响)
122
136
  * @param pathsAccumulator 当前层级收集的 pending paths——由调用方分配并在合适时机 resolve
137
+ * @param styleStack 从根到当前层级累积的样式 frame 栈(scope 级联 graphic state + 四通道 every-X + resetStyle);node / path 进入时按 inside-out per-field 解析 effective 样式
123
138
  */
124
- const processChildren = (children, chain, sink, locatorPrefix, layoutsAccumulator, pathsAccumulator) => {
139
+ const processChildren = (children, chain, sink, locatorPrefix, layoutsAccumulator, pathsAccumulator, styleStack) => {
125
140
  for (let i = 0; i < children.length; i++) {
126
141
  const child = children[i];
127
142
  if (child.type === "node") {
128
- const layout = require_node.layoutNode(child, measureText, nameStack, nodeDistance, chain);
143
+ const layout = require_node.layoutNode(require_style.resolveNodeStyle(child, styleStack), measureText, nameStack, nodeDistance, chain, require_style.resolveLabelDefault(styleStack), effectiveShapes);
129
144
  const globalLayout = chain.length === 0 ? layout : require_scope.projectLayoutToGlobal(layout, chain);
130
145
  if (child.id) nameStack.register(child.id, globalLayout, `${locatorPrefix}children[${i}].node.id`);
131
146
  for (const prim of require_node.emitNodePrimitives(layout, round)) sink.push(prim);
@@ -165,7 +180,7 @@ var compileToScene = (ir, options = {}) => {
165
180
  * 让 scope 内 path 自引用本 scope.id 端点取真 bbox 而非 placeholder */
166
181
  const innerPaths = [];
167
182
  try {
168
- processChildren(child.children, innerChain, innerSink, `${locatorPrefix}children[${i}].scope.`, innerLayouts, innerPaths);
183
+ processChildren(child.children, innerChain, innerSink, `${locatorPrefix}children[${i}].scope.`, innerLayouts, innerPaths, [...styleStack, require_style.buildStyleFrame(child)]);
169
184
  if (child.id) {
170
185
  const bbox = require_scope.computeScopeBoundingBox(innerLayouts);
171
186
  const fallbackOrigin = innerChain.length === 0 ? [0, 0] : require_scope.applyTransformChain([0, 0], innerChain);
@@ -186,14 +201,14 @@ var compileToScene = (ir, options = {}) => {
186
201
  if (hasOwnTransforms) group.transforms = [...ownTransforms];
187
202
  sink.push(group);
188
203
  } else pathsAccumulator.push({
189
- path: child,
204
+ path: require_style.resolveEffectivePath(child, styleStack),
190
205
  irPath: `${locatorPrefix}children[${i}].path`,
191
206
  scopeChain: chain
192
207
  });
193
208
  }
194
209
  };
195
210
  const rootPaths = [];
196
- processChildren(ir.children, [], primitives, "", [], rootPaths);
211
+ processChildren(ir.children, [], primitives, "", [], rootPaths, []);
197
212
  resolvePendingPaths(rootPaths);
198
213
  return {
199
214
  primitives,
@@ -1,5 +1,6 @@
1
1
  import { IR } from '../ir';
2
2
  import { Scene } from '../primitive';
3
+ import { ShapeDefinition } from '../shapes';
3
4
  import { TextMeasurer } from './text-metrics';
4
5
  /** 编译期警告:path / position 解析失败时通过 `CompileOptions.onWarn` 发出,不影响编译产物 */
5
6
  export type CompileWarning = {
@@ -7,7 +8,7 @@ export type CompileWarning = {
7
8
  * 警告类型代码(机器可读)
8
9
  * @description 用户可按 code 分支处理;未来 alpha 加新 code 不破坏调用方
9
10
  */
10
- code: 'UNRESOLVED_NODE_REFERENCE' | 'PATH_TOO_SHORT' | 'ANCHOR_RESOLUTION_FAILED' | 'OFFSET_BASE_UNRESOLVED' | 'POLAR_ORIGIN_UNRESOLVED' | 'AT_TARGET_UNRESOLVED' | 'RELATIVE_INITIAL_NO_PREV_END' | 'BBOX_EXTREME_INPUT' | 'DUPLICATE_NODE_ID' | (string & {});
11
+ code: 'UNRESOLVED_NODE_REFERENCE' | 'PATH_TOO_SHORT' | 'ANCHOR_RESOLUTION_FAILED' | 'OFFSET_BASE_UNRESOLVED' | 'POLAR_ORIGIN_UNRESOLVED' | 'AT_TARGET_UNRESOLVED' | 'RELATIVE_INITIAL_NO_PREV_END' | 'BBOX_EXTREME_INPUT' | 'DUPLICATE_NODE_ID' | 'SHAPE_OVERRIDES_BUILTIN' | (string & {});
11
12
  /** 人类可读消息(英文) */
12
13
  message: string;
13
14
  /** IR locator 路径(jq-like,如 `'children[3].path.children[1].to'`) */
@@ -34,6 +35,12 @@ export type CompileOptions = {
34
35
  * @description path / position 解析失败时按 IR locator + code + message 同步触发;不传时 dev 模式(`process.env.NODE_ENV !== 'production'`)默认 `console.warn`、生产静默
35
36
  */
36
37
  onWarn?: (warning: CompileWarning) => void;
38
+ /**
39
+ * 运行时注入的第三方 shape(不进 IR)
40
+ * @description 有效 shape 表 = `{ ...BUILTIN_SHAPES, ...shapes }`——同名 key 覆盖内置,经 `onWarn` 发
41
+ * `SHAPE_OVERRIDES_BUILTIN`。IR 的 `node.shape` 仍是字符串;未注册名在编译期 throw。
42
+ */
43
+ shapes?: Record<string, ShapeDefinition>;
37
44
  };
38
45
  /**
39
46
  * IR → Scene 纯函数转换,所有 adapter 共享
@@ -1 +1 @@
1
- {"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../../src/compile/compile.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAwC,MAAM,OAAO,CAAC;AACtE,OAAO,KAAK,EAAa,KAAK,EAA6B,MAAM,cAAc,CAAC;AAahF,OAAO,EAAE,KAAK,YAAY,EAAoB,MAAM,gBAAgB,CAAC;AA2CrE,uEAAuE;AACvE,MAAM,MAAM,cAAc,GAAG;IAC3B;;;OAGG;IACH,IAAI,EACA,2BAA2B,GAC3B,gBAAgB,GAChB,0BAA0B,GAC1B,wBAAwB,GACxB,yBAAyB,GACzB,sBAAsB,GACtB,8BAA8B,GAC9B,oBAAoB,GACpB,mBAAmB,GACnB,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;IAClB,iBAAiB;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,mEAAmE;IACnE,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,2BAA2B;AAC3B,MAAM,MAAM,cAAc,GAAG;IAC3B,oCAAoC;IACpC,WAAW,CAAC,EAAE,YAAY,CAAC;IAC3B,qCAAqC;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,IAAI,CAAC;CAC5C,CAAC;AAsDF;;;GAGG;AACH,eAAO,MAAM,c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