@applicaster/quick-brick-core 13.0.0-alpha.3755455151 → 13.0.0-alpha.4004617449

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.
@@ -10,7 +10,11 @@ import * as ReactNative from "react-native";
10
10
 
11
11
  import { isWeb } from "@applicaster/zapp-react-native-utils/reactUtils";
12
12
  import { log_debug, log_error, log_info } from "../logger";
13
-
13
+ import { getAppUrlScheme } from "@applicaster/zapp-react-native-utils/appDataUtils";
14
+ import {
15
+ getZappPlatform,
16
+ ZappPlatform,
17
+ } from "@applicaster/zapp-react-native-utils/appUtils/platform";
14
18
  type Props = {
15
19
  listenerSpy?: (...any) => void;
16
20
  children: ReactChild;
@@ -34,6 +38,15 @@ const initialState = { url: null, done: () => {} };
34
38
 
35
39
  export const URLSchemeContext = createContext<State>(initialState);
36
40
 
41
+ const getWebDeepLink = (initialURL: string) => {
42
+ if (!initialURL) return null;
43
+
44
+ const index = initialURL.indexOf("?");
45
+ if (index === -1) return;
46
+
47
+ return getAppUrlScheme() + "://open" + initialURL.slice(index);
48
+ };
49
+
37
50
  function URLSchemeContextProvider(props: Props) {
38
51
  const [state, setState] = useState<string | null>(initialState.url);
39
52
 
@@ -51,10 +64,24 @@ function URLSchemeContextProvider(props: Props) {
51
64
  props?.listenerSpy?.("getInitialURL");
52
65
 
53
66
  try {
54
- if (isWeb()) return;
55
-
56
67
  const url = await Linking.getInitialURL();
57
68
 
69
+ if (isWeb()) {
70
+ if (getZappPlatform() === ZappPlatform.Vizio) {
71
+ const deepLink = getWebDeepLink(url);
72
+
73
+ if (deepLink) {
74
+ log_info(
75
+ `URLSchemeContextProvider: Retrieved initial deep link: ${deepLink}`
76
+ );
77
+
78
+ return setState(deepLink);
79
+ }
80
+ }
81
+
82
+ return;
83
+ }
84
+
58
85
  log_info(
59
86
  `URLSchemeContextProvider: Retrieved initial url: ${url || "not exist"}`
60
87
  );
@@ -0,0 +1,27 @@
1
+ import { BehaviorSubject } from "rxjs";
2
+
3
+ class LoadingOverlayManager {
4
+ visibilitySubject: BehaviorSubject<boolean>;
5
+
6
+ constructor() {
7
+ this.visibilitySubject = new BehaviorSubject(false);
8
+ }
9
+
10
+ show() {
11
+ this.visibilitySubject.next(true);
12
+ }
13
+
14
+ hide() {
15
+ this.visibilitySubject.next(false);
16
+ }
17
+
18
+ onVisibilityStateChange(cb: (value: boolean) => void) {
19
+ return this.visibilitySubject.subscribe(cb);
20
+ }
21
+
22
+ get visibility(): boolean {
23
+ return this.visibilitySubject.value;
24
+ }
25
+ }
26
+
27
+ export const loadingOverlayManager = new LoadingOverlayManager();
@@ -0,0 +1,49 @@
1
+ import * as React from "react";
2
+ import { View, StyleSheet } from "react-native";
3
+ import { focusManager } from "@applicaster/zapp-react-native-utils/appUtils/focusManager";
4
+ import { isVizioPlatform } from "@applicaster/zapp-react-native-utils/reactUtils";
5
+ import { Spinner } from "@applicaster/zapp-react-native-ui-components/Components/Spinner";
6
+ import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
7
+
8
+ import { useLoadingOverlayVisibility } from "./useLoadingOverlayVisibility";
9
+
10
+ export { loadingOverlayManager } from "./LoadingOverlayManager";
11
+
12
+ const styles = StyleSheet.create({
13
+ container: {
14
+ opacity: 0.5,
15
+ alignItems: "center",
16
+ justifyContent: "center",
17
+ zIndex: 100,
18
+ flex: 1,
19
+ },
20
+ });
21
+
22
+ const LoadingOverlayComponent = () => {
23
+ const visible = useLoadingOverlayVisibility();
24
+ const theme = useTheme();
25
+
26
+ const backgroundColor = React.useMemo(() => {
27
+ return theme?.app_background_color || "black";
28
+ }, [theme?.app_background_color]);
29
+
30
+ React.useEffect(() => {
31
+ if (visible) {
32
+ focusManager.disableFocus();
33
+ } else {
34
+ focusManager.enableFocus();
35
+ }
36
+ }, [visible]);
37
+
38
+ return visible ? (
39
+ <View
40
+ style={[StyleSheet.absoluteFill, styles.container, { backgroundColor }]}
41
+ >
42
+ <Spinner />
43
+ </View>
44
+ ) : null;
45
+ };
46
+
47
+ export const LoadingOverlay = isVizioPlatform()
48
+ ? LoadingOverlayComponent
49
+ : () => null;
@@ -0,0 +1,18 @@
1
+ import * as React from "react";
2
+ import { loadingOverlayManager } from "./LoadingOverlayManager";
3
+
4
+ export const useLoadingOverlayVisibility = () => {
5
+ const [visible, setVisible] = React.useState(
6
+ loadingOverlayManager.visibility
7
+ );
8
+
9
+ React.useEffect(() => {
10
+ const listener = loadingOverlayManager.onVisibilityStateChange(setVisible);
11
+
12
+ return () => {
13
+ listener.unsubscribe();
14
+ };
15
+ }, []);
16
+
17
+ return visible;
18
+ };
@@ -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 {
@@ -67,6 +68,9 @@ 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";
69
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";
70
74
 
71
75
  const logger = coreAppLogger.addSubsystem("Navigator");
72
76
 
@@ -86,6 +90,8 @@ const navigationActions = {
86
90
  const platform = getPlatform();
87
91
 
88
92
  export function NavigationProvider({ children }: Props) {
93
+ const { url: deepLinkURL } = React.useContext(URLSchemeContext);
94
+
89
95
  const {
90
96
  appData: { layoutVersion },
91
97
  rivers,
@@ -393,6 +399,8 @@ export function NavigationProvider({ children }: Props) {
393
399
  } else {
394
400
  dispatch(push(route, { entry: payload, screen: hookPlugin }));
395
401
  }
402
+
403
+ closeLoadingOverlay();
396
404
  };
397
405
 
398
406
  const handleHookError = ({ error, hookPlugin, callback }, dispose) => {
@@ -411,6 +419,8 @@ export function NavigationProvider({ children }: Props) {
411
419
  if (callback && typeof callback === "function") {
412
420
  callback();
413
421
  }
422
+
423
+ closeLoadingOverlay();
414
424
  };
415
425
 
416
426
  const handleHookCancel = ({ hookPlugin, callback }, dispose) => {
@@ -426,6 +436,8 @@ export function NavigationProvider({ children }: Props) {
426
436
  } else {
427
437
  goBack(true, true);
428
438
  }
439
+
440
+ closeLoadingOverlay();
429
441
  };
430
442
 
431
443
  const handleHookSuccess = ({ hookPlugin, callback }) => {
@@ -436,6 +448,10 @@ export function NavigationProvider({ children }: Props) {
436
448
  }
437
449
  };
438
450
 
451
+ const handleBackgroundHook = () => {
452
+ openLoadingOverlay();
453
+ };
454
+
439
455
  const checkStartUpHooks = React.useMemo(() => {
440
456
  if (!pluginConfigurations) return false;
441
457
 
@@ -497,8 +513,7 @@ export function NavigationProvider({ children }: Props) {
497
513
  ({ hookPlugin, payload, callback }, dispose) => {
498
514
  if (hookPlugin?.lastHook) {
499
515
  dispose({ disposeAll: true });
500
-
501
- startUpHooks.current && setStartUpHooks(false);
516
+ currentStartUpHooks.current && setStartUpHooks(false);
502
517
  }
503
518
 
504
519
  dispatch(
@@ -506,6 +521,8 @@ export function NavigationProvider({ children }: Props) {
506
521
  );
507
522
 
508
523
  callback?.();
524
+
525
+ closeLoadingOverlay();
509
526
  };
510
527
 
511
528
  const offlinePlugin = React.useMemo(() => {
@@ -620,6 +637,7 @@ export function NavigationProvider({ children }: Props) {
620
637
  .on(HOOKS_EVENTS.ERROR, handleHookError)
621
638
  .on(HOOKS_EVENTS.CANCEL, handleHookCancel)
622
639
  .on(HOOKS_EVENTS.SUCCESS, handleHookSuccess)
640
+ .on(HOOKS_EVENTS.START_BACKGROUND_HOOK, handleBackgroundHook)
623
641
  .on(
624
642
  HOOKS_EVENTS.COMPLETE,
625
643
  handleHookComplete(navigationAction, targetRoute, {
@@ -635,6 +653,14 @@ export function NavigationProvider({ children }: Props) {
635
653
  },
636
654
  });
637
655
 
656
+ const openLoadingOverlay = React.useCallback(() => {
657
+ deepLinkURL && isVizioPlatform() && loadingOverlayManager.show();
658
+ }, [deepLinkURL]);
659
+
660
+ const closeLoadingOverlay = React.useCallback(() => {
661
+ loadingOverlayManager.hide();
662
+ }, []);
663
+
638
664
  const openPiP = React.useCallback(() => {
639
665
  dispatch(setVideoPiP());
640
666
  }, []);
@@ -131,9 +131,8 @@ export function appLifeCycleManager(appLoader, QuickBrickManager) {
131
131
  )
132
132
  .map((plugin: any) => plugin.module?.getLoginProtocol?.());
133
133
 
134
- const loginProtocols: LoginProtocol[] = await Promise.all(
135
- promiseProtocols
136
- );
134
+ const loginProtocols: LoginProtocol[] =
135
+ await Promise.all(promiseProtocols);
137
136
 
138
137
  // Await all does not work here
139
138
  for (const protocol of loginProtocols) {
package/App/index.tsx CHANGED
@@ -1,3 +1,7 @@
1
+ // Disable logs popups(RN68)
2
+ import { LogBox } from "react-native";
3
+ LogBox.ignoreAllLogs();
4
+
1
5
  import * as React from "react";
2
6
  import * as R from "ramda";
3
7
  import {
@@ -29,6 +33,7 @@ import { appRemoteDataLoader } from "./appRemoteDataLoader";
29
33
  import { withActionExecutor } from "@applicaster/zapp-react-native-utils/actionsExecutor/ActionExecutorContext";
30
34
  import { withScreenDataContextProvider } from "@applicaster/zapp-react-native-ui-components/Contexts/ScreenDataContext";
31
35
  import { LogicAggregatorContainer } from "./LogicAggregatorContainer";
36
+ import { LoadingOverlay } from "./LoadingOverlay";
32
37
 
33
38
  interface AppOptions {
34
39
  Layout: React.ComponentType;
@@ -74,6 +79,7 @@ const App = ({
74
79
  <LogicAggregatorContainer
75
80
  components={[InteractionManager, ApplyScreenHooks]}
76
81
  />
82
+ <LoadingOverlay />
77
83
  </ErrorBoundary>
78
84
  </AppContainer>
79
85
  </SafeAreaProvider>
package/index.d.ts CHANGED
@@ -24,7 +24,7 @@ type AnyValue = void | string | number | boolean | AnyArray | AnyRecord;
24
24
  declare type ReducerAction<
25
25
  T extends string = string,
26
26
  P extends AnyValue = AnyValue,
27
- M extends AnyRecord = AnyRecord
27
+ M extends AnyRecord = AnyRecord,
28
28
  > = {
29
29
  type: T;
30
30
  payload?: P;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/quick-brick-core",
3
- "version": "13.0.0-alpha.3755455151",
3
+ "version": "13.0.0-alpha.4004617449",
4
4
  "description": "Core package for Applicaster's Quick Brick App",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -29,13 +29,13 @@
29
29
  },
30
30
  "homepage": "https://github.com/applicaster/quickbrick#readme",
31
31
  "dependencies": {
32
- "@applicaster/applicaster-types": "13.0.0-alpha.3755455151",
33
- "@applicaster/quick-brick-core-plugins": "13.0.0-alpha.3755455151",
34
- "@applicaster/zapp-pipes-v2-client": "13.0.0-alpha.3755455151",
35
- "@applicaster/zapp-react-native-bridge": "13.0.0-alpha.3755455151",
36
- "@applicaster/zapp-react-native-redux": "13.0.0-alpha.3755455151",
37
- "@applicaster/zapp-react-native-ui-components": "13.0.0-alpha.3755455151",
38
- "@applicaster/zapp-react-native-utils": "13.0.0-alpha.3755455151",
32
+ "@applicaster/applicaster-types": "13.0.0-alpha.4004617449",
33
+ "@applicaster/quick-brick-core-plugins": "13.0.0-alpha.4004617449",
34
+ "@applicaster/zapp-pipes-v2-client": "13.0.0-alpha.4004617449",
35
+ "@applicaster/zapp-react-native-bridge": "13.0.0-alpha.4004617449",
36
+ "@applicaster/zapp-react-native-redux": "13.0.0-alpha.4004617449",
37
+ "@applicaster/zapp-react-native-ui-components": "13.0.0-alpha.4004617449",
38
+ "@applicaster/zapp-react-native-utils": "13.0.0-alpha.4004617449",
39
39
  "atob": "^2.1.2",
40
40
  "axios": "^0.28.0",
41
41
  "btoa": "^1.2.1",