@applicaster/zapp-react-native-utils 12.0.0-rc.12 → 12.0.0-rc.121
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/actionsExecutor/ActionExecutorContext.tsx +16 -8
- package/analyticsUtils/AnalyticPlayerListener.ts +141 -0
- package/analyticsUtils/AnalyticsEvents/index.ts +13 -0
- package/analyticsUtils/AnalyticsEvents/searchEvents.ts +21 -0
- package/analyticsUtils/AnalyticsEvents/sendShareEvent.ts +21 -0
- package/analyticsUtils/PlayerAnalyticsManager.ts +90 -0
- package/analyticsUtils/__tests__/analyticsManager.test.js +75 -73
- package/analyticsUtils/analyticsPlugins.ts +25 -0
- package/analyticsUtils/events.ts +12 -0
- package/analyticsUtils/helpers/hooks.ts +1 -1
- package/analyticsUtils/index.tsx +12 -0
- package/analyticsUtils/{analyticsTracker.ts → playerAnalyticsTracker.ts} +19 -10
- package/appUtils/HooksManager/index.js +3 -1
- package/appUtils/accessibilityManager/const.ts +50 -0
- package/appUtils/accessibilityManager/hooks.ts +40 -0
- package/appUtils/accessibilityManager/index.ts +166 -0
- package/appUtils/accessibilityManager/logger.ts +5 -0
- package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +2 -3
- package/appUtils/focusManager/__tests__/focusManager.test.js +4 -24
- package/appUtils/focusManager/__tests__/index.test.ts +2 -3
- package/appUtils/focusManager/index.ts +76 -57
- package/appUtils/focusManager/treeDataStructure/Utils/index.js +75 -35
- package/appUtils/focusManager/utils/index.ts +100 -0
- package/appUtils/focusManagerAux/index.ts +76 -0
- package/appUtils/focusManagerAux/utils/index.ts +100 -0
- package/appUtils/index.js +2 -0
- package/appUtils/keyCodes/__tests__/__snapshots__/keyCodes.test.js.snap +1 -1
- package/appUtils/keyCodes/__tests__/keyCodes.test.js +80 -85
- package/appUtils/keyCodes/keys.web.js +9 -0
- package/appUtils/keyCodes/keysByPlatform.js +11 -1
- package/appUtils/platform/const.ts +25 -0
- package/appUtils/platform/index.ts +3 -0
- package/appUtils/platform/platformUtils.ts +217 -0
- package/appUtils/playerManager/OverlayObserver/OverlaysObserver.ts +53 -0
- package/appUtils/playerManager/conts.ts +6 -0
- package/appUtils/playerManager/index.ts +20 -32
- package/appUtils/playerManager/nativePlayerManager.ts +12 -0
- package/appUtils/playerManager/player.ts +56 -7
- package/appUtils/playerManager/playerFactory.ts +15 -1
- package/appUtils/playerManager/playerHooks/usePlayerCurrentTime.tsx +57 -0
- package/appUtils/playerManager/playerNative.ts +41 -15
- package/appUtils/playerManager/usePlayerControllerSetup.tsx +8 -2
- package/appUtils/playerManager/usePlayerState.tsx +20 -23
- package/appUtils/playerManager/usePlayerTitleSummaryOverlay.tsx +50 -0
- package/arrayUtils/__tests__/isFilledArray.test.ts +63 -0
- package/arrayUtils/index.ts +5 -0
- package/booleanUtils/index.ts +4 -4
- package/cellUtils/__tests__/cellUtils.test.ts +48 -0
- package/cellUtils/__tests__/fixtures.ts +13 -0
- package/cellUtils/index.ts +78 -7
- package/dateUtils/index.ts +11 -0
- package/focusManager/index.ts +1 -1
- package/functionUtils/__tests__/__snapshots__/functionUtils.test.js.snap +2 -2
- package/functionUtils/__tests__/functionUtils.test.js +244 -248
- package/functionUtils/index.ts +38 -0
- package/headersUtils/index.ts +1 -0
- package/index.d.ts +15 -0
- package/inflatedUrlUtils/index.ts +4 -4
- package/keyboardState/index.ts +0 -0
- package/localizationUtils/__tests__/localizationUtils.test.ts +78 -55
- package/localizationUtils/index.ts +13 -19
- package/logger/index.ts +1 -1
- package/manifestUtils/defaultManifestConfigurations/generalContent.js +6 -0
- package/manifestUtils/defaultManifestConfigurations/player.js +10 -1
- package/manifestUtils/index.js +5 -1
- package/manifestUtils/secondaryImage/index.js +18 -15
- package/modalState/index.ts +57 -0
- package/navigationUtils/index.ts +104 -7
- package/numberUtils/__tests__/isLikeNumber.test.ts +18 -0
- package/numberUtils/__tests__/toNumber.test.ts +2 -2
- package/numberUtils/index.ts +9 -18
- package/package.json +3 -2
- package/playerUtils/configurationGenerator.ts +11 -1
- package/playerUtils/imaScriptDom.ts +59 -0
- package/pluginUtils/index.ts +20 -7
- package/reactHooks/autoscrolling/__tests__/useTrackCurrentAutoScrollingElement.test.ts +2 -0
- package/reactHooks/autoscrolling/__tests__/{useTrackedView.test.ts → useTrackedView.test.tsx} +18 -1
- package/reactHooks/cell-click/__tests__/index.test.js +16 -3
- package/reactHooks/cell-click/index.ts +14 -14
- package/reactHooks/debugging/__tests__/index.test.js +81 -11
- package/reactHooks/feed/__tests__/useBuildPipesUrl.test.tsx +30 -70
- package/reactHooks/feed/__tests__/useFeedRefresh.test.tsx +6 -2
- package/reactHooks/feed/__tests__/useInflatedUrl.test.ts +18 -3
- package/reactHooks/feed/useBuildPipesUrl.ts +7 -10
- package/reactHooks/feed/useFeedRefresh.tsx +9 -7
- package/reactHooks/feed/useInflatedUrl.ts +44 -15
- package/reactHooks/flatList/useLoadNextPageIfNeeded.ts +16 -9
- package/reactHooks/index.ts +2 -0
- package/reactHooks/layout/__tests__/{index.test.js → index.test.tsx} +66 -59
- package/reactHooks/layout/getDeviceInfo/index.ts +4 -2
- package/reactHooks/layout/types/index.ts +2 -0
- package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.native.test.js +11 -16
- package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.test.js +12 -14
- package/reactHooks/layout/useDimensions/useDimensions.ts +15 -7
- package/reactHooks/navigation/__mocks__/index.ts +15 -0
- package/reactHooks/navigation/__mocks__/useNavigation.ts +7 -0
- package/reactHooks/navigation/__tests__/index.test.tsx +240 -81
- package/reactHooks/navigation/index.ts +239 -80
- package/reactHooks/resolvers/__tests__/useCellResolver.test.tsx +3 -1
- package/reactHooks/resolvers/useCellResolver.ts +5 -1
- package/reactHooks/screen/__mocks__/useScreenContext.ts +3 -1
- package/reactHooks/screen/__tests__/useCurrentScreenData.test.tsx +21 -23
- package/reactHooks/screen/index.ts +4 -0
- package/reactHooks/screen/useScreenBackgroundColor.ts +23 -0
- package/reactHooks/screen/useScreenContext.ts +4 -4
- package/reactHooks/screen/useScreenData.ts +1 -1
- package/reactHooks/screen/useTargetScreenData.ts +7 -0
- package/reactHooks/state/useRivers.ts +3 -1
- package/reactHooks/useListenEventBusEvent.ts +1 -4
- package/reactHooks/videoModal/hooks/useVideoModalScreenData.tsx +10 -9
- package/reactUtils/index.ts +104 -0
- package/riverComponetsMeasurementProvider/index.tsx +2 -2
- package/stringUtils/index.ts +5 -0
- package/testUtils/getByTestId.ts +14 -0
- package/testUtils/index.tsx +38 -23
- package/types.ts +4 -0
- package/appUtils/focusManager/FocusableEvents.ts +0 -8
- package/appUtils/focusManager/treeDataStructure/Utils/__tests__/Utils_android.test.js +0 -1094
- 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
|
-
}
|