@visactor/vrender-core 1.1.0-alpha.16 → 1.1.0-alpha.18
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/core/stage.d.ts +4 -1
- package/cjs/core/stage.js +23 -11
- package/cjs/core/stage.js.map +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 +61 -9
- package/cjs/graphic/graphic.js +433 -146
- 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/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/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 +895 -261
- package/es/core/stage.d.ts +4 -1
- package/es/core/stage.js +21 -10
- package/es/core/stage.js.map +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 +61 -9
- package/es/graphic/graphic.js +429 -139
- 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/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/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;
|
|
@@ -244,7 +255,7 @@ class Graphic extends node_tree_1.Node {
|
|
|
244
255
|
null === (_c = this.stateEngine) || void 0 === _c || _c.setResolveContext(this, stateResolveBaseAttrs);
|
|
245
256
|
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);
|
|
246
257
|
this.currentStates = transition.states, this.effectiveStates = [ ...effectiveStates ],
|
|
247
|
-
this.resolvedStatePatch =
|
|
258
|
+
this.resolvedStatePatch = resolvedStateAttrs, this.syncSharedStateActiveRegistrations();
|
|
248
259
|
}
|
|
249
260
|
buildStaticAttributeSnapshot() {
|
|
250
261
|
var _a;
|
|
@@ -279,15 +290,17 @@ class Graphic extends node_tree_1.Node {
|
|
|
279
290
|
next: void 0
|
|
280
291
|
}), delete target[key]));
|
|
281
292
|
const nextValue = snapshot[key];
|
|
282
|
-
(
|
|
293
|
+
areAttributeValuesEqual(previousValue, nextValue) || (delta.set(key, {
|
|
283
294
|
prev: previousValue,
|
|
284
295
|
next: nextValue
|
|
285
296
|
}), target[key] = cloneAttributeValue(nextValue));
|
|
286
297
|
})), delta;
|
|
287
298
|
}
|
|
288
299
|
_syncAttribute() {
|
|
300
|
+
this.attribute === this.baseAttributes && this.resolvedStatePatch && this.detachAttributeFromBaseAttributes();
|
|
289
301
|
const snapshot = this.buildStaticAttributeSnapshot(), delta = this.syncObjectToSnapshot(this.attribute, snapshot);
|
|
290
|
-
return this.valid = this.isValid(),
|
|
302
|
+
return this.valid = this.isValid(), this.attributeMayContainTransientAttrs = !1,
|
|
303
|
+
delta;
|
|
291
304
|
}
|
|
292
305
|
_syncFinalAttributeFromStaticTruth() {
|
|
293
306
|
const target = this.finalAttribute;
|
|
@@ -295,54 +308,155 @@ class Graphic extends node_tree_1.Node {
|
|
|
295
308
|
const snapshot = this.buildStaticAttributeSnapshot();
|
|
296
309
|
this.syncObjectToSnapshot(target, snapshot);
|
|
297
310
|
}
|
|
298
|
-
|
|
311
|
+
mergeAttributeDeltaCategory(category, key, prev, next) {
|
|
312
|
+
var _a;
|
|
313
|
+
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;
|
|
314
|
+
return nextCategory & attribute_update_classifier_1.UpdateCategory.PICK && (nextCategory |= attribute_update_classifier_1.UpdateCategory.BOUNDS),
|
|
315
|
+
nextCategory === attribute_update_classifier_1.UpdateCategory.PAINT && this.needUpdateTag(key) && (nextCategory = attribute_update_classifier_1.UpdateCategory.SHAPE | attribute_update_classifier_1.UpdateCategory.BOUNDS),
|
|
316
|
+
category | nextCategory;
|
|
317
|
+
}
|
|
318
|
+
submitUpdateByCategory(category, forceUpdateTag = !1) {
|
|
299
319
|
var _a;
|
|
300
320
|
if (forceUpdateTag) return this.addUpdateShapeAndBoundsTag(), this.addUpdatePositionTag(),
|
|
301
321
|
void this.addUpdateLayoutTag();
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
category |= nextCategory;
|
|
308
|
-
})), category !== attribute_update_classifier_1.UpdateCategory.NONE && (null === (_a = (0,
|
|
309
|
-
state_perf_monitor_1.getStageStatePerfMonitor)(this.stage)) || void 0 === _a || _a.recordCategory(category)),
|
|
310
|
-
category & attribute_update_classifier_1.UpdateCategory.SHAPE ? this.addUpdateShapeAndBoundsTag() : category & attribute_update_classifier_1.UpdateCategory.BOUNDS && this.addUpdateBoundTag(),
|
|
322
|
+
if (category !== attribute_update_classifier_1.UpdateCategory.NONE) {
|
|
323
|
+
const stage = this.stage;
|
|
324
|
+
stage && (null === (_a = (0, state_perf_monitor_1.getActiveStageStatePerfMonitor)(stage)) || void 0 === _a || _a.recordCategory(category));
|
|
325
|
+
}
|
|
326
|
+
(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(),
|
|
311
327
|
category & attribute_update_classifier_1.UpdateCategory.PAINT && this.addUpdatePaintTag(),
|
|
312
328
|
category & attribute_update_classifier_1.UpdateCategory.TRANSFORM && this.addUpdatePositionTag(),
|
|
313
|
-
category & attribute_update_classifier_1.UpdateCategory.LAYOUT && this.addUpdateLayoutTag();
|
|
329
|
+
category & attribute_update_classifier_1.UpdateCategory.LAYOUT && this.addUpdateLayoutTag()) : this.addBroadUpdateTag();
|
|
330
|
+
}
|
|
331
|
+
submitUpdateByDelta(delta, forceUpdateTag = !1) {
|
|
332
|
+
let category = attribute_update_classifier_1.UpdateCategory.NONE;
|
|
333
|
+
delta.forEach(((entry, key) => {
|
|
334
|
+
category = this.mergeAttributeDeltaCategory(category, key, entry.prev, entry.next);
|
|
335
|
+
})), this.submitUpdateByCategory(category, forceUpdateTag);
|
|
336
|
+
}
|
|
337
|
+
submitTouchedKeyUpdate(keys, forceUpdateTag = !1) {
|
|
338
|
+
this.submitTouchedUpdate(forceUpdateTag || this.needUpdateTags(keys));
|
|
339
|
+
}
|
|
340
|
+
submitTouchedUpdate(needsShapeAndBounds) {
|
|
341
|
+
!this.updateShapeAndBoundsTagSetted() && needsShapeAndBounds ? this.addUpdateShapeAndBoundsTag() : this.addUpdateBoundTag(),
|
|
342
|
+
this.addUpdatePositionTag(), this.addUpdateLayoutTag();
|
|
314
343
|
}
|
|
315
344
|
commitBaseAttributeMutation(forceUpdateTag = !1, context) {
|
|
316
|
-
var _a, _b;
|
|
317
|
-
(null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) && (this.resolverEpoch
|
|
318
|
-
null === (
|
|
345
|
+
var _a, _b, _c;
|
|
346
|
+
(null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) && (this.resolverEpoch = (null !== (_b = this.resolverEpoch) && void 0 !== _b ? _b : 0) + 1,
|
|
347
|
+
null === (_c = this.stateEngine) || void 0 === _c || _c.invalidateResolverCache(),
|
|
319
348
|
this.recomputeCurrentStatePatch());
|
|
320
349
|
const delta = this._syncAttribute();
|
|
321
350
|
this.submitUpdateByDelta(delta, forceUpdateTag), this.onAttributeUpdate(context);
|
|
322
351
|
}
|
|
352
|
+
canCommitBaseAttributesByTouchedKeys() {
|
|
353
|
+
var _a, _b;
|
|
354
|
+
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());
|
|
355
|
+
}
|
|
356
|
+
detachAttributeFromBaseAttributes() {
|
|
357
|
+
this.attribute === this.baseAttributes && (this._baseAttributes = this.attribute,
|
|
358
|
+
this.attribute = cloneAttributeSurface(this.attribute));
|
|
359
|
+
}
|
|
360
|
+
commitInternalBaseAttributes(params, context) {
|
|
361
|
+
params && Object.keys(params).length && (this.canCommitBaseAttributesByTouchedKeys() ? this.commitBaseAttributesByTouchedKeys(params, !1, context) : (this.detachAttributeFromBaseAttributes(),
|
|
362
|
+
this.applyBaseAttributes(params), this.commitBaseAttributeMutation(!1, context)));
|
|
363
|
+
}
|
|
364
|
+
commitBaseAttributesByTouchedKeys(params, forceUpdateTag = !1, context) {
|
|
365
|
+
const source = params, baseAttributes = this.getBaseAttributesStorage();
|
|
366
|
+
let hasKeys = !1, needsShapeAndBounds = forceUpdateTag;
|
|
367
|
+
for (const key in source) Object.prototype.hasOwnProperty.call(source, key) && (hasKeys = !0,
|
|
368
|
+
baseAttributes[key] = source[key], !needsShapeAndBounds && this.needUpdateTag(key) && (needsShapeAndBounds = !0));
|
|
369
|
+
hasKeys && (this.attribute = baseAttributes, this._baseAttributes = void 0, this.valid = this.isValid(),
|
|
370
|
+
this.attributeMayContainTransientAttrs = !1, this.submitTouchedUpdate(needsShapeAndBounds),
|
|
371
|
+
this.onAttributeUpdate(context));
|
|
372
|
+
}
|
|
373
|
+
commitBaseAttributeBySingleKey(key, value, forceUpdateTag = !1, context) {
|
|
374
|
+
this.getBaseAttributesStorage()[key] = value, this.attribute = this.getBaseAttributesStorage(),
|
|
375
|
+
this._baseAttributes = void 0, this.valid = this.isValid(), this.attributeMayContainTransientAttrs = !1,
|
|
376
|
+
this.submitTouchedUpdate(forceUpdateTag || this.needUpdateTag(key)), this.onAttributeUpdate(context);
|
|
377
|
+
}
|
|
323
378
|
applyBaseAttributes(params) {
|
|
324
379
|
const keys = Object.keys(params);
|
|
325
380
|
for (let i = 0; i < keys.length; i++) {
|
|
326
381
|
const key = keys[i];
|
|
327
|
-
this.
|
|
382
|
+
this.getBaseAttributesStorage()[key] = params[key];
|
|
328
383
|
}
|
|
329
384
|
}
|
|
385
|
+
applyAnimationTransientAttributes(params, forceUpdateTag = !1, context) {
|
|
386
|
+
const source = params;
|
|
387
|
+
let target, needsShapeAndBounds = forceUpdateTag;
|
|
388
|
+
for (const key in source) Object.prototype.hasOwnProperty.call(source, key) && (target || (this.detachAttributeFromBaseAttributes(),
|
|
389
|
+
target = this.attribute), target[key] = source[key], !needsShapeAndBounds && this.needUpdateTag(key) && (needsShapeAndBounds = !0));
|
|
390
|
+
target && (this.attributeMayContainTransientAttrs = !0, this.valid = this.isValid(),
|
|
391
|
+
this.submitTouchedUpdate(needsShapeAndBounds), this.onAttributeUpdate(context));
|
|
392
|
+
}
|
|
330
393
|
applyTransientAttributes(params, forceUpdateTag = !1, context) {
|
|
394
|
+
this.detachAttributeFromBaseAttributes();
|
|
331
395
|
const delta = new Map, keys = Object.keys(params);
|
|
332
396
|
for (let i = 0; i < keys.length; i++) {
|
|
333
397
|
const key = keys[i], previousValue = this.attribute[key], nextValue = params[key];
|
|
334
|
-
(
|
|
398
|
+
areAttributeValuesEqual(previousValue, nextValue) || (delta.set(key, {
|
|
335
399
|
prev: previousValue,
|
|
336
400
|
next: nextValue
|
|
337
|
-
}), this.attribute[key] =
|
|
401
|
+
}), this.attribute[key] = nextValue);
|
|
338
402
|
}
|
|
339
|
-
this.
|
|
403
|
+
delta.size && (this.attributeMayContainTransientAttrs = !0), this.valid = this.isValid(),
|
|
404
|
+
this.submitUpdateByDelta(delta, forceUpdateTag), this.onAttributeUpdate(context);
|
|
340
405
|
}
|
|
341
406
|
_restoreAttributeFromStaticTruth(context) {
|
|
342
407
|
this._syncFinalAttributeFromStaticTruth();
|
|
343
408
|
const delta = this._syncAttribute();
|
|
344
409
|
this.submitUpdateByDelta(delta), this.onAttributeUpdate(context);
|
|
345
410
|
}
|
|
411
|
+
collectStatePatchDeltaKeys(previousPatch, nextPatch) {
|
|
412
|
+
const keys = previousPatch ? Object.keys(previousPatch) : [];
|
|
413
|
+
if (!nextPatch) return keys;
|
|
414
|
+
for (const key in nextPatch) Object.prototype.hasOwnProperty.call(nextPatch, key) && !Object.prototype.hasOwnProperty.call(null != previousPatch ? previousPatch : {}, key) && keys.push(key);
|
|
415
|
+
return keys;
|
|
416
|
+
}
|
|
417
|
+
getStaticTruthValueForStateKey(key, nextPatch) {
|
|
418
|
+
var _a;
|
|
419
|
+
const baseAttributes = null !== (_a = this.baseAttributes) && void 0 !== _a ? _a : {}, patch = nextPatch;
|
|
420
|
+
if (patch && Object.prototype.hasOwnProperty.call(patch, key)) {
|
|
421
|
+
const patchValue = patch[key], baseValue = baseAttributes[key];
|
|
422
|
+
return "deep" === this.stateMergeMode && isPlainObjectValue(baseValue) && isPlainObjectValue(patchValue) ? {
|
|
423
|
+
hasValue: !0,
|
|
424
|
+
value: deepMergeAttributeValue(baseValue, patchValue)
|
|
425
|
+
} : {
|
|
426
|
+
hasValue: !0,
|
|
427
|
+
value: patchValue
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
return Object.prototype.hasOwnProperty.call(baseAttributes, key) ? {
|
|
431
|
+
hasValue: !0,
|
|
432
|
+
value: baseAttributes[key]
|
|
433
|
+
} : {
|
|
434
|
+
hasValue: !1,
|
|
435
|
+
value: void 0
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
syncStatePatchDeltaToTarget(target, keys, nextPatch, collectCategory = !1) {
|
|
439
|
+
let category = attribute_update_classifier_1.UpdateCategory.NONE;
|
|
440
|
+
for (let i = 0; i < keys.length; i++) {
|
|
441
|
+
const key = keys[i], previousValue = target[key], next = this.getStaticTruthValueForStateKey(key, nextPatch);
|
|
442
|
+
if (!next.hasValue) {
|
|
443
|
+
Object.prototype.hasOwnProperty.call(target, key) && (delete target[key], collectCategory && (category = this.mergeAttributeDeltaCategory(category, key, previousValue, void 0)));
|
|
444
|
+
continue;
|
|
445
|
+
}
|
|
446
|
+
if (areAttributeValuesEqual(previousValue, next.value)) continue;
|
|
447
|
+
const nextValue = cloneAttributeValue(next.value);
|
|
448
|
+
target[key] = nextValue, collectCategory && (category = this.mergeAttributeDeltaCategory(category, key, previousValue, nextValue));
|
|
449
|
+
}
|
|
450
|
+
return category;
|
|
451
|
+
}
|
|
452
|
+
restoreAttributeFromStatePatchDelta(previousPatch, nextPatch, context) {
|
|
453
|
+
this.detachAttributeFromBaseAttributes();
|
|
454
|
+
const keys = this.collectStatePatchDeltaKeys(previousPatch, nextPatch), finalAttribute = this.finalAttribute;
|
|
455
|
+
finalAttribute && this.syncStatePatchDeltaToTarget(finalAttribute, keys, nextPatch, !1);
|
|
456
|
+
const category = this.syncStatePatchDeltaToTarget(this.attribute, keys, nextPatch, !0);
|
|
457
|
+
this.valid = this.isValid(), this.attributeMayContainTransientAttrs = !1, this.submitUpdateByCategory(category),
|
|
458
|
+
this.onAttributeUpdate(context);
|
|
459
|
+
}
|
|
346
460
|
setMode(mode) {
|
|
347
461
|
"3d" === mode ? this.set3dMode() : this.set2dMode();
|
|
348
462
|
}
|
|
@@ -362,7 +476,7 @@ class Graphic extends node_tree_1.Node {
|
|
|
362
476
|
return point;
|
|
363
477
|
}
|
|
364
478
|
onAnimateBind(animate) {
|
|
365
|
-
this._emitCustomEvent("animate-bind", animate);
|
|
479
|
+
this.detachAttributeFromBaseAttributes(), this._emitCustomEvent("animate-bind", animate);
|
|
366
480
|
}
|
|
367
481
|
visitTrackedAnimates(cb) {
|
|
368
482
|
const hook = this.forEachTrackedAnimate;
|
|
@@ -375,8 +489,22 @@ class Graphic extends node_tree_1.Node {
|
|
|
375
489
|
const getTrackedAnimates = this.getTrackedAnimates;
|
|
376
490
|
return "function" == typeof getTrackedAnimates ? getTrackedAnimates.call(this).size > 0 : !!(null === (_a = this.animates) || void 0 === _a ? void 0 : _a.size);
|
|
377
491
|
}
|
|
492
|
+
mayHaveTrackedAnimates() {
|
|
493
|
+
var _a;
|
|
494
|
+
return !!(null === (_a = this.animates) || void 0 === _a ? void 0 : _a.size) || !!this._animationStateManager;
|
|
495
|
+
}
|
|
378
496
|
tryUpdateAABBBounds() {
|
|
497
|
+
if (!(this.shadowRoot || this._updateTag & enums_1.UpdateTag.UPDATE_BOUNDS)) return this._AABBBounds;
|
|
379
498
|
const full = "imprecise" === this.attribute.boundsMode;
|
|
499
|
+
if (!this.shadowRoot) {
|
|
500
|
+
const graphicService = this.getGraphicService(), graphicTheme = this.getGraphicTheme();
|
|
501
|
+
if (!graphicService.validCheck(this.attribute, graphicTheme, this._AABBBounds, this)) return this._AABBBounds;
|
|
502
|
+
if (!this.valid) return this._AABBBounds.clear(), this._AABBBounds;
|
|
503
|
+
graphicService.beforeUpdateAABBBounds(this, this.stage, !0, this._AABBBounds);
|
|
504
|
+
const bounds = this.doUpdateAABBBounds(full, graphicTheme);
|
|
505
|
+
return graphicService.afterUpdateAABBBounds(this, this.stage, this._AABBBounds, this, !0),
|
|
506
|
+
"empty" === this.attribute.boundsMode && bounds.clear(), bounds;
|
|
507
|
+
}
|
|
380
508
|
if (!this.shouldUpdateAABBBounds()) return this._AABBBounds;
|
|
381
509
|
if (!this.valid) return this._AABBBounds.clear(), this._AABBBounds;
|
|
382
510
|
this.getGraphicService().beforeUpdateAABBBounds(this, this.stage, !0, this._AABBBounds);
|
|
@@ -442,11 +570,11 @@ class Graphic extends node_tree_1.Node {
|
|
|
442
570
|
const _parsedPath = new builtin_symbol_1.CustomSymbolClass(symbolType, cache);
|
|
443
571
|
return Graphic.userSymbolMap[symbolType] = _parsedPath, _parsedPath;
|
|
444
572
|
}
|
|
445
|
-
doUpdateAABBBounds(full) {
|
|
573
|
+
doUpdateAABBBounds(full, graphicTheme) {
|
|
446
574
|
this.updateAABBBoundsStamp++;
|
|
447
|
-
const
|
|
575
|
+
const resolvedGraphicTheme = null != graphicTheme ? graphicTheme : this.getGraphicTheme();
|
|
448
576
|
this._AABBBounds.clear();
|
|
449
|
-
const attribute = this.attribute, bounds = this.updateAABBBounds(attribute,
|
|
577
|
+
const attribute = this.attribute, bounds = this.updateAABBBounds(attribute, resolvedGraphicTheme, this._AABBBounds, full), {boundsPadding: boundsPadding = resolvedGraphicTheme.boundsPadding} = attribute, paddingArray = (0,
|
|
450
578
|
utils_1.parsePadding)(boundsPadding);
|
|
451
579
|
return paddingArray && bounds.expand(paddingArray), this.clearUpdateBoundTag(),
|
|
452
580
|
bounds;
|
|
@@ -559,19 +687,24 @@ class Graphic extends node_tree_1.Node {
|
|
|
559
687
|
}
|
|
560
688
|
setAttributes(params, forceUpdateTag = !1, context) {
|
|
561
689
|
params && ((params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate(params, this.attribute, null, context) || params).background && this.loadImage(params.background, !0),
|
|
562
|
-
isExternalTexture(params.texture) && this.loadImage(params.texture, !1),
|
|
563
|
-
this._setAttributes(params, forceUpdateTag, context));
|
|
690
|
+
params.texture && isExternalTexture(params.texture) && this.loadImage(params.texture, !1),
|
|
691
|
+
params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic), this._setAttributes(params, forceUpdateTag, context));
|
|
564
692
|
}
|
|
565
693
|
_setAttributes(params, forceUpdateTag = !1, context) {
|
|
566
|
-
this.
|
|
694
|
+
this.canCommitBaseAttributesByTouchedKeys() ? this.commitBaseAttributesByTouchedKeys(params, forceUpdateTag, context) : (this.detachAttributeFromBaseAttributes(),
|
|
695
|
+
this.applyBaseAttributes(params), this.commitBaseAttributeMutation(forceUpdateTag, context));
|
|
567
696
|
}
|
|
568
697
|
setAttribute(key, value, forceUpdateTag, context) {
|
|
569
698
|
const params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate({
|
|
570
699
|
[key]: value
|
|
571
700
|
}, this.attribute, key, context);
|
|
572
|
-
params
|
|
573
|
-
|
|
574
|
-
|
|
701
|
+
if (params) this._setAttributes(params, forceUpdateTag, context); else if (this.canCommitBaseAttributesByTouchedKeys()) this.commitBaseAttributeBySingleKey(key, value, !!forceUpdateTag, context); else {
|
|
702
|
+
const nextAttrs = {
|
|
703
|
+
[key]: value
|
|
704
|
+
};
|
|
705
|
+
this.applyBaseAttributes(nextAttrs), this.commitBaseAttributeMutation(!!forceUpdateTag, context);
|
|
706
|
+
}
|
|
707
|
+
"background" === key ? this.loadImage(value, !0) : "texture" === key && isExternalTexture(value) ? this.loadImage(value, !1) : "shadowGraphic" === key && this.setShadowGraphic(value);
|
|
575
708
|
}
|
|
576
709
|
needUpdateTags(keys, k = exports.GRAPHIC_UPDATE_TAG_KEY) {
|
|
577
710
|
for (let i = 0; i < k.length; i++) {
|
|
@@ -591,10 +724,11 @@ class Graphic extends node_tree_1.Node {
|
|
|
591
724
|
type: enums_1.AttributeUpdateType.INIT
|
|
592
725
|
};
|
|
593
726
|
params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate(params, this.attribute, null, context) || params,
|
|
594
|
-
this.
|
|
595
|
-
this.
|
|
596
|
-
isExternalTexture(params.texture) && this.loadImage(params.texture, !1),
|
|
597
|
-
|
|
727
|
+
this.attribute = params, this._baseAttributes = void 0, this.resolvedStatePatch = void 0,
|
|
728
|
+
this.attributeMayContainTransientAttrs = !1, this.valid = this.isValid(), params.background && this.loadImage(params.background, !0),
|
|
729
|
+
params.texture && isExternalTexture(params.texture) && this.loadImage(params.texture, !1),
|
|
730
|
+
params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic), this._updateTag = enums_1.UpdateTag.INIT,
|
|
731
|
+
this.valid = this.isValid(), this.onAttributeUpdate(context);
|
|
598
732
|
}
|
|
599
733
|
translate(x, y) {
|
|
600
734
|
var _a, _b;
|
|
@@ -605,11 +739,15 @@ class Graphic extends node_tree_1.Node {
|
|
|
605
739
|
x: x,
|
|
606
740
|
y: y
|
|
607
741
|
}, this.attribute, tempConstantXYKey, context);
|
|
608
|
-
params && (x = params.x, y = params.y, delete params.x, delete params.y
|
|
609
|
-
const attribute = this.baseAttributes, postMatrix = attribute.postMatrix;
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
742
|
+
params && (x = params.x, y = params.y, delete params.x, delete params.y);
|
|
743
|
+
const attribute = this.baseAttributes, postMatrix = attribute.postMatrix, nextAttrs = params || {};
|
|
744
|
+
if (postMatrix) {
|
|
745
|
+
const nextPostMatrix = postMatrix.clone();
|
|
746
|
+
application_1.application.transformUtil.fromMatrix(nextPostMatrix, nextPostMatrix).translate(x, y),
|
|
747
|
+
nextAttrs.postMatrix = nextPostMatrix;
|
|
748
|
+
} else nextAttrs.x = (null !== (_a = attribute.x) && void 0 !== _a ? _a : config_1.DefaultTransform.x) + x,
|
|
749
|
+
nextAttrs.y = (null !== (_b = attribute.y) && void 0 !== _b ? _b : config_1.DefaultTransform.y) + y;
|
|
750
|
+
return this.commitInternalBaseAttributes(nextAttrs, context), this;
|
|
613
751
|
}
|
|
614
752
|
translateTo(x, y) {
|
|
615
753
|
const attribute = this.baseAttributes;
|
|
@@ -620,9 +758,10 @@ class Graphic extends node_tree_1.Node {
|
|
|
620
758
|
x: x,
|
|
621
759
|
y: y
|
|
622
760
|
}, this.attribute, tempConstantXYKey, context);
|
|
623
|
-
return params ? (this.
|
|
624
|
-
|
|
625
|
-
|
|
761
|
+
return params ? (this.commitInternalBaseAttributes(params, context), this) : (this.commitInternalBaseAttributes({
|
|
762
|
+
x: x,
|
|
763
|
+
y: y
|
|
764
|
+
}, context), this);
|
|
626
765
|
}
|
|
627
766
|
scale(scaleX, scaleY, scaleCenter) {
|
|
628
767
|
var _a, _b;
|
|
@@ -635,15 +774,15 @@ class Graphic extends node_tree_1.Node {
|
|
|
635
774
|
scaleCenter: scaleCenter
|
|
636
775
|
}, this.attribute, tempConstantScaleXYKey, context);
|
|
637
776
|
params && (scaleX = params.scaleX, scaleY = params.scaleY, delete params.scaleX,
|
|
638
|
-
delete params.scaleY
|
|
639
|
-
const attribute = this.baseAttributes;
|
|
777
|
+
delete params.scaleY);
|
|
778
|
+
const attribute = this.baseAttributes, nextAttrs = params || {};
|
|
640
779
|
if (scaleCenter) {
|
|
641
|
-
let {postMatrix: postMatrix} = this.
|
|
642
|
-
postMatrix
|
|
643
|
-
|
|
644
|
-
} else
|
|
645
|
-
|
|
646
|
-
return this.
|
|
780
|
+
let {postMatrix: postMatrix} = this.baseAttributes;
|
|
781
|
+
postMatrix = postMatrix ? postMatrix.clone() : new vutils_1.Matrix, application_1.application.transformUtil.fromMatrix(postMatrix, postMatrix).scale(scaleX, scaleY, scaleCenter),
|
|
782
|
+
nextAttrs.postMatrix = postMatrix;
|
|
783
|
+
} else nextAttrs.scaleX = (null !== (_a = attribute.scaleX) && void 0 !== _a ? _a : config_1.DefaultTransform.scaleX) * scaleX,
|
|
784
|
+
nextAttrs.scaleY = (null !== (_b = attribute.scaleY) && void 0 !== _b ? _b : config_1.DefaultTransform.scaleY) * scaleY;
|
|
785
|
+
return this.commitInternalBaseAttributes(nextAttrs, context), this;
|
|
647
786
|
}
|
|
648
787
|
scaleTo(scaleX, scaleY) {
|
|
649
788
|
const attribute = this.baseAttributes;
|
|
@@ -654,9 +793,10 @@ class Graphic extends node_tree_1.Node {
|
|
|
654
793
|
scaleX: scaleX,
|
|
655
794
|
scaleY: scaleY
|
|
656
795
|
}, this.attribute, tempConstantScaleXYKey, context);
|
|
657
|
-
return params ? (this.
|
|
658
|
-
|
|
659
|
-
|
|
796
|
+
return params ? (this.commitInternalBaseAttributes(params, context), this) : (this.commitInternalBaseAttributes({
|
|
797
|
+
scaleX: scaleX,
|
|
798
|
+
scaleY: scaleY
|
|
799
|
+
}, context), this);
|
|
660
800
|
}
|
|
661
801
|
rotate(angle, rotateCenter) {
|
|
662
802
|
var _a;
|
|
@@ -667,24 +807,23 @@ class Graphic extends node_tree_1.Node {
|
|
|
667
807
|
angle: angle,
|
|
668
808
|
rotateCenter: rotateCenter
|
|
669
809
|
}, this.attribute, tempConstantAngleKey, context);
|
|
670
|
-
params &&
|
|
671
|
-
const attribute = this.baseAttributes;
|
|
810
|
+
params && delete params.angle;
|
|
811
|
+
const attribute = this.baseAttributes, nextAttrs = params || {};
|
|
672
812
|
if (rotateCenter) {
|
|
673
813
|
let {postMatrix: postMatrix} = this.baseAttributes;
|
|
674
|
-
postMatrix
|
|
675
|
-
|
|
676
|
-
} else
|
|
677
|
-
return this.
|
|
814
|
+
postMatrix = postMatrix ? postMatrix.clone() : new vutils_1.Matrix, application_1.application.transformUtil.fromMatrix(postMatrix, postMatrix).rotate(angle, rotateCenter),
|
|
815
|
+
nextAttrs.postMatrix = postMatrix;
|
|
816
|
+
} else nextAttrs.angle = (null !== (_a = attribute.angle) && void 0 !== _a ? _a : config_1.DefaultTransform.angle) + angle;
|
|
817
|
+
return this.commitInternalBaseAttributes(nextAttrs, context), this;
|
|
678
818
|
}
|
|
679
819
|
rotateTo(angle) {
|
|
680
|
-
|
|
681
|
-
if (attribute.angle === angle) return this;
|
|
820
|
+
if (this.baseAttributes.angle === angle) return this;
|
|
682
821
|
const context = {
|
|
683
822
|
type: enums_1.AttributeUpdateType.ROTATE_TO
|
|
684
823
|
}, params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate(angle, this.attribute, tempConstantAngleKey, context);
|
|
685
|
-
return params ? (this.
|
|
686
|
-
|
|
687
|
-
this);
|
|
824
|
+
return params ? (this.commitInternalBaseAttributes(params, context), this) : (this.commitInternalBaseAttributes({
|
|
825
|
+
angle: angle
|
|
826
|
+
}, context), this);
|
|
688
827
|
}
|
|
689
828
|
skewTo(b, c) {
|
|
690
829
|
return this;
|
|
@@ -725,6 +864,119 @@ class Graphic extends node_tree_1.Node {
|
|
|
725
864
|
stateEngine: this.stateEngine
|
|
726
865
|
});
|
|
727
866
|
}
|
|
867
|
+
resolveSimpleLocalStateTransition(states, previousStates) {
|
|
868
|
+
var _a;
|
|
869
|
+
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;
|
|
870
|
+
if (1 === states.length) {
|
|
871
|
+
const stateName = states[0], hasDefinition = Object.prototype.hasOwnProperty.call(this.states, stateName), nextStates = [ stateName ], changed = !this.sameStateNames(previousStates, nextStates), resolvedStateAttrs = {};
|
|
872
|
+
if (hasDefinition) {
|
|
873
|
+
const attrs = this.states[stateName];
|
|
874
|
+
if (null != attrs) {
|
|
875
|
+
if (!isPlainObjectValue(attrs)) return null;
|
|
876
|
+
const keys = Object.keys(attrs);
|
|
877
|
+
for (let keyIndex = 0; keyIndex < keys.length; keyIndex++) {
|
|
878
|
+
const key = keys[keyIndex];
|
|
879
|
+
if (FULL_STATE_DEFINITION_KEYS.has(key)) return null;
|
|
880
|
+
const attrValue = attrs[key];
|
|
881
|
+
resolvedStateAttrs[key] = isPlainObjectValue(attrValue) ? cloneAttributeValue(attrValue) : attrValue;
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
return {
|
|
886
|
+
changed: changed,
|
|
887
|
+
states: nextStates,
|
|
888
|
+
effectiveStates: nextStates,
|
|
889
|
+
resolvedStateAttrs: resolvedStateAttrs
|
|
890
|
+
};
|
|
891
|
+
}
|
|
892
|
+
const uniqueStates = Array.from(new Set(states)), withDefinition = [], withoutDefinition = [];
|
|
893
|
+
for (let i = 0; i < uniqueStates.length; i++) {
|
|
894
|
+
const stateName = uniqueStates[i];
|
|
895
|
+
Object.prototype.hasOwnProperty.call(this.states, stateName) ? withDefinition.push(stateName) : withoutDefinition.push(stateName);
|
|
896
|
+
}
|
|
897
|
+
withDefinition.sort(((left, right) => left.localeCompare(right)));
|
|
898
|
+
const nextStates = withDefinition.concat(withoutDefinition), changed = !this.sameStateNames(previousStates, nextStates), resolvedStateAttrs = {};
|
|
899
|
+
for (let i = 0; i < nextStates.length; i++) {
|
|
900
|
+
const stateName = nextStates[i];
|
|
901
|
+
if (!Object.prototype.hasOwnProperty.call(this.states, stateName)) continue;
|
|
902
|
+
const attrs = this.states[stateName];
|
|
903
|
+
if (null == attrs) continue;
|
|
904
|
+
if (!isPlainObjectValue(attrs)) return null;
|
|
905
|
+
const keys = Object.keys(attrs);
|
|
906
|
+
for (let keyIndex = 0; keyIndex < keys.length; keyIndex++) {
|
|
907
|
+
const key = keys[keyIndex];
|
|
908
|
+
if (FULL_STATE_DEFINITION_KEYS.has(key)) return null;
|
|
909
|
+
const attrValue = attrs[key];
|
|
910
|
+
resolvedStateAttrs[key] = isPlainObjectValue(attrValue) ? cloneAttributeValue(attrValue) : attrValue;
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
return {
|
|
914
|
+
changed: changed,
|
|
915
|
+
states: nextStates,
|
|
916
|
+
effectiveStates: nextStates,
|
|
917
|
+
resolvedStateAttrs: resolvedStateAttrs
|
|
918
|
+
};
|
|
919
|
+
}
|
|
920
|
+
resolveGraphicStateTransition(states, previousStates, forceResolverRefresh = !1) {
|
|
921
|
+
var _a, _b, _c, _d;
|
|
922
|
+
let transition = this.resolveSimpleLocalStateTransition(states, previousStates);
|
|
923
|
+
const isSimpleLocalTransition = !!transition;
|
|
924
|
+
let resolvedStateAttrs;
|
|
925
|
+
if (transition) resolvedStateAttrs = transition.resolvedStateAttrs; else {
|
|
926
|
+
const stateResolveBaseAttrs = null !== (_a = this.baseAttributes) && void 0 !== _a ? _a : this.attribute, stateModel = this.createStateModel();
|
|
927
|
+
null === (_b = this.stateEngine) || void 0 === _b || _b.setResolveContext(this, stateResolveBaseAttrs),
|
|
928
|
+
forceResolverRefresh && (null === (_c = this.stateEngine) || void 0 === _c || _c.invalidateResolverCache()),
|
|
929
|
+
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);
|
|
930
|
+
}
|
|
931
|
+
return {
|
|
932
|
+
transition: transition,
|
|
933
|
+
effectiveStates: null !== (_d = transition.effectiveStates) && void 0 !== _d ? _d : transition.states,
|
|
934
|
+
resolvedStateAttrs: resolvedStateAttrs,
|
|
935
|
+
isSimpleLocalTransition: isSimpleLocalTransition
|
|
936
|
+
};
|
|
937
|
+
}
|
|
938
|
+
normalizeSetStatesOptions(options) {
|
|
939
|
+
return options && "object" == typeof options ? {
|
|
940
|
+
hasAnimation: options.animate,
|
|
941
|
+
animateSameStatePatchChange: !0 === options.animateSameStatePatchChange,
|
|
942
|
+
shouldRefreshSameStatePatch: !0
|
|
943
|
+
} : {
|
|
944
|
+
hasAnimation: "boolean" == typeof options ? options : void 0,
|
|
945
|
+
animateSameStatePatchChange: !1,
|
|
946
|
+
shouldRefreshSameStatePatch: !1
|
|
947
|
+
};
|
|
948
|
+
}
|
|
949
|
+
sameStatePatches(left, right) {
|
|
950
|
+
const leftRecord = null != left ? left : {}, rightRecord = null != right ? right : {}, keys = new Set([ ...Object.keys(leftRecord), ...Object.keys(rightRecord) ]);
|
|
951
|
+
for (const key of keys) {
|
|
952
|
+
if (Object.prototype.hasOwnProperty.call(leftRecord, key) !== Object.prototype.hasOwnProperty.call(rightRecord, key)) return !1;
|
|
953
|
+
if (!areAttributeValuesEqual(leftRecord[key], rightRecord[key])) return !1;
|
|
954
|
+
}
|
|
955
|
+
return !0;
|
|
956
|
+
}
|
|
957
|
+
commitSameStatePatchRefresh(states, hasAnimation, animateSameStatePatchChange = !1) {
|
|
958
|
+
var _a;
|
|
959
|
+
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);
|
|
960
|
+
if ((!patchChanged || this.beforeStateUpdate(resolvedStateAttrs, previousStates, transition.states, hasAnimation, !1)) && (this.currentStates = transition.states,
|
|
961
|
+
this.effectiveStates = isSimpleLocalTransition ? effectiveStates : [ ...effectiveStates ],
|
|
962
|
+
this.resolvedStatePatch = resolvedStateAttrs, this.sharedStateDirty = !1, this.syncSharedStateActiveRegistrations(),
|
|
963
|
+
patchChanged)) {
|
|
964
|
+
if (this.stage) {
|
|
965
|
+
const perfMonitor = (0, state_perf_monitor_1.getActiveStageStatePerfMonitor)(this.stage);
|
|
966
|
+
null == perfMonitor || perfMonitor.incrementCounter("stateCommits"), null == perfMonitor || perfMonitor.recordEvent("state-commit", {
|
|
967
|
+
graphicId: this._uid,
|
|
968
|
+
targetStates: [ ...transition.states ]
|
|
969
|
+
});
|
|
970
|
+
}
|
|
971
|
+
hasAnimation && animateSameStatePatchChange ? (this._syncFinalAttributeFromStaticTruth(),
|
|
972
|
+
this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !1, void 0, this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch))) : (this.stopStateAnimates(),
|
|
973
|
+
this.attributeMayContainTransientAttrs ? this._restoreAttributeFromStaticTruth({
|
|
974
|
+
type: enums_1.AttributeUpdateType.STATE
|
|
975
|
+
}) : this.restoreAttributeFromStatePatchDelta(previousResolvedStatePatch, this.resolvedStatePatch, {
|
|
976
|
+
type: enums_1.AttributeUpdateType.STATE
|
|
977
|
+
}), this.emitStateUpdateEvent());
|
|
978
|
+
}
|
|
979
|
+
}
|
|
728
980
|
resolveStateAnimateConfig(animateConfig) {
|
|
729
981
|
var _a, _b, _c;
|
|
730
982
|
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;
|
|
@@ -744,9 +996,7 @@ class Graphic extends node_tree_1.Node {
|
|
|
744
996
|
});
|
|
745
997
|
this.getStateTransitionOrchestrator().applyTransition(this, plan, hasAnimation, transitionOptions);
|
|
746
998
|
}
|
|
747
|
-
updateNormalAttrs(
|
|
748
|
-
this._deprecatedNormalAttrsView = cloneAttributeValue(this.baseAttributes);
|
|
749
|
-
}
|
|
999
|
+
updateNormalAttrs(_stateAttrs) {}
|
|
750
1000
|
getStateTransitionDefaultAttribute(key, targetAttrs) {
|
|
751
1001
|
return this.getDefaultAttribute(key);
|
|
752
1002
|
}
|
|
@@ -756,6 +1006,7 @@ class Graphic extends node_tree_1.Node {
|
|
|
756
1006
|
stopStateAnimates(type = "end") {
|
|
757
1007
|
const stopAnimationState = this.stopAnimationState;
|
|
758
1008
|
if ("function" == typeof stopAnimationState) return void stopAnimationState.call(this, "state", type);
|
|
1009
|
+
if (!this.mayHaveTrackedAnimates()) return;
|
|
759
1010
|
const stateAnimates = [];
|
|
760
1011
|
this.visitTrackedAnimates((animate => {
|
|
761
1012
|
animate.stateNames && stateAnimates.push(animate);
|
|
@@ -768,23 +1019,27 @@ class Graphic extends node_tree_1.Node {
|
|
|
768
1019
|
}
|
|
769
1020
|
clearStates(hasAnimation) {
|
|
770
1021
|
var _a, _b, _c;
|
|
771
|
-
const previousStates =
|
|
1022
|
+
const previousStates = null !== (_a = this.currentStates) && void 0 !== _a ? _a : EMPTY_STATE_NAMES, previousResolvedStatePatch = this.resolvedStatePatch, transition = this.createStateModel().clearStates();
|
|
772
1023
|
if (!transition.changed && 0 === previousStates.length) return this.currentStates = [],
|
|
773
1024
|
this.effectiveStates = [], this.resolvedStatePatch = void 0, this.sharedStateDirty = !1,
|
|
774
1025
|
void this.clearSharedStateActiveRegistrations();
|
|
775
|
-
const resolvedStateAttrs = cloneAttributeValue(null !== (
|
|
776
|
-
transition.changed
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
1026
|
+
const resolvedStateAttrs = hasAnimation || this.hasCustomEvent("beforeStateUpdate") ? cloneAttributeValue(null !== (_b = this.baseAttributes) && void 0 !== _b ? _b : {}) : null !== (_c = this.baseAttributes) && void 0 !== _c ? _c : {};
|
|
1027
|
+
if (!transition.changed || this.beforeStateUpdate(resolvedStateAttrs, previousStates, transition.states, hasAnimation, !0)) {
|
|
1028
|
+
if (this.currentStates = transition.states, this.effectiveStates = [], this.resolvedStatePatch = void 0,
|
|
1029
|
+
this.sharedStateDirty = !1, this.clearSharedStateActiveRegistrations(), this.stage) {
|
|
1030
|
+
const perfMonitor = (0, state_perf_monitor_1.getActiveStageStatePerfMonitor)(this.stage);
|
|
1031
|
+
null == perfMonitor || perfMonitor.incrementCounter("stateCommits"), null == perfMonitor || perfMonitor.recordEvent("state-commit", {
|
|
1032
|
+
graphicId: this._uid,
|
|
1033
|
+
targetStates: []
|
|
1034
|
+
});
|
|
1035
|
+
}
|
|
1036
|
+
hasAnimation ? (this._syncFinalAttributeFromStaticTruth(), this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !0, void 0, this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch))) : (this.stopStateAnimates(),
|
|
1037
|
+
this.attributeMayContainTransientAttrs ? this._restoreAttributeFromStaticTruth({
|
|
1038
|
+
type: enums_1.AttributeUpdateType.STATE
|
|
1039
|
+
}) : this.restoreAttributeFromStatePatchDelta(previousResolvedStatePatch, void 0, {
|
|
1040
|
+
type: enums_1.AttributeUpdateType.STATE
|
|
1041
|
+
}), this.emitStateUpdateEvent());
|
|
1042
|
+
}
|
|
788
1043
|
}
|
|
789
1044
|
removeState(stateName, hasAnimation) {
|
|
790
1045
|
const transition = this.createStateModel().removeState(stateName);
|
|
@@ -798,42 +1053,51 @@ class Graphic extends node_tree_1.Node {
|
|
|
798
1053
|
const transition = this.createStateModel().addState(stateName, keepCurrentStates);
|
|
799
1054
|
transition.changed && this.useStates(transition.states, hasAnimation);
|
|
800
1055
|
}
|
|
1056
|
+
setStates(states, options) {
|
|
1057
|
+
var _a, _b, _c;
|
|
1058
|
+
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));
|
|
1059
|
+
if (nextStates.length) {
|
|
1060
|
+
if (this.sameStateNames(this.currentStates, nextStates)) return shouldRefreshSameStatePatch ? void this.commitSameStatePatchRefresh(nextStates, hasAnimation, animateSameStatePatchChange) : void (this.sharedStateDirty && this.refreshSharedStateBeforeRender());
|
|
1061
|
+
this.useStates(nextStates, hasAnimation);
|
|
1062
|
+
} else {
|
|
1063
|
+
if (!hasCurrentState && !this.sharedStateDirty) return;
|
|
1064
|
+
this.clearStates(hasAnimation);
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
801
1067
|
useStates(states, hasAnimation) {
|
|
802
|
-
var _a
|
|
1068
|
+
var _a;
|
|
803
1069
|
if (!states.length) return void this.clearStates(hasAnimation);
|
|
804
|
-
const previousStates =
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
}
|
|
1070
|
+
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);
|
|
1071
|
+
if ((transition.changed || !this.sameStateNames(previousStates, transition.states)) && this.beforeStateUpdate(resolvedStateAttrs, previousStates, transition.states, hasAnimation, !1)) {
|
|
1072
|
+
if (this.currentStates = transition.states, this.effectiveStates = isSimpleLocalTransition ? effectiveStates : [ ...effectiveStates ],
|
|
1073
|
+
this.resolvedStatePatch = resolvedStateAttrs, this.sharedStateDirty = !1, this.syncSharedStateActiveRegistrations(),
|
|
1074
|
+
this.stage) {
|
|
1075
|
+
const perfMonitor = (0, state_perf_monitor_1.getActiveStageStatePerfMonitor)(this.stage);
|
|
1076
|
+
null == perfMonitor || perfMonitor.incrementCounter("stateCommits"), null == perfMonitor || perfMonitor.recordEvent("state-commit", {
|
|
1077
|
+
graphicId: this._uid,
|
|
1078
|
+
targetStates: [ ...transition.states ]
|
|
1079
|
+
});
|
|
1080
|
+
}
|
|
1081
|
+
hasAnimation ? (this._syncFinalAttributeFromStaticTruth(), this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !1, void 0, this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch))) : (this.stopStateAnimates(),
|
|
1082
|
+
this.attributeMayContainTransientAttrs ? this._restoreAttributeFromStaticTruth({
|
|
1083
|
+
type: enums_1.AttributeUpdateType.STATE
|
|
1084
|
+
}) : this.restoreAttributeFromStatePatchDelta(previousResolvedStatePatch, this.resolvedStatePatch, {
|
|
1085
|
+
type: enums_1.AttributeUpdateType.STATE
|
|
1086
|
+
}), this.emitStateUpdateEvent());
|
|
1087
|
+
}
|
|
822
1088
|
}
|
|
823
1089
|
invalidateResolver() {
|
|
824
|
-
var _a, _b;
|
|
1090
|
+
var _a, _b, _c;
|
|
825
1091
|
if (!this.stateEngine || !(null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) || !this.compiledStateDefinitions) return;
|
|
826
1092
|
const stateResolveBaseAttrs = null !== (_b = this.baseAttributes) && void 0 !== _b ? _b : this.attribute;
|
|
827
|
-
this.stateEngine.setResolveContext(this, stateResolveBaseAttrs), this.resolverEpoch
|
|
1093
|
+
this.stateEngine.setResolveContext(this, stateResolveBaseAttrs), this.resolverEpoch = (null !== (_c = this.resolverEpoch) && void 0 !== _c ? _c : 0) + 1,
|
|
828
1094
|
this.stateEngine.invalidateResolverCache();
|
|
829
1095
|
const transition = this.stateEngine.applyStates(this.currentStates), resolvedStateAttrs = Object.assign({}, this.stateEngine.resolvedPatch);
|
|
830
|
-
this.effectiveStates = [ ...transition.effectiveStates ], this.resolvedStatePatch =
|
|
1096
|
+
this.effectiveStates = [ ...transition.effectiveStates ], this.resolvedStatePatch = resolvedStateAttrs,
|
|
831
1097
|
this.sharedStateDirty = !1, this.syncSharedStateActiveRegistrations(), this.stopStateAnimates(),
|
|
832
1098
|
this._restoreAttributeFromStaticTruth({
|
|
833
1099
|
type: enums_1.AttributeUpdateType.STATE
|
|
834
|
-
}), this.
|
|
835
|
-
type: enums_1.AttributeUpdateType.STATE
|
|
836
|
-
});
|
|
1100
|
+
}), this.emitStateUpdateEvent();
|
|
837
1101
|
}
|
|
838
1102
|
sameStateNames(left, right) {
|
|
839
1103
|
const normalizedLeft = null != left ? left : [], normalizedRight = null != right ? right : [];
|
|
@@ -855,6 +1119,10 @@ class Graphic extends node_tree_1.Node {
|
|
|
855
1119
|
this._updateTag |= enums_1.UpdateTag.UPDATE_SHAPE_AND_BOUNDS, this.parent && this.parent.addChildUpdateBoundTag(),
|
|
856
1120
|
this.glyphHost && this.glyphHost.addUpdateBoundTag();
|
|
857
1121
|
}
|
|
1122
|
+
addBroadUpdateTag() {
|
|
1123
|
+
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,
|
|
1124
|
+
this.parent && this.parent.addChildUpdateBoundTag(), this.glyphHost && this.glyphHost.addUpdateBoundTag();
|
|
1125
|
+
}
|
|
858
1126
|
updateShapeAndBoundsTagSetted() {
|
|
859
1127
|
return (this._updateTag & enums_1.UpdateTag.UPDATE_SHAPE_AND_BOUNDS) === enums_1.UpdateTag.UPDATE_SHAPE_AND_BOUNDS;
|
|
860
1128
|
}
|
|
@@ -929,12 +1197,12 @@ class Graphic extends node_tree_1.Node {
|
|
|
929
1197
|
}
|
|
930
1198
|
}
|
|
931
1199
|
setStage(stage, layer) {
|
|
932
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1200
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
933
1201
|
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;
|
|
934
1202
|
if (this.stage !== stage || this.layer !== layer) {
|
|
935
|
-
if (this.stage = stage, this.layer = layer,
|
|
936
|
-
this.setStageToShadowRoot(stage, layer), this.hasAnyTrackedAnimate()) {
|
|
937
|
-
const previousTimeline = null === (
|
|
1203
|
+
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),
|
|
1204
|
+
this.setStageToShadowRoot(stage, layer), this.mayHaveTrackedAnimates() && this.hasAnyTrackedAnimate()) {
|
|
1205
|
+
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 = [];
|
|
938
1206
|
this.visitTrackedAnimates((a => {
|
|
939
1207
|
(!!previousTimeline && a.timeline === previousTimeline || a.timeline.isGlobal) && (nextTimeline ? a.timeline !== nextTimeline && (previousTimeline && a.timeline === previousTimeline && previousTimeline.removeAnimate(a, !1),
|
|
940
1208
|
a.setTimeline(nextTimeline), nextTimeline.addAnimate(a)) : previousTimeline && a.timeline === previousTimeline && (previousTimeline.removeAnimate(a, !1),
|
|
@@ -948,9 +1216,18 @@ class Graphic extends node_tree_1.Node {
|
|
|
948
1216
|
type: enums_1.AttributeUpdateType.ANIMATE_END
|
|
949
1217
|
}));
|
|
950
1218
|
}
|
|
951
|
-
return this._onSetStage && this._onSetStage(this, stage, layer), void (null === (
|
|
1219
|
+
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));
|
|
952
1220
|
}
|
|
953
|
-
|
|
1221
|
+
((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);
|
|
1222
|
+
}
|
|
1223
|
+
detachStageForRelease() {
|
|
1224
|
+
var _a, _b, _c;
|
|
1225
|
+
(null === (_a = this.registeredActiveScopes) || void 0 === _a ? void 0 : _a.size) && this.clearSharedStateActiveRegistrations(),
|
|
1226
|
+
(this.mayHaveTrackedAnimates() || this.shadowRoot) && this.stopAnimates(), this.boundSharedStateScope = void 0,
|
|
1227
|
+
this.boundSharedStateRevision = void 0, this.localFallbackCompiledDefinitions = void 0,
|
|
1228
|
+
this.compiledStateDefinitions = void 0, this.compiledStateDefinitionsCacheKey = void 0,
|
|
1229
|
+
this.stateEngine = void 0, this.stateEngineCompiledDefinitions = void 0, this.stateEngineStateProxyModeKey = void 0,
|
|
1230
|
+
this.sharedStateDirty = !1, this.stage = null, this.layer = null, this.shadowRoot && (null === (_c = (_b = this.shadowRoot).detachStageForRelease) || void 0 === _c || _c.call(_b));
|
|
954
1231
|
}
|
|
955
1232
|
setStageToShadowRoot(stage, layer) {
|
|
956
1233
|
this.shadowRoot && this.shadowRoot.setStage(stage, layer);
|
|
@@ -1025,6 +1302,7 @@ class Graphic extends node_tree_1.Node {
|
|
|
1025
1302
|
res && (res.state = "fail", cb && cb());
|
|
1026
1303
|
}
|
|
1027
1304
|
_stopAnimates() {
|
|
1305
|
+
if (!this.mayHaveTrackedAnimates()) return;
|
|
1028
1306
|
const animates = [];
|
|
1029
1307
|
this.visitTrackedAnimates((animate => {
|
|
1030
1308
|
animates.push(animate);
|
|
@@ -1038,15 +1316,19 @@ class Graphic extends node_tree_1.Node {
|
|
|
1038
1316
|
}));
|
|
1039
1317
|
}
|
|
1040
1318
|
release() {
|
|
1041
|
-
var _a, _b, _c;
|
|
1042
|
-
this.releaseStatus = "released", this.
|
|
1043
|
-
|
|
1044
|
-
null
|
|
1319
|
+
var _a, _b, _c, _d;
|
|
1320
|
+
this.releaseStatus = "released", (null === (_a = this.registeredActiveScopes) || void 0 === _a ? void 0 : _a.size) && this.clearSharedStateActiveRegistrations(),
|
|
1321
|
+
(this.mayHaveTrackedAnimates() || this.shadowRoot) && this.stopAnimates();
|
|
1322
|
+
const graphicService = null !== (_c = null === (_b = this.stage) || void 0 === _b ? void 0 : _b.graphicService) && void 0 !== _c ? _c : application_1.application.graphicService;
|
|
1323
|
+
null === (_d = null == graphicService ? void 0 : graphicService.onRelease) || void 0 === _d || _d.call(graphicService, this),
|
|
1045
1324
|
super.release();
|
|
1046
1325
|
}
|
|
1326
|
+
hasCustomEvent(type) {
|
|
1327
|
+
return !!this._events && type in this._events;
|
|
1328
|
+
}
|
|
1047
1329
|
_dispatchCustomEvent(type, context) {
|
|
1048
1330
|
var _a, _b;
|
|
1049
|
-
if (this.
|
|
1331
|
+
if (this.hasCustomEvent(type)) {
|
|
1050
1332
|
const changeEvent = new event_1.CustomEvent(type, context);
|
|
1051
1333
|
changeEvent.bubbles = !1;
|
|
1052
1334
|
const manager = null === (_b = null === (_a = this.stage) || void 0 === _a ? void 0 : _a.eventSystem) || void 0 === _b ? void 0 : _b.manager;
|
|
@@ -1055,7 +1337,7 @@ class Graphic extends node_tree_1.Node {
|
|
|
1055
1337
|
return !0;
|
|
1056
1338
|
}
|
|
1057
1339
|
beforeStateUpdate(attrs, prevStates, nextStates, hasAnimation, isClear) {
|
|
1058
|
-
return this._dispatchCustomEvent("beforeStateUpdate", {
|
|
1340
|
+
return !this.hasCustomEvent("beforeStateUpdate") || this._dispatchCustomEvent("beforeStateUpdate", {
|
|
1059
1341
|
type: enums_1.AttributeUpdateType.STATE,
|
|
1060
1342
|
attrs: Object.assign({}, attrs),
|
|
1061
1343
|
prevStates: prevStates.slice(),
|
|
@@ -1064,6 +1346,11 @@ class Graphic extends node_tree_1.Node {
|
|
|
1064
1346
|
isClear: !!isClear
|
|
1065
1347
|
});
|
|
1066
1348
|
}
|
|
1349
|
+
emitStateUpdateEvent() {
|
|
1350
|
+
this.hasCustomEvent("afterStateUpdate") && this._emitCustomEvent("afterStateUpdate", {
|
|
1351
|
+
type: enums_1.AttributeUpdateType.STATE
|
|
1352
|
+
});
|
|
1353
|
+
}
|
|
1067
1354
|
_emitCustomEvent(type, context) {
|
|
1068
1355
|
this._dispatchCustomEvent(type, context);
|
|
1069
1356
|
}
|