@eva/plugin-renderer-text 1.1.1-fix.2 → 1.1.1-fix.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.
- package/dist/EVA.plugin.renderer.text.js +187 -332
- package/dist/EVA.plugin.renderer.text.js.map +1 -0
- package/dist/EVA.plugin.renderer.text.min.js +0 -1
- package/dist/plugin-renderer-text.cjs.js +5 -2
- package/dist/plugin-renderer-text.cjs.js.map +1 -0
- package/dist/plugin-renderer-text.cjs.prod.js +0 -1
- package/dist/plugin-renderer-text.esm.js +6 -3
- package/dist/plugin-renderer-text.esm.js.map +1 -0
- package/package.json +4 -4
- package/dist/EVA.plugin.renderer.text.min.js.map +0 -1
- package/dist/plugin-renderer-text.cjs.prod.js.map +0 -1
|
@@ -1,334 +1,189 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
d;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
sent: function sent() {
|
|
80
|
-
if (t[0] & 1) throw t[1];
|
|
81
|
-
return t[1];
|
|
82
|
-
},
|
|
83
|
-
trys: [],
|
|
84
|
-
ops: []
|
|
85
|
-
},
|
|
86
|
-
f,
|
|
87
|
-
y,
|
|
88
|
-
t,
|
|
89
|
-
g;
|
|
90
|
-
return g = {
|
|
91
|
-
next: verb(0),
|
|
92
|
-
"throw": verb(1),
|
|
93
|
-
"return": verb(2)
|
|
94
|
-
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
95
|
-
return this;
|
|
96
|
-
}), g;
|
|
97
|
-
|
|
98
|
-
function verb(n) {
|
|
99
|
-
return function (v) {
|
|
100
|
-
return step([n, v]);
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
function step(op) {
|
|
105
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
106
|
-
|
|
107
|
-
while (_) {
|
|
108
|
-
try {
|
|
109
|
-
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;
|
|
110
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
111
|
-
|
|
112
|
-
switch (op[0]) {
|
|
113
|
-
case 0:
|
|
114
|
-
case 1:
|
|
115
|
-
t = op;
|
|
116
|
-
break;
|
|
117
|
-
|
|
118
|
-
case 4:
|
|
119
|
-
_.label++;
|
|
120
|
-
return {
|
|
121
|
-
value: op[1],
|
|
122
|
-
done: false
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
case 5:
|
|
126
|
-
_.label++;
|
|
127
|
-
y = op[1];
|
|
128
|
-
op = [0];
|
|
129
|
-
continue;
|
|
130
|
-
|
|
131
|
-
case 7:
|
|
132
|
-
op = _.ops.pop();
|
|
133
|
-
|
|
134
|
-
_.trys.pop();
|
|
135
|
-
|
|
136
|
-
continue;
|
|
137
|
-
|
|
138
|
-
default:
|
|
139
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
140
|
-
_ = 0;
|
|
141
|
-
continue;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
145
|
-
_.label = op[1];
|
|
146
|
-
break;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
150
|
-
_.label = t[1];
|
|
151
|
-
t = op;
|
|
152
|
-
break;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
if (t && _.label < t[2]) {
|
|
156
|
-
_.label = t[2];
|
|
157
|
-
|
|
158
|
-
_.ops.push(op);
|
|
159
|
-
|
|
160
|
-
break;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
if (t[2]) _.ops.pop();
|
|
164
|
-
|
|
165
|
-
_.trys.pop();
|
|
166
|
-
|
|
167
|
-
continue;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
op = body.call(thisArg, _);
|
|
171
|
-
} catch (e) {
|
|
172
|
-
op = [6, e];
|
|
173
|
-
y = 0;
|
|
174
|
-
} finally {
|
|
175
|
-
f = t = 0;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
if (op[0] & 5) throw op[1];
|
|
180
|
-
return {
|
|
181
|
-
value: op[0] ? op[1] : void 0,
|
|
182
|
-
done: true
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
function getIDEPropsPropertyObj(target, propertyKey) {
|
|
188
|
-
if (!target.constructor.IDEProps) {
|
|
189
|
-
target.constructor.IDEProps = {};
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
if (!target.constructor.IDEProps[propertyKey]) {
|
|
193
|
-
target.constructor.IDEProps[propertyKey] = {};
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
var propertyObj = target.constructor.IDEProps[propertyKey];
|
|
197
|
-
return propertyObj;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
function type(type) {
|
|
201
|
-
return function (target, propertyKey) {
|
|
202
|
-
var prop = getIDEPropsPropertyObj(target, propertyKey);
|
|
203
|
-
prop.key = propertyKey;
|
|
204
|
-
prop.type = type;
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
var Text$2 = function (_super) {
|
|
209
|
-
__extends(Text, _super);
|
|
210
|
-
|
|
211
|
-
function Text() {
|
|
212
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
213
|
-
|
|
214
|
-
_this.text = '';
|
|
215
|
-
_this.style = {};
|
|
216
|
-
return _this;
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('pixi.js'), require('@eva/eva.js'), require('@eva/plugin-renderer'), require('@eva/renderer-adapter')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'pixi.js', '@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.text = {}), global.PIXI, global.EVA, global.EVA.plugin.renderer, global.EVA.rendererAdapter));
|
|
5
|
+
}(this, (function (exports, pixi_js, 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
|
+
}
|
|
217
79
|
}
|
|
218
80
|
|
|
219
|
-
Text
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
Object.defineProperty(exports, '__esModule', {
|
|
329
|
-
value: true
|
|
330
|
-
});
|
|
331
|
-
return exports;
|
|
332
|
-
}({}, PIXI, EVA, EVA.plugin.renderer, EVA.rendererAdapter);
|
|
333
|
-
|
|
334
|
-
window.EVA.plugin.renderer.text = window.EVA.plugin.renderer.text || _EVA_IIFE_text;
|
|
81
|
+
var Text$2 = (function (_super) {
|
|
82
|
+
__extends(Text, _super);
|
|
83
|
+
function Text() {
|
|
84
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
85
|
+
_this.text = '';
|
|
86
|
+
_this.style = {};
|
|
87
|
+
return _this;
|
|
88
|
+
}
|
|
89
|
+
Text.prototype.init = function (obj) {
|
|
90
|
+
var style = new pixi_js.TextStyle({
|
|
91
|
+
fontSize: 20,
|
|
92
|
+
});
|
|
93
|
+
var newStyle = {};
|
|
94
|
+
for (var key in style) {
|
|
95
|
+
if (key.indexOf('_') === 0) {
|
|
96
|
+
newStyle[key.substring(1)] = style[key];
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
this.style = newStyle;
|
|
100
|
+
if (obj) {
|
|
101
|
+
this.text = obj.text;
|
|
102
|
+
Object.assign(this.style, obj.style);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
Text.componentName = 'Text';
|
|
106
|
+
__decorate([
|
|
107
|
+
eva_js.decorators.IDEProp
|
|
108
|
+
], Text.prototype, "text", void 0);
|
|
109
|
+
__decorate([
|
|
110
|
+
eva_js.decorators.IDEProp
|
|
111
|
+
], Text.prototype, "style", void 0);
|
|
112
|
+
return Text;
|
|
113
|
+
}(eva_js.Component));
|
|
114
|
+
var Text$3 = Text$2;
|
|
115
|
+
|
|
116
|
+
var Text = (function (_super) {
|
|
117
|
+
__extends(Text, _super);
|
|
118
|
+
function Text() {
|
|
119
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
120
|
+
_this.name = 'Text';
|
|
121
|
+
_this.texts = {};
|
|
122
|
+
return _this;
|
|
123
|
+
}
|
|
124
|
+
Text.prototype.init = function () {
|
|
125
|
+
this.renderSystem = this.game.getSystem(pluginRenderer.RendererSystem);
|
|
126
|
+
this.renderSystem.rendererManager.register(this);
|
|
127
|
+
};
|
|
128
|
+
Text.prototype.componentChanged = function (changed) {
|
|
129
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
130
|
+
var component, text;
|
|
131
|
+
return __generator(this, function (_a) {
|
|
132
|
+
if (changed.componentName !== 'Text')
|
|
133
|
+
return [2];
|
|
134
|
+
if (changed.type === eva_js.OBSERVER_TYPE.ADD) {
|
|
135
|
+
component = changed.component;
|
|
136
|
+
text = new rendererAdapter.Text(component.text, component.style);
|
|
137
|
+
this.containerManager.getContainer(changed.gameObject.id).addChildAt(text, 0);
|
|
138
|
+
this.texts[changed.gameObject.id] = {
|
|
139
|
+
text: text,
|
|
140
|
+
component: changed.component,
|
|
141
|
+
};
|
|
142
|
+
this.setSize(changed);
|
|
143
|
+
}
|
|
144
|
+
else if (changed.type === eva_js.OBSERVER_TYPE.REMOVE) {
|
|
145
|
+
this.containerManager.getContainer(changed.gameObject.id).removeChild(this.texts[changed.gameObject.id].text);
|
|
146
|
+
this.texts[changed.gameObject.id].text.destroy({ children: true });
|
|
147
|
+
delete this.texts[changed.gameObject.id];
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
this.change(changed);
|
|
151
|
+
this.setSize(changed);
|
|
152
|
+
}
|
|
153
|
+
return [2];
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
};
|
|
157
|
+
Text.prototype.change = function (changed) {
|
|
158
|
+
var _a = this.texts[changed.gameObject.id], text = _a.text, component = _a.component;
|
|
159
|
+
if (changed.prop.prop[0] === 'text') {
|
|
160
|
+
text.text = component.text;
|
|
161
|
+
}
|
|
162
|
+
else if (changed.prop.prop[0] === 'style') {
|
|
163
|
+
Object.assign(text.style, changed.component.style);
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
Text.prototype.setSize = function (changed) {
|
|
167
|
+
var transform = changed.gameObject.transform;
|
|
168
|
+
if (!transform)
|
|
169
|
+
return;
|
|
170
|
+
transform.size.width = this.texts[changed.gameObject.id].text.width;
|
|
171
|
+
transform.size.height = this.texts[changed.gameObject.id].text.height;
|
|
172
|
+
};
|
|
173
|
+
Text.systemName = 'Text';
|
|
174
|
+
Text = __decorate([
|
|
175
|
+
eva_js.decorators.componentObserver({
|
|
176
|
+
Text: ['text', { prop: ['style'], deep: true }],
|
|
177
|
+
})
|
|
178
|
+
], Text);
|
|
179
|
+
return Text;
|
|
180
|
+
}(pluginRenderer.Renderer));
|
|
181
|
+
var Text$1 = Text;
|
|
182
|
+
|
|
183
|
+
exports.Text = Text$3;
|
|
184
|
+
exports.TextSystem = Text$1;
|
|
185
|
+
|
|
186
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
187
|
+
|
|
188
|
+
})));
|
|
189
|
+
//# sourceMappingURL=EVA.plugin.renderer.text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EVA.plugin.renderer.text.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 { TextStyle } from 'pixi.js';\nimport { Component, decorators } from '@eva/eva.js';\n\nexport interface TextParams {\n text: string;\n style?: {\n align?: string;\n breakWords?: boolean;\n dropShadow?: boolean;\n dropShadowAlpha?: number;\n dropShadowAngle?: number;\n dropShadowBlur?: number;\n dropShadowColor?: string | number;\n dropShadowDistance?: number;\n fill?: string | string[] | number | number[] | CanvasGradient | CanvasPattern;\n fillGradientType?: number;\n fillGradientStops?: number[];\n fontFamily?: string | string[];\n fontSize?: number | string;\n fontStyle?: string;\n fontVariant?: string;\n fontWeight?: string;\n letterSpacing?: number;\n lineHeight?: number;\n lineJoin?: string;\n miterLimit?: number;\n padding?: number;\n stroke?: string | number;\n strokeThickness?: number;\n textBaseline?: string;\n trim?: boolean;\n whiteSpace?: string;\n wordWrap?: boolean;\n wordWrapWidth?: number;\n leading?: number;\n };\n}\n\nexport default class Text extends Component<TextParams> {\n static componentName: string = 'Text';\n @decorators.IDEProp text: string = '';\n @decorators.IDEProp style: TextParams['style'] = {};\n init(obj?: TextParams) {\n const style = new TextStyle({\n fontSize: 20,\n });\n const newStyle = {};\n for (const key in style) {\n if (key.indexOf('_') === 0) {\n newStyle[key.substring(1)] = style[key];\n }\n }\n this.style = newStyle;\n if (obj) {\n this.text = obj.text;\n Object.assign(this.style, obj.style);\n }\n }\n}\n","import { decorators, ComponentChanged, OBSERVER_TYPE } from '@eva/eva.js';\n\nimport { RendererManager, ContainerManager, RendererSystem, Renderer } from '@eva/plugin-renderer';\nimport { Text as TextEngine } from '@eva/renderer-adapter';\n\nimport TextComponent from './component';\n@decorators.componentObserver({\n Text: ['text', { prop: ['style'], deep: true }],\n})\nexport default class Text extends Renderer {\n static systemName = 'Text';\n name: string = 'Text';\n texts: {\n [propName: number]: { text: TextEngine; component: TextComponent };\n } = {};\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 async componentChanged(changed: ComponentChanged) {\n if (changed.componentName !== 'Text') return;\n if (changed.type === OBSERVER_TYPE.ADD) {\n const component = changed.component as TextComponent;\n const text = new TextEngine(component.text, component.style);\n this.containerManager.getContainer(changed.gameObject.id).addChildAt(text, 0);\n this.texts[changed.gameObject.id] = {\n text,\n component: changed.component as TextComponent,\n };\n this.setSize(changed);\n } else if (changed.type === OBSERVER_TYPE.REMOVE) {\n this.containerManager.getContainer(changed.gameObject.id).removeChild(this.texts[changed.gameObject.id].text);\n this.texts[changed.gameObject.id].text.destroy({ children: true });\n delete this.texts[changed.gameObject.id];\n } else {\n this.change(changed);\n this.setSize(changed);\n }\n }\n change(changed: ComponentChanged) {\n const { text, component } = this.texts[changed.gameObject.id];\n if (changed.prop.prop[0] === 'text') {\n text.text = component.text;\n } else if (changed.prop.prop[0] === 'style') {\n Object.assign(text.style, (changed.component as TextComponent).style);\n }\n }\n setSize(changed: ComponentChanged) {\n const { transform } = changed.gameObject;\n if (!transform) return;\n transform.size.width = this.texts[changed.gameObject.id].text.width;\n transform.size.height = this.texts[changed.gameObject.id].text.height;\n }\n}\n"],"names":["TextStyle","decorators","Component","Text","RendererSystem","OBSERVER_TYPE","TextEngine","Renderer"],"mappings":";;;;;;IAAA;IACA;AACA;IACA;IACA;AACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;AACA;IACA,IAAI,aAAa,GAAG,SAAS,CAAC,EAAE,CAAC,EAAE;IACnC,IAAI,aAAa,GAAG,MAAM,CAAC,cAAc;IACzC,SAAS,EAAE,SAAS,EAAE,EAAE,EAAE,YAAY,KAAK,IAAI,UAAU,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,EAAE,CAAC;IACpF,QAAQ,UAAU,CAAC,EAAE,CAAC,EAAE,EAAE,KAAK,IAAI,CAAC,IAAI,CAAC,EAAE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AAS,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;SACvE;QA7CM,eAAU,GAAG,MAAM,CAAC;QADR,IAAI;YAHxBJ,iBAAU,CAAC,iBAAiB,CAAC;gBAC5B,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;aAChD,CAAC;WACmB,IAAI,CA+CxB;QAAD,WAAC;KAAA,CA/CiCM,uBAAQ,GA+CzC;iBA/CoB,IAAI;;;;;;;;;;;"}
|
|
@@ -1,2 +1 @@
|
|
|
1
1
|
var e,t;e=this,t=function(e,t,n,r,o){"use strict";var i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};function a(e,t){function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function s(e,t,n,r){var o,i=arguments.length,a=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}function c(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function s(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((r=r.apply(e,t||[])).next())}))}function p(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=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++,r=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],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}var u=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.text="",t.style={},t}return a(r,e),r.prototype.init=function(e){var n=new t.TextStyle({fontSize:20}),r={};for(var o in n)0===o.indexOf("_")&&(r[o.substring(1)]=n[o]);this.style=r,e&&(this.text=e.text,Object.assign(this.style,e.style))},r.componentName="Text",s([n.decorators.IDEProp],r.prototype,"text",void 0),s([n.decorators.IDEProp],r.prototype,"style",void 0),r}(n.Component),l=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="Text",t.texts={},t}return a(t,e),t.prototype.init=function(){this.renderSystem=this.game.getSystem(r.RendererSystem),this.renderSystem.rendererManager.register(this)},t.prototype.componentChanged=function(e){return c(this,void 0,void 0,(function(){var t,r;return p(this,(function(i){return"Text"!==e.componentName||(e.type===n.OBSERVER_TYPE.ADD?(t=e.component,r=new o.Text(t.text,t.style),this.containerManager.getContainer(e.gameObject.id).addChildAt(r,0),this.texts[e.gameObject.id]={text:r,component:e.component},this.setSize(e)):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))),[2]}))}))},t.prototype.change=function(e){var t=this.texts[e.gameObject.id],n=t.text,r=t.component;"text"===e.prop.prop[0]?n.text=r.text:"style"===e.prop.prop[0]&&Object.assign(n.style,e.component.style)},t.prototype.setSize=function(e){var t=e.gameObject.transform;t&&(t.size.width=this.texts[e.gameObject.id].text.width,t.size.height=this.texts[e.gameObject.id].text.height)},t.systemName="Text",t=s([n.decorators.componentObserver({Text:["text",{prop:["style"],deep:!0}]})],t)}(r.Renderer);e.Text=u,e.TextSystem=l,Object.defineProperty(e,"__esModule",{value:!0})},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("pixi.js"),require("@eva/eva.js"),require("@eva/plugin-renderer"),require("@eva/renderer-adapter")):"function"==typeof define&&define.amd?define(["exports","pixi.js","@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.text={}),e.PIXI,e.EVA,e.EVA.plugin.renderer,e.EVA.rendererAdapter);
|
|
2
|
-
//# sourceMappingURL=EVA.plugin.renderer.text.min.js.map
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var pixi_js = require('pixi.js');
|
|
6
6
|
var eva_js = require('@eva/eva.js');
|
|
7
|
-
var inspectorDecorator = require('@eva/inspector-decorator');
|
|
8
7
|
var pluginRenderer = require('@eva/plugin-renderer');
|
|
9
8
|
var rendererAdapter = require('@eva/renderer-adapter');
|
|
10
9
|
|
|
@@ -107,8 +106,11 @@ var Text$2 = (function (_super) {
|
|
|
107
106
|
};
|
|
108
107
|
Text.componentName = 'Text';
|
|
109
108
|
__decorate([
|
|
110
|
-
|
|
109
|
+
eva_js.decorators.IDEProp
|
|
111
110
|
], Text.prototype, "text", void 0);
|
|
111
|
+
__decorate([
|
|
112
|
+
eva_js.decorators.IDEProp
|
|
113
|
+
], Text.prototype, "style", void 0);
|
|
112
114
|
return Text;
|
|
113
115
|
}(eva_js.Component));
|
|
114
116
|
var Text$3 = Text$2;
|
|
@@ -182,3 +184,4 @@ var Text$1 = Text;
|
|
|
182
184
|
|
|
183
185
|
exports.Text = Text$3;
|
|
184
186
|
exports.TextSystem = Text$1;
|
|
187
|
+
//# sourceMappingURL=plugin-renderer-text.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-renderer-text.cjs.js","sources":["../lib/component.ts","../lib/system.ts"],"sourcesContent":["import { TextStyle } from 'pixi.js';\nimport { Component, decorators } from '@eva/eva.js';\n\nexport interface TextParams {\n text: string;\n style?: {\n align?: string;\n breakWords?: boolean;\n dropShadow?: boolean;\n dropShadowAlpha?: number;\n dropShadowAngle?: number;\n dropShadowBlur?: number;\n dropShadowColor?: string | number;\n dropShadowDistance?: number;\n fill?: string | string[] | number | number[] | CanvasGradient | CanvasPattern;\n fillGradientType?: number;\n fillGradientStops?: number[];\n fontFamily?: string | string[];\n fontSize?: number | string;\n fontStyle?: string;\n fontVariant?: string;\n fontWeight?: string;\n letterSpacing?: number;\n lineHeight?: number;\n lineJoin?: string;\n miterLimit?: number;\n padding?: number;\n stroke?: string | number;\n strokeThickness?: number;\n textBaseline?: string;\n trim?: boolean;\n whiteSpace?: string;\n wordWrap?: boolean;\n wordWrapWidth?: number;\n leading?: number;\n };\n}\n\nexport default class Text extends Component<TextParams> {\n static componentName: string = 'Text';\n @decorators.IDEProp text: string = '';\n @decorators.IDEProp style: TextParams['style'] = {};\n init(obj?: TextParams) {\n const style = new TextStyle({\n fontSize: 20,\n });\n const newStyle = {};\n for (const key in style) {\n if (key.indexOf('_') === 0) {\n newStyle[key.substring(1)] = style[key];\n }\n }\n this.style = newStyle;\n if (obj) {\n this.text = obj.text;\n Object.assign(this.style, obj.style);\n }\n }\n}\n","import { decorators, ComponentChanged, OBSERVER_TYPE } from '@eva/eva.js';\n\nimport { RendererManager, ContainerManager, RendererSystem, Renderer } from '@eva/plugin-renderer';\nimport { Text as TextEngine } from '@eva/renderer-adapter';\n\nimport TextComponent from './component';\n@decorators.componentObserver({\n Text: ['text', { prop: ['style'], deep: true }],\n})\nexport default class Text extends Renderer {\n static systemName = 'Text';\n name: string = 'Text';\n texts: {\n [propName: number]: { text: TextEngine; component: TextComponent };\n } = {};\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 async componentChanged(changed: ComponentChanged) {\n if (changed.componentName !== 'Text') return;\n if (changed.type === OBSERVER_TYPE.ADD) {\n const component = changed.component as TextComponent;\n const text = new TextEngine(component.text, component.style);\n this.containerManager.getContainer(changed.gameObject.id).addChildAt(text, 0);\n this.texts[changed.gameObject.id] = {\n text,\n component: changed.component as TextComponent,\n };\n this.setSize(changed);\n } else if (changed.type === OBSERVER_TYPE.REMOVE) {\n this.containerManager.getContainer(changed.gameObject.id).removeChild(this.texts[changed.gameObject.id].text);\n this.texts[changed.gameObject.id].text.destroy({ children: true });\n delete this.texts[changed.gameObject.id];\n } else {\n this.change(changed);\n this.setSize(changed);\n }\n }\n change(changed: ComponentChanged) {\n const { text, component } = this.texts[changed.gameObject.id];\n if (changed.prop.prop[0] === 'text') {\n text.text = component.text;\n } else if (changed.prop.prop[0] === 'style') {\n Object.assign(text.style, (changed.component as TextComponent).style);\n }\n }\n setSize(changed: ComponentChanged) {\n const { transform } = changed.gameObject;\n if (!transform) return;\n transform.size.width = this.texts[changed.gameObject.id].text.width;\n transform.size.height = this.texts[changed.gameOb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AI,CA+CxB;IAAD,WAAC;CAAA,CA/CiCM,uBAAQ,GA+CzC;aA/CoB,IAAI;;;;;"}
|
|
@@ -1,2 +1 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("pixi.js"),e=require("@eva/eva.js"),n=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 n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function i(t,e){function n(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function s(t,e,n,r){var o,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);return i>3&&s&&Object.defineProperty(e,n,s),s}function a(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}var c=function(n){function r(){var t=null!==n&&n.apply(this,arguments)||this;return t.text="",t.style={},t}return i(r,n),r.prototype.init=function(e){var n=new t.TextStyle({fontSize:20}),r={};for(var o in n)0===o.indexOf("_")&&(r[o.substring(1)]=n[o]);this.style=r,e&&(this.text=e.text,Object.assign(this.style,e.style))},r.componentName="Text",s([e.decorators.IDEProp],r.prototype,"text",void 0),s([e.decorators.IDEProp],r.prototype,"style",void 0),r}(e.Component),p=function(t){function o(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="Text",e.texts={},e}return i(o,t),o.prototype.init=function(){this.renderSystem=this.game.getSystem(n.RendererSystem),this.renderSystem.rendererManager.register(this)},o.prototype.componentChanged=function(t){return n=this,o=void 0,s=function(){var n,o;return a(this,(function(i){return"Text"!==t.componentName||(t.type===e.OBSERVER_TYPE.ADD?(n=t.component,o=new r.Text(n.text,n.style),this.containerManager.getContainer(t.gameObject.id).addChildAt(o,0),this.texts[t.gameObject.id]={text:o,component:t.component},this.setSize(t)):t.type===e.OBSERVER_TYPE.REMOVE?(this.containerManager.getContainer(t.gameObject.id).removeChild(this.texts[t.gameObject.id].text),this.texts[t.gameObject.id].text.destroy({children:!0}),delete this.texts[t.gameObject.id]):(this.change(t),this.setSize(t))),[2]}))},new((i=void 0)||(i=Promise))((function(t,e){function r(t){try{c(s.next(t))}catch(t){e(t)}}function a(t){try{c(s.throw(t))}catch(t){e(t)}}function c(e){e.done?t(e.value):new i((function(t){t(e.value)})).then(r,a)}c((s=s.apply(n,o||[])).next())}));var n,o,i,s},o.prototype.change=function(t){var e=this.texts[t.gameObject.id],n=e.text,r=e.component;"text"===t.prop.prop[0]?n.text=r.text:"style"===t.prop.prop[0]&&Object.assign(n.style,t.component.style)},o.prototype.setSize=function(t){var e=t.gameObject.transform;e&&(e.size.width=this.texts[t.gameObject.id].text.width,e.size.height=this.texts[t.gameObject.id].text.height)},o.systemName="Text",o=s([e.decorators.componentObserver({Text:["text",{prop:["style"],deep:!0}]})],o)}(n.Renderer);exports.Text=c,exports.TextSystem=p;
|
|
2
|
-
//# sourceMappingURL=plugin-renderer-text.cjs.prod.js.map
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { TextStyle } from 'pixi.js';
|
|
2
|
-
import {
|
|
3
|
-
import { type } from '@eva/inspector-decorator';
|
|
2
|
+
import { decorators, Component, OBSERVER_TYPE } from '@eva/eva.js';
|
|
4
3
|
import { RendererSystem, Renderer } from '@eva/plugin-renderer';
|
|
5
4
|
import { Text as Text$4 } from '@eva/renderer-adapter';
|
|
6
5
|
|
|
@@ -103,8 +102,11 @@ var Text$2 = (function (_super) {
|
|
|
103
102
|
};
|
|
104
103
|
Text.componentName = 'Text';
|
|
105
104
|
__decorate([
|
|
106
|
-
|
|
105
|
+
decorators.IDEProp
|
|
107
106
|
], Text.prototype, "text", void 0);
|
|
107
|
+
__decorate([
|
|
108
|
+
decorators.IDEProp
|
|
109
|
+
], Text.prototype, "style", void 0);
|
|
108
110
|
return Text;
|
|
109
111
|
}(Component));
|
|
110
112
|
var Text$3 = Text$2;
|
|
@@ -177,3 +179,4 @@ var Text = (function (_super) {
|
|
|
177
179
|
var Text$1 = Text;
|
|
178
180
|
|
|
179
181
|
export { Text$3 as Text, Text$1 as TextSystem };
|
|
182
|
+
//# sourceMappingURL=plugin-renderer-text.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-renderer-text.esm.js","sources":["../lib/component.ts","../lib/system.ts"],"sourcesContent":["import { TextStyle } from 'pixi.js';\nimport { Component, decorators } from '@eva/eva.js';\n\nexport interface TextParams {\n text: string;\n style?: {\n align?: string;\n breakWords?: boolean;\n dropShadow?: boolean;\n dropShadowAlpha?: number;\n dropShadowAngle?: number;\n dropShadowBlur?: number;\n dropShadowColor?: string | number;\n dropShadowDistance?: number;\n fill?: string | string[] | number | number[] | CanvasGradient | CanvasPattern;\n fillGradientType?: number;\n fillGradientStops?: number[];\n fontFamily?: string | string[];\n fontSize?: number | string;\n fontStyle?: string;\n fontVariant?: string;\n fontWeight?: string;\n letterSpacing?: number;\n lineHeight?: number;\n lineJoin?: string;\n miterLimit?: number;\n padding?: number;\n stroke?: string | number;\n strokeThickness?: number;\n textBaseline?: string;\n trim?: boolean;\n whiteSpace?: string;\n wordWrap?: boolean;\n wordWrapWidth?: number;\n leading?: number;\n };\n}\n\nexport default class Text extends Component<TextParams> {\n static componentName: string = 'Text';\n @decorators.IDEProp text: string = '';\n @decorators.IDEProp style: TextParams['style'] = {};\n init(obj?: TextParams) {\n const style = new TextStyle({\n fontSize: 20,\n });\n const newStyle = {};\n for (const key in style) {\n if (key.indexOf('_') === 0) {\n newStyle[key.substring(1)] = style[key];\n }\n }\n this.style = newStyle;\n if (obj) {\n this.text = obj.text;\n Object.assign(this.style, obj.style);\n }\n }\n}\n","import { decorators, ComponentChanged, OBSERVER_TYPE } from '@eva/eva.js';\n\nimport { RendererManager, ContainerManager, RendererSystem, Renderer } from '@eva/plugin-renderer';\nimport { Text as TextEngine } from '@eva/renderer-adapter';\n\nimport TextComponent from './component';\n@decorators.componentObserver({\n Text: ['text', { prop: ['style'], deep: true }],\n})\nexport default class Text extends Renderer {\n static systemName = 'Text';\n name: string = 'Text';\n texts: {\n [propName: number]: { text: TextEngine; component: TextComponent };\n } = {};\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 async componentChanged(changed: ComponentChanged) {\n if (changed.componentName !== 'Text') return;\n if (changed.type === OBSERVER_TYPE.ADD) {\n const component = changed.component as TextComponent;\n const text = new TextEngine(component.text, component.style);\n this.containerManager.getContainer(changed.gameObject.id).addChildAt(text, 0);\n this.texts[changed.gameObject.id] = {\n text,\n component: changed.component as TextComponent,\n };\n this.setSize(changed);\n } else if (changed.type === OBSERVER_TYPE.REMOVE) {\n this.containerManager.getContainer(changed.gameObject.id).removeChild(this.texts[changed.gameObject.id].text);\n this.texts[changed.gameObject.id].text.destroy({ children: true });\n delete this.texts[changed.gameObject.id];\n } else {\n this.change(changed);\n this.setSize(changed);\n }\n }\n change(changed: ComponentChanged) {\n const { text, component } = this.texts[changed.gameObject.id];\n if (changed.prop.prop[0] === 'text') {\n text.text = component.text;\n } else if (changed.prop.prop[0] === 'style') {\n Object.assign(text.style, (changed.component as TextComponent).style);\n }\n }\n setSize(changed: ComponentChanged) {\n const { transform } = changed.gameObject;\n if (!transform) return;\n transform.size.width = this.texts[changed.gameObject.id].text.width;\n transform.size.height = this.texts[changed.gameObject.id].text.height;\n }\n}\n"],"names":["Text","TextEngine"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA;IAAkC,wBAAqB;IAAvD;QAAA,qEAoBC;QAlBqB,UAAI,GAAW,EAAE,CAAC;QAClB,WAAK,GAAwB,EAAE,CAAC;;KAiBrD;IAhBC,mBAAI,GAAJ,UAAK,GAAgB;QACnB,IAAM,KAAK,GAAG,IAAI,SAAS,CAAC;YAC1B,QAAQ,EAAE,EAAE;SACb,CAAC,CAAC;QACH,IAAM,QAAQ,GAAG,EAAE,CAAC;QACpB,KAAK,IAAM,GAAG,IAAI,KAAK,EAAE;YACvB,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;gBAC1B,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;aACzC;SACF;QACD,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC;QACtB,IAAI,GAAG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,SAAS,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC;QACpE,SAAS,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;KACvE;IA7CM,eAAU,GAAG,MAAM,CAAC;IADR,IAAI;QAHxB,UAAU,CAAC,iBAAiB,CAAC;YAC5B,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;SAChD,CAAC;OACmB,IAAI,CA+CxB;IAAD,WAAC;CAAA,CA/CiC,QAAQ,GA+CzC;aA/CoB,IAAI;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eva/plugin-renderer-text",
|
|
3
|
-
"version": "1.1.1-fix.
|
|
3
|
+
"version": "1.1.1-fix.3",
|
|
4
4
|
"description": "@eva/plugin-renderer-text",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "dist/plugin-renderer-text.esm.js",
|
|
@@ -18,9 +18,9 @@
|
|
|
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.3",
|
|
22
|
+
"@eva/renderer-adapter": "1.1.1-fix.3",
|
|
23
|
+
"@eva/eva.js": "1.1.1-fix.3",
|
|
24
24
|
"pixi.js": "^4.8.7"
|
|
25
25
|
}
|
|
26
26
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EVA.plugin.renderer.text.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 { TextStyle } from 'pixi.js';\nimport { Component, decorators } from '@eva/eva.js';\n\nexport interface TextParams {\n text: string;\n style?: {\n align?: string;\n breakWords?: boolean;\n dropShadow?: boolean;\n dropShadowAlpha?: number;\n dropShadowAngle?: number;\n dropShadowBlur?: number;\n dropShadowColor?: string | number;\n dropShadowDistance?: number;\n fill?: string | string[] | number | number[] | CanvasGradient | CanvasPattern;\n fillGradientType?: number;\n fillGradientStops?: number[];\n fontFamily?: string | string[];\n fontSize?: number | string;\n fontStyle?: string;\n fontVariant?: string;\n fontWeight?: string;\n letterSpacing?: number;\n lineHeight?: number;\n lineJoin?: string;\n miterLimit?: number;\n padding?: number;\n stroke?: string | number;\n strokeThickness?: number;\n textBaseline?: string;\n trim?: boolean;\n whiteSpace?: string;\n wordWrap?: boolean;\n wordWrapWidth?: number;\n leading?: number;\n };\n}\n\nexport default class Text extends Component<TextParams> {\n static componentName: string = 'Text';\n @decorators.IDEProp text: string = '';\n @decorators.IDEProp style: TextParams['style'] = {};\n init(obj?: TextParams) {\n const style = new TextStyle({\n fontSize: 20,\n });\n const newStyle = {};\n for (const key in style) {\n if (key.indexOf('_') === 0) {\n newStyle[key.substring(1)] = style[key];\n }\n }\n this.style = newStyle;\n if (obj) {\n this.text = obj.text;\n Object.assign(this.style, obj.style);\n }\n }\n}\n","import { decorators, ComponentChanged, OBSERVER_TYPE } from '@eva/eva.js';\n\nimport { RendererManager, ContainerManager, RendererSystem, Renderer } from '@eva/plugin-renderer';\nimport { Text as TextEngine } from '@eva/renderer-adapter';\n\nimport TextComponent from './component';\n@decorators.componentObserver({\n Text: ['text', { prop: ['style'], deep: true }],\n})\nexport default class Text extends Renderer {\n static systemName = 'Text';\n name: string = 'Text';\n texts: {\n [propName: number]: { text: TextEngine; component: TextComponent };\n } = {};\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 async componentChanged(changed: ComponentChanged) {\n if (changed.componentName !== 'Text') return;\n if (changed.type === OBSERVER_TYPE.ADD) {\n const component = changed.component as TextComponent;\n const text = new TextEngine(component.text, component.style);\n this.containerManager.getContainer(changed.gameObject.id).addChildAt(text, 0);\n this.texts[changed.gameObject.id] = {\n text,\n component: changed.component as TextComponent,\n };\n this.setSize(changed);\n } else if (changed.type === OBSERVER_TYPE.REMOVE) {\n this.containerManager.getContainer(changed.gameObject.id).removeChild(this.texts[changed.gameObject.id].text);\n this.texts[changed.gameObject.id].text.destroy({ children: true });\n delete this.texts[changed.gameObject.id];\n } else {\n this.change(changed);\n this.setSize(changed);\n }\n }\n change(changed: ComponentChanged) {\n const { text, component } = this.texts[changed.gameObject.id];\n if (changed.prop.prop[0] === 'text') {\n text.text = component.text;\n } else if (changed.prop.prop[0] === 'style') {\n Object.assign(text.style, (changed.component as TextComponent).style);\n }\n }\n setSize(changed: ComponentChanged) {\n const { transform } = changed.gameObject;\n if (!transform) return;\n transform.size.width = this.texts[changed.gameObject.id].text.width;\n transform.size.height = this.texts[changed.gameObject.id].text.height;\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","Text","obj","style","TextStyle","fontSize","newStyle","indexOf","substring","text","assign","IDEProp","Component","renderSystem","game","getSystem","RendererSystem","rendererManager","register","changed","componentName","type","OBSERVER_TYPE","ADD","component","TextEngine","containerManager","getContainer","gameObject","id","addChildAt","texts","setSize","REMOVE","removeChild","destroy","children","change","_a","prop","transform","size","width","height","componentObserver","deep","Renderer"],"mappings":"kDAgBA,IAAIA,EAAgB,SAASC,EAAGC,GAI5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AAStG,KAAK0F,MAAMZ,EAAQS,WAAWC,IAAIpB,KAAKkC,SA5C1D1C,aAAa,OADDA,KAHpBvD,aAAWkG,kBAAkB,CAC5B3C,KAAM,CAAC,OAAQ,CAAEsC,KAAM,CAAC,SAAUM,MAAM,OAErB5C,IAAa6C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-renderer-text.cjs.prod.js","sources":["../lib/component.ts","../lib/system.ts"],"sourcesContent":["import { TextStyle } from 'pixi.js';\nimport { Component, decorators } from '@eva/eva.js';\n\nexport interface TextParams {\n text: string;\n style?: {\n align?: string;\n breakWords?: boolean;\n dropShadow?: boolean;\n dropShadowAlpha?: number;\n dropShadowAngle?: number;\n dropShadowBlur?: number;\n dropShadowColor?: string | number;\n dropShadowDistance?: number;\n fill?: string | string[] | number | number[] | CanvasGradient | CanvasPattern;\n fillGradientType?: number;\n fillGradientStops?: number[];\n fontFamily?: string | string[];\n fontSize?: number | string;\n fontStyle?: string;\n fontVariant?: string;\n fontWeight?: string;\n letterSpacing?: number;\n lineHeight?: number;\n lineJoin?: string;\n miterLimit?: number;\n padding?: number;\n stroke?: string | number;\n strokeThickness?: number;\n textBaseline?: string;\n trim?: boolean;\n whiteSpace?: string;\n wordWrap?: boolean;\n wordWrapWidth?: number;\n leading?: number;\n };\n}\n\nexport default class Text extends Component<TextParams> {\n static componentName: string = 'Text';\n @decorators.IDEProp text: string = '';\n @decorators.IDEProp style: TextParams['style'] = {};\n init(obj?: TextParams) {\n const style = new TextStyle({\n fontSize: 20,\n });\n const newStyle = {};\n for (const key in style) {\n if (key.indexOf('_') === 0) {\n newStyle[key.substring(1)] = style[key];\n }\n }\n this.style = newStyle;\n if (obj) {\n this.text = obj.text;\n Object.assign(this.style, obj.style);\n }\n }\n}\n","import { decorators, ComponentChanged, OBSERVER_TYPE } from '@eva/eva.js';\n\nimport { RendererManager, ContainerManager, RendererSystem, Renderer } from '@eva/plugin-renderer';\nimport { Text as TextEngine } from '@eva/renderer-adapter';\n\nimport TextComponent from './component';\n@decorators.componentObserver({\n Text: ['text', { prop: ['style'], deep: true }],\n})\nexport default class Text extends Renderer {\n static systemName = 'Text';\n name: string = 'Text';\n texts: {\n [propName: number]: { text: TextEngine; component: TextComponent };\n } = {};\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 async componentChanged(changed: ComponentChanged) {\n if (changed.componentName !== 'Text') return;\n if (changed.type === OBSERVER_TYPE.ADD) {\n const component = changed.component as TextComponent;\n const text = new TextEngine(component.text, component.style);\n this.containerManager.getContainer(changed.gameObject.id).addChildAt(text, 0);\n this.texts[changed.gameObject.id] = {\n text,\n component: changed.component as TextComponent,\n };\n this.setSize(changed);\n } else if (changed.type === OBSERVER_TYPE.REMOVE) {\n this.containerManager.getContainer(changed.gameObject.id).removeChild(this.texts[changed.gameObject.id].text);\n this.texts[changed.gameObject.id].text.destroy({ children: true });\n delete this.texts[changed.gameObject.id];\n } else {\n this.change(changed);\n this.setSize(changed);\n }\n }\n change(changed: ComponentChanged) {\n const { text, component } = this.texts[changed.gameObject.id];\n if (changed.prop.prop[0] === 'text') {\n text.text = component.text;\n } else if (changed.prop.prop[0] === 'style') {\n Object.assign(text.style, (changed.component as TextComponent).style);\n }\n }\n setSize(changed: ComponentChanged) {\n const { transform } = changed.gameObject;\n if (!transform) return;\n transform.size.width = this.texts[changed.gameObject.id].text.width;\n transform.size.height = this.texts[changed.gameObject.id].text.height;\n }\n}\n"],"names":["_this","__extends","Text","obj","style","TextStyle","fontSize","newStyle","key","indexOf","substring","this","text","Object","assign","__decorate","decorators","IDEProp","Component","renderSystem","game","getSystem","RendererSystem","rendererManager","register","changed","componentName","type","OBSERVER_TYPE","ADD","component","TextEngine","containerManager","getContainer","gameObject","id","addChildAt","texts","setSize","REMOVE","removeChild","destroy","children","change","_a","prop","transform","size","width","height","compon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