@eva/plugin-renderer-text 2.0.1-beta.16 → 2.0.1-beta.18

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.
@@ -86,6 +86,7 @@ var _EVA_IIFE_text = function (exports, pixi_js, eva_js, pluginRenderer, rendere
86
86
  super(...arguments);
87
87
  this.name = 'Text';
88
88
  this.texts = {};
89
+ this._lastFontFamily = undefined;
89
90
  }
90
91
  init() {
91
92
  this.renderSystem = this.game.getSystem(pluginRenderer.RendererSystem);
@@ -125,6 +126,10 @@ var _EVA_IIFE_text = function (exports, pixi_js, eva_js, pluginRenderer, rendere
125
126
  } else if (changed.prop.prop[0] === 'style') {
126
127
  _extends(text.style, changed.component.style);
127
128
  }
129
+ if (text.style.fontFamily && text.style.fontFamily !== this._lastFontFamily) {
130
+ this._lastFontFamily = text.style.fontFamily;
131
+ this.asyncChangeTextStyle(text, text.style);
132
+ }
128
133
  }
129
134
  asyncChangeTextStyle(text, textStyle) {
130
135
  if (textStyle.fontFamily) {
@@ -1 +1 @@
1
- function _extends(){return _extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}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,n,r,s){"use strict";function o(e,t,n,r){var s,o=arguments.length,i=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(s=e[c])&&(i=(o<3?s(i):o>3?s(t,n,i):s(t,n))||i);return o>3&&i&&Object.defineProperty(t,n,i),i}function i(e,t,n,r){return new(n||(n=Promise))((function(s,o){function i(e){try{a(r.next(e))}catch(e){o(e)}}function c(e){try{a(r.throw(e))}catch(e){o(e)}}function a(e){var t;e.done?s(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,c)}a((r=r.apply(e,t||[])).next())}))}class c extends n.Component{constructor(){super(...arguments),this.text="",this.style={}}init(e){const n=new t.TextStyle({fontSize:20}),r={};for(const e in n)0===e.indexOf("_")&&(r[e.substring(1)]=n[e]);delete r.styleKey,this.style=r,e&&(this.text=e.text,_extends(this.style,e.style))}}c.componentName="Text",o([function(e){return function(t,n){var r=function(e,t){return e.constructor.IDEProps||(e.constructor.IDEProps={}),e.constructor.IDEProps[t]||(e.constructor.IDEProps[t]={}),e.constructor.IDEProps[t]}(t,n);r.key=n,r.type=e}}("string")],c.prototype,"text",void 0);let a=class extends r.Renderer{constructor(){super(...arguments),this.name="Text",this.texts={}}init(){this.renderSystem=this.game.getSystem(r.RendererSystem),this.renderSystem.rendererManager.register(this)}componentChanged(e){return i(this,void 0,void 0,(function*(){if("Text"===e.componentName)if(e.type===n.OBSERVER_TYPE.ADD){const t=e.component,n=new s.Text(t.text,t.style);this.containerManager.getContainer(e.gameObject.id).addChildAt(n,0),this.texts[e.gameObject.id]={text:n,component:e.component},this.setSize(e)}else e.type===n.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]):(this.change(e),this.setSize(e))}))}change(e){const{text:t,component:n}=this.texts[e.gameObject.id];"text"===e.prop.prop[0]?t.text=n.text:"style"===e.prop.prop[0]&&_extends(t.style,e.component.style)}asyncChangeTextStyle(e,t){if(t.fontFamily){const n=t.fontFamily;t.fontFamily="",this.asyncUpdateFontFamily(e,n)}_extends(e.style,t)}asyncUpdateFontFamily(e,t){t&&(Array.isArray(t)?Promise.all(t.map((e=>n.resource.getResource(e)))).finally((()=>{e.style.fontFamily=t})):n.resource.getResource(t).finally((()=>{e.style.fontFamily=t})))}setSize(e){const{transform:t}=e.gameObject;t&&(t.size.width=this.texts[e.gameObject.id].text.width,t.size.height=this.texts[e.gameObject.id].text.height)}};a.systemName="Text",a=o([n.decorators.componentObserver({Text:["text",{prop:["style"],deep:!0}]})],a);var l=a;return e.Text=c,e.TextSystem=l,Object.defineProperty(e,"__esModule",{value:!0}),e}({},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 s in n)({}).hasOwnProperty.call(n,s)&&(t[s]=n[s])}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,s,r){"use strict";function i(t,e,n,s){var r,i=arguments.length,o=i<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,n):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,n,s);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(o=(i<3?r(o):i>3?r(e,n,o):r(e,n))||o);return i>3&&o&&Object.defineProperty(e,n,o),o}function o(t,e,n,s){return new(n||(n=Promise))((function(r,i){function o(t){try{l(s.next(t))}catch(t){i(t)}}function a(t){try{l(s.throw(t))}catch(t){i(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}l((s=s.apply(t,e||[])).next())}))}class a extends n.Component{constructor(){super(...arguments),this.text="",this.style={}}init(t){const n=new e.TextStyle({fontSize:20}),s={};for(const t in n)0===t.indexOf("_")&&(s[t.substring(1)]=n[t]);delete s.styleKey,this.style=s,t&&(this.text=t.text,_extends(this.style,t.style))}}a.componentName="Text",i([function(t){return function(e,n){var s=function(t,e){return t.constructor.IDEProps||(t.constructor.IDEProps={}),t.constructor.IDEProps[e]||(t.constructor.IDEProps[e]={}),t.constructor.IDEProps[e]}(e,n);s.key=n,s.type=t}}("string")],a.prototype,"text",void 0);let l=class extends s.Renderer{constructor(){super(...arguments),this.name="Text",this.texts={},this._lastFontFamily=void 0}init(){this.renderSystem=this.game.getSystem(s.RendererSystem),this.renderSystem.rendererManager.register(this)}componentChanged(t){return o(this,void 0,void 0,(function*(){if("Text"===t.componentName)if(t.type===n.OBSERVER_TYPE.ADD){const e=t.component,n=new r.Text(e.text,e.style);this.containerManager.getContainer(t.gameObject.id).addChildAt(n,0),this.texts[t.gameObject.id]={text:n,component:t.component},this.setSize(t)}else 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]):(this.change(t),this.setSize(t))}))}change(t){const{text:e,component:n}=this.texts[t.gameObject.id];"text"===t.prop.prop[0]?e.text=n.text:"style"===t.prop.prop[0]&&_extends(e.style,t.component.style),e.style.fontFamily&&e.style.fontFamily!==this._lastFontFamily&&(this._lastFontFamily=e.style.fontFamily,this.asyncChangeTextStyle(e,e.style))}asyncChangeTextStyle(t,e){if(e.fontFamily){const n=e.fontFamily;e.fontFamily="",this.asyncUpdateFontFamily(t,n)}_extends(t.style,e)}asyncUpdateFontFamily(t,e){e&&(Array.isArray(e)?Promise.all(e.map((t=>n.resource.getResource(t)))).finally((()=>{t.style.fontFamily=e})):n.resource.getResource(e).finally((()=>{t.style.fontFamily=e})))}setSize(t){const{transform:e}=t.gameObject;e&&(e.size.width=this.texts[t.gameObject.id].text.width,e.size.height=this.texts[t.gameObject.id].text.height)}};l.systemName="Text",l=i([n.decorators.componentObserver({Text:["text",{prop:["style"],deep:!0}]})],l);var c=l;return t.Text=a,t.TextSystem=c,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;
@@ -73,6 +73,7 @@ let Text = class Text extends pluginRenderer.Renderer {
73
73
  super(...arguments);
74
74
  this.name = 'Text';
75
75
  this.texts = {};
76
+ this._lastFontFamily = undefined;
76
77
  }
77
78
  init() {
78
79
  this.renderSystem = this.game.getSystem(pluginRenderer.RendererSystem);
@@ -111,6 +112,10 @@ let Text = class Text extends pluginRenderer.Renderer {
111
112
  else if (changed.prop.prop[0] === 'style') {
112
113
  Object.assign(text.style, changed.component.style);
113
114
  }
115
+ if (text.style.fontFamily && text.style.fontFamily !== this._lastFontFamily) {
116
+ this._lastFontFamily = text.style.fontFamily;
117
+ this.asyncChangeTextStyle(text, text.style);
118
+ }
114
119
  }
115
120
  asyncChangeTextStyle(text, textStyle) {
116
121
  if (textStyle.fontFamily) {
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("pixi.js"),t=require("@eva/eva.js"),n=require("@eva/inspector-decorator"),s=require("@eva/plugin-renderer"),i=require("@eva/renderer-adapter");
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("pixi.js"),t=require("@eva/eva.js"),s=require("@eva/inspector-decorator"),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 r(e,t,n,s){var i,r=arguments.length,o=r<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,n):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,s);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(o=(r<3?i(o):r>3?i(t,n,o):i(t,n))||o);return r>3&&o&&Object.defineProperty(t,n,o),o}class o extends t.Component{constructor(){super(...arguments),this.text="",this.style={}}init(t){const n=new e.TextStyle({fontSize:20}),s={};for(const e in n)0===e.indexOf("_")&&(s[e.substring(1)]=n[e]);delete s.styleKey,this.style=s,t&&(this.text=t.text,Object.assign(this.style,t.style))}}o.componentName="Text",r([n.type("string")],o.prototype,"text",void 0);let a=class extends s.Renderer{constructor(){super(...arguments),this.name="Text",this.texts={}}init(){this.renderSystem=this.game.getSystem(s.RendererSystem),this.renderSystem.rendererManager.register(this)}componentChanged(e){return n=this,s=void 0,o=function*(){if("Text"===e.componentName)if(e.type===t.OBSERVER_TYPE.ADD){const t=e.component,n=new i.Text(t.text,t.style);this.containerManager.getContainer(e.gameObject.id).addChildAt(n,0),this.texts[e.gameObject.id]={text:n,component:e.component},this.setSize(e)}else 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]):(this.change(e),this.setSize(e))},new((r=void 0)||(r=Promise))((function(e,t){function i(e){try{c(o.next(e))}catch(e){t(e)}}function a(e){try{c(o.throw(e))}catch(e){t(e)}}function c(t){t.done?e(t.value):new r((function(e){e(t.value)})).then(i,a)}c((o=o.apply(n,s||[])).next())}));var n,s,r,o}change(e){const{text:t,component:n}=this.texts[e.gameObject.id];"text"===e.prop.prop[0]?t.text=n.text:"style"===e.prop.prop[0]&&Object.assign(t.style,e.component.style)}asyncChangeTextStyle(e,t){if(t.fontFamily){const n=t.fontFamily;t.fontFamily="",this.asyncUpdateFontFamily(e,n)}Object.assign(e.style,t)}asyncUpdateFontFamily(e,n){n&&(Array.isArray(n)?Promise.all(n.map((e=>t.resource.getResource(e)))).finally((()=>{e.style.fontFamily=n})):t.resource.getResource(n).finally((()=>{e.style.fontFamily=n})))}setSize(e){const{transform:t}=e.gameObject;t&&(t.size.width=this.texts[e.gameObject.id].text.width,t.size.height=this.texts[e.gameObject.id].text.height)}};a.systemName="Text",a=r([t.decorators.componentObserver({Text:["text",{prop:["style"],deep:!0}]})],a);var c=a;exports.Text=o,exports.TextSystem=c;
16
+ function r(e,t,s,n){var i,r=arguments.length,o=r<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,s):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,s,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(o=(r<3?i(o):r>3?i(t,s,o):i(t,s))||o);return r>3&&o&&Object.defineProperty(t,s,o),o}class o extends t.Component{constructor(){super(...arguments),this.text="",this.style={}}init(t){const s=new e.TextStyle({fontSize:20}),n={};for(const e in s)0===e.indexOf("_")&&(n[e.substring(1)]=s[e]);delete n.styleKey,this.style=n,t&&(this.text=t.text,Object.assign(this.style,t.style))}}o.componentName="Text",r([s.type("string")],o.prototype,"text",void 0);let a=class extends n.Renderer{constructor(){super(...arguments),this.name="Text",this.texts={},this._lastFontFamily=void 0}init(){this.renderSystem=this.game.getSystem(n.RendererSystem),this.renderSystem.rendererManager.register(this)}componentChanged(e){return s=this,n=void 0,o=function*(){if("Text"===e.componentName)if(e.type===t.OBSERVER_TYPE.ADD){const t=e.component,s=new i.Text(t.text,t.style);this.containerManager.getContainer(e.gameObject.id).addChildAt(s,0),this.texts[e.gameObject.id]={text:s,component:e.component},this.setSize(e)}else 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]):(this.change(e),this.setSize(e))},new((r=void 0)||(r=Promise))((function(e,t){function i(e){try{c(o.next(e))}catch(e){t(e)}}function a(e){try{c(o.throw(e))}catch(e){t(e)}}function c(t){t.done?e(t.value):new r((function(e){e(t.value)})).then(i,a)}c((o=o.apply(s,n||[])).next())}));var s,n,r,o}change(e){const{text:t,component:s}=this.texts[e.gameObject.id];"text"===e.prop.prop[0]?t.text=s.text:"style"===e.prop.prop[0]&&Object.assign(t.style,e.component.style),t.style.fontFamily&&t.style.fontFamily!==this._lastFontFamily&&(this._lastFontFamily=t.style.fontFamily,this.asyncChangeTextStyle(t,t.style))}asyncChangeTextStyle(e,t){if(t.fontFamily){const s=t.fontFamily;t.fontFamily="",this.asyncUpdateFontFamily(e,s)}Object.assign(e.style,t)}asyncUpdateFontFamily(e,s){s&&(Array.isArray(s)?Promise.all(s.map((e=>t.resource.getResource(e)))).finally((()=>{e.style.fontFamily=s})):t.resource.getResource(s).finally((()=>{e.style.fontFamily=s})))}setSize(e){const{transform:t}=e.gameObject;t&&(t.size.width=this.texts[e.gameObject.id].text.width,t.size.height=this.texts[e.gameObject.id].text.height)}};a.systemName="Text",a=r([t.decorators.componentObserver({Text:["text",{prop:["style"],deep:!0}]})],a);var c=a;exports.Text=o,exports.TextSystem=c;
@@ -67,6 +67,7 @@ export declare class TextSystem extends Renderer {
67
67
  renderSystem: RendererSystem;
68
68
  rendererManager: RendererManager;
69
69
  containerManager: ContainerManager;
70
+ _lastFontFamily: string | string[] | undefined;
70
71
  init(): void;
71
72
  componentChanged(changed: ComponentChanged): Promise<void>;
72
73
  change(changed: ComponentChanged): void;
@@ -69,6 +69,7 @@ let Text = class Text extends Renderer {
69
69
  super(...arguments);
70
70
  this.name = 'Text';
71
71
  this.texts = {};
72
+ this._lastFontFamily = undefined;
72
73
  }
73
74
  init() {
74
75
  this.renderSystem = this.game.getSystem(RendererSystem);
@@ -107,6 +108,10 @@ let Text = class Text extends Renderer {
107
108
  else if (changed.prop.prop[0] === 'style') {
108
109
  Object.assign(text.style, changed.component.style);
109
110
  }
111
+ if (text.style.fontFamily && text.style.fontFamily !== this._lastFontFamily) {
112
+ this._lastFontFamily = text.style.fontFamily;
113
+ this.asyncChangeTextStyle(text, text.style);
114
+ }
110
115
  }
111
116
  asyncChangeTextStyle(text, textStyle) {
112
117
  if (textStyle.fontFamily) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eva/plugin-renderer-text",
3
- "version": "2.0.1-beta.16",
3
+ "version": "2.0.1-beta.18",
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.16",
23
- "@eva/renderer-adapter": "2.0.1-beta.16",
24
- "@eva/eva.js": "2.0.1-beta.16",
22
+ "@eva/plugin-renderer": "2.0.1-beta.18",
23
+ "@eva/renderer-adapter": "2.0.1-beta.18",
24
+ "@eva/eva.js": "2.0.1-beta.18",
25
25
  "pixi.js": "^8.8.1"
26
26
  }
27
27
  }