@applicaster/zapp-react-native-utils 16.0.0-alpha.2480030155 → 16.0.0-alpha.2554311249

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.
Files changed (106) hide show
  1. package/actionsExecutor/ActionExecutor.ts +40 -2
  2. package/actionsExecutor/ActionExecutorContext.tsx +96 -17
  3. package/actionsExecutor/__tests__/feedDecorator.test.ts +61 -0
  4. package/actionsExecutor/actions/__tests__/dismissBottomSheet.test.ts +25 -0
  5. package/actionsExecutor/actions/__tests__/goBack.test.ts +62 -0
  6. package/actionsExecutor/actions/__tests__/goHome.test.ts +19 -0
  7. package/actionsExecutor/actions/__tests__/loadItemsFromSource.test.ts +88 -0
  8. package/actionsExecutor/actions/__tests__/navigateToScreen.test.ts +133 -0
  9. package/actionsExecutor/actions/__tests__/openBottomSheet.customContent.test.ts +76 -0
  10. package/actionsExecutor/actions/__tests__/openBottomSheet.inlineItems.test.ts +212 -0
  11. package/actionsExecutor/actions/__tests__/presentScreen.test.ts +127 -0
  12. package/actionsExecutor/actions/__tests__/showToast.test.ts +2 -2
  13. package/actionsExecutor/actions/dismissBottomSheet.ts +23 -0
  14. package/actionsExecutor/actions/goBack.ts +60 -0
  15. package/actionsExecutor/actions/goHome.ts +31 -0
  16. package/actionsExecutor/actions/index.ts +10 -0
  17. package/actionsExecutor/actions/navigateToScreen.ts +18 -4
  18. package/actionsExecutor/actions/openBottomSheet.ts +329 -0
  19. package/actionsExecutor/actions/presentScreen.ts +78 -0
  20. package/actionsExecutor/actions/refreshComponent.ts +6 -0
  21. package/actionsExecutor/actions/sendCloudEvent.ts +6 -1
  22. package/actionsExecutor/actions/showToast.ts +2 -2
  23. package/actionsExecutor/consts.ts +26 -0
  24. package/actionsExecutor/feedDecorator.ts +6 -6
  25. package/appUtils/HooksManager/index.ts +9 -0
  26. package/appUtils/playerManager/OverlayObserver/OverlaysObserver.ts +132 -48
  27. package/appUtils/playerManager/OverlayObserver/__tests__/liveContent.test.ts +205 -0
  28. package/appUtils/playerManager/OverlayObserver/__tests__/utils.test.ts +49 -0
  29. package/appUtils/playerManager/OverlayObserver/getUpcomingQueue.android.tv.ts +4 -0
  30. package/appUtils/playerManager/OverlayObserver/getUpcomingQueue.ios.tv.ts +4 -0
  31. package/appUtils/playerManager/OverlayObserver/getUpcomingQueue.ts +11 -0
  32. package/appUtils/playerManager/OverlayObserver/getUpcomingQueue.web.ts +4 -0
  33. package/appUtils/playerManager/OverlayObserver/utils.ts +54 -20
  34. package/appUtils/playerManager/__tests__/playerContent.test.ts +403 -0
  35. package/appUtils/playerManager/__tests__/playerNative.test.ts +38 -0
  36. package/appUtils/playerManager/__tests__/usePlayerContent.test.tsx +64 -0
  37. package/appUtils/playerManager/player.ts +114 -2
  38. package/appUtils/playerManager/playerNative.ts +5 -3
  39. package/appUtils/playerManager/usePlayerContent.tsx +43 -0
  40. package/arrayUtils/__tests__/reorderByIds.test.ts +50 -0
  41. package/arrayUtils/index.ts +79 -0
  42. package/cellUtils/index.ts +30 -3
  43. package/configurationUtils/__tests__/manifestKeyParser.test.ts +21 -0
  44. package/configurationUtils/__tests__/modalBlocksParser.test.ts +260 -0
  45. package/configurationUtils/manifestKeyParser.ts +50 -10
  46. package/configurationUtils/modalBlocksParser.ts +296 -0
  47. package/entryActions/__tests__/buildEntryActions.test.ts +195 -0
  48. package/entryActions/aliasPresentation.ts +124 -0
  49. package/entryActions/buildEntryActions.ts +167 -0
  50. package/entryActions/index.ts +17 -0
  51. package/entryActions/types.ts +39 -0
  52. package/manifestUtils/__tests__/player.audioControls.test.js +158 -0
  53. package/manifestUtils/_internals/index.js +8 -3
  54. package/manifestUtils/defaultManifestConfigurations/generalContent.js +6 -0
  55. package/manifestUtils/defaultManifestConfigurations/player.js +330 -1
  56. package/manifestUtils/index.js +3 -0
  57. package/manifestUtils/modalBlocks.js +304 -0
  58. package/modalState/ContentViewModel.ts +113 -0
  59. package/modalState/EditableCollection.ts +17 -0
  60. package/modalState/EditableCollectionRegistry.ts +51 -0
  61. package/modalState/ModalOrchestrator.ts +211 -0
  62. package/modalState/RemoteEditableCollection.ts +235 -0
  63. package/modalState/__tests__/ContentViewModel.editable.test.ts +69 -0
  64. package/modalState/__tests__/ContentViewModel.test.ts +165 -0
  65. package/modalState/__tests__/EditableCollectionRegistry.test.ts +112 -0
  66. package/modalState/__tests__/ModalOrchestrator.phase3.test.ts +47 -0
  67. package/modalState/__tests__/RemoteEditableCollection.test.ts +415 -0
  68. package/modalState/__tests__/index.test.ts +30 -1
  69. package/modalState/__tests__/useBottomSheetContent.test.ts +349 -0
  70. package/modalState/__tests__/useModalStoreState.test.ts +142 -0
  71. package/modalState/index.ts +35 -83
  72. package/modalState/store.ts +109 -0
  73. package/modalState/types.ts +160 -0
  74. package/modalState/useBottomSheetContent.ts +109 -0
  75. package/package.json +2 -2
  76. package/playerUtils/__tests__/contentDataKeys.test.ts +297 -0
  77. package/playerUtils/__tests__/resolvePlayerActions.test.ts +138 -0
  78. package/playerUtils/__tests__/resolvePlayerTitleSubtitle.test.ts +180 -0
  79. package/playerUtils/contentDataKeys.ts +134 -0
  80. package/playerUtils/index.ts +37 -16
  81. package/playerUtils/isAudioItem.ts +26 -0
  82. package/playerUtils/resolvePlayerActions.ts +71 -0
  83. package/playerUtils/resolvePlayerTitleSubtitle.ts +76 -0
  84. package/reactHooks/actions/index.ts +67 -2
  85. package/reactHooks/cell-click/__tests__/index.test.js +64 -0
  86. package/reactHooks/cell-click/index.ts +21 -14
  87. package/reactHooks/index.ts +2 -0
  88. package/reactHooks/navigation/__tests__/index.test.tsx +176 -1
  89. package/reactHooks/navigation/__tests__/usePresentScreen.test.ts +154 -0
  90. package/reactHooks/navigation/index.ts +2 -0
  91. package/reactHooks/navigation/usePresentScreen.ts +157 -0
  92. package/reactHooks/navigation/useRoute.ts +22 -5
  93. package/reactHooks/usePluginConfiguration.ts +4 -1
  94. package/reactHooks/utils/__tests__/index.test.js +22 -2
  95. package/reactHooks/utils/index.ts +11 -1
  96. package/uiActionsRegistrator/__tests__/resolveActionIdentifiers.test.ts +93 -0
  97. package/uiActionsRegistrator/__tests__/subscribe.test.ts +107 -0
  98. package/uiActionsRegistrator/__tests__/usableActionItems.test.ts +52 -0
  99. package/uiActionsRegistrator/index.ts +25 -203
  100. package/uiActionsRegistrator/registry.ts +335 -0
  101. package/uiActionsRegistrator/resolveActionIdentifiers.ts +100 -0
  102. package/uiActionsRegistrator/usableActionItems.ts +66 -0
  103. package/appUtils/playerManager/usePlayerTitleSummaryOverlay.tsx +0 -56
  104. package/playerUtils/__tests__/getPlayerActionButtons.test.ts +0 -54
  105. package/playerUtils/getPlayerActionButtons.ts +0 -17
  106. /package/reactHooks/actions/__tests__/{index.test.js → index.test.tsx} +0 -0
@@ -0,0 +1,43 @@
1
+ import * as React from "react";
2
+ import { Player, PlayerContent } from "./player";
3
+ import { usePlayer } from "./usePlayer";
4
+
5
+ const EMPTY_CONTENT: PlayerContent = {
6
+ title: null,
7
+ summary: null,
8
+ imageUrl: null,
9
+ };
10
+
11
+ /**
12
+ * Subscribes to the player's resolved Title/Subtitle, the same way
13
+ * `usePlayerState` subscribes to playback state. Modeled on that hook
14
+ * deliberately: one React bridge pattern for everything the manager publishes.
15
+ *
16
+ * Passing no `playerId` uses the active player, which is the right default -
17
+ * only one player instance is live at a time. `usePlayer` additionally swaps
18
+ * to the casting receiver while casting, so this follows cast handover
19
+ * automatically.
20
+ */
21
+ export const usePlayerContent = (playerId?: string): PlayerContent => {
22
+ const player: Player = usePlayer(playerId);
23
+
24
+ const [content, setContent] = React.useState<PlayerContent>(
25
+ () => player?.getContent() ?? EMPTY_CONTENT
26
+ );
27
+
28
+ React.useEffect(() => {
29
+ if (!player) {
30
+ setContent(EMPTY_CONTENT);
31
+
32
+ return;
33
+ }
34
+
35
+ const subscription = player
36
+ .getContentObservable()
37
+ .subscribe((next) => setContent(next));
38
+
39
+ return () => subscription.unsubscribe();
40
+ }, [player]);
41
+
42
+ return content;
43
+ };
@@ -0,0 +1,50 @@
1
+ import { reorderByIds } from "../index";
2
+
3
+ describe("reorderByIds", () => {
4
+ const items = [
5
+ { id: "1", title: "Track 1" },
6
+ { id: "2", title: "Track 2" },
7
+ { id: "3", title: "Track 3" },
8
+ { id: "4", title: "Track 4" },
9
+ ];
10
+
11
+ it("returns an empty array if items is empty or nullish", () => {
12
+ expect(reorderByIds([], ["1"])).toEqual([]);
13
+ expect(reorderByIds(null as any, ["1"])).toEqual([]);
14
+ });
15
+
16
+ it("returns a copy of items if orderedIds is empty or nullish", () => {
17
+ expect(reorderByIds(items, [])).toEqual(items);
18
+ expect(reorderByIds(items, null as any)).toEqual(items);
19
+ });
20
+
21
+ it("reorders items based on the provided orderedIds sequence", () => {
22
+ const result = reorderByIds(items, ["3", "1", "4", "2"]);
23
+
24
+ expect(result.map((i) => i.id)).toEqual(["3", "1", "4", "2"]);
25
+ });
26
+
27
+ it("replaces items in their original slots when reordering a subset", () => {
28
+ const result = reorderByIds(items, ["4", "2"]);
29
+
30
+ expect(result.map((i) => i.id)).toEqual(["1", "4", "3", "2"]);
31
+ });
32
+
33
+ it("ignores IDs in orderedIds that do not exist in items", () => {
34
+ const result = reorderByIds(items, ["unknown", "3", "99", "1"]);
35
+
36
+ expect(result.map((i) => i.id)).toEqual(["3", "2", "1", "4"]);
37
+ });
38
+
39
+ it("supports custom getId selector function", () => {
40
+ const customItems = [
41
+ { key: "a", name: "Alpha" },
42
+ { key: "b", name: "Beta" },
43
+ { key: "c", name: "Gamma" },
44
+ ];
45
+
46
+ const result = reorderByIds(customItems, ["c", "a"], (item) => item.key);
47
+
48
+ expect(result.map((i) => i.key)).toEqual(["c", "b", "a"]);
49
+ });
50
+ });
@@ -158,3 +158,82 @@ export const allTruthy = (xs: boolean[]) =>
158
158
 
159
159
  /** Returns `true` when at least one value in `xs` is truthy. */
160
160
  export const anyTruthy = (xs: boolean[]) => xs.some(Boolean);
161
+
162
+ /**
163
+ * Reorders `items` based on an ordered array of IDs (`orderedIds`).
164
+ * Items whose IDs are in `orderedIds` appear first in that exact sequence.
165
+ * Any remaining items not present in `orderedIds` are appended at the end preserving their relative order.
166
+ */
167
+ export function reorderByIds<T>(
168
+ items: T[],
169
+ orderedIds: string[],
170
+ getId: (item: T) => string | string[] = (item: any) => item?.id
171
+ ): T[] {
172
+ if (!items || items.length === 0) return [];
173
+ if (!orderedIds || orderedIds.length === 0) return [...items];
174
+
175
+ const itemMap = new Map<string, T>();
176
+
177
+ items.forEach((item) => {
178
+ const rawId = getId(item);
179
+ const keys = Array.isArray(rawId) ? rawId : [rawId];
180
+
181
+ keys.forEach((key) => {
182
+ if (key !== undefined && key !== null && key !== "") {
183
+ itemMap.set(String(key), item);
184
+ }
185
+ });
186
+ });
187
+
188
+ const reorderedSubset: T[] = [];
189
+ const orderedIdsSet = new Set<string>();
190
+
191
+ orderedIds.forEach((id) => {
192
+ const strId = String(id);
193
+ const item = itemMap.get(strId);
194
+
195
+ if (item && !reorderedSubset.includes(item)) {
196
+ reorderedSubset.push(item);
197
+ const rawId = getId(item);
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
+ });
205
+ }
206
+ });
207
+
208
+ if (reorderedSubset.length === 0) return [...items];
209
+
210
+ 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
+
225
+ if (isMatched) {
226
+ if (subsetIdx < reorderedSubset.length) {
227
+ result.push(reorderedSubset[subsetIdx++]);
228
+ }
229
+ } else {
230
+ result.push(item);
231
+ }
232
+ });
233
+
234
+ while (subsetIdx < reorderedSubset.length) {
235
+ result.push(reorderedSubset[subsetIdx++]);
236
+ }
237
+
238
+ return result;
239
+ }
@@ -65,11 +65,38 @@ export const isEmptyOrNil = (value: any): boolean =>
65
65
  */
66
66
  export const getLabel = (dataKeyValue, customDataKeyValue) => (entry) => {
67
67
  const label = getKeyForLabel(dataKeyValue, customDataKeyValue);
68
- const isPath = label && R.length(label) > 0;
69
- const fallback = isEmptyOrNil(label) ? "" : R.head(label);
68
+ const isPath = label && label.length > 0;
69
+
70
+ // An unresolved key is rendered as-is, because a data key is allowed to be a
71
+ // literal label ("More") rather than a path. Fall back to the whole key
72
+ // instead of its first segment: "extensions.section" reads as an unresolved
73
+ // path, while "extensions" reads as a legitimate label and hides the problem.
74
+ const fallback = isEmptyOrNil(label) ? "" : label.join(".");
70
75
 
71
76
  try {
72
- return isPath ? R.pathOr(fallback, label, entry) : fallback;
77
+ if (!isPath) {
78
+ return fallback;
79
+ }
80
+
81
+ const resolved = label.reduce(
82
+ (value, key) => (value == null ? undefined : value[key]),
83
+ entry
84
+ );
85
+
86
+ if (isNotNil(resolved)) {
87
+ return resolved;
88
+ }
89
+
90
+ // A multi-segment key is unambiguously a path, so failing to resolve it is
91
+ // a misconfiguration rather than someone typing a literal label.
92
+ if (label.length > 1) {
93
+ cellUtilsLogger.warning({
94
+ message: `getLabel: data key "${fallback}" was not found on the entry, rendering the key itself`,
95
+ data: { dataKeyValue, customDataKeyValue, entryId: entry?.id },
96
+ });
97
+ }
98
+
99
+ return fallback;
73
100
  } catch (error) {
74
101
  cellUtilsLogger.warning({
75
102
  data: { error, dataKeyValue, customDataKeyValue },
@@ -176,6 +176,27 @@ describe("getAllSpecificStyles", () => {
176
176
  });
177
177
  });
178
178
 
179
+ it("should normalize Studio focus alias onto focused state", () => {
180
+ const outStyles = {};
181
+
182
+ const configuration = {
183
+ button_style_focus_background_color: "#FF3B30",
184
+ };
185
+
186
+ getAllSpecificStyles({
187
+ componentName: "button",
188
+ subComponentName: "",
189
+ configuration,
190
+ outStyles,
191
+ });
192
+
193
+ expect(outStyles.focused).toEqual({
194
+ backgroundColor: "#FF3B30",
195
+ });
196
+
197
+ expect(outStyles.focus).toBeUndefined();
198
+ });
199
+
179
200
  it("should handle selected state", () => {
180
201
  const outStyles = {};
181
202
 
@@ -0,0 +1,260 @@
1
+ import { parseModalBlocksConfiguration } from "../modalBlocksParser";
2
+
3
+ // Mock the platform selection logic so it's consistent
4
+ jest.mock("../../reactUtils", () => ({
5
+ platformSelect: jest.fn().mockReturnValue("ios"),
6
+ }));
7
+
8
+ describe("parseModalBlocksConfiguration", () => {
9
+ beforeEach(() => {
10
+ jest.clearAllMocks();
11
+ });
12
+
13
+ it("should return empty structures for missing config or componentName", () => {
14
+ const result1 = parseModalBlocksConfiguration(
15
+ undefined as any,
16
+ "queue_action"
17
+ );
18
+
19
+ expect(result1.header.container).toEqual({});
20
+
21
+ const result2 = parseModalBlocksConfiguration({ foo: "bar" }, "");
22
+ expect(result2.item.background).toEqual({});
23
+ });
24
+
25
+ it("should correctly parse the specified flat keys into nested objects", () => {
26
+ // The keys follow: <component_name>_style_<blockName>_<subComponent>_[platform_][state_]<styleName>
27
+ const config = {
28
+ // Header container - default platform, default state
29
+ queue_action_style_header_container_backgroundColor: "#000000",
30
+
31
+ // Header title - default platform, pressed state
32
+ queue_action_style_header_title_pressed_fontColor: "#ffffff",
33
+
34
+ // Item background - ios platform, default state
35
+ queue_action_style_item_background_ios_backgroundColor: "blue",
36
+
37
+ // Item textLabel1 - default platform, focused state
38
+ queue_action_style_item_text_label_1_focused_fontSize: 16,
39
+
40
+ // Ignored key (unrelated to building blocks or queue_action)
41
+ other_action_style_header_title_fontColor: "red",
42
+ some_random_key: "value",
43
+
44
+ // Ignored non-style data keys (should NEVER be parsed as styles)
45
+ item_data_source: "http://pipes.example.com",
46
+ item_url: "http://example.com",
47
+
48
+ // New dot notation from manifest-generator (without plugin prefix)
49
+ "item.text_label_2.fontColor": "green",
50
+ "action.background.pressed_backgroundColor": "black",
51
+
52
+ // New now_playing_item block
53
+ "now_playing_item.text_label_1.fontColor": "yellow",
54
+ "now_playing_item.now_playing_asset.asset": "equalizer.png",
55
+ };
56
+
57
+ const componentName = "queue_action";
58
+
59
+ const result = parseModalBlocksConfiguration(config, componentName);
60
+
61
+ // Assert header container default state
62
+ expect(result.header.container.default).toEqual({
63
+ backgroundColor: "#000000",
64
+ });
65
+
66
+ // Assert header title pressed state
67
+ // (pressed state will inherit default styles in getAllSpecificStyles if any,
68
+ // but here we just have pressed, so it has default empty from the parser)
69
+ expect(result.header.title.pressed).toEqual({
70
+ fontColor: "#ffffff",
71
+ });
72
+
73
+ // Assert item background ios default state
74
+ // (mocked platform is ios, so it should be accepted and assigned to default)
75
+ expect(result.item.background.default).toEqual({
76
+ backgroundColor: "blue",
77
+ });
78
+
79
+ // Assert item textLabel1 focused state
80
+ expect(result.item.textLabel1.focused).toEqual({
81
+ fontSize: 16,
82
+ });
83
+
84
+ // Assert dot notation textLabel2 default state
85
+ expect(result.item.textLabel2.default).toEqual({
86
+ fontColor: "green",
87
+ });
88
+
89
+ // Assert dot notation action background pressed state
90
+ expect(result.action.background.pressed).toEqual({
91
+ backgroundColor: "black",
92
+ });
93
+
94
+ // Assert nowPlayingItem states
95
+ expect(result.nowPlayingItem?.textLabel1.default).toEqual({
96
+ fontColor: "yellow",
97
+ });
98
+
99
+ expect(result.nowPlayingItem?.nowPlayingAsset.default).toEqual({
100
+ asset: "equalizer.png",
101
+ });
102
+
103
+ // Assert untouched properties remain empty default style objects
104
+ expect(result.button.title).toEqual({ default: {} });
105
+ expect(result.action.leadingIcon).toEqual({ default: {} });
106
+ });
107
+
108
+ it("should map Studio item.background.focus.* onto focused state", () => {
109
+ const result = parseModalBlocksConfiguration(
110
+ {
111
+ "item.background.default.background_color": "transparent",
112
+ "item.background.focus.background_color": "#FF3B30",
113
+ },
114
+ "playlist-experience"
115
+ );
116
+
117
+ expect(result.item.background.default).toEqual(
118
+ expect.objectContaining({
119
+ backgroundColor: "transparent",
120
+ })
121
+ );
122
+
123
+ expect(result.item.background.focused).toEqual(
124
+ expect.objectContaining({
125
+ backgroundColor: "#FF3B30",
126
+ })
127
+ );
128
+ });
129
+
130
+ it("should accept Studio text_label1 keys without underscore before digit", () => {
131
+ const result = parseModalBlocksConfiguration(
132
+ {
133
+ "item.text_label1.font_color": "#00FF00",
134
+ "item.text_label1.font_size": 28,
135
+ "item.text_label2.font_color": "#00FFFF",
136
+ },
137
+ "playlist-experience"
138
+ );
139
+
140
+ expect(result.item.textLabel1.default).toEqual(
141
+ expect.objectContaining({
142
+ fontColor: "#00FF00",
143
+ fontSize: 28,
144
+ })
145
+ );
146
+
147
+ expect(result.item.textLabel2.default).toEqual(
148
+ expect.objectContaining({
149
+ fontColor: "#00FFFF",
150
+ })
151
+ );
152
+ });
153
+
154
+ it("should map button.create_new_playlist_asset onto leadingIcon.asset", () => {
155
+ const result = parseModalBlocksConfiguration(
156
+ {
157
+ "button.create_new_playlist_asset":
158
+ "https://placehold.co/24x24/FF00FF/FFFFFF/png?text=CN",
159
+ },
160
+ "playlist-experience"
161
+ );
162
+
163
+ expect(result.button.leadingIcon.default).toEqual(
164
+ expect.objectContaining({
165
+ asset: "https://placehold.co/24x24/FF00FF/FFFFFF/png?text=CN",
166
+ })
167
+ );
168
+ });
169
+
170
+ it("should map item.checkbox_asset and checked_checkbox_asset onto item.checkbox", () => {
171
+ const result = parseModalBlocksConfiguration(
172
+ {
173
+ "item.checkbox_asset":
174
+ "https://placehold.co/24x24/FF3B30/FFFFFF/png?text=CB",
175
+ "item.checked_checkbox_asset":
176
+ "https://placehold.co/24x24/FFD60A/000000/png?text=CK",
177
+ },
178
+ "playlist-experience"
179
+ );
180
+
181
+ expect(result.item.checkbox.default).toEqual(
182
+ expect.objectContaining({
183
+ asset: "https://placehold.co/24x24/FF3B30/FFFFFF/png?text=CB",
184
+ checkedAsset: "https://placehold.co/24x24/FFD60A/000000/png?text=CK",
185
+ })
186
+ );
187
+ });
188
+
189
+ it("should map reorder/remove Studio assets onto item.actionButtons", () => {
190
+ const result = parseModalBlocksConfiguration(
191
+ {
192
+ "reorder_playlist_item.remove_from_playlist_asset":
193
+ "https://placehold.co/24x24/00FF00/000000/png?text=RM",
194
+ "reorder_playlist_item.reorder_handle_asset":
195
+ "https://placehold.co/24x24/FF3B30/FFFFFF/png?text=RH",
196
+ },
197
+ "playlist-experience"
198
+ );
199
+
200
+ expect(result.item.actionButtons.default).toEqual(
201
+ expect.objectContaining({
202
+ removeAsset: "https://placehold.co/24x24/00FF00/000000/png?text=RM",
203
+ dragAsset: "https://placehold.co/24x24/FF3B30/FFFFFF/png?text=RH",
204
+ })
205
+ );
206
+ });
207
+
208
+ it("should fall back to flavor1 reorder/remove assets", () => {
209
+ const result = parseModalBlocksConfiguration(
210
+ {
211
+ "playlist_experience_assets_flavor1.remove_from_playlist_asset":
212
+ "https://placehold.co/24x24/00FF00/000000/png?text=RM",
213
+ "playlist_experience_assets_flavor1.reorder_handle_asset":
214
+ "https://placehold.co/24x24/FF3B30/FFFFFF/png?text=RH",
215
+ },
216
+ "playlist-experience"
217
+ );
218
+
219
+ expect(result.item.actionButtons.default).toEqual(
220
+ expect.objectContaining({
221
+ removeAsset: "https://placehold.co/24x24/00FF00/000000/png?text=RM",
222
+ dragAsset: "https://placehold.co/24x24/FF3B30/FFFFFF/png?text=RH",
223
+ })
224
+ );
225
+ });
226
+
227
+ it("should fall back to flavor2 reorder/remove assets", () => {
228
+ const result = parseModalBlocksConfiguration(
229
+ {
230
+ "playlist_experience_assets_flavor2.remove_from_playlist_asset":
231
+ "https://placehold.co/24x24/00FF00/000000/png?text=RM",
232
+ "playlist_experience_assets_flavor2.reorder_handle_asset":
233
+ "https://placehold.co/24x24/FF3B30/FFFFFF/png?text=RH",
234
+ },
235
+ "playlist-experience"
236
+ );
237
+
238
+ expect(result.item.actionButtons.default).toEqual(
239
+ expect.objectContaining({
240
+ removeAsset: "https://placehold.co/24x24/00FF00/000000/png?text=RM",
241
+ dragAsset: "https://placehold.co/24x24/FF3B30/FFFFFF/png?text=RH",
242
+ })
243
+ );
244
+ });
245
+
246
+ it("should ignore playlist-only asset keys for other theme plugins", () => {
247
+ const result = parseModalBlocksConfiguration(
248
+ {
249
+ "button.create_new_playlist_asset":
250
+ "https://placehold.co/24x24/FF00FF/FFFFFF/png?text=CN",
251
+ "playlist_experience_assets_flavor1.reorder_handle_asset":
252
+ "https://placehold.co/24x24/FF3B30/FFFFFF/png?text=RH",
253
+ },
254
+ "queue-action"
255
+ );
256
+
257
+ expect(result.button.leadingIcon.default?.asset).toBeUndefined();
258
+ expect(result.item.actionButtons.default?.dragAsset).toBeUndefined();
259
+ });
260
+ });
@@ -11,17 +11,30 @@ const currentPlatform = platformSelect({
11
11
  android_tv: "android",
12
12
  });
13
13
 
14
- // Do not change the order, focused_selected should be first
15
- const states = ["focused_selected", "pressed", "focused", "selected"];
14
+ // Do not change the order: focused_selected must be first, and "focus" must
15
+ // come *after* "focused". Matching uses startsWith(state + "_"), so putting
16
+ // "focus" first would steal focused_* / focused_selected_* keys. Adding
17
+ // "focus" here affects every getAllSpecificStyles consumer (not only modals);
18
+ // property names that themselves start with focus_ (e.g. focus_font_color as
19
+ // a non-state style) would also be classified as the focus state.
20
+ const states = [
21
+ "focused_selected",
22
+ "pressed",
23
+ "focused",
24
+ "focus",
25
+ "selected",
26
+ "default",
27
+ ];
16
28
 
17
29
  const platformSuffixes = ["ios", "tvos", "samsung", "lg", "android"];
18
- type StateKey = (typeof states)[number] | "default";
30
+ type StateKey = (typeof states)[number];
19
31
 
20
32
  export type GetAllSpecificStylesProps = {
21
33
  componentName: string;
22
34
  subComponentName: string;
23
35
  configuration: Record<string, any>;
24
36
  outStyles: Record<string, any>;
37
+ styleSeparator?: string;
25
38
  };
26
39
 
27
40
  /*
@@ -35,14 +48,23 @@ export const getAllSpecificStyles = ({
35
48
  componentName,
36
49
  subComponentName,
37
50
  outStyles,
51
+ styleSeparator = "_style_",
38
52
  }: GetAllSpecificStylesProps) => {
39
53
  if (!outStyles) throw new Error("outStyles is required");
40
54
  if (!componentName) throw new Error("componentName is required");
41
55
 
42
- const prefix =
56
+ const prefixes =
43
57
  subComponentName?.length > 0
44
- ? `${componentName}_style_${subComponentName}_`
45
- : `${componentName}_style_`;
58
+ ? [
59
+ styleSeparator
60
+ ? `${componentName}${styleSeparator}${subComponentName}_`
61
+ : `${subComponentName}_`,
62
+ `${componentName}_style_${subComponentName}_`,
63
+ ]
64
+ : [
65
+ styleSeparator ? `${componentName}${styleSeparator}` : "",
66
+ `${componentName}_style_`,
67
+ ];
46
68
 
47
69
  const defaultKey = "default";
48
70
 
@@ -51,12 +73,24 @@ export const getAllSpecificStyles = ({
51
73
  const tmpGenericDict: Record<StateKey, Record<string, any>> = {};
52
74
  const tmpPlatformDict: Record<StateKey, Record<string, any>> = {};
53
75
 
54
- const parseKey = (key: string, value: any) => {
55
- if (!key.startsWith(prefix)) {
76
+ const parseKey = (key: string, originalKey: string, value: any) => {
77
+ const matchedPrefix = prefixes.find((p) => p && key.startsWith(p));
78
+
79
+ if (!matchedPrefix) {
80
+ return;
81
+ }
82
+
83
+ // Guard: for empty styleSeparator, if matching modern prefix, require dot in originalKey
84
+ if (
85
+ styleSeparator === "" &&
86
+ matchedPrefix === `${subComponentName}_` &&
87
+ !originalKey.includes(".")
88
+ ) {
56
89
  return;
57
90
  }
58
91
 
59
- let styleName = key.slice(prefix.length);
92
+ let styleName = key.slice(matchedPrefix.length);
93
+
60
94
  if (!styleName || styleName.startsWith("_")) return;
61
95
 
62
96
  const platform = platformSuffixes.find((prefix) =>
@@ -84,6 +118,11 @@ export const getAllSpecificStyles = ({
84
118
  state = defaultKey;
85
119
  }
86
120
 
121
+ // Normalize Studio "focus" keys onto the runtime "focused" state bucket.
122
+ if (state === "focus") {
123
+ state = "focused";
124
+ }
125
+
87
126
  if (!styleName) return;
88
127
 
89
128
  const camelCaseKey = toCamelCase(styleName);
@@ -93,7 +132,8 @@ export const getAllSpecificStyles = ({
93
132
  };
94
133
 
95
134
  for (const [key, value] of Object.entries(configuration)) {
96
- parseKey(key, value);
135
+ const formattedKey = key.replace(/\./g, "_");
136
+ parseKey(formattedKey, key, value);
97
137
  }
98
138
 
99
139
  const allStates = Array.from(