@applicaster/zapp-react-native-utils 15.0.0-alpha.7877002324 → 15.0.0-alpha.8127545368

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 (149) hide show
  1. package/README.md +0 -6
  2. package/actionsExecutor/ActionExecutorContext.tsx +3 -6
  3. package/actionsExecutor/feedDecorator.ts +6 -6
  4. package/adsUtils/__tests__/createVMAP.test.ts +419 -0
  5. package/adsUtils/index.ts +2 -2
  6. package/analyticsUtils/README.md +1 -1
  7. package/analyticsUtils/analyticsMapper.ts +10 -2
  8. package/appDataUtils/__tests__/urlScheme.test.ts +678 -0
  9. package/appUtils/HooksManager/__tests__/__snapshots__/hooksManager.test.js.snap +0 -188
  10. package/appUtils/HooksManager/__tests__/hooksManager.test.js +16 -2
  11. package/appUtils/HooksManager/index.ts +10 -10
  12. package/appUtils/RiverFocusManager/{index.js → index.ts} +25 -18
  13. package/appUtils/accessibilityManager/__tests__/utils.test.ts +360 -0
  14. package/appUtils/accessibilityManager/const.ts +4 -0
  15. package/appUtils/accessibilityManager/hooks.ts +8 -24
  16. package/appUtils/accessibilityManager/utils.ts +25 -5
  17. package/appUtils/contextKeysManager/__tests__/getKeys/failure.test.ts +7 -2
  18. package/appUtils/contextKeysManager/__tests__/getKeys/success.test.ts +48 -0
  19. package/appUtils/contextKeysManager/contextResolver.ts +51 -22
  20. package/appUtils/contextKeysManager/index.ts +65 -10
  21. package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +3 -0
  22. package/appUtils/focusManager/index.ios.ts +43 -4
  23. package/appUtils/focusManager/treeDataStructure/Tree/__tests__/Tree.test.js +46 -0
  24. package/appUtils/focusManager/treeDataStructure/Tree/index.js +18 -18
  25. package/appUtils/focusManagerAux/utils/index.ios.ts +122 -0
  26. package/appUtils/focusManagerAux/utils/index.ts +3 -5
  27. package/appUtils/focusManagerAux/utils/utils.ios.ts +202 -3
  28. package/appUtils/keyCodes/keys/keys.web.ts +1 -4
  29. package/appUtils/orientationHelper.ts +2 -4
  30. package/appUtils/platform/platformUtils.ts +50 -35
  31. package/appUtils/playerManager/OverlayObserver/OverlaysObserver.ts +94 -4
  32. package/appUtils/playerManager/OverlayObserver/utils.ts +32 -20
  33. package/appUtils/playerManager/player.ts +4 -0
  34. package/appUtils/playerManager/playerNative.ts +31 -17
  35. package/appUtils/playerManager/usePlayerState.tsx +14 -2
  36. package/cellUtils/index.ts +1 -8
  37. package/cloudEventsUtils/__tests__/index.test.ts +529 -0
  38. package/cloudEventsUtils/index.ts +65 -1
  39. package/configurationUtils/__tests__/imageSrcFromMediaItem.test.ts +38 -0
  40. package/configurationUtils/__tests__/manifestKeyParser.test.ts +26 -26
  41. package/configurationUtils/index.ts +17 -11
  42. package/dateUtils/__tests__/dayjs.test.ts +330 -0
  43. package/enumUtils/__tests__/getEnumKeyByEnumValue.test.ts +207 -0
  44. package/errorUtils/__tests__/GeneralError.test.ts +97 -0
  45. package/errorUtils/__tests__/HttpStatusCode.test.ts +344 -0
  46. package/errorUtils/__tests__/MissingPluginError.test.ts +113 -0
  47. package/errorUtils/__tests__/NetworkError.test.ts +202 -0
  48. package/errorUtils/__tests__/getParsedResponse.test.ts +188 -0
  49. package/errorUtils/__tests__/invariant.test.ts +112 -0
  50. package/focusManager/aux/index.ts +1 -1
  51. package/headersUtils/__tests__/headersUtils.test.js +11 -1
  52. package/headersUtils/index.ts +2 -1
  53. package/manifestUtils/defaultManifestConfigurations/player.js +109 -11
  54. package/manifestUtils/keys.js +21 -0
  55. package/manifestUtils/platformIsTV.js +13 -0
  56. package/manifestUtils/sharedConfiguration/screenPicker/utils.js +1 -0
  57. package/manifestUtils/tvAction/container/index.js +1 -1
  58. package/navigationUtils/index.ts +15 -5
  59. package/numberUtils/__tests__/toNumber.test.ts +25 -0
  60. package/numberUtils/__tests__/toPositiveNumber.test.ts +193 -0
  61. package/numberUtils/index.ts +23 -1
  62. package/package.json +4 -4
  63. package/playerUtils/usePlayerTTS.ts +8 -3
  64. package/pluginUtils/index.ts +4 -0
  65. package/reactHooks/advertising/index.ts +2 -2
  66. package/reactHooks/analytics/__tests__/useSendAnalyticsOnPress.test.ts +537 -0
  67. package/reactHooks/app/__tests__/useAppState.test.ts +1 -1
  68. package/reactHooks/autoscrolling/__tests__/useTrackCurrentAutoScrollingElement.test.ts +1 -1
  69. package/reactHooks/autoscrolling/__tests__/useTrackedView.test.tsx +1 -2
  70. package/reactHooks/cell-click/__tests__/index.test.js +1 -3
  71. package/reactHooks/configuration/__tests__/index.test.tsx +1 -1
  72. package/reactHooks/connection/__tests__/index.test.js +1 -1
  73. package/reactHooks/debugging/__tests__/index.test.js +4 -4
  74. package/reactHooks/dev/__tests__/useReRenderLog.test.ts +188 -0
  75. package/reactHooks/device/useIsTablet.tsx +14 -19
  76. package/reactHooks/device/useMemoizedIsTablet.ts +3 -3
  77. package/reactHooks/events/index.ts +20 -0
  78. package/reactHooks/feed/__tests__/useBatchLoading.test.tsx +32 -23
  79. package/reactHooks/feed/__tests__/useBuildPipesUrl.test.tsx +19 -19
  80. package/reactHooks/feed/__tests__/useEntryScreenId.test.tsx +4 -1
  81. package/reactHooks/feed/__tests__/useFeedLoader.test.tsx +42 -30
  82. package/reactHooks/feed/__tests__/{useInflatedUrl.test.ts → useInflatedUrl.test.tsx} +62 -7
  83. package/reactHooks/feed/index.ts +0 -2
  84. package/reactHooks/feed/useEntryScreenId.ts +2 -2
  85. package/reactHooks/feed/useInflatedUrl.ts +43 -17
  86. package/reactHooks/flatList/useLoadNextPageIfNeeded.ts +13 -16
  87. package/reactHooks/hookModal/hooks/useHookModalScreenData.ts +12 -8
  88. package/reactHooks/index.ts +2 -0
  89. package/reactHooks/layout/__tests__/index.test.tsx +1 -1
  90. package/reactHooks/layout/__tests__/useLayoutVersion.test.tsx +1 -1
  91. package/reactHooks/layout/useDimensions/__tests__/{useDimensions.test.ts → useDimensions.test.tsx} +105 -25
  92. package/reactHooks/layout/useDimensions/useDimensions.ts +2 -2
  93. package/reactHooks/navigation/__tests__/index.test.tsx +40 -9
  94. package/reactHooks/navigation/index.ts +27 -11
  95. package/reactHooks/navigation/useRoute.ts +11 -7
  96. package/reactHooks/player/TVSeekControlller/TVSeekController.ts +27 -10
  97. package/reactHooks/player/__tests__/useAutoSeek._test.tsx +1 -1
  98. package/reactHooks/player/__tests__/useTapSeek._test.ts +1 -1
  99. package/reactHooks/resolvers/__tests__/useCellResolver.test.tsx +1 -1
  100. package/reactHooks/resolvers/__tests__/useComponentResolver.test.tsx +1 -1
  101. package/reactHooks/resolvers/useCellResolver.ts +6 -2
  102. package/reactHooks/resolvers/useComponentResolver.ts +8 -2
  103. package/reactHooks/screen/__tests__/useCurrentScreenData.test.tsx +2 -2
  104. package/reactHooks/screen/__tests__/useScreenBackgroundColor.test.tsx +1 -1
  105. package/reactHooks/screen/__tests__/useScreenData.test.tsx +1 -1
  106. package/reactHooks/screen/__tests__/useTargetScreenData.test.tsx +12 -4
  107. package/reactHooks/screen/useTargetScreenData.ts +4 -2
  108. package/reactHooks/state/__tests__/useComponentScreenState.test.ts +246 -0
  109. package/reactHooks/state/index.ts +2 -0
  110. package/reactHooks/state/useComponentScreenState.ts +45 -0
  111. package/reactHooks/state/useRefWithInitialValue.ts +10 -0
  112. package/reactHooks/state/useRivers.ts +1 -1
  113. package/reactHooks/ui/__tests__/useFadeOutWhenBlurred.test.ts +580 -0
  114. package/reactHooks/usePluginConfiguration.ts +2 -2
  115. package/reactHooks/utils/__tests__/index.test.js +1 -1
  116. package/rectUtils/__tests__/index.test.ts +549 -0
  117. package/rectUtils/index.ts +2 -2
  118. package/refreshUtils/RefreshCoordinator/__tests__/refreshCoordinator.test.ts +161 -0
  119. package/refreshUtils/RefreshCoordinator/index.ts +216 -0
  120. package/refreshUtils/RefreshCoordinator/utils/__tests__/getDataRefreshConfig.test.ts +104 -0
  121. package/refreshUtils/RefreshCoordinator/utils/index.ts +29 -0
  122. package/screenPickerUtils/__tests__/index.test.ts +333 -0
  123. package/screenPickerUtils/index.ts +5 -0
  124. package/screenState/__tests__/index.test.ts +1 -1
  125. package/screenUtils/index.ts +3 -0
  126. package/searchUtils/const.ts +7 -0
  127. package/searchUtils/index.ts +3 -0
  128. package/services/storageServiceSync.web.ts +1 -1
  129. package/stringUtils/index.ts +1 -1
  130. package/testUtils/index.tsx +30 -21
  131. package/time/__tests__/BackgroundTimer.test.ts +156 -0
  132. package/time/__tests__/Timer.test.ts +236 -0
  133. package/typeGuards/__tests__/isString.test.ts +21 -0
  134. package/typeGuards/index.ts +4 -0
  135. package/utils/__tests__/clone.test.ts +158 -0
  136. package/utils/__tests__/mergeRight.test.ts +48 -0
  137. package/utils/__tests__/path.test.ts +7 -0
  138. package/utils/__tests__/selectors.test.ts +124 -0
  139. package/utils/clone.ts +7 -0
  140. package/utils/index.ts +15 -1
  141. package/utils/mergeRight.ts +5 -0
  142. package/utils/path.ts +6 -3
  143. package/utils/pathOr.ts +5 -1
  144. package/utils/selectors.ts +46 -0
  145. package/zappFrameworkUtils/HookCallback/callbackNavigationAction.ts +34 -11
  146. package/zappFrameworkUtils/HookCallback/hookCallbackManifestExtensions.config.js +1 -1
  147. package/reactHooks/componentsMap/index.ts +0 -55
  148. package/reactHooks/feed/__tests__/useFeedRefresh.test.tsx +0 -75
  149. 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();
@@ -10,10 +10,7 @@ import { Platform } from "react-native";
10
10
  * platformKeys[Platform.OS] should only include keys
11
11
  * that are unique to that platform, i.e. Exit: { keyCode: 10182 }
12
12
  */
13
- export const KEYS = Object.assign(
14
- platformKeys["web"],
15
- platformKeys[Platform.OS]
16
- );
13
+ export const KEYS = Object.assign(platformKeys.web, platformKeys[Platform.OS]);
17
14
 
18
15
  export const ARROW_KEYS = [
19
16
  KEYS.ArrowUp,
@@ -1,5 +1,5 @@
1
1
  import * as ReactNative from "react-native";
2
- import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
2
+ import { useAppData } from "@applicaster/zapp-react-native-redux/hooks";
3
3
 
4
4
  import { isTV, platformSelect } from "../reactUtils";
5
5
  import { useIsTablet } from "../reactHooks";
@@ -184,9 +184,7 @@ export const getScreenOrientation = ({
184
184
 
185
185
  export const useGetScreenOrientation = (screenData) => {
186
186
  const isTablet = useIsTablet();
187
-
188
- const { appData } = usePickFromState(["appData"]);
189
- const isTabletPortrait = appData?.isTabletPortrait;
187
+ const { isTabletPortrait } = useAppData();
190
188
 
191
189
  return getScreenOrientation({
192
190
  screenData,
@@ -79,7 +79,7 @@ export class ClosedCaptioningManager {
79
79
  private constructor() {
80
80
  this.initialize();
81
81
 
82
- window["vizioDebug"] = {
82
+ window.vizioDebug = {
83
83
  setCCEnabled: (isCCEnabled: boolean) => {
84
84
  this.ccState$.next(isCCEnabled);
85
85
  },
@@ -209,7 +209,7 @@ export class TTSManager {
209
209
 
210
210
  if (isLgPlatform() && window.webOS?.service) {
211
211
  try {
212
- //https://webostv.developer.lge.com/develop/references/settings-service
212
+ // https://webostv.developer.lge.com/develop/references/settings-service
213
213
  window.webOS.service.request("luna://com.webos.settingsservice", {
214
214
  method: "getSystemSettings",
215
215
  parameters: {
@@ -234,34 +234,66 @@ export class TTSManager {
234
234
  });
235
235
  } catch (error) {
236
236
  log_debug("webOS settings service request error", { error });
237
+ // Fallback to false if the service is not available
237
238
  this.screenReaderEnabled$.next(false);
238
239
  }
239
240
  }
240
241
 
241
- if (isSamsungPlatform() && typeof window.tizen !== "undefined") {
242
+ if (isSamsungPlatform() && typeof window.webapis !== "undefined") {
242
243
  try {
243
244
  if (
244
- window.tizen.accessibility &&
245
- typeof window.tizen.accessibility
246
- .addVoiceGuideStatusChangeListener === "function"
245
+ window.webapis?.tvinfo &&
246
+ typeof window.webapis.tvinfo.getMenuValue === "function" &&
247
+ typeof window.webapis.tvinfo.addCaptionChangeListener === "function"
247
248
  ) {
249
+ // Get initial Voice Guide status
250
+ const initialStatus = window.webapis.tvinfo.getMenuValue(
251
+ window.webapis.tvinfo.TvInfoMenuKey.VOICE_GUIDE_KEY
252
+ );
253
+
254
+ const isEnabled =
255
+ initialStatus === window.webapis.tvinfo.TvInfoMenuValue.ON;
256
+
257
+ log_debug("Samsung Voice Guide initial status", {
258
+ isEnabled,
259
+ initialStatus,
260
+ });
261
+
262
+ this.screenReaderEnabled$.next(isEnabled);
263
+
264
+ // Listen for Voice Guide status changes
265
+ const onChange = () => {
266
+ const currentStatus = window.webapis.tvinfo.getMenuValue(
267
+ window.webapis.tvinfo.TvInfoMenuKey.VOICE_GUIDE_KEY
268
+ );
269
+
270
+ const enabled =
271
+ currentStatus === window.webapis.tvinfo.TvInfoMenuValue.ON;
272
+
273
+ log_debug("Samsung Voice Guide status changed", {
274
+ enabled,
275
+ currentStatus,
276
+ });
277
+
278
+ this.screenReaderEnabled$.next(enabled);
279
+ };
280
+
248
281
  this.samsungListenerId =
249
- window.tizen.accessibility.addVoiceGuideStatusChangeListener(
250
- (enabled: boolean) => {
251
- log_debug("Samsung Voice Guide status changed", { enabled });
252
- this.screenReaderEnabled$.next(!!enabled);
253
- }
282
+ window.webapis.tvinfo.addCaptionChangeListener(
283
+ window.webapis.tvinfo.TvInfoMenuKey.VOICE_GUIDE_KEY,
284
+ onChange
254
285
  );
255
286
 
256
287
  log_debug("Samsung Voice Guide listener registered", {
257
288
  listenerId: this.samsungListenerId,
258
289
  });
259
290
  } else {
260
- log_debug("Samsung accessibility API not available");
291
+ log_debug("Samsung TvInfo API not available");
261
292
  this.screenReaderEnabled$.next(false);
262
293
  }
263
294
  } catch (error) {
264
295
  log_debug("Samsung Voice Guide listener error", { error });
296
+ // Fallback to false if the service is not available
265
297
  this.screenReaderEnabled$.next(false);
266
298
  }
267
299
  }
@@ -282,31 +314,14 @@ export class TTSManager {
282
314
  readText(text: string) {
283
315
  this.ttsState$.next(true);
284
316
 
285
- if (
286
- isSamsungPlatform() &&
287
- typeof window.tizen !== "undefined" &&
288
- window.tizen.speech
289
- ) {
290
- try {
291
- const successCallback = () => {
292
- log_debug("Samsung TTS play started successfully");
293
- // Estimate reading time and set inactive when done
294
- this.scheduleTTSComplete(text);
295
- };
296
-
297
- const errorCallback = (error: any) => {
298
- log_debug("Samsung TTS error", { error: error?.message || error });
299
- this.ttsState$.next(false);
300
- };
317
+ if (isSamsungPlatform() && window.speechSynthesis) {
318
+ const utterance = new SpeechSynthesisUtterance(text);
301
319
 
302
- // Clear any previous speech before speaking new text
303
- window.tizen.speech.stop();
320
+ window.speechSynthesis.cancel(); // Cancel previous speech before speaking new text
321
+ window.speechSynthesis.speak(utterance);
304
322
 
305
- window.tizen.speech.speak(text, successCallback, errorCallback);
306
- } catch (error) {
307
- log_debug("Samsung TTS speak() error", { error });
308
- this.ttsState$.next(false);
309
- }
323
+ // Estimate reading time and set inactive when done
324
+ this.scheduleTTSComplete(text);
310
325
  }
311
326
 
312
327
  if (isLgPlatform() && window.webOS?.service) {
@@ -5,6 +5,7 @@ import { createLogger, utilsLogger } from "../../../logger";
5
5
  import { appStore } from "@applicaster/zapp-react-native-redux/AppStore";
6
6
  import {
7
7
  findPluginByIdentifier,
8
+ loadFeedEntry,
8
9
  loadFeedAndPrefetchThumbnailImage,
9
10
  parseTimeToSeconds,
10
11
  retrieveFeedUrl,
@@ -26,6 +27,19 @@ type ChapterMarkerOriginal = {
26
27
  actions: ActionChapter[];
27
28
  };
28
29
 
30
+ export type LiveMetadataEvent = {
31
+ programId: string;
32
+ assetId: string;
33
+ title: string;
34
+ programStartTime: string;
35
+ programEndTime: string;
36
+ };
37
+
38
+ export type LiveMetadataConfig = {
39
+ updateUrl: string;
40
+ updateInterval: number;
41
+ };
42
+
29
43
  export type TitleSummaryEvent = {
30
44
  title: string | number;
31
45
  summary: string | number;
@@ -50,11 +64,13 @@ export type PlayNextState = PlayNextConfig & {
50
64
  export class OverlaysObserver {
51
65
  readonly chapterSubject: BehaviorSubject<ChapterMarkerEvent>;
52
66
  private playNextSubject: BehaviorSubject<PlayNextState>;
67
+ private liveMetadataSubject: BehaviorSubject<LiveMetadataEvent>;
53
68
  private titleSummarySubject: BehaviorSubject<TitleSummaryEvent>;
54
69
  private feedUrl: string;
55
70
  private reloadData: () => void;
56
71
  private updateTitleAndDescription: (data: any) => void;
57
72
  private feedDataInterval: any;
73
+ private liveMetadataUpdateInterval: any;
58
74
  private releasePlayerObserver?: () => void;
59
75
  readonly entry: ZappEntry;
60
76
  private chapterMarkerEvents: ChapterMarkerEvent[];
@@ -66,13 +82,17 @@ export class OverlaysObserver {
66
82
  this.chapterSubject = new BehaviorSubject(null);
67
83
  this.playNextSubject = new BehaviorSubject(null);
68
84
 
85
+ this.player = player;
86
+ this.entry = player.getEntry();
87
+
69
88
  this.titleSummarySubject = new BehaviorSubject<TitleSummaryEvent>({
70
- title: player.getEntry()?.title || "",
71
- summary: player.getEntry()?.summary || "",
89
+ title: this.entry?.title || "",
90
+ summary: this.entry?.summary || "",
72
91
  });
73
92
 
74
- this.entry = player.getEntry();
75
- this.player = player;
93
+ this.liveMetadataSubject = new BehaviorSubject<LiveMetadataEvent>(
94
+ this.entry?.extensions?.liveMetadata || null
95
+ );
76
96
 
77
97
  this.chapterMarkerEvents = this.prepareChapterMarkers();
78
98
  this.releasePlayerObserver = this.subscribeToPlayerEvents();
@@ -80,7 +100,9 @@ export class OverlaysObserver {
80
100
  this.reloadData = () => {};
81
101
  this.updateTitleAndDescription = () => {};
82
102
  this.feedDataInterval = null;
103
+ this.liveMetadataUpdateInterval = null;
83
104
  void this.preparePlayNext();
105
+ void this.prepareLiveMetadata();
84
106
  }
85
107
 
86
108
  private setupFeedDataInterval(interval: number) {
@@ -98,6 +120,13 @@ export class OverlaysObserver {
98
120
  }
99
121
  }
100
122
 
123
+ public clearLiveMetadataUpdateInterval() {
124
+ if (this.liveMetadataUpdateInterval) {
125
+ clearInterval(this.liveMetadataUpdateInterval);
126
+ this.liveMetadataUpdateInterval = null;
127
+ }
128
+ }
129
+
101
130
  public setFeedDataHandlers(
102
131
  feedUrl: string,
103
132
  reloadData: () => void,
@@ -197,6 +226,48 @@ export class OverlaysObserver {
197
226
  }
198
227
  };
199
228
 
229
+ prepareLiveMetadata = async () => {
230
+ if (!this.player?.isLive?.()) {
231
+ log_debug("prepareLiveMetadata: Player is not live. Skipping...");
232
+
233
+ return;
234
+ }
235
+
236
+ const config: LiveMetadataConfig =
237
+ this.entry?.extensions?.liveMetadataConfig;
238
+
239
+ if (!config?.updateUrl || !config?.updateInterval) {
240
+ log_debug(
241
+ "prepareLiveMetadata: Live metadata configuration is not available. Skipping...",
242
+ { config }
243
+ );
244
+
245
+ return;
246
+ }
247
+
248
+ const reloadData = async () => {
249
+ try {
250
+ const entry = await loadFeedEntry(config.updateUrl, this.entry);
251
+
252
+ this.onLiveMetadataUpdated(entry?.extensions?.liveMetadata || null);
253
+ } catch (error) {
254
+ log_error("prepareLiveMetadata: Metadata fetching failed", {
255
+ error,
256
+ config,
257
+ });
258
+ }
259
+ };
260
+
261
+ log_debug("prepareLiveMetadata: Setting up live metadata observer update", {
262
+ config,
263
+ });
264
+
265
+ const interval = Number(config?.updateInterval) || 60;
266
+
267
+ this.clearLiveMetadataUpdateInterval();
268
+ this.liveMetadataUpdateInterval = setInterval(reloadData, interval * 1000);
269
+ };
270
+
200
271
  // TODO: Hack for video end, will be replaced with playlist prev/next in the future
201
272
  getPlayNextEntry = () =>
202
273
  !this.isCanceledByUser ? this.playNextConfig?.entry : null;
@@ -317,9 +388,11 @@ export class OverlaysObserver {
317
388
  onPlayerClose = () => {
318
389
  this.chapterSubject.complete();
319
390
  this.playNextSubject.complete();
391
+ this.liveMetadataSubject.complete();
320
392
  this.titleSummarySubject.complete();
321
393
  this.releasePlayerObserver?.();
322
394
  this.clearFeedDataInterval();
395
+ this.clearLiveMetadataUpdateInterval();
323
396
  this.releasePlayerObserver = null;
324
397
  };
325
398
 
@@ -352,4 +425,21 @@ export class OverlaysObserver {
352
425
  (prev, curr) => prev?.triggerTime === curr?.triggerTime
353
426
  )
354
427
  );
428
+
429
+ private onLiveMetadataUpdated = (liveMetadataEvent: LiveMetadataEvent) => {
430
+ this.liveMetadataSubject.next(liveMetadataEvent);
431
+ };
432
+
433
+ public getLiveMetadataObservable = (): Observable<LiveMetadataEvent> => {
434
+ return this.liveMetadataSubject.pipe(
435
+ distinctUntilChanged(
436
+ (prev, curr) =>
437
+ prev?.programId === curr?.programId && prev?.assetId === curr?.assetId
438
+ )
439
+ );
440
+ };
441
+
442
+ public getLiveMetadataValue = (): LiveMetadataEvent => {
443
+ return this.liveMetadataSubject.value;
444
+ };
355
445
  }
@@ -92,22 +92,26 @@ export const prefetchImage = (playableItem: ZappEntry, config: any = {}) => {
92
92
  }
93
93
  };
94
94
 
95
- export const loadFeedAndPrefetchThumbnailImage = async (
96
- playNextFeedUrl: string,
97
- entry: ZappEntry,
98
- playNextPlugin
99
- ) => {
95
+ /**
96
+ * Loads a feed entry from the given feed URL using the provided Zapp entry as context.
97
+ *
98
+ * @param {string} feedUrl - The URL of the feed to load the entry from.
99
+ * @param {ZappEntry} entry - The Zapp entry to use as context for the request.
100
+ * @returns {Promise<ZappEntry>} A promise that resolves to the loaded Zapp entry.
101
+ * @throws {Error} If the feed loading fails or no entry is found in the response.
102
+ */
103
+ export const loadFeedEntry = async (feedUrl: string, entry: ZappEntry) => {
100
104
  const requestBuilder = new RequestBuilder()
101
105
  .setEntryContext(entry)
102
106
  .setScreenContext({} as ZappRiver)
103
- .setUrl(playNextFeedUrl);
107
+ .setUrl(feedUrl);
104
108
 
105
109
  const responseObject = await requestBuilder.call<ZappEntry>();
106
110
  const responseHelper = new PipesClientResponseHelper(responseObject);
107
111
 
108
112
  if (responseHelper.error) {
109
113
  log_error(
110
- `loadFeedAndPrefetchThumbnailImage: loading failed with error: ${responseHelper.error.message}. Play next observer, will not be executed`,
114
+ `loadFeedEntry: loading failed with error: ${responseHelper.error.message}. Observer will not be executed`,
111
115
  {
112
116
  response: responseHelper.getLogsData(),
113
117
  }
@@ -116,29 +120,37 @@ export const loadFeedAndPrefetchThumbnailImage = async (
116
120
  throw responseHelper.error;
117
121
  } else {
118
122
  log_info(
119
- `loadFeedAndPrefetchThumbnailImage: Play next url was successfully loaded for url: ${playNextFeedUrl}. Prefetching image`,
123
+ `loadFeedEntry: Feed was successfully loaded for url: ${feedUrl}`,
120
124
  responseHelper.getLogsData()
121
125
  );
122
126
 
123
- const playNextEntry = responseHelper.responseData?.entry[0];
127
+ const entry = responseHelper.responseData?.entry[0];
124
128
 
125
- if (!playNextEntry) {
126
- log_error(
127
- "loadFeedAndPrefetchThumbnailImage: Can not retrieve play next entry, feed was loaded but no entry was found",
128
- responseHelper.getLogsData()
129
- );
129
+ if (!entry) {
130
+ const error =
131
+ "loadFeedEntry: Can not retrieve entry, feed was loaded but no entry was found";
130
132
 
131
- throw new Error(
132
- "Can not retrieve play next entry, feed was loaded but no entry was found"
133
- );
134
- }
133
+ log_error(error, responseHelper.getLogsData());
135
134
 
136
- prefetchImage(playNextEntry, playNextPlugin?.configuration);
135
+ throw new Error(error);
136
+ }
137
137
 
138
- return playNextEntry;
138
+ return entry;
139
139
  }
140
140
  };
141
141
 
142
+ export const loadFeedAndPrefetchThumbnailImage = async (
143
+ playNextFeedUrl: string,
144
+ entry: ZappEntry,
145
+ playNextPlugin
146
+ ) => {
147
+ const playNextEntry = await loadFeedEntry(playNextFeedUrl, entry);
148
+
149
+ prefetchImage(playNextEntry, playNextPlugin?.configuration);
150
+
151
+ return playNextEntry;
152
+ };
153
+
142
154
  export const findPluginByIdentifier = (
143
155
  identifier: string,
144
156
  plugins: ZappPlugin[]
@@ -250,6 +250,10 @@ export class Player {
250
250
  return false;
251
251
  }
252
252
 
253
+ if (!Number.isFinite(duration)) {
254
+ return this.getSeekableDuration() > 0;
255
+ }
256
+
253
257
  return duration > 0;
254
258
  };
255
259