@retikz/core 0.1.0-alpha.0 → 0.1.0-alpha.2
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/index.d.ts +1 -0
- package/dist/es/compile/index.d.ts.map +1 -1
- package/dist/es/compile/node.d.ts +73 -22
- package/dist/es/compile/node.d.ts.map +1 -1
- package/dist/es/compile/node.js +276 -52
- package/dist/es/compile/parseTarget.d.ts +25 -0
- package/dist/es/compile/parseTarget.d.ts.map +1 -0
- package/dist/es/compile/parseTarget.js +48 -0
- package/dist/es/compile/path.d.ts +17 -7
- package/dist/es/compile/path.d.ts.map +1 -1
- package/dist/es/compile/path.js +276 -33
- package/dist/es/compile/text-metrics.d.ts +2 -2
- package/dist/es/compile/text-metrics.d.ts.map +1 -1
- package/dist/es/geometry/circle.d.ts +32 -0
- package/dist/es/geometry/circle.d.ts.map +1 -0
- package/dist/es/geometry/circle.js +79 -0
- package/dist/es/geometry/diamond.d.ts +44 -0
- package/dist/es/geometry/diamond.d.ts.map +1 -0
- package/dist/es/geometry/diamond.js +87 -0
- package/dist/es/geometry/ellipse.d.ts +38 -0
- package/dist/es/geometry/ellipse.d.ts.map +1 -0
- package/dist/es/geometry/ellipse.js +86 -0
- package/dist/es/geometry/index.d.ts +3 -0
- package/dist/es/geometry/index.d.ts.map +1 -1
- package/dist/es/index.d.ts +9 -7
- package/dist/es/index.d.ts.map +1 -1
- package/dist/es/index.js +8 -4
- package/dist/es/ir/node.d.ts +319 -7
- package/dist/es/ir/node.d.ts.map +1 -1
- package/dist/es/ir/node.js +96 -8
- package/dist/es/ir/path/arrow.d.ts +26 -0
- package/dist/es/ir/path/arrow.d.ts.map +1 -0
- package/dist/es/ir/path/arrow.js +25 -0
- package/dist/es/ir/path/index.d.ts +1 -0
- package/dist/es/ir/path/index.d.ts.map +1 -1
- package/dist/es/ir/path/path.d.ts +60 -0
- package/dist/es/ir/path/path.d.ts.map +1 -1
- package/dist/es/ir/path/path.js +10 -0
- package/dist/es/ir/path/step.d.ts +56 -2
- package/dist/es/ir/path/step.d.ts.map +1 -1
- package/dist/es/ir/path/step.js +17 -2
- package/dist/es/ir/scene.d.ts +538 -16
- package/dist/es/ir/scene.d.ts.map +1 -1
- package/dist/es/parsers/parseWay.d.ts +56 -10
- package/dist/es/parsers/parseWay.d.ts.map +1 -1
- package/dist/es/parsers/parseWay.js +68 -6
- package/dist/es/primitive/ellipse.d.ts +34 -0
- package/dist/es/primitive/ellipse.d.ts.map +1 -0
- package/dist/es/primitive/index.d.ts +1 -0
- package/dist/es/primitive/index.d.ts.map +1 -1
- package/dist/es/primitive/path.d.ts +11 -0
- package/dist/es/primitive/path.d.ts.map +1 -1
- package/dist/es/primitive/rect.d.ts +2 -0
- package/dist/es/primitive/rect.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/es/primitive/text.d.ts +43 -13
- package/dist/es/primitive/text.d.ts.map +1 -1
- package/dist/es/types.d.ts +3 -0
- package/dist/es/types.d.ts.map +1 -0
- package/dist/lib/compile/index.d.ts +1 -0
- package/dist/lib/compile/index.d.ts.map +1 -1
- package/dist/lib/compile/node.cjs +278 -52
- package/dist/lib/compile/node.d.ts +73 -22
- package/dist/lib/compile/node.d.ts.map +1 -1
- package/dist/lib/compile/parseTarget.cjs +48 -0
- package/dist/lib/compile/parseTarget.d.ts +25 -0
- package/dist/lib/compile/parseTarget.d.ts.map +1 -0
- package/dist/lib/compile/path.cjs +275 -32
- package/dist/lib/compile/path.d.ts +17 -7
- package/dist/lib/compile/path.d.ts.map +1 -1
- package/dist/lib/compile/text-metrics.d.ts +2 -2
- package/dist/lib/compile/text-metrics.d.ts.map +1 -1
- package/dist/lib/geometry/circle.cjs +79 -0
- package/dist/lib/geometry/circle.d.ts +32 -0
- package/dist/lib/geometry/circle.d.ts.map +1 -0
- package/dist/lib/geometry/diamond.cjs +87 -0
- package/dist/lib/geometry/diamond.d.ts +44 -0
- package/dist/lib/geometry/diamond.d.ts.map +1 -0
- package/dist/lib/geometry/ellipse.cjs +86 -0
- package/dist/lib/geometry/ellipse.d.ts +38 -0
- package/dist/lib/geometry/ellipse.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/index.cjs +16 -0
- package/dist/lib/index.d.ts +9 -7
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/ir/node.cjs +100 -7
- package/dist/lib/ir/node.d.ts +319 -7
- package/dist/lib/ir/node.d.ts.map +1 -1
- package/dist/lib/ir/path/arrow.cjs +25 -0
- package/dist/lib/ir/path/arrow.d.ts +26 -0
- package/dist/lib/ir/path/arrow.d.ts.map +1 -0
- package/dist/lib/ir/path/index.d.ts +1 -0
- package/dist/lib/ir/path/index.d.ts.map +1 -1
- package/dist/lib/ir/path/path.cjs +10 -0
- package/dist/lib/ir/path/path.d.ts +60 -0
- package/dist/lib/ir/path/path.d.ts.map +1 -1
- package/dist/lib/ir/path/step.cjs +18 -1
- package/dist/lib/ir/path/step.d.ts +56 -2
- package/dist/lib/ir/path/step.d.ts.map +1 -1
- package/dist/lib/ir/scene.d.ts +538 -16
- package/dist/lib/ir/scene.d.ts.map +1 -1
- package/dist/lib/parsers/parseWay.cjs +68 -5
- package/dist/lib/parsers/parseWay.d.ts +56 -10
- package/dist/lib/parsers/parseWay.d.ts.map +1 -1
- package/dist/lib/primitive/ellipse.d.ts +34 -0
- package/dist/lib/primitive/ellipse.d.ts.map +1 -0
- package/dist/lib/primitive/index.d.ts +1 -0
- package/dist/lib/primitive/index.d.ts.map +1 -1
- package/dist/lib/primitive/path.d.ts +11 -0
- package/dist/lib/primitive/path.d.ts.map +1 -1
- package/dist/lib/primitive/rect.d.ts +2 -0
- package/dist/lib/primitive/rect.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/dist/lib/primitive/text.d.ts +43 -13
- package/dist/lib/primitive/text.d.ts.map +1 -1
- package/dist/lib/types.d.ts +3 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
//#region src/geometry/ellipse.ts
|
|
2
|
+
var SQRT_HALF = Math.SQRT1_2;
|
|
3
|
+
var localToWorld = (e, local) => {
|
|
4
|
+
const angle = e.rotate ?? 0;
|
|
5
|
+
if (angle === 0) return [e.x + local[0], e.y + local[1]];
|
|
6
|
+
const cos = Math.cos(angle);
|
|
7
|
+
const sin = Math.sin(angle);
|
|
8
|
+
return [e.x + local[0] * cos - local[1] * sin, e.y + local[0] * sin + local[1] * cos];
|
|
9
|
+
};
|
|
10
|
+
var worldToLocal = (e, world) => {
|
|
11
|
+
const tx = world[0] - e.x;
|
|
12
|
+
const ty = world[1] - e.y;
|
|
13
|
+
const angle = e.rotate ?? 0;
|
|
14
|
+
if (angle === 0) return [tx, ty];
|
|
15
|
+
const cos = Math.cos(angle);
|
|
16
|
+
const sin = Math.sin(angle);
|
|
17
|
+
return [tx * cos + ty * sin, -tx * sin + ty * cos];
|
|
18
|
+
};
|
|
19
|
+
/** 椭圆相关基础工具 */
|
|
20
|
+
var ellipse = {
|
|
21
|
+
/** 中心 */
|
|
22
|
+
center: (e) => [e.x, e.y],
|
|
23
|
+
/** 判断点是否在椭圆内(含边界,考虑旋转) */
|
|
24
|
+
contains: (e, p) => {
|
|
25
|
+
const [lx, ly] = worldToLocal(e, p);
|
|
26
|
+
return lx * lx / (e.rx * e.rx) + ly * ly / (e.ry * e.ry) <= 1;
|
|
27
|
+
},
|
|
28
|
+
/**
|
|
29
|
+
* 9 个标准 anchor 的世界坐标。
|
|
30
|
+
* 对角 anchor(NE/NW/SE/SW)取参数曲线 t=π/4 处的点:
|
|
31
|
+
* (rx·cos(π/4), ry·sin(π/4)) = (rx/√2, ry/√2)。
|
|
32
|
+
* 这与 TikZ 椭圆对角 anchor 的"参数等分"约定一致。
|
|
33
|
+
*/
|
|
34
|
+
anchor: (e, name) => {
|
|
35
|
+
let lx = 0;
|
|
36
|
+
let ly = 0;
|
|
37
|
+
switch (name) {
|
|
38
|
+
case "center": break;
|
|
39
|
+
case "north":
|
|
40
|
+
ly = -e.ry;
|
|
41
|
+
break;
|
|
42
|
+
case "south":
|
|
43
|
+
ly = e.ry;
|
|
44
|
+
break;
|
|
45
|
+
case "east":
|
|
46
|
+
lx = e.rx;
|
|
47
|
+
break;
|
|
48
|
+
case "west":
|
|
49
|
+
lx = -e.rx;
|
|
50
|
+
break;
|
|
51
|
+
case "north-east":
|
|
52
|
+
lx = e.rx * SQRT_HALF;
|
|
53
|
+
ly = -e.ry * SQRT_HALF;
|
|
54
|
+
break;
|
|
55
|
+
case "north-west":
|
|
56
|
+
lx = -e.rx * SQRT_HALF;
|
|
57
|
+
ly = -e.ry * SQRT_HALF;
|
|
58
|
+
break;
|
|
59
|
+
case "south-east":
|
|
60
|
+
lx = e.rx * SQRT_HALF;
|
|
61
|
+
ly = e.ry * SQRT_HALF;
|
|
62
|
+
break;
|
|
63
|
+
case "south-west":
|
|
64
|
+
lx = -e.rx * SQRT_HALF;
|
|
65
|
+
ly = e.ry * SQRT_HALF;
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
return localToWorld(e, [lx, ly]);
|
|
69
|
+
},
|
|
70
|
+
/**
|
|
71
|
+
* 从中心向 toward 方向画射线,求与椭圆的交点。
|
|
72
|
+
* 椭圆方程:(x/rx)² + (y/ry)² = 1。
|
|
73
|
+
* 沿方向 (lx, ly) 缩放 t 倍命中:t² × ((lx/rx)² + (ly/ry)²) = 1
|
|
74
|
+
* → t = 1 / √((lx/rx)² + (ly/ry)²)。
|
|
75
|
+
*/
|
|
76
|
+
boundaryPoint: (e, toward) => {
|
|
77
|
+
const [lx, ly] = worldToLocal(e, toward);
|
|
78
|
+
if (lx === 0 && ly === 0) return [e.x, e.y];
|
|
79
|
+
const a = lx / e.rx;
|
|
80
|
+
const b = ly / e.ry;
|
|
81
|
+
const t = 1 / Math.sqrt(a * a + b * b);
|
|
82
|
+
return localToWorld(e, [lx * t, ly * t]);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
//#endregion
|
|
86
|
+
exports.ellipse = ellipse;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Position } from './point';
|
|
2
|
+
/** 椭圆:几何中心 (x, y) + 半长轴 rx / 半短轴 ry + 可选旋转(弧度) */
|
|
3
|
+
export type Ellipse = {
|
|
4
|
+
/** 中心横坐标 */
|
|
5
|
+
x: number;
|
|
6
|
+
/** 中心纵坐标 */
|
|
7
|
+
y: number;
|
|
8
|
+
/** 半长轴(沿本地 +x 方向) */
|
|
9
|
+
rx: number;
|
|
10
|
+
/** 半短轴(沿本地 +y 方向) */
|
|
11
|
+
ry: number;
|
|
12
|
+
/** 绕几何中心旋转弧度;省略或 0 表示不旋转 */
|
|
13
|
+
rotate?: number;
|
|
14
|
+
};
|
|
15
|
+
/** 椭圆 9 个标准 anchor 名(含义与 RECT_ANCHORS 一致) */
|
|
16
|
+
export type EllipseAnchor = 'center' | 'north' | 'south' | 'east' | 'west' | 'north-east' | 'north-west' | 'south-east' | 'south-west';
|
|
17
|
+
/** 椭圆相关基础工具 */
|
|
18
|
+
export declare const ellipse: {
|
|
19
|
+
/** 中心 */
|
|
20
|
+
center: (e: Ellipse) => Position;
|
|
21
|
+
/** 判断点是否在椭圆内(含边界,考虑旋转) */
|
|
22
|
+
contains: (e: Ellipse, p: Position) => boolean;
|
|
23
|
+
/**
|
|
24
|
+
* 9 个标准 anchor 的世界坐标。
|
|
25
|
+
* 对角 anchor(NE/NW/SE/SW)取参数曲线 t=π/4 处的点:
|
|
26
|
+
* (rx·cos(π/4), ry·sin(π/4)) = (rx/√2, ry/√2)。
|
|
27
|
+
* 这与 TikZ 椭圆对角 anchor 的"参数等分"约定一致。
|
|
28
|
+
*/
|
|
29
|
+
anchor: (e: Ellipse, name: EllipseAnchor) => Position;
|
|
30
|
+
/**
|
|
31
|
+
* 从中心向 toward 方向画射线,求与椭圆的交点。
|
|
32
|
+
* 椭圆方程:(x/rx)² + (y/ry)² = 1。
|
|
33
|
+
* 沿方向 (lx, ly) 缩放 t 倍命中:t² × ((lx/rx)² + (ly/ry)²) = 1
|
|
34
|
+
* → t = 1 / √((lx/rx)² + (ly/ry)²)。
|
|
35
|
+
*/
|
|
36
|
+
boundaryPoint: (e: Ellipse, toward: Position) => Position;
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=ellipse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ellipse.d.ts","sourceRoot":"","sources":["../../../src/geometry/ellipse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExC,kDAAkD;AAClD,MAAM,MAAM,OAAO,GAAG;IACpB,YAAY;IACZ,CAAC,EAAE,MAAM,CAAC;IACV,YAAY;IACZ,CAAC,EAAE,MAAM,CAAC;IACV,qBAAqB;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,qBAAqB;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,4BAA4B;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAIF,6CAA6C;AAC7C,MAAM,MAAM,aAAa,GACrB,QAAQ,GACR,OAAO,GACP,OAAO,GACP,MAAM,GACN,MAAM,GACN,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,CAAC;AAoBjB,eAAe;AACf,eAAO,MAAM,OAAO;IAClB,SAAS;gBACG,OAAO,KAAG,QAAQ;IAC9B,0BAA0B;kBACZ,OAAO,KAAK,QAAQ,KAAG,OAAO;IAI5C;;;;;OAKG;gBACS,OAAO,QAAQ,aAAa,KAAG,QAAQ;IAqCnD;;;;;OAKG;uBACgB,OAAO,UAAU,QAAQ,KAAG,QAAQ;CAQxD,CAAC"}
|
|
@@ -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,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"}
|
package/dist/lib/index.cjs
CHANGED
|
@@ -1,22 +1,35 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_position = require("./ir/position/position.cjs");
|
|
3
3
|
const require_polar_position = require("./ir/position/polar-position.cjs");
|
|
4
|
+
const require_arrow = require("./ir/path/arrow.cjs");
|
|
4
5
|
const require_target = require("./ir/path/target.cjs");
|
|
5
6
|
const require_step = require("./ir/path/step.cjs");
|
|
6
7
|
const require_path = require("./ir/path/path.cjs");
|
|
7
8
|
const require_node = require("./ir/node.cjs");
|
|
8
9
|
const require_scene = require("./ir/scene.cjs");
|
|
9
10
|
const require_rect = require("./geometry/rect.cjs");
|
|
11
|
+
const require_circle = require("./geometry/circle.cjs");
|
|
12
|
+
const require_diamond = require("./geometry/diamond.cjs");
|
|
13
|
+
const require_ellipse = require("./geometry/ellipse.cjs");
|
|
10
14
|
const require_text_metrics = require("./compile/text-metrics.cjs");
|
|
11
15
|
const require_compile = require("./compile/compile.cjs");
|
|
12
16
|
const require_parseWay = require("./parsers/parseWay.cjs");
|
|
13
17
|
const require_polar = require("./geometry/polar.cjs");
|
|
14
18
|
const require_point = require("./geometry/point.cjs");
|
|
19
|
+
exports.ARROW_SHAPES = require_arrow.ARROW_SHAPES;
|
|
15
20
|
exports.CURRENT_IR_VERSION = require_scene.CURRENT_IR_VERSION;
|
|
16
21
|
exports.ChildSchema = require_scene.ChildSchema;
|
|
22
|
+
exports.CycleStepSchema = require_step.CycleStepSchema;
|
|
23
|
+
exports.DrawWay = require_parseWay.DrawWay;
|
|
24
|
+
exports.FoldStepSchema = require_step.FoldStepSchema;
|
|
25
|
+
exports.FontSchema = require_node.FontSchema;
|
|
26
|
+
exports.LineSpecSchema = require_node.LineSpecSchema;
|
|
17
27
|
exports.LineStepSchema = require_step.LineStepSchema;
|
|
18
28
|
exports.MoveStepSchema = require_step.MoveStepSchema;
|
|
29
|
+
exports.NODE_SHAPES = require_node.NODE_SHAPES;
|
|
30
|
+
exports.NODE_TEXT_ALIGNS = require_node.NODE_TEXT_ALIGNS;
|
|
19
31
|
exports.NodeSchema = require_node.NodeSchema;
|
|
32
|
+
exports.NodeTextSchema = require_node.NodeTextSchema;
|
|
20
33
|
exports.PathSchema = require_path.PathSchema;
|
|
21
34
|
exports.PolarPositionSchema = require_polar_position.PolarPositionSchema;
|
|
22
35
|
exports.PositionSchema = require_position.PositionSchema;
|
|
@@ -24,7 +37,10 @@ exports.RECT_ANCHORS = require_rect.RECT_ANCHORS;
|
|
|
24
37
|
exports.SceneSchema = require_scene.SceneSchema;
|
|
25
38
|
exports.StepSchema = require_step.StepSchema;
|
|
26
39
|
exports.TargetSchema = require_target.TargetSchema;
|
|
40
|
+
exports.circle = require_circle.circle;
|
|
27
41
|
exports.compileToScene = require_compile.compileToScene;
|
|
42
|
+
exports.diamond = require_diamond.diamond;
|
|
43
|
+
exports.ellipse = require_ellipse.ellipse;
|
|
28
44
|
exports.fallbackMeasurer = require_text_metrics.fallbackMeasurer;
|
|
29
45
|
exports.parseWay = require_parseWay.parseWay;
|
|
30
46
|
exports.point = require_point.point;
|
package/dist/lib/index.d.ts
CHANGED
|
@@ -6,13 +6,15 @@
|
|
|
6
6
|
*
|
|
7
7
|
* 本包零 React、零 DOM 依赖。
|
|
8
8
|
*/
|
|
9
|
-
export { PositionSchema, PolarPositionSchema, TargetSchema, MoveStepSchema, LineStepSchema, StepSchema, NodeSchema, PathSchema, ChildSchema, SceneSchema, CURRENT_IR_VERSION, } from './ir';
|
|
10
|
-
export type { IRPosition, IRTarget, IRMoveStep, IRLineStep, IRStep, IRNode, IRPath, IRChild, IR, } from './ir';
|
|
11
|
-
export
|
|
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';
|
|
11
|
+
export { ARROW_SHAPES, NODE_SHAPES, NODE_TEXT_ALIGNS } from './ir';
|
|
12
|
+
export type { ScenePrimitive, RectPrim, EllipsePrim, TextPrim, TextLine, PathPrim, GroupPrim, ViewBox, Scene, } from './primitive';
|
|
12
13
|
export type { FontSpec, TextMetrics, TextMeasurer, CompileOptions, } from './compile';
|
|
13
14
|
export { fallbackMeasurer, compileToScene } from './compile';
|
|
14
|
-
export type { WayItem, WayDSL } from './parsers';
|
|
15
|
-
export { parseWay } from './parsers';
|
|
16
|
-
export type { Position, Rect, RectAnchor, PolarPosition } from './geometry';
|
|
17
|
-
export { point, rect, RECT_ANCHORS, polar } from './geometry';
|
|
15
|
+
export type { WayItem, WayDSL, WayCycle, WayVia } from './parsers';
|
|
16
|
+
export { parseWay, DrawWay } from './parsers';
|
|
17
|
+
export type { Position, Rect, RectAnchor, Circle, CircleAnchor, Ellipse, EllipseAnchor, Diamond, DiamondAnchor, PolarPosition, } from './geometry';
|
|
18
|
+
export { point, rect, circle, ellipse, diamond, RECT_ANCHORS, polar } from './geometry';
|
|
19
|
+
export type { ValueOf } from './types';
|
|
18
20
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/lib/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,UAAU,EACV,UAAU,EACV,UAAU,EACV,WAAW,EACX,WAAW,EACX,kBAAkB,GACnB,MAAM,MAAM,CAAC;AACd,YAAY,EACV,UAAU,EACV,QAAQ,EACR,UAAU,EACV,UAAU,EACV,MAAM,EACN,MAAM,EACN,MAAM,EACN,OAAO,EACP,EAAE,
|
|
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,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAI9C,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/lib/ir/node.cjs
CHANGED
|
@@ -2,18 +2,111 @@ const require_position = require("./position/position.cjs");
|
|
|
2
2
|
const require_polar_position = require("./position/polar-position.cjs");
|
|
3
3
|
let zod = require("zod");
|
|
4
4
|
//#region src/ir/node.ts
|
|
5
|
+
/**
|
|
6
|
+
* 节点形状常量。值是 IR 中 `shape` 字段的字面字符串;
|
|
7
|
+
* 用 const + ValueOf 派生(不用 TS enum)。
|
|
8
|
+
*
|
|
9
|
+
* - `rectangle`:矩形(默认;UML 类、流程图常规节点)
|
|
10
|
+
* - `circle`:圆形(流程图起止、状态机)
|
|
11
|
+
* - `ellipse`:椭圆(状态机、集合图)
|
|
12
|
+
* - `diamond`:菱形(流程图判定)
|
|
13
|
+
*
|
|
14
|
+
* 每个 shape 的几何语义:node 的视觉边界包住"text 矩形 + padding"——
|
|
15
|
+
* - rectangle: 视觉 rect = text rect
|
|
16
|
+
* - circle: 外接圆,r = √(innerHalfW² + innerHalfH²)
|
|
17
|
+
* - ellipse: 外接椭圆,rx = innerHalfW×√2、ry = innerHalfH×√2
|
|
18
|
+
* - diamond: 外接菱形,halfA = 2×innerHalfW、halfB = 2×innerHalfH
|
|
19
|
+
*/
|
|
20
|
+
var NODE_SHAPES = {
|
|
21
|
+
rectangle: "rectangle",
|
|
22
|
+
circle: "circle",
|
|
23
|
+
ellipse: "ellipse",
|
|
24
|
+
diamond: "diamond"
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* 节点字体规格——family / size / weight / style 全部可选;
|
|
28
|
+
* 单字段透传到 SVG `<text>` 的 `font-*` 属性 / `font-size`。
|
|
29
|
+
*
|
|
30
|
+
* 取代 alpha.1 的标量 `fontSize` 字段(已删)。
|
|
31
|
+
*/
|
|
32
|
+
var FontSchema = zod.z.object({
|
|
33
|
+
family: zod.z.string().optional().describe("CSS font-family string, e.g. \"serif\", \"monospace\", \"Inter, sans-serif\""),
|
|
34
|
+
size: zod.z.number().positive().optional().describe("Font size in user units; falls back to the renderer default when omitted"),
|
|
35
|
+
weight: zod.z.union([zod.z.enum(["normal", "bold"]), zod.z.number()]).optional().describe("CSS font-weight: keyword `normal` / `bold` or numeric 100..900"),
|
|
36
|
+
style: zod.z.enum([
|
|
37
|
+
"normal",
|
|
38
|
+
"italic",
|
|
39
|
+
"oblique"
|
|
40
|
+
]).optional().describe("CSS font-style")
|
|
41
|
+
}).describe("Font properties for the node text label; all fields optional, nested object form (replaces the alpha.1 `fontSize` scalar).");
|
|
42
|
+
/**
|
|
43
|
+
* 单行文本规格——纯字符串走块级默认样式;对象形式可对该行覆盖 fill / opacity / font。
|
|
44
|
+
*
|
|
45
|
+
* 行级覆盖只生效于本行的 `<tspan>`:
|
|
46
|
+
* - `fill`:仅这一行颜色
|
|
47
|
+
* - `opacity`:仅这一行 0~1 透明度
|
|
48
|
+
* - `font`:family / size / weight / style 任意子集;未填字段继承块级 font
|
|
49
|
+
*
|
|
50
|
+
* 块级 `align` / `lineHeight` 不可被行覆盖(多行块整体属性)。
|
|
51
|
+
*/
|
|
52
|
+
var LineSpecSchema = zod.z.union([zod.z.string(), zod.z.object({
|
|
53
|
+
text: zod.z.string().describe("Line content"),
|
|
54
|
+
fill: zod.z.string().optional().describe("Per-line text color; overrides block default"),
|
|
55
|
+
opacity: zod.z.number().min(0).max(1).optional().describe("Per-line opacity 0..1"),
|
|
56
|
+
font: FontSchema.optional().describe("Per-line font overrides; missing fields inherit from block-level `font`")
|
|
57
|
+
})]).describe("Single line of text: bare string for default styling, or an object with per-line `fill` / `opacity` / `font` overrides.");
|
|
58
|
+
/**
|
|
59
|
+
* 节点文本——单行字符串或非空多行数组(每元素一个 LineSpec):
|
|
60
|
+
* - `'Hello'` 等价于 `[{ text: 'Hello' }]`,按一行渲染
|
|
61
|
+
* - `['Line 1', 'Line 2']` 两行无样式覆盖
|
|
62
|
+
* - `[{ text: 'Heading', fill: 'red', font: { weight: 'bold' } }, 'body']` 混排
|
|
63
|
+
*
|
|
64
|
+
* 选 `Array<LineSpec>` 而非 `'\n'` 字符串:JSON 友好(无 escape);行级覆盖天然落字段。
|
|
65
|
+
*/
|
|
66
|
+
var NodeTextSchema = zod.z.union([zod.z.string(), zod.z.array(LineSpecSchema).min(1)]).describe("Text label rendered inside the node: a single string for one line, or a non-empty array of line specs (string for default, object for per-line overrides).");
|
|
67
|
+
/** 节点文本对齐(多行内文本对齐)——TikZ `align=` 同义词 */
|
|
68
|
+
var NODE_TEXT_ALIGNS = {
|
|
69
|
+
left: "left",
|
|
70
|
+
center: "center",
|
|
71
|
+
right: "right"
|
|
72
|
+
};
|
|
5
73
|
var NodeSchema = zod.z.object({
|
|
6
74
|
type: zod.z.literal("node").describe("Discriminator marking this child as a node"),
|
|
7
75
|
id: zod.z.string().min(1).optional().describe("Optional unique id; required if any path needs to reference this node by string"),
|
|
76
|
+
shape: zod.z.nativeEnum(NODE_SHAPES).optional().describe("Node visual shape; defaults to `rectangle`. The boundary fully contains text + padding (circumscribed for circle / ellipse / diamond)."),
|
|
8
77
|
position: zod.z.union([require_position.PositionSchema, require_polar_position.PolarPositionSchema]).describe("Center point of the node content box; Cartesian [x, y] or polar (resolved at compile time)"),
|
|
9
78
|
rotate: zod.z.number().optional().describe("Rotation in degrees around the node center; positive = clockwise (matches TikZ rotate=...)"),
|
|
10
|
-
text:
|
|
11
|
-
|
|
12
|
-
|
|
79
|
+
text: NodeTextSchema.optional(),
|
|
80
|
+
align: zod.z.nativeEnum(NODE_TEXT_ALIGNS).optional().describe("Multi-line text alignment within the text block; `left` / `center` / `right`. Defaults to `center` (matches TikZ)."),
|
|
81
|
+
lineHeight: zod.z.number().positive().optional().describe("Line height in user units; falls back to `font.size × 1.2` when omitted."),
|
|
82
|
+
fill: zod.z.string().optional().describe("Background color of the node shape; any CSS color (e.g. \"lightblue\", \"#fafafa\", \"rgba(...)\")"),
|
|
83
|
+
fillOpacity: zod.z.number().min(0).max(1).optional().describe("Fill opacity 0..1; affects only the shape fill, leaves stroke / text alone."),
|
|
84
|
+
stroke: zod.z.string().optional().describe("Border color of the node shape; any CSS color. Defaults to currentColor when omitted"),
|
|
85
|
+
drawOpacity: zod.z.number().min(0).max(1).optional().describe("Stroke opacity 0..1 (TikZ `draw opacity`); affects only the border."),
|
|
13
86
|
strokeWidth: zod.z.number().optional().describe("Border width in user units; defaults to 1 when omitted"),
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
87
|
+
dashed: zod.z.boolean().optional().describe("Border style preset: dashed line (TikZ `dashed`); compiled to a default dash pattern. `dashArray` takes precedence."),
|
|
88
|
+
dotted: zod.z.boolean().optional().describe("Border style preset: dotted line (TikZ `dotted`); compiled to a default dot pattern. `dashArray` and `dashed` take precedence."),
|
|
89
|
+
dashArray: zod.z.string().optional().describe("Explicit SVG stroke-dasharray value (e.g. \"4 2\"); overrides `dashed` / `dotted`."),
|
|
90
|
+
roundedCorners: zod.z.number().nonnegative().optional().describe("Corner radius in user units; only effective on `rectangle` shape (rx / ry on `<rect>`)."),
|
|
91
|
+
minimumWidth: zod.z.number().nonnegative().optional().describe("Minimum visual border width in user units; floors the bounding box width."),
|
|
92
|
+
minimumHeight: zod.z.number().nonnegative().optional().describe("Minimum visual border height in user units; floors the bounding box height."),
|
|
93
|
+
minimumSize: zod.z.number().nonnegative().optional().describe("Symmetric alias for `minimumWidth` + `minimumHeight`; axis-specific fields take precedence."),
|
|
94
|
+
scale: zod.z.number().positive().optional().describe("Uniform scale factor; multiplies all node dimensions (border, padding, text, fontSize) at layout time. Affects path attachment positions."),
|
|
95
|
+
xScale: zod.z.number().positive().optional().describe("Horizontal scale factor; overrides `scale` for the X axis."),
|
|
96
|
+
yScale: zod.z.number().positive().optional().describe("Vertical scale factor; overrides `scale` for the Y axis."),
|
|
97
|
+
textColor: zod.z.string().optional().describe("Text label color; any CSS color. Defaults to `currentColor`."),
|
|
98
|
+
opacity: zod.z.number().min(0).max(1).optional().describe("Whole-node opacity 0..1; applies uniformly to shape and text."),
|
|
99
|
+
innerXSep: zod.z.number().nonnegative().optional().describe("Inner horizontal padding from text to border in user units. Falls back to `padding` then default."),
|
|
100
|
+
innerYSep: zod.z.number().nonnegative().optional().describe("Inner vertical padding from text to border in user units. Falls back to `padding` then default."),
|
|
101
|
+
outerSep: zod.z.number().nonnegative().optional().describe("Outer margin from border to path attachment point in user units; does NOT change the visible border. Falls back to `margin`."),
|
|
102
|
+
padding: zod.z.number().nonnegative().optional().describe("Symmetric inner padding (alias for `innerXSep` + `innerYSep`); axis-specific fields take precedence."),
|
|
103
|
+
margin: zod.z.number().nonnegative().optional().describe("Symmetric outer margin (alias for `outerSep`); axis-specific field takes precedence."),
|
|
104
|
+
font: FontSchema.optional().describe("Font spec for the inner text label (family / size / weight / style); all fields optional, all fall back to renderer defaults.")
|
|
105
|
+
}).describe("Node primitive: a positioned, optionally textual shape (rectangle / circle / ellipse / diamond)");
|
|
18
106
|
//#endregion
|
|
107
|
+
exports.FontSchema = FontSchema;
|
|
108
|
+
exports.LineSpecSchema = LineSpecSchema;
|
|
109
|
+
exports.NODE_SHAPES = NODE_SHAPES;
|
|
110
|
+
exports.NODE_TEXT_ALIGNS = NODE_TEXT_ALIGNS;
|
|
19
111
|
exports.NodeSchema = NodeSchema;
|
|
112
|
+
exports.NodeTextSchema = NodeTextSchema;
|