@eva/plugin-renderer-img 1.2.2-mini.1 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -275,10 +275,12 @@ var _EVA_IIFE_img = function (exports, eva_js, pluginRenderer, rendererAdapter,
275
275
  };
276
276
 
277
277
  Img.prototype.componentChanged = function (changed) {
278
+ var _a, _b;
279
+
278
280
  return __awaiter(this, void 0, void 0, function () {
279
281
  var component, sprite_1, instance, sprite;
280
- return __generator(this, function (_a) {
281
- switch (_a.label) {
282
+ return __generator(this, function (_c) {
283
+ switch (_c.label) {
282
284
  case 0:
283
285
  if (!(changed.componentName === 'Img')) return [3, 4];
284
286
  component = changed.component;
@@ -302,7 +304,7 @@ var _EVA_IIFE_img = function (exports, eva_js, pluginRenderer, rendererAdapter,
302
304
  return [4, eva_js.resource.getResource(component.resource)];
303
305
 
304
306
  case 2:
305
- instance = _a.sent().instance;
307
+ instance = _c.sent().instance;
306
308
 
307
309
  if (!instance) {
308
310
  console.error("GameObject:" + changed.gameObject.name + "'s Img resource load error");
@@ -314,14 +316,15 @@ var _EVA_IIFE_img = function (exports, eva_js, pluginRenderer, rendererAdapter,
314
316
  case 3:
315
317
  if (changed.type === eva_js.OBSERVER_TYPE.REMOVE) {
316
318
  sprite = this.imgs[changed.gameObject.id];
317
- this.containerManager.getContainer(changed.gameObject.id).removeChild(sprite.sprite);
319
+ if (!sprite) return [2];
320
+ (_b = (_a = this.containerManager) === null || _a === void 0 ? void 0 : _a.getContainer(changed.gameObject.id)) === null || _b === void 0 ? void 0 : _b.removeChild(sprite.sprite);
318
321
  sprite.sprite.destroy({
319
322
  children: true
320
323
  });
321
324
  delete this.imgs[changed.gameObject.id];
322
325
  }
323
326
 
324
- _a.label = 4;
327
+ _c.label = 4;
325
328
 
326
329
  case 4:
327
330
  return [2];
@@ -1 +1 @@
1
- var _EVA_IIFE_img=function(e,t,r,n,o){"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 c(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 o,i=arguments.length,c=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(c=(i<3?o(c):i>3?o(t,r,c):o(t,r))||c);return i>3&&c&&Object.defineProperty(t,r,c),c}function a(e,t,r,n){return new(r||(r=Promise))((function(o,i){function c(e){try{a(n.next(e))}catch(e){i(e)}}function s(e){try{a(n.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(c,s)}a((n=n.apply(e,t||[])).next())}))}function u(e,t){var r,n,o,i,c={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(r)throw new TypeError("Generator is already executing.");for(;c;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return c.label++,{value:i[1],done:!1};case 5:c.label++,n=i[1],i=[0];continue;case 7:i=c.ops.pop(),c.trys.pop();continue;default:if(!(o=c.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){c=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){c.label=i[1];break}if(6===i[0]&&c.label<o[1]){c.label=o[1],o=i;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(i);break}o[2]&&c.ops.pop(),c.trys.pop();continue}i=t.call(e,c)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}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}return c(t,e),t.prototype.init=function(e){e&&e.resource&&(this.resource=e.resource)},t.componentName="Img",s([p("string")],t.prototype,"resource",void 0),t}(t.Component);t.resource.registerInstance(t.RESOURCE_TYPE.IMAGE,(function(e){var t=e.data,r=(void 0===t?{}:t).image;if(r)return o.Texture.from(r)})),t.resource.registerDestroy(t.RESOURCE_TYPE.IMAGE,(function(e){var t=e.instance;t&&t.destroy(!0)}));var f=function(e){function o(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="Img",t.imgs={},t}return c(o,e),o.prototype.init=function(){this.renderSystem=this.game.getSystem(r.RendererSystem),this.renderSystem.rendererManager.register(this)},o.prototype.rendererUpdate=function(e){var t=e.transform.size,r=t.width,n=t.height;this.imgs[e.id]&&(this.imgs[e.id].sprite.width=r,this.imgs[e.id].sprite.height=n)},o.prototype.componentChanged=function(e){return a(this,void 0,void 0,(function(){var r,o,i,c;return u(this,(function(s){switch(s.label){case 0:return"Img"!==e.componentName?[3,4]:(r=e.component,e.type!==t.OBSERVER_TYPE.ADD?[3,1]:(o=new n.Sprite(null),t.resource.getResource(r.resource).then((function(t){var r=t.instance;r||console.error("GameObject:"+e.gameObject.name+"'s Img resource load error"),o.image=r})),this.imgs[e.gameObject.id]=o,this.containerManager.getContainer(e.gameObject.id).addChildAt(o.sprite,0),[3,4]));case 1:return e.type!==t.OBSERVER_TYPE.CHANGE?[3,3]:[4,t.resource.getResource(r.resource)];case 2:return(i=s.sent().instance)||console.error("GameObject:"+e.gameObject.name+"'s Img resource load error"),this.imgs[e.gameObject.id].image=i,[3,4];case 3:e.type===t.OBSERVER_TYPE.REMOVE&&(c=this.imgs[e.gameObject.id],this.containerManager.getContainer(e.gameObject.id).removeChild(c.sprite),c.sprite.destroy({children:!0}),delete this.imgs[e.gameObject.id]),s.label=4;case 4:return[2]}}))}))},o.systemName="Img",o=s([t.decorators.componentObserver({Img:[{prop:["resource"],deep:!1}]})],o)}(r.Renderer);return e.Img=l,e.ImgSystem=f,Object.defineProperty(e,"__esModule",{value:!0}),e}({},EVA,EVA.plugin.renderer,EVA.rendererAdapter,PIXI);
1
+ var _EVA_IIFE_img=function(e,t,r,n,o){"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 c(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 o,i=arguments.length,c=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(c=(i<3?o(c):i>3?o(t,r,c):o(t,r))||c);return i>3&&c&&Object.defineProperty(t,r,c),c}function a(e,t,r,n){return new(r||(r=Promise))((function(o,i){function c(e){try{a(n.next(e))}catch(e){i(e)}}function s(e){try{a(n.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(c,s)}a((n=n.apply(e,t||[])).next())}))}function u(e,t){var r,n,o,i,c={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(r)throw new TypeError("Generator is already executing.");for(;c;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return c.label++,{value:i[1],done:!1};case 5:c.label++,n=i[1],i=[0];continue;case 7:i=c.ops.pop(),c.trys.pop();continue;default:if(!(o=c.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){c=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){c.label=i[1];break}if(6===i[0]&&c.label<o[1]){c.label=o[1],o=i;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(i);break}o[2]&&c.ops.pop(),c.trys.pop();continue}i=t.call(e,c)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}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}return c(t,e),t.prototype.init=function(e){e&&e.resource&&(this.resource=e.resource)},t.componentName="Img",s([p("string")],t.prototype,"resource",void 0),t}(t.Component);t.resource.registerInstance(t.RESOURCE_TYPE.IMAGE,(function(e){var t=e.data,r=(void 0===t?{}:t).image;if(r)return o.Texture.from(r)})),t.resource.registerDestroy(t.RESOURCE_TYPE.IMAGE,(function(e){var t=e.instance;t&&t.destroy(!0)}));var f=function(e){function o(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="Img",t.imgs={},t}return c(o,e),o.prototype.init=function(){this.renderSystem=this.game.getSystem(r.RendererSystem),this.renderSystem.rendererManager.register(this)},o.prototype.rendererUpdate=function(e){var t=e.transform.size,r=t.width,n=t.height;this.imgs[e.id]&&(this.imgs[e.id].sprite.width=r,this.imgs[e.id].sprite.height=n)},o.prototype.componentChanged=function(e){var r,o;return a(this,void 0,void 0,(function(){var i,c,s,a;return u(this,(function(u){switch(u.label){case 0:return"Img"!==e.componentName?[3,4]:(i=e.component,e.type!==t.OBSERVER_TYPE.ADD?[3,1]:(c=new n.Sprite(null),t.resource.getResource(i.resource).then((function(t){var r=t.instance;r||console.error("GameObject:"+e.gameObject.name+"'s Img resource load error"),c.image=r})),this.imgs[e.gameObject.id]=c,this.containerManager.getContainer(e.gameObject.id).addChildAt(c.sprite,0),[3,4]));case 1:return e.type!==t.OBSERVER_TYPE.CHANGE?[3,3]:[4,t.resource.getResource(i.resource)];case 2:return(s=u.sent().instance)||console.error("GameObject:"+e.gameObject.name+"'s Img resource load error"),this.imgs[e.gameObject.id].image=s,[3,4];case 3:if(e.type===t.OBSERVER_TYPE.REMOVE){if(!(a=this.imgs[e.gameObject.id]))return[2];null===(o=null===(r=this.containerManager)||void 0===r?void 0:r.getContainer(e.gameObject.id))||void 0===o||o.removeChild(a.sprite),a.sprite.destroy({children:!0}),delete this.imgs[e.gameObject.id]}u.label=4;case 4:return[2]}}))}))},o.systemName="Img",o=s([t.decorators.componentObserver({Img:[{prop:["resource"],deep:!1}]})],o)}(r.Renderer);return e.Img=l,e.ImgSystem=f,Object.defineProperty(e,"__esModule",{value:!0}),e}({},EVA,EVA.plugin.renderer,EVA.rendererAdapter,PIXI);
@@ -77,10 +77,12 @@ var Img = function (_super) {
77
77
  };
78
78
 
79
79
  Img.prototype.componentChanged = function (changed) {
80
+ var _a, _b;
81
+
80
82
  return __awaiter(this, void 0, void 0, function () {
81
83
  var component, sprite_1, instance, sprite;
82
- return __generator(this, function (_a) {
83
- switch (_a.label) {
84
+ return __generator(this, function (_c) {
85
+ switch (_c.label) {
84
86
  case 0:
85
87
  if (!(changed.componentName === 'Img')) return [3, 4];
86
88
  component = changed.component;
@@ -104,7 +106,7 @@ var Img = function (_super) {
104
106
  return [4, resource.getResource(component.resource)];
105
107
 
106
108
  case 2:
107
- instance = _a.sent().instance;
109
+ instance = _c.sent().instance;
108
110
 
109
111
  if (!instance) {
110
112
  console.error("GameObject:" + changed.gameObject.name + "'s Img resource load error");
@@ -116,14 +118,15 @@ var Img = function (_super) {
116
118
  case 3:
117
119
  if (changed.type === OBSERVER_TYPE.REMOVE) {
118
120
  sprite = this.imgs[changed.gameObject.id];
119
- this.containerManager.getContainer(changed.gameObject.id).removeChild(sprite.sprite);
121
+ if (!sprite) return [2];
122
+ (_b = (_a = this.containerManager) === null || _a === void 0 ? void 0 : _a.getContainer(changed.gameObject.id)) === null || _b === void 0 ? void 0 : _b.removeChild(sprite.sprite);
120
123
  sprite.sprite.destroy({
121
124
  children: true
122
125
  });
123
126
  delete this.imgs[changed.gameObject.id];
124
127
  }
125
128
 
126
- _a.label = 4;
129
+ _c.label = 4;
127
130
 
128
131
  case 4:
129
132
  return [2];
@@ -136,10 +136,11 @@ var Img = (function (_super) {
136
136
  }
137
137
  };
138
138
  Img.prototype.componentChanged = function (changed) {
139
+ var _a, _b;
139
140
  return __awaiter(this, void 0, void 0, function () {
140
141
  var component, sprite_1, instance, sprite;
141
- return __generator(this, function (_a) {
142
- switch (_a.label) {
142
+ return __generator(this, function (_c) {
143
+ switch (_c.label) {
143
144
  case 0:
144
145
  if (!(changed.componentName === 'Img')) return [3, 4];
145
146
  component = changed.component;
@@ -159,7 +160,7 @@ var Img = (function (_super) {
159
160
  if (!(changed.type === eva_js.OBSERVER_TYPE.CHANGE)) return [3, 3];
160
161
  return [4, eva_js.resource.getResource(component.resource)];
161
162
  case 2:
162
- instance = (_a.sent()).instance;
163
+ instance = (_c.sent()).instance;
163
164
  if (!instance) {
164
165
  console.error("GameObject:" + changed.gameObject.name + "'s Img resource load error");
165
166
  }
@@ -168,11 +169,13 @@ var Img = (function (_super) {
168
169
  case 3:
169
170
  if (changed.type === eva_js.OBSERVER_TYPE.REMOVE) {
170
171
  sprite = this.imgs[changed.gameObject.id];
171
- this.containerManager.getContainer(changed.gameObject.id).removeChild(sprite.sprite);
172
+ if (!sprite)
173
+ return [2];
174
+ (_b = (_a = this.containerManager) === null || _a === void 0 ? void 0 : _a.getContainer(changed.gameObject.id)) === null || _b === void 0 ? void 0 : _b.removeChild(sprite.sprite);
172
175
  sprite.sprite.destroy({ children: true });
173
176
  delete this.imgs[changed.gameObject.id];
174
177
  }
175
- _a.label = 4;
178
+ _c.label = 4;
176
179
  case 4: return [2];
177
180
  }
178
181
  });
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@eva/inspector-decorator"),t=require("@eva/eva.js"),r=require("@eva/plugin-renderer"),n=require("@eva/renderer-adapter"),o=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 c(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function a(e,t,r,n){var o,i=arguments.length,c=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(c=(i<3?o(c):i>3?o(t,r,c):o(t,r))||c);return i>3&&c&&Object.defineProperty(t,r,c),c}function s(e,t){var r,n,o,i,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;c;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return c.label++,{value:i[1],done:!1};case 5:c.label++,n=i[1],i=[0];continue;case 7:i=c.ops.pop(),c.trys.pop();continue;default:if(!(o=c.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){c=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){c.label=i[1];break}if(6===i[0]&&c.label<o[1]){c.label=o[1],o=i;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(i);break}o[2]&&c.ops.pop(),c.trys.pop();continue}i=t.call(e,c)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}var u=function(t){function r(){var e=null!==t&&t.apply(this,arguments)||this;return e.resource="",e}return c(r,t),r.prototype.init=function(e){e&&e.resource&&(this.resource=e.resource)},r.componentName="Img",a([e.type("string")],r.prototype,"resource",void 0),r}(t.Component);t.resource.registerInstance(t.RESOURCE_TYPE.IMAGE,(function(e){var t=e.data,r=(void 0===t?{}:t).image;if(r)return o.Texture.from(r)})),t.resource.registerDestroy(t.RESOURCE_TYPE.IMAGE,(function(e){var t=e.instance;t&&t.destroy(!0)}));var p=function(e){function o(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="Img",t.imgs={},t}return c(o,e),o.prototype.init=function(){this.renderSystem=this.game.getSystem(r.RendererSystem),this.renderSystem.rendererManager.register(this)},o.prototype.rendererUpdate=function(e){var t=e.transform.size,r=t.width,n=t.height;this.imgs[e.id]&&(this.imgs[e.id].sprite.width=r,this.imgs[e.id].sprite.height=n)},o.prototype.componentChanged=function(e){return r=this,o=void 0,c=function(){var r,o,i,c;return s(this,(function(a){switch(a.label){case 0:return"Img"!==e.componentName?[3,4]:(r=e.component,e.type!==t.OBSERVER_TYPE.ADD?[3,1]:(o=new n.Sprite(null),t.resource.getResource(r.resource).then((function(t){var r=t.instance;r||console.error("GameObject:"+e.gameObject.name+"'s Img resource load error"),o.image=r})),this.imgs[e.gameObject.id]=o,this.containerManager.getContainer(e.gameObject.id).addChildAt(o.sprite,0),[3,4]));case 1:return e.type!==t.OBSERVER_TYPE.CHANGE?[3,3]:[4,t.resource.getResource(r.resource)];case 2:return(i=a.sent().instance)||console.error("GameObject:"+e.gameObject.name+"'s Img resource load error"),this.imgs[e.gameObject.id].image=i,[3,4];case 3:e.type===t.OBSERVER_TYPE.REMOVE&&(c=this.imgs[e.gameObject.id],this.containerManager.getContainer(e.gameObject.id).removeChild(c.sprite),c.sprite.destroy({children:!0}),delete this.imgs[e.gameObject.id]),a.label=4;case 4:return[2]}}))},new((i=void 0)||(i=Promise))((function(e,t){function n(e){try{s(c.next(e))}catch(e){t(e)}}function a(e){try{s(c.throw(e))}catch(e){t(e)}}function s(t){t.done?e(t.value):new i((function(e){e(t.value)})).then(n,a)}s((c=c.apply(r,o||[])).next())}));var r,o,i,c},o.systemName="Img",o=a([t.decorators.componentObserver({Img:[{prop:["resource"],deep:!1}]})],o)}(r.Renderer);exports.Img=u,exports.ImgSystem=p;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@eva/inspector-decorator"),r=require("@eva/eva.js"),t=require("@eva/plugin-renderer"),n=require("@eva/renderer-adapter"),o=require("pixi.js"),i=function(e,r){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var t in r)r.hasOwnProperty(t)&&(e[t]=r[t])})(e,r)};function c(e,r){function t(){this.constructor=e}i(e,r),e.prototype=null===r?Object.create(r):(t.prototype=r.prototype,new t)}function a(e,r,t,n){var o,i=arguments.length,c=i<3?r:null===n?n=Object.getOwnPropertyDescriptor(r,t):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,r,t,n);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(c=(i<3?o(c):i>3?o(r,t,c):o(r,t))||c);return i>3&&c&&Object.defineProperty(r,t,c),c}function s(e,r){var t,n,o,i,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(t)throw new TypeError("Generator is already executing.");for(;c;)try{if(t=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return c.label++,{value:i[1],done:!1};case 5:c.label++,n=i[1],i=[0];continue;case 7:i=c.ops.pop(),c.trys.pop();continue;default:if(!(o=c.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){c=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){c.label=i[1];break}if(6===i[0]&&c.label<o[1]){c.label=o[1],o=i;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(i);break}o[2]&&c.ops.pop(),c.trys.pop();continue}i=r.call(e,c)}catch(e){i=[6,e],n=0}finally{t=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}var u=function(r){function t(){var e=null!==r&&r.apply(this,arguments)||this;return e.resource="",e}return c(t,r),t.prototype.init=function(e){e&&e.resource&&(this.resource=e.resource)},t.componentName="Img",a([e.type("string")],t.prototype,"resource",void 0),t}(r.Component);r.resource.registerInstance(r.RESOURCE_TYPE.IMAGE,(function(e){var r=e.data,t=(void 0===r?{}:r).image;if(t)return o.Texture.from(t)})),r.resource.registerDestroy(r.RESOURCE_TYPE.IMAGE,(function(e){var r=e.instance;r&&r.destroy(!0)}));var p=function(e){function o(){var r=null!==e&&e.apply(this,arguments)||this;return r.name="Img",r.imgs={},r}return c(o,e),o.prototype.init=function(){this.renderSystem=this.game.getSystem(t.RendererSystem),this.renderSystem.rendererManager.register(this)},o.prototype.rendererUpdate=function(e){var r=e.transform.size,t=r.width,n=r.height;this.imgs[e.id]&&(this.imgs[e.id].sprite.width=t,this.imgs[e.id].sprite.height=n)},o.prototype.componentChanged=function(e){var t,o,i,c,a,u;return i=this,c=void 0,u=function(){var i,c,a,u;return s(this,(function(s){switch(s.label){case 0:return"Img"!==e.componentName?[3,4]:(i=e.component,e.type!==r.OBSERVER_TYPE.ADD?[3,1]:(c=new n.Sprite(null),r.resource.getResource(i.resource).then((function(r){var t=r.instance;t||console.error("GameObject:"+e.gameObject.name+"'s Img resource load error"),c.image=t})),this.imgs[e.gameObject.id]=c,this.containerManager.getContainer(e.gameObject.id).addChildAt(c.sprite,0),[3,4]));case 1:return e.type!==r.OBSERVER_TYPE.CHANGE?[3,3]:[4,r.resource.getResource(i.resource)];case 2:return(a=s.sent().instance)||console.error("GameObject:"+e.gameObject.name+"'s Img resource load error"),this.imgs[e.gameObject.id].image=a,[3,4];case 3:if(e.type===r.OBSERVER_TYPE.REMOVE){if(!(u=this.imgs[e.gameObject.id]))return[2];null===(o=null===(t=this.containerManager)||void 0===t?void 0:t.getContainer(e.gameObject.id))||void 0===o||o.removeChild(u.sprite),u.sprite.destroy({children:!0}),delete this.imgs[e.gameObject.id]}s.label=4;case 4:return[2]}}))},new((a=void 0)||(a=Promise))((function(e,r){function t(e){try{o(u.next(e))}catch(e){r(e)}}function n(e){try{o(u.throw(e))}catch(e){r(e)}}function o(r){r.done?e(r.value):new a((function(e){e(r.value)})).then(t,n)}o((u=u.apply(i,c||[])).next())}))},o.systemName="Img",o=a([r.decorators.componentObserver({Img:[{prop:["resource"],deep:!1}]})],o)}(t.Renderer);exports.Img=u,exports.ImgSystem=p;
@@ -132,10 +132,11 @@ var Img = (function (_super) {
132
132
  }
133
133
  };
134
134
  Img.prototype.componentChanged = function (changed) {
135
+ var _a, _b;
135
136
  return __awaiter(this, void 0, void 0, function () {
136
137
  var component, sprite_1, instance, sprite;
137
- return __generator(this, function (_a) {
138
- switch (_a.label) {
138
+ return __generator(this, function (_c) {
139
+ switch (_c.label) {
139
140
  case 0:
140
141
  if (!(changed.componentName === 'Img')) return [3, 4];
141
142
  component = changed.component;
@@ -155,7 +156,7 @@ var Img = (function (_super) {
155
156
  if (!(changed.type === OBSERVER_TYPE.CHANGE)) return [3, 3];
156
157
  return [4, resource.getResource(component.resource)];
157
158
  case 2:
158
- instance = (_a.sent()).instance;
159
+ instance = (_c.sent()).instance;
159
160
  if (!instance) {
160
161
  console.error("GameObject:" + changed.gameObject.name + "'s Img resource load error");
161
162
  }
@@ -164,11 +165,13 @@ var Img = (function (_super) {
164
165
  case 3:
165
166
  if (changed.type === OBSERVER_TYPE.REMOVE) {
166
167
  sprite = this.imgs[changed.gameObject.id];
167
- this.containerManager.getContainer(changed.gameObject.id).removeChild(sprite.sprite);
168
+ if (!sprite)
169
+ return [2];
170
+ (_b = (_a = this.containerManager) === null || _a === void 0 ? void 0 : _a.getContainer(changed.gameObject.id)) === null || _b === void 0 ? void 0 : _b.removeChild(sprite.sprite);
168
171
  sprite.sprite.destroy({ children: true });
169
172
  delete this.imgs[changed.gameObject.id];
170
173
  }
171
- _a.label = 4;
174
+ _c.label = 4;
172
175
  case 4: return [2];
173
176
  }
174
177
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eva/plugin-renderer-img",
3
- "version": "1.2.2-mini.1",
3
+ "version": "1.2.2",
4
4
  "description": "@eva/plugin-renderer-img",
5
5
  "main": "index.js",
6
6
  "module": "dist/plugin-renderer-img.esm.js",
@@ -19,9 +19,9 @@
19
19
  "homepage": "https://eva.js.org",
20
20
  "dependencies": {
21
21
  "@eva/inspector-decorator": "^0.0.5",
22
- "@eva/plugin-renderer": "1.2.2-mini.1",
23
- "@eva/renderer-adapter": "1.2.2-mini.1",
24
- "@eva/eva.js": "1.2.2-mini.1",
22
+ "@eva/plugin-renderer": "1.2.2",
23
+ "@eva/renderer-adapter": "1.2.2",
24
+ "@eva/eva.js": "1.2.2",
25
25
  "pixi.js": "^4.8.7"
26
26
  }
27
27
  }