@applicaster/zapp-react-native-utils 15.0.0-alpha.3752284136 → 15.0.0-alpha.3842304615
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/README.md +0 -6
- package/actionUtils/index.ts +7 -0
- package/actionsExecutor/ActionExecutorContext.tsx +83 -6
- package/adsUtils/__tests__/createVMAP.test.ts +419 -0
- package/analyticsUtils/analyticsMapper.ts +10 -2
- package/appDataUtils/__tests__/urlScheme.test.ts +678 -0
- package/appUtils/HooksManager/__tests__/__snapshots__/hooksManager.test.js.snap +0 -188
- package/appUtils/HooksManager/__tests__/hooksManager.test.js +16 -2
- package/appUtils/HooksManager/index.ts +35 -0
- package/appUtils/contextKeysManager/__tests__/getKeys/failure.test.ts +7 -2
- package/appUtils/contextKeysManager/__tests__/getKeys/success.test.ts +48 -0
- package/appUtils/contextKeysManager/contextResolver.ts +51 -22
- package/appUtils/contextKeysManager/index.ts +65 -10
- package/appUtils/focusManager/treeDataStructure/Tree/__tests__/Tree.test.js +46 -0
- package/appUtils/focusManager/treeDataStructure/Tree/index.js +18 -18
- package/appUtils/focusManagerAux/utils/index.ts +12 -6
- package/appUtils/focusManagerAux/utils/utils.ios.ts +6 -3
- package/appUtils/localizationsHelper.ts +4 -0
- package/appUtils/playerManager/index.ts +9 -0
- package/appUtils/playerManager/player.ts +1 -1
- package/appUtils/playerManager/playerNative.ts +2 -1
- package/appUtils/playerManager/usePlayer.tsx +5 -3
- package/cellUtils/__tests__/cellUtils.test.ts +39 -0
- package/cellUtils/index.ts +11 -1
- package/cloudEventsUtils/__tests__/index.test.ts +529 -0
- package/cloudEventsUtils/index.ts +65 -1
- package/componentsUtils/index.ts +8 -0
- package/configurationUtils/__tests__/imageSrcFromMediaItem.test.ts +38 -0
- package/configurationUtils/index.ts +17 -11
- package/dateUtils/__tests__/dayjs.test.ts +327 -0
- package/dateUtils/index.ts +2 -0
- package/enumUtils/__tests__/getEnumKeyByEnumValue.test.ts +207 -0
- package/errorUtils/__tests__/GeneralError.test.ts +97 -0
- package/errorUtils/__tests__/HttpStatusCode.test.ts +344 -0
- package/errorUtils/__tests__/MissingPluginError.test.ts +113 -0
- package/errorUtils/__tests__/NetworkError.test.ts +202 -0
- package/errorUtils/__tests__/getParsedResponse.test.ts +188 -0
- package/errorUtils/__tests__/invariant.test.ts +112 -0
- package/headersUtils/__tests__/headersUtils.test.js +11 -1
- package/headersUtils/index.ts +2 -1
- package/manifestUtils/_internals/__tests__/index.test.js +41 -0
- package/manifestUtils/_internals/index.js +33 -0
- package/manifestUtils/defaultManifestConfigurations/player.js +35 -16
- package/manifestUtils/fieldUtils/__tests__/fieldUtils.test.js +49 -0
- package/manifestUtils/fieldUtils/index.js +54 -0
- package/manifestUtils/index.js +2 -0
- package/manifestUtils/keys.js +228 -0
- package/manifestUtils/mobileAction/button/__tests__/mobileActionButton.test.js +168 -0
- package/manifestUtils/mobileAction/button/index.js +140 -0
- package/manifestUtils/mobileAction/container/__tests__/mobileActionButtonsContainer.test.js +102 -0
- package/manifestUtils/mobileAction/container/index.js +73 -0
- package/manifestUtils/mobileAction/groups/__tests__/buildMobileActionButtonGroups.test.js +127 -0
- package/manifestUtils/mobileAction/groups/defaults.js +76 -0
- package/manifestUtils/mobileAction/groups/index.js +80 -0
- package/manifestUtils/platformIsTV.js +13 -0
- package/navigationUtils/index.ts +15 -5
- package/numberUtils/__tests__/toNumber.test.ts +27 -0
- package/numberUtils/__tests__/toPositiveNumber.test.ts +193 -0
- package/numberUtils/index.ts +23 -1
- package/package.json +3 -3
- package/pluginUtils/index.ts +4 -5
- package/reactHooks/analytics/__tests__/useSendAnalyticsOnPress.test.ts +537 -0
- package/reactHooks/app/__tests__/useAppState.test.ts +1 -1
- package/reactHooks/autoscrolling/__tests__/useTrackCurrentAutoScrollingElement.test.ts +1 -1
- package/reactHooks/autoscrolling/__tests__/useTrackedView.test.tsx +1 -2
- package/reactHooks/casting/index.ts +1 -0
- package/reactHooks/casting/useIsCasting.tsx +57 -0
- package/reactHooks/cell-click/__tests__/index.test.js +1 -3
- package/reactHooks/cell-click/index.ts +2 -1
- package/reactHooks/configuration/__tests__/index.test.tsx +1 -1
- package/reactHooks/connection/__tests__/index.test.js +1 -1
- package/reactHooks/dev/__tests__/useReRenderLog.test.ts +188 -0
- package/reactHooks/device/useIsTablet.tsx +14 -19
- package/reactHooks/events/index.ts +20 -0
- package/reactHooks/feed/__tests__/useBatchLoading.test.tsx +32 -23
- package/reactHooks/feed/__tests__/useBuildPipesUrl.test.tsx +19 -19
- package/reactHooks/feed/__tests__/useEntryScreenId.test.tsx +1 -1
- package/reactHooks/feed/__tests__/useFeedLoader.test.tsx +42 -30
- package/reactHooks/feed/__tests__/useInflatedUrl.test.tsx +1 -1
- package/reactHooks/feed/index.ts +0 -2
- package/reactHooks/feed/useInflatedUrl.ts +1 -1
- package/reactHooks/hookModal/hooks/useHookModalScreenData.ts +12 -8
- package/reactHooks/index.ts +2 -0
- package/reactHooks/layout/__tests__/index.test.tsx +1 -1
- package/reactHooks/layout/__tests__/useLayoutVersion.test.tsx +1 -1
- package/reactHooks/navigation/__tests__/index.test.tsx +40 -9
- package/reactHooks/navigation/index.ts +15 -4
- package/reactHooks/navigation/useRoute.ts +3 -1
- package/reactHooks/player/__tests__/useAutoSeek._test.tsx +1 -1
- package/reactHooks/player/__tests__/useTapSeek._test.ts +1 -1
- package/reactHooks/resolvers/__tests__/useCellResolver.test.tsx +1 -1
- package/reactHooks/resolvers/__tests__/useComponentResolver.test.tsx +1 -1
- package/reactHooks/resolvers/useComponentResolver.ts +13 -3
- package/reactHooks/screen/__tests__/useCurrentScreenData.test.tsx +1 -1
- package/reactHooks/screen/__tests__/useCurrentScreenIsHook.test.ts +103 -0
- package/reactHooks/screen/__tests__/useCurrentScreenIsStartupHook.test.ts +94 -0
- package/reactHooks/screen/__tests__/useScreenBackgroundColor.test.tsx +1 -1
- package/reactHooks/screen/__tests__/useScreenData.test.tsx +1 -1
- package/reactHooks/screen/__tests__/useTargetScreenData.test.tsx +1 -1
- package/reactHooks/screen/index.ts +4 -0
- package/reactHooks/screen/useCurrentScreenIsHook.ts +9 -0
- package/reactHooks/screen/useCurrentScreenIsStartupHook.ts +8 -0
- package/reactHooks/state/__tests__/useComponentScreenState.test.ts +246 -0
- package/reactHooks/state/index.ts +2 -0
- package/reactHooks/state/useComponentScreenState.ts +45 -0
- package/reactHooks/state/useRefWithInitialValue.ts +10 -0
- package/reactHooks/ui/__tests__/useFadeOutWhenBlurred.test.ts +580 -0
- package/reactHooks/utils/__tests__/index.test.js +1 -1
- package/rectUtils/__tests__/index.test.ts +549 -0
- package/rectUtils/index.ts +2 -2
- package/refreshUtils/RefreshCoordinator/__tests__/refreshCoordinator.test.ts +206 -0
- package/refreshUtils/RefreshCoordinator/index.ts +245 -0
- package/refreshUtils/RefreshCoordinator/utils/__tests__/getDataRefreshConfig.test.ts +104 -0
- package/refreshUtils/RefreshCoordinator/utils/index.ts +29 -0
- package/screenPickerUtils/__tests__/index.test.ts +333 -0
- package/screenPickerUtils/index.ts +5 -0
- package/screenState/__tests__/index.test.ts +1 -1
- package/screenUtils/index.ts +3 -0
- package/services/storageServiceSync.web.ts +1 -1
- package/time/__tests__/BackgroundTimer.test.ts +156 -0
- package/time/__tests__/Timer.test.ts +236 -0
- package/typeGuards/__tests__/isString.test.ts +21 -0
- package/typeGuards/index.ts +4 -0
- package/utils/__tests__/clone.test.ts +158 -0
- package/utils/__tests__/path.test.ts +7 -0
- package/utils/clone.ts +7 -0
- package/utils/index.ts +2 -1
- package/reactHooks/componentsMap/index.ts +0 -55
- package/reactHooks/feed/__tests__/useFeedRefresh.test.tsx +0 -75
- package/reactHooks/feed/useFeedRefresh.tsx +0 -65
|
@@ -205,31 +205,31 @@ export class Tree {
|
|
|
205
205
|
* @returns founded node or null
|
|
206
206
|
*/
|
|
207
207
|
findInTree(id) {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
return this.findInArray(id, this.root.children, retVal);
|
|
208
|
+
return this.findInArray(id, this.root.children);
|
|
211
209
|
}
|
|
212
210
|
|
|
213
|
-
findInArray(id, children
|
|
214
|
-
if (!
|
|
215
|
-
|
|
211
|
+
findInArray(id, children) {
|
|
212
|
+
if (!children) {
|
|
213
|
+
return null;
|
|
214
|
+
}
|
|
216
215
|
|
|
217
|
-
|
|
218
|
-
children.forEach((child) => {
|
|
219
|
-
if (child.children) {
|
|
220
|
-
retVal = this.findInArray(id, child.children, retVal);
|
|
216
|
+
const directMatch = children.find((obj) => obj.id === id);
|
|
221
217
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
218
|
+
if (directMatch) {
|
|
219
|
+
return directMatch;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
for (const child of children) {
|
|
223
|
+
if (child.children) {
|
|
224
|
+
const nestedMatch = this.findInArray(id, child.children);
|
|
225
|
+
|
|
226
|
+
if (nestedMatch) {
|
|
227
|
+
return nestedMatch;
|
|
228
|
+
}
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
231
|
|
|
232
|
-
return
|
|
232
|
+
return null;
|
|
233
233
|
}
|
|
234
234
|
|
|
235
235
|
/**
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
|
|
14
14
|
import {
|
|
15
15
|
getFocusableId,
|
|
16
|
-
|
|
16
|
+
isTabsScreenContentContainerId,
|
|
17
17
|
} from "@applicaster/zapp-react-native-utils/screenPickerUtils";
|
|
18
18
|
|
|
19
19
|
// run check each 300 ms
|
|
@@ -24,8 +24,6 @@ const isTopMenu = (node) => startsWith(QUICK_BRICK_NAVBAR, node?.id);
|
|
|
24
24
|
const isContent = (node) => startsWith(QUICK_BRICK_CONTENT, node?.id);
|
|
25
25
|
const isRoot = (node) => node?.id === "root";
|
|
26
26
|
|
|
27
|
-
const isScrenPicker = (node) => startsWith(SCREEN_PICKER_CONTAINER, node?.id);
|
|
28
|
-
|
|
29
27
|
type Props = {
|
|
30
28
|
maxTimeout: number;
|
|
31
29
|
conditionFn: () => boolean;
|
|
@@ -136,7 +134,7 @@ export const isTabsScreenOnContentFocused = (node) => {
|
|
|
136
134
|
return false;
|
|
137
135
|
}
|
|
138
136
|
|
|
139
|
-
if (
|
|
137
|
+
if (isTabsScreenContentContainerId(node?.id)) {
|
|
140
138
|
return true;
|
|
141
139
|
}
|
|
142
140
|
|
|
@@ -144,6 +142,10 @@ export const isTabsScreenOnContentFocused = (node) => {
|
|
|
144
142
|
};
|
|
145
143
|
|
|
146
144
|
export const isCurrentFocusOnMenu = (node) => {
|
|
145
|
+
if (isNil(node)) {
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
|
|
147
149
|
if (isRoot(node)) {
|
|
148
150
|
return false;
|
|
149
151
|
}
|
|
@@ -156,10 +158,14 @@ export const isCurrentFocusOnMenu = (node) => {
|
|
|
156
158
|
return false;
|
|
157
159
|
}
|
|
158
160
|
|
|
159
|
-
return isCurrentFocusOnMenu(node
|
|
161
|
+
return isCurrentFocusOnMenu(node?.parent);
|
|
160
162
|
};
|
|
161
163
|
|
|
162
164
|
export const isCurrentFocusOnContent = (node) => {
|
|
165
|
+
if (isNil(node)) {
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
|
|
163
169
|
if (isRoot(node)) {
|
|
164
170
|
return false;
|
|
165
171
|
}
|
|
@@ -172,7 +178,7 @@ export const isCurrentFocusOnContent = (node) => {
|
|
|
172
178
|
return true;
|
|
173
179
|
}
|
|
174
180
|
|
|
175
|
-
return isCurrentFocusOnContent(node
|
|
181
|
+
return isCurrentFocusOnContent(node?.parent);
|
|
176
182
|
};
|
|
177
183
|
|
|
178
184
|
export const isCurrentFocusOn = (id, node) => {
|
|
@@ -106,9 +106,8 @@ const focusableNativeViewRegistration = ({ focusableView, focusableGroup }) => {
|
|
|
106
106
|
);
|
|
107
107
|
};
|
|
108
108
|
|
|
109
|
-
export const
|
|
109
|
+
export const firstFocusableViewInContentRegistrationFactory = () =>
|
|
110
110
|
focusableViewRegistrationSubject$.pipe(
|
|
111
|
-
take(1), // we care about only first FocusableView registration
|
|
112
111
|
switchMap((focusableView) =>
|
|
113
112
|
// start waiting registration of its parent FocusableGroup
|
|
114
113
|
focusableGroupRegistrationSubject$.pipe(
|
|
@@ -126,7 +125,11 @@ export const firstFocusableViewRegistrationFactory = () =>
|
|
|
126
125
|
focusableView,
|
|
127
126
|
focusableGroup,
|
|
128
127
|
})
|
|
129
|
-
)
|
|
128
|
+
),
|
|
129
|
+
filter(({ focusableView }) =>
|
|
130
|
+
isPartOfContent(focusManager.focusableTree, focusableView.id)
|
|
131
|
+
),
|
|
132
|
+
take(1) // we care about only first FocusableView registration
|
|
130
133
|
);
|
|
131
134
|
|
|
132
135
|
// registration on RN level(into RN focusManager)
|
|
@@ -33,6 +33,7 @@ function deprecationWarning(method) {
|
|
|
33
33
|
export interface PlayerLifecycleListener {
|
|
34
34
|
onRegistered?: (player: Player) => void;
|
|
35
35
|
onUnRegistered?: (player: Player) => void;
|
|
36
|
+
onCastingChanged?: (isCasting: boolean) => void;
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
type PlayersMap = {
|
|
@@ -253,10 +254,18 @@ export class PlayerManager {
|
|
|
253
254
|
|
|
254
255
|
public registerCastingReceiver(receiver: Player) {
|
|
255
256
|
this.castingReceiver = receiver;
|
|
257
|
+
|
|
258
|
+
this.lifecycleListeners.forEach((listener) => {
|
|
259
|
+
listener.onCastingChanged?.(true);
|
|
260
|
+
});
|
|
256
261
|
}
|
|
257
262
|
|
|
258
263
|
public unregisterCastingReceiver() {
|
|
259
264
|
this.castingReceiver = null;
|
|
265
|
+
|
|
266
|
+
this.lifecycleListeners.forEach((listener) => {
|
|
267
|
+
listener.onCastingChanged?.(false);
|
|
268
|
+
});
|
|
260
269
|
}
|
|
261
270
|
|
|
262
271
|
/**
|
|
@@ -229,8 +229,9 @@ export class PlayerNative extends Player {
|
|
|
229
229
|
};
|
|
230
230
|
|
|
231
231
|
closeNativePlayer = () => {
|
|
232
|
-
// TODO: Delete does not work
|
|
232
|
+
// TODO: Delete, does not work (component is null)
|
|
233
233
|
this.currentPlayerComponent()?.closeNativePlayer?.();
|
|
234
|
+
this.getPlayerModule()?.stopBackgroundPlayback?.();
|
|
234
235
|
};
|
|
235
236
|
|
|
236
237
|
togglePlayPause = () => {
|
|
@@ -22,7 +22,6 @@ export const usePlayer = (playerId?: string): Player => {
|
|
|
22
22
|
|
|
23
23
|
const isCasting = playerManager.isCasting();
|
|
24
24
|
|
|
25
|
-
// TODO: We need to prerender when we start/stop casting, fix this
|
|
26
25
|
const getPlayer = (playerId, isCasting) =>
|
|
27
26
|
getControlledPlayer(playerId, isCasting);
|
|
28
27
|
|
|
@@ -46,7 +45,7 @@ export const usePlayer = (playerId?: string): Player => {
|
|
|
46
45
|
return playerManager.addLifecycleListener({
|
|
47
46
|
onRegistered: (player) => {
|
|
48
47
|
if (playerIdToUse === player.playerId) {
|
|
49
|
-
setPlayer(getPlayer(playerIdToUse, isCasting));
|
|
48
|
+
setPlayer(getPlayer(playerIdToUse, playerManager.isCasting()));
|
|
50
49
|
}
|
|
51
50
|
},
|
|
52
51
|
onUnRegistered: (player) => {
|
|
@@ -54,8 +53,11 @@ export const usePlayer = (playerId?: string): Player => {
|
|
|
54
53
|
setPlayer(null);
|
|
55
54
|
}
|
|
56
55
|
},
|
|
56
|
+
onCastingChanged: () => {
|
|
57
|
+
setPlayer(getPlayer(playerIdToUse, playerManager.isCasting()));
|
|
58
|
+
},
|
|
57
59
|
} as PlayerLifecycleListener);
|
|
58
|
-
}, [playerIdToUse
|
|
60
|
+
}, [playerIdToUse]);
|
|
59
61
|
|
|
60
62
|
return player;
|
|
61
63
|
};
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
ifEmptyUseFallback,
|
|
4
4
|
textTransform,
|
|
5
5
|
getKeyForLabel,
|
|
6
|
+
getDataTransformForLabel,
|
|
6
7
|
getLabel,
|
|
7
8
|
getAspectRatio,
|
|
8
9
|
getCellWidth,
|
|
@@ -56,6 +57,44 @@ describe("getKeyForLabel", () => {
|
|
|
56
57
|
});
|
|
57
58
|
});
|
|
58
59
|
|
|
60
|
+
describe("getDataTransformForLabel", () => {
|
|
61
|
+
it("returns dataKey when dataKey is not other", () => {
|
|
62
|
+
expect(getDataTransformForLabel(VAL.dataKey, VAL.customKey)).toEqual(
|
|
63
|
+
VAL.dataKey
|
|
64
|
+
);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it("returns customKey when dataKey is other", () => {
|
|
68
|
+
expect(getDataTransformForLabel(VAL.other, VAL.customKey)).toEqual(
|
|
69
|
+
VAL.customKey
|
|
70
|
+
);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("preserves full date formats containing dots", () => {
|
|
74
|
+
expect(getDataTransformForLabel(VAL.other, "DD.MM.YYYY")).toEqual(
|
|
75
|
+
"DD.MM.YYYY"
|
|
76
|
+
);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("returns default date format when selected key is null or undefined", () => {
|
|
80
|
+
expect(getDataTransformForLabel(EMPTY.nulls, VAL.customKey)).toEqual(
|
|
81
|
+
"DD/MM/YYYY"
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
expect(getDataTransformForLabel(EMPTY.undef, VAL.customKey)).toEqual(
|
|
85
|
+
"DD/MM/YYYY"
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
expect(getDataTransformForLabel(VAL.other, EMPTY.nulls)).toEqual(
|
|
89
|
+
"DD/MM/YYYY"
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
expect(getDataTransformForLabel(VAL.other, EMPTY.undef)).toEqual(
|
|
93
|
+
"DD/MM/YYYY"
|
|
94
|
+
);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
|
|
59
98
|
describe("getLabel", () => {
|
|
60
99
|
it("returns a string from dataKey's path", () => {
|
|
61
100
|
expect(getLabel(VAL.dataKey, VAL.customKey)(entry)).toEqual(entry.id);
|
package/cellUtils/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as R from "ramda";
|
|
2
|
-
import dayjs from "
|
|
2
|
+
import { dayjs } from "../dateUtils";
|
|
3
3
|
import validateColor from "validate-color";
|
|
4
4
|
|
|
5
5
|
import { transformColorCode as fixColorHexCode } from "@applicaster/zapp-react-native-utils/transform";
|
|
@@ -31,6 +31,16 @@ export const getKeyForLabel = (dataKey, customKey) => {
|
|
|
31
31
|
return keyToUse.split(".");
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
+
/**
|
|
35
|
+
* Provides `format` for date formatting. Returns customKey if dataKey is "other", otherwise it returns dataKey.
|
|
36
|
+
* Should consist of valid dayjs tokens - https://day.js.org/docs/en/parse/string-format#list-of-all-available-parsing-tokens
|
|
37
|
+
*/
|
|
38
|
+
export const getDataTransformForLabel = (dataKey, customKey) => {
|
|
39
|
+
const keyToUse = dataKey === CUSTOM_KEY ? customKey : dataKey;
|
|
40
|
+
|
|
41
|
+
return keyToUse ?? "DD/MM/YYYY";
|
|
42
|
+
};
|
|
43
|
+
|
|
34
44
|
/**
|
|
35
45
|
* This method will return true if the argument passed to it is either empty or nil
|
|
36
46
|
* The method prevents zero from being evaluated as falsey in an || condition
|