@applicaster/zapp-react-native-utils 12.0.0-alpha.4223432180 → 12.0.0-alpha.4241289980
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/appUtils/accessibilityManager/index.ts +12 -1
- package/appUtils/platform/platformUtils.ts +2 -3
- package/appUtils/playerManager/playerFactory.ts +1 -1
- package/arrayUtils/index.ts +0 -11
- package/focusManager/FocusManager.ts +5 -20
- package/focusManager/__tests__/FocusManager.test.ts +1 -0
- package/manifestUtils/defaultManifestConfigurations/player.js +0 -121
- package/manifestUtils/keys.js +1 -2
- package/navigationUtils/index.ts +1 -1
- package/numberUtils/index.ts +0 -20
- package/package.json +2 -2
- package/playerUtils/configurationGenerator.ts +0 -120
- package/reactHooks/cell-click/__tests__/index.test.js +3 -3
- package/reactHooks/cell-click/index.ts +3 -17
- package/reactHooks/feed/__tests__/useBatchLoading.test.tsx +6 -69
- package/reactHooks/feed/useBatchLoading.ts +28 -52
- package/reactHooks/navigation/index.ts +1 -1
- package/reactHooks/useConfiguration.ts +2 -2
- package/testUtils/index.tsx +9 -42
- package/numberUtils/__tests__/toPositiveNumberWithDefault.test.ts +0 -66
- package/numberUtils/__tests__/toPositiveNumberWithDefaultZero.test.ts +0 -66
- package/reactHooks/layout/useDimensions/__tests__/useDimensions.test.ts +0 -134
|
@@ -85,7 +85,18 @@ export class AccessibilityManager {
|
|
|
85
85
|
textToRead = localizedMessage;
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
if (this.ttsManager) {
|
|
89
|
+
logger.debug({
|
|
90
|
+
message: `Reading text: ${textToRead}`,
|
|
91
|
+
data: {
|
|
92
|
+
textToRead,
|
|
93
|
+
text,
|
|
94
|
+
keyOfLocalizedText,
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
this.ttsManager.readText(textToRead);
|
|
99
|
+
}
|
|
89
100
|
|
|
90
101
|
this.announcements$.next({
|
|
91
102
|
message: textToRead,
|
|
@@ -29,7 +29,8 @@ const { log_debug } = createLogger({
|
|
|
29
29
|
parent: utilsLogger,
|
|
30
30
|
});
|
|
31
31
|
|
|
32
|
-
export const getUserAgent = () =>
|
|
32
|
+
export const getUserAgent = () =>
|
|
33
|
+
window?.navigator?.userAgent || global?.navigator?.userAgent;
|
|
33
34
|
|
|
34
35
|
/** VIZIO UTILS */
|
|
35
36
|
|
|
@@ -42,8 +43,6 @@ export const getUserAgent = () => window?.navigator?.userAgent;
|
|
|
42
43
|
export const isVizioPlatform = () => {
|
|
43
44
|
const userAgent = getUserAgent();
|
|
44
45
|
|
|
45
|
-
if (!userAgent) return false;
|
|
46
|
-
|
|
47
46
|
const isVizioAgent =
|
|
48
47
|
userAgent.includes(PLATFORMS.vizio) ||
|
|
49
48
|
userAgent.includes(PLATFORMS.smartcast) ||
|
|
@@ -46,7 +46,7 @@ export const playerFactory = (
|
|
|
46
46
|
|
|
47
47
|
// TODO: Fix type:
|
|
48
48
|
const playerProtocol: PlayerConstructor =
|
|
49
|
-
playerPlugin?.module?.playerProtocol(config?.screenConfig);
|
|
49
|
+
playerPlugin?.module?.playerProtocol(config?.screenConfig, config?.entry);
|
|
50
50
|
|
|
51
51
|
const playerView = (playerProtocol as any)?.Component || null;
|
|
52
52
|
|
package/arrayUtils/index.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/* eslint-disable unused-imports/no-unused-vars */
|
|
2
2
|
import * as R from "ramda";
|
|
3
|
-
import { invariant } from "@applicaster/zapp-react-native-utils/errorUtils";
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* shifts an array by the given offset. a negative offset will take items
|
|
@@ -101,13 +100,3 @@ export const makeListOf = (value: unknown, size: number): number[] => {
|
|
|
101
100
|
export function isFilledArray(value: unknown): boolean {
|
|
102
101
|
return R.is(Array, value) && R.length(value) > 0;
|
|
103
102
|
}
|
|
104
|
-
|
|
105
|
-
// get random item from the list
|
|
106
|
-
export const sample = (xs: unknown[]): unknown => {
|
|
107
|
-
invariant(R.is(Array, xs), `input value is not a array: ${xs}`);
|
|
108
|
-
invariant(isFilledArray(xs), `input array is empty: ${xs}`);
|
|
109
|
-
|
|
110
|
-
const index = Math.floor(Math.random() * xs.length);
|
|
111
|
-
|
|
112
|
-
return xs[index];
|
|
113
|
-
};
|
|
@@ -18,7 +18,6 @@ class FocusManager {
|
|
|
18
18
|
private static instance: FocusManager;
|
|
19
19
|
|
|
20
20
|
private _focusedId: string | null = null;
|
|
21
|
-
private _prevFocusedId: string | null = null;
|
|
22
21
|
public previousNavigationDirection: FocusManager.Android.NavDir = null;
|
|
23
22
|
|
|
24
23
|
/**
|
|
@@ -48,22 +47,10 @@ class FocusManager {
|
|
|
48
47
|
return focusedRef?.current;
|
|
49
48
|
}
|
|
50
49
|
|
|
51
|
-
get prevFocused() {
|
|
52
|
-
const focusedRef = this.prevFocusedId
|
|
53
|
-
? FocusManager.findFocusable(this.prevFocusedId)
|
|
54
|
-
: { current: null };
|
|
55
|
-
|
|
56
|
-
return focusedRef?.current;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
50
|
get focusedId() {
|
|
60
51
|
return FocusManager.instance._focusedId;
|
|
61
52
|
}
|
|
62
53
|
|
|
63
|
-
get prevFocusedId() {
|
|
64
|
-
return FocusManager.instance._prevFocusedId;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
54
|
public static getInstance(): FocusManager {
|
|
68
55
|
if (!FocusManager.instance) {
|
|
69
56
|
FocusManager.instance = new FocusManager();
|
|
@@ -164,8 +151,9 @@ class FocusManager {
|
|
|
164
151
|
}
|
|
165
152
|
|
|
166
153
|
private setFocusLocal(nextFocus: FocusManager.TouchableReactRef) {
|
|
167
|
-
FocusManager.instance._prevFocusedId = FocusManager.instance._focusedId;
|
|
168
154
|
FocusManager.instance._focusedId = nextFocus?.current?.props?.id ?? null;
|
|
155
|
+
|
|
156
|
+
this.eventHandler?.invokeHandler?.(FOCUS_EVENTS.FOCUS, nextFocus);
|
|
169
157
|
}
|
|
170
158
|
|
|
171
159
|
private setPreviousNavigationDirection(
|
|
@@ -229,11 +217,8 @@ class FocusManager {
|
|
|
229
217
|
|
|
230
218
|
FocusManager.instance.setFocus(nextNextFocus, options);
|
|
231
219
|
} else {
|
|
232
|
-
FocusManager.instance.setFocusLocal(nextFocus);
|
|
233
|
-
|
|
234
220
|
FocusManager.instance.blurPrevious(options);
|
|
235
|
-
|
|
236
|
-
|
|
221
|
+
FocusManager.instance.setFocusLocal(nextFocus);
|
|
237
222
|
FocusManager.instance.setPreviousNavigationDirection(options ?? null);
|
|
238
223
|
|
|
239
224
|
nextFocus?.current?.onFocus?.(nextFocus.current, options ?? {});
|
|
@@ -242,8 +227,8 @@ class FocusManager {
|
|
|
242
227
|
|
|
243
228
|
blurPrevious(options?: FocusManager.Android.CallbackOptions) {
|
|
244
229
|
if (options) {
|
|
245
|
-
FocusManager.instance.
|
|
246
|
-
FocusManager.instance.
|
|
230
|
+
FocusManager.instance.focused?.onBlur?.(
|
|
231
|
+
FocusManager.instance.focused,
|
|
247
232
|
options
|
|
248
233
|
);
|
|
249
234
|
}
|
|
@@ -156,6 +156,7 @@ describe("FocusManager", () => {
|
|
|
156
156
|
child1.current.onBlur.mockClear();
|
|
157
157
|
focusManager.setFocus(child1.current.props.id);
|
|
158
158
|
focusManager.blurPrevious({ direction: "down" });
|
|
159
|
+
expect(child1.current.onBlur).toBeCalled();
|
|
159
160
|
});
|
|
160
161
|
|
|
161
162
|
it("focusManager - focus shouldn't change if nextFocus has blockFocus", () => {
|
|
@@ -18,7 +18,6 @@ function getDevice(platform) {
|
|
|
18
18
|
case "lg_tv":
|
|
19
19
|
case "samsung_tv":
|
|
20
20
|
case "web":
|
|
21
|
-
case "vizio":
|
|
22
21
|
return "tv";
|
|
23
22
|
}
|
|
24
23
|
}
|
|
@@ -1796,30 +1795,6 @@ function getPlayerConfiguration({ platform }) {
|
|
|
1796
1795
|
key: "menu_header_samsung_letter_spacing",
|
|
1797
1796
|
initial_value: 0,
|
|
1798
1797
|
},
|
|
1799
|
-
{
|
|
1800
|
-
type: "vizio_font_selector",
|
|
1801
|
-
label: "Vizio Font Family",
|
|
1802
|
-
key: "menu_header_vizio_font_family",
|
|
1803
|
-
initial_value: "SmsungOneUI-Bold",
|
|
1804
|
-
},
|
|
1805
|
-
{
|
|
1806
|
-
type: "number_input",
|
|
1807
|
-
label: "Vizio Font Size",
|
|
1808
|
-
key: "menu_header_vizio_font_size",
|
|
1809
|
-
initial_value: 30,
|
|
1810
|
-
},
|
|
1811
|
-
{
|
|
1812
|
-
type: "number_input",
|
|
1813
|
-
label: "Vizio Line Height",
|
|
1814
|
-
key: "menu_header_vizio_line_height",
|
|
1815
|
-
initial_value: 60,
|
|
1816
|
-
},
|
|
1817
|
-
{
|
|
1818
|
-
type: "number_input",
|
|
1819
|
-
label: "Vizio Letter Spacing",
|
|
1820
|
-
key: "menu_header_vizio_letter_spacing",
|
|
1821
|
-
initial_value: 0,
|
|
1822
|
-
},
|
|
1823
1798
|
]
|
|
1824
1799
|
),
|
|
1825
1800
|
// Captions Menu - Item Text Label
|
|
@@ -1899,30 +1874,6 @@ function getPlayerConfiguration({ platform }) {
|
|
|
1899
1874
|
key: "menu_item_samsung_letter_spacing",
|
|
1900
1875
|
initial_value: 0,
|
|
1901
1876
|
},
|
|
1902
|
-
{
|
|
1903
|
-
type: "vizio_font_selector",
|
|
1904
|
-
label: "Vizio Font Family",
|
|
1905
|
-
key: "menu_item_vizio_font_family",
|
|
1906
|
-
initial_value: "SmsungOneUI-Bold",
|
|
1907
|
-
},
|
|
1908
|
-
{
|
|
1909
|
-
type: "number_input",
|
|
1910
|
-
label: "Vizio Font Size",
|
|
1911
|
-
key: "menu_item_vizio_font_size",
|
|
1912
|
-
initial_value: 25,
|
|
1913
|
-
},
|
|
1914
|
-
{
|
|
1915
|
-
type: "number_input",
|
|
1916
|
-
label: "Vizio Line Height",
|
|
1917
|
-
key: "menu_item_vizio_line_height",
|
|
1918
|
-
initial_value: 40,
|
|
1919
|
-
},
|
|
1920
|
-
{
|
|
1921
|
-
type: "number_input",
|
|
1922
|
-
label: "Vizio Letter Spacing",
|
|
1923
|
-
key: "menu_item_vizio_letter_spacing",
|
|
1924
|
-
initial_value: 0,
|
|
1925
|
-
},
|
|
1926
1877
|
]
|
|
1927
1878
|
),
|
|
1928
1879
|
// Captions Menu - Item Border
|
|
@@ -2066,18 +2017,6 @@ function getPlayerConfiguration({ platform }) {
|
|
|
2066
2017
|
key: "samsung_tv_video_player_title_font_size",
|
|
2067
2018
|
initial_value: 64,
|
|
2068
2019
|
},
|
|
2069
|
-
{
|
|
2070
|
-
type: "vizio_font_selector",
|
|
2071
|
-
label: "Vizio Font Family",
|
|
2072
|
-
key: "vizio_video_player_title_font_family",
|
|
2073
|
-
initial_value: "Ubuntu-Bold",
|
|
2074
|
-
},
|
|
2075
|
-
{
|
|
2076
|
-
type: "number_input",
|
|
2077
|
-
label: "Vizio Font Size",
|
|
2078
|
-
key: "vizio_video_player_title_font_size",
|
|
2079
|
-
initial_value: 64,
|
|
2080
|
-
},
|
|
2081
2020
|
{
|
|
2082
2021
|
type: "tvos_font_selector",
|
|
2083
2022
|
label: "tvOS Font Family",
|
|
@@ -2151,18 +2090,6 @@ function getPlayerConfiguration({ platform }) {
|
|
|
2151
2090
|
key: "samsung_tv_video_player_summary_font_size",
|
|
2152
2091
|
initial_value: 30,
|
|
2153
2092
|
},
|
|
2154
|
-
{
|
|
2155
|
-
type: "vizio_font_selector",
|
|
2156
|
-
label: "Vizio Font Family",
|
|
2157
|
-
key: "vizio_video_player_summary_font_family",
|
|
2158
|
-
initial_value: "Ubuntu-Bold",
|
|
2159
|
-
},
|
|
2160
|
-
{
|
|
2161
|
-
type: "number_input",
|
|
2162
|
-
label: "Vizio Font Size",
|
|
2163
|
-
key: "vizio_video_player_summary_font_size",
|
|
2164
|
-
initial_value: 30,
|
|
2165
|
-
},
|
|
2166
2093
|
{
|
|
2167
2094
|
type: "tvos_font_selector",
|
|
2168
2095
|
label: "tvOS Font Family",
|
|
@@ -2230,18 +2157,6 @@ function getPlayerConfiguration({ platform }) {
|
|
|
2230
2157
|
key: "samsung_tv_audio_player_title_font_size",
|
|
2231
2158
|
initial_value: 38,
|
|
2232
2159
|
},
|
|
2233
|
-
{
|
|
2234
|
-
type: "vizio_font_selector",
|
|
2235
|
-
label: "Vizio Font Family",
|
|
2236
|
-
key: "vizio_tv_audio_player_title_font_family",
|
|
2237
|
-
initial_value: "Ubuntu-Bold",
|
|
2238
|
-
},
|
|
2239
|
-
{
|
|
2240
|
-
type: "number_input",
|
|
2241
|
-
label: "Vizio Font Size",
|
|
2242
|
-
key: "vizio_audio_player_title_font_size",
|
|
2243
|
-
initial_value: 38,
|
|
2244
|
-
},
|
|
2245
2160
|
{
|
|
2246
2161
|
type: "tvos_font_selector",
|
|
2247
2162
|
label: "tvOS Font Family",
|
|
@@ -2297,18 +2212,6 @@ function getPlayerConfiguration({ platform }) {
|
|
|
2297
2212
|
key: "samsung_tv_audio_player_summary_font_size",
|
|
2298
2213
|
initial_value: 20,
|
|
2299
2214
|
},
|
|
2300
|
-
{
|
|
2301
|
-
type: "vizio_font_selector",
|
|
2302
|
-
label: "Vizio Font Family",
|
|
2303
|
-
key: "vizio_audio_player_summary_font_family",
|
|
2304
|
-
initial_value: "Ubuntu-Bold",
|
|
2305
|
-
},
|
|
2306
|
-
{
|
|
2307
|
-
type: "number_input",
|
|
2308
|
-
label: "Vizio Font Size",
|
|
2309
|
-
key: "vizio_audio_player_summary_font_size",
|
|
2310
|
-
initial_value: 20,
|
|
2311
|
-
},
|
|
2312
2215
|
{
|
|
2313
2216
|
type: "tvos_font_selector",
|
|
2314
2217
|
label: "tvOS Font Family",
|
|
@@ -2364,18 +2267,6 @@ function getPlayerConfiguration({ platform }) {
|
|
|
2364
2267
|
key: "samsung_tv_player_time_font_size",
|
|
2365
2268
|
initial_value: 20,
|
|
2366
2269
|
},
|
|
2367
|
-
{
|
|
2368
|
-
type: "vizio_font_selector",
|
|
2369
|
-
label: "Vizio Font Family",
|
|
2370
|
-
key: "vizio_player_time_font_family",
|
|
2371
|
-
initial_value: "Ubuntu-Bold",
|
|
2372
|
-
},
|
|
2373
|
-
{
|
|
2374
|
-
type: "number_input",
|
|
2375
|
-
label: "Vizio Font Size",
|
|
2376
|
-
key: "vizio_player_time_font_size",
|
|
2377
|
-
initial_value: 20,
|
|
2378
|
-
},
|
|
2379
2270
|
{
|
|
2380
2271
|
type: "android_font_selector",
|
|
2381
2272
|
label: "Android TV Font Family",
|
|
@@ -2431,18 +2322,6 @@ function getPlayerConfiguration({ platform }) {
|
|
|
2431
2322
|
key: "samsung_tv_audio_player_run_time_font_size",
|
|
2432
2323
|
initial_value: 20,
|
|
2433
2324
|
},
|
|
2434
|
-
{
|
|
2435
|
-
type: "vizio_font_selector",
|
|
2436
|
-
label: "Vizio Font Family",
|
|
2437
|
-
key: "vizio_audio_player_run_time_font_family",
|
|
2438
|
-
initial_value: "Ubuntu-Bold",
|
|
2439
|
-
},
|
|
2440
|
-
{
|
|
2441
|
-
type: "number_input",
|
|
2442
|
-
label: "Vizio Font Size",
|
|
2443
|
-
key: "vizio_audio_player_run_time_font_size",
|
|
2444
|
-
initial_value: 20,
|
|
2445
|
-
},
|
|
2446
2325
|
{
|
|
2447
2326
|
type: "tvos_font_selector",
|
|
2448
2327
|
label: "tvOS Font Family",
|
package/manifestUtils/keys.js
CHANGED
|
@@ -17,11 +17,10 @@ const ZAPPIFEST_FIELDS = {
|
|
|
17
17
|
lg: "lg_tv_font_selector",
|
|
18
18
|
samsung: "samsung_font_selector",
|
|
19
19
|
roku: "roku_font_selector",
|
|
20
|
-
vizio: "vizio_font_selector",
|
|
21
20
|
},
|
|
22
21
|
};
|
|
23
22
|
|
|
24
|
-
const TV_PLATFORMS = ["tvOS", "android", "LG", "samsung", "roku"
|
|
23
|
+
const TV_PLATFORMS = ["tvOS", "android", "LG", "samsung", "roku"];
|
|
25
24
|
|
|
26
25
|
const FontPropsForTVPlatform = (platform) => ({
|
|
27
26
|
[`${R.toLower(platform)}FontFamily`]: {
|
package/navigationUtils/index.ts
CHANGED
package/numberUtils/index.ts
CHANGED
|
@@ -66,23 +66,3 @@ 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": "12.0.0-alpha.
|
|
3
|
+
"version": "12.0.0-alpha.4241289980",
|
|
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-alpha.
|
|
31
|
+
"@applicaster/applicaster-types": "12.0.0-alpha.4241289980",
|
|
32
32
|
"buffer": "^5.2.1",
|
|
33
33
|
"camelize": "^1.0.0",
|
|
34
34
|
"create-react-context": "^0.2.3",
|
|
@@ -1798,30 +1798,6 @@ 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
|
-
},
|
|
1825
1801
|
]
|
|
1826
1802
|
),
|
|
1827
1803
|
// Captions Menu - Item Text Label
|
|
@@ -1901,30 +1877,6 @@ function getPlayerConfiguration({ platform }) {
|
|
|
1901
1877
|
key: "menu_item_samsung_letter_spacing",
|
|
1902
1878
|
initial_value: 0,
|
|
1903
1879
|
},
|
|
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
|
-
},
|
|
1928
1880
|
]
|
|
1929
1881
|
),
|
|
1930
1882
|
// Captions Menu - Item Border
|
|
@@ -2068,18 +2020,6 @@ function getPlayerConfiguration({ platform }) {
|
|
|
2068
2020
|
key: "samsung_tv_video_player_title_font_size",
|
|
2069
2021
|
initial_value: 58,
|
|
2070
2022
|
},
|
|
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
|
-
},
|
|
2083
2023
|
{
|
|
2084
2024
|
type: "tvos_font_selector",
|
|
2085
2025
|
label: "tvOS Font Family",
|
|
@@ -2153,18 +2093,6 @@ function getPlayerConfiguration({ platform }) {
|
|
|
2153
2093
|
key: "samsung_tv_video_player_summary_font_size",
|
|
2154
2094
|
initial_value: 30,
|
|
2155
2095
|
},
|
|
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
|
-
},
|
|
2168
2096
|
{
|
|
2169
2097
|
type: "tvos_font_selector",
|
|
2170
2098
|
label: "tvOS Font Family",
|
|
@@ -2232,18 +2160,6 @@ function getPlayerConfiguration({ platform }) {
|
|
|
2232
2160
|
key: "samsung_tv_audio_player_title_font_size",
|
|
2233
2161
|
initial_value: 40,
|
|
2234
2162
|
},
|
|
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
|
-
},
|
|
2247
2163
|
{
|
|
2248
2164
|
type: "tvos_font_selector",
|
|
2249
2165
|
label: "tvOS Font Family",
|
|
@@ -2299,18 +2215,6 @@ function getPlayerConfiguration({ platform }) {
|
|
|
2299
2215
|
key: "samsung_tv_audio_player_summary_font_size",
|
|
2300
2216
|
initial_value: 22,
|
|
2301
2217
|
},
|
|
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
|
-
},
|
|
2314
2218
|
{
|
|
2315
2219
|
type: "tvos_font_selector",
|
|
2316
2220
|
label: "tvOS Font Family",
|
|
@@ -2366,18 +2270,6 @@ function getPlayerConfiguration({ platform }) {
|
|
|
2366
2270
|
key: "samsung_tv_player_time_font_size",
|
|
2367
2271
|
initial_value: 20,
|
|
2368
2272
|
},
|
|
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
|
-
},
|
|
2381
2273
|
{
|
|
2382
2274
|
type: "android_font_selector",
|
|
2383
2275
|
label: "Android TV Font Family",
|
|
@@ -2433,18 +2325,6 @@ function getPlayerConfiguration({ platform }) {
|
|
|
2433
2325
|
key: "samsung_tv_audio_player_run_time_font_size",
|
|
2434
2326
|
initial_value: 20,
|
|
2435
2327
|
},
|
|
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
|
-
},
|
|
2448
2328
|
{
|
|
2449
2329
|
type: "tvos_font_selector",
|
|
2450
2330
|
label: "tvOS Font Family",
|
|
@@ -60,13 +60,13 @@ const wrapper = ({ children }) => (
|
|
|
60
60
|
describe("useCellClick", () => {
|
|
61
61
|
it("returns a function", () => {
|
|
62
62
|
const { result } = renderHook(() => useCellClick(mockProps));
|
|
63
|
-
expect(typeof result.current
|
|
63
|
+
expect(typeof result.current).toBe("function");
|
|
64
64
|
cleanup();
|
|
65
65
|
});
|
|
66
66
|
|
|
67
67
|
it("runs default logic", () => {
|
|
68
68
|
const { result } = renderHook(() => useCellClick(mockProps));
|
|
69
|
-
const useCellClickHook = result.current
|
|
69
|
+
const useCellClickHook = result.current;
|
|
70
70
|
|
|
71
71
|
useCellClickHook();
|
|
72
72
|
|
|
@@ -76,7 +76,7 @@ describe("useCellClick", () => {
|
|
|
76
76
|
|
|
77
77
|
it("runs onCellTap", async () => {
|
|
78
78
|
const { result } = renderHook(() => useCellClick(mockProps), { wrapper });
|
|
79
|
-
const useCellClickHook = result.current
|
|
79
|
+
const useCellClickHook = result.current;
|
|
80
80
|
|
|
81
81
|
useCellClickHook();
|
|
82
82
|
|
|
@@ -30,15 +30,7 @@ type Props = {
|
|
|
30
30
|
zappPipesData?: ZappPipesData;
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
| ((_item?: ZappEntry | any, _index?: number) => Promise<void>)
|
|
35
|
-
| (() => void);
|
|
36
|
-
|
|
37
|
-
export const useCellClick = ({
|
|
38
|
-
component,
|
|
39
|
-
zappPipesData,
|
|
40
|
-
item,
|
|
41
|
-
}: Props): React.MutableRefObject<onPressReturnFn> => {
|
|
33
|
+
export const useCellClick = ({ component, zappPipesData, item }: Props) => {
|
|
42
34
|
const { push, currentRoute } = useNavigation();
|
|
43
35
|
const { pathname } = useRoute();
|
|
44
36
|
|
|
@@ -114,15 +106,9 @@ export const useCellClick = ({
|
|
|
114
106
|
]
|
|
115
107
|
);
|
|
116
108
|
|
|
117
|
-
const onPressRef = React.useRef<onPressReturnFn>();
|
|
118
|
-
|
|
119
109
|
if (!cellSelectable) {
|
|
120
|
-
|
|
121
|
-
onPressRef.current = noop;
|
|
122
|
-
} else {
|
|
123
|
-
// update ref with the latest onPress function
|
|
124
|
-
onPressRef.current = onPress;
|
|
110
|
+
return noop;
|
|
125
111
|
}
|
|
126
112
|
|
|
127
|
-
return
|
|
113
|
+
return onPress;
|
|
128
114
|
};
|
|
@@ -77,6 +77,8 @@ describe("useBatchLoading", () => {
|
|
|
77
77
|
|
|
78
78
|
const actions = store.getActions();
|
|
79
79
|
|
|
80
|
+
expect(useDispatchSpy).toBeCalledTimes(1);
|
|
81
|
+
|
|
80
82
|
expect(actions).toHaveLength(2);
|
|
81
83
|
|
|
82
84
|
expect(actions[0]).toMatchObject({
|
|
@@ -127,8 +129,6 @@ describe("useBatchLoading", () => {
|
|
|
127
129
|
// ... more items
|
|
128
130
|
];
|
|
129
131
|
|
|
130
|
-
expect(useDispatchSpy).toBeCalledTimes(0);
|
|
131
|
-
|
|
132
132
|
renderHook(() => useBatchLoading(data, { initialBatchSize, riverId }), {
|
|
133
133
|
wrapper,
|
|
134
134
|
initialProps: { store },
|
|
@@ -136,6 +136,8 @@ describe("useBatchLoading", () => {
|
|
|
136
136
|
|
|
137
137
|
const actions = store.getActions();
|
|
138
138
|
|
|
139
|
+
expect(useDispatchSpy).toBeCalledTimes(1);
|
|
140
|
+
|
|
139
141
|
expect(actions).toHaveLength(1);
|
|
140
142
|
|
|
141
143
|
expect(actions[0]).toMatchObject({
|
|
@@ -170,6 +172,8 @@ describe("useBatchLoading", () => {
|
|
|
170
172
|
initialProps: { store },
|
|
171
173
|
});
|
|
172
174
|
|
|
175
|
+
expect(useDispatchSpy).toBeCalledTimes(1);
|
|
176
|
+
|
|
173
177
|
const actions = store.getActions();
|
|
174
178
|
|
|
175
179
|
expect(actions).toHaveLength(3);
|
|
@@ -214,73 +218,6 @@ describe("useBatchLoading", () => {
|
|
|
214
218
|
|
|
215
219
|
expect(result.current).toBe(true);
|
|
216
220
|
});
|
|
217
|
-
|
|
218
|
-
it("gallery-qb: loadPipesData should be called only once for first component in the gallery", () => {
|
|
219
|
-
const store = mockStore({
|
|
220
|
-
zappPipes: {},
|
|
221
|
-
test: "true",
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
useDispatchSpy.mockReturnValue(store.dispatch);
|
|
225
|
-
|
|
226
|
-
const initialBatchSize = 3;
|
|
227
|
-
const riverId = "123";
|
|
228
|
-
|
|
229
|
-
const data = [
|
|
230
|
-
{
|
|
231
|
-
component_type: "gallery-qb",
|
|
232
|
-
ui_components: [{ data: { source: "url1" } }],
|
|
233
|
-
},
|
|
234
|
-
{ data: { source: "url2" } },
|
|
235
|
-
{ data: { source: "url3" } },
|
|
236
|
-
{ data: { source: "url4" } },
|
|
237
|
-
{ data: { source: "url5" } },
|
|
238
|
-
{ data: { source: "url6" } },
|
|
239
|
-
// ... more items
|
|
240
|
-
];
|
|
241
|
-
|
|
242
|
-
renderHook(() => useBatchLoading(data, { initialBatchSize, riverId }), {
|
|
243
|
-
wrapper,
|
|
244
|
-
initialProps: { store },
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
const actions = store.getActions();
|
|
248
|
-
|
|
249
|
-
expect(actions).toHaveLength(1);
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
it("gallery-qb: initial batch ready when all initial items loaded", () => {
|
|
253
|
-
const store = mockStore({
|
|
254
|
-
zappPipes: {
|
|
255
|
-
url1: {
|
|
256
|
-
loading: false,
|
|
257
|
-
error: false,
|
|
258
|
-
data: {},
|
|
259
|
-
},
|
|
260
|
-
},
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
useDispatchSpy.mockReturnValue(store.dispatch);
|
|
264
|
-
|
|
265
|
-
const initialBatchSize = 3;
|
|
266
|
-
const riverId = "123";
|
|
267
|
-
|
|
268
|
-
const data: Partial<ZappUIComponent>[] = [
|
|
269
|
-
{
|
|
270
|
-
component_type: "gallery-qb",
|
|
271
|
-
ui_components: [{ data: { source: "url1" } }],
|
|
272
|
-
},
|
|
273
|
-
{ data: { source: "url2" } },
|
|
274
|
-
{ data: { source: "url3" } },
|
|
275
|
-
];
|
|
276
|
-
|
|
277
|
-
const { result } = renderHook(
|
|
278
|
-
() => useBatchLoading(data, { initialBatchSize, riverId }),
|
|
279
|
-
{ wrapper, initialProps: { store } }
|
|
280
|
-
);
|
|
281
|
-
|
|
282
|
-
expect(result.current).toBe(true);
|
|
283
|
-
});
|
|
284
221
|
});
|
|
285
222
|
|
|
286
223
|
describe("allFeedsIsReady", () => {
|
|
@@ -45,23 +45,19 @@ const filterEmptyData = (data) => {
|
|
|
45
45
|
return true;
|
|
46
46
|
};
|
|
47
47
|
|
|
48
|
-
const
|
|
49
|
-
rawData.component_type === "gallery-qb"
|
|
50
|
-
? rawData.ui_components[0].data
|
|
51
|
-
: rawData.data;
|
|
52
|
-
|
|
53
|
-
const extractData = compose(uniq, map(getData));
|
|
48
|
+
const extractData = compose(uniq, map(dataOf));
|
|
54
49
|
|
|
55
50
|
export const allFeedsIsReady = (
|
|
56
51
|
feeds: ZappPipesCollection,
|
|
57
52
|
urls: (ZappDataSourceSource | null)[]
|
|
58
53
|
): boolean =>
|
|
59
|
-
urls
|
|
60
|
-
|
|
61
|
-
|
|
54
|
+
urls
|
|
55
|
+
.filter(complement(isNil))
|
|
56
|
+
.map((url) => (url ? checkFeedIsReady(feeds[url]) : false))
|
|
57
|
+
.every(Boolean);
|
|
62
58
|
|
|
63
59
|
export const useBatchLoading = (
|
|
64
|
-
|
|
60
|
+
data: { data?: ZappDataSource }[],
|
|
65
61
|
options: Options
|
|
66
62
|
) => {
|
|
67
63
|
const dispatch = useDispatch();
|
|
@@ -69,18 +65,10 @@ export const useBatchLoading = (
|
|
|
69
65
|
const [searchContext] = ZappPipesSearchContext.useZappPipesContext();
|
|
70
66
|
const [hasEverBeenReady, setHasEverBeenReady] = React.useState(false);
|
|
71
67
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
? 1
|
|
76
|
-
: min(
|
|
77
|
-
options.initialBatchSize ?? DEFAULT_BATCH_SIZE,
|
|
78
|
-
componentsToRender.length
|
|
79
|
-
);
|
|
80
|
-
|
|
81
|
-
const takeBatchSize = React.useCallback(take(takeSize), [takeSize]);
|
|
68
|
+
const takeBatchSize = take(
|
|
69
|
+
min(options.initialBatchSize ?? DEFAULT_BATCH_SIZE, data.length)
|
|
70
|
+
);
|
|
82
71
|
|
|
83
|
-
// Prepare inflated url for datasource
|
|
84
72
|
const getUrl = React.useCallback(
|
|
85
73
|
(data) => {
|
|
86
74
|
const mappedFeed = data.mapping
|
|
@@ -100,16 +88,13 @@ export const useBatchLoading = (
|
|
|
100
88
|
[entryContext, screenContext, searchContext]
|
|
101
89
|
);
|
|
102
90
|
|
|
103
|
-
|
|
104
|
-
const batchComponents = takeBatchSize(componentsToRender);
|
|
91
|
+
const batchData = takeBatchSize(data);
|
|
105
92
|
|
|
106
|
-
// contains datasources from batch components loading
|
|
107
93
|
const feedData: ZappDataSource[] = React.useMemo(
|
|
108
|
-
() => extractData(
|
|
109
|
-
[
|
|
94
|
+
() => extractData(batchData).filter(filterEmptyData),
|
|
95
|
+
[batchData]
|
|
110
96
|
);
|
|
111
97
|
|
|
112
|
-
// contains inflated urls from batch components loading
|
|
113
98
|
const feedUrls: ZappDataSourceSource[] = React.useMemo(
|
|
114
99
|
() =>
|
|
115
100
|
feedData.map((data) => {
|
|
@@ -117,43 +102,34 @@ export const useBatchLoading = (
|
|
|
117
102
|
|
|
118
103
|
return mappedFeedUrl;
|
|
119
104
|
}),
|
|
120
|
-
[]
|
|
105
|
+
[] // No watchers as batch loaders is used only for initial load
|
|
121
106
|
);
|
|
122
107
|
|
|
123
108
|
const feeds = useZappPipesFeeds(feedUrls);
|
|
124
109
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
const data = getData(rawData);
|
|
110
|
+
React.useEffect(() => {
|
|
111
|
+
const datasources = map(dataOf, batchData)
|
|
112
|
+
.filter(filterEmptyData)
|
|
113
|
+
.filter((data) => {
|
|
114
|
+
const feed = feeds[data.source];
|
|
131
115
|
|
|
132
|
-
|
|
133
|
-
if (!filterEmptyData(data)) return false;
|
|
116
|
+
if (!feed) return true;
|
|
134
117
|
|
|
135
|
-
|
|
136
|
-
|
|
118
|
+
return !feedHasData(feed) && !feedIsLoading(feed);
|
|
119
|
+
});
|
|
137
120
|
|
|
138
|
-
|
|
139
|
-
|
|
121
|
+
datasources.forEach((data) => {
|
|
122
|
+
const mappedFeedUrl = getUrl(data);
|
|
140
123
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
);
|
|
146
|
-
}
|
|
124
|
+
if (mappedFeedUrl) {
|
|
125
|
+
return dispatch(
|
|
126
|
+
loadPipesData(mappedFeedUrl, { riverId: options.riverId })
|
|
127
|
+
);
|
|
147
128
|
}
|
|
148
129
|
});
|
|
149
|
-
}, [
|
|
150
|
-
|
|
151
|
-
React.useEffect(() => {
|
|
152
|
-
runBatchLoading();
|
|
153
|
-
}, []);
|
|
130
|
+
}, []); // No watchers as batch loaders is used only for initial load
|
|
154
131
|
|
|
155
132
|
React.useEffect(() => {
|
|
156
|
-
// check if all feeds are ready and set hasEverBeenReady to true
|
|
157
133
|
if (allFeedsIsReady(feeds, feedUrls) && !hasEverBeenReady) {
|
|
158
134
|
setHasEverBeenReady(true);
|
|
159
135
|
}
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
QUICK_BRICK_NAVBAR,
|
|
18
18
|
QUICK_BRICK_CONTENT,
|
|
19
19
|
} from "@applicaster/quick-brick-core/const";
|
|
20
|
-
import { useZappHooksModalState } from "@applicaster/zapp-react-dom-ui-components/Components/ZappHooksModal/
|
|
20
|
+
import { useZappHooksModalState } from "@applicaster/zapp-react-dom-ui-components/Components/ZappHooksModal/ZappHooksModal";
|
|
21
21
|
import { ZappHookModalContext } from "@applicaster/zapp-react-native-ui-components/Contexts";
|
|
22
22
|
import { PathnameContext } from "@applicaster/zapp-react-native-ui-components/Contexts/PathnameContext";
|
|
23
23
|
import { HookModalContextT } from "@applicaster/zapp-react-native-ui-components/Contexts/ZappHookModalContext";
|
|
@@ -67,7 +67,7 @@ export const useConfiguration = ({
|
|
|
67
67
|
if (component) {
|
|
68
68
|
const remappedStylesConfiguration = remapUpdatedKeys(
|
|
69
69
|
pluginManifest,
|
|
70
|
-
component
|
|
70
|
+
component.styles
|
|
71
71
|
);
|
|
72
72
|
|
|
73
73
|
R.forEachObjIndexed((value, key) => {
|
|
@@ -83,7 +83,7 @@ export const useConfiguration = ({
|
|
|
83
83
|
|
|
84
84
|
const styles = populateConfigurationValues(
|
|
85
85
|
pluginManifest?.styles?.fields,
|
|
86
|
-
remappedStylesConfiguration
|
|
86
|
+
remappedStylesConfiguration,
|
|
87
87
|
skipDefaults
|
|
88
88
|
);
|
|
89
89
|
|
package/testUtils/index.tsx
CHANGED
|
@@ -7,11 +7,9 @@ import { Provider } from "react-redux";
|
|
|
7
7
|
import thunk from "redux-thunk";
|
|
8
8
|
import configureStore from "redux-mock-store";
|
|
9
9
|
import { SafeAreaProvider } from "react-native-safe-area-context";
|
|
10
|
-
import { appStore } from "@applicaster/zapp-react-native-redux/AppStore";
|
|
11
10
|
|
|
12
11
|
import { render } from "@testing-library/react-native";
|
|
13
12
|
import { AnalyticsProvider } from "../analyticsUtils";
|
|
14
|
-
import { ThemeContext } from "../theme";
|
|
15
13
|
|
|
16
14
|
export { getByTestId } from "./getByTestId";
|
|
17
15
|
|
|
@@ -61,9 +59,7 @@ const initialState = {
|
|
|
61
59
|
appSettings: {},
|
|
62
60
|
plugins: [],
|
|
63
61
|
appState: { appReady: true, appLaunched: true },
|
|
64
|
-
pluginConfigurations: {},
|
|
65
62
|
appData: { layoutVersion: "v1" },
|
|
66
|
-
zappPipes: {},
|
|
67
63
|
contentTypes: null,
|
|
68
64
|
};
|
|
69
65
|
|
|
@@ -72,49 +68,20 @@ export const WrappedWithProviders = ({
|
|
|
72
68
|
store: storeObj = {},
|
|
73
69
|
}: any) => {
|
|
74
70
|
const _store = configureStore([thunk])(
|
|
75
|
-
R.
|
|
71
|
+
R.mergeDeepWith(R.concat, { ...initialState }, storeObj)
|
|
76
72
|
);
|
|
77
73
|
|
|
78
|
-
appStore.set(_store);
|
|
79
|
-
|
|
80
74
|
return (
|
|
81
|
-
<
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
component_margin_top: 0,
|
|
86
|
-
component_margin_bottom: 0,
|
|
87
|
-
component_margin_left: 0,
|
|
88
|
-
component_margin_right: 0,
|
|
89
|
-
component_padding_top: 0,
|
|
90
|
-
component_padding_bottom: 0,
|
|
91
|
-
component_padding_left: 0,
|
|
92
|
-
component_padding_right: 0,
|
|
93
|
-
component_gutter_vertical: 0,
|
|
94
|
-
component_gutter_horizontal: 0,
|
|
95
|
-
component_corner_radius: 0,
|
|
96
|
-
app_background_color: "rgba(0,0,0,0)",
|
|
97
|
-
screen_margin_top: 0,
|
|
98
|
-
screen_margin_bottom: 0,
|
|
99
|
-
component_anchor_point_y: 0,
|
|
100
|
-
assets: "",
|
|
101
|
-
},
|
|
102
|
-
},
|
|
103
|
-
selectedThemeId: "light",
|
|
104
|
-
setSelectedThemeId: () => {},
|
|
75
|
+
<SafeAreaProvider
|
|
76
|
+
initialMetrics={{
|
|
77
|
+
insets: { top: 0, left: 0, right: 0, bottom: 0 },
|
|
78
|
+
frame: { x: 0, y: 0, width: 0, height: 0 },
|
|
105
79
|
}}
|
|
106
80
|
>
|
|
107
|
-
<
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}}
|
|
112
|
-
>
|
|
113
|
-
<Provider store={_store}>
|
|
114
|
-
<AnalyticsProvider>{children}</AnalyticsProvider>
|
|
115
|
-
</Provider>
|
|
116
|
-
</SafeAreaProvider>
|
|
117
|
-
</ThemeContext.Provider>
|
|
81
|
+
<Provider store={_store}>
|
|
82
|
+
<AnalyticsProvider>{children}</AnalyticsProvider>
|
|
83
|
+
</Provider>
|
|
84
|
+
</SafeAreaProvider>
|
|
118
85
|
);
|
|
119
86
|
};
|
|
120
87
|
|
|
@@ -1,66 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1,66 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import { renderHook } from "@testing-library/react-hooks";
|
|
2
|
-
import { Dimensions, StatusBar } from "react-native";
|
|
3
|
-
|
|
4
|
-
const mockUsePickFromState = jest.fn();
|
|
5
|
-
const mockUseIsScreenActive = jest.fn();
|
|
6
|
-
const mockGetInitialDimensions = jest.fn();
|
|
7
|
-
const mockGetDeviceInfo = jest.fn();
|
|
8
|
-
|
|
9
|
-
jest.mock("@applicaster/zapp-react-native-redux/hooks", () => ({
|
|
10
|
-
...(jest.requireActual("@applicaster/zapp-react-native-redux/hooks") as {}),
|
|
11
|
-
usePickFromState: mockUsePickFromState,
|
|
12
|
-
}));
|
|
13
|
-
|
|
14
|
-
jest.mock("../../../navigation", () => ({
|
|
15
|
-
useIsScreenActive: mockUseIsScreenActive,
|
|
16
|
-
}));
|
|
17
|
-
|
|
18
|
-
jest.mock("../helpers", () => ({
|
|
19
|
-
getInitialDimensions: mockGetInitialDimensions,
|
|
20
|
-
}));
|
|
21
|
-
|
|
22
|
-
jest.mock("../../getDeviceInfo", () => ({
|
|
23
|
-
getDeviceInfo: mockGetDeviceInfo,
|
|
24
|
-
}));
|
|
25
|
-
|
|
26
|
-
const { useDimensions } = require("../useDimensions");
|
|
27
|
-
|
|
28
|
-
describe("useDimensions", () => {
|
|
29
|
-
const mockDimensions = { width: 100, height: 200, scale: 1, fontScale: 1 };
|
|
30
|
-
const mockAppData = { someData: "test" };
|
|
31
|
-
|
|
32
|
-
beforeEach(() => {
|
|
33
|
-
jest.clearAllMocks();
|
|
34
|
-
Dimensions.get = jest.fn().mockReturnValue(mockDimensions);
|
|
35
|
-
|
|
36
|
-
Dimensions.addEventListener = jest.fn().mockReturnValue({
|
|
37
|
-
remove: jest.fn(),
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
mockUsePickFromState.mockReturnValue({ appData: mockAppData });
|
|
41
|
-
mockUseIsScreenActive.mockReturnValue(true);
|
|
42
|
-
mockGetInitialDimensions.mockReturnValue(mockDimensions);
|
|
43
|
-
mockGetDeviceInfo.mockReturnValue({ deviceInfo: "testDeviceInfo" });
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it("returns correct initial dimensions", () => {
|
|
47
|
-
const { result } = renderHook(() =>
|
|
48
|
-
useDimensions("window", { fullDimensions: false })
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
expect(result.current).toEqual({
|
|
52
|
-
...mockDimensions,
|
|
53
|
-
statusBarHeight: StatusBar.currentHeight,
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
expect(mockGetInitialDimensions).toHaveBeenCalledWith("window");
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it("calls handler on mount", () => {
|
|
60
|
-
renderHook(() => useDimensions("window", { fullDimensions: false }));
|
|
61
|
-
|
|
62
|
-
expect(Dimensions.addEventListener).toHaveBeenCalledWith(
|
|
63
|
-
"change",
|
|
64
|
-
expect.any(Function)
|
|
65
|
-
);
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it("calls handler on isActive change", () => {
|
|
69
|
-
const { rerender } = renderHook(() =>
|
|
70
|
-
useDimensions("window", { fullDimensions: false })
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
mockUseIsScreenActive.mockReturnValue(false);
|
|
74
|
-
rerender();
|
|
75
|
-
|
|
76
|
-
expect(Dimensions.addEventListener).toHaveBeenCalledWith(
|
|
77
|
-
"change",
|
|
78
|
-
expect.any(Function)
|
|
79
|
-
);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it("handles fullDimensions option", () => {
|
|
83
|
-
const { result } = renderHook(() =>
|
|
84
|
-
useDimensions("window", { fullDimensions: true })
|
|
85
|
-
);
|
|
86
|
-
|
|
87
|
-
expect(result.current).toEqual({
|
|
88
|
-
...mockDimensions,
|
|
89
|
-
scale: 1,
|
|
90
|
-
fontScale: 1,
|
|
91
|
-
statusBarHeight: StatusBar.currentHeight,
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it("handles excludeStatusBar option", () => {
|
|
96
|
-
const { result } = renderHook(() =>
|
|
97
|
-
useDimensions("window", { excludeStatusBar: true })
|
|
98
|
-
);
|
|
99
|
-
|
|
100
|
-
expect(result.current.height).toBe(
|
|
101
|
-
mockDimensions.height - StatusBar.currentHeight ?? 0
|
|
102
|
-
);
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it("handles rounded option", () => {
|
|
106
|
-
const { result } = renderHook(() =>
|
|
107
|
-
useDimensions("window", { rounded: true })
|
|
108
|
-
);
|
|
109
|
-
|
|
110
|
-
expect(result.current.width).toBe(Math.ceil(mockDimensions.width));
|
|
111
|
-
expect(result.current.height).toBe(Math.ceil(mockDimensions.height));
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
it("handles deviceInfo option", () => {
|
|
115
|
-
const { result } = renderHook(() =>
|
|
116
|
-
useDimensions("window", { deviceInfo: true })
|
|
117
|
-
);
|
|
118
|
-
|
|
119
|
-
expect(result.current.deviceInfo).toMatchObject({
|
|
120
|
-
deviceInfo: "testDeviceInfo",
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
it("logs deprecation warning when fullDimensions is boolean", () => {
|
|
125
|
-
const consoleWarnSpy = jest.spyOn(console, "warn").mockImplementation();
|
|
126
|
-
renderHook(() => useDimensions("window", true));
|
|
127
|
-
|
|
128
|
-
expect(consoleWarnSpy).toHaveBeenCalledWith(
|
|
129
|
-
"Deprecation Warning\nSecond argument is now the options object. {fullDimensions: boolean, ...}"
|
|
130
|
-
);
|
|
131
|
-
|
|
132
|
-
consoleWarnSpy.mockRestore();
|
|
133
|
-
});
|
|
134
|
-
});
|