@urso/core 0.4.39 → 0.4.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/js/index.js +1 -1
- package/package.json +1 -1
- package/src/js/lib/loader.js +4 -0
- package/src/js/modules/i18n/controller.js +6 -5
- package/src/js/modules/instances/controller.js +12 -2
- package/src/js/modules/objects/proxy.js +16 -0
- package/src/js/modules/objects/styles.js +9 -8
- package/src/js/modules/scenes/resolutions.js +1 -1
package/package.json
CHANGED
package/src/js/lib/loader.js
CHANGED
|
@@ -6,6 +6,8 @@ class ModulesI18nController {
|
|
|
6
6
|
* get text by localeId
|
|
7
7
|
* @param {String} localeId
|
|
8
8
|
* @param {Object} [localeVariables] - variables for locale string
|
|
9
|
+
*
|
|
10
|
+
* @example get('Some333 ${bet} " `test ${multi} text localized', {bet:12,multi:13})
|
|
9
11
|
*/
|
|
10
12
|
get(localeId, localeVariables = {}) {
|
|
11
13
|
if (this.#vocabulary && this.#vocabulary[localeId]) {
|
|
@@ -66,12 +68,11 @@ class ModulesI18nController {
|
|
|
66
68
|
}
|
|
67
69
|
|
|
68
70
|
_interpolate(string, params) {
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const resultEncodedString = new Function(...names, `return \`${encodedString}\`;`)(...vals);
|
|
71
|
+
for (const [key, value] of Object.entries(params)) {
|
|
72
|
+
string = Urso.helper.stringReplace('${' + key + '}', value, string);
|
|
73
|
+
}
|
|
73
74
|
|
|
74
|
-
return
|
|
75
|
+
return string
|
|
75
76
|
}
|
|
76
77
|
}
|
|
77
78
|
|
|
@@ -36,14 +36,24 @@ class ModulesInstancesController {
|
|
|
36
36
|
return true;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
/**
|
|
40
|
+
* remove mode from system
|
|
41
|
+
* @param {String} mode
|
|
42
|
+
* @param {Boolean} passiveMode - do not refresh styles
|
|
43
|
+
* @returns
|
|
44
|
+
*/
|
|
45
|
+
removeMode(mode, passiveMode) {
|
|
40
46
|
let index = this._modes.indexOf(mode);
|
|
41
47
|
|
|
42
48
|
if (index === -1)
|
|
43
49
|
return false;
|
|
44
50
|
|
|
45
51
|
this._modes.splice(index, 1);
|
|
46
|
-
|
|
52
|
+
|
|
53
|
+
if (!passiveMode) {
|
|
54
|
+
Urso.observer.emit(Urso.events.MODULES_INSTANCES_MODES_CHANGED);
|
|
55
|
+
}
|
|
56
|
+
|
|
47
57
|
return true;
|
|
48
58
|
}
|
|
49
59
|
|
|
@@ -101,6 +101,22 @@ class ModulesObjectsProxy {
|
|
|
101
101
|
if (!target.maxWidth && !target.maxHeight)
|
|
102
102
|
return;
|
|
103
103
|
|
|
104
|
+
let calculationNeed = false;
|
|
105
|
+
|
|
106
|
+
const baseObject = target._baseObject;
|
|
107
|
+
//Pixi texts have _texture.orig.width. When we call baseObject.width, Pixi runs update text. Its too slow operation.
|
|
108
|
+
const baseObjectWidth = baseObject._texture ? Math.abs(baseObject.scale.x) * baseObject._texture.orig.width : baseObject.width;
|
|
109
|
+
const baseObjectHeight = baseObject._texture ? Math.abs(baseObject.scale.y) * baseObject._texture.orig.height : baseObject.height;
|
|
110
|
+
|
|
111
|
+
if (target.maxWidth && target.maxWidth < baseObjectWidth) //check maxWidth
|
|
112
|
+
calculationNeed = true;
|
|
113
|
+
|
|
114
|
+
if (target.maxHeight && target.maxHeight < baseObjectHeight) //check maxHeight
|
|
115
|
+
calculationNeed = true;
|
|
116
|
+
|
|
117
|
+
if (!calculationNeed)
|
|
118
|
+
return;
|
|
119
|
+
|
|
104
120
|
let scaleNeed = 1;
|
|
105
121
|
|
|
106
122
|
if (target.maxWidth) {
|
|
@@ -42,7 +42,6 @@ class ModulesObjectsStyles {
|
|
|
42
42
|
delete this._cache[selector];
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
-
|
|
46
45
|
}
|
|
47
46
|
|
|
48
47
|
_apply(selector, style) {
|
|
@@ -68,7 +67,7 @@ class ModulesObjectsStyles {
|
|
|
68
67
|
_globalResetStyles() {
|
|
69
68
|
for (let [selector, selectorCache] of Object.entries(this._cache)) {
|
|
70
69
|
for (let [uid, object] of Object.entries(selectorCache))
|
|
71
|
-
this._removeSelectorStyles(object, selector);
|
|
70
|
+
this._removeSelectorStyles(object, selector, true);
|
|
72
71
|
|
|
73
72
|
delete this._cache[selector];
|
|
74
73
|
}
|
|
@@ -84,7 +83,7 @@ class ModulesObjectsStyles {
|
|
|
84
83
|
}
|
|
85
84
|
}
|
|
86
85
|
|
|
87
|
-
_removeSelectorStyles(object, selector) {
|
|
86
|
+
_removeSelectorStyles(object, selector, globalResetFlag) {
|
|
88
87
|
delete object._styles[selector];
|
|
89
88
|
let template = Urso.template.get();
|
|
90
89
|
let styles = template.styles[selector];
|
|
@@ -94,12 +93,12 @@ class ModulesObjectsStyles {
|
|
|
94
93
|
}
|
|
95
94
|
|
|
96
95
|
for (let [key, value] of Object.entries(styles)) {
|
|
97
|
-
this._restoreValueByKey(key, object);
|
|
96
|
+
this._restoreValueByKey(key, object, globalResetFlag);
|
|
98
97
|
}
|
|
99
98
|
|
|
100
99
|
}
|
|
101
100
|
|
|
102
|
-
_restoreValueByKey(key, object) {
|
|
101
|
+
_restoreValueByKey(key, object, globalResetFlag) {
|
|
103
102
|
//check own
|
|
104
103
|
if (object._originalModel[key])
|
|
105
104
|
return;
|
|
@@ -110,9 +109,11 @@ class ModulesObjectsStyles {
|
|
|
110
109
|
Urso.objects._safeSetValueToTarget(object, key, tempObject[key]);
|
|
111
110
|
|
|
112
111
|
//check other styles
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
112
|
+
if (!globalResetFlag) {
|
|
113
|
+
for (let [selector, style] of Object.entries(object._styles))
|
|
114
|
+
if (typeof style[key] !== 'undefined')
|
|
115
|
+
Urso.objects._safeSetValueToTarget(object, key, style[key]);
|
|
116
|
+
}
|
|
116
117
|
}
|
|
117
118
|
}
|
|
118
119
|
|
|
@@ -55,7 +55,7 @@ class ModulesScenesResolutions {
|
|
|
55
55
|
this._currentOrientation = this._templateSize.orientation;
|
|
56
56
|
|
|
57
57
|
//update InstancesModes
|
|
58
|
-
Object.values(Urso.device.ScreenOrientation).forEach((orientationValue) => Urso.removeInstancesMode(orientationValue + 'Orientation'));
|
|
58
|
+
Object.values(Urso.device.ScreenOrientation).forEach((orientationValue) => Urso.removeInstancesMode(orientationValue + 'Orientation', true));
|
|
59
59
|
Urso.addInstancesMode(this._templateSize.orientation + 'Orientation');
|
|
60
60
|
|
|
61
61
|
this.emit(Urso.events.MODULES_SCENES_ORIENTATION_CHANGE, this._templateSize.orientation);
|