@antv/g6 5.0.0-alpha.8 → 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 (908) hide show
  1. package/dist/g6.min.js +6 -19
  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 +215 -95
  27. package/esm/index.js +11 -4
  28. package/esm/index.js.map +1 -1
  29. package/esm/item/combo.d.ts +79 -2
  30. package/esm/item/combo.js +186 -2
  31. package/esm/item/combo.js.map +1 -1
  32. package/esm/item/edge.d.ts +15 -12
  33. package/esm/item/edge.js +40 -14
  34. package/esm/item/edge.js.map +1 -1
  35. package/esm/item/item.d.ts +12 -10
  36. package/esm/item/item.js +155 -83
  37. package/esm/item/item.js.map +1 -1
  38. package/esm/item/node.d.ts +32 -23
  39. package/esm/item/node.js +70 -49
  40. package/esm/item/node.js.map +1 -1
  41. package/esm/runtime/controller/data.d.ts +28 -4
  42. package/esm/runtime/controller/data.js +562 -173
  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 +23 -8
  46. package/esm/runtime/controller/interaction.js.map +1 -1
  47. package/esm/runtime/controller/item.d.ts +47 -5
  48. package/esm/runtime/controller/item.js +712 -122
  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 +109 -13
  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 +226 -47
  59. package/esm/runtime/graph.js +710 -90
  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 +5 -3
  68. package/esm/stdlib/behavior/click-select.js +21 -7
  69. package/esm/stdlib/behavior/click-select.js.map +1 -1
  70. package/esm/stdlib/behavior/collapse-expand-combo.d.ts +28 -0
  71. package/esm/stdlib/behavior/collapse-expand-combo.js +35 -0
  72. package/esm/stdlib/behavior/collapse-expand-combo.js.map +1 -0
  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 +111 -0
  80. package/esm/stdlib/behavior/drag-combo.js +380 -0
  81. package/esm/stdlib/behavior/drag-combo.js.map +1 -0
  82. package/esm/stdlib/behavior/drag-node.d.ts +33 -13
  83. package/esm/stdlib/behavior/drag-node.js +252 -67
  84. package/esm/stdlib/behavior/drag-node.js.map +1 -1
  85. package/esm/stdlib/behavior/hover-activate.d.ts +2 -1
  86. package/esm/stdlib/behavior/hover-activate.js +2 -0
  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 +115 -49
  125. package/esm/stdlib/index.js +156 -37
  126. package/esm/stdlib/index.js.map +1 -1
  127. package/esm/stdlib/item/combo/circle.d.ts +29 -0
  128. package/esm/stdlib/item/combo/circle.js +56 -0
  129. package/esm/stdlib/item/combo/circle.js.map +1 -0
  130. package/esm/stdlib/item/combo/index.d.ts +2 -0
  131. package/esm/stdlib/item/combo/index.js +3 -0
  132. package/esm/stdlib/item/combo/index.js.map +1 -0
  133. package/esm/stdlib/item/combo/rect.d.ts +31 -0
  134. package/esm/stdlib/item/combo/rect.js +65 -0
  135. package/esm/stdlib/item/combo/rect.js.map +1 -0
  136. package/esm/stdlib/item/edge/base.d.ts +12 -3
  137. package/esm/stdlib/item/edge/base.js +39 -5
  138. package/esm/stdlib/item/edge/base.js.map +1 -1
  139. package/esm/stdlib/item/edge/cubic-horizontal.d.ts +36 -0
  140. package/esm/stdlib/item/edge/cubic-horizontal.js +56 -0
  141. package/esm/stdlib/item/edge/cubic-horizontal.js.map +1 -0
  142. package/esm/stdlib/item/edge/cubic-vertical.d.ts +36 -0
  143. package/esm/stdlib/item/edge/cubic-vertical.js +56 -0
  144. package/esm/stdlib/item/edge/cubic-vertical.js.map +1 -0
  145. package/esm/stdlib/item/edge/cubic.d.ts +59 -0
  146. package/esm/stdlib/item/edge/cubic.js +116 -0
  147. package/esm/stdlib/item/edge/cubic.js.map +1 -0
  148. package/esm/stdlib/item/edge/index.d.ts +6 -0
  149. package/esm/stdlib/item/edge/index.js +6 -0
  150. package/esm/stdlib/item/edge/index.js.map +1 -1
  151. package/esm/stdlib/item/edge/line.d.ts +1 -1
  152. package/esm/stdlib/item/edge/line.js +16 -1
  153. package/esm/stdlib/item/edge/line.js.map +1 -1
  154. package/esm/stdlib/item/edge/loop.d.ts +32 -0
  155. package/esm/stdlib/item/edge/loop.js +115 -0
  156. package/esm/stdlib/item/edge/loop.js.map +1 -0
  157. package/esm/stdlib/item/edge/polyline.d.ts +44 -0
  158. package/esm/stdlib/item/edge/polyline.js +92 -0
  159. package/esm/stdlib/item/edge/polyline.js.map +1 -0
  160. package/esm/stdlib/item/edge/quadratic.d.ts +40 -0
  161. package/esm/stdlib/item/edge/quadratic.js +78 -0
  162. package/esm/stdlib/item/edge/quadratic.js.map +1 -0
  163. package/esm/stdlib/item/node/base.d.ts +83 -38
  164. package/esm/stdlib/item/node/base.js +100 -15
  165. package/esm/stdlib/item/node/base.js.map +1 -1
  166. package/esm/stdlib/item/node/base3d.js +1 -1
  167. package/esm/stdlib/item/node/base3d.js.map +1 -1
  168. package/esm/stdlib/item/node/circle.js +5 -5
  169. package/esm/stdlib/item/node/circle.js.map +1 -1
  170. package/esm/stdlib/item/node/diamond.d.ts +32 -0
  171. package/esm/stdlib/item/node/diamond.js +79 -0
  172. package/esm/stdlib/item/node/diamond.js.map +1 -0
  173. package/esm/stdlib/item/node/donut.d.ts +70 -0
  174. package/esm/stdlib/item/node/donut.js +207 -0
  175. package/esm/stdlib/item/node/donut.js.map +1 -0
  176. package/esm/stdlib/item/node/ellipse.d.ts +32 -0
  177. package/esm/stdlib/item/node/ellipse.js +71 -0
  178. package/esm/stdlib/item/node/ellipse.js.map +1 -0
  179. package/esm/stdlib/item/node/hexagon.d.ts +33 -0
  180. package/esm/stdlib/item/node/hexagon.js +102 -0
  181. package/esm/stdlib/item/node/hexagon.js.map +1 -0
  182. package/esm/stdlib/item/node/index.d.ts +8 -0
  183. package/esm/stdlib/item/node/index.js +8 -0
  184. package/esm/stdlib/item/node/index.js.map +1 -1
  185. package/esm/stdlib/item/node/modelRect.d.ts +61 -0
  186. package/esm/stdlib/item/node/modelRect.js +186 -0
  187. package/esm/stdlib/item/node/modelRect.js.map +1 -0
  188. package/esm/stdlib/item/node/rect.d.ts +32 -0
  189. package/esm/stdlib/item/node/rect.js +75 -0
  190. package/esm/stdlib/item/node/rect.js.map +1 -0
  191. package/esm/stdlib/item/node/star.d.ts +34 -0
  192. package/esm/stdlib/item/node/star.js +115 -0
  193. package/esm/stdlib/item/node/star.js.map +1 -0
  194. package/esm/stdlib/item/node/triangle.d.ts +44 -0
  195. package/esm/stdlib/item/node/triangle.js +177 -0
  196. package/esm/stdlib/item/node/triangle.js.map +1 -0
  197. package/esm/stdlib/plugin/fisheye/index.d.ts +130 -0
  198. package/esm/stdlib/plugin/fisheye/index.js +488 -0
  199. package/esm/stdlib/plugin/fisheye/index.js.map +1 -0
  200. package/esm/stdlib/plugin/grid/index.d.ts +36 -0
  201. package/esm/stdlib/plugin/grid/index.js +81 -0
  202. package/esm/stdlib/plugin/grid/index.js.map +1 -0
  203. package/esm/stdlib/plugin/history/combo-command.d.ts +9 -0
  204. package/esm/stdlib/plugin/history/combo-command.js +21 -0
  205. package/esm/stdlib/plugin/history/combo-command.js.map +1 -0
  206. package/esm/stdlib/plugin/history/command.d.ts +18 -0
  207. package/esm/stdlib/plugin/history/command.js +51 -0
  208. package/esm/stdlib/plugin/history/command.js.map +1 -0
  209. package/esm/stdlib/plugin/history/index.d.ts +112 -0
  210. package/esm/stdlib/plugin/history/index.js +275 -0
  211. package/esm/stdlib/plugin/history/index.js.map +1 -0
  212. package/esm/stdlib/plugin/history/item-data-command.d.ts +14 -0
  213. package/esm/stdlib/plugin/history/item-data-command.js +63 -0
  214. package/esm/stdlib/plugin/history/item-data-command.js.map +1 -0
  215. package/esm/stdlib/plugin/history/layer-updated-command.d.ts +9 -0
  216. package/esm/stdlib/plugin/history/layer-updated-command.js +21 -0
  217. package/esm/stdlib/plugin/history/layer-updated-command.js.map +1 -0
  218. package/esm/stdlib/plugin/history/state-updated-command.d.ts +9 -0
  219. package/esm/stdlib/plugin/history/state-updated-command.js +20 -0
  220. package/esm/stdlib/plugin/history/state-updated-command.js.map +1 -0
  221. package/esm/stdlib/plugin/history/visibility-updated-command.d.ts +10 -0
  222. package/esm/stdlib/plugin/history/visibility-updated-command.js +23 -0
  223. package/esm/stdlib/plugin/history/visibility-updated-command.js.map +1 -0
  224. package/esm/stdlib/plugin/hull/bubbleset.d.ts +9 -0
  225. package/esm/stdlib/plugin/hull/bubbleset.js +592 -0
  226. package/esm/stdlib/plugin/hull/bubbleset.js.map +1 -0
  227. package/esm/stdlib/plugin/hull/convexHull.d.ts +14 -0
  228. package/esm/stdlib/plugin/hull/convexHull.js +56 -0
  229. package/esm/stdlib/plugin/hull/convexHull.js.map +1 -0
  230. package/esm/stdlib/plugin/hull/hullComponent.d.ts +87 -0
  231. package/esm/stdlib/plugin/hull/hullComponent.js +382 -0
  232. package/esm/stdlib/plugin/hull/hullComponent.js.map +1 -0
  233. package/esm/stdlib/plugin/hull/index.d.ts +59 -0
  234. package/esm/stdlib/plugin/hull/index.js +161 -0
  235. package/esm/stdlib/plugin/hull/index.js.map +1 -0
  236. package/esm/stdlib/plugin/hull/types.d.ts +15 -0
  237. package/esm/stdlib/plugin/hull/types.js +2 -0
  238. package/esm/stdlib/plugin/hull/types.js.map +1 -0
  239. package/esm/stdlib/plugin/hull/util.d.ts +77 -0
  240. package/esm/stdlib/plugin/hull/util.js +401 -0
  241. package/esm/stdlib/plugin/hull/util.js.map +1 -0
  242. package/esm/stdlib/plugin/index.d.ts +8 -0
  243. package/esm/stdlib/plugin/index.js +9 -0
  244. package/esm/stdlib/plugin/index.js.map +1 -0
  245. package/esm/stdlib/plugin/legend/index.d.ts +45 -3
  246. package/esm/stdlib/plugin/legend/index.js +47 -42
  247. package/esm/stdlib/plugin/legend/index.js.map +1 -1
  248. package/esm/stdlib/plugin/menu/index.d.ts +55 -0
  249. package/esm/stdlib/plugin/menu/index.js +237 -0
  250. package/esm/stdlib/plugin/menu/index.js.map +1 -0
  251. package/esm/stdlib/plugin/minimap/index.d.ts +11 -3
  252. package/esm/stdlib/plugin/minimap/index.js +19 -21
  253. package/esm/stdlib/plugin/minimap/index.js.map +1 -1
  254. package/esm/stdlib/plugin/toolbar/index.d.ts +59 -0
  255. package/esm/stdlib/plugin/toolbar/index.js +215 -0
  256. package/esm/stdlib/plugin/toolbar/index.js.map +1 -0
  257. package/esm/stdlib/plugin/tooltip/index.d.ts +96 -0
  258. package/esm/stdlib/plugin/tooltip/index.js +378 -0
  259. package/esm/stdlib/plugin/tooltip/index.js.map +1 -0
  260. package/esm/stdlib/plugin/types.d.ts +8 -0
  261. package/esm/stdlib/plugin/types.js +2 -0
  262. package/esm/stdlib/plugin/types.js.map +1 -0
  263. package/esm/stdlib/theme/dark.d.ts +1 -2
  264. package/esm/stdlib/theme/dark.js +13 -1
  265. package/esm/stdlib/theme/dark.js.map +1 -1
  266. package/esm/stdlib/theme/index.d.ts +2 -0
  267. package/esm/stdlib/theme/index.js +3 -0
  268. package/esm/stdlib/theme/index.js.map +1 -0
  269. package/esm/stdlib/theme/light.d.ts +1 -2
  270. package/esm/stdlib/theme/light.js +65 -10
  271. package/esm/stdlib/theme/light.js.map +1 -1
  272. package/esm/stdlib/themeSolver/base.d.ts +1 -1
  273. package/esm/stdlib/themeSolver/base.js +1 -1
  274. package/esm/stdlib/themeSolver/base.js.map +1 -1
  275. package/esm/stdlib/themeSolver/index.d.ts +3 -0
  276. package/esm/stdlib/themeSolver/index.js +4 -0
  277. package/esm/stdlib/themeSolver/index.js.map +1 -0
  278. package/esm/stdlib/themeSolver/spec.d.ts +2 -4
  279. package/esm/stdlib/themeSolver/spec.js +2 -2
  280. package/esm/stdlib/themeSolver/spec.js.map +1 -1
  281. package/esm/stdlib/themeSolver/subject.d.ts +2 -4
  282. package/esm/stdlib/themeSolver/subject.js +2 -2
  283. package/esm/stdlib/themeSolver/subject.js.map +1 -1
  284. package/esm/types/behavior.js.map +1 -1
  285. package/esm/types/combo.d.ts +51 -3
  286. package/esm/types/common.d.ts +10 -0
  287. package/esm/types/data.d.ts +13 -7
  288. package/esm/types/edge.d.ts +19 -5
  289. package/esm/types/event.d.ts +9 -1
  290. package/esm/types/event.js +8 -8
  291. package/esm/types/event.js.map +1 -1
  292. package/esm/types/graph.d.ts +169 -20
  293. package/esm/types/history.d.ts +28 -0
  294. package/esm/types/history.js +6 -0
  295. package/esm/types/history.js.map +1 -0
  296. package/esm/types/hook.d.ts +33 -6
  297. package/esm/types/index.d.ts +11 -5
  298. package/esm/types/index.js.map +1 -1
  299. package/esm/types/item.d.ts +14 -8
  300. package/esm/types/item.js.map +1 -1
  301. package/esm/types/layout.d.ts +4 -1
  302. package/esm/types/loop.d.ts +21 -0
  303. package/esm/types/loop.js +12 -0
  304. package/esm/types/loop.js.map +1 -0
  305. package/esm/types/node.d.ts +90 -10
  306. package/esm/types/plugin.d.ts +4 -0
  307. package/esm/types/plugin.js +1 -1
  308. package/esm/types/plugin.js.map +1 -1
  309. package/esm/types/spec.d.ts +26 -9
  310. package/esm/types/theme.d.ts +76 -10
  311. package/esm/types/theme.js +1 -2
  312. package/esm/types/theme.js.map +1 -1
  313. package/esm/util/animate.d.ts +2 -2
  314. package/esm/util/animate.js +52 -17
  315. package/esm/util/animate.js.map +1 -1
  316. package/esm/util/array.d.ts +8 -0
  317. package/esm/util/array.js +11 -1
  318. package/esm/util/array.js.map +1 -1
  319. package/esm/util/arrow.d.ts +17 -0
  320. package/esm/util/arrow.js +56 -0
  321. package/esm/util/arrow.js.map +1 -0
  322. package/esm/util/bbox.d.ts +106 -0
  323. package/esm/util/bbox.js +255 -0
  324. package/esm/util/bbox.js.map +1 -0
  325. package/esm/util/behavior.d.ts +2 -0
  326. package/esm/util/behavior.js +12 -0
  327. package/esm/util/behavior.js.map +1 -0
  328. package/esm/util/canvas.d.ts +1 -2
  329. package/esm/util/canvas.js +11 -20
  330. package/esm/util/canvas.js.map +1 -1
  331. package/esm/util/data.d.ts +96 -0
  332. package/esm/util/data.js +262 -0
  333. package/esm/util/data.js.map +1 -0
  334. package/esm/util/event.d.ts +29 -1
  335. package/esm/util/event.js +70 -0
  336. package/esm/util/event.js.map +1 -1
  337. package/esm/util/extend.d.ts +8 -2
  338. package/esm/util/extend.js.map +1 -1
  339. package/esm/util/index.d.ts +41 -3
  340. package/esm/util/index.js +20 -1
  341. package/esm/util/index.js.map +1 -1
  342. package/esm/util/item.d.ts +2 -1
  343. package/esm/util/item.js +38 -13
  344. package/esm/util/item.js.map +1 -1
  345. package/esm/util/layout.d.ts +40 -0
  346. package/esm/util/layout.js +160 -0
  347. package/esm/util/layout.js.map +1 -0
  348. package/esm/util/loop.d.ts +37 -0
  349. package/esm/util/loop.js +104 -0
  350. package/esm/util/loop.js.map +1 -0
  351. package/esm/util/mapper.js +4 -9
  352. package/esm/util/mapper.js.map +1 -1
  353. package/esm/util/math.d.ts +15 -0
  354. package/esm/util/math.js +14 -0
  355. package/esm/util/math.js.map +1 -1
  356. package/esm/util/mock.d.ts +30 -0
  357. package/esm/util/mock.js +69 -0
  358. package/esm/util/mock.js.map +1 -0
  359. package/esm/util/path.d.ts +11 -0
  360. package/esm/util/path.js +44 -0
  361. package/esm/util/path.js.map +1 -0
  362. package/esm/util/point.d.ts +24 -2
  363. package/esm/util/point.js +27 -2
  364. package/esm/util/point.js.map +1 -1
  365. package/esm/util/polyline.d.ts +113 -0
  366. package/esm/util/polyline.js +505 -0
  367. package/esm/util/polyline.js.map +1 -0
  368. package/esm/util/router.d.ts +31 -0
  369. package/esm/util/router.js +380 -0
  370. package/esm/util/router.js.map +1 -0
  371. package/esm/util/shape.d.ts +39 -4
  372. package/esm/util/shape.js +118 -2
  373. package/esm/util/shape.js.map +1 -1
  374. package/esm/util/shape3d.d.ts +1 -1
  375. package/esm/util/shape3d.js +12 -6
  376. package/esm/util/shape3d.js.map +1 -1
  377. package/esm/util/type.d.ts +6 -0
  378. package/esm/util/type.js +7 -1
  379. package/esm/util/type.js.map +1 -1
  380. package/esm/util/zoom.d.ts +2 -2
  381. package/esm/util/zoom.js +6 -2
  382. package/esm/util/zoom.js.map +1 -1
  383. package/lib/api-doc/behaviors.d.ts +2 -0
  384. package/lib/api-doc/behaviors.js +18 -0
  385. package/lib/api-doc/behaviors.js.map +1 -0
  386. package/lib/api-doc/graph.d.ts +4 -0
  387. package/lib/api-doc/graph.js +11 -0
  388. package/lib/api-doc/graph.js.map +1 -0
  389. package/lib/api-doc/item.d.ts +9 -0
  390. package/lib/api-doc/item.js +21 -0
  391. package/lib/api-doc/item.js.map +1 -0
  392. package/lib/api-doc/layout.d.ts +1 -0
  393. package/lib/api-doc/layout.js +3 -0
  394. package/lib/api-doc/layout.js.map +1 -0
  395. package/lib/api-doc/plugins.d.ts +1 -0
  396. package/lib/api-doc/plugins.js +18 -0
  397. package/lib/api-doc/plugins.js.map +1 -0
  398. package/lib/api-doc/types.d.ts +0 -0
  399. package/lib/api-doc/types.js +3 -0
  400. package/lib/api-doc/types.js.map +1 -0
  401. package/lib/api-doc/util.d.ts +3 -0
  402. package/lib/api-doc/util.js +10 -0
  403. package/lib/api-doc/util.js.map +1 -0
  404. package/lib/constant/shape.d.ts +7 -14
  405. package/lib/constant/shape.js +1 -0
  406. package/lib/constant/shape.js.map +1 -1
  407. package/lib/index.d.ts +215 -95
  408. package/lib/index.js +13 -3
  409. package/lib/index.js.map +1 -1
  410. package/lib/item/combo.d.ts +79 -2
  411. package/lib/item/combo.js +186 -2
  412. package/lib/item/combo.js.map +1 -1
  413. package/lib/item/edge.d.ts +15 -12
  414. package/lib/item/edge.js +40 -14
  415. package/lib/item/edge.js.map +1 -1
  416. package/lib/item/item.d.ts +12 -10
  417. package/lib/item/item.js +153 -81
  418. package/lib/item/item.js.map +1 -1
  419. package/lib/item/node.d.ts +32 -23
  420. package/lib/item/node.js +70 -49
  421. package/lib/item/node.js.map +1 -1
  422. package/lib/runtime/controller/data.d.ts +28 -4
  423. package/lib/runtime/controller/data.js +561 -172
  424. package/lib/runtime/controller/data.js.map +1 -1
  425. package/lib/runtime/controller/interaction.d.ts +1 -0
  426. package/lib/runtime/controller/interaction.js +22 -7
  427. package/lib/runtime/controller/interaction.js.map +1 -1
  428. package/lib/runtime/controller/item.d.ts +47 -5
  429. package/lib/runtime/controller/item.js +710 -120
  430. package/lib/runtime/controller/item.js.map +1 -1
  431. package/lib/runtime/controller/layout.d.ts +4 -1
  432. package/lib/runtime/controller/layout.js +132 -13
  433. package/lib/runtime/controller/layout.js.map +1 -1
  434. package/lib/runtime/controller/plugin.d.ts +11 -0
  435. package/lib/runtime/controller/plugin.js +39 -6
  436. package/lib/runtime/controller/plugin.js.map +1 -1
  437. package/lib/runtime/controller/theme.js +8 -4
  438. package/lib/runtime/controller/theme.js.map +1 -1
  439. package/lib/runtime/graph.d.ts +226 -47
  440. package/lib/runtime/graph.js +709 -89
  441. package/lib/runtime/graph.js.map +1 -1
  442. package/lib/stdlib/behavior/activate-relations.d.ts +2 -3
  443. package/lib/stdlib/behavior/activate-relations.js +14 -9
  444. package/lib/stdlib/behavior/activate-relations.js.map +1 -1
  445. package/lib/stdlib/behavior/brush-select.d.ts +3 -4
  446. package/lib/stdlib/behavior/brush-select.js +3 -2
  447. package/lib/stdlib/behavior/brush-select.js.map +1 -1
  448. package/lib/stdlib/behavior/click-select.d.ts +5 -3
  449. package/lib/stdlib/behavior/click-select.js +22 -7
  450. package/lib/stdlib/behavior/click-select.js.map +1 -1
  451. package/lib/stdlib/behavior/collapse-expand-combo.d.ts +28 -0
  452. package/lib/stdlib/behavior/collapse-expand-combo.js +39 -0
  453. package/lib/stdlib/behavior/collapse-expand-combo.js.map +1 -0
  454. package/lib/stdlib/behavior/collapse-expand-tree.d.ts +44 -0
  455. package/lib/stdlib/behavior/collapse-expand-tree.js +73 -0
  456. package/lib/stdlib/behavior/collapse-expand-tree.js.map +1 -0
  457. package/lib/stdlib/behavior/drag-canvas.d.ts +1 -2
  458. package/lib/stdlib/behavior/drag-canvas.js +16 -11
  459. package/lib/stdlib/behavior/drag-canvas.js.map +1 -1
  460. package/lib/stdlib/behavior/drag-combo.d.ts +111 -0
  461. package/lib/stdlib/behavior/drag-combo.js +384 -0
  462. package/lib/stdlib/behavior/drag-combo.js.map +1 -0
  463. package/lib/stdlib/behavior/drag-node.d.ts +33 -13
  464. package/lib/stdlib/behavior/drag-node.js +252 -66
  465. package/lib/stdlib/behavior/drag-node.js.map +1 -1
  466. package/lib/stdlib/behavior/hover-activate.d.ts +2 -1
  467. package/lib/stdlib/behavior/hover-activate.js +2 -0
  468. package/lib/stdlib/behavior/hover-activate.js.map +1 -1
  469. package/lib/stdlib/behavior/index.d.ts +15 -0
  470. package/lib/stdlib/behavior/index.js +32 -0
  471. package/lib/stdlib/behavior/index.js.map +1 -0
  472. package/lib/stdlib/behavior/lasso-select.d.ts +7 -3
  473. package/lib/stdlib/behavior/lasso-select.js +4 -6
  474. package/lib/stdlib/behavior/lasso-select.js.map +1 -1
  475. package/lib/stdlib/behavior/orbit-canvas-3d.d.ts +2 -3
  476. package/lib/stdlib/behavior/orbit-canvas-3d.js +4 -6
  477. package/lib/stdlib/behavior/orbit-canvas-3d.js.map +1 -1
  478. package/lib/stdlib/behavior/rotate-canvas-3d.d.ts +1 -2
  479. package/lib/stdlib/behavior/rotate-canvas-3d.js +2 -1
  480. package/lib/stdlib/behavior/rotate-canvas-3d.js.map +1 -1
  481. package/lib/stdlib/behavior/track-canvas-3d.d.ts +2 -3
  482. package/lib/stdlib/behavior/track-canvas-3d.js +4 -6
  483. package/lib/stdlib/behavior/track-canvas-3d.js.map +1 -1
  484. package/lib/stdlib/behavior/types.d.ts +13 -0
  485. package/lib/stdlib/behavior/types.js +3 -0
  486. package/lib/stdlib/behavior/types.js.map +1 -0
  487. package/lib/stdlib/behavior/zoom-canvas-3d.d.ts +1 -2
  488. package/lib/stdlib/behavior/zoom-canvas-3d.js +8 -7
  489. package/lib/stdlib/behavior/zoom-canvas-3d.js.map +1 -1
  490. package/lib/stdlib/behavior/zoom-canvas.d.ts +1 -2
  491. package/lib/stdlib/behavior/zoom-canvas.js +21 -18
  492. package/lib/stdlib/behavior/zoom-canvas.js.map +1 -1
  493. package/lib/stdlib/data/index.d.ts +3 -0
  494. package/lib/stdlib/data/index.js +20 -0
  495. package/lib/stdlib/data/index.js.map +1 -0
  496. package/lib/stdlib/data/mapNodeSize.d.ts +12 -0
  497. package/lib/stdlib/data/mapNodeSize.js +47 -0
  498. package/lib/stdlib/data/mapNodeSize.js.map +1 -0
  499. package/lib/stdlib/data/transformV4Data.d.ts +9 -0
  500. package/lib/stdlib/data/transformV4Data.js +146 -0
  501. package/lib/stdlib/data/transformV4Data.js.map +1 -0
  502. package/lib/stdlib/data/validateData.d.ts +9 -0
  503. package/lib/stdlib/data/validateData.js +102 -0
  504. package/lib/stdlib/data/validateData.js.map +1 -0
  505. package/lib/stdlib/index.d.ts +115 -49
  506. package/lib/stdlib/index.js +190 -47
  507. package/lib/stdlib/index.js.map +1 -1
  508. package/lib/stdlib/item/combo/circle.d.ts +29 -0
  509. package/lib/stdlib/item/combo/circle.js +60 -0
  510. package/lib/stdlib/item/combo/circle.js.map +1 -0
  511. package/lib/stdlib/item/combo/index.d.ts +2 -0
  512. package/lib/stdlib/item/combo/index.js +19 -0
  513. package/lib/stdlib/item/combo/index.js.map +1 -0
  514. package/lib/stdlib/item/combo/rect.d.ts +31 -0
  515. package/lib/stdlib/item/combo/rect.js +69 -0
  516. package/lib/stdlib/item/combo/rect.js.map +1 -0
  517. package/lib/stdlib/item/edge/base.d.ts +12 -3
  518. package/lib/stdlib/item/edge/base.js +38 -4
  519. package/lib/stdlib/item/edge/base.js.map +1 -1
  520. package/lib/stdlib/item/edge/cubic-horizontal.d.ts +36 -0
  521. package/lib/stdlib/item/edge/cubic-horizontal.js +60 -0
  522. package/lib/stdlib/item/edge/cubic-horizontal.js.map +1 -0
  523. package/lib/stdlib/item/edge/cubic-vertical.d.ts +36 -0
  524. package/lib/stdlib/item/edge/cubic-vertical.js +60 -0
  525. package/lib/stdlib/item/edge/cubic-vertical.js.map +1 -0
  526. package/lib/stdlib/item/edge/cubic.d.ts +59 -0
  527. package/lib/stdlib/item/edge/cubic.js +120 -0
  528. package/lib/stdlib/item/edge/cubic.js.map +1 -0
  529. package/lib/stdlib/item/edge/index.d.ts +6 -0
  530. package/lib/stdlib/item/edge/index.js +6 -0
  531. package/lib/stdlib/item/edge/index.js.map +1 -1
  532. package/lib/stdlib/item/edge/line.d.ts +1 -1
  533. package/lib/stdlib/item/edge/line.js +16 -1
  534. package/lib/stdlib/item/edge/line.js.map +1 -1
  535. package/lib/stdlib/item/edge/loop.d.ts +32 -0
  536. package/lib/stdlib/item/edge/loop.js +119 -0
  537. package/lib/stdlib/item/edge/loop.js.map +1 -0
  538. package/lib/stdlib/item/edge/polyline.d.ts +44 -0
  539. package/lib/stdlib/item/edge/polyline.js +96 -0
  540. package/lib/stdlib/item/edge/polyline.js.map +1 -0
  541. package/lib/stdlib/item/edge/quadratic.d.ts +40 -0
  542. package/lib/stdlib/item/edge/quadratic.js +82 -0
  543. package/lib/stdlib/item/edge/quadratic.js.map +1 -0
  544. package/lib/stdlib/item/node/base.d.ts +83 -38
  545. package/lib/stdlib/item/node/base.js +100 -15
  546. package/lib/stdlib/item/node/base.js.map +1 -1
  547. package/lib/stdlib/item/node/base3d.js +1 -1
  548. package/lib/stdlib/item/node/base3d.js.map +1 -1
  549. package/lib/stdlib/item/node/circle.js +5 -5
  550. package/lib/stdlib/item/node/circle.js.map +1 -1
  551. package/lib/stdlib/item/node/diamond.d.ts +32 -0
  552. package/lib/stdlib/item/node/diamond.js +83 -0
  553. package/lib/stdlib/item/node/diamond.js.map +1 -0
  554. package/lib/stdlib/item/node/donut.d.ts +70 -0
  555. package/lib/stdlib/item/node/donut.js +211 -0
  556. package/lib/stdlib/item/node/donut.js.map +1 -0
  557. package/lib/stdlib/item/node/ellipse.d.ts +32 -0
  558. package/lib/stdlib/item/node/ellipse.js +75 -0
  559. package/lib/stdlib/item/node/ellipse.js.map +1 -0
  560. package/lib/stdlib/item/node/hexagon.d.ts +33 -0
  561. package/lib/stdlib/item/node/hexagon.js +106 -0
  562. package/lib/stdlib/item/node/hexagon.js.map +1 -0
  563. package/lib/stdlib/item/node/index.d.ts +8 -0
  564. package/lib/stdlib/item/node/index.js +8 -0
  565. package/lib/stdlib/item/node/index.js.map +1 -1
  566. package/lib/stdlib/item/node/modelRect.d.ts +61 -0
  567. package/lib/stdlib/item/node/modelRect.js +190 -0
  568. package/lib/stdlib/item/node/modelRect.js.map +1 -0
  569. package/lib/stdlib/item/node/rect.d.ts +32 -0
  570. package/lib/stdlib/item/node/rect.js +79 -0
  571. package/lib/stdlib/item/node/rect.js.map +1 -0
  572. package/lib/stdlib/item/node/star.d.ts +34 -0
  573. package/lib/stdlib/item/node/star.js +119 -0
  574. package/lib/stdlib/item/node/star.js.map +1 -0
  575. package/lib/stdlib/item/node/triangle.d.ts +44 -0
  576. package/lib/stdlib/item/node/triangle.js +181 -0
  577. package/lib/stdlib/item/node/triangle.js.map +1 -0
  578. package/lib/stdlib/plugin/fisheye/index.d.ts +130 -0
  579. package/lib/stdlib/plugin/fisheye/index.js +492 -0
  580. package/lib/stdlib/plugin/fisheye/index.js.map +1 -0
  581. package/lib/stdlib/plugin/grid/index.d.ts +36 -0
  582. package/lib/stdlib/plugin/grid/index.js +85 -0
  583. package/lib/stdlib/plugin/grid/index.js.map +1 -0
  584. package/lib/stdlib/plugin/history/combo-command.d.ts +9 -0
  585. package/lib/stdlib/plugin/history/combo-command.js +25 -0
  586. package/lib/stdlib/plugin/history/combo-command.js.map +1 -0
  587. package/lib/stdlib/plugin/history/command.d.ts +18 -0
  588. package/lib/stdlib/plugin/history/command.js +54 -0
  589. package/lib/stdlib/plugin/history/command.js.map +1 -0
  590. package/lib/stdlib/plugin/history/index.d.ts +112 -0
  591. package/lib/stdlib/plugin/history/index.js +283 -0
  592. package/lib/stdlib/plugin/history/index.js.map +1 -0
  593. package/lib/stdlib/plugin/history/item-data-command.d.ts +14 -0
  594. package/lib/stdlib/plugin/history/item-data-command.js +67 -0
  595. package/lib/stdlib/plugin/history/item-data-command.js.map +1 -0
  596. package/lib/stdlib/plugin/history/layer-updated-command.d.ts +9 -0
  597. package/lib/stdlib/plugin/history/layer-updated-command.js +25 -0
  598. package/lib/stdlib/plugin/history/layer-updated-command.js.map +1 -0
  599. package/lib/stdlib/plugin/history/state-updated-command.d.ts +9 -0
  600. package/lib/stdlib/plugin/history/state-updated-command.js +24 -0
  601. package/lib/stdlib/plugin/history/state-updated-command.js.map +1 -0
  602. package/lib/stdlib/plugin/history/visibility-updated-command.d.ts +10 -0
  603. package/lib/stdlib/plugin/history/visibility-updated-command.js +27 -0
  604. package/lib/stdlib/plugin/history/visibility-updated-command.js.map +1 -0
  605. package/lib/stdlib/plugin/hull/bubbleset.d.ts +9 -0
  606. package/lib/stdlib/plugin/hull/bubbleset.js +596 -0
  607. package/lib/stdlib/plugin/hull/bubbleset.js.map +1 -0
  608. package/lib/stdlib/plugin/hull/convexHull.d.ts +14 -0
  609. package/lib/stdlib/plugin/hull/convexHull.js +61 -0
  610. package/lib/stdlib/plugin/hull/convexHull.js.map +1 -0
  611. package/lib/stdlib/plugin/hull/hullComponent.d.ts +87 -0
  612. package/lib/stdlib/plugin/hull/hullComponent.js +385 -0
  613. package/lib/stdlib/plugin/hull/hullComponent.js.map +1 -0
  614. package/lib/stdlib/plugin/hull/index.d.ts +59 -0
  615. package/lib/stdlib/plugin/hull/index.js +167 -0
  616. package/lib/stdlib/plugin/hull/index.js.map +1 -0
  617. package/lib/stdlib/plugin/hull/types.d.ts +15 -0
  618. package/lib/stdlib/plugin/hull/types.js +3 -0
  619. package/lib/stdlib/plugin/hull/types.js.map +1 -0
  620. package/lib/stdlib/plugin/hull/util.d.ts +77 -0
  621. package/lib/stdlib/plugin/hull/util.js +419 -0
  622. package/lib/stdlib/plugin/hull/util.js.map +1 -0
  623. package/lib/stdlib/plugin/index.d.ts +8 -0
  624. package/lib/stdlib/plugin/index.js +25 -0
  625. package/lib/stdlib/plugin/index.js.map +1 -0
  626. package/lib/stdlib/plugin/legend/index.d.ts +45 -3
  627. package/lib/stdlib/plugin/legend/index.js +46 -40
  628. package/lib/stdlib/plugin/legend/index.js.map +1 -1
  629. package/lib/stdlib/plugin/menu/index.d.ts +55 -0
  630. package/lib/stdlib/plugin/menu/index.js +244 -0
  631. package/lib/stdlib/plugin/menu/index.js.map +1 -0
  632. package/lib/stdlib/plugin/minimap/index.d.ts +11 -3
  633. package/lib/stdlib/plugin/minimap/index.js +19 -20
  634. package/lib/stdlib/plugin/minimap/index.js.map +1 -1
  635. package/lib/stdlib/plugin/toolbar/index.d.ts +59 -0
  636. package/lib/stdlib/plugin/toolbar/index.js +222 -0
  637. package/lib/stdlib/plugin/toolbar/index.js.map +1 -0
  638. package/lib/stdlib/plugin/tooltip/index.d.ts +96 -0
  639. package/lib/stdlib/plugin/tooltip/index.js +385 -0
  640. package/lib/stdlib/plugin/tooltip/index.js.map +1 -0
  641. package/lib/stdlib/plugin/types.d.ts +8 -0
  642. package/lib/stdlib/plugin/types.js +3 -0
  643. package/lib/stdlib/plugin/types.js.map +1 -0
  644. package/lib/stdlib/theme/dark.d.ts +1 -2
  645. package/lib/stdlib/theme/dark.js +14 -1
  646. package/lib/stdlib/theme/dark.js.map +1 -1
  647. package/lib/stdlib/theme/index.d.ts +2 -0
  648. package/lib/stdlib/theme/index.js +19 -0
  649. package/lib/stdlib/theme/index.js.map +1 -0
  650. package/lib/stdlib/theme/light.d.ts +1 -2
  651. package/lib/stdlib/theme/light.js +66 -10
  652. package/lib/stdlib/theme/light.js.map +1 -1
  653. package/lib/stdlib/themeSolver/base.d.ts +1 -1
  654. package/lib/stdlib/themeSolver/base.js +2 -1
  655. package/lib/stdlib/themeSolver/base.js.map +1 -1
  656. package/lib/stdlib/themeSolver/index.d.ts +3 -0
  657. package/lib/stdlib/themeSolver/index.js +20 -0
  658. package/lib/stdlib/themeSolver/index.js.map +1 -0
  659. package/lib/stdlib/themeSolver/spec.d.ts +2 -4
  660. package/lib/stdlib/themeSolver/spec.js +4 -6
  661. package/lib/stdlib/themeSolver/spec.js.map +1 -1
  662. package/lib/stdlib/themeSolver/subject.d.ts +2 -4
  663. package/lib/stdlib/themeSolver/subject.js +4 -4
  664. package/lib/stdlib/themeSolver/subject.js.map +1 -1
  665. package/lib/types/behavior.js.map +1 -1
  666. package/lib/types/combo.d.ts +51 -3
  667. package/lib/types/common.d.ts +10 -0
  668. package/lib/types/data.d.ts +13 -7
  669. package/lib/types/edge.d.ts +19 -5
  670. package/lib/types/event.d.ts +9 -1
  671. package/lib/types/event.js +10 -10
  672. package/lib/types/event.js.map +1 -1
  673. package/lib/types/graph.d.ts +169 -20
  674. package/lib/types/history.d.ts +28 -0
  675. package/lib/types/history.js +9 -0
  676. package/lib/types/history.js.map +1 -0
  677. package/lib/types/hook.d.ts +33 -6
  678. package/lib/types/index.d.ts +11 -5
  679. package/lib/types/index.js.map +1 -1
  680. package/lib/types/item.d.ts +14 -8
  681. package/lib/types/item.js +1 -1
  682. package/lib/types/item.js.map +1 -1
  683. package/lib/types/layout.d.ts +4 -1
  684. package/lib/types/loop.d.ts +21 -0
  685. package/lib/types/loop.js +15 -0
  686. package/lib/types/loop.js.map +1 -0
  687. package/lib/types/node.d.ts +90 -10
  688. package/lib/types/plugin.d.ts +4 -0
  689. package/lib/types/plugin.js.map +1 -1
  690. package/lib/types/spec.d.ts +26 -9
  691. package/lib/types/theme.d.ts +76 -10
  692. package/lib/types/theme.js +1 -2
  693. package/lib/types/theme.js.map +1 -1
  694. package/lib/util/animate.d.ts +2 -2
  695. package/lib/util/animate.js +52 -17
  696. package/lib/util/animate.js.map +1 -1
  697. package/lib/util/array.d.ts +8 -0
  698. package/lib/util/array.js +13 -2
  699. package/lib/util/array.js.map +1 -1
  700. package/lib/util/arrow.d.ts +17 -0
  701. package/lib/util/arrow.js +60 -0
  702. package/lib/util/arrow.js.map +1 -0
  703. package/lib/util/bbox.d.ts +106 -0
  704. package/lib/util/bbox.js +273 -0
  705. package/lib/util/bbox.js.map +1 -0
  706. package/lib/util/behavior.d.ts +2 -0
  707. package/lib/util/behavior.js +16 -0
  708. package/lib/util/behavior.js.map +1 -0
  709. package/lib/util/canvas.d.ts +1 -2
  710. package/lib/util/canvas.js +11 -20
  711. package/lib/util/canvas.js.map +1 -1
  712. package/lib/util/data.d.ts +96 -0
  713. package/lib/util/data.js +276 -0
  714. package/lib/util/data.js.map +1 -0
  715. package/lib/util/event.d.ts +29 -1
  716. package/lib/util/event.js +73 -1
  717. package/lib/util/event.js.map +1 -1
  718. package/lib/util/extend.d.ts +8 -2
  719. package/lib/util/extend.js.map +1 -1
  720. package/lib/util/index.d.ts +41 -3
  721. package/lib/util/index.js +20 -1
  722. package/lib/util/index.js.map +1 -1
  723. package/lib/util/item.d.ts +2 -1
  724. package/lib/util/item.js +38 -13
  725. package/lib/util/item.js.map +1 -1
  726. package/lib/util/layout.d.ts +40 -0
  727. package/lib/util/layout.js +172 -0
  728. package/lib/util/layout.js.map +1 -0
  729. package/lib/util/loop.d.ts +37 -0
  730. package/lib/util/loop.js +111 -0
  731. package/lib/util/loop.js.map +1 -0
  732. package/lib/util/mapper.js +4 -9
  733. package/lib/util/mapper.js.map +1 -1
  734. package/lib/util/math.d.ts +15 -0
  735. package/lib/util/math.js +17 -1
  736. package/lib/util/math.js.map +1 -1
  737. package/lib/util/mock.d.ts +30 -0
  738. package/lib/util/mock.js +73 -0
  739. package/lib/util/mock.js.map +1 -0
  740. package/lib/util/path.d.ts +11 -0
  741. package/lib/util/path.js +49 -0
  742. package/lib/util/path.js.map +1 -0
  743. package/lib/util/point.d.ts +24 -2
  744. package/lib/util/point.js +31 -3
  745. package/lib/util/point.js.map +1 -1
  746. package/lib/util/polyline.d.ts +113 -0
  747. package/lib/util/polyline.js +524 -0
  748. package/lib/util/polyline.js.map +1 -0
  749. package/lib/util/router.d.ts +31 -0
  750. package/lib/util/router.js +384 -0
  751. package/lib/util/router.js.map +1 -0
  752. package/lib/util/shape.d.ts +39 -4
  753. package/lib/util/shape.js +122 -3
  754. package/lib/util/shape.js.map +1 -1
  755. package/lib/util/shape3d.d.ts +1 -1
  756. package/lib/util/shape3d.js +11 -5
  757. package/lib/util/shape3d.js.map +1 -1
  758. package/lib/util/type.d.ts +6 -0
  759. package/lib/util/type.js +9 -2
  760. package/lib/util/type.js.map +1 -1
  761. package/lib/util/zoom.d.ts +2 -2
  762. package/lib/util/zoom.js +6 -2
  763. package/lib/util/zoom.js.map +1 -1
  764. package/package.json +42 -22
  765. package/src/api-doc/behaviors.ts +2 -0
  766. package/src/api-doc/graph.ts +4 -0
  767. package/src/api-doc/item.ts +43 -0
  768. package/src/api-doc/layout.ts +13 -0
  769. package/src/api-doc/plugins.ts +1 -0
  770. package/src/api-doc/readme.md +59 -0
  771. package/src/api-doc/types.ts +2 -0
  772. package/src/api-doc/util.ts +3 -0
  773. package/src/constant/shape.ts +4 -1
  774. package/src/index.ts +14 -4
  775. package/src/item/combo.ts +307 -2
  776. package/src/item/edge.ts +73 -24
  777. package/src/item/item.ts +184 -85
  778. package/src/item/node.ts +138 -69
  779. package/src/runtime/controller/data.ts +665 -191
  780. package/src/runtime/controller/interaction.ts +31 -7
  781. package/src/runtime/controller/item.ts +990 -172
  782. package/src/runtime/controller/layout.ts +165 -13
  783. package/src/runtime/controller/plugin.ts +47 -10
  784. package/src/runtime/controller/theme.ts +8 -4
  785. package/src/runtime/graph.ts +922 -144
  786. package/src/stdlib/behavior/activate-relations.ts +14 -11
  787. package/src/stdlib/behavior/brush-select.ts +4 -5
  788. package/src/stdlib/behavior/click-select.ts +26 -11
  789. package/src/stdlib/behavior/collapse-expand-combo.ts +57 -0
  790. package/src/stdlib/behavior/collapse-expand-tree.ts +106 -0
  791. package/src/stdlib/behavior/drag-canvas.ts +15 -13
  792. package/src/stdlib/behavior/drag-combo.ts +589 -0
  793. package/src/stdlib/behavior/drag-node.ts +380 -110
  794. package/src/stdlib/behavior/hover-activate.ts +3 -5
  795. package/src/stdlib/behavior/index.ts +15 -0
  796. package/src/stdlib/behavior/lasso-select.ts +6 -2
  797. package/src/stdlib/behavior/orbit-canvas-3d.ts +3 -5
  798. package/src/stdlib/behavior/rotate-canvas-3d.ts +1 -3
  799. package/src/stdlib/behavior/track-canvas-3d.ts +3 -5
  800. package/src/stdlib/behavior/types.ts +15 -0
  801. package/src/stdlib/behavior/zoom-canvas-3d.ts +5 -7
  802. package/src/stdlib/behavior/zoom-canvas.ts +19 -19
  803. package/src/stdlib/data/index.ts +3 -0
  804. package/src/stdlib/data/mapNodeSize.ts +67 -0
  805. package/src/stdlib/data/transformV4Data.ts +207 -0
  806. package/src/stdlib/data/validateData.ts +146 -0
  807. package/src/stdlib/index.ts +221 -37
  808. package/src/stdlib/item/combo/circle.ts +113 -0
  809. package/src/stdlib/item/combo/index.ts +2 -0
  810. package/src/stdlib/item/combo/rect.ts +123 -0
  811. package/src/stdlib/item/edge/base.ts +71 -6
  812. package/src/stdlib/item/edge/cubic-horizontal.ts +86 -0
  813. package/src/stdlib/item/edge/cubic-vertical.ts +85 -0
  814. package/src/stdlib/item/edge/cubic.ts +198 -0
  815. package/src/stdlib/item/edge/index.ts +6 -0
  816. package/src/stdlib/item/edge/line.ts +14 -15
  817. package/src/stdlib/item/edge/loop.ts +162 -0
  818. package/src/stdlib/item/edge/polyline.ts +161 -0
  819. package/src/stdlib/item/edge/quadratic.ts +133 -0
  820. package/src/stdlib/item/node/base.ts +195 -53
  821. package/src/stdlib/item/node/base3d.ts +2 -0
  822. package/src/stdlib/item/node/circle.ts +5 -5
  823. package/src/stdlib/item/node/diamond.ts +144 -0
  824. package/src/stdlib/item/node/donut.ts +368 -0
  825. package/src/stdlib/item/node/ellipse.ts +128 -0
  826. package/src/stdlib/item/node/hexagon.ts +168 -0
  827. package/src/stdlib/item/node/index.ts +8 -0
  828. package/src/stdlib/item/node/modelRect.ts +405 -0
  829. package/src/stdlib/item/node/rect.ts +141 -0
  830. package/src/stdlib/item/node/star.ts +181 -0
  831. package/src/stdlib/item/node/triangle.ts +265 -0
  832. package/src/stdlib/plugin/fisheye/index.ts +607 -0
  833. package/src/stdlib/plugin/grid/index.ts +125 -0
  834. package/src/stdlib/plugin/history/combo-command.ts +28 -0
  835. package/src/stdlib/plugin/history/command.ts +81 -0
  836. package/src/stdlib/plugin/history/index.ts +347 -0
  837. package/src/stdlib/plugin/history/item-data-command.ts +96 -0
  838. package/src/stdlib/plugin/history/layer-updated-command.ts +28 -0
  839. package/src/stdlib/plugin/history/state-updated-command.ts +36 -0
  840. package/src/stdlib/plugin/history/visibility-updated-command.ts +41 -0
  841. package/src/stdlib/plugin/hull/bubbleset.ts +828 -0
  842. package/src/stdlib/plugin/hull/convexHull.ts +68 -0
  843. package/src/stdlib/plugin/hull/hullComponent.ts +501 -0
  844. package/src/stdlib/plugin/hull/index.ts +234 -0
  845. package/src/stdlib/plugin/hull/types.ts +15 -0
  846. package/src/stdlib/plugin/hull/util.ts +511 -0
  847. package/src/stdlib/plugin/index.ts +8 -0
  848. package/src/stdlib/plugin/legend/index.ts +122 -61
  849. package/src/stdlib/plugin/menu/index.ts +275 -0
  850. package/src/stdlib/plugin/minimap/index.ts +35 -26
  851. package/src/stdlib/plugin/toolbar/index.ts +257 -0
  852. package/src/stdlib/plugin/tooltip/index.ts +444 -0
  853. package/src/stdlib/plugin/types.ts +8 -0
  854. package/src/stdlib/theme/dark.ts +13 -1
  855. package/src/stdlib/theme/index.ts +2 -0
  856. package/src/stdlib/theme/light.ts +88 -10
  857. package/src/stdlib/themeSolver/base.ts +1 -1
  858. package/src/stdlib/themeSolver/index.ts +3 -0
  859. package/src/stdlib/themeSolver/spec.ts +2 -5
  860. package/src/stdlib/themeSolver/subject.ts +2 -5
  861. package/src/types/behavior.ts +0 -1
  862. package/src/types/combo.ts +61 -4
  863. package/src/types/common.ts +13 -0
  864. package/src/types/data.ts +28 -7
  865. package/src/types/edge.ts +30 -6
  866. package/src/types/event.ts +8 -8
  867. package/src/types/graph.ts +232 -25
  868. package/src/types/history.ts +30 -0
  869. package/src/types/hook.ts +37 -7
  870. package/src/types/index.ts +37 -12
  871. package/src/types/item.ts +25 -11
  872. package/src/types/layout.ts +20 -16
  873. package/src/types/loop.ts +23 -0
  874. package/src/types/node.ts +94 -14
  875. package/src/types/plugin.ts +7 -1
  876. package/src/types/spec.ts +30 -13
  877. package/src/types/theme.ts +80 -10
  878. package/src/util/animate.ts +60 -20
  879. package/src/util/array.ts +12 -1
  880. package/src/util/arrow.ts +62 -0
  881. package/src/util/bbox.ts +298 -0
  882. package/src/util/behavior.ts +14 -0
  883. package/src/util/canvas.ts +16 -24
  884. package/src/util/data.ts +307 -0
  885. package/src/util/event.ts +114 -1
  886. package/src/util/extend.ts +8 -2
  887. package/src/util/index.ts +31 -1
  888. package/src/util/item.ts +79 -13
  889. package/src/util/layout.ts +165 -0
  890. package/src/util/loop.ts +145 -0
  891. package/src/util/mapper.ts +10 -9
  892. package/src/util/math.ts +24 -0
  893. package/src/util/mock.ts +72 -0
  894. package/src/util/path.ts +52 -0
  895. package/src/util/point.ts +33 -2
  896. package/src/util/polyline.ts +676 -0
  897. package/src/util/router.ts +552 -0
  898. package/src/util/shape.ts +159 -6
  899. package/src/util/shape3d.ts +16 -11
  900. package/src/util/type.ts +8 -1
  901. package/src/util/zoom.ts +8 -4
  902. package/esm/stdlib/data/comboFromNode.d.ts +0 -9
  903. package/esm/stdlib/data/comboFromNode.js +0 -28
  904. package/esm/stdlib/data/comboFromNode.js.map +0 -1
  905. package/lib/stdlib/data/comboFromNode.d.ts +0 -9
  906. package/lib/stdlib/data/comboFromNode.js +0 -32
  907. package/lib/stdlib/data/comboFromNode.js.map +0 -1
  908. package/src/stdlib/data/comboFromNode.ts +0 -28
@@ -1,13 +1,26 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
1
10
  import { Group } from '@antv/g';
2
- import { debounce, isArray, isObject, throttle } from '@antv/util';
11
+ import { debounce, each, isArray, isObject, map, throttle, uniq, uniqueId, } from '@antv/util';
12
+ import { DirectionalLight, AmbientLight } from '@antv/g-plugin-3d';
3
13
  import registry from '../../stdlib';
4
14
  import Node from '../../item/node';
5
15
  import Edge from '../../item/edge';
6
- import { upsertShape } from '../../util/shape';
16
+ import Combo from '../../item/combo';
17
+ import { getCombinedBoundsByData, upsertShape } from '../../util/shape';
7
18
  import { getExtension } from '../../util/extension';
8
19
  import { upsertTransientItem } from '../../util/item';
9
- import { DirectionalLight, AmbientLight } from '@antv/g-plugin-3d';
10
20
  import { formatLodStrategy } from '../../util/zoom';
21
+ import { deconstructData, graphComboTreeDfs, graphCoreTreeDfs, traverseAncestors, traverseAncestorsAndSucceeds, traverseGraphAncestors, } from '../../util/data';
22
+ import { getGroupedChanges } from '../../util/event';
23
+ import { EdgeCollisionChecker, QuadTree } from '../../util/polyline';
11
24
  /**
12
25
  * Manages and stores the node / edge / combo items.
13
26
  */
@@ -19,18 +32,18 @@ export class ItemController {
19
32
  /**
20
33
  * Node / edge / combo items map
21
34
  */
22
- this.itemMap = {};
23
- // TODO: combo? not a independent group
35
+ this.itemMap = new Map();
24
36
  this.nodeDataTypeSet = new Set();
25
37
  this.edgeDataTypeSet = new Set();
38
+ this.comboDataTypeSet = new Set();
26
39
  // The G shapes or groups on transient map drawn by this controller
27
- this.transientObjectMap = {};
28
- this.transientItemMap = {};
40
+ this.transientObjectMap = new Map();
41
+ this.transientItemMap = new Map();
29
42
  this.onViewportChange = debounce(({ transform, effectTiming }) => {
30
43
  const { zoom } = transform;
31
44
  if (zoom) {
32
45
  const zoomRatio = this.graph.getZoom();
33
- Object.values(this.itemMap).forEach((item) => item.updateZoom(zoomRatio));
46
+ this.itemMap.forEach((item) => item.updateZoom(zoomRatio));
34
47
  this.zoom = zoomRatio;
35
48
  }
36
49
  }, 500, false);
@@ -39,7 +52,7 @@ export class ItemController {
39
52
  return;
40
53
  const { nodeDataTypeSet, edgeDataTypeSet } = this;
41
54
  const { node: nodeTheme, edge: edgeTheme } = theme;
42
- Object.values(this.itemMap).forEach((item) => {
55
+ this.itemMap.forEach((item) => {
43
56
  const itemTye = item.getType();
44
57
  const usingTheme = itemTye === 'node' ? nodeTheme : edgeTheme;
45
58
  const usingTypeSet = itemTye === 'node' ? nodeDataTypeSet : edgeDataTypeSet;
@@ -53,10 +66,12 @@ export class ItemController {
53
66
  };
54
67
  this.onDestroy = () => {
55
68
  Object.values(this.itemMap).forEach((item) => item.destroy());
69
+ // Fix OOM problem, since this map will hold all the refs of items.
70
+ this.itemMap.clear();
56
71
  };
57
72
  this.graph = graph;
58
73
  // get mapper for node / edge / combo
59
- const { node, edge, combo, nodeState, edgeState, comboState } = graph.getSpecification();
74
+ const { node, edge, combo, nodeState = {}, edgeState = {}, comboState = {}, } = graph.getSpecification();
60
75
  this.nodeMapper = node;
61
76
  this.edgeMapper = edge;
62
77
  this.comboMapper = combo;
@@ -78,9 +93,11 @@ export class ItemController {
78
93
  this.graph.hooks.itemchange.tap(this.onChange.bind(this));
79
94
  this.graph.hooks.itemstatechange.tap(this.onItemStateChange.bind(this));
80
95
  this.graph.hooks.itemvisibilitychange.tap(this.onItemVisibilityChange.bind(this));
96
+ this.graph.hooks.itemzindexchange.tap(this.onItemZIndexChange.bind(this));
81
97
  this.graph.hooks.transientupdate.tap(this.onTransientUpdate.bind(this));
82
98
  this.graph.hooks.viewportchange.tap(this.onViewportChange.bind(this));
83
99
  this.graph.hooks.themechange.tap(this.onThemeChange.bind(this));
100
+ this.graph.hooks.treecollapseexpand.tap(this.onTreeCollapseExpand.bind(this));
84
101
  this.graph.hooks.destroy.tap(this.onDestroy.bind(this));
85
102
  }
86
103
  /**
@@ -89,9 +106,9 @@ export class ItemController {
89
106
  getExtensions() {
90
107
  // TODO: user need to config using node/edge/combo types from useLib to spec?
91
108
  const { node, edge, combo } = this.graph.getSpecification();
92
- const nodeTypes = Object.keys(registry.useLib.nodes);
93
- const edgeTypes = Object.keys(registry.useLib.edges);
94
- const comboTypes = Object.keys(registry.useLib.combos);
109
+ const nodeTypes = Object.keys(registry.useLib.nodes || {});
110
+ const edgeTypes = Object.keys(registry.useLib.edges || {});
111
+ const comboTypes = Object.keys(registry.useLib.combos || {});
95
112
  return {
96
113
  node: nodeTypes
97
114
  .map((config) => getExtension(config, registry.useLib, 'node'))
@@ -113,16 +130,21 @@ export class ItemController {
113
130
  const { graph } = this;
114
131
  // 0. clear groups on canvas, and create new groups
115
132
  graph.canvas.removeChildren();
133
+ const comboGroup = new Group({ id: 'combo-group' });
116
134
  const edgeGroup = new Group({ id: 'edge-group' });
117
135
  const nodeGroup = new Group({ id: 'node-group' });
136
+ graph.canvas.appendChild(comboGroup);
118
137
  graph.canvas.appendChild(edgeGroup);
119
138
  graph.canvas.appendChild(nodeGroup);
120
139
  this.nodeGroup = nodeGroup;
121
140
  this.edgeGroup = edgeGroup;
141
+ this.comboGroup = comboGroup;
122
142
  // Also create transient groups on transient canvas.
123
143
  transientCanvas.removeChildren();
144
+ this.transientComboGroup = new Group({ id: 'combo-group' });
124
145
  this.transientEdgeGroup = new Group({ id: 'edge-group' });
125
146
  this.transientNodeGroup = new Group({ id: 'node-group' });
147
+ transientCanvas.appendChild(this.transientComboGroup);
126
148
  transientCanvas.appendChild(this.transientEdgeGroup);
127
149
  transientCanvas.appendChild(this.transientNodeGroup);
128
150
  // 1. create lights for webgl 3d rendering
@@ -140,134 +162,233 @@ export class ItemController {
140
162
  intensity: Math.PI * 0.7,
141
163
  },
142
164
  });
165
+ // @ts-ignore
143
166
  graph.canvas.appendChild(ambientLight);
167
+ // @ts-ignore
144
168
  graph.canvas.appendChild(light);
145
169
  const { width, height } = graph.canvas.getConfig();
146
170
  graph.canvas.getCamera().setPerspective(0.1, 50000, 45, width / height);
147
171
  }
148
172
  // 2. create node / edge / combo items, classes from ../../item, and element drawing and updating fns from node/edge/comboExtensions
149
- const nodeModels = graphCore.getAllNodes();
150
- const edgeModels = graphCore.getAllEdges();
151
- // const combos = graphCore.getAllCombos();
152
- this.renderNodes(nodeModels, theme.node);
153
- this.renderEdges(edgeModels, theme.edge);
154
- // TODO: combo
173
+ const { nodes, edges, combos } = deconstructData({
174
+ nodes: graphCore.getAllNodes(),
175
+ edges: graphCore.getAllEdges(),
176
+ });
177
+ this.renderNodes(nodes, theme.node);
178
+ this.renderCombos(combos, theme.combo, graphCore);
179
+ this.renderEdges(edges, theme.edge);
180
+ this.sortByComboTree(graphCore);
181
+ // collapse the combos which has 'collapsed' in initial data
182
+ if (graphCore.hasTreeStructure('combo')) {
183
+ graphCoreTreeDfs(graphCore, graphCore.getRoots('combo'), (child) => {
184
+ if (child.data.collapsed)
185
+ this.collapseCombo(graphCore, child);
186
+ }, 'BT', 'combo');
187
+ }
188
+ // collapse the sub tree which has 'collapsed' in initial data
189
+ if (graphCore.hasTreeStructure('tree')) {
190
+ const collapseNodes = [];
191
+ graphCoreTreeDfs(graphCore, graphCore.getRoots('tree'), (child) => {
192
+ if (child.data.collapsed)
193
+ collapseNodes.push(child);
194
+ }, 'BT', 'tree');
195
+ this.collapseSubTree(collapseNodes, graphCore, false);
196
+ }
155
197
  }
156
198
  /**
157
199
  * Listener of runtime's itemchange lifecycle hook.
158
200
  * @param param
159
201
  */
160
202
  onChange(param) {
161
- const { changes, graphCore, theme = {}, action } = param;
162
- const groupedChanges = {
163
- NodeRemoved: [],
164
- EdgeRemoved: [],
165
- NodeAdded: [],
166
- EdgeAdded: [],
167
- NodeDataUpdated: [],
168
- EdgeUpdated: [],
169
- EdgeDataUpdated: [],
170
- };
171
- changes.forEach((change) => {
172
- const { type: changeType } = change;
173
- groupedChanges[changeType].push(change);
174
- });
203
+ const { changes, graphCore, action, animate = true, upsertAncestors = true, theme = {}, callback = () => { }, } = param;
204
+ const groupedChanges = getGroupedChanges(graphCore, changes);
175
205
  const { itemMap } = this;
176
206
  // change items according to the order of the keys in groupedChanges
177
207
  // === 1. remove edges; 2. remove nodes ===
178
- groupedChanges.EdgeRemoved.concat(groupedChanges.NodeRemoved).forEach(({ value }) => {
208
+ [...groupedChanges.EdgeRemoved, ...groupedChanges.NodeRemoved].forEach(({ value }) => {
179
209
  const { id } = value;
180
- const item = itemMap[id];
210
+ const item = itemMap.get(id);
181
211
  if (item) {
182
212
  item.destroy();
183
- delete itemMap[id];
213
+ itemMap.delete(id);
184
214
  }
185
215
  });
186
- const { node: nodeTheme = {}, edge: edgeTheme = {} } = theme;
216
+ const { node: nodeTheme = {}, edge: edgeTheme = {}, combo: comboTheme = {}, } = theme;
187
217
  // === 3. add nodes ===
188
218
  if (groupedChanges.NodeAdded.length) {
189
- this.renderNodes(groupedChanges.NodeAdded.map((change) => change.value), nodeTheme);
219
+ const newNodes = [];
220
+ const newCombos = [];
221
+ groupedChanges.NodeAdded.map((change) => change.value).forEach((model) => {
222
+ if (model.data._isCombo)
223
+ newCombos.push(model);
224
+ else
225
+ newNodes.push(model);
226
+ });
227
+ if (newNodes.length) {
228
+ this.renderNodes(newNodes, nodeTheme);
229
+ }
230
+ if (newCombos.length) {
231
+ this.renderCombos(newCombos, comboTheme, graphCore);
232
+ }
190
233
  }
191
234
  // === 4. add edges ===
192
235
  if (groupedChanges.EdgeAdded.length) {
193
236
  this.renderEdges(groupedChanges.EdgeAdded.map((change) => change.value), edgeTheme);
194
237
  }
195
238
  // === 5. update nodes's data ===
196
- // merge changes for each node
239
+ // merge changes for each node or combo
197
240
  if (groupedChanges.NodeDataUpdated.length) {
198
- const nodeUpdate = {};
241
+ const nodeComboUpdate = {};
199
242
  groupedChanges.NodeDataUpdated.forEach((change) => {
200
243
  const { id, propertyName, newValue, oldValue } = change;
201
- nodeUpdate[id] = nodeUpdate[id] || { previous: {}, current: {} };
244
+ nodeComboUpdate[id] = nodeComboUpdate[id] || {
245
+ id,
246
+ previous: {},
247
+ current: {},
248
+ };
202
249
  if (!propertyName) {
203
- nodeUpdate[id] = {
250
+ nodeComboUpdate[id] = {
251
+ id,
204
252
  isReplace: true,
205
253
  previous: oldValue,
206
254
  current: newValue,
207
255
  };
208
256
  }
209
257
  else {
210
- nodeUpdate[id].previous[propertyName] = oldValue;
211
- nodeUpdate[id].current[propertyName] = newValue;
258
+ nodeComboUpdate[id].previous[propertyName] = oldValue;
259
+ nodeComboUpdate[id].current[propertyName] = newValue;
212
260
  }
213
261
  });
214
262
  const { dataTypeField: nodeDataTypeField } = nodeTheme;
215
- const edgeToUpdate = {};
216
- const updateEdges = throttle((updateMap) => {
217
- Object.keys(updateMap || edgeToUpdate).forEach((id) => {
218
- const item = itemMap[id];
263
+ const edgeIdsToUpdate = new Set();
264
+ const comboIdsToUpdate = new Set();
265
+ const updateRelates = (edgeIds) => {
266
+ const ids = edgeIds
267
+ ? [...edgeIds]
268
+ : [...comboIdsToUpdate, ...edgeIdsToUpdate];
269
+ ids.forEach((nid) => {
270
+ const item = itemMap.get(nid);
219
271
  if (item && !item.destroyed)
220
272
  item.forceUpdate();
221
273
  });
222
- }, 16, {
223
- leading: true,
224
- trailing: true,
225
- });
226
- Object.keys(nodeUpdate).forEach((id) => {
227
- const { isReplace, previous, current } = nodeUpdate[id];
274
+ };
275
+ const debounceUpdateRelates = debounce(updateRelates, 16, false);
276
+ Object.values(nodeComboUpdate).forEach((updateObj) => {
277
+ var _a;
278
+ const { isReplace, previous, current, id } = updateObj;
279
+ if (!graphCore.hasNode(id))
280
+ return;
281
+ const onlyMove = action === 'updatePosition';
282
+ const item = itemMap.get(id);
283
+ if (!item || item.destroyed)
284
+ return;
285
+ const type = item.getType();
286
+ const innerModel = graphCore.getNode(id);
287
+ if (onlyMove &&
288
+ type === 'node' &&
289
+ isNaN(current.x) &&
290
+ isNaN(current.y)) {
291
+ callback(innerModel, true);
292
+ return;
293
+ }
294
+ const nodeRelatedIdsToUpdate = new Set();
295
+ // collapse and expand
296
+ if (graphCore.hasTreeStructure('combo')) {
297
+ if (type === 'combo' && current.collapsed !== previous.collapsed) {
298
+ if (current.collapsed) {
299
+ this.collapseCombo(graphCore, innerModel);
300
+ }
301
+ else if (current.collapsed === false) {
302
+ this.expandCombo(graphCore, innerModel);
303
+ }
304
+ }
305
+ const previousParentId = item.displayModel.data.parentId;
306
+ // update the current parent combo tree
307
+ // if the node has previous parent, related previous parent combo should be updated to
308
+ if (upsertAncestors) {
309
+ const begins = [innerModel];
310
+ if (previousParentId &&
311
+ previousParentId !== current.parentId &&
312
+ graphCore.hasNode(previousParentId)) {
313
+ begins.push(graphCore.getNode(previousParentId));
314
+ }
315
+ // ancestors and suceeds combos should be updated
316
+ traverseAncestorsAndSucceeds(this.graph, graphCore, begins, (treeItem) => {
317
+ if (treeItem.data._isCombo && treeItem.id !== innerModel.id)
318
+ comboIdsToUpdate.add(treeItem.id);
319
+ const relatedEdges = graphCore.getRelatedEdges(treeItem.id);
320
+ relatedEdges.forEach((edge) => {
321
+ edgeIdsToUpdate.add(edge.id);
322
+ nodeRelatedIdsToUpdate.add(edge.id);
323
+ });
324
+ });
325
+ }
326
+ else if (type === 'combo') {
327
+ // only the succeed combos should be updated
328
+ graphComboTreeDfs(this.graph, [innerModel], (child) => {
329
+ const relatedEdges = graphCore.getRelatedEdges(child.id);
330
+ relatedEdges.forEach((edge) => {
331
+ edgeIdsToUpdate.add(edge.id);
332
+ nodeRelatedIdsToUpdate.add(edge.id);
333
+ });
334
+ if (child.data._isCombo && child.id !== innerModel.id)
335
+ comboIdsToUpdate.add(child.id);
336
+ });
337
+ }
338
+ }
228
339
  // update the theme if the dataType value is changed
229
340
  let itemTheme;
230
341
  if (nodeDataTypeField &&
231
342
  previous[nodeDataTypeField] !== current[nodeDataTypeField]) {
232
343
  itemTheme = getItemTheme(this.nodeDataTypeSet, nodeDataTypeField, current[nodeDataTypeField], nodeTheme);
233
344
  }
234
- const node = itemMap[id];
235
- let innerModel;
236
- try {
237
- innerModel = graphCore.getNode(id);
238
- }
239
- catch (e) {
240
- innerModel = graphCore.getNode(Number(id));
241
- }
242
- let relatedEdgeInnerModels;
243
- try {
244
- relatedEdgeInnerModels = graphCore.getRelatedEdges(id);
245
- }
246
- catch (e) {
247
- relatedEdgeInnerModels = graphCore.getRelatedEdges(Number(id));
248
- }
249
- const nodeRelatedToUpdate = {};
345
+ const preventPolylineEdgeOverlap = ((_a = innerModel === null || innerModel === void 0 ? void 0 : innerModel.data) === null || _a === void 0 ? void 0 : _a.preventPolylineEdgeOverlap) || false;
346
+ const relatedEdgeInnerModels = preventPolylineEdgeOverlap
347
+ ? this.findNearEdgesByNode(id, graphCore).concat(graphCore.getRelatedEdges(id))
348
+ : graphCore.getRelatedEdges(id);
250
349
  relatedEdgeInnerModels.forEach((edge) => {
251
- edgeToUpdate[edge.id] = edge;
252
- nodeRelatedToUpdate[edge.id] = edge;
350
+ edgeIdsToUpdate.add(edge.id);
351
+ nodeRelatedIdsToUpdate.add(edge.id);
253
352
  });
254
- node.onframe = () => updateEdges(nodeRelatedToUpdate);
255
- node.update(innerModel, { previous, current }, isReplace, itemTheme, action === 'updateNodePosition',
353
+ item.onframe = () => updateRelates(nodeRelatedIdsToUpdate);
354
+ let statesCache;
355
+ if (innerModel.data._isCombo &&
356
+ previous.collapsed !== current.collapsed) {
357
+ statesCache = this.graph.getItemAllStates(id);
358
+ this.graph.clearItemState(id);
359
+ }
360
+ item.update(innerModel, { previous, current }, isReplace, itemTheme, onlyMove, animate,
256
361
  // call after updating finished
257
- () => {
258
- node.onframe = undefined;
259
- });
362
+ throttle((_, canceled) => {
363
+ var _a;
364
+ (_a = item.onframe) === null || _a === void 0 ? void 0 : _a.call(item, true);
365
+ item.onframe = undefined;
366
+ if (statesCache) {
367
+ statesCache.forEach((state) => this.graph.setItemState(id, state, true));
368
+ }
369
+ callback(innerModel, canceled);
370
+ }, 500, {
371
+ leading: false,
372
+ trailing: true,
373
+ }));
374
+ const parentItem = this.itemMap.get(current.parentId);
375
+ if (current.parentId && (parentItem === null || parentItem === void 0 ? void 0 : parentItem.model.data.collapsed)) {
376
+ this.graph.executeWithoutStacking(() => {
377
+ this.graph.hideItem(innerModel.id, false);
378
+ });
379
+ }
260
380
  });
261
- updateEdges();
381
+ debounceUpdateRelates();
262
382
  }
263
383
  // === 6. update edges' data ===
264
384
  if (groupedChanges.EdgeDataUpdated.length) {
265
385
  const edgeUpdate = {};
266
386
  groupedChanges.EdgeDataUpdated.forEach((change) => {
267
387
  const { id, propertyName, newValue, oldValue } = change;
268
- edgeUpdate[id] = edgeUpdate[id] || { previous: {}, current: {} };
388
+ edgeUpdate[id] = edgeUpdate[id] || { id, previous: {}, current: {} };
269
389
  if (!propertyName) {
270
390
  edgeUpdate[id] = {
391
+ id,
271
392
  isReplace: true,
272
393
  previous: oldValue,
273
394
  current: newValue,
@@ -278,17 +399,19 @@ export class ItemController {
278
399
  edgeUpdate[id].current[propertyName] = newValue;
279
400
  }
280
401
  });
281
- const { dataTypeField: edgeDataTypeField } = edgeTheme;
282
- Object.keys(edgeUpdate).forEach((id) => {
283
- const { isReplace, current, previous } = edgeUpdate[id];
402
+ const { dataTypeField: edgeDataTypeField = '' } = edgeTheme;
403
+ Object.values(edgeUpdate).forEach((updateObj) => {
404
+ const { isReplace, current, previous, id } = updateObj;
284
405
  // update the theme if the dataType value is changed
285
406
  let itemTheme;
286
407
  if (previous[edgeDataTypeField] !== current[edgeDataTypeField]) {
287
408
  itemTheme = getItemTheme(this.edgeDataTypeSet, edgeDataTypeField, current[edgeDataTypeField], edgeTheme);
288
409
  }
289
- const item = itemMap[id];
410
+ const item = itemMap.get(id);
290
411
  const innerModel = graphCore.getEdge(id);
291
- item.update(innerModel, { current, previous }, isReplace, itemTheme);
412
+ if (!item || item.destroyed)
413
+ return;
414
+ item.update(innerModel, { current, previous }, isReplace, itemTheme, undefined, animate, (_, canceled) => callback(innerModel, canceled));
292
415
  });
293
416
  }
294
417
  // === 7. update edges' source target ===
@@ -297,16 +420,35 @@ export class ItemController {
297
420
  groupedChanges.EdgeUpdated.forEach((change) => {
298
421
  // propertyName is 'source' or 'target'
299
422
  const { id, propertyName, newValue } = change;
300
- edgeUpdate[id] = edgeUpdate[id] || {};
423
+ edgeUpdate[id] = edgeUpdate[id] || { id };
301
424
  edgeUpdate[id][propertyName] = newValue;
302
425
  });
303
- Object.keys(edgeUpdate).forEach((id) => {
304
- const { source, target } = edgeUpdate[id];
305
- const item = itemMap[id];
426
+ Object.values(edgeUpdate).forEach((updateObj) => {
427
+ const { source, target, id } = updateObj;
428
+ const item = itemMap.get(id);
306
429
  if (source !== undefined)
307
- item.updateEnd('source', this.itemMap[source]);
430
+ item.updateEnd('source', this.itemMap.get(source));
308
431
  if (target !== undefined)
309
- item.updateEnd('target', this.itemMap[target]);
432
+ item.updateEnd('target', this.itemMap.get(target));
433
+ });
434
+ }
435
+ // === 8. combo tree structure change, resort the shapes ===
436
+ if (groupedChanges.ComboStructureChanged.length) {
437
+ this.sortByComboTree(graphCore);
438
+ }
439
+ // === 9. tree data structure change, hide the new node and edge while one of the ancestor is collapsed ===
440
+ if (groupedChanges.TreeStructureChanged.length) {
441
+ groupedChanges.TreeStructureChanged.forEach((change) => {
442
+ const { nodeId } = change;
443
+ // hide it when an ancestor is collapsed
444
+ let parent = graphCore.getParent(nodeId, 'tree');
445
+ while (parent) {
446
+ if (parent.data.collapsed) {
447
+ this.graph.hideItem(nodeId, true);
448
+ break;
449
+ }
450
+ parent = graphCore.getParent(parent.id, 'tree');
451
+ }
310
452
  });
311
453
  }
312
454
  }
@@ -322,7 +464,7 @@ export class ItemController {
322
464
  onItemStateChange(param) {
323
465
  const { ids, states, value } = param;
324
466
  ids.forEach((id) => {
325
- const item = this.itemMap[id];
467
+ const item = this.itemMap.get(id);
326
468
  if (!item) {
327
469
  console.warn(`Fail to set state for item ${id}, which is not exist.`);
328
470
  return;
@@ -337,56 +479,122 @@ export class ItemController {
337
479
  });
338
480
  }
339
481
  onItemVisibilityChange(param) {
340
- const { ids, value, animate = true } = param;
482
+ const { ids, value, graphCore, animate = true } = param;
341
483
  ids.forEach((id) => {
342
- const item = this.itemMap[id];
484
+ const item = this.itemMap.get(id);
343
485
  if (!item) {
344
486
  console.warn(`Fail to set visibility for item ${id}, which is not exist.`);
345
487
  return;
346
488
  }
489
+ const type = item.getType();
347
490
  if (value) {
348
- item.show(animate);
491
+ if (type === 'edge') {
492
+ item.show(animate);
493
+ }
494
+ else {
495
+ if (graphCore.hasTreeStructure('combo')) {
496
+ let anccestorCollapsed = false;
497
+ traverseAncestors(graphCore, [item.model], (model) => {
498
+ if (model.data.collapsed)
499
+ anccestorCollapsed = true;
500
+ return anccestorCollapsed;
501
+ });
502
+ if (anccestorCollapsed)
503
+ return;
504
+ }
505
+ const relatedEdges = graphCore.getRelatedEdges(id);
506
+ item.show(animate);
507
+ relatedEdges.forEach(({ id: edgeId, source, target }) => {
508
+ var _a;
509
+ if (this.getItemVisible(source) && this.getItemVisible(target))
510
+ (_a = this.itemMap.get(edgeId)) === null || _a === void 0 ? void 0 : _a.show(animate);
511
+ });
512
+ }
349
513
  }
350
514
  else {
351
515
  item.hide(animate);
516
+ if (type !== 'edge') {
517
+ const relatedEdges = graphCore.getRelatedEdges(id);
518
+ relatedEdges.forEach(({ id: edgeId }) => {
519
+ var _a;
520
+ (_a = this.itemMap.get(edgeId)) === null || _a === void 0 ? void 0 : _a.hide(animate);
521
+ });
522
+ }
523
+ }
524
+ });
525
+ }
526
+ onItemZIndexChange(params) {
527
+ const { ids = [], action, graphCore } = params;
528
+ ids.forEach((id) => {
529
+ const item = this.itemMap.get(id);
530
+ if (!item)
531
+ return;
532
+ if (action === 'front') {
533
+ item.toFront();
534
+ if (graphCore.hasTreeStructure('combo')) {
535
+ graphComboTreeDfs(this.graph, [item.model], (model) => {
536
+ if (model.data._isCombo) {
537
+ const subCombo = this.itemMap.get(model.id);
538
+ subCombo && subCombo.toFront();
539
+ }
540
+ }, 'TB');
541
+ }
542
+ }
543
+ else {
544
+ item.toBack();
545
+ if (graphCore.hasTreeStructure('combo')) {
546
+ traverseGraphAncestors(this.graph, [item.model], (model) => {
547
+ var _a;
548
+ (_a = this.itemMap.get(model.id)) === null || _a === void 0 ? void 0 : _a.toBack();
549
+ });
550
+ }
352
551
  }
353
552
  });
354
553
  }
355
554
  onTransientUpdate(param) {
356
555
  const { transientObjectMap } = this;
357
- const { type, id, config = {}, canvas } = param;
358
- const { style = {}, data = {}, capture, action, onlyDrawKeyShape, } = config;
556
+ const { type, id, config = {}, canvas, graphCore } = param;
557
+ const { style = {}, data = {}, capture, action, onlyDrawKeyShape, upsertAncestors, } = config;
359
558
  const isItemType = type === 'node' || type === 'edge' || type === 'combo';
360
559
  // Removing
361
560
  if (action === 'remove') {
362
561
  if (isItemType) {
363
- const transientItem = this.transientItemMap[id];
562
+ const transientItem = this.transientItemMap.get(id);
563
+ if (type === 'combo') {
564
+ // remove children from bottom to top
565
+ graphCoreTreeDfs(graphCore, [graphCore.getNode(id)], (child) => {
566
+ const transientChild = this.transientItemMap.get(child.id);
567
+ if (transientChild && !transientChild.destroyed) {
568
+ transientChild.destroy();
569
+ }
570
+ this.transientItemMap.delete(child.id);
571
+ }, 'BT');
572
+ }
364
573
  if (transientItem && !transientItem.destroyed) {
365
574
  transientItem.destroy();
366
575
  }
367
- delete this.transientItemMap[id];
576
+ this.transientItemMap.delete(id);
368
577
  return;
369
578
  }
370
579
  else {
371
- const preObj = transientObjectMap[id];
372
- if (preObj && !preObj.destroyed) {
580
+ const preObj = transientObjectMap.get(id);
581
+ if (preObj && !preObj.destroyed)
373
582
  preObj.destroy();
374
- }
375
- delete transientObjectMap[id];
583
+ transientObjectMap.delete(id);
376
584
  return;
377
585
  }
378
586
  }
379
587
  // Adding / Updating
380
588
  if (isItemType) {
381
- const item = this.itemMap[id];
589
+ const item = this.itemMap.get(id);
382
590
  if (!item) {
383
591
  console.warn(`Fail to draw transient item of ${id}, which is not exist.`);
384
592
  return;
385
593
  }
386
- const transientItem = upsertTransientItem(item, this.transientNodeGroup, this.transientEdgeGroup, this.transientItemMap, onlyDrawKeyShape);
594
+ const transientItem = upsertTransientItem(item, this.transientNodeGroup, this.transientEdgeGroup, this.transientComboGroup, this.transientItemMap, this.itemMap, graphCore, onlyDrawKeyShape, upsertAncestors);
387
595
  if (onlyDrawKeyShape) {
388
596
  // only update node positions to cloned node container(group)
389
- if (type === 'node' &&
597
+ if ((type === 'node' || type === 'combo') &&
390
598
  data.hasOwnProperty('x') &&
391
599
  data.hasOwnProperty('y')) {
392
600
  const { x, y } = data;
@@ -396,16 +604,54 @@ export class ItemController {
396
604
  }
397
605
  else {
398
606
  const transItem = transientItem;
607
+ const positionChanged = data.hasOwnProperty('x') && data.hasOwnProperty('y');
608
+ if (type === 'combo' && positionChanged) {
609
+ const { x, y } = data;
610
+ const { x: ox = x, y: oy = y } = transItem.displayModel.data;
611
+ const dx = x - ox;
612
+ const dy = y - oy;
613
+ // move combo = move children nodes from bottom to top
614
+ graphCoreTreeDfs(graphCore, [transItem.model], (node) => {
615
+ const transChild = this.transientItemMap.get(node.id);
616
+ if (!transChild)
617
+ return;
618
+ const { x: childX = 0, y: childY = 0 } = transChild.model
619
+ .data;
620
+ transChild === null || transChild === void 0 ? void 0 : transChild.update(Object.assign(Object.assign({}, transChild.model), { data: Object.assign(Object.assign({}, transChild.model.data), { x: childX + dx, y: childY + dy }) }));
621
+ }, 'BT');
622
+ }
623
+ if (graphCore.hasTreeStructure('combo') &&
624
+ type !== 'edge' &&
625
+ positionChanged) {
626
+ // force update ancestor combos in the sametime
627
+ let currentAncestor = graphCore.getParent(transItem.model.id, 'combo');
628
+ while (currentAncestor) {
629
+ const ancestorItem = this.transientItemMap.get(currentAncestor.id);
630
+ if (ancestorItem)
631
+ ancestorItem.forceUpdate();
632
+ currentAncestor = graphCore.getParent(currentAncestor.id, 'combo');
633
+ }
634
+ }
635
+ // Update the target combo's posiiton and other props
399
636
  transItem.update(Object.assign(Object.assign({}, transItem.model), { data: Object.assign(Object.assign({}, transItem.model.data), data) }));
400
637
  }
401
638
  return;
402
639
  }
403
- const shape = upsertShape(type, String(id), style, transientObjectMap);
640
+ const idStr = String(id);
641
+ const shape = upsertShape(type, idStr, style, Object.fromEntries(transientObjectMap));
642
+ transientObjectMap.set(idStr, shape);
404
643
  shape.style.pointerEvents = capture ? 'auto' : 'none';
405
644
  canvas.getRoot().appendChild(shape);
406
645
  }
407
646
  getTransient(id) {
408
- return this.transientObjectMap[id];
647
+ return this.transientObjectMap.get(id);
648
+ }
649
+ getTransientItem(id) {
650
+ return this.transientItemMap[id];
651
+ }
652
+ findDisplayModel(id) {
653
+ var _a;
654
+ return (_a = this.itemMap.get(id)) === null || _a === void 0 ? void 0 : _a.displayModel;
409
655
  }
410
656
  /**
411
657
  * Create nodes with inner data to canvas.
@@ -413,7 +659,7 @@ export class ItemController {
413
659
  */
414
660
  renderNodes(models, nodeTheme = {}) {
415
661
  const { nodeExtensions, nodeGroup, nodeDataTypeSet, graph } = this;
416
- const { dataTypeField } = nodeTheme;
662
+ const { dataTypeField = '' } = nodeTheme;
417
663
  const zoom = graph.getZoom();
418
664
  models.forEach((node) => {
419
665
  // get the base styles from theme
@@ -421,7 +667,7 @@ export class ItemController {
421
667
  if (dataTypeField)
422
668
  dataType = node.data[dataTypeField];
423
669
  const itemTheme = getItemTheme(nodeDataTypeSet, dataTypeField, dataType, nodeTheme);
424
- this.itemMap[node.id] = new Node({
670
+ this.itemMap.set(node.id, new Node({
425
671
  model: node,
426
672
  renderExtensions: nodeExtensions,
427
673
  containerGroup: nodeGroup,
@@ -433,7 +679,50 @@ export class ItemController {
433
679
  ? // TODO: G type
434
680
  graph.canvas.context.deviceRendererPlugin.getDevice()
435
681
  : undefined,
682
+ }));
683
+ });
684
+ }
685
+ renderCombos(models, comboTheme = {}, graphCore) {
686
+ const { comboExtensions, comboGroup, comboDataTypeSet, graph, itemMap } = this;
687
+ const { dataTypeField = '' } = comboTheme;
688
+ const zoom = graph.getZoom();
689
+ models.forEach((combo) => {
690
+ // get the base styles from theme
691
+ let dataType;
692
+ if (dataTypeField)
693
+ dataType = combo.data[dataTypeField];
694
+ const itemTheme = getItemTheme(comboDataTypeSet, dataTypeField, dataType, comboTheme);
695
+ const getCombinedBounds = () => {
696
+ // calculate the position of the combo according to its children
697
+ return getCombinedBoundsByData(graph, graphCore
698
+ .getChildren(combo.id, 'combo')
699
+ .map(({ id }) => itemMap.get(id))
700
+ .filter(Boolean));
701
+ };
702
+ const getChildren = () => {
703
+ const childModels = graphCore.getChildren(combo.id, 'combo');
704
+ return childModels.map(({ id }) => itemMap.get(id));
705
+ };
706
+ const comboItem = new Combo({
707
+ model: combo,
708
+ getCombinedBounds,
709
+ getChildren,
710
+ renderExtensions: comboExtensions,
711
+ containerGroup: comboGroup,
712
+ mapper: this.comboMapper,
713
+ stateMapper: this.comboStateMapper,
714
+ zoom,
715
+ theme: itemTheme,
716
+ device: graph.rendererType === 'webgl-3d'
717
+ ? graph.canvas.context.deviceRendererPlugin.getDevice()
718
+ : undefined,
436
719
  });
720
+ // ------- for integration tests -------
721
+ comboItem.getCombinedBounds = getCombinedBounds;
722
+ comboItem.getChildren = getChildren;
723
+ comboItem.type = 'combo';
724
+ // ------- for integration tests end-------
725
+ itemMap.set(combo.id, comboItem);
437
726
  });
438
727
  }
439
728
  /**
@@ -442,24 +731,27 @@ export class ItemController {
442
731
  */
443
732
  renderEdges(models, edgeTheme = {}) {
444
733
  const { edgeExtensions, edgeGroup, itemMap, edgeDataTypeSet, graph } = this;
445
- const { dataTypeField } = edgeTheme;
734
+ const { dataTypeField = '' } = edgeTheme;
446
735
  const zoom = graph.getZoom();
736
+ const nodeMap = filterItemMapByType(itemMap, 'node');
447
737
  models.forEach((edge) => {
448
738
  const { source, target, id } = edge;
449
- const sourceItem = itemMap[source];
450
- const targetItem = itemMap[target];
739
+ const sourceItem = itemMap.get(source);
740
+ const targetItem = itemMap.get(target);
451
741
  if (!sourceItem) {
452
742
  console.warn(`The source node ${source} is not exist in the graph for edge ${id}, please add the node first`);
743
+ return;
453
744
  }
454
745
  if (!targetItem) {
455
746
  console.warn(`The source node ${source} is not exist in the graph for edge ${id}, please add the node first`);
747
+ return;
456
748
  }
457
749
  // get the base styles from theme
458
750
  let dataType;
459
751
  if (dataTypeField)
460
752
  dataType = edge.data[dataTypeField];
461
753
  const itemTheme = getItemTheme(edgeDataTypeSet, dataTypeField, dataType, edgeTheme);
462
- itemMap[id] = new Edge({
754
+ itemMap.set(id, new Edge({
463
755
  model: edge,
464
756
  renderExtensions: edgeExtensions,
465
757
  containerGroup: edgeGroup,
@@ -467,9 +759,10 @@ export class ItemController {
467
759
  stateMapper: this.edgeStateMapper,
468
760
  sourceItem,
469
761
  targetItem,
762
+ nodeMap,
470
763
  zoom,
471
764
  theme: itemTheme,
472
- });
765
+ }));
473
766
  });
474
767
  }
475
768
  /**
@@ -481,7 +774,7 @@ export class ItemController {
481
774
  */
482
775
  findIdByState(itemType, state, value = true) {
483
776
  const ids = [];
484
- Object.values(this.itemMap).forEach((item) => {
777
+ this.itemMap.forEach((item) => {
485
778
  if (item.getType() !== itemType)
486
779
  return;
487
780
  if (item.hasState(state) === value)
@@ -496,35 +789,290 @@ export class ItemController {
496
789
  * @returns {boolean | string} the state value
497
790
  */
498
791
  getItemState(id, state) {
499
- const item = this.itemMap[id];
792
+ const item = this.itemMap.get(id);
500
793
  if (!item) {
501
794
  console.warn(`Fail to get item state, the item with id ${id} does not exist.`);
502
795
  return false;
503
796
  }
504
797
  return item.hasState(state);
505
798
  }
799
+ getItemAllStates(id) {
800
+ const item = this.itemMap.get(id);
801
+ if (!item) {
802
+ console.warn(`Fail to get item state, the item with id ${id} does not exist.`);
803
+ return [];
804
+ }
805
+ return item
806
+ .getStates()
807
+ .filter(({ value }) => value)
808
+ .map(({ name }) => name);
809
+ }
506
810
  getItemById(id) {
507
- return this.itemMap[id];
811
+ return this.itemMap.get(id);
508
812
  }
509
- getItemBBox(id, isKeyShape = false) {
510
- const item = this.itemMap[id];
813
+ getItemBBox(id, isKeyShape = false, isTransient = false) {
814
+ const item = isTransient
815
+ ? this.transientItemMap.get(id)
816
+ : this.itemMap.get(id);
511
817
  if (!item) {
512
818
  console.warn(`Fail to get item bbox, the item with id ${id} does not exist.`);
513
819
  return false;
514
820
  }
821
+ if (item instanceof Group)
822
+ return item.getRenderBounds();
515
823
  return isKeyShape ? item.getKeyBBox() : item.getBBox();
516
824
  }
517
825
  getItemVisible(id) {
518
- const item = this.itemMap[id];
826
+ const item = this.itemMap.get(id);
519
827
  if (!item) {
520
828
  console.warn(`Fail to get item visible, the item with id ${id} does not exist.`);
521
829
  return false;
522
830
  }
523
831
  return item.isVisible();
524
832
  }
833
+ /**
834
+ * Identify edges that are intersected by a particular node
835
+ * @param nodeId node id
836
+ * @param graphCore
837
+ * @returns
838
+ */
839
+ findNearEdgesByNode(nodeId, graphCore) {
840
+ var _a;
841
+ const edges = graphCore.getAllEdges();
842
+ const canvasBBox = this.graph.getRenderBBox(undefined);
843
+ const quadTree = new QuadTree(canvasBBox, 4);
844
+ each(edges, (edge) => {
845
+ const { data: { x: sourceX, y: sourceY }, } = graphCore.getNode(edge.source);
846
+ const { data: { x: targetX, y: targetY }, } = graphCore.getNode(edge.target);
847
+ quadTree.insert({
848
+ id: edge.id,
849
+ p1: { x: sourceX, y: sourceY },
850
+ p2: { x: targetX, y: targetY },
851
+ bbox: this.graph.getRenderBBox(edge.id),
852
+ });
853
+ });
854
+ // update node position
855
+ const node = (this.getTransientItem(nodeId) ||
856
+ this.getItemById(nodeId));
857
+ const nodeBBox = this.graph.getRenderBBox(nodeId);
858
+ const nodeData = (_a = node === null || node === void 0 ? void 0 : node.model) === null || _a === void 0 ? void 0 : _a.data;
859
+ if (nodeData) {
860
+ nodeBBox.update([nodeData.x, nodeData.y, 0], nodeBBox.halfExtents);
861
+ }
862
+ const checker = new EdgeCollisionChecker(quadTree);
863
+ const collisions = checker.getCollidingEdges(nodeBBox);
864
+ const collidingEdges = map(collisions, (collision) => graphCore.getEdge(collision.id));
865
+ return collidingEdges;
866
+ }
867
+ sortByComboTree(graphCore) {
868
+ if (!graphCore.hasTreeStructure('combo'))
869
+ return;
870
+ graphCoreTreeDfs(graphCore, graphCore.getRoots('combo'), (node) => {
871
+ const nodeItem = this.itemMap.get(node.id);
872
+ if (node.data._isCombo && nodeItem) {
873
+ nodeItem.toFront();
874
+ }
875
+ });
876
+ }
877
+ collapseCombo(graphCore, comboModel) {
878
+ let relatedEdges = [];
879
+ const succeedIds = [];
880
+ // find the succeeds in collapsed
881
+ graphComboTreeDfs(this.graph, [comboModel], (child) => {
882
+ if (child.id !== comboModel.id) {
883
+ this.graph.executeWithoutStacking(() => {
884
+ this.graph.hideItem(child.id, false);
885
+ });
886
+ }
887
+ relatedEdges = relatedEdges.concat(graphCore.getRelatedEdges(child.id));
888
+ succeedIds.push(child.id);
889
+ });
890
+ const pairs = [];
891
+ uniq(relatedEdges).forEach((edge) => {
892
+ const { id, source: s, target: t } = edge;
893
+ if (!this.graph.getItemVisible(id))
894
+ return;
895
+ const sourceIsSucceed = succeedIds.includes(s);
896
+ const targetIsSucceed = succeedIds.includes(t);
897
+ // do not add virtual edge if the source and target are both the succeed
898
+ if (sourceIsSucceed && targetIsSucceed)
899
+ return;
900
+ const source = sourceIsSucceed ? comboModel.id : s;
901
+ const target = targetIsSucceed ? comboModel.id : t;
902
+ pairs.push({ source, target });
903
+ });
904
+ // each item in groupedEdges is a virtual edge
905
+ this.graph.executeWithoutStacking(() => {
906
+ this.graph.addData('edge', groupVirtualEdges(pairs));
907
+ });
908
+ }
909
+ expandCombo(graphCore, comboModel) {
910
+ let isAncestorCollapsed = false;
911
+ traverseAncestors(graphCore, [comboModel], (anccestor) => {
912
+ if (anccestor.data.collapsed) {
913
+ isAncestorCollapsed = true;
914
+ return true;
915
+ }
916
+ return false;
917
+ });
918
+ if (isAncestorCollapsed)
919
+ return;
920
+ const relatedVirtualEdgeIds = [];
921
+ let edgesToShow = [];
922
+ const nodesToShow = [];
923
+ // show the succeeds and remove the related virtual edges, including the succeeds' related edges
924
+ graphComboTreeDfs(this.graph, [comboModel], (child) => {
925
+ graphCore.getRelatedEdges(child.id).forEach((edge) => {
926
+ if (edge.data._virtual)
927
+ relatedVirtualEdgeIds.push(edge.id);
928
+ else
929
+ edgesToShow.push(edge.id);
930
+ });
931
+ if (child.id !== comboModel.id) {
932
+ if (!graphCore.getNode(child.data.parentId).data.collapsed) {
933
+ nodesToShow.push(child.id);
934
+ }
935
+ // re-add collapsed succeeds' virtual edges by calling collapseCombo
936
+ if (child.data._isCombo && child.data.collapsed) {
937
+ this.collapseCombo(graphCore, child);
938
+ }
939
+ }
940
+ });
941
+ const virtualPairs = [];
942
+ const visibleAncestorMap = new Map();
943
+ edgesToShow = uniq(edgesToShow.filter((eid) => {
944
+ const { source, target } = graphCore.getEdge(eid);
945
+ const ends = { source, target };
946
+ const endsVisible = {
947
+ source: this.graph.getItemVisible(source) || nodesToShow.includes(source),
948
+ target: this.graph.getItemVisible(target) || nodesToShow.includes(target),
949
+ };
950
+ // actual edges to show
951
+ if (endsVisible.source && endsVisible.target)
952
+ return true;
953
+ // add virtual edges by finding the visible ancestor
954
+ const virtualEnds = { source: undefined, target: undefined };
955
+ Object.keys(virtualEnds).forEach((end) => {
956
+ if (!endsVisible[end]) {
957
+ if (!visibleAncestorMap.get(ends[end])) {
958
+ traverseAncestors(graphCore, [graphCore.getNode(ends[end])], (ancestor) => {
959
+ if (visibleAncestorMap.has(ends[end]))
960
+ return;
961
+ if (this.graph.getItemVisible(ancestor.id) ||
962
+ nodesToShow.includes(ancestor.id))
963
+ visibleAncestorMap.set(ends[end], ancestor.id);
964
+ });
965
+ }
966
+ virtualEnds[end] = visibleAncestorMap.get(ends[end]);
967
+ }
968
+ else {
969
+ virtualEnds[end] = ends[end];
970
+ }
971
+ });
972
+ if (virtualEnds.source !== undefined &&
973
+ virtualEnds.target !== undefined) {
974
+ virtualPairs.push(virtualEnds);
975
+ }
976
+ return false;
977
+ }));
978
+ // remove related virtual edges
979
+ this.graph.executeWithoutStacking(() => {
980
+ this.graph.removeData('edge', uniq(relatedVirtualEdgeIds));
981
+ this.graph.showItem(edgesToShow.concat(nodesToShow));
982
+ // add virtual edges by grouping visible ancestor edges
983
+ this.graph.addData('edge', groupVirtualEdges(virtualPairs));
984
+ });
985
+ }
986
+ /**
987
+ * Collapse or expand a sub tree according to action
988
+ * @param params
989
+ */
990
+ onTreeCollapseExpand(params) {
991
+ const { ids, animate, action, graphCore } = params;
992
+ const rootModels = ids.map((id) => graphCore.getNode(id));
993
+ switch (action) {
994
+ case 'collapse':
995
+ this.collapseSubTree(rootModels, graphCore, animate);
996
+ break;
997
+ case 'expand':
998
+ default:
999
+ this.expandSubTree(rootModels, graphCore, animate);
1000
+ break;
1001
+ }
1002
+ }
1003
+ /**
1004
+ * Collapse sub tree(s).
1005
+ * @param rootModels The root node models of sub trees
1006
+ * @param graphCore
1007
+ * @param animate Whether enable animations for expanding, true by default
1008
+ * @returns
1009
+ */
1010
+ collapseSubTree(rootModels, graphCore, animate = true) {
1011
+ let positions = [];
1012
+ rootModels.forEach((root) => {
1013
+ let shouldCollapse = true;
1014
+ const nodes = [];
1015
+ graphCoreTreeDfs(graphCore, [root], (node) => {
1016
+ var _a;
1017
+ if (node.id === root.id)
1018
+ return;
1019
+ const neighbors = graphCore.getNeighbors(node.id);
1020
+ if (!((_a = graphCore.getChildren(node.id, 'tree')) === null || _a === void 0 ? void 0 : _a.length) &&
1021
+ neighbors.length > 1) {
1022
+ shouldCollapse = false;
1023
+ }
1024
+ nodes.push(node);
1025
+ }, 'TB', 'tree', {
1026
+ stopAllFn: () => !shouldCollapse,
1027
+ });
1028
+ if (shouldCollapse) {
1029
+ positions = positions.concat(nodes.map((node) => ({
1030
+ id: node.id,
1031
+ data: { x: root.data.x, y: root.data.y },
1032
+ })));
1033
+ }
1034
+ });
1035
+ if (!positions.length)
1036
+ return;
1037
+ this.graph.updateNodePosition(positions, undefined, !animate, (model, canceled) => {
1038
+ this.graph.hideItem(model.id, canceled);
1039
+ }, undefined);
1040
+ }
1041
+ /**
1042
+ * Expand sub tree(s).
1043
+ * @param rootModels The root node models of sub trees.
1044
+ * @param graphCore
1045
+ * @param animate Whether enable animations for expanding, true by default.
1046
+ * @returns
1047
+ */
1048
+ expandSubTree(rootModels, graphCore, animate = true) {
1049
+ return __awaiter(this, void 0, void 0, function* () {
1050
+ let allNodeIds = [];
1051
+ let allEdgeIds = [];
1052
+ rootModels.forEach((root) => {
1053
+ const nodeIds = [];
1054
+ graphCoreTreeDfs(graphCore, [root], (node) => nodeIds.push(node.id), 'TB', 'tree', {
1055
+ stopBranchFn: (node) => {
1056
+ const shouldStop = node.id !== root.id && node.data.collapsed;
1057
+ if (shouldStop)
1058
+ nodeIds.push(node.id);
1059
+ return shouldStop;
1060
+ },
1061
+ });
1062
+ allEdgeIds = allEdgeIds.concat(graphCore
1063
+ .getAllEdges()
1064
+ .filter((edge) => nodeIds.includes(edge.source) && nodeIds.includes(edge.target))
1065
+ .map((edge) => edge.id));
1066
+ allNodeIds = allNodeIds.concat(nodeIds.filter((id) => id !== root.id));
1067
+ });
1068
+ const ids = uniq(allNodeIds.concat(allEdgeIds));
1069
+ this.graph.showItem(ids, !animate);
1070
+ yield this.graph.layout(undefined, !animate);
1071
+ });
1072
+ }
525
1073
  }
526
1074
  const getItemTheme = (dataTypeSet, dataTypeField, dataType, itemTheme) => {
527
- const { styles: themeStyles, lodStrategy } = itemTheme;
1075
+ const { styles: themeStyles = [], lodStrategy } = itemTheme;
528
1076
  const formattedLodStrategy = formatLodStrategy(lodStrategy);
529
1077
  if (!dataTypeField) {
530
1078
  // dataType field is not assigned
@@ -541,11 +1089,53 @@ const getItemTheme = (dataTypeSet, dataTypeField, dataType, itemTheme) => {
541
1089
  themeStyle = themeStyles[idx % themeStylesLength];
542
1090
  }
543
1091
  else if (isObject(themeStyles)) {
544
- themeStyle = themeStyles[dataType] || themeStyles.others;
1092
+ themeStyle =
1093
+ themeStyles[dataType] ||
1094
+ themeStyles.others;
545
1095
  }
546
1096
  return {
547
1097
  styles: themeStyle,
548
1098
  lodStrategy: formattedLodStrategy,
549
1099
  };
550
1100
  };
1101
+ const filterItemMapByType = (itemMap, type) => {
1102
+ const filteredMap = new Map();
1103
+ itemMap.forEach((value, key) => {
1104
+ if (value.type === type) {
1105
+ filteredMap.set(key, value);
1106
+ }
1107
+ });
1108
+ return filteredMap;
1109
+ };
1110
+ const groupVirtualEdges = (pairs) => {
1111
+ const groupedVirtualEdges = new Map();
1112
+ pairs.forEach((edge) => {
1113
+ const { source, target } = edge;
1114
+ const key = `${source}_${target}`;
1115
+ const group = groupedVirtualEdges.get(key) || {
1116
+ edges: [],
1117
+ source,
1118
+ target,
1119
+ };
1120
+ group.edges.push(edge);
1121
+ groupedVirtualEdges.set(key, group);
1122
+ });
1123
+ // each item in groupedEdges is a virtual edge
1124
+ const virtualEdges = [];
1125
+ groupedVirtualEdges.forEach((group) => {
1126
+ const { source, target, edges } = group;
1127
+ virtualEdges.push({
1128
+ id: `virtual-${uniqueId()}`,
1129
+ source,
1130
+ target,
1131
+ data: {
1132
+ _virtual: true,
1133
+ keyShape: {
1134
+ lineWidth: edges.length,
1135
+ },
1136
+ },
1137
+ });
1138
+ });
1139
+ return virtualEdges;
1140
+ };
551
1141
  //# sourceMappingURL=item.js.map