@eva/spine-base 1.2.7-editor.10 → 1.2.7-editor.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.
@@ -32,22 +32,6 @@ var _EVA_IIFE_spineBase = function (exports, eva_js, pluginRenderer, pixi_js) {
32
32
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
33
33
  }
34
34
 
35
- var _assign = function __assign() {
36
- _assign = Object.assign || function __assign(t) {
37
- for (var s, i = 1, n = arguments.length; i < n; i++) {
38
- s = arguments[i];
39
-
40
- for (var p in s) {
41
- if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
42
- }
43
- }
44
-
45
- return t;
46
- };
47
-
48
- return _assign.apply(this, arguments);
49
- };
50
-
51
35
  function __decorate(decorators, target, key, desc) {
52
36
  var c = arguments.length,
53
37
  r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
@@ -58,10 +42,6 @@ var _EVA_IIFE_spineBase = function (exports, eva_js, pluginRenderer, pixi_js) {
58
42
  return c > 3 && r && Object.defineProperty(target, key, r), r;
59
43
  }
60
44
 
61
- function __metadata(metadataKey, metadataValue) {
62
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
63
- }
64
-
65
45
  function __awaiter(thisArg, _arguments, P, generator) {
66
46
  function adopt(value) {
67
47
  return value instanceof P ? value : new P(function (resolve) {
@@ -222,123 +202,6 @@ var _EVA_IIFE_spineBase = function (exports, eva_js, pluginRenderer, pixi_js) {
222
202
  throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
223
203
  }
224
204
 
225
- var SymbolKeysNotSupportedError = function (_super) {
226
- __extends(SymbolKeysNotSupportedError, _super);
227
-
228
- function SymbolKeysNotSupportedError() {
229
- var _newTarget = this.constructor;
230
-
231
- var _this = _super.call(this, 'Symbol keys are not supported yet!') || this;
232
-
233
- Object.setPrototypeOf(_this, _newTarget.prototype);
234
- return _this;
235
- }
236
-
237
- return SymbolKeysNotSupportedError;
238
- }(Error);
239
-
240
- (function (_super) {
241
- __extends(StaticGetPropertiesIsNotAFunctionError, _super);
242
-
243
- function StaticGetPropertiesIsNotAFunctionError() {
244
- var _newTarget = this.constructor;
245
-
246
- var _this = _super.call(this, 'getProperties is not a function!') || this;
247
-
248
- Object.setPrototypeOf(_this, _newTarget.prototype);
249
- return _this;
250
- }
251
-
252
- return StaticGetPropertiesIsNotAFunctionError;
253
- })(Error);
254
-
255
- var IDE_PROPERTY_METADATA = 'IDE_PROPERTY_METADATA';
256
-
257
- function transformBasicType(type) {
258
- if (type === String) {
259
- return 'string';
260
- }
261
-
262
- if (type === Number) {
263
- return 'number';
264
- }
265
-
266
- if (type === Boolean) {
267
- return 'boolean';
268
- }
269
-
270
- return 'unknown';
271
- }
272
-
273
- function defineTypes(target, key, options, returnTypeFunction) {
274
- var type = Reflect.getMetadata('design:type', target, key);
275
- var isArray = type === Array;
276
- var str = transformBasicType(type);
277
-
278
- if (str !== 'unknown') {
279
- type = str;
280
- }
281
-
282
- if (returnTypeFunction) {
283
- var returnType = returnTypeFunction();
284
-
285
- if (Array.isArray(returnType)) {
286
- isArray = true;
287
- type = returnType[0];
288
- } else {
289
- type = returnType;
290
- }
291
- }
292
-
293
- var properties = Reflect.getMetadata(IDE_PROPERTY_METADATA, target.constructor) || {};
294
- properties[key] = _assign({
295
- type: type,
296
- isArray: isArray
297
- }, options);
298
- Reflect.defineMetadata(IDE_PROPERTY_METADATA, properties, target.constructor);
299
- }
300
-
301
- function getTypeDecoratorParams(returnTypeFuncOrOptions, maybeOptions) {
302
- if (typeof returnTypeFuncOrOptions === 'function') {
303
- return {
304
- returnTypeFunc: returnTypeFuncOrOptions,
305
- options: maybeOptions || {}
306
- };
307
- }
308
-
309
- return {
310
- options: returnTypeFuncOrOptions || {}
311
- };
312
- }
313
-
314
- function Field(returnTypeFunction, maybeOptions) {
315
- return function (target, propertyKey) {
316
- if (typeof propertyKey === 'symbol') {
317
- throw new SymbolKeysNotSupportedError();
318
- }
319
-
320
- var _a = getTypeDecoratorParams(returnTypeFunction, maybeOptions),
321
- options = _a.options,
322
- returnTypeFunc = _a.returnTypeFunc;
323
-
324
- defineTypes(target, propertyKey, options, returnTypeFunc);
325
- };
326
- }
327
-
328
- var ExecuteMode;
329
-
330
- (function (ExecuteMode) {
331
- ExecuteMode[ExecuteMode["Edit"] = 2] = "Edit";
332
- ExecuteMode[ExecuteMode["Game"] = 4] = "Game";
333
- ExecuteMode[ExecuteMode["All"] = 6] = "All";
334
- })(ExecuteMode || (ExecuteMode = {}));
335
-
336
- var sleep = function sleep(time) {
337
- return new Promise(function (resolve) {
338
- return setTimeout(resolve, time);
339
- });
340
- };
341
-
342
205
  var Spine = function (_super) {
343
206
  __extends(Spine, _super);
344
207
 
@@ -503,49 +366,6 @@ var _EVA_IIFE_spineBase = function (exports, eva_js, pluginRenderer, pixi_js) {
503
366
  };
504
367
 
505
368
  Spine.componentName = 'Spine';
506
-
507
- __decorate([Field({
508
- type: 'resource'
509
- }), __metadata("design:type", String)], Spine.prototype, "resource", void 0);
510
-
511
- __decorate([Field({
512
- type: 'selector',
513
- options: function options(that) {
514
- var _a, _b, _c;
515
-
516
- return __awaiter(this, void 0, void 0, function () {
517
- var animations;
518
- return __generator(this, function (_d) {
519
- switch (_d.label) {
520
- case 0:
521
- return [4, sleep(0)];
522
-
523
- case 1:
524
- _d.sent();
525
-
526
- if (!that.resource || !eva_js.resource.promiseMap[that.resource]) {
527
- return [2, {}];
528
- }
529
-
530
- return [4, eva_js.resource.promiseMap[that.resource]];
531
-
532
- case 2:
533
- _d.sent();
534
-
535
- animations = (_c = (_b = (_a = eva_js.resource.resourcesMap[that.resource]) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.ske) === null || _c === void 0 ? void 0 : _c.animations;
536
- return [2, animations ? Object.keys(animations).reduce(function (prev, key) {
537
- var _a;
538
-
539
- return _assign(_assign({}, prev), (_a = {}, _a[key] = key, _a));
540
- }, {}) : {}];
541
- }
542
- });
543
- });
544
- }
545
- }), __metadata("design:type", String)], Spine.prototype, "animationName", void 0);
546
-
547
- __decorate([Field(), __metadata("design:type", Boolean)], Spine.prototype, "autoPlay", void 0);
548
-
549
369
  return Spine;
550
370
  }(eva_js.Component);
551
371
 
@@ -1 +1 @@
1
- function _extends(){return _extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},_extends.apply(this,arguments)}window.EVA=window.EVA||{},window.EVA.plugin=window.EVA.plugin||{};var _EVA_IIFE_spineBase=function(e,t,n,r){"use strict";var o=function(e,t){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},o(e,t)};function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var a=function(){return a=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},a.apply(this,arguments)};function s(e,t,n,r){var o,i=arguments.length,a=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}function u(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function c(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))}function p(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}var l=function(e){function t(){var t=this.constructor,n=e.call(this,"Symbol keys are not supported yet!")||this;return Object.setPrototypeOf(n,t.prototype),n}return i(t,e),t}(Error);!function(e){function t(){var t=this.constructor,n=e.call(this,"getProperties is not a function!")||this;return Object.setPrototypeOf(n,t.prototype),n}i(t,e)}(Error);var f,m="IDE_PROPERTY_METADATA";function d(e,t,n,r){var o=Reflect.getMetadata("design:type",e,t),i=o===Array,s=function(e){return e===String?"string":e===Number?"number":e===Boolean?"boolean":"unknown"}(o);if("unknown"!==s&&(o=s),r){var u=r();Array.isArray(u)?(i=!0,o=u[0]):o=u}var c=Reflect.getMetadata(m,e.constructor)||{};c[t]=a({type:o,isArray:i},n),Reflect.defineMetadata(m,c,e.constructor)}function y(e,t){return function(n,r){if("symbol"==typeof r)throw new l;var o=function(e,t){return"function"==typeof e?{returnTypeFunc:e,options:t||{}}:{options:e||{}}}(e,t);d(n,r,o.options,o.returnTypeFunc)}}!function(e){e[e.Edit=2]="Edit",e[e.Game=4]="Game",e[e.All=6]="All"}(f||(f={}));var h=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.resource="",t.animationName="",t.autoPlay=!0,t.waitExecuteInfos=[],t}return i(n,e),Object.defineProperty(n.prototype,"armature",{get:function(){return this._armature},set:function(e){var t,n;if(this._armature=e,e){this.autoPlay&&this.play(this.animationName);try{for(var r=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(this.waitExecuteInfos),o=r.next();!o.done;o=r.next()){var i=o.value;if(i.playType){var a=i.name,s=i.loop,u=i.track;this.play(a,s,u)}else this.stop(i.track)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}this.waitExecuteInfos=[]}},enumerable:!1,configurable:!0}),n.prototype.init=function(e){e&&_extends(this,e)},n.prototype.onDestroy=function(){this.destroied=!0},n.prototype.play=function(e,t,n){try{e&&(this.animationName=e),this.armature?(void 0===n&&(n=0),this.armature.state.setAnimation(n,this.animationName,t)):this.waitExecuteInfos.push({playType:!0,name:e,loop:null!=t?t:this.autoPlay,track:n})}catch(e){console.log(e)}},n.prototype.stop=function(e){this.armature?(void 0===e&&(e=0),this.armature.state.setEmptyAnimation(e,0)):this.waitExecuteInfos.push({playType:!1,track:e})},n.prototype.addAnimation=function(e,t,n,r){try{this.armature&&(void 0===r&&(r=0),this.armature.state.addAnimation(r,e,n,t))}catch(e){console.log(e)}},n.prototype.setMix=function(e,t,n){this.armature&&this.armature.stateData.setMix(e,t,n)},n.prototype.getAnim=function(e){void 0===e&&(e=0);try{if(this.armature)return this.armature.state.tracks[e].animation.name}catch(e){console.log(e)}},n.prototype.setDefaultMix=function(e){this.armature&&(this.armature.stateData.defaultMix=e)},n.prototype.setAttachment=function(e,t){this.armature&&this.armature.skeleton.setAttachment(e,t)},n.prototype.getBone=function(e){if(this.armature)return this.armature.skeleton.findBone(e)},n.componentName="Spine",s([y({type:"resource"}),u("design:type",String)],n.prototype,"resource",void 0),s([y({type:"selector",options:function(e){var n,r,o;return c(this,void 0,void 0,(function(){var i;return p(this,(function(s){switch(s.label){case 0:return[4,(u=0,new Promise((function(e){return setTimeout(e,u)})))];case 1:return s.sent(),e.resource&&t.resource.promiseMap[e.resource]?[4,t.resource.promiseMap[e.resource]]:[2,{}];case 2:return s.sent(),[2,(i=null===(o=null===(r=null===(n=t.resource.resourcesMap[e.resource])||void 0===n?void 0:n.data)||void 0===r?void 0:r.ske)||void 0===o?void 0:o.animations)?Object.keys(i).reduce((function(e,t){var n;return a(a({},e),((n={})[t]=t,n))}),{}):{}]}var u}))}))}}),u("design:type",String)],n.prototype,"animationName",void 0),s([y(),u("design:type",Boolean)],n.prototype,"autoPlay",void 0),n}(t.Component),v=h,g={};function b(e){var t=e.image;return{tex:r.Texture.from(t),count:0}}var E={};function w(e,t,n,r){var o=null,i=function(e,t){var n=g[e];return n||(n=b(t),g[e]=n),n.tex}(t.image.src,t);new r.core.TextureAtlas(t.atlas,(function(e,t){t(i.baseTexture)}),(function(e){if(e){var i=new r.core.AtlasAttachmentLoader(e),a=new r.core.SkeletonJson(i);n&&(a.scale=n),o=a.readSkeletonData(t.ske)}}));var a={spineData:o,ref:0,imageSrc:t.image.src};return E[e]=a,a}function O(e,t){return c(this,void 0,void 0,(function(){var n;return p(this,(function(r){if(!(n=E[e.name]))if(e.complete)n=w(e.name,e.data,e.scale,t);else if(!n)return[2];return function(e,t){var n=g[e];n||(n=b(t),g[e]=n),n.count++,n.tex}(e.data.image.src,e.data),n.ref++,[2,n.spineData]}))}))}function x(e,t){var n=E[e];n&&(n.ref--,n.ref<=0&&(!function(e){e&&setTimeout((function(){var t=g[e];t&&(t.count--,t.count<=0&&(t.tex&&(t.tex.destroy(!0),t.tex=null),delete g[e]))}),100)}(t),delete E[e]))}var A=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.armatures={},t}return i(r,e),r.prototype.init=function(e){var r=this,o=e.pixiSpine;this.renderSystem=this.game.getSystem(n.RendererSystem),this.renderSystem.rendererManager.register(this),this.pixiSpine=o,this.game.canvas.addEventListener("webglcontextrestored",(function(){var e=r.game.gameObjects,n=[];for(var o in r.armatures)for(var i=+o,a=0;a<e.length;++a){var s=e[a];if(s.id===i){var u=s.getComponent(v);u&&(r.remove({type:t.OBSERVER_TYPE.REMOVE,gameObject:s,component:u,componentName:v.componentName}),n.push({type:t.OBSERVER_TYPE.ADD,gameObject:s,component:u,componentName:v.componentName}));break}}setTimeout((function(){n.forEach((function(e){r.add(e)}))}),1e3)}),!1)},r.prototype.update=function(t){for(var n in this.armatures)this.armatures[n].update(.001*t.deltaTime),this.armatures[n].updateTransform();e.prototype.update.call(this)},r.prototype.componentChanged=function(e){return c(this,void 0,void 0,(function(){return p(this,(function(n){if("Spine"===e.componentName)if(e.type===t.OBSERVER_TYPE.ADD)this.add(e);else if(e.type===t.OBSERVER_TYPE.CHANGE){if("resource"===e.prop.prop[0])this.change(e)}else e.type===t.OBSERVER_TYPE.REMOVE&&this.remove(e);return[2]}))}))},r.prototype.add=function(e,n){var r,o;return c(this,void 0,void 0,(function(){var i,a,s,u,c,l,f,m,d=this;return p(this,(function(p){switch(p.label){case 0:return i=e.component,clearTimeout(i.addHandler),a=e.gameObject.id,s=this.increaseAsyncId(a),[4,t.resource.getResource(i.resource)];case 1:return u=p.sent(),this.validateAsyncId(a,s)?[4,O(u,this.pixiSpine)]:[2];case 2:return c=p.sent(),this.validateAsyncId(a,s)?c?(this.remove(e),(l=null===(o=null===(r=this.renderSystem)||void 0===r?void 0:r.containerManager)||void 0===o?void 0:o.getContainer(e.gameObject.id))?(i.lastResource=i.resource,f=new this.pixiSpine.Spine(c),this.armatures[e.gameObject.id]=f,e.gameObject&&e.gameObject.transform&&(m=e.gameObject.transform,f.x=m.size.width*m.origin.x,f.y=m.size.height*m.origin.y),l.addChildAt(f,0),f.update(),f.updateTransform(),i.armature=f,i.emit("loaded",{resource:i.resource}),f.state.addListener({start:function(e,t){i.emit("start",{track:e,name:e.animation.name})},complete:function(e,t){i.emit("complete",{track:e,name:e.animation.name})},interrupt:function(e,t){i.emit("interrupt",{track:e,name:e.animation.name})},end:function(e,t){i.emit("end",{track:e,name:e.animation.name})},event:function(e,t){i.emit("event",e,t)}}),[2]):[2]):(i.addHandler=setTimeout((function(){i.destroied||(void 0===n&&(n=20),--n>0?d.add(e,n):console.log("retry exceed max times",i.resource))}),1e3),[2]):[2]}}))}))},r.prototype.change=function(e){this.remove(e),this.add(e)},r.prototype.remove=function(e){var n,r,o,i;return c(this,void 0,void 0,(function(){var a,s,u,c;return p(this,(function(p){switch(p.label){case 0:return this.increaseAsyncId(e.gameObject.id),a=e.component,clearTimeout(a.addHandler),s=this.armatures[e.gameObject.id],(u=null===(r=null===(n=this.renderSystem)||void 0===n?void 0:n.containerManager)||void 0===r?void 0:r.getContainer(e.gameObject.id))&&s&&u.removeChild(s),a.armature?(a.armature.destroy({children:!0}),[4,t.resource.getResource(a.lastResource)]):[3,2];case 1:x((c=p.sent()).name,null===(i=null===(o=c.data)||void 0===o?void 0:o.image)||void 0===i?void 0:i.src),p.label=2;case 2:return a.armature=null,delete this.armatures[e.gameObject.id],e.type,t.OBSERVER_TYPE.CHANGE,[2]}}))}))},r.systemName="SpineSystem",r=s([t.decorators.componentObserver({Spine:["resource"]})],r)}(n.Renderer),S=A;return t.resource.registerResourceType("SPINE"),e.Spine=v,e.SpineSystem=S,Object.defineProperty(e,"__esModule",{value:!0}),e}({},EVA,EVA.plugin.renderer,PIXI);window.EVA.plugin.spineBase=window.EVA.plugin.spineBase||_EVA_IIFE_spineBase;
1
+ function _extends(){return _extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},_extends.apply(this,arguments)}window.EVA=window.EVA||{},window.EVA.plugin=window.EVA.plugin||{};var _EVA_IIFE_spineBase=function(e,t,n,r){"use strict";var o=function(e,t){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},o(e,t)};function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function i(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{u(r.next(e))}catch(e){a(e)}}function s(e){try{u(r.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,s)}u((r=r.apply(e,t||[])).next())}))}function s(e,t){var n,r,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}}var u=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.resource="",t.animationName="",t.autoPlay=!0,t.waitExecuteInfos=[],t}return a(t,e),Object.defineProperty(t.prototype,"armature",{get:function(){return this._armature},set:function(e){var t,n;if(this._armature=e,e){this.autoPlay&&this.play(this.animationName);try{for(var r=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(this.waitExecuteInfos),o=r.next();!o.done;o=r.next()){var a=o.value;if(a.playType){var i=a.name,s=a.loop,u=a.track;this.play(i,s,u)}else this.stop(a.track)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}this.waitExecuteInfos=[]}},enumerable:!1,configurable:!0}),t.prototype.init=function(e){e&&_extends(this,e)},t.prototype.onDestroy=function(){this.destroied=!0},t.prototype.play=function(e,t,n){try{e&&(this.animationName=e),this.armature?(void 0===n&&(n=0),this.armature.state.setAnimation(n,this.animationName,t)):this.waitExecuteInfos.push({playType:!0,name:e,loop:null!=t?t:this.autoPlay,track:n})}catch(e){console.log(e)}},t.prototype.stop=function(e){this.armature?(void 0===e&&(e=0),this.armature.state.setEmptyAnimation(e,0)):this.waitExecuteInfos.push({playType:!1,track:e})},t.prototype.addAnimation=function(e,t,n,r){try{this.armature&&(void 0===r&&(r=0),this.armature.state.addAnimation(r,e,n,t))}catch(e){console.log(e)}},t.prototype.setMix=function(e,t,n){this.armature&&this.armature.stateData.setMix(e,t,n)},t.prototype.getAnim=function(e){void 0===e&&(e=0);try{if(this.armature)return this.armature.state.tracks[e].animation.name}catch(e){console.log(e)}},t.prototype.setDefaultMix=function(e){this.armature&&(this.armature.stateData.defaultMix=e)},t.prototype.setAttachment=function(e,t){this.armature&&this.armature.skeleton.setAttachment(e,t)},t.prototype.getBone=function(e){if(this.armature)return this.armature.skeleton.findBone(e)},t.componentName="Spine",t}(t.Component),c=u,l={};function p(e){var t=e.image;return{tex:r.Texture.from(t),count:0}}var m={};function f(e,t,n,r){var o=null,a=function(e,t){var n=l[e];return n||(n=p(t),l[e]=n),n.tex}(t.image.src,t);new r.core.TextureAtlas(t.atlas,(function(e,t){t(a.baseTexture)}),(function(e){if(e){var a=new r.core.AtlasAttachmentLoader(e),i=new r.core.SkeletonJson(a);n&&(i.scale=n),o=i.readSkeletonData(t.ske)}}));var i={spineData:o,ref:0,imageSrc:t.image.src};return m[e]=i,i}function d(e,t){return i(this,void 0,void 0,(function(){var n;return s(this,(function(r){if(!(n=m[e.name]))if(e.complete)n=f(e.name,e.data,e.scale,t);else if(!n)return[2];return function(e,t){var n=l[e];n||(n=p(t),l[e]=n),n.count++,n.tex}(e.data.image.src,e.data),n.ref++,[2,n.spineData]}))}))}function h(e,t){var n=m[e];n&&(n.ref--,n.ref<=0&&(!function(e){e&&setTimeout((function(){var t=l[e];t&&(t.count--,t.count<=0&&(t.tex&&(t.tex.destroy(!0),t.tex=null),delete l[e]))}),100)}(t),delete m[e]))}var y=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.armatures={},t}return a(r,e),r.prototype.init=function(e){var r=this,o=e.pixiSpine;this.renderSystem=this.game.getSystem(n.RendererSystem),this.renderSystem.rendererManager.register(this),this.pixiSpine=o,this.game.canvas.addEventListener("webglcontextrestored",(function(){var e=r.game.gameObjects,n=[];for(var o in r.armatures)for(var a=+o,i=0;i<e.length;++i){var s=e[i];if(s.id===a){var u=s.getComponent(c);u&&(r.remove({type:t.OBSERVER_TYPE.REMOVE,gameObject:s,component:u,componentName:c.componentName}),n.push({type:t.OBSERVER_TYPE.ADD,gameObject:s,component:u,componentName:c.componentName}));break}}setTimeout((function(){n.forEach((function(e){r.add(e)}))}),1e3)}),!1)},r.prototype.update=function(t){for(var n in this.armatures)this.armatures[n].update(.001*t.deltaTime),this.armatures[n].updateTransform();e.prototype.update.call(this)},r.prototype.componentChanged=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(n){if("Spine"===e.componentName)if(e.type===t.OBSERVER_TYPE.ADD)this.add(e);else if(e.type===t.OBSERVER_TYPE.CHANGE){if("resource"===e.prop.prop[0])this.change(e)}else e.type===t.OBSERVER_TYPE.REMOVE&&this.remove(e);return[2]}))}))},r.prototype.add=function(e,n){var r,o;return i(this,void 0,void 0,(function(){var a,i,u,c,l,p,m,f,h=this;return s(this,(function(s){switch(s.label){case 0:return a=e.component,clearTimeout(a.addHandler),i=e.gameObject.id,u=this.increaseAsyncId(i),[4,t.resource.getResource(a.resource)];case 1:return c=s.sent(),this.validateAsyncId(i,u)?[4,d(c,this.pixiSpine)]:[2];case 2:return l=s.sent(),this.validateAsyncId(i,u)?l?(this.remove(e),(p=null===(o=null===(r=this.renderSystem)||void 0===r?void 0:r.containerManager)||void 0===o?void 0:o.getContainer(e.gameObject.id))?(a.lastResource=a.resource,m=new this.pixiSpine.Spine(l),this.armatures[e.gameObject.id]=m,e.gameObject&&e.gameObject.transform&&(f=e.gameObject.transform,m.x=f.size.width*f.origin.x,m.y=f.size.height*f.origin.y),p.addChildAt(m,0),m.update(),m.updateTransform(),a.armature=m,a.emit("loaded",{resource:a.resource}),m.state.addListener({start:function(e,t){a.emit("start",{track:e,name:e.animation.name})},complete:function(e,t){a.emit("complete",{track:e,name:e.animation.name})},interrupt:function(e,t){a.emit("interrupt",{track:e,name:e.animation.name})},end:function(e,t){a.emit("end",{track:e,name:e.animation.name})},event:function(e,t){a.emit("event",e,t)}}),[2]):[2]):(a.addHandler=setTimeout((function(){a.destroied||(void 0===n&&(n=20),--n>0?h.add(e,n):console.log("retry exceed max times",a.resource))}),1e3),[2]):[2]}}))}))},r.prototype.change=function(e){this.remove(e),this.add(e)},r.prototype.remove=function(e){var n,r,o,a;return i(this,void 0,void 0,(function(){var i,u,c,l;return s(this,(function(s){switch(s.label){case 0:return this.increaseAsyncId(e.gameObject.id),i=e.component,clearTimeout(i.addHandler),u=this.armatures[e.gameObject.id],(c=null===(r=null===(n=this.renderSystem)||void 0===n?void 0:n.containerManager)||void 0===r?void 0:r.getContainer(e.gameObject.id))&&u&&c.removeChild(u),i.armature?(i.armature.destroy({children:!0}),[4,t.resource.getResource(i.lastResource)]):[3,2];case 1:h((l=s.sent()).name,null===(a=null===(o=l.data)||void 0===o?void 0:o.image)||void 0===a?void 0:a.src),s.label=2;case 2:return i.armature=null,delete this.armatures[e.gameObject.id],e.type,t.OBSERVER_TYPE.CHANGE,[2]}}))}))},r.systemName="SpineSystem",r=function(e,t,n,r){var o,a=arguments.length,i=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(i=(a<3?o(i):a>3?o(t,n,i):o(t,n))||i);return a>3&&i&&Object.defineProperty(t,n,i),i}([t.decorators.componentObserver({Spine:["resource"]})],r),r}(n.Renderer),v=y;return t.resource.registerResourceType("SPINE"),e.Spine=c,e.SpineSystem=v,Object.defineProperty(e,"__esModule",{value:!0}),e}({},EVA,EVA.plugin.renderer,PIXI);window.EVA.plugin.spineBase=window.EVA.plugin.spineBase||_EVA_IIFE_spineBase;
@@ -4,7 +4,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var eva_js = require('@eva/eva.js');
6
6
  var pluginRenderer = require('@eva/plugin-renderer');
7
- var inspectorDecorator = require('@eva/inspector-decorator');
8
7
  var pixi_js = require('pixi.js');
9
8
 
10
9
  /*! *****************************************************************************
@@ -36,17 +35,6 @@ function __extends(d, b) {
36
35
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
37
36
  }
38
37
 
39
- var __assign = function() {
40
- __assign = Object.assign || function __assign(t) {
41
- for (var s, i = 1, n = arguments.length; i < n; i++) {
42
- s = arguments[i];
43
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
44
- }
45
- return t;
46
- };
47
- return __assign.apply(this, arguments);
48
- };
49
-
50
38
  function __decorate(decorators, target, key, desc) {
51
39
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
52
40
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -54,10 +42,6 @@ function __decorate(decorators, target, key, desc) {
54
42
  return c > 3 && r && Object.defineProperty(target, key, r), r;
55
43
  }
56
44
 
57
- function __metadata(metadataKey, metadataValue) {
58
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
59
- }
60
-
61
45
  function __awaiter(thisArg, _arguments, P, generator) {
62
46
  return new (P || (P = Promise))(function (resolve, reject) {
63
47
  function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
@@ -106,7 +90,6 @@ function __values(o) {
106
90
  };
107
91
  }
108
92
 
109
- var sleep = function (time) { return new Promise(function (resolve) { return setTimeout(resolve, time); }); };
110
93
  var Spine = (function (_super) {
111
94
  __extends(Spine, _super);
112
95
  function Spine() {
@@ -250,44 +233,6 @@ var Spine = (function (_super) {
250
233
  return this.armature.skeleton.findBone(boneName);
251
234
  };
252
235
  Spine.componentName = 'Spine';
253
- __decorate([
254
- inspectorDecorator.Field({ type: 'resource' }),
255
- __metadata("design:type", String)
256
- ], Spine.prototype, "resource", void 0);
257
- __decorate([
258
- inspectorDecorator.Field({
259
- type: 'selector',
260
- options: function (that) {
261
- var _a, _b, _c;
262
- return __awaiter(this, void 0, void 0, function () {
263
- var animations;
264
- return __generator(this, function (_d) {
265
- switch (_d.label) {
266
- case 0: return [4, sleep(0)];
267
- case 1:
268
- _d.sent();
269
- if (!that.resource || !eva_js.resource.promiseMap[that.resource]) {
270
- return [2, {}];
271
- }
272
- return [4, eva_js.resource.promiseMap[that.resource]];
273
- case 2:
274
- _d.sent();
275
- animations = (_c = (_b = (_a = eva_js.resource.resourcesMap[that.resource]) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.ske) === null || _c === void 0 ? void 0 : _c.animations;
276
- return [2, animations ? Object.keys(animations).reduce(function (prev, key) {
277
- var _a;
278
- return (__assign(__assign({}, prev), (_a = {}, _a[key] = key, _a)));
279
- }, {}) : {}];
280
- }
281
- });
282
- });
283
- },
284
- }),
285
- __metadata("design:type", String)
286
- ], Spine.prototype, "animationName", void 0);
287
- __decorate([
288
- inspectorDecorator.Field(),
289
- __metadata("design:type", Boolean)
290
- ], Spine.prototype, "autoPlay", void 0);
291
236
  return Spine;
292
237
  }(eva_js.Component));
293
238
  var Spine$1 = Spine;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@eva/eva.js"),t=require("@eva/plugin-renderer"),r=require("@eva/inspector-decorator"),n=require("pixi.js"),o=function(e,t){return o=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])},o(e,t)};function a(e,t){function r(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var i=function(){return i=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},i.apply(this,arguments)};function s(e,t,r,n){var o,a=arguments.length,i=a<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(i=(a<3?o(i):a>3?o(t,r,i):o(t,r))||i);return a>3&&i&&Object.defineProperty(t,r,i),i}function u(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function c(e,t,r,n){return new(r||(r=Promise))((function(o,a){function i(e){try{u(n.next(e))}catch(e){a(e)}}function s(e){try{u(n.throw(e))}catch(e){a(e)}}function u(e){e.done?o(e.value):new r((function(t){t(e.value)})).then(i,s)}u((n=n.apply(e,t||[])).next())}))}function l(e,t){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}}var p=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.resource="",e.animationName="",e.autoPlay=!0,e.waitExecuteInfos=[],e}return a(n,t),Object.defineProperty(n.prototype,"armature",{get:function(){return this._armature},set:function(e){var t,r;if(this._armature=e,e){this.autoPlay&&this.play(this.animationName);try{for(var n=function(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}}}}(this.waitExecuteInfos),o=n.next();!o.done;o=n.next()){var a=o.value;if(a.playType){var i=a.name,s=a.loop,u=a.track;this.play(i,s,u)}else this.stop(a.track)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}this.waitExecuteInfos=[]}},enumerable:!1,configurable:!0}),n.prototype.init=function(e){e&&Object.assign(this,e)},n.prototype.onDestroy=function(){this.destroied=!0},n.prototype.play=function(e,t,r){try{e&&(this.animationName=e),this.armature?(void 0===r&&(r=0),this.armature.state.setAnimation(r,this.animationName,t)):this.waitExecuteInfos.push({playType:!0,name:e,loop:null!=t?t:this.autoPlay,track:r})}catch(e){console.log(e)}},n.prototype.stop=function(e){this.armature?(void 0===e&&(e=0),this.armature.state.setEmptyAnimation(e,0)):this.waitExecuteInfos.push({playType:!1,track:e})},n.prototype.addAnimation=function(e,t,r,n){try{this.armature&&(void 0===n&&(n=0),this.armature.state.addAnimation(n,e,r,t))}catch(e){console.log(e)}},n.prototype.setMix=function(e,t,r){this.armature&&this.armature.stateData.setMix(e,t,r)},n.prototype.getAnim=function(e){void 0===e&&(e=0);try{if(this.armature)return this.armature.state.tracks[e].animation.name}catch(e){console.log(e)}},n.prototype.setDefaultMix=function(e){this.armature&&(this.armature.stateData.defaultMix=e)},n.prototype.setAttachment=function(e,t){this.armature&&this.armature.skeleton.setAttachment(e,t)},n.prototype.getBone=function(e){if(this.armature)return this.armature.skeleton.findBone(e)},n.componentName="Spine",s([r.Field({type:"resource"}),u("design:type",String)],n.prototype,"resource",void 0),s([r.Field({type:"selector",options:function(t){var r,n,o;return c(this,void 0,void 0,(function(){var a;return l(this,(function(s){switch(s.label){case 0:return[4,(u=0,new Promise((function(e){return setTimeout(e,u)})))];case 1:return s.sent(),t.resource&&e.resource.promiseMap[t.resource]?[4,e.resource.promiseMap[t.resource]]:[2,{}];case 2:return s.sent(),[2,(a=null===(o=null===(n=null===(r=e.resource.resourcesMap[t.resource])||void 0===r?void 0:r.data)||void 0===n?void 0:n.ske)||void 0===o?void 0:o.animations)?Object.keys(a).reduce((function(e,t){var r;return i(i({},e),((r={})[t]=t,r))}),{}):{}]}var u}))}))}}),u("design:type",String)],n.prototype,"animationName",void 0),s([r.Field(),u("design:type",Boolean)],n.prototype,"autoPlay",void 0),n}(e.Component),m={};function f(e){var t=e.image;return{tex:n.Texture.from(t),count:0}}var d={};function h(e,t,r,n){var o=null,a=function(e,t){var r=m[e];return r||(r=f(t),m[e]=r),r.tex}(t.image.src,t);new n.core.TextureAtlas(t.atlas,(function(e,t){t(a.baseTexture)}),(function(e){if(e){var a=new n.core.AtlasAttachmentLoader(e),i=new n.core.SkeletonJson(a);r&&(i.scale=r),o=i.readSkeletonData(t.ske)}}));var i={spineData:o,ref:0,imageSrc:t.image.src};return d[e]=i,i}function y(e,t){return c(this,void 0,void 0,(function(){var r;return l(this,(function(n){if(!(r=d[e.name]))if(e.complete)r=h(e.name,e.data,e.scale,t);else if(!r)return[2];return function(e,t){var r=m[e];r||(r=f(t),m[e]=r),r.count++,r.tex}(e.data.image.src,e.data),r.ref++,[2,r.spineData]}))}))}function v(e,t){var r=d[e];r&&(r.ref--,r.ref<=0&&(!function(e){e&&setTimeout((function(){var t=m[e];t&&(t.count--,t.count<=0&&(t.tex&&(t.tex.destroy(!0),t.tex=null),delete m[e]))}),100)}(t),delete d[e]))}var g=function(r){function n(){var e=null!==r&&r.apply(this,arguments)||this;return e.armatures={},e}return a(n,r),n.prototype.init=function(r){var n=this,o=r.pixiSpine;this.renderSystem=this.game.getSystem(t.RendererSystem),this.renderSystem.rendererManager.register(this),this.pixiSpine=o,this.game.canvas.addEventListener("webglcontextrestored",(function(){var t=n.game.gameObjects,r=[];for(var o in n.armatures)for(var a=+o,i=0;i<t.length;++i){var s=t[i];if(s.id===a){var u=s.getComponent(p);u&&(n.remove({type:e.OBSERVER_TYPE.REMOVE,gameObject:s,component:u,componentName:p.componentName}),r.push({type:e.OBSERVER_TYPE.ADD,gameObject:s,component:u,componentName:p.componentName}));break}}setTimeout((function(){r.forEach((function(e){n.add(e)}))}),1e3)}),!1)},n.prototype.update=function(e){for(var t in this.armatures)this.armatures[t].update(.001*e.deltaTime),this.armatures[t].updateTransform();r.prototype.update.call(this)},n.prototype.componentChanged=function(t){return c(this,void 0,void 0,(function(){return l(this,(function(r){if("Spine"===t.componentName)if(t.type===e.OBSERVER_TYPE.ADD)this.add(t);else if(t.type===e.OBSERVER_TYPE.CHANGE){if("resource"===t.prop.prop[0])this.change(t)}else t.type===e.OBSERVER_TYPE.REMOVE&&this.remove(t);return[2]}))}))},n.prototype.add=function(t,r){var n,o;return c(this,void 0,void 0,(function(){var a,i,s,u,c,p,m,f,d=this;return l(this,(function(l){switch(l.label){case 0:return a=t.component,clearTimeout(a.addHandler),i=t.gameObject.id,s=this.increaseAsyncId(i),[4,e.resource.getResource(a.resource)];case 1:return u=l.sent(),this.validateAsyncId(i,s)?[4,y(u,this.pixiSpine)]:[2];case 2:return c=l.sent(),this.validateAsyncId(i,s)?c?(this.remove(t),(p=null===(o=null===(n=this.renderSystem)||void 0===n?void 0:n.containerManager)||void 0===o?void 0:o.getContainer(t.gameObject.id))?(a.lastResource=a.resource,m=new this.pixiSpine.Spine(c),this.armatures[t.gameObject.id]=m,t.gameObject&&t.gameObject.transform&&(f=t.gameObject.transform,m.x=f.size.width*f.origin.x,m.y=f.size.height*f.origin.y),p.addChildAt(m,0),m.update(),m.updateTransform(),a.armature=m,a.emit("loaded",{resource:a.resource}),m.state.addListener({start:function(e,t){a.emit("start",{track:e,name:e.animation.name})},complete:function(e,t){a.emit("complete",{track:e,name:e.animation.name})},interrupt:function(e,t){a.emit("interrupt",{track:e,name:e.animation.name})},end:function(e,t){a.emit("end",{track:e,name:e.animation.name})},event:function(e,t){a.emit("event",e,t)}}),[2]):[2]):(a.addHandler=setTimeout((function(){a.destroied||(void 0===r&&(r=20),--r>0?d.add(t,r):console.log("retry exceed max times",a.resource))}),1e3),[2]):[2]}}))}))},n.prototype.change=function(e){this.remove(e),this.add(e)},n.prototype.remove=function(t){var r,n,o,a;return c(this,void 0,void 0,(function(){var i,s,u,c;return l(this,(function(l){switch(l.label){case 0:return this.increaseAsyncId(t.gameObject.id),i=t.component,clearTimeout(i.addHandler),s=this.armatures[t.gameObject.id],(u=null===(n=null===(r=this.renderSystem)||void 0===r?void 0:r.containerManager)||void 0===n?void 0:n.getContainer(t.gameObject.id))&&s&&u.removeChild(s),i.armature?(i.armature.destroy({children:!0}),[4,e.resource.getResource(i.lastResource)]):[3,2];case 1:v((c=l.sent()).name,null===(a=null===(o=c.data)||void 0===o?void 0:o.image)||void 0===a?void 0:a.src),l.label=2;case 2:return i.armature=null,delete this.armatures[t.gameObject.id],t.type,e.OBSERVER_TYPE.CHANGE,[2]}}))}))},n.systemName="SpineSystem",n=s([e.decorators.componentObserver({Spine:["resource"]})],n)}(t.Renderer);e.resource.registerResourceType("SPINE"),exports.Spine=p,exports.SpineSystem=g;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@eva/eva.js"),t=require("@eva/plugin-renderer"),n=require("pixi.js"),r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},r(e,t)};function a(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function o(e,t,n,r){return new(n||(n=Promise))((function(a,o){function i(e){try{u(r.next(e))}catch(e){o(e)}}function s(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){e.done?a(e.value):new n((function(t){t(e.value)})).then(i,s)}u((r=r.apply(e,t||[])).next())}))}function i(e,t){var n,r,a,o,i={label:0,sent:function(){if(1&a[0])throw a[1];return a[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(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(a=2&o[0]?r.return:o[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,o[1])).done)return a;switch(r=0,a&&(o=[2&o[0],a.value]),o[0]){case 0:case 1:a=o;break;case 4:return i.label++,{value:o[1],done:!1};case 5:i.label++,r=o[1],o=[0];continue;case 7:o=i.ops.pop(),i.trys.pop();continue;default:if(!(a=i.trys,(a=a.length>0&&a[a.length-1])||6!==o[0]&&2!==o[0])){i=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]<a[3])){i.label=o[1];break}if(6===o[0]&&i.label<a[1]){i.label=a[1],a=o;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(o);break}a[2]&&i.ops.pop(),i.trys.pop();continue}o=t.call(e,i)}catch(e){o=[6,e],r=0}finally{n=a=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}var s=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.resource="",t.animationName="",t.autoPlay=!0,t.waitExecuteInfos=[],t}return a(t,e),Object.defineProperty(t.prototype,"armature",{get:function(){return this._armature},set:function(e){var t,n;if(this._armature=e,e){this.autoPlay&&this.play(this.animationName);try{for(var r=function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],n=0;return t?t.call(e):{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}}(this.waitExecuteInfos),a=r.next();!a.done;a=r.next()){var o=a.value;if(o.playType){var i=o.name,s=o.loop,u=o.track;this.play(i,s,u)}else this.stop(o.track)}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}this.waitExecuteInfos=[]}},enumerable:!1,configurable:!0}),t.prototype.init=function(e){e&&Object.assign(this,e)},t.prototype.onDestroy=function(){this.destroied=!0},t.prototype.play=function(e,t,n){try{e&&(this.animationName=e),this.armature?(void 0===n&&(n=0),this.armature.state.setAnimation(n,this.animationName,t)):this.waitExecuteInfos.push({playType:!0,name:e,loop:null!=t?t:this.autoPlay,track:n})}catch(e){console.log(e)}},t.prototype.stop=function(e){this.armature?(void 0===e&&(e=0),this.armature.state.setEmptyAnimation(e,0)):this.waitExecuteInfos.push({playType:!1,track:e})},t.prototype.addAnimation=function(e,t,n,r){try{this.armature&&(void 0===r&&(r=0),this.armature.state.addAnimation(r,e,n,t))}catch(e){console.log(e)}},t.prototype.setMix=function(e,t,n){this.armature&&this.armature.stateData.setMix(e,t,n)},t.prototype.getAnim=function(e){void 0===e&&(e=0);try{if(this.armature)return this.armature.state.tracks[e].animation.name}catch(e){console.log(e)}},t.prototype.setDefaultMix=function(e){this.armature&&(this.armature.stateData.defaultMix=e)},t.prototype.setAttachment=function(e,t){this.armature&&this.armature.skeleton.setAttachment(e,t)},t.prototype.getBone=function(e){if(this.armature)return this.armature.skeleton.findBone(e)},t.componentName="Spine",t}(e.Component),u={};function c(e){var t=e.image;return{tex:n.Texture.from(t),count:0}}var l={};function m(e,t,n,r){var a=null,o=function(e,t){var n=u[e];return n||(n=c(t),u[e]=n),n.tex}(t.image.src,t);new r.core.TextureAtlas(t.atlas,(function(e,t){t(o.baseTexture)}),(function(e){if(e){var o=new r.core.AtlasAttachmentLoader(e),i=new r.core.SkeletonJson(o);n&&(i.scale=n),a=i.readSkeletonData(t.ske)}}));var i={spineData:a,ref:0,imageSrc:t.image.src};return l[e]=i,i}function p(e,t){return o(this,void 0,void 0,(function(){var n;return i(this,(function(r){if(!(n=l[e.name]))if(e.complete)n=m(e.name,e.data,e.scale,t);else if(!n)return[2];return function(e,t){var n=u[e];n||(n=c(t),u[e]=n),n.count++,n.tex}(e.data.image.src,e.data),n.ref++,[2,n.spineData]}))}))}function f(e,t){var n=l[e];n&&(n.ref--,n.ref<=0&&(!function(e){e&&setTimeout((function(){var t=u[e];t&&(t.count--,t.count<=0&&(t.tex&&(t.tex.destroy(!0),t.tex=null),delete u[e]))}),100)}(t),delete l[e]))}var d=function(n){function r(){var e=null!==n&&n.apply(this,arguments)||this;return e.armatures={},e}return a(r,n),r.prototype.init=function(n){var r=this,a=n.pixiSpine;this.renderSystem=this.game.getSystem(t.RendererSystem),this.renderSystem.rendererManager.register(this),this.pixiSpine=a,this.game.canvas.addEventListener("webglcontextrestored",(function(){var t=r.game.gameObjects,n=[];for(var a in r.armatures)for(var o=+a,i=0;i<t.length;++i){var u=t[i];if(u.id===o){var c=u.getComponent(s);c&&(r.remove({type:e.OBSERVER_TYPE.REMOVE,gameObject:u,component:c,componentName:s.componentName}),n.push({type:e.OBSERVER_TYPE.ADD,gameObject:u,component:c,componentName:s.componentName}));break}}setTimeout((function(){n.forEach((function(e){r.add(e)}))}),1e3)}),!1)},r.prototype.update=function(e){for(var t in this.armatures)this.armatures[t].update(.001*e.deltaTime),this.armatures[t].updateTransform();n.prototype.update.call(this)},r.prototype.componentChanged=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(n){if("Spine"===t.componentName)if(t.type===e.OBSERVER_TYPE.ADD)this.add(t);else if(t.type===e.OBSERVER_TYPE.CHANGE){if("resource"===t.prop.prop[0])this.change(t)}else t.type===e.OBSERVER_TYPE.REMOVE&&this.remove(t);return[2]}))}))},r.prototype.add=function(t,n){var r,a;return o(this,void 0,void 0,(function(){var o,s,u,c,l,m,f,d,h=this;return i(this,(function(i){switch(i.label){case 0:return o=t.component,clearTimeout(o.addHandler),s=t.gameObject.id,u=this.increaseAsyncId(s),[4,e.resource.getResource(o.resource)];case 1:return c=i.sent(),this.validateAsyncId(s,u)?[4,p(c,this.pixiSpine)]:[2];case 2:return l=i.sent(),this.validateAsyncId(s,u)?l?(this.remove(t),(m=null===(a=null===(r=this.renderSystem)||void 0===r?void 0:r.containerManager)||void 0===a?void 0:a.getContainer(t.gameObject.id))?(o.lastResource=o.resource,f=new this.pixiSpine.Spine(l),this.armatures[t.gameObject.id]=f,t.gameObject&&t.gameObject.transform&&(d=t.gameObject.transform,f.x=d.size.width*d.origin.x,f.y=d.size.height*d.origin.y),m.addChildAt(f,0),f.update(),f.updateTransform(),o.armature=f,o.emit("loaded",{resource:o.resource}),f.state.addListener({start:function(e,t){o.emit("start",{track:e,name:e.animation.name})},complete:function(e,t){o.emit("complete",{track:e,name:e.animation.name})},interrupt:function(e,t){o.emit("interrupt",{track:e,name:e.animation.name})},end:function(e,t){o.emit("end",{track:e,name:e.animation.name})},event:function(e,t){o.emit("event",e,t)}}),[2]):[2]):(o.addHandler=setTimeout((function(){o.destroied||(void 0===n&&(n=20),--n>0?h.add(t,n):console.log("retry exceed max times",o.resource))}),1e3),[2]):[2]}}))}))},r.prototype.change=function(e){this.remove(e),this.add(e)},r.prototype.remove=function(t){var n,r,a,s;return o(this,void 0,void 0,(function(){var o,u,c,l;return i(this,(function(i){switch(i.label){case 0:return this.increaseAsyncId(t.gameObject.id),o=t.component,clearTimeout(o.addHandler),u=this.armatures[t.gameObject.id],(c=null===(r=null===(n=this.renderSystem)||void 0===n?void 0:n.containerManager)||void 0===r?void 0:r.getContainer(t.gameObject.id))&&u&&c.removeChild(u),o.armature?(o.armature.destroy({children:!0}),[4,e.resource.getResource(o.lastResource)]):[3,2];case 1:f((l=i.sent()).name,null===(s=null===(a=l.data)||void 0===a?void 0:a.image)||void 0===s?void 0:s.src),i.label=2;case 2:return o.armature=null,delete this.armatures[t.gameObject.id],t.type,e.OBSERVER_TYPE.CHANGE,[2]}}))}))},r.systemName="SpineSystem",r=function(e,t,n,r){var a,o=arguments.length,i=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(a=e[s])&&(i=(o<3?a(i):o>3?a(t,n,i):a(t,n))||i);return o>3&&i&&Object.defineProperty(t,n,i),i}([e.decorators.componentObserver({Spine:["resource"]})],r),r}(t.Renderer);e.resource.registerResourceType("SPINE"),exports.Spine=s,exports.SpineSystem=d;
@@ -1,6 +1,5 @@
1
- import { Component, resource, OBSERVER_TYPE, decorators } from '@eva/eva.js';
1
+ import { Component, OBSERVER_TYPE, decorators, resource } from '@eva/eva.js';
2
2
  import { RendererSystem, Renderer } from '@eva/plugin-renderer';
3
- import { Field } from '@eva/inspector-decorator';
4
3
  import { Texture } from 'pixi.js';
5
4
 
6
5
  /*! *****************************************************************************
@@ -32,17 +31,6 @@ function __extends(d, b) {
32
31
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
33
32
  }
34
33
 
35
- var __assign = function() {
36
- __assign = Object.assign || function __assign(t) {
37
- for (var s, i = 1, n = arguments.length; i < n; i++) {
38
- s = arguments[i];
39
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
40
- }
41
- return t;
42
- };
43
- return __assign.apply(this, arguments);
44
- };
45
-
46
34
  function __decorate(decorators, target, key, desc) {
47
35
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
48
36
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -50,10 +38,6 @@ function __decorate(decorators, target, key, desc) {
50
38
  return c > 3 && r && Object.defineProperty(target, key, r), r;
51
39
  }
52
40
 
53
- function __metadata(metadataKey, metadataValue) {
54
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
55
- }
56
-
57
41
  function __awaiter(thisArg, _arguments, P, generator) {
58
42
  return new (P || (P = Promise))(function (resolve, reject) {
59
43
  function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
@@ -102,7 +86,6 @@ function __values(o) {
102
86
  };
103
87
  }
104
88
 
105
- var sleep = function (time) { return new Promise(function (resolve) { return setTimeout(resolve, time); }); };
106
89
  var Spine = (function (_super) {
107
90
  __extends(Spine, _super);
108
91
  function Spine() {
@@ -246,44 +229,6 @@ var Spine = (function (_super) {
246
229
  return this.armature.skeleton.findBone(boneName);
247
230
  };
248
231
  Spine.componentName = 'Spine';
249
- __decorate([
250
- Field({ type: 'resource' }),
251
- __metadata("design:type", String)
252
- ], Spine.prototype, "resource", void 0);
253
- __decorate([
254
- Field({
255
- type: 'selector',
256
- options: function (that) {
257
- var _a, _b, _c;
258
- return __awaiter(this, void 0, void 0, function () {
259
- var animations;
260
- return __generator(this, function (_d) {
261
- switch (_d.label) {
262
- case 0: return [4, sleep(0)];
263
- case 1:
264
- _d.sent();
265
- if (!that.resource || !resource.promiseMap[that.resource]) {
266
- return [2, {}];
267
- }
268
- return [4, resource.promiseMap[that.resource]];
269
- case 2:
270
- _d.sent();
271
- animations = (_c = (_b = (_a = resource.resourcesMap[that.resource]) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.ske) === null || _c === void 0 ? void 0 : _c.animations;
272
- return [2, animations ? Object.keys(animations).reduce(function (prev, key) {
273
- var _a;
274
- return (__assign(__assign({}, prev), (_a = {}, _a[key] = key, _a)));
275
- }, {}) : {}];
276
- }
277
- });
278
- });
279
- },
280
- }),
281
- __metadata("design:type", String)
282
- ], Spine.prototype, "animationName", void 0);
283
- __decorate([
284
- Field(),
285
- __metadata("design:type", Boolean)
286
- ], Spine.prototype, "autoPlay", void 0);
287
232
  return Spine;
288
233
  }(Component));
289
234
  var Spine$1 = Spine;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eva/spine-base",
3
- "version": "1.2.7-editor.10",
3
+ "version": "1.2.7-editor.11",
4
4
  "description": "@eva/spine-base",
5
5
  "main": "index.js",
6
6
  "module": "dist/spine-base.esm.js",
@@ -18,9 +18,9 @@
18
18
  "license": "MIT",
19
19
  "homepage": "https://eva.js.org",
20
20
  "dependencies": {
21
- "@eva/eva.js": "1.2.7-editor.10",
22
- "@eva/plugin-renderer": "1.2.7-editor.10",
23
- "@eva/inspector-decorator": "0.1.0-alpha.2",
21
+ "@eva/eva.js": "1.2.7-editor.11",
22
+ "@eva/plugin-renderer": "1.2.7-editor.11",
23
+ "@eva/inspector-decorator": "0.1.0-alpha.3",
24
24
  "pixi.js": "^4.8.9"
25
25
  }
26
26
  }