@eva/plugin-renderer-text 1.2.8-fix.1 → 1.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign
|
|
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 || {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function _extends(){return
|
|
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 };
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eva/plugin-renderer-text",
|
|
3
|
-
"version": "1.2.8
|
|
3
|
+
"version": "1.2.8",
|
|
4
4
|
"description": "@eva/plugin-renderer-text",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "dist/plugin-renderer-text.esm.js",
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"homepage": "https://eva.js.org",
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@eva/inspector-decorator": "^0.0.5",
|
|
22
|
-
"@eva/plugin-renderer": "1.2.8
|
|
23
|
-
"@eva/renderer-adapter": "1.2.8
|
|
24
|
-
"@eva/eva.js": "1.2.8
|
|
22
|
+
"@eva/plugin-renderer": "1.2.8",
|
|
23
|
+
"@eva/renderer-adapter": "1.2.8",
|
|
24
|
+
"@eva/eva.js": "1.2.8",
|
|
25
25
|
"pixi.js": "^4.8.7"
|
|
26
26
|
}
|
|
27
27
|
}
|