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

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,6 +7079,116 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
7092
7079
  length: len
7093
7080
  });
7094
7081
  }
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
+ }
7095
7192
  class MatrixHelper extends pixi_js.Matrix {
7096
7193
  reset() {
7097
7194
  this.a = 1;
@@ -7118,7 +7215,7 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
7118
7215
  return points.map(point => this.applyToY(point.x, point.y));
7119
7216
  }
7120
7217
  }
7121
- class TextElement extends pixi_js.Graphics {
7218
+ class TextGlyphsElement extends pixi_js.Graphics {
7122
7219
  constructor(lottieLayer) {
7123
7220
  super();
7124
7221
  this.label = lottieLayer.fullname;
@@ -7158,11 +7255,13 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
7158
7255
  }
7159
7256
  buildNewText() {
7160
7257
  const documentData = this.lottieLayer.textProperty.currentData;
7161
- this.renderedLetters = createSizedArray(documentData.l ? documentData.l.length : 0);
7258
+ this.renderedLetters = createSizedArray$1(documentData.l ? documentData.l.length : 0);
7162
7259
  let hasFill = false;
7163
7260
  if (documentData.fc) {
7164
7261
  hasFill = true;
7165
- 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);
7166
7265
  } else {
7167
7266
  this._values.fill = '#000000';
7168
7267
  }
@@ -7211,8 +7310,7 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
7211
7310
  shapes = shapeData.shapes ? shapeData.shapes[0].it : [];
7212
7311
  jLen = shapes.length;
7213
7312
  matrixHelper.scale(documentData.finalSize / 100, documentData.finalSize / 100);
7214
- commands = createSizedArray(jLen - 1);
7215
- window.$commands.push(commands);
7313
+ commands = createSizedArray$1(jLen - 1);
7216
7314
  let commandsCounter = 0;
7217
7315
  for (j = 0; j < jLen; j += 1) {
7218
7316
  if (shapes[j].ty === 'sh') {
@@ -7371,23 +7469,7 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
7371
7469
  this.hierarchy = parent;
7372
7470
  }
7373
7471
  updateLottieTransform(transform) {
7374
- if (transform.p) {
7375
- this.x = transform.p.v[0];
7376
- this.y = transform.p.v[1];
7377
- } else {
7378
- this.x = transform.px.v;
7379
- this.y = transform.py.v;
7380
- }
7381
- this.pivot.x = transform.a.v[0];
7382
- this.pivot.y = transform.a.v[1];
7383
- this.scale.x = transform.s.v[0];
7384
- this.scale.y = transform.s.v[1];
7385
- if (transform.r) {
7386
- this.rotation = transform.r.v + transform.orientation;
7387
- } else if (transform.rz) {
7388
- this.rotation = transform.rz.v + transform.or.v[2];
7389
- }
7390
- this.alpha = transform.o.v;
7472
+ updateTransformByHierarchy(this, transform, this.hierarchy);
7391
7473
  }
7392
7474
  updateLottieMasks(masks) {
7393
7475
  this.mask.updateMasks(masks);
@@ -7419,23 +7501,7 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
7419
7501
  this.hierarchy = parent;
7420
7502
  }
7421
7503
  updateLottieTransform(transform) {
7422
- if (transform.p) {
7423
- this.x = transform.p.v[0];
7424
- this.y = transform.p.v[1];
7425
- } else {
7426
- this.x = transform.px.v;
7427
- this.y = transform.py.v;
7428
- }
7429
- this.pivot.x = transform.a.v[0];
7430
- this.pivot.y = transform.a.v[1];
7431
- this.scale.x = transform.s.v[0];
7432
- this.scale.y = transform.s.v[1];
7433
- if (transform.r) {
7434
- this.rotation = transform.r.v + transform.orientation;
7435
- } else if (transform.rz) {
7436
- this.rotation = transform.rz.v + transform.or.v[2];
7437
- }
7438
- this.alpha = transform.o.v;
7504
+ updateTransformByHierarchy(this, transform, this.hierarchy);
7439
7505
  }
7440
7506
  updateLottieMasks(masks) {
7441
7507
  this.mask.updateMasks(masks);
@@ -7473,23 +7539,7 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
7473
7539
  this.hierarchy = parent;
7474
7540
  }
7475
7541
  updateLottieTransform(transform) {
7476
- if (transform.p) {
7477
- this.x = transform.p.v[0];
7478
- this.y = transform.p.v[1];
7479
- } else {
7480
- this.x = transform.px.v;
7481
- this.y = transform.py.v;
7482
- }
7483
- this.pivot.x = transform.a.v[0];
7484
- this.pivot.y = transform.a.v[1];
7485
- this.scale.x = transform.s.v[0];
7486
- this.scale.y = transform.s.v[1];
7487
- if (transform.r) {
7488
- this.rotation = transform.r.v + transform.orientation;
7489
- } else if (transform.rz) {
7490
- this.rotation = transform.rz.v + transform.or.v[2];
7491
- }
7492
- this.alpha = transform.o.v;
7542
+ updateTransformByHierarchy(this, transform, this.hierarchy);
7493
7543
  }
7494
7544
  updateLottieMasks(masks) {
7495
7545
  this.mask.updateMasks(masks);
@@ -7623,6 +7673,30 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
7623
7673
  function loadJson(path) {
7624
7674
  return new LoadJson(path);
7625
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
+ };
7626
7700
  class AnimationGroup extends Eventer {
7627
7701
  constructor(options) {
7628
7702
  super();
@@ -7666,7 +7740,14 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
7666
7740
  }
7667
7741
  if (options.keyframes) {
7668
7742
  if (!this._prefix && options.keyframes.prefix) this._prefix = options.keyframes.prefix;
7669
- 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
+ }
7670
7751
  } else if (options.path) {
7671
7752
  let prefix = '';
7672
7753
  if (options.path.lastIndexOf('\\') !== -1) {
@@ -7677,14 +7758,57 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
7677
7758
  if (!this._prefix && prefix) this._prefix = prefix;
7678
7759
  this.jsonLoader = loadJson(options.path);
7679
7760
  this.jsonLoader.once('success', response => {
7680
- 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
+ }
7681
7769
  });
7682
7770
  this.jsonLoader.once('error', error => {
7683
7771
  this.emit('error', error);
7684
7772
  });
7685
7773
  }
7686
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
+ }
7687
7810
  _setupDate(data) {
7811
+ var _data$fonts, _data$fonts$list;
7688
7812
  this._sourceData = data;
7689
7813
  if (this._copyJSON) data = Tools.copyJSON(data);
7690
7814
  DataManager.completeData(data);
@@ -7756,8 +7880,20 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
7756
7880
  st
7757
7881
  }
7758
7882
  };
7759
- session.fontManager.addChars(data.chars);
7883
+ session.fontManager.addChars(data.chars || []);
7760
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
+ }
7761
7897
  this._buildElements(session);
7762
7898
  if (this.textureLoader !== null && this._justDisplayOnImagesLoaded && !this.textureLoader.loaded && this._justDisplayNeedSet !== null) {
7763
7899
  this.group.visible = false;
@@ -7939,9 +8075,15 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
7939
8075
  return lottieLayer;
7940
8076
  }
7941
8077
  _extraText(layer, session) {
8078
+ var _session$fontManager$;
7942
8079
  layer.global = session;
7943
8080
  const lottieLayer = new TextLottieLayer(layer, session);
7944
- 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
+ }
7945
8087
  return lottieLayer;
7946
8088
  }
7947
8089
  _extraCamera(layer, session) {
@@ -8062,8 +8204,11 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
8062
8204
  }
8063
8205
  update(snippetCache, firstFrame = false) {
8064
8206
  if (!this.living || !this.isDisplayLoaded || this.isPaused && !firstFrame) return;
8065
- const isEnd = this._updateTime(snippetCache);
8066
- 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
+ }
8067
8212
  this.root.updateFrame(correctedFrameNum);
8068
8213
  const np = correctedFrameNum >> 0;
8069
8214
  if (this._lastFrame !== np) {
@@ -8141,6 +8286,11 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
8141
8286
  if (Tools.isBoolean(options.alternate)) this.alternate = options.alternate;
8142
8287
  if (Tools.isNumber(options.wait)) this.wait = options.wait;
8143
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
+ }
8144
8294
  this.replay();
8145
8295
  return this;
8146
8296
  }
@@ -8195,9 +8345,12 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
8195
8345
  this._repeatsCut = this.repeats;
8196
8346
  this._delayCut = this.delay;
8197
8347
  this.living = true;
8198
- this.frameNum = 0;
8348
+ if (this.direction === -1) {
8349
+ this.frameNum = this.duration;
8350
+ } else {
8351
+ this.frameNum = 0;
8352
+ }
8199
8353
  this.duration = Math.floor(this.endFrame - this.beginFrame);
8200
- this.direction = 1;
8201
8354
  return this;
8202
8355
  }
8203
8356
  show() {
@@ -8421,19 +8574,20 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
8421
8574
  });
8422
8575
  }
8423
8576
  add(changed) {
8577
+ var _a, _b;
8424
8578
  return __awaiter(this, void 0, void 0, function* () {
8425
8579
  this.manager = new AnimationManager(this.app);
8426
8580
  const component = changed.component;
8427
8581
  const container = this.renderSystem.containerManager.getContainer(changed.gameObject.id);
8428
8582
  if (!container) return;
8429
- const _a = component.options,
8583
+ const _c = component.options,
8430
8584
  {
8431
8585
  resource: rn
8432
- } = _a,
8433
- otherOpts = __rest(_a, ["resource"]);
8586
+ } = _c,
8587
+ otherOpts = __rest(_c, ["resource"]);
8434
8588
  const res = yield eva_js.resource.getResource(rn);
8435
8589
  const data = res.data;
8436
- const url = res.src.json.url;
8590
+ const url = ((_b = (_a = res.src) === null || _a === void 0 ? void 0 : _a.json) === null || _b === void 0 ? void 0 : _b.url) || '';
8437
8591
  const json = _extends({}, data.json || {});
8438
8592
  const assets = json.assets || [];
8439
8593
  assets.forEach(item => {
@@ -8444,6 +8598,9 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
8444
8598
  prefix: this.getDir(url)
8445
8599
  }, otherOpts));
8446
8600
  component.anim = anim;
8601
+ if (component._replaceData) {
8602
+ anim.replaceData(component._replaceData);
8603
+ }
8447
8604
  container.addChildAt(anim.group, 0);
8448
8605
  this.managerLife.forEach(eventName => {
8449
8606
  anim.on(eventName, e => component.emit(eventName, e));
@@ -8452,6 +8609,7 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
8452
8609
  });
8453
8610
  }
8454
8611
  getDir(url) {
8612
+ if (!url) return url;
8455
8613
  return new URL('./', url).href;
8456
8614
  }
8457
8615
  remove(changed) {
@@ -8472,6 +8630,7 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
8472
8630
  class Lottie extends eva_js.Component {
8473
8631
  constructor(options) {
8474
8632
  super();
8633
+ this._replaceData = null;
8475
8634
  this.loadStatus = false;
8476
8635
  this.firstPlay = null;
8477
8636
  this.prevSlot = {};
@@ -8544,6 +8703,11 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
8544
8703
  });
8545
8704
  this.anim.playSegment(this.playParamsHandle(params), expandOpts);
8546
8705
  }
8706
+ replaceData(data) {
8707
+ if (data) {
8708
+ if (this.anim) this.anim.replaceData(data);else this._replaceData = data;
8709
+ }
8710
+ }
8547
8711
  playParamsHandle(params) {
8548
8712
  let p = [].concat(params);
8549
8713
  const {