@applicaster/zapp-react-native-utils 13.0.0-alpha.3755455151 → 13.0.0-alpha.3829509172

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 (83) hide show
  1. package/README.md +0 -10
  2. package/actionsExecutor/ActionExecutor.ts +16 -9
  3. package/actionsExecutor/ActionExecutorContext.tsx +59 -8
  4. package/alertUtils/alert.ts +148 -0
  5. package/alertUtils/index.ts +1 -148
  6. package/analyticsUtils/currentScreenProperities.ts +6 -4
  7. package/appUtils/HooksManager/Hook.ts +2 -2
  8. package/appUtils/HooksManager/index.ts +1 -1
  9. package/appUtils/HooksManager/types.ts +5 -2
  10. package/appUtils/contextKeysManager/contextResolver.ts +77 -0
  11. package/appUtils/contextKeysManager/index.ts +2 -2
  12. package/appUtils/contextKeysManager/utils/index.ts +2 -1
  13. package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +1 -0
  14. package/appUtils/focusManager/index.ts +11 -12
  15. package/appUtils/focusManagerAux/utils/index.ts +4 -3
  16. package/appUtils/keyCodes/index.ts +11 -7
  17. package/appUtils/orientationHelper.ts +11 -13
  18. package/appUtils/platform/const.ts +14 -0
  19. package/appUtils/platform/platformUtils.ts +47 -4
  20. package/appUtils/playerManager/index.ts +1 -1
  21. package/appUtils/playerManager/player.ts +26 -14
  22. package/appUtils/playerManager/playerNative.ts +18 -3
  23. package/equalUtils/__tests__/isEqual/combination.test.ts +263 -0
  24. package/equalUtils/index.ts +49 -30
  25. package/focusManager/FocusManager.ts +11 -1
  26. package/focusManager/index.ts +41 -4
  27. package/functionUtils/index.ts +21 -8
  28. package/idleUtils/__tests__/withTimeout$.test.ts +37 -0
  29. package/idleUtils/index.ts +1 -1
  30. package/idleUtils/withTimeout.ts +15 -2
  31. package/logger/const.ts +9 -67
  32. package/manifestUtils/__tests__/createConfig.test.js +0 -2
  33. package/manifestUtils/defaultManifestConfigurations/player.js +8 -0
  34. package/manifestUtils/fonts/index.js +5 -6
  35. package/manifestUtils/sharedConfiguration/screenPicker/__tests__/utils.test.js +304 -0
  36. package/manifestUtils/sharedConfiguration/screenPicker/stylesFields.js +875 -0
  37. package/manifestUtils/sharedConfiguration/screenPicker/utils.js +130 -0
  38. package/navigationUtils/__tests__/navigationUtils.test.js +0 -65
  39. package/navigationUtils/index.ts +3 -34
  40. package/numberUtils/index.ts +7 -5
  41. package/package.json +4 -10
  42. package/playerUtils/configurationGenerator.ts +8 -0
  43. package/reactHooks/autoscrolling/__tests__/useTrackedView.test.tsx +5 -7
  44. package/reactHooks/autoscrolling/useTrackedView.ts +12 -1
  45. package/reactHooks/cell-click/__tests__/index.test.js +5 -0
  46. package/reactHooks/cell-click/index.ts +7 -1
  47. package/reactHooks/feed/useFeedLoader.tsx +1 -1
  48. package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.test.js +1 -1
  49. package/reactHooks/layout/useDimensions/useDimensions.ts +8 -0
  50. package/reactHooks/navigation/__mocks__/useNavigation.ts +3 -0
  51. package/reactHooks/navigation/__tests__/index.test.tsx +6 -17
  52. package/reactHooks/navigation/index.ts +13 -23
  53. package/reactHooks/navigation/useGetTabBarHeight.ts +1 -3
  54. package/reactHooks/navigation/useProfilerLogging.ts +15 -0
  55. package/reactHooks/state/useRefWithInitialValue.ts +14 -0
  56. package/reactHooks/state/useStateFromSubscribe.ts +23 -0
  57. package/reactHooks/usePluginConfiguration.ts +1 -1
  58. package/reactHooks/useSubscriberFor.ts +4 -3
  59. package/reactUtils/__tests__/__snapshots__/reactUtilsHelpers.test.js.snap +16 -4
  60. package/reactUtils/__tests__/reactUtils.test.js +1 -19
  61. package/reactUtils/__tests__/reactUtilsHelpers.test.js +72 -71
  62. package/reactUtils/createContext/__tests__/__snapshots__/helpers.test.js.snap +6 -72
  63. package/reactUtils/createContext/__tests__/__snapshots__/provider.test.js.snap +3 -28
  64. package/reactUtils/createContext/__tests__/__snapshots__/withConsumer.test.js.snap +3 -4
  65. package/reactUtils/createContext/__tests__/__snapshots__/withProvider.test.js.snap +7 -3
  66. package/reactUtils/createContext/__tests__/helpers.test.js +107 -121
  67. package/reactUtils/createContext/__tests__/{index.test.js → index.test.ts} +2 -2
  68. package/reactUtils/createContext/__tests__/provider.test.js +4 -6
  69. package/reactUtils/createContext/__tests__/withConsumer.test.js +12 -12
  70. package/reactUtils/createContext/__tests__/withProvider.test.js +4 -4
  71. package/reactUtils/createContext/helpers.ts +6 -1
  72. package/reactUtils/createContext/index.ts +11 -25
  73. package/reactUtils/index.ts +0 -11
  74. package/screenState/index.ts +24 -10
  75. package/services/js2native.ts +673 -0
  76. package/testUtils/index.tsx +0 -10
  77. package/theme/index.ts +1 -1
  78. package/time/BackgroundTimer.ts +55 -0
  79. package/time/Timer.ts +9 -6
  80. package/types.ts +1 -0
  81. package/zappFrameworkUtils/presentPluginOneTime.ts +2 -3
  82. package/reactUtils/createContext/__tests__/index-no-react.test.js +0 -27
  83. /package/reactUtils/createContext/__tests__/__snapshots__/{index.test.js.snap → index.test.ts.snap} +0 -0
@@ -0,0 +1,130 @@
1
+ const defaultPlatforms = {
2
+ tvos: "tvOS",
3
+ android_tv: "Android TV",
4
+ lg_tv: "LG TV",
5
+ samsung_tv: "Samsung TV",
6
+ };
7
+
8
+ const global_defaults = {
9
+ fontSize: 20,
10
+ lineHeight: 40,
11
+ letterSpacing: 0.4,
12
+ };
13
+
14
+ const generateFontConfiguration = (platforms = defaultPlatforms) => {
15
+ const platformEntries = Object.entries(platforms);
16
+ const defaultsEntries = Object.entries(global_defaults);
17
+ const splitCamelCase = (str) => str.replace(/([a-z](?=[A-Z]))/g, "$1_");
18
+
19
+ return platformEntries.reduce((acc, [platformKey, platformValue]) => {
20
+ acc.push(
21
+ ...defaultsEntries.reduce((acc2, [valueKey, defaultValue]) => {
22
+ acc2.push({
23
+ type: "number_input",
24
+ label: `${platformValue} ${splitCamelCase(valueKey).replace(
25
+ "_",
26
+ " "
27
+ )}`,
28
+ key: `${platformKey}_${splitCamelCase(valueKey)}`.toLowerCase(),
29
+ initial_value: defaultValue,
30
+ });
31
+
32
+ return acc2;
33
+ }, [])
34
+ );
35
+
36
+ return acc;
37
+ }, []);
38
+ };
39
+
40
+ const conditional_rule = (key, condition_value) => ({
41
+ key,
42
+ condition_value,
43
+ });
44
+
45
+ const createConditionalConfig = (rules, matchAll = false) => ({
46
+ rules: matchAll ? "all_conditions" : "conditional",
47
+ conditional_fields: rules.map((field) => conditional_rule(...field)),
48
+ });
49
+
50
+ const conditional_horizontal_type = createConditionalConfig([
51
+ ["styles/screen_picker_type", "horizontal"],
52
+ ]);
53
+
54
+ const conditional_vertical_type = createConditionalConfig([
55
+ ["styles/screen_picker_type", "vertical"],
56
+ ]);
57
+
58
+ const conditional_horizontal_type_item_fixed = createConditionalConfig(
59
+ [
60
+ ["styles/screen_picker_type", "horizontal"],
61
+ ["styles/screen_picker_item_size", "fixed"],
62
+ ],
63
+ true
64
+ );
65
+
66
+ const conditional_horizontal_type_item_dynamic = createConditionalConfig(
67
+ [
68
+ ["styles/screen_picker_type", "horizontal"],
69
+ ["screen_picker_horizontal_display_type", "dynamic"],
70
+ ],
71
+ true
72
+ );
73
+
74
+ const conditional_horizontal_display_type_fixed = createConditionalConfig(
75
+ [
76
+ ["styles/screen_picker_type", "horizontal"],
77
+ ["styles/screen_picker_horizontal_display_type", "fixed"],
78
+ ],
79
+ true
80
+ );
81
+
82
+ const conditional_horizontal_asset_on = createConditionalConfig(
83
+ [
84
+ ["styles/screen_picker_type", "horizontal"],
85
+ ["styles/screen_picker_asset_switch", true],
86
+ ],
87
+ true
88
+ );
89
+
90
+ const createVariationFields = ({
91
+ prefix = "screen_picker",
92
+ key,
93
+ type = "number_input",
94
+ label = "",
95
+ variants: [a, b],
96
+ }) => {
97
+ return [
98
+ {
99
+ type,
100
+ key: `${prefix}${prefix.length > 0 ? "_" : ""}${
101
+ a?.key ?? "vertical"
102
+ }_${key}`,
103
+ label: a?.label ?? label,
104
+ initial_value: a.initial_value,
105
+ ...conditional_vertical_type,
106
+ },
107
+ {
108
+ type,
109
+ key: `${prefix}${prefix.length > 0 ? "_" : ""}${
110
+ b.key ?? "horizontal"
111
+ }_${key}`,
112
+ label: b?.label ?? label,
113
+ initial_value: b.initial_value,
114
+ ...conditional_horizontal_type,
115
+ },
116
+ ];
117
+ };
118
+
119
+ module.exports = {
120
+ generateFontConfiguration,
121
+ createVariationFields,
122
+ createConditionalConfig,
123
+ conditional_rule,
124
+ conditional_horizontal_type,
125
+ conditional_vertical_type,
126
+ conditional_horizontal_type_item_fixed,
127
+ conditional_horizontal_type_item_dynamic,
128
+ conditional_horizontal_display_type_fixed,
129
+ conditional_horizontal_asset_on,
130
+ };
@@ -319,68 +319,3 @@ describe("getRiverFromRoute", () => {
319
319
  expect(getRiverFromRoute({ route, rivers })).toEqual(river);
320
320
  });
321
321
  });
322
-
323
- describe("isPreviousRouteHook", () => {
324
- const { isPreviousRouteHook } = navigationUtils;
325
-
326
- const history = {
327
- entries: [],
328
- };
329
-
330
- it("returns false if it's a root route", () => {
331
- history.entries.push({ pathname: "/river/root" });
332
- const currentResult = isPreviousRouteHook(history.entries);
333
- expect(currentResult).toBe(false);
334
- });
335
-
336
- it("returns false if previous root is not a hook", () => {
337
- history.entries.push({ pathname: "/almostHooks/secondLevel" });
338
- const currentResult = isPreviousRouteHook(history.entries);
339
- expect(currentResult).toBe(false);
340
- });
341
-
342
- it("returns true if previous root is a hook", () => {
343
- history.entries.push({ pathname: "/hooks/ThirdLevel" });
344
- history.entries.push({ pathname: "/almostHooks/forthLevel" });
345
- const currentResult = isPreviousRouteHook(history.entries);
346
- expect(currentResult).toBe(true);
347
- });
348
- });
349
-
350
- describe("getPreviousHooksCount", () => {
351
- const { getPreviousHooksCount } = navigationUtils;
352
-
353
- const history = {
354
- entries: [],
355
- };
356
-
357
- it("returns 0 if it's a root route", () => {
358
- history.entries.push({ pathname: "/river/root" });
359
- const currentResult = getPreviousHooksCount(history);
360
- expect(currentResult).toBe(0);
361
- });
362
-
363
- it("returns 0 if previous root is not a hook", () => {
364
- history.entries.push({ pathname: "/almostHooks/secondLevel" });
365
- const currentResult = getPreviousHooksCount(history);
366
- expect(currentResult).toBe(0);
367
- });
368
-
369
- it("returns 1 if previous root is a hook", () => {
370
- history.entries = [];
371
- history.entries.push({ pathname: "/hooks/ThirdLevel" });
372
- history.entries.push({ pathname: "/almostHooks/forthLevel" });
373
- const currentResult = getPreviousHooksCount(history);
374
- expect(currentResult).toBe(1);
375
- });
376
-
377
- it("returns 2 if 2 previous routes are a hooks", () => {
378
- history.entries = [];
379
- history.entries.push({ pathname: "/almostHooks/forthLevel" });
380
- history.entries.push({ pathname: "/hooks/myHook" });
381
- history.entries.push({ pathname: "/hooks/myHook" });
382
- history.entries.push({ pathname: "/almostHooks/forthLevel" });
383
- const currentResult = getPreviousHooksCount(history);
384
- expect(currentResult).toBe(2);
385
- });
386
- });
@@ -361,37 +361,6 @@ export function getRiverFromRoute({
361
361
  return screenType && screenId ? { screenType, screenId } : null;
362
362
  }
363
363
 
364
- /**
365
- * Function returns true if the previous route (in the react-router history) is a hook plugin
366
- * @param {*} entries - React-Router History Object
367
- * @return boolean
368
- */
369
- export function isPreviousRouteHook(entries: [{ pathname: string }]): boolean {
370
- const previousRoute = entries[entries.length - 2];
371
- if (!previousRoute) return false;
372
-
373
- return R.test(/\/hooks\/.*/g, previousRoute.pathname);
374
- }
375
-
376
- /**
377
- * Function returns number of consecutive hooks that are behind the current route
378
- * @param {*} history - React-Router History Object
379
- * @return true
380
- */
381
- export function getPreviousHooksCount(history: {
382
- entries: [{ pathname: string }];
383
- }): number {
384
- let hooksCount = 0;
385
- let entries = R.clone(history.entries);
386
-
387
- while (isPreviousRouteHook(entries)) {
388
- hooksCount++;
389
- entries = R.init(entries);
390
- }
391
-
392
- return hooksCount;
393
- }
394
-
395
364
  export const usesVideoModal = (
396
365
  item: ZappEntry,
397
366
  rivers: Record<string, ZappRiver>,
@@ -644,8 +613,8 @@ export const getScreenId = (
644
613
  fallbackRiver: ZappRiver
645
614
  ) => {
646
615
  return screenData?.targetScreen
647
- ? screenData?.targetScreen?.id ?? fallbackRiver.id
616
+ ? (screenData?.targetScreen?.id ?? fallbackRiver.id)
648
617
  : "screen_id" in screenData
649
- ? screenData.screen_id
650
- : fallbackRiver.id;
618
+ ? screenData.screen_id
619
+ : fallbackRiver.id;
651
620
  };
@@ -3,7 +3,7 @@ import { logger } from "@applicaster/zapp-react-native-utils/logger";
3
3
 
4
4
  const numberUtilsLogger = logger?.addSubsystem("NumberUtils");
5
5
 
6
- export const toNumber = (value: any): number | undefined => {
6
+ export const toNumber = (value: unknown): number | undefined => {
7
7
  if (R.isNil(value) || R.isEmpty(value)) {
8
8
  return undefined;
9
9
  }
@@ -17,10 +17,12 @@ export const toNumber = (value: any): number | undefined => {
17
17
  return undefined;
18
18
  };
19
19
 
20
- export const toNumberWithDefault = (defaultValue: number, value: any): number =>
21
- toNumber(value) ?? defaultValue;
20
+ export const toNumberWithDefault = (
21
+ defaultValue: number,
22
+ value: unknown
23
+ ): number => toNumber(value) ?? defaultValue;
22
24
 
23
- export const toNumberWithDefaultZero = (value: any): number =>
25
+ export const toNumberWithDefaultZero = (value: unknown): number =>
24
26
  toNumberWithDefault(0, value);
25
27
 
26
28
  export const requireNumber = (obj, key: string) => {
@@ -39,7 +41,7 @@ export const requireNumber = (obj, key: string) => {
39
41
 
40
42
  export const toFiniteNumberWithDefault = (
41
43
  defaultValue: number,
42
- value: any
44
+ value: unknown
43
45
  ): number => {
44
46
  const possibleNumber = toNumberWithDefault(defaultValue, value);
45
47
 
package/package.json CHANGED
@@ -1,11 +1,10 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-utils",
3
- "version": "13.0.0-alpha.3755455151",
3
+ "version": "13.0.0-alpha.3829509172",
4
4
  "description": "Applicaster Zapp React Native utilities package",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
7
7
  "scripts": {
8
- "test": "jest -w=2",
9
8
  "build": "echo skipping hybrid ts build in main packages for now"
10
9
  },
11
10
  "publishConfig": {
@@ -28,11 +27,9 @@
28
27
  },
29
28
  "homepage": "https://github.com/applicaster/quickbrick#readme",
30
29
  "dependencies": {
31
- "@applicaster/applicaster-types": "13.0.0-alpha.3755455151",
30
+ "@applicaster/applicaster-types": "13.0.0-alpha.3829509172",
32
31
  "buffer": "^5.2.1",
33
32
  "camelize": "^1.0.0",
34
- "create-react-context": "^0.2.3",
35
- "create-react-ref": "^0.1.0",
36
33
  "dayjs": "^1.11.10",
37
34
  "memoizee": "0.4.15",
38
35
  "prop-types": "^15.0.0",
@@ -42,13 +39,10 @@
42
39
  "@applicaster/zapp-pipes-v2-client": "*",
43
40
  "@react-native-community/netinfo": "*",
44
41
  "immer": "*",
45
- "react": "17.0.2",
46
- "react-native": "0.68.6",
42
+ "react": "*",
43
+ "react-native": "*",
47
44
  "uglify-js": "*",
48
45
  "validate-color": "*",
49
46
  "zustand": "*"
50
- },
51
- "devDependencies": {
52
- "@types/react-native": "0.69.6"
53
47
  }
54
48
  }
@@ -55,6 +55,14 @@ function getPlayerConfiguration({ platform }) {
55
55
  label_tooltip:
56
56
  "Set the query params which control the size of the image e.g width, height. This will help to optimize the loading time, when magic background is enabled.",
57
57
  },
58
+ {
59
+ key: "audio_player_background_image_default_color",
60
+ label: "Audio Player Background Image Default Color",
61
+ initial_value: "",
62
+ type: "text_input",
63
+ label_tooltip:
64
+ "Set the default color for the audio player background image if not image or set of gradient colors are not provided.",
65
+ },
58
66
  ],
59
67
  };
60
68
 
@@ -35,25 +35,23 @@ const Wrapper = ({ children }: { children: React.ReactChild }) => (
35
35
  const { useTrackedView } = require("../useTrackedView");
36
36
 
37
37
  describe("useTrackCurrentAutoScrollingElement", () => {
38
- it("should update position for selected component", async () => {
38
+ it("should update position for selected component - onViewportEnter", () => {
39
39
  const { result } = renderHook(() => useTrackedView("123"), {
40
40
  wrapper: Wrapper,
41
41
  });
42
42
 
43
- // Fast-forward until all timers have been executed
44
- jest.advanceTimersByTime(3000);
45
-
46
43
  expect(result.current.inViewPort).toBe(false);
47
44
 
48
45
  const mockRect = {
49
46
  rect: { left: 1, right: 1, top: 1, bottom: 1 },
50
47
  };
51
48
 
52
- act(() => {
53
- result.current.onPositionUpdated(mockRect);
49
+ act(async () => {
50
+ await result.current.onPositionUpdated(mockRect);
54
51
  });
55
52
 
56
- jest.advanceTimersByTime(3000);
53
+ // Fast-forward until all timers have been executed
54
+ jest.runAllTimers();
57
55
 
58
56
  expect(result.current.inViewPort).toBe(true);
59
57
 
@@ -2,6 +2,10 @@ import { useCallback, useEffect, useMemo, useState } from "react";
2
2
  import { useScreenTrackedViewPositionsContext } from "@applicaster/zapp-react-native-ui-components/Contexts/ScreenTrackedViewPositionsContext";
3
3
  import { useDimensions } from "@applicaster/zapp-react-native-utils/reactHooks/layout";
4
4
  import { findTrackedView } from "./utils/findTrackedView";
5
+ import { isNil } from "ramda";
6
+ import { withTimeout } from "@applicaster/zapp-react-native-utils/idleUtils";
7
+
8
+ const TIMEOUT_FOR_DELAY_ON_VIEWPORT_ENTER_EVENT = 500; // ms
5
9
 
6
10
  const getNormalizedRect = (rect, componentId, screenWidth, screenHeight) => {
7
11
  if (!rect) {
@@ -37,9 +41,16 @@ export const useTrackedView = (componentId: string) => {
37
41
  );
38
42
 
39
43
  const onPositionUpdated = useCallback(
40
- ({ rect }) => {
44
+ async ({ rect }) => {
41
45
  const currentPosition = normalizedRect(componentId, rect);
42
46
 
47
+ // There is an issue on the native side where they are unable to guarantee
48
+ // that the order of onViewportLeave and onViewportEnter events is always correct.
49
+ // This workaround/hack delays the onViewportEnter event to ensure it is received last.
50
+ if (!isNil(currentPosition)) {
51
+ await withTimeout(TIMEOUT_FOR_DELAY_ON_VIEWPORT_ENTER_EVENT);
52
+ }
53
+
43
54
  updateComponentsPositions(componentId, currentPosition as any);
44
55
 
45
56
  setInViewPort(!!currentPosition);
@@ -25,6 +25,11 @@ jest.mock("@applicaster/zapp-react-native-utils/analyticsUtils/", () => ({
25
25
  }),
26
26
  }));
27
27
 
28
+ jest.mock("@applicaster/zapp-react-native-utils/reactHooks/screen", () => ({
29
+ useTargetScreenData: jest.fn(() => ({})),
30
+ useCurrentScreenData: jest.fn(() => ({})),
31
+ }));
32
+
28
33
  jest.mock("@applicaster/zapp-react-native-ui-components/Contexts", () => ({
29
34
  ...jest.requireActual(
30
35
  "@applicaster/zapp-react-native-ui-components/Contexts"
@@ -16,6 +16,7 @@ import { ActionExecutorContext } from "@applicaster/zapp-react-native-utils/acti
16
16
  import { isFunction, noop } from "../../functionUtils";
17
17
  import { useSendAnalyticsOnPress } from "../analytics";
18
18
  import { logOnPress, warnEmptyContentType } from "./helpers";
19
+ import { useCurrentScreenData } from "../screen";
19
20
 
20
21
  /**
21
22
  * If onCellTap is defined execute the function and
@@ -44,6 +45,7 @@ export const useCellClick = ({
44
45
 
45
46
  const onCellTap: Option<Function> = React.useContext(CellTapContext);
46
47
  const actionExecutor = React.useContext(ActionExecutorContext);
48
+ const screenData = useCurrentScreenData();
47
49
 
48
50
  const cellSelectable = toBooleanWithDefaultTrue(
49
51
  component?.rules?.component_cells_selectable
@@ -78,7 +80,10 @@ export const useCellClick = ({
78
80
  logOnPress(selectedItem, pathname, component, onCellTap);
79
81
 
80
82
  if (selectedItem) {
81
- await actionExecutor?.handleEntryActions(selectedItem);
83
+ await actionExecutor?.handleEntryActions(selectedItem, {
84
+ component,
85
+ screenData,
86
+ });
82
87
  }
83
88
 
84
89
  if (selectedItem?.type?.value === "action") {
@@ -111,6 +116,7 @@ export const useCellClick = ({
111
116
  pathname,
112
117
  push,
113
118
  sendAnalyticsOnPress,
119
+ screenData,
114
120
  ]
115
121
  );
116
122
 
@@ -87,7 +87,7 @@ export const useFeedLoader = ({
87
87
  );
88
88
  }
89
89
  }
90
- }, [callableFeedUrl, currentFeed?.data]);
90
+ }, [callableFeedUrl, currentFeed?.data?.next]);
91
91
 
92
92
  useEffect(() => {
93
93
  if (
@@ -5,7 +5,7 @@ const mockDimensionsGet = jest.fn(
5
5
  ({
6
6
  window: { width: 1, height: 1 },
7
7
  screen: { width: 360, height: 540 },
8
- }[type])
8
+ })[type]
9
9
  );
10
10
 
11
11
  ReactNative.Dimensions.get = mockDimensionsGet;
@@ -52,6 +52,14 @@ export const useDimensions: UseDimensions = (
52
52
  ? { fullDimensions }
53
53
  : { ...fullDimensions };
54
54
 
55
+ if (options.updateForInactiveScreens === undefined) {
56
+ options.updateForInactiveScreens = true;
57
+ }
58
+
59
+ if (options.fullDimensions === undefined) {
60
+ options.fullDimensions = false;
61
+ }
62
+
55
63
  const [dimensions, setDimensions] = useState(getInitialDimensions(context));
56
64
  const deviceInfo = useRef(getDeviceInfo(dimensions, appData));
57
65
 
@@ -3,5 +3,8 @@ export const useNavigation = jest.fn(() => ({
3
3
  screenData: {
4
4
  name: "someName",
5
5
  },
6
+ videoModalState: {
7
+ visible: false,
8
+ },
6
9
  currentRoute: "someRoute",
7
10
  }));
@@ -310,14 +310,14 @@ describe("navigation", () => {
310
310
  expect(navBarVisible).toBe(false);
311
311
  });
312
312
 
313
- it("returns false if it's secondary nav bar and hide_secondary_level_menu is true", () => {
313
+ it("returns false if it's secondary nav bar and show_secondary_level_menu is false", () => {
314
314
  const navBarVisible = isNavBarVisible(
315
315
  "",
316
316
  {
317
317
  navigations: [
318
318
  {
319
319
  styles: {
320
- hide_secondary_level_menu: true,
320
+ show_secondary_level_menu: false,
321
321
  },
322
322
  },
323
323
  ],
@@ -329,14 +329,14 @@ describe("navigation", () => {
329
329
  expect(navBarVisible).toBe(false);
330
330
  });
331
331
 
332
- it("returns true if it's secondary nav bar and hide_secondary_level_menu is false", () => {
332
+ it("returns true if it's secondary nav bar and show_secondary_level_menu is true", () => {
333
333
  const navBarVisible = isNavBarVisible(
334
334
  "",
335
335
  {
336
336
  navigations: [
337
337
  {
338
338
  styles: {
339
- hide_secondary_level_menu: false,
339
+ show_secondary_level_menu: true,
340
340
  },
341
341
  },
342
342
  ],
@@ -348,14 +348,14 @@ describe("navigation", () => {
348
348
  expect(navBarVisible).toBe(true);
349
349
  });
350
350
 
351
- it("returns true if it's first level menu and hide_secondary_level_menu is true", () => {
351
+ it("returns true if it's first level menu and show_secondary_level_menu is false", () => {
352
352
  const navBarVisible = isNavBarVisible(
353
353
  "",
354
354
  {
355
355
  navigations: [
356
356
  {
357
357
  styles: {
358
- hide_secondary_level_menu: true,
358
+ show_secondary_level_menu: false,
359
359
  },
360
360
  },
361
361
  ],
@@ -366,16 +366,5 @@ describe("navigation", () => {
366
366
 
367
367
  expect(navBarVisible).toBe(true);
368
368
  });
369
-
370
- it("returns true otherwise", () => {
371
- const navBarVisible = isNavBarVisible(
372
- "",
373
- { navigations: [] } as any,
374
- true,
375
- true
376
- );
377
-
378
- expect(navBarVisible).toBe(true);
379
- });
380
369
  });
381
370
  });
@@ -1,5 +1,5 @@
1
- import React, { useEffect, useMemo } from "react";
2
- import { BackHandler, InteractionManager, NativeModules } from "react-native";
1
+ import { useContext, useEffect, useMemo, useRef } from "react";
2
+ import { BackHandler } from "react-native";
3
3
 
4
4
  import {
5
5
  useContentTypes,
@@ -31,6 +31,8 @@ export { useGetBottomTabBarHeight } from "./useGetBottomTabBarHeight";
31
31
 
32
32
  export { useIsScreenActive } from "./useIsScreenActive";
33
33
 
34
+ export { useProfilerLogging } from "./useProfilerLogging";
35
+
34
36
  export {
35
37
  useUniqueRouteSuffix,
36
38
  useNavbarId,
@@ -106,11 +108,13 @@ export function isNavBarVisible(
106
108
  return false;
107
109
  }
108
110
 
109
- const hideSecondaryLevel = screenData?.navigations?.some(
110
- (navigation) => navigation.styles?.hide_secondary_level_menu
111
- );
111
+ const showSecondaryLevel =
112
+ !isTV() ||
113
+ screenData?.navigations?.some(
114
+ (navigation) => navigation.styles?.show_secondary_level_menu
115
+ );
112
116
 
113
- if (canGoBack && hideSecondaryLevel) {
117
+ if (canGoBack && !showSecondaryLevel) {
114
118
  return false;
115
119
  }
116
120
 
@@ -121,10 +125,8 @@ export function isNavBarVisible(
121
125
  return true;
122
126
  }
123
127
 
124
- const { ProfilerBridge } = NativeModules;
125
-
126
128
  export const useBackHandler = (cb: () => boolean) => {
127
- React.useEffect(() => {
129
+ useEffect(() => {
128
130
  BackHandler.addEventListener("hardwareBackPress", cb);
129
131
 
130
132
  return () => {
@@ -158,7 +160,7 @@ export const useZappHooksForEntry = (
158
160
  setIsHooksExecutionInProgress,
159
161
  setIsPresentingFullScreen,
160
162
  setIsRunningInBackground,
161
- }: HookModalContextT = React.useContext(ZappHookModalContext.ReactContext);
163
+ }: HookModalContextT = useContext(ZappHookModalContext.ReactContext);
162
164
 
163
165
  const {
164
166
  appData: { layoutVersion },
@@ -256,22 +258,10 @@ export const useZappHooksForEntry = (
256
258
  }, [entry.id]);
257
259
  };
258
260
 
259
- export const useProfilerLogging = () => {
260
- const logTimestamp = (data: string) =>
261
- InteractionManager.runAfterInteractions(() => {
262
- if (ProfilerBridge && data) {
263
- ProfilerBridge.updateTimer("navigation", data, Date.now());
264
- }
265
- });
266
-
267
- return logTimestamp;
268
- };
269
-
270
261
  export const useRunIfLongPress = (
271
262
  options = { timeout: LONG_KEY_PRESS_TIMEOUT }
272
263
  ) => {
273
- const pressTimeout =
274
- React.useRef<Nullable<ReturnType<typeof setTimeout>>>(null);
264
+ const pressTimeout = useRef<Nullable<ReturnType<typeof setTimeout>>>(null);
275
265
 
276
266
  const resetTimeout = () => {
277
267
  clearTimeout(pressTimeout.current as ReturnType<typeof setTimeout>);
@@ -1,5 +1,3 @@
1
- import { useSafeAreaInsets } from "react-native-safe-area-context";
2
-
3
1
  import { platformSelect } from "../../reactUtils";
4
2
 
5
3
  const TAB_BAR_HEIGHT_IOS = 49;
@@ -7,6 +5,6 @@ const TAB_BAR_HEIGHT_ANDROID = 56;
7
5
 
8
6
  export const useGetTabBarHeight = () =>
9
7
  platformSelect({
10
- ios: TAB_BAR_HEIGHT_IOS + (useSafeAreaInsets().bottom ?? 0),
8
+ ios: TAB_BAR_HEIGHT_IOS,
11
9
  android: TAB_BAR_HEIGHT_ANDROID,
12
10
  }) as number;
@@ -0,0 +1,15 @@
1
+ import { useCallback } from "react";
2
+ import { InteractionManager, NativeModules } from "react-native";
3
+
4
+ const { ProfilerBridge } = NativeModules;
5
+
6
+ export const useProfilerLogging = () =>
7
+ useCallback(
8
+ (data: string) =>
9
+ InteractionManager.runAfterInteractions(() => {
10
+ if (ProfilerBridge && data) {
11
+ ProfilerBridge.updateTimer("navigation", data, Date.now());
12
+ }
13
+ }),
14
+ []
15
+ );