@applicaster/quick-brick-core 16.0.0-alpha.1052711356 → 16.0.0-alpha.1054344748

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 (31) hide show
  1. package/App/ActionsProvider/LegacyActionsRegistryAdapter.tsx +16 -0
  2. package/App/ActionsProvider/__tests__/LegacyActionsRegistryAdapter.test.tsx +64 -0
  3. package/App/DeepLinking/URLSchemeHandler/SchemeHandlerHooks/__tests__/useOpenSchemeHandler.test.tsx +25 -15
  4. package/App/ModalProvider/ModalBottomSheet/ModalBottomSheetFrame.tsx +3 -4
  5. package/App/ModalProvider/ModalBottomSheet/index.tsx +5 -2
  6. package/App/ModalProvider/ModalContent.tsx +3 -0
  7. package/App/ModalProvider/__tests__/ModalContent.test.tsx +39 -0
  8. package/App/ModalProvider/__tests__/index.test.tsx +99 -0
  9. package/App/ModalProvider/index.tsx +39 -14
  10. package/App/NavigationProvider/NavigationProvider.tsx +57 -5
  11. package/App/NavigationProvider/__tests__/navigationProvider.test.tsx +56 -0
  12. package/App/NavigationProvider/__tests__/utils.test.ts +31 -1
  13. package/App/NavigationProvider/utils.ts +14 -0
  14. package/App/NetworkStatusProvider/NetworkStatusProvider.tsx +32 -4
  15. package/App/NetworkStatusProvider/ResumeVerificationController.ts +282 -0
  16. package/App/NetworkStatusProvider/__tests__/NetworkStatusProvider.test.tsx +152 -1
  17. package/App/NetworkStatusProvider/__tests__/ResumeVerificationController.test.ts +471 -0
  18. package/App/NetworkStatusProvider/__tests__/resumeVerification.test.ts +126 -0
  19. package/App/NetworkStatusProvider/__tests__/useResumeVerifiedNetInfo.test.ts +189 -0
  20. package/App/NetworkStatusProvider/resumeVerification.ts +54 -0
  21. package/App/NetworkStatusProvider/useResumeVerifiedNetInfo.ts +33 -0
  22. package/App/NotificationToastRenderer/NotificationToastManager.ts +5 -0
  23. package/App/NotificationToastRenderer/NotificationToastRenderer.tsx +56 -24
  24. package/App/NotificationToastRenderer/NotificationToastRenderer.tv.tsx +10 -0
  25. package/App/NotificationToastRenderer/__tests__/NotificationToastRenderer.test.tsx +151 -3
  26. package/App/NotificationToastRenderer/__tests__/resolveConfirmationToastStyle.test.ts +118 -0
  27. package/App/NotificationToastRenderer/__tests__/useNotificationHeight.test.tsx +16 -11
  28. package/App/NotificationToastRenderer/index.tsx +5 -1
  29. package/App/NotificationToastRenderer/resolveConfirmationToastStyle.ts +33 -0
  30. package/App/NotificationToastRenderer/useNotificationHeight.tsx +3 -3
  31. package/package.json +8 -8
@@ -66,6 +66,22 @@ function LegacyActionBridge({ plugin }: { plugin: LegacyActionPlugin }) {
66
66
  };
67
67
  }, [plugin.identifier]);
68
68
 
69
+ // Consumers resolve a snapshot of `value`; when the plugin publishes a new
70
+ // one (e.g. cast devices found), make them re-resolve so availability
71
+ // predicates are not read from a stale value. Registration already
72
+ // notifies, so the first render is skipped.
73
+ const isFirstValueRef = React.useRef(true);
74
+
75
+ React.useEffect(() => {
76
+ if (isFirstValueRef.current) {
77
+ isFirstValueRef.current = false;
78
+
79
+ return;
80
+ }
81
+
82
+ uiActionsRegistry.notifyProviderChanged(plugin.identifier);
83
+ }, [value, plugin.identifier]);
84
+
69
85
  return null;
70
86
  }
71
87
 
@@ -0,0 +1,64 @@
1
+ import React from "react";
2
+ import { render } from "@testing-library/react-native";
3
+ import { uiActionsRegistry } from "@applicaster/zapp-react-native-utils/uiActionsRegistrator";
4
+ import { LegacyActionsRegistryAdapter } from "../LegacyActionsRegistryAdapter";
5
+
6
+ const CastContext = React.createContext<any>(null);
7
+
8
+ const plugin = {
9
+ identifier: "cast-action-test",
10
+ module: { context: CastContext },
11
+ };
12
+
13
+ const renderWithValue = (value) => (
14
+ <CastContext.Provider value={value}>
15
+ <LegacyActionsRegistryAdapter actionPlugins={{ cast: plugin } as any} />
16
+ </CastContext.Provider>
17
+ );
18
+
19
+ describe("LegacyActionsRegistryAdapter", () => {
20
+ it("makes consumers re-resolve when the plugin publishes a new value", () => {
21
+ const noDevices = { isActionAvailable: () => false };
22
+ const devicesFound = { isActionAvailable: () => true };
23
+
24
+ const { rerender, unmount } = render(renderWithValue(noDevices));
25
+
26
+ // what a consumer resolved at first paint
27
+ expect(
28
+ uiActionsRegistry
29
+ .getAction("cast-action-test")
30
+ ?.isActionAvailable?.({} as any)
31
+ ).toBe(false);
32
+
33
+ const listener = jest.fn();
34
+ const unsubscribe = uiActionsRegistry.subscribe(listener);
35
+
36
+ rerender(renderWithValue(devicesFound));
37
+
38
+ expect(listener).toHaveBeenCalledTimes(1);
39
+
40
+ expect(
41
+ uiActionsRegistry
42
+ .getAction("cast-action-test")
43
+ ?.isActionAvailable?.({} as any)
44
+ ).toBe(true);
45
+
46
+ unsubscribe();
47
+ unmount();
48
+ });
49
+
50
+ it("does not notify again when the value is unchanged", () => {
51
+ const stable = { isActionAvailable: () => true };
52
+ const { rerender, unmount } = render(renderWithValue(stable));
53
+
54
+ const listener = jest.fn();
55
+ const unsubscribe = uiActionsRegistry.subscribe(listener);
56
+
57
+ rerender(renderWithValue(stable));
58
+
59
+ expect(listener).not.toHaveBeenCalled();
60
+
61
+ unsubscribe();
62
+ unmount();
63
+ });
64
+ });
@@ -60,11 +60,21 @@ jest.spyOn(useNavigationHooks, "useNavigation").mockReturnValue(navigator);
60
60
  const helperSpy = jest.spyOn(helpers, "handlePresentNavigation");
61
61
  const feedLoaderSpy = jest.spyOn(feedLoader, "useFeedLoader");
62
62
 
63
- const setEntryContext = jest.fn();
64
-
65
- jest.doMock("@applicaster/zapp-react-native-ui-components/Contexts", () => ({
63
+ const mockSetEntryContext = jest.fn();
64
+
65
+ // `jest.mock` is hoisted above the imports, so the entry context is replaced
66
+ // before anything can pull the real one in. `jest.doMock` is not hoisted, and
67
+ // only worked here for as long as no import above happened to load this module
68
+ // first - which any new import anywhere in the graph could silently undo,
69
+ // leaving the hook writing to the real context while the spy stayed at zero
70
+ // calls. The rest of the module is kept, since other consumers loaded by this
71
+ // graph read other exports from it.
72
+ jest.mock("@applicaster/zapp-react-native-ui-components/Contexts", () => ({
73
+ ...jest.requireActual(
74
+ "@applicaster/zapp-react-native-ui-components/Contexts"
75
+ ),
66
76
  ZappPipesEntryContext: {
67
- useZappPipesContext: () => [{}, setEntryContext],
77
+ useZappPipesContext: () => [{}, mockSetEntryContext],
68
78
  },
69
79
  }));
70
80
 
@@ -76,7 +86,7 @@ jest.mock("../../../logger", () => ({
76
86
  log_debug: jest.fn(),
77
87
  }));
78
88
 
79
- // to use import instead of require it's required to use jest.mock above
89
+ // Required after the mocks above, so the hook binds to them.
80
90
  const { useOpenSchemeHandler } = require("../useOpenSchemeHandler");
81
91
 
82
92
  const mockStoreObj = { rivers, contentTypes, pipesEndpoints, appData };
@@ -101,7 +111,7 @@ function clearMocks() {
101
111
  navigator.replace.mockClear();
102
112
  navigator.push.mockClear();
103
113
  navigator.goHome.mockClear();
104
- setEntryContext.mockClear();
114
+ mockSetEntryContext.mockClear();
105
115
  }
106
116
 
107
117
  describe("useOpenSchemeHandler", () => {
@@ -215,7 +225,7 @@ describe("useOpenSchemeHandler", () => {
215
225
  })
216
226
  );
217
227
 
218
- expect(setEntryContext).toHaveBeenCalledWith(
228
+ expect(mockSetEntryContext).toHaveBeenCalledWith(
219
229
  expect.objectContaining({
220
230
  ...params,
221
231
  extensions: { ...params, initial_player_state: "fullscreen" },
@@ -272,7 +282,7 @@ describe("useOpenSchemeHandler", () => {
272
282
  })
273
283
  );
274
284
 
275
- expect(setEntryContext).toHaveBeenCalledWith(
285
+ expect(mockSetEntryContext).toHaveBeenCalledWith(
276
286
  expect.objectContaining({
277
287
  ...params,
278
288
  extensions: { ...params, initial_player_state: "fullscreen" },
@@ -331,7 +341,7 @@ describe("useOpenSchemeHandler", () => {
331
341
  })
332
342
  );
333
343
 
334
- expect(setEntryContext).toHaveBeenCalledWith(
344
+ expect(mockSetEntryContext).toHaveBeenCalledWith(
335
345
  entryWithInitialPlayerState
336
346
  );
337
347
  };
@@ -361,7 +371,7 @@ describe("useOpenSchemeHandler", () => {
361
371
  })
362
372
  );
363
373
 
364
- expect(setEntryContext).toHaveBeenCalledWith(
374
+ expect(mockSetEntryContext).toHaveBeenCalledWith(
365
375
  entryWithInitialPlayerState
366
376
  );
367
377
  };
@@ -391,7 +401,7 @@ describe("useOpenSchemeHandler", () => {
391
401
  })
392
402
  );
393
403
 
394
- expect(setEntryContext).toHaveBeenCalledWith(
404
+ expect(mockSetEntryContext).toHaveBeenCalledWith(
395
405
  entryWithInitialPlayerState
396
406
  );
397
407
  };
@@ -421,7 +431,7 @@ describe("useOpenSchemeHandler", () => {
421
431
  })
422
432
  );
423
433
 
424
- expect(setEntryContext).toHaveBeenCalledWith(
434
+ expect(mockSetEntryContext).toHaveBeenCalledWith(
425
435
  entryWithInitialPlayerState
426
436
  );
427
437
  };
@@ -451,7 +461,7 @@ describe("useOpenSchemeHandler", () => {
451
461
  })
452
462
  );
453
463
 
454
- expect(setEntryContext).toHaveBeenCalledWith(
464
+ expect(mockSetEntryContext).toHaveBeenCalledWith(
455
465
  entryWithInitialPlayerState
456
466
  );
457
467
  };
@@ -485,7 +495,7 @@ describe("useOpenSchemeHandler", () => {
485
495
  })
486
496
  );
487
497
 
488
- expect(setEntryContext).toHaveBeenCalledWith(
498
+ expect(mockSetEntryContext).toHaveBeenCalledWith(
489
499
  expect.objectContaining(entryWithInitialPlayerState)
490
500
  );
491
501
  };
@@ -514,7 +524,7 @@ describe("useOpenSchemeHandler", () => {
514
524
  );
515
525
 
516
526
  expect(navigator.goHome).toHaveBeenCalled();
517
- expect(setEntryContext).not.toHaveBeenCalled();
527
+ expect(mockSetEntryContext).not.toHaveBeenCalled();
518
528
  };
519
529
 
520
530
  await testHook({
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { LayoutChangeEvent, Platform, StyleSheet, View } from "react-native";
2
+ import { LayoutChangeEvent, StyleSheet, View } from "react-native";
3
3
 
4
4
  import { Handle, HandleProps } from "./Handle";
5
5
  import { DraggableBottomSheet } from "./DraggableBottomSheet";
@@ -11,6 +11,7 @@ import {
11
11
  import {
12
12
  isAndroidPlatform,
13
13
  isAndroidVersionAtLeast,
14
+ isApplePlatform,
14
15
  platformSelect,
15
16
  } from "@applicaster/zapp-react-native-utils/reactUtils";
16
17
 
@@ -118,9 +119,7 @@ export function ModalBottomSheetFrame(props: Props) {
118
119
  maxWidth={maxWidth}
119
120
  {...dimensions}
120
121
  height={
121
- safeAreaDims.height -
122
- (Platform.OS === "ios" ? bottom : 0) -
123
- keyboardHeight
122
+ safeAreaDims.height - (isApplePlatform() ? bottom : 0) - keyboardHeight
124
123
  }
125
124
  >
126
125
  <SafeAreaView
@@ -47,9 +47,11 @@ export function ModalBottomSheet(props: Props) {
47
47
 
48
48
  const {
49
49
  ModalBottomSheetContent = ModalComponent,
50
- modalBottomSheetContentProps,
50
+ modalBottomSheetContentProps = {},
51
51
  } = props;
52
52
 
53
+ const { key, ...restContentProps } = modalBottomSheetContentProps;
54
+
53
55
  useEffect(() => {
54
56
  Keyboard.dismiss();
55
57
  }, []);
@@ -82,11 +84,12 @@ export function ModalBottomSheet(props: Props) {
82
84
  }}
83
85
  >
84
86
  <ModalBottomSheetContent
87
+ key={key as any}
85
88
  width={
86
89
  Math.min(sheetTabletMaxWidth, dimensions.width) || dimensions.width
87
90
  }
88
91
  maxHeight={sheetMaxHeight}
89
- {...modalBottomSheetContentProps}
92
+ {...restContentProps}
90
93
  dismiss={dismiss}
91
94
  currentRoute={navigator.currentRoute}
92
95
  />
@@ -30,6 +30,9 @@ export function ModalContent(props: Props) {
30
30
  }
31
31
 
32
32
  return (
33
+ // A presented screen fills the window, including the status bar and home
34
+ // indicator. The modal wraps it in its own SafeAreaProvider, so the screen
35
+ // reads the real insets itself and places its own chrome inside them.
33
36
  <View style={styles.container}>
34
37
  <ScreenResolver {...modalScreenProps} />
35
38
  </View>
@@ -0,0 +1,39 @@
1
+ import React from "react";
2
+ import { StyleSheet } from "react-native";
3
+ import { render } from "@testing-library/react-native";
4
+
5
+ import { ModalContent } from "../ModalContent";
6
+
7
+ jest.mock("../ModalBottomSheet", () => ({ ModalBottomSheet: () => null }));
8
+
9
+ jest.mock(
10
+ "@applicaster/zapp-react-native-ui-components/Components/ScreenResolver",
11
+ () => ({ ScreenResolver: () => null })
12
+ );
13
+
14
+ const flatStyle = (tree: any) => StyleSheet.flatten(tree.props.style);
15
+
16
+ describe("ModalContent", () => {
17
+ it("lets a presented screen fill the modal, leaving the safe area to the screen", () => {
18
+ const tree = render(
19
+ <ModalContent modalScreenProps={{ screenId: "river-1" }} />
20
+ ).toJSON();
21
+
22
+ // The modal provides a SafeAreaProvider instead, so the presented screen
23
+ // reads the real insets itself rather than being padded from the outside.
24
+ expect(flatStyle(tree)).toEqual({ flex: 1 });
25
+ });
26
+
27
+ it("leaves a bottom sheet full-bleed", () => {
28
+ const tree = render(
29
+ <ModalContent
30
+ modalScreenProps={{
31
+ screenData: { modalBottomSheetContentProps: { items: [] } },
32
+ }}
33
+ />
34
+ ).toJSON();
35
+
36
+ // Bottom sheets anchor to the screen edge and manage their own insets.
37
+ expect(tree).toBeNull();
38
+ });
39
+ });
@@ -0,0 +1,99 @@
1
+ import React from "react";
2
+ import { render } from "@testing-library/react-native";
3
+
4
+ import { modalStore } from "@applicaster/zapp-react-native-utils/modalState";
5
+
6
+ import { ModalProvider } from "../";
7
+
8
+ /**
9
+ * Records the ScreenDataContext value seen by the presented screen — the
10
+ * context useScreenContext()/useCurrentScreenData() read from.
11
+ */
12
+ const mockSeenScreenData: any[] = [];
13
+
14
+ /** Records the `initialMetrics` each SafeAreaProvider the modal renders got. */
15
+ const mockSafeAreaProviderMetrics: any[] = [];
16
+
17
+ jest.mock(
18
+ "@applicaster/zapp-react-native-ui-components/Components/ScreenResolver",
19
+ () => {
20
+ const ReactLocal = require("react");
21
+
22
+ const {
23
+ ScreenDataContext,
24
+ } = require("@applicaster/zapp-react-native-ui-components/Contexts/ScreenDataContext");
25
+
26
+ return {
27
+ ScreenResolver: () => {
28
+ mockSeenScreenData.push(ReactLocal.useContext(ScreenDataContext));
29
+
30
+ return null;
31
+ },
32
+ };
33
+ }
34
+ );
35
+
36
+ // Needs the navigator + redux to build navbar state; irrelevant to this test.
37
+ jest.mock(
38
+ "@applicaster/zapp-react-native-ui-components/Contexts/ScreenContext",
39
+ () => ({
40
+ ScreenContextProvider: ({ children }: any) => children,
41
+ })
42
+ );
43
+
44
+ // Pulls in the whole Components barrel; only the ScreenResolver branch matters here.
45
+ jest.mock("../ModalBottomSheet", () => ({ ModalBottomSheet: () => null }));
46
+
47
+ jest.mock("react-native-safe-area-context", () => ({
48
+ useSafeAreaInsets: () => ({ top: 0, bottom: 0, left: 0, right: 0 }),
49
+ // A modal renders in its own native window, so it needs its own provider
50
+ // seeded with the window metrics; without them insets read as zero inside.
51
+ initialWindowMetrics: { insets: { top: 59, bottom: 34, left: 0, right: 0 } },
52
+ SafeAreaProvider: ({ children, initialMetrics }: any) => {
53
+ mockSafeAreaProviderMetrics.push(initialMetrics);
54
+
55
+ return children;
56
+ },
57
+ }));
58
+
59
+ const river = { id: "river-parent-lock", type: "parent_lock" } as any;
60
+
61
+ const entry = { id: "entry-1", type: { value: "video" } } as any;
62
+
63
+ const seen = () => mockSeenScreenData[mockSeenScreenData.length - 1];
64
+
65
+ describe("ModalProvider", () => {
66
+ beforeEach(() => {
67
+ mockSeenScreenData.length = 0;
68
+ mockSafeAreaProviderMetrics.length = 0;
69
+ modalStore.getState().dismissModal();
70
+ });
71
+
72
+ it("gives the presented screen its screen and entry through ScreenDataContext", () => {
73
+ modalStore.getState().openModal({ item: river, props: { entry } });
74
+
75
+ render(<ModalProvider />);
76
+
77
+ expect(seen()).toEqual({ screen: river, entry });
78
+ });
79
+
80
+ it("gives the presented screen its screen when presented without an entry", () => {
81
+ modalStore.getState().openModal({ item: river });
82
+
83
+ render(<ModalProvider />);
84
+
85
+ expect(seen()).toMatchObject({ screen: river });
86
+ });
87
+
88
+ it("seeds the presented screen's safe area with the window metrics", () => {
89
+ const { initialWindowMetrics } = require("react-native-safe-area-context");
90
+
91
+ modalStore.getState().openModal({ item: river });
92
+
93
+ render(<ModalProvider />);
94
+
95
+ expect(mockSafeAreaProviderMetrics).toEqual(
96
+ expect.arrayContaining([initialWindowMetrics])
97
+ );
98
+ });
99
+ });
@@ -1,9 +1,15 @@
1
1
  import * as React from "react";
2
2
 
3
+ import {
4
+ initialWindowMetrics,
5
+ SafeAreaProvider,
6
+ } from "react-native-safe-area-context";
7
+
3
8
  import { ModalPresenter } from "./ModalPresenter";
4
9
  import { ModalContent } from "./ModalContent";
5
10
  import { ModalChildrenWrapper } from "./ModalChildrenWrapper";
6
11
  import { PathnameContext } from "@applicaster/zapp-react-native-ui-components/Contexts/PathnameContext";
12
+ import { ScreenDataContext } from "@applicaster/zapp-react-native-ui-components/Contexts/ScreenDataContext";
7
13
  import { ScreenContextProvider } from "@applicaster/zapp-react-native-ui-components/Contexts/ScreenContext";
8
14
  import { ROUTE_TYPES } from "@applicaster/zapp-react-native-utils/navigationUtils/routeTypes";
9
15
  import { useModalStoreState } from "@applicaster/zapp-react-native-utils/modalState";
@@ -14,6 +20,9 @@ export function ModalProvider() {
14
20
  const [modalVisible, setModalVisible] = React.useState(false);
15
21
  const [modalShown, setModalShown] = React.useState(false);
16
22
 
23
+ const screen = modalState?.screen;
24
+ const entry = modalState?.props?.entry as ZappEntry | undefined;
25
+
17
26
  React.useEffect(() => {
18
27
  setModalVisible(!!modalState);
19
28
 
@@ -22,13 +31,25 @@ export function ModalProvider() {
22
31
  }
23
32
  }, [modalState]);
24
33
 
25
- if (!modalState?.screen) {
34
+ /**
35
+ * The modal renders as a sibling of the stack navigator, so nothing upstream
36
+ * provides ScreenDataContext and the presented screen would otherwise see
37
+ * `null` from useScreenContext()/useCurrentScreenData(). Provide it here so a
38
+ * presented screen resolves its own screen and entry, the same way a pushed
39
+ * screen does through the navigator's scene.
40
+ */
41
+ const screenDataContextValue = React.useMemo(
42
+ () => ({ screen, entry }),
43
+ [screen, entry]
44
+ );
45
+
46
+ if (!screen) {
26
47
  return null;
27
48
  }
28
49
 
29
50
  const modalScreenProps = {
30
- screenData: modalState?.screen,
31
- screenId: modalState?.screen?.id,
51
+ screenData: entry ? { ...entry, targetScreen: screen } : screen,
52
+ screenId: screen?.id,
32
53
  screenType: "river",
33
54
  ...modalState.props,
34
55
  };
@@ -39,17 +60,21 @@ export function ModalProvider() {
39
60
 
40
61
  return (
41
62
  <PathnameContext.Provider value={pathname}>
42
- <ScreenContextProvider pathname={pathname}>
43
- <ModalPresenter
44
- visible={shouldShowModal}
45
- {...modalState?.options}
46
- statusBarTranslucent
47
- >
48
- <ModalChildrenWrapper>
49
- <ModalContent modalScreenProps={modalScreenProps} />
50
- </ModalChildrenWrapper>
51
- </ModalPresenter>
52
- </ScreenContextProvider>
63
+ <ScreenDataContext.Provider value={screenDataContextValue}>
64
+ <ScreenContextProvider pathname={pathname}>
65
+ <ModalPresenter
66
+ visible={shouldShowModal}
67
+ {...modalState?.options}
68
+ statusBarTranslucent
69
+ >
70
+ <SafeAreaProvider initialMetrics={initialWindowMetrics}>
71
+ <ModalChildrenWrapper>
72
+ <ModalContent modalScreenProps={modalScreenProps} />
73
+ </ModalChildrenWrapper>
74
+ </SafeAreaProvider>
75
+ </ModalPresenter>
76
+ </ScreenContextProvider>
77
+ </ScreenDataContext.Provider>
53
78
  </PathnameContext.Provider>
54
79
  );
55
80
  }
@@ -55,6 +55,7 @@ import {
55
55
  getTargetScreen,
56
56
  legacyScreenData,
57
57
  openExternalUrl,
58
+ stripHookPrefix,
58
59
  } from "./utils";
59
60
  import {
60
61
  debounce,
@@ -242,6 +243,10 @@ export function NavigationProvider({ children }: Props) {
242
243
  playNextOverlayState.current = state;
243
244
  };
244
245
 
246
+ // The play-next overlay owns remote focus while it is visible, so key
247
+ // handling (InteractionManager) needs to be able to ask for it.
248
+ const getPlayNextOverlay = () => playNextOverlayState.current ?? null;
249
+
245
250
  const setNestedScreenContent = (entry: ZappEntry, screenId: string) => {
246
251
  const screen = rivers[screenId];
247
252
  const parent = findParent(context, navigator.currentRoute);
@@ -348,10 +353,7 @@ export function NavigationProvider({ children }: Props) {
348
353
  state: firstRoute.state,
349
354
  };
350
355
 
351
- if (
352
- stateForBack?.state?.entry &&
353
- "home" in stateForBack?.state?.entry
354
- ) {
356
+ if (stateForBack?.state?.entry?.home) {
355
357
  goHome();
356
358
  } else {
357
359
  dispatch(back(stateForBack));
@@ -414,6 +416,19 @@ export function NavigationProvider({ children }: Props) {
414
416
  },
415
417
  dispose
416
418
  ) => {
419
+ logger.debug({
420
+ message: `Hook screen presented: ${
421
+ hookPlugin.isModalHook() ? `(modal) ${route}` : route
422
+ }`,
423
+ data: {
424
+ route,
425
+ hookIdentifier: hookPlugin?.identifier,
426
+ hookScreenId: hookPlugin?.screen_id,
427
+ isModal: hookPlugin.isModalHook(),
428
+ lastHook: hookPlugin?.lastHook,
429
+ },
430
+ });
431
+
417
432
  if (hookPlugin?.lastHook) {
418
433
  dispose();
419
434
  }
@@ -536,6 +551,17 @@ export function NavigationProvider({ children }: Props) {
536
551
  currentStartUpHooks.current && setStartUpHooks(false);
537
552
  }
538
553
 
554
+ logger.debug({
555
+ message: `Hooks complete, navigating to: ${targetRoute}`,
556
+ data: {
557
+ targetRoute,
558
+ hookIdentifier: hookPlugin?.identifier,
559
+ screenId: screen?.id,
560
+ screenName: screen?.name,
561
+ options,
562
+ },
563
+ });
564
+
539
565
  dispatch(
540
566
  navigationAction(targetRoute, { screen, entry: payload, options })
541
567
  );
@@ -574,12 +600,28 @@ export function NavigationProvider({ children }: Props) {
574
600
  ) => {
575
601
  const { entry, screen, targetRoute, externalUrl } = getNavigationTarget(
576
602
  item,
577
- action === ACTIONS.REPLACE ? "" : pathnameRef.current,
603
+ action === ACTIONS.REPLACE ? "" : stripHookPrefix(pathnameRef.current),
578
604
  contentTypes,
579
605
  layoutVersion,
580
606
  rivers
581
607
  );
582
608
 
609
+ logger.debug({
610
+ message: `Navigating: ${pathnameRef.current || "(none)"} -> ${
611
+ targetRoute || externalUrl || "(unresolved)"
612
+ }`,
613
+ data: {
614
+ action,
615
+ from: pathnameRef.current,
616
+ to: targetRoute,
617
+ externalUrl,
618
+ screenId: screen?.id,
619
+ screenName: screen?.name,
620
+ entryType: entry?.type?.value,
621
+ options,
622
+ },
623
+ });
624
+
583
625
  if (externalUrl) {
584
626
  const openURL = async (url) => {
585
627
  const inflatedURL = await inflateUrl(url);
@@ -668,6 +710,15 @@ export function NavigationProvider({ children }: Props) {
668
710
 
669
711
  hooksManager.handleHooks(legacyScreenData({ entry, screen }));
670
712
  } else {
713
+ logger.debug({
714
+ message: `Navigating offline (hooks skipped) to: ${targetRoute}`,
715
+ data: {
716
+ targetRoute,
717
+ screenId: screen?.id,
718
+ screenName: screen?.name,
719
+ },
720
+ });
721
+
671
722
  dispatch(navigationAction(targetRoute, { screen, entry, options }));
672
723
  }
673
724
  },
@@ -727,6 +778,7 @@ export function NavigationProvider({ children }: Props) {
727
778
  replace: replaceItem,
728
779
  setNestedScreenContent,
729
780
  setPlayNextOverlay,
781
+ getPlayNextOverlay,
730
782
  goHome,
731
783
  canGoBack,
732
784
  goBack,
@@ -410,6 +410,62 @@ describe("<NavigationProvider />", () => {
410
410
  });
411
411
  });
412
412
 
413
+ describe("when backToTop is requested from a non-home tab", () => {
414
+ const listenRiver = {
415
+ id: "LISTEN",
416
+ home: false,
417
+ navigations: [],
418
+ ui_components: [],
419
+ };
420
+
421
+ beforeEach(() => {
422
+ wrapper = renderContextConsumer({
423
+ ...store,
424
+ rivers: { ...rivers, LISTEN: listenRiver },
425
+ });
426
+
427
+ act(() => {
428
+ getNavigatorValues(wrapper).navigator.replace(listenRiver);
429
+ });
430
+ });
431
+
432
+ it("returns to the tab root from the second level", () => {
433
+ act(() => {
434
+ getNavigatorValues(wrapper).navigator.push(rivers.A1234);
435
+ });
436
+
437
+ act(() => {
438
+ getNavigatorValues(wrapper).navigator.goBack(false, false, true);
439
+ });
440
+
441
+ const { navigator, state } = getNavigatorValues(wrapper);
442
+
443
+ expect(navigator.currentRoute).toEqual("/river/LISTEN");
444
+ expect(navigator.activeRiver).toEqual(listenRiver);
445
+ expect(state.stack.mainStack).toHaveLength(1);
446
+ });
447
+
448
+ it("returns to the tab root from the third level", () => {
449
+ act(() => {
450
+ getNavigatorValues(wrapper).navigator.push(rivers.A1234);
451
+ });
452
+
453
+ act(() => {
454
+ getNavigatorValues(wrapper).navigator.push(rivers.C0987);
455
+ });
456
+
457
+ act(() => {
458
+ getNavigatorValues(wrapper).navigator.goBack(false, false, true);
459
+ });
460
+
461
+ const { navigator, state } = getNavigatorValues(wrapper);
462
+
463
+ expect(navigator.currentRoute).toEqual("/river/LISTEN");
464
+ expect(navigator.activeRiver).toEqual(listenRiver);
465
+ expect(state.stack.mainStack).toHaveLength(1);
466
+ });
467
+ });
468
+
413
469
  describe("when there is a previous route and there are hooks", () => {
414
470
  beforeEach(() => {
415
471
  wrapper = renderContextConsumer();