@eva/plugin-renderer-text 2.1.0-beta.14 → 2.1.0-beta.15
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 +306 -121
- package/dist/EVA.plugin.renderer.text.min.js +1 -1
- package/dist/plugin-renderer-text.cjs.js +364 -133
- package/dist/plugin-renderer-text.cjs.prod.js +1 -1
- package/dist/plugin-renderer-text.d.ts +17 -0
- package/dist/plugin-renderer-text.esm.js +366 -135
- package/package.json +5 -5
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
|
+
var globalThis = typeof self !== 'undefined' ? self : typeof window !== 'undefined' ? window : Function('return this')();
|
|
2
3
|
globalThis.EVA = globalThis.EVA || {};
|
|
3
4
|
globalThis.EVA.plugin = globalThis.EVA.plugin || {};
|
|
4
5
|
globalThis.EVA.plugin.renderer = globalThis.EVA.plugin.renderer || {};
|
|
5
6
|
var _EVA_IIFE_text = function (exports, eva_js, pixi_js, pluginRenderer, rendererAdapter) {
|
|
6
7
|
'use strict';
|
|
8
|
+
function __rest(s, e) {
|
|
9
|
+
var t = {};
|
|
10
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
11
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
12
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
13
|
+
}
|
|
14
|
+
return t;
|
|
15
|
+
}
|
|
7
16
|
function __decorate(decorators, target, key, desc) {
|
|
8
17
|
var c = arguments.length,
|
|
9
18
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
@@ -41,10 +50,6 @@ var _EVA_IIFE_text = function (exports, eva_js, pixi_js, pluginRenderer, rendere
|
|
|
41
50
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
51
|
});
|
|
43
52
|
}
|
|
44
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
45
|
-
var e = new Error(message);
|
|
46
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
47
|
-
};
|
|
48
53
|
class BitmapTextStyleMetadata {}
|
|
49
54
|
__decorate([eva_js.type('string'), __metadata("design:type", Object)], BitmapTextStyleMetadata.prototype, "fontFamily", void 0);
|
|
50
55
|
__decorate([eva_js.type('number'), __metadata("design:type", Object)], BitmapTextStyleMetadata.prototype, "fontSize", void 0);
|
|
@@ -226,144 +231,263 @@ var _EVA_IIFE_text = function (exports, eva_js, pixi_js, pluginRenderer, rendere
|
|
|
226
231
|
constructor() {
|
|
227
232
|
super(...arguments);
|
|
228
233
|
this.name = 'Text';
|
|
234
|
+
this.presentationAddFlushEnabled = true;
|
|
229
235
|
this.texts = {};
|
|
236
|
+
this.retired = false;
|
|
237
|
+
this.pendingHTMLTextComponents = {};
|
|
238
|
+
this.fontIdentityIds = new WeakMap();
|
|
239
|
+
this.nextFontIdentityId = 1;
|
|
230
240
|
}
|
|
231
241
|
init() {
|
|
232
242
|
this.renderSystem = this.game.getSystem(pluginRenderer.RendererSystem);
|
|
233
243
|
this.renderSystem.rendererManager.register(this);
|
|
234
244
|
}
|
|
245
|
+
shouldFlushPresentationAddition(changed) {
|
|
246
|
+
return changed.componentName === 'Text' || changed.componentName === 'HTMLText' || changed.componentName === 'BitmapText';
|
|
247
|
+
}
|
|
235
248
|
componentChanged(changed) {
|
|
249
|
+
var _a, _b, _c, _d, _e;
|
|
236
250
|
return __awaiter(this, void 0, void 0, function* () {
|
|
251
|
+
if (this.retired) return;
|
|
237
252
|
const isText = changed.componentName === 'Text';
|
|
238
253
|
const isHTMLText = changed.componentName === 'HTMLText';
|
|
239
254
|
const isBitmapText = changed.componentName === 'BitmapText';
|
|
240
255
|
if (!isText && !isHTMLText && !isBitmapText) return;
|
|
256
|
+
const gameObjectId = changed.gameObject.id;
|
|
241
257
|
if (changed.type === eva_js.OBSERVER_TYPE.ADD) {
|
|
242
258
|
if (isText) {
|
|
243
|
-
|
|
259
|
+
const loading = this.addTextComponent(changed);
|
|
260
|
+
if (loading) yield loading;
|
|
244
261
|
} else if (isHTMLText) {
|
|
245
|
-
|
|
262
|
+
const loading = this.addHTMLTextComponent(changed);
|
|
263
|
+
if (loading) yield loading;
|
|
246
264
|
} else {
|
|
247
|
-
|
|
265
|
+
const loading = this.addBitmapTextComponent(changed);
|
|
266
|
+
if (loading) yield loading;
|
|
267
|
+
}
|
|
268
|
+
if (((_a = this.texts[gameObjectId]) === null || _a === void 0 ? void 0 : _a.component) === changed.component) {
|
|
269
|
+
this.setSize(changed);
|
|
248
270
|
}
|
|
249
|
-
this.setSize(changed);
|
|
250
271
|
} else if (changed.type === eva_js.OBSERVER_TYPE.REMOVE) {
|
|
251
|
-
|
|
252
|
-
this.
|
|
272
|
+
if (((_b = this.texts[gameObjectId]) === null || _b === void 0 ? void 0 : _b.component) !== changed.component && this.pendingHTMLTextComponents[gameObjectId] !== changed.component) return;
|
|
273
|
+
this.increaseAsyncId(gameObjectId);
|
|
274
|
+
if (this.pendingHTMLTextComponents[gameObjectId] === changed.component) {
|
|
275
|
+
delete this.pendingHTMLTextComponents[gameObjectId];
|
|
276
|
+
}
|
|
277
|
+
const current = this.texts[gameObjectId];
|
|
278
|
+
if (!current || current.component !== changed.component) return;
|
|
279
|
+
this.containerManager.getContainer(gameObjectId).removeChild(current.text);
|
|
280
|
+
current.text.destroy({
|
|
253
281
|
children: true
|
|
254
282
|
});
|
|
255
|
-
delete this.texts[
|
|
283
|
+
delete this.texts[gameObjectId];
|
|
256
284
|
} else {
|
|
257
|
-
this.change(changed);
|
|
258
285
|
const component = changed.component;
|
|
259
286
|
const propPath = changed.prop.prop;
|
|
260
287
|
const fontFamilyChanged = propPath[0] === 'style' && (propPath.length === 1 || propPath[1] === 'fontFamily');
|
|
261
|
-
|
|
288
|
+
const current = this.texts[gameObjectId];
|
|
289
|
+
if (!current) {
|
|
290
|
+
if (isHTMLText && this.pendingHTMLTextComponents[gameObjectId] === component && fontFamilyChanged) {
|
|
291
|
+
yield this.addHTMLTextComponent(changed);
|
|
292
|
+
if (((_c = this.texts[gameObjectId]) === null || _c === void 0 ? void 0 : _c.component) === component) {
|
|
293
|
+
this.setSize(changed);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
if (current.component !== component) return;
|
|
299
|
+
const waitsForFontResource = fontFamilyChanged && component.style && this.needsFontLoad(component.style.fontFamily);
|
|
300
|
+
if (fontFamilyChanged && !waitsForFontResource) {
|
|
301
|
+
this.increaseAsyncId(gameObjectId);
|
|
302
|
+
}
|
|
303
|
+
this.change(changed);
|
|
304
|
+
if (waitsForFontResource) {
|
|
262
305
|
const {
|
|
263
306
|
text
|
|
264
|
-
} =
|
|
307
|
+
} = current;
|
|
265
308
|
yield this.waitForFontResource(text, changed, component.style.fontFamily);
|
|
266
309
|
}
|
|
267
|
-
this.
|
|
310
|
+
if (((_d = this.texts[gameObjectId]) === null || _d === void 0 ? void 0 : _d.text) === current.text && ((_e = this.texts[gameObjectId]) === null || _e === void 0 ? void 0 : _e.component) === component) {
|
|
311
|
+
this.setSize(changed);
|
|
312
|
+
}
|
|
268
313
|
}
|
|
269
314
|
});
|
|
270
315
|
}
|
|
271
316
|
addTextComponent(changed) {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
});
|
|
317
|
+
const component = changed.component;
|
|
318
|
+
const styleWithoutFont = this.processStyle(component.style);
|
|
319
|
+
const fontFamily = styleWithoutFont.fontFamily;
|
|
320
|
+
const waitsForFontResource = this.needsFontLoad(fontFamily);
|
|
321
|
+
if (waitsForFontResource) delete styleWithoutFont.fontFamily;
|
|
322
|
+
const initialText = waitsForFontResource ? '' : component.text;
|
|
323
|
+
const text = new rendererAdapter.Text(initialText, styleWithoutFont);
|
|
324
|
+
this.containerManager.getContainer(changed.gameObject.id).addChildAt(text, 0);
|
|
325
|
+
this.texts[changed.gameObject.id] = {
|
|
326
|
+
text,
|
|
327
|
+
component,
|
|
328
|
+
awaitingInitialFont: waitsForFontResource
|
|
329
|
+
};
|
|
330
|
+
if (waitsForFontResource) {
|
|
331
|
+
return this.waitForFontResource(text, changed, fontFamily);
|
|
332
|
+
}
|
|
289
333
|
}
|
|
290
334
|
addHTMLTextComponent(changed) {
|
|
335
|
+
const component = changed.component;
|
|
336
|
+
const gameObjectId = changed.gameObject.id;
|
|
337
|
+
const initialStyle = this.processStyle(component.style);
|
|
338
|
+
const fontFamily = initialStyle.fontFamily;
|
|
339
|
+
const waitsForFontResource = this.needsFontLoad(fontFamily);
|
|
340
|
+
if (waitsForFontResource) {
|
|
341
|
+
this.pendingHTMLTextComponents[gameObjectId] = component;
|
|
342
|
+
return this.addHTMLTextAfterFont(changed, component, fontFamily, this.increaseAsyncId(gameObjectId));
|
|
343
|
+
} else if (this.pendingHTMLTextComponents[gameObjectId] === component) {
|
|
344
|
+
delete this.pendingHTMLTextComponents[gameObjectId];
|
|
345
|
+
}
|
|
346
|
+
this.mountHTMLText(changed, component);
|
|
347
|
+
}
|
|
348
|
+
addHTMLTextAfterFont(changed, component, fontFamily, asyncId) {
|
|
349
|
+
var _a;
|
|
291
350
|
return __awaiter(this, void 0, void 0, function* () {
|
|
292
|
-
const
|
|
293
|
-
const
|
|
294
|
-
const
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
const initialText = waitsForFontResource ? '' : component.text;
|
|
298
|
-
const htmlText = new rendererAdapter.HTMLText(_extends({
|
|
299
|
-
text: initialText,
|
|
300
|
-
style: styleWithoutFont
|
|
301
|
-
}, component.textureStyle && {
|
|
302
|
-
textureStyle: component.textureStyle
|
|
303
|
-
}));
|
|
304
|
-
this.containerManager.getContainer(changed.gameObject.id).addChildAt(htmlText, 0);
|
|
305
|
-
this.texts[changed.gameObject.id] = {
|
|
306
|
-
text: htmlText,
|
|
307
|
-
component
|
|
308
|
-
};
|
|
309
|
-
if (waitsForFontResource) {
|
|
310
|
-
yield this.waitForFontResource(htmlText, changed, fontFamily);
|
|
311
|
-
}
|
|
351
|
+
const gameObjectId = changed.gameObject.id;
|
|
352
|
+
const fontName = this.getFontName(fontFamily);
|
|
353
|
+
const loaded = yield this.loadFontResource(fontFamily);
|
|
354
|
+
if (!loaded || this.retired || changed.gameObject.destroyed || !this.validateAsyncId(gameObjectId, asyncId) || this.pendingHTMLTextComponents[gameObjectId] !== component || this.getFontName((_a = component.style) === null || _a === void 0 ? void 0 : _a.fontFamily) !== fontName) return;
|
|
355
|
+
this.mountHTMLText(changed, component);
|
|
312
356
|
});
|
|
313
357
|
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
this.containerManager.getContainer(changed.gameObject.id).addChildAt(bitmapText, 0);
|
|
324
|
-
this.texts[changed.gameObject.id] = {
|
|
325
|
-
text: bitmapText,
|
|
326
|
-
component
|
|
327
|
-
};
|
|
328
|
-
if (waitsForFontResource) {
|
|
329
|
-
yield this.waitForFontResource(bitmapText, changed, fontFamily);
|
|
330
|
-
}
|
|
358
|
+
mountHTMLText(changed, component) {
|
|
359
|
+
const gameObjectId = changed.gameObject.id;
|
|
360
|
+
const style = this.processStyle(component.style);
|
|
361
|
+
const _a = component.textureStyle || {},
|
|
362
|
+
sampling = __rest(_a, ["resolution"]);
|
|
363
|
+
const htmlText = new rendererAdapter.HTMLText({
|
|
364
|
+
text: component.text,
|
|
365
|
+
style,
|
|
366
|
+
textureStyle: _extends({}, sampling)
|
|
331
367
|
});
|
|
368
|
+
htmlText.rasterCacheFontIdentity = families => this.getHTMLRasterFontIdentity(families);
|
|
369
|
+
this.applyHTMLResolution(htmlText, component, changed);
|
|
370
|
+
this.containerManager.getContainer(gameObjectId).addChildAt(htmlText, 0);
|
|
371
|
+
this.texts[gameObjectId] = {
|
|
372
|
+
text: htmlText,
|
|
373
|
+
component
|
|
374
|
+
};
|
|
375
|
+
delete this.pendingHTMLTextComponents[gameObjectId];
|
|
376
|
+
}
|
|
377
|
+
getHTMLRasterFontIdentity(families) {
|
|
378
|
+
var _a;
|
|
379
|
+
const uniqueFamilies = [...new Set(families.filter(family => typeof family === 'string').map(family => family.replace(/["']/g, '').trim()).filter(Boolean))];
|
|
380
|
+
if (!uniqueFamilies.length) return 'external:<default>';
|
|
381
|
+
const describe = face => [this.objectIdentity(face), face.family, face.style, face.weight, face.stretch, face.unicodeRange, face.variant, face.featureSettings, face.display].map(value => String(value !== null && value !== void 0 ? value : '')).join(':');
|
|
382
|
+
const identities = [];
|
|
383
|
+
for (const family of uniqueFamilies) {
|
|
384
|
+
const current = eva_js.resource.resourcesMap[family];
|
|
385
|
+
if (!current || current.type !== eva_js.RESOURCE_TYPE.FONT) {
|
|
386
|
+
identities.push(`external:${family}`);
|
|
387
|
+
continue;
|
|
388
|
+
}
|
|
389
|
+
if (current.complete !== true) return null;
|
|
390
|
+
const rawFaces = (_a = current.data) === null || _a === void 0 ? void 0 : _a.font;
|
|
391
|
+
const faces = Array.isArray(rawFaces) ? rawFaces : [rawFaces];
|
|
392
|
+
if (!faces.length || faces.some(face => !face || typeof face !== 'object' || face.status !== 'loaded')) return null;
|
|
393
|
+
identities.push(`${family}|resource:${this.objectIdentity(current)}|faces:${faces.map(describe).join(',')}`);
|
|
394
|
+
}
|
|
395
|
+
return identities.join(';');
|
|
396
|
+
}
|
|
397
|
+
objectIdentity(value) {
|
|
398
|
+
let id = this.fontIdentityIds.get(value);
|
|
399
|
+
if (!id) {
|
|
400
|
+
id = this.nextFontIdentityId++;
|
|
401
|
+
this.fontIdentityIds.set(value, id);
|
|
402
|
+
}
|
|
403
|
+
return id;
|
|
404
|
+
}
|
|
405
|
+
addBitmapTextComponent(changed) {
|
|
406
|
+
const component = changed.component;
|
|
407
|
+
const styleWithoutFont = this.processStyle(component.style);
|
|
408
|
+
const fontFamily = styleWithoutFont.fontFamily;
|
|
409
|
+
const waitsForFontResource = this.needsFontLoad(fontFamily);
|
|
410
|
+
if (waitsForFontResource) delete styleWithoutFont.fontFamily;
|
|
411
|
+
const initialText = waitsForFontResource ? '' : component.text;
|
|
412
|
+
const bitmapText = new rendererAdapter.BitmapText(initialText, styleWithoutFont);
|
|
413
|
+
this.containerManager.getContainer(changed.gameObject.id).addChildAt(bitmapText, 0);
|
|
414
|
+
this.texts[changed.gameObject.id] = {
|
|
415
|
+
text: bitmapText,
|
|
416
|
+
component,
|
|
417
|
+
awaitingInitialFont: waitsForFontResource
|
|
418
|
+
};
|
|
419
|
+
if (waitsForFontResource) {
|
|
420
|
+
return this.waitForFontResource(bitmapText, changed, fontFamily);
|
|
421
|
+
}
|
|
332
422
|
}
|
|
333
423
|
hasRegisteredFont(fontFamily) {
|
|
334
424
|
var _a;
|
|
335
425
|
if (!fontFamily) return false;
|
|
336
|
-
const fontName =
|
|
426
|
+
const fontName = this.getFontName(fontFamily);
|
|
337
427
|
return ((_a = eva_js.resource.resourcesMap[fontName]) === null || _a === void 0 ? void 0 : _a.type) === eva_js.RESOURCE_TYPE.FONT;
|
|
338
428
|
}
|
|
429
|
+
needsFontLoad(fontFamily) {
|
|
430
|
+
if (!this.hasRegisteredFont(fontFamily)) return false;
|
|
431
|
+
return eva_js.resource.resourcesMap[this.getFontName(fontFamily)].complete !== true;
|
|
432
|
+
}
|
|
433
|
+
getFontName(fontFamily) {
|
|
434
|
+
if (!fontFamily) return undefined;
|
|
435
|
+
return Array.isArray(fontFamily) ? fontFamily[0] : fontFamily;
|
|
436
|
+
}
|
|
437
|
+
loadFontResource(fontFamily) {
|
|
438
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
439
|
+
const fontName = this.getFontName(fontFamily);
|
|
440
|
+
if (!fontName || !this.hasRegisteredFont(fontFamily)) return false;
|
|
441
|
+
const expectedResource = eva_js.resource.resourcesMap[fontName];
|
|
442
|
+
try {
|
|
443
|
+
const loaded = yield eva_js.resource.getResource(fontName);
|
|
444
|
+
return loaded === expectedResource && loaded.complete === true && eva_js.resource.resourcesMap[fontName] === expectedResource;
|
|
445
|
+
} catch (error) {
|
|
446
|
+
console.warn(`字体资源 ${fontFamily} 加载失败:`, error);
|
|
447
|
+
return false;
|
|
448
|
+
}
|
|
449
|
+
});
|
|
450
|
+
}
|
|
339
451
|
waitForFontResource(text, changed, fontFamily) {
|
|
452
|
+
var _a;
|
|
340
453
|
return __awaiter(this, void 0, void 0, function* () {
|
|
341
454
|
if (!fontFamily) {
|
|
342
455
|
return;
|
|
343
456
|
}
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
text.text = component.text;
|
|
353
|
-
} catch (error) {
|
|
354
|
-
console.warn(`字体资源 ${fontFamily} 加载失败:`, error);
|
|
457
|
+
const gameObjectId = changed.gameObject.id;
|
|
458
|
+
const fontName = this.getFontName(fontFamily);
|
|
459
|
+
if (!fontName || !this.hasRegisteredFont(fontFamily)) return;
|
|
460
|
+
const asyncId = this.increaseAsyncId(gameObjectId);
|
|
461
|
+
const loaded = yield this.loadFontResource(fontFamily);
|
|
462
|
+
const current = this.texts[gameObjectId];
|
|
463
|
+
if (!loaded || this.retired || changed.gameObject.destroyed || !this.validateAsyncId(gameObjectId, asyncId) || !current || current.text !== text || current.component !== changed.component) {
|
|
464
|
+
return;
|
|
355
465
|
}
|
|
466
|
+
const currentFontFamily = (_a = current.component.style) === null || _a === void 0 ? void 0 : _a.fontFamily;
|
|
467
|
+
if (this.getFontName(currentFontFamily) !== fontName) return;
|
|
468
|
+
text.style.fontFamily = currentFontFamily;
|
|
469
|
+
current.awaitingInitialFont = false;
|
|
470
|
+
text.text = current.component.text;
|
|
356
471
|
});
|
|
357
472
|
}
|
|
358
473
|
processStyle(style) {
|
|
359
|
-
const processed =
|
|
360
|
-
if (processed.strokeThickness) {
|
|
361
|
-
const
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
474
|
+
const processed = this.cloneStyleValue(style);
|
|
475
|
+
if (processed.strokeThickness != null || processed.lineJoin != null || processed.miterLimit != null) {
|
|
476
|
+
const stroke = processed.stroke;
|
|
477
|
+
const isOptions = stroke && typeof stroke === 'object' && ['color', 'width', 'fill', 'texture', 'join'].some(key => key in stroke);
|
|
478
|
+
const merged = isOptions ? _extends({}, stroke) : {
|
|
479
|
+
color: stroke !== null && stroke !== void 0 ? stroke : 0x000000
|
|
365
480
|
};
|
|
366
|
-
|
|
481
|
+
if (processed.strokeThickness != null) merged.width = processed.strokeThickness;
|
|
482
|
+
if (processed.lineJoin != null) merged.join = processed.lineJoin;
|
|
483
|
+
if (processed.miterLimit != null) merged.miterLimit = processed.miterLimit;
|
|
484
|
+
if (stroke != null || processed.strokeThickness != null) processed.stroke = merged;
|
|
485
|
+
}
|
|
486
|
+
delete processed.strokeThickness;
|
|
487
|
+
delete processed.lineJoin;
|
|
488
|
+
delete processed.miterLimit;
|
|
489
|
+
if (processed.dropShadow && typeof processed.dropShadow === 'object' && !Array.isArray(processed.dropShadow)) {
|
|
490
|
+
if (processed.dropShadow.enabled === false) processed.dropShadow = false;else delete processed.dropShadow.enabled;
|
|
367
491
|
}
|
|
368
492
|
const hasFlatDropShadowAlias = processed.dropShadowColor != null || processed.dropShadowDistance != null || processed.dropShadowAngle != null || processed.dropShadowAlpha != null || processed.dropShadowBlur != null;
|
|
369
493
|
if (processed.dropShadow && hasFlatDropShadowAlias) {
|
|
@@ -391,58 +515,119 @@ var _EVA_IIFE_text = function (exports, eva_js, pixi_js, pluginRenderer, rendere
|
|
|
391
515
|
delete processed.dropShadowAlpha;
|
|
392
516
|
delete processed.dropShadowBlur;
|
|
393
517
|
if (Array.isArray(processed.fill)) {
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
518
|
+
const colors = processed.fill;
|
|
519
|
+
if (colors.length > 1) {
|
|
520
|
+
const supplied = processed.fillGradientStops;
|
|
521
|
+
const stops = Array.isArray(supplied) && supplied.length === colors.length ? supplied : colors.map((_, index) => index / (colors.length - 1));
|
|
522
|
+
const horizontal = processed.fillGradientType === 1;
|
|
523
|
+
const gradient = new pixi_js.FillGradient({
|
|
524
|
+
start: {
|
|
525
|
+
x: 0,
|
|
526
|
+
y: 0
|
|
527
|
+
},
|
|
528
|
+
end: horizontal ? {
|
|
529
|
+
x: 1,
|
|
530
|
+
y: 0
|
|
531
|
+
} : {
|
|
532
|
+
x: 0,
|
|
533
|
+
y: 1
|
|
534
|
+
},
|
|
535
|
+
textureSpace: 'local'
|
|
536
|
+
});
|
|
537
|
+
colors.forEach((color, index) => {
|
|
538
|
+
gradient.addColorStop(stops[index], pixi_js.Color.shared.setValue(color).toNumber());
|
|
539
|
+
});
|
|
540
|
+
processed.fill = {
|
|
541
|
+
fill: gradient
|
|
542
|
+
};
|
|
402
543
|
} else {
|
|
403
|
-
|
|
544
|
+
processed.fill = colors[0];
|
|
404
545
|
}
|
|
405
|
-
const gradientFill = new pixi_js.FillGradient(0, 0, 0, fontSize * 1.7);
|
|
406
|
-
const fills = processed.fillGradientStops.map(color => pixi_js.Color.shared.setValue(color).toNumber());
|
|
407
|
-
fills.forEach((number, index) => {
|
|
408
|
-
const ratio = index / (fills.length - 1);
|
|
409
|
-
gradientFill.addColorStop(ratio, number);
|
|
410
|
-
});
|
|
411
|
-
processed.fill = {
|
|
412
|
-
fill: gradientFill
|
|
413
|
-
};
|
|
414
|
-
delete processed.fillGradientStops;
|
|
415
546
|
}
|
|
547
|
+
delete processed.fillGradientStops;
|
|
548
|
+
delete processed.fillGradientType;
|
|
416
549
|
return processed;
|
|
417
550
|
}
|
|
418
551
|
change(changed) {
|
|
552
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
553
|
+
const current = this.texts[changed.gameObject.id];
|
|
419
554
|
const {
|
|
420
555
|
text,
|
|
421
556
|
component
|
|
422
|
-
} =
|
|
557
|
+
} = current;
|
|
423
558
|
const isHTMLText = changed.componentName === 'HTMLText';
|
|
424
559
|
if (changed.prop.prop[0] === 'text') {
|
|
425
|
-
text.text = component.text;
|
|
560
|
+
if (!current.awaitingInitialFont) text.text = component.text;
|
|
426
561
|
} else if (changed.prop.prop[0] === 'style') {
|
|
427
562
|
const processedStyle = this.processStyle(component.style);
|
|
428
|
-
if (this.
|
|
563
|
+
if (this.needsFontLoad(processedStyle.fontFamily)) delete processedStyle.fontFamily;
|
|
429
564
|
_extends(text.style, processedStyle);
|
|
565
|
+
if (current.awaitingInitialFont && !this.needsFontLoad((_a = component.style) === null || _a === void 0 ? void 0 : _a.fontFamily)) {
|
|
566
|
+
current.awaitingInitialFont = false;
|
|
567
|
+
text.text = component.text;
|
|
568
|
+
}
|
|
430
569
|
} else if (changed.prop.prop[0] === 'textureStyle' && isHTMLText) {
|
|
431
570
|
const htmlComponent = component;
|
|
432
|
-
const
|
|
433
|
-
const
|
|
434
|
-
|
|
435
|
-
|
|
571
|
+
const htmlText = text;
|
|
572
|
+
const _j = htmlComponent.textureStyle || {},
|
|
573
|
+
sampling = __rest(_j, ["resolution"]);
|
|
574
|
+
if (htmlText.textureStyle) {
|
|
575
|
+
const options = _extends(_extends({}, (pixi_js.TextureStyle === null || pixi_js.TextureStyle === void 0 ? void 0 : pixi_js.TextureStyle.defaultOptions) || {
|
|
576
|
+
addressMode: 'clamp-to-edge',
|
|
577
|
+
scaleMode: 'linear'
|
|
578
|
+
}), sampling);
|
|
579
|
+
htmlText.textureStyle.addressMode = options.addressMode;
|
|
580
|
+
htmlText.textureStyle.scaleMode = options.scaleMode;
|
|
581
|
+
_extends(htmlText.textureStyle, {
|
|
582
|
+
addressModeU: (_b = options.addressModeU) !== null && _b !== void 0 ? _b : options.addressMode,
|
|
583
|
+
addressModeV: (_c = options.addressModeV) !== null && _c !== void 0 ? _c : options.addressMode,
|
|
584
|
+
addressModeW: (_d = options.addressModeW) !== null && _d !== void 0 ? _d : options.addressMode,
|
|
585
|
+
magFilter: (_e = options.magFilter) !== null && _e !== void 0 ? _e : options.scaleMode,
|
|
586
|
+
minFilter: (_f = options.minFilter) !== null && _f !== void 0 ? _f : options.scaleMode,
|
|
587
|
+
mipmapFilter: (_g = options.mipmapFilter) !== null && _g !== void 0 ? _g : options.scaleMode,
|
|
588
|
+
lodMinClamp: options.lodMinClamp,
|
|
589
|
+
lodMaxClamp: options.lodMaxClamp,
|
|
590
|
+
compare: options.compare,
|
|
591
|
+
maxAnisotropy: (_h = options.maxAnisotropy) !== null && _h !== void 0 ? _h : 1
|
|
592
|
+
});
|
|
593
|
+
htmlText.textureStyle.update();
|
|
594
|
+
} else {
|
|
595
|
+
htmlText.textureStyle = new pixi_js.TextureStyle(sampling);
|
|
596
|
+
}
|
|
597
|
+
this.applyHTMLResolution(htmlText, htmlComponent, changed);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
applyHTMLResolution(text, component, changed) {
|
|
601
|
+
var _a, _b, _c, _d;
|
|
602
|
+
const render = (_b = (_a = changed.gameObject).getComponent) === null || _b === void 0 ? void 0 : _b.call(_a, 'Render');
|
|
603
|
+
const resolution = (_c = render === null || render === void 0 ? void 0 : render.resolution) !== null && _c !== void 0 ? _c : (_d = component.textureStyle) === null || _d === void 0 ? void 0 : _d.resolution;
|
|
604
|
+
if (typeof resolution === 'number' && Number.isFinite(resolution) && resolution > 0 && text.resolution !== resolution) {
|
|
605
|
+
text.resolution = resolution;
|
|
606
|
+
} else if (resolution == null) {
|
|
607
|
+
text.resolution = null;
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
onDestroy() {
|
|
611
|
+
var _a, _b;
|
|
612
|
+
this.retired = true;
|
|
613
|
+
for (const id of Object.keys(this.asyncIdMap)) this.increaseAsyncId(Number(id));
|
|
614
|
+
this.pendingHTMLTextComponents = {};
|
|
615
|
+
for (const {
|
|
616
|
+
text
|
|
617
|
+
} of Object.values(this.texts)) {
|
|
618
|
+
(_a = text.parent) === null || _a === void 0 ? void 0 : _a.removeChild(text);
|
|
619
|
+
if (!text.destroyed) (_b = text.destroy) === null || _b === void 0 ? void 0 : _b.call(text, {
|
|
436
620
|
children: true
|
|
437
621
|
});
|
|
438
|
-
const newText = new rendererAdapter.HTMLText({
|
|
439
|
-
text: htmlComponent.text,
|
|
440
|
-
style: htmlComponent.style,
|
|
441
|
-
textureStyle: htmlComponent.textureStyle
|
|
442
|
-
});
|
|
443
|
-
container.addChildAt(newText, index);
|
|
444
|
-
this.texts[changed.gameObject.id].text = newText;
|
|
445
622
|
}
|
|
623
|
+
this.texts = {};
|
|
624
|
+
}
|
|
625
|
+
cloneStyleValue(value) {
|
|
626
|
+
if (Array.isArray(value)) return value.map(item => this.cloneStyleValue(item));
|
|
627
|
+
if (value && Object.getPrototypeOf(value) === Object.prototype) {
|
|
628
|
+
return Object.fromEntries(Object.entries(value).map(([key, child]) => [key, this.cloneStyleValue(child)]));
|
|
629
|
+
}
|
|
630
|
+
return value;
|
|
446
631
|
}
|
|
447
632
|
setSize(changed) {
|
|
448
633
|
const {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function _extends(){return _extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var i in o)({}).hasOwnProperty.call(o,i)&&(e[i]=o[i])}return e},_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(e,t,o,i,n){"use strict";function r(e,t,o,i){var n,r=arguments.length,p=r<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--)(n=e[d])&&(p=(r<3?n(p):r>3?n(t,o,p):n(t,o))||p);return r>3&&p&&Object.defineProperty(t,o,p),p}function p(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function d(e,t,o,i){return new(o||(o=Promise))(function(n,r){function p(e){try{s(i.next(e))}catch(e){r(e)}}function d(e){try{s(i.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?n(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 s{}r([t.type("string"),p("design:type",Object)],s.prototype,"fontFamily",void 0),r([t.type("number"),p("design:type",Object)],s.prototype,"fontSize",void 0),r([t.Field({type:"color"}),p("design:type",Object)],s.prototype,"fill",void 0),r([t.type("string"),p("design:type",String)],s.prototype,"align",void 0),r([t.type("number"),p("design:type",Number)],s.prototype,"letterSpacing",void 0),r([t.type("number"),p("design:type",Number)],s.prototype,"padding",void 0),r([t.Field({type:"color"}),p("design:type",Object)],s.prototype,"stroke",void 0),r([t.type("number"),p("design:type",Number)],s.prototype,"strokeThickness",void 0),r([t.type("string"),p("design:type",String)],s.prototype,"fontWeight",void 0),r([t.type("string"),p("design:type",String)],s.prototype,"fontStyle",void 0);class y extends t.Component{constructor(){super(...arguments),this.text="",this.style={}}init(e){this.style=_extends({fontSize:24,fill:"#000000",fontFamily:"Arial"},null==e?void 0:e.style),e&&(this.text=e.text)}}y.componentName="BitmapText",r([t.type("string"),p("design:type",String)],y.prototype,"text",void 0),r([t.Field(()=>s),p("design:type",Object)],y.prototype,"style",void 0);class l{}r([t.type("number"),p("design:type",Number)],l.prototype,"alpha",void 0),r([t.Field({type:"color"}),p("design:type",Object)],l.prototype,"color",void 0),r([t.type("string"),p("design:type",String)],l.prototype,"join",void 0),r([t.type("number"),p("design:type",Number)],l.prototype,"miterLimit",void 0),r([t.type("number"),p("design:type",Number)],l.prototype,"width",void 0);class a{}r([t.type("number"),p("design:type",Number)],a.prototype,"alpha",void 0),r([t.type("number"),p("design:type",Number)],a.prototype,"angle",void 0),r([t.type("number"),p("design:type",Number)],a.prototype,"blur",void 0),r([t.Field({type:"color"}),p("design:type",Object)],a.prototype,"color",void 0),r([t.type("number"),p("design:type",Number)],a.prototype,"distance",void 0),r([t.type("boolean"),p("design:type",Boolean)],a.prototype,"enabled",void 0);class g{}r([t.type("string"),p("design:type",String)],g.prototype,"align",void 0),r([t.type("boolean"),p("design:type",Boolean)],g.prototype,"breakWords",void 0),r([t.Field(()=>a),p("design:type",Object)],g.prototype,"dropShadow",void 0),r([t.type("number"),p("design:type",Number)],g.prototype,"dropShadowAlpha",void 0),r([t.type("number"),p("design:type",Number)],g.prototype,"dropShadowAngle",void 0),r([t.type("number"),p("design:type",Number)],g.prototype,"dropShadowBlur",void 0),r([t.Field({type:"color"}),p("design:type",Object)],g.prototype,"dropShadowColor",void 0),r([t.type("number"),p("design:type",Number)],g.prototype,"dropShadowDistance",void 0),r([t.Field({type:"color"}),p("design:type",Object)],g.prototype,"fill",void 0),r([t.type("number"),p("design:type",Number)],g.prototype,"fillGradientType",void 0),r([t.type("number"),p("design:type",Array)],g.prototype,"fillGradientStops",void 0),r([t.type("string"),p("design:type",Object)],g.prototype,"fontFamily",void 0),r([t.type("number"),p("design:type",Object)],g.prototype,"fontSize",void 0),r([t.type("string"),p("design:type",String)],g.prototype,"fontStyle",void 0),r([t.type("string"),p("design:type",String)],g.prototype,"fontVariant",void 0),r([t.type("string"),p("design:type",String)],g.prototype,"fontWeight",void 0),r([t.type("number"),p("design:type",Number)],g.prototype,"leading",void 0),r([t.type("number"),p("design:type",Number)],g.prototype,"letterSpacing",void 0),r([t.type("number"),p("design:type",Number)],g.prototype,"lineHeight",void 0),r([t.type("string"),p("design:type",String)],g.prototype,"lineJoin",void 0),r([t.type("number"),p("design:type",Number)],g.prototype,"miterLimit",void 0),r([t.type("number"),p("design:type",Number)],g.prototype,"padding",void 0),r([t.Field(()=>l),p("design:type",Object)],g.prototype,"stroke",void 0),r([t.type("number"),p("design:type",Number)],g.prototype,"strokeThickness",void 0),r([t.type("string"),p("design:type",String)],g.prototype,"textBaseline",void 0),r([t.type("string"),p("design:type",String)],g.prototype,"verticalAlign",void 0),r([t.type("boolean"),p("design:type",Boolean)],g.prototype,"trim",void 0),r([t.type("string"),p("design:type",String)],g.prototype,"whiteSpace",void 0),r([t.type("boolean"),p("design:type",Boolean)],g.prototype,"wordWrap",void 0),r([t.type("number"),p("design:type",Number)],g.prototype,"wordWrapWidth",void 0);class c extends t.Component{constructor(e){super(e),this.text="",this.style={},this.init(e)}init(e){const t=new o.TextStyle({fontSize:20}),i={};for(const e in t)0===e.indexOf("_")&&(i[e.substring(1)]=t[e]);delete i.styleKey,this.style=i,e&&(this.text=e.text,_extends(this.style,e.style))}}c.componentName="Text",r([t.type("string"),p("design:type",String)],c.prototype,"text",void 0),r([t.Field(()=>g),p("design:type",Object)],c.prototype,"style",void 0);class h{}r([t.type("string"),p("design:type",String)],h.prototype,"scaleMode",void 0),r([t.type("number"),p("design:type",Number)],h.prototype,"resolution",void 0);class u{}r([t.type("string"),p("design:type",Object)],u.prototype,"fontFamily",void 0),r([t.type("number"),p("design:type",Object)],u.prototype,"fontSize",void 0),r([t.type("string"),p("design:type",String)],u.prototype,"fontWeight",void 0),r([t.type("string"),p("design:type",String)],u.prototype,"fontStyle",void 0),r([t.type("string"),p("design:type",String)],u.prototype,"fontVariant",void 0),r([t.type("string"),p("design:type",String)],u.prototype,"align",void 0),r([t.type("string"),p("design:type",String)],u.prototype,"textBaseline",void 0),r([t.Field({type:"color"}),p("design:type",Object)],u.prototype,"fill",void 0),r([t.Field({type:"color"}),p("design:type",Object)],u.prototype,"stroke",void 0),r([t.type("number"),p("design:type",Number)],u.prototype,"strokeThickness",void 0),r([t.type("number"),p("design:type",Number)],u.prototype,"lineHeight",void 0),r([t.type("number"),p("design:type",Number)],u.prototype,"letterSpacing",void 0),r([t.type("number"),p("design:type",Number)],u.prototype,"padding",void 0),r([t.type("boolean"),p("design:type",Boolean)],u.prototype,"wordWrap",void 0),r([t.type("number"),p("design:type",Number)],u.prototype,"wordWrapWidth",void 0),r([t.type("boolean"),p("design:type",Boolean)],u.prototype,"breakWords",void 0),r([t.type("string"),p("design:type",String)],u.prototype,"whiteSpace",void 0),r([t.type("boolean"),p("design:type",Boolean)],u.prototype,"dropShadow",void 0),r([t.Field({type:"color"}),p("design:type",Object)],u.prototype,"dropShadowColor",void 0),r([t.type("number"),p("design:type",Number)],u.prototype,"dropShadowAlpha",void 0),r([t.type("number"),p("design:type",Number)],u.prototype,"dropShadowAngle",void 0),r([t.type("number"),p("design:type",Number)],u.prototype,"dropShadowBlur",void 0),r([t.type("number"),p("design:type",Number)],u.prototype,"dropShadowDistance",void 0),r([t.type("object"),p("design:type",Array)],u.prototype,"cssOverrides",void 0),r([t.type("object"),p("design:type",Object)],u.prototype,"tagStyles",void 0),r([t.type("boolean"),p("design:type",Boolean)],u.prototype,"trim",void 0);class m extends t.Component{constructor(){super(...arguments),this.text="",this.style={},this.textureStyle={}}init(e){this.style=_extends({fontSize:24,fill:"#000000",fontFamily:"Arial"},null==e?void 0:e.style),this.textureStyle=_extends({scaleMode:"linear",resolution:window.devicePixelRatio||1},null==e?void 0:e.textureStyle),e&&(this.text=e.text)}}m.componentName="HTMLText",r([t.type("string"),p("design:type",String)],m.prototype,"text",void 0),r([t.Field(()=>u),p("design:type",Object)],m.prototype,"style",void 0),r([t.Field(()=>h),p("design:type",Object)],m.prototype,"textureStyle",void 0);let b=class extends i.Renderer{constructor(){super(...arguments),this.name="Text",this.texts={}}init(){this.renderSystem=this.game.getSystem(i.RendererSystem),this.renderSystem.rendererManager.register(this)}componentChanged(e){return d(this,void 0,void 0,function*(){const o="Text"===e.componentName,i="HTMLText"===e.componentName,n="BitmapText"===e.componentName;if(o||i||n)if(e.type===t.OBSERVER_TYPE.ADD)o?yield this.addTextComponent(e):i?yield this.addHTMLTextComponent(e):yield this.addBitmapTextComponent(e),this.setSize(e);else if(e.type===t.OBSERVER_TYPE.REMOVE)this.containerManager.getContainer(e.gameObject.id).removeChild(this.texts[e.gameObject.id].text),this.texts[e.gameObject.id].text.destroy({children:!0}),delete this.texts[e.gameObject.id];else{this.change(e);const t=e.component,o=e.prop.prop;if("style"===o[0]&&(1===o.length||"fontFamily"===o[1])&&t.style&&this.hasRegisteredFont(t.style.fontFamily)){const{text:o}=this.texts[e.gameObject.id];yield this.waitForFontResource(o,e,t.style.fontFamily)}this.setSize(e)}})}addTextComponent(e){return d(this,void 0,void 0,function*(){const t=e.component,o=this.processStyle(t.style),i=o.fontFamily,r=this.hasRegisteredFont(i);r&&delete o.fontFamily;const p=r?"":t.text,d=new n.Text(p,o);this.containerManager.getContainer(e.gameObject.id).addChildAt(d,0),this.texts[e.gameObject.id]={text:d,component:t},r&&(yield this.waitForFontResource(d,e,i))})}addHTMLTextComponent(e){return d(this,void 0,void 0,function*(){const t=e.component,o=this.processStyle(t.style),i=o.fontFamily,r=this.hasRegisteredFont(i);r&&delete o.fontFamily;const p=r?"":t.text,d=new n.HTMLText(_extends({text:p,style:o},t.textureStyle&&{textureStyle:t.textureStyle}));this.containerManager.getContainer(e.gameObject.id).addChildAt(d,0),this.texts[e.gameObject.id]={text:d,component:t},r&&(yield this.waitForFontResource(d,e,i))})}addBitmapTextComponent(e){return d(this,void 0,void 0,function*(){const t=e.component,o=this.processStyle(t.style),i=o.fontFamily,r=this.hasRegisteredFont(i);r&&delete o.fontFamily;const p=r?"":t.text,d=new n.BitmapText(p,o);this.containerManager.getContainer(e.gameObject.id).addChildAt(d,0),this.texts[e.gameObject.id]={text:d,component:t},r&&(yield this.waitForFontResource(d,e,i))})}hasRegisteredFont(e){var o;if(!e)return!1;const i=Array.isArray(e)?e[0]:e;return(null===(o=t.resource.resourcesMap[i])||void 0===o?void 0:o.type)===t.RESOURCE_TYPE.FONT}waitForFontResource(e,o,i){return d(this,void 0,void 0,function*(){if(i)try{const n=Array.isArray(i)?i[0]:i;if(!this.hasRegisteredFont(i))return;const r=this.increaseAsyncId(o.gameObject.id);if(yield t.resource.getResource(n),!this.validateAsyncId(o.gameObject.id,r))return;const p=this.texts[o.gameObject.id].component;e.style.fontFamily=i,e.text=p.text}catch(e){console.warn(`字体资源 ${i} 加载失败:`,e)}})}processStyle(e){const t=_extends({},e);if(t.strokeThickness){const e=t.stroke;t.stroke={color:e,width:t.strokeThickness},delete t.strokeThickness}const i=null!=t.dropShadowColor||null!=t.dropShadowDistance||null!=t.dropShadowAngle||null!=t.dropShadowAlpha||null!=t.dropShadowBlur;if(t.dropShadow&&i){const e=t.dropShadow&&"object"==typeof t.dropShadow&&!Array.isArray(t.dropShadow)?_extends({},t.dropShadow):{};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}if(delete t.dropShadowColor,delete t.dropShadowDistance,delete t.dropShadowAngle,delete t.dropShadowAlpha,delete t.dropShadowBlur,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 i=new o.FillGradient(0,0,0,1.7*e),n=t.fillGradientStops.map(e=>o.Color.shared.setValue(e).toNumber());n.forEach((e,t)=>{const o=t/(n.length-1);i.addColorStop(o,e)}),t.fill={fill:i},delete t.fillGradientStops}return t}change(e){const{text:t,component:o}=this.texts[e.gameObject.id],i="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);this.hasRegisteredFont(e.fontFamily)&&delete e.fontFamily,_extends(t.style,e)}else if("textureStyle"===e.prop.prop[0]&&i){const i=o,r=this.containerManager.getContainer(e.gameObject.id),p=r.getChildIndex(t);r.removeChild(t),t.destroy({children:!0});const d=new n.HTMLText({text:i.text,style:i.style,textureStyle:i.textureStyle});r.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||(t.size.width=i.width,t.size.height=i.height,this.renderSystem.commitIntrinsicSize(e.gameObject))}};b.systemName="Text",b=r([t.decorators.componentObserver({Text:["text",{prop:["style"],deep:!0}],HTMLText:["text",{prop:["style"],deep:!0},{prop:["textureStyle"],deep:!0}],BitmapText:["text",{prop:["style"],deep:!0}]})],b);var v=b;return e.BitmapText=y,e.HTMLText=m,e.Text=c,e.TextSystem=v,Object.defineProperty(e,"__esModule",{value:!0}),e}({},EVA,PIXI,EVA.plugin.renderer,EVA.rendererAdapter);globalThis.EVA.plugin.renderer.text=globalThis.EVA.plugin.renderer.text||_EVA_IIFE_text;
|
|
1
|
+
function _extends(){return _extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var n in o)({}).hasOwnProperty.call(o,n)&&(e[n]=o[n])}return e},_extends.apply(null,arguments)}var globalThis="undefined"!=typeof self?self:"undefined"!=typeof window?window:Function("return this")();globalThis.EVA=globalThis.EVA||{},globalThis.EVA.plugin=globalThis.EVA.plugin||{},globalThis.EVA.plugin.renderer=globalThis.EVA.plugin.renderer||{};var _EVA_IIFE_text=function(e,t,o,n,i){"use strict";function r(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(o[n[i]]=e[n[i]])}return o}function s(e,t,o,n){var i,r=arguments.length,s=r<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,o,n);else for(var d=e.length-1;d>=0;d--)(i=e[d])&&(s=(r<3?i(s):r>3?i(t,o,s):i(t,o))||s);return r>3&&s&&Object.defineProperty(t,o,s),s}function d(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function p(e,t,o,n){return new(o||(o=Promise))(function(i,r){function s(e){try{p(n.next(e))}catch(e){r(e)}}function d(e){try{p(n.throw(e))}catch(e){r(e)}}function p(e){var t;e.done?i(e.value):(t=e.value,t instanceof o?t:new o(function(e){e(t)})).then(s,d)}p((n=n.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class l{}s([t.type("string"),d("design:type",Object)],l.prototype,"fontFamily",void 0),s([t.type("number"),d("design:type",Object)],l.prototype,"fontSize",void 0),s([t.Field({type:"color"}),d("design:type",Object)],l.prototype,"fill",void 0),s([t.type("string"),d("design:type",String)],l.prototype,"align",void 0),s([t.type("number"),d("design:type",Number)],l.prototype,"letterSpacing",void 0),s([t.type("number"),d("design:type",Number)],l.prototype,"padding",void 0),s([t.Field({type:"color"}),d("design:type",Object)],l.prototype,"stroke",void 0),s([t.type("number"),d("design:type",Number)],l.prototype,"strokeThickness",void 0),s([t.type("string"),d("design:type",String)],l.prototype,"fontWeight",void 0),s([t.type("string"),d("design:type",String)],l.prototype,"fontStyle",void 0);class y extends t.Component{constructor(){super(...arguments),this.text="",this.style={}}init(e){this.style=_extends({fontSize:24,fill:"#000000",fontFamily:"Arial"},null==e?void 0:e.style),e&&(this.text=e.text)}}y.componentName="BitmapText",s([t.type("string"),d("design:type",String)],y.prototype,"text",void 0),s([t.Field(()=>l),d("design:type",Object)],y.prototype,"style",void 0);class a{}s([t.type("number"),d("design:type",Number)],a.prototype,"alpha",void 0),s([t.Field({type:"color"}),d("design:type",Object)],a.prototype,"color",void 0),s([t.type("string"),d("design:type",String)],a.prototype,"join",void 0),s([t.type("number"),d("design:type",Number)],a.prototype,"miterLimit",void 0),s([t.type("number"),d("design:type",Number)],a.prototype,"width",void 0);class c{}s([t.type("number"),d("design:type",Number)],c.prototype,"alpha",void 0),s([t.type("number"),d("design:type",Number)],c.prototype,"angle",void 0),s([t.type("number"),d("design:type",Number)],c.prototype,"blur",void 0),s([t.Field({type:"color"}),d("design:type",Object)],c.prototype,"color",void 0),s([t.type("number"),d("design:type",Number)],c.prototype,"distance",void 0),s([t.type("boolean"),d("design:type",Boolean)],c.prototype,"enabled",void 0);class u{}s([t.type("string"),d("design:type",String)],u.prototype,"align",void 0),s([t.type("boolean"),d("design:type",Boolean)],u.prototype,"breakWords",void 0),s([t.Field(()=>c),d("design:type",Object)],u.prototype,"dropShadow",void 0),s([t.type("number"),d("design:type",Number)],u.prototype,"dropShadowAlpha",void 0),s([t.type("number"),d("design:type",Number)],u.prototype,"dropShadowAngle",void 0),s([t.type("number"),d("design:type",Number)],u.prototype,"dropShadowBlur",void 0),s([t.Field({type:"color"}),d("design:type",Object)],u.prototype,"dropShadowColor",void 0),s([t.type("number"),d("design:type",Number)],u.prototype,"dropShadowDistance",void 0),s([t.Field({type:"color"}),d("design:type",Object)],u.prototype,"fill",void 0),s([t.type("number"),d("design:type",Number)],u.prototype,"fillGradientType",void 0),s([t.type("number"),d("design:type",Array)],u.prototype,"fillGradientStops",void 0),s([t.type("string"),d("design:type",Object)],u.prototype,"fontFamily",void 0),s([t.type("number"),d("design:type",Object)],u.prototype,"fontSize",void 0),s([t.type("string"),d("design:type",String)],u.prototype,"fontStyle",void 0),s([t.type("string"),d("design:type",String)],u.prototype,"fontVariant",void 0),s([t.type("string"),d("design:type",String)],u.prototype,"fontWeight",void 0),s([t.type("number"),d("design:type",Number)],u.prototype,"leading",void 0),s([t.type("number"),d("design:type",Number)],u.prototype,"letterSpacing",void 0),s([t.type("number"),d("design:type",Number)],u.prototype,"lineHeight",void 0),s([t.type("string"),d("design:type",String)],u.prototype,"lineJoin",void 0),s([t.type("number"),d("design:type",Number)],u.prototype,"miterLimit",void 0),s([t.type("number"),d("design:type",Number)],u.prototype,"padding",void 0),s([t.Field(()=>a),d("design:type",Object)],u.prototype,"stroke",void 0),s([t.type("number"),d("design:type",Number)],u.prototype,"strokeThickness",void 0),s([t.type("string"),d("design:type",String)],u.prototype,"textBaseline",void 0),s([t.type("string"),d("design:type",String)],u.prototype,"verticalAlign",void 0),s([t.type("boolean"),d("design:type",Boolean)],u.prototype,"trim",void 0),s([t.type("string"),d("design:type",String)],u.prototype,"whiteSpace",void 0),s([t.type("boolean"),d("design:type",Boolean)],u.prototype,"wordWrap",void 0),s([t.type("number"),d("design:type",Number)],u.prototype,"wordWrapWidth",void 0);class g extends t.Component{constructor(e){super(e),this.text="",this.style={},this.init(e)}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,_extends(this.style,e.style))}}g.componentName="Text",s([t.type("string"),d("design:type",String)],g.prototype,"text",void 0),s([t.Field(()=>u),d("design:type",Object)],g.prototype,"style",void 0);class m{}s([t.type("string"),d("design:type",String)],m.prototype,"scaleMode",void 0),s([t.type("number"),d("design:type",Number)],m.prototype,"resolution",void 0);class h{}s([t.type("string"),d("design:type",Object)],h.prototype,"fontFamily",void 0),s([t.type("number"),d("design:type",Object)],h.prototype,"fontSize",void 0),s([t.type("string"),d("design:type",String)],h.prototype,"fontWeight",void 0),s([t.type("string"),d("design:type",String)],h.prototype,"fontStyle",void 0),s([t.type("string"),d("design:type",String)],h.prototype,"fontVariant",void 0),s([t.type("string"),d("design:type",String)],h.prototype,"align",void 0),s([t.type("string"),d("design:type",String)],h.prototype,"textBaseline",void 0),s([t.Field({type:"color"}),d("design:type",Object)],h.prototype,"fill",void 0),s([t.Field({type:"color"}),d("design:type",Object)],h.prototype,"stroke",void 0),s([t.type("number"),d("design:type",Number)],h.prototype,"strokeThickness",void 0),s([t.type("number"),d("design:type",Number)],h.prototype,"lineHeight",void 0),s([t.type("number"),d("design:type",Number)],h.prototype,"letterSpacing",void 0),s([t.type("number"),d("design:type",Number)],h.prototype,"padding",void 0),s([t.type("boolean"),d("design:type",Boolean)],h.prototype,"wordWrap",void 0),s([t.type("number"),d("design:type",Number)],h.prototype,"wordWrapWidth",void 0),s([t.type("boolean"),d("design:type",Boolean)],h.prototype,"breakWords",void 0),s([t.type("string"),d("design:type",String)],h.prototype,"whiteSpace",void 0),s([t.type("boolean"),d("design:type",Boolean)],h.prototype,"dropShadow",void 0),s([t.Field({type:"color"}),d("design:type",Object)],h.prototype,"dropShadowColor",void 0),s([t.type("number"),d("design:type",Number)],h.prototype,"dropShadowAlpha",void 0),s([t.type("number"),d("design:type",Number)],h.prototype,"dropShadowAngle",void 0),s([t.type("number"),d("design:type",Number)],h.prototype,"dropShadowBlur",void 0),s([t.type("number"),d("design:type",Number)],h.prototype,"dropShadowDistance",void 0),s([t.type("object"),d("design:type",Array)],h.prototype,"cssOverrides",void 0),s([t.type("object"),d("design:type",Object)],h.prototype,"tagStyles",void 0),s([t.type("boolean"),d("design:type",Boolean)],h.prototype,"trim",void 0);class v extends t.Component{constructor(){super(...arguments),this.text="",this.style={},this.textureStyle={}}init(e){this.style=_extends({fontSize:24,fill:"#000000",fontFamily:"Arial"},null==e?void 0:e.style),this.textureStyle=_extends({scaleMode:"linear",resolution:window.devicePixelRatio||1},null==e?void 0:e.textureStyle),e&&(this.text=e.text)}}v.componentName="HTMLText",s([t.type("string"),d("design:type",String)],v.prototype,"text",void 0),s([t.Field(()=>h),d("design:type",Object)],v.prototype,"style",void 0),s([t.Field(()=>m),d("design:type",Object)],v.prototype,"textureStyle",void 0);let b=class extends n.Renderer{constructor(){super(...arguments),this.name="Text",this.presentationAddFlushEnabled=!0,this.texts={},this.retired=!1,this.pendingHTMLTextComponents={},this.fontIdentityIds=new WeakMap,this.nextFontIdentityId=1}init(){this.renderSystem=this.game.getSystem(n.RendererSystem),this.renderSystem.rendererManager.register(this)}shouldFlushPresentationAddition(e){return"Text"===e.componentName||"HTMLText"===e.componentName||"BitmapText"===e.componentName}componentChanged(e){var o,n,i,r,s;return p(this,void 0,void 0,function*(){if(this.retired)return;const d="Text"===e.componentName,p="HTMLText"===e.componentName,l="BitmapText"===e.componentName;if(!d&&!p&&!l)return;const y=e.gameObject.id;if(e.type===t.OBSERVER_TYPE.ADD){if(d){const t=this.addTextComponent(e);t&&(yield t)}else if(p){const t=this.addHTMLTextComponent(e);t&&(yield t)}else{const t=this.addBitmapTextComponent(e);t&&(yield t)}(null===(o=this.texts[y])||void 0===o?void 0:o.component)===e.component&&this.setSize(e)}else if(e.type===t.OBSERVER_TYPE.REMOVE){if((null===(n=this.texts[y])||void 0===n?void 0:n.component)!==e.component&&this.pendingHTMLTextComponents[y]!==e.component)return;this.increaseAsyncId(y),this.pendingHTMLTextComponents[y]===e.component&&delete this.pendingHTMLTextComponents[y];const t=this.texts[y];if(!t||t.component!==e.component)return;this.containerManager.getContainer(y).removeChild(t.text),t.text.destroy({children:!0}),delete this.texts[y]}else{const t=e.component,o=e.prop.prop,n="style"===o[0]&&(1===o.length||"fontFamily"===o[1]),d=this.texts[y];if(!d)return void(p&&this.pendingHTMLTextComponents[y]===t&&n&&(yield this.addHTMLTextComponent(e),(null===(i=this.texts[y])||void 0===i?void 0:i.component)===t&&this.setSize(e)));if(d.component!==t)return;const l=n&&t.style&&this.needsFontLoad(t.style.fontFamily);if(n&&!l&&this.increaseAsyncId(y),this.change(e),l){const{text:o}=d;yield this.waitForFontResource(o,e,t.style.fontFamily)}(null===(r=this.texts[y])||void 0===r?void 0:r.text)===d.text&&(null===(s=this.texts[y])||void 0===s?void 0:s.component)===t&&this.setSize(e)}})}addTextComponent(e){const t=e.component,o=this.processStyle(t.style),n=o.fontFamily,r=this.needsFontLoad(n);r&&delete o.fontFamily;const s=r?"":t.text,d=new i.Text(s,o);if(this.containerManager.getContainer(e.gameObject.id).addChildAt(d,0),this.texts[e.gameObject.id]={text:d,component:t,awaitingInitialFont:r},r)return this.waitForFontResource(d,e,n)}addHTMLTextComponent(e){const t=e.component,o=e.gameObject.id,n=this.processStyle(t.style).fontFamily;if(this.needsFontLoad(n))return this.pendingHTMLTextComponents[o]=t,this.addHTMLTextAfterFont(e,t,n,this.increaseAsyncId(o));this.pendingHTMLTextComponents[o]===t&&delete this.pendingHTMLTextComponents[o],this.mountHTMLText(e,t)}addHTMLTextAfterFont(e,t,o,n){var i;return p(this,void 0,void 0,function*(){const r=e.gameObject.id,s=this.getFontName(o);(yield this.loadFontResource(o))&&!this.retired&&!e.gameObject.destroyed&&this.validateAsyncId(r,n)&&this.pendingHTMLTextComponents[r]===t&&this.getFontName(null===(i=t.style)||void 0===i?void 0:i.fontFamily)===s&&this.mountHTMLText(e,t)})}mountHTMLText(e,t){const o=e.gameObject.id,n=this.processStyle(t.style),s=r(t.textureStyle||{},["resolution"]),d=new i.HTMLText({text:t.text,style:n,textureStyle:_extends({},s)});d.rasterCacheFontIdentity=e=>this.getHTMLRasterFontIdentity(e),this.applyHTMLResolution(d,t,e),this.containerManager.getContainer(o).addChildAt(d,0),this.texts[o]={text:d,component:t},delete this.pendingHTMLTextComponents[o]}getHTMLRasterFontIdentity(e){var o;const n=[...new Set(e.filter(e=>"string"==typeof e).map(e=>e.replace(/["']/g,"").trim()).filter(Boolean))];if(!n.length)return"external:<default>";const i=e=>[this.objectIdentity(e),e.family,e.style,e.weight,e.stretch,e.unicodeRange,e.variant,e.featureSettings,e.display].map(e=>String(null!=e?e:"")).join(":"),r=[];for(const e of n){const n=t.resource.resourcesMap[e];if(!n||n.type!==t.RESOURCE_TYPE.FONT){r.push(`external:${e}`);continue}if(!0!==n.complete)return null;const s=null===(o=n.data)||void 0===o?void 0:o.font,d=Array.isArray(s)?s:[s];if(!d.length||d.some(e=>!e||"object"!=typeof e||"loaded"!==e.status))return null;r.push(`${e}|resource:${this.objectIdentity(n)}|faces:${d.map(i).join(",")}`)}return r.join(";")}objectIdentity(e){let t=this.fontIdentityIds.get(e);return t||(t=this.nextFontIdentityId++,this.fontIdentityIds.set(e,t)),t}addBitmapTextComponent(e){const t=e.component,o=this.processStyle(t.style),n=o.fontFamily,r=this.needsFontLoad(n);r&&delete o.fontFamily;const s=r?"":t.text,d=new i.BitmapText(s,o);if(this.containerManager.getContainer(e.gameObject.id).addChildAt(d,0),this.texts[e.gameObject.id]={text:d,component:t,awaitingInitialFont:r},r)return this.waitForFontResource(d,e,n)}hasRegisteredFont(e){var o;if(!e)return!1;const n=this.getFontName(e);return(null===(o=t.resource.resourcesMap[n])||void 0===o?void 0:o.type)===t.RESOURCE_TYPE.FONT}needsFontLoad(e){return!!this.hasRegisteredFont(e)&&!0!==t.resource.resourcesMap[this.getFontName(e)].complete}getFontName(e){if(e)return Array.isArray(e)?e[0]:e}loadFontResource(e){return p(this,void 0,void 0,function*(){const o=this.getFontName(e);if(!o||!this.hasRegisteredFont(e))return!1;const n=t.resource.resourcesMap[o];try{const e=yield t.resource.getResource(o);return e===n&&!0===e.complete&&t.resource.resourcesMap[o]===n}catch(t){return console.warn(`字体资源 ${e} 加载失败:`,t),!1}})}waitForFontResource(e,t,o){var n;return p(this,void 0,void 0,function*(){if(!o)return;const i=t.gameObject.id,r=this.getFontName(o);if(!r||!this.hasRegisteredFont(o))return;const s=this.increaseAsyncId(i),d=yield this.loadFontResource(o),p=this.texts[i];if(!d||this.retired||t.gameObject.destroyed||!this.validateAsyncId(i,s)||!p||p.text!==e||p.component!==t.component)return;const l=null===(n=p.component.style)||void 0===n?void 0:n.fontFamily;this.getFontName(l)===r&&(e.style.fontFamily=l,p.awaitingInitialFont=!1,e.text=p.component.text)})}processStyle(e){const t=this.cloneStyleValue(e);if(null!=t.strokeThickness||null!=t.lineJoin||null!=t.miterLimit){const e=t.stroke,o=e&&"object"==typeof e&&["color","width","fill","texture","join"].some(t=>t in e)?_extends({},e):{color:null!=e?e:0};null!=t.strokeThickness&&(o.width=t.strokeThickness),null!=t.lineJoin&&(o.join=t.lineJoin),null!=t.miterLimit&&(o.miterLimit=t.miterLimit),null==e&&null==t.strokeThickness||(t.stroke=o)}delete t.strokeThickness,delete t.lineJoin,delete t.miterLimit,t.dropShadow&&"object"==typeof t.dropShadow&&!Array.isArray(t.dropShadow)&&(!1===t.dropShadow.enabled?t.dropShadow=!1:delete t.dropShadow.enabled);const n=null!=t.dropShadowColor||null!=t.dropShadowDistance||null!=t.dropShadowAngle||null!=t.dropShadowAlpha||null!=t.dropShadowBlur;if(t.dropShadow&&n){const e=t.dropShadow&&"object"==typeof t.dropShadow&&!Array.isArray(t.dropShadow)?_extends({},t.dropShadow):{};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}if(delete t.dropShadowColor,delete t.dropShadowDistance,delete t.dropShadowAngle,delete t.dropShadowAlpha,delete t.dropShadowBlur,Array.isArray(t.fill)){const e=t.fill;if(e.length>1){const n=t.fillGradientStops,i=Array.isArray(n)&&n.length===e.length?n:e.map((t,o)=>o/(e.length-1)),r=1===t.fillGradientType,s=new o.FillGradient({start:{x:0,y:0},end:r?{x:1,y:0}:{x:0,y:1},textureSpace:"local"});e.forEach((e,t)=>{s.addColorStop(i[t],o.Color.shared.setValue(e).toNumber())}),t.fill={fill:s}}else t.fill=e[0]}return delete t.fillGradientStops,delete t.fillGradientType,t}change(e){var t,n,i,s,d,p,l,y;const a=this.texts[e.gameObject.id],{text:c,component:u}=a,g="HTMLText"===e.componentName;if("text"===e.prop.prop[0])a.awaitingInitialFont||(c.text=u.text);else if("style"===e.prop.prop[0]){const e=this.processStyle(u.style);this.needsFontLoad(e.fontFamily)&&delete e.fontFamily,_extends(c.style,e),a.awaitingInitialFont&&!this.needsFontLoad(null===(t=u.style)||void 0===t?void 0:t.fontFamily)&&(a.awaitingInitialFont=!1,c.text=u.text)}else if("textureStyle"===e.prop.prop[0]&&g){const t=u,a=c,g=r(t.textureStyle||{},["resolution"]);if(a.textureStyle){const e=_extends(_extends({},(null===o.TextureStyle||void 0===o.TextureStyle?void 0:o.TextureStyle.defaultOptions)||{addressMode:"clamp-to-edge",scaleMode:"linear"}),g);a.textureStyle.addressMode=e.addressMode,a.textureStyle.scaleMode=e.scaleMode,_extends(a.textureStyle,{addressModeU:null!==(n=e.addressModeU)&&void 0!==n?n:e.addressMode,addressModeV:null!==(i=e.addressModeV)&&void 0!==i?i:e.addressMode,addressModeW:null!==(s=e.addressModeW)&&void 0!==s?s:e.addressMode,magFilter:null!==(d=e.magFilter)&&void 0!==d?d:e.scaleMode,minFilter:null!==(p=e.minFilter)&&void 0!==p?p:e.scaleMode,mipmapFilter:null!==(l=e.mipmapFilter)&&void 0!==l?l:e.scaleMode,lodMinClamp:e.lodMinClamp,lodMaxClamp:e.lodMaxClamp,compare:e.compare,maxAnisotropy:null!==(y=e.maxAnisotropy)&&void 0!==y?y:1}),a.textureStyle.update()}else a.textureStyle=new o.TextureStyle(g);this.applyHTMLResolution(a,t,e)}}applyHTMLResolution(e,t,o){var n,i,r,s;const d=null===(i=(n=o.gameObject).getComponent)||void 0===i?void 0:i.call(n,"Render"),p=null!==(r=null==d?void 0:d.resolution)&&void 0!==r?r:null===(s=t.textureStyle)||void 0===s?void 0:s.resolution;"number"==typeof p&&Number.isFinite(p)&&p>0&&e.resolution!==p?e.resolution=p:null==p&&(e.resolution=null)}onDestroy(){var e,t;this.retired=!0;for(const e of Object.keys(this.asyncIdMap))this.increaseAsyncId(Number(e));this.pendingHTMLTextComponents={};for(const{text:o}of Object.values(this.texts))null===(e=o.parent)||void 0===e||e.removeChild(o),o.destroyed||null===(t=o.destroy)||void 0===t||t.call(o,{children:!0});this.texts={}}cloneStyleValue(e){return Array.isArray(e)?e.map(e=>this.cloneStyleValue(e)):e&&Object.getPrototypeOf(e)===Object.prototype?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,this.cloneStyleValue(t)])):e}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||(t.size.width=n.width,t.size.height=n.height,this.renderSystem.commitIntrinsicSize(e.gameObject))}};b.systemName="Text",b=s([t.decorators.componentObserver({Text:["text",{prop:["style"],deep:!0}],HTMLText:["text",{prop:["style"],deep:!0},{prop:["textureStyle"],deep:!0}],BitmapText:["text",{prop:["style"],deep:!0}]})],b);var f=b;return e.BitmapText=y,e.HTMLText=v,e.Text=g,e.TextSystem=f,Object.defineProperty(e,"__esModule",{value:!0}),e}({},EVA,PIXI,EVA.plugin.renderer,EVA.rendererAdapter);globalThis.EVA.plugin.renderer.text=globalThis.EVA.plugin.renderer.text||_EVA_IIFE_text;
|