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