@applicaster/zapp-react-dom-app 14.0.0-alpha.5219335081 → 14.0.0-alpha.5234792518

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,18 +10,18 @@ jest.mock("@applicaster/zapp-react-native-utils/appUtils", () => ({
10
10
  },
11
11
  }));
12
12
 
13
- jest.mock("@applicaster/zapp-react-native-utils/reactHooks/state", () => ({
14
- useIsHomeScreen: jest.fn(),
15
- useIsRootScreen: jest.fn(),
16
- useIsTabsScreen: jest.fn(),
13
+ jest.mock("../hooks", () => ({
14
+ useCurrentScreenIsHome: jest.fn(),
15
+ useCurrentScreenIsRoot: jest.fn(),
16
+ useCurrentScreenIsTabs: jest.fn(),
17
17
  }));
18
18
 
19
19
  import { focusManager } from "@applicaster/zapp-react-native-utils/appUtils";
20
20
  import {
21
- useIsHomeScreen,
22
- useIsRootScreen,
23
- useIsTabsScreen,
24
- } from "@applicaster/zapp-react-native-utils/reactHooks/state";
21
+ useCurrentScreenIsHome,
22
+ useCurrentScreenIsRoot,
23
+ useCurrentScreenIsTabs,
24
+ } from "../hooks";
25
25
 
26
26
  jest.mock("@applicaster/zapp-react-native-utils/reactHooks", () => ({
27
27
  useNavigation: jest.fn(),
@@ -47,9 +47,9 @@ describe("withBackToTopActionHOC", () => {
47
47
  it("returns PLATFORM_BACK when on root screen, focus on menu, and is home", () => {
48
48
  expect.assertions(1);
49
49
 
50
- (useIsRootScreen as jest.Mock).mockReturnValue(true);
51
- (useIsHomeScreen as jest.Mock).mockReturnValue(true);
52
- (useIsTabsScreen as jest.Mock).mockReturnValue(false);
50
+ (useCurrentScreenIsRoot as jest.Mock).mockReturnValue(true);
51
+ (useCurrentScreenIsHome as jest.Mock).mockReturnValue(true);
52
+ (useCurrentScreenIsTabs as jest.Mock).mockReturnValue(false);
53
53
 
54
54
  (useNavigation as jest.Mock).mockReturnValue({
55
55
  getNestedEntry: () => undefined,
@@ -68,9 +68,9 @@ describe("withBackToTopActionHOC", () => {
68
68
  it("returns GO_HOME when on root screen, focus on menu, and not home", () => {
69
69
  expect.assertions(1);
70
70
 
71
- (useIsRootScreen as jest.Mock).mockReturnValue(true);
72
- (useIsHomeScreen as jest.Mock).mockReturnValue(false);
73
- (useIsTabsScreen as jest.Mock).mockReturnValue(false);
71
+ (useCurrentScreenIsRoot as jest.Mock).mockReturnValue(true);
72
+ (useCurrentScreenIsHome as jest.Mock).mockReturnValue(false);
73
+ (useCurrentScreenIsTabs as jest.Mock).mockReturnValue(false);
74
74
 
75
75
  (useNavigation as jest.Mock).mockReturnValue({
76
76
  getNestedEntry: () => undefined,
@@ -84,9 +84,9 @@ describe("withBackToTopActionHOC", () => {
84
84
  });
85
85
 
86
86
  it("returns FOCUS_TOP_NAVIGATION when on root screen and focus on content without tabs_screen", () => {
87
- (useIsRootScreen as jest.Mock).mockReturnValue(true);
88
- (useIsHomeScreen as jest.Mock).mockReturnValue(false);
89
- (useIsTabsScreen as jest.Mock).mockReturnValue(false);
87
+ (useCurrentScreenIsRoot as jest.Mock).mockReturnValue(true);
88
+ (useCurrentScreenIsHome as jest.Mock).mockReturnValue(false);
89
+ (useCurrentScreenIsTabs as jest.Mock).mockReturnValue(false);
90
90
 
91
91
  (useNavigation as jest.Mock).mockReturnValue({
92
92
  getNestedEntry: () => "selectedEntry",
@@ -107,9 +107,9 @@ describe("withBackToTopActionHOC", () => {
107
107
  });
108
108
 
109
109
  it("returns FOCUS_TOP_NAVIGATION when on root screen and focus on content with tabs_screen", () => {
110
- (useIsRootScreen as jest.Mock).mockReturnValue(true);
111
- (useIsHomeScreen as jest.Mock).mockReturnValue(false);
112
- (useIsTabsScreen as jest.Mock).mockReturnValue(true);
110
+ (useCurrentScreenIsRoot as jest.Mock).mockReturnValue(true);
111
+ (useCurrentScreenIsHome as jest.Mock).mockReturnValue(false);
112
+ (useCurrentScreenIsTabs as jest.Mock).mockReturnValue(true);
113
113
 
114
114
  (useNavigation as jest.Mock).mockReturnValue({
115
115
  getNestedEntry: () => "selectedEntry",
@@ -132,9 +132,9 @@ describe("withBackToTopActionHOC", () => {
132
132
  it("returns GO_BACK in default case", () => {
133
133
  expect.assertions(1);
134
134
 
135
- (useIsRootScreen as jest.Mock).mockReturnValue(false);
136
- (useIsHomeScreen as jest.Mock).mockReturnValue(false);
137
- (useIsTabsScreen as jest.Mock).mockReturnValue(false);
135
+ (useCurrentScreenIsRoot as jest.Mock).mockReturnValue(false);
136
+ (useCurrentScreenIsHome as jest.Mock).mockReturnValue(false);
137
+ (useCurrentScreenIsTabs as jest.Mock).mockReturnValue(false);
138
138
 
139
139
  (useNavigation as jest.Mock).mockReturnValue({
140
140
  getNestedEntry: () => undefined,
@@ -0,0 +1,34 @@
1
+ import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks";
2
+ import {
3
+ useHomeRiver,
4
+ useRivers,
5
+ } from "@applicaster/zapp-react-native-utils/reactHooks/state";
6
+ import { last } from "@applicaster/zapp-react-native-utils/utils";
7
+
8
+ export const useCurrentScreenIsHome = (): boolean => {
9
+ const navigator = useNavigation();
10
+ const homeRiver = useHomeRiver();
11
+
12
+ const homePath = `/river/${homeRiver.id}`;
13
+
14
+ return homePath === navigator.currentRoute;
15
+ };
16
+
17
+ export const useCurrentScreenIsRoot = (): boolean => {
18
+ const { mainStack = [] } = useNavigation();
19
+
20
+ // root screen is the bottom(first pushed, deepest) element of the stack
21
+ return mainStack.length <= 1;
22
+ };
23
+
24
+ export const useCurrentScreenIsTabs = (): boolean => {
25
+ const navigator = useNavigation();
26
+
27
+ const riverId = last(navigator.currentRoute.split("/"));
28
+
29
+ const rivers = useRivers();
30
+
31
+ const river = rivers[riverId];
32
+
33
+ return river?.type === "tabs_screen";
34
+ };
@@ -1,10 +1,10 @@
1
1
  import * as React from "react";
2
2
  import { focusManager } from "@applicaster/zapp-react-native-utils/appUtils";
3
3
  import {
4
- useIsHomeScreen,
5
- useIsRootScreen,
6
- useIsTabsScreen,
7
- } from "@applicaster/zapp-react-native-utils/reactHooks/state";
4
+ useCurrentScreenIsHome,
5
+ useCurrentScreenIsRoot,
6
+ useCurrentScreenIsTabs,
7
+ } from "./hooks";
8
8
  import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks";
9
9
 
10
10
  export type BACK_TO_TOP_ACTION = {
@@ -16,14 +16,22 @@ export type BackToTopAction = () => BACK_TO_TOP_ACTION;
16
16
 
17
17
  export function withBackToTopActionHOC(Component) {
18
18
  return function WrappedComponent(props) {
19
- const isHome = useIsHomeScreen();
20
- const isRoot = useIsRootScreen();
21
- const isTabsScreen = useIsTabsScreen();
19
+ const isHome = useCurrentScreenIsHome();
20
+ const isRoot = useCurrentScreenIsRoot();
21
+ const isTabsScreen = useCurrentScreenIsTabs();
22
22
 
23
23
  const navigator = useNavigation();
24
24
  const selectedEntry = navigator.getNestedEntry();
25
25
 
26
+ const isStartUpHook =
27
+ Array.isArray(navigator.startUpHooks) &&
28
+ navigator.startUpHooks.length > 0;
29
+
26
30
  const backToTopAction = React.useCallback((): BACK_TO_TOP_ACTION => {
31
+ if (isRoot && isStartUpHook) {
32
+ return { action: "PLATFORM_BACK" };
33
+ }
34
+
27
35
  if (isRoot && focusManager.isFocusOnMenu() && isHome) {
28
36
  return { action: "PLATFORM_BACK" };
29
37
  }
@@ -8,6 +8,8 @@ import {
8
8
  sendQuickBrickEvent,
9
9
  } from "@applicaster/zapp-react-native-bridge/QuickBrick";
10
10
 
11
+ import { toBooleanWithDefaultFalse } from "@applicaster/zapp-react-native-utils/booleanUtils";
12
+
11
13
  import {
12
14
  debounce,
13
15
  noop,
@@ -62,7 +64,8 @@ const { log_debug, log_warning } = createLogger({
62
64
  });
63
65
 
64
66
  const shouldUseOnScreenKeyboard = () =>
65
- isVizioPlatform() || window.applicaster.useOnScreenKeyboard;
67
+ isVizioPlatform() ||
68
+ toBooleanWithDefaultFalse(window?.applicaster?.useOnScreenKeyboard);
66
69
 
67
70
  type Props = {
68
71
  displayState: string;
@@ -1,4 +1,5 @@
1
1
  import * as React from "react";
2
+ import { createPortal } from "react-dom";
2
3
 
3
4
  import { Background } from "@applicaster/zapp-react-dom-ui-components/Components/Background";
4
5
  import { ConfirmDialog } from "@applicaster/zapp-react-dom-ui-components/Components/ConfirmDialog";
@@ -29,7 +30,7 @@ export function Layout({ children }: Props) {
29
30
  >
30
31
  {children}
31
32
  </LayoutComponent>
32
- <ConfirmDialog />
33
+ {createPortal(<ConfirmDialog />, document.body)}
33
34
  </>
34
35
  );
35
36
  }
@@ -1,14 +1,12 @@
1
- import * as R from "ramda";
2
1
  import { NativeModules } from "react-native";
3
2
  import uuidv4 from "uuid/v4";
4
3
 
5
4
  import { isEmptyOrNil } from "@applicaster/zapp-react-native-utils/cellUtils";
6
- import { mapKeys } from "@applicaster/zapp-react-native-utils/objectUtils";
7
5
  import { appStore } from "@applicaster/zapp-react-native-redux/AppStore";
8
6
  import { sessionStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/SessionStorage";
9
7
  import { localStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/LocalStorage";
10
8
 
11
- import { renameKeys, getDeviceData } from "./utils/platform";
9
+ import { renameKeys, getDeviceData, getUserAgent } from "./utils/platform";
12
10
  import { desiredKeysMap } from "./utils/const";
13
11
 
14
12
  /**
@@ -55,6 +53,9 @@ export const loadPluginDataIntoSession = async (plugins = null) => {
55
53
  async function gatherData(uuid) {
56
54
  const deviceData = await getDeviceData();
57
55
 
56
+ // Prevent the device sdkVersion from overriding the build time value
57
+ delete deviceData.sdkVersion;
58
+
58
59
  const { languageLocale, countryLocale } =
59
60
  NativeModules?.QuickBrickCommunicationModule || {};
60
61
 
@@ -63,6 +64,7 @@ async function gatherData(uuid) {
63
64
  ...NativeModules?.QuickBrickCommunicationModule,
64
65
  // Device data retrieved from native device apis
65
66
  ...deviceData,
67
+ userAgent: deviceData.userAgent || getUserAgent(),
66
68
  uuid: uuid || uuidv4(), // Created on first session, persisted in local thereafter
67
69
  sessionId: uuidv4(), // Created on every session
68
70
  locale: `{language=${languageLocale}, country=${countryLocale}}`,
@@ -79,21 +81,23 @@ async function gatherData(uuid) {
79
81
  * @param {Object} desiredKeys - The map of original key names to desired key names.
80
82
  */
81
83
  function storeData(data, desiredKeys) {
82
- // Pick only the keys we want and need, map them to the correct name, and reject any unusuable data
83
- const filteredData = R.compose(
84
- R.reject(isEmptyOrNil),
85
- R.reject(R.either(R.is(Object), R.is(Function))),
86
- mapKeys(renameKeys),
87
- R.pick(Object.keys(desiredKeys))
88
- )(data);
89
-
90
- R.forEachObjIndexed((value, key) => {
91
- if (key === "uuid") {
92
- localStorage.setItem(key, value);
84
+ const desiredKeysList = Object.keys(desiredKeys);
85
+
86
+ Object.entries(data).forEach(([key, value]) => {
87
+ if (!desiredKeysList.includes(key)) return;
88
+
89
+ if (isEmptyOrNil(value)) return;
90
+
91
+ if (typeof value === "object" || typeof value === "function") return;
92
+
93
+ const renamedKey = renameKeys(key);
94
+
95
+ if (renamedKey === "uuid") {
96
+ localStorage.setItem(renamedKey, value);
93
97
  }
94
98
 
95
- sessionStorage.setItem(key, value);
96
- }, filteredData);
99
+ sessionStorage.setItem(renamedKey, value);
100
+ });
97
101
  }
98
102
 
99
103
  /**
@@ -257,26 +257,7 @@ export const getTizenInfo = () => {
257
257
  */
258
258
  export const getDeviceData = async () => {
259
259
  try {
260
- let deviceData = {
261
- modelName: null,
262
- version: null,
263
- versionMajor: null,
264
- versionMinor: null,
265
- versionDot: null,
266
- sdkVersion: null,
267
- screenWidth: null,
268
- screenHeight: null,
269
- uhd: null,
270
- oled: null,
271
- ddrSize: null,
272
- uhd8K: null,
273
- hdr10: null,
274
- dolbyVision: null,
275
- dolbyAtmos: null,
276
- name: null,
277
- osVersion: null,
278
- networkType: null,
279
- };
260
+ let deviceData = {};
280
261
 
281
262
  if (isLgPlatform()) {
282
263
  const [webOSInfo, webOSConnectionInfo] = await Promise.all([
@@ -308,7 +289,6 @@ export const getDeviceData = async () => {
308
289
  platform: "vizio",
309
290
  deviceMake: "Vizio",
310
291
  deviceType: "tv",
311
- userAgent: getUserAgent(),
312
292
  deviceWidth: window.innerWidth,
313
293
  deviceHeight: window.innerHeight,
314
294
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-dom-app",
3
- "version": "14.0.0-alpha.5219335081",
3
+ "version": "14.0.0-alpha.5234792518",
4
4
  "description": "Zapp App Component for Applicaster's Quick Brick React Native App",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -22,11 +22,11 @@
22
22
  },
23
23
  "homepage": "https://github.com/applicaster/zapp-react-dom-app#readme",
24
24
  "dependencies": {
25
- "@applicaster/zapp-react-dom-ui-components": "14.0.0-alpha.5219335081",
26
- "@applicaster/zapp-react-native-bridge": "14.0.0-alpha.5219335081",
27
- "@applicaster/zapp-react-native-redux": "14.0.0-alpha.5219335081",
28
- "@applicaster/zapp-react-native-ui-components": "14.0.0-alpha.5219335081",
29
- "@applicaster/zapp-react-native-utils": "14.0.0-alpha.5219335081",
25
+ "@applicaster/zapp-react-dom-ui-components": "14.0.0-alpha.5234792518",
26
+ "@applicaster/zapp-react-native-bridge": "14.0.0-alpha.5234792518",
27
+ "@applicaster/zapp-react-native-redux": "14.0.0-alpha.5234792518",
28
+ "@applicaster/zapp-react-native-ui-components": "14.0.0-alpha.5234792518",
29
+ "@applicaster/zapp-react-native-utils": "14.0.0-alpha.5234792518",
30
30
  "abortcontroller-polyfill": "^1.7.5",
31
31
  "typeface-montserrat": "^0.0.54",
32
32
  "video.js": "7.14.3",