@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
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ArrowShapeName } from '../ir/path/arrow';
|
|
2
|
+
import { MarkerPrimitive } from './marker';
|
|
2
3
|
import { PaintValue } from './paint';
|
|
3
4
|
/** Move command:移动游标到目标点,不绘制 */
|
|
4
5
|
export type MovePathCommand = {
|
|
@@ -79,26 +80,29 @@ export type ClosePathCommand = {
|
|
|
79
80
|
*/
|
|
80
81
|
export type PathCommand = MovePathCommand | LinePathCommand | QuadPathCommand | CubicPathCommand | ArcPathCommand | EllipseArcPathCommand | ClosePathCommand;
|
|
81
82
|
/**
|
|
82
|
-
*
|
|
83
|
-
* @description compile
|
|
83
|
+
* 端点级已解析的箭头 marker 描述(Scene primitive 层,renderer-agnostic)
|
|
84
|
+
* @description compile 把 IR `arrowDetail` 顶层 + start/end merge、查 effective arrow 表、调 `def.emit`
|
|
85
|
+
* 产几何,所有视觉输入(scale / length / width / color / fill / lineWidth)在 compile 解析阶段被消费、
|
|
86
|
+
* **不**出现在本结构里。最终挂在 `PathPrim.arrowStart` / `arrowEnd` 上的是"已解析 marker 描述":内部几何
|
|
87
|
+
* `marker`(`MarkerPrimitive[]`,局部 baseSize 坐标系)+ wrapper 参数(`baseSize` / `refX` / `markerWidth` /
|
|
88
|
+
* `markerHeight` / `opacity`)。adapter 只**物化**——把 `marker` 嵌进 `<marker viewBox refX refY markerWidth
|
|
89
|
+
* markerHeight>`,不再 switch、不调 emit、不需要 arrows 注册表。纯 JSON 数据(无函数)。
|
|
84
90
|
*/
|
|
85
91
|
export type ArrowEndSpec = {
|
|
86
|
-
/**
|
|
87
|
-
shape:
|
|
88
|
-
/**
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
fill?: string;
|
|
98
|
-
/** 箭头不透明度 0..1;缺省继承 path opacity */
|
|
92
|
+
/** 形状名:内置 7 或经 `CompileOptions.arrows` 注册的扩展名;标识 / 调试用,已解析后渲染不依赖(保留) */
|
|
93
|
+
shape: ArrowShapeName;
|
|
94
|
+
/** marker viewBox 边长(`def.baseSize ?? 10`);adapter 据此推 viewBox `0 0 baseSize baseSize` 与 refY = baseSize/2 */
|
|
95
|
+
baseSize: number;
|
|
96
|
+
/** 线接触点(marker refX);hollow 已在 compile 解析阶段减 lineWidth/2(adapter 不再算) */
|
|
97
|
+
refX: number;
|
|
98
|
+
/** 已解析尖长 = `(length ?? def.defaultLength) * scale`(adapter 直接当 markerWidth 用) */
|
|
99
|
+
markerWidth: number;
|
|
100
|
+
/** 已解析尖宽 = `(width ?? def.defaultWidth) * scale`(adapter 直接当 markerHeight 用) */
|
|
101
|
+
markerHeight: number;
|
|
102
|
+
/** marker 元素级不透明度 0..1;缺省继承 path opacity */
|
|
99
103
|
opacity?: number;
|
|
100
|
-
/**
|
|
101
|
-
|
|
104
|
+
/** `def.emit` 产物:局部 baseSize 坐标系下的内部几何(fill 限 `string | { kind:'contextStroke' }`) */
|
|
105
|
+
marker: Array<MarkerPrimitive>;
|
|
102
106
|
};
|
|
103
107
|
/** 路径原语:结构化 commands 数组;adapter 在 render 时翻译为各自原生 API */
|
|
104
108
|
export type PathPrim = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../../src/primitive/path.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../../src/primitive/path.ts"],"names":[],"mappings":"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"}
|
|
@@ -5,7 +5,8 @@ import { RectPrim } from './rect';
|
|
|
5
5
|
import { TextPrim } from './text';
|
|
6
6
|
import { Layout } from './layout';
|
|
7
7
|
import { SceneResource } from './paint';
|
|
8
|
-
export type { PaintValue, SceneResource } from './paint';
|
|
8
|
+
export type { PaintValue, SceneResource, PaintResource, ResolvedPatternTile } from './paint';
|
|
9
|
+
export type { ClipShape, ClipResource } from './clip';
|
|
9
10
|
/**
|
|
10
11
|
* Scene primitive:渲染目标无关的最大公约子集
|
|
11
12
|
* @description 所有 adapter(SVG/Canvas/PDF/Skia)都应能消费;不允许出现 SVG-only 或 Canvas-only 特性(filter/marker/imageData)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scene.d.ts","sourceRoot":"","sources":["../../../src/primitive/scene.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"scene.d.ts","sourceRoot":"","sources":["../../../src/primitive/scene.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAC7F,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtD;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,WAAW,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEtF,qCAAqC;AACrC,MAAM,MAAM,KAAK,GAAG;IAClB,wBAAwB;IACxB,UAAU,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;IAClC,gBAAgB;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,gEAAgE;IAChE,SAAS,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;CAClC,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
|
+
exports.BUILTIN_ARROWS = BUILTIN_ARROWS;
|
|
@@ -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,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,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
|
+
exports.createClipRegistry = createClipRegistry;
|
|
@@ -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"}
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
const require_rect = require("../geometry/rect.cjs");
|
|
2
2
|
const require_index = require("../shapes/index.cjs");
|
|
3
|
+
const require_index$1 = require("../arrows/index.cjs");
|
|
4
|
+
const require_index$2 = require("../patterns/index.cjs");
|
|
3
5
|
const require_name_stack = require("./name-stack.cjs");
|
|
4
6
|
const require_scope = require("./scope.cjs");
|
|
5
7
|
const require_position = require("./position.cjs");
|
|
6
8
|
const require_node = require("./node.cjs");
|
|
7
9
|
const require_paint = require("./paint.cjs");
|
|
10
|
+
const require_clip = require("./clip.cjs");
|
|
8
11
|
const require_text_metrics = require("./text-metrics.cjs");
|
|
9
|
-
const
|
|
12
|
+
const require_anchor = require("./path/anchor.cjs");
|
|
13
|
+
const require_index$3 = require("./path/index.cjs");
|
|
10
14
|
const require_precision = require("./precision.cjs");
|
|
11
15
|
const require_style = require("./style.cjs");
|
|
12
16
|
const require_layout = require("./layout.cjs");
|
|
@@ -50,6 +54,28 @@ var scopePlaceholderLayout = (id, chain) => {
|
|
|
50
54
|
return zeroSizeRectAt(id, chain.length === 0 ? [0, 0] : require_scope.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
|
+
...require_index$1.BUILTIN_ARROWS,
|
|
142
|
+
...options.arrows
|
|
143
|
+
} : require_index$1.BUILTIN_ARROWS;
|
|
144
|
+
if (options.arrows) {
|
|
145
|
+
for (const name of Object.keys(options.arrows)) if (Object.prototype.hasOwnProperty.call(require_index$1.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
|
+
...require_index$2.BUILTIN_PATTERNS,
|
|
153
|
+
...options.patterns
|
|
154
|
+
} : require_index$2.BUILTIN_PATTERNS;
|
|
155
|
+
if (options.patterns) {
|
|
156
|
+
for (const name of Object.keys(options.patterns)) if (Object.prototype.hasOwnProperty.call(require_index$2.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 require_name_stack.NameStack({ onDuplicate: (info) => onWarn(formatDuplicateWarning(info)) });
|
|
136
185
|
const allPoints = [];
|
|
137
|
-
const paint = require_paint.createPaintRegistry();
|
|
186
|
+
const paint = require_paint.createPaintRegistry(effectivePatterns, round);
|
|
187
|
+
const clip = require_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 子节点。
|
|
@@ -146,11 +196,13 @@ var compileToScene = (ir, options = {}) => {
|
|
|
146
196
|
nameStack.enterLookupPhase();
|
|
147
197
|
try {
|
|
148
198
|
for (const item of pending) {
|
|
149
|
-
const result = require_index$
|
|
199
|
+
const result = require_index$3.emitPathPrimitive(item.path, nameStack, round, measureText, {
|
|
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 = require_node.layoutNode(require_style.resolveNodeStyle(child, styleStack), measureText, nameStack, nodeDistance, chain, require_style.resolveLabelDefault(styleStack), effectiveShapes);
|
|
239
|
+
const layout = require_node.layoutNode(require_style.resolveNodeStyle(child, styleStack), measureText, nameStack, nodeDistance, chain, require_style.resolveLabelDefault(styleStack), effectiveShapes, require_anchor.refPointOfTarget);
|
|
188
240
|
const globalLayout = chain.length === 0 ? layout : require_scope.projectLayoutToGlobal(layout, chain);
|
|
189
241
|
if (child.id) nameStack.register(child.id, globalLayout, `${locatorPrefix}children[${i}].node.id`);
|
|
190
242
|
for (const prim of require_node.emitNodePrimitives(layout, round, paint.resolve)) {
|
|
@@ -195,7 +247,7 @@ var compileToScene = (ir, options = {}) => {
|
|
|
195
247
|
for (const p of require_node.labelExtentPoints(globalLayout)) allPoints.push(p);
|
|
196
248
|
layoutsAccumulator.push(globalLayout);
|
|
197
249
|
} else if (child.type === "coordinate") {
|
|
198
|
-
const localCenter = require_position.resolvePosition(child.position, nameStack, nodeDistance, chain);
|
|
250
|
+
const localCenter = require_position.resolvePosition(child.position, nameStack, nodeDistance, chain, require_anchor.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: require_layout.computeLayout(allPoints, layoutPadding, round),
|
|
335
|
+
layout: ir.viewBox !== void 0 ? viewBoxToLayout(ir.viewBox, round) : require_layout.computeLayout(allPoints, layoutPadding, round),
|
|
283
336
|
...resources.length > 0 ? { resources } : {}
|
|
284
337
|
};
|
|
285
338
|
};
|
|
@@ -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"}
|