@applicaster/quick-brick-core 15.0.0-rc.8 → 15.0.0-rc.80
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/App/ActionSetters/index.ts +5 -4
- package/App/ActionsProvider/ActionsProvider.tsx +6 -1
- package/App/DeepLinking/URLSchemeHandler/SchemeHandlerHooks/__tests__/useOpenSchemeHandler.test.tsx +12 -27
- package/App/DeepLinking/URLSchemeHandler/SchemeHandlerHooks/__tests__/useUrlSchemeHandler.test.tsx +197 -104
- package/App/DeepLinking/URLSchemeHandler/SchemeHandlerHooks/useOpenSchemeHandler/index.ts +4 -7
- package/App/DeepLinking/URLSchemeHandler/SchemeHandlerHooks/useUrlSchemeHandler.ts +42 -30
- package/App/DeepLinking/URLSchemeHandler/URLSchemeHandler.tsx +4 -1
- package/App/DeepLinking/URLSchemeHandler/__tests__/URLSchemeHandler.test.tsx +20 -13
- package/App/DeepLinking/URLSchemeListener/index.tsx +3 -4
- package/App/ErrorBoundary/__tests__/store.test.js +1 -1
- package/App/ModalProvider/ModalBottomSheet/ModalBottomSheetFrame.tsx +6 -1
- package/App/NavigationProvider/Loader.tsx +3 -4
- package/App/NavigationProvider/NavigationProvider.tsx +22 -35
- package/App/NavigationProvider/ScreenHooks/usePluginScreenHooks.ts +2 -2
- package/App/NavigationProvider/__tests__/navigationProvider.test.tsx +141 -152
- package/App/NavigationProvider/navigator/selectors.ts +21 -5
- package/App/NetworkStatusProvider/NetworkStatusProvider.tsx +2 -2
- package/App/NetworkStatusProvider/__tests__/NetworkStatusProvider.test.tsx +4 -4
- package/App/__tests__/createQuickBrickApp.test.js +1 -1
- package/App/appRemoteDataLoader/index.tsx +2 -2
- package/App/components/ZappAppWrapper.web.ts +2 -2
- package/App/remoteContextReloader/getRemoteContextData/getNativeRemoteContextData.ts +1 -1
- package/App/remoteContextReloader/helpers.ts +3 -3
- package/package.json +8 -8
- package/App/DeepLinking/URLSchemeHandler/__tests__/__snapshots__/URLSchemeHandler.test.tsx.snap +0 -24
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { StyleSheet } from "react-native";
|
|
3
|
+
import { cleanup } from "@testing-library/react-native";
|
|
4
|
+
import { renderWithProviders } from "@applicaster/zapp-react-native-utils/testUtils";
|
|
3
5
|
|
|
4
6
|
const theme = {
|
|
5
7
|
screen_margin_top: 0,
|
|
@@ -10,14 +12,6 @@ jest.mock(
|
|
|
10
12
|
"@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation"
|
|
11
13
|
);
|
|
12
14
|
|
|
13
|
-
jest.mock("@applicaster/zapp-react-native-utils/theme", () => ({
|
|
14
|
-
useTheme: jest.fn(() => theme),
|
|
15
|
-
}));
|
|
16
|
-
|
|
17
|
-
jest.mock("@applicaster/zapp-react-native-redux/hooks", () => ({
|
|
18
|
-
usePickFromState: jest.fn(() => ({})),
|
|
19
|
-
}));
|
|
20
|
-
|
|
21
15
|
const { URLSchemeHandler } = require("../URLSchemeHandler");
|
|
22
16
|
const schemeHooks = require("../SchemeHandlerHooks/useUrlSchemeHandler");
|
|
23
17
|
|
|
@@ -36,12 +30,25 @@ describe("URLSchemeHandler", () => {
|
|
|
36
30
|
|
|
37
31
|
afterEach(cleanup);
|
|
38
32
|
|
|
39
|
-
it("renders correctly and invokes the hook",
|
|
40
|
-
const wrapper =
|
|
41
|
-
|
|
33
|
+
it("renders correctly and invokes the hook", () => {
|
|
34
|
+
const wrapper = renderWithProviders(
|
|
35
|
+
<URLSchemeHandler url={url} onFinish={onFinish} />,
|
|
36
|
+
{},
|
|
37
|
+
theme
|
|
42
38
|
);
|
|
43
39
|
|
|
44
|
-
expect(wrapper.
|
|
40
|
+
expect(wrapper.getByTestId("URLSchemeHandler")).toBeTruthy();
|
|
41
|
+
|
|
42
|
+
expect(
|
|
43
|
+
StyleSheet.flatten(wrapper.getByTestId("URLSchemeHandler").props.style)
|
|
44
|
+
).toMatchObject({
|
|
45
|
+
alignItems: "center",
|
|
46
|
+
backgroundColor: "white",
|
|
47
|
+
flex: 1,
|
|
48
|
+
height: 1334,
|
|
49
|
+
justifyContent: "center",
|
|
50
|
+
width: 750,
|
|
51
|
+
});
|
|
45
52
|
|
|
46
53
|
expect(hookSpy).toHaveBeenCalledWith(
|
|
47
54
|
expect.objectContaining({ url, onFinish })
|
|
@@ -3,16 +3,15 @@ import React, { useCallback, useContext } from "react";
|
|
|
3
3
|
import { URLSchemeHandler } from "../URLSchemeHandler";
|
|
4
4
|
import { URLSchemeContext } from "./URLSchemeContextProvider";
|
|
5
5
|
import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
|
|
6
|
-
import {
|
|
6
|
+
import { useAppSelector } from "@applicaster/zapp-react-native-redux/hooks";
|
|
7
|
+
import { selectAppReady } from "@applicaster/zapp-react-native-redux";
|
|
7
8
|
|
|
8
9
|
export function URLSchemeListener({ children }: { children: React.ReactNode }) {
|
|
9
10
|
const { url, done } = useContext(URLSchemeContext);
|
|
10
11
|
|
|
11
12
|
const navigator = useNavigation();
|
|
12
13
|
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
const appReady = appState?.appReady;
|
|
14
|
+
const appReady = useAppSelector(selectAppReady);
|
|
16
15
|
|
|
17
16
|
const onFinish = useCallback(
|
|
18
17
|
(callback) => {
|
|
@@ -42,12 +42,17 @@ const defaultBottomOffset = platformSelect({
|
|
|
42
42
|
android: 0,
|
|
43
43
|
});
|
|
44
44
|
|
|
45
|
+
const SAFE_AREA_BREAKING_API_VERSION = 35;
|
|
46
|
+
|
|
45
47
|
const getSheetHeight = ({ height, bottomOffset, maxHeight }) => {
|
|
46
48
|
return platformSelect({
|
|
47
49
|
ios: height - bottomOffset,
|
|
48
50
|
default:
|
|
49
51
|
(height || maxHeight) -
|
|
50
|
-
(isAndroidPlatform() &&
|
|
52
|
+
(isAndroidPlatform() &&
|
|
53
|
+
!isAndroidVersionAtLeast(SAFE_AREA_BREAKING_API_VERSION)
|
|
54
|
+
? bottomOffset
|
|
55
|
+
: 0),
|
|
51
56
|
});
|
|
52
57
|
};
|
|
53
58
|
|
|
@@ -2,8 +2,9 @@ import React from "react";
|
|
|
2
2
|
import { View, StyleSheet } from "react-native";
|
|
3
3
|
|
|
4
4
|
import { Spinner } from "@applicaster/zapp-react-native-ui-components/Components/Spinner";
|
|
5
|
-
import {
|
|
5
|
+
import { useAppSelector } from "@applicaster/zapp-react-native-redux/hooks";
|
|
6
6
|
import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
|
|
7
|
+
import { selectAppLaunched } from "@applicaster/zapp-react-native-redux";
|
|
7
8
|
|
|
8
9
|
type Props = {
|
|
9
10
|
children: React.ReactChild;
|
|
@@ -21,9 +22,7 @@ const styles = StyleSheet.create({
|
|
|
21
22
|
});
|
|
22
23
|
|
|
23
24
|
export function Loader({ children }: Props) {
|
|
24
|
-
const
|
|
25
|
-
appState: { appLaunched },
|
|
26
|
-
} = usePickFromState(["appState"]);
|
|
25
|
+
const appLaunched = useAppSelector(selectAppLaunched);
|
|
27
26
|
|
|
28
27
|
const { currentRoute } = useNavigation();
|
|
29
28
|
|
|
@@ -13,10 +13,6 @@ import {
|
|
|
13
13
|
useGetScreenOrientation,
|
|
14
14
|
} from "@applicaster/zapp-react-native-utils/appUtils/orientationHelper";
|
|
15
15
|
import { focusManager } from "@applicaster/zapp-react-native-utils/focusManager/FocusManager";
|
|
16
|
-
import {
|
|
17
|
-
useContentTypes,
|
|
18
|
-
usePickFromState,
|
|
19
|
-
} from "@applicaster/zapp-react-native-redux/hooks";
|
|
20
16
|
|
|
21
17
|
import reducer, {
|
|
22
18
|
ACTIONS,
|
|
@@ -44,6 +40,7 @@ import {
|
|
|
44
40
|
activeRiverSelector,
|
|
45
41
|
homeRiverSelector,
|
|
46
42
|
lastEntrySelector,
|
|
43
|
+
startUpHookPluginIdentifiersSelector,
|
|
47
44
|
} from "./navigator/selectors";
|
|
48
45
|
|
|
49
46
|
import { coreAppLogger } from "../logger";
|
|
@@ -79,6 +76,16 @@ import { Hook } from "@applicaster/zapp-react-native-utils/appUtils/HooksManager
|
|
|
79
76
|
import { URLSchemeContext } from "../DeepLinking/URLSchemeListener/URLSchemeContextProvider";
|
|
80
77
|
|
|
81
78
|
import { loadingOverlayManager } from "../LoadingOverlay";
|
|
79
|
+
import {
|
|
80
|
+
selectAppLaunched,
|
|
81
|
+
useAppSelector,
|
|
82
|
+
useContentTypes,
|
|
83
|
+
usePlugins,
|
|
84
|
+
} from "@applicaster/zapp-react-native-redux";
|
|
85
|
+
import {
|
|
86
|
+
useLayoutVersion,
|
|
87
|
+
useRivers,
|
|
88
|
+
} from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
82
89
|
|
|
83
90
|
const logger = coreAppLogger.addSubsystem("Navigator");
|
|
84
91
|
|
|
@@ -100,22 +107,11 @@ const platform = getPlatform();
|
|
|
100
107
|
export function NavigationProvider({ children }: Props) {
|
|
101
108
|
const { url: deepLinkURL } = React.useContext(URLSchemeContext);
|
|
102
109
|
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
plugins,
|
|
107
|
-
pluginConfigurations,
|
|
108
|
-
appState: { appLaunched },
|
|
109
|
-
} = usePickFromState([
|
|
110
|
-
"appData",
|
|
111
|
-
"rivers",
|
|
112
|
-
"plugins",
|
|
113
|
-
"pluginConfigurations",
|
|
114
|
-
"appState",
|
|
115
|
-
"contentTypes",
|
|
116
|
-
]);
|
|
117
|
-
|
|
110
|
+
const appLaunched = useAppSelector(selectAppLaunched);
|
|
111
|
+
const layoutVersion = useLayoutVersion();
|
|
112
|
+
const rivers = useRivers();
|
|
118
113
|
const contentTypes = useContentTypes();
|
|
114
|
+
const plugins = usePlugins();
|
|
119
115
|
|
|
120
116
|
const [state, dispatch] = React.useReducer<
|
|
121
117
|
NavigationReducer,
|
|
@@ -227,6 +223,7 @@ export function NavigationProvider({ children }: Props) {
|
|
|
227
223
|
};
|
|
228
224
|
|
|
229
225
|
const isVideoModalDocked = () =>
|
|
226
|
+
state?.options.videoModal.visible &&
|
|
230
227
|
state?.options.videoModal.mode === "MINIMIZED";
|
|
231
228
|
|
|
232
229
|
// TODO: Remove as it's using a concept of "current" route.
|
|
@@ -477,21 +474,11 @@ export function NavigationProvider({ children }: Props) {
|
|
|
477
474
|
openLoadingOverlay();
|
|
478
475
|
};
|
|
479
476
|
|
|
480
|
-
const
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
const startUpHooksIdentifiers = R.compose(
|
|
484
|
-
R.map((item) => item.plugin.identifier),
|
|
485
|
-
R.filter(
|
|
486
|
-
R.allPass([
|
|
487
|
-
R.pathEq(["plugin", "api", "require_startup_execution"], true),
|
|
488
|
-
R.pathEq(["plugin", "react_native"], true),
|
|
489
|
-
R.pathEq(["plugin", "preload"], true),
|
|
490
|
-
])
|
|
491
|
-
),
|
|
492
|
-
R.values
|
|
493
|
-
)(pluginConfigurations);
|
|
477
|
+
const startUpHooksIdentifiers = useAppSelector(
|
|
478
|
+
startUpHookPluginIdentifiersSelector
|
|
479
|
+
);
|
|
494
480
|
|
|
481
|
+
const checkStartUpHooks = React.useMemo(() => {
|
|
495
482
|
if (startUpHooksIdentifiers?.length) {
|
|
496
483
|
const startUpHooks = R.filter(
|
|
497
484
|
(plugin) => R.includes(plugin.identifier, startUpHooksIdentifiers),
|
|
@@ -523,7 +510,7 @@ export function NavigationProvider({ children }: Props) {
|
|
|
523
510
|
}
|
|
524
511
|
|
|
525
512
|
return false;
|
|
526
|
-
}, [
|
|
513
|
+
}, [startUpHooksIdentifiers, plugins, rivers]);
|
|
527
514
|
|
|
528
515
|
const [startUpHooks, _setStartUpHooks] = React.useState(checkStartUpHooks);
|
|
529
516
|
const currentStartUpHooks = React.useRef(checkStartUpHooks);
|
|
@@ -726,7 +713,7 @@ export function NavigationProvider({ children }: Props) {
|
|
|
726
713
|
activeRiver,
|
|
727
714
|
getPathname: () => pathnameRef.current, // hack use to fix issue causing broken navigation as currentRoute is unreliable
|
|
728
715
|
currentRoute: pathname, // TODO: remove. Current route shouldn't be needed
|
|
729
|
-
previousAction: lastEntrySelector(state)
|
|
716
|
+
previousAction: (lastEntrySelector(state) as any)
|
|
730
717
|
?.action as QuickBrickNavigationActionType,
|
|
731
718
|
push: pushItem,
|
|
732
719
|
replace: replaceItem,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import * as R from "ramda";
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { usePlugins } from "@applicaster/zapp-react-native-redux";
|
|
5
5
|
|
|
6
6
|
enum ReactHooks {
|
|
7
7
|
useEffect = "useEffect",
|
|
@@ -39,7 +39,7 @@ function invokeScreenHook(hooksWrappers) {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
export function usePluginScreenHooks(pathname: string) {
|
|
42
|
-
const
|
|
42
|
+
const plugins = usePlugins();
|
|
43
43
|
|
|
44
44
|
const hooks = React.useMemo(
|
|
45
45
|
() => R.filter(hasScreenHook, plugins) || [],
|