@urso/core 0.6.16-dev → 0.6.16

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 +227 -227
  4. package/build/js/index.js +1 -1
  5. package/build/js/index.js.LICENSE.txt +38 -270
  6. package/package.json +52 -52
  7. package/src/js/app.js +79 -79
  8. package/src/js/components/_info.js +11 -11
  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 +36 -36
  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 +65 -65
  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 +16 -16
  37. package/src/js/extra/_info.js +26 -26
  38. package/src/js/extra/browserEvents.js +51 -51
  39. package/src/js/extra/pixiPatch.js +150 -150
  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 +556 -556
  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 +203 -203
  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 +20 -20
  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 +15 -15
  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 +366 -366
  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 +357 -357
  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 +13 -13
  81. package/src/js/modules/objects/baseModel.js +200 -200
  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 -58
  85. package/src/js/modules/objects/models/_info.js +27 -27
  86. package/src/js/modules/objects/models/atlasImage.js +50 -50
  87. package/src/js/modules/objects/models/bitmapText.js +37 -37
  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 +46 -46
  93. package/src/js/modules/objects/models/container.js +19 -19
  94. package/src/js/modules/objects/models/dragContainer.js +667 -667
  95. package/src/js/modules/objects/models/emitter.js +67 -67
  96. package/src/js/modules/objects/models/emitterFx.js +99 -99
  97. package/src/js/modules/objects/models/graphics.js +38 -38
  98. package/src/js/modules/objects/models/group.js +19 -19
  99. package/src/js/modules/objects/models/hitArea.js +104 -104
  100. package/src/js/modules/objects/models/image.js +34 -34
  101. package/src/js/modules/objects/models/imagesAnimation.js +113 -113
  102. package/src/js/modules/objects/models/mask.js +38 -38
  103. package/src/js/modules/objects/models/nineSlicePlane.js +30 -30
  104. package/src/js/modules/objects/models/scrollbox.js +64 -64
  105. package/src/js/modules/objects/models/slider.js +253 -253
  106. package/src/js/modules/objects/models/spine.js +296 -287
  107. package/src/js/modules/objects/models/text.js +59 -59
  108. package/src/js/modules/objects/models/textInput.js +66 -66
  109. package/src/js/modules/objects/models/toggle.js +180 -180
  110. package/src/js/modules/objects/models/world.js +19 -19
  111. package/src/js/modules/objects/propertyAdapter.js +588 -587
  112. package/src/js/modules/objects/proxy.js +294 -294
  113. package/src/js/modules/objects/selector.js +136 -136
  114. package/src/js/modules/objects/service.js +242 -242
  115. package/src/js/modules/objects/styles.js +210 -210
  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 +52 -52
  119. package/src/js/modules/scenes/_info.js +8 -8
  120. package/src/js/modules/scenes/controller.js +119 -119
  121. package/src/js/modules/scenes/model.js +28 -28
  122. package/src/js/modules/scenes/pixiWrapper.js +336 -336
  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 +142 -142
  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 +251 -251
  129. package/src/js/modules/statesManager/_info.js +12 -12
  130. package/src/js/modules/statesManager/action.js +68 -68
  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 +46 -46
  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,294 +1,294 @@
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 (
122
- target.maxWidth &&
123
- (
124
- target.maxWidth < baseObjectWidth || //maxWidth is lower than object width
125
- (target.maxWidth > baseObjectWidth && target._baseObject.scale.x < 1) //maxWidth is higher than object width and object is downscaled
126
- )
127
- ) //check maxWidth
128
- calculationNeed = true;
129
-
130
- if (
131
- target.maxHeight &&
132
- (
133
- target.maxHeight < baseObjectHeight || //maxHeight is lower than object height
134
- (target.maxHeight > baseObjectHeight && target._baseObject.scale.y < 1) //maxHeight is higher than object height and object is downscaled
135
- )
136
- ) //check maxHeight
137
- calculationNeed = true;
138
-
139
- if (!calculationNeed)
140
- return;
141
-
142
- let scaleNeed = 1;
143
-
144
- if (target.maxWidth) {
145
- scaleNeed = Math.abs((target._baseObject.scale.x * target.maxWidth) / target._baseObject.width);
146
- }
147
-
148
- if (target.maxHeight) {
149
- const scaleYNeed = Math.abs((target._baseObject.scale.y * target.maxHeight) / target._baseObject.height);
150
-
151
- if (scaleNeed > scaleYNeed)
152
- scaleNeed = scaleYNeed;
153
- }
154
-
155
- if (scaleNeed > 1)
156
- scaleNeed = 1;
157
-
158
- target._baseObject.scale.x = scaleNeed * Math.sign(target._baseObject.scale.x);
159
- target._baseObject.scale.y = scaleNeed * Math.sign(target._baseObject.scale.y);
160
- }
161
-
162
- _runCustomFunction(property, target) {
163
- const funcName = property.replace('function.', '');
164
- if (target[funcName])
165
- target[funcName]();
166
- }
167
-
168
- _checkSelectorProperties(key) {
169
- if (!this._safeFlag && this._getSelectorProperties().includes(key)) {
170
- Urso.logger.error('ModulesObjectsProxy error: you are trying to change selector property: ' + key);
171
- Urso.logger.error('Notice: use functions addClass, removeClass, setId, setName');
172
- }
173
- }
174
-
175
- /**
176
- * transitions tweens creation
177
- * @param {Object} target - ObjectsModel
178
- * @param {String} propertyName
179
- * @param {Number} value
180
- * @param {Number} oldValue
181
- */
182
- _checkNeedTransitions(target, propertyName, value, oldValue) {
183
- if (
184
- typeof oldValue === 'undefined' ||
185
- !target.transitionProperty ||
186
- !target.transitionDuration ||
187
- !target.transitionProperty.split(' ').includes(propertyName)
188
- )
189
- return;
190
-
191
- const baseNewValue = target._baseObject[propertyName];
192
-
193
- //remove old active tween
194
- const currentTween = target._transitions.tweens[propertyName];
195
-
196
- if (currentTween)
197
- currentTween.kill();
198
-
199
- //set base value
200
- target._baseObject[propertyName] = oldValue;
201
-
202
- //create new tween
203
- const tweenParams = { duration: target.transitionDuration / 1000, ease: "none" };
204
- tweenParams[propertyName] = baseNewValue;
205
-
206
- if (target.transitionDelay)
207
- tweenParams.delay = target.transitionDelay / 1000;
208
-
209
- const newTween = gsap.to(target._baseObject, tweenParams);
210
- target._transitions.tweens[propertyName] = newTween;
211
-
212
- newTween.eventCallback("onComplete", () => {
213
- target._transitions.tweens[propertyName] = null;
214
- });
215
- }
216
-
217
- _getSelectorProperties() {
218
- return [
219
- 'id', 'name', 'class'
220
- ];
221
- }
222
-
223
- _getOriginalModelExceptions() {
224
- return [
225
- 'parent', 'contents'
226
- ];
227
- }
228
-
229
- _getAliases() {
230
- return {
231
- 'id': 'id',
232
- 'name': 'name',
233
- 'class': 'class',
234
- 'x': 'x',
235
- 'y': 'y',
236
- 'z': 'z',
237
- 'angle': 'angle',
238
- 'anchorX': 'anchor.x', //'anchor.x',
239
- 'anchorY': 'anchor.y', //'anchor.y',
240
- 'width': 'width', //'width',
241
- 'height': 'height', //'height',
242
- 'stretchingType': 'stretchingType',
243
- 'scaleX': 'scale.x', //'scale.x',
244
- 'scaleY': 'scale.y', //'scale.y',
245
- 'alignX': 'alignX', //'alignX',
246
- 'alignY': 'alignY', //'alignY',
247
- 'parent': 'parent',
248
- 'rightOffset': 'rightOffset',
249
- 'bottomOffset': 'bottomOffset',
250
- 'alpha': 'alpha',
251
- 'visible': 'visible',
252
- 'text': 'text',
253
- //'assetKey': 'function.setAssetKey', /todo
254
- 'frame': 'frame',
255
- 'blendMode': 'blendMode',
256
- 'tint': 'tint',
257
- 'action': 'events.onInputUp._bindings.0._listener', //todo
258
- 'btnFrames.over': 'frames.over',
259
- 'btnFrames.out': 'frames.out',
260
- 'btnFrames.down': 'frames.down',
261
- 'btnFrames.up': 'frames.up',
262
- 'align': 'align',
263
- 'filters': 'filters',
264
- 'lineSpacing': 'lineSpacing',
265
- 'maxWidth': 'maxWidth',
266
- 'maxHeight': 'maxHeight',
267
- 'lineHeight': 'style.lineHeight',
268
- 'fontFamily': 'style.fontFamily',
269
- 'fontSize': 'style.fontSize',
270
- 'fontStyle': 'style.fontStyle',
271
- 'fontWeight': 'style.fontWeight',
272
- 'fill': 'style.fill',
273
- 'fillCustomColors': 'fillCustomColors',
274
- 'stroke': 'style.stroke',
275
- 'strokeThickness': 'style.strokeThickness',
276
- 'dropShadow': 'style.dropShadow',
277
- 'dropShadowColor': 'style.dropShadowColor',
278
- 'dropShadowBlur': 'style.dropShadowBlur',
279
- 'dropShadowAngle': 'style.dropShadowAngle',
280
- 'dropShadowDistance': 'style.dropShadowDistance',
281
- 'wordWrap': 'style.wordWrap',
282
- 'wordWrapWidth': 'style.wordWrapWidth',
283
- 'leading ': 'style.leading',
284
- 'textAlign ': 'style.align',
285
- 'enabled': 'input.enabled',
286
- 'cacheAsBitmap': 'cacheAsBitmap',
287
- 'ignoreParentMask': 'ignoreParentMask',
288
- //baseObject functions
289
- 'toGlobal': 'toGlobal'
290
- };
291
- }
292
- }
293
-
294
- 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 (
122
+ target.maxWidth &&
123
+ (
124
+ target.maxWidth < baseObjectWidth || //maxWidth is lower than object width
125
+ (target.maxWidth > baseObjectWidth && target._baseObject.scale.x < 1) //maxWidth is higher than object width and object is downscaled
126
+ )
127
+ ) //check maxWidth
128
+ calculationNeed = true;
129
+
130
+ if (
131
+ target.maxHeight &&
132
+ (
133
+ target.maxHeight < baseObjectHeight || //maxHeight is lower than object height
134
+ (target.maxHeight > baseObjectHeight && target._baseObject.scale.y < 1) //maxHeight is higher than object height and object is downscaled
135
+ )
136
+ ) //check maxHeight
137
+ calculationNeed = true;
138
+
139
+ if (!calculationNeed)
140
+ return;
141
+
142
+ let scaleNeed = 1;
143
+
144
+ if (target.maxWidth) {
145
+ scaleNeed = Math.abs((target._baseObject.scale.x * target.maxWidth) / target._baseObject.width);
146
+ }
147
+
148
+ if (target.maxHeight) {
149
+ const scaleYNeed = Math.abs((target._baseObject.scale.y * target.maxHeight) / target._baseObject.height);
150
+
151
+ if (scaleNeed > scaleYNeed)
152
+ scaleNeed = scaleYNeed;
153
+ }
154
+
155
+ if (scaleNeed > 1)
156
+ scaleNeed = 1;
157
+
158
+ target._baseObject.scale.x = scaleNeed * Math.sign(target._baseObject.scale.x);
159
+ target._baseObject.scale.y = scaleNeed * Math.sign(target._baseObject.scale.y);
160
+ }
161
+
162
+ _runCustomFunction(property, target) {
163
+ const funcName = property.replace('function.', '');
164
+ if (target[funcName])
165
+ target[funcName]();
166
+ }
167
+
168
+ _checkSelectorProperties(key) {
169
+ if (!this._safeFlag && this._getSelectorProperties().includes(key)) {
170
+ Urso.logger.error('ModulesObjectsProxy error: you are trying to change selector property: ' + key);
171
+ Urso.logger.error('Notice: use functions addClass, removeClass, setId, setName');
172
+ }
173
+ }
174
+
175
+ /**
176
+ * transitions tweens creation
177
+ * @param {Object} target - ObjectsModel
178
+ * @param {String} propertyName
179
+ * @param {Number} value
180
+ * @param {Number} oldValue
181
+ */
182
+ _checkNeedTransitions(target, propertyName, value, oldValue) {
183
+ if (
184
+ typeof oldValue === 'undefined' ||
185
+ !target.transitionProperty ||
186
+ !target.transitionDuration ||
187
+ !target.transitionProperty.split(' ').includes(propertyName)
188
+ )
189
+ return;
190
+
191
+ const baseNewValue = target._baseObject[propertyName];
192
+
193
+ //remove old active tween
194
+ const currentTween = target._transitions.tweens[propertyName];
195
+
196
+ if (currentTween)
197
+ currentTween.kill();
198
+
199
+ //set base value
200
+ target._baseObject[propertyName] = oldValue;
201
+
202
+ //create new tween
203
+ const tweenParams = { duration: target.transitionDuration / 1000, ease: "none" };
204
+ tweenParams[propertyName] = baseNewValue;
205
+
206
+ if (target.transitionDelay)
207
+ tweenParams.delay = target.transitionDelay / 1000;
208
+
209
+ const newTween = gsap.to(target._baseObject, tweenParams);
210
+ target._transitions.tweens[propertyName] = newTween;
211
+
212
+ newTween.eventCallback("onComplete", () => {
213
+ target._transitions.tweens[propertyName] = null;
214
+ });
215
+ }
216
+
217
+ _getSelectorProperties() {
218
+ return [
219
+ 'id', 'name', 'class'
220
+ ];
221
+ }
222
+
223
+ _getOriginalModelExceptions() {
224
+ return [
225
+ 'parent', 'contents'
226
+ ];
227
+ }
228
+
229
+ _getAliases() {
230
+ return {
231
+ 'id': 'id',
232
+ 'name': 'name',
233
+ 'class': 'class',
234
+ 'x': 'x',
235
+ 'y': 'y',
236
+ 'z': 'z',
237
+ 'angle': 'angle',
238
+ 'anchorX': 'anchor.x', //'anchor.x',
239
+ 'anchorY': 'anchor.y', //'anchor.y',
240
+ 'width': 'width', //'width',
241
+ 'height': 'height', //'height',
242
+ 'stretchingType': 'stretchingType',
243
+ 'scaleX': 'scale.x', //'scale.x',
244
+ 'scaleY': 'scale.y', //'scale.y',
245
+ 'alignX': 'alignX', //'alignX',
246
+ 'alignY': 'alignY', //'alignY',
247
+ 'parent': 'parent',
248
+ 'rightOffset': 'rightOffset',
249
+ 'bottomOffset': 'bottomOffset',
250
+ 'alpha': 'alpha',
251
+ 'visible': 'visible',
252
+ 'text': 'text',
253
+ //'assetKey': 'function.setAssetKey', /todo
254
+ 'frame': 'frame',
255
+ 'blendMode': 'blendMode',
256
+ 'tint': 'tint',
257
+ 'action': 'events.onInputUp._bindings.0._listener', //todo
258
+ 'btnFrames.over': 'frames.over',
259
+ 'btnFrames.out': 'frames.out',
260
+ 'btnFrames.down': 'frames.down',
261
+ 'btnFrames.up': 'frames.up',
262
+ 'align': 'align',
263
+ 'filters': 'filters',
264
+ 'lineSpacing': 'lineSpacing',
265
+ 'maxWidth': 'maxWidth',
266
+ 'maxHeight': 'maxHeight',
267
+ 'lineHeight': 'style.lineHeight',
268
+ 'fontFamily': 'style.fontFamily',
269
+ 'fontSize': 'style.fontSize',
270
+ 'fontStyle': 'style.fontStyle',
271
+ 'fontWeight': 'style.fontWeight',
272
+ 'fill': 'style.fill',
273
+ 'fillCustomColors': 'fillCustomColors',
274
+ 'stroke': 'style.stroke',
275
+ 'strokeThickness': 'style.strokeThickness',
276
+ 'dropShadow': 'style.dropShadow',
277
+ 'dropShadowColor': 'style.dropShadowColor',
278
+ 'dropShadowBlur': 'style.dropShadowBlur',
279
+ 'dropShadowAngle': 'style.dropShadowAngle',
280
+ 'dropShadowDistance': 'style.dropShadowDistance',
281
+ 'wordWrap': 'style.wordWrap',
282
+ 'wordWrapWidth': 'style.wordWrapWidth',
283
+ 'leading ': 'style.leading',
284
+ 'textAlign ': 'style.align',
285
+ 'enabled': 'input.enabled',
286
+ 'cacheAsBitmap': 'cacheAsBitmap',
287
+ 'ignoreParentMask': 'ignoreParentMask',
288
+ //baseObject functions
289
+ 'toGlobal': 'toGlobal'
290
+ };
291
+ }
292
+ }
293
+
294
+ module.exports = ModulesObjectsProxy;