@retikz/core 0.2.0-alpha.2 → 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.
- package/dist/es/compile/compile.d.ts +8 -1
- package/dist/es/compile/compile.d.ts.map +1 -1
- package/dist/es/compile/compile.js +15 -2
- package/dist/es/compile/node.d.ts +15 -10
- package/dist/es/compile/node.d.ts.map +1 -1
- package/dist/es/compile/node.js +38 -175
- package/dist/es/compile/scope.d.ts.map +1 -1
- package/dist/es/compile/scope.js +3 -1
- package/dist/es/index.d.ts +3 -1
- package/dist/es/index.d.ts.map +1 -1
- package/dist/es/index.js +4 -2
- package/dist/es/ir/node.d.ts +14 -10
- package/dist/es/ir/node.d.ts.map +1 -1
- package/dist/es/ir/node.js +1 -1
- package/dist/es/ir/scope.d.ts +8 -18
- package/dist/es/ir/scope.d.ts.map +1 -1
- package/dist/es/shapes/_shared.d.ts +7 -0
- package/dist/es/shapes/_shared.d.ts.map +1 -0
- package/dist/es/shapes/_shared.js +11 -0
- package/dist/es/shapes/circle.d.ts +8 -0
- package/dist/es/shapes/circle.d.ts.map +1 -0
- package/dist/es/shapes/circle.js +33 -0
- package/dist/es/shapes/diamond.d.ts +8 -0
- package/dist/es/shapes/diamond.d.ts.map +1 -0
- package/dist/es/shapes/diamond.js +65 -0
- package/dist/es/shapes/ellipse.d.ts +8 -0
- package/dist/es/shapes/ellipse.d.ts.map +1 -0
- package/dist/es/shapes/ellipse.js +45 -0
- package/dist/es/shapes/index.d.ts +14 -0
- package/dist/es/shapes/index.d.ts.map +1 -0
- package/dist/es/shapes/index.js +15 -0
- package/dist/es/shapes/rectangle.d.ts +8 -0
- package/dist/es/shapes/rectangle.d.ts.map +1 -0
- package/dist/es/shapes/rectangle.js +40 -0
- package/dist/es/shapes/types.d.ts +44 -0
- package/dist/es/shapes/types.d.ts.map +1 -0
- package/dist/lib/compile/compile.cjs +17 -4
- package/dist/lib/compile/compile.d.ts +8 -1
- package/dist/lib/compile/compile.d.ts.map +1 -1
- package/dist/lib/compile/node.cjs +38 -175
- package/dist/lib/compile/node.d.ts +15 -10
- package/dist/lib/compile/node.d.ts.map +1 -1
- package/dist/lib/compile/scope.cjs +3 -1
- package/dist/lib/compile/scope.d.ts.map +1 -1
- package/dist/lib/index.cjs +6 -1
- package/dist/lib/index.d.ts +3 -1
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/ir/node.cjs +1 -1
- package/dist/lib/ir/node.d.ts +14 -10
- package/dist/lib/ir/node.d.ts.map +1 -1
- package/dist/lib/ir/scope.d.ts +8 -18
- package/dist/lib/ir/scope.d.ts.map +1 -1
- package/dist/lib/shapes/_shared.cjs +11 -0
- package/dist/lib/shapes/_shared.d.ts +7 -0
- package/dist/lib/shapes/_shared.d.ts.map +1 -0
- package/dist/lib/shapes/circle.cjs +33 -0
- package/dist/lib/shapes/circle.d.ts +8 -0
- package/dist/lib/shapes/circle.d.ts.map +1 -0
- package/dist/lib/shapes/diamond.cjs +65 -0
- package/dist/lib/shapes/diamond.d.ts +8 -0
- package/dist/lib/shapes/diamond.d.ts.map +1 -0
- package/dist/lib/shapes/ellipse.cjs +45 -0
- package/dist/lib/shapes/ellipse.d.ts +8 -0
- package/dist/lib/shapes/ellipse.d.ts.map +1 -0
- package/dist/lib/shapes/index.cjs +14 -0
- package/dist/lib/shapes/index.d.ts +14 -0
- package/dist/lib/shapes/index.d.ts.map +1 -0
- package/dist/lib/shapes/rectangle.cjs +40 -0
- package/dist/lib/shapes/rectangle.d.ts +8 -0
- package/dist/lib/shapes/rectangle.d.ts.map +1 -0
- package/dist/lib/shapes/types.d.ts +44 -0
- package/dist/lib/shapes/types.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/es/ir/scope.d.ts
CHANGED
|
@@ -11,12 +11,7 @@ import { IRTransform } from './transform';
|
|
|
11
11
|
export declare const NodeDefaultSchema: z.ZodObject<Omit<{
|
|
12
12
|
type: z.ZodLiteral<"node">;
|
|
13
13
|
id: z.ZodOptional<z.ZodString>;
|
|
14
|
-
shape: z.ZodOptional<z.
|
|
15
|
-
readonly rectangle: "rectangle";
|
|
16
|
-
readonly circle: "circle";
|
|
17
|
-
readonly ellipse: "ellipse";
|
|
18
|
-
readonly diamond: "diamond";
|
|
19
|
-
}>>;
|
|
14
|
+
shape: z.ZodOptional<z.ZodString>;
|
|
20
15
|
position: z.ZodUnion<[z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>, z.ZodType<import('./position').PolarPosition, z.ZodTypeDef, import('./position').PolarPosition>, z.ZodObject<{
|
|
21
16
|
direction: z.ZodNativeEnum<{
|
|
22
17
|
readonly above: "above";
|
|
@@ -255,7 +250,7 @@ export declare const NodeDefaultSchema: z.ZodObject<Omit<{
|
|
|
255
250
|
weight?: number | "normal" | "bold" | undefined;
|
|
256
251
|
style?: "normal" | "italic" | "oblique" | undefined;
|
|
257
252
|
} | undefined;
|
|
258
|
-
shape?:
|
|
253
|
+
shape?: string | undefined;
|
|
259
254
|
scale?: number | undefined;
|
|
260
255
|
color?: string | undefined;
|
|
261
256
|
textColor?: string | undefined;
|
|
@@ -289,7 +284,7 @@ export declare const NodeDefaultSchema: z.ZodObject<Omit<{
|
|
|
289
284
|
weight?: number | "normal" | "bold" | undefined;
|
|
290
285
|
style?: "normal" | "italic" | "oblique" | undefined;
|
|
291
286
|
} | undefined;
|
|
292
|
-
shape?:
|
|
287
|
+
shape?: string | undefined;
|
|
293
288
|
scale?: number | undefined;
|
|
294
289
|
color?: string | undefined;
|
|
295
290
|
textColor?: string | undefined;
|
|
@@ -1798,12 +1793,7 @@ export declare const ScopeSchema: z.ZodObject<{
|
|
|
1798
1793
|
nodeDefault: z.ZodOptional<z.ZodObject<Omit<{
|
|
1799
1794
|
type: z.ZodLiteral<"node">;
|
|
1800
1795
|
id: z.ZodOptional<z.ZodString>;
|
|
1801
|
-
shape: z.ZodOptional<z.
|
|
1802
|
-
readonly rectangle: "rectangle";
|
|
1803
|
-
readonly circle: "circle";
|
|
1804
|
-
readonly ellipse: "ellipse";
|
|
1805
|
-
readonly diamond: "diamond";
|
|
1806
|
-
}>>;
|
|
1796
|
+
shape: z.ZodOptional<z.ZodString>;
|
|
1807
1797
|
position: z.ZodUnion<[z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>, z.ZodType<import('./position').PolarPosition, z.ZodTypeDef, import('./position').PolarPosition>, z.ZodObject<{
|
|
1808
1798
|
direction: z.ZodNativeEnum<{
|
|
1809
1799
|
readonly above: "above";
|
|
@@ -2042,7 +2032,7 @@ export declare const ScopeSchema: z.ZodObject<{
|
|
|
2042
2032
|
weight?: number | "normal" | "bold" | undefined;
|
|
2043
2033
|
style?: "normal" | "italic" | "oblique" | undefined;
|
|
2044
2034
|
} | undefined;
|
|
2045
|
-
shape?:
|
|
2035
|
+
shape?: string | undefined;
|
|
2046
2036
|
scale?: number | undefined;
|
|
2047
2037
|
color?: string | undefined;
|
|
2048
2038
|
textColor?: string | undefined;
|
|
@@ -2076,7 +2066,7 @@ export declare const ScopeSchema: z.ZodObject<{
|
|
|
2076
2066
|
weight?: number | "normal" | "bold" | undefined;
|
|
2077
2067
|
style?: "normal" | "italic" | "oblique" | undefined;
|
|
2078
2068
|
} | undefined;
|
|
2079
|
-
shape?:
|
|
2069
|
+
shape?: string | undefined;
|
|
2080
2070
|
scale?: number | undefined;
|
|
2081
2071
|
color?: string | undefined;
|
|
2082
2072
|
textColor?: string | undefined;
|
|
@@ -3473,7 +3463,7 @@ export declare const ScopeSchema: z.ZodObject<{
|
|
|
3473
3463
|
weight?: number | "normal" | "bold" | undefined;
|
|
3474
3464
|
style?: "normal" | "italic" | "oblique" | undefined;
|
|
3475
3465
|
} | undefined;
|
|
3476
|
-
shape?:
|
|
3466
|
+
shape?: string | undefined;
|
|
3477
3467
|
scale?: number | undefined;
|
|
3478
3468
|
color?: string | undefined;
|
|
3479
3469
|
textColor?: string | undefined;
|
|
@@ -3604,7 +3594,7 @@ export declare const ScopeSchema: z.ZodObject<{
|
|
|
3604
3594
|
weight?: number | "normal" | "bold" | undefined;
|
|
3605
3595
|
style?: "normal" | "italic" | "oblique" | undefined;
|
|
3606
3596
|
} | undefined;
|
|
3607
|
-
shape?:
|
|
3597
|
+
shape?: string | undefined;
|
|
3608
3598
|
scale?: number | undefined;
|
|
3609
3599
|
color?: string | undefined;
|
|
3610
3600
|
textColor?: string | undefined;
|
|
@@ -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;AAEjD,OAAO,EAAE,KAAK,MAAM,EAAc,MAAM,QAAQ,CAAC;AACjD,OAAO,EAAE,KAAK,MAAM,EAAc,MAAM,QAAQ,CAAC;AAEjD,OAAO,EAAE,KAAK,WAAW,EAAmB,MAAM,aAAa,CAAC;AAOhE;;;;GAIG;AACH,eAAO,MAAM,iBAAiB
|
|
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;AAEjD,OAAO,EAAE,KAAK,MAAM,EAAc,MAAM,QAAQ,CAAC;AACjD,OAAO,EAAE,KAAK,MAAM,EAAc,MAAM,QAAQ,CAAC;AAEjD,OAAO,EAAE,KAAK,WAAW,EAAmB,MAAM,aAAa,CAAC;AAOhE;;;;GAIG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmGrB,CAAC"}
|
|
@@ -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,10 +1,11 @@
|
|
|
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");
|
|
9
10
|
const require_style = require("./style.cjs");
|
|
10
11
|
const require_layout = require("./layout.cjs");
|
|
@@ -16,7 +17,8 @@ const require_layout = require("./layout.cjs");
|
|
|
16
17
|
*/
|
|
17
18
|
var zeroSizeRectAt = (id, [cx, cy]) => ({
|
|
18
19
|
id,
|
|
19
|
-
|
|
20
|
+
shapeName: "rectangle",
|
|
21
|
+
shapeDef: require_index.BUILTIN_SHAPES.rectangle,
|
|
20
22
|
rect: {
|
|
21
23
|
x: cx,
|
|
22
24
|
y: cy,
|
|
@@ -84,6 +86,17 @@ var compileToScene = (ir, options = {}) => {
|
|
|
84
86
|
const round = require_precision.makeRound(options.precision ?? 2);
|
|
85
87
|
const nodeDistance = options.nodeDistance;
|
|
86
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
|
+
}
|
|
87
100
|
const primitives = [];
|
|
88
101
|
const nameStack = new require_name_stack.NameStack({ onDuplicate: (info) => onWarn(formatDuplicateWarning(info)) });
|
|
89
102
|
const allPoints = [];
|
|
@@ -98,7 +111,7 @@ var compileToScene = (ir, options = {}) => {
|
|
|
98
111
|
nameStack.enterLookupPhase();
|
|
99
112
|
try {
|
|
100
113
|
for (const item of pending) {
|
|
101
|
-
const result = require_index.emitPathPrimitive(item.path, nameStack, round, measureText, {
|
|
114
|
+
const result = require_index$1.emitPathPrimitive(item.path, nameStack, round, measureText, {
|
|
102
115
|
onWarn,
|
|
103
116
|
irPath: item.irPath,
|
|
104
117
|
scopeChain: item.scopeChain
|
|
@@ -127,7 +140,7 @@ var compileToScene = (ir, options = {}) => {
|
|
|
127
140
|
for (let i = 0; i < children.length; i++) {
|
|
128
141
|
const child = children[i];
|
|
129
142
|
if (child.type === "node") {
|
|
130
|
-
const layout = require_node.layoutNode(require_style.resolveNodeStyle(child, styleStack), measureText, nameStack, nodeDistance, chain, require_style.resolveLabelDefault(styleStack));
|
|
143
|
+
const layout = require_node.layoutNode(require_style.resolveNodeStyle(child, styleStack), measureText, nameStack, nodeDistance, chain, require_style.resolveLabelDefault(styleStack), effectiveShapes);
|
|
131
144
|
const globalLayout = chain.length === 0 ? layout : require_scope.projectLayoutToGlobal(layout, chain);
|
|
132
145
|
if (child.id) nameStack.register(child.id, globalLayout, `${locatorPrefix}children[${i}].node.id`);
|
|
133
146
|
for (const prim of require_node.emitNodePrimitives(layout, round)) sink.push(prim);
|
|
@@ -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;
|
|
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;AAEhF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAoBjD,OAAO,EAAE,KAAK,YAAY,EAAoB,MAAM,gBAAgB,CAAC;AA4CrE,uEAAuE;AACvE,MAAM,MAAM,cAAc,GAAG;IAC3B;;;OAGG;IACH,IAAI,EACA,2BAA2B,GAC3B,gBAAgB,GAChB,0BAA0B,GAC1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