@applicaster/zapp-react-native-utils 16.0.0-rc.7 → 16.0.0-rc.71

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 (169) hide show
  1. package/actionsExecutor/ActionExecutor.ts +47 -11
  2. package/actionsExecutor/ActionExecutorContext.tsx +87 -316
  3. package/actionsExecutor/__tests__/feedDecorator.test.ts +61 -0
  4. package/actionsExecutor/actions/__tests__/dismissBottomSheet.test.ts +22 -0
  5. package/actionsExecutor/actions/__tests__/loadItemsFromSource.test.ts +88 -0
  6. package/actionsExecutor/actions/__tests__/navigateToScreen.test.ts +133 -0
  7. package/actionsExecutor/actions/__tests__/openBottomSheet.customContent.test.ts +76 -0
  8. package/actionsExecutor/actions/__tests__/openBottomSheet.inlineItems.test.ts +100 -0
  9. package/actionsExecutor/actions/__tests__/showToast.test.ts +88 -0
  10. package/actionsExecutor/actions/appRestart.ts +24 -0
  11. package/actionsExecutor/actions/confirmDialog.ts +53 -0
  12. package/actionsExecutor/actions/dismissBottomSheet.ts +22 -0
  13. package/actionsExecutor/actions/index.ts +34 -0
  14. package/actionsExecutor/actions/localStorageRemove.ts +27 -0
  15. package/actionsExecutor/actions/localStorageSet.ts +28 -0
  16. package/actionsExecutor/actions/localStorageToggleFlag.ts +28 -0
  17. package/actionsExecutor/actions/navigateToScreen.ts +137 -0
  18. package/actionsExecutor/actions/openBottomSheet.ts +320 -0
  19. package/actionsExecutor/actions/refreshComponent.ts +85 -0
  20. package/actionsExecutor/actions/screenSetVariable.ts +35 -0
  21. package/actionsExecutor/actions/screenToggleFlag.ts +38 -0
  22. package/actionsExecutor/actions/sendCloudEvent.ts +93 -0
  23. package/actionsExecutor/actions/sessionStorageRemove.ts +19 -0
  24. package/actionsExecutor/actions/sessionStorageSet.ts +20 -0
  25. package/actionsExecutor/actions/sessionStorageToggleFlag.ts +15 -0
  26. package/actionsExecutor/actions/showToast.ts +87 -0
  27. package/actionsExecutor/actions/switchLayout.ts +40 -0
  28. package/actionsExecutor/consts.ts +23 -0
  29. package/actionsExecutor/feedDecorator.ts +6 -6
  30. package/actionsExecutor/types.ts +59 -0
  31. package/analyticsUtils/AnalyticsEvents/sendMenuClickEvent.ts +2 -2
  32. package/analyticsUtils/PlayerAnalyticsManager.ts +12 -2
  33. package/analyticsUtils/__tests__/analyticsMapper.test.ts +35 -0
  34. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testACP_events.json +1 -1
  35. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testBlockUnlistedParams_rules.json +1 -1
  36. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testEmptyRenameKeepsName_events.json +4 -0
  37. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testEmptyRenameKeepsName_rules.json +6 -0
  38. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testEventRegex_events.json +3 -9
  39. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testIgnoreOrdering_events.json +18 -0
  40. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testIgnoreOrdering_rules.json +16 -0
  41. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexEventNoFallback_events.json +4 -0
  42. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexEventNoFallback_rules.json +6 -0
  43. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexMultiGroupRename_events.json +4 -0
  44. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexMultiGroupRename_rules.json +6 -0
  45. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexNonNamedFullMatch_events.json +4 -0
  46. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexNonNamedFullMatch_rules.json +6 -0
  47. package/analyticsUtils/__tests__/fixtures/index.js +20 -0
  48. package/analyticsUtils/analyticsMapper.ts +4 -1
  49. package/analyticsUtils/playerAnalyticsTracker.ts +26 -3
  50. package/appUtils/HooksManager/index.ts +12 -8
  51. package/appUtils/contextKeysManager/__tests__/getKey/failure.test.ts +1 -1
  52. package/appUtils/contextKeysManager/__tests__/removeKey/failure.test.ts +1 -1
  53. package/appUtils/contextKeysManager/__tests__/setKey/failure/invalidKey.test.ts +4 -4
  54. package/appUtils/contextKeysManager/index.ts +1 -1
  55. package/appUtils/contextKeysManager/utils/index.ts +38 -25
  56. package/appUtils/playerManager/OverlayObserver/OverlaysObserver.ts +143 -53
  57. package/appUtils/playerManager/OverlayObserver/__tests__/liveContent.test.ts +205 -0
  58. package/appUtils/playerManager/OverlayObserver/__tests__/utils.test.ts +49 -0
  59. package/appUtils/playerManager/OverlayObserver/getUpcomingQueue.android.tv.ts +4 -0
  60. package/appUtils/playerManager/OverlayObserver/getUpcomingQueue.ios.tv.ts +4 -0
  61. package/appUtils/playerManager/OverlayObserver/getUpcomingQueue.ts +11 -0
  62. package/appUtils/playerManager/OverlayObserver/getUpcomingQueue.web.ts +4 -0
  63. package/appUtils/playerManager/OverlayObserver/utils.ts +54 -20
  64. package/appUtils/playerManager/__tests__/playerContent.test.ts +403 -0
  65. package/appUtils/playerManager/__tests__/playerFactory.test.ts +150 -0
  66. package/appUtils/playerManager/__tests__/playerNative.test.ts +38 -0
  67. package/appUtils/playerManager/__tests__/usePlayerContent.test.tsx +64 -0
  68. package/appUtils/playerManager/{conts.ts → const.ts} +20 -0
  69. package/appUtils/playerManager/index.ts +1 -1
  70. package/appUtils/playerManager/player.ts +115 -3
  71. package/appUtils/playerManager/playerFactory.ts +18 -35
  72. package/appUtils/playerManager/playerNative.ts +6 -4
  73. package/appUtils/playerManager/usePlayerContent.tsx +43 -0
  74. package/appUtils/playerManager/usePlayerControllerSetup.tsx +1 -1
  75. package/appUtils/playerManager/userLanguagePreference.ts +1 -1
  76. package/arrayUtils/__tests__/{anyThruthy.test.ts → anyTruthy.test.ts} +8 -0
  77. package/arrayUtils/__tests__/arrayUtils.test.ts +165 -108
  78. package/arrayUtils/__tests__/isEmptyArray.test.ts +11 -0
  79. package/arrayUtils/__tests__/isFilledArray.test.ts +12 -0
  80. package/arrayUtils/__tests__/isFirst.test.ts +17 -0
  81. package/arrayUtils/__tests__/isIndexInRange.test.ts +14 -0
  82. package/arrayUtils/__tests__/isLast.test.ts +31 -0
  83. package/arrayUtils/__tests__/makeListOf.test.ts +31 -0
  84. package/arrayUtils/__tests__/makeListOfIndexes.test.ts +20 -0
  85. package/arrayUtils/__tests__/reorderByIds.test.ts +50 -0
  86. package/arrayUtils/__tests__/sample.test.ts +61 -0
  87. package/arrayUtils/index.ts +136 -20
  88. package/bottomSheet/__tests__/scrollContext.test.tsx +35 -0
  89. package/bottomSheet/index.ts +17 -0
  90. package/cellUtils/index.ts +33 -8
  91. package/colorUtils/__tests__/isTransparentColor.test.ts +76 -0
  92. package/colorUtils/__tests__/isValidColor.test.ts +70 -0
  93. package/colorUtils/index.ts +50 -0
  94. package/configurationUtils/__tests__/modalBlocksParser.test.ts +107 -0
  95. package/configurationUtils/manifestKeyParser.ts +38 -9
  96. package/configurationUtils/modalBlocksParser.ts +178 -0
  97. package/manifestUtils/__tests__/player.audioControls.test.js +158 -0
  98. package/manifestUtils/_internals/index.js +6 -0
  99. package/manifestUtils/defaultManifestConfigurations/generalContent.js +35 -0
  100. package/manifestUtils/defaultManifestConfigurations/player.js +327 -19
  101. package/manifestUtils/fieldUtils/__tests__/fieldUtils.test.js +84 -0
  102. package/manifestUtils/fieldUtils/index.js +125 -0
  103. package/manifestUtils/index.js +3 -0
  104. package/manifestUtils/keys.js +9 -0
  105. package/manifestUtils/mobileAction/button/index.js +16 -0
  106. package/manifestUtils/mobileAction/container/index.js +3 -1
  107. package/manifestUtils/mobileAction/groups/defaults.js +3 -1
  108. package/manifestUtils/modalBlocks.js +304 -0
  109. package/manifestUtils/platformIsTV.js +1 -0
  110. package/modalState/ContentViewModel.ts +113 -0
  111. package/modalState/EditableCollection.ts +17 -0
  112. package/modalState/EditableCollectionRegistry.ts +51 -0
  113. package/modalState/ModalOrchestrator.ts +199 -0
  114. package/modalState/RemoteEditableCollection.ts +227 -0
  115. package/modalState/__tests__/ContentViewModel.editable.test.ts +69 -0
  116. package/modalState/__tests__/ContentViewModel.test.ts +165 -0
  117. package/modalState/__tests__/EditableCollectionRegistry.test.ts +112 -0
  118. package/modalState/__tests__/ModalOrchestrator.phase3.test.ts +47 -0
  119. package/modalState/__tests__/RemoteEditableCollection.test.ts +326 -0
  120. package/modalState/__tests__/useBottomSheetContent.test.ts +349 -0
  121. package/modalState/index.ts +30 -83
  122. package/modalState/store.ts +102 -0
  123. package/modalState/types.ts +133 -0
  124. package/modalState/useBottomSheetContent.ts +102 -0
  125. package/numberUtils/__tests__/isMinusZero.test.ts +20 -0
  126. package/numberUtils/__tests__/isZero.test.ts +27 -0
  127. package/numberUtils/__tests__/requireNumber.test.ts +50 -0
  128. package/numberUtils/__tests__/toNumber.test.ts +27 -0
  129. package/numberUtils/__tests__/toNumberWithDefault.test.ts +64 -0
  130. package/numberUtils/__tests__/toNumberWithDefaultZero.test.ts +48 -0
  131. package/numberUtils/index.ts +27 -8
  132. package/package.json +2 -2
  133. package/pipesUtils/__tests__/buildUrlWithQuery.test.ts +33 -0
  134. package/pipesUtils/__tests__/withPipesEndpoint.test.tsx +56 -0
  135. package/pipesUtils/index.ts +1 -0
  136. package/pipesUtils/withPipesEndpoint.tsx +54 -0
  137. package/playerUtils/__tests__/contentDataKeys.test.ts +297 -0
  138. package/playerUtils/__tests__/resolvePlayerTitleSubtitle.test.ts +180 -0
  139. package/playerUtils/contentDataKeys.ts +134 -0
  140. package/playerUtils/index.ts +41 -14
  141. package/playerUtils/isAudioItem.ts +26 -0
  142. package/playerUtils/resolvePlayerTitleSubtitle.ts +76 -0
  143. package/reactHooks/actions/index.ts +51 -1
  144. package/reactHooks/cell-click/index.ts +18 -10
  145. package/reactHooks/feed/__mocks__/useMarkPipesDataStale.ts +4 -0
  146. package/reactHooks/feed/__tests__/useInflatedUrl.test.tsx +25 -0
  147. package/reactHooks/feed/index.ts +5 -1
  148. package/reactHooks/feed/useBatchLoading.ts +9 -1
  149. package/reactHooks/feed/{usePipesCacheReset.ts → useMarkPipesDataStale.ts} +12 -4
  150. package/reactHooks/index.ts +2 -0
  151. package/reactHooks/layout/index.ts +1 -1
  152. package/reactHooks/navigation/__mocks__/index.ts +4 -0
  153. package/reactHooks/navigation/__tests__/useIsScreenActive.test.ts +42 -0
  154. package/reactHooks/navigation/index.ts +1 -1
  155. package/reactHooks/navigation/useIsScreenActive.ts +29 -8
  156. package/reactHooks/state/useComponentScreenState.ts +1 -1
  157. package/reactHooks/usePluginConfiguration.ts +4 -1
  158. package/reactHooks/utils/__tests__/index.test.js +22 -2
  159. package/reactHooks/utils/index.ts +13 -2
  160. package/reactHooks/videoModal/hooks/useVideoModalScreenData.tsx +22 -4
  161. package/riverComponetsMeasurementProvider/index.tsx +12 -8
  162. package/stringUtils/__tests__/stringUtils.test.js +42 -0
  163. package/stringUtils/index.ts +2 -2
  164. package/uiActionsRegistrator/index.ts +203 -0
  165. package/zappFrameworkUtils/__tests__/localStorageHelper.test.ts +146 -0
  166. package/zappFrameworkUtils/localStorageHelper.ts +19 -15
  167. package/appUtils/playerManager/usePlayerTitleSummaryOverlay.tsx +0 -56
  168. package/reactHooks/feed/__mocks__/usePipesCacheReset.ts +0 -1
  169. /package/reactHooks/actions/__tests__/{index.test.js → index.test.tsx} +0 -0
@@ -0,0 +1,28 @@
1
+ /// <reference types="@applicaster/applicaster-types" />
2
+ import { localStorageToggleFlag } from "../StorageActions";
3
+ import { ActionResult } from "../ActionExecutor";
4
+ import { ActionHandler, ActionExecutionContext } from "../types";
5
+
6
+ /**
7
+ * Options for storage toggle flag actions (localStorage/sessionStorage).
8
+ */
9
+ export interface StorageToggleFlagOptions {
10
+ /** The key/namespace for storing the flag */
11
+ key: string;
12
+
13
+ /** Path to extract the tag from entry */
14
+ selector?: string;
15
+
16
+ /** Maximum number of items that can be selected */
17
+ max_items?: number;
18
+ }
19
+
20
+ /**
21
+ * Toggles a flag in local storage (adds or removes an item from a collection).
22
+ * Used for features like favorites, watchlists, etc.
23
+ */
24
+ export const localStorageToggleFlagAction: ActionHandler<
25
+ StorageToggleFlagOptions
26
+ > = async (action, context?: ActionExecutionContext): Promise<ActionResult> => {
27
+ return await localStorageToggleFlag(context, action);
28
+ };
@@ -0,0 +1,137 @@
1
+ /// <reference types="@applicaster/applicaster-types" />
2
+ import { ActionResult } from "../ActionExecutor";
3
+ import { ActionHandler, ActionExecutionContext } from "../types";
4
+ import { createLogger } from "../../logger";
5
+
6
+ const { log_info, log_error } = createLogger({
7
+ subsystem: "ActionExecutorContext",
8
+ category: "General",
9
+ });
10
+
11
+ /**
12
+ * Options for the navigateToScreen action.
13
+ */
14
+ export interface NavigateToScreenOptions {
15
+ /** The screen type to navigate to (from content types mapping) */
16
+ typeMapping: string;
17
+
18
+ /** Navigation action: push adds to history, replace replaces current screen */
19
+ navigationAction?: "push" | "replace";
20
+
21
+ /**
22
+ * Entry to navigate with. Can be:
23
+ * - "@{entry/}" to use the context entry
24
+ * - A ZappEntry object
25
+ * - undefined to navigate to screen without entry
26
+ */
27
+ entry?: "@{entry/}" | ZappEntry;
28
+
29
+ /**
30
+ * Arbitrary values passed through to the destination screen.
31
+ *
32
+ * They are stored on the navigation route as `NavigationScreenData.options`
33
+ * and read on the target screen via `useNavigation().data?.options`. Use this
34
+ * to hand per-navigation parameters to a screen instead of routing them
35
+ * through module-level state.
36
+ *
37
+ * Note: `legacyScreenData()` does not carry these values, so they are not
38
+ * visible through `useCurrentScreenData()` / `useRoute()`.
39
+ */
40
+ navigationOptions?: Record<string, unknown>;
41
+ }
42
+
43
+ /**
44
+ * Creates a navigation action handler with the provided dependencies.
45
+ * This factory pattern allows the action to access navigation state at runtime.
46
+ *
47
+ * @param navigator - The app navigator for push/replace operations
48
+ * @param rivers - Map of screen IDs to river definitions
49
+ * @param contentTypes - Map of content type names to screen configurations
50
+ * @returns An action handler that performs screen navigation
51
+ */
52
+ export function createNavigateToScreenAction(
53
+ navigator: QuickBrickAppNavigator,
54
+ rivers: Record<string, ZappRiver>,
55
+ contentTypes: ZappContentTypes
56
+ ): ActionHandler<NavigateToScreenOptions> {
57
+ return async function navigateToScreenAction(
58
+ action,
59
+ context?: ActionExecutionContext
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
+ const navigationAction = action.options?.navigationAction;
70
+ const entrySource = action.options?.entry;
71
+ const navigationOptions = action.options?.navigationOptions;
72
+
73
+ const entry = entrySource
74
+ ? entrySource === "@{entry/}"
75
+ ? context?.entry
76
+ : entrySource
77
+ : null;
78
+
79
+ if (entry) {
80
+ if (typeof entry !== "object") {
81
+ log_error(
82
+ `navigateToScreen: entry option is not an object, entry: ${entry}`
83
+ );
84
+
85
+ return ActionResult.Error;
86
+ }
87
+
88
+ log_info(
89
+ `navigateToScreen: navigating to screen type: ${screenType} with entry id: ${entry.id}`
90
+ );
91
+
92
+ const overriddenEntry: ZappEntry = {
93
+ ...entry,
94
+ type: {
95
+ value: screenType,
96
+ },
97
+ };
98
+
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);
104
+ }
105
+
106
+ return ActionResult.Success;
107
+ }
108
+
109
+ const screenId = contentTypes?.[screenType]?.screen_id || null;
110
+
111
+ if (!screenId) {
112
+ log_error(
113
+ `navigateToScreen: can not resolve screen type mapping: ${screenType}`
114
+ );
115
+
116
+ return ActionResult.Error;
117
+ }
118
+
119
+ const river = rivers[screenId];
120
+
121
+ if (!river) {
122
+ log_error("navigateToScreen: can not resolve river");
123
+
124
+ return ActionResult.Error;
125
+ }
126
+
127
+ 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
+ }
134
+
135
+ return ActionResult.Success;
136
+ };
137
+ }
@@ -0,0 +1,320 @@
1
+ /// <reference types="@applicaster/applicaster-types" />
2
+ import {
3
+ PipesClientResponseHelper,
4
+ RequestBuilder,
5
+ } from "@applicaster/zapp-pipes-v2-client";
6
+ import uuidv4 from "uuid/v4";
7
+ import { modalOrchestrator } from "../../modalState/ModalOrchestrator";
8
+ import { openBottomSheetModal } from "../../modalState/store";
9
+ import {
10
+ DynamicCollectionOptions,
11
+ isPresentSubMenuAction,
12
+ Menu,
13
+ MenuItem,
14
+ Operation,
15
+ SelectionBehavior,
16
+ } from "../../modalState/types";
17
+ import { actionExecutor, ActionResult } from "../ActionExecutor";
18
+ import { createLogger } from "../../logger";
19
+
20
+ const { log_info, log_error } = createLogger({
21
+ subsystem: "ActionExecutorContext",
22
+ category: "General",
23
+ });
24
+
25
+ export type LoadedSheetContent = {
26
+ items: MenuItem[];
27
+ role?: string;
28
+ behavior?: SelectionBehavior;
29
+ dynamicCollection?: DynamicCollectionOptions;
30
+ };
31
+
32
+ /**
33
+ * Parse a raw `dynamic_collection_options` block (feed or inline content) into
34
+ * the typed `DynamicCollectionOptions`. `operations` accepts either a CSV
35
+ * string (feed) or an array (already parsed).
36
+ */
37
+ export function parseDynamicCollectionOptions(
38
+ raw:
39
+ | {
40
+ operations?: string | string[];
41
+ postUrl?: string;
42
+ provider?: string;
43
+ events?: Record<string, any[]>;
44
+ }
45
+ | undefined
46
+ ): DynamicCollectionOptions | undefined {
47
+ if (!raw) {
48
+ return undefined;
49
+ }
50
+
51
+ const operations = Array.isArray(raw.operations)
52
+ ? (raw.operations as Operation[])
53
+ : ((raw.operations || "").split(",").filter(Boolean) as Operation[]);
54
+
55
+ return {
56
+ operations,
57
+ postUrl: raw.postUrl,
58
+ provider: raw.provider,
59
+ events: raw.events,
60
+ };
61
+ }
62
+
63
+ /**
64
+ * Converts a ZappEntry from a pipes feed into a MenuItem.
65
+ * - Icon: first src found in the image media_group.
66
+ * - Primary action: taken from tap_actions.actions[0].
67
+ * - isSelected: true when entry.id is in currentSelection.
68
+ */
69
+ export function entryToMenuItem(
70
+ entry: ZappEntry,
71
+ currentSelection: string[] = []
72
+ ): MenuItem {
73
+ const imageGroup = entry.media_group?.find((g) => g.type === "image");
74
+
75
+ const firstImage = Array.isArray(imageGroup?.media_item)
76
+ ? imageGroup.media_item[0]
77
+ : imageGroup?.media_item;
78
+
79
+ // Primary action — first tap_action on the entry
80
+ const tapActions = entry.extensions?.tap_actions?.actions || [];
81
+ const primaryAction = tapActions.length > 0 ? tapActions[0] : undefined;
82
+
83
+ const summary = entry.summary as string;
84
+
85
+ const itemId = String(entry.id ?? entry.title ?? uuidv4());
86
+
87
+ return {
88
+ id: itemId,
89
+ title: entry.title as string,
90
+ summary,
91
+ icon: firstImage?.src,
92
+ isSelected: currentSelection.includes(itemId),
93
+ action: primaryAction,
94
+ entryActions: entry.extensions?.entry_action || [],
95
+ };
96
+ }
97
+
98
+ function parseCurrentSelection(rawSelection: unknown): string[] {
99
+ if (Array.isArray(rawSelection)) {
100
+ return (rawSelection as any[]).map(String);
101
+ }
102
+
103
+ if (rawSelection !== undefined && rawSelection !== null) {
104
+ return [String(rawSelection)];
105
+ }
106
+
107
+ return [];
108
+ }
109
+
110
+ function parseBehaviorFromFeed(
111
+ feed: ZappFeed | undefined,
112
+ currentSelection: string[]
113
+ ): SelectionBehavior | undefined {
114
+ const raw = feed?.extensions?.behavior;
115
+
116
+ if (!raw && currentSelection.length === 0) {
117
+ return undefined;
118
+ }
119
+
120
+ return {
121
+ selectMode: raw?.select_mode,
122
+ currentSelection,
123
+ selector: raw?.selector,
124
+ };
125
+ }
126
+
127
+ function parseBehaviorFromContentOptions(
128
+ content: Record<string, any> | undefined
129
+ ): SelectionBehavior | undefined {
130
+ const raw = content?.behavior ?? content?.extensions?.behavior;
131
+
132
+ if (!raw) {
133
+ return undefined;
134
+ }
135
+
136
+ return {
137
+ selectMode: raw.selectMode ?? raw.select_mode,
138
+ currentSelection: parseCurrentSelection(
139
+ raw.currentSelection ?? raw.current_selection
140
+ ),
141
+ selector: raw.selector,
142
+ };
143
+ }
144
+
145
+ // Exported so MultiLevelBottomSheetContent can lazy-load sub-levels
146
+ export async function loadItemsFromSource(
147
+ source: string,
148
+ context?: Record<string, any>
149
+ ): Promise<LoadedSheetContent> {
150
+ const requestBuilder = new RequestBuilder()
151
+ .setEntryContext(context?.entry || {})
152
+ .setScreenContext(context?.screenData || {})
153
+ .setUrl(source);
154
+
155
+ await requestBuilder.buildAxiosRequest();
156
+
157
+ const responseData = await requestBuilder.call<ZappFeed>();
158
+
159
+ const responseHelper = new PipesClientResponseHelper(responseData);
160
+
161
+ if (responseHelper.error) {
162
+ throw responseHelper.error;
163
+ }
164
+
165
+ const feed = responseData?.response as ZappFeed;
166
+
167
+ const currentSelection = parseCurrentSelection(
168
+ feed?.extensions?.behavior?.current_selection
169
+ );
170
+
171
+ const items = (feed?.entry || []).map((entry) =>
172
+ entryToMenuItem(entry, currentSelection)
173
+ );
174
+
175
+ const dynamicCollectionOptions = feed?.extensions?.dynamic_collection_options;
176
+
177
+ const dynamicCollection = parseDynamicCollectionOptions(
178
+ dynamicCollectionOptions
179
+ );
180
+
181
+ return {
182
+ items,
183
+ role: feed?.extensions?.role,
184
+ behavior: parseBehaviorFromFeed(feed, currentSelection),
185
+ dynamicCollection,
186
+ };
187
+ }
188
+
189
+ export async function openBottomSheetAction(
190
+ action: ActionType,
191
+ context?: Record<string, any>
192
+ ): Promise<ActionResult> {
193
+ try {
194
+ const { content, header, themePluginId, styleOverrides } =
195
+ action.options || {};
196
+
197
+ // Custom body component — keep default ModalComponent so standard header
198
+ // (dismiss x) is used; content.component is body-only (e.g. TextInputContent).
199
+ if (content?.component) {
200
+ log_info("openBottomSheet: using custom content component");
201
+
202
+ openBottomSheetModal({
203
+ modalBottomSheetContentProps: {
204
+ title: header?.title,
205
+ summary: header?.subtitle,
206
+ items: [],
207
+ onPress: () => {},
208
+ contentComponent: content.component,
209
+ contentComponentProps: content.props || {},
210
+ },
211
+ });
212
+
213
+ return ActionResult.Success;
214
+ }
215
+
216
+ const inlineItems: ZappEntry[] = content?.items;
217
+ const itemsUrl: string = content?.itemsUrl;
218
+
219
+ let items: MenuItem[];
220
+ let role: string | undefined;
221
+ let behavior: SelectionBehavior | undefined;
222
+
223
+ let dynamicCollection: DynamicCollectionOptions | undefined;
224
+
225
+ if (Array.isArray(inlineItems) && inlineItems.length > 0) {
226
+ log_info("openBottomSheet: using inline items from action options", {
227
+ count: inlineItems.length,
228
+ });
229
+
230
+ role = content?.role ?? content?.extensions?.role;
231
+ behavior = parseBehaviorFromContentOptions(content);
232
+
233
+ items = inlineItems.map((entry) =>
234
+ entryToMenuItem(entry, behavior?.currentSelection ?? [])
235
+ );
236
+
237
+ dynamicCollection = parseDynamicCollectionOptions(
238
+ content?.dynamicCollection ??
239
+ content?.extensions?.dynamic_collection_options
240
+ );
241
+ } else if (itemsUrl) {
242
+ log_info(`openBottomSheet: loading items from source: ${itemsUrl}`);
243
+
244
+ const loaded = await loadItemsFromSource(itemsUrl, context);
245
+ items = loaded.items;
246
+ role = loaded.role ?? content?.role ?? content?.extensions?.role;
247
+ behavior = loaded.behavior ?? parseBehaviorFromContentOptions(content);
248
+ dynamicCollection = loaded.dynamicCollection;
249
+
250
+ log_info(
251
+ `openBottomSheet: loaded ${items.length} items from source: ${itemsUrl}`
252
+ );
253
+ } else {
254
+ log_error(
255
+ "openBottomSheet: no itemsUrl, items, or content.component provided in action options"
256
+ );
257
+
258
+ return ActionResult.Error;
259
+ }
260
+
261
+ const menu: Menu = {
262
+ header: header
263
+ ? {
264
+ title: header.title,
265
+ subtitle: header.subtitle,
266
+ icon: header.icon,
267
+ }
268
+ : undefined,
269
+ content: {
270
+ title: content?.title ?? "",
271
+ items,
272
+ itemsUrl, // stored so the component can reload after an action
273
+ role,
274
+ behavior,
275
+ dynamicCollection,
276
+ themePluginId,
277
+ styleOverrides: styleOverrides ?? content?.styleOverrides,
278
+ },
279
+ };
280
+
281
+ /**
282
+ * Called when the user taps a menu item.
283
+ *
284
+ * - PresentSubMenuAction → handled by the orchestrator (pushes sub-menu)
285
+ * - Any other Action type → forwarded to the action executor, keeping the
286
+ * original execution context so screen/entry data is available to handlers.
287
+ * The pressed item is also added as `entry` so downstream actions can
288
+ * reference it.
289
+ */
290
+ 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
+ }
295
+
296
+ await actionExecutor.handleAction(
297
+ item.action as ActionType,
298
+ {
299
+ ...context,
300
+ entry: item as any,
301
+ } as any
302
+ );
303
+ };
304
+
305
+ if (action.options?.replace) {
306
+ modalOrchestrator.replace(menu, onItemPress);
307
+ } else {
308
+ modalOrchestrator.open(menu, onItemPress);
309
+ }
310
+
311
+ return ActionResult.Success;
312
+ } catch (error) {
313
+ log_error("openBottomSheet: failed to open bottom sheet", {
314
+ error,
315
+ action,
316
+ });
317
+
318
+ return ActionResult.Error;
319
+ }
320
+ }
@@ -0,0 +1,85 @@
1
+ /// <reference types="@applicaster/applicaster-types" />
2
+ import { appStore } from "@applicaster/zapp-react-native-redux/AppStore";
3
+ import { loadPipesData } from "@applicaster/zapp-react-native-redux/ZappPipes";
4
+ import {
5
+ getInflatedDataSourceUrl,
6
+ getSearchContext,
7
+ } from "../../reactHooks/feed/useInflatedUrl";
8
+ import { ActionResult } from "../ActionExecutor";
9
+ import { ActionHandler, ActionExecutionContext } from "../types";
10
+ import { createLogger } from "../../logger";
11
+
12
+ const { log_info } = createLogger({
13
+ subsystem: "ActionExecutorContext",
14
+ category: "General",
15
+ });
16
+
17
+ /** Prefer component data.source, otherwise direct UIComponentContext parent. */
18
+ function getComponentFeedData(component) {
19
+ if (component?.data?.source) {
20
+ return component.data;
21
+ }
22
+
23
+ if (component?.parent?.data?.source) {
24
+ return component.parent.data;
25
+ }
26
+
27
+ return null;
28
+ }
29
+
30
+ /**
31
+ * Refreshes a component's data by reloading its data source.
32
+ * Supports URL inflation with context variables.
33
+ */
34
+ export const refreshComponentAction: ActionHandler = async (
35
+ _action,
36
+ context?: ActionExecutionContext
37
+ ): Promise<ActionResult> => {
38
+ const dispatch = appStore.getDispatch();
39
+
40
+ const componentData = getComponentFeedData(context?.component);
41
+
42
+ const source = componentData?.source;
43
+ const mapping = componentData?.mapping;
44
+
45
+ let dataSource = source;
46
+
47
+ if (source && mapping) {
48
+ dataSource =
49
+ getInflatedDataSourceUrl({
50
+ source,
51
+ contexts: {
52
+ entry: context?.screenEntry,
53
+ screen: context?.screenData,
54
+ search: getSearchContext(null, mapping),
55
+ },
56
+ mapping,
57
+ }) || source;
58
+ }
59
+
60
+ if (!dataSource) {
61
+ log_info("handleAction: refreshComponent skipped: no dataSource found");
62
+
63
+ return ActionResult.Success;
64
+ }
65
+
66
+ log_info(`handleAction: refreshComponent for dataSource:${dataSource}`, {
67
+ source,
68
+ inflatedUrl: dataSource,
69
+ mapping,
70
+ entryContextId: context?.entryContext?.id,
71
+ entryId: context?.entry?.id,
72
+ });
73
+
74
+ // TODO: In theory we should wait callback to complete, before completing the action, but now it's not needed
75
+ // TODO: handle focused item removal
76
+ dispatch(
77
+ loadPipesData(dataSource, {
78
+ silentRefresh: false,
79
+ clearCache: true,
80
+ riverId: context?.screenData?.id,
81
+ })
82
+ );
83
+
84
+ return ActionResult.Success;
85
+ };
@@ -0,0 +1,35 @@
1
+ /// <reference types="@applicaster/applicaster-types" />
2
+ import { screenSetVariable } from "../ScreenActions";
3
+ import { ActionResult } from "../ActionExecutor";
4
+ import { ActionHandler, ActionExecutionContext } from "../types";
5
+
6
+ /**
7
+ * Options for screenSetVariable action.
8
+ */
9
+ export interface ScreenSetVariableOptions {
10
+ /** The key/namespace for storing the variable */
11
+ key: string;
12
+
13
+ /** Path to extract the value from entry */
14
+ selector?: string;
15
+ }
16
+
17
+ /**
18
+ * Sets a variable in screen state storage.
19
+ * The value is extracted from the entry using the selector option.
20
+ */
21
+ export const screenSetVariableAction: ActionHandler<
22
+ ScreenSetVariableOptions
23
+ > = async (action, context?: ActionExecutionContext): Promise<ActionResult> => {
24
+ const route = context?.screenRoute;
25
+ const screenStateStore = context?.screenStateStore;
26
+
27
+ await screenSetVariable(
28
+ route,
29
+ screenStateStore,
30
+ { entry: context?.entry, options: action.options },
31
+ action
32
+ );
33
+
34
+ return ActionResult.Success;
35
+ };
@@ -0,0 +1,38 @@
1
+ /// <reference types="@applicaster/applicaster-types" />
2
+ import { screenToggleFlag } from "../ScreenActions";
3
+ import { ActionResult } from "../ActionExecutor";
4
+ import { ActionHandler, ActionExecutionContext } from "../types";
5
+
6
+ /**
7
+ * Options for screenToggleFlag action.
8
+ */
9
+ export interface ScreenToggleFlagOptions {
10
+ /** The key/namespace for storing the flag */
11
+ key: string;
12
+
13
+ /** Path to extract the tag from entry (e.g., "extensions.tag") */
14
+ selector?: string;
15
+
16
+ /** Maximum number of items that can be selected */
17
+ max_items?: number;
18
+ }
19
+
20
+ /**
21
+ * Toggles a flag in screen state storage (adds or removes an item from a collection).
22
+ * Useful for screen-level multi-select functionality.
23
+ */
24
+ export const screenToggleFlagAction: ActionHandler<
25
+ ScreenToggleFlagOptions
26
+ > = async (action, context?: ActionExecutionContext): Promise<ActionResult> => {
27
+ const screenRoute = context?.screenRoute;
28
+ const screenStateStore = context?.screenStateStore;
29
+
30
+ await screenToggleFlag(
31
+ screenRoute,
32
+ screenStateStore,
33
+ { entry: context?.entry, options: action.options },
34
+ action
35
+ );
36
+
37
+ return ActionResult.Success;
38
+ };