@applicaster/zapp-react-native-utils 15.1.13-alpha.1034774223 → 15.1.13-alpha.4042438573
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 +2 -40
- package/actionsExecutor/ActionExecutorContext.tsx +16 -70
- package/actionsExecutor/actions/index.ts +0 -4
- package/actionsExecutor/actions/refreshComponent.ts +0 -6
- package/actionsExecutor/actions/sendCloudEvent.ts +1 -6
- package/actionsExecutor/consts.ts +0 -23
- package/actionsExecutor/types.ts +1 -1
- package/appUtils/playerManager/OverlayObserver/OverlaysObserver.ts +2 -5
- package/appUtils/playerManager/OverlayObserver/__tests__/utils.test.ts +2 -55
- package/appUtils/playerManager/OverlayObserver/utils.ts +20 -51
- package/arrayUtils/index.ts +0 -79
- package/configurationUtils/__tests__/manifestKeyParser.test.ts +0 -21
- package/configurationUtils/manifestKeyParser.ts +10 -50
- package/manifestUtils/defaultManifestConfigurations/player.js +1 -22
- package/manifestUtils/index.js +0 -3
- package/modalState/__tests__/index.test.ts +1 -30
- package/modalState/index.ts +83 -35
- package/package.json +2 -2
- package/playerUtils/__tests__/getPlayerActionButtons.test.ts +54 -0
- package/playerUtils/getPlayerActionButtons.ts +17 -0
- package/playerUtils/index.ts +1 -17
- package/reactHooks/actions/index.ts +2 -67
- package/reactHooks/cell-click/__tests__/index.test.js +64 -0
- package/reactHooks/cell-click/index.ts +21 -14
- package/reactHooks/usePluginConfiguration.ts +3 -6
- package/uiActionsRegistrator/index.ts +203 -25
- package/actionsExecutor/actions/__tests__/dismissBottomSheet.test.ts +0 -25
- package/actionsExecutor/actions/__tests__/loadItemsFromSource.test.ts +0 -88
- package/actionsExecutor/actions/__tests__/openBottomSheet.customContent.test.ts +0 -76
- package/actionsExecutor/actions/__tests__/openBottomSheet.inlineItems.test.ts +0 -212
- package/actionsExecutor/actions/dismissBottomSheet.ts +0 -23
- package/actionsExecutor/actions/openBottomSheet.ts +0 -325
- package/appUtils/playerManager/OverlayObserver/getUpcomingQueue.android.tv.ts +0 -4
- package/appUtils/playerManager/OverlayObserver/getUpcomingQueue.ios.tv.ts +0 -4
- package/appUtils/playerManager/OverlayObserver/getUpcomingQueue.ts +0 -11
- package/appUtils/playerManager/OverlayObserver/getUpcomingQueue.web.ts +0 -4
- package/arrayUtils/__tests__/reorderByIds.test.ts +0 -50
- package/configurationUtils/__tests__/modalBlocksParser.test.ts +0 -260
- package/configurationUtils/modalBlocksParser.ts +0 -296
- package/entryActions/__tests__/buildEntryActions.test.ts +0 -156
- package/entryActions/aliasPresentation.ts +0 -124
- package/entryActions/buildEntryActions.ts +0 -166
- package/entryActions/index.ts +0 -17
- package/entryActions/types.ts +0 -39
- package/manifestUtils/modalBlocks.js +0 -304
- package/modalState/ContentViewModel.ts +0 -113
- package/modalState/EditableCollection.ts +0 -17
- package/modalState/EditableCollectionRegistry.ts +0 -51
- package/modalState/ModalOrchestrator.ts +0 -211
- package/modalState/RemoteEditableCollection.ts +0 -227
- package/modalState/__tests__/ContentViewModel.editable.test.ts +0 -69
- package/modalState/__tests__/ContentViewModel.test.ts +0 -165
- package/modalState/__tests__/EditableCollectionRegistry.test.ts +0 -112
- package/modalState/__tests__/ModalOrchestrator.phase3.test.ts +0 -47
- package/modalState/__tests__/RemoteEditableCollection.test.ts +0 -326
- package/modalState/__tests__/useBottomSheetContent.test.ts +0 -349
- package/modalState/store.ts +0 -102
- package/modalState/types.ts +0 -159
- package/modalState/useBottomSheetContent.ts +0 -104
- package/playerUtils/__tests__/resolvePlayerActions.test.ts +0 -138
- package/playerUtils/resolvePlayerActions.ts +0 -71
- package/uiActionsRegistrator/__tests__/resolveActionIdentifiers.test.ts +0 -93
- package/uiActionsRegistrator/__tests__/subscribe.test.ts +0 -107
- package/uiActionsRegistrator/__tests__/usableActionItems.test.ts +0 -52
- package/uiActionsRegistrator/registry.ts +0 -335
- package/uiActionsRegistrator/resolveActionIdentifiers.ts +0 -100
- package/uiActionsRegistrator/usableActionItems.ts +0 -66
- /package/reactHooks/actions/__tests__/{index.test.tsx → index.test.js} +0 -0
|
@@ -12,7 +12,7 @@ const { log_error, log_debug, log_info } = createLogger({
|
|
|
12
12
|
category: "General",
|
|
13
13
|
});
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
class ActionExecutor {
|
|
16
16
|
private registeredActions: Record<string, ActionHandler> = {};
|
|
17
17
|
|
|
18
18
|
// TODO: Remove context
|
|
@@ -101,8 +101,7 @@ export class ActionExecutor {
|
|
|
101
101
|
|
|
102
102
|
registerAction = <TOptions = Record<string, any>>(
|
|
103
103
|
type: string,
|
|
104
|
-
handler: ActionHandler<TOptions
|
|
105
|
-
stateResolver?: (entry?: ZappEntry) => any
|
|
104
|
+
handler: ActionHandler<TOptions>
|
|
106
105
|
) => {
|
|
107
106
|
if (this.registeredActions[type]) {
|
|
108
107
|
log_error(`registerAction: action type: ${type} already registered`);
|
|
@@ -113,48 +112,11 @@ export class ActionExecutor {
|
|
|
113
112
|
this.registeredActions[type] = handler;
|
|
114
113
|
log_debug(`registerAction: action type: ${type} registered`);
|
|
115
114
|
|
|
116
|
-
let unregisterState = () => {};
|
|
117
|
-
|
|
118
|
-
if (stateResolver) {
|
|
119
|
-
unregisterState = this.registerActionState(type, stateResolver);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
115
|
return () => {
|
|
123
116
|
this.unregisterAction(type);
|
|
124
|
-
unregisterState();
|
|
125
117
|
log_debug(`registerAction: action type: ${type} un-registered`);
|
|
126
118
|
};
|
|
127
119
|
};
|
|
128
|
-
|
|
129
|
-
private actionStates: Record<string, (entry?: ZappEntry) => any> = {};
|
|
130
|
-
|
|
131
|
-
registerActionState = (
|
|
132
|
-
type: string,
|
|
133
|
-
stateResolver: (entry?: ZappEntry) => any
|
|
134
|
-
) => {
|
|
135
|
-
if (this.actionStates[type]) {
|
|
136
|
-
log_error(
|
|
137
|
-
`registerActionState: action type state: ${type} already registered`
|
|
138
|
-
);
|
|
139
|
-
|
|
140
|
-
return () => {};
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
this.actionStates[type] = stateResolver;
|
|
144
|
-
log_debug(`registerActionState: action type state: ${type} registered`);
|
|
145
|
-
|
|
146
|
-
return () => {
|
|
147
|
-
delete this.actionStates[type];
|
|
148
|
-
|
|
149
|
-
log_debug(
|
|
150
|
-
`registerActionState: action type state: ${type} un-registered`
|
|
151
|
-
);
|
|
152
|
-
};
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
getActionState = (type: string, entry?: ZappEntry) => {
|
|
156
|
-
return this.actionStates[type]?.(entry);
|
|
157
|
-
};
|
|
158
120
|
}
|
|
159
121
|
|
|
160
122
|
export const actionExecutor = new ActionExecutor();
|
|
@@ -21,11 +21,9 @@ import {
|
|
|
21
21
|
createGoBackAction,
|
|
22
22
|
createGoHomeAction,
|
|
23
23
|
createNavigateToScreenAction,
|
|
24
|
-
dismissBottomSheetAction,
|
|
25
24
|
localStorageRemoveAction,
|
|
26
25
|
localStorageSetAction,
|
|
27
26
|
localStorageToggleFlagAction,
|
|
28
|
-
openBottomSheetAction,
|
|
29
27
|
refreshComponentAction,
|
|
30
28
|
screenSetVariableAction,
|
|
31
29
|
screenToggleFlagAction,
|
|
@@ -37,8 +35,6 @@ import {
|
|
|
37
35
|
showToastAction,
|
|
38
36
|
} from "./actions";
|
|
39
37
|
|
|
40
|
-
import { ACTION_TYPES } from "./consts";
|
|
41
|
-
|
|
42
38
|
export const { log_error, log_info, log_debug } = createLogger({
|
|
43
39
|
subsystem: "ActionExecutorContext",
|
|
44
40
|
category: "General",
|
|
@@ -47,15 +43,9 @@ export const { log_error, log_info, log_debug } = createLogger({
|
|
|
47
43
|
export type ActionExecutorContextType = {
|
|
48
44
|
registerAction: <TOptions = Record<string, any>>(
|
|
49
45
|
type: string,
|
|
50
|
-
handler: ActionHandler<TOptions
|
|
51
|
-
stateResolver?: (entry?: ZappEntry) => any
|
|
46
|
+
handler: ActionHandler<TOptions>
|
|
52
47
|
) => void;
|
|
53
48
|
unregisterAction: (type: string) => void;
|
|
54
|
-
registerActionState: (
|
|
55
|
-
type: string,
|
|
56
|
-
stateResolver: (entry?: ZappEntry) => any
|
|
57
|
-
) => () => void;
|
|
58
|
-
getActionState: (type: string, entry?: ZappEntry) => any;
|
|
59
49
|
handleAction: (
|
|
60
50
|
action: ActionType,
|
|
61
51
|
context?: ActionExecutionContext
|
|
@@ -75,76 +65,34 @@ type Props = {
|
|
|
75
65
|
};
|
|
76
66
|
|
|
77
67
|
const prepareDefaultActions = (actionExecutor) => {
|
|
78
|
-
actionExecutor.registerAction(
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
actionExecutor.registerAction(
|
|
84
|
-
ACTION_TYPES.SESSION_STORAGE_SET,
|
|
85
|
-
sessionStorageSetAction
|
|
86
|
-
);
|
|
87
|
-
|
|
88
|
-
actionExecutor.registerAction(
|
|
89
|
-
ACTION_TYPES.LOCAL_STORAGE_REMOVE,
|
|
90
|
-
localStorageRemoveAction
|
|
91
|
-
);
|
|
68
|
+
actionExecutor.registerAction("localStorageSet", localStorageSetAction);
|
|
69
|
+
actionExecutor.registerAction("sessionStorageSet", sessionStorageSetAction);
|
|
70
|
+
actionExecutor.registerAction("localStorageRemove", localStorageRemoveAction);
|
|
92
71
|
|
|
93
72
|
actionExecutor.registerAction(
|
|
94
|
-
|
|
73
|
+
"sessionStorageRemove",
|
|
95
74
|
sessionStorageRemoveAction
|
|
96
75
|
);
|
|
97
76
|
|
|
98
|
-
actionExecutor.registerAction(
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
);
|
|
102
|
-
|
|
103
|
-
actionExecutor.registerAction(ACTION_TYPES.SWITCH_LAYOUT, switchLayoutAction);
|
|
104
|
-
|
|
105
|
-
actionExecutor.registerAction(ACTION_TYPES.APP_RESTART, appRestartAction);
|
|
106
|
-
|
|
107
|
-
actionExecutor.registerAction(
|
|
108
|
-
ACTION_TYPES.CONFIRM_DIALOG,
|
|
109
|
-
confirmDialogAction
|
|
110
|
-
);
|
|
111
|
-
|
|
112
|
-
actionExecutor.registerAction(
|
|
113
|
-
ACTION_TYPES.SEND_CLOUD_EVENT,
|
|
114
|
-
sendCloudEventAction
|
|
115
|
-
);
|
|
77
|
+
actionExecutor.registerAction("refreshComponent", refreshComponentAction);
|
|
78
|
+
actionExecutor.registerAction("switchLayout", switchLayoutAction);
|
|
79
|
+
actionExecutor.registerAction("appRestart", appRestartAction);
|
|
80
|
+
actionExecutor.registerAction("confirmDialog", confirmDialogAction);
|
|
81
|
+
actionExecutor.registerAction("sendCloudEvent", sendCloudEventAction);
|
|
116
82
|
|
|
117
83
|
actionExecutor.registerAction(
|
|
118
|
-
|
|
84
|
+
"sessionStorageToggleFlag",
|
|
119
85
|
sessionStorageToggleFlagAction
|
|
120
86
|
);
|
|
121
87
|
|
|
122
88
|
actionExecutor.registerAction(
|
|
123
|
-
|
|
89
|
+
"localStorageToggleFlag",
|
|
124
90
|
localStorageToggleFlagAction
|
|
125
91
|
);
|
|
126
92
|
|
|
127
|
-
actionExecutor.registerAction(
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
);
|
|
131
|
-
|
|
132
|
-
actionExecutor.registerAction(
|
|
133
|
-
ACTION_TYPES.SCREEN_TOGGLE_FLAG,
|
|
134
|
-
screenToggleFlagAction
|
|
135
|
-
);
|
|
136
|
-
|
|
137
|
-
actionExecutor.registerAction(
|
|
138
|
-
ACTION_TYPES.OPEN_BOTTOM_SHEET,
|
|
139
|
-
openBottomSheetAction
|
|
140
|
-
);
|
|
141
|
-
|
|
142
|
-
actionExecutor.registerAction(
|
|
143
|
-
ACTION_TYPES.DISMISS_BOTTOM_SHEET,
|
|
144
|
-
dismissBottomSheetAction
|
|
145
|
-
);
|
|
146
|
-
|
|
147
|
-
actionExecutor.registerAction(ACTION_TYPES.SHOW_TOAST, showToastAction);
|
|
93
|
+
actionExecutor.registerAction("screenSetVariable", screenSetVariableAction);
|
|
94
|
+
actionExecutor.registerAction("screenToggleFlag", screenToggleFlagAction);
|
|
95
|
+
actionExecutor.registerAction("showToast", showToastAction);
|
|
148
96
|
};
|
|
149
97
|
|
|
150
98
|
export const ActionExecutorContext =
|
|
@@ -162,8 +110,6 @@ export function withActionExecutor(Component) {
|
|
|
162
110
|
return {
|
|
163
111
|
unregisterAction: _actionExecutor.unregisterAction,
|
|
164
112
|
registerAction: _actionExecutor.registerAction,
|
|
165
|
-
registerActionState: _actionExecutor.registerActionState,
|
|
166
|
-
getActionState: _actionExecutor.getActionState,
|
|
167
113
|
handleAction: _actionExecutor.handleAction,
|
|
168
114
|
handleActions: _actionExecutor.handleActions,
|
|
169
115
|
handleEntryActions: _actionExecutor.handleEntryActions,
|
|
@@ -186,7 +132,7 @@ export function withActionExecutor(Component) {
|
|
|
186
132
|
|
|
187
133
|
useEffect(() => {
|
|
188
134
|
return _actionExecutor.registerAction(
|
|
189
|
-
|
|
135
|
+
"navigateToScreen",
|
|
190
136
|
createNavigateToScreenAction(navigator, rivers, contentTypes)
|
|
191
137
|
);
|
|
192
138
|
}, [navigator, rivers, contentTypes]);
|
|
@@ -32,7 +32,3 @@ export { createGoBackAction } from "./goBack";
|
|
|
32
32
|
export { createGoHomeAction } from "./goHome";
|
|
33
33
|
|
|
34
34
|
export { showToastAction } from "./showToast";
|
|
35
|
-
|
|
36
|
-
export { openBottomSheetAction } from "./openBottomSheet";
|
|
37
|
-
|
|
38
|
-
export { dismissBottomSheetAction } from "./dismissBottomSheet";
|
|
@@ -82,12 +82,6 @@ export const refreshComponentAction: ActionHandler = async (
|
|
|
82
82
|
}) || source;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
if (!dataSource) {
|
|
86
|
-
log_info("handleAction: refreshComponent skipped: no dataSource found");
|
|
87
|
-
|
|
88
|
-
return ActionResult.Success;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
85
|
log_info(`handleAction: refreshComponent for dataSource:${dataSource}`, {
|
|
92
86
|
source,
|
|
93
87
|
inflatedUrl: dataSource,
|
|
@@ -62,15 +62,10 @@ export const sendCloudEventAction: ActionHandler<
|
|
|
62
62
|
subject: options.subject || String((entry as ZappEntry)?.id || ""),
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
-
log_info("handleAction:
|
|
66
|
-
url: options.url,
|
|
67
|
-
cloudEvent,
|
|
68
|
-
});
|
|
65
|
+
log_info("handleAction: sendCloudEvent event", { cloudEvent });
|
|
69
66
|
|
|
70
67
|
const { error, code } = await sendCloudEvent(cloudEvent, options.url);
|
|
71
68
|
|
|
72
|
-
log_info("handleAction: sendCloudEvent result", { code, error });
|
|
73
|
-
|
|
74
69
|
if (error) {
|
|
75
70
|
log_error("sendCloudEvent: error sending cloud event", { error });
|
|
76
71
|
|
|
@@ -2,26 +2,3 @@ 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
|
-
SHOW_TOAST: "showToast",
|
|
13
|
-
LOCAL_STORAGE_SET: "localStorageSet",
|
|
14
|
-
LOCAL_STORAGE_REMOVE: "localStorageRemove",
|
|
15
|
-
LOCAL_STORAGE_TOGGLE_FLAG: "localStorageToggleFlag",
|
|
16
|
-
SESSION_STORAGE_SET: "sessionStorageSet",
|
|
17
|
-
SESSION_STORAGE_REMOVE: "sessionStorageRemove",
|
|
18
|
-
SESSION_STORAGE_TOGGLE_FLAG: "sessionStorageToggleFlag",
|
|
19
|
-
REFRESH_COMPONENT: "refreshComponent",
|
|
20
|
-
SWITCH_LAYOUT: "switchLayout",
|
|
21
|
-
APP_RESTART: "appRestart",
|
|
22
|
-
CONFIRM_DIALOG: "confirmDialog",
|
|
23
|
-
SCREEN_SET_VARIABLE: "screenSetVariable",
|
|
24
|
-
SCREEN_TOGGLE_FLAG: "screenToggleFlag",
|
|
25
|
-
} as const;
|
|
26
|
-
|
|
27
|
-
export type KnownActionType = (typeof ACTION_TYPES)[keyof typeof ACTION_TYPES];
|
package/actionsExecutor/types.ts
CHANGED
|
@@ -31,7 +31,7 @@ export interface ActionExecutionContext {
|
|
|
31
31
|
/** Callback function for action completion */
|
|
32
32
|
callback?: (result: { success: boolean; error: any; abort: boolean }) => void;
|
|
33
33
|
|
|
34
|
-
screenState
|
|
34
|
+
screenState: Record<any, any>;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
/**
|
|
@@ -3,8 +3,8 @@ import { distinctUntilChanged } from "rxjs/operators";
|
|
|
3
3
|
import { Player } from "../player";
|
|
4
4
|
import { createLogger, utilsLogger } from "../../../logger";
|
|
5
5
|
import { appStore } from "@applicaster/zapp-react-native-redux/AppStore";
|
|
6
|
-
import { findPluginByIdentifier } from "../../../pluginUtils";
|
|
7
6
|
import {
|
|
7
|
+
findPluginByIdentifier,
|
|
8
8
|
loadFeedEntry,
|
|
9
9
|
loadFeedAndPrefetchThumbnailImage,
|
|
10
10
|
parseTimeToSeconds,
|
|
@@ -252,10 +252,7 @@ export class OverlaysObserver {
|
|
|
252
252
|
return;
|
|
253
253
|
}
|
|
254
254
|
|
|
255
|
-
const playNextFeedUrl: string =
|
|
256
|
-
this.entry,
|
|
257
|
-
plugins
|
|
258
|
-
);
|
|
255
|
+
const playNextFeedUrl: string = retrieveFeedUrl(this.entry);
|
|
259
256
|
|
|
260
257
|
if (!playNextFeedUrl || typeof playNextFeedUrl !== "string") {
|
|
261
258
|
log_debug(
|
|
@@ -1,66 +1,13 @@
|
|
|
1
|
-
const mockGetUpcomingQueue = jest.fn();
|
|
2
|
-
|
|
3
|
-
jest.mock("../getUpcomingQueue", () => ({
|
|
4
|
-
getUpcomingQueue: (...args: unknown[]) => mockGetUpcomingQueue(...args),
|
|
5
|
-
}));
|
|
6
|
-
|
|
7
1
|
import { retrieveFeedUrl, retrievePlayPreviousFeedUrl } from "../utils";
|
|
8
2
|
|
|
9
3
|
const entryWith = (extensions: Record<string, unknown>): ZappEntry =>
|
|
10
4
|
({ id: "1", type: { value: "video" }, extensions }) as ZappEntry;
|
|
11
5
|
|
|
12
|
-
const queuePlugin = { identifier: "queue-action" } as ZappPlugin;
|
|
13
|
-
|
|
14
6
|
describe("playlist feed url accessors", () => {
|
|
15
|
-
|
|
16
|
-
mockGetUpcomingQueue.mockReset();
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it("returns the next feed url when present", async () => {
|
|
20
|
-
const entry = entryWith({ play_next_feed_url: "https://feeds/next.json" });
|
|
21
|
-
|
|
22
|
-
await expect(retrieveFeedUrl(entry, [])).resolves.toBe(
|
|
23
|
-
"https://feeds/next.json"
|
|
24
|
-
);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it("resolves to null for a missing entry", async () => {
|
|
28
|
-
await expect(
|
|
29
|
-
retrieveFeedUrl(undefined as unknown as ZappEntry, [])
|
|
30
|
-
).resolves.toBeNull();
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it("returns a queue play-next url when upcoming items exist", async () => {
|
|
34
|
-
mockGetUpcomingQueue.mockResolvedValue([{ id: "next-item" }]);
|
|
35
|
-
|
|
36
|
-
const entry = entryWith({
|
|
37
|
-
play_next_feed_url: "https://feeds/next.json",
|
|
38
|
-
queueItemId: "queue-1",
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
await expect(retrieveFeedUrl(entry, [queuePlugin])).resolves.toBe(
|
|
42
|
-
"pipesv2://queue-action/play-next?queueItemId=queue-1"
|
|
43
|
-
);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it("falls back to the next feed url when the upcoming queue is empty", async () => {
|
|
47
|
-
mockGetUpcomingQueue.mockResolvedValue([]);
|
|
48
|
-
|
|
49
|
-
const entry = entryWith({ play_next_feed_url: "https://feeds/next.json" });
|
|
50
|
-
|
|
51
|
-
await expect(retrieveFeedUrl(entry, [queuePlugin])).resolves.toBe(
|
|
52
|
-
"https://feeds/next.json"
|
|
53
|
-
);
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it("falls back to the next feed url when QueueManager cannot be resolved", async () => {
|
|
57
|
-
mockGetUpcomingQueue.mockRejectedValue(new Error("not available"));
|
|
58
|
-
|
|
7
|
+
it("returns the next feed url when present", () => {
|
|
59
8
|
const entry = entryWith({ play_next_feed_url: "https://feeds/next.json" });
|
|
60
9
|
|
|
61
|
-
|
|
62
|
-
"https://feeds/next.json"
|
|
63
|
-
);
|
|
10
|
+
expect(retrieveFeedUrl(entry)).toBe("https://feeds/next.json");
|
|
64
11
|
});
|
|
65
12
|
|
|
66
13
|
it("returns the previous feed url when present", () => {
|
|
@@ -3,13 +3,10 @@ import {
|
|
|
3
3
|
PipesClientResponseHelper,
|
|
4
4
|
RequestBuilder,
|
|
5
5
|
} from "@applicaster/zapp-pipes-v2-client";
|
|
6
|
-
import { appStore } from "@applicaster/zapp-react-native-redux/AppStore";
|
|
7
6
|
import { log_error, log_info } from "./OverlaysObserver";
|
|
7
|
+
import * as R from "ramda";
|
|
8
8
|
import { toNumber, toNumberWithDefault } from "../../../numberUtils";
|
|
9
9
|
|
|
10
|
-
import { findPluginByIdentifier } from "../../../pluginUtils";
|
|
11
|
-
import { getUpcomingQueue } from "./getUpcomingQueue";
|
|
12
|
-
|
|
13
10
|
export const parseTimeToSeconds = (timeStr: string): number => {
|
|
14
11
|
const validationError = new Error("Invalid time format");
|
|
15
12
|
|
|
@@ -43,58 +40,14 @@ export const parseTimeToSeconds = (timeStr: string): number => {
|
|
|
43
40
|
}
|
|
44
41
|
};
|
|
45
42
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
* Resolves the play_next_feed_url dynamically for OverlaysObserver.
|
|
49
|
-
*
|
|
50
|
-
* WHY THIS IS HACKED HERE:
|
|
51
|
-
* OverlaysObserver was originally designed as a Recommendation Overlay engine (fetching static
|
|
52
|
-
* play_next_feed_url for overlay UI visuals). However, for dynamic queue & continuous audio playback,
|
|
53
|
-
* modifying feeds via `decorateFeed` at load time doesn't work (due to feed caching and mid-playback queue mutations).
|
|
54
|
-
* To avoid mutating feed payloads across the app, we temporarily intercept play_next_feed_url here
|
|
55
|
-
* at runtime to check if QueueManager has active/upcoming queue items.
|
|
56
|
-
*
|
|
57
|
-
* FUTURE ARCHITECTURE / TODO:
|
|
58
|
-
* Move queue/playlist resolution into a dedicated Player/Queue Provider module (or Handler Chain)
|
|
59
|
-
* on playerManager, decoupling Queue playback logic entirely from OverlaysObserver (which should
|
|
60
|
-
* strictly focus on recommendation visuals and chapter markers).
|
|
61
|
-
*/
|
|
62
|
-
export const retrieveFeedUrl = async (
|
|
63
|
-
entry: ZappEntry,
|
|
64
|
-
plugins?: ZappPlugin[]
|
|
65
|
-
): Promise<string> => {
|
|
66
|
-
if (!entry) return null;
|
|
67
|
-
|
|
68
|
-
const availablePlugins = plugins || appStore.get("plugins");
|
|
69
|
-
|
|
70
|
-
const queuePlugin = findPluginByIdentifier(
|
|
71
|
-
"queue-action",
|
|
72
|
-
availablePlugins,
|
|
73
|
-
true
|
|
74
|
-
);
|
|
75
|
-
|
|
76
|
-
if (queuePlugin) {
|
|
77
|
-
try {
|
|
78
|
-
const upcomingQueue = await getUpcomingQueue(queuePlugin);
|
|
79
|
-
|
|
80
|
-
if (upcomingQueue && upcomingQueue.length > 0) {
|
|
81
|
-
const queueItemId = entry?.extensions?.queueItemId || entry?.id;
|
|
82
|
-
|
|
83
|
-
return `pipesv2://queue-action/play-next?queueItemId=${queueItemId}`;
|
|
84
|
-
}
|
|
85
|
-
} catch (e) {
|
|
86
|
-
log_error("retrieveFeedUrl: Failed to resolve QueueManager", e);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return entry?.extensions?.play_next_feed_url;
|
|
91
|
-
};
|
|
43
|
+
export const retrieveFeedUrl = (entry: ZappEntry) =>
|
|
44
|
+
entry?.extensions?.play_next_feed_url;
|
|
92
45
|
|
|
93
46
|
export const retrievePlayPreviousFeedUrl = (entry: ZappEntry) =>
|
|
94
47
|
entry?.extensions?.play_previous_feed_url;
|
|
95
48
|
|
|
96
49
|
export const retrieveOverlayDuration = (plugin) =>
|
|
97
|
-
toNumberWithDefault(
|
|
50
|
+
toNumberWithDefault(plugin?.configuration?.overlay_duration, 15);
|
|
98
51
|
|
|
99
52
|
export const retrieveOverlayTriggerOffset = (item: ZappEntry) => {
|
|
100
53
|
return item && item.extensions && item.extensions.overlay_timestamp
|
|
@@ -200,3 +153,19 @@ export const loadFeedAndPrefetchThumbnailImage = async (
|
|
|
200
153
|
|
|
201
154
|
return playNextEntry;
|
|
202
155
|
};
|
|
156
|
+
|
|
157
|
+
export const findPluginByIdentifier = (
|
|
158
|
+
identifier: string,
|
|
159
|
+
plugins: ZappPlugin[]
|
|
160
|
+
): ZappPlugin => {
|
|
161
|
+
if (!identifier) {
|
|
162
|
+
return undefined;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const plugin = R.compose(
|
|
166
|
+
R.find(R.propEq("identifier", identifier)),
|
|
167
|
+
R.values
|
|
168
|
+
)(plugins);
|
|
169
|
+
|
|
170
|
+
return plugin;
|
|
171
|
+
};
|
package/arrayUtils/index.ts
CHANGED
|
@@ -121,82 +121,3 @@ export const allTruthy = (xs: boolean[]) =>
|
|
|
121
121
|
isFilledArray(xs) && xs.every(Boolean);
|
|
122
122
|
|
|
123
123
|
export const anyTruthy = (xs: boolean[]) => xs.some(Boolean);
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Reorders `items` based on an ordered array of IDs (`orderedIds`).
|
|
127
|
-
* Items whose IDs are in `orderedIds` appear first in that exact sequence.
|
|
128
|
-
* Any remaining items not present in `orderedIds` are appended at the end preserving their relative order.
|
|
129
|
-
*/
|
|
130
|
-
export function reorderByIds<T>(
|
|
131
|
-
items: T[],
|
|
132
|
-
orderedIds: string[],
|
|
133
|
-
getId: (item: T) => string | string[] = (item: any) => item?.id
|
|
134
|
-
): T[] {
|
|
135
|
-
if (!items || items.length === 0) return [];
|
|
136
|
-
if (!orderedIds || orderedIds.length === 0) return [...items];
|
|
137
|
-
|
|
138
|
-
const itemMap = new Map<string, T>();
|
|
139
|
-
|
|
140
|
-
items.forEach((item) => {
|
|
141
|
-
const rawId = getId(item);
|
|
142
|
-
const keys = Array.isArray(rawId) ? rawId : [rawId];
|
|
143
|
-
|
|
144
|
-
keys.forEach((key) => {
|
|
145
|
-
if (key !== undefined && key !== null && key !== "") {
|
|
146
|
-
itemMap.set(String(key), item);
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
const reorderedSubset: T[] = [];
|
|
152
|
-
const orderedIdsSet = new Set<string>();
|
|
153
|
-
|
|
154
|
-
orderedIds.forEach((id) => {
|
|
155
|
-
const strId = String(id);
|
|
156
|
-
const item = itemMap.get(strId);
|
|
157
|
-
|
|
158
|
-
if (item && !reorderedSubset.includes(item)) {
|
|
159
|
-
reorderedSubset.push(item);
|
|
160
|
-
const rawId = getId(item);
|
|
161
|
-
const keys = Array.isArray(rawId) ? rawId : [rawId];
|
|
162
|
-
|
|
163
|
-
keys.forEach((k) => {
|
|
164
|
-
if (k !== undefined && k !== null && k !== "") {
|
|
165
|
-
orderedIdsSet.add(String(k));
|
|
166
|
-
}
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
if (reorderedSubset.length === 0) return [...items];
|
|
172
|
-
|
|
173
|
-
let subsetIdx = 0;
|
|
174
|
-
const result: T[] = [];
|
|
175
|
-
|
|
176
|
-
items.forEach((item) => {
|
|
177
|
-
const rawId = getId(item);
|
|
178
|
-
const keys = Array.isArray(rawId) ? rawId : [rawId];
|
|
179
|
-
|
|
180
|
-
const isMatched = keys.some(
|
|
181
|
-
(k) =>
|
|
182
|
-
k !== undefined &&
|
|
183
|
-
k !== null &&
|
|
184
|
-
k !== "" &&
|
|
185
|
-
orderedIdsSet.has(String(k))
|
|
186
|
-
);
|
|
187
|
-
|
|
188
|
-
if (isMatched) {
|
|
189
|
-
if (subsetIdx < reorderedSubset.length) {
|
|
190
|
-
result.push(reorderedSubset[subsetIdx++]);
|
|
191
|
-
}
|
|
192
|
-
} else {
|
|
193
|
-
result.push(item);
|
|
194
|
-
}
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
while (subsetIdx < reorderedSubset.length) {
|
|
198
|
-
result.push(reorderedSubset[subsetIdx++]);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
return result;
|
|
202
|
-
}
|
|
@@ -176,27 +176,6 @@ describe("getAllSpecificStyles", () => {
|
|
|
176
176
|
});
|
|
177
177
|
});
|
|
178
178
|
|
|
179
|
-
it("should normalize Studio focus alias onto focused state", () => {
|
|
180
|
-
const outStyles = {};
|
|
181
|
-
|
|
182
|
-
const configuration = {
|
|
183
|
-
button_style_focus_background_color: "#FF3B30",
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
getAllSpecificStyles({
|
|
187
|
-
componentName: "button",
|
|
188
|
-
subComponentName: "",
|
|
189
|
-
configuration,
|
|
190
|
-
outStyles,
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
expect(outStyles.focused).toEqual({
|
|
194
|
-
backgroundColor: "#FF3B30",
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
expect(outStyles.focus).toBeUndefined();
|
|
198
|
-
});
|
|
199
|
-
|
|
200
179
|
it("should handle selected state", () => {
|
|
201
180
|
const outStyles = {};
|
|
202
181
|
|