@retikz/core 0.0.1-rc.3 → 0.1.0-alpha.0
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/LICENSE +21 -21
- package/dist/es/compile/compile.d.ts +27 -0
- package/dist/es/compile/compile.d.ts.map +1 -0
- package/dist/es/compile/compile.js +43 -0
- package/dist/es/compile/index.d.ts +8 -0
- package/dist/es/compile/index.d.ts.map +1 -0
- package/dist/es/compile/node.d.ts +51 -0
- package/dist/es/compile/node.d.ts.map +1 -0
- package/dist/es/compile/node.js +100 -0
- package/dist/es/compile/path.d.ts +19 -0
- package/dist/es/compile/path.d.ts.map +1 -0
- package/dist/es/compile/path.js +55 -0
- package/dist/es/compile/position.d.ts +9 -0
- package/dist/es/compile/position.d.ts.map +1 -0
- package/dist/es/compile/position.js +24 -0
- package/dist/es/compile/precision.d.ts +5 -0
- package/dist/es/compile/precision.d.ts.map +1 -0
- package/dist/es/compile/precision.js +8 -0
- package/dist/es/compile/text-metrics.d.ts +32 -0
- package/dist/es/compile/text-metrics.d.ts.map +1 -0
- package/dist/es/compile/text-metrics.js +8 -0
- package/dist/es/compile/view-box.d.ts +8 -0
- package/dist/es/compile/view-box.d.ts.map +1 -0
- package/dist/es/compile/view-box.js +31 -0
- package/dist/es/geometry/index.d.ts +4 -0
- package/dist/es/geometry/index.d.ts.map +1 -0
- package/dist/es/geometry/point.d.ts +25 -0
- package/dist/es/geometry/point.d.ts.map +1 -0
- package/dist/es/geometry/point.js +34 -0
- package/dist/es/geometry/polar.d.ts +44 -0
- package/dist/es/geometry/polar.d.ts.map +1 -0
- package/dist/es/geometry/polar.js +45 -0
- package/dist/es/geometry/rect.d.ts +59 -0
- package/dist/es/geometry/rect.d.ts.map +1 -0
- package/dist/es/geometry/rect.js +120 -0
- package/dist/es/index.d.ts +18 -10
- package/dist/es/index.d.ts.map +1 -0
- package/dist/es/index.js +14 -12
- package/dist/es/ir/index.d.ts +5 -0
- package/dist/es/ir/index.d.ts.map +1 -0
- package/dist/es/ir/node.d.ts +41 -0
- package/dist/es/ir/node.d.ts.map +1 -0
- package/dist/es/ir/node.js +19 -0
- package/dist/es/ir/path/index.d.ts +4 -0
- package/dist/es/ir/path/index.d.ts.map +1 -0
- package/dist/es/ir/path/path.d.ts +63 -0
- package/dist/es/ir/path/path.d.ts.map +1 -0
- package/dist/es/ir/path/path.js +12 -0
- package/dist/es/ir/path/step.d.ts +62 -0
- package/dist/es/ir/path/step.d.ts.map +1 -0
- package/dist/es/ir/path/step.js +16 -0
- package/dist/es/ir/path/target.d.ts +5 -0
- package/dist/es/ir/path/target.d.ts.map +1 -0
- package/dist/es/ir/path/target.js +11 -0
- package/dist/es/ir/position/index.d.ts +3 -0
- package/dist/es/ir/position/index.d.ts.map +1 -0
- package/dist/es/ir/position/polar-position.d.ts +9 -0
- package/dist/es/ir/position/polar-position.d.ts.map +1 -0
- package/dist/es/ir/position/polar-position.js +18 -0
- package/dist/es/ir/position/position.d.ts +5 -0
- package/dist/es/ir/position/position.d.ts.map +1 -0
- package/dist/es/ir/position/position.js +5 -0
- package/dist/es/ir/scene.d.ts +262 -0
- package/dist/es/ir/scene.d.ts.map +1 -0
- package/dist/es/ir/scene.js +14 -0
- package/dist/es/parsers/index.d.ts +2 -0
- package/dist/es/parsers/index.d.ts.map +1 -0
- package/dist/es/parsers/parseWay.d.ts +25 -0
- package/dist/es/parsers/parseWay.d.ts.map +1 -0
- package/dist/es/parsers/parseWay.js +30 -0
- package/dist/es/primitive/group.d.ts +11 -0
- package/dist/es/primitive/group.d.ts.map +1 -0
- package/dist/es/primitive/index.d.ts +7 -0
- package/dist/es/primitive/index.d.ts.map +1 -0
- package/dist/es/primitive/path.d.ts +22 -0
- package/dist/es/primitive/path.d.ts.map +1 -0
- package/dist/es/primitive/rect.d.ts +28 -0
- package/dist/es/primitive/rect.d.ts.map +1 -0
- package/dist/es/primitive/scene.d.ts +20 -0
- package/dist/es/primitive/scene.d.ts.map +1 -0
- package/dist/es/primitive/text.d.ts +32 -0
- package/dist/es/primitive/text.d.ts.map +1 -0
- package/dist/es/primitive/view-box.d.ts +12 -0
- package/dist/es/primitive/view-box.d.ts.map +1 -0
- package/dist/lib/compile/compile.cjs +43 -0
- package/dist/lib/compile/compile.d.ts +27 -0
- package/dist/lib/compile/compile.d.ts.map +1 -0
- package/dist/lib/compile/index.d.ts +8 -0
- package/dist/lib/compile/index.d.ts.map +1 -0
- package/dist/lib/compile/node.cjs +102 -0
- package/dist/lib/compile/node.d.ts +51 -0
- package/dist/lib/compile/node.d.ts.map +1 -0
- package/dist/lib/compile/path.cjs +55 -0
- package/dist/lib/compile/path.d.ts +19 -0
- package/dist/lib/compile/path.d.ts.map +1 -0
- package/dist/lib/compile/position.cjs +24 -0
- package/dist/lib/compile/position.d.ts +9 -0
- package/dist/lib/compile/position.d.ts.map +1 -0
- package/dist/lib/compile/precision.cjs +8 -0
- package/dist/lib/compile/precision.d.ts +5 -0
- package/dist/lib/compile/precision.d.ts.map +1 -0
- package/dist/lib/compile/text-metrics.cjs +8 -0
- package/dist/lib/compile/text-metrics.d.ts +32 -0
- package/dist/lib/compile/text-metrics.d.ts.map +1 -0
- package/dist/lib/compile/view-box.cjs +31 -0
- package/dist/lib/compile/view-box.d.ts +8 -0
- package/dist/lib/compile/view-box.d.ts.map +1 -0
- package/dist/lib/geometry/index.d.ts +4 -0
- package/dist/lib/geometry/index.d.ts.map +1 -0
- package/dist/lib/geometry/point.cjs +34 -0
- package/dist/lib/geometry/point.d.ts +25 -0
- package/dist/lib/geometry/point.d.ts.map +1 -0
- package/dist/lib/geometry/polar.cjs +45 -0
- package/dist/lib/geometry/polar.d.ts +44 -0
- package/dist/lib/geometry/polar.d.ts.map +1 -0
- package/dist/lib/geometry/rect.cjs +121 -0
- package/dist/lib/geometry/rect.d.ts +59 -0
- package/dist/lib/geometry/rect.d.ts.map +1 -0
- package/dist/lib/index.cjs +31 -11
- package/dist/lib/index.d.ts +18 -10
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/ir/index.d.ts +5 -0
- package/dist/lib/ir/index.d.ts.map +1 -0
- package/dist/lib/ir/node.cjs +19 -0
- package/dist/lib/ir/node.d.ts +41 -0
- package/dist/lib/ir/node.d.ts.map +1 -0
- package/dist/lib/ir/path/index.d.ts +4 -0
- package/dist/lib/ir/path/index.d.ts.map +1 -0
- package/dist/lib/ir/path/path.cjs +12 -0
- package/dist/lib/ir/path/path.d.ts +63 -0
- package/dist/lib/ir/path/path.d.ts.map +1 -0
- package/dist/lib/ir/path/step.cjs +18 -0
- package/dist/lib/ir/path/step.d.ts +62 -0
- package/dist/lib/ir/path/step.d.ts.map +1 -0
- package/dist/lib/ir/path/target.cjs +11 -0
- package/dist/lib/ir/path/target.d.ts +5 -0
- package/dist/lib/ir/path/target.d.ts.map +1 -0
- package/dist/lib/ir/position/index.d.ts +3 -0
- package/dist/lib/ir/position/index.d.ts.map +1 -0
- package/dist/lib/ir/position/polar-position.cjs +18 -0
- package/dist/lib/ir/position/polar-position.d.ts +9 -0
- package/dist/lib/ir/position/polar-position.d.ts.map +1 -0
- package/dist/lib/ir/position/position.cjs +5 -0
- package/dist/lib/ir/position/position.d.ts +5 -0
- package/dist/lib/ir/position/position.d.ts.map +1 -0
- package/dist/lib/ir/scene.cjs +16 -0
- package/dist/lib/ir/scene.d.ts +262 -0
- package/dist/lib/ir/scene.d.ts.map +1 -0
- package/dist/lib/parsers/index.d.ts +2 -0
- package/dist/lib/parsers/index.d.ts.map +1 -0
- package/dist/lib/parsers/parseWay.cjs +30 -0
- package/dist/lib/parsers/parseWay.d.ts +25 -0
- package/dist/lib/parsers/parseWay.d.ts.map +1 -0
- package/dist/lib/primitive/group.d.ts +11 -0
- package/dist/lib/primitive/group.d.ts.map +1 -0
- package/dist/lib/primitive/index.d.ts +7 -0
- package/dist/lib/primitive/index.d.ts.map +1 -0
- package/dist/lib/primitive/path.d.ts +22 -0
- package/dist/lib/primitive/path.d.ts.map +1 -0
- package/dist/lib/primitive/rect.d.ts +28 -0
- package/dist/lib/primitive/rect.d.ts.map +1 -0
- package/dist/lib/primitive/scene.d.ts +20 -0
- package/dist/lib/primitive/scene.d.ts.map +1 -0
- package/dist/lib/primitive/text.d.ts +32 -0
- package/dist/lib/primitive/text.d.ts.map +1 -0
- package/dist/lib/primitive/view-box.d.ts +12 -0
- package/dist/lib/primitive/view-box.d.ts.map +1 -0
- package/package.json +26 -34
- package/README.md +0 -2
- package/dist/es/components/Scope.d.ts +0 -6
- package/dist/es/components/Scope.js +0 -12
- package/dist/es/components/TikZ.d.ts +0 -9
- package/dist/es/components/TikZ.js +0 -12
- package/dist/es/components/draw/Draw.d.ts +0 -26
- package/dist/es/components/draw/Draw.js +0 -59
- package/dist/es/components/draw/InnerDraw.d.ts +0 -17
- package/dist/es/components/draw/InnerDraw.js +0 -52
- package/dist/es/components/draw/arrow/circle.d.ts +0 -7
- package/dist/es/components/draw/arrow/circle.js +0 -20
- package/dist/es/components/draw/arrow/index.d.ts +0 -9
- package/dist/es/components/draw/arrow/index.js +0 -13
- package/dist/es/components/draw/arrow/stealth.d.ts +0 -7
- package/dist/es/components/draw/arrow/stealth.js +0 -29
- package/dist/es/components/draw/arrow/types.d.ts +0 -21
- package/dist/es/components/draw/common.d.ts +0 -4
- package/dist/es/components/draw/common.js +0 -12
- package/dist/es/components/draw/index.d.ts +0 -3
- package/dist/es/components/draw/index.js +0 -4
- package/dist/es/components/draw/segment/Segment.d.ts +0 -12
- package/dist/es/components/draw/segment/Segment.js +0 -41
- package/dist/es/components/draw/segment/index.d.ts +0 -15
- package/dist/es/components/draw/segment/index.js +0 -41
- package/dist/es/components/draw/segment/useArrow.d.ts +0 -12
- package/dist/es/components/draw/segment/useArrow.js +0 -52
- package/dist/es/components/draw/segment/useConvertWay.d.ts +0 -14
- package/dist/es/components/draw/segment/useConvertWay.js +0 -117
- package/dist/es/components/draw/types.d.ts +0 -29
- package/dist/es/components/node/InnerNode.d.ts +0 -33
- package/dist/es/components/node/InnerNode.js +0 -88
- package/dist/es/components/node/Node.d.ts +0 -93
- package/dist/es/components/node/Node.js +0 -88
- package/dist/es/components/node/_hooks/useNodeConfig.d.ts +0 -3
- package/dist/es/components/node/_hooks/useNodeConfig.js +0 -13
- package/dist/es/components/node/_hooks/useNodeContent.d.ts +0 -4
- package/dist/es/components/node/_hooks/useNodeContent.js +0 -30
- package/dist/es/components/node/_hooks/useNodeShape.d.ts +0 -4
- package/dist/es/components/node/_hooks/useNodeShape.js +0 -34
- package/dist/es/components/node/index.d.ts +0 -3
- package/dist/es/components/node/index.js +0 -4
- package/dist/es/components/path-node/PathNode.d.ts +0 -48
- package/dist/es/components/path-node/PathNode.js +0 -76
- package/dist/es/components/path-node/index.d.ts +0 -3
- package/dist/es/components/path-node/index.js +0 -4
- package/dist/es/components/path-node/useAnchor.d.ts +0 -6
- package/dist/es/components/path-node/useAnchor.js +0 -49
- package/dist/es/container/Group.d.ts +0 -6
- package/dist/es/container/Group.js +0 -8
- package/dist/es/container/Surface.d.ts +0 -19
- package/dist/es/container/Surface.js +0 -23
- package/dist/es/elements/Path.d.ts +0 -4
- package/dist/es/elements/Path.js +0 -14
- package/dist/es/elements/Rect.d.ts +0 -4
- package/dist/es/elements/Rect.js +0 -9
- package/dist/es/elements/Text.d.ts +0 -18
- package/dist/es/elements/Text.js +0 -35
- package/dist/es/hooks/context/useCalculate.d.ts +0 -7
- package/dist/es/hooks/context/useCalculate.js +0 -9
- package/dist/es/hooks/context/useNodes.d.ts +0 -9
- package/dist/es/hooks/context/useNodes.js +0 -33
- package/dist/es/hooks/context/usePath.d.ts +0 -13
- package/dist/es/hooks/context/usePath.js +0 -20
- package/dist/es/hooks/context/useScope.d.ts +0 -11
- package/dist/es/hooks/context/useScope.js +0 -7
- package/dist/es/hooks/useForceUpdate.d.ts +0 -2
- package/dist/es/hooks/useForceUpdate.js +0 -8
- package/dist/es/model/component/node.d.ts +0 -45
- package/dist/es/model/component/node.js +0 -164
- package/dist/es/model/component/path.d.ts +0 -19
- package/dist/es/model/component/path.js +0 -47
- package/dist/es/model/equation/line.d.ts +0 -21
- package/dist/es/model/equation/line.js +0 -76
- package/dist/es/model/geometry/point/DescartesPoint.d.ts +0 -21
- package/dist/es/model/geometry/point/DescartesPoint.js +0 -50
- package/dist/es/model/geometry/point/PolarPoint.d.ts +0 -14
- package/dist/es/model/geometry/point/PolarPoint.js +0 -27
- package/dist/es/node_modules/.pnpm/d3-color@3.1.0/node_modules/d3-color/src/color.js +0 -338
- package/dist/es/node_modules/.pnpm/d3-color@3.1.0/node_modules/d3-color/src/define.js +0 -13
- package/dist/es/node_modules/.pnpm/d3-path@3.1.0/node_modules/d3-path/src/path.js +0 -88
- package/dist/es/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/array.js +0 -6
- package/dist/es/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/constant.js +0 -8
- package/dist/es/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/curve/linear.js +0 -39
- package/dist/es/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/line.js +0 -41
- package/dist/es/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/path.js +0 -19
- package/dist/es/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/point.js +0 -10
- package/dist/es/test.d.ts +0 -3
- package/dist/es/types/coordinate/descartes.d.ts +0 -23
- package/dist/es/types/coordinate/index.d.ts +0 -5
- package/dist/es/types/coordinate/polar.d.ts +0 -5
- package/dist/es/types/distance/index.d.ts +0 -8
- package/dist/es/types/distance/sep.d.ts +0 -9
- package/dist/es/types/shape/index.d.ts +0 -8
- package/dist/es/types/shape/index.js +0 -9
- package/dist/es/types/shape/rect.d.ts +0 -25
- package/dist/es/types/shape/rect.js +0 -30
- package/dist/es/types/svg/font.d.ts +0 -10
- package/dist/es/types/svg/stroke.d.ts +0 -10
- package/dist/es/types/tikz/index.d.ts +0 -6
- package/dist/es/utils/compare.d.ts +0 -4
- package/dist/es/utils/compare.js +0 -20
- package/dist/es/utils/css.d.ts +0 -6
- package/dist/es/utils/css.js +0 -26
- package/dist/es/utils/math.d.ts +0 -9
- package/dist/es/utils/math.js +0 -26
- package/dist/es/utils/string.d.ts +0 -7
- package/dist/es/utils/string.js +0 -7
- package/dist/es/utils/style/font.d.ts +0 -17
- package/dist/es/utils/style/font.js +0 -34
- package/dist/es/utils/style/stroke.d.ts +0 -20
- package/dist/es/utils/style/stroke.js +0 -42
- package/dist/lib/components/Scope.cjs +0 -12
- package/dist/lib/components/Scope.d.ts +0 -6
- package/dist/lib/components/TikZ.cjs +0 -12
- package/dist/lib/components/TikZ.d.ts +0 -9
- package/dist/lib/components/draw/Draw.cjs +0 -59
- package/dist/lib/components/draw/Draw.d.ts +0 -26
- package/dist/lib/components/draw/InnerDraw.cjs +0 -52
- package/dist/lib/components/draw/InnerDraw.d.ts +0 -17
- package/dist/lib/components/draw/arrow/circle.cjs +0 -20
- package/dist/lib/components/draw/arrow/circle.d.ts +0 -7
- package/dist/lib/components/draw/arrow/index.cjs +0 -13
- package/dist/lib/components/draw/arrow/index.d.ts +0 -9
- package/dist/lib/components/draw/arrow/stealth.cjs +0 -29
- package/dist/lib/components/draw/arrow/stealth.d.ts +0 -7
- package/dist/lib/components/draw/arrow/types.d.ts +0 -21
- package/dist/lib/components/draw/common.cjs +0 -12
- package/dist/lib/components/draw/common.d.ts +0 -4
- package/dist/lib/components/draw/index.cjs +0 -4
- package/dist/lib/components/draw/index.d.ts +0 -3
- package/dist/lib/components/draw/segment/Segment.cjs +0 -41
- package/dist/lib/components/draw/segment/Segment.d.ts +0 -12
- package/dist/lib/components/draw/segment/index.cjs +0 -41
- package/dist/lib/components/draw/segment/index.d.ts +0 -15
- package/dist/lib/components/draw/segment/useArrow.cjs +0 -52
- package/dist/lib/components/draw/segment/useArrow.d.ts +0 -12
- package/dist/lib/components/draw/segment/useConvertWay.cjs +0 -117
- package/dist/lib/components/draw/segment/useConvertWay.d.ts +0 -14
- package/dist/lib/components/draw/types.d.ts +0 -29
- package/dist/lib/components/node/InnerNode.cjs +0 -88
- package/dist/lib/components/node/InnerNode.d.ts +0 -33
- package/dist/lib/components/node/Node.cjs +0 -88
- package/dist/lib/components/node/Node.d.ts +0 -93
- package/dist/lib/components/node/_hooks/useNodeConfig.cjs +0 -13
- package/dist/lib/components/node/_hooks/useNodeConfig.d.ts +0 -3
- package/dist/lib/components/node/_hooks/useNodeContent.cjs +0 -30
- package/dist/lib/components/node/_hooks/useNodeContent.d.ts +0 -4
- package/dist/lib/components/node/_hooks/useNodeShape.cjs +0 -34
- package/dist/lib/components/node/_hooks/useNodeShape.d.ts +0 -4
- package/dist/lib/components/node/index.cjs +0 -4
- package/dist/lib/components/node/index.d.ts +0 -3
- package/dist/lib/components/path-node/PathNode.cjs +0 -76
- package/dist/lib/components/path-node/PathNode.d.ts +0 -48
- package/dist/lib/components/path-node/index.cjs +0 -4
- package/dist/lib/components/path-node/index.d.ts +0 -3
- package/dist/lib/components/path-node/useAnchor.cjs +0 -49
- package/dist/lib/components/path-node/useAnchor.d.ts +0 -6
- package/dist/lib/container/Group.cjs +0 -8
- package/dist/lib/container/Group.d.ts +0 -6
- package/dist/lib/container/Surface.cjs +0 -23
- package/dist/lib/container/Surface.d.ts +0 -19
- package/dist/lib/elements/Path.cjs +0 -14
- package/dist/lib/elements/Path.d.ts +0 -4
- package/dist/lib/elements/Rect.cjs +0 -9
- package/dist/lib/elements/Rect.d.ts +0 -4
- package/dist/lib/elements/Text.cjs +0 -35
- package/dist/lib/elements/Text.d.ts +0 -18
- package/dist/lib/hooks/context/useCalculate.cjs +0 -9
- package/dist/lib/hooks/context/useCalculate.d.ts +0 -7
- package/dist/lib/hooks/context/useNodes.cjs +0 -33
- package/dist/lib/hooks/context/useNodes.d.ts +0 -9
- package/dist/lib/hooks/context/usePath.cjs +0 -20
- package/dist/lib/hooks/context/usePath.d.ts +0 -13
- package/dist/lib/hooks/context/useScope.cjs +0 -7
- package/dist/lib/hooks/context/useScope.d.ts +0 -11
- package/dist/lib/hooks/useForceUpdate.cjs +0 -8
- package/dist/lib/hooks/useForceUpdate.d.ts +0 -2
- package/dist/lib/model/component/node.cjs +0 -164
- package/dist/lib/model/component/node.d.ts +0 -45
- package/dist/lib/model/component/path.cjs +0 -47
- package/dist/lib/model/component/path.d.ts +0 -19
- package/dist/lib/model/equation/line.cjs +0 -76
- package/dist/lib/model/equation/line.d.ts +0 -21
- package/dist/lib/model/geometry/point/DescartesPoint.cjs +0 -50
- package/dist/lib/model/geometry/point/DescartesPoint.d.ts +0 -21
- package/dist/lib/model/geometry/point/PolarPoint.cjs +0 -27
- package/dist/lib/model/geometry/point/PolarPoint.d.ts +0 -14
- package/dist/lib/node_modules/.pnpm/d3-color@3.1.0/node_modules/d3-color/src/color.cjs +0 -338
- package/dist/lib/node_modules/.pnpm/d3-color@3.1.0/node_modules/d3-color/src/define.cjs +0 -13
- package/dist/lib/node_modules/.pnpm/d3-path@3.1.0/node_modules/d3-path/src/path.cjs +0 -88
- package/dist/lib/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/array.cjs +0 -6
- package/dist/lib/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/constant.cjs +0 -8
- package/dist/lib/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/curve/linear.cjs +0 -39
- package/dist/lib/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/line.cjs +0 -41
- package/dist/lib/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/path.cjs +0 -19
- package/dist/lib/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/point.cjs +0 -10
- package/dist/lib/test.d.ts +0 -3
- package/dist/lib/types/coordinate/descartes.d.ts +0 -23
- package/dist/lib/types/coordinate/index.d.ts +0 -5
- package/dist/lib/types/coordinate/polar.d.ts +0 -5
- package/dist/lib/types/distance/index.d.ts +0 -8
- package/dist/lib/types/distance/sep.d.ts +0 -9
- package/dist/lib/types/shape/index.cjs +0 -9
- package/dist/lib/types/shape/index.d.ts +0 -8
- package/dist/lib/types/shape/rect.cjs +0 -30
- package/dist/lib/types/shape/rect.d.ts +0 -25
- package/dist/lib/types/svg/font.d.ts +0 -10
- package/dist/lib/types/svg/stroke.d.ts +0 -10
- package/dist/lib/types/tikz/index.d.ts +0 -6
- package/dist/lib/utils/compare.cjs +0 -20
- package/dist/lib/utils/compare.d.ts +0 -4
- package/dist/lib/utils/css.cjs +0 -26
- package/dist/lib/utils/css.d.ts +0 -6
- package/dist/lib/utils/math.cjs +0 -26
- package/dist/lib/utils/math.d.ts +0 -9
- package/dist/lib/utils/string.cjs +0 -7
- package/dist/lib/utils/string.d.ts +0 -7
- package/dist/lib/utils/style/font.cjs +0 -34
- package/dist/lib/utils/style/font.d.ts +0 -17
- package/dist/lib/utils/style/stroke.cjs +0 -42
- package/dist/lib/utils/style/stroke.d.ts +0 -20
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
2
|
-
import { PointPosition } from '../../types/coordinate';
|
|
3
|
-
import { StrokeProps } from '../../types/svg/stroke';
|
|
4
|
-
import { StrokeShortcutProps, StrokeType } from '../../utils/style/stroke';
|
|
5
|
-
import { ArrowProps, DrawWayType } from './types';
|
|
6
|
-
export type DrawProps = {
|
|
7
|
-
way: DrawWayType[];
|
|
8
|
-
/** 位置偏移 */
|
|
9
|
-
offset?: PointPosition;
|
|
10
|
-
/** 同 stroke */
|
|
11
|
-
color?: string;
|
|
12
|
-
/** 线段样式快捷属性 */
|
|
13
|
-
strokeType?: StrokeType;
|
|
14
|
-
children?: ReactElement | ReactElement[] | null;
|
|
15
|
-
} & StrokeProps & StrokeShortcutProps & ArrowProps;
|
|
16
|
-
declare const Draw: import('react').ForwardRefExoticComponent<{
|
|
17
|
-
way: DrawWayType[];
|
|
18
|
-
/** 位置偏移 */
|
|
19
|
-
offset?: PointPosition;
|
|
20
|
-
/** 同 stroke */
|
|
21
|
-
color?: string;
|
|
22
|
-
/** 线段样式快捷属性 */
|
|
23
|
-
strokeType?: StrokeType;
|
|
24
|
-
children?: ReactElement | ReactElement[] | null;
|
|
25
|
-
} & StrokeProps & StrokeShortcutProps & ArrowProps & import('react').RefAttributes<SVGPathElement>>;
|
|
26
|
-
export default Draw;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef, useMemo } from "react";
|
|
3
|
-
import useScope from "../../hooks/context/useScope.js";
|
|
4
|
-
import DescartesPoint from "../../model/geometry/point/DescartesPoint.js";
|
|
5
|
-
import { convertStrokeType, convertStrokeShortcut } from "../../utils/style/stroke.js";
|
|
6
|
-
import InnerDraw from "./InnerDraw.js";
|
|
7
|
-
const Draw = forwardRef((props, ref) => {
|
|
8
|
-
const { draw: scopeProps } = useScope();
|
|
9
|
-
const realProps = { ...scopeProps, ...props };
|
|
10
|
-
const { offset, color, stroke, strokeWidth, startArrow, startArrows, endArrow, endArrows, ...resProps } = realProps;
|
|
11
|
-
const realStroke = stroke || color;
|
|
12
|
-
const realStartArrow = typeof startArrow === "string" ? { type: startArrow } : startArrow;
|
|
13
|
-
const realStartArrows = typeof startArrows === "string" ? { type: startArrows } : startArrows;
|
|
14
|
-
const realEndArrow = typeof endArrow === "string" ? { type: endArrow } : endArrow;
|
|
15
|
-
const realEndArrows = typeof endArrows === "string" ? { type: endArrows } : endArrows;
|
|
16
|
-
const convertOffset = offset ? DescartesPoint.formatPosition(offset) : [0, 0];
|
|
17
|
-
const getStrokeTypes = () => resProps.strokeType ? convertStrokeType(resProps.strokeType, strokeWidth ?? 1) : convertStrokeShortcut(resProps, strokeWidth ?? 1);
|
|
18
|
-
const drawProps = useMemo(() => {
|
|
19
|
-
const props2 = { ...resProps };
|
|
20
|
-
[
|
|
21
|
-
"solid",
|
|
22
|
-
"dashed",
|
|
23
|
-
"denselyDashed",
|
|
24
|
-
"looselyDashed",
|
|
25
|
-
"dotted",
|
|
26
|
-
"denselyDotted",
|
|
27
|
-
"looselyDotted",
|
|
28
|
-
"dashDot",
|
|
29
|
-
"denselyDashDot",
|
|
30
|
-
"looselyDashDot",
|
|
31
|
-
"dashDashDot",
|
|
32
|
-
"denselyDashDashDot",
|
|
33
|
-
"looselyDashDashDot"
|
|
34
|
-
].forEach((key) => {
|
|
35
|
-
if (key in props2) {
|
|
36
|
-
delete props2[key];
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
return props2;
|
|
40
|
-
}, [props]);
|
|
41
|
-
return /* @__PURE__ */ jsx(
|
|
42
|
-
InnerDraw,
|
|
43
|
-
{
|
|
44
|
-
ref,
|
|
45
|
-
...getStrokeTypes(),
|
|
46
|
-
offset: convertOffset,
|
|
47
|
-
stroke: realStroke,
|
|
48
|
-
strokeWidth: strokeWidth || 1,
|
|
49
|
-
startArrow: realStartArrow,
|
|
50
|
-
startArrows: realStartArrows,
|
|
51
|
-
endArrow: realEndArrow,
|
|
52
|
-
endArrows: realEndArrows,
|
|
53
|
-
...drawProps
|
|
54
|
-
}
|
|
55
|
-
);
|
|
56
|
-
});
|
|
57
|
-
export {
|
|
58
|
-
Draw as default
|
|
59
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import { Position } from '../../types/coordinate/descartes';
|
|
3
|
-
import { StrokeProps } from '../../types/svg/stroke';
|
|
4
|
-
import { ArrowConfig, ArrowProps, DrawWayType } from './types';
|
|
5
|
-
export type InnerDrawProps = {
|
|
6
|
-
/** 位置偏移 */
|
|
7
|
-
offset: Position;
|
|
8
|
-
way: DrawWayType[];
|
|
9
|
-
children?: ReactNode;
|
|
10
|
-
} & StrokeProps & ArrowProps<ArrowConfig>;
|
|
11
|
-
declare const InnerDraw: import('react').ForwardRefExoticComponent<{
|
|
12
|
-
/** 位置偏移 */
|
|
13
|
-
offset: Position;
|
|
14
|
-
way: DrawWayType[];
|
|
15
|
-
children?: ReactNode;
|
|
16
|
-
} & StrokeProps & ArrowProps<ArrowConfig> & import('react').RefAttributes<SVGPathElement>>;
|
|
17
|
-
export default InnerDraw;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef, useMemo } from "react";
|
|
3
|
-
import Group from "../../container/Group.js";
|
|
4
|
-
import { PathContext } from "../../hooks/context/usePath.js";
|
|
5
|
-
import PathModel from "../../model/component/path.js";
|
|
6
|
-
import { getDrawPointType } from "./common.js";
|
|
7
|
-
import DrawSegment from "./segment/index.js";
|
|
8
|
-
const InnerDraw = forwardRef((props, ref) => {
|
|
9
|
-
const { way, offset, startArrow, startArrows, endArrow, endArrows, children, ...strokeProps } = props;
|
|
10
|
-
const waySegments = useMemo(() => {
|
|
11
|
-
let preNodeType = "coordinate";
|
|
12
|
-
const waySegments2 = [];
|
|
13
|
-
let waySegment = [];
|
|
14
|
-
for (let i = 0; i < way.length; i++) {
|
|
15
|
-
const point = way[i];
|
|
16
|
-
const currentNodeType = getDrawPointType(point);
|
|
17
|
-
waySegment.push(point);
|
|
18
|
-
if (currentNodeType === "node" && preNodeType === "node" && waySegment.length >= 2) {
|
|
19
|
-
waySegments2.push(waySegment);
|
|
20
|
-
waySegment = [waySegment[waySegment.length - 1]];
|
|
21
|
-
}
|
|
22
|
-
if (i === way.length - 1 && waySegment.length > 1) {
|
|
23
|
-
waySegments2.push(waySegment);
|
|
24
|
-
}
|
|
25
|
-
preNodeType = currentNodeType;
|
|
26
|
-
}
|
|
27
|
-
return waySegments2;
|
|
28
|
-
}, [way]);
|
|
29
|
-
return /* @__PURE__ */ jsx(
|
|
30
|
-
PathContext.Provider,
|
|
31
|
-
{
|
|
32
|
-
value: new PathModel(new Array(waySegments.length).fill([]), Number(strokeProps.strokeWidth) || 1, false),
|
|
33
|
-
children: /* @__PURE__ */ jsxs(Group, { ref, transform: `translate(${offset[0]}, ${offset[1]})`, children: [
|
|
34
|
-
waySegments.map((segment, index) => /* @__PURE__ */ jsx(
|
|
35
|
-
DrawSegment,
|
|
36
|
-
{
|
|
37
|
-
index,
|
|
38
|
-
way: segment,
|
|
39
|
-
...strokeProps,
|
|
40
|
-
endArrow: index === waySegments.length - 1 ? endArrow || endArrows : endArrows,
|
|
41
|
-
startArrow: index === waySegments.length - 1 ? startArrow || startArrows : startArrows
|
|
42
|
-
},
|
|
43
|
-
JSON.stringify(segment)
|
|
44
|
-
)),
|
|
45
|
-
children
|
|
46
|
-
] })
|
|
47
|
-
}
|
|
48
|
-
);
|
|
49
|
-
});
|
|
50
|
-
export {
|
|
51
|
-
InnerDraw as default
|
|
52
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
const getCirclePath = (attributes) => {
|
|
2
|
-
const {
|
|
3
|
-
width = 5,
|
|
4
|
-
left = false,
|
|
5
|
-
right = false,
|
|
6
|
-
scale = 1
|
|
7
|
-
} = attributes;
|
|
8
|
-
const radius = width / 2 * scale;
|
|
9
|
-
const diameter = width * scale;
|
|
10
|
-
const startPoint = [0, 0];
|
|
11
|
-
const path = `M ${startPoint.join(",")} ` + (left ? `A ${radius},${radius} 0 1,0 ${-diameter},0 Z` : right ? `A ${radius},${radius} 0 1,1 ${-diameter},0 Z` : `A ${radius},${radius} 0 1,0 ${-diameter},0A ${radius},${radius} 0 1,0 ${startPoint.join(",")} Z`);
|
|
12
|
-
return {
|
|
13
|
-
d: path,
|
|
14
|
-
offsetDistance: radius,
|
|
15
|
-
insertDistance: radius
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
export {
|
|
19
|
-
getCirclePath as default
|
|
20
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ArrowAttributes, ArrowPathConfig } from './types';
|
|
2
|
-
export type { ArrowAttributes as ArrowPositionAttributes, ArrowPathConfig };
|
|
3
|
-
export type ArrowType = 'Stealth' | 'Circle';
|
|
4
|
-
declare const getArrowPath: (type: ArrowType, attributes: ArrowAttributes) => {
|
|
5
|
-
d: string;
|
|
6
|
-
offsetDistance: number;
|
|
7
|
-
insertDistance: number;
|
|
8
|
-
};
|
|
9
|
-
export default getArrowPath;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import getCirclePath from "./circle.js";
|
|
2
|
-
import getStealthPath from "./stealth.js";
|
|
3
|
-
const getArrowPath = (type, attributes) => {
|
|
4
|
-
switch (type) {
|
|
5
|
-
case "Stealth":
|
|
6
|
-
return getStealthPath(attributes);
|
|
7
|
-
case "Circle":
|
|
8
|
-
return getCirclePath(attributes);
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
export {
|
|
12
|
-
getArrowPath as default
|
|
13
|
-
};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import line from "../../../node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/line.js";
|
|
2
|
-
const getStealthPath = (attributes) => {
|
|
3
|
-
const {
|
|
4
|
-
width = 4,
|
|
5
|
-
length = 5,
|
|
6
|
-
insert = 1.75,
|
|
7
|
-
left = false,
|
|
8
|
-
right = false,
|
|
9
|
-
scale = 1,
|
|
10
|
-
strokeWidth = 1,
|
|
11
|
-
round,
|
|
12
|
-
strokeLinejoin = "miter"
|
|
13
|
-
} = attributes;
|
|
14
|
-
const startPoint = [0, 0];
|
|
15
|
-
const leftPoint = [-length * scale, -width / 2 * scale];
|
|
16
|
-
const insertPoint = [(-length + insert) * scale, 0];
|
|
17
|
-
const rightPoint = [-length * scale, width / 2 * scale];
|
|
18
|
-
const way = left ? [startPoint, leftPoint, insertPoint] : right ? [startPoint, rightPoint, insertPoint] : [startPoint, leftPoint, insertPoint, rightPoint];
|
|
19
|
-
const straightLine = line().x((d) => d[0]).y((d) => d[1]);
|
|
20
|
-
const radio = width / 2 / Math.sqrt(length ** 2 + (width / 2) ** 2);
|
|
21
|
-
return {
|
|
22
|
-
d: straightLine(way) + "Z",
|
|
23
|
-
offsetDistance: round || strokeLinejoin === "round" ? strokeWidth / 2 : strokeWidth / (2 * radio),
|
|
24
|
-
insertDistance: length - insert
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
export {
|
|
28
|
-
getStealthPath as default
|
|
29
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/** 箭头属性 */
|
|
2
|
-
export type ArrowAttributes = {
|
|
3
|
-
width?: number;
|
|
4
|
-
length?: number;
|
|
5
|
-
insert?: number;
|
|
6
|
-
left?: boolean;
|
|
7
|
-
right?: boolean;
|
|
8
|
-
round?: boolean;
|
|
9
|
-
strokeWidth?: number;
|
|
10
|
-
scale?: number;
|
|
11
|
-
linkType?: 'center' | 'end';
|
|
12
|
-
strokeLinejoin?: "round" | "inherit" | "bevel" | "miter";
|
|
13
|
-
};
|
|
14
|
-
export type ArrowPathConfig = {
|
|
15
|
-
/** path d 属性路径 */
|
|
16
|
-
d: string;
|
|
17
|
-
/** 箭头顶点与 path 顶点的距离 */
|
|
18
|
-
offsetDistance: number;
|
|
19
|
-
/** insert 点与 path 顶点的距离 */
|
|
20
|
-
insertDistance: number;
|
|
21
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
const offsetReg = /\+[[(]?[+-]?\d+(?:\.\d+)?,\s*[+-]?\d+(?:\.\d+)?[)\]]?/;
|
|
2
|
-
const moveReg = /\+\+[[(]?[+-]?\d+(?:\.\d+)?,\s*[+-]?\d+(?:\.\d+)?[)\]]?/;
|
|
3
|
-
const getDrawPointType = (point) => {
|
|
4
|
-
if (typeof point !== "string") return "coordinate";
|
|
5
|
-
if (["-|", "|-", "-|-", "|-|"].includes(point)) return "vertical";
|
|
6
|
-
if (point.match(moveReg)) return "move";
|
|
7
|
-
if (point.match(offsetReg)) return "offset";
|
|
8
|
-
return "node";
|
|
9
|
-
};
|
|
10
|
-
export {
|
|
11
|
-
getDrawPointType
|
|
12
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
|
-
import { Position } from '../../../types/coordinate/descartes';
|
|
3
|
-
import { StrokeProps } from '../../../types/svg/stroke';
|
|
4
|
-
import { ArrowConfig } from '../types';
|
|
5
|
-
export type InnerDrawSegmentProps = {
|
|
6
|
-
/** 路径,始末节点为 undefined 表示临近点在 node 外边界内 */
|
|
7
|
-
way: Position[];
|
|
8
|
-
startArrow?: ArrowConfig;
|
|
9
|
-
endArrow?: ArrowConfig;
|
|
10
|
-
} & StrokeProps;
|
|
11
|
-
declare const InnerDrawSegment: FC<InnerDrawSegmentProps>;
|
|
12
|
-
export default InnerDrawSegment;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo } from "react";
|
|
3
|
-
import Path from "../../../elements/Path.js";
|
|
4
|
-
import Group from "../../../container/Group.js";
|
|
5
|
-
import useArrow from "./useArrow.js";
|
|
6
|
-
import line from "../../../node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/line.js";
|
|
7
|
-
const InnerDrawSegment = (props) => {
|
|
8
|
-
const { way, startArrow, endArrow, ...strokeProps } = props;
|
|
9
|
-
const pickedArrowStrokeProps = {
|
|
10
|
-
stroke: strokeProps.stroke,
|
|
11
|
-
strokeWidth: Number(strokeProps.strokeWidth),
|
|
12
|
-
strokeOpacity: strokeProps.strokeOpacity
|
|
13
|
-
};
|
|
14
|
-
const startArrowPath = useArrow(
|
|
15
|
-
{ position: way[0], nearPosition: way[1], arrowType: "start" },
|
|
16
|
-
startArrow ? { ...pickedArrowStrokeProps, ...startArrow } : void 0
|
|
17
|
-
);
|
|
18
|
-
const endArrowPath = useArrow(
|
|
19
|
-
{ position: way[way.length - 1], nearPosition: way[way.length - 2], arrowType: "end" },
|
|
20
|
-
endArrow ? { ...pickedArrowStrokeProps, ...endArrow } : void 0
|
|
21
|
-
);
|
|
22
|
-
const d = useMemo(() => {
|
|
23
|
-
const realWay = [...way];
|
|
24
|
-
if (startArrowPath) {
|
|
25
|
-
realWay[0] = startArrowPath.linkPoint;
|
|
26
|
-
}
|
|
27
|
-
if (endArrowPath) {
|
|
28
|
-
realWay[realWay.length - 1] = endArrowPath.linkPoint;
|
|
29
|
-
}
|
|
30
|
-
const straightLine = line().x((d2) => d2[0]).y((d2) => d2[1]);
|
|
31
|
-
return straightLine(realWay);
|
|
32
|
-
}, [way]);
|
|
33
|
-
return endArrowPath || startArrowPath ? /* @__PURE__ */ jsxs(Group, { children: [
|
|
34
|
-
/* @__PURE__ */ jsx(Path, { d: d ?? "", ...strokeProps }),
|
|
35
|
-
startArrowPath ? startArrowPath.arrowPath : null,
|
|
36
|
-
endArrowPath ? endArrowPath.arrowPath : null
|
|
37
|
-
] }) : /* @__PURE__ */ jsx(Path, { d: d ?? "", ...strokeProps });
|
|
38
|
-
};
|
|
39
|
-
export {
|
|
40
|
-
InnerDrawSegment as default
|
|
41
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
|
-
import { StrokeProps } from '../../../types/svg/stroke';
|
|
3
|
-
import { ArrowConfig, DrawWaySegmentType } from '../types';
|
|
4
|
-
export type DrawSegmentProps = {
|
|
5
|
-
/** 路径,首位可以是 Node,其他必须是坐标 */
|
|
6
|
-
way: DrawWaySegmentType;
|
|
7
|
-
index: number;
|
|
8
|
-
/** 线段样式 */
|
|
9
|
-
strokeType?: 'solid' | 'dashed' | 'dotted';
|
|
10
|
-
startArrow?: ArrowConfig;
|
|
11
|
-
endArrow?: ArrowConfig;
|
|
12
|
-
} & StrokeProps;
|
|
13
|
-
/** 单条连续的路径 */
|
|
14
|
-
declare const DrawSegment: FC<DrawSegmentProps>;
|
|
15
|
-
export default DrawSegment;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo } from "react";
|
|
3
|
-
import NodeModel from "../../../model/component/node.js";
|
|
4
|
-
import { convertStrokeType } from "../../../utils/style/stroke.js";
|
|
5
|
-
import InnerDrawSegment from "./Segment.js";
|
|
6
|
-
import useConvertWay from "./useConvertWay.js";
|
|
7
|
-
import usePath from "../../../hooks/context/usePath.js";
|
|
8
|
-
const DrawSegment = (props) => {
|
|
9
|
-
const { way, index, startArrow, endArrow, ...resProps } = props;
|
|
10
|
-
const { strokeType = "solid", strokeWidth = 1, ...strokeProps } = resProps;
|
|
11
|
-
const [convertedWay, nodesInit] = useConvertWay(way);
|
|
12
|
-
const { model, updateModel } = usePath();
|
|
13
|
-
const pointWay = useMemo(() => {
|
|
14
|
-
const realWay = convertedWay.map((wayPoint, index2) => {
|
|
15
|
-
if (wayPoint instanceof NodeModel) {
|
|
16
|
-
const neighborPoint = index2 === 0 ? convertedWay[1] : convertedWay[index2 - 1];
|
|
17
|
-
return wayPoint.getCrossPoint(neighborPoint instanceof NodeModel ? neighborPoint.center : neighborPoint);
|
|
18
|
-
}
|
|
19
|
-
return wayPoint;
|
|
20
|
-
});
|
|
21
|
-
const newWay = [...model.ways];
|
|
22
|
-
newWay[index] = realWay;
|
|
23
|
-
updateModel({ ways: newWay, init: nodesInit });
|
|
24
|
-
return realWay;
|
|
25
|
-
}, [convertedWay]);
|
|
26
|
-
if (!nodesInit) return null;
|
|
27
|
-
return /* @__PURE__ */ jsx(
|
|
28
|
-
InnerDrawSegment,
|
|
29
|
-
{
|
|
30
|
-
way: pointWay,
|
|
31
|
-
startArrow,
|
|
32
|
-
endArrow,
|
|
33
|
-
strokeWidth,
|
|
34
|
-
...convertStrokeType(strokeType, strokeWidth),
|
|
35
|
-
...strokeProps
|
|
36
|
-
}
|
|
37
|
-
);
|
|
38
|
-
};
|
|
39
|
-
export {
|
|
40
|
-
DrawSegment as default
|
|
41
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { ArrowConfig } from '../types';
|
|
2
|
-
import { Position } from '../../../types/coordinate/descartes';
|
|
3
|
-
export type ArrowLinkConfig = {
|
|
4
|
-
nearPosition: Position;
|
|
5
|
-
position: Position;
|
|
6
|
-
arrowType: 'start' | 'end';
|
|
7
|
-
};
|
|
8
|
-
declare const useArrow: (linkConfig: ArrowLinkConfig, arrowConfig?: ArrowConfig) => {
|
|
9
|
-
linkPoint: Position;
|
|
10
|
-
arrowPath: import("react/jsx-runtime").JSX.Element;
|
|
11
|
-
} | null;
|
|
12
|
-
export default useArrow;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo } from "react";
|
|
3
|
-
import useCalculate from "../../../hooks/context/useCalculate.js";
|
|
4
|
-
import getArrowPath from "../arrow/index.js";
|
|
5
|
-
import Path from "../../../elements/Path.js";
|
|
6
|
-
import Line from "../../../model/equation/line.js";
|
|
7
|
-
import { convertPrecision } from "../../../utils/math.js";
|
|
8
|
-
const useArrow = (linkConfig, arrowConfig) => {
|
|
9
|
-
const { precision } = useCalculate();
|
|
10
|
-
return useMemo(() => {
|
|
11
|
-
if (!arrowConfig) return null;
|
|
12
|
-
const { position, nearPosition } = linkConfig;
|
|
13
|
-
const { type, stroke, linkType = "end", round, strokeLinejoin, strokeWidth, ...strokeProps } = arrowConfig;
|
|
14
|
-
const degree = Line.getDegree(nearPosition, position);
|
|
15
|
-
const isRound = round || strokeLinejoin === "round";
|
|
16
|
-
const realStrokeWidth = strokeWidth ?? 1;
|
|
17
|
-
const { d, offsetDistance, insertDistance } = getArrowPath(type, arrowConfig);
|
|
18
|
-
const endOffset = [
|
|
19
|
-
(isRound ? realStrokeWidth : offsetDistance) * Math.cos(degree),
|
|
20
|
-
(isRound ? realStrokeWidth : offsetDistance) * Math.sin(degree)
|
|
21
|
-
];
|
|
22
|
-
const translatePosition = linkType === "end" ? [position[0] - endOffset[0], position[1] - endOffset[1]] : [position[0] + insertDistance * Math.cos(degree), position[1] + insertDistance * Math.sin(degree)];
|
|
23
|
-
const linkPoint = linkType === "end" ? [
|
|
24
|
-
position[0] - insertDistance * Math.cos(degree) - endOffset[0],
|
|
25
|
-
position[1] - insertDistance * Math.sin(degree) - endOffset[1]
|
|
26
|
-
] : position;
|
|
27
|
-
const transform = `translate(
|
|
28
|
-
${convertPrecision(translatePosition[0], precision)}, ${convertPrecision(
|
|
29
|
-
translatePosition[1],
|
|
30
|
-
precision
|
|
31
|
-
)}) rotate(${convertPrecision(degree * (180 / Math.PI), precision)})`;
|
|
32
|
-
return {
|
|
33
|
-
linkPoint,
|
|
34
|
-
arrowPath: /* @__PURE__ */ jsx(
|
|
35
|
-
Path,
|
|
36
|
-
{
|
|
37
|
-
d,
|
|
38
|
-
strokeWidth,
|
|
39
|
-
strokeLinejoin: round ? "round" : "miter",
|
|
40
|
-
strokeMiterlimit: 10,
|
|
41
|
-
fill: stroke || "currentColor",
|
|
42
|
-
stroke,
|
|
43
|
-
transform,
|
|
44
|
-
...strokeProps
|
|
45
|
-
}
|
|
46
|
-
)
|
|
47
|
-
};
|
|
48
|
-
}, [arrowConfig, linkConfig]);
|
|
49
|
-
};
|
|
50
|
-
export {
|
|
51
|
-
useArrow as default
|
|
52
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { default as NodeModel } from '../../../model/component/node';
|
|
2
|
-
import { PointPosition } from '../../../types/coordinate';
|
|
3
|
-
import { Position } from '../../../types/coordinate/descartes';
|
|
4
|
-
import { DrawWaySegmentType } from '../types';
|
|
5
|
-
/** 将坐标格式转换为笛卡尔坐标数组形式 */
|
|
6
|
-
export declare const formatPointPosition: (point: PointPosition) => Position;
|
|
7
|
-
/** 获取两点间的垂直点 */
|
|
8
|
-
export declare const getVerticalPoint: (point1: PointPosition, point2: PointPosition, type: "-|" | "|-" | "-|-" | "|-|") => Position | Position[];
|
|
9
|
-
/**
|
|
10
|
-
* 将特殊路径点转换为坐标,Node 节点转换为对应的 Model
|
|
11
|
-
* 目前支持的节点类型:node,各种坐标,垂点,位移点
|
|
12
|
-
*/
|
|
13
|
-
declare const useConvertWay: (way: DrawWaySegmentType) => [Array<Position | NodeModel>, boolean];
|
|
14
|
-
export default useConvertWay;
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { useRef, useMemo, useLayoutEffect } from "react";
|
|
2
|
-
import useNodes from "../../../hooks/context/useNodes.js";
|
|
3
|
-
import useForceUpdate from "../../../hooks/useForceUpdate.js";
|
|
4
|
-
import DescartesPoint from "../../../model/geometry/point/DescartesPoint.js";
|
|
5
|
-
import PolarPoint from "../../../model/geometry/point/PolarPoint.js";
|
|
6
|
-
import { getDrawPointType } from "../common.js";
|
|
7
|
-
const formatPointPosition = (point) => {
|
|
8
|
-
if (Array.isArray(point)) return point;
|
|
9
|
-
if ("x" in point && "y" in point) {
|
|
10
|
-
const p = point;
|
|
11
|
-
return [p.x, p.y];
|
|
12
|
-
}
|
|
13
|
-
return PolarPoint.convertPolarToDescartesPosition(point);
|
|
14
|
-
};
|
|
15
|
-
const getVerticalPoint = (point1, point2, type) => {
|
|
16
|
-
const p1 = formatPointPosition(point1);
|
|
17
|
-
const p2 = formatPointPosition(point2);
|
|
18
|
-
if (["-|", "|-"].includes(type)) return type === "-|" ? [p2[0], p1[1]] : [p1[0], p2[1]];
|
|
19
|
-
if (type === "-|-") {
|
|
20
|
-
const centerX = (p1[0] + p2[0]) / 2;
|
|
21
|
-
return [[centerX, p1[1]], [centerX, p2[1]]];
|
|
22
|
-
}
|
|
23
|
-
const centerY = (p1[1] + p2[1]) / 2;
|
|
24
|
-
return [[p1[0], centerY], [p2[0], centerY]];
|
|
25
|
-
};
|
|
26
|
-
const convertOffsetAndMovePoint = (point) => {
|
|
27
|
-
const filterPoint = point.replace(/[+()[\]\s]/g, "");
|
|
28
|
-
return filterPoint.split(",").map((item) => parseFloat(item));
|
|
29
|
-
};
|
|
30
|
-
const useConvertWay = (way) => {
|
|
31
|
-
const { getModel, subscribeModel } = useNodes();
|
|
32
|
-
const forceUpdate = useForceUpdate();
|
|
33
|
-
const nodeUpdateCount = useRef(0);
|
|
34
|
-
let cursor = [0, 0];
|
|
35
|
-
const tryGetModel = (name) => {
|
|
36
|
-
const model = getModel(name);
|
|
37
|
-
if (!model) {
|
|
38
|
-
throw new Error(`Node ${name} is not defined`);
|
|
39
|
-
}
|
|
40
|
-
cursor = model.center;
|
|
41
|
-
return model;
|
|
42
|
-
};
|
|
43
|
-
const subscribeCbs = [];
|
|
44
|
-
let allNodeInit = true;
|
|
45
|
-
const result = useMemo(
|
|
46
|
-
() => way.reduce((acc, item, index) => {
|
|
47
|
-
const type = getDrawPointType(item);
|
|
48
|
-
switch (type) {
|
|
49
|
-
case "coordinate": {
|
|
50
|
-
const corPosition = formatPointPosition(item);
|
|
51
|
-
cursor = corPosition;
|
|
52
|
-
acc.push(corPosition);
|
|
53
|
-
return acc;
|
|
54
|
-
}
|
|
55
|
-
case "node": {
|
|
56
|
-
if (![0, way.length - 1].includes(index)) {
|
|
57
|
-
throw new Error(
|
|
58
|
-
"Node can only be the first or last point on DrawSegment component, this may be a retikz bug, please report it."
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
const nodeModel = tryGetModel(item);
|
|
62
|
-
if (!nodeModel.init) allNodeInit = false;
|
|
63
|
-
const cb = subscribeModel(item, () => {
|
|
64
|
-
nodeUpdateCount.current += 1;
|
|
65
|
-
forceUpdate();
|
|
66
|
-
});
|
|
67
|
-
if (cb) subscribeCbs.push(cb);
|
|
68
|
-
cursor = nodeModel.center;
|
|
69
|
-
acc.push(nodeModel);
|
|
70
|
-
return acc;
|
|
71
|
-
}
|
|
72
|
-
case "vertical": {
|
|
73
|
-
if ([0, way.length - 1].includes(index)) {
|
|
74
|
-
throw new Error("Vertical point can not be the first point on path.");
|
|
75
|
-
}
|
|
76
|
-
const beforePosition = cursor;
|
|
77
|
-
const afterPoint = way[index + 1];
|
|
78
|
-
const afterPointType = getDrawPointType(afterPoint);
|
|
79
|
-
if (["vertical", "offset", "move"].includes(afterPointType)) {
|
|
80
|
-
throw new Error("Vertical point can not be followed by these point type: vertical offset move.");
|
|
81
|
-
}
|
|
82
|
-
const afterPosition = afterPointType === "node" ? tryGetModel(afterPoint).center : formatPointPosition(afterPoint);
|
|
83
|
-
const verPosition = getVerticalPoint(beforePosition, afterPosition, item);
|
|
84
|
-
if (Array.isArray(verPosition[0])) {
|
|
85
|
-
const realVerPosition = verPosition;
|
|
86
|
-
cursor = realVerPosition[realVerPosition.length - 1];
|
|
87
|
-
for (const point of realVerPosition) {
|
|
88
|
-
acc.push(point);
|
|
89
|
-
}
|
|
90
|
-
return acc;
|
|
91
|
-
}
|
|
92
|
-
cursor = verPosition;
|
|
93
|
-
acc.push(verPosition);
|
|
94
|
-
return acc;
|
|
95
|
-
}
|
|
96
|
-
default: {
|
|
97
|
-
if (index === 0) throw new Error("offset/move point can not be the first point on path.");
|
|
98
|
-
const convertedPos = convertOffsetAndMovePoint(item);
|
|
99
|
-
const curPos = DescartesPoint.plus(convertedPos, cursor);
|
|
100
|
-
if (type === "move") cursor = curPos;
|
|
101
|
-
acc.push(curPos);
|
|
102
|
-
return acc;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}, []),
|
|
106
|
-
[way, nodeUpdateCount.current]
|
|
107
|
-
);
|
|
108
|
-
useLayoutEffect(() => () => {
|
|
109
|
-
subscribeCbs.forEach((cb) => cb && cb());
|
|
110
|
-
});
|
|
111
|
-
return [result, allNodeInit];
|
|
112
|
-
};
|
|
113
|
-
export {
|
|
114
|
-
useConvertWay as default,
|
|
115
|
-
formatPointPosition,
|
|
116
|
-
getVerticalPoint
|
|
117
|
-
};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { PointPosition } from '../../types/coordinate';
|
|
2
|
-
import { StrokeProps } from '../../types/svg/stroke';
|
|
3
|
-
import { TikZKey } from '../../types/tikz';
|
|
4
|
-
import { ArrowPositionAttributes, ArrowType } from './arrow';
|
|
5
|
-
export type ArrowConfig = {
|
|
6
|
-
type: ArrowType;
|
|
7
|
-
fill?: string;
|
|
8
|
-
} & ArrowPositionAttributes & StrokeProps;
|
|
9
|
-
/** 垂直路径点,临近的节点不能都是特殊路径点 */
|
|
10
|
-
export type VerticalDrawPosition = '-|' | '|-' | '-|-' | '|-|';
|
|
11
|
-
/** 偏移与移动点 */
|
|
12
|
-
export type OffSetOrMovePosition = string;
|
|
13
|
-
/** 路径点类型:节点,坐标,垂点,偏移点,移动点 */
|
|
14
|
-
export type DrawPointType = 'node' | 'coordinate' | 'vertical' | 'offset' | 'move';
|
|
15
|
-
/** 路径节点类型 */
|
|
16
|
-
export type DrawWayType = TikZKey | PointPosition | VerticalDrawPosition | OffSetOrMovePosition;
|
|
17
|
-
/** 路径片段节点类型 */
|
|
18
|
-
export type DrawWaySegmentType = [
|
|
19
|
-
TikZKey | PointPosition,
|
|
20
|
-
...Array<PointPosition | VerticalDrawPosition | OffSetOrMovePosition>,
|
|
21
|
-
TikZKey | PointPosition
|
|
22
|
-
];
|
|
23
|
-
/** 箭头属性 */
|
|
24
|
-
export type ArrowProps<T = ArrowType | ArrowConfig> = {
|
|
25
|
-
startArrow?: T;
|
|
26
|
-
startArrows?: T;
|
|
27
|
-
endArrow?: T;
|
|
28
|
-
endArrows?: T;
|
|
29
|
-
};
|