@applicaster/zapp-react-native-utils 16.0.0-alpha.2024822855 → 16.0.0-alpha.2105365027

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 (109) hide show
  1. package/actionUtils/index.ts +3 -1
  2. package/actionsExecutor/ActionExecutor.ts +10 -1
  3. package/actionsExecutor/ActionExecutorContext.tsx +29 -1
  4. package/actionsExecutor/__tests__/ActionExecutor.test.ts +71 -0
  5. package/actionsExecutor/actions/__tests__/dismissBottomSheet.test.ts +3 -0
  6. package/actionsExecutor/actions/__tests__/goBack.test.ts +62 -0
  7. package/actionsExecutor/actions/__tests__/goHome.test.ts +19 -0
  8. package/actionsExecutor/actions/__tests__/navigateToScreen.test.ts +139 -5
  9. package/actionsExecutor/actions/__tests__/openBottomSheet.customContent.test.ts +24 -0
  10. package/actionsExecutor/actions/__tests__/openBottomSheet.inlineItems.test.ts +201 -1
  11. package/actionsExecutor/actions/__tests__/presentScreen.test.ts +127 -0
  12. package/actionsExecutor/actions/__tests__/showAlert.test.ts +49 -0
  13. package/actionsExecutor/actions/__tests__/showToast.test.ts +2 -2
  14. package/actionsExecutor/actions/dismissBottomSheet.ts +2 -1
  15. package/actionsExecutor/actions/goBack.ts +60 -0
  16. package/actionsExecutor/actions/goHome.ts +31 -0
  17. package/actionsExecutor/actions/index.ts +8 -0
  18. package/actionsExecutor/actions/navigateToScreen.ts +29 -45
  19. package/actionsExecutor/actions/openBottomSheet.ts +35 -16
  20. package/actionsExecutor/actions/presentScreen.ts +78 -0
  21. package/actionsExecutor/actions/showAlert.ts +51 -0
  22. package/actionsExecutor/actions/showToast.ts +2 -2
  23. package/actionsExecutor/consts.ts +4 -0
  24. package/appUtils/playerManager/OverlayObserver/OverlaysObserver.ts +4 -11
  25. package/appUtils/playerManager/OverlayObserver/__tests__/getUpcomingQueue.test.ts +67 -0
  26. package/appUtils/playerManager/OverlayObserver/__tests__/utils.test.ts +9 -2
  27. package/appUtils/playerManager/OverlayObserver/getUpcomingQueue.ts +15 -2
  28. package/appUtils/playerManager/OverlayObserver/utils.ts +2 -5
  29. package/appUtils/playerManager/__tests__/playerNative.test.ts +114 -0
  30. package/appUtils/playerManager/__tests__/playerNativeCommand.test.ts +62 -0
  31. package/appUtils/playerManager/__tests__/playerToolbox.test.ts +97 -0
  32. package/appUtils/playerManager/__tests__/usePlayerControllerSetup.test.tsx +62 -0
  33. package/appUtils/playerManager/const.ts +13 -0
  34. package/appUtils/playerManager/index.ts +7 -0
  35. package/appUtils/playerManager/player.ts +10 -0
  36. package/appUtils/playerManager/playerNative.ts +27 -3
  37. package/appUtils/playerManager/playerNativeCommand.ts +3 -6
  38. package/appUtils/playerManager/playerToolbox.ts +157 -0
  39. package/appUtils/playerManager/usePlayerControllerSetup.tsx +6 -0
  40. package/arrayUtils/__tests__/reorderByIds.test.ts +13 -0
  41. package/arrayUtils/index.ts +26 -43
  42. package/cellUtils/__tests__/getButtonsEnabled.test.ts +28 -0
  43. package/cellUtils/__tests__/getCellNavigationEnabled.test.ts +36 -0
  44. package/cellUtils/__tests__/getIsCellNavigationEnabled.test.ts +35 -0
  45. package/cellUtils/__tests__/isCellNavigationEnabled.test.ts +21 -0
  46. package/cellUtils/index.ts +74 -19
  47. package/configurationUtils/__tests__/manifestKeyParser.test.ts +21 -0
  48. package/configurationUtils/__tests__/modalBlocksParser.test.ts +286 -1
  49. package/configurationUtils/index.ts +77 -73
  50. package/configurationUtils/manifestKeyParser.ts +12 -1
  51. package/configurationUtils/modalBlocksParser.ts +78 -4
  52. package/entryActions/__tests__/buildEntryActions.test.ts +235 -0
  53. package/entryActions/aliasPresentation.ts +108 -0
  54. package/entryActions/buildEntryActions.ts +167 -0
  55. package/entryActions/index.ts +15 -0
  56. package/entryActions/types.ts +39 -0
  57. package/focusManager/FocusManager.ts +26 -0
  58. package/focusManager/__tests__/FocusManager.test.ts +9 -0
  59. package/localizationUtils/index.ts +12 -6
  60. package/logger/__tests__/xrayToolbox.test.ts +69 -0
  61. package/logger/xrayToolbox.ts +67 -0
  62. package/manifestUtils/_internals/index.js +8 -3
  63. package/manifestUtils/defaultManifestConfigurations/generalContent.js +6 -0
  64. package/manifestUtils/defaultManifestConfigurations/player.js +30 -1
  65. package/manifestUtils/keys.js +6 -1
  66. package/manifestUtils/mobileAction/container/__tests__/mobileActionButtonsContainer.test.js +21 -0
  67. package/manifestUtils/mobileAction/groups/__tests__/buildMobileActionButtonGroups.test.js +1 -1
  68. package/manifestUtils/mobileAction/groups/defaults.js +2 -1
  69. package/modalState/ModalOrchestrator.ts +22 -9
  70. package/modalState/RemoteEditableCollection.ts +9 -1
  71. package/modalState/__tests__/ModalOrchestrator.phase3.test.ts +16 -0
  72. package/modalState/__tests__/RemoteEditableCollection.test.ts +90 -1
  73. package/modalState/__tests__/index.test.ts +30 -1
  74. package/modalState/__tests__/useModalStoreState.test.ts +142 -0
  75. package/modalState/index.ts +6 -1
  76. package/modalState/store.ts +9 -2
  77. package/modalState/types.ts +31 -2
  78. package/modalState/useBottomSheetContent.ts +24 -17
  79. package/navigationUtils/xrayNavigator.ts +12 -0
  80. package/package.json +2 -2
  81. package/perfTracker.ts +203 -0
  82. package/playerUtils/__tests__/resolvePlayerActions.test.ts +138 -0
  83. package/playerUtils/index.ts +17 -1
  84. package/playerUtils/resolvePlayerActions.ts +71 -0
  85. package/pluginUtils/__tests__/pluginUtils.test.js +32 -0
  86. package/pluginUtils/index.ts +29 -0
  87. package/reactHooks/__tests__/getPluginConfiguration.test.ts +82 -0
  88. package/reactHooks/actions/index.ts +67 -2
  89. package/reactHooks/cell-click/__tests__/index.test.js +64 -0
  90. package/reactHooks/cell-click/index.ts +21 -14
  91. package/reactHooks/connection/index.tsx +8 -5
  92. package/reactHooks/feed/__tests__/useMarkPipesDataStale.test.tsx +243 -0
  93. package/reactHooks/feed/useMarkPipesDataStale.ts +68 -23
  94. package/reactHooks/navigation/__tests__/index.test.tsx +176 -1
  95. package/reactHooks/navigation/__tests__/usePresentScreen.test.ts +154 -0
  96. package/reactHooks/navigation/index.ts +2 -0
  97. package/reactHooks/navigation/usePresentScreen.ts +157 -0
  98. package/reactHooks/navigation/useRoute.ts +22 -5
  99. package/reactHooks/usePluginConfiguration.ts +84 -46
  100. package/riverComponetsMeasurementProvider/index.tsx +8 -1
  101. package/uiActionsRegistrator/__tests__/resolveActionIdentifiers.test.ts +93 -0
  102. package/uiActionsRegistrator/__tests__/subscribe.test.ts +133 -0
  103. package/uiActionsRegistrator/__tests__/usableActionItems.test.ts +52 -0
  104. package/uiActionsRegistrator/index.ts +25 -203
  105. package/uiActionsRegistrator/registry.ts +351 -0
  106. package/uiActionsRegistrator/resolveActionIdentifiers.ts +100 -0
  107. package/uiActionsRegistrator/usableActionItems.ts +66 -0
  108. package/playerUtils/__tests__/getPlayerActionButtons.test.ts +0 -54
  109. package/playerUtils/getPlayerActionButtons.ts +0 -17
@@ -0,0 +1,127 @@
1
+ import { createPresentScreenAction } from "../presentScreen";
2
+ import { ActionResult } from "../../ActionExecutor";
3
+
4
+ const contextEntry = { id: "context-entry" } as any;
5
+
6
+ const succeeded = { success: true, cancelled: false };
7
+
8
+ const cancelled = { success: false, cancelled: true };
9
+
10
+ describe("presentScreenAction", () => {
11
+ let presentScreen: jest.Mock;
12
+ let presentScreenAction: ReturnType<typeof createPresentScreenAction>;
13
+
14
+ beforeEach(() => {
15
+ presentScreen = jest.fn().mockResolvedValue(succeeded);
16
+ presentScreenAction = createPresentScreenAction(presentScreen);
17
+ });
18
+
19
+ it("presents the screen named by typeMapping", async () => {
20
+ await presentScreenAction({
21
+ type: "presentScreen",
22
+ options: { typeMapping: "parent_lock" },
23
+ });
24
+
25
+ expect(presentScreen).toHaveBeenCalledWith({
26
+ typeMapping: "parent_lock",
27
+ entry: undefined,
28
+ });
29
+ });
30
+
31
+ it("fails without presenting anything when typeMapping is missing", async () => {
32
+ const result = await presentScreenAction({
33
+ type: "presentScreen",
34
+ options: {},
35
+ });
36
+
37
+ expect(result).toBe(ActionResult.Error);
38
+ expect(presentScreen).not.toHaveBeenCalled();
39
+ });
40
+
41
+ it("resolves the '@{entry/}' token to the entry from the execution context", async () => {
42
+ await presentScreenAction(
43
+ {
44
+ type: "presentScreen",
45
+ options: { typeMapping: "parent_lock", entry: "@{entry/}" },
46
+ },
47
+ { entry: contextEntry }
48
+ );
49
+
50
+ expect(presentScreen).toHaveBeenCalledWith({
51
+ typeMapping: "parent_lock",
52
+ entry: contextEntry,
53
+ });
54
+ });
55
+
56
+ it("presents an entry supplied inline in the options", async () => {
57
+ const inlineEntry = { id: "inline-entry" } as any;
58
+
59
+ await presentScreenAction({
60
+ type: "presentScreen",
61
+ options: { typeMapping: "parent_lock", entry: inlineEntry },
62
+ });
63
+
64
+ expect(presentScreen).toHaveBeenCalledWith({
65
+ typeMapping: "parent_lock",
66
+ entry: inlineEntry,
67
+ });
68
+ });
69
+
70
+ it("fails without presenting anything when the entry option is not an object", async () => {
71
+ const result = await presentScreenAction({
72
+ type: "presentScreen",
73
+ options: { typeMapping: "parent_lock", entry: "not-an-entry" as any },
74
+ });
75
+
76
+ expect(result).toBe(ActionResult.Error);
77
+ expect(presentScreen).not.toHaveBeenCalled();
78
+ });
79
+
80
+ it("succeeds when the presented screen reports success", async () => {
81
+ presentScreen.mockResolvedValue(succeeded);
82
+
83
+ const result = await presentScreenAction({
84
+ type: "presentScreen",
85
+ options: { typeMapping: "parent_lock" },
86
+ });
87
+
88
+ expect(result).toBe(ActionResult.Success);
89
+ });
90
+
91
+ it("cancels the action chain when the presented screen is cancelled", async () => {
92
+ presentScreen.mockResolvedValue(cancelled);
93
+
94
+ const result = await presentScreenAction({
95
+ type: "presentScreen",
96
+ options: { typeMapping: "parent_lock" },
97
+ });
98
+
99
+ expect(result).toBe(ActionResult.Cancel);
100
+ });
101
+
102
+ it("cancels the action chain when the presented screen reports failure", async () => {
103
+ presentScreen.mockResolvedValue({ success: false, cancelled: false });
104
+
105
+ const result = await presentScreenAction({
106
+ type: "presentScreen",
107
+ options: { typeMapping: "parent_lock" },
108
+ });
109
+
110
+ expect(result).toBe(ActionResult.Cancel);
111
+ });
112
+
113
+ it("errors when the screen could not be presented at all", async () => {
114
+ presentScreen.mockResolvedValue({
115
+ success: false,
116
+ cancelled: false,
117
+ error: "can not resolve screen type mapping: parent_lock",
118
+ });
119
+
120
+ const result = await presentScreenAction({
121
+ type: "presentScreen",
122
+ options: { typeMapping: "parent_lock" },
123
+ });
124
+
125
+ expect(result).toBe(ActionResult.Error);
126
+ });
127
+ });
@@ -0,0 +1,49 @@
1
+ import { showAlertAction } from "../showAlert";
2
+ import { ActionResult } from "../../ActionExecutor";
3
+ import { showAlertDialog } from "../../../alertUtils";
4
+
5
+ jest.mock("../../../alertUtils", () => ({
6
+ showAlertDialog: jest.fn(),
7
+ }));
8
+
9
+ const dialog = showAlertDialog as jest.Mock;
10
+
11
+ const dismiss = () => dialog.mock.calls[0][0].completion();
12
+
13
+ describe("showAlert", () => {
14
+ beforeEach(() => dialog.mockReset());
15
+
16
+ it("shows the notice and resolves once it is dismissed", async () => {
17
+ const result = showAlertAction({
18
+ type: "showAlert",
19
+ options: { title: "Locked", message: "Ask the account owner." },
20
+ });
21
+
22
+ expect(dialog).toHaveBeenCalledWith(
23
+ expect.objectContaining({
24
+ title: "Locked",
25
+ message: "Ask the account owner.",
26
+ okButtonText: "OK",
27
+ })
28
+ );
29
+
30
+ dismiss();
31
+
32
+ // Dismissing a notice is not a cancellation: the chain carries on.
33
+ await expect(result).resolves.toBe(ActionResult.Success);
34
+ });
35
+
36
+ it("takes the dismiss label from the action", async () => {
37
+ const result = showAlertAction({
38
+ type: "showAlert",
39
+ options: { title: "Locked", okButtonText: "Got it" },
40
+ });
41
+
42
+ expect(dialog).toHaveBeenCalledWith(
43
+ expect.objectContaining({ okButtonText: "Got it" })
44
+ );
45
+
46
+ dismiss();
47
+ await result;
48
+ });
49
+ });
@@ -31,7 +31,7 @@ describe("showToastAction", () => {
31
31
  message: "Added to queue",
32
32
  extraMessage: "Extra info",
33
33
  style: undefined,
34
- timeout: 1000,
34
+ timeout: 5000,
35
35
  source: "confirmation",
36
36
  },
37
37
  ]);
@@ -78,7 +78,7 @@ describe("showToastAction", () => {
78
78
  message: undefined,
79
79
  extraMessage: undefined,
80
80
  style: undefined,
81
- timeout: 1000,
81
+ timeout: 5000,
82
82
  source: "confirmation",
83
83
  },
84
84
  ]);
@@ -1,5 +1,5 @@
1
1
  /// <reference types="@applicaster/applicaster-types" />
2
- import { dismissModal } from "../../modalState";
2
+ import { dismissModal, modalOrchestrator } from "../../modalState";
3
3
  import { ActionResult } from "../ActionExecutor";
4
4
  import { ActionHandler } from "../types";
5
5
  import { createLogger } from "../../logger";
@@ -16,6 +16,7 @@ export const dismissBottomSheetAction: ActionHandler<
16
16
  any
17
17
  > = async (): Promise<ActionResult> => {
18
18
  log_info("handleAction: dismissBottomSheet");
19
+ modalOrchestrator.close();
19
20
  dismissModal();
20
21
 
21
22
  return ActionResult.Success;
@@ -0,0 +1,60 @@
1
+ /// <reference types="@applicaster/applicaster-types" />
2
+ import { ActionResult } from "../ActionExecutor";
3
+ import { ActionHandler } from "../types";
4
+ import { createLogger } from "../../logger";
5
+
6
+ const { log_info } = createLogger({
7
+ subsystem: "ActionExecutorContext",
8
+ category: "General",
9
+ });
10
+
11
+ /**
12
+ * Options for the goBack action.
13
+ */
14
+ export interface GoBackOptions {
15
+ /**
16
+ * Navigate to the home screen when there is no screen to go back to.
17
+ * Defaults to true.
18
+ */
19
+ fallbackToHome?: boolean;
20
+
21
+ /**
22
+ * Go back to the first screen of the stack instead of the previous one.
23
+ * Defaults to false.
24
+ */
25
+ backToTop?: boolean;
26
+ }
27
+
28
+ /**
29
+ * Creates a go back action handler with the provided dependencies.
30
+ * This factory pattern allows the action to access navigation state at runtime.
31
+ *
32
+ * @param navigator - The app navigator performing the back navigation
33
+ * @returns An action handler that navigates back
34
+ */
35
+ export function createGoBackAction(
36
+ navigator: QuickBrickAppNavigator
37
+ ): ActionHandler<GoBackOptions> {
38
+ return async function goBackAction(action): Promise<ActionResult> {
39
+ const fallbackToHome = action.options?.fallbackToHome ?? true;
40
+ const backToTop = action.options?.backToTop ?? false;
41
+
42
+ // With fallbackToHome on, the navigator goes home on an empty stack by
43
+ // itself. The guard only matters when the caller opted out of that.
44
+ if (!fallbackToHome && !navigator.canGoBack()) {
45
+ log_info(
46
+ "goBack: no screen to go back to and fallbackToHome is disabled, ignoring"
47
+ );
48
+
49
+ return ActionResult.Error;
50
+ }
51
+
52
+ log_info(
53
+ `goBack: navigating back, fallbackToHome: ${fallbackToHome}, backToTop: ${backToTop}`
54
+ );
55
+
56
+ navigator.goBack(fallbackToHome, false, backToTop);
57
+
58
+ return ActionResult.Success;
59
+ };
60
+ }
@@ -0,0 +1,31 @@
1
+ /// <reference types="@applicaster/applicaster-types" />
2
+ import { ActionResult } from "../ActionExecutor";
3
+ import { ActionHandler } from "../types";
4
+ import { createLogger } from "../../logger";
5
+
6
+ const { log_info } = createLogger({
7
+ subsystem: "ActionExecutorContext",
8
+ category: "General",
9
+ });
10
+
11
+ /**
12
+ * Creates a go home action handler with the provided dependencies.
13
+ * This factory pattern allows the action to access navigation state at runtime.
14
+ *
15
+ * The navigator's `initialLaunch` flag is intentionally not exposed: it selects
16
+ * the offline home river during app bootstrap and is not a per-action choice.
17
+ *
18
+ * @param navigator - The app navigator performing the navigation
19
+ * @returns An action handler that navigates to the home screen
20
+ */
21
+ export function createGoHomeAction(
22
+ navigator: QuickBrickAppNavigator
23
+ ): ActionHandler {
24
+ return async function goHomeAction(): Promise<ActionResult> {
25
+ log_info("goHome: navigating to the home screen");
26
+
27
+ navigator.goHome();
28
+
29
+ return ActionResult.Success;
30
+ };
31
+ }
@@ -15,6 +15,8 @@ export { appRestartAction } from "./appRestart";
15
15
 
16
16
  export { confirmDialogAction } from "./confirmDialog";
17
17
 
18
+ export { showAlertAction } from "./showAlert";
19
+
18
20
  export { sendCloudEventAction } from "./sendCloudEvent";
19
21
 
20
22
  export { sessionStorageToggleFlagAction } from "./sessionStorageToggleFlag";
@@ -27,6 +29,12 @@ export { screenToggleFlagAction } from "./screenToggleFlag";
27
29
 
28
30
  export { createNavigateToScreenAction } from "./navigateToScreen";
29
31
 
32
+ export { createPresentScreenAction } from "./presentScreen";
33
+
34
+ export { createGoBackAction } from "./goBack";
35
+
36
+ export { createGoHomeAction } from "./goHome";
37
+
30
38
  export { showToastAction } from "./showToast";
31
39
 
32
40
  export { openBottomSheetAction } from "./openBottomSheet";
@@ -13,7 +13,7 @@ const { log_info, log_error } = createLogger({
13
13
  */
14
14
  export interface NavigateToScreenOptions {
15
15
  /** The screen type to navigate to (from content types mapping) */
16
- typeMapping: string;
16
+ typeMapping?: string;
17
17
 
18
18
  /** Navigation action: push adds to history, replace replaces current screen */
19
19
  navigationAction?: "push" | "replace";
@@ -58,14 +58,6 @@ export function createNavigateToScreenAction(
58
58
  action,
59
59
  context?: ActionExecutionContext
60
60
  ): Promise<ActionResult> {
61
- const screenType = action.options?.typeMapping;
62
-
63
- if (!screenType) {
64
- log_error("navigateToScreen: typeMapping option is missing");
65
-
66
- return ActionResult.Error;
67
- }
68
-
69
61
  const navigationAction = action.options?.navigationAction;
70
62
  const entrySource = action.options?.entry;
71
63
  const navigationOptions = action.options?.navigationOptions;
@@ -76,61 +68,53 @@ export function createNavigateToScreenAction(
76
68
  : entrySource
77
69
  : null;
78
70
 
79
- if (entry) {
80
- if (typeof entry !== "object") {
81
- log_error(
82
- `navigateToScreen: entry option is not an object, entry: ${entry}`
83
- );
71
+ const screenType = action.options?.typeMapping || entry?.type?.value;
84
72
 
85
- return ActionResult.Error;
86
- }
73
+ const navigate =
74
+ navigationAction === "push" ? navigator.push : navigator.replace;
75
+
76
+ let navigatingEntry: ZappEntry | ZappRiver = entry;
87
77
 
78
+ if (entry && screenType) {
88
79
  log_info(
89
80
  `navigateToScreen: navigating to screen type: ${screenType} with entry id: ${entry.id}`
90
81
  );
91
82
 
92
- const overriddenEntry: ZappEntry = {
83
+ navigatingEntry = {
93
84
  ...entry,
94
- type: {
95
- value: screenType,
96
- },
85
+ type: { value: screenType },
97
86
  };
87
+ } else {
88
+ if (!screenType) {
89
+ log_error(
90
+ "navigateToScreen: options.typeMapping or entry?.type?.value is not provided"
91
+ );
98
92
 
99
- if (navigationAction === "push") {
100
- navigator.push(overriddenEntry, navigationOptions);
101
- } else {
102
- // Use replaceTop for entries since replace() only accepts ZappRiver
103
- navigator.replaceTop(overriddenEntry, navigationOptions);
93
+ return ActionResult.Error;
104
94
  }
105
95
 
106
- return ActionResult.Success;
107
- }
108
-
109
- const screenId = contentTypes?.[screenType]?.screen_id || null;
96
+ const screenId = contentTypes?.[screenType]?.screen_id || null;
97
+ const river = rivers?.[screenId];
110
98
 
111
- if (!screenId) {
112
- log_error(
113
- `navigateToScreen: can not resolve screen type mapping: ${screenType}`
114
- );
99
+ if (!screenId) {
100
+ log_error(
101
+ `navigateToScreen: can not resolve screen type mapping: ${screenType}`
102
+ );
115
103
 
116
- return ActionResult.Error;
117
- }
104
+ return ActionResult.Error;
105
+ }
118
106
 
119
- const river = rivers[screenId];
107
+ if (!river) {
108
+ log_error("navigateToScreen: can not resolve river");
120
109
 
121
- if (!river) {
122
- log_error("navigateToScreen: can not resolve river");
110
+ return ActionResult.Error;
111
+ }
123
112
 
124
- return ActionResult.Error;
113
+ navigatingEntry = river;
125
114
  }
126
115
 
127
116
  context?.callback?.({ success: false, error: null, abort: true });
128
-
129
- if (navigationAction === "push") {
130
- navigator.push(river, navigationOptions);
131
- } else {
132
- navigator.replace(river, navigationOptions);
133
- }
117
+ navigate(navigatingEntry, navigationOptions);
134
118
 
135
119
  return ActionResult.Success;
136
120
  };
@@ -8,6 +8,7 @@ import { modalOrchestrator } from "../../modalState/ModalOrchestrator";
8
8
  import { openBottomSheetModal } from "../../modalState/store";
9
9
  import {
10
10
  DynamicCollectionOptions,
11
+ getMenuItemActions,
11
12
  isPresentSubMenuAction,
12
13
  Menu,
13
14
  MenuItem,
@@ -91,6 +92,7 @@ export function entryToMenuItem(
91
92
  icon: firstImage?.src,
92
93
  isSelected: currentSelection.includes(itemId),
93
94
  action: primaryAction,
95
+ actions: tapActions,
94
96
  entryActions: entry.extensions?.entry_action || [],
95
97
  };
96
98
  }
@@ -206,7 +208,11 @@ export async function openBottomSheetAction(
206
208
  items: [],
207
209
  onPress: () => {},
208
210
  contentComponent: content.component,
209
- contentComponentProps: content.props || {},
211
+ contentComponentProps: {
212
+ ...(content.props || {}),
213
+ actionContext: context,
214
+ },
215
+ themePluginId,
210
216
  },
211
217
  });
212
218
 
@@ -222,7 +228,18 @@ export async function openBottomSheetAction(
222
228
 
223
229
  let dynamicCollection: DynamicCollectionOptions | undefined;
224
230
 
225
- if (Array.isArray(inlineItems) && inlineItems.length > 0) {
231
+ const rawDynamicCollection =
232
+ content?.dynamicCollection ??
233
+ content?.extensions?.dynamic_collection_options;
234
+
235
+ // An empty items array is a valid starting state for a provider-backed or
236
+ // offline collection. A sheet with neither items nor a source still errors.
237
+ const hasDynamicCollection = Boolean(rawDynamicCollection);
238
+
239
+ if (
240
+ Array.isArray(inlineItems) &&
241
+ (inlineItems.length > 0 || hasDynamicCollection)
242
+ ) {
226
243
  log_info("openBottomSheet: using inline items from action options", {
227
244
  count: inlineItems.length,
228
245
  });
@@ -234,10 +251,7 @@ export async function openBottomSheetAction(
234
251
  entryToMenuItem(entry, behavior?.currentSelection ?? [])
235
252
  );
236
253
 
237
- dynamicCollection = parseDynamicCollectionOptions(
238
- content?.dynamicCollection ??
239
- content?.extensions?.dynamic_collection_options
240
- );
254
+ dynamicCollection = parseDynamicCollectionOptions(rawDynamicCollection);
241
255
  } else if (itemsUrl) {
242
256
  log_info(`openBottomSheet: loading items from source: ${itemsUrl}`);
243
257
 
@@ -275,6 +289,8 @@ export async function openBottomSheetAction(
275
289
  dynamicCollection,
276
290
  themePluginId,
277
291
  styleOverrides: styleOverrides ?? content?.styleOverrides,
292
+ emptyMessage: content?.emptyMessage,
293
+ context,
278
294
  },
279
295
  };
280
296
 
@@ -288,18 +304,21 @@ export async function openBottomSheetAction(
288
304
  * reference it.
289
305
  */
290
306
  const onItemPress = async (item: MenuItem): Promise<void> => {
291
- if (!item.action || isPresentSubMenuAction(item.action)) {
292
- // Submenu navigation is handled internally by the orchestrator
293
- return;
294
- }
307
+ const actions = getMenuItemActions(item);
295
308
 
296
- await actionExecutor.handleAction(
297
- item.action as ActionType,
298
- {
299
- ...context,
300
- entry: item as any,
301
- } as any
309
+ const executableActions = actions.filter(
310
+ (action) => !isPresentSubMenuAction(action)
302
311
  );
312
+
313
+ if (executableActions.length > 0) {
314
+ await actionExecutor.handleActions(
315
+ executableActions as ActionType[],
316
+ {
317
+ ...context,
318
+ entry: item as any,
319
+ } as any
320
+ );
321
+ }
303
322
  };
304
323
 
305
324
  if (action.options?.replace) {
@@ -0,0 +1,78 @@
1
+ /// <reference types="@applicaster/applicaster-types" />
2
+ import { ActionResult } from "../ActionExecutor";
3
+ import { ActionHandler, ActionExecutionContext } from "../types";
4
+ import type { PresentScreenFn } from "../../reactHooks/navigation/usePresentScreen";
5
+ import { createLogger } from "../../logger";
6
+
7
+ const { log_error } = createLogger({
8
+ subsystem: "ActionExecutorContext",
9
+ category: "General",
10
+ });
11
+
12
+ /**
13
+ * Options for the presentScreen action.
14
+ */
15
+ export interface PresentScreenOptions {
16
+ /** The screen type to present (from content types mapping) */
17
+ typeMapping: string;
18
+
19
+ /**
20
+ * Entry to present the screen with. Can be:
21
+ * - "@{entry/}" to use the context entry
22
+ * - A ZappEntry object
23
+ * - undefined to present the screen without an entry
24
+ */
25
+ entry?: "@{entry/}" | ZappEntry;
26
+ }
27
+
28
+ /**
29
+ * Creates a present-screen action handler with the provided dependencies.
30
+ *
31
+ * Unlike navigateToScreen, this action does not return until the presented
32
+ * screen reports a result, so a screen that gates the flow (a parental lock,
33
+ * for example) can stop the remaining actions by being cancelled.
34
+ *
35
+ * @param presentScreen - Presents a screen as a modal and resolves with its result
36
+ * @returns An action handler that presents a screen and awaits its outcome
37
+ */
38
+ export function createPresentScreenAction(
39
+ presentScreen: PresentScreenFn
40
+ ): ActionHandler<PresentScreenOptions> {
41
+ return async function presentScreenAction(
42
+ action,
43
+ context?: ActionExecutionContext
44
+ ): Promise<ActionResult> {
45
+ const typeMapping = action.options?.typeMapping;
46
+
47
+ if (!typeMapping) {
48
+ log_error("presentScreen: typeMapping option is missing");
49
+
50
+ return ActionResult.Error;
51
+ }
52
+
53
+ const entrySource = action.options?.entry;
54
+
55
+ const entry = entrySource
56
+ ? entrySource === "@{entry/}"
57
+ ? context?.entry
58
+ : entrySource
59
+ : undefined;
60
+
61
+ if (entry && typeof entry !== "object") {
62
+ log_error(
63
+ `presentScreen: entry option is not an object, entry: ${entry}`
64
+ );
65
+
66
+ return ActionResult.Error;
67
+ }
68
+
69
+ const result = await presentScreen({ typeMapping, entry });
70
+
71
+ if (result.error) {
72
+ return ActionResult.Error;
73
+ }
74
+
75
+ // Anything short of success stops the remaining actions in the chain.
76
+ return result.success ? ActionResult.Success : ActionResult.Cancel;
77
+ };
78
+ }
@@ -0,0 +1,51 @@
1
+ /// <reference types="@applicaster/applicaster-types" />
2
+ import { showAlertDialog } from "../../alertUtils";
3
+ import { ActionResult } from "../ActionExecutor";
4
+ import { ActionHandler } from "../types";
5
+ import { createLogger } from "../../logger";
6
+
7
+ const { log_info } = createLogger({
8
+ subsystem: "ActionExecutorContext",
9
+ category: "General",
10
+ });
11
+
12
+ /**
13
+ * Options for the showAlert action.
14
+ */
15
+ export interface ShowAlertOptions {
16
+ /** Dialog title (required) */
17
+ title: string;
18
+
19
+ /** Dialog message */
20
+ message?: string;
21
+
22
+ /** Dismiss button text. Defaults to "OK" */
23
+ okButtonText?: string;
24
+ }
25
+
26
+ /**
27
+ * Tells the user something and waits for them to acknowledge it.
28
+ *
29
+ * One button, because there is nothing to decide. Use `confirmDialog` when the
30
+ * user is choosing between going on and backing out; a `confirmDialog` without
31
+ * a cancel label still renders two buttons, the second one blank.
32
+ *
33
+ * Always resolves to Success: dismissing a notice is not a cancellation, so the
34
+ * rest of the chain runs.
35
+ */
36
+ export const showAlertAction: ActionHandler<ShowAlertOptions> = async (
37
+ action
38
+ ): Promise<ActionResult> => {
39
+ log_info("handleAction: showAlert event");
40
+
41
+ const options = action.options as ShowAlertOptions;
42
+
43
+ return new Promise<ActionResult>((resolve) => {
44
+ showAlertDialog({
45
+ title: options?.title,
46
+ message: options?.message,
47
+ okButtonText: options?.okButtonText || "OK",
48
+ completion: () => resolve(ActionResult.Success),
49
+ });
50
+ });
51
+ };
@@ -5,7 +5,7 @@ import { postEvent } from "../../reactHooks/useSubscriberFor";
5
5
 
6
6
  export const CONFIRMATION_TOAST_SOURCE = "confirmation";
7
7
 
8
- export const CONFIRMATION_TOAST_DEFAULT_TIMEOUT = 1000;
8
+ export const CONFIRMATION_TOAST_DEFAULT_TIMEOUT = 5000;
9
9
 
10
10
  /**
11
11
  * Shows a mobile confirmation toast with Theme defaults from
@@ -13,7 +13,7 @@ export const CONFIRMATION_TOAST_DEFAULT_TIMEOUT = 1000;
13
13
  *
14
14
  * This action is confirmation-only by design: it always stamps
15
15
  * `source: "confirmation"` (so Theme confirmation styles apply) and defaults
16
- * `timeout` to 1000 ms. Non-confirmation toasts (e.g. Offline Experience)
16
+ * `timeout` to 5000 ms. Non-confirmation toasts (e.g. Offline Experience)
17
17
  * must post on the shared `"showToast"` event bus directly and omit `source`.
18
18
  * Callers may override individual style fields; Theme supplies the rest.
19
19
  *