@eva/plugin-renderer-text 2.0.2 → 2.1.0-beta.2

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.
@@ -11,6 +11,9 @@ var _EVA_IIFE_text = function (exports, eva_js, pixi_js, pluginRenderer, rendere
11
11
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
12
12
  return c > 3 && r && Object.defineProperty(target, key, r), r;
13
13
  }
14
+ function __metadata(metadataKey, metadataValue) {
15
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
16
+ }
14
17
  function __awaiter(thisArg, _arguments, P, generator) {
15
18
  function adopt(value) {
16
19
  return value instanceof P ? value : new P(function (resolve) {
@@ -38,23 +41,21 @@ var _EVA_IIFE_text = function (exports, eva_js, pixi_js, pluginRenderer, rendere
38
41
  step((generator = generator.apply(thisArg, _arguments || [])).next());
39
42
  });
40
43
  }
41
- function getIDEPropsPropertyObj(target, propertyKey) {
42
- if (!target.constructor.IDEProps) {
43
- target.constructor.IDEProps = {};
44
- }
45
- if (!target.constructor.IDEProps[propertyKey]) {
46
- target.constructor.IDEProps[propertyKey] = {};
47
- }
48
- var propertyObj = target.constructor.IDEProps[propertyKey];
49
- return propertyObj;
50
- }
51
- function type(type) {
52
- return function (target, propertyKey) {
53
- var prop = getIDEPropsPropertyObj(target, propertyKey);
54
- prop.key = propertyKey;
55
- prop.type = type;
56
- };
57
- }
44
+ class BitmapTextStyleMetadata {}
45
+ __decorate([eva_js.type('string'), __metadata("design:type", Object)], BitmapTextStyleMetadata.prototype, "fontFamily", void 0);
46
+ __decorate([eva_js.type('number'), __metadata("design:type", Object)], BitmapTextStyleMetadata.prototype, "fontSize", void 0);
47
+ __decorate([eva_js.Field({
48
+ type: 'color'
49
+ }), __metadata("design:type", Object)], BitmapTextStyleMetadata.prototype, "fill", void 0);
50
+ __decorate([eva_js.type('string'), __metadata("design:type", String)], BitmapTextStyleMetadata.prototype, "align", void 0);
51
+ __decorate([eva_js.type('number'), __metadata("design:type", Number)], BitmapTextStyleMetadata.prototype, "letterSpacing", void 0);
52
+ __decorate([eva_js.type('number'), __metadata("design:type", Number)], BitmapTextStyleMetadata.prototype, "padding", void 0);
53
+ __decorate([eva_js.Field({
54
+ type: 'color'
55
+ }), __metadata("design:type", Object)], BitmapTextStyleMetadata.prototype, "stroke", void 0);
56
+ __decorate([eva_js.type('number'), __metadata("design:type", Number)], BitmapTextStyleMetadata.prototype, "strokeThickness", void 0);
57
+ __decorate([eva_js.type('string'), __metadata("design:type", String)], BitmapTextStyleMetadata.prototype, "fontWeight", void 0);
58
+ __decorate([eva_js.type('string'), __metadata("design:type", String)], BitmapTextStyleMetadata.prototype, "fontStyle", void 0);
58
59
  class BitmapText extends eva_js.Component {
59
60
  constructor() {
60
61
  super(...arguments);
@@ -73,12 +74,66 @@ var _EVA_IIFE_text = function (exports, eva_js, pixi_js, pluginRenderer, rendere
73
74
  }
74
75
  }
75
76
  BitmapText.componentName = 'BitmapText';
76
- __decorate([type('string')], BitmapText.prototype, "text", void 0);
77
+ __decorate([eva_js.type('string'), __metadata("design:type", String)], BitmapText.prototype, "text", void 0);
78
+ __decorate([eva_js.Field(() => BitmapTextStyleMetadata), __metadata("design:type", Object)], BitmapText.prototype, "style", void 0);
79
+ class TextStyleStrokeMetadata {}
80
+ __decorate([eva_js.type('number'), __metadata("design:type", Number)], TextStyleStrokeMetadata.prototype, "alpha", void 0);
81
+ __decorate([eva_js.Field({
82
+ type: 'color'
83
+ }), __metadata("design:type", Object)], TextStyleStrokeMetadata.prototype, "color", void 0);
84
+ __decorate([eva_js.type('string'), __metadata("design:type", String)], TextStyleStrokeMetadata.prototype, "join", void 0);
85
+ __decorate([eva_js.type('number'), __metadata("design:type", Number)], TextStyleStrokeMetadata.prototype, "miterLimit", void 0);
86
+ __decorate([eva_js.type('number'), __metadata("design:type", Number)], TextStyleStrokeMetadata.prototype, "width", void 0);
87
+ class TextStyleDropShadowMetadata {}
88
+ __decorate([eva_js.type('number'), __metadata("design:type", Number)], TextStyleDropShadowMetadata.prototype, "alpha", void 0);
89
+ __decorate([eva_js.type('number'), __metadata("design:type", Number)], TextStyleDropShadowMetadata.prototype, "angle", void 0);
90
+ __decorate([eva_js.type('number'), __metadata("design:type", Number)], TextStyleDropShadowMetadata.prototype, "blur", void 0);
91
+ __decorate([eva_js.Field({
92
+ type: 'color'
93
+ }), __metadata("design:type", Object)], TextStyleDropShadowMetadata.prototype, "color", void 0);
94
+ __decorate([eva_js.type('number'), __metadata("design:type", Number)], TextStyleDropShadowMetadata.prototype, "distance", void 0);
95
+ __decorate([eva_js.type('boolean'), __metadata("design:type", Boolean)], TextStyleDropShadowMetadata.prototype, "enabled", void 0);
96
+ class TextStyleMetadata {}
97
+ __decorate([eva_js.type('string'), __metadata("design:type", String)], TextStyleMetadata.prototype, "align", void 0);
98
+ __decorate([eva_js.type('boolean'), __metadata("design:type", Boolean)], TextStyleMetadata.prototype, "breakWords", void 0);
99
+ __decorate([eva_js.Field(() => TextStyleDropShadowMetadata), __metadata("design:type", Object)], TextStyleMetadata.prototype, "dropShadow", void 0);
100
+ __decorate([eva_js.type('number'), __metadata("design:type", Number)], TextStyleMetadata.prototype, "dropShadowAlpha", void 0);
101
+ __decorate([eva_js.type('number'), __metadata("design:type", Number)], TextStyleMetadata.prototype, "dropShadowAngle", void 0);
102
+ __decorate([eva_js.type('number'), __metadata("design:type", Number)], TextStyleMetadata.prototype, "dropShadowBlur", void 0);
103
+ __decorate([eva_js.Field({
104
+ type: 'color'
105
+ }), __metadata("design:type", Object)], TextStyleMetadata.prototype, "dropShadowColor", void 0);
106
+ __decorate([eva_js.type('number'), __metadata("design:type", Number)], TextStyleMetadata.prototype, "dropShadowDistance", void 0);
107
+ __decorate([eva_js.Field({
108
+ type: 'color'
109
+ }), __metadata("design:type", Object)], TextStyleMetadata.prototype, "fill", void 0);
110
+ __decorate([eva_js.type('number'), __metadata("design:type", Number)], TextStyleMetadata.prototype, "fillGradientType", void 0);
111
+ __decorate([eva_js.type('number'), __metadata("design:type", Array)], TextStyleMetadata.prototype, "fillGradientStops", void 0);
112
+ __decorate([eva_js.type('string'), __metadata("design:type", Object)], TextStyleMetadata.prototype, "fontFamily", void 0);
113
+ __decorate([eva_js.type('number'), __metadata("design:type", Object)], TextStyleMetadata.prototype, "fontSize", void 0);
114
+ __decorate([eva_js.type('string'), __metadata("design:type", String)], TextStyleMetadata.prototype, "fontStyle", void 0);
115
+ __decorate([eva_js.type('string'), __metadata("design:type", String)], TextStyleMetadata.prototype, "fontVariant", void 0);
116
+ __decorate([eva_js.type('string'), __metadata("design:type", String)], TextStyleMetadata.prototype, "fontWeight", void 0);
117
+ __decorate([eva_js.type('number'), __metadata("design:type", Number)], TextStyleMetadata.prototype, "leading", void 0);
118
+ __decorate([eva_js.type('number'), __metadata("design:type", Number)], TextStyleMetadata.prototype, "letterSpacing", void 0);
119
+ __decorate([eva_js.type('number'), __metadata("design:type", Number)], TextStyleMetadata.prototype, "lineHeight", void 0);
120
+ __decorate([eva_js.type('string'), __metadata("design:type", String)], TextStyleMetadata.prototype, "lineJoin", void 0);
121
+ __decorate([eva_js.type('number'), __metadata("design:type", Number)], TextStyleMetadata.prototype, "miterLimit", void 0);
122
+ __decorate([eva_js.type('number'), __metadata("design:type", Number)], TextStyleMetadata.prototype, "padding", void 0);
123
+ __decorate([eva_js.Field(() => TextStyleStrokeMetadata), __metadata("design:type", Object)], TextStyleMetadata.prototype, "stroke", void 0);
124
+ __decorate([eva_js.type('number'), __metadata("design:type", Number)], TextStyleMetadata.prototype, "strokeThickness", void 0);
125
+ __decorate([eva_js.type('string'), __metadata("design:type", String)], TextStyleMetadata.prototype, "textBaseline", void 0);
126
+ __decorate([eva_js.type('string'), __metadata("design:type", String)], TextStyleMetadata.prototype, "verticalAlign", void 0);
127
+ __decorate([eva_js.type('boolean'), __metadata("design:type", Boolean)], TextStyleMetadata.prototype, "trim", void 0);
128
+ __decorate([eva_js.type('string'), __metadata("design:type", String)], TextStyleMetadata.prototype, "whiteSpace", void 0);
129
+ __decorate([eva_js.type('boolean'), __metadata("design:type", Boolean)], TextStyleMetadata.prototype, "wordWrap", void 0);
130
+ __decorate([eva_js.type('number'), __metadata("design:type", Number)], TextStyleMetadata.prototype, "wordWrapWidth", void 0);
77
131
  class Text$2 extends eva_js.Component {
78
- constructor() {
79
- super(...arguments);
132
+ constructor(params) {
133
+ super(params);
80
134
  this.text = '';
81
135
  this.style = {};
136
+ this.init(params);
82
137
  }
83
138
  init(obj) {
84
139
  const style = new pixi_js.TextStyle({
@@ -99,7 +154,44 @@ var _EVA_IIFE_text = function (exports, eva_js, pixi_js, pluginRenderer, rendere
99
154
  }
100
155
  }
101
156
  Text$2.componentName = 'Text';
102
- __decorate([type('string')], Text$2.prototype, "text", void 0);
157
+ __decorate([eva_js.type('string'), __metadata("design:type", String)], Text$2.prototype, "text", void 0);
158
+ __decorate([eva_js.Field(() => TextStyleMetadata), __metadata("design:type", Object)], Text$2.prototype, "style", void 0);
159
+ class HTMLTextTextureStyleMetadata {}
160
+ __decorate([eva_js.type('string'), __metadata("design:type", String)], HTMLTextTextureStyleMetadata.prototype, "scaleMode", void 0);
161
+ __decorate([eva_js.type('number'), __metadata("design:type", Number)], HTMLTextTextureStyleMetadata.prototype, "resolution", void 0);
162
+ class HTMLTextStyleMetadata {}
163
+ __decorate([eva_js.type('string'), __metadata("design:type", Object)], HTMLTextStyleMetadata.prototype, "fontFamily", void 0);
164
+ __decorate([eva_js.type('number'), __metadata("design:type", Object)], HTMLTextStyleMetadata.prototype, "fontSize", void 0);
165
+ __decorate([eva_js.type('string'), __metadata("design:type", String)], HTMLTextStyleMetadata.prototype, "fontWeight", void 0);
166
+ __decorate([eva_js.type('string'), __metadata("design:type", String)], HTMLTextStyleMetadata.prototype, "fontStyle", void 0);
167
+ __decorate([eva_js.type('string'), __metadata("design:type", String)], HTMLTextStyleMetadata.prototype, "fontVariant", void 0);
168
+ __decorate([eva_js.type('string'), __metadata("design:type", String)], HTMLTextStyleMetadata.prototype, "align", void 0);
169
+ __decorate([eva_js.type('string'), __metadata("design:type", String)], HTMLTextStyleMetadata.prototype, "textBaseline", void 0);
170
+ __decorate([eva_js.Field({
171
+ type: 'color'
172
+ }), __metadata("design:type", Object)], HTMLTextStyleMetadata.prototype, "fill", void 0);
173
+ __decorate([eva_js.Field({
174
+ type: 'color'
175
+ }), __metadata("design:type", Object)], HTMLTextStyleMetadata.prototype, "stroke", void 0);
176
+ __decorate([eva_js.type('number'), __metadata("design:type", Number)], HTMLTextStyleMetadata.prototype, "strokeThickness", void 0);
177
+ __decorate([eva_js.type('number'), __metadata("design:type", Number)], HTMLTextStyleMetadata.prototype, "lineHeight", void 0);
178
+ __decorate([eva_js.type('number'), __metadata("design:type", Number)], HTMLTextStyleMetadata.prototype, "letterSpacing", void 0);
179
+ __decorate([eva_js.type('number'), __metadata("design:type", Number)], HTMLTextStyleMetadata.prototype, "padding", void 0);
180
+ __decorate([eva_js.type('boolean'), __metadata("design:type", Boolean)], HTMLTextStyleMetadata.prototype, "wordWrap", void 0);
181
+ __decorate([eva_js.type('number'), __metadata("design:type", Number)], HTMLTextStyleMetadata.prototype, "wordWrapWidth", void 0);
182
+ __decorate([eva_js.type('boolean'), __metadata("design:type", Boolean)], HTMLTextStyleMetadata.prototype, "breakWords", void 0);
183
+ __decorate([eva_js.type('string'), __metadata("design:type", String)], HTMLTextStyleMetadata.prototype, "whiteSpace", void 0);
184
+ __decorate([eva_js.type('boolean'), __metadata("design:type", Boolean)], HTMLTextStyleMetadata.prototype, "dropShadow", void 0);
185
+ __decorate([eva_js.Field({
186
+ type: 'color'
187
+ }), __metadata("design:type", Object)], HTMLTextStyleMetadata.prototype, "dropShadowColor", void 0);
188
+ __decorate([eva_js.type('number'), __metadata("design:type", Number)], HTMLTextStyleMetadata.prototype, "dropShadowAlpha", void 0);
189
+ __decorate([eva_js.type('number'), __metadata("design:type", Number)], HTMLTextStyleMetadata.prototype, "dropShadowAngle", void 0);
190
+ __decorate([eva_js.type('number'), __metadata("design:type", Number)], HTMLTextStyleMetadata.prototype, "dropShadowBlur", void 0);
191
+ __decorate([eva_js.type('number'), __metadata("design:type", Number)], HTMLTextStyleMetadata.prototype, "dropShadowDistance", void 0);
192
+ __decorate([eva_js.type('object'), __metadata("design:type", Array)], HTMLTextStyleMetadata.prototype, "cssOverrides", void 0);
193
+ __decorate([eva_js.type('object'), __metadata("design:type", Object)], HTMLTextStyleMetadata.prototype, "tagStyles", void 0);
194
+ __decorate([eva_js.type('boolean'), __metadata("design:type", Boolean)], HTMLTextStyleMetadata.prototype, "trim", void 0);
103
195
  class HTMLText extends eva_js.Component {
104
196
  constructor() {
105
197
  super(...arguments);
@@ -123,7 +215,9 @@ var _EVA_IIFE_text = function (exports, eva_js, pixi_js, pluginRenderer, rendere
123
215
  }
124
216
  }
125
217
  HTMLText.componentName = 'HTMLText';
126
- __decorate([type('string')], HTMLText.prototype, "text", void 0);
218
+ __decorate([eva_js.type('string'), __metadata("design:type", String)], HTMLText.prototype, "text", void 0);
219
+ __decorate([eva_js.Field(() => HTMLTextStyleMetadata), __metadata("design:type", Object)], HTMLText.prototype, "style", void 0);
220
+ __decorate([eva_js.Field(() => HTMLTextTextureStyleMetadata), __metadata("design:type", Object)], HTMLText.prototype, "textureStyle", void 0);
127
221
  let Text = class Text extends pluginRenderer.Renderer {
128
222
  constructor() {
129
223
  super(...arguments);
@@ -171,7 +265,7 @@ var _EVA_IIFE_text = function (exports, eva_js, pixi_js, pluginRenderer, rendere
171
265
  addTextComponent(changed) {
172
266
  return __awaiter(this, void 0, void 0, function* () {
173
267
  const component = changed.component;
174
- const styleWithoutFont = _extends({}, component.style);
268
+ const styleWithoutFont = this.processStyle(component.style);
175
269
  const fontFamily = styleWithoutFont.fontFamily;
176
270
  delete styleWithoutFont.fontFamily;
177
271
  const initialText = fontFamily ? '' : component.text;
@@ -189,7 +283,7 @@ var _EVA_IIFE_text = function (exports, eva_js, pixi_js, pluginRenderer, rendere
189
283
  addHTMLTextComponent(changed) {
190
284
  return __awaiter(this, void 0, void 0, function* () {
191
285
  const component = changed.component;
192
- const styleWithoutFont = _extends({}, component.style);
286
+ const styleWithoutFont = this.processStyle(component.style);
193
287
  const fontFamily = styleWithoutFont.fontFamily;
194
288
  delete styleWithoutFont.fontFamily;
195
289
  const initialText = fontFamily ? '' : component.text;
@@ -212,7 +306,7 @@ var _EVA_IIFE_text = function (exports, eva_js, pixi_js, pluginRenderer, rendere
212
306
  addBitmapTextComponent(changed) {
213
307
  return __awaiter(this, void 0, void 0, function* () {
214
308
  const component = changed.component;
215
- const styleWithoutFont = _extends({}, component.style);
309
+ const styleWithoutFont = this.processStyle(component.style);
216
310
  const fontFamily = styleWithoutFont.fontFamily;
217
311
  delete styleWithoutFont.fontFamily;
218
312
  const initialText = fontFamily ? '' : component.text;
@@ -255,30 +349,31 @@ var _EVA_IIFE_text = function (exports, eva_js, pixi_js, pluginRenderer, rendere
255
349
  };
256
350
  delete processed.strokeThickness;
257
351
  }
258
- if (processed.dropShadow) {
259
- const dropShadowConfig = {};
352
+ const hasFlatDropShadowAlias = processed.dropShadowColor != null || processed.dropShadowDistance != null || processed.dropShadowAngle != null || processed.dropShadowAlpha != null || processed.dropShadowBlur != null;
353
+ if (processed.dropShadow && hasFlatDropShadowAlias) {
354
+ const base = processed.dropShadow && typeof processed.dropShadow === 'object' && !Array.isArray(processed.dropShadow) ? _extends({}, processed.dropShadow) : {};
260
355
  if (processed.dropShadowColor != null) {
261
- dropShadowConfig.color = processed.dropShadowColor;
356
+ base.color = processed.dropShadowColor;
262
357
  }
263
358
  if (processed.dropShadowDistance != null) {
264
- dropShadowConfig.distance = processed.dropShadowDistance;
359
+ base.distance = processed.dropShadowDistance;
265
360
  }
266
361
  if (processed.dropShadowAngle != null) {
267
- dropShadowConfig.angle = processed.dropShadowAngle;
362
+ base.angle = processed.dropShadowAngle;
268
363
  }
269
364
  if (processed.dropShadowAlpha != null) {
270
- dropShadowConfig.alpha = processed.dropShadowAlpha;
365
+ base.alpha = processed.dropShadowAlpha;
271
366
  }
272
367
  if (processed.dropShadowBlur != null) {
273
- dropShadowConfig.blur = processed.dropShadowBlur;
368
+ base.blur = processed.dropShadowBlur;
274
369
  }
275
- processed.dropShadow = dropShadowConfig;
276
- delete processed.dropShadowColor;
277
- delete processed.dropShadowDistance;
278
- delete processed.dropShadowAngle;
279
- delete processed.dropShadowAlpha;
280
- delete processed.dropShadowBlur;
370
+ processed.dropShadow = base;
281
371
  }
372
+ delete processed.dropShadowColor;
373
+ delete processed.dropShadowDistance;
374
+ delete processed.dropShadowAngle;
375
+ delete processed.dropShadowAlpha;
376
+ delete processed.dropShadowBlur;
282
377
  if (Array.isArray(processed.fill)) {
283
378
  processed.fill = processed.fill[0];
284
379
  }
@@ -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 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;
1
+ function _extends(){return _extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var i in o)({}).hasOwnProperty.call(o,i)&&(e[i]=o[i])}return e},_extends.apply(null,arguments)}globalThis.EVA=globalThis.EVA||{},globalThis.EVA.plugin=globalThis.EVA.plugin||{},globalThis.EVA.plugin.renderer=globalThis.EVA.plugin.renderer||{};var _EVA_IIFE_text=function(e,t,o,i,n){"use strict";function r(e,t,o,i){var n,r=arguments.length,p=r<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)p=Reflect.decorate(e,t,o,i);else for(var d=e.length-1;d>=0;d--)(n=e[d])&&(p=(r<3?n(p):r>3?n(t,o,p):n(t,o))||p);return r>3&&p&&Object.defineProperty(t,o,p),p}function p(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function d(e,t,o,i){return new(o||(o=Promise))(function(n,r){function p(e){try{s(i.next(e))}catch(e){r(e)}}function d(e){try{s(i.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?n(e.value):(t=e.value,t instanceof o?t:new o(function(e){e(t)})).then(p,d)}s((i=i.apply(e,t||[])).next())})}class s{}r([t.type("string"),p("design:type",Object)],s.prototype,"fontFamily",void 0),r([t.type("number"),p("design:type",Object)],s.prototype,"fontSize",void 0),r([t.Field({type:"color"}),p("design:type",Object)],s.prototype,"fill",void 0),r([t.type("string"),p("design:type",String)],s.prototype,"align",void 0),r([t.type("number"),p("design:type",Number)],s.prototype,"letterSpacing",void 0),r([t.type("number"),p("design:type",Number)],s.prototype,"padding",void 0),r([t.Field({type:"color"}),p("design:type",Object)],s.prototype,"stroke",void 0),r([t.type("number"),p("design:type",Number)],s.prototype,"strokeThickness",void 0),r([t.type("string"),p("design:type",String)],s.prototype,"fontWeight",void 0),r([t.type("string"),p("design:type",String)],s.prototype,"fontStyle",void 0);class y extends t.Component{constructor(){super(...arguments),this.text="",this.style={}}init(e){this.style=_extends({fontSize:24,fill:"#000000",fontFamily:"Arial"},null==e?void 0:e.style),e&&(this.text=e.text)}}y.componentName="BitmapText",r([t.type("string"),p("design:type",String)],y.prototype,"text",void 0),r([t.Field(()=>s),p("design:type",Object)],y.prototype,"style",void 0);class l{}r([t.type("number"),p("design:type",Number)],l.prototype,"alpha",void 0),r([t.Field({type:"color"}),p("design:type",Object)],l.prototype,"color",void 0),r([t.type("string"),p("design:type",String)],l.prototype,"join",void 0),r([t.type("number"),p("design:type",Number)],l.prototype,"miterLimit",void 0),r([t.type("number"),p("design:type",Number)],l.prototype,"width",void 0);class a{}r([t.type("number"),p("design:type",Number)],a.prototype,"alpha",void 0),r([t.type("number"),p("design:type",Number)],a.prototype,"angle",void 0),r([t.type("number"),p("design:type",Number)],a.prototype,"blur",void 0),r([t.Field({type:"color"}),p("design:type",Object)],a.prototype,"color",void 0),r([t.type("number"),p("design:type",Number)],a.prototype,"distance",void 0),r([t.type("boolean"),p("design:type",Boolean)],a.prototype,"enabled",void 0);class g{}r([t.type("string"),p("design:type",String)],g.prototype,"align",void 0),r([t.type("boolean"),p("design:type",Boolean)],g.prototype,"breakWords",void 0),r([t.Field(()=>a),p("design:type",Object)],g.prototype,"dropShadow",void 0),r([t.type("number"),p("design:type",Number)],g.prototype,"dropShadowAlpha",void 0),r([t.type("number"),p("design:type",Number)],g.prototype,"dropShadowAngle",void 0),r([t.type("number"),p("design:type",Number)],g.prototype,"dropShadowBlur",void 0),r([t.Field({type:"color"}),p("design:type",Object)],g.prototype,"dropShadowColor",void 0),r([t.type("number"),p("design:type",Number)],g.prototype,"dropShadowDistance",void 0),r([t.Field({type:"color"}),p("design:type",Object)],g.prototype,"fill",void 0),r([t.type("number"),p("design:type",Number)],g.prototype,"fillGradientType",void 0),r([t.type("number"),p("design:type",Array)],g.prototype,"fillGradientStops",void 0),r([t.type("string"),p("design:type",Object)],g.prototype,"fontFamily",void 0),r([t.type("number"),p("design:type",Object)],g.prototype,"fontSize",void 0),r([t.type("string"),p("design:type",String)],g.prototype,"fontStyle",void 0),r([t.type("string"),p("design:type",String)],g.prototype,"fontVariant",void 0),r([t.type("string"),p("design:type",String)],g.prototype,"fontWeight",void 0),r([t.type("number"),p("design:type",Number)],g.prototype,"leading",void 0),r([t.type("number"),p("design:type",Number)],g.prototype,"letterSpacing",void 0),r([t.type("number"),p("design:type",Number)],g.prototype,"lineHeight",void 0),r([t.type("string"),p("design:type",String)],g.prototype,"lineJoin",void 0),r([t.type("number"),p("design:type",Number)],g.prototype,"miterLimit",void 0),r([t.type("number"),p("design:type",Number)],g.prototype,"padding",void 0),r([t.Field(()=>l),p("design:type",Object)],g.prototype,"stroke",void 0),r([t.type("number"),p("design:type",Number)],g.prototype,"strokeThickness",void 0),r([t.type("string"),p("design:type",String)],g.prototype,"textBaseline",void 0),r([t.type("string"),p("design:type",String)],g.prototype,"verticalAlign",void 0),r([t.type("boolean"),p("design:type",Boolean)],g.prototype,"trim",void 0),r([t.type("string"),p("design:type",String)],g.prototype,"whiteSpace",void 0),r([t.type("boolean"),p("design:type",Boolean)],g.prototype,"wordWrap",void 0),r([t.type("number"),p("design:type",Number)],g.prototype,"wordWrapWidth",void 0);class c extends t.Component{constructor(e){super(e),this.text="",this.style={},this.init(e)}init(e){const t=new o.TextStyle({fontSize:20}),i={};for(const e in t)0===e.indexOf("_")&&(i[e.substring(1)]=t[e]);delete i.styleKey,this.style=i,e&&(this.text=e.text,_extends(this.style,e.style))}}c.componentName="Text",r([t.type("string"),p("design:type",String)],c.prototype,"text",void 0),r([t.Field(()=>g),p("design:type",Object)],c.prototype,"style",void 0);class u{}r([t.type("string"),p("design:type",String)],u.prototype,"scaleMode",void 0),r([t.type("number"),p("design:type",Number)],u.prototype,"resolution",void 0);class m{}r([t.type("string"),p("design:type",Object)],m.prototype,"fontFamily",void 0),r([t.type("number"),p("design:type",Object)],m.prototype,"fontSize",void 0),r([t.type("string"),p("design:type",String)],m.prototype,"fontWeight",void 0),r([t.type("string"),p("design:type",String)],m.prototype,"fontStyle",void 0),r([t.type("string"),p("design:type",String)],m.prototype,"fontVariant",void 0),r([t.type("string"),p("design:type",String)],m.prototype,"align",void 0),r([t.type("string"),p("design:type",String)],m.prototype,"textBaseline",void 0),r([t.Field({type:"color"}),p("design:type",Object)],m.prototype,"fill",void 0),r([t.Field({type:"color"}),p("design:type",Object)],m.prototype,"stroke",void 0),r([t.type("number"),p("design:type",Number)],m.prototype,"strokeThickness",void 0),r([t.type("number"),p("design:type",Number)],m.prototype,"lineHeight",void 0),r([t.type("number"),p("design:type",Number)],m.prototype,"letterSpacing",void 0),r([t.type("number"),p("design:type",Number)],m.prototype,"padding",void 0),r([t.type("boolean"),p("design:type",Boolean)],m.prototype,"wordWrap",void 0),r([t.type("number"),p("design:type",Number)],m.prototype,"wordWrapWidth",void 0),r([t.type("boolean"),p("design:type",Boolean)],m.prototype,"breakWords",void 0),r([t.type("string"),p("design:type",String)],m.prototype,"whiteSpace",void 0),r([t.type("boolean"),p("design:type",Boolean)],m.prototype,"dropShadow",void 0),r([t.Field({type:"color"}),p("design:type",Object)],m.prototype,"dropShadowColor",void 0),r([t.type("number"),p("design:type",Number)],m.prototype,"dropShadowAlpha",void 0),r([t.type("number"),p("design:type",Number)],m.prototype,"dropShadowAngle",void 0),r([t.type("number"),p("design:type",Number)],m.prototype,"dropShadowBlur",void 0),r([t.type("number"),p("design:type",Number)],m.prototype,"dropShadowDistance",void 0),r([t.type("object"),p("design:type",Array)],m.prototype,"cssOverrides",void 0),r([t.type("object"),p("design:type",Object)],m.prototype,"tagStyles",void 0),r([t.type("boolean"),p("design:type",Boolean)],m.prototype,"trim",void 0);class h extends t.Component{constructor(){super(...arguments),this.text="",this.style={},this.textureStyle={}}init(e){this.style=_extends({fontSize:24,fill:"#000000",fontFamily:"Arial"},null==e?void 0:e.style),this.textureStyle=_extends({scaleMode:"linear",resolution:window.devicePixelRatio||1},null==e?void 0:e.textureStyle),e&&(this.text=e.text)}}h.componentName="HTMLText",r([t.type("string"),p("design:type",String)],h.prototype,"text",void 0),r([t.Field(()=>m),p("design:type",Object)],h.prototype,"style",void 0),r([t.Field(()=>u),p("design:type",Object)],h.prototype,"textureStyle",void 0);let b=class extends i.Renderer{constructor(){super(...arguments),this.name="Text",this.texts={}}init(){this.renderSystem=this.game.getSystem(i.RendererSystem),this.renderSystem.rendererManager.register(this)}componentChanged(e){return d(this,void 0,void 0,function*(){const o="Text"===e.componentName,i="HTMLText"===e.componentName,n="BitmapText"===e.componentName;if(o||i||n)if(e.type===t.OBSERVER_TYPE.ADD)o?yield this.addTextComponent(e):i?yield this.addHTMLTextComponent(e):yield this.addBitmapTextComponent(e),this.setSize(e);else if(e.type===t.OBSERVER_TYPE.REMOVE)this.containerManager.getContainer(e.gameObject.id).removeChild(this.texts[e.gameObject.id].text),this.texts[e.gameObject.id].text.destroy({children:!0}),delete this.texts[e.gameObject.id];else{this.change(e);const t=e.component;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(e){return d(this,void 0,void 0,function*(){const t=e.component,o=this.processStyle(t.style),i=o.fontFamily;delete o.fontFamily;const r=i?"":t.text,p=new n.Text(r,o);this.containerManager.getContainer(e.gameObject.id).addChildAt(p,0),this.texts[e.gameObject.id]={text:p,component:t},i&&(yield this.waitForFontResource(p,e,i))})}addHTMLTextComponent(e){return d(this,void 0,void 0,function*(){const t=e.component,o=this.processStyle(t.style),i=o.fontFamily;delete o.fontFamily;const r=i?"":t.text,p=new n.HTMLText(_extends({text:r,style:o},t.textureStyle&&{textureStyle:t.textureStyle}));this.containerManager.getContainer(e.gameObject.id).addChildAt(p,0),this.texts[e.gameObject.id]={text:p,component:t},i&&(yield this.waitForFontResource(p,e,i))})}addBitmapTextComponent(e){return d(this,void 0,void 0,function*(){const t=e.component,o=this.processStyle(t.style),i=o.fontFamily;delete o.fontFamily;const r=i?"":t.text,p=new n.BitmapText(r,o);this.containerManager.getContainer(e.gameObject.id).addChildAt(p,0),this.texts[e.gameObject.id]={text:p,component:t},i&&(yield this.waitForFontResource(p,e,i))})}waitForFontResource(e,o,i){return d(this,void 0,void 0,function*(){if(i)try{const n=Array.isArray(i)?i[0]:i,r=this.increaseAsyncId(o.gameObject.id);if(yield t.resource.getResource(n),!this.validateAsyncId(o.gameObject.id,r))return;const p=this.texts[o.gameObject.id].component;e.style.fontFamily=i,e.text=p.text}catch(e){console.warn(`字体资源 ${i} 加载失败:`,e)}})}processStyle(e){const t=_extends({},e);if(t.strokeThickness){const e=t.stroke;t.stroke={color:e,width:t.strokeThickness},delete t.strokeThickness}const i=null!=t.dropShadowColor||null!=t.dropShadowDistance||null!=t.dropShadowAngle||null!=t.dropShadowAlpha||null!=t.dropShadowBlur;if(t.dropShadow&&i){const e=t.dropShadow&&"object"==typeof t.dropShadow&&!Array.isArray(t.dropShadow)?_extends({},t.dropShadow):{};null!=t.dropShadowColor&&(e.color=t.dropShadowColor),null!=t.dropShadowDistance&&(e.distance=t.dropShadowDistance),null!=t.dropShadowAngle&&(e.angle=t.dropShadowAngle),null!=t.dropShadowAlpha&&(e.alpha=t.dropShadowAlpha),null!=t.dropShadowBlur&&(e.blur=t.dropShadowBlur),t.dropShadow=e}if(delete t.dropShadowColor,delete t.dropShadowDistance,delete t.dropShadowAngle,delete t.dropShadowAlpha,delete t.dropShadowBlur,Array.isArray(t.fill)&&(t.fill=t.fill[0]),Array.isArray(t.fillGradientStops)){let e;e=null==t.fontSize?o.TextStyle.defaultTextStyle.fontSize:"string"==typeof t.fontSize?parseInt(t.fontSize,10):t.fontSize;const i=new o.FillGradient(0,0,0,1.7*e),n=t.fillGradientStops.map(e=>o.Color.shared.setValue(e).toNumber());n.forEach((e,t)=>{const o=t/(n.length-1);i.addColorStop(o,e)}),t.fill={fill:i},delete t.fillGradientStops}return t}change(e){const{text:t,component:o}=this.texts[e.gameObject.id],i="HTMLText"===e.componentName;if("text"===e.prop.prop[0])t.text=o.text;else if("style"===e.prop.prop[0]){const e=this.processStyle(o.style);_extends(t.style,e)}else if("textureStyle"===e.prop.prop[0]&&i){const i=o,r=this.containerManager.getContainer(e.gameObject.id),p=r.getChildIndex(t);r.removeChild(t),t.destroy({children:!0});const d=new n.HTMLText({text:i.text,style:i.style,textureStyle:i.textureStyle});r.addChildAt(d,p),this.texts[e.gameObject.id].text=d}}setSize(e){const{transform:t}=e.gameObject;if(!t)return;const{text:o}=this.texts[e.gameObject.id],i=o.getSize();t.size.width=i.width,t.size.height=i.height}};b.systemName="Text",b=r([t.decorators.componentObserver({Text:["text",{prop:["style"],deep:!0}],HTMLText:["text",{prop:["style"],deep:!0},{prop:["textureStyle"],deep:!0}],BitmapText:["text",{prop:["style"],deep:!0}]})],b);var v=b;return e.BitmapText=y,e.HTMLText=h,e.Text=c,e.TextSystem=v,Object.defineProperty(e,"__esModule",{value:!0}),e}({},EVA,PIXI,EVA.plugin.renderer,EVA.rendererAdapter);globalThis.EVA.plugin.renderer.text=globalThis.EVA.plugin.renderer.text||_EVA_IIFE_text;