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

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