@antv/g6 5.0.0-beta.4 → 5.0.0-beta.6

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 (246) hide show
  1. package/dist/g6.min.js +2 -2
  2. package/esm/index.d.ts +15 -1
  3. package/esm/index.js +1 -1
  4. package/esm/item/combo.d.ts +1 -1
  5. package/esm/item/combo.js +16 -9
  6. package/esm/item/combo.js.map +1 -1
  7. package/esm/item/edge.d.ts +2 -1
  8. package/esm/item/edge.js +18 -8
  9. package/esm/item/edge.js.map +1 -1
  10. package/esm/item/item.d.ts +3 -2
  11. package/esm/item/item.js +12 -6
  12. package/esm/item/item.js.map +1 -1
  13. package/esm/item/node.d.ts +2 -1
  14. package/esm/item/node.js +19 -10
  15. package/esm/item/node.js.map +1 -1
  16. package/esm/runtime/controller/item.d.ts +1 -0
  17. package/esm/runtime/controller/item.js +271 -151
  18. package/esm/runtime/controller/item.js.map +1 -1
  19. package/esm/runtime/graph.d.ts +98 -18
  20. package/esm/runtime/graph.js +427 -75
  21. package/esm/runtime/graph.js.map +1 -1
  22. package/esm/stdlib/behavior/activate-relations.js +2 -2
  23. package/esm/stdlib/behavior/activate-relations.js.map +1 -1
  24. package/esm/stdlib/behavior/brush-select.js +1 -2
  25. package/esm/stdlib/behavior/brush-select.js.map +1 -1
  26. package/esm/stdlib/behavior/click-select.js +1 -1
  27. package/esm/stdlib/behavior/click-select.js.map +1 -1
  28. package/esm/stdlib/behavior/create-edge.d.ts +57 -0
  29. package/esm/stdlib/behavior/create-edge.js +206 -0
  30. package/esm/stdlib/behavior/create-edge.js.map +1 -0
  31. package/esm/stdlib/behavior/drag-canvas.d.ts +1 -1
  32. package/esm/stdlib/behavior/drag-canvas.js +51 -28
  33. package/esm/stdlib/behavior/drag-canvas.js.map +1 -1
  34. package/esm/stdlib/behavior/drag-combo.d.ts +2 -2
  35. package/esm/stdlib/behavior/drag-combo.js +43 -32
  36. package/esm/stdlib/behavior/drag-combo.js.map +1 -1
  37. package/esm/stdlib/behavior/drag-node.d.ts +3 -3
  38. package/esm/stdlib/behavior/drag-node.js +76 -63
  39. package/esm/stdlib/behavior/drag-node.js.map +1 -1
  40. package/esm/stdlib/behavior/index.d.ts +2 -0
  41. package/esm/stdlib/behavior/index.js +2 -0
  42. package/esm/stdlib/behavior/index.js.map +1 -1
  43. package/esm/stdlib/behavior/lasso-select.d.ts +1 -1
  44. package/esm/stdlib/behavior/lasso-select.js +1 -2
  45. package/esm/stdlib/behavior/lasso-select.js.map +1 -1
  46. package/esm/stdlib/behavior/scroll-canvas.d.ts +67 -0
  47. package/esm/stdlib/behavior/scroll-canvas.js +266 -0
  48. package/esm/stdlib/behavior/scroll-canvas.js.map +1 -0
  49. package/esm/stdlib/behavior/zoom-canvas.d.ts +1 -1
  50. package/esm/stdlib/behavior/zoom-canvas.js +47 -24
  51. package/esm/stdlib/behavior/zoom-canvas.js.map +1 -1
  52. package/esm/stdlib/index.d.ts +6 -0
  53. package/esm/stdlib/index.js +15 -9
  54. package/esm/stdlib/index.js.map +1 -1
  55. package/esm/stdlib/item/edge/base.d.ts +1 -1
  56. package/esm/stdlib/item/edge/base.js +13 -4
  57. package/esm/stdlib/item/edge/base.js.map +1 -1
  58. package/esm/stdlib/item/node/base.d.ts +1 -1
  59. package/esm/stdlib/item/node/base.js +11 -12
  60. package/esm/stdlib/item/node/base.js.map +1 -1
  61. package/esm/stdlib/item/node/image.d.ts +1 -1
  62. package/esm/stdlib/item/node/image.js +1 -1
  63. package/esm/stdlib/item/node/image.js.map +1 -1
  64. package/esm/stdlib/plugin/history/combo-command.js +2 -2
  65. package/esm/stdlib/plugin/history/combo-command.js.map +1 -1
  66. package/esm/stdlib/plugin/history/index.d.ts +10 -10
  67. package/esm/stdlib/plugin/history/index.js +14 -14
  68. package/esm/stdlib/plugin/history/index.js.map +1 -1
  69. package/esm/stdlib/plugin/history/item-data-command.js +4 -4
  70. package/esm/stdlib/plugin/history/item-data-command.js.map +1 -1
  71. package/esm/stdlib/plugin/history/layer-updated-command.js +2 -2
  72. package/esm/stdlib/plugin/history/layer-updated-command.js.map +1 -1
  73. package/esm/stdlib/plugin/history/state-updated-command.js +1 -1
  74. package/esm/stdlib/plugin/history/state-updated-command.js.map +1 -1
  75. package/esm/stdlib/plugin/history/visibility-updated-command.js +2 -2
  76. package/esm/stdlib/plugin/history/visibility-updated-command.js.map +1 -1
  77. package/esm/stdlib/plugin/hull/hullComponent.d.ts +1 -1
  78. package/esm/stdlib/plugin/hull/hullComponent.js +3 -6
  79. package/esm/stdlib/plugin/hull/hullComponent.js.map +1 -1
  80. package/esm/stdlib/plugin/index.d.ts +1 -0
  81. package/esm/stdlib/plugin/index.js +1 -0
  82. package/esm/stdlib/plugin/index.js.map +1 -1
  83. package/esm/stdlib/plugin/minimap/index.d.ts +5 -1
  84. package/esm/stdlib/plugin/minimap/index.js +109 -8
  85. package/esm/stdlib/plugin/minimap/index.js.map +1 -1
  86. package/esm/stdlib/plugin/snapline/index.d.ts +163 -0
  87. package/esm/stdlib/plugin/snapline/index.js +1052 -0
  88. package/esm/stdlib/plugin/snapline/index.js.map +1 -0
  89. package/esm/stdlib/plugin/types.d.ts +1 -0
  90. package/esm/types/graph.d.ts +45 -19
  91. package/esm/types/hook.d.ts +22 -2
  92. package/esm/types/spec.d.ts +19 -3
  93. package/esm/util/bbox.d.ts +16 -1
  94. package/esm/util/bbox.js +29 -0
  95. package/esm/util/bbox.js.map +1 -1
  96. package/esm/util/item.d.ts +16 -1
  97. package/esm/util/item.js +31 -8
  98. package/esm/util/item.js.map +1 -1
  99. package/esm/util/shape.js +2 -2
  100. package/esm/util/shape.js.map +1 -1
  101. package/esm/util/warn.d.ts +14 -0
  102. package/esm/util/warn.js +4 -0
  103. package/esm/util/warn.js.map +1 -0
  104. package/lib/index.d.ts +15 -1
  105. package/lib/index.js +1 -1
  106. package/lib/item/combo.d.ts +1 -1
  107. package/lib/item/combo.js +16 -9
  108. package/lib/item/combo.js.map +1 -1
  109. package/lib/item/edge.d.ts +2 -1
  110. package/lib/item/edge.js +18 -8
  111. package/lib/item/edge.js.map +1 -1
  112. package/lib/item/item.d.ts +3 -2
  113. package/lib/item/item.js +12 -6
  114. package/lib/item/item.js.map +1 -1
  115. package/lib/item/node.d.ts +2 -1
  116. package/lib/item/node.js +19 -10
  117. package/lib/item/node.js.map +1 -1
  118. package/lib/runtime/controller/item.d.ts +1 -0
  119. package/lib/runtime/controller/item.js +270 -150
  120. package/lib/runtime/controller/item.js.map +1 -1
  121. package/lib/runtime/graph.d.ts +98 -18
  122. package/lib/runtime/graph.js +427 -75
  123. package/lib/runtime/graph.js.map +1 -1
  124. package/lib/stdlib/behavior/activate-relations.js +2 -2
  125. package/lib/stdlib/behavior/activate-relations.js.map +1 -1
  126. package/lib/stdlib/behavior/brush-select.js +1 -2
  127. package/lib/stdlib/behavior/brush-select.js.map +1 -1
  128. package/lib/stdlib/behavior/click-select.js +1 -1
  129. package/lib/stdlib/behavior/click-select.js.map +1 -1
  130. package/lib/stdlib/behavior/create-edge.d.ts +57 -0
  131. package/lib/stdlib/behavior/create-edge.js +210 -0
  132. package/lib/stdlib/behavior/create-edge.js.map +1 -0
  133. package/lib/stdlib/behavior/drag-canvas.d.ts +1 -1
  134. package/lib/stdlib/behavior/drag-canvas.js +51 -28
  135. package/lib/stdlib/behavior/drag-canvas.js.map +1 -1
  136. package/lib/stdlib/behavior/drag-combo.d.ts +2 -2
  137. package/lib/stdlib/behavior/drag-combo.js +43 -32
  138. package/lib/stdlib/behavior/drag-combo.js.map +1 -1
  139. package/lib/stdlib/behavior/drag-node.d.ts +3 -3
  140. package/lib/stdlib/behavior/drag-node.js +76 -63
  141. package/lib/stdlib/behavior/drag-node.js.map +1 -1
  142. package/lib/stdlib/behavior/index.d.ts +2 -0
  143. package/lib/stdlib/behavior/index.js +2 -0
  144. package/lib/stdlib/behavior/index.js.map +1 -1
  145. package/lib/stdlib/behavior/lasso-select.d.ts +1 -1
  146. package/lib/stdlib/behavior/lasso-select.js +1 -2
  147. package/lib/stdlib/behavior/lasso-select.js.map +1 -1
  148. package/lib/stdlib/behavior/scroll-canvas.d.ts +67 -0
  149. package/lib/stdlib/behavior/scroll-canvas.js +270 -0
  150. package/lib/stdlib/behavior/scroll-canvas.js.map +1 -0
  151. package/lib/stdlib/behavior/zoom-canvas.d.ts +1 -1
  152. package/lib/stdlib/behavior/zoom-canvas.js +47 -24
  153. package/lib/stdlib/behavior/zoom-canvas.js.map +1 -1
  154. package/lib/stdlib/index.d.ts +6 -0
  155. package/lib/stdlib/index.js +15 -9
  156. package/lib/stdlib/index.js.map +1 -1
  157. package/lib/stdlib/item/edge/base.d.ts +1 -1
  158. package/lib/stdlib/item/edge/base.js +13 -4
  159. package/lib/stdlib/item/edge/base.js.map +1 -1
  160. package/lib/stdlib/item/node/base.d.ts +1 -1
  161. package/lib/stdlib/item/node/base.js +11 -12
  162. package/lib/stdlib/item/node/base.js.map +1 -1
  163. package/lib/stdlib/item/node/image.d.ts +1 -1
  164. package/lib/stdlib/item/node/image.js +1 -1
  165. package/lib/stdlib/item/node/image.js.map +1 -1
  166. package/lib/stdlib/plugin/history/combo-command.js +2 -2
  167. package/lib/stdlib/plugin/history/combo-command.js.map +1 -1
  168. package/lib/stdlib/plugin/history/index.d.ts +10 -10
  169. package/lib/stdlib/plugin/history/index.js +14 -14
  170. package/lib/stdlib/plugin/history/index.js.map +1 -1
  171. package/lib/stdlib/plugin/history/item-data-command.js +4 -4
  172. package/lib/stdlib/plugin/history/item-data-command.js.map +1 -1
  173. package/lib/stdlib/plugin/history/layer-updated-command.js +2 -2
  174. package/lib/stdlib/plugin/history/layer-updated-command.js.map +1 -1
  175. package/lib/stdlib/plugin/history/state-updated-command.js +1 -1
  176. package/lib/stdlib/plugin/history/state-updated-command.js.map +1 -1
  177. package/lib/stdlib/plugin/history/visibility-updated-command.js +2 -2
  178. package/lib/stdlib/plugin/history/visibility-updated-command.js.map +1 -1
  179. package/lib/stdlib/plugin/hull/hullComponent.d.ts +1 -1
  180. package/lib/stdlib/plugin/hull/hullComponent.js +3 -6
  181. package/lib/stdlib/plugin/hull/hullComponent.js.map +1 -1
  182. package/lib/stdlib/plugin/index.d.ts +1 -0
  183. package/lib/stdlib/plugin/index.js +1 -0
  184. package/lib/stdlib/plugin/index.js.map +1 -1
  185. package/lib/stdlib/plugin/minimap/index.d.ts +5 -1
  186. package/lib/stdlib/plugin/minimap/index.js +109 -8
  187. package/lib/stdlib/plugin/minimap/index.js.map +1 -1
  188. package/lib/stdlib/plugin/snapline/index.d.ts +163 -0
  189. package/lib/stdlib/plugin/snapline/index.js +1056 -0
  190. package/lib/stdlib/plugin/snapline/index.js.map +1 -0
  191. package/lib/stdlib/plugin/types.d.ts +1 -0
  192. package/lib/types/graph.d.ts +45 -19
  193. package/lib/types/hook.d.ts +22 -2
  194. package/lib/types/spec.d.ts +19 -3
  195. package/lib/util/bbox.d.ts +16 -1
  196. package/lib/util/bbox.js +32 -1
  197. package/lib/util/bbox.js.map +1 -1
  198. package/lib/util/item.d.ts +16 -1
  199. package/lib/util/item.js +33 -9
  200. package/lib/util/item.js.map +1 -1
  201. package/lib/util/shape.js +2 -2
  202. package/lib/util/shape.js.map +1 -1
  203. package/lib/util/warn.d.ts +14 -0
  204. package/lib/util/warn.js +8 -0
  205. package/lib/util/warn.js.map +1 -0
  206. package/package.json +2 -2
  207. package/src/index.ts +1 -1
  208. package/src/item/combo.ts +14 -9
  209. package/src/item/edge.ts +17 -8
  210. package/src/item/item.ts +11 -6
  211. package/src/item/node.ts +24 -16
  212. package/src/runtime/controller/item.ts +240 -72
  213. package/src/runtime/graph.ts +536 -80
  214. package/src/stdlib/behavior/activate-relations.ts +2 -2
  215. package/src/stdlib/behavior/brush-select.ts +4 -2
  216. package/src/stdlib/behavior/click-select.ts +1 -1
  217. package/src/stdlib/behavior/create-edge.ts +295 -0
  218. package/src/stdlib/behavior/drag-canvas.ts +67 -29
  219. package/src/stdlib/behavior/drag-combo.ts +10 -10
  220. package/src/stdlib/behavior/drag-node.ts +18 -18
  221. package/src/stdlib/behavior/index.ts +2 -0
  222. package/src/stdlib/behavior/lasso-select.ts +5 -3
  223. package/src/stdlib/behavior/scroll-canvas.ts +348 -0
  224. package/src/stdlib/behavior/zoom-canvas.ts +61 -25
  225. package/src/stdlib/index.ts +16 -7
  226. package/src/stdlib/item/edge/base.ts +13 -5
  227. package/src/stdlib/item/node/base.ts +15 -14
  228. package/src/stdlib/item/node/image.ts +1 -1
  229. package/src/stdlib/plugin/history/combo-command.ts +2 -2
  230. package/src/stdlib/plugin/history/index.ts +14 -14
  231. package/src/stdlib/plugin/history/item-data-command.ts +4 -4
  232. package/src/stdlib/plugin/history/layer-updated-command.ts +2 -2
  233. package/src/stdlib/plugin/history/state-updated-command.ts +1 -1
  234. package/src/stdlib/plugin/history/visibility-updated-command.ts +2 -2
  235. package/src/stdlib/plugin/hull/hullComponent.ts +8 -5
  236. package/src/stdlib/plugin/index.ts +1 -0
  237. package/src/stdlib/plugin/minimap/index.ts +113 -9
  238. package/src/stdlib/plugin/snapline/index.ts +1277 -0
  239. package/src/stdlib/plugin/types.ts +1 -0
  240. package/src/types/graph.ts +53 -22
  241. package/src/types/hook.ts +22 -2
  242. package/src/types/spec.ts +22 -3
  243. package/src/util/bbox.ts +38 -1
  244. package/src/util/item.ts +65 -28
  245. package/src/util/shape.ts +2 -2
  246. package/src/util/warn.ts +20 -0
@@ -24,7 +24,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  const event_emitter_1 = __importDefault(require("@antv/event-emitter"));
27
+ const g_1 = require("@antv/g");
27
28
  const util_1 = require("@antv/util");
29
+ const dom_util_1 = require("@antv/dom-util");
28
30
  const canvas_1 = require("../util/canvas");
29
31
  const shape_1 = require("../util/shape");
30
32
  const controller_1 = require("./controller");
@@ -44,17 +46,17 @@ class Graph extends event_emitter_1.default {
44
46
  * Execute a callback without allowing any stacking operations.
45
47
  * @param callback
46
48
  */
47
- this.executeWithoutStacking = (callback) => {
49
+ this.executeWithNoStack = (callback) => {
48
50
  const history = this.getHistoryPlugin();
49
- history === null || history === void 0 ? void 0 : history.pauseStacking();
51
+ history === null || history === void 0 ? void 0 : history.pauseStack();
50
52
  try {
51
53
  callback();
52
54
  }
53
55
  finally {
54
- history === null || history === void 0 ? void 0 : history.resumeStacking();
56
+ history === null || history === void 0 ? void 0 : history.resumeStack();
55
57
  }
56
58
  };
57
- this.specification = Object.assign({}, this.defaultSpecification, spec);
59
+ this.specification = Object.assign({}, this.defaultSpecification, this.formatSpecification(spec));
58
60
  this.initHooks();
59
61
  this.initCanvas();
60
62
  this.initControllers();
@@ -198,16 +200,22 @@ class Graph extends event_emitter_1.default {
198
200
  }),
199
201
  transientupdate: new hooks_1.default({ name: 'transientupdate' }),
200
202
  pluginchange: new hooks_1.default({ name: 'pluginchange' }),
201
- themechange: new hooks_1.default({ name: 'init' }),
203
+ themechange: new hooks_1.default({ name: 'themechange' }),
204
+ mapperchange: new hooks_1.default({ name: 'mapperchange' }),
202
205
  treecollapseexpand: new hooks_1.default({ name: 'treecollapseexpand' }),
203
206
  destroy: new hooks_1.default({ name: 'destroy' }),
204
207
  };
205
208
  }
209
+ formatSpecification(spec) {
210
+ return Object.assign(Object.assign({}, spec), { optimize: Object.assign({ tileBehavior: 2000, tileBehaviorSize: 1000, tileFirstRender: 10000, tileFirstRenderSize: 1000 }, spec.optimize) });
211
+ }
206
212
  /**
207
213
  * Update the specs(configurations).
208
214
  */
209
215
  updateSpecification(spec) {
210
- return Object.assign(this.specification, spec);
216
+ const newSpec = Object.assign(this.specification, this.formatSpecification(spec));
217
+ // TODO: update something
218
+ return newSpec;
211
219
  }
212
220
  /**
213
221
  * Update the theme specs (configurations).
@@ -228,6 +236,28 @@ class Graph extends event_emitter_1.default {
228
236
  theme: this.themeController.specification,
229
237
  });
230
238
  }
239
+ /**
240
+ * Update the item display mapper for a specific item type.
241
+ * @param {ITEM_TYPE} type - The type of item (node, edge, or combo).
242
+ * @param {NodeMapper | EdgeMapper | ComboMapper} mapper - The mapper to be updated.
243
+ * */
244
+ updateMapper(type, mapper) {
245
+ switch (type) {
246
+ case 'node':
247
+ this.specification.node = mapper;
248
+ break;
249
+ case 'edge':
250
+ this.specification.edge = mapper;
251
+ break;
252
+ case 'combo':
253
+ this.specification.combo = mapper;
254
+ break;
255
+ }
256
+ this.hooks.mapperchange.emit({
257
+ type,
258
+ mapper,
259
+ });
260
+ }
231
261
  /**
232
262
  * Get the copy of specs(configurations).
233
263
  * @returns graph specs
@@ -244,12 +274,17 @@ class Graph extends event_emitter_1.default {
244
274
  */
245
275
  read(data) {
246
276
  return __awaiter(this, void 0, void 0, function* () {
277
+ const { tileFirstRender, tileFirstRenderSize } = this.specification.optimize || {};
247
278
  this.hooks.datachange.emit({ data, type: 'replace' });
248
279
  const emitRender = () => __awaiter(this, void 0, void 0, function* () {
249
- this.hooks.render.emit({
280
+ yield this.hooks.render.emitLinearAsync({
250
281
  graphCore: this.dataController.graphCore,
251
282
  theme: this.themeController.specification,
252
283
  transientCanvas: this.transientCanvas,
284
+ tileOptimize: {
285
+ tileFirstRender,
286
+ tileFirstRenderSize,
287
+ },
253
288
  });
254
289
  this.emit('afterrender');
255
290
  this.once('afterlayout', () => __awaiter(this, void 0, void 0, function* () {
@@ -296,11 +331,16 @@ class Graph extends event_emitter_1.default {
296
331
  */
297
332
  changeData(data, type = 'mergeReplace') {
298
333
  return __awaiter(this, void 0, void 0, function* () {
334
+ const { tileFirstRender, tileFirstRenderSize } = this.specification.optimize || {};
299
335
  this.hooks.datachange.emit({ data, type });
300
336
  this.hooks.render.emit({
301
337
  graphCore: this.dataController.graphCore,
302
338
  theme: this.themeController.specification,
303
339
  transientCanvas: this.transientCanvas,
340
+ tileOptimize: {
341
+ tileFirstRender,
342
+ tileFirstRenderSize,
343
+ },
304
344
  });
305
345
  this.emit('afterrender');
306
346
  yield this.layout();
@@ -311,11 +351,11 @@ class Graph extends event_emitter_1.default {
311
351
  * @returns
312
352
  */
313
353
  clear() {
314
- this.startBatch();
354
+ this.startHistoryBatch();
315
355
  this.removeData('edge', this.getAllEdgesData().map((edge) => edge.id));
316
356
  this.removeData('node', this.getAllNodesData().map((node) => node.id));
317
357
  this.removeData('combo', this.getAllCombosData().map((combo) => combo.id));
318
- this.stopBatch();
358
+ this.stopHistoryBatch();
319
359
  }
320
360
  getViewportCenter() {
321
361
  const { width, height } = this.canvas.getConfig();
@@ -323,9 +363,11 @@ class Graph extends event_emitter_1.default {
323
363
  }
324
364
  transform(options, effectTiming) {
325
365
  return __awaiter(this, void 0, void 0, function* () {
366
+ const { tileLodSize } = this.specification.optimize || {};
326
367
  yield this.hooks.viewportchange.emitLinearAsync({
327
368
  transform: options,
328
369
  effectTiming,
370
+ tileLodSize,
329
371
  });
330
372
  this.emit('viewportchange', options);
331
373
  });
@@ -544,6 +586,25 @@ class Graph extends event_emitter_1.default {
544
586
  this.specification.height = size[1];
545
587
  this.canvas.resize(size[0], size[1]);
546
588
  }
589
+ getCanvasRange() {
590
+ const [width, height] = this.getSize();
591
+ const leftTop = this.getCanvasByViewport({ x: 0, y: 0 });
592
+ const rightBottom = this.getCanvasByViewport({ x: width, y: height });
593
+ return {
594
+ min: [leftTop.x, leftTop.y, leftTop.z],
595
+ max: [rightBottom.x, rightBottom.y, rightBottom.z],
596
+ center: [
597
+ (leftTop.x + rightBottom.x) / 2,
598
+ (leftTop.y + rightBottom.y) / 2,
599
+ (leftTop.z + rightBottom.z) / 2,
600
+ ],
601
+ halfExtents: [
602
+ (rightBottom.x - leftTop.x) / 2,
603
+ (rightBottom.y - leftTop.y) / 2,
604
+ (rightBottom.z - leftTop.z) / 2,
605
+ ],
606
+ };
607
+ }
547
608
  /**
548
609
  * Get the rendering coordinate according to the canvas dom (viewport) coordinate.
549
610
  * @param Point rendering coordinate
@@ -718,23 +779,26 @@ class Graph extends event_emitter_1.default {
718
779
  // data controller and item controller subscribe additem in order
719
780
  const { graphCore } = this.dataController;
720
781
  const { specification } = this.themeController;
782
+ // debugger;
721
783
  graphCore.once('changed', (event) => {
722
784
  if (!event.changes.length)
723
785
  return;
724
786
  const changes = event.changes;
725
- this.hooks.itemchange.emit({
726
- type: itemType,
727
- changes: graphCore.reduceChanges(event.changes),
728
- graphCore,
729
- theme: specification,
730
- });
731
- this.emit('afteritemchange', {
787
+ const timingParameters = {
732
788
  type: itemType,
733
789
  action: 'add',
734
790
  models,
735
791
  apiName: 'addData',
736
792
  changes,
793
+ };
794
+ this.emit('beforeitemchange', timingParameters);
795
+ this.hooks.itemchange.emit({
796
+ type: itemType,
797
+ changes: graphCore.reduceChanges(event.changes),
798
+ graphCore,
799
+ theme: specification,
737
800
  });
801
+ this.emit('afteritemchange', timingParameters);
738
802
  });
739
803
  const modelArr = (0, util_1.isArray)(models) ? models : [models];
740
804
  const data = { nodes: [], edges: [], combos: [] };
@@ -763,19 +827,21 @@ class Graph extends event_emitter_1.default {
763
827
  if (!event.changes.length)
764
828
  return;
765
829
  const changes = event.changes;
766
- this.hooks.itemchange.emit({
767
- type: itemType,
768
- changes: event.changes,
769
- graphCore,
770
- theme: specification,
771
- });
772
- this.emit('afteritemchange', {
830
+ const timingParameters = {
773
831
  type: itemType,
774
832
  action: 'remove',
775
833
  ids: idArr,
776
834
  apiName: 'removeData',
777
835
  changes,
836
+ };
837
+ this.emit('beforeitemchange', timingParameters);
838
+ this.hooks.itemchange.emit({
839
+ type: itemType,
840
+ changes: event.changes,
841
+ graphCore,
842
+ theme: specification,
778
843
  });
844
+ this.emit('afteritemchange', timingParameters);
779
845
  });
780
846
  this.hooks.datachange.emit({
781
847
  data,
@@ -843,19 +909,21 @@ class Graph extends event_emitter_1.default {
843
909
  const { specification } = this.themeController;
844
910
  graphCore.once('changed', (event) => {
845
911
  const changes = this.extendChanges((0, util_1.clone)(event.changes));
846
- this.hooks.itemchange.emit({
847
- type: itemType,
848
- changes: event.changes,
849
- graphCore,
850
- theme: specification,
851
- });
852
- this.emit('afteritemchange', {
912
+ const timingParameters = {
853
913
  type: itemType,
854
914
  action: 'update',
855
915
  models,
856
916
  apiName: 'updateData',
857
917
  changes,
918
+ };
919
+ this.emit('beforeitemchange', timingParameters);
920
+ this.hooks.itemchange.emit({
921
+ type: itemType,
922
+ changes: event.changes,
923
+ graphCore,
924
+ theme: specification,
858
925
  });
926
+ this.emit('afteritemchange', timingParameters);
859
927
  });
860
928
  this.hooks.datachange.emit({
861
929
  data,
@@ -902,6 +970,15 @@ class Graph extends event_emitter_1.default {
902
970
  if (!event.changes.length)
903
971
  return;
904
972
  const changes = event.changes.filter((change) => !(0, util_1.isEqual)(change.newValue, change.oldValue));
973
+ const timingParameters = {
974
+ type,
975
+ action: 'updatePosition',
976
+ upsertAncestors,
977
+ models,
978
+ apiName: 'updatePosition',
979
+ changes,
980
+ };
981
+ this.emit('beforeitemchange', timingParameters);
905
982
  this.hooks.itemchange.emit({
906
983
  type,
907
984
  changes: event.changes,
@@ -912,14 +989,7 @@ class Graph extends event_emitter_1.default {
912
989
  animate: !disableAnimate,
913
990
  callback,
914
991
  });
915
- this.emit('afteritemchange', {
916
- type,
917
- action: 'updatePosition',
918
- upsertAncestors,
919
- models,
920
- apiName: 'updatePosition',
921
- changes,
922
- });
992
+ this.emit('afteritemchange', timingParameters);
923
993
  });
924
994
  this.hooks.datachange.emit({
925
995
  data: {
@@ -979,7 +1049,7 @@ class Graph extends event_emitter_1.default {
979
1049
  * @returns
980
1050
  * @group Item
981
1051
  */
982
- hideItem(ids, disableAnimate = false) {
1052
+ hideItem(ids, disableAnimate = false, keepKeyShape = false) {
983
1053
  const idArr = (0, util_1.isArray)(ids) ? ids : [ids];
984
1054
  if ((0, util_1.isEmpty)(idArr))
985
1055
  return;
@@ -992,6 +1062,7 @@ class Graph extends event_emitter_1.default {
992
1062
  value: false,
993
1063
  graphCore: this.dataController.graphCore,
994
1064
  animate: !disableAnimate,
1065
+ keepKeyShape,
995
1066
  });
996
1067
  this.emit('afteritemvisibilitychange', {
997
1068
  ids,
@@ -999,6 +1070,7 @@ class Graph extends event_emitter_1.default {
999
1070
  animate: !disableAnimate,
1000
1071
  action: 'updateVisibility',
1001
1072
  apiName: 'hideItem',
1073
+ keepKeyShape,
1002
1074
  changes,
1003
1075
  });
1004
1076
  }
@@ -1166,19 +1238,21 @@ class Graph extends event_emitter_1.default {
1166
1238
  if (!event.changes.length)
1167
1239
  return;
1168
1240
  const changes = event.changes;
1169
- this.hooks.itemchange.emit({
1170
- type: 'combo',
1171
- changes: graphCore.reduceChanges(event.changes),
1172
- graphCore,
1173
- theme: specification,
1174
- });
1175
- this.emit('afteritemchange', {
1241
+ const timingParameters = {
1176
1242
  type: 'combo',
1177
1243
  action: 'add',
1178
1244
  models: [model],
1179
1245
  apiName: 'addCombo',
1180
1246
  changes,
1247
+ };
1248
+ this.emit('beforeitemchange', timingParameters);
1249
+ this.hooks.itemchange.emit({
1250
+ type: 'combo',
1251
+ changes: graphCore.reduceChanges(event.changes),
1252
+ graphCore,
1253
+ theme: specification,
1181
1254
  });
1255
+ this.emit('afteritemchange', timingParameters);
1182
1256
  });
1183
1257
  const data = {
1184
1258
  nodes: [],
@@ -1200,7 +1274,7 @@ class Graph extends event_emitter_1.default {
1200
1274
  */
1201
1275
  collapseCombo(comboIds) {
1202
1276
  const ids = (0, util_1.isArray)(comboIds) ? comboIds : [comboIds];
1203
- this.executeWithoutStacking(() => {
1277
+ this.executeWithNoStack(() => {
1204
1278
  this.updateData('combo', ids.map((id) => ({ id, data: { collapsed: true } })));
1205
1279
  });
1206
1280
  this.emit('aftercollapsecombo', {
@@ -1217,7 +1291,7 @@ class Graph extends event_emitter_1.default {
1217
1291
  */
1218
1292
  expandCombo(comboIds) {
1219
1293
  const ids = (0, util_1.isArray)(comboIds) ? comboIds : [comboIds];
1220
- this.executeWithoutStacking(() => {
1294
+ this.executeWithNoStack(() => {
1221
1295
  this.updateData('combo', ids.map((id) => ({ id, data: { collapsed: false } })));
1222
1296
  });
1223
1297
  this.emit('afterexpandcombo', {
@@ -1242,16 +1316,7 @@ class Graph extends event_emitter_1.default {
1242
1316
  if (!event.changes.length)
1243
1317
  return;
1244
1318
  const changes = this.extendChanges((0, util_1.clone)(event.changes));
1245
- this.hooks.itemchange.emit({
1246
- type: 'combo',
1247
- changes: event.changes,
1248
- graphCore,
1249
- theme: specification,
1250
- upsertAncestors,
1251
- action: 'updatePosition',
1252
- callback,
1253
- });
1254
- this.emit('afteritemchange', {
1319
+ const timingParameters = {
1255
1320
  type: 'combo',
1256
1321
  ids: idArr,
1257
1322
  dx,
@@ -1260,7 +1325,18 @@ class Graph extends event_emitter_1.default {
1260
1325
  upsertAncestors,
1261
1326
  apiName: 'moveCombo',
1262
1327
  changes,
1328
+ };
1329
+ this.emit('beforeitemchange', timingParameters);
1330
+ this.hooks.itemchange.emit({
1331
+ type: 'combo',
1332
+ changes: event.changes,
1333
+ graphCore,
1334
+ theme: specification,
1335
+ upsertAncestors,
1336
+ action: 'updatePosition',
1337
+ callback,
1263
1338
  });
1339
+ this.emit('afteritemchange', timingParameters);
1264
1340
  });
1265
1341
  this.hooks.datachange.emit({
1266
1342
  data: {
@@ -1345,6 +1421,14 @@ class Graph extends event_emitter_1.default {
1345
1421
  getMode() {
1346
1422
  return this.interactionController.getMode();
1347
1423
  }
1424
+ /**
1425
+ * Set the cursor. But the cursor in item's style has higher priority.
1426
+ * @param cursor
1427
+ */
1428
+ setCursor(cursor) {
1429
+ this.canvas.setCursor(cursor);
1430
+ this.transientCanvas.setCursor(cursor);
1431
+ }
1348
1432
  /**
1349
1433
  * Add behavior(s) to mode(s).
1350
1434
  * @param behaviors behavior names or configs
@@ -1515,6 +1599,274 @@ class Graph extends event_emitter_1.default {
1515
1599
  });
1516
1600
  return this.itemController.getTransient(String(id));
1517
1601
  }
1602
+ // ===== download operations =====
1603
+ /**
1604
+ * Asynchronously generates a Data URL representation of the canvas content, including
1605
+ * background, main content, and transient canvas.
1606
+ * @param The type of the Data URL (e.g., 'image/png', 'image/jpeg').
1607
+ * @returns A Promise that resolves to the Data URL string.
1608
+ */
1609
+ toDataURL(type) {
1610
+ return __awaiter(this, void 0, void 0, function* () {
1611
+ const backgroundCanvas = this.backgroundCanvas;
1612
+ const canvas = this.canvas;
1613
+ const transientCanvas = this.transientCanvas;
1614
+ const rendererType = this.rendererType;
1615
+ const pixelRatio = typeof window !== 'undefined' ? window.devicePixelRatio : 1;
1616
+ const width = this.getSize()[0];
1617
+ const height = this.getSize()[1];
1618
+ const vContainerDOM = (0, dom_util_1.createDom)('<div id="virtual-image"></div>');
1619
+ const vCanvas = (0, canvas_1.createCanvas)(rendererType, vContainerDOM, width, height, pixelRatio);
1620
+ const vCanvasContextService = vCanvas.getContextService();
1621
+ let bgRect;
1622
+ if (rendererType !== 'svg') {
1623
+ bgRect = new g_1.Rect({
1624
+ style: {
1625
+ x: 0,
1626
+ y: 0,
1627
+ z: -1,
1628
+ width: vCanvasContextService.getDomElement().width,
1629
+ height: vCanvasContextService.getDomElement().height,
1630
+ //@ts-ignore
1631
+ fill: backgroundCanvas.getContextService().getDomElement().style['background-color'],
1632
+ },
1633
+ });
1634
+ vCanvas.appendChild(bgRect);
1635
+ }
1636
+ const backgroundClonedGroup = backgroundCanvas.getRoot().cloneNode(true);
1637
+ const clonedGroup = canvas.getRoot().cloneNode(true);
1638
+ const transientClonedGroup = transientCanvas.getRoot().cloneNode(true);
1639
+ vCanvas.appendChild(backgroundClonedGroup);
1640
+ vCanvas.appendChild(clonedGroup);
1641
+ vCanvas.appendChild(transientClonedGroup);
1642
+ vCanvas.render();
1643
+ if (!type)
1644
+ type = 'image/png';
1645
+ let dataURL = '';
1646
+ yield vCanvasContextService.toDataURL({ type }).then((url) => {
1647
+ dataURL = url;
1648
+ });
1649
+ return dataURL;
1650
+ });
1651
+ }
1652
+ /**
1653
+ * Asynchronously generates a Data URL representation of the full canvas content,
1654
+ * including background, main content, and transient canvas, with optional padding.
1655
+ * @param type The type of the Data URL (e.g., 'image/png', 'image/jpeg').
1656
+ * @param imageConfig Configuration options for the image (optional).
1657
+ * @returns A Promise that resolves to the Data URL string.
1658
+ */
1659
+ toFullDataURL(type, imageConfig) {
1660
+ return __awaiter(this, void 0, void 0, function* () {
1661
+ const backgroundCanvas = this.backgroundCanvas;
1662
+ const canvas = this.canvas;
1663
+ const transientCanvas = this.transientCanvas;
1664
+ const backgroundRoot = canvas.getRoot();
1665
+ const root = canvas.getRoot();
1666
+ const transientRoot = transientCanvas.getRoot();
1667
+ const rendererType = this.rendererType;
1668
+ const backgroundBBox = backgroundRoot.getBBox();
1669
+ const BBox = root.getBBox();
1670
+ const transientBBox = transientRoot.getBBox();
1671
+ let padding = imageConfig ? imageConfig.padding : undefined;
1672
+ if (!padding) {
1673
+ padding = [0, 0, 0, 0];
1674
+ }
1675
+ else if ((0, util_1.isNumber)(padding)) {
1676
+ padding = [padding, padding, padding, padding];
1677
+ }
1678
+ const left = (transientBBox.left
1679
+ ? backgroundBBox.left
1680
+ ? Math.min(backgroundBBox.left, BBox.left, transientBBox.left)
1681
+ : Math.min(BBox.left, transientBBox.left)
1682
+ : BBox.left) - padding[3];
1683
+ const right = (transientBBox.right
1684
+ ? backgroundBBox.right
1685
+ ? Math.max(backgroundBBox.right, BBox.right, transientBBox.right)
1686
+ : Math.max(BBox.right, transientBBox.right)
1687
+ : BBox.right) + padding[1];
1688
+ const top = (transientBBox.top
1689
+ ? backgroundBBox.top
1690
+ ? Math.min(backgroundBBox.top, BBox.top, transientBBox.top)
1691
+ : Math.min(BBox.top, transientBBox.top)
1692
+ : BBox.top) - padding[0];
1693
+ const bottom = (transientBBox.bottom
1694
+ ? backgroundBBox.bottom
1695
+ ? Math.max(backgroundBBox.bottom, BBox.bottom, transientBBox.bottom)
1696
+ : Math.max(BBox.bottom, transientBBox.bottom)
1697
+ : BBox.bottom) + padding[2];
1698
+ const graphCenterX = (left + right) / 2;
1699
+ const graphCenterY = (top + bottom) / 2;
1700
+ const halfX = (right - left) / 2;
1701
+ const halfY = (bottom - top) / 2;
1702
+ const pixelRatio = typeof window !== 'undefined' ? window.devicePixelRatio : 1;
1703
+ const vWidth = halfX * 2;
1704
+ const vHeight = halfY * 2;
1705
+ const vContainerDOM = (0, dom_util_1.createDom)('<div id="virtual-image"></div>');
1706
+ const vCanvas = (0, canvas_1.createCanvas)(rendererType, vContainerDOM, vWidth, vHeight, pixelRatio);
1707
+ const vCanvasContextService = vCanvas.getContextService();
1708
+ if (rendererType !== 'svg') {
1709
+ const bgRect = new g_1.Rect({
1710
+ style: {
1711
+ x: 0,
1712
+ y: 0,
1713
+ z: -1,
1714
+ width: vCanvasContextService.getDomElement().width,
1715
+ height: vCanvasContextService.getDomElement().height,
1716
+ //@ts-ignore
1717
+ fill: backgroundCanvas.getContextService().getDomElement().style['background-color'],
1718
+ },
1719
+ });
1720
+ vCanvas.appendChild(bgRect);
1721
+ }
1722
+ const backgroundClonedGroup = backgroundRoot.cloneNode(true);
1723
+ const clonedGroup = root.cloneNode(true);
1724
+ const transientClonedGroup = transientRoot.cloneNode(true);
1725
+ const transPosition = [
1726
+ -graphCenterX + halfX,
1727
+ -graphCenterY + halfY,
1728
+ ];
1729
+ backgroundClonedGroup.setPosition(transPosition);
1730
+ clonedGroup.setPosition(transPosition);
1731
+ transientClonedGroup.setPosition(transPosition);
1732
+ vCanvas.appendChild(backgroundClonedGroup);
1733
+ vCanvas.appendChild(clonedGroup);
1734
+ vCanvas.appendChild(transientClonedGroup);
1735
+ vCanvas.render();
1736
+ if (!type)
1737
+ type = 'image/png';
1738
+ let dataURL = '';
1739
+ yield vCanvasContextService.toDataURL({ type }).then((url) => {
1740
+ dataURL = url;
1741
+ });
1742
+ return dataURL;
1743
+ });
1744
+ }
1745
+ /**
1746
+ * Converts a Data URL to an image file and handles the download of the image.
1747
+ * @param dataURL The Data URL of the image to be converted and downloaded.
1748
+ * @param renderer The renderer type ('svg' or other) used for the canvas.
1749
+ * @param link The HTML link element used for image download.
1750
+ * @param fileName The desired name for the downloaded image file.
1751
+ */
1752
+ dataURLToImage(dataURL, renderer, link, fileName) {
1753
+ if (!dataURL || dataURL === 'data:') {
1754
+ console.error('Download image failed. The graph is too large or there is invalid attribute values in graph items');
1755
+ return;
1756
+ }
1757
+ if (typeof window !== 'undefined') {
1758
+ if (window.Blob && window.URL && renderer !== 'svg') {
1759
+ const arr = dataURL.split(',');
1760
+ let mime = '';
1761
+ if (arr && arr.length > 0) {
1762
+ const match = arr[0].match(/:(.*?);/);
1763
+ // eslint-disable-next-line prefer-destructuring
1764
+ if (match && match.length >= 2)
1765
+ mime = match[1];
1766
+ }
1767
+ const bstr = atob(arr[1]);
1768
+ let n = bstr.length;
1769
+ const u8arr = new Uint8Array(n);
1770
+ while (n--) {
1771
+ u8arr[n] = bstr.charCodeAt(n);
1772
+ }
1773
+ const blobObj = new Blob([u8arr], { type: mime });
1774
+ if (window.navigator.msSaveBlob) {
1775
+ window.navigator.msSaveBlob(blobObj, fileName);
1776
+ }
1777
+ else {
1778
+ link.addEventListener('click', () => {
1779
+ link.download = fileName;
1780
+ link.href = window.URL.createObjectURL(blobObj);
1781
+ });
1782
+ }
1783
+ }
1784
+ else {
1785
+ link.addEventListener('click', () => {
1786
+ link.download = fileName;
1787
+ link.href = dataURL;
1788
+ });
1789
+ }
1790
+ }
1791
+ }
1792
+ /**
1793
+ * Initiates the download of the graph as an image with an optional name and type.
1794
+ * @param name The desired name for the downloaded image file (optional).
1795
+ * @param type The type of the image to download (optional, defaults to 'image/png').
1796
+ */
1797
+ downloadImage(name, type) {
1798
+ const self = this;
1799
+ // self.stopAnimate();
1800
+ const rendererType = this.rendererType;
1801
+ if (!type)
1802
+ type = 'image/png';
1803
+ const fileName = (name || 'graph') +
1804
+ (rendererType === 'svg' ? '.svg' : type.split('/')[1]);
1805
+ const link = document.createElement('a');
1806
+ self.asyncToDataUrl(type, (dataURL) => {
1807
+ this.dataURLToImage(dataURL, rendererType, link, fileName);
1808
+ const e = document.createEvent('MouseEvents');
1809
+ e.initEvent('click', false, false);
1810
+ link.dispatchEvent(e);
1811
+ });
1812
+ }
1813
+ /**
1814
+ * Initiates the download of the entire graph as an image with optional name, type, and padding configuration.
1815
+ * @param name The desired name for the downloaded image file (optional).
1816
+ * @param type The type of the image to download (optional, defaults to 'image/png').
1817
+ * @param imageConfig Configuration options for the image (optional).
1818
+ */
1819
+ downloadFullImage(name, type, imageConfig) {
1820
+ const self = this;
1821
+ const rendererType = this.rendererType;
1822
+ if (!type)
1823
+ type = 'image/png';
1824
+ const fileName = (name || 'graph') +
1825
+ (rendererType === 'svg' ? '.svg' : type.split('/')[1]);
1826
+ const link = document.createElement('a');
1827
+ self.asyncToFullDataUrl(type, imageConfig, (dataURL) => {
1828
+ this.dataURLToImage(dataURL, rendererType, link, fileName);
1829
+ const e = document.createEvent('MouseEvents');
1830
+ e.initEvent('click', false, false);
1831
+ link.dispatchEvent(e);
1832
+ });
1833
+ }
1834
+ /**
1835
+ * Asynchronously converts the canvas content to a Data URL of the specified type and invokes the provided callback.
1836
+ * @param type The type of the Data URL (optional, defaults to 'image/png').
1837
+ * @param callback A callback function to handle the Data URL (optional).
1838
+ */
1839
+ asyncToDataUrl(type, callback) {
1840
+ let dataURL = '';
1841
+ if (!type)
1842
+ type = 'image/png';
1843
+ setTimeout(() => __awaiter(this, void 0, void 0, function* () {
1844
+ yield this.toDataURL(type).then((url) => {
1845
+ dataURL = url;
1846
+ });
1847
+ if (callback)
1848
+ callback(dataURL);
1849
+ }), 16);
1850
+ }
1851
+ /**
1852
+ * Asynchronously converts the entire canvas content to a Data URL of the specified type
1853
+ * with optional padding, and invokes the provided callback.
1854
+ * @param type The type of the Data URL (optional, defaults to 'image/png').
1855
+ * @param imageConfig Configuration options for the image (optional).
1856
+ * @param callback A callback function to handle the Data URL (optional).
1857
+ */
1858
+ asyncToFullDataUrl(type, imageConfig, callback) {
1859
+ let dataURL = '';
1860
+ if (!type)
1861
+ type = 'image/png';
1862
+ setTimeout(() => __awaiter(this, void 0, void 0, function* () {
1863
+ yield this.toFullDataURL(type, imageConfig).then((url) => {
1864
+ dataURL = url;
1865
+ });
1866
+ if (callback)
1867
+ callback(dataURL);
1868
+ }), 16);
1869
+ }
1518
1870
  // ===== history operations =====
1519
1871
  /**
1520
1872
  * Determine if history (redo/undo) is enabled.
@@ -1536,16 +1888,16 @@ class Graph extends event_emitter_1.default {
1536
1888
  /**
1537
1889
  * Pause stacking operation.
1538
1890
  */
1539
- pauseStacking() {
1891
+ pauseStack() {
1540
1892
  const history = this.getHistoryPlugin();
1541
- return history === null || history === void 0 ? void 0 : history.pauseStacking();
1893
+ return history === null || history === void 0 ? void 0 : history.pauseStack();
1542
1894
  }
1543
1895
  /**
1544
1896
  * Resume stacking operation.
1545
1897
  */
1546
- resumeStacking() {
1898
+ resumeStack() {
1547
1899
  const history = this.getHistoryPlugin();
1548
- return history === null || history === void 0 ? void 0 : history.resumeStacking();
1900
+ return history === null || history === void 0 ? void 0 : history.resumeStack();
1549
1901
  }
1550
1902
  /**
1551
1903
  * Retrieve the current redo stack which consists of operations that could be undone
@@ -1602,38 +1954,38 @@ class Graph extends event_emitter_1.default {
1602
1954
  return history === null || history === void 0 ? void 0 : history.canRedo();
1603
1955
  }
1604
1956
  /**
1605
- * Begin a batch operation.
1606
- * Any operations performed between `startBatch` and `stopBatch` are grouped together.
1957
+ * Begin a historyBatch operation.
1958
+ * Any operations performed between `startHistoryBatch` and `stopHistoryBatch` are grouped together.
1607
1959
  * treated as a single operation when undoing or redoing.
1608
1960
  */
1609
- startBatch() {
1961
+ startHistoryBatch() {
1610
1962
  const history = this.getHistoryPlugin();
1611
- history === null || history === void 0 ? void 0 : history.startBatch();
1963
+ history === null || history === void 0 ? void 0 : history.startHistoryBatch();
1612
1964
  }
1613
1965
  /**
1614
- * End a batch operation.
1615
- * Any operations performed between `startBatch` and `stopBatch` are grouped together.
1966
+ * End a historyBatch operation.
1967
+ * Any operations performed between `startHistoryBatch` and `stopHistoryBatch` are grouped together.
1616
1968
  * treated as a single operation when undoing or redoing.
1617
1969
  */
1618
- stopBatch() {
1970
+ stopHistoryBatch() {
1619
1971
  const history = this.getHistoryPlugin();
1620
- history === null || history === void 0 ? void 0 : history.stopBatch();
1972
+ history === null || history === void 0 ? void 0 : history.stopHistoryBatch();
1621
1973
  }
1622
1974
  /**
1623
1975
  * Execute a provided function within a batched context
1624
1976
  * All operations performed inside callback will be treated as a composite operation
1625
- * more convenient way without manually invoking `startBatch` and `stopBatch`.
1977
+ * more convenient way without manually invoking `startHistoryBatch` and `stopHistoryBatch`.
1626
1978
  * @param callback The func containing operations to be batched together.
1627
1979
  */
1628
- batch(callback) {
1980
+ historyBatch(callback) {
1629
1981
  const history = this.getHistoryPlugin();
1630
- history === null || history === void 0 ? void 0 : history.batch(callback);
1982
+ history === null || history === void 0 ? void 0 : history.historyBatch(callback);
1631
1983
  }
1632
1984
  /**
1633
1985
  * Clear history stack
1634
1986
  * @param {StackType} stackType undo/redo stack
1635
1987
  */
1636
- clearStack(stackType) {
1988
+ cleanHistory(stackType) {
1637
1989
  const history = this.getHistoryPlugin();
1638
1990
  if (!stackType)
1639
1991
  return history === null || history === void 0 ? void 0 : history.clear();
@@ -1685,7 +2037,7 @@ class Graph extends event_emitter_1.default {
1685
2037
  this.backgroundCanvas.destroy();
1686
2038
  this.transientCanvas.destroy();
1687
2039
  // clear history stack
1688
- this.clearStack();
2040
+ this.cleanHistory();
1689
2041
  callback === null || callback === void 0 ? void 0 : callback();
1690
2042
  // }, 500);
1691
2043
  this.hooks.destroy.emit({});