@applicaster/zapp-react-native-utils 12.0.0-rc.99 → 13.0.0-alpha.2322412833
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/AnalyticPlayerListener.ts +141 -0
- package/analyticsUtils/PlayerAnalyticsManager.ts +90 -0
- package/analyticsUtils/{analyticsTracker.ts → playerAnalyticsTracker.ts} +19 -10
- package/appUtils/HooksManager/{Hook.js → Hook.ts} +35 -23
- package/appUtils/HooksManager/__tests__/__snapshots__/hook.test.js.snap +4 -2
- package/appUtils/HooksManager/__tests__/__snapshots__/hooksManager.test.js.snap +693 -0
- package/appUtils/HooksManager/__tests__/hook.test.js +196 -184
- package/appUtils/HooksManager/__tests__/hooksManager.test.js +96 -99
- package/appUtils/HooksManager/{constants.js → constants.ts} +1 -1
- package/appUtils/HooksManager/{index.js → index.ts} +121 -112
- package/appUtils/HooksManager/types.ts +116 -0
- package/appUtils/RiverFocusManager/index.js +17 -12
- package/appUtils/accessibilityManager/hooks.ts +16 -7
- package/appUtils/accessibilityManager/index.ts +33 -28
- package/appUtils/focusManager/treeDataStructure/Tree/index.js +2 -3
- package/appUtils/focusManager/treeDataStructure/Utils/index.js +1 -3
- package/appUtils/{index.js → index.ts} +1 -1
- package/appUtils/keyCodes/__tests__/keyCodes.test.js +3 -3
- package/appUtils/keyCodes/{index.js → index.ts} +2 -0
- package/appUtils/keyCodes/keys/index.ts +3 -0
- package/appUtils/keyCodes/{keys.android.js → keys/keyEventMapper.ts} +0 -19
- package/appUtils/keyCodes/keys/keys.android.ts +18 -0
- package/appUtils/keyCodes/keys/keys.ios.ts +25 -0
- package/appUtils/keyCodes/keys/keys.ts +15 -0
- package/appUtils/platform/platformUtils.ts +35 -16
- package/appUtils/playerManager/index.ts +9 -27
- package/appUtils/playerManager/playerFactory.ts +5 -4
- package/appUtils/playerManager/playerHooks/usePlayerCurrentTime.tsx +57 -0
- package/appUtils/playerManager/playerNative.ts +1 -1
- package/appUtils/playerManager/usePlayerControllerSetup.tsx +1 -1
- package/appUtils/playerManager/usePlayerState.tsx +19 -34
- package/arrayUtils/index.ts +11 -0
- package/cellUtils/index.ts +38 -5
- package/domUtils/{cookieManager.js → cookieManager.ts} +1 -2
- package/focusManager/FocusManager.ts +20 -5
- package/focusManager/__tests__/FocusManager.test.ts +0 -1
- package/functionUtils/index.ts +53 -11
- package/index.d.ts +15 -0
- package/manifestUtils/defaultManifestConfigurations/player.js +121 -0
- package/manifestUtils/keys.js +2 -1
- package/modalState/index.ts +1 -5
- package/navigationUtils/index.ts +15 -6
- 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 +20 -0
- package/package.json +2 -2
- package/playerUtils/configurationGenerator.ts +120 -0
- package/playerUtils/imaScriptDom.ts +59 -0
- package/reactHooks/cell-click/index.ts +17 -3
- package/reactHooks/debugging/__tests__/index.test.js +81 -11
- package/reactHooks/feed/__tests__/useBatchLoading.test.tsx +69 -6
- package/reactHooks/feed/__tests__/useFeedLoader.test.tsx +10 -2
- package/reactHooks/feed/useBatchLoading.ts +52 -28
- package/reactHooks/feed/useFeedLoader.tsx +11 -7
- package/reactHooks/layout/useDimensions/__tests__/useDimensions.test.ts +134 -0
- package/reactHooks/layout/useDimensions/useDimensions.ts +2 -0
- package/reactHooks/navigation/index.ts +8 -5
- package/reactHooks/player/useAutoSeek.tsx +9 -7
- package/reactHooks/resolvers/useCellResolver.ts +5 -1
- package/reactHooks/useConfiguration.ts +2 -2
- package/reactHooks/utils/index.ts +13 -0
- package/reactUtils/index.ts +1 -16
- 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/testUtils/index.tsx +42 -9
- package/appUtils/keyCodes/keys.ios.js +0 -46
- /package/appUtils/HooksManager/{logger.js → logger.ts} +0 -0
- /package/appUtils/{directionHelper.js → directionHelper.ts} +0 -0
- /package/appUtils/keyCodes/{androidTVKeys.js → androidTVKeys.ts} +0 -0
- /package/appUtils/keyCodes/{keys.web.js → keys/keys.web.ts} +0 -0
- /package/appUtils/keyCodes/{keysByPlatform.js → keys/keysByPlatform.ts} +0 -0
- /package/appUtils/{localizationsHelper.js → localizationsHelper.ts} +0 -0
- /package/domUtils/{logger.js → logger.ts} +0 -0
package/navigationUtils/index.ts
CHANGED
|
@@ -263,7 +263,7 @@ export function getTargetRoute(
|
|
|
263
263
|
pathname = "",
|
|
264
264
|
{
|
|
265
265
|
contentTypes = undefined,
|
|
266
|
-
layoutVersion =
|
|
266
|
+
layoutVersion = "v2",
|
|
267
267
|
rivers = {},
|
|
268
268
|
}: {
|
|
269
269
|
contentTypes?: ZappContentTypes | null;
|
|
@@ -324,7 +324,13 @@ export function getPathAttributes({
|
|
|
324
324
|
* @param {object} rivers
|
|
325
325
|
* @returns {object}
|
|
326
326
|
*/
|
|
327
|
-
export function getRiverFromRoute({
|
|
327
|
+
export function getRiverFromRoute({
|
|
328
|
+
route,
|
|
329
|
+
rivers,
|
|
330
|
+
}: {
|
|
331
|
+
route: string;
|
|
332
|
+
rivers: Record<string, ZappRiver>;
|
|
333
|
+
}) {
|
|
328
334
|
if (!route) {
|
|
329
335
|
return null;
|
|
330
336
|
}
|
|
@@ -437,7 +443,7 @@ export const runZappHooksForEntry = async (
|
|
|
437
443
|
|
|
438
444
|
let success;
|
|
439
445
|
let payload;
|
|
440
|
-
const rivers = appStore.get("rivers");
|
|
446
|
+
const rivers: Record<string, ZappRiver> = appStore.get("rivers");
|
|
441
447
|
const plugins = appStore.get("plugins");
|
|
442
448
|
const appData = appStore.get("appData");
|
|
443
449
|
|
|
@@ -492,13 +498,16 @@ export const runZappHooksForEntry = async (
|
|
|
492
498
|
payload = _payload;
|
|
493
499
|
};
|
|
494
500
|
|
|
495
|
-
HooksManager(hooksOptions)
|
|
501
|
+
const hooksManager = HooksManager(hooksOptions);
|
|
502
|
+
|
|
503
|
+
hooksManager.subscriber
|
|
496
504
|
.on(HOOKS_EVENTS.PRESENT_SCREEN_HOOK, handleHookPresent)
|
|
497
505
|
.on(HOOKS_EVENTS.START_BACKGROUND_HOOK, handleBackgroundHook)
|
|
498
506
|
.on(HOOKS_EVENTS.ERROR, onFinished(false))
|
|
499
507
|
.on(HOOKS_EVENTS.CANCEL, onFinished(false))
|
|
500
|
-
.on(HOOKS_EVENTS.COMPLETE, onFinished(true))
|
|
501
|
-
|
|
508
|
+
.on(HOOKS_EVENTS.COMPLETE, onFinished(true));
|
|
509
|
+
|
|
510
|
+
hooksManager.handleHooks(entry);
|
|
502
511
|
|
|
503
512
|
// eslint-disable-next-line no-unmodified-loop-condition
|
|
504
513
|
while (success === undefined) {
|
|
@@ -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
|
@@ -66,3 +66,23 @@ export const isZero = (value: unknown): boolean =>
|
|
|
66
66
|
export const isMinusZero = (value: number) => {
|
|
67
67
|
return 1 / value === -Infinity;
|
|
68
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;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return possibleNumber;
|
|
85
|
+
};
|
|
86
|
+
|
|
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": "
|
|
3
|
+
"version": "13.0.0-alpha.2322412833",
|
|
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": "
|
|
31
|
+
"@applicaster/applicaster-types": "13.0.0-alpha.2322412833",
|
|
32
32
|
"buffer": "^5.2.1",
|
|
33
33
|
"camelize": "^1.0.0",
|
|
34
34
|
"create-react-context": "^0.2.3",
|
|
@@ -1798,6 +1798,30 @@ function getPlayerConfiguration({ platform }) {
|
|
|
1798
1798
|
key: "menu_header_samsung_letter_spacing",
|
|
1799
1799
|
initial_value: 0,
|
|
1800
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
|
+
},
|
|
1801
1825
|
]
|
|
1802
1826
|
),
|
|
1803
1827
|
// Captions Menu - Item Text Label
|
|
@@ -1877,6 +1901,30 @@ function getPlayerConfiguration({ platform }) {
|
|
|
1877
1901
|
key: "menu_item_samsung_letter_spacing",
|
|
1878
1902
|
initial_value: 0,
|
|
1879
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
|
+
},
|
|
1880
1928
|
]
|
|
1881
1929
|
),
|
|
1882
1930
|
// Captions Menu - Item Border
|
|
@@ -2020,6 +2068,18 @@ function getPlayerConfiguration({ platform }) {
|
|
|
2020
2068
|
key: "samsung_tv_video_player_title_font_size",
|
|
2021
2069
|
initial_value: 58,
|
|
2022
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
|
+
},
|
|
2023
2083
|
{
|
|
2024
2084
|
type: "tvos_font_selector",
|
|
2025
2085
|
label: "tvOS Font Family",
|
|
@@ -2093,6 +2153,18 @@ function getPlayerConfiguration({ platform }) {
|
|
|
2093
2153
|
key: "samsung_tv_video_player_summary_font_size",
|
|
2094
2154
|
initial_value: 30,
|
|
2095
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
|
+
},
|
|
2096
2168
|
{
|
|
2097
2169
|
type: "tvos_font_selector",
|
|
2098
2170
|
label: "tvOS Font Family",
|
|
@@ -2160,6 +2232,18 @@ function getPlayerConfiguration({ platform }) {
|
|
|
2160
2232
|
key: "samsung_tv_audio_player_title_font_size",
|
|
2161
2233
|
initial_value: 40,
|
|
2162
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
|
+
},
|
|
2163
2247
|
{
|
|
2164
2248
|
type: "tvos_font_selector",
|
|
2165
2249
|
label: "tvOS Font Family",
|
|
@@ -2215,6 +2299,18 @@ function getPlayerConfiguration({ platform }) {
|
|
|
2215
2299
|
key: "samsung_tv_audio_player_summary_font_size",
|
|
2216
2300
|
initial_value: 22,
|
|
2217
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
|
+
},
|
|
2218
2314
|
{
|
|
2219
2315
|
type: "tvos_font_selector",
|
|
2220
2316
|
label: "tvOS Font Family",
|
|
@@ -2270,6 +2366,18 @@ function getPlayerConfiguration({ platform }) {
|
|
|
2270
2366
|
key: "samsung_tv_player_time_font_size",
|
|
2271
2367
|
initial_value: 20,
|
|
2272
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
|
+
},
|
|
2273
2381
|
{
|
|
2274
2382
|
type: "android_font_selector",
|
|
2275
2383
|
label: "Android TV Font Family",
|
|
@@ -2325,6 +2433,18 @@ function getPlayerConfiguration({ platform }) {
|
|
|
2325
2433
|
key: "samsung_tv_audio_player_run_time_font_size",
|
|
2326
2434
|
initial_value: 20,
|
|
2327
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
|
+
},
|
|
2328
2448
|
{
|
|
2329
2449
|
type: "tvos_font_selector",
|
|
2330
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
|
+
};
|
|
@@ -30,7 +30,15 @@ type Props = {
|
|
|
30
30
|
zappPipesData?: ZappPipesData;
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
type onPressReturnFn =
|
|
34
|
+
| ((_item?: ZappEntry | any, _index?: number) => Promise<void>)
|
|
35
|
+
| (() => void);
|
|
36
|
+
|
|
37
|
+
export const useCellClick = ({
|
|
38
|
+
component,
|
|
39
|
+
zappPipesData,
|
|
40
|
+
item,
|
|
41
|
+
}: Props): onPressReturnFn => {
|
|
34
42
|
const { push, currentRoute } = useNavigation();
|
|
35
43
|
const { pathname } = useRoute();
|
|
36
44
|
|
|
@@ -106,9 +114,15 @@ export const useCellClick = ({ component, zappPipesData, item }: Props) => {
|
|
|
106
114
|
]
|
|
107
115
|
);
|
|
108
116
|
|
|
117
|
+
const onPressRef = React.useRef<onPressReturnFn>();
|
|
118
|
+
|
|
109
119
|
if (!cellSelectable) {
|
|
110
|
-
|
|
120
|
+
// update ref with dummy function
|
|
121
|
+
onPressRef.current = noop;
|
|
122
|
+
} else {
|
|
123
|
+
// update ref with the latest onPress function
|
|
124
|
+
onPressRef.current = onPress;
|
|
111
125
|
}
|
|
112
126
|
|
|
113
|
-
return
|
|
127
|
+
return React.useCallback(onPressRef.current, []);
|
|
114
128
|
};
|
|
@@ -4,38 +4,77 @@ import {
|
|
|
4
4
|
timers,
|
|
5
5
|
} from "@applicaster/zapp-react-native-utils/reactHooks/debugging";
|
|
6
6
|
|
|
7
|
-
jest.useFakeTimers();
|
|
8
|
-
|
|
9
7
|
describe("Debug utils", () => {
|
|
8
|
+
let performanceNowMock;
|
|
9
|
+
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
jest.useFakeTimers();
|
|
12
|
+
// Clear the timers object
|
|
13
|
+
Object.keys(timers).forEach((key) => delete timers[key]);
|
|
14
|
+
|
|
15
|
+
// Mock performance.now()
|
|
16
|
+
// eslint-disable-next-line no-undef
|
|
17
|
+
performanceNowMock = jest.spyOn(performance, "now");
|
|
18
|
+
performanceNowMock.mockReturnValue(0); // Initial value
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
afterEach(() => {
|
|
22
|
+
jest.useRealTimers();
|
|
23
|
+
jest.restoreAllMocks();
|
|
24
|
+
performanceNowMock.mockRestore();
|
|
25
|
+
});
|
|
26
|
+
|
|
10
27
|
describe("Unit Test: time", () => {
|
|
11
28
|
it("should create new timer if timer with a label does not exist", () => {
|
|
29
|
+
performanceNowMock.mockReturnValue(1000);
|
|
12
30
|
time("timer1");
|
|
13
31
|
expect(timers["timer1"]).toBeDefined();
|
|
32
|
+
expect(timers["timer1"].startTime).toBe(1000);
|
|
14
33
|
});
|
|
15
34
|
|
|
16
35
|
it("should update start time of timer if timer with a label exists", () => {
|
|
36
|
+
// First call to time()
|
|
37
|
+
performanceNowMock.mockReturnValue(1000);
|
|
38
|
+
time("timer1");
|
|
17
39
|
const previousStartTime = timers["timer1"].startTime;
|
|
18
|
-
|
|
40
|
+
|
|
41
|
+
// Second call to time()
|
|
42
|
+
performanceNowMock.mockReturnValue(2000);
|
|
19
43
|
time("timer1");
|
|
20
44
|
const currentStartTime = timers["timer1"].startTime;
|
|
21
|
-
|
|
45
|
+
|
|
46
|
+
expect(previousStartTime).toBe(1000);
|
|
47
|
+
expect(currentStartTime).toBe(2000);
|
|
22
48
|
});
|
|
23
49
|
});
|
|
24
50
|
|
|
25
51
|
describe("Unit Test: timeEnd", () => {
|
|
26
|
-
beforeEach(() =>
|
|
52
|
+
beforeEach(() => {
|
|
53
|
+
jest.spyOn(console, "log").mockImplementation(() => {});
|
|
54
|
+
});
|
|
27
55
|
|
|
28
56
|
it("should log elapsed time", () => {
|
|
29
57
|
const logSpy = jest.spyOn(console, "log");
|
|
30
58
|
|
|
59
|
+
performanceNowMock.mockReturnValue(1000);
|
|
60
|
+
time("timer1");
|
|
61
|
+
|
|
62
|
+
performanceNowMock.mockReturnValue(2000);
|
|
31
63
|
timeEnd("timer1");
|
|
32
64
|
|
|
33
|
-
expect(logSpy).
|
|
65
|
+
expect(logSpy).toHaveBeenCalledWith(
|
|
66
|
+
"timer1: 1000.000ms 2",
|
|
67
|
+
expect.any(Object)
|
|
68
|
+
);
|
|
34
69
|
});
|
|
35
70
|
|
|
36
71
|
it("should not log elapsed time if accumulative: true in settings", () => {
|
|
37
72
|
const logSpy = jest.spyOn(console, "log");
|
|
38
73
|
|
|
74
|
+
performanceNowMock.mockReturnValue(1000);
|
|
75
|
+
time("timer1");
|
|
76
|
+
|
|
77
|
+
performanceNowMock.mockReturnValue(2000);
|
|
39
78
|
timeEnd("timer1", { accumulative: true });
|
|
40
79
|
|
|
41
80
|
expect(logSpy).not.toHaveBeenCalled();
|
|
@@ -43,21 +82,52 @@ describe("Debug utils", () => {
|
|
|
43
82
|
});
|
|
44
83
|
|
|
45
84
|
describe("Integration Test: time and timeEnd", () => {
|
|
46
|
-
beforeEach(() =>
|
|
85
|
+
beforeEach(() => {
|
|
86
|
+
jest.spyOn(console, "log").mockImplementation(() => {});
|
|
87
|
+
});
|
|
47
88
|
|
|
48
89
|
it("should log elapsed time on timeEnd call", () => {
|
|
49
90
|
const logSpy = jest.spyOn(console, "log");
|
|
91
|
+
|
|
92
|
+
performanceNowMock.mockReturnValue(1000);
|
|
50
93
|
time("timer1");
|
|
94
|
+
|
|
95
|
+
performanceNowMock.mockReturnValue(2000);
|
|
51
96
|
timeEnd("timer1");
|
|
52
|
-
|
|
97
|
+
|
|
98
|
+
expect(logSpy).toHaveBeenCalledWith(
|
|
99
|
+
"timer1: 1000.000ms 2",
|
|
100
|
+
expect.objectContaining({
|
|
101
|
+
label: "timer1",
|
|
102
|
+
settings: undefined,
|
|
103
|
+
})
|
|
104
|
+
);
|
|
53
105
|
});
|
|
54
106
|
|
|
55
|
-
it("should log total and average time
|
|
107
|
+
it("should log total and average time when accumulative timing is complete", () => {
|
|
56
108
|
const logSpy = jest.spyOn(console, "log");
|
|
109
|
+
|
|
110
|
+
// First timing
|
|
111
|
+
performanceNowMock.mockReturnValue(1000);
|
|
57
112
|
time("timer2");
|
|
113
|
+
|
|
114
|
+
performanceNowMock.mockReturnValue(2000);
|
|
58
115
|
timeEnd("timer2", { accumulative: true });
|
|
59
|
-
|
|
60
|
-
|
|
116
|
+
|
|
117
|
+
// Second timing
|
|
118
|
+
performanceNowMock.mockReturnValue(3000);
|
|
119
|
+
time("timer2");
|
|
120
|
+
|
|
121
|
+
performanceNowMock.mockReturnValue(5000);
|
|
122
|
+
timeEnd("timer2"); // This will log because timer is accumulative (callCount > 1)
|
|
123
|
+
|
|
124
|
+
expect(logSpy).toHaveBeenCalledWith(
|
|
125
|
+
"timer2: 2000.000ms 2",
|
|
126
|
+
expect.objectContaining({
|
|
127
|
+
label: "timer2",
|
|
128
|
+
settings: undefined,
|
|
129
|
+
})
|
|
130
|
+
);
|
|
61
131
|
});
|
|
62
132
|
});
|
|
63
133
|
});
|