@antv/g6 5.0.0-beta.4 → 5.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 (168) hide show
  1. package/dist/g6.min.js +2 -2
  2. package/esm/index.d.ts +3 -1
  3. package/esm/index.js +1 -1
  4. package/esm/item/edge.d.ts +1 -0
  5. package/esm/item/edge.js +3 -1
  6. package/esm/item/edge.js.map +1 -1
  7. package/esm/item/item.d.ts +3 -2
  8. package/esm/item/item.js +12 -6
  9. package/esm/item/item.js.map +1 -1
  10. package/esm/item/node.d.ts +1 -0
  11. package/esm/item/node.js +3 -1
  12. package/esm/item/node.js.map +1 -1
  13. package/esm/runtime/controller/item.js +252 -148
  14. package/esm/runtime/controller/item.js.map +1 -1
  15. package/esm/runtime/graph.d.ts +16 -14
  16. package/esm/runtime/graph.js +66 -28
  17. package/esm/runtime/graph.js.map +1 -1
  18. package/esm/stdlib/behavior/activate-relations.js +2 -2
  19. package/esm/stdlib/behavior/activate-relations.js.map +1 -1
  20. package/esm/stdlib/behavior/click-select.js +1 -1
  21. package/esm/stdlib/behavior/click-select.js.map +1 -1
  22. package/esm/stdlib/behavior/drag-canvas.js +50 -27
  23. package/esm/stdlib/behavior/drag-canvas.js.map +1 -1
  24. package/esm/stdlib/behavior/drag-combo.js +8 -8
  25. package/esm/stdlib/behavior/drag-combo.js.map +1 -1
  26. package/esm/stdlib/behavior/drag-node.js +10 -10
  27. package/esm/stdlib/behavior/drag-node.js.map +1 -1
  28. package/esm/stdlib/behavior/zoom-canvas.js +47 -24
  29. package/esm/stdlib/behavior/zoom-canvas.js.map +1 -1
  30. package/esm/stdlib/index.d.ts +2 -0
  31. package/esm/stdlib/index.js +10 -8
  32. package/esm/stdlib/index.js.map +1 -1
  33. package/esm/stdlib/item/edge/base.d.ts +1 -1
  34. package/esm/stdlib/item/edge/base.js +13 -4
  35. package/esm/stdlib/item/edge/base.js.map +1 -1
  36. package/esm/stdlib/item/node/base.d.ts +1 -1
  37. package/esm/stdlib/item/node/base.js +11 -12
  38. package/esm/stdlib/item/node/base.js.map +1 -1
  39. package/esm/stdlib/item/node/image.d.ts +1 -1
  40. package/esm/stdlib/item/node/image.js +1 -1
  41. package/esm/stdlib/item/node/image.js.map +1 -1
  42. package/esm/stdlib/plugin/history/combo-command.js +2 -2
  43. package/esm/stdlib/plugin/history/combo-command.js.map +1 -1
  44. package/esm/stdlib/plugin/history/index.d.ts +10 -10
  45. package/esm/stdlib/plugin/history/index.js +14 -14
  46. package/esm/stdlib/plugin/history/index.js.map +1 -1
  47. package/esm/stdlib/plugin/history/item-data-command.js +4 -4
  48. package/esm/stdlib/plugin/history/item-data-command.js.map +1 -1
  49. package/esm/stdlib/plugin/history/layer-updated-command.js +2 -2
  50. package/esm/stdlib/plugin/history/layer-updated-command.js.map +1 -1
  51. package/esm/stdlib/plugin/history/state-updated-command.js +1 -1
  52. package/esm/stdlib/plugin/history/state-updated-command.js.map +1 -1
  53. package/esm/stdlib/plugin/history/visibility-updated-command.js +2 -2
  54. package/esm/stdlib/plugin/history/visibility-updated-command.js.map +1 -1
  55. package/esm/stdlib/plugin/index.d.ts +1 -0
  56. package/esm/stdlib/plugin/index.js +1 -0
  57. package/esm/stdlib/plugin/index.js.map +1 -1
  58. package/esm/stdlib/plugin/snapline/index.d.ts +163 -0
  59. package/esm/stdlib/plugin/snapline/index.js +1052 -0
  60. package/esm/stdlib/plugin/snapline/index.js.map +1 -0
  61. package/esm/stdlib/plugin/types.d.ts +1 -0
  62. package/esm/types/graph.d.ts +14 -14
  63. package/esm/types/hook.d.ts +6 -0
  64. package/esm/types/spec.d.ts +13 -0
  65. package/esm/util/bbox.d.ts +16 -1
  66. package/esm/util/bbox.js +29 -0
  67. package/esm/util/bbox.js.map +1 -1
  68. package/esm/util/shape.js +2 -2
  69. package/esm/util/shape.js.map +1 -1
  70. package/lib/index.d.ts +3 -1
  71. package/lib/index.js +1 -1
  72. package/lib/item/edge.d.ts +1 -0
  73. package/lib/item/edge.js +3 -1
  74. package/lib/item/edge.js.map +1 -1
  75. package/lib/item/item.d.ts +3 -2
  76. package/lib/item/item.js +12 -6
  77. package/lib/item/item.js.map +1 -1
  78. package/lib/item/node.d.ts +1 -0
  79. package/lib/item/node.js +3 -1
  80. package/lib/item/node.js.map +1 -1
  81. package/lib/runtime/controller/item.js +251 -147
  82. package/lib/runtime/controller/item.js.map +1 -1
  83. package/lib/runtime/graph.d.ts +16 -14
  84. package/lib/runtime/graph.js +66 -28
  85. package/lib/runtime/graph.js.map +1 -1
  86. package/lib/stdlib/behavior/activate-relations.js +2 -2
  87. package/lib/stdlib/behavior/activate-relations.js.map +1 -1
  88. package/lib/stdlib/behavior/click-select.js +1 -1
  89. package/lib/stdlib/behavior/click-select.js.map +1 -1
  90. package/lib/stdlib/behavior/drag-canvas.js +50 -27
  91. package/lib/stdlib/behavior/drag-canvas.js.map +1 -1
  92. package/lib/stdlib/behavior/drag-combo.js +8 -8
  93. package/lib/stdlib/behavior/drag-combo.js.map +1 -1
  94. package/lib/stdlib/behavior/drag-node.js +10 -10
  95. package/lib/stdlib/behavior/drag-node.js.map +1 -1
  96. package/lib/stdlib/behavior/zoom-canvas.js +47 -24
  97. package/lib/stdlib/behavior/zoom-canvas.js.map +1 -1
  98. package/lib/stdlib/index.d.ts +2 -0
  99. package/lib/stdlib/index.js +10 -8
  100. package/lib/stdlib/index.js.map +1 -1
  101. package/lib/stdlib/item/edge/base.d.ts +1 -1
  102. package/lib/stdlib/item/edge/base.js +13 -4
  103. package/lib/stdlib/item/edge/base.js.map +1 -1
  104. package/lib/stdlib/item/node/base.d.ts +1 -1
  105. package/lib/stdlib/item/node/base.js +11 -12
  106. package/lib/stdlib/item/node/base.js.map +1 -1
  107. package/lib/stdlib/item/node/image.d.ts +1 -1
  108. package/lib/stdlib/item/node/image.js +1 -1
  109. package/lib/stdlib/item/node/image.js.map +1 -1
  110. package/lib/stdlib/plugin/history/combo-command.js +2 -2
  111. package/lib/stdlib/plugin/history/combo-command.js.map +1 -1
  112. package/lib/stdlib/plugin/history/index.d.ts +10 -10
  113. package/lib/stdlib/plugin/history/index.js +14 -14
  114. package/lib/stdlib/plugin/history/index.js.map +1 -1
  115. package/lib/stdlib/plugin/history/item-data-command.js +4 -4
  116. package/lib/stdlib/plugin/history/item-data-command.js.map +1 -1
  117. package/lib/stdlib/plugin/history/layer-updated-command.js +2 -2
  118. package/lib/stdlib/plugin/history/layer-updated-command.js.map +1 -1
  119. package/lib/stdlib/plugin/history/state-updated-command.js +1 -1
  120. package/lib/stdlib/plugin/history/state-updated-command.js.map +1 -1
  121. package/lib/stdlib/plugin/history/visibility-updated-command.js +2 -2
  122. package/lib/stdlib/plugin/history/visibility-updated-command.js.map +1 -1
  123. package/lib/stdlib/plugin/index.d.ts +1 -0
  124. package/lib/stdlib/plugin/index.js +1 -0
  125. package/lib/stdlib/plugin/index.js.map +1 -1
  126. package/lib/stdlib/plugin/snapline/index.d.ts +163 -0
  127. package/lib/stdlib/plugin/snapline/index.js +1056 -0
  128. package/lib/stdlib/plugin/snapline/index.js.map +1 -0
  129. package/lib/stdlib/plugin/types.d.ts +1 -0
  130. package/lib/types/graph.d.ts +14 -14
  131. package/lib/types/hook.d.ts +6 -0
  132. package/lib/types/spec.d.ts +13 -0
  133. package/lib/util/bbox.d.ts +16 -1
  134. package/lib/util/bbox.js +32 -1
  135. package/lib/util/bbox.js.map +1 -1
  136. package/lib/util/shape.js +2 -2
  137. package/lib/util/shape.js.map +1 -1
  138. package/package.json +2 -2
  139. package/src/index.ts +1 -1
  140. package/src/item/edge.ts +4 -1
  141. package/src/item/item.ts +11 -6
  142. package/src/item/node.ts +10 -7
  143. package/src/runtime/controller/item.ts +212 -66
  144. package/src/runtime/graph.ts +91 -29
  145. package/src/stdlib/behavior/activate-relations.ts +2 -2
  146. package/src/stdlib/behavior/click-select.ts +1 -1
  147. package/src/stdlib/behavior/drag-canvas.ts +65 -27
  148. package/src/stdlib/behavior/drag-combo.ts +8 -8
  149. package/src/stdlib/behavior/drag-node.ts +10 -10
  150. package/src/stdlib/behavior/zoom-canvas.ts +60 -24
  151. package/src/stdlib/index.ts +10 -7
  152. package/src/stdlib/item/edge/base.ts +13 -5
  153. package/src/stdlib/item/node/base.ts +15 -14
  154. package/src/stdlib/item/node/image.ts +1 -1
  155. package/src/stdlib/plugin/history/combo-command.ts +2 -2
  156. package/src/stdlib/plugin/history/index.ts +14 -14
  157. package/src/stdlib/plugin/history/item-data-command.ts +4 -4
  158. package/src/stdlib/plugin/history/layer-updated-command.ts +2 -2
  159. package/src/stdlib/plugin/history/state-updated-command.ts +1 -1
  160. package/src/stdlib/plugin/history/visibility-updated-command.ts +2 -2
  161. package/src/stdlib/plugin/index.ts +1 -0
  162. package/src/stdlib/plugin/snapline/index.ts +1277 -0
  163. package/src/stdlib/plugin/types.ts +1 -0
  164. package/src/types/graph.ts +22 -17
  165. package/src/types/hook.ts +6 -0
  166. package/src/types/spec.ts +13 -0
  167. package/src/util/bbox.ts +38 -1
  168. package/src/util/shape.ts +2 -2
@@ -7,3 +7,4 @@ export type { MiniMapConfig } from './minimap';
7
7
  export type { ToolbarConfig } from './toolbar';
8
8
  export type { TooltipConfig } from './tooltip';
9
9
  export type { TimebarConfig } from './timebar';
10
+ export type { SnapLineConfig } from './snapline';
@@ -5,14 +5,14 @@ import { Command } from '../stdlib/plugin/history/command';
5
5
  import { Hooks } from '../types/hook';
6
6
  import { CameraAnimationOptions } from './animate';
7
7
  import { BehaviorOptionsOf, BehaviorRegistry } from './behavior';
8
- import { ComboDisplayModel, ComboModel, ComboUserModel } from './combo';
8
+ import { ComboModel, ComboUserModel } from './combo';
9
9
  import { Padding, Point } from './common';
10
10
  import { GraphData } from './data';
11
- import { EdgeDisplayModel, EdgeModel, EdgeUserModel } from './edge';
11
+ import { EdgeModel, EdgeUserModel } from './edge';
12
12
  import type { StackType } from './history';
13
13
  import { ITEM_TYPE, SHAPE_TYPE } from './item';
14
14
  import { LayoutOptions } from './layout';
15
- import { NodeDisplayModel, NodeModel, NodeUserModel } from './node';
15
+ import { NodeModel, NodeUserModel } from './node';
16
16
  import { RendererName } from './render';
17
17
  import { Specification } from './spec';
18
18
  import { ThemeOptionsOf, ThemeRegistry } from './theme';
@@ -470,7 +470,11 @@ export interface IGraph<
470
470
  * @returns
471
471
  * @group Item
472
472
  */
473
- hideItem: (ids: ID | ID[], disableAnimate?: boolean) => void;
473
+ hideItem: (
474
+ ids: ID | ID[],
475
+ disableAnimate?: boolean,
476
+ keepKeyShape?: boolean,
477
+ ) => void;
474
478
  /**
475
479
  * Make the item(s) to the front.
476
480
  * @param ids the item id(s) to front
@@ -682,16 +686,16 @@ export interface IGraph<
682
686
  /**
683
687
  * Pause stacking operation.
684
688
  */
685
- pauseStacking: () => void;
689
+ pauseStack: () => void;
686
690
  /**
687
691
  * Resume stacking operation.
688
692
  */
689
- resumeStacking: () => void;
693
+ resumeStack: () => void;
690
694
  /**
691
695
  * Execute a callback without allowing any stacking operations.
692
696
  * @param callback
693
697
  */
694
- executeWithoutStacking: (callback: () => void) => void;
698
+ executeWithNoStack: (callback: () => void) => void;
695
699
  /**
696
700
  * Retrieve the current redo stack which consists of operations that could be undone
697
701
  */
@@ -731,33 +735,34 @@ export interface IGraph<
731
735
  canRedo: () => void;
732
736
 
733
737
  /**
734
- * Begin a batch operation.
735
- * Any operations performed between `startBatch` and `stopBatch` are grouped together.
738
+ * Begin a historyBatch operation.
739
+ * Any operations performed between `startHistoryBatch` and `stopHistoryBatch` are grouped together.
736
740
  * treated as a single operation when undoing or redoing.
737
741
  */
738
- startBatch: () => void;
742
+ startHistoryBatch: () => void;
739
743
 
740
744
  /**
741
- * End a batch operation.
742
- * Any operations performed between `startBatch` and `stopBatch` are grouped together.
745
+ * End a historyBatch operation.
746
+ * Any operations performed between `startHistoryBatch` and `stopHistoryBatch` are grouped together.
743
747
  * treated as a single operation when undoing or redoing.
744
748
  */
745
- stopBatch: () => void;
749
+ stopHistoryBatch: () => void;
746
750
 
747
751
  /**
748
752
  * Execute a provided function within a batched context
749
753
  * All operations performed inside callback will be treated as a composite operation
750
- * more convenient way without manually invoking `startBatch` and `stopBatch`.
754
+ * more convenient way without manually invoking `startHistoryBatch` and `stopHistoryBatch`.
751
755
  * @param callback The func containing operations to be batched together.
752
756
  */
753
- batch: (callback: () => void) => void;
757
+ historyBatch: (callback: () => void) => void;
758
+
754
759
  /**
755
760
  * Execute a provided function within a batched context
756
761
  * All operations performed inside callback will be treated as a composite operation
757
- * more convenient way without manually invoking `startBatch` and `stopBatch`.
762
+ * more convenient way without manually invoking `startHistoryBatch` and `stopHistoryBatch`.
758
763
  * @param callback The func containing operations to be batched together.
759
764
  */
760
- clearStack: (stackType?: StackType) => void;
765
+ cleanHistory: (stackType?: StackType) => void;
761
766
  // ===== tree operations =====
762
767
  /**
763
768
  * Collapse sub tree(s).
package/src/types/hook.ts CHANGED
@@ -24,6 +24,7 @@ export interface IHook<T> {
24
24
  export type ViewportChangeHookParams = {
25
25
  transform: GraphTransformOptions;
26
26
  effectTiming?: Partial<CameraAnimationOptions>;
27
+ tileLodSize?: number;
27
28
  };
28
29
 
29
30
  export interface Hooks {
@@ -53,6 +54,10 @@ export interface Hooks {
53
54
  graphCore: GraphCore;
54
55
  theme: ThemeSpecification;
55
56
  transientCanvas: Canvas;
57
+ tileOptimize?: {
58
+ tileFirstRender?: boolean | number;
59
+ tileFirstRenderSize?: number;
60
+ };
56
61
  }>; // TODO: define param template
57
62
  layout: IHook<{
58
63
  graphCore: GraphCore;
@@ -82,6 +87,7 @@ export interface Hooks {
82
87
  action?: string;
83
88
  enableStack?: boolean;
84
89
  changes?: any;
90
+ keepKeyShape?: boolean;
85
91
  }>;
86
92
  itemzindexchange: IHook<{
87
93
  ids: ID[];
package/src/types/spec.ts CHANGED
@@ -47,6 +47,19 @@ export interface Specification<
47
47
  headless: boolean;
48
48
  };
49
49
  zoom?: number;
50
+ /** Global optimize configuration. */
51
+ optimize?: {
52
+ /** Whether enable tile rendering for first time. */
53
+ tileFirstRender?: boolean | number;
54
+ /** Tile size for first rendering. */
55
+ tileFirstRenderSize?: number;
56
+ /** Whether enable tile hiding / showing for behaivors, e.g. hiding shapes while drag-canvas, zoom-canvas. The enableOptimize in behavior configuration has higher priority. */
57
+ tileBehavior?: boolean | number;
58
+ /** Tile size for shape optimizing by behaviors, e.g. hiding shapes while drag-canvas, zoom-canvas. The enableOptimize in behavior configuration has higher priority. */
59
+ tileBehaviorSize?: number;
60
+ /** Tile size for level of detial changing. */
61
+ tileLodSize?: number;
62
+ };
50
63
  autoFit?:
51
64
  | 'view'
52
65
  | 'center'
package/src/util/bbox.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable prefer-spread */
2
2
  import { AABB } from '@antv/g';
3
- import { PolyPoint } from 'types/common';
3
+ import { Point, PolyPoint } from 'types/common';
4
4
 
5
5
  /**
6
6
  * Retrieve the width of a bounding box
@@ -296,3 +296,40 @@ export const isSegmentCrossingBBox = (
296
296
  }
297
297
  return false;
298
298
  };
299
+
300
+ /**
301
+ Determines whether a given point is inside a given bounding box.
302
+ @param {Point} point - The point to be checked.
303
+ @param {AABB} bbox - The bounding box.
304
+ @returns {boolean} - Returns true if the point is inside the bounding box, false otherwise.
305
+ */
306
+ export const isPointInBBox = (point: Point, bbox: AABB) => {
307
+ const { x, y } = point;
308
+ return (
309
+ x > bbox.min[0] && x < bbox.max[0] && y > bbox.min[1] && y < bbox.max[1]
310
+ );
311
+ };
312
+
313
+ /**
314
+ Determines whether a given sub-bounding box is fully contained within a given bounding box.
315
+ @param {AABB} subBBox - The sub-bounding box to be checked.
316
+ @param {AABB} bbox - The bounding box.
317
+ @param {number} [scale] - Optional scaling factor to adjust the size of the bounding box.
318
+ @returns {boolean} - Returns true if the sub-bounding box is fully contained within the bounding box, false otherwise.
319
+ */
320
+ export const isBBoxInBBox = (subBBox: AABB, bbox: AABB, scale?: number) => {
321
+ if (scale) {
322
+ return (
323
+ subBBox.min[0] > bbox.min[0] - bbox.halfExtents[0] * scale &&
324
+ subBBox.max[0] < bbox.max[0] + bbox.halfExtents[0] * scale &&
325
+ subBBox.min[1] > bbox.min[1] - bbox.halfExtents[1] * scale &&
326
+ subBBox.max[1] < bbox.max[1] + bbox.halfExtents[1] * scale
327
+ );
328
+ }
329
+ return (
330
+ subBBox.min[0] > bbox.min[0] &&
331
+ subBBox.max[0] < bbox.max[0] &&
332
+ subBBox.min[1] > bbox.min[1] &&
333
+ subBBox.max[1] < bbox.max[1]
334
+ );
335
+ };
package/src/util/shape.ts CHANGED
@@ -218,13 +218,13 @@ export const updateShapes = (
218
218
  if (prevShape !== newShape) {
219
219
  prevShape.remove();
220
220
  }
221
- if (newShape.style.display !== 'none') {
221
+ if (!newShape.destroyed && newShape.style.display !== 'none') {
222
222
  group.appendChild(newShape);
223
223
  }
224
224
  } else if (!prevShape && newShape) {
225
225
  // add newShapeMap - prevShapeMap
226
226
  finalShapeMap[id] = newShape;
227
- if (newShape.style.display !== 'none') {
227
+ if (!newShape.destroyed && newShape.style.display !== 'none') {
228
228
  group.appendChild(newShape);
229
229
  }
230
230
  } else if (prevShape && !newShape && removeDiff) {