@applicaster/zapp-react-native-ui-components 16.0.0-rc.3 → 16.0.0-rc.31

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 (58) hide show
  1. package/Components/BackgroundImage/BackgroundImage.android.tv.tsx +28 -0
  2. package/Components/BackgroundImage/BackgroundImage.ios.tv.tsx +24 -0
  3. package/Components/BackgroundImage/BackgroundImage.tsx +42 -0
  4. package/Components/BackgroundImage/index.ts +1 -0
  5. package/Components/CellRendererResolver/index.ts +2 -2
  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/FullWidthRow.tsx +38 -0
  22. package/Components/Layout/TV/ScreenContainer.tsx +5 -0
  23. package/Components/Layout/TV/__tests__/__snapshots__/index.test.tsx.snap +0 -1
  24. package/Components/Layout/TV/index.tsx +3 -4
  25. package/Components/Layout/TV/index.web.tsx +2 -3
  26. package/Components/MasterCell/DefaultComponents/ActionButton.tsx +16 -5
  27. package/Components/MasterCell/DefaultComponents/ButtonContainerView/index.tsx +1 -1
  28. package/Components/MasterCell/dataAdapter.ts +15 -5
  29. package/Components/MasterCell/index.tsx +30 -5
  30. package/Components/MasterCell/utils/__tests__/resolveColor.test.js +169 -132
  31. package/Components/MasterCell/utils/__tests__/resolveColorForProp.test.js +92 -0
  32. package/Components/MasterCell/utils/index.ts +85 -46
  33. package/Components/PlayerContainer/PlayerContainer.tsx +14 -10
  34. package/Components/PlayerContainer/__tests__/PlayerContainer.test.tsx +284 -0
  35. package/Components/River/ComponentsMap/ComponentsMap.tsx +2 -2
  36. package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +3 -15
  37. package/Components/Screen/TV/hooks/__tests__/useAfterPaint.test.ts +60 -0
  38. package/Components/Screen/TV/hooks/index.ts +2 -0
  39. package/Components/Screen/TV/hooks/useAfterPaint.ts +23 -0
  40. package/Components/Screen/TV/index.web.tsx +16 -7
  41. package/Components/Screen/index.tsx +8 -4
  42. package/Components/ScreenRevealManager/Overlay.tsx +34 -0
  43. package/Components/ScreenRevealManager/__tests__/Overlay.test.tsx +88 -0
  44. package/Components/ScreenRevealManager/withScreenRevealManager.tsx +8 -19
  45. package/Components/VideoLive/LiveImageManager.ts +56 -45
  46. package/Components/VideoLive/PlayerLiveImageComponent.tsx +4 -2
  47. package/Components/VideoModal/utils.ts +6 -1
  48. package/Components/ZappFrameworkComponents/BarView/BarView.tsx +12 -5
  49. package/Components/ZappFrameworkComponents/BarView/__tests__/BarView.test.tsx +2 -2
  50. package/Contexts/CachedDimensionsContext/__tests__/index.test.ts +154 -0
  51. package/Contexts/CachedDimensionsContext/index.ts +17 -2
  52. package/Helpers/ComponentCellSelectionHelper/index.js +0 -6
  53. package/Helpers/index.js +7 -40
  54. package/package.json +5 -5
  55. package/Components/Layout/TV/LayoutBackground.tsx +0 -31
  56. package/Components/Screen/utils.ts +0 -16
  57. package/Helpers/Analytics/index.js +0 -95
  58. /package/Components/MasterCell/DefaultComponents/ButtonContainerView/{index.tv.android.tsx → index.android.tv.tsx} +0 -0
@@ -1,6 +1,7 @@
1
1
  import { create, useStore } from "zustand";
2
2
  import { produce } from "immer";
3
3
  import { useCallback, useMemo } from "react";
4
+ import { last } from "@applicaster/zapp-react-native-utils/utils";
4
5
 
5
6
  type Dimensions = {
6
7
  width: Option<number>;
@@ -10,14 +11,17 @@ type Dimensions = {
10
11
  type DimensionsState = {
11
12
  dimensions: Record<string, Dimensions>;
12
13
  setCachedDimensions: (id: string, dimensions: Dimensions) => void;
14
+ ids: string[];
13
15
  };
14
16
 
15
17
  const dimensionsStore = create<DimensionsState>((set) => ({
16
18
  dimensions: {},
19
+ ids: [],
17
20
  setCachedDimensions: (id, dimensions) =>
18
21
  set(
19
22
  produce((draft) => {
20
23
  draft.dimensions[id] = dimensions;
24
+ draft.ids.push(id);
21
25
  })
22
26
  ),
23
27
  }));
@@ -28,7 +32,7 @@ const initialDimensions = () => ({
28
32
  });
29
33
 
30
34
  export const useCachedDimensions = (id: string) => {
31
- const { dimensions, setCachedDimensions } = useStore(
35
+ const { dimensions, setCachedDimensions, ids } = useStore(
32
36
  dimensionsStore
33
37
  ) as DimensionsState;
34
38
 
@@ -40,11 +44,22 @@ export const useCachedDimensions = (id: string) => {
40
44
  setCachedDimensions(id, newDimensions);
41
45
  }, []);
42
46
 
47
+ const getLastCachedDimensions = useCallback(() => {
48
+ const previousId = last(ids);
49
+
50
+ if (!previousId) {
51
+ return undefined;
52
+ }
53
+
54
+ return dimensions[previousId];
55
+ }, [dimensions, ids]);
56
+
43
57
  return useMemo(
44
58
  () => ({
45
59
  getCachedDimensions,
46
60
  setCachedDimensions: handleSetCachedDimensions,
61
+ getLastCachedDimensions,
47
62
  }),
48
- [getCachedDimensions, handleSetCachedDimensions]
63
+ [getCachedDimensions, handleSetCachedDimensions, getLastCachedDimensions]
49
64
  );
50
65
  };
@@ -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.3",
3
+ "version": "16.0.0-rc.31",
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.3",
32
- "@applicaster/zapp-react-native-bridge": "16.0.0-rc.3",
33
- "@applicaster/zapp-react-native-redux": "16.0.0-rc.3",
34
- "@applicaster/zapp-react-native-utils": "16.0.0-rc.3",
31
+ "@applicaster/applicaster-types": "16.0.0-rc.31",
32
+ "@applicaster/zapp-react-native-bridge": "16.0.0-rc.31",
33
+ "@applicaster/zapp-react-native-redux": "16.0.0-rc.31",
34
+ "@applicaster/zapp-react-native-utils": "16.0.0-rc.31",
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,16 +0,0 @@
1
- import { map, split, replace, compose, trim } from "ramda";
2
-
3
- function colorIsNotTransparent(color) {
4
- const layers = compose(
5
- map(trim),
6
- split(","),
7
- replace(")", ""),
8
- replace("rgba(", "")
9
- )(color);
10
-
11
- return Number(layers?.[3]) > 0;
12
- }
13
-
14
- export function isValidColor(string) {
15
- return string && string !== "transparent" && colorIsNotTransparent(string);
16
- }
@@ -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
- }