@eva/plugin-renderer-text 2.0.1-beta.6 → 2.0.1-beta.8
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 +21 -0
- package/dist/EVA.plugin.renderer.text.min.js +1 -1
- package/dist/plugin-renderer-text.cjs.js +22 -0
- package/dist/plugin-renderer-text.cjs.prod.js +2 -2
- package/dist/plugin-renderer-text.d.ts +2 -0
- package/dist/plugin-renderer-text.esm.js +23 -1
- package/package.json +4 -4
|
@@ -126,6 +126,27 @@ var _EVA_IIFE_text = function (exports, pixi_js, eva_js, pluginRenderer, rendere
|
|
|
126
126
|
_extends(text.style, changed.component.style);
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
+
asyncChangeTextStyle(text, textStyle) {
|
|
130
|
+
if (textStyle.fontFamily) {
|
|
131
|
+
const fontFamily = textStyle.fontFamily;
|
|
132
|
+
textStyle.fontFamily = '';
|
|
133
|
+
this.asyncUpdateFontFamily(text, fontFamily);
|
|
134
|
+
}
|
|
135
|
+
_extends(text.style, textStyle);
|
|
136
|
+
}
|
|
137
|
+
asyncUpdateFontFamily(text, fontFamily) {
|
|
138
|
+
if (fontFamily) {
|
|
139
|
+
if (Array.isArray(fontFamily)) {
|
|
140
|
+
Promise.all(fontFamily.map(font => eva_js.resource.getResource(font))).finally(() => {
|
|
141
|
+
text.style.fontFamily = fontFamily;
|
|
142
|
+
});
|
|
143
|
+
} else {
|
|
144
|
+
eva_js.resource.getResource(fontFamily).finally(() => {
|
|
145
|
+
text.style.fontFamily = fontFamily;
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
129
150
|
setSize(changed) {
|
|
130
151
|
const {
|
|
131
152
|
transform
|
|
@@ -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)}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(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;
|
|
@@ -112,6 +112,28 @@ let Text = class Text extends pluginRenderer.Renderer {
|
|
|
112
112
|
Object.assign(text.style, changed.component.style);
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
|
+
asyncChangeTextStyle(text, textStyle) {
|
|
116
|
+
if (textStyle.fontFamily) {
|
|
117
|
+
const fontFamily = textStyle.fontFamily;
|
|
118
|
+
textStyle.fontFamily = '';
|
|
119
|
+
this.asyncUpdateFontFamily(text, fontFamily);
|
|
120
|
+
}
|
|
121
|
+
Object.assign(text.style, textStyle);
|
|
122
|
+
}
|
|
123
|
+
asyncUpdateFontFamily(text, fontFamily) {
|
|
124
|
+
if (fontFamily) {
|
|
125
|
+
if (Array.isArray(fontFamily)) {
|
|
126
|
+
Promise.all(fontFamily.map(font => eva_js.resource.getResource(font))).finally(() => {
|
|
127
|
+
text.style.fontFamily = fontFamily;
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
eva_js.resource.getResource(fontFamily).finally(() => {
|
|
132
|
+
text.style.fontFamily = fontFamily;
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
115
137
|
setSize(changed) {
|
|
116
138
|
const { transform } = changed.gameObject;
|
|
117
139
|
if (!transform)
|
|
@@ -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"),
|
|
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");
|
|
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
|
|
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;
|
|
@@ -70,6 +70,8 @@ export declare class TextSystem extends Renderer {
|
|
|
70
70
|
init(): void;
|
|
71
71
|
componentChanged(changed: ComponentChanged): Promise<void>;
|
|
72
72
|
change(changed: ComponentChanged): void;
|
|
73
|
+
asyncChangeTextStyle(text: Text_3, textStyle: TextParams['style']): void;
|
|
74
|
+
asyncUpdateFontFamily(text: Text_3, fontFamily: string | string[] | undefined): void;
|
|
73
75
|
setSize(changed: ComponentChanged): void;
|
|
74
76
|
}
|
|
75
77
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TextStyle } from 'pixi.js';
|
|
2
|
-
import { Component, decorators, OBSERVER_TYPE } from '@eva/eva.js';
|
|
2
|
+
import { Component, resource, decorators, OBSERVER_TYPE } from '@eva/eva.js';
|
|
3
3
|
import { type } from '@eva/inspector-decorator';
|
|
4
4
|
import { Renderer, RendererSystem } from '@eva/plugin-renderer';
|
|
5
5
|
import { Text as Text$3 } from '@eva/renderer-adapter';
|
|
@@ -108,6 +108,28 @@ let Text = class Text extends Renderer {
|
|
|
108
108
|
Object.assign(text.style, changed.component.style);
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
|
+
asyncChangeTextStyle(text, textStyle) {
|
|
112
|
+
if (textStyle.fontFamily) {
|
|
113
|
+
const fontFamily = textStyle.fontFamily;
|
|
114
|
+
textStyle.fontFamily = '';
|
|
115
|
+
this.asyncUpdateFontFamily(text, fontFamily);
|
|
116
|
+
}
|
|
117
|
+
Object.assign(text.style, textStyle);
|
|
118
|
+
}
|
|
119
|
+
asyncUpdateFontFamily(text, fontFamily) {
|
|
120
|
+
if (fontFamily) {
|
|
121
|
+
if (Array.isArray(fontFamily)) {
|
|
122
|
+
Promise.all(fontFamily.map(font => resource.getResource(font))).finally(() => {
|
|
123
|
+
text.style.fontFamily = fontFamily;
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
resource.getResource(fontFamily).finally(() => {
|
|
128
|
+
text.style.fontFamily = fontFamily;
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
111
133
|
setSize(changed) {
|
|
112
134
|
const { transform } = changed.gameObject;
|
|
113
135
|
if (!transform)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eva/plugin-renderer-text",
|
|
3
|
-
"version": "2.0.1-beta.
|
|
3
|
+
"version": "2.0.1-beta.8",
|
|
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.
|
|
23
|
-
"@eva/renderer-adapter": "2.0.1-beta.
|
|
24
|
-
"@eva/eva.js": "2.0.1-beta.
|
|
22
|
+
"@eva/plugin-renderer": "2.0.1-beta.8",
|
|
23
|
+
"@eva/renderer-adapter": "2.0.1-beta.8",
|
|
24
|
+
"@eva/eva.js": "2.0.1-beta.8",
|
|
25
25
|
"pixi.js": "^8.8.1"
|
|
26
26
|
}
|
|
27
27
|
}
|