@applicaster/zapp-react-native-utils 12.0.0-alpha.4837064762 → 12.0.0-alpha.4885205607

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 (70) hide show
  1. package/analyticsUtils/AnalyticsEvents/index.ts +13 -0
  2. package/analyticsUtils/AnalyticsEvents/searchEvents.ts +21 -0
  3. package/analyticsUtils/AnalyticsEvents/sendShareEvent.ts +21 -0
  4. package/analyticsUtils/analyticsPlugins.ts +25 -0
  5. package/analyticsUtils/events.ts +12 -0
  6. package/analyticsUtils/index.tsx +12 -0
  7. package/appUtils/accessibilityManager/const.ts +50 -0
  8. package/appUtils/accessibilityManager/hooks.ts +40 -0
  9. package/appUtils/accessibilityManager/index.ts +155 -0
  10. package/appUtils/accessibilityManager/logger.ts +5 -0
  11. package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +2 -3
  12. package/appUtils/focusManager/__tests__/focusManager.test.js +4 -24
  13. package/appUtils/focusManager/__tests__/index.test.ts +2 -3
  14. package/appUtils/focusManager/index.ts +44 -128
  15. package/appUtils/focusManager/treeDataStructure/Utils/index.js +14 -38
  16. package/appUtils/focusManager/utils/index.ts +100 -0
  17. package/appUtils/focusManagerAux/index.ts +76 -0
  18. package/appUtils/focusManagerAux/utils/index.ts +100 -0
  19. package/appUtils/index.js +2 -0
  20. package/appUtils/keyCodes/keys.web.js +8 -0
  21. package/appUtils/keyCodes/keysByPlatform.js +11 -1
  22. package/appUtils/platform/const.ts +25 -0
  23. package/appUtils/platform/index.ts +3 -0
  24. package/appUtils/platform/platformUtils.ts +185 -0
  25. package/appUtils/playerManager/conts.ts +1 -0
  26. package/appUtils/playerManager/index.ts +11 -5
  27. package/appUtils/playerManager/nativePlayerManager.ts +12 -0
  28. package/appUtils/playerManager/player.ts +9 -3
  29. package/appUtils/playerManager/playerNative.ts +5 -14
  30. package/appUtils/playerManager/usePlayerControllerSetup.tsx +7 -1
  31. package/arrayUtils/__tests__/isFilledArray.test.ts +63 -0
  32. package/arrayUtils/index.ts +5 -0
  33. package/booleanUtils/index.ts +4 -4
  34. package/cellUtils/__tests__/cellUtils.test.ts +9 -20
  35. package/cellUtils/index.ts +11 -17
  36. package/dateUtils/index.ts +11 -0
  37. package/headersUtils/index.ts +1 -0
  38. package/index.d.ts +15 -0
  39. package/inflatedUrlUtils/index.ts +4 -4
  40. package/keyboardState/index.ts +0 -0
  41. package/localizationUtils/__tests__/localizationUtils.test.ts +72 -53
  42. package/localizationUtils/index.ts +13 -22
  43. package/navigationUtils/index.ts +48 -0
  44. package/numberUtils/__tests__/isLikeNumber.test.ts +18 -0
  45. package/numberUtils/__tests__/toNumber.test.ts +2 -2
  46. package/numberUtils/index.ts +9 -18
  47. package/package.json +2 -2
  48. package/playerUtils/imaScriptDom.ts +59 -0
  49. package/pluginUtils/index.ts +9 -0
  50. package/reactHooks/cell-click/__tests__/index.test.js +10 -1
  51. package/reactHooks/cell-click/index.ts +12 -12
  52. package/reactHooks/feed/__tests__/useBuildPipesUrl.test.tsx +30 -70
  53. package/reactHooks/feed/__tests__/useFeedRefresh.test.tsx +6 -2
  54. package/reactHooks/feed/__tests__/useInflatedUrl.test.ts +18 -3
  55. package/reactHooks/feed/useBuildPipesUrl.ts +7 -10
  56. package/reactHooks/feed/useFeedRefresh.tsx +9 -7
  57. package/reactHooks/feed/useInflatedUrl.ts +44 -15
  58. package/reactHooks/navigation/__tests__/index.test.tsx +11 -8
  59. package/reactHooks/navigation/index.ts +46 -68
  60. package/reactHooks/screen/__tests__/useCurrentScreenData.test.tsx +21 -23
  61. package/reactHooks/screen/index.ts +2 -0
  62. package/reactHooks/screen/useScreenBackgroundColor.ts +23 -0
  63. package/reactHooks/screen/useScreenContext.ts +1 -2
  64. package/reactUtils/helpers.tsx +1 -1
  65. package/reactUtils/index.ts +104 -0
  66. package/stringUtils/index.ts +5 -0
  67. package/types.ts +4 -0
  68. package/appUtils/focusManager/FocusableEvents.ts +0 -8
  69. package/appUtils/focusManager/treeDataStructure/Utils/__tests__/Utils_android.test.js +0 -1094
  70. package/appUtils/focusManager/treeDataStructure/Utils/index.android.js +0 -261
@@ -0,0 +1,23 @@
1
+ import * as React from "react";
2
+ import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
3
+ import { useScreenConfiguration } from "@applicaster/zapp-react-native-ui-components/Components/River/useScreenConfiguration";
4
+ import { ifEmptyUseFallback } from "@applicaster/zapp-react-native-utils/cellUtils";
5
+
6
+ export const useScreenBackgroundColor = (screenId: string): string => {
7
+ const { backgroundColor: screenBackgroundColor } =
8
+ useScreenConfiguration(screenId);
9
+
10
+ const theme = useTheme();
11
+
12
+ const themeBackgroundColor = React.useMemo(
13
+ () => theme.app_background_color,
14
+ [theme.app_background_color]
15
+ );
16
+
17
+ const backgroundColor = ifEmptyUseFallback(
18
+ screenBackgroundColor,
19
+ themeBackgroundColor
20
+ );
21
+
22
+ return backgroundColor;
23
+ };
@@ -5,7 +5,7 @@ import { useNestedNavigationContext } from "@applicaster/zapp-react-native-ui-co
5
5
  import { useNavigation } from "../navigation/useNavigation";
6
6
 
7
7
  import { ScreenContext } from "@applicaster/zapp-react-native-ui-components/Contexts/ScreenContext";
8
- import { ScreenDataContext } from "@applicaster/zapp-react-native-ui-components/Components/Layout/TV";
8
+ import { ScreenDataContext } from "@applicaster/zapp-react-native-ui-components/Contexts/ScreenDataContext";
9
9
 
10
10
  export function useScreenContextV2() {
11
11
  return useContext(ScreenContext);
@@ -45,7 +45,6 @@ export function useSetNavbarState() {
45
45
 
46
46
  export function useScreenContext(): NavigationScreenData {
47
47
  const navigator = useNavigation();
48
-
49
48
  const screenData = useContext(ScreenDataContext);
50
49
 
51
50
  const modalScreenData = navigator?.modalData;
@@ -7,7 +7,7 @@ export const isAnyNil = R.any(R.isNil);
7
7
 
8
8
  export const isNilOrEmpty = R.either(R.isNil, R.isEmpty);
9
9
 
10
- export const isNotEmpty = R.both(isNotNil, R.complement(R.isEmpty));
10
+ export const isNotEmpty = R.complement(R.isEmpty);
11
11
 
12
12
  export const withoutNil = R.reject(R.isNil);
13
13
 
@@ -108,3 +108,107 @@ export const isAndroidPlatform = () => Platform.OS === "android";
108
108
  export const isTvOSPlatform = () => getPlatform() === "tvos";
109
109
 
110
110
  export const isAndroidTVPlatform = () => getPlatform() === "android_tv";
111
+
112
+ declare global {
113
+ interface Window {
114
+ VIZIO?: {
115
+ Chromevox: {
116
+ play: (text: string) => void;
117
+ };
118
+ exitApplication: () => void;
119
+ setClosedCaptionHandler: (
120
+ callback: (isCCEnabled: boolean) => void
121
+ ) => void;
122
+ };
123
+ }
124
+ }
125
+
126
+ /**
127
+ * Platforms found in userAgent string, please note that simulators
128
+ * might not have the same agents that the devices have
129
+ */
130
+ export const PLATFORMS = {
131
+ webos: "Web0S",
132
+ tizen: "Tizen",
133
+ samsung: "SMART-TV",
134
+ mac: "Mac",
135
+ win: "Win",
136
+ linux: "Linux",
137
+ iphone: "iPhone",
138
+ android: "Android",
139
+ mobile: "Mobile",
140
+ vizio: "VIZIO",
141
+ smartcast: "SmartCast",
142
+ conjure: "Conjure",
143
+ };
144
+
145
+ /**
146
+ * Simple way of identifying if we have access to the tizen APIs
147
+ */
148
+ export const hasTizen = typeof window?.tizen !== "undefined";
149
+
150
+ /**
151
+ * Simple way of identifying if we have access to the webOS APIs
152
+ */
153
+ export const hasWebOS = typeof window?.webOS !== "undefined";
154
+
155
+ export const getUserAgent = () => window?.navigator?.userAgent;
156
+
157
+ export const isLgPlatform = () => {
158
+ const userAgent = getUserAgent();
159
+
160
+ if (!userAgent) {
161
+ return false;
162
+ }
163
+
164
+ // Note: LG uses the number 0 in their userAgent, possibly because of Palm WebOS
165
+ return hasWebOS || userAgent.includes(PLATFORMS.webos);
166
+ };
167
+
168
+ export const isSamsungPlatform = () => {
169
+ const userAgent = getUserAgent();
170
+
171
+ if (!userAgent) {
172
+ return false;
173
+ }
174
+
175
+ return (
176
+ hasTizen ||
177
+ userAgent.includes(PLATFORMS.samsung) ||
178
+ userAgent.includes(PLATFORMS.tizen)
179
+ );
180
+ };
181
+
182
+ /**
183
+ * Checks if we are on the Vizio platform by using the userAgent string
184
+ *
185
+ * Use this method when you need to identify the platform on runtime
186
+ * before the VIZIO Companion Library has loaded
187
+ */
188
+ export const isVizioPlatform = () => {
189
+ const userAgent = getUserAgent();
190
+
191
+ if (!userAgent) {
192
+ return false;
193
+ }
194
+
195
+ const isVizioAgent =
196
+ userAgent.includes(PLATFORMS.vizio) ||
197
+ userAgent.includes(PLATFORMS.smartcast) ||
198
+ userAgent.includes(PLATFORMS.conjure);
199
+
200
+ return isVizioAgent;
201
+ };
202
+
203
+ /**
204
+ * Checks if we are on the Vizio platform by checking for the global VIZIO object
205
+ * and the VIZIO Companion Library. This method does not use the userAgent string,
206
+ * because it mainly checks whether we have access to apis, which may not be available yet
207
+ */
208
+ export const hasVizioAPIs = () => {
209
+ const hasAPIs =
210
+ typeof window.VIZIO !== "undefined" &&
211
+ window?.applicaster?.vizioLibraryDidLoad;
212
+
213
+ return hasAPIs;
214
+ };
@@ -152,3 +152,8 @@ export function objectToCamelCase(obj) {
152
152
  export function isString(value: unknown): value is string {
153
153
  return typeof value === "string" || value instanceof String;
154
154
  }
155
+
156
+ /** Checks if a value is a non-empty string */
157
+ export function isNotEmptyString(value: unknown): value is string {
158
+ return isString(value) && value.length > 0;
159
+ }
package/types.ts CHANGED
@@ -5,3 +5,7 @@ export type ManifestField<T> = {
5
5
  group?: boolean;
6
6
  fields?: ManifestField<any>[];
7
7
  };
8
+
9
+ export enum ENDPOINT_TAGS {
10
+ allow_missing_keys = "allow_missing_keys",
11
+ }
@@ -1,8 +0,0 @@
1
- export const FOCUSABLE_EVENTS = {
2
- IS_REGISTERED: "isRegistered",
3
- WILL_RECEIVE_FOCUS: "willReceiveFocus",
4
- HAS_RECEIVED_FOCUS: "hasReceivedFocus",
5
- WILL_LOSE_FOCUS: "willLoseFocus",
6
- HAS_LOST_FOCUS: "hasLostFocus",
7
- WILL_UNREGISTER: "willUnregister",
8
- };