@eva/plugin-renderer-img 1.2.6 → 1.2.7-editor.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.
- package/dist/EVA.plugin.renderer.img.js +146 -34
- package/dist/EVA.plugin.renderer.img.min.js +1 -1
- package/dist/miniprogram.js +32 -24
- package/dist/plugin-renderer-img.cjs.js +33 -21
- package/dist/plugin-renderer-img.cjs.prod.js +1 -1
- package/dist/plugin-renderer-img.esm.js +34 -22
- package/package.json +5 -5
|
@@ -12,7 +12,7 @@ var _EVA_IIFE_img = function (exports, eva_js, pluginRenderer, rendererAdapter,
|
|
|
12
12
|
d.__proto__ = b;
|
|
13
13
|
} || function (d, b) {
|
|
14
14
|
for (var p in b) {
|
|
15
|
-
if (
|
|
15
|
+
if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
|
|
16
16
|
}
|
|
17
17
|
};
|
|
18
18
|
|
|
@@ -20,6 +20,8 @@ var _EVA_IIFE_img = function (exports, eva_js, pluginRenderer, rendererAdapter,
|
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
function __extends(d, b) {
|
|
23
|
+
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
24
|
+
|
|
23
25
|
_extendStatics(d, b);
|
|
24
26
|
|
|
25
27
|
function __() {
|
|
@@ -29,6 +31,22 @@ var _EVA_IIFE_img = function (exports, eva_js, pluginRenderer, rendererAdapter,
|
|
|
29
31
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
30
32
|
}
|
|
31
33
|
|
|
34
|
+
var _assign = function __assign() {
|
|
35
|
+
_assign = Object.assign || function __assign(t) {
|
|
36
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
37
|
+
s = arguments[i];
|
|
38
|
+
|
|
39
|
+
for (var p in s) {
|
|
40
|
+
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return t;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
return _assign.apply(this, arguments);
|
|
48
|
+
};
|
|
49
|
+
|
|
32
50
|
function __decorate(decorators, target, key, desc) {
|
|
33
51
|
var c = arguments.length,
|
|
34
52
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
@@ -39,6 +57,10 @@ var _EVA_IIFE_img = function (exports, eva_js, pluginRenderer, rendererAdapter,
|
|
|
39
57
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
40
58
|
}
|
|
41
59
|
|
|
60
|
+
function __metadata(metadataKey, metadataValue) {
|
|
61
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
62
|
+
}
|
|
63
|
+
|
|
42
64
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
43
65
|
function adopt(value) {
|
|
44
66
|
return value instanceof P ? value : new P(function (resolve) {
|
|
@@ -182,24 +204,106 @@ var _EVA_IIFE_img = function (exports, eva_js, pluginRenderer, rendererAdapter,
|
|
|
182
204
|
}
|
|
183
205
|
}
|
|
184
206
|
|
|
185
|
-
function
|
|
186
|
-
|
|
187
|
-
|
|
207
|
+
var SymbolKeysNotSupportedError = function (_super) {
|
|
208
|
+
__extends(SymbolKeysNotSupportedError, _super);
|
|
209
|
+
|
|
210
|
+
function SymbolKeysNotSupportedError() {
|
|
211
|
+
var _newTarget = this.constructor;
|
|
212
|
+
|
|
213
|
+
var _this = _super.call(this, 'Symbol keys are not supported yet!') || this;
|
|
214
|
+
|
|
215
|
+
Object.setPrototypeOf(_this, _newTarget.prototype);
|
|
216
|
+
return _this;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
return SymbolKeysNotSupportedError;
|
|
220
|
+
}(Error);
|
|
221
|
+
|
|
222
|
+
(function (_super) {
|
|
223
|
+
__extends(StaticGetPropertiesIsNotAFunctionError, _super);
|
|
224
|
+
|
|
225
|
+
function StaticGetPropertiesIsNotAFunctionError() {
|
|
226
|
+
var _newTarget = this.constructor;
|
|
227
|
+
|
|
228
|
+
var _this = _super.call(this, 'getProperties is not a function!') || this;
|
|
229
|
+
|
|
230
|
+
Object.setPrototypeOf(_this, _newTarget.prototype);
|
|
231
|
+
return _this;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
return StaticGetPropertiesIsNotAFunctionError;
|
|
235
|
+
})(Error);
|
|
236
|
+
|
|
237
|
+
var IDE_PROPERTY_METADATA = 'IDE_PROPERTY_METADATA';
|
|
238
|
+
|
|
239
|
+
function transformBasicType(type) {
|
|
240
|
+
if (type === String) {
|
|
241
|
+
return 'string';
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
if (type === Number) {
|
|
245
|
+
return 'number';
|
|
188
246
|
}
|
|
189
247
|
|
|
190
|
-
if (
|
|
191
|
-
|
|
248
|
+
if (type === Boolean) {
|
|
249
|
+
return 'boolean';
|
|
192
250
|
}
|
|
193
251
|
|
|
194
|
-
|
|
195
|
-
return propertyObj;
|
|
252
|
+
return 'unknown';
|
|
196
253
|
}
|
|
197
254
|
|
|
198
|
-
function
|
|
255
|
+
function defineTypes(target, key, options, returnTypeFunction) {
|
|
256
|
+
var type = Reflect.getMetadata('design:type', target, key);
|
|
257
|
+
var isArray = type === Array;
|
|
258
|
+
var str = transformBasicType(type);
|
|
259
|
+
|
|
260
|
+
if (str !== 'unknown') {
|
|
261
|
+
type = str;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
if (returnTypeFunction) {
|
|
265
|
+
var returnType = returnTypeFunction();
|
|
266
|
+
|
|
267
|
+
if (Array.isArray(returnType)) {
|
|
268
|
+
isArray = true;
|
|
269
|
+
type = returnType[0];
|
|
270
|
+
} else {
|
|
271
|
+
type = returnType;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
var properties = Reflect.getMetadata(IDE_PROPERTY_METADATA, target.constructor) || {};
|
|
276
|
+
properties[key] = _assign({
|
|
277
|
+
type: type,
|
|
278
|
+
isArray: isArray
|
|
279
|
+
}, options);
|
|
280
|
+
Reflect.defineMetadata(IDE_PROPERTY_METADATA, properties, target.constructor);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
function getTypeDecoratorParams(returnTypeFuncOrOptions, maybeOptions) {
|
|
284
|
+
if (typeof returnTypeFuncOrOptions === 'function') {
|
|
285
|
+
return {
|
|
286
|
+
returnTypeFunc: returnTypeFuncOrOptions,
|
|
287
|
+
options: maybeOptions || {}
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
return {
|
|
292
|
+
options: returnTypeFuncOrOptions || {}
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
function Field(returnTypeFunction, maybeOptions) {
|
|
199
297
|
return function (target, propertyKey) {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
298
|
+
if (typeof propertyKey === 'symbol') {
|
|
299
|
+
throw new SymbolKeysNotSupportedError();
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
var _a = getTypeDecoratorParams(returnTypeFunction, maybeOptions),
|
|
303
|
+
options = _a.options,
|
|
304
|
+
returnTypeFunc = _a.returnTypeFunc;
|
|
305
|
+
|
|
306
|
+
defineTypes(target, propertyKey, options, returnTypeFunc);
|
|
203
307
|
};
|
|
204
308
|
}
|
|
205
309
|
|
|
@@ -221,7 +325,9 @@ var _EVA_IIFE_img = function (exports, eva_js, pluginRenderer, rendererAdapter,
|
|
|
221
325
|
|
|
222
326
|
Img.componentName = 'Img';
|
|
223
327
|
|
|
224
|
-
__decorate([
|
|
328
|
+
__decorate([Field({
|
|
329
|
+
type: 'resource'
|
|
330
|
+
}), __metadata("design:type", String)], Img.prototype, "resource", void 0);
|
|
225
331
|
|
|
226
332
|
return Img;
|
|
227
333
|
}(eva_js.Component);
|
|
@@ -278,43 +384,49 @@ var _EVA_IIFE_img = function (exports, eva_js, pluginRenderer, rendererAdapter,
|
|
|
278
384
|
var _a, _b;
|
|
279
385
|
|
|
280
386
|
return __awaiter(this, void 0, void 0, function () {
|
|
281
|
-
var component,
|
|
387
|
+
var component, sprite, asyncId, instance, asyncId, instance, sprite;
|
|
282
388
|
return __generator(this, function (_c) {
|
|
283
389
|
switch (_c.label) {
|
|
284
390
|
case 0:
|
|
285
|
-
if (!(changed.componentName === 'Img')) return [3,
|
|
391
|
+
if (!(changed.componentName === 'Img')) return [3, 5];
|
|
286
392
|
component = changed.component;
|
|
287
|
-
if (!(changed.type === eva_js.OBSERVER_TYPE.ADD)) return [3,
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
393
|
+
if (!(changed.type === eva_js.OBSERVER_TYPE.ADD)) return [3, 2];
|
|
394
|
+
sprite = new rendererAdapter.Sprite(null);
|
|
395
|
+
this.imgs[changed.gameObject.id] = sprite;
|
|
396
|
+
this.containerManager.getContainer(changed.gameObject.id).addChildAt(sprite.sprite, 0);
|
|
397
|
+
asyncId = this.increaseAsyncId(changed.gameObject.id);
|
|
398
|
+
return [4, eva_js.resource.getResource(component.resource)];
|
|
291
399
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
400
|
+
case 1:
|
|
401
|
+
instance = _c.sent().instance;
|
|
402
|
+
if (!this.validateAsyncId(changed.gameObject.id, asyncId)) return [2];
|
|
295
403
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
this.containerManager.getContainer(changed.gameObject.id).addChildAt(sprite_1.sprite, 0);
|
|
300
|
-
return [3, 4];
|
|
404
|
+
if (!instance) {
|
|
405
|
+
console.error("GameObject:" + changed.gameObject.name + "'s Img resource load error");
|
|
406
|
+
}
|
|
301
407
|
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
return [4, eva_js.resource.getResource(component.resource)];
|
|
408
|
+
this.imgs[changed.gameObject.id].image = instance;
|
|
409
|
+
return [3, 5];
|
|
305
410
|
|
|
306
411
|
case 2:
|
|
412
|
+
if (!(changed.type === eva_js.OBSERVER_TYPE.CHANGE)) return [3, 4];
|
|
413
|
+
asyncId = this.increaseAsyncId(changed.gameObject.id);
|
|
414
|
+
return [4, eva_js.resource.getResource(component.resource)];
|
|
415
|
+
|
|
416
|
+
case 3:
|
|
307
417
|
instance = _c.sent().instance;
|
|
418
|
+
if (!this.validateAsyncId(changed.gameObject.id, asyncId)) return [2];
|
|
308
419
|
|
|
309
420
|
if (!instance) {
|
|
310
421
|
console.error("GameObject:" + changed.gameObject.name + "'s Img resource load error");
|
|
311
422
|
}
|
|
312
423
|
|
|
313
424
|
this.imgs[changed.gameObject.id].image = instance;
|
|
314
|
-
return [3,
|
|
425
|
+
return [3, 5];
|
|
315
426
|
|
|
316
|
-
case
|
|
427
|
+
case 4:
|
|
317
428
|
if (changed.type === eva_js.OBSERVER_TYPE.REMOVE) {
|
|
429
|
+
this.increaseAsyncId(changed.gameObject.id);
|
|
318
430
|
sprite = this.imgs[changed.gameObject.id];
|
|
319
431
|
if (!sprite) return [2];
|
|
320
432
|
(_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);
|
|
@@ -324,9 +436,9 @@ var _EVA_IIFE_img = function (exports, eva_js, pluginRenderer, rendererAdapter,
|
|
|
324
436
|
delete this.imgs[changed.gameObject.id];
|
|
325
437
|
}
|
|
326
438
|
|
|
327
|
-
_c.label =
|
|
439
|
+
_c.label = 5;
|
|
328
440
|
|
|
329
|
-
case
|
|
441
|
+
case 5:
|
|
330
442
|
return [2];
|
|
331
443
|
}
|
|
332
444
|
});
|
|
@@ -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,r,
|
|
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)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},i(e,t)};function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var a=function(){return a=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},a.apply(this,arguments)};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 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 u(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function l(e,t,r,n){return new(r||(r=Promise))((function(o,i){function c(e){try{s(n.next(e))}catch(e){i(e)}}function a(e){try{s(n.throw(e))}catch(e){i(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(c,a)}s((n=n.apply(e,t||[])).next())}))}function p(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 f=function(e){function t(){var t=this.constructor,r=e.call(this,"Symbol keys are not supported yet!")||this;return Object.setPrototypeOf(r,t.prototype),r}return c(t,e),t}(Error);!function(e){function t(){var t=this.constructor,r=e.call(this,"getProperties is not a function!")||this;return Object.setPrototypeOf(r,t.prototype),r}c(t,e)}(Error);var d="IDE_PROPERTY_METADATA";function g(e,t,r,n){var o=Reflect.getMetadata("design:type",e,t),i=o===Array,c=function(e){return e===String?"string":e===Number?"number":e===Boolean?"boolean":"unknown"}(o);if("unknown"!==c&&(o=c),n){var s=n();Array.isArray(s)?(i=!0,o=s[0]):o=s}var u=Reflect.getMetadata(d,e.constructor)||{};u[t]=a({type:o,isArray:i},r),Reflect.defineMetadata(d,u,e.constructor)}var y=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.resource="",t}var r,n;return c(t,e),t.prototype.init=function(e){e&&e.resource&&(this.resource=e.resource)},t.componentName="Img",s([(r={type:"resource"},function(e,t){if("symbol"==typeof t)throw new f;var o=function(e,t){return"function"==typeof e?{returnTypeFunc:e,options:t||{}}:{options:e||{}}}(r,n);g(e,t,o.options,o.returnTypeFunc)}),u("design:type",String)],t.prototype,"resource",void 0),t}(t.Component),m=y;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){var r,o;return l(this,void 0,void 0,(function(){var i,c,a,s;return p(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]:(s=new n.Sprite(null),this.imgs[e.gameObject.id]=s,this.containerManager.getContainer(e.gameObject.id).addChildAt(s.sprite,0),c=this.increaseAsyncId(e.gameObject.id),[4,t.resource.getResource(i.resource)]));case 1:return a=u.sent().instance,this.validateAsyncId(e.gameObject.id,c)?(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]:(c=this.increaseAsyncId(e.gameObject.id),[4,t.resource.getResource(i.resource)]);case 3:return a=u.sent().instance,this.validateAsyncId(e.gameObject.id,c)?(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),!(s=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(s.sprite),s.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),b=h;return e.Img=m,e.ImgSystem=b,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;
|
package/dist/miniprogram.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { __extends, __decorate, __awaiter, __generator } from 'tslib';
|
|
2
|
-
import {
|
|
1
|
+
import { __extends, __decorate, __metadata, __awaiter, __generator } from 'tslib';
|
|
2
|
+
import { Field } from '@eva/inspector-decorator';
|
|
3
3
|
import { Component, resource, RESOURCE_TYPE, OBSERVER_TYPE, decorators } from '@eva/eva.js/dist/miniprogram';
|
|
4
4
|
import { RendererSystem, Renderer } from '@eva/plugin-renderer/dist/miniprogram';
|
|
5
5
|
import { Sprite } from '@eva/renderer-adapter/dist/miniprogram';
|
|
@@ -23,7 +23,9 @@ var Img$2 = function (_super) {
|
|
|
23
23
|
|
|
24
24
|
Img.componentName = 'Img';
|
|
25
25
|
|
|
26
|
-
__decorate([
|
|
26
|
+
__decorate([Field({
|
|
27
|
+
type: 'resource'
|
|
28
|
+
}), __metadata("design:type", String)], Img.prototype, "resource", void 0);
|
|
27
29
|
|
|
28
30
|
return Img;
|
|
29
31
|
}(Component);
|
|
@@ -80,43 +82,49 @@ var Img = function (_super) {
|
|
|
80
82
|
var _a, _b;
|
|
81
83
|
|
|
82
84
|
return __awaiter(this, void 0, void 0, function () {
|
|
83
|
-
var component,
|
|
85
|
+
var component, sprite, asyncId, instance, asyncId, instance, sprite;
|
|
84
86
|
return __generator(this, function (_c) {
|
|
85
87
|
switch (_c.label) {
|
|
86
88
|
case 0:
|
|
87
|
-
if (!(changed.componentName === 'Img')) return [3,
|
|
89
|
+
if (!(changed.componentName === 'Img')) return [3, 5];
|
|
88
90
|
component = changed.component;
|
|
89
|
-
if (!(changed.type === OBSERVER_TYPE.ADD)) return [3,
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
if (!(changed.type === OBSERVER_TYPE.ADD)) return [3, 2];
|
|
92
|
+
sprite = new Sprite(null);
|
|
93
|
+
this.imgs[changed.gameObject.id] = sprite;
|
|
94
|
+
this.containerManager.getContainer(changed.gameObject.id).addChildAt(sprite.sprite, 0);
|
|
95
|
+
asyncId = this.increaseAsyncId(changed.gameObject.id);
|
|
96
|
+
return [4, resource.getResource(component.resource)];
|
|
93
97
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
98
|
+
case 1:
|
|
99
|
+
instance = _c.sent().instance;
|
|
100
|
+
if (!this.validateAsyncId(changed.gameObject.id, asyncId)) return [2];
|
|
97
101
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
this.containerManager.getContainer(changed.gameObject.id).addChildAt(sprite_1.sprite, 0);
|
|
102
|
-
return [3, 4];
|
|
102
|
+
if (!instance) {
|
|
103
|
+
console.error("GameObject:" + changed.gameObject.name + "'s Img resource load error");
|
|
104
|
+
}
|
|
103
105
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
return [4, resource.getResource(component.resource)];
|
|
106
|
+
this.imgs[changed.gameObject.id].image = instance;
|
|
107
|
+
return [3, 5];
|
|
107
108
|
|
|
108
109
|
case 2:
|
|
110
|
+
if (!(changed.type === OBSERVER_TYPE.CHANGE)) return [3, 4];
|
|
111
|
+
asyncId = this.increaseAsyncId(changed.gameObject.id);
|
|
112
|
+
return [4, resource.getResource(component.resource)];
|
|
113
|
+
|
|
114
|
+
case 3:
|
|
109
115
|
instance = _c.sent().instance;
|
|
116
|
+
if (!this.validateAsyncId(changed.gameObject.id, asyncId)) return [2];
|
|
110
117
|
|
|
111
118
|
if (!instance) {
|
|
112
119
|
console.error("GameObject:" + changed.gameObject.name + "'s Img resource load error");
|
|
113
120
|
}
|
|
114
121
|
|
|
115
122
|
this.imgs[changed.gameObject.id].image = instance;
|
|
116
|
-
return [3,
|
|
123
|
+
return [3, 5];
|
|
117
124
|
|
|
118
|
-
case
|
|
125
|
+
case 4:
|
|
119
126
|
if (changed.type === OBSERVER_TYPE.REMOVE) {
|
|
127
|
+
this.increaseAsyncId(changed.gameObject.id);
|
|
120
128
|
sprite = this.imgs[changed.gameObject.id];
|
|
121
129
|
if (!sprite) return [2];
|
|
122
130
|
(_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);
|
|
@@ -126,9 +134,9 @@ var Img = function (_super) {
|
|
|
126
134
|
delete this.imgs[changed.gameObject.id];
|
|
127
135
|
}
|
|
128
136
|
|
|
129
|
-
_c.label =
|
|
137
|
+
_c.label = 5;
|
|
130
138
|
|
|
131
|
-
case
|
|
139
|
+
case 5:
|
|
132
140
|
return [2];
|
|
133
141
|
}
|
|
134
142
|
});
|
|
@@ -44,6 +44,10 @@ function __decorate(decorators, target, key, desc) {
|
|
|
44
44
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
function __metadata(metadataKey, metadataValue) {
|
|
48
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
49
|
+
}
|
|
50
|
+
|
|
47
51
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
48
52
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
49
53
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
@@ -95,7 +99,8 @@ var Img$2 = (function (_super) {
|
|
|
95
99
|
};
|
|
96
100
|
Img.componentName = 'Img';
|
|
97
101
|
__decorate([
|
|
98
|
-
inspectorDecorator.type
|
|
102
|
+
inspectorDecorator.Field({ type: 'resource' }),
|
|
103
|
+
__metadata("design:type", String)
|
|
99
104
|
], Img.prototype, "resource", void 0);
|
|
100
105
|
return Img;
|
|
101
106
|
}(eva_js.Component));
|
|
@@ -138,36 +143,43 @@ var Img = (function (_super) {
|
|
|
138
143
|
Img.prototype.componentChanged = function (changed) {
|
|
139
144
|
var _a, _b;
|
|
140
145
|
return __awaiter(this, void 0, void 0, function () {
|
|
141
|
-
var component,
|
|
146
|
+
var component, sprite, asyncId, instance, asyncId, instance, sprite;
|
|
142
147
|
return __generator(this, function (_c) {
|
|
143
148
|
switch (_c.label) {
|
|
144
149
|
case 0:
|
|
145
|
-
if (!(changed.componentName === 'Img')) return [3,
|
|
150
|
+
if (!(changed.componentName === 'Img')) return [3, 5];
|
|
146
151
|
component = changed.component;
|
|
147
|
-
if (!(changed.type === eva_js.OBSERVER_TYPE.ADD)) return [3,
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
console.error("GameObject:" + changed.gameObject.name + "'s Img resource load error");
|
|
153
|
-
}
|
|
154
|
-
sprite_1.image = instance;
|
|
155
|
-
});
|
|
156
|
-
this.imgs[changed.gameObject.id] = sprite_1;
|
|
157
|
-
this.containerManager.getContainer(changed.gameObject.id).addChildAt(sprite_1.sprite, 0);
|
|
158
|
-
return [3, 4];
|
|
159
|
-
case 1:
|
|
160
|
-
if (!(changed.type === eva_js.OBSERVER_TYPE.CHANGE)) return [3, 3];
|
|
152
|
+
if (!(changed.type === eva_js.OBSERVER_TYPE.ADD)) return [3, 2];
|
|
153
|
+
sprite = new rendererAdapter.Sprite(null);
|
|
154
|
+
this.imgs[changed.gameObject.id] = sprite;
|
|
155
|
+
this.containerManager.getContainer(changed.gameObject.id).addChildAt(sprite.sprite, 0);
|
|
156
|
+
asyncId = this.increaseAsyncId(changed.gameObject.id);
|
|
161
157
|
return [4, eva_js.resource.getResource(component.resource)];
|
|
162
|
-
case
|
|
158
|
+
case 1:
|
|
163
159
|
instance = (_c.sent()).instance;
|
|
160
|
+
if (!this.validateAsyncId(changed.gameObject.id, asyncId))
|
|
161
|
+
return [2];
|
|
164
162
|
if (!instance) {
|
|
165
163
|
console.error("GameObject:" + changed.gameObject.name + "'s Img resource load error");
|
|
166
164
|
}
|
|
167
165
|
this.imgs[changed.gameObject.id].image = instance;
|
|
168
|
-
return [3,
|
|
166
|
+
return [3, 5];
|
|
167
|
+
case 2:
|
|
168
|
+
if (!(changed.type === eva_js.OBSERVER_TYPE.CHANGE)) return [3, 4];
|
|
169
|
+
asyncId = this.increaseAsyncId(changed.gameObject.id);
|
|
170
|
+
return [4, eva_js.resource.getResource(component.resource)];
|
|
169
171
|
case 3:
|
|
172
|
+
instance = (_c.sent()).instance;
|
|
173
|
+
if (!this.validateAsyncId(changed.gameObject.id, asyncId))
|
|
174
|
+
return [2];
|
|
175
|
+
if (!instance) {
|
|
176
|
+
console.error("GameObject:" + changed.gameObject.name + "'s Img resource load error");
|
|
177
|
+
}
|
|
178
|
+
this.imgs[changed.gameObject.id].image = instance;
|
|
179
|
+
return [3, 5];
|
|
180
|
+
case 4:
|
|
170
181
|
if (changed.type === eva_js.OBSERVER_TYPE.REMOVE) {
|
|
182
|
+
this.increaseAsyncId(changed.gameObject.id);
|
|
171
183
|
sprite = this.imgs[changed.gameObject.id];
|
|
172
184
|
if (!sprite)
|
|
173
185
|
return [2];
|
|
@@ -175,8 +187,8 @@ var Img = (function (_super) {
|
|
|
175
187
|
sprite.sprite.destroy({ children: true });
|
|
176
188
|
delete this.imgs[changed.gameObject.id];
|
|
177
189
|
}
|
|
178
|
-
_c.label =
|
|
179
|
-
case
|
|
190
|
+
_c.label = 5;
|
|
191
|
+
case 5: return [2];
|
|
180
192
|
}
|
|
181
193
|
});
|
|
182
194
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@eva/inspector-decorator"),
|
|
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 c(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,c=o<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--)(i=e[a])&&(c=(o<3?i(c):o>3?i(t,r,c):i(t,r))||c);return o>3&&c&&Object.defineProperty(t,r,c),c}function s(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function u(e,t){var r,n,i,o,c={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(;c;)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 c.label++,{value:o[1],done:!1};case 5:c.label++,n=o[1],o=[0];continue;case 7:o=c.ops.pop(),c.trys.pop();continue;default:if(!(i=c.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){c=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){c.label=o[1];break}if(6===o[0]&&c.label<i[1]){c.label=i[1],i=o;break}if(i&&c.label<i[2]){c.label=i[2],c.ops.push(o);break}i[2]&&c.ops.pop(),c.trys.pop();continue}o=t.call(e,c)}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 l=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.Field({type:"resource"}),s("design:type",String)],r.prototype,"resource",void 0),r}(t.Component),p=l;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 d=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="Img",t.imgs={},t}return c(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,c,a,s;return o=this,c=void 0,s=function(){var o,c,a,s;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]:(s=new n.Sprite(null),this.imgs[e.gameObject.id]=s,this.containerManager.getContainer(e.gameObject.id).addChildAt(s.sprite,0),c=this.increaseAsyncId(e.gameObject.id),[4,t.resource.getResource(o.resource)]));case 1:return a=u.sent().instance,this.validateAsyncId(e.gameObject.id,c)?(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]:(c=this.increaseAsyncId(e.gameObject.id),[4,t.resource.getResource(o.resource)]);case 3:return a=u.sent().instance,this.validateAsyncId(e.gameObject.id,c)?(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),!(s=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(s.sprite),s.sprite.destroy({children:!0}),delete this.imgs[e.gameObject.id]}u.label=5;case 5:return[2]}}))},new((a=void 0)||(a=Promise))((function(e,t){function r(e){try{i(s.next(e))}catch(e){t(e)}}function n(e){try{i(s.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((s=s.apply(o,c||[])).next())}))},i.systemName="Img",i=a([t.decorators.componentObserver({Img:[{prop:["resource"],deep:!1}]})],i)}(r.Renderer);exports.Img=p,exports.ImgSystem=d;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Field } from '@eva/inspector-decorator';
|
|
2
2
|
import { Component, resource, RESOURCE_TYPE, decorators, OBSERVER_TYPE } from '@eva/eva.js';
|
|
3
3
|
import { RendererSystem, Renderer } from '@eva/plugin-renderer';
|
|
4
4
|
import { Sprite } from '@eva/renderer-adapter';
|
|
@@ -40,6 +40,10 @@ function __decorate(decorators, target, key, desc) {
|
|
|
40
40
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
function __metadata(metadataKey, metadataValue) {
|
|
44
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
45
|
+
}
|
|
46
|
+
|
|
43
47
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
44
48
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
45
49
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
@@ -91,7 +95,8 @@ var Img$2 = (function (_super) {
|
|
|
91
95
|
};
|
|
92
96
|
Img.componentName = 'Img';
|
|
93
97
|
__decorate([
|
|
94
|
-
type
|
|
98
|
+
Field({ type: 'resource' }),
|
|
99
|
+
__metadata("design:type", String)
|
|
95
100
|
], Img.prototype, "resource", void 0);
|
|
96
101
|
return Img;
|
|
97
102
|
}(Component));
|
|
@@ -134,36 +139,43 @@ var Img = (function (_super) {
|
|
|
134
139
|
Img.prototype.componentChanged = function (changed) {
|
|
135
140
|
var _a, _b;
|
|
136
141
|
return __awaiter(this, void 0, void 0, function () {
|
|
137
|
-
var component,
|
|
142
|
+
var component, sprite, asyncId, instance, asyncId, instance, sprite;
|
|
138
143
|
return __generator(this, function (_c) {
|
|
139
144
|
switch (_c.label) {
|
|
140
145
|
case 0:
|
|
141
|
-
if (!(changed.componentName === 'Img')) return [3,
|
|
146
|
+
if (!(changed.componentName === 'Img')) return [3, 5];
|
|
142
147
|
component = changed.component;
|
|
143
|
-
if (!(changed.type === OBSERVER_TYPE.ADD)) return [3,
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
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 === OBSERVER_TYPE.CHANGE)) return [3, 3];
|
|
148
|
+
if (!(changed.type === OBSERVER_TYPE.ADD)) return [3, 2];
|
|
149
|
+
sprite = new Sprite(null);
|
|
150
|
+
this.imgs[changed.gameObject.id] = sprite;
|
|
151
|
+
this.containerManager.getContainer(changed.gameObject.id).addChildAt(sprite.sprite, 0);
|
|
152
|
+
asyncId = this.increaseAsyncId(changed.gameObject.id);
|
|
157
153
|
return [4, resource.getResource(component.resource)];
|
|
158
|
-
case
|
|
154
|
+
case 1:
|
|
159
155
|
instance = (_c.sent()).instance;
|
|
156
|
+
if (!this.validateAsyncId(changed.gameObject.id, asyncId))
|
|
157
|
+
return [2];
|
|
160
158
|
if (!instance) {
|
|
161
159
|
console.error("GameObject:" + changed.gameObject.name + "'s Img resource load error");
|
|
162
160
|
}
|
|
163
161
|
this.imgs[changed.gameObject.id].image = instance;
|
|
164
|
-
return [3,
|
|
162
|
+
return [3, 5];
|
|
163
|
+
case 2:
|
|
164
|
+
if (!(changed.type === OBSERVER_TYPE.CHANGE)) return [3, 4];
|
|
165
|
+
asyncId = this.increaseAsyncId(changed.gameObject.id);
|
|
166
|
+
return [4, resource.getResource(component.resource)];
|
|
165
167
|
case 3:
|
|
168
|
+
instance = (_c.sent()).instance;
|
|
169
|
+
if (!this.validateAsyncId(changed.gameObject.id, asyncId))
|
|
170
|
+
return [2];
|
|
171
|
+
if (!instance) {
|
|
172
|
+
console.error("GameObject:" + changed.gameObject.name + "'s Img resource load error");
|
|
173
|
+
}
|
|
174
|
+
this.imgs[changed.gameObject.id].image = instance;
|
|
175
|
+
return [3, 5];
|
|
176
|
+
case 4:
|
|
166
177
|
if (changed.type === OBSERVER_TYPE.REMOVE) {
|
|
178
|
+
this.increaseAsyncId(changed.gameObject.id);
|
|
167
179
|
sprite = this.imgs[changed.gameObject.id];
|
|
168
180
|
if (!sprite)
|
|
169
181
|
return [2];
|
|
@@ -171,8 +183,8 @@ var Img = (function (_super) {
|
|
|
171
183
|
sprite.sprite.destroy({ children: true });
|
|
172
184
|
delete this.imgs[changed.gameObject.id];
|
|
173
185
|
}
|
|
174
|
-
_c.label =
|
|
175
|
-
case
|
|
186
|
+
_c.label = 5;
|
|
187
|
+
case 5: return [2];
|
|
176
188
|
}
|
|
177
189
|
});
|
|
178
190
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eva/plugin-renderer-img",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.7-editor.2",
|
|
4
4
|
"description": "@eva/plugin-renderer-img",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "dist/plugin-renderer-img.esm.js",
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"homepage": "https://eva.js.org",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@eva/inspector-decorator": "
|
|
22
|
-
"@eva/plugin-renderer": "1.2.
|
|
23
|
-
"@eva/renderer-adapter": "1.2.
|
|
24
|
-
"@eva/eva.js": "1.2.
|
|
21
|
+
"@eva/inspector-decorator": "0.1.0-alpha.1",
|
|
22
|
+
"@eva/plugin-renderer": "1.2.7-editor.2",
|
|
23
|
+
"@eva/renderer-adapter": "1.2.7-editor.2",
|
|
24
|
+
"@eva/eva.js": "1.2.7-editor.2",
|
|
25
25
|
"pixi.js": "^4.8.7"
|
|
26
26
|
}
|
|
27
27
|
}
|