@antv/g6 5.0.0-beta.25 → 5.0.0-beta.27

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 (329) hide show
  1. package/dist/g6.min.js +2 -2
  2. package/esm/constant/shape.d.ts +1 -1
  3. package/esm/index.d.ts +3 -1
  4. package/esm/index.js +1 -1
  5. package/esm/item/combo.d.ts +6 -4
  6. package/esm/item/combo.js +10 -3
  7. package/esm/item/combo.js.map +1 -1
  8. package/esm/item/edge.d.ts +12 -4
  9. package/esm/item/edge.js +100 -17
  10. package/esm/item/edge.js.map +1 -1
  11. package/esm/item/item.d.ts +18 -8
  12. package/esm/item/item.js +121 -62
  13. package/esm/item/item.js.map +1 -1
  14. package/esm/item/node.d.ts +10 -4
  15. package/esm/item/node.js +92 -8
  16. package/esm/item/node.js.map +1 -1
  17. package/esm/runtime/controller/data.d.ts +5 -1
  18. package/esm/runtime/controller/data.js +38 -1
  19. package/esm/runtime/controller/data.js.map +1 -1
  20. package/esm/runtime/controller/index.d.ts +1 -1
  21. package/esm/runtime/controller/index.js +1 -1
  22. package/esm/runtime/controller/index.js.map +1 -1
  23. package/esm/runtime/controller/item.d.ts +22 -11
  24. package/esm/runtime/controller/item.js +241 -96
  25. package/esm/runtime/controller/item.js.map +1 -1
  26. package/esm/runtime/controller/layout.d.ts +3 -0
  27. package/esm/runtime/controller/layout.js +178 -98
  28. package/esm/runtime/controller/layout.js.map +1 -1
  29. package/esm/runtime/controller/plugin.d.ts +3 -0
  30. package/esm/runtime/controller/plugin.js +66 -24
  31. package/esm/runtime/controller/plugin.js.map +1 -1
  32. package/esm/runtime/controller/viewport.js +9 -2
  33. package/esm/runtime/controller/viewport.js.map +1 -1
  34. package/esm/runtime/graph.d.ts +57 -26
  35. package/esm/runtime/graph.js +263 -139
  36. package/esm/runtime/graph.js.map +1 -1
  37. package/esm/stdlib/behavior/click-select.js +9 -3
  38. package/esm/stdlib/behavior/click-select.js.map +1 -1
  39. package/esm/stdlib/behavior/drag-canvas.js +6 -3
  40. package/esm/stdlib/behavior/drag-canvas.js.map +1 -1
  41. package/esm/stdlib/behavior/drag-combo.js +8 -8
  42. package/esm/stdlib/behavior/drag-combo.js.map +1 -1
  43. package/esm/stdlib/behavior/drag-node.d.ts +4 -0
  44. package/esm/stdlib/behavior/drag-node.js +121 -27
  45. package/esm/stdlib/behavior/drag-node.js.map +1 -1
  46. package/esm/stdlib/behavior/scroll-canvas.js +3 -3
  47. package/esm/stdlib/behavior/scroll-canvas.js.map +1 -1
  48. package/esm/stdlib/behavior/zoom-canvas.js +3 -3
  49. package/esm/stdlib/behavior/zoom-canvas.js.map +1 -1
  50. package/esm/stdlib/data/mapNodeSize.js +2 -2
  51. package/esm/stdlib/data/mapNodeSize.js.map +1 -1
  52. package/esm/stdlib/data/validateData.js +2 -2
  53. package/esm/stdlib/data/validateData.js.map +1 -1
  54. package/esm/stdlib/index.d.ts +2 -0
  55. package/esm/stdlib/index.js +3 -1
  56. package/esm/stdlib/index.js.map +1 -1
  57. package/esm/stdlib/item/edge/base.d.ts +2 -11
  58. package/esm/stdlib/item/edge/base.js +12 -105
  59. package/esm/stdlib/item/edge/base.js.map +1 -1
  60. package/esm/stdlib/item/node/base.d.ts +2 -20
  61. package/esm/stdlib/item/node/base.js +10 -150
  62. package/esm/stdlib/item/node/base.js.map +1 -1
  63. package/esm/stdlib/plugin/edgeFilterLens/index.js +2 -2
  64. package/esm/stdlib/plugin/edgeFilterLens/index.js.map +1 -1
  65. package/esm/stdlib/plugin/fisheye/index.js +3 -2
  66. package/esm/stdlib/plugin/fisheye/index.js.map +1 -1
  67. package/esm/stdlib/plugin/history/visibility-updated-command.js +2 -2
  68. package/esm/stdlib/plugin/history/visibility-updated-command.js.map +1 -1
  69. package/esm/stdlib/plugin/hull/index.d.ts +1 -1
  70. package/esm/stdlib/plugin/index.d.ts +1 -0
  71. package/esm/stdlib/plugin/index.js +1 -0
  72. package/esm/stdlib/plugin/index.js.map +1 -1
  73. package/esm/stdlib/plugin/lodController/index.d.ts +73 -0
  74. package/esm/stdlib/plugin/lodController/index.js +556 -0
  75. package/esm/stdlib/plugin/lodController/index.js.map +1 -0
  76. package/esm/stdlib/plugin/menu/index.js +2 -1
  77. package/esm/stdlib/plugin/menu/index.js.map +1 -1
  78. package/esm/stdlib/plugin/minimap/index.js +12 -14
  79. package/esm/stdlib/plugin/minimap/index.js.map +1 -1
  80. package/esm/stdlib/plugin/toolbar/index.d.ts +2 -2
  81. package/esm/stdlib/plugin/toolbar/index.js +27 -29
  82. package/esm/stdlib/plugin/toolbar/index.js.map +1 -1
  83. package/esm/stdlib/theme/dark.js +32 -35
  84. package/esm/stdlib/theme/dark.js.map +1 -1
  85. package/esm/stdlib/theme/light.js +27 -30
  86. package/esm/stdlib/theme/light.js.map +1 -1
  87. package/esm/stdlib/themeSolver/spec.js +2 -2
  88. package/esm/stdlib/themeSolver/spec.js.map +1 -1
  89. package/esm/types/animate.d.ts +1 -1
  90. package/esm/types/combo.d.ts +2 -2
  91. package/esm/types/edge.d.ts +2 -2
  92. package/esm/types/graph.d.ts +62 -43
  93. package/esm/types/hook.d.ts +5 -0
  94. package/esm/types/item.d.ts +9 -15
  95. package/esm/types/layout.d.ts +7 -2
  96. package/esm/types/layout.js.map +1 -1
  97. package/esm/types/node.d.ts +3 -2
  98. package/esm/types/plugin.d.ts +1 -0
  99. package/esm/types/plugin.js +1 -0
  100. package/esm/types/plugin.js.map +1 -1
  101. package/esm/types/spec.d.ts +1 -0
  102. package/esm/types/theme.d.ts +7 -7
  103. package/esm/util/animate.d.ts +7 -2
  104. package/esm/util/animate.js +40 -23
  105. package/esm/util/animate.js.map +1 -1
  106. package/esm/util/bbox.d.ts +7 -1
  107. package/esm/util/bbox.js +16 -0
  108. package/esm/util/bbox.js.map +1 -1
  109. package/esm/util/data.d.ts +7 -1
  110. package/esm/util/data.js +17 -5
  111. package/esm/util/data.js.map +1 -1
  112. package/esm/util/dom.js +5 -5
  113. package/esm/util/dom.js.map +1 -1
  114. package/esm/util/item.d.ts +1 -1
  115. package/esm/util/item.js +8 -8
  116. package/esm/util/item.js.map +1 -1
  117. package/esm/util/mapper.js +1 -1
  118. package/esm/util/mapper.js.map +1 -1
  119. package/esm/util/path.d.ts +6 -1
  120. package/esm/util/path.js +72 -1
  121. package/esm/util/path.js.map +1 -1
  122. package/esm/util/polyline.d.ts +10 -0
  123. package/esm/util/polyline.js +22 -17
  124. package/esm/util/polyline.js.map +1 -1
  125. package/esm/util/router.d.ts +1 -1
  126. package/esm/util/router.js +19 -18
  127. package/esm/util/router.js.map +1 -1
  128. package/esm/util/shape.d.ts +1 -1
  129. package/esm/util/shape.js +28 -13
  130. package/esm/util/shape.js.map +1 -1
  131. package/esm/util/zoom.d.ts +5 -8
  132. package/esm/util/zoom.js +15 -20
  133. package/esm/util/zoom.js.map +1 -1
  134. package/lib/constant/shape.d.ts +1 -1
  135. package/lib/index.d.ts +3 -1
  136. package/lib/index.js +1 -1
  137. package/lib/item/combo.d.ts +6 -4
  138. package/lib/item/combo.js +10 -3
  139. package/lib/item/combo.js.map +1 -1
  140. package/lib/item/edge.d.ts +12 -4
  141. package/lib/item/edge.js +99 -16
  142. package/lib/item/edge.js.map +1 -1
  143. package/lib/item/item.d.ts +18 -8
  144. package/lib/item/item.js +119 -60
  145. package/lib/item/item.js.map +1 -1
  146. package/lib/item/node.d.ts +10 -4
  147. package/lib/item/node.js +92 -8
  148. package/lib/item/node.js.map +1 -1
  149. package/lib/runtime/controller/data.d.ts +5 -1
  150. package/lib/runtime/controller/data.js +38 -1
  151. package/lib/runtime/controller/data.js.map +1 -1
  152. package/lib/runtime/controller/index.d.ts +1 -1
  153. package/lib/runtime/controller/index.js +1 -1
  154. package/lib/runtime/controller/index.js.map +1 -1
  155. package/lib/runtime/controller/item.d.ts +22 -11
  156. package/lib/runtime/controller/item.js +238 -93
  157. package/lib/runtime/controller/item.js.map +1 -1
  158. package/lib/runtime/controller/layout.d.ts +3 -0
  159. package/lib/runtime/controller/layout.js +178 -98
  160. package/lib/runtime/controller/layout.js.map +1 -1
  161. package/lib/runtime/controller/plugin.d.ts +3 -0
  162. package/lib/runtime/controller/plugin.js +66 -24
  163. package/lib/runtime/controller/plugin.js.map +1 -1
  164. package/lib/runtime/controller/viewport.js +9 -2
  165. package/lib/runtime/controller/viewport.js.map +1 -1
  166. package/lib/runtime/graph.d.ts +57 -26
  167. package/lib/runtime/graph.js +263 -139
  168. package/lib/runtime/graph.js.map +1 -1
  169. package/lib/stdlib/behavior/click-select.js +9 -3
  170. package/lib/stdlib/behavior/click-select.js.map +1 -1
  171. package/lib/stdlib/behavior/drag-canvas.js +6 -3
  172. package/lib/stdlib/behavior/drag-canvas.js.map +1 -1
  173. package/lib/stdlib/behavior/drag-combo.js +8 -8
  174. package/lib/stdlib/behavior/drag-combo.js.map +1 -1
  175. package/lib/stdlib/behavior/drag-node.d.ts +4 -0
  176. package/lib/stdlib/behavior/drag-node.js +121 -27
  177. package/lib/stdlib/behavior/drag-node.js.map +1 -1
  178. package/lib/stdlib/behavior/scroll-canvas.js +3 -3
  179. package/lib/stdlib/behavior/scroll-canvas.js.map +1 -1
  180. package/lib/stdlib/behavior/zoom-canvas.js +3 -3
  181. package/lib/stdlib/behavior/zoom-canvas.js.map +1 -1
  182. package/lib/stdlib/data/mapNodeSize.js +2 -2
  183. package/lib/stdlib/data/mapNodeSize.js.map +1 -1
  184. package/lib/stdlib/data/validateData.js +2 -2
  185. package/lib/stdlib/data/validateData.js.map +1 -1
  186. package/lib/stdlib/index.d.ts +2 -0
  187. package/lib/stdlib/index.js +3 -1
  188. package/lib/stdlib/index.js.map +1 -1
  189. package/lib/stdlib/item/edge/base.d.ts +2 -11
  190. package/lib/stdlib/item/edge/base.js +12 -105
  191. package/lib/stdlib/item/edge/base.js.map +1 -1
  192. package/lib/stdlib/item/node/base.d.ts +2 -20
  193. package/lib/stdlib/item/node/base.js +10 -150
  194. package/lib/stdlib/item/node/base.js.map +1 -1
  195. package/lib/stdlib/plugin/edgeFilterLens/index.js +2 -2
  196. package/lib/stdlib/plugin/edgeFilterLens/index.js.map +1 -1
  197. package/lib/stdlib/plugin/fisheye/index.js +2 -1
  198. package/lib/stdlib/plugin/fisheye/index.js.map +1 -1
  199. package/lib/stdlib/plugin/history/visibility-updated-command.js +2 -2
  200. package/lib/stdlib/plugin/history/visibility-updated-command.js.map +1 -1
  201. package/lib/stdlib/plugin/hull/index.d.ts +1 -1
  202. package/lib/stdlib/plugin/index.d.ts +1 -0
  203. package/lib/stdlib/plugin/index.js +1 -0
  204. package/lib/stdlib/plugin/index.js.map +1 -1
  205. package/lib/stdlib/plugin/lodController/index.d.ts +73 -0
  206. package/lib/stdlib/plugin/lodController/index.js +560 -0
  207. package/lib/stdlib/plugin/lodController/index.js.map +1 -0
  208. package/lib/stdlib/plugin/menu/index.js +2 -1
  209. package/lib/stdlib/plugin/menu/index.js.map +1 -1
  210. package/lib/stdlib/plugin/minimap/index.js +12 -14
  211. package/lib/stdlib/plugin/minimap/index.js.map +1 -1
  212. package/lib/stdlib/plugin/toolbar/index.d.ts +2 -2
  213. package/lib/stdlib/plugin/toolbar/index.js +27 -29
  214. package/lib/stdlib/plugin/toolbar/index.js.map +1 -1
  215. package/lib/stdlib/theme/dark.js +32 -35
  216. package/lib/stdlib/theme/dark.js.map +1 -1
  217. package/lib/stdlib/theme/light.js +27 -30
  218. package/lib/stdlib/theme/light.js.map +1 -1
  219. package/lib/stdlib/themeSolver/spec.js +2 -2
  220. package/lib/stdlib/themeSolver/spec.js.map +1 -1
  221. package/lib/types/animate.d.ts +1 -1
  222. package/lib/types/combo.d.ts +2 -2
  223. package/lib/types/edge.d.ts +2 -2
  224. package/lib/types/graph.d.ts +62 -43
  225. package/lib/types/hook.d.ts +5 -0
  226. package/lib/types/item.d.ts +9 -15
  227. package/lib/types/layout.d.ts +7 -2
  228. package/lib/types/layout.js.map +1 -1
  229. package/lib/types/node.d.ts +3 -2
  230. package/lib/types/plugin.d.ts +1 -0
  231. package/lib/types/plugin.js +1 -0
  232. package/lib/types/plugin.js.map +1 -1
  233. package/lib/types/spec.d.ts +1 -0
  234. package/lib/types/theme.d.ts +7 -7
  235. package/lib/util/animate.d.ts +7 -2
  236. package/lib/util/animate.js +40 -23
  237. package/lib/util/animate.js.map +1 -1
  238. package/lib/util/bbox.d.ts +7 -1
  239. package/lib/util/bbox.js +18 -1
  240. package/lib/util/bbox.js.map +1 -1
  241. package/lib/util/data.d.ts +7 -1
  242. package/lib/util/data.js +19 -6
  243. package/lib/util/data.js.map +1 -1
  244. package/lib/util/dom.js +5 -5
  245. package/lib/util/dom.js.map +1 -1
  246. package/lib/util/item.d.ts +1 -1
  247. package/lib/util/item.js +8 -8
  248. package/lib/util/item.js.map +1 -1
  249. package/lib/util/mapper.js +1 -1
  250. package/lib/util/mapper.js.map +1 -1
  251. package/lib/util/path.d.ts +6 -1
  252. package/lib/util/path.js +72 -1
  253. package/lib/util/path.js.map +1 -1
  254. package/lib/util/polyline.d.ts +10 -0
  255. package/lib/util/polyline.js +25 -18
  256. package/lib/util/polyline.js.map +1 -1
  257. package/lib/util/router.d.ts +1 -1
  258. package/lib/util/router.js +19 -18
  259. package/lib/util/router.js.map +1 -1
  260. package/lib/util/shape.d.ts +1 -1
  261. package/lib/util/shape.js +27 -12
  262. package/lib/util/shape.js.map +1 -1
  263. package/lib/util/zoom.d.ts +5 -8
  264. package/lib/util/zoom.js +17 -22
  265. package/lib/util/zoom.js.map +1 -1
  266. package/package.json +1 -1
  267. package/src/index.ts +1 -1
  268. package/src/item/combo.ts +13 -5
  269. package/src/item/edge.ts +126 -17
  270. package/src/item/item.ts +140 -57
  271. package/src/item/node.ts +109 -12
  272. package/src/runtime/controller/data.ts +64 -3
  273. package/src/runtime/controller/index.ts +1 -1
  274. package/src/runtime/controller/item.ts +321 -135
  275. package/src/runtime/controller/layout.ts +254 -113
  276. package/src/runtime/controller/plugin.ts +86 -33
  277. package/src/runtime/controller/viewport.ts +8 -2
  278. package/src/runtime/graph.ts +383 -158
  279. package/src/stdlib/behavior/click-select.ts +8 -3
  280. package/src/stdlib/behavior/drag-canvas.ts +6 -3
  281. package/src/stdlib/behavior/drag-combo.ts +8 -8
  282. package/src/stdlib/behavior/drag-node.ts +165 -50
  283. package/src/stdlib/behavior/scroll-canvas.ts +3 -3
  284. package/src/stdlib/behavior/zoom-canvas.ts +3 -3
  285. package/src/stdlib/data/mapNodeSize.ts +2 -2
  286. package/src/stdlib/data/validateData.ts +2 -2
  287. package/src/stdlib/index.ts +3 -0
  288. package/src/stdlib/item/edge/base.ts +15 -139
  289. package/src/stdlib/item/node/base.ts +20 -215
  290. package/src/stdlib/plugin/edgeFilterLens/index.ts +2 -2
  291. package/src/stdlib/plugin/fisheye/index.ts +3 -2
  292. package/src/stdlib/plugin/history/visibility-updated-command.ts +2 -2
  293. package/src/stdlib/plugin/index.ts +1 -0
  294. package/src/stdlib/plugin/lodController/index.ts +602 -0
  295. package/src/stdlib/plugin/menu/index.ts +1 -1
  296. package/src/stdlib/plugin/minimap/index.ts +12 -14
  297. package/src/stdlib/plugin/toolbar/index.ts +29 -31
  298. package/src/stdlib/theme/dark.ts +32 -34
  299. package/src/stdlib/theme/light.ts +27 -29
  300. package/src/stdlib/themeSolver/spec.ts +2 -2
  301. package/src/types/animate.ts +1 -1
  302. package/src/types/combo.ts +2 -2
  303. package/src/types/edge.ts +2 -2
  304. package/src/types/graph.ts +65 -53
  305. package/src/types/hook.ts +5 -0
  306. package/src/types/item.ts +8 -14
  307. package/src/types/layout.ts +20 -15
  308. package/src/types/node.ts +3 -2
  309. package/src/types/plugin.ts +2 -0
  310. package/src/types/spec.ts +1 -0
  311. package/src/types/theme.ts +7 -7
  312. package/src/util/animate.ts +104 -75
  313. package/src/util/bbox.ts +26 -1
  314. package/src/util/data.ts +15 -6
  315. package/src/util/dom.ts +6 -6
  316. package/src/util/item.ts +15 -1
  317. package/src/util/mapper.ts +1 -1
  318. package/src/util/path.ts +72 -2
  319. package/src/util/polyline.ts +30 -23
  320. package/src/util/router.ts +21 -19
  321. package/src/util/shape.ts +27 -12
  322. package/src/util/zoom.ts +19 -25
  323. package/esm/runtime/controller/extension.d.ts +0 -9
  324. package/esm/runtime/controller/extension.js +0 -11
  325. package/esm/runtime/controller/extension.js.map +0 -1
  326. package/lib/runtime/controller/extension.d.ts +0 -9
  327. package/lib/runtime/controller/extension.js +0 -15
  328. package/lib/runtime/controller/extension.js.map +0 -1
  329. package/src/runtime/controller/extension.ts +0 -14
@@ -1,7 +1,9 @@
1
- import { AABB, DisplayObject } from '@antv/g';
1
+ import { AABB, DisplayObject, Group } from '@antv/g';
2
2
  import { ID } from '@antv/graphlib';
3
- import { IGraph } from '../../types';
3
+ import { IGraph, NodeDisplayModel } from '../../types';
4
+ import { ComboDisplayModel } from '../../types/combo';
4
5
  import { GraphCore } from '../../types/data';
6
+ import { EdgeDisplayModel } from '../../types/edge';
5
7
  import Node from '../../item/node';
6
8
  import Edge from '../../item/edge';
7
9
  import Combo from '../../item/combo';
@@ -31,16 +33,24 @@ export declare class ItemController {
31
33
  private edgeStateMapper;
32
34
  private comboStateMapper;
33
35
  private nodeGroup;
36
+ private nodeLabelGroup;
37
+ private edgeLabelGroup;
34
38
  private edgeGroup;
35
39
  private comboGroup;
36
40
  private transientNodeGroup;
37
41
  private transientEdgeGroup;
38
42
  private transientComboGroup;
43
+ private transientNodeLabelGroup;
44
+ private transientEdgeLabelGroup;
39
45
  private nodeDataTypeSet;
40
46
  private edgeDataTypeSet;
41
47
  private comboDataTypeSet;
42
48
  private transientObjectMap;
43
49
  private transientItemMap;
50
+ /** Caches */
51
+ private nearEdgesCache;
52
+ private cacheViewItems;
53
+ private cacheWarnMsg;
44
54
  constructor(graph: IGraph<any, any>);
45
55
  /**
46
56
  * Subscribe the lifecycle of graph.
@@ -72,14 +82,20 @@ export declare class ItemController {
72
82
  private onItemStateChange;
73
83
  private onItemVisibilityChange;
74
84
  private onItemZIndexChange;
85
+ /**
86
+ * get the items inside viewport
87
+ * @returns
88
+ */
89
+ private groupItemsByView;
75
90
  private onViewportChange;
76
91
  private onThemeChange;
77
92
  private onMapperChange;
78
93
  private onDestroy;
79
94
  private onTransientUpdate;
80
95
  getTransient(id: string): DisplayObject<any, any>;
81
- getTransientItem(id: ID): any;
82
- findDisplayModel(id: ID): import("../../types/item").ItemDisplayModel;
96
+ getTransientItem(id: ID): Group | Node | Combo | Edge;
97
+ getItemMap(): Map<ID, Node | Combo | Edge>;
98
+ findDisplayModel(id: ID): NodeDisplayModel | EdgeDisplayModel | ComboDisplayModel;
83
99
  /**
84
100
  * Create nodes with inner data to canvas.
85
101
  * @param models nodes' inner datas
@@ -109,14 +125,9 @@ export declare class ItemController {
109
125
  getItemAllStates(id: ID): string[];
110
126
  getItemById(id: ID): Node | Combo | Edge;
111
127
  getItemBBox(id: ID, isKeyShape?: boolean, isTransient?: boolean): AABB | false;
128
+ getItemVisibleShapeIds(id: ID): any[];
129
+ private debounceWarn;
112
130
  getItemVisible(id: ID): boolean;
113
- /**
114
- * Identify edges that are intersected by a particular node
115
- * @param nodeId node id
116
- * @param graphCore
117
- * @returns
118
- */
119
- findNearEdgesByNode(nodeId: ID, graphCore: GraphCore): import("@antv/graphlib").Edge<import("../../types/edge").EdgeUserModelData>[];
120
131
  sortByComboTree(graphCore: GraphCore): void;
121
132
  private collapseCombo;
122
133
  private expandCombo;
@@ -26,9 +26,38 @@ const item_1 = require("../../util/item");
26
26
  const zoom_1 = require("../../util/zoom");
27
27
  const data_1 = require("../../util/data");
28
28
  const event_1 = require("../../util/event");
29
- const polyline_1 = require("../../util/polyline");
30
29
  const bbox_1 = require("../../util/bbox");
31
30
  const type_1 = require("../../util/type");
31
+ const polyline_1 = require("../../util/polyline");
32
+ var WARN_TYPE;
33
+ (function (WARN_TYPE) {
34
+ WARN_TYPE[WARN_TYPE["FAIL_GET_BBOX"] = 0] = "FAIL_GET_BBOX";
35
+ WARN_TYPE[WARN_TYPE["FAIL_GET_VISIBLE"] = 1] = "FAIL_GET_VISIBLE";
36
+ WARN_TYPE[WARN_TYPE["FAIL_SET_STATE"] = 2] = "FAIL_SET_STATE";
37
+ WARN_TYPE[WARN_TYPE["FAIL_GET_STATE"] = 3] = "FAIL_GET_STATE";
38
+ WARN_TYPE[WARN_TYPE["FAIL_SET_VISIBLE"] = 4] = "FAIL_SET_VISIBLE";
39
+ WARN_TYPE[WARN_TYPE["FAIL_DRAW_TRANSIENT"] = 5] = "FAIL_DRAW_TRANSIENT";
40
+ WARN_TYPE[WARN_TYPE["SOURCE_NOT_EXIST"] = 6] = "SOURCE_NOT_EXIST";
41
+ WARN_TYPE[WARN_TYPE["TARGET_NOT_EXIST"] = 7] = "TARGET_NOT_EXIST";
42
+ })(WARN_TYPE || (WARN_TYPE = {}));
43
+ const getWarnMsg = {
44
+ [WARN_TYPE.FAIL_GET_BBOX]: (ids) => `Fail to get items' bboxes, the items with ids ${ids.join(', ')} do not exist.`,
45
+ [WARN_TYPE.FAIL_GET_VISIBLE]: (ids) => `Fail to get items' visible, the items with ids ${ids.join(', ')} do not exist.`,
46
+ [WARN_TYPE.FAIL_SET_STATE]: (ids) => `Fail to set states for items ${ids.join(', ')}, which do not exist.`,
47
+ [WARN_TYPE.FAIL_SET_VISIBLE]: (ids) => `Fail to set visibility for items ${ids.join(', ')}, which do not exist.`,
48
+ [WARN_TYPE.FAIL_DRAW_TRANSIENT]: (ids) => `Fail to draw transient items of ${ids}, which do not exist.`,
49
+ [WARN_TYPE.SOURCE_NOT_EXIST]: (params) => `The source nodes ${params
50
+ .map((p) => p.source)
51
+ .join(', ')} do not exist in the graph for edges ${params
52
+ .map((p) => p.id)
53
+ .join(', ')}, please add the nodes first`,
54
+ [WARN_TYPE.TARGET_NOT_EXIST]: (params) => `The target nodes ${params
55
+ .map((p) => p.target)
56
+ .join(', ')} do not exist in the graph for edges ${params
57
+ .map((p) => p.id)
58
+ .join(', ')}, please add the nodes first`,
59
+ [WARN_TYPE.FAIL_GET_STATE]: (ids) => `Fail to get items' states, the items with ids ${ids.join(', ')} do not exist.`,
60
+ };
32
61
  /**
33
62
  * Manages and stores the node / edge / combo items.
34
63
  */
@@ -47,26 +76,70 @@ class ItemController {
47
76
  // The G shapes or groups on transient map drawn by this controller
48
77
  this.transientObjectMap = new Map();
49
78
  this.transientItemMap = new Map();
50
- this.onViewportChange = (0, util_1.debounce)(({ transform, effectTiming, tileLodSize = 1000, }) => {
51
- const { zoom } = transform;
52
- if (zoom) {
53
- const zoomRatio = this.graph.getZoom();
54
- const range = this.graph.getCanvasRange();
55
- const nodeItems = Array.from(this.itemMap, ([key, value]) => value);
56
- const itemsInViewport = [];
57
- const itemsOutViewport = [];
58
- nodeItems.forEach((item) => {
79
+ /** Caches */
80
+ this.nearEdgesCache = new Map();
81
+ this.cacheWarnMsg = {};
82
+ /**
83
+ * get the items inside viewport
84
+ * @returns
85
+ */
86
+ this.groupItemsByView = (containType = 'inside', ratio = 1) => {
87
+ const range = this.graph.getCanvasRange();
88
+ const items = Array.from(this.itemMap, ([key, value]) => value);
89
+ const containFunc = containType === 'intersect' ? shape_1.intersectBBox : bbox_1.isBBoxInBBox;
90
+ let { inView: itemsInView, outView: itemsOutView } = this.cacheViewItems || {};
91
+ if (!ratio || ratio === 1 || !this.cacheViewItems) {
92
+ itemsInView = [];
93
+ itemsOutView = [];
94
+ items.forEach((item) => {
59
95
  const { keyShape } = item.shapeMap;
60
96
  if (!keyShape)
61
97
  return;
62
98
  const renderBounds = keyShape.getRenderBounds();
63
- if ((0, bbox_1.isBBoxInBBox)(renderBounds, range, 0.4))
64
- itemsInViewport.push(item);
99
+ if (containFunc(renderBounds, range, 0.4))
100
+ itemsInView.push(item);
65
101
  else
66
- itemsOutViewport.push(item);
102
+ itemsOutView.push(item);
103
+ });
104
+ }
105
+ else if (ratio < 1) {
106
+ // zoom-out
107
+ itemsOutView.forEach((item) => {
108
+ const { keyShape } = item.shapeMap;
109
+ if (!keyShape)
110
+ return;
111
+ const renderBounds = keyShape.getRenderBounds();
112
+ if (containFunc(renderBounds, range, 0.4)) {
113
+ itemsInView.push(item);
114
+ }
115
+ });
116
+ }
117
+ else if (ratio > 1) {
118
+ // zoom-in
119
+ itemsInView.forEach((item) => {
120
+ const { keyShape } = item.shapeMap;
121
+ if (!keyShape)
122
+ return;
123
+ const renderBounds = keyShape.getRenderBounds();
124
+ if (!containFunc(renderBounds, range, 0.4)) {
125
+ itemsOutView.push(item);
126
+ }
67
127
  });
68
- const sortedItems = itemsInViewport.concat(itemsOutViewport);
69
- const sections = Math.ceil(nodeItems.length / tileLodSize);
128
+ }
129
+ this.cacheViewItems = { inView: itemsInView, outView: itemsOutView };
130
+ return {
131
+ items,
132
+ inView: itemsInView,
133
+ outView: itemsOutView,
134
+ };
135
+ };
136
+ this.onViewportChange = (0, util_1.debounce)(({ transform, effectTiming, tileLodSize = 1000, }) => {
137
+ const { zoom } = transform;
138
+ if (zoom) {
139
+ const zoomRatio = this.graph.getZoom();
140
+ const { items, inView: itemsInview, outView: itemsOutView, } = this.groupItemsByView();
141
+ const sortedItems = itemsInview.concat(itemsOutView);
142
+ const sections = Math.ceil(items.length / tileLodSize);
70
143
  const itemSections = Array.from({ length: sections }, (v, i) => sortedItems.slice(i * tileLodSize, i * tileLodSize + tileLodSize));
71
144
  let requestId;
72
145
  const update = () => {
@@ -78,7 +151,6 @@ class ItemController {
78
151
  requestId = requestAnimationFrame(update);
79
152
  };
80
153
  requestId = requestAnimationFrame(update);
81
- // this.itemMap.forEach((item) => item.updateZoom(zoomRatio));
82
154
  this.zoom = zoomRatio;
83
155
  }
84
156
  }, 500, false);
@@ -117,6 +189,11 @@ class ItemController {
117
189
  // Fix OOM problem, since this map will hold all the refs of items.
118
190
  this.itemMap.clear();
119
191
  };
192
+ this.debounceWarn = (0, util_1.debounce)((type) => {
193
+ const msg = getWarnMsg[type](this.cacheWarnMsg[type]);
194
+ console.warn(msg);
195
+ this.cacheWarnMsg[type] = [];
196
+ }, 16, false);
120
197
  this.graph = graph;
121
198
  // get mapper for node / edge / combo
122
199
  const { node, edge, combo, nodeState = {}, edgeState = {}, comboState = {}, } = graph.getSpecification();
@@ -176,19 +253,30 @@ class ItemController {
176
253
  */
177
254
  onRender(param) {
178
255
  return __awaiter(this, void 0, void 0, function* () {
179
- const { graphCore, theme = {}, transientCanvas, tileOptimize = {} } = param;
256
+ const { graphCore, theme = {}, transientCanvas, transientLabelCanvas, tileOptimize = {}, } = param;
180
257
  const { graph } = this;
181
258
  // 0. clear groups on canvas, and create new groups
182
259
  graph.canvas.removeChildren();
183
- const comboGroup = new g_1.Group({ id: 'combo-group', style: { zIndex: 0 } });
184
- const edgeGroup = new g_1.Group({ id: 'edge-group', style: { zIndex: 1 } });
185
- const nodeGroup = new g_1.Group({ id: 'node-group', style: { zIndex: 2 } });
186
- graph.canvas.appendChild(comboGroup);
187
- graph.canvas.appendChild(edgeGroup);
188
- graph.canvas.appendChild(nodeGroup);
189
- this.nodeGroup = nodeGroup;
190
- this.edgeGroup = edgeGroup;
191
- this.comboGroup = comboGroup;
260
+ graph.labelCanvas.removeChildren();
261
+ graph.transientCanvas.removeChildren();
262
+ this.itemMap.forEach((item) => item.destroy());
263
+ this.itemMap.clear();
264
+ this.comboGroup = new g_1.Group({ id: 'combo-group', style: { zIndex: 0 } });
265
+ this.edgeGroup = new g_1.Group({ id: 'edge-group', style: { zIndex: 1 } });
266
+ this.nodeGroup = new g_1.Group({ id: 'node-group', style: { zIndex: 2 } });
267
+ this.edgeLabelGroup = new g_1.Group({
268
+ id: 'node-label-group',
269
+ style: { zIndex: 0 },
270
+ });
271
+ this.nodeLabelGroup = new g_1.Group({
272
+ id: 'node-label-group',
273
+ style: { zIndex: 1 },
274
+ });
275
+ graph.canvas.appendChild(this.comboGroup);
276
+ graph.canvas.appendChild(this.edgeGroup);
277
+ graph.canvas.appendChild(this.nodeGroup);
278
+ graph.labelCanvas.appendChild(this.edgeLabelGroup);
279
+ graph.labelCanvas.appendChild(this.nodeLabelGroup);
192
280
  // Also create transient groups on transient canvas.
193
281
  transientCanvas.removeChildren();
194
282
  this.transientComboGroup = new g_1.Group({
@@ -206,6 +294,16 @@ class ItemController {
206
294
  transientCanvas.appendChild(this.transientComboGroup);
207
295
  transientCanvas.appendChild(this.transientEdgeGroup);
208
296
  transientCanvas.appendChild(this.transientNodeGroup);
297
+ this.transientEdgeLabelGroup = new g_1.Group({
298
+ id: 'node-label-group',
299
+ style: { zIndex: 0 },
300
+ });
301
+ this.transientNodeLabelGroup = new g_1.Group({
302
+ id: 'node-label-group',
303
+ style: { zIndex: 1 },
304
+ });
305
+ transientLabelCanvas.appendChild(this.transientEdgeLabelGroup);
306
+ transientLabelCanvas.appendChild(this.transientNodeLabelGroup);
209
307
  // 1. create lights for webgl 3d rendering
210
308
  if (graph.rendererType === 'webgl-3d') {
211
309
  const ambientLight = new g_plugin_3d_1.AmbientLight({
@@ -341,7 +439,6 @@ class ItemController {
341
439
  };
342
440
  const debounceUpdateRelates = (0, util_1.debounce)(updateRelates, 16, false);
343
441
  Object.values(nodeComboUpdate).forEach((updateObj) => {
344
- var _a;
345
442
  const { isReplace, previous, current, id } = updateObj;
346
443
  if (!graphCore.hasNode(id))
347
444
  return;
@@ -409,11 +506,15 @@ class ItemController {
409
506
  previous[nodeDataTypeField] !== current[nodeDataTypeField]) {
410
507
  itemTheme = getItemTheme(this.nodeDataTypeSet, nodeDataTypeField, current[nodeDataTypeField], nodeTheme);
411
508
  }
412
- const preventPolylineEdgeOverlap = ((_a = innerModel === null || innerModel === void 0 ? void 0 : innerModel.data) === null || _a === void 0 ? void 0 : _a.preventPolylineEdgeOverlap) || false;
413
- const relatedEdgeInnerModels = preventPolylineEdgeOverlap
414
- ? this.findNearEdgesByNode(id, graphCore).concat(graphCore.getRelatedEdges(id))
415
- : graphCore.getRelatedEdges(id);
416
- relatedEdgeInnerModels.forEach((edge) => {
509
+ const adjacentEdgeInnerModels = graphCore.getRelatedEdges(id);
510
+ if ((0, polyline_1.isPointPreventPolylineOverlap)(innerModel)) {
511
+ const newNearEdges = this.graph.getNearEdgesData(id, (edge) => (0, polyline_1.isPolylineWithObstacleAvoidance)(edge));
512
+ const prevNearEdges = this.nearEdgesCache.get(id) || [];
513
+ adjacentEdgeInnerModels.push(...newNearEdges);
514
+ adjacentEdgeInnerModels.push(...prevNearEdges);
515
+ this.nearEdgesCache.set(id, newNearEdges);
516
+ }
517
+ adjacentEdgeInnerModels.forEach((edge) => {
417
518
  edgeIdsToUpdate.add(edge.id);
418
519
  nodeRelatedIdsToUpdate.add(edge.id);
419
520
  });
@@ -441,7 +542,7 @@ class ItemController {
441
542
  const parentItem = this.itemMap.get(current.parentId);
442
543
  if (current.parentId && (parentItem === null || parentItem === void 0 ? void 0 : parentItem.model.data.collapsed)) {
443
544
  this.graph.executeWithNoStack(() => {
444
- this.graph.hideItem(innerModel.id, false);
545
+ this.graph.hideItem(innerModel.id, { disableAnimate: false });
445
546
  });
446
547
  }
447
548
  });
@@ -511,7 +612,7 @@ class ItemController {
511
612
  let parent = graphCore.getParent(nodeId, 'tree');
512
613
  while (parent) {
513
614
  if (parent.data.collapsed) {
514
- this.graph.hideItem(nodeId, true);
615
+ this.graph.hideItem(nodeId, { disableAnimate: true });
515
616
  break;
516
617
  }
517
618
  parent = graphCore.getParent(parent.id, 'tree');
@@ -533,7 +634,11 @@ class ItemController {
533
634
  ids.forEach((id) => {
534
635
  const item = this.itemMap.get(id);
535
636
  if (!item) {
536
- console.warn(`Fail to set state for item ${id}, which is not exist.`);
637
+ this.cacheWarnMsg[WARN_TYPE.FAIL_SET_STATE] =
638
+ this.cacheWarnMsg[WARN_TYPE.FAIL_SET_STATE] || [];
639
+ this.cacheWarnMsg[WARN_TYPE.FAIL_SET_STATE].push(id);
640
+ // @ts-ignore
641
+ this.debounceWarn(WARN_TYPE.FAIL_SET_STATE);
537
642
  return;
538
643
  }
539
644
  if (!states || !value) {
@@ -546,17 +651,31 @@ class ItemController {
546
651
  });
547
652
  }
548
653
  onItemVisibilityChange(param) {
549
- const { ids, value, graphCore, animate = true, keepKeyShape = false, } = param;
654
+ const { ids, shapeIds, value, graphCore, animate = true, keepKeyShape = false, keepRelated = false, } = param;
550
655
  ids.forEach((id) => {
551
656
  const item = this.itemMap.get(id);
552
657
  if (!item) {
553
- console.warn(`Fail to set visibility for item ${id}, which is not exist.`);
658
+ this.cacheWarnMsg[WARN_TYPE.FAIL_SET_VISIBLE] =
659
+ this.cacheWarnMsg[WARN_TYPE.FAIL_SET_VISIBLE] || [];
660
+ this.cacheWarnMsg[WARN_TYPE.FAIL_SET_VISIBLE].push(id);
661
+ // @ts-ignore
662
+ this.debounceWarn(WARN_TYPE.FAIL_SET_VISIBLE);
663
+ return;
664
+ }
665
+ if (shapeIds === null || shapeIds === void 0 ? void 0 : shapeIds.length) {
666
+ if (value) {
667
+ item.show(animate, shapeIds);
668
+ }
669
+ else {
670
+ item.hide(animate, false, shapeIds);
671
+ }
554
672
  return;
555
673
  }
556
674
  const type = item.getType();
557
675
  if (value) {
558
676
  if (type === 'edge') {
559
677
  item.show(animate);
678
+ item.forceUpdate();
560
679
  }
561
680
  else {
562
681
  if (graphCore.hasTreeStructure('combo')) {
@@ -580,7 +699,7 @@ class ItemController {
580
699
  }
581
700
  else {
582
701
  item.hide(animate, keepKeyShape);
583
- if (type !== 'edge') {
702
+ if (type !== 'edge' && !keepRelated) {
584
703
  const relatedEdges = graphCore.getRelatedEdges(id);
585
704
  relatedEdges.forEach(({ id: edgeId }) => {
586
705
  var _a;
@@ -659,10 +778,14 @@ class ItemController {
659
778
  if (isItemType) {
660
779
  const item = this.itemMap.get(id);
661
780
  if (!item) {
662
- console.warn(`Fail to draw transient item of ${id}, which is not exist.`);
781
+ this.cacheWarnMsg[WARN_TYPE.FAIL_DRAW_TRANSIENT] =
782
+ this.cacheWarnMsg[WARN_TYPE.FAIL_DRAW_TRANSIENT] || [];
783
+ this.cacheWarnMsg[WARN_TYPE.FAIL_DRAW_TRANSIENT].push(id);
784
+ // @ts-ignore
785
+ this.debounceWarn(WARN_TYPE.FAIL_DRAW_TRANSIENT);
663
786
  return;
664
787
  }
665
- const transientItem = (0, item_1.upsertTransientItem)(item, this.transientNodeGroup, this.transientEdgeGroup, this.transientComboGroup, this.transientItemMap, this.itemMap, graphCore, { shapeIds, drawSource, drawTarget, visible }, upsertAncestors);
788
+ const transientItem = (0, item_1.upsertTransientItem)(item, this.transientNodeGroup, this.transientEdgeGroup, this.transientComboGroup, this.transientNodeLabelGroup, this.transientEdgeLabelGroup, this.transientItemMap, this.itemMap, graphCore, { shapeIds, drawSource, drawTarget, visible }, upsertAncestors);
666
789
  if (shapeIds) {
667
790
  // only update node positions to cloned node container(group)
668
791
  if ((type === 'node' || type === 'combo') &&
@@ -705,6 +828,14 @@ class ItemController {
705
828
  }
706
829
  // Update the target combo's posiiton and other props
707
830
  transItem.update(Object.assign(Object.assign({}, transItem.model), { data: Object.assign(Object.assign({}, transItem.model.data), data) }));
831
+ if (type !== 'edge') {
832
+ const relatedEdges = graphCore.getRelatedEdges(transItem.model.id);
833
+ relatedEdges.forEach((relatedEdge) => {
834
+ const transientEdge = this.transientItemMap.get(relatedEdge.id);
835
+ if (transientEdge)
836
+ transientEdge.forceUpdate();
837
+ });
838
+ }
708
839
  }
709
840
  return;
710
841
  }
@@ -719,11 +850,19 @@ class ItemController {
719
850
  return this.transientObjectMap.get(id);
720
851
  }
721
852
  getTransientItem(id) {
722
- return this.transientItemMap[id];
853
+ return this.transientItemMap.get(id);
854
+ }
855
+ getItemMap() {
856
+ return this.itemMap;
723
857
  }
724
858
  findDisplayModel(id) {
725
- var _a;
726
- return (_a = this.itemMap.get(id)) === null || _a === void 0 ? void 0 : _a.displayModel;
859
+ const item = this.itemMap.get(id);
860
+ if (!item)
861
+ return { id, data: {} };
862
+ return {
863
+ id,
864
+ data: Object.assign(Object.assign(Object.assign({}, item.displayModel.data), item.renderExt.mergedStyles), { lodLevels: item.lodLevels }),
865
+ };
727
866
  }
728
867
  /**
729
868
  * Create nodes with inner data to canvas.
@@ -731,7 +870,7 @@ class ItemController {
731
870
  */
732
871
  renderNodes(models, nodeTheme = {}, tileOptimize) {
733
872
  return __awaiter(this, void 0, void 0, function* () {
734
- const { nodeExtensions, nodeGroup, nodeDataTypeSet, graph } = this;
873
+ const { nodeExtensions, nodeGroup, nodeLabelGroup, nodeDataTypeSet, graph, } = this;
735
874
  const { dataTypeField = '' } = nodeTheme;
736
875
  const { tileFirstRender, tileFirstRenderSize = 1000 } = tileOptimize || {};
737
876
  const zoom = graph.getZoom();
@@ -748,10 +887,12 @@ class ItemController {
748
887
  dataType = node.data[dataTypeField];
749
888
  const itemTheme = getItemTheme(nodeDataTypeSet, dataTypeField, dataType, nodeTheme);
750
889
  const nodeItem = new node_1.default({
890
+ graph,
751
891
  delayFirstDraw,
752
892
  model: node,
753
893
  renderExtensions: nodeExtensions,
754
894
  containerGroup: nodeGroup,
895
+ labelContainerGroup: nodeLabelGroup,
755
896
  mapper: this.nodeMapper,
756
897
  stateMapper: this.nodeStateMapper,
757
898
  zoom,
@@ -816,10 +957,12 @@ class ItemController {
816
957
  };
817
958
  const comboItem = new combo_1.default({
818
959
  model: combo,
960
+ graph: this.graph,
819
961
  getCombinedBounds,
820
962
  getChildren,
821
963
  renderExtensions: comboExtensions,
822
964
  containerGroup: comboGroup,
965
+ labelContainerGroup: this.nodeLabelGroup,
823
966
  mapper: this.comboMapper,
824
967
  stateMapper: this.comboStateMapper,
825
968
  zoom,
@@ -842,7 +985,7 @@ class ItemController {
842
985
  * @param models edges' inner datas
843
986
  */
844
987
  renderEdges(models, edgeTheme = {}, tileOptimize, nodesInView) {
845
- const { edgeExtensions, edgeGroup, itemMap, edgeDataTypeSet, graph } = this;
988
+ const { edgeExtensions, edgeGroup, edgeLabelGroup, itemMap, edgeDataTypeSet, graph, } = this;
846
989
  const { dataTypeField = '' } = edgeTheme;
847
990
  const { tileFirstRender, tileFirstRenderSize = 1000 } = tileOptimize || {};
848
991
  const zoom = graph.getZoom();
@@ -858,11 +1001,19 @@ class ItemController {
858
1001
  const sourceItem = itemMap.get(source);
859
1002
  const targetItem = itemMap.get(target);
860
1003
  if (!sourceItem) {
861
- console.warn(`The source node ${source} is not exist in the graph for edge ${id}, please add the node first`);
1004
+ this.cacheWarnMsg[WARN_TYPE.SOURCE_NOT_EXIST] =
1005
+ this.cacheWarnMsg[WARN_TYPE.SOURCE_NOT_EXIST] || [];
1006
+ this.cacheWarnMsg[WARN_TYPE.SOURCE_NOT_EXIST].push({ id, source });
1007
+ // @ts-ignore
1008
+ this.debounceWarn(WARN_TYPE.SOURCE_NOT_EXIST);
862
1009
  return;
863
1010
  }
864
1011
  if (!targetItem) {
865
- console.warn(`The source node ${source} is not exist in the graph for edge ${id}, please add the node first`);
1012
+ this.cacheWarnMsg[WARN_TYPE.TARGET_NOT_EXIST] =
1013
+ this.cacheWarnMsg[WARN_TYPE.TARGET_NOT_EXIST] || [];
1014
+ this.cacheWarnMsg[WARN_TYPE.TARGET_NOT_EXIST].push({ id, source });
1015
+ // @ts-ignore
1016
+ this.debounceWarn(WARN_TYPE.TARGET_NOT_EXIST);
866
1017
  return;
867
1018
  }
868
1019
  // get the base styles from theme
@@ -871,10 +1022,12 @@ class ItemController {
871
1022
  dataType = edge.data[dataTypeField];
872
1023
  const itemTheme = getItemTheme(edgeDataTypeSet, dataTypeField, dataType, edgeTheme);
873
1024
  const edgeItem = new edge_1.default({
1025
+ graph,
874
1026
  delayFirstDraw,
875
1027
  model: edge,
876
1028
  renderExtensions: edgeExtensions,
877
1029
  containerGroup: edgeGroup,
1030
+ labelContainerGroup: edgeLabelGroup,
878
1031
  mapper: this.edgeMapper,
879
1032
  stateMapper: this.edgeStateMapper,
880
1033
  sourceItem,
@@ -934,7 +1087,11 @@ class ItemController {
934
1087
  getItemState(id, state) {
935
1088
  const item = this.itemMap.get(id);
936
1089
  if (!item) {
937
- console.warn(`Fail to get item state, the item with id ${id} does not exist.`);
1090
+ this.cacheWarnMsg[WARN_TYPE.FAIL_GET_STATE] =
1091
+ this.cacheWarnMsg[WARN_TYPE.FAIL_GET_STATE] || [];
1092
+ this.cacheWarnMsg[WARN_TYPE.FAIL_GET_STATE].push(id);
1093
+ // @ts-ignore
1094
+ this.debounceWarn(WARN_TYPE.FAIL_GET_STATE);
938
1095
  return false;
939
1096
  }
940
1097
  return item.hasState(state);
@@ -942,7 +1099,11 @@ class ItemController {
942
1099
  getItemAllStates(id) {
943
1100
  const item = this.itemMap.get(id);
944
1101
  if (!item) {
945
- console.warn(`Fail to get item state, the item with id ${id} does not exist.`);
1102
+ this.cacheWarnMsg[WARN_TYPE.FAIL_GET_STATE] =
1103
+ this.cacheWarnMsg[WARN_TYPE.FAIL_GET_STATE] || [];
1104
+ this.cacheWarnMsg[WARN_TYPE.FAIL_GET_STATE].push(id);
1105
+ // @ts-ignore
1106
+ this.debounceWarn(WARN_TYPE.FAIL_GET_STATE);
946
1107
  return [];
947
1108
  }
948
1109
  return item
@@ -958,55 +1119,39 @@ class ItemController {
958
1119
  ? this.transientItemMap.get(id)
959
1120
  : this.itemMap.get(id);
960
1121
  if (!item) {
961
- console.warn(`Fail to get item bbox, the item with id ${id} does not exist.`);
1122
+ this.cacheWarnMsg[WARN_TYPE.FAIL_GET_BBOX] =
1123
+ this.cacheWarnMsg[WARN_TYPE.FAIL_GET_BBOX] || [];
1124
+ this.cacheWarnMsg[WARN_TYPE.FAIL_GET_BBOX].push(id);
1125
+ // @ts-ignore
1126
+ this.debounceWarn(WARN_TYPE.FAIL_GET_BBOX);
962
1127
  return false;
963
1128
  }
964
1129
  if (item instanceof g_1.Group)
965
1130
  return item.getRenderBounds();
966
1131
  return isKeyShape ? item.getKeyBBox() : item.getBBox();
967
1132
  }
1133
+ getItemVisibleShapeIds(id) {
1134
+ const item = this.itemMap.get(id);
1135
+ const shapeIds = [];
1136
+ Object.keys(item.shapeMap).forEach((shapeId) => {
1137
+ var _a;
1138
+ if (((_a = item.shapeMap[shapeId]) === null || _a === void 0 ? void 0 : _a.attributes.visibility) !== 'hidden')
1139
+ shapeIds.push(shapeId);
1140
+ });
1141
+ return shapeIds;
1142
+ }
968
1143
  getItemVisible(id) {
969
1144
  const item = this.itemMap.get(id);
970
1145
  if (!item) {
971
- console.warn(`Fail to get item visible, the item with id ${id} does not exist.`);
1146
+ this.cacheWarnMsg[WARN_TYPE.FAIL_GET_VISIBLE] =
1147
+ this.cacheWarnMsg[WARN_TYPE.FAIL_GET_VISIBLE] || [];
1148
+ this.cacheWarnMsg[WARN_TYPE.FAIL_GET_VISIBLE].push(id);
1149
+ // @ts-ignore
1150
+ this.debounceWarn(WARN_TYPE.FAIL_GET_VISIBLE);
972
1151
  return false;
973
1152
  }
974
1153
  return item.isVisible();
975
1154
  }
976
- /**
977
- * Identify edges that are intersected by a particular node
978
- * @param nodeId node id
979
- * @param graphCore
980
- * @returns
981
- */
982
- findNearEdgesByNode(nodeId, graphCore) {
983
- var _a;
984
- const edges = graphCore.getAllEdges();
985
- const canvasBBox = this.graph.getRenderBBox(undefined);
986
- const quadTree = new polyline_1.QuadTree(canvasBBox, 4);
987
- (0, util_1.each)(edges, (edge) => {
988
- const { data: { x: sourceX, y: sourceY }, } = graphCore.getNode(edge.source);
989
- const { data: { x: targetX, y: targetY }, } = graphCore.getNode(edge.target);
990
- quadTree.insert({
991
- id: edge.id,
992
- p1: { x: sourceX, y: sourceY },
993
- p2: { x: targetX, y: targetY },
994
- bbox: this.graph.getRenderBBox(edge.id),
995
- });
996
- });
997
- // update node position
998
- const node = (this.getTransientItem(nodeId) ||
999
- this.getItemById(nodeId));
1000
- const nodeBBox = this.graph.getRenderBBox(nodeId);
1001
- const nodeData = (_a = node === null || node === void 0 ? void 0 : node.model) === null || _a === void 0 ? void 0 : _a.data;
1002
- if (nodeData) {
1003
- nodeBBox.update([nodeData.x, nodeData.y, 0], nodeBBox.halfExtents);
1004
- }
1005
- const checker = new polyline_1.EdgeCollisionChecker(quadTree);
1006
- const collisions = checker.getCollidingEdges(nodeBBox);
1007
- const collidingEdges = (0, util_1.map)(collisions, (collision) => graphCore.getEdge(collision.id));
1008
- return collidingEdges;
1009
- }
1010
1155
  sortByComboTree(graphCore) {
1011
1156
  if (!graphCore.hasTreeStructure('combo'))
1012
1157
  return;
@@ -1024,7 +1169,7 @@ class ItemController {
1024
1169
  (0, data_1.graphComboTreeDfs)(this.graph, [comboModel], (child) => {
1025
1170
  if (child.id !== comboModel.id) {
1026
1171
  this.graph.executeWithNoStack(() => {
1027
- this.graph.hideItem(child.id, false);
1172
+ this.graph.hideItem(child.id, { disableAnimate: false });
1028
1173
  });
1029
1174
  }
1030
1175
  relatedEdges = relatedEdges.concat(graphCore.getRelatedEdges(child.id));
@@ -1178,8 +1323,8 @@ class ItemController {
1178
1323
  if (!positions.length)
1179
1324
  return;
1180
1325
  this.graph.updateNodePosition(positions, undefined, !animate, (model, canceled) => {
1181
- this.graph.hideItem(model.id, canceled);
1182
- }, undefined);
1326
+ this.graph.hideItem(model.id, { disableAnimate: canceled });
1327
+ });
1183
1328
  }
1184
1329
  /**
1185
1330
  * Expand sub tree(s).
@@ -1209,21 +1354,21 @@ class ItemController {
1209
1354
  allNodeIds = allNodeIds.concat(nodeIds.filter((id) => id !== root.id));
1210
1355
  });
1211
1356
  const ids = (0, util_1.uniq)(allNodeIds.concat(allEdgeIds));
1212
- this.graph.showItem(ids, !animate);
1357
+ this.graph.showItem(ids, { disableAnimate: !animate });
1213
1358
  yield this.graph.layout(undefined, !animate);
1214
1359
  });
1215
1360
  }
1216
1361
  }
1217
1362
  exports.ItemController = ItemController;
1218
1363
  const getItemTheme = (dataTypeSet, dataTypeField, dataType, itemTheme) => {
1219
- const { styles: themeStyles = [], lodStrategy } = itemTheme;
1220
- const formattedLodStrategy = (0, zoom_1.formatLodStrategy)(lodStrategy);
1364
+ const { styles: themeStyles = [], lodLevels } = itemTheme;
1365
+ const formattedLodLevels = (0, zoom_1.formatLodLevels)(lodLevels);
1221
1366
  if (!dataTypeField) {
1222
1367
  // dataType field is not assigned
1223
1368
  const styles = (0, util_1.isArray)(themeStyles)
1224
1369
  ? themeStyles[0]
1225
1370
  : Object.values(themeStyles)[0];
1226
- return { styles, lodStrategy: formattedLodStrategy };
1371
+ return { styles, lodLevels: formattedLodLevels };
1227
1372
  }
1228
1373
  dataTypeSet.add(dataType);
1229
1374
  let themeStyle;
@@ -1239,7 +1384,7 @@ const getItemTheme = (dataTypeSet, dataTypeField, dataType, itemTheme) => {
1239
1384
  }
1240
1385
  return {
1241
1386
  styles: themeStyle,
1242
- lodStrategy: formattedLodStrategy,
1387
+ lodLevels: formattedLodLevels,
1243
1388
  };
1244
1389
  };
1245
1390
  const filterItemMapByType = (itemMap, type) => {