@applicaster/zapp-react-native-utils 16.0.0-alpha.2434153375 → 16.0.0-alpha.2500443242
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/ActionExecutor.ts +10 -1
- package/actionsExecutor/ActionExecutorContext.tsx +29 -1
- package/actionsExecutor/__tests__/ActionExecutor.test.ts +71 -0
- package/actionsExecutor/actions/__tests__/dismissBottomSheet.test.ts +3 -0
- package/actionsExecutor/actions/__tests__/goBack.test.ts +62 -0
- package/actionsExecutor/actions/__tests__/goHome.test.ts +19 -0
- package/actionsExecutor/actions/__tests__/navigateToScreen.test.ts +139 -5
- package/actionsExecutor/actions/__tests__/openBottomSheet.customContent.test.ts +24 -0
- package/actionsExecutor/actions/__tests__/openBottomSheet.inlineItems.test.ts +201 -1
- package/actionsExecutor/actions/__tests__/presentScreen.test.ts +127 -0
- package/actionsExecutor/actions/__tests__/showAlert.test.ts +49 -0
- package/actionsExecutor/actions/__tests__/showToast.test.ts +2 -2
- package/actionsExecutor/actions/dismissBottomSheet.ts +2 -1
- package/actionsExecutor/actions/goBack.ts +60 -0
- package/actionsExecutor/actions/goHome.ts +31 -0
- package/actionsExecutor/actions/index.ts +8 -0
- package/actionsExecutor/actions/navigateToScreen.ts +29 -45
- package/actionsExecutor/actions/openBottomSheet.ts +35 -16
- package/actionsExecutor/actions/presentScreen.ts +78 -0
- package/actionsExecutor/actions/showAlert.ts +51 -0
- package/actionsExecutor/actions/showToast.ts +2 -2
- package/actionsExecutor/consts.ts +4 -0
- 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/__tests__/usePlayerControllerSetup.test.tsx +62 -0
- package/appUtils/playerManager/const.ts +13 -0
- package/appUtils/playerManager/index.ts +7 -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 +157 -0
- package/appUtils/playerManager/usePlayerControllerSetup.tsx +6 -0
- package/arrayUtils/__tests__/reorderByIds.test.ts +13 -0
- package/arrayUtils/index.ts +26 -43
- 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 +74 -19
- package/configurationUtils/__tests__/manifestKeyParser.test.ts +21 -0
- package/configurationUtils/__tests__/modalBlocksParser.test.ts +286 -1
- package/configurationUtils/index.ts +77 -73
- package/configurationUtils/manifestKeyParser.ts +12 -1
- package/configurationUtils/modalBlocksParser.ts +78 -4
- package/entryActions/__tests__/buildEntryActions.test.ts +97 -18
- package/entryActions/aliasPresentation.ts +26 -42
- package/entryActions/buildEntryActions.ts +1 -0
- package/entryActions/index.ts +0 -2
- 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/_internals/index.js +8 -3
- package/manifestUtils/defaultManifestConfigurations/generalContent.js +6 -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/modalState/ModalOrchestrator.ts +22 -9
- package/modalState/RemoteEditableCollection.ts +9 -1
- package/modalState/__tests__/ModalOrchestrator.phase3.test.ts +16 -0
- package/modalState/__tests__/RemoteEditableCollection.test.ts +90 -1
- package/modalState/__tests__/index.test.ts +30 -1
- package/modalState/__tests__/useModalStoreState.test.ts +142 -0
- package/modalState/index.ts +6 -1
- package/modalState/store.ts +9 -2
- package/modalState/types.ts +31 -2
- package/modalState/useBottomSheetContent.ts +24 -17
- package/navigationUtils/xrayNavigator.ts +12 -0
- package/package.json +2 -2
- package/perfTracker.ts +206 -0
- package/pluginUtils/__tests__/pluginUtils.test.js +32 -0
- package/pluginUtils/index.ts +29 -0
- package/reactHooks/__tests__/getPluginConfiguration.test.ts +82 -0
- package/reactHooks/cell-click/__tests__/index.test.js +64 -0
- package/reactHooks/cell-click/index.ts +21 -14
- package/reactHooks/connection/index.tsx +8 -5
- package/reactHooks/feed/__tests__/useMarkPipesDataStale.test.tsx +243 -0
- package/reactHooks/feed/useMarkPipesDataStale.ts +68 -23
- package/reactHooks/navigation/__tests__/index.test.tsx +176 -1
- package/reactHooks/navigation/__tests__/usePresentScreen.test.ts +154 -0
- package/reactHooks/navigation/index.ts +2 -0
- package/reactHooks/navigation/usePresentScreen.ts +157 -0
- package/reactHooks/navigation/useRoute.ts +22 -5
- package/reactHooks/usePluginConfiguration.ts +84 -46
- package/riverComponetsMeasurementProvider/index.tsx +8 -1
- package/uiActionsRegistrator/__tests__/subscribe.test.ts +26 -0
- package/uiActionsRegistrator/registry.ts +16 -0
|
@@ -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", () => {
|
|
@@ -154,3 +194,42 @@ describe("buildEntryActions - alias & label resolution", () => {
|
|
|
154
194
|
});
|
|
155
195
|
});
|
|
156
196
|
});
|
|
197
|
+
|
|
198
|
+
describe("buildEntryActions - invokeAction execution context", () => {
|
|
199
|
+
it("forwards the List component from invoke options into handleActions", async () => {
|
|
200
|
+
const handleActions = jest.fn();
|
|
201
|
+
|
|
202
|
+
const component = {
|
|
203
|
+
id: "list-1",
|
|
204
|
+
data: { source: "https://example.com/user/collections/abc" },
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
const deps = {
|
|
208
|
+
actionExecutor: { handleActions } as any,
|
|
209
|
+
actionContext: { screenData: { id: "playlist-screen" } },
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
const entry = {
|
|
213
|
+
id: "entry-1",
|
|
214
|
+
extensions: {
|
|
215
|
+
entry_action: [
|
|
216
|
+
{
|
|
217
|
+
button: { title: "Edit Name" },
|
|
218
|
+
actions: [{ type: "refreshComponent" }],
|
|
219
|
+
},
|
|
220
|
+
],
|
|
221
|
+
},
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
const [action] = buildEntryActions(entry as any, deps);
|
|
225
|
+
|
|
226
|
+
await action.action.invokeAction(entry as any, { component });
|
|
227
|
+
|
|
228
|
+
expect(handleActions).toHaveBeenCalledWith([{ type: "refreshComponent" }], {
|
|
229
|
+
entry,
|
|
230
|
+
entryContext: entry,
|
|
231
|
+
screenData: { id: "playlist-screen" },
|
|
232
|
+
component,
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
});
|
|
@@ -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
|
@@ -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
|
+
};
|
|
@@ -135,7 +135,8 @@ function generateFieldsFromDefaults(label, defaults, fields) {
|
|
|
135
135
|
function generateFieldsFromDefaultsWithoutPrefixedLabel(
|
|
136
136
|
label,
|
|
137
137
|
defaults,
|
|
138
|
-
fields
|
|
138
|
+
fields,
|
|
139
|
+
{ withStyle = false } = {}
|
|
139
140
|
) {
|
|
140
141
|
const keyPrefix = toSnakeCase(label);
|
|
141
142
|
|
|
@@ -151,7 +152,9 @@ function generateFieldsFromDefaultsWithoutPrefixedLabel(
|
|
|
151
152
|
const generatedField = {
|
|
152
153
|
...fieldProps,
|
|
153
154
|
label: capitalizeFirstLetter(field.suffix),
|
|
154
|
-
key:
|
|
155
|
+
key: withStyle
|
|
156
|
+
? `${keyPrefix}_style_${toSnakeCase(field.suffix)}`
|
|
157
|
+
: `${keyPrefix}_${toSnakeCase(field.suffix)}`,
|
|
155
158
|
initial_value: R.when(R.is(Array), R.head)(initialValue),
|
|
156
159
|
};
|
|
157
160
|
|
|
@@ -164,7 +167,9 @@ function generateFieldsFromDefaultsWithoutPrefixedLabel(
|
|
|
164
167
|
const section = condition.section ? `${condition.section}/` : "";
|
|
165
168
|
|
|
166
169
|
return {
|
|
167
|
-
key:
|
|
170
|
+
key: withStyle
|
|
171
|
+
? `${section}${keyPrefix}_style_${toSnakeCase(condition.key)}`
|
|
172
|
+
: `${section}${keyPrefix}_${toSnakeCase(condition.key)}`,
|
|
168
173
|
condition_value: condition.value,
|
|
169
174
|
};
|
|
170
175
|
});
|
|
@@ -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,
|