@applicaster/zapp-react-native-utils 15.0.0-rc.99 → 15.1.0-rc.1
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 +51 -5
- package/actionsExecutor/feedDecorator.ts +6 -6
- package/adsUtils/index.ts +2 -2
- package/analyticsUtils/README.md +1 -1
- package/appUtils/HooksManager/__tests__/__snapshots__/hooksManager.test.js.snap +188 -0
- package/appUtils/HooksManager/__tests__/hooksManager.test.js +2 -16
- package/appUtils/HooksManager/index.ts +45 -10
- package/appUtils/RiverFocusManager/{index.ts → index.js} +18 -25
- package/appUtils/accessibilityManager/const.ts +0 -4
- package/appUtils/accessibilityManager/utils.ts +1 -0
- package/appUtils/contextKeysManager/__tests__/getKeys/failure.test.ts +2 -7
- package/appUtils/contextKeysManager/__tests__/getKeys/success.test.ts +0 -48
- package/appUtils/contextKeysManager/contextResolver.ts +22 -51
- package/appUtils/contextKeysManager/index.ts +10 -65
- package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +0 -3
- package/appUtils/focusManager/index.ios.ts +4 -43
- package/appUtils/focusManagerAux/utils/index.ts +3 -5
- package/appUtils/focusManagerAux/utils/utils.ios.ts +3 -199
- package/appUtils/keyCodes/keys/keys.web.ts +4 -1
- package/appUtils/localizationsHelper.ts +4 -0
- package/appUtils/orientationHelper.ts +4 -2
- package/appUtils/platform/platformUtils.ts +1 -1
- package/appUtils/playerManager/index.ts +9 -0
- package/appUtils/playerManager/player.ts +1 -5
- package/appUtils/playerManager/playerNative.ts +22 -30
- package/appUtils/playerManager/usePlayer.tsx +5 -3
- package/appUtils/playerManager/usePlayerState.tsx +2 -14
- package/cellUtils/__tests__/cellUtils.test.ts +39 -0
- package/cellUtils/index.ts +11 -1
- package/cloudEventsUtils/index.ts +1 -65
- package/configurationUtils/__tests__/manifestKeyParser.test.ts +26 -26
- package/dateUtils/__tests__/dayjs.test.ts +0 -3
- package/dateUtils/index.ts +2 -0
- package/focusManager/aux/index.ts +1 -1
- package/headersUtils/__tests__/headersUtils.test.js +1 -11
- package/headersUtils/index.ts +1 -2
- package/manifestUtils/defaultManifestConfigurations/player.js +7 -75
- package/manifestUtils/tvAction/container/index.js +1 -1
- package/numberUtils/__tests__/toNumber.test.ts +0 -12
- package/numberUtils/index.ts +1 -19
- package/package.json +4 -4
- package/pluginUtils/index.ts +4 -9
- package/reactHooks/advertising/index.ts +2 -2
- 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 +2 -1
- package/reactHooks/casting/index.ts +1 -0
- package/reactHooks/casting/useIsCasting.tsx +57 -0
- package/reactHooks/cell-click/__tests__/index.test.js +3 -1
- package/reactHooks/componentsMap/index.ts +55 -0
- package/reactHooks/configuration/__tests__/index.test.tsx +1 -1
- package/reactHooks/connection/__tests__/index.test.js +1 -1
- package/reactHooks/debugging/__tests__/index.test.js +4 -4
- package/reactHooks/device/useIsTablet.tsx +19 -14
- package/reactHooks/device/useMemoizedIsTablet.ts +3 -3
- package/reactHooks/feed/__tests__/useBatchLoading.test.tsx +23 -32
- package/reactHooks/feed/__tests__/useBuildPipesUrl.test.tsx +19 -19
- package/reactHooks/feed/__tests__/useEntryScreenId.test.tsx +1 -4
- package/reactHooks/feed/__tests__/useFeedLoader.test.tsx +30 -42
- package/reactHooks/feed/__tests__/useFeedRefresh.test.tsx +1 -1
- package/reactHooks/feed/__tests__/useInflatedUrl.test.tsx +1 -1
- package/reactHooks/feed/useBatchLoading.ts +1 -7
- package/reactHooks/feed/useEntryScreenId.ts +2 -2
- package/reactHooks/feed/useInflatedUrl.ts +1 -1
- package/reactHooks/feed/usePipesCacheReset.ts +1 -3
- package/reactHooks/flatList/useLoadNextPageIfNeeded.ts +16 -13
- package/reactHooks/layout/__tests__/index.test.tsx +1 -1
- package/reactHooks/layout/__tests__/useLayoutVersion.test.tsx +1 -1
- package/reactHooks/layout/useDimensions/__tests__/{useDimensions.test.tsx → useDimensions.test.ts} +25 -105
- package/reactHooks/layout/useDimensions/useDimensions.ts +2 -2
- package/reactHooks/navigation/__tests__/index.test.tsx +4 -2
- package/reactHooks/navigation/index.ts +6 -7
- package/reactHooks/navigation/useRoute.ts +6 -8
- package/reactHooks/player/TVSeekControlller/TVSeekController.ts +10 -27
- 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/useCellResolver.ts +2 -6
- package/reactHooks/resolvers/useComponentResolver.ts +13 -9
- package/reactHooks/screen/__tests__/useCurrentScreenData.test.tsx +2 -2
- 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 +4 -12
- package/reactHooks/screen/index.ts +6 -0
- package/reactHooks/screen/useCurrentScreenIsHook.ts +9 -0
- package/reactHooks/screen/useCurrentScreenIsStartupHook.ts +8 -0
- package/reactHooks/screen/useIsStandaloneFullscreen.ts +12 -0
- package/reactHooks/screen/useTargetScreenData.ts +2 -4
- 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/useRivers.ts +1 -1
- package/reactHooks/usePluginConfiguration.ts +2 -2
- package/reactHooks/utils/__tests__/index.test.js +1 -1
- package/rectUtils/index.ts +2 -2
- package/screenPickerUtils/index.ts +5 -0
- package/screenState/__tests__/index.test.ts +1 -1
- package/stringUtils/index.ts +1 -1
- package/testUtils/index.tsx +21 -30
- package/typeGuards/index.ts +0 -4
- package/utils/__tests__/clone.test.ts +158 -0
- package/utils/clone.ts +7 -0
- package/utils/index.ts +1 -13
- package/utils/path.ts +3 -6
- package/utils/pathOr.ts +1 -5
- package/zappFrameworkUtils/HookCallback/callbackNavigationAction.ts +1 -1
- package/zappFrameworkUtils/HookCallback/hookCallbackManifestExtensions.config.js +1 -1
- package/zappFrameworkUtils/loginPluginUtils.ts +1 -1
- package/adsUtils/__tests__/createVMAP.test.ts +0 -419
- package/appDataUtils/__tests__/urlScheme.test.ts +0 -678
- package/appUtils/focusManagerAux/utils/index.ios.ts +0 -122
- package/cloudEventsUtils/__tests__/index.test.ts +0 -529
- package/enumUtils/__tests__/getEnumKeyByEnumValue.test.ts +0 -207
- package/errorUtils/__tests__/GeneralError.test.ts +0 -97
- package/errorUtils/__tests__/HttpStatusCode.test.ts +0 -344
- package/errorUtils/__tests__/MissingPluginError.test.ts +0 -113
- package/errorUtils/__tests__/NetworkError.test.ts +0 -202
- package/errorUtils/__tests__/getParsedResponse.test.ts +0 -188
- package/errorUtils/__tests__/invariant.test.ts +0 -112
- package/numberUtils/__tests__/toPositiveNumber.test.ts +0 -165
- package/reactHooks/analytics/__tests__/useSendAnalyticsOnPress.test.ts +0 -537
- package/reactHooks/dev/__tests__/useReRenderLog.test.ts +0 -188
- package/reactHooks/ui/__tests__/useFadeOutWhenBlurred.test.ts +0 -580
- package/rectUtils/__tests__/index.test.ts +0 -549
- package/screenPickerUtils/__tests__/index.test.ts +0 -333
- package/searchUtils/const.ts +0 -7
- package/searchUtils/index.ts +0 -3
- package/time/__tests__/BackgroundTimer.test.ts +0 -156
- package/time/__tests__/Timer.test.ts +0 -236
- package/typeGuards/__tests__/isString.test.ts +0 -21
- package/utils/__tests__/mergeRight.test.ts +0 -48
- package/utils/__tests__/selectors.test.ts +0 -124
- package/utils/mergeRight.ts +0 -5
- package/utils/selectors.ts +0 -46
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as ReactNative from "react-native";
|
|
2
|
-
import {
|
|
2
|
+
import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
|
|
3
3
|
|
|
4
4
|
import { isTV, platformSelect } from "../reactUtils";
|
|
5
5
|
import { useIsTablet } from "../reactHooks";
|
|
@@ -184,7 +184,9 @@ export const getScreenOrientation = ({
|
|
|
184
184
|
|
|
185
185
|
export const useGetScreenOrientation = (screenData) => {
|
|
186
186
|
const isTablet = useIsTablet();
|
|
187
|
-
|
|
187
|
+
|
|
188
|
+
const { appData } = usePickFromState(["appData"]);
|
|
189
|
+
const isTabletPortrait = appData?.isTabletPortrait;
|
|
188
190
|
|
|
189
191
|
return getScreenOrientation({
|
|
190
192
|
screenData,
|
|
@@ -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
|
/**
|
|
@@ -250,15 +250,11 @@ export class Player {
|
|
|
250
250
|
return false;
|
|
251
251
|
}
|
|
252
252
|
|
|
253
|
-
if (!Number.isFinite(duration)) {
|
|
254
|
-
return this.getSeekableDuration() > 0;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
253
|
return duration > 0;
|
|
258
254
|
};
|
|
259
255
|
|
|
260
256
|
isAd = () => {
|
|
261
|
-
return !!this.playerState.adState || this.playerState.isInAdBreak;
|
|
257
|
+
return !!this.playerState.adState || !!this.playerState.isInAdBreak;
|
|
262
258
|
};
|
|
263
259
|
|
|
264
260
|
isSeeking = () => {
|
|
@@ -15,22 +15,6 @@ const logger = createLogger({
|
|
|
15
15
|
|
|
16
16
|
const { log_warning } = logger;
|
|
17
17
|
|
|
18
|
-
interface PlayerMethods {
|
|
19
|
-
seeking?: (position: number) => void;
|
|
20
|
-
forward?: (deltaTime: number) => void;
|
|
21
|
-
rewind?: (deltaTime: number) => void;
|
|
22
|
-
startSleepTimer?: (sleepTimestamp: number) => void;
|
|
23
|
-
selectTrack?: (
|
|
24
|
-
selected: QuickBrickPlayer.TextTrack | QuickBrickPlayer.AudioTrack
|
|
25
|
-
) => void;
|
|
26
|
-
setPlaybackRate?: (rate: number) => void;
|
|
27
|
-
appStateChange?: (appState: string, previousAppState: string) => void;
|
|
28
|
-
closeNativePlayer?: () => void;
|
|
29
|
-
togglePlayPause?: () => void;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
type PlayerComponent = ReactComponent<PlayerRefProps> & PlayerMethods;
|
|
33
|
-
|
|
34
18
|
type PlayerPlugnId = "QuickBrickPlayerPlugin" | "KalturaPlayerPlugin";
|
|
35
19
|
|
|
36
20
|
type Props = {
|
|
@@ -78,7 +62,7 @@ export class PlayerNative extends Player {
|
|
|
78
62
|
return this.playerState.contentPosition;
|
|
79
63
|
};
|
|
80
64
|
|
|
81
|
-
currentPlayerComponent = ():
|
|
65
|
+
currentPlayerComponent = (): ReactComponent<PlayerRefProps> =>
|
|
82
66
|
this.playerComponent?.current;
|
|
83
67
|
|
|
84
68
|
getState = () => this.playerState;
|
|
@@ -137,7 +121,7 @@ export class PlayerNative extends Player {
|
|
|
137
121
|
|
|
138
122
|
this.playerState.seekPosition = newPosition;
|
|
139
123
|
|
|
140
|
-
this.currentPlayerComponent()?.seeking
|
|
124
|
+
this.currentPlayerComponent()?.["seeking"](this.playerState.seekPosition);
|
|
141
125
|
}
|
|
142
126
|
|
|
143
127
|
this.logState(PlayerModuleFuncNames.seekTo, { position });
|
|
@@ -151,7 +135,7 @@ export class PlayerNative extends Player {
|
|
|
151
135
|
if (!this.invokeNativeFunction(PlayerModuleFuncNames.forward, deltaTime)) {
|
|
152
136
|
// Kaltura does not have yet this implementation, use legacy code
|
|
153
137
|
|
|
154
|
-
this.currentPlayerComponent()?.forward
|
|
138
|
+
this.currentPlayerComponent()?.["forward"](deltaTime);
|
|
155
139
|
}
|
|
156
140
|
|
|
157
141
|
this.notifyPlayHeadPositionUpdate();
|
|
@@ -167,7 +151,7 @@ export class PlayerNative extends Player {
|
|
|
167
151
|
if (!this.invokeNativeFunction(PlayerModuleFuncNames.rewind, deltaTime)) {
|
|
168
152
|
// Kaltura does not have yet this implementation, use legacy code
|
|
169
153
|
|
|
170
|
-
this.currentPlayerComponent()?.rewind
|
|
154
|
+
this.currentPlayerComponent()?.["rewind"](deltaTime);
|
|
171
155
|
}
|
|
172
156
|
|
|
173
157
|
this.notifyPlayHeadPositionUpdate();
|
|
@@ -194,7 +178,7 @@ export class PlayerNative extends Player {
|
|
|
194
178
|
sleepTimestamp
|
|
195
179
|
)
|
|
196
180
|
) {
|
|
197
|
-
this.currentPlayerComponent()?.startSleepTimer
|
|
181
|
+
this.currentPlayerComponent()?.["startSleepTimer"](sleepTimestamp);
|
|
198
182
|
}
|
|
199
183
|
};
|
|
200
184
|
|
|
@@ -211,11 +195,11 @@ export class PlayerNative extends Player {
|
|
|
211
195
|
selectTrack = (
|
|
212
196
|
selected: QuickBrickPlayer.TextTrack | QuickBrickPlayer.AudioTrack
|
|
213
197
|
) => {
|
|
214
|
-
this.currentPlayerComponent()?.selectTrack?.(selected);
|
|
198
|
+
this.currentPlayerComponent()?.["selectTrack"]?.(selected);
|
|
215
199
|
};
|
|
216
200
|
|
|
217
201
|
setPlaybackRate = (rate: number) => {
|
|
218
|
-
this.currentPlayerComponent()?.setPlaybackRate?.(rate);
|
|
202
|
+
this.currentPlayerComponent()?.["setPlaybackRate"]?.(rate);
|
|
219
203
|
};
|
|
220
204
|
|
|
221
205
|
getPluginConfiguration = () => {
|
|
@@ -225,16 +209,24 @@ export class PlayerNative extends Player {
|
|
|
225
209
|
getProps = () => (this.currentPlayerComponent() as any)?.props;
|
|
226
210
|
|
|
227
211
|
appStateChange = (appState, previousAppState) => {
|
|
228
|
-
this.currentPlayerComponent()?.appStateChange?.(
|
|
212
|
+
this.currentPlayerComponent()?.["appStateChange"]?.(
|
|
213
|
+
appState,
|
|
214
|
+
previousAppState
|
|
215
|
+
);
|
|
229
216
|
};
|
|
230
217
|
|
|
231
218
|
closeNativePlayer = () => {
|
|
232
|
-
//
|
|
233
|
-
|
|
219
|
+
// The player component ref may be null (for example, when the native player view is not mounted),
|
|
220
|
+
// so calling closeNativePlayer on the component is best‑effort only. We cannot use invokeNativeFunction
|
|
221
|
+
// here because it prepends the view id, while the native closeNativePlayer implementation does not
|
|
222
|
+
// expect a view id argument. As a reliable fallback we always call stopBackgroundPlayback on the
|
|
223
|
+
// native module to ensure background playback is stopped.
|
|
224
|
+
this.currentPlayerComponent()?.["closeNativePlayer"]?.();
|
|
225
|
+
this.getPlayerModule()?.stopBackgroundPlayback?.();
|
|
234
226
|
};
|
|
235
227
|
|
|
236
228
|
togglePlayPause = () => {
|
|
237
|
-
this.currentPlayerComponent()?.togglePlayPause?.();
|
|
229
|
+
this.currentPlayerComponent()?.["togglePlayPause"]?.();
|
|
238
230
|
};
|
|
239
231
|
|
|
240
232
|
onVideoLoad = (event) => {
|
|
@@ -302,19 +294,19 @@ export class PlayerNative extends Player {
|
|
|
302
294
|
isFullScreenSupported = (): boolean => {
|
|
303
295
|
const config = this.getConfig();
|
|
304
296
|
|
|
305
|
-
const disableFullScreen = config?.disable_fullscreen;
|
|
297
|
+
const disableFullScreen = config?.["disable_fullscreen"];
|
|
306
298
|
|
|
307
299
|
if (disableFullScreen) {
|
|
308
300
|
return false;
|
|
309
301
|
}
|
|
310
302
|
|
|
311
|
-
const isFullScreenAudioPlayer = config?.full_screen_audio_player;
|
|
303
|
+
const isFullScreenAudioPlayer = config?.["full_screen_audio_player"];
|
|
312
304
|
|
|
313
305
|
return !(isFullScreenAudioPlayer && this.isAudioItem());
|
|
314
306
|
};
|
|
315
307
|
|
|
316
308
|
supportsNativeControls = (): boolean =>
|
|
317
|
-
toBooleanWithDefaultFalse(this.getConfig()?.supports_native_controls);
|
|
309
|
+
toBooleanWithDefaultFalse(this.getConfig()?.["supports_native_controls"]);
|
|
318
310
|
|
|
319
311
|
supportNativeCast = (): boolean =>
|
|
320
312
|
toBooleanWithDefaultFalse(
|
|
@@ -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
|
};
|
|
@@ -2,7 +2,7 @@ import * as React from "react";
|
|
|
2
2
|
import { Player } from "./player";
|
|
3
3
|
import { usePlayer } from "./usePlayer";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
type PlayerState = {
|
|
6
6
|
currentTime: number;
|
|
7
7
|
duration: number;
|
|
8
8
|
seekableDuration: number;
|
|
@@ -10,8 +10,6 @@ export type PlayerState = {
|
|
|
10
10
|
isPaused: boolean;
|
|
11
11
|
isBuffering: boolean;
|
|
12
12
|
isReadyToPlay: boolean;
|
|
13
|
-
trackState?: QuickBrickPlayer.TracksState;
|
|
14
|
-
isAd: boolean;
|
|
15
13
|
};
|
|
16
14
|
|
|
17
15
|
export const usePlayerState = (
|
|
@@ -26,8 +24,6 @@ export const usePlayerState = (
|
|
|
26
24
|
isPaused: null,
|
|
27
25
|
isBuffering: false,
|
|
28
26
|
isReadyToPlay: false,
|
|
29
|
-
trackState: null,
|
|
30
|
-
isAd: false,
|
|
31
27
|
});
|
|
32
28
|
|
|
33
29
|
const player: Player = usePlayer(playerId);
|
|
@@ -41,8 +37,6 @@ export const usePlayerState = (
|
|
|
41
37
|
isPaused: player.isPaused(),
|
|
42
38
|
isBuffering: player.isBuffering(),
|
|
43
39
|
isReadyToPlay: player.isReadyToPlay(),
|
|
44
|
-
trackState: player.getTracksState(),
|
|
45
|
-
isAd: player.isAd(),
|
|
46
40
|
});
|
|
47
41
|
}, [player]);
|
|
48
42
|
|
|
@@ -60,16 +54,10 @@ export const usePlayerState = (
|
|
|
60
54
|
onPlayerPause: onPlayerChangeState,
|
|
61
55
|
onPlayerResume: onPlayerChangeState,
|
|
62
56
|
onPlayerSeekComplete: onPlayerChangeState,
|
|
63
|
-
onTracksChanged: onPlayerChangeState,
|
|
64
|
-
onAdBreakBegin: onPlayerChangeState,
|
|
65
|
-
onAdBreakEnd: onPlayerChangeState,
|
|
66
|
-
onAdBegin: onPlayerChangeState,
|
|
67
|
-
onAdEnd: onPlayerChangeState,
|
|
68
|
-
onAdError: onPlayerChangeState,
|
|
69
57
|
},
|
|
70
58
|
});
|
|
71
59
|
}
|
|
72
|
-
}, [
|
|
60
|
+
}, [player]);
|
|
73
61
|
|
|
74
62
|
return state;
|
|
75
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
|
|
@@ -3,41 +3,6 @@ import { RequestBuilder } from "@applicaster/zapp-pipes-v2-client";
|
|
|
3
3
|
import { sessionStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/SessionStorage";
|
|
4
4
|
import { getAppUrlScheme } from "@applicaster/zapp-react-native-utils/appDataUtils";
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* CloudEvents v1.0 compliant event object
|
|
8
|
-
* @see https://github.com/cloudevents/spec/blob/v1.0/spec.md
|
|
9
|
-
*/
|
|
10
|
-
export interface CloudEvent<T = any> {
|
|
11
|
-
/** CloudEvents specification version (always "1.0") */
|
|
12
|
-
specversion: "1.0";
|
|
13
|
-
/** Type of event (e.g., "user.action", "commerce.purchase") */
|
|
14
|
-
type: string;
|
|
15
|
-
/** Identifier for the entity that produced the event */
|
|
16
|
-
source: string;
|
|
17
|
-
/** Unique identifier for the event */
|
|
18
|
-
id: string;
|
|
19
|
-
/** Subject of the event in the context of the event producer */
|
|
20
|
-
subject: string;
|
|
21
|
-
/** Timestamp of when the event occurred (ISO 8601 format) */
|
|
22
|
-
time: string;
|
|
23
|
-
/** Content type of the data attribute (always "application/json") */
|
|
24
|
-
datacontenttype: "application/json";
|
|
25
|
-
/** Event payload */
|
|
26
|
-
data: T;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Parameters required to create a cloud event
|
|
31
|
-
*/
|
|
32
|
-
export interface CreateCloudEventParams<T = any> {
|
|
33
|
-
/** Type of event (e.g., "user.action", "commerce.purchase") */
|
|
34
|
-
type: string;
|
|
35
|
-
/** Subject of the event in the context of the event producer */
|
|
36
|
-
subject: string;
|
|
37
|
-
/** Event payload */
|
|
38
|
-
data: T;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
6
|
let source: string | null = null;
|
|
42
7
|
|
|
43
8
|
const addSource = async () => {
|
|
@@ -61,36 +26,7 @@ const addSource = async () => {
|
|
|
61
26
|
return source;
|
|
62
27
|
};
|
|
63
28
|
|
|
64
|
-
|
|
65
|
-
* Resets the cached CloudEvents source.
|
|
66
|
-
*
|
|
67
|
-
* @internal
|
|
68
|
-
* @testonly This function is intended for test use only and will only work in test environments.
|
|
69
|
-
*
|
|
70
|
-
* @remarks
|
|
71
|
-
* This function clears the cached source value, forcing the next call to `createCloudEvent`
|
|
72
|
-
* to regenerate the source from app metadata. It only operates when NODE_ENV is set to "test"
|
|
73
|
-
* to prevent accidental misuse in production code.
|
|
74
|
-
*
|
|
75
|
-
* @example
|
|
76
|
-
* ```typescript
|
|
77
|
-
* // In Jest tests
|
|
78
|
-
* beforeEach(() => {
|
|
79
|
-
* resetCloudEventsSource();
|
|
80
|
-
* });
|
|
81
|
-
* ```
|
|
82
|
-
*/
|
|
83
|
-
export const resetCloudEventsSource = (): void => {
|
|
84
|
-
if (process.env.NODE_ENV === "test") {
|
|
85
|
-
source = null;
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
export const createCloudEvent = async <T = any>({
|
|
90
|
-
type,
|
|
91
|
-
subject,
|
|
92
|
-
data,
|
|
93
|
-
}: CreateCloudEventParams<T>): Promise<CloudEvent<T>> => {
|
|
29
|
+
export const createCloudEvent = async ({ type, subject, data }) => {
|
|
94
30
|
return {
|
|
95
31
|
specversion: "1.0",
|
|
96
32
|
type,
|
|
@@ -50,7 +50,7 @@ describe("getAllSpecificStyles", () => {
|
|
|
50
50
|
});
|
|
51
51
|
|
|
52
52
|
expect(outStyles).toHaveProperty("default");
|
|
53
|
-
expect(outStyles
|
|
53
|
+
expect(outStyles["default"]).toEqual({});
|
|
54
54
|
});
|
|
55
55
|
|
|
56
56
|
it("should handle empty configuration", () => {
|
|
@@ -83,7 +83,7 @@ describe("getAllSpecificStyles", () => {
|
|
|
83
83
|
outStyles,
|
|
84
84
|
});
|
|
85
85
|
|
|
86
|
-
expect(outStyles
|
|
86
|
+
expect(outStyles["default"]).toEqual({
|
|
87
87
|
backgroundColor: "#FF0000",
|
|
88
88
|
borderWidth: 2,
|
|
89
89
|
});
|
|
@@ -104,7 +104,7 @@ describe("getAllSpecificStyles", () => {
|
|
|
104
104
|
outStyles,
|
|
105
105
|
});
|
|
106
106
|
|
|
107
|
-
expect(outStyles
|
|
107
|
+
expect(outStyles["default"]).toEqual({
|
|
108
108
|
backgroundColor: "#FF0000",
|
|
109
109
|
textSize: 16,
|
|
110
110
|
});
|
|
@@ -126,7 +126,7 @@ describe("getAllSpecificStyles", () => {
|
|
|
126
126
|
outStyles,
|
|
127
127
|
});
|
|
128
128
|
|
|
129
|
-
expect(outStyles
|
|
129
|
+
expect(outStyles["default"]).toEqual({
|
|
130
130
|
backgroundColor: "#FF0000",
|
|
131
131
|
});
|
|
132
132
|
});
|
|
@@ -148,11 +148,11 @@ describe("getAllSpecificStyles", () => {
|
|
|
148
148
|
outStyles,
|
|
149
149
|
});
|
|
150
150
|
|
|
151
|
-
expect(outStyles
|
|
151
|
+
expect(outStyles["default"]).toEqual({
|
|
152
152
|
backgroundColor: "#FF0000",
|
|
153
153
|
});
|
|
154
154
|
|
|
155
|
-
expect(outStyles
|
|
155
|
+
expect(outStyles["pressed"]).toEqual({
|
|
156
156
|
backgroundColor: "#00FF00",
|
|
157
157
|
});
|
|
158
158
|
});
|
|
@@ -171,7 +171,7 @@ describe("getAllSpecificStyles", () => {
|
|
|
171
171
|
outStyles,
|
|
172
172
|
});
|
|
173
173
|
|
|
174
|
-
expect(outStyles
|
|
174
|
+
expect(outStyles["focused"]).toEqual({
|
|
175
175
|
borderWidth: 3,
|
|
176
176
|
});
|
|
177
177
|
});
|
|
@@ -190,7 +190,7 @@ describe("getAllSpecificStyles", () => {
|
|
|
190
190
|
outStyles,
|
|
191
191
|
});
|
|
192
192
|
|
|
193
|
-
expect(outStyles
|
|
193
|
+
expect(outStyles["selected"]).toEqual({
|
|
194
194
|
opacity: 0.5,
|
|
195
195
|
});
|
|
196
196
|
});
|
|
@@ -209,7 +209,7 @@ describe("getAllSpecificStyles", () => {
|
|
|
209
209
|
outStyles,
|
|
210
210
|
});
|
|
211
211
|
|
|
212
|
-
expect(outStyles
|
|
212
|
+
expect(outStyles["focused_selected"]).toEqual({
|
|
213
213
|
scale: 1.2,
|
|
214
214
|
});
|
|
215
215
|
});
|
|
@@ -232,21 +232,21 @@ describe("getAllSpecificStyles", () => {
|
|
|
232
232
|
outStyles,
|
|
233
233
|
});
|
|
234
234
|
|
|
235
|
-
expect(outStyles
|
|
235
|
+
expect(outStyles["default"]).toEqual({
|
|
236
236
|
backgroundColor: "#FF0000",
|
|
237
237
|
borderWidth: 1,
|
|
238
238
|
opacity: 1,
|
|
239
239
|
});
|
|
240
240
|
|
|
241
241
|
// Pressed should have default styles merged with its specific override
|
|
242
|
-
expect(outStyles
|
|
242
|
+
expect(outStyles["pressed"]).toEqual({
|
|
243
243
|
backgroundColor: "#00FF00", // Override
|
|
244
244
|
borderWidth: 1, // From default
|
|
245
245
|
opacity: 1, // From default
|
|
246
246
|
});
|
|
247
247
|
|
|
248
248
|
// Focused should have default styles merged with its specific override
|
|
249
|
-
expect(outStyles
|
|
249
|
+
expect(outStyles["focused"]).toEqual({
|
|
250
250
|
backgroundColor: "#FF0000", // From default
|
|
251
251
|
borderWidth: 1, // From default
|
|
252
252
|
opacity: 0.8, // Override
|
|
@@ -270,7 +270,7 @@ describe("getAllSpecificStyles", () => {
|
|
|
270
270
|
outStyles,
|
|
271
271
|
});
|
|
272
272
|
|
|
273
|
-
expect(outStyles
|
|
273
|
+
expect(outStyles["pressed"]).toEqual({
|
|
274
274
|
existingKey: "existingValue", // Should be preserved
|
|
275
275
|
backgroundColor: "#FF0000", // From default
|
|
276
276
|
textColor: "#FFFFFF", // New pressed style
|
|
@@ -294,7 +294,7 @@ describe("getAllSpecificStyles", () => {
|
|
|
294
294
|
outStyles,
|
|
295
295
|
});
|
|
296
296
|
|
|
297
|
-
expect(outStyles
|
|
297
|
+
expect(outStyles["default"]).toEqual({
|
|
298
298
|
backgroundColor: "#FF0000", // Samsung-specific should be included
|
|
299
299
|
});
|
|
300
300
|
});
|
|
@@ -317,7 +317,7 @@ describe("getAllSpecificStyles", () => {
|
|
|
317
317
|
outStyles,
|
|
318
318
|
});
|
|
319
319
|
|
|
320
|
-
expect(outStyles
|
|
320
|
+
expect(outStyles["default"]).toEqual({
|
|
321
321
|
backgroundColor: "#FFFFFF", // Only non-platform specific
|
|
322
322
|
});
|
|
323
323
|
});
|
|
@@ -336,7 +336,7 @@ describe("getAllSpecificStyles", () => {
|
|
|
336
336
|
outStyles,
|
|
337
337
|
});
|
|
338
338
|
|
|
339
|
-
expect(outStyles
|
|
339
|
+
expect(outStyles["default"]).toEqual({
|
|
340
340
|
color: "#FF0000",
|
|
341
341
|
});
|
|
342
342
|
});
|
|
@@ -356,7 +356,7 @@ describe("getAllSpecificStyles", () => {
|
|
|
356
356
|
outStyles,
|
|
357
357
|
});
|
|
358
358
|
|
|
359
|
-
expect(outStyles
|
|
359
|
+
expect(outStyles["pressed"]).toEqual({
|
|
360
360
|
backgroundColor: "#FF0000", // Only samsung style
|
|
361
361
|
});
|
|
362
362
|
});
|
|
@@ -377,7 +377,7 @@ describe("getAllSpecificStyles", () => {
|
|
|
377
377
|
outStyles,
|
|
378
378
|
});
|
|
379
379
|
|
|
380
|
-
expect(outStyles
|
|
380
|
+
expect(outStyles["default"]).toEqual({
|
|
381
381
|
backgroundColor: "#00FF00", // Samsung-specific should win
|
|
382
382
|
});
|
|
383
383
|
});
|
|
@@ -412,14 +412,14 @@ describe("getAllSpecificStyles", () => {
|
|
|
412
412
|
outStyles,
|
|
413
413
|
});
|
|
414
414
|
|
|
415
|
-
expect(outStyles
|
|
415
|
+
expect(outStyles["default"]).toEqual({
|
|
416
416
|
backgroundColor: "#FFFFFF",
|
|
417
417
|
textColor: "#000000",
|
|
418
418
|
borderWidth: 1,
|
|
419
419
|
padding: 10,
|
|
420
420
|
});
|
|
421
421
|
|
|
422
|
-
expect(outStyles
|
|
422
|
+
expect(outStyles["pressed"]).toEqual({
|
|
423
423
|
backgroundColor: "#EEEEEE",
|
|
424
424
|
textColor: "#000000",
|
|
425
425
|
borderWidth: 1,
|
|
@@ -427,7 +427,7 @@ describe("getAllSpecificStyles", () => {
|
|
|
427
427
|
opacity: 0.8,
|
|
428
428
|
});
|
|
429
429
|
|
|
430
|
-
expect(outStyles
|
|
430
|
+
expect(outStyles["focused"]).toEqual({
|
|
431
431
|
backgroundColor: "#FFFFFF",
|
|
432
432
|
textColor: "#000000",
|
|
433
433
|
borderWidth: 1,
|
|
@@ -453,7 +453,7 @@ describe("getAllSpecificStyles", () => {
|
|
|
453
453
|
outStyles,
|
|
454
454
|
});
|
|
455
455
|
|
|
456
|
-
expect(outStyles
|
|
456
|
+
expect(outStyles["default"]).toEqual({
|
|
457
457
|
validKey: "included",
|
|
458
458
|
});
|
|
459
459
|
});
|
|
@@ -474,11 +474,11 @@ describe("getAllSpecificStyles", () => {
|
|
|
474
474
|
outStyles,
|
|
475
475
|
});
|
|
476
476
|
|
|
477
|
-
expect(outStyles
|
|
477
|
+
expect(outStyles["focused_selected"]).toEqual({
|
|
478
478
|
test: "focused_selected_value",
|
|
479
479
|
});
|
|
480
480
|
|
|
481
|
-
expect(outStyles
|
|
481
|
+
expect(outStyles["focused"]).toEqual({
|
|
482
482
|
another: "focused_value",
|
|
483
483
|
});
|
|
484
484
|
});
|
|
@@ -517,7 +517,7 @@ describe("getAllSpecificStyles", () => {
|
|
|
517
517
|
outStyles,
|
|
518
518
|
});
|
|
519
519
|
|
|
520
|
-
expect(outStyles
|
|
520
|
+
expect(outStyles["pressed"]["backgroundColor"]).toBe("#222222");
|
|
521
521
|
});
|
|
522
522
|
|
|
523
523
|
it("should handle frozen outStyles properties", () => {
|
|
@@ -537,7 +537,7 @@ describe("getAllSpecificStyles", () => {
|
|
|
537
537
|
});
|
|
538
538
|
|
|
539
539
|
// Should create new object instead of mutating frozen one
|
|
540
|
-
expect(outStyles
|
|
540
|
+
expect(outStyles["default"]).toEqual({
|
|
541
541
|
existingProp: "value",
|
|
542
542
|
backgroundColor: "#FF0000",
|
|
543
543
|
});
|
package/dateUtils/index.ts
CHANGED
|
@@ -4,12 +4,14 @@ import timezone from "dayjs/plugin/timezone";
|
|
|
4
4
|
import isoWeek from "dayjs/plugin/isoWeek";
|
|
5
5
|
import duration from "dayjs/plugin/duration";
|
|
6
6
|
import relativeTime from "dayjs/plugin/relativeTime";
|
|
7
|
+
import customParseFormat from "dayjs/plugin/customParseFormat";
|
|
7
8
|
|
|
8
9
|
// Extend dayjs with plugins
|
|
9
10
|
dayjs.extend(utc);
|
|
10
11
|
dayjs.extend(timezone);
|
|
11
12
|
dayjs.extend(isoWeek);
|
|
12
13
|
dayjs.extend(duration);
|
|
14
|
+
dayjs.extend(customParseFormat);
|
|
13
15
|
|
|
14
16
|
dayjs.extend(relativeTime, {
|
|
15
17
|
thresholds: [
|