@eva/plugin-renderer-lottie 2.0.0-beta.1 → 2.0.0-beta.11

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.
@@ -1,35 +1,9 @@
1
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
1
2
  window.EVA = window.EVA || {};
2
3
  window.EVA.plugin = window.EVA.plugin || {};
3
4
  window.EVA.plugin.renderer = window.EVA.plugin.renderer || {};
4
5
  var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
5
6
  'use strict';
6
- var extendStatics = function (d, b) {
7
- extendStatics = Object.setPrototypeOf || {
8
- __proto__: []
9
- } instanceof Array && function (d, b) {
10
- d.__proto__ = b;
11
- } || function (d, b) {
12
- for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
13
- };
14
- return extendStatics(d, b);
15
- };
16
- function __extends(d, b) {
17
- extendStatics(d, b);
18
- function __() {
19
- this.constructor = d;
20
- }
21
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
22
- }
23
- var __assign = function () {
24
- __assign = Object.assign || function __assign(t) {
25
- for (var s, i = 1, n = arguments.length; i < n; i++) {
26
- s = arguments[i];
27
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
28
- }
29
- return t;
30
- };
31
- return __assign.apply(this, arguments);
32
- };
33
7
  function __rest(s, e) {
34
8
  var t = {};
35
9
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
@@ -72,94 +46,6 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
72
46
  step((generator = generator.apply(thisArg, _arguments || [])).next());
73
47
  });
74
48
  }
75
- function __generator(thisArg, body) {
76
- var _ = {
77
- label: 0,
78
- sent: function () {
79
- if (t[0] & 1) throw t[1];
80
- return t[1];
81
- },
82
- trys: [],
83
- ops: []
84
- },
85
- f,
86
- y,
87
- t,
88
- g;
89
- return g = {
90
- next: verb(0),
91
- "throw": verb(1),
92
- "return": verb(2)
93
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
94
- return this;
95
- }), g;
96
- function verb(n) {
97
- return function (v) {
98
- return step([n, v]);
99
- };
100
- }
101
- function step(op) {
102
- if (f) throw new TypeError("Generator is already executing.");
103
- while (_) try {
104
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
105
- if (y = 0, t) op = [op[0] & 2, t.value];
106
- switch (op[0]) {
107
- case 0:
108
- case 1:
109
- t = op;
110
- break;
111
- case 4:
112
- _.label++;
113
- return {
114
- value: op[1],
115
- done: false
116
- };
117
- case 5:
118
- _.label++;
119
- y = op[1];
120
- op = [0];
121
- continue;
122
- case 7:
123
- op = _.ops.pop();
124
- _.trys.pop();
125
- continue;
126
- default:
127
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
128
- _ = 0;
129
- continue;
130
- }
131
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
132
- _.label = op[1];
133
- break;
134
- }
135
- if (op[0] === 6 && _.label < t[1]) {
136
- _.label = t[1];
137
- t = op;
138
- break;
139
- }
140
- if (t && _.label < t[2]) {
141
- _.label = t[2];
142
- _.ops.push(op);
143
- break;
144
- }
145
- if (t[2]) _.ops.pop();
146
- _.trys.pop();
147
- continue;
148
- }
149
- op = body.call(thisArg, _);
150
- } catch (e) {
151
- op = [6, e];
152
- y = 0;
153
- } finally {
154
- f = t = 0;
155
- }
156
- if (op[0] & 5) throw op[1];
157
- return {
158
- value: op[0] ? op[1] : void 0,
159
- done: true
160
- };
161
- }
162
- }
163
49
  function t(t) {
164
50
  return Object.prototype.toString.call(t);
165
51
  }
@@ -3685,199 +3571,175 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
3685
3571
  wt.registerDisplayByType(wt.Type.Sprite, R);
3686
3572
  wt.registerDisplayByType(wt.Type.Component, k);
3687
3573
  wt.registerDisplayByType(wt.Type.Container, pixi_js.Container);
3688
- var LottieSystem = function (_super) {
3689
- __extends(LottieSystem, _super);
3690
- function LottieSystem() {
3691
- var _this = _super !== null && _super.apply(this, arguments) || this;
3692
- _this.managerLife = ['DisplayReady', 'ImageReady', 'success', 'error', 'complete', 'loopComplete', 'enterFrame', 'update'];
3693
- return _this;
3694
- }
3695
- LottieSystem.prototype.init = function () {
3574
+ let LottieSystem = class LottieSystem extends pluginRenderer.Renderer {
3575
+ constructor() {
3576
+ super(...arguments);
3577
+ this.managerLife = ['DisplayReady', 'ImageReady', 'success', 'error', 'complete', 'loopComplete', 'enterFrame', 'update'];
3578
+ }
3579
+ init() {
3696
3580
  this.renderSystem = this.game.getSystem('Renderer');
3697
3581
  this.app = this.renderSystem.application;
3698
- };
3699
- LottieSystem.prototype.componentChanged = function (changed) {
3700
- return __awaiter(this, void 0, void 0, function () {
3701
- return __generator(this, function (_a) {
3702
- if (changed.componentName === 'Lottie') {
3703
- if (changed.type === eva_js.OBSERVER_TYPE.ADD) {
3704
- this.add(changed);
3705
- } else if (changed.type === eva_js.OBSERVER_TYPE.REMOVE) {
3706
- this.remove(changed);
3707
- }
3582
+ }
3583
+ componentChanged(changed) {
3584
+ return __awaiter(this, void 0, void 0, function* () {
3585
+ if (changed.componentName === 'Lottie') {
3586
+ if (changed.type === eva_js.OBSERVER_TYPE.ADD) {
3587
+ this.add(changed);
3588
+ } else if (changed.type === eva_js.OBSERVER_TYPE.REMOVE) {
3589
+ this.remove(changed);
3708
3590
  }
3709
- return [2];
3710
- });
3591
+ }
3711
3592
  });
3712
- };
3713
- LottieSystem.prototype.add = function (changed) {
3714
- return __awaiter(this, void 0, void 0, function () {
3715
- var component, container, _a, rn, otherOpts, data, json, assets, anim;
3716
- return __generator(this, function (_b) {
3717
- switch (_b.label) {
3718
- case 0:
3719
- this.manager = new Gt(this.app);
3720
- component = changed.component;
3721
- container = this.renderSystem.containerManager.getContainer(changed.gameObject.id);
3722
- if (!container) return [2];
3723
- _a = component.options, rn = _a.resource, otherOpts = __rest(_a, ["resource"]);
3724
- return [4, eva_js.resource.getResource(rn)];
3725
- case 1:
3726
- data = _b.sent().data;
3727
- json = __assign({}, data.json || {});
3728
- assets = json.assets || [];
3729
- assets.forEach(function (item) {
3730
- if (item.p) item.p = imageHandle(item.p);
3731
- });
3732
- anim = this.manager.parseAnimation(__assign({
3733
- keyframes: json
3734
- }, otherOpts));
3735
- component.anim = anim;
3736
- container.addChildAt(anim.group, 0);
3737
- this.managerLife.forEach(function (eventName) {
3738
- anim.on(eventName, function (e) {
3739
- return component.emit(eventName, e);
3740
- });
3741
- });
3742
- if (anim.isImagesLoaded) component.emit('success', {});
3743
- return [2];
3744
- }
3593
+ }
3594
+ add(changed) {
3595
+ return __awaiter(this, void 0, void 0, function* () {
3596
+ this.manager = new Gt(this.app);
3597
+ const component = changed.component;
3598
+ const container = this.renderSystem.containerManager.getContainer(changed.gameObject.id);
3599
+ if (!container) return;
3600
+ const _a = component.options,
3601
+ {
3602
+ resource: rn
3603
+ } = _a,
3604
+ otherOpts = __rest(_a, ["resource"]);
3605
+ const {
3606
+ data
3607
+ } = yield eva_js.resource.getResource(rn);
3608
+ const json = _extends({}, data.json || {});
3609
+ const assets = json.assets || [];
3610
+ assets.forEach(item => {
3611
+ if (item.p) item.p = imageHandle(item.p);
3745
3612
  });
3613
+ const anim = this.manager.parseAnimation(_extends({
3614
+ keyframes: json
3615
+ }, otherOpts));
3616
+ component.anim = anim;
3617
+ container.addChildAt(anim.group, 0);
3618
+ this.managerLife.forEach(eventName => {
3619
+ anim.on(eventName, e => component.emit(eventName, e));
3620
+ });
3621
+ if (anim.isImagesLoaded) component.emit('success', {});
3746
3622
  });
3747
- };
3748
- LottieSystem.prototype.remove = function (changed) {
3749
- var component = changed.component;
3750
- var container = this.renderSystem.containerManager.getContainer(changed.gameObject.id);
3623
+ }
3624
+ remove(changed) {
3625
+ const component = changed.component;
3626
+ const container = this.renderSystem.containerManager.getContainer(changed.gameObject.id);
3751
3627
  if (container) {
3752
3628
  container.removeChild(component.anim.group);
3753
3629
  component.anim.destroy();
3754
3630
  }
3755
3631
  component.anim = null;
3756
- };
3757
- LottieSystem.systemName = 'LottieSystem';
3758
- LottieSystem = __decorate([eva_js.decorators.componentObserver({
3759
- Lottie: []
3760
- })], LottieSystem);
3761
- return LottieSystem;
3762
- }(pluginRenderer.Renderer);
3632
+ }
3633
+ };
3634
+ LottieSystem.systemName = 'LottieSystem';
3635
+ LottieSystem = __decorate([eva_js.decorators.componentObserver({
3636
+ Lottie: []
3637
+ })], LottieSystem);
3763
3638
  var LottieSystem$1 = LottieSystem;
3764
- var Lottie = function (_super) {
3765
- __extends(Lottie, _super);
3766
- function Lottie(options) {
3767
- var _this = _super.call(this) || this;
3768
- _this.loadStatus = false;
3769
- _this.firstPlay = null;
3770
- _this.prevSlot = {};
3771
- _this.currentSlot = {};
3772
- _this.options = __assign({
3639
+ class Lottie extends eva_js.Component {
3640
+ constructor(options) {
3641
+ super();
3642
+ this.loadStatus = false;
3643
+ this.firstPlay = null;
3644
+ this.prevSlot = {};
3645
+ this.currentSlot = {};
3646
+ this.options = _extends({
3773
3647
  autoStart: false
3774
3648
  }, options);
3775
- _this.on('success', function () {
3776
- _this.loadStatus = true;
3777
- var _a = _this.anim.keyframes,
3778
- ip = _a.ip,
3779
- op = _a.op;
3780
- var _loop_1 = function (i) {
3781
- var event_1 = "@" + i;
3782
- _this.anim.on(event_1, function (e) {
3783
- return _this.emit(event_1, e);
3784
- });
3785
- };
3786
- for (var i = ip; i <= op; i++) {
3787
- _loop_1(i);
3649
+ this.on('success', () => {
3650
+ this.loadStatus = true;
3651
+ const {
3652
+ ip,
3653
+ op
3654
+ } = this.anim.keyframes;
3655
+ for (let i = ip; i <= op; i++) {
3656
+ const event = `@${i}`;
3657
+ this.anim.on(event, e => this.emit(event, e));
3788
3658
  }
3789
- _this.firstPlay && _this.firstPlay();
3659
+ this.firstPlay && this.firstPlay();
3790
3660
  });
3791
- return _this;
3792
3661
  }
3793
- Lottie.prototype.play = function (params, expandOpts) {
3794
- var _this = this;
3795
- if (params === void 0) {
3796
- params = [];
3797
- }
3798
- if (expandOpts === void 0) {
3799
- expandOpts = {
3800
- repeats: 0
3801
- };
3802
- }
3662
+ play(params = [], expandOpts = {
3663
+ repeats: 0
3664
+ }) {
3803
3665
  if (!this.loadStatus) {
3804
- this.firstPlay = function () {
3805
- _this.play(params, expandOpts);
3666
+ this.firstPlay = () => {
3667
+ this.play(params, expandOpts);
3806
3668
  };
3807
3669
  return;
3808
3670
  }
3809
- var _a = expandOpts.slot,
3810
- slot = _a === void 0 ? [] : _a;
3811
- slot.forEach(function (_a) {
3812
- var name = _a.name,
3813
- type = _a.type,
3814
- value = _a.value,
3815
- _b = _a.style,
3816
- style = _b === void 0 ? {} : _b;
3817
- var x = style.x,
3818
- y = style.y,
3819
- _c = style.anchor,
3820
- anchor = _c === void 0 ? {
3671
+ const {
3672
+ slot = []
3673
+ } = expandOpts;
3674
+ slot.forEach(({
3675
+ name,
3676
+ type,
3677
+ value,
3678
+ style = {}
3679
+ }) => {
3680
+ const {
3681
+ x,
3682
+ y,
3683
+ anchor = {
3821
3684
  x: 0,
3822
3685
  y: 0
3823
- } : _c,
3824
- _d = style.pivot,
3825
- pivot = _d === void 0 ? {
3686
+ },
3687
+ pivot = {
3826
3688
  x: 0,
3827
3689
  y: 0
3828
- } : _d,
3829
- width = style.width,
3830
- height = style.height;
3690
+ },
3691
+ width,
3692
+ height
3693
+ } = style;
3831
3694
  if (type === 'IMAGE') {
3832
- _this.currentSlot[name] = pixi_js.Sprite.from(value);
3695
+ this.currentSlot[name] = pixi_js.Sprite.from(value);
3833
3696
  } else if (type === 'TEXT') {
3834
- _this.currentSlot[name] = new pixi_js.Text(value, new pixi_js.TextStyle(style));
3697
+ this.currentSlot[name] = new pixi_js.Text(value, new pixi_js.TextStyle(style));
3835
3698
  }
3836
- if (x) _this.currentSlot[name].x = x;
3837
- if (y) _this.currentSlot[name].y = y;
3838
- if (width) _this.currentSlot[name].width = width;
3839
- if (height) _this.currentSlot[name].height = height;
3840
- _this.currentSlot[name].anchor.set(anchor.x || 0, anchor.y || 0);
3841
- _this.currentSlot[name].pivot.set(_this.currentSlot[name].width * (pivot.x || 0), _this.currentSlot[name].height * (pivot.y || 0));
3842
- if (_this.prevSlot[name]) _this.anim.unbindSlot(name, _this.prevSlot[name]);
3843
- _this.anim.bindSlot(name, _this.currentSlot[name]);
3844
- _this.prevSlot[name] = _this.currentSlot[name];
3699
+ if (x) this.currentSlot[name].x = x;
3700
+ if (y) this.currentSlot[name].y = y;
3701
+ if (width) this.currentSlot[name].width = width;
3702
+ if (height) this.currentSlot[name].height = height;
3703
+ this.currentSlot[name].anchor.set(anchor.x || 0, anchor.y || 0);
3704
+ this.currentSlot[name].pivot.set(this.currentSlot[name].width * (pivot.x || 0), this.currentSlot[name].height * (pivot.y || 0));
3705
+ if (this.prevSlot[name]) this.anim.unbindSlot(name, this.prevSlot[name]);
3706
+ this.anim.bindSlot(name, this.currentSlot[name]);
3707
+ this.prevSlot[name] = this.currentSlot[name];
3845
3708
  });
3846
3709
  this.anim.playSegment(this.playParamsHandle(params), expandOpts);
3847
- };
3848
- Lottie.prototype.playParamsHandle = function (params) {
3849
- var p = [].concat(params);
3850
- var keyframes = this.anim.keyframes;
3710
+ }
3711
+ playParamsHandle(params) {
3712
+ let p = [].concat(params);
3713
+ const {
3714
+ keyframes
3715
+ } = this.anim;
3851
3716
  if (!p.length || p.length > 2) {
3852
3717
  p = [keyframes.ip, keyframes.op];
3853
3718
  } else if (p.length === 1) {
3854
3719
  p = [p[0] % keyframes.op, keyframes.op];
3855
3720
  }
3856
3721
  return p;
3857
- };
3858
- Lottie.prototype.onTap = function (name, callback) {
3859
- var _this = this;
3860
- var g = new pixi_js.Graphics();
3861
- this.on('success', function () {
3862
- var ele = _this.anim.querySelector(name);
3863
- var display = ele.display;
3722
+ }
3723
+ onTap(name, callback) {
3724
+ const g = new pixi_js.Graphics();
3725
+ this.on('success', () => {
3726
+ const ele = this.anim.querySelector(name);
3727
+ const display = ele.display;
3864
3728
  g.beginFill(0xffffff);
3865
3729
  g.drawRect(0, 0, 100, 100);
3866
3730
  g.endFill();
3867
3731
  g.alpha = 0;
3868
3732
  display.addChild(g);
3869
3733
  ele.display.interactive = true;
3870
- ele.display.on('pointertap', function () {
3734
+ ele.display.on('pointertap', () => {
3871
3735
  callback();
3872
3736
  });
3873
3737
  });
3874
- };
3875
- Lottie.componentName = 'Lottie';
3876
- return Lottie;
3877
- }(eva_js.Component);
3878
- var Lottie$1 = Lottie;
3738
+ }
3739
+ }
3740
+ Lottie.componentName = 'Lottie';
3879
3741
  eva_js.resource.registerResourceType('LOTTIE');
3880
- exports.Lottie = Lottie$1;
3742
+ exports.Lottie = Lottie;
3881
3743
  exports.LottieSystem = LottieSystem$1;
3882
3744
  Object.defineProperty(exports, '__esModule', {
3883
3745
  value: true