@eva/plugin-renderer-text 2.0.2 → 2.1.0-beta.10
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 +137 -38
- package/dist/EVA.plugin.renderer.text.min.js +1 -1
- package/dist/plugin-renderer-text.cjs.js +387 -33
- package/dist/plugin-renderer-text.cjs.prod.js +1 -1
- package/dist/plugin-renderer-text.d.ts +20 -13
- package/dist/plugin-renderer-text.esm.js +388 -34
- package/package.json +5 -5
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var eva_js = require('@eva/eva.js');
|
|
6
|
-
var inspectorDecorator = require('@eva/inspector-decorator');
|
|
7
6
|
var pixi_js = require('pixi.js');
|
|
8
7
|
var pluginRenderer = require('@eva/plugin-renderer');
|
|
9
8
|
var rendererAdapter = require('@eva/renderer-adapter');
|
|
@@ -30,6 +29,10 @@ function __decorate(decorators, target, key, desc) {
|
|
|
30
29
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
31
30
|
}
|
|
32
31
|
|
|
32
|
+
function __metadata(metadataKey, metadataValue) {
|
|
33
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
34
|
+
}
|
|
35
|
+
|
|
33
36
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
34
37
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
35
38
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -45,6 +48,48 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
45
48
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
46
49
|
};
|
|
47
50
|
|
|
51
|
+
class BitmapTextStyleMetadata {
|
|
52
|
+
}
|
|
53
|
+
__decorate([
|
|
54
|
+
eva_js.type('string'),
|
|
55
|
+
__metadata("design:type", Object)
|
|
56
|
+
], BitmapTextStyleMetadata.prototype, "fontFamily", void 0);
|
|
57
|
+
__decorate([
|
|
58
|
+
eva_js.type('number'),
|
|
59
|
+
__metadata("design:type", Object)
|
|
60
|
+
], BitmapTextStyleMetadata.prototype, "fontSize", void 0);
|
|
61
|
+
__decorate([
|
|
62
|
+
eva_js.Field({ type: 'color' }),
|
|
63
|
+
__metadata("design:type", Object)
|
|
64
|
+
], BitmapTextStyleMetadata.prototype, "fill", void 0);
|
|
65
|
+
__decorate([
|
|
66
|
+
eva_js.type('string'),
|
|
67
|
+
__metadata("design:type", String)
|
|
68
|
+
], BitmapTextStyleMetadata.prototype, "align", void 0);
|
|
69
|
+
__decorate([
|
|
70
|
+
eva_js.type('number'),
|
|
71
|
+
__metadata("design:type", Number)
|
|
72
|
+
], BitmapTextStyleMetadata.prototype, "letterSpacing", void 0);
|
|
73
|
+
__decorate([
|
|
74
|
+
eva_js.type('number'),
|
|
75
|
+
__metadata("design:type", Number)
|
|
76
|
+
], BitmapTextStyleMetadata.prototype, "padding", void 0);
|
|
77
|
+
__decorate([
|
|
78
|
+
eva_js.Field({ type: 'color' }),
|
|
79
|
+
__metadata("design:type", Object)
|
|
80
|
+
], BitmapTextStyleMetadata.prototype, "stroke", void 0);
|
|
81
|
+
__decorate([
|
|
82
|
+
eva_js.type('number'),
|
|
83
|
+
__metadata("design:type", Number)
|
|
84
|
+
], BitmapTextStyleMetadata.prototype, "strokeThickness", void 0);
|
|
85
|
+
__decorate([
|
|
86
|
+
eva_js.type('string'),
|
|
87
|
+
__metadata("design:type", String)
|
|
88
|
+
], BitmapTextStyleMetadata.prototype, "fontWeight", void 0);
|
|
89
|
+
__decorate([
|
|
90
|
+
eva_js.type('string'),
|
|
91
|
+
__metadata("design:type", String)
|
|
92
|
+
], BitmapTextStyleMetadata.prototype, "fontStyle", void 0);
|
|
48
93
|
/**
|
|
49
94
|
* 位图文本组件
|
|
50
95
|
*
|
|
@@ -83,9 +128,184 @@ class BitmapText extends eva_js.Component {
|
|
|
83
128
|
}
|
|
84
129
|
BitmapText.componentName = 'BitmapText';
|
|
85
130
|
__decorate([
|
|
86
|
-
|
|
87
|
-
|
|
131
|
+
eva_js.type('string'),
|
|
132
|
+
__metadata("design:type", String)
|
|
133
|
+
], BitmapText.prototype, "text", void 0);
|
|
134
|
+
__decorate([
|
|
135
|
+
eva_js.Field(() => BitmapTextStyleMetadata),
|
|
136
|
+
__metadata("design:type", Object)
|
|
137
|
+
], BitmapText.prototype, "style", void 0);
|
|
88
138
|
|
|
139
|
+
class TextStyleStrokeMetadata {
|
|
140
|
+
}
|
|
141
|
+
__decorate([
|
|
142
|
+
eva_js.type('number'),
|
|
143
|
+
__metadata("design:type", Number)
|
|
144
|
+
], TextStyleStrokeMetadata.prototype, "alpha", void 0);
|
|
145
|
+
__decorate([
|
|
146
|
+
eva_js.Field({ type: 'color' }),
|
|
147
|
+
__metadata("design:type", Object)
|
|
148
|
+
], TextStyleStrokeMetadata.prototype, "color", void 0);
|
|
149
|
+
__decorate([
|
|
150
|
+
eva_js.type('string'),
|
|
151
|
+
__metadata("design:type", String)
|
|
152
|
+
], TextStyleStrokeMetadata.prototype, "join", void 0);
|
|
153
|
+
__decorate([
|
|
154
|
+
eva_js.type('number'),
|
|
155
|
+
__metadata("design:type", Number)
|
|
156
|
+
], TextStyleStrokeMetadata.prototype, "miterLimit", void 0);
|
|
157
|
+
__decorate([
|
|
158
|
+
eva_js.type('number'),
|
|
159
|
+
__metadata("design:type", Number)
|
|
160
|
+
], TextStyleStrokeMetadata.prototype, "width", void 0);
|
|
161
|
+
class TextStyleDropShadowMetadata {
|
|
162
|
+
}
|
|
163
|
+
__decorate([
|
|
164
|
+
eva_js.type('number'),
|
|
165
|
+
__metadata("design:type", Number)
|
|
166
|
+
], TextStyleDropShadowMetadata.prototype, "alpha", void 0);
|
|
167
|
+
__decorate([
|
|
168
|
+
eva_js.type('number'),
|
|
169
|
+
__metadata("design:type", Number)
|
|
170
|
+
], TextStyleDropShadowMetadata.prototype, "angle", void 0);
|
|
171
|
+
__decorate([
|
|
172
|
+
eva_js.type('number'),
|
|
173
|
+
__metadata("design:type", Number)
|
|
174
|
+
], TextStyleDropShadowMetadata.prototype, "blur", void 0);
|
|
175
|
+
__decorate([
|
|
176
|
+
eva_js.Field({ type: 'color' }),
|
|
177
|
+
__metadata("design:type", Object)
|
|
178
|
+
], TextStyleDropShadowMetadata.prototype, "color", void 0);
|
|
179
|
+
__decorate([
|
|
180
|
+
eva_js.type('number'),
|
|
181
|
+
__metadata("design:type", Number)
|
|
182
|
+
], TextStyleDropShadowMetadata.prototype, "distance", void 0);
|
|
183
|
+
__decorate([
|
|
184
|
+
eva_js.type('boolean'),
|
|
185
|
+
__metadata("design:type", Boolean)
|
|
186
|
+
], TextStyleDropShadowMetadata.prototype, "enabled", void 0);
|
|
187
|
+
class TextStyleMetadata {
|
|
188
|
+
}
|
|
189
|
+
__decorate([
|
|
190
|
+
eva_js.type('string'),
|
|
191
|
+
__metadata("design:type", String)
|
|
192
|
+
], TextStyleMetadata.prototype, "align", void 0);
|
|
193
|
+
__decorate([
|
|
194
|
+
eva_js.type('boolean'),
|
|
195
|
+
__metadata("design:type", Boolean)
|
|
196
|
+
], TextStyleMetadata.prototype, "breakWords", void 0);
|
|
197
|
+
__decorate([
|
|
198
|
+
eva_js.Field(() => TextStyleDropShadowMetadata),
|
|
199
|
+
__metadata("design:type", Object)
|
|
200
|
+
], TextStyleMetadata.prototype, "dropShadow", void 0);
|
|
201
|
+
__decorate([
|
|
202
|
+
eva_js.type('number'),
|
|
203
|
+
__metadata("design:type", Number)
|
|
204
|
+
], TextStyleMetadata.prototype, "dropShadowAlpha", void 0);
|
|
205
|
+
__decorate([
|
|
206
|
+
eva_js.type('number'),
|
|
207
|
+
__metadata("design:type", Number)
|
|
208
|
+
], TextStyleMetadata.prototype, "dropShadowAngle", void 0);
|
|
209
|
+
__decorate([
|
|
210
|
+
eva_js.type('number'),
|
|
211
|
+
__metadata("design:type", Number)
|
|
212
|
+
], TextStyleMetadata.prototype, "dropShadowBlur", void 0);
|
|
213
|
+
__decorate([
|
|
214
|
+
eva_js.Field({ type: 'color' }),
|
|
215
|
+
__metadata("design:type", Object)
|
|
216
|
+
], TextStyleMetadata.prototype, "dropShadowColor", void 0);
|
|
217
|
+
__decorate([
|
|
218
|
+
eva_js.type('number'),
|
|
219
|
+
__metadata("design:type", Number)
|
|
220
|
+
], TextStyleMetadata.prototype, "dropShadowDistance", void 0);
|
|
221
|
+
__decorate([
|
|
222
|
+
eva_js.Field({ type: 'color' }),
|
|
223
|
+
__metadata("design:type", Object)
|
|
224
|
+
], TextStyleMetadata.prototype, "fill", void 0);
|
|
225
|
+
__decorate([
|
|
226
|
+
eva_js.type('number'),
|
|
227
|
+
__metadata("design:type", Number)
|
|
228
|
+
], TextStyleMetadata.prototype, "fillGradientType", void 0);
|
|
229
|
+
__decorate([
|
|
230
|
+
eva_js.type('number'),
|
|
231
|
+
__metadata("design:type", Array)
|
|
232
|
+
], TextStyleMetadata.prototype, "fillGradientStops", void 0);
|
|
233
|
+
__decorate([
|
|
234
|
+
eva_js.type('string'),
|
|
235
|
+
__metadata("design:type", Object)
|
|
236
|
+
], TextStyleMetadata.prototype, "fontFamily", void 0);
|
|
237
|
+
__decorate([
|
|
238
|
+
eva_js.type('number'),
|
|
239
|
+
__metadata("design:type", Object)
|
|
240
|
+
], TextStyleMetadata.prototype, "fontSize", void 0);
|
|
241
|
+
__decorate([
|
|
242
|
+
eva_js.type('string'),
|
|
243
|
+
__metadata("design:type", String)
|
|
244
|
+
], TextStyleMetadata.prototype, "fontStyle", void 0);
|
|
245
|
+
__decorate([
|
|
246
|
+
eva_js.type('string'),
|
|
247
|
+
__metadata("design:type", String)
|
|
248
|
+
], TextStyleMetadata.prototype, "fontVariant", void 0);
|
|
249
|
+
__decorate([
|
|
250
|
+
eva_js.type('string'),
|
|
251
|
+
__metadata("design:type", String)
|
|
252
|
+
], TextStyleMetadata.prototype, "fontWeight", void 0);
|
|
253
|
+
__decorate([
|
|
254
|
+
eva_js.type('number'),
|
|
255
|
+
__metadata("design:type", Number)
|
|
256
|
+
], TextStyleMetadata.prototype, "leading", void 0);
|
|
257
|
+
__decorate([
|
|
258
|
+
eva_js.type('number'),
|
|
259
|
+
__metadata("design:type", Number)
|
|
260
|
+
], TextStyleMetadata.prototype, "letterSpacing", void 0);
|
|
261
|
+
__decorate([
|
|
262
|
+
eva_js.type('number'),
|
|
263
|
+
__metadata("design:type", Number)
|
|
264
|
+
], TextStyleMetadata.prototype, "lineHeight", void 0);
|
|
265
|
+
__decorate([
|
|
266
|
+
eva_js.type('string'),
|
|
267
|
+
__metadata("design:type", String)
|
|
268
|
+
], TextStyleMetadata.prototype, "lineJoin", void 0);
|
|
269
|
+
__decorate([
|
|
270
|
+
eva_js.type('number'),
|
|
271
|
+
__metadata("design:type", Number)
|
|
272
|
+
], TextStyleMetadata.prototype, "miterLimit", void 0);
|
|
273
|
+
__decorate([
|
|
274
|
+
eva_js.type('number'),
|
|
275
|
+
__metadata("design:type", Number)
|
|
276
|
+
], TextStyleMetadata.prototype, "padding", void 0);
|
|
277
|
+
__decorate([
|
|
278
|
+
eva_js.Field(() => TextStyleStrokeMetadata),
|
|
279
|
+
__metadata("design:type", Object)
|
|
280
|
+
], TextStyleMetadata.prototype, "stroke", void 0);
|
|
281
|
+
__decorate([
|
|
282
|
+
eva_js.type('number'),
|
|
283
|
+
__metadata("design:type", Number)
|
|
284
|
+
], TextStyleMetadata.prototype, "strokeThickness", void 0);
|
|
285
|
+
__decorate([
|
|
286
|
+
eva_js.type('string'),
|
|
287
|
+
__metadata("design:type", String)
|
|
288
|
+
], TextStyleMetadata.prototype, "textBaseline", void 0);
|
|
289
|
+
__decorate([
|
|
290
|
+
eva_js.type('string'),
|
|
291
|
+
__metadata("design:type", String)
|
|
292
|
+
], TextStyleMetadata.prototype, "verticalAlign", void 0);
|
|
293
|
+
__decorate([
|
|
294
|
+
eva_js.type('boolean'),
|
|
295
|
+
__metadata("design:type", Boolean)
|
|
296
|
+
], TextStyleMetadata.prototype, "trim", void 0);
|
|
297
|
+
__decorate([
|
|
298
|
+
eva_js.type('string'),
|
|
299
|
+
__metadata("design:type", String)
|
|
300
|
+
], TextStyleMetadata.prototype, "whiteSpace", void 0);
|
|
301
|
+
__decorate([
|
|
302
|
+
eva_js.type('boolean'),
|
|
303
|
+
__metadata("design:type", Boolean)
|
|
304
|
+
], TextStyleMetadata.prototype, "wordWrap", void 0);
|
|
305
|
+
__decorate([
|
|
306
|
+
eva_js.type('number'),
|
|
307
|
+
__metadata("design:type", Number)
|
|
308
|
+
], TextStyleMetadata.prototype, "wordWrapWidth", void 0);
|
|
89
309
|
/**
|
|
90
310
|
* 文本组件(基于 PixiJS Text)
|
|
91
311
|
*
|
|
@@ -129,19 +349,17 @@ __decorate([
|
|
|
129
349
|
* ```
|
|
130
350
|
*/
|
|
131
351
|
class Text$2 extends eva_js.Component {
|
|
132
|
-
constructor() {
|
|
133
|
-
super(
|
|
352
|
+
constructor(params) {
|
|
353
|
+
super(params);
|
|
134
354
|
/** 文本内容 */
|
|
135
355
|
this.text = '';
|
|
136
356
|
/** 文本样式配置 */
|
|
137
|
-
// @decorators.IDEProp 复杂编辑后续添加
|
|
138
357
|
this.style = {};
|
|
358
|
+
this.init(params);
|
|
139
359
|
}
|
|
140
360
|
/**
|
|
141
361
|
* 初始化组件
|
|
142
362
|
* @param obj - 初始化参数
|
|
143
|
-
* @param obj.text - 文本内容
|
|
144
|
-
* @param obj.style - 文本样式
|
|
145
363
|
*/
|
|
146
364
|
init(obj) {
|
|
147
365
|
const style = new pixi_js.TextStyle({
|
|
@@ -164,9 +382,130 @@ class Text$2 extends eva_js.Component {
|
|
|
164
382
|
/** 组件名称 */
|
|
165
383
|
Text$2.componentName = 'Text';
|
|
166
384
|
__decorate([
|
|
167
|
-
|
|
168
|
-
|
|
385
|
+
eva_js.type('string'),
|
|
386
|
+
__metadata("design:type", String)
|
|
387
|
+
], Text$2.prototype, "text", void 0);
|
|
388
|
+
__decorate([
|
|
389
|
+
eva_js.Field(() => TextStyleMetadata),
|
|
390
|
+
__metadata("design:type", Object)
|
|
391
|
+
], Text$2.prototype, "style", void 0);
|
|
169
392
|
|
|
393
|
+
class HTMLTextTextureStyleMetadata {
|
|
394
|
+
}
|
|
395
|
+
__decorate([
|
|
396
|
+
eva_js.type('string'),
|
|
397
|
+
__metadata("design:type", String)
|
|
398
|
+
], HTMLTextTextureStyleMetadata.prototype, "scaleMode", void 0);
|
|
399
|
+
__decorate([
|
|
400
|
+
eva_js.type('number'),
|
|
401
|
+
__metadata("design:type", Number)
|
|
402
|
+
], HTMLTextTextureStyleMetadata.prototype, "resolution", void 0);
|
|
403
|
+
class HTMLTextStyleMetadata {
|
|
404
|
+
}
|
|
405
|
+
__decorate([
|
|
406
|
+
eva_js.type('string'),
|
|
407
|
+
__metadata("design:type", Object)
|
|
408
|
+
], HTMLTextStyleMetadata.prototype, "fontFamily", void 0);
|
|
409
|
+
__decorate([
|
|
410
|
+
eva_js.type('number'),
|
|
411
|
+
__metadata("design:type", Object)
|
|
412
|
+
], HTMLTextStyleMetadata.prototype, "fontSize", void 0);
|
|
413
|
+
__decorate([
|
|
414
|
+
eva_js.type('string'),
|
|
415
|
+
__metadata("design:type", String)
|
|
416
|
+
], HTMLTextStyleMetadata.prototype, "fontWeight", void 0);
|
|
417
|
+
__decorate([
|
|
418
|
+
eva_js.type('string'),
|
|
419
|
+
__metadata("design:type", String)
|
|
420
|
+
], HTMLTextStyleMetadata.prototype, "fontStyle", void 0);
|
|
421
|
+
__decorate([
|
|
422
|
+
eva_js.type('string'),
|
|
423
|
+
__metadata("design:type", String)
|
|
424
|
+
], HTMLTextStyleMetadata.prototype, "fontVariant", void 0);
|
|
425
|
+
__decorate([
|
|
426
|
+
eva_js.type('string'),
|
|
427
|
+
__metadata("design:type", String)
|
|
428
|
+
], HTMLTextStyleMetadata.prototype, "align", void 0);
|
|
429
|
+
__decorate([
|
|
430
|
+
eva_js.type('string'),
|
|
431
|
+
__metadata("design:type", String)
|
|
432
|
+
], HTMLTextStyleMetadata.prototype, "textBaseline", void 0);
|
|
433
|
+
__decorate([
|
|
434
|
+
eva_js.Field({ type: 'color' }),
|
|
435
|
+
__metadata("design:type", Object)
|
|
436
|
+
], HTMLTextStyleMetadata.prototype, "fill", void 0);
|
|
437
|
+
__decorate([
|
|
438
|
+
eva_js.Field({ type: 'color' }),
|
|
439
|
+
__metadata("design:type", Object)
|
|
440
|
+
], HTMLTextStyleMetadata.prototype, "stroke", void 0);
|
|
441
|
+
__decorate([
|
|
442
|
+
eva_js.type('number'),
|
|
443
|
+
__metadata("design:type", Number)
|
|
444
|
+
], HTMLTextStyleMetadata.prototype, "strokeThickness", void 0);
|
|
445
|
+
__decorate([
|
|
446
|
+
eva_js.type('number'),
|
|
447
|
+
__metadata("design:type", Number)
|
|
448
|
+
], HTMLTextStyleMetadata.prototype, "lineHeight", void 0);
|
|
449
|
+
__decorate([
|
|
450
|
+
eva_js.type('number'),
|
|
451
|
+
__metadata("design:type", Number)
|
|
452
|
+
], HTMLTextStyleMetadata.prototype, "letterSpacing", void 0);
|
|
453
|
+
__decorate([
|
|
454
|
+
eva_js.type('number'),
|
|
455
|
+
__metadata("design:type", Number)
|
|
456
|
+
], HTMLTextStyleMetadata.prototype, "padding", void 0);
|
|
457
|
+
__decorate([
|
|
458
|
+
eva_js.type('boolean'),
|
|
459
|
+
__metadata("design:type", Boolean)
|
|
460
|
+
], HTMLTextStyleMetadata.prototype, "wordWrap", void 0);
|
|
461
|
+
__decorate([
|
|
462
|
+
eva_js.type('number'),
|
|
463
|
+
__metadata("design:type", Number)
|
|
464
|
+
], HTMLTextStyleMetadata.prototype, "wordWrapWidth", void 0);
|
|
465
|
+
__decorate([
|
|
466
|
+
eva_js.type('boolean'),
|
|
467
|
+
__metadata("design:type", Boolean)
|
|
468
|
+
], HTMLTextStyleMetadata.prototype, "breakWords", void 0);
|
|
469
|
+
__decorate([
|
|
470
|
+
eva_js.type('string'),
|
|
471
|
+
__metadata("design:type", String)
|
|
472
|
+
], HTMLTextStyleMetadata.prototype, "whiteSpace", void 0);
|
|
473
|
+
__decorate([
|
|
474
|
+
eva_js.type('boolean'),
|
|
475
|
+
__metadata("design:type", Boolean)
|
|
476
|
+
], HTMLTextStyleMetadata.prototype, "dropShadow", void 0);
|
|
477
|
+
__decorate([
|
|
478
|
+
eva_js.Field({ type: 'color' }),
|
|
479
|
+
__metadata("design:type", Object)
|
|
480
|
+
], HTMLTextStyleMetadata.prototype, "dropShadowColor", void 0);
|
|
481
|
+
__decorate([
|
|
482
|
+
eva_js.type('number'),
|
|
483
|
+
__metadata("design:type", Number)
|
|
484
|
+
], HTMLTextStyleMetadata.prototype, "dropShadowAlpha", void 0);
|
|
485
|
+
__decorate([
|
|
486
|
+
eva_js.type('number'),
|
|
487
|
+
__metadata("design:type", Number)
|
|
488
|
+
], HTMLTextStyleMetadata.prototype, "dropShadowAngle", void 0);
|
|
489
|
+
__decorate([
|
|
490
|
+
eva_js.type('number'),
|
|
491
|
+
__metadata("design:type", Number)
|
|
492
|
+
], HTMLTextStyleMetadata.prototype, "dropShadowBlur", void 0);
|
|
493
|
+
__decorate([
|
|
494
|
+
eva_js.type('number'),
|
|
495
|
+
__metadata("design:type", Number)
|
|
496
|
+
], HTMLTextStyleMetadata.prototype, "dropShadowDistance", void 0);
|
|
497
|
+
__decorate([
|
|
498
|
+
eva_js.type('object'),
|
|
499
|
+
__metadata("design:type", Array)
|
|
500
|
+
], HTMLTextStyleMetadata.prototype, "cssOverrides", void 0);
|
|
501
|
+
__decorate([
|
|
502
|
+
eva_js.type('object'),
|
|
503
|
+
__metadata("design:type", Object)
|
|
504
|
+
], HTMLTextStyleMetadata.prototype, "tagStyles", void 0);
|
|
505
|
+
__decorate([
|
|
506
|
+
eva_js.type('boolean'),
|
|
507
|
+
__metadata("design:type", Boolean)
|
|
508
|
+
], HTMLTextStyleMetadata.prototype, "trim", void 0);
|
|
170
509
|
/**
|
|
171
510
|
* HTML 富文本组件
|
|
172
511
|
*
|
|
@@ -241,9 +580,6 @@ class HTMLText extends eva_js.Component {
|
|
|
241
580
|
/**
|
|
242
581
|
* 初始化组件
|
|
243
582
|
* @param obj - 初始化参数
|
|
244
|
-
* @param obj.text - 富文本内容
|
|
245
|
-
* @param obj.style - 文本样式
|
|
246
|
-
* @param obj.textureStyle - 纹理配置
|
|
247
583
|
*/
|
|
248
584
|
init(obj) {
|
|
249
585
|
this.style = Object.assign({ fontSize: 24, fill: '#000000', fontFamily: 'Arial' }, obj === null || obj === void 0 ? void 0 : obj.style);
|
|
@@ -256,8 +592,17 @@ class HTMLText extends eva_js.Component {
|
|
|
256
592
|
/** 组件名称 */
|
|
257
593
|
HTMLText.componentName = 'HTMLText';
|
|
258
594
|
__decorate([
|
|
259
|
-
|
|
260
|
-
|
|
595
|
+
eva_js.type('string'),
|
|
596
|
+
__metadata("design:type", String)
|
|
597
|
+
], HTMLText.prototype, "text", void 0);
|
|
598
|
+
__decorate([
|
|
599
|
+
eva_js.Field(() => HTMLTextStyleMetadata),
|
|
600
|
+
__metadata("design:type", Object)
|
|
601
|
+
], HTMLText.prototype, "style", void 0);
|
|
602
|
+
__decorate([
|
|
603
|
+
eva_js.Field(() => HTMLTextTextureStyleMetadata),
|
|
604
|
+
__metadata("design:type", Object)
|
|
605
|
+
], HTMLText.prototype, "textureStyle", void 0);
|
|
261
606
|
|
|
262
607
|
let Text = class Text extends pluginRenderer.Renderer {
|
|
263
608
|
constructor() {
|
|
@@ -309,7 +654,7 @@ let Text = class Text extends pluginRenderer.Renderer {
|
|
|
309
654
|
return __awaiter(this, void 0, void 0, function* () {
|
|
310
655
|
const component = changed.component;
|
|
311
656
|
// 创建文本样式副本,先不设置 fontFamily
|
|
312
|
-
const styleWithoutFont =
|
|
657
|
+
const styleWithoutFont = this.processStyle(component.style);
|
|
313
658
|
const fontFamily = styleWithoutFont.fontFamily;
|
|
314
659
|
delete styleWithoutFont.fontFamily;
|
|
315
660
|
const initialText = fontFamily ? '' : component.text;
|
|
@@ -329,7 +674,7 @@ let Text = class Text extends pluginRenderer.Renderer {
|
|
|
329
674
|
return __awaiter(this, void 0, void 0, function* () {
|
|
330
675
|
const component = changed.component;
|
|
331
676
|
// 创建样式副本,先不设置 fontFamily
|
|
332
|
-
const styleWithoutFont =
|
|
677
|
+
const styleWithoutFont = this.processStyle(component.style);
|
|
333
678
|
const fontFamily = styleWithoutFont.fontFamily;
|
|
334
679
|
delete styleWithoutFont.fontFamily;
|
|
335
680
|
const initialText = fontFamily ? '' : component.text;
|
|
@@ -349,7 +694,7 @@ let Text = class Text extends pluginRenderer.Renderer {
|
|
|
349
694
|
return __awaiter(this, void 0, void 0, function* () {
|
|
350
695
|
const component = changed.component;
|
|
351
696
|
// 创建样式副本,先不设置 fontFamily
|
|
352
|
-
const styleWithoutFont =
|
|
697
|
+
const styleWithoutFont = this.processStyle(component.style);
|
|
353
698
|
const fontFamily = styleWithoutFont.fontFamily;
|
|
354
699
|
delete styleWithoutFont.fontFamily;
|
|
355
700
|
const initialText = fontFamily ? '' : component.text;
|
|
@@ -406,31 +751,40 @@ let Text = class Text extends pluginRenderer.Renderer {
|
|
|
406
751
|
};
|
|
407
752
|
delete processed.strokeThickness;
|
|
408
753
|
}
|
|
409
|
-
// dropShadow* -> dropShadow: { color, distance, angle, alpha, blur }
|
|
410
|
-
|
|
411
|
-
|
|
754
|
+
// dropShadow*(v7 平铺 alias) -> dropShadow: { color, distance, angle, alpha, blur }
|
|
755
|
+
// 关键:只有当存在任何 v7 平铺 alias 时才合并;否则保留 v8 嵌套对象(以及
|
|
756
|
+
// dropShadow: true / false 这种纯开关)原样透传。否则上一种情况会用空对象
|
|
757
|
+
// 把 DSL 已经写好的 angle/blur/distance/... 整个覆盖。
|
|
758
|
+
const hasFlatDropShadowAlias = processed.dropShadowColor != null ||
|
|
759
|
+
processed.dropShadowDistance != null ||
|
|
760
|
+
processed.dropShadowAngle != null ||
|
|
761
|
+
processed.dropShadowAlpha != null ||
|
|
762
|
+
processed.dropShadowBlur != null;
|
|
763
|
+
if (processed.dropShadow && hasFlatDropShadowAlias) {
|
|
764
|
+
const base = processed.dropShadow && typeof processed.dropShadow === 'object' && !Array.isArray(processed.dropShadow)
|
|
765
|
+
? Object.assign({}, processed.dropShadow) : {};
|
|
412
766
|
if (processed.dropShadowColor != null) {
|
|
413
|
-
|
|
767
|
+
base.color = processed.dropShadowColor;
|
|
414
768
|
}
|
|
415
769
|
if (processed.dropShadowDistance != null) {
|
|
416
|
-
|
|
770
|
+
base.distance = processed.dropShadowDistance;
|
|
417
771
|
}
|
|
418
772
|
if (processed.dropShadowAngle != null) {
|
|
419
|
-
|
|
773
|
+
base.angle = processed.dropShadowAngle;
|
|
420
774
|
}
|
|
421
775
|
if (processed.dropShadowAlpha != null) {
|
|
422
|
-
|
|
776
|
+
base.alpha = processed.dropShadowAlpha;
|
|
423
777
|
}
|
|
424
778
|
if (processed.dropShadowBlur != null) {
|
|
425
|
-
|
|
779
|
+
base.blur = processed.dropShadowBlur;
|
|
426
780
|
}
|
|
427
|
-
processed.dropShadow =
|
|
428
|
-
delete processed.dropShadowColor;
|
|
429
|
-
delete processed.dropShadowDistance;
|
|
430
|
-
delete processed.dropShadowAngle;
|
|
431
|
-
delete processed.dropShadowAlpha;
|
|
432
|
-
delete processed.dropShadowBlur;
|
|
781
|
+
processed.dropShadow = base;
|
|
433
782
|
}
|
|
783
|
+
delete processed.dropShadowColor;
|
|
784
|
+
delete processed.dropShadowDistance;
|
|
785
|
+
delete processed.dropShadowAngle;
|
|
786
|
+
delete processed.dropShadowAlpha;
|
|
787
|
+
delete processed.dropShadowBlur;
|
|
434
788
|
// fill 数组 -> 取第一个值 (deprecated)
|
|
435
789
|
if (Array.isArray(processed.fill)) {
|
|
436
790
|
processed.fill = processed.fill[0];
|
|
@@ -478,7 +832,7 @@ let Text = class Text extends pluginRenderer.Renderer {
|
|
|
478
832
|
const newText = new rendererAdapter.HTMLText({
|
|
479
833
|
text: htmlComponent.text,
|
|
480
834
|
style: htmlComponent.style,
|
|
481
|
-
textureStyle: htmlComponent.textureStyle
|
|
835
|
+
textureStyle: htmlComponent.textureStyle,
|
|
482
836
|
});
|
|
483
837
|
container.addChildAt(newText, index);
|
|
484
838
|
this.texts[changed.gameObject.id].text = newText;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@eva/eva.js"),t=require("@eva/inspector-decorator"),o=require("pixi.js"),n=require("@eva/plugin-renderer"),i=require("@eva/renderer-adapter");function s(e,t,o,n){var i,s=arguments.length,r=s<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,o,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(r=(s<3?i(r):s>3?i(t,o,r):i(t,o))||r);return s>3&&r&&Object.defineProperty(t,o,r),r}function r(e,t,o,n){return new(o||(o=Promise))(function(i,s){function r(e){try{l(n.next(e))}catch(e){s(e)}}function a(e){try{l(n.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof o?t:new o(function(e){e(t)})).then(r,a)}l((n=n.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class a extends e.Component{constructor(){super(...arguments),this.text="",this.style={}}init(e){this.style=Object.assign({fontSize:24,fill:"#000000",fontFamily:"Arial"},null==e?void 0:e.style),e&&(this.text=e.text)}}a.componentName="BitmapText",s([t.type("string")],a.prototype,"text",void 0);class l extends e.Component{constructor(){super(...arguments),this.text="",this.style={}}init(e){const t=new o.TextStyle({fontSize:20}),n={};for(const e in t)0===e.indexOf("_")&&(n[e.substring(1)]=t[e]);delete n.styleKey,this.style=n,e&&(this.text=e.text,Object.assign(this.style,e.style))}}l.componentName="Text",s([t.type("string")],l.prototype,"text",void 0);class d extends e.Component{constructor(){super(...arguments),this.text="",this.style={},this.textureStyle={}}init(e){this.style=Object.assign({fontSize:24,fill:"#000000",fontFamily:"Arial"},null==e?void 0:e.style),this.textureStyle=Object.assign({scaleMode:"linear",resolution:window.devicePixelRatio||1},null==e?void 0:e.textureStyle),e&&(this.text=e.text)}}d.componentName="HTMLText",s([t.type("string")],d.prototype,"text",void 0);let c=class extends n.Renderer{constructor(){super(...arguments),this.name="Text",this.texts={}}init(){this.renderSystem=this.game.getSystem(n.RendererSystem),this.renderSystem.rendererManager.register(this)}componentChanged(t){return r(this,void 0,void 0,function*(){const o="Text"===t.componentName,n="HTMLText"===t.componentName,i="BitmapText"===t.componentName;if(o||n||i)if(t.type===e.OBSERVER_TYPE.ADD)o?yield this.addTextComponent(t):n?yield this.addHTMLTextComponent(t):yield this.addBitmapTextComponent(t),this.setSize(t);else if(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];else{this.change(t);const e=t.component;if("style"===t.prop.prop[0]&&e.style&&e.style.fontFamily){const{text:o}=this.texts[t.gameObject.id];yield this.waitForFontResource(o,t,e.style.fontFamily)}this.setSize(t)}})}addTextComponent(e){return r(this,void 0,void 0,function*(){const t=e.component,o=Object.assign({},t.style),n=o.fontFamily;delete o.fontFamily;const s=n?"":t.text,r=new i.Text(s,o);this.containerManager.getContainer(e.gameObject.id).addChildAt(r,0),this.texts[e.gameObject.id]={text:r,component:t},n&&(yield this.waitForFontResource(r,e,n))})}addHTMLTextComponent(e){return r(this,void 0,void 0,function*(){const t=e.component,o=Object.assign({},t.style),n=o.fontFamily;delete o.fontFamily;const s=n?"":t.text,r=new i.HTMLText(Object.assign({text:s,style:o},t.textureStyle&&{textureStyle:t.textureStyle}));this.containerManager.getContainer(e.gameObject.id).addChildAt(r,0),this.texts[e.gameObject.id]={text:r,component:t},n&&(yield this.waitForFontResource(r,e,n))})}addBitmapTextComponent(e){return r(this,void 0,void 0,function*(){const t=e.component,o=Object.assign({},t.style),n=o.fontFamily;delete o.fontFamily;const s=n?"":t.text,r=new i.BitmapText(s,o);this.containerManager.getContainer(e.gameObject.id).addChildAt(r,0),this.texts[e.gameObject.id]={text:r,component:t},n&&(yield this.waitForFontResource(r,e,n))})}waitForFontResource(t,o,n){return r(this,void 0,void 0,function*(){if(n)try{const i=Array.isArray(n)?n[0]:n,s=this.increaseAsyncId(o.gameObject.id);if(yield e.resource.getResource(i),!this.validateAsyncId(o.gameObject.id,s))return;const r=this.texts[o.gameObject.id].component;t.style.fontFamily=n,t.text=r.text}catch(e){console.warn(`字体资源 ${n} 加载失败:`,e)}})}processStyle(e){const t=Object.assign({},e);if(t.strokeThickness){const e=t.stroke;t.stroke={color:e,width:t.strokeThickness},delete t.strokeThickness}if(t.dropShadow){const e={};null!=t.dropShadowColor&&(e.color=t.dropShadowColor),null!=t.dropShadowDistance&&(e.distance=t.dropShadowDistance),null!=t.dropShadowAngle&&(e.angle=t.dropShadowAngle),null!=t.dropShadowAlpha&&(e.alpha=t.dropShadowAlpha),null!=t.dropShadowBlur&&(e.blur=t.dropShadowBlur),t.dropShadow=e,delete t.dropShadowColor,delete t.dropShadowDistance,delete t.dropShadowAngle,delete t.dropShadowAlpha,delete t.dropShadowBlur}if(Array.isArray(t.fill)&&(t.fill=t.fill[0]),Array.isArray(t.fillGradientStops)){let e;e=null==t.fontSize?o.TextStyle.defaultTextStyle.fontSize:"string"==typeof t.fontSize?parseInt(t.fontSize,10):t.fontSize;const n=new o.FillGradient(0,0,0,1.7*e),i=t.fillGradientStops.map(e=>o.Color.shared.setValue(e).toNumber());i.forEach((e,t)=>{const o=t/(i.length-1);n.addColorStop(o,e)}),t.fill={fill:n},delete t.fillGradientStops}return t}change(e){const{text:t,component:o}=this.texts[e.gameObject.id],n="HTMLText"===e.componentName;if("text"===e.prop.prop[0])t.text=o.text;else if("style"===e.prop.prop[0]){const e=this.processStyle(o.style);Object.assign(t.style,e)}else if("textureStyle"===e.prop.prop[0]&&n){const n=o,s=this.containerManager.getContainer(e.gameObject.id),r=s.getChildIndex(t);s.removeChild(t),t.destroy({children:!0});const a=new i.HTMLText({text:n.text,style:n.style,textureStyle:n.textureStyle});s.addChildAt(a,r),this.texts[e.gameObject.id].text=a}}setSize(e){const{transform:t}=e.gameObject;if(!t)return;const{text:o}=this.texts[e.gameObject.id],n=o.getSize();t.size.width=n.width,t.size.height=n.height}};c.systemName="Text",c=s([e.decorators.componentObserver({Text:["text",{prop:["style"],deep:!0}],HTMLText:["text",{prop:["style"],deep:!0},{prop:["textureStyle"],deep:!0}],BitmapText:["text",{prop:["style"],deep:!0}]})],c);var p=c;exports.BitmapText=a,exports.HTMLText=d,exports.Text=l,exports.TextSystem=p;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@eva/eva.js"),t=require("pixi.js"),o=require("@eva/plugin-renderer"),i=require("@eva/renderer-adapter");function r(e,t,o,i){var r,n=arguments.length,p=n<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)p=Reflect.decorate(e,t,o,i);else for(var d=e.length-1;d>=0;d--)(r=e[d])&&(p=(n<3?r(p):n>3?r(t,o,p):r(t,o))||p);return n>3&&p&&Object.defineProperty(t,o,p),p}function n(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function p(e,t,o,i){return new(o||(o=Promise))(function(r,n){function p(e){try{s(i.next(e))}catch(e){n(e)}}function d(e){try{s(i.throw(e))}catch(e){n(e)}}function s(e){var t;e.done?r(e.value):(t=e.value,t instanceof o?t:new o(function(e){e(t)})).then(p,d)}s((i=i.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class d{}r([e.type("string"),n("design:type",Object)],d.prototype,"fontFamily",void 0),r([e.type("number"),n("design:type",Object)],d.prototype,"fontSize",void 0),r([e.Field({type:"color"}),n("design:type",Object)],d.prototype,"fill",void 0),r([e.type("string"),n("design:type",String)],d.prototype,"align",void 0),r([e.type("number"),n("design:type",Number)],d.prototype,"letterSpacing",void 0),r([e.type("number"),n("design:type",Number)],d.prototype,"padding",void 0),r([e.Field({type:"color"}),n("design:type",Object)],d.prototype,"stroke",void 0),r([e.type("number"),n("design:type",Number)],d.prototype,"strokeThickness",void 0),r([e.type("string"),n("design:type",String)],d.prototype,"fontWeight",void 0),r([e.type("string"),n("design:type",String)],d.prototype,"fontStyle",void 0);class s extends e.Component{constructor(){super(...arguments),this.text="",this.style={}}init(e){this.style=Object.assign({fontSize:24,fill:"#000000",fontFamily:"Arial"},null==e?void 0:e.style),e&&(this.text=e.text)}}s.componentName="BitmapText",r([e.type("string"),n("design:type",String)],s.prototype,"text",void 0),r([e.Field(()=>d),n("design:type",Object)],s.prototype,"style",void 0);class y{}r([e.type("number"),n("design:type",Number)],y.prototype,"alpha",void 0),r([e.Field({type:"color"}),n("design:type",Object)],y.prototype,"color",void 0),r([e.type("string"),n("design:type",String)],y.prototype,"join",void 0),r([e.type("number"),n("design:type",Number)],y.prototype,"miterLimit",void 0),r([e.type("number"),n("design:type",Number)],y.prototype,"width",void 0);class l{}r([e.type("number"),n("design:type",Number)],l.prototype,"alpha",void 0),r([e.type("number"),n("design:type",Number)],l.prototype,"angle",void 0),r([e.type("number"),n("design:type",Number)],l.prototype,"blur",void 0),r([e.Field({type:"color"}),n("design:type",Object)],l.prototype,"color",void 0),r([e.type("number"),n("design:type",Number)],l.prototype,"distance",void 0),r([e.type("boolean"),n("design:type",Boolean)],l.prototype,"enabled",void 0);class a{}r([e.type("string"),n("design:type",String)],a.prototype,"align",void 0),r([e.type("boolean"),n("design:type",Boolean)],a.prototype,"breakWords",void 0),r([e.Field(()=>l),n("design:type",Object)],a.prototype,"dropShadow",void 0),r([e.type("number"),n("design:type",Number)],a.prototype,"dropShadowAlpha",void 0),r([e.type("number"),n("design:type",Number)],a.prototype,"dropShadowAngle",void 0),r([e.type("number"),n("design:type",Number)],a.prototype,"dropShadowBlur",void 0),r([e.Field({type:"color"}),n("design:type",Object)],a.prototype,"dropShadowColor",void 0),r([e.type("number"),n("design:type",Number)],a.prototype,"dropShadowDistance",void 0),r([e.Field({type:"color"}),n("design:type",Object)],a.prototype,"fill",void 0),r([e.type("number"),n("design:type",Number)],a.prototype,"fillGradientType",void 0),r([e.type("number"),n("design:type",Array)],a.prototype,"fillGradientStops",void 0),r([e.type("string"),n("design:type",Object)],a.prototype,"fontFamily",void 0),r([e.type("number"),n("design:type",Object)],a.prototype,"fontSize",void 0),r([e.type("string"),n("design:type",String)],a.prototype,"fontStyle",void 0),r([e.type("string"),n("design:type",String)],a.prototype,"fontVariant",void 0),r([e.type("string"),n("design:type",String)],a.prototype,"fontWeight",void 0),r([e.type("number"),n("design:type",Number)],a.prototype,"leading",void 0),r([e.type("number"),n("design:type",Number)],a.prototype,"letterSpacing",void 0),r([e.type("number"),n("design:type",Number)],a.prototype,"lineHeight",void 0),r([e.type("string"),n("design:type",String)],a.prototype,"lineJoin",void 0),r([e.type("number"),n("design:type",Number)],a.prototype,"miterLimit",void 0),r([e.type("number"),n("design:type",Number)],a.prototype,"padding",void 0),r([e.Field(()=>y),n("design:type",Object)],a.prototype,"stroke",void 0),r([e.type("number"),n("design:type",Number)],a.prototype,"strokeThickness",void 0),r([e.type("string"),n("design:type",String)],a.prototype,"textBaseline",void 0),r([e.type("string"),n("design:type",String)],a.prototype,"verticalAlign",void 0),r([e.type("boolean"),n("design:type",Boolean)],a.prototype,"trim",void 0),r([e.type("string"),n("design:type",String)],a.prototype,"whiteSpace",void 0),r([e.type("boolean"),n("design:type",Boolean)],a.prototype,"wordWrap",void 0),r([e.type("number"),n("design:type",Number)],a.prototype,"wordWrapWidth",void 0);class c extends e.Component{constructor(e){super(e),this.text="",this.style={},this.init(e)}init(e){const o=new t.TextStyle({fontSize:20}),i={};for(const e in o)0===e.indexOf("_")&&(i[e.substring(1)]=o[e]);delete i.styleKey,this.style=i,e&&(this.text=e.text,Object.assign(this.style,e.style))}}c.componentName="Text",r([e.type("string"),n("design:type",String)],c.prototype,"text",void 0),r([e.Field(()=>a),n("design:type",Object)],c.prototype,"style",void 0);class g{}r([e.type("string"),n("design:type",String)],g.prototype,"scaleMode",void 0),r([e.type("number"),n("design:type",Number)],g.prototype,"resolution",void 0);class m{}r([e.type("string"),n("design:type",Object)],m.prototype,"fontFamily",void 0),r([e.type("number"),n("design:type",Object)],m.prototype,"fontSize",void 0),r([e.type("string"),n("design:type",String)],m.prototype,"fontWeight",void 0),r([e.type("string"),n("design:type",String)],m.prototype,"fontStyle",void 0),r([e.type("string"),n("design:type",String)],m.prototype,"fontVariant",void 0),r([e.type("string"),n("design:type",String)],m.prototype,"align",void 0),r([e.type("string"),n("design:type",String)],m.prototype,"textBaseline",void 0),r([e.Field({type:"color"}),n("design:type",Object)],m.prototype,"fill",void 0),r([e.Field({type:"color"}),n("design:type",Object)],m.prototype,"stroke",void 0),r([e.type("number"),n("design:type",Number)],m.prototype,"strokeThickness",void 0),r([e.type("number"),n("design:type",Number)],m.prototype,"lineHeight",void 0),r([e.type("number"),n("design:type",Number)],m.prototype,"letterSpacing",void 0),r([e.type("number"),n("design:type",Number)],m.prototype,"padding",void 0),r([e.type("boolean"),n("design:type",Boolean)],m.prototype,"wordWrap",void 0),r([e.type("number"),n("design:type",Number)],m.prototype,"wordWrapWidth",void 0),r([e.type("boolean"),n("design:type",Boolean)],m.prototype,"breakWords",void 0),r([e.type("string"),n("design:type",String)],m.prototype,"whiteSpace",void 0),r([e.type("boolean"),n("design:type",Boolean)],m.prototype,"dropShadow",void 0),r([e.Field({type:"color"}),n("design:type",Object)],m.prototype,"dropShadowColor",void 0),r([e.type("number"),n("design:type",Number)],m.prototype,"dropShadowAlpha",void 0),r([e.type("number"),n("design:type",Number)],m.prototype,"dropShadowAngle",void 0),r([e.type("number"),n("design:type",Number)],m.prototype,"dropShadowBlur",void 0),r([e.type("number"),n("design:type",Number)],m.prototype,"dropShadowDistance",void 0),r([e.type("object"),n("design:type",Array)],m.prototype,"cssOverrides",void 0),r([e.type("object"),n("design:type",Object)],m.prototype,"tagStyles",void 0),r([e.type("boolean"),n("design:type",Boolean)],m.prototype,"trim",void 0);class u extends e.Component{constructor(){super(...arguments),this.text="",this.style={},this.textureStyle={}}init(e){this.style=Object.assign({fontSize:24,fill:"#000000",fontFamily:"Arial"},null==e?void 0:e.style),this.textureStyle=Object.assign({scaleMode:"linear",resolution:window.devicePixelRatio||1},null==e?void 0:e.textureStyle),e&&(this.text=e.text)}}u.componentName="HTMLText",r([e.type("string"),n("design:type",String)],u.prototype,"text",void 0),r([e.Field(()=>m),n("design:type",Object)],u.prototype,"style",void 0),r([e.Field(()=>g),n("design:type",Object)],u.prototype,"textureStyle",void 0);let h=class extends o.Renderer{constructor(){super(...arguments),this.name="Text",this.texts={}}init(){this.renderSystem=this.game.getSystem(o.RendererSystem),this.renderSystem.rendererManager.register(this)}componentChanged(t){return p(this,void 0,void 0,function*(){const o="Text"===t.componentName,i="HTMLText"===t.componentName,r="BitmapText"===t.componentName;if(o||i||r)if(t.type===e.OBSERVER_TYPE.ADD)o?yield this.addTextComponent(t):i?yield this.addHTMLTextComponent(t):yield this.addBitmapTextComponent(t),this.setSize(t);else if(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];else{this.change(t);const e=t.component;if("style"===t.prop.prop[0]&&e.style&&e.style.fontFamily){const{text:o}=this.texts[t.gameObject.id];yield this.waitForFontResource(o,t,e.style.fontFamily)}this.setSize(t)}})}addTextComponent(e){return p(this,void 0,void 0,function*(){const t=e.component,o=this.processStyle(t.style),r=o.fontFamily;delete o.fontFamily;const n=r?"":t.text,p=new i.Text(n,o);this.containerManager.getContainer(e.gameObject.id).addChildAt(p,0),this.texts[e.gameObject.id]={text:p,component:t},r&&(yield this.waitForFontResource(p,e,r))})}addHTMLTextComponent(e){return p(this,void 0,void 0,function*(){const t=e.component,o=this.processStyle(t.style),r=o.fontFamily;delete o.fontFamily;const n=r?"":t.text,p=new i.HTMLText(Object.assign({text:n,style:o},t.textureStyle&&{textureStyle:t.textureStyle}));this.containerManager.getContainer(e.gameObject.id).addChildAt(p,0),this.texts[e.gameObject.id]={text:p,component:t},r&&(yield this.waitForFontResource(p,e,r))})}addBitmapTextComponent(e){return p(this,void 0,void 0,function*(){const t=e.component,o=this.processStyle(t.style),r=o.fontFamily;delete o.fontFamily;const n=r?"":t.text,p=new i.BitmapText(n,o);this.containerManager.getContainer(e.gameObject.id).addChildAt(p,0),this.texts[e.gameObject.id]={text:p,component:t},r&&(yield this.waitForFontResource(p,e,r))})}waitForFontResource(t,o,i){return p(this,void 0,void 0,function*(){if(i)try{const r=Array.isArray(i)?i[0]:i,n=this.increaseAsyncId(o.gameObject.id);if(yield e.resource.getResource(r),!this.validateAsyncId(o.gameObject.id,n))return;const p=this.texts[o.gameObject.id].component;t.style.fontFamily=i,t.text=p.text}catch(e){console.warn(`字体资源 ${i} 加载失败:`,e)}})}processStyle(e){const o=Object.assign({},e);if(o.strokeThickness){const e=o.stroke;o.stroke={color:e,width:o.strokeThickness},delete o.strokeThickness}const i=null!=o.dropShadowColor||null!=o.dropShadowDistance||null!=o.dropShadowAngle||null!=o.dropShadowAlpha||null!=o.dropShadowBlur;if(o.dropShadow&&i){const e=o.dropShadow&&"object"==typeof o.dropShadow&&!Array.isArray(o.dropShadow)?Object.assign({},o.dropShadow):{};null!=o.dropShadowColor&&(e.color=o.dropShadowColor),null!=o.dropShadowDistance&&(e.distance=o.dropShadowDistance),null!=o.dropShadowAngle&&(e.angle=o.dropShadowAngle),null!=o.dropShadowAlpha&&(e.alpha=o.dropShadowAlpha),null!=o.dropShadowBlur&&(e.blur=o.dropShadowBlur),o.dropShadow=e}if(delete o.dropShadowColor,delete o.dropShadowDistance,delete o.dropShadowAngle,delete o.dropShadowAlpha,delete o.dropShadowBlur,Array.isArray(o.fill)&&(o.fill=o.fill[0]),Array.isArray(o.fillGradientStops)){let e;e=null==o.fontSize?t.TextStyle.defaultTextStyle.fontSize:"string"==typeof o.fontSize?parseInt(o.fontSize,10):o.fontSize;const i=new t.FillGradient(0,0,0,1.7*e),r=o.fillGradientStops.map(e=>t.Color.shared.setValue(e).toNumber());r.forEach((e,t)=>{const o=t/(r.length-1);i.addColorStop(o,e)}),o.fill={fill:i},delete o.fillGradientStops}return o}change(e){const{text:t,component:o}=this.texts[e.gameObject.id],r="HTMLText"===e.componentName;if("text"===e.prop.prop[0])t.text=o.text;else if("style"===e.prop.prop[0]){const e=this.processStyle(o.style);Object.assign(t.style,e)}else if("textureStyle"===e.prop.prop[0]&&r){const r=o,n=this.containerManager.getContainer(e.gameObject.id),p=n.getChildIndex(t);n.removeChild(t),t.destroy({children:!0});const d=new i.HTMLText({text:r.text,style:r.style,textureStyle:r.textureStyle});n.addChildAt(d,p),this.texts[e.gameObject.id].text=d}}setSize(e){const{transform:t}=e.gameObject;if(!t)return;const{text:o}=this.texts[e.gameObject.id],i=o.getSize();t.size.width=i.width,t.size.height=i.height}};h.systemName="Text",h=r([e.decorators.componentObserver({Text:["text",{prop:["style"],deep:!0}],HTMLText:["text",{prop:["style"],deep:!0},{prop:["textureStyle"],deep:!0}],BitmapText:["text",{prop:["style"],deep:!0}]})],h);var b=h;exports.BitmapText=s,exports.HTMLText=u,exports.Text=c,exports.TextSystem=b;
|
|
@@ -7,12 +7,6 @@ import { Renderer } from '@eva/plugin-renderer';
|
|
|
7
7
|
import { RendererManager } from '@eva/plugin-renderer';
|
|
8
8
|
import { RendererSystem } from '@eva/plugin-renderer';
|
|
9
9
|
import { Text as Text_3 } from '@eva/renderer-adapter';
|
|
10
|
-
import { TextStyleAlign } from 'pixi.js';
|
|
11
|
-
import { TextStyleFontStyle } from 'pixi.js';
|
|
12
|
-
import { TextStyleFontVariant } from 'pixi.js';
|
|
13
|
-
import { TextStyleFontWeight } from 'pixi.js';
|
|
14
|
-
import { TextStyleTextBaseline } from 'pixi.js';
|
|
15
|
-
import { TextStyleWhiteSpace } from 'pixi.js';
|
|
16
10
|
|
|
17
11
|
/**
|
|
18
12
|
* 位图文本组件
|
|
@@ -135,9 +129,6 @@ export declare class HTMLText extends Component<HTMLTextParams> {
|
|
|
135
129
|
/**
|
|
136
130
|
* 初始化组件
|
|
137
131
|
* @param obj - 初始化参数
|
|
138
|
-
* @param obj.text - 富文本内容
|
|
139
|
-
* @param obj.style - 文本样式
|
|
140
|
-
* @param obj.textureStyle - 纹理配置
|
|
141
132
|
*/
|
|
142
133
|
init(obj?: HTMLTextParams): void;
|
|
143
134
|
}
|
|
@@ -230,11 +221,10 @@ declare class Text_2 extends Component<TextParams> {
|
|
|
230
221
|
text: string;
|
|
231
222
|
/** 文本样式配置 */
|
|
232
223
|
style: TextParams['style'];
|
|
224
|
+
constructor(params?: TextParams);
|
|
233
225
|
/**
|
|
234
226
|
* 初始化组件
|
|
235
227
|
* @param obj - 初始化参数
|
|
236
|
-
* @param obj.text - 文本内容
|
|
237
|
-
* @param obj.style - 文本样式
|
|
238
228
|
*/
|
|
239
229
|
init(obj?: TextParams): void;
|
|
240
230
|
}
|
|
@@ -256,9 +246,9 @@ export declare interface TextParams {
|
|
|
256
246
|
fillGradientStops?: number[];
|
|
257
247
|
fontFamily?: string | string[];
|
|
258
248
|
fontSize?: number | string;
|
|
259
|
-
fontStyle?:
|
|
249
|
+
fontStyle?: TextStyleFontStyle_2;
|
|
260
250
|
fontVariant?: TextStyleFontVariant;
|
|
261
|
-
fontWeight?:
|
|
251
|
+
fontWeight?: TextStyleFontWeight_2;
|
|
262
252
|
letterSpacing?: number;
|
|
263
253
|
lineHeight?: number;
|
|
264
254
|
lineJoin?: string;
|
|
@@ -267,6 +257,7 @@ export declare interface TextParams {
|
|
|
267
257
|
stroke?: string | number;
|
|
268
258
|
strokeThickness?: number;
|
|
269
259
|
textBaseline?: TextStyleTextBaseline;
|
|
260
|
+
verticalAlign?: 'top' | 'middle' | 'bottom' | string;
|
|
270
261
|
trim?: boolean;
|
|
271
262
|
whiteSpace?: TextStyleWhiteSpace;
|
|
272
263
|
wordWrap?: boolean;
|
|
@@ -275,6 +266,22 @@ export declare interface TextParams {
|
|
|
275
266
|
};
|
|
276
267
|
}
|
|
277
268
|
|
|
269
|
+
declare type TextStyleAlign = 'left' | 'center' | 'right' | 'justify';
|
|
270
|
+
|
|
271
|
+
declare type TextStyleFontStyle = 'normal' | 'italic' | 'oblique';
|
|
272
|
+
|
|
273
|
+
declare type TextStyleFontStyle_2 = 'normal' | 'italic' | 'oblique';
|
|
274
|
+
|
|
275
|
+
declare type TextStyleFontVariant = 'normal' | 'small-caps';
|
|
276
|
+
|
|
277
|
+
declare type TextStyleFontWeight = 'normal' | 'bold' | 'bolder' | 'lighter' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900';
|
|
278
|
+
|
|
279
|
+
declare type TextStyleFontWeight_2 = 'normal' | 'bold' | 'bolder' | 'lighter' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900';
|
|
280
|
+
|
|
281
|
+
declare type TextStyleTextBaseline = 'alphabetic' | 'top' | 'hanging' | 'middle' | 'ideographic' | 'bottom';
|
|
282
|
+
|
|
283
|
+
declare type TextStyleWhiteSpace = 'normal' | 'pre' | 'pre-line';
|
|
284
|
+
|
|
278
285
|
export declare class TextSystem extends Renderer {
|
|
279
286
|
static systemName: string;
|
|
280
287
|
name: string;
|