@applicaster/zapp-react-native-utils 13.0.0-alpha.9270615060 → 13.0.0-alpha.9519442225

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 (147) hide show
  1. package/README.md +0 -10
  2. package/actionsExecutor/ActionExecutor.ts +16 -9
  3. package/actionsExecutor/ActionExecutorContext.tsx +74 -9
  4. package/alertUtils/alert.ts +148 -0
  5. package/alertUtils/index.ts +1 -148
  6. package/analyticsUtils/AnalyticPlayerListener.ts +18 -1
  7. package/analyticsUtils/AnalyticsEvents/sendHeaderClickEvent.ts +1 -1
  8. package/analyticsUtils/AnalyticsEvents/sendMenuClickEvent.ts +2 -1
  9. package/analyticsUtils/__tests__/__snapshots__/analyticsManagerNoModule.test.js.snap +9 -9
  10. package/analyticsUtils/currentScreenProperities.ts +6 -4
  11. package/analyticsUtils/helpers/hooks.ts +1 -1
  12. package/analyticsUtils/index.tsx +3 -4
  13. package/analyticsUtils/manager.ts +1 -1
  14. package/appUtils/HooksManager/{Hook.js → Hook.ts} +35 -23
  15. package/appUtils/HooksManager/__tests__/__snapshots__/hook.test.js.snap +10 -8
  16. package/appUtils/HooksManager/__tests__/__snapshots__/hooksManager.test.js.snap +693 -0
  17. package/appUtils/HooksManager/__tests__/hook.test.js +196 -184
  18. package/appUtils/HooksManager/__tests__/hooksManager.test.js +96 -99
  19. package/appUtils/HooksManager/{constants.js → constants.ts} +1 -1
  20. package/appUtils/HooksManager/{index.js → index.ts} +122 -113
  21. package/appUtils/HooksManager/types.ts +119 -0
  22. package/appUtils/RiverFocusManager/index.js +17 -12
  23. package/appUtils/accessibilityManager/index.ts +42 -1
  24. package/appUtils/contextKeysManager/contextResolver.ts +77 -0
  25. package/appUtils/contextKeysManager/index.ts +2 -2
  26. package/appUtils/contextKeysManager/utils/index.ts +2 -1
  27. package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +7 -6
  28. package/appUtils/focusManager/index.ts +100 -74
  29. package/appUtils/focusManager/treeDataStructure/Tree/index.js +25 -3
  30. package/appUtils/focusManager/treeDataStructure/Utils/index.js +1 -3
  31. package/appUtils/focusManager/utils/enums.ts +4 -0
  32. package/appUtils/focusManagerAux/utils/index.ts +4 -3
  33. package/appUtils/{index.js → index.ts} +1 -1
  34. package/appUtils/keyCodes/__tests__/__snapshots__/keyCodes.test.js.snap +2 -2
  35. package/appUtils/keyCodes/__tests__/keyCodes.test.js +4 -4
  36. package/appUtils/keyCodes/{index.js → index.ts} +13 -7
  37. package/appUtils/keyCodes/keys/index.ts +3 -0
  38. package/appUtils/keyCodes/{keys.android.js → keys/keyEventMapper.ts} +0 -19
  39. package/appUtils/keyCodes/keys/keys.android.ts +18 -0
  40. package/appUtils/keyCodes/keys/keys.ios.ts +25 -0
  41. package/appUtils/keyCodes/keys/keys.ts +15 -0
  42. package/appUtils/keyCodes/{keysByPlatform.js → keys/keysByPlatform.ts} +4 -3
  43. package/appUtils/keyCodes/keysByPlatform.ts +8 -0
  44. package/appUtils/keyInputHandler/KeyInputHandler.ts +10 -32
  45. package/appUtils/orientationHelper.ts +1 -2
  46. package/appUtils/platform/const.ts +14 -0
  47. package/appUtils/platform/platformUtils.ts +47 -18
  48. package/appUtils/playerManager/index.ts +7 -3
  49. package/appUtils/playerManager/player.ts +9 -10
  50. package/appUtils/playerManager/playerNative.ts +1 -1
  51. package/appUtils/playerManager/usePlayerControllerSetup.tsx +1 -15
  52. package/arrayUtils/__tests__/__snapshots__/arrayUtils.test.ts.snap +4 -4
  53. package/domUtils/{cookieManager.js → cookieManager.ts} +1 -2
  54. package/equalUtils/__tests__/isEqual/combination.test.ts +263 -0
  55. package/equalUtils/index.ts +49 -30
  56. package/focusManager/FocusManager.ts +11 -1
  57. package/focusManager/index.ts +41 -4
  58. package/functionUtils/__tests__/__snapshots__/functionUtils.test.js.snap +4 -4
  59. package/functionUtils/index.ts +36 -19
  60. package/idleUtils/__tests__/withTimeout$.test.ts +37 -0
  61. package/idleUtils/index.ts +1 -1
  62. package/idleUtils/withTimeout.ts +15 -2
  63. package/logger/const.ts +9 -67
  64. package/manifestUtils/__tests__/createConfig.test.js +16 -16
  65. package/manifestUtils/fonts/index.js +5 -6
  66. package/manifestUtils/sharedConfiguration/screenPicker/__tests__/utils.test.js +304 -0
  67. package/manifestUtils/sharedConfiguration/screenPicker/stylesFields.js +875 -0
  68. package/manifestUtils/sharedConfiguration/screenPicker/utils.js +130 -0
  69. package/modalState/index.ts +1 -5
  70. package/navigationUtils/__tests__/__snapshots__/navigationUtils.test.js.snap +6 -6
  71. package/navigationUtils/__tests__/itemTypes.test.js +2 -2
  72. package/navigationUtils/__tests__/navigationUtils.test.js +2 -2
  73. package/navigationUtils/index.ts +17 -8
  74. package/numberUtils/index.ts +7 -5
  75. package/package.json +5 -9
  76. package/reactHooks/app/useAppState.ts +2 -2
  77. package/reactHooks/autoscrolling/__tests__/useTrackCurrentAutoScrollingElement.test.ts +1 -1
  78. package/reactHooks/autoscrolling/__tests__/useTrackedView.test.tsx +6 -8
  79. package/reactHooks/autoscrolling/useTrackedView.ts +12 -1
  80. package/reactHooks/cell-click/__tests__/index.test.js +10 -2
  81. package/reactHooks/cell-click/index.ts +7 -1
  82. package/reactHooks/feed/__tests__/useBatchLoading.test.tsx +39 -88
  83. package/reactHooks/feed/__tests__/useBuildPipesUrl.test.tsx +4 -4
  84. package/reactHooks/feed/__tests__/useFeedLoader.test.tsx +10 -11
  85. package/reactHooks/feed/useFeedLoader.tsx +1 -1
  86. package/reactHooks/feed/usePipesCacheReset.ts +5 -5
  87. package/reactHooks/flatList/__tests__/index.test.tsx +30 -21
  88. package/reactHooks/layout/__tests__/index.test.tsx +10 -10
  89. package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.native.test.js +14 -28
  90. package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.test.js +1 -1
  91. package/reactHooks/layout/useDimensions/useDimensions.ts +8 -0
  92. package/reactHooks/navigation/__mocks__/useNavigation.ts +3 -0
  93. package/reactHooks/navigation/__tests__/index.test.tsx +6 -21
  94. package/reactHooks/navigation/index.ts +40 -241
  95. package/reactHooks/navigation/useGetBottomTabBarHeight.ts +12 -0
  96. package/reactHooks/navigation/useGetNavBarTopBorderWidth.ts +14 -0
  97. package/reactHooks/navigation/useGetTabBarHeight.ts +10 -0
  98. package/reactHooks/navigation/useIsScreenActive.ts +17 -0
  99. package/reactHooks/navigation/useNavigationPluginData.ts +15 -0
  100. package/reactHooks/navigation/useNavigationType.ts +15 -0
  101. package/reactHooks/navigation/usePathname.ts +4 -0
  102. package/reactHooks/navigation/useProfilerLogging.ts +15 -0
  103. package/reactHooks/navigation/useRoute.ts +100 -0
  104. package/reactHooks/navigation/useUniqueRouteSuffix.ts +41 -0
  105. package/reactHooks/player/TVSeekControlller/ISeekController.ts +28 -3
  106. package/reactHooks/player/TVSeekControlller/LongPressSeekController.ts +43 -95
  107. package/reactHooks/player/TVSeekControlller/TVSeekController.ts +188 -98
  108. package/reactHooks/player/TVSeekControlller/TapSeekController.ts +35 -55
  109. package/reactHooks/player/__tests__/useAutoSeek._test.tsx +115 -0
  110. package/reactHooks/player/__tests__/useTapSeek._test.ts +94 -0
  111. package/reactHooks/player/const.ts +1 -5
  112. package/reactHooks/state/useRefWithInitialValue.ts +14 -0
  113. package/reactHooks/state/useStateFromSubscribe.ts +23 -0
  114. package/reactHooks/usePluginConfiguration.ts +1 -1
  115. package/reactHooks/useSubscriberFor.ts +4 -3
  116. package/reactUtils/__tests__/__snapshots__/reactUtilsHelpers.test.js.snap +16 -4
  117. package/reactUtils/__tests__/reactUtils.test.js +1 -37
  118. package/reactUtils/__tests__/reactUtilsHelpers.test.js +72 -71
  119. package/reactUtils/createContext/__tests__/__snapshots__/helpers.test.js.snap +13 -79
  120. package/reactUtils/createContext/__tests__/__snapshots__/{index.test.js.snap → index.test.ts.snap} +2 -2
  121. package/reactUtils/createContext/__tests__/__snapshots__/provider.test.js.snap +3 -28
  122. package/reactUtils/createContext/__tests__/__snapshots__/withConsumer.test.js.snap +3 -4
  123. package/reactUtils/createContext/__tests__/__snapshots__/withProvider.test.js.snap +7 -3
  124. package/reactUtils/createContext/__tests__/helpers.test.js +107 -121
  125. package/reactUtils/createContext/__tests__/{index.test.js → index.test.ts} +2 -2
  126. package/reactUtils/createContext/__tests__/provider.test.js +4 -6
  127. package/reactUtils/createContext/__tests__/withConsumer.test.js +12 -12
  128. package/reactUtils/createContext/__tests__/withProvider.test.js +4 -4
  129. package/reactUtils/createContext/helpers.ts +6 -1
  130. package/reactUtils/createContext/index.ts +11 -25
  131. package/reactUtils/index.ts +0 -25
  132. package/screenState/index.ts +24 -10
  133. package/testUtils/index.tsx +7 -18
  134. package/theme/__mocks__/index.ts +4 -0
  135. package/theme/index.ts +1 -1
  136. package/time/Timer.ts +5 -2
  137. package/types.ts +1 -0
  138. package/zappFrameworkUtils/presentPluginOneTime.ts +2 -3
  139. package/appUtils/keyCodes/keys.ios.js +0 -46
  140. package/appUtils/playerManager/DelayedSeekPlayerWrapper.tsx +0 -180
  141. package/reactUtils/createContext/__tests__/index-no-react.test.js +0 -27
  142. /package/appUtils/HooksManager/{logger.js → logger.ts} +0 -0
  143. /package/appUtils/{directionHelper.js → directionHelper.ts} +0 -0
  144. /package/appUtils/keyCodes/{androidTVKeys.js → androidTVKeys.ts} +0 -0
  145. /package/appUtils/keyCodes/{keys.web.js → keys/keys.web.ts} +0 -0
  146. /package/appUtils/{localizationsHelper.js → localizationsHelper.ts} +0 -0
  147. /package/domUtils/{logger.js → logger.ts} +0 -0
@@ -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,180 +0,0 @@
1
- import { Player } from "./player";
2
- import { BehaviorSubject } from "rxjs";
3
-
4
- export class DelayedSeekPlayerWrapper extends Player {
5
- private wrappedPlayer: Player;
6
- private delayedSeekPosition: number;
7
- private wasPlaying: boolean;
8
-
9
- constructor(props, player: Player) {
10
- super(props);
11
- this.wrappedPlayer = player;
12
- this.delayedSeekPosition = null;
13
-
14
- this.wrappedPlayer.addListener({
15
- id: "Master-Wrapper-Listener",
16
- listener: this,
17
- });
18
-
19
- this.onPlayerSeekComplete = this.onPlayerSeekComplete.bind(this);
20
- }
21
-
22
- getOverlayObservable = () => {
23
- return this.wrappedPlayer.getOverlayObservable();
24
- };
25
-
26
- getEntryObservable = (): BehaviorSubject<ZappEntry | null> => {
27
- return this.wrappedPlayer.getEntryObservable();
28
- };
29
-
30
- getEntry = (): ZappEntry | null => this.wrappedPlayer.getEntry();
31
-
32
- getListener = (): QuickBrickPlayer.SharedPlayerCallBacks => {
33
- return this.wrappedPlayer.getListener();
34
- };
35
-
36
- togglePlayPause = () => {
37
- this.wrappedPlayer.togglePlayPause();
38
- };
39
-
40
- selectTrack = (_track) => this.wrappedPlayer.selectTrack(_track);
41
-
42
- // Implement all default methods by delegating them to wrapped player
43
- public seekTo = (position: number) => {
44
- this.wrappedPlayer.seekTo(position);
45
- };
46
-
47
- public isPlaying = () => {
48
- return this.wrappedPlayer.isPlaying();
49
- };
50
-
51
- public isPaused = () => {
52
- return this.wrappedPlayer.isPaused();
53
- };
54
-
55
- public play = () => {
56
- this.wrappedPlayer.play();
57
- };
58
-
59
- public pause = () => {
60
- this.wrappedPlayer.pause();
61
- };
62
-
63
- getState = () => {
64
- const currentState = this.wrappedPlayer.getState();
65
-
66
- if (this.delayedSeekPosition === null) {
67
- return currentState;
68
- }
69
-
70
- return {
71
- ...currentState,
72
- contentPosition: this.delayedSeekPosition,
73
- isPaused: false,
74
- seekPosition: this.delayedSeekPosition,
75
- };
76
- };
77
-
78
- forward = (deltaTime: number) => {
79
- if (this.delayedSeekPosition !== null) {
80
- this.delayedSeekPosition += deltaTime;
81
- this.playerState.seekPosition = this.delayedSeekPosition;
82
-
83
- this.onVideoProgress({
84
- currentTime: this.playerState.seekPosition,
85
- duration: this.getDuration(),
86
- seekableDuration: this.playerState.seekableDuration,
87
- isLive: this.playerState.isLive,
88
- });
89
-
90
- // this.scheduleResumePlayback(DELAYED_SEEK_DELAY, this.delayedSeekPosition);
91
-
92
- return;
93
- }
94
-
95
- if (this.playerState.seekPosition == null) {
96
- this.playerState.seekPosition = this.playerState.contentPosition;
97
- }
98
-
99
- this.playerState.seekPosition += deltaTime;
100
-
101
- this.wrappedPlayer.forward(deltaTime);
102
- };
103
-
104
- rewind = (deltaTime: number) => {
105
- if (this.delayedSeekPosition !== null) {
106
- this.delayedSeekPosition -= deltaTime;
107
-
108
- if (this.delayedSeekPosition < 0) {
109
- this.delayedSeekPosition = 0;
110
- }
111
-
112
- this.playerState.seekPosition = this.delayedSeekPosition;
113
-
114
- this.onVideoProgress({
115
- currentTime: this.playerState.seekPosition,
116
- duration: this.getDuration(),
117
- seekableDuration: this.playerState.seekableDuration,
118
- isLive: this.playerState.isLive,
119
- });
120
-
121
- // this.scheduleResumePlayback(DELAYED_SEEK_DELAY, this.delayedSeekPosition);
122
-
123
- return;
124
- }
125
-
126
- if (this.playerState.seekPosition == null) {
127
- this.playerState.seekPosition = this.playerState.contentPosition;
128
- }
129
-
130
- this.playerState.seekPosition -= deltaTime;
131
- this.wrappedPlayer.rewind(deltaTime);
132
- };
133
-
134
- public getConfig = () => this.wrappedPlayer.getConfig();
135
-
136
- // TODO: replace with enum of supported orientations
137
- isFullScreenSupported(): boolean {
138
- return this.wrappedPlayer.isFullScreenSupported();
139
- }
140
-
141
- public supportsNativeControls = (): boolean =>
142
- this.wrappedPlayer.supportsNativeControls();
143
-
144
- public supportNativeCast = (): boolean =>
145
- this.wrappedPlayer.supportNativeCast();
146
-
147
- public isInDelayedSeek = () => this.delayedSeekPosition !== null;
148
-
149
- public enterDelayedSeek() {
150
- if (this.delayedSeekPosition !== null) {
151
- return;
152
- }
153
-
154
- if (this.playerState.seekPosition === null) {
155
- this.playerState.seekPosition = this.playerState.contentPosition;
156
- }
157
-
158
- this.delayedSeekPosition = this.playerState.seekPosition;
159
-
160
- if (!this.isPaused()) {
161
- this.wasPlaying = true;
162
- this.wrappedPlayer.pause();
163
- }
164
- }
165
-
166
- public exitDelayedSeek() {
167
- if (this.delayedSeekPosition === null) {
168
- return;
169
- }
170
-
171
- this.wrappedPlayer.seekTo(this.delayedSeekPosition);
172
-
173
- if (this.wasPlaying) {
174
- this.wasPlaying = false;
175
- this.wrappedPlayer.play();
176
- }
177
-
178
- this.delayedSeekPosition = null;
179
- }
180
- }
@@ -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