@applicaster/quick-brick-core 13.0.0-rc.11 → 13.0.0-rc.110

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 (47) hide show
  1. package/App/ActionsProvider/__tests__/__snapshots__/ActionsProvider.test.js.snap +7 -7
  2. package/App/AssetCache/__tests__/__snapshots__/assetCache.test.ts.snap +103 -103
  3. package/App/AssetCache/__tests__/assetCache.test.ts +3 -2
  4. package/App/DeepLinking/URLSchemeHandler/SchemeHandlerHooks/__tests__/__snapshots__/schemeHandlerHooks.test.ts.snap +1 -1
  5. package/App/DeepLinking/URLSchemeHandler/SchemeHandlerHooks/__tests__/useOpenSchemeHandler.test.tsx +45 -116
  6. package/App/DeepLinking/URLSchemeHandler/__tests__/__snapshots__/URLSchemeHandler.test.tsx.snap +3 -3
  7. package/App/DeepLinking/URLSchemeListener/URLSchemeContextProvider.tsx +30 -3
  8. package/App/DeepLinking/URLSchemeListener/__tests__/URLSchemeListener.test.js +40 -0
  9. package/App/DeepLinking/URLSchemeListener/index.tsx +1 -1
  10. package/App/ErrorBoundary/__tests__/errorBoundary.test.jsx +232 -0
  11. package/App/ErrorBoundary/__tests__/store.test.js +143 -0
  12. package/App/ErrorBoundary/index.tsx +45 -21
  13. package/App/ErrorBoundary/store.ts +26 -0
  14. package/App/LoadingOverlay/LoadingOverlayManager.tsx +27 -0
  15. package/App/LoadingOverlay/index.tsx +49 -0
  16. package/App/LoadingOverlay/useLoadingOverlayVisibility.tsx +18 -0
  17. package/App/ModalProvider/ModalBottomSheet/Overlay.tsx +5 -7
  18. package/App/ModalProvider/ModalBottomSheet/index.tsx +6 -10
  19. package/App/ModalProvider/ModalPresenter.tsx +1 -1
  20. package/App/ModalProvider/index.tsx +6 -3
  21. package/App/NavigationProvider/NavigationProvider.tsx +77 -63
  22. package/App/NavigationProvider/__tests__/navigationProvider.test.tsx +0 -44
  23. package/App/NavigationProvider/navigator/__tests__/__snapshots__/reducer.test.ts.snap +189 -189
  24. package/App/NetworkStatusProvider/utils.ts +0 -1
  25. package/App/RouteManager/__tests__/__snapshots__/routeManager.test.js.snap +2 -2
  26. package/App/StoreConnector/__tests__/storeConnector.test.js +17 -11
  27. package/App/appLifeCycleManager/__tests__/appLifeCycleManager.test.tsx +146 -0
  28. package/App/appLifeCycleManager/index.tsx +6 -7
  29. package/App/index.tsx +6 -3
  30. package/App/remoteContextReloader/__tests__/remoteContextReloader.test.js +11 -21
  31. package/App/remoteContextReloader/consts.ts +2 -0
  32. package/App/remoteContextReloader/getRemoteContextData/getNativeRemoteContextData.ts +31 -6
  33. package/createZappApp/__tests__/__snapshots__/createZappApp.test.js.snap +5 -128
  34. package/createZappApp/__tests__/createZappApp.test.js +7 -20
  35. package/defaults/__tests__/defaults.test.js +3 -4
  36. package/index.d.ts +1 -1
  37. package/package.json +26 -14
  38. package/App/DeepLinking/URLSchemeListener/__tests__/URLSchemeListenerTest.js +0 -177
  39. package/App/ErrorBoundary/__tests__/__snapshots__/errorBoundary.test.js.snap +0 -9
  40. package/App/ErrorBoundary/__tests__/errorBoundary.test.js +0 -72
  41. package/App/ModalProvider/ModalChildrenWrapper/index.web.ts +0 -1
  42. package/App/NavigationProvider/__tests__/__snapshots__/navigationProvider.test.tsx.snap +0 -70
  43. package/App/StoreConnector/__tests__/__snapshots__/storeConnector.test.js.snap +0 -35
  44. package/App/appLifeCycleManager/__tests__/__snapshots__/appLifeCycleManager.test.js.snap +0 -30
  45. package/App/appLifeCycleManager/__tests__/appLifeCycleManager.test.js +0 -134
  46. package/App/remoteContextReloader/__tests__/__snapshots__/remoteContextReloader.test.js.snap +0 -43
  47. /package/App/ModalProvider/ModalChildrenWrapper/{index.ios.ts → index.ts} +0 -0
@@ -6,10 +6,10 @@ import { ModalChildrenWrapper } from "./ModalChildrenWrapper";
6
6
  import { PathnameContext } from "@applicaster/zapp-react-native-ui-components/Contexts/PathnameContext";
7
7
  import { ScreenContextProvider } from "@applicaster/zapp-react-native-ui-components/Contexts/ScreenContext";
8
8
  import { ROUTE_TYPES } from "@applicaster/zapp-react-native-utils/navigationUtils/routeTypes";
9
- import { useModalStore } from "@applicaster/zapp-react-native-utils/modalState";
9
+ import { useModalStoreState } from "@applicaster/zapp-react-native-utils/modalState";
10
10
 
11
11
  export function ModalProvider() {
12
- const { modalState } = useModalStore();
12
+ const modalState = useModalStoreState();
13
13
 
14
14
  const [modalVisible, setModalVisible] = React.useState(false);
15
15
  const [modalShown, setModalShown] = React.useState(false);
@@ -35,12 +35,15 @@ export function ModalProvider() {
35
35
 
36
36
  const pathname = `${ROUTE_TYPES.MODAL}/${modalScreenProps?.screenId}`;
37
37
 
38
+ const shouldShowModal = modalVisible && modalState?.visible;
39
+
38
40
  return (
39
41
  <PathnameContext.Provider value={pathname}>
40
42
  <ScreenContextProvider pathname={pathname}>
41
43
  <ModalPresenter
42
- visible={modalVisible && modalState?.visible}
44
+ visible={shouldShowModal}
43
45
  {...modalState?.options}
46
+ statusBarTranslucent
44
47
  >
45
48
  <ModalChildrenWrapper>
46
49
  <ModalContent modalScreenProps={modalScreenProps} />
@@ -49,6 +49,7 @@ import { coreAppLogger } from "../logger";
49
49
  import {
50
50
  getPlatform,
51
51
  isTV,
52
+ isVizioPlatform,
52
53
  } from "@applicaster/zapp-react-native-utils/reactUtils";
53
54
  import { useConnectionInfo } from "@applicaster/zapp-react-native-utils/reactHooks/connection";
54
55
  import {
@@ -57,15 +58,26 @@ import {
57
58
  legacyScreenData,
58
59
  openExternalUrl,
59
60
  } from "./utils";
60
- import { debounce } from "@applicaster/zapp-react-native-utils/functionUtils";
61
+ import {
62
+ debounce,
63
+ getJsonReplacer,
64
+ } from "@applicaster/zapp-react-native-utils/functionUtils";
61
65
 
62
66
  import { findParent } from "@applicaster/zapp-react-native-ui-components/Contexts/ZappPipesContext/ZappPipesEntryContext";
63
67
  import { ZappPipesEntryContext } from "@applicaster/zapp-react-native-ui-components/Contexts";
64
68
  import { PlayNextState } from "@applicaster/zapp-react-native-utils/appUtils/playerManager/OverlayObserver/OverlaysObserver";
65
69
  import { inflateUrl } from "@applicaster/zapp-react-native-ui-components/Components/LinkHandler/LinkHandler";
66
- import { useModalStore } from "@applicaster/zapp-react-native-utils/modalState";
70
+ import {
71
+ dismissModal,
72
+ modalStore,
73
+ openModal,
74
+ } from "@applicaster/zapp-react-native-utils/modalState";
67
75
  import { useSubscriberFor } from "@applicaster/zapp-react-native-utils/reactHooks/useSubscriberFor";
68
76
  import { QBUIComponentEvents } from "@applicaster/zapp-react-native-ui-components/events";
77
+ import { Hook } from "@applicaster/zapp-react-native-utils/appUtils/HooksManager/Hook";
78
+ import { URLSchemeContext } from "../DeepLinking/URLSchemeListener/URLSchemeContextProvider";
79
+
80
+ import { loadingOverlayManager } from "../LoadingOverlay";
69
81
 
70
82
  const logger = coreAppLogger.addSubsystem("Navigator");
71
83
 
@@ -75,17 +87,6 @@ type Props = {
75
87
  plugins?: QuickBrickPlugin[];
76
88
  };
77
89
 
78
- type EntryWithParent = ZappEntry & { parent?: EntryWithParent };
79
-
80
- type SingleEntry = {
81
- data: EntryWithParent;
82
- route: string;
83
- id: string;
84
- parentId?: string;
85
- };
86
-
87
- type EntryContextType = { [K in string]: SingleEntry };
88
-
89
90
  const navigationActions = {
90
91
  [ACTIONS.PUSH]: push,
91
92
  [ACTIONS.REPLACE]: replace,
@@ -96,6 +97,8 @@ const navigationActions = {
96
97
  const platform = getPlatform();
97
98
 
98
99
  export function NavigationProvider({ children }: Props) {
100
+ const { url: deepLinkURL } = React.useContext(URLSchemeContext);
101
+
99
102
  const {
100
103
  appData: { layoutVersion },
101
104
  rivers,
@@ -122,11 +125,7 @@ export function NavigationProvider({ children }: Props) {
122
125
  const pathname = state?.location?.pathname;
123
126
  const pathnameRef = React.useRef(pathname);
124
127
 
125
- const { context }: EntryContextType = React.useContext(
126
- ZappPipesEntryContext.Context
127
- );
128
-
129
- const { openModal, dismissModal } = useModalStore();
128
+ const { context } = React.useContext(ZappPipesEntryContext.Context);
130
129
 
131
130
  const playNextOverlayState = React.useRef();
132
131
 
@@ -153,7 +152,7 @@ export function NavigationProvider({ children }: Props) {
153
152
  );
154
153
 
155
154
  const getModalState: () => ModalState = () => {
156
- const { modalState } = useModalStore.getState();
155
+ const { modalState } = modalStore.getState();
157
156
 
158
157
  return modalState;
159
158
  };
@@ -380,13 +379,24 @@ export function NavigationProvider({ children }: Props) {
380
379
  }
381
380
  };
382
381
 
383
- const handleHookPresent = ({ hookPlugin, route, payload }, dispose) => {
382
+ const handleHookPresent = (
383
+ {
384
+ hookPlugin,
385
+ route,
386
+ payload,
387
+ }: {
388
+ hookPlugin: Hook;
389
+ route: string;
390
+ payload: object;
391
+ },
392
+ dispose
393
+ ) => {
384
394
  if (hookPlugin?.lastHook) {
385
395
  dispose();
386
396
  }
387
397
 
388
398
  if (hookPlugin.isModalHook()) {
389
- navigator.openModal({
399
+ openModal({
390
400
  item: payload,
391
401
  props: { screenType: "hooks" },
392
402
  options: { ModalContainer: hookPlugin.getModalContainer() },
@@ -394,6 +404,8 @@ export function NavigationProvider({ children }: Props) {
394
404
  } else {
395
405
  dispatch(push(route, { entry: payload, screen: hookPlugin }));
396
406
  }
407
+
408
+ closeLoadingOverlay();
397
409
  };
398
410
 
399
411
  const handleHookError = ({ error, hookPlugin, callback }, dispose) => {
@@ -404,7 +416,7 @@ export function NavigationProvider({ children }: Props) {
404
416
  }
405
417
 
406
418
  if (hookPlugin.isModalHook()) {
407
- navigator.dismissModal();
419
+ dismissModal();
408
420
  } else {
409
421
  goBack(true, true);
410
422
  }
@@ -412,9 +424,11 @@ export function NavigationProvider({ children }: Props) {
412
424
  if (callback && typeof callback === "function") {
413
425
  callback();
414
426
  }
427
+
428
+ closeLoadingOverlay();
415
429
  };
416
430
 
417
- const handleHookCancel = ({ hookPlugin, callback }, dispose) => {
431
+ const handleHookCancel = ({ hookPlugin, callback, abort }, dispose) => {
418
432
  dispose();
419
433
  setStartUpHooks(false);
420
434
 
@@ -422,21 +436,29 @@ export function NavigationProvider({ children }: Props) {
422
436
  callback();
423
437
  }
424
438
 
425
- if (hookPlugin.isModalHook()) {
426
- navigator.dismissModal();
427
- } else {
428
- goBack(true, true);
439
+ if (!abort) {
440
+ if (hookPlugin.isModalHook()) {
441
+ dismissModal();
442
+ } else {
443
+ goBack(true, true);
444
+ }
429
445
  }
446
+
447
+ closeLoadingOverlay();
430
448
  };
431
449
 
432
450
  const handleHookSuccess = ({ hookPlugin, callback }) => {
433
451
  callback?.();
434
452
 
435
453
  if (hookPlugin.isModalHook()) {
436
- navigator.dismissModal();
454
+ dismissModal();
437
455
  }
438
456
  };
439
457
 
458
+ const handleBackgroundHook = () => {
459
+ openLoadingOverlay();
460
+ };
461
+
440
462
  const checkStartUpHooks = React.useMemo(() => {
441
463
  if (!pluginConfigurations) return false;
442
464
 
@@ -498,8 +520,7 @@ export function NavigationProvider({ children }: Props) {
498
520
  ({ hookPlugin, payload, callback }, dispose) => {
499
521
  if (hookPlugin?.lastHook) {
500
522
  dispose({ disposeAll: true });
501
-
502
- startUpHooks.current && setStartUpHooks(false);
523
+ currentStartUpHooks.current && setStartUpHooks(false);
503
524
  }
504
525
 
505
526
  dispatch(
@@ -507,6 +528,8 @@ export function NavigationProvider({ children }: Props) {
507
528
  );
508
529
 
509
530
  callback?.();
531
+
532
+ closeLoadingOverlay();
510
533
  };
511
534
 
512
535
  const offlinePlugin = React.useMemo(() => {
@@ -614,25 +637,37 @@ export function NavigationProvider({ children }: Props) {
614
637
  },
615
638
  };
616
639
 
617
- HooksManager(hooksOptions)
640
+ const hooksManager = HooksManager(hooksOptions);
641
+
642
+ hooksManager.subscriber
618
643
  .on(HOOKS_EVENTS.PRESENT_SCREEN_HOOK, handleHookPresent)
619
644
  .on(HOOKS_EVENTS.ERROR, handleHookError)
620
645
  .on(HOOKS_EVENTS.CANCEL, handleHookCancel)
621
646
  .on(HOOKS_EVENTS.SUCCESS, handleHookSuccess)
647
+ .on(HOOKS_EVENTS.START_BACKGROUND_HOOK, handleBackgroundHook)
622
648
  .on(
623
649
  HOOKS_EVENTS.COMPLETE,
624
650
  handleHookComplete(navigationAction, targetRoute, {
625
651
  screen,
626
652
  options,
627
653
  })
628
- )
629
- .handleHooks(legacyScreenData({ entry, screen }));
654
+ );
655
+
656
+ hooksManager.handleHooks(legacyScreenData({ entry, screen }));
630
657
  } else {
631
658
  dispatch(navigationAction(targetRoute, { screen, entry, options }));
632
659
  }
633
660
  },
634
661
  });
635
662
 
663
+ const openLoadingOverlay = React.useCallback(() => {
664
+ deepLinkURL && isVizioPlatform() && loadingOverlayManager.show();
665
+ }, [deepLinkURL]);
666
+
667
+ const closeLoadingOverlay = React.useCallback(() => {
668
+ loadingOverlayManager.hide();
669
+ }, []);
670
+
636
671
  const openPiP = React.useCallback(() => {
637
672
  dispatch(setVideoPiP());
638
673
  }, []);
@@ -653,33 +688,6 @@ export function NavigationProvider({ children }: Props) {
653
688
  }
654
689
  }, [state?.options?.videoModal?.previousMode]);
655
690
 
656
- const openModalBottomSheet = React.useCallback(
657
- ({
658
- ModalBottomSheetContent,
659
- modalBottomSheetContentProps,
660
- props = {},
661
- options = {},
662
- }) => {
663
- openModal({
664
- item: {
665
- ModalBottomSheetContent,
666
- modalBottomSheetContentProps,
667
- },
668
- props,
669
- options: {
670
- animationType: "none",
671
- animated: false,
672
- ...options,
673
- },
674
- });
675
- },
676
- [openModal]
677
- );
678
-
679
- const closeModalBottomSheet = React.useCallback(() => {
680
- dismissModal();
681
- }, [dismissModal]);
682
-
683
691
  const getNestedEntry = () => state?.location?.state?.nested?.entry ?? null;
684
692
 
685
693
  // It will only work for the regular stack and pathname, It won't work for modals
@@ -720,8 +728,6 @@ export function NavigationProvider({ children }: Props) {
720
728
  openModal,
721
729
  dismissModal,
722
730
  getModalState,
723
- openModalBottomSheet,
724
- closeModalBottomSheet,
725
731
  videoModalState: state.options.videoModal,
726
732
  openVideoModal,
727
733
  closeVideoModal,
@@ -738,7 +744,15 @@ export function NavigationProvider({ children }: Props) {
738
744
  getStackForPathname,
739
745
  mainStack: state.stack.mainStack,
740
746
  }),
741
- [rivers, plugins, JSON.stringify(state), appLaunched, startUpHooks]
747
+ [
748
+ rivers,
749
+ plugins,
750
+ // TODO: Compare entire screen data from state must be removed
751
+ // State size could be large ~150kb and take 80ms on android tv on 8 rails
752
+ JSON.stringify(state, getJsonReplacer()),
753
+ appLaunched,
754
+ startUpHooks,
755
+ ]
742
756
  );
743
757
 
744
758
  // when running the tests, we pass the dispatch function
@@ -461,48 +461,4 @@ describe("<NavigationProvider />", () => {
461
461
  });
462
462
  });
463
463
  });
464
-
465
- describe("modal feature", () => {
466
- it("sets the modalState when opening a modal", () => {
467
- act(() => {
468
- wrapper = renderContextConsumer();
469
- });
470
-
471
- const view = getByTestId(wrapper, "WrapperView");
472
- act(() => view.props.navigator.openModal({ item: rivers.A1234 }));
473
- expect(view.props.navigator.get).toMatchSnapshot();
474
- });
475
-
476
- it("removes the visible flag when dismissing a modal", () => {
477
- act(() => {
478
- wrapper = renderContextConsumer();
479
- });
480
-
481
- const view = getByTestId(wrapper, "WrapperView");
482
- act(() => view.props.navigator.openModal({ item: rivers.A1234 }));
483
- expect(view.props.navigator.getModalState()).toMatchSnapshot();
484
- act(() => view.props.navigator.dismissModal());
485
- expect(view.props.navigator.getModalState().visible).toBeFalsy();
486
- expect(view.props.navigator.getModalState()).toMatchSnapshot();
487
- });
488
-
489
- it("should reset state to initial when dismissing a modal ( closeModalBottomSheet ) opened by openModalBottomSheet", () => {
490
- act(() => {
491
- wrapper = renderContextConsumer();
492
- });
493
-
494
- const view = getByTestId(wrapper, "WrapperView");
495
-
496
- act(() =>
497
- view.props.navigator.openModalBottomSheet({
498
- ModalBottomSheetContent: rivers.A1234,
499
- modalBottomSheetContentProps: { some: "props" },
500
- })
501
- );
502
-
503
- expect(view.props.navigator.getModalState()).toMatchSnapshot();
504
- act(() => view.props.navigator.closeModalBottomSheet());
505
- expect(view.props.navigator.getModalState()).toMatchSnapshot();
506
- });
507
- });
508
464
  });