@antv/g6 5.0.0-beta.2 → 5.0.0-beta.20

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 (608) hide show
  1. package/dist/g6.min.js +2 -2
  2. package/esm/api-doc/graph.d.ts +3 -3
  3. package/esm/api-doc/graph.js +3 -3
  4. package/esm/api-doc/graph.js.map +1 -1
  5. package/esm/api-doc/types.d.ts +1 -0
  6. package/esm/api-doc/types.js +1 -2
  7. package/esm/api-doc/types.js.map +1 -1
  8. package/esm/constant/shape.d.ts +3 -1
  9. package/esm/index.d.ts +24 -63
  10. package/esm/index.js +4 -5
  11. package/esm/index.js.map +1 -1
  12. package/esm/item/combo.d.ts +1 -1
  13. package/esm/item/combo.js +18 -14
  14. package/esm/item/combo.js.map +1 -1
  15. package/esm/item/edge.d.ts +19 -2
  16. package/esm/item/edge.js +100 -44
  17. package/esm/item/edge.js.map +1 -1
  18. package/esm/item/item.d.ts +3 -2
  19. package/esm/item/item.js +27 -13
  20. package/esm/item/item.js.map +1 -1
  21. package/esm/item/node.d.ts +2 -8
  22. package/esm/item/node.js +31 -19
  23. package/esm/item/node.js.map +1 -1
  24. package/esm/runtime/controller/data.d.ts +7 -10
  25. package/esm/runtime/controller/data.js +125 -281
  26. package/esm/runtime/controller/data.js.map +1 -1
  27. package/esm/runtime/controller/interaction.js +9 -4
  28. package/esm/runtime/controller/interaction.js.map +1 -1
  29. package/esm/runtime/controller/item.d.ts +1 -0
  30. package/esm/runtime/controller/item.js +285 -150
  31. package/esm/runtime/controller/item.js.map +1 -1
  32. package/esm/runtime/controller/layout.js +1 -3
  33. package/esm/runtime/controller/layout.js.map +1 -1
  34. package/esm/runtime/controller/plugin.js +9 -5
  35. package/esm/runtime/controller/plugin.js.map +1 -1
  36. package/esm/runtime/graph.d.ts +104 -24
  37. package/esm/runtime/graph.js +472 -94
  38. package/esm/runtime/graph.js.map +1 -1
  39. package/esm/stdlib/behavior/activate-relations.d.ts +1 -1
  40. package/esm/stdlib/behavior/activate-relations.js +2 -2
  41. package/esm/stdlib/behavior/activate-relations.js.map +1 -1
  42. package/esm/stdlib/behavior/brush-select.d.ts +9 -3
  43. package/esm/stdlib/behavior/brush-select.js +10 -12
  44. package/esm/stdlib/behavior/brush-select.js.map +1 -1
  45. package/esm/stdlib/behavior/click-select.d.ts +1 -1
  46. package/esm/stdlib/behavior/click-select.js +1 -1
  47. package/esm/stdlib/behavior/click-select.js.map +1 -1
  48. package/esm/stdlib/behavior/collapse-expand-combo.d.ts +1 -1
  49. package/esm/stdlib/behavior/collapse-expand-tree.d.ts +1 -1
  50. package/esm/stdlib/behavior/create-edge.d.ts +57 -0
  51. package/esm/stdlib/behavior/create-edge.js +215 -0
  52. package/esm/stdlib/behavior/create-edge.js.map +1 -0
  53. package/esm/stdlib/behavior/drag-canvas.d.ts +3 -1
  54. package/esm/stdlib/behavior/drag-canvas.js +78 -33
  55. package/esm/stdlib/behavior/drag-canvas.js.map +1 -1
  56. package/esm/stdlib/behavior/drag-combo.d.ts +3 -3
  57. package/esm/stdlib/behavior/drag-combo.js +43 -32
  58. package/esm/stdlib/behavior/drag-combo.js.map +1 -1
  59. package/esm/stdlib/behavior/drag-node.d.ts +4 -4
  60. package/esm/stdlib/behavior/drag-node.js +80 -63
  61. package/esm/stdlib/behavior/drag-node.js.map +1 -1
  62. package/esm/stdlib/behavior/index.d.ts +3 -0
  63. package/esm/stdlib/behavior/index.js +3 -0
  64. package/esm/stdlib/behavior/index.js.map +1 -1
  65. package/esm/stdlib/behavior/lasso-select.d.ts +1 -1
  66. package/esm/stdlib/behavior/lasso-select.js +3 -4
  67. package/esm/stdlib/behavior/lasso-select.js.map +1 -1
  68. package/esm/stdlib/behavior/scroll-canvas.d.ts +67 -0
  69. package/esm/stdlib/behavior/scroll-canvas.js +266 -0
  70. package/esm/stdlib/behavior/scroll-canvas.js.map +1 -0
  71. package/esm/stdlib/behavior/shortcuts-call.d.ts +38 -0
  72. package/esm/stdlib/behavior/shortcuts-call.js +87 -0
  73. package/esm/stdlib/behavior/shortcuts-call.js.map +1 -0
  74. package/esm/stdlib/behavior/zoom-canvas-3d.js +4 -1
  75. package/esm/stdlib/behavior/zoom-canvas-3d.js.map +1 -1
  76. package/esm/stdlib/behavior/zoom-canvas.d.ts +3 -1
  77. package/esm/stdlib/behavior/zoom-canvas.js +70 -26
  78. package/esm/stdlib/behavior/zoom-canvas.js.map +1 -1
  79. package/esm/stdlib/data/mapNodeSize.d.ts +2 -2
  80. package/esm/stdlib/data/mapNodeSize.js +2 -2
  81. package/esm/stdlib/data/mapNodeSize.js.map +1 -1
  82. package/esm/stdlib/data/transformV4Data.d.ts +2 -2
  83. package/esm/stdlib/data/transformV4Data.js +2 -2
  84. package/esm/stdlib/data/transformV4Data.js.map +1 -1
  85. package/esm/stdlib/data/validateData.d.ts +2 -2
  86. package/esm/stdlib/data/validateData.js +13 -12
  87. package/esm/stdlib/data/validateData.js.map +1 -1
  88. package/esm/stdlib/index.d.ts +18 -6
  89. package/esm/stdlib/index.js +22 -10
  90. package/esm/stdlib/index.js.map +1 -1
  91. package/esm/stdlib/item/edge/base.d.ts +3 -5
  92. package/esm/stdlib/item/edge/base.js +32 -31
  93. package/esm/stdlib/item/edge/base.js.map +1 -1
  94. package/esm/stdlib/item/edge/cubic-horizontal.js.map +1 -1
  95. package/esm/stdlib/item/edge/cubic-vertical.js.map +1 -1
  96. package/esm/stdlib/item/edge/cubic.js +1 -1
  97. package/esm/stdlib/item/edge/cubic.js.map +1 -1
  98. package/esm/stdlib/item/edge/loop.js +1 -1
  99. package/esm/stdlib/item/edge/loop.js.map +1 -1
  100. package/esm/stdlib/item/node/base.d.ts +3 -6
  101. package/esm/stdlib/item/node/base.js +30 -60
  102. package/esm/stdlib/item/node/base.js.map +1 -1
  103. package/esm/stdlib/item/node/base3d.d.ts +1 -0
  104. package/esm/stdlib/item/node/base3d.js +1 -0
  105. package/esm/stdlib/item/node/base3d.js.map +1 -1
  106. package/esm/stdlib/item/node/cube.d.ts +35 -0
  107. package/esm/stdlib/item/node/cube.js +54 -0
  108. package/esm/stdlib/item/node/cube.js.map +1 -0
  109. package/esm/stdlib/item/node/diamond.js +1 -1
  110. package/esm/stdlib/item/node/donut.d.ts +3 -3
  111. package/esm/stdlib/item/node/ellipse.js +2 -2
  112. package/esm/stdlib/item/node/hexagon.js +6 -2
  113. package/esm/stdlib/item/node/hexagon.js.map +1 -1
  114. package/esm/stdlib/item/node/image.d.ts +40 -0
  115. package/esm/stdlib/item/node/image.js +110 -0
  116. package/esm/stdlib/item/node/image.js.map +1 -0
  117. package/esm/stdlib/item/node/index.d.ts +4 -0
  118. package/esm/stdlib/item/node/index.js +4 -0
  119. package/esm/stdlib/item/node/index.js.map +1 -1
  120. package/esm/stdlib/plugin/edgeFilterLens/index.d.ts +66 -0
  121. package/esm/stdlib/plugin/edgeFilterLens/index.js +309 -0
  122. package/esm/stdlib/plugin/edgeFilterLens/index.js.map +1 -0
  123. package/esm/stdlib/plugin/grid/index.d.ts +1 -1
  124. package/esm/stdlib/plugin/grid/index.js +3 -4
  125. package/esm/stdlib/plugin/grid/index.js.map +1 -1
  126. package/esm/stdlib/plugin/history/combo-command.js +2 -2
  127. package/esm/stdlib/plugin/history/combo-command.js.map +1 -1
  128. package/esm/stdlib/plugin/history/index.d.ts +10 -10
  129. package/esm/stdlib/plugin/history/index.js +14 -14
  130. package/esm/stdlib/plugin/history/index.js.map +1 -1
  131. package/esm/stdlib/plugin/history/item-data-command.js +25 -16
  132. package/esm/stdlib/plugin/history/item-data-command.js.map +1 -1
  133. package/esm/stdlib/plugin/history/layer-updated-command.js +2 -2
  134. package/esm/stdlib/plugin/history/layer-updated-command.js.map +1 -1
  135. package/esm/stdlib/plugin/history/state-updated-command.js +1 -1
  136. package/esm/stdlib/plugin/history/state-updated-command.js.map +1 -1
  137. package/esm/stdlib/plugin/history/visibility-updated-command.js +2 -2
  138. package/esm/stdlib/plugin/history/visibility-updated-command.js.map +1 -1
  139. package/esm/stdlib/plugin/hull/convexHull.d.ts +1 -1
  140. package/esm/stdlib/plugin/hull/hullComponent.d.ts +2 -2
  141. package/esm/stdlib/plugin/hull/hullComponent.js +5 -9
  142. package/esm/stdlib/plugin/hull/hullComponent.js.map +1 -1
  143. package/esm/stdlib/plugin/hull/util.d.ts +2 -2
  144. package/esm/stdlib/plugin/hull/util.js +6 -2
  145. package/esm/stdlib/plugin/hull/util.js.map +1 -1
  146. package/esm/stdlib/plugin/index.d.ts +2 -0
  147. package/esm/stdlib/plugin/index.js +2 -0
  148. package/esm/stdlib/plugin/index.js.map +1 -1
  149. package/esm/stdlib/plugin/legend/index.d.ts +3 -3
  150. package/esm/stdlib/plugin/legend/index.js +3 -3
  151. package/esm/stdlib/plugin/legend/index.js.map +1 -1
  152. package/esm/stdlib/plugin/menu/index.d.ts +4 -4
  153. package/esm/stdlib/plugin/menu/index.js +3 -3
  154. package/esm/stdlib/plugin/menu/index.js.map +1 -1
  155. package/esm/stdlib/plugin/minimap/index.d.ts +6 -2
  156. package/esm/stdlib/plugin/minimap/index.js +119 -12
  157. package/esm/stdlib/plugin/minimap/index.js.map +1 -1
  158. package/esm/stdlib/plugin/snapline/index.d.ts +167 -0
  159. package/esm/stdlib/plugin/snapline/index.js +1063 -0
  160. package/esm/stdlib/plugin/snapline/index.js.map +1 -0
  161. package/esm/stdlib/plugin/timebar/index.d.ts +4 -4
  162. package/esm/stdlib/plugin/timebar/index.js +6 -6
  163. package/esm/stdlib/plugin/timebar/index.js.map +1 -1
  164. package/esm/stdlib/plugin/toolbar/index.d.ts +3 -3
  165. package/esm/stdlib/plugin/toolbar/index.js +4 -4
  166. package/esm/stdlib/plugin/toolbar/index.js.map +1 -1
  167. package/esm/stdlib/plugin/tooltip/index.d.ts +5 -5
  168. package/esm/stdlib/plugin/tooltip/index.js +3 -4
  169. package/esm/stdlib/plugin/tooltip/index.js.map +1 -1
  170. package/esm/stdlib/plugin/types.d.ts +2 -0
  171. package/esm/stdlib/plugin/watermaker/index.d.ts +78 -0
  172. package/esm/stdlib/plugin/watermaker/index.js +243 -0
  173. package/esm/stdlib/plugin/watermaker/index.js.map +1 -0
  174. package/esm/stdlib/theme/dark.js +42 -2
  175. package/esm/stdlib/theme/dark.js.map +1 -1
  176. package/esm/stdlib/theme/light.js +4 -4
  177. package/esm/types/animate.d.ts +2 -2
  178. package/esm/types/behavior.d.ts +1 -1
  179. package/esm/types/combo.d.ts +7 -7
  180. package/esm/types/common.d.ts +5 -5
  181. package/esm/types/data.d.ts +6 -6
  182. package/esm/types/edge.d.ts +9 -9
  183. package/esm/types/event.d.ts +2 -1
  184. package/esm/types/graph.d.ts +48 -22
  185. package/esm/types/history.d.ts +2 -2
  186. package/esm/types/hook.d.ts +23 -3
  187. package/esm/types/index.d.ts +2 -1
  188. package/esm/types/index.js +1 -0
  189. package/esm/types/index.js.map +1 -1
  190. package/esm/types/item.d.ts +18 -12
  191. package/esm/types/item.js.map +1 -1
  192. package/esm/types/layout.d.ts +6 -6
  193. package/esm/types/loop.d.ts +2 -2
  194. package/esm/types/node.d.ts +7 -7
  195. package/esm/types/plugin.d.ts +1 -1
  196. package/esm/types/render.d.ts +1 -1
  197. package/esm/types/spec.d.ts +19 -3
  198. package/esm/types/stdlib.d.ts +1 -1
  199. package/esm/types/theme.d.ts +8 -8
  200. package/esm/types/view.d.ts +7 -2
  201. package/esm/util/bbox.d.ts +16 -1
  202. package/esm/util/bbox.js +33 -5
  203. package/esm/util/bbox.js.map +1 -1
  204. package/esm/util/behavior.d.ts +2 -2
  205. package/esm/util/behavior.js +2 -2
  206. package/esm/util/behavior.js.map +1 -1
  207. package/esm/util/data.d.ts +2 -2
  208. package/esm/util/data.js.map +1 -1
  209. package/esm/util/dom.d.ts +15 -0
  210. package/esm/util/dom.js +29 -0
  211. package/esm/util/dom.js.map +1 -0
  212. package/esm/util/event.d.ts +5 -3
  213. package/esm/util/event.js +8 -1
  214. package/esm/util/event.js.map +1 -1
  215. package/esm/util/extend.d.ts +1 -1
  216. package/esm/util/extend.js +0 -1
  217. package/esm/util/extend.js.map +1 -1
  218. package/esm/util/index.d.ts +7 -52
  219. package/esm/util/index.js +7 -23
  220. package/esm/util/index.js.map +1 -1
  221. package/esm/util/item.d.ts +16 -1
  222. package/esm/util/item.js +31 -8
  223. package/esm/util/item.js.map +1 -1
  224. package/esm/util/layout.d.ts +13 -2
  225. package/esm/util/layout.js +45 -0
  226. package/esm/util/layout.js.map +1 -1
  227. package/esm/util/loop.d.ts +1 -1
  228. package/esm/util/loop.js +4 -0
  229. package/esm/util/loop.js.map +1 -1
  230. package/esm/util/math.d.ts +1 -1
  231. package/esm/util/matrix.d.ts +6 -0
  232. package/esm/util/matrix.js +48 -0
  233. package/esm/util/matrix.js.map +1 -0
  234. package/esm/util/path.js +1 -1
  235. package/esm/util/path.js.map +1 -1
  236. package/esm/util/point.d.ts +1 -1
  237. package/esm/util/point.js +9 -2
  238. package/esm/util/point.js.map +1 -1
  239. package/esm/util/polyline.d.ts +2 -1
  240. package/esm/util/polyline.js +2 -1
  241. package/esm/util/polyline.js.map +1 -1
  242. package/esm/util/router.d.ts +1 -1
  243. package/esm/util/shape.d.ts +1 -2
  244. package/esm/util/shape.js +15 -25
  245. package/esm/util/shape.js.map +1 -1
  246. package/esm/util/shape3d.js +16 -17
  247. package/esm/util/shape3d.js.map +1 -1
  248. package/esm/util/text.d.ts +1 -1
  249. package/esm/util/text.js +3 -2
  250. package/esm/util/text.js.map +1 -1
  251. package/esm/util/warn.d.ts +14 -0
  252. package/esm/util/warn.js +4 -0
  253. package/esm/util/warn.js.map +1 -0
  254. package/lib/api-doc/graph.d.ts +3 -3
  255. package/lib/api-doc/graph.js +27 -7
  256. package/lib/api-doc/graph.js.map +1 -1
  257. package/lib/api-doc/types.d.ts +1 -0
  258. package/lib/api-doc/types.js +2 -2
  259. package/lib/api-doc/types.js.map +1 -1
  260. package/lib/constant/shape.d.ts +3 -1
  261. package/lib/index.d.ts +24 -63
  262. package/lib/index.js +18 -10
  263. package/lib/index.js.map +1 -1
  264. package/lib/item/combo.d.ts +1 -1
  265. package/lib/item/combo.js +18 -14
  266. package/lib/item/combo.js.map +1 -1
  267. package/lib/item/edge.d.ts +19 -2
  268. package/lib/item/edge.js +99 -43
  269. package/lib/item/edge.js.map +1 -1
  270. package/lib/item/item.d.ts +3 -2
  271. package/lib/item/item.js +27 -13
  272. package/lib/item/item.js.map +1 -1
  273. package/lib/item/node.d.ts +2 -8
  274. package/lib/item/node.js +31 -19
  275. package/lib/item/node.js.map +1 -1
  276. package/lib/runtime/controller/data.d.ts +7 -10
  277. package/lib/runtime/controller/data.js +125 -281
  278. package/lib/runtime/controller/data.js.map +1 -1
  279. package/lib/runtime/controller/interaction.js +9 -4
  280. package/lib/runtime/controller/interaction.js.map +1 -1
  281. package/lib/runtime/controller/item.d.ts +1 -0
  282. package/lib/runtime/controller/item.js +284 -149
  283. package/lib/runtime/controller/item.js.map +1 -1
  284. package/lib/runtime/controller/layout.js +1 -3
  285. package/lib/runtime/controller/layout.js.map +1 -1
  286. package/lib/runtime/controller/plugin.js +9 -5
  287. package/lib/runtime/controller/plugin.js.map +1 -1
  288. package/lib/runtime/graph.d.ts +104 -24
  289. package/lib/runtime/graph.js +473 -94
  290. package/lib/runtime/graph.js.map +1 -1
  291. package/lib/stdlib/behavior/activate-relations.d.ts +1 -1
  292. package/lib/stdlib/behavior/activate-relations.js +2 -2
  293. package/lib/stdlib/behavior/activate-relations.js.map +1 -1
  294. package/lib/stdlib/behavior/brush-select.d.ts +9 -3
  295. package/lib/stdlib/behavior/brush-select.js +13 -12
  296. package/lib/stdlib/behavior/brush-select.js.map +1 -1
  297. package/lib/stdlib/behavior/click-select.d.ts +1 -1
  298. package/lib/stdlib/behavior/click-select.js +1 -1
  299. package/lib/stdlib/behavior/click-select.js.map +1 -1
  300. package/lib/stdlib/behavior/collapse-expand-combo.d.ts +1 -1
  301. package/lib/stdlib/behavior/collapse-expand-tree.d.ts +1 -1
  302. package/lib/stdlib/behavior/create-edge.d.ts +57 -0
  303. package/lib/stdlib/behavior/create-edge.js +219 -0
  304. package/lib/stdlib/behavior/create-edge.js.map +1 -0
  305. package/lib/stdlib/behavior/drag-canvas.d.ts +3 -1
  306. package/lib/stdlib/behavior/drag-canvas.js +78 -33
  307. package/lib/stdlib/behavior/drag-canvas.js.map +1 -1
  308. package/lib/stdlib/behavior/drag-combo.d.ts +3 -3
  309. package/lib/stdlib/behavior/drag-combo.js +43 -32
  310. package/lib/stdlib/behavior/drag-combo.js.map +1 -1
  311. package/lib/stdlib/behavior/drag-node.d.ts +4 -4
  312. package/lib/stdlib/behavior/drag-node.js +80 -63
  313. package/lib/stdlib/behavior/drag-node.js.map +1 -1
  314. package/lib/stdlib/behavior/index.d.ts +3 -0
  315. package/lib/stdlib/behavior/index.js +3 -0
  316. package/lib/stdlib/behavior/index.js.map +1 -1
  317. package/lib/stdlib/behavior/lasso-select.d.ts +1 -1
  318. package/lib/stdlib/behavior/lasso-select.js +6 -4
  319. package/lib/stdlib/behavior/lasso-select.js.map +1 -1
  320. package/lib/stdlib/behavior/scroll-canvas.d.ts +67 -0
  321. package/lib/stdlib/behavior/scroll-canvas.js +270 -0
  322. package/lib/stdlib/behavior/scroll-canvas.js.map +1 -0
  323. package/lib/stdlib/behavior/shortcuts-call.d.ts +38 -0
  324. package/lib/stdlib/behavior/shortcuts-call.js +91 -0
  325. package/lib/stdlib/behavior/shortcuts-call.js.map +1 -0
  326. package/lib/stdlib/behavior/zoom-canvas-3d.js +4 -1
  327. package/lib/stdlib/behavior/zoom-canvas-3d.js.map +1 -1
  328. package/lib/stdlib/behavior/zoom-canvas.d.ts +3 -1
  329. package/lib/stdlib/behavior/zoom-canvas.js +70 -26
  330. package/lib/stdlib/behavior/zoom-canvas.js.map +1 -1
  331. package/lib/stdlib/data/mapNodeSize.d.ts +2 -2
  332. package/lib/stdlib/data/mapNodeSize.js +2 -2
  333. package/lib/stdlib/data/mapNodeSize.js.map +1 -1
  334. package/lib/stdlib/data/transformV4Data.d.ts +2 -2
  335. package/lib/stdlib/data/transformV4Data.js +2 -2
  336. package/lib/stdlib/data/transformV4Data.js.map +1 -1
  337. package/lib/stdlib/data/validateData.d.ts +2 -2
  338. package/lib/stdlib/data/validateData.js +13 -12
  339. package/lib/stdlib/data/validateData.js.map +1 -1
  340. package/lib/stdlib/index.d.ts +18 -6
  341. package/lib/stdlib/index.js +22 -10
  342. package/lib/stdlib/index.js.map +1 -1
  343. package/lib/stdlib/item/edge/base.d.ts +3 -5
  344. package/lib/stdlib/item/edge/base.js +30 -29
  345. package/lib/stdlib/item/edge/base.js.map +1 -1
  346. package/lib/stdlib/item/edge/cubic-horizontal.js.map +1 -1
  347. package/lib/stdlib/item/edge/cubic-vertical.js.map +1 -1
  348. package/lib/stdlib/item/edge/cubic.js +2 -2
  349. package/lib/stdlib/item/edge/cubic.js.map +1 -1
  350. package/lib/stdlib/item/edge/loop.js +3 -3
  351. package/lib/stdlib/item/edge/loop.js.map +1 -1
  352. package/lib/stdlib/item/node/base.d.ts +3 -6
  353. package/lib/stdlib/item/node/base.js +29 -59
  354. package/lib/stdlib/item/node/base.js.map +1 -1
  355. package/lib/stdlib/item/node/base3d.d.ts +1 -0
  356. package/lib/stdlib/item/node/base3d.js +1 -0
  357. package/lib/stdlib/item/node/base3d.js.map +1 -1
  358. package/lib/stdlib/item/node/cube.d.ts +35 -0
  359. package/lib/stdlib/item/node/cube.js +58 -0
  360. package/lib/stdlib/item/node/cube.js.map +1 -0
  361. package/lib/stdlib/item/node/diamond.js +1 -1
  362. package/lib/stdlib/item/node/donut.d.ts +3 -3
  363. package/lib/stdlib/item/node/ellipse.js +2 -2
  364. package/lib/stdlib/item/node/hexagon.js +6 -2
  365. package/lib/stdlib/item/node/hexagon.js.map +1 -1
  366. package/lib/stdlib/item/node/image.d.ts +40 -0
  367. package/lib/stdlib/item/node/image.js +114 -0
  368. package/lib/stdlib/item/node/image.js.map +1 -0
  369. package/lib/stdlib/item/node/index.d.ts +4 -0
  370. package/lib/stdlib/item/node/index.js +4 -0
  371. package/lib/stdlib/item/node/index.js.map +1 -1
  372. package/lib/stdlib/plugin/edgeFilterLens/index.d.ts +66 -0
  373. package/lib/stdlib/plugin/edgeFilterLens/index.js +313 -0
  374. package/lib/stdlib/plugin/edgeFilterLens/index.js.map +1 -0
  375. package/lib/stdlib/plugin/grid/index.d.ts +1 -1
  376. package/lib/stdlib/plugin/grid/index.js +6 -7
  377. package/lib/stdlib/plugin/grid/index.js.map +1 -1
  378. package/lib/stdlib/plugin/history/combo-command.js +2 -2
  379. package/lib/stdlib/plugin/history/combo-command.js.map +1 -1
  380. package/lib/stdlib/plugin/history/index.d.ts +10 -10
  381. package/lib/stdlib/plugin/history/index.js +14 -14
  382. package/lib/stdlib/plugin/history/index.js.map +1 -1
  383. package/lib/stdlib/plugin/history/item-data-command.js +25 -16
  384. package/lib/stdlib/plugin/history/item-data-command.js.map +1 -1
  385. package/lib/stdlib/plugin/history/layer-updated-command.js +2 -2
  386. package/lib/stdlib/plugin/history/layer-updated-command.js.map +1 -1
  387. package/lib/stdlib/plugin/history/state-updated-command.js +1 -1
  388. package/lib/stdlib/plugin/history/state-updated-command.js.map +1 -1
  389. package/lib/stdlib/plugin/history/visibility-updated-command.js +2 -2
  390. package/lib/stdlib/plugin/history/visibility-updated-command.js.map +1 -1
  391. package/lib/stdlib/plugin/hull/convexHull.d.ts +1 -1
  392. package/lib/stdlib/plugin/hull/hullComponent.d.ts +2 -2
  393. package/lib/stdlib/plugin/hull/hullComponent.js +5 -9
  394. package/lib/stdlib/plugin/hull/hullComponent.js.map +1 -1
  395. package/lib/stdlib/plugin/hull/util.d.ts +2 -2
  396. package/lib/stdlib/plugin/hull/util.js +26 -22
  397. package/lib/stdlib/plugin/hull/util.js.map +1 -1
  398. package/lib/stdlib/plugin/index.d.ts +2 -0
  399. package/lib/stdlib/plugin/index.js +2 -0
  400. package/lib/stdlib/plugin/index.js.map +1 -1
  401. package/lib/stdlib/plugin/legend/index.d.ts +3 -3
  402. package/lib/stdlib/plugin/legend/index.js +3 -3
  403. package/lib/stdlib/plugin/legend/index.js.map +1 -1
  404. package/lib/stdlib/plugin/menu/index.d.ts +4 -4
  405. package/lib/stdlib/plugin/menu/index.js +6 -6
  406. package/lib/stdlib/plugin/menu/index.js.map +1 -1
  407. package/lib/stdlib/plugin/minimap/index.d.ts +6 -2
  408. package/lib/stdlib/plugin/minimap/index.js +121 -14
  409. package/lib/stdlib/plugin/minimap/index.js.map +1 -1
  410. package/lib/stdlib/plugin/snapline/index.d.ts +167 -0
  411. package/lib/stdlib/plugin/snapline/index.js +1067 -0
  412. package/lib/stdlib/plugin/snapline/index.js.map +1 -0
  413. package/lib/stdlib/plugin/timebar/index.d.ts +4 -4
  414. package/lib/stdlib/plugin/timebar/index.js +6 -6
  415. package/lib/stdlib/plugin/timebar/index.js.map +1 -1
  416. package/lib/stdlib/plugin/toolbar/index.d.ts +3 -3
  417. package/lib/stdlib/plugin/toolbar/index.js +5 -5
  418. package/lib/stdlib/plugin/toolbar/index.js.map +1 -1
  419. package/lib/stdlib/plugin/tooltip/index.d.ts +5 -5
  420. package/lib/stdlib/plugin/tooltip/index.js +10 -11
  421. package/lib/stdlib/plugin/tooltip/index.js.map +1 -1
  422. package/lib/stdlib/plugin/types.d.ts +2 -0
  423. package/lib/stdlib/plugin/watermaker/index.d.ts +78 -0
  424. package/lib/stdlib/plugin/watermaker/index.js +247 -0
  425. package/lib/stdlib/plugin/watermaker/index.js.map +1 -0
  426. package/lib/stdlib/theme/dark.js +42 -2
  427. package/lib/stdlib/theme/dark.js.map +1 -1
  428. package/lib/stdlib/theme/light.js +4 -4
  429. package/lib/types/animate.d.ts +2 -2
  430. package/lib/types/behavior.d.ts +1 -1
  431. package/lib/types/combo.d.ts +7 -7
  432. package/lib/types/common.d.ts +5 -5
  433. package/lib/types/data.d.ts +6 -6
  434. package/lib/types/edge.d.ts +9 -9
  435. package/lib/types/event.d.ts +2 -1
  436. package/lib/types/event.js +2 -2
  437. package/lib/types/event.js.map +1 -1
  438. package/lib/types/graph.d.ts +48 -22
  439. package/lib/types/history.d.ts +2 -2
  440. package/lib/types/history.js +1 -1
  441. package/lib/types/history.js.map +1 -1
  442. package/lib/types/hook.d.ts +23 -3
  443. package/lib/types/index.d.ts +2 -1
  444. package/lib/types/index.js +3 -1
  445. package/lib/types/index.js.map +1 -1
  446. package/lib/types/item.d.ts +18 -12
  447. package/lib/types/item.js +1 -1
  448. package/lib/types/item.js.map +1 -1
  449. package/lib/types/layout.d.ts +6 -6
  450. package/lib/types/loop.d.ts +2 -2
  451. package/lib/types/loop.js +1 -1
  452. package/lib/types/loop.js.map +1 -1
  453. package/lib/types/node.d.ts +7 -7
  454. package/lib/types/plugin.d.ts +1 -1
  455. package/lib/types/render.d.ts +1 -1
  456. package/lib/types/spec.d.ts +19 -3
  457. package/lib/types/stdlib.d.ts +1 -1
  458. package/lib/types/theme.d.ts +8 -8
  459. package/lib/types/view.d.ts +7 -2
  460. package/lib/util/bbox.d.ts +16 -1
  461. package/lib/util/bbox.js +36 -6
  462. package/lib/util/bbox.js.map +1 -1
  463. package/lib/util/behavior.d.ts +2 -2
  464. package/lib/util/behavior.js +2 -2
  465. package/lib/util/behavior.js.map +1 -1
  466. package/lib/util/data.d.ts +2 -2
  467. package/lib/util/data.js.map +1 -1
  468. package/lib/util/dom.d.ts +15 -0
  469. package/lib/util/dom.js +34 -0
  470. package/lib/util/dom.js.map +1 -0
  471. package/lib/util/event.d.ts +5 -3
  472. package/lib/util/event.js +8 -1
  473. package/lib/util/event.js.map +1 -1
  474. package/lib/util/extend.d.ts +1 -1
  475. package/lib/util/extend.js +0 -1
  476. package/lib/util/extend.js.map +1 -1
  477. package/lib/util/index.d.ts +7 -52
  478. package/lib/util/index.js +23 -23
  479. package/lib/util/index.js.map +1 -1
  480. package/lib/util/item.d.ts +16 -1
  481. package/lib/util/item.js +33 -9
  482. package/lib/util/item.js.map +1 -1
  483. package/lib/util/layout.d.ts +13 -2
  484. package/lib/util/layout.js +47 -1
  485. package/lib/util/layout.js.map +1 -1
  486. package/lib/util/loop.d.ts +1 -1
  487. package/lib/util/loop.js +4 -0
  488. package/lib/util/loop.js.map +1 -1
  489. package/lib/util/math.d.ts +1 -1
  490. package/lib/util/matrix.d.ts +6 -0
  491. package/lib/util/matrix.js +52 -0
  492. package/lib/util/matrix.js.map +1 -0
  493. package/lib/util/path.js +2 -2
  494. package/lib/util/path.js.map +1 -1
  495. package/lib/util/point.d.ts +1 -1
  496. package/lib/util/point.js +9 -2
  497. package/lib/util/point.js.map +1 -1
  498. package/lib/util/polyline.d.ts +2 -1
  499. package/lib/util/polyline.js +2 -1
  500. package/lib/util/polyline.js.map +1 -1
  501. package/lib/util/router.d.ts +1 -1
  502. package/lib/util/shape.d.ts +1 -2
  503. package/lib/util/shape.js +16 -26
  504. package/lib/util/shape.js.map +1 -1
  505. package/lib/util/shape3d.js +15 -16
  506. package/lib/util/shape3d.js.map +1 -1
  507. package/lib/util/text.d.ts +1 -1
  508. package/lib/util/text.js +3 -2
  509. package/lib/util/text.js.map +1 -1
  510. package/lib/util/warn.d.ts +14 -0
  511. package/lib/util/warn.js +8 -0
  512. package/lib/util/warn.js.map +1 -0
  513. package/package.json +41 -50
  514. package/src/api-doc/graph.ts +4 -3
  515. package/src/api-doc/types.ts +1 -0
  516. package/src/constant/shape.ts +1 -1
  517. package/src/index.ts +5 -6
  518. package/src/item/combo.ts +16 -15
  519. package/src/item/edge.ts +135 -57
  520. package/src/item/item.ts +32 -19
  521. package/src/item/node.ts +36 -50
  522. package/src/runtime/controller/data.ts +140 -339
  523. package/src/runtime/controller/interaction.ts +10 -4
  524. package/src/runtime/controller/item.ts +261 -78
  525. package/src/runtime/controller/layout.ts +1 -5
  526. package/src/runtime/controller/plugin.ts +15 -4
  527. package/src/runtime/graph.ts +605 -103
  528. package/src/stdlib/behavior/activate-relations.ts +2 -2
  529. package/src/stdlib/behavior/brush-select.ts +14 -13
  530. package/src/stdlib/behavior/click-select.ts +1 -1
  531. package/src/stdlib/behavior/create-edge.ts +305 -0
  532. package/src/stdlib/behavior/drag-canvas.ts +107 -35
  533. package/src/stdlib/behavior/drag-combo.ts +10 -10
  534. package/src/stdlib/behavior/drag-node.ts +27 -18
  535. package/src/stdlib/behavior/index.ts +3 -0
  536. package/src/stdlib/behavior/lasso-select.ts +7 -5
  537. package/src/stdlib/behavior/scroll-canvas.ts +348 -0
  538. package/src/stdlib/behavior/shortcuts-call.ts +129 -0
  539. package/src/stdlib/behavior/zoom-canvas-3d.ts +4 -1
  540. package/src/stdlib/behavior/zoom-canvas.ts +98 -27
  541. package/src/stdlib/data/mapNodeSize.ts +2 -2
  542. package/src/stdlib/data/transformV4Data.ts +2 -2
  543. package/src/stdlib/data/validateData.ts +16 -16
  544. package/src/stdlib/index.ts +28 -7
  545. package/src/stdlib/item/edge/base.ts +32 -41
  546. package/src/stdlib/item/edge/cubic-horizontal.ts +0 -1
  547. package/src/stdlib/item/edge/cubic-vertical.ts +0 -1
  548. package/src/stdlib/item/edge/cubic.ts +1 -1
  549. package/src/stdlib/item/edge/loop.ts +1 -1
  550. package/src/stdlib/item/node/base.ts +38 -65
  551. package/src/stdlib/item/node/base3d.ts +1 -0
  552. package/src/stdlib/item/node/cube.ts +102 -0
  553. package/src/stdlib/item/node/diamond.ts +1 -1
  554. package/src/stdlib/item/node/ellipse.ts +2 -2
  555. package/src/stdlib/item/node/hexagon.ts +6 -2
  556. package/src/stdlib/item/node/image.ts +190 -0
  557. package/src/stdlib/item/node/index.ts +4 -0
  558. package/src/stdlib/plugin/edgeFilterLens/index.ts +387 -0
  559. package/src/stdlib/plugin/grid/index.ts +6 -6
  560. package/src/stdlib/plugin/history/combo-command.ts +2 -2
  561. package/src/stdlib/plugin/history/index.ts +14 -14
  562. package/src/stdlib/plugin/history/item-data-command.ts +35 -17
  563. package/src/stdlib/plugin/history/layer-updated-command.ts +2 -2
  564. package/src/stdlib/plugin/history/state-updated-command.ts +1 -1
  565. package/src/stdlib/plugin/history/visibility-updated-command.ts +2 -2
  566. package/src/stdlib/plugin/hull/convexHull.ts +1 -1
  567. package/src/stdlib/plugin/hull/hullComponent.ts +10 -8
  568. package/src/stdlib/plugin/hull/util.ts +6 -2
  569. package/src/stdlib/plugin/index.ts +2 -0
  570. package/src/stdlib/plugin/legend/index.ts +6 -6
  571. package/src/stdlib/plugin/menu/index.ts +13 -13
  572. package/src/stdlib/plugin/minimap/index.ts +126 -16
  573. package/src/stdlib/plugin/snapline/index.ts +1297 -0
  574. package/src/stdlib/plugin/timebar/index.ts +4 -4
  575. package/src/stdlib/plugin/toolbar/index.ts +8 -8
  576. package/src/stdlib/plugin/tooltip/index.ts +10 -10
  577. package/src/stdlib/plugin/types.ts +2 -0
  578. package/src/stdlib/plugin/watermaker/index.ts +302 -0
  579. package/src/stdlib/theme/dark.ts +66 -2
  580. package/src/stdlib/theme/light.ts +4 -4
  581. package/src/types/event.ts +1 -0
  582. package/src/types/graph.ts +62 -25
  583. package/src/types/hook.ts +22 -2
  584. package/src/types/index.ts +2 -1
  585. package/src/types/item.ts +10 -0
  586. package/src/types/plugin.ts +1 -1
  587. package/src/types/spec.ts +22 -3
  588. package/src/types/view.ts +8 -3
  589. package/src/util/bbox.ts +42 -6
  590. package/src/util/behavior.ts +4 -4
  591. package/src/util/data.ts +2 -3
  592. package/src/util/dom.ts +33 -0
  593. package/src/util/event.ts +14 -1
  594. package/src/util/extend.ts +2 -3
  595. package/src/util/index.ts +7 -24
  596. package/src/util/item.ts +65 -28
  597. package/src/util/layout.ts +48 -2
  598. package/src/util/loop.ts +5 -1
  599. package/src/util/math.ts +1 -1
  600. package/src/util/matrix.ts +66 -0
  601. package/src/util/path.ts +1 -1
  602. package/src/util/point.ts +9 -4
  603. package/src/util/polyline.ts +2 -1
  604. package/src/util/router.ts +1 -1
  605. package/src/util/shape.ts +22 -26
  606. package/src/util/shape3d.ts +20 -20
  607. package/src/util/text.ts +3 -1
  608. package/src/util/warn.ts +20 -0
@@ -297,13 +297,17 @@ export class InteractionController {
297
297
  } as FederatedPointerEvent);
298
298
  }
299
299
 
300
+ const isRightClick = event.type === 'click' && event.button === 2;
301
+
300
302
  // Canvas Events
301
303
  if (event.itemType === 'canvas') {
302
304
  if (event.type === 'pointermove') {
303
305
  this.handlePointerMove(event);
304
306
  }
305
- this.graph.emit(`canvas:${gEvent.type}`, event);
306
- this.graph.emit(`${gEvent.type}`, event);
307
+ if (!isRightClick) {
308
+ this.graph.emit(`canvas:${gEvent.type}`, event);
309
+ this.graph.emit(`${gEvent.type}`, event);
310
+ }
307
311
 
308
312
  // contextmenu event for canvas
309
313
  if (event.type === 'pointerdown' && event.button === 2) {
@@ -320,8 +324,10 @@ export class InteractionController {
320
324
  if (event.type === 'pointermove' || event.type === 'pointerleave') {
321
325
  this.handlePointerMove(event);
322
326
  }
323
- this.graph.emit(`${itemType}:${gEvent.type}`, event);
324
- this.graph.emit(`${gEvent.type}`, event);
327
+ if (!isRightClick) {
328
+ this.graph.emit(`${itemType}:${gEvent.type}`, event);
329
+ this.graph.emit(`${gEvent.type}`, event);
330
+ }
325
331
 
326
332
  // contextmenu event for node, edge, or combo
327
333
  if (event.type === 'pointerdown' && event.button === 2) {
@@ -4,6 +4,7 @@ import {
4
4
  debounce,
5
5
  each,
6
6
  isArray,
7
+ isNumber,
7
8
  isObject,
8
9
  map,
9
10
  throttle,
@@ -64,6 +65,8 @@ import { getGroupedChanges } from '../../util/event';
64
65
  import { BaseNode } from '../../stdlib/item/node/base';
65
66
  import { BaseEdge } from '../../stdlib/item/edge/base';
66
67
  import { EdgeCollisionChecker, QuadTree } from '../../util/polyline';
68
+ import { isBBoxInBBox, isPointInBBox } from '../../util/bbox';
69
+ import { convertToNumber } from '../../util/type';
67
70
 
68
71
  /**
69
72
  * Manages and stores the node / edge / combo items.
@@ -174,6 +177,7 @@ export class ItemController {
174
177
  this.graph.hooks.transientupdate.tap(this.onTransientUpdate.bind(this));
175
178
  this.graph.hooks.viewportchange.tap(this.onViewportChange.bind(this));
176
179
  this.graph.hooks.themechange.tap(this.onThemeChange.bind(this));
180
+ this.graph.hooks.mapperchange.tap(this.onMapperChange.bind(this));
177
181
  this.graph.hooks.treecollapseexpand.tap(
178
182
  this.onTreeCollapseExpand.bind(this),
179
183
  );
@@ -207,19 +211,23 @@ export class ItemController {
207
211
  * Listener of runtime's render hook.
208
212
  * @param param contains inner data stored in graphCore structure
209
213
  */
210
- private onRender(param: {
214
+ private async onRender(param: {
211
215
  graphCore: GraphCore;
212
216
  theme: ThemeSpecification;
213
217
  transientCanvas: Canvas;
218
+ tileOptimize?: {
219
+ tileFirstRender?: boolean | number;
220
+ tileFirstRenderSize?: number;
221
+ };
214
222
  }) {
215
- const { graphCore, theme = {}, transientCanvas } = param;
223
+ const { graphCore, theme = {}, transientCanvas, tileOptimize = {} } = param;
216
224
  const { graph } = this;
217
225
 
218
226
  // 0. clear groups on canvas, and create new groups
219
227
  graph.canvas.removeChildren();
220
- const comboGroup = new Group({ id: 'combo-group' });
221
- const edgeGroup = new Group({ id: 'edge-group' });
222
- const nodeGroup = new Group({ id: 'node-group' });
228
+ const comboGroup = new Group({ id: 'combo-group', style: { zIndex: 0 } });
229
+ const edgeGroup = new Group({ id: 'edge-group', style: { zIndex: 1 } });
230
+ const nodeGroup = new Group({ id: 'node-group', style: { zIndex: 2 } });
223
231
  graph.canvas.appendChild(comboGroup);
224
232
  graph.canvas.appendChild(edgeGroup);
225
233
  graph.canvas.appendChild(nodeGroup);
@@ -229,9 +237,18 @@ export class ItemController {
229
237
 
230
238
  // Also create transient groups on transient canvas.
231
239
  transientCanvas.removeChildren();
232
- this.transientComboGroup = new Group({ id: 'combo-group' });
233
- this.transientEdgeGroup = new Group({ id: 'edge-group' });
234
- this.transientNodeGroup = new Group({ id: 'node-group' });
240
+ this.transientComboGroup = new Group({
241
+ id: 'combo-group',
242
+ style: { zIndex: 0 },
243
+ });
244
+ this.transientEdgeGroup = new Group({
245
+ id: 'edge-group',
246
+ style: { zIndex: 1 },
247
+ });
248
+ this.transientNodeGroup = new Group({
249
+ id: 'node-group',
250
+ style: { zIndex: 2 },
251
+ });
235
252
  transientCanvas.appendChild(this.transientComboGroup);
236
253
  transientCanvas.appendChild(this.transientEdgeGroup);
237
254
  transientCanvas.appendChild(this.transientNodeGroup);
@@ -265,9 +282,25 @@ export class ItemController {
265
282
  edges: graphCore.getAllEdges(),
266
283
  });
267
284
 
268
- this.renderNodes(nodes, theme.node);
285
+ const renderNodesPromise = this.renderNodes(
286
+ nodes,
287
+ theme.node,
288
+ tileOptimize,
289
+ );
290
+ let nodesInView;
291
+ if (renderNodesPromise) {
292
+ nodesInView = await renderNodesPromise;
293
+ }
269
294
  this.renderCombos(combos, theme.combo, graphCore);
270
- this.renderEdges(edges, theme.edge);
295
+ const renderEdgesPromise = this.renderEdges(
296
+ edges,
297
+ theme.edge,
298
+ tileOptimize,
299
+ nodesInView,
300
+ );
301
+ if (renderEdgesPromise) {
302
+ await renderEdgesPromise;
303
+ }
271
304
  this.sortByComboTree(graphCore);
272
305
  // collapse the combos which has 'collapsed' in initial data
273
306
  if (graphCore.hasTreeStructure('combo')) {
@@ -415,14 +448,12 @@ export class ItemController {
415
448
  if (!item || item.destroyed) return;
416
449
  const type = item.getType();
417
450
  const innerModel = graphCore.getNode(id);
418
- if (
419
- onlyMove &&
420
- type === 'node' &&
421
- isNaN(current.x) &&
422
- isNaN(current.y)
423
- ) {
424
- callback(innerModel, true);
425
- return;
451
+ if (type === 'node' && onlyMove) {
452
+ const { x, y, fx, fy } = current;
453
+ if (isNaN(x) && isNaN(y) && isNaN(fx) && isNaN(fy)) {
454
+ callback(innerModel, true);
455
+ return;
456
+ }
426
457
  }
427
458
 
428
459
  const nodeRelatedIdsToUpdate: Set<ID> = new Set<ID>();
@@ -533,7 +564,7 @@ export class ItemController {
533
564
  },
534
565
  500,
535
566
  {
536
- leading: false,
567
+ leading: true,
537
568
  trailing: true,
538
569
  },
539
570
  ),
@@ -541,7 +572,7 @@ export class ItemController {
541
572
 
542
573
  const parentItem = this.itemMap.get(current.parentId);
543
574
  if (current.parentId && parentItem?.model.data.collapsed) {
544
- this.graph.executeWithoutStacking(() => {
575
+ this.graph.executeWithNoStack(() => {
545
576
  this.graph.hideItem(innerModel.id, false);
546
577
  });
547
578
  }
@@ -669,8 +700,15 @@ export class ItemController {
669
700
  value: boolean;
670
701
  graphCore: GraphCore;
671
702
  animate?: boolean;
703
+ keepKeyShape?: boolean;
672
704
  }) {
673
- const { ids, value, graphCore, animate = true } = param;
705
+ const {
706
+ ids,
707
+ value,
708
+ graphCore,
709
+ animate = true,
710
+ keepKeyShape = false,
711
+ } = param;
674
712
  ids.forEach((id) => {
675
713
  const item = this.itemMap.get(id);
676
714
  if (!item) {
@@ -700,7 +738,7 @@ export class ItemController {
700
738
  });
701
739
  }
702
740
  } else {
703
- item.hide(animate);
741
+ item.hide(animate, keepKeyShape);
704
742
  if (type !== 'edge') {
705
743
  const relatedEdges = graphCore.getRelatedEdges(id);
706
744
  relatedEdges.forEach(({ id: edgeId }) => {
@@ -747,11 +785,42 @@ export class ItemController {
747
785
  }
748
786
 
749
787
  private onViewportChange = debounce(
750
- ({ transform, effectTiming }: ViewportChangeHookParams) => {
788
+ ({
789
+ transform,
790
+ effectTiming,
791
+ tileLodSize = 1000,
792
+ }: ViewportChangeHookParams) => {
751
793
  const { zoom } = transform;
752
794
  if (zoom) {
753
795
  const zoomRatio = this.graph.getZoom();
754
- this.itemMap.forEach((item) => item.updateZoom(zoomRatio));
796
+ const range = this.graph.getCanvasRange();
797
+ const nodeItems = Array.from(this.itemMap, ([key, value]) => value);
798
+ const itemsInViewport = [];
799
+ const itemsOutViewport = [];
800
+ nodeItems.forEach((item) => {
801
+ const { keyShape } = item.shapeMap;
802
+ if (!keyShape) return;
803
+ const renderBounds = keyShape.getRenderBounds();
804
+ if (isBBoxInBBox(renderBounds, range, 0.4))
805
+ itemsInViewport.push(item);
806
+ else itemsOutViewport.push(item);
807
+ });
808
+ const sortedItems = itemsInViewport.concat(itemsOutViewport);
809
+ const sections = Math.ceil(nodeItems.length / tileLodSize);
810
+ const itemSections = Array.from({ length: sections }, (v, i) =>
811
+ sortedItems.slice(i * tileLodSize, i * tileLodSize + tileLodSize),
812
+ );
813
+ let requestId;
814
+ const update = () => {
815
+ if (!itemSections.length) {
816
+ cancelAnimationFrame(requestId);
817
+ return;
818
+ }
819
+ itemSections.shift().forEach((item) => item.updateZoom(zoomRatio));
820
+ requestId = requestAnimationFrame(update);
821
+ };
822
+ requestId = requestAnimationFrame(update);
823
+ // this.itemMap.forEach((item) => item.updateZoom(zoomRatio));
755
824
  this.zoom = zoomRatio;
756
825
  }
757
826
  },
@@ -789,6 +858,16 @@ export class ItemController {
789
858
  });
790
859
  };
791
860
 
861
+ private onMapperChange = ({ type, mapper }) => {
862
+ if (!mapper) return;
863
+ this.itemMap.forEach((item) => {
864
+ const itemTye = item.getType();
865
+ if (itemTye !== type) return;
866
+ item.mapper = mapper;
867
+ item.update(item.model, undefined, false);
868
+ });
869
+ };
870
+
792
871
  private onDestroy = () => {
793
872
  Object.values(this.itemMap).forEach((item) => item.destroy());
794
873
  // Fix OOM problem, since this map will hold all the refs of items.
@@ -799,12 +878,17 @@ export class ItemController {
799
878
  type: ITEM_TYPE | SHAPE_TYPE;
800
879
  id: ID;
801
880
  config: {
881
+ action: 'remove' | 'add' | 'update' | undefined;
802
882
  style?: ShapeStyle;
803
- // Data to be merged into the transient item.
883
+ /** Data to be merged into the transient item. */
804
884
  data?: Record<string, any>;
805
- action: 'remove' | 'add' | 'update' | undefined;
806
- onlyDrawKeyShape?: boolean;
885
+ shapeIds?: string[];
886
+ /** For type: 'edge' */
887
+ drawSource?: boolean;
888
+ /** For type: 'edge' */
889
+ drawTarget?: boolean;
807
890
  upsertAncestors?: boolean;
891
+ visible?: boolean;
808
892
  [shapeConfig: string]: unknown;
809
893
  };
810
894
  canvas: Canvas;
@@ -817,8 +901,11 @@ export class ItemController {
817
901
  data = {},
818
902
  capture,
819
903
  action,
820
- onlyDrawKeyShape,
904
+ shapeIds,
905
+ drawSource,
906
+ drawTarget,
821
907
  upsertAncestors,
908
+ visible = true,
822
909
  } = config as any;
823
910
  const isItemType = type === 'node' || type === 'edge' || type === 'combo';
824
911
  // Removing
@@ -841,6 +928,9 @@ export class ItemController {
841
928
  );
842
929
  }
843
930
  if (transientItem && !transientItem.destroyed) {
931
+ if (!(transientItem as Node | Edge | Combo).getType?.()) {
932
+ (transientItem as Group).remove();
933
+ }
844
934
  transientItem.destroy();
845
935
  }
846
936
  this.transientItemMap.delete(id);
@@ -869,11 +959,11 @@ export class ItemController {
869
959
  this.transientItemMap,
870
960
  this.itemMap,
871
961
  graphCore,
872
- onlyDrawKeyShape,
962
+ { shapeIds, drawSource, drawTarget, visible },
873
963
  upsertAncestors,
874
964
  );
875
965
 
876
- if (onlyDrawKeyShape) {
966
+ if (shapeIds) {
877
967
  // only update node positions to cloned node container(group)
878
968
  if (
879
969
  (type === 'node' || type === 'combo') &&
@@ -954,7 +1044,7 @@ export class ItemController {
954
1044
  );
955
1045
  transientObjectMap.set(idStr, shape);
956
1046
  shape.style.pointerEvents = capture ? 'auto' : 'none';
957
- canvas.getRoot().appendChild(shape);
1047
+ if (shape.parentNode === null) canvas.getRoot().appendChild(shape);
958
1048
  }
959
1049
  public getTransient(id: string) {
960
1050
  return this.transientObjectMap.get(id);
@@ -972,13 +1062,24 @@ export class ItemController {
972
1062
  * Create nodes with inner data to canvas.
973
1063
  * @param models nodes' inner datas
974
1064
  */
975
- private renderNodes(
1065
+ private async renderNodes(
976
1066
  models: NodeModel[],
977
1067
  nodeTheme: NodeThemeSpecifications = {},
978
- ) {
1068
+ tileOptimize?: {
1069
+ tileFirstRender?: boolean | number;
1070
+ tileFirstRenderSize?: number;
1071
+ },
1072
+ ): Promise<any> | undefined {
979
1073
  const { nodeExtensions, nodeGroup, nodeDataTypeSet, graph } = this;
980
1074
  const { dataTypeField = '' } = nodeTheme;
1075
+ const { tileFirstRender, tileFirstRenderSize = 1000 } = tileOptimize || {};
981
1076
  const zoom = graph.getZoom();
1077
+ const delayFirstDraw = isNumber(tileFirstRender)
1078
+ ? models.length > tileFirstRender
1079
+ : tileFirstRender;
1080
+ const itemsInView = [];
1081
+ const itemsOutView = [];
1082
+ const viewRange = this.graph.getCanvasRange();
982
1083
  models.forEach((node) => {
983
1084
  // get the base styles from theme
984
1085
  let dataType;
@@ -990,30 +1091,73 @@ export class ItemController {
990
1091
  nodeTheme,
991
1092
  );
992
1093
 
993
- this.itemMap.set(
994
- node.id,
995
- new Node({
996
- model: node,
997
- renderExtensions: nodeExtensions,
998
- containerGroup: nodeGroup,
999
- mapper: this.nodeMapper,
1000
- stateMapper: this.nodeStateMapper,
1001
- zoom,
1002
- theme: itemTheme as {
1003
- styles: NodeStyleSet;
1004
- lodStrategy: LodStrategyObj;
1005
- },
1006
- device:
1007
- graph.rendererType === 'webgl-3d'
1008
- ? // TODO: G type
1009
- (graph.canvas.context as any).deviceRendererPlugin.getDevice()
1010
- : undefined,
1011
- }),
1012
- );
1094
+ const nodeItem = new Node({
1095
+ delayFirstDraw,
1096
+ model: node,
1097
+ renderExtensions: nodeExtensions,
1098
+ containerGroup: nodeGroup,
1099
+ mapper: this.nodeMapper,
1100
+ stateMapper: this.nodeStateMapper,
1101
+ zoom,
1102
+ theme: itemTheme as {
1103
+ styles: NodeStyleSet;
1104
+ lodStrategy: LodStrategyObj;
1105
+ },
1106
+ device:
1107
+ graph.rendererType === 'webgl-3d'
1108
+ ? // TODO: G type
1109
+ (graph.canvas.context as any).deviceRendererPlugin.getDevice()
1110
+ : undefined,
1111
+ });
1112
+
1113
+ this.itemMap.set(node.id, nodeItem);
1114
+ const { x, y } = nodeItem.model.data;
1115
+ if (
1116
+ delayFirstDraw &&
1117
+ isPointInBBox(
1118
+ { x: convertToNumber(x), y: convertToNumber(y) },
1119
+ viewRange,
1120
+ )
1121
+ ) {
1122
+ itemsInView.push(nodeItem);
1123
+ } else {
1124
+ itemsOutView.push(nodeItem);
1125
+ }
1013
1126
  });
1127
+ if (delayFirstDraw) {
1128
+ let requestId;
1129
+ const sectionNum = Math.ceil(itemsOutView.length / tileFirstRenderSize);
1130
+ const sections = Array.from({ length: sectionNum }, (v, i) =>
1131
+ itemsOutView.slice(
1132
+ i * tileFirstRenderSize,
1133
+ i * tileFirstRenderSize + tileFirstRenderSize,
1134
+ ),
1135
+ );
1136
+ sections.unshift(itemsInView);
1137
+ const update = (resolve) => {
1138
+ if (!sections.length) {
1139
+ cancelAnimationFrame(requestId);
1140
+ return resolve(itemsInView);
1141
+ }
1142
+ sections
1143
+ .shift()
1144
+ .forEach((item) =>
1145
+ item.draw(
1146
+ item.displayModel as NodeDisplayModel | ComboDisplayModel,
1147
+ undefined,
1148
+ undefined,
1149
+ !item.displayModel.data.disableAnimate,
1150
+ ),
1151
+ );
1152
+ requestId = requestAnimationFrame(() => update(resolve));
1153
+ };
1154
+ return new Promise((resolve) => {
1155
+ requestId = requestAnimationFrame(() => update(resolve));
1156
+ });
1157
+ }
1014
1158
  }
1015
1159
 
1016
- private renderCombos(
1160
+ private async renderCombos(
1017
1161
  models: ComboModel[],
1018
1162
  comboTheme: ComboThemeSpecifications = {},
1019
1163
  graphCore: GraphCore,
@@ -1084,11 +1228,23 @@ export class ItemController {
1084
1228
  private renderEdges(
1085
1229
  models: EdgeModel[],
1086
1230
  edgeTheme: EdgeThemeSpecifications = {},
1087
- ) {
1231
+ tileOptimize?: {
1232
+ tileFirstRender?: boolean | number;
1233
+ tileFirstRenderSize?: number;
1234
+ },
1235
+ nodesInView?: Node[],
1236
+ ): Promise<any> | undefined {
1088
1237
  const { edgeExtensions, edgeGroup, itemMap, edgeDataTypeSet, graph } = this;
1089
1238
  const { dataTypeField = '' } = edgeTheme;
1239
+ const { tileFirstRender, tileFirstRenderSize = 1000 } = tileOptimize || {};
1090
1240
  const zoom = graph.getZoom();
1091
1241
  const nodeMap = filterItemMapByType(itemMap, 'node') as Map<ID, Node>;
1242
+ const delayFirstDraw = isNumber(tileFirstRender)
1243
+ ? models.length > tileFirstRender
1244
+ : tileFirstRender;
1245
+ const nodesInViewIds = new Set(nodesInView?.map((node) => node.getID()));
1246
+ const edgesInView = [];
1247
+ const edgesOutView = [];
1092
1248
  models.forEach((edge) => {
1093
1249
  const { source, target, id } = edge;
1094
1250
  const sourceItem = itemMap.get(source) as Node;
@@ -1115,27 +1271,54 @@ export class ItemController {
1115
1271
  edgeTheme,
1116
1272
  );
1117
1273
 
1118
- itemMap.set(
1119
- id,
1120
- new Edge({
1121
- model: edge,
1122
- renderExtensions: edgeExtensions,
1123
- containerGroup: edgeGroup,
1124
- mapper: this.edgeMapper as DisplayMapper,
1125
- stateMapper: this.edgeStateMapper as {
1126
- [stateName: string]: DisplayMapper;
1127
- },
1128
- sourceItem,
1129
- targetItem,
1130
- nodeMap,
1131
- zoom,
1132
- theme: itemTheme as {
1133
- styles: EdgeStyleSet;
1134
- lodStrategy: LodStrategyObj;
1135
- },
1136
- }),
1137
- );
1274
+ const edgeItem = new Edge({
1275
+ delayFirstDraw,
1276
+ model: edge,
1277
+ renderExtensions: edgeExtensions,
1278
+ containerGroup: edgeGroup,
1279
+ mapper: this.edgeMapper as DisplayMapper,
1280
+ stateMapper: this.edgeStateMapper as {
1281
+ [stateName: string]: DisplayMapper;
1282
+ },
1283
+ sourceItem,
1284
+ targetItem,
1285
+ nodeMap,
1286
+ zoom,
1287
+ theme: itemTheme as {
1288
+ styles: EdgeStyleSet;
1289
+ lodStrategy: LodStrategyObj;
1290
+ },
1291
+ });
1292
+
1293
+ itemMap.set(id, edgeItem);
1294
+ if (nodesInViewIds.has(source) || nodesInViewIds.has(target))
1295
+ edgesInView.push(edgeItem);
1296
+ else edgesOutView.push(edgeItem);
1297
+ return edgeItem;
1138
1298
  });
1299
+
1300
+ if (delayFirstDraw) {
1301
+ let requestId;
1302
+ const sectionNum = Math.ceil(edgesOutView.length / tileFirstRenderSize);
1303
+ const sections = Array.from({ length: sectionNum }, (v, i) =>
1304
+ edgesOutView.slice(
1305
+ i * tileFirstRenderSize,
1306
+ i * tileFirstRenderSize + tileFirstRenderSize,
1307
+ ),
1308
+ );
1309
+ sections.unshift(edgesInView);
1310
+ const update = (resolve) => {
1311
+ if (!sections.length) {
1312
+ cancelAnimationFrame(requestId);
1313
+ return resolve();
1314
+ }
1315
+ sections.shift().forEach((item) => item.draw(item.displayModel));
1316
+ requestId = requestAnimationFrame(() => update(resolve));
1317
+ };
1318
+ return new Promise((resolve) => {
1319
+ requestId = requestAnimationFrame(() => update(resolve));
1320
+ });
1321
+ }
1139
1322
  }
1140
1323
 
1141
1324
  /**
@@ -1288,7 +1471,7 @@ export class ItemController {
1288
1471
  // find the succeeds in collapsed
1289
1472
  graphComboTreeDfs(this.graph, [comboModel], (child) => {
1290
1473
  if (child.id !== comboModel.id) {
1291
- this.graph.executeWithoutStacking(() => {
1474
+ this.graph.executeWithNoStack(() => {
1292
1475
  this.graph.hideItem(child.id, false);
1293
1476
  });
1294
1477
  }
@@ -1308,7 +1491,7 @@ export class ItemController {
1308
1491
  pairs.push({ source, target });
1309
1492
  });
1310
1493
  // each item in groupedEdges is a virtual edge
1311
- this.graph.executeWithoutStacking(() => {
1494
+ this.graph.executeWithNoStack(() => {
1312
1495
  this.graph.addData('edge', groupVirtualEdges(pairs));
1313
1496
  });
1314
1497
  }
@@ -1391,7 +1574,7 @@ export class ItemController {
1391
1574
  );
1392
1575
 
1393
1576
  // remove related virtual edges
1394
- this.graph.executeWithoutStacking(() => {
1577
+ this.graph.executeWithNoStack(() => {
1395
1578
  this.graph.removeData('edge', uniq(relatedVirtualEdgeIds));
1396
1579
  this.graph.showItem(edgesToShow.concat(nodesToShow));
1397
1580
  // add virtual edges by grouping visible ancestor edges
@@ -97,8 +97,6 @@ export class LayoutController {
97
97
  });
98
98
  }
99
99
 
100
- this.graph.emit('startlayout');
101
-
102
100
  const [width, height] = this.graph.getSize();
103
101
  const center = [width / 2, height / 2];
104
102
 
@@ -227,8 +225,6 @@ export class LayoutController {
227
225
  }
228
226
  }
229
227
 
230
- this.graph.emit('endlayout');
231
-
232
228
  // Update nodes' positions.
233
229
  this.updateNodesPosition(positions, animate);
234
230
  }
@@ -279,7 +275,7 @@ export class LayoutController {
279
275
  animationEffectTiming,
280
276
  );
281
277
  }
282
- this.graph.emit('endlayout');
278
+ this.graph.emit('afterlayout');
283
279
  this.updateNodesPosition(
284
280
  { nodes: nodePositions, edges: [] },
285
281
  animated || animate,
@@ -83,7 +83,7 @@ export class PluginController {
83
83
 
84
84
  private initPlugin(config) {
85
85
  const { graph } = this;
86
- if (config instanceof PluginBase) {
86
+ if (typeof config.init === 'function' && config.options) {
87
87
  config.init(graph);
88
88
  const key = config.key || config.options?.key || `plugin-${uniqueId()}`;
89
89
  this.pluginMap.set(key, { type: key, plugin: config });
@@ -116,7 +116,7 @@ export class PluginController {
116
116
  if (action === 'add') {
117
117
  pluginCfgs.forEach((config) => {
118
118
  const { key, plugin } = this.initPlugin(config);
119
- this.addListeners(key, plugin);
119
+ this.addListeners(key, plugin, false);
120
120
  });
121
121
  return;
122
122
  }
@@ -158,7 +158,7 @@ export class PluginController {
158
158
  const { plugin } = item;
159
159
  plugin.updateCfgs(config);
160
160
  this.removeListeners(key);
161
- this.addListeners(key, plugin);
161
+ this.addListeners(key, plugin, false);
162
162
  });
163
163
  return;
164
164
  }
@@ -184,7 +184,11 @@ export class PluginController {
184
184
  return plugin;
185
185
  }
186
186
 
187
- private addListeners = (key: string, plugin: PluginBase) => {
187
+ private addListeners = (
188
+ key: string,
189
+ plugin: PluginBase,
190
+ initWithGraph: boolean = true,
191
+ ) => {
188
192
  const events = plugin.getEvents();
189
193
  this.listenersMap[key] = {};
190
194
  Object.keys(events).forEach((eventName) => {
@@ -196,6 +200,13 @@ export class PluginController {
196
200
  );
197
201
  this.graph.on(eventName, listener);
198
202
  this.listenersMap[key][eventName] = listener;
203
+ // The plugin is not initiated with graph, some events are not listened, trigger them manually
204
+ if (
205
+ !initWithGraph &&
206
+ ['afterrender', 'afterlayout'].includes(eventName)
207
+ ) {
208
+ listener({} as IG6GraphEvent);
209
+ }
199
210
  });
200
211
  };
201
212