@applicaster/zapp-react-native-utils 12.0.0-alpha.7539319320 → 12.0.0-alpha.7725319213

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.
@@ -77,7 +77,7 @@ export class Player {
77
77
  audioTracks: [],
78
78
  audioTrackId: null,
79
79
  textTrackId: null,
80
- },
80
+ }
81
81
  };
82
82
 
83
83
  this.playerId = props.playerId || "error, no player id";
@@ -685,4 +685,6 @@ export class Player {
685
685
  isFullScreenSupported(): boolean {
686
686
  return true;
687
687
  }
688
+
689
+ public supportsNativeControls = ():boolean => false
688
690
  }
@@ -1,17 +1,29 @@
1
1
  import { appStore } from "@applicaster/zapp-react-native-redux/AppStore";
2
2
  import { findPluginByIdentifier } from "@applicaster/zapp-react-native-utils/pluginUtils";
3
3
  import { Player } from "./player";
4
+ import { PlayerRole } from "./conts";
4
5
 
5
6
  type PlayerFactoryItem = {
6
7
  Component: any;
7
8
  controller: Player;
8
9
  };
9
10
 
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
+ }
21
+
10
22
  interface PlayerConstructor {
11
23
  new (params: any): Player;
12
24
  }
13
25
 
14
- export const playerFactory = (config: any): PlayerFactoryItem | null => {
26
+ export const playerFactory = (config: PlayerFactoryProps): PlayerFactoryItem | null => {
15
27
  const IDENTIFIER = config?.playerPluginId;
16
28
 
17
29
  if (!IDENTIFIER) {
@@ -5,6 +5,7 @@ import { Player } from "./player";
5
5
  import { findNodeHandle, NativeModules } from "react-native";
6
6
  import { isApplePlatform } from "../../reactUtils";
7
7
  import { PlayerRole } from "./conts";
8
+ import { toBooleanWithDefaultFalse } from "../../booleanUtils";
8
9
 
9
10
  const RNPlayerManager = {
10
11
  QuickBrickPlayerPlugin: isApplePlatform()
@@ -265,4 +266,7 @@ export class PlayerNative extends Player {
265
266
 
266
267
  return !(isFullScreenAudioPlayer && this.isAudioItem());
267
268
  };
269
+
270
+ supportsNativeControls = (): boolean =>
271
+ toBooleanWithDefaultFalse(this.getConfig()?.["supports_native_controls"]);
268
272
  }
@@ -343,6 +343,19 @@ export const ifElseFocused = R.curry(
343
343
  state === "focused" ? focusedValue : defaultValue
344
344
  );
345
345
 
346
+ export const ifElseSelected = R.curry(
347
+ (state: string, selectedValue, defaultValue) => {
348
+ switch (state) {
349
+ case "selected":
350
+ return selectedValue;
351
+ case "focused_selected":
352
+ return selectedValue;
353
+ default:
354
+ return defaultValue;
355
+ }
356
+ }
357
+ );
358
+
346
359
  /**
347
360
  * Map textAlign values to their corresponding alignSelf values
348
361
  * This is so that we could use the same field for both properties
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-utils",
3
- "version": "12.0.0-alpha.7539319320",
3
+ "version": "12.0.0-alpha.7725319213",
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.7539319320",
31
+ "@applicaster/applicaster-types": "12.0.0-alpha.7725319213",
32
32
  "buffer": "^5.2.1",
33
33
  "camelize": "^1.0.0",
34
34
  "create-react-context": "^0.2.3",
@@ -68,11 +68,13 @@ export function findComponentByType({
68
68
  * Returns the plugin for a given identifier, if found
69
69
  * @param identifier of the plugin to look for
70
70
  * @param plugins map of the available plugins
71
+ * @param doNotWarn if set to true, will not log a warning if plugin is not found
71
72
  * @return whole plugin if found, undefined otherwise
72
73
  */
73
74
  export function findPluginByIdentifier(
74
75
  identifier: string,
75
- plugins: (QuickBrickPlugin | ZappPlugin | Plugin)[]
76
+ plugins: (QuickBrickPlugin | ZappPlugin | Plugin)[],
77
+ doNotWarn: boolean = false
76
78
  ): (QuickBrickPlugin | ZappPlugin | Plugin) | undefined {
77
79
  if (!identifier) {
78
80
  return undefined;
@@ -84,10 +86,12 @@ export function findPluginByIdentifier(
84
86
  )(plugins);
85
87
 
86
88
  if (!plugin && identifier !== "river" && identifier !== "hooks") {
87
- pluginUtilsLogger.warning({
88
- message: `Could not find plugin for identifier ${identifier}`,
89
- data: { identifier },
90
- });
89
+ if (!doNotWarn) {
90
+ pluginUtilsLogger.warning({
91
+ message: `Could not find plugin for identifier ${identifier}`,
92
+ data: { identifier },
93
+ });
94
+ }
91
95
  }
92
96
 
93
97
  return plugin;
@@ -1,6 +1,7 @@
1
1
  import * as React from "react";
2
2
  import { cleanup, renderHook } from "@testing-library/react-hooks";
3
3
  import { CellTapContext } from "@applicaster/zapp-react-native-ui-components/Contexts/CellTapContext";
4
+ import { waitFor } from "@testing-library/react-native";
4
5
 
5
6
  const navigator = {
6
7
  getPathname: () => "pathnameMock",
@@ -64,13 +65,16 @@ describe("useCellClick", () => {
64
65
  cleanup();
65
66
  });
66
67
 
67
- it("runs onCellTap", () => {
68
+ it("runs onCellTap", async () => {
68
69
  const { result } = renderHook(() => useCellClick(mockProps), { wrapper });
69
70
  const useCellClickHook = result.current;
70
71
 
71
72
  useCellClickHook();
72
73
 
73
- expect(onCellTap).toHaveBeenCalled();
74
+ await waitFor(() => {
75
+ expect(onCellTap).toHaveBeenCalled();
76
+ });
77
+
74
78
  cleanup();
75
79
  });
76
80
  });
@@ -53,7 +53,7 @@ export const useCellClick = (props: Props) => {
53
53
  );
54
54
 
55
55
  const onPress = React.useCallback(
56
- (_item?: ZappEntry | any, _index?: number) => {
56
+ async (_item?: ZappEntry | any, _index?: number) => {
57
57
  // Making sure we are not getting GestureResponderEvent in here.
58
58
  const isZappEntry = _item?.id && _item?.type;
59
59
  const selectedItem = isZappEntry ? _item : props.item;
@@ -70,7 +70,7 @@ export const useCellClick = (props: Props) => {
70
70
  logOnPress(selectedItem, pathname, component, onCellTap);
71
71
 
72
72
  if (selectedItem) {
73
- actionExecutor?.handleEntryActions(selectedItem);
73
+ await actionExecutor?.handleEntryActions(selectedItem);
74
74
  }
75
75
 
76
76
  if (selectedItem?.type?.value === "action") {
@@ -39,8 +39,6 @@ export const useFeedLoader = ({
39
39
  mapping,
40
40
  pipesOptions = {},
41
41
  }: Props): FeedLoaderResponse => {
42
- console.log("debug_2", "useFeedLoader", { feedUrl, mapping, pipesOptions });
43
-
44
42
  useEffect(() => {
45
43
  if (!feedUrl) {
46
44
  logger.warning({
@@ -1,6 +1,7 @@
1
1
  import React from "react";
2
2
  import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
3
3
  import * as R from "ramda";
4
+ import { appStore } from "@applicaster/zapp-react-native-redux/AppStore";
4
5
 
5
6
  export function getTargetScreenData(
6
7
  entry: ZappEntry,
@@ -35,6 +36,12 @@ export function getTargetScreenData(
35
36
  return rivers?.[screenId];
36
37
  }
37
38
 
39
+ export function getTargetScreenDataFromEntry(entry: ZappEntry): ZappRiver {
40
+ const { rivers, contentTypes } = appStore.get(["rivers", "contentTypes"]);
41
+
42
+ return getTargetScreenData(entry, rivers, contentTypes);
43
+ }
44
+
38
45
  export const useTargetScreenData = (entry: ZappEntry) => {
39
46
  const { rivers, contentTypes } = usePickFromState(["rivers", "contentTypes"]);
40
47
 
@@ -2,9 +2,6 @@ import * as R from "ramda";
2
2
  import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
3
3
  import { useMemoizedIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks/device";
4
4
 
5
- import { LogBox } from "react-native";
6
- LogBox.ignoreAllLogs();
7
-
8
5
  import { useMobileOrientationEffect } from "./useMobileOrientationEffect";
9
6
  import { noop } from "./utils";
10
7