@antv/g 1.0.0-alpha.20 → 1.0.0-alpha.24

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 (293) hide show
  1. package/es/Canvas.d.ts +40 -18
  2. package/es/Canvas.js +121 -65
  3. package/es/DisplayObjectPool.d.ts +2 -1
  4. package/es/DisplayObjectPool.js +4 -0
  5. package/{lib → es/camera}/Camera.d.ts +6 -3
  6. package/es/{Camera.js → camera/Camera.js} +22 -16
  7. package/es/{Landmark.d.ts → camera/Landmark.d.ts} +2 -2
  8. package/es/{Landmark.js → camera/Landmark.js} +1 -1
  9. package/es/camera/index.d.ts +2 -0
  10. package/es/camera/index.js +2 -0
  11. package/es/components/Cullable.js +1 -1
  12. package/es/components/Geometry.d.ts +8 -1
  13. package/es/components/Renderable.d.ts +9 -8
  14. package/es/components/Renderable.js +2 -6
  15. package/es/components/Sortable.d.ts +6 -2
  16. package/es/display-objects/Circle.d.ts +2 -3
  17. package/es/display-objects/Circle.js +2 -5
  18. package/es/{CustomElement.d.ts → display-objects/CustomElement.d.ts} +1 -1
  19. package/es/{CustomElement.js → display-objects/CustomElement.js} +22 -12
  20. package/{lib → es/display-objects}/DisplayObject.d.ts +136 -141
  21. package/es/{DisplayObject.js → display-objects/DisplayObject.js} +408 -292
  22. package/es/display-objects/Ellipse.d.ts +2 -3
  23. package/es/display-objects/Ellipse.js +2 -5
  24. package/es/display-objects/Group.d.ts +2 -1
  25. package/es/display-objects/Group.js +13 -5
  26. package/es/display-objects/HTML.d.ts +2 -2
  27. package/es/display-objects/HTML.js +4 -7
  28. package/es/display-objects/Image.d.ts +2 -2
  29. package/es/display-objects/Image.js +2 -6
  30. package/es/display-objects/Line.d.ts +2 -2
  31. package/es/display-objects/Line.js +8 -8
  32. package/es/display-objects/Path.d.ts +3 -2
  33. package/es/display-objects/Path.js +8 -8
  34. package/es/display-objects/Polygon.d.ts +2 -2
  35. package/es/display-objects/Polygon.js +2 -6
  36. package/es/display-objects/Polyline.d.ts +2 -2
  37. package/es/display-objects/Polyline.js +8 -8
  38. package/es/display-objects/Rect.d.ts +2 -2
  39. package/es/display-objects/Rect.js +2 -6
  40. package/es/display-objects/Text.d.ts +2 -3
  41. package/es/display-objects/Text.js +8 -7
  42. package/es/display-objects/index.d.ts +2 -0
  43. package/es/display-objects/index.js +2 -0
  44. package/es/{Animation.d.ts → dom/Animation.d.ts} +3 -3
  45. package/es/{Animation.js → dom/Animation.js} +2 -3
  46. package/{lib → es/dom}/AnimationEffectTiming.d.ts +2 -0
  47. package/es/{AnimationEffectTiming.js → dom/AnimationEffectTiming.js} +3 -2
  48. package/es/{AnimationEvent.d.ts → dom/AnimationEvent.d.ts} +3 -2
  49. package/es/{AnimationEvent.js → dom/AnimationEvent.js} +1 -1
  50. package/es/{Timeline.d.ts → dom/AnimationTimeline.d.ts} +1 -1
  51. package/es/{Timeline.js → dom/AnimationTimeline.js} +1 -1
  52. package/es/dom/CustomElementRegistry.d.ts +15 -0
  53. package/es/dom/CustomElementRegistry.js +40 -0
  54. package/{lib → es/dom}/CustomEvent.d.ts +1 -1
  55. package/es/{CustomEvent.js → dom/CustomEvent.js} +1 -1
  56. package/es/dom/Document.d.ts +36 -17
  57. package/es/dom/Document.js +98 -14
  58. package/es/dom/Element.d.ts +71 -92
  59. package/es/dom/Element.js +179 -195
  60. package/es/dom/EventTarget.d.ts +11 -6
  61. package/es/dom/EventTarget.js +12 -4
  62. package/es/dom/FederatedEvent.d.ts +15 -7
  63. package/es/dom/FederatedEvent.js +33 -0
  64. package/es/dom/FederatedMouseEvent.d.ts +1 -1
  65. package/es/{KeyframeEffect.d.ts → dom/KeyframeEffect.d.ts} +16 -5
  66. package/es/{KeyframeEffect.js → dom/KeyframeEffect.js} +50 -4
  67. package/es/{KeyframeList.d.ts → dom/KeyframeList.d.ts} +1 -1
  68. package/es/{KeyframeList.js → dom/KeyframeList.js} +0 -0
  69. package/es/dom/Node.d.ts +38 -23
  70. package/es/dom/Node.js +37 -33
  71. package/es/dom/index.d.ts +15 -2
  72. package/es/dom/index.js +16 -3
  73. package/es/dom/interfaces.d.ts +301 -0
  74. package/es/dom/interfaces.js +1 -0
  75. package/es/global-module.d.ts +0 -2
  76. package/es/global-module.js +31 -29
  77. package/es/index.d.ts +7 -14
  78. package/es/index.js +8 -15
  79. package/es/plugins/CullingPlugin.d.ts +2 -2
  80. package/es/plugins/CullingPlugin.js +13 -16
  81. package/es/plugins/DirtyCheckPlugin.d.ts +1 -1
  82. package/es/plugins/DirtyCheckPlugin.js +8 -7
  83. package/es/plugins/EventPlugin.js +52 -31
  84. package/es/plugins/FrustumCullingStrategy.d.ts +1 -1
  85. package/es/plugins/FrustumCullingStrategy.js +5 -4
  86. package/es/plugins/PrepareRendererPlugin.d.ts +0 -1
  87. package/es/plugins/PrepareRendererPlugin.js +42 -38
  88. package/es/property-handlers/aabb.d.ts +2 -3
  89. package/es/property-handlers/aabb.js +29 -21
  90. package/es/property-handlers/anchor.d.ts +3 -0
  91. package/es/property-handlers/anchor.js +21 -0
  92. package/es/property-handlers/clipPath.d.ts +1 -1
  93. package/es/property-handlers/clipPath.js +3 -4
  94. package/es/property-handlers/color.d.ts +1 -1
  95. package/es/property-handlers/dimension.d.ts +1 -1
  96. package/es/property-handlers/dimension.js +6 -9
  97. package/es/property-handlers/filter.d.ts +1 -1
  98. package/es/property-handlers/index.d.ts +5 -4
  99. package/es/property-handlers/index.js +1 -0
  100. package/es/property-handlers/localPosition.d.ts +1 -1
  101. package/es/property-handlers/localPosition.js +1 -6
  102. package/es/property-handlers/offsetDistance.d.ts +1 -1
  103. package/es/property-handlers/offsetPath.d.ts +1 -1
  104. package/es/property-handlers/origin.d.ts +1 -1
  105. package/es/property-handlers/origin.js +9 -2
  106. package/es/property-handlers/path.d.ts +2 -2
  107. package/es/property-handlers/path.js +8 -4
  108. package/es/property-handlers/points.d.ts +1 -1
  109. package/es/property-handlers/transform.d.ts +1 -1
  110. package/es/property-handlers/zIndex.d.ts +1 -1
  111. package/es/services/ContextService.d.ts +3 -2
  112. package/es/services/EventService.d.ts +18 -13
  113. package/es/services/EventService.js +604 -384
  114. package/es/services/RenderingContext.d.ts +1 -1
  115. package/es/services/RenderingService.d.ts +23 -29
  116. package/es/services/RenderingService.js +63 -54
  117. package/es/services/SceneGraphSelector.d.ts +7 -7
  118. package/es/services/SceneGraphSelector.js +10 -6
  119. package/es/services/SceneGraphService.d.ts +73 -78
  120. package/es/services/SceneGraphService.js +165 -78
  121. package/es/services/aabb/PathUpdater.d.ts +1 -1
  122. package/es/services/aabb/RectUpdater.d.ts +2 -2
  123. package/es/services/aabb/interfaces.d.ts +1 -1
  124. package/es/shapes/Point.d.ts +4 -0
  125. package/es/shapes/Polygon.d.ts +9 -0
  126. package/es/shapes/Polygon.js +62 -0
  127. package/es/shapes/index.d.ts +1 -0
  128. package/es/shapes/index.js +2 -1
  129. package/es/types.d.ts +18 -6
  130. package/es/utils/animation.d.ts +1 -2
  131. package/es/utils/animation.js +5 -10
  132. package/es/utils/canvas.d.ts +1 -1
  133. package/es/utils/custom-easing.d.ts +3 -2
  134. package/es/utils/custom-easing.js +12 -6
  135. package/es/utils/event.js +1 -1
  136. package/es/utils/index.d.ts +1 -0
  137. package/es/utils/index.js +2 -1
  138. package/es/utils/interpolation.d.ts +3 -4
  139. package/es/utils/interpolation.js +0 -16
  140. package/es/utils/path.d.ts +2 -2
  141. package/lib/Canvas.d.ts +40 -18
  142. package/lib/Canvas.js +131 -74
  143. package/lib/DisplayObjectPool.d.ts +2 -1
  144. package/lib/DisplayObjectPool.js +4 -0
  145. package/{es → lib/camera}/Camera.d.ts +6 -3
  146. package/lib/{Camera.js → camera/Camera.js} +25 -20
  147. package/lib/{Landmark.d.ts → camera/Landmark.d.ts} +2 -2
  148. package/lib/{Landmark.js → camera/Landmark.js} +2 -3
  149. package/lib/camera/index.d.ts +2 -0
  150. package/lib/camera/index.js +31 -0
  151. package/lib/components/Cullable.js +1 -1
  152. package/lib/components/Geometry.d.ts +8 -1
  153. package/lib/components/Renderable.d.ts +9 -8
  154. package/lib/components/Renderable.js +2 -6
  155. package/lib/components/Sortable.d.ts +6 -2
  156. package/lib/display-objects/Circle.d.ts +2 -3
  157. package/lib/display-objects/Circle.js +3 -6
  158. package/lib/{CustomElement.d.ts → display-objects/CustomElement.d.ts} +1 -1
  159. package/lib/{CustomElement.js → display-objects/CustomElement.js} +22 -12
  160. package/{es → lib/display-objects}/DisplayObject.d.ts +136 -141
  161. package/lib/{DisplayObject.js → display-objects/DisplayObject.js} +418 -299
  162. package/lib/display-objects/Ellipse.d.ts +2 -3
  163. package/lib/display-objects/Ellipse.js +3 -6
  164. package/lib/display-objects/Group.d.ts +2 -1
  165. package/lib/display-objects/Group.js +12 -4
  166. package/lib/display-objects/HTML.d.ts +2 -2
  167. package/lib/display-objects/HTML.js +4 -7
  168. package/lib/display-objects/Image.d.ts +2 -2
  169. package/lib/display-objects/Image.js +2 -6
  170. package/lib/display-objects/Line.d.ts +2 -2
  171. package/lib/display-objects/Line.js +8 -8
  172. package/lib/display-objects/Path.d.ts +3 -2
  173. package/lib/display-objects/Path.js +8 -8
  174. package/lib/display-objects/Polygon.d.ts +2 -2
  175. package/lib/display-objects/Polygon.js +2 -6
  176. package/lib/display-objects/Polyline.d.ts +2 -2
  177. package/lib/display-objects/Polyline.js +8 -8
  178. package/lib/display-objects/Rect.d.ts +2 -2
  179. package/lib/display-objects/Rect.js +2 -6
  180. package/lib/display-objects/Text.d.ts +2 -3
  181. package/lib/display-objects/Text.js +9 -8
  182. package/lib/display-objects/index.d.ts +2 -0
  183. package/lib/display-objects/index.js +26 -0
  184. package/lib/{Animation.d.ts → dom/Animation.d.ts} +3 -3
  185. package/lib/{Animation.js → dom/Animation.js} +2 -3
  186. package/{es → lib/dom}/AnimationEffectTiming.d.ts +2 -0
  187. package/lib/{AnimationEffectTiming.js → dom/AnimationEffectTiming.js} +3 -3
  188. package/lib/{AnimationEvent.d.ts → dom/AnimationEvent.d.ts} +3 -2
  189. package/lib/{AnimationEvent.js → dom/AnimationEvent.js} +1 -1
  190. package/lib/{Timeline.d.ts → dom/AnimationTimeline.d.ts} +1 -1
  191. package/lib/{Timeline.js → dom/AnimationTimeline.js} +1 -1
  192. package/lib/dom/CustomElementRegistry.d.ts +15 -0
  193. package/lib/dom/CustomElementRegistry.js +48 -0
  194. package/{es → lib/dom}/CustomEvent.d.ts +1 -1
  195. package/lib/{CustomEvent.js → dom/CustomEvent.js} +1 -1
  196. package/lib/dom/Document.d.ts +36 -17
  197. package/lib/dom/Document.js +99 -15
  198. package/lib/dom/Element.d.ts +71 -92
  199. package/lib/dom/Element.js +180 -198
  200. package/lib/dom/EventTarget.d.ts +11 -6
  201. package/lib/dom/EventTarget.js +20 -10
  202. package/lib/dom/FederatedEvent.d.ts +15 -7
  203. package/lib/dom/FederatedEvent.js +33 -0
  204. package/lib/dom/FederatedMouseEvent.d.ts +1 -1
  205. package/lib/{KeyframeEffect.d.ts → dom/KeyframeEffect.d.ts} +16 -5
  206. package/lib/{KeyframeEffect.js → dom/KeyframeEffect.js} +50 -4
  207. package/lib/{KeyframeList.d.ts → dom/KeyframeList.d.ts} +1 -1
  208. package/lib/{KeyframeList.js → dom/KeyframeList.js} +0 -0
  209. package/lib/dom/Node.d.ts +38 -23
  210. package/lib/dom/Node.js +37 -33
  211. package/lib/dom/index.d.ts +15 -2
  212. package/lib/dom/index.js +177 -8
  213. package/lib/dom/interfaces.d.ts +301 -0
  214. package/lib/dom/interfaces.js +5 -0
  215. package/lib/global-module.d.ts +0 -2
  216. package/lib/global-module.js +30 -30
  217. package/lib/index.d.ts +7 -14
  218. package/lib/index.js +44 -135
  219. package/lib/plugins/CullingPlugin.d.ts +2 -2
  220. package/lib/plugins/CullingPlugin.js +14 -16
  221. package/lib/plugins/DirtyCheckPlugin.d.ts +1 -1
  222. package/lib/plugins/DirtyCheckPlugin.js +9 -7
  223. package/lib/plugins/EventPlugin.js +52 -30
  224. package/lib/plugins/FrustumCullingStrategy.d.ts +1 -1
  225. package/lib/plugins/FrustumCullingStrategy.js +5 -4
  226. package/lib/plugins/PrepareRendererPlugin.d.ts +0 -1
  227. package/lib/plugins/PrepareRendererPlugin.js +41 -37
  228. package/lib/property-handlers/aabb.d.ts +2 -3
  229. package/lib/property-handlers/aabb.js +28 -22
  230. package/lib/property-handlers/anchor.d.ts +3 -0
  231. package/lib/property-handlers/anchor.js +34 -0
  232. package/lib/property-handlers/clipPath.d.ts +1 -1
  233. package/lib/property-handlers/clipPath.js +3 -4
  234. package/lib/property-handlers/color.d.ts +1 -1
  235. package/lib/property-handlers/dimension.d.ts +1 -1
  236. package/lib/property-handlers/dimension.js +6 -9
  237. package/lib/property-handlers/filter.d.ts +1 -1
  238. package/lib/property-handlers/index.d.ts +5 -4
  239. package/lib/property-handlers/index.js +14 -0
  240. package/lib/property-handlers/localPosition.d.ts +1 -1
  241. package/lib/property-handlers/localPosition.js +1 -7
  242. package/lib/property-handlers/offsetDistance.d.ts +1 -1
  243. package/lib/property-handlers/offsetPath.d.ts +1 -1
  244. package/lib/property-handlers/origin.d.ts +1 -1
  245. package/lib/property-handlers/origin.js +10 -2
  246. package/lib/property-handlers/path.d.ts +2 -2
  247. package/lib/property-handlers/path.js +8 -4
  248. package/lib/property-handlers/points.d.ts +1 -1
  249. package/lib/property-handlers/transform.d.ts +1 -1
  250. package/lib/property-handlers/zIndex.d.ts +1 -1
  251. package/lib/services/ContextService.d.ts +3 -2
  252. package/lib/services/EventService.d.ts +18 -13
  253. package/lib/services/EventService.js +616 -385
  254. package/lib/services/RenderingContext.d.ts +1 -1
  255. package/lib/services/RenderingService.d.ts +23 -29
  256. package/lib/services/RenderingService.js +66 -56
  257. package/lib/services/SceneGraphSelector.d.ts +7 -7
  258. package/lib/services/SceneGraphSelector.js +10 -6
  259. package/lib/services/SceneGraphService.d.ts +73 -78
  260. package/lib/services/SceneGraphService.js +166 -79
  261. package/lib/services/aabb/PathUpdater.d.ts +1 -1
  262. package/lib/services/aabb/RectUpdater.d.ts +2 -2
  263. package/lib/services/aabb/interfaces.d.ts +1 -1
  264. package/lib/shapes/Point.d.ts +4 -0
  265. package/lib/shapes/Polygon.d.ts +9 -0
  266. package/lib/shapes/Polygon.js +69 -0
  267. package/lib/shapes/index.d.ts +1 -0
  268. package/lib/shapes/index.js +13 -0
  269. package/lib/types.d.ts +18 -6
  270. package/lib/utils/animation.d.ts +1 -2
  271. package/lib/utils/animation.js +8 -16
  272. package/lib/utils/canvas.d.ts +1 -1
  273. package/lib/utils/custom-easing.d.ts +3 -2
  274. package/lib/utils/custom-easing.js +16 -8
  275. package/lib/utils/event.js +1 -1
  276. package/lib/utils/index.d.ts +1 -0
  277. package/lib/utils/index.js +13 -0
  278. package/lib/utils/interpolation.d.ts +3 -4
  279. package/lib/utils/interpolation.js +0 -17
  280. package/lib/utils/path.d.ts +2 -2
  281. package/package.json +6 -6
  282. package/es/Batch.d.ts +0 -25
  283. package/es/Batch.js +0 -82
  284. package/es/shapes-type.d.ts +0 -175
  285. package/es/shapes-type.js +0 -18
  286. package/es/utils/matrix-decompose.d.ts +0 -3
  287. package/es/utils/matrix-decompose.js +0 -404
  288. package/lib/Batch.d.ts +0 -25
  289. package/lib/Batch.js +0 -91
  290. package/lib/shapes-type.d.ts +0 -175
  291. package/lib/shapes-type.js +0 -41
  292. package/lib/utils/matrix-decompose.d.ts +0 -3
  293. package/lib/utils/matrix-decompose.js +0 -414
@@ -0,0 +1,301 @@
1
+ import { Entity } from '@antv/g-ecs';
2
+ import EventEmitter from 'eventemitter3';
3
+ import type { AnimationTimeline } from './AnimationTimeline';
4
+ import { BaseStyleProps, ParsedBaseStyleProps, SHAPE } from '../types';
5
+ import type { FederatedEvent } from './FederatedEvent';
6
+ import { CustomElementRegistry } from './CustomElementRegistry';
7
+ import { DisplayObject } from '..';
8
+ import type { PointLike } from '../shapes';
9
+ import type { Camera } from '../camera';
10
+ import { ContextService } from '../services';
11
+ export interface IEventTarget {
12
+ entity: Entity;
13
+ getEntity(): Entity;
14
+ emitter: EventEmitter;
15
+ on(type: string, listener: EventListenerOrEventListenerObject | ((...args: any[]) => void), options?: boolean | AddEventListenerOptions): this;
16
+ addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): this;
17
+ off(type: string, listener: EventListenerOrEventListenerObject | ((...args: any[]) => void), options?: boolean | AddEventListenerOptions): this;
18
+ removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): this;
19
+ removeAllEventListeners(): void;
20
+ dispatchEvent<T extends FederatedEvent>(e: T): boolean;
21
+ emit(eventName: string, object: object): void;
22
+ }
23
+ export interface INode extends IEventTarget {
24
+ shadow: boolean;
25
+ /**
26
+ * Returns node's node document's document base URL.
27
+ */
28
+ readonly baseURI: string;
29
+ /**
30
+ * Returns the children.
31
+ */
32
+ readonly childNodes: (IChildNode & INode)[];
33
+ /**
34
+ * Returns the first child.
35
+ */
36
+ readonly firstChild: (IChildNode & INode) | null;
37
+ /**
38
+ * Returns true if node is connected and false otherwise.
39
+ */
40
+ isConnected: boolean;
41
+ /**
42
+ * Returns the last child.
43
+ */
44
+ readonly lastChild: (IChildNode & INode) | null;
45
+ /**
46
+ * Returns the next sibling.
47
+ */
48
+ readonly nextSibling: (IChildNode & INode) | null;
49
+ /**
50
+ * Returns a string appropriate for the type of node.
51
+ */
52
+ readonly nodeName: string;
53
+ /**
54
+ * Returns the type of node.
55
+ */
56
+ readonly nodeType: number;
57
+ nodeValue: string | null;
58
+ /**
59
+ * Returns the node document. Returns null for documents.
60
+ */
61
+ ownerDocument: IDocument | null;
62
+ /**
63
+ * Returns the parent element.
64
+ */
65
+ readonly parentElement: IElement | null;
66
+ /**
67
+ * Returns the parent.
68
+ */
69
+ parentNode: (INode & IParentNode) | null;
70
+ /**
71
+ * Returns the previous sibling.
72
+ */
73
+ readonly previousSibling: (IChildNode & INode) | null;
74
+ textContent: string | null;
75
+ appendChild<T extends INode>(newChild: T, index?: number): T;
76
+ /**
77
+ * Returns a copy of node. If deep is true, the copy also includes the node's descendants.
78
+ */
79
+ cloneNode(deep?: boolean): INode;
80
+ /**
81
+ * Returns a bitmask indicating the position of other relative to node.
82
+ */
83
+ compareDocumentPosition(other: INode): number;
84
+ /**
85
+ * Returns true if other is an inclusive descendant of node, and false otherwise.
86
+ */
87
+ contains(other: INode | null): boolean;
88
+ /**
89
+ * Returns node's root.
90
+ */
91
+ getRootNode(options?: GetRootNodeOptions): INode;
92
+ /**
93
+ * Returns node's ancestor.
94
+ */
95
+ getAncestor(n: number): INode | null;
96
+ /**
97
+ * Traverse in sub tree.
98
+ */
99
+ forEach(callback: (o: INode) => void | boolean): void;
100
+ /**
101
+ * Returns whether node has children.
102
+ */
103
+ hasChildNodes(): boolean;
104
+ insertBefore<T extends INode>(newChild: T, refChild: INode | null): T;
105
+ isDefaultNamespace(namespace: string | null): boolean;
106
+ /**
107
+ * Returns whether node and otherNode have the same properties.
108
+ */
109
+ isEqualNode(otherNode: INode | null): boolean;
110
+ isSameNode(otherNode: INode | null): boolean;
111
+ lookupNamespaceURI(prefix: string | null): string | null;
112
+ lookupPrefix(namespace: string | null): string | null;
113
+ /**
114
+ * Removes empty exclusive Text nodes and concatenates the data of remaining contiguous exclusive Text nodes into the first of their nodes.
115
+ */
116
+ normalize(): void;
117
+ removeChild<T extends INode>(oldChild: T, destroy?: boolean): T;
118
+ replaceChild<T extends INode & IChildNode>(newChild: INode, oldChild: T, destroy?: boolean): T;
119
+ /**
120
+ * Destroy itself.
121
+ */
122
+ destroy(): void;
123
+ }
124
+ export interface IParentNode {
125
+ readonly childElementCount: number;
126
+ /**
127
+ * Returns the child elements.
128
+ */
129
+ readonly children: IElement[];
130
+ /**
131
+ * Returns the first child that is an element, and null otherwise.
132
+ */
133
+ readonly firstElementChild: IElement | null;
134
+ /**
135
+ * Returns the last child that is an element, and null otherwise.
136
+ */
137
+ readonly lastElementChild: IElement | null;
138
+ /**
139
+ * Inserts nodes after the last child of node, while replacing strings in nodes with equivalent Text nodes.
140
+ *
141
+ * Throws a "HierarchyRequestError" DOMException if the constraints of the node tree are violated.
142
+ */
143
+ append(...nodes: INode[]): void;
144
+ /**
145
+ * Inserts nodes before the first child of node, while replacing strings in nodes with equivalent Text nodes.
146
+ *
147
+ * Throws a "HierarchyRequestError" DOMException if the constraints of the node tree are violated.
148
+ */
149
+ prepend(...nodes: INode[]): void;
150
+ /**
151
+ * Returns the first element that is a descendant of node that matches selectors.
152
+ */
153
+ querySelector<E extends IElement = IElement>(selectors: string): E | null;
154
+ /**
155
+ * Returns all element descendants of node that match selectors.
156
+ */
157
+ querySelectorAll<E extends IElement = IElement>(selectors: string): E[];
158
+ /**
159
+ * Similar to querySelector, use custom filter instead of selectors.
160
+ */
161
+ find<E extends IElement = IElement>(filter: (node: E) => boolean): E | null;
162
+ /**
163
+ * Similar to querySelectorAll, use custom filter instead of selectors.
164
+ */
165
+ findAll<E extends IElement = IElement>(filter: (node: E) => boolean): E[];
166
+ }
167
+ export interface IChildNode extends INode {
168
+ /**
169
+ * Inserts nodes just after node, while replacing strings in nodes with equivalent Text nodes.
170
+ *
171
+ * Throws a "HierarchyRequestError" DOMException if the constraints of the node tree are violated.
172
+ */
173
+ after(...nodes: INode[]): void;
174
+ /**
175
+ * Inserts nodes just before node, while replacing strings in nodes with equivalent Text nodes.
176
+ *
177
+ * Throws a "HierarchyRequestError" DOMException if the constraints of the node tree are violated.
178
+ */
179
+ before(...nodes: INode[]): void;
180
+ /**
181
+ * Removes node.
182
+ */
183
+ remove(): void;
184
+ /**
185
+ * Replaces node with nodes, while replacing strings in nodes with equivalent Text nodes.
186
+ *
187
+ * Throws a "HierarchyRequestError" DOMException if the constraints of the node tree are violated.
188
+ */
189
+ replaceWith(...nodes: INode[]): void;
190
+ }
191
+ export interface DisplayObjectConfig<StyleProps> {
192
+ /**
193
+ * element's identifier, must be unique in a document.
194
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/id
195
+ */
196
+ id?: string;
197
+ name?: string;
198
+ className?: string;
199
+ /**
200
+ * all styles properties, not read-only
201
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style
202
+ */
203
+ style?: StyleProps;
204
+ /**
205
+ * compatible with G 3.0
206
+ * @alias style
207
+ * @deprecated
208
+ */
209
+ attrs?: StyleProps;
210
+ type?: SHAPE | string;
211
+ /**
212
+ * @deprecated use `style.zIndex` instead
213
+ */
214
+ zIndex?: number;
215
+ /**
216
+ * @deprecated use `style.visibility = 'visible'` instead
217
+ */
218
+ visible?: boolean;
219
+ /**
220
+ * compatible with G 3.0
221
+ * @alias interactive
222
+ * @deprecated
223
+ */
224
+ capture?: boolean;
225
+ /**
226
+ * enable interaction events for the DisplayObject
227
+ */
228
+ interactive?: boolean;
229
+ }
230
+ export interface IElement<StyleProps extends BaseStyleProps = any, ParsedStyleProps extends ParsedBaseStyleProps = any> extends INode, IChildNode, IParentNode {
231
+ /**
232
+ * Returns the value of element's id content attribute. Can be set to change it.
233
+ */
234
+ id: string;
235
+ /**
236
+ * Returns the qualified name.
237
+ */
238
+ tagName: string;
239
+ name: string;
240
+ /**
241
+ * Returns the value of element's class content attribute. Can be set to change it.
242
+ */
243
+ className: string;
244
+ /**
245
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/attributes
246
+ */
247
+ attributes: StyleProps;
248
+ /**
249
+ * compatible with `style`
250
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style
251
+ */
252
+ style: StyleProps;
253
+ parsedStyle: ParsedStyleProps;
254
+ getElementById<E extends IElement = IElement>(id: string): E | null;
255
+ getElementsByName<E extends IElement = IElement>(name: string): E[];
256
+ getElementsByClassName<E extends IElement = IElement>(className: string): E[];
257
+ getElementsByTagName<E extends IElement = IElement>(tagName: string): E[];
258
+ scrollLeft: number;
259
+ scrollTop: number;
260
+ /**
261
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/setAttribute
262
+ */
263
+ setAttribute<Key extends keyof StyleProps>(attributeName: Key, value: StyleProps[Key], force?: boolean): void;
264
+ /**
265
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getAttribute
266
+ */
267
+ getAttribute(attributeName: keyof StyleProps): StyleProps[keyof StyleProps] | undefined;
268
+ /**
269
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/removeAttribute
270
+ */
271
+ removeAttribute(attributeName: keyof StyleProps): void;
272
+ }
273
+ export interface IDocument extends INode, IParentNode {
274
+ /**
275
+ * Returns the Window object of the active document.
276
+ */
277
+ readonly defaultView: ICanvas | null;
278
+ /**
279
+ * Gets a reference to the root node of the document.
280
+ */
281
+ readonly documentElement: IElement;
282
+ readonly ownerDocument: null;
283
+ readonly timeline: AnimationTimeline;
284
+ /**
285
+ * Creates an instance of the element for the specified tag.
286
+ */
287
+ createElement<T extends DisplayObject<StyleProps>, StyleProps extends BaseStyleProps>(tagName: string, options: DisplayObjectConfig<StyleProps>): T;
288
+ }
289
+ export interface ICanvas extends IEventTarget {
290
+ document: IDocument;
291
+ customElements: CustomElementRegistry;
292
+ render(): void;
293
+ destroy(destroyScenegraph?: boolean): void;
294
+ resize(width: number, height: number): void;
295
+ getCamera(): Camera;
296
+ getContextService(): ContextService<unknown>;
297
+ client2Viewport(client: PointLike): PointLike;
298
+ viewport2Client(viewport: PointLike): PointLike;
299
+ canvas2Viewport(canvas: PointLike): PointLike;
300
+ viewport2Canvas(viewport: PointLike): PointLike;
301
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,2 @@
1
1
  import { ContainerModule } from 'inversify';
2
- import { StylePropertyParser, StylePropertyMerger, StylePropertyUpdater, Interpolatable } from './property-handlers';
3
2
  export declare const containerModule: ContainerModule;
4
- export declare function addPropertiesHandler<O, P, I extends Interpolatable = number>(properties: string[], parser: StylePropertyParser<O, P> | undefined, merger: StylePropertyMerger<P, I> | undefined, updater: StylePropertyUpdater<O> | undefined): void;
@@ -7,8 +7,7 @@ import { TextService } from './services/text';
7
7
  import { TextUpdater } from './services/aabb/TextUpdater';
8
8
  import { OffscreenCanvasCreator } from './services/text/OffscreenCanvasCreator';
9
9
  import { DefaultSceneGraphSelector, SceneGraphSelector, SceneGraphSelectorFactory } from './services/SceneGraphSelector';
10
- import { StylePropertyParser, StylePropertyMerger, StylePropertyUpdater, StylePropertyParserFactory, StylePropertyUpdaterFactory, StylePropertyMergerFactory, clampedMergeNumbers, parseNumber, mergeColors, parseColor, updateGeometry, updateLocalPosition, updateOffsetPath, updateClipPath, updateZIndex, updateOffsetDistance, updateOrigin, updateTransform, updateTransformOrigin, parseTransform, mergeTransforms, parsePath, parsePoints, mergePaths, mergeNumbers, mergeNumberLists, parseFilter } from './property-handlers';
11
- import { container } from './inversify.config'; // eslint-disable-next-line @typescript-eslint/no-unused-vars
10
+ import { StylePropertyParser, StylePropertyMerger, StylePropertyUpdater, StylePropertyParserFactory, StylePropertyUpdaterFactory, StylePropertyMergerFactory, clampedMergeNumbers, parseNumber, mergeColors, parseColor, updateGeometry, updateLocalPosition, updateOffsetPath, updateClipPath, updateZIndex, updateOffsetDistance, updateOrigin, updateTransform, updateTransformOrigin, parseTransform, mergeTransforms, parsePath, parsePoints, mergePaths, mergeNumbers, mergeNumberLists, parseFilter, updateAnchor } from './property-handlers'; // eslint-disable-next-line @typescript-eslint/no-unused-vars
12
11
 
13
12
  export var containerModule = new ContainerModule(function (bind, unbind, isBound, rebind) {
14
13
  // bind DisplayObject pool
@@ -74,51 +73,54 @@ export var containerModule = new ContainerModule(function (bind, unbind, isBound
74
73
 
75
74
  return null;
76
75
  };
77
- }); // bind handlers for properties
76
+ });
77
+
78
+ function addPropertyHandler(property, parser, merger, updater) {
79
+ if (parser) {
80
+ bind(StylePropertyParser).toConstantValue(parser).whenTargetNamed(property);
81
+ }
82
+
83
+ if (merger) {
84
+ bind(StylePropertyMerger).toConstantValue(merger).whenTargetNamed(property);
85
+ }
86
+
87
+ if (updater) {
88
+ bind(StylePropertyUpdater).toConstantValue(updater).whenTargetNamed(property);
89
+ }
90
+ }
91
+
92
+ function addPropertiesHandler(properties, parser, merger, updater) {
93
+ for (var i = 0; i < properties.length; i++) {
94
+ addPropertyHandler(properties[i], parser, merger, updater);
95
+ }
96
+ } // bind handlers for properties
97
+
78
98
 
79
99
  addPropertiesHandler(['opacity', 'fillOpacity', 'strokeOpacity', 'offsetDistance'], parseNumber, clampedMergeNumbers(0, 1), undefined);
80
- addPropertiesHandler(['r', 'rx', 'ry', 'lineWidth', 'lineAppendWidth', 'width', 'height', 'shadowBlur'], parseNumber, clampedMergeNumbers(0, Infinity), undefined); // @ts-ignore
100
+ addPropertiesHandler(['r', 'rx', 'ry', 'lineWidth', 'width', 'height', 'shadowBlur'], parseNumber, clampedMergeNumbers(0, Infinity), undefined); // @ts-ignore
81
101
 
82
102
  addPropertiesHandler(['lineDash'], undefined, mergeNumberLists, undefined);
83
103
  addPropertiesHandler(['x1', 'x2', 'y1', 'y2', 'lineDashOffset', 'shadowOffsetX', 'shadowOffsetY'], parseNumber, mergeNumbers, undefined);
84
- addPropertiesHandler(['anchor', 'x1', 'x2', 'y1', 'y2', 'r', 'rx', 'ry', 'width', 'height', 'text', 'shadowBlur', 'shadowOffsetX', 'shadowOffsetY', 'lineWidth', 'lineAppendWidth', 'filter', 'font', 'fontSize', 'fontFamily', 'fontStyle', 'fontWeight', 'fontVariant', 'lineHeight', 'letterSpacing', 'padding', 'wordWrap', 'wordWrapWidth', 'leading', 'textBaseline', 'textAlign', 'whiteSpace'], undefined, undefined, updateGeometry);
104
+ addPropertiesHandler(['x1', 'x2', 'y1', 'y2', 'r', 'rx', 'ry', 'width', 'height', 'path', 'points', 'text', 'shadowBlur', 'shadowOffsetX', 'shadowOffsetY', 'lineWidth', 'filter', 'font', 'fontSize', 'fontFamily', 'fontStyle', 'fontWeight', 'fontVariant', 'lineHeight', 'letterSpacing', 'padding', 'wordWrap', 'wordWrapWidth', 'leading', 'textBaseline', 'textAlign', 'whiteSpace'], undefined, undefined, updateGeometry);
85
105
  addPropertiesHandler(['fill', 'stroke', 'shadowColor'], parseColor, mergeColors, undefined);
86
106
  addPropertyHandler('clipPath', undefined, undefined, updateClipPath);
87
107
  addPropertyHandler('zIndex', undefined, undefined, updateZIndex);
88
108
  addPropertyHandler('offsetPath', undefined, undefined, updateOffsetPath);
89
109
  addPropertyHandler('offsetDistance', undefined, undefined, updateOffsetDistance);
90
- addPropertyHandler('origin', undefined, undefined, updateOrigin);
110
+ addPropertyHandler('origin', undefined, undefined, updateOrigin); // @ts-ignore
111
+
91
112
  addPropertyHandler('transformOrigin', undefined, undefined, updateTransformOrigin); // @ts-ignore
92
113
 
93
114
  addPropertyHandler('transform', parseTransform, mergeTransforms, updateTransform); // Path.path
94
115
  // @ts-ignore
95
116
 
96
- addPropertyHandler('path', parsePath, mergePaths, updateGeometry); // Polyline.points Polygon.points
117
+ addPropertyHandler('path', parsePath, mergePaths, undefined); // Polyline.points Polygon.points
97
118
  // @ts-ignore
98
119
 
99
- addPropertyHandler('points', parsePoints, undefined, updateGeometry); // update local position
120
+ addPropertyHandler('points', parsePoints, undefined, undefined); // update local position
100
121
 
101
122
  addPropertiesHandler(['x', 'y', 'points', 'path', 'x1', 'x2', 'y1', 'y2'], // ['x', 'y'],
102
123
  undefined, undefined, updateLocalPosition);
103
124
  addPropertyHandler('filter', parseFilter, undefined, undefined);
104
- });
105
-
106
- function addPropertyHandler(property, parser, merger, updater) {
107
- if (parser) {
108
- container.bind(StylePropertyParser).toConstantValue(parser).whenTargetNamed(property);
109
- }
110
-
111
- if (merger) {
112
- container.bind(StylePropertyMerger).toConstantValue(merger).whenTargetNamed(property);
113
- }
114
-
115
- if (updater) {
116
- container.bind(StylePropertyUpdater).toConstantValue(updater).whenTargetNamed(property);
117
- }
118
- }
119
-
120
- export function addPropertiesHandler(properties, parser, merger, updater) {
121
- for (var i = 0; i < properties.length; i++) {
122
- addPropertyHandler(properties[i], parser, merger, updater);
123
- }
124
- }
125
+ addPropertyHandler('anchor', undefined, undefined, updateAnchor);
126
+ });
package/es/index.d.ts CHANGED
@@ -1,21 +1,14 @@
1
+ export * from './contribution-provider';
2
+ export * from './types';
3
+ export * from './components';
4
+ export * from './inversify.config';
5
+ export * from './dom';
1
6
  export * from './AbstractRenderer';
2
- export * from './Batch';
3
7
  export * from './Canvas';
4
- export * from './CustomElement';
5
- export * from './CustomEvent';
6
- export * from './DisplayObject';
7
8
  export * from './DisplayObjectPool';
8
- export * from './Camera';
9
- export * from './inversify.config';
10
- export * from './contribution-provider';
11
- export * from './components';
9
+ export * from './camera';
12
10
  export * from './services';
13
11
  export * from './shapes';
14
- export * from './dom';
15
- export * from './display-objects';
16
- export * from './types';
17
12
  export * from './utils';
18
- export * from './Timeline';
19
- export * from './Animation';
20
- export * from './KeyframeEffect';
21
13
  export * from './property-handlers';
14
+ export * from './display-objects';
package/es/index.js CHANGED
@@ -1,21 +1,14 @@
1
+ export * from './contribution-provider';
2
+ export * from './types';
3
+ export * from './components';
4
+ export * from './inversify.config';
5
+ export * from './dom';
1
6
  export * from './AbstractRenderer';
2
- export * from './Batch';
3
7
  export * from './Canvas';
4
- export * from './CustomElement';
5
- export * from './CustomEvent';
6
- export * from './DisplayObject';
7
8
  export * from './DisplayObjectPool';
8
- export * from './Camera';
9
- export * from './inversify.config';
10
- export * from './contribution-provider';
11
- export * from './components';
9
+ export * from './camera';
12
10
  export * from './services';
13
11
  export * from './shapes';
14
- export * from './dom';
15
- export * from './display-objects';
16
- export * from './types';
17
12
  export * from './utils';
18
- export * from './Timeline';
19
- export * from './Animation';
20
- export * from './KeyframeEffect';
21
- export * from './property-handlers';
13
+ export * from './property-handlers';
14
+ export * from './display-objects';
@@ -1,4 +1,4 @@
1
- import { DisplayObject } from '../DisplayObject';
1
+ import { DisplayObject } from '../display-objects/DisplayObject';
2
2
  import { RenderingService, RenderingPlugin } from '../services/RenderingService';
3
3
  export declare const CullingStrategy = "CullingStrategy";
4
4
  export interface CullingStrategy {
@@ -14,5 +14,5 @@ export declare class CullingPlugin implements RenderingPlugin {
14
14
  private canvasConfig;
15
15
  private strategies;
16
16
  private renderingContext;
17
- apply(renderer: RenderingService): void;
17
+ apply(renderingService: RenderingService): void;
18
18
  }
@@ -2,6 +2,7 @@ import { __decorate, __metadata } from "tslib";
2
2
  import { inject, injectable, named } from 'inversify';
3
3
  import { Cullable } from '../components';
4
4
  import { ContributionProvider } from '../contribution-provider';
5
+ import { RenderingServiceEvent } from '../services/RenderingService';
5
6
  import { RenderingContext, RENDER_REASON } from '../services/RenderingContext';
6
7
  import { CanvasConfig } from '../types';
7
8
  export var CullingStrategy = 'CullingStrategy';
@@ -14,15 +15,12 @@ export var CullingStrategy = 'CullingStrategy';
14
15
  var CullingPlugin = function () {
15
16
  function CullingPlugin() {}
16
17
 
17
- CullingPlugin_1 = CullingPlugin;
18
-
19
- CullingPlugin.prototype.apply = function (renderer) {
18
+ CullingPlugin.prototype.apply = function (renderingService) {
20
19
  var _this = this;
21
20
 
22
- renderer.hooks.prepare.tap(CullingPlugin_1.tag, function (object) {
21
+ renderingService.emitter.on(RenderingServiceEvent.Prepare, function (object, next) {
23
22
  if (object) {
24
- var entity = object.getEntity();
25
- var cullable = entity.getComponent(Cullable);
23
+ var cullable = object.entity.getComponent(Cullable);
26
24
 
27
25
  if (_this.strategies.getContributions(true).length === 0) {
28
26
  cullable.visible = true;
@@ -34,36 +32,35 @@ var CullingPlugin = function () {
34
32
  }
35
33
 
36
34
  if (object.isVisible()) {
35
+ next(object);
37
36
  return object;
38
37
  } else {
39
38
  // Those invisible objects which get renderred in last frame should be saved for later use.
40
39
  var enableDirtyRectangleRendering = _this.canvasConfig.renderer.getConfig().enableDirtyRectangleRendering;
41
40
 
42
41
  if (enableDirtyRectangleRendering) {
43
- var removedAABB = object.getBounds();
42
+ var removedRenderBounds = object.getRenderBounds();
44
43
 
45
- if (removedAABB) {
46
- _this.renderingContext.removedAABBs.push(removedAABB);
44
+ if (removedRenderBounds) {
45
+ _this.renderingContext.removedRenderBoundsList.push(removedRenderBounds);
47
46
 
48
47
  _this.renderingContext.renderReasons.add(RENDER_REASON.DisplayObjectRemoved);
49
48
  }
50
- } else {
51
- _this.renderingContext.renderReasons.add(RENDER_REASON.DisplayObjectRemoved);
52
49
  }
53
50
 
51
+ next(null);
54
52
  return null;
55
53
  }
56
54
  }
57
55
 
56
+ next(object);
58
57
  return object;
59
58
  });
60
- renderer.hooks.afterRender.tap(CullingPlugin_1.tag, function (object) {
61
- var entity = object.getEntity();
62
- entity.getComponent(Cullable).visibilityPlaneMask = -1;
59
+ renderingService.emitter.on(RenderingServiceEvent.AfterRender, function (object) {
60
+ object.entity.getComponent(Cullable).visibilityPlaneMask = -1;
63
61
  });
64
62
  };
65
63
 
66
- var CullingPlugin_1;
67
64
  CullingPlugin.tag = 'CullingPlugin';
68
65
 
69
66
  __decorate([inject(CanvasConfig), __metadata("design:type", Object)], CullingPlugin.prototype, "canvasConfig", void 0);
@@ -72,7 +69,7 @@ var CullingPlugin = function () {
72
69
 
73
70
  __decorate([inject(RenderingContext), __metadata("design:type", Object)], CullingPlugin.prototype, "renderingContext", void 0);
74
71
 
75
- CullingPlugin = CullingPlugin_1 = __decorate([injectable()], CullingPlugin);
72
+ CullingPlugin = __decorate([injectable()], CullingPlugin);
76
73
  return CullingPlugin;
77
74
  }();
78
75
 
@@ -6,5 +6,5 @@ export declare class DirtyCheckPlugin implements RenderingPlugin {
6
6
  static tag: string;
7
7
  private canvasConfig;
8
8
  private renderingContext;
9
- apply(renderer: RenderingService): void;
9
+ apply(renderingService: RenderingService): void;
10
10
  }
@@ -2,6 +2,7 @@ import { __decorate, __metadata } from "tslib";
2
2
  import { inject, injectable } from 'inversify';
3
3
  import { Renderable } from '../components';
4
4
  import { CanvasConfig } from '../types';
5
+ import { RenderingServiceEvent } from '../services/RenderingService';
5
6
  import { RenderingContext, RENDER_REASON } from '../services/RenderingContext';
6
7
  /**
7
8
  * Filter dirty renderables and calculate the "dirty rectangle" which will be clear when frame began
@@ -10,12 +11,10 @@ import { RenderingContext, RENDER_REASON } from '../services/RenderingContext';
10
11
  var DirtyCheckPlugin = function () {
11
12
  function DirtyCheckPlugin() {}
12
13
 
13
- DirtyCheckPlugin_1 = DirtyCheckPlugin;
14
-
15
- DirtyCheckPlugin.prototype.apply = function (renderer) {
14
+ DirtyCheckPlugin.prototype.apply = function (renderingService) {
16
15
  var _this = this;
17
16
 
18
- renderer.hooks.prepare.tap(DirtyCheckPlugin_1.tag, function (object) {
17
+ renderingService.emitter.on(RenderingServiceEvent.Prepare, function (object, next) {
19
18
  if (object) {
20
19
  var enableDirtyRectangleRendering = _this.canvasConfig.renderer.getConfig().enableDirtyRectangleRendering;
21
20
 
@@ -23,25 +22,27 @@ var DirtyCheckPlugin = function () {
23
22
 
24
23
  var isDirty = renderable.dirty || _this.renderingContext.renderReasons.has(RENDER_REASON.CameraChanged);
25
24
 
26
- if (isDirty || !enableDirtyRectangleRendering && !renderable.instanced) {
25
+ if (isDirty || !enableDirtyRectangleRendering) {
26
+ next(object);
27
27
  return object;
28
28
  } else {
29
+ next(null);
29
30
  return null;
30
31
  }
31
32
  }
32
33
 
34
+ next(object);
33
35
  return object;
34
36
  });
35
37
  };
36
38
 
37
- var DirtyCheckPlugin_1;
38
39
  DirtyCheckPlugin.tag = 'DirtyCheckPlugin';
39
40
 
40
41
  __decorate([inject(CanvasConfig), __metadata("design:type", Object)], DirtyCheckPlugin.prototype, "canvasConfig", void 0);
41
42
 
42
43
  __decorate([inject(RenderingContext), __metadata("design:type", Object)], DirtyCheckPlugin.prototype, "renderingContext", void 0);
43
44
 
44
- DirtyCheckPlugin = DirtyCheckPlugin_1 = __decorate([injectable()], DirtyCheckPlugin);
45
+ DirtyCheckPlugin = __decorate([injectable()], DirtyCheckPlugin);
45
46
  return DirtyCheckPlugin;
46
47
  }();
47
48