@visactor/vgrammar-core 0.14.0-alpha.3 → 0.14.0-alpha.4

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 (201) hide show
  1. package/cjs/component/axis.d.ts +2 -0
  2. package/cjs/component/axis.js +15 -1
  3. package/cjs/component/axis.js.map +1 -1
  4. package/cjs/component/grid.d.ts +2 -0
  5. package/cjs/component/grid.js +15 -1
  6. package/cjs/component/grid.js.map +1 -1
  7. package/cjs/component/index.d.ts +2 -2
  8. package/cjs/component/index.js +21 -1
  9. package/cjs/component/index.js.map +1 -1
  10. package/cjs/core/factory.d.ts +8 -1
  11. package/cjs/core/factory.js +8 -1
  12. package/cjs/core/factory.js.map +1 -1
  13. package/cjs/glyph/boxplot.js +5 -5
  14. package/cjs/glyph/boxplot.js.map +1 -1
  15. package/cjs/glyph/link-path.js +2 -2
  16. package/cjs/glyph/link-path.js.map +1 -1
  17. package/cjs/glyph/ripple.js +3 -2
  18. package/cjs/glyph/ripple.js.map +1 -1
  19. package/cjs/glyph/tree-path.js +2 -2
  20. package/cjs/glyph/tree-path.js.map +1 -1
  21. package/cjs/glyph/violin.js +4 -4
  22. package/cjs/glyph/violin.js.map +1 -1
  23. package/cjs/glyph/wave.js +3 -2
  24. package/cjs/glyph/wave.js.map +1 -1
  25. package/cjs/graph/animation/animation/update.js +2 -2
  26. package/cjs/graph/animation/animation/update.js.map +1 -1
  27. package/cjs/graph/animation/morph.d.ts +2 -12
  28. package/cjs/graph/animation/morph.js +76 -163
  29. package/cjs/graph/animation/morph.js.map +1 -1
  30. package/cjs/graph/attributes/line.js.map +1 -1
  31. package/cjs/graph/canvas-renderer.d.ts +1 -1
  32. package/cjs/graph/canvas-renderer.js +4 -4
  33. package/cjs/graph/canvas-renderer.js.map +1 -1
  34. package/cjs/graph/element.d.ts +1 -0
  35. package/cjs/graph/element.js +15 -9
  36. package/cjs/graph/element.js.map +1 -1
  37. package/cjs/graph/glyph-element.js +4 -3
  38. package/cjs/graph/glyph-element.js.map +1 -1
  39. package/cjs/graph/layout/layout.d.ts +1 -0
  40. package/cjs/graph/layout/layout.js +8 -2
  41. package/cjs/graph/layout/layout.js.map +1 -1
  42. package/cjs/graph/mark/graphic.js +14 -8
  43. package/cjs/graph/mark/graphic.js.map +1 -1
  44. package/cjs/graph/util/point.js +10 -26
  45. package/cjs/graph/util/point.js.map +1 -1
  46. package/cjs/graph/view-diff.d.ts +8 -0
  47. package/cjs/graph/view-diff.js +93 -0
  48. package/cjs/graph/view-diff.js.map +1 -0
  49. package/cjs/index.d.ts +8 -1
  50. package/cjs/index.js +66 -2
  51. package/cjs/index.js.map +1 -1
  52. package/cjs/interactions/brush-base.js +1 -2
  53. package/cjs/interactions/brush-filter.js +2 -1
  54. package/cjs/interactions/fish-eye.js +1 -2
  55. package/cjs/interactions/index.js +2 -1
  56. package/cjs/interactions/tooltip.js +1 -1
  57. package/cjs/parse/event.d.ts +0 -2
  58. package/cjs/parse/event.js +4 -10
  59. package/cjs/parse/event.js.map +1 -1
  60. package/cjs/parse/util.js.map +1 -1
  61. package/cjs/types/element.d.ts +1 -1
  62. package/cjs/types/element.js.map +1 -1
  63. package/cjs/types/morph.d.ts +1 -2
  64. package/cjs/types/morph.js.map +1 -1
  65. package/cjs/types/renderer.d.ts +6 -1
  66. package/cjs/types/renderer.js.map +1 -1
  67. package/cjs/view/View.d.ts +3 -6
  68. package/cjs/view/View.js +52 -105
  69. package/cjs/view/View.js.map +1 -1
  70. package/cjs/view/animate.js +2 -1
  71. package/cjs/view/animate.js.map +1 -1
  72. package/cjs/view/constants.d.ts +2 -0
  73. package/cjs/view/constants.js +3 -2
  74. package/cjs/view/constants.js.map +1 -1
  75. package/cjs/view/events.d.ts +0 -1
  76. package/cjs/view/events.js +3 -17
  77. package/cjs/view/events.js.map +1 -1
  78. package/cjs/view/glyph.d.ts +4 -0
  79. package/cjs/view/glyph.js +12 -3
  80. package/cjs/view/glyph.js.map +1 -1
  81. package/cjs/view/group.js +3 -3
  82. package/cjs/view/group.js.map +1 -1
  83. package/cjs/view/mark-animate-mixin.d.ts +1 -0
  84. package/cjs/view/mark-animate-mixin.js +29 -0
  85. package/cjs/view/mark-animate-mixin.js.map +1 -0
  86. package/cjs/view/mark.d.ts +2 -0
  87. package/cjs/view/mark.js +30 -23
  88. package/cjs/view/mark.js.map +1 -1
  89. package/cjs/view/view-animate-mixin.d.ts +1 -0
  90. package/cjs/view/view-animate-mixin.js +26 -0
  91. package/cjs/view/view-animate-mixin.js.map +1 -0
  92. package/cjs/view/view-event-mixin.d.ts +1 -0
  93. package/cjs/view/view-event-mixin.js +92 -0
  94. package/cjs/view/view-event-mixin.js.map +1 -0
  95. package/cjs/view/view-morph-mixin.d.ts +1 -0
  96. package/cjs/view/view-morph-mixin.js +32 -0
  97. package/cjs/view/view-morph-mixin.js.map +1 -0
  98. package/es/component/axis.d.ts +2 -0
  99. package/es/component/axis.js +10 -0
  100. package/es/component/axis.js.map +1 -1
  101. package/es/component/grid.d.ts +2 -0
  102. package/es/component/grid.js +10 -0
  103. package/es/component/grid.js.map +1 -1
  104. package/es/component/index.d.ts +2 -2
  105. package/es/component/index.js +2 -2
  106. package/es/component/index.js.map +1 -1
  107. package/es/core/factory.d.ts +8 -1
  108. package/es/core/factory.js +8 -1
  109. package/es/core/factory.js.map +1 -1
  110. package/es/glyph/boxplot.js +4 -2
  111. package/es/glyph/boxplot.js.map +1 -1
  112. package/es/glyph/link-path.js +4 -2
  113. package/es/glyph/link-path.js.map +1 -1
  114. package/es/glyph/ripple.js +3 -1
  115. package/es/glyph/ripple.js.map +1 -1
  116. package/es/glyph/tree-path.js +4 -2
  117. package/es/glyph/tree-path.js.map +1 -1
  118. package/es/glyph/violin.js +4 -2
  119. package/es/glyph/violin.js.map +1 -1
  120. package/es/glyph/wave.js +3 -1
  121. package/es/glyph/wave.js.map +1 -1
  122. package/es/graph/animation/animation/update.js +1 -3
  123. package/es/graph/animation/animation/update.js.map +1 -1
  124. package/es/graph/animation/morph.d.ts +2 -12
  125. package/es/graph/animation/morph.js +72 -159
  126. package/es/graph/animation/morph.js.map +1 -1
  127. package/es/graph/attributes/line.js.map +1 -1
  128. package/es/graph/canvas-renderer.d.ts +1 -1
  129. package/es/graph/canvas-renderer.js +5 -5
  130. package/es/graph/canvas-renderer.js.map +1 -1
  131. package/es/graph/element.d.ts +1 -0
  132. package/es/graph/element.js +13 -9
  133. package/es/graph/element.js.map +1 -1
  134. package/es/graph/glyph-element.js +3 -5
  135. package/es/graph/glyph-element.js.map +1 -1
  136. package/es/graph/layout/layout.d.ts +1 -0
  137. package/es/graph/layout/layout.js +6 -0
  138. package/es/graph/layout/layout.js.map +1 -1
  139. package/es/graph/mark/graphic.js +13 -7
  140. package/es/graph/mark/graphic.js.map +1 -1
  141. package/es/graph/util/point.js +10 -26
  142. package/es/graph/util/point.js.map +1 -1
  143. package/es/graph/view-diff.d.ts +8 -0
  144. package/es/graph/view-diff.js +89 -0
  145. package/es/graph/view-diff.js.map +1 -0
  146. package/es/index.d.ts +8 -1
  147. package/es/index.js +29 -1
  148. package/es/index.js.map +1 -1
  149. package/es/interactions/element-active.js +1 -2
  150. package/es/interactions/element-highlight-by-group.js +2 -1
  151. package/es/interactions/fish-eye.js +1 -1
  152. package/es/parse/event.d.ts +0 -2
  153. package/es/parse/event.js +3 -7
  154. package/es/parse/event.js.map +1 -1
  155. package/es/parse/option.js +1 -2
  156. package/es/parse/scale.js +2 -1
  157. package/es/parse/util.js.map +1 -1
  158. package/es/types/element.d.ts +1 -1
  159. package/es/types/element.js.map +1 -1
  160. package/es/types/morph.d.ts +1 -2
  161. package/es/types/morph.js.map +1 -1
  162. package/es/types/renderer.d.ts +6 -1
  163. package/es/types/renderer.js.map +1 -1
  164. package/es/view/View.d.ts +3 -6
  165. package/es/view/View.js +53 -114
  166. package/es/view/View.js.map +1 -1
  167. package/es/view/animate.js +2 -1
  168. package/es/view/animate.js.map +1 -1
  169. package/es/view/constants.d.ts +2 -0
  170. package/es/view/constants.js +4 -0
  171. package/es/view/constants.js.map +1 -1
  172. package/es/view/events.d.ts +0 -1
  173. package/es/view/events.js +1 -15
  174. package/es/view/events.js.map +1 -1
  175. package/es/view/glyph.d.ts +4 -0
  176. package/es/view/glyph.js +11 -0
  177. package/es/view/glyph.js.map +1 -1
  178. package/es/view/group.js +2 -4
  179. package/es/view/group.js.map +1 -1
  180. package/es/view/mark-animate-mixin.d.ts +1 -0
  181. package/es/view/mark-animate-mixin.js +25 -0
  182. package/es/view/mark-animate-mixin.js.map +1 -0
  183. package/es/view/mark.d.ts +2 -0
  184. package/es/view/mark.js +30 -25
  185. package/es/view/mark.js.map +1 -1
  186. package/es/view/view-animate-mixin.d.ts +1 -0
  187. package/es/view/view-animate-mixin.js +16 -0
  188. package/es/view/view-animate-mixin.js.map +1 -0
  189. package/es/view/view-event-mixin.d.ts +1 -0
  190. package/es/view/view-event-mixin.js +90 -0
  191. package/es/view/view-event-mixin.js.map +1 -0
  192. package/es/view/view-morph-mixin.d.ts +1 -0
  193. package/es/view/view-morph-mixin.js +22 -0
  194. package/es/view/view-morph-mixin.js.map +1 -0
  195. package/package.json +10 -10
  196. package/cjs/graph/util/element.d.ts +0 -2
  197. package/cjs/graph/util/element.js +0 -10
  198. package/cjs/graph/util/element.js.map +0 -1
  199. package/es/graph/util/element.d.ts +0 -2
  200. package/es/graph/util/element.js +0 -8
  201. package/es/graph/util/element.js.map +0 -1
package/es/view/View.js CHANGED
@@ -1,11 +1,9 @@
1
- import { EventEmitter, debounce, isObject, isString, getContainerSize, Logger, array, isNil } from "@visactor/vutils";
1
+ import { EventEmitter, debounce, isString, getContainerSize, Logger, array, isNil, isArray } from "@visactor/vutils";
2
2
 
3
3
  import { vglobal } from "@visactor/vrender-core";
4
4
 
5
5
  import { Data } from "./data";
6
6
 
7
- import { initializeEventConfig, permit, prevent } from "./events";
8
-
9
7
  import Dataflow from "./dataflow";
10
8
 
11
9
  import { traverseMarkTree } from "../graph/mark-tree";
@@ -16,15 +14,13 @@ import CanvasRenderer from "../graph/canvas-renderer";
16
14
 
17
15
  import getExtendedEvents from "../graph/util/events-extend";
18
16
 
19
- import { BROWSER, NO_TRAP, SIGNAL_WIDTH, SIGNAL_HEIGHT, SIGNAL_PADDING, SIGNAL_AUTOFIT, SIGNAL_VIEW_WIDTH, SIGNAL_VIEW_HEIGHT, EVENT_SOURCE_VIEW, EVENT_SOURCE_WINDOW, SIGNAL_VIEW_BOX } from "./constants";
17
+ import { BROWSER, SIGNAL_WIDTH, SIGNAL_HEIGHT, SIGNAL_PADDING, SIGNAL_AUTOFIT, SIGNAL_VIEW_WIDTH, SIGNAL_VIEW_HEIGHT, EVENT_SOURCE_VIEW, SIGNAL_VIEW_BOX, ID_PREFIX, NAME_PREFIX, EVENT_SOURCE_WINDOW } from "./constants";
20
18
 
21
19
  import { Signal } from "./signal";
22
20
 
23
21
  import { BuiltInSignalID, builtInSignals, normalizeMarkTree, normalizeRunningConfig, normalizePadding } from "../parse/view";
24
22
 
25
- import { parseHandler, parseEventSelector, generateFilterByMark, ID_PREFIX, NAME_PREFIX } from "../parse/event";
26
-
27
- import { isGrammar, parseReference } from "../parse/util";
23
+ import { isGrammar } from "../parse/util";
28
24
 
29
25
  import { configureEnvironment } from "../graph/util/env";
30
26
 
@@ -32,16 +28,8 @@ import { GroupMark } from "./group";
32
28
 
33
29
  import { Mark } from "./mark";
34
30
 
35
- import { defaultDoLayout } from "../graph/layout/layout";
36
-
37
- import { GlyphMark } from "./glyph";
38
-
39
- import { Morph } from "../graph/animation/morph";
40
-
41
31
  import { RecordedGrammars, RecordedTreeGrammars } from "./grammar-record";
42
32
 
43
- import { ViewAnimate } from "./animate";
44
-
45
33
  import { ComponentEnum, HOOK_EVENT, LayoutState, GrammarMarkType } from "../graph/enums";
46
34
 
47
35
  import { Text } from "../semantic-marks/text";
@@ -54,6 +42,8 @@ import { Component } from "./component";
54
42
 
55
43
  import { isMarkType, removeGraphicItem } from "../graph/util/graphic";
56
44
 
45
+ import { ViewDiff } from "../graph/view-diff";
46
+
57
47
  export default class View extends EventEmitter {
58
48
  static useRegisters(comps) {
59
49
  comps.forEach((fn => {
@@ -154,7 +144,8 @@ export default class View extends EventEmitter {
154
144
  break;
155
145
 
156
146
  case GrammarMarkType.glyph:
157
- mark = new GlyphMark(this, null == markOptions ? void 0 : markOptions.glyphType, groupMark);
147
+ const GlyphMark = Factory.getMark(GrammarMarkType.glyph);
148
+ GlyphMark && (mark = new GlyphMark(this, null == markOptions ? void 0 : markOptions.glyphType, groupMark));
158
149
  break;
159
150
 
160
151
  case GrammarMarkType.component:
@@ -260,7 +251,7 @@ export default class View extends EventEmitter {
260
251
  })), this;
261
252
  }
262
253
  parseSpec(spec) {
263
- var _a, _b, _c, _d, _e, _f;
254
+ var _a, _b, _c, _d, _e, _f, _g, _h;
264
255
  if (this.emit(HOOK_EVENT.BEFORE_PARSE_VIEW), this._spec = spec, normalizeMarkTree(spec),
265
256
  spec.theme ? this.theme(spec.theme) : this.theme(ThemeManager.getDefaultTheme()),
266
257
  spec.width && this.width(spec.width), spec.height && this.height(spec.height), this.padding(null !== (_b = null !== (_a = spec.padding) && void 0 !== _a ? _a : this._options.padding) && void 0 !== _b ? _b : this._theme.padding),
@@ -288,11 +279,13 @@ export default class View extends EventEmitter {
288
279
  })), spec.marks && spec.marks.length && spec.marks.forEach((mark => {
289
280
  this.parseMarkSpec(mark);
290
281
  })), spec.events && spec.events.length && spec.events.forEach((eventConfig => {
291
- this.event(eventConfig);
282
+ var _b;
283
+ null === (_b = this.event) || void 0 === _b || _b.call(this, eventConfig);
292
284
  })), spec.interactions && spec.interactions.length && spec.interactions.forEach((interaction => {
293
285
  this.interaction(interaction.type, interaction);
294
- })), !1 === spec.animation ? this.animate.disable() : this.animate.enable(), this.emit(HOOK_EVENT.AFTER_PARSE_VIEW),
295
- this._needBuildLayoutTree = !0, this._layoutState = LayoutState.before, this;
286
+ })), !1 === spec.animation ? null === (_g = this.animate) || void 0 === _g || _g.disable() : null === (_h = this.animate) || void 0 === _h || _h.enable(),
287
+ this.emit(HOOK_EVENT.AFTER_PARSE_VIEW), this._needBuildLayoutTree = !0, this._layoutState = LayoutState.before,
288
+ this;
296
289
  }
297
290
  updateSpec(spec) {
298
291
  return this.removeAllInteractions(), this.removeAllGrammars(), this.parseSpec(spec);
@@ -412,7 +405,7 @@ export default class View extends EventEmitter {
412
405
  }
413
406
  doLayout() {
414
407
  var _a;
415
- const doLayout = this._options.doLayout || defaultDoLayout;
408
+ const doLayout = this._options.doLayout || Factory.getDefaultLayout();
416
409
  doLayout && (null === (_a = this._layoutMarks) || void 0 === _a ? void 0 : _a.length) && (this.emit(HOOK_EVENT.BEFORE_DO_LAYOUT),
417
410
  doLayout(this._layoutMarks, this._options, this), this.emit(HOOK_EVENT.AFTER_DO_LAYOUT));
418
411
  }
@@ -435,11 +428,11 @@ export default class View extends EventEmitter {
435
428
  return this.evaluate(runningConfig), this;
436
429
  }
437
430
  doRender(immediately) {
438
- this.emit(HOOK_EVENT.BEFORE_DO_RENDER), this.renderer && (this._progressiveMarks || this.animate.animate(),
431
+ this.emit(HOOK_EVENT.BEFORE_DO_RENDER), this.renderer && (!this._progressiveMarks && this.animate && this.animate.animate(),
439
432
  this.renderer.render(immediately), this.handleRenderEnd()), this.emit(HOOK_EVENT.AFTER_DO_RENDER);
440
433
  }
441
434
  evaluate(runningConfig) {
442
- var _a, _b;
435
+ var _a, _c;
443
436
  const normalizedRunningConfig = normalizeRunningConfig(runningConfig), grammarWillDetach = this._cachedGrammars.size() > 0;
444
437
  grammarWillDetach && (this.reuseCachedGrammars(normalizedRunningConfig), this.detachCachedGrammar());
445
438
  const hasResize = this._resizeRenderer(), hasUpdate = this._dataflow.hasCommitted();
@@ -448,28 +441,28 @@ export default class View extends EventEmitter {
448
441
  this._needBuildLayoutTree = !1), this._layoutState && (this._layoutState = LayoutState.layouting,
449
442
  this.doLayout(), this._dataflow.hasCommitted() && (this._layoutState = LayoutState.reevaluate,
450
443
  this._dataflow.evaluate()), this._layoutState = LayoutState.after, (null === (_a = this._layoutMarks) || void 0 === _a ? void 0 : _a.length) && this.handleLayoutEnd()),
451
- this._layoutState = null, this.findProgressiveMarks(), this._resizeRenderer(), null === (_b = this._willMorphMarks) || void 0 === _b || _b.forEach((morphMarks => {
452
- this._morph.morph(morphMarks.prev, morphMarks.next, normalizedRunningConfig);
453
- })), this._willMorphMarks = null, this.releaseCachedGrammars(normalizedRunningConfig),
454
- this.doRender(!0), this.doPreProgressive(), this) : this;
444
+ this._layoutState = null, this.findProgressiveMarks(), this._resizeRenderer(), null === (_c = this.morph) || void 0 === _c || _c.call(this, normalizedRunningConfig),
445
+ this.releaseCachedGrammars(normalizedRunningConfig), this.doRender(!0), this.doPreProgressive(),
446
+ this) : this;
455
447
  }
456
448
  reuseCachedGrammars(runningConfig) {
457
- if (this._willMorphMarks || (this._willMorphMarks = []), runningConfig.reuse) {
449
+ if (runningConfig.reuse) {
458
450
  const reuseDiffUpdate = diff => {
459
451
  diff.next.reuse(diff.prev), diff.prev.detachAll(), diff.prev.clear(), this._cachedGrammars.unrecord(diff.prev);
460
452
  };
461
- this._morph.diffGrammar(this._cachedGrammars.getAllSignals(), this.grammars.getAllSignals().filter((signal => !BuiltInSignalID.includes(signal.id())))).update.forEach(reuseDiffUpdate);
462
- this._morph.diffGrammar(this._cachedGrammars.getAllData(), this.grammars.getAllData()).update.forEach(reuseDiffUpdate);
463
- this._morph.diffGrammar(this._cachedGrammars.getAllScales(), this.grammars.getAllScales()).update.forEach(reuseDiffUpdate);
464
- this._morph.diffGrammar(this._cachedGrammars.getAllCoordinates(), this.grammars.getAllCoordinates()).update.forEach(reuseDiffUpdate);
453
+ this._differ.diffGrammar(this._cachedGrammars.getAllSignals(), this.grammars.getAllSignals().filter((signal => !BuiltInSignalID.includes(signal.id())))).update.forEach(reuseDiffUpdate);
454
+ this._differ.diffGrammar(this._cachedGrammars.getAllData(), this.grammars.getAllData()).update.forEach(reuseDiffUpdate);
455
+ this._differ.diffGrammar(this._cachedGrammars.getAllScales(), this.grammars.getAllScales()).update.forEach(reuseDiffUpdate);
456
+ this._differ.diffGrammar(this._cachedGrammars.getAllCoordinates(), this.grammars.getAllCoordinates()).update.forEach(reuseDiffUpdate);
465
457
  }
466
- this._morph.diffMark(this._cachedGrammars.getAllMarks(), this.grammars.getAllMarks().filter((mark => "root" !== mark.id())), runningConfig).update.forEach((diff => {
458
+ this._differ.diffMark(this._cachedGrammars.getAllMarks(), this.grammars.getAllMarks().filter((mark => "root" !== mark.id())), runningConfig).update.forEach((diff => {
459
+ var _b;
467
460
  const matched = 1 === diff.prev.length && 1 === diff.next.length && diff.prev[0].markType === diff.next[0].markType, enableMarkMorphConfig = diff.prev.every((mark => mark.getMorphConfig().morph)) && diff.next.every((mark => mark.getMorphConfig().morph));
468
461
  matched && runningConfig.reuse ? (diff.next[0].reuse(diff.prev[0]), diff.prev[0].detachAll(),
469
- diff.prev[0].clear(), this._cachedGrammars.unrecord(diff.prev[0])) : (runningConfig.morph && enableMarkMorphConfig || runningConfig.morphAll) && this._willMorphMarks.push({
462
+ diff.prev[0].clear(), this._cachedGrammars.unrecord(diff.prev[0])) : (runningConfig.morph && enableMarkMorphConfig || runningConfig.morphAll) && (null === (_b = this.addMorphMarks) || void 0 === _b || _b.call(this, {
470
463
  prev: diff.prev,
471
464
  next: diff.next
472
- });
465
+ }));
473
466
  }));
474
467
  }
475
468
  detachCachedGrammar() {
@@ -487,10 +480,11 @@ export default class View extends EventEmitter {
487
480
  }));
488
481
  const markNodes = this._cachedGrammars.getAllMarkNodes();
489
482
  markNodes.forEach((node => {
490
- node.mark.animate.stop(), runningConfig.enableExitAnimation && this.animate.animateAddition(node.mark);
483
+ var _a;
484
+ null === (_a = node.mark.animate) || void 0 === _a || _a.stop(), runningConfig.enableExitAnimation && this.animate && this.animate.animateAddition(node.mark);
491
485
  }));
492
486
  const releaseUp = node => {
493
- if (node.mark.view && 0 === node.mark.animate.getAnimatorCount() && (!node.children || 0 === node.children.length)) {
487
+ if (node.mark.view && (!node.mark.animate || 0 === node.mark.animate.getAnimatorCount()) && (!node.children || 0 === node.children.length)) {
494
488
  node.mark.release();
495
489
  const parent = node.parent;
496
490
  parent && (node.parent.children = node.parent.children.filter((n => n !== node)),
@@ -499,8 +493,8 @@ export default class View extends EventEmitter {
499
493
  };
500
494
  markNodes.forEach((node => {
501
495
  const mark = node.mark;
502
- 0 === mark.animate.getAnimatorCount() ? releaseUp(node) : mark.addEventListener("animationEnd", (() => {
503
- 0 === mark.animate.getAnimatorCount() && releaseUp(node);
496
+ mark.animate && 0 === mark.animate.getAnimatorCount() ? releaseUp(node) : mark.addEventListener("animationEnd", (() => {
497
+ mark.animate && 0 === mark.animate.getAnimatorCount() && releaseUp(node);
504
498
  }));
505
499
  })), this._cachedGrammars.clear();
506
500
  }
@@ -568,73 +562,6 @@ export default class View extends EventEmitter {
568
562
  height: height
569
563
  }), !0);
570
564
  }
571
- bindEvents(eventSpec) {
572
- if (this._eventConfig.disable) return;
573
- const {type: evtType, filter: filter, callback: callback, throttle: throttle, debounce: debounce, consume: consume, target: target, dependency: dependency} = eventSpec, eventSelector = parseEventSelector(evtType);
574
- if (!eventSelector) return;
575
- const {source: source, type: type} = eventSelector, markFilter = generateFilterByMark(eventSelector), validateSignals = (Array.isArray(target) && target.length ? target.map((entry => ({
576
- signal: this.getSignalById(entry.target),
577
- callback: entry.callback
578
- }))) : [ {
579
- signal: isString(target) ? this.getSignalById(target) : null,
580
- callback: callback
581
- } ]).filter((entry => entry.signal || entry.callback)), refs = parseReference(dependency, this), send = parseHandler(((evt, element) => {
582
- const needPreventDefault = source === EVENT_SOURCE_VIEW && prevent(this._eventConfig, type) || consume && (void 0 === evt.cancelable || evt.cancelable);
583
- source === EVENT_SOURCE_WINDOW && (evt = getExtendedEvents(this, evt, element, type, EVENT_SOURCE_WINDOW));
584
- let hasCommitted = !1;
585
- if ((!filter || filter(evt)) && (!markFilter || markFilter(element)) && validateSignals.length) {
586
- const params = refs.reduce(((params, ref) => (params[ref.id()] = ref.output(), params)), {});
587
- validateSignals.forEach((entry => {
588
- if (entry.callback && entry.signal) {
589
- entry.signal.set(entry.callback(evt, params)) && (this.commit(entry.signal), hasCommitted = !0);
590
- } else entry.callback ? entry.callback(evt, params) : (this.commit(entry.signal),
591
- hasCommitted = !0);
592
- }));
593
- }
594
- needPreventDefault && evt.preventDefault(), consume && evt.stopPropagation(), hasCommitted && this.run();
595
- }), {
596
- throttle: throttle,
597
- debounce: debounce
598
- });
599
- if (source === EVENT_SOURCE_VIEW) {
600
- if (permit(this._eventConfig, EVENT_SOURCE_VIEW, type)) return this.addEventListener(type, send, NO_TRAP),
601
- () => {
602
- this.removeEventListener(type, send);
603
- };
604
- } else if (source === EVENT_SOURCE_WINDOW) return vglobal.addEventListener(type, send),
605
- this._eventListeners.push({
606
- type: type,
607
- source: vglobal,
608
- handler: send
609
- }), () => {
610
- vglobal.removeEventListener(type, send);
611
- const index = this._eventListeners.findIndex((entry => entry.type === type && entry.source === vglobal && entry.handler === send));
612
- index >= 0 && this._eventListeners.splice(index, 1);
613
- };
614
- }
615
- event(eventSpec) {
616
- if ("between" in eventSpec) {
617
- const [starEvent, endEvent] = eventSpec.between, id = `${starEvent.type}-${eventSpec.type}-${endEvent.type}`;
618
- let unbindEndEvent;
619
- this.bindEvents(Object.assign({}, starEvent, {
620
- callback: () => {
621
- if (this._eventCache || (this._eventCache = {}), !this._eventCache[id]) {
622
- const unbindEvent = this.bindEvents(eventSpec);
623
- this._eventCache[id] = unbindEvent;
624
- }
625
- unbindEndEvent || (unbindEndEvent = this.bindEvents(Object.assign({}, endEvent, {
626
- callback: () => {
627
- this._eventCache[id] && (this._eventCache[id](), this._eventCache[id] = null);
628
- }
629
- })));
630
- }
631
- }));
632
- } else "merge" in eventSpec ? eventSpec.merge.forEach((entry => {
633
- const singleEvent = Object.assign({}, eventSpec);
634
- isString(entry) ? singleEvent.type = entry : isObject(entry) && Object.assign(singleEvent, entry),
635
- singleEvent.debounce = 50, this.bindEvents(singleEvent);
636
- })) : this.bindEvents(eventSpec);
637
- }
638
565
  interaction(type, spec) {
639
566
  const interaction = Factory.createInteraction(type, this, spec);
640
567
  return interaction && (interaction.bind(), this._boundInteractions || (this._boundInteractions = []),
@@ -657,6 +584,17 @@ export default class View extends EventEmitter {
657
584
  instance.unbind();
658
585
  })), this._boundInteractions = null), this;
659
586
  }
587
+ initializeEventConfig(config) {
588
+ const eventsConfig = Object.assign({
589
+ defaults: {}
590
+ }, config), unpack = (obj, keys) => {
591
+ keys.forEach((k => {
592
+ isArray(obj[k]) && (obj[k] = obj[k].reduce(((set, key) => (set[key] = !0, set)), {}));
593
+ }));
594
+ };
595
+ return unpack(eventsConfig.defaults, [ "prevent", "allow" ]), unpack(eventsConfig, [ EVENT_SOURCE_VIEW, EVENT_SOURCE_WINDOW ]),
596
+ eventsConfig;
597
+ }
660
598
  initEvent() {
661
599
  const stage = this.renderer.stage();
662
600
  stage && stage.on("*", this.delegateEvent);
@@ -679,15 +617,15 @@ export default class View extends EventEmitter {
679
617
  this.renderer = new CanvasRenderer(this), this.renderer.initialize(width, height, this._options, this._eventConfig).background(this._background);
680
618
  }
681
619
  initialize() {
682
- var _a;
620
+ var _a, _c;
683
621
  this.grammars = new RecordedGrammars((grammar => grammar.id()), ((key, grammar) => this.logger.warn(`Grammar id '${key}' has been occupied`, grammar))),
684
622
  this._cachedGrammars = new RecordedTreeGrammars((grammar => grammar.id())), this._options.logger && Logger.setInstance(this._options.logger),
685
623
  this.logger = Logger.getInstance(null !== (_a = this._options.logLevel) && void 0 !== _a ? _a : 0),
686
- this._dataflow = new Dataflow, this.animate = new ViewAnimate(this), this._morph = new Morph,
687
- this._options.hooks && (Object.keys(this._options.hooks).forEach((key => {
624
+ this._dataflow = new Dataflow, this.animate = null === (_c = this.initAnimate) || void 0 === _c ? void 0 : _c.call(this, this),
625
+ this._differ = new ViewDiff, this._options.hooks && (Object.keys(this._options.hooks).forEach((key => {
688
626
  this.on(key, this._options.hooks[key]);
689
627
  })), this.hooks = this._options.hooks), this.container = null, this.renderer = null,
690
- this._eventListeners = [], this._eventConfig = initializeEventConfig(this._options.eventConfig),
628
+ this._eventListeners = [], this._eventConfig = this.initializeEventConfig(this._options.eventConfig),
691
629
  this._theme = this._options.disableTheme ? null : ThemeManager.getDefaultTheme(),
692
630
  this.parseBuiltIn(), configureEnvironment(this._options), this.initializeRenderer(),
693
631
  this._eventConfig.disable || this.initEvent(), this._bindResizeEvent(), this._needBuildLayoutTree = !0,
@@ -725,13 +663,14 @@ export default class View extends EventEmitter {
725
663
  })), this._progressiveMarks = null);
726
664
  }
727
665
  release() {
728
- var _a, _b, _c;
666
+ var _a, _b, _c, _d;
729
667
  this.removeAllInteractions(), this.releaseStageEvent(), this._unBindResizeEvent(),
730
668
  this.clearProgressive(), Factory.unregisterRuntimeTransforms(), Logger.setInstance(null),
731
- this.animate.stop(), this.grammars.release(), this._cachedGrammars.release(), this._dataflow.release(),
732
- this._dataflow = null, null === (_b = null === (_a = this.renderer) || void 0 === _a ? void 0 : _a.release) || void 0 === _b || _b.call(_a),
669
+ null === (_a = this.animate) || void 0 === _a || _a.stop(), this.grammars.release(),
670
+ this._cachedGrammars.release(), this._dataflow.release(), this._dataflow = null,
671
+ null === (_c = null === (_b = this.renderer) || void 0 === _b ? void 0 : _b.release) || void 0 === _c || _c.call(_b),
733
672
  this.renderer = null, this._boundInteractions = null, this.removeAllListeners(),
734
- null === (_c = this._eventListeners) || void 0 === _c || _c.forEach((listener => {
673
+ null === (_d = this._eventListeners) || void 0 === _d || _d.forEach((listener => {
735
674
  listener.source.removeEventListener(listener.type, listener.handler);
736
675
  })), this._eventListeners = null;
737
676
  }