@applicaster/zapp-react-native-utils 12.0.0-alpha.4195481103 → 12.0.0-alpha.4271512420

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.
@@ -1,8 +1,6 @@
1
1
  import { BehaviorSubject } from "rxjs";
2
2
 
3
3
  import { sessionStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/SessionStorage";
4
- import { localStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/LocalStorage";
5
- import { PlayerWebController } from "@applicaster/zapp-react-native-default-player/src/playerFactory/players/playerWebController";
6
4
 
7
5
  import { PLATFORM_KEYS, PLATFORMS } from "./const";
8
6
  import { createLogger, utilsLogger } from "../../logger";
@@ -21,7 +19,7 @@ declare global {
21
19
  }
22
20
  }
23
21
 
24
- const { log_debug, log_error } = createLogger({
22
+ const { log_debug } = createLogger({
25
23
  category: "General",
26
24
  subsystem: "PlatformUtils",
27
25
  parent: utilsLogger,
@@ -131,100 +129,6 @@ export const getClosedCaptionState = () => {
131
129
  return ccManager.getStateAsObservable();
132
130
  };
133
131
 
134
- export class TextTrackManager {
135
- private controller?: PlayerWebController;
136
- private static instance: TextTrackManager;
137
-
138
- private constructor() {}
139
-
140
- static getInstance(): TextTrackManager {
141
- if (!TextTrackManager.instance) {
142
- TextTrackManager.instance = new TextTrackManager();
143
- }
144
-
145
- return TextTrackManager.instance;
146
- }
147
-
148
- initialize(controller: PlayerWebController) {
149
- if (!controller) {
150
- throw new Error(
151
- "Controller is required for TextTrackManager initialization"
152
- );
153
- }
154
-
155
- this.controller = controller;
156
- }
157
-
158
- async setTextTrackBasedOnCaptions(closedCaptionsState: boolean) {
159
- if (!this.controller) {
160
- log_error("Controller is not initialized");
161
-
162
- return;
163
- }
164
-
165
- if (closedCaptionsState) {
166
- const textTracks = this.controller.getTracksState().textTracks;
167
- const preferredTextTrack = await this.getPreferredTextTrack(textTracks);
168
-
169
- if (preferredTextTrack) {
170
- this.controller.selectTrack(preferredTextTrack);
171
- }
172
- } else {
173
- this.controller.selectTrack(null);
174
- }
175
- }
176
-
177
- async getPreferredTextTrack(
178
- textTracks: QuickBrickPlayer.TextTrack[]
179
- ): Promise<QuickBrickPlayer.TextTrack | undefined> {
180
- if (!this.controller) return;
181
-
182
- const userPreferredTextLanguageLocalStorage = await localStorage.getItem(
183
- "preferred_text_language",
184
- "user_preferences"
185
- );
186
-
187
- let userPreferredTextLanguage;
188
-
189
- if (userPreferredTextLanguageLocalStorage) {
190
- userPreferredTextLanguage = textTracks.find(
191
- (track) => track.language === userPreferredTextLanguageLocalStorage
192
- );
193
- }
194
-
195
- if (userPreferredTextLanguage?.id) {
196
- return userPreferredTextLanguage;
197
- }
198
-
199
- const enableAutoTextTrackSelection =
200
- this.controller.getPluginConfiguration()
201
- ?.enable_auto_text_track_selection ||
202
- this.controller.getTracksState().textTracks.length > 0;
203
-
204
- if (enableAutoTextTrackSelection) {
205
- const languageCode = await sessionStorage.getItem("languageCode");
206
-
207
- if (languageCode) {
208
- const chosenTextTrackBySystemLanguage = textTracks.find(
209
- (track) => track.language === languageCode
210
- );
211
-
212
- if (chosenTextTrackBySystemLanguage?.id) {
213
- return chosenTextTrackBySystemLanguage;
214
- }
215
- }
216
- }
217
-
218
- return textTracks?.[0];
219
- }
220
-
221
- isTextTrackEnabled(): boolean {
222
- if (!this.controller) return false;
223
-
224
- return this.controller.getTracksState().textTrackId !== null;
225
- }
226
- }
227
-
228
132
  /**
229
133
  * Manages device based closed captioning state
230
134
  * Returns an observable that emits the current state and updates whenever it changes
@@ -733,4 +733,5 @@ export class Player {
733
733
 
734
734
  public supportsNativeControls = (): boolean => false;
735
735
  public supportNativeCast = (): boolean => false;
736
+ public destroy = () => {};
736
737
  }
@@ -72,6 +72,7 @@ export const usePlayerControllerSetup = ({
72
72
 
73
73
  return () => {
74
74
  playerManager.unregisterPlayer(playerId);
75
+ playerController.destroy?.();
75
76
  };
76
77
  }, [playerId, playerController]);
77
78
 
@@ -31,13 +31,12 @@ export const getKeyForLabel = (dataKey, customKey) => {
31
31
  * This method will return true if the argument passed to it is either empty or nil
32
32
  * The method prevents zero from being evaluated as falsey in an || condition
33
33
  * i.e. - NaN, null, {}, "", [], should all return true
34
- * @param {*} argument - argument passed to it could be any type
35
34
  * @returns {Boolean} returns true if empty or nil
35
+ * @param value
36
36
  */
37
- export const isEmptyOrNil = R.either(
38
- R.equals(NaN),
39
- R.either(R.isEmpty, R.isNil)
40
- );
37
+
38
+ export const isEmptyOrNil = (value: any): boolean =>
39
+ Number.isNaN(value) || value == null || R.isEmpty(value);
41
40
 
42
41
  /**
43
42
  * This method is used to find the appropriate label for any given text field.
@@ -320,6 +319,7 @@ export const ifElseFocusedSelected = (
320
319
  * @param {Object} stylesObj styles object with keys from zapp { button_icon_width: "10" }
321
320
  * @returns {*} value, returns any type that can be used as styles
322
321
  */
322
+
323
323
  export const getValue = (stylesObj) => (key) => {
324
324
  return R.propOr(null, key, stylesObj);
325
325
  };
@@ -592,3 +592,51 @@ export function isMenuDisabled(
592
592
  export function routeIsPlayerScreen(currentRoute) {
593
593
  return currentRoute?.includes("/playable");
594
594
  }
595
+
596
+ export const getNavBarProps =
597
+ (currentRiver: ZappRiver, pathname: string, title: string) => () => {
598
+ const props = getNavigationPropsV2({
599
+ currentRiver,
600
+ title,
601
+ category: "nav_bar",
602
+ });
603
+
604
+ if (props) {
605
+ return {
606
+ ...props,
607
+ id: pathname,
608
+ pathname: pathname,
609
+ };
610
+ }
611
+
612
+ return null;
613
+ };
614
+
615
+ export const findMenuPlugin = (
616
+ navigations: ZappNavigation[],
617
+ plugins
618
+ ): QuickBrickPlugin => {
619
+ return resolveNavigationPlugin({
620
+ category: "menu",
621
+ navigations,
622
+ plugins,
623
+ }) as QuickBrickPlugin;
624
+ };
625
+
626
+ export const shouldNavBarDisplayMenu = (currentRiver: ZappRiver, plugins) =>
627
+ findMenuPlugin(currentRiver.navigations, plugins)?.identifier ===
628
+ "quick_brick_side_menu" ||
629
+ currentRiver?.navigations.findIndex(
630
+ (nav) => nav.category === "nav_bar" && nav.general?.override_menu_target
631
+ ) > -1;
632
+
633
+ export const getScreenId = (
634
+ screenData: LegacyNavigationScreenData,
635
+ fallbackRiver: ZappRiver
636
+ ) => {
637
+ return screenData?.targetScreen
638
+ ? screenData?.targetScreen?.id ?? fallbackRiver.id
639
+ : "screen_id" in screenData
640
+ ? screenData.screen_id
641
+ : fallbackRiver.id;
642
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-utils",
3
- "version": "12.0.0-alpha.4195481103",
3
+ "version": "12.0.0-alpha.4271512420",
4
4
  "description": "Applicaster Zapp React Native utilities package",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "homepage": "https://github.com/applicaster/quickbrick#readme",
30
30
  "dependencies": {
31
- "@applicaster/applicaster-types": "12.0.0-alpha.4195481103",
31
+ "@applicaster/applicaster-types": "12.0.0-alpha.4271512420",
32
32
  "buffer": "^5.2.1",
33
33
  "camelize": "^1.0.0",
34
34
  "create-react-context": "^0.2.3",