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

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.
@@ -7092,7 +7092,6 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
7092
7092
  length: len
7093
7093
  });
7094
7094
  }
7095
- window.$commands = [];
7096
7095
  class MatrixHelper extends pixi_js.Matrix {
7097
7096
  reset() {
7098
7097
  this.a = 1;
@@ -7445,19 +7444,15 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
7445
7444
  class SpriteElement extends pixi_js.Sprite {
7446
7445
  constructor(lottieLayer, imageInfo) {
7447
7446
  const {
7448
- asset,
7449
- texture
7447
+ texture: texturePromise
7450
7448
  } = imageInfo;
7451
- super(texture.baseTexture.texture);
7449
+ super();
7452
7450
  this.label = lottieLayer.fullname;
7453
- if (texture.baseTexture.texture.valid) {
7454
- texture.baseTexture.texture.orig = new pixi_js.Rectangle(0, 0, asset.w, asset.h);
7455
- } else {
7456
- texture.baseTexture.on('loaded', () => {
7457
- this.texture = texture.baseTexture.texture;
7458
- texture.baseTexture.texture.orig = new pixi_js.Rectangle(0, 0, asset.w, asset.h);
7459
- });
7460
- }
7451
+ texturePromise.then(texture => {
7452
+ this.texture = texture;
7453
+ }).catch(e => {
7454
+ console.error(e);
7455
+ });
7461
7456
  this.lottieLayer = lottieLayer;
7462
7457
  if (this.lottieLayer.masks) {
7463
7458
  this.mask = new LottieGraphicsMask(this.lottieLayer.session.local, this.lottieLayer);
@@ -7500,29 +7495,6 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
7500
7495
  this.mask.updateMasks(masks);
7501
7496
  }
7502
7497
  }
7503
- class BaseTexture extends pixi_js.EventEmitter {
7504
- constructor(url) {
7505
- super();
7506
- this.texture = pixi_js.Texture.EMPTY;
7507
- this.img = new Image();
7508
- this.img.src = url;
7509
- this.img.onload = () => {
7510
- this.texture = pixi_js.Texture.from(this.img);
7511
- this.emit('loaded');
7512
- };
7513
- this.img.onerror = () => {
7514
- this.emit('error');
7515
- };
7516
- }
7517
- }
7518
- class Texture {
7519
- constructor(url) {
7520
- this.baseTexture = new BaseTexture(url);
7521
- }
7522
- static from(url) {
7523
- return new Texture(url);
7524
- }
7525
- }
7526
7498
  const regHttp = /^(https?:)?\/\//;
7527
7499
  function createUrl(asset, prefix) {
7528
7500
  if (asset.e === 1) return asset.p;
@@ -7562,25 +7534,18 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
7562
7534
  this.assets.forEach(asset => {
7563
7535
  const id = asset.id;
7564
7536
  const url = createUrl(asset, this.prefix);
7565
- const texture = url ? Texture.from(url, this.textureOptions) : Texture.EMPTY;
7566
- this.textures[id] = texture;
7537
+ const texturePromise = pixi_js.Assets.load(url);
7538
+ this.textures[id] = texturePromise;
7567
7539
  this._total++;
7568
- if (texture.baseTexture.valid || texture === Texture.EMPTY) {
7540
+ texturePromise.then(() => {
7569
7541
  this._received++;
7570
7542
  this.emit('update');
7571
7543
  if (this._received + this._failed >= this._total) this._onComplete();
7572
- } else {
7573
- texture.baseTexture.once('loaded', () => {
7574
- this._received++;
7575
- this.emit('update');
7576
- if (this._received + this._failed >= this._total) this._onComplete();
7577
- });
7578
- texture.baseTexture.once('error', () => {
7579
- this._failed++;
7580
- this.emit('update');
7581
- if (this._received + this._failed >= this._total) this._onComplete();
7582
- });
7583
- }
7544
+ }).catch(e => {
7545
+ this._failed++;
7546
+ this.emit('update');
7547
+ if (this._received + this._failed >= this._total) this._onComplete();
7548
+ });
7584
7549
  });
7585
7550
  }
7586
7551
  _onComplete() {
@@ -7792,7 +7757,6 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
7792
7757
  }
7793
7758
  };
7794
7759
  session.fontManager.addChars(data.chars);
7795
- session.fontManager.addFonts(data.fonts, document.body);
7796
7760
  this._buildElements(session);
7797
7761
  if (this.textureLoader !== null && this._justDisplayOnImagesLoaded && !this.textureLoader.loaded && this._justDisplayNeedSet !== null) {
7798
7762
  this.group.visible = false;
@@ -8400,7 +8364,7 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
8400
8364
  var iOSVersion = iosVersion;
8401
8365
  const {
8402
8366
  major
8403
- } = iOSVersion(window.navigator.userAgent) || {};
8367
+ } = iOSVersion(globalThis.navigator.userAgent) || {};
8404
8368
  function dataURL2blob(dataURL) {
8405
8369
  let binaryString = atob(dataURL.split(',')[1]);
8406
8370
  let arrayBuffer = new ArrayBuffer(binaryString.length);
@@ -8466,16 +8430,17 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
8466
8430
  resource: rn
8467
8431
  } = _a,
8468
8432
  otherOpts = __rest(_a, ["resource"]);
8469
- const {
8470
- data
8471
- } = yield eva_js.resource.getResource(rn);
8433
+ const res = yield eva_js.resource.getResource(rn);
8434
+ const data = res.data;
8435
+ const url = res.src.json.url;
8472
8436
  const json = _extends({}, data.json || {});
8473
8437
  const assets = json.assets || [];
8474
8438
  assets.forEach(item => {
8475
8439
  if (item.p) item.p = imageHandle(item.p);
8476
8440
  });
8477
8441
  const anim = this.manager.parseAnimation(_extends({
8478
- keyframes: json
8442
+ keyframes: json,
8443
+ prefix: this.getDir(url)
8479
8444
  }, otherOpts));
8480
8445
  component.anim = anim;
8481
8446
  container.addChildAt(anim.group, 0);
@@ -8485,6 +8450,9 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
8485
8450
  if (anim.isImagesLoaded) component.emit('success', {});
8486
8451
  });
8487
8452
  }
8453
+ getDir(url) {
8454
+ return new URL('./', url).href;
8455
+ }
8488
8456
  remove(changed) {
8489
8457
  const component = changed.component;
8490
8458
  const container = this.renderSystem.containerManager.getContainer(changed.gameObject.id);
@@ -8558,7 +8526,10 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
8558
8526
  if (type === 'IMAGE') {
8559
8527
  this.currentSlot[name] = pixi_js.Sprite.from(value);
8560
8528
  } else if (type === 'TEXT') {
8561
- this.currentSlot[name] = new pixi_js.Text(value, new pixi_js.TextStyle(style));
8529
+ this.currentSlot[name] = new pixi_js.Text({
8530
+ text: value,
8531
+ style: new pixi_js.TextStyle(style)
8532
+ });
8562
8533
  }
8563
8534
  if (x) this.currentSlot[name].x = x;
8564
8535
  if (y) this.currentSlot[name].y = y;
@@ -8589,9 +8560,7 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
8589
8560
  this.on('success', () => {
8590
8561
  const ele = this.anim.querySelector(name);
8591
8562
  const display = ele.display;
8592
- g.beginFill(0xffffff);
8593
- g.drawRect(0, 0, 100, 100);
8594
- g.endFill();
8563
+ g.rect(0, 0, 100, 100).fill(0xffffff);
8595
8564
  g.alpha = 0;
8596
8565
  display.addChild(g);
8597
8566
  ele.display.interactive = true;