@logicflow/core 2.0.12 → 2.0.14

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 (68) hide show
  1. package/.turbo/turbo-build$colon$dev.log +2 -2
  2. package/.turbo/turbo-build.log +7 -7
  3. package/CHANGELOG.md +12 -0
  4. package/__tests__/algorithm/index.test.ts +22 -17
  5. package/__tests__/algorithm/outline.test.ts +9 -9
  6. package/__tests__/event/event.test.ts +18 -18
  7. package/__tests__/history/history.test.ts +23 -23
  8. package/__tests__/logicflow.test.ts +236 -228
  9. package/__tests__/model/graphmodel.test.ts +51 -31
  10. package/__tests__/util/compatible.test.ts +5 -5
  11. package/__tests__/util/geometry.test.ts +10 -10
  12. package/__tests__/util/graph.test.ts +12 -12
  13. package/__tests__/util/matrix.test.ts +26 -26
  14. package/__tests__/util/node.test.ts +22 -22
  15. package/__tests__/util/sampling.test.ts +6 -10
  16. package/__tests__/util/vector.test.ts +36 -36
  17. package/__tests__/util/zIndex.test.ts +6 -6
  18. package/dist/index.min.js +1 -1
  19. package/dist/index.min.js.map +1 -1
  20. package/es/LogicFlow.d.ts +29 -4
  21. package/es/LogicFlow.js +35 -6
  22. package/es/model/GraphModel.d.ts +35 -1
  23. package/es/model/GraphModel.js +45 -5
  24. package/es/model/node/RectNodeModel.js +3 -0
  25. package/es/options.d.ts +1 -0
  26. package/es/util/theme.d.ts +67 -2
  27. package/es/util/theme.js +189 -2
  28. package/es/view/Graph.d.ts +0 -3
  29. package/es/view/Graph.js +3 -7
  30. package/es/view/edge/BaseEdge.d.ts +4 -0
  31. package/es/view/edge/BaseEdge.js +45 -3
  32. package/es/view/overlay/Grid.js +3 -2
  33. package/es/view/overlay/ToolOverlay.d.ts +1 -3
  34. package/es/view/overlay/ToolOverlay.js +2 -39
  35. package/es/view/shape/Polygon.d.ts +8 -0
  36. package/es/view/shape/Polygon.js +50 -3
  37. package/lib/LogicFlow.d.ts +29 -4
  38. package/lib/LogicFlow.js +34 -5
  39. package/lib/model/GraphModel.d.ts +35 -1
  40. package/lib/model/GraphModel.js +43 -3
  41. package/lib/model/node/RectNodeModel.js +3 -0
  42. package/lib/options.d.ts +1 -0
  43. package/lib/util/theme.d.ts +67 -2
  44. package/lib/util/theme.js +192 -2
  45. package/lib/view/Graph.d.ts +0 -3
  46. package/lib/view/Graph.js +2 -6
  47. package/lib/view/edge/BaseEdge.d.ts +4 -0
  48. package/lib/view/edge/BaseEdge.js +45 -3
  49. package/lib/view/overlay/Grid.js +3 -2
  50. package/lib/view/overlay/ToolOverlay.d.ts +1 -3
  51. package/lib/view/overlay/ToolOverlay.js +2 -39
  52. package/lib/view/shape/Polygon.d.ts +8 -0
  53. package/lib/view/shape/Polygon.js +52 -4
  54. package/package.json +1 -1
  55. package/src/LogicFlow.tsx +57 -7
  56. package/src/model/GraphModel.ts +56 -3
  57. package/src/model/edge/index.ts +4 -4
  58. package/src/model/index.ts +7 -7
  59. package/src/model/node/RectNodeModel.ts +2 -1
  60. package/src/model/node/index.ts +8 -8
  61. package/src/options.ts +1 -0
  62. package/src/util/theme.ts +198 -3
  63. package/src/view/Graph.tsx +3 -15
  64. package/src/view/edge/BaseEdge.tsx +96 -12
  65. package/src/view/overlay/Grid.tsx +2 -1
  66. package/src/view/overlay/ToolOverlay.tsx +2 -17
  67. package/src/view/shape/Polygon.tsx +56 -4
  68. package/stats.html +1 -1
@@ -1,10 +1,10 @@
1
1
 
2
- > @logicflow/core@2.0.11 build:dev /Users/didi/Desktop/github/LogicFlow/packages/core
2
+ > @logicflow/core@2.0.13 build:dev /Users/didi/Desktop/github/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.11 build:less /Users/didi/Desktop/github/LogicFlow/packages/core
7
+ > @logicflow/core@2.0.13 build:less /Users/didi/Desktop/github/LogicFlow/packages/core
8
8
  > rss
9
9
 
10
10
  > [build:less] ./scripts/build-less
@@ -1,16 +1,16 @@
1
1
 
2
- > @logicflow/core@2.0.11 prebuild /Users/didi/Desktop/github/LogicFlow/packages/core
2
+ > @logicflow/core@2.0.13 prebuild /Users/didi/Desktop/github/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.11 build /Users/didi/Desktop/github/LogicFlow/packages/core
8
+ > @logicflow/core@2.0.13 build /Users/didi/Desktop/github/LogicFlow/packages/core
9
9
  > rss
10
10
 
11
11
  > [build] run-p -s build:dev build:umd
12
- > [build:dev] pnpm run --if-present build:less && run-p -s build:cjs build:esm
13
12
  > [build:umd] pnpm run --if-present build:less && rollup -c ../../rollup.config.js --bundleConfigAsCjs
13
+ > [build:dev] pnpm run --if-present build:less && run-p -s build:cjs build:esm
14
14
  > [build:less] ./scripts/build-less
15
15
  > [build:less] ./scripts/build-less
16
16
  
@@ -20,9 +20,9 @@
20
20
  | Bundle Format: umd |
21
21
  | Bundle Name: Core |
22
22
  | Destination: dist/index.min.js |
23
- | Bundle Size: 383.19 KB |
24
- | Minified Size: 381.96 KB |
25
- | GZipped Size: 110.84 KB |
23
+ | Bundle Size: 388.57 KB |
24
+ | Minified Size: 387.34 KB |
25
+ | GZipped Size: 112.19 KB |
26
26
  | |
27
27
  +------------------------------------+
28
28
  (!) Circular dependencies
@@ -30,4 +30,4 @@ src/index.ts -> src/LogicFlow.tsx -> src/index.ts
30
30
  src/util/index.ts -> src/util/edge.ts -> src/util/index.ts
31
31
  src/util/index.ts -> src/util/edge.ts -> src/algorithm/index.ts -> src/algorithm/outline.ts -> src/util/index.ts
32
32
  ...and 19 more
33
- created dist/index.min.js in 28.5s
33
+ created dist/index.min.js in 20.9s
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Change Log
2
2
 
3
+ ## 2.0.14
4
+
5
+ ### Patch Changes
6
+
7
+ - fix: 主题功能增强 & dynamic-group增加事件回调
8
+
9
+ ## 2.0.13
10
+
11
+ ### Patch Changes
12
+
13
+ - feat: 新增清空当前选中节点的方法
14
+
3
15
  ## 2.0.12
4
16
 
5
17
  ### Patch Changes
@@ -1,4 +1,4 @@
1
- import { getVerticalPointOfLine } from '../../src/algorithm';
1
+ import { getVerticalPointOfLine } from '../../src/algorithm'
2
2
 
3
3
  describe('algorithm/index', () => {
4
4
  test('getVerticalPointOfLine', () => {
@@ -14,7 +14,8 @@ describe('algorithm/index', () => {
14
14
  offset: 3,
15
15
  verticalLength: 3,
16
16
  type: 'start',
17
- };
17
+ }
18
+
18
19
  const config2 = {
19
20
  start: {
20
21
  x: 0,
@@ -27,7 +28,9 @@ describe('algorithm/index', () => {
27
28
  offset: 3,
28
29
  verticalLength: 3,
29
30
  type: 'end',
30
- };
31
+ }
32
+
33
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
31
34
  const config3 = {
32
35
  start: {
33
36
  x: 10,
@@ -40,7 +43,9 @@ describe('algorithm/index', () => {
40
43
  offset: 3,
41
44
  verticalLength: 3,
42
45
  type: 'start',
43
- };
46
+ }
47
+
48
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
44
49
  const config4 = {
45
50
  start: {
46
51
  x: 10,
@@ -53,17 +58,17 @@ describe('algorithm/index', () => {
53
58
  offset: 3,
54
59
  verticalLength: 3,
55
60
  type: 'end',
56
- };
57
- const res1 = getVerticalPointOfLine(config1);
58
- expect(Math.abs(res1.leftX) - 5 < Number.EPSILON).toBeTruthy();
59
- expect(Math.abs(res1.leftY) - 3 < Number.EPSILON).toBeTruthy();
60
- expect(Math.abs(res1.rightX) - 5 < Number.EPSILON).toBeTruthy();
61
- expect(Math.abs(res1.rightY) - 3 < Number.EPSILON).toBeTruthy();
61
+ }
62
+ const res1 = getVerticalPointOfLine(config1)
63
+ expect(Math.abs(res1.leftX) - 5 < Number.EPSILON).toBeTruthy()
64
+ expect(Math.abs(res1.leftY) - 3 < Number.EPSILON).toBeTruthy()
65
+ expect(Math.abs(res1.rightX) - 5 < Number.EPSILON).toBeTruthy()
66
+ expect(Math.abs(res1.rightY) - 3 < Number.EPSILON).toBeTruthy()
62
67
 
63
- const res2 = getVerticalPointOfLine(config2);
64
- expect(Math.abs(res2.leftX) - 7 < Number.EPSILON).toBeTruthy();
65
- expect(Math.abs(res2.leftY) - 3 < Number.EPSILON).toBeTruthy();
66
- expect(Math.abs(res2.rightX) - 7 < Number.EPSILON).toBeTruthy();
67
- expect(Math.abs(res2.rightY) - 3 < Number.EPSILON).toBeTruthy();
68
- });
69
- });
68
+ const res2 = getVerticalPointOfLine(config2)
69
+ expect(Math.abs(res2.leftX) - 7 < Number.EPSILON).toBeTruthy()
70
+ expect(Math.abs(res2.leftY) - 3 < Number.EPSILON).toBeTruthy()
71
+ expect(Math.abs(res2.rightX) - 7 < Number.EPSILON).toBeTruthy()
72
+ expect(Math.abs(res2.rightY) - 3 < Number.EPSILON).toBeTruthy()
73
+ })
74
+ })
@@ -1,4 +1,4 @@
1
- import { getEdgeOutline } from '../../src/algorithm/outline';
1
+ import { getEdgeOutline } from '../../src/algorithm/outline'
2
2
 
3
3
  describe('algorithm/outline', () => {
4
4
  test('get edge outline', () => {
@@ -12,32 +12,32 @@ describe('algorithm/outline', () => {
12
12
  x: 10,
13
13
  y: 10,
14
14
  },
15
- };
15
+ }
16
16
  expect(getEdgeOutline(edge1)).toEqual({
17
17
  x: -5,
18
18
  y: -5,
19
19
  x1: 15,
20
20
  y1: 15,
21
- });
21
+ })
22
22
  const edge2 = {
23
23
  modelType: 'polyline-edge',
24
24
  points: '0,0 10,10',
25
- };
25
+ }
26
26
  expect(getEdgeOutline(edge2)).toEqual({
27
27
  x: -4,
28
28
  y: -4,
29
29
  x1: 14,
30
30
  y1: 14,
31
- });
31
+ })
32
32
  const edge3 = {
33
33
  modelType: 'bezier-edge',
34
34
  path: 'M 270 195C 370 195,305 290,405 290',
35
- };
35
+ }
36
36
  expect(getEdgeOutline(edge3)).toEqual({
37
37
  x: 266,
38
38
  y: 191,
39
39
  x1: 409,
40
40
  y1: 294,
41
- });
42
- });
43
- });
41
+ })
42
+ })
43
+ })
@@ -1,22 +1,22 @@
1
- import EventEmitter from '../../src/event/eventEmitter';
1
+ import EventEmitter from '../../src/event/eventEmitter'
2
2
 
3
3
  describe('event/eventEmitter', () => {
4
- const em = new EventEmitter();
4
+ const em = new EventEmitter()
5
5
  test('event emitter', () => {
6
- const fn = jest.fn();
7
- em.on('test', fn);
8
- em.emit('test', { a: 1 });
9
- expect(fn).toBeCalledWith({ a: 1 });
10
- em.off('test', fn);
11
- em.emit('test', { a: 1 });
12
- expect(fn).toBeCalledTimes(1);
6
+ const fn = jest.fn()
7
+ em.on('test', fn)
8
+ em.emit('test', { a: 1 })
9
+ expect(fn).toBeCalledWith({ a: 1 })
10
+ em.off('test', fn)
11
+ em.emit('test', { a: 1 })
12
+ expect(fn).toBeCalledTimes(1)
13
13
 
14
- em.once('test1', fn);
15
- em.emit('test1', { a: 1 });
16
- expect(fn).toBeCalledTimes(2);
17
- em.once('test1', fn);
18
- em.emit('test1', { a: 1 });
19
- const test1Events = em.getEvents().test1;
20
- expect(test1Events).toBeUndefined();
21
- });
22
- });
14
+ em.once('test1', fn)
15
+ em.emit('test1', { a: 1 })
16
+ expect(fn).toBeCalledTimes(2)
17
+ em.once('test1', fn)
18
+ em.emit('test1', { a: 1 })
19
+ const test1Events = em.getEvents().test1
20
+ expect(test1Events).toBeUndefined()
21
+ })
22
+ })
@@ -1,28 +1,28 @@
1
- import History from '../../src/history/History';
2
- import EventEmitter from '../../src/event/eventEmitter';
1
+ import History from '../../src/history/History'
2
+ import EventEmitter from '../../src/event/eventEmitter'
3
3
 
4
4
  describe('history', () => {
5
- const event = new EventEmitter();
6
- const history = new History(event);
7
- expect(history).toBeDefined();
5
+ const event = new EventEmitter()
6
+ const history = new History(event)
7
+ expect(history).toBeDefined()
8
8
  test('add', () => {
9
- history.add(1);
10
- expect(history.undos).toEqual([1]);
11
- expect(history.redos).toEqual([]);
12
- });
9
+ history.add(1)
10
+ expect(history.undos).toEqual([1])
11
+ expect(history.redos).toEqual([])
12
+ })
13
13
  test('undo', () => {
14
- history.add(1);
15
- history.add(2);
16
- history.undo();
17
- expect(history.undos).toEqual([]);
18
- expect(history.redos).toEqual([2]);
19
- });
14
+ history.add(1)
15
+ history.add(2)
16
+ history.undo()
17
+ expect(history.undos).toEqual([])
18
+ expect(history.redos).toEqual([2])
19
+ })
20
20
  test('redo', () => {
21
- history.add(1);
22
- history.add(2);
23
- history.undo();
24
- history.redo();
25
- expect(history.undos).toEqual([]);
26
- expect(history.redos).toEqual([]);
27
- });
28
- });
21
+ history.add(1)
22
+ history.add(2)
23
+ history.undo()
24
+ history.redo()
25
+ expect(history.undos).toEqual([])
26
+ expect(history.redos).toEqual([])
27
+ })
28
+ })