@applicaster/zapp-react-native-utils 12.0.0-rc.14 → 12.0.0-rc.141

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 (133) hide show
  1. package/actionsExecutor/ActionExecutorContext.tsx +16 -8
  2. package/analyticsUtils/AnalyticPlayerListener.ts +141 -0
  3. package/analyticsUtils/AnalyticsEvents/index.ts +13 -0
  4. package/analyticsUtils/AnalyticsEvents/searchEvents.ts +21 -0
  5. package/analyticsUtils/AnalyticsEvents/sendShareEvent.ts +21 -0
  6. package/analyticsUtils/PlayerAnalyticsManager.ts +90 -0
  7. package/analyticsUtils/__tests__/analyticsManager.test.js +75 -73
  8. package/analyticsUtils/analyticsPlugins.ts +25 -0
  9. package/analyticsUtils/events.ts +12 -0
  10. package/analyticsUtils/helpers/hooks.ts +1 -1
  11. package/analyticsUtils/index.tsx +12 -0
  12. package/analyticsUtils/{analyticsTracker.ts → playerAnalyticsTracker.ts} +19 -10
  13. package/appUtils/HooksManager/index.js +3 -1
  14. package/appUtils/accessibilityManager/const.ts +50 -0
  15. package/appUtils/accessibilityManager/hooks.ts +40 -0
  16. package/appUtils/accessibilityManager/index.ts +155 -0
  17. package/appUtils/accessibilityManager/logger.ts +5 -0
  18. package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +2 -3
  19. package/appUtils/focusManager/__tests__/focusManager.test.js +4 -24
  20. package/appUtils/focusManager/__tests__/index.test.ts +2 -3
  21. package/appUtils/focusManager/index.ts +76 -57
  22. package/appUtils/focusManager/treeDataStructure/Utils/index.js +75 -35
  23. package/appUtils/focusManager/utils/index.ts +100 -0
  24. package/appUtils/focusManagerAux/index.ts +76 -0
  25. package/appUtils/focusManagerAux/utils/index.ts +100 -0
  26. package/appUtils/index.js +2 -0
  27. package/appUtils/keyCodes/__tests__/__snapshots__/keyCodes.test.js.snap +1 -1
  28. package/appUtils/keyCodes/__tests__/keyCodes.test.js +80 -85
  29. package/appUtils/keyCodes/keys.web.js +9 -0
  30. package/appUtils/keyCodes/keysByPlatform.js +11 -1
  31. package/appUtils/platform/const.ts +25 -0
  32. package/appUtils/platform/index.ts +3 -0
  33. package/appUtils/platform/platformUtils.ts +218 -0
  34. package/appUtils/playerManager/OverlayObserver/OverlaysObserver.ts +53 -0
  35. package/appUtils/playerManager/conts.ts +6 -0
  36. package/appUtils/playerManager/index.ts +20 -32
  37. package/appUtils/playerManager/nativePlayerManager.ts +12 -0
  38. package/appUtils/playerManager/player.ts +56 -7
  39. package/appUtils/playerManager/playerFactory.ts +20 -5
  40. package/appUtils/playerManager/playerHooks/usePlayerCurrentTime.tsx +57 -0
  41. package/appUtils/playerManager/playerNative.ts +41 -15
  42. package/appUtils/playerManager/usePlayerControllerSetup.tsx +8 -2
  43. package/appUtils/playerManager/usePlayerState.tsx +20 -23
  44. package/appUtils/playerManager/usePlayerTitleSummaryOverlay.tsx +50 -0
  45. package/arrayUtils/__tests__/isFilledArray.test.ts +63 -0
  46. package/arrayUtils/index.ts +16 -0
  47. package/booleanUtils/index.ts +4 -4
  48. package/cellUtils/__tests__/cellUtils.test.ts +48 -0
  49. package/cellUtils/__tests__/fixtures.ts +13 -0
  50. package/cellUtils/index.ts +78 -7
  51. package/dateUtils/index.ts +11 -0
  52. package/focusManager/FocusManager.ts +20 -5
  53. package/focusManager/__tests__/FocusManager.test.ts +0 -1
  54. package/focusManager/index.ts +1 -1
  55. package/functionUtils/__tests__/__snapshots__/functionUtils.test.js.snap +2 -2
  56. package/functionUtils/__tests__/functionUtils.test.js +244 -248
  57. package/functionUtils/index.ts +38 -0
  58. package/headersUtils/index.ts +1 -0
  59. package/index.d.ts +15 -0
  60. package/inflatedUrlUtils/index.ts +4 -4
  61. package/keyboardState/index.ts +0 -0
  62. package/localizationUtils/__tests__/localizationUtils.test.ts +78 -55
  63. package/localizationUtils/index.ts +13 -19
  64. package/logger/index.ts +1 -1
  65. package/manifestUtils/defaultManifestConfigurations/generalContent.js +6 -0
  66. package/manifestUtils/defaultManifestConfigurations/player.js +131 -1
  67. package/manifestUtils/index.js +5 -1
  68. package/manifestUtils/keys.js +2 -1
  69. package/manifestUtils/secondaryImage/index.js +18 -15
  70. package/modalState/index.ts +57 -0
  71. package/navigationUtils/index.ts +105 -8
  72. package/numberUtils/__tests__/isLikeNumber.test.ts +18 -0
  73. package/numberUtils/__tests__/toNumber.test.ts +2 -2
  74. package/numberUtils/__tests__/toPositiveNumberWithDefault.test.ts +66 -0
  75. package/numberUtils/__tests__/toPositiveNumberWithDefaultZero.test.ts +66 -0
  76. package/numberUtils/index.ts +27 -16
  77. package/package.json +3 -2
  78. package/playerUtils/configurationGenerator.ts +131 -1
  79. package/playerUtils/imaScriptDom.ts +59 -0
  80. package/pluginUtils/index.ts +20 -7
  81. package/reactHooks/autoscrolling/__tests__/useTrackCurrentAutoScrollingElement.test.ts +2 -0
  82. package/reactHooks/autoscrolling/__tests__/{useTrackedView.test.ts → useTrackedView.test.tsx} +18 -1
  83. package/reactHooks/cell-click/__tests__/index.test.js +16 -3
  84. package/reactHooks/cell-click/index.ts +30 -16
  85. package/reactHooks/debugging/__tests__/index.test.js +81 -11
  86. package/reactHooks/feed/__tests__/useBatchLoading.test.tsx +69 -6
  87. package/reactHooks/feed/__tests__/useBuildPipesUrl.test.tsx +30 -70
  88. package/reactHooks/feed/__tests__/useFeedRefresh.test.tsx +6 -2
  89. package/reactHooks/feed/__tests__/useInflatedUrl.test.ts +18 -3
  90. package/reactHooks/feed/useBatchLoading.ts +52 -28
  91. package/reactHooks/feed/useBuildPipesUrl.ts +7 -10
  92. package/reactHooks/feed/useFeedRefresh.tsx +9 -7
  93. package/reactHooks/feed/useInflatedUrl.ts +44 -15
  94. package/reactHooks/flatList/useLoadNextPageIfNeeded.ts +16 -9
  95. package/reactHooks/index.ts +2 -0
  96. package/reactHooks/layout/__tests__/{index.test.js → index.test.tsx} +66 -59
  97. package/reactHooks/layout/getDeviceInfo/index.ts +4 -2
  98. package/reactHooks/layout/types/index.ts +2 -0
  99. package/reactHooks/layout/useDimensions/__tests__/useDimensions.test.ts +134 -0
  100. package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.native.test.js +11 -16
  101. package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.test.js +12 -14
  102. package/reactHooks/layout/useDimensions/useDimensions.ts +15 -7
  103. package/reactHooks/navigation/__mocks__/index.ts +15 -0
  104. package/reactHooks/navigation/__mocks__/useNavigation.ts +7 -0
  105. package/reactHooks/navigation/__tests__/index.test.tsx +240 -81
  106. package/reactHooks/navigation/index.ts +240 -81
  107. package/reactHooks/player/useAutoSeek.tsx +9 -7
  108. package/reactHooks/resolvers/__tests__/useCellResolver.test.tsx +3 -1
  109. package/reactHooks/resolvers/useCellResolver.ts +5 -1
  110. package/reactHooks/screen/__mocks__/useScreenContext.ts +3 -1
  111. package/reactHooks/screen/__tests__/useCurrentScreenData.test.tsx +21 -23
  112. package/reactHooks/screen/index.ts +4 -0
  113. package/reactHooks/screen/useScreenBackgroundColor.ts +23 -0
  114. package/reactHooks/screen/useScreenContext.ts +4 -4
  115. package/reactHooks/screen/useScreenData.ts +1 -1
  116. package/reactHooks/screen/useTargetScreenData.ts +7 -0
  117. package/reactHooks/state/useRivers.ts +3 -1
  118. package/reactHooks/useConfiguration.ts +2 -2
  119. package/reactHooks/useListenEventBusEvent.ts +1 -4
  120. package/reactHooks/videoModal/hooks/useVideoModalScreenData.tsx +10 -9
  121. package/reactUtils/index.ts +104 -0
  122. package/riverComponetsMeasurementProvider/index.tsx +2 -2
  123. package/services/localStorageServiceSync.web.ts +48 -0
  124. package/services/sessionStorageServiceSync.web.ts +32 -0
  125. package/services/storageServiceSync.web.ts +24 -0
  126. package/services/storageWebUtils.web.ts +10 -0
  127. package/stringUtils/index.ts +5 -0
  128. package/testUtils/getByTestId.ts +14 -0
  129. package/testUtils/index.tsx +71 -23
  130. package/types.ts +4 -0
  131. package/appUtils/focusManager/FocusableEvents.ts +0 -8
  132. package/appUtils/focusManager/treeDataStructure/Utils/__tests__/Utils_android.test.js +0 -1094
  133. package/appUtils/focusManager/treeDataStructure/Utils/index.android.js +0 -261
@@ -1,261 +0,0 @@
1
- import * as R from "ramda";
2
- import { rejectItemByPath } from "../../../../objectUtils";
3
- import {
4
- measureDistance,
5
- measureEuclidianDistanceToCenter,
6
- } from "@applicaster/zapp-react-native-utils/rectUtils";
7
-
8
- import { mapAsync } from "../../../../functionUtils";
9
-
10
- export const FocusDirection = {
11
- LEFT: 1,
12
- TOP: 2,
13
- RIGHT: 4,
14
- BOTTOM: 8,
15
- };
16
-
17
- /**
18
- * Function search down the tree for priority item in given children array.
19
- * Priorities are:
20
- * Priority 1: Currently selected item - like a menu item
21
- * Priority 2: Previously focused item in the parent group
22
- * Priority 3: Preferrable items - items which have been marked as preferable
23
- * Priority 4: First item on the list - if by any accident above priories are not satisfied
24
- * @private
25
- * @param {Array} children
26
- * @returns focusable priority item.
27
- */
28
- export function findPriorityItem(children) {
29
- let preferedGroups = getPriorityItems(children);
30
-
31
- if (preferedGroups.length > 0 && !preferedGroups[0].children) {
32
- return preferedGroups;
33
- }
34
-
35
- preferedGroups = preferedGroups.filter(
36
- (it) =>
37
- it.children &&
38
- it.children.length > 0 &&
39
- it.children.filter((obj) => obj && obj.component.props.preferredFocus)
40
- .length > 0
41
- );
42
-
43
- while (
44
- preferedGroups.length > 0 &&
45
- preferedGroups[0].children &&
46
- preferedGroups[0].children.length > 0
47
- ) {
48
- preferedGroups = getPriorityItems(preferedGroups[0].children);
49
- }
50
-
51
- return preferedGroups;
52
- }
53
-
54
- /**
55
- * Function search for currently selected item - like a menu item.
56
- * @private
57
- * @param {Array} children
58
- * @returns array of selected items
59
- */
60
- export function getSelectedItems(children) {
61
- const selectedItems = children.filter(
62
- (obj) => obj && obj.component.props.selected
63
- );
64
-
65
- return selectedItems;
66
- }
67
-
68
- /**
69
- * Function search for previously focused item in the parent group.
70
- * @private
71
- * @param {Array} children
72
- * @returns array of last focus items
73
- */
74
- export function getLastFocusedItems(children) {
75
- const lastFocusedItems = children.filter(
76
- (obj) => obj && obj.id === obj.parent.lastFocusedItem
77
- );
78
-
79
- return lastFocusedItems;
80
- }
81
-
82
- /**
83
- * Function search for items which have been marked as preferable.
84
- * @private
85
- * @param {Array} children
86
- * @returns array of prefereable focus items
87
- */
88
- export function getPreferableItems(children) {
89
- const preferredItems = children.filter(
90
- (obj) => obj && obj.component.props.preferredFocus
91
- );
92
-
93
- return preferredItems;
94
- }
95
-
96
- /**
97
- * Function search for priority items in children array. Priorities are:
98
- * Priority 1: Currently selected item - like a menu item
99
- * Priority 2: Previously focused item in the parent group
100
- * Priority 3: Preferrable items - items which have been marked as preferable
101
- * Priority 4: First item on the list - if by any accident above priories are not satisfied
102
- * @private
103
- * @param {Array} children
104
- * @returns array of pririty focus items
105
- */
106
- export function getPriorityItems(children) {
107
- const selectedItems = getSelectedItems(children);
108
- const lastFocusedItems = getLastFocusedItems(children);
109
- const preferredItems = getPreferableItems(children);
110
-
111
- if (selectedItems.length > 0) {
112
- return selectedItems;
113
- } else if (lastFocusedItems.length > 0) {
114
- return lastFocusedItems;
115
- } else if (preferredItems.length > 0) {
116
- return preferredItems;
117
- } else if (children.length > 0) {
118
- return [children[0]];
119
- }
120
-
121
- return [];
122
- }
123
-
124
- /**
125
- * Get target in shortest distance in specified direction
126
- * @private
127
- * @param {Object} direction of the navigation, which led to this focus change
128
- * @param {Object} excludedNode node which should be excluded from target group
129
- * @param {Array} targetNodes array of input target nodes
130
- * @param {Object} comparisonRect rectangle to compare sides in direction.
131
- * @returns {Object} target in direction.
132
- */
133
- export async function getTargetInDirection(
134
- direction,
135
- excludedNode,
136
- targetNodes,
137
- comparisonRect
138
- ) {
139
- const targets = rejectItemByPath(["id"], excludedNode.id, targetNodes);
140
-
141
- const targetsWithDistances = await mapAsync(async (target) => {
142
- const targetRect = await target.component.getRect();
143
-
144
- return {
145
- distance: measureDistance(direction, comparisonRect, targetRect),
146
- euclidianDistance: measureEuclidianDistanceToCenter(
147
- comparisonRect,
148
- targetRect
149
- ),
150
- target,
151
- targetRect,
152
- };
153
- }, targets);
154
-
155
- const distances = targetsWithDistances.filter((obj) => obj.distance >= 0);
156
-
157
- if (!distances || distances.length === 0) {
158
- return null;
159
- }
160
-
161
- const match = R.compose(
162
- R.head,
163
- R.sortBy((it) => it.euclidianDistance),
164
- R.head,
165
- R.values,
166
- R.groupBy((it) => it.distance)
167
- )(distances);
168
-
169
- return match ? match.target : null;
170
- }
171
-
172
- /**
173
- * Find focusable node in direction from currentFocusedNode.
174
- * If it does not find a node in current group it seach parent node
175
- * incuding deep search inside simbilngs of parent. Search goes up the tree
176
- * until find next focusable item or tree ends.
177
- * @public
178
- * @param {Object} direction of the navigation, which led to this focus change
179
- * @param {Object} currentFocusNode currently focused node as start point of search
180
- * @returns {Object} focusable node in direction.
181
- */
182
- export async function findFocusableNode(direction, currentFocusNode) {
183
- const currentFocusable = currentFocusNode.component || null;
184
-
185
- if (currentFocusable) {
186
- const currentFocusableRect = await currentFocusable.getRect();
187
-
188
- let focusableNode = await getTargetInDirection(
189
- direction,
190
- currentFocusNode,
191
- currentFocusNode.parent.children,
192
- currentFocusableRect
193
- );
194
-
195
- const parentHasPriority =
196
- currentFocusNode.parent.component &&
197
- hasPriorityInDirection(direction, currentFocusNode.parent.component);
198
-
199
- const canFindParentSibling = await findFocusableNode(
200
- direction,
201
- currentFocusNode.parent
202
- );
203
-
204
- if (parentHasPriority && canFindParentSibling) {
205
- return canFindParentSibling;
206
- } else if (focusableNode && focusableNode.component) {
207
- // inside group
208
- return focusableNode;
209
- } else {
210
- // outside group
211
- let parentFocusableNode = currentFocusNode;
212
-
213
- // going up the structure untill sibling node
214
- while (
215
- !focusableNode &&
216
- parentFocusableNode &&
217
- parentFocusableNode.parent &&
218
- parentFocusableNode.parent.parent
219
- ) {
220
- parentFocusableNode = parentFocusableNode.parent;
221
-
222
- focusableNode = await getTargetInDirection(
223
- direction,
224
- parentFocusableNode, // excluded sibling parent of current focuable
225
- parentFocusableNode.parent.children, // siblings of parent
226
- currentFocusableRect
227
- );
228
- }
229
-
230
- if (focusableNode) {
231
- const preferred = findPriorityItem(focusableNode.children);
232
-
233
- return preferred[0];
234
- }
235
- }
236
- }
237
- }
238
-
239
- /**
240
- * Checks of component has priority in the direction. It is used to navigate
241
- * outside of the group if group has priotity in specified direction.
242
- * @public
243
- * @param {Object} direction of the navigation, which led to this focus change
244
- * @param {Object} component - object to check props.prioritiseFocusOn
245
- * @returns {Boolean} TRUE if object has priority in direction.
246
- * @returns {Boolean} FALSE if object has NO priority in direction.
247
- */
248
- export function hasPriorityInDirection(direction, component) {
249
- const { prioritiseFocusOn = 0 } = component.props;
250
-
251
- const directionMapper = {
252
- left: 1,
253
- up: 2,
254
- right: 4,
255
- down: 8,
256
- };
257
-
258
- const mappedDirection = directionMapper[direction.value];
259
-
260
- return (prioritiseFocusOn & mappedDirection) > 0;
261
- }