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

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 (591) hide show
  1. package/dist/g6.min.js +2 -2
  2. package/esm/api-doc/graph.d.ts +3 -3
  3. package/esm/api-doc/graph.js +3 -3
  4. package/esm/api-doc/graph.js.map +1 -1
  5. package/esm/api-doc/types.d.ts +1 -0
  6. package/esm/api-doc/types.js +1 -2
  7. package/esm/api-doc/types.js.map +1 -1
  8. package/esm/constant/shape.d.ts +3 -1
  9. package/esm/index.d.ts +33 -65
  10. package/esm/index.js +4 -5
  11. package/esm/index.js.map +1 -1
  12. package/esm/item/combo.d.ts +1 -1
  13. package/esm/item/combo.js +18 -14
  14. package/esm/item/combo.js.map +1 -1
  15. package/esm/item/edge.d.ts +19 -2
  16. package/esm/item/edge.js +100 -44
  17. package/esm/item/edge.js.map +1 -1
  18. package/esm/item/item.d.ts +3 -2
  19. package/esm/item/item.js +27 -13
  20. package/esm/item/item.js.map +1 -1
  21. package/esm/item/node.d.ts +2 -8
  22. package/esm/item/node.js +31 -19
  23. package/esm/item/node.js.map +1 -1
  24. package/esm/runtime/controller/data.d.ts +30 -16
  25. package/esm/runtime/controller/data.js +290 -422
  26. package/esm/runtime/controller/data.js.map +1 -1
  27. package/esm/runtime/controller/interaction.js +9 -4
  28. package/esm/runtime/controller/interaction.js.map +1 -1
  29. package/esm/runtime/controller/item.d.ts +1 -0
  30. package/esm/runtime/controller/item.js +285 -150
  31. package/esm/runtime/controller/item.js.map +1 -1
  32. package/esm/runtime/controller/layout.js +1 -3
  33. package/esm/runtime/controller/layout.js.map +1 -1
  34. package/esm/runtime/controller/plugin.js +9 -5
  35. package/esm/runtime/controller/plugin.js.map +1 -1
  36. package/esm/runtime/graph.d.ts +104 -24
  37. package/esm/runtime/graph.js +472 -94
  38. package/esm/runtime/graph.js.map +1 -1
  39. package/esm/stdlib/behavior/activate-relations.js +2 -2
  40. package/esm/stdlib/behavior/activate-relations.js.map +1 -1
  41. package/esm/stdlib/behavior/brush-select.d.ts +7 -1
  42. package/esm/stdlib/behavior/brush-select.js +10 -12
  43. package/esm/stdlib/behavior/brush-select.js.map +1 -1
  44. package/esm/stdlib/behavior/click-select.js +1 -1
  45. package/esm/stdlib/behavior/click-select.js.map +1 -1
  46. package/esm/stdlib/behavior/create-edge.d.ts +57 -0
  47. package/esm/stdlib/behavior/create-edge.js +215 -0
  48. package/esm/stdlib/behavior/create-edge.js.map +1 -0
  49. package/esm/stdlib/behavior/drag-canvas.d.ts +3 -1
  50. package/esm/stdlib/behavior/drag-canvas.js +78 -33
  51. package/esm/stdlib/behavior/drag-canvas.js.map +1 -1
  52. package/esm/stdlib/behavior/drag-combo.d.ts +2 -2
  53. package/esm/stdlib/behavior/drag-combo.js +43 -32
  54. package/esm/stdlib/behavior/drag-combo.js.map +1 -1
  55. package/esm/stdlib/behavior/drag-node.d.ts +3 -3
  56. package/esm/stdlib/behavior/drag-node.js +80 -63
  57. package/esm/stdlib/behavior/drag-node.js.map +1 -1
  58. package/esm/stdlib/behavior/index.d.ts +3 -0
  59. package/esm/stdlib/behavior/index.js +3 -0
  60. package/esm/stdlib/behavior/index.js.map +1 -1
  61. package/esm/stdlib/behavior/lasso-select.d.ts +1 -1
  62. package/esm/stdlib/behavior/lasso-select.js +3 -4
  63. package/esm/stdlib/behavior/lasso-select.js.map +1 -1
  64. package/esm/stdlib/behavior/scroll-canvas.d.ts +67 -0
  65. package/esm/stdlib/behavior/scroll-canvas.js +266 -0
  66. package/esm/stdlib/behavior/scroll-canvas.js.map +1 -0
  67. package/esm/stdlib/behavior/shortcuts-call.d.ts +38 -0
  68. package/esm/stdlib/behavior/shortcuts-call.js +87 -0
  69. package/esm/stdlib/behavior/shortcuts-call.js.map +1 -0
  70. package/esm/stdlib/behavior/zoom-canvas-3d.js +4 -1
  71. package/esm/stdlib/behavior/zoom-canvas-3d.js.map +1 -1
  72. package/esm/stdlib/behavior/zoom-canvas.d.ts +3 -1
  73. package/esm/stdlib/behavior/zoom-canvas.js +70 -26
  74. package/esm/stdlib/behavior/zoom-canvas.js.map +1 -1
  75. package/esm/stdlib/data/index.d.ts +1 -0
  76. package/esm/stdlib/data/index.js +1 -0
  77. package/esm/stdlib/data/index.js.map +1 -1
  78. package/esm/stdlib/data/mapNodeSize.d.ts +4 -5
  79. package/esm/stdlib/data/mapNodeSize.js +12 -2
  80. package/esm/stdlib/data/mapNodeSize.js.map +1 -1
  81. package/esm/stdlib/data/processParallelEdges.d.ts +21 -0
  82. package/esm/stdlib/data/processParallelEdges.js +127 -0
  83. package/esm/stdlib/data/processParallelEdges.js.map +1 -0
  84. package/esm/stdlib/data/transformV4Data.d.ts +3 -4
  85. package/esm/stdlib/data/transformV4Data.js +10 -2
  86. package/esm/stdlib/data/transformV4Data.js.map +1 -1
  87. package/esm/stdlib/data/validateData.d.ts +4 -5
  88. package/esm/stdlib/data/validateData.js +22 -13
  89. package/esm/stdlib/data/validateData.js.map +1 -1
  90. package/esm/stdlib/index.d.ts +27 -8
  91. package/esm/stdlib/index.js +24 -11
  92. package/esm/stdlib/index.js.map +1 -1
  93. package/esm/stdlib/item/edge/base.d.ts +3 -5
  94. package/esm/stdlib/item/edge/base.js +32 -31
  95. package/esm/stdlib/item/edge/base.js.map +1 -1
  96. package/esm/stdlib/item/edge/cubic-horizontal.js.map +1 -1
  97. package/esm/stdlib/item/edge/cubic-vertical.js.map +1 -1
  98. package/esm/stdlib/item/edge/cubic.js +1 -1
  99. package/esm/stdlib/item/edge/cubic.js.map +1 -1
  100. package/esm/stdlib/item/edge/loop.js +1 -1
  101. package/esm/stdlib/item/edge/loop.js.map +1 -1
  102. package/esm/stdlib/item/node/base.d.ts +3 -6
  103. package/esm/stdlib/item/node/base.js +30 -60
  104. package/esm/stdlib/item/node/base.js.map +1 -1
  105. package/esm/stdlib/item/node/base3d.d.ts +1 -0
  106. package/esm/stdlib/item/node/base3d.js +1 -0
  107. package/esm/stdlib/item/node/base3d.js.map +1 -1
  108. package/esm/stdlib/item/node/cube.d.ts +35 -0
  109. package/esm/stdlib/item/node/cube.js +54 -0
  110. package/esm/stdlib/item/node/cube.js.map +1 -0
  111. package/esm/stdlib/item/node/diamond.js +1 -1
  112. package/esm/stdlib/item/node/ellipse.js +2 -2
  113. package/esm/stdlib/item/node/hexagon.js +6 -2
  114. package/esm/stdlib/item/node/hexagon.js.map +1 -1
  115. package/esm/stdlib/item/node/image.d.ts +40 -0
  116. package/esm/stdlib/item/node/image.js +110 -0
  117. package/esm/stdlib/item/node/image.js.map +1 -0
  118. package/esm/stdlib/item/node/index.d.ts +4 -0
  119. package/esm/stdlib/item/node/index.js +4 -0
  120. package/esm/stdlib/item/node/index.js.map +1 -1
  121. package/esm/stdlib/plugin/edgeFilterLens/index.d.ts +66 -0
  122. package/esm/stdlib/plugin/edgeFilterLens/index.js +309 -0
  123. package/esm/stdlib/plugin/edgeFilterLens/index.js.map +1 -0
  124. package/esm/stdlib/plugin/grid/index.d.ts +1 -1
  125. package/esm/stdlib/plugin/grid/index.js +3 -4
  126. package/esm/stdlib/plugin/grid/index.js.map +1 -1
  127. package/esm/stdlib/plugin/history/combo-command.js +2 -2
  128. package/esm/stdlib/plugin/history/combo-command.js.map +1 -1
  129. package/esm/stdlib/plugin/history/index.d.ts +10 -10
  130. package/esm/stdlib/plugin/history/index.js +14 -14
  131. package/esm/stdlib/plugin/history/index.js.map +1 -1
  132. package/esm/stdlib/plugin/history/item-data-command.js +25 -16
  133. package/esm/stdlib/plugin/history/item-data-command.js.map +1 -1
  134. package/esm/stdlib/plugin/history/layer-updated-command.js +2 -2
  135. package/esm/stdlib/plugin/history/layer-updated-command.js.map +1 -1
  136. package/esm/stdlib/plugin/history/state-updated-command.js +1 -1
  137. package/esm/stdlib/plugin/history/state-updated-command.js.map +1 -1
  138. package/esm/stdlib/plugin/history/visibility-updated-command.js +2 -2
  139. package/esm/stdlib/plugin/history/visibility-updated-command.js.map +1 -1
  140. package/esm/stdlib/plugin/hull/convexHull.d.ts +1 -1
  141. package/esm/stdlib/plugin/hull/hullComponent.d.ts +1 -1
  142. package/esm/stdlib/plugin/hull/hullComponent.js +5 -9
  143. package/esm/stdlib/plugin/hull/hullComponent.js.map +1 -1
  144. package/esm/stdlib/plugin/hull/util.d.ts +2 -2
  145. package/esm/stdlib/plugin/hull/util.js +6 -2
  146. package/esm/stdlib/plugin/hull/util.js.map +1 -1
  147. package/esm/stdlib/plugin/index.d.ts +2 -0
  148. package/esm/stdlib/plugin/index.js +2 -0
  149. package/esm/stdlib/plugin/index.js.map +1 -1
  150. package/esm/stdlib/plugin/legend/index.d.ts +2 -2
  151. package/esm/stdlib/plugin/legend/index.js +3 -3
  152. package/esm/stdlib/plugin/legend/index.js.map +1 -1
  153. package/esm/stdlib/plugin/menu/index.d.ts +4 -4
  154. package/esm/stdlib/plugin/menu/index.js +3 -3
  155. package/esm/stdlib/plugin/menu/index.js.map +1 -1
  156. package/esm/stdlib/plugin/minimap/index.d.ts +6 -2
  157. package/esm/stdlib/plugin/minimap/index.js +119 -12
  158. package/esm/stdlib/plugin/minimap/index.js.map +1 -1
  159. package/esm/stdlib/plugin/snapline/index.d.ts +167 -0
  160. package/esm/stdlib/plugin/snapline/index.js +1063 -0
  161. package/esm/stdlib/plugin/snapline/index.js.map +1 -0
  162. package/esm/stdlib/plugin/timebar/index.js +2 -2
  163. package/esm/stdlib/plugin/timebar/index.js.map +1 -1
  164. package/esm/stdlib/plugin/toolbar/index.d.ts +3 -3
  165. package/esm/stdlib/plugin/toolbar/index.js +4 -4
  166. package/esm/stdlib/plugin/toolbar/index.js.map +1 -1
  167. package/esm/stdlib/plugin/tooltip/index.d.ts +4 -4
  168. package/esm/stdlib/plugin/tooltip/index.js +3 -4
  169. package/esm/stdlib/plugin/tooltip/index.js.map +1 -1
  170. package/esm/stdlib/plugin/types.d.ts +2 -0
  171. package/esm/stdlib/plugin/watermaker/index.d.ts +78 -0
  172. package/esm/stdlib/plugin/watermaker/index.js +243 -0
  173. package/esm/stdlib/plugin/watermaker/index.js.map +1 -0
  174. package/esm/stdlib/theme/dark.js +42 -2
  175. package/esm/stdlib/theme/dark.js.map +1 -1
  176. package/esm/stdlib/theme/light.js +4 -4
  177. package/esm/types/data.d.ts +5 -0
  178. package/esm/types/event.d.ts +1 -0
  179. package/esm/types/graph.d.ts +48 -22
  180. package/esm/types/hook.d.ts +22 -2
  181. package/esm/types/index.d.ts +2 -1
  182. package/esm/types/index.js +1 -0
  183. package/esm/types/index.js.map +1 -1
  184. package/esm/types/item.d.ts +7 -1
  185. package/esm/types/item.js.map +1 -1
  186. package/esm/types/plugin.d.ts +1 -1
  187. package/esm/types/spec.d.ts +20 -3
  188. package/esm/types/view.d.ts +5 -0
  189. package/esm/util/array.d.ts +1 -0
  190. package/esm/util/array.js +3 -0
  191. package/esm/util/array.js.map +1 -1
  192. package/esm/util/bbox.d.ts +16 -1
  193. package/esm/util/bbox.js +33 -5
  194. package/esm/util/bbox.js.map +1 -1
  195. package/esm/util/behavior.d.ts +2 -2
  196. package/esm/util/behavior.js +2 -2
  197. package/esm/util/behavior.js.map +1 -1
  198. package/esm/util/data.d.ts +5 -2
  199. package/esm/util/data.js +15 -0
  200. package/esm/util/data.js.map +1 -1
  201. package/esm/util/dom.d.ts +15 -0
  202. package/esm/util/dom.js +29 -0
  203. package/esm/util/dom.js.map +1 -0
  204. package/esm/util/event.d.ts +3 -1
  205. package/esm/util/event.js +8 -1
  206. package/esm/util/event.js.map +1 -1
  207. package/esm/util/extend.d.ts +1 -1
  208. package/esm/util/extend.js +0 -1
  209. package/esm/util/extend.js.map +1 -1
  210. package/esm/util/index.d.ts +7 -52
  211. package/esm/util/index.js +7 -23
  212. package/esm/util/index.js.map +1 -1
  213. package/esm/util/item.d.ts +16 -1
  214. package/esm/util/item.js +31 -8
  215. package/esm/util/item.js.map +1 -1
  216. package/esm/util/layout.d.ts +12 -1
  217. package/esm/util/layout.js +45 -0
  218. package/esm/util/layout.js.map +1 -1
  219. package/esm/util/loop.d.ts +2 -1
  220. package/esm/util/loop.js +14 -0
  221. package/esm/util/loop.js.map +1 -1
  222. package/esm/util/math.d.ts +1 -1
  223. package/esm/util/matrix.d.ts +6 -0
  224. package/esm/util/matrix.js +48 -0
  225. package/esm/util/matrix.js.map +1 -0
  226. package/esm/util/path.js +1 -1
  227. package/esm/util/path.js.map +1 -1
  228. package/esm/util/point.d.ts +1 -1
  229. package/esm/util/point.js +9 -2
  230. package/esm/util/point.js.map +1 -1
  231. package/esm/util/polyline.d.ts +2 -1
  232. package/esm/util/polyline.js +2 -1
  233. package/esm/util/polyline.js.map +1 -1
  234. package/esm/util/router.d.ts +1 -1
  235. package/esm/util/shape.d.ts +3 -3
  236. package/esm/util/shape.js +17 -26
  237. package/esm/util/shape.js.map +1 -1
  238. package/esm/util/shape3d.d.ts +1 -1
  239. package/esm/util/shape3d.js +16 -17
  240. package/esm/util/shape3d.js.map +1 -1
  241. package/esm/util/text.d.ts +1 -1
  242. package/esm/util/text.js +3 -2
  243. package/esm/util/text.js.map +1 -1
  244. package/esm/util/warn.d.ts +14 -0
  245. package/esm/util/warn.js +4 -0
  246. package/esm/util/warn.js.map +1 -0
  247. package/lib/api-doc/graph.d.ts +3 -3
  248. package/lib/api-doc/graph.js +27 -7
  249. package/lib/api-doc/graph.js.map +1 -1
  250. package/lib/api-doc/types.d.ts +1 -0
  251. package/lib/api-doc/types.js +2 -2
  252. package/lib/api-doc/types.js.map +1 -1
  253. package/lib/constant/shape.d.ts +3 -1
  254. package/lib/index.d.ts +33 -65
  255. package/lib/index.js +18 -10
  256. package/lib/index.js.map +1 -1
  257. package/lib/item/combo.d.ts +1 -1
  258. package/lib/item/combo.js +18 -14
  259. package/lib/item/combo.js.map +1 -1
  260. package/lib/item/edge.d.ts +19 -2
  261. package/lib/item/edge.js +99 -43
  262. package/lib/item/edge.js.map +1 -1
  263. package/lib/item/item.d.ts +3 -2
  264. package/lib/item/item.js +27 -13
  265. package/lib/item/item.js.map +1 -1
  266. package/lib/item/node.d.ts +2 -8
  267. package/lib/item/node.js +31 -19
  268. package/lib/item/node.js.map +1 -1
  269. package/lib/runtime/controller/data.d.ts +30 -16
  270. package/lib/runtime/controller/data.js +288 -420
  271. package/lib/runtime/controller/data.js.map +1 -1
  272. package/lib/runtime/controller/interaction.js +9 -4
  273. package/lib/runtime/controller/interaction.js.map +1 -1
  274. package/lib/runtime/controller/item.d.ts +1 -0
  275. package/lib/runtime/controller/item.js +284 -149
  276. package/lib/runtime/controller/item.js.map +1 -1
  277. package/lib/runtime/controller/layout.js +1 -3
  278. package/lib/runtime/controller/layout.js.map +1 -1
  279. package/lib/runtime/controller/plugin.js +9 -5
  280. package/lib/runtime/controller/plugin.js.map +1 -1
  281. package/lib/runtime/graph.d.ts +104 -24
  282. package/lib/runtime/graph.js +473 -94
  283. package/lib/runtime/graph.js.map +1 -1
  284. package/lib/stdlib/behavior/activate-relations.js +2 -2
  285. package/lib/stdlib/behavior/activate-relations.js.map +1 -1
  286. package/lib/stdlib/behavior/brush-select.d.ts +7 -1
  287. package/lib/stdlib/behavior/brush-select.js +13 -12
  288. package/lib/stdlib/behavior/brush-select.js.map +1 -1
  289. package/lib/stdlib/behavior/click-select.js +1 -1
  290. package/lib/stdlib/behavior/click-select.js.map +1 -1
  291. package/lib/stdlib/behavior/create-edge.d.ts +57 -0
  292. package/lib/stdlib/behavior/create-edge.js +219 -0
  293. package/lib/stdlib/behavior/create-edge.js.map +1 -0
  294. package/lib/stdlib/behavior/drag-canvas.d.ts +3 -1
  295. package/lib/stdlib/behavior/drag-canvas.js +78 -33
  296. package/lib/stdlib/behavior/drag-canvas.js.map +1 -1
  297. package/lib/stdlib/behavior/drag-combo.d.ts +2 -2
  298. package/lib/stdlib/behavior/drag-combo.js +43 -32
  299. package/lib/stdlib/behavior/drag-combo.js.map +1 -1
  300. package/lib/stdlib/behavior/drag-node.d.ts +3 -3
  301. package/lib/stdlib/behavior/drag-node.js +80 -63
  302. package/lib/stdlib/behavior/drag-node.js.map +1 -1
  303. package/lib/stdlib/behavior/index.d.ts +3 -0
  304. package/lib/stdlib/behavior/index.js +3 -0
  305. package/lib/stdlib/behavior/index.js.map +1 -1
  306. package/lib/stdlib/behavior/lasso-select.d.ts +1 -1
  307. package/lib/stdlib/behavior/lasso-select.js +6 -4
  308. package/lib/stdlib/behavior/lasso-select.js.map +1 -1
  309. package/lib/stdlib/behavior/scroll-canvas.d.ts +67 -0
  310. package/lib/stdlib/behavior/scroll-canvas.js +270 -0
  311. package/lib/stdlib/behavior/scroll-canvas.js.map +1 -0
  312. package/lib/stdlib/behavior/shortcuts-call.d.ts +38 -0
  313. package/lib/stdlib/behavior/shortcuts-call.js +91 -0
  314. package/lib/stdlib/behavior/shortcuts-call.js.map +1 -0
  315. package/lib/stdlib/behavior/zoom-canvas-3d.js +4 -1
  316. package/lib/stdlib/behavior/zoom-canvas-3d.js.map +1 -1
  317. package/lib/stdlib/behavior/zoom-canvas.d.ts +3 -1
  318. package/lib/stdlib/behavior/zoom-canvas.js +70 -26
  319. package/lib/stdlib/behavior/zoom-canvas.js.map +1 -1
  320. package/lib/stdlib/data/index.d.ts +1 -0
  321. package/lib/stdlib/data/index.js +1 -0
  322. package/lib/stdlib/data/index.js.map +1 -1
  323. package/lib/stdlib/data/mapNodeSize.d.ts +4 -5
  324. package/lib/stdlib/data/mapNodeSize.js +13 -3
  325. package/lib/stdlib/data/mapNodeSize.js.map +1 -1
  326. package/lib/stdlib/data/processParallelEdges.d.ts +21 -0
  327. package/lib/stdlib/data/processParallelEdges.js +131 -0
  328. package/lib/stdlib/data/processParallelEdges.js.map +1 -0
  329. package/lib/stdlib/data/transformV4Data.d.ts +3 -4
  330. package/lib/stdlib/data/transformV4Data.js +11 -3
  331. package/lib/stdlib/data/transformV4Data.js.map +1 -1
  332. package/lib/stdlib/data/validateData.d.ts +4 -5
  333. package/lib/stdlib/data/validateData.js +23 -14
  334. package/lib/stdlib/data/validateData.js.map +1 -1
  335. package/lib/stdlib/index.d.ts +27 -8
  336. package/lib/stdlib/index.js +24 -11
  337. package/lib/stdlib/index.js.map +1 -1
  338. package/lib/stdlib/item/edge/base.d.ts +3 -5
  339. package/lib/stdlib/item/edge/base.js +30 -29
  340. package/lib/stdlib/item/edge/base.js.map +1 -1
  341. package/lib/stdlib/item/edge/cubic-horizontal.js.map +1 -1
  342. package/lib/stdlib/item/edge/cubic-vertical.js.map +1 -1
  343. package/lib/stdlib/item/edge/cubic.js +2 -2
  344. package/lib/stdlib/item/edge/cubic.js.map +1 -1
  345. package/lib/stdlib/item/edge/loop.js +3 -3
  346. package/lib/stdlib/item/edge/loop.js.map +1 -1
  347. package/lib/stdlib/item/node/base.d.ts +3 -6
  348. package/lib/stdlib/item/node/base.js +29 -59
  349. package/lib/stdlib/item/node/base.js.map +1 -1
  350. package/lib/stdlib/item/node/base3d.d.ts +1 -0
  351. package/lib/stdlib/item/node/base3d.js +1 -0
  352. package/lib/stdlib/item/node/base3d.js.map +1 -1
  353. package/lib/stdlib/item/node/cube.d.ts +35 -0
  354. package/lib/stdlib/item/node/cube.js +58 -0
  355. package/lib/stdlib/item/node/cube.js.map +1 -0
  356. package/lib/stdlib/item/node/diamond.js +1 -1
  357. package/lib/stdlib/item/node/ellipse.js +2 -2
  358. package/lib/stdlib/item/node/hexagon.js +6 -2
  359. package/lib/stdlib/item/node/hexagon.js.map +1 -1
  360. package/lib/stdlib/item/node/image.d.ts +40 -0
  361. package/lib/stdlib/item/node/image.js +114 -0
  362. package/lib/stdlib/item/node/image.js.map +1 -0
  363. package/lib/stdlib/item/node/index.d.ts +4 -0
  364. package/lib/stdlib/item/node/index.js +4 -0
  365. package/lib/stdlib/item/node/index.js.map +1 -1
  366. package/lib/stdlib/plugin/edgeFilterLens/index.d.ts +66 -0
  367. package/lib/stdlib/plugin/edgeFilterLens/index.js +313 -0
  368. package/lib/stdlib/plugin/edgeFilterLens/index.js.map +1 -0
  369. package/lib/stdlib/plugin/grid/index.d.ts +1 -1
  370. package/lib/stdlib/plugin/grid/index.js +6 -7
  371. package/lib/stdlib/plugin/grid/index.js.map +1 -1
  372. package/lib/stdlib/plugin/history/combo-command.js +2 -2
  373. package/lib/stdlib/plugin/history/combo-command.js.map +1 -1
  374. package/lib/stdlib/plugin/history/index.d.ts +10 -10
  375. package/lib/stdlib/plugin/history/index.js +14 -14
  376. package/lib/stdlib/plugin/history/index.js.map +1 -1
  377. package/lib/stdlib/plugin/history/item-data-command.js +25 -16
  378. package/lib/stdlib/plugin/history/item-data-command.js.map +1 -1
  379. package/lib/stdlib/plugin/history/layer-updated-command.js +2 -2
  380. package/lib/stdlib/plugin/history/layer-updated-command.js.map +1 -1
  381. package/lib/stdlib/plugin/history/state-updated-command.js +1 -1
  382. package/lib/stdlib/plugin/history/state-updated-command.js.map +1 -1
  383. package/lib/stdlib/plugin/history/visibility-updated-command.js +2 -2
  384. package/lib/stdlib/plugin/history/visibility-updated-command.js.map +1 -1
  385. package/lib/stdlib/plugin/hull/convexHull.d.ts +1 -1
  386. package/lib/stdlib/plugin/hull/hullComponent.d.ts +1 -1
  387. package/lib/stdlib/plugin/hull/hullComponent.js +5 -9
  388. package/lib/stdlib/plugin/hull/hullComponent.js.map +1 -1
  389. package/lib/stdlib/plugin/hull/util.d.ts +2 -2
  390. package/lib/stdlib/plugin/hull/util.js +26 -22
  391. package/lib/stdlib/plugin/hull/util.js.map +1 -1
  392. package/lib/stdlib/plugin/index.d.ts +2 -0
  393. package/lib/stdlib/plugin/index.js +2 -0
  394. package/lib/stdlib/plugin/index.js.map +1 -1
  395. package/lib/stdlib/plugin/legend/index.d.ts +2 -2
  396. package/lib/stdlib/plugin/legend/index.js +3 -3
  397. package/lib/stdlib/plugin/legend/index.js.map +1 -1
  398. package/lib/stdlib/plugin/menu/index.d.ts +4 -4
  399. package/lib/stdlib/plugin/menu/index.js +6 -6
  400. package/lib/stdlib/plugin/menu/index.js.map +1 -1
  401. package/lib/stdlib/plugin/minimap/index.d.ts +6 -2
  402. package/lib/stdlib/plugin/minimap/index.js +121 -14
  403. package/lib/stdlib/plugin/minimap/index.js.map +1 -1
  404. package/lib/stdlib/plugin/snapline/index.d.ts +167 -0
  405. package/lib/stdlib/plugin/snapline/index.js +1067 -0
  406. package/lib/stdlib/plugin/snapline/index.js.map +1 -0
  407. package/lib/stdlib/plugin/timebar/index.js +2 -2
  408. package/lib/stdlib/plugin/timebar/index.js.map +1 -1
  409. package/lib/stdlib/plugin/toolbar/index.d.ts +3 -3
  410. package/lib/stdlib/plugin/toolbar/index.js +5 -5
  411. package/lib/stdlib/plugin/toolbar/index.js.map +1 -1
  412. package/lib/stdlib/plugin/tooltip/index.d.ts +4 -4
  413. package/lib/stdlib/plugin/tooltip/index.js +10 -11
  414. package/lib/stdlib/plugin/tooltip/index.js.map +1 -1
  415. package/lib/stdlib/plugin/types.d.ts +2 -0
  416. package/lib/stdlib/plugin/watermaker/index.d.ts +78 -0
  417. package/lib/stdlib/plugin/watermaker/index.js +247 -0
  418. package/lib/stdlib/plugin/watermaker/index.js.map +1 -0
  419. package/lib/stdlib/theme/dark.js +42 -2
  420. package/lib/stdlib/theme/dark.js.map +1 -1
  421. package/lib/stdlib/theme/light.js +4 -4
  422. package/lib/types/data.d.ts +5 -0
  423. package/lib/types/event.d.ts +1 -0
  424. package/lib/types/graph.d.ts +48 -22
  425. package/lib/types/hook.d.ts +22 -2
  426. package/lib/types/index.d.ts +2 -1
  427. package/lib/types/index.js +3 -1
  428. package/lib/types/index.js.map +1 -1
  429. package/lib/types/item.d.ts +7 -1
  430. package/lib/types/item.js.map +1 -1
  431. package/lib/types/plugin.d.ts +1 -1
  432. package/lib/types/spec.d.ts +20 -3
  433. package/lib/types/view.d.ts +5 -0
  434. package/lib/util/array.d.ts +1 -0
  435. package/lib/util/array.js +5 -1
  436. package/lib/util/array.js.map +1 -1
  437. package/lib/util/bbox.d.ts +16 -1
  438. package/lib/util/bbox.js +36 -6
  439. package/lib/util/bbox.js.map +1 -1
  440. package/lib/util/behavior.d.ts +2 -2
  441. package/lib/util/behavior.js +2 -2
  442. package/lib/util/behavior.js.map +1 -1
  443. package/lib/util/data.d.ts +5 -2
  444. package/lib/util/data.js +16 -1
  445. package/lib/util/data.js.map +1 -1
  446. package/lib/util/dom.d.ts +15 -0
  447. package/lib/util/dom.js +34 -0
  448. package/lib/util/dom.js.map +1 -0
  449. package/lib/util/event.d.ts +3 -1
  450. package/lib/util/event.js +8 -1
  451. package/lib/util/event.js.map +1 -1
  452. package/lib/util/extend.d.ts +1 -1
  453. package/lib/util/extend.js +0 -1
  454. package/lib/util/extend.js.map +1 -1
  455. package/lib/util/index.d.ts +7 -52
  456. package/lib/util/index.js +23 -23
  457. package/lib/util/index.js.map +1 -1
  458. package/lib/util/item.d.ts +16 -1
  459. package/lib/util/item.js +33 -9
  460. package/lib/util/item.js.map +1 -1
  461. package/lib/util/layout.d.ts +12 -1
  462. package/lib/util/layout.js +47 -1
  463. package/lib/util/layout.js.map +1 -1
  464. package/lib/util/loop.d.ts +2 -1
  465. package/lib/util/loop.js +15 -1
  466. package/lib/util/loop.js.map +1 -1
  467. package/lib/util/math.d.ts +1 -1
  468. package/lib/util/matrix.d.ts +6 -0
  469. package/lib/util/matrix.js +52 -0
  470. package/lib/util/matrix.js.map +1 -0
  471. package/lib/util/path.js +2 -2
  472. package/lib/util/path.js.map +1 -1
  473. package/lib/util/point.d.ts +1 -1
  474. package/lib/util/point.js +9 -2
  475. package/lib/util/point.js.map +1 -1
  476. package/lib/util/polyline.d.ts +2 -1
  477. package/lib/util/polyline.js +2 -1
  478. package/lib/util/polyline.js.map +1 -1
  479. package/lib/util/router.d.ts +1 -1
  480. package/lib/util/shape.d.ts +3 -3
  481. package/lib/util/shape.js +17 -26
  482. package/lib/util/shape.js.map +1 -1
  483. package/lib/util/shape3d.d.ts +1 -1
  484. package/lib/util/shape3d.js +15 -16
  485. package/lib/util/shape3d.js.map +1 -1
  486. package/lib/util/text.d.ts +1 -1
  487. package/lib/util/text.js +3 -2
  488. package/lib/util/text.js.map +1 -1
  489. package/lib/util/warn.d.ts +14 -0
  490. package/lib/util/warn.js +8 -0
  491. package/lib/util/warn.js.map +1 -0
  492. package/package.json +42 -51
  493. package/src/api-doc/graph.ts +4 -3
  494. package/src/api-doc/types.ts +1 -0
  495. package/src/constant/shape.ts +1 -1
  496. package/src/index.ts +5 -6
  497. package/src/item/combo.ts +16 -15
  498. package/src/item/edge.ts +135 -57
  499. package/src/item/item.ts +32 -19
  500. package/src/item/node.ts +36 -50
  501. package/src/runtime/controller/data.ts +371 -490
  502. package/src/runtime/controller/interaction.ts +10 -4
  503. package/src/runtime/controller/item.ts +261 -78
  504. package/src/runtime/controller/layout.ts +1 -5
  505. package/src/runtime/controller/plugin.ts +15 -4
  506. package/src/runtime/graph.ts +605 -103
  507. package/src/stdlib/behavior/activate-relations.ts +2 -2
  508. package/src/stdlib/behavior/brush-select.ts +14 -13
  509. package/src/stdlib/behavior/click-select.ts +1 -1
  510. package/src/stdlib/behavior/create-edge.ts +305 -0
  511. package/src/stdlib/behavior/drag-canvas.ts +107 -35
  512. package/src/stdlib/behavior/drag-combo.ts +10 -10
  513. package/src/stdlib/behavior/drag-node.ts +27 -18
  514. package/src/stdlib/behavior/index.ts +3 -0
  515. package/src/stdlib/behavior/lasso-select.ts +7 -5
  516. package/src/stdlib/behavior/scroll-canvas.ts +348 -0
  517. package/src/stdlib/behavior/shortcuts-call.ts +129 -0
  518. package/src/stdlib/behavior/zoom-canvas-3d.ts +4 -1
  519. package/src/stdlib/behavior/zoom-canvas.ts +98 -27
  520. package/src/stdlib/data/index.ts +1 -0
  521. package/src/stdlib/data/mapNodeSize.ts +22 -3
  522. package/src/stdlib/data/processParallelEdges.ts +203 -0
  523. package/src/stdlib/data/transformV4Data.ts +16 -3
  524. package/src/stdlib/data/validateData.ts +32 -18
  525. package/src/stdlib/index.ts +31 -8
  526. package/src/stdlib/item/edge/base.ts +32 -41
  527. package/src/stdlib/item/edge/cubic-horizontal.ts +0 -1
  528. package/src/stdlib/item/edge/cubic-vertical.ts +0 -1
  529. package/src/stdlib/item/edge/cubic.ts +1 -1
  530. package/src/stdlib/item/edge/loop.ts +1 -1
  531. package/src/stdlib/item/node/base.ts +38 -65
  532. package/src/stdlib/item/node/base3d.ts +1 -0
  533. package/src/stdlib/item/node/cube.ts +102 -0
  534. package/src/stdlib/item/node/diamond.ts +1 -1
  535. package/src/stdlib/item/node/ellipse.ts +2 -2
  536. package/src/stdlib/item/node/hexagon.ts +6 -2
  537. package/src/stdlib/item/node/image.ts +190 -0
  538. package/src/stdlib/item/node/index.ts +4 -0
  539. package/src/stdlib/plugin/edgeFilterLens/index.ts +387 -0
  540. package/src/stdlib/plugin/grid/index.ts +6 -6
  541. package/src/stdlib/plugin/history/combo-command.ts +2 -2
  542. package/src/stdlib/plugin/history/index.ts +14 -14
  543. package/src/stdlib/plugin/history/item-data-command.ts +35 -17
  544. package/src/stdlib/plugin/history/layer-updated-command.ts +2 -2
  545. package/src/stdlib/plugin/history/state-updated-command.ts +1 -1
  546. package/src/stdlib/plugin/history/visibility-updated-command.ts +2 -2
  547. package/src/stdlib/plugin/hull/convexHull.ts +1 -1
  548. package/src/stdlib/plugin/hull/hullComponent.ts +10 -8
  549. package/src/stdlib/plugin/hull/util.ts +6 -2
  550. package/src/stdlib/plugin/index.ts +2 -0
  551. package/src/stdlib/plugin/legend/index.ts +6 -6
  552. package/src/stdlib/plugin/menu/index.ts +13 -13
  553. package/src/stdlib/plugin/minimap/index.ts +126 -16
  554. package/src/stdlib/plugin/snapline/index.ts +1297 -0
  555. package/src/stdlib/plugin/timebar/index.ts +4 -4
  556. package/src/stdlib/plugin/toolbar/index.ts +8 -8
  557. package/src/stdlib/plugin/tooltip/index.ts +10 -10
  558. package/src/stdlib/plugin/types.ts +2 -0
  559. package/src/stdlib/plugin/watermaker/index.ts +302 -0
  560. package/src/stdlib/theme/dark.ts +66 -2
  561. package/src/stdlib/theme/light.ts +4 -4
  562. package/src/types/data.ts +6 -0
  563. package/src/types/event.ts +1 -0
  564. package/src/types/graph.ts +62 -25
  565. package/src/types/hook.ts +22 -2
  566. package/src/types/index.ts +2 -1
  567. package/src/types/item.ts +12 -1
  568. package/src/types/plugin.ts +1 -1
  569. package/src/types/spec.ts +23 -3
  570. package/src/types/view.ts +8 -3
  571. package/src/util/array.ts +12 -0
  572. package/src/util/bbox.ts +42 -6
  573. package/src/util/behavior.ts +4 -4
  574. package/src/util/data.ts +26 -4
  575. package/src/util/dom.ts +33 -0
  576. package/src/util/event.ts +14 -1
  577. package/src/util/extend.ts +2 -3
  578. package/src/util/index.ts +7 -24
  579. package/src/util/item.ts +65 -28
  580. package/src/util/layout.ts +48 -2
  581. package/src/util/loop.ts +16 -1
  582. package/src/util/math.ts +1 -1
  583. package/src/util/matrix.ts +66 -0
  584. package/src/util/path.ts +1 -1
  585. package/src/util/point.ts +9 -4
  586. package/src/util/polyline.ts +2 -1
  587. package/src/util/router.ts +1 -1
  588. package/src/util/shape.ts +23 -26
  589. package/src/util/shape3d.ts +20 -20
  590. package/src/util/text.ts +3 -1
  591. package/src/util/warn.ts +20 -0
@@ -10,11 +10,10 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  return t;
11
11
  };
12
12
  import { Graph as GraphLib } from '@antv/graphlib';
13
- import { clone, isArray, isObject } from '@antv/util';
13
+ import { clone, isArray, isEmpty, isObject } from '@antv/util';
14
14
  import { registery as registry } from '../../stdlib';
15
- import { deconstructData, graphComboTreeDfs, graphData2TreeData, traverse, treeData2GraphData, validateComboStrucutre, } from '../../util/data';
15
+ import { AVAILABLE_DATA_LIFECYCLE, DEFAULT_ACTIVE_DATA_LIFECYCLE, dataLifecycleMap, deconstructData, graphComboTreeDfs, graphData2TreeData, traverse, treeData2GraphData, validateComboStrucutre, } from '../../util/data';
16
16
  import { getExtension } from '../../util/extension';
17
- import { convertToNumber } from '../../util/type';
18
17
  import { isTreeLayout } from '../../util/layout';
19
18
  import { hasTreeBehaviors } from '../../util/behavior';
20
19
  /**
@@ -24,6 +23,22 @@ import { hasTreeBehaviors } from '../../util/behavior';
24
23
  export class DataController {
25
24
  constructor(graph) {
26
25
  this.extensions = [];
26
+ /**
27
+ * Determine whether to execute transform in the current data life cycle
28
+ * @param config transform plugin's configuration
29
+ * @param changeType type of data change
30
+ */
31
+ this.isTransformActive = (config, changeType) => {
32
+ let activeLifecycle = isObject(config) && 'activeLifecycle' in config
33
+ ? config.activeLifecycle
34
+ : DEFAULT_ACTIVE_DATA_LIFECYCLE;
35
+ activeLifecycle = Array.isArray(activeLifecycle)
36
+ ? activeLifecycle
37
+ : activeLifecycle === 'all'
38
+ ? AVAILABLE_DATA_LIFECYCLE
39
+ : [activeLifecycle];
40
+ return activeLifecycle.includes(dataLifecycleMap[changeType]);
41
+ };
27
42
  this.graph = graph;
28
43
  this.tap();
29
44
  }
@@ -129,15 +144,9 @@ export class DataController {
129
144
  */
130
145
  onDataChange(param) {
131
146
  const { data, type: changeType } = param;
132
- const { userGraphCore } = this;
147
+ const { graphCore } = this;
133
148
  const change = () => {
134
149
  switch (changeType) {
135
- case 'remove':
136
- this.removeData(data);
137
- break;
138
- case 'update':
139
- this.updateData(data);
140
- break;
141
150
  case 'moveCombo':
142
151
  this.moveCombo(data);
143
152
  break;
@@ -145,13 +154,13 @@ export class DataController {
145
154
  this.addCombo(data);
146
155
  break;
147
156
  default:
148
- // changeType is 'replace' | 'mergeReplace' | 'union'
157
+ // changeType is 'replace' | 'mergeReplace' | 'union' | 'remove' | 'update'
149
158
  this.changeData(data, changeType);
150
159
  break;
151
160
  }
152
161
  };
153
- if (userGraphCore) {
154
- userGraphCore.batch(change);
162
+ if (graphCore) {
163
+ graphCore.batch(change);
155
164
  }
156
165
  else {
157
166
  change();
@@ -160,21 +169,21 @@ export class DataController {
160
169
  onTreeCollapseExpand(params) {
161
170
  const { ids, action } = params;
162
171
  ids.forEach((id) => {
163
- this.userGraphCore.mergeNodeData(id, {
172
+ this.graphCore.mergeNodeData(id, {
164
173
  collapsed: action === 'collapse',
165
174
  });
166
175
  });
167
176
  }
168
177
  onLayout({ options }) {
169
178
  if (this.treeDirtyFlag && isTreeLayout(options)) {
170
- this.establishUserGraphCoreTree();
179
+ this.establishGraphCoreTree();
171
180
  }
172
181
  }
173
182
  onGraphInit() {
174
183
  const { modes = {} } = this.graph.getSpecification();
175
184
  const mode = this.graph.getMode() || 'default';
176
185
  if (hasTreeBehaviors(modes[mode])) {
177
- this.establishUserGraphCoreTree();
186
+ this.establishGraphCoreTree();
178
187
  }
179
188
  }
180
189
  onBehaviorChange(param) {
@@ -183,56 +192,49 @@ export class DataController {
183
192
  if (action !== 'add' || !modes.includes(mode))
184
193
  return;
185
194
  if (hasTreeBehaviors(behaviors)) {
186
- this.establishUserGraphCoreTree();
195
+ this.establishGraphCoreTree();
187
196
  }
188
197
  }
189
198
  onModeChange(param) {
190
199
  const { modes = {} } = this.graph.getSpecification();
191
200
  if (hasTreeBehaviors(modes[param.mode])) {
192
- this.establishUserGraphCoreTree();
201
+ this.establishGraphCoreTree();
193
202
  }
194
203
  }
195
- establishUserGraphCoreTree() {
204
+ establishGraphCoreTree() {
196
205
  if (!this.treeDirtyFlag)
197
206
  return;
198
- const nodes = this.userGraphCore.getAllNodes();
199
- const edges = this.userGraphCore.getAllEdges();
200
- this.userGraphCore.batch(() => {
201
- // graph data to tree structure and storing
202
- const rootIds = nodes
203
- .filter((node) => node.data.isRoot)
204
- .map((node) => node.id);
205
- graphData2TreeData({}, { nodes, edges }, rootIds).forEach((tree) => {
206
- traverse(tree, (node) => {
207
- var _a;
208
- (_a = node.children) === null || _a === void 0 ? void 0 : _a.forEach((child) => {
209
- this.userGraphCore.setParent(child.id, node.id, 'tree');
210
- });
207
+ const nodes = this.graphCore.getAllNodes();
208
+ const edges = this.graphCore.getAllEdges();
209
+ // graph data to tree structure and storing
210
+ const rootIds = nodes
211
+ .filter((node) => node.data.isRoot)
212
+ .map((node) => node.id);
213
+ graphData2TreeData({}, { nodes, edges }, rootIds).forEach((tree) => {
214
+ traverse(tree, (node) => {
215
+ var _a;
216
+ (_a = node.children) === null || _a === void 0 ? void 0 : _a.forEach((child) => {
217
+ this.graphCore.setParent(child.id, node.id, 'tree');
211
218
  });
212
219
  });
213
220
  });
214
221
  this.treeDirtyFlag = false;
215
222
  }
216
223
  /**
217
- * Change data by replace, merge repalce, or union.
224
+ * Change data by replace, merge repalce, union, remove or update.
218
225
  * @param data new data
219
- * @param changeType type of data change, 'replace' means discard the old data. 'mergeReplace' means merge the common part. 'union' means merge whole sets of old and new one
226
+ * @param changeType type of data change, 'replace' means discard the old data. 'mergeReplace' means merge the common part. 'union' means merge whole sets of old and new one. 'remove' means remove the common part. 'update' means update the comme part.
220
227
  */
221
228
  changeData(dataConfig, changeType) {
222
229
  var _a;
223
230
  const { type: dataType, data } = this.formatData(dataConfig) || {};
224
231
  if (!dataType)
225
232
  return;
226
- const { nodes = [], edges = [], combos = [] } = this.transformData(data);
233
+ this.dataType = dataType;
234
+ const preprocessedData = this.preprocessData(data, changeType);
235
+ const { dataAdded, dataRemoved, dataUpdated } = this.transformData(preprocessedData, changeType);
227
236
  if (changeType === 'replace') {
228
- this.userGraphCore = new GraphLib({
229
- nodes: nodes.concat((combos === null || combos === void 0 ? void 0 : combos.map((combo) => ({
230
- id: combo.id,
231
- data: Object.assign(Object.assign({}, combo.data), { _isCombo: true }),
232
- }))) || []),
233
- edges,
234
- onChanged: (event) => this.updateGraphCore(event),
235
- });
237
+ const { nodes, edges, combos } = dataAdded;
236
238
  this.graphCore = new GraphLib(clone({
237
239
  nodes: nodes.concat((combos === null || combos === void 0 ? void 0 : combos.map((combo) => ({
238
240
  id: combo.id,
@@ -265,209 +267,176 @@ export class DataController {
265
267
  }
266
268
  }
267
269
  else {
268
- const { userGraphCore } = this;
269
- const prevData = deconstructData({
270
- nodes: userGraphCore.getAllNodes(),
271
- edges: [],
272
- });
273
- const nodesAndCombos = nodes.concat(combos.map((combo) => ({
274
- id: combo.id,
275
- data: Object.assign(Object.assign({}, combo.data), { _isCombo: true }),
276
- })));
277
- // =========== node & combos ============
278
- if (!prevData.nodes.length) {
279
- userGraphCore.addNodes(nodesAndCombos);
280
- }
281
- else {
282
- if (changeType === 'mergeReplace') {
283
- // remove the nodes which are not in data but in userGraphCore
284
- const nodeAndComboIds = nodesAndCombos.map((node) => node.id);
285
- prevData.nodes.forEach((prevNode) => {
286
- if (!nodeAndComboIds.includes(prevNode.id))
287
- userGraphCore.removeNode(prevNode.id);
288
- });
289
- }
290
- // add or update node
291
- nodesAndCombos.forEach((item) => {
292
- if (userGraphCore.hasNode(item.id)) {
293
- // update node which is in the graphCore
294
- userGraphCore.mergeNodeData(item.id, item.data);
295
- }
296
- else {
297
- // add node which is in data but not in graphCore
298
- userGraphCore.addNode(item);
299
- }
300
- });
301
- }
302
- // =========== edge ============
303
- prevData.edges = userGraphCore.getAllEdges();
304
- if (!prevData.edges.length) {
305
- userGraphCore.addEdges(edges);
306
- }
307
- else {
308
- if (changeType === 'mergeReplace') {
309
- // remove the edges which are not in data but in userGraphCore
310
- const edgeIds = edges.map((edge) => edge.id);
311
- prevData.edges.forEach((prevEdge) => {
312
- if (!edgeIds.includes(prevEdge.id))
313
- userGraphCore.removeEdge(prevEdge.id);
314
- });
315
- }
316
- // add or update edge
317
- edges.forEach((edge) => {
318
- if (userGraphCore.hasEdge(edge.id)) {
319
- // update edge which is in the graphCore
320
- userGraphCore.mergeEdgeData(edge.id, edge.data);
321
- }
322
- else {
323
- // add edge which is in data but not in graphCore
324
- userGraphCore.addEdge(edge);
325
- }
326
- });
327
- }
270
+ this.doRemove(dataRemoved);
271
+ this.doAdd(dataAdded);
272
+ this.doUpdate(dataUpdated);
328
273
  }
329
- if ((_a = data.edges) === null || _a === void 0 ? void 0 : _a.length) {
330
- const { userGraphCore } = this;
274
+ if ((_a = data.edges) === null || _a === void 0 ? void 0 : _a.filter((edge) => edge.hasOwnProperty('source') || edge.hasOwnProperty('target')).length) {
331
275
  // convert and store tree structure to graphCore
332
276
  this.updateTreeGraph(dataType, {
333
- nodes: userGraphCore.getAllNodes(),
334
- edges: userGraphCore.getAllEdges(),
277
+ nodes: this.graphCore.getAllNodes(),
278
+ edges: this.graphCore.getAllEdges(),
335
279
  });
336
280
  }
337
281
  }
338
282
  /**
339
- * Remove part of old data.
340
- * @param data data to be removed which is part of old one
283
+ * Add new data.
284
+ * @param data data to be added which is not in graphCore
341
285
  */
342
- removeData(data) {
343
- const { userGraphCore } = this;
286
+ doAdd(data) {
287
+ if (isEmpty(data))
288
+ return;
289
+ const { graphCore } = this;
344
290
  const { nodes = [], edges = [], combos = [] } = data;
345
- const nodesAndCombos = nodes.concat(combos);
346
- const prevNodesAndCombos = userGraphCore.getAllNodes();
347
- const prevEdges = userGraphCore.getAllEdges();
348
- if (prevNodesAndCombos.length && nodesAndCombos.length) {
349
- // update the parentId
350
- if (this.graphCore.hasTreeStructure('combo')) {
351
- nodesAndCombos.forEach((item) => {
352
- const { parentId } = item.data;
353
- this.graphCore.getChildren(item.id, 'combo').forEach((child) => {
354
- userGraphCore.mergeNodeData(child.id, { parentId });
355
- });
356
- });
357
- }
358
- // remove the node
359
- userGraphCore.removeNodes(nodesAndCombos.map((node) => node.id));
291
+ if (nodes.length || combos.length) {
292
+ const nodesAndCombos = getNodesAndCombos(data);
293
+ graphCore.addNodes(nodesAndCombos);
360
294
  }
361
- if (prevEdges.length && edges.length) {
362
- // add or update edge
363
- const ids = edges
364
- .map((edge) => edge.id)
365
- .filter((id) => userGraphCore.hasEdge(id));
366
- userGraphCore.removeEdges(ids);
295
+ if (edges.length) {
296
+ graphCore.addEdges(edges);
367
297
  }
368
298
  }
369
299
  /**
370
300
  * Update part of old data.
371
- * @param data data to be updated which is part of old one
301
+ * @param data data to be updated which is part of old one in the graphCore
372
302
  */
373
- updateData(dataConfig) {
374
- const { userGraphCore } = this;
375
- const { type: dataType, data } = this.formatData(dataConfig);
376
- if (!dataType)
303
+ doUpdate(data) {
304
+ if (isEmpty(data))
377
305
  return;
378
- const { nodes = [], edges = [], combos = [] } = data; //this.transformData(data as GraphData);
379
- const { nodes: prevNodes, edges: prevEdges, combos: prevCombos, } = deconstructData({
380
- nodes: userGraphCore.getAllNodes(),
381
- edges: userGraphCore.getAllEdges(),
306
+ const { graphCore } = this;
307
+ const { nodes = [], edges = [], combos = [] } = data;
308
+ // update node
309
+ nodes.forEach((newModel) => {
310
+ const { id, data } = newModel;
311
+ if (data) {
312
+ const mergedData = mergeOneLevelData(graphCore.getNode(id), newModel);
313
+ graphCore.mergeNodeData(id, mergedData);
314
+ }
315
+ if (data.hasOwnProperty('parentId')) {
316
+ graphCore.setParent(id, data.parentId, 'combo');
317
+ }
382
318
  });
383
- if (prevNodes.length) {
384
- // update node
385
- nodes.forEach((newModel) => {
386
- const { id, data } = newModel;
387
- if (data) {
388
- const mergedData = mergeOneLevelData(userGraphCore.getNode(id), newModel);
389
- userGraphCore.mergeNodeData(id, mergedData);
390
- }
391
- });
392
- }
393
- if (prevEdges.length) {
394
- // update edge
395
- edges.forEach((newModel) => {
396
- const oldModel = userGraphCore.getEdge(newModel.id);
397
- if (!oldModel)
398
- return;
399
- const { id, source, target, data } = newModel;
400
- if (source && oldModel.source !== source)
401
- userGraphCore.updateEdgeSource(id, source);
402
- if (target && oldModel.target !== target)
403
- userGraphCore.updateEdgeTarget(id, target);
404
- if (data) {
405
- const mergedData = mergeOneLevelData(userGraphCore.getEdge(id), newModel);
406
- userGraphCore.mergeEdgeData(id, mergedData);
407
- }
408
- });
409
- }
410
- if (prevCombos.length) {
411
- // update combos
412
- const modelsToMove = [];
413
- combos.forEach((newModel) => {
414
- const { id, data } = newModel;
415
- const { x: comboNewX, y: comboNewY } = data, others = __rest(data, ["x", "y"]);
416
- if (comboNewX !== undefined || comboNewY !== undefined) {
417
- if (this.graphCore.getChildren(id, 'combo').length) {
418
- // combo's position is updated, update the succeed nodes' positions
419
- const oldBounds = this.graph.getRenderBBox(id, true);
420
- if (!oldBounds)
421
- return;
422
- const [comboOldX, comboOldY] = oldBounds.center;
423
- const dx = comboNewX - comboOldX;
424
- const dy = comboNewY - comboOldY;
425
- graphComboTreeDfs(this.graph, [newModel], (succeed) => {
426
- const { x, y, _isCombo } = succeed.data;
427
- if (!_isCombo) {
428
- modelsToMove.push({
429
- id: succeed.id,
430
- data: {
431
- x: x + dx,
432
- y: y + dy,
433
- },
434
- });
435
- }
436
- }, 'BT');
437
- }
438
- else {
439
- // empty combo, modify the position directly
440
- modelsToMove.push({
441
- id,
442
- data: {
443
- x: comboNewX,
444
- y: comboNewY,
445
- },
446
- });
447
- }
319
+ // update edge
320
+ edges.forEach((newModel) => {
321
+ const oldModel = graphCore.getEdge(newModel.id);
322
+ if (!oldModel)
323
+ return;
324
+ const { id, source, target, data } = newModel;
325
+ if (source && oldModel.source !== source)
326
+ graphCore.updateEdgeSource(id, source);
327
+ if (target && oldModel.target !== target)
328
+ graphCore.updateEdgeTarget(id, target);
329
+ if (data) {
330
+ const mergedData = mergeOneLevelData(graphCore.getEdge(id), newModel);
331
+ graphCore.mergeEdgeData(id, mergedData);
332
+ }
333
+ });
334
+ // update combos
335
+ const modelsToMove = [];
336
+ combos.forEach((newModel) => {
337
+ const { id, data } = newModel;
338
+ const { x: comboNewX, y: comboNewY } = data, others = __rest(data, ["x", "y"]);
339
+ if (comboNewX !== undefined || comboNewY !== undefined) {
340
+ if (this.graphCore.getChildren(id, 'combo').length) {
341
+ // combo's position is updated, update the succeed nodes' positions
342
+ const oldBounds = this.graph.getRenderBBox(id, true);
343
+ if (!oldBounds)
344
+ return;
345
+ const [comboOldX, comboOldY] = oldBounds.center;
346
+ const dx = comboNewX - comboOldX;
347
+ const dy = comboNewY - comboOldY;
348
+ graphComboTreeDfs(this.graph, [newModel], (succeed) => {
349
+ const { x, y, _isCombo } = succeed.data;
350
+ if (!_isCombo) {
351
+ modelsToMove.push({
352
+ id: succeed.id,
353
+ data: {
354
+ x: x + dx,
355
+ y: y + dy,
356
+ },
357
+ });
358
+ }
359
+ }, 'BT');
448
360
  }
449
- // update other properties
450
- if (Object.keys(others).length) {
451
- const mergedData = mergeOneLevelData(userGraphCore.getNode(id), {
361
+ else {
362
+ // empty combo, modify the position directly
363
+ modelsToMove.push({
452
364
  id,
453
- data: others,
365
+ data: {
366
+ x: comboNewX,
367
+ y: comboNewY,
368
+ },
454
369
  });
455
- userGraphCore.mergeNodeData(id, mergedData);
456
370
  }
457
- });
458
- // update succeed nodes
459
- modelsToMove.forEach((newModel) => {
460
- const { id, data } = newModel;
461
- userGraphCore.mergeNodeData(id, data);
462
- });
371
+ }
372
+ // update other properties
373
+ if (Object.keys(others).length) {
374
+ const mergedData = mergeOneLevelData(graphCore.getNode(id), {
375
+ id,
376
+ data: others,
377
+ });
378
+ graphCore.mergeNodeData(id, mergedData);
379
+ if (others.hasOwnProperty('parentId')) {
380
+ graphCore.setParent(id, others.parentId, 'combo');
381
+ }
382
+ }
383
+ });
384
+ // update succeed nodes
385
+ modelsToMove.forEach((newModel) => {
386
+ const { id, data } = newModel;
387
+ graphCore.mergeNodeData(id, data);
388
+ });
389
+ }
390
+ /**
391
+ * Remove part of old data.
392
+ * @param data data to be removed which is part of old one in the graphCore
393
+ */
394
+ doRemove(data) {
395
+ if (isEmpty(data))
396
+ return;
397
+ const { graphCore } = this;
398
+ if (data.edges.length) {
399
+ // add or update edge
400
+ const ids = data.edges.map((edge) => edge.id);
401
+ graphCore.removeEdges(ids);
463
402
  }
464
- if (edges === null || edges === void 0 ? void 0 : edges.filter((edge) => edge.hasOwnProperty('source') || edge.hasOwnProperty('target')).length) {
465
- // convert and store tree structure to graphCore
466
- this.updateTreeGraph(dataType, {
467
- nodes: this.userGraphCore.getAllNodes(),
468
- edges: this.userGraphCore.getAllEdges(),
403
+ const nodesAndCombos = getNodesAndCombos(data);
404
+ // update combo tree view and tree graph view
405
+ nodesAndCombos === null || nodesAndCombos === void 0 ? void 0 : nodesAndCombos.forEach((item) => this.removeNode(item));
406
+ }
407
+ removeNode(nodeModel) {
408
+ const { id, data } = nodeModel;
409
+ const { graphCore } = this;
410
+ if (graphCore.hasTreeStructure('combo')) {
411
+ // remove from its parent's children list
412
+ graphCore.setParent(id, undefined, 'combo');
413
+ const { parentId } = data;
414
+ // move the children to the grandparent's children list
415
+ graphCore.getChildren(id, 'combo').forEach((child) => {
416
+ graphCore.setParent(child.id, parentId, 'combo');
417
+ graphCore.mergeNodeData(child.id, { parentId });
469
418
  });
470
419
  }
420
+ if (graphCore.hasTreeStructure('tree')) {
421
+ const succeedIds = [];
422
+ graphCore.dfsTree(id, (child) => {
423
+ succeedIds.push(child.id);
424
+ }, 'tree');
425
+ const succeedEdgeIds = graphCore
426
+ .getAllEdges()
427
+ .filter(({ source, target }) => succeedIds.includes(source) && succeedIds.includes(target))
428
+ .map((edge) => edge.id);
429
+ this.graph.showItem(succeedIds
430
+ .filter((succeedId) => succeedId !== id)
431
+ .concat(succeedEdgeIds));
432
+ // for tree graph view, remove the node from the parent's children list
433
+ graphCore.setParent(id, undefined, 'tree');
434
+ // for tree graph view, make the its children to be roots
435
+ graphCore
436
+ .getChildren(id, 'tree')
437
+ .forEach((child) => graphCore.setParent(child.id, undefined, 'tree'));
438
+ }
439
+ graphCore.removeNode(id);
471
440
  }
472
441
  formatData(dataConfig) {
473
442
  const { type, value } = dataConfig;
@@ -486,12 +455,12 @@ export class DataController {
486
455
  return;
487
456
  }
488
457
  return {
489
- type: type || 'graphData',
458
+ type: type || this.dataType || 'graphData',
490
459
  data: data,
491
460
  };
492
461
  }
493
462
  /**
494
- * Relatively move the position of combo a dinstance (dx and dy in combo data).
463
+ * Relatively move the position of combo a distance (dx and dy in combo data).
495
464
  * @param data graph data which contains the combo dx dy info
496
465
  */
497
466
  moveCombo(data) {
@@ -531,12 +500,12 @@ export class DataController {
531
500
  }
532
501
  });
533
502
  // update succeed nodes
534
- const { userGraphCore } = this;
503
+ const { graphCore } = this;
535
504
  succeedNodesModels.forEach((newModel) => {
536
505
  const { id, data } = newModel;
537
506
  if (data) {
538
- const mergedData = mergeOneLevelData(userGraphCore.getNode(id), newModel);
539
- userGraphCore.mergeNodeData(id, mergedData);
507
+ const mergedData = mergeOneLevelData(graphCore.getNode(id), newModel);
508
+ graphCore.mergeNodeData(id, mergedData);
540
509
  }
541
510
  });
542
511
  }
@@ -544,17 +513,20 @@ export class DataController {
544
513
  const { combos = [] } = data;
545
514
  if (!(combos === null || combos === void 0 ? void 0 : combos.length))
546
515
  return;
547
- const { userGraphCore } = this;
516
+ const { graphCore } = this;
548
517
  const { id, data: comboData } = combos[0];
549
518
  const { _children = [] } = comboData, others = __rest(comboData, ["_children"]);
519
+ if (!graphCore.hasTreeStructure('combo')) {
520
+ graphCore.attachTreeStructure('combo');
521
+ }
550
522
  // add or update combo
551
- if (userGraphCore.hasNode(id)) {
523
+ if (graphCore.hasNode(id)) {
552
524
  // update node which is in the graphCore
553
- userGraphCore.mergeNodeData(id, Object.assign(Object.assign({}, others), { _isCombo: true }));
525
+ graphCore.mergeNodeData(id, Object.assign(Object.assign({}, others), { _isCombo: true }));
554
526
  }
555
527
  else {
556
528
  // add node which is in data but not in graphCore
557
- userGraphCore.addNode({ id, data: Object.assign(Object.assign({}, others), { _isCombo: true }) });
529
+ graphCore.addNode({ id, data: Object.assign(Object.assign({}, others), { _isCombo: true }) });
558
530
  }
559
531
  // update strucutre
560
532
  _children.forEach((childId) => {
@@ -562,208 +534,62 @@ export class DataController {
562
534
  console.warn(`Adding child ${childId} to combo ${id} failed. The child ${childId} does not exist`);
563
535
  return;
564
536
  }
565
- userGraphCore.mergeNodeData(childId, { parentId: id });
537
+ graphCore.setParent(childId, id, 'combo');
538
+ graphCore.mergeNodeData(childId, { parentId: id });
566
539
  });
567
540
  }
568
541
  /**
569
- * Update graphCore with transformed userGraphCore data.
542
+ * Preprocess the data and divide the data into three categories: Add, Update, Delete according to the operation type.
543
+ * @param data new graph data
544
+ * @param type type of data change
570
545
  */
571
- updateGraphCore(event) {
546
+ preprocessData(data, type) {
572
547
  const { graphCore } = this;
573
- const { nodes = [], edges = [], combos = [], } = deconstructData({
574
- nodes: this.userGraphCore.getAllNodes(),
575
- edges: this.userGraphCore.getAllEdges(),
576
- });
577
- const prevNodesAndCombos = graphCore.getAllNodes();
578
- // function to update one data in graphCore with different model type ('node' or 'edge')
579
- const syncUpdateToGraphCore = (id, newValue, oldValue, isNodeOrCombo, diff = []) => {
580
- if (isNodeOrCombo) {
581
- if (newValue.data)
582
- graphCore.updateNodeData(id, Object.assign({}, newValue.data));
583
- }
584
- else {
585
- if (diff.includes('data'))
586
- graphCore.updateEdgeData(id, Object.assign({}, newValue.data));
587
- // source and target may be changed
588
- if (diff.includes('source'))
589
- graphCore.updateEdgeSource(id, newValue.source);
590
- if (diff.includes('target'))
591
- graphCore.updateEdgeTarget(id, newValue.target);
592
- }
548
+ const dataCloned = clone(data);
549
+ const prevData = graphCore
550
+ ? deconstructData({
551
+ nodes: graphCore.getAllNodes(),
552
+ edges: graphCore.getAllEdges(),
553
+ })
554
+ : {};
555
+ const { prevMinusNew, newMinusPrev, intersectionOfPrevAndNew } = diffGraphData(prevData, dataCloned);
556
+ const dataChangeMap = {
557
+ replace: { dataAdded: dataCloned, dataUpdated: {}, dataRemoved: {} },
558
+ mergeReplace: {
559
+ dataAdded: newMinusPrev,
560
+ dataUpdated: intersectionOfPrevAndNew,
561
+ dataRemoved: prevMinusNew,
562
+ },
563
+ union: {
564
+ dataAdded: newMinusPrev,
565
+ dataUpdated: intersectionOfPrevAndNew,
566
+ dataRemoved: {},
567
+ },
568
+ remove: {
569
+ dataAdded: {},
570
+ dataUpdated: {},
571
+ dataRemoved: intersectionOfPrevAndNew,
572
+ },
573
+ update: {
574
+ dataAdded: {},
575
+ dataUpdated: intersectionOfPrevAndNew,
576
+ dataRemoved: {},
577
+ },
593
578
  };
594
- graphCore.batch(() => {
595
- // === step 3: sync to graphCore according to the changes in userGraphCore ==
596
- const newModelMap = {};
597
- const parentMap = {};
598
- const changeMap = {};
599
- const treeChanges = [];
600
- event.changes.forEach((change) => {
601
- var _a;
602
- const id = change.id || ((_a = change.value) === null || _a === void 0 ? void 0 : _a.id);
603
- if (id !== undefined) {
604
- changeMap[id] = true;
605
- return;
606
- }
607
- if ([
608
- 'TreeStructureAttached',
609
- 'TreeStructureChanged',
610
- 'TreeStructureChanged',
611
- ].includes(change.type)) {
612
- treeChanges.push(change);
613
- }
614
- });
615
- nodes.forEach((model) => {
616
- newModelMap[model.id] = { type: 'node', model };
617
- if (model.data.hasOwnProperty('parentId')) {
618
- parentMap[model.id] = {
619
- new: model.data.parentId,
620
- old: undefined,
621
- };
622
- }
623
- });
624
- edges.forEach((model) => (newModelMap[model.id] = { type: 'edge', model }));
625
- combos.forEach((model) => {
626
- newModelMap[model.id] = { type: 'combo', model };
627
- if (model.data.hasOwnProperty('parentId')) {
628
- parentMap[model.id] = {
629
- new: model.data.parentId,
630
- old: undefined,
631
- };
632
- }
633
- });
634
- prevNodesAndCombos.forEach((prevModel) => {
635
- var _a, _b;
636
- const { id } = prevModel;
637
- if (((_a = parentMap[id]) === null || _a === void 0 ? void 0 : _a.new) !== undefined ||
638
- prevModel.data.parentId !== undefined) {
639
- parentMap[id] = {
640
- new: (_b = parentMap[id]) === null || _b === void 0 ? void 0 : _b.new,
641
- old: prevModel.data.parentId,
642
- };
643
- }
644
- else {
645
- delete parentMap[id];
646
- }
647
- const { model: newModel } = newModelMap[id] || {};
648
- // remove
649
- if (!newModel) {
650
- // remove a combo, put the children to upper parent
651
- if (prevModel.data._isCombo) {
652
- graphCore.getChildren(id, 'combo').forEach((child) => {
653
- parentMap[child.id] = Object.assign(Object.assign({}, parentMap[child.id]), { new: prevModel.data.parentId });
654
- });
655
- }
656
- // if it has combo parent, remove it from the parent's children list
657
- if (prevModel.data.parentId) {
658
- graphCore.setParent(id, undefined, 'combo');
659
- }
660
- // for tree graph view, show the succeed nodes and edges
661
- const succeedIds = [];
662
- if (graphCore.hasTreeStructure('tree')) {
663
- graphCore.dfsTree(id, (child) => {
664
- succeedIds.push(child.id);
665
- }, 'tree');
666
- const succeedEdgeIds = graphCore
667
- .getAllEdges()
668
- .filter(({ source, target }) => succeedIds.includes(source) && succeedIds.includes(target))
669
- .map((edge) => edge.id);
670
- this.graph.showItem(succeedIds
671
- .filter((succeedId) => succeedId !== id)
672
- .concat(succeedEdgeIds));
673
- // for tree graph view, remove the node from the parent's children list
674
- graphCore.setParent(id, undefined, 'tree');
675
- // for tree graph view, make the its children to be roots
676
- graphCore
677
- .getChildren(id, 'tree')
678
- .forEach((child) => graphCore.setParent(child.id, undefined, 'tree'));
679
- }
680
- // remove the node data
681
- graphCore.removeNode(id);
682
- delete parentMap[prevModel.id];
683
- }
684
- // update
685
- // || diffAt(newModel, prevModel, true)?.length
686
- else if (changeMap[id])
687
- syncUpdateToGraphCore(id, newModel, prevModel, true);
688
- // delete from the map indicates this model is visited
689
- delete newModelMap[id];
690
- });
691
- graphCore.getAllEdges().forEach((prevEdge) => {
692
- const { id } = prevEdge;
693
- const { model: newModel } = newModelMap[id] || {};
694
- // remove
695
- if (!newModel)
696
- graphCore.removeEdge(id);
697
- // update
698
- else {
699
- const diff = diffAt(newModel, prevEdge, false);
700
- if (diff === null || diff === void 0 ? void 0 : diff.length)
701
- syncUpdateToGraphCore(id, newModel, prevEdge, false, diff);
702
- }
703
- // delete from the map indicates this model is visited
704
- delete newModelMap[id];
705
- });
706
- // add
707
- Object.values(newModelMap).forEach(({ type, model }) => {
708
- if (type === 'node' || type === 'combo')
709
- graphCore.addNode(model);
710
- else if (type === 'edge')
711
- graphCore.addEdge(model);
712
- });
713
- // update parents after adding all items
714
- Object.keys(parentMap).forEach((id) => {
715
- var _a;
716
- if (parentMap[id].new === parentMap[id].old)
717
- return;
718
- if (!validateComboStrucutre(this.graph, id, parentMap[id].new)) {
719
- graphCore.mergeNodeData(id, { parentId: parentMap[id].old });
720
- return;
721
- }
722
- graphCore.mergeNodeData(id, { parentId: parentMap[id].new });
723
- graphCore.setParent(id, parentMap[id].new, 'combo');
724
- // after remove from parent's children list, check whether the parent is empty
725
- // if so, update parent's position to be the child's
726
- if (parentMap[id].old !== undefined) {
727
- const parentChildren = graphCore.getChildren(parentMap[id].old, 'combo');
728
- const { x = 0, y = 0, z = 0, } = ((_a = this.graph.getDisplayModel(parentMap[id].old)) === null || _a === void 0 ? void 0 : _a.data) || {};
729
- if (!parentChildren.length) {
730
- graphCore.mergeNodeData(parentMap[id].old, {
731
- x: convertToNumber(x),
732
- y: convertToNumber(y),
733
- z: convertToNumber(z),
734
- });
735
- }
736
- }
737
- });
738
- // update tree structure
739
- treeChanges.forEach((change) => {
740
- const { type, treeKey, nodeId, newParentId } = change;
741
- if (type === 'TreeStructureAttached') {
742
- graphCore.attachTreeStructure(treeKey);
743
- return;
744
- }
745
- else if (type === 'TreeStructureChanged') {
746
- graphCore.setParent(nodeId, newParentId, treeKey);
747
- return;
748
- }
749
- else if (type === 'TreeStructureDetached') {
750
- graphCore.detachTreeStructure(treeKey);
751
- return;
752
- }
753
- });
754
- });
579
+ return dataChangeMap[type];
755
580
  }
756
581
  /**
757
- * Clone data from userGraphCore, and run transforms
582
+ * run transforms on preprocessed data
758
583
  * @returns transformed data and the id map list
759
584
  */
760
- transformData(data) {
761
- let dataCloned = clone(data);
585
+ transformData(data, changeType) {
762
586
  // transform the data with transform extensions, output innerData and idMaps ===
763
587
  this.extensions.forEach(({ func, config }) => {
764
- dataCloned = func(dataCloned, config, this.userGraphCore);
588
+ if (this.isTransformActive(config, changeType)) {
589
+ data = func(data, config, this.graphCore);
590
+ }
765
591
  });
766
- return dataCloned;
592
+ return data;
767
593
  }
768
594
  /**
769
595
  * convert and store tree structure to graphCore
@@ -771,12 +597,12 @@ export class DataController {
771
597
  * @param data
772
598
  */
773
599
  updateTreeGraph(dataType, data) {
774
- this.userGraphCore.attachTreeStructure('tree');
600
+ this.graphCore.attachTreeStructure('tree');
775
601
  if (dataType === 'treeData') {
776
602
  // tree structure storing
777
603
  data.edges.forEach((edge) => {
778
604
  const { source, target } = edge;
779
- this.userGraphCore.setParent(target, source, 'tree');
605
+ this.graphCore.setParent(target, source, 'tree');
780
606
  });
781
607
  }
782
608
  else {
@@ -875,4 +701,46 @@ const mergeOneLevelData = (prevModel, newModel) => {
875
701
  });
876
702
  return mergedData;
877
703
  };
704
+ /**
705
+ * Generate the difference between two model list
706
+ * @param prevModels
707
+ * @param newModels
708
+ * @returns
709
+ */
710
+ const diffData = (prevModels = [], newModels = []) => {
711
+ const prevIds = new Set(prevModels === null || prevModels === void 0 ? void 0 : prevModels.map((item) => item.id));
712
+ const newIds = new Set(newModels === null || newModels === void 0 ? void 0 : newModels.map((item) => item.id));
713
+ return {
714
+ prevMinusNew: prevModels === null || prevModels === void 0 ? void 0 : prevModels.filter((item) => !newIds.has(item.id)),
715
+ newMinusPrev: newModels === null || newModels === void 0 ? void 0 : newModels.filter((item) => !prevIds.has(item.id)),
716
+ intersectionOfPrevAndNew: newModels === null || newModels === void 0 ? void 0 : newModels.filter((item) => prevIds.has(item.id)),
717
+ };
718
+ };
719
+ /**
720
+ * Compute the difference between two graph data structure.
721
+ * @param prevData
722
+ * @param newData
723
+ * @returns
724
+ */
725
+ const diffGraphData = (prevData, newData) => {
726
+ const result = {
727
+ newMinusPrev: { nodes: [], edges: [], combos: [] },
728
+ prevMinusNew: { nodes: [], edges: [], combos: [] },
729
+ intersectionOfPrevAndNew: { nodes: [], edges: [], combos: [] },
730
+ };
731
+ ['nodes', 'edges', 'combos'].forEach((key) => {
732
+ const diff = diffData(prevData[key], newData[key]);
733
+ result.newMinusPrev[key] = diff.newMinusPrev;
734
+ result.prevMinusNew[key] = diff.prevMinusNew;
735
+ result.intersectionOfPrevAndNew[key] = diff.intersectionOfPrevAndNew;
736
+ });
737
+ return result;
738
+ };
739
+ const getNodesAndCombos = (data) => {
740
+ const { nodes = [], combos = [] } = data;
741
+ return nodes.concat(combos.map((combo) => ({
742
+ id: combo.id,
743
+ data: Object.assign(Object.assign({}, combo.data), { _isCombo: true }),
744
+ })));
745
+ };
878
746
  //# sourceMappingURL=data.js.map