@applicaster/zapp-react-native-utils 12.0.0-rc.63 → 12.0.0-rc.64
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/appUtils/playerManager/usePlayerControllerSetup.tsx +6 -1
- package/package.json +2 -2
- package/reactHooks/cell-click/__tests__/index.test.js +5 -0
- package/reactHooks/cell-click/index.ts +2 -2
- package/reactHooks/navigation/__tests__/index.test.tsx +11 -8
- package/reactHooks/navigation/index.ts +17 -65
- package/reactHooks/screen/useScreenContext.ts +3 -2
|
@@ -4,6 +4,7 @@ import { useEffect } from "react";
|
|
|
4
4
|
import { playerManager } from "./index";
|
|
5
5
|
import { useValidatePlayerConfig } from "../../playerUtils/useValidatePlayerConfig";
|
|
6
6
|
import { PlayerRole } from "./conts";
|
|
7
|
+
import { isAppleTV } from "@applicaster/zapp-react-native-ui-components/Helpers/Platform";
|
|
7
8
|
|
|
8
9
|
// TODO: Rename to ControllerType
|
|
9
10
|
export const usePlayerControllerSetup = ({
|
|
@@ -34,10 +35,14 @@ export const usePlayerControllerSetup = ({
|
|
|
34
35
|
useValidatePlayerConfig(config);
|
|
35
36
|
|
|
36
37
|
useEffect(() => {
|
|
38
|
+
const newConfig = isAppleTV()
|
|
39
|
+
? { supports_native_controls: true, ...config }
|
|
40
|
+
: config;
|
|
41
|
+
|
|
37
42
|
const newPlayerController = new ControllerType({
|
|
38
43
|
player: ref,
|
|
39
44
|
listener: props as any,
|
|
40
|
-
config,
|
|
45
|
+
config: newConfig,
|
|
41
46
|
playerId,
|
|
42
47
|
entry,
|
|
43
48
|
playerPluginId: pluginId,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-utils",
|
|
3
|
-
"version": "12.0.0-rc.
|
|
3
|
+
"version": "12.0.0-rc.64",
|
|
4
4
|
"description": "Applicaster Zapp React Native utilities package",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@applicaster/applicaster-types": "12.0.0-rc.
|
|
31
|
+
"@applicaster/applicaster-types": "12.0.0-rc.64",
|
|
32
32
|
"buffer": "^5.2.1",
|
|
33
33
|
"camelize": "^1.0.0",
|
|
34
34
|
"create-react-context": "^0.2.3",
|
|
@@ -6,6 +6,7 @@ import { waitFor } from "@testing-library/react-native";
|
|
|
6
6
|
const navigator = {
|
|
7
7
|
getPathname: () => "pathnameMock",
|
|
8
8
|
push: jest.fn(),
|
|
9
|
+
data: {},
|
|
9
10
|
};
|
|
10
11
|
|
|
11
12
|
jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation", () => ({
|
|
@@ -28,6 +29,10 @@ jest.mock("@applicaster/zapp-react-native-ui-components/Contexts", () => ({
|
|
|
28
29
|
},
|
|
29
30
|
}));
|
|
30
31
|
|
|
32
|
+
jest.mock("@applicaster/zapp-react-native-utils/reactHooks/screen", () => ({
|
|
33
|
+
useScreenContext: jest.fn(() => navigator.data),
|
|
34
|
+
}));
|
|
35
|
+
|
|
31
36
|
const { useCellClick } = require("../");
|
|
32
37
|
|
|
33
38
|
const mockProps = {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="@applicaster/applicaster-types" />
|
|
2
2
|
|
|
3
3
|
import * as React from "react";
|
|
4
|
+
import { useContext } from "react";
|
|
4
5
|
import * as R from "ramda";
|
|
5
6
|
import { handleActionSchemeUrl } from "@applicaster/quick-brick-core/App/DeepLinking/URLSchemeHandler/SchemeHandlerHooks/useUrlSchemeHandler";
|
|
6
7
|
import { CellTapContext } from "@applicaster/zapp-react-native-ui-components/Contexts/CellTapContext";
|
|
@@ -12,7 +13,6 @@ import {
|
|
|
12
13
|
import { ZappPipesEntryContext } from "@applicaster/zapp-react-native-ui-components/Contexts";
|
|
13
14
|
import { toBooleanWithDefaultTrue } from "@applicaster/zapp-react-native-utils/booleanUtils";
|
|
14
15
|
import { noop } from "../../functionUtils";
|
|
15
|
-
import { useContext } from "react";
|
|
16
16
|
import { ActionExecutorContext } from "../../actionsExecutor/ActionExecutorContext";
|
|
17
17
|
import { useSendAnalyticsOnPress } from "../analytics";
|
|
18
18
|
import { logOnPress, warnEmptyContentType } from "./helpers";
|
|
@@ -83,7 +83,7 @@ export const useCellClick = (props: Props) => {
|
|
|
83
83
|
if (typeof onCellTap === "function") {
|
|
84
84
|
onCellTap(selectedItem, _index);
|
|
85
85
|
} else {
|
|
86
|
-
if (currentRoute === pathname || pathname
|
|
86
|
+
if (currentRoute === pathname || pathname.includes("video-modal")) {
|
|
87
87
|
const targetScreen = component?.data?.target;
|
|
88
88
|
|
|
89
89
|
push(
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { PathnameContext } from "@applicaster/zapp-react-native-ui-components/Contexts/PathnameContext";
|
|
3
3
|
import { renderHook } from "@testing-library/react-hooks";
|
|
4
|
-
import {
|
|
4
|
+
import { isNavBarVisible, useRoute } from "../";
|
|
5
5
|
import { Provider } from "react-redux";
|
|
6
6
|
import configureMockStore from "redux-mock-store";
|
|
7
7
|
import { NavigationContext } from "@applicaster/zapp-react-native-ui-components/Contexts/NavigationContext";
|
|
8
8
|
import { ZappHookModalContext } from "@applicaster/zapp-react-native-ui-components/Contexts";
|
|
9
9
|
import { ROUTE_TYPES } from "@applicaster/zapp-react-native-utils/navigationUtils/routeTypes";
|
|
10
|
+
import { ScreenDataContext } from "@applicaster/zapp-react-native-ui-components/Contexts/ScreenDataContext";
|
|
10
11
|
|
|
11
12
|
const plugins = [];
|
|
12
13
|
|
|
@@ -100,13 +101,15 @@ const mainStackWrapper = ({
|
|
|
100
101
|
pathname = homeStack.route,
|
|
101
102
|
}) => (
|
|
102
103
|
<Provider store={store}>
|
|
103
|
-
<
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
{
|
|
108
|
-
|
|
109
|
-
|
|
104
|
+
<ScreenDataContext.Provider value={homeStack.state}>
|
|
105
|
+
<NavigationContext.Provider
|
|
106
|
+
value={{ ...mainStackNavigator, ...navigator, currentRoute: pathname }}
|
|
107
|
+
>
|
|
108
|
+
<PathnameContext.Provider value={pathname}>
|
|
109
|
+
{children}
|
|
110
|
+
</PathnameContext.Provider>
|
|
111
|
+
</NavigationContext.Provider>
|
|
112
|
+
</ScreenDataContext.Provider>
|
|
110
113
|
</Provider>
|
|
111
114
|
);
|
|
112
115
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-use-before-define */
|
|
2
2
|
/* eslint max-len: off */
|
|
3
3
|
|
|
4
|
-
import React, { useEffect, useMemo } from "react";
|
|
4
|
+
import React, { useContext, useEffect, useMemo } from "react";
|
|
5
5
|
import { BackHandler, InteractionManager, NativeModules } from "react-native";
|
|
6
6
|
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
7
7
|
|
|
@@ -31,6 +31,7 @@ import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
|
31
31
|
import { useNavbarState } from "../screen";
|
|
32
32
|
import { useNavigation } from "./useNavigation";
|
|
33
33
|
import { useModalStore } from "../../modalState";
|
|
34
|
+
import { ScreenDataContext } from "@applicaster/zapp-react-native-ui-components/Contexts/ScreenDataContext";
|
|
34
35
|
|
|
35
36
|
export { useNavigation } from "./useNavigation";
|
|
36
37
|
|
|
@@ -146,16 +147,8 @@ export const useRoute = (): {
|
|
|
146
147
|
pathname: string;
|
|
147
148
|
} => {
|
|
148
149
|
const pathname = usePathname() || "";
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* compose `useRoute()` output data
|
|
152
|
-
*/
|
|
153
|
-
const composeRouteData = (screenData: VariousScreenData) => ({
|
|
154
|
-
screenData,
|
|
155
|
-
pathname,
|
|
156
|
-
});
|
|
157
|
-
|
|
158
150
|
const navigator = useNavigation();
|
|
151
|
+
const screenDataContext = legacyScreenData(useContext(ScreenDataContext));
|
|
159
152
|
|
|
160
153
|
const { plugins, contentTypes, rivers } = usePickFromState([
|
|
161
154
|
"plugins",
|
|
@@ -163,10 +156,11 @@ export const useRoute = (): {
|
|
|
163
156
|
"contentTypes",
|
|
164
157
|
]);
|
|
165
158
|
|
|
166
|
-
const currentStack = navigator.getStackForPathname(pathname);
|
|
167
159
|
const { modalState } = useModalStore();
|
|
168
160
|
const hookModalState = useZappHooksModalState();
|
|
161
|
+
|
|
169
162
|
const modalScreenData = modalState.screen;
|
|
163
|
+
|
|
170
164
|
const hookModalScreenData = hookModalState.state.screenData?.payload;
|
|
171
165
|
|
|
172
166
|
const videoModalScreenData =
|
|
@@ -183,15 +177,6 @@ export const useRoute = (): {
|
|
|
183
177
|
plugins
|
|
184
178
|
);
|
|
185
179
|
|
|
186
|
-
const currentRouteScreenData = legacyScreenData(
|
|
187
|
-
{
|
|
188
|
-
screen: currentStack?.state?.screen ?? navigator.data?.screen ?? {},
|
|
189
|
-
entry: currentStack?.state?.entry ?? {},
|
|
190
|
-
} as NavigationScreenData,
|
|
191
|
-
|
|
192
|
-
plugins
|
|
193
|
-
);
|
|
194
|
-
|
|
195
180
|
// There are 4 route scenarios
|
|
196
181
|
// For regular screens take date from navigator stack.
|
|
197
182
|
// is path is model grab screenData from modal state
|
|
@@ -200,63 +185,30 @@ export const useRoute = (): {
|
|
|
200
185
|
// if path is hook grab screenData from screenData
|
|
201
186
|
|
|
202
187
|
if (isModalPathname(pathname)) {
|
|
203
|
-
|
|
188
|
+
const screenData = modalScreenData ?? ({} as ZappEntry);
|
|
189
|
+
|
|
190
|
+
return { screenData, pathname };
|
|
204
191
|
}
|
|
205
192
|
|
|
206
193
|
if (isVideoModalPathname(pathname)) {
|
|
207
|
-
|
|
194
|
+
const screenData = videoModalScreenData as LegacyNavigationScreenData;
|
|
195
|
+
|
|
196
|
+
return { screenData, pathname };
|
|
208
197
|
}
|
|
209
198
|
|
|
210
199
|
if (isHookModalPathname(pathname)) {
|
|
211
|
-
|
|
200
|
+
const screenData = hookModalScreenData;
|
|
201
|
+
|
|
202
|
+
return { screenData, pathname };
|
|
212
203
|
}
|
|
213
204
|
|
|
214
205
|
if (isHookPathname(pathname)) {
|
|
215
|
-
|
|
216
|
-
* HACK
|
|
217
|
-
*
|
|
218
|
-
* This condition relies on hacky approach to get the current hook screen data
|
|
219
|
-
* using navigator.screenData for some cases.
|
|
220
|
-
* This is used when hook is in sequence.
|
|
221
|
-
*/
|
|
222
|
-
|
|
223
|
-
// case 1: stack not yet updated in navigator context, but navigator.screenData is updated already.
|
|
224
|
-
if (!currentStack) {
|
|
225
|
-
return composeRouteData(navigator.screenData);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
const isValidHookInCurrentRouteScreenData =
|
|
229
|
-
"hookPlugin" in currentRouteScreenData &&
|
|
230
|
-
!!currentRouteScreenData.hookPlugin?.module;
|
|
231
|
-
|
|
232
|
-
let screenData;
|
|
233
|
-
|
|
234
|
-
// case 2: stack has valid hook data
|
|
235
|
-
if (isValidHookInCurrentRouteScreenData) {
|
|
236
|
-
screenData = currentRouteScreenData;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
const navigatorScreenData = navigator.screenData as NavigatorEntry;
|
|
240
|
-
|
|
241
|
-
// case 3: current hookPlugin is missing weight, but navigator.screenData has weight, use navigator.screenData
|
|
242
|
-
if (
|
|
243
|
-
screenData.hookPlugin.identifier ===
|
|
244
|
-
navigatorScreenData?.hookPlugin?.identifier &&
|
|
245
|
-
!screenData.hookPlugin?.weight &&
|
|
246
|
-
navigatorScreenData?.hookPlugin?.weight
|
|
247
|
-
) {
|
|
248
|
-
screenData = navigator.screenData;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
return composeRouteData(screenData);
|
|
206
|
+
return { screenData: screenDataContext, pathname };
|
|
252
207
|
}
|
|
253
208
|
|
|
254
|
-
|
|
255
|
-
if (!currentStack) {
|
|
256
|
-
return composeRouteData(navigator.screenData);
|
|
257
|
-
}
|
|
209
|
+
const screenData = screenDataContext;
|
|
258
210
|
|
|
259
|
-
return
|
|
211
|
+
return { screenData, pathname };
|
|
260
212
|
};
|
|
261
213
|
|
|
262
214
|
type Callbacks = Partial<{
|
|
@@ -5,6 +5,7 @@ import { useNestedNavigationContext } from "@applicaster/zapp-react-native-ui-co
|
|
|
5
5
|
import { useNavigation } from "../navigation/useNavigation";
|
|
6
6
|
|
|
7
7
|
import { ScreenContext } from "@applicaster/zapp-react-native-ui-components/Contexts/ScreenContext";
|
|
8
|
+
import { ScreenDataContext } from "@applicaster/zapp-react-native-ui-components/Contexts/ScreenDataContext";
|
|
8
9
|
|
|
9
10
|
export function useScreenContextV2() {
|
|
10
11
|
return useContext(ScreenContext);
|
|
@@ -44,9 +45,9 @@ export function useSetNavbarState() {
|
|
|
44
45
|
|
|
45
46
|
export function useScreenContext(): NavigationScreenData {
|
|
46
47
|
const navigator = useNavigation();
|
|
48
|
+
// Cover cases where screenContext is used before navigation is initialized
|
|
49
|
+
const screenData = useContext(ScreenDataContext) || navigator.data;
|
|
47
50
|
|
|
48
|
-
const screenKey = useMemo(() => navigator?.key, [navigator]);
|
|
49
|
-
const screenData = useMemo(() => navigator?.data, [screenKey]);
|
|
50
51
|
const modalScreenData = navigator?.modalData;
|
|
51
52
|
|
|
52
53
|
const isModal = useModalNavigationContext();
|