@antv/g 5.0.2 → 5.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/index.umd.js +1 -1
  2. package/es/Canvas.d.ts +14 -4
  3. package/es/Canvas.js +18 -10
  4. package/es/camera/Camera.d.ts +2 -1
  5. package/es/camera/Camera.js +13 -5
  6. package/es/components/Sortable.d.ts +4 -0
  7. package/es/components/Sortable.js +5 -0
  8. package/es/display-objects/CustomElement.d.ts +10 -11
  9. package/es/display-objects/CustomElement.js +20 -10
  10. package/es/display-objects/DisplayObject.d.ts +2 -5
  11. package/es/display-objects/DisplayObject.js +16 -9
  12. package/es/display-objects/Line.d.ts +4 -0
  13. package/es/display-objects/Line.js +2 -0
  14. package/es/dom/Document.d.ts +1 -1
  15. package/es/dom/Element.d.ts +9 -9
  16. package/es/dom/Element.js +7 -4
  17. package/es/dom/Node.d.ts +9 -9
  18. package/es/dom/interfaces.d.ts +13 -9
  19. package/es/dom/interfaces.js +5 -0
  20. package/es/global-module.d.ts +4 -0
  21. package/es/global-module.js +58 -71
  22. package/es/plugins/FrustumCullingStrategy.js +3 -1
  23. package/es/property-handlers/localPosition.js +4 -2
  24. package/es/services/RenderingService.d.ts +6 -0
  25. package/es/services/RenderingService.js +29 -1
  26. package/es/types.d.ts +8 -1
  27. package/es/utils/interpolation.js +10 -7
  28. package/lib/Canvas.d.ts +14 -4
  29. package/lib/Canvas.js +18 -10
  30. package/lib/camera/Camera.d.ts +2 -1
  31. package/lib/camera/Camera.js +14 -5
  32. package/lib/components/Sortable.d.ts +4 -0
  33. package/lib/components/Sortable.js +5 -0
  34. package/lib/display-objects/CustomElement.d.ts +10 -11
  35. package/lib/display-objects/CustomElement.js +20 -10
  36. package/lib/display-objects/DisplayObject.d.ts +2 -5
  37. package/lib/display-objects/DisplayObject.js +13 -8
  38. package/lib/display-objects/Line.d.ts +4 -0
  39. package/lib/display-objects/Line.js +2 -0
  40. package/lib/dom/Document.d.ts +1 -1
  41. package/lib/dom/Element.d.ts +9 -9
  42. package/lib/dom/Element.js +7 -4
  43. package/lib/dom/Node.d.ts +9 -9
  44. package/lib/dom/interfaces.d.ts +13 -9
  45. package/lib/dom/interfaces.js +5 -0
  46. package/lib/global-module.d.ts +4 -0
  47. package/lib/global-module.js +58 -71
  48. package/lib/plugins/FrustumCullingStrategy.js +2 -0
  49. package/lib/property-handlers/localPosition.js +4 -2
  50. package/lib/services/RenderingService.d.ts +6 -0
  51. package/lib/services/RenderingService.js +30 -1
  52. package/lib/types.d.ts +8 -1
  53. package/lib/utils/interpolation.js +7 -9
  54. package/package.json +3 -3
package/es/Canvas.d.ts CHANGED
@@ -7,8 +7,9 @@ import { EventService } from './services/EventService';
7
7
  import { Camera } from './camera';
8
8
  import type { AbstractRenderer } from './AbstractRenderer';
9
9
  import type { PointLike } from './shapes';
10
+ import type { IChildNode } from './dom';
10
11
  import { Document, EventTarget } from './dom';
11
- import type { IElement, INode, ICanvas } from './dom/interfaces';
12
+ import type { ICanvas } from './dom/interfaces';
12
13
  import { CustomElementRegistry } from './dom/CustomElementRegistry';
13
14
  export declare enum CanvasEvent {
14
15
  READY = "ready",
@@ -41,6 +42,11 @@ export declare class Canvas extends EventTarget implements ICanvas {
41
42
  * rAF in auto rendering
42
43
  */
43
44
  private frameId?;
45
+ /**
46
+ * cache here since inversify's resolving is very slow
47
+ */
48
+ private eventService;
49
+ private renderingService;
44
50
  constructor(config: CanvasConfig);
45
51
  private initRenderingContext;
46
52
  private initDefaultCamera;
@@ -59,6 +65,10 @@ export declare class Canvas extends EventTarget implements ICanvas {
59
65
  getEventService(): EventService;
60
66
  getRenderingService(): RenderingService;
61
67
  getRenderingContext(): RenderingContext;
68
+ getStats(): {
69
+ total: number;
70
+ rendered: number;
71
+ };
62
72
  getComputedStyle(node: DisplayObject): any;
63
73
  destroy(destroyScenegraph?: boolean): void;
64
74
  /**
@@ -68,9 +78,9 @@ export declare class Canvas extends EventTarget implements ICanvas {
68
78
  */
69
79
  changeSize(width: number, height: number): void;
70
80
  resize(width: number, height: number): void;
71
- appendChild<T extends INode>(child: T, index?: number): T;
72
- insertBefore<T extends INode>(newChild: T, refChild: IElement | null): T;
73
- removeChild<T extends INode>(child: T, destroy?: boolean): T;
81
+ appendChild<T extends IChildNode>(child: T, index?: number): T;
82
+ insertBefore<T extends IChildNode, N extends IChildNode>(newChild: T, refChild: N | null): T;
83
+ removeChild<T extends IChildNode>(child: T, destroy?: boolean): T;
74
84
  removeChildren(destroy?: boolean): void;
75
85
  render(): void;
76
86
  private run;
package/es/Canvas.js CHANGED
@@ -50,9 +50,12 @@ function (_super) {
50
50
  _this.customElements = new CustomElementRegistry();
51
51
  cleanExistedCanvas(config.container, _this);
52
52
 
53
- var mergedConfig = __assign(__assign({}, config), {
54
- cursor: 'default'
55
- });
53
+ var mergedConfig = __assign({
54
+ width: 300,
55
+ height: 150,
56
+ cursor: 'default',
57
+ background: 'white'
58
+ }, config);
56
59
 
57
60
  _this.initRenderingContext(mergedConfig);
58
61
 
@@ -98,8 +101,7 @@ function (_super) {
98
101
 
99
102
  Canvas.prototype.initDefaultCamera = function (width, height) {
100
103
  // set a default ortho camera
101
- var camera = new Camera().setPosition(width / 2, height / 2, 500).setFocalPoint(width / 2, height / 2, 0) // origin to be in the top left
102
- .setOrthographic(width / -2, width / 2, height / -2, height / 2, 0.1, 1000); // redraw when camera changed
104
+ var camera = new Camera().setPosition(width / 2, height / 2, 500).setFocalPoint(width / 2, height / 2, 0).setOrthographic(width / -2, width / 2, height / 2, height / -2, 0.1, 1000); // redraw when camera changed
103
105
 
104
106
  var context = this.container.get(RenderingContext);
105
107
  camera.on(CAMERA_EVENT.Updated, function () {
@@ -142,17 +144,21 @@ function (_super) {
142
144
  };
143
145
 
144
146
  Canvas.prototype.getEventService = function () {
145
- return this.container.get(EventService);
147
+ return this.eventService;
146
148
  };
147
149
 
148
150
  Canvas.prototype.getRenderingService = function () {
149
- return this.container.get(RenderingService);
151
+ return this.renderingService;
150
152
  };
151
153
 
152
154
  Canvas.prototype.getRenderingContext = function () {
153
155
  return this.container.get(RenderingContext);
154
156
  };
155
157
 
158
+ Canvas.prototype.getStats = function () {
159
+ return this.getRenderingService().getStats();
160
+ };
161
+
156
162
  Canvas.prototype.getComputedStyle = function (node) {
157
163
  return node.parsedStyle;
158
164
  };
@@ -203,9 +209,10 @@ function (_super) {
203
209
 
204
210
  var camera = this.container.get(DefaultCamera);
205
211
  var projectionMode = camera.getProjectionMode();
212
+ camera.setPosition(width / 2, height / 2, 500).setFocalPoint(width / 2, height / 2, 0);
206
213
 
207
214
  if (projectionMode === CAMERA_PROJECTION_MODE.ORTHOGRAPHIC) {
208
- camera.setPosition(width / 2, height / 2, 500).setFocalPoint(width / 2, height / 2, 0).setOrthographic(width / -2, width / 2, height / -2, height / 2, camera.getNear(), camera.getFar());
215
+ camera.setOrthographic(width / -2, width / 2, height / 2, height / -2, camera.getNear(), camera.getFar());
209
216
  } else {
210
217
  camera.setAspect(width / height);
211
218
  }
@@ -275,9 +282,10 @@ function (_super) {
275
282
  this.loadRendererContainerModule(renderer); // init context
276
283
 
277
284
  var contextService = this.container.get(ContextService);
278
- var renderingService = this.container.get(RenderingService);
285
+ this.renderingService = this.container.get(RenderingService);
286
+ this.eventService = this.container.get(EventService);
279
287
  contextService.init();
280
- renderingService.init().then(function () {
288
+ this.renderingService.init().then(function () {
281
289
  _this.emit(CanvasEvent.READY, {});
282
290
  });
283
291
 
@@ -129,6 +129,7 @@ export declare class Camera extends EventEmitter {
129
129
  * ortho matrix for Canvas2D & SVG
130
130
  */
131
131
  private orthoMatrix;
132
+ isOrtho(): boolean;
132
133
  clone(): Camera;
133
134
  getProjectionMode(): CAMERA_PROJECTION_MODE;
134
135
  getPerspective(): mat4;
@@ -167,7 +168,7 @@ export declare class Camera extends EventEmitter {
167
168
  * 设置相机矩阵
168
169
  */
169
170
  setMatrix(matrix: mat4): this;
170
- setFov(fov: number): void;
171
+ setFov(fov: number): this;
171
172
  setAspect(aspect: number): this;
172
173
  setNear(near: number): this;
173
174
  setFar(far: number): this;
@@ -136,7 +136,7 @@ function (_super) {
136
136
 
137
137
  _this.fov = 30;
138
138
  _this.near = 0.1;
139
- _this.far = 10000;
139
+ _this.far = 1000;
140
140
  _this.aspect = 1;
141
141
  _this.projectionMatrix = mat4.create();
142
142
  _this.projectionMatrixInverse = mat4.create();
@@ -163,6 +163,10 @@ function (_super) {
163
163
  return _this;
164
164
  }
165
165
 
166
+ Camera.prototype.isOrtho = function () {
167
+ return this.projectionMode === CAMERA_PROJECTION_MODE.ORTHOGRAPHIC;
168
+ };
169
+
166
170
  Camera.prototype.clone = function () {
167
171
  var camera = new Camera();
168
172
  camera.setType(this.type, undefined); // camera.interactor = this.interactor;
@@ -297,6 +301,7 @@ function (_super) {
297
301
 
298
302
  Camera.prototype.setFov = function (fov) {
299
303
  this.setPerspective(this.near, this.far, fov, this.aspect);
304
+ return this;
300
305
  };
301
306
 
302
307
  Camera.prototype.setAspect = function (aspect) {
@@ -404,10 +409,11 @@ function (_super) {
404
409
  top -= this.view.offsetY * height / fullHeight;
405
410
  width *= this.view.width / fullWidth;
406
411
  height *= this.view.height / fullHeight;
407
- } // flip Y
412
+ }
408
413
 
414
+ makePerspective(this.projectionMatrix, left, left + width, top, top - height, near, this.far); // flipY since the origin of OpenGL/WebGL is bottom-left compared with top-left in Canvas2D
409
415
 
410
- makePerspective(this.projectionMatrix, left, left + width, top - height, top, near, this.far);
416
+ mat4.scale(this.projectionMatrix, this.projectionMatrix, vec3.fromValues(1, -1, 1));
411
417
  mat4.invert(this.projectionMatrixInverse, this.projectionMatrix);
412
418
  this.emit(CAMERA_EVENT.Updated);
413
419
  return this;
@@ -439,7 +445,9 @@ function (_super) {
439
445
  bottom = top - scaleH * this.view.height;
440
446
  }
441
447
 
442
- mat4.ortho(this.projectionMatrix, left, right, bottom, top, near, far);
448
+ mat4.ortho(this.projectionMatrix, left, right, bottom, top, near, far); // flipY since the origin of OpenGL/WebGL is bottom-left compared with top-left in Canvas2D
449
+
450
+ mat4.scale(this.projectionMatrix, this.projectionMatrix, vec3.fromValues(1, -1, 1));
443
451
  mat4.invert(this.projectionMatrixInverse, this.projectionMatrix);
444
452
 
445
453
  this._getOrthoMatrix();
@@ -960,7 +968,7 @@ function (_super) {
960
968
 
961
969
  var position = this.position;
962
970
  var rotZ = quat.setAxisAngle(quat.create(), [0, 0, 1], -this.roll * Math.PI / 180);
963
- mat4.fromRotationTranslationScaleOrigin(this.orthoMatrix, rotZ, vec3.fromValues((this.rright - this.left) / 2 - position[0], (this.bottom - this.top) / 2 - position[1], 0), vec3.fromValues(this.zoom, this.zoom, 1), position);
971
+ mat4.fromRotationTranslationScaleOrigin(this.orthoMatrix, rotZ, vec3.fromValues((this.rright - this.left) / 2 - position[0], (this.top - this.bottom) / 2 - position[1], 0), vec3.fromValues(this.zoom, this.zoom, 1), position);
964
972
  };
965
973
 
966
974
  Camera.ProjectionMode = {
@@ -13,4 +13,8 @@ export declare class Sortable {
13
13
  * index in parent's children
14
14
  */
15
15
  lastSortedIndex: number;
16
+ /**
17
+ * render order in whole scenegraph
18
+ */
19
+ renderOrder: number;
16
20
  }
@@ -6,6 +6,11 @@ function () {
6
6
  * need to re-sort
7
7
  */
8
8
  this.dirty = false;
9
+ /**
10
+ * render order in whole scenegraph
11
+ */
12
+
13
+ this.renderOrder = 0;
9
14
  }
10
15
 
11
16
  Sortable.tag = 'c-sortable';
@@ -1,22 +1,21 @@
1
1
  import { DisplayObject } from './DisplayObject';
2
2
  import type { DisplayObjectConfig } from '../dom/interfaces';
3
- export interface CustomElement<CustomElementStyleProps> {
4
- /**
5
- * fired after element insert into DOM tree
6
- */
7
- connectedCallback?: () => void;
8
- /**
9
- * fired before element removed from DOM tree
10
- */
11
- disconnectedCallback?: () => void;
12
- attributeChangedCallback?: <Key extends keyof CustomElementStyleProps>(name: Key, oldValue: CustomElementStyleProps[Key], newValue: CustomElementStyleProps[Key]) => void;
13
- }
14
3
  /**
15
4
  * shadow root
16
5
  * @see https://yuque.antfin-inc.com/antv/czqvg5/pgqipg
17
6
  */
18
7
  export declare abstract class CustomElement<CustomElementStyleProps> extends DisplayObject<CustomElementStyleProps> {
19
8
  constructor(config: DisplayObjectConfig<CustomElementStyleProps>);
9
+ /**
10
+ * fired after element insert into DOM tree
11
+ */
12
+ connectedCallback?(): void;
13
+ /**
14
+ * fired before element removed from DOM tree
15
+ */
16
+ disconnectedCallback?(): void;
17
+ attributeChangedCallback?<Key extends keyof CustomElementStyleProps>(name: Key, oldValue: CustomElementStyleProps[Key], newValue: CustomElementStyleProps[Key]): void;
20
18
  private handleMounted;
19
+ private handleUnmounted;
21
20
  private handleAttributeChanged;
22
21
  }
@@ -15,14 +15,24 @@ function (_super) {
15
15
  function CustomElement(config) {
16
16
  var _this = _super.call(this, config) || this;
17
17
 
18
- _this.handleMounted = function () {
19
- // this.shadowNodes.forEach((node) => {
20
- // // every child and its children should turn into a shadow node
21
- // // a shadow node doesn't mean to be unrenderable, it's just unsearchable in scenegraph
22
- // node.shadow = true;
23
- // });
24
- if (_this.connectedCallback) {
25
- _this.connectedCallback();
18
+ _this.handleMounted = function (e) {
19
+ if (e.target === e.currentTarget) {
20
+ // this.shadowNodes.forEach((node) => {
21
+ // // every child and its children should turn into a shadow node
22
+ // // a shadow node doesn't mean to be unrenderable, it's just unsearchable in scenegraph
23
+ // node.shadow = true;
24
+ // });
25
+ if (_this.connectedCallback) {
26
+ _this.connectedCallback();
27
+ }
28
+ }
29
+ };
30
+
31
+ _this.handleUnmounted = function (e) {
32
+ if (e.target === e.currentTarget) {
33
+ if (_this.disconnectedCallback) {
34
+ _this.disconnectedCallback();
35
+ }
26
36
  }
27
37
  }; // private handleChildInserted = (e: FederatedEvent) => {
28
38
  // (e.target as DisplayObject).forEach((node) => {
@@ -63,11 +73,11 @@ function (_super) {
63
73
  }
64
74
 
65
75
  if (_this.connectedCallback) {
66
- _this.addEventListener(ElementEvent.INSERTED, _this.handleMounted);
76
+ _this.addEventListener(ElementEvent.MOUNTED, _this.handleMounted);
67
77
  }
68
78
 
69
79
  if (_this.disconnectedCallback) {
70
- _this.addEventListener(ElementEvent.REMOVED, _this.disconnectedCallback.bind(_this));
80
+ _this.addEventListener(ElementEvent.UNMOUNTED, _this.handleUnmounted);
71
81
  }
72
82
 
73
83
  return _this;
@@ -2,9 +2,8 @@ import type { mat3, vec2 } from 'gl-matrix';
2
2
  import { mat4, quat, vec3 } from 'gl-matrix';
3
3
  import type { Animation } from '../dom/Animation';
4
4
  import { Element } from '../dom/Element';
5
- import type { DisplayObjectConfig, INode } from '../dom/interfaces';
5
+ import type { DisplayObjectConfig, IChildNode } from '../dom/interfaces';
6
6
  import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
7
- import type { StylePropertyParser, StylePropertyUpdater } from '../property-handlers';
8
7
  /**
9
8
  * prototype chains: DisplayObject -> Element -> Node -> EventTarget
10
9
  *
@@ -32,8 +31,6 @@ export declare class DisplayObject<StyleProps extends BaseStyleProps = any, Pars
32
31
  * push to active animations after calling `animate()`
33
32
  */
34
33
  private activeAnimations;
35
- stylePropertyUpdaterFactory: <Key extends keyof StyleProps>(stylePropertyName: Key) => StylePropertyUpdater<any>[];
36
- stylePropertyParserFactory: <Key extends keyof ParsedStyleProps>(stylePropertyName: Key) => StylePropertyParser<any, any>;
37
34
  constructor(config: DisplayObjectConfig<StyleProps>);
38
35
  destroy(): void;
39
36
  cloneNode(deep?: boolean): this;
@@ -193,7 +190,7 @@ export declare class DisplayObject<StyleProps extends BaseStyleProps = any, Pars
193
190
  * compatible with G 3.0
194
191
  * @deprecated
195
192
  */
196
- add<T extends INode>(child: T, index?: number): T;
193
+ add<T extends IChildNode>(child: T, index?: number): T;
197
194
  /**
198
195
  * @alias style.clipPath
199
196
  * @deprecated
@@ -6,9 +6,10 @@ import { KeyframeEffect } from '../dom/KeyframeEffect';
6
6
  import { Element } from '../dom/Element';
7
7
  import { ElementEvent } from '../dom/interfaces';
8
8
  import { SHAPE } from '../types';
9
- import { createVec3, fromRotationTranslationScale, getEuler, rad2deg } from '../utils';
10
- import { StylePropertyParserFactory, StylePropertyUpdaterFactory } from '../property-handlers';
11
- import { globalContainer } from '../global-module';
9
+ import { createVec3, fromRotationTranslationScale, getEuler, rad2deg } from '../utils'; // import type { StylePropertyParser, StylePropertyUpdater } from '../property-handlers';
10
+ // import { StylePropertyParserFactory, StylePropertyUpdaterFactory } from '../property-handlers';
11
+
12
+ import { globalContainer, stylePropertyParserFactory, stylePropertyUpdaterFactory } from '../global-module';
12
13
  import { dirtifyToRoot } from '../services';
13
14
  var DEFAULT_STYLE_PROPS = {
14
15
  anchor: [0, 0, 0],
@@ -39,7 +40,13 @@ var DEFAULT_STYLE_PROPS = {
39
40
  var DisplayObject =
40
41
  /** @class */
41
42
  function (_super) {
42
- __extends(DisplayObject, _super);
43
+ __extends(DisplayObject, _super); // stylePropertyUpdaterFactory = globalContainer.get<
44
+ // <Key extends keyof StyleProps>(stylePropertyName: Key) => StylePropertyUpdater<any>[]
45
+ // >(StylePropertyUpdaterFactory);
46
+ // stylePropertyParserFactory = globalContainer.get<
47
+ // <Key extends keyof ParsedStyleProps>(stylePropertyName: Key) => StylePropertyParser<any, any>
48
+ // >(StylePropertyParserFactory);
49
+
43
50
 
44
51
  function DisplayObject(config) {
45
52
  var _a, _b, _c;
@@ -50,9 +57,7 @@ function (_super) {
50
57
  */
51
58
 
52
59
 
53
- _this.activeAnimations = [];
54
- _this.stylePropertyUpdaterFactory = globalContainer.get(StylePropertyUpdaterFactory);
55
- _this.stylePropertyParserFactory = globalContainer.get(StylePropertyParserFactory); // assign name, id to config
60
+ _this.activeAnimations = []; // assign name, id to config
56
61
  // eg. group.get('name')
57
62
 
58
63
  _this.config = config; // compatible with G 3.0
@@ -178,7 +183,8 @@ function (_super) {
178
183
 
179
184
 
180
185
  DisplayObject.prototype.parseStyleProperty = function (name, value) {
181
- var stylePropertyParser = this.stylePropertyParserFactory(name);
186
+ // const stylePropertyParser = this.stylePropertyParserFactory(name);
187
+ var stylePropertyParser = stylePropertyParserFactory[name];
182
188
 
183
189
  if (stylePropertyParser) {
184
190
  // @ts-ignore
@@ -191,9 +197,10 @@ function (_super) {
191
197
  DisplayObject.prototype.updateStyleProperty = function (name, oldParsedValue, newParsedValue) {
192
198
  var _this = this; // update property, which may cause AABB re-calc
193
199
  // @ts-ignore
200
+ // const stylePropertyUpdaters = this.stylePropertyUpdaterFactory(name);
194
201
 
195
202
 
196
- var stylePropertyUpdaters = this.stylePropertyUpdaterFactory(name);
203
+ var stylePropertyUpdaters = stylePropertyUpdaterFactory[name];
197
204
 
198
205
  if (stylePropertyUpdaters) {
199
206
  stylePropertyUpdaters.forEach(function (updater) {
@@ -7,12 +7,16 @@ export interface LineStyleProps extends BaseStyleProps {
7
7
  y1: number;
8
8
  x2: number;
9
9
  y2: number;
10
+ z1?: number;
11
+ z2?: number;
10
12
  }
11
13
  export interface ParsedLineStyleProps extends ParsedBaseStyleProps {
12
14
  x1: number;
13
15
  y1: number;
14
16
  x2: number;
15
17
  y2: number;
18
+ z1?: number;
19
+ z2?: number;
16
20
  defX: number;
17
21
  defY: number;
18
22
  }
@@ -20,6 +20,8 @@ function (_super) {
20
20
  y1: 0,
21
21
  x2: 0,
22
22
  y2: 0,
23
+ z1: 0,
24
+ z2: 0,
23
25
  lineJoin: "miter"
24
26
  /* Miter */
25
27
  ,
@@ -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.
@@ -3,7 +3,7 @@ import { Cullable, Geometry, Renderable, Transform, Sortable } from '../componen
3
3
  import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
4
4
  import { Node } from './Node';
5
5
  import type { AABB, Rectangle } from '../shapes';
6
- import type { IEventTarget, IChildNode, IElement, INode } from './interfaces';
6
+ import type { IEventTarget, IElement, INode } from './interfaces';
7
7
  /**
8
8
  * Has following capabilities:
9
9
  * * Node insert/remove, eg. appendChild, removeChild, remove...
@@ -51,8 +51,8 @@ export declare class Element<StyleProps extends BaseStyleProps = any, ParsedStyl
51
51
  get previousSibling(): IElement | null;
52
52
  cloneNode(deep?: boolean): this;
53
53
  appendChild<T extends INode>(child: T, index?: number): T;
54
- insertBefore<T extends INode>(newChild: T, refChild: IElement | null): T;
55
- 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;
56
56
  removeChild<T extends INode>(child: T, destroy?: boolean): T;
57
57
  removeChildren(destroy?: boolean): void;
58
58
  /**
@@ -73,27 +73,27 @@ export declare class Element<StyleProps extends BaseStyleProps = any, ParsedStyl
73
73
  /**
74
74
  * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/after
75
75
  */
76
- after(...nodes: IElement[]): void;
76
+ after(...nodes: INode[]): void;
77
77
  /**
78
78
  * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/before
79
79
  */
80
- before(...nodes: IElement[]): void;
80
+ before(...nodes: INode[]): void;
81
81
  /**
82
82
  * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/replaceWith
83
83
  */
84
- replaceWith(...nodes: IElement[]): void;
84
+ replaceWith(...nodes: INode[]): void;
85
85
  /**
86
86
  * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/append
87
87
  */
88
- append(...nodes: IElement[]): void;
88
+ append(...nodes: INode[]): void;
89
89
  /**
90
90
  * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/prepend
91
91
  */
92
- prepend(...nodes: IElement[]): void;
92
+ prepend(...nodes: INode[]): void;
93
93
  /**
94
94
  * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/replaceChildren
95
95
  */
96
- replaceChildren(...nodes: IElement[]): void;
96
+ replaceChildren(...nodes: INode[]): void;
97
97
  /**
98
98
  * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/remove
99
99
  */
package/es/dom/Element.js CHANGED
@@ -298,6 +298,8 @@ function (_super) {
298
298
 
299
299
 
300
300
  Element.prototype.before = function () {
301
+ var _a;
302
+
301
303
  var nodes = [];
302
304
 
303
305
  for (var _i = 0; _i < arguments.length; _i++) {
@@ -307,12 +309,13 @@ function (_super) {
307
309
  if (this.parentNode) {
308
310
  var index = this.parentNode.childNodes.indexOf(this);
309
311
 
310
- var _a = __read(nodes),
311
- first = _a[0],
312
- rest = _a.slice(1);
312
+ var _b = __read(nodes),
313
+ first = _b[0],
314
+ rest = _b.slice(1);
313
315
 
314
316
  this.parentNode.appendChild(first, index);
315
- first.after.apply(first, __spreadArray([], __read(rest), false));
317
+
318
+ (_a = first).after.apply(_a, __spreadArray([], __read(rest), false));
316
319
  }
317
320
  };
318
321
  /**
package/es/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
  */
@@ -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
  }
@@ -1,6 +1,6 @@
1
1
  import type EventEmitter from 'eventemitter3';
2
2
  import type { AnimationTimeline } from './AnimationTimeline';
3
- import type { BaseStyleProps, ParsedBaseStyleProps, SHAPE } from '../types';
3
+ import type { BaseStyleProps, SHAPE } from '../types';
4
4
  import type { FederatedEvent } from './FederatedEvent';
5
5
  import type { CustomElementRegistry } from './CustomElementRegistry';
6
6
  import type { DisplayObject } from '..';
@@ -31,7 +31,11 @@ export declare enum ElementEvent {
31
31
  CHILD_REMOVED = "child-removed",
32
32
  MOUNTED = "mounted",
33
33
  UNMOUNTED = "unmounted",
34
- BOUNDS_CHANGED = "bounds-changed"
34
+ BOUNDS_CHANGED = "bounds-changed",
35
+ /**
36
+ * trigger when z-index changed
37
+ */
38
+ RENDER_ORDER_CHANGED = "render-order-changed"
35
39
  }
36
40
  export interface IEventTarget {
37
41
  emitter: EventEmitter;
@@ -52,11 +56,11 @@ export interface INode extends IEventTarget {
52
56
  /**
53
57
  * Returns the children.
54
58
  */
55
- readonly childNodes: (IChildNode & INode)[];
59
+ readonly childNodes: IChildNode[];
56
60
  /**
57
61
  * Returns the first child.
58
62
  */
59
- readonly firstChild: (IChildNode & INode) | null;
63
+ readonly firstChild: IChildNode | null;
60
64
  /**
61
65
  * Returns true if node is connected and false otherwise.
62
66
  */
@@ -64,11 +68,11 @@ export interface INode extends IEventTarget {
64
68
  /**
65
69
  * Returns the last child.
66
70
  */
67
- readonly lastChild: (IChildNode & INode) | null;
71
+ readonly lastChild: IChildNode | null;
68
72
  /**
69
73
  * Returns the next sibling.
70
74
  */
71
- readonly nextSibling: (IChildNode & INode) | null;
75
+ readonly nextSibling: IChildNode | null;
72
76
  /**
73
77
  * Returns a string appropriate for the type of node.
74
78
  */
@@ -93,7 +97,7 @@ export interface INode extends IEventTarget {
93
97
  /**
94
98
  * Returns the previous sibling.
95
99
  */
96
- readonly previousSibling: (IChildNode & INode) | null;
100
+ readonly previousSibling: IChildNode | null;
97
101
  textContent: string | null;
98
102
  appendChild: <T extends INode>(newChild: T, index?: number) => T;
99
103
  /**
@@ -138,7 +142,7 @@ export interface INode extends IEventTarget {
138
142
  */
139
143
  normalize: () => void;
140
144
  removeChild: <T extends INode>(oldChild: T, destroy?: boolean) => T;
141
- replaceChild: <T extends INode & IChildNode>(newChild: INode, oldChild: T, destroy?: boolean) => T;
145
+ replaceChild: <T extends INode>(newChild: INode, oldChild: T, destroy?: boolean) => T;
142
146
  /**
143
147
  * Destroy itself.
144
148
  */
@@ -250,7 +254,7 @@ export interface DisplayObjectConfig<StyleProps> {
250
254
  */
251
255
  interactive?: boolean;
252
256
  }
253
- export interface IElement<StyleProps extends BaseStyleProps = any, ParsedStyleProps extends ParsedBaseStyleProps = any> extends INode, IChildNode, IParentNode {
257
+ export interface IElement<StyleProps = any, ParsedStyleProps = any> extends INode, IChildNode, IParentNode {
254
258
  /**
255
259
  * Returns the value of element's id content attribute. Can be set to change it.
256
260
  */
@@ -29,4 +29,9 @@ export var ElementEvent;
29
29
  ElementEvent["MOUNTED"] = "mounted";
30
30
  ElementEvent["UNMOUNTED"] = "unmounted";
31
31
  ElementEvent["BOUNDS_CHANGED"] = "bounds-changed";
32
+ /**
33
+ * trigger when z-index changed
34
+ */
35
+
36
+ ElementEvent["RENDER_ORDER_CHANGED"] = "render-order-changed";
32
37
  })(ElementEvent || (ElementEvent = {}));
@@ -1,2 +1,6 @@
1
+ import type { StylePropertyParser, StylePropertyMerger, StylePropertyUpdater } from './property-handlers';
1
2
  export declare const globalContainer: import("mana-syringe").Container;
3
+ export declare const stylePropertyParserFactory: Record<string, StylePropertyParser<any, any>>;
4
+ export declare const stylePropertyUpdaterFactory: Record<string, StylePropertyUpdater<any>[]>;
5
+ export declare const stylePropertyMergerFactory: Record<string, StylePropertyMerger<any, any>>;
2
6
  export declare const containerModule: import("mana-syringe").SyringeModule;