@applicaster/quick-brick-core 13.0.0-rc.9 → 13.0.0-rc.91

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 (42) 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/index.tsx +4 -2
  18. package/App/ModalProvider/index.tsx +3 -4
  19. package/App/NavigationProvider/NavigationProvider.tsx +68 -27
  20. package/App/NavigationProvider/__tests__/__snapshots__/navigationProvider.test.tsx.snap +20 -22
  21. package/App/NavigationProvider/navigator/__tests__/__snapshots__/reducer.test.ts.snap +189 -189
  22. package/App/NetworkStatusProvider/utils.ts +0 -1
  23. package/App/RouteManager/__tests__/__snapshots__/routeManager.test.js.snap +2 -2
  24. package/App/StoreConnector/__tests__/storeConnector.test.js +17 -11
  25. package/App/appLifeCycleManager/__tests__/appLifeCycleManager.test.tsx +146 -0
  26. package/App/appLifeCycleManager/index.tsx +6 -7
  27. package/App/index.tsx +5 -3
  28. package/App/remoteContextReloader/__tests__/remoteContextReloader.test.js +11 -21
  29. package/App/remoteContextReloader/consts.ts +2 -0
  30. package/App/remoteContextReloader/getRemoteContextData/getNativeRemoteContextData.ts +31 -6
  31. package/createZappApp/__tests__/__snapshots__/createZappApp.test.js.snap +5 -128
  32. package/createZappApp/__tests__/createZappApp.test.js +7 -20
  33. package/defaults/__tests__/defaults.test.js +3 -4
  34. package/index.d.ts +1 -1
  35. package/package.json +26 -14
  36. package/App/DeepLinking/URLSchemeListener/__tests__/URLSchemeListenerTest.js +0 -177
  37. package/App/ErrorBoundary/__tests__/__snapshots__/errorBoundary.test.js.snap +0 -9
  38. package/App/ErrorBoundary/__tests__/errorBoundary.test.js +0 -72
  39. package/App/StoreConnector/__tests__/__snapshots__/storeConnector.test.js.snap +0 -35
  40. package/App/appLifeCycleManager/__tests__/__snapshots__/appLifeCycleManager.test.js.snap +0 -30
  41. package/App/appLifeCycleManager/__tests__/appLifeCycleManager.test.js +0 -134
  42. package/App/remoteContextReloader/__tests__/__snapshots__/remoteContextReloader.test.js.snap +0 -43
@@ -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,7 +58,10 @@ 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";
@@ -66,6 +70,10 @@ import { inflateUrl } from "@applicaster/zapp-react-native-ui-components/Compone
66
70
  import { useModalStore } from "@applicaster/zapp-react-native-utils/modalState";
67
71
  import { useSubscriberFor } from "@applicaster/zapp-react-native-utils/reactHooks/useSubscriberFor";
68
72
  import { QBUIComponentEvents } from "@applicaster/zapp-react-native-ui-components/events";
73
+ import { Hook } from "@applicaster/zapp-react-native-utils/appUtils/HooksManager/Hook";
74
+ import { URLSchemeContext } from "../DeepLinking/URLSchemeListener/URLSchemeContextProvider";
75
+
76
+ import { loadingOverlayManager } from "../LoadingOverlay";
69
77
 
70
78
  const logger = coreAppLogger.addSubsystem("Navigator");
71
79
 
@@ -75,17 +83,6 @@ type Props = {
75
83
  plugins?: QuickBrickPlugin[];
76
84
  };
77
85
 
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
86
  const navigationActions = {
90
87
  [ACTIONS.PUSH]: push,
91
88
  [ACTIONS.REPLACE]: replace,
@@ -96,6 +93,8 @@ const navigationActions = {
96
93
  const platform = getPlatform();
97
94
 
98
95
  export function NavigationProvider({ children }: Props) {
96
+ const { url: deepLinkURL } = React.useContext(URLSchemeContext);
97
+
99
98
  const {
100
99
  appData: { layoutVersion },
101
100
  rivers,
@@ -122,9 +121,7 @@ export function NavigationProvider({ children }: Props) {
122
121
  const pathname = state?.location?.pathname;
123
122
  const pathnameRef = React.useRef(pathname);
124
123
 
125
- const { context }: EntryContextType = React.useContext(
126
- ZappPipesEntryContext.Context
127
- );
124
+ const { context } = React.useContext(ZappPipesEntryContext.Context);
128
125
 
129
126
  const { openModal, dismissModal } = useModalStore();
130
127
 
@@ -380,7 +377,18 @@ export function NavigationProvider({ children }: Props) {
380
377
  }
381
378
  };
382
379
 
383
- const handleHookPresent = ({ hookPlugin, route, payload }, dispose) => {
380
+ const handleHookPresent = (
381
+ {
382
+ hookPlugin,
383
+ route,
384
+ payload,
385
+ }: {
386
+ hookPlugin: Hook;
387
+ route: string;
388
+ payload: object;
389
+ },
390
+ dispose
391
+ ) => {
384
392
  if (hookPlugin?.lastHook) {
385
393
  dispose();
386
394
  }
@@ -394,6 +402,8 @@ export function NavigationProvider({ children }: Props) {
394
402
  } else {
395
403
  dispatch(push(route, { entry: payload, screen: hookPlugin }));
396
404
  }
405
+
406
+ closeLoadingOverlay();
397
407
  };
398
408
 
399
409
  const handleHookError = ({ error, hookPlugin, callback }, dispose) => {
@@ -412,9 +422,11 @@ export function NavigationProvider({ children }: Props) {
412
422
  if (callback && typeof callback === "function") {
413
423
  callback();
414
424
  }
425
+
426
+ closeLoadingOverlay();
415
427
  };
416
428
 
417
- const handleHookCancel = ({ hookPlugin, callback }, dispose) => {
429
+ const handleHookCancel = ({ hookPlugin, callback, abort }, dispose) => {
418
430
  dispose();
419
431
  setStartUpHooks(false);
420
432
 
@@ -422,11 +434,15 @@ export function NavigationProvider({ children }: Props) {
422
434
  callback();
423
435
  }
424
436
 
425
- if (hookPlugin.isModalHook()) {
426
- navigator.dismissModal();
427
- } else {
428
- goBack(true, true);
437
+ if (!abort) {
438
+ if (hookPlugin.isModalHook()) {
439
+ navigator.dismissModal();
440
+ } else {
441
+ goBack(true, true);
442
+ }
429
443
  }
444
+
445
+ closeLoadingOverlay();
430
446
  };
431
447
 
432
448
  const handleHookSuccess = ({ hookPlugin, callback }) => {
@@ -437,6 +453,10 @@ export function NavigationProvider({ children }: Props) {
437
453
  }
438
454
  };
439
455
 
456
+ const handleBackgroundHook = () => {
457
+ openLoadingOverlay();
458
+ };
459
+
440
460
  const checkStartUpHooks = React.useMemo(() => {
441
461
  if (!pluginConfigurations) return false;
442
462
 
@@ -498,8 +518,7 @@ export function NavigationProvider({ children }: Props) {
498
518
  ({ hookPlugin, payload, callback }, dispose) => {
499
519
  if (hookPlugin?.lastHook) {
500
520
  dispose({ disposeAll: true });
501
-
502
- startUpHooks.current && setStartUpHooks(false);
521
+ currentStartUpHooks.current && setStartUpHooks(false);
503
522
  }
504
523
 
505
524
  dispatch(
@@ -507,6 +526,8 @@ export function NavigationProvider({ children }: Props) {
507
526
  );
508
527
 
509
528
  callback?.();
529
+
530
+ closeLoadingOverlay();
510
531
  };
511
532
 
512
533
  const offlinePlugin = React.useMemo(() => {
@@ -614,25 +635,37 @@ export function NavigationProvider({ children }: Props) {
614
635
  },
615
636
  };
616
637
 
617
- HooksManager(hooksOptions)
638
+ const hooksManager = HooksManager(hooksOptions);
639
+
640
+ hooksManager.subscriber
618
641
  .on(HOOKS_EVENTS.PRESENT_SCREEN_HOOK, handleHookPresent)
619
642
  .on(HOOKS_EVENTS.ERROR, handleHookError)
620
643
  .on(HOOKS_EVENTS.CANCEL, handleHookCancel)
621
644
  .on(HOOKS_EVENTS.SUCCESS, handleHookSuccess)
645
+ .on(HOOKS_EVENTS.START_BACKGROUND_HOOK, handleBackgroundHook)
622
646
  .on(
623
647
  HOOKS_EVENTS.COMPLETE,
624
648
  handleHookComplete(navigationAction, targetRoute, {
625
649
  screen,
626
650
  options,
627
651
  })
628
- )
629
- .handleHooks(legacyScreenData({ entry, screen }));
652
+ );
653
+
654
+ hooksManager.handleHooks(legacyScreenData({ entry, screen }));
630
655
  } else {
631
656
  dispatch(navigationAction(targetRoute, { screen, entry, options }));
632
657
  }
633
658
  },
634
659
  });
635
660
 
661
+ const openLoadingOverlay = React.useCallback(() => {
662
+ deepLinkURL && isVizioPlatform() && loadingOverlayManager.show();
663
+ }, [deepLinkURL]);
664
+
665
+ const closeLoadingOverlay = React.useCallback(() => {
666
+ loadingOverlayManager.hide();
667
+ }, []);
668
+
636
669
  const openPiP = React.useCallback(() => {
637
670
  dispatch(setVideoPiP());
638
671
  }, []);
@@ -738,7 +771,15 @@ export function NavigationProvider({ children }: Props) {
738
771
  getStackForPathname,
739
772
  mainStack: state.stack.mainStack,
740
773
  }),
741
- [rivers, plugins, JSON.stringify(state), appLaunched, startUpHooks]
774
+ [
775
+ rivers,
776
+ plugins,
777
+ // TODO: Compare entire screen data from state must be removed
778
+ // State size could be large ~150kb and take 80ms on android tv on 8 rails
779
+ JSON.stringify(state, getJsonReplacer()),
780
+ appLaunched,
781
+ startUpHooks,
782
+ ]
742
783
  );
743
784
 
744
785
  // when running the tests, we pass the dispatch function
@@ -1,8 +1,8 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`<NavigationProvider /> modal feature removes the visible flag when dismissing a modal 1`] = `
4
- Object {
5
- "options": Object {
4
+ {
5
+ "options": {
6
6
  "animated": true,
7
7
  "animationType": "slide",
8
8
  "onDismiss": [Function],
@@ -11,22 +11,20 @@ Object {
11
11
  "presentationStyle": "overFullScreen",
12
12
  "transparent": true,
13
13
  },
14
- "props": Object {
15
- "screenData": Object {},
16
- },
17
- "screen": Object {
14
+ "props": undefined,
15
+ "screen": {
18
16
  "id": "A1234",
19
- "navigations": Array [],
20
- "ui_components": Array [],
17
+ "navigations": [],
18
+ "ui_components": [],
21
19
  },
22
20
  "visible": true,
23
21
  }
24
22
  `;
25
23
 
26
24
  exports[`<NavigationProvider /> modal feature removes the visible flag when dismissing a modal 2`] = `
27
- Object {
28
- "options": Object {},
29
- "props": Object {},
25
+ {
26
+ "options": {},
27
+ "props": {},
30
28
  "screen": null,
31
29
  "visible": false,
32
30
  }
@@ -35,8 +33,8 @@ Object {
35
33
  exports[`<NavigationProvider /> modal feature sets the modalState when opening a modal 1`] = `undefined`;
36
34
 
37
35
  exports[`<NavigationProvider /> modal feature should reset state to initial when dismissing a modal ( closeModalBottomSheet ) opened by openModalBottomSheet 1`] = `
38
- Object {
39
- "options": Object {
36
+ {
37
+ "options": {
40
38
  "animated": false,
41
39
  "animationType": "none",
42
40
  "onDismiss": [Function],
@@ -45,14 +43,14 @@ Object {
45
43
  "presentationStyle": "overFullScreen",
46
44
  "transparent": true,
47
45
  },
48
- "props": Object {},
49
- "screen": Object {
50
- "ModalBottomSheetContent": Object {
46
+ "props": {},
47
+ "screen": {
48
+ "ModalBottomSheetContent": {
51
49
  "id": "A1234",
52
- "navigations": Array [],
53
- "ui_components": Array [],
50
+ "navigations": [],
51
+ "ui_components": [],
54
52
  },
55
- "modalBottomSheetContentProps": Object {
53
+ "modalBottomSheetContentProps": {
56
54
  "some": "props",
57
55
  },
58
56
  },
@@ -61,9 +59,9 @@ Object {
61
59
  `;
62
60
 
63
61
  exports[`<NavigationProvider /> modal feature should reset state to initial when dismissing a modal ( closeModalBottomSheet ) opened by openModalBottomSheet 2`] = `
64
- Object {
65
- "options": Object {},
66
- "props": Object {},
62
+ {
63
+ "options": {},
64
+ "props": {},
67
65
  "screen": null,
68
66
  "visible": false,
69
67
  }