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

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.
@@ -197,7 +197,7 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
197
197
  } else {
198
198
  createTypedArray = createRegularArray;
199
199
  }
200
- function createSizedArray$1(len) {
200
+ function createSizedArray$2(len) {
201
201
  return new Array(len);
202
202
  }
203
203
  var NEWTON_ITERATIONS = 4;
@@ -307,7 +307,7 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
307
307
  getBezierEasing: getBezierEasing
308
308
  };
309
309
  function _double(arr) {
310
- return arr.concat(createSizedArray$1(arr.length));
310
+ return arr.concat(createSizedArray$2(arr.length));
311
311
  }
312
312
  var pooling = {
313
313
  double: _double
@@ -315,7 +315,7 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
315
315
  var PoolFactory = function PoolFactory(initialLength, _create, _release) {
316
316
  var _length = 0;
317
317
  var _maxLength = initialLength;
318
- var pool = createSizedArray$1(_maxLength);
318
+ var pool = createSizedArray$2(_maxLength);
319
319
  var ob = {
320
320
  newElement: newElement,
321
321
  release: release
@@ -464,7 +464,7 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
464
464
  var bezierData = new BezierData(curveSegments);
465
465
  var len = pt3.length;
466
466
  for (var k = 0; k < curveSegments; k += 1) {
467
- point = createSizedArray$1(len);
467
+ point = createSizedArray$2(len);
468
468
  var perc = k / (curveSegments - 1);
469
469
  ptDistance = 0;
470
470
  for (var i = 0; i < len; i += 1) {
@@ -1368,9 +1368,9 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
1368
1368
  this.c = false;
1369
1369
  this._length = 0;
1370
1370
  this._maxLength = 8;
1371
- this.v = createSizedArray$1(this._maxLength);
1372
- this.o = createSizedArray$1(this._maxLength);
1373
- this.i = createSizedArray$1(this._maxLength);
1371
+ this.v = createSizedArray$2(this._maxLength);
1372
+ this.o = createSizedArray$2(this._maxLength);
1373
+ this.i = createSizedArray$2(this._maxLength);
1374
1374
  }
1375
1375
  return _createClass(ShapePath, [{
1376
1376
  key: 'setPathData',
@@ -1396,9 +1396,9 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
1396
1396
  }, {
1397
1397
  key: 'doubleArrayLength',
1398
1398
  value: function doubleArrayLength() {
1399
- this.v = this.v.concat(createSizedArray$1(this._maxLength));
1400
- this.i = this.i.concat(createSizedArray$1(this._maxLength));
1401
- this.o = this.o.concat(createSizedArray$1(this._maxLength));
1399
+ this.v = this.v.concat(createSizedArray$2(this._maxLength));
1400
+ this.i = this.i.concat(createSizedArray$2(this._maxLength));
1401
+ this.o = this.o.concat(createSizedArray$2(this._maxLength));
1402
1402
  this._maxLength *= 2;
1403
1403
  }
1404
1404
  }, {
@@ -1489,13 +1489,13 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
1489
1489
  _classCallCheck(this, ShapeCollection);
1490
1490
  this._length = 0;
1491
1491
  this._maxLength = 4;
1492
- this.shapes = createSizedArray$1(this._maxLength);
1492
+ this.shapes = createSizedArray$2(this._maxLength);
1493
1493
  }
1494
1494
  return _createClass(ShapeCollection, [{
1495
1495
  key: 'addShape',
1496
1496
  value: function addShape(shapeData) {
1497
1497
  if (this._length === this._maxLength) {
1498
- this.shapes = this.shapes.concat(createSizedArray$1(this._maxLength));
1498
+ this.shapes = this.shapes.concat(createSizedArray$2(this._maxLength));
1499
1499
  this._maxLength *= 2;
1500
1500
  }
1501
1501
  this.shapes[this._length] = shapeData;
@@ -1513,7 +1513,7 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
1513
1513
  }();
1514
1514
  var _length = 0;
1515
1515
  var _maxLength = 4;
1516
- var pool = createSizedArray$1(_maxLength);
1516
+ var pool = createSizedArray$2(_maxLength);
1517
1517
  function newShapeCollection() {
1518
1518
  var shapeCollection;
1519
1519
  if (_length) {
@@ -2082,7 +2082,7 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
2082
2082
  _this.propType = 'mask';
2083
2083
  _this.masksProperties = masksProperties || [];
2084
2084
  _this.initDynamicPropertyContainer(elem);
2085
- _this.viewData = createSizedArray$1(_this.masksProperties.length);
2085
+ _this.viewData = createSizedArray$2(_this.masksProperties.length);
2086
2086
  var len = _this.masksProperties.length;
2087
2087
  var hasMasks = false;
2088
2088
  for (var i = 0; i < len; i++) {
@@ -3693,7 +3693,7 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
3693
3693
  _this = _callSuper(this, DashProperty);
3694
3694
  _this.elem = elem;
3695
3695
  _this.frameId = -1;
3696
- _this.dataProps = createSizedArray$1(data.length);
3696
+ _this.dataProps = createSizedArray$2(data.length);
3697
3697
  _this.k = false;
3698
3698
  _this.dashArray = createTypedArray('float32', data.length ? data.length - 1 : 0);
3699
3699
  _this.dashoffset = createTypedArray('float32', 1);
@@ -4840,7 +4840,7 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
4840
4840
  _this._textData = textData;
4841
4841
  _this._renderType = renderType;
4842
4842
  _this.elem = elem;
4843
- _this._animatorsData = createSizedArray$1(_this._textData.a.length);
4843
+ _this._animatorsData = createSizedArray$2(_this._textData.a.length);
4844
4844
  _this._pathData = {};
4845
4845
  _this._moreOptions = {
4846
4846
  alignment: {}
@@ -6856,7 +6856,6 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
6856
6856
  }
6857
6857
  };
6858
6858
  ({
6859
- UPDATE_PRIORITY: pixi_js.UPDATE_PRIORITY,
6860
6859
  animationTicker: pixi_js.Ticker.shared
6861
6860
  });
6862
6861
  const p = n => n > 0 ? n : 0;
@@ -6904,6 +6903,26 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
6904
6903
  });
6905
6904
  }
6906
6905
  }
6906
+ const updateTransformByHierarchy = (container, transform, parent) => {
6907
+ if (transform.p) {
6908
+ container.x = transform.p.v[0];
6909
+ container.y = transform.p.v[1];
6910
+ } else {
6911
+ container.x = transform.px.v;
6912
+ container.y = transform.py.v;
6913
+ }
6914
+ container.pivot.x = transform.a.v[0];
6915
+ container.pivot.y = transform.a.v[1];
6916
+ container.scale.x = transform.s.v[0];
6917
+ container.scale.y = transform.s.v[1];
6918
+ if (transform.r) {
6919
+ container.rotation = transform.r.v + transform.orientation;
6920
+ } else if (transform.rz) {
6921
+ container.rotation = transform.rz.v + transform.or.v[2];
6922
+ }
6923
+ const parentAlpha = parent ? parent.alpha : 1;
6924
+ container.alpha = parentAlpha * transform.o.v;
6925
+ };
6907
6926
  class CompElement extends pixi_js.Container {
6908
6927
  constructor(lottieLayer, isRoot) {
6909
6928
  super();
@@ -6933,23 +6952,7 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
6933
6952
  this._onUpdate();
6934
6953
  }
6935
6954
  updateLottieTransform(transform) {
6936
- if (transform.p) {
6937
- this.x = transform.p.v[0];
6938
- this.y = transform.p.v[1];
6939
- } else {
6940
- this.x = transform.px.v;
6941
- this.y = transform.py.v;
6942
- }
6943
- this.pivot.x = transform.a.v[0];
6944
- this.pivot.y = transform.a.v[1];
6945
- this.scale.x = transform.s.v[0];
6946
- this.scale.y = transform.s.v[1];
6947
- if (transform.r) {
6948
- this.rotation = transform.r.v + transform.orientation;
6949
- } else if (transform.rz) {
6950
- this.rotation = transform.rz.v + transform.or.v[2];
6951
- }
6952
- this.alpha = transform.o.v;
6955
+ updateTransformByHierarchy(this, transform, this.hierarchy);
6953
6956
  }
6954
6957
  updateLottieMasks(masks) {
6955
6958
  this.mask.updateMasks(masks);
@@ -7060,23 +7063,7 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
7060
7063
  this.hierarchy = parent;
7061
7064
  }
7062
7065
  updateLottieTransform(transform) {
7063
- if (transform.p) {
7064
- this.x = transform.p.v[0];
7065
- this.y = transform.p.v[1];
7066
- } else {
7067
- this.x = transform.px.v;
7068
- this.y = transform.py.v;
7069
- }
7070
- this.pivot.x = transform.a.v[0];
7071
- this.pivot.y = transform.a.v[1];
7072
- this.scale.x = transform.s.v[0];
7073
- this.scale.y = transform.s.v[1];
7074
- if (transform.r) {
7075
- this.rotation = transform.r.v + transform.orientation;
7076
- } else if (transform.rz) {
7077
- this.rotation = transform.rz.v + transform.or.v[2];
7078
- }
7079
- this.alpha = transform.o.v;
7066
+ updateTransformByHierarchy(this, transform, this.hierarchy);
7080
7067
  }
7081
7068
  updateLottieMasks(masks) {
7082
7069
  this.mask.updateMasks(masks);
@@ -7092,7 +7079,116 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
7092
7079
  length: len
7093
7080
  });
7094
7081
  }
7095
- window.$commands = [];
7082
+ class TextElement extends pixi_js.Text {
7083
+ constructor(lottieLayer) {
7084
+ super();
7085
+ this.label = lottieLayer.fullname;
7086
+ this.lottieLayer = lottieLayer;
7087
+ this.lottieLayer.lettersChangedFlag = true;
7088
+ if (this.lottieLayer.masks) {
7089
+ this.mask = new LottieGraphicsMask(this.lottieLayer.session.local, this.lottieLayer);
7090
+ this.addChild(this.mask);
7091
+ }
7092
+ this.init();
7093
+ this.buildNewText();
7094
+ this.updateLottie = this.updateLottie.bind(this);
7095
+ this.updateLottie(this.lottieLayer, true);
7096
+ this.lottieLayer.on('updatelayer', this.updateLottie);
7097
+ this.onRender = () => {
7098
+ this.updateLottie(this.lottieLayer, true);
7099
+ };
7100
+ }
7101
+ init() {
7102
+ this._textSpans = [];
7103
+ this._yOffset = 0;
7104
+ this._fillColorAnim = false;
7105
+ this._strokeColorAnim = false;
7106
+ this._strokeWidthAnim = false;
7107
+ this._stroke = false;
7108
+ this._fill = false;
7109
+ this._justifyOffset = 0;
7110
+ this._currentRender = null;
7111
+ this._renderType = 'canvas';
7112
+ this._fillStyle = {};
7113
+ this._values = {
7114
+ fill: '#000000',
7115
+ stroke: '#000000',
7116
+ sWidth: 0,
7117
+ fValue: ''
7118
+ };
7119
+ }
7120
+ buildNewText() {
7121
+ const documentData = this.lottieLayer.textProperty.currentData;
7122
+ this.renderedLetters = createSizedArray(documentData.l ? documentData.l.length : 0);
7123
+ let hasFill = false;
7124
+ if (documentData.fc) {
7125
+ hasFill = true;
7126
+ this._values.fill = Tools.rgb2hex(documentData.fc.map(item => {
7127
+ return item > 1 ? item : item * 255;
7128
+ }), documentData.fc);
7129
+ } else {
7130
+ this._values.fill = '#000000';
7131
+ }
7132
+ this._fill = hasFill;
7133
+ let hasStroke = false;
7134
+ if (documentData.sc) {
7135
+ hasStroke = true;
7136
+ this._values.stroke = this.buildColor(documentData.sc);
7137
+ this._values.sWidth = documentData.sw;
7138
+ }
7139
+ const fontManager = this.lottieLayer.global.fontManager;
7140
+ this._stroke = hasStroke;
7141
+ this._values.fontSize = documentData.finalSize;
7142
+ this._values.fontFamily = fontManager.getFontByName(documentData.f).fFamily;
7143
+ this._values.fontWeight = documentData.fWeight;
7144
+ this._values.fontStyle = documentData.fStyle;
7145
+ this._values.lineHeight = documentData.finalLineHeight;
7146
+ this._text = documentData.t;
7147
+ this.renderText();
7148
+ }
7149
+ async renderText() {
7150
+ this.text = this._text;
7151
+ if (this.style.fontFamily) {
7152
+ await pixi_js.Assets.get(this.style.fontFamily);
7153
+ }
7154
+ this.style.fontFamily = this._values.fontFamily;
7155
+ this.style.fontSize = this._values.fontSize;
7156
+ this.style.fill = this._values.fill;
7157
+ this.style.fontWeight = this._values.fontWeight;
7158
+ this.style.fontStyle = this._values.fontStyle;
7159
+ this.style.lineHeight = this._values.lineHeight;
7160
+ this.anchor.x = 0.5;
7161
+ this.anchor.y = 0.8;
7162
+ }
7163
+ updateLottie(lottieLayer, _forceUpdate = false) {
7164
+ let forceUpdate = true;
7165
+ if (lottieLayer.transform && forceUpdate) {
7166
+ this.updateLottieTransform(lottieLayer.transform);
7167
+ }
7168
+ if (lottieLayer.masks && forceUpdate) {
7169
+ this.updateLottieMasks(lottieLayer.masks);
7170
+ }
7171
+ if (lottieLayer._mdf) {
7172
+ this.renderText();
7173
+ }
7174
+ this.visible = lottieLayer.isInRange;
7175
+ this._onUpdate();
7176
+ }
7177
+ setTransformHierarchy(parent) {
7178
+ this.hierarchy = parent;
7179
+ }
7180
+ updateLottieTransform(transform) {
7181
+ updateTransformByHierarchy(this, transform, this.hierarchy);
7182
+ }
7183
+ updateLottieMasks(masks) {
7184
+ this.mask.updateMasks(masks);
7185
+ }
7186
+ }
7187
+ function createSizedArray$1(len) {
7188
+ return Array.apply(null, {
7189
+ length: len
7190
+ });
7191
+ }
7096
7192
  class MatrixHelper extends pixi_js.Matrix {
7097
7193
  reset() {
7098
7194
  this.a = 1;
@@ -7119,7 +7215,7 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
7119
7215
  return points.map(point => this.applyToY(point.x, point.y));
7120
7216
  }
7121
7217
  }
7122
- class TextElement extends pixi_js.Graphics {
7218
+ class TextGlyphsElement extends pixi_js.Graphics {
7123
7219
  constructor(lottieLayer) {
7124
7220
  super();
7125
7221
  this.label = lottieLayer.fullname;
@@ -7159,11 +7255,13 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
7159
7255
  }
7160
7256
  buildNewText() {
7161
7257
  const documentData = this.lottieLayer.textProperty.currentData;
7162
- this.renderedLetters = createSizedArray(documentData.l ? documentData.l.length : 0);
7258
+ this.renderedLetters = createSizedArray$1(documentData.l ? documentData.l.length : 0);
7163
7259
  let hasFill = false;
7164
7260
  if (documentData.fc) {
7165
7261
  hasFill = true;
7166
- this._values.fill = Tools.rgb2hex(documentData.fc);
7262
+ this._values.fill = Tools.rgb2hex(documentData.fc.map(item => {
7263
+ return item > 1 ? item : item * 255;
7264
+ }), documentData.fc);
7167
7265
  } else {
7168
7266
  this._values.fill = '#000000';
7169
7267
  }
@@ -7212,8 +7310,7 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
7212
7310
  shapes = shapeData.shapes ? shapeData.shapes[0].it : [];
7213
7311
  jLen = shapes.length;
7214
7312
  matrixHelper.scale(documentData.finalSize / 100, documentData.finalSize / 100);
7215
- commands = createSizedArray(jLen - 1);
7216
- window.$commands.push(commands);
7313
+ commands = createSizedArray$1(jLen - 1);
7217
7314
  let commandsCounter = 0;
7218
7315
  for (j = 0; j < jLen; j += 1) {
7219
7316
  if (shapes[j].ty === 'sh') {
@@ -7372,23 +7469,7 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
7372
7469
  this.hierarchy = parent;
7373
7470
  }
7374
7471
  updateLottieTransform(transform) {
7375
- if (transform.p) {
7376
- this.x = transform.p.v[0];
7377
- this.y = transform.p.v[1];
7378
- } else {
7379
- this.x = transform.px.v;
7380
- this.y = transform.py.v;
7381
- }
7382
- this.pivot.x = transform.a.v[0];
7383
- this.pivot.y = transform.a.v[1];
7384
- this.scale.x = transform.s.v[0];
7385
- this.scale.y = transform.s.v[1];
7386
- if (transform.r) {
7387
- this.rotation = transform.r.v + transform.orientation;
7388
- } else if (transform.rz) {
7389
- this.rotation = transform.rz.v + transform.or.v[2];
7390
- }
7391
- this.alpha = transform.o.v;
7472
+ updateTransformByHierarchy(this, transform, this.hierarchy);
7392
7473
  }
7393
7474
  updateLottieMasks(masks) {
7394
7475
  this.mask.updateMasks(masks);
@@ -7420,23 +7501,7 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
7420
7501
  this.hierarchy = parent;
7421
7502
  }
7422
7503
  updateLottieTransform(transform) {
7423
- if (transform.p) {
7424
- this.x = transform.p.v[0];
7425
- this.y = transform.p.v[1];
7426
- } else {
7427
- this.x = transform.px.v;
7428
- this.y = transform.py.v;
7429
- }
7430
- this.pivot.x = transform.a.v[0];
7431
- this.pivot.y = transform.a.v[1];
7432
- this.scale.x = transform.s.v[0];
7433
- this.scale.y = transform.s.v[1];
7434
- if (transform.r) {
7435
- this.rotation = transform.r.v + transform.orientation;
7436
- } else if (transform.rz) {
7437
- this.rotation = transform.rz.v + transform.or.v[2];
7438
- }
7439
- this.alpha = transform.o.v;
7504
+ updateTransformByHierarchy(this, transform, this.hierarchy);
7440
7505
  }
7441
7506
  updateLottieMasks(masks) {
7442
7507
  this.mask.updateMasks(masks);
@@ -7445,19 +7510,15 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
7445
7510
  class SpriteElement extends pixi_js.Sprite {
7446
7511
  constructor(lottieLayer, imageInfo) {
7447
7512
  const {
7448
- asset,
7449
- texture
7513
+ texture: texturePromise
7450
7514
  } = imageInfo;
7451
- super(texture.baseTexture.texture);
7515
+ super();
7452
7516
  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
- }
7517
+ texturePromise.then(texture => {
7518
+ this.texture = texture;
7519
+ }).catch(e => {
7520
+ console.error(e);
7521
+ });
7461
7522
  this.lottieLayer = lottieLayer;
7462
7523
  if (this.lottieLayer.masks) {
7463
7524
  this.mask = new LottieGraphicsMask(this.lottieLayer.session.local, this.lottieLayer);
@@ -7478,51 +7539,12 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
7478
7539
  this.hierarchy = parent;
7479
7540
  }
7480
7541
  updateLottieTransform(transform) {
7481
- if (transform.p) {
7482
- this.x = transform.p.v[0];
7483
- this.y = transform.p.v[1];
7484
- } else {
7485
- this.x = transform.px.v;
7486
- this.y = transform.py.v;
7487
- }
7488
- this.pivot.x = transform.a.v[0];
7489
- this.pivot.y = transform.a.v[1];
7490
- this.scale.x = transform.s.v[0];
7491
- this.scale.y = transform.s.v[1];
7492
- if (transform.r) {
7493
- this.rotation = transform.r.v + transform.orientation;
7494
- } else if (transform.rz) {
7495
- this.rotation = transform.rz.v + transform.or.v[2];
7496
- }
7497
- this.alpha = transform.o.v;
7542
+ updateTransformByHierarchy(this, transform, this.hierarchy);
7498
7543
  }
7499
7544
  updateLottieMasks(masks) {
7500
7545
  this.mask.updateMasks(masks);
7501
7546
  }
7502
7547
  }
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
7548
  const regHttp = /^(https?:)?\/\//;
7527
7549
  function createUrl(asset, prefix) {
7528
7550
  if (asset.e === 1) return asset.p;
@@ -7562,25 +7584,18 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
7562
7584
  this.assets.forEach(asset => {
7563
7585
  const id = asset.id;
7564
7586
  const url = createUrl(asset, this.prefix);
7565
- const texture = url ? Texture.from(url, this.textureOptions) : Texture.EMPTY;
7566
- this.textures[id] = texture;
7587
+ const texturePromise = pixi_js.Assets.load(url);
7588
+ this.textures[id] = texturePromise;
7567
7589
  this._total++;
7568
- if (texture.baseTexture.valid || texture === Texture.EMPTY) {
7590
+ texturePromise.then(() => {
7569
7591
  this._received++;
7570
7592
  this.emit('update');
7571
7593
  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
- }
7594
+ }).catch(e => {
7595
+ this._failed++;
7596
+ this.emit('update');
7597
+ if (this._received + this._failed >= this._total) this._onComplete();
7598
+ });
7584
7599
  });
7585
7600
  }
7586
7601
  _onComplete() {
@@ -7658,6 +7673,30 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
7658
7673
  function loadJson(path) {
7659
7674
  return new LoadJson(path);
7660
7675
  }
7676
+ const getLayerBySubstituteId = (lottieFile, substituteId) => {
7677
+ const {
7678
+ substituteIds
7679
+ } = lottieFile || {};
7680
+ if (!substituteIds || Object.keys(substituteIds).length === 0) return null;
7681
+ let layer;
7682
+ if (substituteId && substituteId.indexOf('_') === -1) {
7683
+ const outerIndex = Number(substituteId);
7684
+ if (!Number.isNaN(outerIndex)) {
7685
+ var _lottieFile$layers;
7686
+ layer = lottieFile === null || lottieFile === void 0 ? void 0 : (_lottieFile$layers = lottieFile.layers) === null || _lottieFile$layers === void 0 ? void 0 : _lottieFile$layers[outerIndex];
7687
+ }
7688
+ } else if (substituteId) {
7689
+ const substituteIdArr = substituteId.split('_');
7690
+ const outerIndex = Number(substituteIdArr[0]);
7691
+ const innerIndex = Number(substituteIdArr[1]);
7692
+ if (!Number.isNaN(outerIndex) && !Number.isNaN(innerIndex)) {
7693
+ var _asset$layers;
7694
+ const asset = lottieFile.assets[outerIndex];
7695
+ layer = asset === null || asset === void 0 ? void 0 : (_asset$layers = asset.layers) === null || _asset$layers === void 0 ? void 0 : _asset$layers[innerIndex];
7696
+ }
7697
+ }
7698
+ return layer;
7699
+ };
7661
7700
  class AnimationGroup extends Eventer {
7662
7701
  constructor(options) {
7663
7702
  super();
@@ -7701,7 +7740,14 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
7701
7740
  }
7702
7741
  if (options.keyframes) {
7703
7742
  if (!this._prefix && options.keyframes.prefix) this._prefix = options.keyframes.prefix;
7704
- this._setupDate(options.keyframes);
7743
+ if (!options.replaceData) {
7744
+ this._setupDate(options.keyframes);
7745
+ } else {
7746
+ this._response = options.keyframes;
7747
+ if (this._replaceData) {
7748
+ this._setupReplaceData();
7749
+ }
7750
+ }
7705
7751
  } else if (options.path) {
7706
7752
  let prefix = '';
7707
7753
  if (options.path.lastIndexOf('\\') !== -1) {
@@ -7712,14 +7758,57 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
7712
7758
  if (!this._prefix && prefix) this._prefix = prefix;
7713
7759
  this.jsonLoader = loadJson(options.path);
7714
7760
  this.jsonLoader.once('success', response => {
7715
- this._setupDate(response);
7761
+ if (!options.replaceData) {
7762
+ this._setupDate(response);
7763
+ } else {
7764
+ this._response = response;
7765
+ if (this._replaceData) {
7766
+ this._setupReplaceData();
7767
+ }
7768
+ }
7716
7769
  });
7717
7770
  this.jsonLoader.once('error', error => {
7718
7771
  this.emit('error', error);
7719
7772
  });
7720
7773
  }
7721
7774
  }
7775
+ replaceData(data) {
7776
+ this._replaceData = data;
7777
+ this._setupReplaceData();
7778
+ }
7779
+ _setupReplaceData() {
7780
+ if (this._response && this._replaceData) {
7781
+ if (this._response.substituteIds) {
7782
+ const revertSubstituteIds = {};
7783
+ for (const key in this._response.substituteIds) {
7784
+ const value = this._response.substituteIds[key];
7785
+ revertSubstituteIds[value] = key;
7786
+ }
7787
+ for (const name in this._replaceData) {
7788
+ const data = this._replaceData[name];
7789
+ const layer = getLayerBySubstituteId(this._response, revertSubstituteIds[name]);
7790
+ if (!layer) continue;
7791
+ const {
7792
+ ty
7793
+ } = layer;
7794
+ if (ty === 2) {
7795
+ const asset = lottieFile.assets.find(item => item.id === layer.refId);
7796
+ if (asset) {
7797
+ asset.p = data;
7798
+ }
7799
+ } else if (ty === 5) {
7800
+ var _layer$t, _layer$t$d, _layer$t$d$k, _layer$t$d$k$, _layer$t$d$k$$s;
7801
+ if (layer !== null && layer !== void 0 && (_layer$t = layer.t) !== null && _layer$t !== void 0 && (_layer$t$d = _layer$t.d) !== null && _layer$t$d !== void 0 && (_layer$t$d$k = _layer$t$d.k) !== null && _layer$t$d$k !== void 0 && (_layer$t$d$k$ = _layer$t$d$k[0]) !== null && _layer$t$d$k$ !== void 0 && (_layer$t$d$k$$s = _layer$t$d$k$.s) !== null && _layer$t$d$k$$s !== void 0 && _layer$t$d$k$$s.t) {
7802
+ layer.t.d.k[0].s.t = data;
7803
+ }
7804
+ }
7805
+ }
7806
+ }
7807
+ this._setupDate(this._response);
7808
+ }
7809
+ }
7722
7810
  _setupDate(data) {
7811
+ var _data$fonts, _data$fonts$list;
7723
7812
  this._sourceData = data;
7724
7813
  if (this._copyJSON) data = Tools.copyJSON(data);
7725
7814
  DataManager.completeData(data);
@@ -7791,8 +7880,20 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
7791
7880
  st
7792
7881
  }
7793
7882
  };
7794
- session.fontManager.addChars(data.chars);
7883
+ session.fontManager.addChars(data.chars || []);
7795
7884
  session.fontManager.addFonts(data.fonts, document.body);
7885
+ if ((_data$fonts = data.fonts) !== null && _data$fonts !== void 0 && (_data$fonts$list = _data$fonts.list) !== null && _data$fonts$list !== void 0 && _data$fonts$list.length) {
7886
+ const fonts = data.fonts.list.map(item => ({
7887
+ alias: item.fFamily,
7888
+ src: item.fPath,
7889
+ data: {
7890
+ family: item.fFamily
7891
+ }
7892
+ })).filter(item => item.src);
7893
+ pixi_js.Assets.load(fonts).catch(e => {
7894
+ console.error(e);
7895
+ });
7896
+ }
7796
7897
  this._buildElements(session);
7797
7898
  if (this.textureLoader !== null && this._justDisplayOnImagesLoaded && !this.textureLoader.loaded && this._justDisplayNeedSet !== null) {
7798
7899
  this.group.visible = false;
@@ -7974,9 +8075,15 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
7974
8075
  return lottieLayer;
7975
8076
  }
7976
8077
  _extraText(layer, session) {
8078
+ var _session$fontManager$;
7977
8079
  layer.global = session;
7978
8080
  const lottieLayer = new TextLottieLayer(layer, session);
7979
- lottieLayer.display = new TextElement(lottieLayer);
8081
+ const usesGlyphs = !!((_session$fontManager$ = session.fontManager.chars) !== null && _session$fontManager$ !== void 0 && _session$fontManager$.length);
8082
+ if (usesGlyphs) {
8083
+ lottieLayer.display = new TextGlyphsElement(lottieLayer);
8084
+ } else {
8085
+ lottieLayer.display = new TextElement(lottieLayer);
8086
+ }
7980
8087
  return lottieLayer;
7981
8088
  }
7982
8089
  _extraCamera(layer, session) {
@@ -8097,8 +8204,11 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
8097
8204
  }
8098
8205
  update(snippetCache, firstFrame = false) {
8099
8206
  if (!this.living || !this.isDisplayLoaded || this.isPaused && !firstFrame) return;
8100
- const isEnd = this._updateTime(snippetCache);
8101
- const correctedFrameNum = this.beginFrame + this.frameNum;
8207
+ let isEnd = this._updateTime(snippetCache);
8208
+ const correctedFrameNum = this.direction === 1 ? this.beginFrame + this.frameNum : this.frameNum;
8209
+ if (this.direction === -1 && correctedFrameNum <= this.beginFrame) {
8210
+ isEnd = true;
8211
+ }
8102
8212
  this.root.updateFrame(correctedFrameNum);
8103
8213
  const np = correctedFrameNum >> 0;
8104
8214
  if (this._lastFrame !== np) {
@@ -8176,6 +8286,11 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
8176
8286
  if (Tools.isBoolean(options.alternate)) this.alternate = options.alternate;
8177
8287
  if (Tools.isNumber(options.wait)) this.wait = options.wait;
8178
8288
  if (Tools.isNumber(options.delay)) this.delay = options.delay;
8289
+ if (Tools.isNumber(options.direction)) {
8290
+ this.direction = options.direction;
8291
+ } else {
8292
+ this.direction = 1;
8293
+ }
8179
8294
  this.replay();
8180
8295
  return this;
8181
8296
  }
@@ -8230,9 +8345,12 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
8230
8345
  this._repeatsCut = this.repeats;
8231
8346
  this._delayCut = this.delay;
8232
8347
  this.living = true;
8233
- this.frameNum = 0;
8348
+ if (this.direction === -1) {
8349
+ this.frameNum = this.duration;
8350
+ } else {
8351
+ this.frameNum = 0;
8352
+ }
8234
8353
  this.duration = Math.floor(this.endFrame - this.beginFrame);
8235
- this.direction = 1;
8236
8354
  return this;
8237
8355
  }
8238
8356
  show() {
@@ -8400,7 +8518,7 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
8400
8518
  var iOSVersion = iosVersion;
8401
8519
  const {
8402
8520
  major
8403
- } = iOSVersion(window.navigator.userAgent) || {};
8521
+ } = iOSVersion(globalThis.navigator.userAgent) || {};
8404
8522
  function dataURL2blob(dataURL) {
8405
8523
  let binaryString = atob(dataURL.split(',')[1]);
8406
8524
  let arrayBuffer = new ArrayBuffer(binaryString.length);
@@ -8456,28 +8574,33 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
8456
8574
  });
8457
8575
  }
8458
8576
  add(changed) {
8577
+ var _a, _b;
8459
8578
  return __awaiter(this, void 0, void 0, function* () {
8460
8579
  this.manager = new AnimationManager(this.app);
8461
8580
  const component = changed.component;
8462
8581
  const container = this.renderSystem.containerManager.getContainer(changed.gameObject.id);
8463
8582
  if (!container) return;
8464
- const _a = component.options,
8583
+ const _c = component.options,
8465
8584
  {
8466
8585
  resource: rn
8467
- } = _a,
8468
- otherOpts = __rest(_a, ["resource"]);
8469
- const {
8470
- data
8471
- } = yield eva_js.resource.getResource(rn);
8586
+ } = _c,
8587
+ otherOpts = __rest(_c, ["resource"]);
8588
+ const res = yield eva_js.resource.getResource(rn);
8589
+ const data = res.data;
8590
+ const url = ((_b = (_a = res.src) === null || _a === void 0 ? void 0 : _a.json) === null || _b === void 0 ? void 0 : _b.url) || '';
8472
8591
  const json = _extends({}, data.json || {});
8473
8592
  const assets = json.assets || [];
8474
8593
  assets.forEach(item => {
8475
8594
  if (item.p) item.p = imageHandle(item.p);
8476
8595
  });
8477
8596
  const anim = this.manager.parseAnimation(_extends({
8478
- keyframes: json
8597
+ keyframes: json,
8598
+ prefix: this.getDir(url)
8479
8599
  }, otherOpts));
8480
8600
  component.anim = anim;
8601
+ if (component._replaceData) {
8602
+ anim.replaceData(component._replaceData);
8603
+ }
8481
8604
  container.addChildAt(anim.group, 0);
8482
8605
  this.managerLife.forEach(eventName => {
8483
8606
  anim.on(eventName, e => component.emit(eventName, e));
@@ -8485,6 +8608,10 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
8485
8608
  if (anim.isImagesLoaded) component.emit('success', {});
8486
8609
  });
8487
8610
  }
8611
+ getDir(url) {
8612
+ if (!url) return url;
8613
+ return new URL('./', url).href;
8614
+ }
8488
8615
  remove(changed) {
8489
8616
  const component = changed.component;
8490
8617
  const container = this.renderSystem.containerManager.getContainer(changed.gameObject.id);
@@ -8503,6 +8630,7 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
8503
8630
  class Lottie extends eva_js.Component {
8504
8631
  constructor(options) {
8505
8632
  super();
8633
+ this._replaceData = null;
8506
8634
  this.loadStatus = false;
8507
8635
  this.firstPlay = null;
8508
8636
  this.prevSlot = {};
@@ -8558,7 +8686,10 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
8558
8686
  if (type === 'IMAGE') {
8559
8687
  this.currentSlot[name] = pixi_js.Sprite.from(value);
8560
8688
  } else if (type === 'TEXT') {
8561
- this.currentSlot[name] = new pixi_js.Text(value, new pixi_js.TextStyle(style));
8689
+ this.currentSlot[name] = new pixi_js.Text({
8690
+ text: value,
8691
+ style: new pixi_js.TextStyle(style)
8692
+ });
8562
8693
  }
8563
8694
  if (x) this.currentSlot[name].x = x;
8564
8695
  if (y) this.currentSlot[name].y = y;
@@ -8572,6 +8703,11 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
8572
8703
  });
8573
8704
  this.anim.playSegment(this.playParamsHandle(params), expandOpts);
8574
8705
  }
8706
+ replaceData(data) {
8707
+ if (data) {
8708
+ if (this.anim) this.anim.replaceData(data);else this._replaceData = data;
8709
+ }
8710
+ }
8575
8711
  playParamsHandle(params) {
8576
8712
  let p = [].concat(params);
8577
8713
  const {
@@ -8589,9 +8725,7 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
8589
8725
  this.on('success', () => {
8590
8726
  const ele = this.anim.querySelector(name);
8591
8727
  const display = ele.display;
8592
- g.beginFill(0xffffff);
8593
- g.drawRect(0, 0, 100, 100);
8594
- g.endFill();
8728
+ g.rect(0, 0, 100, 100).fill(0xffffff);
8595
8729
  g.alpha = 0;
8596
8730
  display.addChild(g);
8597
8731
  ele.display.interactive = true;