@applicaster/zapp-react-native-utils 13.0.0-rc.16 → 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 (47) 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/__tests__/__snapshots__/analyticsManagerNoModule.test.js.snap +9 -9
  5. package/analyticsUtils/helpers/hooks.ts +1 -1
  6. package/appUtils/HooksManager/__tests__/__snapshots__/hook.test.js.snap +7 -7
  7. package/appUtils/HooksManager/__tests__/__snapshots__/hooksManager.test.js.snap +186 -186
  8. package/appUtils/contextKeysManager/contextResolver.ts +73 -0
  9. package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +6 -6
  10. package/appUtils/keyCodes/__tests__/__snapshots__/keyCodes.test.js.snap +2 -2
  11. package/appUtils/keyCodes/__tests__/keyCodes.test.js +1 -1
  12. package/appUtils/orientationHelper.ts +1 -1
  13. package/appUtils/playerManager/playerNative.ts +1 -1
  14. package/arrayUtils/__tests__/__snapshots__/arrayUtils.test.ts.snap +4 -4
  15. package/functionUtils/__tests__/__snapshots__/functionUtils.test.js.snap +4 -4
  16. package/manifestUtils/__tests__/createConfig.test.js +18 -16
  17. package/navigationUtils/__tests__/__snapshots__/navigationUtils.test.js.snap +6 -6
  18. package/navigationUtils/__tests__/itemTypes.test.js +2 -2
  19. package/navigationUtils/__tests__/navigationUtils.test.js +2 -2
  20. package/package.json +3 -2
  21. package/reactHooks/autoscrolling/__tests__/useTrackCurrentAutoScrollingElement.test.ts +1 -1
  22. package/reactHooks/autoscrolling/__tests__/useTrackedView.test.tsx +1 -1
  23. package/reactHooks/cell-click/__tests__/index.test.js +5 -2
  24. package/reactHooks/feed/__tests__/useBuildPipesUrl.test.tsx +4 -4
  25. package/reactHooks/feed/__tests__/useFeedLoader.test.tsx +10 -11
  26. package/reactHooks/feed/usePipesCacheReset.ts +5 -5
  27. package/reactHooks/flatList/__tests__/index.test.tsx +30 -21
  28. package/reactHooks/layout/__tests__/index.test.tsx +10 -10
  29. package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.native.test.js +14 -28
  30. package/reactHooks/navigation/__tests__/index.test.tsx +0 -4
  31. package/reactHooks/navigation/index.ts +22 -214
  32. package/reactHooks/navigation/useGetBottomTabBarHeight.ts +12 -0
  33. package/reactHooks/navigation/useGetNavBarTopBorderWidth.ts +14 -0
  34. package/reactHooks/navigation/useGetTabBarHeight.ts +12 -0
  35. package/reactHooks/navigation/useIsScreenActive.ts +17 -0
  36. package/reactHooks/navigation/useNavigationPluginData.ts +15 -0
  37. package/reactHooks/navigation/useNavigationType.ts +15 -0
  38. package/reactHooks/navigation/usePathname.ts +4 -0
  39. package/reactHooks/navigation/useRoute.ts +100 -0
  40. package/reactHooks/navigation/useUniqueRouteSuffix.ts +41 -0
  41. package/reactHooks/player/__tests__/useAutoSeek._test.tsx +2 -3
  42. package/reactUtils/__tests__/reactUtils.test.js +10 -28
  43. package/reactUtils/createContext/__tests__/__snapshots__/helpers.test.js.snap +19 -19
  44. package/reactUtils/createContext/__tests__/__snapshots__/index.test.js.snap +2 -2
  45. package/reactUtils/createContext/__tests__/__snapshots__/provider.test.js.snap +3 -3
  46. package/reactUtils/createContext/__tests__/helpers.test.js +8 -8
  47. package/theme/__mocks__/index.ts +4 -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";
@@ -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
  }