@applicaster/zapp-react-native-utils 13.0.0-alpha.1909212433 → 13.0.0-alpha.1952415373

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.
Files changed (118) hide show
  1. package/actionsExecutor/ActionExecutor.ts +16 -9
  2. package/actionsExecutor/ActionExecutorContext.tsx +74 -9
  3. package/alertUtils/alert.ts +148 -0
  4. package/alertUtils/index.ts +1 -148
  5. package/analyticsUtils/AnalyticPlayerListener.ts +18 -1
  6. package/analyticsUtils/__tests__/__snapshots__/analyticsManagerNoModule.test.js.snap +9 -9
  7. package/analyticsUtils/helpers/hooks.ts +1 -1
  8. package/appUtils/HooksManager/{Hook.js → Hook.ts} +35 -23
  9. package/appUtils/HooksManager/__tests__/__snapshots__/hook.test.js.snap +10 -8
  10. package/appUtils/HooksManager/__tests__/__snapshots__/hooksManager.test.js.snap +693 -0
  11. package/appUtils/HooksManager/__tests__/hook.test.js +196 -184
  12. package/appUtils/HooksManager/__tests__/hooksManager.test.js +96 -99
  13. package/appUtils/HooksManager/{constants.js → constants.ts} +1 -1
  14. package/appUtils/HooksManager/{index.js → index.ts} +121 -112
  15. package/appUtils/HooksManager/types.ts +119 -0
  16. package/appUtils/RiverFocusManager/index.js +17 -12
  17. package/appUtils/accessibilityManager/index.ts +42 -1
  18. package/appUtils/contextKeysManager/contextResolver.ts +77 -0
  19. package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +7 -6
  20. package/appUtils/focusManager/index.ts +100 -65
  21. package/appUtils/focusManager/treeDataStructure/Tree/index.js +25 -3
  22. package/appUtils/focusManager/treeDataStructure/Utils/index.js +1 -3
  23. package/appUtils/focusManager/utils/enums.ts +4 -0
  24. package/appUtils/focusManagerAux/utils/index.ts +4 -3
  25. package/appUtils/{index.js → index.ts} +1 -1
  26. package/appUtils/keyCodes/__tests__/__snapshots__/keyCodes.test.js.snap +2 -2
  27. package/appUtils/keyCodes/__tests__/keyCodes.test.js +4 -4
  28. package/appUtils/keyCodes/{index.js → index.ts} +2 -0
  29. package/appUtils/keyCodes/keys/index.ts +3 -0
  30. package/appUtils/keyCodes/{keys.android.js → keys/keyEventMapper.ts} +0 -19
  31. package/appUtils/keyCodes/keys/keys.android.ts +18 -0
  32. package/appUtils/keyCodes/keys/keys.ios.ts +25 -0
  33. package/appUtils/keyCodes/keys/keys.ts +15 -0
  34. package/appUtils/keyCodes/{keysByPlatform.js → keys/keysByPlatform.ts} +4 -0
  35. package/appUtils/keyCodes/keysByPlatform.ts +8 -0
  36. package/appUtils/keyInputHandler/KeyInputHandler.ts +68 -0
  37. package/appUtils/orientationHelper.ts +1 -1
  38. package/appUtils/platform/const.ts +14 -0
  39. package/appUtils/platform/platformUtils.ts +41 -18
  40. package/appUtils/playerManager/player.ts +19 -7
  41. package/appUtils/playerManager/playerNative.ts +3 -2
  42. package/appUtils/playerManager/usePlayerControllerSetup.tsx +3 -3
  43. package/arrayUtils/__tests__/__snapshots__/arrayUtils.test.ts.snap +4 -4
  44. package/domUtils/{cookieManager.js → cookieManager.ts} +1 -2
  45. package/functionUtils/__tests__/__snapshots__/functionUtils.test.js.snap +4 -4
  46. package/functionUtils/index.ts +15 -11
  47. package/idleUtils/__tests__/withTimeout$.test.ts +37 -0
  48. package/idleUtils/index.ts +1 -1
  49. package/idleUtils/withTimeout.ts +15 -2
  50. package/logger/const.ts +9 -67
  51. package/manifestUtils/__tests__/createConfig.test.js +16 -16
  52. package/modalState/index.ts +1 -5
  53. package/navigationUtils/__tests__/__snapshots__/navigationUtils.test.js.snap +6 -6
  54. package/navigationUtils/__tests__/itemTypes.test.js +2 -2
  55. package/navigationUtils/__tests__/navigationUtils.test.js +2 -2
  56. package/navigationUtils/index.ts +17 -8
  57. package/package.json +3 -2
  58. package/reactHooks/autoscrolling/__tests__/useTrackCurrentAutoScrollingElement.test.ts +1 -1
  59. package/reactHooks/autoscrolling/__tests__/useTrackedView.test.tsx +1 -1
  60. package/reactHooks/cell-click/__tests__/index.test.js +10 -2
  61. package/reactHooks/cell-click/index.ts +7 -1
  62. package/reactHooks/feed/__tests__/useBuildPipesUrl.test.tsx +4 -4
  63. package/reactHooks/feed/__tests__/useFeedLoader.test.tsx +10 -11
  64. package/reactHooks/feed/useFeedLoader.tsx +1 -1
  65. package/reactHooks/feed/usePipesCacheReset.ts +5 -5
  66. package/reactHooks/flatList/__tests__/index.test.tsx +30 -21
  67. package/reactHooks/layout/__tests__/index.test.tsx +10 -10
  68. package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.native.test.js +14 -28
  69. package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.test.js +1 -1
  70. package/reactHooks/layout/useDimensions/useDimensions.ts +8 -0
  71. package/reactHooks/navigation/__tests__/index.test.tsx +0 -4
  72. package/reactHooks/navigation/index.ts +29 -218
  73. package/reactHooks/navigation/useGetBottomTabBarHeight.ts +12 -0
  74. package/reactHooks/navigation/useGetNavBarTopBorderWidth.ts +14 -0
  75. package/reactHooks/navigation/useGetTabBarHeight.ts +10 -0
  76. package/reactHooks/navigation/useIsScreenActive.ts +17 -0
  77. package/reactHooks/navigation/useNavigationPluginData.ts +15 -0
  78. package/reactHooks/navigation/useNavigationType.ts +15 -0
  79. package/reactHooks/navigation/usePathname.ts +4 -0
  80. package/reactHooks/navigation/useRoute.ts +100 -0
  81. package/reactHooks/navigation/useUniqueRouteSuffix.ts +41 -0
  82. package/reactHooks/player/TVSeekControlller/ISeekController.ts +32 -0
  83. package/reactHooks/player/TVSeekControlller/LongPressSeekController.ts +71 -0
  84. package/reactHooks/player/TVSeekControlller/TVSeekController.ts +258 -0
  85. package/reactHooks/player/TVSeekControlller/TapSeekController.ts +53 -0
  86. package/reactHooks/player/__tests__/{useAutoSeek.test.tsx → useAutoSeek._test.tsx} +2 -3
  87. package/reactHooks/player/const.ts +0 -4
  88. package/reactHooks/player/index.ts +0 -6
  89. package/reactHooks/state/useRefWithInitialValue.ts +14 -0
  90. package/reactHooks/state/useStateFromSubscribe.ts +23 -0
  91. package/reactHooks/usePluginConfiguration.ts +1 -1
  92. package/reactHooks/useSubscriberFor.ts +4 -3
  93. package/reactUtils/__tests__/reactUtils.test.js +10 -28
  94. package/reactUtils/createContext/__tests__/__snapshots__/helpers.test.js.snap +19 -19
  95. package/reactUtils/createContext/__tests__/__snapshots__/index.test.js.snap +2 -2
  96. package/reactUtils/createContext/__tests__/__snapshots__/provider.test.js.snap +3 -3
  97. package/reactUtils/createContext/__tests__/helpers.test.js +8 -8
  98. package/reactUtils/index.ts +0 -14
  99. package/screenState/index.ts +24 -10
  100. package/theme/__mocks__/index.ts +4 -0
  101. package/theme/index.ts +1 -1
  102. package/time/Timer.ts +5 -2
  103. package/types.ts +1 -0
  104. package/zappFrameworkUtils/presentPluginOneTime.ts +2 -3
  105. package/appUtils/keyCodes/keys.ios.js +0 -46
  106. package/manifestUtils/sharedConfiguration/screenPicker/__tests__/utils.test.js +0 -304
  107. package/manifestUtils/sharedConfiguration/screenPicker/stylesFields.js +0 -875
  108. package/manifestUtils/sharedConfiguration/screenPicker/utils.js +0 -130
  109. package/reactHooks/player/useAutoSeek.tsx +0 -87
  110. package/reactHooks/player/useSeek.tsx +0 -66
  111. package/reactHooks/player/useTapSeek.tsx +0 -58
  112. /package/appUtils/HooksManager/{logger.js → logger.ts} +0 -0
  113. /package/appUtils/{directionHelper.js → directionHelper.ts} +0 -0
  114. /package/appUtils/keyCodes/{androidTVKeys.js → androidTVKeys.ts} +0 -0
  115. /package/appUtils/keyCodes/{keys.web.js → keys/keys.web.ts} +0 -0
  116. /package/appUtils/{localizationsHelper.js → localizationsHelper.ts} +0 -0
  117. /package/domUtils/{logger.js → logger.ts} +0 -0
  118. /package/reactHooks/player/__tests__/{useTapSeek.test.ts → useTapSeek._test.ts} +0 -0
@@ -1,130 +0,0 @@
1
- const defaultPlatforms = {
2
- tvos: "tvOS",
3
- android_tv: "Android TV",
4
- lg_tv: "LG TV",
5
- samsung_tv: "Samsung TV",
6
- };
7
-
8
- const global_defaults = {
9
- fontSize: 20,
10
- lineHeight: 40,
11
- letterSpacing: 0.4,
12
- };
13
-
14
- const generateFontConfiguration = (platforms = defaultPlatforms) => {
15
- const platformEntries = Object.entries(platforms);
16
- const defaultsEntries = Object.entries(global_defaults);
17
- const splitCamelCase = (str) => str.replace(/([a-z](?=[A-Z]))/g, "$1_");
18
-
19
- return platformEntries.reduce((acc, [platformKey, platformValue]) => {
20
- acc.push(
21
- ...defaultsEntries.reduce((acc2, [valueKey, defaultValue]) => {
22
- acc2.push({
23
- type: "number_input",
24
- label: `${platformValue} ${splitCamelCase(valueKey).replace(
25
- "_",
26
- " "
27
- )}`,
28
- key: `${platformKey}_${splitCamelCase(valueKey)}`.toLowerCase(),
29
- initial_value: defaultValue,
30
- });
31
-
32
- return acc2;
33
- }, [])
34
- );
35
-
36
- return acc;
37
- }, []);
38
- };
39
-
40
- const conditional_rule = (key, condition_value) => ({
41
- key,
42
- condition_value,
43
- });
44
-
45
- const createConditionalConfig = (rules, matchAll = false) => ({
46
- rules: matchAll ? "all_conditions" : "conditional",
47
- conditional_fields: rules.map((field) => conditional_rule(...field)),
48
- });
49
-
50
- const conditional_horizontal_type = createConditionalConfig([
51
- ["styles/screen_picker_type", "horizontal"],
52
- ]);
53
-
54
- const conditional_vertical_type = createConditionalConfig([
55
- ["styles/screen_picker_type", "vertical"],
56
- ]);
57
-
58
- const conditional_horizontal_type_item_fixed = createConditionalConfig(
59
- [
60
- ["styles/screen_picker_type", "horizontal"],
61
- ["styles/screen_picker_item_size", "fixed"],
62
- ],
63
- true
64
- );
65
-
66
- const conditional_horizontal_type_item_dynamic = createConditionalConfig(
67
- [
68
- ["styles/screen_picker_type", "horizontal"],
69
- ["screen_picker_horizontal_display_type", "dynamic"],
70
- ],
71
- true
72
- );
73
-
74
- const conditional_horizontal_display_type_fixed = createConditionalConfig(
75
- [
76
- ["styles/screen_picker_type", "horizontal"],
77
- ["styles/screen_picker_horizontal_display_type", "fixed"],
78
- ],
79
- true
80
- );
81
-
82
- const conditional_horizontal_asset_on = createConditionalConfig(
83
- [
84
- ["styles/screen_picker_type", "horizontal"],
85
- ["styles/screen_picker_asset_switch", true],
86
- ],
87
- true
88
- );
89
-
90
- const createVariationFields = ({
91
- prefix = "screen_picker",
92
- key,
93
- type = "number_input",
94
- label = "",
95
- variants: [a, b],
96
- }) => {
97
- return [
98
- {
99
- type,
100
- key: `${prefix}${prefix.length > 0 ? "_" : ""}${
101
- a?.key ?? "vertical"
102
- }_${key}`,
103
- label: a?.label ?? label,
104
- initial_value: a.initial_value,
105
- ...conditional_vertical_type,
106
- },
107
- {
108
- type,
109
- key: `${prefix}${prefix.length > 0 ? "_" : ""}${
110
- b.key ?? "horizontal"
111
- }_${key}`,
112
- label: b?.label ?? label,
113
- initial_value: b.initial_value,
114
- ...conditional_horizontal_type,
115
- },
116
- ];
117
- };
118
-
119
- module.exports = {
120
- generateFontConfiguration,
121
- createVariationFields,
122
- createConditionalConfig,
123
- conditional_rule,
124
- conditional_horizontal_type,
125
- conditional_vertical_type,
126
- conditional_horizontal_type_item_fixed,
127
- conditional_horizontal_type_item_dynamic,
128
- conditional_horizontal_display_type_fixed,
129
- conditional_horizontal_asset_on,
130
- };
@@ -1,87 +0,0 @@
1
- import React, { useEffect, useState } from "react";
2
- import { usePrevious } from "@applicaster/zapp-react-native-utils/reactHooks/utils";
3
- import { playerManager } from "@applicaster/zapp-react-native-utils/appUtils/playerManager";
4
- import {
5
- MAX_SEEK_TIME,
6
- ON_HOLD_INTERVAL,
7
- SEEK_TYPE,
8
- SKIP_TIME_BASE,
9
- } from "./const";
10
- import { noop } from "../../functionUtils";
11
-
12
- export const useAutoSeek = (resetHUDTimer = noop) => {
13
- const [isRunning, setIsRunning] = useState<boolean>(false);
14
- const [direction, setDirection] = useState<Nullable<SEEK_TYPE>>(null);
15
- const [multiplier, setMultiplier] = useState(1);
16
- const intervalTimer = React.useRef(null);
17
- const prevRunning = usePrevious(isRunning);
18
-
19
- const clearIntervalTimer = () => {
20
- try {
21
- clearInterval(intervalTimer.current);
22
- } catch (err) {
23
- intervalTimer.current = null;
24
- }
25
- };
26
-
27
- const setIntervalTimer = (cb) => {
28
- clearIntervalTimer();
29
- intervalTimer.current = setInterval(cb, ON_HOLD_INTERVAL);
30
- };
31
-
32
- const resetState = () => {
33
- setIsRunning(false);
34
- setDirection(null);
35
- setMultiplier(1);
36
- clearIntervalTimer();
37
- };
38
-
39
- useEffect(() => {
40
- const player = playerManager.getInstanceController();
41
-
42
- if (!player) return;
43
-
44
- if (direction) {
45
- player[direction](Math.min(MAX_SEEK_TIME, SKIP_TIME_BASE * multiplier));
46
- resetHUDTimer();
47
- }
48
- }, [multiplier, direction]);
49
-
50
- useEffect(() => {
51
- if (isRunning && isRunning !== prevRunning) {
52
- setIntervalTimer(() => {
53
- setMultiplier((prev) => {
54
- return prev + 1;
55
- });
56
- });
57
- } else if (!isRunning && isRunning !== prevRunning) {
58
- resetState();
59
- }
60
-
61
- return () => {
62
- clearIntervalTimer();
63
- };
64
- }, [isRunning, direction]);
65
-
66
- const autoSeekStop = React.useCallback(() => {
67
- resetState();
68
- }, []);
69
-
70
- const autoSeekStart = React.useCallback(
71
- (eventType: SEEK_TYPE) => {
72
- // Check if there is another session running
73
- if (isRunning) {
74
- autoSeekStop();
75
- }
76
-
77
- setDirection(eventType);
78
- setIsRunning(true);
79
- },
80
- [isRunning]
81
- );
82
-
83
- return React.useMemo(
84
- () => ({ autoSeekStart, autoSeekStop }),
85
- [autoSeekStart, autoSeekStop]
86
- );
87
- };
@@ -1,66 +0,0 @@
1
- import React from "react";
2
- import { SEEK_TYPE } from "./const";
3
- import { useTapSeek } from "./useTapSeek";
4
- import { useAutoSeek } from "./useAutoSeek";
5
- import { noop } from "../../functionUtils";
6
-
7
- export const useSeek = (resetHUDTimer = noop) => {
8
- const handlePressEvent = useTapSeek();
9
- const { autoSeekStart, autoSeekStop } = useAutoSeek(resetHUDTimer);
10
-
11
- const onForwardPress = () => {
12
- handlePressEvent(SEEK_TYPE.FORWARD);
13
- };
14
-
15
- const onRewindPress = () => {
16
- handlePressEvent(SEEK_TYPE.REWIND);
17
- };
18
-
19
- const onForwardPressIn = () => {
20
- autoSeekStart(SEEK_TYPE.FORWARD);
21
- };
22
-
23
- const onForwardPressOut = () => {
24
- autoSeekStop();
25
- };
26
-
27
- const onRewindPressIn = () => {
28
- autoSeekStart(SEEK_TYPE.REWIND);
29
- };
30
-
31
- const onRewindLongPress = () => {
32
- autoSeekStart(SEEK_TYPE.REWIND);
33
- };
34
-
35
- const onForwardLongPress = () => {
36
- autoSeekStart(SEEK_TYPE.FORWARD);
37
- };
38
-
39
- const onRewindPressOut = () => {
40
- autoSeekStop();
41
- };
42
-
43
- return React.useMemo(
44
- () => ({
45
- onForwardPress,
46
- onRewindPress,
47
- onForwardPressIn,
48
- onForwardPressOut,
49
- onRewindPressIn,
50
- onRewindPressOut,
51
- onRewindLongPress,
52
- onForwardLongPress,
53
- }),
54
- [handlePressEvent, autoSeekStart]
55
- );
56
- };
57
-
58
- export const withUseSeek = (Component) =>
59
- Object.assign(
60
- (props) => {
61
- const seekMethods = useSeek(props?.resetHUDTimer);
62
-
63
- return <Component {...props} seekMethods={seekMethods} />;
64
- },
65
- { displayName: "WithUseSeek" }
66
- );
@@ -1,58 +0,0 @@
1
- import { useCallback, useRef } from "react";
2
- import * as R from "ramda";
3
- import {
4
- MAX_SEEK_TIME,
5
- ON_PRESS_RESET_DURATION,
6
- SEEK_TYPE,
7
- SKIP_TIME_BASE,
8
- } from "./const";
9
- import { playerManager } from "@applicaster/zapp-react-native-utils/appUtils";
10
-
11
- type SeekType = SEEK_TYPE | null;
12
-
13
- const getSkipTime = (multiplier) => {
14
- const skipTime = R.min(MAX_SEEK_TIME, SKIP_TIME_BASE * multiplier);
15
-
16
- return skipTime;
17
- };
18
-
19
- export const useTapSeek = () => {
20
- const onPressMultiplier = useRef(1);
21
- const lastPressTime = useRef(0);
22
- const currentOnPressEventType = useRef<SeekType>(null);
23
-
24
- const resetMultiplier = useCallback(() => {
25
- onPressMultiplier.current = 1;
26
- }, []);
27
-
28
- const handlePressEvent = useCallback(
29
- (eventType) => {
30
- const player = playerManager.getInstanceController();
31
- if (!player) return;
32
-
33
- const now = Date.now();
34
- const timeSinceLastPress = now - lastPressTime.current;
35
- const isSameEventType = eventType === currentOnPressEventType.current;
36
-
37
- const isWithinResetDuration =
38
- timeSinceLastPress <= ON_PRESS_RESET_DURATION;
39
-
40
- const shouldIncreaseMultiplier = isSameEventType && isWithinResetDuration;
41
-
42
- if (shouldIncreaseMultiplier) {
43
- onPressMultiplier.current += 1;
44
- } else {
45
- resetMultiplier();
46
- }
47
-
48
- const seekTime = getSkipTime(onPressMultiplier.current);
49
- player[eventType](seekTime);
50
-
51
- lastPressTime.current = now;
52
- currentOnPressEventType.current = eventType;
53
- },
54
- [resetMultiplier]
55
- );
56
-
57
- return handlePressEvent;
58
- };
File without changes
File without changes