@retikz/core 0.2.0-alpha.7 → 0.2.0-alpha.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/arrows/index.d.ts +13 -0
- package/dist/es/arrows/index.d.ts.map +1 -0
- package/dist/es/arrows/index.js +118 -0
- package/dist/es/arrows/types.d.ts +43 -0
- package/dist/es/arrows/types.d.ts.map +1 -0
- package/dist/es/compile/compile.d.ts +26 -1
- package/dist/es/compile/compile.d.ts.map +1 -1
- package/dist/es/compile/compile.js +29 -2
- package/dist/es/compile/marker-prim.d.ts +22 -0
- package/dist/es/compile/marker-prim.d.ts.map +1 -0
- package/dist/es/compile/marker-prim.js +63 -0
- package/dist/es/compile/paint.d.ts +6 -1
- package/dist/es/compile/paint.d.ts.map +1 -1
- package/dist/es/compile/paint.js +60 -3
- package/dist/es/compile/path/index.d.ts +15 -0
- package/dist/es/compile/path/index.d.ts.map +1 -1
- package/dist/es/compile/path/index.js +258 -10
- package/dist/es/compile/path/relative.d.ts.map +1 -1
- package/dist/es/compile/path/relative.js +8 -0
- package/dist/es/compile/path/shrink.d.ts +19 -6
- package/dist/es/compile/path/shrink.d.ts.map +1 -1
- package/dist/es/compile/path/shrink.js +147 -25
- package/dist/es/geometry/bend.d.ts +7 -0
- package/dist/es/geometry/bend.d.ts.map +1 -1
- package/dist/es/geometry/bend.js +26 -1
- package/dist/es/index.d.ts +14 -4
- package/dist/es/index.d.ts.map +1 -1
- package/dist/es/index.js +7 -3
- package/dist/es/ir/index.d.ts +1 -0
- package/dist/es/ir/index.d.ts.map +1 -1
- package/dist/es/ir/json.d.ts +22 -0
- package/dist/es/ir/json.d.ts.map +1 -0
- package/dist/es/ir/json.js +25 -0
- package/dist/es/ir/node.d.ts +5 -5
- package/dist/es/ir/paint.d.ts +25 -3
- package/dist/es/ir/paint.d.ts.map +1 -1
- package/dist/es/ir/paint.js +12 -6
- package/dist/es/ir/path/arrow.d.ts +28 -48
- package/dist/es/ir/path/arrow.d.ts.map +1 -1
- package/dist/es/ir/path/arrow.js +5 -5
- package/dist/es/ir/path/path.d.ts +444 -55
- package/dist/es/ir/path/path.d.ts.map +1 -1
- package/dist/es/ir/path/path.js +21 -1
- package/dist/es/ir/path/step.d.ts +363 -8
- package/dist/es/ir/path/step.d.ts.map +1 -1
- package/dist/es/ir/path/step.js +17 -4
- package/dist/es/ir/scope.d.ts +703 -189
- package/dist/es/ir/scope.d.ts.map +1 -1
- package/dist/es/pathGenerators/define.d.ts +16 -0
- package/dist/es/pathGenerators/define.d.ts.map +1 -0
- package/dist/es/pathGenerators/define.js +23 -0
- package/dist/es/pathGenerators/index.d.ts +9 -0
- package/dist/es/pathGenerators/index.d.ts.map +1 -0
- package/dist/es/pathGenerators/types.d.ts +45 -0
- package/dist/es/pathGenerators/types.d.ts.map +1 -0
- package/dist/es/patterns/index.d.ts +10 -0
- package/dist/es/patterns/index.d.ts.map +1 -0
- package/dist/es/patterns/index.js +83 -0
- package/dist/es/patterns/types.d.ts +38 -0
- package/dist/es/patterns/types.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/marker.d.ts +160 -0
- package/dist/es/primitive/marker.d.ts.map +1 -0
- package/dist/es/primitive/paint.d.ts +24 -2
- package/dist/es/primitive/paint.d.ts.map +1 -1
- package/dist/es/primitive/path.d.ts +22 -18
- package/dist/es/primitive/path.d.ts.map +1 -1
- package/dist/es/primitive/scene.d.ts +1 -1
- package/dist/es/primitive/scene.d.ts.map +1 -1
- package/dist/lib/arrows/index.cjs +118 -0
- package/dist/lib/arrows/index.d.ts +13 -0
- package/dist/lib/arrows/index.d.ts.map +1 -0
- package/dist/lib/arrows/types.d.ts +43 -0
- package/dist/lib/arrows/types.d.ts.map +1 -0
- package/dist/lib/compile/compile.cjs +31 -4
- package/dist/lib/compile/compile.d.ts +26 -1
- package/dist/lib/compile/compile.d.ts.map +1 -1
- package/dist/lib/compile/marker-prim.cjs +63 -0
- package/dist/lib/compile/marker-prim.d.ts +22 -0
- package/dist/lib/compile/marker-prim.d.ts.map +1 -0
- package/dist/lib/compile/paint.cjs +60 -3
- package/dist/lib/compile/paint.d.ts +6 -1
- package/dist/lib/compile/paint.d.ts.map +1 -1
- package/dist/lib/compile/path/index.cjs +256 -8
- package/dist/lib/compile/path/index.d.ts +15 -0
- package/dist/lib/compile/path/index.d.ts.map +1 -1
- package/dist/lib/compile/path/relative.cjs +8 -0
- package/dist/lib/compile/path/relative.d.ts.map +1 -1
- package/dist/lib/compile/path/shrink.cjs +147 -25
- package/dist/lib/compile/path/shrink.d.ts +19 -6
- package/dist/lib/compile/path/shrink.d.ts.map +1 -1
- package/dist/lib/geometry/bend.cjs +26 -0
- package/dist/lib/geometry/bend.d.ts +7 -0
- package/dist/lib/geometry/bend.d.ts.map +1 -1
- package/dist/lib/index.cjs +11 -0
- package/dist/lib/index.d.ts +14 -4
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/ir/index.d.ts +1 -0
- package/dist/lib/ir/index.d.ts.map +1 -1
- package/dist/lib/ir/json.cjs +26 -0
- package/dist/lib/ir/json.d.ts +22 -0
- package/dist/lib/ir/json.d.ts.map +1 -0
- package/dist/lib/ir/node.d.ts +5 -5
- package/dist/lib/ir/paint.cjs +12 -5
- package/dist/lib/ir/paint.d.ts +25 -3
- package/dist/lib/ir/paint.d.ts.map +1 -1
- package/dist/lib/ir/path/arrow.cjs +5 -5
- package/dist/lib/ir/path/arrow.d.ts +28 -48
- package/dist/lib/ir/path/arrow.d.ts.map +1 -1
- package/dist/lib/ir/path/path.cjs +20 -0
- package/dist/lib/ir/path/path.d.ts +444 -55
- package/dist/lib/ir/path/path.d.ts.map +1 -1
- package/dist/lib/ir/path/step.cjs +17 -3
- package/dist/lib/ir/path/step.d.ts +363 -8
- package/dist/lib/ir/path/step.d.ts.map +1 -1
- package/dist/lib/ir/scope.d.ts +703 -189
- package/dist/lib/ir/scope.d.ts.map +1 -1
- package/dist/lib/pathGenerators/define.cjs +23 -0
- package/dist/lib/pathGenerators/define.d.ts +16 -0
- package/dist/lib/pathGenerators/define.d.ts.map +1 -0
- package/dist/lib/pathGenerators/index.d.ts +9 -0
- package/dist/lib/pathGenerators/index.d.ts.map +1 -0
- package/dist/lib/pathGenerators/types.d.ts +45 -0
- package/dist/lib/pathGenerators/types.d.ts.map +1 -0
- package/dist/lib/patterns/index.cjs +83 -0
- package/dist/lib/patterns/index.d.ts +10 -0
- package/dist/lib/patterns/index.d.ts.map +1 -0
- package/dist/lib/patterns/types.d.ts +38 -0
- package/dist/lib/patterns/types.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/marker.d.ts +160 -0
- package/dist/lib/primitive/marker.d.ts.map +1 -0
- package/dist/lib/primitive/paint.d.ts +24 -2
- package/dist/lib/primitive/paint.d.ts.map +1 -1
- package/dist/lib/primitive/path.d.ts +22 -18
- package/dist/lib/primitive/path.d.ts.map +1 -1
- package/dist/lib/primitive/scene.d.ts +1 -1
- package/dist/lib/primitive/scene.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/es/compile/path/arrow-geometry.d.ts +0 -22
- package/dist/es/compile/path/arrow-geometry.d.ts.map +0 -1
- package/dist/es/compile/path/arrow-geometry.js +0 -40
- package/dist/lib/compile/path/arrow-geometry.cjs +0 -41
- package/dist/lib/compile/path/arrow-geometry.d.ts +0 -22
- package/dist/lib/compile/path/arrow-geometry.d.ts.map +0 -1
package/dist/es/geometry/bend.js
CHANGED
|
@@ -14,5 +14,30 @@ var bendControlPoints = (from, to, direction, bendAngle) => {
|
|
|
14
14
|
const ctlOffset = 4 / 3 * (chord * Math.tan(bendAngle * Math.PI / 180 / 2));
|
|
15
15
|
return [[from[0] + dx / 3 + ctlOffset * nx, from[1] + dy / 3 + ctlOffset * ny], [from[0] + 2 * dx / 3 + ctlOffset * nx, from[1] + 2 * dy / 3 + ctlOffset * ny]];
|
|
16
16
|
};
|
|
17
|
+
/** 默认 looseness(looseness 缺省时) */
|
|
18
|
+
var DEFAULT_LOOSENESS = 1;
|
|
19
|
+
/** self-loop(from==to)默认环大小(user units,受 looseness 缩放) */
|
|
20
|
+
var DEFAULT_LOOP_SIZE = 1;
|
|
21
|
+
/** 直边 cubic 控制点距离系数(chord 的几分之一) */
|
|
22
|
+
var OUTIN_DISTANCE_FACTOR = 1 / 3;
|
|
23
|
+
/** 角度(度)转单位方向向量(0°=+x,90°=+y screen-down,与 IR 角度约定一致) */
|
|
24
|
+
var dirOf = (angleDeg) => {
|
|
25
|
+
const rad = angleDeg * Math.PI / 180;
|
|
26
|
+
return [Math.cos(rad), Math.sin(rad)];
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* out/in 角 + looseness 拟合 from→to 的非对称 cubic(含 self-loop 退化)
|
|
30
|
+
* @description 标准 TikZ:control1 = from + d·dir(outAngle),control2 = to + d·dir(inAngle);
|
|
31
|
+
* d = looseness × distance,distance = chord × 系数(chord>0)或默认环大小(self-loop,from==to chord=0)。
|
|
32
|
+
* self-loop 时两控制点沿 out/in 两个不同方向各自从端点撑开,画出环(bend 对称弯在 chord=0 时退化为点,故 out/in 是自环唯一手段)。
|
|
33
|
+
*/
|
|
34
|
+
var outInControlPoints = (from, to, outAngle, inAngle, looseness) => {
|
|
35
|
+
const k = looseness ?? DEFAULT_LOOSENESS;
|
|
36
|
+
const chord = Math.hypot(to[0] - from[0], to[1] - from[1]);
|
|
37
|
+
const d = k * (chord === 0 ? DEFAULT_LOOP_SIZE : chord * OUTIN_DISTANCE_FACTOR);
|
|
38
|
+
const outDir = dirOf(outAngle);
|
|
39
|
+
const inDir = dirOf(inAngle);
|
|
40
|
+
return [[from[0] + d * outDir[0], from[1] + d * outDir[1]], [to[0] + d * inDir[0], to[1] + d * inDir[1]]];
|
|
41
|
+
};
|
|
17
42
|
//#endregion
|
|
18
|
-
export { bendControlPoints };
|
|
43
|
+
export { bendControlPoints, outInControlPoints };
|
package/dist/es/index.d.ts
CHANGED
|
@@ -2,14 +2,18 @@
|
|
|
2
2
|
* @retikz/core 公开 API
|
|
3
3
|
* @description 任何 framework adapter(@retikz/react、@retikz/vue、@retikz/canvas、@retikz/ssr)只能 import 本文件导出内容,不准走子路径。本包零 React/零 DOM 依赖
|
|
4
4
|
*/
|
|
5
|
-
export { PositionSchema, PolarPositionSchema, AtPositionSchema, OffsetPositionSchema, AT_DIRECTIONS, TargetSchema, AnchorRefSchema, NodeTargetSchema, RelativeTargetSchema, RelativeAccumulateTargetSchema, MoveStepSchema, LineStepSchema, FoldStepSchema, CycleStepSchema, CurveStepSchema, CubicStepSchema, BendStepSchema, ArcStepSchema, CirclePathStepSchema, EllipsePathStepSchema, RectangleStepSchema, ControlPointSchema, StepLabelSchema, StepSchema, NodeSchema, NodeLabelSchema, CoordinateSchema, FontSchema, TextBlockSchema, LineSpecSchema, PathSchema, ArrowDetailSchema, ArrowEndDetailSchema, ScopeSchema, NodeDefaultSchema, PathDefaultSchema, LabelDefaultSchema, ArrowDefaultSchema, TransformSchema, ChildSchema, SceneSchema, CURRENT_IR_VERSION, PaintSpecSchema, GradientStopSchema, } from './ir';
|
|
6
|
-
export type { IRPosition, IRAtPosition, IROffsetPosition, AtDirection, IRTarget, IRAnchorRef, IRNodeTarget, IRRelativeTarget, IRRelativeAccumulateTarget, IRMoveStep, IRLineStep, IRFoldStep, IRCycleStep, IRCurveStep, IRCubicStep, IRBendStep, IRArcStep, IRCirclePathStep, IREllipsePathStep, IRRectangleStep, IRControlPoint, IRStepLabel, IRStep, IRNode, IRNodeLabel, IRCoordinate, IRFont, IRLineSpec, IRTextBlock, IRPath, IRScope, IRNodeDefault, IRPathDefault, IRLabelDefault, IRArrowDefault, StyleChannel, IRTransform, IRTranslateTransform, IRPolarTranslateTransform, IRAtTranslateTransform, IROffsetTranslateTransform, IRRotateTransform, IRScaleTransform, IRChild, IR, ArrowShape, IRArrowDetail, IRArrowEndDetail, NodeShape, BuiltinShapeName, NodeTextAlign, IRPaintSpec, IRGradientStop, } from './ir';
|
|
7
|
-
export { ARROW_SHAPES, DEFAULT_ARROW_SHAPE, HOLLOW_ARROW_SHAPES, ARROW_MARKER_DEFAULT_SIZE, ARROW_MARKER_HOLLOW_DEFAULT_LINE_WIDTH, NODE_SHAPES, NODE_TEXT_ALIGNS, } from './ir';
|
|
5
|
+
export { PositionSchema, PolarPositionSchema, AtPositionSchema, OffsetPositionSchema, AT_DIRECTIONS, TargetSchema, AnchorRefSchema, NodeTargetSchema, RelativeTargetSchema, RelativeAccumulateTargetSchema, MoveStepSchema, LineStepSchema, FoldStepSchema, CycleStepSchema, CurveStepSchema, CubicStepSchema, BendStepSchema, ArcStepSchema, CirclePathStepSchema, EllipsePathStepSchema, RectangleStepSchema, GeneratorStepSchema, ControlPointSchema, StepLabelSchema, StepSchema, NodeSchema, NodeLabelSchema, CoordinateSchema, FontSchema, TextBlockSchema, LineSpecSchema, PathSchema, ArrowDetailSchema, ArrowEndDetailSchema, ScopeSchema, NodeDefaultSchema, PathDefaultSchema, LabelDefaultSchema, ArrowDefaultSchema, TransformSchema, ChildSchema, SceneSchema, CURRENT_IR_VERSION, PaintSpecSchema, GradientStopSchema, JsonValueSchema, JsonObjectSchema, } from './ir';
|
|
6
|
+
export type { IRPosition, IRAtPosition, IROffsetPosition, AtDirection, IRTarget, IRAnchorRef, IRNodeTarget, IRRelativeTarget, IRRelativeAccumulateTarget, IRMoveStep, IRLineStep, IRFoldStep, IRCycleStep, IRCurveStep, IRCubicStep, IRBendStep, IRArcStep, IRCirclePathStep, IREllipsePathStep, IRRectangleStep, IRGeneratorStep, IRControlPoint, IRStepLabel, IRStep, IRNode, IRNodeLabel, IRCoordinate, IRFont, IRLineSpec, IRTextBlock, IRPath, IRScope, IRNodeDefault, IRPathDefault, IRLabelDefault, IRArrowDefault, StyleChannel, IRTransform, IRTranslateTransform, IRPolarTranslateTransform, IRAtTranslateTransform, IROffsetTranslateTransform, IRRotateTransform, IRScaleTransform, IRChild, IR, ArrowShape, BuiltinArrowName, ArrowShapeName, IRArrowDetail, IRArrowEndDetail, NodeShape, BuiltinShapeName, NodeTextAlign, PatternShapeName, BuiltinPatternName, IRPaintSpec, IRGradientStop, JsonValue, IRJsonObject, } from './ir';
|
|
7
|
+
export { ARROW_SHAPES, DEFAULT_ARROW_SHAPE, HOLLOW_ARROW_SHAPES, ARROW_MARKER_DEFAULT_SIZE, ARROW_MARKER_HOLLOW_DEFAULT_LINE_WIDTH, NODE_SHAPES, NODE_TEXT_ALIGNS, PATTERN_SHAPES, } from './ir';
|
|
8
8
|
export type { ScenePrimitive, RectPrim, EllipsePrim, TextPrim, TextLine, PathPrim, PathCommand,
|
|
9
9
|
/** 7 个 named PathCommand 分支(便于 wrapper / Pick<>) */
|
|
10
10
|
MovePathCommand, LinePathCommand, QuadPathCommand, CubicPathCommand, ArcPathCommand, EllipseArcPathCommand, ClosePathCommand, ArrowEndSpec, GroupPrim, Transform,
|
|
11
11
|
/** 3 个 named Transform 分支 */
|
|
12
|
-
TranslateTransform, RotateTransform, ScaleTransform, Layout, Scene, PaintValue, SceneResource,
|
|
12
|
+
TranslateTransform, RotateTransform, ScaleTransform, Layout, Scene, PaintValue, SceneResource,
|
|
13
|
+
/** 已解析 pattern tile(emit-in-compile 产物,进 Scene 资源,纯数据无函数) */
|
|
14
|
+
ResolvedPatternTile,
|
|
15
|
+
/** marker 窄子集(ArrowDefinition.emit 产物,renderer-agnostic) */
|
|
16
|
+
MarkerPrimitive, MarkerPathPrim, MarkerEllipsePrim, MarkerRectPrim, MarkerGroupPrim, MarkerPathCommand, MarkerFill, } from './primitive';
|
|
13
17
|
export type { FontSpec, TextMetrics, TextMeasurer, CompileOptions, CompileWarning, } from './compile';
|
|
14
18
|
export { computeLayout, fallbackMeasurer, compileToScene } from './compile';
|
|
15
19
|
export type { WayItem, WayDSL, WayCycle, WayVia, WayRelativeItem, WayLabel, WayLabelOp, } from './parsers';
|
|
@@ -18,5 +22,11 @@ export type { Position, Rect, RectAnchor, Circle, Ellipse, Diamond, PolarPositio
|
|
|
18
22
|
export { point, rect, circle, ellipse, diamond, RECT_ANCHORS, polar } from './geometry';
|
|
19
23
|
export type { ShapeDefinition, ShapeStyle } from './shapes';
|
|
20
24
|
export { BUILTIN_SHAPES, worldToLocal, localToWorld } from './shapes';
|
|
25
|
+
export type { ArrowDefinition, ArrowEmitContext } from './arrows';
|
|
26
|
+
export { BUILTIN_ARROWS } from './arrows';
|
|
27
|
+
export type { PatternDefinition, PatternEmitContext } from './patterns';
|
|
28
|
+
export { BUILTIN_PATTERNS } from './patterns';
|
|
29
|
+
export type { PathGeneratorDefinition, PathGeneratorContext } from './pathGenerators';
|
|
30
|
+
export { definePathGenerator } from './pathGenerators';
|
|
21
31
|
export type { ValueOf, AssertEqual } from './types';
|
|
22
32
|
//# 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;;;GAGG;AAGH,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,EACpB,aAAa,EACb,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,8BAA8B,EAC9B,cAAc,EACd,cAAc,EACd,cAAc,EACd,eAAe,EACf,eAAe,EACf,eAAe,EACf,cAAc,EACd,aAAa,EACb,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,UAAU,EACV,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,eAAe,EACf,cAAc,EACd,UAAU,EACV,iBAAiB,EACjB,oBAAoB,EACpB,WAAW,EACX,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,WAAW,EACX,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,kBAAkB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"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"}
|
package/dist/es/index.js
CHANGED
|
@@ -3,13 +3,14 @@ import { PolarPositionSchema } from "./ir/position/polar-position.js";
|
|
|
3
3
|
import { AT_DIRECTIONS, AtPositionSchema } from "./ir/position/at-position.js";
|
|
4
4
|
import { OffsetPositionSchema } from "./ir/position/offset-position.js";
|
|
5
5
|
import { FontSchema } from "./ir/font.js";
|
|
6
|
-
import {
|
|
6
|
+
import { JsonObjectSchema, JsonValueSchema } from "./ir/json.js";
|
|
7
|
+
import { GradientStopSchema, PATTERN_SHAPES, PaintSpecSchema } from "./ir/paint.js";
|
|
7
8
|
import { LineSpecSchema, TextBlockSchema } from "./ir/text.js";
|
|
8
9
|
import { ARROW_MARKER_DEFAULT_SIZE, ARROW_MARKER_HOLLOW_DEFAULT_LINE_WIDTH, ARROW_SHAPES, ArrowDetailSchema, ArrowEndDetailSchema, DEFAULT_ARROW_SHAPE, HOLLOW_ARROW_SHAPES } from "./ir/path/arrow.js";
|
|
9
10
|
import { localToWorld, worldToLocal } from "./geometry/_transform.js";
|
|
10
11
|
import { RECT_ANCHORS, rect } from "./geometry/rect.js";
|
|
11
12
|
import { AnchorRefSchema, NodeTargetSchema, RelativeAccumulateTargetSchema, RelativeTargetSchema, TargetSchema } from "./ir/path/target.js";
|
|
12
|
-
import { ArcStepSchema, BendStepSchema, CirclePathStepSchema, ControlPointSchema, CubicStepSchema, CurveStepSchema, CycleStepSchema, EllipsePathStepSchema, FoldStepSchema, LineStepSchema, MoveStepSchema, RectangleStepSchema, StepLabelSchema, StepSchema } from "./ir/path/step.js";
|
|
13
|
+
import { ArcStepSchema, BendStepSchema, CirclePathStepSchema, ControlPointSchema, CubicStepSchema, CurveStepSchema, CycleStepSchema, EllipsePathStepSchema, FoldStepSchema, GeneratorStepSchema, LineStepSchema, MoveStepSchema, RectangleStepSchema, StepLabelSchema, StepSchema } from "./ir/path/step.js";
|
|
13
14
|
import { PathSchema } from "./ir/path/path.js";
|
|
14
15
|
import { NODE_SHAPES, NODE_TEXT_ALIGNS, NodeLabelSchema, NodeSchema } from "./ir/node.js";
|
|
15
16
|
import { CoordinateSchema } from "./ir/coordinate.js";
|
|
@@ -20,6 +21,8 @@ import { circle } from "./geometry/circle.js";
|
|
|
20
21
|
import { ellipse } from "./geometry/ellipse.js";
|
|
21
22
|
import { diamond } from "./geometry/diamond.js";
|
|
22
23
|
import { BUILTIN_SHAPES } from "./shapes/index.js";
|
|
24
|
+
import { BUILTIN_ARROWS } from "./arrows/index.js";
|
|
25
|
+
import { BUILTIN_PATTERNS } from "./patterns/index.js";
|
|
23
26
|
import { fallbackMeasurer } from "./compile/text-metrics.js";
|
|
24
27
|
import { computeLayout } from "./compile/layout.js";
|
|
25
28
|
import { compileToScene } from "./compile/compile.js";
|
|
@@ -28,4 +31,5 @@ import { parseTargetSugar } from "./parsers/parseTargetSugar.js";
|
|
|
28
31
|
import { DrawWay, parseWay } from "./parsers/parseWay.js";
|
|
29
32
|
import { polar } from "./geometry/polar.js";
|
|
30
33
|
import { point } from "./geometry/point.js";
|
|
31
|
-
|
|
34
|
+
import { definePathGenerator } from "./pathGenerators/define.js";
|
|
35
|
+
export { ARROW_MARKER_DEFAULT_SIZE, ARROW_MARKER_HOLLOW_DEFAULT_LINE_WIDTH, ARROW_SHAPES, AT_DIRECTIONS, AnchorRefSchema, ArcStepSchema, ArrowDefaultSchema, ArrowDetailSchema, ArrowEndDetailSchema, AtPositionSchema, BUILTIN_ARROWS, BUILTIN_PATTERNS, BUILTIN_SHAPES, BendStepSchema, CURRENT_IR_VERSION, ChildSchema, CirclePathStepSchema, ControlPointSchema, CoordinateSchema, CubicStepSchema, CurveStepSchema, CycleStepSchema, DEFAULT_ARROW_SHAPE, DrawWay, EllipsePathStepSchema, FoldStepSchema, FontSchema, GeneratorStepSchema, GradientStopSchema, HOLLOW_ARROW_SHAPES, JsonObjectSchema, JsonValueSchema, LabelDefaultSchema, LineSpecSchema, LineStepSchema, MoveStepSchema, NODE_SHAPES, NODE_TEXT_ALIGNS, NodeDefaultSchema, NodeLabelSchema, NodeSchema, NodeTargetSchema, OffsetPositionSchema, PATTERN_SHAPES, PaintSpecSchema, PathDefaultSchema, PathSchema, PolarPositionSchema, PositionSchema, RECT_ANCHORS, RectangleStepSchema, RelativeAccumulateTargetSchema, RelativeTargetSchema, SceneSchema, ScopeSchema, StepLabelSchema, StepSchema, TargetSchema, TextBlockSchema, TransformSchema, circle, compileToScene, computeLayout, definePathGenerator, diamond, ellipse, fallbackMeasurer, localToWorld, parseNodeTarget, parseTargetSugar, parseWay, point, polar, rect, worldToLocal };
|
package/dist/es/ir/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ir/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ir/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* 递归 JSON 值 schema
|
|
4
|
+
* @description 守 IR 100% JSON 可序列化:path generator step 的 params 只能由 JSON 值构成;
|
|
5
|
+
* 函数 / undefined / class 实例 / Symbol / Map / Set 等非 JSON 值在 parse 阶段被拒。
|
|
6
|
+
* `z.lazy` 让 array / object 分支可递归引用本 schema,深度不限。
|
|
7
|
+
*/
|
|
8
|
+
export declare const JsonValueSchema: z.ZodType<JsonValue>;
|
|
9
|
+
/**
|
|
10
|
+
* JSON 对象 schema
|
|
11
|
+
* @description path generator step 的 `params` 类型;键为字符串、值为递归 JSON 值。
|
|
12
|
+
* 作为 compile 运行时的第二道护栏:即便外部 `paramsSchema` 是宽松类型,对其 parse 结果再跑本 schema
|
|
13
|
+
* 可拦下非 JSON 输出(function / undefined 等)。core 公开供外部 refine。
|
|
14
|
+
*/
|
|
15
|
+
export declare const JsonObjectSchema: z.ZodRecord<z.ZodString, z.ZodType<JsonValue, z.ZodTypeDef, JsonValue>>;
|
|
16
|
+
/** 单个 JSON 值(字符串 / 数字 / 布尔 / null / 数组 / 对象,递归) */
|
|
17
|
+
export type JsonValue = string | number | boolean | null | Array<JsonValue> | {
|
|
18
|
+
[key: string]: JsonValue;
|
|
19
|
+
};
|
|
20
|
+
/** JSON 对象类型(path generator step 的 params 形态) */
|
|
21
|
+
export type IRJsonObject = z.infer<typeof JsonObjectSchema>;
|
|
22
|
+
//# sourceMappingURL=json.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../../src/ir/json.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;GAKG;AACH,eAAO,MAAM,eAAe,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,CAahD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,yEAI1B,CAAC;AAEJ,mDAAmD;AACnD,MAAM,MAAM,SAAS,GACjB,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,KAAK,CAAC,SAAS,CAAC,GAChB;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAEjC,iDAAiD;AACjD,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
//#region src/ir/json.ts
|
|
3
|
+
/**
|
|
4
|
+
* 递归 JSON 值 schema
|
|
5
|
+
* @description 守 IR 100% JSON 可序列化:path generator step 的 params 只能由 JSON 值构成;
|
|
6
|
+
* 函数 / undefined / class 实例 / Symbol / Map / Set 等非 JSON 值在 parse 阶段被拒。
|
|
7
|
+
* `z.lazy` 让 array / object 分支可递归引用本 schema,深度不限。
|
|
8
|
+
*/
|
|
9
|
+
var JsonValueSchema = z.lazy(() => z.union([
|
|
10
|
+
z.string(),
|
|
11
|
+
z.number().finite(),
|
|
12
|
+
z.boolean(),
|
|
13
|
+
z.null(),
|
|
14
|
+
z.array(JsonValueSchema),
|
|
15
|
+
JsonObjectSchema
|
|
16
|
+
]).describe("A JSON value: string, finite number, boolean, null, an array of JSON values, or an object of JSON values. Recursive with no depth limit. Functions, undefined, Symbol, class instances, Map, and Set are rejected to keep the IR fully JSON-serializable."));
|
|
17
|
+
/**
|
|
18
|
+
* JSON 对象 schema
|
|
19
|
+
* @description path generator step 的 `params` 类型;键为字符串、值为递归 JSON 值。
|
|
20
|
+
* 作为 compile 运行时的第二道护栏:即便外部 `paramsSchema` 是宽松类型,对其 parse 结果再跑本 schema
|
|
21
|
+
* 可拦下非 JSON 输出(function / undefined 等)。core 公开供外部 refine。
|
|
22
|
+
*/
|
|
23
|
+
var JsonObjectSchema = z.record(JsonValueSchema).describe("A JSON object: string keys mapping to recursive JSON values. Used as the params payload of a path generator step and as the runtime guard that the value is fully JSON-serializable. No maximum depth or size is enforced.");
|
|
24
|
+
//#endregion
|
|
25
|
+
export { JsonObjectSchema, JsonValueSchema };
|
package/dist/es/ir/node.d.ts
CHANGED
|
@@ -273,7 +273,7 @@ export declare const NodeSchema: z.ZodObject<{
|
|
|
273
273
|
center?: [number, number] | undefined;
|
|
274
274
|
}>, z.ZodObject<{
|
|
275
275
|
type: z.ZodLiteral<"pattern">;
|
|
276
|
-
shape: z.
|
|
276
|
+
shape: z.ZodString;
|
|
277
277
|
color: z.ZodOptional<z.ZodString>;
|
|
278
278
|
background: z.ZodOptional<z.ZodString>;
|
|
279
279
|
size: z.ZodOptional<z.ZodNumber>;
|
|
@@ -281,7 +281,7 @@ export declare const NodeSchema: z.ZodObject<{
|
|
|
281
281
|
rotation: z.ZodOptional<z.ZodNumber>;
|
|
282
282
|
}, "strip", z.ZodTypeAny, {
|
|
283
283
|
type: "pattern";
|
|
284
|
-
shape:
|
|
284
|
+
shape: string;
|
|
285
285
|
size?: number | undefined;
|
|
286
286
|
color?: string | undefined;
|
|
287
287
|
background?: string | undefined;
|
|
@@ -289,7 +289,7 @@ export declare const NodeSchema: z.ZodObject<{
|
|
|
289
289
|
rotation?: number | undefined;
|
|
290
290
|
}, {
|
|
291
291
|
type: "pattern";
|
|
292
|
-
shape:
|
|
292
|
+
shape: string;
|
|
293
293
|
size?: number | undefined;
|
|
294
294
|
color?: string | undefined;
|
|
295
295
|
background?: string | undefined;
|
|
@@ -544,7 +544,7 @@ export declare const NodeSchema: z.ZodObject<{
|
|
|
544
544
|
center?: [number, number] | undefined;
|
|
545
545
|
} | {
|
|
546
546
|
type: "pattern";
|
|
547
|
-
shape:
|
|
547
|
+
shape: string;
|
|
548
548
|
size?: number | undefined;
|
|
549
549
|
color?: string | undefined;
|
|
550
550
|
background?: string | undefined;
|
|
@@ -669,7 +669,7 @@ export declare const NodeSchema: z.ZodObject<{
|
|
|
669
669
|
center?: [number, number] | undefined;
|
|
670
670
|
} | {
|
|
671
671
|
type: "pattern";
|
|
672
|
-
shape:
|
|
672
|
+
shape: string;
|
|
673
673
|
size?: number | undefined;
|
|
674
674
|
color?: string | undefined;
|
|
675
675
|
background?: string | undefined;
|
package/dist/es/ir/paint.d.ts
CHANGED
|
@@ -1,4 +1,26 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { ValueOf } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* 内置 pattern motif 名常量(用 const + ValueOf 派生,不用 TS enum)
|
|
5
|
+
* @description 内置 3 motif:`lines`(横向阴影线)/ `dots`(波点)/ `grid`(横竖网格)。
|
|
6
|
+
* 各 motif 的 tile 几何由 `BUILTIN_PATTERNS` 的 `PatternDefinition.emit` 在 compile 期产出。
|
|
7
|
+
*/
|
|
8
|
+
export declare const PATTERN_SHAPES: {
|
|
9
|
+
readonly lines: "lines";
|
|
10
|
+
readonly dots: "dots";
|
|
11
|
+
readonly grid: "grid";
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* 内置 3 pattern motif 名联合
|
|
15
|
+
* @description `BUILTIN_PATTERNS` 的 Record key(保穷尽性约束,不随 `PatternShapeName` 开放而退化为 `string`)
|
|
16
|
+
*/
|
|
17
|
+
export type BuiltinPatternName = ValueOf<typeof PATTERN_SHAPES>;
|
|
18
|
+
/**
|
|
19
|
+
* pattern motif 名:开放字符串
|
|
20
|
+
* @description 内置 `BuiltinPatternName`,或经 `CompileOptions.patterns` 注册的扩展 motif 名;
|
|
21
|
+
* `& {}` 让 IDE 仍对内置 3 名自动补全,同时接受任意非空字符串
|
|
22
|
+
*/
|
|
23
|
+
export type PatternShapeName = BuiltinPatternName | (string & {});
|
|
2
24
|
/**
|
|
3
25
|
* 渐变 stop:位置 + 颜色 + 可选透明度
|
|
4
26
|
* @description offset 0..1(沿渐变轴的位置);color 任意 CSS 颜色(含 `currentColor` 主题反应);opacity 0..1。
|
|
@@ -90,7 +112,7 @@ export declare const PaintSpecSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
90
112
|
center?: [number, number] | undefined;
|
|
91
113
|
}>, z.ZodObject<{
|
|
92
114
|
type: z.ZodLiteral<"pattern">;
|
|
93
|
-
shape: z.
|
|
115
|
+
shape: z.ZodString;
|
|
94
116
|
color: z.ZodOptional<z.ZodString>;
|
|
95
117
|
background: z.ZodOptional<z.ZodString>;
|
|
96
118
|
size: z.ZodOptional<z.ZodNumber>;
|
|
@@ -98,7 +120,7 @@ export declare const PaintSpecSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
98
120
|
rotation: z.ZodOptional<z.ZodNumber>;
|
|
99
121
|
}, "strip", z.ZodTypeAny, {
|
|
100
122
|
type: "pattern";
|
|
101
|
-
shape:
|
|
123
|
+
shape: string;
|
|
102
124
|
size?: number | undefined;
|
|
103
125
|
color?: string | undefined;
|
|
104
126
|
background?: string | undefined;
|
|
@@ -106,7 +128,7 @@ export declare const PaintSpecSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
106
128
|
rotation?: number | undefined;
|
|
107
129
|
}, {
|
|
108
130
|
type: "pattern";
|
|
109
|
-
shape:
|
|
131
|
+
shape: string;
|
|
110
132
|
size?: number | undefined;
|
|
111
133
|
color?: string | undefined;
|
|
112
134
|
background?: string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paint.d.ts","sourceRoot":"","sources":["../../../src/ir/paint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"paint.d.ts","sourceRoot":"","sources":["../../../src/ir/paint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAExC;;;;GAIG;AACH,eAAO,MAAM,cAAc;;;;CAIjB,CAAC;AAEX;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAC,OAAO,cAAc,CAAC,CAAC;AAEhE;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,kBAAkB,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAElE;;;GAGG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;EAMY,CAAC;AAE5C;;;;GAIG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAsEwF,CAAC;AAErH,iBAAiB;AACjB,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAChE,sCAAsC;AACtC,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC"}
|
package/dist/es/ir/paint.js
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
//#region src/ir/paint.ts
|
|
3
3
|
/**
|
|
4
|
+
* 内置 pattern motif 名常量(用 const + ValueOf 派生,不用 TS enum)
|
|
5
|
+
* @description 内置 3 motif:`lines`(横向阴影线)/ `dots`(波点)/ `grid`(横竖网格)。
|
|
6
|
+
* 各 motif 的 tile 几何由 `BUILTIN_PATTERNS` 的 `PatternDefinition.emit` 在 compile 期产出。
|
|
7
|
+
*/
|
|
8
|
+
var PATTERN_SHAPES = {
|
|
9
|
+
lines: "lines",
|
|
10
|
+
dots: "dots",
|
|
11
|
+
grid: "grid"
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
4
14
|
* 渐变 stop:位置 + 颜色 + 可选透明度
|
|
5
15
|
* @description offset 0..1(沿渐变轴的位置);color 任意 CSS 颜色(含 `currentColor` 主题反应);opacity 0..1。
|
|
6
16
|
*/
|
|
@@ -28,11 +38,7 @@ var PaintSpecSchema = z.discriminatedUnion("type", [
|
|
|
28
38
|
}).describe("Radial gradient paint server"),
|
|
29
39
|
z.object({
|
|
30
40
|
type: z.literal("pattern"),
|
|
31
|
-
shape: z.
|
|
32
|
-
"lines",
|
|
33
|
-
"dots",
|
|
34
|
-
"grid"
|
|
35
|
-
]).describe("Pattern motif: `lines` (hatching) / `dots` / `grid` (crosshatch)"),
|
|
41
|
+
shape: z.string().min(1).describe("Registered pattern motif name; built-in `lines` (hatching) / `dots` / `grid` (crosshatch), or an extension motif registered via `CompileOptions.patterns`. Any non-empty string passes schema validation; unregistered names are rejected at compile time."),
|
|
36
42
|
color: z.string().optional().describe("Motif color; any CSS color, defaults to `currentColor`"),
|
|
37
43
|
background: z.string().optional().describe("Tile background fill; omitted = transparent"),
|
|
38
44
|
size: z.number().finite().positive().optional().describe("Tile period in user units (line gap / dot spacing); default 8"),
|
|
@@ -50,4 +56,4 @@ var PaintSpecSchema = z.discriminatedUnion("type", [
|
|
|
50
56
|
}).describe("Image paint server (fills the shape with an image)")
|
|
51
57
|
]).describe("Paint server spec: gradient / pattern / image. Solid color stays a plain string on `fill` / `stroke`.");
|
|
52
58
|
//#endregion
|
|
53
|
-
export { GradientStopSchema, PaintSpecSchema };
|
|
59
|
+
export { GradientStopSchema, PATTERN_SHAPES, PaintSpecSchema };
|
|
@@ -15,6 +15,18 @@ export declare const ARROW_SHAPES: {
|
|
|
15
15
|
};
|
|
16
16
|
/** 箭头形状字面量类型 */
|
|
17
17
|
export type ArrowShape = ValueOf<typeof ARROW_SHAPES>;
|
|
18
|
+
/**
|
|
19
|
+
* 内置 7 箭头名联合
|
|
20
|
+
* @description `BUILTIN_ARROWS` 的 Record key(保穷尽性约束,不随 `ArrowShapeName` 开放而退化为 `string`);
|
|
21
|
+
* 等价于历史 `ArrowShape`,独立命名对齐 `node.ts` 的 `BuiltinShapeName` 范式
|
|
22
|
+
*/
|
|
23
|
+
export type BuiltinArrowName = ValueOf<typeof ARROW_SHAPES>;
|
|
24
|
+
/**
|
|
25
|
+
* 箭头形状名:开放字符串
|
|
26
|
+
* @description 内置 `BuiltinArrowName`,或经 `CompileOptions.arrows` 注册的扩展箭头名;
|
|
27
|
+
* `& {}` 让 IDE 仍对内置 7 名自动补全,同时接受任意非空字符串(对齐 `node.ts` 的 `NodeShape`)
|
|
28
|
+
*/
|
|
29
|
+
export type ArrowShapeName = BuiltinArrowName | (string & {});
|
|
18
30
|
/** 箭头默认形状 */
|
|
19
31
|
export declare const DEFAULT_ARROW_SHAPE: "stealth";
|
|
20
32
|
/**
|
|
@@ -31,15 +43,7 @@ export declare const ARROW_MARKER_HOLLOW_DEFAULT_LINE_WIDTH = 1.5;
|
|
|
31
43
|
* @description 顶层 8 字段全 optional;fill 在空心 shape 上 silent no-op(schema 不拒绝、compile/render 丢字段);start/end 子对象用相同字段集(无 start/end 递归)
|
|
32
44
|
*/
|
|
33
45
|
export declare const ArrowEndDetailSchema: z.ZodObject<{
|
|
34
|
-
shape: z.ZodOptional<z.
|
|
35
|
-
readonly normal: "normal";
|
|
36
|
-
readonly open: "open";
|
|
37
|
-
readonly stealth: "stealth";
|
|
38
|
-
readonly diamond: "diamond";
|
|
39
|
-
readonly openDiamond: "openDiamond";
|
|
40
|
-
readonly circle: "circle";
|
|
41
|
-
readonly openCircle: "openCircle";
|
|
42
|
-
}>>;
|
|
46
|
+
shape: z.ZodOptional<z.ZodString>;
|
|
43
47
|
scale: z.ZodOptional<z.ZodNumber>;
|
|
44
48
|
length: z.ZodOptional<z.ZodNumber>;
|
|
45
49
|
width: z.ZodOptional<z.ZodNumber>;
|
|
@@ -52,7 +56,7 @@ export declare const ArrowEndDetailSchema: z.ZodObject<{
|
|
|
52
56
|
fill?: string | undefined;
|
|
53
57
|
color?: string | undefined;
|
|
54
58
|
opacity?: number | undefined;
|
|
55
|
-
shape?:
|
|
59
|
+
shape?: string | undefined;
|
|
56
60
|
lineWidth?: number | undefined;
|
|
57
61
|
scale?: number | undefined;
|
|
58
62
|
width?: number | undefined;
|
|
@@ -61,7 +65,7 @@ export declare const ArrowEndDetailSchema: z.ZodObject<{
|
|
|
61
65
|
fill?: string | undefined;
|
|
62
66
|
color?: string | undefined;
|
|
63
67
|
opacity?: number | undefined;
|
|
64
|
-
shape?:
|
|
68
|
+
shape?: string | undefined;
|
|
65
69
|
lineWidth?: number | undefined;
|
|
66
70
|
scale?: number | undefined;
|
|
67
71
|
width?: number | undefined;
|
|
@@ -71,15 +75,7 @@ export declare const ArrowEndDetailSchema: z.ZodObject<{
|
|
|
71
75
|
* @description 顶层视觉字段(与 `ArrowEndDetailSchema` 同字段集)作为起末共享默认;`start` / `end` 子对象逐字段 merge 顶层(缺省字段继承,已填字段 override)
|
|
72
76
|
*/
|
|
73
77
|
export declare const ArrowDetailSchema: z.ZodObject<{
|
|
74
|
-
shape: z.ZodOptional<z.
|
|
75
|
-
readonly normal: "normal";
|
|
76
|
-
readonly open: "open";
|
|
77
|
-
readonly stealth: "stealth";
|
|
78
|
-
readonly diamond: "diamond";
|
|
79
|
-
readonly openDiamond: "openDiamond";
|
|
80
|
-
readonly circle: "circle";
|
|
81
|
-
readonly openCircle: "openCircle";
|
|
82
|
-
}>>;
|
|
78
|
+
shape: z.ZodOptional<z.ZodString>;
|
|
83
79
|
scale: z.ZodOptional<z.ZodNumber>;
|
|
84
80
|
length: z.ZodOptional<z.ZodNumber>;
|
|
85
81
|
width: z.ZodOptional<z.ZodNumber>;
|
|
@@ -89,15 +85,7 @@ export declare const ArrowDetailSchema: z.ZodObject<{
|
|
|
89
85
|
lineWidth: z.ZodOptional<z.ZodNumber>;
|
|
90
86
|
} & {
|
|
91
87
|
start: z.ZodOptional<z.ZodObject<{
|
|
92
|
-
shape: z.ZodOptional<z.
|
|
93
|
-
readonly normal: "normal";
|
|
94
|
-
readonly open: "open";
|
|
95
|
-
readonly stealth: "stealth";
|
|
96
|
-
readonly diamond: "diamond";
|
|
97
|
-
readonly openDiamond: "openDiamond";
|
|
98
|
-
readonly circle: "circle";
|
|
99
|
-
readonly openCircle: "openCircle";
|
|
100
|
-
}>>;
|
|
88
|
+
shape: z.ZodOptional<z.ZodString>;
|
|
101
89
|
scale: z.ZodOptional<z.ZodNumber>;
|
|
102
90
|
length: z.ZodOptional<z.ZodNumber>;
|
|
103
91
|
width: z.ZodOptional<z.ZodNumber>;
|
|
@@ -110,7 +98,7 @@ export declare const ArrowDetailSchema: z.ZodObject<{
|
|
|
110
98
|
fill?: string | undefined;
|
|
111
99
|
color?: string | undefined;
|
|
112
100
|
opacity?: number | undefined;
|
|
113
|
-
shape?:
|
|
101
|
+
shape?: string | undefined;
|
|
114
102
|
lineWidth?: number | undefined;
|
|
115
103
|
scale?: number | undefined;
|
|
116
104
|
width?: number | undefined;
|
|
@@ -119,21 +107,13 @@ export declare const ArrowDetailSchema: z.ZodObject<{
|
|
|
119
107
|
fill?: string | undefined;
|
|
120
108
|
color?: string | undefined;
|
|
121
109
|
opacity?: number | undefined;
|
|
122
|
-
shape?:
|
|
110
|
+
shape?: string | undefined;
|
|
123
111
|
lineWidth?: number | undefined;
|
|
124
112
|
scale?: number | undefined;
|
|
125
113
|
width?: number | undefined;
|
|
126
114
|
}>>;
|
|
127
115
|
end: z.ZodOptional<z.ZodObject<{
|
|
128
|
-
shape: z.ZodOptional<z.
|
|
129
|
-
readonly normal: "normal";
|
|
130
|
-
readonly open: "open";
|
|
131
|
-
readonly stealth: "stealth";
|
|
132
|
-
readonly diamond: "diamond";
|
|
133
|
-
readonly openDiamond: "openDiamond";
|
|
134
|
-
readonly circle: "circle";
|
|
135
|
-
readonly openCircle: "openCircle";
|
|
136
|
-
}>>;
|
|
116
|
+
shape: z.ZodOptional<z.ZodString>;
|
|
137
117
|
scale: z.ZodOptional<z.ZodNumber>;
|
|
138
118
|
length: z.ZodOptional<z.ZodNumber>;
|
|
139
119
|
width: z.ZodOptional<z.ZodNumber>;
|
|
@@ -146,7 +126,7 @@ export declare const ArrowDetailSchema: z.ZodObject<{
|
|
|
146
126
|
fill?: string | undefined;
|
|
147
127
|
color?: string | undefined;
|
|
148
128
|
opacity?: number | undefined;
|
|
149
|
-
shape?:
|
|
129
|
+
shape?: string | undefined;
|
|
150
130
|
lineWidth?: number | undefined;
|
|
151
131
|
scale?: number | undefined;
|
|
152
132
|
width?: number | undefined;
|
|
@@ -155,7 +135,7 @@ export declare const ArrowDetailSchema: z.ZodObject<{
|
|
|
155
135
|
fill?: string | undefined;
|
|
156
136
|
color?: string | undefined;
|
|
157
137
|
opacity?: number | undefined;
|
|
158
|
-
shape?:
|
|
138
|
+
shape?: string | undefined;
|
|
159
139
|
lineWidth?: number | undefined;
|
|
160
140
|
scale?: number | undefined;
|
|
161
141
|
width?: number | undefined;
|
|
@@ -165,7 +145,7 @@ export declare const ArrowDetailSchema: z.ZodObject<{
|
|
|
165
145
|
fill?: string | undefined;
|
|
166
146
|
color?: string | undefined;
|
|
167
147
|
opacity?: number | undefined;
|
|
168
|
-
shape?:
|
|
148
|
+
shape?: string | undefined;
|
|
169
149
|
lineWidth?: number | undefined;
|
|
170
150
|
scale?: number | undefined;
|
|
171
151
|
width?: number | undefined;
|
|
@@ -174,7 +154,7 @@ export declare const ArrowDetailSchema: z.ZodObject<{
|
|
|
174
154
|
fill?: string | undefined;
|
|
175
155
|
color?: string | undefined;
|
|
176
156
|
opacity?: number | undefined;
|
|
177
|
-
shape?:
|
|
157
|
+
shape?: string | undefined;
|
|
178
158
|
lineWidth?: number | undefined;
|
|
179
159
|
scale?: number | undefined;
|
|
180
160
|
width?: number | undefined;
|
|
@@ -184,7 +164,7 @@ export declare const ArrowDetailSchema: z.ZodObject<{
|
|
|
184
164
|
fill?: string | undefined;
|
|
185
165
|
color?: string | undefined;
|
|
186
166
|
opacity?: number | undefined;
|
|
187
|
-
shape?:
|
|
167
|
+
shape?: string | undefined;
|
|
188
168
|
lineWidth?: number | undefined;
|
|
189
169
|
scale?: number | undefined;
|
|
190
170
|
width?: number | undefined;
|
|
@@ -194,7 +174,7 @@ export declare const ArrowDetailSchema: z.ZodObject<{
|
|
|
194
174
|
fill?: string | undefined;
|
|
195
175
|
color?: string | undefined;
|
|
196
176
|
opacity?: number | undefined;
|
|
197
|
-
shape?:
|
|
177
|
+
shape?: string | undefined;
|
|
198
178
|
lineWidth?: number | undefined;
|
|
199
179
|
scale?: number | undefined;
|
|
200
180
|
width?: number | undefined;
|
|
@@ -203,7 +183,7 @@ export declare const ArrowDetailSchema: z.ZodObject<{
|
|
|
203
183
|
fill?: string | undefined;
|
|
204
184
|
color?: string | undefined;
|
|
205
185
|
opacity?: number | undefined;
|
|
206
|
-
shape?:
|
|
186
|
+
shape?: string | undefined;
|
|
207
187
|
lineWidth?: number | undefined;
|
|
208
188
|
scale?: number | undefined;
|
|
209
189
|
width?: number | undefined;
|
|
@@ -213,7 +193,7 @@ export declare const ArrowDetailSchema: z.ZodObject<{
|
|
|
213
193
|
fill?: string | undefined;
|
|
214
194
|
color?: string | undefined;
|
|
215
195
|
opacity?: number | undefined;
|
|
216
|
-
shape?:
|
|
196
|
+
shape?: string | undefined;
|
|
217
197
|
lineWidth?: number | undefined;
|
|
218
198
|
scale?: number | undefined;
|
|
219
199
|
width?: number | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arrow.d.ts","sourceRoot":"","sources":["../../../../src/ir/path/arrow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C;;;GAGG;AACH,eAAO,MAAM,YAAY;;;;;;;;CAQf,CAAC;AAEX,gBAAgB;AAChB,MAAM,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,YAAY,CAAC,CAAC;AAEtD,aAAa;AACb,eAAO,MAAM,mBAAmB,WAAuB,CAAC;AAExD;;;GAGG;AACH,eAAO,MAAM,mBAAmB,iBAA6D,CAAC;AAE9F,wCAAwC;AACxC,eAAO,MAAM,yBAAyB,IAAI,CAAC;AAE3C,0CAA0C;AAC1C,eAAO,MAAM,sCAAsC,MAAM,CAAC;AAE1D;;;GAGG;AACH,eAAO,MAAM,oBAAoB
|
|
1
|
+
{"version":3,"file":"arrow.d.ts","sourceRoot":"","sources":["../../../../src/ir/path/arrow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C;;;GAGG;AACH,eAAO,MAAM,YAAY;;;;;;;;CAQf,CAAC;AAEX,gBAAgB;AAChB,MAAM,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,YAAY,CAAC,CAAC;AAEtD;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,OAAO,CAAC,OAAO,YAAY,CAAC,CAAC;AAE5D;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,gBAAgB,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAE9D,aAAa;AACb,eAAO,MAAM,mBAAmB,WAAuB,CAAC;AAExD;;;GAGG;AACH,eAAO,MAAM,mBAAmB,iBAA6D,CAAC;AAE9F,wCAAwC;AACxC,eAAO,MAAM,yBAAyB,IAAI,CAAC;AAE3C,0CAA0C;AAC1C,eAAO,MAAM,sCAAsC,MAAM,CAAC;AAE1D;;;GAGG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgE9B,CAAC;AAEJ;;;GAGG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAS7B,CAAC;AAEF,gBAAgB;AAChB,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AACpE,mBAAmB;AACnB,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC"}
|
package/dist/es/ir/path/arrow.js
CHANGED
|
@@ -33,14 +33,14 @@ var ARROW_MARKER_HOLLOW_DEFAULT_LINE_WIDTH = 1.5;
|
|
|
33
33
|
* @description 顶层 8 字段全 optional;fill 在空心 shape 上 silent no-op(schema 不拒绝、compile/render 丢字段);start/end 子对象用相同字段集(无 start/end 递归)
|
|
34
34
|
*/
|
|
35
35
|
var ArrowEndDetailSchema = z.object({
|
|
36
|
-
shape: z.
|
|
37
|
-
scale: z.number().positive().optional().describe("Uniform tip scale factor; multiplies `length` and `width` (e.g. `length=10, scale=1.5` → effective 15). Defaults to 1."),
|
|
38
|
-
length: z.number().nonnegative().optional().describe("Tip length in user units (the dimension along the path direction). Defaults to ~6."),
|
|
39
|
-
width: z.number().nonnegative().optional().describe("Tip width in user units (perpendicular to the path). Defaults to ~6."),
|
|
36
|
+
shape: z.string().min(1).optional().describe("Registered arrow name: built-in 7 (`normal` / `open` / `stealth` / `diamond` / `openDiamond` / `circle` / `openCircle`) or an extension arrow registered via `CompileOptions.arrows`. Any non-empty string passes schema validation; unregistered names are rejected at compile time (throw). Defaults to `stealth`."),
|
|
37
|
+
scale: z.number().finite().positive().optional().describe("Uniform tip scale factor; multiplies `length` and `width` (e.g. `length=10, scale=1.5` → effective 15). Defaults to 1."),
|
|
38
|
+
length: z.number().finite().nonnegative().optional().describe("Tip length in user units (the dimension along the path direction). Defaults to ~6."),
|
|
39
|
+
width: z.number().finite().nonnegative().optional().describe("Tip width in user units (perpendicular to the path). Defaults to ~6."),
|
|
40
40
|
color: z.string().optional().describe("Stroke color override. When omitted, the renderer should inherit the path stroke."),
|
|
41
41
|
fill: z.string().optional().describe("Fill color override (effective only on solid shapes). Hollow shapes (`open` / `openDiamond` / `openCircle`) silently ignore this field — `color` drives the stroke."),
|
|
42
42
|
opacity: z.number().min(0).max(1).optional().describe("Arrow opacity 0..1, independent from the path opacity. When omitted, inherits the path opacity."),
|
|
43
|
-
lineWidth: z.number().nonnegative().optional().describe("Stroke width for hollow shapes (user units). Defaults to 1.5. Solid shapes ignore this field.")
|
|
43
|
+
lineWidth: z.number().finite().nonnegative().optional().describe("Stroke width for hollow shapes (user units). Defaults to 1.5. Solid shapes ignore this field.")
|
|
44
44
|
}).describe("Per-end arrow visual spec: shape + visual fields (scale / length / width / color / fill / opacity / lineWidth). All optional; omitted fields fall through to top-level `arrowDetail` defaults and then built-in defaults.");
|
|
45
45
|
/**
|
|
46
46
|
* Path 级箭头详细配置 schema
|