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

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 +55 -25
  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 {
@@ -66,6 +67,10 @@ import { inflateUrl } from "@applicaster/zapp-react-native-ui-components/Compone
66
67
  import { useModalStore } from "@applicaster/zapp-react-native-utils/modalState";
67
68
  import { useSubscriberFor } from "@applicaster/zapp-react-native-utils/reactHooks/useSubscriberFor";
68
69
  import { QBUIComponentEvents } from "@applicaster/zapp-react-native-ui-components/events";
70
+ import { Hook } from "@applicaster/zapp-react-native-utils/appUtils/HooksManager/Hook";
71
+ import { URLSchemeContext } from "../DeepLinking/URLSchemeListener/URLSchemeContextProvider";
72
+
73
+ import { loadingOverlayManager } from "../LoadingOverlay";
69
74
 
70
75
  const logger = coreAppLogger.addSubsystem("Navigator");
71
76
 
@@ -75,17 +80,6 @@ type Props = {
75
80
  plugins?: QuickBrickPlugin[];
76
81
  };
77
82
 
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
83
  const navigationActions = {
90
84
  [ACTIONS.PUSH]: push,
91
85
  [ACTIONS.REPLACE]: replace,
@@ -96,6 +90,8 @@ const navigationActions = {
96
90
  const platform = getPlatform();
97
91
 
98
92
  export function NavigationProvider({ children }: Props) {
93
+ const { url: deepLinkURL } = React.useContext(URLSchemeContext);
94
+
99
95
  const {
100
96
  appData: { layoutVersion },
101
97
  rivers,
@@ -122,9 +118,7 @@ export function NavigationProvider({ children }: Props) {
122
118
  const pathname = state?.location?.pathname;
123
119
  const pathnameRef = React.useRef(pathname);
124
120
 
125
- const { context }: EntryContextType = React.useContext(
126
- ZappPipesEntryContext.Context
127
- );
121
+ const { context } = React.useContext(ZappPipesEntryContext.Context);
128
122
 
129
123
  const { openModal, dismissModal } = useModalStore();
130
124
 
@@ -380,7 +374,18 @@ export function NavigationProvider({ children }: Props) {
380
374
  }
381
375
  };
382
376
 
383
- const handleHookPresent = ({ hookPlugin, route, payload }, dispose) => {
377
+ const handleHookPresent = (
378
+ {
379
+ hookPlugin,
380
+ route,
381
+ payload,
382
+ }: {
383
+ hookPlugin: Hook;
384
+ route: string;
385
+ payload: object;
386
+ },
387
+ dispose
388
+ ) => {
384
389
  if (hookPlugin?.lastHook) {
385
390
  dispose();
386
391
  }
@@ -394,6 +399,8 @@ export function NavigationProvider({ children }: Props) {
394
399
  } else {
395
400
  dispatch(push(route, { entry: payload, screen: hookPlugin }));
396
401
  }
402
+
403
+ closeLoadingOverlay();
397
404
  };
398
405
 
399
406
  const handleHookError = ({ error, hookPlugin, callback }, dispose) => {
@@ -412,9 +419,11 @@ export function NavigationProvider({ children }: Props) {
412
419
  if (callback && typeof callback === "function") {
413
420
  callback();
414
421
  }
422
+
423
+ closeLoadingOverlay();
415
424
  };
416
425
 
417
- const handleHookCancel = ({ hookPlugin, callback }, dispose) => {
426
+ const handleHookCancel = ({ hookPlugin, callback, abort }, dispose) => {
418
427
  dispose();
419
428
  setStartUpHooks(false);
420
429
 
@@ -422,11 +431,15 @@ export function NavigationProvider({ children }: Props) {
422
431
  callback();
423
432
  }
424
433
 
425
- if (hookPlugin.isModalHook()) {
426
- navigator.dismissModal();
427
- } else {
428
- goBack(true, true);
434
+ if (!abort) {
435
+ if (hookPlugin.isModalHook()) {
436
+ navigator.dismissModal();
437
+ } else {
438
+ goBack(true, true);
439
+ }
429
440
  }
441
+
442
+ closeLoadingOverlay();
430
443
  };
431
444
 
432
445
  const handleHookSuccess = ({ hookPlugin, callback }) => {
@@ -437,6 +450,10 @@ export function NavigationProvider({ children }: Props) {
437
450
  }
438
451
  };
439
452
 
453
+ const handleBackgroundHook = () => {
454
+ openLoadingOverlay();
455
+ };
456
+
440
457
  const checkStartUpHooks = React.useMemo(() => {
441
458
  if (!pluginConfigurations) return false;
442
459
 
@@ -498,8 +515,7 @@ export function NavigationProvider({ children }: Props) {
498
515
  ({ hookPlugin, payload, callback }, dispose) => {
499
516
  if (hookPlugin?.lastHook) {
500
517
  dispose({ disposeAll: true });
501
-
502
- startUpHooks.current && setStartUpHooks(false);
518
+ currentStartUpHooks.current && setStartUpHooks(false);
503
519
  }
504
520
 
505
521
  dispatch(
@@ -507,6 +523,8 @@ export function NavigationProvider({ children }: Props) {
507
523
  );
508
524
 
509
525
  callback?.();
526
+
527
+ closeLoadingOverlay();
510
528
  };
511
529
 
512
530
  const offlinePlugin = React.useMemo(() => {
@@ -614,25 +632,37 @@ export function NavigationProvider({ children }: Props) {
614
632
  },
615
633
  };
616
634
 
617
- HooksManager(hooksOptions)
635
+ const hooksManager = HooksManager(hooksOptions);
636
+
637
+ hooksManager.subscriber
618
638
  .on(HOOKS_EVENTS.PRESENT_SCREEN_HOOK, handleHookPresent)
619
639
  .on(HOOKS_EVENTS.ERROR, handleHookError)
620
640
  .on(HOOKS_EVENTS.CANCEL, handleHookCancel)
621
641
  .on(HOOKS_EVENTS.SUCCESS, handleHookSuccess)
642
+ .on(HOOKS_EVENTS.START_BACKGROUND_HOOK, handleBackgroundHook)
622
643
  .on(
623
644
  HOOKS_EVENTS.COMPLETE,
624
645
  handleHookComplete(navigationAction, targetRoute, {
625
646
  screen,
626
647
  options,
627
648
  })
628
- )
629
- .handleHooks(legacyScreenData({ entry, screen }));
649
+ );
650
+
651
+ hooksManager.handleHooks(legacyScreenData({ entry, screen }));
630
652
  } else {
631
653
  dispatch(navigationAction(targetRoute, { screen, entry, options }));
632
654
  }
633
655
  },
634
656
  });
635
657
 
658
+ const openLoadingOverlay = React.useCallback(() => {
659
+ deepLinkURL && isVizioPlatform() && loadingOverlayManager.show();
660
+ }, [deepLinkURL]);
661
+
662
+ const closeLoadingOverlay = React.useCallback(() => {
663
+ loadingOverlayManager.hide();
664
+ }, []);
665
+
636
666
  const openPiP = React.useCallback(() => {
637
667
  dispatch(setVideoPiP());
638
668
  }, []);
@@ -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
  }