@applicaster/zapp-react-native-ui-components 16.0.0-rc.2 → 16.0.0-rc.20

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 (43) hide show
  1. package/Components/BackgroundImage/BackgroundImage.tsx +42 -0
  2. package/Components/BackgroundImage/BackgroundImage.tv.android.tsx +28 -0
  3. package/Components/BackgroundImage/BackgroundImage.tv.ios.tsx +24 -0
  4. package/Components/BackgroundImage/index.ts +1 -0
  5. package/Components/CellRendererResolver/index.ts +1 -1
  6. package/Components/ComponentResolver/__tests__/componentResolver.test.js +1 -1
  7. package/Components/FocusableGroup/FocusableTvOS.tsx +11 -7
  8. package/Components/GeneralContentScreen/GeneralContentScreenHookAdapter.tsx +39 -0
  9. package/Components/GeneralContentScreen/__tests__/GeneralContentScreenHookAdapter.test.tsx +64 -0
  10. package/Components/GeneralContentScreen/__tests__/HookContentFocusGroup.web.test.tsx +91 -0
  11. package/Components/GeneralContentScreen/hookAdapter/__tests__/networkService.test.ts +74 -0
  12. package/Components/GeneralContentScreen/hookAdapter/__tests__/runInBackground.test.ts +139 -0
  13. package/Components/GeneralContentScreen/hookAdapter/__tests__/validationHelper.test.ts +124 -0
  14. package/Components/GeneralContentScreen/hookAdapter/logger.ts +6 -0
  15. package/Components/GeneralContentScreen/hookAdapter/networkService.ts +53 -0
  16. package/Components/GeneralContentScreen/hookAdapter/runInBackground.ts +48 -0
  17. package/Components/GeneralContentScreen/hookAdapter/validationHelper.ts +72 -0
  18. package/Components/GeneralContentScreen/hookFocus/index.tsx +13 -0
  19. package/Components/GeneralContentScreen/hookFocus/index.web.tsx +69 -0
  20. package/Components/GeneralContentScreen/index.ts +2 -0
  21. package/Components/Layout/TV/ScreenContainer.tsx +5 -0
  22. package/Components/Layout/TV/__tests__/__snapshots__/index.test.tsx.snap +0 -1
  23. package/Components/Layout/TV/index.tsx +3 -4
  24. package/Components/Layout/TV/index.web.tsx +2 -3
  25. package/Components/MasterCell/DefaultComponents/ActionButton.tsx +16 -5
  26. package/Components/MasterCell/DefaultComponents/ButtonContainerView/index.tsx +1 -1
  27. package/Components/PlayerContainer/PlayerContainer.tsx +7 -7
  28. package/Components/PlayerContainer/__tests__/PlayerContainer.test.tsx +284 -0
  29. package/Components/Screen/TV/hooks/__tests__/useAfterPaint.test.ts +60 -0
  30. package/Components/Screen/TV/hooks/index.ts +2 -0
  31. package/Components/Screen/TV/hooks/useAfterPaint.ts +23 -0
  32. package/Components/Screen/TV/index.web.tsx +16 -7
  33. package/Components/ScreenRevealManager/Overlay.tsx +34 -0
  34. package/Components/ScreenRevealManager/__tests__/Overlay.test.tsx +88 -0
  35. package/Components/ScreenRevealManager/withScreenRevealManager.tsx +8 -19
  36. package/Components/VideoLive/LiveImageManager.ts +56 -45
  37. package/Components/VideoLive/PlayerLiveImageComponent.tsx +4 -2
  38. package/Components/VideoModal/utils.ts +6 -1
  39. package/Helpers/ComponentCellSelectionHelper/index.js +0 -6
  40. package/Helpers/index.js +7 -40
  41. package/package.json +5 -5
  42. package/Components/Layout/TV/LayoutBackground.tsx +0 -31
  43. package/Helpers/Analytics/index.js +0 -95
@@ -48,7 +48,6 @@ type Position = {
48
48
  type PlayerFactoryConfig = {
49
49
  player: any; // React ref for native view
50
50
  playerId: string;
51
- muted: boolean;
52
51
  playerPluginId: string;
53
52
  screenConfig: Record<string, any>;
54
53
  entry: ZappEntry; // original entry, used as fallback if no hooks
@@ -296,7 +295,7 @@ export class LiveImageManager implements PlayerLifecycleListener {
296
295
 
297
296
  setUserCellPlayerMutedPreference(true);
298
297
 
299
- this.items.forEach((liveImage) => liveImage.player?.mute());
298
+ this.items.forEach((liveImage) => liveImage.mute());
300
299
  };
301
300
 
302
301
  public unmuteAll = () => {
@@ -304,7 +303,7 @@ export class LiveImageManager implements PlayerLifecycleListener {
304
303
 
305
304
  setUserCellPlayerMutedPreference(false);
306
305
 
307
- this.items.forEach((liveImage) => liveImage.player?.unmute());
306
+ this.items.forEach((liveImage) => liveImage.unmute());
308
307
  };
309
308
 
310
309
  public onViewPositionChanged = (item: LiveImage) => {
@@ -574,6 +573,20 @@ export class LiveImage implements QuickBrickPlayer.SharedPlayerCallBacks {
574
573
  left: 0,
575
574
  };
576
575
 
576
+ // Keeps muted state in sync: updates the initial value for deferred
577
+ // player creation and forwards to the player if it already exists.
578
+ public initiallyMuted: boolean = true;
579
+
580
+ mute = () => {
581
+ this.initiallyMuted = true;
582
+ this.player?.mute();
583
+ };
584
+
585
+ unmute = () => {
586
+ this.initiallyMuted = false;
587
+ this.player?.unmute();
588
+ };
589
+
577
590
  positionToString() {
578
591
  if (!this.position) {
579
592
  return "position not set";
@@ -611,48 +624,7 @@ export class LiveImage implements QuickBrickPlayer.SharedPlayerCallBacks {
611
624
  return this._preparePromise;
612
625
  }
613
626
 
614
- this._preparePromise = (async (): Promise<boolean> => {
615
- // 1. Run hooks if configured
616
- let entry = this.factoryConfig.entry;
617
-
618
- if (this.preloadHooks?.length) {
619
- const result = await executePreloadHooks({
620
- preloadHooks: this.preloadHooks,
621
- entry,
622
- });
623
-
624
- if (result) {
625
- this.processedEntry = result;
626
- entry = result;
627
- } else {
628
- return false;
629
- }
630
- }
631
-
632
- // 2. Create the player with the correct entry
633
- const factoryItem = playerFactory({
634
- player: this.factoryConfig.player,
635
- playerId: this.factoryConfig.playerId,
636
- autoplay: false,
637
- entry,
638
- muted: this.factoryConfig.muted,
639
- playerPluginId: this.factoryConfig.playerPluginId,
640
- screenConfig: this.factoryConfig.screenConfig,
641
- playerRole: PlayerRole.Cell,
642
- });
643
-
644
- if (!factoryItem) {
645
- throw new Error("Player factory returned null");
646
- }
647
-
648
- this.player = factoryItem.controller;
649
- this.component = factoryItem.Component;
650
-
651
- // 3. Register callbacks — player now exists
652
- this.player.addListener({ id: "live-image", listener: this });
653
-
654
- return true;
655
- })()
627
+ this._preparePromise = this.createPreparedPlayer()
656
628
  .then((result) => {
657
629
  this._preparePromise = null;
658
630
 
@@ -672,6 +644,45 @@ export class LiveImage implements QuickBrickPlayer.SharedPlayerCallBacks {
672
644
  return this._preparePromise;
673
645
  }
674
646
 
647
+ private async createPreparedPlayer(): Promise<boolean> {
648
+ let entry = this.factoryConfig.entry;
649
+
650
+ if (this.preloadHooks?.length) {
651
+ const result = await executePreloadHooks({
652
+ preloadHooks: this.preloadHooks,
653
+ entry,
654
+ });
655
+
656
+ if (!result) return false;
657
+
658
+ this.processedEntry = result;
659
+ entry = result;
660
+ }
661
+
662
+ const factoryItem = await playerFactory({
663
+ player: this.factoryConfig.player,
664
+ playerId: this.factoryConfig.playerId,
665
+ autoplay: false,
666
+ entry,
667
+ muted: this.initiallyMuted,
668
+ playerPluginId: this.factoryConfig.playerPluginId,
669
+ screenConfig: this.factoryConfig.screenConfig,
670
+ playerRole: PlayerRole.Cell,
671
+ });
672
+
673
+ if (!factoryItem) {
674
+ throw new Error(
675
+ `Player factory returned null (playerId: ${this.factoryConfig.playerId}, playerPluginId: ${this.factoryConfig.playerPluginId})`
676
+ );
677
+ }
678
+
679
+ this.player = factoryItem.controller;
680
+ this.component = factoryItem.Component;
681
+ this.player.addListener({ id: "live-image", listener: this });
682
+
683
+ return true;
684
+ }
685
+
675
686
  public getPlayer = (): Player | null => {
676
687
  return this.player;
677
688
  };
@@ -126,14 +126,16 @@ const PlayerLiveImageComponent = (props: Props) => {
126
126
  factoryConfig: {
127
127
  player: ref,
128
128
  playerId,
129
- muted,
130
129
  playerPluginId: playerPluginId,
131
130
  screenConfig: screenConfig,
132
131
  entry: item,
133
132
  },
134
133
  tag: item.title?.toString(),
135
134
  });
136
- }, [playerId, preloadHooks, muted, playerPluginId, screenConfig, item]);
135
+ }, [playerId, preloadHooks, playerPluginId, screenConfig, item]);
136
+
137
+ // Keep the muted state in sync with user preference and player state
138
+ liveImageItem.initiallyMuted = muted;
137
139
 
138
140
  React.useEffect(() => {
139
141
  liveImageItem.setMode = setModeDebounced;
@@ -10,6 +10,7 @@ import { playerManager } from "@applicaster/zapp-react-native-utils/appUtils";
10
10
  import { create } from "zustand";
11
11
  import { useRivers } from "@applicaster/zapp-react-native-utils/reactHooks";
12
12
  import { selectPluginConfigurationsByPluginId } from "@applicaster/zapp-react-native-redux";
13
+ import { usePlayer } from "@applicaster/zapp-react-native-utils/appUtils/playerManager/usePlayer";
13
14
 
14
15
  export const useConfiguration = () => {
15
16
  const {
@@ -18,6 +19,7 @@ export const useConfiguration = () => {
18
19
 
19
20
  const rivers = useRivers();
20
21
  const contentTypes = useContentTypes();
22
+ const player = usePlayer();
21
23
 
22
24
  const targetScreenId = contentTypes?.[item?.type?.value]?.screen_id;
23
25
  const targetScreenConfiguration = rivers?.[targetScreenId];
@@ -26,7 +28,10 @@ export const useConfiguration = () => {
26
28
  selectPluginConfigurationsByPluginId(state, targetScreenConfiguration?.type)
27
29
  );
28
30
 
29
- const playerPluginConfig = playerManager.getPluginConfiguration();
31
+ const playerPluginConfig =
32
+ player?.getPluginConfiguration() ??
33
+ playerManager.getInstanceController()?.getPluginConfiguration() ??
34
+ {};
30
35
 
31
36
  const config = mergeRight(playerPluginConfig, {
32
37
  ...configuration_json,
@@ -1,4 +1,3 @@
1
- import { sendTapCellEvent, sendTapMenuItem } from "../Analytics";
2
1
  import { getItemType } from "@applicaster/zapp-react-native-utils/navigationUtils";
3
2
  import { SCREEN_TYPES } from "@applicaster/zapp-react-native-utils/navigationUtils/itemTypes";
4
3
 
@@ -12,7 +11,6 @@ export function onCellPress(
12
11
  itemIndex,
13
12
  layoutVersion = "v1"
14
13
  ) {
15
- sendTapCellEvent(entry, component, headerTitle, itemIndex);
16
14
  const componentScreenType = screenTypeFromComponent(component);
17
15
  const entryScreenType = screenTypeFromEntry(entry);
18
16
  const itemType = getItemType(entry, layoutVersion);
@@ -37,7 +35,3 @@ function screenTypeFromComponent(component) {
37
35
  function screenTypeFromEntry(entry) {
38
36
  return entry && entry.screen_type;
39
37
  }
40
-
41
- export function onMenuItemFocus({ item, index, isHome }) {
42
- sendTapMenuItem({ item, index, isHome });
43
- }
package/Helpers/index.js CHANGED
@@ -1,42 +1,9 @@
1
- export const ASSETS = {
2
- APP_BACKGROUND_IMAGE: "app_background_image",
3
- };
1
+ import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
4
2
 
5
- export const ANALYTICS_CORE_EVENTS = {
6
- TAP_CELL: "Tap Cell",
7
- PLAY_VOD_ITEM: "Play VOD Item",
8
- VOD_ITEM_PLAY_WAS_TRIGGERED: "VOD Item: Play Was Triggered",
9
- CHANNEL_ITEM_PLAY_WAS_TRIGGERED: "Channel Item: Play Was Triggered",
10
- PROGRAM_ITEM_PLAY_WAS_TRIGGERED: "Program Item: Play Was Triggered",
11
- TAP_MENU_ICON: "Tap Menu Item",
12
- HOME_SCREEN_VIEWED: "Home Screen: Viewed",
13
- ITEM_NOT_AVAILABLE: "N/A",
14
- };
15
-
16
- export const ANALYTICS_ENTRY_EVENTS = {
17
- ITEM_TYPE: "Item Type",
18
- ITEM_TITLE: "Item Name",
19
- ITEM_ID: "Item ID",
20
- ITEM_LINK: "Item Link",
21
- ITEM_INDEX: "Item Number",
22
- ITEM_TIME_PLAYED: "Item Total Time Played",
23
- ITEM_TOTAL_TIME_PLAYED: "Item Total Time Played",
24
- ITEM_PLAY_COMPLETED: "Completed",
25
- ITEM_CUSTOM_PROPERTY: "Custom Property",
26
- };
27
-
28
- export const ANALYTICS_COMPONENT_EVENTS = {
29
- COMPONENT_ID: "Component ID",
30
- COMPONENT_TYPE: "Component Type",
31
- CELL_STYLE: "Cell Style",
32
- HEADER_TITLE: "Header Name",
33
- COMPONENT_SOURCE: "Component Source",
34
- };
35
-
36
- export const ANALYTICS_MENU_ITEM_EVENTS = {
37
- ITEM_TYPE: "Item Type",
38
- ITEM_TITLE: "Item Name",
39
- ITEM_ID: "Item ID",
40
- ITEM_HOME_SCREEN: "Home Screen",
41
- ITEM_INDEX: "Item Number",
3
+ export const ASSETS = {
4
+ APP_BACKGROUND_IMAGE: platformSelect({
5
+ tvos: "app_background_image",
6
+ android_tv: "tv_app_background",
7
+ amazon: "tv_app_background",
8
+ }),
42
9
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-ui-components",
3
- "version": "16.0.0-rc.2",
3
+ "version": "16.0.0-rc.20",
4
4
  "description": "Applicaster Zapp React Native ui components for the Quick Brick App",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -28,10 +28,10 @@
28
28
  },
29
29
  "homepage": "https://github.com/applicaster/quickbrick#readme",
30
30
  "dependencies": {
31
- "@applicaster/applicaster-types": "16.0.0-rc.2",
32
- "@applicaster/zapp-react-native-bridge": "16.0.0-rc.2",
33
- "@applicaster/zapp-react-native-redux": "16.0.0-rc.2",
34
- "@applicaster/zapp-react-native-utils": "16.0.0-rc.2",
31
+ "@applicaster/applicaster-types": "16.0.0-rc.20",
32
+ "@applicaster/zapp-react-native-bridge": "16.0.0-rc.20",
33
+ "@applicaster/zapp-react-native-redux": "16.0.0-rc.20",
34
+ "@applicaster/zapp-react-native-utils": "16.0.0-rc.20",
35
35
  "fast-json-stable-stringify": "^2.1.0",
36
36
  "promise": "^8.3.0",
37
37
  "url": "^0.11.0",
@@ -1,31 +0,0 @@
1
- import React from "react";
2
- import { getBackgroundImageUrl } from "../utils";
3
- import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
4
- import {
5
- selectRemoteConfigurations,
6
- useAppSelector,
7
- } from "@applicaster/zapp-react-native-redux";
8
-
9
- export const LayoutBackground = ({
10
- Background,
11
- children,
12
- }: {
13
- Background: React.ComponentType<any>;
14
- children: React.ReactNode;
15
- }) => {
16
- const theme = useTheme();
17
-
18
- const remoteConfigurations = useAppSelector(selectRemoteConfigurations);
19
-
20
- const backgroundColor = theme.app_background_color;
21
- const backgroundImageUrl = getBackgroundImageUrl(remoteConfigurations);
22
-
23
- return (
24
- <Background
25
- backgroundColor={backgroundColor}
26
- backgroundImageUrl={backgroundImageUrl}
27
- >
28
- {children}
29
- </Background>
30
- );
31
- };
@@ -1,95 +0,0 @@
1
- import * as R from "ramda";
2
- import { postAnalyticEvent } from "@applicaster/zapp-react-native-tvos-app/AnalyticsManager";
3
- import { extensionsEvents } from "@applicaster/zapp-react-native-utils/analyticsUtils/AnalyticsEvents/helper";
4
- import {
5
- ANALYTICS_CORE_EVENTS,
6
- ANALYTICS_ENTRY_EVENTS,
7
- ANALYTICS_COMPONENT_EVENTS,
8
- ANALYTICS_MENU_ITEM_EVENTS,
9
- } from "../";
10
-
11
- export function sendTapCellEvent(item, component, headerTitle, itemIndex) {
12
- const itemReadableIndex = itemIndex + 1;
13
-
14
- const analyticsProperties = R.compose(
15
- R.reject(R.isNil),
16
- R.merge(eventForEntry(item, itemReadableIndex))
17
- )(eventForComponent(component, headerTitle));
18
-
19
- postEvent(ANALYTICS_CORE_EVENTS.TAP_CELL, analyticsProperties);
20
- }
21
-
22
- export function sendTapMenuItem({ item, index, isHome }) {
23
- const analyticsProperties = R.compose(R.reject(R.isNil))(
24
- eventForMenuItemEntry({ item, index, isHome })
25
- );
26
-
27
- postEvent(ANALYTICS_CORE_EVENTS.TAP_MENU_ICON, analyticsProperties);
28
-
29
- if (isHome) {
30
- postEvent(ANALYTICS_CORE_EVENTS.HOME_SCREEN_VIEWED, null);
31
- }
32
- }
33
-
34
- function postEvent(event, properties) {
35
- postAnalyticEvent(event, properties);
36
- }
37
-
38
- function eventForEntry(item, itemIndex) {
39
- const {
40
- title,
41
- type: { value: valueType },
42
- id,
43
- } = item;
44
-
45
- const analyticsCustomProperties = extensionsEvents(item.extensions);
46
-
47
- const analyticsEvents = {
48
- [ANALYTICS_ENTRY_EVENTS.ITEM_TYPE]: valueType,
49
- [ANALYTICS_ENTRY_EVENTS.ITEM_TITLE]: title,
50
- [ANALYTICS_ENTRY_EVENTS.ITEM_ID]: id,
51
- [ANALYTICS_ENTRY_EVENTS.ITEM_INDEX]:
52
- (itemIndex && itemIndex.toString()) || null,
53
- };
54
-
55
- if (analyticsCustomProperties) {
56
- analyticsEvents.analyticsCustomProperties = analyticsCustomProperties;
57
- }
58
-
59
- return analyticsEvents;
60
- }
61
-
62
- function eventForComponent(
63
- component,
64
- headerTitle, // Zapp Pipes data passed for group components
65
- zappPipesData = null
66
- ) {
67
- const { id, component_type, styles, data } = component;
68
- const { cell_style } = styles;
69
- const source = data?.source || zappPipesData?.data?.url || null;
70
-
71
- return {
72
- [ANALYTICS_COMPONENT_EVENTS.COMPONENT_ID]: id,
73
- [ANALYTICS_COMPONENT_EVENTS.COMPONENT_TYPE]: component_type,
74
- [ANALYTICS_COMPONENT_EVENTS.CELL_STYLE]:
75
- cell_style || ANALYTICS_CORE_EVENTS.ITEM_NOT_AVAILABLE,
76
- [ANALYTICS_COMPONENT_EVENTS.COMPONENT_SOURCE]:
77
- (source && encodeURIComponent(source)) || null,
78
- [ANALYTICS_COMPONENT_EVENTS.HEADER_TITLE]: headerTitle,
79
- };
80
- }
81
-
82
- function eventForMenuItemEntry({ item, index, isHome }) {
83
- const { title, type, id } = item;
84
-
85
- const itemReadableIndex = index + 1;
86
-
87
- return {
88
- [ANALYTICS_MENU_ITEM_EVENTS.ITEM_INDEX]:
89
- (itemReadableIndex && itemReadableIndex.toString()) || null,
90
- [ANALYTICS_MENU_ITEM_EVENTS.ITEM_TYPE]: type,
91
- [ANALYTICS_MENU_ITEM_EVENTS.ITEM_TITLE]: title,
92
- [ANALYTICS_MENU_ITEM_EVENTS.ITEM_ID]: id,
93
- [ANALYTICS_MENU_ITEM_EVENTS.ITEM_HOME_SCREEN]: isHome ? "YES" : "NO",
94
- };
95
- }