@applicaster/zapp-react-native-utils 13.0.0-rc.15 → 13.0.0-rc.17

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 (65) hide show
  1. package/actionsExecutor/ActionExecutorContext.tsx +12 -1
  2. package/alertUtils/alert.ts +148 -0
  3. package/alertUtils/index.ts +1 -148
  4. package/analyticsUtils/AnalyticPlayerListener.ts +18 -1
  5. package/analyticsUtils/__tests__/__snapshots__/analyticsManagerNoModule.test.js.snap +9 -9
  6. package/analyticsUtils/helpers/hooks.ts +1 -1
  7. package/appUtils/HooksManager/__tests__/__snapshots__/hook.test.js.snap +7 -7
  8. package/appUtils/HooksManager/__tests__/__snapshots__/hooksManager.test.js.snap +186 -186
  9. package/appUtils/contextKeysManager/contextResolver.ts +73 -0
  10. package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +6 -6
  11. package/appUtils/focusManager/index.ts +90 -63
  12. package/appUtils/focusManager/treeDataStructure/Tree/index.js +23 -0
  13. package/appUtils/focusManager/utils/enums.ts +4 -0
  14. package/appUtils/keyCodes/__tests__/__snapshots__/keyCodes.test.js.snap +2 -2
  15. package/appUtils/keyCodes/__tests__/keyCodes.test.js +1 -1
  16. package/appUtils/keyCodes/keys/keysByPlatform.ts +4 -0
  17. package/appUtils/keyInputHandler/KeyInputHandler.ts +68 -0
  18. package/appUtils/orientationHelper.ts +1 -1
  19. package/appUtils/playerManager/player.ts +17 -5
  20. package/appUtils/playerManager/playerNative.ts +3 -2
  21. package/appUtils/playerManager/usePlayerControllerSetup.tsx +3 -3
  22. package/arrayUtils/__tests__/__snapshots__/arrayUtils.test.ts.snap +4 -4
  23. package/functionUtils/__tests__/__snapshots__/functionUtils.test.js.snap +4 -4
  24. package/manifestUtils/__tests__/createConfig.test.js +18 -16
  25. package/navigationUtils/__tests__/__snapshots__/navigationUtils.test.js.snap +6 -6
  26. package/navigationUtils/__tests__/itemTypes.test.js +2 -2
  27. package/navigationUtils/__tests__/navigationUtils.test.js +2 -2
  28. package/package.json +3 -2
  29. package/reactHooks/autoscrolling/__tests__/useTrackCurrentAutoScrollingElement.test.ts +1 -1
  30. package/reactHooks/autoscrolling/__tests__/useTrackedView.test.tsx +1 -1
  31. package/reactHooks/cell-click/__tests__/index.test.js +5 -2
  32. package/reactHooks/feed/__tests__/useBuildPipesUrl.test.tsx +4 -4
  33. package/reactHooks/feed/__tests__/useFeedLoader.test.tsx +10 -11
  34. package/reactHooks/feed/usePipesCacheReset.ts +5 -5
  35. package/reactHooks/flatList/__tests__/index.test.tsx +30 -21
  36. package/reactHooks/layout/__tests__/index.test.tsx +10 -10
  37. package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.native.test.js +14 -28
  38. package/reactHooks/navigation/__tests__/index.test.tsx +0 -4
  39. package/reactHooks/navigation/index.ts +22 -214
  40. package/reactHooks/navigation/useGetBottomTabBarHeight.ts +12 -0
  41. package/reactHooks/navigation/useGetNavBarTopBorderWidth.ts +14 -0
  42. package/reactHooks/navigation/useGetTabBarHeight.ts +12 -0
  43. package/reactHooks/navigation/useIsScreenActive.ts +17 -0
  44. package/reactHooks/navigation/useNavigationPluginData.ts +15 -0
  45. package/reactHooks/navigation/useNavigationType.ts +15 -0
  46. package/reactHooks/navigation/usePathname.ts +4 -0
  47. package/reactHooks/navigation/useRoute.ts +100 -0
  48. package/reactHooks/navigation/useUniqueRouteSuffix.ts +41 -0
  49. package/reactHooks/player/TVSeekControlller/ISeekController.ts +32 -0
  50. package/reactHooks/player/TVSeekControlller/LongPressSeekController.ts +71 -0
  51. package/reactHooks/player/TVSeekControlller/TVSeekController.ts +258 -0
  52. package/reactHooks/player/TVSeekControlller/TapSeekController.ts +53 -0
  53. package/reactHooks/player/__tests__/{useAutoSeek.test.tsx → useAutoSeek._test.tsx} +2 -3
  54. package/reactHooks/player/const.ts +0 -4
  55. package/reactHooks/player/index.ts +0 -6
  56. package/reactUtils/__tests__/reactUtils.test.js +10 -28
  57. package/reactUtils/createContext/__tests__/__snapshots__/helpers.test.js.snap +19 -19
  58. package/reactUtils/createContext/__tests__/__snapshots__/index.test.js.snap +2 -2
  59. package/reactUtils/createContext/__tests__/__snapshots__/provider.test.js.snap +3 -3
  60. package/reactUtils/createContext/__tests__/helpers.test.js +8 -8
  61. package/theme/__mocks__/index.ts +4 -0
  62. package/reactHooks/player/useAutoSeek.tsx +0 -87
  63. package/reactHooks/player/useSeek.tsx +0 -66
  64. package/reactHooks/player/useTapSeek.tsx +0 -58
  65. /package/reactHooks/player/__tests__/{useTapSeek.test.ts → useTapSeek._test.ts} +0 -0
@@ -13,6 +13,10 @@ import { createCloudEvent, sendCloudEvent } from "../cloudEventsUtils";
13
13
  import { createLogger } from "../logger";
14
14
  import { StorageMultiSelectProvider } from "@applicaster/zapp-react-native-bridge/ZappStorage/StorageMultiSelectProvider";
15
15
  import { ACTIVE_LAYOUT_ID_STORAGE_KEY } from "@applicaster/quick-brick-core/App/remoteContextReloader/consts";
16
+ import {
17
+ EntryResolver,
18
+ resolveObjectValues,
19
+ } from "../appUtils/contextKeysManager/contextResolver";
16
20
 
17
21
  const { log_error, log_info } = createLogger({
18
22
  subsystem: "ActionExecutorContext",
@@ -84,9 +88,16 @@ const prepareDefaultActions = (actionExecutor) => {
84
88
  try {
85
89
  const options = action.options;
86
90
 
91
+ const entryResolver = new EntryResolver(entry);
92
+
93
+ const data =
94
+ options?.data && options.inflateData
95
+ ? await resolveObjectValues(options.data, { entry: entryResolver })
96
+ : options?.data || entry;
97
+
87
98
  const cloudEvent = await createCloudEvent({
88
99
  type: options.type || "com.applicaster.selector.action.v1",
89
- data: options.data || entry,
100
+ data,
90
101
  subject: options.subject || entry?.id,
91
102
  });
92
103
 
@@ -0,0 +1,148 @@
1
+ import { Alert } from "react-native";
2
+ import { isWeb } from "@applicaster/zapp-react-native-utils/reactUtils";
3
+ import { confirmationDialogStore } from "@applicaster/zapp-react-native-ui-components/Contexts/ConfirmDialogState";
4
+
5
+ // #region "Alert Dialog"
6
+
7
+ const globalAny: any = global;
8
+
9
+ const showWebAlertDialog = ({ message, completion }: AlertWebDialog) => {
10
+ globalAny?.alert?.(message);
11
+ completion?.();
12
+ };
13
+
14
+ const showNativeAlertDialog = ({
15
+ title,
16
+ message,
17
+ okButtonText,
18
+ completion,
19
+ }: AlertDialogType) => {
20
+ Alert.alert(title, message, [
21
+ {
22
+ text: okButtonText,
23
+ onPress: completion,
24
+ },
25
+ ]);
26
+ };
27
+
28
+ export const showAlertDialog = ({
29
+ title,
30
+ message,
31
+ okButtonText,
32
+ completion,
33
+ }: AlertDialogType) => {
34
+ if (isWeb()) {
35
+ showWebAlertDialog({ message, completion });
36
+ } else {
37
+ showNativeAlertDialog({
38
+ title,
39
+ message,
40
+ okButtonText,
41
+ completion,
42
+ });
43
+ }
44
+ };
45
+
46
+ // #endregion "Alert Dialog"
47
+
48
+ // #region "Confirmation Dialog"
49
+
50
+ const showWebDialog = ({
51
+ message,
52
+ confirmCompletion,
53
+ cancelCompletion,
54
+ }: WebConfirmationDialog) => {
55
+ const isConfirmed = globalAny?.confirm?.(message);
56
+
57
+ if (isConfirmed) {
58
+ confirmCompletion?.();
59
+ } else {
60
+ cancelCompletion?.();
61
+ }
62
+ };
63
+
64
+ const showNativeDialog = ({
65
+ title,
66
+ message,
67
+ okButtonText,
68
+ cancelButtonText,
69
+ confirmCompletion,
70
+ cancelCompletion,
71
+ }: ConfirmationDialog) => {
72
+ Alert.alert(title, message, [
73
+ {
74
+ text: cancelButtonText,
75
+ onPress: cancelCompletion,
76
+ },
77
+ {
78
+ text: okButtonText,
79
+ style: "destructive",
80
+ onPress: confirmCompletion,
81
+ },
82
+ ]);
83
+ };
84
+
85
+ const handleCustomDialog = (data) => {
86
+ const {
87
+ showDialog,
88
+ hideDialog,
89
+ setConfirmAction,
90
+ setCancelAction,
91
+ setMessages,
92
+ } = confirmationDialogStore.getState();
93
+
94
+ setMessages(data.messages);
95
+
96
+ if (data?.cancelCompletion) {
97
+ setCancelAction(() => {
98
+ data.cancelCompletion();
99
+ hideDialog();
100
+ });
101
+ }
102
+
103
+ if (data?.confirmCompletion) {
104
+ setConfirmAction(() => {
105
+ data.confirmCompletion();
106
+ hideDialog();
107
+ });
108
+ }
109
+
110
+ showDialog();
111
+ };
112
+
113
+ export const showConfirmationDialog = ({
114
+ title,
115
+ message,
116
+ okButtonText,
117
+ cancelButtonText,
118
+ confirmCompletion,
119
+ cancelCompletion,
120
+ }: CustomConfirmationDialog): void => {
121
+ if (isWeb()) {
122
+ if (cancelCompletion) {
123
+ handleCustomDialog({
124
+ messages: {
125
+ title,
126
+ message,
127
+ okButtonText,
128
+ cancelButtonText,
129
+ },
130
+ confirmCompletion,
131
+ cancelCompletion,
132
+ });
133
+ } else {
134
+ showWebDialog({ message, confirmCompletion, cancelCompletion });
135
+ }
136
+ } else {
137
+ showNativeDialog({
138
+ title,
139
+ message,
140
+ okButtonText,
141
+ cancelButtonText,
142
+ confirmCompletion,
143
+ cancelCompletion,
144
+ });
145
+ }
146
+ };
147
+
148
+ // #endregion "Confirmation Dialog"
@@ -1,148 +1 @@
1
- import { Alert } from "react-native";
2
- import { isWeb } from "@applicaster/zapp-react-native-utils/reactUtils";
3
- import { confirmationDialogStore } from "@applicaster/zapp-react-native-ui-components/Contexts/ConfirmDialogState";
4
-
5
- // #region "Alert Dialog"
6
-
7
- const globalAny: any = global;
8
-
9
- const showWebAlertDialog = ({ message, completion }: AlertWebDialog) => {
10
- globalAny?.alert?.(message);
11
- completion?.();
12
- };
13
-
14
- const showNativeAlertDialog = ({
15
- title,
16
- message,
17
- okButtonText,
18
- completion,
19
- }: AlertDialogType) => {
20
- Alert.alert(title, message, [
21
- {
22
- text: okButtonText,
23
- onPress: completion,
24
- },
25
- ]);
26
- };
27
-
28
- export const showAlertDialog = ({
29
- title,
30
- message,
31
- okButtonText,
32
- completion,
33
- }: AlertDialogType) => {
34
- if (isWeb()) {
35
- showWebAlertDialog({ message, completion });
36
- } else {
37
- showNativeAlertDialog({
38
- title,
39
- message,
40
- okButtonText,
41
- completion,
42
- });
43
- }
44
- };
45
-
46
- // #endregion "Alert Dialog"
47
-
48
- // #region "Confirmation Dialog"
49
-
50
- const showWebDialog = ({
51
- message,
52
- confirmCompletion,
53
- cancelCompletion,
54
- }: WebConfirmationDialog) => {
55
- const isConfirmed = globalAny?.confirm?.(message);
56
-
57
- if (isConfirmed) {
58
- confirmCompletion?.();
59
- } else {
60
- cancelCompletion?.();
61
- }
62
- };
63
-
64
- const showNativeDialog = ({
65
- title,
66
- message,
67
- okButtonText,
68
- cancelButtonText,
69
- confirmCompletion,
70
- cancelCompletion,
71
- }: ConfirmationDialog) => {
72
- Alert.alert(title, message, [
73
- {
74
- text: cancelButtonText,
75
- onPress: cancelCompletion,
76
- },
77
- {
78
- text: okButtonText,
79
- style: "destructive",
80
- onPress: confirmCompletion,
81
- },
82
- ]);
83
- };
84
-
85
- const handleCustomDialog = (data) => {
86
- const {
87
- showDialog,
88
- hideDialog,
89
- setConfirmAction,
90
- setCancelAction,
91
- setMessages,
92
- } = confirmationDialogStore.getState();
93
-
94
- setMessages(data.messages);
95
-
96
- if (data?.cancelCompletion) {
97
- setCancelAction(() => {
98
- data.cancelCompletion();
99
- hideDialog();
100
- });
101
- }
102
-
103
- if (data?.confirmCompletion) {
104
- setConfirmAction(() => {
105
- data.confirmCompletion();
106
- hideDialog();
107
- });
108
- }
109
-
110
- showDialog();
111
- };
112
-
113
- export const showConfirmationDialog = ({
114
- title,
115
- message,
116
- okButtonText,
117
- cancelButtonText,
118
- confirmCompletion,
119
- cancelCompletion,
120
- }: CustomConfirmationDialog): void => {
121
- if (isWeb()) {
122
- if (cancelCompletion) {
123
- handleCustomDialog({
124
- messages: {
125
- title,
126
- message,
127
- okButtonText,
128
- cancelButtonText,
129
- },
130
- confirmCompletion,
131
- cancelCompletion,
132
- });
133
- } else {
134
- showWebDialog({ message, confirmCompletion, cancelCompletion });
135
- }
136
- } else {
137
- showNativeDialog({
138
- title,
139
- message,
140
- okButtonText,
141
- cancelButtonText,
142
- confirmCompletion,
143
- cancelCompletion,
144
- });
145
- }
146
- };
147
-
148
- // #endregion "Confirmation Dialog"
1
+ export { showAlertDialog, showConfirmationDialog } from "./alert";
@@ -14,7 +14,7 @@ export class AnalyticPlayerListener
14
14
  static analyticsListenerID = "analytics-listener";
15
15
  private analyticsTracker: PlayerAnalyticsTracker;
16
16
  private player: Player;
17
-
17
+ private isSeeking: boolean = false;
18
18
  private onVideoLoadCalled; // android only
19
19
 
20
20
  constructor(props: Props) {
@@ -40,10 +40,27 @@ export class AnalyticPlayerListener
40
40
  };
41
41
 
42
42
  onPlayerPause = (event) => {
43
+ if (this.player?.seekController?.isSeeking()) {
44
+ this.isSeeking = true;
45
+
46
+ return;
47
+ }
48
+
43
49
  this.handleAnalyticEvent(PLAYBACK_EVENT.pause, event);
44
50
  };
45
51
 
46
52
  onPlayerResume = (event) => {
53
+ if (this.player?.seekController?.isSeeking()) {
54
+ return;
55
+ }
56
+
57
+ if (this.isSeeking) {
58
+ // Fallback due to player resume event been async and arriving with delays
59
+ this.isSeeking = false;
60
+
61
+ return;
62
+ }
63
+
47
64
  this.handleAnalyticEvent(PLAYBACK_EVENT.play, event);
48
65
  };
49
66
 
@@ -1,24 +1,24 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`AnalyticsManager - with undefined Native Module doesn't crash when calling the methods 1`] = `
4
- Array [
5
- Array [
6
- Object {
4
+ [
5
+ [
6
+ {
7
7
  "message": "Analytics Bridge is missing - no event will be sent",
8
8
  },
9
9
  ],
10
- Array [
11
- Object {
10
+ [
11
+ {
12
12
  "message": "Analytics Bridge is missing - no event will be sent",
13
13
  },
14
14
  ],
15
- Array [
16
- Object {
15
+ [
16
+ {
17
17
  "message": "Analytics Bridge is missing - no event will be sent",
18
18
  },
19
19
  ],
20
- Array [
21
- Object {
20
+ [
21
+ {
22
22
  "message": "Analytics Bridge is missing - no event will be sent",
23
23
  },
24
24
  ],
@@ -2,7 +2,7 @@ import * as R from "ramda";
2
2
  import * as React from "react";
3
3
 
4
4
  import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
5
- import { useScreenContext } from "@applicaster/zapp-react-native-utils/reactHooks/screen";
5
+ import { useScreenContext } from "@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenContext";
6
6
 
7
7
  import { getAnalyticsScreenPropertiesFromScreenData } from "@applicaster/zapp-react-native-utils/analyticsUtils/currentScreenProperities";
8
8
  import { useAnalytics } from "@applicaster/zapp-react-native-utils/analyticsUtils";
@@ -2,27 +2,27 @@
2
2
 
3
3
  exports[`Hook Hook Properties has all the hook properties 1`] = `
4
4
  Hook {
5
- "advertising": Object {},
6
- "general": Object {
5
+ "advertising": {},
6
+ "general": {
7
7
  "allow_screen_plugin_presentation": true,
8
8
  "is_flow_blocker": true,
9
9
  },
10
- "hooks": Array [],
10
+ "hooks": [],
11
11
  "id": "A1234",
12
12
  "identifier": "hook_screen",
13
13
  "lastHook": true,
14
- "manager": Object {
14
+ "manager": {
15
15
  "executeHook": [MockFunction],
16
16
  "presentScreenHook": [MockFunction],
17
- "subscriber": Object {
17
+ "subscriber": {
18
18
  "invokeHandler": [MockFunction],
19
19
  },
20
20
  },
21
21
  "name": "Hook Screen",
22
- "navigations": Array [],
22
+ "navigations": [],
23
23
  "screen_id": "A1234",
24
24
  "state": 0,
25
- "styles": Object {},
25
+ "styles": {},
26
26
  "type": "hook_screen",
27
27
  "weight": 1,
28
28
  }