@urso/core 0.6.2 → 0.6.3
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
|
@@ -16,6 +16,13 @@ class ModulesInstancesController {
|
|
|
16
16
|
this.removeMode = this.removeMode.bind(this);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
* get class by Path
|
|
21
|
+
* @param {String} path
|
|
22
|
+
* @param {Boolean} [noModes]
|
|
23
|
+
* @param {String} [modeName]
|
|
24
|
+
* @returns {Class}
|
|
25
|
+
*/
|
|
19
26
|
getByPath(path, noModes, modeName) {
|
|
20
27
|
let callback = (a) => {
|
|
21
28
|
return a;
|
|
@@ -24,10 +31,19 @@ class ModulesInstancesController {
|
|
|
24
31
|
return this._findClass({ path, callback, noModes, modeName });
|
|
25
32
|
}
|
|
26
33
|
|
|
34
|
+
/**
|
|
35
|
+
* get current modes
|
|
36
|
+
* @returns {Array}
|
|
37
|
+
*/
|
|
27
38
|
getModes() {
|
|
28
39
|
return this._modes;
|
|
29
40
|
}
|
|
30
41
|
|
|
42
|
+
/**
|
|
43
|
+
* add mode to system
|
|
44
|
+
* @param {String} mode
|
|
45
|
+
* @returns {Boolean}
|
|
46
|
+
*/
|
|
31
47
|
addMode(mode) {
|
|
32
48
|
if (this._modes.indexOf(mode) !== -1)
|
|
33
49
|
return false;
|
|
@@ -40,8 +56,8 @@ class ModulesInstancesController {
|
|
|
40
56
|
/**
|
|
41
57
|
* remove mode from system
|
|
42
58
|
* @param {String} mode
|
|
43
|
-
* @param {Boolean} passiveMode - do not refresh styles
|
|
44
|
-
* @returns
|
|
59
|
+
* @param {Boolean} [passiveMode] - do not refresh styles
|
|
60
|
+
* @returns {Boolean}
|
|
45
61
|
*/
|
|
46
62
|
removeMode(mode, passiveMode) {
|
|
47
63
|
let index = this._modes.indexOf(mode);
|
|
@@ -58,6 +74,14 @@ class ModulesInstancesController {
|
|
|
58
74
|
return true;
|
|
59
75
|
}
|
|
60
76
|
|
|
77
|
+
/**
|
|
78
|
+
* get class instance by path
|
|
79
|
+
* @param {String} path
|
|
80
|
+
* @param {mixed} [params]
|
|
81
|
+
* @param {Boolean} [noModes]
|
|
82
|
+
* @param {String} [modeName]
|
|
83
|
+
* @returns {Class | false}
|
|
84
|
+
*/
|
|
61
85
|
getInstance(path, params, noModes, modeName) {
|
|
62
86
|
let callback = (classObject) => {
|
|
63
87
|
if (typeof classObject !== "function") { //typeof class is a function
|
|
@@ -84,11 +108,20 @@ class ModulesInstancesController {
|
|
|
84
108
|
return this._findClass({ path, callback, noModes, modeName });
|
|
85
109
|
}
|
|
86
110
|
|
|
111
|
+
/**
|
|
112
|
+
* get uid for instance
|
|
113
|
+
* @returns {String}
|
|
114
|
+
*/
|
|
87
115
|
_getUid() {
|
|
88
116
|
this._counter++;
|
|
89
117
|
return 'instance' + this._counter;
|
|
90
118
|
}
|
|
91
119
|
|
|
120
|
+
/**
|
|
121
|
+
* set common functions to instance
|
|
122
|
+
* @param {Class} classObject
|
|
123
|
+
* @param {String} path
|
|
124
|
+
*/
|
|
92
125
|
_setComonFunctions(classObject, path) {
|
|
93
126
|
classObject.prototype.getInstance = this._entityGetInstance(path);
|
|
94
127
|
classObject.prototype.addListener = this._entityAddListener;
|
|
@@ -96,6 +129,11 @@ class ModulesInstancesController {
|
|
|
96
129
|
classObject.prototype.emit = this._entityEmit;
|
|
97
130
|
}
|
|
98
131
|
|
|
132
|
+
/**
|
|
133
|
+
* set common entities functions to instance
|
|
134
|
+
* @param {Class} classObject
|
|
135
|
+
* @param {ClassInstance} callerObject
|
|
136
|
+
*/
|
|
99
137
|
_setComonEntityFunctions(classObject, callerObject) {
|
|
100
138
|
if (callerObject.common && !classObject.common) { //components common
|
|
101
139
|
classObject.common = callerObject.common;
|
|
@@ -106,6 +144,10 @@ class ModulesInstancesController {
|
|
|
106
144
|
}
|
|
107
145
|
}
|
|
108
146
|
|
|
147
|
+
/**
|
|
148
|
+
* launch default functions after creation
|
|
149
|
+
* @param {ClassInstance} instance
|
|
150
|
+
*/
|
|
109
151
|
_launchDefaultFunctions(instance) {
|
|
110
152
|
//_subscribe
|
|
111
153
|
if (instance && instance._subscribe)
|
|
@@ -118,6 +160,11 @@ class ModulesInstancesController {
|
|
|
118
160
|
}
|
|
119
161
|
}
|
|
120
162
|
|
|
163
|
+
/**
|
|
164
|
+
* entity get instance (with parent deps)
|
|
165
|
+
* @param {String} path
|
|
166
|
+
* @returns {Function}
|
|
167
|
+
*/
|
|
121
168
|
_entityGetInstance(path) {
|
|
122
169
|
const entityPath = Urso.helper.initial(path.split('.')).join('.');
|
|
123
170
|
const self = this;
|
|
@@ -138,6 +185,11 @@ class ModulesInstancesController {
|
|
|
138
185
|
};
|
|
139
186
|
}
|
|
140
187
|
|
|
188
|
+
/**
|
|
189
|
+
* add entity to caller class
|
|
190
|
+
* @param {ClassInstance} classObject
|
|
191
|
+
* @param {ClassInstance} callerObject
|
|
192
|
+
*/
|
|
141
193
|
_addEntityToClass(classObject, callerObject) {
|
|
142
194
|
if (!callerObject.__entities)
|
|
143
195
|
callerObject.__entities = [];
|
|
@@ -146,18 +198,32 @@ class ModulesInstancesController {
|
|
|
146
198
|
callerObject.__entities.push(classObject);
|
|
147
199
|
}
|
|
148
200
|
|
|
201
|
+
/**
|
|
202
|
+
* entity addListener function
|
|
203
|
+
*/
|
|
149
204
|
_entityAddListener() {
|
|
150
205
|
Urso.observer.add.apply(Urso.observer, arguments);
|
|
151
206
|
}
|
|
152
207
|
|
|
208
|
+
/**
|
|
209
|
+
* entity removeListener function
|
|
210
|
+
*/
|
|
153
211
|
_entityRemoveListener() {
|
|
154
212
|
Urso.observer.remove.apply(Urso.observer, arguments);
|
|
155
213
|
}
|
|
156
214
|
|
|
215
|
+
/**
|
|
216
|
+
* entity emit function
|
|
217
|
+
*/
|
|
157
218
|
_entityEmit() {
|
|
158
219
|
Urso.observer.fire.apply(Urso.observer, arguments);
|
|
159
220
|
}
|
|
160
221
|
|
|
222
|
+
/**
|
|
223
|
+
* find class by params
|
|
224
|
+
* @param {Object} params
|
|
225
|
+
* @returns {Class | false}
|
|
226
|
+
*/
|
|
161
227
|
_findClass(params) {
|
|
162
228
|
//put all params exept callback in key
|
|
163
229
|
let cacheKey = [
|
|
@@ -190,6 +256,12 @@ class ModulesInstancesController {
|
|
|
190
256
|
return params.callback(this._cache[cacheKey]);
|
|
191
257
|
}
|
|
192
258
|
|
|
259
|
+
/**
|
|
260
|
+
* get class by path
|
|
261
|
+
* @param {String} path
|
|
262
|
+
* @param {Boolean} [noModes]
|
|
263
|
+
* @returns {Class | false}
|
|
264
|
+
*/
|
|
193
265
|
_getClassByPath(path, noModes) {
|
|
194
266
|
let pathArr = path.split('.');
|
|
195
267
|
let entitiesArray = Urso.helper.mergeArrays(['Urso', 'Game'], pathArr);
|
|
@@ -199,7 +271,7 @@ class ModulesInstancesController {
|
|
|
199
271
|
/**
|
|
200
272
|
* check if object exist
|
|
201
273
|
* @param {Object} entitiesArray like ['Urso', 'Game', 'Lib', 'Helper']
|
|
202
|
-
* @returns {
|
|
274
|
+
* @returns {Class | false}
|
|
203
275
|
*/
|
|
204
276
|
_checkPathExist(entitiesArray, noModes) {
|
|
205
277
|
let currentTestObject = window;
|
|
@@ -235,6 +307,13 @@ class ModulesInstancesController {
|
|
|
235
307
|
return currentTestObject;
|
|
236
308
|
}
|
|
237
309
|
|
|
310
|
+
/**
|
|
311
|
+
* check path for modes
|
|
312
|
+
* @param {Object} currentTestObject
|
|
313
|
+
* @param {Array} entitiesArray
|
|
314
|
+
* @param {Number} entitiesIndex
|
|
315
|
+
* @returns {Class | false}
|
|
316
|
+
*/
|
|
238
317
|
_checkPathWithModes(currentTestObject, entitiesArray, entitiesIndex) {
|
|
239
318
|
for (let mode of this._modes) {
|
|
240
319
|
const capMode = Urso.helper.capitaliseFirstLetter(mode);
|
|
@@ -253,6 +332,13 @@ class ModulesInstancesController {
|
|
|
253
332
|
return false;
|
|
254
333
|
}
|
|
255
334
|
|
|
335
|
+
/**
|
|
336
|
+
* check path for mixins
|
|
337
|
+
* @param {Object} currentTestObject
|
|
338
|
+
* @param {Array} entitiesArray
|
|
339
|
+
* @param {Number} entitiesIndex
|
|
340
|
+
* @returns {Array}
|
|
341
|
+
*/
|
|
256
342
|
_getMixins(currentTestObject, entitiesArray, entitiesIndex) {
|
|
257
343
|
const mixins = [];
|
|
258
344
|
|