@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.
@@ -32,22 +32,91 @@ declare interface IOptions {
32
32
  replaceData?: boolean;
33
33
  }
34
34
 
35
+ /**
36
+ * Lottie 动画组件
37
+ *
38
+ * Lottie 组件用于播放 Adobe After Effects 导出的 Lottie 动画文件。
39
+ * Lottie 是一种基于 JSON 的动画格式,可以实现复杂的矢量动画效果,
40
+ * 文件体积小、性能高,适用于图标动画、loading 动画、复杂 UI 动效等场景。
41
+ *
42
+ * 主要功能:
43
+ * - 播放 Lottie JSON 动画
44
+ * - 支持动画片段播放和循环
45
+ * - 支持插槽(slot)动态替换内容
46
+ * - 支持帧事件监听
47
+ * - 支持交互热区绑定
48
+ * - 支持动态替换动画数据
49
+ *
50
+ * @example
51
+ * ```typescript
52
+ * // 基础用法
53
+ * const animation = new GameObject('animation');
54
+ * animation.addComponent(new Lottie({
55
+ * resource: 'loadingAnimation', // Lottie JSON 资源
56
+ * autoStart: true
57
+ * }));
58
+ *
59
+ * // 播放指定片段
60
+ * const lottie = animation.getComponent('Lottie');
61
+ * lottie.play([0, 60], { repeats: -1 }); // 播放 0-60 帧,无限循环
62
+ *
63
+ * // 动态替换插槽内容
64
+ * lottie.play([0, 120], {
65
+ * slot: [{
66
+ * name: 'avatar',
67
+ * type: 'IMAGE',
68
+ * value: 'user-avatar.png',
69
+ * style: { width: 100, height: 100 }
70
+ * }, {
71
+ * name: 'username',
72
+ * type: 'TEXT',
73
+ * value: '玩家名称',
74
+ * style: { fontSize: 24 }
75
+ * }]
76
+ * });
77
+ *
78
+ * // 监听特定帧事件
79
+ * lottie.on('@30', () => {
80
+ * console.log('到达第 30 帧');
81
+ * });
82
+ *
83
+ * // 绑定点击热区
84
+ * lottie.onTap('buttonLayer', () => {
85
+ * console.log('按钮被点击');
86
+ * });
87
+ * ```
88
+ */
35
89
  export declare class Lottie extends Component {
90
+ /** 插槽配置 */
36
91
  slot: {
37
92
  [key: string]: string;
38
93
  };
94
+ /** 待替换的数据 */
39
95
  _replaceData: Record<string, string> | null;
96
+ /** 组件名称 */
40
97
  static componentName: string;
98
+ /** Lottie 动画实例 */
41
99
  anim: any;
100
+ /** Lottie 配置选项 */
42
101
  options: ExtendOptions;
102
+ /** 资源加载状态 */
43
103
  loadStatus: boolean;
104
+ /** 首次播放回调 */
44
105
  firstPlay: () => void | null;
106
+ /** 前一次的插槽内容 */
45
107
  prevSlot: {
46
108
  [name: string]: any;
47
109
  };
110
+ /** 当前的插槽内容 */
48
111
  currentSlot: {
49
112
  [name: string]: any;
50
113
  };
114
+ /**
115
+ * 构造 Lottie 组件
116
+ * @param options - Lottie 配置选项
117
+ * @param options.resource - Lottie JSON 资源名称
118
+ * @param options.autoStart - 是否自动开始播放
119
+ */
51
120
  constructor(options: IOptions);
52
121
  play(params?: number[], expandOpts?: IExpandOpts): void;
53
122
  replaceData(data: Record<string, string>): void;
@@ -63,6 +132,12 @@ export declare class LottieSystem extends Renderer {
63
132
  rendererManager: RendererManager;
64
133
  containerManager: ContainerManager;
65
134
  managerLife: string[];
135
+ /**
136
+ * System 初始化用,可以配置参数,游戏未开始
137
+ *
138
+ * System init, set params, game is not begain
139
+ * @param param init params
140
+ */
66
141
  init(): void;
67
142
  componentChanged(changed: ComponentChanged): Promise<void>;
68
143
  add(changed: ComponentChanged): Promise<void>;
@@ -3,19 +3,19 @@ import { Renderer } from '@eva/plugin-renderer';
3
3
  import { Ticker, Container, Assets, Texture, Graphics, Text, Matrix as Matrix$1, Sprite, TextStyle } from 'pixi.js';
4
4
  import iOSVersion from 'ios-version';
5
5
 
6
- /*! *****************************************************************************
7
- Copyright (c) Microsoft Corporation. All rights reserved.
8
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
9
- this file except in compliance with the License. You may obtain a copy of the
10
- License at http://www.apache.org/licenses/LICENSE-2.0
6
+ /******************************************************************************
7
+ Copyright (c) Microsoft Corporation.
11
8
 
12
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
14
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
15
- MERCHANTABLITY OR NON-INFRINGEMENT.
9
+ Permission to use, copy, modify, and/or distribute this software for any
10
+ purpose with or without fee is hereby granted.
16
11
 
17
- See the Apache Version 2.0 License for specific language governing permissions
18
- and limitations under the License.
12
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
13
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
14
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
15
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
16
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
17
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
18
+ PERFORMANCE OF THIS SOFTWARE.
19
19
  ***************************************************************************** */
20
20
 
21
21
  function __rest(s, e) {
@@ -38,13 +38,19 @@ function __decorate(decorators, target, key, desc) {
38
38
  }
39
39
 
40
40
  function __awaiter(thisArg, _arguments, P, generator) {
41
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
41
42
  return new (P || (P = Promise))(function (resolve, reject) {
42
43
  function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
43
44
  function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
44
- function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
45
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
45
46
  step((generator = generator.apply(thisArg, _arguments || [])).next());
46
47
  });
47
- }
48
+ }
49
+
50
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
51
+ var e = new Error(message);
52
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
53
+ };
48
54
 
49
55
  function _assertThisInitialized(e) {
50
56
  if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
@@ -13113,6 +13119,12 @@ let LottieSystem = class LottieSystem extends Renderer {
13113
13119
  'update',
13114
13120
  ];
13115
13121
  }
13122
+ /**
13123
+ * System 初始化用,可以配置参数,游戏未开始
13124
+ *
13125
+ * System init, set params, game is not begain
13126
+ * @param param init params
13127
+ */
13116
13128
  init() {
13117
13129
  this.renderSystem = this.game.getSystem('Renderer');
13118
13130
  this.app = this.renderSystem.application;
@@ -13183,13 +13195,78 @@ LottieSystem = __decorate([
13183
13195
  ], LottieSystem);
13184
13196
  var LottieSystem$1 = LottieSystem;
13185
13197
 
13198
+ /**
13199
+ * Lottie 动画组件
13200
+ *
13201
+ * Lottie 组件用于播放 Adobe After Effects 导出的 Lottie 动画文件。
13202
+ * Lottie 是一种基于 JSON 的动画格式,可以实现复杂的矢量动画效果,
13203
+ * 文件体积小、性能高,适用于图标动画、loading 动画、复杂 UI 动效等场景。
13204
+ *
13205
+ * 主要功能:
13206
+ * - 播放 Lottie JSON 动画
13207
+ * - 支持动画片段播放和循环
13208
+ * - 支持插槽(slot)动态替换内容
13209
+ * - 支持帧事件监听
13210
+ * - 支持交互热区绑定
13211
+ * - 支持动态替换动画数据
13212
+ *
13213
+ * @example
13214
+ * ```typescript
13215
+ * // 基础用法
13216
+ * const animation = new GameObject('animation');
13217
+ * animation.addComponent(new Lottie({
13218
+ * resource: 'loadingAnimation', // Lottie JSON 资源
13219
+ * autoStart: true
13220
+ * }));
13221
+ *
13222
+ * // 播放指定片段
13223
+ * const lottie = animation.getComponent('Lottie');
13224
+ * lottie.play([0, 60], { repeats: -1 }); // 播放 0-60 帧,无限循环
13225
+ *
13226
+ * // 动态替换插槽内容
13227
+ * lottie.play([0, 120], {
13228
+ * slot: [{
13229
+ * name: 'avatar',
13230
+ * type: 'IMAGE',
13231
+ * value: 'user-avatar.png',
13232
+ * style: { width: 100, height: 100 }
13233
+ * }, {
13234
+ * name: 'username',
13235
+ * type: 'TEXT',
13236
+ * value: '玩家名称',
13237
+ * style: { fontSize: 24 }
13238
+ * }]
13239
+ * });
13240
+ *
13241
+ * // 监听特定帧事件
13242
+ * lottie.on('@30', () => {
13243
+ * console.log('到达第 30 帧');
13244
+ * });
13245
+ *
13246
+ * // 绑定点击热区
13247
+ * lottie.onTap('buttonLayer', () => {
13248
+ * console.log('按钮被点击');
13249
+ * });
13250
+ * ```
13251
+ */
13186
13252
  class Lottie extends Component {
13253
+ /**
13254
+ * 构造 Lottie 组件
13255
+ * @param options - Lottie 配置选项
13256
+ * @param options.resource - Lottie JSON 资源名称
13257
+ * @param options.autoStart - 是否自动开始播放
13258
+ */
13187
13259
  constructor(options) {
13188
13260
  super();
13261
+ /** 待替换的数据 */
13189
13262
  this._replaceData = null;
13263
+ /** 资源加载状态 */
13190
13264
  this.loadStatus = false;
13265
+ /** 首次播放回调 */
13191
13266
  this.firstPlay = null;
13267
+ /** 前一次的插槽内容 */
13192
13268
  this.prevSlot = {};
13269
+ /** 当前的插槽内容 */
13193
13270
  this.currentSlot = {};
13194
13271
  this.options = Object.assign({ autoStart: false }, options);
13195
13272
  this.on('success', () => {
@@ -13274,6 +13351,7 @@ class Lottie extends Component {
13274
13351
  });
13275
13352
  }
13276
13353
  }
13354
+ /** 组件名称 */
13277
13355
  Lottie.componentName = 'Lottie';
13278
13356
 
13279
13357
  resource.registerResourceType('LOTTIE');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eva/plugin-renderer-lottie",
3
- "version": "2.0.1-beta.9",
3
+ "version": "2.0.2-beta.0",
4
4
  "description": "@eva/plugin-renderer-lottie",
5
5
  "main": "index.js",
6
6
  "module": "dist/plugin-renderer-lottie.esm.js",
@@ -18,9 +18,9 @@
18
18
  "license": "MIT",
19
19
  "homepage": "https://eva.js.org",
20
20
  "dependencies": {
21
- "@eva/eva.js": "2.0.1-beta.9",
22
- "@eva/plugin-renderer": "2.0.1-beta.9",
21
+ "@eva/eva.js": "2.0.2-beta.0",
22
+ "@eva/plugin-renderer": "2.0.2-beta.0",
23
23
  "ios-version": "^1.0.1",
24
- "pixi.js": "^8.8.1"
24
+ "pixi.js": "^8.17.0"
25
25
  }
26
26
  }