@eva/plugin-renderer-img 1.2.7-editor.9 → 1.2.7-fix.4

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,7 +1,6 @@
1
1
  window.EVA = window.EVA || {};
2
2
  window.EVA.plugin = window.EVA.plugin || {};
3
3
  window.EVA.plugin.renderer = window.EVA.plugin.renderer || {};
4
-
5
4
  var _EVA_IIFE_img = function (exports, eva_js, pluginRenderer, rendererAdapter, pixi_js) {
6
5
  'use strict';
7
6
 
@@ -12,62 +11,33 @@ var _EVA_IIFE_img = function (exports, eva_js, pluginRenderer, rendererAdapter,
12
11
  d.__proto__ = b;
13
12
  } || function (d, b) {
14
13
  for (var p in b) {
15
- if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
14
+ if (b.hasOwnProperty(p)) d[p] = b[p];
16
15
  }
17
16
  };
18
-
19
17
  return _extendStatics(d, b);
20
18
  };
21
-
22
19
  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
-
25
20
  _extendStatics(d, b);
26
-
27
21
  function __() {
28
22
  this.constructor = d;
29
23
  }
30
-
31
24
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
32
25
  }
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
-
50
26
  function __decorate(decorators, target, key, desc) {
51
27
  var c = arguments.length,
52
- r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
53
- d;
28
+ r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
29
+ d;
54
30
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) {
55
31
  if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
56
32
  }
57
33
  return c > 3 && r && Object.defineProperty(target, key, r), r;
58
34
  }
59
-
60
- function __metadata(metadataKey, metadataValue) {
61
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
62
- }
63
-
64
35
  function __awaiter(thisArg, _arguments, P, generator) {
65
36
  function adopt(value) {
66
37
  return value instanceof P ? value : new P(function (resolve) {
67
38
  resolve(value);
68
39
  });
69
40
  }
70
-
71
41
  return new (P || (P = Promise))(function (resolve, reject) {
72
42
  function fulfilled(value) {
73
43
  try {
@@ -76,7 +46,6 @@ var _EVA_IIFE_img = function (exports, eva_js, pluginRenderer, rendererAdapter,
76
46
  reject(e);
77
47
  }
78
48
  }
79
-
80
49
  function rejected(value) {
81
50
  try {
82
51
  step(generator["throw"](value));
@@ -84,29 +53,26 @@ var _EVA_IIFE_img = function (exports, eva_js, pluginRenderer, rendererAdapter,
84
53
  reject(e);
85
54
  }
86
55
  }
87
-
88
56
  function step(result) {
89
57
  result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
90
58
  }
91
-
92
59
  step((generator = generator.apply(thisArg, _arguments || [])).next());
93
60
  });
94
61
  }
95
-
96
62
  function __generator(thisArg, body) {
97
63
  var _ = {
98
- label: 0,
99
- sent: function sent() {
100
- if (t[0] & 1) throw t[1];
101
- return t[1];
64
+ label: 0,
65
+ sent: function sent() {
66
+ if (t[0] & 1) throw t[1];
67
+ return t[1];
68
+ },
69
+ trys: [],
70
+ ops: []
102
71
  },
103
- trys: [],
104
- ops: []
105
- },
106
- f,
107
- y,
108
- t,
109
- g;
72
+ f,
73
+ y,
74
+ t,
75
+ g;
110
76
  return g = {
111
77
  next: verb(0),
112
78
  "throw": verb(1),
@@ -114,79 +80,60 @@ var _EVA_IIFE_img = function (exports, eva_js, pluginRenderer, rendererAdapter,
114
80
  }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
115
81
  return this;
116
82
  }), g;
117
-
118
83
  function verb(n) {
119
84
  return function (v) {
120
85
  return step([n, v]);
121
86
  };
122
87
  }
123
-
124
88
  function step(op) {
125
89
  if (f) throw new TypeError("Generator is already executing.");
126
-
127
90
  while (_) {
128
91
  try {
129
92
  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;
130
93
  if (y = 0, t) op = [op[0] & 2, t.value];
131
-
132
94
  switch (op[0]) {
133
95
  case 0:
134
96
  case 1:
135
97
  t = op;
136
98
  break;
137
-
138
99
  case 4:
139
100
  _.label++;
140
101
  return {
141
102
  value: op[1],
142
103
  done: false
143
104
  };
144
-
145
105
  case 5:
146
106
  _.label++;
147
107
  y = op[1];
148
108
  op = [0];
149
109
  continue;
150
-
151
110
  case 7:
152
111
  op = _.ops.pop();
153
-
154
112
  _.trys.pop();
155
-
156
113
  continue;
157
-
158
114
  default:
159
115
  if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
160
116
  _ = 0;
161
117
  continue;
162
118
  }
163
-
164
119
  if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
165
120
  _.label = op[1];
166
121
  break;
167
122
  }
168
-
169
123
  if (op[0] === 6 && _.label < t[1]) {
170
124
  _.label = t[1];
171
125
  t = op;
172
126
  break;
173
127
  }
174
-
175
128
  if (t && _.label < t[2]) {
176
129
  _.label = t[2];
177
-
178
130
  _.ops.push(op);
179
-
180
131
  break;
181
132
  }
182
-
183
133
  if (t[2]) _.ops.pop();
184
-
185
134
  _.trys.pop();
186
-
187
135
  continue;
188
136
  }
189
-
190
137
  op = body.call(thisArg, _);
191
138
  } catch (e) {
192
139
  op = [6, e];
@@ -195,7 +142,6 @@ var _EVA_IIFE_img = function (exports, eva_js, pluginRenderer, rendererAdapter,
195
142
  f = t = 0;
196
143
  }
197
144
  }
198
-
199
145
  if (op[0] & 5) throw op[1];
200
146
  return {
201
147
  value: op[0] ? op[1] : void 0,
@@ -203,194 +149,79 @@ var _EVA_IIFE_img = function (exports, eva_js, pluginRenderer, rendererAdapter,
203
149
  };
204
150
  }
205
151
  }
206
-
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;
152
+ function getIDEPropsPropertyObj(target, propertyKey) {
153
+ if (!target.constructor.IDEProps) {
154
+ target.constructor.IDEProps = {};
232
155
  }
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';
156
+ if (!target.constructor.IDEProps[propertyKey]) {
157
+ target.constructor.IDEProps[propertyKey] = {};
242
158
  }
243
-
244
- if (type === Number) {
245
- return 'number';
246
- }
247
-
248
- if (type === Boolean) {
249
- return 'boolean';
250
- }
251
-
252
- return 'unknown';
159
+ var propertyObj = target.constructor.IDEProps[propertyKey];
160
+ return propertyObj;
253
161
  }
254
-
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) {
162
+ function type(type) {
297
163
  return function (target, propertyKey) {
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);
164
+ var prop = getIDEPropsPropertyObj(target, propertyKey);
165
+ prop.key = propertyKey;
166
+ prop.type = type;
307
167
  };
308
168
  }
309
-
310
- var ExecuteMode;
311
-
312
- (function (ExecuteMode) {
313
- ExecuteMode[ExecuteMode["Edit"] = 2] = "Edit";
314
- ExecuteMode[ExecuteMode["Game"] = 4] = "Game";
315
- ExecuteMode[ExecuteMode["All"] = 6] = "All";
316
- })(ExecuteMode || (ExecuteMode = {}));
317
-
318
169
  var Img$2 = function (_super) {
319
170
  __extends(Img, _super);
320
-
321
171
  function Img() {
322
172
  var _this = _super !== null && _super.apply(this, arguments) || this;
323
-
324
173
  _this.resource = '';
325
174
  return _this;
326
175
  }
327
-
328
176
  Img.prototype.init = function (obj) {
329
177
  if (obj && obj.resource) {
330
178
  this.resource = obj.resource;
331
179
  }
332
180
  };
333
-
334
181
  Img.componentName = 'Img';
335
-
336
- __decorate([Field({
337
- type: 'resource'
338
- }), __metadata("design:type", String)], Img.prototype, "resource", void 0);
339
-
182
+ __decorate([type('string')], Img.prototype, "resource", void 0);
340
183
  return Img;
341
184
  }(eva_js.Component);
342
-
343
185
  var Img$3 = Img$2;
344
186
  eva_js.resource.registerInstance(eva_js.RESOURCE_TYPE.IMAGE, function (_a) {
345
187
  var _b = _a.data,
346
- data = _b === void 0 ? {} : _b;
188
+ data = _b === void 0 ? {} : _b;
347
189
  var image = data.image;
348
-
349
190
  if (image) {
350
191
  var texture = pixi_js.Texture.from(image);
351
192
  return texture;
352
193
  }
353
-
354
194
  return;
355
195
  });
356
196
  eva_js.resource.registerDestroy(eva_js.RESOURCE_TYPE.IMAGE, function (_a) {
357
197
  var instance = _a.instance;
358
-
359
198
  if (instance) {
360
199
  instance.destroy(true);
361
200
  }
362
201
  });
363
-
364
202
  var Img = function (_super) {
365
203
  __extends(Img, _super);
366
-
367
204
  function Img() {
368
205
  var _this = _super !== null && _super.apply(this, arguments) || this;
369
-
370
206
  _this.name = 'Img';
371
207
  _this.imgs = {};
372
208
  return _this;
373
209
  }
374
-
375
210
  Img.prototype.init = function () {
376
211
  this.renderSystem = this.game.getSystem(pluginRenderer.RendererSystem);
377
212
  this.renderSystem.rendererManager.register(this);
378
213
  };
379
-
380
214
  Img.prototype.rendererUpdate = function (gameObject) {
381
215
  var _a = gameObject.transform.size,
382
- width = _a.width,
383
- height = _a.height;
384
-
216
+ width = _a.width,
217
+ height = _a.height;
385
218
  if (this.imgs[gameObject.id]) {
386
219
  this.imgs[gameObject.id].sprite.width = width;
387
220
  this.imgs[gameObject.id].sprite.height = height;
388
221
  }
389
222
  };
390
-
391
223
  Img.prototype.componentChanged = function (changed) {
392
224
  var _a, _b;
393
-
394
225
  return __awaiter(this, void 0, void 0, function () {
395
226
  var component, sprite, asyncId, instance, asyncId, instance, sprite;
396
227
  return __generator(this, function (_c) {
@@ -404,34 +235,26 @@ var _EVA_IIFE_img = function (exports, eva_js, pluginRenderer, rendererAdapter,
404
235
  this.containerManager.getContainer(changed.gameObject.id).addChildAt(sprite.sprite, 0);
405
236
  asyncId = this.increaseAsyncId(changed.gameObject.id);
406
237
  return [4, eva_js.resource.getResource(component.resource)];
407
-
408
238
  case 1:
409
239
  instance = _c.sent().instance;
410
240
  if (!this.validateAsyncId(changed.gameObject.id, asyncId)) return [2];
411
-
412
241
  if (!instance) {
413
242
  console.error("GameObject:" + changed.gameObject.name + "'s Img resource load error");
414
243
  }
415
-
416
244
  this.imgs[changed.gameObject.id].image = instance;
417
245
  return [3, 5];
418
-
419
246
  case 2:
420
247
  if (!(changed.type === eva_js.OBSERVER_TYPE.CHANGE)) return [3, 4];
421
248
  asyncId = this.increaseAsyncId(changed.gameObject.id);
422
249
  return [4, eva_js.resource.getResource(component.resource)];
423
-
424
250
  case 3:
425
251
  instance = _c.sent().instance;
426
252
  if (!this.validateAsyncId(changed.gameObject.id, asyncId)) return [2];
427
-
428
253
  if (!instance) {
429
254
  console.error("GameObject:" + changed.gameObject.name + "'s Img resource load error");
430
255
  }
431
-
432
256
  this.imgs[changed.gameObject.id].image = instance;
433
257
  return [3, 5];
434
-
435
258
  case 4:
436
259
  if (changed.type === eva_js.OBSERVER_TYPE.REMOVE) {
437
260
  this.increaseAsyncId(changed.gameObject.id);
@@ -443,16 +266,13 @@ var _EVA_IIFE_img = function (exports, eva_js, pluginRenderer, rendererAdapter,
443
266
  });
444
267
  delete this.imgs[changed.gameObject.id];
445
268
  }
446
-
447
269
  _c.label = 5;
448
-
449
270
  case 5:
450
271
  return [2];
451
272
  }
452
273
  });
453
274
  });
454
275
  };
455
-
456
276
  Img.systemName = 'Img';
457
277
  Img = __decorate([eva_js.decorators.componentObserver({
458
278
  Img: [{
@@ -462,7 +282,6 @@ var _EVA_IIFE_img = function (exports, eva_js, pluginRenderer, rendererAdapter,
462
282
  })], Img);
463
283
  return Img;
464
284
  }(pluginRenderer.Renderer);
465
-
466
285
  var Img$1 = Img;
467
286
  exports.Img = Img$3;
468
287
  exports.ImgSystem = Img$1;
@@ -471,5 +290,4 @@ var _EVA_IIFE_img = function (exports, eva_js, pluginRenderer, rendererAdapter,
471
290
  });
472
291
  return exports;
473
292
  }({}, EVA, EVA.plugin.renderer, EVA.rendererAdapter, PIXI);
474
-
475
293
  window.EVA.plugin.renderer.img = window.EVA.plugin.renderer.img || _EVA_IIFE_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)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,g="IDE_PROPERTY_METADATA";function y(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(g,e.constructor)||{};u[t]=a({type:o,isArray:i},r),Reflect.defineMetadata(g,u,e.constructor)}!function(e){e[e.Edit=2]="Edit",e[e.Game=4]="Game",e[e.All=6]="All"}(d||(d={}));var m=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);y(e,t,o.options,o.returnTypeFunc)}),u("design:type",String)],t.prototype,"resource",void 0),t}(t.Component),h=m;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 b=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),v=b;return e.Img=h,e.ImgSystem=v,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,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 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),d=p;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 g=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),f=g;return e.Img=d,e.ImgSystem=f,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,124 @@
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
+ var Img$2 = function (_super) {
8
+ __extends(Img, _super);
9
+ function Img() {
10
+ var _this = _super !== null && _super.apply(this, arguments) || this;
11
+ _this.resource = '';
12
+ return _this;
13
+ }
14
+ Img.prototype.init = function (obj) {
15
+ if (obj && obj.resource) {
16
+ this.resource = obj.resource;
17
+ }
18
+ };
19
+ Img.componentName = 'Img';
20
+ __decorate([type('string')], Img.prototype, "resource", void 0);
21
+ return Img;
22
+ }(Component);
23
+ var Img$3 = Img$2;
24
+ resource.registerInstance(RESOURCE_TYPE.IMAGE, function (_a) {
25
+ var _b = _a.data,
26
+ data = _b === void 0 ? {} : _b;
27
+ var image = data.image;
28
+ if (image) {
29
+ var texture = Texture.from(image);
30
+ return texture;
31
+ }
32
+ return;
33
+ });
34
+ resource.registerDestroy(RESOURCE_TYPE.IMAGE, function (_a) {
35
+ var instance = _a.instance;
36
+ if (instance) {
37
+ instance.destroy(true);
38
+ }
39
+ });
40
+ var Img = function (_super) {
41
+ __extends(Img, _super);
42
+ function Img() {
43
+ var _this = _super !== null && _super.apply(this, arguments) || this;
44
+ _this.name = 'Img';
45
+ _this.imgs = {};
46
+ return _this;
47
+ }
48
+ Img.prototype.init = function () {
49
+ this.renderSystem = this.game.getSystem(RendererSystem);
50
+ this.renderSystem.rendererManager.register(this);
51
+ };
52
+ Img.prototype.rendererUpdate = function (gameObject) {
53
+ var _a = gameObject.transform.size,
54
+ width = _a.width,
55
+ height = _a.height;
56
+ if (this.imgs[gameObject.id]) {
57
+ this.imgs[gameObject.id].sprite.width = width;
58
+ this.imgs[gameObject.id].sprite.height = height;
59
+ }
60
+ };
61
+ Img.prototype.componentChanged = function (changed) {
62
+ var _a, _b;
63
+ return __awaiter(this, void 0, void 0, function () {
64
+ var component, sprite, asyncId, instance, asyncId, instance, sprite;
65
+ return __generator(this, function (_c) {
66
+ switch (_c.label) {
67
+ case 0:
68
+ if (!(changed.componentName === 'Img')) return [3, 5];
69
+ component = changed.component;
70
+ if (!(changed.type === OBSERVER_TYPE.ADD)) return [3, 2];
71
+ sprite = new Sprite(null);
72
+ this.imgs[changed.gameObject.id] = sprite;
73
+ this.containerManager.getContainer(changed.gameObject.id).addChildAt(sprite.sprite, 0);
74
+ asyncId = this.increaseAsyncId(changed.gameObject.id);
75
+ return [4, resource.getResource(component.resource)];
76
+ case 1:
77
+ instance = _c.sent().instance;
78
+ if (!this.validateAsyncId(changed.gameObject.id, asyncId)) return [2];
79
+ if (!instance) {
80
+ console.error("GameObject:" + changed.gameObject.name + "'s Img resource load error");
81
+ }
82
+ this.imgs[changed.gameObject.id].image = instance;
83
+ return [3, 5];
84
+ case 2:
85
+ if (!(changed.type === OBSERVER_TYPE.CHANGE)) return [3, 4];
86
+ asyncId = this.increaseAsyncId(changed.gameObject.id);
87
+ return [4, resource.getResource(component.resource)];
88
+ case 3:
89
+ instance = _c.sent().instance;
90
+ if (!this.validateAsyncId(changed.gameObject.id, asyncId)) return [2];
91
+ if (!instance) {
92
+ console.error("GameObject:" + changed.gameObject.name + "'s Img resource load error");
93
+ }
94
+ this.imgs[changed.gameObject.id].image = instance;
95
+ return [3, 5];
96
+ case 4:
97
+ if (changed.type === OBSERVER_TYPE.REMOVE) {
98
+ this.increaseAsyncId(changed.gameObject.id);
99
+ sprite = this.imgs[changed.gameObject.id];
100
+ if (!sprite) return [2];
101
+ (_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);
102
+ sprite.sprite.destroy({
103
+ children: true
104
+ });
105
+ delete this.imgs[changed.gameObject.id];
106
+ }
107
+ _c.label = 5;
108
+ case 5:
109
+ return [2];
110
+ }
111
+ });
112
+ });
113
+ };
114
+ Img.systemName = 'Img';
115
+ Img = __decorate([decorators.componentObserver({
116
+ Img: [{
117
+ prop: ['resource'],
118
+ deep: false
119
+ }]
120
+ })], Img);
121
+ return Img;
122
+ }(Renderer);
123
+ var Img$1 = Img;
124
+ export { Img$3 as Img, Img$1 as ImgSystem };
@@ -44,10 +44,6 @@ 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
-
51
47
  function __awaiter(thisArg, _arguments, P, generator) {
52
48
  return new (P || (P = Promise))(function (resolve, reject) {
53
49
  function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
@@ -99,8 +95,7 @@ var Img$2 = (function (_super) {
99
95
  };
100
96
  Img.componentName = 'Img';
101
97
  __decorate([
102
- inspectorDecorator.Field({ type: 'resource' }),
103
- __metadata("design:type", String)
98
+ inspectorDecorator.type('string')
104
99
  ], Img.prototype, "resource", void 0);
105
100
  return Img;
106
101
  }(eva_js.Component));
@@ -193,6 +188,15 @@ var Img = (function (_super) {
193
188
  });
194
189
  });
195
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
+ };
196
200
  Img.systemName = 'Img';
197
201
  Img = __decorate([
198
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])},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
+ "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 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),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,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=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 { }
@@ -1,4 +1,4 @@
1
- import { Field } from '@eva/inspector-decorator';
1
+ import { type } 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,10 +40,6 @@ 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
-
47
43
  function __awaiter(thisArg, _arguments, P, generator) {
48
44
  return new (P || (P = Promise))(function (resolve, reject) {
49
45
  function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
@@ -95,8 +91,7 @@ var Img$2 = (function (_super) {
95
91
  };
96
92
  Img.componentName = 'Img';
97
93
  __decorate([
98
- Field({ type: 'resource' }),
99
- __metadata("design:type", String)
94
+ type('string')
100
95
  ], Img.prototype, "resource", void 0);
101
96
  return Img;
102
97
  }(Component));
@@ -189,6 +184,15 @@ var Img = (function (_super) {
189
184
  });
190
185
  });
191
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
+ };
192
196
  Img.systemName = 'Img';
193
197
  Img = __decorate([
194
198
  decorators.componentObserver({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eva/plugin-renderer-img",
3
- "version": "1.2.7-editor.9",
3
+ "version": "1.2.7-fix.4",
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": "0.1.0-alpha.2",
22
- "@eva/plugin-renderer": "1.2.7-editor.9",
23
- "@eva/renderer-adapter": "1.2.7-editor.9",
24
- "@eva/eva.js": "1.2.7-editor.9",
21
+ "@eva/inspector-decorator": "^0.0.5",
22
+ "@eva/plugin-renderer": "1.2.7-fix.4",
23
+ "@eva/renderer-adapter": "1.2.7-fix.4",
24
+ "@eva/eva.js": "1.2.7-fix.4",
25
25
  "pixi.js": "^4.8.7"
26
26
  }
27
27
  }