@applicaster/zapp-react-native-utils 16.0.0-rc.8 → 16.0.0-rc.81
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 +47 -11
- package/actionsExecutor/ActionExecutorContext.tsx +102 -315
- package/actionsExecutor/__tests__/feedDecorator.test.ts +61 -0
- package/actionsExecutor/actions/__tests__/dismissBottomSheet.test.ts +25 -0
- package/actionsExecutor/actions/__tests__/goBack.test.ts +62 -0
- package/actionsExecutor/actions/__tests__/goHome.test.ts +19 -0
- package/actionsExecutor/actions/__tests__/loadItemsFromSource.test.ts +88 -0
- package/actionsExecutor/actions/__tests__/navigateToScreen.test.ts +133 -0
- package/actionsExecutor/actions/__tests__/openBottomSheet.customContent.test.ts +76 -0
- package/actionsExecutor/actions/__tests__/openBottomSheet.inlineItems.test.ts +212 -0
- package/actionsExecutor/actions/__tests__/showToast.test.ts +88 -0
- package/actionsExecutor/actions/appRestart.ts +24 -0
- package/actionsExecutor/actions/confirmDialog.ts +53 -0
- package/actionsExecutor/actions/dismissBottomSheet.ts +23 -0
- package/actionsExecutor/actions/goBack.ts +60 -0
- package/actionsExecutor/actions/goHome.ts +31 -0
- package/actionsExecutor/actions/index.ts +38 -0
- package/actionsExecutor/actions/localStorageRemove.ts +27 -0
- package/actionsExecutor/actions/localStorageSet.ts +28 -0
- package/actionsExecutor/actions/localStorageToggleFlag.ts +28 -0
- package/actionsExecutor/actions/navigateToScreen.ts +137 -0
- package/actionsExecutor/actions/openBottomSheet.ts +325 -0
- package/actionsExecutor/actions/refreshComponent.ts +85 -0
- package/actionsExecutor/actions/screenSetVariable.ts +35 -0
- package/actionsExecutor/actions/screenToggleFlag.ts +38 -0
- package/actionsExecutor/actions/sendCloudEvent.ts +93 -0
- package/actionsExecutor/actions/sessionStorageRemove.ts +19 -0
- package/actionsExecutor/actions/sessionStorageSet.ts +20 -0
- package/actionsExecutor/actions/sessionStorageToggleFlag.ts +15 -0
- package/actionsExecutor/actions/showToast.ts +87 -0
- package/actionsExecutor/actions/switchLayout.ts +40 -0
- package/actionsExecutor/consts.ts +25 -0
- package/actionsExecutor/feedDecorator.ts +6 -6
- package/actionsExecutor/types.ts +59 -0
- package/analyticsUtils/AnalyticsEvents/sendMenuClickEvent.ts +2 -2
- package/analyticsUtils/PlayerAnalyticsManager.ts +12 -2
- package/analyticsUtils/__tests__/analyticsMapper.test.ts +35 -0
- package/analyticsUtils/__tests__/fixtures/analytics_mapper_testACP_events.json +1 -1
- package/analyticsUtils/__tests__/fixtures/analytics_mapper_testBlockUnlistedParams_rules.json +1 -1
- package/analyticsUtils/__tests__/fixtures/analytics_mapper_testEmptyRenameKeepsName_events.json +4 -0
- package/analyticsUtils/__tests__/fixtures/analytics_mapper_testEmptyRenameKeepsName_rules.json +6 -0
- package/analyticsUtils/__tests__/fixtures/analytics_mapper_testEventRegex_events.json +3 -9
- package/analyticsUtils/__tests__/fixtures/analytics_mapper_testIgnoreOrdering_events.json +18 -0
- package/analyticsUtils/__tests__/fixtures/analytics_mapper_testIgnoreOrdering_rules.json +16 -0
- package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexEventNoFallback_events.json +4 -0
- package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexEventNoFallback_rules.json +6 -0
- package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexMultiGroupRename_events.json +4 -0
- package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexMultiGroupRename_rules.json +6 -0
- package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexNonNamedFullMatch_events.json +4 -0
- package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexNonNamedFullMatch_rules.json +6 -0
- package/analyticsUtils/__tests__/fixtures/index.js +20 -0
- package/analyticsUtils/analyticsMapper.ts +4 -1
- package/analyticsUtils/playerAnalyticsTracker.ts +26 -3
- package/appUtils/HooksManager/index.ts +12 -8
- package/appUtils/contextKeysManager/__tests__/getKey/failure.test.ts +1 -1
- package/appUtils/contextKeysManager/__tests__/removeKey/failure.test.ts +1 -1
- package/appUtils/contextKeysManager/__tests__/setKey/failure/invalidKey.test.ts +4 -4
- package/appUtils/contextKeysManager/index.ts +1 -1
- package/appUtils/contextKeysManager/utils/index.ts +38 -25
- package/appUtils/playerManager/OverlayObserver/OverlaysObserver.ts +143 -53
- package/appUtils/playerManager/OverlayObserver/__tests__/liveContent.test.ts +205 -0
- package/appUtils/playerManager/OverlayObserver/__tests__/utils.test.ts +49 -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 +11 -0
- package/appUtils/playerManager/OverlayObserver/getUpcomingQueue.web.ts +4 -0
- package/appUtils/playerManager/OverlayObserver/utils.ts +54 -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 +38 -0
- package/appUtils/playerManager/__tests__/usePlayerContent.test.tsx +64 -0
- package/appUtils/playerManager/{conts.ts → const.ts} +20 -0
- package/appUtils/playerManager/index.ts +1 -1
- package/appUtils/playerManager/player.ts +115 -3
- package/appUtils/playerManager/playerFactory.ts +1 -1
- package/appUtils/playerManager/playerNative.ts +6 -4
- package/appUtils/playerManager/usePlayerContent.tsx +43 -0
- package/appUtils/playerManager/usePlayerControllerSetup.tsx +1 -1
- package/appUtils/playerManager/userLanguagePreference.ts +1 -1
- package/arrayUtils/__tests__/{anyThruthy.test.ts → anyTruthy.test.ts} +8 -0
- package/arrayUtils/__tests__/arrayUtils.test.ts +165 -108
- package/arrayUtils/__tests__/isEmptyArray.test.ts +11 -0
- package/arrayUtils/__tests__/isFilledArray.test.ts +12 -0
- package/arrayUtils/__tests__/isFirst.test.ts +17 -0
- package/arrayUtils/__tests__/isIndexInRange.test.ts +14 -0
- package/arrayUtils/__tests__/isLast.test.ts +31 -0
- package/arrayUtils/__tests__/makeListOf.test.ts +31 -0
- package/arrayUtils/__tests__/makeListOfIndexes.test.ts +20 -0
- package/arrayUtils/__tests__/reorderByIds.test.ts +50 -0
- package/arrayUtils/__tests__/sample.test.ts +61 -0
- package/arrayUtils/index.ts +136 -20
- package/bottomSheet/__tests__/scrollContext.test.tsx +35 -0
- package/bottomSheet/index.ts +17 -0
- package/cellUtils/index.ts +33 -8
- package/colorUtils/__tests__/isTransparentColor.test.ts +76 -0
- package/colorUtils/__tests__/isValidColor.test.ts +70 -0
- package/colorUtils/index.ts +50 -0
- package/configurationUtils/__tests__/manifestKeyParser.test.ts +21 -0
- package/configurationUtils/__tests__/modalBlocksParser.test.ts +260 -0
- package/configurationUtils/manifestKeyParser.ts +50 -10
- package/configurationUtils/modalBlocksParser.ts +296 -0
- package/entryActions/__tests__/buildEntryActions.test.ts +156 -0
- package/entryActions/aliasPresentation.ts +124 -0
- package/entryActions/buildEntryActions.ts +166 -0
- package/entryActions/index.ts +17 -0
- package/entryActions/types.ts +39 -0
- package/manifestUtils/__tests__/player.audioControls.test.js +158 -0
- package/manifestUtils/_internals/index.js +14 -3
- package/manifestUtils/defaultManifestConfigurations/generalContent.js +35 -0
- package/manifestUtils/defaultManifestConfigurations/player.js +349 -20
- package/manifestUtils/fieldUtils/__tests__/fieldUtils.test.js +84 -0
- package/manifestUtils/fieldUtils/index.js +125 -0
- package/manifestUtils/index.js +3 -0
- package/manifestUtils/keys.js +9 -0
- package/manifestUtils/mobileAction/button/index.js +16 -0
- package/manifestUtils/mobileAction/container/index.js +3 -1
- package/manifestUtils/mobileAction/groups/defaults.js +3 -1
- package/manifestUtils/modalBlocks.js +304 -0
- package/manifestUtils/platformIsTV.js +1 -0
- package/modalState/ContentViewModel.ts +113 -0
- package/modalState/EditableCollection.ts +17 -0
- package/modalState/EditableCollectionRegistry.ts +51 -0
- package/modalState/ModalOrchestrator.ts +211 -0
- package/modalState/RemoteEditableCollection.ts +227 -0
- package/modalState/__tests__/ContentViewModel.editable.test.ts +69 -0
- package/modalState/__tests__/ContentViewModel.test.ts +165 -0
- package/modalState/__tests__/EditableCollectionRegistry.test.ts +112 -0
- package/modalState/__tests__/ModalOrchestrator.phase3.test.ts +47 -0
- package/modalState/__tests__/RemoteEditableCollection.test.ts +326 -0
- package/modalState/__tests__/index.test.ts +30 -1
- package/modalState/__tests__/useBottomSheetContent.test.ts +349 -0
- package/modalState/index.ts +35 -83
- package/modalState/store.ts +102 -0
- package/modalState/types.ts +159 -0
- package/modalState/useBottomSheetContent.ts +104 -0
- package/numberUtils/__tests__/isMinusZero.test.ts +20 -0
- package/numberUtils/__tests__/isZero.test.ts +27 -0
- package/numberUtils/__tests__/requireNumber.test.ts +50 -0
- package/numberUtils/__tests__/toNumber.test.ts +27 -0
- package/numberUtils/__tests__/toNumberWithDefault.test.ts +64 -0
- package/numberUtils/__tests__/toNumberWithDefaultZero.test.ts +48 -0
- package/numberUtils/index.ts +27 -8
- package/package.json +2 -2
- package/pipesUtils/__tests__/buildUrlWithQuery.test.ts +33 -0
- package/pipesUtils/__tests__/withPipesEndpoint.test.tsx +56 -0
- package/pipesUtils/index.ts +1 -0
- package/pipesUtils/withPipesEndpoint.tsx +54 -0
- 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 +58 -15
- package/playerUtils/isAudioItem.ts +26 -0
- package/playerUtils/resolvePlayerActions.ts +71 -0
- package/playerUtils/resolvePlayerTitleSubtitle.ts +76 -0
- package/reactHooks/actions/index.ts +117 -2
- package/reactHooks/cell-click/index.ts +18 -10
- package/reactHooks/feed/__mocks__/useMarkPipesDataStale.ts +4 -0
- package/reactHooks/feed/__tests__/useInflatedUrl.test.tsx +25 -0
- package/reactHooks/feed/index.ts +5 -1
- package/reactHooks/feed/useBatchLoading.ts +9 -1
- package/reactHooks/feed/{usePipesCacheReset.ts → useMarkPipesDataStale.ts} +12 -4
- package/reactHooks/index.ts +2 -0
- package/reactHooks/layout/index.ts +1 -1
- package/reactHooks/navigation/__mocks__/index.ts +4 -0
- package/reactHooks/navigation/__tests__/useIsScreenActive.test.ts +42 -0
- package/reactHooks/navigation/index.ts +1 -1
- package/reactHooks/navigation/useIsScreenActive.ts +29 -8
- package/reactHooks/state/useComponentScreenState.ts +1 -1
- package/reactHooks/usePluginConfiguration.ts +4 -1
- package/reactHooks/utils/__tests__/index.test.js +22 -2
- package/reactHooks/utils/index.ts +13 -2
- package/reactHooks/videoModal/hooks/useVideoModalScreenData.tsx +22 -4
- package/riverComponetsMeasurementProvider/index.tsx +12 -8
- package/stringUtils/__tests__/stringUtils.test.js +42 -0
- package/stringUtils/index.ts +2 -2
- package/uiActionsRegistrator/__tests__/resolveActionIdentifiers.test.ts +93 -0
- package/uiActionsRegistrator/__tests__/subscribe.test.ts +107 -0
- package/uiActionsRegistrator/__tests__/usableActionItems.test.ts +52 -0
- package/uiActionsRegistrator/index.ts +25 -0
- package/uiActionsRegistrator/registry.ts +335 -0
- package/uiActionsRegistrator/resolveActionIdentifiers.ts +100 -0
- package/uiActionsRegistrator/usableActionItems.ts +66 -0
- package/zappFrameworkUtils/__tests__/localStorageHelper.test.ts +146 -0
- package/zappFrameworkUtils/localStorageHelper.ts +19 -15
- package/appUtils/playerManager/usePlayerTitleSummaryOverlay.tsx +0 -56
- package/playerUtils/__tests__/getPlayerActionButtons.test.ts +0 -54
- package/playerUtils/getPlayerActionButtons.ts +0 -17
- package/reactHooks/feed/__mocks__/usePipesCacheReset.ts +0 -1
- /package/reactHooks/actions/__tests__/{index.test.js → index.test.tsx} +0 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/// <reference types="@applicaster/applicaster-types" />
|
|
2
|
+
import { showConfirmationDialog } 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 confirmDialog action.
|
|
14
|
+
*/
|
|
15
|
+
export interface ConfirmDialogOptions {
|
|
16
|
+
/** Dialog title (required) */
|
|
17
|
+
title: string;
|
|
18
|
+
|
|
19
|
+
/** Dialog message */
|
|
20
|
+
message?: string;
|
|
21
|
+
|
|
22
|
+
/** Confirm button text */
|
|
23
|
+
okButtonText?: string;
|
|
24
|
+
|
|
25
|
+
/** Cancel button text */
|
|
26
|
+
cancelButtonText?: string;
|
|
27
|
+
|
|
28
|
+
/** Callback when confirmed (deprecated - use action result) */
|
|
29
|
+
confirmCompletion?: () => void;
|
|
30
|
+
|
|
31
|
+
/** Callback when cancelled (deprecated - use action result) */
|
|
32
|
+
cancelCompletion?: () => void;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Shows a confirmation dialog to the user.
|
|
37
|
+
* Resolves to Success if user confirms, Cancel if user dismisses.
|
|
38
|
+
*/
|
|
39
|
+
export const confirmDialogAction: ActionHandler<ConfirmDialogOptions> = async (
|
|
40
|
+
action
|
|
41
|
+
): Promise<ActionResult> => {
|
|
42
|
+
log_info("handleAction: confirmDialog event");
|
|
43
|
+
|
|
44
|
+
const options = action.options as ConfirmDialogOptions;
|
|
45
|
+
|
|
46
|
+
return new Promise<ActionResult>((resolve) => {
|
|
47
|
+
showConfirmationDialog({
|
|
48
|
+
...options,
|
|
49
|
+
confirmCompletion: () => resolve(ActionResult.Success),
|
|
50
|
+
cancelCompletion: () => resolve(ActionResult.Cancel),
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/// <reference types="@applicaster/applicaster-types" />
|
|
2
|
+
import { dismissModal, modalOrchestrator } from "../../modalState";
|
|
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
|
+
* Dismisses the active bottom sheet / modal.
|
|
14
|
+
*/
|
|
15
|
+
export const dismissBottomSheetAction: ActionHandler<
|
|
16
|
+
any
|
|
17
|
+
> = async (): Promise<ActionResult> => {
|
|
18
|
+
log_info("handleAction: dismissBottomSheet");
|
|
19
|
+
modalOrchestrator.close();
|
|
20
|
+
dismissModal();
|
|
21
|
+
|
|
22
|
+
return ActionResult.Success;
|
|
23
|
+
};
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// Export action handlers
|
|
2
|
+
export { localStorageSetAction } from "./localStorageSet";
|
|
3
|
+
|
|
4
|
+
export { sessionStorageSetAction } from "./sessionStorageSet";
|
|
5
|
+
|
|
6
|
+
export { localStorageRemoveAction } from "./localStorageRemove";
|
|
7
|
+
|
|
8
|
+
export { sessionStorageRemoveAction } from "./sessionStorageRemove";
|
|
9
|
+
|
|
10
|
+
export { refreshComponentAction } from "./refreshComponent";
|
|
11
|
+
|
|
12
|
+
export { switchLayoutAction } from "./switchLayout";
|
|
13
|
+
|
|
14
|
+
export { appRestartAction } from "./appRestart";
|
|
15
|
+
|
|
16
|
+
export { confirmDialogAction } from "./confirmDialog";
|
|
17
|
+
|
|
18
|
+
export { sendCloudEventAction } from "./sendCloudEvent";
|
|
19
|
+
|
|
20
|
+
export { sessionStorageToggleFlagAction } from "./sessionStorageToggleFlag";
|
|
21
|
+
|
|
22
|
+
export { localStorageToggleFlagAction } from "./localStorageToggleFlag";
|
|
23
|
+
|
|
24
|
+
export { screenSetVariableAction } from "./screenSetVariable";
|
|
25
|
+
|
|
26
|
+
export { screenToggleFlagAction } from "./screenToggleFlag";
|
|
27
|
+
|
|
28
|
+
export { createNavigateToScreenAction } from "./navigateToScreen";
|
|
29
|
+
|
|
30
|
+
export { createGoBackAction } from "./goBack";
|
|
31
|
+
|
|
32
|
+
export { createGoHomeAction } from "./goHome";
|
|
33
|
+
|
|
34
|
+
export { showToastAction } from "./showToast";
|
|
35
|
+
|
|
36
|
+
export { openBottomSheetAction } from "./openBottomSheet";
|
|
37
|
+
|
|
38
|
+
export { dismissBottomSheetAction } from "./dismissBottomSheet";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/// <reference types="@applicaster/applicaster-types" />
|
|
2
|
+
import { localStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/LocalStorage";
|
|
3
|
+
import { batchRemoveFromStorage } from "../../zappFrameworkUtils/localStorageHelper";
|
|
4
|
+
import { ActionResult } from "../ActionExecutor";
|
|
5
|
+
import { ActionHandler } from "../types";
|
|
6
|
+
import { StorageValuesToRemove } from "../../zappFrameworkUtils/types";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Options for localStorage/sessionStorage remove actions.
|
|
10
|
+
*/
|
|
11
|
+
export interface StorageRemoveOptions {
|
|
12
|
+
/** The keys to remove, organized by namespace */
|
|
13
|
+
content: StorageValuesToRemove;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Removes values from local storage organized by namespaces.
|
|
18
|
+
*/
|
|
19
|
+
export const localStorageRemoveAction: ActionHandler<
|
|
20
|
+
StorageRemoveOptions
|
|
21
|
+
> = async (action): Promise<ActionResult> => {
|
|
22
|
+
const namespaces = action.options.content;
|
|
23
|
+
await batchRemoveFromStorage(namespaces, localStorage);
|
|
24
|
+
// TODO: Add support for ownershipKey and ownershipNamespace
|
|
25
|
+
|
|
26
|
+
return ActionResult.Success;
|
|
27
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/// <reference types="@applicaster/applicaster-types" />
|
|
2
|
+
import { localStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/LocalStorage";
|
|
3
|
+
import { batchSave } from "../../zappFrameworkUtils/localStorageHelper";
|
|
4
|
+
import { ActionResult } from "../ActionExecutor";
|
|
5
|
+
import { ActionHandler } from "../types";
|
|
6
|
+
import { StorageValuesToAdd } from "../../zappFrameworkUtils/types";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Options for localStorage/sessionStorage set actions.
|
|
10
|
+
*/
|
|
11
|
+
export interface StorageSetOptions {
|
|
12
|
+
/** The values to save, organized by namespace */
|
|
13
|
+
content: StorageValuesToAdd;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Saves values to local storage organized by namespaces.
|
|
18
|
+
* The values persist across app sessions.
|
|
19
|
+
*/
|
|
20
|
+
export const localStorageSetAction: ActionHandler<StorageSetOptions> = async (
|
|
21
|
+
action
|
|
22
|
+
): Promise<ActionResult> => {
|
|
23
|
+
const namespaces = action.options.content;
|
|
24
|
+
await batchSave(namespaces, localStorage);
|
|
25
|
+
// TODO: Add support for ownershipKey and ownershipNamespace
|
|
26
|
+
|
|
27
|
+
return ActionResult.Success;
|
|
28
|
+
};
|
|
@@ -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
|
+
}
|