@eva/plugin-renderer-text 1.2.7-editor.9 → 1.2.8-alpha.0

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.
@@ -1,4 +1,4 @@
1
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
1
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
2
 
3
3
  window.EVA = window.EVA || {};
4
4
  window.EVA.plugin = window.EVA.plugin || {};
@@ -14,7 +14,7 @@ var _EVA_IIFE_text = function (exports, pixi_js, eva_js, pluginRenderer, rendere
14
14
  d.__proto__ = b;
15
15
  } || function (d, b) {
16
16
  for (var p in b) {
17
- if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
17
+ if (b.hasOwnProperty(p)) d[p] = b[p];
18
18
  }
19
19
  };
20
20
 
@@ -22,8 +22,6 @@ var _EVA_IIFE_text = function (exports, pixi_js, eva_js, pluginRenderer, rendere
22
22
  };
23
23
 
24
24
  function __extends(d, b) {
25
- if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
26
-
27
25
  _extendStatics(d, b);
28
26
 
29
27
  function __() {
@@ -33,22 +31,6 @@ var _EVA_IIFE_text = function (exports, pixi_js, eva_js, pluginRenderer, rendere
33
31
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
34
32
  }
35
33
 
36
- var _assign = function __assign() {
37
- _assign = Object.assign || function __assign(t) {
38
- for (var s, i = 1, n = arguments.length; i < n; i++) {
39
- s = arguments[i];
40
-
41
- for (var p in s) {
42
- if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
43
- }
44
- }
45
-
46
- return t;
47
- };
48
-
49
- return _assign.apply(this, arguments);
50
- };
51
-
52
34
  function __decorate(decorators, target, key, desc) {
53
35
  var c = arguments.length,
54
36
  r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
@@ -59,10 +41,6 @@ var _EVA_IIFE_text = function (exports, pixi_js, eva_js, pluginRenderer, rendere
59
41
  return c > 3 && r && Object.defineProperty(target, key, r), r;
60
42
  }
61
43
 
62
- function __metadata(metadataKey, metadataValue) {
63
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
64
- }
65
-
66
44
  function __awaiter(thisArg, _arguments, P, generator) {
67
45
  function adopt(value) {
68
46
  return value instanceof P ? value : new P(function (resolve) {
@@ -206,277 +184,27 @@ var _EVA_IIFE_text = function (exports, pixi_js, eva_js, pluginRenderer, rendere
206
184
  }
207
185
  }
208
186
 
209
- var SymbolKeysNotSupportedError = function (_super) {
210
- __extends(SymbolKeysNotSupportedError, _super);
211
-
212
- function SymbolKeysNotSupportedError() {
213
- var _newTarget = this.constructor;
214
-
215
- var _this = _super.call(this, 'Symbol keys are not supported yet!') || this;
216
-
217
- Object.setPrototypeOf(_this, _newTarget.prototype);
218
- return _this;
219
- }
220
-
221
- return SymbolKeysNotSupportedError;
222
- }(Error);
223
-
224
- (function (_super) {
225
- __extends(StaticGetPropertiesIsNotAFunctionError, _super);
226
-
227
- function StaticGetPropertiesIsNotAFunctionError() {
228
- var _newTarget = this.constructor;
229
-
230
- var _this = _super.call(this, 'getProperties is not a function!') || this;
231
-
232
- Object.setPrototypeOf(_this, _newTarget.prototype);
233
- return _this;
234
- }
235
-
236
- return StaticGetPropertiesIsNotAFunctionError;
237
- })(Error);
238
-
239
- var IDE_PROPERTY_METADATA = 'IDE_PROPERTY_METADATA';
240
-
241
- function transformBasicType(type) {
242
- if (type === String) {
243
- return 'string';
244
- }
245
-
246
- if (type === Number) {
247
- return 'number';
248
- }
249
-
250
- if (type === Boolean) {
251
- return 'boolean';
252
- }
253
-
254
- return 'unknown';
255
- }
256
-
257
- function defineTypes(target, key, options, returnTypeFunction) {
258
- var type = Reflect.getMetadata('design:type', target, key);
259
- var isArray = type === Array;
260
- var str = transformBasicType(type);
261
-
262
- if (str !== 'unknown') {
263
- type = str;
264
- }
265
-
266
- if (returnTypeFunction) {
267
- var returnType = returnTypeFunction();
268
-
269
- if (Array.isArray(returnType)) {
270
- isArray = true;
271
- type = returnType[0];
272
- } else {
273
- type = returnType;
274
- }
187
+ function getIDEPropsPropertyObj(target, propertyKey) {
188
+ if (!target.constructor.IDEProps) {
189
+ target.constructor.IDEProps = {};
275
190
  }
276
191
 
277
- var properties = Reflect.getMetadata(IDE_PROPERTY_METADATA, target.constructor) || {};
278
- properties[key] = _assign({
279
- type: type,
280
- isArray: isArray
281
- }, options);
282
- Reflect.defineMetadata(IDE_PROPERTY_METADATA, properties, target.constructor);
283
- }
284
-
285
- function getTypeDecoratorParams(returnTypeFuncOrOptions, maybeOptions) {
286
- if (typeof returnTypeFuncOrOptions === 'function') {
287
- return {
288
- returnTypeFunc: returnTypeFuncOrOptions,
289
- options: maybeOptions || {}
290
- };
192
+ if (!target.constructor.IDEProps[propertyKey]) {
193
+ target.constructor.IDEProps[propertyKey] = {};
291
194
  }
292
195
 
293
- return {
294
- options: returnTypeFuncOrOptions || {}
295
- };
196
+ var propertyObj = target.constructor.IDEProps[propertyKey];
197
+ return propertyObj;
296
198
  }
297
199
 
298
- function Field(returnTypeFunction, maybeOptions) {
200
+ function type(type) {
299
201
  return function (target, propertyKey) {
300
- if (typeof propertyKey === 'symbol') {
301
- throw new SymbolKeysNotSupportedError();
302
- }
303
-
304
- var _a = getTypeDecoratorParams(returnTypeFunction, maybeOptions),
305
- options = _a.options,
306
- returnTypeFunc = _a.returnTypeFunc;
307
-
308
- defineTypes(target, propertyKey, options, returnTypeFunc);
202
+ var prop = getIDEPropsPropertyObj(target, propertyKey);
203
+ prop.key = propertyKey;
204
+ prop.type = type;
309
205
  };
310
206
  }
311
207
 
312
- var ExecuteMode;
313
-
314
- (function (ExecuteMode) {
315
- ExecuteMode[ExecuteMode["Edit"] = 2] = "Edit";
316
- ExecuteMode[ExecuteMode["Game"] = 4] = "Game";
317
- ExecuteMode[ExecuteMode["All"] = 6] = "All";
318
- })(ExecuteMode || (ExecuteMode = {}));
319
-
320
- var Color = function () {
321
- function Color() {}
322
-
323
- Color.getProperties = function () {
324
- return 'color';
325
- };
326
-
327
- return Color;
328
- }();
329
-
330
- var Style = function () {
331
- function Style() {}
332
-
333
- __decorate([Field({
334
- type: 'selector',
335
- isArray: false,
336
- options: ['center', 'left', 'right'],
337
- default: 'left'
338
- }), __metadata("design:type", String)], Style.prototype, "align", void 0);
339
-
340
- __decorate([Field(), __metadata("design:type", Boolean)], Style.prototype, "breakWords", void 0);
341
-
342
- __decorate([Field(), __metadata("design:type", Boolean)], Style.prototype, "dropShadow", void 0);
343
-
344
- __decorate([Field({
345
- default: 1
346
- }), __metadata("design:type", Number)], Style.prototype, "dropShadowAlpha", void 0);
347
-
348
- __decorate([Field({
349
- default: Math.PI / 6
350
- }), __metadata("design:type", Number)], Style.prototype, "dropShadowAngle", void 0);
351
-
352
- __decorate([Field({
353
- default: 0
354
- }), __metadata("design:type", Number)], Style.prototype, "dropShadowBlur", void 0);
355
-
356
- __decorate([Field(function () {
357
- return Color;
358
- }, {
359
- default: '#000000'
360
- }), __metadata("design:type", Object)], Style.prototype, "dropShadowColor", void 0);
361
-
362
- __decorate([Field({
363
- default: 5
364
- }), __metadata("design:type", Number)], Style.prototype, "dropShadowDistance", void 0);
365
-
366
- __decorate([Field(function () {
367
- return [Color];
368
- }, {
369
- default: ['#000000']
370
- }), __metadata("design:type", Object)], Style.prototype, "fill", void 0);
371
-
372
- __decorate([Field({
373
- type: 'selector',
374
- options: {
375
- vertical: 1,
376
- horizontal: 0
377
- },
378
- default: 1,
379
- filter: function filter(val) {
380
- return Number(val);
381
- },
382
- isArray: false
383
- }), __metadata("design:type", Number)], Style.prototype, "fillGradientType", void 0);
384
-
385
- __decorate([Field(function () {
386
- return Number;
387
- }, {
388
- step: 0.1,
389
- min: 0,
390
- max: 1
391
- }), __metadata("design:type", Array)], Style.prototype, "fillGradientStops", void 0);
392
-
393
- __decorate([Field(function () {
394
- return String;
395
- }, {
396
- default: 'Arial'
397
- }), __metadata("design:type", Object)], Style.prototype, "fontFamily", void 0);
398
-
399
- __decorate([Field(function () {
400
- return Number;
401
- }, {
402
- min: 5,
403
- default: 26
404
- }), __metadata("design:type", Object)], Style.prototype, "fontSize", void 0);
405
-
406
- __decorate([Field({
407
- type: 'selector',
408
- options: ['normal', 'italic', 'oblique'],
409
- default: 'normal'
410
- }), __metadata("design:type", String)], Style.prototype, "fontStyle", void 0);
411
-
412
- __decorate([Field({
413
- type: 'selector',
414
- options: ['normal', 'small-caps'],
415
- default: 'normal'
416
- }), __metadata("design:type", String)], Style.prototype, "fontVariant", void 0);
417
-
418
- __decorate([Field({
419
- type: 'selector',
420
- options: ['normal', 'bold', 'bolder', 'lighter', '100', '200', '300', '400', '500', '600', '700', '800', '900'],
421
- default: 'normal'
422
- }), __metadata("design:type", String)], Style.prototype, "fontWeight", void 0);
423
-
424
- __decorate([Field({
425
- default: 0
426
- }), __metadata("design:type", Number)], Style.prototype, "letterSpacing", void 0);
427
-
428
- __decorate([Field({
429
- default: 0
430
- }), __metadata("design:type", Number)], Style.prototype, "lineHeight", void 0);
431
-
432
- __decorate([Field({
433
- type: 'selector',
434
- options: ['miter', 'round', 'bevel'],
435
- default: 'miter'
436
- }), __metadata("design:type", String)], Style.prototype, "lineJoin", void 0);
437
-
438
- __decorate([Field({
439
- default: 10
440
- }), __metadata("design:type", Number)], Style.prototype, "miterLimit", void 0);
441
-
442
- __decorate([Field({
443
- default: 0
444
- }), __metadata("design:type", Number)], Style.prototype, "padding", void 0);
445
-
446
- __decorate([Field(function () {
447
- return Color;
448
- }, {
449
- default: '#000000'
450
- }), __metadata("design:type", Object)], Style.prototype, "stroke", void 0);
451
-
452
- __decorate([Field({
453
- default: 0,
454
- min: 0
455
- }), __metadata("design:type", Number)], Style.prototype, "strokeThickness", void 0);
456
-
457
- __decorate([Field({
458
- default: 'alphabetic'
459
- }), __metadata("design:type", String)], Style.prototype, "textBaseline", void 0);
460
-
461
- __decorate([Field(), __metadata("design:type", Boolean)], Style.prototype, "trim", void 0);
462
-
463
- __decorate([Field({
464
- default: 'pre',
465
- type: 'selector',
466
- options: ['normal', 'pre', 'pre-line']
467
- }), __metadata("design:type", String)], Style.prototype, "whiteSpace", void 0);
468
-
469
- __decorate([Field(), __metadata("design:type", Boolean)], Style.prototype, "wordWrap", void 0);
470
-
471
- __decorate([Field({
472
- default: 100
473
- }), __metadata("design:type", Number)], Style.prototype, "wordWrapWidth", void 0);
474
-
475
- __decorate([Field(), __metadata("design:type", Number)], Style.prototype, "leading", void 0);
476
-
477
- return Style;
478
- }();
479
-
480
208
  var Text$2 = function (_super) {
481
209
  __extends(Text, _super);
482
210
 
@@ -511,22 +239,7 @@ var _EVA_IIFE_text = function (exports, pixi_js, eva_js, pluginRenderer, rendere
511
239
 
512
240
  Text.componentName = 'Text';
513
241
 
514
- __decorate([Field({
515
- type: 'textarea',
516
- filter: function filter(text) {
517
- if (typeof text !== 'string') {
518
- return '';
519
- }
520
-
521
- if (text.length > 100) {
522
- return text.slice(0, 100);
523
- }
524
-
525
- return text;
526
- }
527
- }), __metadata("design:type", String)], Text.prototype, "text", void 0);
528
-
529
- __decorate([Field(), __metadata("design:type", Style)], Text.prototype, "style", void 0);
242
+ __decorate([type('string')], Text.prototype, "text", void 0);
530
243
 
531
244
  return Text;
532
245
  }(eva_js.Component);
@@ -1 +1 @@
1
- function _extends(){return _extends=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},_extends.apply(this,arguments)}window.EVA=window.EVA||{},window.EVA.plugin=window.EVA.plugin||{},window.EVA.plugin.renderer=window.EVA.plugin.renderer||{};var _EVA_IIFE_text=function(t,e,n,o,r){"use strict";var i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},i(t,e)};function p(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var a=function(){return a=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},a.apply(this,arguments)};function s(t,e,n,o){var r,i=arguments.length,p=i<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)p=Reflect.decorate(t,e,n,o);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(p=(i<3?r(p):i>3?r(e,n,p):r(e,n))||p);return i>3&&p&&Object.defineProperty(e,n,p),p}function u(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}function l(t,e,n,o){return new(n||(n=Promise))((function(r,i){function p(t){try{s(o.next(t))}catch(t){i(t)}}function a(t){try{s(o.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(p,a)}s((o=o.apply(t,e||[])).next())}))}function c(t,e){var n,o,r,i,p={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;p;)try{if(n=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return p.label++,{value:i[1],done:!1};case 5:p.label++,o=i[1],i=[0];continue;case 7:i=p.ops.pop(),p.trys.pop();continue;default:if(!(r=p.trys,(r=r.length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){p=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){p.label=i[1];break}if(6===i[0]&&p.label<r[1]){p.label=r[1],r=i;break}if(r&&p.label<r[2]){p.label=r[2],p.ops.push(i);break}r[2]&&p.ops.pop(),p.trys.pop();continue}i=e.call(t,p)}catch(t){i=[6,t],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}var d=function(t){function e(){var e=this.constructor,n=t.call(this,"Symbol keys are not supported yet!")||this;return Object.setPrototypeOf(n,e.prototype),n}return p(e,t),e}(Error);!function(t){function e(){var e=this.constructor,n=t.call(this,"getProperties is not a function!")||this;return Object.setPrototypeOf(n,e.prototype),n}p(e,t)}(Error);var y,f="IDE_PROPERTY_METADATA";function g(t,e,n,o){var r=Reflect.getMetadata("design:type",t,e),i=r===Array,p=function(t){return t===String?"string":t===Number?"number":t===Boolean?"boolean":"unknown"}(r);if("unknown"!==p&&(r=p),o){var s=o();Array.isArray(s)?(i=!0,r=s[0]):r=s}var u=Reflect.getMetadata(f,t.constructor)||{};u[e]=a({type:r,isArray:i},n),Reflect.defineMetadata(f,u,t.constructor)}function h(t,e){return function(n,o){if("symbol"==typeof o)throw new d;var r=function(t,e){return"function"==typeof t?{returnTypeFunc:t,options:e||{}}:{options:t||{}}}(t,e);g(n,o,r.options,r.returnTypeFunc)}}!function(t){t[t.Edit=2]="Edit",t[t.Game=4]="Game",t[t.All=6]="All"}(y||(y={}));var m=function(){function t(){}return t.getProperties=function(){return"color"},t}(),v=function(){function t(){}return s([h({type:"selector",isArray:!1,options:["center","left","right"],default:"left"}),u("design:type",String)],t.prototype,"align",void 0),s([h(),u("design:type",Boolean)],t.prototype,"breakWords",void 0),s([h(),u("design:type",Boolean)],t.prototype,"dropShadow",void 0),s([h({default:1}),u("design:type",Number)],t.prototype,"dropShadowAlpha",void 0),s([h({default:Math.PI/6}),u("design:type",Number)],t.prototype,"dropShadowAngle",void 0),s([h({default:0}),u("design:type",Number)],t.prototype,"dropShadowBlur",void 0),s([h((function(){return m}),{default:"#000000"}),u("design:type",Object)],t.prototype,"dropShadowColor",void 0),s([h({default:5}),u("design:type",Number)],t.prototype,"dropShadowDistance",void 0),s([h((function(){return[m]}),{default:["#000000"]}),u("design:type",Object)],t.prototype,"fill",void 0),s([h({type:"selector",options:{vertical:1,horizontal:0},default:1,filter:function(t){return Number(t)},isArray:!1}),u("design:type",Number)],t.prototype,"fillGradientType",void 0),s([h((function(){return Number}),{step:.1,min:0,max:1}),u("design:type",Array)],t.prototype,"fillGradientStops",void 0),s([h((function(){return String}),{default:"Arial"}),u("design:type",Object)],t.prototype,"fontFamily",void 0),s([h((function(){return Number}),{min:5,default:26}),u("design:type",Object)],t.prototype,"fontSize",void 0),s([h({type:"selector",options:["normal","italic","oblique"],default:"normal"}),u("design:type",String)],t.prototype,"fontStyle",void 0),s([h({type:"selector",options:["normal","small-caps"],default:"normal"}),u("design:type",String)],t.prototype,"fontVariant",void 0),s([h({type:"selector",options:["normal","bold","bolder","lighter","100","200","300","400","500","600","700","800","900"],default:"normal"}),u("design:type",String)],t.prototype,"fontWeight",void 0),s([h({default:0}),u("design:type",Number)],t.prototype,"letterSpacing",void 0),s([h({default:0}),u("design:type",Number)],t.prototype,"lineHeight",void 0),s([h({type:"selector",options:["miter","round","bevel"],default:"miter"}),u("design:type",String)],t.prototype,"lineJoin",void 0),s([h({default:10}),u("design:type",Number)],t.prototype,"miterLimit",void 0),s([h({default:0}),u("design:type",Number)],t.prototype,"padding",void 0),s([h((function(){return m}),{default:"#000000"}),u("design:type",Object)],t.prototype,"stroke",void 0),s([h({default:0,min:0}),u("design:type",Number)],t.prototype,"strokeThickness",void 0),s([h({default:"alphabetic"}),u("design:type",String)],t.prototype,"textBaseline",void 0),s([h(),u("design:type",Boolean)],t.prototype,"trim",void 0),s([h({default:"pre",type:"selector",options:["normal","pre","pre-line"]}),u("design:type",String)],t.prototype,"whiteSpace",void 0),s([h(),u("design:type",Boolean)],t.prototype,"wordWrap",void 0),s([h({default:100}),u("design:type",Number)],t.prototype,"wordWrapWidth",void 0),s([h(),u("design:type",Number)],t.prototype,"leading",void 0),t}(),b=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.text="",e.style={},e}return p(n,t),n.prototype.init=function(t){var n=new e.TextStyle({fontSize:20}),o={};for(var r in n)0===r.indexOf("_")&&(o[r.substring(1)]=n[r]);this.style=o,t&&(this.text=t.text,_extends(this.style,t.style))},n.componentName="Text",s([h({type:"textarea",filter:function(t){return"string"!=typeof t?"":t.length>100?t.slice(0,100):t}}),u("design:type",String)],n.prototype,"text",void 0),s([h(),u("design:type",v)],n.prototype,"style",void 0),n}(n.Component),x=b,w=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="Text",e.texts={},e}return p(e,t),e.prototype.init=function(){this.renderSystem=this.game.getSystem(o.RendererSystem),this.renderSystem.rendererManager.register(this)},e.prototype.componentChanged=function(t){return l(this,void 0,void 0,(function(){var e,o;return c(this,(function(i){return"Text"!==t.componentName||(t.type===n.OBSERVER_TYPE.ADD?(e=t.component,o=new r.Text(e.text,e.style),this.containerManager.getContainer(t.gameObject.id).addChildAt(o,0),this.texts[t.gameObject.id]={text:o,component:t.component},this.setSize(t)):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))),[2]}))}))},e.prototype.change=function(t){var e=this.texts[t.gameObject.id],n=e.text,o=e.component;"text"===t.prop.prop[0]?n.text=o.text:"style"===t.prop.prop[0]&&_extends(n.style,t.component.style)},e.prototype.setSize=function(t){var e=t.gameObject.transform;e&&(e.size.width=this.texts[t.gameObject.id].text.width,e.size.height=this.texts[t.gameObject.id].text.height)},e.systemName="Text",e=s([n.decorators.componentObserver({Text:["text",{prop:["style"],deep:!0}]})],e)}(o.Renderer),O=w;return t.Text=x,t.TextSystem=O,Object.defineProperty(t,"__esModule",{value:!0}),t}({},PIXI,EVA,EVA.plugin.renderer,EVA.rendererAdapter);window.EVA.plugin.renderer.text=window.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 r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},_extends.apply(this,arguments)}window.EVA=window.EVA||{},window.EVA.plugin=window.EVA.plugin||{},window.EVA.plugin.renderer=window.EVA.plugin.renderer||{};var _EVA_IIFE_text=function(t,e,n,r,o){"use strict";var i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},i(t,e)};function c(t,e){function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function s(t,e,n,r){var o,i=arguments.length,c=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(t,e,n,r);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(c=(i<3?o(c):i>3?o(e,n,c):o(e,n))||c);return i>3&&c&&Object.defineProperty(e,n,c),c}function a(t,e,n,r){return new(n||(n=Promise))((function(o,i){function c(t){try{a(r.next(t))}catch(t){i(t)}}function s(t){try{a(r.throw(t))}catch(t){i(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(c,s)}a((r=r.apply(t,e||[])).next())}))}function u(t,e){var n,r,o,i,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;c;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return c.label++,{value:i[1],done:!1};case 5:c.label++,r=i[1],i=[0];continue;case 7:i=c.ops.pop(),c.trys.pop();continue;default:if(!(o=c.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){c=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){c.label=i[1];break}if(6===i[0]&&c.label<o[1]){c.label=o[1],o=i;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(i);break}o[2]&&c.ops.pop(),c.trys.pop();continue}i=e.call(t,c)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}function p(t){return function(e,n){var r=function(t,e){return t.constructor.IDEProps||(t.constructor.IDEProps={}),t.constructor.IDEProps[e]||(t.constructor.IDEProps[e]={}),t.constructor.IDEProps[e]}(e,n);r.key=n,r.type=t}}var l=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.text="",e.style={},e}return c(n,t),n.prototype.init=function(t){var n=new e.TextStyle({fontSize:20}),r={};for(var o in n)0===o.indexOf("_")&&(r[o.substring(1)]=n[o]);this.style=r,t&&(this.text=t.text,_extends(this.style,t.style))},n.componentName="Text",s([p("string")],n.prototype,"text",void 0),n}(n.Component),f=l,d=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="Text",e.texts={},e}return c(e,t),e.prototype.init=function(){this.renderSystem=this.game.getSystem(r.RendererSystem),this.renderSystem.rendererManager.register(this)},e.prototype.componentChanged=function(t){return a(this,void 0,void 0,(function(){var e,r;return u(this,(function(i){return"Text"!==t.componentName||(t.type===n.OBSERVER_TYPE.ADD?(e=t.component,r=new o.Text(e.text,e.style),this.containerManager.getContainer(t.gameObject.id).addChildAt(r,0),this.texts[t.gameObject.id]={text:r,component:t.component},this.setSize(t)):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))),[2]}))}))},e.prototype.change=function(t){var e=this.texts[t.gameObject.id],n=e.text,r=e.component;"text"===t.prop.prop[0]?n.text=r.text:"style"===t.prop.prop[0]&&_extends(n.style,t.component.style)},e.prototype.setSize=function(t){var e=t.gameObject.transform;e&&(e.size.width=this.texts[t.gameObject.id].text.width,e.size.height=this.texts[t.gameObject.id].text.height)},e.systemName="Text",e=s([n.decorators.componentObserver({Text:["text",{prop:["style"],deep:!0}]})],e)}(r.Renderer),h=d;return t.Text=f,t.TextSystem=h,Object.defineProperty(t,"__esModule",{value:!0}),t}({},PIXI,EVA,EVA.plugin.renderer,EVA.rendererAdapter);window.EVA.plugin.renderer.text=window.EVA.plugin.renderer.text||_EVA_IIFE_text;
@@ -0,0 +1,128 @@
1
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+
3
+ import { __extends, __decorate, __awaiter, __generator } from 'tslib';
4
+ import { TextStyle } from '@eva/miniprogram-pixi';
5
+ import { Component, OBSERVER_TYPE, decorators } from '@eva/eva.js/dist/miniprogram';
6
+ import { type } from '@eva/inspector-decorator';
7
+ import { RendererSystem, Renderer } from '@eva/plugin-renderer/dist/miniprogram';
8
+ import { Text as Text$4 } from '@eva/renderer-adapter/dist/miniprogram';
9
+
10
+ var Text$2 = function (_super) {
11
+ __extends(Text, _super);
12
+
13
+ function Text() {
14
+ var _this = _super !== null && _super.apply(this, arguments) || this;
15
+
16
+ _this.text = '';
17
+ _this.style = {};
18
+ return _this;
19
+ }
20
+
21
+ Text.prototype.init = function (obj) {
22
+ var style = new TextStyle({
23
+ fontSize: 20
24
+ });
25
+ var newStyle = {};
26
+
27
+ for (var key in style) {
28
+ if (key.indexOf('_') === 0) {
29
+ newStyle[key.substring(1)] = style[key];
30
+ }
31
+ }
32
+
33
+ this.style = newStyle;
34
+
35
+ if (obj) {
36
+ this.text = obj.text;
37
+
38
+ _extends(this.style, obj.style);
39
+ }
40
+ };
41
+
42
+ Text.componentName = 'Text';
43
+
44
+ __decorate([type('string')], Text.prototype, "text", void 0);
45
+
46
+ return Text;
47
+ }(Component);
48
+
49
+ var Text$3 = Text$2;
50
+
51
+ var Text = function (_super) {
52
+ __extends(Text, _super);
53
+
54
+ function Text() {
55
+ var _this = _super !== null && _super.apply(this, arguments) || this;
56
+
57
+ _this.name = 'Text';
58
+ _this.texts = {};
59
+ return _this;
60
+ }
61
+
62
+ Text.prototype.init = function () {
63
+ this.renderSystem = this.game.getSystem(RendererSystem);
64
+ this.renderSystem.rendererManager.register(this);
65
+ };
66
+
67
+ Text.prototype.componentChanged = function (changed) {
68
+ return __awaiter(this, void 0, void 0, function () {
69
+ var component, text;
70
+ return __generator(this, function (_a) {
71
+ if (changed.componentName !== 'Text') return [2];
72
+
73
+ if (changed.type === OBSERVER_TYPE.ADD) {
74
+ component = changed.component;
75
+ text = new Text$4(component.text, component.style);
76
+ this.containerManager.getContainer(changed.gameObject.id).addChildAt(text, 0);
77
+ this.texts[changed.gameObject.id] = {
78
+ text: text,
79
+ component: changed.component
80
+ };
81
+ this.setSize(changed);
82
+ } else if (changed.type === OBSERVER_TYPE.REMOVE) {
83
+ this.containerManager.getContainer(changed.gameObject.id).removeChild(this.texts[changed.gameObject.id].text);
84
+ this.texts[changed.gameObject.id].text.destroy({
85
+ children: true
86
+ });
87
+ delete this.texts[changed.gameObject.id];
88
+ } else {
89
+ this.change(changed);
90
+ this.setSize(changed);
91
+ }
92
+
93
+ return [2];
94
+ });
95
+ });
96
+ };
97
+
98
+ Text.prototype.change = function (changed) {
99
+ var _a = this.texts[changed.gameObject.id],
100
+ text = _a.text,
101
+ component = _a.component;
102
+
103
+ if (changed.prop.prop[0] === 'text') {
104
+ text.text = component.text;
105
+ } else if (changed.prop.prop[0] === 'style') {
106
+ _extends(text.style, changed.component.style);
107
+ }
108
+ };
109
+
110
+ Text.prototype.setSize = function (changed) {
111
+ var transform = changed.gameObject.transform;
112
+ if (!transform) return;
113
+ transform.size.width = this.texts[changed.gameObject.id].text.width;
114
+ transform.size.height = this.texts[changed.gameObject.id].text.height;
115
+ };
116
+
117
+ Text.systemName = 'Text';
118
+ Text = __decorate([decorators.componentObserver({
119
+ Text: ['text', {
120
+ prop: ['style'],
121
+ deep: true
122
+ }]
123
+ })], Text);
124
+ return Text;
125
+ }(Renderer);
126
+
127
+ var Text$1 = Text;
128
+ export { Text$3 as Text, Text$1 as TextSystem };
@@ -44,10 +44,6 @@ function __decorate(decorators, target, key, desc) {
44
44
  return c > 3 && r && Object.defineProperty(target, key, r), r;
45
45
  }
46
46
 
47
- function __metadata(metadataKey, metadataValue) {
48
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
49
- }
50
-
51
47
  function __awaiter(thisArg, _arguments, P, generator) {
52
48
  return new (P || (P = Promise))(function (resolve, reject) {
53
49
  function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
@@ -85,150 +81,6 @@ function __generator(thisArg, body) {
85
81
  }
86
82
  }
87
83
 
88
- var Color = (function () {
89
- function Color() {
90
- }
91
- Color.getProperties = function () {
92
- return 'color';
93
- };
94
- return Color;
95
- }());
96
- var Style = (function () {
97
- function Style() {
98
- }
99
- __decorate([
100
- inspectorDecorator.Field({
101
- type: 'selector',
102
- isArray: false,
103
- options: ['center', 'left', 'right'],
104
- default: 'left',
105
- }),
106
- __metadata("design:type", String)
107
- ], Style.prototype, "align", void 0);
108
- __decorate([
109
- inspectorDecorator.Field(),
110
- __metadata("design:type", Boolean)
111
- ], Style.prototype, "breakWords", void 0);
112
- __decorate([
113
- inspectorDecorator.Field(),
114
- __metadata("design:type", Boolean)
115
- ], Style.prototype, "dropShadow", void 0);
116
- __decorate([
117
- inspectorDecorator.Field({ default: 1 }),
118
- __metadata("design:type", Number)
119
- ], Style.prototype, "dropShadowAlpha", void 0);
120
- __decorate([
121
- inspectorDecorator.Field({ default: Math.PI / 6 }),
122
- __metadata("design:type", Number)
123
- ], Style.prototype, "dropShadowAngle", void 0);
124
- __decorate([
125
- inspectorDecorator.Field({ default: 0 }),
126
- __metadata("design:type", Number)
127
- ], Style.prototype, "dropShadowBlur", void 0);
128
- __decorate([
129
- inspectorDecorator.Field(function () { return Color; }, { default: '#000000' }),
130
- __metadata("design:type", Object)
131
- ], Style.prototype, "dropShadowColor", void 0);
132
- __decorate([
133
- inspectorDecorator.Field({ default: 5 }),
134
- __metadata("design:type", Number)
135
- ], Style.prototype, "dropShadowDistance", void 0);
136
- __decorate([
137
- inspectorDecorator.Field(function () { return [Color]; }, { default: ['#000000'] }),
138
- __metadata("design:type", Object)
139
- ], Style.prototype, "fill", void 0);
140
- __decorate([
141
- inspectorDecorator.Field({
142
- type: 'selector',
143
- options: { vertical: 1, horizontal: 0 },
144
- default: 1,
145
- filter: function (val) { return Number(val); },
146
- isArray: false,
147
- }),
148
- __metadata("design:type", Number)
149
- ], Style.prototype, "fillGradientType", void 0);
150
- __decorate([
151
- inspectorDecorator.Field(function () { return Number; }, { step: 0.1, min: 0, max: 1 }),
152
- __metadata("design:type", Array)
153
- ], Style.prototype, "fillGradientStops", void 0);
154
- __decorate([
155
- inspectorDecorator.Field(function () { return String; }, { default: 'Arial' }),
156
- __metadata("design:type", Object)
157
- ], Style.prototype, "fontFamily", void 0);
158
- __decorate([
159
- inspectorDecorator.Field(function () { return Number; }, { min: 5, default: 26 }),
160
- __metadata("design:type", Object)
161
- ], Style.prototype, "fontSize", void 0);
162
- __decorate([
163
- inspectorDecorator.Field({ type: 'selector', options: ['normal', 'italic', 'oblique'], default: 'normal' }),
164
- __metadata("design:type", String)
165
- ], Style.prototype, "fontStyle", void 0);
166
- __decorate([
167
- inspectorDecorator.Field({ type: 'selector', options: ['normal', 'small-caps'], default: 'normal' }),
168
- __metadata("design:type", String)
169
- ], Style.prototype, "fontVariant", void 0);
170
- __decorate([
171
- inspectorDecorator.Field({
172
- type: 'selector',
173
- options: ['normal', 'bold', 'bolder', 'lighter', '100', '200', '300', '400', '500', '600', '700', '800', '900'],
174
- default: 'normal',
175
- }),
176
- __metadata("design:type", String)
177
- ], Style.prototype, "fontWeight", void 0);
178
- __decorate([
179
- inspectorDecorator.Field({ default: 0 }),
180
- __metadata("design:type", Number)
181
- ], Style.prototype, "letterSpacing", void 0);
182
- __decorate([
183
- inspectorDecorator.Field({ default: 0 }),
184
- __metadata("design:type", Number)
185
- ], Style.prototype, "lineHeight", void 0);
186
- __decorate([
187
- inspectorDecorator.Field({ type: 'selector', options: ['miter', 'round', 'bevel'], default: 'miter' }),
188
- __metadata("design:type", String)
189
- ], Style.prototype, "lineJoin", void 0);
190
- __decorate([
191
- inspectorDecorator.Field({ default: 10 }),
192
- __metadata("design:type", Number)
193
- ], Style.prototype, "miterLimit", void 0);
194
- __decorate([
195
- inspectorDecorator.Field({ default: 0 }),
196
- __metadata("design:type", Number)
197
- ], Style.prototype, "padding", void 0);
198
- __decorate([
199
- inspectorDecorator.Field(function () { return Color; }, { default: '#000000' }),
200
- __metadata("design:type", Object)
201
- ], Style.prototype, "stroke", void 0);
202
- __decorate([
203
- inspectorDecorator.Field({ default: 0, min: 0 }),
204
- __metadata("design:type", Number)
205
- ], Style.prototype, "strokeThickness", void 0);
206
- __decorate([
207
- inspectorDecorator.Field({ default: 'alphabetic' }),
208
- __metadata("design:type", String)
209
- ], Style.prototype, "textBaseline", void 0);
210
- __decorate([
211
- inspectorDecorator.Field(),
212
- __metadata("design:type", Boolean)
213
- ], Style.prototype, "trim", void 0);
214
- __decorate([
215
- inspectorDecorator.Field({ default: 'pre', type: 'selector', options: ['normal', 'pre', 'pre-line'] }),
216
- __metadata("design:type", String)
217
- ], Style.prototype, "whiteSpace", void 0);
218
- __decorate([
219
- inspectorDecorator.Field(),
220
- __metadata("design:type", Boolean)
221
- ], Style.prototype, "wordWrap", void 0);
222
- __decorate([
223
- inspectorDecorator.Field({ default: 100 }),
224
- __metadata("design:type", Number)
225
- ], Style.prototype, "wordWrapWidth", void 0);
226
- __decorate([
227
- inspectorDecorator.Field(),
228
- __metadata("design:type", Number)
229
- ], Style.prototype, "leading", void 0);
230
- return Style;
231
- }());
232
84
  var Text$2 = (function (_super) {
233
85
  __extends(Text, _super);
234
86
  function Text() {
@@ -255,24 +107,8 @@ var Text$2 = (function (_super) {
255
107
  };
256
108
  Text.componentName = 'Text';
257
109
  __decorate([
258
- inspectorDecorator.Field({
259
- type: 'textarea',
260
- filter: function (text) {
261
- if (typeof text !== 'string') {
262
- return '';
263
- }
264
- if (text.length > 100) {
265
- return text.slice(0, 100);
266
- }
267
- return text;
268
- },
269
- }),
270
- __metadata("design:type", String)
110
+ inspectorDecorator.type('string')
271
111
  ], Text.prototype, "text", void 0);
272
- __decorate([
273
- inspectorDecorator.Field(),
274
- __metadata("design:type", Style)
275
- ], Text.prototype, "style", void 0);
276
112
  return Text;
277
113
  }(eva_js.Component));
278
114
  var Text$3 = Text$2;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("pixi.js"),t=require("@eva/eva.js"),o=require("@eva/inspector-decorator"),r=require("@eva/plugin-renderer"),n=require("@eva/renderer-adapter"),i=function(e,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var o in t)t.hasOwnProperty(o)&&(e[o]=t[o])},i(e,t)};function p(e,t){function o(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(o.prototype=t.prototype,new o)}function d(e,t,o,r){var n,i=arguments.length,p=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,o):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)p=Reflect.decorate(e,t,o,r);else for(var d=e.length-1;d>=0;d--)(n=e[d])&&(p=(i<3?n(p):i>3?n(t,o,p):n(t,o))||p);return i>3&&p&&Object.defineProperty(t,o,p),p}function l(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function a(e,t){var o,r,n,i,p={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return i={next:d(0),throw:d(1),return:d(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function d(i){return function(d){return function(i){if(o)throw new TypeError("Generator is already executing.");for(;p;)try{if(o=1,r&&(n=2&i[0]?r.return:i[0]?r.throw||((n=r.return)&&n.call(r),0):r.next)&&!(n=n.call(r,i[1])).done)return n;switch(r=0,n&&(i=[2&i[0],n.value]),i[0]){case 0:case 1:n=i;break;case 4:return p.label++,{value:i[1],done:!1};case 5:p.label++,r=i[1],i=[0];continue;case 7:i=p.ops.pop(),p.trys.pop();continue;default:if(!(n=p.trys,(n=n.length>0&&n[n.length-1])||6!==i[0]&&2!==i[0])){p=0;continue}if(3===i[0]&&(!n||i[1]>n[0]&&i[1]<n[3])){p.label=i[1];break}if(6===i[0]&&p.label<n[1]){p.label=n[1],n=i;break}if(n&&p.label<n[2]){p.label=n[2],p.ops.push(i);break}n[2]&&p.ops.pop(),p.trys.pop();continue}i=t.call(e,p)}catch(e){i=[6,e],r=0}finally{o=n=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,d])}}}var s=function(){function e(){}return e.getProperties=function(){return"color"},e}(),u=function(){function e(){}return d([o.Field({type:"selector",isArray:!1,options:["center","left","right"],default:"left"}),l("design:type",String)],e.prototype,"align",void 0),d([o.Field(),l("design:type",Boolean)],e.prototype,"breakWords",void 0),d([o.Field(),l("design:type",Boolean)],e.prototype,"dropShadow",void 0),d([o.Field({default:1}),l("design:type",Number)],e.prototype,"dropShadowAlpha",void 0),d([o.Field({default:Math.PI/6}),l("design:type",Number)],e.prototype,"dropShadowAngle",void 0),d([o.Field({default:0}),l("design:type",Number)],e.prototype,"dropShadowBlur",void 0),d([o.Field((function(){return s}),{default:"#000000"}),l("design:type",Object)],e.prototype,"dropShadowColor",void 0),d([o.Field({default:5}),l("design:type",Number)],e.prototype,"dropShadowDistance",void 0),d([o.Field((function(){return[s]}),{default:["#000000"]}),l("design:type",Object)],e.prototype,"fill",void 0),d([o.Field({type:"selector",options:{vertical:1,horizontal:0},default:1,filter:function(e){return Number(e)},isArray:!1}),l("design:type",Number)],e.prototype,"fillGradientType",void 0),d([o.Field((function(){return Number}),{step:.1,min:0,max:1}),l("design:type",Array)],e.prototype,"fillGradientStops",void 0),d([o.Field((function(){return String}),{default:"Arial"}),l("design:type",Object)],e.prototype,"fontFamily",void 0),d([o.Field((function(){return Number}),{min:5,default:26}),l("design:type",Object)],e.prototype,"fontSize",void 0),d([o.Field({type:"selector",options:["normal","italic","oblique"],default:"normal"}),l("design:type",String)],e.prototype,"fontStyle",void 0),d([o.Field({type:"selector",options:["normal","small-caps"],default:"normal"}),l("design:type",String)],e.prototype,"fontVariant",void 0),d([o.Field({type:"selector",options:["normal","bold","bolder","lighter","100","200","300","400","500","600","700","800","900"],default:"normal"}),l("design:type",String)],e.prototype,"fontWeight",void 0),d([o.Field({default:0}),l("design:type",Number)],e.prototype,"letterSpacing",void 0),d([o.Field({default:0}),l("design:type",Number)],e.prototype,"lineHeight",void 0),d([o.Field({type:"selector",options:["miter","round","bevel"],default:"miter"}),l("design:type",String)],e.prototype,"lineJoin",void 0),d([o.Field({default:10}),l("design:type",Number)],e.prototype,"miterLimit",void 0),d([o.Field({default:0}),l("design:type",Number)],e.prototype,"padding",void 0),d([o.Field((function(){return s}),{default:"#000000"}),l("design:type",Object)],e.prototype,"stroke",void 0),d([o.Field({default:0,min:0}),l("design:type",Number)],e.prototype,"strokeThickness",void 0),d([o.Field({default:"alphabetic"}),l("design:type",String)],e.prototype,"textBaseline",void 0),d([o.Field(),l("design:type",Boolean)],e.prototype,"trim",void 0),d([o.Field({default:"pre",type:"selector",options:["normal","pre","pre-line"]}),l("design:type",String)],e.prototype,"whiteSpace",void 0),d([o.Field(),l("design:type",Boolean)],e.prototype,"wordWrap",void 0),d([o.Field({default:100}),l("design:type",Number)],e.prototype,"wordWrapWidth",void 0),d([o.Field(),l("design:type",Number)],e.prototype,"leading",void 0),e}(),c=function(t){function r(){var e=null!==t&&t.apply(this,arguments)||this;return e.text="",e.style={},e}return p(r,t),r.prototype.init=function(t){var o=new e.TextStyle({fontSize:20}),r={};for(var n in o)0===n.indexOf("_")&&(r[n.substring(1)]=o[n]);this.style=r,t&&(this.text=t.text,Object.assign(this.style,t.style))},r.componentName="Text",d([o.Field({type:"textarea",filter:function(e){return"string"!=typeof e?"":e.length>100?e.slice(0,100):e}}),l("design:type",String)],r.prototype,"text",void 0),d([o.Field(),l("design:type",u)],r.prototype,"style",void 0),r}(t.Component),y=c,f=function(e){function o(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="Text",t.texts={},t}return p(o,e),o.prototype.init=function(){this.renderSystem=this.game.getSystem(r.RendererSystem),this.renderSystem.rendererManager.register(this)},o.prototype.componentChanged=function(e){return o=this,r=void 0,p=function(){var o,r;return a(this,(function(i){return"Text"!==e.componentName||(e.type===t.OBSERVER_TYPE.ADD?(o=e.component,r=new n.Text(o.text,o.style),this.containerManager.getContainer(e.gameObject.id).addChildAt(r,0),this.texts[e.gameObject.id]={text:r,component:e.component},this.setSize(e)):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))),[2]}))},new((i=void 0)||(i=Promise))((function(e,t){function n(e){try{l(p.next(e))}catch(e){t(e)}}function d(e){try{l(p.throw(e))}catch(e){t(e)}}function l(t){t.done?e(t.value):new i((function(e){e(t.value)})).then(n,d)}l((p=p.apply(o,r||[])).next())}));var o,r,i,p},o.prototype.change=function(e){var t=this.texts[e.gameObject.id],o=t.text,r=t.component;"text"===e.prop.prop[0]?o.text=r.text:"style"===e.prop.prop[0]&&Object.assign(o.style,e.component.style)},o.prototype.setSize=function(e){var t=e.gameObject.transform;t&&(t.size.width=this.texts[e.gameObject.id].text.width,t.size.height=this.texts[e.gameObject.id].text.height)},o.systemName="Text",o=d([t.decorators.componentObserver({Text:["text",{prop:["style"],deep:!0}]})],o)}(r.Renderer);exports.Text=y,exports.TextSystem=f;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("pixi.js"),t=require("@eva/eva.js"),n=require("@eva/inspector-decorator"),r=require("@eva/plugin-renderer"),o=require("@eva/renderer-adapter"),i=function(e,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},i(e,t)};function s(e,t){function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function a(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s}function c(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}var p=function(t){function r(){var e=null!==t&&t.apply(this,arguments)||this;return e.text="",e.style={},e}return s(r,t),r.prototype.init=function(t){var n=new e.TextStyle({fontSize:20}),r={};for(var o in n)0===o.indexOf("_")&&(r[o.substring(1)]=n[o]);this.style=r,t&&(this.text=t.text,Object.assign(this.style,t.style))},r.componentName="Text",a([n.type("string")],r.prototype,"text",void 0),r}(t.Component),u=p,l=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="Text",t.texts={},t}return s(n,e),n.prototype.init=function(){this.renderSystem=this.game.getSystem(r.RendererSystem),this.renderSystem.rendererManager.register(this)},n.prototype.componentChanged=function(e){return n=this,r=void 0,s=function(){var n,r;return c(this,(function(i){return"Text"!==e.componentName||(e.type===t.OBSERVER_TYPE.ADD?(n=e.component,r=new o.Text(n.text,n.style),this.containerManager.getContainer(e.gameObject.id).addChildAt(r,0),this.texts[e.gameObject.id]={text:r,component:e.component},this.setSize(e)):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))),[2]}))},new((i=void 0)||(i=Promise))((function(e,t){function o(e){try{c(s.next(e))}catch(e){t(e)}}function a(e){try{c(s.throw(e))}catch(e){t(e)}}function c(t){t.done?e(t.value):new i((function(e){e(t.value)})).then(o,a)}c((s=s.apply(n,r||[])).next())}));var n,r,i,s},n.prototype.change=function(e){var t=this.texts[e.gameObject.id],n=t.text,r=t.component;"text"===e.prop.prop[0]?n.text=r.text:"style"===e.prop.prop[0]&&Object.assign(n.style,e.component.style)},n.prototype.setSize=function(e){var t=e.gameObject.transform;t&&(t.size.width=this.texts[e.gameObject.id].text.width,t.size.height=this.texts[e.gameObject.id].text.height)},n.systemName="Text",n=a([t.decorators.componentObserver({Text:["text",{prop:["style"],deep:!0}]})],n)}(r.Renderer);exports.Text=u,exports.TextSystem=l;
@@ -6,49 +6,47 @@ import { RendererManager } from '@eva/plugin-renderer';
6
6
  import { RendererSystem } from '@eva/plugin-renderer';
7
7
  import { Text as Text_3 } from '@eva/renderer-adapter';
8
8
 
9
- declare class Style {
10
- align?: string;
11
- breakWords?: boolean;
12
- dropShadow?: boolean;
13
- dropShadowAlpha?: number;
14
- dropShadowAngle?: number;
15
- dropShadowBlur?: number;
16
- dropShadowColor?: string | number;
17
- dropShadowDistance?: number;
18
- fill?: string | string[] | number | number[] | CanvasGradient | CanvasPattern;
19
- fillGradientType?: number;
20
- fillGradientStops?: number[];
21
- fontFamily?: string | string[];
22
- fontSize?: number | string;
23
- fontStyle?: string;
24
- fontVariant?: string;
25
- fontWeight?: string;
26
- letterSpacing?: number;
27
- lineHeight?: number;
28
- lineJoin?: string;
29
- miterLimit?: number;
30
- padding?: number;
31
- stroke?: string | number;
32
- strokeThickness?: number;
33
- textBaseline?: string;
34
- trim?: boolean;
35
- whiteSpace?: string;
36
- wordWrap?: boolean;
37
- wordWrapWidth?: number;
38
- leading?: number;
39
- }
40
-
41
9
  declare class Text_2 extends Component<TextParams> {
42
10
  static componentName: string;
43
11
  text: string;
44
- style: Style;
12
+ style: TextParams['style'];
45
13
  init(obj?: TextParams): void;
46
14
  }
47
15
  export { Text_2 as Text }
48
16
 
49
17
  export declare interface TextParams {
50
18
  text: string;
51
- style?: Style;
19
+ style?: {
20
+ align?: string;
21
+ breakWords?: boolean;
22
+ dropShadow?: boolean;
23
+ dropShadowAlpha?: number;
24
+ dropShadowAngle?: number;
25
+ dropShadowBlur?: number;
26
+ dropShadowColor?: string | number;
27
+ dropShadowDistance?: number;
28
+ fill?: string | string[] | number | number[] | CanvasGradient | CanvasPattern;
29
+ fillGradientType?: number;
30
+ fillGradientStops?: number[];
31
+ fontFamily?: string | string[];
32
+ fontSize?: number | string;
33
+ fontStyle?: string;
34
+ fontVariant?: string;
35
+ fontWeight?: string;
36
+ letterSpacing?: number;
37
+ lineHeight?: number;
38
+ lineJoin?: string;
39
+ miterLimit?: number;
40
+ padding?: number;
41
+ stroke?: string | number;
42
+ strokeThickness?: number;
43
+ textBaseline?: string;
44
+ trim?: boolean;
45
+ whiteSpace?: string;
46
+ wordWrap?: boolean;
47
+ wordWrapWidth?: number;
48
+ leading?: number;
49
+ };
52
50
  }
53
51
 
54
52
  export declare class TextSystem extends Renderer {
@@ -1,6 +1,6 @@
1
1
  import { TextStyle } from 'pixi.js';
2
2
  import { Component, decorators, OBSERVER_TYPE } from '@eva/eva.js';
3
- import { Field } from '@eva/inspector-decorator';
3
+ import { type } from '@eva/inspector-decorator';
4
4
  import { RendererSystem, Renderer } from '@eva/plugin-renderer';
5
5
  import { Text as Text$4 } from '@eva/renderer-adapter';
6
6
 
@@ -40,10 +40,6 @@ function __decorate(decorators, target, key, desc) {
40
40
  return c > 3 && r && Object.defineProperty(target, key, r), r;
41
41
  }
42
42
 
43
- function __metadata(metadataKey, metadataValue) {
44
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
45
- }
46
-
47
43
  function __awaiter(thisArg, _arguments, P, generator) {
48
44
  return new (P || (P = Promise))(function (resolve, reject) {
49
45
  function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
@@ -81,150 +77,6 @@ function __generator(thisArg, body) {
81
77
  }
82
78
  }
83
79
 
84
- var Color = (function () {
85
- function Color() {
86
- }
87
- Color.getProperties = function () {
88
- return 'color';
89
- };
90
- return Color;
91
- }());
92
- var Style = (function () {
93
- function Style() {
94
- }
95
- __decorate([
96
- Field({
97
- type: 'selector',
98
- isArray: false,
99
- options: ['center', 'left', 'right'],
100
- default: 'left',
101
- }),
102
- __metadata("design:type", String)
103
- ], Style.prototype, "align", void 0);
104
- __decorate([
105
- Field(),
106
- __metadata("design:type", Boolean)
107
- ], Style.prototype, "breakWords", void 0);
108
- __decorate([
109
- Field(),
110
- __metadata("design:type", Boolean)
111
- ], Style.prototype, "dropShadow", void 0);
112
- __decorate([
113
- Field({ default: 1 }),
114
- __metadata("design:type", Number)
115
- ], Style.prototype, "dropShadowAlpha", void 0);
116
- __decorate([
117
- Field({ default: Math.PI / 6 }),
118
- __metadata("design:type", Number)
119
- ], Style.prototype, "dropShadowAngle", void 0);
120
- __decorate([
121
- Field({ default: 0 }),
122
- __metadata("design:type", Number)
123
- ], Style.prototype, "dropShadowBlur", void 0);
124
- __decorate([
125
- Field(function () { return Color; }, { default: '#000000' }),
126
- __metadata("design:type", Object)
127
- ], Style.prototype, "dropShadowColor", void 0);
128
- __decorate([
129
- Field({ default: 5 }),
130
- __metadata("design:type", Number)
131
- ], Style.prototype, "dropShadowDistance", void 0);
132
- __decorate([
133
- Field(function () { return [Color]; }, { default: ['#000000'] }),
134
- __metadata("design:type", Object)
135
- ], Style.prototype, "fill", void 0);
136
- __decorate([
137
- Field({
138
- type: 'selector',
139
- options: { vertical: 1, horizontal: 0 },
140
- default: 1,
141
- filter: function (val) { return Number(val); },
142
- isArray: false,
143
- }),
144
- __metadata("design:type", Number)
145
- ], Style.prototype, "fillGradientType", void 0);
146
- __decorate([
147
- Field(function () { return Number; }, { step: 0.1, min: 0, max: 1 }),
148
- __metadata("design:type", Array)
149
- ], Style.prototype, "fillGradientStops", void 0);
150
- __decorate([
151
- Field(function () { return String; }, { default: 'Arial' }),
152
- __metadata("design:type", Object)
153
- ], Style.prototype, "fontFamily", void 0);
154
- __decorate([
155
- Field(function () { return Number; }, { min: 5, default: 26 }),
156
- __metadata("design:type", Object)
157
- ], Style.prototype, "fontSize", void 0);
158
- __decorate([
159
- Field({ type: 'selector', options: ['normal', 'italic', 'oblique'], default: 'normal' }),
160
- __metadata("design:type", String)
161
- ], Style.prototype, "fontStyle", void 0);
162
- __decorate([
163
- Field({ type: 'selector', options: ['normal', 'small-caps'], default: 'normal' }),
164
- __metadata("design:type", String)
165
- ], Style.prototype, "fontVariant", void 0);
166
- __decorate([
167
- Field({
168
- type: 'selector',
169
- options: ['normal', 'bold', 'bolder', 'lighter', '100', '200', '300', '400', '500', '600', '700', '800', '900'],
170
- default: 'normal',
171
- }),
172
- __metadata("design:type", String)
173
- ], Style.prototype, "fontWeight", void 0);
174
- __decorate([
175
- Field({ default: 0 }),
176
- __metadata("design:type", Number)
177
- ], Style.prototype, "letterSpacing", void 0);
178
- __decorate([
179
- Field({ default: 0 }),
180
- __metadata("design:type", Number)
181
- ], Style.prototype, "lineHeight", void 0);
182
- __decorate([
183
- Field({ type: 'selector', options: ['miter', 'round', 'bevel'], default: 'miter' }),
184
- __metadata("design:type", String)
185
- ], Style.prototype, "lineJoin", void 0);
186
- __decorate([
187
- Field({ default: 10 }),
188
- __metadata("design:type", Number)
189
- ], Style.prototype, "miterLimit", void 0);
190
- __decorate([
191
- Field({ default: 0 }),
192
- __metadata("design:type", Number)
193
- ], Style.prototype, "padding", void 0);
194
- __decorate([
195
- Field(function () { return Color; }, { default: '#000000' }),
196
- __metadata("design:type", Object)
197
- ], Style.prototype, "stroke", void 0);
198
- __decorate([
199
- Field({ default: 0, min: 0 }),
200
- __metadata("design:type", Number)
201
- ], Style.prototype, "strokeThickness", void 0);
202
- __decorate([
203
- Field({ default: 'alphabetic' }),
204
- __metadata("design:type", String)
205
- ], Style.prototype, "textBaseline", void 0);
206
- __decorate([
207
- Field(),
208
- __metadata("design:type", Boolean)
209
- ], Style.prototype, "trim", void 0);
210
- __decorate([
211
- Field({ default: 'pre', type: 'selector', options: ['normal', 'pre', 'pre-line'] }),
212
- __metadata("design:type", String)
213
- ], Style.prototype, "whiteSpace", void 0);
214
- __decorate([
215
- Field(),
216
- __metadata("design:type", Boolean)
217
- ], Style.prototype, "wordWrap", void 0);
218
- __decorate([
219
- Field({ default: 100 }),
220
- __metadata("design:type", Number)
221
- ], Style.prototype, "wordWrapWidth", void 0);
222
- __decorate([
223
- Field(),
224
- __metadata("design:type", Number)
225
- ], Style.prototype, "leading", void 0);
226
- return Style;
227
- }());
228
80
  var Text$2 = (function (_super) {
229
81
  __extends(Text, _super);
230
82
  function Text() {
@@ -251,24 +103,8 @@ var Text$2 = (function (_super) {
251
103
  };
252
104
  Text.componentName = 'Text';
253
105
  __decorate([
254
- Field({
255
- type: 'textarea',
256
- filter: function (text) {
257
- if (typeof text !== 'string') {
258
- return '';
259
- }
260
- if (text.length > 100) {
261
- return text.slice(0, 100);
262
- }
263
- return text;
264
- },
265
- }),
266
- __metadata("design:type", String)
106
+ type('string')
267
107
  ], Text.prototype, "text", void 0);
268
- __decorate([
269
- Field(),
270
- __metadata("design:type", Style)
271
- ], Text.prototype, "style", void 0);
272
108
  return Text;
273
109
  }(Component));
274
110
  var Text$3 = Text$2;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eva/plugin-renderer-text",
3
- "version": "1.2.7-editor.9",
3
+ "version": "1.2.8-alpha.0",
4
4
  "description": "@eva/plugin-renderer-text",
5
5
  "main": "index.js",
6
6
  "module": "dist/plugin-renderer-text.esm.js",
@@ -18,10 +18,10 @@
18
18
  "license": "MIT",
19
19
  "homepage": "https://eva.js.org",
20
20
  "dependencies": {
21
- "@eva/inspector-decorator": "0.1.0-alpha.2",
22
- "@eva/plugin-renderer": "1.2.7-editor.9",
23
- "@eva/renderer-adapter": "1.2.7-editor.9",
24
- "@eva/eva.js": "1.2.7-editor.9",
21
+ "@eva/inspector-decorator": "^0.0.5",
22
+ "@eva/plugin-renderer": "1.2.8-alpha.0",
23
+ "@eva/renderer-adapter": "1.2.8-alpha.0",
24
+ "@eva/eva.js": "1.2.8-alpha.0",
25
25
  "pixi.js": "^4.8.7"
26
26
  }
27
27
  }