@antv/g 5.0.1 → 5.0.5

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 (177) hide show
  1. package/LICENSE +21 -0
  2. package/dist/index.umd.js +2 -2
  3. package/es/AbstractRenderer.d.ts +7 -7
  4. package/es/Canvas.d.ts +15 -5
  5. package/es/Canvas.js +10 -5
  6. package/es/camera/Camera.js +3 -5
  7. package/es/components/Geometry.d.ts +1 -1
  8. package/es/components/Renderable.d.ts +1 -1
  9. package/es/display-objects/CustomElement.d.ts +7 -8
  10. package/es/display-objects/CustomElement.js +24 -11
  11. package/es/display-objects/DisplayObject.d.ts +5 -7
  12. package/es/display-objects/DisplayObject.js +20 -12
  13. package/es/display-objects/Group.d.ts +1 -1
  14. package/es/display-objects/HTML.d.ts +1 -1
  15. package/es/display-objects/Image.d.ts +1 -1
  16. package/es/display-objects/Path.d.ts +1 -1
  17. package/es/display-objects/Polygon.d.ts +1 -1
  18. package/es/display-objects/Polyline.d.ts +1 -1
  19. package/es/display-objects/Text.d.ts +1 -1
  20. package/es/display-objects/Text.js +1 -1
  21. package/es/dom/Animation.js +9 -4
  22. package/es/dom/AnimationEffectTiming.d.ts +0 -1
  23. package/es/dom/AnimationTimeline.js +2 -1
  24. package/es/dom/CustomElementRegistry.d.ts +1 -1
  25. package/es/dom/CustomEvent.js +2 -1
  26. package/es/dom/Document.d.ts +3 -3
  27. package/es/dom/Document.js +13 -6
  28. package/es/dom/Element.d.ts +11 -12
  29. package/es/dom/Element.js +12 -8
  30. package/es/dom/EventTarget.js +1 -0
  31. package/es/dom/FederatedEvent.d.ts +1 -1
  32. package/es/dom/KeyframeEffect.js +1 -1
  33. package/es/dom/Node.d.ts +10 -10
  34. package/es/dom/Node.js +11 -5
  35. package/es/dom/interfaces.d.ts +63 -63
  36. package/es/global-module.d.ts +4 -0
  37. package/es/global-module.js +57 -69
  38. package/es/plugins/CullingPlugin.d.ts +3 -3
  39. package/es/plugins/DirtyCheckPlugin.d.ts +1 -1
  40. package/es/plugins/EventPlugin.d.ts +2 -1
  41. package/es/plugins/FrustumCullingStrategy.d.ts +1 -2
  42. package/es/plugins/FrustumCullingStrategy.js +31 -32
  43. package/es/plugins/PrepareRendererPlugin.d.ts +1 -1
  44. package/es/plugins/PrepareRendererPlugin.js +7 -20
  45. package/es/property-handlers/aabb.js +16 -19
  46. package/es/property-handlers/anchor.d.ts +2 -1
  47. package/es/property-handlers/anchor.js +2 -2
  48. package/es/property-handlers/clipPath.js +2 -2
  49. package/es/property-handlers/color.d.ts +3 -4
  50. package/es/property-handlers/color.js +2 -2
  51. package/es/property-handlers/filter.d.ts +3 -4
  52. package/es/property-handlers/filter.js +2 -2
  53. package/es/property-handlers/interfaces.d.ts +1 -1
  54. package/es/property-handlers/lineDash.d.ts +1 -2
  55. package/es/property-handlers/lineDash.js +1 -1
  56. package/es/property-handlers/path.d.ts +2 -3
  57. package/es/property-handlers/path.js +2 -2
  58. package/es/property-handlers/points.d.ts +1 -2
  59. package/es/property-handlers/points.js +1 -1
  60. package/es/property-handlers/transform.d.ts +1 -1
  61. package/es/property-handlers/transform.js +0 -5
  62. package/es/services/ContextService.d.ts +8 -8
  63. package/es/services/EventService.d.ts +2 -2
  64. package/es/services/RenderingContext.d.ts +2 -2
  65. package/es/services/RenderingService.d.ts +23 -18
  66. package/es/services/RenderingService.js +18 -4
  67. package/es/services/SceneGraphSelector.d.ts +5 -5
  68. package/es/services/SceneGraphSelector.js +3 -2
  69. package/es/services/SceneGraphService.d.ts +36 -34
  70. package/es/services/SceneGraphService.js +33 -4
  71. package/es/services/aabb/PathUpdater.d.ts +1 -2
  72. package/es/services/aabb/PathUpdater.js +1 -1
  73. package/es/services/aabb/interfaces.d.ts +1 -1
  74. package/es/services/text/index.js +1 -1
  75. package/es/shapes/AABB.d.ts +3 -2
  76. package/es/shapes/Frustum.d.ts +1 -1
  77. package/es/shapes/Polygon.d.ts +1 -1
  78. package/es/shapes/Ray.d.ts +3 -3
  79. package/es/types.d.ts +1 -2
  80. package/es/utils/custom-easing.d.ts +3 -5
  81. package/es/utils/custom-easing.js +2 -1
  82. package/es/utils/event.d.ts +1 -1
  83. package/es/utils/interpolation.js +16 -16
  84. package/es/utils/math.d.ts +2 -1
  85. package/es/utils/math.js +1 -2
  86. package/es/utils/path.d.ts +1 -1
  87. package/es/utils/path.js +4 -7
  88. package/es/utils/raf.js +2 -1
  89. package/lib/AbstractRenderer.d.ts +7 -7
  90. package/lib/Canvas.d.ts +15 -5
  91. package/lib/Canvas.js +10 -5
  92. package/lib/camera/Camera.js +4 -5
  93. package/lib/components/Geometry.d.ts +1 -1
  94. package/lib/components/Renderable.d.ts +1 -1
  95. package/lib/display-objects/CustomElement.d.ts +7 -8
  96. package/lib/display-objects/CustomElement.js +24 -11
  97. package/lib/display-objects/DisplayObject.d.ts +5 -7
  98. package/lib/display-objects/DisplayObject.js +19 -11
  99. package/lib/display-objects/Group.d.ts +1 -1
  100. package/lib/display-objects/HTML.d.ts +1 -1
  101. package/lib/display-objects/Image.d.ts +1 -1
  102. package/lib/display-objects/Path.d.ts +1 -1
  103. package/lib/display-objects/Polygon.d.ts +1 -1
  104. package/lib/display-objects/Polyline.d.ts +1 -1
  105. package/lib/display-objects/Text.d.ts +1 -1
  106. package/lib/display-objects/Text.js +1 -1
  107. package/lib/dom/Animation.js +9 -4
  108. package/lib/dom/AnimationEffectTiming.d.ts +0 -1
  109. package/lib/dom/AnimationTimeline.js +2 -1
  110. package/lib/dom/CustomElementRegistry.d.ts +1 -1
  111. package/lib/dom/CustomEvent.js +1 -1
  112. package/lib/dom/Document.d.ts +3 -3
  113. package/lib/dom/Document.js +13 -6
  114. package/lib/dom/Element.d.ts +11 -12
  115. package/lib/dom/Element.js +12 -8
  116. package/lib/dom/EventTarget.js +1 -0
  117. package/lib/dom/FederatedEvent.d.ts +1 -1
  118. package/lib/dom/KeyframeEffect.js +1 -1
  119. package/lib/dom/Node.d.ts +10 -10
  120. package/lib/dom/Node.js +11 -5
  121. package/lib/dom/interfaces.d.ts +63 -63
  122. package/lib/global-module.d.ts +4 -0
  123. package/lib/global-module.js +57 -69
  124. package/lib/plugins/CullingPlugin.d.ts +3 -3
  125. package/lib/plugins/DirtyCheckPlugin.d.ts +1 -1
  126. package/lib/plugins/EventPlugin.d.ts +2 -1
  127. package/lib/plugins/FrustumCullingStrategy.d.ts +1 -2
  128. package/lib/plugins/FrustumCullingStrategy.js +28 -30
  129. package/lib/plugins/PrepareRendererPlugin.d.ts +1 -1
  130. package/lib/plugins/PrepareRendererPlugin.js +6 -19
  131. package/lib/property-handlers/aabb.js +15 -19
  132. package/lib/property-handlers/anchor.d.ts +2 -1
  133. package/lib/property-handlers/anchor.js +2 -2
  134. package/lib/property-handlers/clipPath.js +2 -2
  135. package/lib/property-handlers/color.d.ts +3 -4
  136. package/lib/property-handlers/color.js +2 -2
  137. package/lib/property-handlers/filter.d.ts +3 -4
  138. package/lib/property-handlers/filter.js +2 -2
  139. package/lib/property-handlers/interfaces.d.ts +1 -1
  140. package/lib/property-handlers/lineDash.d.ts +1 -2
  141. package/lib/property-handlers/lineDash.js +1 -1
  142. package/lib/property-handlers/path.d.ts +2 -3
  143. package/lib/property-handlers/path.js +2 -2
  144. package/lib/property-handlers/points.d.ts +1 -2
  145. package/lib/property-handlers/points.js +1 -1
  146. package/lib/property-handlers/transform.d.ts +1 -1
  147. package/lib/property-handlers/transform.js +0 -4
  148. package/lib/services/ContextService.d.ts +8 -8
  149. package/lib/services/EventService.d.ts +2 -2
  150. package/lib/services/RenderingContext.d.ts +2 -2
  151. package/lib/services/RenderingService.d.ts +23 -18
  152. package/lib/services/RenderingService.js +18 -4
  153. package/lib/services/SceneGraphSelector.d.ts +5 -5
  154. package/lib/services/SceneGraphSelector.js +3 -2
  155. package/lib/services/SceneGraphService.d.ts +36 -34
  156. package/lib/services/SceneGraphService.js +35 -4
  157. package/lib/services/aabb/PathUpdater.d.ts +1 -2
  158. package/lib/services/aabb/PathUpdater.js +1 -1
  159. package/lib/services/aabb/interfaces.d.ts +1 -1
  160. package/lib/services/text/index.js +1 -1
  161. package/lib/shapes/AABB.d.ts +3 -2
  162. package/lib/shapes/Frustum.d.ts +1 -1
  163. package/lib/shapes/Polygon.d.ts +1 -1
  164. package/lib/shapes/Ray.d.ts +3 -3
  165. package/lib/types.d.ts +1 -2
  166. package/lib/utils/custom-easing.d.ts +3 -5
  167. package/lib/utils/custom-easing.js +2 -1
  168. package/lib/utils/event.d.ts +1 -1
  169. package/lib/utils/interpolation.js +13 -18
  170. package/lib/utils/math.d.ts +2 -1
  171. package/lib/utils/math.js +1 -2
  172. package/lib/utils/path.d.ts +2 -2
  173. package/lib/utils/path.js +4 -7
  174. package/lib/utils/raf.js +2 -1
  175. package/package.json +6 -6
  176. package/lib/dom/__tests__/utils/easing.d.ts +0 -14
  177. package/lib/dom/__tests__/utils/keyframe.d.ts +0 -38
@@ -23,14 +23,24 @@ function (_super) {
23
23
  function CustomElement(config) {
24
24
  var _this = _super.call(this, config) || this;
25
25
 
26
- _this.handleMounted = function () {
27
- // this.shadowNodes.forEach((node) => {
28
- // // every child and its children should turn into a shadow node
29
- // // a shadow node doesn't mean to be unrenderable, it's just unsearchable in scenegraph
30
- // node.shadow = true;
31
- // });
32
- if (_this.connectedCallback) {
33
- _this.connectedCallback();
26
+ _this.handleMounted = function (e) {
27
+ if (e.target === e.currentTarget) {
28
+ // this.shadowNodes.forEach((node) => {
29
+ // // every child and its children should turn into a shadow node
30
+ // // a shadow node doesn't mean to be unrenderable, it's just unsearchable in scenegraph
31
+ // node.shadow = true;
32
+ // });
33
+ if (_this.connectedCallback) {
34
+ _this.connectedCallback();
35
+ }
36
+ }
37
+ };
38
+
39
+ _this.handleUnmounted = function (e) {
40
+ if (e.target === e.currentTarget) {
41
+ if (_this.disconnectedCallback) {
42
+ _this.disconnectedCallback();
43
+ }
34
44
  }
35
45
  }; // private handleChildInserted = (e: FederatedEvent) => {
36
46
  // (e.target as DisplayObject).forEach((node) => {
@@ -58,7 +68,10 @@ function (_super) {
58
68
  attributeName = _a.attributeName,
59
69
  oldValue = _a.oldValue,
60
70
  newValue = _a.newValue;
61
- _this.attributeChangedCallback && _this.attributeChangedCallback(attributeName, oldValue, newValue);
71
+
72
+ if (_this.attributeChangedCallback) {
73
+ _this.attributeChangedCallback(attributeName, oldValue, newValue);
74
+ }
62
75
  }; // this.addEventListener(ElementEvent.CHILD_INSERTED, this.handleChildInserted);
63
76
  // this.addEventListener(ElementEvent.CHILD_REMOVED, this.handleChildRemoved);
64
77
 
@@ -68,11 +81,11 @@ function (_super) {
68
81
  }
69
82
 
70
83
  if (_this.connectedCallback) {
71
- _this.addEventListener(_interfaces.ElementEvent.INSERTED, _this.handleMounted);
84
+ _this.addEventListener(_interfaces.ElementEvent.MOUNTED, _this.handleMounted);
72
85
  }
73
86
 
74
87
  if (_this.disconnectedCallback) {
75
- _this.addEventListener(_interfaces.ElementEvent.REMOVED, _this.disconnectedCallback.bind(_this));
88
+ _this.addEventListener(_interfaces.ElementEvent.UNMOUNTED, _this.handleUnmounted);
76
89
  }
77
90
 
78
91
  return _this;
@@ -1,9 +1,9 @@
1
- import { mat3, mat4, quat, vec2, vec3 } from 'gl-matrix';
2
- import { Animation } from '../dom/Animation';
1
+ import type { mat3, vec2 } from 'gl-matrix';
2
+ import { mat4, quat, vec3 } from 'gl-matrix';
3
+ import type { Animation } from '../dom/Animation';
3
4
  import { Element } from '../dom/Element';
4
- import type { DisplayObjectConfig, INode } from '../dom/interfaces';
5
+ import type { DisplayObjectConfig, IChildNode } from '../dom/interfaces';
5
6
  import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
6
- import { StylePropertyParser, StylePropertyUpdater } from '../property-handlers';
7
7
  /**
8
8
  * prototype chains: DisplayObject -> Element -> Node -> EventTarget
9
9
  *
@@ -31,8 +31,6 @@ export declare class DisplayObject<StyleProps extends BaseStyleProps = any, Pars
31
31
  * push to active animations after calling `animate()`
32
32
  */
33
33
  private activeAnimations;
34
- stylePropertyUpdaterFactory: <Key extends keyof StyleProps>(stylePropertyName: Key) => StylePropertyUpdater<any>[];
35
- stylePropertyParserFactory: <Key extends keyof ParsedStyleProps>(stylePropertyName: Key) => StylePropertyParser<any, any>;
36
34
  constructor(config: DisplayObjectConfig<StyleProps>);
37
35
  destroy(): void;
38
36
  cloneNode(deep?: boolean): this;
@@ -192,7 +190,7 @@ export declare class DisplayObject<StyleProps extends BaseStyleProps = any, Pars
192
190
  * compatible with G 3.0
193
191
  * @deprecated
194
192
  */
195
- add<T extends INode>(child: T, index?: number): T;
193
+ add<T extends IChildNode>(child: T, index?: number): T;
196
194
  /**
197
195
  * @alias style.clipPath
198
196
  * @deprecated
@@ -23,10 +23,12 @@ var _types = require("../types");
23
23
 
24
24
  var _utils = require("../utils");
25
25
 
26
- var _propertyHandlers = require("../property-handlers");
27
-
28
26
  var _globalModule = require("../global-module");
29
27
 
28
+ var _services = require("../services");
29
+
30
+ // import type { StylePropertyParser, StylePropertyUpdater } from '../property-handlers';
31
+ // import { StylePropertyParserFactory, StylePropertyUpdaterFactory } from '../property-handlers';
30
32
  var DEFAULT_STYLE_PROPS = {
31
33
  anchor: [0, 0, 0],
32
34
  origin: [0, 0, 0],
@@ -56,20 +58,23 @@ var DEFAULT_STYLE_PROPS = {
56
58
  var DisplayObject =
57
59
  /** @class */
58
60
  function (_super) {
59
- (0, _tslib.__extends)(DisplayObject, _super);
61
+ (0, _tslib.__extends)(DisplayObject, _super); // stylePropertyUpdaterFactory = globalContainer.get<
62
+ // <Key extends keyof StyleProps>(stylePropertyName: Key) => StylePropertyUpdater<any>[]
63
+ // >(StylePropertyUpdaterFactory);
64
+ // stylePropertyParserFactory = globalContainer.get<
65
+ // <Key extends keyof ParsedStyleProps>(stylePropertyName: Key) => StylePropertyParser<any, any>
66
+ // >(StylePropertyParserFactory);
60
67
 
61
68
  function DisplayObject(config) {
62
69
  var _a, _b, _c;
63
70
 
64
- var _this = _super.call(this, config) || this;
71
+ var _this = _super.call(this) || this;
65
72
  /**
66
73
  * push to active animations after calling `animate()`
67
74
  */
68
75
 
69
76
 
70
- _this.activeAnimations = [];
71
- _this.stylePropertyUpdaterFactory = _globalModule.globalContainer.get(_propertyHandlers.StylePropertyUpdaterFactory);
72
- _this.stylePropertyParserFactory = _globalModule.globalContainer.get(_propertyHandlers.StylePropertyParserFactory); // assign name, id to config
77
+ _this.activeAnimations = []; // assign name, id to config
73
78
  // eg. group.get('name')
74
79
 
75
80
  _this.config = config; // compatible with G 3.0
@@ -197,7 +202,8 @@ function (_super) {
197
202
 
198
203
 
199
204
  DisplayObject.prototype.parseStyleProperty = function (name, value) {
200
- var stylePropertyParser = this.stylePropertyParserFactory(name);
205
+ // const stylePropertyParser = this.stylePropertyParserFactory(name);
206
+ var stylePropertyParser = _globalModule.stylePropertyParserFactory[name];
201
207
 
202
208
  if (stylePropertyParser) {
203
209
  // @ts-ignore
@@ -210,9 +216,10 @@ function (_super) {
210
216
  DisplayObject.prototype.updateStyleProperty = function (name, oldParsedValue, newParsedValue) {
211
217
  var _this = this; // update property, which may cause AABB re-calc
212
218
  // @ts-ignore
219
+ // const stylePropertyUpdaters = this.stylePropertyUpdaterFactory(name);
213
220
 
214
221
 
215
- var stylePropertyUpdaters = this.stylePropertyUpdaterFactory(name);
222
+ var stylePropertyUpdaters = _globalModule.stylePropertyUpdaterFactory[name];
216
223
 
217
224
  if (stylePropertyUpdaters) {
218
225
  stylePropertyUpdaters.forEach(function (updater) {
@@ -242,7 +249,7 @@ function (_super) {
242
249
 
243
250
  if (this.attributes.clipPathTargets && this.attributes.clipPathTargets.length) {
244
251
  this.attributes.clipPathTargets.forEach(function (target) {
245
- target.emit(_interfaces.ElementEvent.BOUNDS_CHANGED, {});
252
+ (0, _services.dirtifyToRoot)(target);
246
253
  target.emit(_interfaces.ElementEvent.ATTRIBUTE_CHANGED, {
247
254
  attributeName: 'clipPath',
248
255
  oldValue: _this,
@@ -815,7 +822,8 @@ function (_super) {
815
822
  sx = _b[0],
816
823
  sy = _b[1];
817
824
 
818
- var rotation = _glMatrix.mat4.getRotation(_glMatrix.quat.create(), transform);
825
+ var rotation = _glMatrix.mat4.getRotation(_glMatrix.quat.create(), transform); // eslint-disable-next-line @typescript-eslint/no-unused-vars
826
+
819
827
 
820
828
  var _c = (0, _tslib.__read)((0, _utils.getEuler)(_glMatrix.vec3.create(), rotation), 3),
821
829
  eux = _c[0],
@@ -1,6 +1,6 @@
1
1
  import type { BaseStyleProps } from '../types';
2
2
  import { DisplayObject } from './DisplayObject';
3
- import { DisplayObjectConfig } from '../dom';
3
+ import type { DisplayObjectConfig } from '../dom';
4
4
  export declare class Group extends DisplayObject {
5
5
  constructor(config?: DisplayObjectConfig<BaseStyleProps>);
6
6
  }
@@ -1,6 +1,6 @@
1
1
  import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
2
2
  import { DisplayObject } from './DisplayObject';
3
- import { DisplayObjectConfig } from '../dom';
3
+ import type { DisplayObjectConfig } from '../dom';
4
4
  import { AABB } from '../shapes';
5
5
  export interface HTMLStyleProps extends BaseStyleProps {
6
6
  innerHTML: string | HTMLElement;
@@ -1,6 +1,6 @@
1
1
  import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
2
2
  import { DisplayObject } from './DisplayObject';
3
- import { DisplayObjectConfig } from '../dom';
3
+ import type { DisplayObjectConfig } from '../dom';
4
4
  export interface ImageStyleProps extends BaseStyleProps {
5
5
  img: string | HTMLImageElement;
6
6
  width?: number;
@@ -1,6 +1,6 @@
1
1
  import type { BaseStyleProps, PathCommand } from '../types';
2
2
  import { DisplayObject } from './DisplayObject';
3
- import { DisplayObjectConfig } from '../dom';
3
+ import type { DisplayObjectConfig } from '../dom';
4
4
  import { Point } from '../shapes';
5
5
  import type { Rect } from '../shapes/Rect';
6
6
  export interface PathStyleProps extends BaseStyleProps {
@@ -1,6 +1,6 @@
1
1
  import type { BaseStyleProps } from '../types';
2
2
  import { DisplayObject } from './DisplayObject';
3
- import { DisplayObjectConfig } from '../dom';
3
+ import type { DisplayObjectConfig } from '../dom';
4
4
  import type { ParsedPolylineStyleProps } from './Polyline';
5
5
  export interface PolygonStyleProps extends BaseStyleProps {
6
6
  points: [number, number][];
@@ -1,6 +1,6 @@
1
1
  import type { BaseStyleProps } from '../types';
2
2
  import { DisplayObject } from './DisplayObject';
3
- import { DisplayObjectConfig } from '../dom';
3
+ import type { DisplayObjectConfig } from '../dom';
4
4
  import { Point } from '../shapes';
5
5
  export interface PolylineStyleProps extends BaseStyleProps {
6
6
  points: [number, number][];
@@ -1,4 +1,4 @@
1
- import { TextMetrics } from '../services/text';
1
+ import type { TextMetrics } from '../services/text';
2
2
  import type { DisplayObjectConfig } from '../dom/interfaces';
3
3
  import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
4
4
  import { DisplayObject } from './DisplayObject';
@@ -60,7 +60,7 @@ function (_super) {
60
60
  Text.prototype.getLineBoundingRects = function () {
61
61
  var _a;
62
62
 
63
- return (_a = this.parsedStyle.metrics) === null || _a === void 0 ? void 0 : _a.lineMetrics;
63
+ return ((_a = this.parsedStyle.metrics) === null || _a === void 0 ? void 0 : _a.lineMetrics) || [];
64
64
  };
65
65
 
66
66
  return Text;
@@ -427,15 +427,18 @@ function () {
427
427
 
428
428
  Animation.prototype.persist = function () {
429
429
  throw new Error('Method not implemented.');
430
- };
430
+ }; // eslint-disable-next-line @typescript-eslint/no-unused-vars
431
+
431
432
 
432
433
  Animation.prototype.addEventListener = function (type, listener, options) {
433
434
  throw new Error('Method not implemented.');
434
- };
435
+ }; // eslint-disable-next-line @typescript-eslint/no-unused-vars
436
+
435
437
 
436
438
  Animation.prototype.removeEventListener = function (type, listener, options) {
437
439
  throw new Error('Method not implemented.');
438
- };
440
+ }; // eslint-disable-next-line @typescript-eslint/no-unused-vars
441
+
439
442
 
440
443
  Animation.prototype.dispatchEvent = function (event) {
441
444
  throw new Error('Method not implemented.');
@@ -484,7 +487,9 @@ function () {
484
487
  if (this.onfinish) {
485
488
  var event_1 = new _AnimationEvent.AnimationEvent(null, this, this.currentTime, baseTime);
486
489
  setTimeout(function () {
487
- _this.onfinish && _this.onfinish(event_1);
490
+ if (_this.onfinish) {
491
+ _this.onfinish(event_1);
492
+ }
488
493
  });
489
494
  }
490
495
 
@@ -55,5 +55,4 @@ export declare class AnimationEffectTiming implements EffectTiming {
55
55
  endTime: number;
56
56
  currentIteration: number | null;
57
57
  progress: number | null;
58
- constructor();
59
58
  }
@@ -165,7 +165,8 @@ function () {
165
165
 
166
166
  this.rafCallbacks.push([id, f]);
167
167
  return id;
168
- };
168
+ }; // eslint-disable-next-line @typescript-eslint/ban-types
169
+
169
170
 
170
171
  AnimationTimeline.prototype.requestAnimationFrame = function (f) {
171
172
  var _this = this;
@@ -1,4 +1,4 @@
1
- import { DisplayObject } from '../display-objects';
1
+ import type { DisplayObject } from '../display-objects';
2
2
  /**
3
3
  * canvas.customElements
4
4
  *
@@ -24,7 +24,7 @@ var _FederatedEvent = require("./FederatedEvent");
24
24
  var CustomEvent =
25
25
  /** @class */
26
26
  function (_super) {
27
- (0, _tslib.__extends)(CustomEvent, _super);
27
+ (0, _tslib.__extends)(CustomEvent, _super); // eslint-disable-next-line @typescript-eslint/ban-types
28
28
 
29
29
  function CustomEvent(eventName, object) {
30
30
  var _this = _super.call(this, null) || this;
@@ -1,9 +1,9 @@
1
1
  import { Node } from './Node';
2
2
  import { AnimationTimeline } from './AnimationTimeline';
3
3
  import { Group } from '../display-objects/Group';
4
- import { DisplayObject } from '../display-objects/DisplayObject';
4
+ import type { DisplayObject } from '../display-objects/DisplayObject';
5
5
  import type { IDocument, IElement, INode, ICanvas, DisplayObjectConfig } from './interfaces';
6
- import { BaseStyleProps } from '../types';
6
+ import type { BaseStyleProps } from '../types';
7
7
  /**
8
8
  * the entry of DOM tree
9
9
  * Document -> Node -> EventTarget
@@ -34,7 +34,7 @@ export declare class Document extends Node implements IDocument {
34
34
  * @example const circle = document.createElement('circle', { style: { r: 10 } });
35
35
  */
36
36
  createElement<T extends DisplayObject<StyleProps>, StyleProps extends BaseStyleProps>(tagName: string, options: DisplayObjectConfig<StyleProps>): T;
37
- cloneNode(deep?: boolean): INode;
37
+ cloneNode(deep?: boolean): this;
38
38
  destroy(): void;
39
39
  /**
40
40
  * eg. Uncaught DOMException: Failed to execute 'appendChild' on 'Node': Only one element on document allowed.
@@ -81,7 +81,8 @@ function (_super) {
81
81
  Document.prototype.createElement = function (tagName, options) {
82
82
  var clazz = this.defaultView.customElements.get(tagName);
83
83
  return new clazz(options);
84
- };
84
+ }; // eslint-disable-next-line @typescript-eslint/no-unused-vars
85
+
85
86
 
86
87
  Document.prototype.cloneNode = function (deep) {
87
88
  throw new Error('Method not implemented.');
@@ -97,23 +98,28 @@ function (_super) {
97
98
  /**
98
99
  * eg. Uncaught DOMException: Failed to execute 'appendChild' on 'Node': Only one element on document allowed.
99
100
  */
101
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
100
102
 
101
103
 
102
104
  Document.prototype.appendChild = function (newChild, index) {
103
105
  throw new Error('Use document.documentElement instead.');
104
- };
106
+ }; // eslint-disable-next-line @typescript-eslint/no-unused-vars
107
+
105
108
 
106
109
  Document.prototype.insertBefore = function (newChild, refChild) {
107
110
  throw new Error('Use document.documentElement instead.');
108
- };
111
+ }; // eslint-disable-next-line @typescript-eslint/no-unused-vars
112
+
109
113
 
110
114
  Document.prototype.removeChild = function (oldChild, destroy) {
111
115
  throw new Error('Use document.documentElement instead.');
112
- };
116
+ }; // eslint-disable-next-line @typescript-eslint/no-unused-vars
117
+
113
118
 
114
119
  Document.prototype.replaceChild = function (newChild, oldChild, destroy) {
115
120
  throw new Error('Use document.documentElement instead.');
116
- };
121
+ }; // eslint-disable-next-line @typescript-eslint/no-unused-vars
122
+
117
123
 
118
124
  Document.prototype.append = function () {
119
125
  var nodes = [];
@@ -123,7 +129,8 @@ function (_super) {
123
129
  }
124
130
 
125
131
  throw new Error('Use document.documentElement instead.');
126
- };
132
+ }; // eslint-disable-next-line @typescript-eslint/no-unused-vars
133
+
127
134
 
128
135
  Document.prototype.prepend = function () {
129
136
  var nodes = [];
@@ -1,9 +1,9 @@
1
1
  import { SceneGraphService } from '../services/SceneGraphService';
2
2
  import { Cullable, Geometry, Renderable, Transform, Sortable } from '../components';
3
- import { BaseStyleProps, ParsedBaseStyleProps } from '../types';
3
+ import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
4
4
  import { Node } from './Node';
5
- import { AABB, Rectangle } from '../shapes';
6
- import type { DisplayObjectConfig, IEventTarget, IChildNode, IElement, INode } from './interfaces';
5
+ import type { AABB, Rectangle } from '../shapes';
6
+ import type { IEventTarget, IElement, INode } from './interfaces';
7
7
  /**
8
8
  * Has following capabilities:
9
9
  * * Node insert/remove, eg. appendChild, removeChild, remove...
@@ -19,7 +19,6 @@ export declare class Element<StyleProps extends BaseStyleProps = any, ParsedStyl
19
19
  transformable: Transform;
20
20
  sortable: Sortable;
21
21
  geometry: Geometry;
22
- constructor(config: DisplayObjectConfig<StyleProps>);
23
22
  /**
24
23
  * used with `getElementById()`
25
24
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/id
@@ -52,8 +51,8 @@ export declare class Element<StyleProps extends BaseStyleProps = any, ParsedStyl
52
51
  get previousSibling(): IElement | null;
53
52
  cloneNode(deep?: boolean): this;
54
53
  appendChild<T extends INode>(child: T, index?: number): T;
55
- insertBefore<T extends INode>(newChild: T, refChild: IElement | null): T;
56
- replaceChild<T extends INode & IChildNode>(newChild: INode, oldChild: T, destroy?: boolean): T;
54
+ insertBefore<T extends INode>(newChild: T, refChild: INode | null): T;
55
+ replaceChild<T extends INode>(newChild: INode, oldChild: T, destroy?: boolean): T;
57
56
  removeChild<T extends INode>(child: T, destroy?: boolean): T;
58
57
  removeChildren(destroy?: boolean): void;
59
58
  /**
@@ -74,27 +73,27 @@ export declare class Element<StyleProps extends BaseStyleProps = any, ParsedStyl
74
73
  /**
75
74
  * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/after
76
75
  */
77
- after(...nodes: IElement[]): void;
76
+ after(...nodes: INode[]): void;
78
77
  /**
79
78
  * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/before
80
79
  */
81
- before(...nodes: IElement[]): void;
80
+ before(...nodes: INode[]): void;
82
81
  /**
83
82
  * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/replaceWith
84
83
  */
85
- replaceWith(...nodes: IElement[]): void;
84
+ replaceWith(...nodes: INode[]): void;
86
85
  /**
87
86
  * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/append
88
87
  */
89
- append(...nodes: IElement[]): void;
88
+ append(...nodes: INode[]): void;
90
89
  /**
91
90
  * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/prepend
92
91
  */
93
- prepend(...nodes: IElement[]): void;
92
+ prepend(...nodes: INode[]): void;
94
93
  /**
95
94
  * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/replaceChildren
96
95
  */
97
- replaceChildren(...nodes: IElement[]): void;
96
+ replaceChildren(...nodes: INode[]): void;
98
97
  /**
99
98
  * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/remove
100
99
  */
@@ -32,8 +32,8 @@ var Element =
32
32
  function (_super) {
33
33
  (0, _tslib.__extends)(Element, _super);
34
34
 
35
- function Element(config) {
36
- var _this = _super.call(this) || this;
35
+ function Element() {
36
+ var _this = _super !== null && _super.apply(this, arguments) || this;
37
37
 
38
38
  _this.sceneGraphService = _globalModule.globalContainer.get(_SceneGraphService.SceneGraphService);
39
39
  _this.entity = entityCounter++;
@@ -143,7 +143,7 @@ function (_super) {
143
143
  },
144
144
  enumerable: false,
145
145
  configurable: true
146
- });
146
+ }); // eslint-disable-next-line @typescript-eslint/no-unused-vars
147
147
 
148
148
  Element.prototype.cloneNode = function (deep) {
149
149
  throw new Error('Method not implemented.');
@@ -312,6 +312,8 @@ function (_super) {
312
312
 
313
313
 
314
314
  Element.prototype.before = function () {
315
+ var _a;
316
+
315
317
  var nodes = [];
316
318
 
317
319
  for (var _i = 0; _i < arguments.length; _i++) {
@@ -321,12 +323,13 @@ function (_super) {
321
323
  if (this.parentNode) {
322
324
  var index = this.parentNode.childNodes.indexOf(this);
323
325
 
324
- var _a = (0, _tslib.__read)(nodes),
325
- first = _a[0],
326
- rest = _a.slice(1);
326
+ var _b = (0, _tslib.__read)(nodes),
327
+ first = _b[0],
328
+ rest = _b.slice(1);
327
329
 
328
330
  this.parentNode.appendChild(first, index);
329
- first.after.apply(first, (0, _tslib.__spreadArray)([], (0, _tslib.__read)(rest), false));
331
+
332
+ (_a = first).after.apply(_a, (0, _tslib.__spreadArray)([], (0, _tslib.__read)(rest), false));
330
333
  }
331
334
  };
332
335
  /**
@@ -490,7 +493,8 @@ function (_super) {
490
493
  */
491
494
 
492
495
 
493
- Element.prototype.setAttribute = function (attributeName, value, force) {
496
+ Element.prototype.setAttribute = function (attributeName, value, // eslint-disable-next-line @typescript-eslint/no-unused-vars
497
+ force) {
494
498
  if (force === void 0) {
495
499
  force = false;
496
500
  }
@@ -132,6 +132,7 @@ function () {
132
132
  * @deprecated
133
133
  * @alias dispatchEvent
134
134
  */
135
+ // eslint-disable-next-line @typescript-eslint/ban-types
135
136
 
136
137
 
137
138
  EventTarget.prototype.emit = function (eventName, object) {
@@ -1,6 +1,6 @@
1
1
  import { Point } from '../shapes/Point';
2
2
  import type { EventService } from '../services';
3
- import { IEventTarget } from './interfaces';
3
+ import type { IEventTarget } from './interfaces';
4
4
  /**
5
5
  * An DOM-compatible synthetic event implementation that is "forwarded" on behalf of an original
6
6
  * FederatedEvent or native {@link https://dom.spec.whatwg.org/#event Event}.
@@ -131,7 +131,7 @@ function () {
131
131
 
132
132
  return target[prop];
133
133
  },
134
- set: function set(_, prop, value) {
134
+ set: function set() {
135
135
  return true;
136
136
  }
137
137
  });
package/lib/dom/Node.d.ts CHANGED
@@ -28,7 +28,7 @@ export declare abstract class Node extends EventTarget implements INode {
28
28
  * Returns the children.
29
29
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Node/childNodes
30
30
  */
31
- childNodes: (IChildNode & INode)[];
31
+ childNodes: IChildNode[];
32
32
  /**
33
33
  * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Node/nodeType
34
34
  */
@@ -48,7 +48,7 @@ export declare abstract class Node extends EventTarget implements INode {
48
48
  /**
49
49
  * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Node/getRootNode
50
50
  */
51
- getRootNode(options?: GetRootNodeOptions): INode;
51
+ getRootNode(): INode;
52
52
  hasChildNodes(): boolean;
53
53
  isDefaultNamespace(namespace: string | null): boolean;
54
54
  compareDocumentPosition(other: INode): number;
@@ -70,14 +70,14 @@ export declare abstract class Node extends EventTarget implements INode {
70
70
  */
71
71
  get parent(): INode | null;
72
72
  get parentElement(): IElement | null;
73
- get nextSibling(): (IChildNode & INode) | null;
74
- get previousSibling(): (IChildNode & INode) | null;
75
- get firstChild(): (IChildNode & INode) | null;
76
- get lastChild(): (IChildNode & INode) | null;
73
+ get nextSibling(): IChildNode | null;
74
+ get previousSibling(): IChildNode | null;
75
+ get firstChild(): IChildNode | null;
76
+ get lastChild(): IChildNode | null;
77
77
  /**
78
78
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Node/cloneNode
79
79
  */
80
- abstract cloneNode(deep?: boolean): INode;
80
+ abstract cloneNode(deep?: boolean): this;
81
81
  /**
82
82
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Node/appendChild
83
83
  */
@@ -93,14 +93,14 @@ export declare abstract class Node extends EventTarget implements INode {
93
93
  /**
94
94
  * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Node/replaceChild
95
95
  */
96
- abstract replaceChild<T extends INode & IChildNode>(newChild: INode, oldChild: T, destroy?: boolean): T;
96
+ abstract replaceChild<T extends INode>(newChild: INode, oldChild: T, destroy?: boolean): T;
97
97
  abstract destroy(): void;
98
98
  /**
99
99
  * @deprecated
100
100
  * @alias contains
101
101
  */
102
- contain(other: INode | null): boolean;
103
- contains(other: INode | null): boolean;
102
+ contain<T extends INode>(other: T | null): boolean;
103
+ contains<T extends INode>(other: T | null): boolean;
104
104
  getAncestor(n: number): INode | null;
105
105
  forEach(callback: (o: INode) => void | boolean): void;
106
106
  }
package/lib/dom/Node.js CHANGED
@@ -84,7 +84,8 @@ function (_super) {
84
84
  */
85
85
 
86
86
 
87
- Node.prototype.getRootNode = function (options) {
87
+ Node.prototype.getRootNode = function () {
88
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
88
89
  var temp = this;
89
90
 
90
91
  while (temp.parentNode) {
@@ -96,19 +97,23 @@ function (_super) {
96
97
 
97
98
  Node.prototype.hasChildNodes = function () {
98
99
  return this.childNodes.length > 0;
99
- };
100
+ }; // eslint-disable-next-line @typescript-eslint/no-unused-vars
101
+
100
102
 
101
103
  Node.prototype.isDefaultNamespace = function (namespace) {
102
104
  throw new Error('Method not implemented.');
103
- };
105
+ }; // eslint-disable-next-line @typescript-eslint/no-unused-vars
106
+
104
107
 
105
108
  Node.prototype.compareDocumentPosition = function (other) {
106
109
  throw new Error('Method not implemented.');
107
- };
110
+ }; // eslint-disable-next-line @typescript-eslint/no-unused-vars
111
+
108
112
 
109
113
  Node.prototype.lookupNamespaceURI = function (prefix) {
110
114
  throw new Error('Method not implemented.');
111
- };
115
+ }; // eslint-disable-next-line @typescript-eslint/no-unused-vars
116
+
112
117
 
113
118
  Node.prototype.lookupPrefix = function (namespace) {
114
119
  throw new Error('Method not implemented.');
@@ -198,6 +203,7 @@ function (_super) {
198
203
  };
199
204
 
200
205
  Node.prototype.getAncestor = function (n) {
206
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
201
207
  var temp = this;
202
208
 
203
209
  while (n > 0 && temp) {