@applicaster/zapp-react-native-utils 15.0.0-alpha.8680244503 → 15.0.0-alpha.9102699023

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 (98) hide show
  1. package/adsUtils/__tests__/createVMAP.test.ts +419 -0
  2. package/analyticsUtils/analyticsMapper.ts +10 -2
  3. package/appDataUtils/__tests__/urlScheme.test.ts +678 -0
  4. package/appUtils/HooksManager/__tests__/__snapshots__/hooksManager.test.js.snap +0 -188
  5. package/appUtils/HooksManager/__tests__/hooksManager.test.js +16 -2
  6. package/appUtils/RiverFocusManager/{index.js → index.ts} +25 -18
  7. package/appUtils/accessibilityManager/__tests__/utils.test.ts +360 -0
  8. package/appUtils/accessibilityManager/utils.ts +25 -5
  9. package/appUtils/contextKeysManager/__tests__/getKeys/failure.test.ts +7 -2
  10. package/appUtils/contextKeysManager/__tests__/getKeys/success.test.ts +48 -0
  11. package/appUtils/contextKeysManager/contextResolver.ts +51 -22
  12. package/appUtils/contextKeysManager/index.ts +65 -10
  13. package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +3 -0
  14. package/appUtils/focusManager/index.ios.ts +43 -4
  15. package/appUtils/focusManager/treeDataStructure/Tree/__tests__/Tree.test.js +46 -0
  16. package/appUtils/focusManager/treeDataStructure/Tree/index.js +18 -18
  17. package/appUtils/focusManagerAux/utils/index.ios.ts +122 -0
  18. package/appUtils/focusManagerAux/utils/index.ts +1 -1
  19. package/appUtils/focusManagerAux/utils/utils.ios.ts +199 -3
  20. package/appUtils/playerManager/playerNative.ts +2 -1
  21. package/cloudEventsUtils/__tests__/index.test.ts +529 -0
  22. package/cloudEventsUtils/index.ts +65 -1
  23. package/configurationUtils/__tests__/imageSrcFromMediaItem.test.ts +38 -0
  24. package/configurationUtils/index.ts +17 -11
  25. package/dateUtils/__tests__/dayjs.test.ts +330 -0
  26. package/enumUtils/__tests__/getEnumKeyByEnumValue.test.ts +207 -0
  27. package/errorUtils/__tests__/GeneralError.test.ts +97 -0
  28. package/errorUtils/__tests__/HttpStatusCode.test.ts +344 -0
  29. package/errorUtils/__tests__/MissingPluginError.test.ts +113 -0
  30. package/errorUtils/__tests__/NetworkError.test.ts +202 -0
  31. package/errorUtils/__tests__/getParsedResponse.test.ts +188 -0
  32. package/errorUtils/__tests__/invariant.test.ts +112 -0
  33. package/focusManager/aux/index.ts +1 -1
  34. package/headersUtils/__tests__/headersUtils.test.js +11 -1
  35. package/headersUtils/index.ts +2 -1
  36. package/manifestUtils/defaultManifestConfigurations/player.js +34 -10
  37. package/manifestUtils/platformIsTV.js +13 -0
  38. package/navigationUtils/index.ts +15 -5
  39. package/numberUtils/__tests__/toNumber.test.ts +12 -0
  40. package/numberUtils/__tests__/toPositiveNumber.test.ts +165 -0
  41. package/numberUtils/index.ts +19 -1
  42. package/package.json +4 -4
  43. package/reactHooks/analytics/__tests__/useSendAnalyticsOnPress.test.ts +537 -0
  44. package/reactHooks/app/__tests__/useAppState.test.ts +1 -1
  45. package/reactHooks/autoscrolling/__tests__/useTrackCurrentAutoScrollingElement.test.ts +1 -1
  46. package/reactHooks/autoscrolling/__tests__/useTrackedView.test.tsx +1 -2
  47. package/reactHooks/cell-click/__tests__/index.test.js +1 -3
  48. package/reactHooks/configuration/__tests__/index.test.tsx +1 -1
  49. package/reactHooks/connection/__tests__/index.test.js +1 -1
  50. package/reactHooks/dev/__tests__/useReRenderLog.test.ts +188 -0
  51. package/reactHooks/device/useIsTablet.tsx +14 -19
  52. package/reactHooks/events/index.ts +20 -0
  53. package/reactHooks/feed/__tests__/useBatchLoading.test.tsx +32 -23
  54. package/reactHooks/feed/__tests__/useBuildPipesUrl.test.tsx +19 -19
  55. package/reactHooks/feed/__tests__/useEntryScreenId.test.tsx +1 -1
  56. package/reactHooks/feed/__tests__/useFeedLoader.test.tsx +42 -30
  57. package/reactHooks/feed/__tests__/useFeedRefresh.test.tsx +1 -1
  58. package/reactHooks/feed/__tests__/{useInflatedUrl.test.ts → useInflatedUrl.test.tsx} +62 -7
  59. package/reactHooks/feed/useInflatedUrl.ts +43 -17
  60. package/reactHooks/hookModal/hooks/useHookModalScreenData.ts +12 -8
  61. package/reactHooks/index.ts +2 -0
  62. package/reactHooks/layout/__tests__/index.test.tsx +1 -1
  63. package/reactHooks/layout/__tests__/useLayoutVersion.test.tsx +1 -1
  64. package/reactHooks/navigation/__tests__/index.test.tsx +40 -9
  65. package/reactHooks/navigation/index.ts +19 -4
  66. package/reactHooks/navigation/useRoute.ts +3 -1
  67. package/reactHooks/player/__tests__/useAutoSeek._test.tsx +1 -1
  68. package/reactHooks/player/__tests__/useTapSeek._test.ts +1 -1
  69. package/reactHooks/resolvers/__tests__/useCellResolver.test.tsx +1 -1
  70. package/reactHooks/resolvers/__tests__/useComponentResolver.test.tsx +1 -1
  71. package/reactHooks/screen/__tests__/useCurrentScreenData.test.tsx +2 -2
  72. package/reactHooks/screen/__tests__/useScreenBackgroundColor.test.tsx +1 -1
  73. package/reactHooks/screen/__tests__/useScreenData.test.tsx +1 -1
  74. package/reactHooks/screen/__tests__/useTargetScreenData.test.tsx +2 -2
  75. package/reactHooks/state/useRefWithInitialValue.ts +10 -0
  76. package/reactHooks/ui/__tests__/useFadeOutWhenBlurred.test.ts +580 -0
  77. package/reactHooks/utils/__tests__/index.test.js +1 -1
  78. package/rectUtils/__tests__/index.test.ts +549 -0
  79. package/rectUtils/index.ts +2 -2
  80. package/screenPickerUtils/__tests__/index.test.ts +333 -0
  81. package/screenState/__tests__/index.test.ts +1 -1
  82. package/searchUtils/const.ts +7 -0
  83. package/searchUtils/index.ts +3 -0
  84. package/services/storageServiceSync.web.ts +1 -1
  85. package/stringUtils/index.ts +1 -1
  86. package/testUtils/index.tsx +1 -1
  87. package/time/__tests__/BackgroundTimer.test.ts +156 -0
  88. package/time/__tests__/Timer.test.ts +236 -0
  89. package/typeGuards/__tests__/isString.test.ts +21 -0
  90. package/typeGuards/index.ts +4 -0
  91. package/utils/__tests__/mergeRight.test.ts +48 -0
  92. package/utils/index.ts +10 -0
  93. package/utils/mergeRight.ts +5 -0
  94. package/utils/path.ts +6 -3
  95. package/utils/pathOr.ts +5 -1
  96. package/zappFrameworkUtils/HookCallback/callbackNavigationAction.ts +19 -5
  97. package/zappFrameworkUtils/HookCallback/hookCallbackManifestExtensions.config.js +1 -1
  98. package/reactHooks/componentsMap/index.ts +0 -55
@@ -1,7 +1,9 @@
1
- import { ReplaySubject } from "rxjs";
2
- import { filter } from "rxjs/operators";
1
+ import { ReplaySubject, Subject } from "rxjs";
2
+ import { filter, switchMap, take, withLatestFrom, map } from "rxjs/operators";
3
+
3
4
  import { BUTTON_PREFIX } from "@applicaster/zapp-react-native-ui-components/Components/MasterCell/DefaultComponents/tv/TvActionButtons/const";
4
5
  import { focusManager } from "@applicaster/zapp-react-native-utils/appUtils/focusManager/index.ios";
6
+ import { isPartOfMenu, isPartOfContent } from "./index.ios";
5
7
 
6
8
  type FocusableID = string;
7
9
  type RegistrationEvent = {
@@ -9,6 +11,25 @@ type RegistrationEvent = {
9
11
  registered: boolean;
10
12
  };
11
13
 
14
+ let focusableViewRegistrationSubject$ = new Subject<{
15
+ id: FocusableID;
16
+ groupId: FocusableID;
17
+ }>();
18
+
19
+ let focusableGroupRegistrationSubject$ = new ReplaySubject<{
20
+ id: FocusableID;
21
+ }>();
22
+
23
+ let focusableNativeViewRegistrationSubject$ = new Subject<{
24
+ id: FocusableID;
25
+ groupId: FocusableID;
26
+ }>();
27
+
28
+ let focusableNativeGroupRegistrationSubject$ = new ReplaySubject<{
29
+ id: FocusableID;
30
+ groupId: FocusableID;
31
+ }>();
32
+
12
33
  const isFocusableButton = (id: Option<FocusableID>): boolean =>
13
34
  id && id.includes?.(BUTTON_PREFIX);
14
35
 
@@ -22,14 +43,189 @@ export const focusableButtonsRegistration$ = (focusableGroupId: string) =>
22
43
  )
23
44
  );
24
45
 
25
- export const emitRegistered = (id: Option<FocusableID>): void => {
46
+ export const resetFocusableRegistration = () => {
47
+ // complete the old subject so subscribers are notified and resources are freed
48
+ if (!focusableViewRegistrationSubject$.closed) {
49
+ focusableViewRegistrationSubject$.complete();
50
+ }
51
+
52
+ if (!focusableGroupRegistrationSubject$.closed) {
53
+ focusableGroupRegistrationSubject$.complete();
54
+ }
55
+
56
+ if (!focusableNativeViewRegistrationSubject$.closed) {
57
+ focusableNativeViewRegistrationSubject$.complete();
58
+ }
59
+
60
+ if (!focusableNativeGroupRegistrationSubject$.closed) {
61
+ focusableNativeGroupRegistrationSubject$.complete();
62
+ }
63
+
64
+ focusableViewRegistrationSubject$ = new Subject<{
65
+ id: FocusableID;
66
+ groupId: FocusableID;
67
+ }>();
68
+
69
+ focusableGroupRegistrationSubject$ = new ReplaySubject<{
70
+ id: FocusableID;
71
+ }>();
72
+
73
+ focusableNativeViewRegistrationSubject$ = new Subject<{
74
+ id: FocusableID;
75
+ groupId: FocusableID;
76
+ }>();
77
+
78
+ focusableNativeGroupRegistrationSubject$ = new ReplaySubject<{
79
+ id: FocusableID;
80
+ groupId: FocusableID;
81
+ }>();
82
+ };
83
+
84
+ const focusableNativeViewRegistration = ({ focusableView, focusableGroup }) => {
85
+ return focusableNativeViewRegistrationSubject$.pipe(
86
+ filter(
87
+ (focusableNativeView) => focusableNativeView.id === focusableView.id
88
+ ),
89
+ take(1),
90
+ switchMap((focusableNativeView) =>
91
+ // start waiting registration of its parent FocusableNativeGroup
92
+ focusableNativeGroupRegistrationSubject$.pipe(
93
+ filter(
94
+ (focusableNativeGroup) =>
95
+ focusableNativeGroup.id === focusableNativeView.groupId
96
+ ),
97
+ take(1),
98
+ map((focusableNativeGroup) => ({
99
+ focusableNativeGroup,
100
+ focusableNativeView,
101
+ focusableView,
102
+ focusableGroup,
103
+ }))
104
+ )
105
+ )
106
+ );
107
+ };
108
+
109
+ export const firstFocusableViewRegistrationFactory = () =>
110
+ focusableViewRegistrationSubject$.pipe(
111
+ take(1), // we care about only first FocusableView registration
112
+ switchMap((focusableView) =>
113
+ // start waiting registration of its parent FocusableGroup
114
+ focusableGroupRegistrationSubject$.pipe(
115
+ filter((focusableGroup) => focusableGroup.id === focusableView.groupId),
116
+ take(1),
117
+ map((focusableGroup) => ({
118
+ focusableView,
119
+ focusableGroup,
120
+ }))
121
+ )
122
+ ),
123
+ // start waiting registration for FocusableNativeView and its parent FocusableNativeGroup
124
+ switchMap(({ focusableView, focusableGroup }) =>
125
+ focusableNativeViewRegistration({
126
+ focusableView,
127
+ focusableGroup,
128
+ })
129
+ )
130
+ );
131
+
132
+ // registration on RN level(into RN focusManager)
133
+ export const emitRegistered = ({
134
+ id,
135
+ groupId,
136
+ isGroup,
137
+ }: {
138
+ id: Option<FocusableID>;
139
+ groupId: Option<FocusableID>;
140
+ isGroup: boolean;
141
+ }): void => {
26
142
  if (isFocusableButton(id)) {
27
143
  registeredSubject$.next({ id, registered: true });
28
144
  }
145
+
146
+ if (isGroup && id) {
147
+ focusableGroupRegistrationSubject$.next({ id });
148
+ }
149
+
150
+ if (!isGroup && id && groupId) {
151
+ focusableViewRegistrationSubject$.next({ id, groupId });
152
+ }
29
153
  };
30
154
 
155
+ // unregistration on RN level(into RN focusManager)
31
156
  export const emitUnregistered = (id: Option<FocusableID>): void => {
32
157
  if (isFocusableButton(id)) {
33
158
  registeredSubject$.next({ id, registered: false });
34
159
  }
35
160
  };
161
+
162
+ // registration focusableNativeView and focusableNativeGroup
163
+ export const emitNativeRegistered = ({
164
+ id,
165
+ groupId,
166
+ isGroup,
167
+ }: {
168
+ id: Option<FocusableID>;
169
+ groupId: Option<FocusableID>;
170
+ isGroup: boolean;
171
+ }): void => {
172
+ if (!isGroup && id && groupId) {
173
+ focusableNativeViewRegistrationSubject$.next({ id, groupId });
174
+ }
175
+
176
+ if (isGroup && id && groupId) {
177
+ focusableNativeGroupRegistrationSubject$.next({ id, groupId });
178
+ }
179
+ };
180
+
181
+ // /////
182
+
183
+ const focusedSubject$ = new Subject<FocusableID>();
184
+
185
+ const focused$ = focusedSubject$.asObservable();
186
+
187
+ export const emitFocused = (id: FocusableID): void => {
188
+ focusedSubject$.next(id);
189
+ };
190
+
191
+ export const topMenuItemFocused$ = focused$.pipe(
192
+ filter((id) => id && isPartOfMenu(focusManager.focusableTree, id))
193
+ );
194
+
195
+ export const contentFocused$ = focused$.pipe(
196
+ filter((id) => {
197
+ const isContent = isPartOfContent(focusManager.focusableTree, id);
198
+
199
+ return id && isContent;
200
+ })
201
+ );
202
+
203
+ const createFocusableRegistry = () => {
204
+ const subject$ = new ReplaySubject<FocusableID | undefined>(1);
205
+
206
+ return {
207
+ observable$: subject$.asObservable(),
208
+ register: (id: FocusableID) => {
209
+ // save focusable_id on registration
210
+ subject$.next(id);
211
+ },
212
+ unregister: () => {
213
+ // reset focusable_id on unregistration
214
+ subject$.next(undefined);
215
+ },
216
+ };
217
+ };
218
+
219
+ /// HOME_TOP_MENU_ITEM
220
+ export const HomeTopMenuItemRegistry = createFocusableRegistry();
221
+
222
+ export const homeTopMenuItemFocused$ = topMenuItemFocused$.pipe(
223
+ withLatestFrom(HomeTopMenuItemRegistry.observable$),
224
+ filter(([id, homeId]) => id === homeId)
225
+ );
226
+
227
+ /// SCREEN_PICKER
228
+ export const ScreenPickerContentContainerRegistry = createFocusableRegistry();
229
+
230
+ /// SEARCH_INPUT
231
+ export const SearchInputRegistry = createFocusableRegistry();
@@ -229,8 +229,9 @@ export class PlayerNative extends Player {
229
229
  };
230
230
 
231
231
  closeNativePlayer = () => {
232
- // TODO: Delete does not work
232
+ // TODO: Delete, does not work (component is null)
233
233
  this.currentPlayerComponent()?.closeNativePlayer?.();
234
+ this.getPlayerModule()?.stopBackgroundPlayback?.();
234
235
  };
235
236
 
236
237
  togglePlayPause = () => {