@eva/plugin-renderer-text 2.0.1-beta.37 → 2.0.1-beta.38

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.
@@ -255,6 +255,30 @@ var _EVA_IIFE_text = function (exports, eva_js, pixi_js, pluginRenderer, rendere
255
255
  };
256
256
  delete processed.strokeThickness;
257
257
  }
258
+ if (processed.dropShadow) {
259
+ const dropShadowConfig = {};
260
+ if (processed.dropShadowColor != null) {
261
+ dropShadowConfig.color = processed.dropShadowColor;
262
+ }
263
+ if (processed.dropShadowDistance != null) {
264
+ dropShadowConfig.distance = processed.dropShadowDistance;
265
+ }
266
+ if (processed.dropShadowAngle != null) {
267
+ dropShadowConfig.angle = processed.dropShadowAngle;
268
+ }
269
+ if (processed.dropShadowAlpha != null) {
270
+ dropShadowConfig.alpha = processed.dropShadowAlpha;
271
+ }
272
+ if (processed.dropShadowBlur != null) {
273
+ dropShadowConfig.blur = processed.dropShadowBlur;
274
+ }
275
+ processed.dropShadow = dropShadowConfig;
276
+ delete processed.dropShadowColor;
277
+ delete processed.dropShadowDistance;
278
+ delete processed.dropShadowAngle;
279
+ delete processed.dropShadowAlpha;
280
+ delete processed.dropShadowBlur;
281
+ }
258
282
  if (Array.isArray(processed.fill)) {
259
283
  processed.fill = processed.fill[0];
260
284
  }
@@ -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 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 l=t.length-1;l>=0;l--)(o=t[l])&&(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{a(i.next(t))}catch(t){s(t)}}function l(t){try{a(i.throw(t))}catch(t){s(t)}}function a(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,l)}a((i=i.apply(t,e||[])).next())}))}function l(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 a extends e.Component{constructor(){super(...arguments),this.text="",this.style={}}init(t){this.style=_extends({fontSize:24,fill:"#000000",fontFamily:"Arial"},null==t?void 0:t.style),t&&(this.text=t.text)}}a.componentName="BitmapText",s([l("string")],a.prototype,"text",void 0);class c extends e.Component{constructor(){super(...arguments),this.text="",this.style={}}init(t){const e=new n.TextStyle({fontSize:20}),i={};for(const t in e)0===t.indexOf("_")&&(i[t.substring(1)]=e[t]);delete i.styleKey,this.style=i,t&&(this.text=t.text,_extends(this.style,t.style))}}c.componentName="Text",s([l("string")],c.prototype,"text",void 0);class d extends e.Component{constructor(){super(...arguments),this.text="",this.style={},this.textureStyle={}}init(t){this.style=_extends({fontSize:24,fill:"#000000",fontFamily:"Arial"},null==t?void 0:t.style),this.textureStyle=_extends({scaleMode:"linear",resolution:window.devicePixelRatio||1},null==t?void 0:t.textureStyle),t&&(this.text=t.text)}}d.componentName="HTMLText",s([l("string")],d.prototype,"text",void 0);let x=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 n="Text"===t.componentName,i="HTMLText"===t.componentName,o="BitmapText"===t.componentName;if(n||i||o)if(t.type===e.OBSERVER_TYPE.ADD)n?yield this.addTextComponent(t):i?yield this.addHTMLTextComponent(t):yield this.addBitmapTextComponent(t),this.setSize(t);else if(t.type===e.OBSERVER_TYPE.REMOVE)this.containerManager.getContainer(t.gameObject.id).removeChild(this.texts[t.gameObject.id].text),this.texts[t.gameObject.id].text.destroy({children:!0}),delete this.texts[t.gameObject.id];else{this.change(t);const e=t.component;if("style"===t.prop.prop[0]&&e.style&&e.style.fontFamily){const{text: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))}))}addBitmapTextComponent(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.BitmapText(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))}))}waitForFontResource(t,n,i){return r(this,void 0,void 0,(function*(){if(i)try{const o=Array.isArray(i)?i[0]:i,s=this.increaseAsyncId(n.gameObject.id);if(yield e.resource.getResource(o),!this.validateAsyncId(n.gameObject.id,s))return;const r=this.texts[n.gameObject.id].component;t.style.fontFamily=i,t.text=r.text}catch(t){console.warn(`字体资源 ${i} 加载失败:`,t)}}))}processStyle(t){const e=_extends({},t);if(e.strokeThickness){const t=e.stroke;e.stroke={color:t,width:e.strokeThickness},delete e.strokeThickness}if(Array.isArray(e.fill)&&(e.fill=e.fill[0]),Array.isArray(e.fillGradientStops)){let t;t=null==e.fontSize?n.TextStyle.defaultTextStyle.fontSize:"string"==typeof e.fontSize?parseInt(e.fontSize,10):e.fontSize;const i=new n.FillGradient(0,0,0,1.7*t),o=e.fillGradientStops.map((t=>n.Color.shared.setValue(t).toNumber()));o.forEach(((t,e)=>{const n=e/(o.length-1);i.addColorStop(n,t)})),e.fill={fill:i},delete e.fillGradientStops}return e}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]){const t=this.processStyle(n.style);_extends(e.style,t)}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 l=new o.HTMLText({text:i.text,style:i.style,textureStyle:i.textureStyle});s.addChildAt(l,r),this.texts[t.gameObject.id].text=l}}setSize(t){const{transform:e}=t.gameObject;if(!e)return;const{text:n}=this.texts[t.gameObject.id],i=n.getSize();e.size.width=i.width,e.size.height=i.height}};x.systemName="Text",x=s([e.decorators.componentObserver({Text:["text",{prop:["style"],deep:!0}],HTMLText:["text",{prop:["style"],deep:!0},{prop:["textureStyle"],deep:!0}],BitmapText:["text",{prop:["style"],deep:!0}]})],x);var p=x;return t.BitmapText=a,t.HTMLText=d,t.Text=c,t.TextSystem=p,Object.defineProperty(t,"__esModule",{value:!0}),t}({},EVA,PIXI,EVA.plugin.renderer,EVA.rendererAdapter);globalThis.EVA.plugin.renderer.text=globalThis.EVA.plugin.renderer.text||_EVA_IIFE_text;
1
+ function _extends(){return _extends=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)({}).hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},_extends.apply(null,arguments)}globalThis.EVA=globalThis.EVA||{},globalThis.EVA.plugin=globalThis.EVA.plugin||{},globalThis.EVA.plugin.renderer=globalThis.EVA.plugin.renderer||{};var _EVA_IIFE_text=function(t,e,n,o,i){"use strict";function r(t,e,n,o){var i,r=arguments.length,s=r<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,o);else for(var l=t.length-1;l>=0;l--)(i=t[l])&&(s=(r<3?i(s):r>3?i(e,n,s):i(e,n))||s);return r>3&&s&&Object.defineProperty(e,n,s),s}function s(t,e,n,o){return new(n||(n=Promise))((function(i,r){function s(t){try{d(o.next(t))}catch(t){r(t)}}function l(t){try{d(o.throw(t))}catch(t){r(t)}}function d(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,l)}d((o=o.apply(t,e||[])).next())}))}function l(t){return function(e,n){var o=function(t,e){return t.constructor.IDEProps||(t.constructor.IDEProps={}),t.constructor.IDEProps[e]||(t.constructor.IDEProps[e]={}),t.constructor.IDEProps[e]}(e,n);o.key=n,o.type=t}}class d extends e.Component{constructor(){super(...arguments),this.text="",this.style={}}init(t){this.style=_extends({fontSize:24,fill:"#000000",fontFamily:"Arial"},null==t?void 0:t.style),t&&(this.text=t.text)}}d.componentName="BitmapText",r([l("string")],d.prototype,"text",void 0);class a extends e.Component{constructor(){super(...arguments),this.text="",this.style={}}init(t){const e=new n.TextStyle({fontSize:20}),o={};for(const t in e)0===t.indexOf("_")&&(o[t.substring(1)]=e[t]);delete o.styleKey,this.style=o,t&&(this.text=t.text,_extends(this.style,t.style))}}a.componentName="Text",r([l("string")],a.prototype,"text",void 0);class c extends e.Component{constructor(){super(...arguments),this.text="",this.style={},this.textureStyle={}}init(t){this.style=_extends({fontSize:24,fill:"#000000",fontFamily:"Arial"},null==t?void 0:t.style),this.textureStyle=_extends({scaleMode:"linear",resolution:window.devicePixelRatio||1},null==t?void 0:t.textureStyle),t&&(this.text=t.text)}}c.componentName="HTMLText",r([l("string")],c.prototype,"text",void 0);let p=class extends o.Renderer{constructor(){super(...arguments),this.name="Text",this.texts={}}init(){this.renderSystem=this.game.getSystem(o.RendererSystem),this.renderSystem.rendererManager.register(this)}componentChanged(t){return s(this,void 0,void 0,(function*(){const n="Text"===t.componentName,o="HTMLText"===t.componentName,i="BitmapText"===t.componentName;if(n||o||i)if(t.type===e.OBSERVER_TYPE.ADD)n?yield this.addTextComponent(t):o?yield this.addHTMLTextComponent(t):yield this.addBitmapTextComponent(t),this.setSize(t);else if(t.type===e.OBSERVER_TYPE.REMOVE)this.containerManager.getContainer(t.gameObject.id).removeChild(this.texts[t.gameObject.id].text),this.texts[t.gameObject.id].text.destroy({children:!0}),delete this.texts[t.gameObject.id];else{this.change(t);const e=t.component;if("style"===t.prop.prop[0]&&e.style&&e.style.fontFamily){const{text:n}=this.texts[t.gameObject.id];yield this.waitForFontResource(n,t,e.style.fontFamily)}this.setSize(t)}}))}addTextComponent(t){return s(this,void 0,void 0,(function*(){const e=t.component,n=_extends({},e.style),o=n.fontFamily;delete n.fontFamily;const r=o?"":e.text,s=new i.Text(r,n);this.containerManager.getContainer(t.gameObject.id).addChildAt(s,0),this.texts[t.gameObject.id]={text:s,component:e},o&&(yield this.waitForFontResource(s,t,o))}))}addHTMLTextComponent(t){return s(this,void 0,void 0,(function*(){const e=t.component,n=_extends({},e.style),o=n.fontFamily;delete n.fontFamily;const r=o?"":e.text,s=new i.HTMLText(_extends({text:r,style:n},e.textureStyle&&{textureStyle:e.textureStyle}));this.containerManager.getContainer(t.gameObject.id).addChildAt(s,0),this.texts[t.gameObject.id]={text:s,component:e},o&&(yield this.waitForFontResource(s,t,o))}))}addBitmapTextComponent(t){return s(this,void 0,void 0,(function*(){const e=t.component,n=_extends({},e.style),o=n.fontFamily;delete n.fontFamily;const r=o?"":e.text,s=new i.BitmapText(r,n);this.containerManager.getContainer(t.gameObject.id).addChildAt(s,0),this.texts[t.gameObject.id]={text:s,component:e},o&&(yield this.waitForFontResource(s,t,o))}))}waitForFontResource(t,n,o){return s(this,void 0,void 0,(function*(){if(o)try{const i=Array.isArray(o)?o[0]:o,r=this.increaseAsyncId(n.gameObject.id);if(yield e.resource.getResource(i),!this.validateAsyncId(n.gameObject.id,r))return;const s=this.texts[n.gameObject.id].component;t.style.fontFamily=o,t.text=s.text}catch(t){console.warn(`字体资源 ${o} 加载失败:`,t)}}))}processStyle(t){const e=_extends({},t);if(e.strokeThickness){const t=e.stroke;e.stroke={color:t,width:e.strokeThickness},delete e.strokeThickness}if(e.dropShadow){const t={};null!=e.dropShadowColor&&(t.color=e.dropShadowColor),null!=e.dropShadowDistance&&(t.distance=e.dropShadowDistance),null!=e.dropShadowAngle&&(t.angle=e.dropShadowAngle),null!=e.dropShadowAlpha&&(t.alpha=e.dropShadowAlpha),null!=e.dropShadowBlur&&(t.blur=e.dropShadowBlur),e.dropShadow=t,delete e.dropShadowColor,delete e.dropShadowDistance,delete e.dropShadowAngle,delete e.dropShadowAlpha,delete e.dropShadowBlur}if(Array.isArray(e.fill)&&(e.fill=e.fill[0]),Array.isArray(e.fillGradientStops)){let t;t=null==e.fontSize?n.TextStyle.defaultTextStyle.fontSize:"string"==typeof e.fontSize?parseInt(e.fontSize,10):e.fontSize;const o=new n.FillGradient(0,0,0,1.7*t),i=e.fillGradientStops.map((t=>n.Color.shared.setValue(t).toNumber()));i.forEach(((t,e)=>{const n=e/(i.length-1);o.addColorStop(n,t)})),e.fill={fill:o},delete e.fillGradientStops}return e}change(t){const{text:e,component:n}=this.texts[t.gameObject.id],o="HTMLText"===t.componentName;if("text"===t.prop.prop[0])e.text=n.text;else if("style"===t.prop.prop[0]){const t=this.processStyle(n.style);_extends(e.style,t)}else if("textureStyle"===t.prop.prop[0]&&o){const o=n,r=this.containerManager.getContainer(t.gameObject.id),s=r.getChildIndex(e);r.removeChild(e),e.destroy({children:!0});const l=new i.HTMLText({text:o.text,style:o.style,textureStyle:o.textureStyle});r.addChildAt(l,s),this.texts[t.gameObject.id].text=l}}setSize(t){const{transform:e}=t.gameObject;if(!e)return;const{text:n}=this.texts[t.gameObject.id],o=n.getSize();e.size.width=o.width,e.size.height=o.height}};p.systemName="Text",p=r([e.decorators.componentObserver({Text:["text",{prop:["style"],deep:!0}],HTMLText:["text",{prop:["style"],deep:!0},{prop:["textureStyle"],deep:!0}],BitmapText:["text",{prop:["style"],deep:!0}]})],p);var h=p;return t.BitmapText=d,t.HTMLText=c,t.Text=a,t.TextSystem=h,Object.defineProperty(t,"__esModule",{value:!0}),t}({},EVA,PIXI,EVA.plugin.renderer,EVA.rendererAdapter);globalThis.EVA.plugin.renderer.text=globalThis.EVA.plugin.renderer.text||_EVA_IIFE_text;
@@ -400,6 +400,31 @@ let Text = class Text extends pluginRenderer.Renderer {
400
400
  };
401
401
  delete processed.strokeThickness;
402
402
  }
403
+ // dropShadow* -> dropShadow: { color, distance, angle, alpha, blur }
404
+ if (processed.dropShadow) {
405
+ const dropShadowConfig = {};
406
+ if (processed.dropShadowColor != null) {
407
+ dropShadowConfig.color = processed.dropShadowColor;
408
+ }
409
+ if (processed.dropShadowDistance != null) {
410
+ dropShadowConfig.distance = processed.dropShadowDistance;
411
+ }
412
+ if (processed.dropShadowAngle != null) {
413
+ dropShadowConfig.angle = processed.dropShadowAngle;
414
+ }
415
+ if (processed.dropShadowAlpha != null) {
416
+ dropShadowConfig.alpha = processed.dropShadowAlpha;
417
+ }
418
+ if (processed.dropShadowBlur != null) {
419
+ dropShadowConfig.blur = processed.dropShadowBlur;
420
+ }
421
+ processed.dropShadow = dropShadowConfig;
422
+ delete processed.dropShadowColor;
423
+ delete processed.dropShadowDistance;
424
+ delete processed.dropShadowAngle;
425
+ delete processed.dropShadowAlpha;
426
+ delete processed.dropShadowBlur;
427
+ }
403
428
  // fill 数组 -> 取第一个值 (deprecated)
404
429
  if (Array.isArray(processed.fill)) {
405
430
  processed.fill = processed.fill[0];
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@eva/eva.js"),e=require("@eva/inspector-decorator"),i=require("pixi.js"),n=require("@eva/plugin-renderer"),s=require("@eva/renderer-adapter");
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@eva/eva.js"),e=require("@eva/inspector-decorator"),o=require("pixi.js"),n=require("@eva/plugin-renderer"),i=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 o(t,e,i,n){var s,o=arguments.length,r=o<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var a=t.length-1;a>=0;a--)(s=t[a])&&(r=(o<3?s(r):o>3?s(e,i,r):s(e,i))||r);return o>3&&r&&Object.defineProperty(e,i,r),r}function r(t,e,i,n){return new(i||(i=Promise))((function(s,o){function r(t){try{l(n.next(t))}catch(t){o(t)}}function a(t){try{l(n.throw(t))}catch(t){o(t)}}function l(t){t.done?s(t.value):new i((function(e){e(t.value)})).then(r,a)}l((n=n.apply(t,e||[])).next())}))}class a extends t.Component{constructor(){super(...arguments),this.text="",this.style={}}init(t){this.style=Object.assign({fontSize:24,fill:"#000000",fontFamily:"Arial"},null==t?void 0:t.style),t&&(this.text=t.text)}}a.componentName="BitmapText",o([e.type("string")],a.prototype,"text",void 0);class l extends t.Component{constructor(){super(...arguments),this.text="",this.style={}}init(t){const e=new i.TextStyle({fontSize:20}),n={};for(const t in e)0===t.indexOf("_")&&(n[t.substring(1)]=e[t]);delete n.styleKey,this.style=n,t&&(this.text=t.text,Object.assign(this.style,t.style))}}l.componentName="Text",o([e.type("string")],l.prototype,"text",void 0);class c extends t.Component{constructor(){super(...arguments),this.text="",this.style={},this.textureStyle={}}init(t){this.style=Object.assign({fontSize:24,fill:"#000000",fontFamily:"Arial"},null==t?void 0:t.style),this.textureStyle=Object.assign({scaleMode:"linear",resolution:window.devicePixelRatio||1},null==t?void 0:t.textureStyle),t&&(this.text=t.text)}}c.componentName="HTMLText",o([e.type("string")],c.prototype,"text",void 0);let d=class extends n.Renderer{constructor(){super(...arguments),this.name="Text",this.texts={}}init(){this.renderSystem=this.game.getSystem(n.RendererSystem),this.renderSystem.rendererManager.register(this)}componentChanged(e){return r(this,void 0,void 0,(function*(){const i="Text"===e.componentName,n="HTMLText"===e.componentName,s="BitmapText"===e.componentName;if(i||n||s)if(e.type===t.OBSERVER_TYPE.ADD)i?yield this.addTextComponent(e):n?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;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(t){return r(this,void 0,void 0,(function*(){const e=t.component,i=Object.assign({},e.style),n=i.fontFamily;delete i.fontFamily;const o=n?"":e.text,r=new s.Text(o,i);this.containerManager.getContainer(t.gameObject.id).addChildAt(r,0),this.texts[t.gameObject.id]={text:r,component:e},n&&(yield this.waitForFontResource(r,t,n))}))}addHTMLTextComponent(t){return r(this,void 0,void 0,(function*(){const e=t.component,i=Object.assign({},e.style),n=i.fontFamily;delete i.fontFamily;const o=n?"":e.text,r=new s.HTMLText(Object.assign({text:o,style:i},e.textureStyle&&{textureStyle:e.textureStyle}));this.containerManager.getContainer(t.gameObject.id).addChildAt(r,0),this.texts[t.gameObject.id]={text:r,component:e},n&&(yield this.waitForFontResource(r,t,n))}))}addBitmapTextComponent(t){return r(this,void 0,void 0,(function*(){const e=t.component,i=Object.assign({},e.style),n=i.fontFamily;delete i.fontFamily;const o=n?"":e.text,r=new s.BitmapText(o,i);this.containerManager.getContainer(t.gameObject.id).addChildAt(r,0),this.texts[t.gameObject.id]={text:r,component:e},n&&(yield this.waitForFontResource(r,t,n))}))}waitForFontResource(e,i,n){return r(this,void 0,void 0,(function*(){if(n)try{const s=Array.isArray(n)?n[0]:n,o=this.increaseAsyncId(i.gameObject.id);if(yield t.resource.getResource(s),!this.validateAsyncId(i.gameObject.id,o))return;const r=this.texts[i.gameObject.id].component;e.style.fontFamily=n,e.text=r.text}catch(t){console.warn(`字体资源 ${n} 加载失败:`,t)}}))}processStyle(t){const e=Object.assign({},t);if(e.strokeThickness){const t=e.stroke;e.stroke={color:t,width:e.strokeThickness},delete e.strokeThickness}if(Array.isArray(e.fill)&&(e.fill=e.fill[0]),Array.isArray(e.fillGradientStops)){let t;t=null==e.fontSize?i.TextStyle.defaultTextStyle.fontSize:"string"==typeof e.fontSize?parseInt(e.fontSize,10):e.fontSize;const n=new i.FillGradient(0,0,0,1.7*t),s=e.fillGradientStops.map((t=>i.Color.shared.setValue(t).toNumber()));s.forEach(((t,e)=>{const i=e/(s.length-1);n.addColorStop(i,t)})),e.fill={fill:n},delete e.fillGradientStops}return e}change(t){const{text:e,component:i}=this.texts[t.gameObject.id],n="HTMLText"===t.componentName;if("text"===t.prop.prop[0])e.text=i.text;else if("style"===t.prop.prop[0]){const t=this.processStyle(i.style);Object.assign(e.style,t)}else if("textureStyle"===t.prop.prop[0]&&n){const n=i,o=this.containerManager.getContainer(t.gameObject.id),r=o.getChildIndex(e);o.removeChild(e),e.destroy({children:!0});const a=new s.HTMLText({text:n.text,style:n.style,textureStyle:n.textureStyle});o.addChildAt(a,r),this.texts[t.gameObject.id].text=a}}setSize(t){const{transform:e}=t.gameObject;if(!e)return;const{text:i}=this.texts[t.gameObject.id],n=i.getSize();e.size.width=n.width,e.size.height=n.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}],BitmapText:["text",{prop:["style"],deep:!0}]})],d);var p=d;exports.BitmapText=a,exports.HTMLText=c,exports.Text=l,exports.TextSystem=p;
16
+ function s(t,e,o,n){var i,s=arguments.length,r=s<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,o,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(r=(s<3?i(r):s>3?i(e,o,r):i(e,o))||r);return s>3&&r&&Object.defineProperty(e,o,r),r}function r(t,e,o,n){return new(o||(o=Promise))((function(i,s){function r(t){try{l(n.next(t))}catch(t){s(t)}}function a(t){try{l(n.throw(t))}catch(t){s(t)}}function l(t){t.done?i(t.value):new o((function(e){e(t.value)})).then(r,a)}l((n=n.apply(t,e||[])).next())}))}class a extends t.Component{constructor(){super(...arguments),this.text="",this.style={}}init(t){this.style=Object.assign({fontSize:24,fill:"#000000",fontFamily:"Arial"},null==t?void 0:t.style),t&&(this.text=t.text)}}a.componentName="BitmapText",s([e.type("string")],a.prototype,"text",void 0);class l extends t.Component{constructor(){super(...arguments),this.text="",this.style={}}init(t){const e=new o.TextStyle({fontSize:20}),n={};for(const t in e)0===t.indexOf("_")&&(n[t.substring(1)]=e[t]);delete n.styleKey,this.style=n,t&&(this.text=t.text,Object.assign(this.style,t.style))}}l.componentName="Text",s([e.type("string")],l.prototype,"text",void 0);class d extends t.Component{constructor(){super(...arguments),this.text="",this.style={},this.textureStyle={}}init(t){this.style=Object.assign({fontSize:24,fill:"#000000",fontFamily:"Arial"},null==t?void 0:t.style),this.textureStyle=Object.assign({scaleMode:"linear",resolution:window.devicePixelRatio||1},null==t?void 0:t.textureStyle),t&&(this.text=t.text)}}d.componentName="HTMLText",s([e.type("string")],d.prototype,"text",void 0);let c=class extends n.Renderer{constructor(){super(...arguments),this.name="Text",this.texts={}}init(){this.renderSystem=this.game.getSystem(n.RendererSystem),this.renderSystem.rendererManager.register(this)}componentChanged(e){return r(this,void 0,void 0,(function*(){const o="Text"===e.componentName,n="HTMLText"===e.componentName,i="BitmapText"===e.componentName;if(o||n||i)if(e.type===t.OBSERVER_TYPE.ADD)o?yield this.addTextComponent(e):n?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;if("style"===e.prop.prop[0]&&t.style&&t.style.fontFamily){const{text:o}=this.texts[e.gameObject.id];yield this.waitForFontResource(o,e,t.style.fontFamily)}this.setSize(e)}}))}addTextComponent(t){return r(this,void 0,void 0,(function*(){const e=t.component,o=Object.assign({},e.style),n=o.fontFamily;delete o.fontFamily;const s=n?"":e.text,r=new i.Text(s,o);this.containerManager.getContainer(t.gameObject.id).addChildAt(r,0),this.texts[t.gameObject.id]={text:r,component:e},n&&(yield this.waitForFontResource(r,t,n))}))}addHTMLTextComponent(t){return r(this,void 0,void 0,(function*(){const e=t.component,o=Object.assign({},e.style),n=o.fontFamily;delete o.fontFamily;const s=n?"":e.text,r=new i.HTMLText(Object.assign({text:s,style:o},e.textureStyle&&{textureStyle:e.textureStyle}));this.containerManager.getContainer(t.gameObject.id).addChildAt(r,0),this.texts[t.gameObject.id]={text:r,component:e},n&&(yield this.waitForFontResource(r,t,n))}))}addBitmapTextComponent(t){return r(this,void 0,void 0,(function*(){const e=t.component,o=Object.assign({},e.style),n=o.fontFamily;delete o.fontFamily;const s=n?"":e.text,r=new i.BitmapText(s,o);this.containerManager.getContainer(t.gameObject.id).addChildAt(r,0),this.texts[t.gameObject.id]={text:r,component:e},n&&(yield this.waitForFontResource(r,t,n))}))}waitForFontResource(e,o,n){return r(this,void 0,void 0,(function*(){if(n)try{const i=Array.isArray(n)?n[0]:n,s=this.increaseAsyncId(o.gameObject.id);if(yield t.resource.getResource(i),!this.validateAsyncId(o.gameObject.id,s))return;const r=this.texts[o.gameObject.id].component;e.style.fontFamily=n,e.text=r.text}catch(t){console.warn(`字体资源 ${n} 加载失败:`,t)}}))}processStyle(t){const e=Object.assign({},t);if(e.strokeThickness){const t=e.stroke;e.stroke={color:t,width:e.strokeThickness},delete e.strokeThickness}if(e.dropShadow){const t={};null!=e.dropShadowColor&&(t.color=e.dropShadowColor),null!=e.dropShadowDistance&&(t.distance=e.dropShadowDistance),null!=e.dropShadowAngle&&(t.angle=e.dropShadowAngle),null!=e.dropShadowAlpha&&(t.alpha=e.dropShadowAlpha),null!=e.dropShadowBlur&&(t.blur=e.dropShadowBlur),e.dropShadow=t,delete e.dropShadowColor,delete e.dropShadowDistance,delete e.dropShadowAngle,delete e.dropShadowAlpha,delete e.dropShadowBlur}if(Array.isArray(e.fill)&&(e.fill=e.fill[0]),Array.isArray(e.fillGradientStops)){let t;t=null==e.fontSize?o.TextStyle.defaultTextStyle.fontSize:"string"==typeof e.fontSize?parseInt(e.fontSize,10):e.fontSize;const n=new o.FillGradient(0,0,0,1.7*t),i=e.fillGradientStops.map((t=>o.Color.shared.setValue(t).toNumber()));i.forEach(((t,e)=>{const o=e/(i.length-1);n.addColorStop(o,t)})),e.fill={fill:n},delete e.fillGradientStops}return e}change(t){const{text:e,component:o}=this.texts[t.gameObject.id],n="HTMLText"===t.componentName;if("text"===t.prop.prop[0])e.text=o.text;else if("style"===t.prop.prop[0]){const t=this.processStyle(o.style);Object.assign(e.style,t)}else if("textureStyle"===t.prop.prop[0]&&n){const n=o,s=this.containerManager.getContainer(t.gameObject.id),r=s.getChildIndex(e);s.removeChild(e),e.destroy({children:!0});const a=new i.HTMLText({text:n.text,style:n.style,textureStyle:n.textureStyle});s.addChildAt(a,r),this.texts[t.gameObject.id].text=a}}setSize(t){const{transform:e}=t.gameObject;if(!e)return;const{text:o}=this.texts[t.gameObject.id],n=o.getSize();e.size.width=n.width,e.size.height=n.height}};c.systemName="Text",c=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}]})],c);var p=c;exports.BitmapText=a,exports.HTMLText=d,exports.Text=l,exports.TextSystem=p;
@@ -396,6 +396,31 @@ let Text = class Text extends Renderer {
396
396
  };
397
397
  delete processed.strokeThickness;
398
398
  }
399
+ // dropShadow* -> dropShadow: { color, distance, angle, alpha, blur }
400
+ if (processed.dropShadow) {
401
+ const dropShadowConfig = {};
402
+ if (processed.dropShadowColor != null) {
403
+ dropShadowConfig.color = processed.dropShadowColor;
404
+ }
405
+ if (processed.dropShadowDistance != null) {
406
+ dropShadowConfig.distance = processed.dropShadowDistance;
407
+ }
408
+ if (processed.dropShadowAngle != null) {
409
+ dropShadowConfig.angle = processed.dropShadowAngle;
410
+ }
411
+ if (processed.dropShadowAlpha != null) {
412
+ dropShadowConfig.alpha = processed.dropShadowAlpha;
413
+ }
414
+ if (processed.dropShadowBlur != null) {
415
+ dropShadowConfig.blur = processed.dropShadowBlur;
416
+ }
417
+ processed.dropShadow = dropShadowConfig;
418
+ delete processed.dropShadowColor;
419
+ delete processed.dropShadowDistance;
420
+ delete processed.dropShadowAngle;
421
+ delete processed.dropShadowAlpha;
422
+ delete processed.dropShadowBlur;
423
+ }
399
424
  // fill 数组 -> 取第一个值 (deprecated)
400
425
  if (Array.isArray(processed.fill)) {
401
426
  processed.fill = processed.fill[0];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eva/plugin-renderer-text",
3
- "version": "2.0.1-beta.37",
3
+ "version": "2.0.1-beta.38",
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.37",
23
- "@eva/renderer-adapter": "2.0.1-beta.37",
24
- "@eva/eva.js": "2.0.1-beta.37",
22
+ "@eva/plugin-renderer": "2.0.1-beta.38",
23
+ "@eva/renderer-adapter": "2.0.1-beta.38",
24
+ "@eva/eva.js": "2.0.1-beta.38",
25
25
  "pixi.js": "^8.17.0"
26
26
  }
27
27
  }