@applicaster/zapp-react-native-utils 15.0.0-alpha.4153840309 → 15.0.0-alpha.4200413542

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 (125) hide show
  1. package/actionsExecutor/ActionExecutorContext.tsx +3 -6
  2. package/actionsExecutor/feedDecorator.ts +6 -6
  3. package/adsUtils/__tests__/createVMAP.test.ts +419 -0
  4. package/adsUtils/index.ts +2 -2
  5. package/analyticsUtils/README.md +1 -1
  6. package/analyticsUtils/analyticsMapper.ts +10 -2
  7. package/appDataUtils/__tests__/urlScheme.test.ts +678 -0
  8. package/appUtils/HooksManager/__tests__/__snapshots__/hooksManager.test.js.snap +0 -188
  9. package/appUtils/HooksManager/__tests__/hooksManager.test.js +16 -2
  10. package/appUtils/HooksManager/index.ts +10 -10
  11. package/appUtils/RiverFocusManager/{index.js → index.ts} +25 -18
  12. package/appUtils/accessibilityManager/__tests__/utils.test.ts +360 -0
  13. package/appUtils/accessibilityManager/const.ts +4 -0
  14. package/appUtils/accessibilityManager/utils.ts +25 -5
  15. package/appUtils/contextKeysManager/__tests__/getKeys/failure.test.ts +7 -2
  16. package/appUtils/contextKeysManager/__tests__/getKeys/success.test.ts +48 -0
  17. package/appUtils/contextKeysManager/contextResolver.ts +51 -22
  18. package/appUtils/contextKeysManager/index.ts +65 -10
  19. package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +3 -0
  20. package/appUtils/focusManager/index.ios.ts +43 -4
  21. package/appUtils/focusManagerAux/utils/index.ios.ts +122 -0
  22. package/appUtils/focusManagerAux/utils/index.ts +1 -1
  23. package/appUtils/focusManagerAux/utils/utils.ios.ts +199 -3
  24. package/appUtils/keyCodes/keys/keys.web.ts +1 -4
  25. package/appUtils/orientationHelper.ts +2 -4
  26. package/appUtils/platform/platformUtils.ts +1 -1
  27. package/appUtils/playerManager/player.ts +4 -0
  28. package/appUtils/playerManager/playerNative.ts +29 -16
  29. package/appUtils/playerManager/usePlayerState.tsx +14 -2
  30. package/cloudEventsUtils/__tests__/index.test.ts +529 -0
  31. package/cloudEventsUtils/index.ts +65 -1
  32. package/configurationUtils/__tests__/imageSrcFromMediaItem.test.ts +38 -0
  33. package/configurationUtils/__tests__/manifestKeyParser.test.ts +26 -26
  34. package/configurationUtils/index.ts +17 -11
  35. package/dateUtils/__tests__/dayjs.test.ts +330 -0
  36. package/enumUtils/__tests__/getEnumKeyByEnumValue.test.ts +207 -0
  37. package/errorUtils/__tests__/GeneralError.test.ts +97 -0
  38. package/errorUtils/__tests__/HttpStatusCode.test.ts +344 -0
  39. package/errorUtils/__tests__/MissingPluginError.test.ts +113 -0
  40. package/errorUtils/__tests__/NetworkError.test.ts +202 -0
  41. package/errorUtils/__tests__/getParsedResponse.test.ts +188 -0
  42. package/errorUtils/__tests__/invariant.test.ts +112 -0
  43. package/focusManager/aux/index.ts +1 -1
  44. package/headersUtils/__tests__/headersUtils.test.js +11 -1
  45. package/headersUtils/index.ts +2 -1
  46. package/manifestUtils/defaultManifestConfigurations/player.js +125 -11
  47. package/manifestUtils/platformIsTV.js +13 -0
  48. package/manifestUtils/tvAction/container/index.js +1 -1
  49. package/navigationUtils/index.ts +15 -5
  50. package/numberUtils/__tests__/toNumber.test.ts +12 -0
  51. package/numberUtils/__tests__/toPositiveNumber.test.ts +165 -0
  52. package/numberUtils/index.ts +19 -1
  53. package/package.json +4 -4
  54. package/pluginUtils/index.ts +4 -0
  55. package/reactHooks/advertising/index.ts +2 -2
  56. package/reactHooks/analytics/__tests__/useSendAnalyticsOnPress.test.ts +537 -0
  57. package/reactHooks/app/__tests__/useAppState.test.ts +1 -1
  58. package/reactHooks/autoscrolling/__tests__/useTrackCurrentAutoScrollingElement.test.ts +1 -1
  59. package/reactHooks/autoscrolling/__tests__/useTrackedView.test.tsx +1 -2
  60. package/reactHooks/cell-click/__tests__/index.test.js +1 -3
  61. package/reactHooks/configuration/__tests__/index.test.tsx +1 -1
  62. package/reactHooks/connection/__tests__/index.test.js +1 -1
  63. package/reactHooks/debugging/__tests__/index.test.js +4 -4
  64. package/reactHooks/dev/__tests__/useReRenderLog.test.ts +188 -0
  65. package/reactHooks/device/useIsTablet.tsx +14 -19
  66. package/reactHooks/device/useMemoizedIsTablet.ts +3 -3
  67. package/reactHooks/events/index.ts +20 -0
  68. package/reactHooks/feed/__tests__/useBatchLoading.test.tsx +32 -23
  69. package/reactHooks/feed/__tests__/useBuildPipesUrl.test.tsx +19 -19
  70. package/reactHooks/feed/__tests__/useEntryScreenId.test.tsx +4 -1
  71. package/reactHooks/feed/__tests__/useFeedLoader.test.tsx +42 -30
  72. package/reactHooks/feed/__tests__/useFeedRefresh.test.tsx +1 -1
  73. package/reactHooks/feed/__tests__/{useInflatedUrl.test.ts → useInflatedUrl.test.tsx} +62 -7
  74. package/reactHooks/feed/useEntryScreenId.ts +2 -2
  75. package/reactHooks/feed/useInflatedUrl.ts +43 -17
  76. package/reactHooks/flatList/useLoadNextPageIfNeeded.ts +13 -16
  77. package/reactHooks/hookModal/hooks/useHookModalScreenData.ts +12 -8
  78. package/reactHooks/index.ts +2 -0
  79. package/reactHooks/layout/__tests__/index.test.tsx +1 -1
  80. package/reactHooks/layout/__tests__/useLayoutVersion.test.tsx +1 -1
  81. package/reactHooks/layout/useDimensions/__tests__/{useDimensions.test.ts → useDimensions.test.tsx} +105 -25
  82. package/reactHooks/layout/useDimensions/useDimensions.ts +2 -2
  83. package/reactHooks/navigation/__tests__/index.test.tsx +40 -9
  84. package/reactHooks/navigation/index.ts +27 -11
  85. package/reactHooks/navigation/useRoute.ts +11 -7
  86. package/reactHooks/player/TVSeekControlller/TVSeekController.ts +27 -10
  87. package/reactHooks/player/__tests__/useAutoSeek._test.tsx +1 -1
  88. package/reactHooks/player/__tests__/useTapSeek._test.ts +1 -1
  89. package/reactHooks/resolvers/__tests__/useCellResolver.test.tsx +1 -1
  90. package/reactHooks/resolvers/__tests__/useComponentResolver.test.tsx +1 -1
  91. package/reactHooks/resolvers/useCellResolver.ts +6 -2
  92. package/reactHooks/resolvers/useComponentResolver.ts +8 -2
  93. package/reactHooks/screen/__tests__/useCurrentScreenData.test.tsx +2 -2
  94. package/reactHooks/screen/__tests__/useScreenBackgroundColor.test.tsx +1 -1
  95. package/reactHooks/screen/__tests__/useScreenData.test.tsx +1 -1
  96. package/reactHooks/screen/__tests__/useTargetScreenData.test.tsx +12 -4
  97. package/reactHooks/screen/useTargetScreenData.ts +4 -2
  98. package/reactHooks/state/useRefWithInitialValue.ts +10 -0
  99. package/reactHooks/state/useRivers.ts +1 -1
  100. package/reactHooks/ui/__tests__/useFadeOutWhenBlurred.test.ts +580 -0
  101. package/reactHooks/usePluginConfiguration.ts +2 -2
  102. package/reactHooks/utils/__tests__/index.test.js +1 -1
  103. package/rectUtils/__tests__/index.test.ts +549 -0
  104. package/rectUtils/index.ts +2 -2
  105. package/screenPickerUtils/__tests__/index.test.ts +333 -0
  106. package/screenState/__tests__/index.test.ts +1 -1
  107. package/searchUtils/const.ts +7 -0
  108. package/searchUtils/index.ts +3 -0
  109. package/services/storageServiceSync.web.ts +1 -1
  110. package/stringUtils/index.ts +1 -1
  111. package/testUtils/index.tsx +30 -21
  112. package/time/__tests__/BackgroundTimer.test.ts +156 -0
  113. package/time/__tests__/Timer.test.ts +236 -0
  114. package/typeGuards/__tests__/isString.test.ts +21 -0
  115. package/typeGuards/index.ts +4 -0
  116. package/utils/__tests__/mergeRight.test.ts +48 -0
  117. package/utils/__tests__/selectors.test.ts +124 -0
  118. package/utils/index.ts +13 -0
  119. package/utils/mergeRight.ts +5 -0
  120. package/utils/path.ts +6 -3
  121. package/utils/pathOr.ts +5 -1
  122. package/utils/selectors.ts +46 -0
  123. package/zappFrameworkUtils/HookCallback/callbackNavigationAction.ts +34 -11
  124. package/zappFrameworkUtils/HookCallback/hookCallbackManifestExtensions.config.js +1 -1
  125. package/reactHooks/componentsMap/index.ts +0 -55
@@ -3,6 +3,41 @@ import { RequestBuilder } from "@applicaster/zapp-pipes-v2-client";
3
3
  import { sessionStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/SessionStorage";
4
4
  import { getAppUrlScheme } from "@applicaster/zapp-react-native-utils/appDataUtils";
5
5
 
6
+ /**
7
+ * CloudEvents v1.0 compliant event object
8
+ * @see https://github.com/cloudevents/spec/blob/v1.0/spec.md
9
+ */
10
+ export interface CloudEvent<T = any> {
11
+ /** CloudEvents specification version (always "1.0") */
12
+ specversion: "1.0";
13
+ /** Type of event (e.g., "user.action", "commerce.purchase") */
14
+ type: string;
15
+ /** Identifier for the entity that produced the event */
16
+ source: string;
17
+ /** Unique identifier for the event */
18
+ id: string;
19
+ /** Subject of the event in the context of the event producer */
20
+ subject: string;
21
+ /** Timestamp of when the event occurred (ISO 8601 format) */
22
+ time: string;
23
+ /** Content type of the data attribute (always "application/json") */
24
+ datacontenttype: "application/json";
25
+ /** Event payload */
26
+ data: T;
27
+ }
28
+
29
+ /**
30
+ * Parameters required to create a cloud event
31
+ */
32
+ export interface CreateCloudEventParams<T = any> {
33
+ /** Type of event (e.g., "user.action", "commerce.purchase") */
34
+ type: string;
35
+ /** Subject of the event in the context of the event producer */
36
+ subject: string;
37
+ /** Event payload */
38
+ data: T;
39
+ }
40
+
6
41
  let source: string | null = null;
7
42
 
8
43
  const addSource = async () => {
@@ -26,7 +61,36 @@ const addSource = async () => {
26
61
  return source;
27
62
  };
28
63
 
29
- export const createCloudEvent = async ({ type, subject, data }) => {
64
+ /**
65
+ * Resets the cached CloudEvents source.
66
+ *
67
+ * @internal
68
+ * @testonly This function is intended for test use only and will only work in test environments.
69
+ *
70
+ * @remarks
71
+ * This function clears the cached source value, forcing the next call to `createCloudEvent`
72
+ * to regenerate the source from app metadata. It only operates when NODE_ENV is set to "test"
73
+ * to prevent accidental misuse in production code.
74
+ *
75
+ * @example
76
+ * ```typescript
77
+ * // In Jest tests
78
+ * beforeEach(() => {
79
+ * resetCloudEventsSource();
80
+ * });
81
+ * ```
82
+ */
83
+ export const resetCloudEventsSource = (): void => {
84
+ if (process.env.NODE_ENV === "test") {
85
+ source = null;
86
+ }
87
+ };
88
+
89
+ export const createCloudEvent = async <T = any>({
90
+ type,
91
+ subject,
92
+ data,
93
+ }: CreateCloudEventParams<T>): Promise<CloudEvent<T>> => {
30
94
  return {
31
95
  specversion: "1.0",
32
96
  type,
@@ -31,4 +31,42 @@ describe("imageSrcFromMediaItem", () => {
31
31
 
32
32
  expect(imageSrcFromMediaItem(badEntry, ["image_base"])).toBeUndefined();
33
33
  });
34
+
35
+ it("returns undefined when fallback is false and key is not found", () => {
36
+ const result = imageSrcFromMediaItem(entry as ZappEntry, [
37
+ "does_not_exist",
38
+ false,
39
+ ]);
40
+
41
+ expect(result).toBeUndefined();
42
+ });
43
+
44
+ it("returns src when fallback is false and key is found", () => {
45
+ const result = imageSrcFromMediaItem(entry as ZappEntry, [
46
+ "logo_thumbnail",
47
+ false,
48
+ ]);
49
+
50
+ expect(result).toEqual(entry.media_group[1].media_item[0].src);
51
+ });
52
+
53
+ it("returns image_base as fallback when fallback is explicitly true and key is not found", () => {
54
+ const result = imageSrcFromMediaItem(entry as ZappEntry, [
55
+ "does_not_exist",
56
+ true,
57
+ ]);
58
+
59
+ const fallback = entry.media_group[0].media_item[0];
60
+ expect(result).toEqual(fallback.src);
61
+ expect(fallback.key).toBe("image_base");
62
+ });
63
+
64
+ it("returns src when fallback is explicitly true and key is found", () => {
65
+ const result = imageSrcFromMediaItem(entry as ZappEntry, [
66
+ "logo_thumbnail",
67
+ true,
68
+ ]);
69
+
70
+ expect(result).toEqual(entry.media_group[1].media_item[0].src);
71
+ });
34
72
  });
@@ -50,7 +50,7 @@ describe("getAllSpecificStyles", () => {
50
50
  });
51
51
 
52
52
  expect(outStyles).toHaveProperty("default");
53
- expect(outStyles["default"]).toEqual({});
53
+ expect(outStyles.default).toEqual({});
54
54
  });
55
55
 
56
56
  it("should handle empty configuration", () => {
@@ -83,7 +83,7 @@ describe("getAllSpecificStyles", () => {
83
83
  outStyles,
84
84
  });
85
85
 
86
- expect(outStyles["default"]).toEqual({
86
+ expect(outStyles.default).toEqual({
87
87
  backgroundColor: "#FF0000",
88
88
  borderWidth: 2,
89
89
  });
@@ -104,7 +104,7 @@ describe("getAllSpecificStyles", () => {
104
104
  outStyles,
105
105
  });
106
106
 
107
- expect(outStyles["default"]).toEqual({
107
+ expect(outStyles.default).toEqual({
108
108
  backgroundColor: "#FF0000",
109
109
  textSize: 16,
110
110
  });
@@ -126,7 +126,7 @@ describe("getAllSpecificStyles", () => {
126
126
  outStyles,
127
127
  });
128
128
 
129
- expect(outStyles["default"]).toEqual({
129
+ expect(outStyles.default).toEqual({
130
130
  backgroundColor: "#FF0000",
131
131
  });
132
132
  });
@@ -148,11 +148,11 @@ describe("getAllSpecificStyles", () => {
148
148
  outStyles,
149
149
  });
150
150
 
151
- expect(outStyles["default"]).toEqual({
151
+ expect(outStyles.default).toEqual({
152
152
  backgroundColor: "#FF0000",
153
153
  });
154
154
 
155
- expect(outStyles["pressed"]).toEqual({
155
+ expect(outStyles.pressed).toEqual({
156
156
  backgroundColor: "#00FF00",
157
157
  });
158
158
  });
@@ -171,7 +171,7 @@ describe("getAllSpecificStyles", () => {
171
171
  outStyles,
172
172
  });
173
173
 
174
- expect(outStyles["focused"]).toEqual({
174
+ expect(outStyles.focused).toEqual({
175
175
  borderWidth: 3,
176
176
  });
177
177
  });
@@ -190,7 +190,7 @@ describe("getAllSpecificStyles", () => {
190
190
  outStyles,
191
191
  });
192
192
 
193
- expect(outStyles["selected"]).toEqual({
193
+ expect(outStyles.selected).toEqual({
194
194
  opacity: 0.5,
195
195
  });
196
196
  });
@@ -209,7 +209,7 @@ describe("getAllSpecificStyles", () => {
209
209
  outStyles,
210
210
  });
211
211
 
212
- expect(outStyles["focused_selected"]).toEqual({
212
+ expect(outStyles.focused_selected).toEqual({
213
213
  scale: 1.2,
214
214
  });
215
215
  });
@@ -232,21 +232,21 @@ describe("getAllSpecificStyles", () => {
232
232
  outStyles,
233
233
  });
234
234
 
235
- expect(outStyles["default"]).toEqual({
235
+ expect(outStyles.default).toEqual({
236
236
  backgroundColor: "#FF0000",
237
237
  borderWidth: 1,
238
238
  opacity: 1,
239
239
  });
240
240
 
241
241
  // Pressed should have default styles merged with its specific override
242
- expect(outStyles["pressed"]).toEqual({
242
+ expect(outStyles.pressed).toEqual({
243
243
  backgroundColor: "#00FF00", // Override
244
244
  borderWidth: 1, // From default
245
245
  opacity: 1, // From default
246
246
  });
247
247
 
248
248
  // Focused should have default styles merged with its specific override
249
- expect(outStyles["focused"]).toEqual({
249
+ expect(outStyles.focused).toEqual({
250
250
  backgroundColor: "#FF0000", // From default
251
251
  borderWidth: 1, // From default
252
252
  opacity: 0.8, // Override
@@ -270,7 +270,7 @@ describe("getAllSpecificStyles", () => {
270
270
  outStyles,
271
271
  });
272
272
 
273
- expect(outStyles["pressed"]).toEqual({
273
+ expect(outStyles.pressed).toEqual({
274
274
  existingKey: "existingValue", // Should be preserved
275
275
  backgroundColor: "#FF0000", // From default
276
276
  textColor: "#FFFFFF", // New pressed style
@@ -294,7 +294,7 @@ describe("getAllSpecificStyles", () => {
294
294
  outStyles,
295
295
  });
296
296
 
297
- expect(outStyles["default"]).toEqual({
297
+ expect(outStyles.default).toEqual({
298
298
  backgroundColor: "#FF0000", // Samsung-specific should be included
299
299
  });
300
300
  });
@@ -317,7 +317,7 @@ describe("getAllSpecificStyles", () => {
317
317
  outStyles,
318
318
  });
319
319
 
320
- expect(outStyles["default"]).toEqual({
320
+ expect(outStyles.default).toEqual({
321
321
  backgroundColor: "#FFFFFF", // Only non-platform specific
322
322
  });
323
323
  });
@@ -336,7 +336,7 @@ describe("getAllSpecificStyles", () => {
336
336
  outStyles,
337
337
  });
338
338
 
339
- expect(outStyles["default"]).toEqual({
339
+ expect(outStyles.default).toEqual({
340
340
  color: "#FF0000",
341
341
  });
342
342
  });
@@ -356,7 +356,7 @@ describe("getAllSpecificStyles", () => {
356
356
  outStyles,
357
357
  });
358
358
 
359
- expect(outStyles["pressed"]).toEqual({
359
+ expect(outStyles.pressed).toEqual({
360
360
  backgroundColor: "#FF0000", // Only samsung style
361
361
  });
362
362
  });
@@ -377,7 +377,7 @@ describe("getAllSpecificStyles", () => {
377
377
  outStyles,
378
378
  });
379
379
 
380
- expect(outStyles["default"]).toEqual({
380
+ expect(outStyles.default).toEqual({
381
381
  backgroundColor: "#00FF00", // Samsung-specific should win
382
382
  });
383
383
  });
@@ -412,14 +412,14 @@ describe("getAllSpecificStyles", () => {
412
412
  outStyles,
413
413
  });
414
414
 
415
- expect(outStyles["default"]).toEqual({
415
+ expect(outStyles.default).toEqual({
416
416
  backgroundColor: "#FFFFFF",
417
417
  textColor: "#000000",
418
418
  borderWidth: 1,
419
419
  padding: 10,
420
420
  });
421
421
 
422
- expect(outStyles["pressed"]).toEqual({
422
+ expect(outStyles.pressed).toEqual({
423
423
  backgroundColor: "#EEEEEE",
424
424
  textColor: "#000000",
425
425
  borderWidth: 1,
@@ -427,7 +427,7 @@ describe("getAllSpecificStyles", () => {
427
427
  opacity: 0.8,
428
428
  });
429
429
 
430
- expect(outStyles["focused"]).toEqual({
430
+ expect(outStyles.focused).toEqual({
431
431
  backgroundColor: "#FFFFFF",
432
432
  textColor: "#000000",
433
433
  borderWidth: 1,
@@ -453,7 +453,7 @@ describe("getAllSpecificStyles", () => {
453
453
  outStyles,
454
454
  });
455
455
 
456
- expect(outStyles["default"]).toEqual({
456
+ expect(outStyles.default).toEqual({
457
457
  validKey: "included",
458
458
  });
459
459
  });
@@ -474,11 +474,11 @@ describe("getAllSpecificStyles", () => {
474
474
  outStyles,
475
475
  });
476
476
 
477
- expect(outStyles["focused_selected"]).toEqual({
477
+ expect(outStyles.focused_selected).toEqual({
478
478
  test: "focused_selected_value",
479
479
  });
480
480
 
481
- expect(outStyles["focused"]).toEqual({
481
+ expect(outStyles.focused).toEqual({
482
482
  another: "focused_value",
483
483
  });
484
484
  });
@@ -517,7 +517,7 @@ describe("getAllSpecificStyles", () => {
517
517
  outStyles,
518
518
  });
519
519
 
520
- expect(outStyles["pressed"]["backgroundColor"]).toBe("#222222");
520
+ expect(outStyles.pressed.backgroundColor).toBe("#222222");
521
521
  });
522
522
 
523
523
  it("should handle frozen outStyles properties", () => {
@@ -537,7 +537,7 @@ describe("getAllSpecificStyles", () => {
537
537
  });
538
538
 
539
539
  // Should create new object instead of mutating frozen one
540
- expect(outStyles["default"]).toEqual({
540
+ expect(outStyles.default).toEqual({
541
541
  existingProp: "value",
542
542
  backgroundColor: "#FF0000",
543
543
  });
@@ -155,9 +155,9 @@ export function getMediaItems(entry: ZappEntry): Option<ZappMediaItem[]> {
155
155
 
156
156
  /**
157
157
  * Retrieves the "src" value from a media item in the entry's media group,
158
- * based on a provided key, with fallback logic.
158
+ * based on a provided key, with optional fallback logic.
159
159
  *
160
- * Fallback order:
160
+ * Fallback order (when enabled):
161
161
  * 1. Attempts to find a media item with the specified key (or "image_base" if none provided).
162
162
  * 2. If not found, attempts to find a media item with the key "image_base".
163
163
  * 3. If still not found, falls back to the first available media item.
@@ -166,15 +166,19 @@ export function getMediaItems(entry: ZappEntry): Option<ZappMediaItem[]> {
166
166
  * since empty URIs are invalid in some platforms (e.g., React Native).
167
167
  *
168
168
  * @param {ZappEntry} entry - The entry object containing a media group.
169
- * @param {string[] | unknown} arg - A single-element array containing the key to look up, or any unknown value.
169
+ * @param {string[] | unknown} arg - Can be an array or any other value (treated as empty array).
170
+ * When an array:
171
+ * - First element: The key to look up. If omitted or undefined, defaults to "image_base".
172
+ * - Second element: Boolean to enable/disable fallback logic. If omitted or undefined, defaults to true.
170
173
  * @returns {?string} The "src" URI from the matched media item, or undefined if not found or empty.
171
174
  */
172
175
  export function imageSrcFromMediaItem(
173
176
  entry: ZappEntry,
174
177
  arg: string[] | unknown
175
178
  ): Option<string> {
176
- const args: unknown = R.unless(Array.isArray, Array)(arg || []);
179
+ const args: any = R.unless(Array.isArray, Array)(arg || []);
177
180
  const imageKey: string = args?.[0] || "image_base"; // always a single key in this function
181
+ const fallback: boolean = args?.[1] !== false;
178
182
 
179
183
  const mediaItems = getMediaItems(entry);
180
184
 
@@ -185,14 +189,16 @@ export function imageSrcFromMediaItem(
185
189
  // Try to find the item with the given key
186
190
  let foundItem = mediaItems.find((item) => item.key === imageKey);
187
191
 
188
- // If not found and key was not "image_base", try to find "image_base"
189
- if (!foundItem && imageKey !== "image_base") {
190
- foundItem = mediaItems.find((item) => item.key === "image_base");
191
- }
192
+ if (fallback) {
193
+ // If not found and key was not "image_base", try to find "image_base"
194
+ if (!foundItem && imageKey !== "image_base") {
195
+ foundItem = mediaItems.find((item) => item.key === "image_base");
196
+ }
192
197
 
193
- // If still not found, default to first item
194
- if (!foundItem) {
195
- foundItem = mediaItems[0];
198
+ // If still not found, default to first item
199
+ if (!foundItem) {
200
+ foundItem = mediaItems[0];
201
+ }
196
202
  }
197
203
 
198
204
  const src = foundItem?.src;