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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (608) hide show
  1. package/dist/g6.min.js +2 -2
  2. package/esm/api-doc/graph.d.ts +3 -3
  3. package/esm/api-doc/graph.js +3 -3
  4. package/esm/api-doc/graph.js.map +1 -1
  5. package/esm/api-doc/types.d.ts +1 -0
  6. package/esm/api-doc/types.js +1 -2
  7. package/esm/api-doc/types.js.map +1 -1
  8. package/esm/constant/shape.d.ts +3 -1
  9. package/esm/index.d.ts +24 -63
  10. package/esm/index.js +4 -5
  11. package/esm/index.js.map +1 -1
  12. package/esm/item/combo.d.ts +1 -1
  13. package/esm/item/combo.js +18 -14
  14. package/esm/item/combo.js.map +1 -1
  15. package/esm/item/edge.d.ts +19 -2
  16. package/esm/item/edge.js +100 -44
  17. package/esm/item/edge.js.map +1 -1
  18. package/esm/item/item.d.ts +3 -2
  19. package/esm/item/item.js +27 -13
  20. package/esm/item/item.js.map +1 -1
  21. package/esm/item/node.d.ts +2 -8
  22. package/esm/item/node.js +31 -19
  23. package/esm/item/node.js.map +1 -1
  24. package/esm/runtime/controller/data.d.ts +7 -10
  25. package/esm/runtime/controller/data.js +125 -281
  26. package/esm/runtime/controller/data.js.map +1 -1
  27. package/esm/runtime/controller/interaction.js +9 -4
  28. package/esm/runtime/controller/interaction.js.map +1 -1
  29. package/esm/runtime/controller/item.d.ts +1 -0
  30. package/esm/runtime/controller/item.js +285 -150
  31. package/esm/runtime/controller/item.js.map +1 -1
  32. package/esm/runtime/controller/layout.js +1 -3
  33. package/esm/runtime/controller/layout.js.map +1 -1
  34. package/esm/runtime/controller/plugin.js +9 -5
  35. package/esm/runtime/controller/plugin.js.map +1 -1
  36. package/esm/runtime/graph.d.ts +104 -24
  37. package/esm/runtime/graph.js +472 -94
  38. package/esm/runtime/graph.js.map +1 -1
  39. package/esm/stdlib/behavior/activate-relations.d.ts +1 -1
  40. package/esm/stdlib/behavior/activate-relations.js +2 -2
  41. package/esm/stdlib/behavior/activate-relations.js.map +1 -1
  42. package/esm/stdlib/behavior/brush-select.d.ts +9 -3
  43. package/esm/stdlib/behavior/brush-select.js +10 -12
  44. package/esm/stdlib/behavior/brush-select.js.map +1 -1
  45. package/esm/stdlib/behavior/click-select.d.ts +1 -1
  46. package/esm/stdlib/behavior/click-select.js +1 -1
  47. package/esm/stdlib/behavior/click-select.js.map +1 -1
  48. package/esm/stdlib/behavior/collapse-expand-combo.d.ts +1 -1
  49. package/esm/stdlib/behavior/collapse-expand-tree.d.ts +1 -1
  50. package/esm/stdlib/behavior/create-edge.d.ts +57 -0
  51. package/esm/stdlib/behavior/create-edge.js +215 -0
  52. package/esm/stdlib/behavior/create-edge.js.map +1 -0
  53. package/esm/stdlib/behavior/drag-canvas.d.ts +3 -1
  54. package/esm/stdlib/behavior/drag-canvas.js +78 -33
  55. package/esm/stdlib/behavior/drag-canvas.js.map +1 -1
  56. package/esm/stdlib/behavior/drag-combo.d.ts +3 -3
  57. package/esm/stdlib/behavior/drag-combo.js +43 -32
  58. package/esm/stdlib/behavior/drag-combo.js.map +1 -1
  59. package/esm/stdlib/behavior/drag-node.d.ts +4 -4
  60. package/esm/stdlib/behavior/drag-node.js +80 -63
  61. package/esm/stdlib/behavior/drag-node.js.map +1 -1
  62. package/esm/stdlib/behavior/index.d.ts +3 -0
  63. package/esm/stdlib/behavior/index.js +3 -0
  64. package/esm/stdlib/behavior/index.js.map +1 -1
  65. package/esm/stdlib/behavior/lasso-select.d.ts +1 -1
  66. package/esm/stdlib/behavior/lasso-select.js +3 -4
  67. package/esm/stdlib/behavior/lasso-select.js.map +1 -1
  68. package/esm/stdlib/behavior/scroll-canvas.d.ts +67 -0
  69. package/esm/stdlib/behavior/scroll-canvas.js +266 -0
  70. package/esm/stdlib/behavior/scroll-canvas.js.map +1 -0
  71. package/esm/stdlib/behavior/shortcuts-call.d.ts +38 -0
  72. package/esm/stdlib/behavior/shortcuts-call.js +87 -0
  73. package/esm/stdlib/behavior/shortcuts-call.js.map +1 -0
  74. package/esm/stdlib/behavior/zoom-canvas-3d.js +4 -1
  75. package/esm/stdlib/behavior/zoom-canvas-3d.js.map +1 -1
  76. package/esm/stdlib/behavior/zoom-canvas.d.ts +3 -1
  77. package/esm/stdlib/behavior/zoom-canvas.js +70 -26
  78. package/esm/stdlib/behavior/zoom-canvas.js.map +1 -1
  79. package/esm/stdlib/data/mapNodeSize.d.ts +2 -2
  80. package/esm/stdlib/data/mapNodeSize.js +2 -2
  81. package/esm/stdlib/data/mapNodeSize.js.map +1 -1
  82. package/esm/stdlib/data/transformV4Data.d.ts +2 -2
  83. package/esm/stdlib/data/transformV4Data.js +2 -2
  84. package/esm/stdlib/data/transformV4Data.js.map +1 -1
  85. package/esm/stdlib/data/validateData.d.ts +2 -2
  86. package/esm/stdlib/data/validateData.js +13 -12
  87. package/esm/stdlib/data/validateData.js.map +1 -1
  88. package/esm/stdlib/index.d.ts +18 -6
  89. package/esm/stdlib/index.js +22 -10
  90. package/esm/stdlib/index.js.map +1 -1
  91. package/esm/stdlib/item/edge/base.d.ts +3 -5
  92. package/esm/stdlib/item/edge/base.js +32 -31
  93. package/esm/stdlib/item/edge/base.js.map +1 -1
  94. package/esm/stdlib/item/edge/cubic-horizontal.js.map +1 -1
  95. package/esm/stdlib/item/edge/cubic-vertical.js.map +1 -1
  96. package/esm/stdlib/item/edge/cubic.js +1 -1
  97. package/esm/stdlib/item/edge/cubic.js.map +1 -1
  98. package/esm/stdlib/item/edge/loop.js +1 -1
  99. package/esm/stdlib/item/edge/loop.js.map +1 -1
  100. package/esm/stdlib/item/node/base.d.ts +3 -6
  101. package/esm/stdlib/item/node/base.js +30 -60
  102. package/esm/stdlib/item/node/base.js.map +1 -1
  103. package/esm/stdlib/item/node/base3d.d.ts +1 -0
  104. package/esm/stdlib/item/node/base3d.js +1 -0
  105. package/esm/stdlib/item/node/base3d.js.map +1 -1
  106. package/esm/stdlib/item/node/cube.d.ts +35 -0
  107. package/esm/stdlib/item/node/cube.js +54 -0
  108. package/esm/stdlib/item/node/cube.js.map +1 -0
  109. package/esm/stdlib/item/node/diamond.js +1 -1
  110. package/esm/stdlib/item/node/donut.d.ts +3 -3
  111. package/esm/stdlib/item/node/ellipse.js +2 -2
  112. package/esm/stdlib/item/node/hexagon.js +6 -2
  113. package/esm/stdlib/item/node/hexagon.js.map +1 -1
  114. package/esm/stdlib/item/node/image.d.ts +40 -0
  115. package/esm/stdlib/item/node/image.js +110 -0
  116. package/esm/stdlib/item/node/image.js.map +1 -0
  117. package/esm/stdlib/item/node/index.d.ts +4 -0
  118. package/esm/stdlib/item/node/index.js +4 -0
  119. package/esm/stdlib/item/node/index.js.map +1 -1
  120. package/esm/stdlib/plugin/edgeFilterLens/index.d.ts +66 -0
  121. package/esm/stdlib/plugin/edgeFilterLens/index.js +309 -0
  122. package/esm/stdlib/plugin/edgeFilterLens/index.js.map +1 -0
  123. package/esm/stdlib/plugin/grid/index.d.ts +1 -1
  124. package/esm/stdlib/plugin/grid/index.js +3 -4
  125. package/esm/stdlib/plugin/grid/index.js.map +1 -1
  126. package/esm/stdlib/plugin/history/combo-command.js +2 -2
  127. package/esm/stdlib/plugin/history/combo-command.js.map +1 -1
  128. package/esm/stdlib/plugin/history/index.d.ts +10 -10
  129. package/esm/stdlib/plugin/history/index.js +14 -14
  130. package/esm/stdlib/plugin/history/index.js.map +1 -1
  131. package/esm/stdlib/plugin/history/item-data-command.js +25 -16
  132. package/esm/stdlib/plugin/history/item-data-command.js.map +1 -1
  133. package/esm/stdlib/plugin/history/layer-updated-command.js +2 -2
  134. package/esm/stdlib/plugin/history/layer-updated-command.js.map +1 -1
  135. package/esm/stdlib/plugin/history/state-updated-command.js +1 -1
  136. package/esm/stdlib/plugin/history/state-updated-command.js.map +1 -1
  137. package/esm/stdlib/plugin/history/visibility-updated-command.js +2 -2
  138. package/esm/stdlib/plugin/history/visibility-updated-command.js.map +1 -1
  139. package/esm/stdlib/plugin/hull/convexHull.d.ts +1 -1
  140. package/esm/stdlib/plugin/hull/hullComponent.d.ts +2 -2
  141. package/esm/stdlib/plugin/hull/hullComponent.js +5 -9
  142. package/esm/stdlib/plugin/hull/hullComponent.js.map +1 -1
  143. package/esm/stdlib/plugin/hull/util.d.ts +2 -2
  144. package/esm/stdlib/plugin/hull/util.js +6 -2
  145. package/esm/stdlib/plugin/hull/util.js.map +1 -1
  146. package/esm/stdlib/plugin/index.d.ts +2 -0
  147. package/esm/stdlib/plugin/index.js +2 -0
  148. package/esm/stdlib/plugin/index.js.map +1 -1
  149. package/esm/stdlib/plugin/legend/index.d.ts +3 -3
  150. package/esm/stdlib/plugin/legend/index.js +3 -3
  151. package/esm/stdlib/plugin/legend/index.js.map +1 -1
  152. package/esm/stdlib/plugin/menu/index.d.ts +4 -4
  153. package/esm/stdlib/plugin/menu/index.js +3 -3
  154. package/esm/stdlib/plugin/menu/index.js.map +1 -1
  155. package/esm/stdlib/plugin/minimap/index.d.ts +6 -2
  156. package/esm/stdlib/plugin/minimap/index.js +119 -12
  157. package/esm/stdlib/plugin/minimap/index.js.map +1 -1
  158. package/esm/stdlib/plugin/snapline/index.d.ts +167 -0
  159. package/esm/stdlib/plugin/snapline/index.js +1063 -0
  160. package/esm/stdlib/plugin/snapline/index.js.map +1 -0
  161. package/esm/stdlib/plugin/timebar/index.d.ts +4 -4
  162. package/esm/stdlib/plugin/timebar/index.js +6 -6
  163. package/esm/stdlib/plugin/timebar/index.js.map +1 -1
  164. package/esm/stdlib/plugin/toolbar/index.d.ts +3 -3
  165. package/esm/stdlib/plugin/toolbar/index.js +4 -4
  166. package/esm/stdlib/plugin/toolbar/index.js.map +1 -1
  167. package/esm/stdlib/plugin/tooltip/index.d.ts +5 -5
  168. package/esm/stdlib/plugin/tooltip/index.js +3 -4
  169. package/esm/stdlib/plugin/tooltip/index.js.map +1 -1
  170. package/esm/stdlib/plugin/types.d.ts +2 -0
  171. package/esm/stdlib/plugin/watermaker/index.d.ts +78 -0
  172. package/esm/stdlib/plugin/watermaker/index.js +243 -0
  173. package/esm/stdlib/plugin/watermaker/index.js.map +1 -0
  174. package/esm/stdlib/theme/dark.js +42 -2
  175. package/esm/stdlib/theme/dark.js.map +1 -1
  176. package/esm/stdlib/theme/light.js +4 -4
  177. package/esm/types/animate.d.ts +2 -2
  178. package/esm/types/behavior.d.ts +1 -1
  179. package/esm/types/combo.d.ts +7 -7
  180. package/esm/types/common.d.ts +5 -5
  181. package/esm/types/data.d.ts +6 -6
  182. package/esm/types/edge.d.ts +9 -9
  183. package/esm/types/event.d.ts +2 -1
  184. package/esm/types/graph.d.ts +48 -22
  185. package/esm/types/history.d.ts +2 -2
  186. package/esm/types/hook.d.ts +23 -3
  187. package/esm/types/index.d.ts +2 -1
  188. package/esm/types/index.js +1 -0
  189. package/esm/types/index.js.map +1 -1
  190. package/esm/types/item.d.ts +18 -12
  191. package/esm/types/item.js.map +1 -1
  192. package/esm/types/layout.d.ts +6 -6
  193. package/esm/types/loop.d.ts +2 -2
  194. package/esm/types/node.d.ts +7 -7
  195. package/esm/types/plugin.d.ts +1 -1
  196. package/esm/types/render.d.ts +1 -1
  197. package/esm/types/spec.d.ts +19 -3
  198. package/esm/types/stdlib.d.ts +1 -1
  199. package/esm/types/theme.d.ts +8 -8
  200. package/esm/types/view.d.ts +7 -2
  201. package/esm/util/bbox.d.ts +16 -1
  202. package/esm/util/bbox.js +33 -5
  203. package/esm/util/bbox.js.map +1 -1
  204. package/esm/util/behavior.d.ts +2 -2
  205. package/esm/util/behavior.js +2 -2
  206. package/esm/util/behavior.js.map +1 -1
  207. package/esm/util/data.d.ts +2 -2
  208. package/esm/util/data.js.map +1 -1
  209. package/esm/util/dom.d.ts +15 -0
  210. package/esm/util/dom.js +29 -0
  211. package/esm/util/dom.js.map +1 -0
  212. package/esm/util/event.d.ts +5 -3
  213. package/esm/util/event.js +8 -1
  214. package/esm/util/event.js.map +1 -1
  215. package/esm/util/extend.d.ts +1 -1
  216. package/esm/util/extend.js +0 -1
  217. package/esm/util/extend.js.map +1 -1
  218. package/esm/util/index.d.ts +7 -52
  219. package/esm/util/index.js +7 -23
  220. package/esm/util/index.js.map +1 -1
  221. package/esm/util/item.d.ts +16 -1
  222. package/esm/util/item.js +31 -8
  223. package/esm/util/item.js.map +1 -1
  224. package/esm/util/layout.d.ts +13 -2
  225. package/esm/util/layout.js +45 -0
  226. package/esm/util/layout.js.map +1 -1
  227. package/esm/util/loop.d.ts +1 -1
  228. package/esm/util/loop.js +4 -0
  229. package/esm/util/loop.js.map +1 -1
  230. package/esm/util/math.d.ts +1 -1
  231. package/esm/util/matrix.d.ts +6 -0
  232. package/esm/util/matrix.js +48 -0
  233. package/esm/util/matrix.js.map +1 -0
  234. package/esm/util/path.js +1 -1
  235. package/esm/util/path.js.map +1 -1
  236. package/esm/util/point.d.ts +1 -1
  237. package/esm/util/point.js +9 -2
  238. package/esm/util/point.js.map +1 -1
  239. package/esm/util/polyline.d.ts +2 -1
  240. package/esm/util/polyline.js +2 -1
  241. package/esm/util/polyline.js.map +1 -1
  242. package/esm/util/router.d.ts +1 -1
  243. package/esm/util/shape.d.ts +1 -2
  244. package/esm/util/shape.js +15 -25
  245. package/esm/util/shape.js.map +1 -1
  246. package/esm/util/shape3d.js +16 -17
  247. package/esm/util/shape3d.js.map +1 -1
  248. package/esm/util/text.d.ts +1 -1
  249. package/esm/util/text.js +3 -2
  250. package/esm/util/text.js.map +1 -1
  251. package/esm/util/warn.d.ts +14 -0
  252. package/esm/util/warn.js +4 -0
  253. package/esm/util/warn.js.map +1 -0
  254. package/lib/api-doc/graph.d.ts +3 -3
  255. package/lib/api-doc/graph.js +27 -7
  256. package/lib/api-doc/graph.js.map +1 -1
  257. package/lib/api-doc/types.d.ts +1 -0
  258. package/lib/api-doc/types.js +2 -2
  259. package/lib/api-doc/types.js.map +1 -1
  260. package/lib/constant/shape.d.ts +3 -1
  261. package/lib/index.d.ts +24 -63
  262. package/lib/index.js +18 -10
  263. package/lib/index.js.map +1 -1
  264. package/lib/item/combo.d.ts +1 -1
  265. package/lib/item/combo.js +18 -14
  266. package/lib/item/combo.js.map +1 -1
  267. package/lib/item/edge.d.ts +19 -2
  268. package/lib/item/edge.js +99 -43
  269. package/lib/item/edge.js.map +1 -1
  270. package/lib/item/item.d.ts +3 -2
  271. package/lib/item/item.js +27 -13
  272. package/lib/item/item.js.map +1 -1
  273. package/lib/item/node.d.ts +2 -8
  274. package/lib/item/node.js +31 -19
  275. package/lib/item/node.js.map +1 -1
  276. package/lib/runtime/controller/data.d.ts +7 -10
  277. package/lib/runtime/controller/data.js +125 -281
  278. package/lib/runtime/controller/data.js.map +1 -1
  279. package/lib/runtime/controller/interaction.js +9 -4
  280. package/lib/runtime/controller/interaction.js.map +1 -1
  281. package/lib/runtime/controller/item.d.ts +1 -0
  282. package/lib/runtime/controller/item.js +284 -149
  283. package/lib/runtime/controller/item.js.map +1 -1
  284. package/lib/runtime/controller/layout.js +1 -3
  285. package/lib/runtime/controller/layout.js.map +1 -1
  286. package/lib/runtime/controller/plugin.js +9 -5
  287. package/lib/runtime/controller/plugin.js.map +1 -1
  288. package/lib/runtime/graph.d.ts +104 -24
  289. package/lib/runtime/graph.js +473 -94
  290. package/lib/runtime/graph.js.map +1 -1
  291. package/lib/stdlib/behavior/activate-relations.d.ts +1 -1
  292. package/lib/stdlib/behavior/activate-relations.js +2 -2
  293. package/lib/stdlib/behavior/activate-relations.js.map +1 -1
  294. package/lib/stdlib/behavior/brush-select.d.ts +9 -3
  295. package/lib/stdlib/behavior/brush-select.js +13 -12
  296. package/lib/stdlib/behavior/brush-select.js.map +1 -1
  297. package/lib/stdlib/behavior/click-select.d.ts +1 -1
  298. package/lib/stdlib/behavior/click-select.js +1 -1
  299. package/lib/stdlib/behavior/click-select.js.map +1 -1
  300. package/lib/stdlib/behavior/collapse-expand-combo.d.ts +1 -1
  301. package/lib/stdlib/behavior/collapse-expand-tree.d.ts +1 -1
  302. package/lib/stdlib/behavior/create-edge.d.ts +57 -0
  303. package/lib/stdlib/behavior/create-edge.js +219 -0
  304. package/lib/stdlib/behavior/create-edge.js.map +1 -0
  305. package/lib/stdlib/behavior/drag-canvas.d.ts +3 -1
  306. package/lib/stdlib/behavior/drag-canvas.js +78 -33
  307. package/lib/stdlib/behavior/drag-canvas.js.map +1 -1
  308. package/lib/stdlib/behavior/drag-combo.d.ts +3 -3
  309. package/lib/stdlib/behavior/drag-combo.js +43 -32
  310. package/lib/stdlib/behavior/drag-combo.js.map +1 -1
  311. package/lib/stdlib/behavior/drag-node.d.ts +4 -4
  312. package/lib/stdlib/behavior/drag-node.js +80 -63
  313. package/lib/stdlib/behavior/drag-node.js.map +1 -1
  314. package/lib/stdlib/behavior/index.d.ts +3 -0
  315. package/lib/stdlib/behavior/index.js +3 -0
  316. package/lib/stdlib/behavior/index.js.map +1 -1
  317. package/lib/stdlib/behavior/lasso-select.d.ts +1 -1
  318. package/lib/stdlib/behavior/lasso-select.js +6 -4
  319. package/lib/stdlib/behavior/lasso-select.js.map +1 -1
  320. package/lib/stdlib/behavior/scroll-canvas.d.ts +67 -0
  321. package/lib/stdlib/behavior/scroll-canvas.js +270 -0
  322. package/lib/stdlib/behavior/scroll-canvas.js.map +1 -0
  323. package/lib/stdlib/behavior/shortcuts-call.d.ts +38 -0
  324. package/lib/stdlib/behavior/shortcuts-call.js +91 -0
  325. package/lib/stdlib/behavior/shortcuts-call.js.map +1 -0
  326. package/lib/stdlib/behavior/zoom-canvas-3d.js +4 -1
  327. package/lib/stdlib/behavior/zoom-canvas-3d.js.map +1 -1
  328. package/lib/stdlib/behavior/zoom-canvas.d.ts +3 -1
  329. package/lib/stdlib/behavior/zoom-canvas.js +70 -26
  330. package/lib/stdlib/behavior/zoom-canvas.js.map +1 -1
  331. package/lib/stdlib/data/mapNodeSize.d.ts +2 -2
  332. package/lib/stdlib/data/mapNodeSize.js +2 -2
  333. package/lib/stdlib/data/mapNodeSize.js.map +1 -1
  334. package/lib/stdlib/data/transformV4Data.d.ts +2 -2
  335. package/lib/stdlib/data/transformV4Data.js +2 -2
  336. package/lib/stdlib/data/transformV4Data.js.map +1 -1
  337. package/lib/stdlib/data/validateData.d.ts +2 -2
  338. package/lib/stdlib/data/validateData.js +13 -12
  339. package/lib/stdlib/data/validateData.js.map +1 -1
  340. package/lib/stdlib/index.d.ts +18 -6
  341. package/lib/stdlib/index.js +22 -10
  342. package/lib/stdlib/index.js.map +1 -1
  343. package/lib/stdlib/item/edge/base.d.ts +3 -5
  344. package/lib/stdlib/item/edge/base.js +30 -29
  345. package/lib/stdlib/item/edge/base.js.map +1 -1
  346. package/lib/stdlib/item/edge/cubic-horizontal.js.map +1 -1
  347. package/lib/stdlib/item/edge/cubic-vertical.js.map +1 -1
  348. package/lib/stdlib/item/edge/cubic.js +2 -2
  349. package/lib/stdlib/item/edge/cubic.js.map +1 -1
  350. package/lib/stdlib/item/edge/loop.js +3 -3
  351. package/lib/stdlib/item/edge/loop.js.map +1 -1
  352. package/lib/stdlib/item/node/base.d.ts +3 -6
  353. package/lib/stdlib/item/node/base.js +29 -59
  354. package/lib/stdlib/item/node/base.js.map +1 -1
  355. package/lib/stdlib/item/node/base3d.d.ts +1 -0
  356. package/lib/stdlib/item/node/base3d.js +1 -0
  357. package/lib/stdlib/item/node/base3d.js.map +1 -1
  358. package/lib/stdlib/item/node/cube.d.ts +35 -0
  359. package/lib/stdlib/item/node/cube.js +58 -0
  360. package/lib/stdlib/item/node/cube.js.map +1 -0
  361. package/lib/stdlib/item/node/diamond.js +1 -1
  362. package/lib/stdlib/item/node/donut.d.ts +3 -3
  363. package/lib/stdlib/item/node/ellipse.js +2 -2
  364. package/lib/stdlib/item/node/hexagon.js +6 -2
  365. package/lib/stdlib/item/node/hexagon.js.map +1 -1
  366. package/lib/stdlib/item/node/image.d.ts +40 -0
  367. package/lib/stdlib/item/node/image.js +114 -0
  368. package/lib/stdlib/item/node/image.js.map +1 -0
  369. package/lib/stdlib/item/node/index.d.ts +4 -0
  370. package/lib/stdlib/item/node/index.js +4 -0
  371. package/lib/stdlib/item/node/index.js.map +1 -1
  372. package/lib/stdlib/plugin/edgeFilterLens/index.d.ts +66 -0
  373. package/lib/stdlib/plugin/edgeFilterLens/index.js +313 -0
  374. package/lib/stdlib/plugin/edgeFilterLens/index.js.map +1 -0
  375. package/lib/stdlib/plugin/grid/index.d.ts +1 -1
  376. package/lib/stdlib/plugin/grid/index.js +6 -7
  377. package/lib/stdlib/plugin/grid/index.js.map +1 -1
  378. package/lib/stdlib/plugin/history/combo-command.js +2 -2
  379. package/lib/stdlib/plugin/history/combo-command.js.map +1 -1
  380. package/lib/stdlib/plugin/history/index.d.ts +10 -10
  381. package/lib/stdlib/plugin/history/index.js +14 -14
  382. package/lib/stdlib/plugin/history/index.js.map +1 -1
  383. package/lib/stdlib/plugin/history/item-data-command.js +25 -16
  384. package/lib/stdlib/plugin/history/item-data-command.js.map +1 -1
  385. package/lib/stdlib/plugin/history/layer-updated-command.js +2 -2
  386. package/lib/stdlib/plugin/history/layer-updated-command.js.map +1 -1
  387. package/lib/stdlib/plugin/history/state-updated-command.js +1 -1
  388. package/lib/stdlib/plugin/history/state-updated-command.js.map +1 -1
  389. package/lib/stdlib/plugin/history/visibility-updated-command.js +2 -2
  390. package/lib/stdlib/plugin/history/visibility-updated-command.js.map +1 -1
  391. package/lib/stdlib/plugin/hull/convexHull.d.ts +1 -1
  392. package/lib/stdlib/plugin/hull/hullComponent.d.ts +2 -2
  393. package/lib/stdlib/plugin/hull/hullComponent.js +5 -9
  394. package/lib/stdlib/plugin/hull/hullComponent.js.map +1 -1
  395. package/lib/stdlib/plugin/hull/util.d.ts +2 -2
  396. package/lib/stdlib/plugin/hull/util.js +26 -22
  397. package/lib/stdlib/plugin/hull/util.js.map +1 -1
  398. package/lib/stdlib/plugin/index.d.ts +2 -0
  399. package/lib/stdlib/plugin/index.js +2 -0
  400. package/lib/stdlib/plugin/index.js.map +1 -1
  401. package/lib/stdlib/plugin/legend/index.d.ts +3 -3
  402. package/lib/stdlib/plugin/legend/index.js +3 -3
  403. package/lib/stdlib/plugin/legend/index.js.map +1 -1
  404. package/lib/stdlib/plugin/menu/index.d.ts +4 -4
  405. package/lib/stdlib/plugin/menu/index.js +6 -6
  406. package/lib/stdlib/plugin/menu/index.js.map +1 -1
  407. package/lib/stdlib/plugin/minimap/index.d.ts +6 -2
  408. package/lib/stdlib/plugin/minimap/index.js +121 -14
  409. package/lib/stdlib/plugin/minimap/index.js.map +1 -1
  410. package/lib/stdlib/plugin/snapline/index.d.ts +167 -0
  411. package/lib/stdlib/plugin/snapline/index.js +1067 -0
  412. package/lib/stdlib/plugin/snapline/index.js.map +1 -0
  413. package/lib/stdlib/plugin/timebar/index.d.ts +4 -4
  414. package/lib/stdlib/plugin/timebar/index.js +6 -6
  415. package/lib/stdlib/plugin/timebar/index.js.map +1 -1
  416. package/lib/stdlib/plugin/toolbar/index.d.ts +3 -3
  417. package/lib/stdlib/plugin/toolbar/index.js +5 -5
  418. package/lib/stdlib/plugin/toolbar/index.js.map +1 -1
  419. package/lib/stdlib/plugin/tooltip/index.d.ts +5 -5
  420. package/lib/stdlib/plugin/tooltip/index.js +10 -11
  421. package/lib/stdlib/plugin/tooltip/index.js.map +1 -1
  422. package/lib/stdlib/plugin/types.d.ts +2 -0
  423. package/lib/stdlib/plugin/watermaker/index.d.ts +78 -0
  424. package/lib/stdlib/plugin/watermaker/index.js +247 -0
  425. package/lib/stdlib/plugin/watermaker/index.js.map +1 -0
  426. package/lib/stdlib/theme/dark.js +42 -2
  427. package/lib/stdlib/theme/dark.js.map +1 -1
  428. package/lib/stdlib/theme/light.js +4 -4
  429. package/lib/types/animate.d.ts +2 -2
  430. package/lib/types/behavior.d.ts +1 -1
  431. package/lib/types/combo.d.ts +7 -7
  432. package/lib/types/common.d.ts +5 -5
  433. package/lib/types/data.d.ts +6 -6
  434. package/lib/types/edge.d.ts +9 -9
  435. package/lib/types/event.d.ts +2 -1
  436. package/lib/types/event.js +2 -2
  437. package/lib/types/event.js.map +1 -1
  438. package/lib/types/graph.d.ts +48 -22
  439. package/lib/types/history.d.ts +2 -2
  440. package/lib/types/history.js +1 -1
  441. package/lib/types/history.js.map +1 -1
  442. package/lib/types/hook.d.ts +23 -3
  443. package/lib/types/index.d.ts +2 -1
  444. package/lib/types/index.js +3 -1
  445. package/lib/types/index.js.map +1 -1
  446. package/lib/types/item.d.ts +18 -12
  447. package/lib/types/item.js +1 -1
  448. package/lib/types/item.js.map +1 -1
  449. package/lib/types/layout.d.ts +6 -6
  450. package/lib/types/loop.d.ts +2 -2
  451. package/lib/types/loop.js +1 -1
  452. package/lib/types/loop.js.map +1 -1
  453. package/lib/types/node.d.ts +7 -7
  454. package/lib/types/plugin.d.ts +1 -1
  455. package/lib/types/render.d.ts +1 -1
  456. package/lib/types/spec.d.ts +19 -3
  457. package/lib/types/stdlib.d.ts +1 -1
  458. package/lib/types/theme.d.ts +8 -8
  459. package/lib/types/view.d.ts +7 -2
  460. package/lib/util/bbox.d.ts +16 -1
  461. package/lib/util/bbox.js +36 -6
  462. package/lib/util/bbox.js.map +1 -1
  463. package/lib/util/behavior.d.ts +2 -2
  464. package/lib/util/behavior.js +2 -2
  465. package/lib/util/behavior.js.map +1 -1
  466. package/lib/util/data.d.ts +2 -2
  467. package/lib/util/data.js.map +1 -1
  468. package/lib/util/dom.d.ts +15 -0
  469. package/lib/util/dom.js +34 -0
  470. package/lib/util/dom.js.map +1 -0
  471. package/lib/util/event.d.ts +5 -3
  472. package/lib/util/event.js +8 -1
  473. package/lib/util/event.js.map +1 -1
  474. package/lib/util/extend.d.ts +1 -1
  475. package/lib/util/extend.js +0 -1
  476. package/lib/util/extend.js.map +1 -1
  477. package/lib/util/index.d.ts +7 -52
  478. package/lib/util/index.js +23 -23
  479. package/lib/util/index.js.map +1 -1
  480. package/lib/util/item.d.ts +16 -1
  481. package/lib/util/item.js +33 -9
  482. package/lib/util/item.js.map +1 -1
  483. package/lib/util/layout.d.ts +13 -2
  484. package/lib/util/layout.js +47 -1
  485. package/lib/util/layout.js.map +1 -1
  486. package/lib/util/loop.d.ts +1 -1
  487. package/lib/util/loop.js +4 -0
  488. package/lib/util/loop.js.map +1 -1
  489. package/lib/util/math.d.ts +1 -1
  490. package/lib/util/matrix.d.ts +6 -0
  491. package/lib/util/matrix.js +52 -0
  492. package/lib/util/matrix.js.map +1 -0
  493. package/lib/util/path.js +2 -2
  494. package/lib/util/path.js.map +1 -1
  495. package/lib/util/point.d.ts +1 -1
  496. package/lib/util/point.js +9 -2
  497. package/lib/util/point.js.map +1 -1
  498. package/lib/util/polyline.d.ts +2 -1
  499. package/lib/util/polyline.js +2 -1
  500. package/lib/util/polyline.js.map +1 -1
  501. package/lib/util/router.d.ts +1 -1
  502. package/lib/util/shape.d.ts +1 -2
  503. package/lib/util/shape.js +16 -26
  504. package/lib/util/shape.js.map +1 -1
  505. package/lib/util/shape3d.js +15 -16
  506. package/lib/util/shape3d.js.map +1 -1
  507. package/lib/util/text.d.ts +1 -1
  508. package/lib/util/text.js +3 -2
  509. package/lib/util/text.js.map +1 -1
  510. package/lib/util/warn.d.ts +14 -0
  511. package/lib/util/warn.js +8 -0
  512. package/lib/util/warn.js.map +1 -0
  513. package/package.json +41 -50
  514. package/src/api-doc/graph.ts +4 -3
  515. package/src/api-doc/types.ts +1 -0
  516. package/src/constant/shape.ts +1 -1
  517. package/src/index.ts +5 -6
  518. package/src/item/combo.ts +16 -15
  519. package/src/item/edge.ts +135 -57
  520. package/src/item/item.ts +32 -19
  521. package/src/item/node.ts +36 -50
  522. package/src/runtime/controller/data.ts +140 -339
  523. package/src/runtime/controller/interaction.ts +10 -4
  524. package/src/runtime/controller/item.ts +261 -78
  525. package/src/runtime/controller/layout.ts +1 -5
  526. package/src/runtime/controller/plugin.ts +15 -4
  527. package/src/runtime/graph.ts +605 -103
  528. package/src/stdlib/behavior/activate-relations.ts +2 -2
  529. package/src/stdlib/behavior/brush-select.ts +14 -13
  530. package/src/stdlib/behavior/click-select.ts +1 -1
  531. package/src/stdlib/behavior/create-edge.ts +305 -0
  532. package/src/stdlib/behavior/drag-canvas.ts +107 -35
  533. package/src/stdlib/behavior/drag-combo.ts +10 -10
  534. package/src/stdlib/behavior/drag-node.ts +27 -18
  535. package/src/stdlib/behavior/index.ts +3 -0
  536. package/src/stdlib/behavior/lasso-select.ts +7 -5
  537. package/src/stdlib/behavior/scroll-canvas.ts +348 -0
  538. package/src/stdlib/behavior/shortcuts-call.ts +129 -0
  539. package/src/stdlib/behavior/zoom-canvas-3d.ts +4 -1
  540. package/src/stdlib/behavior/zoom-canvas.ts +98 -27
  541. package/src/stdlib/data/mapNodeSize.ts +2 -2
  542. package/src/stdlib/data/transformV4Data.ts +2 -2
  543. package/src/stdlib/data/validateData.ts +16 -16
  544. package/src/stdlib/index.ts +28 -7
  545. package/src/stdlib/item/edge/base.ts +32 -41
  546. package/src/stdlib/item/edge/cubic-horizontal.ts +0 -1
  547. package/src/stdlib/item/edge/cubic-vertical.ts +0 -1
  548. package/src/stdlib/item/edge/cubic.ts +1 -1
  549. package/src/stdlib/item/edge/loop.ts +1 -1
  550. package/src/stdlib/item/node/base.ts +38 -65
  551. package/src/stdlib/item/node/base3d.ts +1 -0
  552. package/src/stdlib/item/node/cube.ts +102 -0
  553. package/src/stdlib/item/node/diamond.ts +1 -1
  554. package/src/stdlib/item/node/ellipse.ts +2 -2
  555. package/src/stdlib/item/node/hexagon.ts +6 -2
  556. package/src/stdlib/item/node/image.ts +190 -0
  557. package/src/stdlib/item/node/index.ts +4 -0
  558. package/src/stdlib/plugin/edgeFilterLens/index.ts +387 -0
  559. package/src/stdlib/plugin/grid/index.ts +6 -6
  560. package/src/stdlib/plugin/history/combo-command.ts +2 -2
  561. package/src/stdlib/plugin/history/index.ts +14 -14
  562. package/src/stdlib/plugin/history/item-data-command.ts +35 -17
  563. package/src/stdlib/plugin/history/layer-updated-command.ts +2 -2
  564. package/src/stdlib/plugin/history/state-updated-command.ts +1 -1
  565. package/src/stdlib/plugin/history/visibility-updated-command.ts +2 -2
  566. package/src/stdlib/plugin/hull/convexHull.ts +1 -1
  567. package/src/stdlib/plugin/hull/hullComponent.ts +10 -8
  568. package/src/stdlib/plugin/hull/util.ts +6 -2
  569. package/src/stdlib/plugin/index.ts +2 -0
  570. package/src/stdlib/plugin/legend/index.ts +6 -6
  571. package/src/stdlib/plugin/menu/index.ts +13 -13
  572. package/src/stdlib/plugin/minimap/index.ts +126 -16
  573. package/src/stdlib/plugin/snapline/index.ts +1297 -0
  574. package/src/stdlib/plugin/timebar/index.ts +4 -4
  575. package/src/stdlib/plugin/toolbar/index.ts +8 -8
  576. package/src/stdlib/plugin/tooltip/index.ts +10 -10
  577. package/src/stdlib/plugin/types.ts +2 -0
  578. package/src/stdlib/plugin/watermaker/index.ts +302 -0
  579. package/src/stdlib/theme/dark.ts +66 -2
  580. package/src/stdlib/theme/light.ts +4 -4
  581. package/src/types/event.ts +1 -0
  582. package/src/types/graph.ts +62 -25
  583. package/src/types/hook.ts +22 -2
  584. package/src/types/index.ts +2 -1
  585. package/src/types/item.ts +10 -0
  586. package/src/types/plugin.ts +1 -1
  587. package/src/types/spec.ts +22 -3
  588. package/src/types/view.ts +8 -3
  589. package/src/util/bbox.ts +42 -6
  590. package/src/util/behavior.ts +4 -4
  591. package/src/util/data.ts +2 -3
  592. package/src/util/dom.ts +33 -0
  593. package/src/util/event.ts +14 -1
  594. package/src/util/extend.ts +2 -3
  595. package/src/util/index.ts +7 -24
  596. package/src/util/item.ts +65 -28
  597. package/src/util/layout.ts +48 -2
  598. package/src/util/loop.ts +5 -1
  599. package/src/util/math.ts +1 -1
  600. package/src/util/matrix.ts +66 -0
  601. package/src/util/path.ts +1 -1
  602. package/src/util/point.ts +9 -4
  603. package/src/util/polyline.ts +2 -1
  604. package/src/util/router.ts +1 -1
  605. package/src/util/shape.ts +22 -26
  606. package/src/util/shape3d.ts +20 -20
  607. package/src/util/text.ts +3 -1
  608. package/src/util/warn.ts +20 -0
@@ -19,13 +19,16 @@ var __rest = (this && this.__rest) || function (s, e) {
19
19
  return t;
20
20
  };
21
21
  import EventEmitter from '@antv/event-emitter';
22
+ import { Rect, } from '@antv/g';
22
23
  import { clone, groupBy, isArray, isEmpty, isEqual, isNil, isNumber, isObject, isString, map, } from '@antv/util';
23
24
  import { changeRenderer, createCanvas } from '../util/canvas';
24
25
  import { formatPadding } from '../util/shape';
26
+ import { getLayoutBounds } from '../util/layout';
27
+ import { createDOM } from '../util/dom';
25
28
  import { DataController, ExtensionController, InteractionController, ItemController, LayoutController, ThemeController, ViewportController, } from './controller';
26
29
  import { PluginController } from './controller/plugin';
27
30
  import Hook from './hooks';
28
- export default class Graph extends EventEmitter {
31
+ export class Graph extends EventEmitter {
29
32
  constructor(spec) {
30
33
  super();
31
34
  this.defaultSpecification = {
@@ -39,17 +42,17 @@ export default class Graph extends EventEmitter {
39
42
  * Execute a callback without allowing any stacking operations.
40
43
  * @param callback
41
44
  */
42
- this.executeWithoutStacking = (callback) => {
45
+ this.executeWithNoStack = (callback) => {
43
46
  const history = this.getHistoryPlugin();
44
- history === null || history === void 0 ? void 0 : history.pauseStacking();
47
+ history === null || history === void 0 ? void 0 : history.pauseStack();
45
48
  try {
46
49
  callback();
47
50
  }
48
51
  finally {
49
- history === null || history === void 0 ? void 0 : history.resumeStacking();
52
+ history === null || history === void 0 ? void 0 : history.resumeStack();
50
53
  }
51
54
  };
52
- this.specification = Object.assign({}, this.defaultSpecification, spec);
55
+ this.specification = Object.assign({}, this.defaultSpecification, this.formatSpecification(spec));
53
56
  this.initHooks();
54
57
  this.initCanvas();
55
58
  this.initControllers();
@@ -129,11 +132,12 @@ export default class Graph extends EventEmitter {
129
132
  .getContextService()
130
133
  .getDomElement();
131
134
  if ($domElement && $domElement.style) {
132
- $domElement.style.position = 'fixed';
135
+ // Make all these 3 canvas doms overlap each other. The container already has `position: relative` style.
136
+ $domElement.style.position = 'absolute';
133
137
  $domElement.style.outline = 'none';
134
138
  $domElement.tabIndex = 1; // Enable keyboard events
135
139
  // Transient canvas should let interactive events go through.
136
- if (i === 2) {
140
+ if (i !== 1) {
137
141
  $domElement.style.pointerEvents = 'none';
138
142
  }
139
143
  }
@@ -193,16 +197,23 @@ export default class Graph extends EventEmitter {
193
197
  }),
194
198
  transientupdate: new Hook({ name: 'transientupdate' }),
195
199
  pluginchange: new Hook({ name: 'pluginchange' }),
196
- themechange: new Hook({ name: 'init' }),
200
+ themechange: new Hook({ name: 'themechange' }),
201
+ mapperchange: new Hook({ name: 'mapperchange' }),
197
202
  treecollapseexpand: new Hook({ name: 'treecollapseexpand' }),
198
203
  destroy: new Hook({ name: 'destroy' }),
199
204
  };
200
205
  }
206
+ formatSpecification(spec) {
207
+ var _a;
208
+ return Object.assign(Object.assign(Object.assign({}, this.specification), spec), { optimize: Object.assign(Object.assign({ tileBehavior: 2000, tileBehaviorSize: 1000, tileFirstRender: 10000, tileFirstRenderSize: 1000 }, (_a = this.specification) === null || _a === void 0 ? void 0 : _a.optimize), spec.optimize) });
209
+ }
201
210
  /**
202
211
  * Update the specs(configurations).
203
212
  */
204
213
  updateSpecification(spec) {
205
- return Object.assign(this.specification, spec);
214
+ const newSpec = Object.assign(this.specification, this.formatSpecification(spec));
215
+ // TODO: update something
216
+ return newSpec;
206
217
  }
207
218
  /**
208
219
  * Update the theme specs (configurations).
@@ -223,6 +234,28 @@ export default class Graph extends EventEmitter {
223
234
  theme: this.themeController.specification,
224
235
  });
225
236
  }
237
+ /**
238
+ * Update the item display mapper for a specific item type.
239
+ * @param {ITEM_TYPE} type - The type of item (node, edge, or combo).
240
+ * @param {NodeMapper | EdgeMapper | ComboMapper} mapper - The mapper to be updated.
241
+ * */
242
+ updateMapper(type, mapper) {
243
+ switch (type) {
244
+ case 'node':
245
+ this.specification.node = mapper;
246
+ break;
247
+ case 'edge':
248
+ this.specification.edge = mapper;
249
+ break;
250
+ case 'combo':
251
+ this.specification.combo = mapper;
252
+ break;
253
+ }
254
+ this.hooks.mapperchange.emit({
255
+ type,
256
+ mapper,
257
+ });
258
+ }
226
259
  /**
227
260
  * Get the copy of specs(configurations).
228
261
  * @returns graph specs
@@ -239,30 +272,39 @@ export default class Graph extends EventEmitter {
239
272
  */
240
273
  read(data) {
241
274
  return __awaiter(this, void 0, void 0, function* () {
275
+ const { tileFirstRender, tileFirstRenderSize } = this.specification.optimize || {};
242
276
  this.hooks.datachange.emit({ data, type: 'replace' });
243
277
  const emitRender = () => __awaiter(this, void 0, void 0, function* () {
244
- this.hooks.render.emit({
278
+ yield this.hooks.render.emitLinearAsync({
245
279
  graphCore: this.dataController.graphCore,
246
280
  theme: this.themeController.specification,
247
281
  transientCanvas: this.transientCanvas,
282
+ tileOptimize: {
283
+ tileFirstRender,
284
+ tileFirstRenderSize,
285
+ },
248
286
  });
249
287
  this.emit('afterrender');
250
288
  this.once('afterlayout', () => __awaiter(this, void 0, void 0, function* () {
251
289
  const { autoFit } = this.specification;
252
290
  if (autoFit) {
253
291
  if (autoFit === 'view') {
254
- yield this.fitView();
292
+ yield this.fitView({ rules: { boundsType: 'layout' } });
255
293
  }
256
294
  else if (autoFit === 'center') {
257
- yield this.fitCenter();
295
+ yield this.fitCenter('layout');
258
296
  }
259
297
  else {
260
298
  const { type, effectTiming } = autoFit, others = __rest(autoFit, ["type", "effectTiming"]);
261
299
  if (type === 'view') {
262
- yield this.fitView(others, effectTiming);
300
+ const { padding, rules } = others;
301
+ yield this.fitView({
302
+ padding,
303
+ rules: Object.assign(Object.assign({}, rules), { boundsType: 'layout' }),
304
+ }, effectTiming);
263
305
  }
264
306
  else if (type === 'center') {
265
- yield this.fitCenter(effectTiming);
307
+ yield this.fitCenter('layout', effectTiming);
266
308
  }
267
309
  else if (type === 'position') {
268
310
  // TODO: align
@@ -291,11 +333,16 @@ export default class Graph extends EventEmitter {
291
333
  */
292
334
  changeData(data, type = 'mergeReplace') {
293
335
  return __awaiter(this, void 0, void 0, function* () {
336
+ const { tileFirstRender, tileFirstRenderSize } = this.specification.optimize || {};
294
337
  this.hooks.datachange.emit({ data, type });
295
338
  this.hooks.render.emit({
296
339
  graphCore: this.dataController.graphCore,
297
340
  theme: this.themeController.specification,
298
341
  transientCanvas: this.transientCanvas,
342
+ tileOptimize: {
343
+ tileFirstRender,
344
+ tileFirstRenderSize,
345
+ },
299
346
  });
300
347
  this.emit('afterrender');
301
348
  yield this.layout();
@@ -306,11 +353,11 @@ export default class Graph extends EventEmitter {
306
353
  * @returns
307
354
  */
308
355
  clear() {
309
- this.startBatch();
356
+ this.startHistoryBatch();
310
357
  this.removeData('edge', this.getAllEdgesData().map((edge) => edge.id));
311
358
  this.removeData('node', this.getAllNodesData().map((node) => node.id));
312
359
  this.removeData('combo', this.getAllCombosData().map((combo) => combo.id));
313
- this.stopBatch();
360
+ this.stopHistoryBatch();
314
361
  }
315
362
  getViewportCenter() {
316
363
  const { width, height } = this.canvas.getConfig();
@@ -318,9 +365,11 @@ export default class Graph extends EventEmitter {
318
365
  }
319
366
  transform(options, effectTiming) {
320
367
  return __awaiter(this, void 0, void 0, function* () {
368
+ const { tileLodSize } = this.specification.optimize || {};
321
369
  yield this.hooks.viewportchange.emitLinearAsync({
322
370
  transform: options,
323
371
  effectTiming,
372
+ tileLodSize,
324
373
  });
325
374
  this.emit('viewportchange', options);
326
375
  });
@@ -428,9 +477,12 @@ export default class Graph extends EventEmitter {
428
477
  const [top, right, bottom, left] = padding
429
478
  ? formatPadding(padding)
430
479
  : [0, 0, 0, 0];
431
- const { direction = 'both', ratioRule = 'min' } = rules || {};
432
- // Get the bounds of the whole graph.
433
- const { center: [graphCenterX, graphCenterY], halfExtents, } = this.canvas.document.documentElement.getBounds();
480
+ const { direction = 'both', ratioRule = 'min', boundsType = 'render', } = rules || {};
481
+ const { center: [graphCenterX, graphCenterY], halfExtents, } = boundsType === 'render'
482
+ ? // Get the bounds of the whole graph content.
483
+ this.canvas.document.documentElement.getBounds()
484
+ : // Get the bounds of the nodes positions while the graph content is not ready.
485
+ getLayoutBounds(this);
434
486
  const origin = this.canvas.canvas2Viewport({
435
487
  x: graphCenterX,
436
488
  y: graphCenterY,
@@ -475,10 +527,13 @@ export default class Graph extends EventEmitter {
475
527
  * Fit the graph center to the view center.
476
528
  * @param effectTiming animation configurations
477
529
  */
478
- fitCenter(effectTiming) {
530
+ fitCenter(boundsType = 'render', effectTiming) {
479
531
  return __awaiter(this, void 0, void 0, function* () {
480
- // Get the bounds of the whole graph.
481
- const { center: [graphCenterX, graphCenterY], } = this.canvas.document.documentElement.getBounds();
532
+ const { center: [graphCenterX, graphCenterY], } = boundsType === 'render'
533
+ ? // Get the bounds of the whole graph content.
534
+ this.canvas.document.documentElement.getBounds()
535
+ : // Get the bounds of the nodes positions while the graph content is not ready.
536
+ getLayoutBounds(this);
482
537
  yield this.translateTo(this.canvas.canvas2Viewport({ x: graphCenterX, y: graphCenterY }), effectTiming);
483
538
  });
484
539
  }
@@ -535,9 +590,33 @@ export default class Graph extends EventEmitter {
535
590
  console.warn(`Failed to setSize. The parameter size: ${size} is invalid. It must be an array with 2 number elements.`);
536
591
  return;
537
592
  }
593
+ const oldSize = [this.specification.width, this.specification.height];
594
+ this.emit('beforesetsize', { oldSize, size: size });
538
595
  this.specification.width = size[0];
539
596
  this.specification.height = size[1];
540
597
  this.canvas.resize(size[0], size[1]);
598
+ this.transientCanvas.resize(size[0], size[1]);
599
+ this.backgroundCanvas.resize(size[0], size[1]);
600
+ this.emit('aftersetsize', { oldSize, size: size });
601
+ }
602
+ getCanvasRange() {
603
+ const [width, height] = this.getSize();
604
+ const leftTop = this.getCanvasByViewport({ x: 0, y: 0 });
605
+ const rightBottom = this.getCanvasByViewport({ x: width, y: height });
606
+ return {
607
+ min: [leftTop.x, leftTop.y, leftTop.z],
608
+ max: [rightBottom.x, rightBottom.y, rightBottom.z],
609
+ center: [
610
+ (leftTop.x + rightBottom.x) / 2,
611
+ (leftTop.y + rightBottom.y) / 2,
612
+ (leftTop.z + rightBottom.z) / 2,
613
+ ],
614
+ halfExtents: [
615
+ (rightBottom.x - leftTop.x) / 2,
616
+ (rightBottom.y - leftTop.y) / 2,
617
+ (rightBottom.z - leftTop.z) / 2,
618
+ ],
619
+ };
541
620
  }
542
621
  /**
543
622
  * Get the rendering coordinate according to the canvas dom (viewport) coordinate.
@@ -717,19 +796,21 @@ export default class Graph extends EventEmitter {
717
796
  if (!event.changes.length)
718
797
  return;
719
798
  const changes = event.changes;
720
- this.hooks.itemchange.emit({
721
- type: itemType,
722
- changes: graphCore.reduceChanges(event.changes),
723
- graphCore,
724
- theme: specification,
725
- });
726
- this.emit('afteritemchange', {
799
+ const timingParameters = {
727
800
  type: itemType,
728
801
  action: 'add',
729
802
  models,
730
803
  apiName: 'addData',
731
804
  changes,
805
+ };
806
+ this.emit('beforeitemchange', timingParameters);
807
+ this.hooks.itemchange.emit({
808
+ type: itemType,
809
+ changes: graphCore.reduceChanges(event.changes),
810
+ graphCore,
811
+ theme: specification,
732
812
  });
813
+ this.emit('afteritemchange', timingParameters);
733
814
  });
734
815
  const modelArr = isArray(models) ? models : [models];
735
816
  const data = { nodes: [], edges: [], combos: [] };
@@ -750,27 +831,38 @@ export default class Graph extends EventEmitter {
750
831
  removeData(itemType, ids) {
751
832
  const idArr = isArray(ids) ? ids : [ids];
752
833
  const data = { nodes: [], edges: [], combos: [] };
753
- const { userGraphCore, graphCore } = this.dataController;
834
+ const { graphCore } = this.dataController;
754
835
  const { specification } = this.themeController;
755
- const getItem = itemType === 'edge' ? userGraphCore.getEdge : userGraphCore.getNode;
756
- data[`${itemType}s`] = idArr.map((id) => getItem.bind(userGraphCore)(id));
836
+ const getItem = itemType === 'edge' ? graphCore.getEdge : graphCore.getNode;
837
+ const hasItem = itemType === 'edge' ? graphCore.hasEdge : graphCore.hasNode;
838
+ data[`${itemType}s`] = idArr
839
+ .map((id) => {
840
+ if (!hasItem.bind(graphCore)(id)) {
841
+ console.warn(`The ${itemType} data with id ${id} does not exist. It will be ignored`);
842
+ return;
843
+ }
844
+ return getItem.bind(graphCore)(id);
845
+ })
846
+ .filter(Boolean);
757
847
  graphCore.once('changed', (event) => {
758
848
  if (!event.changes.length)
759
849
  return;
760
850
  const changes = event.changes;
761
- this.hooks.itemchange.emit({
762
- type: itemType,
763
- changes: event.changes,
764
- graphCore,
765
- theme: specification,
766
- });
767
- this.emit('afteritemchange', {
851
+ const timingParameters = {
768
852
  type: itemType,
769
853
  action: 'remove',
770
854
  ids: idArr,
771
855
  apiName: 'removeData',
772
856
  changes,
857
+ };
858
+ this.emit('beforeitemchange', timingParameters);
859
+ this.hooks.itemchange.emit({
860
+ type: itemType,
861
+ changes: event.changes,
862
+ graphCore,
863
+ theme: specification,
773
864
  });
865
+ this.emit('afteritemchange', timingParameters);
774
866
  });
775
867
  this.hooks.datachange.emit({
776
868
  data,
@@ -838,19 +930,21 @@ export default class Graph extends EventEmitter {
838
930
  const { specification } = this.themeController;
839
931
  graphCore.once('changed', (event) => {
840
932
  const changes = this.extendChanges(clone(event.changes));
841
- this.hooks.itemchange.emit({
842
- type: itemType,
843
- changes: event.changes,
844
- graphCore,
845
- theme: specification,
846
- });
847
- this.emit('afteritemchange', {
933
+ const timingParameters = {
848
934
  type: itemType,
849
935
  action: 'update',
850
936
  models,
851
937
  apiName: 'updateData',
852
938
  changes,
939
+ };
940
+ this.emit('beforeitemchange', timingParameters);
941
+ this.hooks.itemchange.emit({
942
+ type: itemType,
943
+ changes: event.changes,
944
+ graphCore,
945
+ theme: specification,
853
946
  });
947
+ this.emit('afteritemchange', timingParameters);
854
948
  });
855
949
  this.hooks.datachange.emit({
856
950
  data,
@@ -893,10 +987,19 @@ export default class Graph extends EventEmitter {
893
987
  const modelArr = isArray(models) ? models : [models];
894
988
  const { graphCore } = this.dataController;
895
989
  const { specification } = this.themeController;
896
- graphCore.once('changed', (event) => {
990
+ graphCore === null || graphCore === void 0 ? void 0 : graphCore.once('changed', (event) => {
897
991
  if (!event.changes.length)
898
992
  return;
899
993
  const changes = event.changes.filter((change) => !isEqual(change.newValue, change.oldValue));
994
+ const timingParameters = {
995
+ type,
996
+ action: 'updatePosition',
997
+ upsertAncestors,
998
+ models,
999
+ apiName: 'updatePosition',
1000
+ changes,
1001
+ };
1002
+ this.emit('beforeitemchange', timingParameters);
900
1003
  this.hooks.itemchange.emit({
901
1004
  type,
902
1005
  changes: event.changes,
@@ -907,14 +1010,7 @@ export default class Graph extends EventEmitter {
907
1010
  animate: !disableAnimate,
908
1011
  callback,
909
1012
  });
910
- this.emit('afteritemchange', {
911
- type,
912
- action: 'updatePosition',
913
- upsertAncestors,
914
- models,
915
- apiName: 'updatePosition',
916
- changes,
917
- });
1013
+ this.emit('afteritemchange', timingParameters);
918
1014
  });
919
1015
  this.hooks.datachange.emit({
920
1016
  data: {
@@ -974,7 +1070,7 @@ export default class Graph extends EventEmitter {
974
1070
  * @returns
975
1071
  * @group Item
976
1072
  */
977
- hideItem(ids, disableAnimate = false) {
1073
+ hideItem(ids, disableAnimate = false, keepKeyShape = false) {
978
1074
  const idArr = isArray(ids) ? ids : [ids];
979
1075
  if (isEmpty(idArr))
980
1076
  return;
@@ -987,6 +1083,7 @@ export default class Graph extends EventEmitter {
987
1083
  value: false,
988
1084
  graphCore: this.dataController.graphCore,
989
1085
  animate: !disableAnimate,
1086
+ keepKeyShape,
990
1087
  });
991
1088
  this.emit('afteritemvisibilitychange', {
992
1089
  ids,
@@ -994,6 +1091,7 @@ export default class Graph extends EventEmitter {
994
1091
  animate: !disableAnimate,
995
1092
  action: 'updateVisibility',
996
1093
  apiName: 'hideItem',
1094
+ keepKeyShape,
997
1095
  changes,
998
1096
  });
999
1097
  }
@@ -1071,7 +1169,7 @@ export default class Graph extends EventEmitter {
1071
1169
  value,
1072
1170
  });
1073
1171
  this.emit('afteritemstatechange', {
1074
- ids,
1172
+ ids: idArr,
1075
1173
  states,
1076
1174
  value,
1077
1175
  action: 'updateState',
@@ -1118,7 +1216,7 @@ export default class Graph extends EventEmitter {
1118
1216
  value: false,
1119
1217
  });
1120
1218
  this.emit('afteritemstatechange', {
1121
- ids,
1219
+ ids: idArr,
1122
1220
  states,
1123
1221
  value: false,
1124
1222
  action: 'updateState',
@@ -1161,19 +1259,21 @@ export default class Graph extends EventEmitter {
1161
1259
  if (!event.changes.length)
1162
1260
  return;
1163
1261
  const changes = event.changes;
1164
- this.hooks.itemchange.emit({
1165
- type: 'combo',
1166
- changes: graphCore.reduceChanges(event.changes),
1167
- graphCore,
1168
- theme: specification,
1169
- });
1170
- this.emit('afteritemchange', {
1262
+ const timingParameters = {
1171
1263
  type: 'combo',
1172
1264
  action: 'add',
1173
1265
  models: [model],
1174
1266
  apiName: 'addCombo',
1175
1267
  changes,
1268
+ };
1269
+ this.emit('beforeitemchange', timingParameters);
1270
+ this.hooks.itemchange.emit({
1271
+ type: 'combo',
1272
+ changes: graphCore.reduceChanges(event.changes),
1273
+ graphCore,
1274
+ theme: specification,
1176
1275
  });
1276
+ this.emit('afteritemchange', timingParameters);
1177
1277
  });
1178
1278
  const data = {
1179
1279
  nodes: [],
@@ -1195,7 +1295,7 @@ export default class Graph extends EventEmitter {
1195
1295
  */
1196
1296
  collapseCombo(comboIds) {
1197
1297
  const ids = isArray(comboIds) ? comboIds : [comboIds];
1198
- this.executeWithoutStacking(() => {
1298
+ this.executeWithNoStack(() => {
1199
1299
  this.updateData('combo', ids.map((id) => ({ id, data: { collapsed: true } })));
1200
1300
  });
1201
1301
  this.emit('aftercollapsecombo', {
@@ -1212,7 +1312,7 @@ export default class Graph extends EventEmitter {
1212
1312
  */
1213
1313
  expandCombo(comboIds) {
1214
1314
  const ids = isArray(comboIds) ? comboIds : [comboIds];
1215
- this.executeWithoutStacking(() => {
1315
+ this.executeWithNoStack(() => {
1216
1316
  this.updateData('combo', ids.map((id) => ({ id, data: { collapsed: false } })));
1217
1317
  });
1218
1318
  this.emit('afterexpandcombo', {
@@ -1237,16 +1337,7 @@ export default class Graph extends EventEmitter {
1237
1337
  if (!event.changes.length)
1238
1338
  return;
1239
1339
  const changes = this.extendChanges(clone(event.changes));
1240
- this.hooks.itemchange.emit({
1241
- type: 'combo',
1242
- changes: event.changes,
1243
- graphCore,
1244
- theme: specification,
1245
- upsertAncestors,
1246
- action: 'updatePosition',
1247
- callback,
1248
- });
1249
- this.emit('afteritemchange', {
1340
+ const timingParameters = {
1250
1341
  type: 'combo',
1251
1342
  ids: idArr,
1252
1343
  dx,
@@ -1255,7 +1346,18 @@ export default class Graph extends EventEmitter {
1255
1346
  upsertAncestors,
1256
1347
  apiName: 'moveCombo',
1257
1348
  changes,
1349
+ };
1350
+ this.emit('beforeitemchange', timingParameters);
1351
+ this.hooks.itemchange.emit({
1352
+ type: 'combo',
1353
+ changes: event.changes,
1354
+ graphCore,
1355
+ theme: specification,
1356
+ upsertAncestors,
1357
+ action: 'updatePosition',
1358
+ callback,
1258
1359
  });
1360
+ this.emit('afteritemchange', timingParameters);
1259
1361
  });
1260
1362
  this.hooks.datachange.emit({
1261
1363
  data: {
@@ -1340,6 +1442,14 @@ export default class Graph extends EventEmitter {
1340
1442
  getMode() {
1341
1443
  return this.interactionController.getMode();
1342
1444
  }
1445
+ /**
1446
+ * Set the cursor. But the cursor in item's style has higher priority.
1447
+ * @param cursor
1448
+ */
1449
+ setCursor(cursor) {
1450
+ this.canvas.setCursor(cursor);
1451
+ this.transientCanvas.setCursor(cursor);
1452
+ }
1343
1453
  /**
1344
1454
  * Add behavior(s) to mode(s).
1345
1455
  * @param behaviors behavior names or configs
@@ -1510,6 +1620,274 @@ export default class Graph extends EventEmitter {
1510
1620
  });
1511
1621
  return this.itemController.getTransient(String(id));
1512
1622
  }
1623
+ // ===== download operations =====
1624
+ /**
1625
+ * Asynchronously generates a Data URL representation of the canvas content, including
1626
+ * background, main content, and transient canvas.
1627
+ * @param The type of the Data URL (e.g., 'image/png', 'image/jpeg').
1628
+ * @returns A Promise that resolves to the Data URL string.
1629
+ */
1630
+ toDataURL(type) {
1631
+ return __awaiter(this, void 0, void 0, function* () {
1632
+ const backgroundCanvas = this.backgroundCanvas;
1633
+ const canvas = this.canvas;
1634
+ const transientCanvas = this.transientCanvas;
1635
+ const rendererType = this.rendererType;
1636
+ const pixelRatio = typeof window !== 'undefined' ? window.devicePixelRatio : 1;
1637
+ const width = this.getSize()[0];
1638
+ const height = this.getSize()[1];
1639
+ const vContainerDOM = createDOM('<div id="virtual-image"></div>');
1640
+ const vCanvas = createCanvas(rendererType, vContainerDOM, width, height, pixelRatio);
1641
+ const vCanvasContextService = vCanvas.getContextService();
1642
+ let bgRect;
1643
+ if (rendererType !== 'svg') {
1644
+ bgRect = new Rect({
1645
+ style: {
1646
+ x: 0,
1647
+ y: 0,
1648
+ z: -1,
1649
+ width: vCanvasContextService.getDomElement().width,
1650
+ height: vCanvasContextService.getDomElement().height,
1651
+ //@ts-ignore
1652
+ fill: backgroundCanvas.getContextService().getDomElement().style['background-color'],
1653
+ },
1654
+ });
1655
+ vCanvas.appendChild(bgRect);
1656
+ }
1657
+ const backgroundClonedGroup = backgroundCanvas.getRoot().cloneNode(true);
1658
+ const clonedGroup = canvas.getRoot().cloneNode(true);
1659
+ const transientClonedGroup = transientCanvas.getRoot().cloneNode(true);
1660
+ vCanvas.appendChild(backgroundClonedGroup);
1661
+ vCanvas.appendChild(clonedGroup);
1662
+ vCanvas.appendChild(transientClonedGroup);
1663
+ vCanvas.render();
1664
+ if (!type)
1665
+ type = 'image/png';
1666
+ let dataURL = '';
1667
+ yield vCanvasContextService.toDataURL({ type }).then((url) => {
1668
+ dataURL = url;
1669
+ });
1670
+ return dataURL;
1671
+ });
1672
+ }
1673
+ /**
1674
+ * Asynchronously generates a Data URL representation of the full canvas content,
1675
+ * including background, main content, and transient canvas, with optional padding.
1676
+ * @param type The type of the Data URL (e.g., 'image/png', 'image/jpeg').
1677
+ * @param imageConfig Configuration options for the image (optional).
1678
+ * @returns A Promise that resolves to the Data URL string.
1679
+ */
1680
+ toFullDataURL(type, imageConfig) {
1681
+ return __awaiter(this, void 0, void 0, function* () {
1682
+ const backgroundCanvas = this.backgroundCanvas;
1683
+ const canvas = this.canvas;
1684
+ const transientCanvas = this.transientCanvas;
1685
+ const backgroundRoot = canvas.getRoot();
1686
+ const root = canvas.getRoot();
1687
+ const transientRoot = transientCanvas.getRoot();
1688
+ const rendererType = this.rendererType;
1689
+ const backgroundBBox = backgroundRoot.getBBox();
1690
+ const BBox = root.getBBox();
1691
+ const transientBBox = transientRoot.getBBox();
1692
+ let padding = imageConfig ? imageConfig.padding : undefined;
1693
+ if (!padding) {
1694
+ padding = [0, 0, 0, 0];
1695
+ }
1696
+ else if (isNumber(padding)) {
1697
+ padding = [padding, padding, padding, padding];
1698
+ }
1699
+ const left = (transientBBox.left
1700
+ ? backgroundBBox.left
1701
+ ? Math.min(backgroundBBox.left, BBox.left, transientBBox.left)
1702
+ : Math.min(BBox.left, transientBBox.left)
1703
+ : BBox.left) - padding[3];
1704
+ const right = (transientBBox.right
1705
+ ? backgroundBBox.right
1706
+ ? Math.max(backgroundBBox.right, BBox.right, transientBBox.right)
1707
+ : Math.max(BBox.right, transientBBox.right)
1708
+ : BBox.right) + padding[1];
1709
+ const top = (transientBBox.top
1710
+ ? backgroundBBox.top
1711
+ ? Math.min(backgroundBBox.top, BBox.top, transientBBox.top)
1712
+ : Math.min(BBox.top, transientBBox.top)
1713
+ : BBox.top) - padding[0];
1714
+ const bottom = (transientBBox.bottom
1715
+ ? backgroundBBox.bottom
1716
+ ? Math.max(backgroundBBox.bottom, BBox.bottom, transientBBox.bottom)
1717
+ : Math.max(BBox.bottom, transientBBox.bottom)
1718
+ : BBox.bottom) + padding[2];
1719
+ const graphCenterX = (left + right) / 2;
1720
+ const graphCenterY = (top + bottom) / 2;
1721
+ const halfX = (right - left) / 2;
1722
+ const halfY = (bottom - top) / 2;
1723
+ const pixelRatio = typeof window !== 'undefined' ? window.devicePixelRatio : 1;
1724
+ const vWidth = halfX * 2;
1725
+ const vHeight = halfY * 2;
1726
+ const vContainerDOM = createDOM('<div id="virtual-image"></div>');
1727
+ const vCanvas = createCanvas(rendererType, vContainerDOM, vWidth, vHeight, pixelRatio);
1728
+ const vCanvasContextService = vCanvas.getContextService();
1729
+ if (rendererType !== 'svg') {
1730
+ const bgRect = new Rect({
1731
+ style: {
1732
+ x: 0,
1733
+ y: 0,
1734
+ z: -1,
1735
+ width: vCanvasContextService.getDomElement().width,
1736
+ height: vCanvasContextService.getDomElement().height,
1737
+ //@ts-ignore
1738
+ fill: backgroundCanvas.getContextService().getDomElement().style['background-color'],
1739
+ },
1740
+ });
1741
+ vCanvas.appendChild(bgRect);
1742
+ }
1743
+ const backgroundClonedGroup = backgroundRoot.cloneNode(true);
1744
+ const clonedGroup = root.cloneNode(true);
1745
+ const transientClonedGroup = transientRoot.cloneNode(true);
1746
+ const transPosition = [
1747
+ -graphCenterX + halfX,
1748
+ -graphCenterY + halfY,
1749
+ ];
1750
+ backgroundClonedGroup.setPosition(transPosition);
1751
+ clonedGroup.setPosition(transPosition);
1752
+ transientClonedGroup.setPosition(transPosition);
1753
+ vCanvas.appendChild(backgroundClonedGroup);
1754
+ vCanvas.appendChild(clonedGroup);
1755
+ vCanvas.appendChild(transientClonedGroup);
1756
+ vCanvas.render();
1757
+ if (!type)
1758
+ type = 'image/png';
1759
+ let dataURL = '';
1760
+ yield vCanvasContextService.toDataURL({ type }).then((url) => {
1761
+ dataURL = url;
1762
+ });
1763
+ return dataURL;
1764
+ });
1765
+ }
1766
+ /**
1767
+ * Converts a Data URL to an image file and handles the download of the image.
1768
+ * @param dataURL The Data URL of the image to be converted and downloaded.
1769
+ * @param renderer The renderer type ('svg' or other) used for the canvas.
1770
+ * @param link The HTML link element used for image download.
1771
+ * @param fileName The desired name for the downloaded image file.
1772
+ */
1773
+ dataURLToImage(dataURL, renderer, link, fileName) {
1774
+ if (!dataURL || dataURL === 'data:') {
1775
+ console.error('Download image failed. The graph is too large or there is invalid attribute values in graph items');
1776
+ return;
1777
+ }
1778
+ if (typeof window !== 'undefined') {
1779
+ if (window.Blob && window.URL && renderer !== 'svg') {
1780
+ const arr = dataURL.split(',');
1781
+ let mime = '';
1782
+ if (arr && arr.length > 0) {
1783
+ const match = arr[0].match(/:(.*?);/);
1784
+ // eslint-disable-next-line prefer-destructuring
1785
+ if (match && match.length >= 2)
1786
+ mime = match[1];
1787
+ }
1788
+ const bstr = atob(arr[1]);
1789
+ let n = bstr.length;
1790
+ const u8arr = new Uint8Array(n);
1791
+ while (n--) {
1792
+ u8arr[n] = bstr.charCodeAt(n);
1793
+ }
1794
+ const blobObj = new Blob([u8arr], { type: mime });
1795
+ if (window.navigator.msSaveBlob) {
1796
+ window.navigator.msSaveBlob(blobObj, fileName);
1797
+ }
1798
+ else {
1799
+ link.addEventListener('click', () => {
1800
+ link.download = fileName;
1801
+ link.href = window.URL.createObjectURL(blobObj);
1802
+ });
1803
+ }
1804
+ }
1805
+ else {
1806
+ link.addEventListener('click', () => {
1807
+ link.download = fileName;
1808
+ link.href = dataURL;
1809
+ });
1810
+ }
1811
+ }
1812
+ }
1813
+ /**
1814
+ * Initiates the download of the graph as an image with an optional name and type.
1815
+ * @param name The desired name for the downloaded image file (optional).
1816
+ * @param type The type of the image to download (optional, defaults to 'image/png').
1817
+ */
1818
+ downloadImage(name, type) {
1819
+ const self = this;
1820
+ // self.stopAnimate();
1821
+ const rendererType = this.rendererType;
1822
+ if (!type)
1823
+ type = 'image/png';
1824
+ const fileName = (name || 'graph') +
1825
+ (rendererType === 'svg' ? '.svg' : type.split('/')[1]);
1826
+ const link = document.createElement('a');
1827
+ self.asyncToDataUrl(type, (dataURL) => {
1828
+ this.dataURLToImage(dataURL, rendererType, link, fileName);
1829
+ const e = document.createEvent('MouseEvents');
1830
+ e.initEvent('click', false, false);
1831
+ link.dispatchEvent(e);
1832
+ });
1833
+ }
1834
+ /**
1835
+ * Initiates the download of the entire graph as an image with optional name, type, and padding configuration.
1836
+ * @param name The desired name for the downloaded image file (optional).
1837
+ * @param type The type of the image to download (optional, defaults to 'image/png').
1838
+ * @param imageConfig Configuration options for the image (optional).
1839
+ */
1840
+ downloadFullImage(name, type, imageConfig) {
1841
+ const self = this;
1842
+ const rendererType = this.rendererType;
1843
+ if (!type)
1844
+ type = 'image/png';
1845
+ const fileName = (name || 'graph') +
1846
+ (rendererType === 'svg' ? '.svg' : type.split('/')[1]);
1847
+ const link = document.createElement('a');
1848
+ self.asyncToFullDataUrl(type, imageConfig, (dataURL) => {
1849
+ this.dataURLToImage(dataURL, rendererType, link, fileName);
1850
+ const e = document.createEvent('MouseEvents');
1851
+ e.initEvent('click', false, false);
1852
+ link.dispatchEvent(e);
1853
+ });
1854
+ }
1855
+ /**
1856
+ * Asynchronously converts the canvas content to a Data URL of the specified type and invokes the provided callback.
1857
+ * @param type The type of the Data URL (optional, defaults to 'image/png').
1858
+ * @param callback A callback function to handle the Data URL (optional).
1859
+ */
1860
+ asyncToDataUrl(type, callback) {
1861
+ let dataURL = '';
1862
+ if (!type)
1863
+ type = 'image/png';
1864
+ setTimeout(() => __awaiter(this, void 0, void 0, function* () {
1865
+ yield this.toDataURL(type).then((url) => {
1866
+ dataURL = url;
1867
+ });
1868
+ if (callback)
1869
+ callback(dataURL);
1870
+ }), 16);
1871
+ }
1872
+ /**
1873
+ * Asynchronously converts the entire canvas content to a Data URL of the specified type
1874
+ * with optional padding, and invokes the provided callback.
1875
+ * @param type The type of the Data URL (optional, defaults to 'image/png').
1876
+ * @param imageConfig Configuration options for the image (optional).
1877
+ * @param callback A callback function to handle the Data URL (optional).
1878
+ */
1879
+ asyncToFullDataUrl(type, imageConfig, callback) {
1880
+ let dataURL = '';
1881
+ if (!type)
1882
+ type = 'image/png';
1883
+ setTimeout(() => __awaiter(this, void 0, void 0, function* () {
1884
+ yield this.toFullDataURL(type, imageConfig).then((url) => {
1885
+ dataURL = url;
1886
+ });
1887
+ if (callback)
1888
+ callback(dataURL);
1889
+ }), 16);
1890
+ }
1513
1891
  // ===== history operations =====
1514
1892
  /**
1515
1893
  * Determine if history (redo/undo) is enabled.
@@ -1531,16 +1909,16 @@ export default class Graph extends EventEmitter {
1531
1909
  /**
1532
1910
  * Pause stacking operation.
1533
1911
  */
1534
- pauseStacking() {
1912
+ pauseStack() {
1535
1913
  const history = this.getHistoryPlugin();
1536
- return history === null || history === void 0 ? void 0 : history.pauseStacking();
1914
+ return history === null || history === void 0 ? void 0 : history.pauseStack();
1537
1915
  }
1538
1916
  /**
1539
1917
  * Resume stacking operation.
1540
1918
  */
1541
- resumeStacking() {
1919
+ resumeStack() {
1542
1920
  const history = this.getHistoryPlugin();
1543
- return history === null || history === void 0 ? void 0 : history.resumeStacking();
1921
+ return history === null || history === void 0 ? void 0 : history.resumeStack();
1544
1922
  }
1545
1923
  /**
1546
1924
  * Retrieve the current redo stack which consists of operations that could be undone
@@ -1597,38 +1975,38 @@ export default class Graph extends EventEmitter {
1597
1975
  return history === null || history === void 0 ? void 0 : history.canRedo();
1598
1976
  }
1599
1977
  /**
1600
- * Begin a batch operation.
1601
- * Any operations performed between `startBatch` and `stopBatch` are grouped together.
1978
+ * Begin a historyBatch operation.
1979
+ * Any operations performed between `startHistoryBatch` and `stopHistoryBatch` are grouped together.
1602
1980
  * treated as a single operation when undoing or redoing.
1603
1981
  */
1604
- startBatch() {
1982
+ startHistoryBatch() {
1605
1983
  const history = this.getHistoryPlugin();
1606
- history === null || history === void 0 ? void 0 : history.startBatch();
1984
+ history === null || history === void 0 ? void 0 : history.startHistoryBatch();
1607
1985
  }
1608
1986
  /**
1609
- * End a batch operation.
1610
- * Any operations performed between `startBatch` and `stopBatch` are grouped together.
1987
+ * End a historyBatch operation.
1988
+ * Any operations performed between `startHistoryBatch` and `stopHistoryBatch` are grouped together.
1611
1989
  * treated as a single operation when undoing or redoing.
1612
1990
  */
1613
- stopBatch() {
1991
+ stopHistoryBatch() {
1614
1992
  const history = this.getHistoryPlugin();
1615
- history === null || history === void 0 ? void 0 : history.stopBatch();
1993
+ history === null || history === void 0 ? void 0 : history.stopHistoryBatch();
1616
1994
  }
1617
1995
  /**
1618
1996
  * Execute a provided function within a batched context
1619
1997
  * All operations performed inside callback will be treated as a composite operation
1620
- * more convenient way without manually invoking `startBatch` and `stopBatch`.
1998
+ * more convenient way without manually invoking `startHistoryBatch` and `stopHistoryBatch`.
1621
1999
  * @param callback The func containing operations to be batched together.
1622
2000
  */
1623
- batch(callback) {
2001
+ historyBatch(callback) {
1624
2002
  const history = this.getHistoryPlugin();
1625
- history === null || history === void 0 ? void 0 : history.batch(callback);
2003
+ history === null || history === void 0 ? void 0 : history.historyBatch(callback);
1626
2004
  }
1627
2005
  /**
1628
2006
  * Clear history stack
1629
2007
  * @param {StackType} stackType undo/redo stack
1630
2008
  */
1631
- clearStack(stackType) {
2009
+ cleanHistory(stackType) {
1632
2010
  const history = this.getHistoryPlugin();
1633
2011
  if (!stackType)
1634
2012
  return history === null || history === void 0 ? void 0 : history.clear();
@@ -1680,7 +2058,7 @@ export default class Graph extends EventEmitter {
1680
2058
  this.backgroundCanvas.destroy();
1681
2059
  this.transientCanvas.destroy();
1682
2060
  // clear history stack
1683
- this.clearStack();
2061
+ this.cleanHistory();
1684
2062
  callback === null || callback === void 0 ? void 0 : callback();
1685
2063
  // }, 500);
1686
2064
  this.hooks.destroy.emit({});