@applicaster/quick-brick-core 15.1.0-rc.9 → 16.0.0-alpha.1833861900

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.
Files changed (22) hide show
  1. package/App/ActionSetters/index.ts +5 -4
  2. package/App/DeepLinking/URLSchemeHandler/SchemeHandlerHooks/__tests__/useOpenSchemeHandler.test.tsx +12 -27
  3. package/App/DeepLinking/URLSchemeHandler/SchemeHandlerHooks/__tests__/useUrlSchemeHandler.test.tsx +197 -104
  4. package/App/DeepLinking/URLSchemeHandler/SchemeHandlerHooks/useOpenSchemeHandler/index.ts +4 -7
  5. package/App/DeepLinking/URLSchemeHandler/SchemeHandlerHooks/useUrlSchemeHandler.ts +42 -30
  6. package/App/DeepLinking/URLSchemeHandler/URLSchemeHandler.tsx +4 -1
  7. package/App/DeepLinking/URLSchemeHandler/__tests__/URLSchemeHandler.test.tsx +20 -13
  8. package/App/DeepLinking/URLSchemeListener/index.tsx +3 -4
  9. package/App/ErrorBoundary/__tests__/store.test.js +1 -1
  10. package/App/NavigationProvider/Loader.tsx +3 -4
  11. package/App/NavigationProvider/NavigationProvider.tsx +22 -35
  12. package/App/NavigationProvider/ScreenHooks/usePluginScreenHooks.ts +2 -2
  13. package/App/NavigationProvider/__tests__/navigationProvider.test.tsx +193 -152
  14. package/App/NavigationProvider/navigator/selectors.ts +21 -5
  15. package/App/NetworkStatusProvider/NetworkStatusProvider.tsx +2 -2
  16. package/App/NetworkStatusProvider/__tests__/NetworkStatusProvider.test.tsx +4 -4
  17. package/App/__tests__/createQuickBrickApp.test.js +1 -1
  18. package/App/appRemoteDataLoader/index.tsx +2 -2
  19. package/App/remoteContextReloader/getRemoteContextData/getNativeRemoteContextData.ts +1 -1
  20. package/App/remoteContextReloader/helpers.ts +3 -3
  21. package/package.json +8 -8
  22. package/App/DeepLinking/URLSchemeHandler/__tests__/__snapshots__/URLSchemeHandler.test.tsx.snap +0 -24
@@ -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 { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
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 { appState } = usePickFromState(["appState"]);
14
-
15
- const appReady = appState?.appReady;
14
+ const appReady = useAppSelector(selectAppReady);
16
15
 
17
16
  const onFinish = useCallback(
18
17
  (callback) => {
@@ -1,4 +1,4 @@
1
- import { act, renderHook } from "@testing-library/react-hooks";
1
+ import { act, renderHook } from "@testing-library/react-native";
2
2
  import { useErrorStore } from "../store";
3
3
 
4
4
  describe("Error Store", () => {
@@ -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 { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
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
- 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
-
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.
@@ -485,21 +482,11 @@ export function NavigationProvider({ children }: Props) {
485
482
  openLoadingOverlay();
486
483
  };
487
484
 
488
- const checkStartUpHooks = React.useMemo(() => {
489
- if (!pluginConfigurations) return false;
490
-
491
- const startUpHooksIdentifiers = R.compose(
492
- R.map((item) => item.plugin.identifier),
493
- R.filter(
494
- R.allPass([
495
- R.pathEq(["plugin", "api", "require_startup_execution"], true),
496
- R.pathEq(["plugin", "react_native"], true),
497
- R.pathEq(["plugin", "preload"], true),
498
- ])
499
- ),
500
- R.values
501
- )(pluginConfigurations);
485
+ const startUpHooksIdentifiers = useAppSelector(
486
+ startUpHookPluginIdentifiersSelector
487
+ );
502
488
 
489
+ const checkStartUpHooks = React.useMemo(() => {
503
490
  if (startUpHooksIdentifiers?.length) {
504
491
  const startUpHooks = R.filter(
505
492
  (plugin) => R.includes(plugin.identifier, startUpHooksIdentifiers),
@@ -531,7 +518,7 @@ export function NavigationProvider({ children }: Props) {
531
518
  }
532
519
 
533
520
  return false;
534
- }, [pluginConfigurations, plugins, rivers]);
521
+ }, [startUpHooksIdentifiers, plugins, rivers]);
535
522
 
536
523
  const [startUpHooks, _setStartUpHooks] = React.useState(checkStartUpHooks);
537
524
  const currentStartUpHooks = React.useRef(checkStartUpHooks);
@@ -734,7 +721,7 @@ export function NavigationProvider({ children }: Props) {
734
721
  activeRiver,
735
722
  getPathname: () => pathnameRef.current, // hack use to fix issue causing broken navigation as currentRoute is unreliable
736
723
  currentRoute: pathname, // TODO: remove. Current route shouldn't be needed
737
- previousAction: lastEntrySelector(state)
724
+ previousAction: (lastEntrySelector(state) as any)
738
725
  ?.action as QuickBrickNavigationActionType,
739
726
  push: pushItem,
740
727
  replace: replaceItem,
@@ -1,7 +1,7 @@
1
1
  import * as React from "react";
2
2
  import * as R from "ramda";
3
3
 
4
- import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
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 { plugins } = usePickFromState(["plugins"]);
42
+ const plugins = usePlugins();
43
43
 
44
44
  const hooks = React.useMemo(
45
45
  () => R.filter(hasScreenHook, plugins) || [],