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

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 (259) hide show
  1. package/cjs/component/axis.d.ts +0 -2
  2. package/cjs/component/axis.js +1 -15
  3. package/cjs/component/axis.js.map +1 -1
  4. package/cjs/component/grid.d.ts +0 -2
  5. package/cjs/component/grid.js +1 -15
  6. package/cjs/component/grid.js.map +1 -1
  7. package/cjs/component/index.d.ts +2 -2
  8. package/cjs/component/index.js +1 -21
  9. package/cjs/component/index.js.map +1 -1
  10. package/cjs/core/factory.d.ts +1 -8
  11. package/cjs/core/factory.js +1 -8
  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 +2 -3
  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 +2 -3
  24. package/cjs/glyph/wave.js.map +1 -1
  25. package/cjs/graph/animation/animation/fade.js +4 -4
  26. package/cjs/graph/animation/animation/fade.js.map +1 -1
  27. package/cjs/graph/animation/animation/grow-cartesian.js +14 -14
  28. package/cjs/graph/animation/animation/grow-cartesian.js.map +1 -1
  29. package/cjs/graph/animation/animation/grow-interval.js +9 -9
  30. package/cjs/graph/animation/animation/grow-interval.js.map +1 -1
  31. package/cjs/graph/animation/animation/grow-points.js +9 -9
  32. package/cjs/graph/animation/animation/grow-points.js.map +1 -1
  33. package/cjs/graph/animation/animation/grow-polar.js +24 -24
  34. package/cjs/graph/animation/animation/grow-polar.js.map +1 -1
  35. package/cjs/graph/animation/animation/move.js +6 -6
  36. package/cjs/graph/animation/animation/move.js.map +1 -1
  37. package/cjs/graph/animation/animation/rotate.js +5 -5
  38. package/cjs/graph/animation/animation/rotate.js.map +1 -1
  39. package/cjs/graph/animation/animation/scale.js +5 -5
  40. package/cjs/graph/animation/animation/scale.js.map +1 -1
  41. package/cjs/graph/animation/animation/update.js +2 -2
  42. package/cjs/graph/animation/animation/update.js.map +1 -1
  43. package/cjs/graph/animation/animator.js +6 -1
  44. package/cjs/graph/animation/animator.js.map +1 -1
  45. package/cjs/graph/animation/morph.d.ts +12 -2
  46. package/cjs/graph/animation/morph.js +163 -76
  47. package/cjs/graph/animation/morph.js.map +1 -1
  48. package/cjs/graph/attributes/line.d.ts +1 -0
  49. package/cjs/graph/attributes/line.js +17 -5
  50. package/cjs/graph/attributes/line.js.map +1 -1
  51. package/cjs/graph/canvas-renderer.d.ts +1 -1
  52. package/cjs/graph/canvas-renderer.js +4 -4
  53. package/cjs/graph/canvas-renderer.js.map +1 -1
  54. package/cjs/graph/constants.d.ts +1 -0
  55. package/cjs/graph/constants.js +2 -2
  56. package/cjs/graph/constants.js.map +1 -1
  57. package/cjs/graph/element.d.ts +2 -1
  58. package/cjs/graph/element.js +22 -20
  59. package/cjs/graph/element.js.map +1 -1
  60. package/cjs/graph/glyph-element.js +6 -7
  61. package/cjs/graph/glyph-element.js.map +1 -1
  62. package/cjs/graph/layout/layout.d.ts +0 -1
  63. package/cjs/graph/layout/layout.js +2 -8
  64. package/cjs/graph/layout/layout.js.map +1 -1
  65. package/cjs/graph/mark/graphic.js +8 -14
  66. package/cjs/graph/mark/graphic.js.map +1 -1
  67. package/cjs/graph/util/element.d.ts +2 -0
  68. package/cjs/graph/util/element.js +10 -0
  69. package/cjs/graph/util/element.js.map +1 -0
  70. package/cjs/graph/util/point.js +26 -10
  71. package/cjs/graph/util/point.js.map +1 -1
  72. package/cjs/index.d.ts +1 -8
  73. package/cjs/index.js +2 -66
  74. package/cjs/index.js.map +1 -1
  75. package/cjs/interactions/brush-base.js +2 -1
  76. package/cjs/interactions/brush-filter.js +1 -2
  77. package/cjs/interactions/fish-eye.js +2 -1
  78. package/cjs/interactions/index.js +1 -2
  79. package/cjs/interactions/tooltip.js +1 -1
  80. package/cjs/parse/event.d.ts +2 -0
  81. package/cjs/parse/event.js +10 -4
  82. package/cjs/parse/event.js.map +1 -1
  83. package/cjs/parse/util.js.map +1 -1
  84. package/cjs/transforms/mark/mark-overlap.js +6 -6
  85. package/cjs/transforms/mark/mark-overlap.js.map +1 -1
  86. package/cjs/types/animate.d.ts +1 -0
  87. package/cjs/types/animate.js.map +1 -1
  88. package/cjs/types/element.d.ts +5 -1
  89. package/cjs/types/element.js.map +1 -1
  90. package/cjs/types/morph.d.ts +2 -1
  91. package/cjs/types/morph.js.map +1 -1
  92. package/cjs/types/renderer.d.ts +1 -6
  93. package/cjs/types/renderer.js.map +1 -1
  94. package/cjs/view/View.d.ts +6 -3
  95. package/cjs/view/View.js +105 -52
  96. package/cjs/view/View.js.map +1 -1
  97. package/cjs/view/animate.js +1 -2
  98. package/cjs/view/animate.js.map +1 -1
  99. package/cjs/view/constants.d.ts +0 -2
  100. package/cjs/view/constants.js +2 -3
  101. package/cjs/view/constants.js.map +1 -1
  102. package/cjs/view/events.d.ts +1 -0
  103. package/cjs/view/events.js +17 -3
  104. package/cjs/view/events.js.map +1 -1
  105. package/cjs/view/glyph.d.ts +0 -4
  106. package/cjs/view/glyph.js +3 -12
  107. package/cjs/view/glyph.js.map +1 -1
  108. package/cjs/view/grammar-record.js +2 -3
  109. package/cjs/view/grammar-record.js.map +1 -1
  110. package/cjs/view/group.js +3 -3
  111. package/cjs/view/group.js.map +1 -1
  112. package/cjs/view/mark.d.ts +0 -2
  113. package/cjs/view/mark.js +28 -31
  114. package/cjs/view/mark.js.map +1 -1
  115. package/es/component/axis.d.ts +0 -2
  116. package/es/component/axis.js +0 -10
  117. package/es/component/axis.js.map +1 -1
  118. package/es/component/grid.d.ts +0 -2
  119. package/es/component/grid.js +0 -10
  120. package/es/component/grid.js.map +1 -1
  121. package/es/component/index.d.ts +2 -2
  122. package/es/component/index.js +2 -2
  123. package/es/component/index.js.map +1 -1
  124. package/es/core/factory.d.ts +1 -8
  125. package/es/core/factory.js +1 -8
  126. package/es/core/factory.js.map +1 -1
  127. package/es/glyph/boxplot.js +2 -4
  128. package/es/glyph/boxplot.js.map +1 -1
  129. package/es/glyph/link-path.js +2 -4
  130. package/es/glyph/link-path.js.map +1 -1
  131. package/es/glyph/ripple.js +1 -3
  132. package/es/glyph/ripple.js.map +1 -1
  133. package/es/glyph/tree-path.js +2 -4
  134. package/es/glyph/tree-path.js.map +1 -1
  135. package/es/glyph/violin.js +2 -4
  136. package/es/glyph/violin.js.map +1 -1
  137. package/es/glyph/wave.js +1 -3
  138. package/es/glyph/wave.js.map +1 -1
  139. package/es/graph/animation/animation/fade.js +4 -4
  140. package/es/graph/animation/animation/fade.js.map +1 -1
  141. package/es/graph/animation/animation/grow-cartesian.js +14 -14
  142. package/es/graph/animation/animation/grow-cartesian.js.map +1 -1
  143. package/es/graph/animation/animation/grow-interval.js +9 -9
  144. package/es/graph/animation/animation/grow-interval.js.map +1 -1
  145. package/es/graph/animation/animation/grow-points.js +9 -9
  146. package/es/graph/animation/animation/grow-points.js.map +1 -1
  147. package/es/graph/animation/animation/grow-polar.js +24 -24
  148. package/es/graph/animation/animation/grow-polar.js.map +1 -1
  149. package/es/graph/animation/animation/move.js +6 -6
  150. package/es/graph/animation/animation/move.js.map +1 -1
  151. package/es/graph/animation/animation/rotate.js +4 -4
  152. package/es/graph/animation/animation/rotate.js.map +1 -1
  153. package/es/graph/animation/animation/scale.js +5 -5
  154. package/es/graph/animation/animation/scale.js.map +1 -1
  155. package/es/graph/animation/animation/update.js +3 -1
  156. package/es/graph/animation/animation/update.js.map +1 -1
  157. package/es/graph/animation/animator.js +6 -1
  158. package/es/graph/animation/animator.js.map +1 -1
  159. package/es/graph/animation/morph.d.ts +12 -2
  160. package/es/graph/animation/morph.js +159 -72
  161. package/es/graph/animation/morph.js.map +1 -1
  162. package/es/graph/attributes/line.d.ts +1 -0
  163. package/es/graph/attributes/line.js +14 -3
  164. package/es/graph/attributes/line.js.map +1 -1
  165. package/es/graph/canvas-renderer.d.ts +1 -1
  166. package/es/graph/canvas-renderer.js +5 -5
  167. package/es/graph/canvas-renderer.js.map +1 -1
  168. package/es/graph/constants.d.ts +1 -0
  169. package/es/graph/constants.js +2 -0
  170. package/es/graph/constants.js.map +1 -1
  171. package/es/graph/element.d.ts +2 -1
  172. package/es/graph/element.js +24 -20
  173. package/es/graph/element.js.map +1 -1
  174. package/es/graph/glyph-element.js +8 -6
  175. package/es/graph/glyph-element.js.map +1 -1
  176. package/es/graph/layout/layout.d.ts +0 -1
  177. package/es/graph/layout/layout.js +0 -6
  178. package/es/graph/layout/layout.js.map +1 -1
  179. package/es/graph/mark/graphic.js +7 -13
  180. package/es/graph/mark/graphic.js.map +1 -1
  181. package/es/graph/util/element.d.ts +2 -0
  182. package/es/graph/util/element.js +8 -0
  183. package/es/graph/util/element.js.map +1 -0
  184. package/es/graph/util/point.js +26 -10
  185. package/es/graph/util/point.js.map +1 -1
  186. package/es/index.d.ts +1 -8
  187. package/es/index.js +1 -29
  188. package/es/index.js.map +1 -1
  189. package/es/interactions/element-active.js +2 -1
  190. package/es/interactions/element-highlight-by-group.js +1 -2
  191. package/es/interactions/fish-eye.js +1 -1
  192. package/es/parse/event.d.ts +2 -0
  193. package/es/parse/event.js +7 -3
  194. package/es/parse/event.js.map +1 -1
  195. package/es/parse/option.js +2 -1
  196. package/es/parse/scale.js +1 -2
  197. package/es/parse/util.js.map +1 -1
  198. package/es/transforms/mark/mark-overlap.js +6 -6
  199. package/es/transforms/mark/mark-overlap.js.map +1 -1
  200. package/es/types/animate.d.ts +1 -0
  201. package/es/types/animate.js.map +1 -1
  202. package/es/types/element.d.ts +5 -1
  203. package/es/types/element.js.map +1 -1
  204. package/es/types/morph.d.ts +2 -1
  205. package/es/types/morph.js.map +1 -1
  206. package/es/types/renderer.d.ts +1 -6
  207. package/es/types/renderer.js.map +1 -1
  208. package/es/view/View.d.ts +6 -3
  209. package/es/view/View.js +114 -53
  210. package/es/view/View.js.map +1 -1
  211. package/es/view/animate.js +1 -2
  212. package/es/view/animate.js.map +1 -1
  213. package/es/view/constants.d.ts +0 -2
  214. package/es/view/constants.js +0 -4
  215. package/es/view/constants.js.map +1 -1
  216. package/es/view/events.d.ts +1 -0
  217. package/es/view/events.js +15 -1
  218. package/es/view/events.js.map +1 -1
  219. package/es/view/glyph.d.ts +0 -4
  220. package/es/view/glyph.js +0 -11
  221. package/es/view/glyph.js.map +1 -1
  222. package/es/view/grammar-record.js +2 -3
  223. package/es/view/grammar-record.js.map +1 -1
  224. package/es/view/group.js +4 -2
  225. package/es/view/group.js.map +1 -1
  226. package/es/view/mark.d.ts +0 -2
  227. package/es/view/mark.js +30 -32
  228. package/es/view/mark.js.map +1 -1
  229. package/package.json +9 -9
  230. package/cjs/graph/view-diff.d.ts +0 -8
  231. package/cjs/graph/view-diff.js +0 -93
  232. package/cjs/graph/view-diff.js.map +0 -1
  233. package/cjs/view/mark-animate-mixin.d.ts +0 -1
  234. package/cjs/view/mark-animate-mixin.js +0 -29
  235. package/cjs/view/mark-animate-mixin.js.map +0 -1
  236. package/cjs/view/view-animate-mixin.d.ts +0 -1
  237. package/cjs/view/view-animate-mixin.js +0 -26
  238. package/cjs/view/view-animate-mixin.js.map +0 -1
  239. package/cjs/view/view-event-mixin.d.ts +0 -1
  240. package/cjs/view/view-event-mixin.js +0 -92
  241. package/cjs/view/view-event-mixin.js.map +0 -1
  242. package/cjs/view/view-morph-mixin.d.ts +0 -1
  243. package/cjs/view/view-morph-mixin.js +0 -32
  244. package/cjs/view/view-morph-mixin.js.map +0 -1
  245. package/es/graph/view-diff.d.ts +0 -8
  246. package/es/graph/view-diff.js +0 -89
  247. package/es/graph/view-diff.js.map +0 -1
  248. package/es/view/mark-animate-mixin.d.ts +0 -1
  249. package/es/view/mark-animate-mixin.js +0 -25
  250. package/es/view/mark-animate-mixin.js.map +0 -1
  251. package/es/view/view-animate-mixin.d.ts +0 -1
  252. package/es/view/view-animate-mixin.js +0 -16
  253. package/es/view/view-animate-mixin.js.map +0 -1
  254. package/es/view/view-event-mixin.d.ts +0 -1
  255. package/es/view/view-event-mixin.js +0 -90
  256. package/es/view/view-event-mixin.js.map +0 -1
  257. package/es/view/view-morph-mixin.d.ts +0 -1
  258. package/es/view/view-morph-mixin.js +0 -22
  259. package/es/view/view-morph-mixin.js.map +0 -1
package/es/view/View.js CHANGED
@@ -1,9 +1,11 @@
1
- import { EventEmitter, debounce, isString, getContainerSize, Logger, array, isNil, isArray } from "@visactor/vutils";
1
+ import { EventEmitter, debounce, isObject, isString, getContainerSize, Logger, array, isNil } 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
+
7
9
  import Dataflow from "./dataflow";
8
10
 
9
11
  import { traverseMarkTree } from "../graph/mark-tree";
@@ -14,13 +16,15 @@ import CanvasRenderer from "../graph/canvas-renderer";
14
16
 
15
17
  import getExtendedEvents from "../graph/util/events-extend";
16
18
 
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";
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";
18
20
 
19
21
  import { Signal } from "./signal";
20
22
 
21
23
  import { BuiltInSignalID, builtInSignals, normalizeMarkTree, normalizeRunningConfig, normalizePadding } from "../parse/view";
22
24
 
23
- import { isGrammar } from "../parse/util";
25
+ import { parseHandler, parseEventSelector, generateFilterByMark, ID_PREFIX, NAME_PREFIX } from "../parse/event";
26
+
27
+ import { isGrammar, parseReference } from "../parse/util";
24
28
 
25
29
  import { configureEnvironment } from "../graph/util/env";
26
30
 
@@ -28,8 +32,16 @@ import { GroupMark } from "./group";
28
32
 
29
33
  import { Mark } from "./mark";
30
34
 
35
+ import { defaultDoLayout } from "../graph/layout/layout";
36
+
37
+ import { GlyphMark } from "./glyph";
38
+
39
+ import { Morph } from "../graph/animation/morph";
40
+
31
41
  import { RecordedGrammars, RecordedTreeGrammars } from "./grammar-record";
32
42
 
43
+ import { ViewAnimate } from "./animate";
44
+
33
45
  import { ComponentEnum, HOOK_EVENT, LayoutState, GrammarMarkType } from "../graph/enums";
34
46
 
35
47
  import { Text } from "../semantic-marks/text";
@@ -42,8 +54,6 @@ import { Component } from "./component";
42
54
 
43
55
  import { isMarkType, removeGraphicItem } from "../graph/util/graphic";
44
56
 
45
- import { ViewDiff } from "../graph/view-diff";
46
-
47
57
  export default class View extends EventEmitter {
48
58
  static useRegisters(comps) {
49
59
  comps.forEach((fn => {
@@ -144,8 +154,7 @@ export default class View extends EventEmitter {
144
154
  break;
145
155
 
146
156
  case GrammarMarkType.glyph:
147
- const GlyphMark = Factory.getMark(GrammarMarkType.glyph);
148
- GlyphMark && (mark = new GlyphMark(this, null == markOptions ? void 0 : markOptions.glyphType, groupMark));
157
+ mark = new GlyphMark(this, null == markOptions ? void 0 : markOptions.glyphType, groupMark);
149
158
  break;
150
159
 
151
160
  case GrammarMarkType.component:
@@ -251,7 +260,7 @@ export default class View extends EventEmitter {
251
260
  })), this;
252
261
  }
253
262
  parseSpec(spec) {
254
- var _a, _b, _c, _d, _e, _f, _g, _h;
263
+ var _a, _b, _c, _d, _e, _f;
255
264
  if (this.emit(HOOK_EVENT.BEFORE_PARSE_VIEW), this._spec = spec, normalizeMarkTree(spec),
256
265
  spec.theme ? this.theme(spec.theme) : this.theme(ThemeManager.getDefaultTheme()),
257
266
  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),
@@ -279,13 +288,11 @@ export default class View extends EventEmitter {
279
288
  })), spec.marks && spec.marks.length && spec.marks.forEach((mark => {
280
289
  this.parseMarkSpec(mark);
281
290
  })), spec.events && spec.events.length && spec.events.forEach((eventConfig => {
282
- var _b;
283
- null === (_b = this.event) || void 0 === _b || _b.call(this, eventConfig);
291
+ this.event(eventConfig);
284
292
  })), spec.interactions && spec.interactions.length && spec.interactions.forEach((interaction => {
285
293
  this.interaction(interaction.type, interaction);
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;
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;
289
296
  }
290
297
  updateSpec(spec) {
291
298
  return this.removeAllInteractions(), this.removeAllGrammars(), this.parseSpec(spec);
@@ -405,7 +412,7 @@ export default class View extends EventEmitter {
405
412
  }
406
413
  doLayout() {
407
414
  var _a;
408
- const doLayout = this._options.doLayout || Factory.getDefaultLayout();
415
+ const doLayout = this._options.doLayout || defaultDoLayout;
409
416
  doLayout && (null === (_a = this._layoutMarks) || void 0 === _a ? void 0 : _a.length) && (this.emit(HOOK_EVENT.BEFORE_DO_LAYOUT),
410
417
  doLayout(this._layoutMarks, this._options, this), this.emit(HOOK_EVENT.AFTER_DO_LAYOUT));
411
418
  }
@@ -428,11 +435,11 @@ export default class View extends EventEmitter {
428
435
  return this.evaluate(runningConfig), this;
429
436
  }
430
437
  doRender(immediately) {
431
- this.emit(HOOK_EVENT.BEFORE_DO_RENDER), this.renderer && (!this._progressiveMarks && this.animate && this.animate.animate(),
438
+ this.emit(HOOK_EVENT.BEFORE_DO_RENDER), this.renderer && (this._progressiveMarks || this.animate.animate(),
432
439
  this.renderer.render(immediately), this.handleRenderEnd()), this.emit(HOOK_EVENT.AFTER_DO_RENDER);
433
440
  }
434
441
  evaluate(runningConfig) {
435
- var _a, _c;
442
+ var _a, _b;
436
443
  const normalizedRunningConfig = normalizeRunningConfig(runningConfig), grammarWillDetach = this._cachedGrammars.size() > 0;
437
444
  grammarWillDetach && (this.reuseCachedGrammars(normalizedRunningConfig), this.detachCachedGrammar());
438
445
  const hasResize = this._resizeRenderer(), hasUpdate = this._dataflow.hasCommitted();
@@ -441,28 +448,28 @@ export default class View extends EventEmitter {
441
448
  this._needBuildLayoutTree = !1), this._layoutState && (this._layoutState = LayoutState.layouting,
442
449
  this.doLayout(), this._dataflow.hasCommitted() && (this._layoutState = LayoutState.reevaluate,
443
450
  this._dataflow.evaluate()), this._layoutState = LayoutState.after, (null === (_a = this._layoutMarks) || void 0 === _a ? void 0 : _a.length) && this.handleLayoutEnd()),
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;
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;
447
455
  }
448
456
  reuseCachedGrammars(runningConfig) {
449
- if (runningConfig.reuse) {
457
+ if (this._willMorphMarks || (this._willMorphMarks = []), runningConfig.reuse) {
450
458
  const reuseDiffUpdate = diff => {
451
459
  diff.next.reuse(diff.prev), diff.prev.detachAll(), diff.prev.clear(), this._cachedGrammars.unrecord(diff.prev);
452
460
  };
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);
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);
457
465
  }
458
- this._differ.diffMark(this._cachedGrammars.getAllMarks(), this.grammars.getAllMarks().filter((mark => "root" !== mark.id())), runningConfig).update.forEach((diff => {
459
- var _b;
466
+ this._morph.diffMark(this._cachedGrammars.getAllMarks(), this.grammars.getAllMarks().filter((mark => "root" !== mark.id())), runningConfig).update.forEach((diff => {
460
467
  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));
461
468
  matched && runningConfig.reuse ? (diff.next[0].reuse(diff.prev[0]), diff.prev[0].detachAll(),
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, {
469
+ diff.prev[0].clear(), this._cachedGrammars.unrecord(diff.prev[0])) : (runningConfig.morph && enableMarkMorphConfig || runningConfig.morphAll) && this._willMorphMarks.push({
463
470
  prev: diff.prev,
464
471
  next: diff.next
465
- }));
472
+ });
466
473
  }));
467
474
  }
468
475
  detachCachedGrammar() {
@@ -480,11 +487,10 @@ export default class View extends EventEmitter {
480
487
  }));
481
488
  const markNodes = this._cachedGrammars.getAllMarkNodes();
482
489
  markNodes.forEach((node => {
483
- var _a;
484
- null === (_a = node.mark.animate) || void 0 === _a || _a.stop(), runningConfig.enableExitAnimation && this.animate && this.animate.animateAddition(node.mark);
490
+ node.mark.animate.stop(), runningConfig.enableExitAnimation && this.animate.animateAddition(node.mark);
485
491
  }));
486
492
  const releaseUp = node => {
487
- if (node.mark.view && (!node.mark.animate || 0 === node.mark.animate.getAnimatorCount()) && (!node.children || 0 === node.children.length)) {
493
+ if (node.mark.view && 0 === node.mark.animate.getAnimatorCount() && (!node.children || 0 === node.children.length)) {
488
494
  node.mark.release();
489
495
  const parent = node.parent;
490
496
  parent && (node.parent.children = node.parent.children.filter((n => n !== node)),
@@ -493,8 +499,8 @@ export default class View extends EventEmitter {
493
499
  };
494
500
  markNodes.forEach((node => {
495
501
  const mark = node.mark;
496
- mark.animate && 0 === mark.animate.getAnimatorCount() ? releaseUp(node) : mark.addEventListener("animationEnd", (() => {
497
- mark.animate && 0 === mark.animate.getAnimatorCount() && releaseUp(node);
502
+ 0 === mark.animate.getAnimatorCount() ? releaseUp(node) : mark.addEventListener("animationEnd", (() => {
503
+ 0 === mark.animate.getAnimatorCount() && releaseUp(node);
498
504
  }));
499
505
  })), this._cachedGrammars.clear();
500
506
  }
@@ -562,6 +568,73 @@ export default class View extends EventEmitter {
562
568
  height: height
563
569
  }), !0);
564
570
  }
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
+ }
565
638
  interaction(type, spec) {
566
639
  const interaction = Factory.createInteraction(type, this, spec);
567
640
  return interaction && (interaction.bind(), this._boundInteractions || (this._boundInteractions = []),
@@ -584,17 +657,6 @@ export default class View extends EventEmitter {
584
657
  instance.unbind();
585
658
  })), this._boundInteractions = null), this;
586
659
  }
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
- }
598
660
  initEvent() {
599
661
  const stage = this.renderer.stage();
600
662
  stage && stage.on("*", this.delegateEvent);
@@ -617,15 +679,15 @@ export default class View extends EventEmitter {
617
679
  this.renderer = new CanvasRenderer(this), this.renderer.initialize(width, height, this._options, this._eventConfig).background(this._background);
618
680
  }
619
681
  initialize() {
620
- var _a, _c;
682
+ var _a;
621
683
  this.grammars = new RecordedGrammars((grammar => grammar.id()), ((key, grammar) => this.logger.warn(`Grammar id '${key}' has been occupied`, grammar))),
622
684
  this._cachedGrammars = new RecordedTreeGrammars((grammar => grammar.id())), this._options.logger && Logger.setInstance(this._options.logger),
623
685
  this.logger = Logger.getInstance(null !== (_a = this._options.logLevel) && void 0 !== _a ? _a : 0),
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 => {
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 => {
626
688
  this.on(key, this._options.hooks[key]);
627
689
  })), this.hooks = this._options.hooks), this.container = null, this.renderer = null,
628
- this._eventListeners = [], this._eventConfig = this.initializeEventConfig(this._options.eventConfig),
690
+ this._eventListeners = [], this._eventConfig = initializeEventConfig(this._options.eventConfig),
629
691
  this._theme = this._options.disableTheme ? null : ThemeManager.getDefaultTheme(),
630
692
  this.parseBuiltIn(), configureEnvironment(this._options), this.initializeRenderer(),
631
693
  this._eventConfig.disable || this.initEvent(), this._bindResizeEvent(), this._needBuildLayoutTree = !0,
@@ -663,14 +725,13 @@ export default class View extends EventEmitter {
663
725
  })), this._progressiveMarks = null);
664
726
  }
665
727
  release() {
666
- var _a, _b, _c, _d;
728
+ var _a, _b, _c;
667
729
  this.removeAllInteractions(), this.releaseStageEvent(), this._unBindResizeEvent(),
668
730
  this.clearProgressive(), Factory.unregisterRuntimeTransforms(), Logger.setInstance(null),
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),
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),
672
733
  this.renderer = null, this._boundInteractions = null, this.removeAllListeners(),
673
- null === (_d = this._eventListeners) || void 0 === _d || _d.forEach((listener => {
734
+ null === (_c = this._eventListeners) || void 0 === _c || _c.forEach((listener => {
674
735
  listener.source.removeEventListener(listener.type, listener.handler);
675
736
  })), this._eventListeners = null;
676
737
  }