@eva/plugin-renderer-nine-patch 1.1.1-fix.1 → 1.1.1-fix.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/EVA.plugin.renderer.ninePatch.js +371 -0
- package/dist/EVA.plugin.renderer.ninePatch.min.js +2 -0
- package/dist/EVA.plugin.renderer.ninePatch.min.js.map +1 -0
- package/dist/plugin-renderer-nine-patch.cjs.js +21 -9
- package/dist/plugin-renderer-nine-patch.cjs.prod.js +2 -1
- package/dist/plugin-renderer-nine-patch.cjs.prod.js.map +1 -0
- package/dist/plugin-renderer-nine-patch.d.ts +46 -0
- package/dist/plugin-renderer-nine-patch.esm.js +22 -10
- package/package.json +4 -4
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
window.EVA = window.EVA || {};
|
|
2
|
+
window.EVA.plugin = window.EVA.plugin || {};
|
|
3
|
+
window.EVA.plugin.renderer = window.EVA.plugin.renderer || {};
|
|
4
|
+
|
|
5
|
+
var _EVA_IIFE_ninePatch = function (exports, eva_js, pluginRenderer, rendererAdapter) {
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
var _extendStatics = function extendStatics(d, b) {
|
|
9
|
+
_extendStatics = Object.setPrototypeOf || {
|
|
10
|
+
__proto__: []
|
|
11
|
+
} instanceof Array && function (d, b) {
|
|
12
|
+
d.__proto__ = b;
|
|
13
|
+
} || function (d, b) {
|
|
14
|
+
for (var p in b) {
|
|
15
|
+
if (b.hasOwnProperty(p)) d[p] = b[p];
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
return _extendStatics(d, b);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
function __extends(d, b) {
|
|
23
|
+
_extendStatics(d, b);
|
|
24
|
+
|
|
25
|
+
function __() {
|
|
26
|
+
this.constructor = d;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function __decorate(decorators, target, key, desc) {
|
|
33
|
+
var c = arguments.length,
|
|
34
|
+
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
35
|
+
d;
|
|
36
|
+
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--) {
|
|
37
|
+
if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
38
|
+
}
|
|
39
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
43
|
+
function adopt(value) {
|
|
44
|
+
return value instanceof P ? value : new P(function (resolve) {
|
|
45
|
+
resolve(value);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
50
|
+
function fulfilled(value) {
|
|
51
|
+
try {
|
|
52
|
+
step(generator.next(value));
|
|
53
|
+
} catch (e) {
|
|
54
|
+
reject(e);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function rejected(value) {
|
|
59
|
+
try {
|
|
60
|
+
step(generator["throw"](value));
|
|
61
|
+
} catch (e) {
|
|
62
|
+
reject(e);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function step(result) {
|
|
67
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function __generator(thisArg, body) {
|
|
75
|
+
var _ = {
|
|
76
|
+
label: 0,
|
|
77
|
+
sent: function sent() {
|
|
78
|
+
if (t[0] & 1) throw t[1];
|
|
79
|
+
return t[1];
|
|
80
|
+
},
|
|
81
|
+
trys: [],
|
|
82
|
+
ops: []
|
|
83
|
+
},
|
|
84
|
+
f,
|
|
85
|
+
y,
|
|
86
|
+
t,
|
|
87
|
+
g;
|
|
88
|
+
return g = {
|
|
89
|
+
next: verb(0),
|
|
90
|
+
"throw": verb(1),
|
|
91
|
+
"return": verb(2)
|
|
92
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
93
|
+
return this;
|
|
94
|
+
}), g;
|
|
95
|
+
|
|
96
|
+
function verb(n) {
|
|
97
|
+
return function (v) {
|
|
98
|
+
return step([n, v]);
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function step(op) {
|
|
103
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
104
|
+
|
|
105
|
+
while (_) {
|
|
106
|
+
try {
|
|
107
|
+
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;
|
|
108
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
109
|
+
|
|
110
|
+
switch (op[0]) {
|
|
111
|
+
case 0:
|
|
112
|
+
case 1:
|
|
113
|
+
t = op;
|
|
114
|
+
break;
|
|
115
|
+
|
|
116
|
+
case 4:
|
|
117
|
+
_.label++;
|
|
118
|
+
return {
|
|
119
|
+
value: op[1],
|
|
120
|
+
done: false
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
case 5:
|
|
124
|
+
_.label++;
|
|
125
|
+
y = op[1];
|
|
126
|
+
op = [0];
|
|
127
|
+
continue;
|
|
128
|
+
|
|
129
|
+
case 7:
|
|
130
|
+
op = _.ops.pop();
|
|
131
|
+
|
|
132
|
+
_.trys.pop();
|
|
133
|
+
|
|
134
|
+
continue;
|
|
135
|
+
|
|
136
|
+
default:
|
|
137
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
138
|
+
_ = 0;
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
143
|
+
_.label = op[1];
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
148
|
+
_.label = t[1];
|
|
149
|
+
t = op;
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (t && _.label < t[2]) {
|
|
154
|
+
_.label = t[2];
|
|
155
|
+
|
|
156
|
+
_.ops.push(op);
|
|
157
|
+
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (t[2]) _.ops.pop();
|
|
162
|
+
|
|
163
|
+
_.trys.pop();
|
|
164
|
+
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
op = body.call(thisArg, _);
|
|
169
|
+
} catch (e) {
|
|
170
|
+
op = [6, e];
|
|
171
|
+
y = 0;
|
|
172
|
+
} finally {
|
|
173
|
+
f = t = 0;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (op[0] & 5) throw op[1];
|
|
178
|
+
return {
|
|
179
|
+
value: op[0] ? op[1] : void 0,
|
|
180
|
+
done: true
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function getIDEPropsPropertyObj(target, propertyKey) {
|
|
186
|
+
if (!target.constructor.IDEProps) {
|
|
187
|
+
target.constructor.IDEProps = {};
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (!target.constructor.IDEProps[propertyKey]) {
|
|
191
|
+
target.constructor.IDEProps[propertyKey] = {};
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
var propertyObj = target.constructor.IDEProps[propertyKey];
|
|
195
|
+
return propertyObj;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function type(type) {
|
|
199
|
+
return function (target, propertyKey) {
|
|
200
|
+
var prop = getIDEPropsPropertyObj(target, propertyKey);
|
|
201
|
+
prop.key = propertyKey;
|
|
202
|
+
prop.type = type;
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function step(step) {
|
|
207
|
+
return function (target, propertyKey) {
|
|
208
|
+
var prop = getIDEPropsPropertyObj(target, propertyKey);
|
|
209
|
+
prop.step = step;
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
var NinePatch$2 = function (_super) {
|
|
214
|
+
__extends(NinePatch, _super);
|
|
215
|
+
|
|
216
|
+
function NinePatch() {
|
|
217
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
218
|
+
|
|
219
|
+
_this.resource = '';
|
|
220
|
+
_this.spriteName = '';
|
|
221
|
+
_this.leftWidth = 0;
|
|
222
|
+
_this.topHeight = 0;
|
|
223
|
+
_this.rightWidth = 0;
|
|
224
|
+
_this.bottomHeight = 0;
|
|
225
|
+
return _this;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
NinePatch.prototype.init = function (obj) {
|
|
229
|
+
this.resource = obj.resource;
|
|
230
|
+
this.spriteName = obj.spriteName;
|
|
231
|
+
this.leftWidth = obj.leftWidth;
|
|
232
|
+
this.topHeight = obj.topHeight;
|
|
233
|
+
this.rightWidth = obj.rightWidth;
|
|
234
|
+
this.bottomHeight = obj.bottomHeight;
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
NinePatch.componentName = 'NinePatch';
|
|
238
|
+
|
|
239
|
+
__decorate([type('string')], NinePatch.prototype, "resource", void 0);
|
|
240
|
+
|
|
241
|
+
__decorate([type('string')], NinePatch.prototype, "spriteName", void 0);
|
|
242
|
+
|
|
243
|
+
__decorate([type('number'), step(1)], NinePatch.prototype, "leftWidth", void 0);
|
|
244
|
+
|
|
245
|
+
__decorate([type('number'), step(1)], NinePatch.prototype, "topHeight", void 0);
|
|
246
|
+
|
|
247
|
+
__decorate([type('number'), step(1)], NinePatch.prototype, "rightWidth", void 0);
|
|
248
|
+
|
|
249
|
+
__decorate([type('number'), step(1)], NinePatch.prototype, "bottomHeight", void 0);
|
|
250
|
+
|
|
251
|
+
return NinePatch;
|
|
252
|
+
}(eva_js.Component);
|
|
253
|
+
|
|
254
|
+
var NinePatch$3 = NinePatch$2;
|
|
255
|
+
var resourceKeySplit = '_s|r|c_';
|
|
256
|
+
|
|
257
|
+
var NinePatch = function (_super) {
|
|
258
|
+
__extends(NinePatch, _super);
|
|
259
|
+
|
|
260
|
+
function NinePatch() {
|
|
261
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
262
|
+
|
|
263
|
+
_this.name = 'NinePatch';
|
|
264
|
+
_this.ninePatch = {};
|
|
265
|
+
return _this;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
NinePatch.prototype.init = function () {
|
|
269
|
+
this.renderSystem = this.game.getSystem(pluginRenderer.RendererSystem);
|
|
270
|
+
this.renderSystem.rendererManager.register(this);
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
NinePatch.prototype.rendererUpdate = function (gameObject) {
|
|
274
|
+
var _a = gameObject.transform.size,
|
|
275
|
+
width = _a.width,
|
|
276
|
+
height = _a.height;
|
|
277
|
+
|
|
278
|
+
if (this.ninePatch[gameObject.id]) {
|
|
279
|
+
this.ninePatch[gameObject.id].width = width;
|
|
280
|
+
this.ninePatch[gameObject.id].height = height;
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
NinePatch.prototype.componentChanged = function (changed) {
|
|
285
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
286
|
+
return __generator(this, function (_a) {
|
|
287
|
+
if (changed.componentName === 'NinePatch') {
|
|
288
|
+
if (changed.type === eva_js.OBSERVER_TYPE.ADD) {
|
|
289
|
+
this.add(changed);
|
|
290
|
+
} else if (changed.type === eva_js.OBSERVER_TYPE.REMOVE) {
|
|
291
|
+
this.remove(changed);
|
|
292
|
+
} else {
|
|
293
|
+
this.remove(changed);
|
|
294
|
+
this.add(changed);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
return [2];
|
|
299
|
+
});
|
|
300
|
+
});
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
NinePatch.prototype.add = function (changed) {
|
|
304
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
305
|
+
var component, gameObjectId, asyncId, _a, type, data, img, leftWidth, topHeight, rightWidth, bottomHeight, np;
|
|
306
|
+
|
|
307
|
+
return __generator(this, function (_b) {
|
|
308
|
+
switch (_b.label) {
|
|
309
|
+
case 0:
|
|
310
|
+
component = changed.component;
|
|
311
|
+
gameObjectId = changed.gameObject.id;
|
|
312
|
+
asyncId = this.increaseAsyncId(gameObjectId);
|
|
313
|
+
return [4, eva_js.resource.getResource(component.resource)];
|
|
314
|
+
|
|
315
|
+
case 1:
|
|
316
|
+
_a = _b.sent(), type = _a.type, data = _a.data;
|
|
317
|
+
if (!this.validateAsyncId(gameObjectId, asyncId)) return [2];
|
|
318
|
+
|
|
319
|
+
if (!data) {
|
|
320
|
+
console.error("GameObject:" + changed.gameObject.name + "'s NinePatch resource load error");
|
|
321
|
+
return [2];
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
if (type === eva_js.RESOURCE_TYPE.SPRITE) {
|
|
325
|
+
img = component.resource + resourceKeySplit + component.spriteName;
|
|
326
|
+
} else {
|
|
327
|
+
img = data.image;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
leftWidth = component.leftWidth, topHeight = component.topHeight, rightWidth = component.rightWidth, bottomHeight = component.bottomHeight;
|
|
331
|
+
np = new rendererAdapter.NinePatch(img, leftWidth, topHeight, rightWidth, bottomHeight);
|
|
332
|
+
this.ninePatch[changed.gameObject.id] = np;
|
|
333
|
+
component.ninePatch = np;
|
|
334
|
+
this.containerManager.getContainer(changed.gameObject.id).addChildAt(np, 0);
|
|
335
|
+
return [2];
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
});
|
|
339
|
+
};
|
|
340
|
+
|
|
341
|
+
NinePatch.prototype.remove = function (changed) {
|
|
342
|
+
var gameObjectId = changed.gameObject.id;
|
|
343
|
+
this.increaseAsyncId(gameObjectId);
|
|
344
|
+
var sprite = this.ninePatch[gameObjectId];
|
|
345
|
+
|
|
346
|
+
if (sprite) {
|
|
347
|
+
this.containerManager.getContainer(changed.gameObject.id).removeChild(sprite);
|
|
348
|
+
delete this.ninePatch[changed.gameObject.id];
|
|
349
|
+
sprite.destroy({
|
|
350
|
+
children: true
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
NinePatch.systemName = 'NinePatch';
|
|
356
|
+
NinePatch = __decorate([eva_js.decorators.componentObserver({
|
|
357
|
+
NinePatch: ['resource', 'spriteName', 'leftWidth', 'topHeight', 'rightWidth', 'bottomHeight']
|
|
358
|
+
})], NinePatch);
|
|
359
|
+
return NinePatch;
|
|
360
|
+
}(pluginRenderer.Renderer);
|
|
361
|
+
|
|
362
|
+
var NinePatch$1 = NinePatch;
|
|
363
|
+
exports.NinePatch = NinePatch$3;
|
|
364
|
+
exports.NinePatchSystem = NinePatch$1;
|
|
365
|
+
Object.defineProperty(exports, '__esModule', {
|
|
366
|
+
value: true
|
|
367
|
+
});
|
|
368
|
+
return exports;
|
|
369
|
+
}({}, EVA, EVA.plugin.renderer, EVA.rendererAdapter);
|
|
370
|
+
|
|
371
|
+
window.EVA.plugin.renderer.ninePatch = window.EVA.plugin.renderer.ninePatch || _EVA_IIFE_ninePatch;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var e,t;e=this,t=function(e,t,r,n){"use strict";var o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};function i(e,t){function r(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function a(e,t,r,n){var o,i=arguments.length,a=i<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--)(o=e[c])&&(a=(i<3?o(a):i>3?o(t,r,a):o(t,r))||a);return i>3&&a&&Object.defineProperty(t,r,a),a}function c(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{h(n.next(e))}catch(e){i(e)}}function c(e){try{h(n.throw(e))}catch(e){i(e)}}function h(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,c)}h((n=n.apply(e,t||[])).next())}))}function h(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)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 a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}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,c])}}}var s=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 i(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.decorators.IDEProp],r.prototype,"resource",void 0),a([t.decorators.IDEProp],r.prototype,"spriteName",void 0),a([t.decorators.IDEProp],r.prototype,"leftWidth",void 0),a([t.decorators.IDEProp],r.prototype,"topHeight",void 0),a([t.decorators.IDEProp],r.prototype,"rightWidth",void 0),a([t.decorators.IDEProp],r.prototype,"bottomHeight",void 0),r}(t.Component),p=function(e){function o(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="NinePatch",t.ninePatch={},t}return i(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.ninePatch[e.id]&&(this.ninePatch[e.id].width=r,this.ninePatch[e.id].height=n)},o.prototype.componentChanged=function(e){return c(this,void 0,void 0,(function(){return h(this,(function(r){return"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))),[2]}))}))},o.prototype.add=function(e){return c(this,void 0,void 0,(function(){var r,o,i,a,c,s,p,u,d,l;return h(this,(function(h){switch(h.label){case 0:return r=e.component,[4,t.resource.getResource(r.resource)];case 1:if(o=h.sent(),i=o.type,!(a=o.data))throw new Error("GameObject:"+e.gameObject.name+"'s NinePatch resource load error");return c=i===t.RESOURCE_TYPE.SPRITE?r.resource+"_s|r|c_"+r.spriteName:a.image,s=r.leftWidth,p=r.topHeight,u=r.rightWidth,d=r.bottomHeight,l=new n.NinePatch(c,s,p,u,d),this.ninePatch[e.gameObject.id]=l,r.ninePatch=l,this.containerManager.getContainer(e.gameObject.id).addChildAt(l,0),[2]}}))}))},o.prototype.remove=function(e){var t=this.ninePatch[e.gameObject.id];t&&(this.containerManager.getContainer(e.gameObject.id).removeChild(t),delete this.ninePatch[e.gameObject.id],t.destroy({children:!0}))},o.systemName="NinePatch",o=a([t.decorators.componentObserver({NinePatch:["resource","spriteName","leftWidth","topHeight","rightWidth","bottomHeight"]})],o)}(r.Renderer);e.NinePatch=s,e.NinePatchSystem=p,Object.defineProperty(e,"__esModule",{value:!0})},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@eva/eva.js"),require("@eva/plugin-renderer"),require("@eva/renderer-adapter")):"function"==typeof define&&define.amd?define(["exports","@eva/eva.js","@eva/plugin-renderer","@eva/renderer-adapter"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).EVA=e.EVA||{},e.EVA.plugin=e.EVA.plugin||{},e.EVA.plugin.renderer=e.EVA.plugin.renderer||{},e.EVA.plugin.renderer.ninePatch={}),e.EVA,e.EVA.plugin.renderer,e.EVA.rendererAdapter);
|
|
2
|
+
//# sourceMappingURL=EVA.plugin.renderer.ninePatch.min.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EVA.plugin.renderer.ninePatch.min.js","sources":["../../../node_modules/tslib/tslib.es6.js","../lib/component.ts","../lib/system.ts"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n 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;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport function __createBinding(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n}\r\n\r\nexport function __exportStar(m, exports) {\r\n for (var p in m) if (p !== \"default\" && !exports.hasOwnProperty(p)) exports[p] = m[p];\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n};\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\r\n result.default = mod;\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, privateMap) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to get private field on non-instance\");\r\n }\r\n return privateMap.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, privateMap, value) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to set private field on non-instance\");\r\n }\r\n privateMap.set(receiver, value);\r\n return value;\r\n}\r\n","import { Component, decorators } from '@eva/eva.js';\n\nexport interface NinePatchParams {\n resource: string;\n spriteName?: string;\n leftWidth?: number;\n topHeight?: number;\n rightWidth?: number;\n bottomHeight?: number;\n}\n\nexport default class NinePatch extends Component<NinePatchParams> {\n static componentName: string = 'NinePatch';\n ninePatch: any;\n @decorators.IDEProp resource: string = '';\n @decorators.IDEProp spriteName: string = '';\n\n @decorators.IDEProp leftWidth: number = 0;\n @decorators.IDEProp topHeight: number = 0;\n @decorators.IDEProp rightWidth: number = 0;\n @decorators.IDEProp bottomHeight: number = 0;\n init(obj?: NinePatchParams) {\n this.resource = obj.resource;\n this.spriteName = obj.spriteName;\n this.leftWidth = obj.leftWidth;\n this.topHeight = obj.topHeight;\n this.rightWidth = obj.rightWidth;\n this.bottomHeight = obj.bottomHeight;\n }\n}\n","import { GameObject, decorators, resource, ComponentChanged, RESOURCE_TYPE, OBSERVER_TYPE } from '@eva/eva.js';\nimport { RendererManager, ContainerManager, RendererSystem, Renderer } from '@eva/plugin-renderer';\nimport { NinePatch as NinePatchSprite } from '@eva/renderer-adapter';\nimport NinePatchComponent from './component';\n\nconst resourceKeySplit = '_s|r|c_'; // Notice: This key be created by sprite system.\n\n@decorators.componentObserver({\n NinePatch: ['resource', 'spriteName', 'leftWidth', 'topHeight', 'rightWidth', 'bottomHeight'],\n})\nexport default class NinePatch extends Renderer {\n static systemName: string = 'NinePatch';\n name: string = 'NinePatch';\n ninePatch: { [propName: number]: any } = {};\n renderSystem: RendererSystem;\n rendererManager: RendererManager;\n containerManager: ContainerManager;\n init() {\n this.renderSystem = this.game.getSystem(RendererSystem) as RendererSystem;\n this.renderSystem.rendererManager.register(this);\n }\n rendererUpdate(gameObject: GameObject) {\n const { width, height } = gameObject.transform.size;\n if (this.ninePatch[gameObject.id]) {\n this.ninePatch[gameObject.id].width = width;\n this.ninePatch[gameObject.id].height = height;\n }\n }\n async componentChanged(changed: ComponentChanged) {\n if (changed.componentName === 'NinePatch') {\n if (changed.type === OBSERVER_TYPE.ADD) {\n this.add(changed);\n } else if (changed.type === OBSERVER_TYPE.REMOVE) {\n this.remove(changed);\n } else {\n this.remove(changed);\n this.add(changed);\n }\n }\n }\n async add(changed) {\n const component = changed.component as NinePatchComponent;\n const { type, data } = await resource.getResource(component.resource);\n if (!data) {\n throw new Error(`GameObject:${changed.gameObject.name}'s NinePatch resource load error`);\n }\n let img: any;\n if (type === RESOURCE_TYPE.SPRITE) {\n img = component.resource + resourceKeySplit + component.spriteName;\n } else {\n img = data.image;\n }\n const { leftWidth, topHeight, rightWidth, bottomHeight } = component;\n const np = new NinePatchSprite(img, leftWidth, topHeight, rightWidth, bottomHeight);\n\n this.ninePatch[changed.gameObject.id] = np;\n component.ninePatch = np;\n this.containerManager\n .getContainer(changed.gameObject.id)\n // @ts-ignore\n .addChildAt(np, 0);\n }\n remove(changed) {\n const sprite = this.ninePatch[changed.gameObject.id];\n if (sprite) {\n this.containerManager.getContainer(changed.gameObject.id).removeChild(sprite);\n delete this.ninePatch[changed.gameObject.id];\n sprite.destroy({ children: true });\n }\n }\n}\n"],"names":["extendStatics","d","b","Object","setPrototypeOf","__proto__","Array","p","hasOwnProperty","__extends","__","this","constructor","prototype","create","__decorate","decorators","target","key","desc","c","arguments","length","r","getOwnPropertyDescriptor","Reflect","decorate","i","defineProperty","__awaiter","thisArg","_arguments","P","generator","Promise","resolve","reject","fulfilled","value","step","next","e","rejected","result","done","then","apply","__generator","body","f","y","t","g","_","label","sent","trys","ops","verb","throw","return","Symbol","iterator","n","v","op","TypeError","call","pop","push","_this","NinePatch","obj","resource","spriteName","leftWidth","topHeight","rightWidth","bottomHeight","IDEProp","Component","renderSystem","game","getSystem","RendererSystem","rendererManager","register","gameObject","_a","transform","size","width","height","ninePatch","id","changed","componentName","type","OBSERVER_TYPE","ADD","add","REMOVE","remove","component","getResource","_b","data","Error","name","img","RESOURCE_TYPE","SPRITE","image","np","NinePatchSprite","containerManager","getContainer","addChildAt","sprite","removeChild","destroy","children","componentObserver","Renderer"],"mappings":"gDAgBA,IAAIA,EAAgB,SAASC,EAAGC,GAI5B,OAHAF,EAAgBG,OAAOC,gBAClB,CAAEC,UAAW,cAAgBC,OAAS,SAAUL,EAAGC,GAAKD,EAAEI,UAAYH,IACvE,SAAUD,EAAGC,GAAK,IAAK,IAAIK,KAAKL,EAAOA,EAAEM,eAAeD,KAAIN,EAAEM,GAAKL,EAAEK,MACpDN,EAAGC,IAGrB,SAASO,EAAUR,EAAGC,GAEzB,SAASQ,IAAOC,KAAKC,YAAcX,EADnCD,EAAcC,EAAGC,GAEjBD,EAAEY,UAAkB,OAANX,EAAaC,OAAOW,OAAOZ,IAAMQ,EAAGG,UAAYX,EAAEW,UAAW,IAAIH,GA0B5E,SAASK,EAAWC,EA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= require('@eva/eva.js');
|
|
6
|
+
var inspectorDecorator = require('@eva/inspector-decorator');
|
|
6
7
|
var pluginRenderer = require('@eva/plugin-renderer');
|
|
7
8
|
var rendererAdapter = require('@eva/renderer-adapter');
|
|
8
9
|
|
|
@@ -101,22 +102,26 @@ var NinePatch$2 = (function (_super) {
|
|
|
101
102
|
};
|
|
102
103
|
NinePatch.componentName = 'NinePatch';
|
|
103
104
|
__decorate([
|
|
104
|
-
|
|
105
|
+
inspectorDecorator.type('string')
|
|
105
106
|
], NinePatch.prototype, "resource", void 0);
|
|
106
107
|
__decorate([
|
|
107
|
-
|
|
108
|
+
inspectorDecorator.type('string')
|
|
108
109
|
], NinePatch.prototype, "spriteName", void 0);
|
|
109
110
|
__decorate([
|
|
110
|
-
|
|
111
|
+
inspectorDecorator.type('number'),
|
|
112
|
+
inspectorDecorator.step(1)
|
|
111
113
|
], NinePatch.prototype, "leftWidth", void 0);
|
|
112
114
|
__decorate([
|
|
113
|
-
|
|
115
|
+
inspectorDecorator.type('number'),
|
|
116
|
+
inspectorDecorator.step(1)
|
|
114
117
|
], NinePatch.prototype, "topHeight", void 0);
|
|
115
118
|
__decorate([
|
|
116
|
-
|
|
119
|
+
inspectorDecorator.type('number'),
|
|
120
|
+
inspectorDecorator.step(1)
|
|
117
121
|
], NinePatch.prototype, "rightWidth", void 0);
|
|
118
122
|
__decorate([
|
|
119
|
-
|
|
123
|
+
inspectorDecorator.type('number'),
|
|
124
|
+
inspectorDecorator.step(1)
|
|
120
125
|
], NinePatch.prototype, "bottomHeight", void 0);
|
|
121
126
|
return NinePatch;
|
|
122
127
|
}(eva_js.Component));
|
|
@@ -163,16 +168,21 @@ var NinePatch = (function (_super) {
|
|
|
163
168
|
};
|
|
164
169
|
NinePatch.prototype.add = function (changed) {
|
|
165
170
|
return __awaiter(this, void 0, void 0, function () {
|
|
166
|
-
var component, _a, type, data, img, leftWidth, topHeight, rightWidth, bottomHeight, np;
|
|
171
|
+
var component, gameObjectId, asyncId, _a, type, data, img, leftWidth, topHeight, rightWidth, bottomHeight, np;
|
|
167
172
|
return __generator(this, function (_b) {
|
|
168
173
|
switch (_b.label) {
|
|
169
174
|
case 0:
|
|
170
175
|
component = changed.component;
|
|
176
|
+
gameObjectId = changed.gameObject.id;
|
|
177
|
+
asyncId = this.increaseAsyncId(gameObjectId);
|
|
171
178
|
return [4, eva_js.resource.getResource(component.resource)];
|
|
172
179
|
case 1:
|
|
173
180
|
_a = _b.sent(), type = _a.type, data = _a.data;
|
|
181
|
+
if (!this.validateAsyncId(gameObjectId, asyncId))
|
|
182
|
+
return [2];
|
|
174
183
|
if (!data) {
|
|
175
|
-
|
|
184
|
+
console.error("GameObject:" + changed.gameObject.name + "'s NinePatch resource load error");
|
|
185
|
+
return [2];
|
|
176
186
|
}
|
|
177
187
|
if (type === eva_js.RESOURCE_TYPE.SPRITE) {
|
|
178
188
|
img = component.resource + resourceKeySplit + component.spriteName;
|
|
@@ -193,7 +203,9 @@ var NinePatch = (function (_super) {
|
|
|
193
203
|
});
|
|
194
204
|
};
|
|
195
205
|
NinePatch.prototype.remove = function (changed) {
|
|
196
|
-
var
|
|
206
|
+
var gameObjectId = changed.gameObject.id;
|
|
207
|
+
this.increaseAsyncId(gameObjectId);
|
|
208
|
+
var sprite = this.ninePatch[gameObjectId];
|
|
197
209
|
if (sprite) {
|
|
198
210
|
this.containerManager.getContainer(changed.gameObject.id).removeChild(sprite);
|
|
199
211
|
delete this.ninePatch[changed.gameObject.id];
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@eva/eva.js"),e=require("@eva/plugin-renderer"),r=require("@eva/renderer-adapter"),o=function(t,e){return
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@eva/eva.js"),e=require("@eva/plugin-renderer"),r=require("@eva/renderer-adapter"),o=function(t,e){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)};function n(t,e){function r(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function i(t,e,r,o){var n,i=arguments.length,a=i<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,r):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,r,o);else for(var c=t.length-1;c>=0;c--)(n=t[c])&&(a=(i<3?n(a):i>3?n(e,r,a):n(e,r))||a);return i>3&&a&&Object.defineProperty(e,r,a),a}function a(t,e,r,o){return new(r||(r=Promise))((function(n,i){function a(t){try{h(o.next(t))}catch(t){i(t)}}function c(t){try{h(o.throw(t))}catch(t){i(t)}}function h(t){t.done?n(t.value):new r((function(e){e(t.value)})).then(a,c)}h((o=o.apply(t,e||[])).next())}))}function c(t,e){var r,o,n,i,a={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,o&&(n=2&i[0]?o.return:i[0]?o.throw||((n=o.return)&&n.call(o),0):o.next)&&!(n=n.call(o,i[1])).done)return n;switch(o=0,n&&(i=[2&i[0],n.value]),i[0]){case 0:case 1:n=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,o=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(n=a.trys,(n=n.length>0&&n[n.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!n||i[1]>n[0]&&i[1]<n[3])){a.label=i[1];break}if(6===i[0]&&a.label<n[1]){a.label=n[1],n=i;break}if(n&&a.label<n[2]){a.label=n[2],a.ops.push(i);break}n[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],o=0}finally{r=n=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,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 n(r,e),r.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},r.componentName="NinePatch",i([t.decorators.IDEProp],r.prototype,"resource",void 0),i([t.decorators.IDEProp],r.prototype,"spriteName",void 0),i([t.decorators.IDEProp],r.prototype,"leftWidth",void 0),i([t.decorators.IDEProp],r.prototype,"topHeight",void 0),i([t.decorators.IDEProp],r.prototype,"rightWidth",void 0),i([t.decorators.IDEProp],r.prototype,"bottomHeight",void 0),r}(t.Component),s=function(o){function h(){var t=null!==o&&o.apply(this,arguments)||this;return t.name="NinePatch",t.ninePatch={},t}return n(h,o),h.prototype.init=function(){this.renderSystem=this.game.getSystem(e.RendererSystem),this.renderSystem.rendererManager.register(this)},h.prototype.rendererUpdate=function(t){var e=t.transform.size,r=e.width,o=e.height;this.ninePatch[t.id]&&(this.ninePatch[t.id].width=r,this.ninePatch[t.id].height=o)},h.prototype.componentChanged=function(e){return a(this,void 0,void 0,(function(){return c(this,(function(r){return"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))),[2]}))}))},h.prototype.add=function(e){return a(this,void 0,void 0,(function(){var o,n,i,a,h,s,p,u,d,l;return c(this,(function(c){switch(c.label){case 0:return o=e.component,[4,t.resource.getResource(o.resource)];case 1:if(n=c.sent(),i=n.type,!(a=n.data))throw new Error("GameObject:"+e.gameObject.name+"'s NinePatch resource load error");return h=i===t.RESOURCE_TYPE.SPRITE?o.resource+"_s|r|c_"+o.spriteName:a.image,s=o.leftWidth,p=o.topHeight,u=o.rightWidth,d=o.bottomHeight,l=new r.NinePatch(h,s,p,u,d),this.ninePatch[e.gameObject.id]=l,o.ninePatch=l,this.containerManager.getContainer(e.gameObject.id).addChildAt(l,0),[2]}}))}))},h.prototype.remove=function(t){var e=this.ninePatch[t.gameObject.id];e&&(this.containerManager.getContainer(t.gameObject.id).removeChild(e),delete this.ninePatch[t.gameObject.id],e.destroy({children:!0}))},h.systemName="NinePatch",h=i([t.decorators.componentObserver({NinePatch:["resource","spriteName","leftWidth","topHeight","rightWidth","bottomHeight"]})],h)}(e.Renderer);exports.NinePatch=h,exports.NinePatchSystem=s;
|
|
2
|
+
//# sourceMappingURL=plugin-renderer-nine-patch.cjs.prod.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-renderer-nine-patch.cjs.prod.js","sources":["../lib/component.ts","../lib/system.ts"],"sourcesContent":["import { Component, decorators } from '@eva/eva.js';\n\nexport interface NinePatchParams {\n resource: string;\n spriteName?: string;\n leftWidth?: number;\n topHeight?: number;\n rightWidth?: number;\n bottomHeight?: number;\n}\n\nexport default class NinePatch extends Component<NinePatchParams> {\n static componentName: string = 'NinePatch';\n ninePatch: any;\n @decorators.IDEProp resource: string = '';\n @decorators.IDEProp spriteName: string = '';\n\n @decorators.IDEProp leftWidth: number = 0;\n @decorators.IDEProp topHeight: number = 0;\n @decorators.IDEProp rightWidth: number = 0;\n @decorators.IDEProp bottomHeight: number = 0;\n init(obj?: NinePatchParams) {\n this.resource = obj.resource;\n this.spriteName = obj.spriteName;\n this.leftWidth = obj.leftWidth;\n this.topHeight = obj.topHeight;\n this.rightWidth = obj.rightWidth;\n this.bottomHeight = obj.bottomHeight;\n }\n}\n","import { GameObject, decorators, resource, ComponentChanged, RESOURCE_TYPE, OBSERVER_TYPE } from '@eva/eva.js';\nimport { RendererManager, ContainerManager, RendererSystem, Renderer } from '@eva/plugin-renderer';\nimport { NinePatch as NinePatchSprite } from '@eva/renderer-adapter';\nimport NinePatchComponent from './component';\n\nconst resourceKeySplit = '_s|r|c_'; // Notice: This key be created by sprite system.\n\n@decorators.componentObserver({\n NinePatch: ['resource', 'spriteName', 'leftWidth', 'topHeight', 'rightWidth', 'bottomHeight'],\n})\nexport default class NinePatch extends Renderer {\n static systemName: string = 'NinePatch';\n name: string = 'NinePatch';\n ninePatch: { [propName: number]: any } = {};\n renderSystem: RendererSystem;\n rendererManager: RendererManager;\n containerManager: ContainerManager;\n init() {\n this.renderSystem = this.game.getSystem(RendererSystem) as RendererSystem;\n this.renderSystem.rendererManager.register(this);\n }\n rendererUpdate(gameObject: GameObject) {\n const { width, height } = gameObject.transform.size;\n if (this.ninePatch[gameObject.id]) {\n this.ninePatch[gameObject.id].width = width;\n this.ninePatch[gameObject.id].height = height;\n }\n }\n async componentChanged(changed: ComponentChanged) {\n if (changed.componentName === 'NinePatch') {\n if (changed.type === OBSERVER_TYPE.ADD) {\n this.add(changed);\n } else if (changed.type === OBSERVER_TYPE.REMOVE) {\n this.remove(changed);\n } else {\n this.remove(changed);\n this.add(changed);\n }\n }\n }\n async add(changed) {\n const component = changed.component as NinePatchComponent;\n const { type, data } = await resource.getResource(component.resource);\n if (!data) {\n throw new Error(`GameObject:${changed.gameObject.name}'s NinePatch resource load error`);\n }\n let img: any;\n if (type === RESOURCE_TYPE.SPRITE) {\n img = component.resource + resourceKeySplit + component.spriteName;\n } else {\n img = data.image;\n }\n const { leftWidth, topHeight, rightWidth, bottomHeight } = component;\n const np = new NinePatchSprite(img, leftWidth, topHeight, rightWidth, bottomHeight);\n\n this.ninePatch[changed.gameObject.id] = np;\n component.ninePatch = np;\n this.containerManager\n .getContainer(changed.gameObject.id)\n // @ts-ignore\n .addChildAt(np, 0);\n }\n remove(changed) {\n const sprite = this.ninePatch[changed.gameObject.id];\n if (sprite) {\n this.containerManager.getContainer(changed.gameObject.id).removeChild(sprite);\n delete this.ninePatch[changed.gameObject.id];\n sprite.destroy({ children: true });\n }\n }\n}\n"],"names":["_this","__extends","NinePatch","obj","this","resource","spriteName","leftWidth","topHeight","rightWidth","bottomHeight","__decorate","decorators","IDEProp","Component","renderSystem","game","getSystem","RendererSystem","rendererManager","register","gameObject","_a","transform","size","width","height","ninePatch","id","changed","componentName","type","OBSERVER_TYPE","ADD","add","REMOVE","remove","component","getResource","_b","data","Error","name","img","RESOURCE_TYPE","SPRITE","image","np","NinePatchSprite","containerManager","getContainer","addChildAt","sprite","removeChild","destroy","children","componentObserver","Renderer"],"mappings":"0kEAWA,kBAAA,aAAA,qDAGsBA,WAAmB,GACnBA,aAAqB,GAErBA,YAAoB,EACpBA,YAAoB,EACpBA,aAAqB,EACrBA,eAAuB,IAS7C,OAlBuCC,OAUrCC,iBAAA,SAAKC,GACHC,KAAKC,SAAWF,EAAIE,SACpBD,KAAKE,WAAaH,EAAIG,WACtBF,KAAKG,UAAYJ,EAAII,UACrBH,KAAKI,UAAYL,EAAIK,UACrBJ,KAAKK,WAAaN,EAAIM,WACtBL,KAAKM,aAAeP,EAAIO,cAfnBR,gBAAwB,YAEXS,GAAnBC,aAAWC,wCACQF,GAAnBC,aAAWC,0CAEQF,GAAnBC,aAAWC,yCACQF,GAAnBC,aAAWC,yCACQF,GAAnBC,aAAWC,0CACQF,GAAnBC,aAAWC,+CATyBC,2BCDvC,aAAA,qDAEEd,OAAe,YACfA,YAAyC,KAyD3C,OA5DuCC,OAOrCC,iBAAA,WACEE,KAAKW,aAAeX,KAAKY,KAAKC,UAAUC,kBACxCd,KAAKW,aAAaI,gBAAgBC,SAAShB,OAE7CF,2BAAA,SAAemB,GACP,IAAAC,EAAoBD,EAAWE,UAAUC,KAAvCC,UAAOC,WACXtB,KAAKuB,UAAUN,EAAWO,MAC5BxB,KAAKuB,UAAUN,EAAWO,IAAIH,MAAQA,EACtCrB,KAAKuB,UAAUN,EAAWO,IAAIF,OAASA,IAGrCxB,6BAAN,SAAuB2B,4EACS,cAA1BA,EAAQC,gBACND,EAAQE,OAASC,gBAAcC,IACjC7B,KAAK8B,IAAIL,GACAA,EAAQE,OAASC,gBAAcG,OACxC/B,KAAKgC,OAAOP,IAEZzB,KAAKgC,OAAOP,GACZzB,KAAK8B,IAAIL,gBAIT3B,gBAAN,SAAU2B,qHAEe,OADjBQ,EAAYR,EAAQQ,aACGhC,WAASiC,YAAYD,EAAUhC,kBAC5D,GADMiB,EAAiBiB,SAAfR,WAAMS,UAEZ,MAAM,IAAIC,MAAM,cAAcZ,EAAQR,WAAWqB,gDAIjDC,EADEZ,IAASa,gBAAcC,OACnBR,EAAUhC,SA3CG,UA2C2BgC,EAAU/B,WAElDkC,EAAKM,MAELvC,EAAmD8B,YAAxC7B,EAAwC6B,YAA7B5B,EAA6B4B,aAAjB3B,EAAiB2B,eACrDU,EAAK,IAAIC,YAAgBL,EAAKpC,EAAWC,EAAWC,EAAYC,GAEtEN,KAAKuB,UAAUE,EAAQR,WAAWO,IAAMmB,EACxCV,EAAUV,UAAYoB,EACtB3C,KAAK6C,iBACFC,aAAarB,EAAQR,WAAWO,IAEhCuB,WAAWJ,EAAI,eAEpB7C,mBAAA,SAAO2B,GACL,IAAMuB,EAAShD,KAAKuB,UAAUE,EAAQR,WAAWO,IAC7CwB,IACFhD,KAAK6C,iBAAiBC,aAAarB,EAAQR,WAAWO,IAAIyB,YAAYD,UAC/DhD,KAAKuB,UAAUE,EAAQR,WAAWO,IACzCwB,EAAOE,QAAQ,CAAEC,UAAU,MAxDxBrD,aAAqB,YADTA,KAHpBU,aAAW4C,kBAAkB,CAC5BtD,UAAW,CAAC,WAAY,aAAc,YAAa,YAAa,aAAc,mBAE3DA,IAAkBuD"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Component } from '@eva/eva.js';
|
|
2
|
+
import { ComponentChanged } from '@eva/eva.js';
|
|
3
|
+
import { ContainerManager } from '@eva/plugin-renderer';
|
|
4
|
+
import { GameObject } from '@eva/eva.js';
|
|
5
|
+
import { Renderer } from '@eva/plugin-renderer';
|
|
6
|
+
import { RendererManager } from '@eva/plugin-renderer';
|
|
7
|
+
import { RendererSystem } from '@eva/plugin-renderer';
|
|
8
|
+
|
|
9
|
+
export declare class NinePatch extends Component<NinePatchParams> {
|
|
10
|
+
static componentName: string;
|
|
11
|
+
ninePatch: any;
|
|
12
|
+
resource: string;
|
|
13
|
+
spriteName: string;
|
|
14
|
+
leftWidth: number;
|
|
15
|
+
topHeight: number;
|
|
16
|
+
rightWidth: number;
|
|
17
|
+
bottomHeight: number;
|
|
18
|
+
init(obj?: NinePatchParams): void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export declare interface NinePatchParams {
|
|
22
|
+
resource: string;
|
|
23
|
+
spriteName?: string;
|
|
24
|
+
leftWidth?: number;
|
|
25
|
+
topHeight?: number;
|
|
26
|
+
rightWidth?: number;
|
|
27
|
+
bottomHeight?: number;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export declare class NinePatchSystem extends Renderer {
|
|
31
|
+
static systemName: string;
|
|
32
|
+
name: string;
|
|
33
|
+
ninePatch: {
|
|
34
|
+
[propName: number]: any;
|
|
35
|
+
};
|
|
36
|
+
renderSystem: RendererSystem;
|
|
37
|
+
rendererManager: RendererManager;
|
|
38
|
+
containerManager: ContainerManager;
|
|
39
|
+
init(): void;
|
|
40
|
+
rendererUpdate(gameObject: GameObject): void;
|
|
41
|
+
componentChanged(changed: ComponentChanged): Promise<void>;
|
|
42
|
+
add(changed: any): Promise<void>;
|
|
43
|
+
remove(changed: any): void;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export { }
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Component, decorators, OBSERVER_TYPE, RESOURCE_TYPE, resource } from '@eva/eva.js';
|
|
2
|
+
import { type, step } from '@eva/inspector-decorator';
|
|
2
3
|
import { RendererSystem, Renderer } from '@eva/plugin-renderer';
|
|
3
4
|
import { NinePatch as NinePatch$4 } from '@eva/renderer-adapter';
|
|
4
5
|
|
|
@@ -97,22 +98,26 @@ var NinePatch$2 = (function (_super) {
|
|
|
97
98
|
};
|
|
98
99
|
NinePatch.componentName = 'NinePatch';
|
|
99
100
|
__decorate([
|
|
100
|
-
|
|
101
|
+
type('string')
|
|
101
102
|
], NinePatch.prototype, "resource", void 0);
|
|
102
103
|
__decorate([
|
|
103
|
-
|
|
104
|
+
type('string')
|
|
104
105
|
], NinePatch.prototype, "spriteName", void 0);
|
|
105
106
|
__decorate([
|
|
106
|
-
|
|
107
|
+
type('number'),
|
|
108
|
+
step(1)
|
|
107
109
|
], NinePatch.prototype, "leftWidth", void 0);
|
|
108
110
|
__decorate([
|
|
109
|
-
|
|
111
|
+
type('number'),
|
|
112
|
+
step(1)
|
|
110
113
|
], NinePatch.prototype, "topHeight", void 0);
|
|
111
114
|
__decorate([
|
|
112
|
-
|
|
115
|
+
type('number'),
|
|
116
|
+
step(1)
|
|
113
117
|
], NinePatch.prototype, "rightWidth", void 0);
|
|
114
118
|
__decorate([
|
|
115
|
-
|
|
119
|
+
type('number'),
|
|
120
|
+
step(1)
|
|
116
121
|
], NinePatch.prototype, "bottomHeight", void 0);
|
|
117
122
|
return NinePatch;
|
|
118
123
|
}(Component));
|
|
@@ -159,16 +164,21 @@ var NinePatch = (function (_super) {
|
|
|
159
164
|
};
|
|
160
165
|
NinePatch.prototype.add = function (changed) {
|
|
161
166
|
return __awaiter(this, void 0, void 0, function () {
|
|
162
|
-
var component, _a, type, data, img, leftWidth, topHeight, rightWidth, bottomHeight, np;
|
|
167
|
+
var component, gameObjectId, asyncId, _a, type, data, img, leftWidth, topHeight, rightWidth, bottomHeight, np;
|
|
163
168
|
return __generator(this, function (_b) {
|
|
164
169
|
switch (_b.label) {
|
|
165
170
|
case 0:
|
|
166
171
|
component = changed.component;
|
|
172
|
+
gameObjectId = changed.gameObject.id;
|
|
173
|
+
asyncId = this.increaseAsyncId(gameObjectId);
|
|
167
174
|
return [4, resource.getResource(component.resource)];
|
|
168
175
|
case 1:
|
|
169
176
|
_a = _b.sent(), type = _a.type, data = _a.data;
|
|
177
|
+
if (!this.validateAsyncId(gameObjectId, asyncId))
|
|
178
|
+
return [2];
|
|
170
179
|
if (!data) {
|
|
171
|
-
|
|
180
|
+
console.error("GameObject:" + changed.gameObject.name + "'s NinePatch resource load error");
|
|
181
|
+
return [2];
|
|
172
182
|
}
|
|
173
183
|
if (type === RESOURCE_TYPE.SPRITE) {
|
|
174
184
|
img = component.resource + resourceKeySplit + component.spriteName;
|
|
@@ -189,7 +199,9 @@ var NinePatch = (function (_super) {
|
|
|
189
199
|
});
|
|
190
200
|
};
|
|
191
201
|
NinePatch.prototype.remove = function (changed) {
|
|
192
|
-
var
|
|
202
|
+
var gameObjectId = changed.gameObject.id;
|
|
203
|
+
this.increaseAsyncId(gameObjectId);
|
|
204
|
+
var sprite = this.ninePatch[gameObjectId];
|
|
193
205
|
if (sprite) {
|
|
194
206
|
this.containerManager.getContainer(changed.gameObject.id).removeChild(sprite);
|
|
195
207
|
delete this.ninePatch[changed.gameObject.id];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eva/plugin-renderer-nine-patch",
|
|
3
|
-
"version": "1.1.1-fix.
|
|
3
|
+
"version": "1.1.1-fix.2",
|
|
4
4
|
"description": "@eva/plugin-renderer-nine-patch",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "dist/plugin-renderer-nine-patch.esm.js",
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"homepage": "https://eva.js.org",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@eva/plugin-renderer": "1.1.1-fix.
|
|
22
|
-
"@eva/renderer-adapter": "1.1.1-fix.
|
|
23
|
-
"@eva/eva.js": "1.1.1-fix.
|
|
21
|
+
"@eva/plugin-renderer": "1.1.1-fix.2",
|
|
22
|
+
"@eva/renderer-adapter": "1.1.1-fix.2",
|
|
23
|
+
"@eva/eva.js": "1.1.1-fix.2"
|
|
24
24
|
}
|
|
25
25
|
}
|