@eva/plugin-renderer-img 1.1.1-fix.0 → 1.1.1-fix.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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/renderer-adapter"),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])})(e,t)};function i(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 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 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: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 s=function(t){function r(){var e=null!==t&&t.apply(this,arguments)||this;return e.resource="",e}return i(r,t),r.prototype.init=function(e){e&&e.resource&&(this.resource=e.resource)},r.componentName="Img",c([e.decorators.IDEProp],r.prototype,"resource",void 0),r}(e.Component);e.resource.registerInstance(e.RESOURCE_TYPE.IMAGE,(function(e){var t=e.data,r=(void 0===t?{}:t).image;if(r)return n.Texture.from(r)})),e.resource.registerDestroy(e.RESOURCE_TYPE.IMAGE,(function(e){var t=e.instance;t&&t.destroy(!0)}));var u=function(n){function o(){var e=null!==n&&n.apply(this,arguments)||this;return e.name="Img",e.imgs={},e}return i(o,n),o.prototype.init=function(){this.renderSystem=this.game.getSystem(t.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(t){return n=this,o=void 0,c=function(){var n,o,i,c;return a(this,(function(a){switch(a.label){case 0:return"Img"!==t.componentName?[3,4]:(n=t.component,t.type!==e.OBSERVER_TYPE.ADD?[3,1]:(o=new r.Sprite(null),e.resource.getResource(n.resource).then((function(e){var r=e.instance;r||console.error("GameObject:"+t.gameObject.name+"'s Img resource load error"),o.image=r})),this.imgs[t.gameObject.id]=o,this.containerManager.getContainer(t.gameObject.id).addChildAt(o.sprite,0),[3,4]));case 1:return t.type!==e.OBSERVER_TYPE.CHANGE?[3,3]:[4,e.resource.getResource(n.resource)];case 2:return(i=a.sent().instance)||console.error("GameObject:"+t.gameObject.name+"'s Img resource load error"),this.imgs[t.gameObject.id].image=i,[3,4];case 3:t.type===e.OBSERVER_TYPE.REMOVE&&(c=this.imgs[t.gameObject.id],this.containerManager.getContainer(t.gameObject.id).removeChild(c.sprite),c.sprite.destroy({children:!0}),delete this.imgs[t.gameObject.id]),a.label=4;case 4:return[2]}}))},new((i=void 0)||(i=Promise))((function(e,t){function r(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(r,a)}s((c=c.apply(n,o||[])).next())}));var n,o,i,c},o.systemName="Img",o=c([e.decorators.componentObserver({Img:[{prop:["resource"],deep:!1}]})],o)}(t.Renderer);exports.Img=s,exports.ImgSystem=u;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@eva/eva.js"),t=require("@eva/plugin-renderer"),r=require("@eva/renderer-adapter"),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 i(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 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 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: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 s=function(t){function r(){var e=null!==t&&t.apply(this,arguments)||this;return e.resource="",e}return i(r,t),r.prototype.init=function(e){e&&e.resource&&(this.resource=e.resource)},r.componentName="Img",c([e.decorators.IDEProp],r.prototype,"resource",void 0),r}(e.Component),u=s;e.resource.registerInstance(e.RESOURCE_TYPE.IMAGE,(function(e){var t=e.data,r=(void 0===t?{}:t).image;if(r)return n.Texture.from(r)})),e.resource.registerDestroy(e.RESOURCE_TYPE.IMAGE,(function(e){var t=e.instance;t&&t.destroy(!0)}));var p=function(n){function o(){var e=null!==n&&n.apply(this,arguments)||this;return e.name="Img",e.imgs={},e}return i(o,n),o.prototype.init=function(){this.renderSystem=this.game.getSystem(t.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(t){return n=this,o=void 0,c=function(){var n,o,i,c;return a(this,(function(a){switch(a.label){case 0:return"Img"!==t.componentName?[3,4]:(n=t.component,t.type!==e.OBSERVER_TYPE.ADD?[3,1]:(o=new r.Sprite(null),e.resource.getResource(n.resource).then((function(e){var r=e.instance;r||console.error("GameObject:"+t.gameObject.name+"'s Img resource load error"),o.image=r})),this.imgs[t.gameObject.id]=o,this.containerManager.getContainer(t.gameObject.id).addChildAt(o.sprite,0),[3,4]));case 1:return t.type!==e.OBSERVER_TYPE.CHANGE?[3,3]:[4,e.resource.getResource(n.resource)];case 2:return(i=a.sent().instance)||console.error("GameObject:"+t.gameObject.name+"'s Img resource load error"),this.imgs[t.gameObject.id].image=i,[3,4];case 3:t.type===e.OBSERVER_TYPE.REMOVE&&(c=this.imgs[t.gameObject.id],this.containerManager.getContainer(t.gameObject.id).removeChild(c.sprite),c.sprite.destroy({children:!0}),delete this.imgs[t.gameObject.id]),a.label=4;case 4:return[2]}}))},new((i=void 0)||(i=Promise))((function(e,t){function r(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(r,a)}s((c=c.apply(n,o||[])).next())}));var n,o,i,c},o.systemName="Img",o=c([e.decorators.componentObserver({Img:[{prop:["resource"],deep:!1}]})],o)}(t.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.1.1-fix.0",
3
+ "version": "1.1.1-fix.1",
4
4
  "description": "@eva/plugin-renderer-img",
5
5
  "main": "index.js",
6
6
  "module": "dist/plugin-renderer-img.esm.js",
@@ -18,9 +18,9 @@
18
18
  "license": "MIT",
19
19
  "homepage": "https://eva.js.org",
20
20
  "dependencies": {
21
- "@eva/plugin-renderer": "1.1.1-fix.0",
22
- "@eva/renderer-adapter": "1.1.1-fix.0",
23
- "@eva/eva.js": "1.1.1-fix.0",
21
+ "@eva/plugin-renderer": "1.1.1-fix.1",
22
+ "@eva/renderer-adapter": "1.1.1-fix.1",
23
+ "@eva/eva.js": "1.1.1-fix.1",
24
24
  "pixi.js": "^4.8.7"
25
25
  }
26
26
  }
@@ -1,193 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@eva/eva.js'), require('@eva/plugin-renderer'), require('@eva/renderer-adapter'), require('pixi.js')) :
3
- typeof define === 'function' && define.amd ? define(['exports', '@eva/eva.js', '@eva/plugin-renderer', '@eva/renderer-adapter', 'pixi.js'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.EVA = global.EVA || {}, global.EVA.plugin = global.EVA.plugin || {}, global.EVA.plugin.renderer = global.EVA.plugin.renderer || {}, global.EVA.plugin.renderer.img = {}), global.EVA, global.EVA.plugin.renderer, global.EVA.rendererAdapter, global.PIXI));
5
- }(this, (function (exports, eva_js, pluginRenderer, rendererAdapter, pixi_js) { 'use strict';
6
-
7
- /*! *****************************************************************************
8
- Copyright (c) Microsoft Corporation.
9
-
10
- Permission to use, copy, modify, and/or distribute this software for any
11
- purpose with or without fee is hereby granted.
12
-
13
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
14
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
15
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
16
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
17
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
18
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19
- PERFORMANCE OF THIS SOFTWARE.
20
- ***************************************************************************** */
21
- /* global Reflect, Promise */
22
-
23
- var extendStatics = function(d, b) {
24
- extendStatics = Object.setPrototypeOf ||
25
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
26
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
27
- return extendStatics(d, b);
28
- };
29
-
30
- function __extends(d, b) {
31
- extendStatics(d, b);
32
- function __() { this.constructor = d; }
33
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
34
- }
35
-
36
- function __decorate(decorators, target, key, desc) {
37
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
38
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
39
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
40
- return c > 3 && r && Object.defineProperty(target, key, r), r;
41
- }
42
-
43
- function __awaiter(thisArg, _arguments, P, generator) {
44
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
45
- return new (P || (P = Promise))(function (resolve, reject) {
46
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
47
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
48
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
49
- step((generator = generator.apply(thisArg, _arguments || [])).next());
50
- });
51
- }
52
-
53
- function __generator(thisArg, body) {
54
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
55
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
56
- function verb(n) { return function (v) { return step([n, v]); }; }
57
- function step(op) {
58
- if (f) throw new TypeError("Generator is already executing.");
59
- while (_) try {
60
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
61
- if (y = 0, t) op = [op[0] & 2, t.value];
62
- switch (op[0]) {
63
- case 0: case 1: t = op; break;
64
- case 4: _.label++; return { value: op[1], done: false };
65
- case 5: _.label++; y = op[1]; op = [0]; continue;
66
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
67
- default:
68
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
69
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
70
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
71
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
72
- if (t[2]) _.ops.pop();
73
- _.trys.pop(); continue;
74
- }
75
- op = body.call(thisArg, _);
76
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
77
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
78
- }
79
- }
80
-
81
- var Img$2 = (function (_super) {
82
- __extends(Img, _super);
83
- function Img() {
84
- var _this = _super !== null && _super.apply(this, arguments) || this;
85
- _this.resource = '';
86
- return _this;
87
- }
88
- Img.prototype.init = function (obj) {
89
- if (obj && obj.resource) {
90
- this.resource = obj.resource;
91
- }
92
- };
93
- Img.componentName = 'Img';
94
- __decorate([
95
- eva_js.decorators.IDEProp
96
- ], Img.prototype, "resource", void 0);
97
- return Img;
98
- }(eva_js.Component));
99
- var Img$3 = Img$2;
100
-
101
- eva_js.resource.registerInstance(eva_js.RESOURCE_TYPE.IMAGE, function (_a) {
102
- var _b = _a.data, data = _b === void 0 ? {} : _b;
103
- var image = data.image;
104
- if (image) {
105
- var texture = pixi_js.Texture.from(image);
106
- return texture;
107
- }
108
- return;
109
- });
110
- eva_js.resource.registerDestroy(eva_js.RESOURCE_TYPE.IMAGE, function (_a) {
111
- var instance = _a.instance;
112
- if (instance) {
113
- instance.destroy(true);
114
- }
115
- });
116
- var Img = (function (_super) {
117
- __extends(Img, _super);
118
- function Img() {
119
- var _this = _super !== null && _super.apply(this, arguments) || this;
120
- _this.name = 'Img';
121
- _this.imgs = {};
122
- return _this;
123
- }
124
- Img.prototype.init = function () {
125
- this.renderSystem = this.game.getSystem(pluginRenderer.RendererSystem);
126
- this.renderSystem.rendererManager.register(this);
127
- };
128
- Img.prototype.rendererUpdate = function (gameObject) {
129
- var _a = gameObject.transform.size, width = _a.width, height = _a.height;
130
- if (this.imgs[gameObject.id]) {
131
- this.imgs[gameObject.id].sprite.width = width;
132
- this.imgs[gameObject.id].sprite.height = height;
133
- }
134
- };
135
- Img.prototype.componentChanged = function (changed) {
136
- return __awaiter(this, void 0, void 0, function () {
137
- var component, sprite_1, instance, sprite;
138
- return __generator(this, function (_a) {
139
- switch (_a.label) {
140
- case 0:
141
- if (!(changed.componentName === 'Img')) return [3, 4];
142
- component = changed.component;
143
- if (!(changed.type === eva_js.OBSERVER_TYPE.ADD)) return [3, 1];
144
- sprite_1 = new rendererAdapter.Sprite(null);
145
- eva_js.resource.getResource(component.resource).then(function (_a) {
146
- var instance = _a.instance;
147
- if (!instance) {
148
- console.error("GameObject:" + changed.gameObject.name + "'s Img resource load error");
149
- }
150
- sprite_1.image = instance;
151
- });
152
- this.imgs[changed.gameObject.id] = sprite_1;
153
- this.containerManager.getContainer(changed.gameObject.id).addChildAt(sprite_1.sprite, 0);
154
- return [3, 4];
155
- case 1:
156
- if (!(changed.type === eva_js.OBSERVER_TYPE.CHANGE)) return [3, 3];
157
- return [4, eva_js.resource.getResource(component.resource)];
158
- case 2:
159
- instance = (_a.sent()).instance;
160
- if (!instance) {
161
- console.error("GameObject:" + changed.gameObject.name + "'s Img resource load error");
162
- }
163
- this.imgs[changed.gameObject.id].image = instance;
164
- return [3, 4];
165
- case 3:
166
- if (changed.type === eva_js.OBSERVER_TYPE.REMOVE) {
167
- sprite = this.imgs[changed.gameObject.id];
168
- this.containerManager.getContainer(changed.gameObject.id).removeChild(sprite.sprite);
169
- sprite.sprite.destroy({ children: true });
170
- delete this.imgs[changed.gameObject.id];
171
- }
172
- _a.label = 4;
173
- case 4: return [2];
174
- }
175
- });
176
- });
177
- };
178
- Img.systemName = 'Img';
179
- Img = __decorate([
180
- eva_js.decorators.componentObserver({
181
- Img: [{ prop: ['resource'], deep: false }],
182
- })
183
- ], Img);
184
- return Img;
185
- }(pluginRenderer.Renderer));
186
- var Img$1 = Img;
187
-
188
- exports.Img = Img$3;
189
- exports.ImgSystem = Img$1;
190
-
191
- Object.defineProperty(exports, '__esModule', { value: true });
192
-
193
- })));
@@ -1 +0,0 @@
1
- var e,r;e=this,r=function(e,r,t,n,o){"use strict";var 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 a(e,r){function t(){this.constructor=e}i(e,r),e.prototype=null===r?Object.create(r):(t.prototype=r.prototype,new t)}function s(e,r,t,n){var o,i=arguments.length,a=i<3?r:null===n?n=Object.getOwnPropertyDescriptor(r,t):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,r,t,n);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(r,t,a):o(r,t))||a);return i>3&&a&&Object.defineProperty(r,t,a),a}function c(e,r,t,n){return new(t||(t=Promise))((function(o,i){function a(e){try{c(n.next(e))}catch(e){i(e)}}function s(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var r;e.done?o(e.value):(r=e.value,r instanceof t?r:new t((function(e){e(r)}))).then(a,s)}c((n=n.apply(e,r||[])).next())}))}function u(e,r){var t,n,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(t)throw new TypeError("Generator is already executing.");for(;a;)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 a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).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=r.call(e,a)}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,s])}}}var p=function(e){function t(){var r=null!==e&&e.apply(this,arguments)||this;return r.resource="",r}return a(t,e),t.prototype.init=function(e){e&&e.resource&&(this.resource=e.resource)},t.componentName="Img",s([r.decorators.IDEProp],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 l=function(e){function o(){var r=null!==e&&e.apply(this,arguments)||this;return r.name="Img",r.imgs={},r}return a(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){return c(this,void 0,void 0,(function(){var t,o,i,a;return u(this,(function(s){switch(s.label){case 0:return"Img"!==e.componentName?[3,4]:(t=e.component,e.type!==r.OBSERVER_TYPE.ADD?[3,1]:(o=new n.Sprite(null),r.resource.getResource(t.resource).then((function(r){var t=r.instance;t||console.error("GameObject:"+e.gameObject.name+"'s Img resource load error"),o.image=t})),this.imgs[e.gameObject.id]=o,this.containerManager.getContainer(e.gameObject.id).addChildAt(o.sprite,0),[3,4]));case 1:return e.type!==r.OBSERVER_TYPE.CHANGE?[3,3]:[4,r.resource.getResource(t.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===r.OBSERVER_TYPE.REMOVE&&(a=this.imgs[e.gameObject.id],this.containerManager.getContainer(e.gameObject.id).removeChild(a.sprite),a.sprite.destroy({children:!0}),delete this.imgs[e.gameObject.id]),s.label=4;case 4:return[2]}}))}))},o.systemName="Img",o=s([r.decorators.componentObserver({Img:[{prop:["resource"],deep:!1}]})],o)}(t.Renderer);e.Img=p,e.ImgSystem=l,Object.defineProperty(e,"__esModule",{value:!0})},"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("@eva/eva.js"),require("@eva/plugin-renderer"),require("@eva/renderer-adapter"),require("pixi.js")):"function"==typeof define&&define.amd?define(["exports","@eva/eva.js","@eva/plugin-renderer","@eva/renderer-adapter","pixi.js"],r):r(((e="undefined"!=typeof globalThis?globalThis:e||self).EVA=e.EVA||{},e.EVA.plugin=e.EVA.plugin||{},e.EVA.plugin.renderer=e.EVA.plugin.renderer||{},e.EVA.plugin.renderer.img={}),e.EVA,e.EVA.plugin.renderer,e.EVA.rendererAdapter,e.PIXI);
@@ -1,115 +0,0 @@
1
- import { __extends, __decorate, __awaiter, __generator } from 'tslib';
2
- import { type } from '@eva/inspector-decorator/dist/miniprogram';
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
- function Img() {
11
- var _this = _super !== null && _super.apply(this, arguments) || this;
12
- _this.resource = '';
13
- return _this;
14
- }
15
- Img.prototype.init = function (obj) {
16
- if (obj && obj.resource) {
17
- this.resource = obj.resource;
18
- }
19
- };
20
- Img.componentName = 'Img';
21
- __decorate([
22
- type('string')
23
- ], Img.prototype, "resource", void 0);
24
- return Img;
25
- }(Component));
26
- var Img$3 = Img$2;
27
-
28
- resource.registerInstance(RESOURCE_TYPE.IMAGE, function (_a) {
29
- var _b = _a.data, data = _b === void 0 ? {} : _b;
30
- var image = data.image;
31
- if (image) {
32
- var texture = Texture.from(image);
33
- return texture;
34
- }
35
- return;
36
- });
37
- resource.registerDestroy(RESOURCE_TYPE.IMAGE, function (_a) {
38
- var instance = _a.instance;
39
- if (instance) {
40
- instance.destroy(true);
41
- }
42
- });
43
- var Img = (function (_super) {
44
- __extends(Img, _super);
45
- function Img() {
46
- var _this = _super !== null && _super.apply(this, arguments) || this;
47
- _this.name = 'Img';
48
- _this.imgs = {};
49
- return _this;
50
- }
51
- Img.prototype.init = function () {
52
- this.renderSystem = this.game.getSystem(RendererSystem);
53
- this.renderSystem.rendererManager.register(this);
54
- };
55
- Img.prototype.rendererUpdate = function (gameObject) {
56
- var _a = gameObject.transform.size, width = _a.width, height = _a.height;
57
- if (this.imgs[gameObject.id]) {
58
- this.imgs[gameObject.id].sprite.width = width;
59
- this.imgs[gameObject.id].sprite.height = height;
60
- }
61
- };
62
- Img.prototype.componentChanged = function (changed) {
63
- return __awaiter(this, void 0, void 0, function () {
64
- var component, sprite_1, instance, sprite;
65
- return __generator(this, function (_a) {
66
- switch (_a.label) {
67
- case 0:
68
- if (!(changed.componentName === 'Img')) return [3, 4];
69
- component = changed.component;
70
- if (!(changed.type === OBSERVER_TYPE.ADD)) return [3, 1];
71
- sprite_1 = new Sprite(null);
72
- resource.getResource(component.resource).then(function (_a) {
73
- var instance = _a.instance;
74
- if (!instance) {
75
- console.error("GameObject:" + changed.gameObject.name + "'s Img resource load error");
76
- }
77
- sprite_1.image = instance;
78
- });
79
- this.imgs[changed.gameObject.id] = sprite_1;
80
- this.containerManager.getContainer(changed.gameObject.id).addChildAt(sprite_1.sprite, 0);
81
- return [3, 4];
82
- case 1:
83
- if (!(changed.type === OBSERVER_TYPE.CHANGE)) return [3, 3];
84
- return [4, resource.getResource(component.resource)];
85
- case 2:
86
- instance = (_a.sent()).instance;
87
- if (!instance) {
88
- console.error("GameObject:" + changed.gameObject.name + "'s Img resource load error");
89
- }
90
- this.imgs[changed.gameObject.id].image = instance;
91
- return [3, 4];
92
- case 3:
93
- if (changed.type === OBSERVER_TYPE.REMOVE) {
94
- sprite = this.imgs[changed.gameObject.id];
95
- this.containerManager.getContainer(changed.gameObject.id).removeChild(sprite.sprite);
96
- sprite.sprite.destroy({ children: true });
97
- delete this.imgs[changed.gameObject.id];
98
- }
99
- _a.label = 4;
100
- case 4: return [2];
101
- }
102
- });
103
- });
104
- };
105
- Img.systemName = 'Img';
106
- Img = __decorate([
107
- decorators.componentObserver({
108
- Img: [{ prop: ['resource'], deep: false }],
109
- })
110
- ], Img);
111
- return Img;
112
- }(Renderer));
113
- var Img$1 = Img;
114
-
115
- export { Img$3 as Img, Img$1 as ImgSystem };
@@ -1,34 +0,0 @@
1
- import { Component } from '@eva/eva.js';
2
- import { ComponentChanged } from '@eva/eva.js';
3
- import { ContainerManager } from '@eva/plugin-renderer';
4
- import { GameObject } from '@eva/eva.js';
5
- import { Renderer } from '@eva/plugin-renderer';
6
- import { RendererManager } from '@eva/plugin-renderer';
7
- import { RendererSystem } from '@eva/plugin-renderer';
8
- import { Sprite } from '@eva/renderer-adapter';
9
-
10
- export declare class Img extends Component<ImgParams> {
11
- static componentName: string;
12
- resource: string;
13
- init(obj?: ImgParams): void;
14
- }
15
-
16
- export declare interface ImgParams {
17
- resource: string;
18
- }
19
-
20
- export declare class ImgSystem extends Renderer {
21
- static systemName: string;
22
- name: string;
23
- imgs: {
24
- [propName: number]: Sprite;
25
- };
26
- renderSystem: RendererSystem;
27
- rendererManager: RendererManager;
28
- containerManager: ContainerManager;
29
- init(): void;
30
- rendererUpdate(gameObject: GameObject): void;
31
- componentChanged(changed: ComponentChanged): Promise<void>;
32
- }
33
-
34
- export { }