@applicaster/zapp-react-native-utils 16.0.0-alpha.1334507601 → 16.0.0-alpha.1444784746
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 +88 -0
- package/actionsExecutor/actions/navigateToScreen.ts +39 -47
- package/actionsExecutor/actions/openBottomSheet.ts +14 -5
- package/appUtils/playerManager/OverlayObserver/OverlaysObserver.ts +4 -11
- package/appUtils/playerManager/OverlayObserver/__tests__/getUpcomingQueue.test.ts +67 -0
- package/appUtils/playerManager/OverlayObserver/__tests__/utils.test.ts +9 -2
- package/appUtils/playerManager/OverlayObserver/getUpcomingQueue.ts +15 -2
- package/appUtils/playerManager/OverlayObserver/utils.ts +2 -5
- package/appUtils/playerManager/__tests__/playerNative.test.ts +76 -0
- package/appUtils/playerManager/__tests__/playerNativeCommand.test.ts +62 -0
- package/appUtils/playerManager/__tests__/playerToolbox.test.ts +97 -0
- package/appUtils/playerManager/const.ts +13 -0
- package/appUtils/playerManager/index.ts +2 -0
- package/appUtils/playerManager/player.ts +10 -0
- package/appUtils/playerManager/playerNative.ts +22 -0
- package/appUtils/playerManager/playerNativeCommand.ts +3 -6
- package/appUtils/playerManager/playerToolbox.ts +192 -0
- package/arrayUtils/__tests__/reorderByIds.test.ts +13 -0
- package/arrayUtils/index.ts +26 -43
- package/configurationUtils/__tests__/modalBlocksParser.test.ts +61 -0
- package/configurationUtils/modalBlocksParser.ts +14 -0
- package/modalState/ModalOrchestrator.ts +1 -0
- package/modalState/__tests__/ModalOrchestrator.phase3.test.ts +16 -0
- package/modalState/types.ts +2 -0
- package/package.json +2 -2
- package/pluginUtils/__tests__/pluginUtils.test.js +32 -0
- package/pluginUtils/index.ts +29 -0
- package/reactHooks/connection/index.tsx +8 -5
- package/reactHooks/feed/__tests__/useMarkPipesDataStale.test.tsx +243 -0
- package/reactHooks/feed/useMarkPipesDataStale.ts +68 -23
- package/uiActionsRegistrator/__tests__/subscribe.test.ts +26 -0
- package/uiActionsRegistrator/registry.ts +16 -0
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
import { setUserLanguagePreference } from "./userLanguagePreference";
|
|
12
12
|
import { PlayerRole } from "./const";
|
|
13
13
|
import { RNPlayerManager } from "./nativePlayerManager";
|
|
14
|
+
import { registerPlayerToolbox } from "./playerToolbox";
|
|
14
15
|
|
|
15
16
|
const { log_error, log_debug, log_warning } = createLogger({
|
|
16
17
|
category: "General",
|
|
@@ -54,6 +55,7 @@ export class PlayerManager {
|
|
|
54
55
|
public static getInstance() {
|
|
55
56
|
if (!PlayerManager.instance) {
|
|
56
57
|
PlayerManager.instance = new PlayerManager();
|
|
58
|
+
registerPlayerToolbox(PlayerManager.instance);
|
|
57
59
|
}
|
|
58
60
|
|
|
59
61
|
return PlayerManager.instance;
|
|
@@ -746,6 +746,13 @@ export class Player {
|
|
|
746
746
|
});
|
|
747
747
|
};
|
|
748
748
|
|
|
749
|
+
onRemoteCommand = (event: QuickBrickPlayer.RemoteCommandEvent) => {
|
|
750
|
+
this.invokeListenersUpdate({
|
|
751
|
+
callbackName: SharedPlayerCallBacksKeys.OnRemoteCommand,
|
|
752
|
+
event,
|
|
753
|
+
});
|
|
754
|
+
};
|
|
755
|
+
|
|
749
756
|
getTracksState = (): QuickBrickPlayer.TracksState =>
|
|
750
757
|
this.playerState.trackState;
|
|
751
758
|
|
|
@@ -823,6 +830,8 @@ export class Player {
|
|
|
823
830
|
// PIP
|
|
824
831
|
onPlayerDetached: this.onPlayerDetached,
|
|
825
832
|
onPlayerAttached: this.onPlayerAttached,
|
|
833
|
+
|
|
834
|
+
onRemoteCommand: this.onRemoteCommand,
|
|
826
835
|
});
|
|
827
836
|
|
|
828
837
|
play = () => {};
|
|
@@ -832,6 +841,7 @@ export class Player {
|
|
|
832
841
|
setPlaybackRate = (_rate) => {};
|
|
833
842
|
startSleepTimer = (_timestamp) => {};
|
|
834
843
|
cancelSleepTimer = () => {};
|
|
844
|
+
command = (_command: string, _userInfo?: Record<string, any>) => {};
|
|
835
845
|
|
|
836
846
|
getPluginConfiguration = () => null;
|
|
837
847
|
appStateChange = (_appState, _previousAppState) => {};
|
|
@@ -6,6 +6,7 @@ import { findNodeHandle } from "react-native";
|
|
|
6
6
|
import { PlayerRole } from "./const";
|
|
7
7
|
import { toBooleanWithDefaultFalse } from "../../booleanUtils";
|
|
8
8
|
import { RNPlayerManager } from "./nativePlayerManager";
|
|
9
|
+
import { isApplePlatform } from "../../reactUtils";
|
|
9
10
|
|
|
10
11
|
const logger = createLogger({
|
|
11
12
|
category: "PlayerNativeController",
|
|
@@ -27,6 +28,7 @@ interface PlayerMethods {
|
|
|
27
28
|
appStateChange?: (appState: string, previousAppState: string) => void;
|
|
28
29
|
closeNativePlayer?: () => void;
|
|
29
30
|
togglePlayPause?: () => void;
|
|
31
|
+
command?: (command: string, userInfo?: Record<string, any>) => void;
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
type PlayerComponent = ReactComponent<PlayerRefProps> & PlayerMethods;
|
|
@@ -52,6 +54,7 @@ const PlayerModuleFuncNames = {
|
|
|
52
54
|
startSleepTimer: "startSleepTimer",
|
|
53
55
|
cancelSleepTimer: "cancelSleepTimer",
|
|
54
56
|
getSleepTimerEnd: "getSleepTimerEnd",
|
|
57
|
+
command: "command",
|
|
55
58
|
};
|
|
56
59
|
|
|
57
60
|
export class PlayerNative extends Player {
|
|
@@ -206,6 +209,25 @@ export class PlayerNative extends Player {
|
|
|
206
209
|
}
|
|
207
210
|
};
|
|
208
211
|
|
|
212
|
+
command = (command: string, userInfo?: Record<string, any>) => {
|
|
213
|
+
if (isApplePlatform()) {
|
|
214
|
+
const module = this.getPlayerModule();
|
|
215
|
+
module?.command?.(command, this.playerId, userInfo);
|
|
216
|
+
|
|
217
|
+
return true;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if (
|
|
221
|
+
!this.invokeNativeFunction(
|
|
222
|
+
PlayerModuleFuncNames.command,
|
|
223
|
+
command,
|
|
224
|
+
userInfo
|
|
225
|
+
)
|
|
226
|
+
) {
|
|
227
|
+
this.currentPlayerComponent()?.command?.(command, userInfo);
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
|
|
209
231
|
disableBufferAnimation = (): boolean => false;
|
|
210
232
|
|
|
211
233
|
selectTrack = (
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { isApplePlatform } from "../../reactUtils";
|
|
2
2
|
import { NativeModules } from "react-native";
|
|
3
3
|
|
|
4
|
-
const NativePlayerModule = isApplePlatform()
|
|
5
|
-
? NativeModules.PlayerModule
|
|
6
|
-
: NativeModules.QuickBrickDefaultPlayerModule;
|
|
7
|
-
|
|
8
4
|
const PlayerNativeCommandTypes = {
|
|
9
5
|
pause: "pause",
|
|
10
6
|
clearPlayerData: "clearPlayerData",
|
|
11
7
|
removeViewByNativeId: "removeViewByNativeId",
|
|
8
|
+
setPlayerControls: "setPlayerControls",
|
|
12
9
|
};
|
|
13
10
|
|
|
14
11
|
const PlayerNativeSendCommand = (
|
|
@@ -16,8 +13,8 @@ const PlayerNativeSendCommand = (
|
|
|
16
13
|
playerId: string,
|
|
17
14
|
userInfo?: Record<string, any>
|
|
18
15
|
) => {
|
|
19
|
-
if (playerId && command) {
|
|
20
|
-
|
|
16
|
+
if (isApplePlatform() && playerId && command) {
|
|
17
|
+
NativeModules.PlayerModule?.command?.(command, playerId, userInfo);
|
|
21
18
|
}
|
|
22
19
|
};
|
|
23
20
|
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { getXray } from "../../logger";
|
|
2
|
+
import type { PlayerManager } from "./index";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* X-Ray `player.*` toolbox: lets an agent read and drive the active player without screenshots.
|
|
6
|
+
* Registered by the PlayerManager singleton itself, so it exists wherever players do. Skipped
|
|
7
|
+
* when the installed X-Ray plugin has no React toolbox API.
|
|
8
|
+
*
|
|
9
|
+
* How the player is shown (video modal mode, mini player) is navigation state: see `nav.*`.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
type ToolSpec = {
|
|
13
|
+
name: string;
|
|
14
|
+
description: string;
|
|
15
|
+
parameters?: Array<{
|
|
16
|
+
name: string;
|
|
17
|
+
type: "number";
|
|
18
|
+
description: string;
|
|
19
|
+
}>;
|
|
20
|
+
handler: (args: Record<string, unknown>) => unknown;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
type RegisterReactToolbox = (toolbox: {
|
|
24
|
+
name: string;
|
|
25
|
+
description: string;
|
|
26
|
+
tools: ToolSpec[];
|
|
27
|
+
}) => Promise<void>;
|
|
28
|
+
|
|
29
|
+
let registration: Promise<void> | undefined;
|
|
30
|
+
|
|
31
|
+
const toNumber = (value: unknown) =>
|
|
32
|
+
typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
33
|
+
|
|
34
|
+
const clamp = (value: number, max: number) => Math.min(Math.max(value, 0), max);
|
|
35
|
+
|
|
36
|
+
/** The range a seek can reach: the DVR window on live, the content on VOD. */
|
|
37
|
+
const requireSeekable = (player: {
|
|
38
|
+
getSeekableDuration: () => number | undefined;
|
|
39
|
+
}) => {
|
|
40
|
+
const seekable = toNumber(player.getSeekableDuration());
|
|
41
|
+
|
|
42
|
+
if (!seekable) throw new Error("Seek is not supported");
|
|
43
|
+
|
|
44
|
+
return seekable;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const tools = (manager: PlayerManager): ToolSpec[] => {
|
|
48
|
+
const requirePlayer = () => {
|
|
49
|
+
const player = manager.getActivePlayer();
|
|
50
|
+
|
|
51
|
+
if (!player) throw new Error("No active player");
|
|
52
|
+
|
|
53
|
+
return player;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
return [
|
|
57
|
+
{
|
|
58
|
+
name: "state",
|
|
59
|
+
description:
|
|
60
|
+
"The active player: entry, position and duration in seconds, playing/buffering/ad/live/muted, " +
|
|
61
|
+
"role (Primary, Cell, Chromecast) and casting. active: false when nothing plays.",
|
|
62
|
+
handler: () => {
|
|
63
|
+
const player = manager.getActivePlayer();
|
|
64
|
+
|
|
65
|
+
if (!player) return { active: false, casting: manager.isCasting() };
|
|
66
|
+
|
|
67
|
+
const entry = player.getEntry();
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
active: true,
|
|
71
|
+
playerId: player.playerId,
|
|
72
|
+
entry: entry ? { id: entry.id, title: entry.title } : null,
|
|
73
|
+
position: toNumber(player.getPosition()),
|
|
74
|
+
duration: toNumber(player.getDuration()),
|
|
75
|
+
// isPlaying() only means "not paused", which is also true before the stream starts.
|
|
76
|
+
playing: !!player.isReadyToPlay() && player.isPlaying(),
|
|
77
|
+
buffering: !!player.isBuffering(),
|
|
78
|
+
readyToPlay: !!player.isReadyToPlay(),
|
|
79
|
+
ad: player.isAd(),
|
|
80
|
+
live: !!player.isLive(),
|
|
81
|
+
muted: !!player.getIsMuted(),
|
|
82
|
+
role: player.playerRole,
|
|
83
|
+
casting: manager.isCasting(),
|
|
84
|
+
};
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
name: "play",
|
|
89
|
+
description: "Resume the active player.",
|
|
90
|
+
handler: () => {
|
|
91
|
+
requirePlayer().play();
|
|
92
|
+
|
|
93
|
+
return "OK";
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
name: "pause",
|
|
98
|
+
description: "Pause the active player.",
|
|
99
|
+
handler: () => {
|
|
100
|
+
requirePlayer().pause();
|
|
101
|
+
|
|
102
|
+
return "OK";
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
name: "seek",
|
|
107
|
+
description:
|
|
108
|
+
"Seek to an absolute position, as the player's console command does: seconds from the start, " +
|
|
109
|
+
"or from the end when negative. Clamped to the seekable range. Where it lands can differ: " +
|
|
110
|
+
"server-side ads snap back to the break before the target; read player.state afterwards.",
|
|
111
|
+
parameters: [
|
|
112
|
+
{
|
|
113
|
+
name: "position",
|
|
114
|
+
type: "number",
|
|
115
|
+
description:
|
|
116
|
+
"Seconds from the start; negative values count back from the end.",
|
|
117
|
+
},
|
|
118
|
+
],
|
|
119
|
+
handler: ({ position }) => {
|
|
120
|
+
const player = requirePlayer();
|
|
121
|
+
const seconds = toNumber(position);
|
|
122
|
+
|
|
123
|
+
if (seconds === null) {
|
|
124
|
+
throw new Error("'position' must be a number of seconds");
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const seekable = requireSeekable(player);
|
|
128
|
+
|
|
129
|
+
const target =
|
|
130
|
+
seconds >= 0
|
|
131
|
+
? Math.min(seconds, seekable)
|
|
132
|
+
: clamp(seekable + seconds, seekable);
|
|
133
|
+
|
|
134
|
+
player.seekTo(target);
|
|
135
|
+
|
|
136
|
+
return { position: target };
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
name: "offset",
|
|
141
|
+
description:
|
|
142
|
+
"Seek relative to the current position, as the player's console command does: positive " +
|
|
143
|
+
"forward, negative back. Clamped to the seekable range.",
|
|
144
|
+
parameters: [
|
|
145
|
+
{
|
|
146
|
+
name: "seconds",
|
|
147
|
+
type: "number",
|
|
148
|
+
description: "Seconds to move: positive forward, negative back.",
|
|
149
|
+
},
|
|
150
|
+
],
|
|
151
|
+
handler: ({ seconds }) => {
|
|
152
|
+
const player = requirePlayer();
|
|
153
|
+
const delta = toNumber(seconds);
|
|
154
|
+
|
|
155
|
+
if (delta === null) throw new Error("'seconds' must be a number");
|
|
156
|
+
|
|
157
|
+
if (delta === 0) throw new Error("Ignored zero relative seek");
|
|
158
|
+
|
|
159
|
+
const seekable = requireSeekable(player);
|
|
160
|
+
const from = toNumber(player.getContentPosition()) ?? 0;
|
|
161
|
+
const target = clamp(from + delta, seekable);
|
|
162
|
+
|
|
163
|
+
player.seekTo(target);
|
|
164
|
+
|
|
165
|
+
return { from, position: target };
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
];
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
export const registerPlayerToolbox = (manager: PlayerManager) => {
|
|
172
|
+
if (registration) return registration;
|
|
173
|
+
|
|
174
|
+
const register = (
|
|
175
|
+
getXray() as
|
|
176
|
+
| { registerReactToolbox?: RegisterReactToolbox }
|
|
177
|
+
| null
|
|
178
|
+
| undefined
|
|
179
|
+
)?.registerReactToolbox;
|
|
180
|
+
|
|
181
|
+
if (!register) return Promise.resolve();
|
|
182
|
+
|
|
183
|
+
registration = register({
|
|
184
|
+
name: "player",
|
|
185
|
+
description: "Inspect and control the active player.",
|
|
186
|
+
tools: tools(manager),
|
|
187
|
+
}).catch(() => {
|
|
188
|
+
registration = undefined;
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
return registration;
|
|
192
|
+
};
|
|
@@ -47,4 +47,17 @@ describe("reorderByIds", () => {
|
|
|
47
47
|
|
|
48
48
|
expect(result.map((i) => i.key)).toEqual(["c", "b", "a"]);
|
|
49
49
|
});
|
|
50
|
+
|
|
51
|
+
it("reorders duplicate items when using unique slot identifiers via getId", () => {
|
|
52
|
+
const duplicateItems = [
|
|
53
|
+
{ id: "x", slot: "s1", name: "First X" },
|
|
54
|
+
{ id: "y", slot: "s2", name: "Y" },
|
|
55
|
+
{ id: "x", slot: "s3", name: "Second X" },
|
|
56
|
+
];
|
|
57
|
+
|
|
58
|
+
const result = reorderByIds(duplicateItems, ["s3", "s1"], (i) => i.slot);
|
|
59
|
+
|
|
60
|
+
expect(result).toHaveLength(3);
|
|
61
|
+
expect(result.map((i) => i.name)).toEqual(["Second X", "Y", "First X"]);
|
|
62
|
+
});
|
|
50
63
|
});
|
package/arrayUtils/index.ts
CHANGED
|
@@ -167,7 +167,7 @@ export const anyTruthy = (xs: boolean[]) => xs.some(Boolean);
|
|
|
167
167
|
export function reorderByIds<T>(
|
|
168
168
|
items: T[],
|
|
169
169
|
orderedIds: string[],
|
|
170
|
-
getId: (item: T) => string
|
|
170
|
+
getId: (item: T) => string = (item: any) => item?.id
|
|
171
171
|
): T[] {
|
|
172
172
|
if (!items || items.length === 0) return [];
|
|
173
173
|
if (!orderedIds || orderedIds.length === 0) return [...items];
|
|
@@ -175,14 +175,16 @@ export function reorderByIds<T>(
|
|
|
175
175
|
const itemMap = new Map<string, T>();
|
|
176
176
|
|
|
177
177
|
items.forEach((item) => {
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
178
|
+
const id = getId(item);
|
|
179
|
+
|
|
180
|
+
if (
|
|
181
|
+
id !== undefined &&
|
|
182
|
+
id !== null &&
|
|
183
|
+
id !== "" &&
|
|
184
|
+
!itemMap.has(String(id))
|
|
185
|
+
) {
|
|
186
|
+
itemMap.set(String(id), item);
|
|
187
|
+
}
|
|
186
188
|
});
|
|
187
189
|
|
|
188
190
|
const reorderedSubset: T[] = [];
|
|
@@ -192,48 +194,29 @@ export function reorderByIds<T>(
|
|
|
192
194
|
const strId = String(id);
|
|
193
195
|
const item = itemMap.get(strId);
|
|
194
196
|
|
|
195
|
-
if (item && !
|
|
197
|
+
if (item && !orderedIdsSet.has(strId)) {
|
|
196
198
|
reorderedSubset.push(item);
|
|
197
|
-
|
|
198
|
-
const keys = Array.isArray(rawId) ? rawId : [rawId];
|
|
199
|
-
|
|
200
|
-
keys.forEach((k) => {
|
|
201
|
-
if (k !== undefined && k !== null && k !== "") {
|
|
202
|
-
orderedIdsSet.add(String(k));
|
|
203
|
-
}
|
|
204
|
-
});
|
|
199
|
+
orderedIdsSet.add(strId);
|
|
205
200
|
}
|
|
206
201
|
});
|
|
207
202
|
|
|
208
203
|
if (reorderedSubset.length === 0) return [...items];
|
|
209
204
|
|
|
210
205
|
let subsetIdx = 0;
|
|
211
|
-
const result: T[] = [];
|
|
212
|
-
|
|
213
|
-
items.forEach((item) => {
|
|
214
|
-
const rawId = getId(item);
|
|
215
|
-
const keys = Array.isArray(rawId) ? rawId : [rawId];
|
|
216
|
-
|
|
217
|
-
const isMatched = keys.some(
|
|
218
|
-
(k) =>
|
|
219
|
-
k !== undefined &&
|
|
220
|
-
k !== null &&
|
|
221
|
-
k !== "" &&
|
|
222
|
-
orderedIdsSet.has(String(k))
|
|
223
|
-
);
|
|
224
206
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
207
|
+
return items.map((item) => {
|
|
208
|
+
const id = getId(item);
|
|
209
|
+
|
|
210
|
+
if (
|
|
211
|
+
id !== undefined &&
|
|
212
|
+
id !== null &&
|
|
213
|
+
id !== "" &&
|
|
214
|
+
orderedIdsSet.has(String(id)) &&
|
|
215
|
+
subsetIdx < reorderedSubset.length
|
|
216
|
+
) {
|
|
217
|
+
return reorderedSubset[subsetIdx++];
|
|
231
218
|
}
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
while (subsetIdx < reorderedSubset.length) {
|
|
235
|
-
result.push(reorderedSubset[subsetIdx++]);
|
|
236
|
-
}
|
|
237
219
|
|
|
238
|
-
|
|
220
|
+
return item;
|
|
221
|
+
});
|
|
239
222
|
}
|
|
@@ -205,4 +205,65 @@ describe("getEmptyModalBlocksStructure", () => {
|
|
|
205
205
|
getEmptyModalBlocksStructure()
|
|
206
206
|
);
|
|
207
207
|
});
|
|
208
|
+
|
|
209
|
+
it("should parse section_header title and action_buttons independently of header", () => {
|
|
210
|
+
const result = parseModalBlocksConfiguration(
|
|
211
|
+
{
|
|
212
|
+
"section_header.title.font_color": "#ABCDEF",
|
|
213
|
+
"section_header.title.font_size": 13,
|
|
214
|
+
"section_header.title.ios.font_family": "SFProText-Bold",
|
|
215
|
+
"section_header.action_buttons.default.background_color":
|
|
216
|
+
"rgba(62, 62, 62, 1)",
|
|
217
|
+
"section_header.action_buttons.focus.background_color":
|
|
218
|
+
"rgba(78, 78, 78, 1)",
|
|
219
|
+
"section_header.action_buttons.default.font_color": "#FFFFFF",
|
|
220
|
+
"section_header.action_buttons.font_size": 14,
|
|
221
|
+
"section_header.action_buttons.border_radius": 16,
|
|
222
|
+
// Theme modal header — must not leak into sectionHeader
|
|
223
|
+
queue_action_style_header_title_default_fontColor: "#111111",
|
|
224
|
+
queue_action_style_header_title_default_fontSize: 22,
|
|
225
|
+
},
|
|
226
|
+
"queue_action"
|
|
227
|
+
);
|
|
228
|
+
|
|
229
|
+
expect(result.sectionHeader.title.default).toEqual(
|
|
230
|
+
expect.objectContaining({
|
|
231
|
+
fontColor: "#ABCDEF",
|
|
232
|
+
fontSize: 13,
|
|
233
|
+
fontFamily: "SFProText-Bold",
|
|
234
|
+
})
|
|
235
|
+
);
|
|
236
|
+
|
|
237
|
+
expect(result.sectionHeader.actionButtons.default).toEqual(
|
|
238
|
+
expect.objectContaining({
|
|
239
|
+
backgroundColor: "rgba(62, 62, 62, 1)",
|
|
240
|
+
fontColor: "#FFFFFF",
|
|
241
|
+
fontSize: 14,
|
|
242
|
+
borderRadius: 16,
|
|
243
|
+
})
|
|
244
|
+
);
|
|
245
|
+
|
|
246
|
+
expect(result.sectionHeader.actionButtons.focused).toEqual(
|
|
247
|
+
expect.objectContaining({
|
|
248
|
+
backgroundColor: "rgba(78, 78, 78, 1)",
|
|
249
|
+
})
|
|
250
|
+
);
|
|
251
|
+
|
|
252
|
+
expect(result.header.title.default).toEqual(
|
|
253
|
+
expect.objectContaining({
|
|
254
|
+
fontColor: "#111111",
|
|
255
|
+
fontSize: 22,
|
|
256
|
+
})
|
|
257
|
+
);
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
it("should leave sectionHeader empty when keys are absent", () => {
|
|
261
|
+
const result = parseModalBlocksConfiguration(
|
|
262
|
+
{ "item.text_label1.font_color": "#FFFFFF" },
|
|
263
|
+
"playlist-experience"
|
|
264
|
+
);
|
|
265
|
+
|
|
266
|
+
expect(result.sectionHeader.title).toEqual({ default: {} });
|
|
267
|
+
expect(result.sectionHeader.actionButtons).toEqual({ default: {} });
|
|
268
|
+
});
|
|
208
269
|
});
|
|
@@ -7,6 +7,14 @@ export type ModalBlocksConfig = {
|
|
|
7
7
|
closeButton: Record<string, any>;
|
|
8
8
|
actionButtons: Record<string, any>;
|
|
9
9
|
};
|
|
10
|
+
/**
|
|
11
|
+
* Queue Section Header (BB Variant 3) — shared by Next in Queue / Next Up.
|
|
12
|
+
* Separate from Theme modal `header` so top-title styles do not collide.
|
|
13
|
+
*/
|
|
14
|
+
sectionHeader: {
|
|
15
|
+
title: Record<string, any>;
|
|
16
|
+
actionButtons: Record<string, any>;
|
|
17
|
+
};
|
|
10
18
|
action: {
|
|
11
19
|
background: Record<string, any>;
|
|
12
20
|
title: Record<string, any>;
|
|
@@ -60,6 +68,10 @@ export const getEmptyModalBlocksStructure = (): ModalBlocksConfig => {
|
|
|
60
68
|
closeButton: {},
|
|
61
69
|
actionButtons: {},
|
|
62
70
|
},
|
|
71
|
+
sectionHeader: {
|
|
72
|
+
title: {},
|
|
73
|
+
actionButtons: {},
|
|
74
|
+
},
|
|
63
75
|
action: {
|
|
64
76
|
background: {},
|
|
65
77
|
title: {},
|
|
@@ -154,6 +166,8 @@ export const parseModalBlocksConfiguration = (
|
|
|
154
166
|
"action_buttons",
|
|
155
167
|
]);
|
|
156
168
|
|
|
169
|
+
parseBlock("section_header", ["title", "action_buttons"]);
|
|
170
|
+
|
|
157
171
|
parseBlock("action", [
|
|
158
172
|
"background",
|
|
159
173
|
"title",
|
|
@@ -44,4 +44,20 @@ describe("ModalOrchestrator phase 3", () => {
|
|
|
44
44
|
expect(props.title).toBe("Sleep Timer");
|
|
45
45
|
expect(props.summary).toBe("remaining");
|
|
46
46
|
});
|
|
47
|
+
|
|
48
|
+
it("forwards the queue empty message onto the sheet props", () => {
|
|
49
|
+
modalOrchestrator.open({
|
|
50
|
+
header: { title: "Queue" },
|
|
51
|
+
content: {
|
|
52
|
+
title: "Queue",
|
|
53
|
+
items: [],
|
|
54
|
+
emptyMessage: "Queued items will be added here",
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const props = (modalStore.getState().modalState.screen as any)
|
|
59
|
+
?.modalBottomSheetContentProps;
|
|
60
|
+
|
|
61
|
+
expect(props.emptyMessage).toBe("Queued items will be added here");
|
|
62
|
+
});
|
|
47
63
|
});
|
package/modalState/types.ts
CHANGED
|
@@ -118,6 +118,8 @@ export interface Content {
|
|
|
118
118
|
dynamicCollection?: DynamicCollectionOptions;
|
|
119
119
|
themePluginId?: string;
|
|
120
120
|
styleOverrides?: Record<string, any>;
|
|
121
|
+
/** Shown under Next Up when the queue sheet has no upcoming items. */
|
|
122
|
+
emptyMessage?: string;
|
|
121
123
|
context?: Record<string, any>;
|
|
122
124
|
}
|
|
123
125
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-utils",
|
|
3
|
-
"version": "16.0.0-alpha.
|
|
3
|
+
"version": "16.0.0-alpha.1444784746",
|
|
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": "16.0.0-alpha.
|
|
30
|
+
"@applicaster/applicaster-types": "16.0.0-alpha.1444784746",
|
|
31
31
|
"buffer": "^5.2.1",
|
|
32
32
|
"camelize": "^1.0.0",
|
|
33
33
|
"dayjs": "^1.11.10",
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
const mockAppStoreGet = jest.fn();
|
|
2
|
+
|
|
3
|
+
jest.mock("@applicaster/zapp-react-native-redux/AppStore", () => ({
|
|
4
|
+
appStore: { get: (key) => mockAppStoreGet(key) },
|
|
5
|
+
}));
|
|
6
|
+
|
|
1
7
|
import * as R from "ramda";
|
|
2
8
|
import * as pluginUtils from "../index";
|
|
3
9
|
|
|
@@ -148,6 +154,32 @@ describe("findPluginByIdentifier", () => {
|
|
|
148
154
|
});
|
|
149
155
|
});
|
|
150
156
|
|
|
157
|
+
describe("getPluginByIdentifier", () => {
|
|
158
|
+
const { getPluginByIdentifier } = pluginUtils;
|
|
159
|
+
|
|
160
|
+
const plugins = {
|
|
161
|
+
foo: pluginMock("foo", "foo", "some_plugin_type"),
|
|
162
|
+
bar: pluginMock("foo", "bar", "some_plugin_type"),
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
beforeEach(() => {
|
|
166
|
+
mockAppStoreGet.mockReset();
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
it("reads plugins from appStore and returns the matching plugin", () => {
|
|
170
|
+
mockAppStoreGet.mockReturnValue(plugins);
|
|
171
|
+
|
|
172
|
+
expect(getPluginByIdentifier("foo")).toEqual(plugins.foo);
|
|
173
|
+
expect(mockAppStoreGet).toHaveBeenCalledWith("plugins");
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
it("returns undefined when the plugin is not found", () => {
|
|
177
|
+
mockAppStoreGet.mockReturnValue(plugins);
|
|
178
|
+
|
|
179
|
+
expect(getPluginByIdentifier("do_not_exist")).toBeUndefined();
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
|
|
151
183
|
describe("findPluginByType", () => {
|
|
152
184
|
const { findPluginByType } = pluginUtils;
|
|
153
185
|
|
package/pluginUtils/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as R from "ramda";
|
|
2
|
+
import { appStore } from "@applicaster/zapp-react-native-redux/AppStore";
|
|
2
3
|
import { toCamelCase, toPascalCase } from "../stringUtils";
|
|
3
4
|
|
|
4
5
|
import { getNavigationType } from "../navigationUtils";
|
|
@@ -97,6 +98,34 @@ export function findPluginByIdentifier(
|
|
|
97
98
|
return plugin;
|
|
98
99
|
}
|
|
99
100
|
|
|
101
|
+
/**
|
|
102
|
+
* Like findPluginByIdentifier, but reads the current plugins list from appStore.
|
|
103
|
+
* Convenience for non-render / hook code that doesn't already have `plugins` in hand.
|
|
104
|
+
* @param identifier of the plugin to look for
|
|
105
|
+
* @param doNotWarn if set to true, will not log a warning if plugin is not found
|
|
106
|
+
* @return whole plugin if found, undefined otherwise
|
|
107
|
+
*/
|
|
108
|
+
export function getPluginByIdentifier(
|
|
109
|
+
identifier: string,
|
|
110
|
+
doNotWarn: boolean = false
|
|
111
|
+
): (QuickBrickPlugin | ZappPlugin | Plugin) | undefined {
|
|
112
|
+
try {
|
|
113
|
+
const plugins = appStore.get("plugins") ?? {};
|
|
114
|
+
|
|
115
|
+
return findPluginByIdentifier(identifier, plugins, doNotWarn);
|
|
116
|
+
} catch (error) {
|
|
117
|
+
if (!doNotWarn) {
|
|
118
|
+
pluginUtilsLogger.warning({
|
|
119
|
+
message:
|
|
120
|
+
"Could not read plugins from appStore while resolving plugin by identifier",
|
|
121
|
+
data: { identifier, error },
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return undefined;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
100
129
|
const pluginTypeForItemTypeMap = {
|
|
101
130
|
playable: "player",
|
|
102
131
|
};
|