@eva/plugin-renderer-lottie 2.0.1-beta.9 → 2.0.2-beta.0

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.
@@ -11,19 +11,19 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
11
11
 
12
12
  var iOSVersion__default = /*#__PURE__*/_interopDefaultLegacy(iOSVersion);
13
13
 
14
- /*! *****************************************************************************
15
- Copyright (c) Microsoft Corporation. All rights reserved.
16
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
17
- this file except in compliance with the License. You may obtain a copy of the
18
- License at http://www.apache.org/licenses/LICENSE-2.0
14
+ /******************************************************************************
15
+ Copyright (c) Microsoft Corporation.
19
16
 
20
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
22
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
23
- MERCHANTABLITY OR NON-INFRINGEMENT.
17
+ Permission to use, copy, modify, and/or distribute this software for any
18
+ purpose with or without fee is hereby granted.
24
19
 
25
- See the Apache Version 2.0 License for specific language governing permissions
26
- and limitations under the License.
20
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
21
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
22
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
23
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
24
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
25
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
26
+ PERFORMANCE OF THIS SOFTWARE.
27
27
  ***************************************************************************** */
28
28
 
29
29
  function __rest(s, e) {
@@ -46,13 +46,19 @@ function __decorate(decorators, target, key, desc) {
46
46
  }
47
47
 
48
48
  function __awaiter(thisArg, _arguments, P, generator) {
49
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
49
50
  return new (P || (P = Promise))(function (resolve, reject) {
50
51
  function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
51
52
  function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
52
- function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
53
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
53
54
  step((generator = generator.apply(thisArg, _arguments || [])).next());
54
55
  });
55
- }
56
+ }
57
+
58
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
59
+ var e = new Error(message);
60
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
61
+ };
56
62
 
57
63
  function _assertThisInitialized(e) {
58
64
  if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
@@ -13121,6 +13127,12 @@ let LottieSystem = class LottieSystem extends pluginRenderer.Renderer {
13121
13127
  'update',
13122
13128
  ];
13123
13129
  }
13130
+ /**
13131
+ * System 初始化用,可以配置参数,游戏未开始
13132
+ *
13133
+ * System init, set params, game is not begain
13134
+ * @param param init params
13135
+ */
13124
13136
  init() {
13125
13137
  this.renderSystem = this.game.getSystem('Renderer');
13126
13138
  this.app = this.renderSystem.application;
@@ -13191,13 +13203,78 @@ LottieSystem = __decorate([
13191
13203
  ], LottieSystem);
13192
13204
  var LottieSystem$1 = LottieSystem;
13193
13205
 
13206
+ /**
13207
+ * Lottie 动画组件
13208
+ *
13209
+ * Lottie 组件用于播放 Adobe After Effects 导出的 Lottie 动画文件。
13210
+ * Lottie 是一种基于 JSON 的动画格式,可以实现复杂的矢量动画效果,
13211
+ * 文件体积小、性能高,适用于图标动画、loading 动画、复杂 UI 动效等场景。
13212
+ *
13213
+ * 主要功能:
13214
+ * - 播放 Lottie JSON 动画
13215
+ * - 支持动画片段播放和循环
13216
+ * - 支持插槽(slot)动态替换内容
13217
+ * - 支持帧事件监听
13218
+ * - 支持交互热区绑定
13219
+ * - 支持动态替换动画数据
13220
+ *
13221
+ * @example
13222
+ * ```typescript
13223
+ * // 基础用法
13224
+ * const animation = new GameObject('animation');
13225
+ * animation.addComponent(new Lottie({
13226
+ * resource: 'loadingAnimation', // Lottie JSON 资源
13227
+ * autoStart: true
13228
+ * }));
13229
+ *
13230
+ * // 播放指定片段
13231
+ * const lottie = animation.getComponent('Lottie');
13232
+ * lottie.play([0, 60], { repeats: -1 }); // 播放 0-60 帧,无限循环
13233
+ *
13234
+ * // 动态替换插槽内容
13235
+ * lottie.play([0, 120], {
13236
+ * slot: [{
13237
+ * name: 'avatar',
13238
+ * type: 'IMAGE',
13239
+ * value: 'user-avatar.png',
13240
+ * style: { width: 100, height: 100 }
13241
+ * }, {
13242
+ * name: 'username',
13243
+ * type: 'TEXT',
13244
+ * value: '玩家名称',
13245
+ * style: { fontSize: 24 }
13246
+ * }]
13247
+ * });
13248
+ *
13249
+ * // 监听特定帧事件
13250
+ * lottie.on('@30', () => {
13251
+ * console.log('到达第 30 帧');
13252
+ * });
13253
+ *
13254
+ * // 绑定点击热区
13255
+ * lottie.onTap('buttonLayer', () => {
13256
+ * console.log('按钮被点击');
13257
+ * });
13258
+ * ```
13259
+ */
13194
13260
  class Lottie extends eva_js.Component {
13261
+ /**
13262
+ * 构造 Lottie 组件
13263
+ * @param options - Lottie 配置选项
13264
+ * @param options.resource - Lottie JSON 资源名称
13265
+ * @param options.autoStart - 是否自动开始播放
13266
+ */
13195
13267
  constructor(options) {
13196
13268
  super();
13269
+ /** 待替换的数据 */
13197
13270
  this._replaceData = null;
13271
+ /** 资源加载状态 */
13198
13272
  this.loadStatus = false;
13273
+ /** 首次播放回调 */
13199
13274
  this.firstPlay = null;
13275
+ /** 前一次的插槽内容 */
13200
13276
  this.prevSlot = {};
13277
+ /** 当前的插槽内容 */
13201
13278
  this.currentSlot = {};
13202
13279
  this.options = Object.assign({ autoStart: false }, options);
13203
13280
  this.on('success', () => {
@@ -13282,6 +13359,7 @@ class Lottie extends eva_js.Component {
13282
13359
  });
13283
13360
  }
13284
13361
  }
13362
+ /** 组件名称 */
13285
13363
  Lottie.componentName = 'Lottie';
13286
13364
 
13287
13365
  eva_js.resource.registerResourceType('LOTTIE');