@applicaster/zapp-react-native-utils 16.0.0-alpha.3081324238 → 16.0.0-alpha.3202041045
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/actionUtils/index.ts +3 -1
- package/actionsExecutor/actions/__tests__/navigateToScreen.test.ts +139 -5
- package/actionsExecutor/actions/__tests__/openBottomSheet.customContent.test.ts +24 -0
- package/actionsExecutor/actions/navigateToScreen.ts +29 -45
- package/actionsExecutor/actions/openBottomSheet.ts +1 -0
- package/appUtils/playerManager/__tests__/playerDiagnostics.test.ts +62 -0
- package/appUtils/playerManager/__tests__/playerToolbox.test.ts +188 -4
- package/appUtils/playerManager/index.ts +5 -0
- package/appUtils/playerManager/player.ts +15 -0
- package/appUtils/playerManager/playerToolbox.ts +45 -41
- package/cellUtils/__tests__/getButtonsEnabled.test.ts +28 -0
- package/cellUtils/__tests__/getCellNavigationEnabled.test.ts +36 -0
- package/cellUtils/__tests__/getIsCellNavigationEnabled.test.ts +35 -0
- package/cellUtils/__tests__/isCellNavigationEnabled.test.ts +21 -0
- package/cellUtils/index.ts +40 -0
- package/configurationUtils/__tests__/modalBlocksParser.test.ts +60 -0
- package/focusManager/FocusManager.ts +26 -0
- package/focusManager/__tests__/FocusManager.test.ts +9 -0
- package/localizationUtils/index.ts +12 -6
- package/logger/__tests__/xrayToolbox.test.ts +69 -0
- package/logger/xrayToolbox.ts +67 -0
- package/manifestUtils/defaultManifestConfigurations/player.js +8 -0
- package/manifestUtils/keys.js +7 -1
- package/manifestUtils/mobileAction/container/__tests__/mobileActionButtonsContainer.test.js +21 -0
- package/manifestUtils/mobileAction/groups/defaults.js +1 -0
- package/navigationUtils/xrayNavigator.ts +12 -0
- package/package.json +3 -2
- package/quickBrickAssets/__tests__/index.test.ts +18 -0
- package/quickBrickAssets/index.ts +35 -0
- package/reactHooks/__tests__/getPluginConfiguration.test.ts +82 -0
- package/reactHooks/actions/index.ts +29 -23
- package/reactHooks/usePluginConfiguration.ts +84 -46
- package/riverComponetsMeasurementProvider/index.tsx +3 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { registerXrayToolbox, XrayToolSpec } from "../../logger/xrayToolbox";
|
|
2
2
|
import type { PlayerManager } from "./index";
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -9,30 +9,17 @@ import type { PlayerManager } from "./index";
|
|
|
9
9
|
* How the player is shown (video modal mode, mini player) is navigation state: see `nav.*`.
|
|
10
10
|
*/
|
|
11
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
12
|
const toNumber = (value: unknown) =>
|
|
32
13
|
typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
33
14
|
|
|
34
15
|
const clamp = (value: number, max: number) => Math.min(Math.max(value, 0), max);
|
|
35
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
|
+
|
|
36
23
|
/** The range a seek can reach: the DVR window on live, the content on VOD. */
|
|
37
24
|
const requireSeekable = (player: {
|
|
38
25
|
getSeekableDuration: () => number | undefined;
|
|
@@ -44,7 +31,7 @@ const requireSeekable = (player: {
|
|
|
44
31
|
return seekable;
|
|
45
32
|
};
|
|
46
33
|
|
|
47
|
-
const tools = (manager: PlayerManager):
|
|
34
|
+
const tools = (manager: PlayerManager): XrayToolSpec[] => {
|
|
48
35
|
const requirePlayer = () => {
|
|
49
36
|
const player = manager.getActivePlayer();
|
|
50
37
|
|
|
@@ -57,14 +44,21 @@ const tools = (manager: PlayerManager): ToolSpec[] => {
|
|
|
57
44
|
{
|
|
58
45
|
name: "state",
|
|
59
46
|
description:
|
|
60
|
-
"The active player: entry, position and duration in seconds
|
|
61
|
-
"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.",
|
|
62
53
|
handler: () => {
|
|
63
54
|
const player = manager.getActivePlayer();
|
|
64
55
|
|
|
65
56
|
if (!player) return { active: false, casting: manager.isCasting() };
|
|
66
57
|
|
|
67
58
|
const entry = player.getEntry();
|
|
59
|
+
const seekableDuration = toNumber(player.getSeekableDuration());
|
|
60
|
+
const next = player.getPlayNextEntry();
|
|
61
|
+
const error: any = player.lastError;
|
|
68
62
|
|
|
69
63
|
return {
|
|
70
64
|
active: true,
|
|
@@ -80,7 +74,18 @@ const tools = (manager: PlayerManager): ToolSpec[] => {
|
|
|
80
74
|
live: !!player.isLive(),
|
|
81
75
|
muted: !!player.getIsMuted(),
|
|
82
76
|
role: player.playerRole,
|
|
77
|
+
plugin: player.playerPluginId ?? null,
|
|
78
|
+
engine: player.engine ?? null,
|
|
83
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,
|
|
84
89
|
};
|
|
85
90
|
},
|
|
86
91
|
},
|
|
@@ -102,6 +107,21 @@ const tools = (manager: PlayerManager): ToolSpec[] => {
|
|
|
102
107
|
return "OK";
|
|
103
108
|
},
|
|
104
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
|
+
},
|
|
105
125
|
{
|
|
106
126
|
name: "seek",
|
|
107
127
|
description:
|
|
@@ -168,25 +188,9 @@ const tools = (manager: PlayerManager): ToolSpec[] => {
|
|
|
168
188
|
];
|
|
169
189
|
};
|
|
170
190
|
|
|
171
|
-
export const registerPlayerToolbox = (manager: PlayerManager) =>
|
|
172
|
-
|
|
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({
|
|
191
|
+
export const registerPlayerToolbox = (manager: PlayerManager) =>
|
|
192
|
+
registerXrayToolbox({
|
|
184
193
|
name: "player",
|
|
185
194
|
description: "Inspect and control the active player.",
|
|
186
195
|
tools: tools(manager),
|
|
187
|
-
}).catch(() => {
|
|
188
|
-
registration = undefined;
|
|
189
196
|
});
|
|
190
|
-
|
|
191
|
-
return registration;
|
|
192
|
-
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { getButtonsEnabled } from "..";
|
|
2
|
+
|
|
3
|
+
describe("getButtonsEnabled", () => {
|
|
4
|
+
it("returns true when the buttons container is enabled", () => {
|
|
5
|
+
expect(
|
|
6
|
+
getButtonsEnabled({ mobile_buttons_container_buttons_enabled: true })
|
|
7
|
+
).toBe(true);
|
|
8
|
+
|
|
9
|
+
expect(
|
|
10
|
+
getButtonsEnabled({ mobile_buttons_container_buttons_enabled: "true" })
|
|
11
|
+
).toBe(true);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it("returns false when the buttons container is disabled", () => {
|
|
15
|
+
expect(
|
|
16
|
+
getButtonsEnabled({ mobile_buttons_container_buttons_enabled: false })
|
|
17
|
+
).toBe(false);
|
|
18
|
+
|
|
19
|
+
expect(
|
|
20
|
+
getButtonsEnabled({ mobile_buttons_container_buttons_enabled: "false" })
|
|
21
|
+
).toBe(false);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("returns false when the key or styles are missing", () => {
|
|
25
|
+
expect(getButtonsEnabled({})).toBe(false);
|
|
26
|
+
expect(getButtonsEnabled(undefined)).toBe(false);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { getCellNavigationEnabled } from "..";
|
|
2
|
+
|
|
3
|
+
describe("getCellNavigationEnabled", () => {
|
|
4
|
+
it("returns true when cell navigation is enabled", () => {
|
|
5
|
+
expect(
|
|
6
|
+
getCellNavigationEnabled({
|
|
7
|
+
mobile_buttons_container_cell_navigation_enabled: true,
|
|
8
|
+
})
|
|
9
|
+
).toBe(true);
|
|
10
|
+
|
|
11
|
+
expect(
|
|
12
|
+
getCellNavigationEnabled({
|
|
13
|
+
mobile_buttons_container_cell_navigation_enabled: "true",
|
|
14
|
+
})
|
|
15
|
+
).toBe(true);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("returns false when cell navigation is disabled", () => {
|
|
19
|
+
expect(
|
|
20
|
+
getCellNavigationEnabled({
|
|
21
|
+
mobile_buttons_container_cell_navigation_enabled: false,
|
|
22
|
+
})
|
|
23
|
+
).toBe(false);
|
|
24
|
+
|
|
25
|
+
expect(
|
|
26
|
+
getCellNavigationEnabled({
|
|
27
|
+
mobile_buttons_container_cell_navigation_enabled: "false",
|
|
28
|
+
})
|
|
29
|
+
).toBe(false);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("returns false when the key or styles are missing", () => {
|
|
33
|
+
expect(getCellNavigationEnabled({})).toBe(false);
|
|
34
|
+
expect(getCellNavigationEnabled(undefined)).toBe(false);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { getIsCellNavigationEnabled } from "..";
|
|
2
|
+
|
|
3
|
+
describe("getIsCellNavigationEnabled", () => {
|
|
4
|
+
it("is disabled when buttons are enabled and cell navigation is off", () => {
|
|
5
|
+
expect(
|
|
6
|
+
getIsCellNavigationEnabled({
|
|
7
|
+
mobile_buttons_container_buttons_enabled: true,
|
|
8
|
+
mobile_buttons_container_cell_navigation_enabled: false,
|
|
9
|
+
})
|
|
10
|
+
).toBe(false);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it("is enabled when buttons and cell navigation are both on", () => {
|
|
14
|
+
expect(
|
|
15
|
+
getIsCellNavigationEnabled({
|
|
16
|
+
mobile_buttons_container_buttons_enabled: true,
|
|
17
|
+
mobile_buttons_container_cell_navigation_enabled: true,
|
|
18
|
+
})
|
|
19
|
+
).toBe(true);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("is enabled when buttons are disabled", () => {
|
|
23
|
+
expect(
|
|
24
|
+
getIsCellNavigationEnabled({
|
|
25
|
+
mobile_buttons_container_buttons_enabled: false,
|
|
26
|
+
mobile_buttons_container_cell_navigation_enabled: false,
|
|
27
|
+
})
|
|
28
|
+
).toBe(true);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("is enabled when the keys or styles are missing", () => {
|
|
32
|
+
expect(getIsCellNavigationEnabled({})).toBe(true);
|
|
33
|
+
expect(getIsCellNavigationEnabled(undefined)).toBe(true);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { isCellNavigationEnabled } from "..";
|
|
2
|
+
|
|
3
|
+
describe("isCellNavigationEnabled", () => {
|
|
4
|
+
it("is enabled when buttons are disabled, regardless of the toggle", () => {
|
|
5
|
+
expect(isCellNavigationEnabled(false, false)).toBe(true);
|
|
6
|
+
expect(isCellNavigationEnabled(false, true)).toBe(true);
|
|
7
|
+
expect(isCellNavigationEnabled(undefined, undefined)).toBe(true);
|
|
8
|
+
expect(isCellNavigationEnabled("false", false)).toBe(true);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it("is disabled when buttons are enabled and the toggle is off or missing", () => {
|
|
12
|
+
expect(isCellNavigationEnabled(true, false)).toBe(false);
|
|
13
|
+
expect(isCellNavigationEnabled(true, undefined)).toBe(false);
|
|
14
|
+
expect(isCellNavigationEnabled("true", "false")).toBe(false);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("is enabled when buttons and the toggle are both enabled", () => {
|
|
18
|
+
expect(isCellNavigationEnabled(true, true)).toBe(true);
|
|
19
|
+
expect(isCellNavigationEnabled("true", "true")).toBe(true);
|
|
20
|
+
});
|
|
21
|
+
});
|
package/cellUtils/index.ts
CHANGED
|
@@ -12,6 +12,7 @@ import { isWeb } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
|
12
12
|
import { isNotNil } from "@applicaster/zapp-react-native-utils/reactUtils/helpers";
|
|
13
13
|
|
|
14
14
|
import { toNumberWithDefault, toNumberWithDefaultZero } from "../numberUtils";
|
|
15
|
+
import { isTrue } from "../booleanUtils";
|
|
15
16
|
|
|
16
17
|
const CUSTOM_KEY = "other";
|
|
17
18
|
|
|
@@ -572,3 +573,42 @@ export const hasTextLabelsEnabled = (
|
|
|
572
573
|
return Boolean(value);
|
|
573
574
|
});
|
|
574
575
|
};
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
* Reads the mobile buttons container "buttons enabled" switch from cell styles.
|
|
579
|
+
*/
|
|
580
|
+
export const getButtonsEnabled = (styles?: Record<string, any>): boolean => {
|
|
581
|
+
return isTrue(styles?.mobile_buttons_container_buttons_enabled);
|
|
582
|
+
};
|
|
583
|
+
|
|
584
|
+
/**
|
|
585
|
+
* Reads the mobile buttons container "cell navigation enabled" switch from cell styles.
|
|
586
|
+
*/
|
|
587
|
+
export const getCellNavigationEnabled = (
|
|
588
|
+
styles?: Record<string, any>
|
|
589
|
+
): boolean => {
|
|
590
|
+
return isTrue(styles?.mobile_buttons_container_cell_navigation_enabled);
|
|
591
|
+
};
|
|
592
|
+
|
|
593
|
+
/**
|
|
594
|
+
* Whether tapping a cell outside its action buttons triggers the cell's navigation.
|
|
595
|
+
* Always true when the buttons are disabled.
|
|
596
|
+
* @param buttonsEnabled the cell's "buttons enabled" switch value
|
|
597
|
+
* @param cellNavigationEnabled the cell's "cell navigation enabled" switch value
|
|
598
|
+
*/
|
|
599
|
+
export const isCellNavigationEnabled = (
|
|
600
|
+
buttonsEnabled: unknown,
|
|
601
|
+
cellNavigationEnabled: unknown
|
|
602
|
+
): boolean => !isTrue(buttonsEnabled) || isTrue(cellNavigationEnabled);
|
|
603
|
+
|
|
604
|
+
/**
|
|
605
|
+
* Whether tapping a mobile cell outside its action buttons triggers the cell's navigation,
|
|
606
|
+
* read from the cell styles.
|
|
607
|
+
*/
|
|
608
|
+
export const getIsCellNavigationEnabled = (
|
|
609
|
+
styles?: Record<string, any>
|
|
610
|
+
): boolean =>
|
|
611
|
+
isCellNavigationEnabled(
|
|
612
|
+
getButtonsEnabled(styles),
|
|
613
|
+
getCellNavigationEnabled(styles)
|
|
614
|
+
);
|
|
@@ -329,4 +329,64 @@ describe("getEmptyModalBlocksStructure", () => {
|
|
|
329
329
|
expect(result.sectionHeader.title).toEqual({ default: {} });
|
|
330
330
|
expect(result.sectionHeader.actionButtons).toEqual({ default: {} });
|
|
331
331
|
});
|
|
332
|
+
|
|
333
|
+
it("maps playlist button font family and the new green style keys", () => {
|
|
334
|
+
const result = parseModalBlocksConfiguration(
|
|
335
|
+
{
|
|
336
|
+
"button.title.ios.font_family": "GreycliffCF-Bold",
|
|
337
|
+
"button.title.inactive_font_color": "#111111",
|
|
338
|
+
"button.title.focused_font_color": "#222222",
|
|
339
|
+
"button.title.text_transform": "uppercase",
|
|
340
|
+
"button.background.inactive_color": "#999999",
|
|
341
|
+
"button.background.horizontal_gutter": 6,
|
|
342
|
+
"button.icons.width": 24,
|
|
343
|
+
"button.icons.height": 24,
|
|
344
|
+
},
|
|
345
|
+
"playlist-experience"
|
|
346
|
+
);
|
|
347
|
+
|
|
348
|
+
expect(result.button.title.default).toEqual(
|
|
349
|
+
expect.objectContaining({
|
|
350
|
+
fontFamily: "GreycliffCF-Bold",
|
|
351
|
+
inactiveFontColor: "#111111",
|
|
352
|
+
textTransform: "uppercase",
|
|
353
|
+
})
|
|
354
|
+
);
|
|
355
|
+
|
|
356
|
+
// "focused_" is a state prefix, so this key lands on the focused bucket.
|
|
357
|
+
expect(result.button.title.focused).toEqual(
|
|
358
|
+
expect.objectContaining({
|
|
359
|
+
fontColor: "#222222",
|
|
360
|
+
})
|
|
361
|
+
);
|
|
362
|
+
|
|
363
|
+
expect(result.button.background.default).toEqual(
|
|
364
|
+
expect.objectContaining({
|
|
365
|
+
inactiveColor: "#999999",
|
|
366
|
+
horizontalGutter: 6,
|
|
367
|
+
})
|
|
368
|
+
);
|
|
369
|
+
|
|
370
|
+
expect(result.button.icons.default).toEqual(
|
|
371
|
+
expect.objectContaining({
|
|
372
|
+
width: 24,
|
|
373
|
+
height: 24,
|
|
374
|
+
})
|
|
375
|
+
);
|
|
376
|
+
});
|
|
377
|
+
|
|
378
|
+
it("keeps a font-selector object on the button title", () => {
|
|
379
|
+
const result = parseModalBlocksConfiguration(
|
|
380
|
+
{
|
|
381
|
+
"button.title.ios.font_family": { fontFamily: "GreycliffCF-Bold" },
|
|
382
|
+
},
|
|
383
|
+
"playlist-experience"
|
|
384
|
+
);
|
|
385
|
+
|
|
386
|
+
expect(result.button.title.default).toEqual(
|
|
387
|
+
expect.objectContaining({
|
|
388
|
+
fontFamily: { fontFamily: "GreycliffCF-Bold" },
|
|
389
|
+
})
|
|
390
|
+
);
|
|
391
|
+
});
|
|
332
392
|
});
|
|
@@ -224,12 +224,38 @@ class FocusManager {
|
|
|
224
224
|
|
|
225
225
|
unregisterFocusable(focusableId: string) {
|
|
226
226
|
const node = this.tree.find(focusableId);
|
|
227
|
+
const parentNode = this.tree.findParent(focusableId);
|
|
227
228
|
|
|
228
229
|
this.focusableComponents = this.focusableComponents.filter(
|
|
229
230
|
(c) => c !== node?.component
|
|
230
231
|
);
|
|
231
232
|
|
|
232
233
|
this.tree.remove(focusableId);
|
|
234
|
+
|
|
235
|
+
if (this._focusedId === focusableId) {
|
|
236
|
+
this._focusedId = null;
|
|
237
|
+
this.retainFocus(parentNode);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// Empty groups drop their focusable list after the feed fails, which is
|
|
242
|
+
// after Layout's one-shot focus pass. Land on the nearest ancestor that is
|
|
243
|
+
// still mounted so key handlers keep a target.
|
|
244
|
+
private retainFocus(node: TreeNode | null) {
|
|
245
|
+
let current = node;
|
|
246
|
+
|
|
247
|
+
while (current) {
|
|
248
|
+
const ref = current.component;
|
|
249
|
+
|
|
250
|
+
if (ref?.current?.props?.id) {
|
|
251
|
+
this.setFocusLocal(ref);
|
|
252
|
+
ref.current.onFocus?.(ref.current, {}, undefined);
|
|
253
|
+
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
current = current.parentId ? this.tree.find(current.parentId) : null;
|
|
258
|
+
}
|
|
233
259
|
}
|
|
234
260
|
|
|
235
261
|
private setNextFocus(
|
|
@@ -231,6 +231,15 @@ describe("FocusManager", () => {
|
|
|
231
231
|
).toBeFalsy();
|
|
232
232
|
});
|
|
233
233
|
|
|
234
|
+
it("moves focus to the mounted parent when the focused element unregisters", () => {
|
|
235
|
+
focusManager.setFocus("child1");
|
|
236
|
+
|
|
237
|
+
focusManager.unregisterFocusable("child1");
|
|
238
|
+
|
|
239
|
+
expect(focusManager.focusedId).toBe("group");
|
|
240
|
+
expect(focusManager.focused).toBe(group.current);
|
|
241
|
+
});
|
|
242
|
+
|
|
234
243
|
it("focusManager registerFocusable should be defined", () => {
|
|
235
244
|
expect(focusManager.registerFocusable).toBeDefined();
|
|
236
245
|
});
|
|
@@ -28,17 +28,23 @@ const RTL_LOCALES = [
|
|
|
28
28
|
"yi", // Yiddish
|
|
29
29
|
];
|
|
30
30
|
|
|
31
|
+
// The strings for the UI language, else the first language present
|
|
32
|
+
export const getLocalizedStrings = (
|
|
33
|
+
localizations = {},
|
|
34
|
+
languageCode = getUILanguage()
|
|
35
|
+
) =>
|
|
36
|
+
localizations?.[languageCode] ||
|
|
37
|
+
Object.values(localizations).find(
|
|
38
|
+
(value) => typeof value === "object" && value !== null
|
|
39
|
+
) ||
|
|
40
|
+
{};
|
|
41
|
+
|
|
31
42
|
export function useLocalizedStrings({ localizations = {} }) {
|
|
32
43
|
const languageCode = getUILanguage();
|
|
33
44
|
|
|
34
45
|
// TODO: probably we can call getLocalizations here from localizationsHelper.js
|
|
35
46
|
const result = useMemo(
|
|
36
|
-
() =>
|
|
37
|
-
localizations?.[languageCode] ||
|
|
38
|
-
Object.values(localizations).find(
|
|
39
|
-
(value) => typeof value === "object" && value !== null
|
|
40
|
-
) ||
|
|
41
|
-
{},
|
|
47
|
+
() => getLocalizedStrings(localizations, languageCode),
|
|
42
48
|
[languageCode, localizations]
|
|
43
49
|
);
|
|
44
50
|
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
const xray = require("@applicaster/quick-brick-xray");
|
|
2
|
+
|
|
3
|
+
const toolbox = { name: "test", description: "", tools: [] };
|
|
4
|
+
|
|
5
|
+
const load = (): typeof import("../xrayToolbox") => {
|
|
6
|
+
let module;
|
|
7
|
+
|
|
8
|
+
jest.isolateModules(() => {
|
|
9
|
+
module = require("../xrayToolbox");
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
return module;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
describe("registerXrayToolbox", () => {
|
|
16
|
+
afterEach(() => {
|
|
17
|
+
delete xray.registerReactToolbox;
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("registers once per name", async () => {
|
|
21
|
+
xray.registerReactToolbox = jest.fn().mockResolvedValue(undefined);
|
|
22
|
+
const { registerXrayToolbox } = load();
|
|
23
|
+
|
|
24
|
+
await expect(registerXrayToolbox(toolbox)).resolves.toBe(true);
|
|
25
|
+
await expect(registerXrayToolbox(toolbox)).resolves.toBe(true);
|
|
26
|
+
|
|
27
|
+
expect(xray.registerReactToolbox).toHaveBeenCalledTimes(1);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("resolves false without a toolbox API", async () => {
|
|
31
|
+
await expect(load().registerXrayToolbox(toolbox)).resolves.toBe(false);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("keeps a failed registration instead of retrying it", async () => {
|
|
35
|
+
xray.registerReactToolbox = jest
|
|
36
|
+
.fn()
|
|
37
|
+
.mockRejectedValue(new Error("XRayToolboxBridge is not available"));
|
|
38
|
+
|
|
39
|
+
const { registerXrayToolbox } = load();
|
|
40
|
+
|
|
41
|
+
await expect(registerXrayToolbox(toolbox)).resolves.toBe(false);
|
|
42
|
+
await expect(registerXrayToolbox(toolbox)).resolves.toBe(false);
|
|
43
|
+
|
|
44
|
+
expect(xray.registerReactToolbox).toHaveBeenCalledTimes(1);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("registers new tools under the same name again (Fast Refresh)", async () => {
|
|
48
|
+
xray.registerReactToolbox = jest.fn().mockResolvedValue(undefined);
|
|
49
|
+
const { registerXrayToolbox } = load();
|
|
50
|
+
|
|
51
|
+
await registerXrayToolbox(toolbox);
|
|
52
|
+
await registerXrayToolbox({ ...toolbox, tools: [] });
|
|
53
|
+
|
|
54
|
+
expect(xray.registerReactToolbox).toHaveBeenCalledTimes(2);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it("stops trying every toolbox once the bridge is missing", async () => {
|
|
58
|
+
xray.registerReactToolbox = jest.fn().mockRejectedValue(new Error("no"));
|
|
59
|
+
const { registerXrayToolbox } = load();
|
|
60
|
+
|
|
61
|
+
await registerXrayToolbox(toolbox);
|
|
62
|
+
|
|
63
|
+
await expect(
|
|
64
|
+
registerXrayToolbox({ ...toolbox, name: "other" })
|
|
65
|
+
).resolves.toBe(false);
|
|
66
|
+
|
|
67
|
+
expect(xray.registerReactToolbox).toHaveBeenCalledTimes(1);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { getXray } from ".";
|
|
2
|
+
|
|
3
|
+
/** One tool of an X-Ray React toolbox: an agent calls it by name with JSON arguments. */
|
|
4
|
+
export type XrayToolSpec = {
|
|
5
|
+
name: string;
|
|
6
|
+
description: string;
|
|
7
|
+
parameters?: Array<{
|
|
8
|
+
name: string;
|
|
9
|
+
type: "number" | "string";
|
|
10
|
+
description: string;
|
|
11
|
+
}>;
|
|
12
|
+
handler: (args: Record<string, unknown>) => unknown;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type XrayToolbox = {
|
|
16
|
+
name: string;
|
|
17
|
+
description: string;
|
|
18
|
+
tools: XrayToolSpec[];
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
type RegisterReactToolbox = (toolbox: XrayToolbox) => Promise<void>;
|
|
22
|
+
|
|
23
|
+
const registered = new Map<
|
|
24
|
+
string,
|
|
25
|
+
{ tools: XrayToolSpec[]; registration: Promise<boolean> }
|
|
26
|
+
>();
|
|
27
|
+
|
|
28
|
+
/** Set once a registration fails: the build has no X-Ray bridge, which cannot appear later. */
|
|
29
|
+
let bridgeMissing = false;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Registers an X-Ray React toolbox and resolves whether it is registered. The same tools are
|
|
33
|
+
* registered once; new tools under the same name (Fast Refresh re-ran the module) replace them.
|
|
34
|
+
* A build without the X-Ray native bridge (release builds) rejects the first attempt and every
|
|
35
|
+
* later call resolves false at once, so callers on hot paths pay for one attempt only.
|
|
36
|
+
*/
|
|
37
|
+
export const registerXrayToolbox = (toolbox: XrayToolbox): Promise<boolean> => {
|
|
38
|
+
const cached = registered.get(toolbox.name);
|
|
39
|
+
|
|
40
|
+
if (cached?.tools === toolbox.tools) return cached.registration;
|
|
41
|
+
|
|
42
|
+
if (bridgeMissing) return Promise.resolve(false);
|
|
43
|
+
|
|
44
|
+
const register = (
|
|
45
|
+
getXray() as
|
|
46
|
+
| { registerReactToolbox?: RegisterReactToolbox }
|
|
47
|
+
| null
|
|
48
|
+
| undefined
|
|
49
|
+
)?.registerReactToolbox;
|
|
50
|
+
|
|
51
|
+
const registration = register
|
|
52
|
+
? register(toolbox).then(
|
|
53
|
+
() => true,
|
|
54
|
+
() => {
|
|
55
|
+
bridgeMissing = true;
|
|
56
|
+
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
)
|
|
60
|
+
: Promise.resolve(false);
|
|
61
|
+
|
|
62
|
+
if (!register) bridgeMissing = true;
|
|
63
|
+
|
|
64
|
+
registered.set(toolbox.name, { tools: toolbox.tools, registration });
|
|
65
|
+
|
|
66
|
+
return registration;
|
|
67
|
+
};
|
|
@@ -830,6 +830,14 @@ function getPlayerConfiguration({ platform, version }) {
|
|
|
830
830
|
type: "switch",
|
|
831
831
|
label_tooltip:
|
|
832
832
|
"Enable this option to have a floating video player when the app is in the background.",
|
|
833
|
+
},
|
|
834
|
+
{
|
|
835
|
+
key: "vertical_video_player",
|
|
836
|
+
label: "Vertical video mode",
|
|
837
|
+
initial_value: false,
|
|
838
|
+
type: "switch",
|
|
839
|
+
label_tooltip:
|
|
840
|
+
"Enable this option to use the vertical video player layout.",
|
|
833
841
|
}
|
|
834
842
|
);
|
|
835
843
|
|
package/manifestUtils/keys.js
CHANGED
|
@@ -412,6 +412,12 @@ const mobileActionButtonContainerFields = (positionOptions) => [
|
|
|
412
412
|
type: ZAPPIFEST_FIELDS.switch,
|
|
413
413
|
suffix: "buttons enabled",
|
|
414
414
|
},
|
|
415
|
+
{
|
|
416
|
+
type: ZAPPIFEST_FIELDS.switch,
|
|
417
|
+
suffix: "cell navigation enabled",
|
|
418
|
+
label_tooltip:
|
|
419
|
+
"Controls whether tapping on the cell (outside the buttons) triggers its navigation behavior. When disabled, only the configured buttons are interactive. Useful for Home screens (tap anywhere to open) vs. Details screens (only buttons should work).",
|
|
420
|
+
},
|
|
415
421
|
{
|
|
416
422
|
type: ZAPPIFEST_FIELDS.select,
|
|
417
423
|
suffix: "position",
|
|
@@ -478,7 +484,7 @@ const MOBILE_ACTION_BUTTON_FIELDS = [
|
|
|
478
484
|
{ text: "share", value: "native_share_action" },
|
|
479
485
|
{ text: "downloads", value: "offline-content-button" },
|
|
480
486
|
{ text: "trailer", value: "trailer_action" },
|
|
481
|
-
{ text: "mute/unmute", value: "
|
|
487
|
+
{ text: "mute/unmute", value: "mute_unmute_action" },
|
|
482
488
|
],
|
|
483
489
|
},
|
|
484
490
|
{
|
|
@@ -7,6 +7,7 @@ describe("mobileActionButtonsContainer", () => {
|
|
|
7
7
|
description: "container",
|
|
8
8
|
defaults: {
|
|
9
9
|
buttonsEnabled: false,
|
|
10
|
+
cellNavigationEnabled: false,
|
|
10
11
|
position: ["over_image", "text_label_1", "text_label_2"],
|
|
11
12
|
align: "left",
|
|
12
13
|
overImagePosition: "bottom_left",
|
|
@@ -31,6 +32,26 @@ describe("mobileActionButtonsContainer", () => {
|
|
|
31
32
|
expect(enabledField).toBeTruthy();
|
|
32
33
|
expect(enabledField.type).toBe("switch");
|
|
33
34
|
|
|
35
|
+
const cellNavigationField = result.fields.find(
|
|
36
|
+
(field) =>
|
|
37
|
+
field.key === "mobile_buttons_container_cell_navigation_enabled"
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
expect(cellNavigationField).toMatchObject({
|
|
41
|
+
type: "switch",
|
|
42
|
+
label: "Cell navigation enabled",
|
|
43
|
+
initial_value: false,
|
|
44
|
+
label_tooltip: expect.stringContaining(
|
|
45
|
+
"Controls whether tapping on the cell"
|
|
46
|
+
),
|
|
47
|
+
conditional_fields: [
|
|
48
|
+
{
|
|
49
|
+
key: "styles/mobile_buttons_container_buttons_enabled",
|
|
50
|
+
condition_value: true,
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
});
|
|
54
|
+
|
|
34
55
|
const positionField = result.fields.find(
|
|
35
56
|
(field) => field.key === "mobile_buttons_container_position"
|
|
36
57
|
);
|