@retikz/core 0.1.0-alpha.0 → 0.1.0-alpha.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/index.d.ts +1 -0
- package/dist/es/compile/index.d.ts.map +1 -1
- package/dist/es/compile/node.d.ts +41 -16
- package/dist/es/compile/node.d.ts.map +1 -1
- package/dist/es/compile/node.js +168 -28
- 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/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 +33 -1
- package/dist/es/ir/node.d.ts.map +1 -1
- package/dist/es/ir/node.js +26 -4
- 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 +162 -0
- 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 +32 -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 +7 -0
- package/dist/es/primitive/path.d.ts.map +1 -1
- package/dist/es/primitive/scene.d.ts +2 -1
- package/dist/es/primitive/scene.d.ts.map +1 -1
- package/dist/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 +170 -28
- package/dist/lib/compile/node.d.ts +41 -16
- 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/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 +12 -0
- package/dist/lib/index.d.ts +9 -7
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/ir/node.cjs +26 -3
- package/dist/lib/ir/node.d.ts +33 -1
- 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 +162 -0
- 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 +32 -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 +7 -0
- package/dist/lib/primitive/path.d.ts.map +1 -1
- package/dist/lib/primitive/scene.d.ts +2 -1
- package/dist/lib/primitive/scene.d.ts.map +1 -1
- package/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
|
+
export { ellipse };
|
|
@@ -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/es/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, PathSchema, ChildSchema, SceneSchema, CURRENT_IR_VERSION, } from './ir';
|
|
10
|
+
export type { IRPosition, IRTarget, IRMoveStep, IRLineStep, IRFoldStep, IRCycleStep, IRStep, IRNode, IRPath, IRChild, IR, ArrowShape, NodeShape, } from './ir';
|
|
11
|
+
export { ARROW_SHAPES, NODE_SHAPES } from './ir';
|
|
12
|
+
export type { ScenePrimitive, RectPrim, EllipsePrim, TextPrim, 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/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,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,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,OAAO,EACP,EAAE,EACF,UAAU,EACV,SAAS,GACV,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AAGjD,YAAY,EACV,cAAc,EACd,QAAQ,EACR,WAAW,EACX,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/es/index.js
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { PositionSchema } from "./ir/position/position.js";
|
|
2
2
|
import { PolarPositionSchema } from "./ir/position/polar-position.js";
|
|
3
|
+
import { ARROW_SHAPES } from "./ir/path/arrow.js";
|
|
3
4
|
import { TargetSchema } from "./ir/path/target.js";
|
|
4
|
-
import { LineStepSchema, MoveStepSchema, StepSchema } from "./ir/path/step.js";
|
|
5
|
+
import { CycleStepSchema, FoldStepSchema, LineStepSchema, MoveStepSchema, StepSchema } from "./ir/path/step.js";
|
|
5
6
|
import { PathSchema } from "./ir/path/path.js";
|
|
6
|
-
import { NodeSchema } from "./ir/node.js";
|
|
7
|
+
import { NODE_SHAPES, NodeSchema } from "./ir/node.js";
|
|
7
8
|
import { CURRENT_IR_VERSION, ChildSchema, SceneSchema } from "./ir/scene.js";
|
|
8
9
|
import { RECT_ANCHORS, rect } from "./geometry/rect.js";
|
|
10
|
+
import { circle } from "./geometry/circle.js";
|
|
11
|
+
import { diamond } from "./geometry/diamond.js";
|
|
12
|
+
import { ellipse } from "./geometry/ellipse.js";
|
|
9
13
|
import { fallbackMeasurer } from "./compile/text-metrics.js";
|
|
10
14
|
import { compileToScene } from "./compile/compile.js";
|
|
11
|
-
import { parseWay } from "./parsers/parseWay.js";
|
|
15
|
+
import { DrawWay, parseWay } from "./parsers/parseWay.js";
|
|
12
16
|
import { polar } from "./geometry/polar.js";
|
|
13
17
|
import { point } from "./geometry/point.js";
|
|
14
|
-
export { CURRENT_IR_VERSION, ChildSchema, LineStepSchema, MoveStepSchema, NodeSchema, PathSchema, PolarPositionSchema, PositionSchema, RECT_ANCHORS, SceneSchema, StepSchema, TargetSchema, compileToScene, fallbackMeasurer, parseWay, point, polar, rect };
|
|
18
|
+
export { ARROW_SHAPES, CURRENT_IR_VERSION, ChildSchema, CycleStepSchema, DrawWay, FoldStepSchema, LineStepSchema, MoveStepSchema, NODE_SHAPES, NodeSchema, PathSchema, PolarPositionSchema, PositionSchema, RECT_ANCHORS, SceneSchema, StepSchema, TargetSchema, circle, compileToScene, diamond, ellipse, fallbackMeasurer, parseWay, point, polar, rect };
|
package/dist/es/ir/node.d.ts
CHANGED
|
@@ -1,7 +1,37 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { ValueOf } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* 节点形状常量。值是 IR 中 `shape` 字段的字面字符串;
|
|
5
|
+
* 用 const + ValueOf 派生(不用 TS enum)。
|
|
6
|
+
*
|
|
7
|
+
* - `rectangle`:矩形(默认;UML 类、流程图常规节点)
|
|
8
|
+
* - `circle`:圆形(流程图起止、状态机)
|
|
9
|
+
* - `ellipse`:椭圆(状态机、集合图)
|
|
10
|
+
* - `diamond`:菱形(流程图判定)
|
|
11
|
+
*
|
|
12
|
+
* 每个 shape 的几何语义:node 的视觉边界包住"text 矩形 + padding"——
|
|
13
|
+
* - rectangle: 视觉 rect = text rect
|
|
14
|
+
* - circle: 外接圆,r = √(innerHalfW² + innerHalfH²)
|
|
15
|
+
* - ellipse: 外接椭圆,rx = innerHalfW×√2、ry = innerHalfH×√2
|
|
16
|
+
* - diamond: 外接菱形,halfA = 2×innerHalfW、halfB = 2×innerHalfH
|
|
17
|
+
*/
|
|
18
|
+
export declare const NODE_SHAPES: {
|
|
19
|
+
readonly rectangle: "rectangle";
|
|
20
|
+
readonly circle: "circle";
|
|
21
|
+
readonly ellipse: "ellipse";
|
|
22
|
+
readonly diamond: "diamond";
|
|
23
|
+
};
|
|
24
|
+
/** 节点形状字面量类型,由 `NODE_SHAPES` 派生 */
|
|
25
|
+
export type NodeShape = ValueOf<typeof NODE_SHAPES>;
|
|
2
26
|
export declare const NodeSchema: z.ZodObject<{
|
|
3
27
|
type: z.ZodLiteral<"node">;
|
|
4
28
|
id: z.ZodOptional<z.ZodString>;
|
|
29
|
+
shape: z.ZodOptional<z.ZodNativeEnum<{
|
|
30
|
+
readonly rectangle: "rectangle";
|
|
31
|
+
readonly circle: "circle";
|
|
32
|
+
readonly ellipse: "ellipse";
|
|
33
|
+
readonly diamond: "diamond";
|
|
34
|
+
}>>;
|
|
5
35
|
position: z.ZodUnion<[z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>, z.ZodType<import('./position').PolarPosition, z.ZodTypeDef, import('./position').PolarPosition>]>;
|
|
6
36
|
rotate: z.ZodOptional<z.ZodNumber>;
|
|
7
37
|
text: z.ZodOptional<z.ZodString>;
|
|
@@ -15,6 +45,7 @@ export declare const NodeSchema: z.ZodObject<{
|
|
|
15
45
|
type: "node";
|
|
16
46
|
position: [number, number] | import('./position').PolarPosition;
|
|
17
47
|
fill?: string | undefined;
|
|
48
|
+
shape?: "diamond" | "circle" | "rectangle" | "ellipse" | undefined;
|
|
18
49
|
stroke?: string | undefined;
|
|
19
50
|
strokeWidth?: number | undefined;
|
|
20
51
|
id?: string | undefined;
|
|
@@ -27,6 +58,7 @@ export declare const NodeSchema: z.ZodObject<{
|
|
|
27
58
|
type: "node";
|
|
28
59
|
position: [number, number] | import('./position').PolarPosition;
|
|
29
60
|
fill?: string | undefined;
|
|
61
|
+
shape?: "diamond" | "circle" | "rectangle" | "ellipse" | undefined;
|
|
30
62
|
stroke?: string | undefined;
|
|
31
63
|
strokeWidth?: number | undefined;
|
|
32
64
|
id?: string | undefined;
|
|
@@ -36,6 +68,6 @@ export declare const NodeSchema: z.ZodObject<{
|
|
|
36
68
|
margin?: number | undefined;
|
|
37
69
|
fontSize?: number | undefined;
|
|
38
70
|
}>;
|
|
39
|
-
/**
|
|
71
|
+
/** 节点:可定位的形状容器(矩形 / 圆 / 椭圆 / 菱形)+ 可选文本标签 */
|
|
40
72
|
export type IRNode = z.infer<typeof NodeSchema>;
|
|
41
73
|
//# sourceMappingURL=node.d.ts.map
|
package/dist/es/ir/node.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../src/ir/node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../src/ir/node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAGxC;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,WAAW;;;;;CAKd,CAAC;AAEX,mCAAmC;AACnC,MAAM,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC;AAEpD,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuEpB,CAAC;AAEJ,4CAA4C;AAC5C,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC"}
|
package/dist/es/ir/node.js
CHANGED
|
@@ -2,18 +2,40 @@ import { PositionSchema } from "./position/position.js";
|
|
|
2
2
|
import { PolarPositionSchema } from "./position/polar-position.js";
|
|
3
3
|
import { z } from "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
|
+
};
|
|
5
26
|
var NodeSchema = z.object({
|
|
6
27
|
type: z.literal("node").describe("Discriminator marking this child as a node"),
|
|
7
28
|
id: z.string().min(1).optional().describe("Optional unique id; required if any path needs to reference this node by string"),
|
|
29
|
+
shape: z.nativeEnum(NODE_SHAPES).optional().describe("Node visual shape; defaults to `rectangle`. The boundary fully contains text + padding (circumscribed for circle / ellipse / diamond)."),
|
|
8
30
|
position: z.union([PositionSchema, PolarPositionSchema]).describe("Center point of the node content box; Cartesian [x, y] or polar (resolved at compile time)"),
|
|
9
31
|
rotate: z.number().optional().describe("Rotation in degrees around the node center; positive = clockwise (matches TikZ rotate=...)"),
|
|
10
32
|
text: z.string().optional().describe("Text label rendered inside the node; omit for an empty node"),
|
|
11
|
-
fill: z.string().optional().describe("Background color of the node
|
|
12
|
-
stroke: z.string().optional().describe("Border color of the node
|
|
33
|
+
fill: z.string().optional().describe("Background color of the node shape; any CSS color (e.g. \"lightblue\", \"#fafafa\", \"rgba(...)\")"),
|
|
34
|
+
stroke: z.string().optional().describe("Border color of the node shape; any CSS color. Defaults to currentColor when omitted"),
|
|
13
35
|
strokeWidth: z.number().optional().describe("Border width in user units; defaults to 1 when omitted"),
|
|
14
36
|
padding: z.number().optional().describe("Inner padding in user units between the text content and the node border"),
|
|
15
37
|
margin: z.number().nonnegative().optional().describe("Outer margin in user units: distance between the visual border and where paths attach. Lines stop this far from the border. Defaults to 0."),
|
|
16
38
|
fontSize: z.number().optional().describe("Text font size in user units; defaults to a fixed size for now (TikZ font sizes will be supported later)")
|
|
17
|
-
}).describe("
|
|
39
|
+
}).describe("Node primitive: a positioned, optionally textual shape (rectangle / circle / ellipse / diamond)");
|
|
18
40
|
//#endregion
|
|
19
|
-
export { NodeSchema };
|
|
41
|
+
export { NODE_SHAPES, NodeSchema };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ValueOf } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* 箭头形状常量。值就是 IR / Scene 中 arrow 字段的字面字符串;
|
|
4
|
+
* 用 const 而不是 TS enum——避免 enum 在数值场景生成 reverse-mapping、
|
|
5
|
+
* 在 string 场景与字面量类型不互通的两个坑。
|
|
6
|
+
*
|
|
7
|
+
* - `normal`:实心三角(默认;最常见)
|
|
8
|
+
* - `open`:空心三角(UML 泛化 / 继承)
|
|
9
|
+
* - `stealth`:尖锐倒钩三角(流图常见、视觉锐利)
|
|
10
|
+
* - `diamond`:实心菱形(UML 组合)
|
|
11
|
+
* - `openDiamond`:空心菱形(UML 聚合)
|
|
12
|
+
* - `circle`:实心圆点(连接点 / dot end)
|
|
13
|
+
* - `openCircle`:空心圆点(白圈 / o-end)
|
|
14
|
+
*/
|
|
15
|
+
export declare const ARROW_SHAPES: {
|
|
16
|
+
readonly normal: "normal";
|
|
17
|
+
readonly open: "open";
|
|
18
|
+
readonly stealth: "stealth";
|
|
19
|
+
readonly diamond: "diamond";
|
|
20
|
+
readonly openDiamond: "openDiamond";
|
|
21
|
+
readonly circle: "circle";
|
|
22
|
+
readonly openCircle: "openCircle";
|
|
23
|
+
};
|
|
24
|
+
/** 箭头形状字面量类型,由 `ARROW_SHAPES` 派生 */
|
|
25
|
+
export type ArrowShape = ValueOf<typeof ARROW_SHAPES>;
|
|
26
|
+
//# sourceMappingURL=arrow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arrow.d.ts","sourceRoot":"","sources":["../../../../src/ir/path/arrow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,YAAY;;;;;;;;CAQf,CAAC;AAEX,oCAAoC;AACpC,MAAM,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,YAAY,CAAC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region src/ir/path/arrow.ts
|
|
2
|
+
/**
|
|
3
|
+
* 箭头形状常量。值就是 IR / Scene 中 arrow 字段的字面字符串;
|
|
4
|
+
* 用 const 而不是 TS enum——避免 enum 在数值场景生成 reverse-mapping、
|
|
5
|
+
* 在 string 场景与字面量类型不互通的两个坑。
|
|
6
|
+
*
|
|
7
|
+
* - `normal`:实心三角(默认;最常见)
|
|
8
|
+
* - `open`:空心三角(UML 泛化 / 继承)
|
|
9
|
+
* - `stealth`:尖锐倒钩三角(流图常见、视觉锐利)
|
|
10
|
+
* - `diamond`:实心菱形(UML 组合)
|
|
11
|
+
* - `openDiamond`:空心菱形(UML 聚合)
|
|
12
|
+
* - `circle`:实心圆点(连接点 / dot end)
|
|
13
|
+
* - `openCircle`:空心圆点(白圈 / o-end)
|
|
14
|
+
*/
|
|
15
|
+
var ARROW_SHAPES = {
|
|
16
|
+
normal: "normal",
|
|
17
|
+
open: "open",
|
|
18
|
+
stealth: "stealth",
|
|
19
|
+
diamond: "diamond",
|
|
20
|
+
openDiamond: "openDiamond",
|
|
21
|
+
circle: "circle",
|
|
22
|
+
openCircle: "openCircle"
|
|
23
|
+
};
|
|
24
|
+
//#endregion
|
|
25
|
+
export { ARROW_SHAPES };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ir/path/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ir/path/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC"}
|
|
@@ -4,6 +4,18 @@ export declare const PathSchema: z.ZodObject<{
|
|
|
4
4
|
stroke: z.ZodOptional<z.ZodString>;
|
|
5
5
|
strokeWidth: z.ZodOptional<z.ZodNumber>;
|
|
6
6
|
strokeDasharray: z.ZodOptional<z.ZodString>;
|
|
7
|
+
arrow: z.ZodOptional<z.ZodEnum<["none", "->", "<-", "<->"]>>;
|
|
8
|
+
arrowShape: z.ZodOptional<z.ZodNativeEnum<{
|
|
9
|
+
readonly normal: "normal";
|
|
10
|
+
readonly open: "open";
|
|
11
|
+
readonly stealth: "stealth";
|
|
12
|
+
readonly diamond: "diamond";
|
|
13
|
+
readonly openDiamond: "openDiamond";
|
|
14
|
+
readonly circle: "circle";
|
|
15
|
+
readonly openCircle: "openCircle";
|
|
16
|
+
}>>;
|
|
17
|
+
fill: z.ZodOptional<z.ZodString>;
|
|
18
|
+
fillRule: z.ZodOptional<z.ZodEnum<["nonzero", "evenodd"]>>;
|
|
7
19
|
children: z.ZodArray<z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
8
20
|
type: z.ZodLiteral<"step">;
|
|
9
21
|
kind: z.ZodLiteral<"move">;
|
|
@@ -28,6 +40,30 @@ export declare const PathSchema: z.ZodObject<{
|
|
|
28
40
|
type: "step";
|
|
29
41
|
kind: "line";
|
|
30
42
|
to: string | [number, number] | import('..').PolarPosition;
|
|
43
|
+
}>, z.ZodObject<{
|
|
44
|
+
type: z.ZodLiteral<"step">;
|
|
45
|
+
kind: z.ZodLiteral<"step">;
|
|
46
|
+
via: z.ZodEnum<["-|", "|-"]>;
|
|
47
|
+
to: z.ZodUnion<[z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>, z.ZodType<import('..').PolarPosition, z.ZodTypeDef, import('..').PolarPosition>, z.ZodString]>;
|
|
48
|
+
}, "strip", z.ZodTypeAny, {
|
|
49
|
+
type: "step";
|
|
50
|
+
kind: "step";
|
|
51
|
+
to: string | [number, number] | import('..').PolarPosition;
|
|
52
|
+
via: "-|" | "|-";
|
|
53
|
+
}, {
|
|
54
|
+
type: "step";
|
|
55
|
+
kind: "step";
|
|
56
|
+
to: string | [number, number] | import('..').PolarPosition;
|
|
57
|
+
via: "-|" | "|-";
|
|
58
|
+
}>, z.ZodObject<{
|
|
59
|
+
type: z.ZodLiteral<"step">;
|
|
60
|
+
kind: z.ZodLiteral<"cycle">;
|
|
61
|
+
}, "strip", z.ZodTypeAny, {
|
|
62
|
+
type: "step";
|
|
63
|
+
kind: "cycle";
|
|
64
|
+
}, {
|
|
65
|
+
type: "step";
|
|
66
|
+
kind: "cycle";
|
|
31
67
|
}>]>, "many">;
|
|
32
68
|
}, "strip", z.ZodTypeAny, {
|
|
33
69
|
type: "path";
|
|
@@ -39,10 +75,22 @@ export declare const PathSchema: z.ZodObject<{
|
|
|
39
75
|
type: "step";
|
|
40
76
|
kind: "line";
|
|
41
77
|
to: string | [number, number] | import('..').PolarPosition;
|
|
78
|
+
} | {
|
|
79
|
+
type: "step";
|
|
80
|
+
kind: "step";
|
|
81
|
+
to: string | [number, number] | import('..').PolarPosition;
|
|
82
|
+
via: "-|" | "|-";
|
|
83
|
+
} | {
|
|
84
|
+
type: "step";
|
|
85
|
+
kind: "cycle";
|
|
42
86
|
})[];
|
|
87
|
+
fill?: string | undefined;
|
|
43
88
|
stroke?: string | undefined;
|
|
44
89
|
strokeWidth?: number | undefined;
|
|
45
90
|
strokeDasharray?: string | undefined;
|
|
91
|
+
arrow?: "none" | "->" | "<-" | "<->" | undefined;
|
|
92
|
+
arrowShape?: "normal" | "open" | "stealth" | "diamond" | "openDiamond" | "circle" | "openCircle" | undefined;
|
|
93
|
+
fillRule?: "nonzero" | "evenodd" | undefined;
|
|
46
94
|
}, {
|
|
47
95
|
type: "path";
|
|
48
96
|
children: ({
|
|
@@ -53,10 +101,22 @@ export declare const PathSchema: z.ZodObject<{
|
|
|
53
101
|
type: "step";
|
|
54
102
|
kind: "line";
|
|
55
103
|
to: string | [number, number] | import('..').PolarPosition;
|
|
104
|
+
} | {
|
|
105
|
+
type: "step";
|
|
106
|
+
kind: "step";
|
|
107
|
+
to: string | [number, number] | import('..').PolarPosition;
|
|
108
|
+
via: "-|" | "|-";
|
|
109
|
+
} | {
|
|
110
|
+
type: "step";
|
|
111
|
+
kind: "cycle";
|
|
56
112
|
})[];
|
|
113
|
+
fill?: string | undefined;
|
|
57
114
|
stroke?: string | undefined;
|
|
58
115
|
strokeWidth?: number | undefined;
|
|
59
116
|
strokeDasharray?: string | undefined;
|
|
117
|
+
arrow?: "none" | "->" | "<-" | "<->" | undefined;
|
|
118
|
+
arrowShape?: "normal" | "open" | "stealth" | "diamond" | "openDiamond" | "circle" | "openCircle" | undefined;
|
|
119
|
+
fillRule?: "nonzero" | "evenodd" | undefined;
|
|
60
120
|
}>;
|
|
61
121
|
/** 路径:由若干 step 动作(move / line / ...)组成的绘制路径 */
|
|
62
122
|
export type IRPath = z.infer<typeof PathSchema>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../../../src/ir/path/path.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../../../src/ir/path/path.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsDpB,CAAC;AAEJ,+CAA+C;AAC/C,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC"}
|
package/dist/es/ir/path/path.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ARROW_SHAPES } from "./arrow.js";
|
|
1
2
|
import { StepSchema } from "./step.js";
|
|
2
3
|
import { z } from "zod";
|
|
3
4
|
//#region src/ir/path/path.ts
|
|
@@ -6,6 +7,15 @@ var PathSchema = z.object({
|
|
|
6
7
|
stroke: z.string().optional().describe("Stroke color of the path; any CSS color. Defaults to currentColor when omitted"),
|
|
7
8
|
strokeWidth: z.number().optional().describe("Stroke width in user units; defaults to 1 when omitted"),
|
|
8
9
|
strokeDasharray: z.string().optional().describe("SVG stroke-dasharray pattern (e.g. \"4 2\"); leave empty for solid line"),
|
|
10
|
+
arrow: z.enum([
|
|
11
|
+
"none",
|
|
12
|
+
"->",
|
|
13
|
+
"<-",
|
|
14
|
+
"<->"
|
|
15
|
+
]).optional().describe("Path-level arrow direction. omitted/`none` = no arrows; `->` = arrow at end; `<-` = at start; `<->` = both."),
|
|
16
|
+
arrowShape: z.nativeEnum(ARROW_SHAPES).optional().describe("Arrow tip shape; default `normal` (filled triangle). Other values: `open` (hollow triangle), `stealth` (sharp barb), `diamond`, `circle`."),
|
|
17
|
+
fill: z.string().optional().describe("Fill color of the closed region; any CSS color. Omitted = no fill (stroke only). Pairs with `cycle` step for filled shapes."),
|
|
18
|
+
fillRule: z.enum(["nonzero", "evenodd"]).optional().describe("How self-intersecting / nested sub-paths are filled. `nonzero` (default, SVG default) winds-by-direction; `evenodd` toggles fill on each crossing — useful for ring / donut shapes."),
|
|
9
19
|
children: z.array(StepSchema).min(2).describe("Sequence of step actions defining the path; the first should usually be a `move`")
|
|
10
20
|
}).describe("A drawn path composed of a sequence of step actions (move / line / ...)");
|
|
11
21
|
//#endregion
|
|
@@ -25,6 +25,32 @@ export declare const LineStepSchema: z.ZodObject<{
|
|
|
25
25
|
kind: "line";
|
|
26
26
|
to: string | [number, number] | import('..').PolarPosition;
|
|
27
27
|
}>;
|
|
28
|
+
export declare const FoldStepSchema: z.ZodObject<{
|
|
29
|
+
type: z.ZodLiteral<"step">;
|
|
30
|
+
kind: z.ZodLiteral<"step">;
|
|
31
|
+
via: z.ZodEnum<["-|", "|-"]>;
|
|
32
|
+
to: z.ZodUnion<[z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>, z.ZodType<import('..').PolarPosition, z.ZodTypeDef, import('..').PolarPosition>, z.ZodString]>;
|
|
33
|
+
}, "strip", z.ZodTypeAny, {
|
|
34
|
+
type: "step";
|
|
35
|
+
kind: "step";
|
|
36
|
+
to: string | [number, number] | import('..').PolarPosition;
|
|
37
|
+
via: "-|" | "|-";
|
|
38
|
+
}, {
|
|
39
|
+
type: "step";
|
|
40
|
+
kind: "step";
|
|
41
|
+
to: string | [number, number] | import('..').PolarPosition;
|
|
42
|
+
via: "-|" | "|-";
|
|
43
|
+
}>;
|
|
44
|
+
export declare const CycleStepSchema: z.ZodObject<{
|
|
45
|
+
type: z.ZodLiteral<"step">;
|
|
46
|
+
kind: z.ZodLiteral<"cycle">;
|
|
47
|
+
}, "strip", z.ZodTypeAny, {
|
|
48
|
+
type: "step";
|
|
49
|
+
kind: "cycle";
|
|
50
|
+
}, {
|
|
51
|
+
type: "step";
|
|
52
|
+
kind: "cycle";
|
|
53
|
+
}>;
|
|
28
54
|
export declare const StepSchema: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
29
55
|
type: z.ZodLiteral<"step">;
|
|
30
56
|
kind: z.ZodLiteral<"move">;
|
|
@@ -49,14 +75,42 @@ export declare const StepSchema: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
|
49
75
|
type: "step";
|
|
50
76
|
kind: "line";
|
|
51
77
|
to: string | [number, number] | import('..').PolarPosition;
|
|
78
|
+
}>, z.ZodObject<{
|
|
79
|
+
type: z.ZodLiteral<"step">;
|
|
80
|
+
kind: z.ZodLiteral<"step">;
|
|
81
|
+
via: z.ZodEnum<["-|", "|-"]>;
|
|
82
|
+
to: z.ZodUnion<[z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>, z.ZodType<import('..').PolarPosition, z.ZodTypeDef, import('..').PolarPosition>, z.ZodString]>;
|
|
83
|
+
}, "strip", z.ZodTypeAny, {
|
|
84
|
+
type: "step";
|
|
85
|
+
kind: "step";
|
|
86
|
+
to: string | [number, number] | import('..').PolarPosition;
|
|
87
|
+
via: "-|" | "|-";
|
|
88
|
+
}, {
|
|
89
|
+
type: "step";
|
|
90
|
+
kind: "step";
|
|
91
|
+
to: string | [number, number] | import('..').PolarPosition;
|
|
92
|
+
via: "-|" | "|-";
|
|
93
|
+
}>, z.ZodObject<{
|
|
94
|
+
type: z.ZodLiteral<"step">;
|
|
95
|
+
kind: z.ZodLiteral<"cycle">;
|
|
96
|
+
}, "strip", z.ZodTypeAny, {
|
|
97
|
+
type: "step";
|
|
98
|
+
kind: "cycle";
|
|
99
|
+
}, {
|
|
100
|
+
type: "step";
|
|
101
|
+
kind: "cycle";
|
|
52
102
|
}>]>;
|
|
53
103
|
/** Move step:移动游标但不绘制 */
|
|
54
104
|
export type IRMoveStep = z.infer<typeof MoveStepSchema>;
|
|
55
105
|
/** Line step:从游标到目标画直线 */
|
|
56
106
|
export type IRLineStep = z.infer<typeof LineStepSchema>;
|
|
107
|
+
/** Fold step:折角段,从游标到目标经一个直角中间点(TikZ `-|` / `|-`) */
|
|
108
|
+
export type IRFoldStep = z.infer<typeof FoldStepSchema>;
|
|
109
|
+
/** Cycle step:把当前子路径闭合回起点(TikZ `cycle` / SVG `Z`) */
|
|
110
|
+
export type IRCycleStep = z.infer<typeof CycleStepSchema>;
|
|
57
111
|
/**
|
|
58
|
-
* 路径上的一个动作。v0.1.0-alpha
|
|
59
|
-
* 后续会加 '
|
|
112
|
+
* 路径上的一个动作。v0.1.0-alpha.1 支持 'move' / 'line' / 'step'(折角)/ 'cycle'(闭合)。
|
|
113
|
+
* 后续会加 'curve'、'cubic'、'rel' 等。
|
|
60
114
|
*/
|
|
61
115
|
export type IRStep = z.infer<typeof StepSchema>;
|
|
62
116
|
//# sourceMappingURL=step.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../../../../src/ir/path/step.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,cAAc;;;;;;;;;;;;EAQyC,CAAC;AAErE,eAAO,MAAM,cAAc;;;;;;;;;;;;EAQ4C,CAAC;AAExE,eAAO,MAAM,UAAU
|
|
1
|
+
{"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../../../../src/ir/path/step.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,cAAc;;;;;;;;;;;;EAQyC,CAAC;AAErE,eAAO,MAAM,cAAc;;;;;;;;;;;;EAQ4C,CAAC;AAExE,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;EAiBxB,CAAC;AAEJ,eAAO,MAAM,eAAe;;;;;;;;;EAWzB,CAAC;AAEJ,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAE+C,CAAC;AAEvE,yBAAyB;AACzB,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAExD,0BAA0B;AAC1B,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAExD,qDAAqD;AACrD,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAExD,qDAAqD;AACrD,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAE1D;;;GAGG;AACH,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC"}
|
package/dist/es/ir/path/step.js
CHANGED
|
@@ -11,6 +11,21 @@ var LineStepSchema = z.object({
|
|
|
11
11
|
kind: z.literal("line").describe("Draw a straight line from the current cursor to the target (like SVG path \"L\")"),
|
|
12
12
|
to: TargetSchema.describe("Destination point of the line segment")
|
|
13
13
|
}).describe("Line action: straight-line segment from cursor to target");
|
|
14
|
-
var
|
|
14
|
+
var FoldStepSchema = z.object({
|
|
15
|
+
type: z.literal("step").describe("Discriminator marking this as a path step node"),
|
|
16
|
+
kind: z.literal("step").describe("Folded right-angle segment from cursor to target through one intermediate point (TikZ `-|` / `|-`)"),
|
|
17
|
+
via: z.enum(["-|", "|-"]).describe("Folding direction: `-|` first horizontal then vertical; `|-` first vertical then horizontal"),
|
|
18
|
+
to: TargetSchema.describe("Destination point of the folded segment")
|
|
19
|
+
}).describe("Fold action: TikZ-style right-angle fold with a single intermediate point chosen by `via`");
|
|
20
|
+
var CycleStepSchema = z.object({
|
|
21
|
+
type: z.literal("step").describe("Discriminator marking this as a path step node"),
|
|
22
|
+
kind: z.literal("cycle").describe("Close the path back to the most recent move target (TikZ `cycle` / SVG path \"Z\")")
|
|
23
|
+
}).describe("Cycle action: close the current sub-path back to its starting point; carries no `to` field");
|
|
24
|
+
var StepSchema = z.discriminatedUnion("kind", [
|
|
25
|
+
MoveStepSchema,
|
|
26
|
+
LineStepSchema,
|
|
27
|
+
FoldStepSchema,
|
|
28
|
+
CycleStepSchema
|
|
29
|
+
]).describe("A single path action; the discriminator field is `kind`");
|
|
15
30
|
//#endregion
|
|
16
|
-
export { LineStepSchema, MoveStepSchema, StepSchema };
|
|
31
|
+
export { CycleStepSchema, FoldStepSchema, LineStepSchema, MoveStepSchema, StepSchema };
|