@applicaster/zapp-react-native-utils 16.0.0-rc.4 → 16.0.0-rc.40
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 +8 -10
- package/actionsExecutor/ActionExecutorContext.tsx +43 -326
- package/actionsExecutor/actions/appRestart.ts +24 -0
- package/actionsExecutor/actions/confirmDialog.ts +53 -0
- package/actionsExecutor/actions/index.ts +30 -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 +123 -0
- package/actionsExecutor/actions/refreshComponent.ts +79 -0
- package/actionsExecutor/actions/screenSetVariable.ts +35 -0
- package/actionsExecutor/actions/screenToggleFlag.ts +38 -0
- package/actionsExecutor/actions/sendCloudEvent.ts +88 -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 +31 -0
- package/actionsExecutor/actions/switchLayout.ts +40 -0
- package/actionsExecutor/types.ts +59 -0
- package/analyticsUtils/AnalyticsEvents/sendMenuClickEvent.ts +2 -2
- package/analyticsUtils/PlayerAnalyticsManager.ts +11 -1
- 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 +3 -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/__tests__/playerFactory.test.ts +150 -0
- package/appUtils/playerManager/playerFactory.ts +17 -34
- package/cellUtils/index.ts +3 -5
- package/colorUtils/__tests__/isTransparentColor.test.ts +76 -0
- package/colorUtils/__tests__/isValidColor.test.ts +70 -0
- package/colorUtils/index.ts +50 -0
- package/manifestUtils/_internals/index.js +6 -0
- package/manifestUtils/defaultManifestConfigurations/generalContent.js +35 -0
- package/manifestUtils/defaultManifestConfigurations/player.js +15 -15
- package/manifestUtils/fieldUtils/__tests__/fieldUtils.test.js +84 -0
- package/manifestUtils/fieldUtils/index.js +125 -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/platformIsTV.js +1 -0
- 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/index.ts +24 -2
- package/reactHooks/actions/index.ts +51 -1
- package/reactHooks/cell-click/index.ts +18 -10
- package/reactHooks/feed/__mocks__/useMarkPipesDataStale.ts +4 -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/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/screen/__tests__/useIsStandaloneFullscreen.test.ts +114 -0
- package/reactHooks/screen/index.ts +2 -0
- package/reactHooks/screen/useIsStandaloneFullscreen.ts +12 -0
- package/reactHooks/state/useComponentScreenState.ts +1 -1
- package/reactHooks/utils/index.ts +3 -2
- package/reactHooks/videoModal/hooks/useVideoModalScreenData.tsx +22 -4
- package/riverComponetsMeasurementProvider/index.tsx +12 -8
- package/uiActionsRegistrator/index.ts +203 -0
- package/reactHooks/feed/__mocks__/usePipesCacheReset.ts +0 -1
|
@@ -0,0 +1,123 @@
|
|
|
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
|
+
/**
|
|
31
|
+
* Creates a navigation action handler with the provided dependencies.
|
|
32
|
+
* This factory pattern allows the action to access navigation state at runtime.
|
|
33
|
+
*
|
|
34
|
+
* @param navigator - The app navigator for push/replace operations
|
|
35
|
+
* @param rivers - Map of screen IDs to river definitions
|
|
36
|
+
* @param contentTypes - Map of content type names to screen configurations
|
|
37
|
+
* @returns An action handler that performs screen navigation
|
|
38
|
+
*/
|
|
39
|
+
export function createNavigateToScreenAction(
|
|
40
|
+
navigator: QuickBrickAppNavigator,
|
|
41
|
+
rivers: Record<string, ZappRiver>,
|
|
42
|
+
contentTypes: ZappContentTypes
|
|
43
|
+
): ActionHandler<NavigateToScreenOptions> {
|
|
44
|
+
return async function navigateToScreenAction(
|
|
45
|
+
action,
|
|
46
|
+
context?: ActionExecutionContext
|
|
47
|
+
): Promise<ActionResult> {
|
|
48
|
+
const screenType = action.options?.typeMapping;
|
|
49
|
+
|
|
50
|
+
if (!screenType) {
|
|
51
|
+
log_error("navigateToScreen: typeMapping option is missing");
|
|
52
|
+
|
|
53
|
+
return ActionResult.Error;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const navigationAction = action.options?.navigationAction;
|
|
57
|
+
const entrySource = action.options?.entry;
|
|
58
|
+
|
|
59
|
+
const entry = entrySource
|
|
60
|
+
? entrySource === "@{entry/}"
|
|
61
|
+
? context?.entry
|
|
62
|
+
: entrySource
|
|
63
|
+
: null;
|
|
64
|
+
|
|
65
|
+
if (entry) {
|
|
66
|
+
if (typeof entry !== "object") {
|
|
67
|
+
log_error(
|
|
68
|
+
`navigateToScreen: entry option is not an object, entry: ${entry}`
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
return ActionResult.Error;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
log_info(
|
|
75
|
+
`navigateToScreen: navigating to screen type: ${screenType} with entry id: ${entry.id}`
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
const overriddenEntry: ZappEntry = {
|
|
79
|
+
...entry,
|
|
80
|
+
type: {
|
|
81
|
+
value: screenType,
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
if (navigationAction === "push") {
|
|
86
|
+
navigator.push(overriddenEntry);
|
|
87
|
+
} else {
|
|
88
|
+
// Use replaceTop for entries since replace() only accepts ZappRiver
|
|
89
|
+
navigator.replaceTop(overriddenEntry);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return ActionResult.Success;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const screenId = contentTypes?.[screenType]?.screen_id || null;
|
|
96
|
+
|
|
97
|
+
if (!screenId) {
|
|
98
|
+
log_error(
|
|
99
|
+
`navigateToScreen: can not resolve screen type mapping: ${screenType}`
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
return ActionResult.Error;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const river = rivers[screenId];
|
|
106
|
+
|
|
107
|
+
if (!river) {
|
|
108
|
+
log_error("navigateToScreen: can not resolve river");
|
|
109
|
+
|
|
110
|
+
return ActionResult.Error;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
context?.callback?.({ success: false, error: null, abort: true });
|
|
114
|
+
|
|
115
|
+
if (navigationAction === "push") {
|
|
116
|
+
navigator.push(river);
|
|
117
|
+
} else {
|
|
118
|
+
navigator.replace(river);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return ActionResult.Success;
|
|
122
|
+
};
|
|
123
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
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
|
+
log_info(`handleAction: refreshComponent for dataSource:${dataSource}`, {
|
|
61
|
+
source,
|
|
62
|
+
inflatedUrl: dataSource,
|
|
63
|
+
mapping,
|
|
64
|
+
entryContextId: context?.entryContext?.id,
|
|
65
|
+
entryId: context?.entry?.id,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// TODO: In theory we should wait callback to complete, before completing the action, but now it's not needed
|
|
69
|
+
// TODO: handle focused item removal
|
|
70
|
+
dispatch(
|
|
71
|
+
loadPipesData(dataSource, {
|
|
72
|
+
silentRefresh: false,
|
|
73
|
+
clearCache: true,
|
|
74
|
+
riverId: context?.screenData?.id,
|
|
75
|
+
})
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
return ActionResult.Success;
|
|
79
|
+
};
|
|
@@ -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
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/// <reference types="@applicaster/applicaster-types" />
|
|
2
|
+
import { createCloudEvent, sendCloudEvent } from "../../cloudEventsUtils";
|
|
3
|
+
import {
|
|
4
|
+
EntryResolver,
|
|
5
|
+
resolveObjectValues,
|
|
6
|
+
} from "../../appUtils/contextKeysManager/contextResolver";
|
|
7
|
+
import { ActionResult } from "../ActionExecutor";
|
|
8
|
+
import { ActionHandler, ActionExecutionContext } from "../types";
|
|
9
|
+
import { createLogger } from "../../logger";
|
|
10
|
+
|
|
11
|
+
const { log_info, log_error } = createLogger({
|
|
12
|
+
subsystem: "ActionExecutorContext",
|
|
13
|
+
category: "General",
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Options for the sendCloudEvent action.
|
|
18
|
+
*/
|
|
19
|
+
export interface SendCloudEventOptions {
|
|
20
|
+
/** The cloud event type (defaults to "com.applicaster.selector.action.v1") */
|
|
21
|
+
type?: string;
|
|
22
|
+
|
|
23
|
+
/** The event data payload */
|
|
24
|
+
data?: Record<string, any>;
|
|
25
|
+
|
|
26
|
+
/** The event subject (defaults to entry.id) */
|
|
27
|
+
subject?: string;
|
|
28
|
+
|
|
29
|
+
/** The URL endpoint to send the event to */
|
|
30
|
+
url: string;
|
|
31
|
+
|
|
32
|
+
/** Whether to inflate data with context variables */
|
|
33
|
+
inflateData?: boolean;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Sends a cloud event to a remote endpoint.
|
|
38
|
+
* Supports data inflation using context variables from entry and screen.
|
|
39
|
+
*/
|
|
40
|
+
export const sendCloudEventAction: ActionHandler<
|
|
41
|
+
SendCloudEventOptions
|
|
42
|
+
> = async (action, context?: ActionExecutionContext): Promise<ActionResult> => {
|
|
43
|
+
try {
|
|
44
|
+
const options = action.options as SendCloudEventOptions;
|
|
45
|
+
|
|
46
|
+
const entry = context?.entry || {};
|
|
47
|
+
const entryResolver = new EntryResolver(entry as ZappEntry);
|
|
48
|
+
const screenData = context?.screenStateStore?.getState?.()?.data || {};
|
|
49
|
+
const screenResolver = new EntryResolver(screenData as ZappEntry);
|
|
50
|
+
|
|
51
|
+
const data =
|
|
52
|
+
options?.data && options.inflateData
|
|
53
|
+
? await resolveObjectValues(options.data, {
|
|
54
|
+
entry: entryResolver,
|
|
55
|
+
screen: screenResolver,
|
|
56
|
+
})
|
|
57
|
+
: options?.data || entry;
|
|
58
|
+
|
|
59
|
+
const cloudEvent = await createCloudEvent({
|
|
60
|
+
type: options.type || "com.applicaster.selector.action.v1",
|
|
61
|
+
data,
|
|
62
|
+
subject: options.subject || String((entry as ZappEntry)?.id || ""),
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
log_info("handleAction: sendCloudEvent event", { cloudEvent });
|
|
66
|
+
|
|
67
|
+
const { error, code } = await sendCloudEvent(cloudEvent, options.url);
|
|
68
|
+
|
|
69
|
+
if (error) {
|
|
70
|
+
log_error("sendCloudEvent: error sending cloud event", { error });
|
|
71
|
+
|
|
72
|
+
return ActionResult.Error;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (code && code >= 200 && code < 300 && !error) {
|
|
76
|
+
log_info("sendCloudEvent: cloud event sent successfully");
|
|
77
|
+
|
|
78
|
+
return ActionResult.Success;
|
|
79
|
+
}
|
|
80
|
+
} catch (error) {
|
|
81
|
+
log_error("sendCloudEvent: error sending cloud event", {
|
|
82
|
+
action,
|
|
83
|
+
error,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return ActionResult.Error;
|
|
88
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference types="@applicaster/applicaster-types" />
|
|
2
|
+
import { sessionStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/SessionStorage";
|
|
3
|
+
import { batchRemoveFromStorage } from "../../zappFrameworkUtils/localStorageHelper";
|
|
4
|
+
import { ActionResult } from "../ActionExecutor";
|
|
5
|
+
import { ActionHandler } from "../types";
|
|
6
|
+
import { StorageRemoveOptions } from "./localStorageRemove";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Removes values from session storage organized by namespaces.
|
|
10
|
+
*/
|
|
11
|
+
export const sessionStorageRemoveAction: ActionHandler<
|
|
12
|
+
StorageRemoveOptions
|
|
13
|
+
> = async (action): Promise<ActionResult> => {
|
|
14
|
+
const namespaces = action.options.content;
|
|
15
|
+
await batchRemoveFromStorage(namespaces, sessionStorage);
|
|
16
|
+
// TODO: Add support for ownershipKey and ownershipNamespace
|
|
17
|
+
|
|
18
|
+
return ActionResult.Success;
|
|
19
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/// <reference types="@applicaster/applicaster-types" />
|
|
2
|
+
import { sessionStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/SessionStorage";
|
|
3
|
+
import { batchSave } from "../../zappFrameworkUtils/localStorageHelper";
|
|
4
|
+
import { ActionResult } from "../ActionExecutor";
|
|
5
|
+
import { ActionHandler } from "../types";
|
|
6
|
+
import { StorageSetOptions } from "./localStorageSet";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Saves values to session storage organized by namespaces.
|
|
10
|
+
* The values persist only for the current app session.
|
|
11
|
+
*/
|
|
12
|
+
export const sessionStorageSetAction: ActionHandler<StorageSetOptions> = async (
|
|
13
|
+
action
|
|
14
|
+
): Promise<ActionResult> => {
|
|
15
|
+
const namespaces = (action.options as StorageSetOptions).content;
|
|
16
|
+
await batchSave(namespaces, sessionStorage);
|
|
17
|
+
// TODO: Add support for ownershipKey and ownershipNamespace
|
|
18
|
+
|
|
19
|
+
return ActionResult.Success;
|
|
20
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="@applicaster/applicaster-types" />
|
|
2
|
+
import { sessionStorageToggleFlag } from "../StorageActions";
|
|
3
|
+
import { ActionResult } from "../ActionExecutor";
|
|
4
|
+
import { ActionHandler, ActionExecutionContext } from "../types";
|
|
5
|
+
import { StorageToggleFlagOptions } from "./localStorageToggleFlag";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Toggles a flag in session storage (adds or removes an item from a collection).
|
|
9
|
+
* Values persist only for the current app session.
|
|
10
|
+
*/
|
|
11
|
+
export const sessionStorageToggleFlagAction: ActionHandler<
|
|
12
|
+
StorageToggleFlagOptions
|
|
13
|
+
> = async (action, context?: ActionExecutionContext): Promise<ActionResult> => {
|
|
14
|
+
return await sessionStorageToggleFlag(context, action);
|
|
15
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/// <reference types="@applicaster/applicaster-types" />
|
|
2
|
+
import { ActionResult } from "../ActionExecutor";
|
|
3
|
+
import { ActionHandler } from "../types";
|
|
4
|
+
import { postEvent } from "../../reactHooks/useSubscriberFor";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Options for showToast action.
|
|
8
|
+
*/
|
|
9
|
+
export interface ShowToastActionOptions {
|
|
10
|
+
id: string;
|
|
11
|
+
message: string;
|
|
12
|
+
extraMessage?: string;
|
|
13
|
+
style?: any;
|
|
14
|
+
timeout?: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const showToastAction: ActionHandler<ShowToastActionOptions> = async (
|
|
18
|
+
action
|
|
19
|
+
): Promise<ActionResult> => {
|
|
20
|
+
postEvent("showToast", [
|
|
21
|
+
{
|
|
22
|
+
id: action.options.id,
|
|
23
|
+
message: action.options.message,
|
|
24
|
+
extraMessage: action.options.extraMessage,
|
|
25
|
+
style: action.options.style,
|
|
26
|
+
timeout: action.options.timeout,
|
|
27
|
+
},
|
|
28
|
+
]);
|
|
29
|
+
|
|
30
|
+
return ActionResult.Success;
|
|
31
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/// <reference types="@applicaster/applicaster-types" />
|
|
2
|
+
import { localStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/LocalStorage";
|
|
3
|
+
import * as QuickBrickManager from "@applicaster/zapp-react-native-bridge/QuickBrick";
|
|
4
|
+
import { QUICK_BRICK_EVENTS } from "@applicaster/zapp-react-native-bridge/QuickBrick";
|
|
5
|
+
import { ACTIVE_LAYOUT_ID_STORAGE_KEY } from "@applicaster/quick-brick-core/App/remoteContextReloader/consts";
|
|
6
|
+
import { ActionResult } from "../ActionExecutor";
|
|
7
|
+
import { ActionHandler } from "../types";
|
|
8
|
+
import { createLogger } from "../../logger";
|
|
9
|
+
|
|
10
|
+
const { log_info } = createLogger({
|
|
11
|
+
subsystem: "ActionExecutorContext",
|
|
12
|
+
category: "General",
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Options for the switchLayout action.
|
|
17
|
+
*/
|
|
18
|
+
export interface SwitchLayoutOptions {
|
|
19
|
+
/** The ID of the layout to switch to */
|
|
20
|
+
layoutId: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Switches the active layout and triggers an app reload.
|
|
25
|
+
* Saves the new layout ID to local storage before reloading.
|
|
26
|
+
*/
|
|
27
|
+
export const switchLayoutAction: ActionHandler<SwitchLayoutOptions> = async (
|
|
28
|
+
action
|
|
29
|
+
): Promise<ActionResult> => {
|
|
30
|
+
log_info("handleAction: switchLayout event");
|
|
31
|
+
|
|
32
|
+
await localStorage.setItem(
|
|
33
|
+
ACTIVE_LAYOUT_ID_STORAGE_KEY,
|
|
34
|
+
action.options.layoutId
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
QuickBrickManager.sendQuickBrickEvent(QUICK_BRICK_EVENTS.FORCE_APP_RELOAD);
|
|
38
|
+
|
|
39
|
+
return ActionResult.Success;
|
|
40
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/// <reference types="@applicaster/applicaster-types" />
|
|
2
|
+
import { ActionResult } from "./ActionExecutor";
|
|
3
|
+
import { useScreenStateStore } from "../reactHooks/navigation/useScreenStateStore";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Base context object passed to action handlers during execution.
|
|
7
|
+
* Contains references to the current entry, screen, and other execution state.
|
|
8
|
+
*/
|
|
9
|
+
export interface ActionExecutionContext {
|
|
10
|
+
/** The entry associated with this action (e.g., the item that was tapped) */
|
|
11
|
+
entry?: ZappEntry;
|
|
12
|
+
|
|
13
|
+
/** The current screen/river data */
|
|
14
|
+
screenData?: ZappRiver;
|
|
15
|
+
|
|
16
|
+
/** The entry that defines the screen (if screen was opened from an entry) */
|
|
17
|
+
screenEntry?: ZappEntry;
|
|
18
|
+
|
|
19
|
+
/** The UI component that triggered the action.
|
|
20
|
+
* From UIComponentContext as `{ ...component, parent }`.
|
|
21
|
+
*/
|
|
22
|
+
component?: ZappUIComponent & { parent?: ZappUIComponent };
|
|
23
|
+
|
|
24
|
+
/** The route identifier for the current screen */
|
|
25
|
+
screenRoute?: string;
|
|
26
|
+
|
|
27
|
+
/** The screen state store for managing screen-level state (Zustand store) */
|
|
28
|
+
screenStateStore?: ReturnType<typeof useScreenStateStore>;
|
|
29
|
+
|
|
30
|
+
/** Context entry for additional data */
|
|
31
|
+
entryContext?: ZappEntry;
|
|
32
|
+
|
|
33
|
+
/** Callback function for action completion */
|
|
34
|
+
callback?: (result: { success: boolean; error: any; abort: boolean }) => void;
|
|
35
|
+
|
|
36
|
+
screenState?: Record<any, any>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Type for action handler functions.
|
|
41
|
+
* Handlers receive the action (which may have typed options) and execution context.
|
|
42
|
+
*
|
|
43
|
+
* @template _TOptions - Optional type hint for the action's options object (for documentation/intellisense)
|
|
44
|
+
* @param action - The action to execute
|
|
45
|
+
* @param context - The execution context
|
|
46
|
+
* @returns A promise that resolves to the action result
|
|
47
|
+
*/
|
|
48
|
+
export type ActionHandler<_TOptions = any> = (
|
|
49
|
+
action: ActionType,
|
|
50
|
+
context?: ActionExecutionContext
|
|
51
|
+
) => Promise<ActionResult>;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Factory function that creates an action handler.
|
|
55
|
+
* Used for actions that need to capture dependencies at registration time.
|
|
56
|
+
*/
|
|
57
|
+
export type ActionHandlerFactory<_TOptions = any> = (
|
|
58
|
+
...dependencies: any[]
|
|
59
|
+
) => ActionHandler<_TOptions>;
|
|
@@ -6,9 +6,9 @@ import { postAnalyticEvent } from "../manager";
|
|
|
6
6
|
import { ANALYTICS_CORE_EVENTS } from "../events";
|
|
7
7
|
|
|
8
8
|
type AnalyticsDefaultHelperProperties = {
|
|
9
|
-
analyticsScreenData
|
|
9
|
+
analyticsScreenData?: AnalyticsScreenProperties;
|
|
10
10
|
extraProps: any;
|
|
11
|
-
props;
|
|
11
|
+
props?: any;
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
export const sendMenuClickEvent = ({
|
|
@@ -23,6 +23,15 @@ class PlayerAnalyticsTrackerFactory {
|
|
|
23
23
|
return new PlayerAnalyticsTracker();
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
+
|
|
27
|
+
onPlayerRegistered(tracker: PlayerAnalyticsTrackerI, player: Player) {
|
|
28
|
+
tracker.setPlayer(player);
|
|
29
|
+
tracker.onPlayerPresented();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
onPlayerUnRegistered(tracker?: PlayerAnalyticsTrackerI) {
|
|
33
|
+
tracker?.onPlayerClosed();
|
|
34
|
+
}
|
|
26
35
|
}
|
|
27
36
|
|
|
28
37
|
export class PlayerAnalyticsManager implements PlayerLifecycleListener {
|
|
@@ -70,7 +79,7 @@ export class PlayerAnalyticsManager implements PlayerLifecycleListener {
|
|
|
70
79
|
}
|
|
71
80
|
|
|
72
81
|
const tracker = this.getTracker(player.playerId);
|
|
73
|
-
|
|
82
|
+
this.trackerFactory.onPlayerRegistered(tracker, player);
|
|
74
83
|
|
|
75
84
|
const analyticsListener = new AnalyticPlayerListener({
|
|
76
85
|
analyticsTracker: tracker,
|
|
@@ -84,6 +93,7 @@ export class PlayerAnalyticsManager implements PlayerLifecycleListener {
|
|
|
84
93
|
};
|
|
85
94
|
|
|
86
95
|
onUnRegistered = (player: Player) => {
|
|
96
|
+
this.trackerFactory.onPlayerUnRegistered(this.trackers[player.playerId]);
|
|
87
97
|
player.removeListener(AnalyticPlayerListener.analyticsListenerID);
|
|
88
98
|
delete this.trackers[player.playerId];
|
|
89
99
|
};
|
|
@@ -74,4 +74,39 @@ describe("Analytics Mapper", () => {
|
|
|
74
74
|
const rules = fixtures.ACPEventRules;
|
|
75
75
|
await setConfigRunMapTest(rules, fixtures.ACPEventEvents);
|
|
76
76
|
});
|
|
77
|
+
|
|
78
|
+
it("Does not let an ignore rule short-circuit later events", async () => {
|
|
79
|
+
await setConfigRunMapTest(
|
|
80
|
+
fixtures.ignoreOrderingRules,
|
|
81
|
+
fixtures.ignoreOrderingEvents
|
|
82
|
+
);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it("Keeps the original name when rename is empty", async () => {
|
|
86
|
+
await setConfigRunMapTest(
|
|
87
|
+
fixtures.emptyRenameRules,
|
|
88
|
+
fixtures.emptyRenameEvents
|
|
89
|
+
);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it("Renames via a regex with no named groups", async () => {
|
|
93
|
+
await setConfigRunMapTest(
|
|
94
|
+
fixtures.regexNonNamedFullMatchRules,
|
|
95
|
+
fixtures.regexNonNamedFullMatchEvents
|
|
96
|
+
);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it("Substitutes every named group in a regex rename", async () => {
|
|
100
|
+
await setConfigRunMapTest(
|
|
101
|
+
fixtures.regexMultiGroupRenameRules,
|
|
102
|
+
fixtures.regexMultiGroupRenameEvents
|
|
103
|
+
);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it("Does not fall back to event match when a regex rule does not match", async () => {
|
|
107
|
+
await setConfigRunMapTest(
|
|
108
|
+
fixtures.regexEventNoFallbackRules,
|
|
109
|
+
fixtures.regexEventNoFallbackEvents
|
|
110
|
+
);
|
|
111
|
+
});
|
|
77
112
|
});
|