@eva/plugin-renderer-sprite 1.2.7-editor.7 → 1.2.8-fix.1

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.
@@ -5,24 +5,22 @@ window.EVA.plugin.renderer = window.EVA.plugin.renderer || {};
5
5
  var _EVA_IIFE_sprite = function (exports, eva_js, pluginRenderer, pixi_js) {
6
6
  'use strict';
7
7
 
8
- var _extendStatics$ = function extendStatics$1(d, b) {
9
- _extendStatics$ = Object.setPrototypeOf || {
8
+ var _extendStatics = function extendStatics(d, b) {
9
+ _extendStatics = Object.setPrototypeOf || {
10
10
  __proto__: []
11
11
  } instanceof Array && function (d, b) {
12
12
  d.__proto__ = b;
13
13
  } || function (d, b) {
14
14
  for (var p in b) {
15
- if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
15
+ if (b.hasOwnProperty(p)) d[p] = b[p];
16
16
  }
17
17
  };
18
18
 
19
- return _extendStatics$(d, b);
19
+ return _extendStatics(d, b);
20
20
  };
21
21
 
22
- function __extends$1(d, b) {
23
- if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
24
-
25
- _extendStatics$(d, b);
22
+ function __extends(d, b) {
23
+ _extendStatics(d, b);
26
24
 
27
25
  function __() {
28
26
  this.constructor = d;
@@ -31,22 +29,6 @@ var _EVA_IIFE_sprite = function (exports, eva_js, pluginRenderer, pixi_js) {
31
29
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
32
30
  }
33
31
 
34
- var _assign = function __assign() {
35
- _assign = Object.assign || function __assign(t) {
36
- for (var s, i = 1, n = arguments.length; i < n; i++) {
37
- s = arguments[i];
38
-
39
- for (var p in s) {
40
- if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
41
- }
42
- }
43
-
44
- return t;
45
- };
46
-
47
- return _assign.apply(this, arguments);
48
- };
49
-
50
32
  function __decorate(decorators, target, key, desc) {
51
33
  var c = arguments.length,
52
34
  r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
@@ -57,10 +39,6 @@ var _EVA_IIFE_sprite = function (exports, eva_js, pluginRenderer, pixi_js) {
57
39
  return c > 3 && r && Object.defineProperty(target, key, r), r;
58
40
  }
59
41
 
60
- function __metadata(metadataKey, metadataValue) {
61
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
62
- }
63
-
64
42
  function __awaiter(thisArg, _arguments, P, generator) {
65
43
  function adopt(value) {
66
44
  return value instanceof P ? value : new P(function (resolve) {
@@ -221,119 +199,29 @@ var _EVA_IIFE_sprite = function (exports, eva_js, pluginRenderer, pixi_js) {
221
199
  throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
222
200
  }
223
201
 
224
- var SymbolKeysNotSupportedError = function (_super) {
225
- __extends$1(SymbolKeysNotSupportedError, _super);
226
-
227
- function SymbolKeysNotSupportedError() {
228
- var _newTarget = this.constructor;
229
-
230
- var _this = _super.call(this, 'Symbol keys are not supported yet!') || this;
231
-
232
- Object.setPrototypeOf(_this, _newTarget.prototype);
233
- return _this;
234
- }
235
-
236
- return SymbolKeysNotSupportedError;
237
- }(Error);
238
-
239
- (function (_super) {
240
- __extends$1(StaticGetPropertiesIsNotAFunctionError, _super);
241
-
242
- function StaticGetPropertiesIsNotAFunctionError() {
243
- var _newTarget = this.constructor;
244
-
245
- var _this = _super.call(this, 'getProperties is not a function!') || this;
246
-
247
- Object.setPrototypeOf(_this, _newTarget.prototype);
248
- return _this;
249
- }
250
-
251
- return StaticGetPropertiesIsNotAFunctionError;
252
- })(Error);
253
-
254
- var IDE_PROPERTY_METADATA = 'IDE_PROPERTY_METADATA';
255
-
256
- function transformBasicType(type) {
257
- if (type === String) {
258
- return 'string';
202
+ function getIDEPropsPropertyObj(target, propertyKey) {
203
+ if (!target.constructor.IDEProps) {
204
+ target.constructor.IDEProps = {};
259
205
  }
260
206
 
261
- if (type === Number) {
262
- return 'number';
207
+ if (!target.constructor.IDEProps[propertyKey]) {
208
+ target.constructor.IDEProps[propertyKey] = {};
263
209
  }
264
210
 
265
- if (type === Boolean) {
266
- return 'boolean';
267
- }
268
-
269
- return 'unknown';
211
+ var propertyObj = target.constructor.IDEProps[propertyKey];
212
+ return propertyObj;
270
213
  }
271
214
 
272
- function defineTypes(target, key, options, returnTypeFunction) {
273
- var type = Reflect.getMetadata('design:type', target, key);
274
- var isArray = type === Array;
275
- var str = transformBasicType(type);
276
-
277
- if (str !== 'unknown') {
278
- type = str;
279
- }
280
-
281
- if (returnTypeFunction) {
282
- var returnType = returnTypeFunction();
283
-
284
- if (Array.isArray(returnType)) {
285
- isArray = true;
286
- type = returnType[0];
287
- } else {
288
- type = returnType;
289
- }
290
- }
291
-
292
- var properties = Reflect.getMetadata(IDE_PROPERTY_METADATA, target.constructor) || {};
293
- properties[key] = _assign({
294
- type: type,
295
- isArray: isArray
296
- }, options);
297
- Reflect.defineMetadata(IDE_PROPERTY_METADATA, properties, target.constructor);
298
- }
299
-
300
- function getTypeDecoratorParams(returnTypeFuncOrOptions, maybeOptions) {
301
- if (typeof returnTypeFuncOrOptions === 'function') {
302
- return {
303
- returnTypeFunc: returnTypeFuncOrOptions,
304
- options: maybeOptions || {}
305
- };
306
- }
307
-
308
- return {
309
- options: returnTypeFuncOrOptions || {}
310
- };
311
- }
312
-
313
- function Field(returnTypeFunction, maybeOptions) {
215
+ function type(type) {
314
216
  return function (target, propertyKey) {
315
- if (typeof propertyKey === 'symbol') {
316
- throw new SymbolKeysNotSupportedError();
317
- }
318
-
319
- var _a = getTypeDecoratorParams(returnTypeFunction, maybeOptions),
320
- options = _a.options,
321
- returnTypeFunc = _a.returnTypeFunc;
322
-
323
- defineTypes(target, propertyKey, options, returnTypeFunc);
217
+ var prop = getIDEPropsPropertyObj(target, propertyKey);
218
+ prop.key = propertyKey;
219
+ prop.type = type;
324
220
  };
325
221
  }
326
222
 
327
- var ExecuteMode;
328
-
329
- (function (ExecuteMode) {
330
- ExecuteMode[ExecuteMode["Edit"] = 2] = "Edit";
331
- ExecuteMode[ExecuteMode["Game"] = 4] = "Game";
332
- ExecuteMode[ExecuteMode["All"] = 6] = "All";
333
- })(ExecuteMode || (ExecuteMode = {}));
334
-
335
223
  var Sprite$3 = function (_super) {
336
- __extends$1(Sprite, _super);
224
+ __extends(Sprite, _super);
337
225
 
338
226
  function Sprite() {
339
227
  var _this = _super !== null && _super.apply(this, arguments) || this;
@@ -352,94 +240,15 @@ var _EVA_IIFE_sprite = function (exports, eva_js, pluginRenderer, pixi_js) {
352
240
 
353
241
  Sprite.componentName = 'Sprite';
354
242
 
355
- __decorate([Field(), __metadata("design:type", String)], Sprite.prototype, "resource", void 0);
243
+ __decorate([type('string')], Sprite.prototype, "resource", void 0);
356
244
 
357
- __decorate([Field(), __metadata("design:type", String)], Sprite.prototype, "spriteName", void 0);
245
+ __decorate([type('string')], Sprite.prototype, "spriteName", void 0);
358
246
 
359
247
  return Sprite;
360
248
  }(eva_js.Component);
361
249
 
362
250
  var Sprite$4 = Sprite$3;
363
251
 
364
- var _extendStatics = function extendStatics(d, b) {
365
- _extendStatics = Object.setPrototypeOf || {
366
- __proto__: []
367
- } instanceof Array && function (d, b) {
368
- d.__proto__ = b;
369
- } || function (d, b) {
370
- for (var p in b) {
371
- if (b.hasOwnProperty(p)) d[p] = b[p];
372
- }
373
- };
374
-
375
- return _extendStatics(d, b);
376
- };
377
-
378
- function __extends(d, b) {
379
- _extendStatics(d, b);
380
-
381
- function __() {
382
- this.constructor = d;
383
- }
384
-
385
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
386
- }
387
-
388
- (function (_super) {
389
- __extends(Application, _super);
390
-
391
- function Application(params) {
392
- var _this = this;
393
-
394
- params.autoStart = false;
395
- _this = _super.call(this, params) || this;
396
- return _this;
397
- }
398
-
399
- return Application;
400
- })(pixi_js.Application);
401
-
402
- (function (_super) {
403
- __extends(Container, _super);
404
-
405
- function Container() {
406
- return _super !== null && _super.apply(this, arguments) || this;
407
- }
408
-
409
- return Container;
410
- })(pixi_js.Container);
411
-
412
- (function (_super) {
413
- __extends(Graphics, _super);
414
-
415
- function Graphics() {
416
- return _super !== null && _super.apply(this, arguments) || this;
417
- }
418
-
419
- return Graphics;
420
- })(pixi_js.Graphics);
421
-
422
- (function (_super) {
423
- __extends(NinePatch, _super);
424
-
425
- function NinePatch(img, leftWidth, topHeight, rightWidth, bottomHeight) {
426
- var _this = this;
427
-
428
- var texture;
429
-
430
- if (img === 'string') {
431
- texture = pixi_js.Texture.fromFrame(img);
432
- } else {
433
- texture = pixi_js.Texture.from(img);
434
- }
435
-
436
- _this = _super.call(this, texture, leftWidth, topHeight, rightWidth, bottomHeight) || this;
437
- return _this;
438
- }
439
-
440
- return NinePatch;
441
- })(pixi_js.mesh.NineSlicePlane);
442
-
443
252
  var Sprite$2 = function () {
444
253
  function Sprite(image) {
445
254
  this._image = null;
@@ -480,94 +289,7 @@ var _EVA_IIFE_sprite = function (exports, eva_js, pluginRenderer, pixi_js) {
480
289
  return Sprite;
481
290
  }();
482
291
 
483
- var Sprite$1$1 = Sprite$2;
484
-
485
- (function () {
486
- function SpriteAnimation(_a) {
487
- var frames = _a.frames;
488
- this.animatedSprite = new pixi_js.extras.AnimatedSprite(frames);
489
- }
490
-
491
- SpriteAnimation.prototype.play = function () {
492
- this.animatedSprite.play();
493
- };
494
-
495
- SpriteAnimation.prototype.stop = function () {
496
- this.animatedSprite.stop();
497
- };
498
-
499
- SpriteAnimation.prototype.gotoAndPlay = function (frameNumber) {
500
- this.animatedSprite.gotoAndPlay(frameNumber);
501
- };
502
-
503
- SpriteAnimation.prototype.gotoAndStop = function (frameNumber) {
504
- this.animatedSprite.gotoAndStop(frameNumber);
505
- };
506
-
507
- Object.defineProperty(SpriteAnimation.prototype, "speed", {
508
- get: function get() {
509
- return this.animatedSprite.animationSpeed;
510
- },
511
- set: function set(val) {
512
- this.animatedSprite.animationSpeed = val;
513
- },
514
- enumerable: false,
515
- configurable: true
516
- });
517
- return SpriteAnimation;
518
- })();
519
-
520
- (function (_super) {
521
- __extends(Text, _super);
522
-
523
- function Text(text, style) {
524
- return _super.call(this, text, style) || this;
525
- }
526
-
527
- return Text;
528
- })(pixi_js.Text);
529
-
530
- var PIXITilingSprite = pixi_js.extras.TilingSprite;
531
-
532
- (function () {
533
- function TilingSprite(image) {
534
- this._image = null;
535
- this._image = image;
536
-
537
- if (image) {
538
- if (image instanceof HTMLImageElement) {
539
- this.tilingSprite = new PIXITilingSprite(pixi_js.Texture.from(image));
540
- } else if (image instanceof pixi_js.Texture) {
541
- this.tilingSprite = new PIXITilingSprite(image);
542
- }
543
- } else {
544
- this.tilingSprite = new PIXITilingSprite(pixi_js.Texture.EMPTY);
545
- }
546
- }
547
-
548
- Object.defineProperty(TilingSprite.prototype, "image", {
549
- get: function get() {
550
- return this._image;
551
- },
552
- set: function set(val) {
553
- if (this._image === val) {
554
- return;
555
- }
556
-
557
- if (val instanceof HTMLImageElement) {
558
- this.tilingSprite.texture = pixi_js.Texture.from(val);
559
- } else if (val instanceof pixi_js.Texture) {
560
- this.tilingSprite.texture = val;
561
- }
562
-
563
- this._image = val;
564
- },
565
- enumerable: false,
566
- configurable: true
567
- });
568
- return TilingSprite;
569
- })();
570
-
292
+ var SpriteEngine = Sprite$2;
571
293
  var resourceKeySplit = '_s|r|c_';
572
294
  eva_js.resource.registerInstance(eva_js.RESOURCE_TYPE.SPRITE, function (_a) {
573
295
  var name = _a.name,
@@ -630,7 +352,7 @@ var _EVA_IIFE_sprite = function (exports, eva_js, pluginRenderer, pixi_js) {
630
352
  });
631
353
 
632
354
  var Sprite = function (_super) {
633
- __extends$1(Sprite, _super);
355
+ __extends(Sprite, _super);
634
356
 
635
357
  function Sprite() {
636
358
  var _this = _super !== null && _super.apply(this, arguments) || this;
@@ -666,7 +388,7 @@ var _EVA_IIFE_sprite = function (exports, eva_js, pluginRenderer, pixi_js) {
666
388
  gameObjectId = changed.gameObject.id;
667
389
  component = changed.component;
668
390
  if (!(changed.type === eva_js.OBSERVER_TYPE.ADD)) return [3, 2];
669
- sprite = new Sprite$1$1(null);
391
+ sprite = new SpriteEngine(null);
670
392
  this.sprites[changed.gameObject.id] = sprite;
671
393
  this.containerManager.getContainer(changed.gameObject.id).addChildAt(sprite.sprite, 0);
672
394
  asyncId = this.increaseAsyncId(gameObjectId);
@@ -1 +1 @@
1
- window.EVA=window.EVA||{},window.EVA.plugin=window.EVA.plugin||{},window.EVA.plugin.renderer=window.EVA.plugin.renderer||{};var _EVA_IIFE_sprite=function(e,t,r,n){"use strict";var i=function(e,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},i(e,t)};function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var a=function(){return a=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},a.apply(this,arguments)};function s(e,t,r,n){var i,o=arguments.length,a=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(a=(o<3?i(a):o>3?i(t,r,a):i(t,r))||a);return o>3&&a&&Object.defineProperty(t,r,a),a}function c(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function u(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{c(n.next(e))}catch(e){o(e)}}function s(e){try{c(n.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}c((n=n.apply(e,t||[])).next())}))}function p(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}function f(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}var l=function(e){function t(){var t=this.constructor,r=e.call(this,"Symbol keys are not supported yet!")||this;return Object.setPrototypeOf(r,t.prototype),r}return o(t,e),t}(Error);!function(e){function t(){var t=this.constructor,r=e.call(this,"getProperties is not a function!")||this;return Object.setPrototypeOf(r,t.prototype),r}o(t,e)}(Error);var h,y="IDE_PROPERTY_METADATA";function d(e,t,r,n){var i=Reflect.getMetadata("design:type",e,t),o=i===Array,s=function(e){return e===String?"string":e===Number?"number":e===Boolean?"boolean":"unknown"}(i);if("unknown"!==s&&(i=s),n){var c=n();Array.isArray(c)?(o=!0,i=c[0]):i=c}var u=Reflect.getMetadata(y,e.constructor)||{};u[t]=a({type:i,isArray:o},r),Reflect.defineMetadata(y,u,e.constructor)}function m(e,t){return function(r,n){if("symbol"==typeof n)throw new l;var i=function(e,t){return"function"==typeof e?{returnTypeFunc:e,options:t||{}}:{options:e||{}}}(e,t);d(r,n,i.options,i.returnTypeFunc)}}!function(e){e[e.Edit=2]="Edit",e[e.Game=4]="Game",e[e.All=6]="All"}(h||(h={}));var g=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.resource="",t.spriteName="",t}return o(t,e),t.prototype.init=function(e){e&&e.resource&&(this.resource=e.resource,this.spriteName=e.spriteName)},t.componentName="Sprite",s([m(),c("design:type",String)],t.prototype,"resource",void 0),s([m(),c("design:type",String)],t.prototype,"spriteName",void 0),t}(t.Component),b=g,v=function(e,t){return v=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},v(e,t)};function S(e,t){function r(){this.constructor=e}v(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}!function(e){function t(t){return t.autoStart=!1,e.call(this,t)||this}S(t,e)}(n.Application),function(e){function t(){return null!==e&&e.apply(this,arguments)||this}S(t,e)}(n.Container),function(e){function t(){return null!==e&&e.apply(this,arguments)||this}S(t,e)}(n.Graphics),function(e){function t(t,r,i,o,a){var s;return s="string"===t?n.Texture.fromFrame(t):n.Texture.from(t),e.call(this,s,r,i,o,a)||this}S(t,e)}(n.mesh.NineSlicePlane);var w=function(){function e(e){this._image=null,this._image=e,e?e instanceof HTMLImageElement?this.sprite=n.Sprite.from(e):e instanceof n.Texture&&(this.sprite=new n.Sprite(e)):this.sprite=new n.Sprite}return Object.defineProperty(e.prototype,"image",{get:function(){return this._image},set:function(e){this._image!==e&&(e instanceof HTMLImageElement?(this.sprite.texture&&this.sprite.texture.destroy(!1),this.sprite.texture=n.Texture.from(e)):e instanceof n.Texture&&(this.sprite.texture=e),this._image=e)},enumerable:!1,configurable:!0}),e}(),E=w;!function(){function e(e){var t=e.frames;this.animatedSprite=new n.extras.AnimatedSprite(t)}e.prototype.play=function(){this.animatedSprite.play()},e.prototype.stop=function(){this.animatedSprite.stop()},e.prototype.gotoAndPlay=function(e){this.animatedSprite.gotoAndPlay(e)},e.prototype.gotoAndStop=function(e){this.animatedSprite.gotoAndStop(e)},Object.defineProperty(e.prototype,"speed",{get:function(){return this.animatedSprite.animationSpeed},set:function(e){this.animatedSprite.animationSpeed=e},enumerable:!1,configurable:!0})}(),function(e){function t(t,r){return e.call(this,t,r)||this}S(t,e)}(n.Text);var O=n.extras.TilingSprite;!function(){function e(e){this._image=null,this._image=e,e?e instanceof HTMLImageElement?this.tilingSprite=new O(n.Texture.from(e)):e instanceof n.Texture&&(this.tilingSprite=new O(e)):this.tilingSprite=new O(n.Texture.EMPTY)}Object.defineProperty(e.prototype,"image",{get:function(){return this._image},set:function(e){this._image!==e&&(e instanceof HTMLImageElement?this.tilingSprite.texture=n.Texture.from(e):e instanceof n.Texture&&(this.tilingSprite.texture=e),this._image=e)},enumerable:!1,configurable:!0})}();var _="_s|r|c_";t.resource.registerInstance(t.RESOURCE_TYPE.SPRITE,(function(e){var t=e.name,r=e.data;return new Promise((function(e){var i,o,a=r.json,s=n.BaseTexture.from(r.image),c=a.frames||{},u=a.animations||{},p={};for(var l in c){p[t+_+l]=c[l]}for(var l in u){var h=[];if(u[l]&&u[l].length>=0)try{for(var y=(i=void 0,f(u[l])),d=y.next();!d.done;d=y.next()){var m=d.value,g=t+_+m;h.push(g)}}catch(e){i={error:e}}finally{try{d&&!d.done&&(o=y.return)&&o.call(y)}finally{if(i)throw i.error}}u[l]=h}a.frames=p;var b=new n.Spritesheet(s,a);b.parse((function(){var t=b.textures;e(t)}))}))})),t.resource.registerDestroy(t.RESOURCE_TYPE.SPRITE,(function(e){var t=e.instance;if(t)for(var r in t)t[r].destroy(!0)}));var A=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="Sprite",t.sprites={},t}return o(n,e),n.prototype.init=function(){this.renderSystem=this.game.getSystem(r.RendererSystem),this.renderSystem.rendererManager.register(this)},n.prototype.rendererUpdate=function(e){var t=e.transform.size,r=t.width,n=t.height;this.sprites[e.id]&&(this.sprites[e.id].sprite.width=r,this.sprites[e.id].sprite.height=n)},n.prototype.componentChanged=function(e){return u(this,void 0,void 0,(function(){var r,n,i,o,a;return p(this,(function(s){switch(s.label){case 0:return"Sprite"!==e.componentName?[3,5]:(r=e.gameObject.id,n=e.component,e.type!==t.OBSERVER_TYPE.ADD?[3,2]:(a=new E(null),this.sprites[e.gameObject.id]=a,this.containerManager.getContainer(e.gameObject.id).addChildAt(a.sprite,0),i=this.increaseAsyncId(r),[4,t.resource.getResource(n.resource)]));case 1:return o=s.sent().instance,this.validateAsyncId(r,i)?o?(a.image=o[n.resource+_+n.spriteName],[3,5]):(console.error("GameObject:"+e.gameObject.name+"'s Sprite resource load error"),[2]):[2];case 2:return e.type!==t.OBSERVER_TYPE.CHANGE?[3,4]:(i=this.increaseAsyncId(r),[4,t.resource.getResource(n.resource)]);case 3:return o=s.sent().instance,this.validateAsyncId(r,i)?o?(this.sprites[e.gameObject.id].image=o[n.resource+_+n.spriteName],[3,5]):(console.error("GameObject:"+e.gameObject.name+"'s Sprite resource load error"),[2]):[2];case 4:e.type===t.OBSERVER_TYPE.REMOVE&&(this.increaseAsyncId(r),a=this.sprites[e.gameObject.id],this.containerManager.getContainer(e.gameObject.id).removeChild(a.sprite),a.sprite.destroy({children:!0}),delete this.sprites[e.gameObject.id]),s.label=5;case 5:return[2]}}))}))},n.systemName="Sprite",n=s([t.decorators.componentObserver({Sprite:["spriteName"]})],n)}(r.Renderer),T=A;return e.Sprite=b,e.SpriteSystem=T,Object.defineProperty(e,"__esModule",{value:!0}),e}({},EVA,EVA.plugin.renderer,PIXI);window.EVA.plugin.renderer.sprite=window.EVA.plugin.renderer.sprite||_EVA_IIFE_sprite;
1
+ window.EVA=window.EVA||{},window.EVA.plugin=window.EVA.plugin||{},window.EVA.plugin.renderer=window.EVA.plugin.renderer||{};var _EVA_IIFE_sprite=function(e,t,r,n){"use strict";var i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};function o(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function s(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s}function a(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{c(n.next(e))}catch(e){o(e)}}function a(e){try{c(n.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))}function c(e,t){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}function u(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function p(e){return function(t,r){var n=function(e,t){return e.constructor.IDEProps||(e.constructor.IDEProps={}),e.constructor.IDEProps[t]||(e.constructor.IDEProps[t]={}),e.constructor.IDEProps[t]}(t,r);n.key=r,n.type=e}}var l=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.resource="",t.spriteName="",t}return o(t,e),t.prototype.init=function(e){e&&e.resource&&(this.resource=e.resource,this.spriteName=e.spriteName)},t.componentName="Sprite",s([p("string")],t.prototype,"resource",void 0),s([p("string")],t.prototype,"spriteName",void 0),t}(t.Component),f=function(){function e(e){this._image=null,this._image=e,e?e instanceof HTMLImageElement?this.sprite=n.Sprite.from(e):e instanceof n.Texture&&(this.sprite=new n.Sprite(e)):this.sprite=new n.Sprite}return Object.defineProperty(e.prototype,"image",{get:function(){return this._image},set:function(e){this._image!==e&&(e instanceof HTMLImageElement?(this.sprite.texture&&this.sprite.texture.destroy(!1),this.sprite.texture=n.Texture.from(e)):e instanceof n.Texture&&(this.sprite.texture=e),this._image=e)},enumerable:!1,configurable:!0}),e}(),d="_s|r|c_";t.resource.registerInstance(t.RESOURCE_TYPE.SPRITE,(function(e){var t=e.name,r=e.data;return new Promise((function(e){var i,o,s=r.json,a=n.BaseTexture.from(r.image),c=s.frames||{},p=s.animations||{},l={};for(var f in c){l[t+d+f]=c[f]}for(var f in p){var h=[];if(p[f]&&p[f].length>=0)try{for(var m=(i=void 0,u(p[f])),y=m.next();!y.done;y=m.next()){var g=y.value,v=t+d+g;h.push(v)}}catch(e){i={error:e}}finally{try{y&&!y.done&&(o=m.return)&&o.call(m)}finally{if(i)throw i.error}}p[f]=h}s.frames=l;var b=new n.Spritesheet(a,s);b.parse((function(){var t=b.textures;e(t)}))}))})),t.resource.registerDestroy(t.RESOURCE_TYPE.SPRITE,(function(e){var t=e.instance;if(t)for(var r in t)t[r].destroy(!0)}));var h=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="Sprite",t.sprites={},t}return o(n,e),n.prototype.init=function(){this.renderSystem=this.game.getSystem(r.RendererSystem),this.renderSystem.rendererManager.register(this)},n.prototype.rendererUpdate=function(e){var t=e.transform.size,r=t.width,n=t.height;this.sprites[e.id]&&(this.sprites[e.id].sprite.width=r,this.sprites[e.id].sprite.height=n)},n.prototype.componentChanged=function(e){return a(this,void 0,void 0,(function(){var r,n,i,o,s;return c(this,(function(a){switch(a.label){case 0:return"Sprite"!==e.componentName?[3,5]:(r=e.gameObject.id,n=e.component,e.type!==t.OBSERVER_TYPE.ADD?[3,2]:(s=new f(null),this.sprites[e.gameObject.id]=s,this.containerManager.getContainer(e.gameObject.id).addChildAt(s.sprite,0),i=this.increaseAsyncId(r),[4,t.resource.getResource(n.resource)]));case 1:return o=a.sent().instance,this.validateAsyncId(r,i)?o?(s.image=o[n.resource+d+n.spriteName],[3,5]):(console.error("GameObject:"+e.gameObject.name+"'s Sprite resource load error"),[2]):[2];case 2:return e.type!==t.OBSERVER_TYPE.CHANGE?[3,4]:(i=this.increaseAsyncId(r),[4,t.resource.getResource(n.resource)]);case 3:return o=a.sent().instance,this.validateAsyncId(r,i)?o?(this.sprites[e.gameObject.id].image=o[n.resource+d+n.spriteName],[3,5]):(console.error("GameObject:"+e.gameObject.name+"'s Sprite resource load error"),[2]):[2];case 4:e.type===t.OBSERVER_TYPE.REMOVE&&(this.increaseAsyncId(r),s=this.sprites[e.gameObject.id],this.containerManager.getContainer(e.gameObject.id).removeChild(s.sprite),s.sprite.destroy({children:!0}),delete this.sprites[e.gameObject.id]),a.label=5;case 5:return[2]}}))}))},n.systemName="Sprite",n=s([t.decorators.componentObserver({Sprite:["spriteName"]})],n)}(r.Renderer);return e.Sprite=l,e.SpriteSystem=h,Object.defineProperty(e,"__esModule",{value:!0}),e}({},EVA,EVA.plugin.renderer,PIXI);window.EVA.plugin.renderer.sprite=window.EVA.plugin.renderer.sprite||_EVA_IIFE_sprite;
@@ -43,10 +43,6 @@ function __decorate(decorators, target, key, desc) {
43
43
  return c > 3 && r && Object.defineProperty(target, key, r), r;
44
44
  }
45
45
 
46
- function __metadata(metadataKey, metadataValue) {
47
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
48
- }
49
-
50
46
  function __awaiter(thisArg, _arguments, P, generator) {
51
47
  return new (P || (P = Promise))(function (resolve, reject) {
52
48
  function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
@@ -111,12 +107,10 @@ var Sprite$3 = (function (_super) {
111
107
  };
112
108
  Sprite.componentName = 'Sprite';
113
109
  __decorate([
114
- inspectorDecorator.Field(),
115
- __metadata("design:type", String)
110
+ inspectorDecorator.type('string')
116
111
  ], Sprite.prototype, "resource", void 0);
117
112
  __decorate([
118
- inspectorDecorator.Field(),
119
- __metadata("design:type", String)
113
+ inspectorDecorator.type('string')
120
114
  ], Sprite.prototype, "spriteName", void 0);
121
115
  return Sprite;
122
116
  }(eva_js.Component));
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@eva/eva.js"),t=require("@eva/inspector-decorator"),r=require("@eva/plugin-renderer"),n=require("pixi.js"),i=function(e,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},i(e,t)};function o(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function s(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s}function a(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function c(e,t){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}function u(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}}var p=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.resource="",t.spriteName="",t}return o(r,e),r.prototype.init=function(e){e&&e.resource&&(this.resource=e.resource,this.spriteName=e.spriteName)},r.componentName="Sprite",s([t.Field(),a("design:type",String)],r.prototype,"resource",void 0),s([t.Field(),a("design:type",String)],r.prototype,"spriteName",void 0),r}(e.Component),l=p,f=function(){function e(e){this._image=null,this._image=e,e?e instanceof HTMLImageElement?this.sprite=n.Sprite.from(e):e instanceof n.Texture&&(this.sprite=new n.Sprite(e)):this.sprite=new n.Sprite}return Object.defineProperty(e.prototype,"image",{get:function(){return this._image},set:function(e){this._image!==e&&(e instanceof HTMLImageElement?(this.sprite.texture&&this.sprite.texture.destroy(!1),this.sprite.texture=n.Texture.from(e)):e instanceof n.Texture&&(this.sprite.texture=e),this._image=e)},enumerable:!1,configurable:!0}),e}(),h=f;e.resource.registerInstance(e.RESOURCE_TYPE.SPRITE,(function(e){var t=e.name,r=e.data;return new Promise((function(e){var i,o,s=r.json,a=n.BaseTexture.from(r.image),c=s.frames||{},p=s.animations||{},l={};for(var f in c){l[t+"_s|r|c_"+f]=c[f]}for(var f in p){var h=[];if(p[f]&&p[f].length>=0)try{for(var d=(i=void 0,u(p[f])),m=d.next();!m.done;m=d.next()){var y=m.value,g=t+"_s|r|c_"+y;h.push(g)}}catch(e){i={error:e}}finally{try{m&&!m.done&&(o=d.return)&&o.call(d)}finally{if(i)throw i.error}}p[f]=h}s.frames=l;var v=new n.Spritesheet(a,s);v.parse((function(){var t=v.textures;e(t)}))}))})),e.resource.registerDestroy(e.RESOURCE_TYPE.SPRITE,(function(e){var t=e.instance;if(t)for(var r in t)t[r].destroy(!0)}));var d=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="Sprite",e.sprites={},e}return o(n,t),n.prototype.init=function(){this.renderSystem=this.game.getSystem(r.RendererSystem),this.renderSystem.rendererManager.register(this)},n.prototype.rendererUpdate=function(e){var t=e.transform.size,r=t.width,n=t.height;this.sprites[e.id]&&(this.sprites[e.id].sprite.width=r,this.sprites[e.id].sprite.height=n)},n.prototype.componentChanged=function(t){return r=this,n=void 0,o=function(){var r,n,i,o,s;return c(this,(function(a){switch(a.label){case 0:return"Sprite"!==t.componentName?[3,5]:(r=t.gameObject.id,n=t.component,t.type!==e.OBSERVER_TYPE.ADD?[3,2]:(s=new h(null),this.sprites[t.gameObject.id]=s,this.containerManager.getContainer(t.gameObject.id).addChildAt(s.sprite,0),i=this.increaseAsyncId(r),[4,e.resource.getResource(n.resource)]));case 1:return o=a.sent().instance,this.validateAsyncId(r,i)?o?(s.image=o[n.resource+"_s|r|c_"+n.spriteName],[3,5]):(console.error("GameObject:"+t.gameObject.name+"'s Sprite resource load error"),[2]):[2];case 2:return t.type!==e.OBSERVER_TYPE.CHANGE?[3,4]:(i=this.increaseAsyncId(r),[4,e.resource.getResource(n.resource)]);case 3:return o=a.sent().instance,this.validateAsyncId(r,i)?o?(this.sprites[t.gameObject.id].image=o[n.resource+"_s|r|c_"+n.spriteName],[3,5]):(console.error("GameObject:"+t.gameObject.name+"'s Sprite resource load error"),[2]):[2];case 4:t.type===e.OBSERVER_TYPE.REMOVE&&(this.increaseAsyncId(r),s=this.sprites[t.gameObject.id],this.containerManager.getContainer(t.gameObject.id).removeChild(s.sprite),s.sprite.destroy({children:!0}),delete this.sprites[t.gameObject.id]),a.label=5;case 5:return[2]}}))},new((i=void 0)||(i=Promise))((function(e,t){function s(e){try{c(o.next(e))}catch(e){t(e)}}function a(e){try{c(o.throw(e))}catch(e){t(e)}}function c(t){t.done?e(t.value):new i((function(e){e(t.value)})).then(s,a)}c((o=o.apply(r,n||[])).next())}));var r,n,i,o},n.systemName="Sprite",n=s([e.decorators.componentObserver({Sprite:["spriteName"]})],n)}(r.Renderer);exports.Sprite=l,exports.SpriteSystem=d;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@eva/eva.js"),t=require("@eva/inspector-decorator"),r=require("@eva/plugin-renderer"),n=require("pixi.js"),i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};function o(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function s(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s}function a(e,t){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}function c(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}}var u=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.resource="",t.spriteName="",t}return o(r,e),r.prototype.init=function(e){e&&e.resource&&(this.resource=e.resource,this.spriteName=e.spriteName)},r.componentName="Sprite",s([t.type("string")],r.prototype,"resource",void 0),s([t.type("string")],r.prototype,"spriteName",void 0),r}(e.Component),p=function(){function e(e){this._image=null,this._image=e,e?e instanceof HTMLImageElement?this.sprite=n.Sprite.from(e):e instanceof n.Texture&&(this.sprite=new n.Sprite(e)):this.sprite=new n.Sprite}return Object.defineProperty(e.prototype,"image",{get:function(){return this._image},set:function(e){this._image!==e&&(e instanceof HTMLImageElement?(this.sprite.texture&&this.sprite.texture.destroy(!1),this.sprite.texture=n.Texture.from(e)):e instanceof n.Texture&&(this.sprite.texture=e),this._image=e)},enumerable:!1,configurable:!0}),e}();e.resource.registerInstance(e.RESOURCE_TYPE.SPRITE,(function(e){var t=e.name,r=e.data;return new Promise((function(e){var i,o,s=r.json,a=n.BaseTexture.from(r.image),u=s.frames||{},p=s.animations||{},l={};for(var f in u){l[t+"_s|r|c_"+f]=u[f]}for(var f in p){var h=[];if(p[f]&&p[f].length>=0)try{for(var m=(i=void 0,c(p[f])),d=m.next();!d.done;d=m.next()){var y=d.value,g=t+"_s|r|c_"+y;h.push(g)}}catch(e){i={error:e}}finally{try{d&&!d.done&&(o=m.return)&&o.call(m)}finally{if(i)throw i.error}}p[f]=h}s.frames=l;var v=new n.Spritesheet(a,s);v.parse((function(){var t=v.textures;e(t)}))}))})),e.resource.registerDestroy(e.RESOURCE_TYPE.SPRITE,(function(e){var t=e.instance;if(t)for(var r in t)t[r].destroy(!0)}));var l=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="Sprite",e.sprites={},e}return o(n,t),n.prototype.init=function(){this.renderSystem=this.game.getSystem(r.RendererSystem),this.renderSystem.rendererManager.register(this)},n.prototype.rendererUpdate=function(e){var t=e.transform.size,r=t.width,n=t.height;this.sprites[e.id]&&(this.sprites[e.id].sprite.width=r,this.sprites[e.id].sprite.height=n)},n.prototype.componentChanged=function(t){return r=this,n=void 0,o=function(){var r,n,i,o,s;return a(this,(function(a){switch(a.label){case 0:return"Sprite"!==t.componentName?[3,5]:(r=t.gameObject.id,n=t.component,t.type!==e.OBSERVER_TYPE.ADD?[3,2]:(s=new p(null),this.sprites[t.gameObject.id]=s,this.containerManager.getContainer(t.gameObject.id).addChildAt(s.sprite,0),i=this.increaseAsyncId(r),[4,e.resource.getResource(n.resource)]));case 1:return o=a.sent().instance,this.validateAsyncId(r,i)?o?(s.image=o[n.resource+"_s|r|c_"+n.spriteName],[3,5]):(console.error("GameObject:"+t.gameObject.name+"'s Sprite resource load error"),[2]):[2];case 2:return t.type!==e.OBSERVER_TYPE.CHANGE?[3,4]:(i=this.increaseAsyncId(r),[4,e.resource.getResource(n.resource)]);case 3:return o=a.sent().instance,this.validateAsyncId(r,i)?o?(this.sprites[t.gameObject.id].image=o[n.resource+"_s|r|c_"+n.spriteName],[3,5]):(console.error("GameObject:"+t.gameObject.name+"'s Sprite resource load error"),[2]):[2];case 4:t.type===e.OBSERVER_TYPE.REMOVE&&(this.increaseAsyncId(r),s=this.sprites[t.gameObject.id],this.containerManager.getContainer(t.gameObject.id).removeChild(s.sprite),s.sprite.destroy({children:!0}),delete this.sprites[t.gameObject.id]),a.label=5;case 5:return[2]}}))},new((i=void 0)||(i=Promise))((function(e,t){function s(e){try{c(o.next(e))}catch(e){t(e)}}function a(e){try{c(o.throw(e))}catch(e){t(e)}}function c(t){t.done?e(t.value):new i((function(e){e(t.value)})).then(s,a)}c((o=o.apply(r,n||[])).next())}));var r,n,i,o},n.systemName="Sprite",n=s([e.decorators.componentObserver({Sprite:["spriteName"]})],n)}(r.Renderer);exports.Sprite=u,exports.SpriteSystem=l;
@@ -1,5 +1,5 @@
1
1
  import { Component, resource, RESOURCE_TYPE, decorators, OBSERVER_TYPE } from '@eva/eva.js';
2
- import { Field } from '@eva/inspector-decorator';
2
+ import { type } from '@eva/inspector-decorator';
3
3
  import { RendererSystem, Renderer } from '@eva/plugin-renderer';
4
4
  import { Texture, Sprite as Sprite$5, BaseTexture, Spritesheet } from 'pixi.js';
5
5
 
@@ -39,10 +39,6 @@ function __decorate(decorators, target, key, desc) {
39
39
  return c > 3 && r && Object.defineProperty(target, key, r), r;
40
40
  }
41
41
 
42
- function __metadata(metadataKey, metadataValue) {
43
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
44
- }
45
-
46
42
  function __awaiter(thisArg, _arguments, P, generator) {
47
43
  return new (P || (P = Promise))(function (resolve, reject) {
48
44
  function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
@@ -107,12 +103,10 @@ var Sprite$3 = (function (_super) {
107
103
  };
108
104
  Sprite.componentName = 'Sprite';
109
105
  __decorate([
110
- Field(),
111
- __metadata("design:type", String)
106
+ type('string')
112
107
  ], Sprite.prototype, "resource", void 0);
113
108
  __decorate([
114
- Field(),
115
- __metadata("design:type", String)
109
+ type('string')
116
110
  ], Sprite.prototype, "spriteName", void 0);
117
111
  return Sprite;
118
112
  }(Component));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eva/plugin-renderer-sprite",
3
- "version": "1.2.7-editor.7",
3
+ "version": "1.2.8-fix.1",
4
4
  "description": "@eva/plugin-renderer-sprite",
5
5
  "main": "index.js",
6
6
  "module": "dist/plugin-renderer-sprite.esm.js",
@@ -18,9 +18,9 @@
18
18
  "license": "MIT",
19
19
  "homepage": "https://eva.js.org",
20
20
  "dependencies": {
21
- "@eva/inspector-decorator": "0.1.0-alpha.2",
22
- "@eva/plugin-renderer": "1.2.7-editor.7",
23
- "@eva/eva.js": "1.2.7-editor.7",
21
+ "@eva/inspector-decorator": "^0.0.5",
22
+ "@eva/plugin-renderer": "1.2.8-fix.1",
23
+ "@eva/eva.js": "1.2.8-fix.1",
24
24
  "pixi.js": "^4.8.7"
25
25
  }
26
26
  }
@@ -1,197 +0,0 @@
1
- import { __extends, __decorate, __metadata, __values, __awaiter, __generator } from 'tslib';
2
- import { Component, resource, RESOURCE_TYPE, OBSERVER_TYPE, decorators } from '@eva/eva.js/dist/miniprogram';
3
- import { Field } from '@eva/inspector-decorator';
4
- import { RendererSystem, Renderer } from '@eva/plugin-renderer/dist/miniprogram';
5
- import { Sprite as Sprite$4 } from '@eva/renderer-adapter/dist/miniprogram';
6
- import { BaseTexture, Spritesheet } from '@eva/miniprogram-pixi';
7
-
8
- var Sprite$2 = function (_super) {
9
- __extends(Sprite, _super);
10
-
11
- function Sprite() {
12
- var _this = _super !== null && _super.apply(this, arguments) || this;
13
-
14
- _this.resource = '';
15
- _this.spriteName = '';
16
- return _this;
17
- }
18
-
19
- Sprite.prototype.init = function (obj) {
20
- if (obj && obj.resource) {
21
- this.resource = obj.resource;
22
- this.spriteName = obj.spriteName;
23
- }
24
- };
25
-
26
- Sprite.componentName = 'Sprite';
27
-
28
- __decorate([Field(), __metadata("design:type", String)], Sprite.prototype, "resource", void 0);
29
-
30
- __decorate([Field(), __metadata("design:type", String)], Sprite.prototype, "spriteName", void 0);
31
-
32
- return Sprite;
33
- }(Component);
34
-
35
- var Sprite$3 = Sprite$2;
36
- var resourceKeySplit = '_s|r|c_';
37
- resource.registerInstance(RESOURCE_TYPE.SPRITE, function (_a) {
38
- var name = _a.name,
39
- data = _a.data;
40
- return new Promise(function (r) {
41
- var e_1, _a;
42
-
43
- var textureObj = data.json;
44
- var texture = BaseTexture.from(data.image);
45
- var frames = textureObj.frames || {};
46
- var animations = textureObj.animations || {};
47
- var newFrames = {};
48
-
49
- for (var key in frames) {
50
- var newKey = name + resourceKeySplit + key;
51
- newFrames[newKey] = frames[key];
52
- }
53
-
54
- for (var key in animations) {
55
- var spriteList = [];
56
-
57
- if (animations[key] && animations[key].length >= 0) {
58
- try {
59
- for (var _b = (e_1 = void 0, __values(animations[key])), _c = _b.next(); !_c.done; _c = _b.next()) {
60
- var spriteName = _c.value;
61
- var newSpriteName = name + resourceKeySplit + spriteName;
62
- spriteList.push(newSpriteName);
63
- }
64
- } catch (e_1_1) {
65
- e_1 = {
66
- error: e_1_1
67
- };
68
- } finally {
69
- try {
70
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
71
- } finally {
72
- if (e_1) throw e_1.error;
73
- }
74
- }
75
- }
76
-
77
- animations[key] = spriteList;
78
- }
79
-
80
- textureObj.frames = newFrames;
81
- var spriteSheet = new Spritesheet(texture, textureObj);
82
- spriteSheet.parse(function () {
83
- var textures = spriteSheet.textures;
84
- r(textures);
85
- });
86
- });
87
- });
88
- resource.registerDestroy(RESOURCE_TYPE.SPRITE, function (_a) {
89
- var instance = _a.instance;
90
- if (!instance) return;
91
-
92
- for (var key in instance) {
93
- instance[key].destroy(true);
94
- }
95
- });
96
-
97
- var Sprite = function (_super) {
98
- __extends(Sprite, _super);
99
-
100
- function Sprite() {
101
- var _this = _super !== null && _super.apply(this, arguments) || this;
102
-
103
- _this.name = 'Sprite';
104
- _this.sprites = {};
105
- return _this;
106
- }
107
-
108
- Sprite.prototype.init = function () {
109
- this.renderSystem = this.game.getSystem(RendererSystem);
110
- this.renderSystem.rendererManager.register(this);
111
- };
112
-
113
- Sprite.prototype.rendererUpdate = function (gameObject) {
114
- var _a = gameObject.transform.size,
115
- width = _a.width,
116
- height = _a.height;
117
-
118
- if (this.sprites[gameObject.id]) {
119
- this.sprites[gameObject.id].sprite.width = width;
120
- this.sprites[gameObject.id].sprite.height = height;
121
- }
122
- };
123
-
124
- Sprite.prototype.componentChanged = function (changed) {
125
- return __awaiter(this, void 0, void 0, function () {
126
- var gameObjectId, component, sprite, asyncId, instance, asyncId, instance, sprite;
127
- return __generator(this, function (_a) {
128
- switch (_a.label) {
129
- case 0:
130
- if (!(changed.componentName === 'Sprite')) return [3, 5];
131
- gameObjectId = changed.gameObject.id;
132
- component = changed.component;
133
- if (!(changed.type === OBSERVER_TYPE.ADD)) return [3, 2];
134
- sprite = new Sprite$4(null);
135
- this.sprites[changed.gameObject.id] = sprite;
136
- this.containerManager.getContainer(changed.gameObject.id).addChildAt(sprite.sprite, 0);
137
- asyncId = this.increaseAsyncId(gameObjectId);
138
- return [4, resource.getResource(component.resource)];
139
-
140
- case 1:
141
- instance = _a.sent().instance;
142
- if (!this.validateAsyncId(gameObjectId, asyncId)) return [2];
143
-
144
- if (!instance) {
145
- console.error("GameObject:" + changed.gameObject.name + "'s Sprite resource load error");
146
- return [2];
147
- }
148
-
149
- sprite.image = instance[component.resource + resourceKeySplit + component.spriteName];
150
- return [3, 5];
151
-
152
- case 2:
153
- if (!(changed.type === OBSERVER_TYPE.CHANGE)) return [3, 4];
154
- asyncId = this.increaseAsyncId(gameObjectId);
155
- return [4, resource.getResource(component.resource)];
156
-
157
- case 3:
158
- instance = _a.sent().instance;
159
- if (!this.validateAsyncId(gameObjectId, asyncId)) return [2];
160
-
161
- if (!instance) {
162
- console.error("GameObject:" + changed.gameObject.name + "'s Sprite resource load error");
163
- return [2];
164
- }
165
-
166
- this.sprites[changed.gameObject.id].image = instance[component.resource + resourceKeySplit + component.spriteName];
167
- return [3, 5];
168
-
169
- case 4:
170
- if (changed.type === OBSERVER_TYPE.REMOVE) {
171
- this.increaseAsyncId(gameObjectId);
172
- sprite = this.sprites[changed.gameObject.id];
173
- this.containerManager.getContainer(changed.gameObject.id).removeChild(sprite.sprite);
174
- sprite.sprite.destroy({
175
- children: true
176
- });
177
- delete this.sprites[changed.gameObject.id];
178
- }
179
-
180
- _a.label = 5;
181
-
182
- case 5:
183
- return [2];
184
- }
185
- });
186
- });
187
- };
188
-
189
- Sprite.systemName = 'Sprite';
190
- Sprite = __decorate([decorators.componentObserver({
191
- Sprite: ['spriteName']
192
- })], Sprite);
193
- return Sprite;
194
- }(Renderer);
195
-
196
- var Sprite$1 = Sprite;
197
- export { Sprite$3 as Sprite, Sprite$1 as SpriteSystem };