@urso/core 0.5.3 → 0.5.6

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.
Files changed (158) hide show
  1. package/.babelrc +11 -11
  2. package/LICENSE +20 -20
  3. package/README.md +220 -220
  4. package/build/js/index.js +1 -1
  5. package/build/js/index.js.LICENSE.txt +222 -38
  6. package/package.json +52 -52
  7. package/src/js/app.js +78 -78
  8. package/src/js/components/_info.js +10 -10
  9. package/src/js/components/base/_info.js +3 -3
  10. package/src/js/components/base/controller.js +78 -78
  11. package/src/js/components/debug/_info.js +7 -7
  12. package/src/js/components/debug/controller.js +38 -38
  13. package/src/js/components/debug/coords.js +23 -23
  14. package/src/js/components/debug/fps.js +34 -34
  15. package/src/js/components/debug/template.js +55 -55
  16. package/src/js/components/debug/timescale.js +60 -60
  17. package/src/js/components/deviceRotate/_info.js +3 -3
  18. package/src/js/components/deviceRotate/controller.js +86 -86
  19. package/src/js/components/fullscreen/_info.js +6 -6
  20. package/src/js/components/fullscreen/android.js +104 -104
  21. package/src/js/components/fullscreen/controller.js +76 -76
  22. package/src/js/components/fullscreen/desktop.js +49 -49
  23. package/src/js/components/fullscreen/ios.js +115 -115
  24. package/src/js/components/layersSwitcher/_info.js +4 -4
  25. package/src/js/components/layersSwitcher/config.js +26 -26
  26. package/src/js/components/layersSwitcher/controller.js +34 -34
  27. package/src/js/components/loader/_info.js +4 -4
  28. package/src/js/components/loader/controller.js +66 -66
  29. package/src/js/components/loader/template.js +70 -70
  30. package/src/js/components/soundInitialPopup/_info.js +3 -3
  31. package/src/js/components/soundInitialPopup/controller.js +42 -42
  32. package/src/js/components/soundInitialPopup/template.js +109 -109
  33. package/src/js/components/stateDriven/_info.js +3 -3
  34. package/src/js/components/stateDriven/controller.js +118 -118
  35. package/src/js/config/load.js +5 -5
  36. package/src/js/config/main.js +12 -12
  37. package/src/js/extra/_info.js +26 -26
  38. package/src/js/extra/browserEvents.js +38 -38
  39. package/src/js/extra/pixiPatch.js +79 -79
  40. package/src/js/extra/setTimeout.js +7 -7
  41. package/src/js/index.js +8 -8
  42. package/src/js/lib/_info.js +13 -13
  43. package/src/js/lib/cache.js +105 -105
  44. package/src/js/lib/composition.js +85 -85
  45. package/src/js/lib/device.js +1286 -1286
  46. package/src/js/lib/helper.js +539 -539
  47. package/src/js/lib/loader.js +136 -136
  48. package/src/js/lib/localData.js +15 -15
  49. package/src/js/lib/logger.js +69 -69
  50. package/src/js/lib/math.js +35 -35
  51. package/src/js/lib/objectPool.js +54 -54
  52. package/src/js/lib/time.js +18 -18
  53. package/src/js/lib/tween.js +147 -147
  54. package/src/js/modules/_info.js +12 -12
  55. package/src/js/modules/assets/_info.js +7 -7
  56. package/src/js/modules/assets/baseModel.js +18 -18
  57. package/src/js/modules/assets/config.js +37 -37
  58. package/src/js/modules/assets/controller.js +46 -46
  59. package/src/js/modules/assets/models/_info.js +11 -11
  60. package/src/js/modules/assets/models/atlas.js +8 -8
  61. package/src/js/modules/assets/models/audiosprite.js +27 -27
  62. package/src/js/modules/assets/models/bitmapFont.js +8 -8
  63. package/src/js/modules/assets/models/container.js +16 -16
  64. package/src/js/modules/assets/models/font.js +8 -8
  65. package/src/js/modules/assets/models/image.js +13 -13
  66. package/src/js/modules/assets/models/json.js +8 -8
  67. package/src/js/modules/assets/models/sound.js +14 -14
  68. package/src/js/modules/assets/models/spine.js +14 -14
  69. package/src/js/modules/assets/service.js +365 -365
  70. package/src/js/modules/i18n/_info.js +4 -4
  71. package/src/js/modules/i18n/config.js +17 -17
  72. package/src/js/modules/i18n/controller.js +79 -79
  73. package/src/js/modules/instances/_info.js +3 -3
  74. package/src/js/modules/instances/controller.js +261 -261
  75. package/src/js/modules/logic/_info.js +4 -4
  76. package/src/js/modules/logic/config/_info.js +2 -2
  77. package/src/js/modules/logic/config/sounds.js +23 -23
  78. package/src/js/modules/logic/controller.js +48 -48
  79. package/src/js/modules/logic/sounds.js +103 -103
  80. package/src/js/modules/objects/_info.js +12 -11
  81. package/src/js/modules/objects/baseModel.js +197 -197
  82. package/src/js/modules/objects/cache.js +99 -99
  83. package/src/js/modules/objects/controller.js +131 -131
  84. package/src/js/modules/objects/find.js +58 -140
  85. package/src/js/modules/objects/models/_info.js +26 -26
  86. package/src/js/modules/objects/models/atlasImage.js +50 -50
  87. package/src/js/modules/objects/models/bitmapText.js +39 -39
  88. package/src/js/modules/objects/models/button.js +189 -189
  89. package/src/js/modules/objects/models/buttonComposite.js +35 -35
  90. package/src/js/modules/objects/models/checkbox.js +96 -96
  91. package/src/js/modules/objects/models/collection.js +54 -54
  92. package/src/js/modules/objects/models/component.js +44 -44
  93. package/src/js/modules/objects/models/container.js +19 -19
  94. package/src/js/modules/objects/models/emitter.js +67 -67
  95. package/src/js/modules/objects/models/emitterFx.js +99 -99
  96. package/src/js/modules/objects/models/graphics.js +38 -38
  97. package/src/js/modules/objects/models/group.js +19 -19
  98. package/src/js/modules/objects/models/hitArea.js +104 -104
  99. package/src/js/modules/objects/models/image.js +34 -34
  100. package/src/js/modules/objects/models/imagesAnimation.js +113 -113
  101. package/src/js/modules/objects/models/mask.js +38 -38
  102. package/src/js/modules/objects/models/nineSlicePlane.js +30 -30
  103. package/src/js/modules/objects/models/scrollbox.js +64 -61
  104. package/src/js/modules/objects/models/slider.js +253 -253
  105. package/src/js/modules/objects/models/spine.js +276 -276
  106. package/src/js/modules/objects/models/text.js +59 -59
  107. package/src/js/modules/objects/models/textInput.js +66 -66
  108. package/src/js/modules/objects/models/toggle.js +180 -180
  109. package/src/js/modules/objects/models/world.js +19 -19
  110. package/src/js/modules/objects/propertyAdapter.js +423 -423
  111. package/src/js/modules/objects/proxy.js +282 -282
  112. package/src/js/modules/objects/selector.js +136 -0
  113. package/src/js/modules/objects/service.js +240 -240
  114. package/src/js/modules/objects/styles.js +210 -120
  115. package/src/js/modules/observer/_info.js +4 -4
  116. package/src/js/modules/observer/controller.js +99 -99
  117. package/src/js/modules/observer/events.js +45 -45
  118. package/src/js/modules/scenes/_info.js +8 -8
  119. package/src/js/modules/scenes/controller.js +103 -103
  120. package/src/js/modules/scenes/model.js +28 -28
  121. package/src/js/modules/scenes/pixiWrapper.js +237 -237
  122. package/src/js/modules/scenes/resolutions.js +173 -173
  123. package/src/js/modules/scenes/resolutionsConfig.js +73 -73
  124. package/src/js/modules/scenes/service.js +142 -142
  125. package/src/js/modules/soundManager/_info.js +3 -3
  126. package/src/js/modules/soundManager/controller.js +100 -100
  127. package/src/js/modules/soundManager/soundSprite.js +256 -243
  128. package/src/js/modules/statesManager/_info.js +12 -12
  129. package/src/js/modules/statesManager/action.js +60 -60
  130. package/src/js/modules/statesManager/actions/_info.js +3 -3
  131. package/src/js/modules/statesManager/all.js +23 -23
  132. package/src/js/modules/statesManager/configStates.js +71 -71
  133. package/src/js/modules/statesManager/controller.js +170 -170
  134. package/src/js/modules/statesManager/functionsStorage.js +82 -82
  135. package/src/js/modules/statesManager/helper.js +27 -27
  136. package/src/js/modules/statesManager/race.js +75 -75
  137. package/src/js/modules/statesManager/sequence.js +47 -47
  138. package/src/js/modules/template/_info.js +6 -6
  139. package/src/js/modules/template/controller.js +28 -28
  140. package/src/js/modules/template/model.js +11 -11
  141. package/src/js/modules/template/service.js +137 -137
  142. package/src/js/modules/template/types.js +46 -46
  143. package/src/js/modules/transport/_info.js +8 -8
  144. package/src/js/modules/transport/baseConnectionType.js +24 -24
  145. package/src/js/modules/transport/config.js +13 -13
  146. package/src/js/modules/transport/connectionTypes/_info.js +3 -3
  147. package/src/js/modules/transport/connectionTypes/websocket.js +74 -74
  148. package/src/js/modules/transport/connectionTypes/xhr.js +44 -44
  149. package/src/js/modules/transport/controller.js +48 -48
  150. package/src/js/modules/transport/decorator.js +17 -17
  151. package/src/js/modules/transport/service.js +153 -153
  152. package/src/js/templates/_info.js +4 -4
  153. package/src/js/templates/groups/_info.js +1 -1
  154. package/src/js/templates/scenes/_info.js +1 -1
  155. package/webpack.config.js +47 -47
  156. package/src/js/components/editor/_info.js +0 -4
  157. package/src/js/components/editor/api.js +0 -72
  158. package/src/js/components/editor/controller.js +0 -13
@@ -0,0 +1,136 @@
1
+ /**
2
+ * tools for selector parse and objects check
3
+ */
4
+ class ModulesObjectsSelector {
5
+
6
+ constructor() {
7
+ this.singleton = true;
8
+ };
9
+
10
+ /**
11
+ * test object for selector
12
+ * @param {Object} testObject
13
+ * @param {String} selector
14
+ * @returns {Boolean}
15
+ */
16
+ testObject(testObject, selector) {
17
+ let selectorsPartsParsed = this.parse(selector);
18
+ return this.testObjectWithParsedSelector(testObject, selectorsPartsParsed);
19
+ }
20
+
21
+ /**
22
+ * test object for selector parts array
23
+ * @param {Object} testObject
24
+ * @param {Array} selectorsPartsParsed
25
+ * @returns {Boolean}
26
+ */
27
+ testObjectWithParsedSelector(testObject, selectorsPartsParsed) {
28
+ let properties = selectorsPartsParsed[
29
+ selectorsPartsParsed.length - 1
30
+ ];
31
+
32
+ if (!this._testObjectsProperties(testObject, properties))
33
+ return false;
34
+
35
+ if (selectorsPartsParsed.length === 1)
36
+ return true;
37
+
38
+ //now we will check objects parents (for complex selectors)
39
+ let parent = testObject.parent;
40
+
41
+ for (let i = selectorsPartsParsed.length - 2; i >= 0; i--) {
42
+ let parentProperties = selectorsPartsParsed[i];
43
+ let expectedParentFoundFlag = 0;
44
+
45
+ while (expectedParentFoundFlag !== 1 && parent) {
46
+ if (this._testObjectsProperties(parent, parentProperties))
47
+ expectedParentFoundFlag = 1;
48
+
49
+ parent = parent.parent;
50
+ }
51
+
52
+ if (expectedParentFoundFlag === 1 && i === 0) //last property from selector and all is good
53
+ return true;
54
+
55
+ if (expectedParentFoundFlag === 0)
56
+ return false;
57
+ }
58
+ }
59
+
60
+ /**
61
+ * test object for properties list
62
+ * @param {Object} object
63
+ * @param {Array} properties - class, id or name with value. [{type:'class',value:'someClassName'}...]
64
+ * @returns {Boolean}
65
+ */
66
+ _testObjectsProperties(object, properties) {
67
+ for (let property of properties) {
68
+ if (property.type === 'class') {
69
+ if (
70
+ !object[property.type] ||
71
+ !object[property.type].split(' ').includes(property.value)
72
+ )
73
+ return false;
74
+
75
+ } else if (object[property.type] !== property.value)
76
+ return false;
77
+ }
78
+
79
+ return true;
80
+ };
81
+
82
+ /**
83
+ * parse selector to a array of parts
84
+ * @param {String} selector
85
+ * @returns {Array}
86
+ */
87
+ parse(selector) {
88
+ let selectorsParts = selector.split(' ');
89
+ let selectorsPartsParsed = [];
90
+
91
+ for (let selectorsPart of selectorsParts) {
92
+ let selectorPartParsed = this._parseSelectorPart(selectorsPart);
93
+
94
+ if (!selectorPartParsed)
95
+ Urso.logger.error('ModulesObjectsService error, cannot parse selector part: ' + selectorsPart);
96
+
97
+ selectorsPartsParsed.push(selectorPartParsed);
98
+ }
99
+
100
+ return selectorsPartsParsed;
101
+ };
102
+
103
+ /**
104
+ * parse selectors one object part
105
+ * @param {String} selectorPart
106
+ * @returns {mixed}
107
+ */
108
+ _parseSelectorPart(selectorPart) {
109
+ const characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+";
110
+ const matchExpr = {
111
+ "id": new RegExp("^#(" + characterEncoding + ")"),
112
+ "name": new RegExp("^\\^(" + characterEncoding + ")"),
113
+ "class": new RegExp("^\\.(" + characterEncoding + ")")
114
+ };
115
+
116
+ let result = [];
117
+
118
+ for (let type in matchExpr) {
119
+ let foundItem = matchExpr[type].exec(selectorPart);
120
+
121
+ if (foundItem) {
122
+ result.push({ type: type, value: foundItem[1] });
123
+
124
+ let restSelectorPart = Urso.helper.stringReplace(foundItem[0], '', selectorPart);
125
+ let restItems = this._parseSelectorPart(restSelectorPart);
126
+
127
+ if (restItems)
128
+ return Urso.helper.mergeArrays(result, restItems);
129
+ }
130
+ }
131
+
132
+ return (result && result.length > 0) ? result : false;
133
+ };
134
+ }
135
+
136
+ module.exports = ModulesObjectsSelector;
@@ -1,240 +1,240 @@
1
- class ModulesObjectsService {
2
- constructor() {
3
- this.singleton = true;
4
-
5
- this._world = null;
6
- this._counter = 0;
7
- this._objectsTypesFlipped;
8
- }
9
-
10
- _checkWorld() {
11
- if (this._world)
12
- return this._world;
13
-
14
- this.resetWorld();
15
-
16
- return this._world;
17
- }
18
-
19
- resetWorld() {
20
- const model = this.getInstance('Models.World', { name: 'WORLD' });
21
- const proxy = this.getInstance('Proxy').get(model);
22
-
23
- this._world = proxy;
24
-
25
- this.updateWorldBounds({ template: Urso.scenes.getTemplateSize() })
26
- this.getInstance('Cache').reset();
27
- this.applyClassesToWorld();
28
- this._addToCache(proxy);
29
- }
30
-
31
- updateWorldBounds(params) {
32
- if (!this._world)
33
- return;
34
-
35
- Urso.objects._safeSetValueToTarget(this._world, 'width', params.template.width);
36
- Urso.objects._safeSetValueToTarget(this._world, 'height', params.template.height);
37
- }
38
-
39
- applyClassesToWorld() {
40
- if (!this._world) {
41
- return; //world do not created yet
42
- }
43
-
44
- //remove old classes
45
- if (this._world.class) {
46
- this._world.class.split(' ').forEach((className) => this._world.removeClass(className, true));
47
- }
48
-
49
- //apply new classes
50
- Urso.getInstancesModes().forEach((className) => this._world.addClass(className, true));
51
-
52
- //refresh styles
53
- Urso.objects.refreshStyles();
54
- }
55
-
56
- _getUid() {
57
- this._counter++;
58
- return 'object_' + this._counter;
59
- }
60
-
61
- getWorld() {
62
- return this._world;
63
- }
64
-
65
- add(object, parent) {
66
- const world = this._checkWorld();
67
-
68
- if (!parent)
69
- parent = world;
70
-
71
- let model, contents;
72
-
73
- if (object.contents) {
74
- contents = object.contents;
75
- object.contents = []; //clear contents. We will put here just correct models
76
- }
77
-
78
- if (!this._objectsTypesFlipped)
79
- this._objectsTypesFlipped = Urso.helper.objectFlip(Urso.types.objects);
80
-
81
- //set uid
82
- object._uid = this._getUid();
83
-
84
- switch (object.type) {
85
- //exceptions with camelCase namings
86
- case Urso.types.objects.ATLASIMAGE:
87
- model = this.getInstance('Models.AtlasImage', object);
88
- break;
89
- case Urso.types.objects.BITMAPTEXT:
90
- model = this.getInstance('Models.BitmapText', object);
91
- break;
92
- case Urso.types.objects.HITAREA:
93
- model = this.getInstance('Models.HitArea', object);
94
- break;
95
- case Urso.types.objects.IMAGESANIMATION:
96
- model = this.getInstance('Models.ImagesAnimation', object);
97
- break;
98
- case Urso.types.objects.TEXTINPUT:
99
- model = this.getInstance('Models.TextInput', object);
100
- break;
101
- case Urso.types.objects.NINESLICEPLANE:
102
- model = this.getInstance('Models.NineSlicePlane', object);
103
- break;
104
- case Urso.types.objects.EMITTERFX:
105
- model = this.getInstance('Models.EmitterFx', object);
106
- break;
107
-
108
- default:
109
- const objectName = Urso.helper.capitaliseFirstLetter(
110
- this._objectsTypesFlipped[object.type].toLowerCase()
111
- );
112
-
113
- model = this.getInstance(`Models.${objectName}`, object);
114
- break;
115
- }
116
-
117
- if (!model)
118
- Urso.logger.error('ModulesObjectsCreate model type error', object.type, object);
119
-
120
- if (!model._baseObject)
121
- Urso.logger.error('ModulesObjectsCreate baseObject error', model);
122
-
123
- //proxing model
124
- let proxy = this.getInstance('Proxy').get(model);
125
-
126
- //link to component(if its compinent)
127
- if (object.type === Urso.types.objects.COMPONENT)
128
- object._controller.common.object = proxy;
129
-
130
- //add child baseObject
131
- this.addChild(parent, proxy, true);
132
-
133
- //set properties from originalModel
134
- this._updateCommonProperties(proxy);
135
-
136
- //check is mask
137
- if (model.type === Urso.types.objects.MASK)
138
- parent._baseObject.mask = model._baseObject;
139
-
140
- //contents
141
- if (contents) {
142
- for (const child of contents) {
143
- this.add(child, proxy);
144
- }
145
- }
146
-
147
- //cache
148
- this._addToCache(proxy);
149
-
150
- return proxy;
151
- }
152
-
153
- addChild(newParent, child, doNotRefreshStylesFlag) {
154
- if (child.parent) {
155
- this.removeChild(child.parent, child, true);
156
- }
157
-
158
- if (child._baseObject) { //regular our object
159
- newParent.contents.push(child);
160
- let childBase = child._baseObject;
161
- newParent._baseObject.addChild(childBase);
162
- child.parent = newParent;
163
-
164
- if (!doNotRefreshStylesFlag)
165
- Urso.objects.refreshStyles(); //todo optimization
166
- } else { //pixi system object
167
- newParent._baseObject.addChild(child);
168
- }
169
- }
170
-
171
- removeChild(parent, child, doNotRefreshStylesFlag) {
172
- child.parent = null;
173
- let childIndex = parent.contents.indexOf(child);
174
- parent.contents.splice(childIndex, 1);
175
- parent._baseObject.removeChild(child._baseObject);
176
-
177
- if (!doNotRefreshStylesFlag)
178
- Urso.objects.refreshStyles(); //todo optimization
179
- }
180
-
181
- destroy(object, doNotRefreshStylesFlag) {
182
- if (object.parent)
183
- this.removeChild(object.parent, object, true);
184
-
185
- //children
186
- if (object.contents)
187
- //for (const child of object.contents)
188
- while (object.contents.length > 0)
189
- this.destroy(object.contents[0], true);
190
-
191
- object._customDestroy();
192
- object._baseObject && object._baseObject.destroy();
193
- this._removeFromCache(object);
194
- this.getInstance('Styles').removeFromCache(object);
195
-
196
- //null all properties. example: _controller object
197
- if (object._controller) {
198
- if (object._controller.common.object) {
199
- object._controller.common.object = null;
200
- }
201
-
202
- object._controller = null;
203
- object.instance = null;
204
- }
205
-
206
- if (!doNotRefreshStylesFlag)
207
- Urso.objects.refreshStyles(); //todo optimization
208
-
209
- object.destroyed = true;
210
- }
211
-
212
- _updateCommonProperties(proxy) {
213
- for (let key in proxy._originalModel) {
214
- if (proxy._originalModel.hasOwnProperty(key)) {
215
- let value = proxy._originalModel[key];
216
- Urso.objects._safeSetValueToTarget(proxy, key, value);
217
- }
218
- }
219
- }
220
-
221
- _addToCache(proxy) {
222
- if (proxy.id)
223
- this.getInstance('Cache').addId(proxy.id, proxy);
224
- if (proxy.name)
225
- this.getInstance('Cache').addName(proxy.name, proxy);
226
- if (proxy.class)
227
- this.getInstance('Cache').addClass(proxy.class, proxy);
228
- }
229
-
230
- _removeFromCache(proxy) {
231
- if (proxy.id)
232
- this.getInstance('Cache').removeId(proxy.id, proxy);
233
- if (proxy.name)
234
- this.getInstance('Cache').removeName(proxy.name, proxy);
235
- if (proxy.class)
236
- this.getInstance('Cache').removeClass(proxy.class, proxy);
237
- }
238
- }
239
-
240
- module.exports = ModulesObjectsService;
1
+ class ModulesObjectsService {
2
+ constructor() {
3
+ this.singleton = true;
4
+
5
+ this._world = null;
6
+ this._counter = 0;
7
+ this._objectsTypesFlipped;
8
+ }
9
+
10
+ _checkWorld() {
11
+ if (this._world)
12
+ return this._world;
13
+
14
+ this.resetWorld();
15
+
16
+ return this._world;
17
+ }
18
+
19
+ resetWorld() {
20
+ const model = this.getInstance('Models.World', { name: 'WORLD' });
21
+ const proxy = this.getInstance('Proxy').get(model);
22
+
23
+ this._world = proxy;
24
+
25
+ this.updateWorldBounds({ template: Urso.scenes.getTemplateSize() })
26
+ this.getInstance('Cache').reset();
27
+ this.applyClassesToWorld();
28
+ this._addToCache(proxy);
29
+ }
30
+
31
+ updateWorldBounds(params) {
32
+ if (!this._world)
33
+ return;
34
+
35
+ Urso.objects._safeSetValueToTarget(this._world, 'width', params.template.width);
36
+ Urso.objects._safeSetValueToTarget(this._world, 'height', params.template.height);
37
+ }
38
+
39
+ applyClassesToWorld() {
40
+ if (!this._world) {
41
+ return; //world do not created yet
42
+ }
43
+
44
+ //remove old classes
45
+ if (this._world.class) {
46
+ this._world.class.split(' ').forEach((className) => this._world.removeClass(className, true));
47
+ }
48
+
49
+ //apply new classes
50
+ Urso.getInstancesModes().forEach((className) => this._world.addClass(className, true));
51
+
52
+ //refresh styles
53
+ Urso.objects.refreshStyles();
54
+ }
55
+
56
+ _getUid() {
57
+ this._counter++;
58
+ return 'object_' + this._counter;
59
+ }
60
+
61
+ getWorld() {
62
+ return this._world;
63
+ }
64
+
65
+ add(object, parent) {
66
+ const world = this._checkWorld();
67
+
68
+ if (!parent)
69
+ parent = world;
70
+
71
+ let model, contents;
72
+
73
+ if (object.contents) {
74
+ contents = object.contents;
75
+ object.contents = []; //clear contents. We will put here just correct models
76
+ }
77
+
78
+ if (!this._objectsTypesFlipped)
79
+ this._objectsTypesFlipped = Urso.helper.objectFlip(Urso.types.objects);
80
+
81
+ //set uid
82
+ object._uid = this._getUid();
83
+
84
+ switch (object.type) {
85
+ //exceptions with camelCase namings
86
+ case Urso.types.objects.ATLASIMAGE:
87
+ model = this.getInstance('Models.AtlasImage', object);
88
+ break;
89
+ case Urso.types.objects.BITMAPTEXT:
90
+ model = this.getInstance('Models.BitmapText', object);
91
+ break;
92
+ case Urso.types.objects.HITAREA:
93
+ model = this.getInstance('Models.HitArea', object);
94
+ break;
95
+ case Urso.types.objects.IMAGESANIMATION:
96
+ model = this.getInstance('Models.ImagesAnimation', object);
97
+ break;
98
+ case Urso.types.objects.TEXTINPUT:
99
+ model = this.getInstance('Models.TextInput', object);
100
+ break;
101
+ case Urso.types.objects.NINESLICEPLANE:
102
+ model = this.getInstance('Models.NineSlicePlane', object);
103
+ break;
104
+ case Urso.types.objects.EMITTERFX:
105
+ model = this.getInstance('Models.EmitterFx', object);
106
+ break;
107
+
108
+ default:
109
+ const objectName = Urso.helper.capitaliseFirstLetter(
110
+ this._objectsTypesFlipped[object.type].toLowerCase()
111
+ );
112
+
113
+ model = this.getInstance(`Models.${objectName}`, object);
114
+ break;
115
+ }
116
+
117
+ if (!model)
118
+ Urso.logger.error('ModulesObjectsCreate model type error', object.type, object);
119
+
120
+ if (!model._baseObject)
121
+ Urso.logger.error('ModulesObjectsCreate baseObject error', model);
122
+
123
+ //proxing model
124
+ let proxy = this.getInstance('Proxy').get(model);
125
+
126
+ //link to component(if its compinent)
127
+ if (object.type === Urso.types.objects.COMPONENT)
128
+ object._controller.common.object = proxy;
129
+
130
+ //add child baseObject
131
+ this.addChild(parent, proxy, true);
132
+
133
+ //set properties from originalModel
134
+ this._updateCommonProperties(proxy);
135
+
136
+ //check is mask
137
+ if (model.type === Urso.types.objects.MASK)
138
+ parent._baseObject.mask = model._baseObject;
139
+
140
+ //contents
141
+ if (contents) {
142
+ for (const child of contents) {
143
+ this.add(child, proxy);
144
+ }
145
+ }
146
+
147
+ //cache
148
+ this._addToCache(proxy);
149
+
150
+ return proxy;
151
+ }
152
+
153
+ addChild(newParent, child, doNotRefreshStylesFlag) {
154
+ if (child.parent) {
155
+ this.removeChild(child.parent, child, true);
156
+ }
157
+
158
+ if (child._baseObject) { //regular our object
159
+ newParent.contents.push(child);
160
+ let childBase = child._baseObject;
161
+ newParent._baseObject.addChild(childBase);
162
+ child.parent = newParent;
163
+
164
+ if (!doNotRefreshStylesFlag)
165
+ Urso.objects.refreshStyles(); //todo optimization
166
+ } else { //pixi system object
167
+ newParent._baseObject.addChild(child);
168
+ }
169
+ }
170
+
171
+ removeChild(parent, child, doNotRefreshStylesFlag) {
172
+ child.parent = null;
173
+ let childIndex = parent.contents.indexOf(child);
174
+ parent.contents.splice(childIndex, 1);
175
+ parent._baseObject.removeChild(child._baseObject);
176
+
177
+ if (!doNotRefreshStylesFlag)
178
+ Urso.objects.refreshStyles(); //todo optimization
179
+ }
180
+
181
+ destroy(object, doNotRefreshStylesFlag) {
182
+ if (object.parent)
183
+ this.removeChild(object.parent, object, true);
184
+
185
+ //children
186
+ if (object.contents)
187
+ //for (const child of object.contents)
188
+ while (object.contents.length > 0)
189
+ this.destroy(object.contents[0], true);
190
+
191
+ object._customDestroy();
192
+ object._baseObject && object._baseObject.destroy();
193
+ this._removeFromCache(object);
194
+ this.getInstance('Styles').removeFromCache(object);
195
+
196
+ //null all properties. example: _controller object
197
+ if (object._controller) {
198
+ if (object._controller.common.object) {
199
+ object._controller.common.object = null;
200
+ }
201
+
202
+ object._controller = null;
203
+ object.instance = null;
204
+ }
205
+
206
+ if (!doNotRefreshStylesFlag)
207
+ Urso.objects.refreshStyles(); //todo optimization
208
+
209
+ object.destroyed = true;
210
+ }
211
+
212
+ _updateCommonProperties(proxy) {
213
+ for (let key in proxy._originalModel) {
214
+ if (proxy._originalModel.hasOwnProperty(key)) {
215
+ let value = proxy._originalModel[key];
216
+ Urso.objects._safeSetValueToTarget(proxy, key, value);
217
+ }
218
+ }
219
+ }
220
+
221
+ _addToCache(proxy) {
222
+ if (proxy.id)
223
+ this.getInstance('Cache').addId(proxy.id, proxy);
224
+ if (proxy.name)
225
+ this.getInstance('Cache').addName(proxy.name, proxy);
226
+ if (proxy.class)
227
+ this.getInstance('Cache').addClass(proxy.class, proxy);
228
+ }
229
+
230
+ _removeFromCache(proxy) {
231
+ if (proxy.id)
232
+ this.getInstance('Cache').removeId(proxy.id, proxy);
233
+ if (proxy.name)
234
+ this.getInstance('Cache').removeName(proxy.name, proxy);
235
+ if (proxy.class)
236
+ this.getInstance('Cache').removeClass(proxy.class, proxy);
237
+ }
238
+ }
239
+
240
+ module.exports = ModulesObjectsService;