@antv/g 5.0.22-alpha.6 → 5.0.23-alpha.10

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 (164) hide show
  1. package/dist/index.umd.min.js +3 -3
  2. package/es/AbstractRenderer.js +5 -0
  3. package/es/camera/Camera.js +2 -2
  4. package/es/css/cssom/CSSKeywordValue.d.ts +1 -1
  5. package/es/css/cssom/CSSNumericSumValue.d.ts +1 -1
  6. package/es/css/cssom/CSSNumericValue.d.ts +141 -4
  7. package/es/css/cssom/CSSNumericValue.js +1166 -5
  8. package/es/css/cssom/CSSTransformValue.d.ts +1 -1
  9. package/es/css/cssom/index.d.ts +0 -10
  10. package/es/css/cssom/index.js +1 -11
  11. package/es/css/parser/color.js +1 -1
  12. package/es/css/parser/dimension.js +1 -2
  13. package/es/css/parser/numeric.d.ts +1 -1
  14. package/es/css/parser/numeric.js +2 -2
  15. package/es/css/parser/path.d.ts +2 -2
  16. package/es/css/parser/path.js +1 -1
  17. package/es/css/parser/points.js +1 -1
  18. package/es/css/parser/transform-origin.d.ts +1 -1
  19. package/es/css/parser/transform-origin.js +2 -2
  20. package/es/css/parser/transform.d.ts +1 -3
  21. package/es/css/parser/transform.js +9 -8
  22. package/es/css/properties/CSSPropertyPath.d.ts +14 -2
  23. package/es/css/properties/CSSPropertyTextTransform.d.ts +2 -2
  24. package/es/css/properties/CSSPropertyTransform.js +3 -4
  25. package/es/display-objects/DisplayObject.js +4 -5
  26. package/es/display-objects/Path.d.ts +15 -15
  27. package/es/display-objects/Path.js +1 -1
  28. package/es/display-objects/Polygon.d.ts +8 -1
  29. package/es/display-objects/Polyline.d.ts +7 -5
  30. package/es/dom/Document.js +2 -2
  31. package/es/dom/Element.js +1 -2
  32. package/es/dom/EventTarget.js +1 -1
  33. package/es/dom/FederatedTouchEvent.d.ts +5 -3
  34. package/es/plugins/CullingPlugin.d.ts +0 -1
  35. package/es/plugins/CullingPlugin.js +3 -8
  36. package/es/plugins/DirtyCheckPlugin.d.ts +1 -1
  37. package/es/plugins/DirtyCheckPlugin.js +9 -8
  38. package/es/plugins/EventPlugin.d.ts +1 -1
  39. package/es/plugins/EventPlugin.js +163 -148
  40. package/es/plugins/PrepareRendererPlugin.d.ts +0 -1
  41. package/es/plugins/PrepareRendererPlugin.js +16 -17
  42. package/es/services/EventService.d.ts +8 -0
  43. package/es/services/EventService.js +274 -20
  44. package/es/services/RenderingService.d.ts +17 -16
  45. package/es/services/RenderingService.js +19 -18
  46. package/es/services/SceneGraphService.js +1 -1
  47. package/es/services/aabb/PathUpdater.d.ts +3 -3
  48. package/es/services/aabb/PolylineUpdater.d.ts +3 -3
  49. package/es/services/aabb/RectUpdater.js +1 -1
  50. package/es/types.d.ts +5 -3
  51. package/es/utils/assert.d.ts +6 -0
  52. package/es/utils/assert.js +18 -0
  53. package/es/utils/event.d.ts +18 -16
  54. package/es/utils/hooks.d.ts +280 -0
  55. package/es/utils/hooks.js +753 -0
  56. package/es/utils/index.d.ts +1 -0
  57. package/es/utils/index.js +2 -1
  58. package/es/utils/math.d.ts +1 -0
  59. package/es/utils/math.js +13 -2
  60. package/es/utils/string.d.ts +1 -0
  61. package/es/utils/string.js +8 -0
  62. package/es/utils/text.js +2 -1
  63. package/lib/AbstractRenderer.js +5 -0
  64. package/lib/camera/Camera.js +4 -4
  65. package/lib/css/cssom/CSSKeywordValue.d.ts +1 -1
  66. package/lib/css/cssom/CSSNumericSumValue.d.ts +1 -1
  67. package/lib/css/cssom/CSSNumericValue.d.ts +141 -4
  68. package/lib/css/cssom/CSSNumericValue.js +1226 -52
  69. package/lib/css/cssom/CSSTransformValue.d.ts +1 -1
  70. package/lib/css/cssom/index.d.ts +0 -10
  71. package/lib/css/cssom/index.js +0 -130
  72. package/lib/css/parser/color.js +5 -5
  73. package/lib/css/parser/dimension.js +1 -3
  74. package/lib/css/parser/numeric.d.ts +1 -1
  75. package/lib/css/parser/numeric.js +7 -7
  76. package/lib/css/parser/path.d.ts +2 -2
  77. package/lib/css/parser/path.js +4 -4
  78. package/lib/css/parser/points.js +2 -2
  79. package/lib/css/parser/transform-origin.d.ts +1 -1
  80. package/lib/css/parser/transform-origin.js +4 -4
  81. package/lib/css/parser/transform.d.ts +1 -3
  82. package/lib/css/parser/transform.js +25 -24
  83. package/lib/css/properties/CSSPropertyPath.d.ts +14 -2
  84. package/lib/css/properties/CSSPropertyTextTransform.d.ts +2 -2
  85. package/lib/css/properties/CSSPropertyTransform.js +18 -20
  86. package/lib/display-objects/DisplayObject.js +7 -9
  87. package/lib/display-objects/Path.d.ts +15 -15
  88. package/lib/display-objects/Path.js +3 -3
  89. package/lib/display-objects/Polygon.d.ts +8 -1
  90. package/lib/display-objects/Polyline.d.ts +7 -5
  91. package/lib/dom/Document.js +2 -2
  92. package/lib/dom/Element.js +1 -3
  93. package/lib/dom/EventTarget.js +9 -9
  94. package/lib/dom/FederatedTouchEvent.d.ts +5 -3
  95. package/lib/plugins/CullingPlugin.d.ts +0 -1
  96. package/lib/plugins/CullingPlugin.js +3 -7
  97. package/lib/plugins/DirtyCheckPlugin.d.ts +1 -1
  98. package/lib/plugins/DirtyCheckPlugin.js +10 -8
  99. package/lib/plugins/EventPlugin.d.ts +1 -1
  100. package/lib/plugins/EventPlugin.js +172 -156
  101. package/lib/plugins/PrepareRendererPlugin.d.ts +0 -1
  102. package/lib/plugins/PrepareRendererPlugin.js +16 -16
  103. package/lib/services/EventService.d.ts +8 -0
  104. package/lib/services/EventService.js +274 -19
  105. package/lib/services/RenderingService.d.ts +17 -16
  106. package/lib/services/RenderingService.js +21 -20
  107. package/lib/services/SceneGraphService.js +3 -3
  108. package/lib/services/aabb/PathUpdater.d.ts +3 -3
  109. package/lib/services/aabb/PolylineUpdater.d.ts +3 -3
  110. package/lib/services/aabb/RectUpdater.js +3 -3
  111. package/lib/types.d.ts +5 -3
  112. package/lib/utils/assert.d.ts +6 -0
  113. package/lib/utils/assert.js +30 -0
  114. package/lib/utils/event.d.ts +18 -16
  115. package/lib/utils/hooks.d.ts +280 -0
  116. package/lib/utils/hooks.js +759 -0
  117. package/lib/utils/index.d.ts +1 -0
  118. package/lib/utils/index.js +13 -0
  119. package/lib/utils/math.d.ts +1 -0
  120. package/lib/utils/math.js +17 -4
  121. package/lib/utils/string.d.ts +1 -0
  122. package/lib/utils/string.js +11 -0
  123. package/lib/utils/text.js +5 -3
  124. package/package.json +4 -7
  125. package/es/css/cssom/CSSMathInvert.d.ts +0 -14
  126. package/es/css/cssom/CSSMathInvert.js +0 -84
  127. package/es/css/cssom/CSSMathMax.d.ts +0 -17
  128. package/es/css/cssom/CSSMathMax.js +0 -118
  129. package/es/css/cssom/CSSMathMin.d.ts +0 -17
  130. package/es/css/cssom/CSSMathMin.js +0 -119
  131. package/es/css/cssom/CSSMathNegate.d.ts +0 -14
  132. package/es/css/cssom/CSSMathNegate.js +0 -80
  133. package/es/css/cssom/CSSMathProduct.d.ts +0 -16
  134. package/es/css/cssom/CSSMathProduct.js +0 -109
  135. package/es/css/cssom/CSSMathSum.d.ts +0 -17
  136. package/es/css/cssom/CSSMathSum.js +0 -117
  137. package/es/css/cssom/CSSMathValue.d.ts +0 -11
  138. package/es/css/cssom/CSSMathValue.js +0 -27
  139. package/es/css/cssom/CSSMathVariadic.d.ts +0 -9
  140. package/es/css/cssom/CSSMathVariadic.js +0 -44
  141. package/es/css/cssom/CSSNumericValueType.d.ts +0 -33
  142. package/es/css/cssom/CSSNumericValueType.js +0 -259
  143. package/es/css/cssom/CSSUnitValue.d.ts +0 -33
  144. package/es/css/cssom/CSSUnitValue.js +0 -252
  145. package/lib/css/cssom/CSSMathInvert.d.ts +0 -14
  146. package/lib/css/cssom/CSSMathInvert.js +0 -94
  147. package/lib/css/cssom/CSSMathMax.d.ts +0 -17
  148. package/lib/css/cssom/CSSMathMax.js +0 -128
  149. package/lib/css/cssom/CSSMathMin.d.ts +0 -17
  150. package/lib/css/cssom/CSSMathMin.js +0 -128
  151. package/lib/css/cssom/CSSMathNegate.d.ts +0 -14
  152. package/lib/css/cssom/CSSMathNegate.js +0 -89
  153. package/lib/css/cssom/CSSMathProduct.d.ts +0 -16
  154. package/lib/css/cssom/CSSMathProduct.js +0 -119
  155. package/lib/css/cssom/CSSMathSum.d.ts +0 -17
  156. package/lib/css/cssom/CSSMathSum.js +0 -129
  157. package/lib/css/cssom/CSSMathValue.d.ts +0 -11
  158. package/lib/css/cssom/CSSMathValue.js +0 -35
  159. package/lib/css/cssom/CSSMathVariadic.d.ts +0 -9
  160. package/lib/css/cssom/CSSMathVariadic.js +0 -55
  161. package/lib/css/cssom/CSSNumericValueType.d.ts +0 -33
  162. package/lib/css/cssom/CSSNumericValueType.js +0 -272
  163. package/lib/css/cssom/CSSUnitValue.d.ts +0 -33
  164. package/lib/css/cssom/CSSUnitValue.js +0 -267
@@ -0,0 +1,280 @@
1
+ /**
2
+ * a lite tapable implementation
3
+ * borrow from https://github.com/funnyecho/hamon
4
+ */
5
+ declare type Measure<T extends number> = T extends 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 ? T : never;
6
+ declare type Append<T extends any[], U> = {
7
+ 0: [U];
8
+ 1: [T[0], U];
9
+ 2: [T[0], T[1], U];
10
+ 3: [T[0], T[1], T[2], U];
11
+ 4: [T[0], T[1], T[2], T[3], U];
12
+ 5: [T[0], T[1], T[2], T[3], T[4], U];
13
+ 6: [T[0], T[1], T[2], T[3], T[4], T[5], U];
14
+ 7: [T[0], T[1], T[2], T[3], T[4], T[5], T[6], U];
15
+ 8: [T[0], T[1], T[2], T[3], T[4], T[5], T[6], T[7], U];
16
+ }[Measure<T['length']>];
17
+ declare type AsArray<T> = T extends any[] ? T : [];
18
+ declare type Callback<E, T> = (error?: E, result?: T) => void;
19
+ declare type ITapID = string;
20
+ declare type IHookBucketType = any;
21
+ declare type IHookBucketHashcode<T> = (...args: AsArray<T>) => IHookBucketType;
22
+ declare type IAsyncTapArgs<T, R> = Append<AsArray<T>, Callback<Error, R>>;
23
+ declare type ISyncTapCallback<T, R> = (...args: AsArray<T>) => R;
24
+ declare type IAsyncTapCallback<T, R> = (...args: IAsyncTapArgs<T, R>) => void;
25
+ declare type IPromiseTapCallback<T, R> = (...args: AsArray<T>) => Promise<R>;
26
+ export declare type ITapDestroy = () => void;
27
+ interface ITapOptions<T, R> {
28
+ fn: IAsyncTapCallback<T, R> | ISyncTapCallback<T, R>;
29
+ bucket: string;
30
+ }
31
+ interface IInvokeSeriesObserver<T, R> {
32
+ shouldBail?: boolean;
33
+ shouldWaterfall?: boolean;
34
+ onComplete?: (err: Error, result?: R) => void;
35
+ }
36
+ interface IInvokeParallelObserver<T, R> {
37
+ shouldBail?: boolean;
38
+ onComplete?: (err: Error, result?: R) => void;
39
+ }
40
+ interface IInvokeSynchronouslyObserver<T, R> {
41
+ shouldBail?: boolean;
42
+ shouldWaterfall?: boolean;
43
+ }
44
+ /**
45
+ * Basic Hook Type
46
+ *
47
+ * @remarks
48
+ * All subtype hooks are extends from `Hook` which provide the tapping and calling logic
49
+ *
50
+ * @param T - tuple types of calling arguments
51
+ * @param R - returning value type of calling
52
+ *
53
+ * @public
54
+ * */
55
+ export declare abstract class Hook<T, R> {
56
+ private tapIdSeed;
57
+ /**
58
+ * @internal
59
+ * */
60
+ protected readonly bucketHashcode: IHookBucketHashcode<T>;
61
+ /**
62
+ * @internal
63
+ * */
64
+ protected readonly presetTapBucket: Set<ITapID>;
65
+ /**
66
+ * @internal
67
+ * */
68
+ protected readonly tapBuckets: Map<IHookBucketType, Set<ITapID>>;
69
+ /**
70
+ * @internal
71
+ * */
72
+ protected readonly tapOptionsCache: Map<ITapID, ITapOptions<T, R>>;
73
+ /**
74
+ * @param bucketHashcode - calculate the hashcode value of calling arguments
75
+ * */
76
+ constructor(bucketHashcode?: IHookBucketHashcode<T>);
77
+ /**
78
+ * clear all tapping from hook
79
+ *
80
+ * @public
81
+ * */
82
+ exhaust(): void;
83
+ /**
84
+ * clear all tapping from hook
85
+ *
86
+ * @remarks
87
+ * The same as `exhaust` {@link Hook.exhaust}
88
+ *
89
+ * @privateRemarks
90
+ * call `exhaust`
91
+ *
92
+ * @public
93
+ * */
94
+ destroy(): void;
95
+ /**
96
+ * @internal
97
+ * */
98
+ protected insertSyncTap(fn: ISyncTapCallback<T, R>, bucket?: IHookBucketType): ITapDestroy;
99
+ /**
100
+ * @internal
101
+ * */
102
+ protected insertAsyncTap(fn: IAsyncTapCallback<T, R>, bucket?: IHookBucketType): ITapDestroy;
103
+ /**
104
+ * @internal
105
+ * */
106
+ protected insertPromiseTap(fn: IPromiseTapCallback<T, R | void>, bucket?: IHookBucketType): ITapDestroy;
107
+ /**
108
+ * @internal
109
+ * */
110
+ protected invokeSeries(args: AsArray<T>, observer?: IInvokeSeriesObserver<T, R>): void;
111
+ /**
112
+ * @internal
113
+ * */
114
+ protected invokeParallel(args: AsArray<T>, observer?: IInvokeParallelObserver<T, R>): void;
115
+ /**
116
+ * @internal
117
+ * */
118
+ protected invokeSynchronously(args: AsArray<T>, observer?: IInvokeSynchronouslyObserver<T, R>): R;
119
+ /**
120
+ * @internal
121
+ * */
122
+ protected getBucketTaps(args: AsArray<T>): Set<ITapOptions<T, R>>;
123
+ /**
124
+ * @internal
125
+ * */
126
+ private tapping;
127
+ /**
128
+ * @internal
129
+ * */
130
+ protected popoutTap(tapId: ITapID): void;
131
+ /**
132
+ * @internal
133
+ * */
134
+ private generateTapId;
135
+ }
136
+ /**
137
+ * Abstract Sync Hook
138
+ *
139
+ * @remarks
140
+ * Providing `tap` method for synchronous hooks
141
+ *
142
+ * @public
143
+ * */
144
+ export declare abstract class SyncTapHook<T, R> extends Hook<T, R> {
145
+ /**
146
+ * listen to hook
147
+ *
148
+ * @param fn - Listener callback
149
+ * @param bucket - Listen to specified hashcode bucket
150
+ * @returns The unTap function
151
+ *
152
+ * @public
153
+ * */
154
+ tap(fn: ISyncTapCallback<T, R>, bucket?: IHookBucketType): ITapDestroy;
155
+ }
156
+ /**
157
+ * Abstract Async Hook
158
+ *
159
+ * @remarks
160
+ * Providing `tapAsync` and `tapPromise` methods for asynchronous hooks
161
+ *
162
+ * @public
163
+ * */
164
+ export declare abstract class AsyncTapHook<T, R> extends Hook<T, R> {
165
+ /**
166
+ * listen to hook in async callback mode
167
+ *
168
+ * @param fn - Listener callback
169
+ * The last argument of `fn` which named `cb` will be a function which signature is `(err?: Error, result?: T) => void`.
170
+ * When error occur, pass the error to `cb` as first param and the `result` param should be void,
171
+ * Otherwise, first param must be void.
172
+ *
173
+ * @param bucket - Listen to specified hashcode bucket
174
+ * @returns The unTap function
175
+ *
176
+ * @public
177
+ * */
178
+ tapAsync(fn: IAsyncTapCallback<T, R>, bucket?: IHookBucketType): ITapDestroy;
179
+ /**
180
+ * listen to hook in async promise mode
181
+ *
182
+ * @param fn - Listener callback
183
+ * When tapping success, return resolved promise.
184
+ * Otherwise, throw error or return rejected promise.
185
+ *
186
+ * @param bucket - Listen to specified hashcode bucket
187
+ * @returns The unTap function
188
+ *
189
+ * @public
190
+ * */
191
+ tapPromise(fn: IPromiseTapCallback<T, R | void>, bucket?: IHookBucketType): ITapDestroy;
192
+ }
193
+ /**
194
+ * Synchronous Hook
195
+ *
196
+ * @remarks
197
+ * Invoke listener Synchronously and return nothing
198
+ *
199
+ * @public
200
+ * */
201
+ export declare class SyncHook<T, R = void> extends SyncTapHook<T, R> {
202
+ /**
203
+ * call listener with `...args`
204
+ *
205
+ * @param args - rest parameters of calling arguments
206
+ *
207
+ * */
208
+ call(...args: AsArray<T>): void;
209
+ }
210
+ /**
211
+ * Synchronous Waterfall Hook
212
+ *
213
+ * @remarks
214
+ * Invoke listener Synchronously.
215
+ * Those non-undefined value returned from upstream listener, will waterfall to downstream as first element of arguments.
216
+ * Calling return with waterfall value of last listener.
217
+ *
218
+ * @public
219
+ * */
220
+ export declare class SyncWaterfallHook<T, R> extends SyncTapHook<T, R> {
221
+ /**
222
+ * call listener with `...args`
223
+ *
224
+ * @param args - rest parameters of calling arguments
225
+ * @returns waterfall value
226
+ * */
227
+ call(...args: AsArray<T>): R;
228
+ }
229
+ /**
230
+ * Asynchronous Parallel Hook
231
+ *
232
+ * @remarks
233
+ * Invoke listeners in parallel asynchronously
234
+ *
235
+ * @public
236
+ * */
237
+ export declare class AsyncParallelHook<T, R = void> extends AsyncTapHook<T, R> {
238
+ /**
239
+ * call listener with `...args` and `cb`
240
+ *
241
+ * @param args - rest parameters of calling arguments and `cb`
242
+ * The signature of `cb` is `(err?: Error) => void`.
243
+ * */
244
+ callAsync(...args: IAsyncTapArgs<T, R>): void;
245
+ /***
246
+ * call listener with `...args`
247
+ *
248
+ * @param args - rest parameters of calling arguments
249
+ * @returns Promise indicated whether calling succeed or failed
250
+ * */
251
+ callPromise(...args: AsArray<T>): Promise<R>;
252
+ }
253
+ /**
254
+ * Asynchronous Waterfall Hook
255
+ *
256
+ * @remarks
257
+ * Invoke listener in queue Asynchronously.
258
+ * Those non-undefined value returned from upstream listener, will waterfall to downstream as first element of arguments.
259
+ * Calling return with waterfall value of last listener.
260
+ *
261
+ * @public
262
+ * */
263
+ export declare class AsyncSeriesWaterfallHook<T, R> extends AsyncTapHook<T, R> {
264
+ /**
265
+ * call listener with `...args` and `cb`
266
+ *
267
+ * @param args - rest parameters of calling arguments and `cb`
268
+ * The signature of `cb` is `(err?: Error) => void`.
269
+ * */
270
+ callAsync(...args: IAsyncTapArgs<T, R>): void;
271
+ /***
272
+ * call listener with `...args`
273
+ *
274
+ * @param args - rest parameters of calling arguments
275
+ * @returns Promise indicated whether calling succeed or failed
276
+ * If calling succeed, promise was resolved with waterfall value.
277
+ * */
278
+ callPromise(...args: AsArray<T>): Promise<R>;
279
+ }
280
+ export {};