@logicflow/core 2.0.0-beta.3 → 2.0.0-beta.5

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 (42) hide show
  1. package/.turbo/turbo-build$colon$dev.log +2 -2
  2. package/.turbo/turbo-build.log +6 -6
  3. package/__tests__/bugs/1545-spec.test.ts +19 -15
  4. package/__tests__/util/edge.test.ts +57 -57
  5. package/dist/index.min.js +1 -1
  6. package/es/constant/index.d.ts +2 -1
  7. package/es/constant/index.js +1 -0
  8. package/es/constant/index.js.map +1 -1
  9. package/es/event/eventArgs.d.ts +6 -0
  10. package/es/event/eventEmitter.js +0 -1
  11. package/es/event/eventEmitter.js.map +1 -1
  12. package/es/model/GraphModel.d.ts +12 -1
  13. package/es/model/GraphModel.js +21 -2
  14. package/es/model/GraphModel.js.map +1 -1
  15. package/es/model/edge/BaseEdgeModel.d.ts +2 -2
  16. package/es/model/edge/BaseEdgeModel.js.map +1 -1
  17. package/es/view/Graph.d.ts +1 -0
  18. package/es/view/Graph.js +4 -0
  19. package/es/view/Graph.js.map +1 -1
  20. package/lib/constant/index.d.ts +2 -1
  21. package/lib/constant/index.js +1 -0
  22. package/lib/constant/index.js.map +1 -1
  23. package/lib/event/eventArgs.d.ts +6 -0
  24. package/lib/event/eventEmitter.js +0 -1
  25. package/lib/event/eventEmitter.js.map +1 -1
  26. package/lib/model/GraphModel.d.ts +12 -1
  27. package/lib/model/GraphModel.js +21 -2
  28. package/lib/model/GraphModel.js.map +1 -1
  29. package/lib/model/edge/BaseEdgeModel.d.ts +2 -2
  30. package/lib/model/edge/BaseEdgeModel.js.map +1 -1
  31. package/lib/view/Graph.d.ts +1 -0
  32. package/lib/view/Graph.js +4 -0
  33. package/lib/view/Graph.js.map +1 -1
  34. package/package.json +1 -1
  35. package/src/constant/index.ts +1 -0
  36. package/src/event/eventArgs.ts +6 -0
  37. package/src/event/eventEmitter.ts +1 -2
  38. package/src/model/GraphModel.ts +22 -2
  39. package/src/model/edge/BaseEdgeModel.ts +1 -1
  40. package/src/options.ts +1 -1
  41. package/src/view/Graph.tsx +5 -1
  42. package/tsconfig.json +1 -1
@@ -1,10 +1,10 @@
1
1
 
2
- > @logicflow/core@2.0.0-beta.3 build:dev /Users/r0ger1tlearn/WorkSpace/Github/DiDi/logicflow/packages/core
2
+ > @logicflow/core@2.0.0-beta.5 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.3 build:less /Users/r0ger1tlearn/WorkSpace/Github/DiDi/logicflow/packages/core
7
+ > @logicflow/core@2.0.0-beta.5 build:less /Users/r0ger1tlearn/WorkSpace/Github/didi/LogicFlow/packages/core
8
8
  > rss
9
9
 
10
10
  > [build:less] ./scripts/build-less
@@ -1,11 +1,11 @@
1
1
 
2
- > @logicflow/core@2.0.0-beta.3 prebuild /Users/r0ger1tlearn/WorkSpace/Github/DiDi/logicflow/packages/core
2
+ > @logicflow/core@2.0.0-beta.5 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
7
 
8
- > @logicflow/core@2.0.0-beta.3 build /Users/r0ger1tlearn/WorkSpace/Github/DiDi/logicflow/packages/core
8
+ > @logicflow/core@2.0.0-beta.5 build /Users/r0ger1tlearn/WorkSpace/Github/didi/LogicFlow/packages/core
9
9
  > rss
10
10
 
11
11
  > [build] run-p -s build:dev build:umd
@@ -20,9 +20,9 @@
20
20
  | Bundle Format: umd |
21
21
  | Bundle Name: Core |
22
22
  | Destination: dist/index.min.js |
23
- | Bundle Size: 369.82 KB |
24
- | Minified Size: 367.86 KB |
25
- | GZipped Size: 107.22 KB |
23
+ | Bundle Size: 370.13 KB |
24
+ | Minified Size: 368.17 KB |
25
+ | GZipped Size: 106.93 KB |
26
26
  | |
27
27
  +------------------------------------+
28
28
  (!) Circular dependencies
@@ -33,4 +33,4 @@ src/model/index.ts -> src/model/edge/index.ts -> src/model/edge/BaseEdgeModel.ts
33
33
  (!) Broken sourcemap
34
34
  https://rollupjs.org/troubleshooting/#warning-sourcemap-is-likely-to-be-incorrect
35
35
  Plugins that transform code (such as "terser") should generate accompanying sourcemaps.
36
- created dist/index.min.js in 14.4s
36
+ created dist/index.min.js in 48s
@@ -1,17 +1,21 @@
1
- import type { NodeConfig, TextConfig } from '../../src/index';
2
- import { LogicFlow } from '../../src/index';
1
+ import LogicFlow from '../../src/index'
3
2
 
4
- type NodeConfigTextObj = NodeConfig & { text: TextConfig };
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
+ })