@antv/g 5.0.4 → 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.
- package/dist/index.umd.js +1 -1
- package/es/Canvas.d.ts +9 -0
- package/es/Canvas.js +9 -4
- package/es/display-objects/DisplayObject.d.ts +0 -3
- package/es/display-objects/DisplayObject.js +16 -9
- package/es/global-module.d.ts +4 -0
- package/es/global-module.js +57 -69
- package/es/plugins/FrustumCullingStrategy.js +3 -1
- package/es/services/RenderingService.d.ts +5 -0
- package/es/services/RenderingService.js +15 -1
- package/es/utils/interpolation.js +10 -7
- package/lib/Canvas.d.ts +9 -0
- package/lib/Canvas.js +9 -4
- package/lib/display-objects/DisplayObject.d.ts +0 -3
- package/lib/display-objects/DisplayObject.js +13 -8
- package/lib/global-module.d.ts +4 -0
- package/lib/global-module.js +57 -69
- package/lib/plugins/FrustumCullingStrategy.js +2 -0
- package/lib/services/RenderingService.d.ts +5 -0
- package/lib/services/RenderingService.js +15 -1
- package/lib/utils/interpolation.js +7 -9
- package/package.json +3 -3
package/es/Canvas.d.ts
CHANGED
|
@@ -42,6 +42,11 @@ export declare class Canvas extends EventTarget implements ICanvas {
|
|
|
42
42
|
* rAF in auto rendering
|
|
43
43
|
*/
|
|
44
44
|
private frameId?;
|
|
45
|
+
/**
|
|
46
|
+
* cache here since inversify's resolving is very slow
|
|
47
|
+
*/
|
|
48
|
+
private eventService;
|
|
49
|
+
private renderingService;
|
|
45
50
|
constructor(config: CanvasConfig);
|
|
46
51
|
private initRenderingContext;
|
|
47
52
|
private initDefaultCamera;
|
|
@@ -60,6 +65,10 @@ export declare class Canvas extends EventTarget implements ICanvas {
|
|
|
60
65
|
getEventService(): EventService;
|
|
61
66
|
getRenderingService(): RenderingService;
|
|
62
67
|
getRenderingContext(): RenderingContext;
|
|
68
|
+
getStats(): {
|
|
69
|
+
total: number;
|
|
70
|
+
rendered: number;
|
|
71
|
+
};
|
|
63
72
|
getComputedStyle(node: DisplayObject): any;
|
|
64
73
|
destroy(destroyScenegraph?: boolean): void;
|
|
65
74
|
/**
|
package/es/Canvas.js
CHANGED
|
@@ -142,17 +142,21 @@ function (_super) {
|
|
|
142
142
|
};
|
|
143
143
|
|
|
144
144
|
Canvas.prototype.getEventService = function () {
|
|
145
|
-
return this.
|
|
145
|
+
return this.eventService;
|
|
146
146
|
};
|
|
147
147
|
|
|
148
148
|
Canvas.prototype.getRenderingService = function () {
|
|
149
|
-
return this.
|
|
149
|
+
return this.renderingService;
|
|
150
150
|
};
|
|
151
151
|
|
|
152
152
|
Canvas.prototype.getRenderingContext = function () {
|
|
153
153
|
return this.container.get(RenderingContext);
|
|
154
154
|
};
|
|
155
155
|
|
|
156
|
+
Canvas.prototype.getStats = function () {
|
|
157
|
+
return this.getRenderingService().getStats();
|
|
158
|
+
};
|
|
159
|
+
|
|
156
160
|
Canvas.prototype.getComputedStyle = function (node) {
|
|
157
161
|
return node.parsedStyle;
|
|
158
162
|
};
|
|
@@ -275,9 +279,10 @@ function (_super) {
|
|
|
275
279
|
this.loadRendererContainerModule(renderer); // init context
|
|
276
280
|
|
|
277
281
|
var contextService = this.container.get(ContextService);
|
|
278
|
-
|
|
282
|
+
this.renderingService = this.container.get(RenderingService);
|
|
283
|
+
this.eventService = this.container.get(EventService);
|
|
279
284
|
contextService.init();
|
|
280
|
-
renderingService.init().then(function () {
|
|
285
|
+
this.renderingService.init().then(function () {
|
|
281
286
|
_this.emit(CanvasEvent.READY, {});
|
|
282
287
|
});
|
|
283
288
|
|
|
@@ -4,7 +4,6 @@ import type { Animation } from '../dom/Animation';
|
|
|
4
4
|
import { Element } from '../dom/Element';
|
|
5
5
|
import type { DisplayObjectConfig, IChildNode } from '../dom/interfaces';
|
|
6
6
|
import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
|
|
7
|
-
import type { StylePropertyParser, StylePropertyUpdater } from '../property-handlers';
|
|
8
7
|
/**
|
|
9
8
|
* prototype chains: DisplayObject -> Element -> Node -> EventTarget
|
|
10
9
|
*
|
|
@@ -32,8 +31,6 @@ export declare class DisplayObject<StyleProps extends BaseStyleProps = any, Pars
|
|
|
32
31
|
* push to active animations after calling `animate()`
|
|
33
32
|
*/
|
|
34
33
|
private activeAnimations;
|
|
35
|
-
stylePropertyUpdaterFactory: <Key extends keyof StyleProps>(stylePropertyName: Key) => StylePropertyUpdater<any>[];
|
|
36
|
-
stylePropertyParserFactory: <Key extends keyof ParsedStyleProps>(stylePropertyName: Key) => StylePropertyParser<any, any>;
|
|
37
34
|
constructor(config: DisplayObjectConfig<StyleProps>);
|
|
38
35
|
destroy(): void;
|
|
39
36
|
cloneNode(deep?: boolean): this;
|
|
@@ -6,9 +6,10 @@ import { KeyframeEffect } from '../dom/KeyframeEffect';
|
|
|
6
6
|
import { Element } from '../dom/Element';
|
|
7
7
|
import { ElementEvent } from '../dom/interfaces';
|
|
8
8
|
import { SHAPE } from '../types';
|
|
9
|
-
import { createVec3, fromRotationTranslationScale, getEuler, rad2deg } from '../utils';
|
|
10
|
-
import { StylePropertyParserFactory, StylePropertyUpdaterFactory } from '../property-handlers';
|
|
11
|
-
|
|
9
|
+
import { createVec3, fromRotationTranslationScale, getEuler, rad2deg } from '../utils'; // import type { StylePropertyParser, StylePropertyUpdater } from '../property-handlers';
|
|
10
|
+
// import { StylePropertyParserFactory, StylePropertyUpdaterFactory } from '../property-handlers';
|
|
11
|
+
|
|
12
|
+
import { globalContainer, stylePropertyParserFactory, stylePropertyUpdaterFactory } from '../global-module';
|
|
12
13
|
import { dirtifyToRoot } from '../services';
|
|
13
14
|
var DEFAULT_STYLE_PROPS = {
|
|
14
15
|
anchor: [0, 0, 0],
|
|
@@ -39,7 +40,13 @@ var DEFAULT_STYLE_PROPS = {
|
|
|
39
40
|
var DisplayObject =
|
|
40
41
|
/** @class */
|
|
41
42
|
function (_super) {
|
|
42
|
-
__extends(DisplayObject, _super);
|
|
43
|
+
__extends(DisplayObject, _super); // stylePropertyUpdaterFactory = globalContainer.get<
|
|
44
|
+
// <Key extends keyof StyleProps>(stylePropertyName: Key) => StylePropertyUpdater<any>[]
|
|
45
|
+
// >(StylePropertyUpdaterFactory);
|
|
46
|
+
// stylePropertyParserFactory = globalContainer.get<
|
|
47
|
+
// <Key extends keyof ParsedStyleProps>(stylePropertyName: Key) => StylePropertyParser<any, any>
|
|
48
|
+
// >(StylePropertyParserFactory);
|
|
49
|
+
|
|
43
50
|
|
|
44
51
|
function DisplayObject(config) {
|
|
45
52
|
var _a, _b, _c;
|
|
@@ -50,9 +57,7 @@ function (_super) {
|
|
|
50
57
|
*/
|
|
51
58
|
|
|
52
59
|
|
|
53
|
-
_this.activeAnimations = [];
|
|
54
|
-
_this.stylePropertyUpdaterFactory = globalContainer.get(StylePropertyUpdaterFactory);
|
|
55
|
-
_this.stylePropertyParserFactory = globalContainer.get(StylePropertyParserFactory); // assign name, id to config
|
|
60
|
+
_this.activeAnimations = []; // assign name, id to config
|
|
56
61
|
// eg. group.get('name')
|
|
57
62
|
|
|
58
63
|
_this.config = config; // compatible with G 3.0
|
|
@@ -178,7 +183,8 @@ function (_super) {
|
|
|
178
183
|
|
|
179
184
|
|
|
180
185
|
DisplayObject.prototype.parseStyleProperty = function (name, value) {
|
|
181
|
-
|
|
186
|
+
// const stylePropertyParser = this.stylePropertyParserFactory(name);
|
|
187
|
+
var stylePropertyParser = stylePropertyParserFactory[name];
|
|
182
188
|
|
|
183
189
|
if (stylePropertyParser) {
|
|
184
190
|
// @ts-ignore
|
|
@@ -191,9 +197,10 @@ function (_super) {
|
|
|
191
197
|
DisplayObject.prototype.updateStyleProperty = function (name, oldParsedValue, newParsedValue) {
|
|
192
198
|
var _this = this; // update property, which may cause AABB re-calc
|
|
193
199
|
// @ts-ignore
|
|
200
|
+
// const stylePropertyUpdaters = this.stylePropertyUpdaterFactory(name);
|
|
194
201
|
|
|
195
202
|
|
|
196
|
-
var stylePropertyUpdaters =
|
|
203
|
+
var stylePropertyUpdaters = stylePropertyUpdaterFactory[name];
|
|
197
204
|
|
|
198
205
|
if (stylePropertyUpdaters) {
|
|
199
206
|
stylePropertyUpdaters.forEach(function (updater) {
|
package/es/global-module.d.ts
CHANGED
|
@@ -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;
|
package/es/global-module.js
CHANGED
|
@@ -7,8 +7,14 @@ 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 {
|
|
10
|
+
import { // StylePropertyParserFactory,
|
|
11
|
+
// StylePropertyUpdaterFactory,
|
|
12
|
+
// StylePropertyMergerFactory,
|
|
13
|
+
clampedMergeNumbers, parseNumber, mergeColors, parseColor, updateGeometry, updateLocalPosition, updateOffsetPath, updateClipPath, updateZIndex, updateOffsetDistance, updateOrigin, updateTransform, updateTransformOrigin, parseTransform, mergeTransforms, parsePath, parsePoints, mergePaths, mergeNumbers, mergeNumberLists, parseFilter, updateAnchor, parseLineDash } from './property-handlers';
|
|
11
14
|
export var globalContainer = GlobalContainer;
|
|
15
|
+
export var stylePropertyParserFactory = {};
|
|
16
|
+
export var stylePropertyUpdaterFactory = {};
|
|
17
|
+
export var stylePropertyMergerFactory = {};
|
|
12
18
|
export var containerModule = Module(function (register) {
|
|
13
19
|
decorate(injectable(), EventEmitter); // bind DisplayObject pool
|
|
14
20
|
|
|
@@ -56,83 +62,65 @@ export var containerModule = Module(function (register) {
|
|
|
56
62
|
return cache[tagName];
|
|
57
63
|
};
|
|
58
64
|
}
|
|
59
|
-
}); // bind style property handlers
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
return cache[propertyName];
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
});
|
|
65
|
+
}); // // bind style property handlers
|
|
66
|
+
// register({
|
|
67
|
+
// token: StylePropertyParserFactory,
|
|
68
|
+
// useFactory: (context) => {
|
|
69
|
+
// const cache = {};
|
|
70
|
+
// return (propertyName: string) => {
|
|
71
|
+
// if (!cache[propertyName]) {
|
|
72
|
+
// if (context.container.isBoundNamed(StylePropertyParser, propertyName)) {
|
|
73
|
+
// cache[propertyName] = context.container.getNamed(StylePropertyParser, propertyName);
|
|
74
|
+
// }
|
|
75
|
+
// }
|
|
76
|
+
// return cache[propertyName];
|
|
77
|
+
// };
|
|
78
|
+
// },
|
|
79
|
+
// });
|
|
80
|
+
// register({
|
|
81
|
+
// token: StylePropertyUpdaterFactory,
|
|
82
|
+
// useFactory: (context) => {
|
|
83
|
+
// const cache = {};
|
|
84
|
+
// return (propertyName: string) => {
|
|
85
|
+
// if (!cache[propertyName]) {
|
|
86
|
+
// if (context.container.isBoundNamed(StylePropertyUpdater, propertyName)) {
|
|
87
|
+
// cache[propertyName] = context.container.getAllNamed(StylePropertyUpdater, propertyName);
|
|
88
|
+
// }
|
|
89
|
+
// }
|
|
90
|
+
// return cache[propertyName];
|
|
91
|
+
// };
|
|
92
|
+
// },
|
|
93
|
+
// });
|
|
94
|
+
// register({
|
|
95
|
+
// token: StylePropertyMergerFactory,
|
|
96
|
+
// useFactory: (context) => {
|
|
97
|
+
// const cache = {};
|
|
98
|
+
// return (propertyName: string) => {
|
|
99
|
+
// if (!cache[propertyName]) {
|
|
100
|
+
// if (context.container.isBoundNamed(StylePropertyMerger, propertyName)) {
|
|
101
|
+
// cache[propertyName] = context.container.getNamed(StylePropertyMerger, propertyName);
|
|
102
|
+
// }
|
|
103
|
+
// }
|
|
104
|
+
// return cache[propertyName];
|
|
105
|
+
// };
|
|
106
|
+
// },
|
|
107
|
+
// });
|
|
106
108
|
|
|
107
109
|
function addPropertyHandler(property, parser, merger, updater) {
|
|
108
110
|
if (parser) {
|
|
109
|
-
register({
|
|
110
|
-
token: {
|
|
111
|
-
token: StylePropertyParser,
|
|
112
|
-
named: property
|
|
113
|
-
},
|
|
114
|
-
useValue: parser
|
|
115
|
-
});
|
|
111
|
+
stylePropertyParserFactory[property] = parser; // register({ token: { token: StylePropertyParser, named: property }, useValue: parser });
|
|
116
112
|
}
|
|
117
113
|
|
|
118
114
|
if (merger) {
|
|
119
|
-
register({
|
|
120
|
-
token: {
|
|
121
|
-
token: StylePropertyMerger,
|
|
122
|
-
named: property
|
|
123
|
-
},
|
|
124
|
-
useValue: merger
|
|
125
|
-
});
|
|
115
|
+
stylePropertyMergerFactory[property] = merger; // register({ token: { token: StylePropertyMerger, named: property }, useValue: merger });
|
|
126
116
|
}
|
|
127
117
|
|
|
128
118
|
if (updater) {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
useValue: updater
|
|
135
|
-
});
|
|
119
|
+
if (!stylePropertyUpdaterFactory[property]) {
|
|
120
|
+
stylePropertyUpdaterFactory[property] = [];
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
stylePropertyUpdaterFactory[property].push(updater); // register({ token: { token: StylePropertyUpdater, named: property }, useValue: updater });
|
|
136
124
|
}
|
|
137
125
|
}
|
|
138
126
|
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { __decorate } from "tslib";
|
|
1
|
+
import { __decorate } from "tslib"; // import { vec3, mat4 } from 'gl-matrix';
|
|
2
|
+
// import { inject, singleton } from 'mana-syringe';
|
|
3
|
+
|
|
2
4
|
import { vec3 } from 'gl-matrix';
|
|
3
5
|
import { singleton } from 'mana-syringe';
|
|
4
6
|
import { CullingStrategyContribution } from './CullingPlugin';
|
|
@@ -24,6 +24,7 @@ export declare class RenderingService {
|
|
|
24
24
|
private renderingContext;
|
|
25
25
|
private sceneGraphService;
|
|
26
26
|
private inited;
|
|
27
|
+
private stats;
|
|
27
28
|
hooks: {
|
|
28
29
|
init: AsyncSeriesHook<[], import("tapable").UnsetAdditionalOptions>;
|
|
29
30
|
prepare: SyncWaterfallHook<[DisplayObject<any, any>], import("tapable").UnsetAdditionalOptions>;
|
|
@@ -45,6 +46,10 @@ export declare class RenderingService {
|
|
|
45
46
|
pointerWheel: SyncHook<[InteractivePointerEvent], void, import("tapable").UnsetAdditionalOptions>;
|
|
46
47
|
};
|
|
47
48
|
init(): Promise<void>;
|
|
49
|
+
getStats(): {
|
|
50
|
+
total: number;
|
|
51
|
+
rendered: number;
|
|
52
|
+
};
|
|
48
53
|
render(): void;
|
|
49
54
|
private renderDisplayObject;
|
|
50
55
|
destroy(): void;
|
|
@@ -19,6 +19,10 @@ var RenderingService =
|
|
|
19
19
|
function () {
|
|
20
20
|
function RenderingService() {
|
|
21
21
|
this.inited = false;
|
|
22
|
+
this.stats = {
|
|
23
|
+
total: 0,
|
|
24
|
+
rendered: 0
|
|
25
|
+
};
|
|
22
26
|
this.hooks = {
|
|
23
27
|
init: new AsyncSeriesHook(),
|
|
24
28
|
prepare: new SyncWaterfallHook(['object']),
|
|
@@ -71,7 +75,13 @@ function () {
|
|
|
71
75
|
});
|
|
72
76
|
};
|
|
73
77
|
|
|
78
|
+
RenderingService.prototype.getStats = function () {
|
|
79
|
+
return this.stats;
|
|
80
|
+
};
|
|
81
|
+
|
|
74
82
|
RenderingService.prototype.render = function () {
|
|
83
|
+
this.stats.total = 0;
|
|
84
|
+
this.stats.rendered = 0;
|
|
75
85
|
this.sceneGraphService.syncHierarchy(this.renderingContext.root);
|
|
76
86
|
|
|
77
87
|
if (this.renderingContext.renderReasons.size && this.inited) {
|
|
@@ -88,7 +98,8 @@ function () {
|
|
|
88
98
|
}
|
|
89
99
|
|
|
90
100
|
this.renderingContext.renderReasons.clear();
|
|
91
|
-
}
|
|
101
|
+
} // console.log('render objects: ', this.stats.count);
|
|
102
|
+
|
|
92
103
|
};
|
|
93
104
|
|
|
94
105
|
RenderingService.prototype.renderDisplayObject = function (displayObject) {
|
|
@@ -96,8 +107,11 @@ function () {
|
|
|
96
107
|
|
|
97
108
|
|
|
98
109
|
var objectToRender = this.hooks.prepare.call(displayObject);
|
|
110
|
+
this.stats.total++;
|
|
99
111
|
|
|
100
112
|
if (objectToRender) {
|
|
113
|
+
this.stats.rendered++;
|
|
114
|
+
|
|
101
115
|
if (!this.renderingContext.dirty) {
|
|
102
116
|
this.renderingContext.dirty = true;
|
|
103
117
|
this.hooks.beginFrame.call();
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { __read, __spreadArray } from "tslib";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { stylePropertyMergerFactory, stylePropertyParserFactory } from '../global-module'; // import {
|
|
3
|
+
// StylePropertyMergerFactory,
|
|
4
|
+
// StylePropertyParserFactory,
|
|
5
|
+
// } from '../property-handlers/interfaces';
|
|
6
|
+
|
|
4
7
|
import { parseEasingFunction } from './animation';
|
|
5
8
|
export function convertEffectInput(keyframes, timing, target) {
|
|
6
9
|
var propertySpecificKeyframeGroups = makePropertySpecificKeyframeGroups(keyframes, timing);
|
|
@@ -104,11 +107,11 @@ function makeInterpolations(propertySpecificKeyframeGroups, target) {
|
|
|
104
107
|
|
|
105
108
|
function propertyInterpolation(property, left, right, target) {
|
|
106
109
|
var parsedLeft = left;
|
|
107
|
-
var parsedRight = right;
|
|
108
|
-
|
|
109
|
-
var parser =
|
|
110
|
-
|
|
111
|
-
var merger =
|
|
110
|
+
var parsedRight = right; // const parserFactory = globalContainer.get<StylePropertyParserFactory>(StylePropertyParserFactory);
|
|
111
|
+
|
|
112
|
+
var parser = stylePropertyParserFactory[property]; // const mergerFactory = globalContainer.get<StylePropertyMergerFactory>(StylePropertyMergerFactory);
|
|
113
|
+
|
|
114
|
+
var merger = stylePropertyMergerFactory[property]; // if (left == 'initial' || right == 'initial') {
|
|
112
115
|
// if (left == 'initial')
|
|
113
116
|
// left = initialValues[ucProperty];
|
|
114
117
|
// if (right == 'initial')
|
package/lib/Canvas.d.ts
CHANGED
|
@@ -42,6 +42,11 @@ export declare class Canvas extends EventTarget implements ICanvas {
|
|
|
42
42
|
* rAF in auto rendering
|
|
43
43
|
*/
|
|
44
44
|
private frameId?;
|
|
45
|
+
/**
|
|
46
|
+
* cache here since inversify's resolving is very slow
|
|
47
|
+
*/
|
|
48
|
+
private eventService;
|
|
49
|
+
private renderingService;
|
|
45
50
|
constructor(config: CanvasConfig);
|
|
46
51
|
private initRenderingContext;
|
|
47
52
|
private initDefaultCamera;
|
|
@@ -60,6 +65,10 @@ export declare class Canvas extends EventTarget implements ICanvas {
|
|
|
60
65
|
getEventService(): EventService;
|
|
61
66
|
getRenderingService(): RenderingService;
|
|
62
67
|
getRenderingContext(): RenderingContext;
|
|
68
|
+
getStats(): {
|
|
69
|
+
total: number;
|
|
70
|
+
rendered: number;
|
|
71
|
+
};
|
|
63
72
|
getComputedStyle(node: DisplayObject): any;
|
|
64
73
|
destroy(destroyScenegraph?: boolean): void;
|
|
65
74
|
/**
|
package/lib/Canvas.js
CHANGED
|
@@ -163,17 +163,21 @@ function (_super) {
|
|
|
163
163
|
};
|
|
164
164
|
|
|
165
165
|
Canvas.prototype.getEventService = function () {
|
|
166
|
-
return this.
|
|
166
|
+
return this.eventService;
|
|
167
167
|
};
|
|
168
168
|
|
|
169
169
|
Canvas.prototype.getRenderingService = function () {
|
|
170
|
-
return this.
|
|
170
|
+
return this.renderingService;
|
|
171
171
|
};
|
|
172
172
|
|
|
173
173
|
Canvas.prototype.getRenderingContext = function () {
|
|
174
174
|
return this.container.get(_RenderingContext.RenderingContext);
|
|
175
175
|
};
|
|
176
176
|
|
|
177
|
+
Canvas.prototype.getStats = function () {
|
|
178
|
+
return this.getRenderingService().getStats();
|
|
179
|
+
};
|
|
180
|
+
|
|
177
181
|
Canvas.prototype.getComputedStyle = function (node) {
|
|
178
182
|
return node.parsedStyle;
|
|
179
183
|
};
|
|
@@ -296,9 +300,10 @@ function (_super) {
|
|
|
296
300
|
this.loadRendererContainerModule(renderer); // init context
|
|
297
301
|
|
|
298
302
|
var contextService = this.container.get(_services.ContextService);
|
|
299
|
-
|
|
303
|
+
this.renderingService = this.container.get(_RenderingService.RenderingService);
|
|
304
|
+
this.eventService = this.container.get(_EventService.EventService);
|
|
300
305
|
contextService.init();
|
|
301
|
-
renderingService.init().then(function () {
|
|
306
|
+
this.renderingService.init().then(function () {
|
|
302
307
|
_this.emit(CanvasEvent.READY, {});
|
|
303
308
|
});
|
|
304
309
|
|
|
@@ -4,7 +4,6 @@ import type { Animation } from '../dom/Animation';
|
|
|
4
4
|
import { Element } from '../dom/Element';
|
|
5
5
|
import type { DisplayObjectConfig, IChildNode } from '../dom/interfaces';
|
|
6
6
|
import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
|
|
7
|
-
import type { StylePropertyParser, StylePropertyUpdater } from '../property-handlers';
|
|
8
7
|
/**
|
|
9
8
|
* prototype chains: DisplayObject -> Element -> Node -> EventTarget
|
|
10
9
|
*
|
|
@@ -32,8 +31,6 @@ export declare class DisplayObject<StyleProps extends BaseStyleProps = any, Pars
|
|
|
32
31
|
* push to active animations after calling `animate()`
|
|
33
32
|
*/
|
|
34
33
|
private activeAnimations;
|
|
35
|
-
stylePropertyUpdaterFactory: <Key extends keyof StyleProps>(stylePropertyName: Key) => StylePropertyUpdater<any>[];
|
|
36
|
-
stylePropertyParserFactory: <Key extends keyof ParsedStyleProps>(stylePropertyName: Key) => StylePropertyParser<any, any>;
|
|
37
34
|
constructor(config: DisplayObjectConfig<StyleProps>);
|
|
38
35
|
destroy(): void;
|
|
39
36
|
cloneNode(deep?: boolean): this;
|
|
@@ -23,12 +23,12 @@ var _types = require("../types");
|
|
|
23
23
|
|
|
24
24
|
var _utils = require("../utils");
|
|
25
25
|
|
|
26
|
-
var _propertyHandlers = require("../property-handlers");
|
|
27
|
-
|
|
28
26
|
var _globalModule = require("../global-module");
|
|
29
27
|
|
|
30
28
|
var _services = require("../services");
|
|
31
29
|
|
|
30
|
+
// import type { StylePropertyParser, StylePropertyUpdater } from '../property-handlers';
|
|
31
|
+
// import { StylePropertyParserFactory, StylePropertyUpdaterFactory } from '../property-handlers';
|
|
32
32
|
var DEFAULT_STYLE_PROPS = {
|
|
33
33
|
anchor: [0, 0, 0],
|
|
34
34
|
origin: [0, 0, 0],
|
|
@@ -58,7 +58,12 @@ var DEFAULT_STYLE_PROPS = {
|
|
|
58
58
|
var DisplayObject =
|
|
59
59
|
/** @class */
|
|
60
60
|
function (_super) {
|
|
61
|
-
(0, _tslib.__extends)(DisplayObject, _super);
|
|
61
|
+
(0, _tslib.__extends)(DisplayObject, _super); // stylePropertyUpdaterFactory = globalContainer.get<
|
|
62
|
+
// <Key extends keyof StyleProps>(stylePropertyName: Key) => StylePropertyUpdater<any>[]
|
|
63
|
+
// >(StylePropertyUpdaterFactory);
|
|
64
|
+
// stylePropertyParserFactory = globalContainer.get<
|
|
65
|
+
// <Key extends keyof ParsedStyleProps>(stylePropertyName: Key) => StylePropertyParser<any, any>
|
|
66
|
+
// >(StylePropertyParserFactory);
|
|
62
67
|
|
|
63
68
|
function DisplayObject(config) {
|
|
64
69
|
var _a, _b, _c;
|
|
@@ -69,9 +74,7 @@ function (_super) {
|
|
|
69
74
|
*/
|
|
70
75
|
|
|
71
76
|
|
|
72
|
-
_this.activeAnimations = [];
|
|
73
|
-
_this.stylePropertyUpdaterFactory = _globalModule.globalContainer.get(_propertyHandlers.StylePropertyUpdaterFactory);
|
|
74
|
-
_this.stylePropertyParserFactory = _globalModule.globalContainer.get(_propertyHandlers.StylePropertyParserFactory); // assign name, id to config
|
|
77
|
+
_this.activeAnimations = []; // assign name, id to config
|
|
75
78
|
// eg. group.get('name')
|
|
76
79
|
|
|
77
80
|
_this.config = config; // compatible with G 3.0
|
|
@@ -199,7 +202,8 @@ function (_super) {
|
|
|
199
202
|
|
|
200
203
|
|
|
201
204
|
DisplayObject.prototype.parseStyleProperty = function (name, value) {
|
|
202
|
-
|
|
205
|
+
// const stylePropertyParser = this.stylePropertyParserFactory(name);
|
|
206
|
+
var stylePropertyParser = _globalModule.stylePropertyParserFactory[name];
|
|
203
207
|
|
|
204
208
|
if (stylePropertyParser) {
|
|
205
209
|
// @ts-ignore
|
|
@@ -212,9 +216,10 @@ function (_super) {
|
|
|
212
216
|
DisplayObject.prototype.updateStyleProperty = function (name, oldParsedValue, newParsedValue) {
|
|
213
217
|
var _this = this; // update property, which may cause AABB re-calc
|
|
214
218
|
// @ts-ignore
|
|
219
|
+
// const stylePropertyUpdaters = this.stylePropertyUpdaterFactory(name);
|
|
215
220
|
|
|
216
221
|
|
|
217
|
-
var stylePropertyUpdaters =
|
|
222
|
+
var stylePropertyUpdaters = _globalModule.stylePropertyUpdaterFactory[name];
|
|
218
223
|
|
|
219
224
|
if (stylePropertyUpdaters) {
|
|
220
225
|
stylePropertyUpdaters.forEach(function (updater) {
|
package/lib/global-module.d.ts
CHANGED
|
@@ -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;
|