@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
@@ -1,12 +1,12 @@
1
- import EventEmitter from 'eventemitter3';
1
+ import type EventEmitter from 'eventemitter3';
2
2
  import type { AnimationTimeline } from './AnimationTimeline';
3
- import { BaseStyleProps, ParsedBaseStyleProps, SHAPE } from '../types';
3
+ import type { BaseStyleProps, SHAPE } from '../types';
4
4
  import type { FederatedEvent } from './FederatedEvent';
5
- import { CustomElementRegistry } from './CustomElementRegistry';
6
- import { DisplayObject } from '..';
5
+ import type { CustomElementRegistry } from './CustomElementRegistry';
6
+ import type { DisplayObject } from '..';
7
7
  import type { PointLike } from '../shapes';
8
8
  import type { Camera } from '../camera';
9
- import { ContextService } from '../services';
9
+ import type { ContextService } from '../services';
10
10
  /**
11
11
  * built-in events for element
12
12
  */
@@ -35,13 +35,13 @@ export declare enum ElementEvent {
35
35
  }
36
36
  export interface IEventTarget {
37
37
  emitter: EventEmitter;
38
- on(type: string, listener: EventListenerOrEventListenerObject | ((...args: any[]) => void), options?: boolean | AddEventListenerOptions): this;
39
- addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): this;
40
- off(type: string, listener: EventListenerOrEventListenerObject | ((...args: any[]) => void), options?: boolean | AddEventListenerOptions): this;
41
- removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): this;
42
- removeAllEventListeners(): void;
43
- dispatchEvent<T extends FederatedEvent>(e: T): boolean;
44
- emit(eventName: string, object: object): void;
38
+ on: (type: string, listener: EventListenerOrEventListenerObject | ((...args: any[]) => void), options?: boolean | AddEventListenerOptions) => this;
39
+ addEventListener: (type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions) => this;
40
+ off: (type: string, listener: EventListenerOrEventListenerObject | ((...args: any[]) => void), options?: boolean | AddEventListenerOptions) => this;
41
+ removeEventListener: (type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions) => this;
42
+ removeAllEventListeners: () => void;
43
+ dispatchEvent: <T extends FederatedEvent>(e: T) => boolean;
44
+ emit: (eventName: string, object: object) => void;
45
45
  }
46
46
  export interface INode extends IEventTarget {
47
47
  shadow: boolean;
@@ -52,11 +52,11 @@ export interface INode extends IEventTarget {
52
52
  /**
53
53
  * Returns the children.
54
54
  */
55
- readonly childNodes: (IChildNode & INode)[];
55
+ readonly childNodes: IChildNode[];
56
56
  /**
57
57
  * Returns the first child.
58
58
  */
59
- readonly firstChild: (IChildNode & INode) | null;
59
+ readonly firstChild: IChildNode | null;
60
60
  /**
61
61
  * Returns true if node is connected and false otherwise.
62
62
  */
@@ -64,11 +64,11 @@ export interface INode extends IEventTarget {
64
64
  /**
65
65
  * Returns the last child.
66
66
  */
67
- readonly lastChild: (IChildNode & INode) | null;
67
+ readonly lastChild: IChildNode | null;
68
68
  /**
69
69
  * Returns the next sibling.
70
70
  */
71
- readonly nextSibling: (IChildNode & INode) | null;
71
+ readonly nextSibling: IChildNode | null;
72
72
  /**
73
73
  * Returns a string appropriate for the type of node.
74
74
  */
@@ -93,56 +93,56 @@ export interface INode extends IEventTarget {
93
93
  /**
94
94
  * Returns the previous sibling.
95
95
  */
96
- readonly previousSibling: (IChildNode & INode) | null;
96
+ readonly previousSibling: IChildNode | null;
97
97
  textContent: string | null;
98
- appendChild<T extends INode>(newChild: T, index?: number): T;
98
+ appendChild: <T extends INode>(newChild: T, index?: number) => T;
99
99
  /**
100
100
  * Returns a copy of node. If deep is true, the copy also includes the node's descendants.
101
101
  */
102
- cloneNode(deep?: boolean): INode;
102
+ cloneNode: (deep?: boolean) => INode;
103
103
  /**
104
104
  * Returns a bitmask indicating the position of other relative to node.
105
105
  */
106
- compareDocumentPosition(other: INode): number;
106
+ compareDocumentPosition: (other: INode) => number;
107
107
  /**
108
108
  * Returns true if other is an inclusive descendant of node, and false otherwise.
109
109
  */
110
- contains(other: INode | null): boolean;
110
+ contains: (other: INode | null) => boolean;
111
111
  /**
112
112
  * Returns node's root.
113
113
  */
114
- getRootNode(options?: GetRootNodeOptions): INode;
114
+ getRootNode: (options?: GetRootNodeOptions) => INode;
115
115
  /**
116
116
  * Returns node's ancestor.
117
117
  */
118
- getAncestor(n: number): INode | null;
118
+ getAncestor: (n: number) => INode | null;
119
119
  /**
120
120
  * Traverse in sub tree.
121
121
  */
122
- forEach(callback: (o: INode) => void | boolean): void;
122
+ forEach: (callback: (o: INode) => void | boolean) => void;
123
123
  /**
124
124
  * Returns whether node has children.
125
125
  */
126
- hasChildNodes(): boolean;
127
- insertBefore<T extends INode>(newChild: T, refChild: INode | null): T;
128
- isDefaultNamespace(namespace: string | null): boolean;
126
+ hasChildNodes: () => boolean;
127
+ insertBefore: <T extends INode>(newChild: T, refChild: INode | null) => T;
128
+ isDefaultNamespace: (namespace: string | null) => boolean;
129
129
  /**
130
130
  * Returns whether node and otherNode have the same properties.
131
131
  */
132
- isEqualNode(otherNode: INode | null): boolean;
133
- isSameNode(otherNode: INode | null): boolean;
134
- lookupNamespaceURI(prefix: string | null): string | null;
135
- lookupPrefix(namespace: string | null): string | null;
132
+ isEqualNode: (otherNode: INode | null) => boolean;
133
+ isSameNode: (otherNode: INode | null) => boolean;
134
+ lookupNamespaceURI: (prefix: string | null) => string | null;
135
+ lookupPrefix: (namespace: string | null) => string | null;
136
136
  /**
137
137
  * Removes empty exclusive Text nodes and concatenates the data of remaining contiguous exclusive Text nodes into the first of their nodes.
138
138
  */
139
- normalize(): void;
140
- removeChild<T extends INode>(oldChild: T, destroy?: boolean): T;
141
- replaceChild<T extends INode & IChildNode>(newChild: INode, oldChild: T, destroy?: boolean): T;
139
+ normalize: () => void;
140
+ removeChild: <T extends INode>(oldChild: T, destroy?: boolean) => T;
141
+ replaceChild: <T extends INode>(newChild: INode, oldChild: T, destroy?: boolean) => T;
142
142
  /**
143
143
  * Destroy itself.
144
144
  */
145
- destroy(): void;
145
+ destroy: () => void;
146
146
  }
147
147
  export interface IParentNode {
148
148
  readonly childElementCount: number;
@@ -163,29 +163,29 @@ export interface IParentNode {
163
163
  *
164
164
  * Throws a "HierarchyRequestError" DOMException if the constraints of the node tree are violated.
165
165
  */
166
- append(...nodes: INode[]): void;
166
+ append: (...nodes: INode[]) => void;
167
167
  /**
168
168
  * Inserts nodes before the first child of node, while replacing strings in nodes with equivalent Text nodes.
169
169
  *
170
170
  * Throws a "HierarchyRequestError" DOMException if the constraints of the node tree are violated.
171
171
  */
172
- prepend(...nodes: INode[]): void;
172
+ prepend: (...nodes: INode[]) => void;
173
173
  /**
174
174
  * Returns the first element that is a descendant of node that matches selectors.
175
175
  */
176
- querySelector<E extends IElement = IElement>(selectors: string): E | null;
176
+ querySelector: <E extends IElement = IElement>(selectors: string) => E | null;
177
177
  /**
178
178
  * Returns all element descendants of node that match selectors.
179
179
  */
180
- querySelectorAll<E extends IElement = IElement>(selectors: string): E[];
180
+ querySelectorAll: <E extends IElement = IElement>(selectors: string) => E[];
181
181
  /**
182
182
  * Similar to querySelector, use custom filter instead of selectors.
183
183
  */
184
- find<E extends IElement = IElement>(filter: (node: E) => boolean): E | null;
184
+ find: <E extends IElement = IElement>(filter: (node: E) => boolean) => E | null;
185
185
  /**
186
186
  * Similar to querySelectorAll, use custom filter instead of selectors.
187
187
  */
188
- findAll<E extends IElement = IElement>(filter: (node: E) => boolean): E[];
188
+ findAll: <E extends IElement = IElement>(filter: (node: E) => boolean) => E[];
189
189
  }
190
190
  export interface IChildNode extends INode {
191
191
  /**
@@ -193,23 +193,23 @@ export interface IChildNode extends INode {
193
193
  *
194
194
  * Throws a "HierarchyRequestError" DOMException if the constraints of the node tree are violated.
195
195
  */
196
- after(...nodes: INode[]): void;
196
+ after: (...nodes: INode[]) => void;
197
197
  /**
198
198
  * Inserts nodes just before node, while replacing strings in nodes with equivalent Text nodes.
199
199
  *
200
200
  * Throws a "HierarchyRequestError" DOMException if the constraints of the node tree are violated.
201
201
  */
202
- before(...nodes: INode[]): void;
202
+ before: (...nodes: INode[]) => void;
203
203
  /**
204
204
  * Removes node.
205
205
  */
206
- remove(): void;
206
+ remove: () => void;
207
207
  /**
208
208
  * Replaces node with nodes, while replacing strings in nodes with equivalent Text nodes.
209
209
  *
210
210
  * Throws a "HierarchyRequestError" DOMException if the constraints of the node tree are violated.
211
211
  */
212
- replaceWith(...nodes: INode[]): void;
212
+ replaceWith: (...nodes: INode[]) => void;
213
213
  }
214
214
  export interface DisplayObjectConfig<StyleProps> {
215
215
  /**
@@ -250,7 +250,7 @@ export interface DisplayObjectConfig<StyleProps> {
250
250
  */
251
251
  interactive?: boolean;
252
252
  }
253
- export interface IElement<StyleProps extends BaseStyleProps = any, ParsedStyleProps extends ParsedBaseStyleProps = any> extends INode, IChildNode, IParentNode {
253
+ export interface IElement<StyleProps = any, ParsedStyleProps = any> extends INode, IChildNode, IParentNode {
254
254
  /**
255
255
  * Returns the value of element's id content attribute. Can be set to change it.
256
256
  */
@@ -274,24 +274,24 @@ export interface IElement<StyleProps extends BaseStyleProps = any, ParsedStylePr
274
274
  */
275
275
  style: StyleProps;
276
276
  parsedStyle: ParsedStyleProps;
277
- getElementById<E extends IElement = IElement>(id: string): E | null;
278
- getElementsByName<E extends IElement = IElement>(name: string): E[];
279
- getElementsByClassName<E extends IElement = IElement>(className: string): E[];
280
- getElementsByTagName<E extends IElement = IElement>(tagName: string): E[];
277
+ getElementById: <E extends IElement = IElement>(id: string) => E | null;
278
+ getElementsByName: <E extends IElement = IElement>(name: string) => E[];
279
+ getElementsByClassName: <E extends IElement = IElement>(className: string) => E[];
280
+ getElementsByTagName: <E extends IElement = IElement>(tagName: string) => E[];
281
281
  scrollLeft: number;
282
282
  scrollTop: number;
283
283
  /**
284
284
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/setAttribute
285
285
  */
286
- setAttribute<Key extends keyof StyleProps>(attributeName: Key, value: StyleProps[Key], force?: boolean): void;
286
+ setAttribute: <Key extends keyof StyleProps>(attributeName: Key, value: StyleProps[Key], force?: boolean) => void;
287
287
  /**
288
288
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getAttribute
289
289
  */
290
- getAttribute(attributeName: keyof StyleProps): StyleProps[keyof StyleProps] | undefined;
290
+ getAttribute: (attributeName: keyof StyleProps) => StyleProps[keyof StyleProps] | undefined;
291
291
  /**
292
292
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/removeAttribute
293
293
  */
294
- removeAttribute(attributeName: keyof StyleProps): void;
294
+ removeAttribute: (attributeName: keyof StyleProps) => void;
295
295
  }
296
296
  export interface IDocument extends INode, IParentNode {
297
297
  /**
@@ -307,18 +307,18 @@ export interface IDocument extends INode, IParentNode {
307
307
  /**
308
308
  * Creates an instance of the element for the specified tag.
309
309
  */
310
- createElement<T extends DisplayObject<StyleProps>, StyleProps extends BaseStyleProps>(tagName: string, options: DisplayObjectConfig<StyleProps>): T;
310
+ createElement: <T extends DisplayObject<StyleProps>, StyleProps extends BaseStyleProps>(tagName: string, options: DisplayObjectConfig<StyleProps>) => T;
311
311
  }
312
312
  export interface ICanvas extends IEventTarget {
313
313
  document: IDocument;
314
314
  customElements: CustomElementRegistry;
315
- render(): void;
316
- destroy(destroyScenegraph?: boolean): void;
317
- resize(width: number, height: number): void;
318
- getCamera(): Camera;
319
- getContextService(): ContextService<unknown>;
320
- client2Viewport(client: PointLike): PointLike;
321
- viewport2Client(viewport: PointLike): PointLike;
322
- canvas2Viewport(canvas: PointLike): PointLike;
323
- viewport2Canvas(viewport: PointLike): PointLike;
315
+ render: () => void;
316
+ destroy: (destroyScenegraph?: boolean) => void;
317
+ resize: (width: number, height: number) => void;
318
+ getCamera: () => Camera;
319
+ getContextService: () => ContextService<unknown>;
320
+ client2Viewport: (client: PointLike) => PointLike;
321
+ viewport2Client: (viewport: PointLike) => PointLike;
322
+ canvas2Viewport: (canvas: PointLike) => PointLike;
323
+ viewport2Canvas: (viewport: PointLike) => PointLike;
324
324
  }
@@ -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;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.globalContainer = exports.containerModule = void 0;
6
+ exports.stylePropertyUpdaterFactory = exports.stylePropertyParserFactory = exports.stylePropertyMergerFactory = exports.globalContainer = exports.containerModule = void 0;
7
7
 
8
8
  var _manaSyringe = require("mana-syringe");
9
9
 
@@ -27,6 +27,12 @@ var _propertyHandlers = require("./property-handlers");
27
27
 
28
28
  var globalContainer = _manaSyringe.GlobalContainer;
29
29
  exports.globalContainer = globalContainer;
30
+ var stylePropertyParserFactory = {};
31
+ exports.stylePropertyParserFactory = stylePropertyParserFactory;
32
+ var stylePropertyUpdaterFactory = {};
33
+ exports.stylePropertyUpdaterFactory = stylePropertyUpdaterFactory;
34
+ var stylePropertyMergerFactory = {};
35
+ exports.stylePropertyMergerFactory = stylePropertyMergerFactory;
30
36
  var containerModule = (0, _manaSyringe.Module)(function (register) {
31
37
  (0, _manaSyringe.decorate)((0, _manaSyringe.injectable)(), _eventemitter.EventEmitter); // bind DisplayObject pool
32
38
 
@@ -74,83 +80,65 @@ var containerModule = (0, _manaSyringe.Module)(function (register) {
74
80
  return cache[tagName];
75
81
  };
76
82
  }
77
- }); // bind style property handlers
78
-
79
- register({
80
- token: _propertyHandlers.StylePropertyParserFactory,
81
- useFactory: function useFactory(context) {
82
- var cache = {};
83
- return function (propertyName) {
84
- if (!cache[propertyName]) {
85
- if (context.container.isBoundNamed(_propertyHandlers.StylePropertyParser, propertyName)) {
86
- cache[propertyName] = context.container.getNamed(_propertyHandlers.StylePropertyParser, propertyName);
87
- }
88
- }
89
-
90
- return cache[propertyName];
91
- };
92
- }
93
- });
94
- register({
95
- token: _propertyHandlers.StylePropertyUpdaterFactory,
96
- useFactory: function useFactory(context) {
97
- var cache = {};
98
- return function (propertyName) {
99
- if (!cache[propertyName]) {
100
- if (context.container.isBoundNamed(_propertyHandlers.StylePropertyUpdater, propertyName)) {
101
- cache[propertyName] = context.container.getAllNamed(_propertyHandlers.StylePropertyUpdater, propertyName);
102
- }
103
- }
104
-
105
- return cache[propertyName];
106
- };
107
- }
108
- });
109
- register({
110
- token: _propertyHandlers.StylePropertyMergerFactory,
111
- useFactory: function useFactory(context) {
112
- var cache = {};
113
- return function (propertyName) {
114
- if (!cache[propertyName]) {
115
- if (context.container.isBoundNamed(_propertyHandlers.StylePropertyMerger, propertyName)) {
116
- cache[propertyName] = context.container.getNamed(_propertyHandlers.StylePropertyMerger, propertyName);
117
- }
118
- }
119
-
120
- return cache[propertyName];
121
- };
122
- }
123
- });
83
+ }); // // bind style property handlers
84
+ // register({
85
+ // token: StylePropertyParserFactory,
86
+ // useFactory: (context) => {
87
+ // const cache = {};
88
+ // return (propertyName: string) => {
89
+ // if (!cache[propertyName]) {
90
+ // if (context.container.isBoundNamed(StylePropertyParser, propertyName)) {
91
+ // cache[propertyName] = context.container.getNamed(StylePropertyParser, propertyName);
92
+ // }
93
+ // }
94
+ // return cache[propertyName];
95
+ // };
96
+ // },
97
+ // });
98
+ // register({
99
+ // token: StylePropertyUpdaterFactory,
100
+ // useFactory: (context) => {
101
+ // const cache = {};
102
+ // return (propertyName: string) => {
103
+ // if (!cache[propertyName]) {
104
+ // if (context.container.isBoundNamed(StylePropertyUpdater, propertyName)) {
105
+ // cache[propertyName] = context.container.getAllNamed(StylePropertyUpdater, propertyName);
106
+ // }
107
+ // }
108
+ // return cache[propertyName];
109
+ // };
110
+ // },
111
+ // });
112
+ // register({
113
+ // token: StylePropertyMergerFactory,
114
+ // useFactory: (context) => {
115
+ // const cache = {};
116
+ // return (propertyName: string) => {
117
+ // if (!cache[propertyName]) {
118
+ // if (context.container.isBoundNamed(StylePropertyMerger, propertyName)) {
119
+ // cache[propertyName] = context.container.getNamed(StylePropertyMerger, propertyName);
120
+ // }
121
+ // }
122
+ // return cache[propertyName];
123
+ // };
124
+ // },
125
+ // });
124
126
 
125
127
  function addPropertyHandler(property, parser, merger, updater) {
126
128
  if (parser) {
127
- register({
128
- token: {
129
- token: _propertyHandlers.StylePropertyParser,
130
- named: property
131
- },
132
- useValue: parser
133
- });
129
+ stylePropertyParserFactory[property] = parser; // register({ token: { token: StylePropertyParser, named: property }, useValue: parser });
134
130
  }
135
131
 
136
132
  if (merger) {
137
- register({
138
- token: {
139
- token: _propertyHandlers.StylePropertyMerger,
140
- named: property
141
- },
142
- useValue: merger
143
- });
133
+ stylePropertyMergerFactory[property] = merger; // register({ token: { token: StylePropertyMerger, named: property }, useValue: merger });
144
134
  }
145
135
 
146
136
  if (updater) {
147
- register({
148
- token: {
149
- token: _propertyHandlers.StylePropertyUpdater,
150
- named: property
151
- },
152
- useValue: updater
153
- });
137
+ if (!stylePropertyUpdaterFactory[property]) {
138
+ stylePropertyUpdaterFactory[property] = [];
139
+ }
140
+
141
+ stylePropertyUpdaterFactory[property].push(updater); // register({ token: { token: StylePropertyUpdater, named: property }, useValue: updater });
154
142
  }
155
143
  }
156
144
 
@@ -1,9 +1,9 @@
1
1
  import { Syringe } from 'mana-syringe';
2
- import { DisplayObject } from '../display-objects/DisplayObject';
3
- import { RenderingService, RenderingPlugin } from '../services/RenderingService';
2
+ import type { DisplayObject } from '../display-objects/DisplayObject';
3
+ import type { RenderingService, RenderingPlugin } from '../services/RenderingService';
4
4
  export declare const CullingStrategyContribution: Syringe.DefinedToken;
5
5
  export interface CullingStrategyContribution {
6
- isVisible(object: DisplayObject): boolean;
6
+ isVisible: (object: DisplayObject) => boolean;
7
7
  }
8
8
  /**
9
9
  * apply following rules:
@@ -1,4 +1,4 @@
1
- import { RenderingService, RenderingPlugin } from '../services/RenderingService';
1
+ import type { RenderingService, RenderingPlugin } from '../services/RenderingService';
2
2
  /**
3
3
  * Filter dirty renderables and calculate the "dirty rectangle" which will be clear when frame began
4
4
  */
@@ -1,4 +1,5 @@
1
- import { RenderingPlugin, RenderingService } from '../services';
1
+ import type { RenderingPlugin } from '../services';
2
+ import { RenderingService } from '../services';
2
3
  /**
3
4
  * support mouse & touch events
4
5
  * @see https://github.com/pixijs/pixi.js/blob/dev/packages/interaction/README.md
@@ -1,7 +1,6 @@
1
1
  import { CullingStrategyContribution } from './CullingPlugin';
2
- import { DisplayObject } from '../display-objects/DisplayObject';
2
+ import type { DisplayObject } from '../display-objects/DisplayObject';
3
3
  export declare class FrustumCullingStrategy implements CullingStrategyContribution {
4
- private camera;
5
4
  isVisible(object: DisplayObject): boolean;
6
5
  /**
7
6
  *
@@ -15,40 +15,39 @@ var _CullingPlugin = require("./CullingPlugin");
15
15
 
16
16
  var _shapes = require("../shapes");
17
17
 
18
- var _Camera = require("../camera/Camera");
19
-
18
+ // import { vec3, mat4 } from 'gl-matrix';
19
+ // import { inject, singleton } from 'mana-syringe';
20
+ // import type { Element } from '../dom';
20
21
  var FrustumCullingStrategy =
21
22
  /** @class */
22
23
  function () {
23
- function FrustumCullingStrategy() {}
24
-
25
- FrustumCullingStrategy.prototype.isVisible = function (object) {
26
- var _a, _b;
27
-
28
- var entity = object.entity;
29
- var cullable = object.cullable;
30
- return true;
31
-
32
- if (!cullable.enable) {
33
- return true;
34
- }
24
+ function FrustumCullingStrategy() {} // @inject(DefaultCamera)
25
+ // private camera: Camera;
26
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
35
27
 
36
- var renderBounds = object.getRenderBounds();
37
28
 
38
- if (!renderBounds) {
39
- return false;
40
- }
41
-
42
- var viewMatrix = this.camera.getViewTransform();
43
-
44
- var vpMatrix = _glMatrix.mat4.multiply(_glMatrix.mat4.create(), this.camera.getPerspective(), viewMatrix); // get VP matrix from camera
45
-
46
-
47
- this.camera.getFrustum().extractFromVPMatrix(vpMatrix);
48
- var parentVisibilityPlaneMask = (_b = (_a = object.parentNode) === null || _a === void 0 ? void 0 : _a.cullable) === null || _b === void 0 ? void 0 : _b.visibilityPlaneMask;
49
- cullable.visibilityPlaneMask = this.computeVisibilityWithPlaneMask(renderBounds, parentVisibilityPlaneMask || _shapes.Mask.INDETERMINATE, this.camera.getFrustum().planes);
50
- cullable.visible = cullable.visibilityPlaneMask !== _shapes.Mask.OUTSIDE;
51
- return cullable.visible;
29
+ FrustumCullingStrategy.prototype.isVisible = function (object) {
30
+ return true; // const entity = object.entity;
31
+ // const cullable = object.cullable;
32
+ // if (!cullable.enable) {
33
+ // return true;
34
+ // }
35
+ // const renderBounds = object.getRenderBounds();
36
+ // if (!renderBounds) {
37
+ // return false;
38
+ // }
39
+ // const viewMatrix = this.camera.getViewTransform();
40
+ // const vpMatrix = mat4.multiply(mat4.create(), this.camera.getPerspective(), viewMatrix);
41
+ // // get VP matrix from camera
42
+ // this.camera.getFrustum().extractFromVPMatrix(vpMatrix);
43
+ // const parentVisibilityPlaneMask = (object.parentNode as Element)?.cullable?.visibilityPlaneMask;
44
+ // cullable.visibilityPlaneMask = this.computeVisibilityWithPlaneMask(
45
+ // renderBounds,
46
+ // parentVisibilityPlaneMask || Mask.INDETERMINATE,
47
+ // this.camera.getFrustum().planes,
48
+ // );
49
+ // cullable.visible = cullable.visibilityPlaneMask !== Mask.OUTSIDE;
50
+ // return cullable.visible;
52
51
  };
53
52
  /**
54
53
  *
@@ -104,7 +103,6 @@ function () {
104
103
  return mask;
105
104
  };
106
105
 
107
- (0, _tslib.__decorate)([(0, _manaSyringe.inject)(_Camera.DefaultCamera), (0, _tslib.__metadata)("design:type", _Camera.Camera)], FrustumCullingStrategy.prototype, "camera", void 0);
108
106
  FrustumCullingStrategy = (0, _tslib.__decorate)([(0, _manaSyringe.singleton)({
109
107
  contrib: _CullingPlugin.CullingStrategyContribution
110
108
  })], FrustumCullingStrategy);
@@ -1,4 +1,4 @@
1
- import { RenderingService, RenderingPlugin } from '../services/RenderingService';
1
+ import type { RenderingService, RenderingPlugin } from '../services/RenderingService';
2
2
  export declare class PrepareRendererPlugin implements RenderingPlugin {
3
3
  static tag: string;
4
4
  private renderingContext;
@@ -23,35 +23,22 @@ function () {
23
23
  PrepareRendererPlugin.prototype.apply = function (renderingService) {
24
24
  var _this = this;
25
25
 
26
- var handleAttributeChanged = function handleAttributeChanged(e) {
26
+ var handleAttributeChanged = function handleAttributeChanged() {
27
27
  _this.renderingContext.renderReasons.add(_services.RENDER_REASON.DisplayObjectChanged);
28
28
  };
29
29
 
30
- var dirtifyToRoot = function dirtifyToRoot(e) {
31
- // skip Document & Canvas
32
- var path = e.composedPath().slice(0, -2);
33
- path.forEach(function (node) {
34
- var renderable = node.renderable;
35
-
36
- if (renderable) {
37
- renderable.renderBoundsDirty = true;
38
- renderable.boundsDirty = true;
39
- renderable.dirty = true;
40
- }
41
- });
30
+ var handleBoundsChanged = function handleBoundsChanged() {
42
31
  renderingService.dirtify();
43
32
  };
44
33
 
45
- var handleBoundsChanged = function handleBoundsChanged(e) {
46
- dirtifyToRoot(e);
47
- };
48
-
49
34
  var handleMounted = function handleMounted(e) {
50
- dirtifyToRoot(e);
35
+ (0, _services.dirtifyToRoot)(e.target);
36
+ renderingService.dirtify();
51
37
  };
52
38
 
53
39
  var handleUnmounted = function handleUnmounted(e) {
54
- dirtifyToRoot(e);
40
+ (0, _services.dirtifyToRoot)(e.target);
41
+ renderingService.dirtify();
55
42
  };
56
43
 
57
44
  renderingService.hooks.init.tap(PrepareRendererPlugin_1.tag, function () {