@applicaster/quick-brick-core 15.0.0-rc.98 → 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/App/ActionSetters/index.ts +4 -5
- package/App/DeepLinking/URLSchemeHandler/SchemeHandlerHooks/__tests__/useOpenSchemeHandler.test.tsx +27 -12
- package/App/DeepLinking/URLSchemeHandler/SchemeHandlerHooks/__tests__/usePresentSchemeHandler.test.tsx +72 -35
- package/App/DeepLinking/URLSchemeHandler/SchemeHandlerHooks/__tests__/useUrlSchemeHandler.test.tsx +104 -197
- package/App/DeepLinking/URLSchemeHandler/SchemeHandlerHooks/useOpenSchemeHandler/index.ts +7 -4
- package/App/DeepLinking/URLSchemeHandler/SchemeHandlerHooks/usePresentSchemeHandler.ts +14 -12
- package/App/DeepLinking/URLSchemeHandler/SchemeHandlerHooks/useUrlSchemeHandler.ts +30 -42
- package/App/DeepLinking/URLSchemeHandler/URLSchemeHandler.tsx +1 -4
- package/App/DeepLinking/URLSchemeHandler/__tests__/URLSchemeHandler.test.tsx +13 -20
- package/App/DeepLinking/URLSchemeHandler/__tests__/__snapshots__/URLSchemeHandler.test.tsx.snap +24 -0
- package/App/DeepLinking/URLSchemeListener/URLSchemeContextProvider.tsx +59 -0
- package/App/DeepLinking/URLSchemeListener/index.tsx +4 -3
- package/App/DeepLinking/helpers/index.ts +3 -3
- package/App/ErrorBoundary/__tests__/store.test.js +1 -1
- package/App/NavigationProvider/Loader.tsx +4 -3
- package/App/NavigationProvider/NavigationProvider.tsx +42 -27
- package/App/NavigationProvider/ScreenHooks/usePluginScreenHooks.ts +2 -2
- package/App/NavigationProvider/__tests__/navigationProvider.test.tsx +152 -141
- package/App/NavigationProvider/navigator/selectors.ts +5 -21
- 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/remoteContextReloader/getRemoteContextData/getNativeRemoteContextData.ts +1 -1
- package/App/remoteContextReloader/helpers.ts +3 -3
- package/package.json +8 -8
|
@@ -101,26 +101,28 @@ export function usePresentSchemeHandler({
|
|
|
101
101
|
|
|
102
102
|
// @ts-ignore - to be fixed on iOS side
|
|
103
103
|
// key accountsAccountID should be accountsAccountId
|
|
104
|
-
const accountId = getKeyFromStorage
|
|
104
|
+
const accountId = getKeyFromStorage(accountKey, sessionData);
|
|
105
105
|
|
|
106
|
-
const appBundleIdentifier = getKeyFromStorage
|
|
106
|
+
const appBundleIdentifier = getKeyFromStorage(
|
|
107
107
|
"bundleIdentifier",
|
|
108
108
|
sessionData
|
|
109
109
|
);
|
|
110
110
|
|
|
111
|
-
const versionName = getKeyFromStorage
|
|
112
|
-
"version_name",
|
|
113
|
-
sessionData
|
|
114
|
-
);
|
|
111
|
+
const versionName = getKeyFromStorage("version_name", sessionData);
|
|
115
112
|
|
|
116
|
-
const familyId = getKeyFromStorage
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
113
|
+
const familyId = getKeyFromStorage("app_family_id", sessionData);
|
|
114
|
+
|
|
115
|
+
const storeKey = getKeyFromStorage("store", sessionData);
|
|
116
|
+
|
|
117
|
+
const WEB_STORE_PLATFORM: Record<string, string> = {
|
|
118
|
+
samsung: "samsung_app_store",
|
|
119
|
+
lg: "lg_content_store",
|
|
120
|
+
vizio: "vizio_app_store",
|
|
121
|
+
};
|
|
120
122
|
|
|
121
|
-
const
|
|
123
|
+
const cdnStoreKey = WEB_STORE_PLATFORM[storeKey] ?? storeKey;
|
|
122
124
|
|
|
123
|
-
const riversUrl = `https://assets-secure.applicaster.com/zapp/accounts/${accountId}/apps/${appBundleIdentifier}/${
|
|
125
|
+
const riversUrl = `https://assets-secure.applicaster.com/zapp/accounts/${accountId}/apps/${appBundleIdentifier}/${cdnStoreKey}/${versionName}/layouts/${rivers_configuration_id}.json`;
|
|
124
126
|
|
|
125
127
|
const cellStylesUrl = `https://assets-secure.applicaster.com/zapp/accounts/${accountId}/app_families/${familyId}/layouts/${rivers_configuration_id}/cell_styles.json`;
|
|
126
128
|
|
|
@@ -1,59 +1,55 @@
|
|
|
1
|
+
import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
|
|
1
2
|
import { appStore } from "@applicaster/zapp-react-native-redux/AppStore";
|
|
2
|
-
import
|
|
3
|
-
selectUrlSchemePlugins,
|
|
4
|
-
useAppSelector,
|
|
5
|
-
} from "@applicaster/zapp-react-native-redux";
|
|
3
|
+
import * as R from "ramda";
|
|
6
4
|
|
|
7
5
|
import { schemeHandlerHooks } from ".";
|
|
8
6
|
import { parseUrl } from "../../helpers";
|
|
7
|
+
|
|
9
8
|
import { log_warning } from "../../logger";
|
|
10
|
-
import { getPluginModuleUrlScheme } from "@applicaster/zapp-react-native-utils/pluginUtils";
|
|
11
9
|
|
|
12
10
|
type useUrlSchemeHandlerArgs = {
|
|
13
11
|
url: string;
|
|
14
12
|
onFinish: (callback: (done: () => void) => void) => void;
|
|
15
13
|
};
|
|
16
14
|
|
|
17
|
-
function resolveSchemeHandler(
|
|
18
|
-
host: string,
|
|
19
|
-
eligiblePlugins: QuickBrickPlugin[]
|
|
20
|
-
) {
|
|
21
|
-
// First check built-in scheme handlers
|
|
15
|
+
function resolveSchemeHandler(host, plugins) {
|
|
22
16
|
if (schemeHandlerHooks?.[host]) return schemeHandlerHooks?.[host];
|
|
23
17
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
);
|
|
18
|
+
const elligiblePlugins = R.filter(
|
|
19
|
+
R.hasPath(["module", "urlScheme"]),
|
|
20
|
+
plugins
|
|
21
|
+
);
|
|
29
22
|
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
if (elligiblePlugins?.length > 0) {
|
|
24
|
+
const match = R.compose(
|
|
25
|
+
R.prop("handler"),
|
|
26
|
+
R.head,
|
|
27
|
+
R.filter(R.propEq("host", host)),
|
|
28
|
+
R.map(R.path(["module", "urlScheme"]))
|
|
29
|
+
)(elligiblePlugins);
|
|
32
30
|
|
|
33
|
-
|
|
31
|
+
return match;
|
|
32
|
+
}
|
|
34
33
|
}
|
|
35
34
|
|
|
35
|
+
const skipSchemeHandle = ({ url }) => {
|
|
36
|
+
throw new Error(
|
|
37
|
+
`Non of the installed plugins knows how to handle this urlScheme ${url}`
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
|
|
36
41
|
export function useUrlSchemeHandler({
|
|
37
42
|
url,
|
|
38
43
|
onFinish,
|
|
39
44
|
}: useUrlSchemeHandlerArgs) {
|
|
40
45
|
const { host, query } = parseUrl(url);
|
|
41
|
-
const
|
|
46
|
+
const { plugins } = usePickFromState(["plugins"]);
|
|
42
47
|
|
|
43
|
-
const
|
|
48
|
+
const useSchemeHandler =
|
|
49
|
+
resolveSchemeHandler(host, plugins) || skipSchemeHandle;
|
|
44
50
|
|
|
45
51
|
try {
|
|
46
|
-
|
|
47
|
-
schemeHandler({ query, url, onFinish });
|
|
48
|
-
} else {
|
|
49
|
-
onFinish((done) => {
|
|
50
|
-
log_warning(
|
|
51
|
-
`unable to resolve ${url}: No handler found for scheme ${host}`
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
done?.();
|
|
55
|
-
});
|
|
56
|
-
}
|
|
52
|
+
useSchemeHandler({ query, url, onFinish });
|
|
57
53
|
} catch (e) {
|
|
58
54
|
onFinish((done) => {
|
|
59
55
|
log_warning(`unable to resolve ${url}: ${e.message}`);
|
|
@@ -62,19 +58,11 @@ export function useUrlSchemeHandler({
|
|
|
62
58
|
}
|
|
63
59
|
}
|
|
64
60
|
|
|
65
|
-
export function handleActionSchemeUrl({
|
|
66
|
-
url,
|
|
67
|
-
availablePlugins = appStore.get("plugins"),
|
|
68
|
-
}) {
|
|
61
|
+
export function handleActionSchemeUrl({ url }) {
|
|
69
62
|
const { host, query } = parseUrl(url);
|
|
63
|
+
const plugins = appStore.get("plugins");
|
|
70
64
|
|
|
71
|
-
const actionScheme = resolveSchemeHandler(host,
|
|
72
|
-
|
|
73
|
-
if (!actionScheme) {
|
|
74
|
-
throw new Error(
|
|
75
|
-
`Non of the installed plugins knows how to handle this urlScheme ${url}`
|
|
76
|
-
);
|
|
77
|
-
}
|
|
65
|
+
const actionScheme = resolveSchemeHandler(host, plugins) || skipSchemeHandle;
|
|
78
66
|
|
|
79
67
|
actionScheme({ query, url });
|
|
80
68
|
}
|
|
@@ -30,10 +30,7 @@ export function URLSchemeHandler({ url, onFinish }: Props) {
|
|
|
30
30
|
useUrlSchemeHandler({ url, onFinish });
|
|
31
31
|
|
|
32
32
|
return (
|
|
33
|
-
<View
|
|
34
|
-
testID="URLSchemeHandler"
|
|
35
|
-
style={[viewStyles.container, { width, height, backgroundColor }]}
|
|
36
|
-
>
|
|
33
|
+
<View style={[viewStyles.container, { width, height, backgroundColor }]}>
|
|
37
34
|
<Spinner size="large" />
|
|
38
35
|
</View>
|
|
39
36
|
);
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
import { cleanup } from "@testing-library/react-native";
|
|
4
|
-
import { renderWithProviders } from "@applicaster/zapp-react-native-utils/testUtils";
|
|
2
|
+
import { cleanup, render, waitFor } from "@testing-library/react-native";
|
|
5
3
|
|
|
6
4
|
const theme = {
|
|
7
5
|
screen_margin_top: 0,
|
|
@@ -12,6 +10,14 @@ jest.mock(
|
|
|
12
10
|
"@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation"
|
|
13
11
|
);
|
|
14
12
|
|
|
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
|
+
|
|
15
21
|
const { URLSchemeHandler } = require("../URLSchemeHandler");
|
|
16
22
|
const schemeHooks = require("../SchemeHandlerHooks/useUrlSchemeHandler");
|
|
17
23
|
|
|
@@ -30,25 +36,12 @@ describe("URLSchemeHandler", () => {
|
|
|
30
36
|
|
|
31
37
|
afterEach(cleanup);
|
|
32
38
|
|
|
33
|
-
it("renders correctly and invokes the hook", () => {
|
|
34
|
-
const wrapper =
|
|
35
|
-
<URLSchemeHandler url={url} onFinish={onFinish}
|
|
36
|
-
{},
|
|
37
|
-
theme
|
|
39
|
+
it("renders correctly and invokes the hook", async () => {
|
|
40
|
+
const wrapper = await waitFor(() =>
|
|
41
|
+
render(<URLSchemeHandler url={url} onFinish={onFinish} />)
|
|
38
42
|
);
|
|
39
43
|
|
|
40
|
-
expect(wrapper.
|
|
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
|
-
});
|
|
44
|
+
expect(wrapper.toJSON()).toMatchSnapshot();
|
|
52
45
|
|
|
53
46
|
expect(hookSpy).toHaveBeenCalledWith(
|
|
54
47
|
expect.objectContaining({ url, onFinish })
|
package/App/DeepLinking/URLSchemeHandler/__tests__/__snapshots__/URLSchemeHandler.test.tsx.snap
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`URLSchemeHandler renders correctly and invokes the hook 1`] = `
|
|
4
|
+
<View
|
|
5
|
+
style={
|
|
6
|
+
[
|
|
7
|
+
{
|
|
8
|
+
"alignItems": "center",
|
|
9
|
+
"flex": 1,
|
|
10
|
+
"justifyContent": "center",
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"backgroundColor": "white",
|
|
14
|
+
"height": 1334,
|
|
15
|
+
"width": 750,
|
|
16
|
+
},
|
|
17
|
+
]
|
|
18
|
+
}
|
|
19
|
+
>
|
|
20
|
+
<ActivityIndicator
|
|
21
|
+
size="large"
|
|
22
|
+
/>
|
|
23
|
+
</View>
|
|
24
|
+
`;
|
|
@@ -10,6 +10,7 @@ import * as ReactNative from "react-native";
|
|
|
10
10
|
|
|
11
11
|
import { isWeb } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
12
12
|
import { log_debug, log_error, log_info } from "../logger";
|
|
13
|
+
import { parseUrl } from "../helpers";
|
|
13
14
|
import { getAppUrlScheme } from "@applicaster/zapp-react-native-utils/appDataUtils";
|
|
14
15
|
import {
|
|
15
16
|
getZappPlatform,
|
|
@@ -47,6 +48,24 @@ const getWebDeepLink = (initialURL: string) => {
|
|
|
47
48
|
return getAppUrlScheme() + "://open" + initialURL.slice(index);
|
|
48
49
|
};
|
|
49
50
|
|
|
51
|
+
const getPresentDeepLink = (
|
|
52
|
+
initialURL: string | null | undefined
|
|
53
|
+
): string | null => {
|
|
54
|
+
if (!initialURL) return null;
|
|
55
|
+
|
|
56
|
+
const index = initialURL.indexOf("?");
|
|
57
|
+
if (index === -1) return null;
|
|
58
|
+
|
|
59
|
+
const { query } = parseUrl(initialURL);
|
|
60
|
+
if (!query?.rivers_configuration_id) return null;
|
|
61
|
+
|
|
62
|
+
return getAppUrlScheme() + "://present" + initialURL.slice(index);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export const triggerUrlScheme = (url: string): void => {
|
|
66
|
+
DeviceEventEmitter.emit("handleOpenUrl", { url });
|
|
67
|
+
};
|
|
68
|
+
|
|
50
69
|
function URLSchemeContextProvider(props: Props) {
|
|
51
70
|
const [state, setState] = useState<string | null>(initialState.url);
|
|
52
71
|
|
|
@@ -67,6 +86,16 @@ function URLSchemeContextProvider(props: Props) {
|
|
|
67
86
|
const url = await Linking.getInitialURL();
|
|
68
87
|
|
|
69
88
|
if (isWeb()) {
|
|
89
|
+
const presentDeepLink = getPresentDeepLink(url);
|
|
90
|
+
|
|
91
|
+
if (presentDeepLink) {
|
|
92
|
+
log_info(
|
|
93
|
+
`URLSchemeContextProvider: Retrieved initial deep link: ${presentDeepLink}`
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
return setState(presentDeepLink);
|
|
97
|
+
}
|
|
98
|
+
|
|
70
99
|
if (getZappPlatform() === ZappPlatform.Vizio) {
|
|
71
100
|
const deepLink = getWebDeepLink(url);
|
|
72
101
|
|
|
@@ -127,6 +156,36 @@ function URLSchemeContextProvider(props: Props) {
|
|
|
127
156
|
};
|
|
128
157
|
}
|
|
129
158
|
|
|
159
|
+
if (isWeb()) {
|
|
160
|
+
log_debug(
|
|
161
|
+
`URLSchemeContextProvider: Register DeviceEventEmitter "handleOpenUrl" listener — Platform.OS=${Platform.OS}`
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
const listener = DeviceEventEmitter.addListener(
|
|
165
|
+
"handleOpenUrl",
|
|
166
|
+
({ url: eventUrl }) => {
|
|
167
|
+
if (eventUrl) {
|
|
168
|
+
log_info(
|
|
169
|
+
`URLSchemeContextProvider: DeviceEventEmitter "handleOpenUrl" received — url=${eventUrl}`
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
setState(eventUrl);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
const linkingListener = Linking.addEventListener(
|
|
178
|
+
URL_EVENT_TYPE,
|
|
179
|
+
handleOpenURL
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
return () => {
|
|
183
|
+
log_debug("URLSchemeContextProvider: Remove URL event listeners");
|
|
184
|
+
listener.remove();
|
|
185
|
+
linkingListener.remove();
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
|
|
130
189
|
log_debug("URLSchemeContextProvider: Register URL event listener");
|
|
131
190
|
|
|
132
191
|
const listener = Linking.addEventListener(URL_EVENT_TYPE, handleOpenURL);
|
|
@@ -3,15 +3,16 @@ 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 {
|
|
7
|
-
import { selectAppReady } from "@applicaster/zapp-react-native-redux";
|
|
6
|
+
import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
|
|
8
7
|
|
|
9
8
|
export function URLSchemeListener({ children }: { children: React.ReactNode }) {
|
|
10
9
|
const { url, done } = useContext(URLSchemeContext);
|
|
11
10
|
|
|
12
11
|
const navigator = useNavigation();
|
|
13
12
|
|
|
14
|
-
const
|
|
13
|
+
const { appState } = usePickFromState(["appState"]);
|
|
14
|
+
|
|
15
|
+
const appReady = appState?.appReady;
|
|
15
16
|
|
|
16
17
|
const onFinish = useCallback(
|
|
17
18
|
(callback) => {
|
|
@@ -120,13 +120,13 @@ export function isInternalUrl(url = "") {
|
|
|
120
120
|
return query?.isInternalLink;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
export function getKeyFromStorage
|
|
123
|
+
export function getKeyFromStorage(
|
|
124
124
|
key: keyof SessionStorageKeys,
|
|
125
125
|
sessionData: Partial<SessionStorageKeys>
|
|
126
|
-
):
|
|
126
|
+
): string {
|
|
127
127
|
if (!sessionData[key]) {
|
|
128
128
|
throw new Error(`${key} is not available in session storage data`);
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
-
return
|
|
131
|
+
return String(sessionData[key]).replace(/"/g, "");
|
|
132
132
|
}
|
|
@@ -2,9 +2,8 @@ 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 { usePickFromState } 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";
|
|
8
7
|
|
|
9
8
|
type Props = {
|
|
10
9
|
children: React.ReactChild;
|
|
@@ -22,7 +21,9 @@ const styles = StyleSheet.create({
|
|
|
22
21
|
});
|
|
23
22
|
|
|
24
23
|
export function Loader({ children }: Props) {
|
|
25
|
-
const
|
|
24
|
+
const {
|
|
25
|
+
appState: { appLaunched },
|
|
26
|
+
} = usePickFromState(["appState"]);
|
|
26
27
|
|
|
27
28
|
const { currentRoute } = useNavigation();
|
|
28
29
|
|
|
@@ -7,12 +7,16 @@ import {
|
|
|
7
7
|
getTargetRoute,
|
|
8
8
|
usesVideoModal,
|
|
9
9
|
} from "@applicaster/zapp-react-native-utils/navigationUtils";
|
|
10
|
-
import { last } from "@applicaster/zapp-react-native-utils/utils";
|
|
10
|
+
import { clone, last } from "@applicaster/zapp-react-native-utils/utils";
|
|
11
11
|
import {
|
|
12
12
|
allowedOrientationsForScreen,
|
|
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";
|
|
16
20
|
|
|
17
21
|
import reducer, {
|
|
18
22
|
ACTIONS,
|
|
@@ -40,7 +44,6 @@ import {
|
|
|
40
44
|
activeRiverSelector,
|
|
41
45
|
homeRiverSelector,
|
|
42
46
|
lastEntrySelector,
|
|
43
|
-
startUpHookPluginIdentifiersSelector,
|
|
44
47
|
} from "./navigator/selectors";
|
|
45
48
|
|
|
46
49
|
import { coreAppLogger } from "../logger";
|
|
@@ -76,16 +79,6 @@ import { Hook } from "@applicaster/zapp-react-native-utils/appUtils/HooksManager
|
|
|
76
79
|
import { URLSchemeContext } from "../DeepLinking/URLSchemeListener/URLSchemeContextProvider";
|
|
77
80
|
|
|
78
81
|
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";
|
|
89
82
|
|
|
90
83
|
const logger = coreAppLogger.addSubsystem("Navigator");
|
|
91
84
|
|
|
@@ -107,11 +100,22 @@ const platform = getPlatform();
|
|
|
107
100
|
export function NavigationProvider({ children }: Props) {
|
|
108
101
|
const { url: deepLinkURL } = React.useContext(URLSchemeContext);
|
|
109
102
|
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
103
|
+
const {
|
|
104
|
+
appData: { layoutVersion },
|
|
105
|
+
rivers,
|
|
106
|
+
plugins,
|
|
107
|
+
pluginConfigurations,
|
|
108
|
+
appState: { appLaunched },
|
|
109
|
+
} = usePickFromState([
|
|
110
|
+
"appData",
|
|
111
|
+
"rivers",
|
|
112
|
+
"plugins",
|
|
113
|
+
"pluginConfigurations",
|
|
114
|
+
"appState",
|
|
115
|
+
"contentTypes",
|
|
116
|
+
]);
|
|
117
|
+
|
|
113
118
|
const contentTypes = useContentTypes();
|
|
114
|
-
const plugins = usePlugins();
|
|
115
119
|
|
|
116
120
|
const [state, dispatch] = React.useReducer<
|
|
117
121
|
NavigationReducer,
|
|
@@ -223,7 +227,6 @@ export function NavigationProvider({ children }: Props) {
|
|
|
223
227
|
};
|
|
224
228
|
|
|
225
229
|
const isVideoModalDocked = () =>
|
|
226
|
-
state?.options.videoModal.visible &&
|
|
227
230
|
state?.options.videoModal.mode === "MINIMIZED";
|
|
228
231
|
|
|
229
232
|
// TODO: Remove as it's using a concept of "current" route.
|
|
@@ -246,22 +249,24 @@ export function NavigationProvider({ children }: Props) {
|
|
|
246
249
|
const screen = rivers[screenId];
|
|
247
250
|
const parent = findParent(context, navigator.currentRoute);
|
|
248
251
|
|
|
252
|
+
const entryClone = clone(entry);
|
|
253
|
+
|
|
249
254
|
if (!screen) {
|
|
250
255
|
logger.warn({
|
|
251
256
|
message: `Cannot resolve type mapping for ${screenId} id`,
|
|
252
|
-
data: { entry, screenId },
|
|
257
|
+
data: { entry: entryClone, screenId },
|
|
253
258
|
});
|
|
254
259
|
|
|
255
260
|
return;
|
|
256
261
|
}
|
|
257
262
|
|
|
258
263
|
if (parent) {
|
|
259
|
-
|
|
264
|
+
entryClone.parent = parent?.data;
|
|
260
265
|
|
|
261
|
-
|
|
266
|
+
entryClone.parentId = parent?.id;
|
|
262
267
|
}
|
|
263
268
|
|
|
264
|
-
dispatch(setNestedContent(pathname,
|
|
269
|
+
dispatch(setNestedContent(pathname, entryClone, screen));
|
|
265
270
|
};
|
|
266
271
|
|
|
267
272
|
const pushItem = (item, options = {}) => {
|
|
@@ -474,11 +479,21 @@ export function NavigationProvider({ children }: Props) {
|
|
|
474
479
|
openLoadingOverlay();
|
|
475
480
|
};
|
|
476
481
|
|
|
477
|
-
const startUpHooksIdentifiers = useAppSelector(
|
|
478
|
-
startUpHookPluginIdentifiersSelector
|
|
479
|
-
);
|
|
480
|
-
|
|
481
482
|
const checkStartUpHooks = React.useMemo(() => {
|
|
483
|
+
if (!pluginConfigurations) return false;
|
|
484
|
+
|
|
485
|
+
const startUpHooksIdentifiers = R.compose(
|
|
486
|
+
R.map((item) => item.plugin.identifier),
|
|
487
|
+
R.filter(
|
|
488
|
+
R.allPass([
|
|
489
|
+
R.pathEq(["plugin", "api", "require_startup_execution"], true),
|
|
490
|
+
R.pathEq(["plugin", "react_native"], true),
|
|
491
|
+
R.pathEq(["plugin", "preload"], true),
|
|
492
|
+
])
|
|
493
|
+
),
|
|
494
|
+
R.values
|
|
495
|
+
)(pluginConfigurations);
|
|
496
|
+
|
|
482
497
|
if (startUpHooksIdentifiers?.length) {
|
|
483
498
|
const startUpHooks = R.filter(
|
|
484
499
|
(plugin) => R.includes(plugin.identifier, startUpHooksIdentifiers),
|
|
@@ -510,7 +525,7 @@ export function NavigationProvider({ children }: Props) {
|
|
|
510
525
|
}
|
|
511
526
|
|
|
512
527
|
return false;
|
|
513
|
-
}, [
|
|
528
|
+
}, [pluginConfigurations, plugins, rivers]);
|
|
514
529
|
|
|
515
530
|
const [startUpHooks, _setStartUpHooks] = React.useState(checkStartUpHooks);
|
|
516
531
|
const currentStartUpHooks = React.useRef(checkStartUpHooks);
|
|
@@ -713,7 +728,7 @@ export function NavigationProvider({ children }: Props) {
|
|
|
713
728
|
activeRiver,
|
|
714
729
|
getPathname: () => pathnameRef.current, // hack use to fix issue causing broken navigation as currentRoute is unreliable
|
|
715
730
|
currentRoute: pathname, // TODO: remove. Current route shouldn't be needed
|
|
716
|
-
previousAction:
|
|
731
|
+
previousAction: lastEntrySelector(state)
|
|
717
732
|
?.action as QuickBrickNavigationActionType,
|
|
718
733
|
push: pushItem,
|
|
719
734
|
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 { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
|
|
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 plugins =
|
|
42
|
+
const { plugins } = usePickFromState(["plugins"]);
|
|
43
43
|
|
|
44
44
|
const hooks = React.useMemo(
|
|
45
45
|
() => R.filter(hasScreenHook, plugins) || [],
|