@applicaster/zapp-react-native-utils 16.0.0-rc.6 → 16.0.0-rc.60

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 (161) hide show
  1. package/actionsExecutor/ActionExecutor.ts +47 -11
  2. package/actionsExecutor/ActionExecutorContext.tsx +87 -316
  3. package/actionsExecutor/actions/__tests__/dismissBottomSheet.test.ts +22 -0
  4. package/actionsExecutor/actions/__tests__/loadItemsFromSource.test.ts +88 -0
  5. package/actionsExecutor/actions/__tests__/openBottomSheet.customContent.test.ts +76 -0
  6. package/actionsExecutor/actions/__tests__/openBottomSheet.inlineItems.test.ts +130 -0
  7. package/actionsExecutor/actions/__tests__/showToast.test.ts +88 -0
  8. package/actionsExecutor/actions/appRestart.ts +24 -0
  9. package/actionsExecutor/actions/confirmDialog.ts +53 -0
  10. package/actionsExecutor/actions/dismissBottomSheet.ts +22 -0
  11. package/actionsExecutor/actions/index.ts +34 -0
  12. package/actionsExecutor/actions/localStorageRemove.ts +27 -0
  13. package/actionsExecutor/actions/localStorageSet.ts +28 -0
  14. package/actionsExecutor/actions/localStorageToggleFlag.ts +28 -0
  15. package/actionsExecutor/actions/navigateToScreen.ts +123 -0
  16. package/actionsExecutor/actions/openBottomSheet.ts +322 -0
  17. package/actionsExecutor/actions/refreshComponent.ts +85 -0
  18. package/actionsExecutor/actions/screenSetVariable.ts +35 -0
  19. package/actionsExecutor/actions/screenToggleFlag.ts +38 -0
  20. package/actionsExecutor/actions/sendCloudEvent.ts +93 -0
  21. package/actionsExecutor/actions/sessionStorageRemove.ts +19 -0
  22. package/actionsExecutor/actions/sessionStorageSet.ts +20 -0
  23. package/actionsExecutor/actions/sessionStorageToggleFlag.ts +15 -0
  24. package/actionsExecutor/actions/showToast.ts +87 -0
  25. package/actionsExecutor/actions/switchLayout.ts +40 -0
  26. package/actionsExecutor/consts.ts +23 -0
  27. package/actionsExecutor/types.ts +59 -0
  28. package/analyticsUtils/AnalyticsEvents/sendMenuClickEvent.ts +2 -2
  29. package/analyticsUtils/PlayerAnalyticsManager.ts +12 -2
  30. package/analyticsUtils/__tests__/analyticsMapper.test.ts +35 -0
  31. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testACP_events.json +1 -1
  32. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testBlockUnlistedParams_rules.json +1 -1
  33. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testEmptyRenameKeepsName_events.json +4 -0
  34. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testEmptyRenameKeepsName_rules.json +6 -0
  35. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testEventRegex_events.json +3 -9
  36. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testIgnoreOrdering_events.json +18 -0
  37. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testIgnoreOrdering_rules.json +16 -0
  38. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexEventNoFallback_events.json +4 -0
  39. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexEventNoFallback_rules.json +6 -0
  40. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexMultiGroupRename_events.json +4 -0
  41. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexMultiGroupRename_rules.json +6 -0
  42. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexNonNamedFullMatch_events.json +4 -0
  43. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexNonNamedFullMatch_rules.json +6 -0
  44. package/analyticsUtils/__tests__/fixtures/index.js +20 -0
  45. package/analyticsUtils/analyticsMapper.ts +4 -1
  46. package/analyticsUtils/playerAnalyticsTracker.ts +26 -3
  47. package/appUtils/HooksManager/index.ts +12 -8
  48. package/appUtils/contextKeysManager/__tests__/getKey/failure.test.ts +1 -1
  49. package/appUtils/contextKeysManager/__tests__/removeKey/failure.test.ts +1 -1
  50. package/appUtils/contextKeysManager/__tests__/setKey/failure/invalidKey.test.ts +4 -4
  51. package/appUtils/contextKeysManager/index.ts +1 -1
  52. package/appUtils/contextKeysManager/utils/index.ts +38 -25
  53. package/appUtils/playerManager/OverlayObserver/OverlaysObserver.ts +143 -53
  54. package/appUtils/playerManager/OverlayObserver/__tests__/liveContent.test.ts +205 -0
  55. package/appUtils/playerManager/OverlayObserver/__tests__/utils.test.ts +49 -0
  56. package/appUtils/playerManager/OverlayObserver/utils.ts +49 -20
  57. package/appUtils/playerManager/__tests__/playerContent.test.ts +403 -0
  58. package/appUtils/playerManager/__tests__/playerFactory.test.ts +150 -0
  59. package/appUtils/playerManager/__tests__/usePlayerContent.test.tsx +64 -0
  60. package/appUtils/playerManager/{conts.ts → const.ts} +20 -0
  61. package/appUtils/playerManager/index.ts +1 -1
  62. package/appUtils/playerManager/player.ts +115 -3
  63. package/appUtils/playerManager/playerFactory.ts +18 -35
  64. package/appUtils/playerManager/playerNative.ts +1 -1
  65. package/appUtils/playerManager/usePlayerContent.tsx +43 -0
  66. package/appUtils/playerManager/usePlayerControllerSetup.tsx +1 -1
  67. package/appUtils/playerManager/userLanguagePreference.ts +1 -1
  68. package/arrayUtils/__tests__/{anyThruthy.test.ts → anyTruthy.test.ts} +8 -0
  69. package/arrayUtils/__tests__/arrayUtils.test.ts +165 -108
  70. package/arrayUtils/__tests__/isEmptyArray.test.ts +11 -0
  71. package/arrayUtils/__tests__/isFilledArray.test.ts +12 -0
  72. package/arrayUtils/__tests__/isFirst.test.ts +17 -0
  73. package/arrayUtils/__tests__/isIndexInRange.test.ts +14 -0
  74. package/arrayUtils/__tests__/isLast.test.ts +31 -0
  75. package/arrayUtils/__tests__/makeListOf.test.ts +31 -0
  76. package/arrayUtils/__tests__/makeListOfIndexes.test.ts +20 -0
  77. package/arrayUtils/__tests__/reorderByIds.test.ts +50 -0
  78. package/arrayUtils/__tests__/sample.test.ts +61 -0
  79. package/arrayUtils/index.ts +136 -20
  80. package/bottomSheet/__tests__/scrollContext.test.tsx +35 -0
  81. package/bottomSheet/index.ts +17 -0
  82. package/cellUtils/index.ts +3 -5
  83. package/colorUtils/__tests__/isTransparentColor.test.ts +76 -0
  84. package/colorUtils/__tests__/isValidColor.test.ts +70 -0
  85. package/colorUtils/index.ts +50 -0
  86. package/configurationUtils/__tests__/modalBlocksParser.test.ts +107 -0
  87. package/configurationUtils/manifestKeyParser.ts +38 -9
  88. package/configurationUtils/modalBlocksParser.ts +178 -0
  89. package/manifestUtils/__tests__/player.audioControls.test.js +158 -0
  90. package/manifestUtils/_internals/index.js +6 -0
  91. package/manifestUtils/defaultManifestConfigurations/generalContent.js +35 -0
  92. package/manifestUtils/defaultManifestConfigurations/player.js +327 -19
  93. package/manifestUtils/fieldUtils/__tests__/fieldUtils.test.js +84 -0
  94. package/manifestUtils/fieldUtils/index.js +125 -0
  95. package/manifestUtils/index.js +3 -0
  96. package/manifestUtils/keys.js +9 -0
  97. package/manifestUtils/mobileAction/button/index.js +16 -0
  98. package/manifestUtils/mobileAction/container/index.js +3 -1
  99. package/manifestUtils/mobileAction/groups/defaults.js +3 -1
  100. package/manifestUtils/modalBlocks.js +304 -0
  101. package/manifestUtils/platformIsTV.js +1 -0
  102. package/modalState/ContentViewModel.ts +113 -0
  103. package/modalState/EditableCollection.ts +17 -0
  104. package/modalState/EditableCollectionRegistry.ts +51 -0
  105. package/modalState/ModalOrchestrator.ts +201 -0
  106. package/modalState/RemoteEditableCollection.ts +227 -0
  107. package/modalState/__tests__/ContentViewModel.editable.test.ts +69 -0
  108. package/modalState/__tests__/ContentViewModel.test.ts +165 -0
  109. package/modalState/__tests__/EditableCollectionRegistry.test.ts +112 -0
  110. package/modalState/__tests__/ModalOrchestrator.phase3.test.ts +55 -0
  111. package/modalState/__tests__/RemoteEditableCollection.test.ts +326 -0
  112. package/modalState/__tests__/useBottomSheetContent.test.ts +349 -0
  113. package/modalState/index.ts +30 -83
  114. package/modalState/store.ts +102 -0
  115. package/modalState/types.ts +137 -0
  116. package/modalState/useBottomSheetContent.ts +102 -0
  117. package/numberUtils/__tests__/isMinusZero.test.ts +20 -0
  118. package/numberUtils/__tests__/isZero.test.ts +27 -0
  119. package/numberUtils/__tests__/requireNumber.test.ts +50 -0
  120. package/numberUtils/__tests__/toNumber.test.ts +27 -0
  121. package/numberUtils/__tests__/toNumberWithDefault.test.ts +64 -0
  122. package/numberUtils/__tests__/toNumberWithDefaultZero.test.ts +48 -0
  123. package/numberUtils/index.ts +27 -8
  124. package/package.json +2 -2
  125. package/pipesUtils/__tests__/buildUrlWithQuery.test.ts +33 -0
  126. package/pipesUtils/__tests__/withPipesEndpoint.test.tsx +56 -0
  127. package/pipesUtils/index.ts +1 -0
  128. package/pipesUtils/withPipesEndpoint.tsx +54 -0
  129. package/playerUtils/__tests__/contentDataKeys.test.ts +297 -0
  130. package/playerUtils/__tests__/resolvePlayerTitleSubtitle.test.ts +180 -0
  131. package/playerUtils/contentDataKeys.ts +134 -0
  132. package/playerUtils/index.ts +41 -14
  133. package/playerUtils/isAudioItem.ts +26 -0
  134. package/playerUtils/resolvePlayerTitleSubtitle.ts +76 -0
  135. package/reactHooks/actions/index.ts +51 -1
  136. package/reactHooks/cell-click/index.ts +18 -10
  137. package/reactHooks/feed/__mocks__/useMarkPipesDataStale.ts +4 -0
  138. package/reactHooks/feed/__tests__/useInflatedUrl.test.tsx +25 -0
  139. package/reactHooks/feed/index.ts +5 -1
  140. package/reactHooks/feed/useBatchLoading.ts +9 -1
  141. package/reactHooks/feed/{usePipesCacheReset.ts → useMarkPipesDataStale.ts} +12 -4
  142. package/reactHooks/index.ts +2 -0
  143. package/reactHooks/layout/index.ts +1 -1
  144. package/reactHooks/navigation/__mocks__/index.ts +4 -0
  145. package/reactHooks/navigation/__tests__/useIsScreenActive.test.ts +42 -0
  146. package/reactHooks/navigation/index.ts +1 -1
  147. package/reactHooks/navigation/useIsScreenActive.ts +29 -8
  148. package/reactHooks/state/useComponentScreenState.ts +1 -1
  149. package/reactHooks/usePluginConfiguration.ts +4 -1
  150. package/reactHooks/utils/__tests__/index.test.js +22 -2
  151. package/reactHooks/utils/index.ts +13 -2
  152. package/reactHooks/videoModal/hooks/useVideoModalScreenData.tsx +22 -4
  153. package/riverComponetsMeasurementProvider/index.tsx +12 -8
  154. package/stringUtils/__tests__/stringUtils.test.js +42 -0
  155. package/stringUtils/index.ts +2 -2
  156. package/uiActionsRegistrator/index.ts +203 -0
  157. package/zappFrameworkUtils/__tests__/localStorageHelper.test.ts +146 -0
  158. package/zappFrameworkUtils/localStorageHelper.ts +19 -15
  159. package/appUtils/playerManager/usePlayerTitleSummaryOverlay.tsx +0 -56
  160. package/reactHooks/feed/__mocks__/usePipesCacheReset.ts +0 -1
  161. /package/reactHooks/actions/__tests__/{index.test.js → index.test.tsx} +0 -0
@@ -67,3 +67,23 @@ export enum PlayerRole {
67
67
  Chromecast = "Chromecast",
68
68
  Unspecified = "Unspecified",
69
69
  }
70
+
71
+ /**
72
+ * The playback engine backing a web player. Published on
73
+ * `window.applicaster.playerType` when a player is created, so that plugins
74
+ * observing the player can tell which engine they are looking at instead of
75
+ * inferring it from the API the instance happens to expose.
76
+ *
77
+ * Keep in sync with `ApplicasterGlobals["playerType"]` in applicaster-types.
78
+ */
79
+ export enum WebPlayerEngine {
80
+ Videojs = "videojs",
81
+ Hlsjs = "hlsjs",
82
+ Dashjs = "dashjs",
83
+ }
84
+
85
+ export enum PLAYER_EVENTS {
86
+ PlayNextTriggered = "play_next_triggered",
87
+ }
88
+
89
+ export type PlayNextTriggeredEvent = { id: string };
@@ -9,7 +9,7 @@ import {
9
9
  unsubscribeToDeviceNetworkChanges,
10
10
  } from "@applicaster/quick-brick-core/App/NetworkStatusProvider/utils";
11
11
  import { setUserLanguagePreference } from "./userLanguagePreference";
12
- import { PlayerRole } from "./conts";
12
+ import { PlayerRole } from "./const";
13
13
  import { RNPlayerManager } from "./nativePlayerManager";
14
14
 
15
15
  const { log_error, log_debug, log_warning } = createLogger({
@@ -1,9 +1,22 @@
1
1
  import * as R from "ramda";
2
- import { BehaviorSubject } from "rxjs";
2
+ import { BehaviorSubject, Observable } from "rxjs";
3
+ import { distinctUntilChanged } from "rxjs/operators";
3
4
  import { isEmptyOrNil } from "@applicaster/zapp-react-native-utils/cellUtils";
4
5
  import { createLogger, utilsLogger } from "../../logger";
5
- import { getBoolFromConfigValue } from "../../configurationUtils";
6
- import { PlayerRole, SharedPlayerCallBacksKeys } from "./conts";
6
+ import {
7
+ getBoolFromConfigValue,
8
+ imageSrcFromMediaItem,
9
+ } from "../../configurationUtils";
10
+ // Imported from the leaf modules rather than the `playerUtils` barrel: that
11
+ // barrel imports `playerManager`, so going through it would create a require
12
+ // cycle (playerManager/index -> player -> playerUtils/index -> playerManager).
13
+ import {
14
+ resolvePlayerTitleSubtitle,
15
+ getPlayerContentDataKeys,
16
+ } from "../../playerUtils/resolvePlayerTitleSubtitle";
17
+ import { isAudioItem } from "../../playerUtils/isAudioItem";
18
+ import { isTV } from "../../reactUtils";
19
+ import { PlayerRole, SharedPlayerCallBacksKeys } from "./const";
7
20
  import { OverlaysObserver } from "./OverlayObserver/OverlaysObserver";
8
21
  import { TVSeekController } from "../../reactHooks/player/TVSeekControlller/TVSeekController";
9
22
 
@@ -19,6 +32,23 @@ export declare type PlayerControllerListenerData = {
19
32
  id: string;
20
33
  listener: QuickBrickPlayer.SharedPlayerCallBacks;
21
34
  };
35
+
36
+ /**
37
+ * The player's resolved Title/Subtitle text, published by the player the same
38
+ * way duration and progress are. Consumers render these values as-is rather
39
+ * than reading `entry` or the plugin configuration themselves.
40
+ */
41
+ export type PlayerContent = {
42
+ title: Option<string | number>;
43
+ summary: Option<string | number>;
44
+ /**
45
+ * Cover art for the content currently playing. Published alongside the text
46
+ * (rather than read from `entry` by whoever needs it) so it follows the same
47
+ * entry: on live audio that means the programme's own artwork, refreshed
48
+ * with every feed poll, instead of the channel's.
49
+ */
50
+ imageUrl: Option<string>;
51
+ };
22
52
  /**
23
53
  * Player Instance Controller
24
54
  * Instance exposes utility methods that will help set or get state
@@ -45,6 +75,7 @@ export class Player {
45
75
  readonly playerRole: PlayerRole = PlayerRole.Unspecified;
46
76
  private overlaysObserver?: OverlaysObserver | null;
47
77
  private entryObservable?: BehaviorSubject<ZappEntry> | null;
78
+ private contentSubject?: BehaviorSubject<PlayerContent> | null;
48
79
 
49
80
  protected listeners: {
50
81
  [key: string]: QuickBrickPlayer.SharedPlayerCallBacks;
@@ -58,7 +89,17 @@ export class Player {
58
89
 
59
90
  set entry(newEntry: ZappEntry | null) {
60
91
  this._entry = newEntry;
92
+ // The live entry is scoped to the entry it overlays - see
93
+ // `OverlaysObserver.clearLiveEntry`. No-op when there is no observer,
94
+ // which is every non-live player.
95
+ this.overlaysObserver?.clearLiveEntry();
61
96
  this.entryObservable?.next(newEntry);
97
+ // Optional chaining short-circuits the whole call expression, so
98
+ // `getContent()` is NOT evaluated while no subscriber exists. That
99
+ // matters: `PlayerNative` assigns `this.entry` in its constructor, before
100
+ // subclass arrow-function properties such as `getPluginConfiguration`
101
+ // have been assigned.
102
+ this.contentSubject?.next(this.getContent());
62
103
  }
63
104
 
64
105
  constructor(props) {
@@ -117,6 +158,77 @@ export class Player {
117
158
  return this.entryObservable;
118
159
  };
119
160
 
161
+ /**
162
+ * The player's resolved Title/Subtitle.
163
+ *
164
+ * Resolved on demand rather than cached: the plugin configuration arrives
165
+ * asynchronously on both the native and cast paths, so a value computed once
166
+ * at entry-set time would be stale for whichever arrives first.
167
+ *
168
+ * Every fallback (no config, empty/whitespace key, unresolvable key, key
169
+ * resolving to an empty string or to a non-string/non-number) lives in
170
+ * `resolvePlayerContentText` and is never reimplemented here.
171
+ */
172
+ getContent = (): PlayerContent => {
173
+ // Live audio keeps playing one channel while the programme on air
174
+ // changes, so the observer's freshly-loaded programme entry wins when
175
+ // there is one. Read through `?.` so this never constructs an observer:
176
+ // a VOD or cast player has none and falls straight through to its entry.
177
+ const entry = this.overlaysObserver?.liveEntry ?? this.entry;
178
+
179
+ return {
180
+ ...resolvePlayerTitleSubtitle({
181
+ entry,
182
+ pluginConfiguration: this.getPluginConfiguration(),
183
+ dataKeys: getPlayerContentDataKeys({
184
+ isTV: isTV(),
185
+ isAudioContent: isAudioItem(entry),
186
+ }),
187
+ }),
188
+ // Same selection Android's `EntryHelpers.extractCoverImage` makes:
189
+ // prefer the `image_base` media item, otherwise the first one available.
190
+ // Reused rather than reimplemented so the two platforms cannot drift.
191
+ imageUrl: entry ? imageSrcFromMediaItem(entry, []) : undefined,
192
+ };
193
+ };
194
+
195
+ /**
196
+ * Created lazily, like `entryObservable`. An eagerly created subject would
197
+ * resolve during `PlayerNative`'s constructor and call a not-yet-assigned
198
+ * `getPluginConfiguration`.
199
+ *
200
+ * The seed is produced by calling the resolver, never from raw entry fields:
201
+ * a `BehaviorSubject` replays its seed synchronously on subscribe, so a raw
202
+ * seed would overwrite correctly-resolved text at mount.
203
+ */
204
+ getContentObservable = (): Observable<PlayerContent> => {
205
+ if (!this.contentSubject) {
206
+ this.contentSubject = new BehaviorSubject<PlayerContent>(
207
+ this.getContent()
208
+ );
209
+ }
210
+
211
+ return this.contentSubject.asObservable().pipe(
212
+ // `resolvePlayerTitleSubtitle` returns a fresh object every call, so
213
+ // reference equality would never dedupe. Compare by value.
214
+ distinctUntilChanged(
215
+ (previous, next) =>
216
+ previous.title === next.title &&
217
+ previous.summary === next.summary &&
218
+ previous.imageUrl === next.imageUrl
219
+ )
220
+ );
221
+ };
222
+
223
+ /**
224
+ * Re-resolves and publishes the current content. Called when something the
225
+ * resolution depends on changed without `entry` itself being reassigned -
226
+ * today that is the observer swapping in a newly-loaded live programme.
227
+ */
228
+ publishContent = () => {
229
+ this.contentSubject?.next(this.getContent());
230
+ };
231
+
120
232
  /**
121
233
  * ---------------------------------------- PLAYER SETTERS GETTERS ----------------------------------------
122
234
  * These methods let you get information about the content / ad playing
@@ -1,7 +1,7 @@
1
1
  import { appStore } from "@applicaster/zapp-react-native-redux/AppStore";
2
2
  import { findPluginByIdentifier } from "@applicaster/zapp-react-native-utils/pluginUtils";
3
3
  import { Player } from "./player";
4
- import { PlayerRole } from "./conts";
4
+ import { PlayerRole } from "./const";
5
5
 
6
6
  type PlayerFactoryItem = {
7
7
  Component: any;
@@ -19,52 +19,35 @@ type PlayerFactoryProps = {
19
19
  playerRole: PlayerRole;
20
20
  };
21
21
 
22
- interface PlayerConstructor {
22
+ interface PlayerControllerConstructor {
23
23
  new (params: any): Player;
24
24
  }
25
25
 
26
- export const playerFactory = (
27
- config: PlayerFactoryProps
28
- ): PlayerFactoryItem | null => {
29
- const IDENTIFIER = config?.playerPluginId;
26
+ type PlayerProtocol = {
27
+ Component: any;
28
+ controllerClass: PlayerControllerConstructor;
29
+ };
30
30
 
31
- if (!IDENTIFIER) {
32
- return null;
33
- }
31
+ export const playerFactory = async (
32
+ config: PlayerFactoryProps
33
+ ): Promise<PlayerFactoryItem | null> => {
34
+ if (!config?.playerPluginId) return null;
34
35
 
35
36
  const plugins = appStore.get("plugins");
37
+ if (!plugins) return null;
36
38
 
37
- if (!plugins) {
38
- return null;
39
- }
40
-
41
- const playerPlugin = findPluginByIdentifier(IDENTIFIER, plugins);
39
+ const playerPlugin = findPluginByIdentifier(config.playerPluginId, plugins);
40
+ if (!playerPlugin?.module?.playerProtocol) return null;
42
41
 
43
- if (!playerPlugin?.module?.playerProtocol) {
44
- return null;
45
- }
46
-
47
- const playerProtocol: PlayerConstructor = playerPlugin.module.playerProtocol(
48
- config?.screenConfig,
49
- config?.entry
50
- );
42
+ const playerProtocol: PlayerProtocol | null =
43
+ await playerPlugin.module.playerProtocol(config.screenConfig, config.entry);
51
44
 
52
- const playerView = (playerProtocol as any)?.Component || null;
53
-
54
- if (!playerView) {
45
+ if (!playerProtocol?.Component || !playerProtocol.controllerClass) {
55
46
  return null;
56
47
  }
57
48
 
58
- const Controller = (playerProtocol as any)?.controllerClass || null;
59
-
60
- if (Controller === null) {
61
- return null;
62
- }
63
-
64
- const controller = new Controller(config);
65
-
66
49
  return {
67
- controller,
68
- Component: playerView,
50
+ controller: new playerProtocol.controllerClass(config),
51
+ Component: playerProtocol.Component,
69
52
  };
70
53
  };
@@ -3,7 +3,7 @@ import { isEmptyOrNil } from "@applicaster/zapp-react-native-utils/cellUtils";
3
3
  import { createLogger, utilsLogger } from "../../logger";
4
4
  import { Player } from "./player";
5
5
  import { findNodeHandle } from "react-native";
6
- import { PlayerRole } from "./conts";
6
+ import { PlayerRole } from "./const";
7
7
  import { toBooleanWithDefaultFalse } from "../../booleanUtils";
8
8
  import { RNPlayerManager } from "./nativePlayerManager";
9
9
 
@@ -0,0 +1,43 @@
1
+ import * as React from "react";
2
+ import { Player, PlayerContent } from "./player";
3
+ import { usePlayer } from "./usePlayer";
4
+
5
+ const EMPTY_CONTENT: PlayerContent = {
6
+ title: null,
7
+ summary: null,
8
+ imageUrl: null,
9
+ };
10
+
11
+ /**
12
+ * Subscribes to the player's resolved Title/Subtitle, the same way
13
+ * `usePlayerState` subscribes to playback state. Modeled on that hook
14
+ * deliberately: one React bridge pattern for everything the manager publishes.
15
+ *
16
+ * Passing no `playerId` uses the active player, which is the right default -
17
+ * only one player instance is live at a time. `usePlayer` additionally swaps
18
+ * to the casting receiver while casting, so this follows cast handover
19
+ * automatically.
20
+ */
21
+ export const usePlayerContent = (playerId?: string): PlayerContent => {
22
+ const player: Player = usePlayer(playerId);
23
+
24
+ const [content, setContent] = React.useState<PlayerContent>(
25
+ () => player?.getContent() ?? EMPTY_CONTENT
26
+ );
27
+
28
+ React.useEffect(() => {
29
+ if (!player) {
30
+ setContent(EMPTY_CONTENT);
31
+
32
+ return;
33
+ }
34
+
35
+ const subscription = player
36
+ .getContentObservable()
37
+ .subscribe((next) => setContent(next));
38
+
39
+ return () => subscription.unsubscribe();
40
+ }, [player]);
41
+
42
+ return content;
43
+ };
@@ -3,7 +3,7 @@ import { useConfiguration } from "../../reactHooks/useConfiguration";
3
3
  import { useEffect } from "react";
4
4
  import { playerManager } from "./index";
5
5
  import { useValidatePlayerConfig } from "../../playerUtils/useValidatePlayerConfig";
6
- import { PlayerRole } from "./conts";
6
+ import { PlayerRole } from "./const";
7
7
  import { isAppleTV } from "@applicaster/zapp-react-native-ui-components/Helpers/Platform";
8
8
  import { TVSeekController } from "../../reactHooks/player/TVSeekControlller/TVSeekController";
9
9
  import { KeyInputHandler } from "../keyInputHandler/KeyInputHandler";
@@ -1,7 +1,7 @@
1
1
  import { localStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/LocalStorage";
2
2
  import { sessionStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/SessionStorage";
3
3
  import { createLogger, utilsLogger } from "../../logger";
4
- import { userPreferencesNamespace } from "./conts";
4
+ import { userPreferencesNamespace } from "./const";
5
5
 
6
6
  export const preferredAudioLanguageStorageKey = "preferred_audio_language";
7
7
 
@@ -21,4 +21,12 @@ describe("anyTruthy", () => {
21
21
  expect(anyTruthy([true])).toBe(true);
22
22
  expect(anyTruthy([false])).toBe(false);
23
23
  });
24
+
25
+ it("should return true when the first value is true", () => {
26
+ expect(anyTruthy([true, false, false])).toBe(true);
27
+ });
28
+
29
+ it("should return true when only the last value is true", () => {
30
+ expect(anyTruthy([false, false, true])).toBe(true);
31
+ });
24
32
  });