@applicaster/zapp-react-native-utils 12.0.0-alpha.4337072244 → 12.0.0-alpha.4342066143
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/analyticsPlugins.ts +25 -0
- package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +3 -3
- package/appUtils/focusManager/__tests__/focusManager.test.js +24 -4
- package/appUtils/focusManager/__tests__/index.test.ts +3 -3
- package/appUtils/focusManager/index.ts +56 -141
- package/appUtils/focusManager/treeDataStructure/Utils/index.js +43 -73
- package/appUtils/playerManager/usePlayerControllerSetup.tsx +6 -1
- package/arrayUtils/index.ts +0 -5
- package/numberUtils/__tests__/isLikeNumber.test.ts +0 -18
- package/numberUtils/index.ts +18 -5
- package/package.json +2 -2
- package/reactHooks/cell-click/__tests__/index.test.js +7 -10
- package/reactHooks/cell-click/index.ts +12 -12
- package/reactHooks/feed/__tests__/useBuildPipesUrl.test.tsx +70 -30
- package/reactHooks/feed/useBuildPipesUrl.ts +10 -7
- package/reactHooks/navigation/__tests__/index.test.tsx +11 -8
- package/reactHooks/navigation/index.ts +21 -80
- package/reactHooks/screen/__tests__/useCurrentScreenData.test.tsx +23 -21
- package/reactHooks/screen/index.ts +0 -2
- package/reactHooks/screen/useScreenContext.ts +3 -3
- package/appUtils/focusManager/utils/index.ts +0 -94
- package/arrayUtils/__tests__/isFilledArray.test.ts +0 -63
- package/reactHooks/screen/useScreenBackgroundColor.ts +0 -23
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { isNotNil } from "@applicaster/zapp-react-native-utils/reactUtils/helpers";
|
|
2
|
-
import { find, last, startsWith, pathOr } from "ramda";
|
|
3
|
-
|
|
4
|
-
// run check each 300 ms
|
|
5
|
-
// run this check too often could lead to performance penalty on low-end devices
|
|
6
|
-
const HOW_OFTEN_TO_CHECK_CONDITION = 300; // ms
|
|
7
|
-
|
|
8
|
-
type Props = {
|
|
9
|
-
maxTimeout: number;
|
|
10
|
-
conditionFn: () => boolean;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export const waitUntil = ({ maxTimeout, conditionFn }: Props) => {
|
|
14
|
-
let interval;
|
|
15
|
-
let timeout;
|
|
16
|
-
|
|
17
|
-
return new Promise((resolve, reject) => {
|
|
18
|
-
// run interval check
|
|
19
|
-
interval = setInterval(() => {
|
|
20
|
-
if (conditionFn()) {
|
|
21
|
-
clearInterval(interval);
|
|
22
|
-
clearTimeout(timeout);
|
|
23
|
-
|
|
24
|
-
resolve(undefined);
|
|
25
|
-
}
|
|
26
|
-
}, HOW_OFTEN_TO_CHECK_CONDITION);
|
|
27
|
-
|
|
28
|
-
// max timeout when we need to stop interval check
|
|
29
|
-
timeout = setTimeout(() => {
|
|
30
|
-
clearInterval(interval);
|
|
31
|
-
clearTimeout(timeout);
|
|
32
|
-
|
|
33
|
-
const error = Error(
|
|
34
|
-
"Failed to wait satisfy condition. Max timeout is reached."
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
reject(error);
|
|
38
|
-
}, maxTimeout);
|
|
39
|
-
});
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export const waitForActiveScreen = (currentRoute: string, focusableTree) => {
|
|
43
|
-
const isActiveScreenAvailableToFocus = (): boolean => {
|
|
44
|
-
const routes = focusableTree.root.children;
|
|
45
|
-
|
|
46
|
-
const route = find((route) => route.id === currentRoute, routes);
|
|
47
|
-
|
|
48
|
-
return isNotNil(route);
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
return waitUntil({
|
|
52
|
-
maxTimeout: HOW_OFTEN_TO_CHECK_CONDITION * 10, // ms
|
|
53
|
-
conditionFn: isActiveScreenAvailableToFocus,
|
|
54
|
-
});
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const getActiveScreenChildren = (focusableTree) => {
|
|
58
|
-
return pathOr([], ["children"], last(focusableTree.root.children));
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
export const getContentNode = (focusableTree) => {
|
|
62
|
-
const content = find(
|
|
63
|
-
(child) => startsWith("content", child.id),
|
|
64
|
-
getActiveScreenChildren(focusableTree)
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
return content;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
export const getNavbarNode = (focusableTree) => {
|
|
71
|
-
const navbar = find(
|
|
72
|
-
(child) => startsWith("navbar", child.id),
|
|
73
|
-
getActiveScreenChildren(focusableTree)
|
|
74
|
-
);
|
|
75
|
-
|
|
76
|
-
return navbar;
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
export const waitForContent = (focusableTree) => {
|
|
80
|
-
const contentHasAnyChildren = (): boolean => {
|
|
81
|
-
const countOfChildren = pathOr(
|
|
82
|
-
0,
|
|
83
|
-
["children", "length"],
|
|
84
|
-
getContentNode(focusableTree)
|
|
85
|
-
);
|
|
86
|
-
|
|
87
|
-
return countOfChildren > 0;
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
return waitUntil({
|
|
91
|
-
maxTimeout: HOW_OFTEN_TO_CHECK_CONDITION * 10, // ms
|
|
92
|
-
conditionFn: contentHasAnyChildren,
|
|
93
|
-
});
|
|
94
|
-
};
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { isFilledArray } from "..";
|
|
2
|
-
|
|
3
|
-
describe("isFilledArray", () => {
|
|
4
|
-
it("non-empty array is not empty", () => {
|
|
5
|
-
const value = [1, 2, 3];
|
|
6
|
-
|
|
7
|
-
expect(isFilledArray(value)).toBe(true);
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it("empty array is empty", () => {
|
|
11
|
-
const value = [];
|
|
12
|
-
|
|
13
|
-
expect(isFilledArray(value)).toBe(false);
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it("number is not array", () => {
|
|
17
|
-
const value = 123;
|
|
18
|
-
|
|
19
|
-
expect(isFilledArray(value)).toBe(false);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it("string is not array", () => {
|
|
23
|
-
const value = "vfnjdk";
|
|
24
|
-
|
|
25
|
-
expect(isFilledArray(value)).toBe(false);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it("empty string is not array", () => {
|
|
29
|
-
const value = "";
|
|
30
|
-
|
|
31
|
-
expect(isFilledArray(value)).toBe(false);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it("NaN is not array", () => {
|
|
35
|
-
const value = "";
|
|
36
|
-
|
|
37
|
-
expect(isFilledArray(value)).toBe(false);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it("object is not array", () => {
|
|
41
|
-
const value = { test: 1 };
|
|
42
|
-
|
|
43
|
-
expect(isFilledArray(value)).toBe(false);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it("empty object is not array", () => {
|
|
47
|
-
const value = {};
|
|
48
|
-
|
|
49
|
-
expect(isFilledArray(value)).toBe(false);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it("undefined is not array", () => {
|
|
53
|
-
const value = undefined;
|
|
54
|
-
|
|
55
|
-
expect(isFilledArray(value)).toBe(false);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it("null is not array", () => {
|
|
59
|
-
const value = null;
|
|
60
|
-
|
|
61
|
-
expect(isFilledArray(value)).toBe(false);
|
|
62
|
-
});
|
|
63
|
-
});
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
|
|
3
|
-
import { useScreenConfiguration } from "@applicaster/zapp-react-native-ui-components/Components/River/useScreenConfiguration";
|
|
4
|
-
import { ifEmptyUseFallback } from "@applicaster/zapp-react-native-utils/cellUtils";
|
|
5
|
-
|
|
6
|
-
export const useScreenBackgroundColor = (screenId: string): string => {
|
|
7
|
-
const { backgroundColor: screenBackgroundColor } =
|
|
8
|
-
useScreenConfiguration(screenId);
|
|
9
|
-
|
|
10
|
-
const theme = useTheme();
|
|
11
|
-
|
|
12
|
-
const themeBackgroundColor = React.useMemo(
|
|
13
|
-
() => theme.app_background_color,
|
|
14
|
-
[theme.app_background_color]
|
|
15
|
-
);
|
|
16
|
-
|
|
17
|
-
const backgroundColor = ifEmptyUseFallback(
|
|
18
|
-
screenBackgroundColor,
|
|
19
|
-
themeBackgroundColor
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
return backgroundColor;
|
|
23
|
-
};
|