@logicflow/core 2.2.0-alpha.7 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/package.json +6 -1
  2. package/.turbo/turbo-build$colon$dev.log +0 -10
  3. package/.turbo/turbo-build.log +0 -33
  4. package/CHANGELOG.md +0 -1901
  5. package/__tests__/algorithm/egde.test.ts +0 -131
  6. package/__tests__/algorithm/index.test.ts +0 -74
  7. package/__tests__/algorithm/outline.test.ts +0 -43
  8. package/__tests__/bugs/1545-spec.test.ts +0 -42
  9. package/__tests__/event/event.test.ts +0 -22
  10. package/__tests__/history/history.test.ts +0 -28
  11. package/__tests__/logicflow.test.ts +0 -575
  12. package/__tests__/model/graphmodel.test.ts +0 -87
  13. package/__tests__/util/compatible.test.ts +0 -48
  14. package/__tests__/util/edge.test.ts +0 -224
  15. package/__tests__/util/geometry.test.ts +0 -14
  16. package/__tests__/util/graph.test.ts +0 -16
  17. package/__tests__/util/matrix.test.ts +0 -41
  18. package/__tests__/util/node.test.ts +0 -68
  19. package/__tests__/util/sampling.test.ts +0 -12
  20. package/__tests__/util/vector.test.ts +0 -50
  21. package/__tests__/util/zIndex.test.ts +0 -10
  22. package/src/LogicFlow.tsx +0 -2017
  23. package/src/algorithm/edge.ts +0 -67
  24. package/src/algorithm/index.ts +0 -70
  25. package/src/algorithm/outline.ts +0 -77
  26. package/src/algorithm/rotate.ts +0 -55
  27. package/src/common/drag.ts +0 -219
  28. package/src/common/history.ts +0 -108
  29. package/src/common/index.ts +0 -6
  30. package/src/common/keyboard.ts +0 -108
  31. package/src/common/matrix.ts +0 -122
  32. package/src/common/vector.ts +0 -93
  33. package/src/constant/index.ts +0 -179
  34. package/src/constant/theme.ts +0 -708
  35. package/src/event/event.md +0 -66
  36. package/src/event/eventArgs.ts +0 -643
  37. package/src/event/eventEmitter.ts +0 -156
  38. package/src/history/index.ts +0 -119
  39. package/src/index.less +0 -1
  40. package/src/index.ts +0 -26
  41. package/src/keyboard/index.ts +0 -112
  42. package/src/keyboard/shortcut.ts +0 -200
  43. package/src/model/BaseModel.ts +0 -250
  44. package/src/model/EditConfigModel.ts +0 -334
  45. package/src/model/GraphModel.ts +0 -1824
  46. package/src/model/NestedTransformModel.ts +0 -121
  47. package/src/model/SnaplineModel.ts +0 -256
  48. package/src/model/TransformModel.ts +0 -258
  49. package/src/model/edge/BaseEdgeModel.ts +0 -785
  50. package/src/model/edge/BezierEdgeModel.ts +0 -197
  51. package/src/model/edge/LineEdgeModel.ts +0 -36
  52. package/src/model/edge/PolylineEdgeModel.ts +0 -817
  53. package/src/model/edge/index.ts +0 -4
  54. package/src/model/index.ts +0 -9
  55. package/src/model/node/BaseNodeModel.ts +0 -959
  56. package/src/model/node/CircleNodeModel.ts +0 -91
  57. package/src/model/node/DiamondNodeModel.ts +0 -132
  58. package/src/model/node/EllipseNodeModel.ts +0 -98
  59. package/src/model/node/HtmlNodeModel.ts +0 -64
  60. package/src/model/node/PolygonNodeModel.ts +0 -152
  61. package/src/model/node/RectNodeModel.ts +0 -69
  62. package/src/model/node/TextNodeModel.ts +0 -54
  63. package/src/model/node/index.ts +0 -8
  64. package/src/options.ts +0 -150
  65. package/src/style/index.less +0 -262
  66. package/src/style/raw.ts +0 -221
  67. package/src/tool/MultipleSelectTool.tsx +0 -140
  68. package/src/tool/TextEditTool.tsx +0 -193
  69. package/src/tool/index.ts +0 -101
  70. package/src/typings.d.ts +0 -5
  71. package/src/util/animation.ts +0 -29
  72. package/src/util/browser.ts +0 -4
  73. package/src/util/compatible.ts +0 -15
  74. package/src/util/drag.ts +0 -219
  75. package/src/util/edge.ts +0 -1094
  76. package/src/util/geometry.ts +0 -154
  77. package/src/util/graph.ts +0 -46
  78. package/src/util/index.ts +0 -17
  79. package/src/util/matrix.ts +0 -129
  80. package/src/util/mobx.ts +0 -23
  81. package/src/util/node.ts +0 -543
  82. package/src/util/raf.ts +0 -28
  83. package/src/util/resize.ts +0 -606
  84. package/src/util/sampling.ts +0 -85
  85. package/src/util/theme.ts +0 -84
  86. package/src/util/uuid.ts +0 -26
  87. package/src/util/vector.ts +0 -93
  88. package/src/util/zIndex.ts +0 -6
  89. package/src/view/Anchor.tsx +0 -462
  90. package/src/view/Control.tsx +0 -510
  91. package/src/view/Graph.tsx +0 -141
  92. package/src/view/Rotate.tsx +0 -113
  93. package/src/view/behavior/dnd.ts +0 -162
  94. package/src/view/behavior/index.ts +0 -2
  95. package/src/view/behavior/snapline.ts +0 -16
  96. package/src/view/edge/AdjustPoint.tsx +0 -425
  97. package/src/view/edge/Arrow.tsx +0 -54
  98. package/src/view/edge/BaseEdge.tsx +0 -660
  99. package/src/view/edge/BezierEdge.tsx +0 -101
  100. package/src/view/edge/LineEdge.tsx +0 -81
  101. package/src/view/edge/PolylineEdge.tsx +0 -311
  102. package/src/view/edge/index.ts +0 -6
  103. package/src/view/index.ts +0 -8
  104. package/src/view/node/BaseNode.tsx +0 -585
  105. package/src/view/node/CircleNode.tsx +0 -21
  106. package/src/view/node/DiamondNode.tsx +0 -24
  107. package/src/view/node/EllipseNode.tsx +0 -22
  108. package/src/view/node/HtmlNode.tsx +0 -112
  109. package/src/view/node/PolygonNode.tsx +0 -28
  110. package/src/view/node/RectNode.tsx +0 -30
  111. package/src/view/node/TextNode.tsx +0 -39
  112. package/src/view/node/index.ts +0 -8
  113. package/src/view/overlay/BackgroundOverlay.tsx +0 -34
  114. package/src/view/overlay/BezierAdjustOverlay.tsx +0 -150
  115. package/src/view/overlay/CanvasOverlay.tsx +0 -290
  116. package/src/view/overlay/Grid.tsx +0 -319
  117. package/src/view/overlay/ModificationOverlay.tsx +0 -31
  118. package/src/view/overlay/OutlineOverlay.tsx +0 -158
  119. package/src/view/overlay/SnaplineOverlay.tsx +0 -44
  120. package/src/view/overlay/ToolOverlay.tsx +0 -65
  121. package/src/view/overlay/getTransformHoc.tsx +0 -50
  122. package/src/view/overlay/gridConfig.ts +0 -103
  123. package/src/view/overlay/index.ts +0 -8
  124. package/src/view/shape/Circle.tsx +0 -41
  125. package/src/view/shape/Ellipse.tsx +0 -42
  126. package/src/view/shape/Line.tsx +0 -39
  127. package/src/view/shape/Path.tsx +0 -22
  128. package/src/view/shape/Polygon.tsx +0 -54
  129. package/src/view/shape/Polyline.tsx +0 -31
  130. package/src/view/shape/Rect.tsx +0 -44
  131. package/src/view/shape/Text.tsx +0 -168
  132. package/src/view/shape/index.ts +0 -8
  133. package/src/view/text/BaseText.tsx +0 -134
  134. package/src/view/text/LineText.tsx +0 -168
  135. package/src/view/text/index.ts +0 -2
  136. package/stats.html +0 -4842
  137. package/tsconfig.json +0 -18
@@ -1,224 +0,0 @@
1
- import {
2
- isBboxOverLapping,
3
- mergeBBox,
4
- isPointOutsideBBox,
5
- isSegmentCrossingBBox,
6
- getLongestEdge,
7
- getSimplePolyline,
8
- pointDirection,
9
- getBBoxCrossPointsByPoint,
10
- isSegmentsInNode,
11
- isSegmentsCrossNode,
12
- getCrossPointInRect,
13
- segmentDirection,
14
- } from '../../src/util/edge'
15
-
16
- describe('util/edge', () => {
17
- test('is bbox overlapping', () => {
18
- const bbox1 = {
19
- centerX: 1,
20
- centerY: 1,
21
- width: 2,
22
- height: 2,
23
- }
24
- const bbox2 = {
25
- centerX: 2,
26
- centerY: 2,
27
- width: 2,
28
- height: 2,
29
- }
30
- expect(isBboxOverLapping(bbox1, bbox2)).toBeTruthy()
31
-
32
- const bbox3 = {
33
- centerX: 3,
34
- centerY: 3,
35
- width: 2,
36
- height: 2,
37
- }
38
- expect(isBboxOverLapping(bbox1, bbox3)).toBeFalsy()
39
- })
40
- test('filter repeat points', () => {
41
- const sPoint1 = {
42
- x: 0,
43
- y: 0,
44
- }
45
- const tPoint1 = {
46
- x: 10,
47
- y: 10,
48
- }
49
- expect(getSimplePolyline(sPoint1, tPoint1)).toEqual([
50
- { x: 0, y: 0, id: '0-0' },
51
- { x: 0, y: 10, id: '0-10' },
52
- { x: 10, y: 10, id: '10-10' },
53
- ])
54
-
55
- const sPoint2 = {
56
- x: 0,
57
- y: 0,
58
- }
59
- const tPoint2 = {
60
- x: 0,
61
- y: 10,
62
- }
63
- expect(getSimplePolyline(sPoint2, tPoint2)).toEqual([
64
- { x: 0, y: 0, id: '0-0' },
65
- { x: 0, y: 10, id: '0-10' },
66
- ])
67
- })
68
- test('merge two BBoxes', () => {
69
- const bbox1 = {
70
- minX: 0,
71
- minY: 0,
72
- maxX: 2,
73
- maxY: 2,
74
- }
75
- const bbox2 = {
76
- minX: 1,
77
- minY: 1,
78
- maxX: 3,
79
- maxY: 3,
80
- }
81
- expect(mergeBBox(bbox1, bbox2)).toEqual({
82
- minX: 0,
83
- minY: 0,
84
- maxX: 3,
85
- maxY: 3,
86
- centerX: 1.5,
87
- centerY: 1.5,
88
- width: 3,
89
- height: 3,
90
- })
91
- })
92
- test('get direction of two points', () => {
93
- const point = {
94
- x: 0,
95
- y: 0,
96
- }
97
- const bbox1 = {
98
- width: 2,
99
- height: 4,
100
- centerX: 1,
101
- centerY: 1,
102
- }
103
- const bbox2 = {
104
- width: 4,
105
- height: 2,
106
- centerX: 1,
107
- centerY: 1,
108
- }
109
- expect(pointDirection(point, bbox1)).toEqual('horizontal')
110
- expect(pointDirection(point, bbox2)).toEqual('vertical')
111
- })
112
- test('is point inside the bbox', () => {
113
- const bbox = {
114
- minX: 0,
115
- minY: 0,
116
- maxX: 2,
117
- maxY: 2,
118
- }
119
- expect(isPointOutsideBBox({ x: 1, y: 1 }, bbox)).toBeFalsy()
120
- expect(isPointOutsideBBox({ x: 3, y: 3 }, bbox)).toBeTruthy()
121
- })
122
- test('get cross points of bbox and point', () => {
123
- const bbox = {
124
- minX: 0,
125
- minY: 0,
126
- maxX: 2,
127
- maxY: 2,
128
- }
129
- const point1 = {
130
- x: 1,
131
- y: 1,
132
- }
133
- const point2 = {
134
- x: 3,
135
- y: 3,
136
- }
137
- expect(getBBoxCrossPointsByPoint(bbox, point1)).toEqual([
138
- { x: 1, y: 0 },
139
- { x: 1, y: 2 },
140
- { x: 0, y: 1 },
141
- { x: 2, y: 1 },
142
- ])
143
- expect(getBBoxCrossPointsByPoint(bbox, point2)).toEqual([])
144
- })
145
- test('is segment cross the bbox', () => {
146
- const bbox = {
147
- minX: 0,
148
- minY: 0,
149
- maxX: 2,
150
- maxY: 2,
151
- }
152
- expect(
153
- isSegmentCrossingBBox({ x: 1, y: 1 }, { x: 3, y: 3 }, bbox),
154
- ).toBeTruthy()
155
- expect(
156
- isSegmentCrossingBBox({ x: 3, y: 3 }, { x: 4, y: 4 }, bbox),
157
- ).toBeFalsy()
158
- })
159
- test('get longest edge', () => {
160
- const points = [
161
- { x: 0, y: 0 },
162
- { x: 1, y: 1 },
163
- { x: 2, y: 2 },
164
- ]
165
- expect(getLongestEdge(points)).toEqual([
166
- { x: 0, y: 0 },
167
- { x: 1, y: 1 },
168
- ])
169
- })
170
-
171
- const segment1 = [
172
- {
173
- x: 0,
174
- y: 0,
175
- },
176
- {
177
- x: 0,
178
- y: 10,
179
- },
180
- ]
181
- const segment2 = [
182
- {
183
- x: -30,
184
- y: 0,
185
- },
186
- {
187
- x: 30,
188
- y: 0,
189
- },
190
- ]
191
- const bbox = {
192
- x: 0,
193
- y: 0,
194
- width: 20,
195
- height: 20,
196
- }
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
- })
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
- })
205
- test('get cross point in rect', () => {
206
- expect(getCrossPointInRect(segment1[0], segment1[1], bbox)).toEqual({
207
- x: 0,
208
- y: 10,
209
- })
210
- expect(getCrossPointInRect(segment2[0], segment2[1], bbox)).toEqual({
211
- x: -10,
212
- y: 0,
213
- })
214
- })
215
- test('segment direction', () => {
216
- expect(segmentDirection(segment1[0], segment1[1])).toEqual('vertical')
217
- expect(
218
- segmentDirection(segment1[0], {
219
- x: 10,
220
- y: 0,
221
- }),
222
- ).toEqual('horizontal')
223
- })
224
- })
@@ -1,14 +0,0 @@
1
- import { snapToGrid, getGridOffset } from '../../src/util'
2
-
3
- describe('util/geometry', () => {
4
- test('snapToGrid', () => {
5
- const point = 2.5
6
- const grid = 1.5
7
- expect(snapToGrid(point, grid) - 3 < Number.EPSILON).toBeTruthy()
8
- })
9
- test('getGridOffset', () => {
10
- const distance = 3
11
- const grid = 1.5
12
- expect(getGridOffset(distance, grid) - 2 < Number.EPSILON).toBeTruthy()
13
- })
14
- })
@@ -1,16 +0,0 @@
1
- import { isPointInArea } from '../../src/util/graph'
2
-
3
- describe('util/graph', () => {
4
- test('if element is in an area, truthy', () => {
5
- const point: [number, number] = [1, 1]
6
- const leftTopPoint: [number, number] = [0, 0]
7
- const rightBottomPoint: [number, number] = [2, 2]
8
- expect(isPointInArea(point, leftTopPoint, rightBottomPoint)).toBeTruthy()
9
- })
10
- test('if element is in an area, falsy', () => {
11
- const point: [number, number] = [1, 1]
12
- const leftTopPoint: [number, number] = [2, 2]
13
- const rightBottomPoint: [number, number] = [4, 4]
14
- expect(isPointInArea(point, leftTopPoint, rightBottomPoint)).toBeFalsy()
15
- })
16
- })
@@ -1,41 +0,0 @@
1
- import { Matrix } from '../../src/util/matrix'
2
-
3
- describe('util/matrix', () => {
4
- test('construct', () => {
5
- const m = new Matrix([1, 2, 3], [4, 5, 6], [7, 8, 9])
6
- expect(m[0]).toEqual([1, 2, 3])
7
- expect(m[1]).toEqual([4, 5, 6])
8
- expect(m[2]).toEqual([7, 8, 9])
9
- })
10
- test('cross', () => {
11
- const m = new Matrix([1, 2, 3], [4, 5, 6], [7, 8, 9])
12
- const n = new Matrix([9, 8, 7], [6, 5, 4], [3, 2, 1])
13
- expect(m.cross(n)).toEqual(
14
- new Matrix([30, 24, 18], [84, 69, 54], [138, 114, 90]),
15
- )
16
- })
17
- test('transpose', () => {
18
- const m = new Matrix([1, 2, 3], [4, 5, 6], [7, 8, 9])
19
- expect(m.transpose()).toEqual(new Matrix([1, 4, 7], [2, 5, 8], [3, 6, 9]))
20
- })
21
- test('translate', () => {
22
- const m = new Matrix([1, 0, 0], [0, 1, 0], [0, 0, 1])
23
- expect(m.translate(2, 3)).toEqual(
24
- new Matrix([1, 0, 0], [0, 1, 0], [2, 3, 1]),
25
- )
26
- })
27
- test('rotate', () => {
28
- const m = new Matrix([1, 0, 0], [0, 1, 0], [0, 0, 1])
29
- expect(m.rotate(Math.PI / 2)).toEqual(
30
- new Matrix([0, 1, 0], [-1, 0, 0], [0, 0, 1]),
31
- )
32
- })
33
- test('scale', () => {
34
- const m = new Matrix([1, 0, 0], [0, 1, 0], [0, 0, 1])
35
- expect(m.scale(2, 3)).toEqual(new Matrix([2, 0, 0], [0, 3, 0], [0, 0, 1]))
36
- })
37
- test('toString', () => {
38
- const m = new Matrix([1, 0, 0], [0, 1, 0], [1, 1, 1])
39
- expect(m.toString()).toEqual('matrix(1 0 0 1 1 1)')
40
- })
41
- })
@@ -1,68 +0,0 @@
1
- import {
2
- getClosestAnchor,
3
- isInNode,
4
- getCrossPointWithCircle,
5
- getCrossPointWithEllipse,
6
- } from '../../src/util/node'
7
-
8
- describe('util/node', () => {
9
- test('get closest anchor', () => {
10
- const position = { x: 0, y: 0 }
11
- const node = {
12
- anchors: [
13
- { x: 0, y: 0, id: '1' },
14
- { x: 1, y: 1, id: '2' },
15
- { x: 2, y: 2, id: '3' },
16
- ],
17
- }
18
- expect(getClosestAnchor(position, node)).toEqual({
19
- anchor: { x: 0, y: 0, id: '1' },
20
- index: 0,
21
- })
22
- })
23
- test('is point inside the node', () => {
24
- const position1 = { x: 0, y: 0 }
25
- const position2 = { x: 110, y: 110 }
26
- const node = {
27
- x: 0,
28
- y: 0,
29
- width: 100,
30
- height: 100,
31
- }
32
- expect(isInNode(position1, node)).toBeTruthy()
33
- expect(isInNode(position2, node)).toBeFalsy()
34
- })
35
- test('get cross point with circle', () => {
36
- const position = { x: 0, y: 0 }
37
- const node = {
38
- x: 0,
39
- y: 0,
40
- r: 10,
41
- }
42
- expect(getCrossPointWithCircle(position, 'horizontal', node)).toEqual({
43
- x: 10,
44
- y: 0,
45
- })
46
- expect(getCrossPointWithCircle(position, 'vertical', node)).toEqual({
47
- x: 0,
48
- y: 10,
49
- })
50
- })
51
- test('get cross point with ellipse', () => {
52
- const position = { x: 0, y: 0 }
53
- const node = {
54
- x: 0,
55
- y: 0,
56
- rx: 10,
57
- ry: 5,
58
- }
59
- expect(getCrossPointWithEllipse(position, 'horizontal', node)).toEqual({
60
- x: 10,
61
- y: 0,
62
- })
63
- expect(getCrossPointWithEllipse(position, 'vertical', node)).toEqual({
64
- x: 0,
65
- y: 5,
66
- })
67
- })
68
- })
@@ -1,12 +0,0 @@
1
- import { degrees, getThetaOfVector, Vector } from '../../src/util'
2
-
3
- describe('util/sampling', () => {
4
- test('degrees', () => {
5
- expect(degrees(1)).toBe(57.29577951308232)
6
- })
7
- test('getThetaOfVector', () => {
8
- expect(
9
- getThetaOfVector(new Vector(1, 1)) - 45 < Number.EPSILON,
10
- ).toBeTruthy()
11
- })
12
- })
@@ -1,50 +0,0 @@
1
- import { Vector } from '../../src/util/vector'
2
-
3
- describe('util/vector', () => {
4
- test('construct', () => {
5
- const v = new Vector(1, 2)
6
- expect(v.x).toEqual(1)
7
- expect(v[0]).toEqual(1)
8
-
9
- expect(v.y).toEqual(2)
10
- expect(v[1]).toEqual(2)
11
-
12
- expect(v.z).toEqual(0)
13
- expect(v[2]).toEqual(0)
14
- })
15
- test('add', () => {
16
- const v = new Vector(1, 2)
17
- const v1 = new Vector(3, 4)
18
- expect(v.add(v1)).toEqual(new Vector(4, 6))
19
- })
20
- test('subtract', () => {
21
- const v = new Vector(1, 2)
22
- const v1 = new Vector(3, 4)
23
- expect(v.subtract(v1)).toEqual(new Vector(-2, -2))
24
- })
25
- test('dot', () => {
26
- const v = new Vector(1, 2)
27
- const v1 = new Vector(3, 4)
28
- expect(v.dot(v1)).toEqual(11)
29
- })
30
- test('cross', () => {
31
- const v = new Vector(1, 2)
32
- const v1 = new Vector(3, 4)
33
- expect(v.cross(v1)).toEqual(new Vector(0, 0, -2))
34
- })
35
- test('getLength', () => {
36
- const v = new Vector(1, 2)
37
- expect(v.getLength()).toEqual(Math.sqrt(5))
38
- })
39
- test('normalize', () => {
40
- const v = new Vector(1, 2)
41
- expect(v.normalize()).toEqual(
42
- new Vector(1 / Math.sqrt(5), 2 / Math.sqrt(5)),
43
- )
44
- })
45
- test('angle', () => {
46
- const v = new Vector(1, 1)
47
- const v1 = new Vector(0, 1)
48
- expect(v.angle(v1) - Math.PI / 4 < Number.EPSILON).toBeTruthy()
49
- })
50
- })
@@ -1,10 +0,0 @@
1
- import { getZIndex, getMinIndex } from '../../src/util/zIndex'
2
-
3
- describe('util/zIndex', () => {
4
- test('getZIndex', () => {
5
- expect(getZIndex()).toBe(1001)
6
- })
7
- test('getMinIndex', () => {
8
- expect(getMinIndex()).toBe(998)
9
- })
10
- })