@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.
- package/analyticsUtils/AnalyticsEvents/index.ts +13 -0
- package/analyticsUtils/AnalyticsEvents/searchEvents.ts +21 -0
- package/analyticsUtils/AnalyticsEvents/sendShareEvent.ts +21 -0
- package/analyticsUtils/analyticsPlugins.ts +25 -0
- package/analyticsUtils/events.ts +12 -0
- package/analyticsUtils/index.tsx +12 -0
- package/appUtils/accessibilityManager/const.ts +50 -0
- package/appUtils/accessibilityManager/hooks.ts +40 -0
- package/appUtils/accessibilityManager/index.ts +155 -0
- package/appUtils/accessibilityManager/logger.ts +5 -0
- package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +2 -3
- package/appUtils/focusManager/__tests__/focusManager.test.js +4 -24
- package/appUtils/focusManager/__tests__/index.test.ts +2 -3
- package/appUtils/focusManager/index.ts +44 -128
- package/appUtils/focusManager/treeDataStructure/Utils/index.js +14 -38
- package/appUtils/focusManager/utils/index.ts +100 -0
- package/appUtils/focusManagerAux/index.ts +76 -0
- package/appUtils/focusManagerAux/utils/index.ts +100 -0
- package/appUtils/index.js +2 -0
- package/appUtils/keyCodes/keys.web.js +8 -0
- package/appUtils/keyCodes/keysByPlatform.js +11 -1
- package/appUtils/platform/const.ts +25 -0
- package/appUtils/platform/index.ts +3 -0
- package/appUtils/platform/platformUtils.ts +185 -0
- package/appUtils/playerManager/conts.ts +1 -0
- package/appUtils/playerManager/index.ts +11 -5
- package/appUtils/playerManager/nativePlayerManager.ts +12 -0
- package/appUtils/playerManager/player.ts +9 -3
- package/appUtils/playerManager/playerNative.ts +5 -14
- package/appUtils/playerManager/usePlayerControllerSetup.tsx +7 -1
- package/arrayUtils/__tests__/isFilledArray.test.ts +63 -0
- package/arrayUtils/index.ts +5 -0
- package/booleanUtils/index.ts +4 -4
- package/cellUtils/__tests__/cellUtils.test.ts +9 -20
- package/cellUtils/index.ts +11 -17
- package/dateUtils/index.ts +11 -0
- package/headersUtils/index.ts +1 -0
- package/index.d.ts +15 -0
- package/inflatedUrlUtils/index.ts +4 -4
- package/keyboardState/index.ts +0 -0
- package/localizationUtils/__tests__/localizationUtils.test.ts +72 -53
- package/localizationUtils/index.ts +13 -22
- package/navigationUtils/index.ts +48 -0
- package/numberUtils/__tests__/isLikeNumber.test.ts +18 -0
- package/numberUtils/__tests__/toNumber.test.ts +2 -2
- package/numberUtils/index.ts +9 -18
- package/package.json +2 -2
- package/playerUtils/imaScriptDom.ts +59 -0
- package/pluginUtils/index.ts +9 -0
- package/reactHooks/cell-click/__tests__/index.test.js +10 -1
- package/reactHooks/cell-click/index.ts +12 -12
- package/reactHooks/feed/__tests__/useBuildPipesUrl.test.tsx +30 -70
- package/reactHooks/feed/__tests__/useFeedRefresh.test.tsx +6 -2
- package/reactHooks/feed/__tests__/useInflatedUrl.test.ts +18 -3
- package/reactHooks/feed/useBuildPipesUrl.ts +7 -10
- package/reactHooks/feed/useFeedRefresh.tsx +9 -7
- package/reactHooks/feed/useInflatedUrl.ts +44 -15
- package/reactHooks/navigation/__tests__/index.test.tsx +11 -8
- package/reactHooks/navigation/index.ts +46 -68
- package/reactHooks/screen/__tests__/useCurrentScreenData.test.tsx +21 -23
- package/reactHooks/screen/index.ts +2 -0
- package/reactHooks/screen/useScreenBackgroundColor.ts +23 -0
- package/reactHooks/screen/useScreenContext.ts +1 -2
- package/reactUtils/helpers.tsx +1 -1
- package/reactUtils/index.ts +104 -0
- package/stringUtils/index.ts +5 -0
- package/types.ts +4 -0
- package/appUtils/focusManager/FocusableEvents.ts +0 -8
- package/appUtils/focusManager/treeDataStructure/Utils/__tests__/Utils_android.test.js +0 -1094
- 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/
|
|
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;
|
package/reactUtils/helpers.tsx
CHANGED
|
@@ -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.
|
|
10
|
+
export const isNotEmpty = R.complement(R.isEmpty);
|
|
11
11
|
|
|
12
12
|
export const withoutNil = R.reject(R.isNil);
|
|
13
13
|
|
package/reactUtils/index.ts
CHANGED
|
@@ -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
|
+
};
|
package/stringUtils/index.ts
CHANGED
|
@@ -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