@applicaster/zapp-react-native-utils 15.1.21 → 15.1.22
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/actions/__tests__/openBottomSheet.inlineItems.test.ts +72 -0
- package/actionsExecutor/actions/openBottomSheet.ts +1 -0
- package/appUtils/playerManager/__tests__/playerDiagnostics.test.ts +62 -0
- package/appUtils/playerManager/__tests__/playerToolbox.test.ts +185 -1
- package/appUtils/playerManager/player.ts +15 -0
- package/appUtils/playerManager/playerToolbox.ts +41 -2
- package/configurationUtils/__tests__/modalBlocksParser.test.ts +46 -34
- package/configurationUtils/modalBlocksParser.ts +10 -106
- package/entryActions/__tests__/buildEntryActions.test.ts +58 -18
- package/entryActions/aliasPresentation.ts +26 -42
- package/entryActions/index.ts +0 -2
- package/modalState/ModalOrchestrator.ts +1 -0
- package/modalState/__tests__/ModalOrchestrator.phase3.test.ts +23 -0
- package/modalState/index.ts +2 -0
- package/modalState/types.ts +11 -0
- package/package.json +2 -2
|
@@ -2,6 +2,22 @@ import { openBottomSheetAction } from "../openBottomSheet";
|
|
|
2
2
|
import { actionExecutor, ActionResult } from "../../ActionExecutor";
|
|
3
3
|
import { modalOrchestrator } from "../../../modalState/ModalOrchestrator";
|
|
4
4
|
|
|
5
|
+
jest.mock("@applicaster/zapp-pipes-v2-client", () => ({
|
|
6
|
+
PipesClientResponseHelper: jest.fn(() => ({ error: null })),
|
|
7
|
+
RequestBuilder: jest.fn(() => ({
|
|
8
|
+
setEntryContext: jest.fn().mockReturnThis(),
|
|
9
|
+
setScreenContext: jest.fn().mockReturnThis(),
|
|
10
|
+
setUrl: jest.fn().mockReturnThis(),
|
|
11
|
+
buildAxiosRequest: jest.fn().mockResolvedValue(undefined),
|
|
12
|
+
call: jest.fn().mockResolvedValue({
|
|
13
|
+
response: {
|
|
14
|
+
entry: [],
|
|
15
|
+
extensions: { dynamic_collection_options: { operations: "add" } },
|
|
16
|
+
},
|
|
17
|
+
}),
|
|
18
|
+
})),
|
|
19
|
+
}));
|
|
20
|
+
|
|
5
21
|
jest.mock("../../../modalState/store", () => ({
|
|
6
22
|
openBottomSheetModal: jest.fn(),
|
|
7
23
|
}));
|
|
@@ -165,6 +181,62 @@ describe("openBottomSheetAction inline items", () => {
|
|
|
165
181
|
expect(menu.content.emptyMessage).toBe("Queued items will be added here");
|
|
166
182
|
});
|
|
167
183
|
|
|
184
|
+
it("forwards content.operationButtons onto the menu", async () => {
|
|
185
|
+
const result = await openBottomSheetAction({
|
|
186
|
+
type: "openBottomSheet",
|
|
187
|
+
options: {
|
|
188
|
+
header: { title: "Playlists" },
|
|
189
|
+
content: {
|
|
190
|
+
items: [{ id: "p1", title: "Playlist 1" }],
|
|
191
|
+
operationButtons: {
|
|
192
|
+
add: {
|
|
193
|
+
title: "Create New Playlist",
|
|
194
|
+
iconURL: "https://example.com/add.png",
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
} as any);
|
|
200
|
+
|
|
201
|
+
expect(result).toBe(ActionResult.Success);
|
|
202
|
+
|
|
203
|
+
const [menu] = (modalOrchestrator.open as jest.Mock).mock.calls[0];
|
|
204
|
+
|
|
205
|
+
expect(menu.content.operationButtons).toEqual({
|
|
206
|
+
add: {
|
|
207
|
+
title: "Create New Playlist",
|
|
208
|
+
iconURL: "https://example.com/add.png",
|
|
209
|
+
},
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
it("preserves Add presentation when loading itemsUrl content", async () => {
|
|
214
|
+
const result = await openBottomSheetAction({
|
|
215
|
+
type: "openBottomSheet",
|
|
216
|
+
options: {
|
|
217
|
+
content: {
|
|
218
|
+
itemsUrl: "https://example.com/collections",
|
|
219
|
+
operationButtons: {
|
|
220
|
+
add: {
|
|
221
|
+
title: "Create Collection",
|
|
222
|
+
iconURL: "file:///bundled-add.png",
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
},
|
|
226
|
+
},
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
expect(result).toBe(ActionResult.Success);
|
|
230
|
+
const [menu] = (modalOrchestrator.open as jest.Mock).mock.calls[0];
|
|
231
|
+
|
|
232
|
+
expect(menu.content).toMatchObject({
|
|
233
|
+
operationButtons: {
|
|
234
|
+
add: { title: "Create Collection", iconURL: "file:///bundled-add.png" },
|
|
235
|
+
},
|
|
236
|
+
dynamicCollection: { operations: ["add"] },
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
|
|
168
240
|
it("pushes a new sheet by default even when another sheet is already open", async () => {
|
|
169
241
|
(modalOrchestrator as any).stackSize = 1;
|
|
170
242
|
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Player } from "../player";
|
|
2
|
+
|
|
3
|
+
const entry = (id: string) => ({ id, title: id }) as unknown as ZappEntry;
|
|
4
|
+
|
|
5
|
+
const makePlayer = () => {
|
|
6
|
+
const player = new Player({ playerId: "test-player" });
|
|
7
|
+
player.entry = entry("first");
|
|
8
|
+
|
|
9
|
+
return player;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
describe("Player per-entry diagnostics", () => {
|
|
13
|
+
it("keeps the latest of onError and onVideoError, and clears it when a new entry loads", () => {
|
|
14
|
+
const player = makePlayer();
|
|
15
|
+
const second = { message: "second" };
|
|
16
|
+
|
|
17
|
+
player.onError({ message: "first" } as any);
|
|
18
|
+
player.onVideoError(second as any);
|
|
19
|
+
|
|
20
|
+
expect(player.lastError).toBe(second);
|
|
21
|
+
|
|
22
|
+
player.entry = entry("second");
|
|
23
|
+
|
|
24
|
+
expect(player.lastError).toBeNull();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("reads the next entry without creating the overlay observer", () => {
|
|
28
|
+
const player = makePlayer();
|
|
29
|
+
|
|
30
|
+
expect(player.getPlayNextEntry()).toBeNull();
|
|
31
|
+
|
|
32
|
+
jest
|
|
33
|
+
.spyOn(player.getOverlayObservable(), "getPlayNextEntry")
|
|
34
|
+
.mockReturnValue(entry("next"));
|
|
35
|
+
|
|
36
|
+
expect(player.getPlayNextEntry()).toEqual(entry("next"));
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it("keeps the content clock while a client-side ad plays", () => {
|
|
40
|
+
const player = makePlayer();
|
|
41
|
+
|
|
42
|
+
player.onVideoProgress({
|
|
43
|
+
currentTime: 300,
|
|
44
|
+
duration: 1800,
|
|
45
|
+
seekableDuration: 1800,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
player.onAdBegin({});
|
|
49
|
+
|
|
50
|
+
player.onVideoProgress({
|
|
51
|
+
currentTime: 5,
|
|
52
|
+
duration: 15,
|
|
53
|
+
seekableDuration: 15,
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
expect(player.getPosition()).toBe(5);
|
|
57
|
+
expect(player.getDuration()).toBe(15);
|
|
58
|
+
expect(player.getContentPosition()).toBe(300);
|
|
59
|
+
expect(player.getContentDuration()).toBe(1800);
|
|
60
|
+
expect(player.getSeekableDuration()).toBe(1800);
|
|
61
|
+
});
|
|
62
|
+
});
|
|
@@ -18,6 +18,9 @@ const loadToolbox = () => {
|
|
|
18
18
|
const player = (overrides = {}) => ({
|
|
19
19
|
getSeekableDuration: () => 100,
|
|
20
20
|
getContentPosition: () => 40,
|
|
21
|
+
isLive: () => false,
|
|
22
|
+
getPlayNextEntry: () => null,
|
|
23
|
+
playNextHandler: jest.fn(),
|
|
21
24
|
seekTo: jest.fn(),
|
|
22
25
|
...overrides,
|
|
23
26
|
});
|
|
@@ -30,7 +33,7 @@ const registeredTools = async (active) => {
|
|
|
30
33
|
mockXray = { registerReactToolbox: mockRegister };
|
|
31
34
|
await loadToolbox().registerPlayerToolbox(manager(active));
|
|
32
35
|
|
|
33
|
-
const { tools } = mockRegister.mock.
|
|
36
|
+
const { tools } = mockRegister.mock.lastCall[0];
|
|
34
37
|
|
|
35
38
|
return Object.fromEntries(tools.map((tool) => [tool.name, tool.handler]));
|
|
36
39
|
};
|
|
@@ -87,6 +90,187 @@ describe("playerToolbox", () => {
|
|
|
87
90
|
);
|
|
88
91
|
});
|
|
89
92
|
|
|
93
|
+
describe("state", () => {
|
|
94
|
+
const playing = (overrides = {}, entry: any = { id: "e1", title: "T" }) =>
|
|
95
|
+
player({
|
|
96
|
+
playerId: "p1",
|
|
97
|
+
playerRole: "Primary",
|
|
98
|
+
getEntry: () => entry,
|
|
99
|
+
getPosition: () => 40,
|
|
100
|
+
getDuration: () => 100,
|
|
101
|
+
getContentDuration: () => 100,
|
|
102
|
+
isReadyToPlay: () => true,
|
|
103
|
+
isPlaying: () => true,
|
|
104
|
+
isBuffering: () => false,
|
|
105
|
+
isAd: () => false,
|
|
106
|
+
isLive: () => false,
|
|
107
|
+
getIsMuted: () => false,
|
|
108
|
+
...overrides,
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
const state = async (overrides = {}, entry?: any) =>
|
|
112
|
+
(await registeredTools(playing(overrides, entry))).state();
|
|
113
|
+
|
|
114
|
+
it("reports inactive when nothing plays", async () => {
|
|
115
|
+
expect((await registeredTools(null)).state()).toEqual({
|
|
116
|
+
active: false,
|
|
117
|
+
casting: false,
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it("keeps the existing fields and adds the content clock for a VOD", async () => {
|
|
122
|
+
expect(await state()).toEqual({
|
|
123
|
+
active: true,
|
|
124
|
+
playerId: "p1",
|
|
125
|
+
entry: { id: "e1", title: "T" },
|
|
126
|
+
position: 40,
|
|
127
|
+
duration: 100,
|
|
128
|
+
playing: true,
|
|
129
|
+
buffering: false,
|
|
130
|
+
readyToPlay: true,
|
|
131
|
+
ad: false,
|
|
132
|
+
live: false,
|
|
133
|
+
muted: false,
|
|
134
|
+
role: "Primary",
|
|
135
|
+
plugin: null,
|
|
136
|
+
engine: null,
|
|
137
|
+
casting: false,
|
|
138
|
+
seekableDuration: 100,
|
|
139
|
+
contentPosition: 40,
|
|
140
|
+
contentDuration: 100,
|
|
141
|
+
drm: null,
|
|
142
|
+
lastError: null,
|
|
143
|
+
next: null,
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it("reports the content's clock next to the ad's during a client-side ad", async () => {
|
|
148
|
+
const result = await state({
|
|
149
|
+
isAd: () => true,
|
|
150
|
+
getPosition: () => 5,
|
|
151
|
+
getDuration: () => 15,
|
|
152
|
+
getContentPosition: () => 300,
|
|
153
|
+
getContentDuration: () => 1800,
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
expect(result).toMatchObject({
|
|
157
|
+
ad: true,
|
|
158
|
+
position: 5,
|
|
159
|
+
duration: 15,
|
|
160
|
+
contentPosition: 300,
|
|
161
|
+
contentDuration: 1800,
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it("reports non-finite numbers as null", async () => {
|
|
166
|
+
expect(
|
|
167
|
+
await state({
|
|
168
|
+
getSeekableDuration: () => NaN,
|
|
169
|
+
getContentPosition: () => null,
|
|
170
|
+
getContentDuration: () => Infinity,
|
|
171
|
+
})
|
|
172
|
+
).toMatchObject({
|
|
173
|
+
seekableDuration: null,
|
|
174
|
+
contentPosition: null,
|
|
175
|
+
contentDuration: null,
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
it("reports the player plugin and its web engine", async () => {
|
|
180
|
+
expect(
|
|
181
|
+
await state({
|
|
182
|
+
playerPluginId: "QuickBrickPlayerPlugin",
|
|
183
|
+
engine: "hls.js",
|
|
184
|
+
})
|
|
185
|
+
).toMatchObject({ plugin: "QuickBrickPlayerPlugin", engine: "hls.js" });
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
it("lists the entry's DRM key systems, or null", async () => {
|
|
189
|
+
const drm = { widevine: { license_url: "w" }, playready: {} };
|
|
190
|
+
|
|
191
|
+
expect((await state({}, { id: "e", extensions: { drm } })).drm).toEqual([
|
|
192
|
+
"widevine",
|
|
193
|
+
"playready",
|
|
194
|
+
]);
|
|
195
|
+
|
|
196
|
+
expect((await state({}, { id: "e", extensions: { drm: {} } })).drm).toBe(
|
|
197
|
+
null
|
|
198
|
+
);
|
|
199
|
+
|
|
200
|
+
expect((await state({}, { id: "e", extensions: {} })).drm).toBe(null);
|
|
201
|
+
expect((await state({}, null)).drm).toBe(null);
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
it("reports no last error as null", async () => {
|
|
205
|
+
expect((await state({ lastError: null })).lastError).toBeNull();
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
describe("play next", () => {
|
|
210
|
+
const nextEntry = { id: "n1", title: "Next", extensions: {} };
|
|
211
|
+
|
|
212
|
+
const stateWith = async (overrides) =>
|
|
213
|
+
(
|
|
214
|
+
await registeredTools(
|
|
215
|
+
player({
|
|
216
|
+
getEntry: () => null,
|
|
217
|
+
getPosition: () => 0,
|
|
218
|
+
getDuration: () => 0,
|
|
219
|
+
getContentDuration: () => 0,
|
|
220
|
+
isReadyToPlay: () => true,
|
|
221
|
+
isPlaying: () => true,
|
|
222
|
+
isBuffering: () => false,
|
|
223
|
+
isAd: () => false,
|
|
224
|
+
getIsMuted: () => false,
|
|
225
|
+
...overrides,
|
|
226
|
+
})
|
|
227
|
+
)
|
|
228
|
+
).state();
|
|
229
|
+
|
|
230
|
+
it("reports the entry Play Next would play", async () => {
|
|
231
|
+
expect(
|
|
232
|
+
(await stateWith({ getPlayNextEntry: () => nextEntry })).next
|
|
233
|
+
).toEqual({ id: "n1", title: "Next" });
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
it("reports no next entry as null", async () => {
|
|
237
|
+
expect((await stateWith({})).next).toBeNull();
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
it("plays the next entry through the player's Play Next action", async () => {
|
|
241
|
+
const active = player({ getPlayNextEntry: () => nextEntry });
|
|
242
|
+
const tools = await registeredTools(active);
|
|
243
|
+
|
|
244
|
+
expect(tools.next()).toEqual({ id: "n1", title: "Next" });
|
|
245
|
+
expect(active.playNextHandler).toHaveBeenCalledTimes(1);
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
it("fails without a next entry", async () => {
|
|
249
|
+
const active = player();
|
|
250
|
+
const tools = await registeredTools(active);
|
|
251
|
+
|
|
252
|
+
expect(() => tools.next()).toThrow("No next item");
|
|
253
|
+
expect(active.playNextHandler).not.toHaveBeenCalled();
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
it("fails when no Play Next action is registered", async () => {
|
|
257
|
+
const tools = await registeredTools(
|
|
258
|
+
player({
|
|
259
|
+
getPlayNextEntry: () => nextEntry,
|
|
260
|
+
playNextHandler: null,
|
|
261
|
+
})
|
|
262
|
+
);
|
|
263
|
+
|
|
264
|
+
expect(() => tools.next()).toThrow("No next item");
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
it("fails without an active player", async () => {
|
|
268
|
+
const tools = await registeredTools(null);
|
|
269
|
+
|
|
270
|
+
expect(() => tools.next()).toThrow("No active player");
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
|
|
90
274
|
it("refuses to seek a stream that is not seekable", async () => {
|
|
91
275
|
const tools = await registeredTools(
|
|
92
276
|
player({ getSeekableDuration: () => 0 })
|
|
@@ -76,6 +76,12 @@ export class Player {
|
|
|
76
76
|
private overlaysObserver?: OverlaysObserver | null;
|
|
77
77
|
private entryObservable?: BehaviorSubject<ZappEntry> | null;
|
|
78
78
|
private contentSubject?: BehaviorSubject<PlayerContent> | null;
|
|
79
|
+
// Read by the X-Ray `player` toolbox: the last onError/onVideoError of the current entry,
|
|
80
|
+
// and the Play Next action of the PlayerContainer showing this player.
|
|
81
|
+
public lastError: unknown = null;
|
|
82
|
+
public playNextHandler: (() => void) | null = null;
|
|
83
|
+
// The web engine the default player picked (hls.js, dash.js, shaka, video.js); null elsewhere.
|
|
84
|
+
public engine: string | null = null;
|
|
79
85
|
|
|
80
86
|
protected listeners: {
|
|
81
87
|
[key: string]: QuickBrickPlayer.SharedPlayerCallBacks;
|
|
@@ -89,6 +95,7 @@ export class Player {
|
|
|
89
95
|
|
|
90
96
|
set entry(newEntry: ZappEntry | null) {
|
|
91
97
|
this._entry = newEntry;
|
|
98
|
+
this.lastError = null;
|
|
92
99
|
// The live entry is scoped to the entry it overlays - see
|
|
93
100
|
// `OverlaysObserver.clearLiveEntry`. No-op when there is no observer,
|
|
94
101
|
// which is every non-live player.
|
|
@@ -271,6 +278,10 @@ export class Player {
|
|
|
271
278
|
|
|
272
279
|
getEntry = (): ZappEntry | null => this.entry;
|
|
273
280
|
|
|
281
|
+
/** The entry Play Next would play now; null without one. Never creates the overlay observer. */
|
|
282
|
+
getPlayNextEntry = (): ZappEntry | null =>
|
|
283
|
+
this.overlaysObserver?.getPlayNextEntry() ?? null;
|
|
284
|
+
|
|
274
285
|
logState = (text, additionalParams = {}) => {
|
|
275
286
|
const isSeeking = this.playerState.seekPosition !== null;
|
|
276
287
|
|
|
@@ -488,6 +499,8 @@ export class Player {
|
|
|
488
499
|
};
|
|
489
500
|
|
|
490
501
|
onVideoError = (error: Error) => {
|
|
502
|
+
this.lastError = error;
|
|
503
|
+
|
|
491
504
|
this.invokeListenersUpdate({
|
|
492
505
|
callbackName: SharedPlayerCallBacksKeys.OnVideoError,
|
|
493
506
|
event: error,
|
|
@@ -495,6 +508,8 @@ export class Player {
|
|
|
495
508
|
};
|
|
496
509
|
|
|
497
510
|
onError = (error: Error) => {
|
|
511
|
+
this.lastError = error;
|
|
512
|
+
|
|
498
513
|
this.invokeListenersUpdate({
|
|
499
514
|
callbackName: SharedPlayerCallBacksKeys.OnError,
|
|
500
515
|
event: error,
|
|
@@ -14,6 +14,12 @@ const toNumber = (value: unknown) =>
|
|
|
14
14
|
|
|
15
15
|
const clamp = (value: number, max: number) => Math.min(Math.max(value, 0), max);
|
|
16
16
|
|
|
17
|
+
/** Key systems the entry declares (widevine, playready, fairplay...). */
|
|
18
|
+
const drmKeySystems = (drm: unknown) =>
|
|
19
|
+
drm && typeof drm === "object" && Object.keys(drm).length
|
|
20
|
+
? Object.keys(drm)
|
|
21
|
+
: null;
|
|
22
|
+
|
|
17
23
|
/** The range a seek can reach: the DVR window on live, the content on VOD. */
|
|
18
24
|
const requireSeekable = (player: {
|
|
19
25
|
getSeekableDuration: () => number | undefined;
|
|
@@ -38,14 +44,21 @@ const tools = (manager: PlayerManager): XrayToolSpec[] => {
|
|
|
38
44
|
{
|
|
39
45
|
name: "state",
|
|
40
46
|
description:
|
|
41
|
-
"The active player: entry, position and duration in seconds
|
|
42
|
-
"role (Primary, Cell, Chromecast) and casting
|
|
47
|
+
"The active player: entry, position and duration in seconds (the ad's while an ad plays), " +
|
|
48
|
+
"playing/buffering/ad/live/muted, role (Primary, Cell, Chromecast) and casting; in seconds, " +
|
|
49
|
+
"seekableDuration and contentPosition/contentDuration (the content's, even during ads); " +
|
|
50
|
+
"drm key systems, lastError {message} and next {id, title}, each null when absent; " +
|
|
51
|
+
"plugin (player plugin id) and engine (the default player's web engine, else null). " +
|
|
52
|
+
"active: false when nothing plays.",
|
|
43
53
|
handler: () => {
|
|
44
54
|
const player = manager.getActivePlayer();
|
|
45
55
|
|
|
46
56
|
if (!player) return { active: false, casting: manager.isCasting() };
|
|
47
57
|
|
|
48
58
|
const entry = player.getEntry();
|
|
59
|
+
const seekableDuration = toNumber(player.getSeekableDuration());
|
|
60
|
+
const next = player.getPlayNextEntry();
|
|
61
|
+
const error: any = player.lastError;
|
|
49
62
|
|
|
50
63
|
return {
|
|
51
64
|
active: true,
|
|
@@ -61,7 +74,18 @@ const tools = (manager: PlayerManager): XrayToolSpec[] => {
|
|
|
61
74
|
live: !!player.isLive(),
|
|
62
75
|
muted: !!player.getIsMuted(),
|
|
63
76
|
role: player.playerRole,
|
|
77
|
+
plugin: player.playerPluginId ?? null,
|
|
78
|
+
engine: player.engine ?? null,
|
|
64
79
|
casting: manager.isCasting(),
|
|
80
|
+
seekableDuration,
|
|
81
|
+
contentPosition: toNumber(player.getContentPosition()),
|
|
82
|
+
contentDuration: toNumber(player.getContentDuration()),
|
|
83
|
+
drm: drmKeySystems(entry?.extensions?.drm),
|
|
84
|
+
lastError:
|
|
85
|
+
error == null
|
|
86
|
+
? null
|
|
87
|
+
: { message: String(error?.message ?? error?.error ?? error) },
|
|
88
|
+
next: next ? { id: next.id, title: next.title } : null,
|
|
65
89
|
};
|
|
66
90
|
},
|
|
67
91
|
},
|
|
@@ -83,6 +107,21 @@ const tools = (manager: PlayerManager): XrayToolSpec[] => {
|
|
|
83
107
|
return "OK";
|
|
84
108
|
},
|
|
85
109
|
},
|
|
110
|
+
{
|
|
111
|
+
name: "next",
|
|
112
|
+
description:
|
|
113
|
+
"Play the next item, as the Play Next overlay does. Fails when there is none.",
|
|
114
|
+
handler: () => {
|
|
115
|
+
const player = requirePlayer();
|
|
116
|
+
const next = player.getPlayNextEntry();
|
|
117
|
+
|
|
118
|
+
if (!next || !player.playNextHandler) throw new Error("No next item");
|
|
119
|
+
|
|
120
|
+
player.playNextHandler();
|
|
121
|
+
|
|
122
|
+
return { id: next.id, title: next.title };
|
|
123
|
+
},
|
|
124
|
+
},
|
|
86
125
|
{
|
|
87
126
|
name: "seek",
|
|
88
127
|
description:
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
getEmptyModalBlocksStructure,
|
|
3
|
+
parseModalBlocksConfiguration,
|
|
4
|
+
} from "../modalBlocksParser";
|
|
2
5
|
|
|
3
6
|
// Mock the platform selection logic so it's consistent
|
|
4
7
|
jest.mock("../../reactUtils", () => ({
|
|
@@ -151,57 +154,66 @@ describe("parseModalBlocksConfiguration", () => {
|
|
|
151
154
|
);
|
|
152
155
|
});
|
|
153
156
|
|
|
154
|
-
it("should map
|
|
157
|
+
it("should ignore keys that do not map to a known block sub-component", () => {
|
|
155
158
|
const result = parseModalBlocksConfiguration(
|
|
156
159
|
{
|
|
157
160
|
"button.create_new_playlist_asset":
|
|
158
161
|
"https://placehold.co/24x24/FF00FF/FFFFFF/png?text=CN",
|
|
162
|
+
"item.checkbox_asset":
|
|
163
|
+
"https://placehold.co/24x24/FF3B30/FFFFFF/png?text=CB",
|
|
164
|
+
"reorder_playlist_item.reorder_handle_asset":
|
|
165
|
+
"https://placehold.co/24x24/FF3B30/FFFFFF/png?text=RH",
|
|
159
166
|
},
|
|
160
167
|
"playlist-experience"
|
|
161
168
|
);
|
|
162
169
|
|
|
163
|
-
expect(result.button.leadingIcon.default).
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
})
|
|
167
|
-
);
|
|
170
|
+
expect(result.button.leadingIcon.default?.asset).toBeUndefined();
|
|
171
|
+
expect(result.item.checkbox.default).toBeUndefined();
|
|
172
|
+
expect(result.item.actionButtons.default).toBeUndefined();
|
|
168
173
|
});
|
|
169
174
|
|
|
170
|
-
it("
|
|
175
|
+
it("parses the generic button leading icon asset", () => {
|
|
171
176
|
const result = parseModalBlocksConfiguration(
|
|
172
|
-
{
|
|
173
|
-
"item.checkbox_asset":
|
|
174
|
-
"https://placehold.co/24x24/FF3B30/FFFFFF/png?text=CB",
|
|
175
|
-
"item.checked_checkbox_asset":
|
|
176
|
-
"https://placehold.co/24x24/FFD60A/000000/png?text=CK",
|
|
177
|
-
},
|
|
177
|
+
{ "button.leading_icon.asset": "https://example.com/add.png" },
|
|
178
178
|
"playlist-experience"
|
|
179
179
|
);
|
|
180
180
|
|
|
181
|
-
expect(result.
|
|
182
|
-
|
|
183
|
-
asset: "https://placehold.co/24x24/FF3B30/FFFFFF/png?text=CB",
|
|
184
|
-
checkedAsset: "https://placehold.co/24x24/FFD60A/000000/png?text=CK",
|
|
185
|
-
})
|
|
181
|
+
expect(result.button.leadingIcon.default?.asset).toBe(
|
|
182
|
+
"https://example.com/add.png"
|
|
186
183
|
);
|
|
187
184
|
});
|
|
185
|
+
});
|
|
188
186
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
"reorder_playlist_item.remove_from_playlist_asset":
|
|
193
|
-
"https://placehold.co/24x24/00FF00/000000/png?text=RM",
|
|
194
|
-
"reorder_playlist_item.reorder_handle_asset":
|
|
195
|
-
"https://placehold.co/24x24/FF3B30/FFFFFF/png?text=RH",
|
|
196
|
-
},
|
|
197
|
-
"playlist-experience"
|
|
198
|
-
);
|
|
187
|
+
describe("getEmptyModalBlocksStructure", () => {
|
|
188
|
+
it("should return every block with empty containers and no state entries", () => {
|
|
189
|
+
const result = getEmptyModalBlocksStructure();
|
|
199
190
|
|
|
200
|
-
expect(result.
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
191
|
+
expect(result.header.container).toEqual({});
|
|
192
|
+
expect(result.item.background).toEqual({});
|
|
193
|
+
expect(result.button.background).toEqual({});
|
|
194
|
+
expect(result.action.background).toEqual({});
|
|
195
|
+
|
|
196
|
+
expect(result.button.leadingIcon.default).toBeUndefined();
|
|
197
|
+
expect(result.item.checkbox.default).toBeUndefined();
|
|
198
|
+
expect(result.item.actionButtons.default).toBeUndefined();
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
it("should return a fresh object on every call", () => {
|
|
202
|
+
const first = getEmptyModalBlocksStructure();
|
|
203
|
+
const second = getEmptyModalBlocksStructure();
|
|
204
|
+
|
|
205
|
+
expect(first).not.toBe(second);
|
|
206
|
+
expect(first.header).not.toBe(second.header);
|
|
207
|
+
expect(first).toEqual(second);
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
it("should be what the parser returns when config or componentName is missing", () => {
|
|
211
|
+
expect(
|
|
212
|
+
parseModalBlocksConfiguration(undefined as any, "queue_action")
|
|
213
|
+
).toEqual(getEmptyModalBlocksStructure());
|
|
214
|
+
|
|
215
|
+
expect(parseModalBlocksConfiguration({ foo: "bar" }, "")).toEqual(
|
|
216
|
+
getEmptyModalBlocksStructure()
|
|
205
217
|
);
|
|
206
218
|
});
|
|
207
219
|
|
|
@@ -60,10 +60,7 @@ export type ModalBlocksConfig = {
|
|
|
60
60
|
};
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
-
export const
|
|
64
|
-
configuration: Record<string, any>,
|
|
65
|
-
componentName: string
|
|
66
|
-
): ModalBlocksConfig => {
|
|
63
|
+
export const getEmptyModalBlocksStructure = (): ModalBlocksConfig => {
|
|
67
64
|
const result: ModalBlocksConfig = {
|
|
68
65
|
header: {
|
|
69
66
|
container: {},
|
|
@@ -118,6 +115,15 @@ export const parseModalBlocksConfiguration = (
|
|
|
118
115
|
},
|
|
119
116
|
};
|
|
120
117
|
|
|
118
|
+
return result;
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
export const parseModalBlocksConfiguration = (
|
|
122
|
+
configuration: Record<string, any>,
|
|
123
|
+
componentName: string
|
|
124
|
+
): ModalBlocksConfig => {
|
|
125
|
+
const result = getEmptyModalBlocksStructure();
|
|
126
|
+
|
|
121
127
|
if (!configuration || !componentName) {
|
|
122
128
|
return result;
|
|
123
129
|
}
|
|
@@ -242,107 +248,5 @@ export const parseModalBlocksConfiguration = (
|
|
|
242
248
|
|
|
243
249
|
assignLeafAsset(result.item, "item.reorder_handle_asset", "dragAsset");
|
|
244
250
|
|
|
245
|
-
// Playlist-experience Studio keys live in this shared parser because modal
|
|
246
|
-
// blocks are themed by themePluginId. Gate them so other plugins are not
|
|
247
|
-
// affected by playlist-only asset names.
|
|
248
|
-
const isPlaylistExperience =
|
|
249
|
-
normalizedComponentName === "playlist_experience";
|
|
250
|
-
|
|
251
|
-
// Studio uploads Create New icon as button.create_new_playlist_asset (not
|
|
252
|
-
// button.leading_icon.asset). Map it onto leadingIcon so AudioPlayerButton
|
|
253
|
-
// can override the hardcoded action-type asset.
|
|
254
|
-
const createNewPlaylistAsset = isPlaylistExperience
|
|
255
|
-
? configuration["button.create_new_playlist_asset"] ||
|
|
256
|
-
configuration[
|
|
257
|
-
`${normalizedComponentName}_button_create_new_playlist_asset`
|
|
258
|
-
]
|
|
259
|
-
: undefined;
|
|
260
|
-
|
|
261
|
-
if (createNewPlaylistAsset) {
|
|
262
|
-
if (!result.button.leadingIcon.default) {
|
|
263
|
-
result.button.leadingIcon.default = {};
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
result.button.leadingIcon.default.asset = createNewPlaylistAsset;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
// Studio checkbox assets are top-level item.* keys (not a parseBlock
|
|
270
|
-
// sub-component). Map onto item.checkbox so multiSelect can render them.
|
|
271
|
-
const checkboxAsset =
|
|
272
|
-
configuration["item.checkbox_asset"] ||
|
|
273
|
-
configuration[`${normalizedComponentName}_item_checkbox_asset`];
|
|
274
|
-
|
|
275
|
-
const checkedCheckboxAsset =
|
|
276
|
-
configuration["item.checked_checkbox_asset"] ||
|
|
277
|
-
configuration[`${normalizedComponentName}_item_checked_checkbox_asset`];
|
|
278
|
-
|
|
279
|
-
if (checkboxAsset || checkedCheckboxAsset) {
|
|
280
|
-
if (!result.item.checkbox.default) {
|
|
281
|
-
result.item.checkbox.default = {};
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
if (checkboxAsset) {
|
|
285
|
-
result.item.checkbox.default.asset = checkboxAsset;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
if (checkedCheckboxAsset) {
|
|
289
|
-
result.item.checkbox.default.checkedAsset = checkedCheckboxAsset;
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
// Edit Order row icons: prefer reorder_playlist_item.*, then flavor1, then
|
|
294
|
-
// flavor2 playlist_experience_assets_* (playlist-experience theme only).
|
|
295
|
-
const removeAsset = isPlaylistExperience
|
|
296
|
-
? configuration["reorder_playlist_item.remove_from_playlist_asset"] ||
|
|
297
|
-
configuration[
|
|
298
|
-
`${normalizedComponentName}_reorder_playlist_item_remove_from_playlist_asset`
|
|
299
|
-
] ||
|
|
300
|
-
configuration[
|
|
301
|
-
"playlist_experience_assets_flavor1.remove_from_playlist_asset"
|
|
302
|
-
] ||
|
|
303
|
-
configuration[
|
|
304
|
-
`${normalizedComponentName}_assets_flavor1_remove_from_playlist_asset`
|
|
305
|
-
] ||
|
|
306
|
-
configuration[
|
|
307
|
-
"playlist_experience_assets_flavor2.remove_from_playlist_asset"
|
|
308
|
-
] ||
|
|
309
|
-
configuration[
|
|
310
|
-
`${normalizedComponentName}_assets_flavor2_remove_from_playlist_asset`
|
|
311
|
-
]
|
|
312
|
-
: undefined;
|
|
313
|
-
|
|
314
|
-
const dragAsset = isPlaylistExperience
|
|
315
|
-
? configuration["reorder_playlist_item.reorder_handle_asset"] ||
|
|
316
|
-
configuration[
|
|
317
|
-
`${normalizedComponentName}_reorder_playlist_item_reorder_handle_asset`
|
|
318
|
-
] ||
|
|
319
|
-
configuration[
|
|
320
|
-
"playlist_experience_assets_flavor1.reorder_handle_asset"
|
|
321
|
-
] ||
|
|
322
|
-
configuration[
|
|
323
|
-
`${normalizedComponentName}_assets_flavor1_reorder_handle_asset`
|
|
324
|
-
] ||
|
|
325
|
-
configuration[
|
|
326
|
-
"playlist_experience_assets_flavor2.reorder_handle_asset"
|
|
327
|
-
] ||
|
|
328
|
-
configuration[
|
|
329
|
-
`${normalizedComponentName}_assets_flavor2_reorder_handle_asset`
|
|
330
|
-
]
|
|
331
|
-
: undefined;
|
|
332
|
-
|
|
333
|
-
if (removeAsset || dragAsset) {
|
|
334
|
-
if (!result.item.actionButtons.default) {
|
|
335
|
-
result.item.actionButtons.default = {};
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
if (removeAsset) {
|
|
339
|
-
result.item.actionButtons.default.removeAsset = removeAsset;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
if (dragAsset) {
|
|
343
|
-
result.item.actionButtons.default.dragAsset = dragAsset;
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
|
|
347
251
|
return result;
|
|
348
252
|
};
|
|
@@ -60,7 +60,7 @@ describe("buildEntryActions - alias & label resolution", () => {
|
|
|
60
60
|
expect(state.label).toBe("Label Property Action");
|
|
61
61
|
});
|
|
62
62
|
|
|
63
|
-
it("
|
|
63
|
+
it("humanizes an un-overridden alias and falls back to the placeholder asset", () => {
|
|
64
64
|
const entry = {
|
|
65
65
|
id: "entry-3",
|
|
66
66
|
extensions: {
|
|
@@ -71,11 +71,7 @@ describe("buildEntryActions - alias & label resolution", () => {
|
|
|
71
71
|
dismiss_on_action: true,
|
|
72
72
|
},
|
|
73
73
|
{
|
|
74
|
-
button: { alias: "
|
|
75
|
-
actions: [{ type: "test" }],
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
button: { alias: "delete_collection" },
|
|
74
|
+
button: { alias: "custom_unknown_action" },
|
|
79
75
|
actions: [{ type: "test" }],
|
|
80
76
|
},
|
|
81
77
|
],
|
|
@@ -84,42 +80,86 @@ describe("buildEntryActions - alias & label resolution", () => {
|
|
|
84
80
|
|
|
85
81
|
const actions = resolveEntryActions(entry as any);
|
|
86
82
|
|
|
87
|
-
expect(actions).toHaveLength(
|
|
83
|
+
expect(actions).toHaveLength(2);
|
|
88
84
|
|
|
85
|
+
// No built-in alias vocabulary any more: underscores become spaces and
|
|
86
|
+
// only the first letter is capitalized, so "queue" stays lowercase.
|
|
89
87
|
expect(actions[0].action.initialEntryState(entry as any)).toMatchObject({
|
|
90
88
|
state: 0,
|
|
91
|
-
label: "Add all to
|
|
89
|
+
label: "Add all to queue",
|
|
92
90
|
});
|
|
93
91
|
|
|
94
92
|
expect(actions[1].action.initialEntryState(entry as any)).toMatchObject({
|
|
95
93
|
state: 0,
|
|
96
|
-
label: "
|
|
94
|
+
label: "Custom unknown action",
|
|
97
95
|
});
|
|
98
96
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
97
|
+
// The asset has no such fallback: without an override it is the red-box
|
|
98
|
+
// placeholder, so a missing Studio icon is visible rather than absent.
|
|
99
|
+
for (const action of actions) {
|
|
100
|
+
expect(action.action.initialEntryState(entry as any)).toMatchObject({
|
|
101
|
+
asset: expect.stringMatching(/^data:image\/png;base64,/),
|
|
102
|
+
});
|
|
103
|
+
}
|
|
103
104
|
});
|
|
104
105
|
|
|
105
|
-
it("
|
|
106
|
+
it("prefers aliasPresentation overrides over the humanized fallbacks", () => {
|
|
107
|
+
const deps = {
|
|
108
|
+
actionExecutor: { handleActions: jest.fn() } as any,
|
|
109
|
+
actionContext: {},
|
|
110
|
+
aliasPresentation: {
|
|
111
|
+
labels: { add_all_to_queue: "Add all to Queue" },
|
|
112
|
+
assets: { add_all_to_queue: "http://example.com/queue.png" },
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
|
|
106
116
|
const entry = {
|
|
107
117
|
id: "entry-4",
|
|
108
118
|
extensions: {
|
|
109
119
|
entry_action: [
|
|
110
120
|
{
|
|
111
|
-
button: { alias: "
|
|
121
|
+
button: { alias: "add_all_to_queue" },
|
|
122
|
+
actions: [{ type: "test" }],
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
button: { alias: "not_overridden" },
|
|
112
126
|
actions: [{ type: "test" }],
|
|
113
127
|
},
|
|
114
128
|
],
|
|
115
129
|
},
|
|
116
130
|
};
|
|
117
131
|
|
|
118
|
-
const actions =
|
|
132
|
+
const actions = buildEntryActions(entry as any, deps);
|
|
119
133
|
|
|
120
|
-
expect(actions).
|
|
134
|
+
expect(actions[0].action.initialEntryState(entry as any)).toMatchObject({
|
|
135
|
+
label: "Add all to Queue",
|
|
136
|
+
asset: "http://example.com/queue.png",
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
// Overrides are per-alias, so an alias absent from the map still humanizes.
|
|
140
|
+
expect(actions[1].action.initialEntryState(entry as any)).toMatchObject({
|
|
141
|
+
label: "Not overridden",
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it("returns no asset when the button has neither iconURL nor alias", () => {
|
|
146
|
+
const entry = {
|
|
147
|
+
id: "entry-5",
|
|
148
|
+
extensions: {
|
|
149
|
+
entry_action: [
|
|
150
|
+
{
|
|
151
|
+
button: { label: "Plain Label" },
|
|
152
|
+
actions: [{ type: "test" }],
|
|
153
|
+
},
|
|
154
|
+
],
|
|
155
|
+
},
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
const actions = resolveEntryActions(entry as any);
|
|
121
159
|
const state = actions[0].action.initialEntryState(entry as any);
|
|
122
|
-
|
|
160
|
+
|
|
161
|
+
expect(state.label).toBe("Plain Label");
|
|
162
|
+
expect(state.asset).toBeUndefined();
|
|
123
163
|
});
|
|
124
164
|
|
|
125
165
|
it("uses actionExecutor.getActionState for plugin-provided label and asset", () => {
|
|
@@ -1,52 +1,29 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Presentation
|
|
2
|
+
* Presentation fallbacks for backend action aliases.
|
|
3
3
|
*
|
|
4
4
|
* Entries may declare an action by `alias` alone, without a label or an icon.
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* There is no built-in alias vocabulary: a label falls back to a humanized
|
|
6
|
+
* version of the alias itself, and an icon falls back to an inline placeholder
|
|
7
|
+
* that is deliberately conspicuous, so a missing asset reads as unconfigured
|
|
8
|
+
* rather than as a deliberate blank.
|
|
7
9
|
*
|
|
8
|
-
*
|
|
9
|
-
* alias vocabulary
|
|
10
|
-
*
|
|
10
|
+
* Both are last resorts, not a framework guarantee: an app that speaks its own
|
|
11
|
+
* alias vocabulary or needs other languages passes labels and assets through
|
|
12
|
+
* `EntryActionDeps.aliasPresentation`, which is consulted per alias.
|
|
11
13
|
*/
|
|
12
14
|
|
|
13
15
|
import { EntryAction } from "./types";
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
"https://assets-secure.applicaster.com/zapp/assets/app_family/1710/906728572617/playlist_add_24dp_FFFFFF_FILL0_wght400_GRAD0_opsz24.png";
|
|
17
|
-
|
|
18
|
-
const REMOVE_ICON =
|
|
19
|
-
"https://assets-secure.applicaster.com/zapp/assets/app_family/1710/372097240191/remove_24dp_EA3323_FILL0_wght400_GRAD0_opsz24.png";
|
|
20
|
-
|
|
21
|
-
const EDIT_ICON =
|
|
22
|
-
"https://upload.wikimedia.org/wikipedia/commons/b/b6/Edit-icon.png";
|
|
23
|
-
|
|
24
|
-
/** Known backend action alias labels. */
|
|
25
|
-
export const ALIAS_LABELS: Record<string, string> = {
|
|
26
|
-
add_to_playlist: "Add to Playlist",
|
|
27
|
-
add_to_queue: "Add to Queue",
|
|
28
|
-
add_all_to_queue: "Add all to Queue",
|
|
29
|
-
play_all: "Play All",
|
|
30
|
-
remove_item: "Remove item",
|
|
31
|
-
delete_collection: "Delete collection",
|
|
32
|
-
create_collection: "Create collection",
|
|
33
|
-
edit: "Edit",
|
|
34
|
-
edit_name: "Edit Name & Details",
|
|
35
|
-
};
|
|
17
|
+
import { createLogger } from "@applicaster/zapp-react-native-utils/logger";
|
|
36
18
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
remove_item: REMOVE_ICON,
|
|
44
|
-
delete_collection: REMOVE_ICON,
|
|
45
|
-
edit: EDIT_ICON,
|
|
46
|
-
edit_name: EDIT_ICON,
|
|
47
|
-
};
|
|
19
|
+
const logger = createLogger({
|
|
20
|
+
category: "zapp-react-native-utils:aliasPresentation",
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const PLACEHOLDER_RED_BOX =
|
|
24
|
+
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAJ0lEQVR4nO3NMQEAAAjDsIF/z2ACvlRAU5NMHuvPOQAAAAAAAMBdC/07Ai5sNw+CAAAAAElFTkSuQmCC";
|
|
48
25
|
|
|
49
|
-
/** Per-app
|
|
26
|
+
/** Per-app labels and icons, keyed by alias, that outrank the fallbacks. */
|
|
50
27
|
export type AliasPresentation = {
|
|
51
28
|
labels?: Record<string, string>;
|
|
52
29
|
assets?: Record<string, string>;
|
|
@@ -56,7 +33,7 @@ function formatAliasLabel(
|
|
|
56
33
|
alias: string,
|
|
57
34
|
overrides?: AliasPresentation
|
|
58
35
|
): string {
|
|
59
|
-
const label = overrides?.labels?.[alias]
|
|
36
|
+
const label = overrides?.labels?.[alias];
|
|
60
37
|
|
|
61
38
|
if (label) {
|
|
62
39
|
return label;
|
|
@@ -107,7 +84,7 @@ export function resolveButtonLabel(
|
|
|
107
84
|
return "";
|
|
108
85
|
}
|
|
109
86
|
|
|
110
|
-
/** Icon to show for an entry action: explicit iconURL,
|
|
87
|
+
/** Icon to show for an entry action: explicit iconURL, matching alias asset or fallback to red box. */
|
|
111
88
|
export function resolveButtonAsset(
|
|
112
89
|
button: EntryAction["button"],
|
|
113
90
|
overrides?: AliasPresentation
|
|
@@ -120,5 +97,12 @@ export function resolveButtonAsset(
|
|
|
120
97
|
return undefined;
|
|
121
98
|
}
|
|
122
99
|
|
|
123
|
-
|
|
100
|
+
if (!overrides?.assets?.[button.alias]) {
|
|
101
|
+
logger.log_warning(
|
|
102
|
+
`Entry action alias '${button.alias}' was not resolved by any plugin feedDecorator or app override. Falling back to placeholder red box.`,
|
|
103
|
+
{ data: { button } }
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return overrides?.assets?.[button.alias] ?? PLACEHOLDER_RED_BOX;
|
|
124
108
|
}
|
package/entryActions/index.ts
CHANGED
|
@@ -60,4 +60,27 @@ describe("ModalOrchestrator phase 3", () => {
|
|
|
60
60
|
|
|
61
61
|
expect(props.emptyMessage).toBe("Queued items will be added here");
|
|
62
62
|
});
|
|
63
|
+
|
|
64
|
+
it("forwards operationButtons onto the sheet props unchanged", () => {
|
|
65
|
+
const operationButtons = {
|
|
66
|
+
add: {
|
|
67
|
+
title: "Create New Playlist",
|
|
68
|
+
iconURL: "https://example.com/add.png",
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
modalOrchestrator.open({
|
|
73
|
+
header: { title: "Playlists" },
|
|
74
|
+
content: {
|
|
75
|
+
title: "Playlists",
|
|
76
|
+
items: [],
|
|
77
|
+
operationButtons,
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
const props = (modalStore.getState().modalState.screen as any)
|
|
82
|
+
?.modalBottomSheetContentProps;
|
|
83
|
+
|
|
84
|
+
expect(props.operationButtons).toEqual(operationButtons);
|
|
85
|
+
});
|
|
63
86
|
});
|
package/modalState/index.ts
CHANGED
package/modalState/types.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { EntryAction } from "../entryActions/types";
|
|
2
|
+
|
|
1
3
|
export interface Header {
|
|
2
4
|
title: string;
|
|
3
5
|
subtitle?: string;
|
|
@@ -107,6 +109,13 @@ export interface DynamicCollectionOptions {
|
|
|
107
109
|
events?: Record<CollectionScopedOperation | string, Action[]>;
|
|
108
110
|
}
|
|
109
111
|
|
|
112
|
+
/** Presentation of a sheet-synthesized operation control; same fields as an entry action button. */
|
|
113
|
+
export type OperationButton = Pick<EntryAction["button"], "title" | "iconURL">;
|
|
114
|
+
|
|
115
|
+
export type OperationButtons = Partial<
|
|
116
|
+
Record<CollectionScopedOperation | string, OperationButton>
|
|
117
|
+
>;
|
|
118
|
+
|
|
110
119
|
export interface Content {
|
|
111
120
|
title: string;
|
|
112
121
|
stickyTitle?: boolean;
|
|
@@ -120,6 +129,8 @@ export interface Content {
|
|
|
120
129
|
styleOverrides?: Record<string, any>;
|
|
121
130
|
/** Shown under Next Up when the queue sheet has no upcoming items. */
|
|
122
131
|
emptyMessage?: string;
|
|
132
|
+
/** Producer-owned presentation for sheet-synthesized operation controls (e.g. `add`). */
|
|
133
|
+
operationButtons?: OperationButtons;
|
|
123
134
|
context?: Record<string, any>;
|
|
124
135
|
}
|
|
125
136
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-utils",
|
|
3
|
-
"version": "15.1.
|
|
3
|
+
"version": "15.1.22",
|
|
4
4
|
"description": "Applicaster Zapp React Native utilities package",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@applicaster/applicaster-types": "15.1.
|
|
30
|
+
"@applicaster/applicaster-types": "15.1.22",
|
|
31
31
|
"buffer": "^5.2.1",
|
|
32
32
|
"camelize": "^1.0.0",
|
|
33
33
|
"dayjs": "^1.11.10",
|