@applicaster/zapp-react-native-utils 13.0.0-rc.4 → 13.0.0-rc.40

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 +47 -18
  40. package/appUtils/playerManager/index.ts +6 -2
  41. package/appUtils/playerManager/player.ts +19 -7
  42. package/appUtils/playerManager/playerNative.ts +3 -2
  43. package/appUtils/playerManager/usePlayerControllerSetup.tsx +3 -3
  44. package/arrayUtils/__tests__/__snapshots__/arrayUtils.test.ts.snap +4 -4
  45. package/domUtils/{cookieManager.js → cookieManager.ts} +1 -2
  46. package/equalUtils/index.ts +10 -3
  47. package/functionUtils/__tests__/__snapshots__/functionUtils.test.js.snap +4 -4
  48. package/functionUtils/index.ts +15 -11
  49. package/idleUtils/__tests__/withTimeout$.test.ts +37 -0
  50. package/idleUtils/index.ts +1 -1
  51. package/idleUtils/withTimeout.ts +15 -2
  52. package/logger/const.ts +9 -67
  53. package/manifestUtils/__tests__/createConfig.test.js +16 -16
  54. package/modalState/index.ts +1 -5
  55. package/navigationUtils/__tests__/__snapshots__/navigationUtils.test.js.snap +6 -6
  56. package/navigationUtils/__tests__/itemTypes.test.js +2 -2
  57. package/navigationUtils/__tests__/navigationUtils.test.js +2 -2
  58. package/navigationUtils/index.ts +17 -8
  59. package/package.json +3 -2
  60. package/reactHooks/autoscrolling/__tests__/useTrackCurrentAutoScrollingElement.test.ts +1 -1
  61. package/reactHooks/autoscrolling/__tests__/useTrackedView.test.tsx +1 -1
  62. package/reactHooks/cell-click/__tests__/index.test.js +10 -2
  63. package/reactHooks/cell-click/index.ts +7 -1
  64. package/reactHooks/feed/__tests__/useBuildPipesUrl.test.tsx +4 -4
  65. package/reactHooks/feed/__tests__/useFeedLoader.test.tsx +20 -13
  66. package/reactHooks/feed/useFeedLoader.tsx +10 -5
  67. package/reactHooks/feed/usePipesCacheReset.ts +5 -5
  68. package/reactHooks/flatList/__tests__/index.test.tsx +30 -21
  69. package/reactHooks/layout/__tests__/index.test.tsx +10 -10
  70. package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.native.test.js +14 -28
  71. package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.test.js +1 -1
  72. package/reactHooks/layout/useDimensions/useDimensions.ts +8 -0
  73. package/reactHooks/navigation/__tests__/index.test.tsx +0 -4
  74. package/reactHooks/navigation/index.ts +29 -218
  75. package/reactHooks/navigation/useGetBottomTabBarHeight.ts +12 -0
  76. package/reactHooks/navigation/useGetNavBarTopBorderWidth.ts +14 -0
  77. package/reactHooks/navigation/useGetTabBarHeight.ts +10 -0
  78. package/reactHooks/navigation/useIsScreenActive.ts +17 -0
  79. package/reactHooks/navigation/useNavigationPluginData.ts +15 -0
  80. package/reactHooks/navigation/useNavigationType.ts +15 -0
  81. package/reactHooks/navigation/usePathname.ts +4 -0
  82. package/reactHooks/navigation/useRoute.ts +100 -0
  83. package/reactHooks/navigation/useUniqueRouteSuffix.ts +41 -0
  84. package/reactHooks/player/TVSeekControlller/ISeekController.ts +32 -0
  85. package/reactHooks/player/TVSeekControlller/LongPressSeekController.ts +71 -0
  86. package/reactHooks/player/TVSeekControlller/TVSeekController.ts +258 -0
  87. package/reactHooks/player/TVSeekControlller/TapSeekController.ts +53 -0
  88. package/reactHooks/player/__tests__/{useAutoSeek.test.tsx → useAutoSeek._test.tsx} +2 -3
  89. package/reactHooks/player/const.ts +0 -4
  90. package/reactHooks/player/index.ts +0 -6
  91. package/reactHooks/state/useRefWithInitialValue.ts +14 -0
  92. package/reactHooks/state/useStateFromSubscribe.ts +23 -0
  93. package/reactHooks/usePluginConfiguration.ts +1 -1
  94. package/reactHooks/useSubscriberFor.ts +4 -3
  95. package/reactHooks/utils/index.ts +1 -1
  96. package/reactUtils/__tests__/reactUtils.test.js +10 -28
  97. package/reactUtils/createContext/__tests__/__snapshots__/helpers.test.js.snap +19 -19
  98. package/reactUtils/createContext/__tests__/__snapshots__/index.test.js.snap +2 -2
  99. package/reactUtils/createContext/__tests__/__snapshots__/provider.test.js.snap +3 -3
  100. package/reactUtils/createContext/__tests__/helpers.test.js +8 -8
  101. package/reactUtils/index.ts +0 -14
  102. package/screenState/index.ts +24 -10
  103. package/theme/__mocks__/index.ts +4 -0
  104. package/theme/index.ts +1 -1
  105. package/time/Timer.ts +5 -2
  106. package/types.ts +1 -0
  107. package/zappFrameworkUtils/presentPluginOneTime.ts +2 -3
  108. package/appUtils/keyCodes/keys.ios.js +0 -46
  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
@@ -91,7 +91,7 @@ export function useLayoutConfiguration<
91
91
  S extends unknown,
92
92
  G extends unknown,
93
93
  R extends unknown,
94
- L extends unknown
94
+ L extends unknown,
95
95
  >(layoutData, manifest, options: Options = {}) {
96
96
  const keys = options.keys || [
97
97
  "assets",
@@ -4,9 +4,10 @@ import { subscriber } from "@applicaster/zapp-react-native-utils/functionUtils";
4
4
  const subscriberObjects = Object.create({});
5
5
 
6
6
  interface UseSubscriberFor {
7
- (eventName: string, handler?: (...args: unknown[]) => void): (
8
- ...args: unknown[]
9
- ) => ReturnType<typeof subscriber>;
7
+ (
8
+ eventName: string,
9
+ handler?: (...args: unknown[]) => void
10
+ ): (...args: unknown[]) => ReturnType<typeof subscriber>;
10
11
  }
11
12
 
12
13
  /**
@@ -33,7 +33,7 @@ export const useIsInitialRender = (): boolean => {
33
33
 
34
34
  export const checkIsLocalFeed = (feedUrl) => feedUrl?.startsWith("pipesv2://");
35
35
 
36
- export const shouldUseCachedData = (
36
+ export const shouldDispatchData = (
37
37
  url: string,
38
38
  feed: ZappPipesData | null,
39
39
  clearCache: boolean
@@ -1,4 +1,3 @@
1
- jest.mock("create-react-ref/lib/createRef", () => jest.fn());
2
1
  import * as React from "react";
3
2
  import * as helpers from "../helpers";
4
3
 
@@ -8,13 +7,7 @@ import {
8
7
  componentDidMount,
9
8
  } from "./fixtures";
10
9
 
11
- const {
12
- attachLifeCycleMethods,
13
- createReactRef,
14
- mergeChildrenProps,
15
- } = require("../index");
16
-
17
- const createRef = require("create-react-ref/lib/createRef");
10
+ import { attachLifeCycleMethods, createReactRef, mergeChildrenProps } from "..";
18
11
 
19
12
  describe("attachLifeCycleMethods", () => {
20
13
  let addLifeCycleMethodsSpy;
@@ -50,30 +43,19 @@ describe("attachLifeCycleMethods", () => {
50
43
 
51
44
  describe("createReactRef", () => {
52
45
  it("calls the React.createRef function if it exists", () => {
53
- jest.resetModules();
54
-
55
- jest.doMock("react", () => ({
56
- ...jest.requireActual("react"),
57
- createRef: jest.fn(),
58
- }));
59
-
60
- const React = require("react");
46
+ jest.clearAllMocks();
61
47
 
62
- createReactRef();
63
- expect(React.createRef).toHaveBeenCalled();
64
- expect(createRef).not.toHaveBeenCalled();
48
+ const ref = createReactRef();
49
+ expect(ref).toHaveProperty("current");
65
50
  });
66
51
 
67
52
  it("calls the polyfill if React.createRef doesn't exist", () => {
68
- jest.resetModules();
69
-
70
- jest.doMock("react", () => ({
71
- ...jest.requireActual("react"),
72
- createRef: undefined,
73
- }));
74
-
75
- createReactRef();
76
- expect(createRef).toHaveBeenCalled();
53
+ jest.clearAllMocks();
54
+ const originalCreateRef = React.createRef;
55
+ React.createRef = undefined;
56
+ const ref = createReactRef();
57
+ expect(ref).toHaveProperty("current");
58
+ React.createRef = originalCreateRef;
77
59
  });
78
60
  });
79
61
 
@@ -1,104 +1,104 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`createContextSetters when no state validator is provided calls setState when the setters are called, no matter what the value is 1`] = `
4
- Object {
4
+ {
5
5
  "bar": "bar",
6
6
  "foo": "foo",
7
7
  }
8
8
  `;
9
9
 
10
10
  exports[`createContextSetters when no state validator is provided calls setState when the setters are called, no matter what the value is 2`] = `
11
- Object {
11
+ {
12
12
  "bar": "bar",
13
13
  "foo": "invalid foo",
14
14
  }
15
15
  `;
16
16
 
17
17
  exports[`createContextSetters when no state validator is provided calls setState when the setters are called, no matter what the value is 3`] = `
18
- Object {
18
+ {
19
19
  "bar": "invalid bar",
20
20
  "foo": "invalid foo",
21
21
  }
22
22
  `;
23
23
 
24
24
  exports[`createContextSetters when no state validator is provided calls setState when the setters are called, no matter what the value is 4`] = `
25
- Array [
26
- Array [
25
+ [
26
+ [
27
27
  [Function],
28
28
  ],
29
- Array [
29
+ [
30
30
  [Function],
31
31
  ],
32
32
  ]
33
33
  `;
34
34
 
35
35
  exports[`createContextSetters when state validator is provided calls setState when the setters are called & the validator passes 1`] = `
36
- Object {
36
+ {
37
37
  "bar": "bar",
38
38
  "foo": "foo",
39
39
  }
40
40
  `;
41
41
 
42
42
  exports[`createContextSetters when state validator is provided calls setState when the setters are called & the validator passes 2`] = `
43
- Object {
43
+ {
44
44
  "bar": "bar",
45
45
  "foo": "new foo",
46
46
  }
47
47
  `;
48
48
 
49
49
  exports[`createContextSetters when state validator is provided calls setState when the setters are called & the validator passes 3`] = `
50
- Object {
50
+ {
51
51
  "bar": "new bar",
52
52
  "foo": "new foo",
53
53
  }
54
54
  `;
55
55
 
56
56
  exports[`createContextSetters when state validator is provided calls setState when the setters are called & the validator passes 4`] = `
57
- Array [
58
- Array [
57
+ [
58
+ [
59
59
  [Function],
60
60
  ],
61
- Array [
61
+ [
62
62
  [Function],
63
63
  ],
64
64
  ]
65
65
  `;
66
66
 
67
67
  exports[`createContextSetters when state validator is provided skips the update if the new value is the same as the previous one 1`] = `
68
- Object {
68
+ {
69
69
  "bar": "bar",
70
70
  "foo": "new foo",
71
71
  }
72
72
  `;
73
73
 
74
74
  exports[`createContextSetters when state validator is provided skips the update if the state validator doesn't pass 1`] = `
75
- Object {
75
+ {
76
76
  "bar": "bar",
77
77
  "foo": "foo",
78
78
  }
79
79
  `;
80
80
 
81
81
  exports[`createContextSetters when state validator is provided skips the update if the state validator doesn't pass 2`] = `
82
- Object {
82
+ {
83
83
  "bar": "bar",
84
84
  "foo": "foo",
85
85
  }
86
86
  `;
87
87
 
88
88
  exports[`createContextSetters when state validator is provided skips the update if the state validator doesn't pass 3`] = `
89
- Object {
89
+ {
90
90
  "bar": "bar",
91
91
  "foo": "foo",
92
92
  }
93
93
  `;
94
94
 
95
95
  exports[`createContextSetters when state validator is provided skips the update if the state validator doesn't pass 4`] = `
96
- Array [
97
- Array [
96
+ [
97
+ [
98
98
  "trying to invoke setFoo with invalid foo - but it was rejected by the state validator
99
99
  skipping context update",
100
100
  ],
101
- Array [
101
+ [
102
102
  "trying to invoke setBar with invalid bar - but it was rejected by the state validator
103
103
  skipping context update",
104
104
  ],
@@ -1,10 +1,10 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`createContext - when React has the new context API returns the components and the decorators 1`] = `
4
- Object {
4
+ {
5
5
  "Consumer": [MockFunction],
6
6
  "Provider": [MockFunction],
7
- "ReactContext": Object {
7
+ "ReactContext": {
8
8
  "Consumer": [MockFunction],
9
9
  "Provider": [MockFunction],
10
10
  },
@@ -3,7 +3,7 @@
3
3
  exports[`createProvider creates a context Provider component 1`] = `
4
4
  <mockConstructor
5
5
  value={
6
- Object {
6
+ {
7
7
  "context": "initialValue",
8
8
  "otherContext": "otherValue",
9
9
  "setContext": [Function],
@@ -18,11 +18,11 @@ exports[`createProvider creates a context Provider component 1`] = `
18
18
  `;
19
19
 
20
20
  exports[`createProvider creates a context Provider component 2`] = `
21
- Object {
21
+ {
22
22
  "children": <MockChild
23
23
  context="context"
24
24
  />,
25
- "value": Object {
25
+ "value": {
26
26
  "context": "initialValue",
27
27
  "otherContext": "otherValue",
28
28
  "setContext": [Function],
@@ -9,13 +9,13 @@ function stateValidator({ property, value }) {
9
9
  );
10
10
  }
11
11
 
12
- const logger = {
12
+ const mockLogger = {
13
13
  warning: jest.fn(),
14
14
  };
15
15
 
16
16
  jest.mock("../../logger", () => ({
17
17
  reactUtilsLogger: {
18
- addSubsystem: jest.fn(() => logger),
18
+ addSubsystem: jest.fn(() => mockLogger),
19
19
  },
20
20
  }));
21
21
 
@@ -62,7 +62,7 @@ describe("createContextSetters", () => {
62
62
  beforeEach(() => {
63
63
  instance.resetInitialState();
64
64
  setStateSpy.mockClear();
65
- logger.warning.mockClear();
65
+ mockLogger.warning.mockClear();
66
66
  });
67
67
 
68
68
  it("adds all properties and setters to the component", () => {
@@ -83,7 +83,7 @@ describe("createContextSetters", () => {
83
83
 
84
84
  expect(setStateSpy).toHaveBeenCalledTimes(2);
85
85
  expect(setStateSpy.mock.calls).toMatchSnapshot();
86
- expect(logger.warning).not.toHaveBeenCalled();
86
+ expect(mockLogger.warning).not.toHaveBeenCalled();
87
87
  });
88
88
 
89
89
  it("skips the update if the state validator doesn't pass", () => {
@@ -96,8 +96,8 @@ describe("createContextSetters", () => {
96
96
  expect(instance.state).toMatchSnapshot();
97
97
 
98
98
  expect(setStateSpy).not.toHaveBeenCalled();
99
- expect(logger.warning).toHaveBeenCalledTimes(2);
100
- expect(logger.warning.mock.calls).toMatchSnapshot();
99
+ expect(mockLogger.warning).toHaveBeenCalledTimes(2);
100
+ expect(mockLogger.warning.mock.calls).toMatchSnapshot();
101
101
  });
102
102
 
103
103
  it("skips the update if the new value is the same as the previous one", () => {
@@ -131,7 +131,7 @@ describe("createContextSetters", () => {
131
131
 
132
132
  afterEach(() => {
133
133
  setStateSpy.mockClear();
134
- logger.warning.mockClear();
134
+ mockLogger.warning.mockClear();
135
135
  });
136
136
 
137
137
  it("adds all properties and setters to the component", () => {
@@ -152,7 +152,7 @@ describe("createContextSetters", () => {
152
152
 
153
153
  expect(setStateSpy).toHaveBeenCalledTimes(2);
154
154
  expect(setStateSpy.mock.calls).toMatchSnapshot();
155
- expect(logger.warning).not.toHaveBeenCalled();
155
+ expect(mockLogger.warning).not.toHaveBeenCalled();
156
156
  });
157
157
  });
158
158
  });
@@ -109,20 +109,6 @@ export const isTvOSPlatform = () => getPlatform() === "tvos";
109
109
 
110
110
  export const isAndroidTVPlatform = () => getPlatform() === "android_tv";
111
111
 
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
112
  /**
127
113
  * Platforms found in userAgent string, please note that simulators
128
114
  * might not have the same agents that the devices have
@@ -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
- // const state = useState(screenState);
39
- const screenState = useScreenStore(
40
- path(["screens", screenId])
41
- ) as ScreenState;
42
+ const screenState = useScreenStore<ScreenState>(
43
+ useShallow(path(["screens", screenId]))
44
+ );
42
45
 
43
- const setSelectedEntry = useScreenStore((state) => state.setSelectedEntry);
46
+ const setSelectedEntry = useScreenStore<SetSelectedEntry>(
47
+ useShallow(path(["setSelectedEntry"]))
48
+ );
44
49
 
45
- if (!screenId) return null;
50
+ const memoizedSetSelectedEntry = React.useCallback(
51
+ (entryId) => setSelectedEntry(screenId, entryId),
52
+ [screenId, setSelectedEntry]
53
+ );
46
54
 
47
- return {
48
- screen: screenState,
49
- setSelectedEntry: (entryId) => setSelectedEntry(screenId, entryId),
50
- };
55
+ return React.useMemo(
56
+ () =>
57
+ !screenId
58
+ ? null
59
+ : {
60
+ screen: screenState,
61
+ setSelectedEntry: memoizedSetSelectedEntry,
62
+ },
63
+ [screenId, screenState]
64
+ );
51
65
  }
@@ -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(private callback: () => void, private duration: number) {
7
- this.remaining = duration;
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
@@ -8,4 +8,5 @@ export type ManifestField<T> = {
8
8
 
9
9
  export enum ENDPOINT_TAGS {
10
10
  allow_missing_keys = "allow_missing_keys",
11
+ observe_storage = "observe_storage",
11
12
  }
@@ -92,9 +92,8 @@ export const PresentHookPluginOneTime = (
92
92
  const presentOneTimeVersionName =
93
93
  await getLatestWatchedVersionNumberFromStorage(storageKey, namespace);
94
94
 
95
- const applicationVersionName = await sessionStorage.getItem(
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
- );