@eva/plugin-renderer-lottie 2.0.1-beta.3 → 2.0.1-beta.4

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.
@@ -10565,8 +10565,6 @@ function createSizedArray(len) {
10565
10565
  return Array.apply(null, { length: len });
10566
10566
  }
10567
10567
 
10568
- window.$commands = [];
10569
-
10570
10568
  class MatrixHelper extends pixi_js.Matrix {
10571
10569
  reset() {
10572
10570
  // 重置为单位矩阵
@@ -11097,18 +11095,17 @@ class SpriteElement extends pixi_js.Sprite {
11097
11095
  * @param {object} config layer data information
11098
11096
  */
11099
11097
  constructor(lottieLayer, imageInfo) {
11100
- const { asset, texture } = imageInfo;
11101
- super(texture.baseTexture.texture);
11098
+ const { texture: texturePromise } = imageInfo;
11099
+ super();
11102
11100
  this.label = lottieLayer.fullname;
11103
11101
 
11104
- if (texture.baseTexture.texture.valid) {
11105
- texture.baseTexture.texture.orig = new pixi_js.Rectangle(0, 0, asset.w, asset.h);
11106
- } else {
11107
- texture.baseTexture.on('loaded', () => {
11108
- this.texture = texture.baseTexture.texture;
11109
- texture.baseTexture.texture.orig = new pixi_js.Rectangle(0, 0, asset.w, asset.h);
11102
+ texturePromise
11103
+ .then(texture => {
11104
+ this.texture = texture;
11105
+ })
11106
+ .catch(e => {
11107
+ console.error(e);
11110
11108
  });
11111
- }
11112
11109
 
11113
11110
  this.lottieLayer = lottieLayer;
11114
11111
 
@@ -11181,32 +11178,6 @@ class SpriteElement extends pixi_js.Sprite {
11181
11178
  }
11182
11179
  }
11183
11180
 
11184
- class BaseTexture extends pixi_js.EventEmitter {
11185
- constructor(url) {
11186
- super();
11187
- this.texture = pixi_js.Texture.EMPTY;
11188
- this.img = new Image();
11189
- this.img.src = url;
11190
- this.img.onload = () => {
11191
- this.texture = pixi_js.Texture.from(this.img);
11192
- this.emit('loaded');
11193
- };
11194
- this.img.onerror = () => {
11195
- this.emit('error');
11196
- };
11197
- }
11198
- }
11199
-
11200
- class Texture {
11201
- constructor(url) {
11202
- this.baseTexture = new BaseTexture(url);
11203
- }
11204
-
11205
- static from(url) {
11206
- return new Texture(url);
11207
- }
11208
- }
11209
-
11210
11181
  const regHttp = /^(https?:)?\/\//;
11211
11182
 
11212
11183
  /**
@@ -11262,25 +11233,20 @@ class LoadTexture extends Eventer {
11262
11233
  this.assets.forEach(asset => {
11263
11234
  const id = asset.id;
11264
11235
  const url = createUrl(asset, this.prefix);
11265
- const texture = url ? Texture.from(url, this.textureOptions) : Texture.EMPTY;
11266
- this.textures[id] = texture;
11236
+ const texturePromise = pixi_js.Assets.load(url);
11237
+ this.textures[id] = texturePromise;
11267
11238
  this._total++;
11268
- if (texture.baseTexture.valid || texture === Texture.EMPTY) {
11269
- this._received++;
11270
- this.emit('update');
11271
- if (this._received + this._failed >= this._total) this._onComplete();
11272
- } else {
11273
- texture.baseTexture.once('loaded', () => {
11239
+ texturePromise
11240
+ .then(() => {
11274
11241
  this._received++;
11275
11242
  this.emit('update');
11276
11243
  if (this._received + this._failed >= this._total) this._onComplete();
11277
- });
11278
- texture.baseTexture.once('error', () => {
11244
+ })
11245
+ .catch(e => {
11279
11246
  this._failed++;
11280
11247
  this.emit('update');
11281
11248
  if (this._received + this._failed >= this._total) this._onComplete();
11282
11249
  });
11283
- }
11284
11250
  });
11285
11251
  }
11286
11252
 
@@ -12884,7 +12850,7 @@ class AnimationManager extends Eventer {
12884
12850
  }
12885
12851
  }
12886
12852
 
12887
- const { major } = iOSVersion__default(window.navigator.userAgent) || {};
12853
+ const { major } = iOSVersion__default(globalThis.navigator.userAgent) || {};
12888
12854
 
12889
12855
  /**
12890
12856
  * dataURL 转成 blob
@@ -12970,14 +12936,16 @@ let LottieSystem = class LottieSystem extends pluginRenderer.Renderer {
12970
12936
  if (!container)
12971
12937
  return;
12972
12938
  const _a = component.options, { resource: rn } = _a, otherOpts = __rest(_a, ["resource"]);
12973
- const { data } = yield eva_js.resource.getResource(rn);
12939
+ const res = yield eva_js.resource.getResource(rn);
12940
+ const data = res.data;
12941
+ const url = res.src.json.url;
12974
12942
  const json = Object.assign({}, (data.json || {}));
12975
12943
  const assets = json.assets || [];
12976
12944
  assets.forEach(item => {
12977
12945
  if (item.p)
12978
12946
  item.p = imageHandle(item.p);
12979
12947
  });
12980
- const anim = this.manager.parseAnimation(Object.assign({ keyframes: json }, otherOpts));
12948
+ const anim = this.manager.parseAnimation(Object.assign({ keyframes: json, prefix: this.getDir(url) }, otherOpts));
12981
12949
  component.anim = anim;
12982
12950
  container.addChildAt(anim.group, 0);
12983
12951
  this.managerLife.forEach(eventName => {
@@ -12987,6 +12955,9 @@ let LottieSystem = class LottieSystem extends pluginRenderer.Renderer {
12987
12955
  component.emit('success', {});
12988
12956
  });
12989
12957
  }
12958
+ getDir(url) {
12959
+ return new URL('./', url).href;
12960
+ }
12990
12961
  remove(changed) {
12991
12962
  const component = changed.component;
12992
12963
  const container = this.renderSystem.containerManager.getContainer(changed.gameObject.id);
@@ -13039,7 +13010,10 @@ class Lottie extends eva_js.Component {
13039
13010
  this.currentSlot[name] = pixi_js.Sprite.from(value);
13040
13011
  }
13041
13012
  else if (type === 'TEXT') {
13042
- this.currentSlot[name] = new pixi_js.Text(value, new pixi_js.TextStyle(style));
13013
+ this.currentSlot[name] = new pixi_js.Text({
13014
+ text: value,
13015
+ style: new pixi_js.TextStyle(style),
13016
+ });
13043
13017
  }
13044
13018
  if (x)
13045
13019
  this.currentSlot[name].x = x;
@@ -13074,9 +13048,7 @@ class Lottie extends eva_js.Component {
13074
13048
  this.on('success', () => {
13075
13049
  const ele = this.anim.querySelector(name);
13076
13050
  const display = ele.display;
13077
- g.beginFill(0xffffff);
13078
- g.drawRect(0, 0, 100, 100);
13079
- g.endFill();
13051
+ g.rect(0, 0, 100, 100).fill(0xffffff);
13080
13052
  g.alpha = 0;
13081
13053
  display.addChild(g);
13082
13054
  ele.display.interactive = true;