@applicaster/zapp-react-native-utils 16.0.0-alpha.1052711356 → 16.0.0-alpha.1054344748
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.
- package/actionsExecutor/ActionExecutor.ts +50 -3
- package/actionsExecutor/ActionExecutorContext.tsx +97 -19
- package/actionsExecutor/__tests__/ActionExecutor.test.ts +71 -0
- package/actionsExecutor/__tests__/feedDecorator.test.ts +61 -0
- package/actionsExecutor/actions/__tests__/dismissBottomSheet.test.ts +3 -0
- package/actionsExecutor/actions/__tests__/goBack.test.ts +62 -0
- package/actionsExecutor/actions/__tests__/goHome.test.ts +19 -0
- package/actionsExecutor/actions/__tests__/navigateToScreen.test.ts +133 -0
- package/actionsExecutor/actions/__tests__/openBottomSheet.inlineItems.test.ts +300 -0
- package/actionsExecutor/actions/__tests__/presentScreen.test.ts +127 -0
- package/actionsExecutor/actions/__tests__/showAlert.test.ts +49 -0
- package/actionsExecutor/actions/__tests__/showToast.test.ts +29 -4
- package/actionsExecutor/actions/dismissBottomSheet.ts +2 -1
- package/actionsExecutor/actions/goBack.ts +60 -0
- package/actionsExecutor/actions/goHome.ts +31 -0
- package/actionsExecutor/actions/index.ts +8 -0
- package/actionsExecutor/actions/navigateToScreen.ts +18 -4
- package/actionsExecutor/actions/openBottomSheet.ts +51 -31
- package/actionsExecutor/actions/presentScreen.ts +78 -0
- package/actionsExecutor/actions/sendCloudEvent.ts +5 -8
- package/actionsExecutor/actions/showAlert.ts +51 -0
- package/actionsExecutor/actions/showToast.ts +62 -6
- package/actionsExecutor/consts.ts +27 -0
- package/actionsExecutor/feedDecorator.ts +6 -6
- package/analyticsUtils/PlayerAnalyticsManager.ts +1 -1
- package/appUtils/HooksManager/index.ts +9 -0
- package/appUtils/playerManager/OverlayObserver/OverlaysObserver.ts +142 -59
- package/appUtils/playerManager/OverlayObserver/__tests__/getUpcomingQueue.test.ts +67 -0
- package/appUtils/playerManager/OverlayObserver/__tests__/liveContent.test.ts +205 -0
- package/appUtils/playerManager/OverlayObserver/__tests__/utils.test.ts +56 -0
- package/appUtils/playerManager/OverlayObserver/getUpcomingQueue.android.tv.ts +4 -0
- package/appUtils/playerManager/OverlayObserver/getUpcomingQueue.ios.tv.ts +4 -0
- package/appUtils/playerManager/OverlayObserver/getUpcomingQueue.ts +24 -0
- package/appUtils/playerManager/OverlayObserver/getUpcomingQueue.web.ts +4 -0
- package/appUtils/playerManager/OverlayObserver/utils.ts +51 -20
- package/appUtils/playerManager/__tests__/playerContent.test.ts +403 -0
- package/appUtils/playerManager/__tests__/playerFactory.test.ts +1 -1
- package/appUtils/playerManager/__tests__/playerNative.test.ts +114 -0
- package/appUtils/playerManager/__tests__/playerNativeCommand.test.ts +62 -0
- package/appUtils/playerManager/__tests__/playerToolbox.test.ts +97 -0
- package/appUtils/playerManager/__tests__/usePlayerContent.test.tsx +64 -0
- package/appUtils/playerManager/{conts.ts → const.ts} +33 -0
- package/appUtils/playerManager/index.ts +3 -1
- package/appUtils/playerManager/player.ts +125 -3
- package/appUtils/playerManager/playerFactory.ts +1 -1
- package/appUtils/playerManager/playerNative.ts +28 -4
- package/appUtils/playerManager/playerNativeCommand.ts +3 -6
- package/appUtils/playerManager/playerToolbox.ts +192 -0
- package/appUtils/playerManager/usePlayerContent.tsx +43 -0
- package/appUtils/playerManager/usePlayerControllerSetup.tsx +1 -1
- package/appUtils/playerManager/userLanguagePreference.ts +1 -1
- package/arrayUtils/__tests__/reorderByIds.test.ts +63 -0
- package/arrayUtils/index.ts +62 -0
- package/cellUtils/index.ts +30 -3
- package/configurationUtils/__tests__/manifestKeyParser.test.ts +21 -0
- package/configurationUtils/__tests__/modalBlocksParser.test.ts +269 -0
- package/configurationUtils/manifestKeyParser.ts +50 -10
- package/configurationUtils/modalBlocksParser.ts +214 -0
- package/entryActions/__tests__/buildEntryActions.test.ts +235 -0
- package/entryActions/aliasPresentation.ts +108 -0
- package/entryActions/buildEntryActions.ts +167 -0
- package/entryActions/index.ts +15 -0
- package/entryActions/types.ts +39 -0
- package/manifestUtils/__tests__/player.audioControls.test.js +158 -0
- package/manifestUtils/_internals/index.js +8 -3
- package/manifestUtils/defaultManifestConfigurations/generalContent.js +6 -0
- package/manifestUtils/defaultManifestConfigurations/player.js +330 -1
- package/manifestUtils/index.js +3 -0
- package/manifestUtils/modalBlocks.js +304 -0
- package/modalState/ContentViewModel.ts +2 -0
- package/modalState/ModalOrchestrator.ts +23 -9
- package/modalState/RemoteEditableCollection.ts +77 -31
- package/modalState/__tests__/ContentViewModel.test.ts +3 -3
- package/modalState/__tests__/ModalOrchestrator.phase3.test.ts +35 -0
- package/modalState/__tests__/RemoteEditableCollection.test.ts +157 -1
- package/modalState/__tests__/index.test.ts +30 -1
- package/modalState/__tests__/useBottomSheetContent.test.ts +0 -23
- package/modalState/__tests__/useModalStoreState.test.ts +142 -0
- package/modalState/index.ts +6 -1
- package/modalState/store.ts +9 -2
- package/modalState/types.ts +56 -4
- package/modalState/useBottomSheetContent.ts +37 -26
- package/package.json +2 -2
- package/playerUtils/__tests__/contentDataKeys.test.ts +297 -0
- package/playerUtils/__tests__/resolvePlayerActions.test.ts +138 -0
- package/playerUtils/__tests__/resolvePlayerTitleSubtitle.test.ts +180 -0
- package/playerUtils/contentDataKeys.ts +134 -0
- package/playerUtils/index.ts +37 -16
- package/playerUtils/isAudioItem.ts +26 -0
- package/playerUtils/resolvePlayerActions.ts +71 -0
- package/playerUtils/resolvePlayerTitleSubtitle.ts +76 -0
- package/pluginUtils/__tests__/pluginUtils.test.js +32 -0
- package/pluginUtils/index.ts +29 -0
- package/reactHooks/actions/index.ts +67 -2
- package/reactHooks/cell-click/__tests__/index.test.js +64 -0
- package/reactHooks/cell-click/index.ts +21 -14
- package/reactHooks/connection/index.tsx +8 -5
- package/reactHooks/feed/__tests__/useMarkPipesDataStale.test.tsx +243 -0
- package/reactHooks/feed/useMarkPipesDataStale.ts +68 -23
- package/reactHooks/index.ts +2 -0
- package/reactHooks/layout/index.ts +1 -1
- package/reactHooks/navigation/__tests__/index.test.tsx +176 -1
- package/reactHooks/navigation/__tests__/usePresentScreen.test.ts +154 -0
- package/reactHooks/navigation/index.ts +2 -0
- package/reactHooks/navigation/usePresentScreen.ts +157 -0
- package/reactHooks/navigation/useRoute.ts +22 -5
- package/reactHooks/usePluginConfiguration.ts +4 -1
- package/reactHooks/utils/__tests__/index.test.js +22 -2
- package/reactHooks/utils/index.ts +11 -1
- package/uiActionsRegistrator/__tests__/resolveActionIdentifiers.test.ts +93 -0
- package/uiActionsRegistrator/__tests__/subscribe.test.ts +133 -0
- package/uiActionsRegistrator/__tests__/usableActionItems.test.ts +52 -0
- package/uiActionsRegistrator/index.ts +25 -203
- package/uiActionsRegistrator/registry.ts +351 -0
- package/uiActionsRegistrator/resolveActionIdentifiers.ts +100 -0
- package/uiActionsRegistrator/usableActionItems.ts +66 -0
- package/zappFrameworkUtils/localStorageHelper.ts +10 -2
- package/appUtils/playerManager/usePlayerTitleSummaryOverlay.tsx +0 -56
- package/playerUtils/__tests__/getPlayerActionButtons.test.ts +0 -54
- package/playerUtils/getPlayerActionButtons.ts +0 -17
|
@@ -25,6 +25,19 @@ export interface NavigateToScreenOptions {
|
|
|
25
25
|
* - undefined to navigate to screen without entry
|
|
26
26
|
*/
|
|
27
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>;
|
|
28
41
|
}
|
|
29
42
|
|
|
30
43
|
/**
|
|
@@ -55,6 +68,7 @@ export function createNavigateToScreenAction(
|
|
|
55
68
|
|
|
56
69
|
const navigationAction = action.options?.navigationAction;
|
|
57
70
|
const entrySource = action.options?.entry;
|
|
71
|
+
const navigationOptions = action.options?.navigationOptions;
|
|
58
72
|
|
|
59
73
|
const entry = entrySource
|
|
60
74
|
? entrySource === "@{entry/}"
|
|
@@ -83,10 +97,10 @@ export function createNavigateToScreenAction(
|
|
|
83
97
|
};
|
|
84
98
|
|
|
85
99
|
if (navigationAction === "push") {
|
|
86
|
-
navigator.push(overriddenEntry);
|
|
100
|
+
navigator.push(overriddenEntry, navigationOptions);
|
|
87
101
|
} else {
|
|
88
102
|
// Use replaceTop for entries since replace() only accepts ZappRiver
|
|
89
|
-
navigator.replaceTop(overriddenEntry);
|
|
103
|
+
navigator.replaceTop(overriddenEntry, navigationOptions);
|
|
90
104
|
}
|
|
91
105
|
|
|
92
106
|
return ActionResult.Success;
|
|
@@ -113,9 +127,9 @@ export function createNavigateToScreenAction(
|
|
|
113
127
|
context?.callback?.({ success: false, error: null, abort: true });
|
|
114
128
|
|
|
115
129
|
if (navigationAction === "push") {
|
|
116
|
-
navigator.push(river);
|
|
130
|
+
navigator.push(river, navigationOptions);
|
|
117
131
|
} else {
|
|
118
|
-
navigator.replace(river);
|
|
132
|
+
navigator.replace(river, navigationOptions);
|
|
119
133
|
}
|
|
120
134
|
|
|
121
135
|
return ActionResult.Success;
|
|
@@ -3,10 +3,12 @@ import {
|
|
|
3
3
|
PipesClientResponseHelper,
|
|
4
4
|
RequestBuilder,
|
|
5
5
|
} from "@applicaster/zapp-pipes-v2-client";
|
|
6
|
+
import uuidv4 from "uuid/v4";
|
|
6
7
|
import { modalOrchestrator } from "../../modalState/ModalOrchestrator";
|
|
7
8
|
import { openBottomSheetModal } from "../../modalState/store";
|
|
8
9
|
import {
|
|
9
10
|
DynamicCollectionOptions,
|
|
11
|
+
getMenuItemActions,
|
|
10
12
|
isPresentSubMenuAction,
|
|
11
13
|
Menu,
|
|
12
14
|
MenuItem,
|
|
@@ -79,26 +81,18 @@ export function entryToMenuItem(
|
|
|
79
81
|
const tapActions = entry.extensions?.tap_actions?.actions || [];
|
|
80
82
|
const primaryAction = tapActions.length > 0 ? tapActions[0] : undefined;
|
|
81
83
|
|
|
82
|
-
|
|
84
|
+
const summary = entry.summary as string;
|
|
83
85
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
if (
|
|
87
|
-
!summary &&
|
|
88
|
-
entry.extensions &&
|
|
89
|
-
typeof entry.extensions.item_count === "number"
|
|
90
|
-
) {
|
|
91
|
-
const count = entry.extensions.item_count;
|
|
92
|
-
summary = `${count} ${count === 1 ? "Item" : "Items"}`;
|
|
93
|
-
}
|
|
86
|
+
const itemId = String(entry.id ?? entry.title ?? uuidv4());
|
|
94
87
|
|
|
95
88
|
return {
|
|
96
|
-
id:
|
|
89
|
+
id: itemId,
|
|
97
90
|
title: entry.title as string,
|
|
98
91
|
summary,
|
|
99
92
|
icon: firstImage?.src,
|
|
100
|
-
isSelected: currentSelection.includes(
|
|
93
|
+
isSelected: currentSelection.includes(itemId),
|
|
101
94
|
action: primaryAction,
|
|
95
|
+
actions: tapActions,
|
|
102
96
|
entryActions: entry.extensions?.entry_action || [],
|
|
103
97
|
};
|
|
104
98
|
}
|
|
@@ -199,7 +193,8 @@ export async function openBottomSheetAction(
|
|
|
199
193
|
context?: Record<string, any>
|
|
200
194
|
): Promise<ActionResult> {
|
|
201
195
|
try {
|
|
202
|
-
const { content, header } =
|
|
196
|
+
const { content, header, themePluginId, styleOverrides } =
|
|
197
|
+
action.options || {};
|
|
203
198
|
|
|
204
199
|
// Custom body component — keep default ModalComponent so standard header
|
|
205
200
|
// (dismiss x) is used; content.component is body-only (e.g. TextInputContent).
|
|
@@ -213,7 +208,10 @@ export async function openBottomSheetAction(
|
|
|
213
208
|
items: [],
|
|
214
209
|
onPress: () => {},
|
|
215
210
|
contentComponent: content.component,
|
|
216
|
-
contentComponentProps:
|
|
211
|
+
contentComponentProps: {
|
|
212
|
+
...(content.props || {}),
|
|
213
|
+
actionContext: context,
|
|
214
|
+
},
|
|
217
215
|
},
|
|
218
216
|
});
|
|
219
217
|
|
|
@@ -229,19 +227,30 @@ export async function openBottomSheetAction(
|
|
|
229
227
|
|
|
230
228
|
let dynamicCollection: DynamicCollectionOptions | undefined;
|
|
231
229
|
|
|
232
|
-
|
|
230
|
+
const rawDynamicCollection =
|
|
231
|
+
content?.dynamicCollection ??
|
|
232
|
+
content?.extensions?.dynamic_collection_options;
|
|
233
|
+
|
|
234
|
+
// An empty items array is a valid starting state for a provider-backed or
|
|
235
|
+
// offline collection. A sheet with neither items nor a source still errors.
|
|
236
|
+
const hasDynamicCollection = Boolean(rawDynamicCollection);
|
|
237
|
+
|
|
238
|
+
if (
|
|
239
|
+
Array.isArray(inlineItems) &&
|
|
240
|
+
(inlineItems.length > 0 || hasDynamicCollection)
|
|
241
|
+
) {
|
|
233
242
|
log_info("openBottomSheet: using inline items from action options", {
|
|
234
243
|
count: inlineItems.length,
|
|
235
244
|
});
|
|
236
245
|
|
|
237
|
-
items = inlineItems.map((entry) => entryToMenuItem(entry));
|
|
238
246
|
role = content?.role ?? content?.extensions?.role;
|
|
239
247
|
behavior = parseBehaviorFromContentOptions(content);
|
|
240
248
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
content?.extensions?.dynamic_collection_options
|
|
249
|
+
items = inlineItems.map((entry) =>
|
|
250
|
+
entryToMenuItem(entry, behavior?.currentSelection ?? [])
|
|
244
251
|
);
|
|
252
|
+
|
|
253
|
+
dynamicCollection = parseDynamicCollectionOptions(rawDynamicCollection);
|
|
245
254
|
} else if (itemsUrl) {
|
|
246
255
|
log_info(`openBottomSheet: loading items from source: ${itemsUrl}`);
|
|
247
256
|
|
|
@@ -277,6 +286,10 @@ export async function openBottomSheetAction(
|
|
|
277
286
|
role,
|
|
278
287
|
behavior,
|
|
279
288
|
dynamicCollection,
|
|
289
|
+
themePluginId,
|
|
290
|
+
styleOverrides: styleOverrides ?? content?.styleOverrides,
|
|
291
|
+
emptyMessage: content?.emptyMessage,
|
|
292
|
+
context,
|
|
280
293
|
},
|
|
281
294
|
};
|
|
282
295
|
|
|
@@ -290,21 +303,28 @@ export async function openBottomSheetAction(
|
|
|
290
303
|
* reference it.
|
|
291
304
|
*/
|
|
292
305
|
const onItemPress = async (item: MenuItem): Promise<void> => {
|
|
293
|
-
|
|
294
|
-
// Submenu navigation is handled internally by the orchestrator
|
|
295
|
-
return;
|
|
296
|
-
}
|
|
306
|
+
const actions = getMenuItemActions(item);
|
|
297
307
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
{
|
|
301
|
-
...context,
|
|
302
|
-
entry: item as any,
|
|
303
|
-
} as any
|
|
308
|
+
const executableActions = actions.filter(
|
|
309
|
+
(action) => !isPresentSubMenuAction(action)
|
|
304
310
|
);
|
|
311
|
+
|
|
312
|
+
if (executableActions.length > 0) {
|
|
313
|
+
await actionExecutor.handleActions(
|
|
314
|
+
executableActions as ActionType[],
|
|
315
|
+
{
|
|
316
|
+
...context,
|
|
317
|
+
entry: item as any,
|
|
318
|
+
} as any
|
|
319
|
+
);
|
|
320
|
+
}
|
|
305
321
|
};
|
|
306
322
|
|
|
307
|
-
|
|
323
|
+
if (action.options?.replace) {
|
|
324
|
+
modalOrchestrator.replace(menu, onItemPress);
|
|
325
|
+
} else {
|
|
326
|
+
modalOrchestrator.open(menu, onItemPress);
|
|
327
|
+
}
|
|
308
328
|
|
|
309
329
|
return ActionResult.Success;
|
|
310
330
|
} catch (error) {
|
|
@@ -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
|
+
}
|
|
@@ -62,17 +62,14 @@ export const sendCloudEventAction: ActionHandler<
|
|
|
62
62
|
subject: options.subject || String((entry as ZappEntry)?.id || ""),
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
);
|
|
70
|
-
|
|
71
|
-
log_info("handleAction: sendCloudEvent event", { cloudEvent });
|
|
65
|
+
log_info("handleAction: sending sendCloudEvent to URL", {
|
|
66
|
+
url: options.url,
|
|
67
|
+
cloudEvent,
|
|
68
|
+
});
|
|
72
69
|
|
|
73
70
|
const { error, code } = await sendCloudEvent(cloudEvent, options.url);
|
|
74
71
|
|
|
75
|
-
|
|
72
|
+
log_info("handleAction: sendCloudEvent result", { code, error });
|
|
76
73
|
|
|
77
74
|
if (error) {
|
|
78
75
|
log_error("sendCloudEvent: error sending cloud event", { error });
|
|
@@ -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
|
+
};
|
|
@@ -3,8 +3,61 @@ import { ActionResult } from "../ActionExecutor";
|
|
|
3
3
|
import { ActionHandler } from "../types";
|
|
4
4
|
import { postEvent } from "../../reactHooks/useSubscriberFor";
|
|
5
5
|
|
|
6
|
+
export const CONFIRMATION_TOAST_SOURCE = "confirmation";
|
|
7
|
+
|
|
8
|
+
export const CONFIRMATION_TOAST_DEFAULT_TIMEOUT = 5000;
|
|
9
|
+
|
|
6
10
|
/**
|
|
7
|
-
*
|
|
11
|
+
* Shows a mobile confirmation toast with Theme defaults from
|
|
12
|
+
* `Confirmation Toast / Message` in the base theme plugin.
|
|
13
|
+
*
|
|
14
|
+
* This action is confirmation-only by design: it always stamps
|
|
15
|
+
* `source: "confirmation"` (so Theme confirmation styles apply) and defaults
|
|
16
|
+
* `timeout` to 5000 ms. Non-confirmation toasts (e.g. Offline Experience)
|
|
17
|
+
* must post on the shared `"showToast"` event bus directly and omit `source`.
|
|
18
|
+
* Callers may override individual style fields; Theme supplies the rest.
|
|
19
|
+
*
|
|
20
|
+
* @example From React via ActionExecutorContext
|
|
21
|
+
* ```tsx
|
|
22
|
+
* import React, { useContext } from "react";
|
|
23
|
+
* import { ActionExecutorContext } from "@applicaster/zapp-react-native-utils/actionsExecutor/ActionExecutorContext";
|
|
24
|
+
*
|
|
25
|
+
* function QueueButton() {
|
|
26
|
+
* const { handleAction } = useContext(ActionExecutorContext);
|
|
27
|
+
*
|
|
28
|
+
* const onPress = () => {
|
|
29
|
+
* void handleAction({
|
|
30
|
+
* type: "showToast",
|
|
31
|
+
* options: { message: "Added to queue" },
|
|
32
|
+
* });
|
|
33
|
+
* };
|
|
34
|
+
*
|
|
35
|
+
* return <Button onPress={onPress} title="Add to queue" />;
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @example From code via the actionExecutor singleton
|
|
40
|
+
* ```ts
|
|
41
|
+
* import { actionExecutor } from "@applicaster/zapp-react-native-utils/actionsExecutor/ActionExecutor";
|
|
42
|
+
*
|
|
43
|
+
* await actionExecutor.handleAction({
|
|
44
|
+
* type: "showToast",
|
|
45
|
+
* options: {
|
|
46
|
+
* message: "Playlist created",
|
|
47
|
+
* style: { backgroundColor: "#00AA55" }, // optional partial override
|
|
48
|
+
* },
|
|
49
|
+
* });
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* @example From entry / pipes actions JSON
|
|
53
|
+
* ```json
|
|
54
|
+
* {
|
|
55
|
+
* "type": "showToast",
|
|
56
|
+
* "options": {
|
|
57
|
+
* "message": "Item removed from playlist"
|
|
58
|
+
* }
|
|
59
|
+
* }
|
|
60
|
+
* ```
|
|
8
61
|
*/
|
|
9
62
|
export interface ShowToastActionOptions {
|
|
10
63
|
id?: string;
|
|
@@ -17,13 +70,16 @@ export interface ShowToastActionOptions {
|
|
|
17
70
|
export const showToastAction: ActionHandler<ShowToastActionOptions> = async (
|
|
18
71
|
action
|
|
19
72
|
): Promise<ActionResult> => {
|
|
73
|
+
const options = action?.options;
|
|
74
|
+
|
|
20
75
|
postEvent("showToast", [
|
|
21
76
|
{
|
|
22
|
-
id:
|
|
23
|
-
message:
|
|
24
|
-
extraMessage:
|
|
25
|
-
style:
|
|
26
|
-
timeout:
|
|
77
|
+
id: options?.id,
|
|
78
|
+
message: options?.message,
|
|
79
|
+
extraMessage: options?.extraMessage,
|
|
80
|
+
style: options?.style,
|
|
81
|
+
timeout: options?.timeout ?? CONFIRMATION_TOAST_DEFAULT_TIMEOUT,
|
|
82
|
+
source: CONFIRMATION_TOAST_SOURCE,
|
|
27
83
|
},
|
|
28
84
|
]);
|
|
29
85
|
|
|
@@ -2,3 +2,30 @@ export const TOGGLE_FLAG_MAX_ITEMS_REACHED_EVENT =
|
|
|
2
2
|
"action.localStorageToggleFlag.maxItemsReached";
|
|
3
3
|
|
|
4
4
|
export const ACTION_EXECUTOR_EVENT_SOURCE = "ActionExecutor";
|
|
5
|
+
|
|
6
|
+
export const ACTION_TYPES = {
|
|
7
|
+
OPEN_BOTTOM_SHEET: "openBottomSheet",
|
|
8
|
+
DISMISS_BOTTOM_SHEET: "dismissBottomSheet",
|
|
9
|
+
PRESENT_SUB_MENU: "presentSubMenu",
|
|
10
|
+
SEND_CLOUD_EVENT: "sendCloudEvent",
|
|
11
|
+
NAVIGATE_TO_SCREEN: "navigateToScreen",
|
|
12
|
+
PRESENT_SCREEN: "presentScreen",
|
|
13
|
+
GO_BACK: "goBack",
|
|
14
|
+
GO_HOME: "goHome",
|
|
15
|
+
SHOW_TOAST: "showToast",
|
|
16
|
+
LOCAL_STORAGE_SET: "localStorageSet",
|
|
17
|
+
LOCAL_STORAGE_REMOVE: "localStorageRemove",
|
|
18
|
+
LOCAL_STORAGE_TOGGLE_FLAG: "localStorageToggleFlag",
|
|
19
|
+
SESSION_STORAGE_SET: "sessionStorageSet",
|
|
20
|
+
SESSION_STORAGE_REMOVE: "sessionStorageRemove",
|
|
21
|
+
SESSION_STORAGE_TOGGLE_FLAG: "sessionStorageToggleFlag",
|
|
22
|
+
REFRESH_COMPONENT: "refreshComponent",
|
|
23
|
+
SWITCH_LAYOUT: "switchLayout",
|
|
24
|
+
APP_RESTART: "appRestart",
|
|
25
|
+
CONFIRM_DIALOG: "confirmDialog",
|
|
26
|
+
SHOW_ALERT: "showAlert",
|
|
27
|
+
SCREEN_SET_VARIABLE: "screenSetVariable",
|
|
28
|
+
SCREEN_TOGGLE_FLAG: "screenToggleFlag",
|
|
29
|
+
} as const;
|
|
30
|
+
|
|
31
|
+
export type KnownActionType = (typeof ACTION_TYPES)[keyof typeof ACTION_TYPES];
|
|
@@ -159,13 +159,13 @@ export const decorateFeed = (feed: ZappFeed) => {
|
|
|
159
159
|
|
|
160
160
|
const decoratedFeed = R.clone(feed);
|
|
161
161
|
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
|
|
162
|
+
const selectMode =
|
|
163
|
+
feed.extensions?.preference_editor_options?.select_mode ||
|
|
164
|
+
feed.extensions?.behavior?.select_mode;
|
|
165
165
|
|
|
166
|
-
if (
|
|
166
|
+
if (selectMode === "single") {
|
|
167
167
|
return makeSingleSelect(feed, key, decoratedFeed);
|
|
168
|
-
} else {
|
|
169
|
-
return makeMultiSelect(feed, key, decoratedFeed);
|
|
170
168
|
}
|
|
169
|
+
|
|
170
|
+
return makeMultiSelect(feed, key, decoratedFeed);
|
|
171
171
|
};
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
} from "../appUtils/playerManager";
|
|
9
9
|
import { Player } from "../appUtils/playerManager/player";
|
|
10
10
|
import { AnalyticPlayerListener } from "./AnalyticPlayerListener";
|
|
11
|
-
import { PlayerRole } from "../appUtils/playerManager/
|
|
11
|
+
import { PlayerRole } from "../appUtils/playerManager/const";
|
|
12
12
|
|
|
13
13
|
enum PlayerAnalyticsTrackerType {
|
|
14
14
|
PlayerAnalyticsTracker = "PlayerAnalyticsTracker",
|
|
@@ -498,6 +498,15 @@ export function HooksManager({
|
|
|
498
498
|
presentUI
|
|
499
499
|
);
|
|
500
500
|
} catch (e) {
|
|
501
|
+
// Without this the failure is invisible: the hook stops right after the
|
|
502
|
+
// "Executing hook" line, with nothing in the log explaining why and no
|
|
503
|
+
// remaining hook ever running.
|
|
504
|
+
logHookEvent(
|
|
505
|
+
hooksManagerLogger.error,
|
|
506
|
+
`runInBackground: hook ${hookPlugin.identifier} threw: ${e?.message}`,
|
|
507
|
+
{ hook: hookPlugin, payload, error: e, stack: e?.stack }
|
|
508
|
+
);
|
|
509
|
+
|
|
501
510
|
hookPlugin.setStateAndNotify(HOOKS_EVENTS.ERROR, {
|
|
502
511
|
error: e,
|
|
503
512
|
hookPlugin,
|