@applicaster/zapp-react-native-utils 16.0.0-rc.9 → 16.0.0-rc.90
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 +57 -12
- package/actionsExecutor/ActionExecutorContext.tsx +113 -314
- package/actionsExecutor/__tests__/ActionExecutor.test.ts +71 -0
- 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__/presentScreen.test.ts +127 -0
- package/actionsExecutor/actions/__tests__/showAlert.test.ts +49 -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 +42 -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 +329 -0
- package/actionsExecutor/actions/presentScreen.ts +78 -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/showAlert.ts +51 -0
- package/actionsExecutor/actions/showToast.ts +87 -0
- package/actionsExecutor/actions/switchLayout.ts +40 -0
- package/actionsExecutor/consts.ts +27 -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 +195 -0
- package/entryActions/aliasPresentation.ts +124 -0
- package/entryActions/buildEntryActions.ts +167 -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 +41 -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 +235 -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 +415 -0
- package/modalState/__tests__/index.test.ts +30 -1
- package/modalState/__tests__/useBottomSheetContent.test.ts +349 -0
- package/modalState/__tests__/useModalStoreState.test.ts +142 -0
- package/modalState/index.ts +35 -83
- package/modalState/store.ts +109 -0
- package/modalState/types.ts +160 -0
- package/modalState/useBottomSheetContent.ts +109 -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 +41 -18
- 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/__tests__/index.test.js +64 -0
- package/reactHooks/cell-click/index.ts +39 -24
- 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__/index.test.tsx +176 -1
- package/reactHooks/navigation/__tests__/useIsScreenActive.test.ts +42 -0
- package/reactHooks/navigation/__tests__/usePresentScreen.test.ts +154 -0
- package/reactHooks/navigation/index.ts +3 -1
- package/reactHooks/navigation/useIsScreenActive.ts +29 -8
- package/reactHooks/navigation/usePresentScreen.ts +157 -0
- package/reactHooks/navigation/useRoute.ts +22 -5
- 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,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
|
+
};
|
|
@@ -0,0 +1,93 @@
|
|
|
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: sending sendCloudEvent to URL", {
|
|
66
|
+
url: options.url,
|
|
67
|
+
cloudEvent,
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const { error, code } = await sendCloudEvent(cloudEvent, options.url);
|
|
71
|
+
|
|
72
|
+
log_info("handleAction: sendCloudEvent result", { code, error });
|
|
73
|
+
|
|
74
|
+
if (error) {
|
|
75
|
+
log_error("sendCloudEvent: error sending cloud event", { error });
|
|
76
|
+
|
|
77
|
+
return ActionResult.Error;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (code && code >= 200 && code < 300 && !error) {
|
|
81
|
+
log_info("sendCloudEvent: cloud event sent successfully");
|
|
82
|
+
|
|
83
|
+
return ActionResult.Success;
|
|
84
|
+
}
|
|
85
|
+
} catch (error) {
|
|
86
|
+
log_error("sendCloudEvent: error sending cloud event", {
|
|
87
|
+
action,
|
|
88
|
+
error,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return ActionResult.Error;
|
|
93
|
+
};
|
|
@@ -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,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
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/// <reference types="@applicaster/applicaster-types" />
|
|
2
|
+
import { ActionResult } from "../ActionExecutor";
|
|
3
|
+
import { ActionHandler } from "../types";
|
|
4
|
+
import { postEvent } from "../../reactHooks/useSubscriberFor";
|
|
5
|
+
|
|
6
|
+
export const CONFIRMATION_TOAST_SOURCE = "confirmation";
|
|
7
|
+
|
|
8
|
+
export const CONFIRMATION_TOAST_DEFAULT_TIMEOUT = 5000;
|
|
9
|
+
|
|
10
|
+
/**
|
|
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
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export interface ShowToastActionOptions {
|
|
63
|
+
id?: string;
|
|
64
|
+
message?: string;
|
|
65
|
+
extraMessage?: string;
|
|
66
|
+
style?: any;
|
|
67
|
+
timeout?: number;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export const showToastAction: ActionHandler<ShowToastActionOptions> = async (
|
|
71
|
+
action
|
|
72
|
+
): Promise<ActionResult> => {
|
|
73
|
+
const options = action?.options;
|
|
74
|
+
|
|
75
|
+
postEvent("showToast", [
|
|
76
|
+
{
|
|
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,
|
|
83
|
+
},
|
|
84
|
+
]);
|
|
85
|
+
|
|
86
|
+
return ActionResult.Success;
|
|
87
|
+
};
|
|
@@ -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
|
+
};
|
|
@@ -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
|
};
|
|
@@ -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 = ({
|
|
@@ -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",
|
|
@@ -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
|
};
|