@retikz/core 0.3.0-alpha.4 → 0.3.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/arrows/define.d.ts +9 -0
- package/dist/es/arrows/define.d.ts.map +1 -0
- package/dist/es/arrows/define.js +10 -0
- package/dist/es/arrows/index.d.ts +3 -1
- package/dist/es/arrows/index.d.ts.map +1 -1
- package/dist/es/arrows/index.js +14 -1
- package/dist/es/arrows/types.d.ts +4 -2
- package/dist/es/arrows/types.d.ts.map +1 -1
- package/dist/es/compile/anchor-cache.d.ts +3 -3
- package/dist/es/compile/anchor-cache.d.ts.map +1 -1
- package/dist/es/compile/anchor-cache.js +18 -5
- package/dist/es/compile/compile.d.ts +5 -14
- package/dist/es/compile/compile.d.ts.map +1 -1
- package/dist/es/compile/compile.js +73 -41
- package/dist/es/compile/{lowerComposites.d.ts → composite.d.ts} +9 -2
- package/dist/es/compile/composite.d.ts.map +1 -0
- package/dist/es/compile/{lowerComposites.js → composite.js} +9 -1
- package/dist/es/compile/constant.d.ts +32 -0
- package/dist/es/compile/constant.d.ts.map +1 -0
- package/dist/es/compile/constant.js +23 -0
- package/dist/es/compile/direction.d.ts +27 -0
- package/dist/es/compile/direction.d.ts.map +1 -0
- package/dist/es/compile/direction.js +30 -0
- package/dist/es/compile/index.d.ts +3 -1
- package/dist/es/compile/index.d.ts.map +1 -1
- package/dist/es/compile/name-stack.d.ts +3 -1
- package/dist/es/compile/name-stack.d.ts.map +1 -1
- package/dist/es/compile/name-stack.js +5 -1
- package/dist/es/compile/node.d.ts +20 -7
- package/dist/es/compile/node.d.ts.map +1 -1
- package/dist/es/compile/node.js +42 -63
- package/dist/es/compile/paint.js +1 -1
- package/dist/es/compile/path/anchor.d.ts +4 -3
- package/dist/es/compile/path/anchor.d.ts.map +1 -1
- package/dist/es/compile/path/anchor.js +9 -12
- package/dist/es/compile/path/index.d.ts +6 -8
- package/dist/es/compile/path/index.d.ts.map +1 -1
- package/dist/es/compile/path/index.js +59 -34
- package/dist/es/compile/path/relative.d.ts +1 -1
- package/dist/es/compile/path/relative.js +1 -1
- package/dist/es/compile/path/shrink.d.ts +3 -1
- package/dist/es/compile/path/shrink.d.ts.map +1 -1
- package/dist/es/compile/path/shrink.js +16 -11
- package/dist/es/compile/position.d.ts +2 -2
- package/dist/es/compile/position.d.ts.map +1 -1
- package/dist/es/compile/position.js +6 -19
- package/dist/es/compile/precision.d.ts +1 -1
- package/dist/es/compile/precision.d.ts.map +1 -1
- package/dist/es/compile/precision.js +2 -2
- package/dist/es/compile/scope.d.ts +7 -5
- package/dist/es/compile/scope.d.ts.map +1 -1
- package/dist/es/compile/scope.js +29 -13
- package/dist/es/compile/style.d.ts +2 -2
- package/dist/es/compile/style.d.ts.map +1 -1
- package/dist/es/compile/style.js +2 -2
- package/dist/es/composites/define.d.ts +8 -0
- package/dist/es/composites/define.d.ts.map +1 -0
- package/dist/es/composites/{types.js → define.js} +2 -2
- package/dist/es/composites/index.d.ts +1 -1
- package/dist/es/composites/index.d.ts.map +1 -1
- package/dist/es/composites/types.d.ts +0 -6
- package/dist/es/composites/types.d.ts.map +1 -1
- package/dist/es/geometry/anchor.d.ts +33 -0
- package/dist/es/geometry/anchor.d.ts.map +1 -0
- package/dist/es/geometry/anchor.js +45 -0
- package/dist/es/geometry/bend.d.ts +1 -1
- package/dist/es/geometry/bend.js +2 -2
- package/dist/es/geometry/circle.d.ts +4 -4
- package/dist/es/geometry/circle.d.ts.map +1 -1
- package/dist/es/geometry/circle.js +3 -3
- package/dist/es/geometry/{roundedContour.d.ts → contour.d.ts} +4 -5
- package/dist/es/geometry/contour.d.ts.map +1 -0
- package/dist/es/geometry/{roundedContour.js → contour.js} +22 -34
- package/dist/es/geometry/diamond.d.ts +3 -3
- package/dist/es/geometry/diamond.d.ts.map +1 -1
- package/dist/es/geometry/diamond.js +2 -2
- package/dist/{lib/geometry/_edge.d.ts → es/geometry/edge.d.ts} +1 -1
- package/dist/es/geometry/edge.d.ts.map +1 -0
- package/dist/es/geometry/{_edge.js → edge.js} +1 -1
- package/dist/es/geometry/ellipse.d.ts +3 -3
- package/dist/es/geometry/ellipse.d.ts.map +1 -1
- package/dist/es/geometry/ellipse.js +2 -2
- package/dist/es/geometry/index.d.ts +2 -1
- package/dist/es/geometry/index.d.ts.map +1 -1
- package/dist/es/geometry/point.d.ts +6 -0
- package/dist/es/geometry/point.d.ts.map +1 -1
- package/dist/es/geometry/point.js +17 -0
- package/dist/es/geometry/rect.d.ts +4 -17
- package/dist/es/geometry/rect.d.ts.map +1 -1
- package/dist/es/geometry/rect.js +4 -16
- package/dist/es/geometry/segment.d.ts.map +1 -1
- package/dist/es/geometry/segment.js +25 -47
- package/dist/{lib/geometry/_transform.d.ts → es/geometry/transform.d.ts} +1 -1
- package/dist/es/geometry/transform.d.ts.map +1 -0
- package/dist/es/geometry/{_transform.js → transform.js} +1 -1
- package/dist/es/index.d.ts +13 -10
- package/dist/es/index.d.ts.map +1 -1
- package/dist/es/index.js +19 -14
- package/dist/es/ir/animation.d.ts +219 -0
- package/dist/es/ir/animation.d.ts.map +1 -0
- package/dist/es/ir/animation.js +118 -0
- package/dist/es/ir/boundary.d.ts +1 -1
- package/dist/es/ir/boundary.d.ts.map +1 -1
- package/dist/es/ir/coordinate.d.ts +8 -8
- package/dist/es/ir/index.d.ts +1 -0
- package/dist/es/ir/index.d.ts.map +1 -1
- package/dist/es/ir/node.d.ts +249 -92
- package/dist/es/ir/node.d.ts.map +1 -1
- package/dist/es/ir/node.js +25 -23
- package/dist/es/ir/paint.d.ts +19 -18
- package/dist/es/ir/paint.d.ts.map +1 -1
- package/dist/es/ir/paint.js +10 -10
- package/dist/es/ir/path/arrow.d.ts +39 -38
- package/dist/es/ir/path/arrow.d.ts.map +1 -1
- package/dist/es/ir/path/arrow.js +18 -16
- package/dist/es/ir/path/path.d.ts +1106 -209
- package/dist/es/ir/path/path.d.ts.map +1 -1
- package/dist/es/ir/path/path.js +3 -1
- package/dist/es/ir/path/step.d.ts +932 -20
- package/dist/es/ir/path/step.d.ts.map +1 -1
- package/dist/es/ir/path/step.js +73 -22
- package/dist/es/ir/path/target.js +3 -3
- package/dist/es/ir/position/at-position.d.ts +18 -18
- package/dist/es/ir/position/at-position.d.ts.map +1 -1
- package/dist/es/ir/position/at-position.js +11 -11
- package/dist/es/ir/scene.d.ts +156 -0
- package/dist/es/ir/scene.d.ts.map +1 -1
- package/dist/es/ir/scene.js +3 -1
- package/dist/es/ir/scope.d.ts +3446 -1306
- package/dist/es/ir/scope.d.ts.map +1 -1
- package/dist/es/ir/scope.js +10 -6
- package/dist/es/ir/transform.d.ts +44 -17
- package/dist/es/ir/transform.d.ts.map +1 -1
- package/dist/es/ir/transform.js +10 -3
- package/dist/es/parsers/index.d.ts +3 -3
- package/dist/es/parsers/index.d.ts.map +1 -1
- package/dist/es/parsers/{parseNodeTarget.d.ts → node-target.d.ts} +1 -1
- package/dist/es/parsers/node-target.d.ts.map +1 -0
- package/dist/es/parsers/{parseNodeTarget.js → node-target.js} +10 -8
- package/dist/{lib/parsers/parseTargetSugar.d.ts → es/parsers/target-sugar.d.ts} +1 -1
- package/dist/es/parsers/target-sugar.d.ts.map +1 -0
- package/dist/es/parsers/{parseTargetSugar.js → target-sugar.js} +9 -4
- package/dist/{lib/parsers/parseWay.d.ts → es/parsers/way.d.ts} +1 -1
- package/dist/es/parsers/way.d.ts.map +1 -0
- package/dist/es/parsers/{parseWay.js → way.js} +9 -5
- package/dist/es/path-generators/define.d.ts.map +1 -0
- package/dist/es/{pathGenerators → path-generators}/define.js +1 -1
- package/dist/es/path-generators/index.d.ts.map +1 -0
- package/dist/es/path-generators/types.d.ts.map +1 -0
- package/dist/es/patterns/define.d.ts +9 -0
- package/dist/es/patterns/define.d.ts.map +1 -0
- package/dist/es/patterns/define.js +10 -0
- package/dist/es/patterns/index.d.ts +1 -0
- package/dist/es/patterns/index.d.ts.map +1 -1
- package/dist/es/patterns/index.js +42 -35
- package/dist/es/presets/animation.d.ts +123 -0
- package/dist/es/presets/animation.d.ts.map +1 -0
- package/dist/es/presets/animation.js +272 -0
- package/dist/es/presets/index.d.ts +3 -0
- package/dist/es/presets/index.d.ts.map +1 -0
- package/dist/es/primitive/ellipse.d.ts +3 -0
- package/dist/es/primitive/ellipse.d.ts.map +1 -1
- package/dist/es/primitive/group.d.ts +3 -0
- package/dist/es/primitive/group.d.ts.map +1 -1
- package/dist/es/primitive/marker.d.ts +1 -1
- package/dist/es/primitive/paint.d.ts +1 -1
- package/dist/es/primitive/path.d.ts +4 -1
- package/dist/es/primitive/path.d.ts.map +1 -1
- package/dist/es/primitive/rect.d.ts +3 -0
- package/dist/es/primitive/rect.d.ts.map +1 -1
- package/dist/es/primitive/scene.d.ts +3 -0
- package/dist/es/primitive/scene.d.ts.map +1 -1
- package/dist/es/primitive/text.d.ts +3 -0
- package/dist/es/primitive/text.d.ts.map +1 -1
- package/dist/es/shapes/arc.js +2 -2
- package/dist/{lib/shapes/_contour.d.ts → es/shapes/contour.d.ts} +6 -3
- package/dist/es/shapes/contour.d.ts.map +1 -0
- package/dist/es/shapes/{_contour.js → contour.js} +14 -2
- package/dist/es/shapes/ellipse.js +2 -2
- package/dist/es/shapes/index.d.ts +1 -1
- package/dist/es/shapes/index.d.ts.map +1 -1
- package/dist/es/shapes/index.js +1 -1
- package/dist/es/shapes/polygon.d.ts +1 -1
- package/dist/es/shapes/polygon.d.ts.map +1 -1
- package/dist/es/shapes/polygon.js +26 -21
- package/dist/es/shapes/rectangle.js +5 -5
- package/dist/es/shapes/sector.d.ts.map +1 -1
- package/dist/es/shapes/sector.js +30 -22
- package/dist/es/shapes/{_shared.d.ts → shared.d.ts} +4 -8
- package/dist/es/shapes/shared.d.ts.map +1 -0
- package/dist/es/shapes/{_shared.js → shared.js} +8 -12
- package/dist/es/shapes/star.d.ts.map +1 -1
- package/dist/es/shapes/star.js +4 -14
- package/dist/lib/arrows/define.cjs +10 -0
- package/dist/lib/arrows/define.d.ts +9 -0
- package/dist/lib/arrows/define.d.ts.map +1 -0
- package/dist/lib/arrows/index.cjs +14 -1
- package/dist/lib/arrows/index.d.ts +3 -1
- package/dist/lib/arrows/index.d.ts.map +1 -1
- package/dist/lib/arrows/types.d.ts +4 -2
- package/dist/lib/arrows/types.d.ts.map +1 -1
- package/dist/lib/compile/anchor-cache.cjs +17 -4
- package/dist/lib/compile/anchor-cache.d.ts +3 -3
- package/dist/lib/compile/anchor-cache.d.ts.map +1 -1
- package/dist/lib/compile/compile.cjs +71 -39
- package/dist/lib/compile/compile.d.ts +5 -14
- package/dist/lib/compile/compile.d.ts.map +1 -1
- package/dist/lib/compile/{lowerComposites.cjs → composite.cjs} +9 -1
- package/dist/lib/compile/{lowerComposites.d.ts → composite.d.ts} +9 -2
- package/dist/lib/compile/composite.d.ts.map +1 -0
- package/dist/lib/compile/constant.cjs +24 -0
- package/dist/lib/compile/constant.d.ts +32 -0
- package/dist/lib/compile/constant.d.ts.map +1 -0
- package/dist/lib/compile/direction.cjs +31 -0
- package/dist/lib/compile/direction.d.ts +27 -0
- package/dist/lib/compile/direction.d.ts.map +1 -0
- package/dist/lib/compile/index.d.ts +3 -1
- package/dist/lib/compile/index.d.ts.map +1 -1
- package/dist/lib/compile/name-stack.cjs +5 -1
- package/dist/lib/compile/name-stack.d.ts +3 -1
- package/dist/lib/compile/name-stack.d.ts.map +1 -1
- package/dist/lib/compile/node.cjs +42 -62
- package/dist/lib/compile/node.d.ts +20 -7
- package/dist/lib/compile/node.d.ts.map +1 -1
- package/dist/lib/compile/paint.cjs +1 -1
- package/dist/lib/compile/path/anchor.cjs +10 -12
- package/dist/lib/compile/path/anchor.d.ts +4 -3
- package/dist/lib/compile/path/anchor.d.ts.map +1 -1
- package/dist/lib/compile/path/index.cjs +58 -33
- package/dist/lib/compile/path/index.d.ts +6 -8
- package/dist/lib/compile/path/index.d.ts.map +1 -1
- package/dist/lib/compile/path/relative.cjs +1 -1
- package/dist/lib/compile/path/relative.d.ts +1 -1
- package/dist/lib/compile/path/shrink.cjs +16 -11
- package/dist/lib/compile/path/shrink.d.ts +3 -1
- package/dist/lib/compile/path/shrink.d.ts.map +1 -1
- package/dist/lib/compile/position.cjs +6 -19
- package/dist/lib/compile/position.d.ts +2 -2
- package/dist/lib/compile/position.d.ts.map +1 -1
- package/dist/lib/compile/precision.cjs +2 -2
- package/dist/lib/compile/precision.d.ts +1 -1
- package/dist/lib/compile/precision.d.ts.map +1 -1
- package/dist/lib/compile/scope.cjs +29 -13
- package/dist/lib/compile/scope.d.ts +7 -5
- package/dist/lib/compile/scope.d.ts.map +1 -1
- package/dist/lib/compile/style.cjs +2 -2
- package/dist/lib/compile/style.d.ts +2 -2
- package/dist/lib/compile/style.d.ts.map +1 -1
- package/dist/lib/composites/{types.cjs → define.cjs} +2 -2
- package/dist/lib/composites/define.d.ts +8 -0
- package/dist/lib/composites/define.d.ts.map +1 -0
- package/dist/lib/composites/index.d.ts +1 -1
- package/dist/lib/composites/index.d.ts.map +1 -1
- package/dist/lib/composites/types.d.ts +0 -6
- package/dist/lib/composites/types.d.ts.map +1 -1
- package/dist/lib/geometry/anchor.cjs +47 -0
- package/dist/lib/geometry/anchor.d.ts +33 -0
- package/dist/lib/geometry/anchor.d.ts.map +1 -0
- package/dist/lib/geometry/bend.cjs +2 -2
- package/dist/lib/geometry/bend.d.ts +1 -1
- package/dist/lib/geometry/circle.cjs +9 -9
- package/dist/lib/geometry/circle.d.ts +4 -4
- package/dist/lib/geometry/circle.d.ts.map +1 -1
- package/dist/lib/geometry/{roundedContour.cjs → contour.cjs} +21 -32
- package/dist/lib/geometry/{roundedContour.d.ts → contour.d.ts} +4 -5
- package/dist/lib/geometry/contour.d.ts.map +1 -0
- package/dist/lib/geometry/diamond.cjs +7 -7
- package/dist/lib/geometry/diamond.d.ts +3 -3
- package/dist/lib/geometry/diamond.d.ts.map +1 -1
- package/dist/lib/geometry/{_edge.cjs → edge.cjs} +1 -1
- package/dist/{es/geometry/_edge.d.ts → lib/geometry/edge.d.ts} +1 -1
- package/dist/lib/geometry/edge.d.ts.map +1 -0
- package/dist/lib/geometry/ellipse.cjs +8 -8
- package/dist/lib/geometry/ellipse.d.ts +3 -3
- package/dist/lib/geometry/ellipse.d.ts.map +1 -1
- package/dist/lib/geometry/index.d.ts +2 -1
- package/dist/lib/geometry/index.d.ts.map +1 -1
- package/dist/lib/geometry/point.cjs +17 -0
- package/dist/lib/geometry/point.d.ts +6 -0
- package/dist/lib/geometry/point.d.ts.map +1 -1
- package/dist/lib/geometry/rect.cjs +9 -22
- package/dist/lib/geometry/rect.d.ts +4 -17
- package/dist/lib/geometry/rect.d.ts.map +1 -1
- package/dist/lib/geometry/segment.cjs +25 -47
- package/dist/lib/geometry/segment.d.ts.map +1 -1
- package/dist/lib/geometry/{_transform.cjs → transform.cjs} +1 -1
- package/dist/{es/geometry/_transform.d.ts → lib/geometry/transform.d.ts} +1 -1
- package/dist/lib/geometry/transform.d.ts.map +1 -0
- package/dist/lib/index.cjs +56 -22
- package/dist/lib/index.d.ts +13 -10
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/ir/animation.cjs +127 -0
- package/dist/lib/ir/animation.d.ts +219 -0
- package/dist/lib/ir/animation.d.ts.map +1 -0
- package/dist/lib/ir/boundary.d.ts +1 -1
- package/dist/lib/ir/boundary.d.ts.map +1 -1
- package/dist/lib/ir/coordinate.d.ts +8 -8
- package/dist/lib/ir/index.d.ts +1 -0
- package/dist/lib/ir/index.d.ts.map +1 -1
- package/dist/lib/ir/node.cjs +25 -23
- package/dist/lib/ir/node.d.ts +249 -92
- package/dist/lib/ir/node.d.ts.map +1 -1
- package/dist/lib/ir/paint.cjs +10 -10
- package/dist/lib/ir/paint.d.ts +19 -18
- package/dist/lib/ir/paint.d.ts.map +1 -1
- package/dist/lib/ir/path/arrow.cjs +18 -16
- package/dist/lib/ir/path/arrow.d.ts +39 -38
- package/dist/lib/ir/path/arrow.d.ts.map +1 -1
- package/dist/lib/ir/path/path.cjs +3 -1
- package/dist/lib/ir/path/path.d.ts +1106 -209
- package/dist/lib/ir/path/path.d.ts.map +1 -1
- package/dist/lib/ir/path/step.cjs +73 -21
- package/dist/lib/ir/path/step.d.ts +932 -20
- package/dist/lib/ir/path/step.d.ts.map +1 -1
- package/dist/lib/ir/path/target.cjs +3 -3
- package/dist/lib/ir/position/at-position.cjs +11 -11
- package/dist/lib/ir/position/at-position.d.ts +18 -18
- package/dist/lib/ir/position/at-position.d.ts.map +1 -1
- package/dist/lib/ir/scene.cjs +3 -1
- package/dist/lib/ir/scene.d.ts +156 -0
- package/dist/lib/ir/scene.d.ts.map +1 -1
- package/dist/lib/ir/scope.cjs +10 -6
- package/dist/lib/ir/scope.d.ts +3446 -1306
- package/dist/lib/ir/scope.d.ts.map +1 -1
- package/dist/lib/ir/transform.cjs +9 -2
- package/dist/lib/ir/transform.d.ts +44 -17
- package/dist/lib/ir/transform.d.ts.map +1 -1
- package/dist/lib/parsers/index.d.ts +3 -3
- package/dist/lib/parsers/index.d.ts.map +1 -1
- package/dist/lib/parsers/{parseNodeTarget.cjs → node-target.cjs} +10 -8
- package/dist/lib/parsers/{parseNodeTarget.d.ts → node-target.d.ts} +1 -1
- package/dist/lib/parsers/node-target.d.ts.map +1 -0
- package/dist/lib/parsers/{parseTargetSugar.cjs → target-sugar.cjs} +9 -4
- package/dist/{es/parsers/parseTargetSugar.d.ts → lib/parsers/target-sugar.d.ts} +1 -1
- package/dist/lib/parsers/target-sugar.d.ts.map +1 -0
- package/dist/lib/parsers/{parseWay.cjs → way.cjs} +12 -8
- package/dist/{es/parsers/parseWay.d.ts → lib/parsers/way.d.ts} +1 -1
- package/dist/lib/parsers/way.d.ts.map +1 -0
- package/dist/lib/{pathGenerators → path-generators}/define.cjs +1 -1
- package/dist/lib/path-generators/define.d.ts.map +1 -0
- package/dist/lib/path-generators/index.d.ts.map +1 -0
- package/dist/lib/path-generators/types.d.ts.map +1 -0
- package/dist/lib/patterns/define.cjs +10 -0
- package/dist/lib/patterns/define.d.ts +9 -0
- package/dist/lib/patterns/define.d.ts.map +1 -0
- package/dist/lib/patterns/index.cjs +42 -35
- package/dist/lib/patterns/index.d.ts +1 -0
- package/dist/lib/patterns/index.d.ts.map +1 -1
- package/dist/lib/presets/animation.cjs +286 -0
- package/dist/lib/presets/animation.d.ts +123 -0
- package/dist/lib/presets/animation.d.ts.map +1 -0
- package/dist/lib/presets/index.d.ts +3 -0
- package/dist/lib/presets/index.d.ts.map +1 -0
- package/dist/lib/primitive/ellipse.d.ts +3 -0
- package/dist/lib/primitive/ellipse.d.ts.map +1 -1
- package/dist/lib/primitive/group.d.ts +3 -0
- package/dist/lib/primitive/group.d.ts.map +1 -1
- package/dist/lib/primitive/marker.d.ts +1 -1
- package/dist/lib/primitive/paint.d.ts +1 -1
- package/dist/lib/primitive/path.d.ts +4 -1
- package/dist/lib/primitive/path.d.ts.map +1 -1
- package/dist/lib/primitive/rect.d.ts +3 -0
- package/dist/lib/primitive/rect.d.ts.map +1 -1
- package/dist/lib/primitive/scene.d.ts +3 -0
- package/dist/lib/primitive/scene.d.ts.map +1 -1
- package/dist/lib/primitive/text.d.ts +3 -0
- package/dist/lib/primitive/text.d.ts.map +1 -1
- package/dist/lib/shapes/arc.cjs +4 -4
- package/dist/lib/shapes/{_contour.cjs → contour.cjs} +14 -1
- package/dist/{es/shapes/_contour.d.ts → lib/shapes/contour.d.ts} +6 -3
- package/dist/lib/shapes/contour.d.ts.map +1 -0
- package/dist/lib/shapes/ellipse.cjs +2 -2
- package/dist/lib/shapes/index.cjs +1 -1
- package/dist/lib/shapes/index.d.ts +1 -1
- package/dist/lib/shapes/index.d.ts.map +1 -1
- package/dist/lib/shapes/polygon.cjs +29 -24
- package/dist/lib/shapes/polygon.d.ts +1 -1
- package/dist/lib/shapes/polygon.d.ts.map +1 -1
- package/dist/lib/shapes/rectangle.cjs +11 -11
- package/dist/lib/shapes/sector.cjs +41 -33
- package/dist/lib/shapes/sector.d.ts.map +1 -1
- package/dist/lib/shapes/{_shared.cjs → shared.cjs} +7 -12
- package/dist/lib/shapes/{_shared.d.ts → shared.d.ts} +4 -8
- package/dist/lib/shapes/shared.d.ts.map +1 -0
- package/dist/lib/shapes/star.cjs +7 -17
- package/dist/lib/shapes/star.d.ts.map +1 -1
- package/package.json +2 -3
- package/dist/es/compile/lowerComposites.d.ts.map +0 -1
- package/dist/es/geometry/_edge.d.ts.map +0 -1
- package/dist/es/geometry/_transform.d.ts.map +0 -1
- package/dist/es/geometry/roundedContour.d.ts.map +0 -1
- package/dist/es/parsers/parseNodeTarget.d.ts.map +0 -1
- package/dist/es/parsers/parseTargetSugar.d.ts.map +0 -1
- package/dist/es/parsers/parseWay.d.ts.map +0 -1
- package/dist/es/pathGenerators/define.d.ts.map +0 -1
- package/dist/es/pathGenerators/index.d.ts.map +0 -1
- package/dist/es/pathGenerators/types.d.ts.map +0 -1
- package/dist/es/shapes/_contour.d.ts.map +0 -1
- package/dist/es/shapes/_shared.d.ts.map +0 -1
- package/dist/lib/compile/lowerComposites.d.ts.map +0 -1
- package/dist/lib/geometry/_edge.d.ts.map +0 -1
- package/dist/lib/geometry/_transform.d.ts.map +0 -1
- package/dist/lib/geometry/roundedContour.d.ts.map +0 -1
- package/dist/lib/parsers/parseNodeTarget.d.ts.map +0 -1
- package/dist/lib/parsers/parseTargetSugar.d.ts.map +0 -1
- package/dist/lib/parsers/parseWay.d.ts.map +0 -1
- package/dist/lib/pathGenerators/define.d.ts.map +0 -1
- package/dist/lib/pathGenerators/index.d.ts.map +0 -1
- package/dist/lib/pathGenerators/types.d.ts.map +0 -1
- package/dist/lib/shapes/_contour.d.ts.map +0 -1
- package/dist/lib/shapes/_shared.d.ts.map +0 -1
- /package/dist/es/{pathGenerators → path-generators}/define.d.ts +0 -0
- /package/dist/es/{pathGenerators → path-generators}/index.d.ts +0 -0
- /package/dist/es/{pathGenerators → path-generators}/types.d.ts +0 -0
- /package/dist/lib/{pathGenerators → path-generators}/define.d.ts +0 -0
- /package/dist/lib/{pathGenerators → path-generators}/index.d.ts +0 -0
- /package/dist/lib/{pathGenerators → path-generators}/types.d.ts +0 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ArrowDefinition } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* 定义一个 arrow 注册项
|
|
4
|
+
* @description 与 `defineShape` / `definePathGenerator` 对齐的定义点 helper;当前不做额外运行时校验,
|
|
5
|
+
* 只保留 `ArrowDefinition` 形态并让第三方扩展面写法一致。
|
|
6
|
+
* @returns 原样返回的 def(便于 `export const bracket = defineArrow({ ... })`)
|
|
7
|
+
*/
|
|
8
|
+
export declare const defineArrow: (def: ArrowDefinition) => ArrowDefinition;
|
|
9
|
+
//# sourceMappingURL=define.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define.d.ts","sourceRoot":"","sources":["../../../src/arrows/define.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GAAI,KAAK,eAAe,KAAG,eAAsB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/arrows/define.ts
|
|
2
|
+
/**
|
|
3
|
+
* 定义一个 arrow 注册项
|
|
4
|
+
* @description 与 `defineShape` / `definePathGenerator` 对齐的定义点 helper;当前不做额外运行时校验,
|
|
5
|
+
* 只保留 `ArrowDefinition` 形态并让第三方扩展面写法一致。
|
|
6
|
+
* @returns 原样返回的 def(便于 `export const bracket = defineArrow({ ... })`)
|
|
7
|
+
*/
|
|
8
|
+
var defineArrow = (def) => def;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { defineArrow };
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { BuiltinArrowName } from '../ir/path/arrow';
|
|
2
2
|
import { ArrowDefinition } from './types';
|
|
3
3
|
/**
|
|
4
|
-
* 内置
|
|
4
|
+
* 内置 8 arrow 注册项;与 `CompileOptions.arrows` 合并时被同名注入覆盖
|
|
5
5
|
* @description 几何字段(lineContactX 静态 base / tipX / hollow):
|
|
6
6
|
* 实心 normal/diamond/circle lineContactX=0;stealth=3;open/openDiamond base=1 + tipX=9 + hollow;
|
|
7
|
+
* openStealth base=3 + tipX=9 + hollow;
|
|
7
8
|
* openCircle base=0.75 + hollow。baseSize / defaultLength / defaultWidth 走类型缺省(10 / 6 / 6)。
|
|
8
9
|
* framework 对 hollow def 统一把 lineContactX 减 lineWidth/2 得实际 refX / shrink 接触点。
|
|
9
10
|
* emit 几何在局部 baseSize=10 坐标系(renderer-agnostic)。
|
|
10
11
|
*/
|
|
11
12
|
export declare const BUILTIN_ARROWS: Record<BuiltinArrowName, ArrowDefinition>;
|
|
12
13
|
export type { ArrowDefinition, ArrowEmitContext } from './types';
|
|
14
|
+
export { defineArrow } from './define';
|
|
13
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/arrows/index.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAoB,MAAM,SAAS,CAAC;AAiCjE
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/arrows/index.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAoB,MAAM,SAAS,CAAC;AAiCjE;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,gBAAgB,EAAE,eAAe,CA2DpE,CAAC;AAEF,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/es/arrows/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import "./define.js";
|
|
1
2
|
//#region src/arrows/index.ts
|
|
2
3
|
/** 实心闭合三角 / 菱形 / V 形的 path 工厂:填充走 ctx.fill(无 override = contextStroke) */
|
|
3
4
|
var filledPath = (ctx, points) => ({
|
|
@@ -34,9 +35,10 @@ var hollowPath = (ctx, points, strokeLinejoin) => ({
|
|
|
34
35
|
...strokeLinejoin ? { strokeLinejoin } : {}
|
|
35
36
|
});
|
|
36
37
|
/**
|
|
37
|
-
* 内置
|
|
38
|
+
* 内置 8 arrow 注册项;与 `CompileOptions.arrows` 合并时被同名注入覆盖
|
|
38
39
|
* @description 几何字段(lineContactX 静态 base / tipX / hollow):
|
|
39
40
|
* 实心 normal/diamond/circle lineContactX=0;stealth=3;open/openDiamond base=1 + tipX=9 + hollow;
|
|
41
|
+
* openStealth base=3 + tipX=9 + hollow;
|
|
40
42
|
* openCircle base=0.75 + hollow。baseSize / defaultLength / defaultWidth 走类型缺省(10 / 6 / 6)。
|
|
41
43
|
* framework 对 hollow def 统一把 lineContactX 减 lineWidth/2 得实际 refX / shrink 接触点。
|
|
42
44
|
* emit 几何在局部 baseSize=10 坐标系(renderer-agnostic)。
|
|
@@ -69,6 +71,17 @@ var BUILTIN_ARROWS = {
|
|
|
69
71
|
[3, 5]
|
|
70
72
|
])]
|
|
71
73
|
},
|
|
74
|
+
openStealth: {
|
|
75
|
+
hollow: true,
|
|
76
|
+
lineContactX: 3,
|
|
77
|
+
tipX: 9,
|
|
78
|
+
emit: (ctx) => [hollowPath(ctx, [
|
|
79
|
+
[1, 1],
|
|
80
|
+
[9, 5],
|
|
81
|
+
[1, 9],
|
|
82
|
+
[3, 5]
|
|
83
|
+
], "miter")]
|
|
84
|
+
},
|
|
72
85
|
diamond: {
|
|
73
86
|
lineContactX: 0,
|
|
74
87
|
emit: (ctx) => [filledPath(ctx, [
|
|
@@ -18,10 +18,10 @@ export type ArrowEmitContext = {
|
|
|
18
18
|
/**
|
|
19
19
|
* 一个 arrow 的可注册定义:几何尺寸 + emit
|
|
20
20
|
* @description plain object(factory 友好),含函数、**不进 IR**,走 `CompileOptions.arrows` 运行时注入。
|
|
21
|
-
* 内置
|
|
21
|
+
* 内置 8 箭头也是注册项(无内置特权,对齐 `ShapeDefinition` / `BUILTIN_SHAPES`)。
|
|
22
22
|
*
|
|
23
23
|
* `lineContactX` 存**静态 base**(不含 lineWidth 调整):实心 normal/diamond/circle = 0、stealth = 3、
|
|
24
|
-
* open/openDiamond base = 1、openCircle base = 0.75。framework 对 `hollow: true` 的 def 统一减
|
|
24
|
+
* open/openDiamond base = 1、openStealth base = 3、openCircle base = 0.75。framework 对 `hollow: true` 的 def 统一减
|
|
25
25
|
* `lineWidth/2` 得到实际 refX / shrink 接触点(这条调整由编译器 / adapter 落,def 只声明静态 base)。
|
|
26
26
|
*/
|
|
27
27
|
export type ArrowDefinition = {
|
|
@@ -31,6 +31,8 @@ export type ArrowDefinition = {
|
|
|
31
31
|
hollow?: boolean;
|
|
32
32
|
/** 线接触点静态 base(决定 path shrink + marker refX);空心 def 由 framework 再减 lineWidth/2 */
|
|
33
33
|
lineContactX: number;
|
|
34
|
+
/** 外轮廓补偿量(marker 局部坐标);缺省时空心箭头用 lineWidth/2,实心箭头用 0 */
|
|
35
|
+
outerInset?: number;
|
|
34
36
|
/** 尖端 x(shrink 用);缺省 = baseSize */
|
|
35
37
|
tipX?: number;
|
|
36
38
|
/** 默认箭头长度(length fallback);缺省 6 */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/arrows/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEvE;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,sEAAsE;IACtE,MAAM,EAAE,UAAU,CAAC;IACnB,qDAAqD;IACrD,IAAI,EAAE,UAAU,CAAC;IACjB,8CAA8C;IAC9C,SAAS,EAAE,MAAM,CAAC;IAClB,8CAA8C;IAC9C,KAAK,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;CAC9B,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,yFAAyF;IACzF,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,kFAAkF;IAClF,YAAY,EAAE,MAAM,CAAC;IACrB,mCAAmC;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,mCAAmC;IACnC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,kCAAkC;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iEAAiE;IACjE,IAAI,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,QAAQ,CAAC,eAAe,CAAC,CAAC;CAC5D,CAAC"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/arrows/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEvE;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,sEAAsE;IACtE,MAAM,EAAE,UAAU,CAAC;IACnB,qDAAqD;IACrD,IAAI,EAAE,UAAU,CAAC;IACjB,8CAA8C;IAC9C,SAAS,EAAE,MAAM,CAAC;IAClB,8CAA8C;IAC9C,KAAK,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;CAC9B,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,yFAAyF;IACzF,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,kFAAkF;IAClF,YAAY,EAAE,MAAM,CAAC;IACrB,uDAAuD;IACvD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mCAAmC;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,mCAAmC;IACnC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,kCAAkC;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iEAAiE;IACjE,IAAI,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,QAAQ,CAAC,eAAe,CAAC,CAAC;CAC5D,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Side } from '../geometry/
|
|
1
|
+
import { Side } from '../geometry/edge';
|
|
2
2
|
import { IRBoundary, IRPosition } from '../ir';
|
|
3
3
|
import { NodeLayout } from './node';
|
|
4
4
|
/**
|
|
5
5
|
* 取节点 anchor 的全局坐标,带 per-layout 缓存
|
|
6
|
-
* @description name
|
|
6
|
+
* @description name 接受方位 anchor 关键字(如 `'north'` / `'south-west'` / `'top-left'`)或数字角度字符串(如 `'30'` / `'-45'`);
|
|
7
7
|
* boundary 指定连接面(默认 `'shape'`,即节点自身视觉轮廓);不同 boundary 产生独立缓存条目,互不串扰;
|
|
8
8
|
* 同一 (layout, name, boundary) 组合第二次起返回首调用结果的**同一引用**——上游可用 `===` 判定 cache 命中
|
|
9
9
|
* @param layout 已 Pass 1 完成的 NodeLayout(rect 已是全局坐标)
|
|
@@ -15,7 +15,7 @@ export declare const resolveAnchor: (layout: NodeLayout, anchorName: string, bou
|
|
|
15
15
|
/**
|
|
16
16
|
* 取节点边上比例点 `{ side, t }` 的全局坐标,带 per-layout 缓存
|
|
17
17
|
* @description 走 `layout.shapeDef.edgePoint`——shape 未实现(如自定义 shape)抛"does not support side anchors";
|
|
18
|
-
* 零尺寸 layout(Coordinate
|
|
18
|
+
* 零尺寸 layout(Coordinate)抛错(边上比例点对一个点无意义,报错比退化中心更可诊断)。
|
|
19
19
|
* 缓存 key = `${side}:${t}`,与命名 anchor(`'north'` / `'30'`)共用 layout 的 Map——key 含 `:` 故命名空间不冲突。
|
|
20
20
|
* @param layout 已 Pass 1 完成的 NodeLayout(rect 已是全局坐标)
|
|
21
21
|
* @returns 全局坐标系下的 IRPosition `[x, y]`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anchor-cache.d.ts","sourceRoot":"","sources":["../../../src/compile/anchor-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"anchor-cache.d.ts","sourceRoot":"","sources":["../../../src/compile/anchor-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAEpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AA8CzC;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,GACxB,QAAQ,UAAU,EAClB,YAAY,MAAM,EAClB,WAAU,UAAU,GAAG,SAAmB,KACzC,UAYF,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,GAC3B,QAAQ,UAAU,EAClB,MAAM,IAAI,EACV,GAAG,MAAM,KACR,UAuBF,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { normalizeCompassAnchor } from "../geometry/anchor.js";
|
|
1
2
|
import { boundaryKey } from "./boundary.js";
|
|
2
|
-
import { anchorOf, angleBoundaryOf } from "./node.js";
|
|
3
|
+
import { anchorOf, angleBoundaryOf, outerRectOf } from "./node.js";
|
|
3
4
|
//#region src/compile/anchor-cache.ts
|
|
4
5
|
/**
|
|
5
6
|
* (layout, anchorName) → IRPosition 缓存
|
|
@@ -8,19 +9,31 @@ import { anchorOf, angleBoundaryOf } from "./node.js";
|
|
|
8
9
|
var cache = /* @__PURE__ */ new WeakMap();
|
|
9
10
|
/** 角度字符串识别:可选负号 + 数字 + 可选小数;与 parseTarget.ts 的 ANGLE_RE 同语义 */
|
|
10
11
|
var ANGLE_RE = /^-?\d+(\.\d+)?$/;
|
|
12
|
+
/** 把 layout 的 rect 换成外边界 AABB(外扩 outerSep)——border 类 anchor 在其上解析(ADR-07 §1) */
|
|
13
|
+
var withOuterRect = (layout) => ({
|
|
14
|
+
...layout,
|
|
15
|
+
rect: outerRectOf(layout)
|
|
16
|
+
});
|
|
11
17
|
/**
|
|
12
18
|
* 把 anchorName 解析到对应 shape 的 anchor / boundaryPoint 上
|
|
13
|
-
* @description 数字字符串走 angleBoundaryOf
|
|
19
|
+
* @description 数字字符串走 angleBoundaryOf;其余按标准方位 / shape-specific anchor 走 anchorOf;boundary 透传给两者。
|
|
20
|
+
* border 类 anchor(数字角度 + compass 方位名)按 outerSep 外推:在外扩 margin 的 rect(`outerRectOf`)上解析
|
|
21
|
+
* (ADR-07 §1)。形状专属命名 anchor(tip-N / apex 等)恒走视觉 rect、不外扩(§3)。`center` 在 inflate 下
|
|
22
|
+
* 中心不变,走哪条路结果一致。
|
|
14
23
|
*/
|
|
15
24
|
var computeAnchor = (layout, anchorName, boundary) => {
|
|
16
|
-
if (ANGLE_RE.test(anchorName))
|
|
25
|
+
if (ANGLE_RE.test(anchorName)) {
|
|
26
|
+
const angle = Number(anchorName);
|
|
27
|
+
return positionToIR(angleBoundaryOf(withOuterRect(layout), angle, boundary));
|
|
28
|
+
}
|
|
29
|
+
if (normalizeCompassAnchor(anchorName) !== void 0) return positionToIR(anchorOf(withOuterRect(layout), anchorName, boundary));
|
|
17
30
|
return positionToIR(anchorOf(layout, anchorName, boundary));
|
|
18
31
|
};
|
|
19
32
|
/** geometry Position(含 readonly 形态)转 IRPosition 元组(IRPosition === [number, number]) */
|
|
20
33
|
var positionToIR = (p) => [p[0], p[1]];
|
|
21
34
|
/**
|
|
22
35
|
* 取节点 anchor 的全局坐标,带 per-layout 缓存
|
|
23
|
-
* @description name
|
|
36
|
+
* @description name 接受方位 anchor 关键字(如 `'north'` / `'south-west'` / `'top-left'`)或数字角度字符串(如 `'30'` / `'-45'`);
|
|
24
37
|
* boundary 指定连接面(默认 `'shape'`,即节点自身视觉轮廓);不同 boundary 产生独立缓存条目,互不串扰;
|
|
25
38
|
* 同一 (layout, name, boundary) 组合第二次起返回首调用结果的**同一引用**——上游可用 `===` 判定 cache 命中
|
|
26
39
|
* @param layout 已 Pass 1 完成的 NodeLayout(rect 已是全局坐标)
|
|
@@ -44,7 +57,7 @@ var resolveAnchor = (layout, anchorName, boundary = "shape") => {
|
|
|
44
57
|
/**
|
|
45
58
|
* 取节点边上比例点 `{ side, t }` 的全局坐标,带 per-layout 缓存
|
|
46
59
|
* @description 走 `layout.shapeDef.edgePoint`——shape 未实现(如自定义 shape)抛"does not support side anchors";
|
|
47
|
-
* 零尺寸 layout(Coordinate
|
|
60
|
+
* 零尺寸 layout(Coordinate)抛错(边上比例点对一个点无意义,报错比退化中心更可诊断)。
|
|
48
61
|
* 缓存 key = `${side}:${t}`,与命名 anchor(`'north'` / `'30'`)共用 layout 的 Map——key 含 `:` 故命名空间不冲突。
|
|
49
62
|
* @param layout 已 Pass 1 完成的 NodeLayout(rect 已是全局坐标)
|
|
50
63
|
* @returns 全局坐标系下的 IRPosition `[x, y]`
|
|
@@ -3,21 +3,12 @@ import { Scene } from '../primitive';
|
|
|
3
3
|
import { ShapeDefinition } from '../shapes';
|
|
4
4
|
import { ArrowDefinition } from '../arrows';
|
|
5
5
|
import { PatternDefinition } from '../patterns';
|
|
6
|
-
import { PathGeneratorDefinition } from '../
|
|
6
|
+
import { PathGeneratorDefinition } from '../path-generators';
|
|
7
7
|
import { CompositeDefinition } from '../composites';
|
|
8
|
+
import { CompileWarning } from './constant';
|
|
8
9
|
import { TextMeasurer } from './text-metrics';
|
|
9
|
-
|
|
10
|
-
export
|
|
11
|
-
/**
|
|
12
|
-
* 警告类型代码(机器可读)
|
|
13
|
-
* @description 用户可按 code 分支处理;未来 alpha 加新 code 不破坏调用方
|
|
14
|
-
*/
|
|
15
|
-
code: 'UNRESOLVED_NODE_REFERENCE' | 'PATH_TOO_SHORT' | 'ANCHOR_RESOLUTION_FAILED' | 'OFFSET_BASE_UNRESOLVED' | 'POLAR_ORIGIN_UNRESOLVED' | 'AT_TARGET_UNRESOLVED' | 'RELATIVE_INITIAL_NO_PREV_END' | 'BBOX_EXTREME_INPUT' | 'DUPLICATE_NODE_ID' | 'SHAPE_OVERRIDES_BUILTIN' | 'ARROW_OVERRIDES_BUILTIN' | 'PATTERN_OVERRIDES_BUILTIN' | 'COMPOSITE_NOT_REGISTERED' | (string & {});
|
|
16
|
-
/** 人类可读消息(英文) */
|
|
17
|
-
message: string;
|
|
18
|
-
/** IR locator 路径(jq-like,如 `'children[3].path.children[1].to'`) */
|
|
19
|
-
path: string;
|
|
20
|
-
};
|
|
10
|
+
export type { CompileWarning } from './constant';
|
|
11
|
+
export { CompileWarningCode } from './constant';
|
|
21
12
|
/** compileToScene 的可选参数 */
|
|
22
13
|
export type CompileOptions = {
|
|
23
14
|
/** 注入文字度量函数;不传则用 fallback(不准但可跑) */
|
|
@@ -81,7 +72,7 @@ export type CompileOptions = {
|
|
|
81
72
|
};
|
|
82
73
|
/**
|
|
83
74
|
* IR → Scene 纯函数转换,所有 adapter 共享
|
|
84
|
-
* @description Pass 1 递归处理 node / coordinate / scope,把 scope 树下沉为嵌套 GroupPrim;scope.transforms 中的
|
|
75
|
+
* @description Pass 1 递归处理 node / coordinate / scope,把 scope 树下沉为嵌套 GroupPrim;scope.transforms 中的 5 种 translate 变体按 lowerScopeTransforms 展平为 Cartesian transform;node 在 Scene primitive 树里是局部坐标 + GroupPrim transform 链、在 NameStack 中存全局坐标供其他节点 / path 引用。NameStack 用栈式 frame 管理命名空间:默认全局扁平、`<Scope localNamespace>` 推入子 frame;scope.id 始终在父 frame 注册(外部句柄);id lookup 从栈顶向栈底 inside-out 搜索;同 frame 重复 id 触发 DUPLICATE_NODE_ID warn + 后定义覆盖前定义。Pass 2 解析 path 端点写 d 字符串,path primitive 发到 Pass 1 记录的对应容器;末端按 precision 折算 layout
|
|
85
76
|
*/
|
|
86
77
|
export declare const compileToScene: (ir: IR, options?: CompileOptions) => Scene;
|
|
87
78
|
//# sourceMappingURL=compile.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../../src/compile/compile.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../../src/compile/compile.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAA0D,MAAM,OAAO,CAAC;AACxF,OAAO,KAAK,EAAa,KAAK,EAA6B,MAAM,cAAc,CAAC;AAEhF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAEjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAEjD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EACL,KAAK,cAAc,EAGpB,MAAM,YAAY,CAAC;AAuBpB,OAAO,EAAE,KAAK,YAAY,EAAoB,MAAM,gBAAgB,CAAC;AAGrE,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAoDhD,2BAA2B;AAC3B,MAAM,MAAM,cAAc,GAAG;IAC3B,oCAAoC;IACpC,WAAW,CAAC,EAAE,YAAY,CAAC;IAC3B,qCAAqC;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,IAAI,CAAC;IAC3C;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IACzC;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IACzC;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAC7C;;;;;;;OAOG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAC;IACzD;;;;OAIG;IACH,UAAU,CAAC,EAAE,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACxC;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAuLF;;;GAGG;AACH,eAAO,MAAM,cAAc,GAAI,IAAI,EAAE,EAAE,UAAS,cAAmB,KAAG,KAkXrE,CAAC"}
|
|
@@ -2,18 +2,19 @@ import { rect } from "../geometry/rect.js";
|
|
|
2
2
|
import { BUILTIN_SHAPES } from "../shapes/index.js";
|
|
3
3
|
import { BUILTIN_ARROWS } from "../arrows/index.js";
|
|
4
4
|
import { BUILTIN_PATTERNS } from "../patterns/index.js";
|
|
5
|
-
import {
|
|
5
|
+
import { CompileWarningCode, formatCompileWarning } from "./constant.js";
|
|
6
|
+
import { lowerComposites } from "./composite.js";
|
|
6
7
|
import { NameStack } from "./name-stack.js";
|
|
7
8
|
import { applyTransformChain, computeScopeBoundingBox, lowerScopeTransforms, projectLayoutToGlobal, registerScopeAsLayout } from "./scope.js";
|
|
8
9
|
import { resolvePosition } from "./position.js";
|
|
9
|
-
import { emitNodePrimitives, labelExtentPoints, layoutNode } from "./node.js";
|
|
10
|
+
import { emitNodePrimitives, labelExtentPoints, layoutNode, outerRectOf } from "./node.js";
|
|
10
11
|
import { createPaintRegistry } from "./paint.js";
|
|
11
12
|
import { createClipRegistry } from "./clip.js";
|
|
12
13
|
import { fallbackMeasurer } from "./text-metrics.js";
|
|
13
14
|
import { refPointOfTarget } from "./path/anchor.js";
|
|
14
15
|
import { emitPathPrimitive } from "./path/index.js";
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
16
|
+
import { createRound } from "./precision.js";
|
|
17
|
+
import { createStyleFrame, resolveEffectivePath, resolveLabelDefault, resolveNodeStyle } from "./style.js";
|
|
17
18
|
import { computeLayout } from "./layout.js";
|
|
18
19
|
//#region src/compile/compile.ts
|
|
19
20
|
/**
|
|
@@ -21,10 +22,10 @@ import { computeLayout } from "./layout.js";
|
|
|
21
22
|
* @description coordinate / scope.id 入场临时占位等"无形状只有位置"句柄共享此结构,
|
|
22
23
|
* 让后续 path target / `at.of` / `offset.of` / `polar.origin` 引用时 boundaryPoint 命中中心。
|
|
23
24
|
*/
|
|
24
|
-
var zeroSizeRectAt = (id, [cx, cy]) => ({
|
|
25
|
+
var zeroSizeRectAt = (id, [cx, cy], shapes) => ({
|
|
25
26
|
id,
|
|
26
27
|
shapeName: "rectangle",
|
|
27
|
-
shapeDef:
|
|
28
|
+
shapeDef: shapes.rectangle,
|
|
28
29
|
rect: {
|
|
29
30
|
x: cx,
|
|
30
31
|
y: cy,
|
|
@@ -39,21 +40,21 @@ var zeroSizeRectAt = (id, [cx, cy]) => ({
|
|
|
39
40
|
align: "middle",
|
|
40
41
|
lineHeight: 0,
|
|
41
42
|
fontSize: 0,
|
|
42
|
-
shapes
|
|
43
|
+
shapes
|
|
43
44
|
});
|
|
44
45
|
/**
|
|
45
46
|
* 把 coordinate 注册成 0×0 NodeLayout
|
|
46
47
|
* @description 让后续 path target / `at.of` 引用时 boundaryPoint 命中中心,符合"占位无形状边界"语义
|
|
47
48
|
*/
|
|
48
|
-
var coordinateAsLayout = (id, center) => zeroSizeRectAt(id, center);
|
|
49
|
+
var coordinateAsLayout = (id, center, shapes) => zeroSizeRectAt(id, center, shapes);
|
|
49
50
|
/**
|
|
50
51
|
* scope.id 入场时的临时占位 NodeLayout
|
|
51
52
|
* @description scope 子树尚未处理时先放 0×0 占位(落在 scope 局部原点经累积 chain 投到全局的位置),
|
|
52
53
|
* 让 scope 子树内任何 lookup 不返回 undefined(占位语义自洽)。
|
|
53
54
|
* 子树 Pass 1 处理完毕后由 `registerScopeAsLayout` 算出真 bbox layout 覆盖此占位(NameStack.replaceLayout 不发 duplicate warn)
|
|
54
55
|
*/
|
|
55
|
-
var scopePlaceholderLayout = (id, chain) => {
|
|
56
|
-
return zeroSizeRectAt(id, chain.length === 0 ? [0, 0] : applyTransformChain([0, 0], chain));
|
|
56
|
+
var scopePlaceholderLayout = (id, chain, shapes) => {
|
|
57
|
+
return zeroSizeRectAt(id, chain.length === 0 ? [0, 0] : applyTransformChain([0, 0], chain), shapes);
|
|
57
58
|
};
|
|
58
59
|
/**
|
|
59
60
|
* 显式 viewBox → Scene.layout(finite 守卫 + round)
|
|
@@ -93,7 +94,27 @@ var assertFiniteLayout = (layout) => {
|
|
|
93
94
|
*/
|
|
94
95
|
var defaultWarnDispatcher = (warning) => {
|
|
95
96
|
if (typeof process !== "undefined" && process.env.NODE_ENV === "production") return;
|
|
96
|
-
console.warn(
|
|
97
|
+
console.warn(formatCompileWarning(warning));
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* 校验 animation tracks 的 viewBox⇔根 约束(schema 上下文无关、分不清元素 vs 根,故在此 compile 层做)
|
|
101
|
+
* @description `viewBox`(镜头)只在 scene 根合法、元素级非法;scene 根只接受 `viewBox`。违例 track → `warn(ANIMATION_INVALID_PROPERTY)` + drop(不丢图、不影响其余 track)。全空返回 undefined(不 stamp 空数组)。
|
|
102
|
+
*/
|
|
103
|
+
var filterAnimations = (tracks, context, onWarn, irPath) => {
|
|
104
|
+
if (tracks === void 0) return void 0;
|
|
105
|
+
const kept = tracks.filter((track, index) => {
|
|
106
|
+
const isViewBox = track.property === "viewBox";
|
|
107
|
+
if (!(context === "root" ? isViewBox : !isViewBox)) {
|
|
108
|
+
onWarn({
|
|
109
|
+
code: CompileWarningCode.AnimationInvalidProperty,
|
|
110
|
+
message: context === "root" ? `Scene-root animation must use the "viewBox" property (camera); got "${track.property}". Track dropped.` : `Animation property "viewBox" is camera-only (scene root), not valid on an element. Track dropped.`,
|
|
111
|
+
path: `${irPath}.animations[${index}]`
|
|
112
|
+
});
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
return true;
|
|
116
|
+
});
|
|
117
|
+
return kept.length > 0 ? kept : void 0;
|
|
97
118
|
};
|
|
98
119
|
var makePathPlaceholder = () => ({ type: "path-placeholder" });
|
|
99
120
|
/** 把内部 sink 收窄回公开 ScenePrimitive[]:占位已全部回填(compileToScene 末端 placeholderBalance 无条件校验兜底) */
|
|
@@ -110,11 +131,12 @@ var collectPlaceholderLocators = (prims, prefix = "primitives") => {
|
|
|
110
131
|
/** scope.transforms 解析失败时根据失败成因映射的 warn code */
|
|
111
132
|
var scopeTransformWarnCode = (scope) => {
|
|
112
133
|
for (const t of scope.transforms ?? []) {
|
|
113
|
-
if (t.kind === "offset-translate") return
|
|
114
|
-
if (t.kind === "at-translate") return
|
|
115
|
-
if (t.kind === "polar-translate") return
|
|
134
|
+
if (t.kind === "offset-translate") return CompileWarningCode.OffsetBaseUnresolved;
|
|
135
|
+
if (t.kind === "at-translate") return CompileWarningCode.AtTargetUnresolved;
|
|
136
|
+
if (t.kind === "polar-translate") return CompileWarningCode.PolarOriginUnresolved;
|
|
137
|
+
if (t.kind === "between-translate") return CompileWarningCode.UnresolvedNodeReference;
|
|
116
138
|
}
|
|
117
|
-
return
|
|
139
|
+
return CompileWarningCode.UnresolvedNodeReference;
|
|
118
140
|
};
|
|
119
141
|
/** 把 DuplicateRegisterInfo 翻成 CompileWarning(含可读 message + 双 IR locator) */
|
|
120
142
|
var formatDuplicateWarning = (info) => {
|
|
@@ -122,19 +144,19 @@ var formatDuplicateWarning = (info) => {
|
|
|
122
144
|
const firstLoc = info.firstIrPath ?? "(unknown earlier location)";
|
|
123
145
|
const secondLoc = info.secondIrPath ?? "(unknown current location)";
|
|
124
146
|
return {
|
|
125
|
-
code:
|
|
147
|
+
code: CompileWarningCode.DuplicateNodeId,
|
|
126
148
|
message: `Duplicate id '${info.id}' registered in the same namespace frame (${frameNote}); first defined at ${firstLoc}, redefined at ${secondLoc}. The later definition overrides the earlier one (last-wins).`,
|
|
127
149
|
path: secondLoc
|
|
128
150
|
};
|
|
129
151
|
};
|
|
130
152
|
/**
|
|
131
153
|
* IR → Scene 纯函数转换,所有 adapter 共享
|
|
132
|
-
* @description Pass 1 递归处理 node / coordinate / scope,把 scope 树下沉为嵌套 GroupPrim;scope.transforms 中的
|
|
154
|
+
* @description Pass 1 递归处理 node / coordinate / scope,把 scope 树下沉为嵌套 GroupPrim;scope.transforms 中的 5 种 translate 变体按 lowerScopeTransforms 展平为 Cartesian transform;node 在 Scene primitive 树里是局部坐标 + GroupPrim transform 链、在 NameStack 中存全局坐标供其他节点 / path 引用。NameStack 用栈式 frame 管理命名空间:默认全局扁平、`<Scope localNamespace>` 推入子 frame;scope.id 始终在父 frame 注册(外部句柄);id lookup 从栈顶向栈底 inside-out 搜索;同 frame 重复 id 触发 DUPLICATE_NODE_ID warn + 后定义覆盖前定义。Pass 2 解析 path 端点写 d 字符串,path primitive 发到 Pass 1 记录的对应容器;末端按 precision 折算 layout
|
|
133
155
|
*/
|
|
134
156
|
var compileToScene = (ir, options = {}) => {
|
|
135
157
|
const measureText = options.measureText ?? fallbackMeasurer;
|
|
136
158
|
const layoutPadding = options.padding ?? 10;
|
|
137
|
-
const round =
|
|
159
|
+
const round = createRound(options.precision ?? 2);
|
|
138
160
|
const nodeDistance = options.nodeDistance;
|
|
139
161
|
const onWarn = options.onWarn ?? defaultWarnDispatcher;
|
|
140
162
|
const loweredIr = lowerComposites(ir, options.composites ?? [], {
|
|
@@ -147,7 +169,7 @@ var compileToScene = (ir, options = {}) => {
|
|
|
147
169
|
} : BUILTIN_SHAPES;
|
|
148
170
|
if (options.shapes) {
|
|
149
171
|
for (const name of Object.keys(options.shapes)) if (Object.prototype.hasOwnProperty.call(BUILTIN_SHAPES, name)) onWarn({
|
|
150
|
-
code:
|
|
172
|
+
code: CompileWarningCode.ShapeOverridesBuiltin,
|
|
151
173
|
message: `Injected shape '${name}' overrides the built-in shape of the same name.`,
|
|
152
174
|
path: `options.shapes.${name}`
|
|
153
175
|
});
|
|
@@ -159,7 +181,7 @@ var compileToScene = (ir, options = {}) => {
|
|
|
159
181
|
} : BUILTIN_ARROWS;
|
|
160
182
|
if (options.arrows) {
|
|
161
183
|
for (const name of Object.keys(options.arrows)) if (Object.prototype.hasOwnProperty.call(BUILTIN_ARROWS, name)) onWarn({
|
|
162
|
-
code:
|
|
184
|
+
code: CompileWarningCode.ArrowOverridesBuiltin,
|
|
163
185
|
message: `Injected arrow '${name}' overrides the built-in arrow of the same name.`,
|
|
164
186
|
path: `options.arrows.${name}`
|
|
165
187
|
});
|
|
@@ -170,7 +192,7 @@ var compileToScene = (ir, options = {}) => {
|
|
|
170
192
|
} : BUILTIN_PATTERNS;
|
|
171
193
|
if (options.patterns) {
|
|
172
194
|
for (const name of Object.keys(options.patterns)) if (Object.prototype.hasOwnProperty.call(BUILTIN_PATTERNS, name)) onWarn({
|
|
173
|
-
code:
|
|
195
|
+
code: CompileWarningCode.PatternOverridesBuiltin,
|
|
174
196
|
message: `Injected pattern '${name}' overrides the built-in pattern of the same name.`,
|
|
175
197
|
path: `options.patterns.${name}`
|
|
176
198
|
});
|
|
@@ -239,7 +261,7 @@ var compileToScene = (ir, options = {}) => {
|
|
|
239
261
|
};
|
|
240
262
|
/**
|
|
241
263
|
* 递归处理一组 IR child,把 node / coordinate 发到 sink、把本层 path 收集到 pathsAccumulator、scope 下沉为 GroupPrim
|
|
242
|
-
* @description **不**在内部 resolve pathsAccumulator——调用方负责在合适时机(scope 入口:bbox replaceLayout 之后 / popFrame 之前;顶层:所有处理结束后)调用 resolvePendingPaths。这样 scope.id 的 placeholder→real bbox 替换在本层 path 端点 lookup 之前完成,避免 "scope 内 path 自引用本 scope.id 拿到 placeholder" 的 latent bug,同时保留
|
|
264
|
+
* @description **不**在内部 resolve pathsAccumulator——调用方负责在合适时机(scope 入口:bbox replaceLayout 之后 / popFrame 之前;顶层:所有处理结束后)调用 resolvePendingPaths。这样 scope.id 的 placeholder→real bbox 替换在本层 path 端点 lookup 之前完成,避免 "scope 内 path 自引用本 scope.id 拿到 placeholder" 的 latent bug,同时保留"本层 path 在本层 frame 还在栈顶时 resolve"的 inside-out lookup 语义。
|
|
243
265
|
* @param children 当前层级的 IR child 数组
|
|
244
266
|
* @param chain 从根到当前层级累积的 Cartesian-only transform 链
|
|
245
267
|
* @param sink 当前层级 Scene primitive 落点(顶层 = primitives,scope 内 = GroupPrim.children)
|
|
@@ -253,41 +275,43 @@ var compileToScene = (ir, options = {}) => {
|
|
|
253
275
|
const child = children[i];
|
|
254
276
|
if ("namespace" in child) throw new Error(`Unexpected composite node '${child.namespace}.${child.type}' reached compile; composites must be lowered via lowerComposites first.`);
|
|
255
277
|
if (child.type === "node") {
|
|
256
|
-
const
|
|
278
|
+
const effectiveNode = resolveNodeStyle(child, styleStack);
|
|
279
|
+
const layout = layoutNode({
|
|
280
|
+
...effectiveNode,
|
|
281
|
+
animations: filterAnimations(effectiveNode.animations, "element", onWarn, `${locatorPrefix}children[${i}].node`)
|
|
282
|
+
}, measureText, nameStack, nodeDistance, chain, resolveLabelDefault(styleStack), effectiveShapes, refPointOfTarget);
|
|
257
283
|
const globalLayout = chain.length === 0 ? layout : projectLayoutToGlobal(layout, chain);
|
|
258
284
|
if (child.id) nameStack.register(child.id, globalLayout, `${locatorPrefix}children[${i}].node.id`);
|
|
259
285
|
for (const prim of emitNodePrimitives(layout, round, paint.resolve)) {
|
|
260
286
|
sink.push(prim);
|
|
261
287
|
if (child.zIndex !== void 0) zIndexOf.set(prim, child.zIndex);
|
|
262
288
|
}
|
|
263
|
-
|
|
289
|
+
const outerRect = outerRectOf(globalLayout);
|
|
290
|
+
allPoints.push(rect.anchor(outerRect, "north-west"), rect.anchor(outerRect, "north-east"), rect.anchor(outerRect, "south-west"), rect.anchor(outerRect, "south-east"));
|
|
264
291
|
for (const p of labelExtentPoints(globalLayout)) allPoints.push(p);
|
|
265
292
|
layoutsAccumulator.push(globalLayout);
|
|
266
293
|
} else if (child.type === "coordinate") {
|
|
267
294
|
const localCenter = resolvePosition(child.position, nameStack, nodeDistance, chain, refPointOfTarget);
|
|
268
|
-
if (!localCenter) {
|
|
269
|
-
onWarn({
|
|
270
|
-
code: "POLAR_ORIGIN_UNRESOLVED",
|
|
271
|
-
message: `Cannot resolve position for coordinate '${child.id}'; polar.origin or at.of may reference an undefined node`,
|
|
272
|
-
path: `${locatorPrefix}children[${i}].coordinate.position`
|
|
273
|
-
});
|
|
274
|
-
throw new Error(`Cannot resolve position for coordinate ${child.id}; polar.origin or at.of may reference an undefined node`);
|
|
275
|
-
}
|
|
295
|
+
if (!localCenter) throw new Error(`Cannot resolve position for coordinate ${child.id}; polar.origin or at.of may reference an undefined node`);
|
|
276
296
|
const globalCenter = chain.length === 0 ? localCenter : applyTransformChain(localCenter, chain);
|
|
277
|
-
const coordLayout = coordinateAsLayout(child.id, globalCenter);
|
|
297
|
+
const coordLayout = coordinateAsLayout(child.id, globalCenter, effectiveShapes);
|
|
278
298
|
nameStack.register(child.id, coordLayout, `${locatorPrefix}children[${i}].coordinate.id`);
|
|
279
299
|
layoutsAccumulator.push(coordLayout);
|
|
280
300
|
} else if (child.type === "scope") {
|
|
281
|
-
const loweredOwn = lowerScopeTransforms(child.transforms ?? [], nameStack, nodeDistance);
|
|
301
|
+
const loweredOwn = lowerScopeTransforms(child.transforms ?? [], nameStack, nodeDistance, refPointOfTarget);
|
|
282
302
|
if (loweredOwn === null) onWarn({
|
|
283
303
|
code: scopeTransformWarnCode(child),
|
|
284
|
-
message: `Cannot resolve one of scope.transforms; referent (at.of / offset.of / polar.origin) is undefined or defined later in the IR`,
|
|
304
|
+
message: `Cannot resolve one of scope.transforms; referent (at.of / offset.of / polar.origin / between endpoints) is undefined or defined later in the IR`,
|
|
285
305
|
path: `${locatorPrefix}children[${i}].scope.transforms`
|
|
286
306
|
});
|
|
287
307
|
const ownTransforms = loweredOwn ?? [];
|
|
288
308
|
const innerChain = [...chain, ...ownTransforms];
|
|
289
309
|
const parentFrameDepth = nameStack.depth - 1;
|
|
290
|
-
|
|
310
|
+
let placeholderLayout;
|
|
311
|
+
if (child.id) {
|
|
312
|
+
placeholderLayout = scopePlaceholderLayout(child.id, innerChain, effectiveShapes);
|
|
313
|
+
nameStack.register(child.id, placeholderLayout, `${locatorPrefix}children[${i}].scope.id`);
|
|
314
|
+
}
|
|
291
315
|
const pushedFrame = child.localNamespace === true;
|
|
292
316
|
if (pushedFrame) nameStack.pushFrame();
|
|
293
317
|
const innerSink = [];
|
|
@@ -297,12 +321,12 @@ var compileToScene = (ir, options = {}) => {
|
|
|
297
321
|
* 让 scope 内 path 自引用本 scope.id 端点取真 bbox 而非 placeholder */
|
|
298
322
|
const innerPaths = [];
|
|
299
323
|
try {
|
|
300
|
-
processChildren(child.children, innerChain, innerSink, `${locatorPrefix}children[${i}].scope.`, innerLayouts, innerPaths, [...styleStack,
|
|
324
|
+
processChildren(child.children, innerChain, innerSink, `${locatorPrefix}children[${i}].scope.`, innerLayouts, innerPaths, [...styleStack, createStyleFrame(child)]);
|
|
301
325
|
if (child.id) {
|
|
302
326
|
const bbox = computeScopeBoundingBox(innerLayouts);
|
|
303
327
|
const fallbackOrigin = innerChain.length === 0 ? [0, 0] : applyTransformChain([0, 0], innerChain);
|
|
304
|
-
const bboxLayout = registerScopeAsLayout(child.id, bbox, fallbackOrigin);
|
|
305
|
-
nameStack.replaceLayout(child.id, bboxLayout, parentFrameDepth);
|
|
328
|
+
const bboxLayout = registerScopeAsLayout(child.id, bbox, fallbackOrigin, effectiveShapes);
|
|
329
|
+
nameStack.replaceLayout(child.id, bboxLayout, parentFrameDepth, placeholderLayout);
|
|
306
330
|
layoutsAccumulator.push(bboxLayout);
|
|
307
331
|
} else for (const innerLayout of innerLayouts) layoutsAccumulator.push(innerLayout);
|
|
308
332
|
resolvePendingPaths(innerPaths);
|
|
@@ -317,13 +341,19 @@ var compileToScene = (ir, options = {}) => {
|
|
|
317
341
|
};
|
|
318
342
|
if (child.id !== void 0) group.id = child.id;
|
|
319
343
|
if (child.meta !== void 0) group.meta = child.meta;
|
|
344
|
+
const scopeAnimations = filterAnimations(child.animations, "element", onWarn, `${locatorPrefix}children[${i}].scope`);
|
|
345
|
+
if (scopeAnimations !== void 0) group.animations = scopeAnimations;
|
|
320
346
|
if (hasOwnTransforms) group.transforms = [...ownTransforms];
|
|
321
347
|
if (child.clip !== void 0) group.clipRef = clip.resolve(child.clip);
|
|
322
348
|
sink.push(group);
|
|
323
349
|
if (child.zIndex !== void 0) zIndexOf.set(group, child.zIndex);
|
|
324
350
|
} else {
|
|
351
|
+
const effectivePath = resolveEffectivePath(child, styleStack);
|
|
325
352
|
const pending = {
|
|
326
|
-
path:
|
|
353
|
+
path: {
|
|
354
|
+
...effectivePath,
|
|
355
|
+
animations: filterAnimations(effectivePath.animations, "element", onWarn, `${locatorPrefix}children[${i}].path`)
|
|
356
|
+
},
|
|
327
357
|
irPath: `${locatorPrefix}children[${i}].path`,
|
|
328
358
|
scopeChain: chain,
|
|
329
359
|
zIndex: child.zIndex
|
|
@@ -349,10 +379,12 @@ var compileToScene = (ir, options = {}) => {
|
|
|
349
379
|
throw new Error(`internal: ${placeholderBalance} unresolved path placeholder(s) leaked into Scene output${detail}`);
|
|
350
380
|
}
|
|
351
381
|
const resources = [...paint.resources(), ...clip.resources()];
|
|
382
|
+
const rootAnimations = filterAnimations(loweredIr.animations, "root", onWarn, "scene");
|
|
352
383
|
return {
|
|
353
384
|
primitives: stableSortByZIndex(sealSink(primitives)),
|
|
354
385
|
layout: loweredIr.viewBox !== void 0 ? viewBoxToLayout(loweredIr.viewBox, round) : assertFiniteLayout(computeLayout(allPoints, layoutPadding, round)),
|
|
355
|
-
...resources.length > 0 ? { resources } : {}
|
|
386
|
+
...resources.length > 0 ? { resources } : {},
|
|
387
|
+
...rootAnimations !== void 0 ? { animations: rootAnimations } : {}
|
|
356
388
|
};
|
|
357
389
|
};
|
|
358
390
|
//#endregion
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CompositeDefinition } from '../composites';
|
|
2
2
|
import { IR } from '../ir';
|
|
3
|
-
import { CompileWarning } from './
|
|
3
|
+
import { CompileWarning } from './constant';
|
|
4
4
|
/** composite 嵌套展开的默认最大深度(防环 / 防失控递归);可经 CompileOptions.maxCompositeDepth 覆盖 */
|
|
5
5
|
export declare const DEFAULT_MAX_COMPOSITE_DEPTH = 32;
|
|
6
6
|
type LowerOptions = {
|
|
@@ -13,7 +13,14 @@ type LowerOptions = {
|
|
|
13
13
|
* 查表 → `schema.parse(node)` 精确校验 + 强类型 → `expand` → 递归展开产物 fixpoint),否则 tier1(scope 递归
|
|
14
14
|
* children)。未注册 → `onWarn(COMPOSITE_NOT_REGISTERED)` + 跳过该节点(不进 Scene),继续编译其余;
|
|
15
15
|
* 环 / 超 `maxDepth` → throw(死循环防护)。无 tier2 节点时等价于原样返回。
|
|
16
|
+
*
|
|
17
|
+
* **注册表策略差异(有意,非疏漏)**:composite 以 `Array<CompositeDefinition>` 注入,可能重复,故重名
|
|
18
|
+
* **throw**(结构上无法天然去重,撞名是调用方错误);未注册走 **warn + skip**——composite 是高层节点,
|
|
19
|
+
* 缺对应包时跳过它仍能渲染其余图元,优雅降级优于整图崩。相对地,shape / arrow / pattern 以 `Record` 注入
|
|
20
|
+
* (key 天然去重,无重名可言),同名覆盖内置走 **warn + last-wins**(覆盖是合法定制);未注册名走 **throw**
|
|
21
|
+
* ——这些是"定位 / 布局类"基元,节点引用了不存在的 shape 根本无法布局,必须 fail-fast。两类策略按"数据结构
|
|
22
|
+
* + 语义分层"区分,不强行统一。
|
|
16
23
|
*/
|
|
17
24
|
export declare const lowerComposites: (ir: IR, composites: Array<CompositeDefinition>, options: LowerOptions) => IR;
|
|
18
25
|
export {};
|
|
19
|
-
//# sourceMappingURL=
|
|
26
|
+
//# sourceMappingURL=composite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composite.d.ts","sourceRoot":"","sources":["../../../src/compile/composite.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,KAAK,EAAE,EAAE,EAAW,MAAM,OAAO,CAAC;AAEzC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,+EAA+E;AAC/E,eAAO,MAAM,2BAA2B,KAAK,CAAC;AAE9C,KAAK,YAAY,GAAG;IAClB,MAAM,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,IAAI,CAAC;IAC1C,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAoBF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,eAAe,GAC1B,IAAI,EAAE,EACN,YAAY,KAAK,CAAC,mBAAmB,CAAC,EACtC,SAAS,YAAY,KACpB,EA8CF,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CompileWarningCode } from "./constant.js";
|
|
1
2
|
import { z } from "zod";
|
|
2
3
|
/**
|
|
3
4
|
* 从注册项的 schema 提取 `namespace` / `type` 的 literal 值(建表 key)
|
|
@@ -21,6 +22,13 @@ var extractKey = (schema) => {
|
|
|
21
22
|
* 查表 → `schema.parse(node)` 精确校验 + 强类型 → `expand` → 递归展开产物 fixpoint),否则 tier1(scope 递归
|
|
22
23
|
* children)。未注册 → `onWarn(COMPOSITE_NOT_REGISTERED)` + 跳过该节点(不进 Scene),继续编译其余;
|
|
23
24
|
* 环 / 超 `maxDepth` → throw(死循环防护)。无 tier2 节点时等价于原样返回。
|
|
25
|
+
*
|
|
26
|
+
* **注册表策略差异(有意,非疏漏)**:composite 以 `Array<CompositeDefinition>` 注入,可能重复,故重名
|
|
27
|
+
* **throw**(结构上无法天然去重,撞名是调用方错误);未注册走 **warn + skip**——composite 是高层节点,
|
|
28
|
+
* 缺对应包时跳过它仍能渲染其余图元,优雅降级优于整图崩。相对地,shape / arrow / pattern 以 `Record` 注入
|
|
29
|
+
* (key 天然去重,无重名可言),同名覆盖内置走 **warn + last-wins**(覆盖是合法定制);未注册名走 **throw**
|
|
30
|
+
* ——这些是"定位 / 布局类"基元,节点引用了不存在的 shape 根本无法布局,必须 fail-fast。两类策略按"数据结构
|
|
31
|
+
* + 语义分层"区分,不强行统一。
|
|
24
32
|
*/
|
|
25
33
|
var lowerComposites = (ir, composites, options) => {
|
|
26
34
|
const { onWarn, maxDepth = 32 } = options;
|
|
@@ -38,7 +46,7 @@ var lowerComposites = (ir, composites, options) => {
|
|
|
38
46
|
const definition = registry.get(key);
|
|
39
47
|
if (!definition) {
|
|
40
48
|
onWarn({
|
|
41
|
-
code:
|
|
49
|
+
code: CompileWarningCode.CompositeNotRegistered,
|
|
42
50
|
message: `No composite registered for '${key}'; the node is skipped.`,
|
|
43
51
|
path
|
|
44
52
|
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ValueOf } from '../types';
|
|
2
|
+
/** 编译期 warning code(机器可读)。 */
|
|
3
|
+
export declare const CompileWarningCode: {
|
|
4
|
+
readonly UnresolvedNodeReference: "UNRESOLVED_NODE_REFERENCE";
|
|
5
|
+
readonly PathTooShort: "PATH_TOO_SHORT";
|
|
6
|
+
readonly AnchorResolutionFailed: "ANCHOR_RESOLUTION_FAILED";
|
|
7
|
+
readonly OffsetBaseUnresolved: "OFFSET_BASE_UNRESOLVED";
|
|
8
|
+
readonly PolarOriginUnresolved: "POLAR_ORIGIN_UNRESOLVED";
|
|
9
|
+
readonly AtTargetUnresolved: "AT_TARGET_UNRESOLVED";
|
|
10
|
+
readonly RelativeInitialNoPrevEnd: "RELATIVE_INITIAL_NO_PREV_END";
|
|
11
|
+
readonly BboxExtremeInput: "BBOX_EXTREME_INPUT";
|
|
12
|
+
readonly DuplicateNodeId: "DUPLICATE_NODE_ID";
|
|
13
|
+
readonly ShapeOverridesBuiltin: "SHAPE_OVERRIDES_BUILTIN";
|
|
14
|
+
readonly ArrowOverridesBuiltin: "ARROW_OVERRIDES_BUILTIN";
|
|
15
|
+
readonly PatternOverridesBuiltin: "PATTERN_OVERRIDES_BUILTIN";
|
|
16
|
+
readonly CompositeNotRegistered: "COMPOSITE_NOT_REGISTERED";
|
|
17
|
+
readonly AnimationInvalidProperty: "ANIMATION_INVALID_PROPERTY";
|
|
18
|
+
readonly ArcMissingRadius: "ARC_MISSING_RADIUS";
|
|
19
|
+
readonly PartialArcNeedsBothAngles: "PARTIAL_ARC_NEEDS_BOTH_ANGLES";
|
|
20
|
+
};
|
|
21
|
+
export type CompileWarningCodeValue = ValueOf<typeof CompileWarningCode> | (string & {});
|
|
22
|
+
/** 编译期 warning:不影响 Scene 产物,交给调用方收集或展示。 */
|
|
23
|
+
export type CompileWarning = {
|
|
24
|
+
/** 机器可读 warning code。 */
|
|
25
|
+
code: CompileWarningCodeValue;
|
|
26
|
+
/** 人类可读消息(英文)。 */
|
|
27
|
+
message: string;
|
|
28
|
+
/** IR locator 路径(jq-like),如 `children[3].path.children[1].to`。 */
|
|
29
|
+
path: string;
|
|
30
|
+
};
|
|
31
|
+
export declare const formatCompileWarning: (warning: CompileWarning) => string;
|
|
32
|
+
//# sourceMappingURL=constant.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constant.d.ts","sourceRoot":"","sources":["../../../src/compile/constant.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAExC,8BAA8B;AAC9B,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;CAiBrB,CAAC;AAEX,MAAM,MAAM,uBAAuB,GAC/B,OAAO,CAAC,OAAO,kBAAkB,CAAC,GAClC,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAElB,2CAA2C;AAC3C,MAAM,MAAM,cAAc,GAAG;IAC3B,yBAAyB;IACzB,IAAI,EAAE,uBAAuB,CAAC;IAC9B,kBAAkB;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,kEAAkE;IAClE,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,SAAS,cAAc,KAAG,MACI,CAAC"}
|