@antv/g6 5.0.0-alpha.9 → 5.0.0-beta.0

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 (895) hide show
  1. package/dist/g6.min.js +2 -2
  2. package/esm/api-doc/behaviors.d.ts +2 -0
  3. package/esm/api-doc/behaviors.js +2 -0
  4. package/esm/api-doc/behaviors.js.map +1 -0
  5. package/esm/api-doc/graph.d.ts +4 -0
  6. package/esm/api-doc/graph.js +4 -0
  7. package/esm/api-doc/graph.js.map +1 -0
  8. package/esm/api-doc/item.d.ts +9 -0
  9. package/esm/api-doc/item.js +3 -0
  10. package/esm/api-doc/item.js.map +1 -0
  11. package/esm/api-doc/layout.d.ts +1 -0
  12. package/esm/api-doc/layout.js +2 -0
  13. package/esm/api-doc/layout.js.map +1 -0
  14. package/esm/api-doc/plugins.d.ts +1 -0
  15. package/esm/api-doc/plugins.js +2 -0
  16. package/esm/api-doc/plugins.js.map +1 -0
  17. package/esm/api-doc/types.d.ts +0 -0
  18. package/esm/api-doc/types.js +3 -0
  19. package/esm/api-doc/types.js.map +1 -0
  20. package/esm/api-doc/util.d.ts +3 -0
  21. package/esm/api-doc/util.js +4 -0
  22. package/esm/api-doc/util.js.map +1 -0
  23. package/esm/constant/shape.d.ts +7 -14
  24. package/esm/constant/shape.js +1 -0
  25. package/esm/constant/shape.js.map +1 -1
  26. package/esm/index.d.ts +213 -113
  27. package/esm/index.js +11 -4
  28. package/esm/index.js.map +1 -1
  29. package/esm/item/combo.d.ts +13 -6
  30. package/esm/item/combo.js +72 -8
  31. package/esm/item/combo.js.map +1 -1
  32. package/esm/item/edge.d.ts +12 -9
  33. package/esm/item/edge.js +38 -11
  34. package/esm/item/edge.js.map +1 -1
  35. package/esm/item/item.d.ts +8 -6
  36. package/esm/item/item.js +124 -81
  37. package/esm/item/item.js.map +1 -1
  38. package/esm/item/node.d.ts +14 -9
  39. package/esm/item/node.js +63 -48
  40. package/esm/item/node.js.map +1 -1
  41. package/esm/runtime/controller/data.d.ts +17 -1
  42. package/esm/runtime/controller/data.js +320 -223
  43. package/esm/runtime/controller/data.js.map +1 -1
  44. package/esm/runtime/controller/interaction.d.ts +1 -0
  45. package/esm/runtime/controller/interaction.js +7 -4
  46. package/esm/runtime/controller/interaction.js.map +1 -1
  47. package/esm/runtime/controller/item.d.ts +37 -4
  48. package/esm/runtime/controller/item.js +475 -177
  49. package/esm/runtime/controller/item.js.map +1 -1
  50. package/esm/runtime/controller/layout.d.ts +4 -1
  51. package/esm/runtime/controller/layout.js +96 -14
  52. package/esm/runtime/controller/layout.js.map +1 -1
  53. package/esm/runtime/controller/plugin.d.ts +11 -0
  54. package/esm/runtime/controller/plugin.js +39 -6
  55. package/esm/runtime/controller/plugin.js.map +1 -1
  56. package/esm/runtime/controller/theme.js +8 -4
  57. package/esm/runtime/controller/theme.js.map +1 -1
  58. package/esm/runtime/graph.d.ts +181 -39
  59. package/esm/runtime/graph.js +561 -72
  60. package/esm/runtime/graph.js.map +1 -1
  61. package/esm/stdlib/behavior/activate-relations.d.ts +2 -3
  62. package/esm/stdlib/behavior/activate-relations.js +13 -9
  63. package/esm/stdlib/behavior/activate-relations.js.map +1 -1
  64. package/esm/stdlib/behavior/brush-select.d.ts +3 -4
  65. package/esm/stdlib/behavior/brush-select.js +2 -2
  66. package/esm/stdlib/behavior/brush-select.js.map +1 -1
  67. package/esm/stdlib/behavior/click-select.d.ts +2 -3
  68. package/esm/stdlib/behavior/click-select.js +8 -6
  69. package/esm/stdlib/behavior/click-select.js.map +1 -1
  70. package/esm/stdlib/behavior/collapse-expand-combo.d.ts +1 -2
  71. package/esm/stdlib/behavior/collapse-expand-combo.js +1 -1
  72. package/esm/stdlib/behavior/collapse-expand-combo.js.map +1 -1
  73. package/esm/stdlib/behavior/collapse-expand-tree.d.ts +44 -0
  74. package/esm/stdlib/behavior/collapse-expand-tree.js +69 -0
  75. package/esm/stdlib/behavior/collapse-expand-tree.js.map +1 -0
  76. package/esm/stdlib/behavior/drag-canvas.d.ts +1 -2
  77. package/esm/stdlib/behavior/drag-canvas.js +15 -11
  78. package/esm/stdlib/behavior/drag-canvas.js.map +1 -1
  79. package/esm/stdlib/behavior/drag-combo.d.ts +16 -4
  80. package/esm/stdlib/behavior/drag-combo.js +70 -31
  81. package/esm/stdlib/behavior/drag-combo.js.map +1 -1
  82. package/esm/stdlib/behavior/drag-node.d.ts +20 -4
  83. package/esm/stdlib/behavior/drag-node.js +145 -57
  84. package/esm/stdlib/behavior/drag-node.js.map +1 -1
  85. package/esm/stdlib/behavior/hover-activate.d.ts +1 -2
  86. package/esm/stdlib/behavior/hover-activate.js +1 -1
  87. package/esm/stdlib/behavior/hover-activate.js.map +1 -1
  88. package/esm/stdlib/behavior/index.d.ts +15 -0
  89. package/esm/stdlib/behavior/index.js +16 -0
  90. package/esm/stdlib/behavior/index.js.map +1 -0
  91. package/esm/stdlib/behavior/lasso-select.d.ts +7 -3
  92. package/esm/stdlib/behavior/lasso-select.js +2 -2
  93. package/esm/stdlib/behavior/lasso-select.js.map +1 -1
  94. package/esm/stdlib/behavior/orbit-canvas-3d.d.ts +2 -3
  95. package/esm/stdlib/behavior/orbit-canvas-3d.js +2 -2
  96. package/esm/stdlib/behavior/orbit-canvas-3d.js.map +1 -1
  97. package/esm/stdlib/behavior/rotate-canvas-3d.d.ts +1 -2
  98. package/esm/stdlib/behavior/rotate-canvas-3d.js +1 -1
  99. package/esm/stdlib/behavior/rotate-canvas-3d.js.map +1 -1
  100. package/esm/stdlib/behavior/track-canvas-3d.d.ts +2 -3
  101. package/esm/stdlib/behavior/track-canvas-3d.js +2 -2
  102. package/esm/stdlib/behavior/track-canvas-3d.js.map +1 -1
  103. package/esm/stdlib/behavior/types.d.ts +13 -0
  104. package/esm/stdlib/behavior/types.js +2 -0
  105. package/esm/stdlib/behavior/types.js.map +1 -0
  106. package/esm/stdlib/behavior/zoom-canvas-3d.d.ts +1 -2
  107. package/esm/stdlib/behavior/zoom-canvas-3d.js +7 -7
  108. package/esm/stdlib/behavior/zoom-canvas-3d.js.map +1 -1
  109. package/esm/stdlib/behavior/zoom-canvas.d.ts +1 -2
  110. package/esm/stdlib/behavior/zoom-canvas.js +20 -18
  111. package/esm/stdlib/behavior/zoom-canvas.js.map +1 -1
  112. package/esm/stdlib/data/index.d.ts +3 -0
  113. package/esm/stdlib/data/index.js +4 -0
  114. package/esm/stdlib/data/index.js.map +1 -0
  115. package/esm/stdlib/data/mapNodeSize.d.ts +12 -0
  116. package/esm/stdlib/data/mapNodeSize.js +43 -0
  117. package/esm/stdlib/data/mapNodeSize.js.map +1 -0
  118. package/esm/stdlib/data/transformV4Data.d.ts +9 -0
  119. package/esm/stdlib/data/transformV4Data.js +142 -0
  120. package/esm/stdlib/data/transformV4Data.js.map +1 -0
  121. package/esm/stdlib/data/validateData.d.ts +9 -0
  122. package/esm/stdlib/data/validateData.js +98 -0
  123. package/esm/stdlib/data/validateData.js.map +1 -0
  124. package/esm/stdlib/index.d.ts +113 -69
  125. package/esm/stdlib/index.js +150 -53
  126. package/esm/stdlib/index.js.map +1 -1
  127. package/esm/stdlib/item/combo/index.d.ts +2 -0
  128. package/esm/stdlib/item/combo/index.js +3 -0
  129. package/esm/stdlib/item/combo/index.js.map +1 -0
  130. package/esm/stdlib/item/combo/rect.d.ts +31 -0
  131. package/esm/stdlib/item/combo/rect.js +65 -0
  132. package/esm/stdlib/item/combo/rect.js.map +1 -0
  133. package/esm/stdlib/item/edge/base.d.ts +10 -1
  134. package/esm/stdlib/item/edge/base.js +36 -5
  135. package/esm/stdlib/item/edge/base.js.map +1 -1
  136. package/{lib/stdlib/item/edge/cubic-horizon.d.ts → esm/stdlib/item/edge/cubic-horizontal.d.ts} +6 -7
  137. package/esm/stdlib/item/edge/{cubic-horizon.js → cubic-horizontal.js} +18 -33
  138. package/esm/stdlib/item/edge/cubic-horizontal.js.map +1 -0
  139. package/esm/stdlib/item/edge/cubic-vertical.d.ts +7 -8
  140. package/esm/stdlib/item/edge/cubic-vertical.js +17 -32
  141. package/esm/stdlib/item/edge/cubic-vertical.js.map +1 -1
  142. package/esm/stdlib/item/edge/cubic.d.ts +7 -8
  143. package/esm/stdlib/item/edge/cubic.js +22 -5
  144. package/esm/stdlib/item/edge/cubic.js.map +1 -1
  145. package/esm/stdlib/item/edge/index.d.ts +5 -0
  146. package/esm/stdlib/item/edge/index.js +5 -0
  147. package/esm/stdlib/item/edge/index.js.map +1 -1
  148. package/esm/stdlib/item/edge/line.d.ts +1 -1
  149. package/esm/stdlib/item/edge/line.js +16 -1
  150. package/esm/stdlib/item/edge/line.js.map +1 -1
  151. package/esm/stdlib/item/edge/loop.d.ts +32 -0
  152. package/esm/stdlib/item/edge/loop.js +115 -0
  153. package/esm/stdlib/item/edge/loop.js.map +1 -0
  154. package/esm/stdlib/item/edge/polyline.d.ts +44 -0
  155. package/esm/stdlib/item/edge/polyline.js +92 -0
  156. package/esm/stdlib/item/edge/polyline.js.map +1 -0
  157. package/esm/stdlib/item/edge/quadratic.d.ts +5 -6
  158. package/esm/stdlib/item/edge/quadratic.js +31 -19
  159. package/esm/stdlib/item/edge/quadratic.js.map +1 -1
  160. package/esm/stdlib/item/node/base.d.ts +45 -1
  161. package/esm/stdlib/item/node/base.js +97 -12
  162. package/esm/stdlib/item/node/base.js.map +1 -1
  163. package/esm/stdlib/item/node/base3d.js +1 -1
  164. package/esm/stdlib/item/node/base3d.js.map +1 -1
  165. package/esm/stdlib/item/node/circle.js +5 -5
  166. package/esm/stdlib/item/node/circle.js.map +1 -1
  167. package/esm/stdlib/item/node/diamond.d.ts +32 -0
  168. package/esm/stdlib/item/node/diamond.js +79 -0
  169. package/esm/stdlib/item/node/diamond.js.map +1 -0
  170. package/esm/stdlib/item/node/donut.d.ts +70 -0
  171. package/esm/stdlib/item/node/donut.js +207 -0
  172. package/esm/stdlib/item/node/donut.js.map +1 -0
  173. package/esm/stdlib/item/node/ellipse.d.ts +32 -0
  174. package/esm/stdlib/item/node/ellipse.js +71 -0
  175. package/esm/stdlib/item/node/ellipse.js.map +1 -0
  176. package/esm/stdlib/item/node/hexagon.d.ts +33 -0
  177. package/esm/stdlib/item/node/hexagon.js +102 -0
  178. package/esm/stdlib/item/node/hexagon.js.map +1 -0
  179. package/esm/stdlib/item/node/index.d.ts +7 -0
  180. package/esm/stdlib/item/node/index.js +7 -0
  181. package/esm/stdlib/item/node/index.js.map +1 -1
  182. package/esm/stdlib/item/node/modelRect.d.ts +61 -0
  183. package/esm/stdlib/item/node/modelRect.js +186 -0
  184. package/esm/stdlib/item/node/modelRect.js.map +1 -0
  185. package/esm/stdlib/item/node/rect.d.ts +1 -0
  186. package/esm/stdlib/item/node/rect.js +16 -0
  187. package/esm/stdlib/item/node/rect.js.map +1 -1
  188. package/esm/stdlib/item/node/star.d.ts +34 -0
  189. package/esm/stdlib/item/node/star.js +115 -0
  190. package/esm/stdlib/item/node/star.js.map +1 -0
  191. package/esm/stdlib/item/node/triangle.d.ts +44 -0
  192. package/esm/stdlib/item/node/triangle.js +177 -0
  193. package/esm/stdlib/item/node/triangle.js.map +1 -0
  194. package/esm/stdlib/plugin/fisheye/index.d.ts +32 -4
  195. package/esm/stdlib/plugin/fisheye/index.js +3 -2
  196. package/esm/stdlib/plugin/fisheye/index.js.map +1 -1
  197. package/esm/stdlib/plugin/grid/index.d.ts +36 -0
  198. package/esm/stdlib/plugin/grid/index.js +81 -0
  199. package/esm/stdlib/plugin/grid/index.js.map +1 -0
  200. package/esm/stdlib/plugin/history/combo-command.d.ts +9 -0
  201. package/esm/stdlib/plugin/history/combo-command.js +21 -0
  202. package/esm/stdlib/plugin/history/combo-command.js.map +1 -0
  203. package/esm/stdlib/plugin/history/command.d.ts +18 -0
  204. package/esm/stdlib/plugin/history/command.js +51 -0
  205. package/esm/stdlib/plugin/history/command.js.map +1 -0
  206. package/esm/stdlib/plugin/history/index.d.ts +112 -0
  207. package/esm/stdlib/plugin/history/index.js +275 -0
  208. package/esm/stdlib/plugin/history/index.js.map +1 -0
  209. package/esm/stdlib/plugin/history/item-data-command.d.ts +14 -0
  210. package/esm/stdlib/plugin/history/item-data-command.js +63 -0
  211. package/esm/stdlib/plugin/history/item-data-command.js.map +1 -0
  212. package/esm/stdlib/plugin/history/layer-updated-command.d.ts +9 -0
  213. package/esm/stdlib/plugin/history/layer-updated-command.js +21 -0
  214. package/esm/stdlib/plugin/history/layer-updated-command.js.map +1 -0
  215. package/esm/stdlib/plugin/history/state-updated-command.d.ts +9 -0
  216. package/esm/stdlib/plugin/history/state-updated-command.js +20 -0
  217. package/esm/stdlib/plugin/history/state-updated-command.js.map +1 -0
  218. package/esm/stdlib/plugin/history/visibility-updated-command.d.ts +10 -0
  219. package/esm/stdlib/plugin/history/visibility-updated-command.js +23 -0
  220. package/esm/stdlib/plugin/history/visibility-updated-command.js.map +1 -0
  221. package/esm/stdlib/plugin/hull/bubbleset.d.ts +9 -0
  222. package/esm/stdlib/plugin/hull/bubbleset.js +592 -0
  223. package/esm/stdlib/plugin/hull/bubbleset.js.map +1 -0
  224. package/esm/stdlib/plugin/hull/convexHull.d.ts +14 -0
  225. package/esm/stdlib/plugin/hull/convexHull.js +56 -0
  226. package/esm/stdlib/plugin/hull/convexHull.js.map +1 -0
  227. package/esm/stdlib/plugin/hull/hullComponent.d.ts +87 -0
  228. package/esm/stdlib/plugin/hull/hullComponent.js +382 -0
  229. package/esm/stdlib/plugin/hull/hullComponent.js.map +1 -0
  230. package/esm/stdlib/plugin/hull/index.d.ts +59 -0
  231. package/esm/stdlib/plugin/hull/index.js +161 -0
  232. package/esm/stdlib/plugin/hull/index.js.map +1 -0
  233. package/esm/stdlib/plugin/hull/types.d.ts +15 -0
  234. package/esm/stdlib/plugin/hull/types.js +2 -0
  235. package/esm/stdlib/plugin/hull/types.js.map +1 -0
  236. package/esm/stdlib/plugin/hull/util.d.ts +77 -0
  237. package/esm/stdlib/plugin/hull/util.js +401 -0
  238. package/esm/stdlib/plugin/hull/util.js.map +1 -0
  239. package/esm/stdlib/plugin/index.d.ts +8 -0
  240. package/esm/stdlib/plugin/index.js +9 -0
  241. package/esm/stdlib/plugin/index.js.map +1 -0
  242. package/esm/stdlib/plugin/legend/index.d.ts +45 -3
  243. package/esm/stdlib/plugin/legend/index.js +47 -42
  244. package/esm/stdlib/plugin/legend/index.js.map +1 -1
  245. package/esm/stdlib/plugin/menu/index.d.ts +18 -5
  246. package/esm/stdlib/plugin/menu/index.js +4 -3
  247. package/esm/stdlib/plugin/menu/index.js.map +1 -1
  248. package/esm/stdlib/plugin/minimap/index.d.ts +11 -3
  249. package/esm/stdlib/plugin/minimap/index.js +19 -21
  250. package/esm/stdlib/plugin/minimap/index.js.map +1 -1
  251. package/esm/stdlib/plugin/toolbar/index.d.ts +59 -0
  252. package/esm/stdlib/plugin/toolbar/index.js +215 -0
  253. package/esm/stdlib/plugin/toolbar/index.js.map +1 -0
  254. package/esm/stdlib/plugin/tooltip/index.d.ts +24 -3
  255. package/esm/stdlib/plugin/tooltip/index.js +13 -12
  256. package/esm/stdlib/plugin/tooltip/index.js.map +1 -1
  257. package/esm/stdlib/plugin/types.d.ts +8 -0
  258. package/esm/stdlib/plugin/types.js +2 -0
  259. package/esm/stdlib/plugin/types.js.map +1 -0
  260. package/esm/stdlib/theme/dark.d.ts +1 -2
  261. package/esm/stdlib/theme/dark.js +9 -1
  262. package/esm/stdlib/theme/dark.js.map +1 -1
  263. package/esm/stdlib/theme/index.d.ts +2 -0
  264. package/esm/stdlib/theme/index.js +3 -0
  265. package/esm/stdlib/theme/index.js.map +1 -0
  266. package/esm/stdlib/theme/light.d.ts +1 -2
  267. package/esm/stdlib/theme/light.js +12 -2
  268. package/esm/stdlib/theme/light.js.map +1 -1
  269. package/esm/stdlib/themeSolver/base.d.ts +1 -1
  270. package/esm/stdlib/themeSolver/base.js +1 -1
  271. package/esm/stdlib/themeSolver/base.js.map +1 -1
  272. package/esm/stdlib/themeSolver/index.d.ts +3 -0
  273. package/esm/stdlib/themeSolver/index.js +4 -0
  274. package/esm/stdlib/themeSolver/index.js.map +1 -0
  275. package/esm/stdlib/themeSolver/spec.d.ts +2 -4
  276. package/esm/stdlib/themeSolver/spec.js +2 -2
  277. package/esm/stdlib/themeSolver/spec.js.map +1 -1
  278. package/esm/stdlib/themeSolver/subject.d.ts +2 -4
  279. package/esm/stdlib/themeSolver/subject.js +2 -2
  280. package/esm/stdlib/themeSolver/subject.js.map +1 -1
  281. package/esm/types/behavior.js.map +1 -1
  282. package/esm/types/combo.d.ts +3 -4
  283. package/esm/types/common.d.ts +10 -0
  284. package/esm/types/data.d.ts +10 -4
  285. package/esm/types/edge.d.ts +17 -2
  286. package/esm/types/graph.d.ts +129 -16
  287. package/esm/types/history.d.ts +28 -0
  288. package/esm/types/history.js +6 -0
  289. package/esm/types/history.js.map +1 -0
  290. package/esm/types/hook.d.ts +25 -5
  291. package/esm/types/index.d.ts +11 -5
  292. package/esm/types/index.js.map +1 -1
  293. package/esm/types/item.d.ts +10 -4
  294. package/esm/types/item.js.map +1 -1
  295. package/esm/types/layout.d.ts +4 -1
  296. package/esm/types/loop.d.ts +21 -0
  297. package/esm/types/loop.js +12 -0
  298. package/esm/types/loop.js.map +1 -0
  299. package/esm/types/node.d.ts +87 -6
  300. package/esm/types/plugin.d.ts +4 -0
  301. package/esm/types/plugin.js +1 -1
  302. package/esm/types/plugin.js.map +1 -1
  303. package/esm/types/spec.d.ts +26 -9
  304. package/esm/types/theme.d.ts +76 -10
  305. package/esm/types/theme.js +1 -2
  306. package/esm/types/theme.js.map +1 -1
  307. package/esm/util/animate.d.ts +2 -2
  308. package/esm/util/animate.js +52 -17
  309. package/esm/util/animate.js.map +1 -1
  310. package/esm/util/array.d.ts +8 -0
  311. package/esm/util/array.js +11 -1
  312. package/esm/util/array.js.map +1 -1
  313. package/esm/util/arrow.d.ts +17 -0
  314. package/esm/util/arrow.js +56 -0
  315. package/esm/util/arrow.js.map +1 -0
  316. package/esm/util/bbox.d.ts +106 -0
  317. package/esm/util/bbox.js +255 -0
  318. package/esm/util/bbox.js.map +1 -0
  319. package/esm/util/behavior.d.ts +2 -0
  320. package/esm/util/behavior.js +12 -0
  321. package/esm/util/behavior.js.map +1 -0
  322. package/esm/util/canvas.d.ts +1 -2
  323. package/esm/util/canvas.js +3 -20
  324. package/esm/util/canvas.js.map +1 -1
  325. package/esm/util/data.d.ts +33 -2
  326. package/esm/util/data.js +117 -5
  327. package/esm/util/data.js.map +1 -1
  328. package/esm/util/event.d.ts +22 -2
  329. package/esm/util/event.js +54 -0
  330. package/esm/util/event.js.map +1 -1
  331. package/esm/util/extend.d.ts +8 -2
  332. package/esm/util/extend.js.map +1 -1
  333. package/esm/util/index.d.ts +41 -3
  334. package/esm/util/index.js +20 -1
  335. package/esm/util/index.js.map +1 -1
  336. package/esm/util/item.d.ts +1 -1
  337. package/esm/util/item.js +7 -5
  338. package/esm/util/item.js.map +1 -1
  339. package/esm/util/layout.d.ts +40 -0
  340. package/esm/util/layout.js +160 -0
  341. package/esm/util/layout.js.map +1 -0
  342. package/esm/util/loop.d.ts +37 -0
  343. package/esm/util/loop.js +104 -0
  344. package/esm/util/loop.js.map +1 -0
  345. package/esm/util/mapper.js +4 -9
  346. package/esm/util/mapper.js.map +1 -1
  347. package/esm/util/math.d.ts +15 -0
  348. package/esm/util/math.js +14 -0
  349. package/esm/util/math.js.map +1 -1
  350. package/esm/util/mock.d.ts +30 -0
  351. package/esm/util/mock.js +69 -0
  352. package/esm/util/mock.js.map +1 -0
  353. package/esm/util/path.d.ts +11 -0
  354. package/esm/util/path.js +44 -0
  355. package/esm/util/path.js.map +1 -0
  356. package/esm/util/point.d.ts +24 -2
  357. package/esm/util/point.js +27 -2
  358. package/esm/util/point.js.map +1 -1
  359. package/esm/util/polyline.d.ts +113 -0
  360. package/esm/util/polyline.js +505 -0
  361. package/esm/util/polyline.js.map +1 -0
  362. package/esm/util/router.d.ts +31 -0
  363. package/esm/util/router.js +380 -0
  364. package/esm/util/router.js.map +1 -0
  365. package/esm/util/shape.d.ts +3 -3
  366. package/esm/util/shape.js +19 -3
  367. package/esm/util/shape.js.map +1 -1
  368. package/esm/util/shape3d.d.ts +1 -1
  369. package/esm/util/shape3d.js +12 -6
  370. package/esm/util/shape3d.js.map +1 -1
  371. package/esm/util/type.d.ts +6 -0
  372. package/esm/util/type.js +7 -1
  373. package/esm/util/type.js.map +1 -1
  374. package/esm/util/zoom.d.ts +1 -1
  375. package/esm/util/zoom.js +6 -2
  376. package/esm/util/zoom.js.map +1 -1
  377. package/lib/api-doc/behaviors.d.ts +2 -0
  378. package/lib/api-doc/behaviors.js +18 -0
  379. package/lib/api-doc/behaviors.js.map +1 -0
  380. package/lib/api-doc/graph.d.ts +4 -0
  381. package/lib/api-doc/graph.js +11 -0
  382. package/lib/api-doc/graph.js.map +1 -0
  383. package/lib/api-doc/item.d.ts +9 -0
  384. package/lib/api-doc/item.js +21 -0
  385. package/lib/api-doc/item.js.map +1 -0
  386. package/lib/api-doc/layout.d.ts +1 -0
  387. package/lib/api-doc/layout.js +3 -0
  388. package/lib/api-doc/layout.js.map +1 -0
  389. package/lib/api-doc/plugins.d.ts +1 -0
  390. package/lib/api-doc/plugins.js +18 -0
  391. package/lib/api-doc/plugins.js.map +1 -0
  392. package/lib/api-doc/types.d.ts +0 -0
  393. package/lib/api-doc/types.js +3 -0
  394. package/lib/api-doc/types.js.map +1 -0
  395. package/lib/api-doc/util.d.ts +3 -0
  396. package/lib/api-doc/util.js +10 -0
  397. package/lib/api-doc/util.js.map +1 -0
  398. package/lib/constant/shape.d.ts +7 -14
  399. package/lib/constant/shape.js +1 -0
  400. package/lib/constant/shape.js.map +1 -1
  401. package/lib/index.d.ts +213 -113
  402. package/lib/index.js +13 -3
  403. package/lib/index.js.map +1 -1
  404. package/lib/item/combo.d.ts +13 -6
  405. package/lib/item/combo.js +72 -8
  406. package/lib/item/combo.js.map +1 -1
  407. package/lib/item/edge.d.ts +12 -9
  408. package/lib/item/edge.js +38 -11
  409. package/lib/item/edge.js.map +1 -1
  410. package/lib/item/item.d.ts +8 -6
  411. package/lib/item/item.js +123 -80
  412. package/lib/item/item.js.map +1 -1
  413. package/lib/item/node.d.ts +14 -9
  414. package/lib/item/node.js +63 -48
  415. package/lib/item/node.js.map +1 -1
  416. package/lib/runtime/controller/data.d.ts +17 -1
  417. package/lib/runtime/controller/data.js +318 -221
  418. package/lib/runtime/controller/data.js.map +1 -1
  419. package/lib/runtime/controller/interaction.d.ts +1 -0
  420. package/lib/runtime/controller/interaction.js +7 -4
  421. package/lib/runtime/controller/interaction.js.map +1 -1
  422. package/lib/runtime/controller/item.d.ts +37 -4
  423. package/lib/runtime/controller/item.js +474 -176
  424. package/lib/runtime/controller/item.js.map +1 -1
  425. package/lib/runtime/controller/layout.d.ts +4 -1
  426. package/lib/runtime/controller/layout.js +119 -14
  427. package/lib/runtime/controller/layout.js.map +1 -1
  428. package/lib/runtime/controller/plugin.d.ts +11 -0
  429. package/lib/runtime/controller/plugin.js +39 -6
  430. package/lib/runtime/controller/plugin.js.map +1 -1
  431. package/lib/runtime/controller/theme.js +8 -4
  432. package/lib/runtime/controller/theme.js.map +1 -1
  433. package/lib/runtime/graph.d.ts +181 -39
  434. package/lib/runtime/graph.js +560 -71
  435. package/lib/runtime/graph.js.map +1 -1
  436. package/lib/stdlib/behavior/activate-relations.d.ts +2 -3
  437. package/lib/stdlib/behavior/activate-relations.js +14 -9
  438. package/lib/stdlib/behavior/activate-relations.js.map +1 -1
  439. package/lib/stdlib/behavior/brush-select.d.ts +3 -4
  440. package/lib/stdlib/behavior/brush-select.js +3 -2
  441. package/lib/stdlib/behavior/brush-select.js.map +1 -1
  442. package/lib/stdlib/behavior/click-select.d.ts +2 -3
  443. package/lib/stdlib/behavior/click-select.js +9 -6
  444. package/lib/stdlib/behavior/click-select.js.map +1 -1
  445. package/lib/stdlib/behavior/collapse-expand-combo.d.ts +1 -2
  446. package/lib/stdlib/behavior/collapse-expand-combo.js +2 -1
  447. package/lib/stdlib/behavior/collapse-expand-combo.js.map +1 -1
  448. package/lib/stdlib/behavior/collapse-expand-tree.d.ts +44 -0
  449. package/lib/stdlib/behavior/collapse-expand-tree.js +73 -0
  450. package/lib/stdlib/behavior/collapse-expand-tree.js.map +1 -0
  451. package/lib/stdlib/behavior/drag-canvas.d.ts +1 -2
  452. package/lib/stdlib/behavior/drag-canvas.js +16 -11
  453. package/lib/stdlib/behavior/drag-canvas.js.map +1 -1
  454. package/lib/stdlib/behavior/drag-combo.d.ts +16 -4
  455. package/lib/stdlib/behavior/drag-combo.js +70 -30
  456. package/lib/stdlib/behavior/drag-combo.js.map +1 -1
  457. package/lib/stdlib/behavior/drag-node.d.ts +20 -4
  458. package/lib/stdlib/behavior/drag-node.js +145 -56
  459. package/lib/stdlib/behavior/drag-node.js.map +1 -1
  460. package/lib/stdlib/behavior/hover-activate.d.ts +1 -2
  461. package/lib/stdlib/behavior/hover-activate.js +2 -1
  462. package/lib/stdlib/behavior/hover-activate.js.map +1 -1
  463. package/lib/stdlib/behavior/index.d.ts +15 -0
  464. package/lib/stdlib/behavior/index.js +32 -0
  465. package/lib/stdlib/behavior/index.js.map +1 -0
  466. package/lib/stdlib/behavior/lasso-select.d.ts +7 -3
  467. package/lib/stdlib/behavior/lasso-select.js +4 -6
  468. package/lib/stdlib/behavior/lasso-select.js.map +1 -1
  469. package/lib/stdlib/behavior/orbit-canvas-3d.d.ts +2 -3
  470. package/lib/stdlib/behavior/orbit-canvas-3d.js +4 -6
  471. package/lib/stdlib/behavior/orbit-canvas-3d.js.map +1 -1
  472. package/lib/stdlib/behavior/rotate-canvas-3d.d.ts +1 -2
  473. package/lib/stdlib/behavior/rotate-canvas-3d.js +2 -1
  474. package/lib/stdlib/behavior/rotate-canvas-3d.js.map +1 -1
  475. package/lib/stdlib/behavior/track-canvas-3d.d.ts +2 -3
  476. package/lib/stdlib/behavior/track-canvas-3d.js +4 -6
  477. package/lib/stdlib/behavior/track-canvas-3d.js.map +1 -1
  478. package/lib/stdlib/behavior/types.d.ts +13 -0
  479. package/lib/stdlib/behavior/types.js +3 -0
  480. package/lib/stdlib/behavior/types.js.map +1 -0
  481. package/lib/stdlib/behavior/zoom-canvas-3d.d.ts +1 -2
  482. package/lib/stdlib/behavior/zoom-canvas-3d.js +8 -7
  483. package/lib/stdlib/behavior/zoom-canvas-3d.js.map +1 -1
  484. package/lib/stdlib/behavior/zoom-canvas.d.ts +1 -2
  485. package/lib/stdlib/behavior/zoom-canvas.js +21 -18
  486. package/lib/stdlib/behavior/zoom-canvas.js.map +1 -1
  487. package/lib/stdlib/data/index.d.ts +3 -0
  488. package/lib/stdlib/data/index.js +20 -0
  489. package/lib/stdlib/data/index.js.map +1 -0
  490. package/lib/stdlib/data/mapNodeSize.d.ts +12 -0
  491. package/lib/stdlib/data/mapNodeSize.js +47 -0
  492. package/lib/stdlib/data/mapNodeSize.js.map +1 -0
  493. package/lib/stdlib/data/transformV4Data.d.ts +9 -0
  494. package/lib/stdlib/data/transformV4Data.js +146 -0
  495. package/lib/stdlib/data/transformV4Data.js.map +1 -0
  496. package/lib/stdlib/data/validateData.d.ts +9 -0
  497. package/lib/stdlib/data/validateData.js +102 -0
  498. package/lib/stdlib/data/validateData.js.map +1 -0
  499. package/lib/stdlib/index.d.ts +113 -69
  500. package/lib/stdlib/index.js +188 -67
  501. package/lib/stdlib/index.js.map +1 -1
  502. package/lib/stdlib/item/combo/index.d.ts +2 -0
  503. package/lib/stdlib/item/combo/index.js +19 -0
  504. package/lib/stdlib/item/combo/index.js.map +1 -0
  505. package/lib/stdlib/item/combo/rect.d.ts +31 -0
  506. package/lib/stdlib/item/combo/rect.js +69 -0
  507. package/lib/stdlib/item/combo/rect.js.map +1 -0
  508. package/lib/stdlib/item/edge/base.d.ts +10 -1
  509. package/lib/stdlib/item/edge/base.js +35 -4
  510. package/lib/stdlib/item/edge/base.js.map +1 -1
  511. package/{esm/stdlib/item/edge/cubic-horizon.d.ts → lib/stdlib/item/edge/cubic-horizontal.d.ts} +6 -7
  512. package/lib/stdlib/item/edge/{cubic-horizon.js → cubic-horizontal.js} +20 -35
  513. package/lib/stdlib/item/edge/cubic-horizontal.js.map +1 -0
  514. package/lib/stdlib/item/edge/cubic-vertical.d.ts +7 -8
  515. package/lib/stdlib/item/edge/cubic-vertical.js +17 -32
  516. package/lib/stdlib/item/edge/cubic-vertical.js.map +1 -1
  517. package/lib/stdlib/item/edge/cubic.d.ts +7 -8
  518. package/lib/stdlib/item/edge/cubic.js +22 -5
  519. package/lib/stdlib/item/edge/cubic.js.map +1 -1
  520. package/lib/stdlib/item/edge/index.d.ts +5 -0
  521. package/lib/stdlib/item/edge/index.js +5 -0
  522. package/lib/stdlib/item/edge/index.js.map +1 -1
  523. package/lib/stdlib/item/edge/line.d.ts +1 -1
  524. package/lib/stdlib/item/edge/line.js +16 -1
  525. package/lib/stdlib/item/edge/line.js.map +1 -1
  526. package/lib/stdlib/item/edge/loop.d.ts +32 -0
  527. package/lib/stdlib/item/edge/loop.js +119 -0
  528. package/lib/stdlib/item/edge/loop.js.map +1 -0
  529. package/lib/stdlib/item/edge/polyline.d.ts +44 -0
  530. package/lib/stdlib/item/edge/polyline.js +96 -0
  531. package/lib/stdlib/item/edge/polyline.js.map +1 -0
  532. package/lib/stdlib/item/edge/quadratic.d.ts +5 -6
  533. package/lib/stdlib/item/edge/quadratic.js +33 -21
  534. package/lib/stdlib/item/edge/quadratic.js.map +1 -1
  535. package/lib/stdlib/item/node/base.d.ts +45 -1
  536. package/lib/stdlib/item/node/base.js +97 -12
  537. package/lib/stdlib/item/node/base.js.map +1 -1
  538. package/lib/stdlib/item/node/base3d.js +1 -1
  539. package/lib/stdlib/item/node/base3d.js.map +1 -1
  540. package/lib/stdlib/item/node/circle.js +5 -5
  541. package/lib/stdlib/item/node/circle.js.map +1 -1
  542. package/lib/stdlib/item/node/diamond.d.ts +32 -0
  543. package/lib/stdlib/item/node/diamond.js +83 -0
  544. package/lib/stdlib/item/node/diamond.js.map +1 -0
  545. package/lib/stdlib/item/node/donut.d.ts +70 -0
  546. package/lib/stdlib/item/node/donut.js +211 -0
  547. package/lib/stdlib/item/node/donut.js.map +1 -0
  548. package/lib/stdlib/item/node/ellipse.d.ts +32 -0
  549. package/lib/stdlib/item/node/ellipse.js +75 -0
  550. package/lib/stdlib/item/node/ellipse.js.map +1 -0
  551. package/lib/stdlib/item/node/hexagon.d.ts +33 -0
  552. package/lib/stdlib/item/node/hexagon.js +106 -0
  553. package/lib/stdlib/item/node/hexagon.js.map +1 -0
  554. package/lib/stdlib/item/node/index.d.ts +7 -0
  555. package/lib/stdlib/item/node/index.js +7 -0
  556. package/lib/stdlib/item/node/index.js.map +1 -1
  557. package/lib/stdlib/item/node/modelRect.d.ts +61 -0
  558. package/lib/stdlib/item/node/modelRect.js +190 -0
  559. package/lib/stdlib/item/node/modelRect.js.map +1 -0
  560. package/lib/stdlib/item/node/rect.d.ts +1 -0
  561. package/lib/stdlib/item/node/rect.js +16 -0
  562. package/lib/stdlib/item/node/rect.js.map +1 -1
  563. package/lib/stdlib/item/node/star.d.ts +34 -0
  564. package/lib/stdlib/item/node/star.js +119 -0
  565. package/lib/stdlib/item/node/star.js.map +1 -0
  566. package/lib/stdlib/item/node/triangle.d.ts +44 -0
  567. package/lib/stdlib/item/node/triangle.js +181 -0
  568. package/lib/stdlib/item/node/triangle.js.map +1 -0
  569. package/lib/stdlib/plugin/fisheye/index.d.ts +32 -4
  570. package/lib/stdlib/plugin/fisheye/index.js +3 -1
  571. package/lib/stdlib/plugin/fisheye/index.js.map +1 -1
  572. package/lib/stdlib/plugin/grid/index.d.ts +36 -0
  573. package/lib/stdlib/plugin/grid/index.js +85 -0
  574. package/lib/stdlib/plugin/grid/index.js.map +1 -0
  575. package/lib/stdlib/plugin/history/combo-command.d.ts +9 -0
  576. package/lib/stdlib/plugin/history/combo-command.js +25 -0
  577. package/lib/stdlib/plugin/history/combo-command.js.map +1 -0
  578. package/lib/stdlib/plugin/history/command.d.ts +18 -0
  579. package/lib/stdlib/plugin/history/command.js +54 -0
  580. package/lib/stdlib/plugin/history/command.js.map +1 -0
  581. package/lib/stdlib/plugin/history/index.d.ts +112 -0
  582. package/lib/stdlib/plugin/history/index.js +283 -0
  583. package/lib/stdlib/plugin/history/index.js.map +1 -0
  584. package/lib/stdlib/plugin/history/item-data-command.d.ts +14 -0
  585. package/lib/stdlib/plugin/history/item-data-command.js +67 -0
  586. package/lib/stdlib/plugin/history/item-data-command.js.map +1 -0
  587. package/lib/stdlib/plugin/history/layer-updated-command.d.ts +9 -0
  588. package/lib/stdlib/plugin/history/layer-updated-command.js +25 -0
  589. package/lib/stdlib/plugin/history/layer-updated-command.js.map +1 -0
  590. package/lib/stdlib/plugin/history/state-updated-command.d.ts +9 -0
  591. package/lib/stdlib/plugin/history/state-updated-command.js +24 -0
  592. package/lib/stdlib/plugin/history/state-updated-command.js.map +1 -0
  593. package/lib/stdlib/plugin/history/visibility-updated-command.d.ts +10 -0
  594. package/lib/stdlib/plugin/history/visibility-updated-command.js +27 -0
  595. package/lib/stdlib/plugin/history/visibility-updated-command.js.map +1 -0
  596. package/lib/stdlib/plugin/hull/bubbleset.d.ts +9 -0
  597. package/lib/stdlib/plugin/hull/bubbleset.js +596 -0
  598. package/lib/stdlib/plugin/hull/bubbleset.js.map +1 -0
  599. package/lib/stdlib/plugin/hull/convexHull.d.ts +14 -0
  600. package/lib/stdlib/plugin/hull/convexHull.js +61 -0
  601. package/lib/stdlib/plugin/hull/convexHull.js.map +1 -0
  602. package/lib/stdlib/plugin/hull/hullComponent.d.ts +87 -0
  603. package/lib/stdlib/plugin/hull/hullComponent.js +385 -0
  604. package/lib/stdlib/plugin/hull/hullComponent.js.map +1 -0
  605. package/lib/stdlib/plugin/hull/index.d.ts +59 -0
  606. package/lib/stdlib/plugin/hull/index.js +167 -0
  607. package/lib/stdlib/plugin/hull/index.js.map +1 -0
  608. package/lib/stdlib/plugin/hull/types.d.ts +15 -0
  609. package/lib/stdlib/plugin/hull/types.js +3 -0
  610. package/lib/stdlib/plugin/hull/types.js.map +1 -0
  611. package/lib/stdlib/plugin/hull/util.d.ts +77 -0
  612. package/lib/stdlib/plugin/hull/util.js +419 -0
  613. package/lib/stdlib/plugin/hull/util.js.map +1 -0
  614. package/lib/stdlib/plugin/index.d.ts +8 -0
  615. package/lib/stdlib/plugin/index.js +25 -0
  616. package/lib/stdlib/plugin/index.js.map +1 -0
  617. package/lib/stdlib/plugin/legend/index.d.ts +45 -3
  618. package/lib/stdlib/plugin/legend/index.js +46 -40
  619. package/lib/stdlib/plugin/legend/index.js.map +1 -1
  620. package/lib/stdlib/plugin/menu/index.d.ts +18 -5
  621. package/lib/stdlib/plugin/menu/index.js +5 -3
  622. package/lib/stdlib/plugin/menu/index.js.map +1 -1
  623. package/lib/stdlib/plugin/minimap/index.d.ts +11 -3
  624. package/lib/stdlib/plugin/minimap/index.js +19 -20
  625. package/lib/stdlib/plugin/minimap/index.js.map +1 -1
  626. package/lib/stdlib/plugin/toolbar/index.d.ts +59 -0
  627. package/lib/stdlib/plugin/toolbar/index.js +222 -0
  628. package/lib/stdlib/plugin/toolbar/index.js.map +1 -0
  629. package/lib/stdlib/plugin/tooltip/index.d.ts +24 -3
  630. package/lib/stdlib/plugin/tooltip/index.js +14 -12
  631. package/lib/stdlib/plugin/tooltip/index.js.map +1 -1
  632. package/lib/stdlib/plugin/types.d.ts +8 -0
  633. package/lib/stdlib/plugin/types.js +3 -0
  634. package/lib/stdlib/plugin/types.js.map +1 -0
  635. package/lib/stdlib/theme/dark.d.ts +1 -2
  636. package/lib/stdlib/theme/dark.js +10 -1
  637. package/lib/stdlib/theme/dark.js.map +1 -1
  638. package/lib/stdlib/theme/index.d.ts +2 -0
  639. package/lib/stdlib/theme/index.js +19 -0
  640. package/lib/stdlib/theme/index.js.map +1 -0
  641. package/lib/stdlib/theme/light.d.ts +1 -2
  642. package/lib/stdlib/theme/light.js +13 -2
  643. package/lib/stdlib/theme/light.js.map +1 -1
  644. package/lib/stdlib/themeSolver/base.d.ts +1 -1
  645. package/lib/stdlib/themeSolver/base.js +2 -1
  646. package/lib/stdlib/themeSolver/base.js.map +1 -1
  647. package/lib/stdlib/themeSolver/index.d.ts +3 -0
  648. package/lib/stdlib/themeSolver/index.js +20 -0
  649. package/lib/stdlib/themeSolver/index.js.map +1 -0
  650. package/lib/stdlib/themeSolver/spec.d.ts +2 -4
  651. package/lib/stdlib/themeSolver/spec.js +4 -6
  652. package/lib/stdlib/themeSolver/spec.js.map +1 -1
  653. package/lib/stdlib/themeSolver/subject.d.ts +2 -4
  654. package/lib/stdlib/themeSolver/subject.js +4 -4
  655. package/lib/stdlib/themeSolver/subject.js.map +1 -1
  656. package/lib/types/behavior.js.map +1 -1
  657. package/lib/types/combo.d.ts +3 -4
  658. package/lib/types/common.d.ts +10 -0
  659. package/lib/types/data.d.ts +10 -4
  660. package/lib/types/edge.d.ts +17 -2
  661. package/lib/types/graph.d.ts +129 -16
  662. package/lib/types/history.d.ts +28 -0
  663. package/lib/types/history.js +9 -0
  664. package/lib/types/history.js.map +1 -0
  665. package/lib/types/hook.d.ts +25 -5
  666. package/lib/types/index.d.ts +11 -5
  667. package/lib/types/index.js.map +1 -1
  668. package/lib/types/item.d.ts +10 -4
  669. package/lib/types/item.js.map +1 -1
  670. package/lib/types/layout.d.ts +4 -1
  671. package/lib/types/loop.d.ts +21 -0
  672. package/lib/types/loop.js +15 -0
  673. package/lib/types/loop.js.map +1 -0
  674. package/lib/types/node.d.ts +87 -6
  675. package/lib/types/plugin.d.ts +4 -0
  676. package/lib/types/plugin.js.map +1 -1
  677. package/lib/types/spec.d.ts +26 -9
  678. package/lib/types/theme.d.ts +76 -10
  679. package/lib/types/theme.js +1 -2
  680. package/lib/types/theme.js.map +1 -1
  681. package/lib/util/animate.d.ts +2 -2
  682. package/lib/util/animate.js +52 -17
  683. package/lib/util/animate.js.map +1 -1
  684. package/lib/util/array.d.ts +8 -0
  685. package/lib/util/array.js +13 -2
  686. package/lib/util/array.js.map +1 -1
  687. package/lib/util/arrow.d.ts +17 -0
  688. package/lib/util/arrow.js +60 -0
  689. package/lib/util/arrow.js.map +1 -0
  690. package/lib/util/bbox.d.ts +106 -0
  691. package/lib/util/bbox.js +273 -0
  692. package/lib/util/bbox.js.map +1 -0
  693. package/lib/util/behavior.d.ts +2 -0
  694. package/lib/util/behavior.js +16 -0
  695. package/lib/util/behavior.js.map +1 -0
  696. package/lib/util/canvas.d.ts +1 -2
  697. package/lib/util/canvas.js +3 -20
  698. package/lib/util/canvas.js.map +1 -1
  699. package/lib/util/data.d.ts +33 -2
  700. package/lib/util/data.js +121 -6
  701. package/lib/util/data.js.map +1 -1
  702. package/lib/util/event.d.ts +22 -2
  703. package/lib/util/event.js +56 -1
  704. package/lib/util/event.js.map +1 -1
  705. package/lib/util/extend.d.ts +8 -2
  706. package/lib/util/extend.js.map +1 -1
  707. package/lib/util/index.d.ts +41 -3
  708. package/lib/util/index.js +20 -1
  709. package/lib/util/index.js.map +1 -1
  710. package/lib/util/item.d.ts +1 -1
  711. package/lib/util/item.js +7 -5
  712. package/lib/util/item.js.map +1 -1
  713. package/lib/util/layout.d.ts +40 -0
  714. package/lib/util/layout.js +172 -0
  715. package/lib/util/layout.js.map +1 -0
  716. package/lib/util/loop.d.ts +37 -0
  717. package/lib/util/loop.js +111 -0
  718. package/lib/util/loop.js.map +1 -0
  719. package/lib/util/mapper.js +4 -9
  720. package/lib/util/mapper.js.map +1 -1
  721. package/lib/util/math.d.ts +15 -0
  722. package/lib/util/math.js +17 -1
  723. package/lib/util/math.js.map +1 -1
  724. package/lib/util/mock.d.ts +30 -0
  725. package/lib/util/mock.js +73 -0
  726. package/lib/util/mock.js.map +1 -0
  727. package/lib/util/path.d.ts +11 -0
  728. package/lib/util/path.js +49 -0
  729. package/lib/util/path.js.map +1 -0
  730. package/lib/util/point.d.ts +24 -2
  731. package/lib/util/point.js +31 -3
  732. package/lib/util/point.js.map +1 -1
  733. package/lib/util/polyline.d.ts +113 -0
  734. package/lib/util/polyline.js +524 -0
  735. package/lib/util/polyline.js.map +1 -0
  736. package/lib/util/router.d.ts +31 -0
  737. package/lib/util/router.js +384 -0
  738. package/lib/util/router.js.map +1 -0
  739. package/lib/util/shape.d.ts +3 -3
  740. package/lib/util/shape.js +19 -3
  741. package/lib/util/shape.js.map +1 -1
  742. package/lib/util/shape3d.d.ts +1 -1
  743. package/lib/util/shape3d.js +11 -5
  744. package/lib/util/shape3d.js.map +1 -1
  745. package/lib/util/type.d.ts +6 -0
  746. package/lib/util/type.js +9 -2
  747. package/lib/util/type.js.map +1 -1
  748. package/lib/util/zoom.d.ts +1 -1
  749. package/lib/util/zoom.js +6 -2
  750. package/lib/util/zoom.js.map +1 -1
  751. package/package.json +35 -15
  752. package/src/api-doc/behaviors.ts +2 -0
  753. package/src/api-doc/graph.ts +4 -0
  754. package/src/api-doc/item.ts +43 -0
  755. package/src/api-doc/layout.ts +13 -0
  756. package/src/api-doc/plugins.ts +1 -0
  757. package/src/api-doc/readme.md +59 -0
  758. package/src/api-doc/types.ts +2 -0
  759. package/src/api-doc/util.ts +3 -0
  760. package/src/constant/shape.ts +4 -1
  761. package/src/index.ts +14 -4
  762. package/src/item/combo.ts +105 -18
  763. package/src/item/edge.ts +68 -18
  764. package/src/item/item.ts +138 -82
  765. package/src/item/node.ts +100 -54
  766. package/src/runtime/controller/data.ts +410 -258
  767. package/src/runtime/controller/interaction.ts +8 -4
  768. package/src/runtime/controller/item.ts +690 -252
  769. package/src/runtime/controller/layout.ts +147 -14
  770. package/src/runtime/controller/plugin.ts +47 -10
  771. package/src/runtime/controller/theme.ts +8 -4
  772. package/src/runtime/graph.ts +721 -130
  773. package/src/stdlib/behavior/activate-relations.ts +14 -11
  774. package/src/stdlib/behavior/brush-select.ts +4 -5
  775. package/src/stdlib/behavior/click-select.ts +12 -10
  776. package/src/stdlib/behavior/collapse-expand-combo.ts +1 -3
  777. package/src/stdlib/behavior/collapse-expand-tree.ts +106 -0
  778. package/src/stdlib/behavior/drag-canvas.ts +15 -13
  779. package/src/stdlib/behavior/drag-combo.ts +109 -53
  780. package/src/stdlib/behavior/drag-node.ts +220 -83
  781. package/src/stdlib/behavior/hover-activate.ts +1 -2
  782. package/src/stdlib/behavior/index.ts +15 -0
  783. package/src/stdlib/behavior/lasso-select.ts +6 -2
  784. package/src/stdlib/behavior/orbit-canvas-3d.ts +2 -4
  785. package/src/stdlib/behavior/rotate-canvas-3d.ts +1 -3
  786. package/src/stdlib/behavior/track-canvas-3d.ts +2 -4
  787. package/src/stdlib/behavior/types.ts +15 -0
  788. package/src/stdlib/behavior/zoom-canvas-3d.ts +5 -7
  789. package/src/stdlib/behavior/zoom-canvas.ts +19 -19
  790. package/src/stdlib/data/index.ts +3 -0
  791. package/src/stdlib/data/mapNodeSize.ts +67 -0
  792. package/src/stdlib/data/transformV4Data.ts +207 -0
  793. package/src/stdlib/data/validateData.ts +146 -0
  794. package/src/stdlib/index.ts +215 -53
  795. package/src/stdlib/item/combo/index.ts +2 -0
  796. package/src/stdlib/item/combo/rect.ts +123 -0
  797. package/src/stdlib/item/edge/base.ts +66 -4
  798. package/src/stdlib/item/edge/{cubic-horizon.ts → cubic-horizontal.ts} +25 -53
  799. package/src/stdlib/item/edge/cubic-vertical.ts +24 -55
  800. package/src/stdlib/item/edge/cubic.ts +36 -36
  801. package/src/stdlib/item/edge/index.ts +5 -0
  802. package/src/stdlib/item/edge/line.ts +14 -15
  803. package/src/stdlib/item/edge/loop.ts +162 -0
  804. package/src/stdlib/item/edge/polyline.ts +161 -0
  805. package/src/stdlib/item/edge/quadratic.ts +34 -37
  806. package/src/stdlib/item/node/base.ts +116 -12
  807. package/src/stdlib/item/node/base3d.ts +2 -0
  808. package/src/stdlib/item/node/circle.ts +5 -5
  809. package/src/stdlib/item/node/diamond.ts +144 -0
  810. package/src/stdlib/item/node/donut.ts +368 -0
  811. package/src/stdlib/item/node/ellipse.ts +128 -0
  812. package/src/stdlib/item/node/hexagon.ts +168 -0
  813. package/src/stdlib/item/node/index.ts +7 -0
  814. package/src/stdlib/item/node/modelRect.ts +405 -0
  815. package/src/stdlib/item/node/rect.ts +17 -0
  816. package/src/stdlib/item/node/star.ts +181 -0
  817. package/src/stdlib/item/node/triangle.ts +265 -0
  818. package/src/stdlib/plugin/fisheye/index.ts +35 -6
  819. package/src/stdlib/plugin/grid/index.ts +125 -0
  820. package/src/stdlib/plugin/history/combo-command.ts +28 -0
  821. package/src/stdlib/plugin/history/command.ts +81 -0
  822. package/src/stdlib/plugin/history/index.ts +347 -0
  823. package/src/stdlib/plugin/history/item-data-command.ts +96 -0
  824. package/src/stdlib/plugin/history/layer-updated-command.ts +28 -0
  825. package/src/stdlib/plugin/history/state-updated-command.ts +36 -0
  826. package/src/stdlib/plugin/history/visibility-updated-command.ts +41 -0
  827. package/src/stdlib/plugin/hull/bubbleset.ts +828 -0
  828. package/src/stdlib/plugin/hull/convexHull.ts +68 -0
  829. package/src/stdlib/plugin/hull/hullComponent.ts +501 -0
  830. package/src/stdlib/plugin/hull/index.ts +234 -0
  831. package/src/stdlib/plugin/hull/types.ts +15 -0
  832. package/src/stdlib/plugin/hull/util.ts +511 -0
  833. package/src/stdlib/plugin/index.ts +8 -0
  834. package/src/stdlib/plugin/legend/index.ts +122 -61
  835. package/src/stdlib/plugin/menu/index.ts +21 -6
  836. package/src/stdlib/plugin/minimap/index.ts +35 -26
  837. package/src/stdlib/plugin/toolbar/index.ts +257 -0
  838. package/src/stdlib/plugin/tooltip/index.ts +38 -18
  839. package/src/stdlib/plugin/types.ts +8 -0
  840. package/src/stdlib/theme/dark.ts +9 -1
  841. package/src/stdlib/theme/index.ts +2 -0
  842. package/src/stdlib/theme/light.ts +13 -3
  843. package/src/stdlib/themeSolver/base.ts +1 -1
  844. package/src/stdlib/themeSolver/index.ts +3 -0
  845. package/src/stdlib/themeSolver/spec.ts +2 -5
  846. package/src/stdlib/themeSolver/subject.ts +2 -5
  847. package/src/types/behavior.ts +0 -1
  848. package/src/types/combo.ts +3 -4
  849. package/src/types/common.ts +13 -0
  850. package/src/types/data.ts +23 -4
  851. package/src/types/edge.ts +28 -4
  852. package/src/types/graph.ts +161 -11
  853. package/src/types/history.ts +30 -0
  854. package/src/types/hook.ts +29 -6
  855. package/src/types/index.ts +37 -12
  856. package/src/types/item.ts +15 -2
  857. package/src/types/layout.ts +20 -16
  858. package/src/types/loop.ts +23 -0
  859. package/src/types/node.ts +91 -11
  860. package/src/types/plugin.ts +7 -1
  861. package/src/types/spec.ts +30 -13
  862. package/src/types/theme.ts +80 -10
  863. package/src/util/animate.ts +58 -17
  864. package/src/util/array.ts +12 -1
  865. package/src/util/arrow.ts +62 -0
  866. package/src/util/bbox.ts +298 -0
  867. package/src/util/behavior.ts +14 -0
  868. package/src/util/canvas.ts +6 -24
  869. package/src/util/data.ts +134 -5
  870. package/src/util/event.ts +86 -2
  871. package/src/util/extend.ts +8 -2
  872. package/src/util/index.ts +31 -1
  873. package/src/util/item.ts +11 -8
  874. package/src/util/layout.ts +165 -0
  875. package/src/util/loop.ts +145 -0
  876. package/src/util/mapper.ts +10 -9
  877. package/src/util/math.ts +24 -0
  878. package/src/util/mock.ts +72 -0
  879. package/src/util/path.ts +52 -0
  880. package/src/util/point.ts +33 -2
  881. package/src/util/polyline.ts +676 -0
  882. package/src/util/router.ts +552 -0
  883. package/src/util/shape.ts +23 -7
  884. package/src/util/shape3d.ts +16 -11
  885. package/src/util/type.ts +8 -1
  886. package/src/util/zoom.ts +7 -3
  887. package/esm/stdlib/data/comboFromNode.d.ts +0 -9
  888. package/esm/stdlib/data/comboFromNode.js +0 -28
  889. package/esm/stdlib/data/comboFromNode.js.map +0 -1
  890. package/esm/stdlib/item/edge/cubic-horizon.js.map +0 -1
  891. package/lib/stdlib/data/comboFromNode.d.ts +0 -9
  892. package/lib/stdlib/data/comboFromNode.js +0 -32
  893. package/lib/stdlib/data/comboFromNode.js.map +0 -1
  894. package/lib/stdlib/item/edge/cubic-horizon.js.map +0 -1
  895. package/src/stdlib/data/comboFromNode.ts +0 -28
@@ -1,8 +1,21 @@
1
1
  import EventEmitter from '@antv/event-emitter';
2
- import { AABB, Canvas, DisplayObject, PointLike, runtime } from '@antv/g';
2
+ import { AABB, Canvas, DisplayObject, PointLike } from '@antv/g';
3
3
  import { GraphChange, ID } from '@antv/graphlib';
4
- import { isArray, isNil, isNumber, isObject, isString } from '@antv/util';
5
4
  import {
5
+ clone,
6
+ groupBy,
7
+ isArray,
8
+ isEmpty,
9
+ isEqual,
10
+ isNil,
11
+ isNumber,
12
+ isObject,
13
+ isString,
14
+ map,
15
+ } from '@antv/util';
16
+ import { History } from '../stdlib/plugin/history';
17
+ import { Command } from '../stdlib/plugin/history/command';
18
+ import type {
6
19
  ComboUserModel,
7
20
  EdgeUserModel,
8
21
  GraphData,
@@ -10,22 +23,23 @@ import {
10
23
  NodeUserModel,
11
24
  Specification,
12
25
  } from '../types';
13
- import { CameraAnimationOptions } from '../types/animate';
14
- import { BehaviorOptionsOf, BehaviorRegistry } from '../types/behavior';
15
- import { ComboModel } from '../types/combo';
16
- import { Padding, Point } from '../types/common';
17
- import { DataChangeType, GraphCore } from '../types/data';
18
- import { EdgeModel, EdgeModelData } from '../types/edge';
19
- import { Hooks, ViewportChangeHookParams } from '../types/hook';
20
- import { ITEM_TYPE, ShapeStyle, SHAPE_TYPE } from '../types/item';
21
- import {
26
+ import type { CameraAnimationOptions } from '../types/animate';
27
+ import type { BehaviorOptionsOf, BehaviorRegistry } from '../types/behavior';
28
+ import type { ComboDisplayModel, ComboModel } from '../types/combo';
29
+ import type { Padding, Point } from '../types/common';
30
+ import type { DataChangeType, DataConfig, GraphCore } from '../types/data';
31
+ import type { EdgeDisplayModel, EdgeModel, EdgeModelData } from '../types/edge';
32
+ import type { StackType } from '../types/history';
33
+ import type { Hooks, ViewportChangeHookParams } from '../types/hook';
34
+ import type { ITEM_TYPE, SHAPE_TYPE, ShapeStyle } from '../types/item';
35
+ import type {
22
36
  ImmediatelyInvokedLayoutOptions,
23
37
  LayoutOptions,
24
38
  StandardLayoutOptions,
25
39
  } from '../types/layout';
26
- import { NodeModel, NodeModelData } from '../types/node';
27
- import { RendererName } from '../types/render';
28
- import {
40
+ import type { NodeDisplayModel, NodeModel, NodeModelData } from '../types/node';
41
+ import type { RendererName } from '../types/render';
42
+ import type {
29
43
  ThemeOptionsOf,
30
44
  ThemeRegistry,
31
45
  ThemeSpecification,
@@ -33,6 +47,7 @@ import {
33
47
  import { FitViewRules, GraphTransformOptions } from '../types/view';
34
48
  import { changeRenderer, createCanvas } from '../util/canvas';
35
49
  import { formatPadding } from '../util/shape';
50
+ import { Plugin as PluginBase } from '../types/plugin';
36
51
  import {
37
52
  DataController,
38
53
  ExtensionController,
@@ -44,12 +59,6 @@ import {
44
59
  } from './controller';
45
60
  import { PluginController } from './controller/plugin';
46
61
  import Hook from './hooks';
47
- import { graphComboTreeDfs } from '../util/data';
48
-
49
- /**
50
- * Disable CSS parsing for better performance.
51
- */
52
- runtime.enableCSSParsing = false;
53
62
 
54
63
  export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
55
64
  extends EventEmitter
@@ -71,6 +80,7 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
71
80
  // the tag indicates all the three canvases are all ready
72
81
  private canvasReady: boolean;
73
82
  private specification: Specification<B, T>;
83
+
74
84
  private dataController: DataController;
75
85
  private interactionController: InteractionController;
76
86
  private layoutController: LayoutController;
@@ -85,6 +95,7 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
85
95
  type: 'spec',
86
96
  base: 'light',
87
97
  },
98
+ enableStack: true,
88
99
  };
89
100
 
90
101
  constructor(spec: Specification<B, T>) {
@@ -94,6 +105,7 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
94
105
  this.initHooks();
95
106
  this.initCanvas();
96
107
  this.initControllers();
108
+ this.initHistory();
97
109
 
98
110
  this.hooks.init.emit({
99
111
  canvases: {
@@ -125,8 +137,17 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
125
137
  }
126
138
 
127
139
  private initCanvas() {
128
- const { renderer, container, width, height } = this.specification;
129
- let pixelRatio;
140
+ const {
141
+ renderer,
142
+ container,
143
+ canvas,
144
+ backgroundCanvas,
145
+ transientCanvas,
146
+ width,
147
+ height,
148
+ } = this.specification;
149
+
150
+ let pixelRatio: number;
130
151
  if (renderer && !isString(renderer)) {
131
152
  // @ts-ignore
132
153
  this.rendererType = renderer.type || 'canvas';
@@ -136,55 +157,99 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
136
157
  // @ts-ignore
137
158
  this.rendererType = renderer || 'canvas';
138
159
  }
139
- const containerDOM = isString(container)
140
- ? document.getElementById(container as string)
141
- : container;
142
- if (!containerDOM) {
143
- console.error(
144
- `Create graph failed. The container for graph ${containerDOM} is not exist.`,
160
+
161
+ /**
162
+ * These 3 canvases can be passed in by users, e.g. when doing serverside rendering we can't use DOM API.
163
+ */
164
+ if (canvas) {
165
+ this.canvas = canvas;
166
+ this.backgroundCanvas = backgroundCanvas;
167
+ this.transientCanvas = transientCanvas;
168
+ this.container = container as HTMLDivElement;
169
+ } else {
170
+ const containerDOM = isString(container)
171
+ ? document.getElementById(container as string)
172
+ : (container as HTMLElement);
173
+
174
+ if (!containerDOM) {
175
+ console.error(
176
+ `Create graph failed. The container for graph ${containerDOM} is not exist.`,
177
+ );
178
+ this.destroy();
179
+ return;
180
+ }
181
+
182
+ this.container = containerDOM;
183
+ const size = [width, height];
184
+ if (size[0] === undefined) {
185
+ size[0] = containerDOM.scrollWidth;
186
+ }
187
+ if (size[1] === undefined) {
188
+ size[1] = containerDOM.scrollHeight;
189
+ }
190
+ this.backgroundCanvas = createCanvas(
191
+ this.rendererType,
192
+ containerDOM,
193
+ size[0],
194
+ size[1],
195
+ pixelRatio,
196
+ );
197
+ this.canvas = createCanvas(
198
+ this.rendererType,
199
+ containerDOM,
200
+ size[0],
201
+ size[1],
202
+ pixelRatio,
203
+ );
204
+ this.transientCanvas = createCanvas(
205
+ this.rendererType,
206
+ containerDOM,
207
+ size[0],
208
+ size[1],
209
+ pixelRatio,
145
210
  );
146
- this.destroy();
147
- return;
148
- }
149
- this.container = containerDOM;
150
- const size = [width, height];
151
- if (size[0] === undefined) {
152
- size[0] = containerDOM.scrollWidth;
153
- }
154
- if (size[1] === undefined) {
155
- size[1] = containerDOM.scrollHeight;
156
211
  }
157
212
 
158
- this.backgroundCanvas = createCanvas(
159
- this.rendererType,
160
- containerDOM,
161
- size[0],
162
- size[1],
163
- pixelRatio,
164
- );
165
- this.canvas = createCanvas(
166
- this.rendererType,
167
- containerDOM,
168
- size[0],
169
- size[1],
170
- pixelRatio,
171
- );
172
- this.transientCanvas = createCanvas(
173
- this.rendererType,
174
- containerDOM,
175
- size[0],
176
- size[1],
177
- pixelRatio,
178
- true,
179
- {
180
- pointerEvents: 'none',
181
- },
182
- );
183
213
  Promise.all(
184
214
  [this.backgroundCanvas, this.canvas, this.transientCanvas].map(
185
215
  (canvas) => canvas.ready,
186
216
  ),
187
- ).then(() => (this.canvasReady = true));
217
+ ).then(() => {
218
+ [this.backgroundCanvas, this.canvas, this.transientCanvas].forEach(
219
+ (canvas, i) => {
220
+ const $domElement = canvas
221
+ .getContextService()
222
+ .getDomElement() as unknown as HTMLElement;
223
+ if ($domElement && $domElement.style) {
224
+ $domElement.style.position = 'fixed';
225
+ $domElement.style.outline = 'none';
226
+ $domElement.tabIndex = 1; // Enable keyboard events
227
+ // Transient canvas should let interactive events go through.
228
+ if (i === 2) {
229
+ $domElement.style.pointerEvents = 'none';
230
+ }
231
+ }
232
+ },
233
+ );
234
+
235
+ this.canvasReady = true;
236
+ });
237
+ }
238
+
239
+ private initHistory() {
240
+ const { enableStack, stackCfg } = this.specification;
241
+ if (enableStack) {
242
+ const history = {
243
+ type: 'history',
244
+ key: 'history',
245
+ enableStack,
246
+ stackCfg,
247
+ };
248
+ if (!this.specification.plugins) {
249
+ this.specification.plugins = [];
250
+ }
251
+ this.specification.plugins.push(history);
252
+ }
188
253
  }
189
254
 
190
255
  /**
@@ -217,6 +282,7 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
217
282
  changes: GraphChange<NodeModelData, EdgeModelData>[];
218
283
  graphCore: GraphCore;
219
284
  theme: ThemeSpecification;
285
+ animate?: boolean;
220
286
  upsertAncestors?: boolean;
221
287
  }>({ name: 'itemchange' }),
222
288
  render: new Hook<{
@@ -226,7 +292,11 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
226
292
  }>({
227
293
  name: 'render',
228
294
  }),
229
- layout: new Hook<{ graphCore: GraphCore }>({ name: 'layout' }),
295
+ layout: new Hook<{
296
+ graphCore: GraphCore;
297
+ options?: LayoutOptions;
298
+ animate?: boolean;
299
+ }>({ name: 'layout' }),
230
300
  viewportchange: new Hook<ViewportChangeHookParams>({ name: 'viewport' }),
231
301
  modechange: new Hook<{ mode: string }>({ name: 'modechange' }),
232
302
  behaviorchange: new Hook<{
@@ -244,7 +314,11 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
244
314
  itemvisibilitychange: new Hook<{ ids: ID[]; value: boolean }>({
245
315
  name: 'itemvisibilitychange',
246
316
  }),
247
- itemzindexchange: new Hook<{ ids: ID[]; action: 'front' | 'back' }>({
317
+ itemzindexchange: new Hook<{
318
+ ids: ID[];
319
+ action: 'front' | 'back';
320
+ graphCore: GraphCore;
321
+ }>({
248
322
  name: 'itemzindexchange',
249
323
  }),
250
324
  transientupdate: new Hook<{
@@ -272,6 +346,12 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
272
346
  transient: Canvas;
273
347
  };
274
348
  }>({ name: 'init' }),
349
+ treecollapseexpand: new Hook<{
350
+ ids: ID[];
351
+ animate: boolean;
352
+ action: 'collapse' | 'expand';
353
+ graphCore: GraphCore;
354
+ }>({ name: 'treecollapseexpand' }),
275
355
  destroy: new Hook<{}>({ name: 'destroy' }),
276
356
  };
277
357
  }
@@ -282,7 +362,6 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
282
362
  public updateSpecification(spec: Specification<B, T>): Specification<B, T> {
283
363
  return Object.assign(this.specification, spec);
284
364
  }
285
-
286
365
  /**
287
366
  * Update the theme specs (configurations).
288
367
  */
@@ -318,7 +397,7 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
318
397
  * @returns
319
398
  * @group Data
320
399
  */
321
- public async read(data: GraphData) {
400
+ public async read(data: DataConfig) {
322
401
  this.hooks.datachange.emit({ data, type: 'replace' });
323
402
  const emitRender = async () => {
324
403
  this.hooks.render.emit({
@@ -328,6 +407,26 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
328
407
  });
329
408
  this.emit('afterrender');
330
409
 
410
+ this.once('afterlayout', async () => {
411
+ const { autoFit } = this.specification;
412
+ if (autoFit) {
413
+ if (autoFit === 'view') {
414
+ await this.fitView();
415
+ } else if (autoFit === 'center') {
416
+ await this.fitCenter();
417
+ } else {
418
+ const { type, effectTiming, ...others } = autoFit;
419
+ if (type === 'view') {
420
+ await this.fitView(others as any, effectTiming);
421
+ } else if (type === 'center') {
422
+ await this.fitCenter(effectTiming);
423
+ } else if (type === 'position') {
424
+ // TODO: align
425
+ await this.translateTo((others as any).position, effectTiming);
426
+ }
427
+ }
428
+ }
429
+ });
331
430
  await this.layout();
332
431
  };
333
432
  if (this.canvasReady) {
@@ -350,7 +449,7 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
350
449
  * @group Data
351
450
  */
352
451
  public async changeData(
353
- data: GraphData,
452
+ data: DataConfig,
354
453
  type: 'replace' | 'mergeReplace' = 'mergeReplace',
355
454
  ) {
356
455
  this.hooks.datachange.emit({ data, type });
@@ -369,6 +468,7 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
369
468
  * @returns
370
469
  */
371
470
  public clear() {
471
+ this.startBatch();
372
472
  this.removeData(
373
473
  'edge',
374
474
  this.getAllEdgesData().map((edge) => edge.id),
@@ -381,6 +481,7 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
381
481
  'combo',
382
482
  this.getAllCombosData().map((combo) => combo.id),
383
483
  );
484
+ this.stopBatch();
384
485
  }
385
486
 
386
487
  public getViewportCenter(): PointLike {
@@ -433,7 +534,7 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
433
534
  * @param effectTiming animation configurations
434
535
  */
435
536
  public async translateTo(
436
- { x, y }: PointLike,
537
+ { x, y }: Point,
437
538
  effectTiming?: CameraAnimationOptions,
438
539
  ) {
439
540
  const { x: cx, y: cy } = this.getViewportCenter();
@@ -448,7 +549,7 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
448
549
  */
449
550
  public async zoom(
450
551
  ratio: number,
451
- origin?: PointLike,
552
+ origin?: Point,
452
553
  effectTiming?: CameraAnimationOptions,
453
554
  ) {
454
555
  await this.transform(
@@ -620,7 +721,7 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
620
721
  public async focusItem(id: ID | ID[], effectTiming?: CameraAnimationOptions) {
621
722
  let bounds: AABB | null = null;
622
723
  for (const itemId of !isArray(id) ? [id] : id) {
623
- const item = this.itemController.getItemById(itemId);
724
+ const item = this.getItemById(itemId);
624
725
  if (item) {
625
726
  const itemBounds = item.group.getBounds();
626
727
  if (!bounds) {
@@ -642,6 +743,15 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
642
743
  }
643
744
  }
644
745
 
746
+ /**
747
+ * Get item by id. We don't want to
748
+ * @param id
749
+ * @returns Node | Edge | Combo
750
+ */
751
+ private getItemById(id: ID) {
752
+ return this.itemController.getItemById(id);
753
+ }
754
+
645
755
  /**
646
756
  * Get the size of the graph canvas.
647
757
  * @returns [width, height]
@@ -805,6 +915,28 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
805
915
  return this.dataController.findChildren(comboId, 'combo');
806
916
  }
807
917
 
918
+ /*
919
+ * Get the display model of a node / edge / combo.
920
+ * @param id item id
921
+ * @returns display model
922
+ * @group Data
923
+ */
924
+ protected getDisplayModel(
925
+ id: ID,
926
+ ): NodeDisplayModel | EdgeDisplayModel | ComboDisplayModel {
927
+ return this.itemController.findDisplayModel(id);
928
+ }
929
+
930
+ /**
931
+ * Retrieve the nearby edges for a given node using quadtree collision detection.
932
+ * @param nodeId node id
933
+ * @group Data
934
+ */
935
+ public getNearEdgesForNode(nodeId: ID): EdgeModel[] {
936
+ const { graphCore } = this.dataController;
937
+ return this.itemController.findNearEdgesByNode(nodeId, graphCore);
938
+ }
939
+
808
940
  /**
809
941
  * Find items which has the state.
810
942
  * @param itemType item type
@@ -832,7 +964,6 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
832
964
  * Add one or more node/edge/combo data to the graph.
833
965
  * @param itemType item type
834
966
  * @param model user data
835
- * @param stack whether push this operation to stack
836
967
  * @returns whether success
837
968
  * @group Data
838
969
  */
@@ -845,7 +976,6 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
845
976
  | NodeUserModel[]
846
977
  | EdgeUserModel[]
847
978
  | ComboUserModel[],
848
- stack?: boolean,
849
979
  ):
850
980
  | NodeModel
851
981
  | EdgeModel
@@ -859,13 +989,20 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
859
989
  const { specification } = this.themeController;
860
990
  graphCore.once('changed', (event) => {
861
991
  if (!event.changes.length) return;
992
+ const changes = event.changes;
862
993
  this.hooks.itemchange.emit({
863
994
  type: itemType,
864
995
  changes: graphCore.reduceChanges(event.changes),
865
996
  graphCore,
866
997
  theme: specification,
867
998
  });
868
- this.emit('afteritemchange', { type: itemType, action: 'add', models });
999
+ this.emit('afteritemchange', {
1000
+ type: itemType,
1001
+ action: 'add',
1002
+ models,
1003
+ apiName: 'addData',
1004
+ changes,
1005
+ });
869
1006
  });
870
1007
 
871
1008
  const modelArr = isArray(models) ? models : [models];
@@ -884,11 +1021,10 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
884
1021
  /**
885
1022
  * Remove one or more node/edge/combo data from the graph.
886
1023
  * @param item the item to be removed
887
- * @param stack whether push this operation to stack
888
1024
  * @returns whether success
889
1025
  * @group Data
890
1026
  */
891
- public removeData(itemType: ITEM_TYPE, ids: ID | ID[], stack?: boolean) {
1027
+ public removeData(itemType: ITEM_TYPE, ids: ID | ID[]) {
892
1028
  const idArr = isArray(ids) ? ids : [ids];
893
1029
  const data = { nodes: [], edges: [], combos: [] };
894
1030
  const { userGraphCore, graphCore } = this.dataController;
@@ -898,24 +1034,84 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
898
1034
  data[`${itemType}s`] = idArr.map((id) => getItem.bind(userGraphCore)(id));
899
1035
  graphCore.once('changed', (event) => {
900
1036
  if (!event.changes.length) return;
1037
+ const changes = event.changes;
901
1038
  this.hooks.itemchange.emit({
902
1039
  type: itemType,
903
1040
  changes: event.changes,
904
1041
  graphCore,
905
1042
  theme: specification,
906
1043
  });
907
- this.emit('afteritemchange', { type: itemType, action: 'remove', ids });
1044
+ this.emit('afteritemchange', {
1045
+ type: itemType,
1046
+ action: 'remove',
1047
+ ids: idArr,
1048
+ apiName: 'removeData',
1049
+ changes,
1050
+ });
908
1051
  });
909
1052
  this.hooks.datachange.emit({
910
1053
  data,
911
1054
  type: 'remove',
912
1055
  });
913
1056
  }
1057
+ /**
1058
+ * Extends the fields of oldValue and newValue
1059
+ * to make sure they both contain the union set of their original fields.
1060
+ * The missing fields' values are filled using data from displayModel data.
1061
+ * @param changes
1062
+ * @returns
1063
+ */
1064
+ private extendChanges(changes) {
1065
+ return changes
1066
+ .map((change) => {
1067
+ const { id, propertyName, oldValue, newValue } = change;
1068
+ if (!oldValue || !newValue) return change;
1069
+ if (propertyName) {
1070
+ if (oldValue !== newValue) return change;
1071
+ return false;
1072
+ }
1073
+
1074
+ const displayData = this.getItemById(id).displayModel.data;
1075
+ const oldFields = Object.keys(oldValue);
1076
+ const newFields = Object.keys(newValue);
1077
+ const commonFields = [...new Set([...oldFields, ...newFields])];
1078
+
1079
+ commonFields.forEach((field) => {
1080
+ if (!Object.prototype.hasOwnProperty.call(oldValue, field)) {
1081
+ oldValue[field] = displayData[field];
1082
+ }
1083
+ if (!Object.prototype.hasOwnProperty.call(newValue, field)) {
1084
+ newValue[field] = displayData[field];
1085
+ }
1086
+ });
1087
+
1088
+ if (
1089
+ (oldValue.x === undefined || Number.isNaN(oldValue.x)) &&
1090
+ !oldValue._isCombo
1091
+ )
1092
+ oldValue.x = 0;
1093
+ if (
1094
+ (oldValue.y === undefined || Number.isNaN(oldValue.x)) &&
1095
+ !oldValue._isCombo
1096
+ )
1097
+ oldValue.y = 0;
1098
+ if (Number.isNaN(newValue.x)) delete newValue.x;
1099
+ if (Number.isNaN(newValue.y)) delete newValue.y;
1100
+
1101
+ if (isEqual(newValue, oldValue)) return false;
1102
+
1103
+ return {
1104
+ ...change,
1105
+ newValue,
1106
+ oldValue,
1107
+ };
1108
+ })
1109
+ .filter(Boolean);
1110
+ }
914
1111
  /**
915
1112
  * Update one or more node/edge/combo data on the graph.
916
1113
  * @param {ITEM_TYPE} itemType 'node' | 'edge' | 'combo'
917
1114
  * @param models new configurations for every node/edge/combo, which has id field to indicate the specific item
918
- * @param {boolean} stack whether push this operation into graph's stack, true by default
919
1115
  * @group Data
920
1116
  */
921
1117
  public updateData(
@@ -929,7 +1125,6 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
929
1125
  | Partial<EdgeUserModel>[]
930
1126
  | Partial<ComboUserModel>[]
931
1127
  >,
932
- stack?: boolean,
933
1128
  ):
934
1129
  | NodeModel
935
1130
  | EdgeModel
@@ -944,6 +1139,7 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
944
1139
  const { graphCore } = this.dataController;
945
1140
  const { specification } = this.themeController;
946
1141
  graphCore.once('changed', (event) => {
1142
+ const changes = this.extendChanges(clone(event.changes));
947
1143
  this.hooks.itemchange.emit({
948
1144
  type: itemType,
949
1145
  changes: event.changes,
@@ -954,6 +1150,8 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
954
1150
  type: itemType,
955
1151
  action: 'update',
956
1152
  models,
1153
+ apiName: 'updateData',
1154
+ changes,
957
1155
  });
958
1156
  });
959
1157
 
@@ -972,7 +1170,6 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
972
1170
  * Update one or more nodes' positions,
973
1171
  * do not update other styles which leads to better performance than updating positions by updateData.
974
1172
  * @param models new configurations with x and y for every node, which has id field to indicate the specific item
975
- * @param {boolean} stack whether push this operation into graph's stack, true by default
976
1173
  * @group Data
977
1174
  */
978
1175
  public updateNodePosition(
@@ -982,9 +1179,21 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
982
1179
  ComboUserModel | Partial<NodeUserModel>[] | Partial<ComboUserModel>[]
983
1180
  >,
984
1181
  upsertAncestors?: boolean,
1182
+ disableAnimate = false,
1183
+ callback?: (
1184
+ model: NodeModel | EdgeModel | ComboModel,
1185
+ canceled?: boolean,
1186
+ ) => void,
985
1187
  stack?: boolean,
986
1188
  ) {
987
- return this.updatePosition('node', models, upsertAncestors, stack);
1189
+ return this.updatePosition(
1190
+ 'node',
1191
+ models,
1192
+ upsertAncestors,
1193
+ disableAnimate,
1194
+ callback,
1195
+ stack,
1196
+ );
988
1197
  }
989
1198
 
990
1199
  /**
@@ -992,7 +1201,6 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
992
1201
  * do not update other styles which leads to better performance than updating positions by updateData.
993
1202
  * In fact, it changes the succeed nodes positions to affect the combo's position, but not modify the combo's position directly.
994
1203
  * @param models new configurations with x and y for every combo, which has id field to indicate the specific item
995
- * @param {boolean} stack whether push this operation into graph's stack, true by default
996
1204
  * @group Data
997
1205
  */
998
1206
  public updateComboPosition(
@@ -1002,9 +1210,32 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1002
1210
  ComboUserModel | Partial<NodeUserModel>[] | Partial<ComboUserModel>[]
1003
1211
  >,
1004
1212
  upsertAncestors?: boolean,
1213
+ disableAnimate = false,
1214
+ callback?: (model: NodeModel | EdgeModel | ComboModel) => void,
1005
1215
  stack?: boolean,
1006
1216
  ) {
1007
- return this.updatePosition('combo', models, upsertAncestors, stack);
1217
+ return this.updatePosition(
1218
+ 'combo',
1219
+ models,
1220
+ upsertAncestors,
1221
+ disableAnimate,
1222
+ callback,
1223
+ stack,
1224
+ );
1225
+ }
1226
+
1227
+ /**
1228
+ * Get history plugin instance
1229
+ */
1230
+ private getHistoryPlugin(): History {
1231
+ if (
1232
+ !this.specification.enableStack ||
1233
+ !this.pluginController.hasPlugin('history')
1234
+ ) {
1235
+ console.error('The history plugin is not loaded or initialized.');
1236
+ return;
1237
+ }
1238
+ return this.pluginController.getPlugin('history') as History;
1008
1239
  }
1009
1240
 
1010
1241
  private updatePosition(
@@ -1015,6 +1246,11 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1015
1246
  ComboUserModel | Partial<NodeUserModel>[] | Partial<ComboUserModel>[]
1016
1247
  >,
1017
1248
  upsertAncestors?: boolean,
1249
+ disableAnimate = false,
1250
+ callback?: (
1251
+ model: NodeModel | EdgeModel | ComboModel,
1252
+ canceled?: boolean,
1253
+ ) => void,
1018
1254
  stack?: boolean,
1019
1255
  ) {
1020
1256
  const modelArr = isArray(models) ? models : [models];
@@ -1022,6 +1258,9 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1022
1258
  const { specification } = this.themeController;
1023
1259
  graphCore.once('changed', (event) => {
1024
1260
  if (!event.changes.length) return;
1261
+ const changes = event.changes.filter(
1262
+ (change) => !isEqual(change.newValue, change.oldValue),
1263
+ );
1025
1264
  this.hooks.itemchange.emit({
1026
1265
  type,
1027
1266
  changes: event.changes,
@@ -1029,12 +1268,16 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1029
1268
  theme: specification,
1030
1269
  upsertAncestors,
1031
1270
  action: 'updatePosition',
1271
+ animate: !disableAnimate,
1272
+ callback,
1032
1273
  });
1033
1274
  this.emit('afteritemchange', {
1034
1275
  type,
1035
1276
  action: 'updatePosition',
1036
1277
  upsertAncestors,
1037
1278
  models,
1279
+ apiName: 'updatePosition',
1280
+ changes,
1038
1281
  });
1039
1282
  });
1040
1283
 
@@ -1053,19 +1296,46 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1053
1296
  return isArray(models) ? dataList : dataList[0];
1054
1297
  }
1055
1298
 
1299
+ private getItemPreviousVisibility(ids: ID[]) {
1300
+ const objs = ids.map((id) => ({ id, visible: this.getItemVisible(id) }));
1301
+ const groupedByVisible = groupBy(objs, 'visible');
1302
+
1303
+ const values = [];
1304
+ for (const visible in groupedByVisible) {
1305
+ values.push({
1306
+ ids: map(groupedByVisible[visible], (item) => item.id),
1307
+ visible: visible === 'true',
1308
+ });
1309
+ }
1310
+ return values;
1311
+ }
1312
+
1056
1313
  /**
1057
1314
  * Show the item(s).
1058
1315
  * @param item the item to be shown
1059
1316
  * @returns
1060
1317
  * @group Item
1061
1318
  */
1062
- public showItem(ids: ID | ID[], disableAniamte?: boolean) {
1319
+ public showItem(ids: ID | ID[], disableAnimate = false) {
1063
1320
  const idArr = isArray(ids) ? ids : [ids];
1321
+ if (isEmpty(idArr)) return;
1322
+ const changes = {
1323
+ newValue: [{ ids: idArr, visible: true }],
1324
+ oldValue: this.getItemPreviousVisibility(idArr),
1325
+ };
1064
1326
  this.hooks.itemvisibilitychange.emit({
1065
1327
  ids: idArr as ID[],
1066
1328
  value: true,
1067
1329
  graphCore: this.dataController.graphCore,
1068
- animate: !disableAniamte,
1330
+ animate: !disableAnimate,
1331
+ });
1332
+ this.emit('afteritemvisibilitychange', {
1333
+ ids,
1334
+ value: true,
1335
+ animate: !disableAnimate,
1336
+ action: 'updateVisibility',
1337
+ apiName: 'showItem',
1338
+ changes,
1069
1339
  });
1070
1340
  }
1071
1341
  /**
@@ -1074,13 +1344,26 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1074
1344
  * @returns
1075
1345
  * @group Item
1076
1346
  */
1077
- public hideItem(ids: ID | ID[], disableAniamte?: boolean) {
1347
+ public hideItem(ids: ID | ID[], disableAnimate = false) {
1078
1348
  const idArr = isArray(ids) ? ids : [ids];
1349
+ if (isEmpty(idArr)) return;
1350
+ const changes = {
1351
+ newValue: [{ ids: idArr, visible: false }],
1352
+ oldValue: this.getItemPreviousVisibility(idArr),
1353
+ };
1079
1354
  this.hooks.itemvisibilitychange.emit({
1080
1355
  ids: idArr as ID[],
1081
1356
  value: false,
1082
1357
  graphCore: this.dataController.graphCore,
1083
- animate: !disableAniamte,
1358
+ animate: !disableAnimate,
1359
+ });
1360
+ this.emit('afteritemvisibilitychange', {
1361
+ ids,
1362
+ value: false,
1363
+ animate: !disableAnimate,
1364
+ action: 'updateVisibility',
1365
+ apiName: 'hideItem',
1366
+ changes,
1084
1367
  });
1085
1368
  }
1086
1369
 
@@ -1095,6 +1378,12 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1095
1378
  this.hooks.itemzindexchange.emit({
1096
1379
  ids: idArr as ID[],
1097
1380
  action: 'front',
1381
+ graphCore: this.dataController.graphCore,
1382
+ });
1383
+ this.emit('afteritemzindexchange', {
1384
+ ids: idArr,
1385
+ action: 'front',
1386
+ apiName: 'frontItem',
1098
1387
  });
1099
1388
  }
1100
1389
  /**
@@ -1108,6 +1397,30 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1108
1397
  this.hooks.itemzindexchange.emit({
1109
1398
  ids: idArr as ID[],
1110
1399
  action: 'back',
1400
+ graphCore: this.dataController.graphCore,
1401
+ });
1402
+ this.emit('afteritemzindexchange', {
1403
+ ids: idArr,
1404
+ action: 'back',
1405
+ apiName: 'backItem',
1406
+ });
1407
+ }
1408
+
1409
+ private getItemPreviousStates(stateOption: {
1410
+ ids: ID | ID[];
1411
+ states: string | string[];
1412
+ value: boolean;
1413
+ }) {
1414
+ const { ids, states } = stateOption;
1415
+ const idArr = Array.isArray(ids) ? ids : [ids];
1416
+ const stateArr = Array.isArray(states) ? states : [states];
1417
+ if (isEmpty(idArr)) return;
1418
+ return idArr.flatMap((id) => {
1419
+ return stateArr.map((state) => ({
1420
+ ids: id,
1421
+ states: state,
1422
+ value: this.getItemState(id, state),
1423
+ }));
1111
1424
  });
1112
1425
  }
1113
1426
  /**
@@ -1125,12 +1438,24 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1125
1438
  ) {
1126
1439
  const idArr = isArray(ids) ? ids : [ids];
1127
1440
  const stateArr = isArray(states) ? states : [states];
1441
+ const stateOption = { ids: idArr, states: stateArr, value };
1442
+ const changes = {
1443
+ newValue: [stateOption],
1444
+ oldValue: this.getItemPreviousStates(stateOption),
1445
+ };
1128
1446
  this.hooks.itemstatechange.emit({
1129
1447
  ids: idArr as ID[],
1130
1448
  states: stateArr as string[],
1131
1449
  value,
1132
1450
  });
1133
- this.emit('afteritemstatechange', { ids, states, value });
1451
+ this.emit('afteritemstatechange', {
1452
+ ids,
1453
+ states,
1454
+ value,
1455
+ action: 'updateState',
1456
+ apiName: 'setItemState',
1457
+ changes,
1458
+ });
1134
1459
  }
1135
1460
  /**
1136
1461
  * Get the state value for an item.
@@ -1143,6 +1468,16 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1143
1468
  return this.itemController.getItemState(id, state);
1144
1469
  }
1145
1470
 
1471
+ /**
1472
+ * Get all the state names with value true for an item.
1473
+ * @param id the id for the item
1474
+ * @returns {string[]} the state names with value true
1475
+ * @group Item
1476
+ */
1477
+ public getItemAllStates(id: ID): string[] {
1478
+ return this.itemController.getItemAllStates(id);
1479
+ }
1480
+
1146
1481
  /**
1147
1482
  * Clear all the states for item(s).
1148
1483
  * @param ids the id(s) for the item(s) to be clear
@@ -1152,12 +1487,24 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1152
1487
  */
1153
1488
  public clearItemState(ids: ID | ID[], states?: string[]) {
1154
1489
  const idArr = isArray(ids) ? ids : [ids];
1490
+ const stateOptions = { ids: idArr, states, value: false };
1491
+ const changes = {
1492
+ newValue: [stateOptions],
1493
+ oldValue: this.getItemPreviousStates(stateOptions),
1494
+ };
1155
1495
  this.hooks.itemstatechange.emit({
1156
1496
  ids: idArr as ID[],
1157
1497
  states,
1158
1498
  value: false,
1159
1499
  });
1160
- this.emit('afteritemstatechange', { ids, states, value: false });
1500
+ this.emit('afteritemstatechange', {
1501
+ ids,
1502
+ states,
1503
+ value: false,
1504
+ action: 'updateState',
1505
+ apiName: 'clearItemState',
1506
+ changes,
1507
+ });
1161
1508
  }
1162
1509
 
1163
1510
  /**
@@ -1191,19 +1538,15 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1191
1538
  * Add a new combo to the graph, and update the structure of the existed child in childrenIds to be the children of the new combo.
1192
1539
  * Different from addData with combo type, this API update the succeeds' combo tree strucutres in the same time.
1193
1540
  * @param model combo user data
1194
- * @param stack whether push this operation to stack
1195
1541
  * @returns whether success
1196
1542
  * @group Combo
1197
1543
  */
1198
- public addCombo(
1199
- model: ComboUserModel,
1200
- childrenIds: ID[],
1201
- stack?: boolean,
1202
- ): ComboModel {
1544
+ public addCombo(model: ComboUserModel, childrenIds: ID[]): ComboModel {
1203
1545
  const { graphCore } = this.dataController;
1204
1546
  const { specification } = this.themeController;
1205
1547
  graphCore.once('changed', (event) => {
1206
1548
  if (!event.changes.length) return;
1549
+ const changes = event.changes;
1207
1550
  this.hooks.itemchange.emit({
1208
1551
  type: 'combo',
1209
1552
  changes: graphCore.reduceChanges(event.changes),
@@ -1214,6 +1557,8 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1214
1557
  type: 'combo',
1215
1558
  action: 'add',
1216
1559
  models: [model],
1560
+ apiName: 'addCombo',
1561
+ changes,
1217
1562
  });
1218
1563
  });
1219
1564
 
@@ -1241,26 +1586,40 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1241
1586
  * @param comboId combo ids
1242
1587
  * @group Combo
1243
1588
  */
1244
- public collapseCombo(comboIds: ID | ID[], stack?: boolean) {
1589
+ public collapseCombo(comboIds: ID | ID[]) {
1245
1590
  const ids = isArray(comboIds) ? comboIds : [comboIds];
1246
- this.updateData(
1247
- 'combo',
1248
- ids.map((id) => ({ id, data: { collapsed: true } })),
1249
- );
1250
- // emit collapse event?
1591
+ this.executeWithoutStacking(() => {
1592
+ this.updateData(
1593
+ 'combo',
1594
+ ids.map((id) => ({ id, data: { collapsed: true } })),
1595
+ );
1596
+ });
1597
+ this.emit('aftercollapsecombo', {
1598
+ type: 'combo',
1599
+ action: 'collapseCombo',
1600
+ ids: comboIds,
1601
+ apiName: 'collapseCombo',
1602
+ });
1251
1603
  }
1252
1604
  /**
1253
1605
  * Expand a combo.
1254
1606
  * @param combo combo ids
1255
1607
  * @group Combo
1256
1608
  */
1257
- public expandCombo(comboIds: ID | ID[], stack?: boolean) {
1609
+ public expandCombo(comboIds: ID | ID[]) {
1258
1610
  const ids = isArray(comboIds) ? comboIds : [comboIds];
1259
- this.updateData(
1260
- 'combo',
1261
- ids.map((id) => ({ id, data: { collapsed: false } })),
1262
- );
1263
- // emit expand event?
1611
+ this.executeWithoutStacking(() => {
1612
+ this.updateData(
1613
+ 'combo',
1614
+ ids.map((id) => ({ id, data: { collapsed: false } })),
1615
+ );
1616
+ });
1617
+ this.emit('afterexpandcombo', {
1618
+ type: 'combo',
1619
+ action: 'expandCombo',
1620
+ ids: comboIds,
1621
+ apiName: 'expandCombo',
1622
+ });
1264
1623
  }
1265
1624
 
1266
1625
  /**
@@ -1268,7 +1627,6 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1268
1627
  * do not update other styles which leads to better performance than updating positions by updateData.
1269
1628
  * In fact, it changes the succeed nodes positions to affect the combo's position, but not modify the combo's position directly.
1270
1629
  * @param models new configurations with x and y for every combo, which has id field to indicate the specific item
1271
- * @param {boolean} stack whether push this operation into graph's stack, true by default
1272
1630
  * @group Combo
1273
1631
  */
1274
1632
  public moveCombo(
@@ -1276,13 +1634,17 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1276
1634
  dx: number,
1277
1635
  dy: number,
1278
1636
  upsertAncestors?: boolean,
1279
- stack?: boolean,
1637
+ callback?: (
1638
+ model: NodeModel | EdgeModel | ComboModel,
1639
+ canceled?: boolean,
1640
+ ) => void,
1280
1641
  ): ComboModel[] {
1281
1642
  const idArr = isArray(ids) ? ids : [ids];
1282
1643
  const { graphCore } = this.dataController;
1283
1644
  const { specification } = this.themeController;
1284
1645
  graphCore.once('changed', (event) => {
1285
1646
  if (!event.changes.length) return;
1647
+ const changes = this.extendChanges(clone(event.changes));
1286
1648
  this.hooks.itemchange.emit({
1287
1649
  type: 'combo',
1288
1650
  changes: event.changes,
@@ -1290,6 +1652,7 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1290
1652
  theme: specification,
1291
1653
  upsertAncestors,
1292
1654
  action: 'updatePosition',
1655
+ callback,
1293
1656
  });
1294
1657
  this.emit('afteritemchange', {
1295
1658
  type: 'combo',
@@ -1298,6 +1661,8 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1298
1661
  dy,
1299
1662
  action: 'updatePosition',
1300
1663
  upsertAncestors,
1664
+ apiName: 'moveCombo',
1665
+ changes,
1301
1666
  });
1302
1667
  });
1303
1668
 
@@ -1316,14 +1681,19 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1316
1681
  /**
1317
1682
  * Layout the graph (with current configurations if cfg is not assigned).
1318
1683
  */
1319
- public async layout(options?: LayoutOptions) {
1684
+ public async layout(options?: LayoutOptions, disableAnimate = false) {
1685
+ this.emit('beforelayout');
1320
1686
  const { graphCore } = this.dataController;
1321
1687
  const formattedOptions = {
1322
1688
  ...this.getSpecification().layout,
1323
1689
  ...options,
1324
1690
  } as LayoutOptions;
1325
1691
 
1326
- const layoutUnset = !options && !this.getSpecification().layout;
1692
+ this.updateSpecification({ layout: formattedOptions });
1693
+
1694
+ const layoutUnset =
1695
+ (!options && !this.getSpecification().layout) ||
1696
+ !Object.keys(formattedOptions).length;
1327
1697
  if (layoutUnset) {
1328
1698
  const nodes = graphCore.getAllNodes();
1329
1699
  if (nodes.every((node) => isNil(node.data.x) && isNil(node.data.y))) {
@@ -1352,7 +1722,9 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1352
1722
  await this.hooks.layout.emitLinearAsync({
1353
1723
  graphCore,
1354
1724
  options: formattedOptions,
1725
+ animate: !disableAnimate,
1355
1726
  });
1727
+
1356
1728
  this.emit('afterlayout');
1357
1729
  }
1358
1730
 
@@ -1363,6 +1735,14 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1363
1735
  this.layoutController.stopLayout();
1364
1736
  }
1365
1737
 
1738
+ /**
1739
+ *
1740
+ * @returns
1741
+ */
1742
+ public getLayoutCurrentAnimation() {
1743
+ return this.layoutController.getCurrentAnimation();
1744
+ }
1745
+
1366
1746
  /**
1367
1747
  * Switch mode.
1368
1748
  * @param mode mode name
@@ -1373,6 +1753,15 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1373
1753
  this.hooks.modechange.emit({ mode });
1374
1754
  }
1375
1755
 
1756
+ /**
1757
+ * Get current mode.
1758
+ * @returns mode name
1759
+ * @group Interaction
1760
+ */
1761
+ public getMode(): string {
1762
+ return this.interactionController.getMode();
1763
+ }
1764
+
1376
1765
  /**
1377
1766
  * Add behavior(s) to mode(s).
1378
1767
  * @param behaviors behavior names or configs
@@ -1381,7 +1770,7 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1381
1770
  * @group Interaction
1382
1771
  */
1383
1772
  public addBehaviors(
1384
- behaviors: BehaviorOptionsOf<B>[],
1773
+ behaviors: BehaviorOptionsOf<B> | BehaviorOptionsOf<B>[],
1385
1774
  modes: string | string[],
1386
1775
  ) {
1387
1776
  const modesArr = isArray(modes) ? modes : [modes];
@@ -1508,16 +1897,21 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1508
1897
  * @returns
1509
1898
  * @group Plugin
1510
1899
  */
1511
- public removePlugins(pluginKeys: string[]) {
1900
+ public removePlugins(pluginKeys: (PluginBase | string)[]) {
1901
+ const pluginArr = isArray(pluginKeys) ? pluginKeys : [pluginKeys];
1512
1902
  this.hooks.pluginchange.emit({
1513
1903
  action: 'remove',
1514
- plugins: pluginKeys,
1904
+ plugins: pluginArr,
1515
1905
  });
1516
1906
  // update the graph specification
1517
1907
  const { plugins } = this.specification;
1518
1908
  this.specification.plugins = plugins?.filter((plugin) => {
1519
- if (isObject(plugin)) return !pluginKeys.includes(plugin.key);
1520
- return !pluginKeys.includes(plugin);
1909
+ if (isObject(plugin))
1910
+ return !(
1911
+ pluginArr.includes(plugin.key) ||
1912
+ pluginArr.includes(plugin as PluginBase)
1913
+ );
1914
+ return !pluginArr.includes(plugin);
1521
1915
  });
1522
1916
  }
1523
1917
 
@@ -1527,11 +1921,16 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1527
1921
  * @returns
1528
1922
  * @group Interaction
1529
1923
  */
1530
- public updatePlugin(plugin: {
1531
- key: string;
1532
- type: string;
1533
- [cfg: string]: unknown;
1534
- }) {
1924
+ public updatePlugin(
1925
+ plugin:
1926
+ | {
1927
+ key: string;
1928
+ type: string;
1929
+ [cfg: string]: unknown;
1930
+ }
1931
+ | PluginBase,
1932
+ ) {
1933
+ const { plugins } = this.specification;
1535
1934
  const { key } = plugin;
1536
1935
  if (!key) {
1537
1936
  console.warn(
@@ -1539,7 +1938,6 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1539
1938
  );
1540
1939
  return;
1541
1940
  }
1542
- const { plugins } = this.specification;
1543
1941
  if (!plugins) {
1544
1942
  console.warn(
1545
1943
  'Update plugin failed, the plugin to be updated does not exist.',
@@ -1586,17 +1984,206 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1586
1984
  onlyDrawKeyShape?: boolean;
1587
1985
  upsertAncestors?: boolean;
1588
1986
  },
1987
+ canvas?: Canvas,
1589
1988
  ): DisplayObject {
1590
1989
  this.hooks.transientupdate.emit({
1591
1990
  type,
1592
1991
  id,
1593
1992
  config,
1594
- canvas: this.transientCanvas,
1993
+ canvas: canvas || this.transientCanvas,
1595
1994
  graphCore: this.dataController.graphCore,
1596
1995
  });
1597
1996
  return this.itemController.getTransient(String(id));
1598
1997
  }
1599
1998
 
1999
+ // ===== history operations =====
2000
+
2001
+ /**
2002
+ * Determine if history (redo/undo) is enabled.
2003
+ */
2004
+ public isHistoryEnabled() {
2005
+ const history = this.getHistoryPlugin();
2006
+ return history?.isEnable();
2007
+ }
2008
+
2009
+ /**
2010
+ * Push the operation(s) onto the specified stack
2011
+ * @param cmd commands to be pushed
2012
+ * @param stackType undo/redo stack
2013
+ * @param isNew
2014
+ */
2015
+ public pushStack(cmd: Command[], stackType: StackType, isNew?: boolean) {
2016
+ const history = this.getHistoryPlugin();
2017
+ return history?.push(cmd, stackType, isNew);
2018
+ }
2019
+
2020
+ /**
2021
+ * Pause stacking operation.
2022
+ */
2023
+ public pauseStacking(): void {
2024
+ const history = this.getHistoryPlugin();
2025
+ return history?.pauseStacking();
2026
+ }
2027
+
2028
+ /**
2029
+ * Resume stacking operation.
2030
+ */
2031
+ public resumeStacking(): void {
2032
+ const history = this.getHistoryPlugin();
2033
+ return history?.resumeStacking();
2034
+ }
2035
+
2036
+ /**
2037
+ * Execute a callback without allowing any stacking operations.
2038
+ * @param callback
2039
+ */
2040
+ public executeWithoutStacking = (callback: () => void): void => {
2041
+ const history = this.getHistoryPlugin();
2042
+ history?.pauseStacking();
2043
+ try {
2044
+ callback();
2045
+ } finally {
2046
+ history?.resumeStacking();
2047
+ }
2048
+ };
2049
+
2050
+ /**
2051
+ * Retrieve the current redo stack which consists of operations that could be undone
2052
+ */
2053
+ public getUndoStack() {
2054
+ const history = this.getHistoryPlugin();
2055
+ return history?.getUndoStack();
2056
+ }
2057
+
2058
+ /**
2059
+ * Retrieve the current undo stack which consists of operations that were undone
2060
+ */
2061
+ public getRedoStack() {
2062
+ const history = this.getHistoryPlugin();
2063
+ return history?.getRedoStack();
2064
+ }
2065
+
2066
+ /**
2067
+ * Retrieve the complete history stack
2068
+ * @returns
2069
+ */
2070
+ public getStack() {
2071
+ const history = this.getHistoryPlugin();
2072
+ return history?.getStack();
2073
+ }
2074
+
2075
+ /**
2076
+ * Restore n operations that were last n reverted on the graph.
2077
+ * @param steps The number of operations to undo. Default to 1.
2078
+ * @returns
2079
+ */
2080
+ public undo() {
2081
+ const history = this.getHistoryPlugin();
2082
+ history?.undo();
2083
+ }
2084
+
2085
+ /**
2086
+ * Revert recent n operation(s) performed on the graph.
2087
+ * @param steps The number of operations to redo. Default to 1.
2088
+ * @returns
2089
+ */
2090
+ public redo() {
2091
+ const history = this.getHistoryPlugin();
2092
+ history?.redo();
2093
+ }
2094
+
2095
+ /**
2096
+ * Indicate whether there are any actions available in the undo stack.
2097
+ */
2098
+ public canUndo() {
2099
+ const history = this.getHistoryPlugin();
2100
+ return history?.canUndo();
2101
+ }
2102
+
2103
+ /**
2104
+ * Indicate whether there are any actions available in the redo stack.
2105
+ */
2106
+ public canRedo() {
2107
+ const history = this.getHistoryPlugin();
2108
+ return history?.canRedo();
2109
+ }
2110
+
2111
+ /**
2112
+ * Begin a batch operation.
2113
+ * Any operations performed between `startBatch` and `stopBatch` are grouped together.
2114
+ * treated as a single operation when undoing or redoing.
2115
+ */
2116
+ public startBatch() {
2117
+ const history = this.getHistoryPlugin();
2118
+ history?.startBatch();
2119
+ }
2120
+
2121
+ /**
2122
+ * End a batch operation.
2123
+ * Any operations performed between `startBatch` and `stopBatch` are grouped together.
2124
+ * treated as a single operation when undoing or redoing.
2125
+ */
2126
+ public stopBatch() {
2127
+ const history = this.getHistoryPlugin();
2128
+ history?.stopBatch();
2129
+ }
2130
+
2131
+ /**
2132
+ * Execute a provided function within a batched context
2133
+ * All operations performed inside callback will be treated as a composite operation
2134
+ * more convenient way without manually invoking `startBatch` and `stopBatch`.
2135
+ * @param callback The func containing operations to be batched together.
2136
+ */
2137
+ public batch(callback: () => void) {
2138
+ const history = this.getHistoryPlugin();
2139
+ history?.batch(callback);
2140
+ }
2141
+
2142
+ /**
2143
+ * Clear history stack
2144
+ * @param {StackType} stackType undo/redo stack
2145
+ */
2146
+ public clearStack(stackType?: StackType) {
2147
+ const history = this.getHistoryPlugin();
2148
+ if (!stackType) return history?.clear();
2149
+ return stackType === 'undo'
2150
+ ? history?.clearUndoStack()
2151
+ : history?.clearRedoStack();
2152
+ }
2153
+
2154
+ /**
2155
+ * Collapse sub tree(s).
2156
+ * @param ids Root id(s) of the sub trees.
2157
+ * @param disableAnimate Whether disable the animations for this operation.
2158
+ * @param stack Whether push this operation to stack.
2159
+ * @returns
2160
+ * @group Tree
2161
+ */
2162
+ public collapse(ids: ID | ID[], disableAnimate = false, stack?: boolean) {
2163
+ this.hooks.treecollapseexpand.emit({
2164
+ ids: isArray(ids) ? ids : [ids],
2165
+ action: 'collapse',
2166
+ animate: !disableAnimate,
2167
+ graphCore: this.dataController.graphCore,
2168
+ });
2169
+ }
2170
+ /**
2171
+ * Expand sub tree(s).
2172
+ * @param ids Root id(s) of the sub trees.
2173
+ * @param disableAnimate Whether disable the animations for this operation.
2174
+ * @param stack Whether push this operation to stack.
2175
+ * @returns
2176
+ * @group Tree
2177
+ */
2178
+ public expand(ids: ID | ID[], disableAnimate = false, stack?: boolean) {
2179
+ this.hooks.treecollapseexpand.emit({
2180
+ ids: isArray(ids) ? ids : [ids],
2181
+ action: 'expand',
2182
+ animate: !disableAnimate,
2183
+ graphCore: this.dataController.graphCore,
2184
+ });
2185
+ }
2186
+
1600
2187
  /**
1601
2188
  * Destroy the graph instance and remove the related canvases.
1602
2189
  * @returns
@@ -1604,12 +2191,16 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
1604
2191
  */
1605
2192
  public destroy(callback?: Function) {
1606
2193
  // TODO: call the destroy functions after items' buildOut animations finished
1607
- setTimeout(() => {
1608
- this.canvas.destroy();
1609
- this.backgroundCanvas.destroy();
1610
- this.transientCanvas.destroy();
1611
- callback?.();
1612
- }, 500);
2194
+ // setTimeout(() => {
2195
+ this.canvas.destroy();
2196
+ this.backgroundCanvas.destroy();
2197
+ this.transientCanvas.destroy();
2198
+
2199
+ // clear history stack
2200
+ this.clearStack();
2201
+
2202
+ callback?.();
2203
+ // }, 500);
1613
2204
 
1614
2205
  this.hooks.destroy.emit({});
1615
2206