@eva/plugin-renderer-text 2.0.1-beta.8 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/EVA.plugin.renderer.text.js +236 -34
- package/dist/EVA.plugin.renderer.text.min.js +1 -1
- package/dist/plugin-renderer-text.cjs.js +383 -33
- package/dist/plugin-renderer-text.cjs.prod.js +2 -2
- package/dist/plugin-renderer-text.d.ts +233 -4
- package/dist/plugin-renderer-text.esm.js +384 -36
- package/package.json +5 -5
|
@@ -2,7 +2,7 @@ function _extends() { return _extends = Object.assign ? Object.assign.bind() : f
|
|
|
2
2
|
globalThis.EVA = globalThis.EVA || {};
|
|
3
3
|
globalThis.EVA.plugin = globalThis.EVA.plugin || {};
|
|
4
4
|
globalThis.EVA.plugin.renderer = globalThis.EVA.plugin.renderer || {};
|
|
5
|
-
var _EVA_IIFE_text = function (exports,
|
|
5
|
+
var _EVA_IIFE_text = function (exports, eva_js, pixi_js, pluginRenderer, rendererAdapter) {
|
|
6
6
|
'use strict';
|
|
7
7
|
function __decorate(decorators, target, key, desc) {
|
|
8
8
|
var c = arguments.length,
|
|
@@ -55,6 +55,25 @@ var _EVA_IIFE_text = function (exports, pixi_js, eva_js, pluginRenderer, rendere
|
|
|
55
55
|
prop.type = type;
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
|
+
class BitmapText extends eva_js.Component {
|
|
59
|
+
constructor() {
|
|
60
|
+
super(...arguments);
|
|
61
|
+
this.text = '';
|
|
62
|
+
this.style = {};
|
|
63
|
+
}
|
|
64
|
+
init(obj) {
|
|
65
|
+
this.style = _extends({
|
|
66
|
+
fontSize: 24,
|
|
67
|
+
fill: '#000000',
|
|
68
|
+
fontFamily: 'Arial'
|
|
69
|
+
}, obj === null || obj === void 0 ? void 0 : obj.style);
|
|
70
|
+
if (obj) {
|
|
71
|
+
this.text = obj.text;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
BitmapText.componentName = 'BitmapText';
|
|
76
|
+
__decorate([type('string')], BitmapText.prototype, "text", void 0);
|
|
58
77
|
class Text$2 extends eva_js.Component {
|
|
59
78
|
constructor() {
|
|
60
79
|
super(...arguments);
|
|
@@ -81,6 +100,30 @@ var _EVA_IIFE_text = function (exports, pixi_js, eva_js, pluginRenderer, rendere
|
|
|
81
100
|
}
|
|
82
101
|
Text$2.componentName = 'Text';
|
|
83
102
|
__decorate([type('string')], Text$2.prototype, "text", void 0);
|
|
103
|
+
class HTMLText extends eva_js.Component {
|
|
104
|
+
constructor() {
|
|
105
|
+
super(...arguments);
|
|
106
|
+
this.text = '';
|
|
107
|
+
this.style = {};
|
|
108
|
+
this.textureStyle = {};
|
|
109
|
+
}
|
|
110
|
+
init(obj) {
|
|
111
|
+
this.style = _extends({
|
|
112
|
+
fontSize: 24,
|
|
113
|
+
fill: '#000000',
|
|
114
|
+
fontFamily: 'Arial'
|
|
115
|
+
}, obj === null || obj === void 0 ? void 0 : obj.style);
|
|
116
|
+
this.textureStyle = _extends({
|
|
117
|
+
scaleMode: 'linear',
|
|
118
|
+
resolution: window.devicePixelRatio || 1
|
|
119
|
+
}, obj === null || obj === void 0 ? void 0 : obj.textureStyle);
|
|
120
|
+
if (obj) {
|
|
121
|
+
this.text = obj.text;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
HTMLText.componentName = 'HTMLText';
|
|
126
|
+
__decorate([type('string')], HTMLText.prototype, "text", void 0);
|
|
84
127
|
let Text = class Text extends pluginRenderer.Renderer {
|
|
85
128
|
constructor() {
|
|
86
129
|
super(...arguments);
|
|
@@ -93,15 +136,18 @@ var _EVA_IIFE_text = function (exports, pixi_js, eva_js, pluginRenderer, rendere
|
|
|
93
136
|
}
|
|
94
137
|
componentChanged(changed) {
|
|
95
138
|
return __awaiter(this, void 0, void 0, function* () {
|
|
96
|
-
|
|
139
|
+
const isText = changed.componentName === 'Text';
|
|
140
|
+
const isHTMLText = changed.componentName === 'HTMLText';
|
|
141
|
+
const isBitmapText = changed.componentName === 'BitmapText';
|
|
142
|
+
if (!isText && !isHTMLText && !isBitmapText) return;
|
|
97
143
|
if (changed.type === eva_js.OBSERVER_TYPE.ADD) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
144
|
+
if (isText) {
|
|
145
|
+
yield this.addTextComponent(changed);
|
|
146
|
+
} else if (isHTMLText) {
|
|
147
|
+
yield this.addHTMLTextComponent(changed);
|
|
148
|
+
} else {
|
|
149
|
+
yield this.addBitmapTextComponent(changed);
|
|
150
|
+
}
|
|
105
151
|
this.setSize(changed);
|
|
106
152
|
} else if (changed.type === eva_js.OBSERVER_TYPE.REMOVE) {
|
|
107
153
|
this.containerManager.getContainer(changed.gameObject.id).removeChild(this.texts[changed.gameObject.id].text);
|
|
@@ -111,40 +157,179 @@ var _EVA_IIFE_text = function (exports, pixi_js, eva_js, pluginRenderer, rendere
|
|
|
111
157
|
delete this.texts[changed.gameObject.id];
|
|
112
158
|
} else {
|
|
113
159
|
this.change(changed);
|
|
160
|
+
const component = changed.component;
|
|
161
|
+
if (changed.prop.prop[0] === 'style' && component.style && component.style.fontFamily) {
|
|
162
|
+
const {
|
|
163
|
+
text
|
|
164
|
+
} = this.texts[changed.gameObject.id];
|
|
165
|
+
yield this.waitForFontResource(text, changed, component.style.fontFamily);
|
|
166
|
+
}
|
|
114
167
|
this.setSize(changed);
|
|
115
168
|
}
|
|
116
169
|
});
|
|
117
170
|
}
|
|
171
|
+
addTextComponent(changed) {
|
|
172
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
173
|
+
const component = changed.component;
|
|
174
|
+
const styleWithoutFont = _extends({}, component.style);
|
|
175
|
+
const fontFamily = styleWithoutFont.fontFamily;
|
|
176
|
+
delete styleWithoutFont.fontFamily;
|
|
177
|
+
const initialText = fontFamily ? '' : component.text;
|
|
178
|
+
const text = new rendererAdapter.Text(initialText, styleWithoutFont);
|
|
179
|
+
this.containerManager.getContainer(changed.gameObject.id).addChildAt(text, 0);
|
|
180
|
+
this.texts[changed.gameObject.id] = {
|
|
181
|
+
text,
|
|
182
|
+
component
|
|
183
|
+
};
|
|
184
|
+
if (fontFamily) {
|
|
185
|
+
yield this.waitForFontResource(text, changed, fontFamily);
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
addHTMLTextComponent(changed) {
|
|
190
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
191
|
+
const component = changed.component;
|
|
192
|
+
const styleWithoutFont = _extends({}, component.style);
|
|
193
|
+
const fontFamily = styleWithoutFont.fontFamily;
|
|
194
|
+
delete styleWithoutFont.fontFamily;
|
|
195
|
+
const initialText = fontFamily ? '' : component.text;
|
|
196
|
+
const htmlText = new rendererAdapter.HTMLText(_extends({
|
|
197
|
+
text: initialText,
|
|
198
|
+
style: styleWithoutFont
|
|
199
|
+
}, component.textureStyle && {
|
|
200
|
+
textureStyle: component.textureStyle
|
|
201
|
+
}));
|
|
202
|
+
this.containerManager.getContainer(changed.gameObject.id).addChildAt(htmlText, 0);
|
|
203
|
+
this.texts[changed.gameObject.id] = {
|
|
204
|
+
text: htmlText,
|
|
205
|
+
component
|
|
206
|
+
};
|
|
207
|
+
if (fontFamily) {
|
|
208
|
+
yield this.waitForFontResource(htmlText, changed, fontFamily);
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
addBitmapTextComponent(changed) {
|
|
213
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
214
|
+
const component = changed.component;
|
|
215
|
+
const styleWithoutFont = _extends({}, component.style);
|
|
216
|
+
const fontFamily = styleWithoutFont.fontFamily;
|
|
217
|
+
delete styleWithoutFont.fontFamily;
|
|
218
|
+
const initialText = fontFamily ? '' : component.text;
|
|
219
|
+
const bitmapText = new rendererAdapter.BitmapText(initialText, styleWithoutFont);
|
|
220
|
+
this.containerManager.getContainer(changed.gameObject.id).addChildAt(bitmapText, 0);
|
|
221
|
+
this.texts[changed.gameObject.id] = {
|
|
222
|
+
text: bitmapText,
|
|
223
|
+
component
|
|
224
|
+
};
|
|
225
|
+
if (fontFamily) {
|
|
226
|
+
yield this.waitForFontResource(bitmapText, changed, fontFamily);
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
waitForFontResource(text, changed, fontFamily) {
|
|
231
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
232
|
+
if (!fontFamily) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
try {
|
|
236
|
+
const fontName = Array.isArray(fontFamily) ? fontFamily[0] : fontFamily;
|
|
237
|
+
const asyncId = this.increaseAsyncId(changed.gameObject.id);
|
|
238
|
+
yield eva_js.resource.getResource(fontName);
|
|
239
|
+
if (!this.validateAsyncId(changed.gameObject.id, asyncId)) return;
|
|
240
|
+
const component = this.texts[changed.gameObject.id].component;
|
|
241
|
+
text.style.fontFamily = fontFamily;
|
|
242
|
+
text.text = component.text;
|
|
243
|
+
} catch (error) {
|
|
244
|
+
console.warn(`字体资源 ${fontFamily} 加载失败:`, error);
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
processStyle(style) {
|
|
249
|
+
const processed = _extends({}, style);
|
|
250
|
+
if (processed.strokeThickness) {
|
|
251
|
+
const color = processed.stroke;
|
|
252
|
+
processed.stroke = {
|
|
253
|
+
color,
|
|
254
|
+
width: processed.strokeThickness
|
|
255
|
+
};
|
|
256
|
+
delete processed.strokeThickness;
|
|
257
|
+
}
|
|
258
|
+
if (processed.dropShadow) {
|
|
259
|
+
const dropShadowConfig = {};
|
|
260
|
+
if (processed.dropShadowColor != null) {
|
|
261
|
+
dropShadowConfig.color = processed.dropShadowColor;
|
|
262
|
+
}
|
|
263
|
+
if (processed.dropShadowDistance != null) {
|
|
264
|
+
dropShadowConfig.distance = processed.dropShadowDistance;
|
|
265
|
+
}
|
|
266
|
+
if (processed.dropShadowAngle != null) {
|
|
267
|
+
dropShadowConfig.angle = processed.dropShadowAngle;
|
|
268
|
+
}
|
|
269
|
+
if (processed.dropShadowAlpha != null) {
|
|
270
|
+
dropShadowConfig.alpha = processed.dropShadowAlpha;
|
|
271
|
+
}
|
|
272
|
+
if (processed.dropShadowBlur != null) {
|
|
273
|
+
dropShadowConfig.blur = processed.dropShadowBlur;
|
|
274
|
+
}
|
|
275
|
+
processed.dropShadow = dropShadowConfig;
|
|
276
|
+
delete processed.dropShadowColor;
|
|
277
|
+
delete processed.dropShadowDistance;
|
|
278
|
+
delete processed.dropShadowAngle;
|
|
279
|
+
delete processed.dropShadowAlpha;
|
|
280
|
+
delete processed.dropShadowBlur;
|
|
281
|
+
}
|
|
282
|
+
if (Array.isArray(processed.fill)) {
|
|
283
|
+
processed.fill = processed.fill[0];
|
|
284
|
+
}
|
|
285
|
+
if (Array.isArray(processed.fillGradientStops)) {
|
|
286
|
+
let fontSize;
|
|
287
|
+
if (processed.fontSize == null) {
|
|
288
|
+
fontSize = pixi_js.TextStyle.defaultTextStyle.fontSize;
|
|
289
|
+
} else if (typeof processed.fontSize === 'string') {
|
|
290
|
+
fontSize = parseInt(processed.fontSize, 10);
|
|
291
|
+
} else {
|
|
292
|
+
fontSize = processed.fontSize;
|
|
293
|
+
}
|
|
294
|
+
const gradientFill = new pixi_js.FillGradient(0, 0, 0, fontSize * 1.7);
|
|
295
|
+
const fills = processed.fillGradientStops.map(color => pixi_js.Color.shared.setValue(color).toNumber());
|
|
296
|
+
fills.forEach((number, index) => {
|
|
297
|
+
const ratio = index / (fills.length - 1);
|
|
298
|
+
gradientFill.addColorStop(ratio, number);
|
|
299
|
+
});
|
|
300
|
+
processed.fill = {
|
|
301
|
+
fill: gradientFill
|
|
302
|
+
};
|
|
303
|
+
delete processed.fillGradientStops;
|
|
304
|
+
}
|
|
305
|
+
return processed;
|
|
306
|
+
}
|
|
118
307
|
change(changed) {
|
|
119
308
|
const {
|
|
120
309
|
text,
|
|
121
310
|
component
|
|
122
311
|
} = this.texts[changed.gameObject.id];
|
|
312
|
+
const isHTMLText = changed.componentName === 'HTMLText';
|
|
123
313
|
if (changed.prop.prop[0] === 'text') {
|
|
124
314
|
text.text = component.text;
|
|
125
315
|
} else if (changed.prop.prop[0] === 'style') {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
} else {
|
|
144
|
-
eva_js.resource.getResource(fontFamily).finally(() => {
|
|
145
|
-
text.style.fontFamily = fontFamily;
|
|
146
|
-
});
|
|
147
|
-
}
|
|
316
|
+
const processedStyle = this.processStyle(component.style);
|
|
317
|
+
_extends(text.style, processedStyle);
|
|
318
|
+
} else if (changed.prop.prop[0] === 'textureStyle' && isHTMLText) {
|
|
319
|
+
const htmlComponent = component;
|
|
320
|
+
const container = this.containerManager.getContainer(changed.gameObject.id);
|
|
321
|
+
const index = container.getChildIndex(text);
|
|
322
|
+
container.removeChild(text);
|
|
323
|
+
text.destroy({
|
|
324
|
+
children: true
|
|
325
|
+
});
|
|
326
|
+
const newText = new rendererAdapter.HTMLText({
|
|
327
|
+
text: htmlComponent.text,
|
|
328
|
+
style: htmlComponent.style,
|
|
329
|
+
textureStyle: htmlComponent.textureStyle
|
|
330
|
+
});
|
|
331
|
+
container.addChildAt(newText, index);
|
|
332
|
+
this.texts[changed.gameObject.id].text = newText;
|
|
148
333
|
}
|
|
149
334
|
}
|
|
150
335
|
setSize(changed) {
|
|
@@ -152,8 +337,12 @@ var _EVA_IIFE_text = function (exports, pixi_js, eva_js, pluginRenderer, rendere
|
|
|
152
337
|
transform
|
|
153
338
|
} = changed.gameObject;
|
|
154
339
|
if (!transform) return;
|
|
155
|
-
|
|
156
|
-
|
|
340
|
+
const {
|
|
341
|
+
text
|
|
342
|
+
} = this.texts[changed.gameObject.id];
|
|
343
|
+
const size = text.getSize();
|
|
344
|
+
transform.size.width = size.width;
|
|
345
|
+
transform.size.height = size.height;
|
|
157
346
|
}
|
|
158
347
|
};
|
|
159
348
|
Text.systemName = 'Text';
|
|
@@ -161,14 +350,27 @@ var _EVA_IIFE_text = function (exports, pixi_js, eva_js, pluginRenderer, rendere
|
|
|
161
350
|
Text: ['text', {
|
|
162
351
|
prop: ['style'],
|
|
163
352
|
deep: true
|
|
353
|
+
}],
|
|
354
|
+
HTMLText: ['text', {
|
|
355
|
+
prop: ['style'],
|
|
356
|
+
deep: true
|
|
357
|
+
}, {
|
|
358
|
+
prop: ['textureStyle'],
|
|
359
|
+
deep: true
|
|
360
|
+
}],
|
|
361
|
+
BitmapText: ['text', {
|
|
362
|
+
prop: ['style'],
|
|
363
|
+
deep: true
|
|
164
364
|
}]
|
|
165
365
|
})], Text);
|
|
166
366
|
var Text$1 = Text;
|
|
367
|
+
exports.BitmapText = BitmapText;
|
|
368
|
+
exports.HTMLText = HTMLText;
|
|
167
369
|
exports.Text = Text$2;
|
|
168
370
|
exports.TextSystem = Text$1;
|
|
169
371
|
Object.defineProperty(exports, '__esModule', {
|
|
170
372
|
value: true
|
|
171
373
|
});
|
|
172
374
|
return exports;
|
|
173
|
-
}({},
|
|
375
|
+
}({}, EVA, PIXI, EVA.plugin.renderer, EVA.rendererAdapter);
|
|
174
376
|
globalThis.EVA.plugin.renderer.text = globalThis.EVA.plugin.renderer.text || _EVA_IIFE_text;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function _extends(){return _extends=Object.assign?Object.assign.bind():function(
|
|
1
|
+
function _extends(){return _extends=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)({}).hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},_extends.apply(null,arguments)}globalThis.EVA=globalThis.EVA||{},globalThis.EVA.plugin=globalThis.EVA.plugin||{},globalThis.EVA.plugin.renderer=globalThis.EVA.plugin.renderer||{};var _EVA_IIFE_text=function(t,e,n,o,i){"use strict";function r(t,e,n,o){var i,r=arguments.length,s=r<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,o);else for(var l=t.length-1;l>=0;l--)(i=t[l])&&(s=(r<3?i(s):r>3?i(e,n,s):i(e,n))||s);return r>3&&s&&Object.defineProperty(e,n,s),s}function s(t,e,n,o){return new(n||(n=Promise))((function(i,r){function s(t){try{d(o.next(t))}catch(t){r(t)}}function l(t){try{d(o.throw(t))}catch(t){r(t)}}function d(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,l)}d((o=o.apply(t,e||[])).next())}))}function l(t){return function(e,n){var o=function(t,e){return t.constructor.IDEProps||(t.constructor.IDEProps={}),t.constructor.IDEProps[e]||(t.constructor.IDEProps[e]={}),t.constructor.IDEProps[e]}(e,n);o.key=n,o.type=t}}class d extends e.Component{constructor(){super(...arguments),this.text="",this.style={}}init(t){this.style=_extends({fontSize:24,fill:"#000000",fontFamily:"Arial"},null==t?void 0:t.style),t&&(this.text=t.text)}}d.componentName="BitmapText",r([l("string")],d.prototype,"text",void 0);class a extends e.Component{constructor(){super(...arguments),this.text="",this.style={}}init(t){const e=new n.TextStyle({fontSize:20}),o={};for(const t in e)0===t.indexOf("_")&&(o[t.substring(1)]=e[t]);delete o.styleKey,this.style=o,t&&(this.text=t.text,_extends(this.style,t.style))}}a.componentName="Text",r([l("string")],a.prototype,"text",void 0);class c extends e.Component{constructor(){super(...arguments),this.text="",this.style={},this.textureStyle={}}init(t){this.style=_extends({fontSize:24,fill:"#000000",fontFamily:"Arial"},null==t?void 0:t.style),this.textureStyle=_extends({scaleMode:"linear",resolution:window.devicePixelRatio||1},null==t?void 0:t.textureStyle),t&&(this.text=t.text)}}c.componentName="HTMLText",r([l("string")],c.prototype,"text",void 0);let p=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 s(this,void 0,void 0,(function*(){const n="Text"===t.componentName,o="HTMLText"===t.componentName,i="BitmapText"===t.componentName;if(n||o||i)if(t.type===e.OBSERVER_TYPE.ADD)n?yield this.addTextComponent(t):o?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:n}=this.texts[t.gameObject.id];yield this.waitForFontResource(n,t,e.style.fontFamily)}this.setSize(t)}}))}addTextComponent(t){return s(this,void 0,void 0,(function*(){const e=t.component,n=_extends({},e.style),o=n.fontFamily;delete n.fontFamily;const r=o?"":e.text,s=new i.Text(r,n);this.containerManager.getContainer(t.gameObject.id).addChildAt(s,0),this.texts[t.gameObject.id]={text:s,component:e},o&&(yield this.waitForFontResource(s,t,o))}))}addHTMLTextComponent(t){return s(this,void 0,void 0,(function*(){const e=t.component,n=_extends({},e.style),o=n.fontFamily;delete n.fontFamily;const r=o?"":e.text,s=new i.HTMLText(_extends({text:r,style:n},e.textureStyle&&{textureStyle:e.textureStyle}));this.containerManager.getContainer(t.gameObject.id).addChildAt(s,0),this.texts[t.gameObject.id]={text:s,component:e},o&&(yield this.waitForFontResource(s,t,o))}))}addBitmapTextComponent(t){return s(this,void 0,void 0,(function*(){const e=t.component,n=_extends({},e.style),o=n.fontFamily;delete n.fontFamily;const r=o?"":e.text,s=new i.BitmapText(r,n);this.containerManager.getContainer(t.gameObject.id).addChildAt(s,0),this.texts[t.gameObject.id]={text:s,component:e},o&&(yield this.waitForFontResource(s,t,o))}))}waitForFontResource(t,n,o){return s(this,void 0,void 0,(function*(){if(o)try{const i=Array.isArray(o)?o[0]:o,r=this.increaseAsyncId(n.gameObject.id);if(yield e.resource.getResource(i),!this.validateAsyncId(n.gameObject.id,r))return;const s=this.texts[n.gameObject.id].component;t.style.fontFamily=o,t.text=s.text}catch(t){console.warn(`字体资源 ${o} 加载失败:`,t)}}))}processStyle(t){const e=_extends({},t);if(e.strokeThickness){const t=e.stroke;e.stroke={color:t,width:e.strokeThickness},delete e.strokeThickness}if(e.dropShadow){const t={};null!=e.dropShadowColor&&(t.color=e.dropShadowColor),null!=e.dropShadowDistance&&(t.distance=e.dropShadowDistance),null!=e.dropShadowAngle&&(t.angle=e.dropShadowAngle),null!=e.dropShadowAlpha&&(t.alpha=e.dropShadowAlpha),null!=e.dropShadowBlur&&(t.blur=e.dropShadowBlur),e.dropShadow=t,delete e.dropShadowColor,delete e.dropShadowDistance,delete e.dropShadowAngle,delete e.dropShadowAlpha,delete e.dropShadowBlur}if(Array.isArray(e.fill)&&(e.fill=e.fill[0]),Array.isArray(e.fillGradientStops)){let t;t=null==e.fontSize?n.TextStyle.defaultTextStyle.fontSize:"string"==typeof e.fontSize?parseInt(e.fontSize,10):e.fontSize;const o=new n.FillGradient(0,0,0,1.7*t),i=e.fillGradientStops.map((t=>n.Color.shared.setValue(t).toNumber()));i.forEach(((t,e)=>{const n=e/(i.length-1);o.addColorStop(n,t)})),e.fill={fill:o},delete e.fillGradientStops}return e}change(t){const{text:e,component:n}=this.texts[t.gameObject.id],o="HTMLText"===t.componentName;if("text"===t.prop.prop[0])e.text=n.text;else if("style"===t.prop.prop[0]){const t=this.processStyle(n.style);_extends(e.style,t)}else if("textureStyle"===t.prop.prop[0]&&o){const o=n,r=this.containerManager.getContainer(t.gameObject.id),s=r.getChildIndex(e);r.removeChild(e),e.destroy({children:!0});const l=new i.HTMLText({text:o.text,style:o.style,textureStyle:o.textureStyle});r.addChildAt(l,s),this.texts[t.gameObject.id].text=l}}setSize(t){const{transform:e}=t.gameObject;if(!e)return;const{text:n}=this.texts[t.gameObject.id],o=n.getSize();e.size.width=o.width,e.size.height=o.height}};p.systemName="Text",p=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}]})],p);var h=p;return t.BitmapText=d,t.HTMLText=c,t.Text=a,t.TextSystem=h,Object.defineProperty(t,"__esModule",{value:!0}),t}({},EVA,PIXI,EVA.plugin.renderer,EVA.rendererAdapter);globalThis.EVA.plugin.renderer.text=globalThis.EVA.plugin.renderer.text||_EVA_IIFE_text;
|