@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.
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 +61 -9
  8. package/cjs/graphic/graphic.js +433 -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 +4 -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 +9 -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 +895 -261
  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 +61 -9
  43. package/es/graphic/graphic.js +429 -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 +5 -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 +9 -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
@@ -36,7 +36,7 @@ import { StateEngine } from "./state/state-engine";
36
36
 
37
37
  import { StateModel } from "./state/state-model";
38
38
 
39
- import { UpdateCategory, classifyAttributeDelta } from "./state/attribute-update-classifier";
39
+ import { ATTRIBUTE_CATEGORY, UpdateCategory, classifyAttributeDelta } from "./state/attribute-update-classifier";
40
40
 
41
41
  import { StateStyleResolver } from "./state/state-style-resolver";
42
42
 
@@ -46,7 +46,7 @@ import { collectSharedStateScopeChain, ensureSharedStateScopeFresh } from "./sta
46
46
 
47
47
  import { enqueueGraphicSharedStateRefresh, scheduleStageSharedStateRefresh } from "./state/shared-state-refresh";
48
48
 
49
- import { getStageStatePerfMonitor } from "./state/state-perf-monitor";
49
+ import { getActiveStageStatePerfMonitor } from "./state/state-perf-monitor";
50
50
 
51
51
  const _tempBounds = new AABBBounds, loadShadowRootFactory = () => require("./shadow-root"), tempMatrix = new Matrix;
52
52
 
@@ -54,10 +54,10 @@ export const PURE_STYLE_KEY = [ "stroke", "opacity", "strokeOpacity", "lineDash"
54
54
 
55
55
  export const GRAPHIC_UPDATE_TAG_KEY = [ "lineWidth", "scaleX", "scaleY", "angle", "anchor", "visible" ];
56
56
 
57
- 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 Point;
57
+ 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 Point, EMPTY_STATE_NAMES = [], BROAD_UPDATE_CATEGORY = UpdateCategory.PAINT | UpdateCategory.SHAPE | UpdateCategory.BOUNDS | UpdateCategory.TRANSFORM | UpdateCategory.LAYOUT;
58
58
 
59
59
  function isPlainObjectValue(value) {
60
- return "object" == typeof value && null != value && !isArray(value);
60
+ return "object" == typeof value && null != value && !Array.isArray(value);
61
61
  }
62
62
 
63
63
  function cloneAttributeValue(value) {
@@ -69,14 +69,6 @@ function cloneAttributeValue(value) {
69
69
  })), clone;
70
70
  }
71
71
 
72
- function cloneSimpleAttributeRecord(value) {
73
- return isPlainObjectValue(value) ? Object.assign({}, value) : value;
74
- }
75
-
76
- export function shouldUseSimpleAttributeFastPath(value) {
77
- return !!isPlainObjectValue(value) && !Object.keys(value).some((key => isPlainObjectValue(value[key])));
78
- }
79
-
80
72
  function cloneAttributeSurface(value) {
81
73
  if (!isPlainObjectValue(value)) return value;
82
74
  const source = value, clone = {};
@@ -86,6 +78,10 @@ function cloneAttributeSurface(value) {
86
78
  })), clone;
87
79
  }
88
80
 
81
+ function areAttributeValuesEqual(left, right) {
82
+ return left === right || !!(isPlainObjectValue(left) || isPlainObjectValue(right) || Array.isArray(left) || Array.isArray(right)) && isEqual(left, right);
83
+ }
84
+
89
85
  function deepMergeAttributeValue(base, value) {
90
86
  var _a;
91
87
  const result = null !== (_a = cloneAttributeValue(base)) && void 0 !== _a ? _a : {};
@@ -149,19 +145,27 @@ export class Graphic extends Node {
149
145
  get globalTransMatrix() {
150
146
  return this.tryUpdateGlobalTransMatrix(!0);
151
147
  }
148
+ get baseAttributes() {
149
+ var _a;
150
+ return null !== (_a = this._baseAttributes) && void 0 !== _a ? _a : this.attribute;
151
+ }
152
+ set baseAttributes(value) {
153
+ value !== this.attribute ? this._baseAttributes = value : this._baseAttributes = void 0;
154
+ }
152
155
  constructor(params = {}) {
153
156
  var _a;
154
- super(), this.resolverEpoch = 0, this._AABBBounds = new AABBBounds, this._updateTag = UpdateTag.INIT;
155
- const useSimpleAttributeFastPath = shouldUseSimpleAttributeFastPath(params), initialBaseAttributes = useSimpleAttributeFastPath ? cloneSimpleAttributeRecord(params) : cloneAttributeValue(params);
156
- this.baseAttributes = initialBaseAttributes, this.attribute = useSimpleAttributeFastPath ? cloneSimpleAttributeRecord(initialBaseAttributes) : cloneAttributeSurface(initialBaseAttributes),
157
+ super(), this._AABBBounds = new AABBBounds, this._updateTag = UpdateTag.INIT, this.attribute = params,
157
158
  this.valid = this.isValid(), this.updateAABBBoundsStamp = 0, params.background && this.loadImage(null !== (_a = params.background.background) && void 0 !== _a ? _a : params.background, !0),
158
- isExternalTexture(params.texture) && this.loadImage(params.texture, !1), params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic);
159
+ params.texture && isExternalTexture(params.texture) && this.loadImage(params.texture, !1),
160
+ params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic);
159
161
  }
160
162
  get normalAttrs() {
161
163
  return this.baseAttributes;
162
164
  }
163
- set normalAttrs(value) {
164
- this._deprecatedNormalAttrsView = null != value ? value : void 0;
165
+ set normalAttrs(_value) {}
166
+ getBaseAttributesStorage() {
167
+ var _a;
168
+ return null !== (_a = this._baseAttributes) && void 0 !== _a ? _a : this.attribute;
165
169
  }
166
170
  getGraphicService() {
167
171
  var _a, _b;
@@ -200,10 +204,18 @@ export class Graphic extends Node {
200
204
  markDirty && (null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) && this.markSharedStateDirty(),
201
205
  !0);
202
206
  }
203
- syncSharedStateActiveRegistrations() {
207
+ syncSharedStateScopeBindingOnTreeChange(markDirty = !0) {
204
208
  var _a, _b;
205
- const nextScopes = (null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) && this.boundSharedStateScope ? new Set(collectSharedStateScopeChain(this.boundSharedStateScope)) : new Set;
206
- (null !== (_b = this.registeredActiveScopes) && void 0 !== _b ? _b : new Set).forEach((scope => {
209
+ 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);
210
+ }
211
+ syncSharedStateActiveRegistrations() {
212
+ var _a;
213
+ const previousScopes = this.registeredActiveScopes;
214
+ if (!(null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) || !this.boundSharedStateScope) return (null == previousScopes ? void 0 : previousScopes.size) && (previousScopes.forEach((scope => {
215
+ scope.subtreeActiveDescendants.delete(this);
216
+ })), previousScopes.clear()), void (this.registeredActiveScopes = void 0);
217
+ const nextScopes = new Set(collectSharedStateScopeChain(this.boundSharedStateScope));
218
+ null == previousScopes || previousScopes.forEach((scope => {
207
219
  nextScopes.has(scope) || scope.subtreeActiveDescendants.delete(this);
208
220
  })), nextScopes.forEach((scope => {
209
221
  scope.subtreeActiveDescendants.add(this);
@@ -220,7 +232,7 @@ export class Graphic extends Node {
220
232
  scheduleStageSharedStateRefresh(this.stage);
221
233
  }
222
234
  onParentSharedStateTreeChanged(stage, layer) {
223
- this.stage === stage && this.layer === layer ? this.syncSharedStateScopeBindingFromTree() : this.setStage(stage, layer);
235
+ this.stage === stage && this.layer === layer ? this.syncSharedStateScopeBindingOnTreeChange() : this.setStage(stage, layer);
224
236
  }
225
237
  refreshSharedStateBeforeRender() {
226
238
  var _a;
@@ -228,9 +240,7 @@ export class Graphic extends Node {
228
240
  this.boundSharedStateScope && ensureSharedStateScopeFresh(this.boundSharedStateScope),
229
241
  this.recomputeCurrentStatePatch(), this.stopStateAnimates(), this._restoreAttributeFromStaticTruth({
230
242
  type: AttributeUpdateType.STATE
231
- }), this._emitCustomEvent("afterStateUpdate", {
232
- type: AttributeUpdateType.STATE
233
- }), this.sharedStateDirty = !1) : this.sharedStateDirty = !1;
243
+ }), this.emitStateUpdateEvent(), this.sharedStateDirty = !1) : this.sharedStateDirty = !1;
234
244
  }
235
245
  getLocalStatesVersion() {
236
246
  var _a, _b;
@@ -287,7 +297,7 @@ export class Graphic extends Node {
287
297
  null === (_c = this.stateEngine) || void 0 === _c || _c.setResolveContext(this, stateResolveBaseAttrs);
288
298
  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);
289
299
  this.currentStates = transition.states, this.effectiveStates = [ ...effectiveStates ],
290
- this.resolvedStatePatch = Object.assign({}, resolvedStateAttrs), this.syncSharedStateActiveRegistrations();
300
+ this.resolvedStatePatch = resolvedStateAttrs, this.syncSharedStateActiveRegistrations();
291
301
  }
292
302
  buildStaticAttributeSnapshot() {
293
303
  var _a;
@@ -322,15 +332,17 @@ export class Graphic extends Node {
322
332
  next: void 0
323
333
  }), delete target[key]));
324
334
  const nextValue = snapshot[key];
325
- isEqual(previousValue, nextValue) || (delta.set(key, {
335
+ areAttributeValuesEqual(previousValue, nextValue) || (delta.set(key, {
326
336
  prev: previousValue,
327
337
  next: nextValue
328
338
  }), target[key] = cloneAttributeValue(nextValue));
329
339
  })), delta;
330
340
  }
331
341
  _syncAttribute() {
342
+ this.attribute === this.baseAttributes && this.resolvedStatePatch && this.detachAttributeFromBaseAttributes();
332
343
  const snapshot = this.buildStaticAttributeSnapshot(), delta = this.syncObjectToSnapshot(this.attribute, snapshot);
333
- return this.valid = this.isValid(), delta;
344
+ return this.valid = this.isValid(), this.attributeMayContainTransientAttrs = !1,
345
+ delta;
334
346
  }
335
347
  _syncFinalAttributeFromStaticTruth() {
336
348
  const target = this.finalAttribute;
@@ -338,51 +350,154 @@ export class Graphic extends Node {
338
350
  const snapshot = this.buildStaticAttributeSnapshot();
339
351
  this.syncObjectToSnapshot(target, snapshot);
340
352
  }
341
- submitUpdateByDelta(delta, forceUpdateTag = !1) {
353
+ mergeAttributeDeltaCategory(category, key, prev, next) {
354
+ var _a;
355
+ let nextCategory = "stroke" === key || "shadowBlur" === key ? classifyAttributeDelta(key, prev, next) : null !== (_a = ATTRIBUTE_CATEGORY[key]) && void 0 !== _a ? _a : UpdateCategory.PAINT;
356
+ return nextCategory & UpdateCategory.PICK && (nextCategory |= UpdateCategory.BOUNDS),
357
+ nextCategory === UpdateCategory.PAINT && this.needUpdateTag(key) && (nextCategory = UpdateCategory.SHAPE | UpdateCategory.BOUNDS),
358
+ category | nextCategory;
359
+ }
360
+ submitUpdateByCategory(category, forceUpdateTag = !1) {
342
361
  var _a;
343
362
  if (forceUpdateTag) return this.addUpdateShapeAndBoundsTag(), this.addUpdatePositionTag(),
344
363
  void this.addUpdateLayoutTag();
364
+ if (category !== UpdateCategory.NONE) {
365
+ const stage = this.stage;
366
+ stage && (null === (_a = getActiveStageStatePerfMonitor(stage)) || void 0 === _a || _a.recordCategory(category));
367
+ }
368
+ (category & BROAD_UPDATE_CATEGORY) !== BROAD_UPDATE_CATEGORY ? (category & UpdateCategory.SHAPE ? this.addUpdateShapeAndBoundsTag() : category & UpdateCategory.BOUNDS && this.addUpdateBoundTag(),
369
+ category & UpdateCategory.PAINT && this.addUpdatePaintTag(), category & UpdateCategory.TRANSFORM && this.addUpdatePositionTag(),
370
+ category & UpdateCategory.LAYOUT && this.addUpdateLayoutTag()) : this.addBroadUpdateTag();
371
+ }
372
+ submitUpdateByDelta(delta, forceUpdateTag = !1) {
345
373
  let category = UpdateCategory.NONE;
346
374
  delta.forEach(((entry, key) => {
347
- let nextCategory = classifyAttributeDelta(key, entry.prev, entry.next);
348
- nextCategory & UpdateCategory.PICK && (nextCategory |= UpdateCategory.BOUNDS), nextCategory === UpdateCategory.PAINT && this.needUpdateTag(key) && (nextCategory = UpdateCategory.SHAPE | UpdateCategory.BOUNDS),
349
- category |= nextCategory;
350
- })), category !== UpdateCategory.NONE && (null === (_a = getStageStatePerfMonitor(this.stage)) || void 0 === _a || _a.recordCategory(category)),
351
- category & UpdateCategory.SHAPE ? this.addUpdateShapeAndBoundsTag() : category & UpdateCategory.BOUNDS && this.addUpdateBoundTag(),
352
- category & UpdateCategory.PAINT && this.addUpdatePaintTag(), category & UpdateCategory.TRANSFORM && this.addUpdatePositionTag(),
353
- category & UpdateCategory.LAYOUT && this.addUpdateLayoutTag();
375
+ category = this.mergeAttributeDeltaCategory(category, key, entry.prev, entry.next);
376
+ })), this.submitUpdateByCategory(category, forceUpdateTag);
377
+ }
378
+ submitTouchedKeyUpdate(keys, forceUpdateTag = !1) {
379
+ this.submitTouchedUpdate(forceUpdateTag || this.needUpdateTags(keys));
380
+ }
381
+ submitTouchedUpdate(needsShapeAndBounds) {
382
+ !this.updateShapeAndBoundsTagSetted() && needsShapeAndBounds ? this.addUpdateShapeAndBoundsTag() : this.addUpdateBoundTag(),
383
+ this.addUpdatePositionTag(), this.addUpdateLayoutTag();
354
384
  }
355
385
  commitBaseAttributeMutation(forceUpdateTag = !1, context) {
356
- var _a, _b;
357
- (null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) && (this.resolverEpoch += 1,
358
- null === (_b = this.stateEngine) || void 0 === _b || _b.invalidateResolverCache(),
386
+ var _a, _b, _c;
387
+ (null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) && (this.resolverEpoch = (null !== (_b = this.resolverEpoch) && void 0 !== _b ? _b : 0) + 1,
388
+ null === (_c = this.stateEngine) || void 0 === _c || _c.invalidateResolverCache(),
359
389
  this.recomputeCurrentStatePatch());
360
390
  const delta = this._syncAttribute();
361
391
  this.submitUpdateByDelta(delta, forceUpdateTag), this.onAttributeUpdate(context);
362
392
  }
393
+ canCommitBaseAttributesByTouchedKeys() {
394
+ var _a, _b;
395
+ 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());
396
+ }
397
+ detachAttributeFromBaseAttributes() {
398
+ this.attribute === this.baseAttributes && (this._baseAttributes = this.attribute,
399
+ this.attribute = cloneAttributeSurface(this.attribute));
400
+ }
401
+ commitInternalBaseAttributes(params, context) {
402
+ params && Object.keys(params).length && (this.canCommitBaseAttributesByTouchedKeys() ? this.commitBaseAttributesByTouchedKeys(params, !1, context) : (this.detachAttributeFromBaseAttributes(),
403
+ this.applyBaseAttributes(params), this.commitBaseAttributeMutation(!1, context)));
404
+ }
405
+ commitBaseAttributesByTouchedKeys(params, forceUpdateTag = !1, context) {
406
+ const source = params, baseAttributes = this.getBaseAttributesStorage();
407
+ let hasKeys = !1, needsShapeAndBounds = forceUpdateTag;
408
+ for (const key in source) Object.prototype.hasOwnProperty.call(source, key) && (hasKeys = !0,
409
+ baseAttributes[key] = source[key], !needsShapeAndBounds && this.needUpdateTag(key) && (needsShapeAndBounds = !0));
410
+ hasKeys && (this.attribute = baseAttributes, this._baseAttributes = void 0, this.valid = this.isValid(),
411
+ this.attributeMayContainTransientAttrs = !1, this.submitTouchedUpdate(needsShapeAndBounds),
412
+ this.onAttributeUpdate(context));
413
+ }
414
+ commitBaseAttributeBySingleKey(key, value, forceUpdateTag = !1, context) {
415
+ this.getBaseAttributesStorage()[key] = value, this.attribute = this.getBaseAttributesStorage(),
416
+ this._baseAttributes = void 0, this.valid = this.isValid(), this.attributeMayContainTransientAttrs = !1,
417
+ this.submitTouchedUpdate(forceUpdateTag || this.needUpdateTag(key)), this.onAttributeUpdate(context);
418
+ }
363
419
  applyBaseAttributes(params) {
364
420
  const keys = Object.keys(params);
365
421
  for (let i = 0; i < keys.length; i++) {
366
422
  const key = keys[i];
367
- this.baseAttributes[key] = cloneAttributeValue(params[key]);
423
+ this.getBaseAttributesStorage()[key] = params[key];
368
424
  }
369
425
  }
426
+ applyAnimationTransientAttributes(params, forceUpdateTag = !1, context) {
427
+ const source = params;
428
+ let target, needsShapeAndBounds = forceUpdateTag;
429
+ for (const key in source) Object.prototype.hasOwnProperty.call(source, key) && (target || (this.detachAttributeFromBaseAttributes(),
430
+ target = this.attribute), target[key] = source[key], !needsShapeAndBounds && this.needUpdateTag(key) && (needsShapeAndBounds = !0));
431
+ target && (this.attributeMayContainTransientAttrs = !0, this.valid = this.isValid(),
432
+ this.submitTouchedUpdate(needsShapeAndBounds), this.onAttributeUpdate(context));
433
+ }
370
434
  applyTransientAttributes(params, forceUpdateTag = !1, context) {
435
+ this.detachAttributeFromBaseAttributes();
371
436
  const delta = new Map, keys = Object.keys(params);
372
437
  for (let i = 0; i < keys.length; i++) {
373
438
  const key = keys[i], previousValue = this.attribute[key], nextValue = params[key];
374
- isEqual(previousValue, nextValue) || (delta.set(key, {
439
+ areAttributeValuesEqual(previousValue, nextValue) || (delta.set(key, {
375
440
  prev: previousValue,
376
441
  next: nextValue
377
- }), this.attribute[key] = cloneAttributeValue(nextValue));
442
+ }), this.attribute[key] = nextValue);
378
443
  }
379
- this.valid = this.isValid(), this.submitUpdateByDelta(delta, forceUpdateTag), this.onAttributeUpdate(context);
444
+ delta.size && (this.attributeMayContainTransientAttrs = !0), this.valid = this.isValid(),
445
+ this.submitUpdateByDelta(delta, forceUpdateTag), this.onAttributeUpdate(context);
380
446
  }
381
447
  _restoreAttributeFromStaticTruth(context) {
382
448
  this._syncFinalAttributeFromStaticTruth();
383
449
  const delta = this._syncAttribute();
384
450
  this.submitUpdateByDelta(delta), this.onAttributeUpdate(context);
385
451
  }
452
+ collectStatePatchDeltaKeys(previousPatch, nextPatch) {
453
+ const keys = previousPatch ? Object.keys(previousPatch) : [];
454
+ if (!nextPatch) return keys;
455
+ for (const key in nextPatch) Object.prototype.hasOwnProperty.call(nextPatch, key) && !Object.prototype.hasOwnProperty.call(null != previousPatch ? previousPatch : {}, key) && keys.push(key);
456
+ return keys;
457
+ }
458
+ getStaticTruthValueForStateKey(key, nextPatch) {
459
+ var _a;
460
+ const baseAttributes = null !== (_a = this.baseAttributes) && void 0 !== _a ? _a : {}, patch = nextPatch;
461
+ if (patch && Object.prototype.hasOwnProperty.call(patch, key)) {
462
+ const patchValue = patch[key], baseValue = baseAttributes[key];
463
+ return "deep" === this.stateMergeMode && isPlainObjectValue(baseValue) && isPlainObjectValue(patchValue) ? {
464
+ hasValue: !0,
465
+ value: deepMergeAttributeValue(baseValue, patchValue)
466
+ } : {
467
+ hasValue: !0,
468
+ value: patchValue
469
+ };
470
+ }
471
+ return Object.prototype.hasOwnProperty.call(baseAttributes, key) ? {
472
+ hasValue: !0,
473
+ value: baseAttributes[key]
474
+ } : {
475
+ hasValue: !1,
476
+ value: void 0
477
+ };
478
+ }
479
+ syncStatePatchDeltaToTarget(target, keys, nextPatch, collectCategory = !1) {
480
+ let category = UpdateCategory.NONE;
481
+ for (let i = 0; i < keys.length; i++) {
482
+ const key = keys[i], previousValue = target[key], next = this.getStaticTruthValueForStateKey(key, nextPatch);
483
+ if (!next.hasValue) {
484
+ Object.prototype.hasOwnProperty.call(target, key) && (delete target[key], collectCategory && (category = this.mergeAttributeDeltaCategory(category, key, previousValue, void 0)));
485
+ continue;
486
+ }
487
+ if (areAttributeValuesEqual(previousValue, next.value)) continue;
488
+ const nextValue = cloneAttributeValue(next.value);
489
+ target[key] = nextValue, collectCategory && (category = this.mergeAttributeDeltaCategory(category, key, previousValue, nextValue));
490
+ }
491
+ return category;
492
+ }
493
+ restoreAttributeFromStatePatchDelta(previousPatch, nextPatch, context) {
494
+ this.detachAttributeFromBaseAttributes();
495
+ const keys = this.collectStatePatchDeltaKeys(previousPatch, nextPatch), finalAttribute = this.finalAttribute;
496
+ finalAttribute && this.syncStatePatchDeltaToTarget(finalAttribute, keys, nextPatch, !1);
497
+ const category = this.syncStatePatchDeltaToTarget(this.attribute, keys, nextPatch, !0);
498
+ this.valid = this.isValid(), this.attributeMayContainTransientAttrs = !1, this.submitUpdateByCategory(category),
499
+ this.onAttributeUpdate(context);
500
+ }
386
501
  setMode(mode) {
387
502
  "3d" === mode ? this.set3dMode() : this.set2dMode();
388
503
  }
@@ -402,7 +517,7 @@ export class Graphic extends Node {
402
517
  return point;
403
518
  }
404
519
  onAnimateBind(animate) {
405
- this._emitCustomEvent("animate-bind", animate);
520
+ this.detachAttributeFromBaseAttributes(), this._emitCustomEvent("animate-bind", animate);
406
521
  }
407
522
  visitTrackedAnimates(cb) {
408
523
  const hook = this.forEachTrackedAnimate;
@@ -415,8 +530,22 @@ export class Graphic extends Node {
415
530
  const getTrackedAnimates = this.getTrackedAnimates;
416
531
  return "function" == typeof getTrackedAnimates ? getTrackedAnimates.call(this).size > 0 : !!(null === (_a = this.animates) || void 0 === _a ? void 0 : _a.size);
417
532
  }
533
+ mayHaveTrackedAnimates() {
534
+ var _a;
535
+ return !!(null === (_a = this.animates) || void 0 === _a ? void 0 : _a.size) || !!this._animationStateManager;
536
+ }
418
537
  tryUpdateAABBBounds() {
538
+ if (!(this.shadowRoot || this._updateTag & UpdateTag.UPDATE_BOUNDS)) return this._AABBBounds;
419
539
  const full = "imprecise" === this.attribute.boundsMode;
540
+ if (!this.shadowRoot) {
541
+ const graphicService = this.getGraphicService(), graphicTheme = this.getGraphicTheme();
542
+ if (!graphicService.validCheck(this.attribute, graphicTheme, this._AABBBounds, this)) return this._AABBBounds;
543
+ if (!this.valid) return this._AABBBounds.clear(), this._AABBBounds;
544
+ graphicService.beforeUpdateAABBBounds(this, this.stage, !0, this._AABBBounds);
545
+ const bounds = this.doUpdateAABBBounds(full, graphicTheme);
546
+ return graphicService.afterUpdateAABBBounds(this, this.stage, this._AABBBounds, this, !0),
547
+ "empty" === this.attribute.boundsMode && bounds.clear(), bounds;
548
+ }
420
549
  if (!this.shouldUpdateAABBBounds()) return this._AABBBounds;
421
550
  if (!this.valid) return this._AABBBounds.clear(), this._AABBBounds;
422
551
  this.getGraphicService().beforeUpdateAABBBounds(this, this.stage, !0, this._AABBBounds);
@@ -480,11 +609,11 @@ export class Graphic extends Node {
480
609
  const _parsedPath = new CustomSymbolClass(symbolType, cache);
481
610
  return Graphic.userSymbolMap[symbolType] = _parsedPath, _parsedPath;
482
611
  }
483
- doUpdateAABBBounds(full) {
612
+ doUpdateAABBBounds(full, graphicTheme) {
484
613
  this.updateAABBBoundsStamp++;
485
- const graphicTheme = this.getGraphicTheme();
614
+ const resolvedGraphicTheme = null != graphicTheme ? graphicTheme : this.getGraphicTheme();
486
615
  this._AABBBounds.clear();
487
- const attribute = this.attribute, bounds = this.updateAABBBounds(attribute, graphicTheme, this._AABBBounds, full), {boundsPadding: boundsPadding = graphicTheme.boundsPadding} = attribute, paddingArray = parsePadding(boundsPadding);
616
+ const attribute = this.attribute, bounds = this.updateAABBBounds(attribute, resolvedGraphicTheme, this._AABBBounds, full), {boundsPadding: boundsPadding = resolvedGraphicTheme.boundsPadding} = attribute, paddingArray = parsePadding(boundsPadding);
488
617
  return paddingArray && bounds.expand(paddingArray), this.clearUpdateBoundTag(),
489
618
  bounds;
490
619
  }
@@ -594,19 +723,24 @@ export class Graphic extends Node {
594
723
  }
595
724
  setAttributes(params, forceUpdateTag = !1, context) {
596
725
  params && ((params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate(params, this.attribute, null, context) || params).background && this.loadImage(params.background, !0),
597
- isExternalTexture(params.texture) && this.loadImage(params.texture, !1), params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic),
598
- this._setAttributes(params, forceUpdateTag, context));
726
+ params.texture && isExternalTexture(params.texture) && this.loadImage(params.texture, !1),
727
+ params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic), this._setAttributes(params, forceUpdateTag, context));
599
728
  }
600
729
  _setAttributes(params, forceUpdateTag = !1, context) {
601
- this.applyBaseAttributes(params), this.commitBaseAttributeMutation(forceUpdateTag, context);
730
+ this.canCommitBaseAttributesByTouchedKeys() ? this.commitBaseAttributesByTouchedKeys(params, forceUpdateTag, context) : (this.detachAttributeFromBaseAttributes(),
731
+ this.applyBaseAttributes(params), this.commitBaseAttributeMutation(forceUpdateTag, context));
602
732
  }
603
733
  setAttribute(key, value, forceUpdateTag, context) {
604
734
  const params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate({
605
735
  [key]: value
606
736
  }, this.attribute, key, context);
607
- params ? this._setAttributes(params, forceUpdateTag, context) : (this.applyBaseAttributes({
608
- [key]: value
609
- }), this.commitBaseAttributeMutation(!!forceUpdateTag, context)), "background" === key ? this.loadImage(value, !0) : "texture" === key && isExternalTexture(value) ? this.loadImage(value, !1) : "shadowGraphic" === key && this.setShadowGraphic(value);
737
+ if (params) this._setAttributes(params, forceUpdateTag, context); else if (this.canCommitBaseAttributesByTouchedKeys()) this.commitBaseAttributeBySingleKey(key, value, !!forceUpdateTag, context); else {
738
+ const nextAttrs = {
739
+ [key]: value
740
+ };
741
+ this.applyBaseAttributes(nextAttrs), this.commitBaseAttributeMutation(!!forceUpdateTag, context);
742
+ }
743
+ "background" === key ? this.loadImage(value, !0) : "texture" === key && isExternalTexture(value) ? this.loadImage(value, !1) : "shadowGraphic" === key && this.setShadowGraphic(value);
610
744
  }
611
745
  needUpdateTags(keys, k = GRAPHIC_UPDATE_TAG_KEY) {
612
746
  for (let i = 0; i < k.length; i++) {
@@ -626,10 +760,11 @@ export class Graphic extends Node {
626
760
  type: AttributeUpdateType.INIT
627
761
  };
628
762
  params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate(params, this.attribute, null, context) || params,
629
- this.baseAttributes = cloneAttributeValue(params), this.attribute || (this.attribute = {}),
630
- this.resolvedStatePatch = void 0, this._syncAttribute(), params.background && this.loadImage(params.background, !0),
631
- isExternalTexture(params.texture) && this.loadImage(params.texture, !1), params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic),
632
- this._updateTag = UpdateTag.INIT, this.valid = this.isValid(), this.onAttributeUpdate(context);
763
+ this.attribute = params, this._baseAttributes = void 0, this.resolvedStatePatch = void 0,
764
+ this.attributeMayContainTransientAttrs = !1, this.valid = this.isValid(), params.background && this.loadImage(params.background, !0),
765
+ params.texture && isExternalTexture(params.texture) && this.loadImage(params.texture, !1),
766
+ params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic), this._updateTag = UpdateTag.INIT,
767
+ this.valid = this.isValid(), this.onAttributeUpdate(context);
633
768
  }
634
769
  translate(x, y) {
635
770
  var _a, _b;
@@ -640,11 +775,15 @@ export class Graphic extends Node {
640
775
  x: x,
641
776
  y: y
642
777
  }, this.attribute, tempConstantXYKey, context);
643
- params && (x = params.x, y = params.y, delete params.x, delete params.y, this.applyBaseAttributes(params));
644
- const attribute = this.baseAttributes, postMatrix = attribute.postMatrix;
645
- return postMatrix ? application.transformUtil.fromMatrix(postMatrix, postMatrix).translate(x, y) : (attribute.x = (null !== (_a = attribute.x) && void 0 !== _a ? _a : DefaultTransform.x) + x,
646
- attribute.y = (null !== (_b = attribute.y) && void 0 !== _b ? _b : DefaultTransform.y) + y),
647
- this.commitBaseAttributeMutation(!1, context), this;
778
+ params && (x = params.x, y = params.y, delete params.x, delete params.y);
779
+ const attribute = this.baseAttributes, postMatrix = attribute.postMatrix, nextAttrs = params || {};
780
+ if (postMatrix) {
781
+ const nextPostMatrix = postMatrix.clone();
782
+ application.transformUtil.fromMatrix(nextPostMatrix, nextPostMatrix).translate(x, y),
783
+ nextAttrs.postMatrix = nextPostMatrix;
784
+ } else nextAttrs.x = (null !== (_a = attribute.x) && void 0 !== _a ? _a : DefaultTransform.x) + x,
785
+ nextAttrs.y = (null !== (_b = attribute.y) && void 0 !== _b ? _b : DefaultTransform.y) + y;
786
+ return this.commitInternalBaseAttributes(nextAttrs, context), this;
648
787
  }
649
788
  translateTo(x, y) {
650
789
  const attribute = this.baseAttributes;
@@ -655,9 +794,10 @@ export class Graphic extends Node {
655
794
  x: x,
656
795
  y: y
657
796
  }, this.attribute, tempConstantXYKey, context);
658
- return params ? (this.applyBaseAttributes(params), this.commitBaseAttributeMutation(!1, context),
659
- this) : (attribute.x = x, attribute.y = y, this.commitBaseAttributeMutation(!1, context),
660
- this);
797
+ return params ? (this.commitInternalBaseAttributes(params, context), this) : (this.commitInternalBaseAttributes({
798
+ x: x,
799
+ y: y
800
+ }, context), this);
661
801
  }
662
802
  scale(scaleX, scaleY, scaleCenter) {
663
803
  var _a, _b;
@@ -670,14 +810,15 @@ export class Graphic extends Node {
670
810
  scaleCenter: scaleCenter
671
811
  }, this.attribute, tempConstantScaleXYKey, context);
672
812
  params && (scaleX = params.scaleX, scaleY = params.scaleY, delete params.scaleX,
673
- delete params.scaleY, this.applyBaseAttributes(params));
674
- const attribute = this.baseAttributes;
813
+ delete params.scaleY);
814
+ const attribute = this.baseAttributes, nextAttrs = params || {};
675
815
  if (scaleCenter) {
676
- let {postMatrix: postMatrix} = this.attribute;
677
- postMatrix || (postMatrix = new Matrix, attribute.postMatrix = postMatrix), application.transformUtil.fromMatrix(postMatrix, postMatrix).scale(scaleX, scaleY, scaleCenter);
678
- } else attribute.scaleX = (null !== (_a = attribute.scaleX) && void 0 !== _a ? _a : DefaultTransform.scaleX) * scaleX,
679
- attribute.scaleY = (null !== (_b = attribute.scaleY) && void 0 !== _b ? _b : DefaultTransform.scaleY) * scaleY;
680
- return this.commitBaseAttributeMutation(!1, context), this;
816
+ let {postMatrix: postMatrix} = this.baseAttributes;
817
+ postMatrix = postMatrix ? postMatrix.clone() : new Matrix, application.transformUtil.fromMatrix(postMatrix, postMatrix).scale(scaleX, scaleY, scaleCenter),
818
+ nextAttrs.postMatrix = postMatrix;
819
+ } else nextAttrs.scaleX = (null !== (_a = attribute.scaleX) && void 0 !== _a ? _a : DefaultTransform.scaleX) * scaleX,
820
+ nextAttrs.scaleY = (null !== (_b = attribute.scaleY) && void 0 !== _b ? _b : DefaultTransform.scaleY) * scaleY;
821
+ return this.commitInternalBaseAttributes(nextAttrs, context), this;
681
822
  }
682
823
  scaleTo(scaleX, scaleY) {
683
824
  const attribute = this.baseAttributes;
@@ -688,9 +829,10 @@ export class Graphic extends Node {
688
829
  scaleX: scaleX,
689
830
  scaleY: scaleY
690
831
  }, this.attribute, tempConstantScaleXYKey, context);
691
- return params ? (this.applyBaseAttributes(params), this.commitBaseAttributeMutation(!1, context),
692
- this) : (attribute.scaleX = scaleX, attribute.scaleY = scaleY, this.commitBaseAttributeMutation(!1, context),
693
- this);
832
+ return params ? (this.commitInternalBaseAttributes(params, context), this) : (this.commitInternalBaseAttributes({
833
+ scaleX: scaleX,
834
+ scaleY: scaleY
835
+ }, context), this);
694
836
  }
695
837
  rotate(angle, rotateCenter) {
696
838
  var _a;
@@ -701,24 +843,23 @@ export class Graphic extends Node {
701
843
  angle: angle,
702
844
  rotateCenter: rotateCenter
703
845
  }, this.attribute, tempConstantAngleKey, context);
704
- params && (delete params.angle, this.applyBaseAttributes(params));
705
- const attribute = this.baseAttributes;
846
+ params && delete params.angle;
847
+ const attribute = this.baseAttributes, nextAttrs = params || {};
706
848
  if (rotateCenter) {
707
849
  let {postMatrix: postMatrix} = this.baseAttributes;
708
- postMatrix || (postMatrix = new Matrix, this.baseAttributes.postMatrix = postMatrix),
709
- application.transformUtil.fromMatrix(postMatrix, postMatrix).rotate(angle, rotateCenter);
710
- } else attribute.angle = (null !== (_a = attribute.angle) && void 0 !== _a ? _a : DefaultTransform.angle) + angle;
711
- return this.commitBaseAttributeMutation(!1, context), this;
850
+ postMatrix = postMatrix ? postMatrix.clone() : new Matrix, application.transformUtil.fromMatrix(postMatrix, postMatrix).rotate(angle, rotateCenter),
851
+ nextAttrs.postMatrix = postMatrix;
852
+ } else nextAttrs.angle = (null !== (_a = attribute.angle) && void 0 !== _a ? _a : DefaultTransform.angle) + angle;
853
+ return this.commitInternalBaseAttributes(nextAttrs, context), this;
712
854
  }
713
855
  rotateTo(angle) {
714
- const attribute = this.baseAttributes;
715
- if (attribute.angle === angle) return this;
856
+ if (this.baseAttributes.angle === angle) return this;
716
857
  const context = {
717
858
  type: AttributeUpdateType.ROTATE_TO
718
859
  }, params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate(angle, this.attribute, tempConstantAngleKey, context);
719
- return params ? (this.applyBaseAttributes(params), this.commitBaseAttributeMutation(!1, context),
720
- this) : (attribute.angle = angle, this.commitBaseAttributeMutation(!1, context),
721
- this);
860
+ return params ? (this.commitInternalBaseAttributes(params, context), this) : (this.commitInternalBaseAttributes({
861
+ angle: angle
862
+ }, context), this);
722
863
  }
723
864
  skewTo(b, c) {
724
865
  return this;
@@ -759,6 +900,119 @@ export class Graphic extends Node {
759
900
  stateEngine: this.stateEngine
760
901
  });
761
902
  }
903
+ resolveSimpleLocalStateTransition(states, previousStates) {
904
+ var _a;
905
+ 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;
906
+ if (1 === states.length) {
907
+ const stateName = states[0], hasDefinition = Object.prototype.hasOwnProperty.call(this.states, stateName), nextStates = [ stateName ], changed = !this.sameStateNames(previousStates, nextStates), resolvedStateAttrs = {};
908
+ if (hasDefinition) {
909
+ const attrs = this.states[stateName];
910
+ if (null != attrs) {
911
+ if (!isPlainObjectValue(attrs)) return null;
912
+ const keys = Object.keys(attrs);
913
+ for (let keyIndex = 0; keyIndex < keys.length; keyIndex++) {
914
+ const key = keys[keyIndex];
915
+ if (FULL_STATE_DEFINITION_KEYS.has(key)) return null;
916
+ const attrValue = attrs[key];
917
+ resolvedStateAttrs[key] = isPlainObjectValue(attrValue) ? cloneAttributeValue(attrValue) : attrValue;
918
+ }
919
+ }
920
+ }
921
+ return {
922
+ changed: changed,
923
+ states: nextStates,
924
+ effectiveStates: nextStates,
925
+ resolvedStateAttrs: resolvedStateAttrs
926
+ };
927
+ }
928
+ const uniqueStates = Array.from(new Set(states)), withDefinition = [], withoutDefinition = [];
929
+ for (let i = 0; i < uniqueStates.length; i++) {
930
+ const stateName = uniqueStates[i];
931
+ Object.prototype.hasOwnProperty.call(this.states, stateName) ? withDefinition.push(stateName) : withoutDefinition.push(stateName);
932
+ }
933
+ withDefinition.sort(((left, right) => left.localeCompare(right)));
934
+ const nextStates = withDefinition.concat(withoutDefinition), changed = !this.sameStateNames(previousStates, nextStates), resolvedStateAttrs = {};
935
+ for (let i = 0; i < nextStates.length; i++) {
936
+ const stateName = nextStates[i];
937
+ if (!Object.prototype.hasOwnProperty.call(this.states, stateName)) continue;
938
+ const attrs = this.states[stateName];
939
+ if (null == attrs) continue;
940
+ if (!isPlainObjectValue(attrs)) return null;
941
+ const keys = Object.keys(attrs);
942
+ for (let keyIndex = 0; keyIndex < keys.length; keyIndex++) {
943
+ const key = keys[keyIndex];
944
+ if (FULL_STATE_DEFINITION_KEYS.has(key)) return null;
945
+ const attrValue = attrs[key];
946
+ resolvedStateAttrs[key] = isPlainObjectValue(attrValue) ? cloneAttributeValue(attrValue) : attrValue;
947
+ }
948
+ }
949
+ return {
950
+ changed: changed,
951
+ states: nextStates,
952
+ effectiveStates: nextStates,
953
+ resolvedStateAttrs: resolvedStateAttrs
954
+ };
955
+ }
956
+ resolveGraphicStateTransition(states, previousStates, forceResolverRefresh = !1) {
957
+ var _a, _b, _c, _d;
958
+ let transition = this.resolveSimpleLocalStateTransition(states, previousStates);
959
+ const isSimpleLocalTransition = !!transition;
960
+ let resolvedStateAttrs;
961
+ if (transition) resolvedStateAttrs = transition.resolvedStateAttrs; else {
962
+ const stateResolveBaseAttrs = null !== (_a = this.baseAttributes) && void 0 !== _a ? _a : this.attribute, stateModel = this.createStateModel();
963
+ null === (_b = this.stateEngine) || void 0 === _b || _b.setResolveContext(this, stateResolveBaseAttrs),
964
+ forceResolverRefresh && (null === (_c = this.stateEngine) || void 0 === _c || _c.invalidateResolverCache()),
965
+ 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);
966
+ }
967
+ return {
968
+ transition: transition,
969
+ effectiveStates: null !== (_d = transition.effectiveStates) && void 0 !== _d ? _d : transition.states,
970
+ resolvedStateAttrs: resolvedStateAttrs,
971
+ isSimpleLocalTransition: isSimpleLocalTransition
972
+ };
973
+ }
974
+ normalizeSetStatesOptions(options) {
975
+ return options && "object" == typeof options ? {
976
+ hasAnimation: options.animate,
977
+ animateSameStatePatchChange: !0 === options.animateSameStatePatchChange,
978
+ shouldRefreshSameStatePatch: !0
979
+ } : {
980
+ hasAnimation: "boolean" == typeof options ? options : void 0,
981
+ animateSameStatePatchChange: !1,
982
+ shouldRefreshSameStatePatch: !1
983
+ };
984
+ }
985
+ sameStatePatches(left, right) {
986
+ const leftRecord = null != left ? left : {}, rightRecord = null != right ? right : {}, keys = new Set([ ...Object.keys(leftRecord), ...Object.keys(rightRecord) ]);
987
+ for (const key of keys) {
988
+ if (Object.prototype.hasOwnProperty.call(leftRecord, key) !== Object.prototype.hasOwnProperty.call(rightRecord, key)) return !1;
989
+ if (!areAttributeValuesEqual(leftRecord[key], rightRecord[key])) return !1;
990
+ }
991
+ return !0;
992
+ }
993
+ commitSameStatePatchRefresh(states, hasAnimation, animateSameStatePatchChange = !1) {
994
+ var _a;
995
+ 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);
996
+ if ((!patchChanged || this.beforeStateUpdate(resolvedStateAttrs, previousStates, transition.states, hasAnimation, !1)) && (this.currentStates = transition.states,
997
+ this.effectiveStates = isSimpleLocalTransition ? effectiveStates : [ ...effectiveStates ],
998
+ this.resolvedStatePatch = resolvedStateAttrs, this.sharedStateDirty = !1, this.syncSharedStateActiveRegistrations(),
999
+ patchChanged)) {
1000
+ if (this.stage) {
1001
+ const perfMonitor = getActiveStageStatePerfMonitor(this.stage);
1002
+ null == perfMonitor || perfMonitor.incrementCounter("stateCommits"), null == perfMonitor || perfMonitor.recordEvent("state-commit", {
1003
+ graphicId: this._uid,
1004
+ targetStates: [ ...transition.states ]
1005
+ });
1006
+ }
1007
+ hasAnimation && animateSameStatePatchChange ? (this._syncFinalAttributeFromStaticTruth(),
1008
+ this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !1, void 0, this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch))) : (this.stopStateAnimates(),
1009
+ this.attributeMayContainTransientAttrs ? this._restoreAttributeFromStaticTruth({
1010
+ type: AttributeUpdateType.STATE
1011
+ }) : this.restoreAttributeFromStatePatchDelta(previousResolvedStatePatch, this.resolvedStatePatch, {
1012
+ type: AttributeUpdateType.STATE
1013
+ }), this.emitStateUpdateEvent());
1014
+ }
1015
+ }
762
1016
  resolveStateAnimateConfig(animateConfig) {
763
1017
  var _a, _b, _c;
764
1018
  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 : DefaultStateAnimateConfig;
@@ -778,9 +1032,7 @@ export class Graphic extends Node {
778
1032
  });
779
1033
  this.getStateTransitionOrchestrator().applyTransition(this, plan, hasAnimation, transitionOptions);
780
1034
  }
781
- updateNormalAttrs(stateAttrs) {
782
- this._deprecatedNormalAttrsView = cloneAttributeValue(this.baseAttributes);
783
- }
1035
+ updateNormalAttrs(_stateAttrs) {}
784
1036
  getStateTransitionDefaultAttribute(key, targetAttrs) {
785
1037
  return this.getDefaultAttribute(key);
786
1038
  }
@@ -790,6 +1042,7 @@ export class Graphic extends Node {
790
1042
  stopStateAnimates(type = "end") {
791
1043
  const stopAnimationState = this.stopAnimationState;
792
1044
  if ("function" == typeof stopAnimationState) return void stopAnimationState.call(this, "state", type);
1045
+ if (!this.mayHaveTrackedAnimates()) return;
793
1046
  const stateAnimates = [];
794
1047
  this.visitTrackedAnimates((animate => {
795
1048
  animate.stateNames && stateAnimates.push(animate);
@@ -802,23 +1055,27 @@ export class Graphic extends Node {
802
1055
  }
803
1056
  clearStates(hasAnimation) {
804
1057
  var _a, _b, _c;
805
- const previousStates = this.currentStates ? this.currentStates.slice() : [], previousResolvedStatePatch = this.resolvedStatePatch ? cloneAttributeValue(this.resolvedStatePatch) : void 0, transition = this.createStateModel().clearStates();
1058
+ const previousStates = null !== (_a = this.currentStates) && void 0 !== _a ? _a : EMPTY_STATE_NAMES, previousResolvedStatePatch = this.resolvedStatePatch, transition = this.createStateModel().clearStates();
806
1059
  if (!transition.changed && 0 === previousStates.length) return this.currentStates = [],
807
1060
  this.effectiveStates = [], this.resolvedStatePatch = void 0, this.sharedStateDirty = !1,
808
1061
  void this.clearSharedStateActiveRegistrations();
809
- const resolvedStateAttrs = cloneAttributeValue(null !== (_a = this.baseAttributes) && void 0 !== _a ? _a : {});
810
- transition.changed && !this.beforeStateUpdate(resolvedStateAttrs, previousStates, transition.states, hasAnimation, !0) || (this.currentStates = transition.states,
811
- this.effectiveStates = [], this.resolvedStatePatch = void 0, this.sharedStateDirty = !1,
812
- this.clearSharedStateActiveRegistrations(), null === (_b = getStageStatePerfMonitor(this.stage)) || void 0 === _b || _b.incrementCounter("stateCommits"),
813
- null === (_c = getStageStatePerfMonitor(this.stage)) || void 0 === _c || _c.recordEvent("state-commit", {
814
- graphicId: this._uid,
815
- targetStates: []
816
- }), hasAnimation ? (this._syncFinalAttributeFromStaticTruth(), this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !0, void 0, this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch))) : (this.stopStateAnimates(),
817
- this._restoreAttributeFromStaticTruth({
818
- type: AttributeUpdateType.STATE
819
- }), this._emitCustomEvent("afterStateUpdate", {
820
- type: AttributeUpdateType.STATE
821
- })));
1062
+ const resolvedStateAttrs = hasAnimation || this.hasCustomEvent("beforeStateUpdate") ? cloneAttributeValue(null !== (_b = this.baseAttributes) && void 0 !== _b ? _b : {}) : null !== (_c = this.baseAttributes) && void 0 !== _c ? _c : {};
1063
+ if (!transition.changed || this.beforeStateUpdate(resolvedStateAttrs, previousStates, transition.states, hasAnimation, !0)) {
1064
+ if (this.currentStates = transition.states, this.effectiveStates = [], this.resolvedStatePatch = void 0,
1065
+ this.sharedStateDirty = !1, this.clearSharedStateActiveRegistrations(), this.stage) {
1066
+ const perfMonitor = getActiveStageStatePerfMonitor(this.stage);
1067
+ null == perfMonitor || perfMonitor.incrementCounter("stateCommits"), null == perfMonitor || perfMonitor.recordEvent("state-commit", {
1068
+ graphicId: this._uid,
1069
+ targetStates: []
1070
+ });
1071
+ }
1072
+ hasAnimation ? (this._syncFinalAttributeFromStaticTruth(), this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !0, void 0, this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch))) : (this.stopStateAnimates(),
1073
+ this.attributeMayContainTransientAttrs ? this._restoreAttributeFromStaticTruth({
1074
+ type: AttributeUpdateType.STATE
1075
+ }) : this.restoreAttributeFromStatePatchDelta(previousResolvedStatePatch, void 0, {
1076
+ type: AttributeUpdateType.STATE
1077
+ }), this.emitStateUpdateEvent());
1078
+ }
822
1079
  }
823
1080
  removeState(stateName, hasAnimation) {
824
1081
  const transition = this.createStateModel().removeState(stateName);
@@ -832,41 +1089,51 @@ export class Graphic extends Node {
832
1089
  const transition = this.createStateModel().addState(stateName, keepCurrentStates);
833
1090
  transition.changed && this.useStates(transition.states, hasAnimation);
834
1091
  }
1092
+ setStates(states, options) {
1093
+ var _a, _b, _c;
1094
+ 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));
1095
+ if (nextStates.length) {
1096
+ if (this.sameStateNames(this.currentStates, nextStates)) return shouldRefreshSameStatePatch ? void this.commitSameStatePatchRefresh(nextStates, hasAnimation, animateSameStatePatchChange) : void (this.sharedStateDirty && this.refreshSharedStateBeforeRender());
1097
+ this.useStates(nextStates, hasAnimation);
1098
+ } else {
1099
+ if (!hasCurrentState && !this.sharedStateDirty) return;
1100
+ this.clearStates(hasAnimation);
1101
+ }
1102
+ }
835
1103
  useStates(states, hasAnimation) {
836
- var _a, _b, _c, _d, _e;
1104
+ var _a;
837
1105
  if (!states.length) return void this.clearStates(hasAnimation);
838
- 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();
839
- null === (_b = this.stateEngine) || void 0 === _b || _b.setResolveContext(this, stateResolveBaseAttrs);
840
- const transition = stateModel.useStates(states);
841
- if (!transition.changed && this.sameStateNames(previousStates, transition.states)) return;
842
- 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);
843
- this.beforeStateUpdate(resolvedStateAttrs, previousStates, transition.states, hasAnimation, !1) && (this.currentStates = transition.states,
844
- this.effectiveStates = [ ...effectiveStates ], this.resolvedStatePatch = Object.assign({}, resolvedStateAttrs),
845
- this.sharedStateDirty = !1, this.syncSharedStateActiveRegistrations(), null === (_d = getStageStatePerfMonitor(this.stage)) || void 0 === _d || _d.incrementCounter("stateCommits"),
846
- null === (_e = getStageStatePerfMonitor(this.stage)) || void 0 === _e || _e.recordEvent("state-commit", {
847
- graphicId: this._uid,
848
- targetStates: [ ...transition.states ]
849
- }), hasAnimation ? (this._syncFinalAttributeFromStaticTruth(), this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !1, void 0, this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch))) : (this.stopStateAnimates(),
850
- this._restoreAttributeFromStaticTruth({
851
- type: AttributeUpdateType.STATE
852
- }), this._emitCustomEvent("afterStateUpdate", {
853
- type: AttributeUpdateType.STATE
854
- })));
1106
+ 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);
1107
+ if ((transition.changed || !this.sameStateNames(previousStates, transition.states)) && this.beforeStateUpdate(resolvedStateAttrs, previousStates, transition.states, hasAnimation, !1)) {
1108
+ if (this.currentStates = transition.states, this.effectiveStates = isSimpleLocalTransition ? effectiveStates : [ ...effectiveStates ],
1109
+ this.resolvedStatePatch = resolvedStateAttrs, this.sharedStateDirty = !1, this.syncSharedStateActiveRegistrations(),
1110
+ this.stage) {
1111
+ const perfMonitor = getActiveStageStatePerfMonitor(this.stage);
1112
+ null == perfMonitor || perfMonitor.incrementCounter("stateCommits"), null == perfMonitor || perfMonitor.recordEvent("state-commit", {
1113
+ graphicId: this._uid,
1114
+ targetStates: [ ...transition.states ]
1115
+ });
1116
+ }
1117
+ hasAnimation ? (this._syncFinalAttributeFromStaticTruth(), this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !1, void 0, this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch))) : (this.stopStateAnimates(),
1118
+ this.attributeMayContainTransientAttrs ? this._restoreAttributeFromStaticTruth({
1119
+ type: AttributeUpdateType.STATE
1120
+ }) : this.restoreAttributeFromStatePatchDelta(previousResolvedStatePatch, this.resolvedStatePatch, {
1121
+ type: AttributeUpdateType.STATE
1122
+ }), this.emitStateUpdateEvent());
1123
+ }
855
1124
  }
856
1125
  invalidateResolver() {
857
- var _a, _b;
1126
+ var _a, _b, _c;
858
1127
  if (!this.stateEngine || !(null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) || !this.compiledStateDefinitions) return;
859
1128
  const stateResolveBaseAttrs = null !== (_b = this.baseAttributes) && void 0 !== _b ? _b : this.attribute;
860
- this.stateEngine.setResolveContext(this, stateResolveBaseAttrs), this.resolverEpoch += 1,
1129
+ this.stateEngine.setResolveContext(this, stateResolveBaseAttrs), this.resolverEpoch = (null !== (_c = this.resolverEpoch) && void 0 !== _c ? _c : 0) + 1,
861
1130
  this.stateEngine.invalidateResolverCache();
862
1131
  const transition = this.stateEngine.applyStates(this.currentStates), resolvedStateAttrs = Object.assign({}, this.stateEngine.resolvedPatch);
863
- this.effectiveStates = [ ...transition.effectiveStates ], this.resolvedStatePatch = Object.assign({}, resolvedStateAttrs),
1132
+ this.effectiveStates = [ ...transition.effectiveStates ], this.resolvedStatePatch = resolvedStateAttrs,
864
1133
  this.sharedStateDirty = !1, this.syncSharedStateActiveRegistrations(), this.stopStateAnimates(),
865
1134
  this._restoreAttributeFromStaticTruth({
866
1135
  type: AttributeUpdateType.STATE
867
- }), this._emitCustomEvent("afterStateUpdate", {
868
- type: AttributeUpdateType.STATE
869
- });
1136
+ }), this.emitStateUpdateEvent();
870
1137
  }
871
1138
  sameStateNames(left, right) {
872
1139
  const normalizedLeft = null != left ? left : [], normalizedRight = null != right ? right : [];
@@ -888,6 +1155,10 @@ export class Graphic extends Node {
888
1155
  this._updateTag |= UpdateTag.UPDATE_SHAPE_AND_BOUNDS, this.parent && this.parent.addChildUpdateBoundTag(),
889
1156
  this.glyphHost && this.glyphHost.addUpdateBoundTag();
890
1157
  }
1158
+ addBroadUpdateTag() {
1159
+ this.shadowRoot && this.shadowRoot.addUpdateGlobalPositionTag(), this._updateTag |= UpdateTag.UPDATE_SHAPE_AND_BOUNDS | UpdateTag.UPDATE_PAINT | UpdateTag.UPDATE_GLOBAL_LOCAL_MATRIX | UpdateTag.UPDATE_LAYOUT,
1160
+ this.parent && this.parent.addChildUpdateBoundTag(), this.glyphHost && this.glyphHost.addUpdateBoundTag();
1161
+ }
891
1162
  updateShapeAndBoundsTagSetted() {
892
1163
  return (this._updateTag & UpdateTag.UPDATE_SHAPE_AND_BOUNDS) === UpdateTag.UPDATE_SHAPE_AND_BOUNDS;
893
1164
  }
@@ -961,12 +1232,12 @@ export class Graphic extends Node {
961
1232
  }
962
1233
  }
963
1234
  setStage(stage, layer) {
964
- var _a, _b, _c, _d, _e, _f, _g, _h;
1235
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
965
1236
  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.graphicService, previousStage = this.stage;
966
1237
  if (this.stage !== stage || this.layer !== layer) {
967
- if (this.stage = stage, this.layer = layer, this.syncSharedStateScopeBindingFromTree(!!(null === (_d = this.currentStates) || void 0 === _d ? void 0 : _d.length)),
968
- this.setStageToShadowRoot(stage, layer), this.hasAnyTrackedAnimate()) {
969
- 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 = [];
1238
+ 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),
1239
+ this.setStageToShadowRoot(stage, layer), this.mayHaveTrackedAnimates() && this.hasAnyTrackedAnimate()) {
1240
+ 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 = [];
970
1241
  this.visitTrackedAnimates((a => {
971
1242
  (!!previousTimeline && a.timeline === previousTimeline || a.timeline.isGlobal) && (nextTimeline ? a.timeline !== nextTimeline && (previousTimeline && a.timeline === previousTimeline && previousTimeline.removeAnimate(a, !1),
972
1243
  a.setTimeline(nextTimeline), nextTimeline.addAnimate(a)) : previousTimeline && a.timeline === previousTimeline && (previousTimeline.removeAnimate(a, !1),
@@ -980,9 +1251,18 @@ export class Graphic extends Node {
980
1251
  type: AttributeUpdateType.ANIMATE_END
981
1252
  }));
982
1253
  }
983
- 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));
1254
+ 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));
984
1255
  }
985
- this.syncSharedStateScopeBindingFromTree(!!(null === (_h = this.currentStates) || void 0 === _h ? void 0 : _h.length));
1256
+ ((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);
1257
+ }
1258
+ detachStageForRelease() {
1259
+ var _a, _b, _c;
1260
+ (null === (_a = this.registeredActiveScopes) || void 0 === _a ? void 0 : _a.size) && this.clearSharedStateActiveRegistrations(),
1261
+ (this.mayHaveTrackedAnimates() || this.shadowRoot) && this.stopAnimates(), this.boundSharedStateScope = void 0,
1262
+ this.boundSharedStateRevision = void 0, this.localFallbackCompiledDefinitions = void 0,
1263
+ this.compiledStateDefinitions = void 0, this.compiledStateDefinitionsCacheKey = void 0,
1264
+ this.stateEngine = void 0, this.stateEngineCompiledDefinitions = void 0, this.stateEngineStateProxyModeKey = void 0,
1265
+ this.sharedStateDirty = !1, this.stage = null, this.layer = null, this.shadowRoot && (null === (_c = (_b = this.shadowRoot).detachStageForRelease) || void 0 === _c || _c.call(_b));
986
1266
  }
987
1267
  setStageToShadowRoot(stage, layer) {
988
1268
  this.shadowRoot && this.shadowRoot.setStage(stage, layer);
@@ -1056,6 +1336,7 @@ export class Graphic extends Node {
1056
1336
  res && (res.state = "fail", cb && cb());
1057
1337
  }
1058
1338
  _stopAnimates() {
1339
+ if (!this.mayHaveTrackedAnimates()) return;
1059
1340
  const animates = [];
1060
1341
  this.visitTrackedAnimates((animate => {
1061
1342
  animates.push(animate);
@@ -1069,15 +1350,19 @@ export class Graphic extends Node {
1069
1350
  }));
1070
1351
  }
1071
1352
  release() {
1072
- var _a, _b, _c;
1073
- this.releaseStatus = "released", this.clearSharedStateActiveRegistrations(), this.stopAnimates();
1074
- const graphicService = null !== (_b = null === (_a = this.stage) || void 0 === _a ? void 0 : _a.graphicService) && void 0 !== _b ? _b : application.graphicService;
1075
- null === (_c = null == graphicService ? void 0 : graphicService.onRelease) || void 0 === _c || _c.call(graphicService, this),
1353
+ var _a, _b, _c, _d;
1354
+ this.releaseStatus = "released", (null === (_a = this.registeredActiveScopes) || void 0 === _a ? void 0 : _a.size) && this.clearSharedStateActiveRegistrations(),
1355
+ (this.mayHaveTrackedAnimates() || this.shadowRoot) && this.stopAnimates();
1356
+ const graphicService = null !== (_c = null === (_b = this.stage) || void 0 === _b ? void 0 : _b.graphicService) && void 0 !== _c ? _c : application.graphicService;
1357
+ null === (_d = null == graphicService ? void 0 : graphicService.onRelease) || void 0 === _d || _d.call(graphicService, this),
1076
1358
  super.release();
1077
1359
  }
1360
+ hasCustomEvent(type) {
1361
+ return !!this._events && type in this._events;
1362
+ }
1078
1363
  _dispatchCustomEvent(type, context) {
1079
1364
  var _a, _b;
1080
- if (this._events && type in this._events) {
1365
+ if (this.hasCustomEvent(type)) {
1081
1366
  const changeEvent = new CustomEvent(type, context);
1082
1367
  changeEvent.bubbles = !1;
1083
1368
  const manager = null === (_b = null === (_a = this.stage) || void 0 === _a ? void 0 : _a.eventSystem) || void 0 === _b ? void 0 : _b.manager;
@@ -1086,7 +1371,7 @@ export class Graphic extends Node {
1086
1371
  return !0;
1087
1372
  }
1088
1373
  beforeStateUpdate(attrs, prevStates, nextStates, hasAnimation, isClear) {
1089
- return this._dispatchCustomEvent("beforeStateUpdate", {
1374
+ return !this.hasCustomEvent("beforeStateUpdate") || this._dispatchCustomEvent("beforeStateUpdate", {
1090
1375
  type: AttributeUpdateType.STATE,
1091
1376
  attrs: Object.assign({}, attrs),
1092
1377
  prevStates: prevStates.slice(),
@@ -1095,6 +1380,11 @@ export class Graphic extends Node {
1095
1380
  isClear: !!isClear
1096
1381
  });
1097
1382
  }
1383
+ emitStateUpdateEvent() {
1384
+ this.hasCustomEvent("afterStateUpdate") && this._emitCustomEvent("afterStateUpdate", {
1385
+ type: AttributeUpdateType.STATE
1386
+ });
1387
+ }
1098
1388
  _emitCustomEvent(type, context) {
1099
1389
  this._dispatchCustomEvent(type, context);
1100
1390
  }