@eva/plugin-renderer-img 1.2.8-fix.1 → 1.2.8

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.
@@ -339,6 +339,19 @@ var _EVA_IIFE_img = function (exports, eva_js, pluginRenderer, rendererAdapter,
339
339
  });
340
340
  };
341
341
 
342
+ Img.prototype.destroy = function () {
343
+ var _a, _b;
344
+
345
+ for (var key in this.imgs) {
346
+ var sprite = this.imgs[key];
347
+ (_b = (_a = this.containerManager) === null || _a === void 0 ? void 0 : _a.getContainer(parseInt(key))) === null || _b === void 0 ? void 0 : _b.removeChild(sprite.sprite);
348
+ sprite.sprite.destroy({
349
+ children: true
350
+ });
351
+ delete this.imgs[key];
352
+ }
353
+ };
354
+
342
355
  Img.systemName = 'Img';
343
356
  Img = __decorate([eva_js.decorators.componentObserver({
344
357
  Img: [{
@@ -1 +1 @@
1
- window.EVA=window.EVA||{},window.EVA.plugin=window.EVA.plugin||{},window.EVA.plugin.renderer=window.EVA.plugin.renderer||{};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 l(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 p=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([l("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 d=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,5]:(i=e.component,e.type!==t.OBSERVER_TYPE.ADD?[3,2]:(a=new n.Sprite(null),this.imgs[e.gameObject.id]=a,this.containerManager.getContainer(e.gameObject.id).addChildAt(a.sprite,0),c=this.increaseAsyncId(e.gameObject.id),[4,t.resource.getResource(i.resource)]));case 1:return s=u.sent().instance,this.validateAsyncId(e.gameObject.id,c)?(s||console.error("GameObject:"+e.gameObject.name+"'s Img resource load error"),this.imgs[e.gameObject.id].image=s,[3,5]):[2];case 2:return e.type!==t.OBSERVER_TYPE.CHANGE?[3,4]:(c=this.increaseAsyncId(e.gameObject.id),[4,t.resource.getResource(i.resource)]);case 3:return s=u.sent().instance,this.validateAsyncId(e.gameObject.id,c)?(s||console.error("GameObject:"+e.gameObject.name+"'s Img resource load error"),this.imgs[e.gameObject.id].image=s,[3,5]):[2];case 4:if(e.type===t.OBSERVER_TYPE.REMOVE){if(this.increaseAsyncId(e.gameObject.id),!(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=5;case 5:return[2]}}))}))},o.systemName="Img",o=s([t.decorators.componentObserver({Img:[{prop:["resource"],deep:!1}]})],o)}(r.Renderer);return e.Img=p,e.ImgSystem=d,Object.defineProperty(e,"__esModule",{value:!0}),e}({},EVA,EVA.plugin.renderer,EVA.rendererAdapter,PIXI);window.EVA.plugin.renderer.img=window.EVA.plugin.renderer.img||_EVA_IIFE_img;
1
+ window.EVA=window.EVA||{},window.EVA.plugin=window.EVA.plugin||{},window.EVA.plugin.renderer=window.EVA.plugin.renderer||{};var _EVA_IIFE_img=function(e,t,r,n,i){"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 r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},o(e,t)};function s(e,t){function r(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function c(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 c=e.length-1;c>=0;c--)(i=e[c])&&(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{a(n.next(e))}catch(e){o(e)}}function c(e){try{a(n.throw(e))}catch(e){o(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,c)}a((n=n.apply(e,t||[])).next())}))}function u(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:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){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,c])}}}function l(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 d=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.resource="",t}return s(t,e),t.prototype.init=function(e){e&&e.resource&&(this.resource=e.resource)},t.componentName="Img",c([l("string")],t.prototype,"resource",void 0),t}(t.Component),p=d;t.resource.registerInstance(t.RESOURCE_TYPE.IMAGE,(function(e){var t=e.data,r=(void 0===t?{}:t).image;if(r)return i.Texture.from(r)})),t.resource.registerDestroy(t.RESOURCE_TYPE.IMAGE,(function(e){var t=e.instance;t&&t.destroy(!0)}));var g=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="Img",t.imgs={},t}return s(i,e),i.prototype.init=function(){this.renderSystem=this.game.getSystem(r.RendererSystem),this.renderSystem.rendererManager.register(this)},i.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)},i.prototype.componentChanged=function(e){var r,i;return a(this,void 0,void 0,(function(){var o,s,c,a;return u(this,(function(u){switch(u.label){case 0:return"Img"!==e.componentName?[3,5]:(o=e.component,e.type!==t.OBSERVER_TYPE.ADD?[3,2]:(a=new n.Sprite(null),this.imgs[e.gameObject.id]=a,this.containerManager.getContainer(e.gameObject.id).addChildAt(a.sprite,0),s=this.increaseAsyncId(e.gameObject.id),[4,t.resource.getResource(o.resource)]));case 1:return c=u.sent().instance,this.validateAsyncId(e.gameObject.id,s)?(c||console.error("GameObject:"+e.gameObject.name+"'s Img resource load error"),this.imgs[e.gameObject.id].image=c,[3,5]):[2];case 2:return e.type!==t.OBSERVER_TYPE.CHANGE?[3,4]:(s=this.increaseAsyncId(e.gameObject.id),[4,t.resource.getResource(o.resource)]);case 3:return c=u.sent().instance,this.validateAsyncId(e.gameObject.id,s)?(c||console.error("GameObject:"+e.gameObject.name+"'s Img resource load error"),this.imgs[e.gameObject.id].image=c,[3,5]):[2];case 4:if(e.type===t.OBSERVER_TYPE.REMOVE){if(this.increaseAsyncId(e.gameObject.id),!(a=this.imgs[e.gameObject.id]))return[2];null===(i=null===(r=this.containerManager)||void 0===r?void 0:r.getContainer(e.gameObject.id))||void 0===i||i.removeChild(a.sprite),a.sprite.destroy({children:!0}),delete this.imgs[e.gameObject.id]}u.label=5;case 5:return[2]}}))}))},i.prototype.destroy=function(){var e,t;for(var r in this.imgs){var n=this.imgs[r];null===(t=null===(e=this.containerManager)||void 0===e?void 0:e.getContainer(parseInt(r)))||void 0===t||t.removeChild(n.sprite),n.sprite.destroy({children:!0}),delete this.imgs[r]}},i.systemName="Img",i=c([t.decorators.componentObserver({Img:[{prop:["resource"],deep:!1}]})],i)}(r.Renderer),m=g;return e.Img=p,e.ImgSystem=m,Object.defineProperty(e,"__esModule",{value:!0}),e}({},EVA,EVA.plugin.renderer,EVA.rendererAdapter,PIXI);window.EVA.plugin.renderer.img=window.EVA.plugin.renderer.img||_EVA_IIFE_img;
@@ -0,0 +1,168 @@
1
+ import { __extends, __decorate, __awaiter, __generator } from 'tslib';
2
+ import { type } from '@eva/inspector-decorator';
3
+ import { Component, resource, RESOURCE_TYPE, OBSERVER_TYPE, decorators } from '@eva/eva.js/dist/miniprogram';
4
+ import { RendererSystem, Renderer } from '@eva/plugin-renderer/dist/miniprogram';
5
+ import { Sprite } from '@eva/renderer-adapter/dist/miniprogram';
6
+ import { Texture } from '@eva/miniprogram-pixi';
7
+
8
+ var Img$2 = function (_super) {
9
+ __extends(Img, _super);
10
+
11
+ function Img() {
12
+ var _this = _super !== null && _super.apply(this, arguments) || this;
13
+
14
+ _this.resource = '';
15
+ return _this;
16
+ }
17
+
18
+ Img.prototype.init = function (obj) {
19
+ if (obj && obj.resource) {
20
+ this.resource = obj.resource;
21
+ }
22
+ };
23
+
24
+ Img.componentName = 'Img';
25
+
26
+ __decorate([type('string')], Img.prototype, "resource", void 0);
27
+
28
+ return Img;
29
+ }(Component);
30
+
31
+ var Img$3 = Img$2;
32
+ resource.registerInstance(RESOURCE_TYPE.IMAGE, function (_a) {
33
+ var _b = _a.data,
34
+ data = _b === void 0 ? {} : _b;
35
+ var image = data.image;
36
+
37
+ if (image) {
38
+ var texture = Texture.from(image);
39
+ return texture;
40
+ }
41
+
42
+ return;
43
+ });
44
+ resource.registerDestroy(RESOURCE_TYPE.IMAGE, function (_a) {
45
+ var instance = _a.instance;
46
+
47
+ if (instance) {
48
+ instance.destroy(true);
49
+ }
50
+ });
51
+
52
+ var Img = function (_super) {
53
+ __extends(Img, _super);
54
+
55
+ function Img() {
56
+ var _this = _super !== null && _super.apply(this, arguments) || this;
57
+
58
+ _this.name = 'Img';
59
+ _this.imgs = {};
60
+ return _this;
61
+ }
62
+
63
+ Img.prototype.init = function () {
64
+ this.renderSystem = this.game.getSystem(RendererSystem);
65
+ this.renderSystem.rendererManager.register(this);
66
+ };
67
+
68
+ Img.prototype.rendererUpdate = function (gameObject) {
69
+ var _a = gameObject.transform.size,
70
+ width = _a.width,
71
+ height = _a.height;
72
+
73
+ if (this.imgs[gameObject.id]) {
74
+ this.imgs[gameObject.id].sprite.width = width;
75
+ this.imgs[gameObject.id].sprite.height = height;
76
+ }
77
+ };
78
+
79
+ Img.prototype.componentChanged = function (changed) {
80
+ var _a, _b;
81
+
82
+ return __awaiter(this, void 0, void 0, function () {
83
+ var component, sprite, asyncId, instance, asyncId, instance, sprite;
84
+ return __generator(this, function (_c) {
85
+ switch (_c.label) {
86
+ case 0:
87
+ if (!(changed.componentName === 'Img')) return [3, 5];
88
+ component = changed.component;
89
+ if (!(changed.type === OBSERVER_TYPE.ADD)) return [3, 2];
90
+ sprite = new Sprite(null);
91
+ this.imgs[changed.gameObject.id] = sprite;
92
+ this.containerManager.getContainer(changed.gameObject.id).addChildAt(sprite.sprite, 0);
93
+ asyncId = this.increaseAsyncId(changed.gameObject.id);
94
+ return [4, resource.getResource(component.resource)];
95
+
96
+ case 1:
97
+ instance = _c.sent().instance;
98
+ if (!this.validateAsyncId(changed.gameObject.id, asyncId)) return [2];
99
+
100
+ if (!instance) {
101
+ console.error("GameObject:" + changed.gameObject.name + "'s Img resource load error");
102
+ }
103
+
104
+ this.imgs[changed.gameObject.id].image = instance;
105
+ return [3, 5];
106
+
107
+ case 2:
108
+ if (!(changed.type === OBSERVER_TYPE.CHANGE)) return [3, 4];
109
+ asyncId = this.increaseAsyncId(changed.gameObject.id);
110
+ return [4, resource.getResource(component.resource)];
111
+
112
+ case 3:
113
+ instance = _c.sent().instance;
114
+ if (!this.validateAsyncId(changed.gameObject.id, asyncId)) return [2];
115
+
116
+ if (!instance) {
117
+ console.error("GameObject:" + changed.gameObject.name + "'s Img resource load error");
118
+ }
119
+
120
+ this.imgs[changed.gameObject.id].image = instance;
121
+ return [3, 5];
122
+
123
+ case 4:
124
+ if (changed.type === OBSERVER_TYPE.REMOVE) {
125
+ this.increaseAsyncId(changed.gameObject.id);
126
+ sprite = this.imgs[changed.gameObject.id];
127
+ if (!sprite) return [2];
128
+ (_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);
129
+ sprite.sprite.destroy({
130
+ children: true
131
+ });
132
+ delete this.imgs[changed.gameObject.id];
133
+ }
134
+
135
+ _c.label = 5;
136
+
137
+ case 5:
138
+ return [2];
139
+ }
140
+ });
141
+ });
142
+ };
143
+
144
+ Img.prototype.destroy = function () {
145
+ var _a, _b;
146
+
147
+ for (var key in this.imgs) {
148
+ var sprite = this.imgs[key];
149
+ (_b = (_a = this.containerManager) === null || _a === void 0 ? void 0 : _a.getContainer(parseInt(key))) === null || _b === void 0 ? void 0 : _b.removeChild(sprite.sprite);
150
+ sprite.sprite.destroy({
151
+ children: true
152
+ });
153
+ delete this.imgs[key];
154
+ }
155
+ };
156
+
157
+ Img.systemName = 'Img';
158
+ Img = __decorate([decorators.componentObserver({
159
+ Img: [{
160
+ prop: ['resource'],
161
+ deep: false
162
+ }]
163
+ })], Img);
164
+ return Img;
165
+ }(Renderer);
166
+
167
+ var Img$1 = Img;
168
+ export { Img$3 as Img, Img$1 as ImgSystem };
@@ -188,6 +188,15 @@ var Img = (function (_super) {
188
188
  });
189
189
  });
190
190
  };
191
+ Img.prototype.destroy = function () {
192
+ var _a, _b;
193
+ for (var key in this.imgs) {
194
+ var sprite = this.imgs[key];
195
+ (_b = (_a = this.containerManager) === null || _a === void 0 ? void 0 : _a.getContainer(parseInt(key))) === null || _b === void 0 ? void 0 : _b.removeChild(sprite.sprite);
196
+ sprite.sprite.destroy({ children: true });
197
+ delete this.imgs[key];
198
+ }
199
+ };
191
200
  Img.systemName = 'Img';
192
201
  Img = __decorate([
193
202
  eva_js.decorators.componentObserver({
@@ -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"),i=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])})(e,t)};function s(e,t){function r(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function c(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 c=e.length-1;c>=0;c--)(i=e[c])&&(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:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){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,c])}}}var u=function(t){function r(){var e=null!==t&&t.apply(this,arguments)||this;return e.resource="",e}return s(r,t),r.prototype.init=function(e){e&&e.resource&&(this.resource=e.resource)},r.componentName="Img",c([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 i.Texture.from(r)})),t.resource.registerDestroy(t.RESOURCE_TYPE.IMAGE,(function(e){var t=e.instance;t&&t.destroy(!0)}));var l=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="Img",t.imgs={},t}return s(i,e),i.prototype.init=function(){this.renderSystem=this.game.getSystem(r.RendererSystem),this.renderSystem.rendererManager.register(this)},i.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)},i.prototype.componentChanged=function(e){var r,i,o,s,c,u;return o=this,s=void 0,u=function(){var o,s,c,u;return a(this,(function(a){switch(a.label){case 0:return"Img"!==e.componentName?[3,5]:(o=e.component,e.type!==t.OBSERVER_TYPE.ADD?[3,2]:(u=new n.Sprite(null),this.imgs[e.gameObject.id]=u,this.containerManager.getContainer(e.gameObject.id).addChildAt(u.sprite,0),s=this.increaseAsyncId(e.gameObject.id),[4,t.resource.getResource(o.resource)]));case 1:return c=a.sent().instance,this.validateAsyncId(e.gameObject.id,s)?(c||console.error("GameObject:"+e.gameObject.name+"'s Img resource load error"),this.imgs[e.gameObject.id].image=c,[3,5]):[2];case 2:return e.type!==t.OBSERVER_TYPE.CHANGE?[3,4]:(s=this.increaseAsyncId(e.gameObject.id),[4,t.resource.getResource(o.resource)]);case 3:return c=a.sent().instance,this.validateAsyncId(e.gameObject.id,s)?(c||console.error("GameObject:"+e.gameObject.name+"'s Img resource load error"),this.imgs[e.gameObject.id].image=c,[3,5]):[2];case 4:if(e.type===t.OBSERVER_TYPE.REMOVE){if(this.increaseAsyncId(e.gameObject.id),!(u=this.imgs[e.gameObject.id]))return[2];null===(i=null===(r=this.containerManager)||void 0===r?void 0:r.getContainer(e.gameObject.id))||void 0===i||i.removeChild(u.sprite),u.sprite.destroy({children:!0}),delete this.imgs[e.gameObject.id]}a.label=5;case 5:return[2]}}))},new((c=void 0)||(c=Promise))((function(e,t){function r(e){try{i(u.next(e))}catch(e){t(e)}}function n(e){try{i(u.throw(e))}catch(e){t(e)}}function i(t){t.done?e(t.value):new c((function(e){e(t.value)})).then(r,n)}i((u=u.apply(o,s||[])).next())}))},i.systemName="Img",i=c([t.decorators.componentObserver({Img:[{prop:["resource"],deep:!1}]})],i)}(r.Renderer);exports.Img=u,exports.ImgSystem=l;
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"),i=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 s(e,t){function r(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function a(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 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])}}}var u=function(t){function r(){var e=null!==t&&t.apply(this,arguments)||this;return e.resource="",e}return s(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),l=u;t.resource.registerInstance(t.RESOURCE_TYPE.IMAGE,(function(e){var t=e.data,r=(void 0===t?{}:t).image;if(r)return i.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 i(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="Img",t.imgs={},t}return s(i,e),i.prototype.init=function(){this.renderSystem=this.game.getSystem(r.RendererSystem),this.renderSystem.rendererManager.register(this)},i.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)},i.prototype.componentChanged=function(e){var r,i,o,s,a,u;return o=this,s=void 0,u=function(){var o,s,a,u;return c(this,(function(c){switch(c.label){case 0:return"Img"!==e.componentName?[3,5]:(o=e.component,e.type!==t.OBSERVER_TYPE.ADD?[3,2]:(u=new n.Sprite(null),this.imgs[e.gameObject.id]=u,this.containerManager.getContainer(e.gameObject.id).addChildAt(u.sprite,0),s=this.increaseAsyncId(e.gameObject.id),[4,t.resource.getResource(o.resource)]));case 1:return a=c.sent().instance,this.validateAsyncId(e.gameObject.id,s)?(a||console.error("GameObject:"+e.gameObject.name+"'s Img resource load error"),this.imgs[e.gameObject.id].image=a,[3,5]):[2];case 2:return e.type!==t.OBSERVER_TYPE.CHANGE?[3,4]:(s=this.increaseAsyncId(e.gameObject.id),[4,t.resource.getResource(o.resource)]);case 3:return a=c.sent().instance,this.validateAsyncId(e.gameObject.id,s)?(a||console.error("GameObject:"+e.gameObject.name+"'s Img resource load error"),this.imgs[e.gameObject.id].image=a,[3,5]):[2];case 4:if(e.type===t.OBSERVER_TYPE.REMOVE){if(this.increaseAsyncId(e.gameObject.id),!(u=this.imgs[e.gameObject.id]))return[2];null===(i=null===(r=this.containerManager)||void 0===r?void 0:r.getContainer(e.gameObject.id))||void 0===i||i.removeChild(u.sprite),u.sprite.destroy({children:!0}),delete this.imgs[e.gameObject.id]}c.label=5;case 5:return[2]}}))},new((a=void 0)||(a=Promise))((function(e,t){function r(e){try{i(u.next(e))}catch(e){t(e)}}function n(e){try{i(u.throw(e))}catch(e){t(e)}}function i(t){t.done?e(t.value):new a((function(e){e(t.value)})).then(r,n)}i((u=u.apply(o,s||[])).next())}))},i.prototype.destroy=function(){var e,t;for(var r in this.imgs){var n=this.imgs[r];null===(t=null===(e=this.containerManager)||void 0===e?void 0:e.getContainer(parseInt(r)))||void 0===t||t.removeChild(n.sprite),n.sprite.destroy({children:!0}),delete this.imgs[r]}},i.systemName="Img",i=a([t.decorators.componentObserver({Img:[{prop:["resource"],deep:!1}]})],i)}(r.Renderer);exports.Img=l,exports.ImgSystem=p;
@@ -29,6 +29,7 @@ export declare class ImgSystem extends Renderer {
29
29
  init(): void;
30
30
  rendererUpdate(gameObject: GameObject): void;
31
31
  componentChanged(changed: ComponentChanged): Promise<void>;
32
+ destroy(): void;
32
33
  }
33
34
 
34
35
  export { }
@@ -184,6 +184,15 @@ var Img = (function (_super) {
184
184
  });
185
185
  });
186
186
  };
187
+ Img.prototype.destroy = function () {
188
+ var _a, _b;
189
+ for (var key in this.imgs) {
190
+ var sprite = this.imgs[key];
191
+ (_b = (_a = this.containerManager) === null || _a === void 0 ? void 0 : _a.getContainer(parseInt(key))) === null || _b === void 0 ? void 0 : _b.removeChild(sprite.sprite);
192
+ sprite.sprite.destroy({ children: true });
193
+ delete this.imgs[key];
194
+ }
195
+ };
187
196
  Img.systemName = 'Img';
188
197
  Img = __decorate([
189
198
  decorators.componentObserver({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eva/plugin-renderer-img",
3
- "version": "1.2.8-fix.1",
3
+ "version": "1.2.8",
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.8-fix.1",
23
- "@eva/renderer-adapter": "1.2.8-fix.1",
24
- "@eva/eva.js": "1.2.8-fix.1",
22
+ "@eva/plugin-renderer": "1.2.8",
23
+ "@eva/renderer-adapter": "1.2.8",
24
+ "@eva/eva.js": "1.2.8",
25
25
  "pixi.js": "^4.8.7"
26
26
  }
27
27
  }