@logicflow/core 2.0.0-beta.4 → 2.0.0-beta.6
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/.turbo/turbo-build$colon$dev.log +2 -2
- package/.turbo/turbo-build.log +9 -15
- package/__tests__/bugs/1545-spec.test.ts +19 -15
- package/__tests__/util/edge.test.ts +57 -57
- package/dist/index.min.js +4 -4
- package/es/LogicFlow.d.ts +32 -6
- package/es/LogicFlow.js +15 -12
- package/es/LogicFlow.js.map +1 -1
- package/es/algorithm/edge.js.map +1 -1
- package/es/algorithm/index.d.ts +2 -0
- package/es/algorithm/index.js +2 -0
- package/es/algorithm/index.js.map +1 -1
- package/es/algorithm/outline.d.ts +1 -1
- package/es/common/drag.d.ts +2 -2
- package/es/common/drag.js.map +1 -1
- package/es/constant/index.d.ts +37 -1
- package/es/constant/index.js +40 -1
- package/es/constant/index.js.map +1 -1
- package/es/event/eventArgs.d.ts +88 -25
- package/es/index.d.ts +4 -0
- package/es/index.js +4 -0
- package/es/index.js.map +1 -1
- package/es/keyboard/shortcut.d.ts +4 -0
- package/es/keyboard/shortcut.js +9 -8
- package/es/keyboard/shortcut.js.map +1 -1
- package/es/model/BaseModel.d.ts +12 -16
- package/es/model/EditConfigModel.d.ts +97 -36
- package/es/model/EditConfigModel.js +166 -79
- package/es/model/EditConfigModel.js.map +1 -1
- package/es/model/GraphModel.d.ts +12 -1
- package/es/model/GraphModel.js +40 -9
- package/es/model/GraphModel.js.map +1 -1
- package/es/model/TransformModel.js +1 -1
- package/es/model/TransformModel.js.map +1 -1
- package/es/model/edge/BaseEdgeModel.d.ts +7 -1
- package/es/model/edge/BaseEdgeModel.js +33 -17
- package/es/model/edge/BaseEdgeModel.js.map +1 -1
- package/es/model/edge/BezierEdgeModel.d.ts +1 -1
- package/es/model/edge/BezierEdgeModel.js +5 -2
- package/es/model/edge/BezierEdgeModel.js.map +1 -1
- package/es/model/edge/PolylineEdgeModel.d.ts +3 -3
- package/es/model/edge/PolylineEdgeModel.js +20 -14
- package/es/model/edge/PolylineEdgeModel.js.map +1 -1
- package/es/model/node/BaseNodeModel.d.ts +7 -1
- package/es/model/node/BaseNodeModel.js +22 -11
- package/es/model/node/BaseNodeModel.js.map +1 -1
- package/es/model/node/CircleNodeModel.js.map +1 -1
- package/es/model/node/DiamondNodeModel.js.map +1 -1
- package/es/model/node/EllipseNodeModel.js.map +1 -1
- package/es/options.d.ts +4 -1
- package/es/options.js.map +1 -1
- package/es/tool/MultipleSelectTool.d.ts +1 -1
- package/es/tool/MultipleSelectTool.js +5 -5
- package/es/tool/MultipleSelectTool.js.map +1 -1
- package/es/tool/TextEditTool.d.ts +3 -3
- package/es/tool/TextEditTool.js +2 -2
- package/es/tool/TextEditTool.js.map +1 -1
- package/es/tool/index.d.ts +24 -2
- package/es/tool/index.js +82 -2
- package/es/tool/index.js.map +1 -1
- package/es/util/drag.d.ts +5 -5
- package/es/util/drag.js +3 -1
- package/es/util/drag.js.map +1 -1
- package/es/util/edge.d.ts +2 -1
- package/es/util/edge.js +9 -12
- package/es/util/edge.js.map +1 -1
- package/es/util/node.d.ts +2 -5
- package/es/util/node.js +1 -0
- package/es/util/node.js.map +1 -1
- package/es/view/Anchor.d.ts +1 -3
- package/es/view/Anchor.js +3 -0
- package/es/view/Anchor.js.map +1 -1
- package/es/view/Control.d.ts +1 -1
- package/es/view/Control.js +7 -7
- package/es/view/Control.js.map +1 -1
- package/es/view/Graph.d.ts +1 -1
- package/es/view/Rotate.js +2 -1
- package/es/view/Rotate.js.map +1 -1
- package/es/view/behavior/index.d.ts +2 -0
- package/es/view/behavior/index.js +3 -0
- package/es/view/behavior/index.js.map +1 -0
- package/es/view/behavior/snapline.d.ts +3 -0
- package/es/{tool → view/behavior}/snapline.js +0 -1
- package/es/view/behavior/snapline.js.map +1 -0
- package/es/view/edge/AdjustPoint.js +9 -20
- package/es/view/edge/AdjustPoint.js.map +1 -1
- package/es/view/edge/BaseEdge.js +25 -17
- package/es/view/edge/BaseEdge.js.map +1 -1
- package/es/view/node/BaseNode.js +14 -9
- package/es/view/node/BaseNode.js.map +1 -1
- package/es/view/node/HtmlNode.js +2 -2
- package/es/view/node/HtmlNode.js.map +1 -1
- package/es/view/overlay/CanvasOverlay.js +1 -0
- package/es/view/overlay/CanvasOverlay.js.map +1 -1
- package/es/view/overlay/ToolOverlay.d.ts +1 -1
- package/es/view/overlay/ToolOverlay.js +1 -1
- package/es/view/overlay/ToolOverlay.js.map +1 -1
- package/es/view/text/BaseText.js +7 -3
- package/es/view/text/BaseText.js.map +1 -1
- package/lib/LogicFlow.d.ts +32 -6
- package/lib/LogicFlow.js +17 -14
- package/lib/LogicFlow.js.map +1 -1
- package/lib/algorithm/edge.js.map +1 -1
- package/lib/algorithm/index.d.ts +2 -0
- package/lib/algorithm/index.js +17 -1
- package/lib/algorithm/index.js.map +1 -1
- package/lib/algorithm/outline.d.ts +1 -1
- package/lib/common/drag.d.ts +2 -2
- package/lib/common/drag.js.map +1 -1
- package/lib/constant/index.d.ts +37 -1
- package/lib/constant/index.js +41 -2
- package/lib/constant/index.js.map +1 -1
- package/lib/event/eventArgs.d.ts +88 -25
- package/lib/index.d.ts +4 -0
- package/lib/index.js +4 -0
- package/lib/index.js.map +1 -1
- package/lib/keyboard/shortcut.d.ts +4 -0
- package/lib/keyboard/shortcut.js +12 -9
- package/lib/keyboard/shortcut.js.map +1 -1
- package/lib/model/BaseModel.d.ts +12 -16
- package/lib/model/EditConfigModel.d.ts +97 -36
- package/lib/model/EditConfigModel.js +165 -78
- package/lib/model/EditConfigModel.js.map +1 -1
- package/lib/model/GraphModel.d.ts +12 -1
- package/lib/model/GraphModel.js +38 -7
- package/lib/model/GraphModel.js.map +1 -1
- package/lib/model/TransformModel.js +1 -1
- package/lib/model/TransformModel.js.map +1 -1
- package/lib/model/edge/BaseEdgeModel.d.ts +7 -1
- package/lib/model/edge/BaseEdgeModel.js +31 -15
- package/lib/model/edge/BaseEdgeModel.js.map +1 -1
- package/lib/model/edge/BezierEdgeModel.d.ts +1 -1
- package/lib/model/edge/BezierEdgeModel.js +4 -1
- package/lib/model/edge/BezierEdgeModel.js.map +1 -1
- package/lib/model/edge/PolylineEdgeModel.d.ts +3 -3
- package/lib/model/edge/PolylineEdgeModel.js +19 -13
- package/lib/model/edge/PolylineEdgeModel.js.map +1 -1
- package/lib/model/node/BaseNodeModel.d.ts +7 -1
- package/lib/model/node/BaseNodeModel.js +20 -9
- package/lib/model/node/BaseNodeModel.js.map +1 -1
- package/lib/model/node/CircleNodeModel.js.map +1 -1
- package/lib/model/node/DiamondNodeModel.js.map +1 -1
- package/lib/model/node/EllipseNodeModel.js.map +1 -1
- package/lib/options.d.ts +4 -1
- package/lib/options.js.map +1 -1
- package/lib/tool/MultipleSelectTool.d.ts +1 -1
- package/lib/tool/MultipleSelectTool.js +5 -5
- package/lib/tool/MultipleSelectTool.js.map +1 -1
- package/lib/tool/TextEditTool.d.ts +3 -3
- package/lib/tool/TextEditTool.js +4 -4
- package/lib/tool/TextEditTool.js.map +1 -1
- package/lib/tool/index.d.ts +24 -2
- package/lib/tool/index.js +85 -15
- package/lib/tool/index.js.map +1 -1
- package/lib/util/drag.d.ts +5 -5
- package/lib/util/drag.js +3 -1
- package/lib/util/drag.js.map +1 -1
- package/lib/util/edge.d.ts +2 -1
- package/lib/util/edge.js +11 -14
- package/lib/util/edge.js.map +1 -1
- package/lib/util/node.d.ts +2 -5
- package/lib/util/node.js +1 -0
- package/lib/util/node.js.map +1 -1
- package/lib/view/Anchor.d.ts +1 -3
- package/lib/view/Anchor.js +3 -0
- package/lib/view/Anchor.js.map +1 -1
- package/lib/view/Control.d.ts +1 -1
- package/lib/view/Control.js +7 -7
- package/lib/view/Control.js.map +1 -1
- package/lib/view/Graph.d.ts +1 -1
- package/lib/view/Rotate.js +2 -1
- package/lib/view/Rotate.js.map +1 -1
- package/lib/view/behavior/index.d.ts +2 -0
- package/lib/view/behavior/index.js +19 -0
- package/lib/view/behavior/index.js.map +1 -0
- package/lib/view/behavior/snapline.d.ts +3 -0
- package/lib/{tool → view/behavior}/snapline.js +0 -1
- package/lib/view/behavior/snapline.js.map +1 -0
- package/lib/view/edge/AdjustPoint.js +9 -20
- package/lib/view/edge/AdjustPoint.js.map +1 -1
- package/lib/view/edge/BaseEdge.js +24 -16
- package/lib/view/edge/BaseEdge.js.map +1 -1
- package/lib/view/node/BaseNode.js +13 -8
- package/lib/view/node/BaseNode.js.map +1 -1
- package/lib/view/node/HtmlNode.js +2 -2
- package/lib/view/node/HtmlNode.js.map +1 -1
- package/lib/view/overlay/CanvasOverlay.js +1 -0
- package/lib/view/overlay/CanvasOverlay.js.map +1 -1
- package/lib/view/overlay/ToolOverlay.d.ts +1 -1
- package/lib/view/overlay/ToolOverlay.js +1 -1
- package/lib/view/overlay/ToolOverlay.js.map +1 -1
- package/lib/view/text/BaseText.js +6 -2
- package/lib/view/text/BaseText.js.map +1 -1
- package/package.json +1 -1
- package/src/LogicFlow.tsx +52 -14
- package/src/algorithm/edge.ts +1 -0
- package/src/algorithm/index.ts +2 -0
- package/src/algorithm/outline.ts +2 -2
- package/src/common/drag.ts +16 -2
- package/src/constant/index.ts +42 -1
- package/src/event/eventArgs.ts +155 -34
- package/src/index.ts +4 -0
- package/src/keyboard/shortcut.ts +12 -8
- package/src/model/BaseModel.ts +15 -17
- package/src/model/EditConfigModel.ts +206 -94
- package/src/model/GraphModel.ts +43 -8
- package/src/model/TransformModel.ts +1 -1
- package/src/model/edge/BaseEdgeModel.ts +27 -18
- package/src/model/edge/BezierEdgeModel.ts +5 -6
- package/src/model/edge/PolylineEdgeModel.ts +22 -18
- package/src/model/node/BaseNodeModel.ts +19 -13
- package/src/model/node/CircleNodeModel.ts +0 -1
- package/src/model/node/DiamondNodeModel.ts +0 -1
- package/src/model/node/EllipseNodeModel.ts +0 -1
- package/src/options.ts +6 -1
- package/src/tool/MultipleSelectTool.tsx +6 -6
- package/src/tool/TextEditTool.tsx +3 -3
- package/src/tool/index.ts +96 -2
- package/src/util/drag.ts +22 -6
- package/src/util/edge.ts +14 -13
- package/src/util/node.ts +3 -5
- package/src/view/Anchor.tsx +3 -1
- package/src/view/Control.tsx +16 -7
- package/src/view/Graph.tsx +1 -1
- package/src/view/Rotate.tsx +2 -1
- package/src/view/behavior/index.ts +2 -0
- package/src/{tool → view/behavior}/snapline.ts +3 -4
- package/src/view/edge/AdjustPoint.tsx +32 -46
- package/src/view/edge/BaseEdge.tsx +58 -38
- package/src/view/node/BaseNode.tsx +24 -10
- package/src/view/node/HtmlNode.tsx +2 -2
- package/src/view/overlay/CanvasOverlay.tsx +1 -0
- package/src/view/overlay/ToolOverlay.tsx +1 -1
- package/src/view/text/BaseText.tsx +11 -3
- package/tsconfig.json +1 -1
- package/es/tool/snapline.d.ts +0 -3
- package/es/tool/snapline.js.map +0 -1
- package/es/tool/tool.d.ts +0 -22
- package/es/tool/tool.js +0 -43
- package/es/tool/tool.js.map +0 -1
- package/lib/tool/snapline.d.ts +0 -3
- package/lib/tool/snapline.js.map +0 -1
- package/lib/tool/tool.d.ts +0 -22
- package/lib/tool/tool.js +0 -49
- package/lib/tool/tool.js.map +0 -1
- package/src/tool/tool.ts +0 -66
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
|
|
2
|
-
> @logicflow/core@2.0.0-beta.
|
|
2
|
+
> @logicflow/core@2.0.0-beta.6 build:dev /Users/r0ger1tlearn/WorkSpace/Github/DiDi/logicflow/packages/core
|
|
3
3
|
> rss
|
|
4
4
|
|
|
5
5
|
> [build:dev] pnpm run --if-present build:less && run-p -s build:cjs build:esm
|
|
6
6
|
|
|
7
|
-
> @logicflow/core@2.0.0-beta.
|
|
7
|
+
> @logicflow/core@2.0.0-beta.6 build:less /Users/r0ger1tlearn/WorkSpace/Github/DiDi/logicflow/packages/core
|
|
8
8
|
> rss
|
|
9
9
|
|
|
10
10
|
> [build:less] ./scripts/build-less
|
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,22 +1,16 @@
|
|
|
1
1
|
|
|
2
|
-
> @logicflow/core@2.0.0-beta.
|
|
2
|
+
> @logicflow/core@2.0.0-beta.6 prebuild /Users/r0ger1tlearn/WorkSpace/Github/DiDi/logicflow/packages/core
|
|
3
3
|
> rss
|
|
4
4
|
|
|
5
5
|
> [prebuild] run-s -s clean:build
|
|
6
6
|
> [clean:build] rimraf dist es lib
|
|
7
|
-
[Error: ENOTEMPTY: directory not empty, rmdir '/Users/r0ger1tlearn/WorkSpace/Github/DiDi/logicflow/packages/core/es'] {
|
|
8
|
-
errno: -66,
|
|
9
|
-
code: 'ENOTEMPTY',
|
|
10
|
-
syscall: 'rmdir',
|
|
11
|
-
path: '/Users/r0ger1tlearn/WorkSpace/Github/DiDi/logicflow/packages/core/es'
|
|
12
|
-
}
|
|
13
7
|
|
|
14
|
-
> @logicflow/core@2.0.0-beta.
|
|
8
|
+
> @logicflow/core@2.0.0-beta.6 build /Users/r0ger1tlearn/WorkSpace/Github/DiDi/logicflow/packages/core
|
|
15
9
|
> rss
|
|
16
10
|
|
|
17
11
|
> [build] run-p -s build:dev build:umd
|
|
18
|
-
> [build:umd] pnpm run --if-present build:less && rollup -c ../../rollup.config.js --bundleConfigAsCjs
|
|
19
12
|
> [build:dev] pnpm run --if-present build:less && run-p -s build:cjs build:esm
|
|
13
|
+
> [build:umd] pnpm run --if-present build:less && rollup -c ../../rollup.config.js --bundleConfigAsCjs
|
|
20
14
|
> [build:less] ./scripts/build-less
|
|
21
15
|
> [build:less] ./scripts/build-less
|
|
22
16
|
[36m
|
|
@@ -26,17 +20,17 @@
|
|
|
26
20
|
| [32m[1mBundle Format:[22m[39m [33mumd[39m |
|
|
27
21
|
| [32m[1mBundle Name:[22m[39m [33mCore[39m |
|
|
28
22
|
| [32m[1mDestination:[22m[39m [33mdist/index.min.js[39m |
|
|
29
|
-
| [32m[1mBundle Size:[22m[39m [
|
|
30
|
-
| [32m[1mMinified Size:[22m[39m [
|
|
31
|
-
| [32m[1mGZipped Size:[22m[39m [
|
|
23
|
+
| [32m[1mBundle Size:[22m[39m [33m376.36 KB[39m |
|
|
24
|
+
| [32m[1mMinified Size:[22m[39m [33m374.39 KB[39m |
|
|
25
|
+
| [32m[1mGZipped Size:[22m[39m [33m109.1 KB[39m |
|
|
32
26
|
| |
|
|
33
27
|
+------------------------------------+
|
|
34
28
|
[1m[33m(!) Circular dependencies[39m[22m
|
|
35
29
|
src/index.ts -> src/LogicFlow.tsx -> src/index.ts
|
|
36
30
|
src/util/index.ts -> src/util/edge.ts -> src/util/index.ts
|
|
37
|
-
src/
|
|
38
|
-
...and
|
|
31
|
+
src/util/index.ts -> src/util/edge.ts -> src/algorithm/index.ts -> src/algorithm/outline.ts -> src/util/index.ts
|
|
32
|
+
...and 16 more
|
|
39
33
|
[1m[33m(!) Broken sourcemap[39m[22m
|
|
40
34
|
[90mhttps://rollupjs.org/troubleshooting/#warning-sourcemap-is-likely-to-be-incorrect[39m
|
|
41
35
|
Plugins that transform code (such as "terser") should generate accompanying sourcemaps.
|
|
42
|
-
[32mcreated [1mdist/index.min.js[22m in [
|
|
36
|
+
[32mcreated [1mdist/index.min.js[22m in [1m32.4s[22m[39m
|
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { LogicFlow } from '../../src/index';
|
|
1
|
+
import LogicFlow from '../../src/index'
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
import NodeConfig = LogicFlow.NodeConfig
|
|
4
|
+
import TextConfig = LogicFlow.TextConfig
|
|
5
|
+
|
|
6
|
+
type NodeConfigTextObj = NodeConfig & {
|
|
7
|
+
text: TextConfig
|
|
8
|
+
}
|
|
5
9
|
describe('#1545', () => {
|
|
6
|
-
const dom = document.createElement('div')
|
|
7
|
-
dom.id = 'main-graph'
|
|
8
|
-
document.body.appendChild(dom)
|
|
10
|
+
const dom = document.createElement('div')
|
|
11
|
+
dom.id = 'main-graph'
|
|
12
|
+
document.body.appendChild(dom)
|
|
9
13
|
const lf = new LogicFlow({
|
|
10
14
|
container: dom,
|
|
11
15
|
width: 1000,
|
|
12
16
|
height: 1000,
|
|
13
17
|
grid: true,
|
|
14
|
-
})
|
|
18
|
+
})
|
|
15
19
|
|
|
16
20
|
it('clone node text pos should snap to grid', () => {
|
|
17
21
|
lf.render({
|
|
@@ -28,11 +32,11 @@ describe('#1545', () => {
|
|
|
28
32
|
},
|
|
29
33
|
},
|
|
30
34
|
],
|
|
31
|
-
})
|
|
32
|
-
const originNode = lf.getDataById('node_id_1') as NodeConfigTextObj
|
|
33
|
-
const newNode = lf.cloneNode('node_id_1') as NodeConfigTextObj
|
|
34
|
-
expect(originNode.x - originNode.text.x).toEqual(newNode.x - newNode.text.x)
|
|
35
|
-
expect(originNode.y - originNode.text.y).toEqual(newNode.y - newNode.text.y)
|
|
36
|
-
expect(originNode.text.value).toEqual(newNode.text.value)
|
|
37
|
-
})
|
|
38
|
-
})
|
|
35
|
+
})
|
|
36
|
+
const originNode = lf.getDataById('node_id_1') as NodeConfigTextObj
|
|
37
|
+
const newNode = lf.cloneNode('node_id_1') as NodeConfigTextObj
|
|
38
|
+
expect(originNode.x - originNode.text.x).toEqual(newNode.x - newNode.text.x)
|
|
39
|
+
expect(originNode.y - originNode.text.y).toEqual(newNode.y - newNode.text.y)
|
|
40
|
+
expect(originNode.text.value).toEqual(newNode.text.value)
|
|
41
|
+
})
|
|
42
|
+
})
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
isSegmentsCrossNode,
|
|
12
12
|
getCrossPointInRect,
|
|
13
13
|
segmentDirection,
|
|
14
|
-
} from '../../src/util/edge'
|
|
14
|
+
} from '../../src/util/edge'
|
|
15
15
|
|
|
16
16
|
describe('util/edge', () => {
|
|
17
17
|
test('is bbox overlapping', () => {
|
|
@@ -20,64 +20,64 @@ describe('util/edge', () => {
|
|
|
20
20
|
centerY: 1,
|
|
21
21
|
width: 2,
|
|
22
22
|
height: 2,
|
|
23
|
-
}
|
|
23
|
+
}
|
|
24
24
|
const bbox2 = {
|
|
25
25
|
centerX: 2,
|
|
26
26
|
centerY: 2,
|
|
27
27
|
width: 2,
|
|
28
28
|
height: 2,
|
|
29
|
-
}
|
|
30
|
-
expect(isBboxOverLapping(bbox1, bbox2)).toBeTruthy()
|
|
29
|
+
}
|
|
30
|
+
expect(isBboxOverLapping(bbox1, bbox2)).toBeTruthy()
|
|
31
31
|
|
|
32
32
|
const bbox3 = {
|
|
33
33
|
centerX: 3,
|
|
34
34
|
centerY: 3,
|
|
35
35
|
width: 2,
|
|
36
36
|
height: 2,
|
|
37
|
-
}
|
|
38
|
-
expect(isBboxOverLapping(bbox1, bbox3)).toBeFalsy()
|
|
39
|
-
})
|
|
37
|
+
}
|
|
38
|
+
expect(isBboxOverLapping(bbox1, bbox3)).toBeFalsy()
|
|
39
|
+
})
|
|
40
40
|
test('filter repeat points', () => {
|
|
41
41
|
const sPoint1 = {
|
|
42
42
|
x: 0,
|
|
43
43
|
y: 0,
|
|
44
|
-
}
|
|
44
|
+
}
|
|
45
45
|
const tPoint1 = {
|
|
46
46
|
x: 10,
|
|
47
47
|
y: 10,
|
|
48
|
-
}
|
|
48
|
+
}
|
|
49
49
|
expect(getSimplePolyline(sPoint1, tPoint1)).toEqual([
|
|
50
50
|
{ x: 0, y: 0, id: '0-0' },
|
|
51
51
|
{ x: 0, y: 10, id: '0-10' },
|
|
52
52
|
{ x: 10, y: 10, id: '10-10' },
|
|
53
|
-
])
|
|
53
|
+
])
|
|
54
54
|
|
|
55
55
|
const sPoint2 = {
|
|
56
56
|
x: 0,
|
|
57
57
|
y: 0,
|
|
58
|
-
}
|
|
58
|
+
}
|
|
59
59
|
const tPoint2 = {
|
|
60
60
|
x: 0,
|
|
61
61
|
y: 10,
|
|
62
|
-
}
|
|
62
|
+
}
|
|
63
63
|
expect(getSimplePolyline(sPoint2, tPoint2)).toEqual([
|
|
64
64
|
{ x: 0, y: 0, id: '0-0' },
|
|
65
65
|
{ x: 0, y: 10, id: '0-10' },
|
|
66
|
-
])
|
|
67
|
-
})
|
|
66
|
+
])
|
|
67
|
+
})
|
|
68
68
|
test('merge two BBoxes', () => {
|
|
69
69
|
const bbox1 = {
|
|
70
70
|
minX: 0,
|
|
71
71
|
minY: 0,
|
|
72
72
|
maxX: 2,
|
|
73
73
|
maxY: 2,
|
|
74
|
-
}
|
|
74
|
+
}
|
|
75
75
|
const bbox2 = {
|
|
76
76
|
minX: 1,
|
|
77
77
|
minY: 1,
|
|
78
78
|
maxX: 3,
|
|
79
79
|
maxY: 3,
|
|
80
|
-
}
|
|
80
|
+
}
|
|
81
81
|
expect(mergeBBox(bbox1, bbox2)).toEqual({
|
|
82
82
|
minX: 0,
|
|
83
83
|
minY: 0,
|
|
@@ -87,86 +87,86 @@ describe('util/edge', () => {
|
|
|
87
87
|
centerY: 1.5,
|
|
88
88
|
width: 3,
|
|
89
89
|
height: 3,
|
|
90
|
-
})
|
|
91
|
-
})
|
|
90
|
+
})
|
|
91
|
+
})
|
|
92
92
|
test('get direction of two points', () => {
|
|
93
93
|
const point = {
|
|
94
94
|
x: 0,
|
|
95
95
|
y: 0,
|
|
96
|
-
}
|
|
96
|
+
}
|
|
97
97
|
const bbox1 = {
|
|
98
98
|
width: 2,
|
|
99
99
|
height: 4,
|
|
100
100
|
centerX: 1,
|
|
101
101
|
centerY: 1,
|
|
102
|
-
}
|
|
102
|
+
}
|
|
103
103
|
const bbox2 = {
|
|
104
104
|
width: 4,
|
|
105
105
|
height: 2,
|
|
106
106
|
centerX: 1,
|
|
107
107
|
centerY: 1,
|
|
108
|
-
}
|
|
109
|
-
expect(pointDirection(point, bbox1)).toEqual('horizontal')
|
|
110
|
-
expect(pointDirection(point, bbox2)).toEqual('vertical')
|
|
111
|
-
})
|
|
108
|
+
}
|
|
109
|
+
expect(pointDirection(point, bbox1)).toEqual('horizontal')
|
|
110
|
+
expect(pointDirection(point, bbox2)).toEqual('vertical')
|
|
111
|
+
})
|
|
112
112
|
test('is point inside the bbox', () => {
|
|
113
113
|
const bbox = {
|
|
114
114
|
minX: 0,
|
|
115
115
|
minY: 0,
|
|
116
116
|
maxX: 2,
|
|
117
117
|
maxY: 2,
|
|
118
|
-
}
|
|
119
|
-
expect(isPointOutsideBBox({ x: 1, y: 1 }, bbox)).toBeFalsy()
|
|
120
|
-
expect(isPointOutsideBBox({ x: 3, y: 3 }, bbox)).toBeTruthy()
|
|
121
|
-
})
|
|
118
|
+
}
|
|
119
|
+
expect(isPointOutsideBBox({ x: 1, y: 1 }, bbox)).toBeFalsy()
|
|
120
|
+
expect(isPointOutsideBBox({ x: 3, y: 3 }, bbox)).toBeTruthy()
|
|
121
|
+
})
|
|
122
122
|
test('get cross points of bbox and point', () => {
|
|
123
123
|
const bbox = {
|
|
124
124
|
minX: 0,
|
|
125
125
|
minY: 0,
|
|
126
126
|
maxX: 2,
|
|
127
127
|
maxY: 2,
|
|
128
|
-
}
|
|
128
|
+
}
|
|
129
129
|
const point1 = {
|
|
130
130
|
x: 1,
|
|
131
131
|
y: 1,
|
|
132
|
-
}
|
|
132
|
+
}
|
|
133
133
|
const point2 = {
|
|
134
134
|
x: 3,
|
|
135
135
|
y: 3,
|
|
136
|
-
}
|
|
136
|
+
}
|
|
137
137
|
expect(getBBoxCrossPointsByPoint(bbox, point1)).toEqual([
|
|
138
138
|
{ x: 1, y: 0 },
|
|
139
139
|
{ x: 1, y: 2 },
|
|
140
140
|
{ x: 0, y: 1 },
|
|
141
141
|
{ x: 2, y: 1 },
|
|
142
|
-
])
|
|
143
|
-
expect(getBBoxCrossPointsByPoint(bbox, point2)).toEqual([])
|
|
144
|
-
})
|
|
142
|
+
])
|
|
143
|
+
expect(getBBoxCrossPointsByPoint(bbox, point2)).toEqual([])
|
|
144
|
+
})
|
|
145
145
|
test('is segment cross the bbox', () => {
|
|
146
146
|
const bbox = {
|
|
147
147
|
minX: 0,
|
|
148
148
|
minY: 0,
|
|
149
149
|
maxX: 2,
|
|
150
150
|
maxY: 2,
|
|
151
|
-
}
|
|
151
|
+
}
|
|
152
152
|
expect(
|
|
153
153
|
isSegmentCrossingBBox({ x: 1, y: 1 }, { x: 3, y: 3 }, bbox),
|
|
154
|
-
).toBeTruthy()
|
|
154
|
+
).toBeTruthy()
|
|
155
155
|
expect(
|
|
156
156
|
isSegmentCrossingBBox({ x: 3, y: 3 }, { x: 4, y: 4 }, bbox),
|
|
157
|
-
).toBeFalsy()
|
|
158
|
-
})
|
|
157
|
+
).toBeFalsy()
|
|
158
|
+
})
|
|
159
159
|
test('get longest edge', () => {
|
|
160
160
|
const points = [
|
|
161
161
|
{ x: 0, y: 0 },
|
|
162
162
|
{ x: 1, y: 1 },
|
|
163
163
|
{ x: 2, y: 2 },
|
|
164
|
-
]
|
|
164
|
+
]
|
|
165
165
|
expect(getLongestEdge(points)).toEqual([
|
|
166
166
|
{ x: 0, y: 0 },
|
|
167
167
|
{ x: 1, y: 1 },
|
|
168
|
-
])
|
|
169
|
-
})
|
|
168
|
+
])
|
|
169
|
+
})
|
|
170
170
|
|
|
171
171
|
const segment1 = [
|
|
172
172
|
{
|
|
@@ -177,7 +177,7 @@ describe('util/edge', () => {
|
|
|
177
177
|
x: 0,
|
|
178
178
|
y: 10,
|
|
179
179
|
},
|
|
180
|
-
]
|
|
180
|
+
]
|
|
181
181
|
const segment2 = [
|
|
182
182
|
{
|
|
183
183
|
x: -30,
|
|
@@ -187,38 +187,38 @@ describe('util/edge', () => {
|
|
|
187
187
|
x: 30,
|
|
188
188
|
y: 0,
|
|
189
189
|
},
|
|
190
|
-
]
|
|
190
|
+
]
|
|
191
191
|
const bbox = {
|
|
192
192
|
x: 0,
|
|
193
193
|
y: 0,
|
|
194
194
|
width: 20,
|
|
195
195
|
height: 20,
|
|
196
|
-
}
|
|
196
|
+
}
|
|
197
197
|
test('is segments in node', () => {
|
|
198
|
-
expect(isSegmentsInNode(segment1[0], segment1[1], bbox)).toBeTruthy()
|
|
199
|
-
expect(isSegmentsInNode(segment2[0], segment2[1], bbox)).toBeFalsy()
|
|
200
|
-
})
|
|
198
|
+
expect(isSegmentsInNode(segment1[0], segment1[1], bbox)).toBeTruthy()
|
|
199
|
+
expect(isSegmentsInNode(segment2[0], segment2[1], bbox)).toBeFalsy()
|
|
200
|
+
})
|
|
201
201
|
test('is segments cross node', () => {
|
|
202
|
-
expect(isSegmentsCrossNode(segment1[0], segment1[1], bbox)).toBeFalsy()
|
|
203
|
-
expect(isSegmentsCrossNode(segment2[0], segment1[0], bbox)).toBeTruthy()
|
|
204
|
-
})
|
|
202
|
+
expect(isSegmentsCrossNode(segment1[0], segment1[1], bbox)).toBeFalsy()
|
|
203
|
+
expect(isSegmentsCrossNode(segment2[0], segment1[0], bbox)).toBeTruthy()
|
|
204
|
+
})
|
|
205
205
|
test('get cross point in rect', () => {
|
|
206
206
|
expect(getCrossPointInRect(segment1[0], segment1[1], bbox)).toEqual({
|
|
207
207
|
x: 0,
|
|
208
208
|
y: 10,
|
|
209
|
-
})
|
|
209
|
+
})
|
|
210
210
|
expect(getCrossPointInRect(segment2[0], segment2[1], bbox)).toEqual({
|
|
211
211
|
x: -10,
|
|
212
212
|
y: 0,
|
|
213
|
-
})
|
|
214
|
-
})
|
|
213
|
+
})
|
|
214
|
+
})
|
|
215
215
|
test('segment direction', () => {
|
|
216
|
-
expect(segmentDirection(segment1[0], segment1[1])).toEqual('vertical')
|
|
216
|
+
expect(segmentDirection(segment1[0], segment1[1])).toEqual('vertical')
|
|
217
217
|
expect(
|
|
218
218
|
segmentDirection(segment1[0], {
|
|
219
219
|
x: 10,
|
|
220
220
|
y: 0,
|
|
221
221
|
}),
|
|
222
|
-
).toEqual('horizontal')
|
|
223
|
-
})
|
|
224
|
-
})
|
|
222
|
+
).toEqual('horizontal')
|
|
223
|
+
})
|
|
224
|
+
})
|