@retikz/core 0.2.0-alpha.8 → 0.2.0-beta.1
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 +1 -1
- package/dist/es/arrows/index.js +1 -1
- 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.map +1 -1
- package/dist/es/compile/compile.js +31 -5
- 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/path/anchor.d.ts.map +1 -1
- package/dist/es/compile/path/anchor.js +12 -0
- package/dist/es/compile/path/index.d.ts.map +1 -1
- package/dist/es/compile/path/index.js +11 -3
- 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/compile/precision.d.ts +6 -1
- package/dist/es/compile/precision.d.ts.map +1 -1
- package/dist/es/compile/precision.js +10 -2
- package/dist/es/index.d.ts +5 -3
- package/dist/es/index.d.ts.map +1 -1
- package/dist/es/index.js +7 -5
- 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 +1 -0
- package/dist/es/ir/index.d.ts.map +1 -1
- package/dist/es/ir/node.d.ts +5 -5
- package/dist/es/ir/node.d.ts.map +1 -1
- package/dist/es/ir/node.js +4 -2
- package/dist/es/ir/path/arrow.d.ts +12 -12
- package/dist/es/ir/path/path.d.ts +128 -128
- package/dist/es/ir/path/step.d.ts +134 -134
- package/dist/es/ir/path/step.js +1 -1
- 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 +303 -198
- package/dist/es/ir/scope.d.ts.map +1 -1
- package/dist/es/ir/scope.js +2 -0
- package/dist/es/patterns/index.d.ts +1 -1
- package/dist/es/patterns/index.js +1 -1
- 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 +1 -0
- package/dist/es/primitive/index.d.ts.map +1 -1
- package/dist/es/primitive/paint.d.ts +11 -5
- package/dist/es/primitive/paint.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 +1 -1
- package/dist/lib/arrows/index.d.ts +1 -1
- 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 +31 -5
- package/dist/lib/compile/compile.d.ts.map +1 -1
- 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/path/anchor.cjs +12 -0
- package/dist/lib/compile/path/anchor.d.ts.map +1 -1
- package/dist/lib/compile/path/index.cjs +11 -3
- package/dist/lib/compile/path/index.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/compile/precision.cjs +10 -2
- package/dist/lib/compile/precision.d.ts +6 -1
- package/dist/lib/compile/precision.d.ts.map +1 -1
- package/dist/lib/index.cjs +9 -3
- package/dist/lib/index.d.ts +5 -3
- 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 +1 -0
- package/dist/lib/ir/index.d.ts.map +1 -1
- package/dist/lib/ir/node.cjs +4 -2
- package/dist/lib/ir/node.d.ts +5 -5
- package/dist/lib/ir/node.d.ts.map +1 -1
- package/dist/lib/ir/path/arrow.d.ts +12 -12
- package/dist/lib/ir/path/path.d.ts +128 -128
- package/dist/lib/ir/path/step.cjs +1 -1
- package/dist/lib/ir/path/step.d.ts +134 -134
- 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 +303 -198
- package/dist/lib/ir/scope.d.ts.map +1 -1
- package/dist/lib/patterns/index.cjs +1 -1
- package/dist/lib/patterns/index.d.ts +1 -1
- 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 +1 -0
- package/dist/lib/primitive/index.d.ts.map +1 -1
- package/dist/lib/primitive/paint.d.ts +11 -5
- package/dist/lib/primitive/paint.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
|
@@ -6,7 +6,7 @@ import { ArrowDefinition } from './types';
|
|
|
6
6
|
* 实心 normal/diamond/circle lineContactX=0;stealth=3;open/openDiamond base=1 + tipX=9 + hollow;
|
|
7
7
|
* openCircle base=0.75 + hollow。baseSize / defaultLength / defaultWidth 走类型缺省(10 / 6 / 6)。
|
|
8
8
|
* framework 对 hollow def 统一把 lineContactX 减 lineWidth/2 得实际 refX / shrink 接触点。
|
|
9
|
-
* emit 几何在局部 baseSize=10
|
|
9
|
+
* emit 几何在局部 baseSize=10 坐标系(renderer-agnostic)。
|
|
10
10
|
*/
|
|
11
11
|
export declare const BUILTIN_ARROWS: Record<BuiltinArrowName, ArrowDefinition>;
|
|
12
12
|
export type { ArrowDefinition, ArrowEmitContext } from './types';
|
package/dist/es/arrows/index.js
CHANGED
|
@@ -39,7 +39,7 @@ var hollowPath = (ctx, points, strokeLinejoin) => ({
|
|
|
39
39
|
* 实心 normal/diamond/circle lineContactX=0;stealth=3;open/openDiamond base=1 + tipX=9 + hollow;
|
|
40
40
|
* openCircle base=0.75 + hollow。baseSize / defaultLength / defaultWidth 走类型缺省(10 / 6 / 6)。
|
|
41
41
|
* framework 对 hollow def 统一把 lineContactX 减 lineWidth/2 得实际 refX / shrink 接触点。
|
|
42
|
-
* emit 几何在局部 baseSize=10
|
|
42
|
+
* emit 几何在局部 baseSize=10 坐标系(renderer-agnostic)。
|
|
43
43
|
*/
|
|
44
44
|
var BUILTIN_ARROWS = {
|
|
45
45
|
normal: {
|
|
@@ -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 +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;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;
|
|
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"}
|
|
@@ -7,7 +7,9 @@ import { applyTransformChain, computeScopeBoundingBox, lowerScopeTransforms, pro
|
|
|
7
7
|
import { resolvePosition } from "./position.js";
|
|
8
8
|
import { emitNodePrimitives, labelExtentPoints, layoutNode } from "./node.js";
|
|
9
9
|
import { createPaintRegistry } from "./paint.js";
|
|
10
|
+
import { createClipRegistry } from "./clip.js";
|
|
10
11
|
import { fallbackMeasurer } from "./text-metrics.js";
|
|
12
|
+
import { refPointOfTarget } from "./path/anchor.js";
|
|
11
13
|
import { emitPathPrimitive } from "./path/index.js";
|
|
12
14
|
import { makeRound } from "./precision.js";
|
|
13
15
|
import { buildStyleFrame, resolveEffectivePath, resolveLabelDefault, resolveNodeStyle } from "./style.js";
|
|
@@ -52,6 +54,28 @@ var scopePlaceholderLayout = (id, chain) => {
|
|
|
52
54
|
return zeroSizeRectAt(id, chain.length === 0 ? [0, 0] : applyTransformChain([0, 0], chain));
|
|
53
55
|
};
|
|
54
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
|
+
/**
|
|
55
79
|
* 默认 warn dispatcher:dev 模式 console.warn、生产静默
|
|
56
80
|
* @description 用户传 onWarn 时使用用户的;不传走此 fallback
|
|
57
81
|
*/
|
|
@@ -160,6 +184,7 @@ var compileToScene = (ir, options = {}) => {
|
|
|
160
184
|
const nameStack = new NameStack({ onDuplicate: (info) => onWarn(formatDuplicateWarning(info)) });
|
|
161
185
|
const allPoints = [];
|
|
162
186
|
const paint = createPaintRegistry(effectivePatterns, round);
|
|
187
|
+
const clip = createClipRegistry(round);
|
|
163
188
|
/**
|
|
164
189
|
* 解析一批本层收集的 pending paths(lookup-only 阶段)
|
|
165
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 子节点。
|
|
@@ -211,7 +236,7 @@ var compileToScene = (ir, options = {}) => {
|
|
|
211
236
|
for (let i = 0; i < children.length; i++) {
|
|
212
237
|
const child = children[i];
|
|
213
238
|
if (child.type === "node") {
|
|
214
|
-
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);
|
|
215
240
|
const globalLayout = chain.length === 0 ? layout : projectLayoutToGlobal(layout, chain);
|
|
216
241
|
if (child.id) nameStack.register(child.id, globalLayout, `${locatorPrefix}children[${i}].node.id`);
|
|
217
242
|
for (const prim of emitNodePrimitives(layout, round, paint.resolve)) {
|
|
@@ -222,7 +247,7 @@ var compileToScene = (ir, options = {}) => {
|
|
|
222
247
|
for (const p of labelExtentPoints(globalLayout)) allPoints.push(p);
|
|
223
248
|
layoutsAccumulator.push(globalLayout);
|
|
224
249
|
} else if (child.type === "coordinate") {
|
|
225
|
-
const localCenter = resolvePosition(child.position, nameStack, nodeDistance, chain);
|
|
250
|
+
const localCenter = resolvePosition(child.position, nameStack, nodeDistance, chain, refPointOfTarget);
|
|
226
251
|
if (!localCenter) {
|
|
227
252
|
onWarn({
|
|
228
253
|
code: "POLAR_ORIGIN_UNRESOLVED",
|
|
@@ -268,12 +293,13 @@ var compileToScene = (ir, options = {}) => {
|
|
|
268
293
|
if (pushedFrame) nameStack.popFrame();
|
|
269
294
|
}
|
|
270
295
|
const hasOwnTransforms = ownTransforms.length > 0;
|
|
271
|
-
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;
|
|
272
297
|
const group = {
|
|
273
298
|
type: "group",
|
|
274
299
|
children: stableSortByZIndex(sealSink(innerSink))
|
|
275
300
|
};
|
|
276
301
|
if (hasOwnTransforms) group.transforms = [...ownTransforms];
|
|
302
|
+
if (child.clip !== void 0) group.clipRef = clip.resolve(child.clip);
|
|
277
303
|
sink.push(group);
|
|
278
304
|
if (child.zIndex !== void 0) zIndexOf.set(group, child.zIndex);
|
|
279
305
|
} else {
|
|
@@ -303,10 +329,10 @@ var compileToScene = (ir, options = {}) => {
|
|
|
303
329
|
const detail = typeof process !== "undefined" && process.env.NODE_ENV !== "production" ? ` at ${collectPlaceholderLocators(primitives).join(", ")}` : "";
|
|
304
330
|
throw new Error(`internal: ${placeholderBalance} unresolved path placeholder(s) leaked into Scene output${detail}`);
|
|
305
331
|
}
|
|
306
|
-
const resources = paint.resources();
|
|
332
|
+
const resources = [...paint.resources(), ...clip.resources()];
|
|
307
333
|
return {
|
|
308
334
|
primitives: stableSortByZIndex(sealSink(primitives)),
|
|
309
|
-
layout: computeLayout(allPoints, layoutPadding, round),
|
|
335
|
+
layout: ir.viewBox !== void 0 ? viewBoxToLayout(ir.viewBox, round) : computeLayout(allPoints, layoutPadding, round),
|
|
310
336
|
...resources.length > 0 ? { resources } : {}
|
|
311
337
|
};
|
|
312
338
|
};
|
|
@@ -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,M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,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;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anchor.d.ts","sourceRoot":"","sources":["../../../../src/compile/path/anchor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"anchor.d.ts","sourceRoot":"","sources":["../../../../src/compile/path/anchor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmC,UAAU,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACtF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAGjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAyB/C;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAC3B,QAAQ,QAAQ,EAChB,WAAW,SAAS,EACpB,aAAY,aAAa,CAAC,SAAS,CAAM,KACxC,UAAU,GAAG,IA8Bf,CAAC;AAEF,4DAA4D;AAC5D,eAAO,MAAM,QAAQ,GACnB,MAAM,UAAU,EAChB,MAAM,UAAU,EAChB,KAAK,IAAI,GAAG,IAAI,KACf,UACqD,CAAC;AAEzD;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GACxB,QAAQ,QAAQ,EAChB,QAAQ,UAAU,EAClB,WAAW,SAAS,EACpB,aAAY,aAAa,CAAC,SAAS,CAAM,KACxC,UAAU,GAAG,IAsBf,CAAC;AAEF,qCAAqC;AACrC,eAAO,MAAM,SAAS,GAAI,GAAG,UAAU,GAAG,IAAI,EAAE,GAAG,UAAU,GAAG,IAAI,KAAG,OACzB,CAAC;AAE/C,6BAA6B;AAC7B,eAAO,MAAM,WAAW,GAAI,GAAG,UAAU,EAAE,QAAQ,UAAU,EAAE,MAAM,MAAM,KAAG,UAM7E,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { lerpPoint } from "../../geometry/_edge.js";
|
|
1
2
|
import { applyTransformChain } from "../scope.js";
|
|
2
3
|
import { resolvePosition } from "../position.js";
|
|
3
4
|
import { boundaryPointOf } from "../node.js";
|
|
@@ -5,6 +6,8 @@ import { resolveAnchor, resolveEdgePoint } from "../anchor-cache.js";
|
|
|
5
6
|
//#region src/compile/path/anchor.ts
|
|
6
7
|
/** target 是否对象形态 NodeTarget(`{ id, anchor?, offset? }`);与 Position(array) / Polar / Offset(of) / Relative 区分(独有 `id`) */
|
|
7
8
|
var isNodeTarget = (t) => typeof t === "object" && !Array.isArray(t) && "id" in t;
|
|
9
|
+
/** target 是否 between 比例点(`{ between, t }`);独有 `between` 字段 */
|
|
10
|
+
var isBetween = (t) => typeof t === "object" && !Array.isArray(t) && "between" in t;
|
|
8
11
|
/** 解析 NodeTarget 的 anchor(非 undefined)到世界坐标:命名 / 角度走 resolveAnchor,`{ side, t }` 走 resolveEdgePoint */
|
|
9
12
|
var resolveAnchorRef = (node, anchor) => {
|
|
10
13
|
if (typeof anchor === "number") return resolveAnchor(node, String(anchor));
|
|
@@ -26,6 +29,14 @@ var refPointOfTarget = (target, nameStack, scopeChain = []) => {
|
|
|
26
29
|
if (!node) return null;
|
|
27
30
|
return addOffset(target.anchor === void 0 ? [node.rect.x, node.rect.y] : resolveAnchorRef(node, target.anchor), target.offset);
|
|
28
31
|
}
|
|
32
|
+
if (isBetween(target)) {
|
|
33
|
+
const a = refPointOfTarget(target.between[0], nameStack, scopeChain);
|
|
34
|
+
const b = refPointOfTarget(target.between[1], nameStack, scopeChain);
|
|
35
|
+
if (!a || !b) return null;
|
|
36
|
+
const mid = lerpPoint(a, b, target.t);
|
|
37
|
+
if (!Number.isFinite(mid[0]) || !Number.isFinite(mid[1])) return null;
|
|
38
|
+
return mid;
|
|
39
|
+
}
|
|
29
40
|
if (typeof target === "object" && !Array.isArray(target) && ("relative" in target || "relativeAccumulate" in target)) return null;
|
|
30
41
|
const local = resolvePosition(target, nameStack, void 0, scopeChain);
|
|
31
42
|
if (!local) return null;
|
|
@@ -45,6 +56,7 @@ var clipForTarget = (target, toward, nameStack, scopeChain = []) => {
|
|
|
45
56
|
if (!node) return null;
|
|
46
57
|
return addOffset(target.anchor === void 0 ? boundaryPointOf(node, toward) : resolveAnchorRef(node, target.anchor), target.offset);
|
|
47
58
|
}
|
|
59
|
+
if (isBetween(target)) return refPointOfTarget(target, nameStack, scopeChain);
|
|
48
60
|
if (typeof target === "object" && !Array.isArray(target) && ("relative" in target || "relativeAccumulate" in target)) return null;
|
|
49
61
|
const local = resolvePosition(target, nameStack, void 0, scopeChain);
|
|
50
62
|
if (!local) return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/compile/path/index.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAY9C,OAAO,KAAK,EACV,MAAM,EAEN,UAAU,EAGX,MAAM,UAAU,CAAC;AAElB,OAAO,KAAK,EAIV,cAAc,EACd,SAAS,EACV,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,KAAK,YAAY,EAAoB,MAAM,iBAAiB,CAAC;AAKtE,OAAO,EAAE,KAAK,eAAe,EAA2D,MAAM,UAAU,C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AE,KAAK,CAAC,cAAc,CAAC,CAAC;IAAC,MAAM,EAAE,KAAK,CAAC,UAAU,CAAC,CAAA;CAAE,GAAG,IA0tBrE,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { JsonObjectSchema } from "../../ir/json.js";
|
|
2
1
|
import { rectOutline } from "../../geometry/rect.js";
|
|
2
|
+
import { JsonObjectSchema } from "../../ir/json.js";
|
|
3
3
|
import { BUILTIN_ARROWS } from "../../arrows/index.js";
|
|
4
4
|
import { applyTransformChain } from "../scope.js";
|
|
5
5
|
import { arcBoundingPoints, arcEndPoint, ellipseArcBoundingPoints, ellipseArcPoint } from "../../geometry/arc.js";
|
|
@@ -12,8 +12,16 @@ import { normalizeRelativeTargets } from "./relative.js";
|
|
|
12
12
|
import { applyArrowShrinks, endpointArrows, resolveMarkArrowSpec } from "./shrink.js";
|
|
13
13
|
import { splitSubPathsForEndpointArrows } from "./split.js";
|
|
14
14
|
//#region src/compile/path/index.ts
|
|
15
|
-
/**
|
|
16
|
-
|
|
15
|
+
/**
|
|
16
|
+
* 目标里的一个代表性节点 id——给 UNRESOLVED_NODE_REFERENCE 诊断用
|
|
17
|
+
* @description 对象 NodeTarget(`{ id, ... }`)直接取 id;between 比例点递归挖端点里第一个节点引用
|
|
18
|
+
* (端点未解析时整 between 失败,需照样报 unresolved 而非静默);其余形态返回 undefined。
|
|
19
|
+
*/
|
|
20
|
+
var nodeRefId = (t) => {
|
|
21
|
+
if (typeof t !== "object" || Array.isArray(t)) return void 0;
|
|
22
|
+
if ("id" in t) return t.id;
|
|
23
|
+
if ("between" in t) return nodeRefId(t.between[0]) ?? nodeRefId(t.between[1]);
|
|
24
|
+
};
|
|
17
25
|
/** 有限数 */
|
|
18
26
|
var isFiniteNum = (n) => typeof n === "number" && Number.isFinite(n);
|
|
19
27
|
/** 有限坐标点 `[number, number]` */
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
import { IRAtPosition, IROffsetPosition, IRPosition, PolarPosition } from '../ir';
|
|
1
|
+
import { IRAtPosition, IRBetweenPosition, IROffsetPosition, IRPosition, PolarPosition } from '../ir';
|
|
2
2
|
import { Transform } from '../primitive';
|
|
3
3
|
import { NameStack } from './name-stack';
|
|
4
|
+
/**
|
|
5
|
+
* between 端点 → 世界坐标解析器(依赖注入,避免 position.ts ↔ compile/path/anchor.ts 循环)
|
|
6
|
+
* @description 实参由 compile 层注入(= `refPointOfTarget`,处理 NodeTarget anchor / Cartesian / Polar /
|
|
7
|
+
* Offset / 嵌套 between,返回世界坐标)。resolvePosition 收到 between 时调它取世界中点再反投影回局部。
|
|
8
|
+
*/
|
|
9
|
+
export type ResolveBetweenGlobal = (between: IRBetweenPosition, nameStack: NameStack, scopeChain: ReadonlyArray<Transform>) => IRPosition | null;
|
|
4
10
|
/**
|
|
5
11
|
* IR 各种位置形态(笛卡尔/极坐标/相对定位/偏移定位/节点 id)→ 笛卡尔位置
|
|
6
12
|
* @description
|
|
@@ -20,5 +26,5 @@ import { NameStack } from './name-stack';
|
|
|
20
26
|
* - 节点 id lookup 走 NameStack.lookup 进行 inside-out 搜索(内层 frame 可见外层 frame);
|
|
21
27
|
* nodeDistance 为容器 prop 注入默认距离,AtPosition 自带 distance 优先
|
|
22
28
|
*/
|
|
23
|
-
export declare const resolvePosition: (pos: IRPosition | PolarPosition | IRAtPosition | IROffsetPosition | string, nameStack: NameStack, nodeDistance?: number, scopeChain?: ReadonlyArray<Transform
|
|
29
|
+
export declare const resolvePosition: (pos: IRPosition | PolarPosition | IRAtPosition | IROffsetPosition | IRBetweenPosition | string, nameStack: NameStack, nodeDistance?: number, scopeChain?: ReadonlyArray<Transform>, resolveBetweenGlobal?: ResolveBetweenGlobal) => IRPosition | null;
|
|
24
30
|
//# sourceMappingURL=position.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"position.d.ts","sourceRoot":"","sources":["../../../src/compile/position.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,YAAY,EAAE,gBAAgB,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"position.d.ts","sourceRoot":"","sources":["../../../src/compile/position.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACvH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAG9C;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,GAAG,CACjC,OAAO,EAAE,iBAAiB,EAC1B,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,aAAa,CAAC,SAAS,CAAC,KACjC,UAAU,GAAG,IAAI,CAAC;AAoBvB;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,eAAe,GAC1B,KAAK,UAAU,GAAG,aAAa,GAAG,YAAY,GAAG,gBAAgB,GAAG,iBAAiB,GAAG,MAAM,EAC9F,WAAW,SAAS,EACpB,eAAc,MAA8B,EAC5C,aAAY,aAAa,CAAC,SAAS,CAAM,EACzC,uBAAuB,oBAAoB,KAC1C,UAAU,GAAG,IAiDf,CAAC"}
|
|
@@ -35,7 +35,7 @@ var DIRECTION_VECTOR = {
|
|
|
35
35
|
* - 节点 id lookup 走 NameStack.lookup 进行 inside-out 搜索(内层 frame 可见外层 frame);
|
|
36
36
|
* nodeDistance 为容器 prop 注入默认距离,AtPosition 自带 distance 优先
|
|
37
37
|
*/
|
|
38
|
-
var resolvePosition = (pos, nameStack, nodeDistance = DEFAULT_NODE_DISTANCE, scopeChain = []) => {
|
|
38
|
+
var resolvePosition = (pos, nameStack, nodeDistance = DEFAULT_NODE_DISTANCE, scopeChain = [], resolveBetweenGlobal) => {
|
|
39
39
|
if (typeof pos === "string") {
|
|
40
40
|
const node = nameStack.lookup(pos);
|
|
41
41
|
if (!node) return null;
|
|
@@ -57,6 +57,12 @@ var resolvePosition = (pos, nameStack, nodeDistance = DEFAULT_NODE_DISTANCE, sco
|
|
|
57
57
|
if (!base) return null;
|
|
58
58
|
return [base[0] + pos.offset[0], base[1] + pos.offset[1]];
|
|
59
59
|
}
|
|
60
|
+
if ("between" in pos) {
|
|
61
|
+
if (!resolveBetweenGlobal) return null;
|
|
62
|
+
const global = resolveBetweenGlobal(pos, nameStack, scopeChain);
|
|
63
|
+
if (!global) return null;
|
|
64
|
+
return scopeChain.length === 0 ? global : inverseTransformChain(global, scopeChain);
|
|
65
|
+
}
|
|
60
66
|
let origin;
|
|
61
67
|
if (!pos.origin) origin = [0, 0];
|
|
62
68
|
else {
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
/** 默认输出精度:保留 2 位小数 */
|
|
2
2
|
export declare const DEFAULT_PRECISION = 2;
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* 按指定小数位精度四舍五入;precision = 0 表示取整
|
|
5
|
+
* @description 末端把 `-0` 归一为 `+0`——`Math.round` 对负的亚精度值(如 `-0.001`)产 `-0`,
|
|
6
|
+
* 而 `JSON.stringify(-0) === '0'` 会让 Scene round-trip 在 `Object.is` 层失真(`-0 !== 0` 于 Object.is)。
|
|
7
|
+
* 归一让序列化往返稳定;数值上 `-0 === 0`,渲染 / 计算无影响。
|
|
8
|
+
*/
|
|
4
9
|
export declare const makeRound: (precision: number) => (n: number) => number;
|
|
5
10
|
//# sourceMappingURL=precision.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"precision.d.ts","sourceRoot":"","sources":["../../../src/compile/precision.ts"],"names":[],"mappings":"AAAA,sBAAsB;AACtB,eAAO,MAAM,iBAAiB,IAAI,CAAC;AAEnC
|
|
1
|
+
{"version":3,"file":"precision.d.ts","sourceRoot":"","sources":["../../../src/compile/precision.ts"],"names":[],"mappings":"AAAA,sBAAsB;AACtB,eAAO,MAAM,iBAAiB,IAAI,CAAC;AAEnC;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GAAI,WAAW,MAAM,MAEjC,GAAG,MAAM,WAIlB,CAAC"}
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
//#region src/compile/precision.ts
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* 按指定小数位精度四舍五入;precision = 0 表示取整
|
|
4
|
+
* @description 末端把 `-0` 归一为 `+0`——`Math.round` 对负的亚精度值(如 `-0.001`)产 `-0`,
|
|
5
|
+
* 而 `JSON.stringify(-0) === '0'` 会让 Scene round-trip 在 `Object.is` 层失真(`-0 !== 0` 于 Object.is)。
|
|
6
|
+
* 归一让序列化往返稳定;数值上 `-0 === 0`,渲染 / 计算无影响。
|
|
7
|
+
*/
|
|
3
8
|
var makeRound = (precision) => {
|
|
4
9
|
const factor = 10 ** precision;
|
|
5
|
-
return (n) =>
|
|
10
|
+
return (n) => {
|
|
11
|
+
const r = Math.round(n * factor) / factor;
|
|
12
|
+
return r === 0 ? 0 : r;
|
|
13
|
+
};
|
|
6
14
|
};
|
|
7
15
|
//#endregion
|
|
8
16
|
export { makeRound };
|
package/dist/es/index.d.ts
CHANGED
|
@@ -2,14 +2,16 @@
|
|
|
2
2
|
* @retikz/core 公开 API
|
|
3
3
|
* @description 任何 framework adapter(@retikz/react、@retikz/vue、@retikz/canvas、@retikz/ssr)只能 import 本文件导出内容,不准走子路径。本包零 React/零 DOM 依赖
|
|
4
4
|
*/
|
|
5
|
-
export { PositionSchema, PolarPositionSchema, AtPositionSchema, OffsetPositionSchema, AT_DIRECTIONS, TargetSchema, AnchorRefSchema, NodeTargetSchema, RelativeTargetSchema, RelativeAccumulateTargetSchema, MoveStepSchema, LineStepSchema, FoldStepSchema, CycleStepSchema, CurveStepSchema, CubicStepSchema, BendStepSchema, ArcStepSchema, CirclePathStepSchema, EllipsePathStepSchema, RectangleStepSchema, GeneratorStepSchema, ControlPointSchema, StepLabelSchema, StepSchema, NodeSchema, NodeLabelSchema, CoordinateSchema, FontSchema, TextBlockSchema, LineSpecSchema, PathSchema, ArrowDetailSchema, ArrowEndDetailSchema, ScopeSchema, NodeDefaultSchema, PathDefaultSchema, LabelDefaultSchema, ArrowDefaultSchema, TransformSchema, ChildSchema, SceneSchema, CURRENT_IR_VERSION, PaintSpecSchema, GradientStopSchema, JsonValueSchema, JsonObjectSchema, } from './ir';
|
|
6
|
-
export type { IRPosition, IRAtPosition, IROffsetPosition, AtDirection, IRTarget, IRAnchorRef, IRNodeTarget, IRRelativeTarget, IRRelativeAccumulateTarget, IRMoveStep, IRLineStep, IRFoldStep, IRCycleStep, IRCurveStep, IRCubicStep, IRBendStep, IRArcStep, IRCirclePathStep, IREllipsePathStep, IRRectangleStep, IRGeneratorStep, IRControlPoint, IRStepLabel, IRStep, IRNode, IRNodeLabel, IRCoordinate, IRFont, IRLineSpec, IRTextBlock, IRPath, IRScope, IRNodeDefault, IRPathDefault, IRLabelDefault, IRArrowDefault, StyleChannel, IRTransform, IRTranslateTransform, IRPolarTranslateTransform, IRAtTranslateTransform, IROffsetTranslateTransform, IRRotateTransform, IRScaleTransform, IRChild, IR, ArrowShape, BuiltinArrowName, ArrowShapeName, IRArrowDetail, IRArrowEndDetail, NodeShape, BuiltinShapeName, NodeTextAlign, PatternShapeName, BuiltinPatternName, IRPaintSpec, IRGradientStop, JsonValue, IRJsonObject, } from './ir';
|
|
5
|
+
export { PositionSchema, PolarPositionSchema, AtPositionSchema, OffsetPositionSchema, AT_DIRECTIONS, TargetSchema, AnchorRefSchema, NodeTargetSchema, RelativeTargetSchema, RelativeAccumulateTargetSchema, AbsoluteTargetSchema, BetweenPositionSchema, MoveStepSchema, LineStepSchema, FoldStepSchema, CycleStepSchema, CurveStepSchema, CubicStepSchema, BendStepSchema, ArcStepSchema, CirclePathStepSchema, EllipsePathStepSchema, RectangleStepSchema, GeneratorStepSchema, ControlPointSchema, StepLabelSchema, StepSchema, NodeSchema, NodeLabelSchema, CoordinateSchema, FontSchema, TextBlockSchema, LineSpecSchema, PathSchema, ArrowDetailSchema, ArrowEndDetailSchema, ScopeSchema, NodeDefaultSchema, PathDefaultSchema, LabelDefaultSchema, ArrowDefaultSchema, TransformSchema, ChildSchema, SceneSchema, CURRENT_IR_VERSION, PaintSpecSchema, GradientStopSchema, JsonValueSchema, JsonObjectSchema, ClipSpecSchema, ViewBoxSchema, } from './ir';
|
|
6
|
+
export type { IRPosition, IRAtPosition, IROffsetPosition, AtDirection, IRTarget, IRAnchorRef, IRNodeTarget, IRRelativeTarget, IRRelativeAccumulateTarget, IRAbsoluteTarget, IRBetweenPosition, IRMoveStep, IRLineStep, IRFoldStep, IRCycleStep, IRCurveStep, IRCubicStep, IRBendStep, IRArcStep, IRCirclePathStep, IREllipsePathStep, IRRectangleStep, IRGeneratorStep, IRControlPoint, IRStepLabel, IRStep, IRNode, IRNodeLabel, IRCoordinate, IRFont, IRLineSpec, IRTextBlock, IRPath, IRScope, IRNodeDefault, IRPathDefault, IRLabelDefault, IRArrowDefault, StyleChannel, IRTransform, IRTranslateTransform, IRPolarTranslateTransform, IRAtTranslateTransform, IROffsetTranslateTransform, IRRotateTransform, IRScaleTransform, IRChild, IR, ArrowShape, BuiltinArrowName, ArrowShapeName, IRArrowDetail, IRArrowEndDetail, NodeShape, BuiltinShapeName, NodeTextAlign, PatternShapeName, BuiltinPatternName, IRPaintSpec, IRGradientStop, JsonValue, IRJsonObject, IRClipSpec, IRViewBox, } from './ir';
|
|
7
7
|
export { ARROW_SHAPES, DEFAULT_ARROW_SHAPE, HOLLOW_ARROW_SHAPES, ARROW_MARKER_DEFAULT_SIZE, ARROW_MARKER_HOLLOW_DEFAULT_LINE_WIDTH, NODE_SHAPES, NODE_TEXT_ALIGNS, PATTERN_SHAPES, } from './ir';
|
|
8
8
|
export type { ScenePrimitive, RectPrim, EllipsePrim, TextPrim, TextLine, PathPrim, PathCommand,
|
|
9
9
|
/** 7 个 named PathCommand 分支(便于 wrapper / Pick<>) */
|
|
10
10
|
MovePathCommand, LinePathCommand, QuadPathCommand, CubicPathCommand, ArcPathCommand, EllipseArcPathCommand, ClosePathCommand, ArrowEndSpec, GroupPrim, Transform,
|
|
11
11
|
/** 3 个 named Transform 分支 */
|
|
12
|
-
TranslateTransform, RotateTransform, ScaleTransform, Layout, Scene, PaintValue, SceneResource,
|
|
12
|
+
TranslateTransform, RotateTransform, ScaleTransform, Layout, Scene, PaintValue, SceneResource, PaintResource,
|
|
13
|
+
/** 裁剪资源(renderer-agnostic,adapter 物化 `<clipPath>`) */
|
|
14
|
+
ClipResource, ClipShape,
|
|
13
15
|
/** 已解析 pattern tile(emit-in-compile 产物,进 Scene 资源,纯数据无函数) */
|
|
14
16
|
ResolvedPatternTile,
|
|
15
17
|
/** marker 窄子集(ArrowDefinition.emit 产物,renderer-agnostic) */
|
package/dist/es/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,EACpB,aAAa,EACb,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,8BAA8B,EAC9B,cAAc,EACd,cAAc,EACd,cAAc,EACd,eAAe,EACf,eAAe,EACf,eAAe,EACf,cAAc,EACd,aAAa,EACb,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,UAAU,EACV,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,eAAe,EACf,cAAc,EACd,UAAU,EACV,iBAAiB,EACjB,oBAAoB,EACpB,WAAW,EACX,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,WAAW,EACX,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,gBAAgB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,EACpB,aAAa,EACb,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,8BAA8B,EAC9B,oBAAoB,EACpB,qBAAqB,EACrB,cAAc,EACd,cAAc,EACd,cAAc,EACd,eAAe,EACf,eAAe,EACf,eAAe,EACf,cAAc,EACd,aAAa,EACb,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,UAAU,EACV,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,eAAe,EACf,cAAc,EACd,UAAU,EACV,iBAAiB,EACjB,oBAAoB,EACpB,WAAW,EACX,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,WAAW,EACX,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,aAAa,GACd,MAAM,MAAM,CAAC;AACd,YAAY,EACV,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,WAAW,EACX,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,0BAA0B,EAC1B,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,EACV,UAAU,EACV,UAAU,EACV,WAAW,EACX,WAAW,EACX,WAAW,EACX,UAAU,EACV,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,cAAc,EACd,WAAW,EACX,MAAM,EACN,MAAM,EACN,WAAW,EACX,YAAY,EACZ,MAAM,EACN,UAAU,EACV,WAAW,EACX,MAAM,EACN,OAAO,EACP,aAAa,EACb,aAAa,EACb,cAAc,EACd,cAAc,EACd,YAAY,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e,EACf,QAAQ,EACR,UAAU,GACX,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAIjF,YAAY,EACV,QAAQ,EACR,IAAI,EACJ,UAAU,EACV,MAAM,EACN,OAAO,EACP,OAAO,EACP,aAAa,GACd,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAGxF,YAAY,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAGtE,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAG1C,YAAY,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAG9C,YAAY,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACtF,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAGvD,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC"}
|
package/dist/es/index.js
CHANGED
|
@@ -2,21 +2,23 @@ import { PositionSchema } from "./ir/position/position.js";
|
|
|
2
2
|
import { PolarPositionSchema } from "./ir/position/polar-position.js";
|
|
3
3
|
import { AT_DIRECTIONS, AtPositionSchema } from "./ir/position/at-position.js";
|
|
4
4
|
import { OffsetPositionSchema } from "./ir/position/offset-position.js";
|
|
5
|
+
import { localToWorld, worldToLocal } from "./geometry/_transform.js";
|
|
6
|
+
import { RECT_ANCHORS, rect } from "./geometry/rect.js";
|
|
7
|
+
import { AnchorRefSchema, NodeTargetSchema, RelativeAccumulateTargetSchema, RelativeTargetSchema, TargetSchema } from "./ir/path/target.js";
|
|
8
|
+
import { AbsoluteTargetSchema, BetweenPositionSchema } from "./ir/position/between-position.js";
|
|
5
9
|
import { FontSchema } from "./ir/font.js";
|
|
6
10
|
import { JsonObjectSchema, JsonValueSchema } from "./ir/json.js";
|
|
7
11
|
import { GradientStopSchema, PATTERN_SHAPES, PaintSpecSchema } from "./ir/paint.js";
|
|
12
|
+
import { ClipSpecSchema } from "./ir/clip.js";
|
|
8
13
|
import { LineSpecSchema, TextBlockSchema } from "./ir/text.js";
|
|
9
14
|
import { ARROW_MARKER_DEFAULT_SIZE, ARROW_MARKER_HOLLOW_DEFAULT_LINE_WIDTH, ARROW_SHAPES, ArrowDetailSchema, ArrowEndDetailSchema, DEFAULT_ARROW_SHAPE, HOLLOW_ARROW_SHAPES } from "./ir/path/arrow.js";
|
|
10
|
-
import { localToWorld, worldToLocal } from "./geometry/_transform.js";
|
|
11
|
-
import { RECT_ANCHORS, rect } from "./geometry/rect.js";
|
|
12
|
-
import { AnchorRefSchema, NodeTargetSchema, RelativeAccumulateTargetSchema, RelativeTargetSchema, TargetSchema } from "./ir/path/target.js";
|
|
13
15
|
import { ArcStepSchema, BendStepSchema, CirclePathStepSchema, ControlPointSchema, CubicStepSchema, CurveStepSchema, CycleStepSchema, EllipsePathStepSchema, FoldStepSchema, GeneratorStepSchema, LineStepSchema, MoveStepSchema, RectangleStepSchema, StepLabelSchema, StepSchema } from "./ir/path/step.js";
|
|
14
16
|
import { PathSchema } from "./ir/path/path.js";
|
|
15
17
|
import { NODE_SHAPES, NODE_TEXT_ALIGNS, NodeLabelSchema, NodeSchema } from "./ir/node.js";
|
|
16
18
|
import { CoordinateSchema } from "./ir/coordinate.js";
|
|
17
19
|
import { TransformSchema } from "./ir/transform.js";
|
|
18
20
|
import { ArrowDefaultSchema, LabelDefaultSchema, NodeDefaultSchema, PathDefaultSchema, ScopeSchema } from "./ir/scope.js";
|
|
19
|
-
import { CURRENT_IR_VERSION, ChildSchema, SceneSchema } from "./ir/scene.js";
|
|
21
|
+
import { CURRENT_IR_VERSION, ChildSchema, SceneSchema, ViewBoxSchema } from "./ir/scene.js";
|
|
20
22
|
import { circle } from "./geometry/circle.js";
|
|
21
23
|
import { ellipse } from "./geometry/ellipse.js";
|
|
22
24
|
import { diamond } from "./geometry/diamond.js";
|
|
@@ -32,4 +34,4 @@ import { DrawWay, parseWay } from "./parsers/parseWay.js";
|
|
|
32
34
|
import { polar } from "./geometry/polar.js";
|
|
33
35
|
import { point } from "./geometry/point.js";
|
|
34
36
|
import { definePathGenerator } from "./pathGenerators/define.js";
|
|
35
|
-
export { ARROW_MARKER_DEFAULT_SIZE, ARROW_MARKER_HOLLOW_DEFAULT_LINE_WIDTH, ARROW_SHAPES, AT_DIRECTIONS, AnchorRefSchema, ArcStepSchema, ArrowDefaultSchema, ArrowDetailSchema, ArrowEndDetailSchema, AtPositionSchema, BUILTIN_ARROWS, BUILTIN_PATTERNS, BUILTIN_SHAPES, BendStepSchema, CURRENT_IR_VERSION, ChildSchema, CirclePathStepSchema, ControlPointSchema, CoordinateSchema, CubicStepSchema, CurveStepSchema, CycleStepSchema, DEFAULT_ARROW_SHAPE, DrawWay, EllipsePathStepSchema, FoldStepSchema, FontSchema, GeneratorStepSchema, GradientStopSchema, HOLLOW_ARROW_SHAPES, JsonObjectSchema, JsonValueSchema, LabelDefaultSchema, LineSpecSchema, LineStepSchema, MoveStepSchema, NODE_SHAPES, NODE_TEXT_ALIGNS, NodeDefaultSchema, NodeLabelSchema, NodeSchema, NodeTargetSchema, OffsetPositionSchema, PATTERN_SHAPES, PaintSpecSchema, PathDefaultSchema, PathSchema, PolarPositionSchema, PositionSchema, RECT_ANCHORS, RectangleStepSchema, RelativeAccumulateTargetSchema, RelativeTargetSchema, SceneSchema, ScopeSchema, StepLabelSchema, StepSchema, TargetSchema, TextBlockSchema, TransformSchema, circle, compileToScene, computeLayout, definePathGenerator, diamond, ellipse, fallbackMeasurer, localToWorld, parseNodeTarget, parseTargetSugar, parseWay, point, polar, rect, worldToLocal };
|
|
37
|
+
export { ARROW_MARKER_DEFAULT_SIZE, ARROW_MARKER_HOLLOW_DEFAULT_LINE_WIDTH, ARROW_SHAPES, AT_DIRECTIONS, AbsoluteTargetSchema, AnchorRefSchema, ArcStepSchema, ArrowDefaultSchema, ArrowDetailSchema, ArrowEndDetailSchema, AtPositionSchema, BUILTIN_ARROWS, BUILTIN_PATTERNS, BUILTIN_SHAPES, BendStepSchema, BetweenPositionSchema, CURRENT_IR_VERSION, ChildSchema, CirclePathStepSchema, ClipSpecSchema, ControlPointSchema, CoordinateSchema, CubicStepSchema, CurveStepSchema, CycleStepSchema, DEFAULT_ARROW_SHAPE, DrawWay, EllipsePathStepSchema, FoldStepSchema, FontSchema, GeneratorStepSchema, GradientStopSchema, HOLLOW_ARROW_SHAPES, JsonObjectSchema, JsonValueSchema, LabelDefaultSchema, LineSpecSchema, LineStepSchema, MoveStepSchema, NODE_SHAPES, NODE_TEXT_ALIGNS, NodeDefaultSchema, NodeLabelSchema, NodeSchema, NodeTargetSchema, OffsetPositionSchema, PATTERN_SHAPES, PaintSpecSchema, PathDefaultSchema, PathSchema, PolarPositionSchema, PositionSchema, RECT_ANCHORS, RectangleStepSchema, RelativeAccumulateTargetSchema, RelativeTargetSchema, SceneSchema, ScopeSchema, StepLabelSchema, StepSchema, TargetSchema, TextBlockSchema, TransformSchema, ViewBoxSchema, circle, compileToScene, computeLayout, definePathGenerator, diamond, ellipse, fallbackMeasurer, localToWorld, parseNodeTarget, parseTargetSugar, parseWay, point, polar, rect, worldToLocal };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* 裁剪区规格(4 种结构化形状之一)
|
|
4
|
+
* @description renderer-agnostic 的纯数值裁剪区:`rect` 取景窗 / `circle` 圆形遮罩 / `ellipse` 椭圆遮罩 /
|
|
5
|
+
* `polygon` 任意直边区域。坐标为所在 scope 的局部坐标系(与 scope children 同帧)。
|
|
6
|
+
* 尺寸字段 `.positive().finite()`、坐标 `.finite()` 守 Scene JSON 可序列化(NaN/Infinity round-trip 失真)。
|
|
7
|
+
* 不含 SVG path 迷你语言(任意贝塞尔裁剪推迟)。
|
|
8
|
+
*/
|
|
9
|
+
export declare const ClipSpecSchema: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
10
|
+
kind: z.ZodLiteral<"rect">;
|
|
11
|
+
x: z.ZodNumber;
|
|
12
|
+
y: z.ZodNumber;
|
|
13
|
+
width: z.ZodNumber;
|
|
14
|
+
height: z.ZodNumber;
|
|
15
|
+
}, "strip", z.ZodTypeAny, {
|
|
16
|
+
kind: "rect";
|
|
17
|
+
x: number;
|
|
18
|
+
y: number;
|
|
19
|
+
width: number;
|
|
20
|
+
height: number;
|
|
21
|
+
}, {
|
|
22
|
+
kind: "rect";
|
|
23
|
+
x: number;
|
|
24
|
+
y: number;
|
|
25
|
+
width: number;
|
|
26
|
+
height: number;
|
|
27
|
+
}>, z.ZodObject<{
|
|
28
|
+
kind: z.ZodLiteral<"circle">;
|
|
29
|
+
cx: z.ZodNumber;
|
|
30
|
+
cy: z.ZodNumber;
|
|
31
|
+
r: z.ZodNumber;
|
|
32
|
+
}, "strip", z.ZodTypeAny, {
|
|
33
|
+
kind: "circle";
|
|
34
|
+
cx: number;
|
|
35
|
+
cy: number;
|
|
36
|
+
r: number;
|
|
37
|
+
}, {
|
|
38
|
+
kind: "circle";
|
|
39
|
+
cx: number;
|
|
40
|
+
cy: number;
|
|
41
|
+
r: number;
|
|
42
|
+
}>, z.ZodObject<{
|
|
43
|
+
kind: z.ZodLiteral<"ellipse">;
|
|
44
|
+
cx: z.ZodNumber;
|
|
45
|
+
cy: z.ZodNumber;
|
|
46
|
+
rx: z.ZodNumber;
|
|
47
|
+
ry: z.ZodNumber;
|
|
48
|
+
}, "strip", z.ZodTypeAny, {
|
|
49
|
+
kind: "ellipse";
|
|
50
|
+
cx: number;
|
|
51
|
+
cy: number;
|
|
52
|
+
rx: number;
|
|
53
|
+
ry: number;
|
|
54
|
+
}, {
|
|
55
|
+
kind: "ellipse";
|
|
56
|
+
cx: number;
|
|
57
|
+
cy: number;
|
|
58
|
+
rx: number;
|
|
59
|
+
ry: number;
|
|
60
|
+
}>, z.ZodObject<{
|
|
61
|
+
kind: z.ZodLiteral<"polygon">;
|
|
62
|
+
points: z.ZodArray<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>, "many">;
|
|
63
|
+
}, "strip", z.ZodTypeAny, {
|
|
64
|
+
kind: "polygon";
|
|
65
|
+
points: [number, number][];
|
|
66
|
+
}, {
|
|
67
|
+
kind: "polygon";
|
|
68
|
+
points: [number, number][];
|
|
69
|
+
}>]>;
|
|
70
|
+
/** 裁剪区 IR 类型(4 形状判别 union) */
|
|
71
|
+
export type IRClipSpec = z.infer<typeof ClipSpecSchema>;
|
|
72
|
+
//# sourceMappingURL=clip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clip.d.ts","sourceRoot":"","sources":["../../../src/ir/clip.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;GAMG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAwCxB,CAAC;AAEJ,8BAA8B;AAC9B,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC"}
|