@retikz/core 0.2.0-alpha.7 → 0.2.0-alpha.9
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/arrows/index.d.ts +13 -0
- package/dist/es/arrows/index.d.ts.map +1 -0
- package/dist/es/arrows/index.js +118 -0
- package/dist/es/arrows/types.d.ts +43 -0
- package/dist/es/arrows/types.d.ts.map +1 -0
- package/dist/es/compile/clip.d.ts +17 -0
- package/dist/es/compile/clip.d.ts.map +1 -0
- package/dist/es/compile/clip.js +84 -0
- package/dist/es/compile/compile.d.ts +26 -1
- package/dist/es/compile/compile.d.ts.map +1 -1
- package/dist/es/compile/compile.js +60 -7
- package/dist/es/compile/marker-prim.d.ts +22 -0
- package/dist/es/compile/marker-prim.d.ts.map +1 -0
- package/dist/es/compile/marker-prim.js +63 -0
- package/dist/es/compile/node.d.ts +2 -1
- package/dist/es/compile/node.d.ts.map +1 -1
- package/dist/es/compile/node.js +3 -3
- package/dist/es/compile/paint.d.ts +6 -1
- package/dist/es/compile/paint.d.ts.map +1 -1
- package/dist/es/compile/paint.js +60 -3
- package/dist/es/compile/path/anchor.d.ts.map +1 -1
- package/dist/es/compile/path/anchor.js +12 -0
- package/dist/es/compile/path/index.d.ts +15 -0
- package/dist/es/compile/path/index.d.ts.map +1 -1
- package/dist/es/compile/path/index.js +268 -12
- package/dist/es/compile/path/relative.d.ts.map +1 -1
- package/dist/es/compile/path/relative.js +8 -0
- package/dist/es/compile/path/shrink.d.ts +19 -6
- package/dist/es/compile/path/shrink.d.ts.map +1 -1
- package/dist/es/compile/path/shrink.js +147 -25
- package/dist/es/compile/position.d.ts +8 -2
- package/dist/es/compile/position.d.ts.map +1 -1
- package/dist/es/compile/position.js +7 -1
- package/dist/es/geometry/bend.d.ts +7 -0
- package/dist/es/geometry/bend.d.ts.map +1 -1
- package/dist/es/geometry/bend.js +26 -1
- package/dist/es/index.d.ts +16 -4
- package/dist/es/index.d.ts.map +1 -1
- package/dist/es/index.js +13 -7
- package/dist/es/ir/clip.d.ts +72 -0
- package/dist/es/ir/clip.d.ts.map +1 -0
- package/dist/es/ir/clip.js +37 -0
- package/dist/es/ir/coordinate.d.ts +3 -3
- package/dist/es/ir/coordinate.d.ts.map +1 -1
- package/dist/es/ir/coordinate.js +4 -2
- package/dist/es/ir/index.d.ts +2 -0
- package/dist/es/ir/index.d.ts.map +1 -1
- package/dist/es/ir/json.d.ts +22 -0
- package/dist/es/ir/json.d.ts.map +1 -0
- package/dist/es/ir/json.js +25 -0
- package/dist/es/ir/node.d.ts +10 -10
- package/dist/es/ir/node.d.ts.map +1 -1
- package/dist/es/ir/node.js +4 -2
- package/dist/es/ir/paint.d.ts +25 -3
- package/dist/es/ir/paint.d.ts.map +1 -1
- package/dist/es/ir/paint.js +12 -6
- package/dist/es/ir/path/arrow.d.ts +40 -60
- package/dist/es/ir/path/arrow.d.ts.map +1 -1
- package/dist/es/ir/path/arrow.js +5 -5
- package/dist/es/ir/path/path.d.ts +553 -164
- package/dist/es/ir/path/path.d.ts.map +1 -1
- package/dist/es/ir/path/path.js +21 -1
- package/dist/es/ir/path/step.d.ts +483 -128
- package/dist/es/ir/path/step.d.ts.map +1 -1
- package/dist/es/ir/path/step.js +18 -5
- package/dist/es/ir/path/target.d.ts +1 -1
- package/dist/es/ir/path/target.d.ts.map +1 -1
- package/dist/es/ir/path/target.js +4 -2
- package/dist/es/ir/position/between-position.d.ts +26 -0
- package/dist/es/ir/position/between-position.d.ts.map +1 -0
- package/dist/es/ir/position/between-position.js +21 -0
- package/dist/es/ir/position/index.d.ts +1 -0
- package/dist/es/ir/position/index.d.ts.map +1 -1
- package/dist/es/ir/scene.d.ts +51 -0
- package/dist/es/ir/scene.d.ts.map +1 -1
- package/dist/es/ir/scene.js +14 -2
- package/dist/es/ir/scope.d.ts +999 -380
- package/dist/es/ir/scope.d.ts.map +1 -1
- package/dist/es/ir/scope.js +2 -0
- package/dist/es/pathGenerators/define.d.ts +16 -0
- package/dist/es/pathGenerators/define.d.ts.map +1 -0
- package/dist/es/pathGenerators/define.js +23 -0
- package/dist/es/pathGenerators/index.d.ts +9 -0
- package/dist/es/pathGenerators/index.d.ts.map +1 -0
- package/dist/es/pathGenerators/types.d.ts +45 -0
- package/dist/es/pathGenerators/types.d.ts.map +1 -0
- package/dist/es/patterns/index.d.ts +10 -0
- package/dist/es/patterns/index.d.ts.map +1 -0
- package/dist/es/patterns/index.js +83 -0
- package/dist/es/patterns/types.d.ts +38 -0
- package/dist/es/patterns/types.d.ts.map +1 -0
- package/dist/es/primitive/clip.d.ts +18 -0
- package/dist/es/primitive/clip.d.ts.map +1 -0
- package/dist/es/primitive/group.d.ts +6 -0
- package/dist/es/primitive/group.d.ts.map +1 -1
- package/dist/es/primitive/index.d.ts +2 -0
- package/dist/es/primitive/index.d.ts.map +1 -1
- package/dist/es/primitive/marker.d.ts +160 -0
- package/dist/es/primitive/marker.d.ts.map +1 -0
- package/dist/es/primitive/paint.d.ts +32 -4
- package/dist/es/primitive/paint.d.ts.map +1 -1
- package/dist/es/primitive/path.d.ts +22 -18
- package/dist/es/primitive/path.d.ts.map +1 -1
- package/dist/es/primitive/scene.d.ts +2 -1
- package/dist/es/primitive/scene.d.ts.map +1 -1
- package/dist/lib/arrows/index.cjs +118 -0
- package/dist/lib/arrows/index.d.ts +13 -0
- package/dist/lib/arrows/index.d.ts.map +1 -0
- package/dist/lib/arrows/types.d.ts +43 -0
- package/dist/lib/arrows/types.d.ts.map +1 -0
- package/dist/lib/compile/clip.cjs +84 -0
- package/dist/lib/compile/clip.d.ts +17 -0
- package/dist/lib/compile/clip.d.ts.map +1 -0
- package/dist/lib/compile/compile.cjs +62 -9
- package/dist/lib/compile/compile.d.ts +26 -1
- package/dist/lib/compile/compile.d.ts.map +1 -1
- package/dist/lib/compile/marker-prim.cjs +63 -0
- package/dist/lib/compile/marker-prim.d.ts +22 -0
- package/dist/lib/compile/marker-prim.d.ts.map +1 -0
- package/dist/lib/compile/node.cjs +3 -3
- package/dist/lib/compile/node.d.ts +2 -1
- package/dist/lib/compile/node.d.ts.map +1 -1
- package/dist/lib/compile/paint.cjs +60 -3
- package/dist/lib/compile/paint.d.ts +6 -1
- package/dist/lib/compile/paint.d.ts.map +1 -1
- package/dist/lib/compile/path/anchor.cjs +12 -0
- package/dist/lib/compile/path/anchor.d.ts.map +1 -1
- package/dist/lib/compile/path/index.cjs +266 -10
- package/dist/lib/compile/path/index.d.ts +15 -0
- package/dist/lib/compile/path/index.d.ts.map +1 -1
- package/dist/lib/compile/path/relative.cjs +8 -0
- package/dist/lib/compile/path/relative.d.ts.map +1 -1
- package/dist/lib/compile/path/shrink.cjs +147 -25
- package/dist/lib/compile/path/shrink.d.ts +19 -6
- package/dist/lib/compile/path/shrink.d.ts.map +1 -1
- package/dist/lib/compile/position.cjs +7 -1
- package/dist/lib/compile/position.d.ts +8 -2
- package/dist/lib/compile/position.d.ts.map +1 -1
- package/dist/lib/geometry/bend.cjs +26 -0
- package/dist/lib/geometry/bend.d.ts +7 -0
- package/dist/lib/geometry/bend.d.ts.map +1 -1
- package/dist/lib/index.cjs +20 -3
- package/dist/lib/index.d.ts +16 -4
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/ir/clip.cjs +37 -0
- package/dist/lib/ir/clip.d.ts +72 -0
- package/dist/lib/ir/clip.d.ts.map +1 -0
- package/dist/lib/ir/coordinate.cjs +4 -2
- package/dist/lib/ir/coordinate.d.ts +3 -3
- package/dist/lib/ir/coordinate.d.ts.map +1 -1
- package/dist/lib/ir/index.d.ts +2 -0
- package/dist/lib/ir/index.d.ts.map +1 -1
- package/dist/lib/ir/json.cjs +26 -0
- package/dist/lib/ir/json.d.ts +22 -0
- package/dist/lib/ir/json.d.ts.map +1 -0
- package/dist/lib/ir/node.cjs +4 -2
- package/dist/lib/ir/node.d.ts +10 -10
- package/dist/lib/ir/node.d.ts.map +1 -1
- package/dist/lib/ir/paint.cjs +12 -5
- package/dist/lib/ir/paint.d.ts +25 -3
- package/dist/lib/ir/paint.d.ts.map +1 -1
- package/dist/lib/ir/path/arrow.cjs +5 -5
- package/dist/lib/ir/path/arrow.d.ts +40 -60
- package/dist/lib/ir/path/arrow.d.ts.map +1 -1
- package/dist/lib/ir/path/path.cjs +20 -0
- package/dist/lib/ir/path/path.d.ts +553 -164
- package/dist/lib/ir/path/path.d.ts.map +1 -1
- package/dist/lib/ir/path/step.cjs +18 -4
- package/dist/lib/ir/path/step.d.ts +483 -128
- package/dist/lib/ir/path/step.d.ts.map +1 -1
- package/dist/lib/ir/path/target.cjs +4 -2
- package/dist/lib/ir/path/target.d.ts +1 -1
- package/dist/lib/ir/path/target.d.ts.map +1 -1
- package/dist/lib/ir/position/between-position.cjs +22 -0
- package/dist/lib/ir/position/between-position.d.ts +26 -0
- package/dist/lib/ir/position/between-position.d.ts.map +1 -0
- package/dist/lib/ir/position/index.d.ts +1 -0
- package/dist/lib/ir/position/index.d.ts.map +1 -1
- package/dist/lib/ir/scene.cjs +14 -1
- package/dist/lib/ir/scene.d.ts +51 -0
- package/dist/lib/ir/scene.d.ts.map +1 -1
- package/dist/lib/ir/scope.cjs +2 -0
- package/dist/lib/ir/scope.d.ts +999 -380
- package/dist/lib/ir/scope.d.ts.map +1 -1
- package/dist/lib/pathGenerators/define.cjs +23 -0
- package/dist/lib/pathGenerators/define.d.ts +16 -0
- package/dist/lib/pathGenerators/define.d.ts.map +1 -0
- package/dist/lib/pathGenerators/index.d.ts +9 -0
- package/dist/lib/pathGenerators/index.d.ts.map +1 -0
- package/dist/lib/pathGenerators/types.d.ts +45 -0
- package/dist/lib/pathGenerators/types.d.ts.map +1 -0
- package/dist/lib/patterns/index.cjs +83 -0
- package/dist/lib/patterns/index.d.ts +10 -0
- package/dist/lib/patterns/index.d.ts.map +1 -0
- package/dist/lib/patterns/types.d.ts +38 -0
- package/dist/lib/patterns/types.d.ts.map +1 -0
- package/dist/lib/primitive/clip.d.ts +18 -0
- package/dist/lib/primitive/clip.d.ts.map +1 -0
- package/dist/lib/primitive/group.d.ts +6 -0
- package/dist/lib/primitive/group.d.ts.map +1 -1
- package/dist/lib/primitive/index.d.ts +2 -0
- package/dist/lib/primitive/index.d.ts.map +1 -1
- package/dist/lib/primitive/marker.d.ts +160 -0
- package/dist/lib/primitive/marker.d.ts.map +1 -0
- package/dist/lib/primitive/paint.d.ts +32 -4
- package/dist/lib/primitive/paint.d.ts.map +1 -1
- package/dist/lib/primitive/path.d.ts +22 -18
- package/dist/lib/primitive/path.d.ts.map +1 -1
- package/dist/lib/primitive/scene.d.ts +2 -1
- package/dist/lib/primitive/scene.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/es/compile/path/arrow-geometry.d.ts +0 -22
- package/dist/es/compile/path/arrow-geometry.d.ts.map +0 -1
- package/dist/es/compile/path/arrow-geometry.js +0 -40
- package/dist/lib/compile/path/arrow-geometry.cjs +0 -41
- package/dist/lib/compile/path/arrow-geometry.d.ts +0 -22
- package/dist/lib/compile/path/arrow-geometry.d.ts.map +0 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BuiltinArrowName } from '../ir/path/arrow';
|
|
2
|
+
import { ArrowDefinition } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* 内置 7 arrow 注册项;与 `CompileOptions.arrows` 合并时被同名注入覆盖
|
|
5
|
+
* @description 几何字段(lineContactX 静态 base / tipX / hollow):
|
|
6
|
+
* 实心 normal/diamond/circle lineContactX=0;stealth=3;open/openDiamond base=1 + tipX=9 + hollow;
|
|
7
|
+
* openCircle base=0.75 + hollow。baseSize / defaultLength / defaultWidth 走类型缺省(10 / 6 / 6)。
|
|
8
|
+
* framework 对 hollow def 统一把 lineContactX 减 lineWidth/2 得实际 refX / shrink 接触点。
|
|
9
|
+
* emit 几何在局部 baseSize=10 坐标系,等价历史 SVG。
|
|
10
|
+
*/
|
|
11
|
+
export declare const BUILTIN_ARROWS: Record<BuiltinArrowName, ArrowDefinition>;
|
|
12
|
+
export type { ArrowDefinition, ArrowEmitContext } from './types';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/arrows/index.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAoB,MAAM,SAAS,CAAC;AAiCjE;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,gBAAgB,EAAE,eAAe,CAqDpE,CAAC;AAEF,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
//#region src/arrows/index.ts
|
|
2
|
+
/** 实心闭合三角 / 菱形 / V 形的 path 工厂:填充走 ctx.fill(无 override = contextStroke) */
|
|
3
|
+
var filledPath = (ctx, points) => ({
|
|
4
|
+
type: "path",
|
|
5
|
+
commands: [
|
|
6
|
+
{
|
|
7
|
+
kind: "move",
|
|
8
|
+
to: points[0]
|
|
9
|
+
},
|
|
10
|
+
...points.slice(1).map((p) => ({
|
|
11
|
+
kind: "line",
|
|
12
|
+
to: p
|
|
13
|
+
})),
|
|
14
|
+
{ kind: "close" }
|
|
15
|
+
],
|
|
16
|
+
fill: typeof ctx.fill === "string" ? ctx.fill : { kind: "contextStroke" }
|
|
17
|
+
});
|
|
18
|
+
/** 空心闭合 path 工厂:无 fill、描边走 ctx.stroke / ctx.lineWidth(contextStroke 由 adapter 映射) */
|
|
19
|
+
var hollowPath = (ctx, points, strokeLinejoin) => ({
|
|
20
|
+
type: "path",
|
|
21
|
+
commands: [
|
|
22
|
+
{
|
|
23
|
+
kind: "move",
|
|
24
|
+
to: points[0]
|
|
25
|
+
},
|
|
26
|
+
...points.slice(1).map((p) => ({
|
|
27
|
+
kind: "line",
|
|
28
|
+
to: p
|
|
29
|
+
})),
|
|
30
|
+
{ kind: "close" }
|
|
31
|
+
],
|
|
32
|
+
stroke: typeof ctx.stroke === "string" ? ctx.stroke : "context-stroke",
|
|
33
|
+
strokeWidth: ctx.lineWidth,
|
|
34
|
+
...strokeLinejoin ? { strokeLinejoin } : {}
|
|
35
|
+
});
|
|
36
|
+
/**
|
|
37
|
+
* 内置 7 arrow 注册项;与 `CompileOptions.arrows` 合并时被同名注入覆盖
|
|
38
|
+
* @description 几何字段(lineContactX 静态 base / tipX / hollow):
|
|
39
|
+
* 实心 normal/diamond/circle lineContactX=0;stealth=3;open/openDiamond base=1 + tipX=9 + hollow;
|
|
40
|
+
* openCircle base=0.75 + hollow。baseSize / defaultLength / defaultWidth 走类型缺省(10 / 6 / 6)。
|
|
41
|
+
* framework 对 hollow def 统一把 lineContactX 减 lineWidth/2 得实际 refX / shrink 接触点。
|
|
42
|
+
* emit 几何在局部 baseSize=10 坐标系,等价历史 SVG。
|
|
43
|
+
*/
|
|
44
|
+
var BUILTIN_ARROWS = {
|
|
45
|
+
normal: {
|
|
46
|
+
lineContactX: 0,
|
|
47
|
+
emit: (ctx) => [filledPath(ctx, [
|
|
48
|
+
[0, 0],
|
|
49
|
+
[10, 5],
|
|
50
|
+
[0, 10]
|
|
51
|
+
])]
|
|
52
|
+
},
|
|
53
|
+
open: {
|
|
54
|
+
hollow: true,
|
|
55
|
+
lineContactX: 1,
|
|
56
|
+
tipX: 9,
|
|
57
|
+
emit: (ctx) => [hollowPath(ctx, [
|
|
58
|
+
[1, 1],
|
|
59
|
+
[9, 5],
|
|
60
|
+
[1, 9]
|
|
61
|
+
])]
|
|
62
|
+
},
|
|
63
|
+
stealth: {
|
|
64
|
+
lineContactX: 3,
|
|
65
|
+
emit: (ctx) => [filledPath(ctx, [
|
|
66
|
+
[0, 0],
|
|
67
|
+
[10, 5],
|
|
68
|
+
[0, 10],
|
|
69
|
+
[3, 5]
|
|
70
|
+
])]
|
|
71
|
+
},
|
|
72
|
+
diamond: {
|
|
73
|
+
lineContactX: 0,
|
|
74
|
+
emit: (ctx) => [filledPath(ctx, [
|
|
75
|
+
[0, 5],
|
|
76
|
+
[5, 0],
|
|
77
|
+
[10, 5],
|
|
78
|
+
[5, 10]
|
|
79
|
+
])]
|
|
80
|
+
},
|
|
81
|
+
openDiamond: {
|
|
82
|
+
hollow: true,
|
|
83
|
+
lineContactX: 1,
|
|
84
|
+
tipX: 9,
|
|
85
|
+
emit: (ctx) => [hollowPath(ctx, [
|
|
86
|
+
[1, 5],
|
|
87
|
+
[5, 1],
|
|
88
|
+
[9, 5],
|
|
89
|
+
[5, 9]
|
|
90
|
+
], "round")]
|
|
91
|
+
},
|
|
92
|
+
circle: {
|
|
93
|
+
lineContactX: 0,
|
|
94
|
+
emit: (ctx) => [{
|
|
95
|
+
type: "ellipse",
|
|
96
|
+
cx: 5,
|
|
97
|
+
cy: 5,
|
|
98
|
+
rx: 5,
|
|
99
|
+
ry: 5,
|
|
100
|
+
fill: typeof ctx.fill === "string" ? ctx.fill : { kind: "contextStroke" }
|
|
101
|
+
}]
|
|
102
|
+
},
|
|
103
|
+
openCircle: {
|
|
104
|
+
hollow: true,
|
|
105
|
+
lineContactX: .75,
|
|
106
|
+
emit: (ctx) => [{
|
|
107
|
+
type: "ellipse",
|
|
108
|
+
cx: 5,
|
|
109
|
+
cy: 5,
|
|
110
|
+
rx: 4.25,
|
|
111
|
+
ry: 4.25,
|
|
112
|
+
stroke: typeof ctx.stroke === "string" ? ctx.stroke : "context-stroke",
|
|
113
|
+
strokeWidth: ctx.lineWidth
|
|
114
|
+
}]
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
//#endregion
|
|
118
|
+
export { BUILTIN_ARROWS };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { MarkerFill, MarkerPrimitive } from '../primitive/marker';
|
|
2
|
+
/**
|
|
3
|
+
* emit 拿到的运行时上下文
|
|
4
|
+
* @description framework 把宿主 path 已解析的颜色 / 描边粗细传进来;def 据此产 marker 几何。
|
|
5
|
+
* `stroke` / `fill` 是 `MarkerFill`(纯色串或 `{ kind: 'contextStroke' }`,无 override 时取 contextStroke
|
|
6
|
+
* 继承 path stroke、主题反应不冻结)——可直接当 marker primitive 的 `fill` / `stroke` 用,无需收窄。
|
|
7
|
+
*/
|
|
8
|
+
export type ArrowEmitContext = {
|
|
9
|
+
/** 描边颜色(无 override 时 = `{ kind: 'contextStroke' }`,继承 path stroke) */
|
|
10
|
+
stroke: MarkerFill;
|
|
11
|
+
/** 填充颜色(实心箭头主导色;空心箭头由 framework 据 `hollow` 处理后传入) */
|
|
12
|
+
fill: MarkerFill;
|
|
13
|
+
/** 描边粗细(marker 局部坐标,user units);空心箭头据此画外轮廓 */
|
|
14
|
+
lineWidth: number;
|
|
15
|
+
/** 精度取整函数(与 compile/render 同一 round,保几何一致) */
|
|
16
|
+
round: (n: number) => number;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* 一个 arrow 的可注册定义:几何尺寸 + emit
|
|
20
|
+
* @description plain object(factory 友好),含函数、**不进 IR**,走 `CompileOptions.arrows` 运行时注入。
|
|
21
|
+
* 内置 7 箭头也是注册项(无内置特权,对齐 `ShapeDefinition` / `BUILTIN_SHAPES`)。
|
|
22
|
+
*
|
|
23
|
+
* `lineContactX` 存**静态 base**(不含 lineWidth 调整):实心 normal/diamond/circle = 0、stealth = 3、
|
|
24
|
+
* open/openDiamond base = 1、openCircle base = 0.75。framework 对 `hollow: true` 的 def 统一减
|
|
25
|
+
* `lineWidth/2` 得到实际 refX / shrink 接触点(这条调整由编译器 / adapter 落,def 只声明静态 base)。
|
|
26
|
+
*/
|
|
27
|
+
export type ArrowDefinition = {
|
|
28
|
+
/** marker 局部基准边长(viewBox `0 0 baseSize baseSize`,refY = baseSize/2);缺省 10 */
|
|
29
|
+
baseSize?: number;
|
|
30
|
+
/** 空心标志:true 时 framework 丢 fill、color 主导描边、启用 lineWidth;并对 lineContactX 减 lineWidth/2 */
|
|
31
|
+
hollow?: boolean;
|
|
32
|
+
/** 线接触点静态 base(决定 path shrink + marker refX);空心 def 由 framework 再减 lineWidth/2 */
|
|
33
|
+
lineContactX: number;
|
|
34
|
+
/** 尖端 x(shrink 用);缺省 = baseSize */
|
|
35
|
+
tipX?: number;
|
|
36
|
+
/** 默认箭头长度(length fallback);缺省 6 */
|
|
37
|
+
defaultLength?: number;
|
|
38
|
+
/** 默认箭头宽度(width fallback);缺省 6 */
|
|
39
|
+
defaultWidth?: number;
|
|
40
|
+
/** 局部坐标 marker 几何(renderer-agnostic);adapter 把产物嵌进 `<marker>` */
|
|
41
|
+
emit: (ctx: ArrowEmitContext) => Iterable<MarkerPrimitive>;
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/arrows/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEvE;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,sEAAsE;IACtE,MAAM,EAAE,UAAU,CAAC;IACnB,qDAAqD;IACrD,IAAI,EAAE,UAAU,CAAC;IACjB,8CAA8C;IAC9C,SAAS,EAAE,MAAM,CAAC;IAClB,8CAA8C;IAC9C,KAAK,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;CAC9B,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,yFAAyF;IACzF,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,kFAAkF;IAClF,YAAY,EAAE,MAAM,CAAC;IACrB,mCAAmC;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,mCAAmC;IACnC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,kCAAkC;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iEAAiE;IACjE,IAAI,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,QAAQ,CAAC,eAAe,CAAC,CAAC;CAC5D,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { IRClipSpec } from '../ir';
|
|
2
|
+
import { ClipResource } from '../primitive';
|
|
3
|
+
/** clip 登记表:编译期收集裁剪区、去重派稳定 id(`clip-1`…),最后产出 Scene clip 资源 */
|
|
4
|
+
export type ClipRegistry = {
|
|
5
|
+
/** 把一个裁剪区去重派 id;返回资源 id(供 GroupPrim.clipRef) */
|
|
6
|
+
resolve: (clip: IRClipSpec) => string;
|
|
7
|
+
/** 产出收集到的全部 clip 资源 */
|
|
8
|
+
resources: () => Array<ClipResource>;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* 建一个 clip 登记表
|
|
12
|
+
* @description resolve 对结构相同裁剪区(JSON 深比较)合并为一个资源、派稳定 id(`clip-1` / `clip-2`…,首见序)。
|
|
13
|
+
* 同一份 IR 编译两次 → 同 id(快照稳定)。裁剪区坐标 / 尺寸经 finite 守卫 + round。
|
|
14
|
+
* @param round 精度取整(与 compile / render 同一 round,保几何一致)
|
|
15
|
+
*/
|
|
16
|
+
export declare const createClipRegistry: (round: (n: number) => number) => ClipRegistry;
|
|
17
|
+
//# sourceMappingURL=clip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clip.d.ts","sourceRoot":"","sources":["../../../src/compile/clip.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,KAAK,EAAE,YAAY,EAAa,MAAM,cAAc,CAAC;AAE5D,+DAA+D;AAC/D,MAAM,MAAM,YAAY,GAAG;IACzB,gDAAgD;IAChD,OAAO,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,MAAM,CAAC;IACtC,uBAAuB;IACvB,SAAS,EAAE,MAAM,KAAK,CAAC,YAAY,CAAC,CAAC;CACtC,CAAC;AA4DF;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAAI,OAAO,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,KAAG,YAiBjE,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
//#region src/compile/clip.ts
|
|
2
|
+
/**
|
|
3
|
+
* 裁剪区 finite 守卫 + round
|
|
4
|
+
* @description schema 的 `.finite().positive()` 只在 IR parse 守门;compileToScene 直接收手搓 / LLM IR 会绕过,
|
|
5
|
+
* 故 compile 是唯一真实关口——非 finite / 非正尺寸会污染 Scene round-trip(JSON.stringify(NaN/Infinity)=null)。
|
|
6
|
+
* 在此抛清晰错(含 kind),对齐 arrow / pattern 的 finite 守卫。坐标 / 尺寸按 Scene precision round。
|
|
7
|
+
*/
|
|
8
|
+
var guardAndRound = (clip, round) => {
|
|
9
|
+
const bad = (field, v) => {
|
|
10
|
+
throw new Error(`Clip '${clip.kind}' has an invalid ${field} (${String(v)}); it must be a finite number${field === "x" || field === "y" || field === "cx" || field === "cy" ? "" : " greater than 0"}.`);
|
|
11
|
+
};
|
|
12
|
+
const fin = (field, v) => {
|
|
13
|
+
if (!Number.isFinite(v)) bad(field, v);
|
|
14
|
+
return round(v);
|
|
15
|
+
};
|
|
16
|
+
const pos = (field, v) => {
|
|
17
|
+
if (!Number.isFinite(v) || v <= 0) bad(field, v);
|
|
18
|
+
return round(v);
|
|
19
|
+
};
|
|
20
|
+
switch (clip.kind) {
|
|
21
|
+
case "rect": return {
|
|
22
|
+
kind: "rect",
|
|
23
|
+
x: fin("x", clip.x),
|
|
24
|
+
y: fin("y", clip.y),
|
|
25
|
+
width: pos("width", clip.width),
|
|
26
|
+
height: pos("height", clip.height)
|
|
27
|
+
};
|
|
28
|
+
case "circle": return {
|
|
29
|
+
kind: "circle",
|
|
30
|
+
cx: fin("cx", clip.cx),
|
|
31
|
+
cy: fin("cy", clip.cy),
|
|
32
|
+
r: pos("r", clip.r)
|
|
33
|
+
};
|
|
34
|
+
case "ellipse": return {
|
|
35
|
+
kind: "ellipse",
|
|
36
|
+
cx: fin("cx", clip.cx),
|
|
37
|
+
cy: fin("cy", clip.cy),
|
|
38
|
+
rx: pos("rx", clip.rx),
|
|
39
|
+
ry: pos("ry", clip.ry)
|
|
40
|
+
};
|
|
41
|
+
case "polygon":
|
|
42
|
+
if (clip.points.length < 3) throw new Error(`Clip 'polygon' needs at least 3 points; got ${clip.points.length}.`);
|
|
43
|
+
return {
|
|
44
|
+
kind: "polygon",
|
|
45
|
+
points: clip.points.map(([px, py], i) => {
|
|
46
|
+
if (!Number.isFinite(px) || !Number.isFinite(py)) throw new Error(`Clip 'polygon' point[${i}] is not finite (${String(px)}, ${String(py)}).`);
|
|
47
|
+
return [round(px), round(py)];
|
|
48
|
+
})
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* 建一个 clip 登记表
|
|
54
|
+
* @description resolve 对结构相同裁剪区(JSON 深比较)合并为一个资源、派稳定 id(`clip-1` / `clip-2`…,首见序)。
|
|
55
|
+
* 同一份 IR 编译两次 → 同 id(快照稳定)。裁剪区坐标 / 尺寸经 finite 守卫 + round。
|
|
56
|
+
* @param round 精度取整(与 compile / render 同一 round,保几何一致)
|
|
57
|
+
*/
|
|
58
|
+
var createClipRegistry = (round) => {
|
|
59
|
+
const idByKey = /* @__PURE__ */ new Map();
|
|
60
|
+
const list = [];
|
|
61
|
+
let counter = 0;
|
|
62
|
+
const resolve = (clip) => {
|
|
63
|
+
const shape = guardAndRound(clip, round);
|
|
64
|
+
const key = JSON.stringify(shape);
|
|
65
|
+
let id = idByKey.get(key);
|
|
66
|
+
if (id === void 0) {
|
|
67
|
+
counter += 1;
|
|
68
|
+
id = `clip-${counter}`;
|
|
69
|
+
idByKey.set(key, id);
|
|
70
|
+
list.push({
|
|
71
|
+
kind: "clip",
|
|
72
|
+
id,
|
|
73
|
+
shape
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
return id;
|
|
77
|
+
};
|
|
78
|
+
return {
|
|
79
|
+
resolve,
|
|
80
|
+
resources: () => list
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
//#endregion
|
|
84
|
+
export { createClipRegistry };
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { IR } from '../ir';
|
|
2
2
|
import { Scene } from '../primitive';
|
|
3
3
|
import { ShapeDefinition } from '../shapes';
|
|
4
|
+
import { ArrowDefinition } from '../arrows';
|
|
5
|
+
import { PatternDefinition } from '../patterns';
|
|
6
|
+
import { PathGeneratorDefinition } from '../pathGenerators';
|
|
4
7
|
import { TextMeasurer } from './text-metrics';
|
|
5
8
|
/** 编译期警告:path / position 解析失败时通过 `CompileOptions.onWarn` 发出,不影响编译产物 */
|
|
6
9
|
export type CompileWarning = {
|
|
@@ -8,7 +11,7 @@ export type CompileWarning = {
|
|
|
8
11
|
* 警告类型代码(机器可读)
|
|
9
12
|
* @description 用户可按 code 分支处理;未来 alpha 加新 code 不破坏调用方
|
|
10
13
|
*/
|
|
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 & {});
|
|
14
|
+
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' | 'ARROW_OVERRIDES_BUILTIN' | 'PATTERN_OVERRIDES_BUILTIN' | (string & {});
|
|
12
15
|
/** 人类可读消息(英文) */
|
|
13
16
|
message: string;
|
|
14
17
|
/** IR locator 路径(jq-like,如 `'children[3].path.children[1].to'`) */
|
|
@@ -41,6 +44,28 @@ export type CompileOptions = {
|
|
|
41
44
|
* `SHAPE_OVERRIDES_BUILTIN`。IR 的 `node.shape` 仍是字符串;未注册名在编译期 throw。
|
|
42
45
|
*/
|
|
43
46
|
shapes?: Record<string, ShapeDefinition>;
|
|
47
|
+
/**
|
|
48
|
+
* 运行时注入的第三方 arrow(不进 IR)
|
|
49
|
+
* @description 有效 arrow 表 = `{ ...BUILTIN_ARROWS, ...arrows }`——同名 key 覆盖内置,经 `onWarn` 发
|
|
50
|
+
* `ARROW_OVERRIDES_BUILTIN`。IR 的 `arrowDetail.shape` 仍是字符串;未注册名在编译期 throw。
|
|
51
|
+
*/
|
|
52
|
+
arrows?: Record<string, ArrowDefinition>;
|
|
53
|
+
/**
|
|
54
|
+
* 运行时注入的第三方 pattern motif(不进 IR)
|
|
55
|
+
* @description 有效 pattern 表 = `{ ...BUILTIN_PATTERNS, ...patterns }`——同名 key 覆盖内置,经 `onWarn` 发
|
|
56
|
+
* `PATTERN_OVERRIDES_BUILTIN`。IR 的 `pattern.shape` 仍是字符串;未注册名在编译期 throw。
|
|
57
|
+
* compile 对 pattern 资源查本表 + 调 `PatternDefinition.emit` 产 tile,写进 `SceneResource.tile`。
|
|
58
|
+
*/
|
|
59
|
+
patterns?: Record<string, PatternDefinition>;
|
|
60
|
+
/**
|
|
61
|
+
* 运行时注入的第三方 path generator(不进 IR)
|
|
62
|
+
* @description generator step 编译时按 `name` 查本表;core 不内置任何曲线生成器,故无内置合并。
|
|
63
|
+
* 解析时序:查表(未注册 throw,错误列出可用名)→ `paramsSchema.parse(params)` →
|
|
64
|
+
* 对结果再跑 `JsonObjectSchema.parse` 二次确认 JSON-safe → `targetParams` 顶层 key 经 target lookup
|
|
65
|
+
* resolve 成世界坐标 → 调 `generate(ctx)` → splice 产出的 `PathCommand[]` 进命令流。IR 的
|
|
66
|
+
* `generator.name` 仍是字符串;generator 函数本身只在此运行时注入面、不进 IR。
|
|
67
|
+
*/
|
|
68
|
+
pathGenerators?: Record<string, PathGeneratorDefinition>;
|
|
44
69
|
};
|
|
45
70
|
/**
|
|
46
71
|
* 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;AAEhF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,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;AAEjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAEjD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAuBjE,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,GAC1B,wBAAwB,GACxB,yBAAyB,GACzB,sBAAsB,GACtB,8BAA8B,GAC9B,oBAAoB,GACpB,mBAAmB,GACnB,yBAAyB,GACzB,yBAAyB,GACzB,2BAA2B,GAC3B,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;IAC3C;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IACzC;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IACzC;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAC7C;;;;;;;OAOG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAC;CAC1D,CAAC;AA+HF;;;GAGG;AACH,eAAO,MAAM,cAAc,GAAI,IAAI,EAAE,EAAE,UAAS,cAAmB,KAAG,KAqVrE,CAAC"}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { rect } from "../geometry/rect.js";
|
|
2
2
|
import { BUILTIN_SHAPES } from "../shapes/index.js";
|
|
3
|
+
import { BUILTIN_ARROWS } from "../arrows/index.js";
|
|
4
|
+
import { BUILTIN_PATTERNS } from "../patterns/index.js";
|
|
3
5
|
import { NameStack } from "./name-stack.js";
|
|
4
6
|
import { applyTransformChain, computeScopeBoundingBox, lowerScopeTransforms, projectLayoutToGlobal, registerScopeAsLayout } from "./scope.js";
|
|
5
7
|
import { resolvePosition } from "./position.js";
|
|
6
8
|
import { emitNodePrimitives, labelExtentPoints, layoutNode } from "./node.js";
|
|
7
9
|
import { createPaintRegistry } from "./paint.js";
|
|
10
|
+
import { createClipRegistry } from "./clip.js";
|
|
8
11
|
import { fallbackMeasurer } from "./text-metrics.js";
|
|
12
|
+
import { refPointOfTarget } from "./path/anchor.js";
|
|
9
13
|
import { emitPathPrimitive } from "./path/index.js";
|
|
10
14
|
import { makeRound } from "./precision.js";
|
|
11
15
|
import { buildStyleFrame, resolveEffectivePath, resolveLabelDefault, resolveNodeStyle } from "./style.js";
|
|
@@ -50,6 +54,28 @@ var scopePlaceholderLayout = (id, chain) => {
|
|
|
50
54
|
return zeroSizeRectAt(id, chain.length === 0 ? [0, 0] : applyTransformChain([0, 0], chain));
|
|
51
55
|
};
|
|
52
56
|
/**
|
|
57
|
+
* 显式 viewBox → Scene.layout(finite 守卫 + round)
|
|
58
|
+
* @description schema 的 `.finite().positive()` 只在 IR parse 守门;compileToScene 直接收手搓 / LLM IR 会绕过,
|
|
59
|
+
* 故此处是唯一真实关口——非 finite / 非正尺寸会污染 Scene round-trip。非法即抛清晰错(不泄漏进 Scene);
|
|
60
|
+
* 四字段按 Scene precision round(与自动算 layout 同口径)。
|
|
61
|
+
*/
|
|
62
|
+
var viewBoxToLayout = (vb, round) => {
|
|
63
|
+
if (!Number.isFinite(vb.x) || !Number.isFinite(vb.y)) throw new Error(`viewBox has a non-finite origin (x=${String(vb.x)}, y=${String(vb.y)}); both must be finite.`);
|
|
64
|
+
if (!Number.isFinite(vb.width) || vb.width <= 0) throw new Error(`viewBox has an invalid width (${String(vb.width)}); it must be a finite number greater than 0.`);
|
|
65
|
+
if (!Number.isFinite(vb.height) || vb.height <= 0) throw new Error(`viewBox has an invalid height (${String(vb.height)}); it must be a finite number greater than 0.`);
|
|
66
|
+
const x = round(vb.x);
|
|
67
|
+
const y = round(vb.y);
|
|
68
|
+
const width = round(vb.width);
|
|
69
|
+
const height = round(vb.height);
|
|
70
|
+
if (!Number.isFinite(x) || !Number.isFinite(y) || !Number.isFinite(width) || width <= 0 || !Number.isFinite(height) || height <= 0) throw new Error(`viewBox rounds to an invalid layout (x=${String(x)}, y=${String(y)}, width=${String(width)}, height=${String(height)}); check precision and coordinate magnitude.`);
|
|
71
|
+
return {
|
|
72
|
+
x,
|
|
73
|
+
y,
|
|
74
|
+
width,
|
|
75
|
+
height
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
53
79
|
* 默认 warn dispatcher:dev 模式 console.warn、生产静默
|
|
54
80
|
* @description 用户传 onWarn 时使用用户的;不传走此 fallback
|
|
55
81
|
*/
|
|
@@ -110,6 +136,29 @@ var compileToScene = (ir, options = {}) => {
|
|
|
110
136
|
path: `options.shapes.${name}`
|
|
111
137
|
});
|
|
112
138
|
}
|
|
139
|
+
const effectivePathGenerators = options.pathGenerators ?? {};
|
|
140
|
+
const effectiveArrows = options.arrows ? {
|
|
141
|
+
...BUILTIN_ARROWS,
|
|
142
|
+
...options.arrows
|
|
143
|
+
} : BUILTIN_ARROWS;
|
|
144
|
+
if (options.arrows) {
|
|
145
|
+
for (const name of Object.keys(options.arrows)) if (Object.prototype.hasOwnProperty.call(BUILTIN_ARROWS, name)) onWarn({
|
|
146
|
+
code: "ARROW_OVERRIDES_BUILTIN",
|
|
147
|
+
message: `Injected arrow '${name}' overrides the built-in arrow of the same name.`,
|
|
148
|
+
path: `options.arrows.${name}`
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
const effectivePatterns = options.patterns ? {
|
|
152
|
+
...BUILTIN_PATTERNS,
|
|
153
|
+
...options.patterns
|
|
154
|
+
} : BUILTIN_PATTERNS;
|
|
155
|
+
if (options.patterns) {
|
|
156
|
+
for (const name of Object.keys(options.patterns)) if (Object.prototype.hasOwnProperty.call(BUILTIN_PATTERNS, name)) onWarn({
|
|
157
|
+
code: "PATTERN_OVERRIDES_BUILTIN",
|
|
158
|
+
message: `Injected pattern '${name}' overrides the built-in pattern of the same name.`,
|
|
159
|
+
path: `options.patterns.${name}`
|
|
160
|
+
});
|
|
161
|
+
}
|
|
113
162
|
const primitives = [];
|
|
114
163
|
/** 已 push 但未回填的占位计数;compileToScene 返回前必须归零(无条件守 Scene 公开契约) */
|
|
115
164
|
let placeholderBalance = 0;
|
|
@@ -134,7 +183,8 @@ var compileToScene = (ir, options = {}) => {
|
|
|
134
183
|
};
|
|
135
184
|
const nameStack = new NameStack({ onDuplicate: (info) => onWarn(formatDuplicateWarning(info)) });
|
|
136
185
|
const allPoints = [];
|
|
137
|
-
const paint = createPaintRegistry();
|
|
186
|
+
const paint = createPaintRegistry(effectivePatterns, round);
|
|
187
|
+
const clip = createClipRegistry(round);
|
|
138
188
|
/**
|
|
139
189
|
* 解析一批本层收集的 pending paths(lookup-only 阶段)
|
|
140
190
|
* @description 两种落点:有 `slot`(scopeChain 为空)→ 原位 splice 回填该 path 在本层 sink 占的位(按引用定位免索引漂移),保住与同层 node 的 IR 声明序;无 `slot`(scopeChain 非空)→ hoist 到顶层 `primitives`,因端点已是全局坐标、进 transformed GroupPrim 会被 scope.transform 二次 apply。NameStack 切到 pass2 守门:path 解析中误调 register 抛 internal error;解析完切回 pass1 让上层 scope 子树继续 register 子节点。
|
|
@@ -150,7 +200,9 @@ var compileToScene = (ir, options = {}) => {
|
|
|
150
200
|
onWarn,
|
|
151
201
|
irPath: item.irPath,
|
|
152
202
|
scopeChain: item.scopeChain,
|
|
153
|
-
resolveFill: paint.resolve
|
|
203
|
+
resolveFill: paint.resolve,
|
|
204
|
+
effectiveArrows,
|
|
205
|
+
effectivePathGenerators
|
|
154
206
|
});
|
|
155
207
|
if (item.slot) {
|
|
156
208
|
const idx = item.slot.sink.indexOf(item.slot.placeholder);
|
|
@@ -184,7 +236,7 @@ var compileToScene = (ir, options = {}) => {
|
|
|
184
236
|
for (let i = 0; i < children.length; i++) {
|
|
185
237
|
const child = children[i];
|
|
186
238
|
if (child.type === "node") {
|
|
187
|
-
const layout = layoutNode(resolveNodeStyle(child, styleStack), measureText, nameStack, nodeDistance, chain, resolveLabelDefault(styleStack), effectiveShapes);
|
|
239
|
+
const layout = layoutNode(resolveNodeStyle(child, styleStack), measureText, nameStack, nodeDistance, chain, resolveLabelDefault(styleStack), effectiveShapes, refPointOfTarget);
|
|
188
240
|
const globalLayout = chain.length === 0 ? layout : projectLayoutToGlobal(layout, chain);
|
|
189
241
|
if (child.id) nameStack.register(child.id, globalLayout, `${locatorPrefix}children[${i}].node.id`);
|
|
190
242
|
for (const prim of emitNodePrimitives(layout, round, paint.resolve)) {
|
|
@@ -195,7 +247,7 @@ var compileToScene = (ir, options = {}) => {
|
|
|
195
247
|
for (const p of labelExtentPoints(globalLayout)) allPoints.push(p);
|
|
196
248
|
layoutsAccumulator.push(globalLayout);
|
|
197
249
|
} else if (child.type === "coordinate") {
|
|
198
|
-
const localCenter = resolvePosition(child.position, nameStack, nodeDistance, chain);
|
|
250
|
+
const localCenter = resolvePosition(child.position, nameStack, nodeDistance, chain, refPointOfTarget);
|
|
199
251
|
if (!localCenter) {
|
|
200
252
|
onWarn({
|
|
201
253
|
code: "POLAR_ORIGIN_UNRESOLVED",
|
|
@@ -241,12 +293,13 @@ var compileToScene = (ir, options = {}) => {
|
|
|
241
293
|
if (pushedFrame) nameStack.popFrame();
|
|
242
294
|
}
|
|
243
295
|
const hasOwnTransforms = ownTransforms.length > 0;
|
|
244
|
-
if (innerSink.length === 0 && !hasOwnTransforms && child.id === void 0) continue;
|
|
296
|
+
if (innerSink.length === 0 && !hasOwnTransforms && child.id === void 0 && child.clip === void 0) continue;
|
|
245
297
|
const group = {
|
|
246
298
|
type: "group",
|
|
247
299
|
children: stableSortByZIndex(sealSink(innerSink))
|
|
248
300
|
};
|
|
249
301
|
if (hasOwnTransforms) group.transforms = [...ownTransforms];
|
|
302
|
+
if (child.clip !== void 0) group.clipRef = clip.resolve(child.clip);
|
|
250
303
|
sink.push(group);
|
|
251
304
|
if (child.zIndex !== void 0) zIndexOf.set(group, child.zIndex);
|
|
252
305
|
} else {
|
|
@@ -276,10 +329,10 @@ var compileToScene = (ir, options = {}) => {
|
|
|
276
329
|
const detail = typeof process !== "undefined" && process.env.NODE_ENV !== "production" ? ` at ${collectPlaceholderLocators(primitives).join(", ")}` : "";
|
|
277
330
|
throw new Error(`internal: ${placeholderBalance} unresolved path placeholder(s) leaked into Scene output${detail}`);
|
|
278
331
|
}
|
|
279
|
-
const resources = paint.resources();
|
|
332
|
+
const resources = [...paint.resources(), ...clip.resources()];
|
|
280
333
|
return {
|
|
281
334
|
primitives: stableSortByZIndex(sealSink(primitives)),
|
|
282
|
-
layout: computeLayout(allPoints, layoutPadding, round),
|
|
335
|
+
layout: ir.viewBox !== void 0 ? viewBoxToLayout(ir.viewBox, round) : computeLayout(allPoints, layoutPadding, round),
|
|
283
336
|
...resources.length > 0 ? { resources } : {}
|
|
284
337
|
};
|
|
285
338
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { MarkerPrimitive } from '../primitive/marker';
|
|
2
|
+
/** 深度查 emit 产物里有没有函数(守 Scene 100% JSON 可序列化) */
|
|
3
|
+
export declare const assertNoFunction: (owner: string, value: unknown) => void;
|
|
4
|
+
/**
|
|
5
|
+
* 深度查 emit 产物里有没有非 finite 数(NaN / Infinity)
|
|
6
|
+
* @description 第三方 / LLM 的 emit 算错坐标(除零 / 溢出)会产 NaN / Infinity;`JSON.stringify` 把它们变成
|
|
7
|
+
* `null`,破坏 Scene round-trip 等价。故在此抛含 owner 的清晰错,不放任非 finite 流入 Scene(与 arrow
|
|
8
|
+
* geometry / path generator 的 finite 守卫同源)。
|
|
9
|
+
*/
|
|
10
|
+
export declare const assertFiniteNumbers: (owner: string, value: unknown) => void;
|
|
11
|
+
/**
|
|
12
|
+
* 递归校验单个 emit 产物符合 `MarkerPrimitive` 窄子集(运行时栅栏,TS 只能编译期守门)
|
|
13
|
+
* @description type 限 path/ellipse/rect/group(拒 text 等);fill 限 string | contextStroke(拒 resourceRef
|
|
14
|
+
* 等外部资源引用);group 递归 children。守"marker 内无文本布局 / 无外部资源 / 无递归 marker"契约。
|
|
15
|
+
*/
|
|
16
|
+
export declare const assertValidMarkerPrim: (owner: string, prim: unknown) => void;
|
|
17
|
+
/**
|
|
18
|
+
* 跑完整窄子集 + JSON-safe 校验(产物逐个过 `assertValidMarkerPrim` + 深度无函数检查)
|
|
19
|
+
* @description arrow / pattern 调 emit 收齐 `MarkerPrimitive[]` 后调用;任一原语违窄子集即抛含 owner 的清晰错。
|
|
20
|
+
*/
|
|
21
|
+
export declare const validateMarkerPrimitives: (owner: string, marker: ReadonlyArray<MarkerPrimitive>) => void;
|
|
22
|
+
//# sourceMappingURL=marker-prim.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"marker-prim.d.ts","sourceRoot":"","sources":["../../../src/compile/marker-prim.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAa3D,gDAAgD;AAChD,eAAO,MAAM,gBAAgB,GAAI,OAAO,MAAM,EAAE,OAAO,OAAO,KAAG,IAWhE,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAAI,OAAO,MAAM,EAAE,OAAO,OAAO,KAAG,IAcnE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAAI,OAAO,MAAM,EAAE,MAAM,OAAO,KAAG,IA2BpE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,wBAAwB,GACnC,OAAO,MAAM,EACb,QAAQ,aAAa,CAAC,eAAe,CAAC,KACrC,IAIF,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
//#region src/compile/marker-prim.ts
|
|
2
|
+
/**
|
|
3
|
+
* marker 窄子集运行时栅栏(arrow + pattern 共用)
|
|
4
|
+
* @description `MarkerPrimitive` 的窄子集(type 限 path/ellipse/rect/group、fill 限 string | contextStroke、
|
|
5
|
+
* 无外部 resourceRef / text / 函数)TS 只能编译期守门;第三方 / LLM 写出的 emit 会在运行时绕过类型,
|
|
6
|
+
* 故这里做运行时校验。arrow(marker 几何)与 pattern(motif 几何)emit 产物同契约,复用本组校验。
|
|
7
|
+
* `owner` 是错误消息里的归属串(如 `Arrow 'normal'` / `Pattern 'lines'`),便于第三方 / LLM 自修。
|
|
8
|
+
*/
|
|
9
|
+
/** marker 子集允许的 primitive type(窄子集运行时栅栏) */
|
|
10
|
+
var MARKER_PRIM_TYPES = new Set([
|
|
11
|
+
"path",
|
|
12
|
+
"ellipse",
|
|
13
|
+
"rect",
|
|
14
|
+
"group"
|
|
15
|
+
]);
|
|
16
|
+
/** 深度查 emit 产物里有没有函数(守 Scene 100% JSON 可序列化) */
|
|
17
|
+
var assertNoFunction = (owner, value) => {
|
|
18
|
+
if (typeof value === "function") throw new Error(`${owner} emit produced a marker containing a function; markers must be plain JSON data.`);
|
|
19
|
+
if (Array.isArray(value)) for (const v of value) assertNoFunction(owner, v);
|
|
20
|
+
else if (value !== null && typeof value === "object") for (const v of Object.values(value)) assertNoFunction(owner, v);
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* 深度查 emit 产物里有没有非 finite 数(NaN / Infinity)
|
|
24
|
+
* @description 第三方 / LLM 的 emit 算错坐标(除零 / 溢出)会产 NaN / Infinity;`JSON.stringify` 把它们变成
|
|
25
|
+
* `null`,破坏 Scene round-trip 等价。故在此抛含 owner 的清晰错,不放任非 finite 流入 Scene(与 arrow
|
|
26
|
+
* geometry / path generator 的 finite 守卫同源)。
|
|
27
|
+
*/
|
|
28
|
+
var assertFiniteNumbers = (owner, value) => {
|
|
29
|
+
if (typeof value === "number") {
|
|
30
|
+
if (!Number.isFinite(value)) throw new Error(`${owner} emit produced a marker with a non-finite number (${String(value)}); marker coordinates must be finite.`);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (Array.isArray(value)) for (const v of value) assertFiniteNumbers(owner, v);
|
|
34
|
+
else if (value !== null && typeof value === "object") for (const v of Object.values(value)) assertFiniteNumbers(owner, v);
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* 递归校验单个 emit 产物符合 `MarkerPrimitive` 窄子集(运行时栅栏,TS 只能编译期守门)
|
|
38
|
+
* @description type 限 path/ellipse/rect/group(拒 text 等);fill 限 string | contextStroke(拒 resourceRef
|
|
39
|
+
* 等外部资源引用);group 递归 children。守"marker 内无文本布局 / 无外部资源 / 无递归 marker"契约。
|
|
40
|
+
*/
|
|
41
|
+
var assertValidMarkerPrim = (owner, prim) => {
|
|
42
|
+
if (prim === null || typeof prim !== "object") throw new Error(`${owner} emit produced a non-object marker primitive.`);
|
|
43
|
+
const type = prim.type;
|
|
44
|
+
if (typeof type !== "string" || !MARKER_PRIM_TYPES.has(type)) throw new Error(`${owner} emit produced an invalid marker primitive type '${String(type)}'; allowed: group, path, ellipse, rect.`);
|
|
45
|
+
const fill = prim.fill;
|
|
46
|
+
if (fill !== void 0 && typeof fill !== "string" && !(typeof fill === "object" && fill !== null && fill.kind === "contextStroke")) throw new Error(`${owner} marker fill must be a color string or { kind: 'contextStroke' }; external paint references are not allowed inside markers.`);
|
|
47
|
+
if (type === "group") {
|
|
48
|
+
const children = prim.children;
|
|
49
|
+
if (!Array.isArray(children)) throw new Error(`${owner} marker group must have a children array.`);
|
|
50
|
+
for (const child of children) assertValidMarkerPrim(owner, child);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* 跑完整窄子集 + JSON-safe 校验(产物逐个过 `assertValidMarkerPrim` + 深度无函数检查)
|
|
55
|
+
* @description arrow / pattern 调 emit 收齐 `MarkerPrimitive[]` 后调用;任一原语违窄子集即抛含 owner 的清晰错。
|
|
56
|
+
*/
|
|
57
|
+
var validateMarkerPrimitives = (owner, marker) => {
|
|
58
|
+
for (const prim of marker) assertValidMarkerPrim(owner, prim);
|
|
59
|
+
assertNoFunction(owner, marker);
|
|
60
|
+
assertFiniteNumbers(owner, marker);
|
|
61
|
+
};
|
|
62
|
+
//#endregion
|
|
63
|
+
export { validateMarkerPrimitives };
|
|
@@ -5,6 +5,7 @@ import { PaintResolver } from './paint';
|
|
|
5
5
|
import { ScenePrimitive, TextLine, Transform } from '../primitive';
|
|
6
6
|
import { ShapeDefinition } from '../shapes';
|
|
7
7
|
import { NameStack } from './name-stack';
|
|
8
|
+
import { ResolveBetweenGlobal } from './position';
|
|
8
9
|
import { TextMeasurer } from './text-metrics';
|
|
9
10
|
export type NodeLayout = {
|
|
10
11
|
/** 节点 id(其他位置可引用) */
|
|
@@ -116,7 +117,7 @@ export declare const angleBoundaryOf: (layout: NodeLayout, angleDeg: number) =>
|
|
|
116
117
|
* scope 局部度量),调用方负责后续 `projectLayoutToGlobal` / `applyTransformChain` 投回全局;
|
|
117
118
|
* 笛卡尔字面量 `Position` 已在 scope 局部度量,行为延续 v0.1。
|
|
118
119
|
*/
|
|
119
|
-
export declare const layoutNode: (node: IRNode, measureText: TextMeasurer, nameStack: NameStack, nodeDistance?: number, scopeChain?: ReadonlyArray<Transform>, labelDefault?: IRLabelDefault, shapes?: Record<string, ShapeDefinition
|
|
120
|
+
export declare const layoutNode: (node: IRNode, measureText: TextMeasurer, nameStack: NameStack, nodeDistance?: number, scopeChain?: ReadonlyArray<Transform>, labelDefault?: IRLabelDefault, shapes?: Record<string, ShapeDefinition>, resolveBetweenGlobal?: ResolveBetweenGlobal) => NodeLayout;
|
|
120
121
|
/**
|
|
121
122
|
* NodeLayout → Scene primitives
|
|
122
123
|
* @description shape 主体走 `shapeDef.emit`(收轴对齐 rect、可出多 primitive);text 始终走 TextPrim;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../src/compile/node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,IAAI,EAAc,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAc,MAAM,EAAe,WAAW,EAAE,MAAM,OAAO,CAAC;AACvG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,EAAa,cAAc,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEnF,OAAO,KAAK,EAAE,eAAe,EAAc,MAAM,WAAW,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../src/compile/node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,IAAI,EAAc,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAc,MAAM,EAAe,WAAW,EAAE,MAAM,OAAO,CAAC;AACvG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,EAAa,cAAc,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEnF,OAAO,KAAK,EAAE,eAAe,EAAc,MAAM,WAAW,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,KAAK,oBAAoB,EAAmB,MAAM,YAAY,CAAC;AACxE,OAAO,KAAK,EAAY,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAgG7D,MAAM,MAAM,UAAU,GAAG;IACvB,qBAAqB;IACrB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,qCAAqC;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,iFAAiF;IACjF,QAAQ,EAAE,eAAe,CAAC;IAC1B;;;OAGG;IACH,IAAI,EAAE,IAAI,CAAC;IACX,4DAA4D;IAC5D,SAAS,EAAE,MAAM,CAAC;IAClB,uCAAuC;IACvC,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;IACxB,8CAA8C;IAC9C,SAAS,EAAE,MAAM,CAAC;IAClB,iCAAiC;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,oCAAoC;IACpC,KAAK,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;IAClC,iBAAiB;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,mBAAmB;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,2BAA2B;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS;IACT,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC7B,SAAS;IACT,SAAS,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;IAC5C,wFAAwF;IACxF,IAAI,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;IAC5B,gBAAgB;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qCAAqC;IACrC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,qCAAqC;IACrC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,uBAAuB;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,uDAAuD;IACvD,WAAW,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC5B,sCAAsC;IACtC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oCAAoC;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6CAA6C;IAC7C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,MAAM,CAAC,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;CACjC,CAAC;AAEF,4CAA4C;AAC5C,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,kBAAkB;IAClB,QAAQ,EAAE,WAAW,GAAG,MAAM,CAAC;IAC/B,aAAa;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC7B,SAAS,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;IAC5C,4DAA4D;IAC5D,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,CAAC;IAChD,+BAA+B;IAC/B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,4CAA4C;IAC5C,aAAa,EAAE,MAAM,CAAC;IACtB,sFAAsF;IACtF,GAAG,CAAC,EAAE,OAAO,GAAG;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;KAAE,CAAC;CACxF,CAAC;AAQF;;;GAGG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,UAAU,EAAE,QAAQ,QAAQ,KAAG,QACS,CAAC;AAEjF;;;;GAIG;AACH,eAAO,MAAM,QAAQ,GAAI,QAAQ,UAAU,EAAE,MAAM,MAAM,KAAG,QAM3D,CAAC;AA8FF;;;GAGG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,UAAU,EAAE,UAAU,MAAM,KAAG,QActE,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,GACrB,MAAM,MAAM,EACZ,aAAa,YAAY,EACzB,WAAW,SAAS,EACpB,eAAe,MAAM,EACrB,aAAY,aAAa,CAAC,SAAS,CAAM,EACzC,eAAe,cAAc,EAC7B,SAAQ,MAAM,CAAC,MAAM,EAAE,eAAe,CAAkB,EACxD,uBAAuB,oBAAoB,KAC1C,UA4KF,CAAC;AAcF;;;;GAIG;AACH;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAI,QAAQ,UAAU,KAAG,KAAK,CAAC,QAAQ,CA6BpE,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAC7B,QAAQ,UAAU,EAClB,OAAO,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,EAC5B,aAAa,aAAa,KACzB,KAAK,CAAC,cAAc,CAwGtB,CAAC"}
|
package/dist/es/compile/node.js
CHANGED
|
@@ -205,7 +205,7 @@ var angleBoundaryOf = (layout, angleDeg) => {
|
|
|
205
205
|
* scope 局部度量),调用方负责后续 `projectLayoutToGlobal` / `applyTransformChain` 投回全局;
|
|
206
206
|
* 笛卡尔字面量 `Position` 已在 scope 局部度量,行为延续 v0.1。
|
|
207
207
|
*/
|
|
208
|
-
var layoutNode = (node, measureText, nameStack, nodeDistance, scopeChain = [], labelDefault, shapes = BUILTIN_SHAPES) => {
|
|
208
|
+
var layoutNode = (node, measureText, nameStack, nodeDistance, scopeChain = [], labelDefault, shapes = BUILTIN_SHAPES, resolveBetweenGlobal) => {
|
|
209
209
|
const shapeName = node.shape ?? "rectangle";
|
|
210
210
|
const shapeDef = Object.prototype.hasOwnProperty.call(shapes, shapeName) ? shapes[shapeName] : void 0;
|
|
211
211
|
if (!shapeDef) throw new Error(`Unknown shape '${shapeName}'; registered shapes: ${Object.keys(shapes).sort().join(", ")}`);
|
|
@@ -263,8 +263,8 @@ var layoutNode = (node, measureText, nameStack, nodeDistance, scopeChain = [], l
|
|
|
263
263
|
const innerHalfH = Math.max(textHeight / 2 + ySep, ySep, minH / 2);
|
|
264
264
|
const { halfWidth: boundsHalfW, halfHeight: boundsHalfH } = shapeDef.circumscribe(innerHalfW, innerHalfH);
|
|
265
265
|
const rotateDeg = node.rotate ?? 0;
|
|
266
|
-
const center = resolvePosition(node.position, nameStack, nodeDistance, scopeChain);
|
|
267
|
-
if (!center) throw new Error(`Cannot resolve position for node ${node.id ?? "(unnamed)"}; polar.origin
|
|
266
|
+
const center = resolvePosition(node.position, nameStack, nodeDistance, scopeChain, resolveBetweenGlobal);
|
|
267
|
+
if (!center) throw new Error(`Cannot resolve position for node ${node.id ?? "(unnamed)"}; polar.origin / at.of / between endpoint may reference an undefined node`);
|
|
268
268
|
const labels = (node.label === void 0 ? void 0 : Array.isArray(node.label) ? node.label : [node.label])?.map((lab) => {
|
|
269
269
|
const labFont = lab.font;
|
|
270
270
|
const labFontSize = (labFont?.size ?? labelDefault?.font?.size ?? baseFontSize) * fontScale;
|