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

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 (245) 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.js.map +1 -1
  49. package/cjs/graph/canvas-renderer.d.ts +1 -1
  50. package/cjs/graph/canvas-renderer.js +4 -4
  51. package/cjs/graph/canvas-renderer.js.map +1 -1
  52. package/cjs/graph/element.d.ts +2 -1
  53. package/cjs/graph/element.js +20 -19
  54. package/cjs/graph/element.js.map +1 -1
  55. package/cjs/graph/glyph-element.js +3 -4
  56. package/cjs/graph/glyph-element.js.map +1 -1
  57. package/cjs/graph/layout/layout.d.ts +0 -1
  58. package/cjs/graph/layout/layout.js +2 -8
  59. package/cjs/graph/layout/layout.js.map +1 -1
  60. package/cjs/graph/mark/graphic.js +8 -14
  61. package/cjs/graph/mark/graphic.js.map +1 -1
  62. package/cjs/graph/util/element.d.ts +2 -0
  63. package/cjs/graph/util/element.js +10 -0
  64. package/cjs/graph/util/element.js.map +1 -0
  65. package/cjs/graph/util/point.js +26 -10
  66. package/cjs/graph/util/point.js.map +1 -1
  67. package/cjs/index.d.ts +1 -8
  68. package/cjs/index.js +2 -66
  69. package/cjs/index.js.map +1 -1
  70. package/cjs/interactions/brush-base.js +2 -1
  71. package/cjs/interactions/brush-filter.js +1 -2
  72. package/cjs/interactions/fish-eye.js +2 -1
  73. package/cjs/interactions/index.js +1 -2
  74. package/cjs/interactions/tooltip.js +1 -1
  75. package/cjs/parse/event.d.ts +2 -0
  76. package/cjs/parse/event.js +10 -4
  77. package/cjs/parse/event.js.map +1 -1
  78. package/cjs/parse/util.js.map +1 -1
  79. package/cjs/types/animate.d.ts +1 -0
  80. package/cjs/types/animate.js.map +1 -1
  81. package/cjs/types/element.d.ts +5 -1
  82. package/cjs/types/element.js.map +1 -1
  83. package/cjs/types/morph.d.ts +2 -1
  84. package/cjs/types/morph.js.map +1 -1
  85. package/cjs/types/renderer.d.ts +1 -6
  86. package/cjs/types/renderer.js.map +1 -1
  87. package/cjs/view/View.d.ts +6 -3
  88. package/cjs/view/View.js +105 -52
  89. package/cjs/view/View.js.map +1 -1
  90. package/cjs/view/animate.js +1 -2
  91. package/cjs/view/animate.js.map +1 -1
  92. package/cjs/view/constants.d.ts +0 -2
  93. package/cjs/view/constants.js +2 -3
  94. package/cjs/view/constants.js.map +1 -1
  95. package/cjs/view/events.d.ts +1 -0
  96. package/cjs/view/events.js +17 -3
  97. package/cjs/view/events.js.map +1 -1
  98. package/cjs/view/glyph.d.ts +0 -4
  99. package/cjs/view/glyph.js +3 -12
  100. package/cjs/view/glyph.js.map +1 -1
  101. package/cjs/view/grammar-record.js +2 -3
  102. package/cjs/view/grammar-record.js.map +1 -1
  103. package/cjs/view/group.js +3 -3
  104. package/cjs/view/group.js.map +1 -1
  105. package/cjs/view/mark.d.ts +0 -2
  106. package/cjs/view/mark.js +28 -31
  107. package/cjs/view/mark.js.map +1 -1
  108. package/es/component/axis.d.ts +0 -2
  109. package/es/component/axis.js +0 -10
  110. package/es/component/axis.js.map +1 -1
  111. package/es/component/grid.d.ts +0 -2
  112. package/es/component/grid.js +0 -10
  113. package/es/component/grid.js.map +1 -1
  114. package/es/component/index.d.ts +2 -2
  115. package/es/component/index.js +2 -2
  116. package/es/component/index.js.map +1 -1
  117. package/es/core/factory.d.ts +1 -8
  118. package/es/core/factory.js +1 -8
  119. package/es/core/factory.js.map +1 -1
  120. package/es/glyph/boxplot.js +2 -4
  121. package/es/glyph/boxplot.js.map +1 -1
  122. package/es/glyph/link-path.js +2 -4
  123. package/es/glyph/link-path.js.map +1 -1
  124. package/es/glyph/ripple.js +1 -3
  125. package/es/glyph/ripple.js.map +1 -1
  126. package/es/glyph/tree-path.js +2 -4
  127. package/es/glyph/tree-path.js.map +1 -1
  128. package/es/glyph/violin.js +2 -4
  129. package/es/glyph/violin.js.map +1 -1
  130. package/es/glyph/wave.js +1 -3
  131. package/es/glyph/wave.js.map +1 -1
  132. package/es/graph/animation/animation/fade.js +4 -4
  133. package/es/graph/animation/animation/fade.js.map +1 -1
  134. package/es/graph/animation/animation/grow-cartesian.js +14 -14
  135. package/es/graph/animation/animation/grow-cartesian.js.map +1 -1
  136. package/es/graph/animation/animation/grow-interval.js +9 -9
  137. package/es/graph/animation/animation/grow-interval.js.map +1 -1
  138. package/es/graph/animation/animation/grow-points.js +9 -9
  139. package/es/graph/animation/animation/grow-points.js.map +1 -1
  140. package/es/graph/animation/animation/grow-polar.js +24 -24
  141. package/es/graph/animation/animation/grow-polar.js.map +1 -1
  142. package/es/graph/animation/animation/move.js +6 -6
  143. package/es/graph/animation/animation/move.js.map +1 -1
  144. package/es/graph/animation/animation/rotate.js +4 -4
  145. package/es/graph/animation/animation/rotate.js.map +1 -1
  146. package/es/graph/animation/animation/scale.js +5 -5
  147. package/es/graph/animation/animation/scale.js.map +1 -1
  148. package/es/graph/animation/animation/update.js +3 -1
  149. package/es/graph/animation/animation/update.js.map +1 -1
  150. package/es/graph/animation/animator.js +6 -1
  151. package/es/graph/animation/animator.js.map +1 -1
  152. package/es/graph/animation/morph.d.ts +12 -2
  153. package/es/graph/animation/morph.js +159 -72
  154. package/es/graph/animation/morph.js.map +1 -1
  155. package/es/graph/attributes/line.js.map +1 -1
  156. package/es/graph/canvas-renderer.d.ts +1 -1
  157. package/es/graph/canvas-renderer.js +5 -5
  158. package/es/graph/canvas-renderer.js.map +1 -1
  159. package/es/graph/element.d.ts +2 -1
  160. package/es/graph/element.js +20 -17
  161. package/es/graph/element.js.map +1 -1
  162. package/es/graph/glyph-element.js +5 -3
  163. package/es/graph/glyph-element.js.map +1 -1
  164. package/es/graph/layout/layout.d.ts +0 -1
  165. package/es/graph/layout/layout.js +0 -6
  166. package/es/graph/layout/layout.js.map +1 -1
  167. package/es/graph/mark/graphic.js +7 -13
  168. package/es/graph/mark/graphic.js.map +1 -1
  169. package/es/graph/util/element.d.ts +2 -0
  170. package/es/graph/util/element.js +8 -0
  171. package/es/graph/util/element.js.map +1 -0
  172. package/es/graph/util/point.js +26 -10
  173. package/es/graph/util/point.js.map +1 -1
  174. package/es/index.d.ts +1 -8
  175. package/es/index.js +1 -29
  176. package/es/index.js.map +1 -1
  177. package/es/interactions/element-active.js +2 -1
  178. package/es/interactions/element-highlight-by-group.js +1 -2
  179. package/es/interactions/fish-eye.js +1 -1
  180. package/es/parse/event.d.ts +2 -0
  181. package/es/parse/event.js +7 -3
  182. package/es/parse/event.js.map +1 -1
  183. package/es/parse/option.js +2 -1
  184. package/es/parse/scale.js +1 -2
  185. package/es/parse/util.js.map +1 -1
  186. package/es/types/animate.d.ts +1 -0
  187. package/es/types/animate.js.map +1 -1
  188. package/es/types/element.d.ts +5 -1
  189. package/es/types/element.js.map +1 -1
  190. package/es/types/morph.d.ts +2 -1
  191. package/es/types/morph.js.map +1 -1
  192. package/es/types/renderer.d.ts +1 -6
  193. package/es/types/renderer.js.map +1 -1
  194. package/es/view/View.d.ts +6 -3
  195. package/es/view/View.js +114 -53
  196. package/es/view/View.js.map +1 -1
  197. package/es/view/animate.js +1 -2
  198. package/es/view/animate.js.map +1 -1
  199. package/es/view/constants.d.ts +0 -2
  200. package/es/view/constants.js +0 -4
  201. package/es/view/constants.js.map +1 -1
  202. package/es/view/events.d.ts +1 -0
  203. package/es/view/events.js +15 -1
  204. package/es/view/events.js.map +1 -1
  205. package/es/view/glyph.d.ts +0 -4
  206. package/es/view/glyph.js +0 -11
  207. package/es/view/glyph.js.map +1 -1
  208. package/es/view/grammar-record.js +2 -3
  209. package/es/view/grammar-record.js.map +1 -1
  210. package/es/view/group.js +4 -2
  211. package/es/view/group.js.map +1 -1
  212. package/es/view/mark.d.ts +0 -2
  213. package/es/view/mark.js +30 -32
  214. package/es/view/mark.js.map +1 -1
  215. package/package.json +12 -12
  216. package/cjs/graph/view-diff.d.ts +0 -8
  217. package/cjs/graph/view-diff.js +0 -93
  218. package/cjs/graph/view-diff.js.map +0 -1
  219. package/cjs/view/mark-animate-mixin.d.ts +0 -1
  220. package/cjs/view/mark-animate-mixin.js +0 -29
  221. package/cjs/view/mark-animate-mixin.js.map +0 -1
  222. package/cjs/view/view-animate-mixin.d.ts +0 -1
  223. package/cjs/view/view-animate-mixin.js +0 -26
  224. package/cjs/view/view-animate-mixin.js.map +0 -1
  225. package/cjs/view/view-event-mixin.d.ts +0 -1
  226. package/cjs/view/view-event-mixin.js +0 -92
  227. package/cjs/view/view-event-mixin.js.map +0 -1
  228. package/cjs/view/view-morph-mixin.d.ts +0 -1
  229. package/cjs/view/view-morph-mixin.js +0 -32
  230. package/cjs/view/view-morph-mixin.js.map +0 -1
  231. package/es/graph/view-diff.d.ts +0 -8
  232. package/es/graph/view-diff.js +0 -89
  233. package/es/graph/view-diff.js.map +0 -1
  234. package/es/view/mark-animate-mixin.d.ts +0 -1
  235. package/es/view/mark-animate-mixin.js +0 -25
  236. package/es/view/mark-animate-mixin.js.map +0 -1
  237. package/es/view/view-animate-mixin.d.ts +0 -1
  238. package/es/view/view-animate-mixin.js +0 -16
  239. package/es/view/view-animate-mixin.js.map +0 -1
  240. package/es/view/view-event-mixin.d.ts +0 -1
  241. package/es/view/view-event-mixin.js +0 -90
  242. package/es/view/view-event-mixin.js.map +0 -1
  243. package/es/view/view-morph-mixin.d.ts +0 -1
  244. package/es/view/view-morph-mixin.js +0 -22
  245. package/es/view/view-morph-mixin.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import type { IBoundsLike } from '@visactor/vutils';
2
- import type { IColor, IEventTarget, Stage } from '@visactor/vrender-core';
2
+ import type { IColor, Stage } from '@visactor/vrender-core';
3
3
  import type { IViewEventConfig, IViewOptions } from './view';
4
4
  export interface IRenderer {
5
5
  initialize: (width: number, height: number, options: IViewOptions, eventConfig: IViewEventConfig) => this;
@@ -18,8 +18,3 @@ export interface IRenderer {
18
18
  toCanvas: () => HTMLCanvasElement;
19
19
  release: () => void;
20
20
  }
21
- export interface IStageEventPlugin<T> {
22
- new (taget: IEventTarget, cfg?: T): {
23
- release: () => void;
24
- };
25
- }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types/renderer.ts"],"names":[],"mappings":"","file":"renderer.js","sourcesContent":["import type { IBoundsLike } from '@visactor/vutils';\nimport type { IColor, IEventTarget, Stage } from '@visactor/vrender-core';\nimport type { IViewEventConfig, IViewOptions } from './view';\n\nexport interface IRenderer {\n initialize: (width: number, height: number, options: IViewOptions, eventConfig: IViewEventConfig) => this;\n\n render: (immediately?: boolean) => this;\n renderNextFrame: () => this;\n resize: (width: number, height: number) => this;\n shouldResize: (width: number, height: number) => boolean;\n combineIncrementalLayers: () => this;\n preventRender: (tag: boolean) => void;\n\n setDpr: (resolution: number, redraw: boolean) => this;\n background: (color: IColor) => this;\n setViewBox: (viewBox: IBoundsLike, rerender: boolean) => this;\n\n stage: () => Stage;\n canvas: () => HTMLCanvasElement;\n context: () => CanvasRenderingContext2D;\n\n toCanvas: () => HTMLCanvasElement;\n // toImageData: () => Promise<ImageData | undefined>;\n\n release: () => void;\n}\n\nexport interface IStageEventPlugin<T> {\n new (taget: IEventTarget, cfg?: T): {\n release: () => void;\n };\n}\n"]}
1
+ {"version":3,"sources":["../src/types/renderer.ts"],"names":[],"mappings":"","file":"renderer.js","sourcesContent":["import type { IBoundsLike } from '@visactor/vutils';\nimport type { IColor, Stage } from '@visactor/vrender-core';\nimport type { IViewEventConfig, IViewOptions } from './view';\n\nexport interface IRenderer {\n initialize: (width: number, height: number, options: IViewOptions, eventConfig: IViewEventConfig) => this;\n\n render: (immediately?: boolean) => this;\n renderNextFrame: () => this;\n resize: (width: number, height: number) => this;\n shouldResize: (width: number, height: number) => boolean;\n combineIncrementalLayers: () => this;\n preventRender: (tag: boolean) => void;\n\n setDpr: (resolution: number, redraw: boolean) => this;\n background: (color: IColor) => this;\n setViewBox: (viewBox: IBoundsLike, rerender: boolean) => this;\n\n stage: () => Stage;\n canvas: () => HTMLCanvasElement;\n context: () => CanvasRenderingContext2D;\n\n toCanvas: () => HTMLCanvasElement;\n // toImageData: () => Promise<ImageData | undefined>;\n\n release: () => void;\n}\n"]}
package/es/view/View.d.ts CHANGED
@@ -2,7 +2,7 @@ import type { IBounds, ILogger } from '@visactor/vutils';
2
2
  import { EventEmitter } from '@visactor/vutils';
3
3
  import type { IColor } from '@visactor/vrender-core';
4
4
  import type { CoordinateType } from '@visactor/vgrammar-coordinate';
5
- import type { IData, ISignal, ViewSpec, IView, IViewOptions, IViewThemeConfig, Hooks, IMark, MarkType, GrammarScaleType, SignalFunctionType, IScale, IGrammarBase, IGroupMark, IGlyphMark, ICoordinate, BaseEventHandler, IRecordedGrammars, IComponent, IRunningConfig, IViewAnimate, ITheme, InteractionSpec, IInteraction } from '../types/';
5
+ import type { IData, ISignal, ViewSpec, IView, IViewOptions, IViewThemeConfig, Hooks, IMark, EventSpec, MarkType, GrammarScaleType, SignalFunctionType, IScale, IGrammarBase, IGroupMark, IGlyphMark, ICoordinate, BaseEventHandler, IRecordedGrammars, IComponent, IRunningConfig, IViewAnimate, ITheme, InteractionSpec, IInteraction } from '../types/';
6
6
  import type { IRenderer } from '../types/renderer';
7
7
  import { LayoutState } from '../graph/enums';
8
8
  import type { IAxis, IDatazoom, IGrid, ILabel, ILegend, IPlayer, IScrollbar, ISlider, ITitle } from '../types/component';
@@ -18,7 +18,8 @@ export default class View extends EventEmitter implements IView {
18
18
  private _config;
19
19
  private _options;
20
20
  private _cachedGrammars;
21
- private _differ;
21
+ private _willMorphMarks;
22
+ private _morph;
22
23
  private _eventConfig;
23
24
  private _eventListeners;
24
25
  private _theme;
@@ -27,6 +28,7 @@ export default class View extends EventEmitter implements IView {
27
28
  private _layoutState?;
28
29
  private _layoutMarks?;
29
30
  private _background?;
31
+ private _eventCache;
30
32
  private _progressiveMarks?;
31
33
  private _progressiveRafId?;
32
34
  private _observer;
@@ -120,10 +122,11 @@ export default class View extends EventEmitter implements IView {
120
122
  private _onResize;
121
123
  resize(width: number, height: number, render?: boolean): this;
122
124
  private _resizeRenderer;
125
+ private bindEvents;
126
+ event(eventSpec: EventSpec): void;
123
127
  interaction(type: string, spec: Partial<InteractionSpec>): IInteraction<any>;
124
128
  removeInteraction(type: string | IInteraction, id?: string): this;
125
129
  removeAllInteractions(): this;
126
- initializeEventConfig(config: any): any;
127
130
  private initEvent;
128
131
  private releaseStageEvent;
129
132
  private delegateEvent;
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
  }