@urso/core 0.4.45 → 0.4.49

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 (156) 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 +32 -32
  6. package/package.json +51 -51
  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/editor/_info.js +4 -0
  20. package/src/js/components/editor/api.js +72 -0
  21. package/src/js/components/editor/controller.js +13 -0
  22. package/src/js/components/fullscreen/_info.js +6 -6
  23. package/src/js/components/fullscreen/android.js +104 -104
  24. package/src/js/components/fullscreen/controller.js +76 -76
  25. package/src/js/components/fullscreen/desktop.js +49 -49
  26. package/src/js/components/fullscreen/ios.js +115 -115
  27. package/src/js/components/layersSwitcher/_info.js +4 -4
  28. package/src/js/components/layersSwitcher/config.js +26 -26
  29. package/src/js/components/layersSwitcher/controller.js +34 -34
  30. package/src/js/components/loader/_info.js +4 -4
  31. package/src/js/components/loader/controller.js +66 -66
  32. package/src/js/components/loader/template.js +70 -70
  33. package/src/js/components/soundInitialPopup/_info.js +3 -3
  34. package/src/js/components/soundInitialPopup/controller.js +42 -42
  35. package/src/js/components/soundInitialPopup/template.js +109 -109
  36. package/src/js/components/stateDriven/_info.js +3 -3
  37. package/src/js/components/stateDriven/controller.js +118 -118
  38. package/src/js/config/load.js +5 -5
  39. package/src/js/config/main.js +11 -10
  40. package/src/js/extra/_info.js +24 -24
  41. package/src/js/extra/browserEvents.js +38 -38
  42. package/src/js/extra/pixiPatch.js +79 -79
  43. package/src/js/extra/setTimeout.js +7 -7
  44. package/src/js/index.js +8 -8
  45. package/src/js/lib/_info.js +13 -13
  46. package/src/js/lib/cache.js +105 -105
  47. package/src/js/lib/composition.js +85 -85
  48. package/src/js/lib/device.js +1286 -1286
  49. package/src/js/lib/helper.js +539 -539
  50. package/src/js/lib/loader.js +136 -131
  51. package/src/js/lib/localData.js +15 -15
  52. package/src/js/lib/logger.js +22 -22
  53. package/src/js/lib/math.js +35 -35
  54. package/src/js/lib/objectPool.js +54 -54
  55. package/src/js/lib/time.js +18 -18
  56. package/src/js/lib/tween.js +147 -147
  57. package/src/js/modules/_info.js +12 -12
  58. package/src/js/modules/assets/_info.js +7 -7
  59. package/src/js/modules/assets/baseModel.js +18 -18
  60. package/src/js/modules/assets/config.js +37 -37
  61. package/src/js/modules/assets/controller.js +46 -46
  62. package/src/js/modules/assets/models/_info.js +11 -11
  63. package/src/js/modules/assets/models/atlas.js +8 -8
  64. package/src/js/modules/assets/models/audiosprite.js +27 -27
  65. package/src/js/modules/assets/models/bitmapFont.js +8 -8
  66. package/src/js/modules/assets/models/container.js +16 -16
  67. package/src/js/modules/assets/models/font.js +8 -8
  68. package/src/js/modules/assets/models/image.js +13 -13
  69. package/src/js/modules/assets/models/json.js +8 -8
  70. package/src/js/modules/assets/models/sound.js +14 -14
  71. package/src/js/modules/assets/models/spine.js +14 -14
  72. package/src/js/modules/assets/service.js +365 -365
  73. package/src/js/modules/i18n/_info.js +4 -4
  74. package/src/js/modules/i18n/config.js +17 -17
  75. package/src/js/modules/i18n/controller.js +79 -79
  76. package/src/js/modules/instances/_info.js +3 -3
  77. package/src/js/modules/instances/controller.js +261 -261
  78. package/src/js/modules/logic/_info.js +4 -4
  79. package/src/js/modules/logic/config/_info.js +2 -2
  80. package/src/js/modules/logic/config/sounds.js +23 -23
  81. package/src/js/modules/logic/controller.js +48 -48
  82. package/src/js/modules/logic/sounds.js +103 -103
  83. package/src/js/modules/objects/_info.js +11 -11
  84. package/src/js/modules/objects/baseModel.js +197 -197
  85. package/src/js/modules/objects/cache.js +99 -99
  86. package/src/js/modules/objects/controller.js +131 -131
  87. package/src/js/modules/objects/create.js +237 -237
  88. package/src/js/modules/objects/find.js +140 -140
  89. package/src/js/modules/objects/models/_info.js +25 -25
  90. package/src/js/modules/objects/models/atlasImage.js +50 -50
  91. package/src/js/modules/objects/models/bitmapText.js +39 -39
  92. package/src/js/modules/objects/models/button.js +189 -189
  93. package/src/js/modules/objects/models/buttonComposite.js +35 -35
  94. package/src/js/modules/objects/models/checkbox.js +96 -96
  95. package/src/js/modules/objects/models/collection.js +54 -54
  96. package/src/js/modules/objects/models/component.js +44 -44
  97. package/src/js/modules/objects/models/container.js +19 -19
  98. package/src/js/modules/objects/models/emitter.js +67 -54
  99. package/src/js/modules/objects/models/graphics.js +38 -38
  100. package/src/js/modules/objects/models/group.js +19 -19
  101. package/src/js/modules/objects/models/hitArea.js +104 -104
  102. package/src/js/modules/objects/models/image.js +34 -34
  103. package/src/js/modules/objects/models/imagesAnimation.js +113 -113
  104. package/src/js/modules/objects/models/mask.js +38 -38
  105. package/src/js/modules/objects/models/nineSlicePlane.js +30 -30
  106. package/src/js/modules/objects/models/scrollbox.js +61 -61
  107. package/src/js/modules/objects/models/slider.js +253 -253
  108. package/src/js/modules/objects/models/spine.js +271 -271
  109. package/src/js/modules/objects/models/text.js +59 -59
  110. package/src/js/modules/objects/models/textInput.js +66 -66
  111. package/src/js/modules/objects/models/toggle.js +180 -180
  112. package/src/js/modules/objects/models/world.js +19 -19
  113. package/src/js/modules/objects/propertyAdapter.js +422 -422
  114. package/src/js/modules/objects/proxy.js +282 -282
  115. package/src/js/modules/objects/styles.js +120 -120
  116. package/src/js/modules/observer/_info.js +4 -4
  117. package/src/js/modules/observer/controller.js +99 -99
  118. package/src/js/modules/observer/events.js +44 -44
  119. package/src/js/modules/scenes/_info.js +8 -8
  120. package/src/js/modules/scenes/controller.js +103 -103
  121. package/src/js/modules/scenes/model.js +28 -28
  122. package/src/js/modules/scenes/pixiWrapper.js +237 -237
  123. package/src/js/modules/scenes/resolutions.js +173 -173
  124. package/src/js/modules/scenes/resolutionsConfig.js +73 -73
  125. package/src/js/modules/scenes/service.js +139 -139
  126. package/src/js/modules/soundManager/_info.js +3 -3
  127. package/src/js/modules/soundManager/controller.js +100 -100
  128. package/src/js/modules/soundManager/soundSprite.js +243 -243
  129. package/src/js/modules/statesManager/_info.js +12 -12
  130. package/src/js/modules/statesManager/action.js +60 -60
  131. package/src/js/modules/statesManager/actions/_info.js +3 -3
  132. package/src/js/modules/statesManager/all.js +23 -23
  133. package/src/js/modules/statesManager/configStates.js +71 -71
  134. package/src/js/modules/statesManager/controller.js +170 -170
  135. package/src/js/modules/statesManager/functionsStorage.js +82 -82
  136. package/src/js/modules/statesManager/helper.js +27 -27
  137. package/src/js/modules/statesManager/race.js +75 -75
  138. package/src/js/modules/statesManager/sequence.js +47 -47
  139. package/src/js/modules/template/_info.js +6 -6
  140. package/src/js/modules/template/controller.js +28 -28
  141. package/src/js/modules/template/model.js +11 -11
  142. package/src/js/modules/template/service.js +137 -137
  143. package/src/js/modules/template/types.js +45 -45
  144. package/src/js/modules/transport/_info.js +8 -8
  145. package/src/js/modules/transport/baseConnectionType.js +24 -24
  146. package/src/js/modules/transport/config.js +13 -13
  147. package/src/js/modules/transport/connectionTypes/_info.js +3 -3
  148. package/src/js/modules/transport/connectionTypes/websocket.js +74 -74
  149. package/src/js/modules/transport/connectionTypes/xhr.js +44 -44
  150. package/src/js/modules/transport/controller.js +48 -48
  151. package/src/js/modules/transport/decorator.js +17 -17
  152. package/src/js/modules/transport/service.js +153 -153
  153. package/src/js/templates/_info.js +4 -4
  154. package/src/js/templates/groups/_info.js +1 -1
  155. package/src/js/templates/scenes/_info.js +1 -1
  156. package/webpack.config.js +47 -47
@@ -1,282 +1,282 @@
1
- class ModulesObjectsProxy {
2
- constructor() {
3
- this.singleton = true;
4
- this._safeFlag = false;
5
-
6
- this._customSetLogic = this._customSetLogic.bind(this);
7
- this._customGetLogic = this._customGetLogic.bind(this);
8
-
9
- this._propertyAdapter = this.getInstance('PropertyAdapter');
10
- };
11
-
12
- get(model) {
13
- const _this = this;
14
-
15
- let proxy = new Proxy(model, {
16
- get(target, key, receiver) {
17
- const rv = Reflect.get(target, key, receiver);
18
- return _this._customGetLogic({ target: target, proxy: receiver }, key, rv);
19
- },
20
-
21
- set(target, key, value, receiver) {
22
- const oldValue = target._baseObject[key];
23
- const rv = Reflect.set(target, key, value, receiver);
24
- _this._customSetLogic(target, key, value, proxy, oldValue);
25
- return rv;
26
- }
27
- });
28
-
29
- return proxy;
30
- }
31
-
32
- /* targetObject - object from models
33
- * propertyName - property to adapt for PIXI object
34
- * value - value to set
35
- */
36
- _setProperty(target, propertyName, value, oldValue) {
37
- const isAdaptiveProperty = this._propertyAdapter.isAdaptiveProperty(propertyName);
38
-
39
- if (isAdaptiveProperty)
40
- this._propertyAdapter.propertyChangeHandler(target, propertyName);
41
- else
42
- Urso.helper.recursiveSet(propertyName, value, target._baseObject);
43
-
44
- this._checkNeedTransitions(target, propertyName, value, oldValue);
45
- }
46
-
47
- safeSetValueToTarget(target, key, value) {
48
- this._safeFlag = true;
49
-
50
- const originalValue = target._originalModel[key]; // we need to save original value in the end
51
-
52
- //setting value
53
- target[key] = value;
54
-
55
- target._originalModel[key] = originalValue;
56
-
57
- this._safeFlag = false;
58
- }
59
-
60
- //returns reflectValue = value that would be used when target[key] is called
61
- _customGetLogic(object, key, reflectValue) {
62
- const target = object.target;
63
- const wrapKey = this._getAliases()[key];
64
- const isReflectValueObject = typeof reflectValue !== 'undefined'; //&& typeof reflectValue !== 'boolean'; //it was for getting width and height
65
-
66
- if ((isReflectValueObject && (typeof wrapKey != 'undefined')) || !wrapKey)
67
- return reflectValue;
68
-
69
- return Urso.helper.recursiveGet(wrapKey, target._baseObject, reflectValue);
70
- }
71
-
72
- _customSetLogic(target, key, value, proxy, oldValue) {
73
- if (!this._getOriginalModelExceptions().includes(key))
74
- target._originalModel[key] = value;
75
-
76
- //apply to pixi
77
- const propertyName = this._getAliases()[key];
78
-
79
- if (!propertyName)
80
- return false;
81
-
82
- if (propertyName.startsWith('function.')) {
83
- this._runCustomFunction(propertyName, target);
84
- return true;
85
- }
86
-
87
- this._checkSelectorProperties(key);
88
-
89
- this._setProperty(target, propertyName, value, oldValue);
90
-
91
- //if property is text - we will update it
92
- if (propertyName === 'text') {
93
- target._baseObject.updateText(true);
94
- }
95
-
96
- this._checkMaxSize(target);
97
-
98
- //setup dirty to recalc params
99
- if (typeof target._baseObject.dirty !== 'undefined')
100
- target._baseObject.dirty = true;
101
-
102
- return true;
103
- };
104
-
105
- _checkMaxSize(target) {
106
- if (!target.maxWidth && !target.maxHeight)
107
- return;
108
-
109
- let calculationNeed = false;
110
-
111
- const baseObject = target._baseObject;
112
-
113
- //Pixi texts have _texture.orig.width. When we call baseObject.width, Pixi runs update text. Its too slow operation.
114
- if (baseObject._texture && (!baseObject._texture.orig.width || !baseObject._texture.orig.height)) {
115
- baseObject.updateText(true);
116
- }
117
-
118
- const baseObjectWidth = baseObject._texture ? Math.abs(baseObject.scale.x) * baseObject._texture.orig.width : baseObject.width;
119
- const baseObjectHeight = baseObject._texture ? Math.abs(baseObject.scale.y) * baseObject._texture.orig.height : baseObject.height;
120
-
121
- if (target.maxWidth && target.maxWidth < baseObjectWidth) //check maxWidth
122
- calculationNeed = true;
123
-
124
- if (target.maxHeight && target.maxHeight < baseObjectHeight) //check maxHeight
125
- calculationNeed = true;
126
-
127
- if (!calculationNeed)
128
- return;
129
-
130
- let scaleNeed = 1;
131
-
132
- if (target.maxWidth) {
133
- scaleNeed = Math.abs((target._baseObject.scale.x * target.maxWidth) / target._baseObject.width);
134
- }
135
-
136
- if (target.maxHeight) {
137
- const scaleYNeed = Math.abs((target._baseObject.scale.y * target.maxHeight) / target._baseObject.height);
138
-
139
- if (scaleNeed > scaleYNeed)
140
- scaleNeed = scaleYNeed;
141
- }
142
-
143
- if (scaleNeed > 1)
144
- scaleNeed = 1;
145
-
146
- target._baseObject.scale.x = scaleNeed * Math.sign(target._baseObject.scale.x);
147
- target._baseObject.scale.y = scaleNeed * Math.sign(target._baseObject.scale.y);
148
- }
149
-
150
- _runCustomFunction(property, target) {
151
- const funcName = property.replace('function.', '');
152
- if (target[funcName])
153
- target[funcName]();
154
- }
155
-
156
- _checkSelectorProperties(key) {
157
- if (!this._safeFlag && this._getSelectorProperties().includes(key)) {
158
- Urso.logger.error('ModulesObjectsProxy error: you are trying to change selector propertie: ' + key);
159
- Urso.logger.error('Notice: use functions addClass, removeClass, setId, setName');
160
- }
161
- }
162
-
163
- /**
164
- * transitions tweens creation
165
- * @param {Object} target - ObjectsModel
166
- * @param {String} propertyName
167
- * @param {Number} value
168
- * @param {Number} oldValue
169
- */
170
- _checkNeedTransitions(target, propertyName, value, oldValue) {
171
- if (
172
- typeof oldValue === 'undefined' ||
173
- !target.transitionProperty ||
174
- !target.transitionDuration ||
175
- !target.transitionProperty.split(' ').includes(propertyName)
176
- )
177
- return;
178
-
179
- const baseNewValue = target._baseObject[propertyName];
180
-
181
- //remove old active tween
182
- const currentTween = target._transitions.tweens[propertyName];
183
-
184
- if (currentTween)
185
- currentTween.kill();
186
-
187
- //set base value
188
- target._baseObject[propertyName] = oldValue;
189
-
190
- //create new tween
191
- const tweenParams = { duration: target.transitionDuration / 1000, ease: "none" };
192
- tweenParams[propertyName] = baseNewValue;
193
-
194
- if (target.transitionDelay)
195
- tweenParams.delay = target.transitionDelay / 1000;
196
-
197
- const newTween = gsap.to(target._baseObject, tweenParams);
198
- target._transitions.tweens[propertyName] = newTween;
199
-
200
- newTween.eventCallback("onComplete", () => {
201
- target._transitions.tweens[propertyName] = null;
202
- });
203
- }
204
-
205
- _getSelectorProperties() {
206
- return [
207
- 'id', 'name', 'class'
208
- ];
209
- }
210
-
211
- _getOriginalModelExceptions() {
212
- return [
213
- 'parent', 'contents'
214
- ];
215
- }
216
-
217
- _getAliases() {
218
- return {
219
- 'id': 'id',
220
- 'name': 'name',
221
- 'class': 'class',
222
- 'x': 'x',
223
- 'y': 'y',
224
- 'z': 'z',
225
- 'angle': 'angle',
226
- 'anchorX': 'anchor.x', //'anchor.x',
227
- 'anchorY': 'anchor.y', //'anchor.y',
228
- 'width': 'width', //'width',
229
- 'height': 'height', //'height',
230
- 'stretchingType': 'stretchingType',
231
- 'scaleX': 'scale.x', //'scale.x',
232
- 'scaleY': 'scale.y', //'scale.y',
233
- 'alignX': 'alignX', //'alignX',
234
- 'alignY': 'alignY', //'alignY',
235
- 'parent': 'parent',
236
- 'rightOffset': 'rightOffset',
237
- 'bottomOffset': 'bottomOffset',
238
- 'alpha': 'alpha',
239
- 'visible': 'visible',
240
- 'text': 'text',
241
- //'assetKey': 'function.setAssetKey', /todo
242
- 'frame': 'frame',
243
- 'blendMode': 'blendMode',
244
- 'tint': 'tint',
245
- 'action': 'events.onInputUp._bindings.0._listener', //todo
246
- 'btnFrames.over': 'frames.over',
247
- 'btnFrames.out': 'frames.out',
248
- 'btnFrames.down': 'frames.down',
249
- 'btnFrames.up': 'frames.up',
250
- 'align': 'align',
251
- 'filters': 'filters',
252
- 'lineSpacing': 'lineSpacing',
253
- 'maxWidth': 'maxWidth',
254
- 'maxHeight': 'maxHeight',
255
- 'lineHeight': 'style.lineHeight',
256
- 'fontFamily': 'style.fontFamily',
257
- 'fontSize': 'style.fontSize',
258
- 'fontStyle': 'style.fontStyle',
259
- 'fontWeight': 'style.fontWeight',
260
- 'fill': 'style.fill',
261
- 'fillCustomColors': 'fillCustomColors',
262
- 'stroke': 'style.stroke',
263
- 'strokeThickness': 'style.strokeThickness',
264
- 'dropShadow': 'style.dropShadow',
265
- 'dropShadowColor': 'style.dropShadowColor',
266
- 'dropShadowBlur': 'style.dropShadowBlur',
267
- 'dropShadowAngle': 'style.dropShadowAngle',
268
- 'dropShadowDistance': 'style.dropShadowDistance',
269
- 'wordWrap': 'style.wordWrap',
270
- 'wordWrapWidth': 'style.wordWrapWidth',
271
- 'leading ': 'style.leading',
272
- 'textAlign ': 'style.align',
273
- 'enabled': 'input.enabled',
274
- 'cacheAsBitmap': 'cacheAsBitmap',
275
-
276
- //baseObject functions
277
- 'toGlobal': 'toGlobal'
278
- };
279
- }
280
- }
281
-
282
- module.exports = ModulesObjectsProxy;
1
+ class ModulesObjectsProxy {
2
+ constructor() {
3
+ this.singleton = true;
4
+ this._safeFlag = false;
5
+
6
+ this._customSetLogic = this._customSetLogic.bind(this);
7
+ this._customGetLogic = this._customGetLogic.bind(this);
8
+
9
+ this._propertyAdapter = this.getInstance('PropertyAdapter');
10
+ };
11
+
12
+ get(model) {
13
+ const _this = this;
14
+
15
+ let proxy = new Proxy(model, {
16
+ get(target, key, receiver) {
17
+ const rv = Reflect.get(target, key, receiver);
18
+ return _this._customGetLogic({ target: target, proxy: receiver }, key, rv);
19
+ },
20
+
21
+ set(target, key, value, receiver) {
22
+ const oldValue = target._baseObject[key];
23
+ const rv = Reflect.set(target, key, value, receiver);
24
+ _this._customSetLogic(target, key, value, proxy, oldValue);
25
+ return rv;
26
+ }
27
+ });
28
+
29
+ return proxy;
30
+ }
31
+
32
+ /* targetObject - object from models
33
+ * propertyName - property to adapt for PIXI object
34
+ * value - value to set
35
+ */
36
+ _setProperty(target, propertyName, value, oldValue) {
37
+ const isAdaptiveProperty = this._propertyAdapter.isAdaptiveProperty(propertyName);
38
+
39
+ if (isAdaptiveProperty)
40
+ this._propertyAdapter.propertyChangeHandler(target, propertyName);
41
+ else
42
+ Urso.helper.recursiveSet(propertyName, value, target._baseObject);
43
+
44
+ this._checkNeedTransitions(target, propertyName, value, oldValue);
45
+ }
46
+
47
+ safeSetValueToTarget(target, key, value) {
48
+ this._safeFlag = true;
49
+
50
+ const originalValue = target._originalModel[key]; // we need to save original value in the end
51
+
52
+ //setting value
53
+ target[key] = value;
54
+
55
+ target._originalModel[key] = originalValue;
56
+
57
+ this._safeFlag = false;
58
+ }
59
+
60
+ //returns reflectValue = value that would be used when target[key] is called
61
+ _customGetLogic(object, key, reflectValue) {
62
+ const target = object.target;
63
+ const wrapKey = this._getAliases()[key];
64
+ const isReflectValueObject = typeof reflectValue !== 'undefined'; //&& typeof reflectValue !== 'boolean'; //it was for getting width and height
65
+
66
+ if ((isReflectValueObject && (typeof wrapKey != 'undefined')) || !wrapKey)
67
+ return reflectValue;
68
+
69
+ return Urso.helper.recursiveGet(wrapKey, target._baseObject, reflectValue);
70
+ }
71
+
72
+ _customSetLogic(target, key, value, proxy, oldValue) {
73
+ if (!this._getOriginalModelExceptions().includes(key))
74
+ target._originalModel[key] = value;
75
+
76
+ //apply to pixi
77
+ const propertyName = this._getAliases()[key];
78
+
79
+ if (!propertyName)
80
+ return false;
81
+
82
+ if (propertyName.startsWith('function.')) {
83
+ this._runCustomFunction(propertyName, target);
84
+ return true;
85
+ }
86
+
87
+ this._checkSelectorProperties(key);
88
+
89
+ this._setProperty(target, propertyName, value, oldValue);
90
+
91
+ //if property is text - we will update it
92
+ if (propertyName === 'text') {
93
+ target._baseObject.updateText(true);
94
+ }
95
+
96
+ this._checkMaxSize(target);
97
+
98
+ //setup dirty to recalc params
99
+ if (typeof target._baseObject.dirty !== 'undefined')
100
+ target._baseObject.dirty = true;
101
+
102
+ return true;
103
+ };
104
+
105
+ _checkMaxSize(target) {
106
+ if (!target.maxWidth && !target.maxHeight)
107
+ return;
108
+
109
+ let calculationNeed = false;
110
+
111
+ const baseObject = target._baseObject;
112
+
113
+ //Pixi texts have _texture.orig.width. When we call baseObject.width, Pixi runs update text. Its too slow operation.
114
+ if (baseObject._texture && (!baseObject._texture.orig.width || !baseObject._texture.orig.height)) {
115
+ baseObject.updateText(true);
116
+ }
117
+
118
+ const baseObjectWidth = baseObject._texture ? Math.abs(baseObject.scale.x) * baseObject._texture.orig.width : baseObject.width;
119
+ const baseObjectHeight = baseObject._texture ? Math.abs(baseObject.scale.y) * baseObject._texture.orig.height : baseObject.height;
120
+
121
+ if (target.maxWidth && target.maxWidth < baseObjectWidth) //check maxWidth
122
+ calculationNeed = true;
123
+
124
+ if (target.maxHeight && target.maxHeight < baseObjectHeight) //check maxHeight
125
+ calculationNeed = true;
126
+
127
+ if (!calculationNeed)
128
+ return;
129
+
130
+ let scaleNeed = 1;
131
+
132
+ if (target.maxWidth) {
133
+ scaleNeed = Math.abs((target._baseObject.scale.x * target.maxWidth) / target._baseObject.width);
134
+ }
135
+
136
+ if (target.maxHeight) {
137
+ const scaleYNeed = Math.abs((target._baseObject.scale.y * target.maxHeight) / target._baseObject.height);
138
+
139
+ if (scaleNeed > scaleYNeed)
140
+ scaleNeed = scaleYNeed;
141
+ }
142
+
143
+ if (scaleNeed > 1)
144
+ scaleNeed = 1;
145
+
146
+ target._baseObject.scale.x = scaleNeed * Math.sign(target._baseObject.scale.x);
147
+ target._baseObject.scale.y = scaleNeed * Math.sign(target._baseObject.scale.y);
148
+ }
149
+
150
+ _runCustomFunction(property, target) {
151
+ const funcName = property.replace('function.', '');
152
+ if (target[funcName])
153
+ target[funcName]();
154
+ }
155
+
156
+ _checkSelectorProperties(key) {
157
+ if (!this._safeFlag && this._getSelectorProperties().includes(key)) {
158
+ Urso.logger.error('ModulesObjectsProxy error: you are trying to change selector propertie: ' + key);
159
+ Urso.logger.error('Notice: use functions addClass, removeClass, setId, setName');
160
+ }
161
+ }
162
+
163
+ /**
164
+ * transitions tweens creation
165
+ * @param {Object} target - ObjectsModel
166
+ * @param {String} propertyName
167
+ * @param {Number} value
168
+ * @param {Number} oldValue
169
+ */
170
+ _checkNeedTransitions(target, propertyName, value, oldValue) {
171
+ if (
172
+ typeof oldValue === 'undefined' ||
173
+ !target.transitionProperty ||
174
+ !target.transitionDuration ||
175
+ !target.transitionProperty.split(' ').includes(propertyName)
176
+ )
177
+ return;
178
+
179
+ const baseNewValue = target._baseObject[propertyName];
180
+
181
+ //remove old active tween
182
+ const currentTween = target._transitions.tweens[propertyName];
183
+
184
+ if (currentTween)
185
+ currentTween.kill();
186
+
187
+ //set base value
188
+ target._baseObject[propertyName] = oldValue;
189
+
190
+ //create new tween
191
+ const tweenParams = { duration: target.transitionDuration / 1000, ease: "none" };
192
+ tweenParams[propertyName] = baseNewValue;
193
+
194
+ if (target.transitionDelay)
195
+ tweenParams.delay = target.transitionDelay / 1000;
196
+
197
+ const newTween = gsap.to(target._baseObject, tweenParams);
198
+ target._transitions.tweens[propertyName] = newTween;
199
+
200
+ newTween.eventCallback("onComplete", () => {
201
+ target._transitions.tweens[propertyName] = null;
202
+ });
203
+ }
204
+
205
+ _getSelectorProperties() {
206
+ return [
207
+ 'id', 'name', 'class'
208
+ ];
209
+ }
210
+
211
+ _getOriginalModelExceptions() {
212
+ return [
213
+ 'parent', 'contents'
214
+ ];
215
+ }
216
+
217
+ _getAliases() {
218
+ return {
219
+ 'id': 'id',
220
+ 'name': 'name',
221
+ 'class': 'class',
222
+ 'x': 'x',
223
+ 'y': 'y',
224
+ 'z': 'z',
225
+ 'angle': 'angle',
226
+ 'anchorX': 'anchor.x', //'anchor.x',
227
+ 'anchorY': 'anchor.y', //'anchor.y',
228
+ 'width': 'width', //'width',
229
+ 'height': 'height', //'height',
230
+ 'stretchingType': 'stretchingType',
231
+ 'scaleX': 'scale.x', //'scale.x',
232
+ 'scaleY': 'scale.y', //'scale.y',
233
+ 'alignX': 'alignX', //'alignX',
234
+ 'alignY': 'alignY', //'alignY',
235
+ 'parent': 'parent',
236
+ 'rightOffset': 'rightOffset',
237
+ 'bottomOffset': 'bottomOffset',
238
+ 'alpha': 'alpha',
239
+ 'visible': 'visible',
240
+ 'text': 'text',
241
+ //'assetKey': 'function.setAssetKey', /todo
242
+ 'frame': 'frame',
243
+ 'blendMode': 'blendMode',
244
+ 'tint': 'tint',
245
+ 'action': 'events.onInputUp._bindings.0._listener', //todo
246
+ 'btnFrames.over': 'frames.over',
247
+ 'btnFrames.out': 'frames.out',
248
+ 'btnFrames.down': 'frames.down',
249
+ 'btnFrames.up': 'frames.up',
250
+ 'align': 'align',
251
+ 'filters': 'filters',
252
+ 'lineSpacing': 'lineSpacing',
253
+ 'maxWidth': 'maxWidth',
254
+ 'maxHeight': 'maxHeight',
255
+ 'lineHeight': 'style.lineHeight',
256
+ 'fontFamily': 'style.fontFamily',
257
+ 'fontSize': 'style.fontSize',
258
+ 'fontStyle': 'style.fontStyle',
259
+ 'fontWeight': 'style.fontWeight',
260
+ 'fill': 'style.fill',
261
+ 'fillCustomColors': 'fillCustomColors',
262
+ 'stroke': 'style.stroke',
263
+ 'strokeThickness': 'style.strokeThickness',
264
+ 'dropShadow': 'style.dropShadow',
265
+ 'dropShadowColor': 'style.dropShadowColor',
266
+ 'dropShadowBlur': 'style.dropShadowBlur',
267
+ 'dropShadowAngle': 'style.dropShadowAngle',
268
+ 'dropShadowDistance': 'style.dropShadowDistance',
269
+ 'wordWrap': 'style.wordWrap',
270
+ 'wordWrapWidth': 'style.wordWrapWidth',
271
+ 'leading ': 'style.leading',
272
+ 'textAlign ': 'style.align',
273
+ 'enabled': 'input.enabled',
274
+ 'cacheAsBitmap': 'cacheAsBitmap',
275
+
276
+ //baseObject functions
277
+ 'toGlobal': 'toGlobal'
278
+ };
279
+ }
280
+ }
281
+
282
+ module.exports = ModulesObjectsProxy;