@urso/core 0.7.23 → 0.7.25
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/package.json
CHANGED
package/src/js/lib/helper.js
CHANGED
|
@@ -582,6 +582,23 @@ class LibHelper {
|
|
|
582
582
|
|
|
583
583
|
return results;
|
|
584
584
|
}
|
|
585
|
+
|
|
586
|
+
/**
|
|
587
|
+
* apply params to string
|
|
588
|
+
* @param {String} string
|
|
589
|
+
* @param {Object} params
|
|
590
|
+
* @returns {String}
|
|
591
|
+
*
|
|
592
|
+
* @example interpolate('Bet ${bet} with Multi ${multi}', {bet:12,multi:13})
|
|
593
|
+
* returns 'Bet 12 with Multi 13'
|
|
594
|
+
*/
|
|
595
|
+
interpolate(string, params) {
|
|
596
|
+
for (const [key, value] of Object.entries(params)) {
|
|
597
|
+
string = Urso.helper.stringReplace('${' + key + '}', value, string);
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
return string
|
|
601
|
+
}
|
|
585
602
|
}
|
|
586
603
|
|
|
587
604
|
module.exports = LibHelper;
|
|
@@ -11,7 +11,7 @@ class ModulesI18nController {
|
|
|
11
11
|
*/
|
|
12
12
|
get(localeId, localeVariables = {}) {
|
|
13
13
|
if (this.#vocabulary && this.#vocabulary[localeId]) {
|
|
14
|
-
return
|
|
14
|
+
return Urso.helper.interpolate(this.#vocabulary[localeId], localeVariables);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
return localeId;
|
|
@@ -66,14 +66,6 @@ class ModulesI18nController {
|
|
|
66
66
|
const localeAsset = { type: Urso.types.assets.JSON, key: localeKey, path: pathToLocaleJson };
|
|
67
67
|
Urso.assets.preload(localeAsset, () => this.setLocale(localeKey));
|
|
68
68
|
}
|
|
69
|
-
|
|
70
|
-
_interpolate(string, params) {
|
|
71
|
-
for (const [key, value] of Object.entries(params)) {
|
|
72
|
-
string = Urso.helper.stringReplace('${' + key + '}', value, string);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return string
|
|
76
|
-
}
|
|
77
69
|
}
|
|
78
70
|
|
|
79
71
|
module.exports = ModulesI18nController;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
class ModulesLogicController {
|
|
2
|
-
constructor() {
|
|
2
|
+
constructor() {
|
|
3
3
|
this._baseLogicBlocks = ['main', 'sounds'];
|
|
4
4
|
const additionalLogicBlocks = this.getAdditionalLogicBlocks();
|
|
5
5
|
this.logicBlocks = [...this._baseLogicBlocks, ...additionalLogicBlocks];
|
|
@@ -7,16 +7,16 @@ class ModulesLogicController {
|
|
|
7
7
|
this._instances = {};
|
|
8
8
|
this._init();
|
|
9
9
|
};
|
|
10
|
-
|
|
11
|
-
_init(){
|
|
10
|
+
|
|
11
|
+
_init() {
|
|
12
12
|
this._createLogicInstances();
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
getAdditionalLogicBlocks(){
|
|
15
|
+
getAdditionalLogicBlocks() {
|
|
16
16
|
return [];
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
_createLogicInstances(){
|
|
19
|
+
_createLogicInstances() {
|
|
20
20
|
//console.log('[Modules.Brain.Controller]', ' Creating logic blocks:', JSON.stringify(this.logicBlocks));
|
|
21
21
|
|
|
22
22
|
for (let i = 0; i < this.logicBlocks.length; i++) {
|
|
@@ -26,23 +26,27 @@ class ModulesLogicController {
|
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
/**
|
|
30
|
+
* launch function with current name (first agrument) per each logic block (if exists)
|
|
31
|
+
* @returns {Mixed}
|
|
32
|
+
*/
|
|
33
|
+
do() {
|
|
30
34
|
const results = [];
|
|
31
|
-
const params =
|
|
32
|
-
const
|
|
35
|
+
const params = [...arguments];
|
|
36
|
+
const functionName = params.shift();
|
|
33
37
|
|
|
34
38
|
for (let blockName in this._instances) {
|
|
35
39
|
const instance = this._instances[blockName];
|
|
36
40
|
|
|
37
|
-
if(instance && instance[
|
|
38
|
-
results[blockName] = instance[
|
|
41
|
+
if (instance && instance[functionName]) {
|
|
42
|
+
results[blockName] = instance[functionName].apply(this, params);
|
|
39
43
|
}
|
|
40
44
|
}
|
|
41
45
|
|
|
42
|
-
|
|
46
|
+
return results;
|
|
43
47
|
};
|
|
44
48
|
|
|
45
|
-
_subscribe(){};
|
|
49
|
+
_subscribe() { };
|
|
46
50
|
}
|
|
47
51
|
|
|
48
52
|
module.exports = ModulesLogicController;
|