@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.
- package/README.md +0 -6
- package/adsUtils/__tests__/createVMAP.test.ts +419 -0
- package/analyticsUtils/analyticsMapper.ts +10 -2
- package/appDataUtils/__tests__/urlScheme.test.ts +678 -0
- package/appUtils/HooksManager/__tests__/__snapshots__/hooksManager.test.js.snap +0 -188
- package/appUtils/HooksManager/__tests__/hooksManager.test.js +16 -2
- package/appUtils/RiverFocusManager/{index.js → index.ts} +25 -18
- package/appUtils/accessibilityManager/__tests__/utils.test.ts +360 -0
- package/appUtils/accessibilityManager/utils.ts +25 -5
- package/appUtils/contextKeysManager/__tests__/getKeys/failure.test.ts +7 -2
- package/appUtils/contextKeysManager/__tests__/getKeys/success.test.ts +48 -0
- package/appUtils/contextKeysManager/contextResolver.ts +51 -22
- package/appUtils/contextKeysManager/index.ts +65 -10
- package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +3 -0
- package/appUtils/focusManager/index.ios.ts +43 -4
- package/appUtils/focusManager/treeDataStructure/Tree/__tests__/Tree.test.js +46 -0
- package/appUtils/focusManager/treeDataStructure/Tree/index.js +18 -18
- package/appUtils/focusManagerAux/utils/index.ios.ts +122 -0
- package/appUtils/focusManagerAux/utils/index.ts +3 -5
- package/appUtils/focusManagerAux/utils/utils.ios.ts +202 -3
- package/appUtils/playerManager/playerNative.ts +2 -1
- package/cloudEventsUtils/__tests__/index.test.ts +529 -0
- package/cloudEventsUtils/index.ts +65 -1
- package/configurationUtils/__tests__/imageSrcFromMediaItem.test.ts +38 -0
- package/configurationUtils/index.ts +17 -11
- package/dateUtils/__tests__/dayjs.test.ts +330 -0
- package/enumUtils/__tests__/getEnumKeyByEnumValue.test.ts +207 -0
- package/errorUtils/__tests__/GeneralError.test.ts +97 -0
- package/errorUtils/__tests__/HttpStatusCode.test.ts +344 -0
- package/errorUtils/__tests__/MissingPluginError.test.ts +113 -0
- package/errorUtils/__tests__/NetworkError.test.ts +202 -0
- package/errorUtils/__tests__/getParsedResponse.test.ts +188 -0
- package/errorUtils/__tests__/invariant.test.ts +112 -0
- package/focusManager/aux/index.ts +1 -1
- package/headersUtils/__tests__/headersUtils.test.js +11 -1
- package/headersUtils/index.ts +2 -1
- package/manifestUtils/defaultManifestConfigurations/player.js +40 -10
- package/manifestUtils/platformIsTV.js +13 -0
- package/navigationUtils/index.ts +15 -5
- package/numberUtils/__tests__/toNumber.test.ts +27 -0
- package/numberUtils/__tests__/toPositiveNumber.test.ts +193 -0
- package/numberUtils/index.ts +23 -1
- package/package.json +4 -4
- package/reactHooks/analytics/__tests__/useSendAnalyticsOnPress.test.ts +537 -0
- package/reactHooks/app/__tests__/useAppState.test.ts +1 -1
- package/reactHooks/autoscrolling/__tests__/useTrackCurrentAutoScrollingElement.test.ts +1 -1
- package/reactHooks/autoscrolling/__tests__/useTrackedView.test.tsx +1 -2
- package/reactHooks/cell-click/__tests__/index.test.js +1 -3
- package/reactHooks/configuration/__tests__/index.test.tsx +1 -1
- package/reactHooks/connection/__tests__/index.test.js +1 -1
- package/reactHooks/dev/__tests__/useReRenderLog.test.ts +188 -0
- package/reactHooks/device/useIsTablet.tsx +14 -19
- package/reactHooks/events/index.ts +20 -0
- package/reactHooks/feed/__tests__/useBatchLoading.test.tsx +32 -23
- package/reactHooks/feed/__tests__/useBuildPipesUrl.test.tsx +19 -19
- package/reactHooks/feed/__tests__/useEntryScreenId.test.tsx +1 -1
- package/reactHooks/feed/__tests__/useFeedLoader.test.tsx +42 -30
- package/reactHooks/feed/__tests__/{useInflatedUrl.test.ts → useInflatedUrl.test.tsx} +62 -7
- package/reactHooks/feed/index.ts +0 -2
- package/reactHooks/feed/useInflatedUrl.ts +43 -17
- package/reactHooks/hookModal/hooks/useHookModalScreenData.ts +12 -8
- package/reactHooks/index.ts +2 -0
- package/reactHooks/layout/__tests__/index.test.tsx +1 -1
- package/reactHooks/layout/__tests__/useLayoutVersion.test.tsx +1 -1
- package/reactHooks/navigation/__tests__/index.test.tsx +40 -9
- package/reactHooks/navigation/index.ts +19 -4
- package/reactHooks/navigation/useRoute.ts +3 -1
- package/reactHooks/player/__tests__/useAutoSeek._test.tsx +1 -1
- package/reactHooks/player/__tests__/useTapSeek._test.ts +1 -1
- package/reactHooks/resolvers/__tests__/useCellResolver.test.tsx +1 -1
- package/reactHooks/resolvers/__tests__/useComponentResolver.test.tsx +1 -1
- package/reactHooks/screen/__tests__/useCurrentScreenData.test.tsx +2 -2
- package/reactHooks/screen/__tests__/useScreenBackgroundColor.test.tsx +1 -1
- package/reactHooks/screen/__tests__/useScreenData.test.tsx +1 -1
- package/reactHooks/screen/__tests__/useTargetScreenData.test.tsx +2 -2
- package/reactHooks/state/__tests__/useComponentScreenState.test.ts +246 -0
- package/reactHooks/state/index.ts +2 -0
- package/reactHooks/state/useComponentScreenState.ts +45 -0
- package/reactHooks/state/useRefWithInitialValue.ts +10 -0
- package/reactHooks/ui/__tests__/useFadeOutWhenBlurred.test.ts +580 -0
- package/reactHooks/utils/__tests__/index.test.js +1 -1
- package/rectUtils/__tests__/index.test.ts +549 -0
- package/rectUtils/index.ts +2 -2
- package/refreshUtils/RefreshCoordinator/__tests__/refreshCoordinator.test.ts +161 -0
- package/refreshUtils/RefreshCoordinator/index.ts +216 -0
- package/refreshUtils/RefreshCoordinator/utils/__tests__/getDataRefreshConfig.test.ts +104 -0
- package/refreshUtils/RefreshCoordinator/utils/index.ts +29 -0
- package/screenPickerUtils/__tests__/index.test.ts +333 -0
- package/screenPickerUtils/index.ts +5 -0
- package/screenState/__tests__/index.test.ts +1 -1
- package/screenUtils/index.ts +3 -0
- package/searchUtils/const.ts +7 -0
- package/searchUtils/index.ts +3 -0
- package/services/storageServiceSync.web.ts +1 -1
- package/stringUtils/index.ts +1 -1
- package/testUtils/index.tsx +1 -1
- package/time/__tests__/BackgroundTimer.test.ts +156 -0
- package/time/__tests__/Timer.test.ts +236 -0
- package/typeGuards/__tests__/isString.test.ts +21 -0
- package/typeGuards/index.ts +4 -0
- package/utils/__tests__/clone.test.ts +158 -0
- package/utils/__tests__/mergeRight.test.ts +48 -0
- package/utils/__tests__/path.test.ts +7 -0
- package/utils/clone.ts +7 -0
- package/utils/index.ts +12 -1
- package/utils/mergeRight.ts +5 -0
- package/utils/path.ts +6 -3
- package/utils/pathOr.ts +5 -1
- package/zappFrameworkUtils/HookCallback/callbackNavigationAction.ts +19 -5
- package/zappFrameworkUtils/HookCallback/hookCallbackManifestExtensions.config.js +1 -1
- package/reactHooks/componentsMap/index.ts +0 -55
- package/reactHooks/feed/__tests__/useFeedRefresh.test.tsx +0 -75
- 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
|
|
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 = () => {
|