@visactor/vrender-core 1.1.0-alpha.2 → 1.1.0-alpha.21
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/cjs/common/diff.js +1 -2
- package/cjs/common/event-transformer.js +2 -1
- package/cjs/common/rect-utils.js +1 -1
- package/cjs/common/render-area.js +1 -1
- package/cjs/common/render-command-list.js +1 -1
- package/cjs/common/render-curve.js +1 -1
- package/cjs/common/render-utils.js +1 -1
- package/cjs/common/seg-context.js +1 -2
- package/cjs/common/simplify.js +1 -1
- package/cjs/common/sort.js +1 -1
- package/cjs/common/split-path.js +1 -1
- package/cjs/common/store.js +1 -1
- package/cjs/common/text.js +1 -1
- package/cjs/common/utils.js +1 -1
- package/cjs/core/camera.js +1 -1
- package/cjs/core/constants.js +1 -1
- package/cjs/core/core-modules.js +1 -1
- package/cjs/core/global-module.js +2 -0
- package/cjs/core/global.js +1 -1
- package/cjs/core/graphic-utils.js +1 -1
- package/cjs/core/index.js +1 -1
- package/cjs/core/layer-service.js +2 -1
- package/cjs/core/layer.js +1 -1
- package/cjs/core/light.js +1 -1
- package/cjs/core/stage.d.ts +4 -1
- package/cjs/core/stage.js +24 -12
- package/cjs/core/stage.js.map +1 -1
- package/cjs/core/window.js +1 -1
- package/cjs/graphic/graphic-service/graphic-service.d.ts +4 -0
- package/cjs/graphic/graphic-service/graphic-service.js +6 -5
- package/cjs/graphic/graphic-service/graphic-service.js.map +1 -1
- package/cjs/graphic/graphic.d.ts +73 -11
- package/cjs/graphic/graphic.js +516 -157
- package/cjs/graphic/graphic.js.map +1 -1
- package/cjs/graphic/group.d.ts +5 -1
- package/cjs/graphic/group.js +37 -18
- package/cjs/graphic/group.js.map +1 -1
- package/cjs/graphic/rect.d.ts +2 -0
- package/cjs/graphic/rect.js +44 -0
- package/cjs/graphic/rect.js.map +1 -1
- package/cjs/graphic/state/shared-state-refresh.js +4 -3
- package/cjs/graphic/state/shared-state-refresh.js.map +1 -1
- package/cjs/graphic/state/shared-state-scope.js +1 -1
- package/cjs/graphic/state/shared-state-scope.js.map +1 -1
- package/cjs/graphic/state/state-engine.js +2 -2
- package/cjs/graphic/state/state-engine.js.map +1 -1
- package/cjs/graphic/state/state-perf-monitor.d.ts +1 -0
- package/cjs/graphic/state/state-perf-monitor.js +9 -2
- package/cjs/graphic/state/state-perf-monitor.js.map +1 -1
- package/cjs/graphic/state/state-style-resolver.d.ts +0 -9
- package/cjs/graphic/state/state-style-resolver.js +0 -23
- package/cjs/graphic/state/state-style-resolver.js.map +1 -1
- package/cjs/graphic/state/state-transition-orchestrator.d.ts +5 -0
- package/cjs/graphic/state/state-transition-orchestrator.js +17 -5
- package/cjs/graphic/state/state-transition-orchestrator.js.map +1 -1
- package/cjs/interface/animation/animate.d.ts +1 -0
- package/cjs/interface/animation/animate.js.map +1 -1
- package/cjs/interface/graphic.d.ts +9 -0
- package/cjs/interface/graphic.js.map +1 -1
- package/cjs/interface/node-tree.js.map +1 -1
- package/cjs/plugins/builtin-plugin/dirty-bounds-plugin.d.ts +4 -1
- package/cjs/plugins/builtin-plugin/dirty-bounds-plugin.js +20 -10
- package/cjs/plugins/builtin-plugin/dirty-bounds-plugin.js.map +1 -1
- package/cjs/plugins/builtin-plugin/flex-layout-plugin.js +3 -2
- package/cjs/plugins/builtin-plugin/flex-layout-plugin.js.map +1 -1
- package/cjs/render/contributions/render/base-render.js +8 -7
- package/cjs/render/contributions/render/base-render.js.map +1 -1
- package/dist/index.es.js +1150 -279
- package/es/common/diff.js +1 -2
- package/es/common/event-transformer.js +2 -1
- package/es/common/rect-utils.js +1 -1
- package/es/common/render-area.js +1 -1
- package/es/common/render-command-list.js +1 -1
- package/es/common/render-curve.js +1 -1
- package/es/common/render-utils.js +1 -1
- package/es/common/seg-context.js +1 -2
- package/es/common/simplify.js +1 -1
- package/es/common/sort.js +1 -1
- package/es/common/split-path.js +1 -1
- package/es/common/store.js +1 -1
- package/es/common/text.js +1 -1
- package/es/common/utils.js +1 -1
- package/es/core/camera.js +1 -1
- package/es/core/constants.js +1 -1
- package/es/core/core-modules.js +1 -1
- package/es/core/global-module.js +2 -0
- package/es/core/global.js +1 -1
- package/es/core/graphic-utils.js +1 -1
- package/es/core/index.js +1 -1
- package/es/core/layer-service.js +2 -1
- package/es/core/layer.js +1 -1
- package/es/core/light.js +1 -1
- package/es/core/stage.d.ts +4 -1
- package/es/core/stage.js +22 -11
- package/es/core/stage.js.map +1 -1
- package/es/core/window.js +1 -1
- package/es/graphic/graphic-service/graphic-service.d.ts +4 -0
- package/es/graphic/graphic-service/graphic-service.js +6 -5
- package/es/graphic/graphic-service/graphic-service.js.map +1 -1
- package/es/graphic/graphic.d.ts +73 -11
- package/es/graphic/graphic.js +511 -150
- package/es/graphic/graphic.js.map +1 -1
- package/es/graphic/group.d.ts +5 -1
- package/es/graphic/group.js +36 -18
- package/es/graphic/group.js.map +1 -1
- package/es/graphic/rect.d.ts +2 -0
- package/es/graphic/rect.js +44 -0
- package/es/graphic/rect.js.map +1 -1
- package/es/graphic/state/shared-state-refresh.js +5 -4
- package/es/graphic/state/shared-state-refresh.js.map +1 -1
- package/es/graphic/state/shared-state-scope.js +2 -2
- package/es/graphic/state/shared-state-scope.js.map +1 -1
- package/es/graphic/state/state-engine.js +3 -3
- package/es/graphic/state/state-engine.js.map +1 -1
- package/es/graphic/state/state-perf-monitor.d.ts +1 -0
- package/es/graphic/state/state-perf-monitor.js +7 -0
- package/es/graphic/state/state-perf-monitor.js.map +1 -1
- package/es/graphic/state/state-style-resolver.d.ts +0 -9
- package/es/graphic/state/state-style-resolver.js +0 -23
- package/es/graphic/state/state-style-resolver.js.map +1 -1
- package/es/graphic/state/state-transition-orchestrator.d.ts +5 -0
- package/es/graphic/state/state-transition-orchestrator.js +17 -5
- package/es/graphic/state/state-transition-orchestrator.js.map +1 -1
- package/es/interface/animation/animate.d.ts +1 -0
- package/es/interface/animation/animate.js.map +1 -1
- package/es/interface/graphic.d.ts +9 -0
- package/es/interface/graphic.js.map +1 -1
- package/es/interface/node-tree.js.map +1 -1
- package/es/plugins/builtin-plugin/dirty-bounds-plugin.d.ts +4 -1
- package/es/plugins/builtin-plugin/dirty-bounds-plugin.js +20 -10
- package/es/plugins/builtin-plugin/dirty-bounds-plugin.js.map +1 -1
- package/es/plugins/builtin-plugin/flex-layout-plugin.js +3 -2
- package/es/plugins/builtin-plugin/flex-layout-plugin.js.map +1 -1
- package/es/render/contributions/render/base-render.js +8 -6
- package/es/render/contributions/render/base-render.js.map +1 -1
- package/package.json +3 -3
package/cjs/graphic/graphic.js
CHANGED
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: !0
|
|
5
|
-
}), exports.Graphic = exports.NOWORK_ANIMATE_ATTR = exports.
|
|
5
|
+
}), exports.Graphic = exports.NOWORK_ANIMATE_ATTR = exports.GRAPHIC_UPDATE_TAG_KEY = exports.PURE_STYLE_KEY = void 0;
|
|
6
6
|
|
|
7
7
|
const vutils_1 = require("@visactor/vutils"), node_tree_1 = require("./node-tree"), event_1 = require("../event"), config_1 = require("./config"), application_1 = require("../application"), custom_path2d_1 = require("../common/custom-path2d"), loader_1 = require("../resource-loader/loader"), enums_1 = require("../common/enums"), bounds_context_1 = require("../common/bounds-context"), render_command_list_1 = require("../common/render-command-list"), utils_1 = require("../common/utils"), builtin_symbol_1 = require("./builtin-symbol"), xml_1 = require("../common/xml"), constants_1 = require("./constants"), config_2 = require("../animate/config"), canvas_1 = require("../canvas"), state_definition_compiler_1 = require("./state/state-definition-compiler"), state_engine_1 = require("./state/state-engine"), state_model_1 = require("./state/state-model"), attribute_update_classifier_1 = require("./state/attribute-update-classifier"), state_style_resolver_1 = require("./state/state-style-resolver"), state_transition_orchestrator_1 = require("./state/state-transition-orchestrator"), shared_state_scope_1 = require("./state/shared-state-scope"), shared_state_refresh_1 = require("./state/shared-state-refresh"), state_perf_monitor_1 = require("./state/state-perf-monitor"), _tempBounds = new vutils_1.AABBBounds, loadShadowRootFactory = () => require("./shadow-root"), tempMatrix = new vutils_1.Matrix;
|
|
8
8
|
|
|
9
9
|
exports.PURE_STYLE_KEY = [ "stroke", "opacity", "strokeOpacity", "lineDash", "lineDashOffset", "lineCap", "lineJoin", "miterLimit", "fill", "fillOpacity" ],
|
|
10
10
|
exports.GRAPHIC_UPDATE_TAG_KEY = [ "lineWidth", "scaleX", "scaleY", "angle", "anchor", "visible" ];
|
|
11
11
|
|
|
12
|
-
const tempConstantXYKey = [ "x", "y" ], tempConstantScaleXYKey = [ "scaleX", "scaleY" ], tempConstantAngleKey = [ "angle" ], builtinTextureTypes = new Set([ "circle", "diamond", "rect", "vertical-line", "horizontal-line", "bias-lr", "bias-rl", "grid", "wave" ]), point = new vutils_1.Point;
|
|
12
|
+
const tempConstantXYKey = [ "x", "y" ], tempConstantScaleXYKey = [ "scaleX", "scaleY" ], tempConstantAngleKey = [ "angle" ], builtinTextureTypes = new Set([ "circle", "diamond", "rect", "vertical-line", "horizontal-line", "bias-lr", "bias-rl", "grid", "wave" ]), FULL_STATE_DEFINITION_KEYS = new Set([ "name", "patch", "priority", "exclude", "suppress", "resolver", "declaredAffectedKeys" ]), point = new vutils_1.Point, EMPTY_STATE_NAMES = [], BROAD_UPDATE_CATEGORY = attribute_update_classifier_1.UpdateCategory.PAINT | attribute_update_classifier_1.UpdateCategory.SHAPE | attribute_update_classifier_1.UpdateCategory.BOUNDS | attribute_update_classifier_1.UpdateCategory.TRANSFORM | attribute_update_classifier_1.UpdateCategory.LAYOUT;
|
|
13
13
|
|
|
14
14
|
function isPlainObjectValue(value) {
|
|
15
|
-
return "object" == typeof value && null != value && !
|
|
15
|
+
return "object" == typeof value && null != value && !Array.isArray(value);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
function cloneAttributeValue(value) {
|
|
@@ -24,14 +24,6 @@ function cloneAttributeValue(value) {
|
|
|
24
24
|
})), clone;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
function cloneSimpleAttributeRecord(value) {
|
|
28
|
-
return isPlainObjectValue(value) ? Object.assign({}, value) : value;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function shouldUseSimpleAttributeFastPath(value) {
|
|
32
|
-
return !!isPlainObjectValue(value) && !Object.keys(value).some((key => isPlainObjectValue(value[key])));
|
|
33
|
-
}
|
|
34
|
-
|
|
35
27
|
function cloneAttributeSurface(value) {
|
|
36
28
|
if (!isPlainObjectValue(value)) return value;
|
|
37
29
|
const source = value, clone = {};
|
|
@@ -41,6 +33,11 @@ function cloneAttributeSurface(value) {
|
|
|
41
33
|
})), clone;
|
|
42
34
|
}
|
|
43
35
|
|
|
36
|
+
function areAttributeValuesEqual(left, right) {
|
|
37
|
+
return left === right || !!(isPlainObjectValue(left) || isPlainObjectValue(right) || Array.isArray(left) || Array.isArray(right)) && (0,
|
|
38
|
+
vutils_1.isEqual)(left, right);
|
|
39
|
+
}
|
|
40
|
+
|
|
44
41
|
function deepMergeAttributeValue(base, value) {
|
|
45
42
|
var _a;
|
|
46
43
|
const result = null !== (_a = cloneAttributeValue(base)) && void 0 !== _a ? _a : {};
|
|
@@ -50,7 +47,7 @@ function deepMergeAttributeValue(base, value) {
|
|
|
50
47
|
})), result;
|
|
51
48
|
}
|
|
52
49
|
|
|
53
|
-
exports.
|
|
50
|
+
exports.NOWORK_ANIMATE_ATTR = {
|
|
54
51
|
strokeSeg: 1,
|
|
55
52
|
boundsPadding: 2,
|
|
56
53
|
pickMode: 1,
|
|
@@ -104,19 +101,28 @@ class Graphic extends node_tree_1.Node {
|
|
|
104
101
|
get globalTransMatrix() {
|
|
105
102
|
return this.tryUpdateGlobalTransMatrix(!0);
|
|
106
103
|
}
|
|
104
|
+
get baseAttributes() {
|
|
105
|
+
var _a;
|
|
106
|
+
return null !== (_a = this._baseAttributes) && void 0 !== _a ? _a : this.attribute;
|
|
107
|
+
}
|
|
108
|
+
set baseAttributes(value) {
|
|
109
|
+
value !== this.attribute ? this._baseAttributes = value : this._baseAttributes = void 0;
|
|
110
|
+
}
|
|
107
111
|
constructor(params = {}) {
|
|
108
112
|
var _a;
|
|
109
|
-
super(), this.
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
113
|
+
super(), this._AABBBounds = new vutils_1.AABBBounds, this._updateTag = enums_1.UpdateTag.INIT,
|
|
114
|
+
this.attribute = params, this.valid = this.isValid(), this.updateAABBBoundsStamp = 0,
|
|
115
|
+
params.background && this.loadImage(null !== (_a = params.background.background) && void 0 !== _a ? _a : params.background, !0),
|
|
116
|
+
params.texture && isExternalTexture(params.texture) && this.loadImage(params.texture, !1),
|
|
117
|
+
params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic);
|
|
114
118
|
}
|
|
115
119
|
get normalAttrs() {
|
|
116
120
|
return this.baseAttributes;
|
|
117
121
|
}
|
|
118
|
-
set normalAttrs(
|
|
119
|
-
|
|
122
|
+
set normalAttrs(_value) {}
|
|
123
|
+
getBaseAttributesStorage() {
|
|
124
|
+
var _a;
|
|
125
|
+
return null !== (_a = this._baseAttributes) && void 0 !== _a ? _a : this.attribute;
|
|
120
126
|
}
|
|
121
127
|
getGraphicService() {
|
|
122
128
|
var _a, _b;
|
|
@@ -155,11 +161,18 @@ class Graphic extends node_tree_1.Node {
|
|
|
155
161
|
markDirty && (null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) && this.markSharedStateDirty(),
|
|
156
162
|
!0);
|
|
157
163
|
}
|
|
158
|
-
|
|
164
|
+
syncSharedStateScopeBindingOnTreeChange(markDirty = !0) {
|
|
159
165
|
var _a, _b;
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
166
|
+
return !!((null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) || this.boundSharedStateScope || (null === (_b = this.registeredActiveScopes) || void 0 === _b ? void 0 : _b.size) || this.sharedStateDirty) && this.syncSharedStateScopeBindingFromTree(markDirty);
|
|
167
|
+
}
|
|
168
|
+
syncSharedStateActiveRegistrations() {
|
|
169
|
+
var _a;
|
|
170
|
+
const previousScopes = this.registeredActiveScopes;
|
|
171
|
+
if (!(null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) || !this.boundSharedStateScope) return (null == previousScopes ? void 0 : previousScopes.size) && (previousScopes.forEach((scope => {
|
|
172
|
+
scope.subtreeActiveDescendants.delete(this);
|
|
173
|
+
})), previousScopes.clear()), void (this.registeredActiveScopes = void 0);
|
|
174
|
+
const nextScopes = new Set((0, shared_state_scope_1.collectSharedStateScopeChain)(this.boundSharedStateScope));
|
|
175
|
+
null == previousScopes || previousScopes.forEach((scope => {
|
|
163
176
|
nextScopes.has(scope) || scope.subtreeActiveDescendants.delete(this);
|
|
164
177
|
})), nextScopes.forEach((scope => {
|
|
165
178
|
scope.subtreeActiveDescendants.add(this);
|
|
@@ -176,7 +189,7 @@ class Graphic extends node_tree_1.Node {
|
|
|
176
189
|
(0, shared_state_refresh_1.scheduleStageSharedStateRefresh)(this.stage);
|
|
177
190
|
}
|
|
178
191
|
onParentSharedStateTreeChanged(stage, layer) {
|
|
179
|
-
this.stage === stage && this.layer === layer ? this.
|
|
192
|
+
this.stage === stage && this.layer === layer ? this.syncSharedStateScopeBindingOnTreeChange() : this.setStage(stage, layer);
|
|
180
193
|
}
|
|
181
194
|
refreshSharedStateBeforeRender() {
|
|
182
195
|
var _a;
|
|
@@ -184,9 +197,7 @@ class Graphic extends node_tree_1.Node {
|
|
|
184
197
|
this.boundSharedStateScope && (0, shared_state_scope_1.ensureSharedStateScopeFresh)(this.boundSharedStateScope),
|
|
185
198
|
this.recomputeCurrentStatePatch(), this.stopStateAnimates(), this._restoreAttributeFromStaticTruth({
|
|
186
199
|
type: enums_1.AttributeUpdateType.STATE
|
|
187
|
-
}), this.
|
|
188
|
-
type: enums_1.AttributeUpdateType.STATE
|
|
189
|
-
}), this.sharedStateDirty = !1) : this.sharedStateDirty = !1;
|
|
200
|
+
}), this.emitStateUpdateEvent(), this.sharedStateDirty = !1) : this.sharedStateDirty = !1;
|
|
190
201
|
}
|
|
191
202
|
getLocalStatesVersion() {
|
|
192
203
|
var _a, _b;
|
|
@@ -237,14 +248,12 @@ class Graphic extends node_tree_1.Node {
|
|
|
237
248
|
};
|
|
238
249
|
}
|
|
239
250
|
recomputeCurrentStatePatch() {
|
|
240
|
-
var _a, _b
|
|
251
|
+
var _a, _b;
|
|
241
252
|
if (!(null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length)) return this.effectiveStates = [],
|
|
242
253
|
this.resolvedStatePatch = void 0, void this.syncSharedStateActiveRegistrations();
|
|
243
|
-
const stateResolveBaseAttrs = null !== (_b =
|
|
244
|
-
null === (_c = this.stateEngine) || void 0 === _c || _c.setResolveContext(this, stateResolveBaseAttrs);
|
|
245
|
-
const transition = stateModel.useStates(this.currentStates), effectiveStates = null !== (_d = transition.effectiveStates) && void 0 !== _d ? _d : transition.states, resolvedStateAttrs = this.stateEngine && this.compiledStateDefinitions ? Object.assign({}, this.stateEngine.resolvedPatch) : this.getStateStyleResolver(this.stateMergeMode).resolve(stateResolveBaseAttrs, this.states, this.stateProxy, transition.states, this.stateSort);
|
|
254
|
+
const stateResolveBaseAttrs = this.getStateResolveBaseAttrs(), transition = this.createStateModel(stateResolveBaseAttrs).useStates(this.currentStates), effectiveStates = null !== (_b = transition.effectiveStates) && void 0 !== _b ? _b : transition.states, resolvedStateAttrs = this.stateEngine && this.compiledStateDefinitions ? Object.assign({}, this.stateEngine.resolvedPatch) : this.getStateStyleResolver(this.stateMergeMode).resolve(stateResolveBaseAttrs, this.states, this.stateProxy, transition.states, this.stateSort);
|
|
246
255
|
this.currentStates = transition.states, this.effectiveStates = [ ...effectiveStates ],
|
|
247
|
-
this.resolvedStatePatch =
|
|
256
|
+
this.resolvedStatePatch = resolvedStateAttrs, this.syncSharedStateActiveRegistrations();
|
|
248
257
|
}
|
|
249
258
|
buildStaticAttributeSnapshot() {
|
|
250
259
|
var _a;
|
|
@@ -254,6 +263,22 @@ class Graphic extends node_tree_1.Node {
|
|
|
254
263
|
"deep" === this.stateMergeMode && isPlainObjectValue(previousValue) && isPlainObjectValue(nextValue) ? snapshot[key] = deepMergeAttributeValue(previousValue, nextValue) : snapshot[key] = cloneAttributeValue(nextValue);
|
|
255
264
|
})), snapshot) : snapshot;
|
|
256
265
|
}
|
|
266
|
+
buildRemovedStateAnimationAttrs(targetStateAttrs, previousResolvedStatePatch) {
|
|
267
|
+
const extraAttrs = {};
|
|
268
|
+
if (!previousResolvedStatePatch) return extraAttrs;
|
|
269
|
+
const snapshot = this.buildStaticAttributeSnapshot(), staticTargetAttrs = snapshot;
|
|
270
|
+
return Object.keys(previousResolvedStatePatch).forEach((key => {
|
|
271
|
+
const hasTargetAttr = Object.prototype.hasOwnProperty.call(targetStateAttrs, key);
|
|
272
|
+
if (hasTargetAttr && void 0 !== targetStateAttrs[key]) return;
|
|
273
|
+
const assignFallbackAttr = value => {
|
|
274
|
+
void 0 === value && this.shouldSkipStateTransitionDefaultAttribute(key, staticTargetAttrs) || (extraAttrs[key] = void 0 === value ? value : cloneAttributeValue(value));
|
|
275
|
+
};
|
|
276
|
+
if (hasTargetAttr) assignFallbackAttr(this.getStateTransitionDefaultAttribute(key, staticTargetAttrs)); else if (Object.prototype.hasOwnProperty.call(snapshot, key)) {
|
|
277
|
+
const snapshotValue = snapshot[key];
|
|
278
|
+
assignFallbackAttr(void 0 === snapshotValue ? this.getStateTransitionDefaultAttribute(key, staticTargetAttrs) : snapshotValue);
|
|
279
|
+
} else assignFallbackAttr(this.getStateTransitionDefaultAttribute(key, staticTargetAttrs));
|
|
280
|
+
})), extraAttrs;
|
|
281
|
+
}
|
|
257
282
|
syncObjectToSnapshot(target, snapshot) {
|
|
258
283
|
const delta = new Map;
|
|
259
284
|
return new Set([ ...Object.keys(target), ...Object.keys(snapshot) ]).forEach((key => {
|
|
@@ -263,15 +288,17 @@ class Graphic extends node_tree_1.Node {
|
|
|
263
288
|
next: void 0
|
|
264
289
|
}), delete target[key]));
|
|
265
290
|
const nextValue = snapshot[key];
|
|
266
|
-
(
|
|
291
|
+
areAttributeValuesEqual(previousValue, nextValue) || (delta.set(key, {
|
|
267
292
|
prev: previousValue,
|
|
268
293
|
next: nextValue
|
|
269
294
|
}), target[key] = cloneAttributeValue(nextValue));
|
|
270
295
|
})), delta;
|
|
271
296
|
}
|
|
272
297
|
_syncAttribute() {
|
|
298
|
+
this.attribute === this.baseAttributes && this.resolvedStatePatch && this.detachAttributeFromBaseAttributes();
|
|
273
299
|
const snapshot = this.buildStaticAttributeSnapshot(), delta = this.syncObjectToSnapshot(this.attribute, snapshot);
|
|
274
|
-
return this.valid = this.isValid(),
|
|
300
|
+
return this.valid = this.isValid(), this.attributeMayContainTransientAttrs = !1,
|
|
301
|
+
delta;
|
|
275
302
|
}
|
|
276
303
|
_syncFinalAttributeFromStaticTruth() {
|
|
277
304
|
const target = this.finalAttribute;
|
|
@@ -279,54 +306,155 @@ class Graphic extends node_tree_1.Node {
|
|
|
279
306
|
const snapshot = this.buildStaticAttributeSnapshot();
|
|
280
307
|
this.syncObjectToSnapshot(target, snapshot);
|
|
281
308
|
}
|
|
282
|
-
|
|
309
|
+
mergeAttributeDeltaCategory(category, key, prev, next) {
|
|
310
|
+
var _a;
|
|
311
|
+
let nextCategory = "stroke" === key || "shadowBlur" === key ? (0, attribute_update_classifier_1.classifyAttributeDelta)(key, prev, next) : null !== (_a = attribute_update_classifier_1.ATTRIBUTE_CATEGORY[key]) && void 0 !== _a ? _a : attribute_update_classifier_1.UpdateCategory.PAINT;
|
|
312
|
+
return nextCategory & attribute_update_classifier_1.UpdateCategory.PICK && (nextCategory |= attribute_update_classifier_1.UpdateCategory.BOUNDS),
|
|
313
|
+
nextCategory === attribute_update_classifier_1.UpdateCategory.PAINT && this.needUpdateTag(key) && (nextCategory = attribute_update_classifier_1.UpdateCategory.SHAPE | attribute_update_classifier_1.UpdateCategory.BOUNDS),
|
|
314
|
+
category | nextCategory;
|
|
315
|
+
}
|
|
316
|
+
submitUpdateByCategory(category, forceUpdateTag = !1) {
|
|
283
317
|
var _a;
|
|
284
318
|
if (forceUpdateTag) return this.addUpdateShapeAndBoundsTag(), this.addUpdatePositionTag(),
|
|
285
319
|
void this.addUpdateLayoutTag();
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
category |= nextCategory;
|
|
292
|
-
})), category !== attribute_update_classifier_1.UpdateCategory.NONE && (null === (_a = (0,
|
|
293
|
-
state_perf_monitor_1.getStageStatePerfMonitor)(this.stage)) || void 0 === _a || _a.recordCategory(category)),
|
|
294
|
-
category & attribute_update_classifier_1.UpdateCategory.SHAPE ? this.addUpdateShapeAndBoundsTag() : category & attribute_update_classifier_1.UpdateCategory.BOUNDS && this.addUpdateBoundTag(),
|
|
320
|
+
if (category !== attribute_update_classifier_1.UpdateCategory.NONE) {
|
|
321
|
+
const stage = this.stage;
|
|
322
|
+
stage && (null === (_a = (0, state_perf_monitor_1.getActiveStageStatePerfMonitor)(stage)) || void 0 === _a || _a.recordCategory(category));
|
|
323
|
+
}
|
|
324
|
+
(category & BROAD_UPDATE_CATEGORY) !== BROAD_UPDATE_CATEGORY ? (category & attribute_update_classifier_1.UpdateCategory.SHAPE ? this.addUpdateShapeAndBoundsTag() : category & attribute_update_classifier_1.UpdateCategory.BOUNDS && this.addUpdateBoundTag(),
|
|
295
325
|
category & attribute_update_classifier_1.UpdateCategory.PAINT && this.addUpdatePaintTag(),
|
|
296
326
|
category & attribute_update_classifier_1.UpdateCategory.TRANSFORM && this.addUpdatePositionTag(),
|
|
297
|
-
category & attribute_update_classifier_1.UpdateCategory.LAYOUT && this.addUpdateLayoutTag();
|
|
327
|
+
category & attribute_update_classifier_1.UpdateCategory.LAYOUT && this.addUpdateLayoutTag()) : this.addBroadUpdateTag();
|
|
328
|
+
}
|
|
329
|
+
submitUpdateByDelta(delta, forceUpdateTag = !1) {
|
|
330
|
+
let category = attribute_update_classifier_1.UpdateCategory.NONE;
|
|
331
|
+
delta.forEach(((entry, key) => {
|
|
332
|
+
category = this.mergeAttributeDeltaCategory(category, key, entry.prev, entry.next);
|
|
333
|
+
})), this.submitUpdateByCategory(category, forceUpdateTag);
|
|
334
|
+
}
|
|
335
|
+
submitTouchedKeyUpdate(keys, forceUpdateTag = !1) {
|
|
336
|
+
this.submitTouchedUpdate(forceUpdateTag || this.needUpdateTags(keys));
|
|
337
|
+
}
|
|
338
|
+
submitTouchedUpdate(needsShapeAndBounds) {
|
|
339
|
+
!this.updateShapeAndBoundsTagSetted() && needsShapeAndBounds ? this.addUpdateShapeAndBoundsTag() : this.addUpdateBoundTag(),
|
|
340
|
+
this.addUpdatePositionTag(), this.addUpdateLayoutTag();
|
|
298
341
|
}
|
|
299
342
|
commitBaseAttributeMutation(forceUpdateTag = !1, context) {
|
|
300
|
-
var _a, _b;
|
|
301
|
-
(null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) && (this.resolverEpoch
|
|
302
|
-
null === (
|
|
343
|
+
var _a, _b, _c;
|
|
344
|
+
(null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) && (this.resolverEpoch = (null !== (_b = this.resolverEpoch) && void 0 !== _b ? _b : 0) + 1,
|
|
345
|
+
null === (_c = this.stateEngine) || void 0 === _c || _c.invalidateResolverCache(),
|
|
303
346
|
this.recomputeCurrentStatePatch());
|
|
304
347
|
const delta = this._syncAttribute();
|
|
305
348
|
this.submitUpdateByDelta(delta, forceUpdateTag), this.onAttributeUpdate(context);
|
|
306
349
|
}
|
|
350
|
+
canCommitBaseAttributesByTouchedKeys() {
|
|
351
|
+
var _a, _b;
|
|
352
|
+
return !((null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) || this.resolvedStatePatch || this.attributeMayContainTransientAttrs) && (!(null === (_b = this.animates) || void 0 === _b ? void 0 : _b.size) && !this._animationStateManager || !this.hasAnyTrackedAnimate());
|
|
353
|
+
}
|
|
354
|
+
detachAttributeFromBaseAttributes() {
|
|
355
|
+
this.attribute === this.baseAttributes && (this._baseAttributes = this.attribute,
|
|
356
|
+
this.attribute = cloneAttributeSurface(this.attribute));
|
|
357
|
+
}
|
|
358
|
+
commitInternalBaseAttributes(params, context) {
|
|
359
|
+
params && Object.keys(params).length && (this.canCommitBaseAttributesByTouchedKeys() ? this.commitBaseAttributesByTouchedKeys(params, !1, context) : (this.detachAttributeFromBaseAttributes(),
|
|
360
|
+
this.applyBaseAttributes(params), this.commitBaseAttributeMutation(!1, context)));
|
|
361
|
+
}
|
|
362
|
+
commitBaseAttributesByTouchedKeys(params, forceUpdateTag = !1, context) {
|
|
363
|
+
const source = params, baseAttributes = this.getBaseAttributesStorage();
|
|
364
|
+
let hasKeys = !1, needsShapeAndBounds = forceUpdateTag;
|
|
365
|
+
for (const key in source) Object.prototype.hasOwnProperty.call(source, key) && (hasKeys = !0,
|
|
366
|
+
baseAttributes[key] = source[key], !needsShapeAndBounds && this.needUpdateTag(key) && (needsShapeAndBounds = !0));
|
|
367
|
+
hasKeys && (this.attribute = baseAttributes, this._baseAttributes = void 0, this.valid = this.isValid(),
|
|
368
|
+
this.attributeMayContainTransientAttrs = !1, this.submitTouchedUpdate(needsShapeAndBounds),
|
|
369
|
+
this.onAttributeUpdate(context));
|
|
370
|
+
}
|
|
371
|
+
commitBaseAttributeBySingleKey(key, value, forceUpdateTag = !1, context) {
|
|
372
|
+
this.getBaseAttributesStorage()[key] = value, this.attribute = this.getBaseAttributesStorage(),
|
|
373
|
+
this._baseAttributes = void 0, this.valid = this.isValid(), this.attributeMayContainTransientAttrs = !1,
|
|
374
|
+
this.submitTouchedUpdate(forceUpdateTag || this.needUpdateTag(key)), this.onAttributeUpdate(context);
|
|
375
|
+
}
|
|
307
376
|
applyBaseAttributes(params) {
|
|
308
377
|
const keys = Object.keys(params);
|
|
309
378
|
for (let i = 0; i < keys.length; i++) {
|
|
310
379
|
const key = keys[i];
|
|
311
|
-
this.
|
|
380
|
+
this.getBaseAttributesStorage()[key] = params[key];
|
|
312
381
|
}
|
|
313
382
|
}
|
|
383
|
+
applyAnimationTransientAttributes(params, forceUpdateTag = !1, context) {
|
|
384
|
+
const source = params;
|
|
385
|
+
let target, needsShapeAndBounds = forceUpdateTag;
|
|
386
|
+
for (const key in source) Object.prototype.hasOwnProperty.call(source, key) && (target || (this.detachAttributeFromBaseAttributes(),
|
|
387
|
+
target = this.attribute), target[key] = source[key], !needsShapeAndBounds && this.needUpdateTag(key) && (needsShapeAndBounds = !0));
|
|
388
|
+
target && (this.attributeMayContainTransientAttrs = !0, this.valid = this.isValid(),
|
|
389
|
+
this.submitTouchedUpdate(needsShapeAndBounds), this.onAttributeUpdate(context));
|
|
390
|
+
}
|
|
314
391
|
applyTransientAttributes(params, forceUpdateTag = !1, context) {
|
|
392
|
+
this.detachAttributeFromBaseAttributes();
|
|
315
393
|
const delta = new Map, keys = Object.keys(params);
|
|
316
394
|
for (let i = 0; i < keys.length; i++) {
|
|
317
395
|
const key = keys[i], previousValue = this.attribute[key], nextValue = params[key];
|
|
318
|
-
(
|
|
396
|
+
areAttributeValuesEqual(previousValue, nextValue) || (delta.set(key, {
|
|
319
397
|
prev: previousValue,
|
|
320
398
|
next: nextValue
|
|
321
|
-
}), this.attribute[key] =
|
|
399
|
+
}), this.attribute[key] = nextValue);
|
|
322
400
|
}
|
|
323
|
-
this.
|
|
401
|
+
delta.size && (this.attributeMayContainTransientAttrs = !0), this.valid = this.isValid(),
|
|
402
|
+
this.submitUpdateByDelta(delta, forceUpdateTag), this.onAttributeUpdate(context);
|
|
324
403
|
}
|
|
325
404
|
_restoreAttributeFromStaticTruth(context) {
|
|
326
405
|
this._syncFinalAttributeFromStaticTruth();
|
|
327
406
|
const delta = this._syncAttribute();
|
|
328
407
|
this.submitUpdateByDelta(delta), this.onAttributeUpdate(context);
|
|
329
408
|
}
|
|
409
|
+
collectStatePatchDeltaKeys(previousPatch, nextPatch) {
|
|
410
|
+
const keys = previousPatch ? Object.keys(previousPatch) : [];
|
|
411
|
+
if (!nextPatch) return keys;
|
|
412
|
+
for (const key in nextPatch) Object.prototype.hasOwnProperty.call(nextPatch, key) && !Object.prototype.hasOwnProperty.call(null != previousPatch ? previousPatch : {}, key) && keys.push(key);
|
|
413
|
+
return keys;
|
|
414
|
+
}
|
|
415
|
+
getStaticTruthValueForStateKey(key, nextPatch) {
|
|
416
|
+
var _a;
|
|
417
|
+
const baseAttributes = null !== (_a = this.baseAttributes) && void 0 !== _a ? _a : {}, patch = nextPatch;
|
|
418
|
+
if (patch && Object.prototype.hasOwnProperty.call(patch, key)) {
|
|
419
|
+
const patchValue = patch[key], baseValue = baseAttributes[key];
|
|
420
|
+
return "deep" === this.stateMergeMode && isPlainObjectValue(baseValue) && isPlainObjectValue(patchValue) ? {
|
|
421
|
+
hasValue: !0,
|
|
422
|
+
value: deepMergeAttributeValue(baseValue, patchValue)
|
|
423
|
+
} : {
|
|
424
|
+
hasValue: !0,
|
|
425
|
+
value: patchValue
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
return Object.prototype.hasOwnProperty.call(baseAttributes, key) ? {
|
|
429
|
+
hasValue: !0,
|
|
430
|
+
value: baseAttributes[key]
|
|
431
|
+
} : {
|
|
432
|
+
hasValue: !1,
|
|
433
|
+
value: void 0
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
syncStatePatchDeltaToTarget(target, keys, nextPatch, collectCategory = !1) {
|
|
437
|
+
let category = attribute_update_classifier_1.UpdateCategory.NONE;
|
|
438
|
+
for (let i = 0; i < keys.length; i++) {
|
|
439
|
+
const key = keys[i], previousValue = target[key], next = this.getStaticTruthValueForStateKey(key, nextPatch);
|
|
440
|
+
if (!next.hasValue) {
|
|
441
|
+
Object.prototype.hasOwnProperty.call(target, key) && (delete target[key], collectCategory && (category = this.mergeAttributeDeltaCategory(category, key, previousValue, void 0)));
|
|
442
|
+
continue;
|
|
443
|
+
}
|
|
444
|
+
if (areAttributeValuesEqual(previousValue, next.value)) continue;
|
|
445
|
+
const nextValue = cloneAttributeValue(next.value);
|
|
446
|
+
target[key] = nextValue, collectCategory && (category = this.mergeAttributeDeltaCategory(category, key, previousValue, nextValue));
|
|
447
|
+
}
|
|
448
|
+
return category;
|
|
449
|
+
}
|
|
450
|
+
restoreAttributeFromStatePatchDelta(previousPatch, nextPatch, context) {
|
|
451
|
+
this.detachAttributeFromBaseAttributes();
|
|
452
|
+
const keys = this.collectStatePatchDeltaKeys(previousPatch, nextPatch), finalAttribute = this.finalAttribute;
|
|
453
|
+
finalAttribute && this.syncStatePatchDeltaToTarget(finalAttribute, keys, nextPatch, !1);
|
|
454
|
+
const category = this.syncStatePatchDeltaToTarget(this.attribute, keys, nextPatch, !0);
|
|
455
|
+
this.valid = this.isValid(), this.attributeMayContainTransientAttrs = !1, this.submitUpdateByCategory(category),
|
|
456
|
+
this.onAttributeUpdate(context);
|
|
457
|
+
}
|
|
330
458
|
setMode(mode) {
|
|
331
459
|
"3d" === mode ? this.set3dMode() : this.set2dMode();
|
|
332
460
|
}
|
|
@@ -346,7 +474,7 @@ class Graphic extends node_tree_1.Node {
|
|
|
346
474
|
return point;
|
|
347
475
|
}
|
|
348
476
|
onAnimateBind(animate) {
|
|
349
|
-
this._emitCustomEvent("animate-bind", animate);
|
|
477
|
+
this.detachAttributeFromBaseAttributes(), this._emitCustomEvent("animate-bind", animate);
|
|
350
478
|
}
|
|
351
479
|
visitTrackedAnimates(cb) {
|
|
352
480
|
const hook = this.forEachTrackedAnimate;
|
|
@@ -359,8 +487,22 @@ class Graphic extends node_tree_1.Node {
|
|
|
359
487
|
const getTrackedAnimates = this.getTrackedAnimates;
|
|
360
488
|
return "function" == typeof getTrackedAnimates ? getTrackedAnimates.call(this).size > 0 : !!(null === (_a = this.animates) || void 0 === _a ? void 0 : _a.size);
|
|
361
489
|
}
|
|
490
|
+
mayHaveTrackedAnimates() {
|
|
491
|
+
var _a;
|
|
492
|
+
return !!(null === (_a = this.animates) || void 0 === _a ? void 0 : _a.size) || !!this._animationStateManager;
|
|
493
|
+
}
|
|
362
494
|
tryUpdateAABBBounds() {
|
|
495
|
+
if (!(this.shadowRoot || this._updateTag & enums_1.UpdateTag.UPDATE_BOUNDS)) return this._AABBBounds;
|
|
363
496
|
const full = "imprecise" === this.attribute.boundsMode;
|
|
497
|
+
if (!this.shadowRoot) {
|
|
498
|
+
const graphicService = this.getGraphicService(), graphicTheme = this.getGraphicTheme();
|
|
499
|
+
if (!graphicService.validCheck(this.attribute, graphicTheme, this._AABBBounds, this)) return this._AABBBounds;
|
|
500
|
+
if (!this.valid) return this._AABBBounds.clear(), this._AABBBounds;
|
|
501
|
+
graphicService.beforeUpdateAABBBounds(this, this.stage, !0, this._AABBBounds);
|
|
502
|
+
const bounds = this.doUpdateAABBBounds(full, graphicTheme);
|
|
503
|
+
return graphicService.afterUpdateAABBBounds(this, this.stage, this._AABBBounds, this, !0),
|
|
504
|
+
"empty" === this.attribute.boundsMode && bounds.clear(), bounds;
|
|
505
|
+
}
|
|
364
506
|
if (!this.shouldUpdateAABBBounds()) return this._AABBBounds;
|
|
365
507
|
if (!this.valid) return this._AABBBounds.clear(), this._AABBBounds;
|
|
366
508
|
this.getGraphicService().beforeUpdateAABBBounds(this, this.stage, !0, this._AABBBounds);
|
|
@@ -426,11 +568,11 @@ class Graphic extends node_tree_1.Node {
|
|
|
426
568
|
const _parsedPath = new builtin_symbol_1.CustomSymbolClass(symbolType, cache);
|
|
427
569
|
return Graphic.userSymbolMap[symbolType] = _parsedPath, _parsedPath;
|
|
428
570
|
}
|
|
429
|
-
doUpdateAABBBounds(full) {
|
|
571
|
+
doUpdateAABBBounds(full, graphicTheme) {
|
|
430
572
|
this.updateAABBBoundsStamp++;
|
|
431
|
-
const
|
|
573
|
+
const resolvedGraphicTheme = null != graphicTheme ? graphicTheme : this.getGraphicTheme();
|
|
432
574
|
this._AABBBounds.clear();
|
|
433
|
-
const attribute = this.attribute, bounds = this.updateAABBBounds(attribute,
|
|
575
|
+
const attribute = this.attribute, bounds = this.updateAABBBounds(attribute, resolvedGraphicTheme, this._AABBBounds, full), {boundsPadding: boundsPadding = resolvedGraphicTheme.boundsPadding} = attribute, paddingArray = (0,
|
|
434
576
|
utils_1.parsePadding)(boundsPadding);
|
|
435
577
|
return paddingArray && bounds.expand(paddingArray), this.clearUpdateBoundTag(),
|
|
436
578
|
bounds;
|
|
@@ -503,27 +645,72 @@ class Graphic extends node_tree_1.Node {
|
|
|
503
645
|
this.widthWithoutTransform = aabbBounds.x2 - aabbBounds.x1, this.heightWithoutTransform = aabbBounds.y2 - aabbBounds.y1;
|
|
504
646
|
}
|
|
505
647
|
setAttributesAndPreventAnimate(params, forceUpdateTag = !1, context, ignorePriority) {
|
|
648
|
+
if (!params) return;
|
|
649
|
+
const keys = Object.keys(params);
|
|
650
|
+
this.captureTransientFromAttrsBeforePreventAnimate(params, keys, context), this.syncFinalAttributesFromUpdateContext(context),
|
|
506
651
|
this.visitTrackedAnimates((animate => {
|
|
507
|
-
(animate.priority !== 1 / 0 || ignorePriority) &&
|
|
508
|
-
animate.preventAttr(key);
|
|
509
|
-
}));
|
|
652
|
+
(animate.priority !== 1 / 0 || ignorePriority) && animate.preventAttrs(keys);
|
|
510
653
|
})), this.applyTransientAttributes(params, forceUpdateTag, context);
|
|
511
654
|
}
|
|
655
|
+
syncFinalAttributesFromUpdateContext(context) {
|
|
656
|
+
var _a;
|
|
657
|
+
const updateType = null == context ? void 0 : context.type;
|
|
658
|
+
if (updateType === enums_1.AttributeUpdateType.STATE || null != updateType && updateType >= enums_1.AttributeUpdateType.ANIMATE_BIND && updateType <= enums_1.AttributeUpdateType.ANIMATE_END) return;
|
|
659
|
+
const finalAttrs = null === (_a = this.context) || void 0 === _a ? void 0 : _a.finalAttrs, setFinalAttributes = this.setFinalAttributes;
|
|
660
|
+
finalAttrs && "function" == typeof setFinalAttributes && setFinalAttributes.call(this, finalAttrs);
|
|
661
|
+
}
|
|
662
|
+
captureTransientFromAttrsBeforePreventAnimate(params, keys, context) {
|
|
663
|
+
var _a, _b;
|
|
664
|
+
const graphicContext = this.context, diffAttrs = null !== (_a = null == graphicContext ? void 0 : graphicContext.diffAttrs) && void 0 !== _a ? _a : params, updateType = null == context ? void 0 : context.type;
|
|
665
|
+
if (!keys.length || !diffAttrs || updateType === enums_1.AttributeUpdateType.STATE || null != updateType && updateType >= enums_1.AttributeUpdateType.ANIMATE_BIND && updateType <= enums_1.AttributeUpdateType.ANIMATE_END) return;
|
|
666
|
+
const sameDiffAttrs = this.transientFromAttrsBeforePreventAnimateDiffAttrs === diffAttrs;
|
|
667
|
+
let fromAttrs = sameDiffAttrs && null !== (_b = this.transientFromAttrsBeforePreventAnimate) && void 0 !== _b ? _b : null;
|
|
668
|
+
sameDiffAttrs || (this.transientFromAttrsBeforePreventAnimate = null, this.transientFromAttrsBeforePreventAnimateDiffAttrs = null);
|
|
669
|
+
let captured = !1;
|
|
670
|
+
for (let i = 0; i < keys.length; i++) {
|
|
671
|
+
const key = keys[i];
|
|
672
|
+
if (!Object.prototype.hasOwnProperty.call(diffAttrs, key)) continue;
|
|
673
|
+
const previousValue = this.attribute[key], nextValue = params[key];
|
|
674
|
+
(0, vutils_1.isEqual)(previousValue, nextValue) || (null != fromAttrs || (fromAttrs = {}),
|
|
675
|
+
fromAttrs[key] = cloneAttributeValue(previousValue), captured = !0);
|
|
676
|
+
}
|
|
677
|
+
captured && (this.transientFromAttrsBeforePreventAnimate = fromAttrs, this.transientFromAttrsBeforePreventAnimateDiffAttrs = diffAttrs);
|
|
678
|
+
}
|
|
679
|
+
consumeTransientFromAttrsBeforePreventAnimate(diffAttrs) {
|
|
680
|
+
const transientFromAttrs = this.transientFromAttrsBeforePreventAnimate, sourceDiffAttrs = this.transientFromAttrsBeforePreventAnimateDiffAttrs;
|
|
681
|
+
if (!transientFromAttrs || !sourceDiffAttrs) return null;
|
|
682
|
+
for (const key in diffAttrs) if (Object.prototype.hasOwnProperty.call(diffAttrs, key) && (!Object.prototype.hasOwnProperty.call(sourceDiffAttrs, key) || !(0,
|
|
683
|
+
vutils_1.isEqual)(sourceDiffAttrs[key], diffAttrs[key]))) return null;
|
|
684
|
+
let fromAttrs = null, remaining = !1;
|
|
685
|
+
for (const key in transientFromAttrs) Object.prototype.hasOwnProperty.call(transientFromAttrs, key) && (Object.prototype.hasOwnProperty.call(diffAttrs, key) ? (null != fromAttrs || (fromAttrs = {}),
|
|
686
|
+
fromAttrs[key] = transientFromAttrs[key]) : remaining = !0);
|
|
687
|
+
if (remaining) {
|
|
688
|
+
const nextTransientFromAttrs = {};
|
|
689
|
+
for (const key in transientFromAttrs) Object.prototype.hasOwnProperty.call(transientFromAttrs, key) && !Object.prototype.hasOwnProperty.call(diffAttrs, key) && (nextTransientFromAttrs[key] = transientFromAttrs[key]);
|
|
690
|
+
this.transientFromAttrsBeforePreventAnimate = nextTransientFromAttrs;
|
|
691
|
+
} else this.transientFromAttrsBeforePreventAnimate = null, this.transientFromAttrsBeforePreventAnimateDiffAttrs = null;
|
|
692
|
+
return fromAttrs;
|
|
693
|
+
}
|
|
512
694
|
setAttributes(params, forceUpdateTag = !1, context) {
|
|
513
695
|
params && ((params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate(params, this.attribute, null, context) || params).background && this.loadImage(params.background, !0),
|
|
514
|
-
isExternalTexture(params.texture) && this.loadImage(params.texture, !1),
|
|
515
|
-
this._setAttributes(params, forceUpdateTag, context));
|
|
696
|
+
params.texture && isExternalTexture(params.texture) && this.loadImage(params.texture, !1),
|
|
697
|
+
params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic), this._setAttributes(params, forceUpdateTag, context));
|
|
516
698
|
}
|
|
517
699
|
_setAttributes(params, forceUpdateTag = !1, context) {
|
|
518
|
-
this.
|
|
700
|
+
this.canCommitBaseAttributesByTouchedKeys() ? this.commitBaseAttributesByTouchedKeys(params, forceUpdateTag, context) : (this.detachAttributeFromBaseAttributes(),
|
|
701
|
+
this.applyBaseAttributes(params), this.commitBaseAttributeMutation(forceUpdateTag, context));
|
|
519
702
|
}
|
|
520
703
|
setAttribute(key, value, forceUpdateTag, context) {
|
|
521
704
|
const params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate({
|
|
522
705
|
[key]: value
|
|
523
706
|
}, this.attribute, key, context);
|
|
524
|
-
params
|
|
525
|
-
|
|
526
|
-
|
|
707
|
+
if (params) this._setAttributes(params, forceUpdateTag, context); else if (this.canCommitBaseAttributesByTouchedKeys()) this.commitBaseAttributeBySingleKey(key, value, !!forceUpdateTag, context); else {
|
|
708
|
+
const nextAttrs = {
|
|
709
|
+
[key]: value
|
|
710
|
+
};
|
|
711
|
+
this.applyBaseAttributes(nextAttrs), this.commitBaseAttributeMutation(!!forceUpdateTag, context);
|
|
712
|
+
}
|
|
713
|
+
"background" === key ? this.loadImage(value, !0) : "texture" === key && isExternalTexture(value) ? this.loadImage(value, !1) : "shadowGraphic" === key && this.setShadowGraphic(value);
|
|
527
714
|
}
|
|
528
715
|
needUpdateTags(keys, k = exports.GRAPHIC_UPDATE_TAG_KEY) {
|
|
529
716
|
for (let i = 0; i < k.length; i++) {
|
|
@@ -543,10 +730,11 @@ class Graphic extends node_tree_1.Node {
|
|
|
543
730
|
type: enums_1.AttributeUpdateType.INIT
|
|
544
731
|
};
|
|
545
732
|
params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate(params, this.attribute, null, context) || params,
|
|
546
|
-
this.
|
|
547
|
-
this.
|
|
548
|
-
isExternalTexture(params.texture) && this.loadImage(params.texture, !1),
|
|
549
|
-
|
|
733
|
+
this.attribute = params, this._baseAttributes = void 0, this.resolvedStatePatch = void 0,
|
|
734
|
+
this.attributeMayContainTransientAttrs = !1, this.valid = this.isValid(), params.background && this.loadImage(params.background, !0),
|
|
735
|
+
params.texture && isExternalTexture(params.texture) && this.loadImage(params.texture, !1),
|
|
736
|
+
params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic), this._updateTag = enums_1.UpdateTag.INIT,
|
|
737
|
+
this.valid = this.isValid(), this.onAttributeUpdate(context);
|
|
550
738
|
}
|
|
551
739
|
translate(x, y) {
|
|
552
740
|
var _a, _b;
|
|
@@ -557,11 +745,15 @@ class Graphic extends node_tree_1.Node {
|
|
|
557
745
|
x: x,
|
|
558
746
|
y: y
|
|
559
747
|
}, this.attribute, tempConstantXYKey, context);
|
|
560
|
-
params && (x = params.x, y = params.y, delete params.x, delete params.y
|
|
561
|
-
const attribute = this.baseAttributes, postMatrix = attribute.postMatrix;
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
748
|
+
params && (x = params.x, y = params.y, delete params.x, delete params.y);
|
|
749
|
+
const attribute = this.baseAttributes, postMatrix = attribute.postMatrix, nextAttrs = params || {};
|
|
750
|
+
if (postMatrix) {
|
|
751
|
+
const nextPostMatrix = postMatrix.clone();
|
|
752
|
+
application_1.application.transformUtil.fromMatrix(nextPostMatrix, nextPostMatrix).translate(x, y),
|
|
753
|
+
nextAttrs.postMatrix = nextPostMatrix;
|
|
754
|
+
} else nextAttrs.x = (null !== (_a = attribute.x) && void 0 !== _a ? _a : config_1.DefaultTransform.x) + x,
|
|
755
|
+
nextAttrs.y = (null !== (_b = attribute.y) && void 0 !== _b ? _b : config_1.DefaultTransform.y) + y;
|
|
756
|
+
return this.commitInternalBaseAttributes(nextAttrs, context), this;
|
|
565
757
|
}
|
|
566
758
|
translateTo(x, y) {
|
|
567
759
|
const attribute = this.baseAttributes;
|
|
@@ -572,9 +764,10 @@ class Graphic extends node_tree_1.Node {
|
|
|
572
764
|
x: x,
|
|
573
765
|
y: y
|
|
574
766
|
}, this.attribute, tempConstantXYKey, context);
|
|
575
|
-
return params ? (this.
|
|
576
|
-
|
|
577
|
-
|
|
767
|
+
return params ? (this.commitInternalBaseAttributes(params, context), this) : (this.commitInternalBaseAttributes({
|
|
768
|
+
x: x,
|
|
769
|
+
y: y
|
|
770
|
+
}, context), this);
|
|
578
771
|
}
|
|
579
772
|
scale(scaleX, scaleY, scaleCenter) {
|
|
580
773
|
var _a, _b;
|
|
@@ -587,15 +780,15 @@ class Graphic extends node_tree_1.Node {
|
|
|
587
780
|
scaleCenter: scaleCenter
|
|
588
781
|
}, this.attribute, tempConstantScaleXYKey, context);
|
|
589
782
|
params && (scaleX = params.scaleX, scaleY = params.scaleY, delete params.scaleX,
|
|
590
|
-
delete params.scaleY
|
|
591
|
-
const attribute = this.baseAttributes;
|
|
783
|
+
delete params.scaleY);
|
|
784
|
+
const attribute = this.baseAttributes, nextAttrs = params || {};
|
|
592
785
|
if (scaleCenter) {
|
|
593
|
-
let {postMatrix: postMatrix} = this.
|
|
594
|
-
postMatrix
|
|
595
|
-
|
|
596
|
-
} else
|
|
597
|
-
|
|
598
|
-
return this.
|
|
786
|
+
let {postMatrix: postMatrix} = this.baseAttributes;
|
|
787
|
+
postMatrix = postMatrix ? postMatrix.clone() : new vutils_1.Matrix, application_1.application.transformUtil.fromMatrix(postMatrix, postMatrix).scale(scaleX, scaleY, scaleCenter),
|
|
788
|
+
nextAttrs.postMatrix = postMatrix;
|
|
789
|
+
} else nextAttrs.scaleX = (null !== (_a = attribute.scaleX) && void 0 !== _a ? _a : config_1.DefaultTransform.scaleX) * scaleX,
|
|
790
|
+
nextAttrs.scaleY = (null !== (_b = attribute.scaleY) && void 0 !== _b ? _b : config_1.DefaultTransform.scaleY) * scaleY;
|
|
791
|
+
return this.commitInternalBaseAttributes(nextAttrs, context), this;
|
|
599
792
|
}
|
|
600
793
|
scaleTo(scaleX, scaleY) {
|
|
601
794
|
const attribute = this.baseAttributes;
|
|
@@ -606,9 +799,10 @@ class Graphic extends node_tree_1.Node {
|
|
|
606
799
|
scaleX: scaleX,
|
|
607
800
|
scaleY: scaleY
|
|
608
801
|
}, this.attribute, tempConstantScaleXYKey, context);
|
|
609
|
-
return params ? (this.
|
|
610
|
-
|
|
611
|
-
|
|
802
|
+
return params ? (this.commitInternalBaseAttributes(params, context), this) : (this.commitInternalBaseAttributes({
|
|
803
|
+
scaleX: scaleX,
|
|
804
|
+
scaleY: scaleY
|
|
805
|
+
}, context), this);
|
|
612
806
|
}
|
|
613
807
|
rotate(angle, rotateCenter) {
|
|
614
808
|
var _a;
|
|
@@ -619,24 +813,23 @@ class Graphic extends node_tree_1.Node {
|
|
|
619
813
|
angle: angle,
|
|
620
814
|
rotateCenter: rotateCenter
|
|
621
815
|
}, this.attribute, tempConstantAngleKey, context);
|
|
622
|
-
params &&
|
|
623
|
-
const attribute = this.baseAttributes;
|
|
816
|
+
params && delete params.angle;
|
|
817
|
+
const attribute = this.baseAttributes, nextAttrs = params || {};
|
|
624
818
|
if (rotateCenter) {
|
|
625
819
|
let {postMatrix: postMatrix} = this.baseAttributes;
|
|
626
|
-
postMatrix
|
|
627
|
-
|
|
628
|
-
} else
|
|
629
|
-
return this.
|
|
820
|
+
postMatrix = postMatrix ? postMatrix.clone() : new vutils_1.Matrix, application_1.application.transformUtil.fromMatrix(postMatrix, postMatrix).rotate(angle, rotateCenter),
|
|
821
|
+
nextAttrs.postMatrix = postMatrix;
|
|
822
|
+
} else nextAttrs.angle = (null !== (_a = attribute.angle) && void 0 !== _a ? _a : config_1.DefaultTransform.angle) + angle;
|
|
823
|
+
return this.commitInternalBaseAttributes(nextAttrs, context), this;
|
|
630
824
|
}
|
|
631
825
|
rotateTo(angle) {
|
|
632
|
-
|
|
633
|
-
if (attribute.angle === angle) return this;
|
|
826
|
+
if (this.baseAttributes.angle === angle) return this;
|
|
634
827
|
const context = {
|
|
635
828
|
type: enums_1.AttributeUpdateType.ROTATE_TO
|
|
636
829
|
}, params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate(angle, this.attribute, tempConstantAngleKey, context);
|
|
637
|
-
return params ? (this.
|
|
638
|
-
|
|
639
|
-
this);
|
|
830
|
+
return params ? (this.commitInternalBaseAttributes(params, context), this) : (this.commitInternalBaseAttributes({
|
|
831
|
+
angle: angle
|
|
832
|
+
}, context), this);
|
|
640
833
|
}
|
|
641
834
|
skewTo(b, c) {
|
|
642
835
|
return this;
|
|
@@ -656,7 +849,16 @@ class Graphic extends node_tree_1.Node {
|
|
|
656
849
|
var _a;
|
|
657
850
|
return null === (_a = this.states) || void 0 === _a ? void 0 : _a[stateName];
|
|
658
851
|
}
|
|
659
|
-
|
|
852
|
+
getStateResolveBaseAttrs() {
|
|
853
|
+
var _a;
|
|
854
|
+
return null !== (_a = this.baseAttributes) && void 0 !== _a ? _a : this.attribute;
|
|
855
|
+
}
|
|
856
|
+
syncStateResolveContext(stateResolveBaseAttrs = this.getStateResolveBaseAttrs()) {
|
|
857
|
+
var _a;
|
|
858
|
+
return null === (_a = this.stateEngine) || void 0 === _a || _a.setResolveContext(this, stateResolveBaseAttrs),
|
|
859
|
+
stateResolveBaseAttrs;
|
|
860
|
+
}
|
|
861
|
+
createStateModel(stateResolveBaseAttrs = this.getStateResolveBaseAttrs()) {
|
|
660
862
|
const {compiledDefinitions: compiledDefinitions, stateProxyEligibility: stateProxyEligibility, stateProxyModeKey: stateProxyModeKey} = this.resolveEffectiveCompiledDefinitions();
|
|
661
863
|
return this.compiledStateDefinitions = compiledDefinitions, compiledDefinitions ? this.stateEngine && this.stateEngineCompiledDefinitions === compiledDefinitions && this.stateEngineStateProxy === this.stateProxy && this.stateEngineStateSort === this.stateSort && this.stateEngineMergeMode === this.stateMergeMode && this.stateEngineStateProxyModeKey === stateProxyModeKey || (this.stateEngine = new state_engine_1.StateEngine({
|
|
662
864
|
compiledDefinitions: compiledDefinitions,
|
|
@@ -669,7 +871,7 @@ class Graphic extends node_tree_1.Node {
|
|
|
669
871
|
this.stateEngineStateSort = this.stateSort, this.stateEngineMergeMode = this.stateMergeMode,
|
|
670
872
|
this.stateEngineStateProxyModeKey = stateProxyModeKey) : (this.stateEngine = void 0,
|
|
671
873
|
this.stateEngineCompiledDefinitions = void 0, this.stateEngineStateProxyModeKey = void 0),
|
|
672
|
-
new state_model_1.StateModel({
|
|
874
|
+
this.syncStateResolveContext(stateResolveBaseAttrs), new state_model_1.StateModel({
|
|
673
875
|
states: this.states,
|
|
674
876
|
currentStates: this.currentStates,
|
|
675
877
|
stateSort: this.stateSort,
|
|
@@ -677,27 +879,148 @@ class Graphic extends node_tree_1.Node {
|
|
|
677
879
|
stateEngine: this.stateEngine
|
|
678
880
|
});
|
|
679
881
|
}
|
|
882
|
+
resolveSimpleLocalStateTransition(states, previousStates) {
|
|
883
|
+
var _a;
|
|
884
|
+
if (!this.states || this.stateProxy || this.stateSort || "deep" === this.stateMergeMode || this.parent || (null === (_a = this.stage) || void 0 === _a ? void 0 : _a.rootSharedStateScope) || this.boundSharedStateScope) return null;
|
|
885
|
+
if (1 === states.length) {
|
|
886
|
+
const stateName = states[0], hasDefinition = Object.prototype.hasOwnProperty.call(this.states, stateName), nextStates = [ stateName ], changed = !this.sameStateNames(previousStates, nextStates), resolvedStateAttrs = {};
|
|
887
|
+
if (hasDefinition) {
|
|
888
|
+
const attrs = this.states[stateName];
|
|
889
|
+
if (null != attrs) {
|
|
890
|
+
if (!isPlainObjectValue(attrs)) return null;
|
|
891
|
+
const keys = Object.keys(attrs);
|
|
892
|
+
for (let keyIndex = 0; keyIndex < keys.length; keyIndex++) {
|
|
893
|
+
const key = keys[keyIndex];
|
|
894
|
+
if (FULL_STATE_DEFINITION_KEYS.has(key)) return null;
|
|
895
|
+
const attrValue = attrs[key];
|
|
896
|
+
resolvedStateAttrs[key] = isPlainObjectValue(attrValue) ? cloneAttributeValue(attrValue) : attrValue;
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
return {
|
|
901
|
+
changed: changed,
|
|
902
|
+
states: nextStates,
|
|
903
|
+
effectiveStates: nextStates,
|
|
904
|
+
resolvedStateAttrs: resolvedStateAttrs
|
|
905
|
+
};
|
|
906
|
+
}
|
|
907
|
+
const uniqueStates = Array.from(new Set(states)), withDefinition = [], withoutDefinition = [];
|
|
908
|
+
for (let i = 0; i < uniqueStates.length; i++) {
|
|
909
|
+
const stateName = uniqueStates[i];
|
|
910
|
+
Object.prototype.hasOwnProperty.call(this.states, stateName) ? withDefinition.push(stateName) : withoutDefinition.push(stateName);
|
|
911
|
+
}
|
|
912
|
+
withDefinition.sort(((left, right) => left.localeCompare(right)));
|
|
913
|
+
const nextStates = withDefinition.concat(withoutDefinition), changed = !this.sameStateNames(previousStates, nextStates), resolvedStateAttrs = {};
|
|
914
|
+
for (let i = 0; i < nextStates.length; i++) {
|
|
915
|
+
const stateName = nextStates[i];
|
|
916
|
+
if (!Object.prototype.hasOwnProperty.call(this.states, stateName)) continue;
|
|
917
|
+
const attrs = this.states[stateName];
|
|
918
|
+
if (null == attrs) continue;
|
|
919
|
+
if (!isPlainObjectValue(attrs)) return null;
|
|
920
|
+
const keys = Object.keys(attrs);
|
|
921
|
+
for (let keyIndex = 0; keyIndex < keys.length; keyIndex++) {
|
|
922
|
+
const key = keys[keyIndex];
|
|
923
|
+
if (FULL_STATE_DEFINITION_KEYS.has(key)) return null;
|
|
924
|
+
const attrValue = attrs[key];
|
|
925
|
+
resolvedStateAttrs[key] = isPlainObjectValue(attrValue) ? cloneAttributeValue(attrValue) : attrValue;
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
return {
|
|
929
|
+
changed: changed,
|
|
930
|
+
states: nextStates,
|
|
931
|
+
effectiveStates: nextStates,
|
|
932
|
+
resolvedStateAttrs: resolvedStateAttrs
|
|
933
|
+
};
|
|
934
|
+
}
|
|
935
|
+
resolveGraphicStateTransition(states, previousStates, forceResolverRefresh = !1) {
|
|
936
|
+
var _a, _b;
|
|
937
|
+
let transition = this.resolveSimpleLocalStateTransition(states, previousStates);
|
|
938
|
+
const isSimpleLocalTransition = !!transition;
|
|
939
|
+
let resolvedStateAttrs;
|
|
940
|
+
if (transition) resolvedStateAttrs = transition.resolvedStateAttrs; else {
|
|
941
|
+
const stateResolveBaseAttrs = this.getStateResolveBaseAttrs(), stateModel = this.createStateModel(stateResolveBaseAttrs);
|
|
942
|
+
forceResolverRefresh && (null === (_a = this.stateEngine) || void 0 === _a || _a.invalidateResolverCache()),
|
|
943
|
+
transition = stateModel.useStates(states), resolvedStateAttrs = this.stateEngine && this.compiledStateDefinitions ? Object.assign({}, this.stateEngine.resolvedPatch) : this.getStateStyleResolver(this.stateMergeMode).resolve(stateResolveBaseAttrs, this.states, this.stateProxy, transition.states, this.stateSort);
|
|
944
|
+
}
|
|
945
|
+
return {
|
|
946
|
+
transition: transition,
|
|
947
|
+
effectiveStates: null !== (_b = transition.effectiveStates) && void 0 !== _b ? _b : transition.states,
|
|
948
|
+
resolvedStateAttrs: resolvedStateAttrs,
|
|
949
|
+
isSimpleLocalTransition: isSimpleLocalTransition
|
|
950
|
+
};
|
|
951
|
+
}
|
|
952
|
+
normalizeSetStatesOptions(options) {
|
|
953
|
+
return options && "object" == typeof options ? {
|
|
954
|
+
hasAnimation: options.animate,
|
|
955
|
+
animateSameStatePatchChange: !0 === options.animateSameStatePatchChange,
|
|
956
|
+
shouldRefreshSameStatePatch: !0
|
|
957
|
+
} : {
|
|
958
|
+
hasAnimation: "boolean" == typeof options ? options : void 0,
|
|
959
|
+
animateSameStatePatchChange: !1,
|
|
960
|
+
shouldRefreshSameStatePatch: !1
|
|
961
|
+
};
|
|
962
|
+
}
|
|
963
|
+
sameStatePatches(left, right) {
|
|
964
|
+
const leftRecord = null != left ? left : {}, rightRecord = null != right ? right : {}, keys = new Set([ ...Object.keys(leftRecord), ...Object.keys(rightRecord) ]);
|
|
965
|
+
for (const key of keys) {
|
|
966
|
+
if (Object.prototype.hasOwnProperty.call(leftRecord, key) !== Object.prototype.hasOwnProperty.call(rightRecord, key)) return !1;
|
|
967
|
+
if (!areAttributeValuesEqual(leftRecord[key], rightRecord[key])) return !1;
|
|
968
|
+
}
|
|
969
|
+
return !0;
|
|
970
|
+
}
|
|
971
|
+
commitSameStatePatchRefresh(states, hasAnimation, animateSameStatePatchChange = !1) {
|
|
972
|
+
var _a;
|
|
973
|
+
const previousStates = null !== (_a = this.currentStates) && void 0 !== _a ? _a : EMPTY_STATE_NAMES, previousResolvedStatePatch = this.resolvedStatePatch, {transition: transition, effectiveStates: effectiveStates, resolvedStateAttrs: resolvedStateAttrs, isSimpleLocalTransition: isSimpleLocalTransition} = this.resolveGraphicStateTransition(states, previousStates, !0), patchChanged = !this.sameStatePatches(previousResolvedStatePatch, resolvedStateAttrs);
|
|
974
|
+
if ((!patchChanged || this.beforeStateUpdate(resolvedStateAttrs, previousStates, transition.states, hasAnimation, !1)) && (this.currentStates = transition.states,
|
|
975
|
+
this.effectiveStates = isSimpleLocalTransition ? effectiveStates : [ ...effectiveStates ],
|
|
976
|
+
this.resolvedStatePatch = resolvedStateAttrs, this.sharedStateDirty = !1, this.syncSharedStateActiveRegistrations(),
|
|
977
|
+
patchChanged)) {
|
|
978
|
+
if (this.stage) {
|
|
979
|
+
const perfMonitor = (0, state_perf_monitor_1.getActiveStageStatePerfMonitor)(this.stage);
|
|
980
|
+
null == perfMonitor || perfMonitor.incrementCounter("stateCommits"), null == perfMonitor || perfMonitor.recordEvent("state-commit", {
|
|
981
|
+
graphicId: this._uid,
|
|
982
|
+
targetStates: [ ...transition.states ]
|
|
983
|
+
});
|
|
984
|
+
}
|
|
985
|
+
hasAnimation && animateSameStatePatchChange ? (this._syncFinalAttributeFromStaticTruth(),
|
|
986
|
+
this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !1, void 0, this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch))) : (this.stopStateAnimates(),
|
|
987
|
+
this.attributeMayContainTransientAttrs ? this._restoreAttributeFromStaticTruth({
|
|
988
|
+
type: enums_1.AttributeUpdateType.STATE
|
|
989
|
+
}) : this.restoreAttributeFromStatePatchDelta(previousResolvedStatePatch, this.resolvedStatePatch, {
|
|
990
|
+
type: enums_1.AttributeUpdateType.STATE
|
|
991
|
+
}), this.emitStateUpdateEvent());
|
|
992
|
+
}
|
|
993
|
+
}
|
|
680
994
|
resolveStateAnimateConfig(animateConfig) {
|
|
681
995
|
var _a, _b, _c;
|
|
682
996
|
return null !== (_c = null !== (_a = null != animateConfig ? animateConfig : this.stateAnimateConfig) && void 0 !== _a ? _a : null === (_b = this.context) || void 0 === _b ? void 0 : _b.stateAnimateConfig) && void 0 !== _c ? _c : config_2.DefaultStateAnimateConfig;
|
|
683
997
|
}
|
|
684
|
-
applyStateAttrs(attrs, stateNames, hasAnimation, isClear, animateConfig) {
|
|
998
|
+
applyStateAttrs(attrs, stateNames, hasAnimation, isClear, animateConfig, extraAnimateAttrs) {
|
|
685
999
|
const resolvedAnimateConfig = hasAnimation ? this.resolveStateAnimateConfig(animateConfig) : void 0, transitionOptions = resolvedAnimateConfig ? {
|
|
686
|
-
animateConfig: resolvedAnimateConfig
|
|
1000
|
+
animateConfig: resolvedAnimateConfig,
|
|
1001
|
+
extraAnimateAttrs: extraAnimateAttrs,
|
|
1002
|
+
shouldSkipDefaultAttribute: this.shouldSkipStateTransitionDefaultAttribute.bind(this)
|
|
687
1003
|
} : void 0;
|
|
688
1004
|
if (isClear) return void this.getStateTransitionOrchestrator().applyClearTransition(this, attrs, hasAnimation, stateNames, transitionOptions);
|
|
689
1005
|
const plan = this.getStateTransitionOrchestrator().analyzeTransition({}, attrs, stateNames, hasAnimation, {
|
|
690
1006
|
noWorkAnimateAttr: this.getNoWorkAnimateAttr(),
|
|
691
|
-
animateConfig: resolvedAnimateConfig
|
|
1007
|
+
animateConfig: resolvedAnimateConfig,
|
|
1008
|
+
extraAnimateAttrs: extraAnimateAttrs,
|
|
1009
|
+
shouldSkipDefaultAttribute: this.shouldSkipStateTransitionDefaultAttribute.bind(this)
|
|
692
1010
|
});
|
|
693
1011
|
this.getStateTransitionOrchestrator().applyTransition(this, plan, hasAnimation, transitionOptions);
|
|
694
1012
|
}
|
|
695
|
-
updateNormalAttrs(
|
|
696
|
-
|
|
1013
|
+
updateNormalAttrs(_stateAttrs) {}
|
|
1014
|
+
getStateTransitionDefaultAttribute(key, targetAttrs) {
|
|
1015
|
+
return this.getDefaultAttribute(key);
|
|
1016
|
+
}
|
|
1017
|
+
shouldSkipStateTransitionDefaultAttribute(_key, _targetAttrs) {
|
|
1018
|
+
return !1;
|
|
697
1019
|
}
|
|
698
1020
|
stopStateAnimates(type = "end") {
|
|
699
1021
|
const stopAnimationState = this.stopAnimationState;
|
|
700
1022
|
if ("function" == typeof stopAnimationState) return void stopAnimationState.call(this, "state", type);
|
|
1023
|
+
if (!this.mayHaveTrackedAnimates()) return;
|
|
701
1024
|
const stateAnimates = [];
|
|
702
1025
|
this.visitTrackedAnimates((animate => {
|
|
703
1026
|
animate.stateNames && stateAnimates.push(animate);
|
|
@@ -710,23 +1033,27 @@ class Graphic extends node_tree_1.Node {
|
|
|
710
1033
|
}
|
|
711
1034
|
clearStates(hasAnimation) {
|
|
712
1035
|
var _a, _b, _c;
|
|
713
|
-
const previousStates =
|
|
1036
|
+
const previousStates = null !== (_a = this.currentStates) && void 0 !== _a ? _a : EMPTY_STATE_NAMES, previousResolvedStatePatch = this.resolvedStatePatch, transition = this.createStateModel().clearStates();
|
|
714
1037
|
if (!transition.changed && 0 === previousStates.length) return this.currentStates = [],
|
|
715
1038
|
this.effectiveStates = [], this.resolvedStatePatch = void 0, this.sharedStateDirty = !1,
|
|
716
1039
|
void this.clearSharedStateActiveRegistrations();
|
|
717
|
-
const resolvedStateAttrs = cloneAttributeValue(null !== (
|
|
718
|
-
transition.changed
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
1040
|
+
const resolvedStateAttrs = hasAnimation || this.hasCustomEvent("beforeStateUpdate") ? cloneAttributeValue(null !== (_b = this.baseAttributes) && void 0 !== _b ? _b : {}) : null !== (_c = this.baseAttributes) && void 0 !== _c ? _c : {};
|
|
1041
|
+
if (!transition.changed || this.beforeStateUpdate(resolvedStateAttrs, previousStates, transition.states, hasAnimation, !0)) {
|
|
1042
|
+
if (this.currentStates = transition.states, this.effectiveStates = [], this.resolvedStatePatch = void 0,
|
|
1043
|
+
this.sharedStateDirty = !1, this.clearSharedStateActiveRegistrations(), this.stage) {
|
|
1044
|
+
const perfMonitor = (0, state_perf_monitor_1.getActiveStageStatePerfMonitor)(this.stage);
|
|
1045
|
+
null == perfMonitor || perfMonitor.incrementCounter("stateCommits"), null == perfMonitor || perfMonitor.recordEvent("state-commit", {
|
|
1046
|
+
graphicId: this._uid,
|
|
1047
|
+
targetStates: []
|
|
1048
|
+
});
|
|
1049
|
+
}
|
|
1050
|
+
hasAnimation ? (this._syncFinalAttributeFromStaticTruth(), this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !0, void 0, this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch))) : (this.stopStateAnimates(),
|
|
1051
|
+
this.attributeMayContainTransientAttrs ? this._restoreAttributeFromStaticTruth({
|
|
1052
|
+
type: enums_1.AttributeUpdateType.STATE
|
|
1053
|
+
}) : this.restoreAttributeFromStatePatchDelta(previousResolvedStatePatch, void 0, {
|
|
1054
|
+
type: enums_1.AttributeUpdateType.STATE
|
|
1055
|
+
}), this.emitStateUpdateEvent());
|
|
1056
|
+
}
|
|
730
1057
|
}
|
|
731
1058
|
removeState(stateName, hasAnimation) {
|
|
732
1059
|
const transition = this.createStateModel().removeState(stateName);
|
|
@@ -740,42 +1067,51 @@ class Graphic extends node_tree_1.Node {
|
|
|
740
1067
|
const transition = this.createStateModel().addState(stateName, keepCurrentStates);
|
|
741
1068
|
transition.changed && this.useStates(transition.states, hasAnimation);
|
|
742
1069
|
}
|
|
1070
|
+
setStates(states, options) {
|
|
1071
|
+
var _a, _b, _c;
|
|
1072
|
+
const {hasAnimation: hasAnimation, animateSameStatePatchChange: animateSameStatePatchChange, shouldRefreshSameStatePatch: shouldRefreshSameStatePatch} = this.normalizeSetStatesOptions(options), nextStates = (null == states ? void 0 : states.length) ? states : EMPTY_STATE_NAMES, hasCurrentState = !!((null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) || (null === (_b = this.effectiveStates) || void 0 === _b ? void 0 : _b.length) || this.resolvedStatePatch || (null === (_c = this.registeredActiveScopes) || void 0 === _c ? void 0 : _c.size));
|
|
1073
|
+
if (nextStates.length) {
|
|
1074
|
+
if (this.sameStateNames(this.currentStates, nextStates)) return shouldRefreshSameStatePatch ? void this.commitSameStatePatchRefresh(nextStates, hasAnimation, animateSameStatePatchChange) : void (this.sharedStateDirty && this.refreshSharedStateBeforeRender());
|
|
1075
|
+
this.useStates(nextStates, hasAnimation);
|
|
1076
|
+
} else {
|
|
1077
|
+
if (!hasCurrentState && !this.sharedStateDirty) return;
|
|
1078
|
+
this.clearStates(hasAnimation);
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
743
1081
|
useStates(states, hasAnimation) {
|
|
744
|
-
var _a
|
|
1082
|
+
var _a;
|
|
745
1083
|
if (!states.length) return void this.clearStates(hasAnimation);
|
|
746
|
-
const previousStates =
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
}
|
|
1084
|
+
const previousStates = null !== (_a = this.currentStates) && void 0 !== _a ? _a : EMPTY_STATE_NAMES, previousResolvedStatePatch = this.resolvedStatePatch, {transition: transition, effectiveStates: effectiveStates, resolvedStateAttrs: resolvedStateAttrs, isSimpleLocalTransition: isSimpleLocalTransition} = this.resolveGraphicStateTransition(states, previousStates);
|
|
1085
|
+
if ((transition.changed || !this.sameStateNames(previousStates, transition.states)) && this.beforeStateUpdate(resolvedStateAttrs, previousStates, transition.states, hasAnimation, !1)) {
|
|
1086
|
+
if (this.currentStates = transition.states, this.effectiveStates = isSimpleLocalTransition ? effectiveStates : [ ...effectiveStates ],
|
|
1087
|
+
this.resolvedStatePatch = resolvedStateAttrs, this.sharedStateDirty = !1, this.syncSharedStateActiveRegistrations(),
|
|
1088
|
+
this.stage) {
|
|
1089
|
+
const perfMonitor = (0, state_perf_monitor_1.getActiveStageStatePerfMonitor)(this.stage);
|
|
1090
|
+
null == perfMonitor || perfMonitor.incrementCounter("stateCommits"), null == perfMonitor || perfMonitor.recordEvent("state-commit", {
|
|
1091
|
+
graphicId: this._uid,
|
|
1092
|
+
targetStates: [ ...transition.states ]
|
|
1093
|
+
});
|
|
1094
|
+
}
|
|
1095
|
+
hasAnimation ? (this._syncFinalAttributeFromStaticTruth(), this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !1, void 0, this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch))) : (this.stopStateAnimates(),
|
|
1096
|
+
this.attributeMayContainTransientAttrs ? this._restoreAttributeFromStaticTruth({
|
|
1097
|
+
type: enums_1.AttributeUpdateType.STATE
|
|
1098
|
+
}) : this.restoreAttributeFromStatePatchDelta(previousResolvedStatePatch, this.resolvedStatePatch, {
|
|
1099
|
+
type: enums_1.AttributeUpdateType.STATE
|
|
1100
|
+
}), this.emitStateUpdateEvent());
|
|
1101
|
+
}
|
|
764
1102
|
}
|
|
765
1103
|
invalidateResolver() {
|
|
766
1104
|
var _a, _b;
|
|
767
1105
|
if (!this.stateEngine || !(null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) || !this.compiledStateDefinitions) return;
|
|
768
|
-
|
|
769
|
-
this.
|
|
1106
|
+
this.syncStateResolveContext();
|
|
1107
|
+
this.resolverEpoch = (null !== (_b = this.resolverEpoch) && void 0 !== _b ? _b : 0) + 1,
|
|
770
1108
|
this.stateEngine.invalidateResolverCache();
|
|
771
1109
|
const transition = this.stateEngine.applyStates(this.currentStates), resolvedStateAttrs = Object.assign({}, this.stateEngine.resolvedPatch);
|
|
772
|
-
this.effectiveStates = [ ...transition.effectiveStates ], this.resolvedStatePatch =
|
|
1110
|
+
this.effectiveStates = [ ...transition.effectiveStates ], this.resolvedStatePatch = resolvedStateAttrs,
|
|
773
1111
|
this.sharedStateDirty = !1, this.syncSharedStateActiveRegistrations(), this.stopStateAnimates(),
|
|
774
1112
|
this._restoreAttributeFromStaticTruth({
|
|
775
1113
|
type: enums_1.AttributeUpdateType.STATE
|
|
776
|
-
}), this.
|
|
777
|
-
type: enums_1.AttributeUpdateType.STATE
|
|
778
|
-
});
|
|
1114
|
+
}), this.emitStateUpdateEvent();
|
|
779
1115
|
}
|
|
780
1116
|
sameStateNames(left, right) {
|
|
781
1117
|
const normalizedLeft = null != left ? left : [], normalizedRight = null != right ? right : [];
|
|
@@ -797,6 +1133,10 @@ class Graphic extends node_tree_1.Node {
|
|
|
797
1133
|
this._updateTag |= enums_1.UpdateTag.UPDATE_SHAPE_AND_BOUNDS, this.parent && this.parent.addChildUpdateBoundTag(),
|
|
798
1134
|
this.glyphHost && this.glyphHost.addUpdateBoundTag();
|
|
799
1135
|
}
|
|
1136
|
+
addBroadUpdateTag() {
|
|
1137
|
+
this.shadowRoot && this.shadowRoot.addUpdateGlobalPositionTag(), this._updateTag |= enums_1.UpdateTag.UPDATE_SHAPE_AND_BOUNDS | enums_1.UpdateTag.UPDATE_PAINT | enums_1.UpdateTag.UPDATE_GLOBAL_LOCAL_MATRIX | enums_1.UpdateTag.UPDATE_LAYOUT,
|
|
1138
|
+
this.parent && this.parent.addChildUpdateBoundTag(), this.glyphHost && this.glyphHost.addUpdateBoundTag();
|
|
1139
|
+
}
|
|
800
1140
|
updateShapeAndBoundsTagSetted() {
|
|
801
1141
|
return (this._updateTag & enums_1.UpdateTag.UPDATE_SHAPE_AND_BOUNDS) === enums_1.UpdateTag.UPDATE_SHAPE_AND_BOUNDS;
|
|
802
1142
|
}
|
|
@@ -871,12 +1211,12 @@ class Graphic extends node_tree_1.Node {
|
|
|
871
1211
|
}
|
|
872
1212
|
}
|
|
873
1213
|
setStage(stage, layer) {
|
|
874
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1214
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
875
1215
|
const graphicService = null !== (_c = null !== (_a = null == stage ? void 0 : stage.graphicService) && void 0 !== _a ? _a : null === (_b = this.stage) || void 0 === _b ? void 0 : _b.graphicService) && void 0 !== _c ? _c : application_1.application.graphicService, previousStage = this.stage;
|
|
876
1216
|
if (this.stage !== stage || this.layer !== layer) {
|
|
877
|
-
if (this.stage = stage, this.layer = layer,
|
|
878
|
-
this.setStageToShadowRoot(stage, layer), this.hasAnyTrackedAnimate()) {
|
|
879
|
-
const previousTimeline = null === (
|
|
1217
|
+
if (this.stage = stage, this.layer = layer, ((null === (_d = this.currentStates) || void 0 === _d ? void 0 : _d.length) || this.boundSharedStateScope || (null === (_e = this.registeredActiveScopes) || void 0 === _e ? void 0 : _e.size) || this.sharedStateDirty) && this.syncSharedStateScopeBindingOnTreeChange(!0),
|
|
1218
|
+
this.setStageToShadowRoot(stage, layer), this.mayHaveTrackedAnimates() && this.hasAnyTrackedAnimate()) {
|
|
1219
|
+
const previousTimeline = null === (_f = null == previousStage ? void 0 : previousStage.getTimeline) || void 0 === _f ? void 0 : _f.call(previousStage), nextTimeline = null === (_g = null == stage ? void 0 : stage.getTimeline) || void 0 === _g ? void 0 : _g.call(stage), detachedStageAnimates = [];
|
|
880
1220
|
this.visitTrackedAnimates((a => {
|
|
881
1221
|
(!!previousTimeline && a.timeline === previousTimeline || a.timeline.isGlobal) && (nextTimeline ? a.timeline !== nextTimeline && (previousTimeline && a.timeline === previousTimeline && previousTimeline.removeAnimate(a, !1),
|
|
882
1222
|
a.setTimeline(nextTimeline), nextTimeline.addAnimate(a)) : previousTimeline && a.timeline === previousTimeline && (previousTimeline.removeAnimate(a, !1),
|
|
@@ -890,9 +1230,18 @@ class Graphic extends node_tree_1.Node {
|
|
|
890
1230
|
type: enums_1.AttributeUpdateType.ANIMATE_END
|
|
891
1231
|
}));
|
|
892
1232
|
}
|
|
893
|
-
return this._onSetStage && this._onSetStage(this, stage, layer), void (null === (
|
|
1233
|
+
return this._onSetStage && this._onSetStage(this, stage, layer), void (null === (_h = null == graphicService ? void 0 : graphicService.onSetStage) || void 0 === _h || _h.call(graphicService, this, stage));
|
|
894
1234
|
}
|
|
895
|
-
|
|
1235
|
+
((null === (_j = this.currentStates) || void 0 === _j ? void 0 : _j.length) || this.boundSharedStateScope || (null === (_k = this.registeredActiveScopes) || void 0 === _k ? void 0 : _k.size) || this.sharedStateDirty) && this.syncSharedStateScopeBindingOnTreeChange(!0);
|
|
1236
|
+
}
|
|
1237
|
+
detachStageForRelease() {
|
|
1238
|
+
var _a, _b, _c;
|
|
1239
|
+
(null === (_a = this.registeredActiveScopes) || void 0 === _a ? void 0 : _a.size) && this.clearSharedStateActiveRegistrations(),
|
|
1240
|
+
(this.mayHaveTrackedAnimates() || this.shadowRoot) && this.stopAnimates(), this.boundSharedStateScope = void 0,
|
|
1241
|
+
this.boundSharedStateRevision = void 0, this.localFallbackCompiledDefinitions = void 0,
|
|
1242
|
+
this.compiledStateDefinitions = void 0, this.compiledStateDefinitionsCacheKey = void 0,
|
|
1243
|
+
this.stateEngine = void 0, this.stateEngineCompiledDefinitions = void 0, this.stateEngineStateProxyModeKey = void 0,
|
|
1244
|
+
this.sharedStateDirty = !1, this.stage = null, this.layer = null, this.shadowRoot && (null === (_c = (_b = this.shadowRoot).detachStageForRelease) || void 0 === _c || _c.call(_b));
|
|
896
1245
|
}
|
|
897
1246
|
setStageToShadowRoot(stage, layer) {
|
|
898
1247
|
this.shadowRoot && this.shadowRoot.setStage(stage, layer);
|
|
@@ -967,6 +1316,7 @@ class Graphic extends node_tree_1.Node {
|
|
|
967
1316
|
res && (res.state = "fail", cb && cb());
|
|
968
1317
|
}
|
|
969
1318
|
_stopAnimates() {
|
|
1319
|
+
if (!this.mayHaveTrackedAnimates()) return;
|
|
970
1320
|
const animates = [];
|
|
971
1321
|
this.visitTrackedAnimates((animate => {
|
|
972
1322
|
animates.push(animate);
|
|
@@ -980,15 +1330,19 @@ class Graphic extends node_tree_1.Node {
|
|
|
980
1330
|
}));
|
|
981
1331
|
}
|
|
982
1332
|
release() {
|
|
983
|
-
var _a, _b, _c;
|
|
984
|
-
this.releaseStatus = "released", this.
|
|
985
|
-
|
|
986
|
-
null
|
|
1333
|
+
var _a, _b, _c, _d;
|
|
1334
|
+
this.releaseStatus = "released", (null === (_a = this.registeredActiveScopes) || void 0 === _a ? void 0 : _a.size) && this.clearSharedStateActiveRegistrations(),
|
|
1335
|
+
(this.mayHaveTrackedAnimates() || this.shadowRoot) && this.stopAnimates();
|
|
1336
|
+
const graphicService = null !== (_c = null === (_b = this.stage) || void 0 === _b ? void 0 : _b.graphicService) && void 0 !== _c ? _c : application_1.application.graphicService;
|
|
1337
|
+
null === (_d = null == graphicService ? void 0 : graphicService.onRelease) || void 0 === _d || _d.call(graphicService, this),
|
|
987
1338
|
super.release();
|
|
988
1339
|
}
|
|
1340
|
+
hasCustomEvent(type) {
|
|
1341
|
+
return !!this._events && type in this._events;
|
|
1342
|
+
}
|
|
989
1343
|
_dispatchCustomEvent(type, context) {
|
|
990
1344
|
var _a, _b;
|
|
991
|
-
if (this.
|
|
1345
|
+
if (this.hasCustomEvent(type)) {
|
|
992
1346
|
const changeEvent = new event_1.CustomEvent(type, context);
|
|
993
1347
|
changeEvent.bubbles = !1;
|
|
994
1348
|
const manager = null === (_b = null === (_a = this.stage) || void 0 === _a ? void 0 : _a.eventSystem) || void 0 === _b ? void 0 : _b.manager;
|
|
@@ -997,7 +1351,7 @@ class Graphic extends node_tree_1.Node {
|
|
|
997
1351
|
return !0;
|
|
998
1352
|
}
|
|
999
1353
|
beforeStateUpdate(attrs, prevStates, nextStates, hasAnimation, isClear) {
|
|
1000
|
-
return this._dispatchCustomEvent("beforeStateUpdate", {
|
|
1354
|
+
return !this.hasCustomEvent("beforeStateUpdate") || this._dispatchCustomEvent("beforeStateUpdate", {
|
|
1001
1355
|
type: enums_1.AttributeUpdateType.STATE,
|
|
1002
1356
|
attrs: Object.assign({}, attrs),
|
|
1003
1357
|
prevStates: prevStates.slice(),
|
|
@@ -1006,6 +1360,11 @@ class Graphic extends node_tree_1.Node {
|
|
|
1006
1360
|
isClear: !!isClear
|
|
1007
1361
|
});
|
|
1008
1362
|
}
|
|
1363
|
+
emitStateUpdateEvent() {
|
|
1364
|
+
this.hasCustomEvent("afterStateUpdate") && this._emitCustomEvent("afterStateUpdate", {
|
|
1365
|
+
type: enums_1.AttributeUpdateType.STATE
|
|
1366
|
+
});
|
|
1367
|
+
}
|
|
1009
1368
|
_emitCustomEvent(type, context) {
|
|
1010
1369
|
this._dispatchCustomEvent(type, context);
|
|
1011
1370
|
}
|