@retikz/core 0.1.0-alpha.4 → 0.1.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/compile/compile.d.ts +23 -13
- package/dist/es/compile/compile.d.ts.map +1 -1
- package/dist/es/compile/compile.js +44 -25
- package/dist/es/compile/index.d.ts +1 -1
- package/dist/es/compile/index.d.ts.map +1 -1
- package/dist/es/compile/node.d.ts +40 -59
- package/dist/es/compile/node.d.ts.map +1 -1
- package/dist/es/compile/node.js +51 -43
- package/dist/es/compile/parseTarget.d.ts +3 -8
- package/dist/es/compile/parseTarget.d.ts.map +1 -1
- package/dist/es/compile/parseTarget.js +7 -19
- package/dist/es/compile/path/anchor.d.ts +19 -0
- package/dist/es/compile/path/anchor.d.ts.map +1 -0
- package/dist/es/compile/path/anchor.js +54 -0
- package/dist/es/compile/path/index.d.ts +24 -0
- package/dist/es/compile/path/index.d.ts.map +1 -0
- package/dist/es/compile/path/index.js +308 -0
- package/dist/es/compile/path/label.d.ts +18 -0
- package/dist/es/compile/path/label.d.ts.map +1 -0
- package/dist/es/compile/path/label.js +102 -0
- package/dist/es/compile/path/relative.d.ts +8 -0
- package/dist/es/compile/path/relative.d.ts.map +1 -0
- package/dist/es/compile/path/relative.js +48 -0
- package/dist/es/compile/path/shrink.d.ts +24 -0
- package/dist/es/compile/path/shrink.d.ts.map +1 -0
- package/dist/es/compile/path/shrink.js +136 -0
- package/dist/es/compile/path/split.d.ts +15 -0
- package/dist/es/compile/path/split.d.ts.map +1 -0
- package/dist/es/compile/path/split.js +46 -0
- package/dist/es/compile/position.d.ts +4 -8
- package/dist/es/compile/position.d.ts.map +1 -1
- package/dist/es/compile/position.js +10 -10
- package/dist/es/compile/text-metrics.d.ts +6 -5
- package/dist/es/compile/text-metrics.d.ts.map +1 -1
- package/dist/es/compile/text-metrics.js +11 -5
- package/dist/es/compile/view-box.d.ts +1 -4
- package/dist/es/compile/view-box.d.ts.map +1 -1
- package/dist/es/compile/view-box.js +1 -4
- package/dist/es/geometry/_transform.d.ts +21 -0
- package/dist/es/geometry/_transform.d.ts.map +1 -0
- package/dist/es/geometry/_transform.js +27 -0
- package/dist/es/geometry/arc.d.ts +3 -28
- package/dist/es/geometry/arc.d.ts.map +1 -1
- package/dist/es/geometry/arc.js +4 -31
- package/dist/es/geometry/bend.d.ts +2 -13
- package/dist/es/geometry/bend.d.ts.map +1 -1
- package/dist/es/geometry/bend.js +2 -13
- package/dist/es/geometry/circle.d.ts +6 -15
- package/dist/es/geometry/circle.d.ts.map +1 -1
- package/dist/es/geometry/circle.js +2 -20
- package/dist/es/geometry/diamond.d.ts +10 -26
- package/dist/es/geometry/diamond.d.ts.map +1 -1
- package/dist/es/geometry/diamond.js +5 -30
- package/dist/es/geometry/ellipse.d.ts +10 -17
- package/dist/es/geometry/ellipse.d.ts.map +1 -1
- package/dist/es/geometry/ellipse.js +5 -24
- package/dist/es/geometry/point.d.ts +8 -9
- package/dist/es/geometry/point.d.ts.map +1 -1
- package/dist/es/geometry/point.js +8 -9
- package/dist/es/geometry/polar.d.ts +12 -21
- package/dist/es/geometry/polar.d.ts.map +1 -1
- package/dist/es/geometry/polar.js +8 -19
- package/dist/es/geometry/rect.d.ts +8 -32
- package/dist/es/geometry/rect.d.ts.map +1 -1
- package/dist/es/geometry/rect.js +6 -49
- package/dist/es/geometry/segment.d.ts +15 -18
- package/dist/es/geometry/segment.d.ts.map +1 -1
- package/dist/es/geometry/segment.js +9 -16
- package/dist/es/index.d.ts +13 -13
- package/dist/es/index.d.ts.map +1 -1
- package/dist/es/index.js +7 -4
- package/dist/es/ir/coordinate.d.ts +18 -10
- package/dist/es/ir/coordinate.d.ts.map +1 -1
- package/dist/es/ir/coordinate.js +6 -11
- package/dist/es/ir/font.d.ts +21 -0
- package/dist/es/ir/font.d.ts.map +1 -0
- package/dist/es/ir/font.js +15 -0
- package/dist/es/ir/index.d.ts +2 -0
- package/dist/es/ir/index.d.ts.map +1 -1
- package/dist/es/ir/node.d.ts +51 -181
- package/dist/es/ir/node.d.ts.map +1 -1
- package/dist/es/ir/node.js +15 -70
- package/dist/es/ir/path/arrow.d.ts +210 -12
- package/dist/es/ir/path/arrow.d.ts.map +1 -1
- package/dist/es/ir/path/arrow.js +39 -12
- package/dist/es/ir/path/path.d.ts +477 -153
- package/dist/es/ir/path/path.d.ts.map +1 -1
- package/dist/es/ir/path/path.js +6 -6
- package/dist/es/ir/path/step.d.ts +395 -223
- package/dist/es/ir/path/step.d.ts.map +1 -1
- package/dist/es/ir/path/step.js +21 -22
- package/dist/es/ir/path/target.d.ts +25 -16
- package/dist/es/ir/path/target.d.ts.map +1 -1
- package/dist/es/ir/path/target.js +8 -6
- package/dist/es/ir/position/at-position.d.ts +4 -11
- package/dist/es/ir/position/at-position.d.ts.map +1 -1
- package/dist/es/ir/position/at-position.js +2 -9
- 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/position/offset-position.d.ts +14 -0
- package/dist/es/ir/position/offset-position.d.ts.map +1 -0
- package/dist/es/ir/position/offset-position.js +14 -0
- package/dist/es/ir/position/polar-position.d.ts +1 -4
- package/dist/es/ir/position/polar-position.d.ts.map +1 -1
- package/dist/es/ir/position/polar-position.js +3 -6
- package/dist/es/ir/position/position.d.ts.map +1 -1
- package/dist/es/ir/position/position.js +1 -1
- package/dist/es/ir/scene.d.ts +1236 -422
- package/dist/es/ir/scene.d.ts.map +1 -1
- package/dist/es/ir/text.d.ts +96 -0
- package/dist/es/ir/text.d.ts.map +1 -0
- package/dist/es/ir/text.js +20 -0
- package/dist/es/parsers/parseTargetSugar.d.ts +4 -0
- package/dist/es/parsers/parseTargetSugar.d.ts.map +1 -1
- package/dist/es/parsers/parseTargetSugar.js +7 -19
- package/dist/es/parsers/parseWay.d.ts +26 -118
- package/dist/es/parsers/parseWay.d.ts.map +1 -1
- package/dist/es/parsers/parseWay.js +19 -61
- package/dist/es/primitive/ellipse.d.ts +4 -14
- package/dist/es/primitive/ellipse.d.ts.map +1 -1
- package/dist/es/primitive/group.d.ts +37 -3
- package/dist/es/primitive/group.d.ts.map +1 -1
- package/dist/es/primitive/path.d.ts +107 -7
- package/dist/es/primitive/path.d.ts.map +1 -1
- package/dist/es/primitive/rect.d.ts +2 -2
- package/dist/es/primitive/rect.d.ts.map +1 -1
- package/dist/es/primitive/scene.d.ts +2 -4
- package/dist/es/primitive/scene.d.ts.map +1 -1
- package/dist/es/primitive/text.d.ts +16 -32
- package/dist/es/primitive/text.d.ts.map +1 -1
- package/dist/es/primitive/view-box.d.ts +1 -1
- package/dist/es/primitive/view-box.d.ts.map +1 -1
- package/dist/es/types.d.ts +8 -0
- package/dist/es/types.d.ts.map +1 -1
- package/dist/lib/compile/compile.cjs +44 -25
- package/dist/lib/compile/compile.d.ts +23 -13
- package/dist/lib/compile/compile.d.ts.map +1 -1
- package/dist/lib/compile/index.d.ts +1 -1
- package/dist/lib/compile/index.d.ts.map +1 -1
- package/dist/lib/compile/node.cjs +51 -43
- package/dist/lib/compile/node.d.ts +40 -59
- package/dist/lib/compile/node.d.ts.map +1 -1
- package/dist/lib/compile/parseTarget.cjs +7 -19
- package/dist/lib/compile/parseTarget.d.ts +3 -8
- package/dist/lib/compile/parseTarget.d.ts.map +1 -1
- package/dist/lib/compile/path/anchor.cjs +58 -0
- package/dist/lib/compile/path/anchor.d.ts +19 -0
- package/dist/lib/compile/path/anchor.d.ts.map +1 -0
- package/dist/lib/compile/path/index.cjs +308 -0
- package/dist/lib/compile/path/index.d.ts +24 -0
- package/dist/lib/compile/path/index.d.ts.map +1 -0
- package/dist/lib/compile/path/label.cjs +103 -0
- package/dist/lib/compile/path/label.d.ts +18 -0
- package/dist/lib/compile/path/label.d.ts.map +1 -0
- package/dist/lib/compile/path/relative.cjs +48 -0
- package/dist/lib/compile/path/relative.d.ts +8 -0
- package/dist/lib/compile/path/relative.d.ts.map +1 -0
- package/dist/lib/compile/path/shrink.cjs +138 -0
- package/dist/lib/compile/path/shrink.d.ts +24 -0
- package/dist/lib/compile/path/shrink.d.ts.map +1 -0
- package/dist/lib/compile/path/split.cjs +46 -0
- package/dist/lib/compile/path/split.d.ts +15 -0
- package/dist/lib/compile/path/split.d.ts.map +1 -0
- package/dist/lib/compile/position.cjs +10 -10
- package/dist/lib/compile/position.d.ts +4 -8
- package/dist/lib/compile/position.d.ts.map +1 -1
- package/dist/lib/compile/text-metrics.cjs +11 -5
- package/dist/lib/compile/text-metrics.d.ts +6 -5
- package/dist/lib/compile/text-metrics.d.ts.map +1 -1
- package/dist/lib/compile/view-box.cjs +1 -4
- package/dist/lib/compile/view-box.d.ts +1 -4
- package/dist/lib/compile/view-box.d.ts.map +1 -1
- package/dist/lib/geometry/_transform.cjs +28 -0
- package/dist/lib/geometry/_transform.d.ts +21 -0
- package/dist/lib/geometry/_transform.d.ts.map +1 -0
- package/dist/lib/geometry/arc.cjs +3 -31
- package/dist/lib/geometry/arc.d.ts +3 -28
- package/dist/lib/geometry/arc.d.ts.map +1 -1
- package/dist/lib/geometry/bend.cjs +2 -13
- package/dist/lib/geometry/bend.d.ts +2 -13
- package/dist/lib/geometry/bend.d.ts.map +1 -1
- package/dist/lib/geometry/circle.cjs +6 -24
- package/dist/lib/geometry/circle.d.ts +6 -15
- package/dist/lib/geometry/circle.d.ts.map +1 -1
- package/dist/lib/geometry/diamond.cjs +9 -34
- package/dist/lib/geometry/diamond.d.ts +10 -26
- package/dist/lib/geometry/diamond.d.ts.map +1 -1
- package/dist/lib/geometry/ellipse.cjs +9 -28
- package/dist/lib/geometry/ellipse.d.ts +10 -17
- package/dist/lib/geometry/ellipse.d.ts.map +1 -1
- package/dist/lib/geometry/point.cjs +8 -9
- package/dist/lib/geometry/point.d.ts +8 -9
- package/dist/lib/geometry/point.d.ts.map +1 -1
- package/dist/lib/geometry/polar.cjs +8 -19
- package/dist/lib/geometry/polar.d.ts +12 -21
- package/dist/lib/geometry/polar.d.ts.map +1 -1
- package/dist/lib/geometry/rect.cjs +10 -53
- package/dist/lib/geometry/rect.d.ts +8 -32
- package/dist/lib/geometry/rect.d.ts.map +1 -1
- package/dist/lib/geometry/segment.cjs +9 -16
- package/dist/lib/geometry/segment.d.ts +15 -18
- package/dist/lib/geometry/segment.d.ts.map +1 -1
- package/dist/lib/index.cjs +14 -5
- package/dist/lib/index.d.ts +13 -13
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/ir/coordinate.cjs +6 -11
- package/dist/lib/ir/coordinate.d.ts +18 -10
- package/dist/lib/ir/coordinate.d.ts.map +1 -1
- package/dist/lib/ir/font.cjs +15 -0
- package/dist/lib/ir/font.d.ts +21 -0
- package/dist/lib/ir/font.d.ts.map +1 -0
- package/dist/lib/ir/index.d.ts +2 -0
- package/dist/lib/ir/index.d.ts.map +1 -1
- package/dist/lib/ir/node.cjs +16 -74
- package/dist/lib/ir/node.d.ts +51 -181
- package/dist/lib/ir/node.d.ts.map +1 -1
- package/dist/lib/ir/path/arrow.cjs +43 -11
- package/dist/lib/ir/path/arrow.d.ts +210 -12
- package/dist/lib/ir/path/arrow.d.ts.map +1 -1
- package/dist/lib/ir/path/path.cjs +5 -5
- package/dist/lib/ir/path/path.d.ts +477 -153
- package/dist/lib/ir/path/path.d.ts.map +1 -1
- package/dist/lib/ir/path/step.cjs +21 -22
- package/dist/lib/ir/path/step.d.ts +395 -223
- package/dist/lib/ir/path/step.d.ts.map +1 -1
- package/dist/lib/ir/path/target.cjs +9 -7
- package/dist/lib/ir/path/target.d.ts +25 -16
- package/dist/lib/ir/path/target.d.ts.map +1 -1
- package/dist/lib/ir/position/at-position.cjs +2 -9
- package/dist/lib/ir/position/at-position.d.ts +4 -11
- package/dist/lib/ir/position/at-position.d.ts.map +1 -1
- 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/position/offset-position.cjs +14 -0
- package/dist/lib/ir/position/offset-position.d.ts +14 -0
- package/dist/lib/ir/position/offset-position.d.ts.map +1 -0
- package/dist/lib/ir/position/polar-position.cjs +3 -6
- package/dist/lib/ir/position/polar-position.d.ts +1 -4
- package/dist/lib/ir/position/polar-position.d.ts.map +1 -1
- package/dist/lib/ir/position/position.cjs +1 -1
- package/dist/lib/ir/position/position.d.ts.map +1 -1
- package/dist/lib/ir/scene.d.ts +1236 -422
- package/dist/lib/ir/scene.d.ts.map +1 -1
- package/dist/lib/ir/text.cjs +21 -0
- package/dist/lib/ir/text.d.ts +96 -0
- package/dist/lib/ir/text.d.ts.map +1 -0
- package/dist/lib/parsers/parseTargetSugar.cjs +7 -19
- package/dist/lib/parsers/parseTargetSugar.d.ts +4 -0
- package/dist/lib/parsers/parseTargetSugar.d.ts.map +1 -1
- package/dist/lib/parsers/parseWay.cjs +19 -61
- package/dist/lib/parsers/parseWay.d.ts +26 -118
- package/dist/lib/parsers/parseWay.d.ts.map +1 -1
- package/dist/lib/primitive/ellipse.d.ts +4 -14
- package/dist/lib/primitive/ellipse.d.ts.map +1 -1
- package/dist/lib/primitive/group.d.ts +37 -3
- package/dist/lib/primitive/group.d.ts.map +1 -1
- package/dist/lib/primitive/path.d.ts +107 -7
- package/dist/lib/primitive/path.d.ts.map +1 -1
- package/dist/lib/primitive/rect.d.ts +2 -2
- package/dist/lib/primitive/rect.d.ts.map +1 -1
- package/dist/lib/primitive/scene.d.ts +2 -4
- package/dist/lib/primitive/scene.d.ts.map +1 -1
- package/dist/lib/primitive/text.d.ts +16 -32
- package/dist/lib/primitive/text.d.ts.map +1 -1
- package/dist/lib/primitive/view-box.d.ts +1 -1
- package/dist/lib/primitive/view-box.d.ts.map +1 -1
- package/dist/lib/types.d.ts +8 -0
- package/dist/lib/types.d.ts.map +1 -1
- package/package.json +13 -4
- package/dist/es/compile/path.d.ts +0 -30
- package/dist/es/compile/path.d.ts.map +0 -1
- package/dist/es/compile/path.js +0 -617
- package/dist/lib/compile/path.cjs +0 -617
- package/dist/lib/compile/path.d.ts +0 -30
- package/dist/lib/compile/path.d.ts.map +0 -1
|
@@ -1,10 +1,44 @@
|
|
|
1
1
|
import { ScenePrimitive } from './scene';
|
|
2
|
-
/**
|
|
2
|
+
/** Translate transform:沿 x / y 平移(user units) */
|
|
3
|
+
export type TranslateTransform = {
|
|
4
|
+
/** 鉴别字面量 */
|
|
5
|
+
kind: 'translate';
|
|
6
|
+
/** x 方向位移 */
|
|
7
|
+
x: number;
|
|
8
|
+
/** y 方向位移(屏幕 y-down) */
|
|
9
|
+
y: number;
|
|
10
|
+
};
|
|
11
|
+
/** Rotate transform:按角度旋转,可指定旋转中心;中心缺省 = 绕原点 (0, 0) */
|
|
12
|
+
export type RotateTransform = {
|
|
13
|
+
/** 鉴别字面量 */
|
|
14
|
+
kind: 'rotate';
|
|
15
|
+
/** 旋转角度(度,正向 = 屏幕 y-down 下的视觉顺时针) */
|
|
16
|
+
degrees: number;
|
|
17
|
+
/** 旋转中心 x(缺省 0) */
|
|
18
|
+
cx?: number;
|
|
19
|
+
/** 旋转中心 y(缺省 0) */
|
|
20
|
+
cy?: number;
|
|
21
|
+
};
|
|
22
|
+
/** Scale transform:等比 / 非等比缩放;y 缺省 = x(等比) */
|
|
23
|
+
export type ScaleTransform = {
|
|
24
|
+
/** 鉴别字面量 */
|
|
25
|
+
kind: 'scale';
|
|
26
|
+
/** x 轴缩放因子 */
|
|
27
|
+
x: number;
|
|
28
|
+
/** y 轴缩放因子;缺省 = x(等比缩放) */
|
|
29
|
+
y?: number;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Group transform:结构化变换(3 分支 discriminated union)
|
|
33
|
+
* @description 按数组顺序应用(与 SVG transform 多操作列表语义一致);角度=度,缩放 y 缺省等比 x,rotate cx/cy 缺省绕原点。每个 kind 有对应 named type export。
|
|
34
|
+
*/
|
|
35
|
+
export type Transform = TranslateTransform | RotateTransform | ScaleTransform;
|
|
36
|
+
/** 编组:把若干 primitive 用结构化 transforms 包起来 */
|
|
3
37
|
export type GroupPrim = {
|
|
4
38
|
/** 类型判别符 */
|
|
5
39
|
type: 'group';
|
|
6
|
-
/**
|
|
7
|
-
|
|
40
|
+
/** 结构化变换序列,按数组顺序应用;undefined / 空数组表示无变换 */
|
|
41
|
+
transforms?: Array<Transform>;
|
|
8
42
|
/** 组内子原语 */
|
|
9
43
|
children: Array<ScenePrimitive>;
|
|
10
44
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"group.d.ts","sourceRoot":"","sources":["../../../src/primitive/group.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,
|
|
1
|
+
{"version":3,"file":"group.d.ts","sourceRoot":"","sources":["../../../src/primitive/group.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,iDAAiD;AACjD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,YAAY;IACZ,IAAI,EAAE,WAAW,CAAC;IAClB,aAAa;IACb,CAAC,EAAE,MAAM,CAAC;IACV,wBAAwB;IACxB,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAEF,uDAAuD;AACvD,MAAM,MAAM,eAAe,GAAG;IAC5B,YAAY;IACZ,IAAI,EAAE,QAAQ,CAAC;IACf,qCAAqC;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,mBAAmB;IACnB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,mBAAmB;IACnB,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,8CAA8C;AAC9C,MAAM,MAAM,cAAc,GAAG;IAC3B,YAAY;IACZ,IAAI,EAAE,OAAO,CAAC;IACd,cAAc;IACd,CAAC,EAAE,MAAM,CAAC;IACV,2BAA2B;IAC3B,CAAC,CAAC,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,SAAS,GACjB,kBAAkB,GAClB,eAAe,GACf,cAAc,CAAC;AAEnB,2CAA2C;AAC3C,MAAM,MAAM,SAAS,GAAG;IACtB,YAAY;IACZ,IAAI,EAAE,OAAO,CAAC;IACd,2CAA2C;IAC3C,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IAC9B,YAAY;IACZ,QAAQ,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;CACjC,CAAC"}
|
|
@@ -1,10 +1,110 @@
|
|
|
1
1
|
import { ArrowShape } from '../ir/path/arrow';
|
|
2
|
-
/**
|
|
2
|
+
/** Move command:移动游标到目标点,不绘制 */
|
|
3
|
+
export type MovePathCommand = {
|
|
4
|
+
/** 鉴别字面量 */
|
|
5
|
+
kind: 'move';
|
|
6
|
+
/** 目标点 [x, y] */
|
|
7
|
+
to: [number, number];
|
|
8
|
+
};
|
|
9
|
+
/** Line command:从游标到目标点画直线 */
|
|
10
|
+
export type LinePathCommand = {
|
|
11
|
+
/** 鉴别字面量 */
|
|
12
|
+
kind: 'line';
|
|
13
|
+
/** 终点 [x, y] */
|
|
14
|
+
to: [number, number];
|
|
15
|
+
};
|
|
16
|
+
/** Quad command:二次贝塞尔,一个控制点 */
|
|
17
|
+
export type QuadPathCommand = {
|
|
18
|
+
/** 鉴别字面量 */
|
|
19
|
+
kind: 'quad';
|
|
20
|
+
/** 控制点 [x, y] */
|
|
21
|
+
control: [number, number];
|
|
22
|
+
/** 终点 [x, y] */
|
|
23
|
+
to: [number, number];
|
|
24
|
+
};
|
|
25
|
+
/** Cubic command:三次贝塞尔,两个控制点 */
|
|
26
|
+
export type CubicPathCommand = {
|
|
27
|
+
/** 鉴别字面量 */
|
|
28
|
+
kind: 'cubic';
|
|
29
|
+
/** 第一控制点 [x, y](影响起点切线) */
|
|
30
|
+
control1: [number, number];
|
|
31
|
+
/** 第二控制点 [x, y](影响终点切线) */
|
|
32
|
+
control2: [number, number];
|
|
33
|
+
/** 终点 [x, y] */
|
|
34
|
+
to: [number, number];
|
|
35
|
+
};
|
|
36
|
+
/** Arc command:以 center 为圆心、给定半径与起末角度的圆弧(center-parameterization) */
|
|
37
|
+
export type ArcPathCommand = {
|
|
38
|
+
/** 鉴别字面量 */
|
|
39
|
+
kind: 'arc';
|
|
40
|
+
/** 圆心 [x, y] */
|
|
41
|
+
center: [number, number];
|
|
42
|
+
/** 半径(user units) */
|
|
43
|
+
radius: number;
|
|
44
|
+
/** 起始角度(度,0° = +x、90° = +y screen-down) */
|
|
45
|
+
startAngle: number;
|
|
46
|
+
/** 终止角度(度) */
|
|
47
|
+
endAngle: number;
|
|
48
|
+
/** 是否逆时针扫描;缺省 / `false` = CW(屏幕坐标系正向) */
|
|
49
|
+
counterClockwise?: boolean;
|
|
50
|
+
};
|
|
51
|
+
/** EllipseArc command:以 center 为圆心、给定 x/y 半径与起末角度的椭圆弧;可选 rotation */
|
|
52
|
+
export type EllipseArcPathCommand = {
|
|
53
|
+
/** 鉴别字面量 */
|
|
54
|
+
kind: 'ellipseArc';
|
|
55
|
+
/** 圆心 [x, y] */
|
|
56
|
+
center: [number, number];
|
|
57
|
+
/** x 轴半径 */
|
|
58
|
+
radiusX: number;
|
|
59
|
+
/** y 轴半径 */
|
|
60
|
+
radiusY: number;
|
|
61
|
+
/** 椭圆整体旋转角度(度),缺省 0 */
|
|
62
|
+
rotation?: number;
|
|
63
|
+
/** 起始角度(度) */
|
|
64
|
+
startAngle: number;
|
|
65
|
+
/** 终止角度(度) */
|
|
66
|
+
endAngle: number;
|
|
67
|
+
/** 是否逆时针扫描;缺省 / `false` = CW */
|
|
68
|
+
counterClockwise?: boolean;
|
|
69
|
+
};
|
|
70
|
+
/** Close command:闭合当前子路径回最近一次 move 起点 */
|
|
71
|
+
export type ClosePathCommand = {
|
|
72
|
+
/** 鉴别字面量;无其他字段 */
|
|
73
|
+
kind: 'close';
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Path 命令:结构化路径绘制操作(7 分支 discriminated union)
|
|
77
|
+
* @description discriminated union 按 kind 分发;坐标 / 角度均使用 user units(角度=度,0=+x、90=+y/视觉下、CW=正)。各 adapter 自行翻译为原生 API:SVG 拼 `d` 字符串、Canvas 调 ctx.moveTo/lineTo/arc 等。每个 kind 有对应 named type export,便于 wrapper / `Pick<>` 派生。
|
|
78
|
+
*/
|
|
79
|
+
export type PathCommand = MovePathCommand | LinePathCommand | QuadPathCommand | CubicPathCommand | ArcPathCommand | EllipseArcPathCommand | ClosePathCommand;
|
|
80
|
+
/**
|
|
81
|
+
* 端点级解析后的箭头视觉规格(Scene primitive 层)
|
|
82
|
+
* @description compile/path.ts 把 IR `arrowDetail` 顶层 + start/end merge 后产出此结构。`shape` 必填、其余视觉字段全 optional:缺省字段交给 renderer 走 context-stroke / 硬编码 fallback,保持向后兼容
|
|
83
|
+
*/
|
|
84
|
+
export type ArrowEndSpec = {
|
|
85
|
+
/** 形状名 */
|
|
86
|
+
shape: ArrowShape;
|
|
87
|
+
/** 等比缩放因子(乘到 length/width 上);缺省 1 */
|
|
88
|
+
scale?: number;
|
|
89
|
+
/** 尖长(user units);缺省让 renderer 走默认 6 */
|
|
90
|
+
length?: number;
|
|
91
|
+
/** 尖宽(user units);缺省让 renderer 走默认 6 */
|
|
92
|
+
width?: number;
|
|
93
|
+
/** 描边颜色 override;缺省走 context-stroke(继承 path stroke) */
|
|
94
|
+
color?: string;
|
|
95
|
+
/** 填充色 override(仅实心 shape 生效;空心 shape 已在 compile 阶段被丢) */
|
|
96
|
+
fill?: string;
|
|
97
|
+
/** 箭头不透明度 0..1;缺省继承 path opacity */
|
|
98
|
+
opacity?: number;
|
|
99
|
+
/** 空心 shape 描边粗细(user units);缺省 1.5。实心 shape 忽略 */
|
|
100
|
+
lineWidth?: number;
|
|
101
|
+
};
|
|
102
|
+
/** 路径原语:结构化 commands 数组;adapter 在 render 时翻译为各自原生 API */
|
|
3
103
|
export type PathPrim = {
|
|
4
104
|
/** 类型判别符 */
|
|
5
105
|
type: 'path';
|
|
6
|
-
/**
|
|
7
|
-
|
|
106
|
+
/** 结构化路径命令序列,按数组顺序绘制 */
|
|
107
|
+
commands: Array<PathCommand>;
|
|
8
108
|
/** 填充色;不填表示不填充 */
|
|
9
109
|
fill?: string;
|
|
10
110
|
/** 填充透明度 0~1 */
|
|
@@ -23,10 +123,10 @@ export type PathPrim = {
|
|
|
23
123
|
strokeLinecap?: 'butt' | 'round' | 'square';
|
|
24
124
|
/** 拐点形状 */
|
|
25
125
|
strokeLinejoin?: 'miter' | 'round' | 'bevel';
|
|
26
|
-
/**
|
|
27
|
-
arrowStart?:
|
|
28
|
-
/**
|
|
29
|
-
arrowEnd?:
|
|
126
|
+
/** 起点箭头视觉规格;undefined = 无箭头 */
|
|
127
|
+
arrowStart?: ArrowEndSpec;
|
|
128
|
+
/** 终点箭头视觉规格;undefined = 无箭头 */
|
|
129
|
+
arrowEnd?: ArrowEndSpec;
|
|
30
130
|
/** 整体透明度 0~1 */
|
|
31
131
|
opacity?: number;
|
|
32
132
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../../src/primitive/path.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,
|
|
1
|
+
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../../src/primitive/path.ts"],"names":[],"mappings":"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"}
|
|
@@ -16,11 +16,11 @@ export type RectPrim = {
|
|
|
16
16
|
fillOpacity?: number;
|
|
17
17
|
/** 描边色 */
|
|
18
18
|
stroke?: string;
|
|
19
|
-
/** 描边透明度 0~1
|
|
19
|
+
/** 描边透明度 0~1 */
|
|
20
20
|
strokeOpacity?: number;
|
|
21
21
|
/** 描边宽度 */
|
|
22
22
|
strokeWidth?: number;
|
|
23
|
-
/** SVG stroke-dasharray
|
|
23
|
+
/** 描边 dash 模式(如 '4 2',与 SVG/CSS `stroke-dasharray` 同格式) */
|
|
24
24
|
strokeDasharray?: string;
|
|
25
25
|
/** 圆角半径(同时作用于 rx/ry) */
|
|
26
26
|
cornerRadius?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rect.d.ts","sourceRoot":"","sources":["../../../src/primitive/rect.ts"],"names":[],"mappings":"AAAA,WAAW;AACX,MAAM,MAAM,QAAQ,GAAG;IACrB,YAAY;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,aAAa;IACb,CAAC,EAAE,MAAM,CAAC;IACV,aAAa;IACb,CAAC,EAAE,MAAM,CAAC;IACV,WAAW;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW;IACX,MAAM,EAAE,MAAM,CAAC;IACf,oBAAoB;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gBAAgB;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU;IACV,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,
|
|
1
|
+
{"version":3,"file":"rect.d.ts","sourceRoot":"","sources":["../../../src/primitive/rect.ts"],"names":[],"mappings":"AAAA,WAAW;AACX,MAAM,MAAM,QAAQ,GAAG;IACrB,YAAY;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,aAAa;IACb,CAAC,EAAE,MAAM,CAAC;IACV,aAAa;IACb,CAAC,EAAE,MAAM,CAAC;IACV,WAAW;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW;IACX,MAAM,EAAE,MAAM,CAAC;IACf,oBAAoB;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gBAAgB;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU;IACV,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gBAAgB;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW;IACX,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2DAA2D;IAC3D,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,wBAAwB;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gBAAgB;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC"}
|
|
@@ -5,10 +5,8 @@ import { RectPrim } from './rect';
|
|
|
5
5
|
import { TextPrim } from './text';
|
|
6
6
|
import { ViewBox } from './view-box';
|
|
7
7
|
/**
|
|
8
|
-
* Scene primitive
|
|
9
|
-
* 所有 adapter(SVG
|
|
10
|
-
*
|
|
11
|
-
* 不允许出现 SVG-only 或 Canvas-only 特性(filter、marker、imageData 等)。
|
|
8
|
+
* Scene primitive:渲染目标无关的最大公约子集
|
|
9
|
+
* @description 所有 adapter(SVG/Canvas/PDF/Skia)都应能消费;不允许出现 SVG-only 或 Canvas-only 特性(filter/marker/imageData)
|
|
12
10
|
*/
|
|
13
11
|
export type ScenePrimitive = RectPrim | EllipsePrim | TextPrim | PathPrim | GroupPrim;
|
|
14
12
|
/** 场景:渲染目标无关的"已布局好的图元集合 + viewBox" */
|
|
@@ -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,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C
|
|
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,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,WAAW,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEtF,sCAAsC;AACtC,MAAM,MAAM,KAAK,GAAG;IAClB,wBAAwB;IACxB,UAAU,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;IAClC,gBAAgB;IAChB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC"}
|
|
@@ -1,62 +1,46 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 行级字段——`<tspan>` 上可独立指定的属性。
|
|
3
|
-
* 块级(TextPrim 顶层)属性是默认值;行级未填字段走块级默认。
|
|
4
|
-
*/
|
|
1
|
+
/** 行级字段(每行可独立指定),未填走块级 TextPrim 默认 */
|
|
5
2
|
export type TextLine = {
|
|
6
|
-
/**
|
|
3
|
+
/** 行文字内容 */
|
|
7
4
|
text: string;
|
|
8
|
-
/**
|
|
5
|
+
/** 行级字号 override(user units);缺省走块级 TextPrim.fontSize */
|
|
9
6
|
fontSize?: number;
|
|
10
|
-
/**
|
|
7
|
+
/** 行级字体族 override(CSS font-family);缺省走块级 */
|
|
11
8
|
fontFamily?: string;
|
|
12
|
-
/**
|
|
9
|
+
/** 行级字重 override(CSS font-weight);缺省走块级 */
|
|
13
10
|
fontWeight?: string | number;
|
|
14
|
-
/**
|
|
11
|
+
/** 行级字形 override;缺省走块级 */
|
|
15
12
|
fontStyle?: 'normal' | 'italic' | 'oblique';
|
|
16
|
-
/**
|
|
13
|
+
/** 行级文字颜色 override;缺省走块级 TextPrim.fill */
|
|
17
14
|
fill?: string;
|
|
18
|
-
/**
|
|
15
|
+
/** 行级透明度 0..1 override;缺省走块级 */
|
|
19
16
|
opacity?: number;
|
|
20
17
|
};
|
|
21
18
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* 多行:`lines` 至少 1 行;renderer 把每行画为 `<tspan>`,按 `lineHeight` 堆叠,
|
|
25
|
-
* 整块根据 `baseline` 在 (x, y) 锚点上下居中 / 顶 / 底对齐。
|
|
26
|
-
*
|
|
27
|
-
* 顶层 `fontSize` / `fontFamily` / `fontWeight` / `fontStyle` / `fill` / `opacity` 是默认值;
|
|
28
|
-
* 单行可在 `TextLine` 上覆盖(仅生效于该行 `<tspan>`)。
|
|
19
|
+
* 文本原语(measuredWidth/Height 由 Scene 编译阶段算好)
|
|
20
|
+
* @description 多行 lines 至少 1 行;renderer 按 lineHeight 堆叠每行、按 baseline 在 (x,y) 锚点上下对齐。顶层属性是块级默认,单行 TextLine 可覆盖
|
|
29
21
|
*/
|
|
30
22
|
export type TextPrim = {
|
|
31
|
-
/** 类型判别符 */
|
|
32
23
|
type: 'text';
|
|
33
|
-
/** 锚点横坐标(具体含义由 align
|
|
24
|
+
/** 锚点横坐标(具体含义由 align 决定) */
|
|
34
25
|
x: number;
|
|
35
26
|
/** 锚点纵坐标(具体含义由 baseline 决定) */
|
|
36
27
|
y: number;
|
|
37
|
-
/**
|
|
28
|
+
/** 至少 1 行;单行节点也用 `[{ text: 'Hello' }]` */
|
|
38
29
|
lines: Array<TextLine>;
|
|
39
|
-
/** 块级默认字号 */
|
|
40
30
|
fontSize: number;
|
|
41
|
-
/** 块级默认字体族 */
|
|
42
31
|
fontFamily?: string;
|
|
43
|
-
/** 块级默认字重 */
|
|
44
32
|
fontWeight?: string | number;
|
|
45
|
-
/** 块级默认字形 */
|
|
46
33
|
fontStyle?: 'normal' | 'italic' | 'oblique';
|
|
47
|
-
/** 水平对齐:start / middle / end 锚点位置 */
|
|
48
34
|
align: 'start' | 'middle' | 'end';
|
|
49
|
-
/** 垂直基线对齐方式 */
|
|
50
35
|
baseline: 'top' | 'middle' | 'bottom' | 'alphabetic';
|
|
51
|
-
/**
|
|
36
|
+
/** 行高,多行下相邻行的垂直距离 */
|
|
52
37
|
lineHeight: number;
|
|
53
|
-
/**
|
|
38
|
+
/** 编译期算好的整块文字宽度 = max line width */
|
|
54
39
|
measuredWidth: number;
|
|
55
|
-
/**
|
|
40
|
+
/** 编译期算好的整块文字高度 ≈ lines × lineHeight */
|
|
56
41
|
measuredHeight: number;
|
|
57
|
-
/** 块级默认文字颜色 */
|
|
58
42
|
fill?: string;
|
|
59
|
-
/**
|
|
43
|
+
/** 整体透明度 0~1 */
|
|
60
44
|
opacity?: number;
|
|
61
45
|
};
|
|
62
46
|
//# sourceMappingURL=text.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../src/primitive/text.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../src/primitive/text.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,MAAM,MAAM,QAAQ,GAAG;IACrB,YAAY;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,wDAAwD;IACxD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,4CAA4C;IAC5C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2CAA2C;IAC3C,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC7B,0BAA0B;IAC1B,SAAS,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;IAC5C,0CAA0C;IAC1C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gCAAgC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,4BAA4B;IAC5B,CAAC,EAAE,MAAM,CAAC;IACV,+BAA+B;IAC/B,CAAC,EAAE,MAAM,CAAC;IACV,0CAA0C;IAC1C,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC7B,SAAS,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;IAC5C,KAAK,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;IAClC,QAAQ,EAAE,KAAK,GAAG,QAAQ,GAAG,QAAQ,GAAG,YAAY,CAAC;IACrD,qBAAqB;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,oCAAoC;IACpC,aAAa,EAAE,MAAM,CAAC;IACtB,wCAAwC;IACxC,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gBAAgB;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view-box.d.ts","sourceRoot":"","sources":["../../../src/primitive/view-box.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"view-box.d.ts","sourceRoot":"","sources":["../../../src/primitive/view-box.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,MAAM,MAAM,OAAO,GAAG;IACpB,eAAe;IACf,CAAC,EAAE,MAAM,CAAC;IACV,eAAe;IACf,CAAC,EAAE,MAAM,CAAC;IACV,WAAW;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW;IACX,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC"}
|
package/dist/es/types.d.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
/** 获取对象所有值的联合类型,等价于 (typeof T)[keyof typeof T] */
|
|
2
2
|
export type ValueOf<T extends object> = T[keyof T];
|
|
3
|
+
/**
|
|
4
|
+
* 类型层等价检查工具(internal idiom,公开 API 不导出)
|
|
5
|
+
* @description 当 A、B 完全等价时类型为 `true`,否则为 `false`——配合 `as const satisfies` 实现"字段表必须完备覆盖类型 key 集合"的互锁;漏字段或多字段 TS 编译期报错
|
|
6
|
+
* @example
|
|
7
|
+
* const NODE_FIELDS = ['id', 'shape'] as const satisfies ReadonlyArray<keyof IRNode>;
|
|
8
|
+
* type _Check = AssertEqual<typeof NODE_FIELDS[number], keyof IRNode>;
|
|
9
|
+
*/
|
|
10
|
+
export type AssertEqual<TActual, TExpected> = [TActual] extends [TExpected] ? [TExpected] extends [TActual] ? true : false : false;
|
|
3
11
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/es/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAEnD;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,CAAC,OAAO,EAAE,SAAS,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC,GACvE,CAAC,SAAS,CAAC,SAAS,CAAC,OAAO,CAAC,GAC3B,IAAI,GACJ,KAAK,GACP,KAAK,CAAC"}
|
|
@@ -2,14 +2,13 @@ const require_rect = require("../geometry/rect.cjs");
|
|
|
2
2
|
const require_position = require("./position.cjs");
|
|
3
3
|
const require_node = require("./node.cjs");
|
|
4
4
|
const require_text_metrics = require("./text-metrics.cjs");
|
|
5
|
-
const
|
|
5
|
+
const require_index = require("./path/index.cjs");
|
|
6
6
|
const require_precision = require("./precision.cjs");
|
|
7
7
|
const require_view_box = require("./view-box.cjs");
|
|
8
8
|
//#region src/compile/compile.ts
|
|
9
9
|
/**
|
|
10
|
-
* 把 coordinate
|
|
11
|
-
*
|
|
12
|
-
* 的 boundaryPoint 始终返回中心,符合"占位无形状边界"语义)。
|
|
10
|
+
* 把 coordinate 注册成 0×0 NodeLayout
|
|
11
|
+
* @description 让后续 path target / `at.of` 引用时 boundaryPoint 命中中心,符合"占位无形状边界"语义
|
|
13
12
|
*/
|
|
14
13
|
var coordinateAsLayout = (id, center) => ({
|
|
15
14
|
id,
|
|
@@ -30,37 +29,57 @@ var coordinateAsLayout = (id, center) => ({
|
|
|
30
29
|
fontSize: 0
|
|
31
30
|
});
|
|
32
31
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
32
|
+
* 默认 warn dispatcher:dev 模式 console.warn、生产静默
|
|
33
|
+
* @description 用户传 onWarn 时使用用户的;不传走此 fallback
|
|
34
|
+
*/
|
|
35
|
+
var defaultWarnDispatcher = (warning) => {
|
|
36
|
+
if (typeof process !== "undefined" && process.env.NODE_ENV === "production") return;
|
|
37
|
+
console.warn(`[retikz] ${warning.code} at ${warning.path}: ${warning.message}`);
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* IR → Scene 纯函数转换,所有 adapter 共享
|
|
41
|
+
* @description Pass 1 处理 Node/coordinate 并注册 nodeIndex、发 primitive、累积 bbox;Pass 2 解析 Path 端点写 d 字符串;末端按 precision 折算 viewBox
|
|
40
42
|
*/
|
|
41
43
|
var compileToScene = (ir, options = {}) => {
|
|
42
44
|
const measureText = options.measureText ?? require_text_metrics.fallbackMeasurer;
|
|
43
45
|
const viewBoxPadding = options.padding ?? 10;
|
|
44
46
|
const round = require_precision.makeRound(options.precision ?? 2);
|
|
45
47
|
const nodeDistance = options.nodeDistance;
|
|
48
|
+
const onWarn = options.onWarn ?? defaultWarnDispatcher;
|
|
46
49
|
const primitives = [];
|
|
47
50
|
const nodeIndex = /* @__PURE__ */ new Map();
|
|
48
51
|
const allPoints = [];
|
|
49
|
-
for (
|
|
50
|
-
const
|
|
51
|
-
if (child.
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
52
|
+
for (let i = 0; i < ir.children.length; i++) {
|
|
53
|
+
const child = ir.children[i];
|
|
54
|
+
if (child.type === "node") {
|
|
55
|
+
const layout = require_node.layoutNode(child, measureText, nodeIndex, nodeDistance);
|
|
56
|
+
if (child.id) nodeIndex.set(child.id, layout);
|
|
57
|
+
for (const prim of require_node.emitNodePrimitives(layout, round)) primitives.push(prim);
|
|
58
|
+
allPoints.push(require_rect.rect.anchor(layout.rect, "north-west"), require_rect.rect.anchor(layout.rect, "north-east"), require_rect.rect.anchor(layout.rect, "south-west"), require_rect.rect.anchor(layout.rect, "south-east"));
|
|
59
|
+
} else if (child.type === "coordinate") {
|
|
60
|
+
const center = require_position.resolvePosition(child.position, nodeIndex, nodeDistance);
|
|
61
|
+
if (!center) {
|
|
62
|
+
onWarn({
|
|
63
|
+
code: "POLAR_ORIGIN_UNRESOLVED",
|
|
64
|
+
message: `Cannot resolve position for coordinate '${child.id}'; polar.origin or at.of may reference an undefined node`,
|
|
65
|
+
path: `children[${i}].coordinate.position`
|
|
66
|
+
});
|
|
67
|
+
throw new Error(`Cannot resolve position for coordinate ${child.id}; polar.origin or at.of may reference an undefined node`);
|
|
68
|
+
}
|
|
69
|
+
nodeIndex.set(child.id, coordinateAsLayout(child.id, center));
|
|
70
|
+
}
|
|
58
71
|
}
|
|
59
|
-
for (
|
|
60
|
-
const
|
|
61
|
-
if (
|
|
62
|
-
|
|
63
|
-
|
|
72
|
+
for (let i = 0; i < ir.children.length; i++) {
|
|
73
|
+
const child = ir.children[i];
|
|
74
|
+
if (child.type === "path") {
|
|
75
|
+
const result = require_index.emitPathPrimitive(child, nodeIndex, round, measureText, {
|
|
76
|
+
onWarn,
|
|
77
|
+
irPath: `children[${i}].path`
|
|
78
|
+
});
|
|
79
|
+
if (result) {
|
|
80
|
+
for (const prim of result.primitives) primitives.push(prim);
|
|
81
|
+
for (const p of result.points) allPoints.push(p);
|
|
82
|
+
}
|
|
64
83
|
}
|
|
65
84
|
}
|
|
66
85
|
return {
|
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
import { IR } from '../ir';
|
|
2
2
|
import { Scene } from '../primitive';
|
|
3
3
|
import { TextMeasurer } from './text-metrics';
|
|
4
|
+
/** 编译期警告:path / position 解析失败时通过 `CompileOptions.onWarn` 发出,不影响编译产物 */
|
|
5
|
+
export type CompileWarning = {
|
|
6
|
+
/**
|
|
7
|
+
* 警告类型代码(机器可读)
|
|
8
|
+
* @description 用户可按 code 分支处理;未来 alpha 加新 code 不破坏调用方
|
|
9
|
+
*/
|
|
10
|
+
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' | (string & {});
|
|
11
|
+
/** 人类可读消息(英文) */
|
|
12
|
+
message: string;
|
|
13
|
+
/** IR locator 路径(jq-like,如 `'children[3].path.children[1].to'`) */
|
|
14
|
+
path: string;
|
|
15
|
+
};
|
|
4
16
|
/** compileToScene 的可选参数 */
|
|
5
17
|
export type CompileOptions = {
|
|
6
18
|
/** 注入文字度量函数;不传则用 fallback(不准但可跑) */
|
|
@@ -8,26 +20,24 @@ export type CompileOptions = {
|
|
|
8
20
|
/** viewBox 周围的留白(user units),默认 10 */
|
|
9
21
|
padding?: number;
|
|
10
22
|
/**
|
|
11
|
-
* 输出坐标的小数位精度;默认 2
|
|
12
|
-
*
|
|
13
|
-
* 内部几何计算保持完整 double 精度,避免误差累积。
|
|
23
|
+
* 输出坐标的小数位精度;默认 2
|
|
24
|
+
* @description 仅作用于 Scene primitive / path d / viewBox;内部几何计算保持完整 double 精度
|
|
14
25
|
*/
|
|
15
26
|
precision?: number;
|
|
16
27
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* 未配则回退到 1。
|
|
28
|
+
* 相对定位的默认距离(对应 TikZ `node distance`,user units)
|
|
29
|
+
* @description `Node.position` 为 `{ direction, of }` 且未自带 `distance` 时取此值;未配回退到 1
|
|
20
30
|
*/
|
|
21
31
|
nodeDistance?: number;
|
|
32
|
+
/**
|
|
33
|
+
* 编译期警告收集器
|
|
34
|
+
* @description path / position 解析失败时按 IR locator + code + message 同步触发;不传时 dev 模式(`process.env.NODE_ENV !== 'production'`)默认 `console.warn`、生产静默
|
|
35
|
+
*/
|
|
36
|
+
onWarn?: (warning: CompileWarning) => void;
|
|
22
37
|
};
|
|
23
38
|
/**
|
|
24
|
-
* IR → Scene
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* 流程:
|
|
28
|
-
* 1. Pass 1:按 IR children 源码顺序处理 Node——计算 layout、注册 nodeIndex、发出 RectPrim/TextPrim、累积 bbox 角点
|
|
29
|
-
* 2. Pass 2:处理 Path——解析每个 step 端点(节点 ref 走 boundaryPoint,其他走 resolvePosition),写 d 字符串
|
|
30
|
-
* 3. 末端用 computeViewBox 折算最终 viewBox(按 precision 四舍五入)
|
|
39
|
+
* IR → Scene 纯函数转换,所有 adapter 共享
|
|
40
|
+
* @description Pass 1 处理 Node/coordinate 并注册 nodeIndex、发 primitive、累积 bbox;Pass 2 解析 Path 端点写 d 字符串;末端按 precision 折算 viewBox
|
|
31
41
|
*/
|
|
32
42
|
export declare const compileToScene: (ir: IR, options?: CompileOptions) => Scene;
|
|
33
43
|
//# sourceMappingURL=compile.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../../src/compile/compile.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAc,MAAM,OAAO,CAAC;AAC5C,OAAO,KAAK,EAAE,KAAK,EAAkB,MAAM,cAAc,CAAC;AAK1D,OAAO,EAAE,KAAK,YAAY,EAAoB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../../src/compile/compile.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAc,MAAM,OAAO,CAAC;AAC5C,OAAO,KAAK,EAAE,KAAK,EAAkB,MAAM,cAAc,CAAC;AAK1D,OAAO,EAAE,KAAK,YAAY,EAAoB,MAAM,gBAAgB,CAAC;AAuBrE,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,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,sCAAsC;IACtC,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;CAC5C,CAAC;AAWF;;;GAGG;AACH,eAAO,MAAM,cAAc,GAAI,IAAI,EAAE,EAAE,UAAS,cAAmB,KAAG,KAkErE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/compile/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,eAAe,CAAC;AAC9B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/compile/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC"}
|