@applicaster/zapp-react-native-utils 12.0.0-rc.31 → 12.0.0-rc.33

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.
@@ -9,21 +9,23 @@ type PlayerFactoryItem = {
9
9
  };
10
10
 
11
11
  type PlayerFactoryProps = {
12
- player: any,
13
- playerId: string,
14
- autoplay: boolean,
15
- entry: ZappEntry,
16
- muted: boolean,
17
- playerPluginId: string,
18
- screenConfig: Record<string, any>,
19
- playerRole: PlayerRole,
20
- }
12
+ player: any;
13
+ playerId: string;
14
+ autoplay: boolean;
15
+ entry: ZappEntry;
16
+ muted: boolean;
17
+ playerPluginId: string;
18
+ screenConfig: Record<string, any>;
19
+ playerRole: PlayerRole;
20
+ };
21
21
 
22
22
  interface PlayerConstructor {
23
23
  new (params: any): Player;
24
24
  }
25
25
 
26
- export const playerFactory = (config: PlayerFactoryProps): PlayerFactoryItem | null => {
26
+ export const playerFactory = (
27
+ config: PlayerFactoryProps
28
+ ): PlayerFactoryItem | null => {
27
29
  const IDENTIFIER = config?.playerPluginId;
28
30
 
29
31
  if (!IDENTIFIER) {
@@ -22,7 +22,11 @@ const {
22
22
  const { buttonKey } = require("./buttons");
23
23
  const { tvBadges } = require("./tvBadges");
24
24
  const { mobileProgressBar, tvProgressBar } = require("./progressBar");
25
- const { secondaryImage, getUpdatedSecondaryImageKeys } = require("./secondaryImage");
25
+
26
+ const {
27
+ secondaryImage,
28
+ getUpdatedSecondaryImageKeys,
29
+ } = require("./secondaryImage");
26
30
 
27
31
  module.exports = {
28
32
  fontKey,
@@ -132,29 +132,32 @@ function secondaryImage({
132
132
 
133
133
  const POSITION_OVER_IMAGE = toSnakeCase(position_over_image);
134
134
 
135
- const getUpdatedSecondaryImageKeys = (secondaryImageManifest) => secondaryImageManifest.fields.reduce((acc, item) => {
136
- const key = item.key;
135
+ const getUpdatedSecondaryImageKeys = (secondaryImageManifest) =>
136
+ secondaryImageManifest.fields.reduce((acc, item) => {
137
+ const key = item.key;
137
138
 
138
- const conditionalFields = (item.conditional_fields || []).map((field) => field.key);
139
+ const conditionalFields = (item.conditional_fields || []).map(
140
+ (field) => field.key
141
+ );
139
142
 
140
- const updatedConditionalFields = conditionalFields.reduce((acc, field) => {
141
- const updatedKey = field.replace("secondary_image_", "nested_image_");
143
+ const updatedConditionalFields = conditionalFields.reduce((acc, field) => {
144
+ const updatedKey = field.replace("secondary_image_", "nested_image_");
145
+
146
+ return {
147
+ ...acc,
148
+ [updatedKey]: field,
149
+ };
150
+ }, {});
151
+
152
+ const updatedKey = key.replace("secondary_image_", "nested_image_");
142
153
 
143
154
  return {
144
155
  ...acc,
145
- [updatedKey]: field,
156
+ ...updatedConditionalFields,
157
+ [updatedKey]: key,
146
158
  };
147
159
  }, {});
148
160
 
149
- const updatedKey = key.replace("secondary_image_", "nested_image_");
150
-
151
- return {
152
- ...acc,
153
- ...updatedConditionalFields,
154
- [updatedKey]: key,
155
- };
156
- }, {});
157
-
158
161
  module.exports = {
159
162
  secondaryImage,
160
163
  getUpdatedSecondaryImageKeys,
@@ -114,7 +114,11 @@ export function getNavigationProps({
114
114
  } | null {
115
115
  const { activeRiver } = navigator;
116
116
  const { navigations, id: selected, home } = activeRiver; // use useRiver hook instead
117
- const navigation = R.find(R.propEq("category", category), navigations);
117
+
118
+ const navigation: ZappNavigation = R.find(
119
+ R.propEq("category", category),
120
+ navigations
121
+ );
118
122
 
119
123
  if (!navigation) {
120
124
  return null;
@@ -127,9 +131,9 @@ export function getNavigationProps({
127
131
  title,
128
132
  home,
129
133
  styles,
130
- assets,
131
- nav_items,
132
- rules,
134
+ assets: assets as ZappNavBarAssets,
135
+ nav_items: nav_items as any as NavBarItem[],
136
+ rules: rules as any as ZappNavBarRules,
133
137
  };
134
138
  }
135
139
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-utils",
3
- "version": "12.0.0-rc.31",
3
+ "version": "12.0.0-rc.33",
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-rc.31",
31
+ "@applicaster/applicaster-types": "12.0.0-rc.33",
32
32
  "buffer": "^5.2.1",
33
33
  "camelize": "^1.0.0",
34
34
  "create-react-context": "^0.2.3",
@@ -0,0 +1,4 @@
1
+ export const useNavigation = jest.fn(() => ({
2
+ data: {},
3
+ currentRoute: "someRoute",
4
+ }));
@@ -45,10 +45,19 @@ const videoItem = {
45
45
  type: { value: "video" },
46
46
  };
47
47
 
48
+ const mockGetStackForPathname = jest.fn().mockReturnValue(homeStack);
49
+
48
50
  const mainStackNavigator = {
49
- getStackForPathname: jest.fn().mockReturnValue(homeStack),
51
+ getStackForPathname: mockGetStackForPathname,
50
52
  getModalState: () => {},
51
53
  videoModalState: {},
54
+ canGoBack: jest.fn(),
55
+ };
56
+
57
+ const _createWrapper = (Wrapper, props) => {
58
+ return function CreatedWrapper({ children }: any) {
59
+ return <Wrapper {...props}>{children}</Wrapper>;
60
+ };
52
61
  };
53
62
 
54
63
  const videoModalNavigator = {
@@ -85,10 +94,16 @@ const store = mockStore({
85
94
  contentTypes,
86
95
  });
87
96
 
88
- const mainStackWrapper = ({ children }) => (
97
+ const mainStackWrapper = ({
98
+ children,
99
+ navigator = {},
100
+ pathname = homeStack.route,
101
+ }) => (
89
102
  <Provider store={store}>
90
- <NavigationContext.Provider value={mainStackNavigator}>
91
- <PathnameContext.Provider value={homeStack.route}>
103
+ <NavigationContext.Provider
104
+ value={{ ...mainStackNavigator, ...navigator, currentRoute: pathname }}
105
+ >
106
+ <PathnameContext.Provider value={pathname}>
92
107
  {children}
93
108
  </PathnameContext.Provider>
94
109
  </NavigationContext.Provider>
@@ -1,7 +1,7 @@
1
1
  // @ts-ignore
2
2
  import { View } from "react-native";
3
3
 
4
- const mockData: NavigationScreenData = {
4
+ const mockData = {
5
5
  screen: {
6
6
  id: "screen-id",
7
7
  name: "screen",
@@ -40,3 +40,5 @@ const mockData: NavigationScreenData = {
40
40
  };
41
41
 
42
42
  export const useScreenContext = jest.fn().mockReturnValue(mockData);
43
+
44
+ export const useNavbarState = () => ({ visible: true });
@@ -2,7 +2,7 @@ import { useContext, useMemo } from "react";
2
2
 
3
3
  import { useModalNavigationContext } from "@applicaster/zapp-react-native-ui-components/Contexts/ModalNavigationContext";
4
4
  import { useNestedNavigationContext } from "@applicaster/zapp-react-native-ui-components/Contexts/NestedNavigationContext";
5
- import { useNavigation } from "../navigation";
5
+ import { useNavigation } from "../navigation/useNavigation";
6
6
 
7
7
  import { ScreenContext } from "@applicaster/zapp-react-native-ui-components/Contexts/ScreenContext";
8
8
 
@@ -13,10 +13,7 @@ export const useListenEventBusEvent = (
13
13
  // TODO: remove after implementing ReactNativeEventBusBridge on iOS
14
14
  if (Platform.OS === "android") {
15
15
  // subscribe to DeviceEventEmitter using subsciption ID
16
- const sub = DeviceEventEmitter.addListener(
17
- subscriptionID,
18
- handler
19
- );
16
+ const sub = DeviceEventEmitter.addListener(subscriptionID, handler);
20
17
 
21
18
  // ask native to start routing these events to RN
22
19
  ReactNativeEventBusBridge.subscribe(subscriptionID, { [source]: events });
@@ -6,8 +6,10 @@ import { View } from "react-native";
6
6
  import { Provider } from "react-redux";
7
7
  import thunk from "redux-thunk";
8
8
  import configureStore from "redux-mock-store";
9
+ import { SafeAreaProvider } from "react-native-safe-area-context";
9
10
 
10
11
  import { render } from "@testing-library/react-native";
12
+ import { AnalyticsProvider } from "../analyticsUtils";
11
13
 
12
14
  /**
13
15
  * Function to be used in tandem with enzyme findWhere(node => node.prop('testID') === 'yourID')
@@ -69,9 +71,20 @@ const initialState = {
69
71
  };
70
72
 
71
73
  export const WrappedWithProviders = ({ children, store = {} }: any) => {
72
- const _store = configureStore([thunk])({ ...initialState, store });
74
+ const _store = configureStore([thunk])({ ...initialState, ...store });
73
75
 
74
- return <Provider store={_store}>{children}</Provider>;
76
+ return (
77
+ <SafeAreaProvider
78
+ initialMetrics={{
79
+ insets: { top: 0, left: 0, right: 0, bottom: 0 },
80
+ frame: { x: 0, y: 0, width: 0, height: 0 },
81
+ }}
82
+ >
83
+ <Provider store={_store}>
84
+ <AnalyticsProvider>{children}</AnalyticsProvider>
85
+ </Provider>
86
+ </SafeAreaProvider>
87
+ );
75
88
  };
76
89
 
77
90
  /**