@eva/plugin-renderer-img 1.2.1-type.2 → 1.2.2-alpha.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.
@@ -1,8 +1,8 @@
1
- this.EVA = this.EVA || {};
2
- this.EVA.plugin = this.EVA.plugin || {};
3
- this.EVA.plugin.renderer = this.EVA.plugin.renderer || {};
1
+ window.EVA = window.EVA || {};
2
+ window.EVA.plugin = window.EVA.plugin || {};
3
+ window.EVA.plugin.renderer = window.EVA.plugin.renderer || {};
4
4
 
5
- this.EVA.plugin.renderer.img = function (exports, eva_js, pluginRenderer, rendererAdapter, pixi_js) {
5
+ var _EVA_IIFE_img = function (exports, eva_js, pluginRenderer, rendererAdapter, pixi_js) {
6
6
  'use strict';
7
7
 
8
8
  var _extendStatics = function extendStatics(d, b) {
@@ -348,3 +348,5 @@ this.EVA.plugin.renderer.img = function (exports, eva_js, pluginRenderer, render
348
348
  });
349
349
  return exports;
350
350
  }({}, EVA, EVA.plugin.renderer, EVA.rendererAdapter, PIXI);
351
+
352
+ window.EVA.plugin.renderer.img = window.EVA.plugin.renderer.img || _EVA_IIFE_img;
@@ -1 +1 @@
1
- this.EVA=this.EVA||{},this.EVA.plugin=this.EVA.plugin||{},this.EVA.plugin.renderer=this.EVA.plugin.renderer||{},this.EVA.plugin.renderer.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])},i(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 u(e,t,r,n){return new(r||(r=Promise))((function(o,i){function c(e){try{u(n.next(e))}catch(e){i(e)}}function s(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(c,s)}u((n=n.apply(e,t||[])).next())}))}function a(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),f=l;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 h=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 u(this,void 0,void 0,(function(){var r,o,i,c;return a(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),g=h;return e.Img=f,e.ImgSystem=g,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){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);
@@ -0,0 +1,146 @@
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
+ return __awaiter(this, void 0, void 0, function () {
81
+ var component, sprite_1, instance, sprite;
82
+ return __generator(this, function (_a) {
83
+ switch (_a.label) {
84
+ case 0:
85
+ if (!(changed.componentName === 'Img')) return [3, 4];
86
+ component = changed.component;
87
+ if (!(changed.type === OBSERVER_TYPE.ADD)) return [3, 1];
88
+ sprite_1 = new Sprite(null);
89
+ resource.getResource(component.resource).then(function (_a) {
90
+ var instance = _a.instance;
91
+
92
+ if (!instance) {
93
+ console.error("GameObject:" + changed.gameObject.name + "'s Img resource load error");
94
+ }
95
+
96
+ sprite_1.image = instance;
97
+ });
98
+ this.imgs[changed.gameObject.id] = sprite_1;
99
+ this.containerManager.getContainer(changed.gameObject.id).addChildAt(sprite_1.sprite, 0);
100
+ return [3, 4];
101
+
102
+ case 1:
103
+ if (!(changed.type === OBSERVER_TYPE.CHANGE)) return [3, 3];
104
+ return [4, resource.getResource(component.resource)];
105
+
106
+ case 2:
107
+ instance = _a.sent().instance;
108
+
109
+ if (!instance) {
110
+ console.error("GameObject:" + changed.gameObject.name + "'s Img resource load error");
111
+ }
112
+
113
+ this.imgs[changed.gameObject.id].image = instance;
114
+ return [3, 4];
115
+
116
+ case 3:
117
+ if (changed.type === OBSERVER_TYPE.REMOVE) {
118
+ sprite = this.imgs[changed.gameObject.id];
119
+ this.containerManager.getContainer(changed.gameObject.id).removeChild(sprite.sprite);
120
+ sprite.sprite.destroy({
121
+ children: true
122
+ });
123
+ delete this.imgs[changed.gameObject.id];
124
+ }
125
+
126
+ _a.label = 4;
127
+
128
+ case 4:
129
+ return [2];
130
+ }
131
+ });
132
+ });
133
+ };
134
+
135
+ Img.systemName = 'Img';
136
+ Img = __decorate([decorators.componentObserver({
137
+ Img: [{
138
+ prop: ['resource'],
139
+ deep: false
140
+ }]
141
+ })], Img);
142
+ return Img;
143
+ }(Renderer);
144
+
145
+ var Img$1 = Img;
146
+ export { Img$3 as Img, Img$1 as ImgSystem };
@@ -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])},i(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),p=u;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 l=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=p,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"),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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eva/plugin-renderer-img",
3
- "version": "1.2.1-type.2",
3
+ "version": "1.2.2-alpha.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.1-type.2",
23
- "@eva/renderer-adapter": "1.2.1-type.2",
24
- "@eva/eva.js": "1.2.1-type.2",
22
+ "@eva/plugin-renderer": "1.2.2-alpha.2",
23
+ "@eva/renderer-adapter": "1.2.2-alpha.2",
24
+ "@eva/eva.js": "1.2.2-alpha.2",
25
25
  "pixi.js": "^4.8.7"
26
26
  }
27
27
  }