@retikz/core 0.0.1-rc.2 → 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 +21 -29
- 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 -110
- 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 -1
- 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 -110
- 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 -1
- 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
package/dist/es/elements/Path.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef } from "react";
|
|
3
|
-
const Path = forwardRef((props, ref) => {
|
|
4
|
-
const { fill: propFill, strokeWidth: propStrokeWidth, stroke: propStroke, ...otherProps } = props;
|
|
5
|
-
const defaultProps = {
|
|
6
|
-
fill: propFill || "transparent",
|
|
7
|
-
strokeWidth: propStrokeWidth ?? 1,
|
|
8
|
-
stroke: propStroke || "currentColor"
|
|
9
|
-
};
|
|
10
|
-
return /* @__PURE__ */ jsx("path", { ref, ...defaultProps, ...otherProps });
|
|
11
|
-
});
|
|
12
|
-
export {
|
|
13
|
-
Path as default
|
|
14
|
-
};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { PropsWithChildren, SVGProps } from 'react';
|
|
2
|
-
export type RectProps = SVGProps<SVGRectElement>;
|
|
3
|
-
declare const Rect: import('react').ForwardRefExoticComponent<Omit<PropsWithChildren<RectProps>, "ref"> & import('react').RefAttributes<SVGRectElement>>;
|
|
4
|
-
export default Rect;
|
package/dist/es/elements/Rect.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { PropsWithChildren, SVGProps } from 'react';
|
|
2
|
-
import { FontProps } from '../types/svg/font';
|
|
3
|
-
type TextVerticalAlign = 'top' | 'center' | 'bottom';
|
|
4
|
-
export type DominantBaseline = 'auto' | 'text-bottom' | 'alphabetic' | 'ideographic' | 'middle' | 'central' | 'mathematical' | 'hanging' | 'text-top';
|
|
5
|
-
export type TextProps = {
|
|
6
|
-
x?: SVGProps<SVGTextElement>['x'];
|
|
7
|
-
y?: SVGProps<SVGTextElement>['y'];
|
|
8
|
-
align?: 'start' | 'middle' | 'end' | 'inherit';
|
|
9
|
-
verticalAlign?: TextVerticalAlign | DominantBaseline;
|
|
10
|
-
fontSize?: SVGProps<SVGTextElement>['fontSize'];
|
|
11
|
-
fill?: SVGProps<SVGTextElement>['fill'];
|
|
12
|
-
} & FontProps & SVGProps<SVGTextElement>;
|
|
13
|
-
/**
|
|
14
|
-
* 文本节点
|
|
15
|
-
* @tikz node
|
|
16
|
-
*/
|
|
17
|
-
declare const Text: import('react').ForwardRefExoticComponent<Omit<PropsWithChildren<TextProps>, "ref"> & import('react').RefAttributes<SVGTextElement>>;
|
|
18
|
-
export default Text;
|
package/dist/es/elements/Text.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef, useMemo } from "react";
|
|
3
|
-
import { textWrapParse } from "../utils/string.js";
|
|
4
|
-
const Text = forwardRef((props, ref) => {
|
|
5
|
-
const { children, align, verticalAlign, fontSize, fill, ...otherProps } = props;
|
|
6
|
-
const dominantBaseline = useMemo(() => {
|
|
7
|
-
switch (verticalAlign) {
|
|
8
|
-
case "top":
|
|
9
|
-
return "text-top";
|
|
10
|
-
case "bottom":
|
|
11
|
-
return "text-bottom";
|
|
12
|
-
case "center":
|
|
13
|
-
return "central";
|
|
14
|
-
default:
|
|
15
|
-
return verticalAlign;
|
|
16
|
-
}
|
|
17
|
-
}, [verticalAlign]);
|
|
18
|
-
const textProps = {
|
|
19
|
-
textAnchor: align || "middle",
|
|
20
|
-
dominantBaseline: dominantBaseline || "central",
|
|
21
|
-
fontSize: fontSize || "1em",
|
|
22
|
-
fill: fill || "currentColor",
|
|
23
|
-
...otherProps
|
|
24
|
-
};
|
|
25
|
-
const parseChildren = (children2) => {
|
|
26
|
-
if (typeof children2 === "string") {
|
|
27
|
-
return textWrapParse(children2).map((child, index) => /* @__PURE__ */ jsx("tspan", { children: child }, index));
|
|
28
|
-
}
|
|
29
|
-
return children2;
|
|
30
|
-
};
|
|
31
|
-
return /* @__PURE__ */ jsx("text", { ref, ...textProps, children: parseChildren(children) });
|
|
32
|
-
});
|
|
33
|
-
export {
|
|
34
|
-
Text as default
|
|
35
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export type CalculateProps = {
|
|
2
|
-
precision: number | false;
|
|
3
|
-
};
|
|
4
|
-
export declare const CalculateContext: import('react').Context<CalculateProps>;
|
|
5
|
-
declare const useCalculate: () => CalculateProps;
|
|
6
|
-
export declare const useCalculateValue: (value: number, deep?: boolean) => number;
|
|
7
|
-
export default useCalculate;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { default as NodeModel, NodeConfig, StateListener } from '../../model/component/node';
|
|
2
|
-
export declare const NodesContext: import('react').Context<Map<string, NodeModel>>;
|
|
3
|
-
declare const useNodes: () => {
|
|
4
|
-
subscribeModel: (name: string, listener: StateListener) => false | (() => boolean);
|
|
5
|
-
getModel: (name: string) => NodeModel | undefined;
|
|
6
|
-
updateModel: (name: string, config: NodeConfig, init?: boolean) => void;
|
|
7
|
-
deleteModel: (name: string) => void;
|
|
8
|
-
};
|
|
9
|
-
export default useNodes;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { createContext, useContext } from "react";
|
|
2
|
-
import NodeModel from "../../model/component/node.js";
|
|
3
|
-
const NodesContext = createContext(/* @__PURE__ */ new Map());
|
|
4
|
-
const useNodes = () => {
|
|
5
|
-
const nodes = useContext(NodesContext);
|
|
6
|
-
return {
|
|
7
|
-
subscribeModel: (name, listener) => {
|
|
8
|
-
const model = nodes.get(name);
|
|
9
|
-
if (!model) return false;
|
|
10
|
-
return model.subscribe(listener);
|
|
11
|
-
},
|
|
12
|
-
getModel: (name) => nodes.get(name),
|
|
13
|
-
updateModel: (name, config, init = true) => {
|
|
14
|
-
const model = nodes.get(name);
|
|
15
|
-
if (model) {
|
|
16
|
-
model.update(config, init);
|
|
17
|
-
} else {
|
|
18
|
-
nodes.set(name, new NodeModel(config, init));
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
deleteModel: (name) => {
|
|
22
|
-
const model = nodes.get(name);
|
|
23
|
-
if (!model) return;
|
|
24
|
-
model.dispose();
|
|
25
|
-
model.notify();
|
|
26
|
-
nodes.delete(name);
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
export {
|
|
31
|
-
NodesContext,
|
|
32
|
-
useNodes as default
|
|
33
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { default as PathModel, StateListener } from '../../model/component/path';
|
|
2
|
-
import { Position } from '../../types/coordinate/descartes';
|
|
3
|
-
export declare const PathContext: import('react').Context<PathModel | null>;
|
|
4
|
-
declare const usePath: () => {
|
|
5
|
-
model: PathModel;
|
|
6
|
-
subscribeModel: (listener: StateListener) => (() => boolean) | undefined;
|
|
7
|
-
updateModel: (config: {
|
|
8
|
-
ways?: Array<Position[]>;
|
|
9
|
-
lineWidth?: number;
|
|
10
|
-
init?: boolean;
|
|
11
|
-
}) => void;
|
|
12
|
-
};
|
|
13
|
-
export default usePath;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { createContext, useContext } from "react";
|
|
2
|
-
const PathContext = createContext(null);
|
|
3
|
-
const usePath = () => {
|
|
4
|
-
const pathModel = useContext(PathContext);
|
|
5
|
-
if (!pathModel) throw new Error("usePath must be used within a PathProvider");
|
|
6
|
-
return {
|
|
7
|
-
model: pathModel,
|
|
8
|
-
subscribeModel: (listener) => {
|
|
9
|
-
if (!pathModel) return;
|
|
10
|
-
return pathModel.subscribe(listener);
|
|
11
|
-
},
|
|
12
|
-
updateModel: (config) => {
|
|
13
|
-
pathModel == null ? void 0 : pathModel.update(config);
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
export {
|
|
18
|
-
PathContext,
|
|
19
|
-
usePath as default
|
|
20
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { DrawProps } from '../../components/draw/Draw';
|
|
2
|
-
import { NodeProps } from '../../components/node';
|
|
3
|
-
import { Position } from '../../types/coordinate/descartes';
|
|
4
|
-
export type ScopeProps = {
|
|
5
|
-
offset?: Position;
|
|
6
|
-
node?: Omit<NodeProps, 'name' | 'ref' | 'position' | 'offset'>;
|
|
7
|
-
draw?: Omit<DrawProps, 'ref' | 'way' | 'offset'>;
|
|
8
|
-
};
|
|
9
|
-
export declare const ScopeContext: import('react').Context<ScopeProps>;
|
|
10
|
-
declare const useScope: () => ScopeProps;
|
|
11
|
-
export default useScope;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { Direction } from '../../types/coordinate';
|
|
2
|
-
import { Position } from '../../types/coordinate/descartes';
|
|
3
|
-
import { DirectionDistance } from '../../types/distance';
|
|
4
|
-
import { Area, Size } from '../../types/shape';
|
|
5
|
-
import { RectMidPoint, RectThirdPoint, RectVertexPoint } from '../../types/shape/rect';
|
|
6
|
-
export type StateListener = (state?: NodeModel, prevState?: NodeModel) => void;
|
|
7
|
-
export type NodeConfig = {
|
|
8
|
-
/** 内容中心位置 */
|
|
9
|
-
position: Position;
|
|
10
|
-
/** 内容(文本)尺寸 */
|
|
11
|
-
contentSize: Size;
|
|
12
|
-
/** 内边框距离 */
|
|
13
|
-
innerSep: DirectionDistance;
|
|
14
|
-
/** 外边框距离 */
|
|
15
|
-
outerSep: DirectionDistance;
|
|
16
|
-
};
|
|
17
|
-
export type NodeAttribute = keyof NodeConfig;
|
|
18
|
-
export default class NodeModel {
|
|
19
|
-
type: string[];
|
|
20
|
-
/** 是否初始化节点数据, 很多节点在 layout 阶段才能初始化全部数据 */
|
|
21
|
-
init: boolean;
|
|
22
|
-
/** 节点是否已经被销毁,如果已近销毁,其他地方应该删除对节点对象的引用 */
|
|
23
|
-
disposed: boolean;
|
|
24
|
-
center: Position;
|
|
25
|
-
size: Size;
|
|
26
|
-
innerSep: DirectionDistance;
|
|
27
|
-
outerSep: DirectionDistance;
|
|
28
|
-
listeners: Set<StateListener>;
|
|
29
|
-
constructor(config: NodeConfig, init?: boolean);
|
|
30
|
-
update(config: Partial<NodeConfig>, init?: boolean): void;
|
|
31
|
-
notify(preSelf?: NodeModel): void;
|
|
32
|
-
subscribe(listener: StateListener): () => boolean;
|
|
33
|
-
dispose(): void;
|
|
34
|
-
/** 获取某个点相对于节点外边界的区域 */
|
|
35
|
-
getPointArea(point: Position): Area;
|
|
36
|
-
/** 获取外边界特殊点(中点,顶点,三等分点) */
|
|
37
|
-
getOuterPoint(point: RectVertexPoint | RectMidPoint | RectThirdPoint): Position | undefined;
|
|
38
|
-
/** 获取外部点与 node 中心连线与外边缘的交点 */
|
|
39
|
-
getCrossPoint(point: Position): Position;
|
|
40
|
-
/** 获取到边界的距离 */
|
|
41
|
-
getOuterDistance(direction: Direction): number;
|
|
42
|
-
/** 判断某个变量是否为初始化完成的节点 */
|
|
43
|
-
static isInitializedNode: (node: unknown) => boolean;
|
|
44
|
-
static isNode: (node: unknown) => boolean;
|
|
45
|
-
}
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import { Area } from "../../types/shape/index.js";
|
|
5
|
-
import { RectThirdPoint, RectMidPoint, RectVertexPoint } from "../../types/shape/rect.js";
|
|
6
|
-
import { isSameArray, isSameObj } from "../../utils/compare.js";
|
|
7
|
-
import { between } from "../../utils/math.js";
|
|
8
|
-
import Line from "../equation/line.js";
|
|
9
|
-
const _NodeModel = class _NodeModel {
|
|
10
|
-
constructor(config, init = true) {
|
|
11
|
-
__publicField(this, "type", ["node"]);
|
|
12
|
-
/** 是否初始化节点数据, 很多节点在 layout 阶段才能初始化全部数据 */
|
|
13
|
-
__publicField(this, "init", false);
|
|
14
|
-
/** 节点是否已经被销毁,如果已近销毁,其他地方应该删除对节点对象的引用 */
|
|
15
|
-
__publicField(this, "disposed", false);
|
|
16
|
-
__publicField(this, "center", [0, 0]);
|
|
17
|
-
__publicField(this, "size", [0, 0]);
|
|
18
|
-
__publicField(this, "innerSep", { left: 0, right: 0, top: 0, bottom: 0 });
|
|
19
|
-
__publicField(this, "outerSep", { left: 0, right: 0, top: 0, bottom: 0 });
|
|
20
|
-
__publicField(this, "listeners", /* @__PURE__ */ new Set());
|
|
21
|
-
this.update(config, init);
|
|
22
|
-
}
|
|
23
|
-
update(config, init = true) {
|
|
24
|
-
const preSelf = { ...this };
|
|
25
|
-
const { position, contentSize, innerSep, outerSep } = config;
|
|
26
|
-
let needUpdate = false;
|
|
27
|
-
if (!this.init && init) {
|
|
28
|
-
this.init = init;
|
|
29
|
-
needUpdate = true;
|
|
30
|
-
}
|
|
31
|
-
if (position && !isSameArray(position, this.center)) {
|
|
32
|
-
this.center = position;
|
|
33
|
-
needUpdate = true;
|
|
34
|
-
}
|
|
35
|
-
if (contentSize && !isSameArray(contentSize, this.size)) {
|
|
36
|
-
this.size = contentSize;
|
|
37
|
-
needUpdate = true;
|
|
38
|
-
}
|
|
39
|
-
if (innerSep && !isSameObj(innerSep, this.innerSep)) {
|
|
40
|
-
this.innerSep = innerSep;
|
|
41
|
-
needUpdate = true;
|
|
42
|
-
}
|
|
43
|
-
if (outerSep && !isSameObj(outerSep, this.outerSep)) {
|
|
44
|
-
this.outerSep = outerSep;
|
|
45
|
-
needUpdate = true;
|
|
46
|
-
}
|
|
47
|
-
if (this.init && needUpdate) {
|
|
48
|
-
this.notify(preSelf);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
notify(preSelf) {
|
|
52
|
-
this.listeners.forEach((listener) => listener({ ...this }, preSelf));
|
|
53
|
-
}
|
|
54
|
-
subscribe(listener) {
|
|
55
|
-
this.listeners.add(listener);
|
|
56
|
-
return () => this.listeners.delete(listener);
|
|
57
|
-
}
|
|
58
|
-
dispose() {
|
|
59
|
-
this.listeners.clear();
|
|
60
|
-
this.disposed = true;
|
|
61
|
-
this.notify(this);
|
|
62
|
-
}
|
|
63
|
-
/** 获取某个点相对于节点外边界的区域 */
|
|
64
|
-
getPointArea(point) {
|
|
65
|
-
const [pX, pY] = point;
|
|
66
|
-
const [x, y] = this.center;
|
|
67
|
-
const edgeX = [x - this.getOuterDistance("left"), x + this.getOuterDistance("right")];
|
|
68
|
-
const edgeY = [y - this.getOuterDistance("top"), y + this.getOuterDistance("bottom")];
|
|
69
|
-
if (between(pX, edgeX) && between(pY, edgeY)) return Area.INSIDE;
|
|
70
|
-
if (between(pX, edgeX, true) && between(pY, edgeY, true)) return Area.EDGE;
|
|
71
|
-
return Area.OUTSIDE;
|
|
72
|
-
}
|
|
73
|
-
/** 获取外边界特殊点(中点,顶点,三等分点) */
|
|
74
|
-
getOuterPoint(point) {
|
|
75
|
-
if (!this.init) return void 0;
|
|
76
|
-
const [x, y] = this.center;
|
|
77
|
-
const [width, height] = this.size;
|
|
78
|
-
const { left: innerLeft, right: innerRight, top: innerTop, bottom: innerBottom } = this.innerSep;
|
|
79
|
-
const { left: outerLeft, right: outerRight, top: outerTop, bottom: outerBottom } = this.outerSep;
|
|
80
|
-
switch (point) {
|
|
81
|
-
case RectVertexPoint.TL:
|
|
82
|
-
return [x - width / 2 - innerLeft - outerLeft, y - height / 2 - innerTop - outerTop];
|
|
83
|
-
case RectVertexPoint.TR:
|
|
84
|
-
return [x + width / 2 + innerRight + outerRight, y - height / 2 - innerTop - outerTop];
|
|
85
|
-
case RectVertexPoint.BL:
|
|
86
|
-
return [x - width / 2 - innerLeft - outerLeft, y + height / 2 + innerBottom + outerBottom];
|
|
87
|
-
case RectVertexPoint.BR:
|
|
88
|
-
return [x + width / 2 + innerRight + outerRight, y + height / 2 + innerBottom + outerBottom];
|
|
89
|
-
case RectMidPoint.T:
|
|
90
|
-
return [x, y - height / 2 - innerTop - outerTop];
|
|
91
|
-
case RectMidPoint.B:
|
|
92
|
-
return [x, y + height / 2 + innerBottom + outerBottom];
|
|
93
|
-
case RectMidPoint.L:
|
|
94
|
-
return [x - width / 2 - innerLeft - outerLeft, y];
|
|
95
|
-
case RectMidPoint.R:
|
|
96
|
-
return [x + width / 2 + innerRight + outerRight, y];
|
|
97
|
-
case RectThirdPoint.TL:
|
|
98
|
-
return [x - (width / 2 + innerLeft + outerLeft) / 3, y - (height / 2 + innerTop + outerTop) / 3];
|
|
99
|
-
case RectThirdPoint.TR:
|
|
100
|
-
return [x + (width / 2 + innerRight + outerRight) / 3, y - (height / 2 + innerTop + outerTop) / 3];
|
|
101
|
-
case RectThirdPoint.BL:
|
|
102
|
-
return [x - (width / 2 + innerLeft + outerLeft) / 3, y + (height / 2 + innerBottom + outerBottom) / 3];
|
|
103
|
-
case RectThirdPoint.BR:
|
|
104
|
-
return [x + (width / 2 + innerRight + outerRight) / 3, y + (height / 2 + innerBottom + outerBottom) / 3];
|
|
105
|
-
case RectThirdPoint.LT:
|
|
106
|
-
return [x - (width / 2 + innerLeft + outerLeft) / 3, y - (height / 2 + innerTop + outerTop) / 3];
|
|
107
|
-
case RectThirdPoint.LB:
|
|
108
|
-
return [x - (width / 2 + innerLeft + outerLeft) / 3, y + (height / 2 + innerBottom + outerBottom) / 3];
|
|
109
|
-
case RectThirdPoint.RT:
|
|
110
|
-
return [x + (width / 2 + innerRight + outerRight) / 3, y - (height / 2 + innerTop + outerTop) / 3];
|
|
111
|
-
case RectThirdPoint.RB:
|
|
112
|
-
return [x + (width / 2 + innerRight + outerRight) / 3, y + (height / 2 + innerBottom + outerBottom) / 3];
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
/** 获取外部点与 node 中心连线与外边缘的交点 */
|
|
116
|
-
getCrossPoint(point) {
|
|
117
|
-
if (!this.init) return this.center;
|
|
118
|
-
const pointArea = this.getPointArea(point);
|
|
119
|
-
if (pointArea === Area.EDGE) return point;
|
|
120
|
-
const line = Line.fromPoints(point, this.center);
|
|
121
|
-
const PointTL = this.getOuterPoint(RectVertexPoint.TL);
|
|
122
|
-
const PointTR = this.getOuterPoint(RectVertexPoint.TR);
|
|
123
|
-
const topCrossPoint = line.getIntersection(Line.fromPoints(PointTL, PointTR));
|
|
124
|
-
if (topCrossPoint && point[1] < this.center[1] && between(topCrossPoint[0], [PointTL[0], PointTR[0]], true)) {
|
|
125
|
-
return topCrossPoint;
|
|
126
|
-
}
|
|
127
|
-
const PointBL = this.getOuterPoint(RectVertexPoint.BL);
|
|
128
|
-
const PointBR = this.getOuterPoint(RectVertexPoint.BR);
|
|
129
|
-
const belowCrossPoint = line.getIntersection(Line.fromPoints(PointBL, PointBR));
|
|
130
|
-
if (belowCrossPoint && point[1] > this.center[1] && between(belowCrossPoint[0], [PointBL[0], PointBR[0]], true))
|
|
131
|
-
return belowCrossPoint;
|
|
132
|
-
const leftCrossPoint = line.getIntersection(Line.fromPoints(PointTL, PointBL));
|
|
133
|
-
if (leftCrossPoint && point[0] < this.center[0] && between(leftCrossPoint[1], [PointTL[1], PointBL[1]], true))
|
|
134
|
-
return leftCrossPoint;
|
|
135
|
-
const rightCrossPoint = line.getIntersection(Line.fromPoints(PointTR, PointBR));
|
|
136
|
-
return rightCrossPoint;
|
|
137
|
-
}
|
|
138
|
-
/** 获取到边界的距离 */
|
|
139
|
-
getOuterDistance(direction) {
|
|
140
|
-
switch (direction) {
|
|
141
|
-
case "top":
|
|
142
|
-
return this.size[1] / 2 + this.innerSep.top + this.outerSep.top;
|
|
143
|
-
case "bottom":
|
|
144
|
-
return this.size[1] / 2 + this.innerSep.bottom + this.outerSep.bottom;
|
|
145
|
-
case "left":
|
|
146
|
-
return this.size[0] / 2 + this.innerSep.left + this.outerSep.left;
|
|
147
|
-
case "right":
|
|
148
|
-
return this.size[0] / 2 + this.innerSep.right + this.outerSep.right;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
/** 判断某个变量是否为初始化完成的节点 */
|
|
153
|
-
__publicField(_NodeModel, "isInitializedNode", (node) => {
|
|
154
|
-
return _NodeModel.isNode(node) && node.init;
|
|
155
|
-
});
|
|
156
|
-
__publicField(_NodeModel, "isNode", (node) => {
|
|
157
|
-
if (typeof node !== "object" || node === null) return false;
|
|
158
|
-
if (!("type" in node) || !Array.isArray(node.type)) return false;
|
|
159
|
-
return node.type.includes("node");
|
|
160
|
-
});
|
|
161
|
-
let NodeModel = _NodeModel;
|
|
162
|
-
export {
|
|
163
|
-
NodeModel as default
|
|
164
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Position } from '../../types/coordinate/descartes';
|
|
2
|
-
export type StateListener = (state?: PathModel, prevState?: PathModel) => void;
|
|
3
|
-
export default class PathModel {
|
|
4
|
-
type: string[];
|
|
5
|
-
init: boolean;
|
|
6
|
-
disposed: boolean;
|
|
7
|
-
ways: Array<Position[]>;
|
|
8
|
-
lineWidth: number;
|
|
9
|
-
listeners: Set<StateListener>;
|
|
10
|
-
constructor(ways: Array<Position[]>, lineWidth: number, init?: boolean);
|
|
11
|
-
update(config: {
|
|
12
|
-
ways?: Array<Position[]>;
|
|
13
|
-
lineWidth?: number;
|
|
14
|
-
init?: boolean;
|
|
15
|
-
}): void;
|
|
16
|
-
notify(preSelf?: PathModel): void;
|
|
17
|
-
subscribe(listener: StateListener): () => boolean;
|
|
18
|
-
dispose(): void;
|
|
19
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
class PathModel {
|
|
5
|
-
constructor(ways, lineWidth, init = true) {
|
|
6
|
-
__publicField(this, "type", ["path"]);
|
|
7
|
-
__publicField(this, "init", false);
|
|
8
|
-
__publicField(this, "disposed", false);
|
|
9
|
-
__publicField(this, "ways", []);
|
|
10
|
-
__publicField(this, "lineWidth", 1);
|
|
11
|
-
__publicField(this, "listeners", /* @__PURE__ */ new Set());
|
|
12
|
-
this.update({ ways, lineWidth, init });
|
|
13
|
-
}
|
|
14
|
-
update(config) {
|
|
15
|
-
const { ways, lineWidth, init } = config;
|
|
16
|
-
const preSelf = { ...this };
|
|
17
|
-
let needUpdate = false;
|
|
18
|
-
if (!this.init && init) {
|
|
19
|
-
this.init = init;
|
|
20
|
-
needUpdate = true;
|
|
21
|
-
}
|
|
22
|
-
if (ways && ways !== this.ways) {
|
|
23
|
-
this.ways = ways;
|
|
24
|
-
needUpdate = true;
|
|
25
|
-
}
|
|
26
|
-
if (lineWidth && lineWidth !== this.lineWidth) {
|
|
27
|
-
this.lineWidth = lineWidth;
|
|
28
|
-
needUpdate = true;
|
|
29
|
-
}
|
|
30
|
-
if (this.init && needUpdate) this.notify(preSelf);
|
|
31
|
-
}
|
|
32
|
-
notify(preSelf) {
|
|
33
|
-
this.listeners.forEach((listener) => listener({ ...this }, preSelf));
|
|
34
|
-
}
|
|
35
|
-
subscribe(listener) {
|
|
36
|
-
this.listeners.add(listener);
|
|
37
|
-
return () => this.listeners.delete(listener);
|
|
38
|
-
}
|
|
39
|
-
dispose() {
|
|
40
|
-
this.listeners.clear();
|
|
41
|
-
this.disposed = true;
|
|
42
|
-
this.notify(this);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
export {
|
|
46
|
-
PathModel as default
|
|
47
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Position } from '../../types/coordinate/descartes';
|
|
2
|
-
export default class Line {
|
|
3
|
-
private a;
|
|
4
|
-
private b;
|
|
5
|
-
private c;
|
|
6
|
-
constructor(a: number, b: number, c: number);
|
|
7
|
-
getY(x: number): number | undefined;
|
|
8
|
-
getX(y: number): number | undefined;
|
|
9
|
-
/** 判断点是否在线上 */
|
|
10
|
-
isPointOn(point: Position, epsilon?: number): boolean;
|
|
11
|
-
/** 两点获取直线方程 */
|
|
12
|
-
static fromPoints: (point1: Position, point2: Position) => Line;
|
|
13
|
-
/** 获取两点的夹角(弧度制) */
|
|
14
|
-
static getDegree: (point1: Position, point2: Position) => number;
|
|
15
|
-
/** 根据百分比获取点位置 */
|
|
16
|
-
static getPositionByPercent: (startPoint: Position, endPoint: Position, percent: number) => Position;
|
|
17
|
-
/** 获取两条直线交点 */
|
|
18
|
-
getIntersection(line: Line, epsilon?: number): Position | undefined;
|
|
19
|
-
/** 点到直线距离 */
|
|
20
|
-
getPointDistance(point: Position): number;
|
|
21
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
const _Line = class _Line {
|
|
5
|
-
constructor(a, b, c) {
|
|
6
|
-
// 一般式系数 Ax + By + C = 0,A >= 0
|
|
7
|
-
__publicField(this, "a", 0);
|
|
8
|
-
__publicField(this, "b", 0);
|
|
9
|
-
__publicField(this, "c", 0);
|
|
10
|
-
if (a === 0 && b === 0) {
|
|
11
|
-
console.error("invalid line equation");
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
this.a = a;
|
|
15
|
-
this.b = b;
|
|
16
|
-
this.c = c;
|
|
17
|
-
}
|
|
18
|
-
getY(x) {
|
|
19
|
-
if (this.b === 0) return;
|
|
20
|
-
return -(this.a * x + this.c) / this.b;
|
|
21
|
-
}
|
|
22
|
-
getX(y) {
|
|
23
|
-
if (this.a === 0) return;
|
|
24
|
-
return -(this.b * y + this.c) / this.a;
|
|
25
|
-
}
|
|
26
|
-
/** 判断点是否在线上 */
|
|
27
|
-
isPointOn(point, epsilon = 1e-9) {
|
|
28
|
-
const value = this.a * point[0] + this.b * point[1] + this.c;
|
|
29
|
-
return Math.abs(value) <= epsilon;
|
|
30
|
-
}
|
|
31
|
-
/** 获取两条直线交点 */
|
|
32
|
-
getIntersection(line, epsilon = 1e-9) {
|
|
33
|
-
const A1 = this.a;
|
|
34
|
-
const B1 = this.b;
|
|
35
|
-
const C1 = this.c;
|
|
36
|
-
const A2 = line.a;
|
|
37
|
-
const B2 = line.b;
|
|
38
|
-
const C2 = line.c;
|
|
39
|
-
const D = A1 * B2 - A2 * B1;
|
|
40
|
-
if (Math.abs(D) <= epsilon) return;
|
|
41
|
-
const x = (C2 * B1 - C1 * B2) / D;
|
|
42
|
-
const y = (A2 * C1 - A1 * C2) / D;
|
|
43
|
-
return [x, y];
|
|
44
|
-
}
|
|
45
|
-
/** 点到直线距离 */
|
|
46
|
-
getPointDistance(point) {
|
|
47
|
-
return Math.abs(this.a * point[0] + this.b * point[1] + this.c) / Math.sqrt(this.a * this.a + this.b * this.b);
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
/** 两点获取直线方程 */
|
|
51
|
-
__publicField(_Line, "fromPoints", (point1, point2) => {
|
|
52
|
-
const [x1, y1] = point1;
|
|
53
|
-
const [x2, y2] = point2;
|
|
54
|
-
const A = y2 - y1;
|
|
55
|
-
const B = x1 - x2;
|
|
56
|
-
const C = x2 * y1 - x1 * y2;
|
|
57
|
-
return new _Line(A, B, C);
|
|
58
|
-
});
|
|
59
|
-
/** 获取两点的夹角(弧度制) */
|
|
60
|
-
__publicField(_Line, "getDegree", (point1, point2) => {
|
|
61
|
-
const [x1, y1] = point1;
|
|
62
|
-
const [x2, y2] = point2;
|
|
63
|
-
return Math.atan2(y2 - y1, x2 - x1);
|
|
64
|
-
});
|
|
65
|
-
/** 根据百分比获取点位置 */
|
|
66
|
-
__publicField(_Line, "getPositionByPercent", (startPoint, endPoint, percent) => {
|
|
67
|
-
const [x1, y1] = startPoint;
|
|
68
|
-
const [x2, y2] = endPoint;
|
|
69
|
-
const dirX = x2 - x1;
|
|
70
|
-
const dirY = y2 - y1;
|
|
71
|
-
return [x1 + dirX * percent, y1 + dirY * percent];
|
|
72
|
-
});
|
|
73
|
-
let Line = _Line;
|
|
74
|
-
export {
|
|
75
|
-
Line as default
|
|
76
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { PointPosition } from '../../../types/coordinate';
|
|
2
|
-
import { DescartesPosition, Position } from '../../../types/coordinate/descartes';
|
|
3
|
-
import { PolarPosition } from '../../../types/coordinate/polar';
|
|
4
|
-
import { default as PolarPoint } from './PolarPoint';
|
|
5
|
-
/** 笛卡尔坐标点 */
|
|
6
|
-
export default class DescartesPoint {
|
|
7
|
-
readonly position: Position;
|
|
8
|
-
constructor(point: Position | DescartesPosition);
|
|
9
|
-
/** 获取极坐标 */
|
|
10
|
-
getPolarPosition(): PolarPosition;
|
|
11
|
-
/** 获取极点 */
|
|
12
|
-
getPolarPoint(): PolarPoint;
|
|
13
|
-
/** 将笛卡尔坐标点转换为极坐标点 */
|
|
14
|
-
static convertPolarToDescartesPosition: (position: Position) => PolarPosition;
|
|
15
|
-
/** 对象形式转换为数组形式 */
|
|
16
|
-
static covertToPosition: (position: DescartesPosition) => number[];
|
|
17
|
-
/** 将坐标格式转换为笛卡尔坐标数组形式 */
|
|
18
|
-
static formatPosition: (point: PointPosition) => Position;
|
|
19
|
-
/** 多个点相加 */
|
|
20
|
-
static plus: (...positions: Array<PointPosition>) => Position;
|
|
21
|
-
}
|