@applicaster/zapp-react-native-utils 12.0.0-rc.14 → 12.0.0-rc.141
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/actionsExecutor/ActionExecutorContext.tsx +16 -8
- package/analyticsUtils/AnalyticPlayerListener.ts +141 -0
- package/analyticsUtils/AnalyticsEvents/index.ts +13 -0
- package/analyticsUtils/AnalyticsEvents/searchEvents.ts +21 -0
- package/analyticsUtils/AnalyticsEvents/sendShareEvent.ts +21 -0
- package/analyticsUtils/PlayerAnalyticsManager.ts +90 -0
- package/analyticsUtils/__tests__/analyticsManager.test.js +75 -73
- package/analyticsUtils/analyticsPlugins.ts +25 -0
- package/analyticsUtils/events.ts +12 -0
- package/analyticsUtils/helpers/hooks.ts +1 -1
- package/analyticsUtils/index.tsx +12 -0
- package/analyticsUtils/{analyticsTracker.ts → playerAnalyticsTracker.ts} +19 -10
- package/appUtils/HooksManager/index.js +3 -1
- 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 +76 -57
- package/appUtils/focusManager/treeDataStructure/Utils/index.js +75 -35
- 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/__tests__/__snapshots__/keyCodes.test.js.snap +1 -1
- package/appUtils/keyCodes/__tests__/keyCodes.test.js +80 -85
- package/appUtils/keyCodes/keys.web.js +9 -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 +218 -0
- package/appUtils/playerManager/OverlayObserver/OverlaysObserver.ts +53 -0
- package/appUtils/playerManager/conts.ts +6 -0
- package/appUtils/playerManager/index.ts +20 -32
- package/appUtils/playerManager/nativePlayerManager.ts +12 -0
- package/appUtils/playerManager/player.ts +56 -7
- package/appUtils/playerManager/playerFactory.ts +20 -5
- package/appUtils/playerManager/playerHooks/usePlayerCurrentTime.tsx +57 -0
- package/appUtils/playerManager/playerNative.ts +41 -15
- package/appUtils/playerManager/usePlayerControllerSetup.tsx +8 -2
- package/appUtils/playerManager/usePlayerState.tsx +20 -23
- package/appUtils/playerManager/usePlayerTitleSummaryOverlay.tsx +50 -0
- package/arrayUtils/__tests__/isFilledArray.test.ts +63 -0
- package/arrayUtils/index.ts +16 -0
- package/booleanUtils/index.ts +4 -4
- package/cellUtils/__tests__/cellUtils.test.ts +48 -0
- package/cellUtils/__tests__/fixtures.ts +13 -0
- package/cellUtils/index.ts +78 -7
- package/dateUtils/index.ts +11 -0
- package/focusManager/FocusManager.ts +20 -5
- package/focusManager/__tests__/FocusManager.test.ts +0 -1
- package/focusManager/index.ts +1 -1
- package/functionUtils/__tests__/__snapshots__/functionUtils.test.js.snap +2 -2
- package/functionUtils/__tests__/functionUtils.test.js +244 -248
- package/functionUtils/index.ts +38 -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 +78 -55
- package/localizationUtils/index.ts +13 -19
- package/logger/index.ts +1 -1
- package/manifestUtils/defaultManifestConfigurations/generalContent.js +6 -0
- package/manifestUtils/defaultManifestConfigurations/player.js +131 -1
- package/manifestUtils/index.js +5 -1
- package/manifestUtils/keys.js +2 -1
- package/manifestUtils/secondaryImage/index.js +18 -15
- package/modalState/index.ts +57 -0
- package/navigationUtils/index.ts +105 -8
- package/numberUtils/__tests__/isLikeNumber.test.ts +18 -0
- package/numberUtils/__tests__/toNumber.test.ts +2 -2
- package/numberUtils/__tests__/toPositiveNumberWithDefault.test.ts +66 -0
- package/numberUtils/__tests__/toPositiveNumberWithDefaultZero.test.ts +66 -0
- package/numberUtils/index.ts +27 -16
- package/package.json +3 -2
- package/playerUtils/configurationGenerator.ts +131 -1
- package/playerUtils/imaScriptDom.ts +59 -0
- package/pluginUtils/index.ts +20 -7
- package/reactHooks/autoscrolling/__tests__/useTrackCurrentAutoScrollingElement.test.ts +2 -0
- package/reactHooks/autoscrolling/__tests__/{useTrackedView.test.ts → useTrackedView.test.tsx} +18 -1
- package/reactHooks/cell-click/__tests__/index.test.js +16 -3
- package/reactHooks/cell-click/index.ts +30 -16
- package/reactHooks/debugging/__tests__/index.test.js +81 -11
- package/reactHooks/feed/__tests__/useBatchLoading.test.tsx +69 -6
- 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/useBatchLoading.ts +52 -28
- package/reactHooks/feed/useBuildPipesUrl.ts +7 -10
- package/reactHooks/feed/useFeedRefresh.tsx +9 -7
- package/reactHooks/feed/useInflatedUrl.ts +44 -15
- package/reactHooks/flatList/useLoadNextPageIfNeeded.ts +16 -9
- package/reactHooks/index.ts +2 -0
- package/reactHooks/layout/__tests__/{index.test.js → index.test.tsx} +66 -59
- package/reactHooks/layout/getDeviceInfo/index.ts +4 -2
- package/reactHooks/layout/types/index.ts +2 -0
- package/reactHooks/layout/useDimensions/__tests__/useDimensions.test.ts +134 -0
- package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.native.test.js +11 -16
- package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.test.js +12 -14
- package/reactHooks/layout/useDimensions/useDimensions.ts +15 -7
- package/reactHooks/navigation/__mocks__/index.ts +15 -0
- package/reactHooks/navigation/__mocks__/useNavigation.ts +7 -0
- package/reactHooks/navigation/__tests__/index.test.tsx +240 -81
- package/reactHooks/navigation/index.ts +240 -81
- package/reactHooks/player/useAutoSeek.tsx +9 -7
- package/reactHooks/resolvers/__tests__/useCellResolver.test.tsx +3 -1
- package/reactHooks/resolvers/useCellResolver.ts +5 -1
- package/reactHooks/screen/__mocks__/useScreenContext.ts +3 -1
- package/reactHooks/screen/__tests__/useCurrentScreenData.test.tsx +21 -23
- package/reactHooks/screen/index.ts +4 -0
- package/reactHooks/screen/useScreenBackgroundColor.ts +23 -0
- package/reactHooks/screen/useScreenContext.ts +4 -4
- package/reactHooks/screen/useScreenData.ts +1 -1
- package/reactHooks/screen/useTargetScreenData.ts +7 -0
- package/reactHooks/state/useRivers.ts +3 -1
- package/reactHooks/useConfiguration.ts +2 -2
- package/reactHooks/useListenEventBusEvent.ts +1 -4
- package/reactHooks/videoModal/hooks/useVideoModalScreenData.tsx +10 -9
- package/reactUtils/index.ts +104 -0
- package/riverComponetsMeasurementProvider/index.tsx +2 -2
- package/services/localStorageServiceSync.web.ts +48 -0
- package/services/sessionStorageServiceSync.web.ts +32 -0
- package/services/storageServiceSync.web.ts +24 -0
- package/services/storageWebUtils.web.ts +10 -0
- package/stringUtils/index.ts +5 -0
- package/testUtils/getByTestId.ts +14 -0
- package/testUtils/index.tsx +71 -23
- 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
package/navigationUtils/index.ts
CHANGED
|
@@ -93,19 +93,68 @@ export function resolveNavigationPlugin({
|
|
|
93
93
|
* @param {Object} navigator to look for navigation props
|
|
94
94
|
* @param {String} category to look for in screen navigations
|
|
95
95
|
* @returns {Object} props
|
|
96
|
+
* @deprecated use getNavigationPropsV2 instead
|
|
96
97
|
*/
|
|
97
98
|
export function getNavigationProps({
|
|
98
|
-
navigator
|
|
99
|
+
navigator,
|
|
99
100
|
title = "",
|
|
100
101
|
category,
|
|
101
102
|
}: {
|
|
102
103
|
navigator: QuickBrickAppNavigator;
|
|
103
104
|
title: string;
|
|
104
105
|
category: string;
|
|
105
|
-
}):
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
}): {
|
|
107
|
+
selected: string;
|
|
108
|
+
title: string;
|
|
109
|
+
home: boolean;
|
|
110
|
+
styles: unknown;
|
|
111
|
+
assets: ZappNavBarAssets;
|
|
112
|
+
rules: ZappNavBarRules;
|
|
113
|
+
nav_items: NavBarItem[];
|
|
114
|
+
} | null {
|
|
115
|
+
const { activeRiver } = navigator;
|
|
116
|
+
const { navigations, id: selected, home } = activeRiver; // use useRiver hook instead
|
|
117
|
+
|
|
118
|
+
const navigation: ZappNavigation = R.find(
|
|
119
|
+
R.propEq("category", category),
|
|
120
|
+
navigations
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
if (!navigation) {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const { styles, assets, nav_items, rules } = navigation;
|
|
128
|
+
|
|
129
|
+
return {
|
|
130
|
+
selected,
|
|
131
|
+
title,
|
|
132
|
+
home,
|
|
133
|
+
styles,
|
|
134
|
+
assets: assets as ZappNavBarAssets,
|
|
135
|
+
nav_items: nav_items as any as NavBarItem[],
|
|
136
|
+
rules: rules as any as ZappNavBarRules,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export function getNavigationPropsV2({
|
|
141
|
+
currentRiver,
|
|
142
|
+
title = "",
|
|
143
|
+
category,
|
|
144
|
+
}: {
|
|
145
|
+
currentRiver: ZappRiver;
|
|
146
|
+
title: string;
|
|
147
|
+
category: string;
|
|
148
|
+
}): {
|
|
149
|
+
selected: string;
|
|
150
|
+
title: string;
|
|
151
|
+
home: boolean;
|
|
152
|
+
styles: unknown;
|
|
153
|
+
assets: ZappNavBarAssets;
|
|
154
|
+
rules: ZappNavBarRules;
|
|
155
|
+
nav_items: NavBarItem[];
|
|
156
|
+
} | null {
|
|
157
|
+
const { navigations, id: selected, home } = currentRiver; // use useRiver hook instead
|
|
109
158
|
const navigation = R.find(R.propEq("category", category), navigations);
|
|
110
159
|
|
|
111
160
|
if (!navigation) {
|
|
@@ -170,7 +219,7 @@ export function getScreenIdForContentType(payload, contentTypes) {
|
|
|
170
219
|
export function getItemTargetId(
|
|
171
220
|
item: ZappEntry | ZappRiver,
|
|
172
221
|
screenType?: string, // todo: creat screen types enum
|
|
173
|
-
contentTypes?: ZappContentTypes,
|
|
222
|
+
contentTypes?: ZappContentTypes | null,
|
|
174
223
|
rivers?: Record<string, ZappRiver>
|
|
175
224
|
) {
|
|
176
225
|
// Pipes v2 resolution
|
|
@@ -214,10 +263,10 @@ export function getTargetRoute(
|
|
|
214
263
|
pathname = "",
|
|
215
264
|
{
|
|
216
265
|
contentTypes = undefined,
|
|
217
|
-
layoutVersion =
|
|
266
|
+
layoutVersion = "v2",
|
|
218
267
|
rivers = {},
|
|
219
268
|
}: {
|
|
220
|
-
contentTypes?: ZappContentTypes;
|
|
269
|
+
contentTypes?: ZappContentTypes | null;
|
|
221
270
|
layoutVersion?: Maybe<ZappLayoutVersions>;
|
|
222
271
|
rivers?: Record<string, ZappRiver>;
|
|
223
272
|
} = {}
|
|
@@ -543,3 +592,51 @@ export function isMenuDisabled(
|
|
|
543
592
|
export function routeIsPlayerScreen(currentRoute) {
|
|
544
593
|
return currentRoute?.includes("/playable");
|
|
545
594
|
}
|
|
595
|
+
|
|
596
|
+
export const getNavBarProps =
|
|
597
|
+
(currentRiver: ZappRiver, pathname: string, title: string) => () => {
|
|
598
|
+
const props = getNavigationPropsV2({
|
|
599
|
+
currentRiver,
|
|
600
|
+
title,
|
|
601
|
+
category: "nav_bar",
|
|
602
|
+
});
|
|
603
|
+
|
|
604
|
+
if (props) {
|
|
605
|
+
return {
|
|
606
|
+
...props,
|
|
607
|
+
id: pathname,
|
|
608
|
+
pathname: pathname,
|
|
609
|
+
};
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
return null;
|
|
613
|
+
};
|
|
614
|
+
|
|
615
|
+
export const findMenuPlugin = (
|
|
616
|
+
navigations: ZappNavigation[],
|
|
617
|
+
plugins
|
|
618
|
+
): QuickBrickPlugin => {
|
|
619
|
+
return resolveNavigationPlugin({
|
|
620
|
+
category: "menu",
|
|
621
|
+
navigations,
|
|
622
|
+
plugins,
|
|
623
|
+
}) as QuickBrickPlugin;
|
|
624
|
+
};
|
|
625
|
+
|
|
626
|
+
export const shouldNavBarDisplayMenu = (currentRiver: ZappRiver, plugins) =>
|
|
627
|
+
findMenuPlugin(currentRiver.navigations, plugins)?.identifier ===
|
|
628
|
+
"quick_brick_side_menu" ||
|
|
629
|
+
currentRiver?.navigations.findIndex(
|
|
630
|
+
(nav) => nav.category === "nav_bar" && nav.general?.override_menu_target
|
|
631
|
+
) > -1;
|
|
632
|
+
|
|
633
|
+
export const getScreenId = (
|
|
634
|
+
screenData: LegacyNavigationScreenData,
|
|
635
|
+
fallbackRiver: ZappRiver
|
|
636
|
+
) => {
|
|
637
|
+
return screenData?.targetScreen
|
|
638
|
+
? screenData?.targetScreen?.id ?? fallbackRiver.id
|
|
639
|
+
: "screen_id" in screenData
|
|
640
|
+
? screenData.screen_id
|
|
641
|
+
: fallbackRiver.id;
|
|
642
|
+
};
|
|
@@ -7,12 +7,24 @@ describe("isLikeNumber", () => {
|
|
|
7
7
|
expect(isLikeNumber(value)).toBe(true);
|
|
8
8
|
});
|
|
9
9
|
|
|
10
|
+
it("value is a number", () => {
|
|
11
|
+
const value = 123.45;
|
|
12
|
+
|
|
13
|
+
expect(isLikeNumber(value)).toBe(true);
|
|
14
|
+
});
|
|
15
|
+
|
|
10
16
|
it("value is a string as number", () => {
|
|
11
17
|
const value = "123";
|
|
12
18
|
|
|
13
19
|
expect(isLikeNumber(value)).toBe(true);
|
|
14
20
|
});
|
|
15
21
|
|
|
22
|
+
it("value is a string as number", () => {
|
|
23
|
+
const value = "123.45";
|
|
24
|
+
|
|
25
|
+
expect(isLikeNumber(value)).toBe(true);
|
|
26
|
+
});
|
|
27
|
+
|
|
16
28
|
it("value is empty string", () => {
|
|
17
29
|
const value = "";
|
|
18
30
|
|
|
@@ -54,4 +66,10 @@ describe("isLikeNumber", () => {
|
|
|
54
66
|
|
|
55
67
|
expect(isLikeNumber(value)).toBe(false);
|
|
56
68
|
});
|
|
69
|
+
|
|
70
|
+
it("NaN is not a number", () => {
|
|
71
|
+
const value = NaN;
|
|
72
|
+
|
|
73
|
+
expect(isLikeNumber(value)).toBe(false);
|
|
74
|
+
});
|
|
57
75
|
});
|
|
@@ -2,7 +2,7 @@ import { toNumber } from "..";
|
|
|
2
2
|
|
|
3
3
|
describe("toNumber", () => {
|
|
4
4
|
it("return number if input is number", () => {
|
|
5
|
-
const inputs = [-1, 0, 1, 100];
|
|
5
|
+
const inputs = [-1, 0, 1, 100, 0.2];
|
|
6
6
|
expect.assertions(inputs.length);
|
|
7
7
|
|
|
8
8
|
inputs.forEach((input) => {
|
|
@@ -12,7 +12,7 @@ describe("toNumber", () => {
|
|
|
12
12
|
});
|
|
13
13
|
|
|
14
14
|
it("return number if input is string as number", () => {
|
|
15
|
-
const inputs = ["-1", "0", "1", "100"];
|
|
15
|
+
const inputs = ["-1", "0", "1", "100", "0.2"];
|
|
16
16
|
expect.assertions(inputs.length);
|
|
17
17
|
|
|
18
18
|
inputs.forEach((input) => {
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { toPositiveNumberWithDefault } from "..";
|
|
2
|
+
|
|
3
|
+
describe("toNumber", () => {
|
|
4
|
+
const DEFAULT = 5;
|
|
5
|
+
|
|
6
|
+
it("return number if input is positive number", () => {
|
|
7
|
+
const inputs = [0, 1, 2, 100, 200.12, Infinity];
|
|
8
|
+
expect.assertions(inputs.length);
|
|
9
|
+
|
|
10
|
+
inputs.forEach((input) => {
|
|
11
|
+
const output = toPositiveNumberWithDefault(DEFAULT, input);
|
|
12
|
+
expect(output).toBe(input);
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("return number if input is positive number as string", () => {
|
|
17
|
+
const inputs = ["0", "1", "2", "100", "200.12"];
|
|
18
|
+
expect.assertions(inputs.length);
|
|
19
|
+
|
|
20
|
+
inputs.forEach((input) => {
|
|
21
|
+
const output = toPositiveNumberWithDefault(DEFAULT, input);
|
|
22
|
+
expect(output).toBe(Number(input));
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("return default number if input is negative number", () => {
|
|
27
|
+
const inputs = [-1, -2, -100, -Infinity];
|
|
28
|
+
expect.assertions(inputs.length);
|
|
29
|
+
|
|
30
|
+
inputs.forEach((input) => {
|
|
31
|
+
const output = toPositiveNumberWithDefault(DEFAULT, input);
|
|
32
|
+
expect(output).toBe(DEFAULT);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("return default number if input is negative number as string", () => {
|
|
37
|
+
const inputs = ["-1", "-2", "-100"];
|
|
38
|
+
expect.assertions(inputs.length);
|
|
39
|
+
|
|
40
|
+
inputs.forEach((input) => {
|
|
41
|
+
const output = toPositiveNumberWithDefault(DEFAULT, input);
|
|
42
|
+
expect(output).toBe(DEFAULT);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("return default if input is not a number or infinite", () => {
|
|
47
|
+
const inputs = [
|
|
48
|
+
"vfdvf",
|
|
49
|
+
null,
|
|
50
|
+
undefined,
|
|
51
|
+
NaN,
|
|
52
|
+
"",
|
|
53
|
+
{},
|
|
54
|
+
{ test: 1 },
|
|
55
|
+
[],
|
|
56
|
+
[1],
|
|
57
|
+
];
|
|
58
|
+
|
|
59
|
+
expect.assertions(inputs.length);
|
|
60
|
+
|
|
61
|
+
inputs.forEach((input) => {
|
|
62
|
+
const output = toPositiveNumberWithDefault(DEFAULT, input);
|
|
63
|
+
expect(output).toBe(DEFAULT);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { toPositiveNumberWithDefaultZero } from "..";
|
|
2
|
+
|
|
3
|
+
const DEFAULT = 0;
|
|
4
|
+
|
|
5
|
+
describe("toNumber", () => {
|
|
6
|
+
it("return number if input is positive number", () => {
|
|
7
|
+
const inputs = [0, 1, 2, 100, 200.12];
|
|
8
|
+
expect.assertions(inputs.length);
|
|
9
|
+
|
|
10
|
+
inputs.forEach((input) => {
|
|
11
|
+
const output = toPositiveNumberWithDefaultZero(input);
|
|
12
|
+
expect(output).toBe(input);
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("return number if input is positive number as string", () => {
|
|
17
|
+
const inputs = ["0", "1", "2", "100", "200.12"];
|
|
18
|
+
expect.assertions(inputs.length);
|
|
19
|
+
|
|
20
|
+
inputs.forEach((input) => {
|
|
21
|
+
const output = toPositiveNumberWithDefaultZero(input);
|
|
22
|
+
expect(output).toBe(Number(input));
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("return default number if input is negative number", () => {
|
|
27
|
+
const inputs = [-1, -2, -100];
|
|
28
|
+
expect.assertions(inputs.length);
|
|
29
|
+
|
|
30
|
+
inputs.forEach((input) => {
|
|
31
|
+
const output = toPositiveNumberWithDefaultZero(input);
|
|
32
|
+
expect(output).toBe(DEFAULT);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("return default number if input is negative number as string", () => {
|
|
37
|
+
const inputs = ["-1", "-2", "-100"];
|
|
38
|
+
expect.assertions(inputs.length);
|
|
39
|
+
|
|
40
|
+
inputs.forEach((input) => {
|
|
41
|
+
const output = toPositiveNumberWithDefaultZero(input);
|
|
42
|
+
expect(output).toBe(DEFAULT);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("return default if input is not a number or infinite", () => {
|
|
47
|
+
const inputs = [
|
|
48
|
+
"vfdvf",
|
|
49
|
+
null,
|
|
50
|
+
undefined,
|
|
51
|
+
NaN,
|
|
52
|
+
"",
|
|
53
|
+
{},
|
|
54
|
+
{ test: 1 },
|
|
55
|
+
[],
|
|
56
|
+
[1],
|
|
57
|
+
];
|
|
58
|
+
|
|
59
|
+
expect.assertions(inputs.length);
|
|
60
|
+
|
|
61
|
+
inputs.forEach((input) => {
|
|
62
|
+
const output = toPositiveNumberWithDefaultZero(input);
|
|
63
|
+
expect(output).toBe(DEFAULT);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
});
|
package/numberUtils/index.ts
CHANGED
|
@@ -50,28 +50,39 @@ export const toFiniteNumberWithDefault = (
|
|
|
50
50
|
return possibleNumber;
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
-
export const isLikeNumber = (value:
|
|
54
|
-
|
|
53
|
+
export const isLikeNumber = (value: unknown): boolean => {
|
|
54
|
+
const possibleNumber = toNumber(value);
|
|
55
|
+
|
|
56
|
+
if (R.isNil(possibleNumber)) {
|
|
55
57
|
return false;
|
|
56
58
|
}
|
|
57
59
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
60
|
+
return true;
|
|
61
|
+
};
|
|
61
62
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
.split("")
|
|
65
|
-
.filter((char) =>
|
|
66
|
-
["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"].includes(char)
|
|
67
|
-
)
|
|
68
|
-
.join("");
|
|
63
|
+
export const isZero = (value: unknown): boolean =>
|
|
64
|
+
Object.is(value, -0) || Object.is(value, 0);
|
|
69
65
|
|
|
70
|
-
|
|
66
|
+
export const isMinusZero = (value: number) => {
|
|
67
|
+
return 1 / value === -Infinity;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export const toPositiveNumberWithDefault = (
|
|
71
|
+
defaultValue: number,
|
|
72
|
+
value: unknown
|
|
73
|
+
): number => {
|
|
74
|
+
const possibleNumber = toNumber(value);
|
|
75
|
+
|
|
76
|
+
if (R.isNil(possibleNumber)) {
|
|
77
|
+
return defaultValue;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (possibleNumber < 0) {
|
|
81
|
+
return defaultValue;
|
|
71
82
|
}
|
|
72
83
|
|
|
73
|
-
return
|
|
84
|
+
return possibleNumber;
|
|
74
85
|
};
|
|
75
86
|
|
|
76
|
-
export const
|
|
77
|
-
|
|
87
|
+
export const toPositiveNumberWithDefaultZero = (value: unknown): number =>
|
|
88
|
+
toPositiveNumberWithDefault(0, value);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-utils",
|
|
3
|
-
"version": "12.0.0-rc.
|
|
3
|
+
"version": "12.0.0-rc.141",
|
|
4
4
|
"description": "Applicaster Zapp React Native utilities package",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@applicaster/applicaster-types": "12.0.0-rc.
|
|
31
|
+
"@applicaster/applicaster-types": "12.0.0-rc.141",
|
|
32
32
|
"buffer": "^5.2.1",
|
|
33
33
|
"camelize": "^1.0.0",
|
|
34
34
|
"create-react-context": "^0.2.3",
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"immer": "*",
|
|
45
45
|
"react": "17.0.2",
|
|
46
46
|
"react-native": "0.68.6",
|
|
47
|
+
"validate-color": "*",
|
|
47
48
|
"zustand": "*"
|
|
48
49
|
},
|
|
49
50
|
"devDependencies": {
|
|
@@ -22,6 +22,7 @@ function getDevice(platform) {
|
|
|
22
22
|
case "android_tv_for_quickbrick":
|
|
23
23
|
case "lg_tv":
|
|
24
24
|
case "samsung_tv":
|
|
25
|
+
case "vizio":
|
|
25
26
|
case "web":
|
|
26
27
|
return "tv";
|
|
27
28
|
}
|
|
@@ -46,6 +47,14 @@ function getPlayerConfiguration({ platform }) {
|
|
|
46
47
|
label_tooltip:
|
|
47
48
|
"Enable if you want to have adaptive background gradient based on audio background image.",
|
|
48
49
|
},
|
|
50
|
+
{
|
|
51
|
+
key: "audio_player_background_image_query",
|
|
52
|
+
label: "Audio Player Image Query",
|
|
53
|
+
initial_value: "",
|
|
54
|
+
type: "text_input",
|
|
55
|
+
label_tooltip:
|
|
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
|
+
},
|
|
49
58
|
],
|
|
50
59
|
};
|
|
51
60
|
|
|
@@ -1651,7 +1660,8 @@ function getPlayerConfiguration({ platform }) {
|
|
|
1651
1660
|
platform.includes("lg") ||
|
|
1652
1661
|
platform.includes("samsung") ||
|
|
1653
1662
|
platform.includes("android_tv") ||
|
|
1654
|
-
platform.includes("amazon")
|
|
1663
|
+
platform.includes("amazon") ||
|
|
1664
|
+
platform.includes("vizio")
|
|
1655
1665
|
) {
|
|
1656
1666
|
styles.fields.push(
|
|
1657
1667
|
// Captions Menu for TV
|
|
@@ -1788,6 +1798,30 @@ function getPlayerConfiguration({ platform }) {
|
|
|
1788
1798
|
key: "menu_header_samsung_letter_spacing",
|
|
1789
1799
|
initial_value: 0,
|
|
1790
1800
|
},
|
|
1801
|
+
{
|
|
1802
|
+
type: "vizio_font_selector",
|
|
1803
|
+
label: "Vizio Font Family",
|
|
1804
|
+
key: "menu_header_vizio_font_family",
|
|
1805
|
+
initial_value: "Ubuntu-Bold",
|
|
1806
|
+
},
|
|
1807
|
+
{
|
|
1808
|
+
type: "number_input",
|
|
1809
|
+
label: "Vizio Font Size",
|
|
1810
|
+
key: "menu_header_vizio_font_size",
|
|
1811
|
+
initial_value: 30,
|
|
1812
|
+
},
|
|
1813
|
+
{
|
|
1814
|
+
type: "number_input",
|
|
1815
|
+
label: "Vizio Line Height",
|
|
1816
|
+
key: "menu_header_vizio_line_height",
|
|
1817
|
+
initial_value: 60,
|
|
1818
|
+
},
|
|
1819
|
+
{
|
|
1820
|
+
type: "number_input",
|
|
1821
|
+
label: "Vizio Letter Spacing",
|
|
1822
|
+
key: "menu_header_vizio_letter_spacing",
|
|
1823
|
+
initial_value: 0,
|
|
1824
|
+
},
|
|
1791
1825
|
]
|
|
1792
1826
|
),
|
|
1793
1827
|
// Captions Menu - Item Text Label
|
|
@@ -1867,6 +1901,30 @@ function getPlayerConfiguration({ platform }) {
|
|
|
1867
1901
|
key: "menu_item_samsung_letter_spacing",
|
|
1868
1902
|
initial_value: 0,
|
|
1869
1903
|
},
|
|
1904
|
+
{
|
|
1905
|
+
type: "vizio_font_selector",
|
|
1906
|
+
label: "Vizio Font Family",
|
|
1907
|
+
key: "menu_item_vizio_font_family",
|
|
1908
|
+
initial_value: "Ubuntu-Medium",
|
|
1909
|
+
},
|
|
1910
|
+
{
|
|
1911
|
+
type: "number_input",
|
|
1912
|
+
label: "Vizio Font Size",
|
|
1913
|
+
key: "menu_item_vizio_font_size",
|
|
1914
|
+
initial_value: 25,
|
|
1915
|
+
},
|
|
1916
|
+
{
|
|
1917
|
+
type: "number_input",
|
|
1918
|
+
label: "Vizio Line Height",
|
|
1919
|
+
key: "menu_item_vizio_line_height",
|
|
1920
|
+
initial_value: 40,
|
|
1921
|
+
},
|
|
1922
|
+
{
|
|
1923
|
+
type: "number_input",
|
|
1924
|
+
label: "Vizio Letter Spacing",
|
|
1925
|
+
key: "menu_item_vizio_letter_spacing",
|
|
1926
|
+
initial_value: 0,
|
|
1927
|
+
},
|
|
1870
1928
|
]
|
|
1871
1929
|
),
|
|
1872
1930
|
// Captions Menu - Item Border
|
|
@@ -2010,6 +2068,18 @@ function getPlayerConfiguration({ platform }) {
|
|
|
2010
2068
|
key: "samsung_tv_video_player_title_font_size",
|
|
2011
2069
|
initial_value: 58,
|
|
2012
2070
|
},
|
|
2071
|
+
{
|
|
2072
|
+
type: "vizio_font_selector",
|
|
2073
|
+
label: "Vizio Font Family",
|
|
2074
|
+
key: "vizio_video_player_title_font_family",
|
|
2075
|
+
initial_value: "Ubuntu-Bold",
|
|
2076
|
+
},
|
|
2077
|
+
{
|
|
2078
|
+
type: "number_input",
|
|
2079
|
+
label: "Vizio Font Size",
|
|
2080
|
+
key: "vizio_video_player_title_font_size",
|
|
2081
|
+
initial_value: 58,
|
|
2082
|
+
},
|
|
2013
2083
|
{
|
|
2014
2084
|
type: "tvos_font_selector",
|
|
2015
2085
|
label: "tvOS Font Family",
|
|
@@ -2083,6 +2153,18 @@ function getPlayerConfiguration({ platform }) {
|
|
|
2083
2153
|
key: "samsung_tv_video_player_summary_font_size",
|
|
2084
2154
|
initial_value: 30,
|
|
2085
2155
|
},
|
|
2156
|
+
{
|
|
2157
|
+
type: "vizio_font_selector",
|
|
2158
|
+
label: "Vizio Font Family",
|
|
2159
|
+
key: "vizio_video_player_summary_font_family",
|
|
2160
|
+
initial_value: "Ubuntu-Medium",
|
|
2161
|
+
},
|
|
2162
|
+
{
|
|
2163
|
+
type: "number_input",
|
|
2164
|
+
label: "Vizio Font Size",
|
|
2165
|
+
key: "vizio_video_player_summary_font_size",
|
|
2166
|
+
initial_value: 30,
|
|
2167
|
+
},
|
|
2086
2168
|
{
|
|
2087
2169
|
type: "tvos_font_selector",
|
|
2088
2170
|
label: "tvOS Font Family",
|
|
@@ -2150,6 +2232,18 @@ function getPlayerConfiguration({ platform }) {
|
|
|
2150
2232
|
key: "samsung_tv_audio_player_title_font_size",
|
|
2151
2233
|
initial_value: 40,
|
|
2152
2234
|
},
|
|
2235
|
+
{
|
|
2236
|
+
type: "vizio_font_selector",
|
|
2237
|
+
label: "Vizio Font Family",
|
|
2238
|
+
key: "vizio_audio_player_title_font_family",
|
|
2239
|
+
initial_value: "Ubuntu-Bold",
|
|
2240
|
+
},
|
|
2241
|
+
{
|
|
2242
|
+
type: "number_input",
|
|
2243
|
+
label: "Vizio Font Size",
|
|
2244
|
+
key: "vizio_audio_player_title_font_size",
|
|
2245
|
+
initial_value: 40,
|
|
2246
|
+
},
|
|
2153
2247
|
{
|
|
2154
2248
|
type: "tvos_font_selector",
|
|
2155
2249
|
label: "tvOS Font Family",
|
|
@@ -2205,6 +2299,18 @@ function getPlayerConfiguration({ platform }) {
|
|
|
2205
2299
|
key: "samsung_tv_audio_player_summary_font_size",
|
|
2206
2300
|
initial_value: 22,
|
|
2207
2301
|
},
|
|
2302
|
+
{
|
|
2303
|
+
type: "vizio_font_selector",
|
|
2304
|
+
label: "Vizio Font Family",
|
|
2305
|
+
key: "vizio_audio_player_summary_font_family",
|
|
2306
|
+
initial_value: "Ubuntu-Medium",
|
|
2307
|
+
},
|
|
2308
|
+
{
|
|
2309
|
+
type: "number_input",
|
|
2310
|
+
label: "Vizio Font Size",
|
|
2311
|
+
key: "vizio_audio_player_summary_font_size",
|
|
2312
|
+
initial_value: 22,
|
|
2313
|
+
},
|
|
2208
2314
|
{
|
|
2209
2315
|
type: "tvos_font_selector",
|
|
2210
2316
|
label: "tvOS Font Family",
|
|
@@ -2260,6 +2366,18 @@ function getPlayerConfiguration({ platform }) {
|
|
|
2260
2366
|
key: "samsung_tv_player_time_font_size",
|
|
2261
2367
|
initial_value: 20,
|
|
2262
2368
|
},
|
|
2369
|
+
{
|
|
2370
|
+
type: "vizio_font_selector",
|
|
2371
|
+
label: "Vizio Font Family",
|
|
2372
|
+
key: "vizio_player_time_font_family",
|
|
2373
|
+
initial_value: "Ubuntu-Medium",
|
|
2374
|
+
},
|
|
2375
|
+
{
|
|
2376
|
+
type: "number_input",
|
|
2377
|
+
label: "Vizio Font Size",
|
|
2378
|
+
key: "vizio_player_time_font_size",
|
|
2379
|
+
initial_value: 20,
|
|
2380
|
+
},
|
|
2263
2381
|
{
|
|
2264
2382
|
type: "android_font_selector",
|
|
2265
2383
|
label: "Android TV Font Family",
|
|
@@ -2315,6 +2433,18 @@ function getPlayerConfiguration({ platform }) {
|
|
|
2315
2433
|
key: "samsung_tv_audio_player_run_time_font_size",
|
|
2316
2434
|
initial_value: 20,
|
|
2317
2435
|
},
|
|
2436
|
+
{
|
|
2437
|
+
type: "vizio_font_selector",
|
|
2438
|
+
label: "Vizio Font Family",
|
|
2439
|
+
key: "vizio_audio_player_run_time_font_family",
|
|
2440
|
+
initial_value: "Ubuntu-Medium",
|
|
2441
|
+
},
|
|
2442
|
+
{
|
|
2443
|
+
type: "number_input",
|
|
2444
|
+
label: "Vizio Font Size",
|
|
2445
|
+
key: "vizio_audio_player_run_time_font_size",
|
|
2446
|
+
initial_value: 20,
|
|
2447
|
+
},
|
|
2318
2448
|
{
|
|
2319
2449
|
type: "tvos_font_selector",
|
|
2320
2450
|
label: "tvOS Font Family",
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { createLogger } from "../logger";
|
|
2
|
+
|
|
3
|
+
export const logger = createLogger({
|
|
4
|
+
category: "ImaDomUtils",
|
|
5
|
+
subsystem: "Player/ImaDomUtils",
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
const { log_debug, log_error, log_verbose } = logger;
|
|
9
|
+
|
|
10
|
+
const removeElement = (node) => {
|
|
11
|
+
if (node) {
|
|
12
|
+
const parentNode = node.parentNode;
|
|
13
|
+
|
|
14
|
+
if (parentNode) {
|
|
15
|
+
parentNode.removeChild(node);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
// TODO: This should probably be loaded to root of project before player init
|
|
21
|
+
export const loadIMAScript = async () => {
|
|
22
|
+
return new Promise((resolve) => {
|
|
23
|
+
// If ima script is already loaded, resolve
|
|
24
|
+
const imaScript = document.getElementById("ima-script");
|
|
25
|
+
|
|
26
|
+
if (imaScript) {
|
|
27
|
+
log_verbose("loadIMAScript: IMA script already loaded");
|
|
28
|
+
|
|
29
|
+
return resolve(true);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const script = document.createElement("script");
|
|
33
|
+
|
|
34
|
+
if (__DEV__) {
|
|
35
|
+
script.src = "https://imasdk.googleapis.com/js/sdkloader/ima3_debug.js";
|
|
36
|
+
} else {
|
|
37
|
+
script.src = "https://imasdk.googleapis.com/js/sdkloader/ima3.js";
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
script.async = true;
|
|
41
|
+
script.id = "ima-script";
|
|
42
|
+
|
|
43
|
+
script.onload = () => {
|
|
44
|
+
removeElement(script);
|
|
45
|
+
log_debug("loadIMAScript: Loaded ima script", script.src);
|
|
46
|
+
resolve(true);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
script.onerror = (_e) => {
|
|
50
|
+
removeElement(script);
|
|
51
|
+
log_error("loadIMAScript: Failed to load ima script", script.src);
|
|
52
|
+
resolve(false);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
if (document.head) {
|
|
56
|
+
document.head.appendChild(script);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
};
|