@applicaster/zapp-react-native-ui-components 16.0.0-rc.99 → 17.0.0-alpha.1102403272

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 (112) hide show
  1. package/Components/AudioPlayer/index.web.tsx +10 -0
  2. package/Components/Cell/PlatformCellComponent.ts +9 -0
  3. package/Components/Cell/PlatformCellComponent.web.ts +3 -0
  4. package/Components/Cell/index.js +2 -9
  5. package/Components/CellRendererResolver/index.ts +22 -3
  6. package/Components/ComponentResolver/ComponentResolver.ts +6 -2
  7. package/Components/ComponentResolver/__tests__/componentResolver.test.js +13 -5
  8. package/Components/ContentScreen/index.js +2 -2
  9. package/Components/Focusable/index.web.tsx +3 -0
  10. package/Components/FocusableList/hooks/useCheckItemIdsForUnique.ts +2 -7
  11. package/Components/GeneralContentScreen/GeneralContentScreen.tsx +1 -1
  12. package/Components/GeneralContentScreen/hookAdapter/logger.ts +1 -1
  13. package/Components/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +158 -1
  14. package/Components/GeneralContentScreen/utils/index.ts +2 -2
  15. package/Components/GeneralContentScreen/utils/logger.ts +3 -4
  16. package/Components/GeneralContentScreen/utils/useCurationAPI.ts +32 -10
  17. package/Components/HandlePlayable/utils.ts +2 -7
  18. package/Components/HookRenderer/HookRenderer.tsx +2 -2
  19. package/Components/MasterCell/DefaultComponents/ActionButton.tsx +42 -4
  20. package/Components/MasterCell/DefaultComponents/ButtonContainerView/index.android.tv.tsx +7 -4
  21. package/Components/MasterCell/DefaultComponents/ButtonContainerView/types.ts +1 -0
  22. package/Components/MasterCell/DefaultComponents/FocusableView/index.android.tsx +10 -4
  23. package/Components/MasterCell/DefaultComponents/Image/hoc/utils/__tests__/withDimensions.test.ts +1 -1
  24. package/Components/MasterCell/DefaultComponents/Image/hoc/utils/index.ts +2 -4
  25. package/Components/MasterCell/DefaultComponents/Image/hooks/checkTooBigImageSize.ts +2 -7
  26. package/Components/MasterCell/DefaultComponents/Image/index.web.ts +7 -0
  27. package/Components/MasterCell/DefaultComponents/LiveImage/__tests__/prepareEntry.test.ts +30 -0
  28. package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +34 -7
  29. package/Components/MasterCell/DefaultComponents/PressableView.tsx +3 -0
  30. package/Components/MasterCell/DefaultComponents/Text/hooks/useText.ts +2 -7
  31. package/Components/MasterCell/DefaultComponents/__tests__/ActionButton.missingPlugin.test.tsx +66 -0
  32. package/Components/MasterCell/DefaultComponents/__tests__/ActionButton.test.tsx +288 -0
  33. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/ActionButton.tsx +2 -1
  34. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/PressableView.test.tsx +4 -2
  35. package/Components/MasterCell/SharedUI/CollapsibleTextContainer/__tests__/factory.test.ts +2 -2
  36. package/Components/MasterCell/SharedUI/CollapsibleTextContainer/index.ts +2 -1
  37. package/Components/MasterCell/__tests__/masterCell.test.js +116 -0
  38. package/Components/MasterCell/index.tsx +45 -6
  39. package/Components/MasterCell/logger.ts +2 -2
  40. package/Components/MasterCell/utils/__tests__/getFocusableElementId.test.ts +38 -0
  41. package/Components/MasterCell/utils/__tests__/useIsCellSelected.test.ts +91 -0
  42. package/Components/MasterCell/utils/__tests__/withoutFocusedState.test.js +20 -0
  43. package/Components/MasterCell/utils/behaviorProvider.ts +57 -38
  44. package/Components/MasterCell/utils/index.ts +60 -19
  45. package/Components/ModalComponent/ActionsBottomSheet/openActionsBottomSheet.ts +1 -1
  46. package/Components/ModalComponent/AudioPlayer/Components/Button.tsx +7 -3
  47. package/Components/ModalComponent/AudioPlayer/Components/Item.tsx +22 -1
  48. package/Components/ModalComponent/AudioPlayer/Components/__tests__/Item.test.tsx +52 -1
  49. package/Components/ModalComponent/AudioPlayer/utils/__tests__/mergeStyles.test.ts +77 -0
  50. package/Components/ModalComponent/AudioPlayer/utils/mergeStyles.ts +58 -16
  51. package/Components/ModalComponent/BottomSheetDragArea.web.tsx +15 -0
  52. package/Components/ModalComponent/BottomSheetModalContent.tsx +51 -82
  53. package/Components/ModalComponent/Button/index.tsx +3 -1
  54. package/Components/ModalComponent/SortableList.tsx +2 -3
  55. package/Components/ModalComponent/__tests__/BottomSheetDragArea.test.tsx +30 -0
  56. package/Components/ModalComponent/__tests__/BottomSheetModalContent.test.tsx +237 -17
  57. package/Components/ModalComponent/__tests__/showTextInput.test.ts +25 -0
  58. package/Components/ModalComponent/presets/__tests__/getCell.test.ts +29 -2
  59. package/Components/ModalComponent/presets/index.ts +2 -3
  60. package/Components/ModalComponent/showTextInput.ts +2 -0
  61. package/Components/OfflineHandler/__tests__/index.test.tsx +136 -0
  62. package/Components/OfflineHandler/index.tsx +45 -6
  63. package/Components/PlayerContainer/PlayerContainer.tsx +30 -6
  64. package/Components/PlayerContainer/__tests__/PlayerContainer.test.tsx +51 -0
  65. package/Components/PlayerContainer/logger.ts +9 -5
  66. package/Components/River/ComponentsMap/ComponentsMap.tsx +4 -1
  67. package/Components/River/ComponentsMap/index.web.tsx +3 -0
  68. package/Components/River/RiverItem.tsx +4 -0
  69. package/Components/River/TV/River.tsx +7 -1
  70. package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +2 -0
  71. package/Components/ScreenFeedLoader/ScreenFeedLoader.tsx +2 -2
  72. package/Components/ScreenResolver/index.tsx +6 -4
  73. package/Components/Tabs/TV/index.web.tsx +5 -0
  74. package/Components/TopCutoffOverlay/__tests__/TopCutoffOverlay.test.tsx +56 -10
  75. package/Components/TopCutoffOverlay/index.tsx +41 -10
  76. package/Components/Transitioner/AnimationManager.js +1 -1
  77. package/Components/Transitioner/Scene.tsx +4 -3
  78. package/Components/Transitioner/Transitioner.tsx +71 -33
  79. package/Components/Transitioner/__tests__/transitioner.test.js +372 -3
  80. package/Components/VideoLive/LiveImageManager.ts +126 -12
  81. package/Components/VideoLive/MuteUnmuteController.ts +135 -0
  82. package/Components/VideoLive/PlayerLiveImageComponent.tsx +15 -19
  83. package/Components/VideoLive/__tests__/LiveImageManager.test.ts +30 -0
  84. package/Components/VideoLive/__tests__/LiveImageMuteState.test.ts +311 -0
  85. package/Components/VideoLive/__tests__/MuteUnmuteController.test.ts +135 -0
  86. package/Components/VideoLive/__tests__/PlayerLiveImageComponent.test.tsx +63 -1
  87. package/Components/VideoLive/loggerHelper.ts +2 -2
  88. package/Components/VideoModal/PlayerDetails.tsx +27 -2
  89. package/Components/VideoModal/PlayerWrapper.tsx +9 -2
  90. package/Components/VideoModal/__tests__/PlayerDetails.test.tsx +84 -0
  91. package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +1 -0
  92. package/Components/VideoModal/__tests__/playerWrapperStyle.test.ts +263 -0
  93. package/Components/VideoModal/__tests__/playerWrapperUtils.test.ts +125 -0
  94. package/Components/VideoModal/hooks/useModalSize.ts +2 -7
  95. package/Components/VideoModal/playerWrapperStyle.ts +62 -23
  96. package/Components/VideoModal/playerWrapperUtils.ts +141 -1
  97. package/Components/__tests__/webVariants.test.js +73 -0
  98. package/Components/default-cell-renderer/containerStyles/index.web.ts +6 -0
  99. package/Components/default-cell-renderer/viewTrees/index.web.ts +10 -0
  100. package/Contexts/ZappPipesContext/ZappPipesContextFactory.tsx +3 -5
  101. package/Decorators/RiverResolver/__tests__/riverResolver.missingRiver.test.tsx +52 -0
  102. package/Decorators/RiverResolver/index.tsx +25 -0
  103. package/Decorators/ZappPipesDataConnector/__tests__/UrlFeedResolver.test.tsx +4 -3
  104. package/Decorators/ZappPipesDataConnector/__tests__/screenToolbox.test.ts +347 -0
  105. package/Decorators/ZappPipesDataConnector/__tests__/screenToolboxUnavailable.test.ts +53 -0
  106. package/Decorators/ZappPipesDataConnector/index.tsx +19 -4
  107. package/Decorators/ZappPipesDataConnector/resolvers/UrlFeedResolver.tsx +2 -21
  108. package/Decorators/ZappPipesDataConnector/screenToolbox.ts +384 -0
  109. package/Decorators/ZappPipesDataConnector/utils/mongoFilter.ts +1 -1
  110. package/Decorators/ZappPipesDataConnector/utils/useFilter.tsx +1 -1
  111. package/Helpers/logger.js +2 -2
  112. package/package.json +5 -5
@@ -0,0 +1,125 @@
1
+ import {
2
+ getEdges,
3
+ getPlayerLayout,
4
+ getVerticalColumnWidth,
5
+ } from "../playerWrapperUtils";
6
+
7
+ describe("getEdges", () => {
8
+ it("keeps the top edge in fullscreen when not vertical", () => {
9
+ expect(getEdges(false, false)).toEqual(["top"]);
10
+ });
11
+
12
+ it("has no edges in vertical fullscreen", () => {
13
+ expect(getEdges(false, false, true)).toEqual([]);
14
+ expect(getEdges(true, false, true)).toEqual([]);
15
+ });
16
+
17
+ it("keeps the top edge for the vertical inline modal", () => {
18
+ expect(getEdges(false, true, true)).toEqual(["top"]);
19
+ });
20
+ });
21
+
22
+ describe("getVerticalColumnWidth", () => {
23
+ it("splits the frame by the configured percentage", () => {
24
+ expect(getVerticalColumnWidth(1000, "25%")).toBeCloseTo(750);
25
+ });
26
+
27
+ it("subtracts a fixed sidebar", () => {
28
+ expect(getVerticalColumnWidth(1000, "300")).toBeCloseTo(700);
29
+ });
30
+
31
+ it("falls back to the default split without a sidebar", () => {
32
+ expect(getVerticalColumnWidth(1000, undefined)).toBeCloseTo(650);
33
+ });
34
+
35
+ it("falls back to the default split for a malformed sidebar", () => {
36
+ expect(getVerticalColumnWidth(1000, "abc")).toBeCloseTo(650);
37
+ expect(getVerticalColumnWidth(1000, "abc%")).toBeCloseTo(650);
38
+ });
39
+
40
+ it("never leaves a negative column for a sidebar wider than the frame", () => {
41
+ expect(getVerticalColumnWidth(1000, "120%")).toBeCloseTo(650);
42
+ expect(getVerticalColumnWidth(1000, "1200")).toBeCloseTo(650);
43
+ });
44
+
45
+ it("has no column before the frame is known", () => {
46
+ expect(getVerticalColumnWidth(0, "35%")).toBe(0);
47
+ });
48
+ });
49
+
50
+ describe("getPlayerLayout", () => {
51
+ const baseDimensions = { width: 786.5, height: undefined };
52
+
53
+ it("keeps the aspect-ratio frame when the tablet vertical layout does not apply", () => {
54
+ expect(
55
+ getPlayerLayout({
56
+ baseDimensions,
57
+ aspectRatio: 16 / 9,
58
+ verticalInlineTablet: false,
59
+ frameWidth: 1210,
60
+ frameHeight: 834,
61
+ sidebarWidth: "35%",
62
+ topInset: 24,
63
+ bottomInset: 20,
64
+ })
65
+ ).toEqual({
66
+ containerDimensions: {
67
+ width: 786.5,
68
+ height: undefined,
69
+ aspectRatio: 16 / 9,
70
+ },
71
+ playerDimensions: {
72
+ width: 786.5,
73
+ height: undefined,
74
+ aspectRatio: 16 / 9,
75
+ },
76
+ wrapperStyle: null,
77
+ });
78
+ });
79
+
80
+ it("fills the column height and centers a 9:16 video inside the current width", () => {
81
+ const layout = getPlayerLayout({
82
+ baseDimensions,
83
+ aspectRatio: 9 / 16,
84
+ verticalInlineTablet: true,
85
+ frameWidth: 1210,
86
+ frameHeight: 834,
87
+ sidebarWidth: "35%",
88
+ topInset: 24,
89
+ bottomInset: 20,
90
+ });
91
+
92
+ const videoHeight = 834 - 24 - 20;
93
+
94
+ expect(layout.wrapperStyle).toEqual({
95
+ width: 786.5,
96
+ height: 834,
97
+ paddingBottom: 20,
98
+ });
99
+
100
+ expect(layout.playerDimensions).toEqual({
101
+ width: videoHeight * (9 / 16),
102
+ height: videoHeight,
103
+ alignSelf: "center",
104
+ });
105
+ });
106
+
107
+ it("does not grow wider than the player column", () => {
108
+ const layout = getPlayerLayout({
109
+ baseDimensions: { width: 300, height: undefined },
110
+ aspectRatio: 9 / 16,
111
+ verticalInlineTablet: true,
112
+ frameWidth: 300,
113
+ frameHeight: 834,
114
+ sidebarWidth: "0%",
115
+ topInset: 0,
116
+ bottomInset: 0,
117
+ });
118
+
119
+ expect(layout.playerDimensions.width).toBe(300);
120
+ expect(layout.playerDimensions.height).toBeCloseTo(300 * (16 / 9));
121
+ expect(layout.playerDimensions.marginTop).toBe("auto");
122
+ expect(layout.playerDimensions.marginBottom).toBe("auto");
123
+ expect(layout.wrapperStyle).toMatchObject({ width: 300 });
124
+ });
125
+ });
@@ -7,7 +7,7 @@ import {
7
7
  removeOrientationChangeListener,
8
8
  } from "@applicaster/zapp-react-native-utils/appUtils/orientationHelper";
9
9
 
10
- import { getXray } from "@applicaster/zapp-react-native-utils/logger";
10
+ import { subsystemLogger } from "@applicaster/zapp-react-native-utils/logger";
11
11
  import { useSafeAreaFrame } from "react-native-safe-area-context";
12
12
  import {
13
13
  isAndroidPlatform,
@@ -16,12 +16,7 @@ import {
16
16
  import { StatusBar } from "react-native";
17
17
  import { isAndroidTablet } from "@applicaster/zapp-react-native-utils/reactHooks/layout/isTablet";
18
18
 
19
- const { Logger } = getXray();
20
-
21
- const logger = new Logger(
22
- "hooks",
23
- "zapp-react-native-ui-components/Components/VideoModal"
24
- );
19
+ const logger = subsystemLogger("player/modal", "hooks");
25
20
 
26
21
  type Size = {
27
22
  width: number | string;
@@ -1,14 +1,20 @@
1
1
  import * as React from "react";
2
2
  import { StyleSheet, ViewStyle } from "react-native";
3
+ import {
4
+ useSafeAreaFrame,
5
+ useSafeAreaInsets,
6
+ } from "react-native-safe-area-context";
3
7
  import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
4
- import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
8
+ import {
9
+ useIsTablet,
10
+ useOrientation,
11
+ } from "@applicaster/zapp-react-native-utils/reactHooks";
5
12
  import { playerDimensionsHack } from "./utils";
6
13
  import { getTabletWidth } from "@applicaster/zapp-react-native-utils/playerUtils";
7
14
  import {
8
15
  getBaseDimensions,
9
16
  calculateAspectRatio,
10
- getPlayerDimensions,
11
- getContainerDimensions,
17
+ getPlayerLayout,
12
18
  } from "./playerWrapperUtils";
13
19
 
14
20
  export const defaultStyles = StyleSheet.create({
@@ -22,13 +28,18 @@ export const useStyle = ({
22
28
  isTabletPortrait,
23
29
  configuration,
24
30
  pip,
31
+ vertical,
25
32
  }) => {
26
33
  const isTablet = useIsTablet();
34
+ const isLandscape = useOrientation() === "landscape";
27
35
 
28
36
  const isInlineModal = inline && isModal;
29
37
 
30
38
  const isTabletLandscape = !isTV() && isTablet && !isTabletPortrait;
31
39
 
40
+ const frame = useSafeAreaFrame();
41
+ const insets = useSafeAreaInsets();
42
+
32
43
  const tabletWidth = getTabletWidth(
33
44
  configuration.tablet_landscape_sidebar_width,
34
45
  style
@@ -40,31 +51,59 @@ export const useStyle = ({
40
51
  );
41
52
 
42
53
  const aspectRatio = React.useMemo(
43
- () => calculateAspectRatio(isInlineModal, pip),
54
+ () => {
55
+ const value = calculateAspectRatio(isInlineModal, pip);
56
+
57
+ if (!vertical) {
58
+ return value;
59
+ }
60
+
61
+ // vertical fullscreen in landscape: the width is the long side, keep the screen ratio so the container matches the screen
62
+ if (isLandscape && !isInlineModal && !pip) {
63
+ return value;
64
+ }
65
+
66
+ return 1 / value;
67
+ },
44
68
  // ignoring insets - only initial needed
45
69
  // eslint-disable-next-line react-hooks/exhaustive-deps
46
- [isInlineModal, pip]
70
+ [isInlineModal, pip, vertical, isLandscape]
47
71
  );
48
72
 
49
- return React.useMemo(() => {
50
- const playerDimensions: ViewStyle = getPlayerDimensions(
51
- baseDimensions,
52
- aspectRatio
53
- );
73
+ const verticalInlineTablet =
74
+ vertical && isInlineModal && isTabletLandscape && !pip;
54
75
 
55
- const containerDimensions: ViewStyle = getContainerDimensions(
56
- baseDimensions,
57
- aspectRatio
58
- );
76
+ return React.useMemo(() => {
77
+ const { containerDimensions, playerDimensions, wrapperStyle } =
78
+ getPlayerLayout({
79
+ baseDimensions,
80
+ aspectRatio,
81
+ verticalInlineTablet,
82
+ frameWidth: frame.width,
83
+ frameHeight: frame.height,
84
+ sidebarWidth: configuration.tablet_landscape_sidebar_width,
85
+ topInset: insets.top,
86
+ bottomInset: insets.bottom,
87
+ });
59
88
 
60
- const childrenStyles = {
61
- ...playerDimensions,
62
- ...playerDimensionsHack,
89
+ return {
90
+ ...StyleSheet.create({
91
+ containerDimensions,
92
+ childrenStyles: {
93
+ ...playerDimensions,
94
+ ...playerDimensionsHack,
95
+ },
96
+ }),
97
+ wrapperStyle,
63
98
  };
64
-
65
- return StyleSheet.create({
66
- containerDimensions,
67
- childrenStyles,
68
- });
69
- }, [baseDimensions, aspectRatio]);
99
+ }, [
100
+ baseDimensions,
101
+ aspectRatio,
102
+ verticalInlineTablet,
103
+ configuration.tablet_landscape_sidebar_width,
104
+ frame.width,
105
+ frame.height,
106
+ insets.top,
107
+ insets.bottom,
108
+ ]);
70
109
  };
@@ -1,5 +1,6 @@
1
1
  import { Dimensions, DimensionValue, Platform, ViewStyle } from "react-native";
2
2
  import { Edge } from "react-native-safe-area-context";
3
+ import { getTabletWidth } from "@applicaster/zapp-react-native-utils/playerUtils";
3
4
 
4
5
  export type DimensionsT = {
5
6
  width: number | string;
@@ -13,6 +14,43 @@ export type Configuration = {
13
14
  tablet_landscape_player_container_background_color?: string;
14
15
  };
15
16
 
17
+ export type PlayerLayout = {
18
+ containerDimensions: ViewStyle;
19
+ playerDimensions: ViewStyle;
20
+ wrapperStyle: ViewStyle | null;
21
+ };
22
+
23
+ const VERTICAL_VIDEO_ASPECT_RATIO = 9 / 16;
24
+
25
+ const DEFAULT_PLAYER_COLUMN_RATIO = 0.65;
26
+
27
+ /**
28
+ * Player column width for the given frame, using the same split as the rest of
29
+ * the tablet landscape layout. `getTabletWidth` resolves percentages against
30
+ * `Dimensions.get("screen")`, which is the whole device in split view and lags
31
+ * a rotation on Android, so it is fed the live frame instead.
32
+ */
33
+ export const getVerticalColumnWidth = (
34
+ frameWidth: number,
35
+ sidebarWidth?: string
36
+ ): number => {
37
+ if (!(frameWidth > 0)) {
38
+ return 0;
39
+ }
40
+
41
+ const columnWidth = getTabletWidth(sidebarWidth, {
42
+ width: frameWidth,
43
+ height: undefined,
44
+ });
45
+
46
+ // A malformed sidebar width yields NaN or a negative column.
47
+ if (!(columnWidth > 0)) {
48
+ return frameWidth * DEFAULT_PLAYER_COLUMN_RATIO;
49
+ }
50
+
51
+ return Math.min(columnWidth, frameWidth);
52
+ };
53
+
16
54
  // This is safe, remembering screen dimensions once as they do not change during runtime
17
55
  // TODO: consider sharing screen orientation as a shared function for the app
18
56
  const { width: SCREEN_WIDTH, height: SCREEN_HEIGHT } = Dimensions.get("screen");
@@ -44,8 +82,14 @@ export const getScreenAspectRatio = () => {
44
82
 
45
83
  export const getEdges = (
46
84
  isTablet: boolean,
47
- isInlineModal: boolean
85
+ isInlineModal: boolean,
86
+ vertical: boolean = false
48
87
  ): readonly Edge[] => {
88
+ // vertical fullscreen: the player takes the full screen height, a top inset would push it below the screen
89
+ if (vertical && !isInlineModal) {
90
+ return [];
91
+ }
92
+
49
93
  if (isTablet) {
50
94
  return ["top"];
51
95
  }
@@ -89,3 +133,99 @@ export const getContainerDimensions = (
89
133
  ...baseDimensions,
90
134
  aspectRatio,
91
135
  });
136
+
137
+ /**
138
+ * Tablet landscape inline. Column widths stay put. The 9:16 video fills the
139
+ * height and is centered; controls use the full column.
140
+ */
141
+ const getTabletVerticalInlineLayout = ({
142
+ columnWidth,
143
+ frameHeight,
144
+ topInset,
145
+ bottomInset,
146
+ }: {
147
+ columnWidth: number;
148
+ frameHeight: number;
149
+ topInset: number;
150
+ bottomInset: number;
151
+ }): PlayerLayout | null => {
152
+ const availableHeight = frameHeight - topInset - bottomInset;
153
+
154
+ if (!(columnWidth > 0) || !(availableHeight > 0)) {
155
+ return null;
156
+ }
157
+
158
+ const videoWidth = Math.min(
159
+ columnWidth,
160
+ availableHeight * VERTICAL_VIDEO_ASPECT_RATIO
161
+ );
162
+
163
+ const videoHeight = videoWidth / VERTICAL_VIDEO_ASPECT_RATIO;
164
+
165
+ // alignSelf only centers horizontally. A column narrower than a full-height
166
+ // 9:16 frame (common on Android tablets) leaves empty space below the video.
167
+ const verticalMargins =
168
+ videoHeight < availableHeight
169
+ ? { marginTop: "auto" as const, marginBottom: "auto" as const }
170
+ : null;
171
+
172
+ return {
173
+ wrapperStyle: {
174
+ width: columnWidth,
175
+ height: frameHeight,
176
+ paddingBottom: bottomInset,
177
+ },
178
+ containerDimensions: {
179
+ flex: 1,
180
+ width: "100%",
181
+ alignSelf: "stretch",
182
+ },
183
+ playerDimensions: {
184
+ width: videoWidth,
185
+ height: videoHeight,
186
+ alignSelf: "center",
187
+ ...verticalMargins,
188
+ },
189
+ };
190
+ };
191
+
192
+ export const getPlayerLayout = ({
193
+ baseDimensions,
194
+ aspectRatio,
195
+ verticalInlineTablet,
196
+ frameWidth,
197
+ frameHeight,
198
+ sidebarWidth,
199
+ topInset,
200
+ bottomInset,
201
+ }: {
202
+ baseDimensions: ViewStyle;
203
+ aspectRatio: number;
204
+ verticalInlineTablet: boolean;
205
+ frameWidth: number;
206
+ frameHeight: number;
207
+ sidebarWidth?: string;
208
+ topInset: number;
209
+ bottomInset: number;
210
+ }): PlayerLayout => {
211
+ const columnWidth = getVerticalColumnWidth(frameWidth, sidebarWidth);
212
+
213
+ if (verticalInlineTablet && columnWidth > 0) {
214
+ const layout = getTabletVerticalInlineLayout({
215
+ columnWidth,
216
+ frameHeight,
217
+ topInset,
218
+ bottomInset,
219
+ });
220
+
221
+ if (layout) {
222
+ return layout;
223
+ }
224
+ }
225
+
226
+ return {
227
+ containerDimensions: getContainerDimensions(baseDimensions, aspectRatio),
228
+ playerDimensions: getPlayerDimensions(baseDimensions, aspectRatio),
229
+ wrapperStyle: null,
230
+ };
231
+ };
@@ -0,0 +1,73 @@
1
+ // Web builds resolve `*.web.*` files first. Each web variant must export what its
2
+ // platformSelect module picks on every web platform, without importing the native
3
+ // implementations.
4
+
5
+ jest.mock(
6
+ "@applicaster/zapp-react-native-ui-components/Components/MasterCell/DefaultComponents/Image/hoc/withDimensions",
7
+ () => ({ withDimensionsHOC: (Component) => Component })
8
+ );
9
+
10
+ const UI = "@applicaster/zapp-react-native-ui-components/Components";
11
+ const TVOS_UI = "@applicaster/zapp-react-native-tvos-ui-components/Components";
12
+
13
+ const SWITCHES = [
14
+ [`${UI}/River/ComponentsMap/index`, "ComponentsMap"],
15
+ [`${UI}/Cell/PlatformCellComponent`, "PlatformCellComponent"],
16
+ [`${UI}/Focusable/index`, "Focusable"],
17
+ [`${UI}/Tabs/TV/index`, "Tabs"],
18
+ [`${UI}/Tabs/TV/index`, "TabContent"],
19
+ [`${UI}/MasterCell/DefaultComponents/Image/index`, "default"],
20
+ [`${TVOS_UI}/TVEventHandlerComponent/index`, "TVEventHandlerComponent"],
21
+ ];
22
+
23
+ const COMPONENT_TYPES = [
24
+ "hero",
25
+ "screen_picker",
26
+ "grid",
27
+ "horizontal_list",
28
+ "gallery-qb",
29
+ "unknown",
30
+ ];
31
+
32
+ describe.each(["web", "samsung_tv", "lg_tv"])("on %s", (platform) => {
33
+ it.each(SWITCHES)("%s.web exports the selected %s", (path, name) => {
34
+ jest.isolateModules(() => {
35
+ require("react-native").Platform.OS = platform;
36
+
37
+ const selected = require(path)[name];
38
+
39
+ expect(selected).toBeDefined();
40
+ expect(require(`${path}.web`)[name]).toBe(selected);
41
+ });
42
+ });
43
+
44
+ it("AudioPlayer.web renders the same player as AudioPlayer", () => {
45
+ jest.isolateModules(() => {
46
+ require("react-native").Platform.OS = platform;
47
+
48
+ const props = { entry: { id: "a" } };
49
+ const selected = require(`${UI}/AudioPlayer/index`).AudioPlayer(props);
50
+ const web = require(`${UI}/AudioPlayer/index.web`).AudioPlayer(props);
51
+
52
+ expect(selected.type).toBe(require(`${UI}/AudioPlayer/tv`).AudioPlayerTV);
53
+ expect(web.type).toBe(selected.type);
54
+ expect(web.props).toEqual(selected.props);
55
+ });
56
+ });
57
+
58
+ it.each([
59
+ ["viewTrees", "viewTreeResolver"],
60
+ ["containerStyles", "containerStyleResolver"],
61
+ ])("default-cell-renderer %s.web resolves like the original", (dir, name) => {
62
+ jest.isolateModules(() => {
63
+ require("react-native").Platform.OS = platform;
64
+
65
+ const base = require(`${UI}/default-cell-renderer/${dir}/index`)[name];
66
+ const web = require(`${UI}/default-cell-renderer/${dir}/index.web`)[name];
67
+
68
+ COMPONENT_TYPES.forEach((component_type) => {
69
+ expect(web({ component_type })).toEqual(base({ component_type }));
70
+ });
71
+ });
72
+ });
73
+ });
@@ -0,0 +1,6 @@
1
+ import { containerStyleResolver as tvResolver } from "./tv";
2
+
3
+ // Web platforms (web, samsung_tv, lg_tv) always use the TV resolver, so web builds leave the mobile one out.
4
+ export function containerStyleResolver({ component_type }) {
5
+ return tvResolver({ component_type });
6
+ }
@@ -0,0 +1,10 @@
1
+ import { viewTreeResolver as tvResolver } from "./tv";
2
+
3
+ // Web platforms (web, samsung_tv, lg_tv) always use the TV resolver, so web builds leave the mobile one out.
4
+ export function viewTreeResolver({
5
+ component_type,
6
+ }: {
7
+ component_type: string;
8
+ }) {
9
+ return tvResolver({ component_type });
10
+ }
@@ -64,11 +64,9 @@ export function createZappPipesContext<T, S = T>(
64
64
  initialContextValue ?? initialContext.context
65
65
  );
66
66
 
67
- return (
68
- <Context.Provider value={{ context, setContext }}>
69
- {children}
70
- </Context.Provider>
71
- );
67
+ const value = useMemo(() => ({ context, setContext }), [context]);
68
+
69
+ return <Context.Provider value={value}>{children}</Context.Provider>;
72
70
  }
73
71
 
74
72
  function withProvider(Component: React.ComponentType<any>) {
@@ -0,0 +1,52 @@
1
+ import React from "react";
2
+ import { View } from "react-native";
3
+ import { render } from "@testing-library/react-native";
4
+
5
+ const mockError = jest.fn();
6
+
7
+ jest.mock("@applicaster/zapp-react-native-utils/logger", () => ({
8
+ // Called on import, before mockError is assigned: look it up at call time.
9
+ subsystemLogger: () => ({ error: (event) => mockError(event) }),
10
+ }));
11
+
12
+ jest.mock("@applicaster/zapp-react-native-utils/reactHooks", () => ({
13
+ useRivers: () => ({ A123: { id: "A123" } }),
14
+ }));
15
+
16
+ jest.mock(
17
+ "@applicaster/zapp-react-native-utils/reactHooks/navigation/usePathname",
18
+ () => ({ usePathname: () => "/home" })
19
+ );
20
+
21
+ import { withRiver } from "../";
22
+
23
+ const Wrapped = withRiver((props) => <View {...props} />);
24
+
25
+ describe("withRiver with a screen that is not in the layout", () => {
26
+ beforeEach(() => mockError.mockClear());
27
+
28
+ it("renders nothing and logs the entry that led there", () => {
29
+ const entry = { id: "e1", title: "Star Wars", type: { value: "movie" } };
30
+
31
+ const { toJSON } = render(<Wrapped screenId="e1" screenData={entry} />);
32
+
33
+ expect(toJSON()).toBeNull();
34
+ expect(mockError).toHaveBeenCalledTimes(1);
35
+
36
+ expect(mockError).toHaveBeenCalledWith({
37
+ message:
38
+ "river not found, blank screen shown, screen_id=e1, entry_type=movie",
39
+ data: {
40
+ diagnostic: { code: "type-mapping" },
41
+ screen_id: "e1",
42
+ entry,
43
+ },
44
+ });
45
+ });
46
+
47
+ it("does not log for a screen that exists", () => {
48
+ render(<Wrapped screenId="A123" />);
49
+
50
+ expect(mockError).not.toHaveBeenCalled();
51
+ });
52
+ });
@@ -3,6 +3,9 @@ import * as React from "react";
3
3
  import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
4
4
  import { usePathname } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/usePathname";
5
5
  import { useRivers } from "@applicaster/zapp-react-native-utils/reactHooks";
6
+ import { subsystemLogger } from "@applicaster/zapp-react-native-utils/logger";
7
+
8
+ const logger = subsystemLogger("ui/screens", "RiverResolver");
6
9
 
7
10
  type Props = ZappUIComponentProps & {
8
11
  rivers: ZappRivers;
@@ -15,6 +18,28 @@ export function withRiver(Component: ZappComponent): ZappComponent {
15
18
  const river = useRivers()?.[screenId];
16
19
  const pathname = usePathname();
17
20
 
21
+ // Nothing is rendered for a screen that is not in the layout, so the log is the only trace of
22
+ // the blank screen: usually a tapped entry whose type leads to no screen.
23
+ React.useEffect(() => {
24
+ if (!river) {
25
+ // Without a river the screen data is the entry that was pushed.
26
+ const entry = otherProps.screenData as unknown as ZappEntry | undefined;
27
+
28
+ logger.error({
29
+ message: `river not found, blank screen shown, screen_id=${screenId}, entry_type=${entry?.type?.value}`,
30
+ data: {
31
+ // For X-Ray diagnostics: keep when the message is reworded. No `case`: all that is
32
+ // known here is that the screen is missing.
33
+ diagnostic: { code: "type-mapping" },
34
+ screen_id: screenId,
35
+ entry,
36
+ },
37
+ });
38
+ }
39
+ // Once per screen: the entry object is new on every render.
40
+ // eslint-disable-next-line @wogns3623/better-exhaustive-deps/exhaustive-deps
41
+ }, [river, screenId]);
42
+
18
43
  if (!river) {
19
44
  return null;
20
45
  }
@@ -177,7 +177,7 @@ describe("UrlFeedResolver", () => {
177
177
  });
178
178
  });
179
179
 
180
- it("should set up URL context key changes listener", () => {
180
+ it("keeps screen and refresh listeners without observing storage twice", () => {
181
181
  const props = {
182
182
  feedUrl: "https://example.com/feed",
183
183
  component: { ...componentRequiredKeys } as any,
@@ -193,10 +193,11 @@ describe("UrlFeedResolver", () => {
193
193
  expect(mockSubscribeForKeyChanges.mock.calls[0][0]).toMatchObject({
194
194
  url: "https://example.com/feed",
195
195
  callback: mockReloadData,
196
+ observeStorage: false,
196
197
  });
197
198
  });
198
199
 
199
- it("should set up pipesv2 URL listener from plugin if available", () => {
200
+ it("leaves plugin observation to the centralized feed observer", () => {
200
201
  const props = {
201
202
  feedUrl: "pipesv2://test-plugin/endpoint",
202
203
  component: { ...componentRequiredKeys } as any,
@@ -217,7 +218,7 @@ describe("UrlFeedResolver", () => {
217
218
 
218
219
  renderWithProviders(<UrlFeedResolver {...props} />);
219
220
 
220
- expect(mockAddDataSourceListener).toHaveBeenCalledWith(mockReloadData);
221
+ expect(mockAddDataSourceListener).not.toHaveBeenCalled();
221
222
  expect(mockSubscribeForKeyChanges).not.toHaveBeenCalled();
222
223
  });
223
224