@applicaster/zapp-react-native-utils 13.0.0-rc.5 → 13.0.0-rc.50
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/README.md +0 -10
- package/actionsExecutor/ActionExecutor.ts +16 -9
- package/actionsExecutor/ActionExecutorContext.tsx +74 -9
- package/alertUtils/alert.ts +148 -0
- package/alertUtils/index.ts +1 -148
- package/analyticsUtils/AnalyticPlayerListener.ts +18 -1
- package/analyticsUtils/__tests__/__snapshots__/analyticsManagerNoModule.test.js.snap +9 -9
- package/analyticsUtils/currentScreenProperities.ts +6 -4
- package/analyticsUtils/helpers/hooks.ts +1 -1
- package/appUtils/HooksManager/{Hook.js → Hook.ts} +35 -23
- package/appUtils/HooksManager/__tests__/__snapshots__/hook.test.js.snap +10 -8
- 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 +119 -0
- package/appUtils/RiverFocusManager/index.js +17 -12
- package/appUtils/accessibilityManager/index.ts +42 -1
- package/appUtils/contextKeysManager/contextResolver.ts +77 -0
- package/appUtils/contextKeysManager/index.ts +2 -2
- package/appUtils/contextKeysManager/utils/index.ts +2 -1
- package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +7 -6
- package/appUtils/focusManager/index.ts +100 -65
- package/appUtils/focusManager/treeDataStructure/Tree/index.js +25 -3
- package/appUtils/focusManager/treeDataStructure/Utils/index.js +1 -3
- package/appUtils/focusManager/utils/enums.ts +4 -0
- package/appUtils/focusManagerAux/utils/index.ts +4 -3
- package/appUtils/{index.js → index.ts} +1 -1
- package/appUtils/keyCodes/__tests__/__snapshots__/keyCodes.test.js.snap +2 -2
- package/appUtils/keyCodes/__tests__/keyCodes.test.js +4 -4
- package/appUtils/keyCodes/{index.js → index.ts} +13 -7
- 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/keyCodes/{keysByPlatform.js → keys/keysByPlatform.ts} +4 -0
- package/appUtils/keyCodes/keysByPlatform.ts +8 -0
- package/appUtils/keyInputHandler/KeyInputHandler.ts +68 -0
- package/appUtils/orientationHelper.ts +1 -1
- package/appUtils/platform/const.ts +14 -0
- package/appUtils/platform/platformUtils.ts +47 -18
- package/appUtils/playerManager/index.ts +2 -2
- package/appUtils/playerManager/player.ts +19 -7
- package/appUtils/playerManager/playerNative.ts +3 -2
- package/appUtils/playerManager/usePlayerControllerSetup.tsx +3 -3
- package/arrayUtils/__tests__/__snapshots__/arrayUtils.test.ts.snap +4 -4
- package/domUtils/{cookieManager.js → cookieManager.ts} +1 -2
- package/equalUtils/__tests__/isEqual/combination.test.ts +263 -0
- package/equalUtils/index.ts +49 -30
- package/focusManager/FocusManager.ts +11 -1
- package/focusManager/index.ts +41 -4
- package/functionUtils/__tests__/__snapshots__/functionUtils.test.js.snap +4 -4
- package/functionUtils/index.ts +15 -11
- package/idleUtils/__tests__/withTimeout$.test.ts +37 -0
- package/idleUtils/index.ts +1 -1
- package/idleUtils/withTimeout.ts +15 -2
- package/logger/const.ts +9 -67
- package/manifestUtils/__tests__/createConfig.test.js +16 -16
- package/manifestUtils/sharedConfiguration/screenPicker/__tests__/utils.test.js +304 -0
- package/manifestUtils/sharedConfiguration/screenPicker/stylesFields.js +875 -0
- package/manifestUtils/sharedConfiguration/screenPicker/utils.js +130 -0
- package/modalState/index.ts +1 -5
- package/navigationUtils/__tests__/__snapshots__/navigationUtils.test.js.snap +6 -6
- package/navigationUtils/__tests__/itemTypes.test.js +2 -2
- package/navigationUtils/__tests__/navigationUtils.test.js +2 -2
- package/navigationUtils/index.ts +17 -8
- package/package.json +5 -6
- package/reactHooks/autoscrolling/__tests__/useTrackCurrentAutoScrollingElement.test.ts +1 -1
- package/reactHooks/autoscrolling/__tests__/useTrackedView.test.tsx +1 -1
- package/reactHooks/cell-click/__tests__/index.test.js +10 -2
- package/reactHooks/cell-click/index.ts +7 -1
- package/reactHooks/feed/__tests__/useBuildPipesUrl.test.tsx +4 -4
- package/reactHooks/feed/__tests__/useFeedLoader.test.tsx +10 -11
- package/reactHooks/feed/useFeedLoader.tsx +1 -1
- package/reactHooks/feed/usePipesCacheReset.ts +5 -5
- package/reactHooks/flatList/__tests__/index.test.tsx +30 -21
- package/reactHooks/layout/__tests__/index.test.tsx +10 -10
- package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.native.test.js +14 -28
- package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.test.js +1 -1
- package/reactHooks/layout/useDimensions/useDimensions.ts +8 -0
- package/reactHooks/navigation/__mocks__/useNavigation.ts +3 -0
- package/reactHooks/navigation/__tests__/index.test.tsx +0 -4
- package/reactHooks/navigation/index.ts +35 -236
- package/reactHooks/navigation/useGetBottomTabBarHeight.ts +12 -0
- package/reactHooks/navigation/useGetNavBarTopBorderWidth.ts +14 -0
- package/reactHooks/navigation/useGetTabBarHeight.ts +10 -0
- package/reactHooks/navigation/useIsScreenActive.ts +17 -0
- package/reactHooks/navigation/useNavigationPluginData.ts +15 -0
- package/reactHooks/navigation/useNavigationType.ts +15 -0
- package/reactHooks/navigation/usePathname.ts +4 -0
- package/reactHooks/navigation/useProfilerLogging.ts +15 -0
- package/reactHooks/navigation/useRoute.ts +100 -0
- package/reactHooks/navigation/useUniqueRouteSuffix.ts +41 -0
- package/reactHooks/player/TVSeekControlller/ISeekController.ts +32 -0
- package/reactHooks/player/TVSeekControlller/LongPressSeekController.ts +71 -0
- package/reactHooks/player/TVSeekControlller/TVSeekController.ts +258 -0
- package/reactHooks/player/TVSeekControlller/TapSeekController.ts +53 -0
- package/reactHooks/player/__tests__/{useAutoSeek.test.tsx → useAutoSeek._test.tsx} +2 -3
- package/reactHooks/player/const.ts +0 -4
- package/reactHooks/player/index.ts +0 -6
- package/reactHooks/state/useRefWithInitialValue.ts +14 -0
- package/reactHooks/state/useStateFromSubscribe.ts +23 -0
- package/reactHooks/usePluginConfiguration.ts +1 -1
- package/reactHooks/useSubscriberFor.ts +4 -3
- package/reactUtils/__tests__/__snapshots__/reactUtilsHelpers.test.js.snap +16 -4
- package/reactUtils/__tests__/reactUtils.test.js +1 -37
- package/reactUtils/__tests__/reactUtilsHelpers.test.js +72 -71
- package/reactUtils/createContext/__tests__/__snapshots__/helpers.test.js.snap +13 -79
- package/reactUtils/createContext/__tests__/__snapshots__/{index.test.js.snap → index.test.ts.snap} +2 -2
- package/reactUtils/createContext/__tests__/__snapshots__/provider.test.js.snap +3 -28
- package/reactUtils/createContext/__tests__/__snapshots__/withConsumer.test.js.snap +3 -4
- package/reactUtils/createContext/__tests__/__snapshots__/withProvider.test.js.snap +7 -3
- package/reactUtils/createContext/__tests__/helpers.test.js +107 -121
- package/reactUtils/createContext/__tests__/{index.test.js → index.test.ts} +2 -2
- package/reactUtils/createContext/__tests__/provider.test.js +4 -6
- package/reactUtils/createContext/__tests__/withConsumer.test.js +12 -12
- package/reactUtils/createContext/__tests__/withProvider.test.js +4 -4
- package/reactUtils/createContext/helpers.ts +6 -1
- package/reactUtils/createContext/index.ts +11 -25
- package/reactUtils/index.ts +0 -25
- package/screenState/index.ts +24 -10
- package/testUtils/index.tsx +0 -10
- package/theme/__mocks__/index.ts +4 -0
- package/theme/index.ts +1 -1
- package/time/Timer.ts +5 -2
- package/types.ts +1 -0
- package/zappFrameworkUtils/presentPluginOneTime.ts +2 -3
- package/appUtils/keyCodes/keys.ios.js +0 -46
- package/reactHooks/player/useAutoSeek.tsx +0 -87
- package/reactHooks/player/useSeek.tsx +0 -66
- package/reactHooks/player/useTapSeek.tsx +0 -58
- package/reactUtils/createContext/__tests__/index-no-react.test.js +0 -27
- /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/{localizationsHelper.js → localizationsHelper.ts} +0 -0
- /package/domUtils/{logger.js → logger.ts} +0 -0
- /package/reactHooks/player/__tests__/{useTapSeek.test.ts → useTapSeek._test.ts} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable react/prop-types */
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import { render } from "@testing-library/react-native";
|
|
4
|
+
|
|
5
5
|
import { View } from "react-native";
|
|
6
6
|
|
|
7
7
|
import { createProvider } from "../provider";
|
|
@@ -29,14 +29,12 @@ describe("createProvider", () => {
|
|
|
29
29
|
it("creates a context Provider component", () => {
|
|
30
30
|
const MockChild = (props) => <View>{props.context}</View>;
|
|
31
31
|
|
|
32
|
-
const wrapper =
|
|
32
|
+
const wrapper = render(
|
|
33
33
|
<Provider>
|
|
34
34
|
<MockChild context={"context"} />
|
|
35
35
|
</Provider>
|
|
36
36
|
);
|
|
37
37
|
|
|
38
|
-
expect(
|
|
39
|
-
|
|
40
|
-
expect(wrapper.find(ReactContext.Provider).props()).toMatchSnapshot();
|
|
38
|
+
expect(wrapper.toJSON()).toMatchSnapshot();
|
|
41
39
|
});
|
|
42
40
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable react/prop-types */
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import { render } from "@testing-library/react-native";
|
|
4
|
+
|
|
5
5
|
import { View } from "react-native";
|
|
6
6
|
|
|
7
7
|
import { createWithConsumerDecorator } from "../withConsumer";
|
|
@@ -11,21 +11,21 @@ describe("createConsumer", () => {
|
|
|
11
11
|
const { Consumer } = ReactContext;
|
|
12
12
|
const withConsumer = createWithConsumerDecorator(Consumer);
|
|
13
13
|
|
|
14
|
-
it("returns a function", () => {
|
|
15
|
-
expect(withConsumer).toBeFunction();
|
|
16
|
-
});
|
|
17
|
-
|
|
18
14
|
it("creates a context consumer function", () => {
|
|
19
|
-
|
|
20
|
-
const DecoratedChild = withConsumer(Child);
|
|
15
|
+
expect(withConsumer).toBeFunction();
|
|
21
16
|
const newContextValue = "newValue";
|
|
22
17
|
|
|
23
|
-
const
|
|
18
|
+
const Child = (props) => {
|
|
19
|
+
props.setContext(newContextValue);
|
|
20
|
+
|
|
21
|
+
return <View>{props.context}</View>;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const DecoratedChild = withConsumer(Child);
|
|
24
25
|
|
|
25
|
-
const
|
|
26
|
+
const wrapper = render(<DecoratedChild />);
|
|
26
27
|
|
|
27
|
-
expect(
|
|
28
|
-
childWrapper.props().setContext(newContextValue);
|
|
28
|
+
expect(wrapper.toJSON()).toMatchSnapshot();
|
|
29
29
|
|
|
30
30
|
expect(mockContextData.setContext).toHaveBeenCalledWith(newContextValue);
|
|
31
31
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable react/prop-types */
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import { render } from "@testing-library/react-native";
|
|
4
|
+
|
|
5
5
|
import { View, Text } from "react-native";
|
|
6
6
|
|
|
7
7
|
import { createWithProviderDecorator } from "../withProvider";
|
|
@@ -19,8 +19,8 @@ describe("withProvider", () => {
|
|
|
19
19
|
|
|
20
20
|
const DecoratedComponent = withProvider(Component);
|
|
21
21
|
|
|
22
|
-
const wrapper =
|
|
22
|
+
const wrapper = render(<DecoratedComponent />);
|
|
23
23
|
|
|
24
|
-
expect(
|
|
24
|
+
expect(wrapper.toJSON()).toMatchSnapshot();
|
|
25
25
|
});
|
|
26
26
|
});
|
|
@@ -33,7 +33,12 @@ export const getSetterName: (property: string) => string = R.compose(
|
|
|
33
33
|
export function createContextSetters(
|
|
34
34
|
properties: string[],
|
|
35
35
|
component: any,
|
|
36
|
-
options:
|
|
36
|
+
options: {
|
|
37
|
+
stateValidator?: (
|
|
38
|
+
obj: { property: string; value: unknown },
|
|
39
|
+
oldValue: unknown
|
|
40
|
+
) => boolean;
|
|
41
|
+
} = {}
|
|
37
42
|
) {
|
|
38
43
|
const { stateValidator = R.T } = options;
|
|
39
44
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import createReactContext from "create-react-context";
|
|
3
2
|
import * as R from "ramda";
|
|
4
3
|
|
|
5
4
|
import { getSetterName, NOOP } from "./helpers";
|
|
@@ -7,33 +6,20 @@ import { createProvider } from "./provider";
|
|
|
7
6
|
import { createWithConsumerDecorator } from "./withConsumer";
|
|
8
7
|
import { createWithProviderDecorator } from "./withProvider";
|
|
9
8
|
|
|
10
|
-
const reactContextCreator = React.createContext;
|
|
11
|
-
|
|
12
|
-
// Depending on the version of React used, the `createContext` function may not be available
|
|
13
|
-
// if this is the case, we fall back to a polyfill library
|
|
14
|
-
const contextCreatorFn =
|
|
15
|
-
reactContextCreator && typeof reactContextCreator === "function"
|
|
16
|
-
? reactContextCreator
|
|
17
|
-
: createReactContext;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* @typedef Context
|
|
21
|
-
* @property {Object} Context.Provider react class component to use as context provider
|
|
22
|
-
* @property {Function} Context.Consumer react functional component to use as context consumer
|
|
23
|
-
* @property {Function} Context.withProvider HOC to apply the context provider
|
|
24
|
-
* @property {function} Context.withConsumer HOC to apply the context consumer. passes the context as props
|
|
25
|
-
* @property {React.Context} Context.ReactContext React context object
|
|
26
|
-
* to the wrapped component
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
9
|
/**
|
|
30
10
|
* Creates a React Context and returns consumer & providers components & decorators to interact
|
|
31
11
|
* with this context.
|
|
32
|
-
* @param
|
|
33
|
-
* @param
|
|
34
|
-
* @returns
|
|
12
|
+
* @param initialContext map of context properties and their initial values
|
|
13
|
+
* @param stateValidator optional predicate to tell whether the state update is valid or not
|
|
14
|
+
* @returns Object containing the context components & decorators
|
|
35
15
|
*/
|
|
36
|
-
export function createContext(
|
|
16
|
+
export function createContext(
|
|
17
|
+
initialContext: Record<string, any>,
|
|
18
|
+
stateValidator: (
|
|
19
|
+
obj: { property: string; value: unknown },
|
|
20
|
+
oldValue: unknown
|
|
21
|
+
) => boolean = R.T
|
|
22
|
+
) {
|
|
37
23
|
// first we extract the properties name, and create setters name for those
|
|
38
24
|
const contextPropertiesNames = R.keys(initialContext);
|
|
39
25
|
const contextSettersNames = R.map(getSetterName, contextPropertiesNames);
|
|
@@ -41,7 +27,7 @@ export function createContext(initialContext, stateValidator = R.T) {
|
|
|
41
27
|
// we create a React Context with the properties & their setters, assigning a noop function
|
|
42
28
|
// temporarily (will be overriden by proper setters in the provider component)
|
|
43
29
|
const ReactContext = R.compose(
|
|
44
|
-
|
|
30
|
+
React.createContext,
|
|
45
31
|
R.merge(initialContext),
|
|
46
32
|
R.zipObj(contextSettersNames),
|
|
47
33
|
R.map(R.always(NOOP))
|
package/reactUtils/index.ts
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import * as R from "ramda";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { Platform } from "react-native";
|
|
5
|
-
import createRef from "create-react-ref/lib/createRef";
|
|
6
5
|
|
|
7
6
|
import { addLifeCycleMethods, wrapInClass, isClassComponent } from "./helpers";
|
|
8
7
|
|
|
@@ -19,16 +18,6 @@ export function attachLifeCycleMethods(lifecycleMethods) {
|
|
|
19
18
|
);
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
/**
|
|
23
|
-
* creates a React Ref. if the version of React doesn't
|
|
24
|
-
* have this API, will use a polyfill instead
|
|
25
|
-
*/
|
|
26
|
-
export function createReactRef() {
|
|
27
|
-
return React.createRef && typeof React.createRef === "function"
|
|
28
|
-
? React.createRef()
|
|
29
|
-
: createRef();
|
|
30
|
-
}
|
|
31
|
-
|
|
32
21
|
/**
|
|
33
22
|
* Clone the children and merge each of the cloned elements with otherProps.
|
|
34
23
|
* @param {React.Children} children to clone
|
|
@@ -109,20 +98,6 @@ export const isTvOSPlatform = () => getPlatform() === "tvos";
|
|
|
109
98
|
|
|
110
99
|
export const isAndroidTVPlatform = () => getPlatform() === "android_tv";
|
|
111
100
|
|
|
112
|
-
declare global {
|
|
113
|
-
interface Window {
|
|
114
|
-
VIZIO?: {
|
|
115
|
-
Chromevox: {
|
|
116
|
-
play: (text: string) => void;
|
|
117
|
-
};
|
|
118
|
-
exitApplication: () => void;
|
|
119
|
-
setClosedCaptionHandler: (
|
|
120
|
-
callback: (isCCEnabled: boolean) => void
|
|
121
|
-
) => void;
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
101
|
/**
|
|
127
102
|
* Platforms found in userAgent string, please note that simulators
|
|
128
103
|
* might not have the same agents that the devices have
|
package/screenState/index.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { create } from "zustand";
|
|
2
2
|
import { produce } from "immer";
|
|
3
3
|
import { path } from "ramda";
|
|
4
|
+
import React from "react";
|
|
5
|
+
import { useShallow } from "zustand/react/shallow";
|
|
4
6
|
|
|
5
7
|
type ScreenState = {
|
|
6
8
|
selectedEntry: {
|
|
@@ -18,6 +20,8 @@ type ScreenStore = {
|
|
|
18
20
|
setSelectedEntry: (screenId: string, entryId: string) => void;
|
|
19
21
|
};
|
|
20
22
|
|
|
23
|
+
type SetSelectedEntry = (screenId: string, entryId: string) => void;
|
|
24
|
+
|
|
21
25
|
const useScreenStore = create<ScreenStore>((set) => ({
|
|
22
26
|
screens: screensInitialState,
|
|
23
27
|
setSelectedEntry: (screenId, entryId) =>
|
|
@@ -35,17 +39,27 @@ const useScreenStore = create<ScreenStore>((set) => ({
|
|
|
35
39
|
export function useScreenState(
|
|
36
40
|
screenId: ScreenId
|
|
37
41
|
): null | { screen: ScreenState; setSelectedEntry: (entryId: string) => void } {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
) as ScreenState;
|
|
42
|
+
const screenState = useScreenStore<ScreenState>(
|
|
43
|
+
useShallow(path(["screens", screenId]))
|
|
44
|
+
);
|
|
42
45
|
|
|
43
|
-
const setSelectedEntry = useScreenStore(
|
|
46
|
+
const setSelectedEntry = useScreenStore<SetSelectedEntry>(
|
|
47
|
+
useShallow(path(["setSelectedEntry"]))
|
|
48
|
+
);
|
|
44
49
|
|
|
45
|
-
|
|
50
|
+
const memoizedSetSelectedEntry = React.useCallback(
|
|
51
|
+
(entryId) => setSelectedEntry(screenId, entryId),
|
|
52
|
+
[screenId, setSelectedEntry]
|
|
53
|
+
);
|
|
46
54
|
|
|
47
|
-
return
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
55
|
+
return React.useMemo(
|
|
56
|
+
() =>
|
|
57
|
+
!screenId
|
|
58
|
+
? null
|
|
59
|
+
: {
|
|
60
|
+
screen: screenState,
|
|
61
|
+
setSelectedEntry: memoizedSetSelectedEntry,
|
|
62
|
+
},
|
|
63
|
+
[screenId, screenState]
|
|
64
|
+
);
|
|
51
65
|
}
|
package/testUtils/index.tsx
CHANGED
|
@@ -15,16 +15,6 @@ import { ThemeContext } from "../theme";
|
|
|
15
15
|
|
|
16
16
|
export { getByTestId } from "./getByTestId";
|
|
17
17
|
|
|
18
|
-
/**
|
|
19
|
-
* Function to be used in tandem with enzyme findWhere(node => node.prop('testID') === 'yourID')
|
|
20
|
-
* Example:
|
|
21
|
-
* wrapper.findWhere(testIDEquals('yourID'))
|
|
22
|
-
* @param {*} testId
|
|
23
|
-
* @return boolean
|
|
24
|
-
*/
|
|
25
|
-
export const testIDEquals = (testId: any): boolean =>
|
|
26
|
-
R.compose(R.equals(testId), R.invoker(1, "prop")("testID"));
|
|
27
|
-
|
|
28
18
|
/** Helper function for react-test-renderer, accepts type and renderer
|
|
29
19
|
* * @param {*} type React Component type instance or name of component
|
|
30
20
|
* * @param {*} renderer renderer instance
|
package/theme/__mocks__/index.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
1
3
|
export const themeMock = {
|
|
2
4
|
screen_padding_top: 20,
|
|
3
5
|
screen_padding_bottom: 48,
|
|
@@ -17,3 +19,5 @@ export const themeMock = {
|
|
|
17
19
|
};
|
|
18
20
|
|
|
19
21
|
export const useTheme = jest.fn().mockReturnValue(themeMock);
|
|
22
|
+
|
|
23
|
+
export const ThemeContext = React.createContext(themeMock);
|
package/theme/index.ts
CHANGED
|
@@ -14,7 +14,7 @@ export const ThemeContext = React.createContext({
|
|
|
14
14
|
export function useTheme<
|
|
15
15
|
T extends Record<string, any> =
|
|
16
16
|
| BaseThemePropertiesTV
|
|
17
|
-
| BaseThemePropertiesMobile
|
|
17
|
+
| BaseThemePropertiesMobile,
|
|
18
18
|
>(): T {
|
|
19
19
|
const { themes, selectedThemeId } = React.useContext(ThemeContext);
|
|
20
20
|
|
package/time/Timer.ts
CHANGED
|
@@ -3,8 +3,11 @@ export class Timer {
|
|
|
3
3
|
private remaining: number;
|
|
4
4
|
private timeoutId: NodeJS.Timeout | null;
|
|
5
5
|
|
|
6
|
-
constructor(
|
|
7
|
-
|
|
6
|
+
constructor(
|
|
7
|
+
private callback: () => void,
|
|
8
|
+
private duration: number
|
|
9
|
+
) {
|
|
10
|
+
this.remaining = this.duration;
|
|
8
11
|
this.timeoutId = null;
|
|
9
12
|
}
|
|
10
13
|
|
package/types.ts
CHANGED
|
@@ -92,9 +92,8 @@ export const PresentHookPluginOneTime = (
|
|
|
92
92
|
const presentOneTimeVersionName =
|
|
93
93
|
await getLatestWatchedVersionNumberFromStorage(storageKey, namespace);
|
|
94
94
|
|
|
95
|
-
const applicationVersionName =
|
|
96
|
-
versionNameKey
|
|
97
|
-
);
|
|
95
|
+
const applicationVersionName =
|
|
96
|
+
await sessionStorage.getItem(versionNameKey);
|
|
98
97
|
|
|
99
98
|
if (!presentOneTimeVersionName || !applicationVersionName) {
|
|
100
99
|
log_info(
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/* global tizen */
|
|
2
|
-
const isTizen = typeof tizen !== "undefined";
|
|
3
|
-
|
|
4
|
-
export const KEYS = {
|
|
5
|
-
Enter: { code: "Enter", keyCode: 13 },
|
|
6
|
-
Space: { code: "Space", keyCode: 32 },
|
|
7
|
-
m: { code: "m", keyCode: 77 },
|
|
8
|
-
ArrowLeft: { code: "ArrowLeft", keyCode: 37 },
|
|
9
|
-
ArrowUp: { code: "ArrowUp", keyCode: 38 },
|
|
10
|
-
ArrowRight: { code: "ArrowRight", keyCode: 39 },
|
|
11
|
-
ArrowDown: { code: "ArrowDown", keyCode: 40 },
|
|
12
|
-
Back: isTizen
|
|
13
|
-
? { code: "Back", keyCode: 10009 }
|
|
14
|
-
: { code: "Backspace", keyCode: 8 },
|
|
15
|
-
Play: isTizen
|
|
16
|
-
? { code: "MediaPlay", keyCode: 10252 }
|
|
17
|
-
: { code: "PlayPause", keyCode: 179 },
|
|
18
|
-
Pause: isTizen
|
|
19
|
-
? { code: "MediaPause", keyCode: 19 }
|
|
20
|
-
: { code: "Pause", keyCode: 179 },
|
|
21
|
-
Forward: isTizen
|
|
22
|
-
? { code: "MediaFastForward", keyCode: 417 }
|
|
23
|
-
: { code: "Forward", keyCode: 176 },
|
|
24
|
-
Rewind: isTizen
|
|
25
|
-
? { code: "MediaRewind", keyCode: 412 }
|
|
26
|
-
: { code: "Rewind", keyCode: 177 },
|
|
27
|
-
VolumeUp: isTizen
|
|
28
|
-
? { code: "VolumeUp", keyCode: 447 }
|
|
29
|
-
: { code: "VolumeUp", keyCode: 175 },
|
|
30
|
-
VolumeDown: isTizen
|
|
31
|
-
? { code: "VolumeDown", keyCode: 448 }
|
|
32
|
-
: { code: "VolumeDown", keyCode: 174 },
|
|
33
|
-
ToggleMute: isTizen
|
|
34
|
-
? { code: "VolumeMute", keyCode: 449 }
|
|
35
|
-
: { code: "VolumeMute", keyCode: 173 },
|
|
36
|
-
Stop: isTizen
|
|
37
|
-
? { code: "MediaStop", keyCode: 413 }
|
|
38
|
-
: { code: "Q", keyCode: 81 },
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export const ARROW_KEYS = [
|
|
42
|
-
KEYS.ArrowUp,
|
|
43
|
-
KEYS.ArrowLeft,
|
|
44
|
-
KEYS.ArrowDown,
|
|
45
|
-
KEYS.ArrowRight,
|
|
46
|
-
];
|
|
@@ -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
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
jest.mock("create-react-context", () =>
|
|
2
|
-
jest.fn(() => ({
|
|
3
|
-
Consumer: jest.fn(),
|
|
4
|
-
Provider: jest.fn(),
|
|
5
|
-
}))
|
|
6
|
-
);
|
|
7
|
-
|
|
8
|
-
jest.mock("react", () => ({
|
|
9
|
-
...jest.requireActual("react"),
|
|
10
|
-
createContext: undefined,
|
|
11
|
-
}));
|
|
12
|
-
|
|
13
|
-
const { createContext } = require("../index");
|
|
14
|
-
const createReactContext = require("create-react-context");
|
|
15
|
-
|
|
16
|
-
describe("when react context api is not defined", () => {
|
|
17
|
-
it("uses the polyfill", () => {
|
|
18
|
-
createContext({ foo: "bar" });
|
|
19
|
-
|
|
20
|
-
expect(createReactContext).toHaveBeenCalledWith(
|
|
21
|
-
expect.objectContaining({
|
|
22
|
-
foo: "bar",
|
|
23
|
-
setFoo: expect.any(Function),
|
|
24
|
-
})
|
|
25
|
-
);
|
|
26
|
-
});
|
|
27
|
-
});
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|