@retikz/core 0.1.0-alpha.2 → 0.1.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/compile/compile.d.ts +6 -0
- package/dist/es/compile/compile.d.ts.map +1 -1
- package/dist/es/compile/compile.js +33 -4
- package/dist/es/compile/node.d.ts +23 -2
- package/dist/es/compile/node.d.ts.map +1 -1
- package/dist/es/compile/node.js +94 -4
- package/dist/es/compile/path.d.ts +3 -2
- package/dist/es/compile/path.d.ts.map +1 -1
- package/dist/es/compile/path.js +333 -14
- package/dist/es/compile/position.d.ts +8 -5
- package/dist/es/compile/position.d.ts.map +1 -1
- package/dist/es/compile/position.js +32 -5
- package/dist/es/geometry/arc.d.ts +34 -0
- package/dist/es/geometry/arc.d.ts.map +1 -0
- package/dist/es/geometry/arc.js +53 -0
- package/dist/es/geometry/bend.d.ts +18 -0
- package/dist/es/geometry/bend.d.ts.map +1 -0
- package/dist/es/geometry/bend.js +29 -0
- package/dist/es/geometry/index.d.ts +3 -0
- package/dist/es/geometry/index.d.ts.map +1 -1
- package/dist/es/geometry/segment.d.ts +38 -0
- package/dist/es/geometry/segment.d.ts.map +1 -0
- package/dist/es/geometry/segment.js +82 -0
- package/dist/es/index.d.ts +4 -4
- package/dist/es/index.d.ts.map +1 -1
- package/dist/es/index.js +7 -4
- package/dist/es/ir/coordinate.d.ts +57 -0
- package/dist/es/ir/coordinate.d.ts.map +1 -0
- package/dist/es/ir/coordinate.js +27 -0
- 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 +276 -17
- package/dist/es/ir/node.d.ts.map +1 -1
- package/dist/es/ir/node.js +28 -3
- package/dist/es/ir/path/path.d.ts +625 -15
- package/dist/es/ir/path/path.d.ts.map +1 -1
- package/dist/es/ir/path/path.js +22 -0
- package/dist/es/ir/path/step.d.ts +872 -20
- package/dist/es/ir/path/step.d.ts.map +1 -1
- package/dist/es/ir/path/step.js +86 -4
- package/dist/es/ir/path/target.d.ts +32 -2
- package/dist/es/ir/path/target.d.ts.map +1 -1
- package/dist/es/ir/path/target.js +7 -3
- package/dist/es/ir/position/at-position.d.ts +50 -0
- package/dist/es/ir/position/at-position.d.ts.map +1 -0
- package/dist/es/ir/position/at-position.js +30 -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 +2072 -112
- package/dist/es/ir/scene.d.ts.map +1 -1
- package/dist/es/ir/scene.js +6 -1
- package/dist/es/parsers/index.d.ts +1 -0
- package/dist/es/parsers/index.d.ts.map +1 -1
- package/dist/es/parsers/parseTargetSugar.d.ts +3 -0
- package/dist/es/parsers/parseTargetSugar.d.ts.map +1 -0
- package/dist/es/parsers/parseTargetSugar.js +31 -0
- package/dist/es/parsers/parseWay.d.ts +131 -22
- package/dist/es/parsers/parseWay.d.ts.map +1 -1
- package/dist/es/parsers/parseWay.js +149 -17
- package/dist/lib/compile/compile.cjs +33 -4
- package/dist/lib/compile/compile.d.ts +6 -0
- package/dist/lib/compile/compile.d.ts.map +1 -1
- package/dist/lib/compile/node.cjs +94 -4
- package/dist/lib/compile/node.d.ts +23 -2
- package/dist/lib/compile/node.d.ts.map +1 -1
- package/dist/lib/compile/path.cjs +333 -14
- package/dist/lib/compile/path.d.ts +3 -2
- package/dist/lib/compile/path.d.ts.map +1 -1
- package/dist/lib/compile/position.cjs +32 -5
- package/dist/lib/compile/position.d.ts +8 -5
- package/dist/lib/compile/position.d.ts.map +1 -1
- package/dist/lib/geometry/arc.cjs +55 -0
- package/dist/lib/geometry/arc.d.ts +34 -0
- package/dist/lib/geometry/arc.d.ts.map +1 -0
- package/dist/lib/geometry/bend.cjs +29 -0
- package/dist/lib/geometry/bend.d.ts +18 -0
- package/dist/lib/geometry/bend.d.ts.map +1 -0
- package/dist/lib/geometry/index.d.ts +3 -0
- package/dist/lib/geometry/index.d.ts.map +1 -1
- package/dist/lib/geometry/segment.cjs +88 -0
- package/dist/lib/geometry/segment.d.ts +38 -0
- package/dist/lib/geometry/segment.d.ts.map +1 -0
- package/dist/lib/index.cjs +18 -0
- package/dist/lib/index.d.ts +4 -4
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/ir/coordinate.cjs +27 -0
- package/dist/lib/ir/coordinate.d.ts +57 -0
- package/dist/lib/ir/coordinate.d.ts.map +1 -0
- 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 +28 -2
- package/dist/lib/ir/node.d.ts +276 -17
- package/dist/lib/ir/node.d.ts.map +1 -1
- package/dist/lib/ir/path/path.cjs +22 -0
- package/dist/lib/ir/path/path.d.ts +625 -15
- package/dist/lib/ir/path/path.d.ts.map +1 -1
- package/dist/lib/ir/path/step.cjs +93 -3
- package/dist/lib/ir/path/step.d.ts +872 -20
- package/dist/lib/ir/path/step.d.ts.map +1 -1
- package/dist/lib/ir/path/target.cjs +8 -2
- package/dist/lib/ir/path/target.d.ts +32 -2
- package/dist/lib/ir/path/target.d.ts.map +1 -1
- package/dist/lib/ir/position/at-position.cjs +31 -0
- package/dist/lib/ir/position/at-position.d.ts +50 -0
- package/dist/lib/ir/position/at-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 +6 -1
- package/dist/lib/ir/scene.d.ts +2072 -112
- package/dist/lib/ir/scene.d.ts.map +1 -1
- package/dist/lib/parsers/index.d.ts +1 -0
- package/dist/lib/parsers/index.d.ts.map +1 -1
- package/dist/lib/parsers/parseTargetSugar.cjs +31 -0
- package/dist/lib/parsers/parseTargetSugar.d.ts +3 -0
- package/dist/lib/parsers/parseTargetSugar.d.ts.map +1 -0
- package/dist/lib/parsers/parseWay.cjs +149 -17
- package/dist/lib/parsers/parseWay.d.ts +131 -22
- package/dist/lib/parsers/parseWay.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region src/geometry/bend.ts
|
|
2
|
+
/**
|
|
3
|
+
* 用 cubic Bezier 拟合 from→to 的弧形 bend。
|
|
4
|
+
*
|
|
5
|
+
* 算法(ADR-0001):
|
|
6
|
+
* 1. apex offset = chord × tan(bendAngle / 2)(沿 path 法向 left / right 偏移量)
|
|
7
|
+
* 2. 控制点取 chord 1/3 / 2/3 处沿法向偏移;为让 cubic 在 t=0.5 处穿过 apex,
|
|
8
|
+
* 控制点 offset = (4/3) × apex offset(推导:B(0.5) = midpoint + (3/4)·s·n)
|
|
9
|
+
*
|
|
10
|
+
* 法向定义(SVG y 向下,"left/right" 按视觉,不按数学):
|
|
11
|
+
* chord direction = (dx, dy) / |chord|
|
|
12
|
+
* visual-left normal = ( dy, -dx) / |chord| (从 from 看向 to,向左偏)
|
|
13
|
+
* visual-right normal = (-dy, dx) / |chord|
|
|
14
|
+
*
|
|
15
|
+
* chord 长度为 0 时无方向可推,两个控制点都返回 from。
|
|
16
|
+
*/
|
|
17
|
+
var bendControlPoints = (from, to, direction, bendAngle) => {
|
|
18
|
+
const dx = to[0] - from[0];
|
|
19
|
+
const dy = to[1] - from[1];
|
|
20
|
+
const chord = Math.hypot(dx, dy);
|
|
21
|
+
if (chord === 0) return [[from[0], from[1]], [from[0], from[1]]];
|
|
22
|
+
const sign = direction === "left" ? 1 : -1;
|
|
23
|
+
const nx = dy / chord * sign;
|
|
24
|
+
const ny = -dx / chord * sign;
|
|
25
|
+
const ctlOffset = 4 / 3 * (chord * Math.tan(bendAngle * Math.PI / 180 / 2));
|
|
26
|
+
return [[from[0] + dx / 3 + ctlOffset * nx, from[1] + dy / 3 + ctlOffset * ny], [from[0] + 2 * dx / 3 + ctlOffset * nx, from[1] + 2 * dy / 3 + ctlOffset * ny]];
|
|
27
|
+
};
|
|
28
|
+
//#endregion
|
|
29
|
+
export { bendControlPoints };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/geometry/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/geometry/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Position } from './point';
|
|
2
|
+
export type SegmentSample = {
|
|
3
|
+
/** t 处的点坐标 */
|
|
4
|
+
point: Position;
|
|
5
|
+
/** t 处的切线方向(单位向量;零向量时回退到 [1, 0]) */
|
|
6
|
+
tangent: Position;
|
|
7
|
+
};
|
|
8
|
+
/** 直线段 from → to */
|
|
9
|
+
export declare const lineSegmentSample: (from: Position, to: Position, t: number) => SegmentSample;
|
|
10
|
+
/**
|
|
11
|
+
* 二次贝塞尔 from → control → to。
|
|
12
|
+
* P(t) = (1-t)²·P0 + 2(1-t)t·P1 + t²·P2
|
|
13
|
+
* P'(t) = 2(1-t)(P1-P0) + 2t(P2-P1)
|
|
14
|
+
*/
|
|
15
|
+
export declare const quadSegmentSample: (from: Position, control: Position, to: Position, t: number) => SegmentSample;
|
|
16
|
+
/**
|
|
17
|
+
* 三次贝塞尔 from → c1 → c2 → to。
|
|
18
|
+
* P'(t) = 3(1-t)²(P1-P0) + 6(1-t)t(P2-P1) + 3t²(P3-P2)
|
|
19
|
+
*/
|
|
20
|
+
export declare const cubicSegmentSample: (from: Position, c1: Position, c2: Position, to: Position, t: number) => SegmentSample;
|
|
21
|
+
/**
|
|
22
|
+
* 折角段 from → corner → to。
|
|
23
|
+
* t∈[0, 0.5] 走第一段(参数 2t);t∈(0.5, 1] 走第二段(参数 2t-1)。
|
|
24
|
+
* t=0.5 落在 corner,切线取第一段方向(与"靠近 prev 一侧"一致)。
|
|
25
|
+
*/
|
|
26
|
+
export declare const foldSegmentSample: (from: Position, corner: Position, to: Position, t: number) => SegmentSample;
|
|
27
|
+
/**
|
|
28
|
+
* 弧段(与 ir/path arc 同约定,角度单位为度)。
|
|
29
|
+
* 切线沿"扫描方向"——endAngle ≥ startAngle 时为 (-sin, cos),否则反向。
|
|
30
|
+
*/
|
|
31
|
+
export declare const arcSegmentSample: (center: Position, radius: number, startAngleDeg: number, endAngleDeg: number, t: number) => SegmentSample;
|
|
32
|
+
/**
|
|
33
|
+
* 整圆——从 0°(east)开始,与 compile/path circlePath 输出方向(右→左→右,sweep=1)一致。
|
|
34
|
+
*/
|
|
35
|
+
export declare const circleSegmentSample: (center: Position, radius: number, t: number) => SegmentSample;
|
|
36
|
+
/** 整椭圆——参数化 (rx·cos(2πt), ry·sin(2πt)) */
|
|
37
|
+
export declare const ellipseSegmentSample: (center: Position, rx: number, ry: number, t: number) => SegmentSample;
|
|
38
|
+
//# sourceMappingURL=segment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"segment.d.ts","sourceRoot":"","sources":["../../../src/geometry/segment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAuBxC,MAAM,MAAM,aAAa,GAAG;IAC1B,cAAc;IACd,KAAK,EAAE,QAAQ,CAAC;IAChB,oCAAoC;IACpC,OAAO,EAAE,QAAQ,CAAC;CACnB,CAAC;AAQF,oBAAoB;AACpB,eAAO,MAAM,iBAAiB,GAC5B,MAAM,QAAQ,EACd,IAAI,QAAQ,EACZ,GAAG,MAAM,KACR,aAGD,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAC5B,MAAM,QAAQ,EACd,SAAS,QAAQ,EACjB,IAAI,QAAQ,EACZ,GAAG,MAAM,KACR,aASF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAC7B,MAAM,QAAQ,EACd,IAAI,QAAQ,EACZ,IAAI,QAAQ,EACZ,IAAI,QAAQ,EACZ,GAAG,MAAM,KACR,aAqBF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAC5B,MAAM,QAAQ,EACd,QAAQ,QAAQ,EAChB,IAAI,QAAQ,EACZ,GAAG,MAAM,KACR,aAGF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,gBAAgB,GAC3B,QAAQ,QAAQ,EAChB,QAAQ,MAAM,EACd,eAAe,MAAM,EACrB,aAAa,MAAM,EACnB,GAAG,MAAM,KACR,aAUF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,GAC9B,QAAQ,QAAQ,EAChB,QAAQ,MAAM,EACd,GAAG,MAAM,KACR,aASF,CAAC;AAEF,0CAA0C;AAC1C,eAAO,MAAM,oBAAoB,GAC/B,QAAQ,QAAQ,EAChB,IAAI,MAAM,EACV,IAAI,MAAM,EACV,GAAG,MAAM,KACR,aASF,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
//#region src/geometry/segment.ts
|
|
2
|
+
var DEG_TO_RAD = Math.PI / 180;
|
|
3
|
+
var normalize = (v) => {
|
|
4
|
+
const len = Math.hypot(v[0], v[1]);
|
|
5
|
+
if (len === 0) return [1, 0];
|
|
6
|
+
return [v[0] / len, v[1] / len];
|
|
7
|
+
};
|
|
8
|
+
/** 直线段 from → to */
|
|
9
|
+
var lineSegmentSample = (from, to, t) => ({
|
|
10
|
+
point: [from[0] + (to[0] - from[0]) * t, from[1] + (to[1] - from[1]) * t],
|
|
11
|
+
tangent: normalize([to[0] - from[0], to[1] - from[1]])
|
|
12
|
+
});
|
|
13
|
+
/**
|
|
14
|
+
* 二次贝塞尔 from → control → to。
|
|
15
|
+
* P(t) = (1-t)²·P0 + 2(1-t)t·P1 + t²·P2
|
|
16
|
+
* P'(t) = 2(1-t)(P1-P0) + 2t(P2-P1)
|
|
17
|
+
*/
|
|
18
|
+
var quadSegmentSample = (from, control, to, t) => {
|
|
19
|
+
const u = 1 - t;
|
|
20
|
+
return {
|
|
21
|
+
point: [u * u * from[0] + 2 * u * t * control[0] + t * t * to[0], u * u * from[1] + 2 * u * t * control[1] + t * t * to[1]],
|
|
22
|
+
tangent: normalize([2 * u * (control[0] - from[0]) + 2 * t * (to[0] - control[0]), 2 * u * (control[1] - from[1]) + 2 * t * (to[1] - control[1])])
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* 三次贝塞尔 from → c1 → c2 → to。
|
|
27
|
+
* P'(t) = 3(1-t)²(P1-P0) + 6(1-t)t(P2-P1) + 3t²(P3-P2)
|
|
28
|
+
*/
|
|
29
|
+
var cubicSegmentSample = (from, c1, c2, to, t) => {
|
|
30
|
+
const u = 1 - t;
|
|
31
|
+
return {
|
|
32
|
+
point: [u * u * u * from[0] + 3 * u * u * t * c1[0] + 3 * u * t * t * c2[0] + t * t * t * to[0], u * u * u * from[1] + 3 * u * u * t * c1[1] + 3 * u * t * t * c2[1] + t * t * t * to[1]],
|
|
33
|
+
tangent: normalize([3 * u * u * (c1[0] - from[0]) + 6 * u * t * (c2[0] - c1[0]) + 3 * t * t * (to[0] - c2[0]), 3 * u * u * (c1[1] - from[1]) + 6 * u * t * (c2[1] - c1[1]) + 3 * t * t * (to[1] - c2[1])])
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* 折角段 from → corner → to。
|
|
38
|
+
* t∈[0, 0.5] 走第一段(参数 2t);t∈(0.5, 1] 走第二段(参数 2t-1)。
|
|
39
|
+
* t=0.5 落在 corner,切线取第一段方向(与"靠近 prev 一侧"一致)。
|
|
40
|
+
*/
|
|
41
|
+
var foldSegmentSample = (from, corner, to, t) => {
|
|
42
|
+
if (t <= .5) return lineSegmentSample(from, corner, t * 2);
|
|
43
|
+
return lineSegmentSample(corner, to, t * 2 - 1);
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* 弧段(与 ir/path arc 同约定,角度单位为度)。
|
|
47
|
+
* 切线沿"扫描方向"——endAngle ≥ startAngle 时为 (-sin, cos),否则反向。
|
|
48
|
+
*/
|
|
49
|
+
var arcSegmentSample = (center, radius, startAngleDeg, endAngleDeg, t) => {
|
|
50
|
+
const rad = (startAngleDeg + t * (endAngleDeg - startAngleDeg)) * DEG_TO_RAD;
|
|
51
|
+
const cos = Math.cos(rad);
|
|
52
|
+
const sin = Math.sin(rad);
|
|
53
|
+
const sweepSign = endAngleDeg >= startAngleDeg ? 1 : -1;
|
|
54
|
+
return {
|
|
55
|
+
point: [center[0] + radius * cos, center[1] + radius * sin],
|
|
56
|
+
tangent: normalize([-sin * sweepSign, cos * sweepSign])
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* 整圆——从 0°(east)开始,与 compile/path circlePath 输出方向(右→左→右,sweep=1)一致。
|
|
61
|
+
*/
|
|
62
|
+
var circleSegmentSample = (center, radius, t) => {
|
|
63
|
+
const rad = t * 360 * DEG_TO_RAD;
|
|
64
|
+
const cos = Math.cos(rad);
|
|
65
|
+
const sin = Math.sin(rad);
|
|
66
|
+
return {
|
|
67
|
+
point: [center[0] + radius * cos, center[1] + radius * sin],
|
|
68
|
+
tangent: normalize([-sin, cos])
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
/** 整椭圆——参数化 (rx·cos(2πt), ry·sin(2πt)) */
|
|
72
|
+
var ellipseSegmentSample = (center, rx, ry, t) => {
|
|
73
|
+
const rad = t * 360 * DEG_TO_RAD;
|
|
74
|
+
const cos = Math.cos(rad);
|
|
75
|
+
const sin = Math.sin(rad);
|
|
76
|
+
return {
|
|
77
|
+
point: [center[0] + rx * cos, center[1] + ry * sin],
|
|
78
|
+
tangent: normalize([-rx * sin, ry * cos])
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
//#endregion
|
|
82
|
+
export { arcSegmentSample, circleSegmentSample, cubicSegmentSample, ellipseSegmentSample, foldSegmentSample, lineSegmentSample, quadSegmentSample };
|
package/dist/es/index.d.ts
CHANGED
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
*
|
|
7
7
|
* 本包零 React、零 DOM 依赖。
|
|
8
8
|
*/
|
|
9
|
-
export { PositionSchema, PolarPositionSchema, TargetSchema, MoveStepSchema, LineStepSchema, FoldStepSchema, CycleStepSchema, StepSchema, NodeSchema, FontSchema, NodeTextSchema, LineSpecSchema, PathSchema, ChildSchema, SceneSchema, CURRENT_IR_VERSION, } from './ir';
|
|
10
|
-
export type { IRPosition, IRTarget, IRMoveStep, IRLineStep, IRFoldStep, IRCycleStep, IRStep, IRNode, IRFont, IRLineSpec, IRPath, IRChild, IR, ArrowShape, NodeShape, NodeTextAlign, } from './ir';
|
|
9
|
+
export { PositionSchema, PolarPositionSchema, AtPositionSchema, AT_DIRECTIONS, TargetSchema, RelTargetSchema, RelAccumulateTargetSchema, MoveStepSchema, LineStepSchema, FoldStepSchema, CycleStepSchema, CurveStepSchema, CubicStepSchema, BendStepSchema, ArcStepSchema, CirclePathStepSchema, EllipsePathStepSchema, ControlPointSchema, StepLabelSchema, StepSchema, NodeSchema, NodeLabelSchema, CoordinateSchema, FontSchema, NodeTextSchema, LineSpecSchema, PathSchema, ChildSchema, SceneSchema, CURRENT_IR_VERSION, } from './ir';
|
|
10
|
+
export type { IRPosition, IRAtPosition, AtDirection, IRTarget, IRRelTarget, IRRelAccumulateTarget, IRMoveStep, IRLineStep, IRFoldStep, IRCycleStep, IRCurveStep, IRCubicStep, IRBendStep, IRArcStep, IRCirclePathStep, IREllipsePathStep, IRControlPoint, IRStepLabel, IRStep, IRNode, IRNodeLabel, IRCoordinate, IRFont, IRLineSpec, IRPath, IRChild, IR, ArrowShape, NodeShape, NodeTextAlign, } from './ir';
|
|
11
11
|
export { ARROW_SHAPES, NODE_SHAPES, NODE_TEXT_ALIGNS } from './ir';
|
|
12
12
|
export type { ScenePrimitive, RectPrim, EllipsePrim, TextPrim, TextLine, PathPrim, GroupPrim, ViewBox, Scene, } from './primitive';
|
|
13
13
|
export type { FontSpec, TextMetrics, TextMeasurer, CompileOptions, } from './compile';
|
|
14
14
|
export { fallbackMeasurer, compileToScene } from './compile';
|
|
15
|
-
export type { WayItem, WayDSL, WayCycle, WayVia } from './parsers';
|
|
16
|
-
export { parseWay, DrawWay } from './parsers';
|
|
15
|
+
export type { WayItem, WayDSL, WayCycle, WayVia, WayRelItem, WayLabel, WayLabelOp, } from './parsers';
|
|
16
|
+
export { parseWay, DrawWay, parseTargetSugar } from './parsers';
|
|
17
17
|
export type { Position, Rect, RectAnchor, Circle, CircleAnchor, Ellipse, EllipseAnchor, Diamond, DiamondAnchor, PolarPosition, } from './geometry';
|
|
18
18
|
export { point, rect, circle, ellipse, diamond, RECT_ANCHORS, polar } from './geometry';
|
|
19
19
|
export type { ValueOf } from './types';
|
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;;;;;;;GAOG;AAGH,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,YAAY,EACZ,cAAc,EACd,cAAc,EACd,cAAc,EACd,eAAe,EACf,UAAU,EACV,UAAU,EACV,UAAU,EACV,cAAc,EACd,cAAc,EACd,UAAU,EACV,WAAW,EACX,WAAW,EACX,kBAAkB,GACnB,MAAM,MAAM,CAAC;AACd,YAAY,EACV,UAAU,EACV,QAAQ,EACR,UAAU,EACV,UAAU,EACV,UAAU,EACV,WAAW,EACX,MAAM,EACN,MAAM,EACN,MAAM,EACN,UAAU,EACV,MAAM,EACN,OAAO,EACP,EAAE,EACF,UAAU,EACV,SAAS,EACT,aAAa,GACd,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,MAAM,CAAC;AAGnE,YAAY,EACV,cAAc,EACd,QAAQ,EACR,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,OAAO,EACP,KAAK,GACN,MAAM,aAAa,CAAC;AAGrB,YAAY,EACV,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,cAAc,GACf,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAG7D,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,eAAe,EACf,yBAAyB,EACzB,cAAc,EACd,cAAc,EACd,cAAc,EACd,eAAe,EACf,eAAe,EACf,eAAe,EACf,cAAc,EACd,aAAa,EACb,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,EAClB,eAAe,EACf,UAAU,EACV,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,cAAc,EACd,cAAc,EACd,UAAU,EACV,WAAW,EACX,WAAW,EACX,kBAAkB,GACnB,MAAM,MAAM,CAAC;AACd,YAAY,EACV,UAAU,EACV,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,WAAW,EACX,qBAAqB,EACrB,UAAU,EACV,UAAU,EACV,UAAU,EACV,WAAW,EACX,WAAW,EACX,WAAW,EACX,UAAU,EACV,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,WAAW,EACX,MAAM,EACN,MAAM,EACN,WAAW,EACX,YAAY,EACZ,MAAM,EACN,UAAU,EACV,MAAM,EACN,OAAO,EACP,EAAE,EACF,UAAU,EACV,SAAS,EACT,aAAa,GACd,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,MAAM,CAAC;AAGnE,YAAY,EACV,cAAc,EACd,QAAQ,EACR,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,OAAO,EACP,KAAK,GACN,MAAM,aAAa,CAAC;AAGrB,YAAY,EACV,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,cAAc,GACf,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAG7D,YAAY,EACV,OAAO,EACP,MAAM,EACN,QAAQ,EACR,MAAM,EACN,UAAU,EACV,QAAQ,EACR,UAAU,GACX,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAIhE,YAAY,EACV,QAAQ,EACR,IAAI,EACJ,UAAU,EACV,MAAM,EACN,YAAY,EACZ,OAAO,EACP,aAAa,EACb,OAAO,EACP,aAAa,EACb,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,OAAO,EAAE,MAAM,SAAS,CAAC"}
|
package/dist/es/index.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { PositionSchema } from "./ir/position/position.js";
|
|
2
2
|
import { PolarPositionSchema } from "./ir/position/polar-position.js";
|
|
3
|
+
import { AT_DIRECTIONS, AtPositionSchema } from "./ir/position/at-position.js";
|
|
3
4
|
import { ARROW_SHAPES } from "./ir/path/arrow.js";
|
|
4
|
-
import { TargetSchema } from "./ir/path/target.js";
|
|
5
|
-
import { CycleStepSchema, FoldStepSchema, LineStepSchema, MoveStepSchema, StepSchema } from "./ir/path/step.js";
|
|
5
|
+
import { RelAccumulateTargetSchema, RelTargetSchema, TargetSchema } from "./ir/path/target.js";
|
|
6
|
+
import { ArcStepSchema, BendStepSchema, CirclePathStepSchema, ControlPointSchema, CubicStepSchema, CurveStepSchema, CycleStepSchema, EllipsePathStepSchema, FoldStepSchema, LineStepSchema, MoveStepSchema, StepLabelSchema, StepSchema } from "./ir/path/step.js";
|
|
6
7
|
import { PathSchema } from "./ir/path/path.js";
|
|
7
|
-
import { FontSchema, LineSpecSchema, NODE_SHAPES, NODE_TEXT_ALIGNS, NodeSchema, NodeTextSchema } from "./ir/node.js";
|
|
8
|
+
import { FontSchema, LineSpecSchema, NODE_SHAPES, NODE_TEXT_ALIGNS, NodeLabelSchema, NodeSchema, NodeTextSchema } from "./ir/node.js";
|
|
9
|
+
import { CoordinateSchema } from "./ir/coordinate.js";
|
|
8
10
|
import { CURRENT_IR_VERSION, ChildSchema, SceneSchema } from "./ir/scene.js";
|
|
9
11
|
import { RECT_ANCHORS, rect } from "./geometry/rect.js";
|
|
10
12
|
import { circle } from "./geometry/circle.js";
|
|
@@ -12,7 +14,8 @@ import { diamond } from "./geometry/diamond.js";
|
|
|
12
14
|
import { ellipse } from "./geometry/ellipse.js";
|
|
13
15
|
import { fallbackMeasurer } from "./compile/text-metrics.js";
|
|
14
16
|
import { compileToScene } from "./compile/compile.js";
|
|
17
|
+
import { parseTargetSugar } from "./parsers/parseTargetSugar.js";
|
|
15
18
|
import { DrawWay, parseWay } from "./parsers/parseWay.js";
|
|
16
19
|
import { polar } from "./geometry/polar.js";
|
|
17
20
|
import { point } from "./geometry/point.js";
|
|
18
|
-
export { ARROW_SHAPES, CURRENT_IR_VERSION, ChildSchema, CycleStepSchema, DrawWay, FoldStepSchema, FontSchema, LineSpecSchema, LineStepSchema, MoveStepSchema, NODE_SHAPES, NODE_TEXT_ALIGNS, NodeSchema, NodeTextSchema, PathSchema, PolarPositionSchema, PositionSchema, RECT_ANCHORS, SceneSchema, StepSchema, TargetSchema, circle, compileToScene, diamond, ellipse, fallbackMeasurer, parseWay, point, polar, rect };
|
|
21
|
+
export { ARROW_SHAPES, AT_DIRECTIONS, ArcStepSchema, AtPositionSchema, BendStepSchema, CURRENT_IR_VERSION, ChildSchema, CirclePathStepSchema, ControlPointSchema, CoordinateSchema, CubicStepSchema, CurveStepSchema, CycleStepSchema, DrawWay, EllipsePathStepSchema, FoldStepSchema, FontSchema, LineSpecSchema, LineStepSchema, MoveStepSchema, NODE_SHAPES, NODE_TEXT_ALIGNS, NodeLabelSchema, NodeSchema, NodeTextSchema, PathSchema, PolarPositionSchema, PositionSchema, RECT_ANCHORS, RelAccumulateTargetSchema, RelTargetSchema, SceneSchema, StepLabelSchema, StepSchema, TargetSchema, circle, compileToScene, diamond, ellipse, fallbackMeasurer, parseTargetSugar, parseWay, point, polar, rect };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Coordinate(占位节点)——TikZ `\coordinate (m) at (3,2);` 同义。
|
|
4
|
+
*
|
|
5
|
+
* 命名一个点供后续 path / at 引用,自身不绘制任何图形。
|
|
6
|
+
* 支持笛卡尔 / 极坐标 / 相对定位三种 position 形态,与 `Node.position` 完全一致。
|
|
7
|
+
*
|
|
8
|
+
* 特点:
|
|
9
|
+
* - 必须有 `id`(无 id 的占位节点没有意义)
|
|
10
|
+
* - 不参与 viewBox 扩展(无视觉边界);只在被引用时才间接影响 viewBox(通过引用它的 node / path)
|
|
11
|
+
* - 与 Node 在同一个 nodeIndex 中注册——path target 字符串、`Node.position.of` 都能命中 coordinate id
|
|
12
|
+
*/
|
|
13
|
+
export declare const CoordinateSchema: z.ZodObject<{
|
|
14
|
+
type: z.ZodLiteral<"coordinate">;
|
|
15
|
+
id: z.ZodString;
|
|
16
|
+
position: z.ZodUnion<[z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>, z.ZodType<import('./position').PolarPosition, z.ZodTypeDef, import('./position').PolarPosition>, z.ZodObject<{
|
|
17
|
+
direction: z.ZodNativeEnum<{
|
|
18
|
+
readonly above: "above";
|
|
19
|
+
readonly below: "below";
|
|
20
|
+
readonly left: "left";
|
|
21
|
+
readonly right: "right";
|
|
22
|
+
readonly 'above-left': "above-left";
|
|
23
|
+
readonly 'above-right': "above-right";
|
|
24
|
+
readonly 'below-left': "below-left";
|
|
25
|
+
readonly 'below-right': "below-right";
|
|
26
|
+
}>;
|
|
27
|
+
of: z.ZodString;
|
|
28
|
+
distance: z.ZodOptional<z.ZodNumber>;
|
|
29
|
+
}, "strip", z.ZodTypeAny, {
|
|
30
|
+
direction: "above" | "below" | "left" | "right" | "above-left" | "above-right" | "below-left" | "below-right";
|
|
31
|
+
of: string;
|
|
32
|
+
distance?: number | undefined;
|
|
33
|
+
}, {
|
|
34
|
+
direction: "above" | "below" | "left" | "right" | "above-left" | "above-right" | "below-left" | "below-right";
|
|
35
|
+
of: string;
|
|
36
|
+
distance?: number | undefined;
|
|
37
|
+
}>]>;
|
|
38
|
+
}, "strip", z.ZodTypeAny, {
|
|
39
|
+
type: "coordinate";
|
|
40
|
+
position: [number, number] | import('./position').PolarPosition | {
|
|
41
|
+
direction: "above" | "below" | "left" | "right" | "above-left" | "above-right" | "below-left" | "below-right";
|
|
42
|
+
of: string;
|
|
43
|
+
distance?: number | undefined;
|
|
44
|
+
};
|
|
45
|
+
id: string;
|
|
46
|
+
}, {
|
|
47
|
+
type: "coordinate";
|
|
48
|
+
position: [number, number] | import('./position').PolarPosition | {
|
|
49
|
+
direction: "above" | "below" | "left" | "right" | "above-left" | "above-right" | "below-left" | "below-right";
|
|
50
|
+
of: string;
|
|
51
|
+
distance?: number | undefined;
|
|
52
|
+
};
|
|
53
|
+
id: string;
|
|
54
|
+
}>;
|
|
55
|
+
/** Coordinate IR 类型——`{ type: 'coordinate', id, position }` */
|
|
56
|
+
export type IRCoordinate = z.infer<typeof CoordinateSchema>;
|
|
57
|
+
//# sourceMappingURL=coordinate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coordinate.d.ts","sourceRoot":"","sources":["../../../src/ir/coordinate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmB1B,CAAC;AAEJ,+DAA+D;AAC/D,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { PositionSchema } from "./position/position.js";
|
|
2
|
+
import { PolarPositionSchema } from "./position/polar-position.js";
|
|
3
|
+
import { AtPositionSchema } from "./position/at-position.js";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
//#region src/ir/coordinate.ts
|
|
6
|
+
/**
|
|
7
|
+
* Coordinate(占位节点)——TikZ `\coordinate (m) at (3,2);` 同义。
|
|
8
|
+
*
|
|
9
|
+
* 命名一个点供后续 path / at 引用,自身不绘制任何图形。
|
|
10
|
+
* 支持笛卡尔 / 极坐标 / 相对定位三种 position 形态,与 `Node.position` 完全一致。
|
|
11
|
+
*
|
|
12
|
+
* 特点:
|
|
13
|
+
* - 必须有 `id`(无 id 的占位节点没有意义)
|
|
14
|
+
* - 不参与 viewBox 扩展(无视觉边界);只在被引用时才间接影响 viewBox(通过引用它的 node / path)
|
|
15
|
+
* - 与 Node 在同一个 nodeIndex 中注册——path target 字符串、`Node.position.of` 都能命中 coordinate id
|
|
16
|
+
*/
|
|
17
|
+
var CoordinateSchema = z.object({
|
|
18
|
+
type: z.literal("coordinate").describe("Discriminator marking this child as a coordinate placeholder"),
|
|
19
|
+
id: z.string().min(1).describe("Required unique id; the whole point of a coordinate is to be referenced by paths or other nodes"),
|
|
20
|
+
position: z.union([
|
|
21
|
+
PositionSchema,
|
|
22
|
+
PolarPositionSchema,
|
|
23
|
+
AtPositionSchema
|
|
24
|
+
]).describe("Coordinate position; Cartesian [x, y], polar, or relative-to-another-node (`at`-style). Resolved at compile time.")
|
|
25
|
+
}).describe("Coordinate placeholder: a named point with no visual; usable as a target for paths and as an anchor for relative positioning. Mirrors TikZ `\\coordinate (id) at (...);`");
|
|
26
|
+
//#endregion
|
|
27
|
+
export { CoordinateSchema };
|
package/dist/es/ir/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ir/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ir/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC"}
|