@applicaster/zapp-react-native-utils 16.0.0-alpha.9235607812 → 16.0.0-alpha.9338540010
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__/playerToolbox.test.ts +97 -0
- package/appUtils/playerManager/__tests__/usePlayerControllerSetup.test.tsx +62 -0
- package/appUtils/playerManager/index.ts +7 -0
- package/appUtils/playerManager/playerToolbox.ts +157 -0
- package/appUtils/playerManager/usePlayerControllerSetup.tsx +6 -0
- 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 +123 -0
- package/configurationUtils/modalBlocksParser.ts +38 -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 +6 -1
- package/manifestUtils/mobileAction/container/__tests__/mobileActionButtonsContainer.test.js +21 -0
- package/manifestUtils/mobileAction/groups/__tests__/buildMobileActionButtonGroups.test.js +1 -1
- package/manifestUtils/mobileAction/groups/defaults.js +2 -1
- 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/usePluginConfiguration.ts +84 -46
- package/riverComponetsMeasurementProvider/index.tsx +3 -1
- package/uiActionsRegistrator/__tests__/subscribe.test.ts +26 -0
- package/uiActionsRegistrator/registry.ts +16 -0
|
@@ -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
|
+
);
|
|
@@ -257,6 +257,69 @@ describe("getEmptyModalBlocksStructure", () => {
|
|
|
257
257
|
);
|
|
258
258
|
});
|
|
259
259
|
|
|
260
|
+
it("maps text label and now playing font keys onto the label style", () => {
|
|
261
|
+
const result = parseModalBlocksConfiguration(
|
|
262
|
+
{
|
|
263
|
+
"item.text_label1.ios.font_family": "SFProText-Bold",
|
|
264
|
+
"item.text_label1.letter_spacing": -0.4,
|
|
265
|
+
"item.text_label1.text_transform": "uppercase",
|
|
266
|
+
"now_playing_item.now_playing_label.ios.font_family":
|
|
267
|
+
"SFProText-Semibold",
|
|
268
|
+
"now_playing_item.now_playing_label.font_size": 18,
|
|
269
|
+
},
|
|
270
|
+
"queue-action"
|
|
271
|
+
);
|
|
272
|
+
|
|
273
|
+
expect(result.item.textLabel1.default).toEqual(
|
|
274
|
+
expect.objectContaining({
|
|
275
|
+
fontFamily: "SFProText-Bold",
|
|
276
|
+
letterSpacing: -0.4,
|
|
277
|
+
textTransform: "uppercase",
|
|
278
|
+
})
|
|
279
|
+
);
|
|
280
|
+
|
|
281
|
+
expect(result.nowPlayingItem?.nowPlayingLabel.default).toEqual(
|
|
282
|
+
expect.objectContaining({
|
|
283
|
+
fontFamily: "SFProText-Semibold",
|
|
284
|
+
fontSize: 18,
|
|
285
|
+
})
|
|
286
|
+
);
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
it("maps queue remove and reorder assets onto item action buttons", () => {
|
|
290
|
+
const result = parseModalBlocksConfiguration(
|
|
291
|
+
{
|
|
292
|
+
"item.remove_asset": "https://example.com/remove.png",
|
|
293
|
+
"item.reorder_handle_asset": "https://example.com/reorder.png",
|
|
294
|
+
},
|
|
295
|
+
"queue-action"
|
|
296
|
+
);
|
|
297
|
+
|
|
298
|
+
expect(result.item.actionButtons.default).toEqual(
|
|
299
|
+
expect.objectContaining({
|
|
300
|
+
removeAsset: "https://example.com/remove.png",
|
|
301
|
+
dragAsset: "https://example.com/reorder.png",
|
|
302
|
+
})
|
|
303
|
+
);
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
it("maps now playing play and pause assets onto action buttons", () => {
|
|
307
|
+
const result = parseModalBlocksConfiguration(
|
|
308
|
+
{
|
|
309
|
+
"now_playing_item.play_asset": "https://example.com/play.png",
|
|
310
|
+
"now_playing_item.pause_asset": "https://example.com/pause.png",
|
|
311
|
+
},
|
|
312
|
+
"queue-action"
|
|
313
|
+
);
|
|
314
|
+
|
|
315
|
+
expect(result.nowPlayingItem?.actionButtons.default).toEqual(
|
|
316
|
+
expect.objectContaining({
|
|
317
|
+
playAsset: "https://example.com/play.png",
|
|
318
|
+
pauseAsset: "https://example.com/pause.png",
|
|
319
|
+
})
|
|
320
|
+
);
|
|
321
|
+
});
|
|
322
|
+
|
|
260
323
|
it("should leave sectionHeader empty when keys are absent", () => {
|
|
261
324
|
const result = parseModalBlocksConfiguration(
|
|
262
325
|
{ "item.text_label1.font_color": "#FFFFFF" },
|
|
@@ -266,4 +329,64 @@ describe("getEmptyModalBlocksStructure", () => {
|
|
|
266
329
|
expect(result.sectionHeader.title).toEqual({ default: {} });
|
|
267
330
|
expect(result.sectionHeader.actionButtons).toEqual({ default: {} });
|
|
268
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
|
+
});
|
|
269
392
|
});
|
|
@@ -210,5 +210,43 @@ export const parseModalBlocksConfiguration = (
|
|
|
210
210
|
|
|
211
211
|
parseBlock("button", ["background", "title", "icons", "leading_icon"]);
|
|
212
212
|
|
|
213
|
+
// Leaf uploader keys. They are not `<block>_<sub>_<prop>` styles, so
|
|
214
|
+
// getAllSpecificStyles never sees them.
|
|
215
|
+
const assignLeafAsset = (
|
|
216
|
+
block: ModalBlocksConfig["item"] | undefined,
|
|
217
|
+
key: string,
|
|
218
|
+
prop: "playAsset" | "pauseAsset" | "removeAsset" | "dragAsset"
|
|
219
|
+
) => {
|
|
220
|
+
if (!block) return;
|
|
221
|
+
|
|
222
|
+
const value = configuration[key];
|
|
223
|
+
|
|
224
|
+
if (typeof value !== "string" || !value.trim()) return;
|
|
225
|
+
|
|
226
|
+
block.actionButtons = {
|
|
227
|
+
...block.actionButtons,
|
|
228
|
+
default: {
|
|
229
|
+
...(block.actionButtons?.default || {}),
|
|
230
|
+
[prop]: value,
|
|
231
|
+
},
|
|
232
|
+
};
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
assignLeafAsset(
|
|
236
|
+
result.nowPlayingItem,
|
|
237
|
+
"now_playing_item.play_asset",
|
|
238
|
+
"playAsset"
|
|
239
|
+
);
|
|
240
|
+
|
|
241
|
+
assignLeafAsset(
|
|
242
|
+
result.nowPlayingItem,
|
|
243
|
+
"now_playing_item.pause_asset",
|
|
244
|
+
"pauseAsset"
|
|
245
|
+
);
|
|
246
|
+
|
|
247
|
+
assignLeafAsset(result.item, "item.remove_asset", "removeAsset");
|
|
248
|
+
|
|
249
|
+
assignLeafAsset(result.item, "item.reorder_handle_asset", "dragAsset");
|
|
250
|
+
|
|
213
251
|
return result;
|
|
214
252
|
};
|
|
@@ -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",
|
|
@@ -472,7 +478,6 @@ const MOBILE_ACTION_BUTTON_FIELDS = [
|
|
|
472
478
|
suffix: "assign action",
|
|
473
479
|
options: [
|
|
474
480
|
{ text: "primary navigation", value: "navigation_action" },
|
|
475
|
-
{ text: "secondary navigation", value: "secondary_navigation" },
|
|
476
481
|
{ text: "favorite", value: "local_storage_favourites_action" },
|
|
477
482
|
{ text: "more", value: "open-modal-bottom-sheet-cell-action" },
|
|
478
483
|
{ text: "add to calendar", value: "add_to_calendar_action" },
|
|
@@ -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
|
);
|
|
@@ -67,7 +67,7 @@ describe("buildMobileActionButtonGroups", () => {
|
|
|
67
67
|
);
|
|
68
68
|
|
|
69
69
|
expect(button2EnabledField.initial_value).toBe(false);
|
|
70
|
-
expect(button2AssignActionField.initial_value).toBe("
|
|
70
|
+
expect(button2AssignActionField.initial_value).toBe("trailer_action");
|
|
71
71
|
|
|
72
72
|
const button3Fields = groups[3].fields;
|
|
73
73
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const DEFAULT_MOBILE_ACTION_BUTTONS_CONTAINER_DEFAULTS = {
|
|
2
2
|
buttonsEnabled: false,
|
|
3
|
+
cellNavigationEnabled: false,
|
|
3
4
|
|
|
4
5
|
align: "left",
|
|
5
6
|
overImagePosition: "bottom_left",
|
|
@@ -63,7 +64,7 @@ const DEFAULT_MOBILE_ACTION_BUTTON_PRESETS = {
|
|
|
63
64
|
},
|
|
64
65
|
2: {
|
|
65
66
|
buttonEnabled: false,
|
|
66
|
-
assignAction: "
|
|
67
|
+
assignAction: "trailer_action",
|
|
67
68
|
},
|
|
68
69
|
3: {
|
|
69
70
|
buttonEnabled: false,
|