@eva/plugin-renderer-text 2.0.0-beta.1 → 2.0.0-beta.3
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.
|
@@ -4,23 +4,6 @@ window.EVA.plugin = window.EVA.plugin || {};
|
|
|
4
4
|
window.EVA.plugin.renderer = window.EVA.plugin.renderer || {};
|
|
5
5
|
var _EVA_IIFE_text = function (exports, pixi_js, eva_js, pluginRenderer, rendererAdapter) {
|
|
6
6
|
'use strict';
|
|
7
|
-
var extendStatics = function (d, b) {
|
|
8
|
-
extendStatics = Object.setPrototypeOf || {
|
|
9
|
-
__proto__: []
|
|
10
|
-
} instanceof Array && function (d, b) {
|
|
11
|
-
d.__proto__ = b;
|
|
12
|
-
} || function (d, b) {
|
|
13
|
-
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
|
14
|
-
};
|
|
15
|
-
return extendStatics(d, b);
|
|
16
|
-
};
|
|
17
|
-
function __extends(d, b) {
|
|
18
|
-
extendStatics(d, b);
|
|
19
|
-
function __() {
|
|
20
|
-
this.constructor = d;
|
|
21
|
-
}
|
|
22
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
23
|
-
}
|
|
24
7
|
function __decorate(decorators, target, key, desc) {
|
|
25
8
|
var c = arguments.length,
|
|
26
9
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
@@ -55,94 +38,6 @@ var _EVA_IIFE_text = function (exports, pixi_js, eva_js, pluginRenderer, rendere
|
|
|
55
38
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
56
39
|
});
|
|
57
40
|
}
|
|
58
|
-
function __generator(thisArg, body) {
|
|
59
|
-
var _ = {
|
|
60
|
-
label: 0,
|
|
61
|
-
sent: function () {
|
|
62
|
-
if (t[0] & 1) throw t[1];
|
|
63
|
-
return t[1];
|
|
64
|
-
},
|
|
65
|
-
trys: [],
|
|
66
|
-
ops: []
|
|
67
|
-
},
|
|
68
|
-
f,
|
|
69
|
-
y,
|
|
70
|
-
t,
|
|
71
|
-
g;
|
|
72
|
-
return g = {
|
|
73
|
-
next: verb(0),
|
|
74
|
-
"throw": verb(1),
|
|
75
|
-
"return": verb(2)
|
|
76
|
-
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
77
|
-
return this;
|
|
78
|
-
}), g;
|
|
79
|
-
function verb(n) {
|
|
80
|
-
return function (v) {
|
|
81
|
-
return step([n, v]);
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
function step(op) {
|
|
85
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
86
|
-
while (_) try {
|
|
87
|
-
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;
|
|
88
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
89
|
-
switch (op[0]) {
|
|
90
|
-
case 0:
|
|
91
|
-
case 1:
|
|
92
|
-
t = op;
|
|
93
|
-
break;
|
|
94
|
-
case 4:
|
|
95
|
-
_.label++;
|
|
96
|
-
return {
|
|
97
|
-
value: op[1],
|
|
98
|
-
done: false
|
|
99
|
-
};
|
|
100
|
-
case 5:
|
|
101
|
-
_.label++;
|
|
102
|
-
y = op[1];
|
|
103
|
-
op = [0];
|
|
104
|
-
continue;
|
|
105
|
-
case 7:
|
|
106
|
-
op = _.ops.pop();
|
|
107
|
-
_.trys.pop();
|
|
108
|
-
continue;
|
|
109
|
-
default:
|
|
110
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
111
|
-
_ = 0;
|
|
112
|
-
continue;
|
|
113
|
-
}
|
|
114
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
115
|
-
_.label = op[1];
|
|
116
|
-
break;
|
|
117
|
-
}
|
|
118
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
119
|
-
_.label = t[1];
|
|
120
|
-
t = op;
|
|
121
|
-
break;
|
|
122
|
-
}
|
|
123
|
-
if (t && _.label < t[2]) {
|
|
124
|
-
_.label = t[2];
|
|
125
|
-
_.ops.push(op);
|
|
126
|
-
break;
|
|
127
|
-
}
|
|
128
|
-
if (t[2]) _.ops.pop();
|
|
129
|
-
_.trys.pop();
|
|
130
|
-
continue;
|
|
131
|
-
}
|
|
132
|
-
op = body.call(thisArg, _);
|
|
133
|
-
} catch (e) {
|
|
134
|
-
op = [6, e];
|
|
135
|
-
y = 0;
|
|
136
|
-
} finally {
|
|
137
|
-
f = t = 0;
|
|
138
|
-
}
|
|
139
|
-
if (op[0] & 5) throw op[1];
|
|
140
|
-
return {
|
|
141
|
-
value: op[0] ? op[1] : void 0,
|
|
142
|
-
done: true
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
41
|
function getIDEPropsPropertyObj(target, propertyKey) {
|
|
147
42
|
if (!target.constructor.IDEProps) {
|
|
148
43
|
target.constructor.IDEProps = {};
|
|
@@ -160,20 +55,18 @@ var _EVA_IIFE_text = function (exports, pixi_js, eva_js, pluginRenderer, rendere
|
|
|
160
55
|
prop.type = type;
|
|
161
56
|
};
|
|
162
57
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
_this.style = {};
|
|
169
|
-
return _this;
|
|
58
|
+
class Text$2 extends eva_js.Component {
|
|
59
|
+
constructor() {
|
|
60
|
+
super(...arguments);
|
|
61
|
+
this.text = '';
|
|
62
|
+
this.style = {};
|
|
170
63
|
}
|
|
171
|
-
|
|
172
|
-
|
|
64
|
+
init(obj) {
|
|
65
|
+
const style = new pixi_js.TextStyle({
|
|
173
66
|
fontSize: 20
|
|
174
67
|
});
|
|
175
|
-
|
|
176
|
-
for (
|
|
68
|
+
const newStyle = {};
|
|
69
|
+
for (const key in style) {
|
|
177
70
|
if (key.indexOf('_') === 0) {
|
|
178
71
|
newStyle[key.substring(1)] = style[key];
|
|
179
72
|
}
|
|
@@ -184,79 +77,73 @@ var _EVA_IIFE_text = function (exports, pixi_js, eva_js, pluginRenderer, rendere
|
|
|
184
77
|
this.text = obj.text;
|
|
185
78
|
_extends(this.style, obj.style);
|
|
186
79
|
}
|
|
187
|
-
};
|
|
188
|
-
Text.componentName = 'Text';
|
|
189
|
-
__decorate([type('string')], Text.prototype, "text", void 0);
|
|
190
|
-
return Text;
|
|
191
|
-
}(eva_js.Component);
|
|
192
|
-
var Text$3 = Text$2;
|
|
193
|
-
var Text = function (_super) {
|
|
194
|
-
__extends(Text, _super);
|
|
195
|
-
function Text() {
|
|
196
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
197
|
-
_this.name = 'Text';
|
|
198
|
-
_this.texts = {};
|
|
199
|
-
return _this;
|
|
200
80
|
}
|
|
201
|
-
|
|
81
|
+
}
|
|
82
|
+
Text$2.componentName = 'Text';
|
|
83
|
+
__decorate([type('string')], Text$2.prototype, "text", void 0);
|
|
84
|
+
let Text = class Text extends pluginRenderer.Renderer {
|
|
85
|
+
constructor() {
|
|
86
|
+
super(...arguments);
|
|
87
|
+
this.name = 'Text';
|
|
88
|
+
this.texts = {};
|
|
89
|
+
}
|
|
90
|
+
init() {
|
|
202
91
|
this.renderSystem = this.game.getSystem(pluginRenderer.RendererSystem);
|
|
203
92
|
this.renderSystem.rendererManager.register(this);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
this.setSize(changed);
|
|
228
|
-
}
|
|
229
|
-
return [2];
|
|
230
|
-
});
|
|
93
|
+
}
|
|
94
|
+
componentChanged(changed) {
|
|
95
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
96
|
+
if (changed.componentName !== 'Text') return;
|
|
97
|
+
if (changed.type === eva_js.OBSERVER_TYPE.ADD) {
|
|
98
|
+
const component = changed.component;
|
|
99
|
+
const text = new rendererAdapter.Text(component.text, component.style);
|
|
100
|
+
this.containerManager.getContainer(changed.gameObject.id).addChildAt(text, 0);
|
|
101
|
+
this.texts[changed.gameObject.id] = {
|
|
102
|
+
text,
|
|
103
|
+
component: changed.component
|
|
104
|
+
};
|
|
105
|
+
this.setSize(changed);
|
|
106
|
+
} else if (changed.type === eva_js.OBSERVER_TYPE.REMOVE) {
|
|
107
|
+
this.containerManager.getContainer(changed.gameObject.id).removeChild(this.texts[changed.gameObject.id].text);
|
|
108
|
+
this.texts[changed.gameObject.id].text.destroy({
|
|
109
|
+
children: true
|
|
110
|
+
});
|
|
111
|
+
delete this.texts[changed.gameObject.id];
|
|
112
|
+
} else {
|
|
113
|
+
this.change(changed);
|
|
114
|
+
this.setSize(changed);
|
|
115
|
+
}
|
|
231
116
|
});
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
text
|
|
236
|
-
component
|
|
117
|
+
}
|
|
118
|
+
change(changed) {
|
|
119
|
+
const {
|
|
120
|
+
text,
|
|
121
|
+
component
|
|
122
|
+
} = this.texts[changed.gameObject.id];
|
|
237
123
|
if (changed.prop.prop[0] === 'text') {
|
|
238
124
|
text.text = component.text;
|
|
239
125
|
} else if (changed.prop.prop[0] === 'style') {
|
|
240
126
|
_extends(text.style, changed.component.style);
|
|
241
127
|
}
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
|
|
128
|
+
}
|
|
129
|
+
setSize(changed) {
|
|
130
|
+
const {
|
|
131
|
+
transform
|
|
132
|
+
} = changed.gameObject;
|
|
245
133
|
if (!transform) return;
|
|
246
134
|
transform.size.width = this.texts[changed.gameObject.id].text.width;
|
|
247
135
|
transform.size.height = this.texts[changed.gameObject.id].text.height;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
}(pluginRenderer.Renderer);
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
Text.systemName = 'Text';
|
|
139
|
+
Text = __decorate([eva_js.decorators.componentObserver({
|
|
140
|
+
Text: ['text', {
|
|
141
|
+
prop: ['style'],
|
|
142
|
+
deep: true
|
|
143
|
+
}]
|
|
144
|
+
})], Text);
|
|
258
145
|
var Text$1 = Text;
|
|
259
|
-
exports.Text = Text$
|
|
146
|
+
exports.Text = Text$2;
|
|
260
147
|
exports.TextSystem = Text$1;
|
|
261
148
|
Object.defineProperty(exports, '__esModule', {
|
|
262
149
|
value: true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function _extends(){return _extends=Object.assign?Object.assign.bind():function(
|
|
1
|
+
function _extends(){return _extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},_extends.apply(null,arguments)}window.EVA=window.EVA||{},window.EVA.plugin=window.EVA.plugin||{},window.EVA.plugin.renderer=window.EVA.plugin.renderer||{};var _EVA_IIFE_text=function(e,t,n,r,o){"use strict";function i(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(o=e[c])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s}function s(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{d(r.next(e))}catch(e){i(e)}}function c(e){try{d(r.throw(e))}catch(e){i(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,c)}d((r=r.apply(e,t||[])).next())}))}class c extends n.Component{constructor(){super(...arguments),this.text="",this.style={}}init(e){const n=new t.TextStyle({fontSize:20}),r={};for(const e in n)0===e.indexOf("_")&&(r[e.substring(1)]=n[e]);delete r.styleKey,this.style=r,e&&(this.text=e.text,_extends(this.style,e.style))}}c.componentName="Text",i([function(e){return function(t,n){var r=function(e,t){return e.constructor.IDEProps||(e.constructor.IDEProps={}),e.constructor.IDEProps[t]||(e.constructor.IDEProps[t]={}),e.constructor.IDEProps[t]}(t,n);r.key=n,r.type=e}}("string")],c.prototype,"text",void 0);let d=class extends r.Renderer{constructor(){super(...arguments),this.name="Text",this.texts={}}init(){this.renderSystem=this.game.getSystem(r.RendererSystem),this.renderSystem.rendererManager.register(this)}componentChanged(e){return s(this,void 0,void 0,(function*(){if("Text"===e.componentName)if(e.type===n.OBSERVER_TYPE.ADD){const t=e.component,n=new o.Text(t.text,t.style);this.containerManager.getContainer(e.gameObject.id).addChildAt(n,0),this.texts[e.gameObject.id]={text:n,component:e.component},this.setSize(e)}else e.type===n.OBSERVER_TYPE.REMOVE?(this.containerManager.getContainer(e.gameObject.id).removeChild(this.texts[e.gameObject.id].text),this.texts[e.gameObject.id].text.destroy({children:!0}),delete this.texts[e.gameObject.id]):(this.change(e),this.setSize(e))}))}change(e){const{text:t,component:n}=this.texts[e.gameObject.id];"text"===e.prop.prop[0]?t.text=n.text:"style"===e.prop.prop[0]&&_extends(t.style,e.component.style)}setSize(e){const{transform:t}=e.gameObject;t&&(t.size.width=this.texts[e.gameObject.id].text.width,t.size.height=this.texts[e.gameObject.id].text.height)}};d.systemName="Text",d=i([n.decorators.componentObserver({Text:["text",{prop:["style"],deep:!0}]})],d);var a=d;return e.Text=c,e.TextSystem=a,Object.defineProperty(e,"__esModule",{value:!0}),e}({},PIXI,EVA,EVA.plugin.renderer,EVA.rendererAdapter);window.EVA.plugin.renderer.text=window.EVA.plugin.renderer.text||_EVA_IIFE_text;
|
|
@@ -22,20 +22,6 @@ MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
|
22
22
|
See the Apache Version 2.0 License for specific language governing permissions
|
|
23
23
|
and limitations under the License.
|
|
24
24
|
***************************************************************************** */
|
|
25
|
-
/* global Reflect, Promise */
|
|
26
|
-
|
|
27
|
-
var extendStatics = function(d, b) {
|
|
28
|
-
extendStatics = Object.setPrototypeOf ||
|
|
29
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
30
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
31
|
-
return extendStatics(d, b);
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
function __extends(d, b) {
|
|
35
|
-
extendStatics(d, b);
|
|
36
|
-
function __() { this.constructor = d; }
|
|
37
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
38
|
-
}
|
|
39
25
|
|
|
40
26
|
function __decorate(decorators, target, key, desc) {
|
|
41
27
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -51,50 +37,20 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
51
37
|
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
52
38
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
53
39
|
});
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function __generator(thisArg, body) {
|
|
57
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
58
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
59
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
60
|
-
function step(op) {
|
|
61
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
62
|
-
while (_) try {
|
|
63
|
-
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;
|
|
64
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
65
|
-
switch (op[0]) {
|
|
66
|
-
case 0: case 1: t = op; break;
|
|
67
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
68
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
69
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
70
|
-
default:
|
|
71
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
72
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
73
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
74
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
75
|
-
if (t[2]) _.ops.pop();
|
|
76
|
-
_.trys.pop(); continue;
|
|
77
|
-
}
|
|
78
|
-
op = body.call(thisArg, _);
|
|
79
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
80
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
81
|
-
}
|
|
82
40
|
}
|
|
83
41
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
_this.style = {};
|
|
90
|
-
return _this;
|
|
42
|
+
class Text$2 extends eva_js.Component {
|
|
43
|
+
constructor() {
|
|
44
|
+
super(...arguments);
|
|
45
|
+
this.text = '';
|
|
46
|
+
this.style = {};
|
|
91
47
|
}
|
|
92
|
-
|
|
93
|
-
|
|
48
|
+
init(obj) {
|
|
49
|
+
const style = new pixi_js.TextStyle({
|
|
94
50
|
fontSize: 20,
|
|
95
51
|
});
|
|
96
|
-
|
|
97
|
-
for (
|
|
52
|
+
const newStyle = {};
|
|
53
|
+
for (const key in style) {
|
|
98
54
|
if (key.indexOf('_') === 0) {
|
|
99
55
|
newStyle[key.substring(1)] = style[key];
|
|
100
56
|
}
|
|
@@ -105,81 +61,72 @@ var Text$2 = (function (_super) {
|
|
|
105
61
|
this.text = obj.text;
|
|
106
62
|
Object.assign(this.style, obj.style);
|
|
107
63
|
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}(eva_js.Component));
|
|
115
|
-
var Text$3 = Text$2;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
Text$2.componentName = 'Text';
|
|
67
|
+
__decorate([
|
|
68
|
+
inspectorDecorator.type('string')
|
|
69
|
+
], Text$2.prototype, "text", void 0);
|
|
116
70
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
_this.texts = {};
|
|
123
|
-
return _this;
|
|
71
|
+
let Text = class Text extends pluginRenderer.Renderer {
|
|
72
|
+
constructor() {
|
|
73
|
+
super(...arguments);
|
|
74
|
+
this.name = 'Text';
|
|
75
|
+
this.texts = {};
|
|
124
76
|
}
|
|
125
|
-
|
|
77
|
+
init() {
|
|
126
78
|
this.renderSystem = this.game.getSystem(pluginRenderer.RendererSystem);
|
|
127
79
|
this.renderSystem.rendererManager.register(this);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
this.setSize(changed);
|
|
153
|
-
}
|
|
154
|
-
return [2];
|
|
155
|
-
});
|
|
80
|
+
}
|
|
81
|
+
componentChanged(changed) {
|
|
82
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
+
if (changed.componentName !== 'Text')
|
|
84
|
+
return;
|
|
85
|
+
if (changed.type === eva_js.OBSERVER_TYPE.ADD) {
|
|
86
|
+
const component = changed.component;
|
|
87
|
+
const text = new rendererAdapter.Text(component.text, component.style);
|
|
88
|
+
this.containerManager.getContainer(changed.gameObject.id).addChildAt(text, 0);
|
|
89
|
+
this.texts[changed.gameObject.id] = {
|
|
90
|
+
text,
|
|
91
|
+
component: changed.component,
|
|
92
|
+
};
|
|
93
|
+
this.setSize(changed);
|
|
94
|
+
}
|
|
95
|
+
else if (changed.type === eva_js.OBSERVER_TYPE.REMOVE) {
|
|
96
|
+
this.containerManager.getContainer(changed.gameObject.id).removeChild(this.texts[changed.gameObject.id].text);
|
|
97
|
+
this.texts[changed.gameObject.id].text.destroy({ children: true });
|
|
98
|
+
delete this.texts[changed.gameObject.id];
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
this.change(changed);
|
|
102
|
+
this.setSize(changed);
|
|
103
|
+
}
|
|
156
104
|
});
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
|
|
105
|
+
}
|
|
106
|
+
change(changed) {
|
|
107
|
+
const { text, component } = this.texts[changed.gameObject.id];
|
|
160
108
|
if (changed.prop.prop[0] === 'text') {
|
|
161
109
|
text.text = component.text;
|
|
162
110
|
}
|
|
163
111
|
else if (changed.prop.prop[0] === 'style') {
|
|
164
112
|
Object.assign(text.style, changed.component.style);
|
|
165
113
|
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
|
|
114
|
+
}
|
|
115
|
+
setSize(changed) {
|
|
116
|
+
const { transform } = changed.gameObject;
|
|
169
117
|
if (!transform)
|
|
170
118
|
return;
|
|
171
119
|
transform.size.width = this.texts[changed.gameObject.id].text.width;
|
|
172
120
|
transform.size.height = this.texts[changed.gameObject.id].text.height;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
}(pluginRenderer.Renderer));
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
Text.systemName = 'Text';
|
|
124
|
+
Text = __decorate([
|
|
125
|
+
eva_js.decorators.componentObserver({
|
|
126
|
+
Text: ['text', { prop: ['style'], deep: true }],
|
|
127
|
+
})
|
|
128
|
+
], Text);
|
|
182
129
|
var Text$1 = Text;
|
|
183
130
|
|
|
184
|
-
exports.Text = Text$
|
|
131
|
+
exports.Text = Text$2;
|
|
185
132
|
exports.TextSystem = Text$1;
|
|
@@ -1 +1,16 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("pixi.js"),t=require("@eva/eva.js"),n=require("@eva/inspector-decorator"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("pixi.js"),t=require("@eva/eva.js"),n=require("@eva/inspector-decorator"),s=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 i(e,t,n,s){var r,i=arguments.length,o=i<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,n):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,s);else for(var c=e.length-1;c>=0;c--)(r=e[c])&&(o=(i<3?r(o):i>3?r(t,n,o):r(t,n))||o);return i>3&&o&&Object.defineProperty(t,n,o),o}class o extends t.Component{constructor(){super(...arguments),this.text="",this.style={}}init(t){const n=new e.TextStyle({fontSize:20}),s={};for(const e in n)0===e.indexOf("_")&&(s[e.substring(1)]=n[e]);delete s.styleKey,this.style=s,t&&(this.text=t.text,Object.assign(this.style,t.style))}}o.componentName="Text",i([n.type("string")],o.prototype,"text",void 0);let c=class extends s.Renderer{constructor(){super(...arguments),this.name="Text",this.texts={}}init(){this.renderSystem=this.game.getSystem(s.RendererSystem),this.renderSystem.rendererManager.register(this)}componentChanged(e){return n=this,s=void 0,o=function*(){if("Text"===e.componentName)if(e.type===t.OBSERVER_TYPE.ADD){const t=e.component,n=new r.Text(t.text,t.style);this.containerManager.getContainer(e.gameObject.id).addChildAt(n,0),this.texts[e.gameObject.id]={text:n,component:e.component},this.setSize(e)}else e.type===t.OBSERVER_TYPE.REMOVE?(this.containerManager.getContainer(e.gameObject.id).removeChild(this.texts[e.gameObject.id].text),this.texts[e.gameObject.id].text.destroy({children:!0}),delete this.texts[e.gameObject.id]):(this.change(e),this.setSize(e))},new((i=void 0)||(i=Promise))((function(e,t){function r(e){try{a(o.next(e))}catch(e){t(e)}}function c(e){try{a(o.throw(e))}catch(e){t(e)}}function a(t){t.done?e(t.value):new i((function(e){e(t.value)})).then(r,c)}a((o=o.apply(n,s||[])).next())}));var n,s,i,o}change(e){const{text:t,component:n}=this.texts[e.gameObject.id];"text"===e.prop.prop[0]?t.text=n.text:"style"===e.prop.prop[0]&&Object.assign(t.style,e.component.style)}setSize(e){const{transform:t}=e.gameObject;t&&(t.size.width=this.texts[e.gameObject.id].text.width,t.size.height=this.texts[e.gameObject.id].text.height)}};c.systemName="Text",c=i([t.decorators.componentObserver({Text:["text",{prop:["style"],deep:!0}]})],c);var a=c;exports.Text=o,exports.TextSystem=a;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { TextStyle } from 'pixi.js';
|
|
2
2
|
import { Component, decorators, OBSERVER_TYPE } from '@eva/eva.js';
|
|
3
3
|
import { type } from '@eva/inspector-decorator';
|
|
4
|
-
import {
|
|
5
|
-
import { Text as Text$
|
|
4
|
+
import { Renderer, RendererSystem } from '@eva/plugin-renderer';
|
|
5
|
+
import { Text as Text$3 } from '@eva/renderer-adapter';
|
|
6
6
|
|
|
7
7
|
/*! *****************************************************************************
|
|
8
8
|
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -18,20 +18,6 @@ MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
|
18
18
|
See the Apache Version 2.0 License for specific language governing permissions
|
|
19
19
|
and limitations under the License.
|
|
20
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
21
|
|
|
36
22
|
function __decorate(decorators, target, key, desc) {
|
|
37
23
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -47,50 +33,20 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
47
33
|
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
48
34
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
49
35
|
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function __generator(thisArg, body) {
|
|
53
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
54
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
55
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
56
|
-
function step(op) {
|
|
57
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
58
|
-
while (_) try {
|
|
59
|
-
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;
|
|
60
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
61
|
-
switch (op[0]) {
|
|
62
|
-
case 0: case 1: t = op; break;
|
|
63
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
64
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
65
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
66
|
-
default:
|
|
67
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
68
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
69
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
70
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
71
|
-
if (t[2]) _.ops.pop();
|
|
72
|
-
_.trys.pop(); continue;
|
|
73
|
-
}
|
|
74
|
-
op = body.call(thisArg, _);
|
|
75
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
76
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
77
|
-
}
|
|
78
36
|
}
|
|
79
37
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
_this.style = {};
|
|
86
|
-
return _this;
|
|
38
|
+
class Text$2 extends Component {
|
|
39
|
+
constructor() {
|
|
40
|
+
super(...arguments);
|
|
41
|
+
this.text = '';
|
|
42
|
+
this.style = {};
|
|
87
43
|
}
|
|
88
|
-
|
|
89
|
-
|
|
44
|
+
init(obj) {
|
|
45
|
+
const style = new TextStyle({
|
|
90
46
|
fontSize: 20,
|
|
91
47
|
});
|
|
92
|
-
|
|
93
|
-
for (
|
|
48
|
+
const newStyle = {};
|
|
49
|
+
for (const key in style) {
|
|
94
50
|
if (key.indexOf('_') === 0) {
|
|
95
51
|
newStyle[key.substring(1)] = style[key];
|
|
96
52
|
}
|
|
@@ -101,80 +57,71 @@ var Text$2 = (function (_super) {
|
|
|
101
57
|
this.text = obj.text;
|
|
102
58
|
Object.assign(this.style, obj.style);
|
|
103
59
|
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}(Component));
|
|
111
|
-
var Text$3 = Text$2;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
Text$2.componentName = 'Text';
|
|
63
|
+
__decorate([
|
|
64
|
+
type('string')
|
|
65
|
+
], Text$2.prototype, "text", void 0);
|
|
112
66
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
_this.texts = {};
|
|
119
|
-
return _this;
|
|
67
|
+
let Text = class Text extends Renderer {
|
|
68
|
+
constructor() {
|
|
69
|
+
super(...arguments);
|
|
70
|
+
this.name = 'Text';
|
|
71
|
+
this.texts = {};
|
|
120
72
|
}
|
|
121
|
-
|
|
73
|
+
init() {
|
|
122
74
|
this.renderSystem = this.game.getSystem(RendererSystem);
|
|
123
75
|
this.renderSystem.rendererManager.register(this);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
this.setSize(changed);
|
|
149
|
-
}
|
|
150
|
-
return [2];
|
|
151
|
-
});
|
|
76
|
+
}
|
|
77
|
+
componentChanged(changed) {
|
|
78
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
79
|
+
if (changed.componentName !== 'Text')
|
|
80
|
+
return;
|
|
81
|
+
if (changed.type === OBSERVER_TYPE.ADD) {
|
|
82
|
+
const component = changed.component;
|
|
83
|
+
const text = new Text$3(component.text, component.style);
|
|
84
|
+
this.containerManager.getContainer(changed.gameObject.id).addChildAt(text, 0);
|
|
85
|
+
this.texts[changed.gameObject.id] = {
|
|
86
|
+
text,
|
|
87
|
+
component: changed.component,
|
|
88
|
+
};
|
|
89
|
+
this.setSize(changed);
|
|
90
|
+
}
|
|
91
|
+
else if (changed.type === OBSERVER_TYPE.REMOVE) {
|
|
92
|
+
this.containerManager.getContainer(changed.gameObject.id).removeChild(this.texts[changed.gameObject.id].text);
|
|
93
|
+
this.texts[changed.gameObject.id].text.destroy({ children: true });
|
|
94
|
+
delete this.texts[changed.gameObject.id];
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
this.change(changed);
|
|
98
|
+
this.setSize(changed);
|
|
99
|
+
}
|
|
152
100
|
});
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
|
|
101
|
+
}
|
|
102
|
+
change(changed) {
|
|
103
|
+
const { text, component } = this.texts[changed.gameObject.id];
|
|
156
104
|
if (changed.prop.prop[0] === 'text') {
|
|
157
105
|
text.text = component.text;
|
|
158
106
|
}
|
|
159
107
|
else if (changed.prop.prop[0] === 'style') {
|
|
160
108
|
Object.assign(text.style, changed.component.style);
|
|
161
109
|
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
|
|
110
|
+
}
|
|
111
|
+
setSize(changed) {
|
|
112
|
+
const { transform } = changed.gameObject;
|
|
165
113
|
if (!transform)
|
|
166
114
|
return;
|
|
167
115
|
transform.size.width = this.texts[changed.gameObject.id].text.width;
|
|
168
116
|
transform.size.height = this.texts[changed.gameObject.id].text.height;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
}(Renderer));
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
Text.systemName = 'Text';
|
|
120
|
+
Text = __decorate([
|
|
121
|
+
decorators.componentObserver({
|
|
122
|
+
Text: ['text', { prop: ['style'], deep: true }],
|
|
123
|
+
})
|
|
124
|
+
], Text);
|
|
178
125
|
var Text$1 = Text;
|
|
179
126
|
|
|
180
|
-
export { Text$
|
|
127
|
+
export { Text$2 as Text, Text$1 as TextSystem };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eva/plugin-renderer-text",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.3",
|
|
4
4
|
"description": "@eva/plugin-renderer-text",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "dist/plugin-renderer-text.esm.js",
|
|
@@ -19,9 +19,9 @@
|
|
|
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.
|
|
23
|
-
"@eva/renderer-adapter": "2.0.0-beta.
|
|
24
|
-
"@eva/eva.js": "2.0.0-beta.
|
|
22
|
+
"@eva/plugin-renderer": "2.0.0-beta.3",
|
|
23
|
+
"@eva/renderer-adapter": "2.0.0-beta.3",
|
|
24
|
+
"@eva/eva.js": "2.0.0-beta.3",
|
|
25
25
|
"pixi.js": "^8.6.3"
|
|
26
26
|
}
|
|
27
27
|
}
|