@visactor/vrender-core 1.1.0-alpha.16 → 1.1.0-alpha.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/cjs/core/stage.d.ts +4 -1
  2. package/cjs/core/stage.js +23 -11
  3. package/cjs/core/stage.js.map +1 -1
  4. package/cjs/graphic/graphic-service/graphic-service.d.ts +4 -0
  5. package/cjs/graphic/graphic-service/graphic-service.js +6 -5
  6. package/cjs/graphic/graphic-service/graphic-service.js.map +1 -1
  7. package/cjs/graphic/graphic.d.ts +41 -8
  8. package/cjs/graphic/graphic.js +383 -146
  9. package/cjs/graphic/graphic.js.map +1 -1
  10. package/cjs/graphic/group.d.ts +5 -1
  11. package/cjs/graphic/group.js +37 -18
  12. package/cjs/graphic/group.js.map +1 -1
  13. package/cjs/graphic/state/shared-state-refresh.js +3 -3
  14. package/cjs/graphic/state/shared-state-refresh.js.map +1 -1
  15. package/cjs/graphic/state/shared-state-scope.js +1 -1
  16. package/cjs/graphic/state/shared-state-scope.js.map +1 -1
  17. package/cjs/graphic/state/state-engine.js +2 -2
  18. package/cjs/graphic/state/state-engine.js.map +1 -1
  19. package/cjs/graphic/state/state-perf-monitor.d.ts +1 -0
  20. package/cjs/graphic/state/state-perf-monitor.js +9 -2
  21. package/cjs/graphic/state/state-perf-monitor.js.map +1 -1
  22. package/cjs/graphic/state/state-style-resolver.d.ts +0 -9
  23. package/cjs/graphic/state/state-style-resolver.js +0 -23
  24. package/cjs/graphic/state/state-style-resolver.js.map +1 -1
  25. package/cjs/interface/graphic.d.ts +2 -0
  26. package/cjs/interface/graphic.js.map +1 -1
  27. package/cjs/interface/node-tree.js.map +1 -1
  28. package/cjs/plugins/builtin-plugin/dirty-bounds-plugin.d.ts +4 -1
  29. package/cjs/plugins/builtin-plugin/dirty-bounds-plugin.js +20 -10
  30. package/cjs/plugins/builtin-plugin/dirty-bounds-plugin.js.map +1 -1
  31. package/cjs/plugins/builtin-plugin/flex-layout-plugin.js +3 -2
  32. package/cjs/plugins/builtin-plugin/flex-layout-plugin.js.map +1 -1
  33. package/cjs/render/contributions/render/base-render.js +8 -7
  34. package/cjs/render/contributions/render/base-render.js.map +1 -1
  35. package/dist/index.es.js +806 -263
  36. package/es/core/stage.d.ts +4 -1
  37. package/es/core/stage.js +21 -10
  38. package/es/core/stage.js.map +1 -1
  39. package/es/graphic/graphic-service/graphic-service.d.ts +4 -0
  40. package/es/graphic/graphic-service/graphic-service.js +6 -5
  41. package/es/graphic/graphic-service/graphic-service.js.map +1 -1
  42. package/es/graphic/graphic.d.ts +41 -8
  43. package/es/graphic/graphic.js +379 -139
  44. package/es/graphic/graphic.js.map +1 -1
  45. package/es/graphic/group.d.ts +5 -1
  46. package/es/graphic/group.js +36 -18
  47. package/es/graphic/group.js.map +1 -1
  48. package/es/graphic/state/shared-state-refresh.js +4 -4
  49. package/es/graphic/state/shared-state-refresh.js.map +1 -1
  50. package/es/graphic/state/shared-state-scope.js +2 -2
  51. package/es/graphic/state/shared-state-scope.js.map +1 -1
  52. package/es/graphic/state/state-engine.js +3 -3
  53. package/es/graphic/state/state-engine.js.map +1 -1
  54. package/es/graphic/state/state-perf-monitor.d.ts +1 -0
  55. package/es/graphic/state/state-perf-monitor.js +7 -0
  56. package/es/graphic/state/state-perf-monitor.js.map +1 -1
  57. package/es/graphic/state/state-style-resolver.d.ts +0 -9
  58. package/es/graphic/state/state-style-resolver.js +0 -23
  59. package/es/graphic/state/state-style-resolver.js.map +1 -1
  60. package/es/interface/graphic.d.ts +2 -0
  61. package/es/interface/graphic.js.map +1 -1
  62. package/es/interface/node-tree.js.map +1 -1
  63. package/es/plugins/builtin-plugin/dirty-bounds-plugin.d.ts +4 -1
  64. package/es/plugins/builtin-plugin/dirty-bounds-plugin.js +20 -10
  65. package/es/plugins/builtin-plugin/dirty-bounds-plugin.js.map +1 -1
  66. package/es/plugins/builtin-plugin/flex-layout-plugin.js +3 -2
  67. package/es/plugins/builtin-plugin/flex-layout-plugin.js.map +1 -1
  68. package/es/render/contributions/render/base-render.js +8 -6
  69. package/es/render/contributions/render/base-render.js.map +1 -1
  70. package/package.json +3 -3
@@ -2,17 +2,17 @@
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: !0
5
- }), exports.Graphic = exports.NOWORK_ANIMATE_ATTR = exports.shouldUseSimpleAttributeFastPath = exports.GRAPHIC_UPDATE_TAG_KEY = exports.PURE_STYLE_KEY = void 0;
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 && !(0, vutils_1.isArray)(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.shouldUseSimpleAttributeFastPath = shouldUseSimpleAttributeFastPath, exports.NOWORK_ANIMATE_ATTR = {
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.resolverEpoch = 0, this._AABBBounds = new vutils_1.AABBBounds, this._updateTag = enums_1.UpdateTag.INIT;
110
- const useSimpleAttributeFastPath = shouldUseSimpleAttributeFastPath(params), initialBaseAttributes = useSimpleAttributeFastPath ? cloneSimpleAttributeRecord(params) : cloneAttributeValue(params);
111
- this.baseAttributes = initialBaseAttributes, this.attribute = useSimpleAttributeFastPath ? cloneSimpleAttributeRecord(initialBaseAttributes) : cloneAttributeSurface(initialBaseAttributes),
112
- this.valid = this.isValid(), this.updateAABBBoundsStamp = 0, params.background && this.loadImage(null !== (_a = params.background.background) && void 0 !== _a ? _a : params.background, !0),
113
- isExternalTexture(params.texture) && this.loadImage(params.texture, !1), params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic);
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(value) {
119
- this._deprecatedNormalAttrsView = null != value ? value : void 0;
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
- syncSharedStateActiveRegistrations() {
164
+ syncSharedStateScopeBindingOnTreeChange(markDirty = !0) {
159
165
  var _a, _b;
160
- const nextScopes = (null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) && this.boundSharedStateScope ? new Set((0,
161
- shared_state_scope_1.collectSharedStateScopeChain)(this.boundSharedStateScope)) : new Set;
162
- (null !== (_b = this.registeredActiveScopes) && void 0 !== _b ? _b : new Set).forEach((scope => {
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.syncSharedStateScopeBindingFromTree() : this.setStage(stage, layer);
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._emitCustomEvent("afterStateUpdate", {
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 = Object.assign({}, resolvedStateAttrs), this.syncSharedStateActiveRegistrations();
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
- (0, vutils_1.isEqual)(previousValue, nextValue) || (delta.set(key, {
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(), delta;
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
- submitUpdateByDelta(delta, forceUpdateTag = !1) {
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
- let category = attribute_update_classifier_1.UpdateCategory.NONE;
303
- delta.forEach(((entry, key) => {
304
- let nextCategory = (0, attribute_update_classifier_1.classifyAttributeDelta)(key, entry.prev, entry.next);
305
- nextCategory & attribute_update_classifier_1.UpdateCategory.PICK && (nextCategory |= attribute_update_classifier_1.UpdateCategory.BOUNDS),
306
- nextCategory === attribute_update_classifier_1.UpdateCategory.PAINT && this.needUpdateTag(key) && (nextCategory = attribute_update_classifier_1.UpdateCategory.SHAPE | attribute_update_classifier_1.UpdateCategory.BOUNDS),
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 += 1,
318
- null === (_b = this.stateEngine) || void 0 === _b || _b.invalidateResolverCache(),
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.baseAttributes[key] = cloneAttributeValue(params[key]);
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
- (0, vutils_1.isEqual)(previousValue, nextValue) || (delta.set(key, {
398
+ areAttributeValuesEqual(previousValue, nextValue) || (delta.set(key, {
335
399
  prev: previousValue,
336
400
  next: nextValue
337
- }), this.attribute[key] = cloneAttributeValue(nextValue));
401
+ }), this.attribute[key] = nextValue);
338
402
  }
339
- this.valid = this.isValid(), this.submitUpdateByDelta(delta, forceUpdateTag), this.onAttributeUpdate(context);
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 graphicTheme = this.getGraphicTheme();
575
+ const resolvedGraphicTheme = null != graphicTheme ? graphicTheme : this.getGraphicTheme();
448
576
  this._AABBBounds.clear();
449
- const attribute = this.attribute, bounds = this.updateAABBBounds(attribute, graphicTheme, this._AABBBounds, full), {boundsPadding: boundsPadding = graphicTheme.boundsPadding} = attribute, paddingArray = (0,
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), params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic),
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.applyBaseAttributes(params), this.commitBaseAttributeMutation(forceUpdateTag, context);
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 ? this._setAttributes(params, forceUpdateTag, context) : (this.applyBaseAttributes({
573
- [key]: value
574
- }), this.commitBaseAttributeMutation(!!forceUpdateTag, context)), "background" === key ? this.loadImage(value, !0) : "texture" === key && isExternalTexture(value) ? this.loadImage(value, !1) : "shadowGraphic" === key && this.setShadowGraphic(value);
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.baseAttributes = cloneAttributeValue(params), this.attribute || (this.attribute = {}),
595
- this.resolvedStatePatch = void 0, this._syncAttribute(), params.background && this.loadImage(params.background, !0),
596
- isExternalTexture(params.texture) && this.loadImage(params.texture, !1), params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic),
597
- this._updateTag = enums_1.UpdateTag.INIT, this.valid = this.isValid(), this.onAttributeUpdate(context);
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, this.applyBaseAttributes(params));
609
- const attribute = this.baseAttributes, postMatrix = attribute.postMatrix;
610
- return postMatrix ? application_1.application.transformUtil.fromMatrix(postMatrix, postMatrix).translate(x, y) : (attribute.x = (null !== (_a = attribute.x) && void 0 !== _a ? _a : config_1.DefaultTransform.x) + x,
611
- attribute.y = (null !== (_b = attribute.y) && void 0 !== _b ? _b : config_1.DefaultTransform.y) + y),
612
- this.commitBaseAttributeMutation(!1, context), this;
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.applyBaseAttributes(params), this.commitBaseAttributeMutation(!1, context),
624
- this) : (attribute.x = x, attribute.y = y, this.commitBaseAttributeMutation(!1, context),
625
- this);
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, this.applyBaseAttributes(params));
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.attribute;
642
- postMatrix || (postMatrix = new vutils_1.Matrix, attribute.postMatrix = postMatrix),
643
- application_1.application.transformUtil.fromMatrix(postMatrix, postMatrix).scale(scaleX, scaleY, scaleCenter);
644
- } else attribute.scaleX = (null !== (_a = attribute.scaleX) && void 0 !== _a ? _a : config_1.DefaultTransform.scaleX) * scaleX,
645
- attribute.scaleY = (null !== (_b = attribute.scaleY) && void 0 !== _b ? _b : config_1.DefaultTransform.scaleY) * scaleY;
646
- return this.commitBaseAttributeMutation(!1, context), 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.applyBaseAttributes(params), this.commitBaseAttributeMutation(!1, context),
658
- this) : (attribute.scaleX = scaleX, attribute.scaleY = scaleY, this.commitBaseAttributeMutation(!1, context),
659
- this);
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 && (delete params.angle, this.applyBaseAttributes(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 || (postMatrix = new vutils_1.Matrix, this.baseAttributes.postMatrix = postMatrix),
675
- application_1.application.transformUtil.fromMatrix(postMatrix, postMatrix).rotate(angle, rotateCenter);
676
- } else attribute.angle = (null !== (_a = attribute.angle) && void 0 !== _a ? _a : config_1.DefaultTransform.angle) + angle;
677
- return this.commitBaseAttributeMutation(!1, context), 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
- const attribute = this.baseAttributes;
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.applyBaseAttributes(params), this.commitBaseAttributeMutation(!1, context),
686
- this) : (attribute.angle = angle, this.commitBaseAttributeMutation(!1, context),
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,59 @@ 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
+ }
728
920
  resolveStateAnimateConfig(animateConfig) {
729
921
  var _a, _b, _c;
730
922
  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 +936,7 @@ class Graphic extends node_tree_1.Node {
744
936
  });
745
937
  this.getStateTransitionOrchestrator().applyTransition(this, plan, hasAnimation, transitionOptions);
746
938
  }
747
- updateNormalAttrs(stateAttrs) {
748
- this._deprecatedNormalAttrsView = cloneAttributeValue(this.baseAttributes);
749
- }
939
+ updateNormalAttrs(_stateAttrs) {}
750
940
  getStateTransitionDefaultAttribute(key, targetAttrs) {
751
941
  return this.getDefaultAttribute(key);
752
942
  }
@@ -756,6 +946,7 @@ class Graphic extends node_tree_1.Node {
756
946
  stopStateAnimates(type = "end") {
757
947
  const stopAnimationState = this.stopAnimationState;
758
948
  if ("function" == typeof stopAnimationState) return void stopAnimationState.call(this, "state", type);
949
+ if (!this.mayHaveTrackedAnimates()) return;
759
950
  const stateAnimates = [];
760
951
  this.visitTrackedAnimates((animate => {
761
952
  animate.stateNames && stateAnimates.push(animate);
@@ -768,23 +959,27 @@ class Graphic extends node_tree_1.Node {
768
959
  }
769
960
  clearStates(hasAnimation) {
770
961
  var _a, _b, _c;
771
- const previousStates = this.currentStates ? this.currentStates.slice() : [], previousResolvedStatePatch = this.resolvedStatePatch ? cloneAttributeValue(this.resolvedStatePatch) : void 0, transition = this.createStateModel().clearStates();
962
+ const previousStates = null !== (_a = this.currentStates) && void 0 !== _a ? _a : EMPTY_STATE_NAMES, previousResolvedStatePatch = this.resolvedStatePatch, transition = this.createStateModel().clearStates();
772
963
  if (!transition.changed && 0 === previousStates.length) return this.currentStates = [],
773
964
  this.effectiveStates = [], this.resolvedStatePatch = void 0, this.sharedStateDirty = !1,
774
965
  void this.clearSharedStateActiveRegistrations();
775
- const resolvedStateAttrs = cloneAttributeValue(null !== (_a = this.baseAttributes) && void 0 !== _a ? _a : {});
776
- transition.changed && !this.beforeStateUpdate(resolvedStateAttrs, previousStates, transition.states, hasAnimation, !0) || (this.currentStates = transition.states,
777
- this.effectiveStates = [], this.resolvedStatePatch = void 0, this.sharedStateDirty = !1,
778
- this.clearSharedStateActiveRegistrations(), null === (_b = (0, state_perf_monitor_1.getStageStatePerfMonitor)(this.stage)) || void 0 === _b || _b.incrementCounter("stateCommits"),
779
- null === (_c = (0, state_perf_monitor_1.getStageStatePerfMonitor)(this.stage)) || void 0 === _c || _c.recordEvent("state-commit", {
780
- graphicId: this._uid,
781
- targetStates: []
782
- }), hasAnimation ? (this._syncFinalAttributeFromStaticTruth(), this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !0, void 0, this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch))) : (this.stopStateAnimates(),
783
- this._restoreAttributeFromStaticTruth({
784
- type: enums_1.AttributeUpdateType.STATE
785
- }), this._emitCustomEvent("afterStateUpdate", {
786
- type: enums_1.AttributeUpdateType.STATE
787
- })));
966
+ const resolvedStateAttrs = hasAnimation || this.hasCustomEvent("beforeStateUpdate") ? cloneAttributeValue(null !== (_b = this.baseAttributes) && void 0 !== _b ? _b : {}) : null !== (_c = this.baseAttributes) && void 0 !== _c ? _c : {};
967
+ if (!transition.changed || this.beforeStateUpdate(resolvedStateAttrs, previousStates, transition.states, hasAnimation, !0)) {
968
+ if (this.currentStates = transition.states, this.effectiveStates = [], this.resolvedStatePatch = void 0,
969
+ this.sharedStateDirty = !1, this.clearSharedStateActiveRegistrations(), this.stage) {
970
+ const perfMonitor = (0, state_perf_monitor_1.getActiveStageStatePerfMonitor)(this.stage);
971
+ null == perfMonitor || perfMonitor.incrementCounter("stateCommits"), null == perfMonitor || perfMonitor.recordEvent("state-commit", {
972
+ graphicId: this._uid,
973
+ targetStates: []
974
+ });
975
+ }
976
+ hasAnimation ? (this._syncFinalAttributeFromStaticTruth(), this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !0, void 0, this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch))) : (this.stopStateAnimates(),
977
+ this.attributeMayContainTransientAttrs ? this._restoreAttributeFromStaticTruth({
978
+ type: enums_1.AttributeUpdateType.STATE
979
+ }) : this.restoreAttributeFromStatePatchDelta(previousResolvedStatePatch, void 0, {
980
+ type: enums_1.AttributeUpdateType.STATE
981
+ }), this.emitStateUpdateEvent());
982
+ }
788
983
  }
789
984
  removeState(stateName, hasAnimation) {
790
985
  const transition = this.createStateModel().removeState(stateName);
@@ -798,42 +993,61 @@ class Graphic extends node_tree_1.Node {
798
993
  const transition = this.createStateModel().addState(stateName, keepCurrentStates);
799
994
  transition.changed && this.useStates(transition.states, hasAnimation);
800
995
  }
996
+ setStates(states, hasAnimation) {
997
+ var _a, _b, _c;
998
+ const 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));
999
+ if (nextStates.length) this.sameStateNames(this.currentStates, nextStates) ? this.sharedStateDirty && this.refreshSharedStateBeforeRender() : this.useStates(nextStates, hasAnimation); else {
1000
+ if (!hasCurrentState && !this.sharedStateDirty) return;
1001
+ this.clearStates(hasAnimation);
1002
+ }
1003
+ }
801
1004
  useStates(states, hasAnimation) {
802
- var _a, _b, _c, _d, _e;
1005
+ var _a, _b, _c, _d;
803
1006
  if (!states.length) return void this.clearStates(hasAnimation);
804
- const previousStates = this.currentStates ? this.currentStates.slice() : [], previousResolvedStatePatch = this.resolvedStatePatch ? cloneAttributeValue(this.resolvedStatePatch) : void 0, stateResolveBaseAttrs = null !== (_a = this.baseAttributes) && void 0 !== _a ? _a : this.attribute, stateModel = this.createStateModel();
805
- null === (_b = this.stateEngine) || void 0 === _b || _b.setResolveContext(this, stateResolveBaseAttrs);
806
- const transition = stateModel.useStates(states);
807
- if (!transition.changed && this.sameStateNames(previousStates, transition.states)) return;
808
- const effectiveStates = null !== (_c = transition.effectiveStates) && void 0 !== _c ? _c : 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);
809
- this.beforeStateUpdate(resolvedStateAttrs, previousStates, transition.states, hasAnimation, !1) && (this.currentStates = transition.states,
810
- this.effectiveStates = [ ...effectiveStates ], this.resolvedStatePatch = Object.assign({}, resolvedStateAttrs),
811
- this.sharedStateDirty = !1, this.syncSharedStateActiveRegistrations(), null === (_d = (0,
812
- state_perf_monitor_1.getStageStatePerfMonitor)(this.stage)) || void 0 === _d || _d.incrementCounter("stateCommits"),
813
- null === (_e = (0, state_perf_monitor_1.getStageStatePerfMonitor)(this.stage)) || void 0 === _e || _e.recordEvent("state-commit", {
814
- graphicId: this._uid,
815
- targetStates: [ ...transition.states ]
816
- }), hasAnimation ? (this._syncFinalAttributeFromStaticTruth(), this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !1, void 0, this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch))) : (this.stopStateAnimates(),
817
- this._restoreAttributeFromStaticTruth({
818
- type: enums_1.AttributeUpdateType.STATE
819
- }), this._emitCustomEvent("afterStateUpdate", {
820
- type: enums_1.AttributeUpdateType.STATE
821
- })));
1007
+ const previousStates = null !== (_a = this.currentStates) && void 0 !== _a ? _a : EMPTY_STATE_NAMES, previousResolvedStatePatch = this.resolvedStatePatch;
1008
+ let transition = this.resolveSimpleLocalStateTransition(states, previousStates);
1009
+ const isSimpleLocalTransition = !!transition;
1010
+ let resolvedStateAttrs;
1011
+ if (transition) {
1012
+ if (!transition.changed) return;
1013
+ resolvedStateAttrs = transition.resolvedStateAttrs;
1014
+ } else {
1015
+ const stateResolveBaseAttrs = null !== (_b = this.baseAttributes) && void 0 !== _b ? _b : this.attribute, stateModel = this.createStateModel();
1016
+ if (null === (_c = this.stateEngine) || void 0 === _c || _c.setResolveContext(this, stateResolveBaseAttrs),
1017
+ transition = stateModel.useStates(states), !transition.changed && this.sameStateNames(previousStates, transition.states)) return;
1018
+ resolvedStateAttrs = this.stateEngine && this.compiledStateDefinitions ? Object.assign({}, this.stateEngine.resolvedPatch) : this.getStateStyleResolver(this.stateMergeMode).resolve(stateResolveBaseAttrs, this.states, this.stateProxy, transition.states, this.stateSort);
1019
+ }
1020
+ const effectiveStates = null !== (_d = transition.effectiveStates) && void 0 !== _d ? _d : transition.states;
1021
+ if (this.beforeStateUpdate(resolvedStateAttrs, previousStates, transition.states, hasAnimation, !1)) {
1022
+ if (this.currentStates = transition.states, this.effectiveStates = isSimpleLocalTransition ? effectiveStates : [ ...effectiveStates ],
1023
+ this.resolvedStatePatch = resolvedStateAttrs, this.sharedStateDirty = !1, this.syncSharedStateActiveRegistrations(),
1024
+ this.stage) {
1025
+ const perfMonitor = (0, state_perf_monitor_1.getActiveStageStatePerfMonitor)(this.stage);
1026
+ null == perfMonitor || perfMonitor.incrementCounter("stateCommits"), null == perfMonitor || perfMonitor.recordEvent("state-commit", {
1027
+ graphicId: this._uid,
1028
+ targetStates: [ ...transition.states ]
1029
+ });
1030
+ }
1031
+ hasAnimation ? (this._syncFinalAttributeFromStaticTruth(), this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !1, void 0, this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch))) : (this.stopStateAnimates(),
1032
+ this.attributeMayContainTransientAttrs ? this._restoreAttributeFromStaticTruth({
1033
+ type: enums_1.AttributeUpdateType.STATE
1034
+ }) : this.restoreAttributeFromStatePatchDelta(previousResolvedStatePatch, this.resolvedStatePatch, {
1035
+ type: enums_1.AttributeUpdateType.STATE
1036
+ }), this.emitStateUpdateEvent());
1037
+ }
822
1038
  }
823
1039
  invalidateResolver() {
824
- var _a, _b;
1040
+ var _a, _b, _c;
825
1041
  if (!this.stateEngine || !(null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) || !this.compiledStateDefinitions) return;
826
1042
  const stateResolveBaseAttrs = null !== (_b = this.baseAttributes) && void 0 !== _b ? _b : this.attribute;
827
- this.stateEngine.setResolveContext(this, stateResolveBaseAttrs), this.resolverEpoch += 1,
1043
+ this.stateEngine.setResolveContext(this, stateResolveBaseAttrs), this.resolverEpoch = (null !== (_c = this.resolverEpoch) && void 0 !== _c ? _c : 0) + 1,
828
1044
  this.stateEngine.invalidateResolverCache();
829
1045
  const transition = this.stateEngine.applyStates(this.currentStates), resolvedStateAttrs = Object.assign({}, this.stateEngine.resolvedPatch);
830
- this.effectiveStates = [ ...transition.effectiveStates ], this.resolvedStatePatch = Object.assign({}, resolvedStateAttrs),
1046
+ this.effectiveStates = [ ...transition.effectiveStates ], this.resolvedStatePatch = resolvedStateAttrs,
831
1047
  this.sharedStateDirty = !1, this.syncSharedStateActiveRegistrations(), this.stopStateAnimates(),
832
1048
  this._restoreAttributeFromStaticTruth({
833
1049
  type: enums_1.AttributeUpdateType.STATE
834
- }), this._emitCustomEvent("afterStateUpdate", {
835
- type: enums_1.AttributeUpdateType.STATE
836
- });
1050
+ }), this.emitStateUpdateEvent();
837
1051
  }
838
1052
  sameStateNames(left, right) {
839
1053
  const normalizedLeft = null != left ? left : [], normalizedRight = null != right ? right : [];
@@ -855,6 +1069,10 @@ class Graphic extends node_tree_1.Node {
855
1069
  this._updateTag |= enums_1.UpdateTag.UPDATE_SHAPE_AND_BOUNDS, this.parent && this.parent.addChildUpdateBoundTag(),
856
1070
  this.glyphHost && this.glyphHost.addUpdateBoundTag();
857
1071
  }
1072
+ addBroadUpdateTag() {
1073
+ 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,
1074
+ this.parent && this.parent.addChildUpdateBoundTag(), this.glyphHost && this.glyphHost.addUpdateBoundTag();
1075
+ }
858
1076
  updateShapeAndBoundsTagSetted() {
859
1077
  return (this._updateTag & enums_1.UpdateTag.UPDATE_SHAPE_AND_BOUNDS) === enums_1.UpdateTag.UPDATE_SHAPE_AND_BOUNDS;
860
1078
  }
@@ -929,12 +1147,12 @@ class Graphic extends node_tree_1.Node {
929
1147
  }
930
1148
  }
931
1149
  setStage(stage, layer) {
932
- var _a, _b, _c, _d, _e, _f, _g, _h;
1150
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
933
1151
  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
1152
  if (this.stage !== stage || this.layer !== layer) {
935
- if (this.stage = stage, this.layer = layer, this.syncSharedStateScopeBindingFromTree(!!(null === (_d = this.currentStates) || void 0 === _d ? void 0 : _d.length)),
936
- this.setStageToShadowRoot(stage, layer), this.hasAnyTrackedAnimate()) {
937
- const previousTimeline = null === (_e = null == previousStage ? void 0 : previousStage.getTimeline) || void 0 === _e ? void 0 : _e.call(previousStage), nextTimeline = null === (_f = null == stage ? void 0 : stage.getTimeline) || void 0 === _f ? void 0 : _f.call(stage), detachedStageAnimates = [];
1153
+ 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),
1154
+ this.setStageToShadowRoot(stage, layer), this.mayHaveTrackedAnimates() && this.hasAnyTrackedAnimate()) {
1155
+ 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
1156
  this.visitTrackedAnimates((a => {
939
1157
  (!!previousTimeline && a.timeline === previousTimeline || a.timeline.isGlobal) && (nextTimeline ? a.timeline !== nextTimeline && (previousTimeline && a.timeline === previousTimeline && previousTimeline.removeAnimate(a, !1),
940
1158
  a.setTimeline(nextTimeline), nextTimeline.addAnimate(a)) : previousTimeline && a.timeline === previousTimeline && (previousTimeline.removeAnimate(a, !1),
@@ -948,9 +1166,18 @@ class Graphic extends node_tree_1.Node {
948
1166
  type: enums_1.AttributeUpdateType.ANIMATE_END
949
1167
  }));
950
1168
  }
951
- return this._onSetStage && this._onSetStage(this, stage, layer), void (null === (_g = null == graphicService ? void 0 : graphicService.onSetStage) || void 0 === _g || _g.call(graphicService, this, stage));
1169
+ 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
1170
  }
953
- this.syncSharedStateScopeBindingFromTree(!!(null === (_h = this.currentStates) || void 0 === _h ? void 0 : _h.length));
1171
+ ((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);
1172
+ }
1173
+ detachStageForRelease() {
1174
+ var _a, _b, _c;
1175
+ (null === (_a = this.registeredActiveScopes) || void 0 === _a ? void 0 : _a.size) && this.clearSharedStateActiveRegistrations(),
1176
+ (this.mayHaveTrackedAnimates() || this.shadowRoot) && this.stopAnimates(), this.boundSharedStateScope = void 0,
1177
+ this.boundSharedStateRevision = void 0, this.localFallbackCompiledDefinitions = void 0,
1178
+ this.compiledStateDefinitions = void 0, this.compiledStateDefinitionsCacheKey = void 0,
1179
+ this.stateEngine = void 0, this.stateEngineCompiledDefinitions = void 0, this.stateEngineStateProxyModeKey = void 0,
1180
+ this.sharedStateDirty = !1, this.stage = null, this.layer = null, this.shadowRoot && (null === (_c = (_b = this.shadowRoot).detachStageForRelease) || void 0 === _c || _c.call(_b));
954
1181
  }
955
1182
  setStageToShadowRoot(stage, layer) {
956
1183
  this.shadowRoot && this.shadowRoot.setStage(stage, layer);
@@ -1025,6 +1252,7 @@ class Graphic extends node_tree_1.Node {
1025
1252
  res && (res.state = "fail", cb && cb());
1026
1253
  }
1027
1254
  _stopAnimates() {
1255
+ if (!this.mayHaveTrackedAnimates()) return;
1028
1256
  const animates = [];
1029
1257
  this.visitTrackedAnimates((animate => {
1030
1258
  animates.push(animate);
@@ -1038,15 +1266,19 @@ class Graphic extends node_tree_1.Node {
1038
1266
  }));
1039
1267
  }
1040
1268
  release() {
1041
- var _a, _b, _c;
1042
- this.releaseStatus = "released", this.clearSharedStateActiveRegistrations(), this.stopAnimates();
1043
- const graphicService = null !== (_b = null === (_a = this.stage) || void 0 === _a ? void 0 : _a.graphicService) && void 0 !== _b ? _b : application_1.application.graphicService;
1044
- null === (_c = null == graphicService ? void 0 : graphicService.onRelease) || void 0 === _c || _c.call(graphicService, this),
1269
+ var _a, _b, _c, _d;
1270
+ this.releaseStatus = "released", (null === (_a = this.registeredActiveScopes) || void 0 === _a ? void 0 : _a.size) && this.clearSharedStateActiveRegistrations(),
1271
+ (this.mayHaveTrackedAnimates() || this.shadowRoot) && this.stopAnimates();
1272
+ const graphicService = null !== (_c = null === (_b = this.stage) || void 0 === _b ? void 0 : _b.graphicService) && void 0 !== _c ? _c : application_1.application.graphicService;
1273
+ null === (_d = null == graphicService ? void 0 : graphicService.onRelease) || void 0 === _d || _d.call(graphicService, this),
1045
1274
  super.release();
1046
1275
  }
1276
+ hasCustomEvent(type) {
1277
+ return !!this._events && type in this._events;
1278
+ }
1047
1279
  _dispatchCustomEvent(type, context) {
1048
1280
  var _a, _b;
1049
- if (this._events && type in this._events) {
1281
+ if (this.hasCustomEvent(type)) {
1050
1282
  const changeEvent = new event_1.CustomEvent(type, context);
1051
1283
  changeEvent.bubbles = !1;
1052
1284
  const manager = null === (_b = null === (_a = this.stage) || void 0 === _a ? void 0 : _a.eventSystem) || void 0 === _b ? void 0 : _b.manager;
@@ -1055,7 +1287,7 @@ class Graphic extends node_tree_1.Node {
1055
1287
  return !0;
1056
1288
  }
1057
1289
  beforeStateUpdate(attrs, prevStates, nextStates, hasAnimation, isClear) {
1058
- return this._dispatchCustomEvent("beforeStateUpdate", {
1290
+ return !this.hasCustomEvent("beforeStateUpdate") || this._dispatchCustomEvent("beforeStateUpdate", {
1059
1291
  type: enums_1.AttributeUpdateType.STATE,
1060
1292
  attrs: Object.assign({}, attrs),
1061
1293
  prevStates: prevStates.slice(),
@@ -1064,6 +1296,11 @@ class Graphic extends node_tree_1.Node {
1064
1296
  isClear: !!isClear
1065
1297
  });
1066
1298
  }
1299
+ emitStateUpdateEvent() {
1300
+ this.hasCustomEvent("afterStateUpdate") && this._emitCustomEvent("afterStateUpdate", {
1301
+ type: enums_1.AttributeUpdateType.STATE
1302
+ });
1303
+ }
1067
1304
  _emitCustomEvent(type, context) {
1068
1305
  this._dispatchCustomEvent(type, context);
1069
1306
  }