@eva/plugin-renderer-nine-patch 2.0.0-beta.1 → 2.0.0-beta.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.
@@ -3,23 +3,6 @@ window.EVA.plugin = window.EVA.plugin || {};
3
3
  window.EVA.plugin.renderer = window.EVA.plugin.renderer || {};
4
4
  var _EVA_IIFE_ninePatch = function (exports, eva_js, pluginRenderer, rendererAdapter) {
5
5
  'use strict';
6
- var extendStatics = function (d, b) {
7
- extendStatics = Object.setPrototypeOf || {
8
- __proto__: []
9
- } instanceof Array && function (d, b) {
10
- d.__proto__ = b;
11
- } || function (d, b) {
12
- for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
13
- };
14
- return extendStatics(d, b);
15
- };
16
- function __extends(d, b) {
17
- extendStatics(d, b);
18
- function __() {
19
- this.constructor = d;
20
- }
21
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
22
- }
23
6
  function __decorate(decorators, target, key, desc) {
24
7
  var c = arguments.length,
25
8
  r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
@@ -54,94 +37,6 @@ var _EVA_IIFE_ninePatch = function (exports, eva_js, pluginRenderer, rendererAda
54
37
  step((generator = generator.apply(thisArg, _arguments || [])).next());
55
38
  });
56
39
  }
57
- function __generator(thisArg, body) {
58
- var _ = {
59
- label: 0,
60
- sent: function () {
61
- if (t[0] & 1) throw t[1];
62
- return t[1];
63
- },
64
- trys: [],
65
- ops: []
66
- },
67
- f,
68
- y,
69
- t,
70
- g;
71
- return g = {
72
- next: verb(0),
73
- "throw": verb(1),
74
- "return": verb(2)
75
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
76
- return this;
77
- }), g;
78
- function verb(n) {
79
- return function (v) {
80
- return step([n, v]);
81
- };
82
- }
83
- function step(op) {
84
- if (f) throw new TypeError("Generator is already executing.");
85
- while (_) try {
86
- 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;
87
- if (y = 0, t) op = [op[0] & 2, t.value];
88
- switch (op[0]) {
89
- case 0:
90
- case 1:
91
- t = op;
92
- break;
93
- case 4:
94
- _.label++;
95
- return {
96
- value: op[1],
97
- done: false
98
- };
99
- case 5:
100
- _.label++;
101
- y = op[1];
102
- op = [0];
103
- continue;
104
- case 7:
105
- op = _.ops.pop();
106
- _.trys.pop();
107
- continue;
108
- default:
109
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
110
- _ = 0;
111
- continue;
112
- }
113
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
114
- _.label = op[1];
115
- break;
116
- }
117
- if (op[0] === 6 && _.label < t[1]) {
118
- _.label = t[1];
119
- t = op;
120
- break;
121
- }
122
- if (t && _.label < t[2]) {
123
- _.label = t[2];
124
- _.ops.push(op);
125
- break;
126
- }
127
- if (t[2]) _.ops.pop();
128
- _.trys.pop();
129
- continue;
130
- }
131
- op = body.call(thisArg, _);
132
- } catch (e) {
133
- op = [6, e];
134
- y = 0;
135
- } finally {
136
- f = t = 0;
137
- }
138
- if (op[0] & 5) throw op[1];
139
- return {
140
- value: op[0] ? op[1] : void 0,
141
- done: true
142
- };
143
- }
144
- }
145
40
  function getIDEPropsPropertyObj(target, propertyKey) {
146
41
  if (!target.constructor.IDEProps) {
147
42
  target.constructor.IDEProps = {};
@@ -165,111 +60,103 @@ var _EVA_IIFE_ninePatch = function (exports, eva_js, pluginRenderer, rendererAda
165
60
  prop.step = step;
166
61
  };
167
62
  }
168
- var NinePatch$2 = function (_super) {
169
- __extends(NinePatch, _super);
170
- function NinePatch() {
171
- var _this = _super !== null && _super.apply(this, arguments) || this;
172
- _this.resource = '';
173
- _this.spriteName = '';
174
- _this.leftWidth = 0;
175
- _this.topHeight = 0;
176
- _this.rightWidth = 0;
177
- _this.bottomHeight = 0;
178
- return _this;
63
+ class NinePatch$2 extends eva_js.Component {
64
+ constructor() {
65
+ super(...arguments);
66
+ this.resource = '';
67
+ this.spriteName = '';
68
+ this.leftWidth = 0;
69
+ this.topHeight = 0;
70
+ this.rightWidth = 0;
71
+ this.bottomHeight = 0;
179
72
  }
180
- NinePatch.prototype.init = function (obj) {
73
+ init(obj) {
181
74
  this.resource = obj.resource;
182
75
  this.spriteName = obj.spriteName;
183
76
  this.leftWidth = obj.leftWidth;
184
77
  this.topHeight = obj.topHeight;
185
78
  this.rightWidth = obj.rightWidth;
186
79
  this.bottomHeight = obj.bottomHeight;
187
- };
188
- NinePatch.componentName = 'NinePatch';
189
- __decorate([type('string')], NinePatch.prototype, "resource", void 0);
190
- __decorate([type('string')], NinePatch.prototype, "spriteName", void 0);
191
- __decorate([type('number'), step(1)], NinePatch.prototype, "leftWidth", void 0);
192
- __decorate([type('number'), step(1)], NinePatch.prototype, "topHeight", void 0);
193
- __decorate([type('number'), step(1)], NinePatch.prototype, "rightWidth", void 0);
194
- __decorate([type('number'), step(1)], NinePatch.prototype, "bottomHeight", void 0);
195
- return NinePatch;
196
- }(eva_js.Component);
197
- var NinePatch$3 = NinePatch$2;
198
- var resourceKeySplit = '_s|r|c_';
199
- var NinePatch = function (_super) {
200
- __extends(NinePatch, _super);
201
- function NinePatch() {
202
- var _this = _super !== null && _super.apply(this, arguments) || this;
203
- _this.name = 'NinePatch';
204
- _this.ninePatch = {};
205
- return _this;
206
80
  }
207
- NinePatch.prototype.init = function () {
81
+ }
82
+ NinePatch$2.componentName = 'NinePatch';
83
+ __decorate([type('string')], NinePatch$2.prototype, "resource", void 0);
84
+ __decorate([type('string')], NinePatch$2.prototype, "spriteName", void 0);
85
+ __decorate([type('number'), step(1)], NinePatch$2.prototype, "leftWidth", void 0);
86
+ __decorate([type('number'), step(1)], NinePatch$2.prototype, "topHeight", void 0);
87
+ __decorate([type('number'), step(1)], NinePatch$2.prototype, "rightWidth", void 0);
88
+ __decorate([type('number'), step(1)], NinePatch$2.prototype, "bottomHeight", void 0);
89
+ const resourceKeySplit = '_s|r|c_';
90
+ let NinePatch = class NinePatch extends pluginRenderer.Renderer {
91
+ constructor() {
92
+ super(...arguments);
93
+ this.name = 'NinePatch';
94
+ this.ninePatch = {};
95
+ }
96
+ init() {
208
97
  this.renderSystem = this.game.getSystem(pluginRenderer.RendererSystem);
209
98
  this.renderSystem.rendererManager.register(this);
210
- };
211
- NinePatch.prototype.rendererUpdate = function (gameObject) {
212
- var _a = gameObject.transform.size,
213
- width = _a.width,
214
- height = _a.height;
99
+ }
100
+ rendererUpdate(gameObject) {
101
+ const {
102
+ width,
103
+ height
104
+ } = gameObject.transform.size;
215
105
  if (this.ninePatch[gameObject.id]) {
216
106
  this.ninePatch[gameObject.id].width = width;
217
107
  this.ninePatch[gameObject.id].height = height;
218
108
  }
219
- };
220
- NinePatch.prototype.componentChanged = function (changed) {
221
- return __awaiter(this, void 0, void 0, function () {
222
- return __generator(this, function (_a) {
223
- if (changed.componentName === 'NinePatch') {
224
- if (changed.type === eva_js.OBSERVER_TYPE.ADD) {
225
- this.add(changed);
226
- } else if (changed.type === eva_js.OBSERVER_TYPE.REMOVE) {
227
- this.remove(changed);
228
- } else {
229
- this.remove(changed);
230
- this.add(changed);
231
- }
109
+ }
110
+ componentChanged(changed) {
111
+ return __awaiter(this, void 0, void 0, function* () {
112
+ if (changed.componentName === 'NinePatch') {
113
+ if (changed.type === eva_js.OBSERVER_TYPE.ADD) {
114
+ this.add(changed);
115
+ } else if (changed.type === eva_js.OBSERVER_TYPE.REMOVE) {
116
+ this.remove(changed);
117
+ } else {
118
+ this.remove(changed);
119
+ this.add(changed);
232
120
  }
233
- return [2];
234
- });
121
+ }
235
122
  });
236
- };
237
- NinePatch.prototype.add = function (changed) {
238
- return __awaiter(this, void 0, void 0, function () {
239
- var component, gameObjectId, asyncId, _a, type, data, img, leftWidth, topHeight, rightWidth, bottomHeight, np;
240
- return __generator(this, function (_b) {
241
- switch (_b.label) {
242
- case 0:
243
- component = changed.component;
244
- gameObjectId = changed.gameObject.id;
245
- asyncId = this.increaseAsyncId(gameObjectId);
246
- return [4, eva_js.resource.getResource(component.resource)];
247
- case 1:
248
- _a = _b.sent(), type = _a.type, data = _a.data;
249
- if (!this.validateAsyncId(gameObjectId, asyncId)) return [2];
250
- if (!data) {
251
- console.error("GameObject:" + changed.gameObject.name + "'s NinePatch resource load error");
252
- return [2];
253
- }
254
- if (type === eva_js.RESOURCE_TYPE.SPRITE) {
255
- img = component.resource + resourceKeySplit + component.spriteName;
256
- } else {
257
- img = data.image;
258
- }
259
- leftWidth = component.leftWidth, topHeight = component.topHeight, rightWidth = component.rightWidth, bottomHeight = component.bottomHeight;
260
- np = new rendererAdapter.NinePatch(img, leftWidth, topHeight, rightWidth, bottomHeight);
261
- this.ninePatch[changed.gameObject.id] = np;
262
- component.ninePatch = np;
263
- this.containerManager.getContainer(changed.gameObject.id).addChildAt(np, 0);
264
- return [2];
265
- }
266
- });
123
+ }
124
+ add(changed) {
125
+ return __awaiter(this, void 0, void 0, function* () {
126
+ const component = changed.component;
127
+ const gameObjectId = changed.gameObject.id;
128
+ const asyncId = this.increaseAsyncId(gameObjectId);
129
+ const {
130
+ type,
131
+ data
132
+ } = yield eva_js.resource.getResource(component.resource);
133
+ if (!this.validateAsyncId(gameObjectId, asyncId)) return;
134
+ if (!data) {
135
+ console.error(`GameObject:${changed.gameObject.name}'s NinePatch resource load error`);
136
+ return;
137
+ }
138
+ let img;
139
+ if (type === eva_js.RESOURCE_TYPE.SPRITE) {
140
+ img = component.resource + resourceKeySplit + component.spriteName;
141
+ } else {
142
+ img = data.image;
143
+ }
144
+ const {
145
+ leftWidth,
146
+ topHeight,
147
+ rightWidth,
148
+ bottomHeight
149
+ } = component;
150
+ const np = new rendererAdapter.NinePatch(img, leftWidth, topHeight, rightWidth, bottomHeight);
151
+ this.ninePatch[changed.gameObject.id] = np;
152
+ component.ninePatch = np;
153
+ this.containerManager.getContainer(changed.gameObject.id).addChildAt(np, 0);
267
154
  });
268
- };
269
- NinePatch.prototype.remove = function (changed) {
270
- var gameObjectId = changed.gameObject.id;
155
+ }
156
+ remove(changed) {
157
+ const gameObjectId = changed.gameObject.id;
271
158
  this.increaseAsyncId(gameObjectId);
272
- var sprite = this.ninePatch[gameObjectId];
159
+ const sprite = this.ninePatch[gameObjectId];
273
160
  if (sprite) {
274
161
  this.containerManager.getContainer(changed.gameObject.id).removeChild(sprite);
275
162
  delete this.ninePatch[changed.gameObject.id];
@@ -277,15 +164,14 @@ var _EVA_IIFE_ninePatch = function (exports, eva_js, pluginRenderer, rendererAda
277
164
  children: true
278
165
  });
279
166
  }
280
- };
281
- NinePatch.systemName = 'NinePatch';
282
- NinePatch = __decorate([eva_js.decorators.componentObserver({
283
- NinePatch: ['resource', 'spriteName', 'leftWidth', 'topHeight', 'rightWidth', 'bottomHeight']
284
- })], NinePatch);
285
- return NinePatch;
286
- }(pluginRenderer.Renderer);
167
+ }
168
+ };
169
+ NinePatch.systemName = 'NinePatch';
170
+ NinePatch = __decorate([eva_js.decorators.componentObserver({
171
+ NinePatch: ['resource', 'spriteName', 'leftWidth', 'topHeight', 'rightWidth', 'bottomHeight']
172
+ })], NinePatch);
287
173
  var NinePatch$1 = NinePatch;
288
- exports.NinePatch = NinePatch$3;
174
+ exports.NinePatch = NinePatch$2;
289
175
  exports.NinePatchSystem = NinePatch$1;
290
176
  Object.defineProperty(exports, '__esModule', {
291
177
  value: true
@@ -1 +1 @@
1
- window.EVA=window.EVA||{},window.EVA.plugin=window.EVA.plugin||{},window.EVA.plugin.renderer=window.EVA.plugin.renderer||{};var _EVA_IIFE_ninePatch=function(t,e,n,r){"use strict";var i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},i(t,e)};function o(t,e){function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function c(t,e,n,r){var i,o=arguments.length,c=o<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(c=(o<3?i(c):o>3?i(e,n,c):i(e,n))||c);return o>3&&c&&Object.defineProperty(e,n,c),c}function a(t,e,n,r){return new(n||(n=Promise))((function(i,o){function c(t){try{s(r.next(t))}catch(t){o(t)}}function a(t){try{s(r.throw(t))}catch(t){o(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((r=r.apply(t,e||[])).next())}))}function s(t,e){var n,r,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(n)throw new TypeError("Generator is already executing.");for(;c;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=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++,r=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=e.call(t,c)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}function u(t,e){return t.constructor.IDEProps||(t.constructor.IDEProps={}),t.constructor.IDEProps[e]||(t.constructor.IDEProps[e]={}),t.constructor.IDEProps[e]}function h(t){return function(e,n){var r=u(e,n);r.key=n,r.type=t}}function p(t){return function(e,n){u(e,n).step=t}}var d=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.resource="",e.spriteName="",e.leftWidth=0,e.topHeight=0,e.rightWidth=0,e.bottomHeight=0,e}return o(e,t),e.prototype.init=function(t){this.resource=t.resource,this.spriteName=t.spriteName,this.leftWidth=t.leftWidth,this.topHeight=t.topHeight,this.rightWidth=t.rightWidth,this.bottomHeight=t.bottomHeight},e.componentName="NinePatch",c([h("string")],e.prototype,"resource",void 0),c([h("string")],e.prototype,"spriteName",void 0),c([h("number"),p(1)],e.prototype,"leftWidth",void 0),c([h("number"),p(1)],e.prototype,"topHeight",void 0),c([h("number"),p(1)],e.prototype,"rightWidth",void 0),c([h("number"),p(1)],e.prototype,"bottomHeight",void 0),e}(e.Component),l=d,f=function(t){function i(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="NinePatch",e.ninePatch={},e}return o(i,t),i.prototype.init=function(){this.renderSystem=this.game.getSystem(n.RendererSystem),this.renderSystem.rendererManager.register(this)},i.prototype.rendererUpdate=function(t){var e=t.transform.size,n=e.width,r=e.height;this.ninePatch[t.id]&&(this.ninePatch[t.id].width=n,this.ninePatch[t.id].height=r)},i.prototype.componentChanged=function(t){return a(this,void 0,void 0,(function(){return s(this,(function(n){return"NinePatch"===t.componentName&&(t.type===e.OBSERVER_TYPE.ADD?this.add(t):t.type===e.OBSERVER_TYPE.REMOVE?this.remove(t):(this.remove(t),this.add(t))),[2]}))}))},i.prototype.add=function(t){return a(this,void 0,void 0,(function(){var n,i,o,c,a,u,h,p,d,l,f,y;return s(this,(function(s){switch(s.label){case 0:return n=t.component,i=t.gameObject.id,o=this.increaseAsyncId(i),[4,e.resource.getResource(n.resource)];case 1:return c=s.sent(),a=c.type,u=c.data,this.validateAsyncId(i,o)?u?(h=a===e.RESOURCE_TYPE.SPRITE?n.resource+"_s|r|c_"+n.spriteName:u.image,p=n.leftWidth,d=n.topHeight,l=n.rightWidth,f=n.bottomHeight,y=new r.NinePatch(h,p,d,l,f),this.ninePatch[t.gameObject.id]=y,n.ninePatch=y,this.containerManager.getContainer(t.gameObject.id).addChildAt(y,0),[2]):(console.error("GameObject:"+t.gameObject.name+"'s NinePatch resource load error"),[2]):[2]}}))}))},i.prototype.remove=function(t){var e=t.gameObject.id;this.increaseAsyncId(e);var n=this.ninePatch[e];n&&(this.containerManager.getContainer(t.gameObject.id).removeChild(n),delete this.ninePatch[t.gameObject.id],n.destroy({children:!0}))},i.systemName="NinePatch",i=c([e.decorators.componentObserver({NinePatch:["resource","spriteName","leftWidth","topHeight","rightWidth","bottomHeight"]})],i)}(n.Renderer),y=f;return t.NinePatch=l,t.NinePatchSystem=y,Object.defineProperty(t,"__esModule",{value:!0}),t}({},EVA,EVA.plugin.renderer,EVA.rendererAdapter);window.EVA.plugin.renderer.ninePatch=window.EVA.plugin.renderer.ninePatch||_EVA_IIFE_ninePatch;
1
+ window.EVA=window.EVA||{},window.EVA.plugin=window.EVA.plugin||{},window.EVA.plugin.renderer=window.EVA.plugin.renderer||{};var _EVA_IIFE_ninePatch=function(e,t,i,n){"use strict";function r(e,t,i,n){var r,o=arguments.length,c=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,i,n);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(c=(o<3?r(c):o>3?r(t,i,c):r(t,i))||c);return o>3&&c&&Object.defineProperty(t,i,c),c}function o(e,t,i,n){return new(i||(i=Promise))((function(r,o){function c(e){try{h(n.next(e))}catch(e){o(e)}}function s(e){try{h(n.throw(e))}catch(e){o(e)}}function h(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(c,s)}h((n=n.apply(e,t||[])).next())}))}function c(e,t){return e.constructor.IDEProps||(e.constructor.IDEProps={}),e.constructor.IDEProps[t]||(e.constructor.IDEProps[t]={}),e.constructor.IDEProps[t]}function s(e){return function(t,i){var n=c(t,i);n.key=i,n.type=e}}function h(e){return function(t,i){c(t,i).step=e}}class d extends t.Component{constructor(){super(...arguments),this.resource="",this.spriteName="",this.leftWidth=0,this.topHeight=0,this.rightWidth=0,this.bottomHeight=0}init(e){this.resource=e.resource,this.spriteName=e.spriteName,this.leftWidth=e.leftWidth,this.topHeight=e.topHeight,this.rightWidth=e.rightWidth,this.bottomHeight=e.bottomHeight}}d.componentName="NinePatch",r([s("string")],d.prototype,"resource",void 0),r([s("string")],d.prototype,"spriteName",void 0),r([s("number"),h(1)],d.prototype,"leftWidth",void 0),r([s("number"),h(1)],d.prototype,"topHeight",void 0),r([s("number"),h(1)],d.prototype,"rightWidth",void 0),r([s("number"),h(1)],d.prototype,"bottomHeight",void 0);let a=class extends i.Renderer{constructor(){super(...arguments),this.name="NinePatch",this.ninePatch={}}init(){this.renderSystem=this.game.getSystem(i.RendererSystem),this.renderSystem.rendererManager.register(this)}rendererUpdate(e){const{width:t,height:i}=e.transform.size;this.ninePatch[e.id]&&(this.ninePatch[e.id].width=t,this.ninePatch[e.id].height=i)}componentChanged(e){return o(this,void 0,void 0,(function*(){"NinePatch"===e.componentName&&(e.type===t.OBSERVER_TYPE.ADD?this.add(e):e.type===t.OBSERVER_TYPE.REMOVE?this.remove(e):(this.remove(e),this.add(e)))}))}add(e){return o(this,void 0,void 0,(function*(){const i=e.component,r=e.gameObject.id,o=this.increaseAsyncId(r),{type:c,data:s}=yield t.resource.getResource(i.resource);if(!this.validateAsyncId(r,o))return;if(!s)return void console.error(`GameObject:${e.gameObject.name}'s NinePatch resource load error`);let h;h=c===t.RESOURCE_TYPE.SPRITE?i.resource+"_s|r|c_"+i.spriteName:s.image;const{leftWidth:d,topHeight:a,rightWidth:u,bottomHeight:p}=i,g=new n.NinePatch(h,d,a,u,p);this.ninePatch[e.gameObject.id]=g,i.ninePatch=g,this.containerManager.getContainer(e.gameObject.id).addChildAt(g,0)}))}remove(e){const t=e.gameObject.id;this.increaseAsyncId(t);const i=this.ninePatch[t];i&&(this.containerManager.getContainer(e.gameObject.id).removeChild(i),delete this.ninePatch[e.gameObject.id],i.destroy({children:!0}))}};a.systemName="NinePatch",a=r([t.decorators.componentObserver({NinePatch:["resource","spriteName","leftWidth","topHeight","rightWidth","bottomHeight"]})],a);var u=a;return e.NinePatch=d,e.NinePatchSystem=u,Object.defineProperty(e,"__esModule",{value:!0}),e}({},EVA,EVA.plugin.renderer,EVA.rendererAdapter);window.EVA.plugin.renderer.ninePatch=window.EVA.plugin.renderer.ninePatch||_EVA_IIFE_ninePatch;
@@ -21,20 +21,6 @@ MERCHANTABLITY OR NON-INFRINGEMENT.
21
21
  See the Apache Version 2.0 License for specific language governing permissions
22
22
  and limitations under the License.
23
23
  ***************************************************************************** */
24
- /* global Reflect, Promise */
25
-
26
- var extendStatics = function(d, b) {
27
- extendStatics = Object.setPrototypeOf ||
28
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
29
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
30
- return extendStatics(d, b);
31
- };
32
-
33
- function __extends(d, b) {
34
- extendStatics(d, b);
35
- function __() { this.constructor = d; }
36
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
37
- }
38
24
 
39
25
  function __decorate(decorators, target, key, desc) {
40
26
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -50,177 +36,131 @@ function __awaiter(thisArg, _arguments, P, generator) {
50
36
  function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
51
37
  step((generator = generator.apply(thisArg, _arguments || [])).next());
52
38
  });
53
- }
54
-
55
- function __generator(thisArg, body) {
56
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
57
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
58
- function verb(n) { return function (v) { return step([n, v]); }; }
59
- function step(op) {
60
- if (f) throw new TypeError("Generator is already executing.");
61
- while (_) try {
62
- 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;
63
- if (y = 0, t) op = [op[0] & 2, t.value];
64
- switch (op[0]) {
65
- case 0: case 1: t = op; break;
66
- case 4: _.label++; return { value: op[1], done: false };
67
- case 5: _.label++; y = op[1]; op = [0]; continue;
68
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
69
- default:
70
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
71
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
72
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
73
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
74
- if (t[2]) _.ops.pop();
75
- _.trys.pop(); continue;
76
- }
77
- op = body.call(thisArg, _);
78
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
79
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
80
- }
81
39
  }
82
40
 
83
- var NinePatch$2 = (function (_super) {
84
- __extends(NinePatch, _super);
85
- function NinePatch() {
86
- var _this = _super !== null && _super.apply(this, arguments) || this;
87
- _this.resource = '';
88
- _this.spriteName = '';
89
- _this.leftWidth = 0;
90
- _this.topHeight = 0;
91
- _this.rightWidth = 0;
92
- _this.bottomHeight = 0;
93
- return _this;
41
+ class NinePatch$2 extends eva_js.Component {
42
+ constructor() {
43
+ super(...arguments);
44
+ this.resource = '';
45
+ this.spriteName = '';
46
+ this.leftWidth = 0;
47
+ this.topHeight = 0;
48
+ this.rightWidth = 0;
49
+ this.bottomHeight = 0;
94
50
  }
95
- NinePatch.prototype.init = function (obj) {
51
+ init(obj) {
96
52
  this.resource = obj.resource;
97
53
  this.spriteName = obj.spriteName;
98
54
  this.leftWidth = obj.leftWidth;
99
55
  this.topHeight = obj.topHeight;
100
56
  this.rightWidth = obj.rightWidth;
101
57
  this.bottomHeight = obj.bottomHeight;
102
- };
103
- NinePatch.componentName = 'NinePatch';
104
- __decorate([
105
- inspectorDecorator.type('string')
106
- ], NinePatch.prototype, "resource", void 0);
107
- __decorate([
108
- inspectorDecorator.type('string')
109
- ], NinePatch.prototype, "spriteName", void 0);
110
- __decorate([
111
- inspectorDecorator.type('number'),
112
- inspectorDecorator.step(1)
113
- ], NinePatch.prototype, "leftWidth", void 0);
114
- __decorate([
115
- inspectorDecorator.type('number'),
116
- inspectorDecorator.step(1)
117
- ], NinePatch.prototype, "topHeight", void 0);
118
- __decorate([
119
- inspectorDecorator.type('number'),
120
- inspectorDecorator.step(1)
121
- ], NinePatch.prototype, "rightWidth", void 0);
122
- __decorate([
123
- inspectorDecorator.type('number'),
124
- inspectorDecorator.step(1)
125
- ], NinePatch.prototype, "bottomHeight", void 0);
126
- return NinePatch;
127
- }(eva_js.Component));
128
- var NinePatch$3 = NinePatch$2;
58
+ }
59
+ }
60
+ NinePatch$2.componentName = 'NinePatch';
61
+ __decorate([
62
+ inspectorDecorator.type('string')
63
+ ], NinePatch$2.prototype, "resource", void 0);
64
+ __decorate([
65
+ inspectorDecorator.type('string')
66
+ ], NinePatch$2.prototype, "spriteName", void 0);
67
+ __decorate([
68
+ inspectorDecorator.type('number'),
69
+ inspectorDecorator.step(1)
70
+ ], NinePatch$2.prototype, "leftWidth", void 0);
71
+ __decorate([
72
+ inspectorDecorator.type('number'),
73
+ inspectorDecorator.step(1)
74
+ ], NinePatch$2.prototype, "topHeight", void 0);
75
+ __decorate([
76
+ inspectorDecorator.type('number'),
77
+ inspectorDecorator.step(1)
78
+ ], NinePatch$2.prototype, "rightWidth", void 0);
79
+ __decorate([
80
+ inspectorDecorator.type('number'),
81
+ inspectorDecorator.step(1)
82
+ ], NinePatch$2.prototype, "bottomHeight", void 0);
129
83
 
130
- var resourceKeySplit = '_s|r|c_';
131
- var NinePatch = (function (_super) {
132
- __extends(NinePatch, _super);
133
- function NinePatch() {
134
- var _this = _super !== null && _super.apply(this, arguments) || this;
135
- _this.name = 'NinePatch';
136
- _this.ninePatch = {};
137
- return _this;
84
+ const resourceKeySplit = '_s|r|c_';
85
+ let NinePatch = class NinePatch extends pluginRenderer.Renderer {
86
+ constructor() {
87
+ super(...arguments);
88
+ this.name = 'NinePatch';
89
+ this.ninePatch = {};
138
90
  }
139
- NinePatch.prototype.init = function () {
91
+ init() {
140
92
  this.renderSystem = this.game.getSystem(pluginRenderer.RendererSystem);
141
93
  this.renderSystem.rendererManager.register(this);
142
- };
143
- NinePatch.prototype.rendererUpdate = function (gameObject) {
144
- var _a = gameObject.transform.size, width = _a.width, height = _a.height;
94
+ }
95
+ rendererUpdate(gameObject) {
96
+ const { width, height } = gameObject.transform.size;
145
97
  if (this.ninePatch[gameObject.id]) {
146
98
  this.ninePatch[gameObject.id].width = width;
147
99
  this.ninePatch[gameObject.id].height = height;
148
100
  }
149
- };
150
- NinePatch.prototype.componentChanged = function (changed) {
151
- return __awaiter(this, void 0, void 0, function () {
152
- return __generator(this, function (_a) {
153
- if (changed.componentName === 'NinePatch') {
154
- if (changed.type === eva_js.OBSERVER_TYPE.ADD) {
155
- this.add(changed);
156
- }
157
- else if (changed.type === eva_js.OBSERVER_TYPE.REMOVE) {
158
- this.remove(changed);
159
- }
160
- else {
161
- this.remove(changed);
162
- this.add(changed);
163
- }
101
+ }
102
+ componentChanged(changed) {
103
+ return __awaiter(this, void 0, void 0, function* () {
104
+ if (changed.componentName === 'NinePatch') {
105
+ if (changed.type === eva_js.OBSERVER_TYPE.ADD) {
106
+ this.add(changed);
164
107
  }
165
- return [2];
166
- });
167
- });
168
- };
169
- NinePatch.prototype.add = function (changed) {
170
- return __awaiter(this, void 0, void 0, function () {
171
- var component, gameObjectId, asyncId, _a, type, data, img, leftWidth, topHeight, rightWidth, bottomHeight, np;
172
- return __generator(this, function (_b) {
173
- switch (_b.label) {
174
- case 0:
175
- component = changed.component;
176
- gameObjectId = changed.gameObject.id;
177
- asyncId = this.increaseAsyncId(gameObjectId);
178
- return [4, eva_js.resource.getResource(component.resource)];
179
- case 1:
180
- _a = _b.sent(), type = _a.type, data = _a.data;
181
- if (!this.validateAsyncId(gameObjectId, asyncId))
182
- return [2];
183
- if (!data) {
184
- console.error("GameObject:" + changed.gameObject.name + "'s NinePatch resource load error");
185
- return [2];
186
- }
187
- if (type === eva_js.RESOURCE_TYPE.SPRITE) {
188
- img = component.resource + resourceKeySplit + component.spriteName;
189
- }
190
- else {
191
- img = data.image;
192
- }
193
- leftWidth = component.leftWidth, topHeight = component.topHeight, rightWidth = component.rightWidth, bottomHeight = component.bottomHeight;
194
- np = new rendererAdapter.NinePatch(img, leftWidth, topHeight, rightWidth, bottomHeight);
195
- this.ninePatch[changed.gameObject.id] = np;
196
- component.ninePatch = np;
197
- this.containerManager
198
- .getContainer(changed.gameObject.id)
199
- .addChildAt(np, 0);
200
- return [2];
108
+ else if (changed.type === eva_js.OBSERVER_TYPE.REMOVE) {
109
+ this.remove(changed);
110
+ }
111
+ else {
112
+ this.remove(changed);
113
+ this.add(changed);
201
114
  }
202
- });
115
+ }
203
116
  });
204
- };
205
- NinePatch.prototype.remove = function (changed) {
206
- var gameObjectId = changed.gameObject.id;
117
+ }
118
+ add(changed) {
119
+ return __awaiter(this, void 0, void 0, function* () {
120
+ const component = changed.component;
121
+ const gameObjectId = changed.gameObject.id;
122
+ const asyncId = this.increaseAsyncId(gameObjectId);
123
+ const { type, data } = yield eva_js.resource.getResource(component.resource);
124
+ if (!this.validateAsyncId(gameObjectId, asyncId))
125
+ return;
126
+ if (!data) {
127
+ console.error(`GameObject:${changed.gameObject.name}'s NinePatch resource load error`);
128
+ return;
129
+ }
130
+ let img;
131
+ if (type === eva_js.RESOURCE_TYPE.SPRITE) {
132
+ img = component.resource + resourceKeySplit + component.spriteName;
133
+ }
134
+ else {
135
+ img = data.image;
136
+ }
137
+ const { leftWidth, topHeight, rightWidth, bottomHeight } = component;
138
+ const np = new rendererAdapter.NinePatch(img, leftWidth, topHeight, rightWidth, bottomHeight);
139
+ this.ninePatch[changed.gameObject.id] = np;
140
+ component.ninePatch = np;
141
+ this.containerManager
142
+ .getContainer(changed.gameObject.id)
143
+ .addChildAt(np, 0);
144
+ });
145
+ }
146
+ remove(changed) {
147
+ const gameObjectId = changed.gameObject.id;
207
148
  this.increaseAsyncId(gameObjectId);
208
- var sprite = this.ninePatch[gameObjectId];
149
+ const sprite = this.ninePatch[gameObjectId];
209
150
  if (sprite) {
210
151
  this.containerManager.getContainer(changed.gameObject.id).removeChild(sprite);
211
152
  delete this.ninePatch[changed.gameObject.id];
212
153
  sprite.destroy({ children: true });
213
154
  }
214
- };
215
- NinePatch.systemName = 'NinePatch';
216
- NinePatch = __decorate([
217
- eva_js.decorators.componentObserver({
218
- NinePatch: ['resource', 'spriteName', 'leftWidth', 'topHeight', 'rightWidth', 'bottomHeight'],
219
- })
220
- ], NinePatch);
221
- return NinePatch;
222
- }(pluginRenderer.Renderer));
155
+ }
156
+ };
157
+ NinePatch.systemName = 'NinePatch';
158
+ NinePatch = __decorate([
159
+ eva_js.decorators.componentObserver({
160
+ NinePatch: ['resource', 'spriteName', 'leftWidth', 'topHeight', 'rightWidth', 'bottomHeight'],
161
+ })
162
+ ], NinePatch);
223
163
  var NinePatch$1 = NinePatch;
224
164
 
225
- exports.NinePatch = NinePatch$3;
165
+ exports.NinePatch = NinePatch$2;
226
166
  exports.NinePatchSystem = NinePatch$1;
@@ -1 +1,16 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@eva/eva.js"),t=require("@eva/inspector-decorator"),r=require("@eva/plugin-renderer"),n=require("@eva/renderer-adapter"),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 o(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function a(e,t,r,n){var i,o=arguments.length,a=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,n);else for(var c=e.length-1;c>=0;c--)(i=e[c])&&(a=(o<3?i(a):o>3?i(t,r,a):i(t,r))||a);return o>3&&a&&Object.defineProperty(t,r,a),a}function c(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{s(n.next(e))}catch(e){o(e)}}function c(e){try{s(n.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new r((function(t){t(e.value)})).then(a,c)}s((n=n.apply(e,t||[])).next())}))}function s(e,t){var r,n,i,o,a={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(;a;)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 a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}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 h=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.resource="",t.spriteName="",t.leftWidth=0,t.topHeight=0,t.rightWidth=0,t.bottomHeight=0,t}return o(r,e),r.prototype.init=function(e){this.resource=e.resource,this.spriteName=e.spriteName,this.leftWidth=e.leftWidth,this.topHeight=e.topHeight,this.rightWidth=e.rightWidth,this.bottomHeight=e.bottomHeight},r.componentName="NinePatch",a([t.type("string")],r.prototype,"resource",void 0),a([t.type("string")],r.prototype,"spriteName",void 0),a([t.type("number"),t.step(1)],r.prototype,"leftWidth",void 0),a([t.type("number"),t.step(1)],r.prototype,"topHeight",void 0),a([t.type("number"),t.step(1)],r.prototype,"rightWidth",void 0),a([t.type("number"),t.step(1)],r.prototype,"bottomHeight",void 0),r}(e.Component),p=h,u=function(t){function i(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="NinePatch",e.ninePatch={},e}return o(i,t),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.ninePatch[e.id]&&(this.ninePatch[e.id].width=r,this.ninePatch[e.id].height=n)},i.prototype.componentChanged=function(t){return c(this,void 0,void 0,(function(){return s(this,(function(r){return"NinePatch"===t.componentName&&(t.type===e.OBSERVER_TYPE.ADD?this.add(t):t.type===e.OBSERVER_TYPE.REMOVE?this.remove(t):(this.remove(t),this.add(t))),[2]}))}))},i.prototype.add=function(t){return c(this,void 0,void 0,(function(){var r,i,o,a,c,h,p,u,d,l,f,y;return s(this,(function(s){switch(s.label){case 0:return r=t.component,i=t.gameObject.id,o=this.increaseAsyncId(i),[4,e.resource.getResource(r.resource)];case 1:return a=s.sent(),c=a.type,h=a.data,this.validateAsyncId(i,o)?h?(p=c===e.RESOURCE_TYPE.SPRITE?r.resource+"_s|r|c_"+r.spriteName:h.image,u=r.leftWidth,d=r.topHeight,l=r.rightWidth,f=r.bottomHeight,y=new n.NinePatch(p,u,d,l,f),this.ninePatch[t.gameObject.id]=y,r.ninePatch=y,this.containerManager.getContainer(t.gameObject.id).addChildAt(y,0),[2]):(console.error("GameObject:"+t.gameObject.name+"'s NinePatch resource load error"),[2]):[2]}}))}))},i.prototype.remove=function(e){var t=e.gameObject.id;this.increaseAsyncId(t);var r=this.ninePatch[t];r&&(this.containerManager.getContainer(e.gameObject.id).removeChild(r),delete this.ninePatch[e.gameObject.id],r.destroy({children:!0}))},i.systemName="NinePatch",i=a([e.decorators.componentObserver({NinePatch:["resource","spriteName","leftWidth","topHeight","rightWidth","bottomHeight"]})],i)}(r.Renderer);exports.NinePatch=p,exports.NinePatchSystem=u;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@eva/eva.js"),t=require("@eva/inspector-decorator"),i=require("@eva/plugin-renderer"),r=require("@eva/renderer-adapter");
2
+ /*! *****************************************************************************
3
+ Copyright (c) Microsoft Corporation. All rights reserved.
4
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
5
+ this file except in compliance with the License. You may obtain a copy of the
6
+ License at http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
9
+ KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
10
+ WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
11
+ MERCHANTABLITY OR NON-INFRINGEMENT.
12
+
13
+ See the Apache Version 2.0 License for specific language governing permissions
14
+ and limitations under the License.
15
+ ***************************************************************************** */
16
+ function n(e,t,i,r){var n,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,i,r);else for(var h=e.length-1;h>=0;h--)(n=e[h])&&(s=(o<3?n(s):o>3?n(t,i,s):n(t,i))||s);return o>3&&s&&Object.defineProperty(t,i,s),s}function o(e,t,i,r){return new(i||(i=Promise))((function(n,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function h(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?n(e.value):new i((function(t){t(e.value)})).then(s,h)}c((r=r.apply(e,t||[])).next())}))}class s extends e.Component{constructor(){super(...arguments),this.resource="",this.spriteName="",this.leftWidth=0,this.topHeight=0,this.rightWidth=0,this.bottomHeight=0}init(e){this.resource=e.resource,this.spriteName=e.spriteName,this.leftWidth=e.leftWidth,this.topHeight=e.topHeight,this.rightWidth=e.rightWidth,this.bottomHeight=e.bottomHeight}}s.componentName="NinePatch",n([t.type("string")],s.prototype,"resource",void 0),n([t.type("string")],s.prototype,"spriteName",void 0),n([t.type("number"),t.step(1)],s.prototype,"leftWidth",void 0),n([t.type("number"),t.step(1)],s.prototype,"topHeight",void 0),n([t.type("number"),t.step(1)],s.prototype,"rightWidth",void 0),n([t.type("number"),t.step(1)],s.prototype,"bottomHeight",void 0);let h=class extends i.Renderer{constructor(){super(...arguments),this.name="NinePatch",this.ninePatch={}}init(){this.renderSystem=this.game.getSystem(i.RendererSystem),this.renderSystem.rendererManager.register(this)}rendererUpdate(e){const{width:t,height:i}=e.transform.size;this.ninePatch[e.id]&&(this.ninePatch[e.id].width=t,this.ninePatch[e.id].height=i)}componentChanged(t){return o(this,void 0,void 0,(function*(){"NinePatch"===t.componentName&&(t.type===e.OBSERVER_TYPE.ADD?this.add(t):t.type===e.OBSERVER_TYPE.REMOVE?this.remove(t):(this.remove(t),this.add(t)))}))}add(t){return o(this,void 0,void 0,(function*(){const i=t.component,n=t.gameObject.id,o=this.increaseAsyncId(n),{type:s,data:h}=yield e.resource.getResource(i.resource);if(!this.validateAsyncId(n,o))return;if(!h)return void console.error(`GameObject:${t.gameObject.name}'s NinePatch resource load error`);let c;c=s===e.RESOURCE_TYPE.SPRITE?i.resource+"_s|r|c_"+i.spriteName:h.image;const{leftWidth:a,topHeight:d,rightWidth:p,bottomHeight:m}=i,u=new r.NinePatch(c,a,d,p,m);this.ninePatch[t.gameObject.id]=u,i.ninePatch=u,this.containerManager.getContainer(t.gameObject.id).addChildAt(u,0)}))}remove(e){const t=e.gameObject.id;this.increaseAsyncId(t);const i=this.ninePatch[t];i&&(this.containerManager.getContainer(e.gameObject.id).removeChild(i),delete this.ninePatch[e.gameObject.id],i.destroy({children:!0}))}};h.systemName="NinePatch",h=n([e.decorators.componentObserver({NinePatch:["resource","spriteName","leftWidth","topHeight","rightWidth","bottomHeight"]})],h);var c=h;exports.NinePatch=s,exports.NinePatchSystem=c;
@@ -1,7 +1,7 @@
1
- import { Component, decorators, OBSERVER_TYPE, RESOURCE_TYPE, resource } from '@eva/eva.js';
1
+ import { Component, decorators, OBSERVER_TYPE, resource, RESOURCE_TYPE } from '@eva/eva.js';
2
2
  import { type, step } from '@eva/inspector-decorator';
3
- import { RendererSystem, Renderer } from '@eva/plugin-renderer';
4
- import { NinePatch as NinePatch$4 } from '@eva/renderer-adapter';
3
+ import { Renderer, RendererSystem } from '@eva/plugin-renderer';
4
+ import { NinePatch as NinePatch$3 } from '@eva/renderer-adapter';
5
5
 
6
6
  /*! *****************************************************************************
7
7
  Copyright (c) Microsoft Corporation. All rights reserved.
@@ -17,20 +17,6 @@ MERCHANTABLITY OR NON-INFRINGEMENT.
17
17
  See the Apache Version 2.0 License for specific language governing permissions
18
18
  and limitations under the License.
19
19
  ***************************************************************************** */
20
- /* global Reflect, Promise */
21
-
22
- var extendStatics = function(d, b) {
23
- extendStatics = Object.setPrototypeOf ||
24
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
25
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
26
- return extendStatics(d, b);
27
- };
28
-
29
- function __extends(d, b) {
30
- extendStatics(d, b);
31
- function __() { this.constructor = d; }
32
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
33
- }
34
20
 
35
21
  function __decorate(decorators, target, key, desc) {
36
22
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -46,176 +32,130 @@ function __awaiter(thisArg, _arguments, P, generator) {
46
32
  function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
47
33
  step((generator = generator.apply(thisArg, _arguments || [])).next());
48
34
  });
49
- }
50
-
51
- function __generator(thisArg, body) {
52
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
53
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
54
- function verb(n) { return function (v) { return step([n, v]); }; }
55
- function step(op) {
56
- if (f) throw new TypeError("Generator is already executing.");
57
- while (_) try {
58
- 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;
59
- if (y = 0, t) op = [op[0] & 2, t.value];
60
- switch (op[0]) {
61
- case 0: case 1: t = op; break;
62
- case 4: _.label++; return { value: op[1], done: false };
63
- case 5: _.label++; y = op[1]; op = [0]; continue;
64
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
65
- default:
66
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
67
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
68
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
69
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
70
- if (t[2]) _.ops.pop();
71
- _.trys.pop(); continue;
72
- }
73
- op = body.call(thisArg, _);
74
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
75
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
76
- }
77
35
  }
78
36
 
79
- var NinePatch$2 = (function (_super) {
80
- __extends(NinePatch, _super);
81
- function NinePatch() {
82
- var _this = _super !== null && _super.apply(this, arguments) || this;
83
- _this.resource = '';
84
- _this.spriteName = '';
85
- _this.leftWidth = 0;
86
- _this.topHeight = 0;
87
- _this.rightWidth = 0;
88
- _this.bottomHeight = 0;
89
- return _this;
37
+ class NinePatch$2 extends Component {
38
+ constructor() {
39
+ super(...arguments);
40
+ this.resource = '';
41
+ this.spriteName = '';
42
+ this.leftWidth = 0;
43
+ this.topHeight = 0;
44
+ this.rightWidth = 0;
45
+ this.bottomHeight = 0;
90
46
  }
91
- NinePatch.prototype.init = function (obj) {
47
+ init(obj) {
92
48
  this.resource = obj.resource;
93
49
  this.spriteName = obj.spriteName;
94
50
  this.leftWidth = obj.leftWidth;
95
51
  this.topHeight = obj.topHeight;
96
52
  this.rightWidth = obj.rightWidth;
97
53
  this.bottomHeight = obj.bottomHeight;
98
- };
99
- NinePatch.componentName = 'NinePatch';
100
- __decorate([
101
- type('string')
102
- ], NinePatch.prototype, "resource", void 0);
103
- __decorate([
104
- type('string')
105
- ], NinePatch.prototype, "spriteName", void 0);
106
- __decorate([
107
- type('number'),
108
- step(1)
109
- ], NinePatch.prototype, "leftWidth", void 0);
110
- __decorate([
111
- type('number'),
112
- step(1)
113
- ], NinePatch.prototype, "topHeight", void 0);
114
- __decorate([
115
- type('number'),
116
- step(1)
117
- ], NinePatch.prototype, "rightWidth", void 0);
118
- __decorate([
119
- type('number'),
120
- step(1)
121
- ], NinePatch.prototype, "bottomHeight", void 0);
122
- return NinePatch;
123
- }(Component));
124
- var NinePatch$3 = NinePatch$2;
54
+ }
55
+ }
56
+ NinePatch$2.componentName = 'NinePatch';
57
+ __decorate([
58
+ type('string')
59
+ ], NinePatch$2.prototype, "resource", void 0);
60
+ __decorate([
61
+ type('string')
62
+ ], NinePatch$2.prototype, "spriteName", void 0);
63
+ __decorate([
64
+ type('number'),
65
+ step(1)
66
+ ], NinePatch$2.prototype, "leftWidth", void 0);
67
+ __decorate([
68
+ type('number'),
69
+ step(1)
70
+ ], NinePatch$2.prototype, "topHeight", void 0);
71
+ __decorate([
72
+ type('number'),
73
+ step(1)
74
+ ], NinePatch$2.prototype, "rightWidth", void 0);
75
+ __decorate([
76
+ type('number'),
77
+ step(1)
78
+ ], NinePatch$2.prototype, "bottomHeight", void 0);
125
79
 
126
- var resourceKeySplit = '_s|r|c_';
127
- var NinePatch = (function (_super) {
128
- __extends(NinePatch, _super);
129
- function NinePatch() {
130
- var _this = _super !== null && _super.apply(this, arguments) || this;
131
- _this.name = 'NinePatch';
132
- _this.ninePatch = {};
133
- return _this;
80
+ const resourceKeySplit = '_s|r|c_';
81
+ let NinePatch = class NinePatch extends Renderer {
82
+ constructor() {
83
+ super(...arguments);
84
+ this.name = 'NinePatch';
85
+ this.ninePatch = {};
134
86
  }
135
- NinePatch.prototype.init = function () {
87
+ init() {
136
88
  this.renderSystem = this.game.getSystem(RendererSystem);
137
89
  this.renderSystem.rendererManager.register(this);
138
- };
139
- NinePatch.prototype.rendererUpdate = function (gameObject) {
140
- var _a = gameObject.transform.size, width = _a.width, height = _a.height;
90
+ }
91
+ rendererUpdate(gameObject) {
92
+ const { width, height } = gameObject.transform.size;
141
93
  if (this.ninePatch[gameObject.id]) {
142
94
  this.ninePatch[gameObject.id].width = width;
143
95
  this.ninePatch[gameObject.id].height = height;
144
96
  }
145
- };
146
- NinePatch.prototype.componentChanged = function (changed) {
147
- return __awaiter(this, void 0, void 0, function () {
148
- return __generator(this, function (_a) {
149
- if (changed.componentName === 'NinePatch') {
150
- if (changed.type === OBSERVER_TYPE.ADD) {
151
- this.add(changed);
152
- }
153
- else if (changed.type === OBSERVER_TYPE.REMOVE) {
154
- this.remove(changed);
155
- }
156
- else {
157
- this.remove(changed);
158
- this.add(changed);
159
- }
97
+ }
98
+ componentChanged(changed) {
99
+ return __awaiter(this, void 0, void 0, function* () {
100
+ if (changed.componentName === 'NinePatch') {
101
+ if (changed.type === OBSERVER_TYPE.ADD) {
102
+ this.add(changed);
160
103
  }
161
- return [2];
162
- });
163
- });
164
- };
165
- NinePatch.prototype.add = function (changed) {
166
- return __awaiter(this, void 0, void 0, function () {
167
- var component, gameObjectId, asyncId, _a, type, data, img, leftWidth, topHeight, rightWidth, bottomHeight, np;
168
- return __generator(this, function (_b) {
169
- switch (_b.label) {
170
- case 0:
171
- component = changed.component;
172
- gameObjectId = changed.gameObject.id;
173
- asyncId = this.increaseAsyncId(gameObjectId);
174
- return [4, resource.getResource(component.resource)];
175
- case 1:
176
- _a = _b.sent(), type = _a.type, data = _a.data;
177
- if (!this.validateAsyncId(gameObjectId, asyncId))
178
- return [2];
179
- if (!data) {
180
- console.error("GameObject:" + changed.gameObject.name + "'s NinePatch resource load error");
181
- return [2];
182
- }
183
- if (type === RESOURCE_TYPE.SPRITE) {
184
- img = component.resource + resourceKeySplit + component.spriteName;
185
- }
186
- else {
187
- img = data.image;
188
- }
189
- leftWidth = component.leftWidth, topHeight = component.topHeight, rightWidth = component.rightWidth, bottomHeight = component.bottomHeight;
190
- np = new NinePatch$4(img, leftWidth, topHeight, rightWidth, bottomHeight);
191
- this.ninePatch[changed.gameObject.id] = np;
192
- component.ninePatch = np;
193
- this.containerManager
194
- .getContainer(changed.gameObject.id)
195
- .addChildAt(np, 0);
196
- return [2];
104
+ else if (changed.type === OBSERVER_TYPE.REMOVE) {
105
+ this.remove(changed);
106
+ }
107
+ else {
108
+ this.remove(changed);
109
+ this.add(changed);
197
110
  }
198
- });
111
+ }
199
112
  });
200
- };
201
- NinePatch.prototype.remove = function (changed) {
202
- var gameObjectId = changed.gameObject.id;
113
+ }
114
+ add(changed) {
115
+ return __awaiter(this, void 0, void 0, function* () {
116
+ const component = changed.component;
117
+ const gameObjectId = changed.gameObject.id;
118
+ const asyncId = this.increaseAsyncId(gameObjectId);
119
+ const { type, data } = yield resource.getResource(component.resource);
120
+ if (!this.validateAsyncId(gameObjectId, asyncId))
121
+ return;
122
+ if (!data) {
123
+ console.error(`GameObject:${changed.gameObject.name}'s NinePatch resource load error`);
124
+ return;
125
+ }
126
+ let img;
127
+ if (type === RESOURCE_TYPE.SPRITE) {
128
+ img = component.resource + resourceKeySplit + component.spriteName;
129
+ }
130
+ else {
131
+ img = data.image;
132
+ }
133
+ const { leftWidth, topHeight, rightWidth, bottomHeight } = component;
134
+ const np = new NinePatch$3(img, leftWidth, topHeight, rightWidth, bottomHeight);
135
+ this.ninePatch[changed.gameObject.id] = np;
136
+ component.ninePatch = np;
137
+ this.containerManager
138
+ .getContainer(changed.gameObject.id)
139
+ .addChildAt(np, 0);
140
+ });
141
+ }
142
+ remove(changed) {
143
+ const gameObjectId = changed.gameObject.id;
203
144
  this.increaseAsyncId(gameObjectId);
204
- var sprite = this.ninePatch[gameObjectId];
145
+ const sprite = this.ninePatch[gameObjectId];
205
146
  if (sprite) {
206
147
  this.containerManager.getContainer(changed.gameObject.id).removeChild(sprite);
207
148
  delete this.ninePatch[changed.gameObject.id];
208
149
  sprite.destroy({ children: true });
209
150
  }
210
- };
211
- NinePatch.systemName = 'NinePatch';
212
- NinePatch = __decorate([
213
- decorators.componentObserver({
214
- NinePatch: ['resource', 'spriteName', 'leftWidth', 'topHeight', 'rightWidth', 'bottomHeight'],
215
- })
216
- ], NinePatch);
217
- return NinePatch;
218
- }(Renderer));
151
+ }
152
+ };
153
+ NinePatch.systemName = 'NinePatch';
154
+ NinePatch = __decorate([
155
+ decorators.componentObserver({
156
+ NinePatch: ['resource', 'spriteName', 'leftWidth', 'topHeight', 'rightWidth', 'bottomHeight'],
157
+ })
158
+ ], NinePatch);
219
159
  var NinePatch$1 = NinePatch;
220
160
 
221
- export { NinePatch$3 as NinePatch, NinePatch$1 as NinePatchSystem };
161
+ export { NinePatch$2 as NinePatch, NinePatch$1 as NinePatchSystem };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eva/plugin-renderer-nine-patch",
3
- "version": "2.0.0-beta.1",
3
+ "version": "2.0.0-beta.2",
4
4
  "description": "@eva/plugin-renderer-nine-patch",
5
5
  "main": "index.js",
6
6
  "module": "dist/plugin-renderer-nine-patch.esm.js",
@@ -19,8 +19,8 @@
19
19
  "homepage": "https://eva.js.org",
20
20
  "dependencies": {
21
21
  "@eva/inspector-decorator": "^0.0.5",
22
- "@eva/plugin-renderer": "2.0.0-beta.1",
23
- "@eva/renderer-adapter": "2.0.0-beta.1",
24
- "@eva/eva.js": "2.0.0-beta.1"
22
+ "@eva/plugin-renderer": "2.0.0-beta.2",
23
+ "@eva/renderer-adapter": "2.0.0-beta.2",
24
+ "@eva/eva.js": "2.0.0-beta.2"
25
25
  }
26
26
  }