@applicaster/zapp-react-native-utils 13.0.0-alpha.1552112220 → 13.0.0-alpha.1612843433

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 (152) hide show
  1. package/README.md +0 -10
  2. package/actionsExecutor/ActionExecutor.ts +16 -9
  3. package/actionsExecutor/ActionExecutorContext.tsx +196 -11
  4. package/actionsExecutor/consts.ts +4 -0
  5. package/alertUtils/alert.ts +148 -0
  6. package/alertUtils/index.ts +1 -148
  7. package/analyticsUtils/__tests__/__snapshots__/analyticsManagerNoModule.test.js.snap +9 -9
  8. package/analyticsUtils/currentScreenProperities.ts +6 -4
  9. package/analyticsUtils/helpers/hooks.ts +1 -1
  10. package/appUtils/HooksManager/Hook.ts +6 -2
  11. package/appUtils/HooksManager/__tests__/__snapshots__/hook.test.js.snap +7 -7
  12. package/appUtils/HooksManager/__tests__/__snapshots__/hooksManager.test.js.snap +186 -186
  13. package/appUtils/HooksManager/index.ts +3 -1
  14. package/appUtils/HooksManager/types.ts +5 -2
  15. package/appUtils/__tests__/__snapshots__/localizationsHelper.test.ts.snap +151 -0
  16. package/appUtils/__tests__/allZappLocales.ts +79 -0
  17. package/appUtils/__tests__/{localizationsHelper.test.js → localizationsHelper.test.ts} +11 -0
  18. package/appUtils/accessibilityManager/index.ts +42 -1
  19. package/appUtils/contextKeysManager/contextResolver.ts +66 -0
  20. package/appUtils/contextKeysManager/index.ts +2 -2
  21. package/appUtils/contextKeysManager/utils/index.ts +2 -1
  22. package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +9 -6
  23. package/appUtils/focusManager/index.ios.ts +14 -4
  24. package/appUtils/focusManager/index.ts +108 -69
  25. package/appUtils/focusManager/treeDataStructure/Tree/index.js +23 -0
  26. package/appUtils/focusManager/utils/__tests__/findChild.test.ts +35 -0
  27. package/appUtils/focusManager/utils/enums.ts +4 -0
  28. package/appUtils/focusManager/utils/index.ts +5 -0
  29. package/appUtils/focusManagerAux/utils/index.ts +4 -3
  30. package/appUtils/keyCodes/__tests__/__snapshots__/keyCodes.test.js.snap +2 -2
  31. package/appUtils/keyCodes/__tests__/keyCodes.test.js +1 -1
  32. package/appUtils/keyCodes/index.ts +11 -7
  33. package/appUtils/localizationsHelper.ts +31 -0
  34. package/appUtils/orientationHelper.ts +11 -13
  35. package/appUtils/platform/const.ts +14 -0
  36. package/appUtils/platform/platformUtils.ts +47 -4
  37. package/appUtils/playerManager/index.ts +1 -1
  38. package/appUtils/playerManager/player.ts +26 -14
  39. package/appUtils/playerManager/playerHooks/usePlayerCurrentTime.tsx +11 -7
  40. package/appUtils/playerManager/playerNative.ts +19 -4
  41. package/appUtils/playerManager/usePlayerTitleSummaryOverlay.tsx +7 -1
  42. package/arrayUtils/__tests__/__snapshots__/arrayUtils.test.ts.snap +4 -4
  43. package/cellUtils/index.ts +9 -5
  44. package/componentsUtils/__tests__/isFirstComponentGallery.test.ts +33 -0
  45. package/componentsUtils/__tests__/isFirstComponentScreenPicker.test.ts +33 -0
  46. package/componentsUtils/__tests__/isGallery.test.ts +33 -0
  47. package/componentsUtils/__tests__/isScreenPicker.test.ts +33 -0
  48. package/componentsUtils/index.ts +39 -0
  49. package/dateUtils/index.ts +19 -0
  50. package/equalUtils/__tests__/isEqual/combination.test.ts +263 -0
  51. package/equalUtils/index.ts +49 -30
  52. package/focusManager/FocusManager.ts +14 -2
  53. package/focusManager/index.ts +23 -4
  54. package/functionUtils/__tests__/__snapshots__/functionUtils.test.js.snap +4 -4
  55. package/functionUtils/index.ts +46 -8
  56. package/idleUtils/__tests__/withTimeout$.test.ts +37 -0
  57. package/idleUtils/index.ts +1 -1
  58. package/idleUtils/withTimeout.ts +15 -2
  59. package/index.d.ts +0 -12
  60. package/localizationUtils/index.ts +8 -13
  61. package/logger/const.ts +9 -67
  62. package/manifestUtils/__tests__/createConfig.test.js +16 -16
  63. package/manifestUtils/defaultManifestConfigurations/generalContent.js +13 -0
  64. package/manifestUtils/defaultManifestConfigurations/player.js +9 -3
  65. package/manifestUtils/fonts/index.js +5 -6
  66. package/manifestUtils/keys.js +27 -2
  67. package/manifestUtils/sharedConfiguration/screenPicker/__tests__/utils.test.js +304 -0
  68. package/manifestUtils/sharedConfiguration/screenPicker/stylesFields.js +875 -0
  69. package/manifestUtils/sharedConfiguration/screenPicker/utils.js +130 -0
  70. package/modalState/__tests__/index.test.ts +51 -0
  71. package/modalState/index.ts +32 -2
  72. package/navigationUtils/__tests__/__snapshots__/navigationUtils.test.js.snap +7 -6
  73. package/navigationUtils/__tests__/itemTypes.test.js +2 -2
  74. package/navigationUtils/__tests__/navigationUtils.test.js +2 -2
  75. package/navigationUtils/index.ts +6 -4
  76. package/numberUtils/__tests__/toPositiveNumberWithDefault.test.ts +23 -3
  77. package/numberUtils/index.ts +11 -5
  78. package/package.json +5 -10
  79. package/playerUtils/configurationGenerator.ts +9 -11
  80. package/reactHooks/advertising/index.ts +5 -5
  81. package/reactHooks/autoscrolling/__tests__/useTrackCurrentAutoScrollingElement.test.ts +1 -1
  82. package/reactHooks/autoscrolling/__tests__/useTrackedView.test.tsx +6 -8
  83. package/reactHooks/autoscrolling/useTrackedView.ts +12 -1
  84. package/reactHooks/cell-click/__tests__/index.test.js +10 -2
  85. package/reactHooks/cell-click/index.ts +7 -1
  86. package/reactHooks/feed/__tests__/useBuildPipesUrl.test.tsx +4 -4
  87. package/reactHooks/feed/__tests__/useFeedLoader.test.tsx +10 -11
  88. package/reactHooks/feed/useBatchLoading.ts +10 -12
  89. package/reactHooks/feed/useFeedLoader.tsx +18 -9
  90. package/reactHooks/feed/usePipesCacheReset.ts +5 -5
  91. package/reactHooks/flatList/__tests__/index.test.tsx +30 -21
  92. package/reactHooks/hookModal/hooks/useHookModalScreenData.ts +39 -0
  93. package/reactHooks/layout/__tests__/index.test.tsx +10 -10
  94. package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.native.test.js +14 -28
  95. package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.test.js +1 -1
  96. package/reactHooks/layout/useDimensions/useDimensions.ts +8 -0
  97. package/reactHooks/navigation/__mocks__/useNavigation.ts +3 -0
  98. package/reactHooks/navigation/__tests__/index.test.tsx +6 -21
  99. package/reactHooks/navigation/index.ts +34 -236
  100. package/reactHooks/navigation/useGetBottomTabBarHeight.ts +12 -0
  101. package/reactHooks/navigation/useGetNavBarTopBorderWidth.ts +14 -0
  102. package/reactHooks/navigation/useGetTabBarHeight.ts +10 -0
  103. package/reactHooks/navigation/useIsScreenActive.ts +17 -0
  104. package/reactHooks/navigation/useNavigationPluginData.ts +15 -0
  105. package/reactHooks/navigation/useNavigationType.ts +15 -0
  106. package/reactHooks/navigation/usePathname.ts +4 -0
  107. package/reactHooks/navigation/useProfilerLogging.ts +15 -0
  108. package/reactHooks/navigation/useRoute.ts +98 -0
  109. package/reactHooks/navigation/useUniqueRouteSuffix.ts +41 -0
  110. package/reactHooks/player/TVSeekControlller/TVSeekController.ts +4 -4
  111. package/reactHooks/player/__tests__/useAutoSeek._test.tsx +115 -0
  112. package/reactHooks/player/__tests__/useTapSeek._test.ts +94 -0
  113. package/reactHooks/screen/__tests__/useScreenBackgroundColor.test.tsx +69 -0
  114. package/reactHooks/screen/useScreenBackgroundColor.ts +3 -15
  115. package/reactHooks/state/useRefWithInitialValue.ts +14 -0
  116. package/reactHooks/state/useStateFromSubscribe.ts +23 -0
  117. package/reactHooks/useListenEventBusEvent.ts +1 -1
  118. package/reactHooks/usePluginConfiguration.ts +1 -1
  119. package/reactHooks/useSubscriberFor.ts +4 -3
  120. package/reactUtils/__tests__/__snapshots__/reactUtilsHelpers.test.js.snap +16 -4
  121. package/reactUtils/__tests__/reactUtils.test.js +1 -37
  122. package/reactUtils/__tests__/reactUtilsHelpers.test.js +72 -71
  123. package/reactUtils/createContext/__tests__/__snapshots__/helpers.test.js.snap +13 -79
  124. package/reactUtils/createContext/__tests__/__snapshots__/{index.test.js.snap → index.test.ts.snap} +2 -2
  125. package/reactUtils/createContext/__tests__/__snapshots__/provider.test.js.snap +3 -28
  126. package/reactUtils/createContext/__tests__/__snapshots__/withConsumer.test.js.snap +3 -4
  127. package/reactUtils/createContext/__tests__/__snapshots__/withProvider.test.js.snap +7 -3
  128. package/reactUtils/createContext/__tests__/helpers.test.js +107 -121
  129. package/reactUtils/createContext/__tests__/{index.test.js → index.test.ts} +2 -2
  130. package/reactUtils/createContext/__tests__/provider.test.js +4 -6
  131. package/reactUtils/createContext/__tests__/withConsumer.test.js +12 -12
  132. package/reactUtils/createContext/__tests__/withProvider.test.js +4 -4
  133. package/reactUtils/createContext/helpers.ts +6 -1
  134. package/reactUtils/createContext/index.ts +11 -25
  135. package/reactUtils/index.ts +9 -11
  136. package/screenState/index.ts +24 -10
  137. package/services/js2native.ts +673 -0
  138. package/testUtils/index.tsx +0 -10
  139. package/theme/__mocks__/index.ts +4 -0
  140. package/theme/index.ts +1 -1
  141. package/time/BackgroundTimer.ts +55 -0
  142. package/time/Timer.ts +9 -6
  143. package/types.ts +1 -0
  144. package/utils/README.md +30 -0
  145. package/utils/chunk.ts +5 -0
  146. package/utils/index.ts +5 -0
  147. package/utils/times.ts +5 -0
  148. package/zappFrameworkUtils/localStorageHelper.ts +6 -0
  149. package/zappFrameworkUtils/loginPluginUtils.ts +6 -2
  150. package/zappFrameworkUtils/presentPluginOneTime.ts +2 -3
  151. package/zappFrameworkUtils/types.ts +11 -0
  152. package/reactUtils/createContext/__tests__/index-no-react.test.js +0 -27
@@ -2,7 +2,6 @@
2
2
  import * as R from "ramda";
3
3
  import * as React from "react";
4
4
  import { Platform } from "react-native";
5
- import createRef from "create-react-ref/lib/createRef";
6
5
 
7
6
  import { addLifeCycleMethods, wrapInClass, isClassComponent } from "./helpers";
8
7
 
@@ -19,16 +18,6 @@ export function attachLifeCycleMethods(lifecycleMethods) {
19
18
  );
20
19
  }
21
20
 
22
- /**
23
- * creates a React Ref. if the version of React doesn't
24
- * have this API, will use a polyfill instead
25
- */
26
- export function createReactRef() {
27
- return React.createRef && typeof React.createRef === "function"
28
- ? React.createRef()
29
- : createRef();
30
- }
31
-
32
21
  /**
33
22
  * Clone the children and merge each of the cloned elements with otherProps.
34
23
  * @param {React.Children} children to clone
@@ -198,3 +187,12 @@ export const hasVizioAPIs = () => {
198
187
 
199
188
  return hasAPIs;
200
189
  };
190
+
191
+ /**
192
+ * Checks if the Android version is at least the expected version
193
+ * @param expectedVersion The version to compare against
194
+ * @returns True if the current Android version is at least the expected version, false otherwise
195
+ */
196
+ export const isAndroidVersionAtLeast = (expectedVersion: number) => {
197
+ return parseFloat(Platform.Version.toString()) >= expectedVersion;
198
+ };
@@ -1,6 +1,8 @@
1
1
  import { create } from "zustand";
2
2
  import { produce } from "immer";
3
3
  import { path } from "ramda";
4
+ import React from "react";
5
+ import { useShallow } from "zustand/react/shallow";
4
6
 
5
7
  type ScreenState = {
6
8
  selectedEntry: {
@@ -18,6 +20,8 @@ type ScreenStore = {
18
20
  setSelectedEntry: (screenId: string, entryId: string) => void;
19
21
  };
20
22
 
23
+ type SetSelectedEntry = (screenId: string, entryId: string) => void;
24
+
21
25
  const useScreenStore = create<ScreenStore>((set) => ({
22
26
  screens: screensInitialState,
23
27
  setSelectedEntry: (screenId, entryId) =>
@@ -35,17 +39,27 @@ const useScreenStore = create<ScreenStore>((set) => ({
35
39
  export function useScreenState(
36
40
  screenId: ScreenId
37
41
  ): null | { screen: ScreenState; setSelectedEntry: (entryId: string) => void } {
38
- // const state = useState(screenState);
39
- const screenState = useScreenStore(
40
- path(["screens", screenId])
41
- ) as ScreenState;
42
+ const screenState = useScreenStore<ScreenState>(
43
+ useShallow(path(["screens", screenId]))
44
+ );
42
45
 
43
- const setSelectedEntry = useScreenStore((state) => state.setSelectedEntry);
46
+ const setSelectedEntry = useScreenStore<SetSelectedEntry>(
47
+ useShallow(path(["setSelectedEntry"]))
48
+ );
44
49
 
45
- if (!screenId) return null;
50
+ const memoizedSetSelectedEntry = React.useCallback(
51
+ (entryId) => setSelectedEntry(screenId, entryId),
52
+ [screenId, setSelectedEntry]
53
+ );
46
54
 
47
- return {
48
- screen: screenState,
49
- setSelectedEntry: (entryId) => setSelectedEntry(screenId, entryId),
50
- };
55
+ return React.useMemo(
56
+ () =>
57
+ !screenId
58
+ ? null
59
+ : {
60
+ screen: screenState,
61
+ setSelectedEntry: memoizedSetSelectedEntry,
62
+ },
63
+ [screenId, screenState]
64
+ );
51
65
  }