@retikz/core 0.2.0-alpha.6 → 0.2.0-alpha.8
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/compile.d.ts +26 -1
- package/dist/es/compile/compile.d.ts.map +1 -1
- package/dist/es/compile/compile.js +37 -4
- 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 +19 -4
- package/dist/es/compile/node.d.ts.map +1 -1
- package/dist/es/compile/node.js +159 -29
- package/dist/es/compile/paint.d.ts +21 -0
- package/dist/es/compile/paint.d.ts.map +1 -0
- package/dist/es/compile/paint.js +94 -0
- package/dist/es/compile/path/index.d.ts +18 -0
- package/dist/es/compile/path/index.d.ts.map +1 -1
- package/dist/es/compile/path/index.js +260 -11
- 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/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 +14 -4
- package/dist/es/index.d.ts.map +1 -1
- package/dist/es/index.js +7 -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 +262 -9
- package/dist/es/ir/node.d.ts.map +1 -1
- package/dist/es/ir/node.js +9 -2
- package/dist/es/ir/paint.d.ts +154 -0
- package/dist/es/ir/paint.d.ts.map +1 -0
- package/dist/es/ir/paint.js +59 -0
- package/dist/es/ir/path/arrow.d.ts +52 -72
- 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 +637 -87
- package/dist/es/ir/path/path.d.ts.map +1 -1
- package/dist/es/ir/path/path.js +23 -2
- package/dist/es/ir/path/step.d.ts +363 -8
- package/dist/es/ir/path/step.d.ts.map +1 -1
- package/dist/es/ir/path/step.js +17 -4
- package/dist/es/ir/scope.d.ts +1874 -338
- package/dist/es/ir/scope.d.ts.map +1 -1
- package/dist/es/ir/scope.js +2 -1
- 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/ellipse.d.ts +3 -5
- package/dist/es/primitive/ellipse.d.ts.map +1 -1
- package/dist/es/primitive/index.d.ts +1 -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 +46 -0
- package/dist/es/primitive/paint.d.ts.map +1 -0
- package/dist/es/primitive/path.d.ts +25 -20
- package/dist/es/primitive/path.d.ts.map +1 -1
- package/dist/es/primitive/rect.d.ts +3 -2
- package/dist/es/primitive/rect.d.ts.map +1 -1
- package/dist/es/primitive/scene.d.ts +4 -0
- package/dist/es/primitive/scene.d.ts.map +1 -1
- package/dist/es/shapes/types.d.ts +2 -2
- package/dist/es/shapes/types.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/compile.cjs +38 -5
- 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 +159 -28
- package/dist/lib/compile/node.d.ts +19 -4
- package/dist/lib/compile/node.d.ts.map +1 -1
- package/dist/lib/compile/paint.cjs +94 -0
- package/dist/lib/compile/paint.d.ts +21 -0
- package/dist/lib/compile/paint.d.ts.map +1 -0
- package/dist/lib/compile/path/index.cjs +258 -9
- package/dist/lib/compile/path/index.d.ts +18 -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/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 +14 -0
- package/dist/lib/index.d.ts +14 -4
- package/dist/lib/index.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 +9 -2
- package/dist/lib/ir/node.d.ts +262 -9
- package/dist/lib/ir/node.d.ts.map +1 -1
- package/dist/lib/ir/paint.cjs +61 -0
- package/dist/lib/ir/paint.d.ts +154 -0
- package/dist/lib/ir/paint.d.ts.map +1 -0
- package/dist/lib/ir/path/arrow.cjs +5 -5
- package/dist/lib/ir/path/arrow.d.ts +52 -72
- package/dist/lib/ir/path/arrow.d.ts.map +1 -1
- package/dist/lib/ir/path/path.cjs +22 -1
- package/dist/lib/ir/path/path.d.ts +637 -87
- package/dist/lib/ir/path/path.d.ts.map +1 -1
- package/dist/lib/ir/path/step.cjs +17 -3
- package/dist/lib/ir/path/step.d.ts +363 -8
- package/dist/lib/ir/path/step.d.ts.map +1 -1
- package/dist/lib/ir/scope.cjs +2 -1
- package/dist/lib/ir/scope.d.ts +1874 -338
- 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/ellipse.d.ts +3 -5
- package/dist/lib/primitive/ellipse.d.ts.map +1 -1
- package/dist/lib/primitive/index.d.ts +1 -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 +46 -0
- package/dist/lib/primitive/paint.d.ts.map +1 -0
- package/dist/lib/primitive/path.d.ts +25 -20
- package/dist/lib/primitive/path.d.ts.map +1 -1
- package/dist/lib/primitive/rect.d.ts +3 -2
- package/dist/lib/primitive/rect.d.ts.map +1 -1
- package/dist/lib/primitive/scene.d.ts +4 -0
- package/dist/lib/primitive/scene.d.ts.map +1 -1
- package/dist/lib/shapes/types.d.ts +2 -2
- package/dist/lib/shapes/types.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"}
|
|
@@ -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;AAqBjE,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;AA6FF;;;GAGG;AACH,eAAO,MAAM,cAAc,GAAI,IAAI,EAAE,EAAE,UAAS,cAAmB,KAAG,KA4UrE,CAAC"}
|
|
@@ -1,9 +1,12 @@
|
|
|
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
|
-
import { emitNodePrimitives, layoutNode } from "./node.js";
|
|
8
|
+
import { emitNodePrimitives, labelExtentPoints, layoutNode } from "./node.js";
|
|
9
|
+
import { createPaintRegistry } from "./paint.js";
|
|
7
10
|
import { fallbackMeasurer } from "./text-metrics.js";
|
|
8
11
|
import { emitPathPrimitive } from "./path/index.js";
|
|
9
12
|
import { makeRound } from "./precision.js";
|
|
@@ -109,6 +112,29 @@ var compileToScene = (ir, options = {}) => {
|
|
|
109
112
|
path: `options.shapes.${name}`
|
|
110
113
|
});
|
|
111
114
|
}
|
|
115
|
+
const effectivePathGenerators = options.pathGenerators ?? {};
|
|
116
|
+
const effectiveArrows = options.arrows ? {
|
|
117
|
+
...BUILTIN_ARROWS,
|
|
118
|
+
...options.arrows
|
|
119
|
+
} : BUILTIN_ARROWS;
|
|
120
|
+
if (options.arrows) {
|
|
121
|
+
for (const name of Object.keys(options.arrows)) if (Object.prototype.hasOwnProperty.call(BUILTIN_ARROWS, name)) onWarn({
|
|
122
|
+
code: "ARROW_OVERRIDES_BUILTIN",
|
|
123
|
+
message: `Injected arrow '${name}' overrides the built-in arrow of the same name.`,
|
|
124
|
+
path: `options.arrows.${name}`
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
const effectivePatterns = options.patterns ? {
|
|
128
|
+
...BUILTIN_PATTERNS,
|
|
129
|
+
...options.patterns
|
|
130
|
+
} : BUILTIN_PATTERNS;
|
|
131
|
+
if (options.patterns) {
|
|
132
|
+
for (const name of Object.keys(options.patterns)) if (Object.prototype.hasOwnProperty.call(BUILTIN_PATTERNS, name)) onWarn({
|
|
133
|
+
code: "PATTERN_OVERRIDES_BUILTIN",
|
|
134
|
+
message: `Injected pattern '${name}' overrides the built-in pattern of the same name.`,
|
|
135
|
+
path: `options.patterns.${name}`
|
|
136
|
+
});
|
|
137
|
+
}
|
|
112
138
|
const primitives = [];
|
|
113
139
|
/** 已 push 但未回填的占位计数;compileToScene 返回前必须归零(无条件守 Scene 公开契约) */
|
|
114
140
|
let placeholderBalance = 0;
|
|
@@ -133,6 +159,7 @@ var compileToScene = (ir, options = {}) => {
|
|
|
133
159
|
};
|
|
134
160
|
const nameStack = new NameStack({ onDuplicate: (info) => onWarn(formatDuplicateWarning(info)) });
|
|
135
161
|
const allPoints = [];
|
|
162
|
+
const paint = createPaintRegistry(effectivePatterns, round);
|
|
136
163
|
/**
|
|
137
164
|
* 解析一批本层收集的 pending paths(lookup-only 阶段)
|
|
138
165
|
* @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 子节点。
|
|
@@ -147,7 +174,10 @@ var compileToScene = (ir, options = {}) => {
|
|
|
147
174
|
const result = emitPathPrimitive(item.path, nameStack, round, measureText, {
|
|
148
175
|
onWarn,
|
|
149
176
|
irPath: item.irPath,
|
|
150
|
-
scopeChain: item.scopeChain
|
|
177
|
+
scopeChain: item.scopeChain,
|
|
178
|
+
resolveFill: paint.resolve,
|
|
179
|
+
effectiveArrows,
|
|
180
|
+
effectivePathGenerators
|
|
151
181
|
});
|
|
152
182
|
if (item.slot) {
|
|
153
183
|
const idx = item.slot.sink.indexOf(item.slot.placeholder);
|
|
@@ -184,11 +214,12 @@ var compileToScene = (ir, options = {}) => {
|
|
|
184
214
|
const layout = layoutNode(resolveNodeStyle(child, styleStack), measureText, nameStack, nodeDistance, chain, resolveLabelDefault(styleStack), effectiveShapes);
|
|
185
215
|
const globalLayout = chain.length === 0 ? layout : projectLayoutToGlobal(layout, chain);
|
|
186
216
|
if (child.id) nameStack.register(child.id, globalLayout, `${locatorPrefix}children[${i}].node.id`);
|
|
187
|
-
for (const prim of emitNodePrimitives(layout, round)) {
|
|
217
|
+
for (const prim of emitNodePrimitives(layout, round, paint.resolve)) {
|
|
188
218
|
sink.push(prim);
|
|
189
219
|
if (child.zIndex !== void 0) zIndexOf.set(prim, child.zIndex);
|
|
190
220
|
}
|
|
191
221
|
allPoints.push(rect.anchor(globalLayout.rect, "north-west"), rect.anchor(globalLayout.rect, "north-east"), rect.anchor(globalLayout.rect, "south-west"), rect.anchor(globalLayout.rect, "south-east"));
|
|
222
|
+
for (const p of labelExtentPoints(globalLayout)) allPoints.push(p);
|
|
192
223
|
layoutsAccumulator.push(globalLayout);
|
|
193
224
|
} else if (child.type === "coordinate") {
|
|
194
225
|
const localCenter = resolvePosition(child.position, nameStack, nodeDistance, chain);
|
|
@@ -272,9 +303,11 @@ var compileToScene = (ir, options = {}) => {
|
|
|
272
303
|
const detail = typeof process !== "undefined" && process.env.NODE_ENV !== "production" ? ` at ${collectPlaceholderLocators(primitives).join(", ")}` : "";
|
|
273
304
|
throw new Error(`internal: ${placeholderBalance} unresolved path placeholder(s) leaked into Scene output${detail}`);
|
|
274
305
|
}
|
|
306
|
+
const resources = paint.resources();
|
|
275
307
|
return {
|
|
276
308
|
primitives: stableSortByZIndex(sealSink(primitives)),
|
|
277
|
-
layout: computeLayout(allPoints, layoutPadding, round)
|
|
309
|
+
layout: computeLayout(allPoints, layoutPadding, round),
|
|
310
|
+
...resources.length > 0 ? { resources } : {}
|
|
278
311
|
};
|
|
279
312
|
};
|
|
280
313
|
//#endregion
|
|
@@ -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 };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Position } from '../geometry/point';
|
|
2
2
|
import { Rect } from '../geometry/rect';
|
|
3
|
-
import { AtDirection, IRLabelDefault, IRNode } from '../ir';
|
|
3
|
+
import { AtDirection, IRLabelDefault, IRNode, IRPaintSpec } from '../ir';
|
|
4
|
+
import { PaintResolver } from './paint';
|
|
4
5
|
import { ScenePrimitive, TextLine, Transform } from '../primitive';
|
|
5
6
|
import { ShapeDefinition } from '../shapes';
|
|
6
7
|
import { NameStack } from './name-stack';
|
|
@@ -42,8 +43,8 @@ export type NodeLayout = {
|
|
|
42
43
|
fontWeight?: string | number;
|
|
43
44
|
/** 字形 */
|
|
44
45
|
fontStyle?: 'normal' | 'italic' | 'oblique';
|
|
45
|
-
/**
|
|
46
|
-
fill?: string;
|
|
46
|
+
/** 节点背景填充(纯色 / PaintSpec gradient),emit 时经 resolveFill → PaintValue、'transparent' 兜底 */
|
|
47
|
+
fill?: string | IRPaintSpec;
|
|
47
48
|
/** 填充透明度 0~1 */
|
|
48
49
|
fillOpacity?: number;
|
|
49
50
|
/** 节点边框色,emit 时 'currentColor' 兜底 */
|
|
@@ -83,6 +84,14 @@ export type NodeLabelLayout = {
|
|
|
83
84
|
rotate?: 'none' | 'radial' | 'tangent' | number;
|
|
84
85
|
/** 自旋后若文字倒置则翻 180°;缺省 false */
|
|
85
86
|
keepUpright?: boolean;
|
|
87
|
+
/** label 文本测量宽度(pin leader 算 label 框近边用) */
|
|
88
|
+
measuredWidth: number;
|
|
89
|
+
/** pin:true = 默认引线;对象 = 带样式引线(stroke / strokeWidth / dashPattern);缺省 / false = 无引线 */
|
|
90
|
+
pin?: boolean | {
|
|
91
|
+
stroke?: string;
|
|
92
|
+
strokeWidth?: number;
|
|
93
|
+
dashPattern?: Array<number>;
|
|
94
|
+
};
|
|
86
95
|
};
|
|
87
96
|
/**
|
|
88
97
|
* 取节点 shape 在 toward 方向的附着点(path 端点贴边用)
|
|
@@ -113,5 +122,11 @@ export declare const layoutNode: (node: IRNode, measureText: TextMeasurer, nameS
|
|
|
113
122
|
* @description shape 主体走 `shapeDef.emit`(收轴对齐 rect、可出多 primitive);text 始终走 TextPrim;
|
|
114
123
|
* 有旋转时外层 GroupPrim 用 `rotate(deg cx cy)` 统一包裹 shape + text(diamond 顶点 / text 都靠 group 旋转)
|
|
115
124
|
*/
|
|
116
|
-
|
|
125
|
+
/**
|
|
126
|
+
* 节点 label 的外接点(供顶层 bbox / viewBox 计算,让 label 不被裁——与 step.label 进 bbox 一致)
|
|
127
|
+
* @description 每个 label 取其文本框四角;label 中心走 labelCenter(轴对齐系),node 自身 rotate 时绕 node 中心旋转
|
|
128
|
+
* (与 emit 的 group rotate 同步)。pin 引线起点在 node 边界内、已被 node 四角覆盖,无需额外。
|
|
129
|
+
*/
|
|
130
|
+
export declare const labelExtentPoints: (layout: NodeLayout) => Array<Position>;
|
|
131
|
+
export declare const emitNodePrimitives: (layout: NodeLayout, round: (n: number) => number, resolveFill: PaintResolver) => Array<ScenePrimitive>;
|
|
117
132
|
//# sourceMappingURL=node.d.ts.map
|
|
@@ -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,MAAM,OAAO,CAAC;
|
|
1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