@visactor/vrender-core 1.1.0-alpha.12 → 1.1.0-alpha.14

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 (40) hide show
  1. package/cjs/common/canvas-utils.js +0 -1
  2. package/cjs/common/event-transformer.js +2 -1
  3. package/cjs/common/explicit-binding.js +1 -1
  4. package/cjs/common/generator.js +1 -1
  5. package/cjs/common/matrix.js +1 -1
  6. package/cjs/common/morphing-utils.js +1 -1
  7. package/cjs/common/path-svg.js +1 -1
  8. package/cjs/common/performance-raf.js +1 -1
  9. package/cjs/common/polygon.js +2 -2
  10. package/cjs/entries/app-context.js +1 -1
  11. package/cjs/entries/browser.js +1 -1
  12. package/cjs/entries/index.js +1 -1
  13. package/cjs/entries/miniapp.js +1 -1
  14. package/cjs/entries/node.js +1 -1
  15. package/cjs/entries/runtime-installer.js +1 -1
  16. package/cjs/entries/types.js +1 -1
  17. package/cjs/graphic/graphic.d.ts +4 -0
  18. package/cjs/graphic/graphic.js +36 -4
  19. package/cjs/graphic/graphic.js.map +1 -1
  20. package/dist/index.es.js +89 -3
  21. package/es/common/canvas-utils.js +1 -2
  22. package/es/common/event-transformer.js +2 -1
  23. package/es/common/explicit-binding.js +1 -1
  24. package/es/common/generator.js +1 -1
  25. package/es/common/matrix.js +1 -1
  26. package/es/common/morphing-utils.js +1 -1
  27. package/es/common/path-svg.js +1 -1
  28. package/es/common/performance-raf.js +1 -1
  29. package/es/common/polygon.js +1 -1
  30. package/es/entries/app-context.js +1 -1
  31. package/es/entries/browser.js +1 -1
  32. package/es/entries/index.js +1 -1
  33. package/es/entries/miniapp.js +1 -1
  34. package/es/entries/node.js +1 -1
  35. package/es/entries/runtime-installer.js +1 -1
  36. package/es/entries/types.js +1 -1
  37. package/es/graphic/graphic.d.ts +4 -0
  38. package/es/graphic/graphic.js +35 -4
  39. package/es/graphic/graphic.js.map +1 -1
  40. package/package.json +2 -2
package/dist/index.es.js CHANGED
@@ -11309,16 +11309,102 @@ class Graphic extends Node {
11309
11309
  this.heightWithoutTransform = aabbBounds.y2 - aabbBounds.y1;
11310
11310
  }
11311
11311
  setAttributesAndPreventAnimate(params, forceUpdateTag = false, context, ignorePriority) {
11312
+ if (!params) {
11313
+ return;
11314
+ }
11315
+ const keys = Object.keys(params);
11316
+ this.captureTransientFromAttrsBeforePreventAnimate(params, keys, context);
11312
11317
  this.visitTrackedAnimates(animate => {
11313
11318
  if (animate.priority === Infinity && !ignorePriority) {
11314
11319
  return;
11315
11320
  }
11316
- Object.keys(params).forEach(key => {
11317
- animate.preventAttr(key);
11318
- });
11321
+ animate.preventAttrs(keys);
11319
11322
  });
11320
11323
  this.applyTransientAttributes(params, forceUpdateTag, context);
11321
11324
  }
11325
+ captureTransientFromAttrsBeforePreventAnimate(params, keys, context) {
11326
+ var _a;
11327
+ const graphicContext = this.context;
11328
+ const diffAttrs = graphicContext === null || graphicContext === void 0 ? void 0 : graphicContext.diffAttrs;
11329
+ const updateType = context === null || context === void 0 ? void 0 : context.type;
11330
+ if (!keys.length ||
11331
+ !graphicContext ||
11332
+ !diffAttrs ||
11333
+ updateType === AttributeUpdateType.STATE ||
11334
+ (updateType != null &&
11335
+ updateType >= AttributeUpdateType.ANIMATE_BIND &&
11336
+ updateType <= AttributeUpdateType.ANIMATE_END)) {
11337
+ return;
11338
+ }
11339
+ const sameDiffAttrs = this.transientFromAttrsBeforePreventAnimateDiffAttrs === diffAttrs;
11340
+ let fromAttrs = sameDiffAttrs
11341
+ ? (_a = this.transientFromAttrsBeforePreventAnimate) !== null && _a !== void 0 ? _a : null
11342
+ : null;
11343
+ if (!sameDiffAttrs) {
11344
+ this.transientFromAttrsBeforePreventAnimate = null;
11345
+ this.transientFromAttrsBeforePreventAnimateDiffAttrs = null;
11346
+ }
11347
+ let captured = false;
11348
+ for (let i = 0; i < keys.length; i++) {
11349
+ const key = keys[i];
11350
+ if (!Object.prototype.hasOwnProperty.call(diffAttrs, key)) {
11351
+ continue;
11352
+ }
11353
+ const previousValue = this.attribute[key];
11354
+ const nextValue = params[key];
11355
+ if (isEqual(previousValue, nextValue)) {
11356
+ continue;
11357
+ }
11358
+ fromAttrs !== null && fromAttrs !== void 0 ? fromAttrs : (fromAttrs = {});
11359
+ fromAttrs[key] = cloneAttributeValue(previousValue);
11360
+ captured = true;
11361
+ }
11362
+ if (captured) {
11363
+ this.transientFromAttrsBeforePreventAnimate = fromAttrs;
11364
+ this.transientFromAttrsBeforePreventAnimateDiffAttrs = diffAttrs;
11365
+ }
11366
+ }
11367
+ consumeTransientFromAttrsBeforePreventAnimate(diffAttrs) {
11368
+ const transientFromAttrs = this.transientFromAttrsBeforePreventAnimate;
11369
+ const sourceDiffAttrs = this.transientFromAttrsBeforePreventAnimateDiffAttrs;
11370
+ if (!transientFromAttrs || !sourceDiffAttrs) {
11371
+ return null;
11372
+ }
11373
+ for (const key in diffAttrs) {
11374
+ if (Object.prototype.hasOwnProperty.call(diffAttrs, key) &&
11375
+ (!Object.prototype.hasOwnProperty.call(sourceDiffAttrs, key) || !isEqual(sourceDiffAttrs[key], diffAttrs[key]))) {
11376
+ return null;
11377
+ }
11378
+ }
11379
+ let fromAttrs = null;
11380
+ let remaining = false;
11381
+ for (const key in transientFromAttrs) {
11382
+ if (!Object.prototype.hasOwnProperty.call(transientFromAttrs, key)) {
11383
+ continue;
11384
+ }
11385
+ if (Object.prototype.hasOwnProperty.call(diffAttrs, key)) {
11386
+ fromAttrs !== null && fromAttrs !== void 0 ? fromAttrs : (fromAttrs = {});
11387
+ fromAttrs[key] = transientFromAttrs[key];
11388
+ continue;
11389
+ }
11390
+ remaining = true;
11391
+ }
11392
+ if (remaining) {
11393
+ const nextTransientFromAttrs = {};
11394
+ for (const key in transientFromAttrs) {
11395
+ if (Object.prototype.hasOwnProperty.call(transientFromAttrs, key) &&
11396
+ !Object.prototype.hasOwnProperty.call(diffAttrs, key)) {
11397
+ nextTransientFromAttrs[key] = transientFromAttrs[key];
11398
+ }
11399
+ }
11400
+ this.transientFromAttrsBeforePreventAnimate = nextTransientFromAttrs;
11401
+ }
11402
+ else {
11403
+ this.transientFromAttrsBeforePreventAnimate = null;
11404
+ this.transientFromAttrsBeforePreventAnimateDiffAttrs = null;
11405
+ }
11406
+ return fromAttrs;
11407
+ }
11322
11408
  setAttributes(params, forceUpdateTag = false, context) {
11323
11409
  if (!params) {
11324
11410
  return;
@@ -51,5 +51,4 @@ function createConicGradient(context, color, x, y, w, h) {
51
51
  return color.stops.forEach((stop => {
52
52
  canvasGradient.addColorStop(stop.offset, stop.color);
53
53
  })), canvasGradient.GetPattern ? canvasGradient.GetPattern(w + x, h + y, undefined) : canvasGradient;
54
- }
55
- //# sourceMappingURL=canvas-utils.js.map
54
+ }
@@ -113,4 +113,5 @@ export function mapToCanvasPointForCanvas(nativeEvent) {
113
113
  x: nativeEvent._canvasX || 0,
114
114
  y: nativeEvent._canvasY || 0
115
115
  };
116
- }
116
+ }
117
+ //# sourceMappingURL=event-transformer.js.map
@@ -7,4 +7,4 @@ export function resolveContainerBinding(container, serviceIdentifier) {
7
7
  if (null == instance) throw new Error(`No binding found for ${describeServiceIdentifier(serviceIdentifier)}.`);
8
8
  return instance;
9
9
  }
10
- //# sourceMappingURL=explicit-binding.js.map
10
+ //# sourceMappingURL=explicit-binding.js.map
@@ -5,4 +5,4 @@ export class Generator {
5
5
  }
6
6
 
7
7
  Generator.auto_increment_id = 0;
8
- //# sourceMappingURL=generator.js.map
8
+ //# sourceMappingURL=generator.js.map
@@ -118,4 +118,4 @@ export function transformMat4(out, a, m) {
118
118
  return w = w || 1, out[0] = (m[0] * x + m[4] * y + m[8] * z + m[12]) / w, out[1] = (m[1] * x + m[5] * y + m[9] * z + m[13]) / w,
119
119
  out[2] = (m[2] * x + m[6] * y + m[10] * z + m[14]) / w, out;
120
120
  }
121
- //# sourceMappingURL=matrix.js.map
121
+ //# sourceMappingURL=matrix.js.map
@@ -189,4 +189,4 @@ export function bezierCurversToPath(bezierCurves) {
189
189
  }
190
190
  return path;
191
191
  }
192
- //# sourceMappingURL=morphing-utils.js.map
192
+ //# sourceMappingURL=morphing-utils.js.map
@@ -55,4 +55,4 @@ export function parseSvgPath(str) {
55
55
  } else result.push(currCommandData);
56
56
  return result;
57
57
  }
58
- //# sourceMappingURL=path-svg.js.map
58
+ //# sourceMappingURL=path-svg.js.map
@@ -26,4 +26,4 @@ export class PerformanceRAF {
26
26
  }));
27
27
  }
28
28
  }
29
- //# sourceMappingURL=performance-raf.js.map
29
+ //# sourceMappingURL=performance-raf.js.map
@@ -38,4 +38,4 @@ function getProportionPoint(point, segment, length, dx, dy) {
38
38
  y: point.y - dy * factor
39
39
  };
40
40
  }
41
- //# sourceMappingURL=polygon.js.map
41
+ //# sourceMappingURL=polygon.js.map
@@ -83,4 +83,4 @@ export class AppContext {
83
83
  };
84
84
  }
85
85
  }
86
- //# sourceMappingURL=app-context.js.map
86
+ //# sourceMappingURL=app-context.js.map
@@ -33,4 +33,4 @@ export class BrowserEntry {
33
33
  export function createBrowserApp(options = {}) {
34
34
  return new BrowserEntry(options);
35
35
  }
36
- //# sourceMappingURL=browser.js.map
36
+ //# sourceMappingURL=browser.js.map
@@ -11,4 +11,4 @@ export * from "./miniapp";
11
11
  export * from "./runtime-installer";
12
12
 
13
13
  export { createBrowserApp as createApp } from "./browser";
14
- //# sourceMappingURL=index.js.map
14
+ //# sourceMappingURL=index.js.map
@@ -9,4 +9,4 @@ export class MiniappEntry extends BrowserEntry {
9
9
  export function createMiniappApp(options = {}) {
10
10
  return new MiniappEntry(options);
11
11
  }
12
- //# sourceMappingURL=miniapp.js.map
12
+ //# sourceMappingURL=miniapp.js.map
@@ -9,4 +9,4 @@ export class NodeEntry extends BrowserEntry {
9
9
  export function createNodeApp(options = {}) {
10
10
  return new NodeEntry(options);
11
11
  }
12
- //# sourceMappingURL=node.js.map
12
+ //# sourceMappingURL=node.js.map
@@ -127,4 +127,4 @@ export function installRuntimePickersToApp(app, serviceIdentifier) {
127
127
  const pickers = bindingContext.getAll(serviceIdentifier);
128
128
  app.registry.picker.clear(), registerRuntimeEntries(((key, picker) => app.registry.picker.register(key, picker)), pickers, "runtime-picker");
129
129
  }
130
- //# sourceMappingURL=runtime-installer.js.map
130
+ //# sourceMappingURL=runtime-installer.js.map
@@ -1,2 +1,2 @@
1
1
  export { };
2
- //# sourceMappingURL=types.js.map
2
+ //# sourceMappingURL=types.js.map
@@ -52,6 +52,8 @@ export declare abstract class Graphic<T extends Partial<IGraphicAttribute> = Par
52
52
  static mixin(source: Dict<any>): void;
53
53
  _events?: any;
54
54
  context?: Record<string, any>;
55
+ private transientFromAttrsBeforePreventAnimate?;
56
+ private transientFromAttrsBeforePreventAnimateDiffAttrs?;
55
57
  static userSymbolMap: Record<string, ISymbolClass>;
56
58
  onBeforeAttributeUpdate?: (val: any, attributes: Partial<T>, key: null | string | string[], context?: ISetAttributeContext) => T | undefined;
57
59
  parent: any;
@@ -189,6 +191,8 @@ export declare abstract class Graphic<T extends Partial<IGraphicAttribute> = Par
189
191
  containsPoint(x: number, y: number, mode: IContainPointMode, picker?: IPickerService): boolean;
190
192
  protected setWidthHeightWithoutTransform(aabbBounds: IAABBBounds): void;
191
193
  setAttributesAndPreventAnimate(params: Partial<T>, forceUpdateTag?: boolean, context?: ISetAttributeContext, ignorePriority?: boolean): void;
194
+ protected captureTransientFromAttrsBeforePreventAnimate(params: Partial<T>, keys: string[], context?: ISetAttributeContext): void;
195
+ protected consumeTransientFromAttrsBeforePreventAnimate(diffAttrs: Record<string, any>): Record<string, any> | null;
192
196
  setAttributes(params: Partial<T>, forceUpdateTag?: boolean, context?: ISetAttributeContext): void;
193
197
  _setAttributes(params: Partial<T>, forceUpdateTag?: boolean, context?: ISetAttributeContext): void;
194
198
  setAttribute(key: string, value: any, forceUpdateTag?: boolean, context?: ISetAttributeContext): void;
@@ -555,12 +555,43 @@ export class Graphic extends Node {
555
555
  this.widthWithoutTransform = aabbBounds.x2 - aabbBounds.x1, this.heightWithoutTransform = aabbBounds.y2 - aabbBounds.y1;
556
556
  }
557
557
  setAttributesAndPreventAnimate(params, forceUpdateTag = !1, context, ignorePriority) {
558
- this.visitTrackedAnimates((animate => {
559
- (animate.priority !== 1 / 0 || ignorePriority) && Object.keys(params).forEach((key => {
560
- animate.preventAttr(key);
561
- }));
558
+ if (!params) return;
559
+ const keys = Object.keys(params);
560
+ this.captureTransientFromAttrsBeforePreventAnimate(params, keys, context), this.visitTrackedAnimates((animate => {
561
+ (animate.priority !== 1 / 0 || ignorePriority) && animate.preventAttrs(keys);
562
562
  })), this.applyTransientAttributes(params, forceUpdateTag, context);
563
563
  }
564
+ captureTransientFromAttrsBeforePreventAnimate(params, keys, context) {
565
+ var _a;
566
+ const graphicContext = this.context, diffAttrs = null == graphicContext ? void 0 : graphicContext.diffAttrs, updateType = null == context ? void 0 : context.type;
567
+ if (!keys.length || !graphicContext || !diffAttrs || updateType === AttributeUpdateType.STATE || null != updateType && updateType >= AttributeUpdateType.ANIMATE_BIND && updateType <= AttributeUpdateType.ANIMATE_END) return;
568
+ const sameDiffAttrs = this.transientFromAttrsBeforePreventAnimateDiffAttrs === diffAttrs;
569
+ let fromAttrs = sameDiffAttrs && null !== (_a = this.transientFromAttrsBeforePreventAnimate) && void 0 !== _a ? _a : null;
570
+ sameDiffAttrs || (this.transientFromAttrsBeforePreventAnimate = null, this.transientFromAttrsBeforePreventAnimateDiffAttrs = null);
571
+ let captured = !1;
572
+ for (let i = 0; i < keys.length; i++) {
573
+ const key = keys[i];
574
+ if (!Object.prototype.hasOwnProperty.call(diffAttrs, key)) continue;
575
+ const previousValue = this.attribute[key], nextValue = params[key];
576
+ isEqual(previousValue, nextValue) || (null != fromAttrs || (fromAttrs = {}), fromAttrs[key] = cloneAttributeValue(previousValue),
577
+ captured = !0);
578
+ }
579
+ captured && (this.transientFromAttrsBeforePreventAnimate = fromAttrs, this.transientFromAttrsBeforePreventAnimateDiffAttrs = diffAttrs);
580
+ }
581
+ consumeTransientFromAttrsBeforePreventAnimate(diffAttrs) {
582
+ const transientFromAttrs = this.transientFromAttrsBeforePreventAnimate, sourceDiffAttrs = this.transientFromAttrsBeforePreventAnimateDiffAttrs;
583
+ if (!transientFromAttrs || !sourceDiffAttrs) return null;
584
+ for (const key in diffAttrs) if (Object.prototype.hasOwnProperty.call(diffAttrs, key) && (!Object.prototype.hasOwnProperty.call(sourceDiffAttrs, key) || !isEqual(sourceDiffAttrs[key], diffAttrs[key]))) return null;
585
+ let fromAttrs = null, remaining = !1;
586
+ for (const key in transientFromAttrs) Object.prototype.hasOwnProperty.call(transientFromAttrs, key) && (Object.prototype.hasOwnProperty.call(diffAttrs, key) ? (null != fromAttrs || (fromAttrs = {}),
587
+ fromAttrs[key] = transientFromAttrs[key]) : remaining = !0);
588
+ if (remaining) {
589
+ const nextTransientFromAttrs = {};
590
+ for (const key in transientFromAttrs) Object.prototype.hasOwnProperty.call(transientFromAttrs, key) && !Object.prototype.hasOwnProperty.call(diffAttrs, key) && (nextTransientFromAttrs[key] = transientFromAttrs[key]);
591
+ this.transientFromAttrsBeforePreventAnimate = nextTransientFromAttrs;
592
+ } else this.transientFromAttrsBeforePreventAnimate = null, this.transientFromAttrsBeforePreventAnimateDiffAttrs = null;
593
+ return fromAttrs;
594
+ }
564
595
  setAttributes(params, forceUpdateTag = !1, context) {
565
596
  params && ((params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate(params, this.attribute, null, context) || params).background && this.loadImage(params.background, !0),
566
597
  isExternalTexture(params.texture) && this.loadImage(params.texture, !1), params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic),