@applicaster/zapp-react-native-utils 15.1.11-alpha.7557142055 → 15.1.11-alpha.7595631787

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 (45) hide show
  1. package/actionsExecutor/ActionExecutor.ts +2 -40
  2. package/actionsExecutor/ActionExecutorContext.tsx +16 -70
  3. package/actionsExecutor/actions/index.ts +0 -4
  4. package/actionsExecutor/actions/refreshComponent.ts +0 -6
  5. package/actionsExecutor/actions/sendCloudEvent.ts +1 -6
  6. package/actionsExecutor/consts.ts +0 -23
  7. package/actionsExecutor/types.ts +1 -1
  8. package/appUtils/playerManager/OverlayObserver/OverlaysObserver.ts +2 -5
  9. package/appUtils/playerManager/OverlayObserver/__tests__/utils.test.ts +2 -55
  10. package/appUtils/playerManager/OverlayObserver/utils.ts +20 -51
  11. package/arrayUtils/index.ts +0 -79
  12. package/configurationUtils/manifestKeyParser.ts +9 -38
  13. package/manifestUtils/index.js +0 -3
  14. package/modalState/index.ts +83 -30
  15. package/package.json +2 -2
  16. package/reactHooks/usePluginConfiguration.ts +3 -6
  17. package/actionsExecutor/actions/__tests__/dismissBottomSheet.test.ts +0 -22
  18. package/actionsExecutor/actions/__tests__/loadItemsFromSource.test.ts +0 -88
  19. package/actionsExecutor/actions/__tests__/openBottomSheet.customContent.test.ts +0 -76
  20. package/actionsExecutor/actions/__tests__/openBottomSheet.inlineItems.test.ts +0 -100
  21. package/actionsExecutor/actions/dismissBottomSheet.ts +0 -22
  22. package/actionsExecutor/actions/openBottomSheet.ts +0 -320
  23. package/appUtils/playerManager/OverlayObserver/getUpcomingQueue.android.tv.ts +0 -4
  24. package/appUtils/playerManager/OverlayObserver/getUpcomingQueue.ios.tv.ts +0 -4
  25. package/appUtils/playerManager/OverlayObserver/getUpcomingQueue.ts +0 -11
  26. package/appUtils/playerManager/OverlayObserver/getUpcomingQueue.web.ts +0 -4
  27. package/arrayUtils/__tests__/reorderByIds.test.ts +0 -50
  28. package/configurationUtils/__tests__/modalBlocksParser.test.ts +0 -107
  29. package/configurationUtils/modalBlocksParser.ts +0 -178
  30. package/manifestUtils/modalBlocks.js +0 -304
  31. package/modalState/ContentViewModel.ts +0 -113
  32. package/modalState/EditableCollection.ts +0 -17
  33. package/modalState/EditableCollectionRegistry.ts +0 -51
  34. package/modalState/ModalOrchestrator.ts +0 -199
  35. package/modalState/RemoteEditableCollection.ts +0 -227
  36. package/modalState/__tests__/ContentViewModel.editable.test.ts +0 -69
  37. package/modalState/__tests__/ContentViewModel.test.ts +0 -165
  38. package/modalState/__tests__/EditableCollectionRegistry.test.ts +0 -112
  39. package/modalState/__tests__/ModalOrchestrator.phase3.test.ts +0 -47
  40. package/modalState/__tests__/RemoteEditableCollection.test.ts +0 -326
  41. package/modalState/__tests__/useBottomSheetContent.test.ts +0 -349
  42. package/modalState/store.ts +0 -102
  43. package/modalState/types.ts +0 -133
  44. package/modalState/useBottomSheetContent.ts +0 -102
  45. /package/reactHooks/actions/__tests__/{index.test.tsx → index.test.js} +0 -0
@@ -12,7 +12,7 @@ const { log_error, log_debug, log_info } = createLogger({
12
12
  category: "General",
13
13
  });
14
14
 
15
- export class ActionExecutor {
15
+ class ActionExecutor {
16
16
  private registeredActions: Record<string, ActionHandler> = {};
17
17
 
18
18
  // TODO: Remove context
@@ -101,8 +101,7 @@ export class ActionExecutor {
101
101
 
102
102
  registerAction = <TOptions = Record<string, any>>(
103
103
  type: string,
104
- handler: ActionHandler<TOptions>,
105
- stateResolver?: (entry?: ZappEntry) => any
104
+ handler: ActionHandler<TOptions>
106
105
  ) => {
107
106
  if (this.registeredActions[type]) {
108
107
  log_error(`registerAction: action type: ${type} already registered`);
@@ -113,48 +112,11 @@ export class ActionExecutor {
113
112
  this.registeredActions[type] = handler;
114
113
  log_debug(`registerAction: action type: ${type} registered`);
115
114
 
116
- let unregisterState = () => {};
117
-
118
- if (stateResolver) {
119
- unregisterState = this.registerActionState(type, stateResolver);
120
- }
121
-
122
115
  return () => {
123
116
  this.unregisterAction(type);
124
- unregisterState();
125
117
  log_debug(`registerAction: action type: ${type} un-registered`);
126
118
  };
127
119
  };
128
-
129
- private actionStates: Record<string, (entry?: ZappEntry) => any> = {};
130
-
131
- registerActionState = (
132
- type: string,
133
- stateResolver: (entry?: ZappEntry) => any
134
- ) => {
135
- if (this.actionStates[type]) {
136
- log_error(
137
- `registerActionState: action type state: ${type} already registered`
138
- );
139
-
140
- return () => {};
141
- }
142
-
143
- this.actionStates[type] = stateResolver;
144
- log_debug(`registerActionState: action type state: ${type} registered`);
145
-
146
- return () => {
147
- delete this.actionStates[type];
148
-
149
- log_debug(
150
- `registerActionState: action type state: ${type} un-registered`
151
- );
152
- };
153
- };
154
-
155
- getActionState = (type: string, entry?: ZappEntry) => {
156
- return this.actionStates[type]?.(entry);
157
- };
158
120
  }
159
121
 
160
122
  export const actionExecutor = new ActionExecutor();
@@ -19,11 +19,9 @@ import {
19
19
  appRestartAction,
20
20
  confirmDialogAction,
21
21
  createNavigateToScreenAction,
22
- dismissBottomSheetAction,
23
22
  localStorageRemoveAction,
24
23
  localStorageSetAction,
25
24
  localStorageToggleFlagAction,
26
- openBottomSheetAction,
27
25
  refreshComponentAction,
28
26
  screenSetVariableAction,
29
27
  screenToggleFlagAction,
@@ -35,8 +33,6 @@ import {
35
33
  showToastAction,
36
34
  } from "./actions";
37
35
 
38
- import { ACTION_TYPES } from "./consts";
39
-
40
36
  export const { log_error, log_info, log_debug } = createLogger({
41
37
  subsystem: "ActionExecutorContext",
42
38
  category: "General",
@@ -45,15 +41,9 @@ export const { log_error, log_info, log_debug } = createLogger({
45
41
  export type ActionExecutorContextType = {
46
42
  registerAction: <TOptions = Record<string, any>>(
47
43
  type: string,
48
- handler: ActionHandler<TOptions>,
49
- stateResolver?: (entry?: ZappEntry) => any
44
+ handler: ActionHandler<TOptions>
50
45
  ) => void;
51
46
  unregisterAction: (type: string) => void;
52
- registerActionState: (
53
- type: string,
54
- stateResolver: (entry?: ZappEntry) => any
55
- ) => () => void;
56
- getActionState: (type: string, entry?: ZappEntry) => any;
57
47
  handleAction: (
58
48
  action: ActionType,
59
49
  context?: ActionExecutionContext
@@ -73,76 +63,34 @@ type Props = {
73
63
  };
74
64
 
75
65
  const prepareDefaultActions = (actionExecutor) => {
76
- actionExecutor.registerAction(
77
- ACTION_TYPES.LOCAL_STORAGE_SET,
78
- localStorageSetAction
79
- );
80
-
81
- actionExecutor.registerAction(
82
- ACTION_TYPES.SESSION_STORAGE_SET,
83
- sessionStorageSetAction
84
- );
85
-
86
- actionExecutor.registerAction(
87
- ACTION_TYPES.LOCAL_STORAGE_REMOVE,
88
- localStorageRemoveAction
89
- );
66
+ actionExecutor.registerAction("localStorageSet", localStorageSetAction);
67
+ actionExecutor.registerAction("sessionStorageSet", sessionStorageSetAction);
68
+ actionExecutor.registerAction("localStorageRemove", localStorageRemoveAction);
90
69
 
91
70
  actionExecutor.registerAction(
92
- ACTION_TYPES.SESSION_STORAGE_REMOVE,
71
+ "sessionStorageRemove",
93
72
  sessionStorageRemoveAction
94
73
  );
95
74
 
96
- actionExecutor.registerAction(
97
- ACTION_TYPES.REFRESH_COMPONENT,
98
- refreshComponentAction
99
- );
100
-
101
- actionExecutor.registerAction(ACTION_TYPES.SWITCH_LAYOUT, switchLayoutAction);
102
-
103
- actionExecutor.registerAction(ACTION_TYPES.APP_RESTART, appRestartAction);
104
-
105
- actionExecutor.registerAction(
106
- ACTION_TYPES.CONFIRM_DIALOG,
107
- confirmDialogAction
108
- );
109
-
110
- actionExecutor.registerAction(
111
- ACTION_TYPES.SEND_CLOUD_EVENT,
112
- sendCloudEventAction
113
- );
75
+ actionExecutor.registerAction("refreshComponent", refreshComponentAction);
76
+ actionExecutor.registerAction("switchLayout", switchLayoutAction);
77
+ actionExecutor.registerAction("appRestart", appRestartAction);
78
+ actionExecutor.registerAction("confirmDialog", confirmDialogAction);
79
+ actionExecutor.registerAction("sendCloudEvent", sendCloudEventAction);
114
80
 
115
81
  actionExecutor.registerAction(
116
- ACTION_TYPES.SESSION_STORAGE_TOGGLE_FLAG,
82
+ "sessionStorageToggleFlag",
117
83
  sessionStorageToggleFlagAction
118
84
  );
119
85
 
120
86
  actionExecutor.registerAction(
121
- ACTION_TYPES.LOCAL_STORAGE_TOGGLE_FLAG,
87
+ "localStorageToggleFlag",
122
88
  localStorageToggleFlagAction
123
89
  );
124
90
 
125
- actionExecutor.registerAction(
126
- ACTION_TYPES.SCREEN_SET_VARIABLE,
127
- screenSetVariableAction
128
- );
129
-
130
- actionExecutor.registerAction(
131
- ACTION_TYPES.SCREEN_TOGGLE_FLAG,
132
- screenToggleFlagAction
133
- );
134
-
135
- actionExecutor.registerAction(
136
- ACTION_TYPES.OPEN_BOTTOM_SHEET,
137
- openBottomSheetAction
138
- );
139
-
140
- actionExecutor.registerAction(
141
- ACTION_TYPES.DISMISS_BOTTOM_SHEET,
142
- dismissBottomSheetAction
143
- );
144
-
145
- actionExecutor.registerAction(ACTION_TYPES.SHOW_TOAST, showToastAction);
91
+ actionExecutor.registerAction("screenSetVariable", screenSetVariableAction);
92
+ actionExecutor.registerAction("screenToggleFlag", screenToggleFlagAction);
93
+ actionExecutor.registerAction("showToast", showToastAction);
146
94
  };
147
95
 
148
96
  export const ActionExecutorContext =
@@ -160,8 +108,6 @@ export function withActionExecutor(Component) {
160
108
  return {
161
109
  unregisterAction: _actionExecutor.unregisterAction,
162
110
  registerAction: _actionExecutor.registerAction,
163
- registerActionState: _actionExecutor.registerActionState,
164
- getActionState: _actionExecutor.getActionState,
165
111
  handleAction: _actionExecutor.handleAction,
166
112
  handleActions: _actionExecutor.handleActions,
167
113
  handleEntryActions: _actionExecutor.handleEntryActions,
@@ -184,7 +130,7 @@ export function withActionExecutor(Component) {
184
130
 
185
131
  useEffect(() => {
186
132
  return _actionExecutor.registerAction(
187
- ACTION_TYPES.NAVIGATE_TO_SCREEN,
133
+ "navigateToScreen",
188
134
  createNavigateToScreenAction(navigator, rivers, contentTypes)
189
135
  );
190
136
  }, [navigator, rivers, contentTypes]);
@@ -28,7 +28,3 @@ export { screenToggleFlagAction } from "./screenToggleFlag";
28
28
  export { createNavigateToScreenAction } from "./navigateToScreen";
29
29
 
30
30
  export { showToastAction } from "./showToast";
31
-
32
- export { openBottomSheetAction } from "./openBottomSheet";
33
-
34
- export { dismissBottomSheetAction } from "./dismissBottomSheet";
@@ -82,12 +82,6 @@ export const refreshComponentAction: ActionHandler = async (
82
82
  }) || source;
83
83
  }
84
84
 
85
- if (!dataSource) {
86
- log_info("handleAction: refreshComponent skipped: no dataSource found");
87
-
88
- return ActionResult.Success;
89
- }
90
-
91
85
  log_info(`handleAction: refreshComponent for dataSource:${dataSource}`, {
92
86
  source,
93
87
  inflatedUrl: dataSource,
@@ -62,15 +62,10 @@ export const sendCloudEventAction: ActionHandler<
62
62
  subject: options.subject || String((entry as ZappEntry)?.id || ""),
63
63
  });
64
64
 
65
- log_info("handleAction: sending sendCloudEvent to URL", {
66
- url: options.url,
67
- cloudEvent,
68
- });
65
+ log_info("handleAction: sendCloudEvent event", { cloudEvent });
69
66
 
70
67
  const { error, code } = await sendCloudEvent(cloudEvent, options.url);
71
68
 
72
- log_info("handleAction: sendCloudEvent result", { code, error });
73
-
74
69
  if (error) {
75
70
  log_error("sendCloudEvent: error sending cloud event", { error });
76
71
 
@@ -2,26 +2,3 @@ export const TOGGLE_FLAG_MAX_ITEMS_REACHED_EVENT =
2
2
  "action.localStorageToggleFlag.maxItemsReached";
3
3
 
4
4
  export const ACTION_EXECUTOR_EVENT_SOURCE = "ActionExecutor";
5
-
6
- export const ACTION_TYPES = {
7
- OPEN_BOTTOM_SHEET: "openBottomSheet",
8
- DISMISS_BOTTOM_SHEET: "dismissBottomSheet",
9
- PRESENT_SUB_MENU: "presentSubMenu",
10
- SEND_CLOUD_EVENT: "sendCloudEvent",
11
- NAVIGATE_TO_SCREEN: "navigateToScreen",
12
- SHOW_TOAST: "showToast",
13
- LOCAL_STORAGE_SET: "localStorageSet",
14
- LOCAL_STORAGE_REMOVE: "localStorageRemove",
15
- LOCAL_STORAGE_TOGGLE_FLAG: "localStorageToggleFlag",
16
- SESSION_STORAGE_SET: "sessionStorageSet",
17
- SESSION_STORAGE_REMOVE: "sessionStorageRemove",
18
- SESSION_STORAGE_TOGGLE_FLAG: "sessionStorageToggleFlag",
19
- REFRESH_COMPONENT: "refreshComponent",
20
- SWITCH_LAYOUT: "switchLayout",
21
- APP_RESTART: "appRestart",
22
- CONFIRM_DIALOG: "confirmDialog",
23
- SCREEN_SET_VARIABLE: "screenSetVariable",
24
- SCREEN_TOGGLE_FLAG: "screenToggleFlag",
25
- } as const;
26
-
27
- export type KnownActionType = (typeof ACTION_TYPES)[keyof typeof ACTION_TYPES];
@@ -31,7 +31,7 @@ export interface ActionExecutionContext {
31
31
  /** Callback function for action completion */
32
32
  callback?: (result: { success: boolean; error: any; abort: boolean }) => void;
33
33
 
34
- screenState?: Record<any, any>;
34
+ screenState: Record<any, any>;
35
35
  }
36
36
 
37
37
  /**
@@ -3,8 +3,8 @@ import { distinctUntilChanged } from "rxjs/operators";
3
3
  import { Player } from "../player";
4
4
  import { createLogger, utilsLogger } from "../../../logger";
5
5
  import { appStore } from "@applicaster/zapp-react-native-redux/AppStore";
6
- import { findPluginByIdentifier } from "../../../pluginUtils";
7
6
  import {
7
+ findPluginByIdentifier,
8
8
  loadFeedEntry,
9
9
  loadFeedAndPrefetchThumbnailImage,
10
10
  parseTimeToSeconds,
@@ -252,10 +252,7 @@ export class OverlaysObserver {
252
252
  return;
253
253
  }
254
254
 
255
- const playNextFeedUrl: string = await retrieveFeedUrl(
256
- this.entry,
257
- plugins
258
- );
255
+ const playNextFeedUrl: string = retrieveFeedUrl(this.entry);
259
256
 
260
257
  if (!playNextFeedUrl || typeof playNextFeedUrl !== "string") {
261
258
  log_debug(
@@ -1,66 +1,13 @@
1
- const mockGetUpcomingQueue = jest.fn();
2
-
3
- jest.mock("../getUpcomingQueue", () => ({
4
- getUpcomingQueue: (...args: unknown[]) => mockGetUpcomingQueue(...args),
5
- }));
6
-
7
1
  import { retrieveFeedUrl, retrievePlayPreviousFeedUrl } from "../utils";
8
2
 
9
3
  const entryWith = (extensions: Record<string, unknown>): ZappEntry =>
10
4
  ({ id: "1", type: { value: "video" }, extensions }) as ZappEntry;
11
5
 
12
- const queuePlugin = { identifier: "queue-action" } as ZappPlugin;
13
-
14
6
  describe("playlist feed url accessors", () => {
15
- beforeEach(() => {
16
- mockGetUpcomingQueue.mockReset();
17
- });
18
-
19
- it("returns the next feed url when present", async () => {
20
- const entry = entryWith({ play_next_feed_url: "https://feeds/next.json" });
21
-
22
- await expect(retrieveFeedUrl(entry, [])).resolves.toBe(
23
- "https://feeds/next.json"
24
- );
25
- });
26
-
27
- it("resolves to null for a missing entry", async () => {
28
- await expect(
29
- retrieveFeedUrl(undefined as unknown as ZappEntry, [])
30
- ).resolves.toBeNull();
31
- });
32
-
33
- it("returns a queue play-next url when upcoming items exist", async () => {
34
- mockGetUpcomingQueue.mockResolvedValue([{ id: "next-item" }]);
35
-
36
- const entry = entryWith({
37
- play_next_feed_url: "https://feeds/next.json",
38
- queueItemId: "queue-1",
39
- });
40
-
41
- await expect(retrieveFeedUrl(entry, [queuePlugin])).resolves.toBe(
42
- "pipesv2://queue-action/play-next?queueItemId=queue-1"
43
- );
44
- });
45
-
46
- it("falls back to the next feed url when the upcoming queue is empty", async () => {
47
- mockGetUpcomingQueue.mockResolvedValue([]);
48
-
49
- const entry = entryWith({ play_next_feed_url: "https://feeds/next.json" });
50
-
51
- await expect(retrieveFeedUrl(entry, [queuePlugin])).resolves.toBe(
52
- "https://feeds/next.json"
53
- );
54
- });
55
-
56
- it("falls back to the next feed url when QueueManager cannot be resolved", async () => {
57
- mockGetUpcomingQueue.mockRejectedValue(new Error("not available"));
58
-
7
+ it("returns the next feed url when present", () => {
59
8
  const entry = entryWith({ play_next_feed_url: "https://feeds/next.json" });
60
9
 
61
- await expect(retrieveFeedUrl(entry, [queuePlugin])).resolves.toBe(
62
- "https://feeds/next.json"
63
- );
10
+ expect(retrieveFeedUrl(entry)).toBe("https://feeds/next.json");
64
11
  });
65
12
 
66
13
  it("returns the previous feed url when present", () => {
@@ -3,13 +3,10 @@ import {
3
3
  PipesClientResponseHelper,
4
4
  RequestBuilder,
5
5
  } from "@applicaster/zapp-pipes-v2-client";
6
- import { appStore } from "@applicaster/zapp-react-native-redux/AppStore";
7
6
  import { log_error, log_info } from "./OverlaysObserver";
7
+ import * as R from "ramda";
8
8
  import { toNumber, toNumberWithDefault } from "../../../numberUtils";
9
9
 
10
- import { findPluginByIdentifier } from "../../../pluginUtils";
11
- import { getUpcomingQueue } from "./getUpcomingQueue";
12
-
13
10
  export const parseTimeToSeconds = (timeStr: string): number => {
14
11
  const validationError = new Error("Invalid time format");
15
12
 
@@ -43,58 +40,14 @@ export const parseTimeToSeconds = (timeStr: string): number => {
43
40
  }
44
41
  };
45
42
 
46
- /**
47
- * HACK / TEMPORARY WORKAROUND:
48
- * Resolves the play_next_feed_url dynamically for OverlaysObserver.
49
- *
50
- * WHY THIS IS HACKED HERE:
51
- * OverlaysObserver was originally designed as a Recommendation Overlay engine (fetching static
52
- * play_next_feed_url for overlay UI visuals). However, for dynamic queue & continuous audio playback,
53
- * modifying feeds via `decorateFeed` at load time doesn't work (due to feed caching and mid-playback queue mutations).
54
- * To avoid mutating feed payloads across the app, we temporarily intercept play_next_feed_url here
55
- * at runtime to check if QueueManager has active/upcoming queue items.
56
- *
57
- * FUTURE ARCHITECTURE / TODO:
58
- * Move queue/playlist resolution into a dedicated Player/Queue Provider module (or Handler Chain)
59
- * on playerManager, decoupling Queue playback logic entirely from OverlaysObserver (which should
60
- * strictly focus on recommendation visuals and chapter markers).
61
- */
62
- export const retrieveFeedUrl = async (
63
- entry: ZappEntry,
64
- plugins?: ZappPlugin[]
65
- ): Promise<string> => {
66
- if (!entry) return null;
67
-
68
- const availablePlugins = plugins || appStore.get("plugins");
69
-
70
- const queuePlugin = findPluginByIdentifier(
71
- "queue-action",
72
- availablePlugins,
73
- true
74
- );
75
-
76
- if (queuePlugin) {
77
- try {
78
- const upcomingQueue = await getUpcomingQueue(queuePlugin);
79
-
80
- if (upcomingQueue && upcomingQueue.length > 0) {
81
- const queueItemId = entry?.extensions?.queueItemId || entry?.id;
82
-
83
- return `pipesv2://queue-action/play-next?queueItemId=${queueItemId}`;
84
- }
85
- } catch (e) {
86
- log_error("retrieveFeedUrl: Failed to resolve QueueManager", e);
87
- }
88
- }
89
-
90
- return entry?.extensions?.play_next_feed_url;
91
- };
43
+ export const retrieveFeedUrl = (entry: ZappEntry) =>
44
+ entry?.extensions?.play_next_feed_url;
92
45
 
93
46
  export const retrievePlayPreviousFeedUrl = (entry: ZappEntry) =>
94
47
  entry?.extensions?.play_previous_feed_url;
95
48
 
96
49
  export const retrieveOverlayDuration = (plugin) =>
97
- toNumberWithDefault(15, plugin?.configuration?.overlay_duration);
50
+ toNumberWithDefault(plugin?.configuration?.overlay_duration, 15);
98
51
 
99
52
  export const retrieveOverlayTriggerOffset = (item: ZappEntry) => {
100
53
  return item && item.extensions && item.extensions.overlay_timestamp
@@ -200,3 +153,19 @@ export const loadFeedAndPrefetchThumbnailImage = async (
200
153
 
201
154
  return playNextEntry;
202
155
  };
156
+
157
+ export const findPluginByIdentifier = (
158
+ identifier: string,
159
+ plugins: ZappPlugin[]
160
+ ): ZappPlugin => {
161
+ if (!identifier) {
162
+ return undefined;
163
+ }
164
+
165
+ const plugin = R.compose(
166
+ R.find(R.propEq("identifier", identifier)),
167
+ R.values
168
+ )(plugins);
169
+
170
+ return plugin;
171
+ };
@@ -121,82 +121,3 @@ export const allTruthy = (xs: boolean[]) =>
121
121
  isFilledArray(xs) && xs.every(Boolean);
122
122
 
123
123
  export const anyTruthy = (xs: boolean[]) => xs.some(Boolean);
124
-
125
- /**
126
- * Reorders `items` based on an ordered array of IDs (`orderedIds`).
127
- * Items whose IDs are in `orderedIds` appear first in that exact sequence.
128
- * Any remaining items not present in `orderedIds` are appended at the end preserving their relative order.
129
- */
130
- export function reorderByIds<T>(
131
- items: T[],
132
- orderedIds: string[],
133
- getId: (item: T) => string | string[] = (item: any) => item?.id
134
- ): T[] {
135
- if (!items || items.length === 0) return [];
136
- if (!orderedIds || orderedIds.length === 0) return [...items];
137
-
138
- const itemMap = new Map<string, T>();
139
-
140
- items.forEach((item) => {
141
- const rawId = getId(item);
142
- const keys = Array.isArray(rawId) ? rawId : [rawId];
143
-
144
- keys.forEach((key) => {
145
- if (key !== undefined && key !== null && key !== "") {
146
- itemMap.set(String(key), item);
147
- }
148
- });
149
- });
150
-
151
- const reorderedSubset: T[] = [];
152
- const orderedIdsSet = new Set<string>();
153
-
154
- orderedIds.forEach((id) => {
155
- const strId = String(id);
156
- const item = itemMap.get(strId);
157
-
158
- if (item && !reorderedSubset.includes(item)) {
159
- reorderedSubset.push(item);
160
- const rawId = getId(item);
161
- const keys = Array.isArray(rawId) ? rawId : [rawId];
162
-
163
- keys.forEach((k) => {
164
- if (k !== undefined && k !== null && k !== "") {
165
- orderedIdsSet.add(String(k));
166
- }
167
- });
168
- }
169
- });
170
-
171
- if (reorderedSubset.length === 0) return [...items];
172
-
173
- let subsetIdx = 0;
174
- const result: T[] = [];
175
-
176
- items.forEach((item) => {
177
- const rawId = getId(item);
178
- const keys = Array.isArray(rawId) ? rawId : [rawId];
179
-
180
- const isMatched = keys.some(
181
- (k) =>
182
- k !== undefined &&
183
- k !== null &&
184
- k !== "" &&
185
- orderedIdsSet.has(String(k))
186
- );
187
-
188
- if (isMatched) {
189
- if (subsetIdx < reorderedSubset.length) {
190
- result.push(reorderedSubset[subsetIdx++]);
191
- }
192
- } else {
193
- result.push(item);
194
- }
195
- });
196
-
197
- while (subsetIdx < reorderedSubset.length) {
198
- result.push(reorderedSubset[subsetIdx++]);
199
- }
200
-
201
- return result;
202
- }
@@ -12,23 +12,16 @@ const currentPlatform = platformSelect({
12
12
  });
13
13
 
14
14
  // Do not change the order, focused_selected should be first
15
- const states = [
16
- "focused_selected",
17
- "pressed",
18
- "focused",
19
- "selected",
20
- "default",
21
- ];
15
+ const states = ["focused_selected", "pressed", "focused", "selected"];
22
16
 
23
17
  const platformSuffixes = ["ios", "tvos", "samsung", "lg", "android"];
24
- type StateKey = (typeof states)[number];
18
+ type StateKey = (typeof states)[number] | "default";
25
19
 
26
20
  export type GetAllSpecificStylesProps = {
27
21
  componentName: string;
28
22
  subComponentName: string;
29
23
  configuration: Record<string, any>;
30
24
  outStyles: Record<string, any>;
31
- styleSeparator?: string;
32
25
  };
33
26
 
34
27
  /*
@@ -42,23 +35,14 @@ export const getAllSpecificStyles = ({
42
35
  componentName,
43
36
  subComponentName,
44
37
  outStyles,
45
- styleSeparator = "_style_",
46
38
  }: GetAllSpecificStylesProps) => {
47
39
  if (!outStyles) throw new Error("outStyles is required");
48
40
  if (!componentName) throw new Error("componentName is required");
49
41
 
50
- const prefixes =
42
+ const prefix =
51
43
  subComponentName?.length > 0
52
- ? [
53
- styleSeparator
54
- ? `${componentName}${styleSeparator}${subComponentName}_`
55
- : `${subComponentName}_`,
56
- `${componentName}_style_${subComponentName}_`,
57
- ]
58
- : [
59
- styleSeparator ? `${componentName}${styleSeparator}` : "",
60
- `${componentName}_style_`,
61
- ];
44
+ ? `${componentName}_style_${subComponentName}_`
45
+ : `${componentName}_style_`;
62
46
 
63
47
  const defaultKey = "default";
64
48
 
@@ -67,24 +51,12 @@ export const getAllSpecificStyles = ({
67
51
  const tmpGenericDict: Record<StateKey, Record<string, any>> = {};
68
52
  const tmpPlatformDict: Record<StateKey, Record<string, any>> = {};
69
53
 
70
- const parseKey = (key: string, originalKey: string, value: any) => {
71
- const matchedPrefix = prefixes.find((p) => p && key.startsWith(p));
72
-
73
- if (!matchedPrefix) {
54
+ const parseKey = (key: string, value: any) => {
55
+ if (!key.startsWith(prefix)) {
74
56
  return;
75
57
  }
76
58
 
77
- // Guard: for empty styleSeparator, if matching modern prefix, require dot in originalKey
78
- if (
79
- styleSeparator === "" &&
80
- matchedPrefix === `${subComponentName}_` &&
81
- !originalKey.includes(".")
82
- ) {
83
- return;
84
- }
85
-
86
- let styleName = key.slice(matchedPrefix.length);
87
-
59
+ let styleName = key.slice(prefix.length);
88
60
  if (!styleName || styleName.startsWith("_")) return;
89
61
 
90
62
  const platform = platformSuffixes.find((prefix) =>
@@ -121,8 +93,7 @@ export const getAllSpecificStyles = ({
121
93
  };
122
94
 
123
95
  for (const [key, value] of Object.entries(configuration)) {
124
- const formattedKey = key.replace(/\./g, "_");
125
- parseKey(formattedKey, key, value);
96
+ parseKey(key, value);
126
97
  }
127
98
 
128
99
  const allStates = Array.from(
@@ -23,7 +23,6 @@ const {
23
23
  const { buttonKey } = require("./buttons");
24
24
  const { tvBadges } = require("./tvBadges");
25
25
  const { mobileProgressBar, tvProgressBar } = require("./progressBar");
26
- const { getModalBlockStyles, getModalLocalizations } = require("./modalBlocks");
27
26
 
28
27
  const {
29
28
  secondaryImage,
@@ -53,6 +52,4 @@ module.exports = {
53
52
  getUpdatedSecondaryImageKeys,
54
53
  DEFAULT_GRADIENT_IMAGE,
55
54
  compact,
56
- getModalBlockStyles,
57
- getModalLocalizations,
58
55
  };