@eva/plugin-renderer-dragonbone 2.0.2 → 2.1.0-beta.2

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.
@@ -4,9 +4,23 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var inspectorDecorator = require('@eva/inspector-decorator');
6
6
  var eva_js = require('@eva/eva.js');
7
- var pixi_js = require('pixi.js');
7
+ var PIXIImport = require('pixi.js');
8
8
  var pluginRenderer = require('@eva/plugin-renderer');
9
9
 
10
+ function _interopNamespace(e) {
11
+ if (e && e.__esModule) return e;
12
+ var n = Object.create(null);
13
+ if (e) {
14
+ for (var k in e) {
15
+ n[k] = e[k];
16
+ }
17
+ }
18
+ n["default"] = e;
19
+ return Object.freeze(n);
20
+ }
21
+
22
+ var PIXIImport__namespace = /*#__PURE__*/_interopNamespace(PIXIImport);
23
+
10
24
  /******************************************************************************
11
25
  Copyright (c) Microsoft Corporation.
12
26
 
@@ -29,6 +43,10 @@ function __decorate(decorators, target, key, desc) {
29
43
  return c > 3 && r && Object.defineProperty(target, key, r), r;
30
44
  }
31
45
 
46
+ function __metadata(metadataKey, metadataValue) {
47
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
48
+ }
49
+
32
50
  function __awaiter(thisArg, _arguments, P, generator) {
33
51
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
34
52
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -162,26 +180,73 @@ class DragonBone$3 extends eva_js.Component {
162
180
  /** 组件名称 */
163
181
  DragonBone$3.componentName = 'DragonBone';
164
182
  __decorate([
165
- inspectorDecorator.type('string')
183
+ inspectorDecorator.type('string'),
184
+ __metadata("design:type", String)
166
185
  ], DragonBone$3.prototype, "resource", void 0);
167
186
  __decorate([
168
- inspectorDecorator.type('string')
187
+ inspectorDecorator.type('string'),
188
+ __metadata("design:type", String)
169
189
  ], DragonBone$3.prototype, "armatureName", void 0);
170
190
  __decorate([
171
- inspectorDecorator.type('string')
191
+ inspectorDecorator.type('string'),
192
+ __metadata("design:type", String)
172
193
  ], DragonBone$3.prototype, "animationName", void 0);
173
194
  __decorate([
174
- inspectorDecorator.type('boolean')
195
+ inspectorDecorator.type('boolean'),
196
+ __metadata("design:type", Boolean)
175
197
  ], DragonBone$3.prototype, "autoPlay", void 0);
176
198
 
199
+ // PixiJS v8 移除了 DisplayObject.setTransform,dragonbones runtime 还在用,
200
+ // 给 Container 原型打回 polyfill,行为对齐 v7。
201
+ if (PIXIImport__namespace.Container && !PIXIImport__namespace.Container.prototype.setTransform) {
202
+ PIXIImport__namespace.Container.prototype.setTransform = function (
203
+ x, y, scaleX, scaleY, rotation, skewX, skewY, pivotX, pivotY,
204
+ ) {
205
+ if (x !== undefined) this.position.set(x, y || 0);
206
+ if (scaleX !== undefined) this.scale.set(scaleX, scaleY === undefined ? scaleX : scaleY);
207
+ if (rotation !== undefined) this.rotation = rotation;
208
+ if (skewX !== undefined && this.skew) this.skew.set(skewX, skewY || 0);
209
+ if (pivotX !== undefined) this.pivot.set(pivotX, pivotY || 0);
210
+ return this;
211
+ };
212
+ }
213
+
177
214
  const PIXI = {
178
- Texture: pixi_js.Texture,
179
- Rectangle: pixi_js.Rectangle,
180
- Sprite: pixi_js.Sprite,
181
- Graphics: pixi_js.Graphics,
182
- BLEND_MODES: pixi_js.BLEND_MODES,
183
- mesh: pixi_js.mesh,
184
- ticker: pixi_js.ticker,
215
+ Texture: PIXIImport__namespace.Texture,
216
+ Rectangle: PIXIImport__namespace.Rectangle,
217
+ Sprite: PIXIImport__namespace.Sprite,
218
+ Graphics: PIXIImport__namespace.Graphics,
219
+ BLEND_MODES: PIXIImport__namespace.BLEND_MODES || {
220
+ NORMAL: 'normal',
221
+ ADD: 'add',
222
+ DARKEN: 'darken',
223
+ DIFFERENCE: 'difference',
224
+ HARD_LIGHT: 'hard-light',
225
+ LIGHTEN: 'lighten',
226
+ MULTIPLY: 'multiply',
227
+ OVERLAY: 'overlay',
228
+ SCREEN: 'screen',
229
+ },
230
+ // PixiJS v8 不再导出 mesh / ticker namespace,这里给 dragonbones runtime
231
+ // 提供一个最小 stub:把 Mesh 用 Container 替身(无 skinned mesh 变形,但
232
+ // 大部分骨骼动画走 Sprite 渲染,fallback 到 Sprite 也可见效果)。
233
+ mesh: (PIXIImport__namespace.mesh) || {
234
+ Mesh: /** @class */ (function () {
235
+ // PixiJS v8 不再有 mesh.Mesh,这里只为让 dragonbones runtime 不爆错
236
+ // 提供 vertices/uvs/indices 数组占位。无真实 skinned mesh 渲染,
237
+ // 但 sprite-only 的 dragonbones 资源仍能正常显示。
238
+ function MeshStub() {
239
+ var s = new PIXIImport__namespace.Sprite();
240
+ s.vertices = [];
241
+ s.uvs = [];
242
+ s.indices = [];
243
+ return s;
244
+ }
245
+ MeshStub.DRAW_MODES = { TRIANGLES: 4, TRIANGLE_STRIP: 5, TRIANGLE_FAN: 6 };
246
+ return MeshStub;
247
+ })(),
248
+ },
249
+ ticker: PIXIImport__namespace.ticker || {},
185
250
  };
186
251
  var dragonBones;
187
252
  var __extends =
@@ -16217,7 +16282,9 @@ if (!Date.now) {
16217
16282
  var PixiArmatureDisplay = /** @class */ (function (_super) {
16218
16283
  __extends(PixiArmatureDisplay, _super);
16219
16284
  function PixiArmatureDisplay() {
16220
- var _this = (_super !== null && _super.apply(this, arguments)) || this;
16285
+ // PixiJS v8 Sprite 改为 ES class,不能用 _super.apply(this, ...)
16286
+ // 改用 Reflect.construct 在 _super 上构造一个新实例,再把当前 prototype 链挂回去。
16287
+ var _this = (_super !== null && Reflect.construct(_super, arguments, this.constructor)) || this;
16221
16288
  /**
16222
16289
  * @private
16223
16290
  */
@@ -16993,7 +17060,7 @@ const factory = dragonBones$1.PixiFactory.factory;
16993
17060
  eva_js.resource.registerResourceType('DRAGONBONE');
16994
17061
  eva_js.resource.registerInstance(eva_js.RESOURCE_TYPE.DRAGONBONE, ({ data, name }) => {
16995
17062
  factory.parseDragonBonesData(data.ske, name);
16996
- factory.parseTextureAtlasData(data.tex, pixi_js.Texture.from(data.image), name);
17063
+ factory.parseTextureAtlasData(data.tex, PIXIImport.Texture.from(data.image), name);
16997
17064
  });
16998
17065
  eva_js.resource.registerDestroy(eva_js.RESOURCE_TYPE.DRAGONBONE, ({ name }) => {
16999
17066
  factory.removeDragonBonesData(name);