@eva/plugin-renderer-text 2.0.1-beta.28 → 2.0.1-beta.29

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.
@@ -60,7 +60,6 @@ var _EVA_IIFE_text = function (exports, pixi_js, eva_js, pluginRenderer, rendere
60
60
  super(...arguments);
61
61
  this.text = '';
62
62
  this.style = {};
63
- this.resolution = 1;
64
63
  }
65
64
  init(obj) {
66
65
  const style = new pixi_js.TextStyle({
@@ -77,15 +76,11 @@ var _EVA_IIFE_text = function (exports, pixi_js, eva_js, pluginRenderer, rendere
77
76
  if (obj) {
78
77
  this.text = obj.text;
79
78
  _extends(this.style, obj.style);
80
- if (obj.resolution !== undefined) {
81
- this.resolution = obj.resolution;
82
- }
83
79
  }
84
80
  }
85
81
  }
86
82
  Text$2.componentName = 'Text';
87
83
  __decorate([type('string')], Text$2.prototype, "text", void 0);
88
- __decorate([type('number')], Text$2.prototype, "resolution", void 0);
89
84
  class HTMLText extends eva_js.Component {
90
85
  constructor() {
91
86
  super(...arguments);
@@ -159,9 +154,6 @@ var _EVA_IIFE_text = function (exports, pixi_js, eva_js, pluginRenderer, rendere
159
154
  delete styleWithoutFont.fontFamily;
160
155
  const initialText = fontFamily ? '' : component.text;
161
156
  const text = new rendererAdapter.Text(initialText, styleWithoutFont);
162
- if (component.resolution !== undefined && component.resolution > 0) {
163
- text.resolution = component.resolution;
164
- }
165
157
  this.containerManager.getContainer(changed.gameObject.id).addChildAt(text, 0);
166
158
  this.texts[changed.gameObject.id] = {
167
159
  text,
@@ -223,11 +215,6 @@ var _EVA_IIFE_text = function (exports, pixi_js, eva_js, pluginRenderer, rendere
223
215
  text.text = component.text;
224
216
  } else if (changed.prop.prop[0] === 'style') {
225
217
  _extends(text.style, component.style);
226
- } else if (changed.prop.prop[0] === 'resolution' && !isHTMLText) {
227
- const textComponent = component;
228
- if (textComponent.resolution !== undefined && textComponent.resolution > 0) {
229
- text.resolution = textComponent.resolution;
230
- }
231
218
  } else if (changed.prop.prop[0] === 'textureStyle' && isHTMLText) {
232
219
  const htmlComponent = component;
233
220
  const container = this.containerManager.getContainer(changed.gameObject.id);
@@ -263,7 +250,7 @@ var _EVA_IIFE_text = function (exports, pixi_js, eva_js, pluginRenderer, rendere
263
250
  Text: ['text', {
264
251
  prop: ['style'],
265
252
  deep: true
266
- }, 'resolution'],
253
+ }],
267
254
  HTMLText: ['text', {
268
255
  prop: ['style'],
269
256
  deep: true
@@ -1 +1 @@
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 s(t,e,n,o){var i,s=arguments.length,r=s<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,n,o);else for(var l=t.length-1;l>=0;l--)(i=t[l])&&(r=(s<3?i(r):s>3?i(e,n,r):i(e,n))||r);return s>3&&r&&Object.defineProperty(e,n,r),r}function r(t,e,n,o){return new(n||(n=Promise))((function(i,s){function r(t){try{c(o.next(t))}catch(t){s(t)}}function l(t){try{c(o.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,l)}c((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 c extends n.Component{constructor(){super(...arguments),this.text="",this.style={},this.resolution=1}init(t){const n=new e.TextStyle({fontSize:20}),o={};for(const t in n)0===t.indexOf("_")&&(o[t.substring(1)]=n[t]);delete o.styleKey,this.style=o,t&&(this.text=t.text,_extends(this.style,t.style),void 0!==t.resolution&&(this.resolution=t.resolution))}}c.componentName="Text",s([l("string")],c.prototype,"text",void 0),s([l("number")],c.prototype,"resolution",void 0);class a extends n.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)}}a.componentName="HTMLText",s([l("string")],a.prototype,"text",void 0);let d=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 r(this,void 0,void 0,(function*(){const e="Text"===t.componentName,o="HTMLText"===t.componentName;if(e||o)if(t.type===n.OBSERVER_TYPE.ADD)e?yield this.addTextComponent(t):yield this.addHTMLTextComponent(t),this.setSize(t);else if(t.type===n.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 r(this,void 0,void 0,(function*(){const e=t.component,n=_extends({},e.style),o=n.fontFamily;delete n.fontFamily;const s=o?"":e.text,r=new i.Text(s,n);void 0!==e.resolution&&e.resolution>0&&(r.resolution=e.resolution),this.containerManager.getContainer(t.gameObject.id).addChildAt(r,0),this.texts[t.gameObject.id]={text:r,component:e},o&&(yield this.waitForFontResource(r,t,o))}))}addHTMLTextComponent(t){return r(this,void 0,void 0,(function*(){const e=t.component,n=_extends({},e.style),o=n.fontFamily;delete n.fontFamily;const s=o?"":e.text,r=new i.HTMLText(_extends({text:s,style:n},e.textureStyle&&{textureStyle:e.textureStyle}));this.containerManager.getContainer(t.gameObject.id).addChildAt(r,0),this.texts[t.gameObject.id]={text:r,component:e},o&&(yield this.waitForFontResource(r,t,o))}))}waitForFontResource(t,e,o){return r(this,void 0,void 0,(function*(){if(o)try{const i=Array.isArray(o)?o[0]:o,s=this.increaseAsyncId(e.gameObject.id);if(yield n.resource.getResource(i),!this.validateAsyncId(e.gameObject.id,s))return;const r=this.texts[e.gameObject.id].component;t.style.fontFamily=o,t.text=r.text}catch(t){console.warn(`字体资源 ${o} 加载失败:`,t)}}))}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])_extends(e.style,n.style);else if("resolution"!==t.prop.prop[0]||o){if("textureStyle"===t.prop.prop[0]&&o){const o=n,s=this.containerManager.getContainer(t.gameObject.id),r=s.getChildIndex(e);s.removeChild(e),e.destroy({children:!0});const l=new i.HTMLText({text:o.text,style:o.style,textureStyle:o.textureStyle});s.addChildAt(l,r),this.texts[t.gameObject.id].text=l}}else{const t=n;void 0!==t.resolution&&t.resolution>0&&(e.resolution=t.resolution)}}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}};d.systemName="Text",d=s([n.decorators.componentObserver({Text:["text",{prop:["style"],deep:!0},"resolution"],HTMLText:["text",{prop:["style"],deep:!0},{prop:["textureStyle"],deep:!0}]})],d);var u=d;return t.HTMLText=a,t.Text=c,t.TextSystem=u,Object.defineProperty(t,"__esModule",{value:!0}),t}({},PIXI,EVA,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(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)({}).hasOwnProperty.call(n,i)&&(t[i]=n[i])}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,i,o){"use strict";function s(t,e,n,i){var o,s=arguments.length,r=s<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,n,i);else for(var c=t.length-1;c>=0;c--)(o=t[c])&&(r=(s<3?o(r):s>3?o(e,n,r):o(e,n))||r);return s>3&&r&&Object.defineProperty(e,n,r),r}function r(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function c(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,c)}l((i=i.apply(t,e||[])).next())}))}function c(t){return function(e,n){var i=function(t,e){return t.constructor.IDEProps||(t.constructor.IDEProps={}),t.constructor.IDEProps[e]||(t.constructor.IDEProps[e]={}),t.constructor.IDEProps[e]}(e,n);i.key=n,i.type=t}}class l extends n.Component{constructor(){super(...arguments),this.text="",this.style={}}init(t){const n=new e.TextStyle({fontSize:20}),i={};for(const t in n)0===t.indexOf("_")&&(i[t.substring(1)]=n[t]);delete i.styleKey,this.style=i,t&&(this.text=t.text,_extends(this.style,t.style))}}l.componentName="Text",s([c("string")],l.prototype,"text",void 0);class a extends n.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)}}a.componentName="HTMLText",s([c("string")],a.prototype,"text",void 0);let d=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(t){return r(this,void 0,void 0,(function*(){const e="Text"===t.componentName,i="HTMLText"===t.componentName;if(e||i)if(t.type===n.OBSERVER_TYPE.ADD)e?yield this.addTextComponent(t):yield this.addHTMLTextComponent(t),this.setSize(t);else if(t.type===n.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 r(this,void 0,void 0,(function*(){const e=t.component,n=_extends({},e.style),i=n.fontFamily;delete n.fontFamily;const s=i?"":e.text,r=new o.Text(s,n);this.containerManager.getContainer(t.gameObject.id).addChildAt(r,0),this.texts[t.gameObject.id]={text:r,component:e},i&&(yield this.waitForFontResource(r,t,i))}))}addHTMLTextComponent(t){return r(this,void 0,void 0,(function*(){const e=t.component,n=_extends({},e.style),i=n.fontFamily;delete n.fontFamily;const s=i?"":e.text,r=new o.HTMLText(_extends({text:s,style:n},e.textureStyle&&{textureStyle:e.textureStyle}));this.containerManager.getContainer(t.gameObject.id).addChildAt(r,0),this.texts[t.gameObject.id]={text:r,component:e},i&&(yield this.waitForFontResource(r,t,i))}))}waitForFontResource(t,e,i){return r(this,void 0,void 0,(function*(){if(i)try{const o=Array.isArray(i)?i[0]:i,s=this.increaseAsyncId(e.gameObject.id);if(yield n.resource.getResource(o),!this.validateAsyncId(e.gameObject.id,s))return;const r=this.texts[e.gameObject.id].component;t.style.fontFamily=i,t.text=r.text}catch(t){console.warn(`字体资源 ${i} 加载失败:`,t)}}))}change(t){const{text:e,component:n}=this.texts[t.gameObject.id],i="HTMLText"===t.componentName;if("text"===t.prop.prop[0])e.text=n.text;else if("style"===t.prop.prop[0])_extends(e.style,n.style);else if("textureStyle"===t.prop.prop[0]&&i){const i=n,s=this.containerManager.getContainer(t.gameObject.id),r=s.getChildIndex(e);s.removeChild(e),e.destroy({children:!0});const c=new o.HTMLText({text:i.text,style:i.style,textureStyle:i.textureStyle});s.addChildAt(c,r),this.texts[t.gameObject.id].text=c}}setSize(t){const{transform:e}=t.gameObject;if(!e)return;const{text:n}=this.texts[t.gameObject.id],i=n.getSize();e.size.width=i.width,e.size.height=i.height}};d.systemName="Text",d=s([n.decorators.componentObserver({Text:["text",{prop:["style"],deep:!0}],HTMLText:["text",{prop:["style"],deep:!0},{prop:["textureStyle"],deep:!0}]})],d);var x=d;return t.HTMLText=a,t.Text=l,t.TextSystem=x,Object.defineProperty(t,"__esModule",{value:!0}),t}({},PIXI,EVA,EVA.plugin.renderer,EVA.rendererAdapter);globalThis.EVA.plugin.renderer.text=globalThis.EVA.plugin.renderer.text||_EVA_IIFE_text;
@@ -50,7 +50,6 @@ function __awaiter(thisArg, _arguments, P, generator) {
50
50
  * - 支持文本颜色、渐变填充
51
51
  * - 支持描边和投影效果
52
52
  * - 支持文本对齐和换行
53
- * - 可配置渲染分辨率
54
53
  *
55
54
  * @example
56
55
  * ```typescript
@@ -76,9 +75,10 @@ function __awaiter(thisArg, _arguments, P, generator) {
76
75
  * strokeThickness: 4,
77
76
  * dropShadow: true,
78
77
  * dropShadowDistance: 3
79
- * },
80
- * resolution: 2 // 高清渲染
78
+ * }
81
79
  * }));
80
+ * // 如需高清渲染,使用 Render 组件的 resolution 属性
81
+ * label.addComponent(new Render({ resolution: 2 }));
82
82
  * ```
83
83
  */
84
84
  class Text$2 extends eva_js.Component {
@@ -89,15 +89,12 @@ class Text$2 extends eva_js.Component {
89
89
  /** 文本样式配置 */
90
90
  // @decorators.IDEProp 复杂编辑后续添加
91
91
  this.style = {};
92
- /** 渲染分辨率,值越大文本越清晰但性能消耗越大 */
93
- this.resolution = 1;
94
92
  }
95
93
  /**
96
94
  * 初始化组件
97
95
  * @param obj - 初始化参数
98
96
  * @param obj.text - 文本内容
99
97
  * @param obj.style - 文本样式
100
- * @param obj.resolution - 渲染分辨率
101
98
  */
102
99
  init(obj) {
103
100
  const style = new pixi_js.TextStyle({
@@ -114,9 +111,6 @@ class Text$2 extends eva_js.Component {
114
111
  if (obj) {
115
112
  this.text = obj.text;
116
113
  Object.assign(this.style, obj.style);
117
- if (obj.resolution !== undefined) {
118
- this.resolution = obj.resolution;
119
- }
120
114
  }
121
115
  }
122
116
  }
@@ -124,10 +118,7 @@ class Text$2 extends eva_js.Component {
124
118
  Text$2.componentName = 'Text';
125
119
  __decorate([
126
120
  inspectorDecorator.type('string')
127
- ], Text$2.prototype, "text", void 0);
128
- __decorate([
129
- inspectorDecorator.type('number')
130
- ], Text$2.prototype, "resolution", void 0);
121
+ ], Text$2.prototype, "text", void 0);
131
122
 
132
123
  /**
133
124
  * HTML 富文本组件
@@ -180,14 +171,14 @@ __decorate([
180
171
  * }
181
172
  * }));
182
173
  *
183
- * // 高分辨率渲染
174
+ * // 高分辨率渲染(推荐使用 Render 组件的 resolution 属性)
184
175
  * label.addComponent(new HTMLText({
185
176
  * text: '高清文本',
186
177
  * textureStyle: {
187
- * resolution: 2,
188
178
  * scaleMode: 'linear'
189
179
  * }
190
180
  * }));
181
+ * label.addComponent(new Render({ resolution: 2 }));
191
182
  * ```
192
183
  */
193
184
  class HTMLText extends eva_js.Component {
@@ -272,10 +263,6 @@ let Text = class Text extends pluginRenderer.Renderer {
272
263
  delete styleWithoutFont.fontFamily;
273
264
  const initialText = fontFamily ? '' : component.text;
274
265
  const text = new rendererAdapter.Text(initialText, styleWithoutFont);
275
- // 设置 resolution 以提升清晰度
276
- if (component.resolution !== undefined && component.resolution > 0) {
277
- text.resolution = component.resolution;
278
- }
279
266
  this.containerManager.getContainer(changed.gameObject.id).addChildAt(text, 0);
280
267
  this.texts[changed.gameObject.id] = {
281
268
  text,
@@ -343,13 +330,6 @@ let Text = class Text extends pluginRenderer.Renderer {
343
330
  else if (changed.prop.prop[0] === 'style') {
344
331
  Object.assign(text.style, component.style);
345
332
  }
346
- else if (changed.prop.prop[0] === 'resolution' && !isHTMLText) {
347
- // 更新 resolution
348
- const textComponent = component;
349
- if (textComponent.resolution !== undefined && textComponent.resolution > 0) {
350
- text.resolution = textComponent.resolution;
351
- }
352
- }
353
333
  else if (changed.prop.prop[0] === 'textureStyle' && isHTMLText) {
354
334
  // HTMLText 纹理样式变化需要重新创建
355
335
  const htmlComponent = component;
@@ -379,7 +359,7 @@ let Text = class Text extends pluginRenderer.Renderer {
379
359
  Text.systemName = 'Text';
380
360
  Text = __decorate([
381
361
  eva_js.decorators.componentObserver({
382
- Text: ['text', { prop: ['style'], deep: true }, 'resolution'],
362
+ Text: ['text', { prop: ['style'], deep: true }],
383
363
  HTMLText: ['text', { prop: ['style'], deep: true }, { prop: ['textureStyle'], deep: true }],
384
364
  })
385
365
  ], Text);
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("pixi.js"),t=require("@eva/eva.js"),i=require("@eva/inspector-decorator"),o=require("@eva/plugin-renderer"),n=require("@eva/renderer-adapter");
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("pixi.js"),t=require("@eva/eva.js"),n=require("@eva/inspector-decorator"),i=require("@eva/plugin-renderer"),s=require("@eva/renderer-adapter");
2
2
  /*! *****************************************************************************
3
3
  Copyright (c) Microsoft Corporation. All rights reserved.
4
4
  Licensed under the Apache License, Version 2.0 (the "License"); you may not use
@@ -13,4 +13,4 @@ MERCHANTABLITY OR NON-INFRINGEMENT.
13
13
  See the Apache Version 2.0 License for specific language governing permissions
14
14
  and limitations under the License.
15
15
  ***************************************************************************** */
16
- function s(e,t,i,o){var n,s=arguments.length,r=s<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,i,o);else for(var c=e.length-1;c>=0;c--)(n=e[c])&&(r=(s<3?n(r):s>3?n(t,i,r):n(t,i))||r);return s>3&&r&&Object.defineProperty(t,i,r),r}function r(e,t,i,o){return new(i||(i=Promise))((function(n,s){function r(e){try{l(o.next(e))}catch(e){s(e)}}function c(e){try{l(o.throw(e))}catch(e){s(e)}}function l(e){e.done?n(e.value):new i((function(t){t(e.value)})).then(r,c)}l((o=o.apply(e,t||[])).next())}))}class c extends t.Component{constructor(){super(...arguments),this.text="",this.style={},this.resolution=1}init(t){const i=new e.TextStyle({fontSize:20}),o={};for(const e in i)0===e.indexOf("_")&&(o[e.substring(1)]=i[e]);delete o.styleKey,this.style=o,t&&(this.text=t.text,Object.assign(this.style,t.style),void 0!==t.resolution&&(this.resolution=t.resolution))}}c.componentName="Text",s([i.type("string")],c.prototype,"text",void 0),s([i.type("number")],c.prototype,"resolution",void 0);class l extends t.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)}}l.componentName="HTMLText",s([i.type("string")],l.prototype,"text",void 0);let a=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(e){return r(this,void 0,void 0,(function*(){const i="Text"===e.componentName,o="HTMLText"===e.componentName;if(i||o)if(e.type===t.OBSERVER_TYPE.ADD)i?yield this.addTextComponent(e):yield this.addHTMLTextComponent(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;if("style"===e.prop.prop[0]&&t.style&&t.style.fontFamily){const{text:i}=this.texts[e.gameObject.id];yield this.waitForFontResource(i,e,t.style.fontFamily)}this.setSize(e)}}))}addTextComponent(e){return r(this,void 0,void 0,(function*(){const t=e.component,i=Object.assign({},t.style),o=i.fontFamily;delete i.fontFamily;const s=o?"":t.text,r=new n.Text(s,i);void 0!==t.resolution&&t.resolution>0&&(r.resolution=t.resolution),this.containerManager.getContainer(e.gameObject.id).addChildAt(r,0),this.texts[e.gameObject.id]={text:r,component:t},o&&(yield this.waitForFontResource(r,e,o))}))}addHTMLTextComponent(e){return r(this,void 0,void 0,(function*(){const t=e.component,i=Object.assign({},t.style),o=i.fontFamily;delete i.fontFamily;const s=o?"":t.text,r=new n.HTMLText(Object.assign({text:s,style:i},t.textureStyle&&{textureStyle:t.textureStyle}));this.containerManager.getContainer(e.gameObject.id).addChildAt(r,0),this.texts[e.gameObject.id]={text:r,component:t},o&&(yield this.waitForFontResource(r,e,o))}))}waitForFontResource(e,i,o){return r(this,void 0,void 0,(function*(){if(o)try{const n=Array.isArray(o)?o[0]:o,s=this.increaseAsyncId(i.gameObject.id);if(yield t.resource.getResource(n),!this.validateAsyncId(i.gameObject.id,s))return;const r=this.texts[i.gameObject.id].component;e.style.fontFamily=o,e.text=r.text}catch(e){console.warn(`字体资源 ${o} 加载失败:`,e)}}))}change(e){const{text:t,component:i}=this.texts[e.gameObject.id],o="HTMLText"===e.componentName;if("text"===e.prop.prop[0])t.text=i.text;else if("style"===e.prop.prop[0])Object.assign(t.style,i.style);else if("resolution"!==e.prop.prop[0]||o){if("textureStyle"===e.prop.prop[0]&&o){const o=i,s=this.containerManager.getContainer(e.gameObject.id),r=s.getChildIndex(t);s.removeChild(t),t.destroy({children:!0});const c=new n.HTMLText({text:o.text,style:o.style,textureStyle:o.textureStyle});s.addChildAt(c,r),this.texts[e.gameObject.id].text=c}}else{const e=i;void 0!==e.resolution&&e.resolution>0&&(t.resolution=e.resolution)}}setSize(e){const{transform:t}=e.gameObject;if(!t)return;const{text:i}=this.texts[e.gameObject.id],o=i.getSize();t.size.width=o.width,t.size.height=o.height}};a.systemName="Text",a=s([t.decorators.componentObserver({Text:["text",{prop:["style"],deep:!0},"resolution"],HTMLText:["text",{prop:["style"],deep:!0},{prop:["textureStyle"],deep:!0}]})],a);var d=a;exports.HTMLText=l,exports.Text=c,exports.TextSystem=d;
16
+ function o(e,t,n,i){var s,o=arguments.length,r=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,n,i);else for(var c=e.length-1;c>=0;c--)(s=e[c])&&(r=(o<3?s(r):o>3?s(t,n,r):s(t,n))||r);return o>3&&r&&Object.defineProperty(t,n,r),r}function r(e,t,n,i){return new(n||(n=Promise))((function(s,o){function r(e){try{a(i.next(e))}catch(e){o(e)}}function c(e){try{a(i.throw(e))}catch(e){o(e)}}function a(e){e.done?s(e.value):new n((function(t){t(e.value)})).then(r,c)}a((i=i.apply(e,t||[])).next())}))}class c extends t.Component{constructor(){super(...arguments),this.text="",this.style={}}init(t){const n=new e.TextStyle({fontSize:20}),i={};for(const e in n)0===e.indexOf("_")&&(i[e.substring(1)]=n[e]);delete i.styleKey,this.style=i,t&&(this.text=t.text,Object.assign(this.style,t.style))}}c.componentName="Text",o([n.type("string")],c.prototype,"text",void 0);class a extends t.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)}}a.componentName="HTMLText",o([n.type("string")],a.prototype,"text",void 0);let d=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 r(this,void 0,void 0,(function*(){const n="Text"===e.componentName,i="HTMLText"===e.componentName;if(n||i)if(e.type===t.OBSERVER_TYPE.ADD)n?yield this.addTextComponent(e):yield this.addHTMLTextComponent(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;if("style"===e.prop.prop[0]&&t.style&&t.style.fontFamily){const{text:n}=this.texts[e.gameObject.id];yield this.waitForFontResource(n,e,t.style.fontFamily)}this.setSize(e)}}))}addTextComponent(e){return r(this,void 0,void 0,(function*(){const t=e.component,n=Object.assign({},t.style),i=n.fontFamily;delete n.fontFamily;const o=i?"":t.text,r=new s.Text(o,n);this.containerManager.getContainer(e.gameObject.id).addChildAt(r,0),this.texts[e.gameObject.id]={text:r,component:t},i&&(yield this.waitForFontResource(r,e,i))}))}addHTMLTextComponent(e){return r(this,void 0,void 0,(function*(){const t=e.component,n=Object.assign({},t.style),i=n.fontFamily;delete n.fontFamily;const o=i?"":t.text,r=new s.HTMLText(Object.assign({text:o,style:n},t.textureStyle&&{textureStyle:t.textureStyle}));this.containerManager.getContainer(e.gameObject.id).addChildAt(r,0),this.texts[e.gameObject.id]={text:r,component:t},i&&(yield this.waitForFontResource(r,e,i))}))}waitForFontResource(e,n,i){return r(this,void 0,void 0,(function*(){if(i)try{const s=Array.isArray(i)?i[0]:i,o=this.increaseAsyncId(n.gameObject.id);if(yield t.resource.getResource(s),!this.validateAsyncId(n.gameObject.id,o))return;const r=this.texts[n.gameObject.id].component;e.style.fontFamily=i,e.text=r.text}catch(e){console.warn(`字体资源 ${i} 加载失败:`,e)}}))}change(e){const{text:t,component:n}=this.texts[e.gameObject.id],i="HTMLText"===e.componentName;if("text"===e.prop.prop[0])t.text=n.text;else if("style"===e.prop.prop[0])Object.assign(t.style,n.style);else if("textureStyle"===e.prop.prop[0]&&i){const i=n,o=this.containerManager.getContainer(e.gameObject.id),r=o.getChildIndex(t);o.removeChild(t),t.destroy({children:!0});const c=new s.HTMLText({text:i.text,style:i.style,textureStyle:i.textureStyle});o.addChildAt(c,r),this.texts[e.gameObject.id].text=c}}setSize(e){const{transform:t}=e.gameObject;if(!t)return;const{text:n}=this.texts[e.gameObject.id],i=n.getSize();t.size.width=i.width,t.size.height=i.height}};d.systemName="Text",d=o([t.decorators.componentObserver({Text:["text",{prop:["style"],deep:!0}],HTMLText:["text",{prop:["style"],deep:!0},{prop:["textureStyle"],deep:!0}]})],d);var l=d;exports.HTMLText=a,exports.Text=c,exports.TextSystem=l;
@@ -64,14 +64,14 @@ import { TextStyleWhiteSpace } from 'pixi.js';
64
64
  * }
65
65
  * }));
66
66
  *
67
- * // 高分辨率渲染
67
+ * // 高分辨率渲染(推荐使用 Render 组件的 resolution 属性)
68
68
  * label.addComponent(new HTMLText({
69
69
  * text: '高清文本',
70
70
  * textureStyle: {
71
- * resolution: 2,
72
71
  * scaleMode: 'linear'
73
72
  * }
74
73
  * }));
74
+ * label.addComponent(new Render({ resolution: 2 }));
75
75
  * ```
76
76
  */
77
77
  export declare class HTMLText extends Component<HTMLTextParams> {
@@ -143,7 +143,6 @@ declare interface HTMLTextStyleOptions {
143
143
  * - 支持文本颜色、渐变填充
144
144
  * - 支持描边和投影效果
145
145
  * - 支持文本对齐和换行
146
- * - 可配置渲染分辨率
147
146
  *
148
147
  * @example
149
148
  * ```typescript
@@ -169,9 +168,10 @@ declare interface HTMLTextStyleOptions {
169
168
  * strokeThickness: 4,
170
169
  * dropShadow: true,
171
170
  * dropShadowDistance: 3
172
- * },
173
- * resolution: 2 // 高清渲染
171
+ * }
174
172
  * }));
173
+ * // 如需高清渲染,使用 Render 组件的 resolution 属性
174
+ * label.addComponent(new Render({ resolution: 2 }));
175
175
  * ```
176
176
  */
177
177
  declare class Text_2 extends Component<TextParams> {
@@ -181,14 +181,11 @@ declare class Text_2 extends Component<TextParams> {
181
181
  text: string;
182
182
  /** 文本样式配置 */
183
183
  style: TextParams['style'];
184
- /** 渲染分辨率,值越大文本越清晰但性能消耗越大 */
185
- resolution: number;
186
184
  /**
187
185
  * 初始化组件
188
186
  * @param obj - 初始化参数
189
187
  * @param obj.text - 文本内容
190
188
  * @param obj.style - 文本样式
191
- * @param obj.resolution - 渲染分辨率
192
189
  */
193
190
  init(obj?: TextParams): void;
194
191
  }
@@ -227,7 +224,6 @@ export declare interface TextParams {
227
224
  wordWrapWidth?: number;
228
225
  leading?: number;
229
226
  };
230
- resolution?: number;
231
227
  }
232
228
 
233
229
  export declare class TextSystem extends Renderer {
@@ -46,7 +46,6 @@ function __awaiter(thisArg, _arguments, P, generator) {
46
46
  * - 支持文本颜色、渐变填充
47
47
  * - 支持描边和投影效果
48
48
  * - 支持文本对齐和换行
49
- * - 可配置渲染分辨率
50
49
  *
51
50
  * @example
52
51
  * ```typescript
@@ -72,9 +71,10 @@ function __awaiter(thisArg, _arguments, P, generator) {
72
71
  * strokeThickness: 4,
73
72
  * dropShadow: true,
74
73
  * dropShadowDistance: 3
75
- * },
76
- * resolution: 2 // 高清渲染
74
+ * }
77
75
  * }));
76
+ * // 如需高清渲染,使用 Render 组件的 resolution 属性
77
+ * label.addComponent(new Render({ resolution: 2 }));
78
78
  * ```
79
79
  */
80
80
  class Text$2 extends Component {
@@ -85,15 +85,12 @@ class Text$2 extends Component {
85
85
  /** 文本样式配置 */
86
86
  // @decorators.IDEProp 复杂编辑后续添加
87
87
  this.style = {};
88
- /** 渲染分辨率,值越大文本越清晰但性能消耗越大 */
89
- this.resolution = 1;
90
88
  }
91
89
  /**
92
90
  * 初始化组件
93
91
  * @param obj - 初始化参数
94
92
  * @param obj.text - 文本内容
95
93
  * @param obj.style - 文本样式
96
- * @param obj.resolution - 渲染分辨率
97
94
  */
98
95
  init(obj) {
99
96
  const style = new TextStyle({
@@ -110,9 +107,6 @@ class Text$2 extends Component {
110
107
  if (obj) {
111
108
  this.text = obj.text;
112
109
  Object.assign(this.style, obj.style);
113
- if (obj.resolution !== undefined) {
114
- this.resolution = obj.resolution;
115
- }
116
110
  }
117
111
  }
118
112
  }
@@ -120,10 +114,7 @@ class Text$2 extends Component {
120
114
  Text$2.componentName = 'Text';
121
115
  __decorate([
122
116
  type('string')
123
- ], Text$2.prototype, "text", void 0);
124
- __decorate([
125
- type('number')
126
- ], Text$2.prototype, "resolution", void 0);
117
+ ], Text$2.prototype, "text", void 0);
127
118
 
128
119
  /**
129
120
  * HTML 富文本组件
@@ -176,14 +167,14 @@ __decorate([
176
167
  * }
177
168
  * }));
178
169
  *
179
- * // 高分辨率渲染
170
+ * // 高分辨率渲染(推荐使用 Render 组件的 resolution 属性)
180
171
  * label.addComponent(new HTMLText({
181
172
  * text: '高清文本',
182
173
  * textureStyle: {
183
- * resolution: 2,
184
174
  * scaleMode: 'linear'
185
175
  * }
186
176
  * }));
177
+ * label.addComponent(new Render({ resolution: 2 }));
187
178
  * ```
188
179
  */
189
180
  class HTMLText extends Component {
@@ -268,10 +259,6 @@ let Text = class Text extends Renderer {
268
259
  delete styleWithoutFont.fontFamily;
269
260
  const initialText = fontFamily ? '' : component.text;
270
261
  const text = new Text$3(initialText, styleWithoutFont);
271
- // 设置 resolution 以提升清晰度
272
- if (component.resolution !== undefined && component.resolution > 0) {
273
- text.resolution = component.resolution;
274
- }
275
262
  this.containerManager.getContainer(changed.gameObject.id).addChildAt(text, 0);
276
263
  this.texts[changed.gameObject.id] = {
277
264
  text,
@@ -339,13 +326,6 @@ let Text = class Text extends Renderer {
339
326
  else if (changed.prop.prop[0] === 'style') {
340
327
  Object.assign(text.style, component.style);
341
328
  }
342
- else if (changed.prop.prop[0] === 'resolution' && !isHTMLText) {
343
- // 更新 resolution
344
- const textComponent = component;
345
- if (textComponent.resolution !== undefined && textComponent.resolution > 0) {
346
- text.resolution = textComponent.resolution;
347
- }
348
- }
349
329
  else if (changed.prop.prop[0] === 'textureStyle' && isHTMLText) {
350
330
  // HTMLText 纹理样式变化需要重新创建
351
331
  const htmlComponent = component;
@@ -375,7 +355,7 @@ let Text = class Text extends Renderer {
375
355
  Text.systemName = 'Text';
376
356
  Text = __decorate([
377
357
  decorators.componentObserver({
378
- Text: ['text', { prop: ['style'], deep: true }, 'resolution'],
358
+ Text: ['text', { prop: ['style'], deep: true }],
379
359
  HTMLText: ['text', { prop: ['style'], deep: true }, { prop: ['textureStyle'], deep: true }],
380
360
  })
381
361
  ], Text);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eva/plugin-renderer-text",
3
- "version": "2.0.1-beta.28",
3
+ "version": "2.0.1-beta.29",
4
4
  "description": "@eva/plugin-renderer-text",
5
5
  "main": "index.js",
6
6
  "module": "dist/plugin-renderer-text.esm.js",
@@ -19,9 +19,9 @@
19
19
  "homepage": "https://eva.js.org",
20
20
  "dependencies": {
21
21
  "@eva/inspector-decorator": "^0.0.5",
22
- "@eva/plugin-renderer": "2.0.1-beta.28",
23
- "@eva/renderer-adapter": "2.0.1-beta.28",
24
- "@eva/eva.js": "2.0.1-beta.28",
22
+ "@eva/plugin-renderer": "2.0.1-beta.29",
23
+ "@eva/renderer-adapter": "2.0.1-beta.29",
24
+ "@eva/eva.js": "2.0.1-beta.29",
25
25
  "pixi.js": "^8.8.1"
26
26
  }
27
27
  }