@applicaster/zapp-react-native-utils 15.0.0-rc.98 → 15.1.0-alpha.1852552014

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 (172) hide show
  1. package/actionsExecutor/ActionExecutorContext.tsx +51 -5
  2. package/actionsExecutor/feedDecorator.ts +6 -6
  3. package/adsUtils/index.ts +2 -2
  4. package/analyticsUtils/AnalyticsEvents/sendMenuClickEvent.ts +2 -2
  5. package/analyticsUtils/PlayerAnalyticsManager.ts +11 -1
  6. package/analyticsUtils/README.md +1 -1
  7. package/analyticsUtils/__tests__/analyticsMapper.test.ts +35 -0
  8. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testACP_events.json +1 -1
  9. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testBlockUnlistedParams_rules.json +1 -1
  10. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testEmptyRenameKeepsName_events.json +4 -0
  11. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testEmptyRenameKeepsName_rules.json +6 -0
  12. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testEventRegex_events.json +3 -9
  13. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testIgnoreOrdering_events.json +18 -0
  14. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testIgnoreOrdering_rules.json +16 -0
  15. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexEventNoFallback_events.json +4 -0
  16. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexEventNoFallback_rules.json +6 -0
  17. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexMultiGroupRename_events.json +4 -0
  18. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexMultiGroupRename_rules.json +6 -0
  19. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexNonNamedFullMatch_events.json +4 -0
  20. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexNonNamedFullMatch_rules.json +6 -0
  21. package/analyticsUtils/__tests__/fixtures/index.js +20 -0
  22. package/analyticsUtils/analyticsMapper.ts +4 -1
  23. package/analyticsUtils/playerAnalyticsTracker.ts +26 -3
  24. package/appUtils/HooksManager/__tests__/__snapshots__/hooksManager.test.js.snap +188 -0
  25. package/appUtils/HooksManager/__tests__/hooksManager.test.js +2 -16
  26. package/appUtils/HooksManager/index.ts +47 -17
  27. package/appUtils/RiverFocusManager/{index.ts → index.js} +18 -25
  28. package/appUtils/accessibilityManager/const.ts +0 -4
  29. package/appUtils/accessibilityManager/utils.ts +1 -0
  30. package/appUtils/contextKeysManager/__tests__/getKeys/failure.test.ts +2 -7
  31. package/appUtils/contextKeysManager/__tests__/getKeys/success.test.ts +0 -48
  32. package/appUtils/contextKeysManager/contextResolver.ts +22 -51
  33. package/appUtils/contextKeysManager/index.ts +10 -65
  34. package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +0 -3
  35. package/appUtils/focusManager/index.ios.ts +4 -43
  36. package/appUtils/focusManagerAux/utils/index.ts +3 -5
  37. package/appUtils/focusManagerAux/utils/utils.ios.ts +3 -199
  38. package/appUtils/keyCodes/keys/keys.web.ts +4 -1
  39. package/appUtils/localizationsHelper.ts +4 -0
  40. package/appUtils/orientationHelper.ts +4 -2
  41. package/appUtils/platform/platformUtils.ts +1 -1
  42. package/appUtils/playerManager/__tests__/playerFactory.test.ts +150 -0
  43. package/appUtils/playerManager/index.ts +9 -0
  44. package/appUtils/playerManager/player.ts +1 -5
  45. package/appUtils/playerManager/playerFactory.ts +17 -34
  46. package/appUtils/playerManager/playerNative.ts +22 -30
  47. package/appUtils/playerManager/usePlayer.tsx +5 -3
  48. package/appUtils/playerManager/usePlayerState.tsx +2 -14
  49. package/cellUtils/__tests__/cellUtils.test.ts +39 -0
  50. package/cellUtils/index.ts +14 -6
  51. package/cloudEventsUtils/index.ts +1 -65
  52. package/colorUtils/__tests__/isTransparentColor.test.ts +76 -0
  53. package/colorUtils/__tests__/isValidColor.test.ts +70 -0
  54. package/colorUtils/index.ts +50 -0
  55. package/configurationUtils/__tests__/manifestKeyParser.test.ts +26 -26
  56. package/dateUtils/__tests__/dayjs.test.ts +0 -3
  57. package/dateUtils/index.ts +2 -0
  58. package/focusManager/aux/index.ts +1 -1
  59. package/headersUtils/__tests__/headersUtils.test.js +1 -11
  60. package/headersUtils/index.ts +1 -2
  61. package/manifestUtils/defaultManifestConfigurations/player.js +7 -75
  62. package/manifestUtils/keys.js +1 -0
  63. package/manifestUtils/platformIsTV.js +14 -0
  64. package/manifestUtils/tvAction/container/index.js +1 -1
  65. package/numberUtils/__tests__/toNumber.test.ts +0 -12
  66. package/numberUtils/index.ts +1 -19
  67. package/package.json +4 -4
  68. package/pipesUtils/__tests__/buildUrlWithQuery.test.ts +33 -0
  69. package/pipesUtils/__tests__/withPipesEndpoint.test.tsx +56 -0
  70. package/pipesUtils/index.ts +1 -0
  71. package/pipesUtils/withPipesEndpoint.tsx +54 -0
  72. package/playerUtils/index.ts +24 -2
  73. package/pluginUtils/index.ts +4 -9
  74. package/reactHooks/advertising/index.ts +2 -2
  75. package/reactHooks/app/__tests__/useAppState.test.ts +1 -1
  76. package/reactHooks/autoscrolling/__tests__/useTrackCurrentAutoScrollingElement.test.ts +1 -1
  77. package/reactHooks/autoscrolling/__tests__/useTrackedView.test.tsx +2 -1
  78. package/reactHooks/casting/index.ts +1 -0
  79. package/reactHooks/casting/useIsCasting.tsx +57 -0
  80. package/reactHooks/cell-click/__tests__/index.test.js +3 -1
  81. package/reactHooks/componentsMap/index.ts +55 -0
  82. package/reactHooks/configuration/__tests__/index.test.tsx +1 -1
  83. package/reactHooks/connection/__tests__/index.test.js +1 -1
  84. package/reactHooks/debugging/__tests__/index.test.js +4 -4
  85. package/reactHooks/device/useIsTablet.tsx +19 -14
  86. package/reactHooks/device/useMemoizedIsTablet.ts +3 -3
  87. package/reactHooks/events/index.ts +20 -0
  88. package/reactHooks/feed/__tests__/useBatchLoading.test.tsx +23 -32
  89. package/reactHooks/feed/__tests__/useBuildPipesUrl.test.tsx +19 -19
  90. package/reactHooks/feed/__tests__/useEntryScreenId.test.tsx +1 -4
  91. package/reactHooks/feed/__tests__/useFeedLoader.test.tsx +30 -42
  92. package/reactHooks/feed/__tests__/useFeedRefresh.test.tsx +1 -1
  93. package/reactHooks/feed/__tests__/useInflatedUrl.test.tsx +1 -1
  94. package/reactHooks/feed/useBatchLoading.ts +1 -7
  95. package/reactHooks/feed/useEntryScreenId.ts +2 -2
  96. package/reactHooks/feed/useInflatedUrl.ts +1 -1
  97. package/reactHooks/feed/usePipesCacheReset.ts +1 -3
  98. package/reactHooks/flatList/useLoadNextPageIfNeeded.ts +16 -13
  99. package/reactHooks/index.ts +2 -0
  100. package/reactHooks/layout/__tests__/index.test.tsx +1 -1
  101. package/reactHooks/layout/__tests__/useLayoutVersion.test.tsx +1 -1
  102. package/reactHooks/layout/useDimensions/__tests__/{useDimensions.test.tsx → useDimensions.test.ts} +25 -105
  103. package/reactHooks/layout/useDimensions/useDimensions.ts +2 -2
  104. package/reactHooks/navigation/__tests__/index.test.tsx +4 -2
  105. package/reactHooks/navigation/index.ts +6 -7
  106. package/reactHooks/navigation/useRoute.ts +6 -8
  107. package/reactHooks/player/TVSeekControlller/TVSeekController.ts +10 -27
  108. package/reactHooks/player/__tests__/useAutoSeek._test.tsx +1 -1
  109. package/reactHooks/player/__tests__/useTapSeek._test.ts +1 -1
  110. package/reactHooks/resolvers/__tests__/useCellResolver.test.tsx +1 -1
  111. package/reactHooks/resolvers/__tests__/useComponentResolver.test.tsx +1 -1
  112. package/reactHooks/resolvers/useCellResolver.ts +2 -6
  113. package/reactHooks/resolvers/useComponentResolver.ts +13 -9
  114. package/reactHooks/screen/__tests__/useCurrentScreenData.test.tsx +2 -2
  115. package/reactHooks/screen/__tests__/useCurrentScreenIsHook.test.ts +103 -0
  116. package/reactHooks/screen/__tests__/useCurrentScreenIsStartupHook.test.ts +94 -0
  117. package/reactHooks/screen/__tests__/useScreenBackgroundColor.test.tsx +1 -1
  118. package/reactHooks/screen/__tests__/useScreenData.test.tsx +1 -1
  119. package/reactHooks/screen/__tests__/useTargetScreenData.test.tsx +4 -12
  120. package/reactHooks/screen/index.ts +6 -0
  121. package/reactHooks/screen/useCurrentScreenIsHook.ts +9 -0
  122. package/reactHooks/screen/useCurrentScreenIsStartupHook.ts +8 -0
  123. package/reactHooks/screen/useIsStandaloneFullscreen.ts +12 -0
  124. package/reactHooks/screen/useTargetScreenData.ts +2 -4
  125. package/reactHooks/state/__tests__/useComponentScreenState.test.ts +246 -0
  126. package/reactHooks/state/index.ts +2 -0
  127. package/reactHooks/state/useComponentScreenState.ts +45 -0
  128. package/reactHooks/state/useRivers.ts +1 -1
  129. package/reactHooks/usePluginConfiguration.ts +2 -2
  130. package/reactHooks/utils/__tests__/index.test.js +1 -1
  131. package/reactHooks/videoModal/hooks/useVideoModalScreenData.tsx +22 -4
  132. package/rectUtils/index.ts +2 -2
  133. package/riverComponetsMeasurementProvider/index.tsx +12 -8
  134. package/screenPickerUtils/index.ts +5 -0
  135. package/screenState/__tests__/index.test.ts +1 -1
  136. package/stringUtils/index.ts +1 -1
  137. package/testUtils/index.tsx +21 -30
  138. package/typeGuards/index.ts +0 -4
  139. package/utils/__tests__/clone.test.ts +158 -0
  140. package/utils/clone.ts +7 -0
  141. package/utils/index.ts +1 -13
  142. package/utils/path.ts +3 -6
  143. package/utils/pathOr.ts +1 -5
  144. package/zappFrameworkUtils/HookCallback/callbackNavigationAction.ts +2 -2
  145. package/zappFrameworkUtils/HookCallback/hookCallbackManifestExtensions.config.js +1 -1
  146. package/zappFrameworkUtils/loginPluginUtils.ts +1 -1
  147. package/adsUtils/__tests__/createVMAP.test.ts +0 -419
  148. package/appDataUtils/__tests__/urlScheme.test.ts +0 -678
  149. package/appUtils/focusManagerAux/utils/index.ios.ts +0 -122
  150. package/cloudEventsUtils/__tests__/index.test.ts +0 -529
  151. package/enumUtils/__tests__/getEnumKeyByEnumValue.test.ts +0 -207
  152. package/errorUtils/__tests__/GeneralError.test.ts +0 -97
  153. package/errorUtils/__tests__/HttpStatusCode.test.ts +0 -344
  154. package/errorUtils/__tests__/MissingPluginError.test.ts +0 -113
  155. package/errorUtils/__tests__/NetworkError.test.ts +0 -202
  156. package/errorUtils/__tests__/getParsedResponse.test.ts +0 -188
  157. package/errorUtils/__tests__/invariant.test.ts +0 -112
  158. package/numberUtils/__tests__/toPositiveNumber.test.ts +0 -165
  159. package/reactHooks/analytics/__tests__/useSendAnalyticsOnPress.test.ts +0 -537
  160. package/reactHooks/dev/__tests__/useReRenderLog.test.ts +0 -188
  161. package/reactHooks/ui/__tests__/useFadeOutWhenBlurred.test.ts +0 -580
  162. package/rectUtils/__tests__/index.test.ts +0 -549
  163. package/screenPickerUtils/__tests__/index.test.ts +0 -333
  164. package/searchUtils/const.ts +0 -7
  165. package/searchUtils/index.ts +0 -3
  166. package/time/__tests__/BackgroundTimer.test.ts +0 -156
  167. package/time/__tests__/Timer.test.ts +0 -236
  168. package/typeGuards/__tests__/isString.test.ts +0 -21
  169. package/utils/__tests__/mergeRight.test.ts +0 -48
  170. package/utils/__tests__/selectors.test.ts +0 -124
  171. package/utils/mergeRight.ts +0 -5
  172. package/utils/selectors.ts +0 -46
@@ -0,0 +1,50 @@
1
+ import validateColor from "validate-color";
2
+ import { isNil } from "@applicaster/zapp-react-native-utils/utils";
3
+ import { isString } from "@applicaster/zapp-react-native-utils/stringUtils";
4
+
5
+ const normalizeRgbaAlpha = (color: string): string => {
6
+ return color.replace(
7
+ /^rgba\(([^)]+),\s*(\d+(?:\.\d+)?)\s*\)$/i,
8
+ (_, rgb, alpha) => {
9
+ const alphaValue = parseFloat(alpha);
10
+
11
+ if (!Number.isFinite(alphaValue) || !Number.isInteger(alphaValue)) {
12
+ return color;
13
+ }
14
+
15
+ return `rgba(${rgb},${alphaValue})`;
16
+ }
17
+ );
18
+ };
19
+
20
+ export const isValidColor = (color: string): boolean => {
21
+ if (isNil(color) || !isString(color)) {
22
+ return false;
23
+ }
24
+
25
+ if (validateColor(color)) {
26
+ return true;
27
+ }
28
+
29
+ // validate-color rejects integer alpha values written as floats (e.g. 1.0)
30
+ // https://github.com/dreamyguy/validate-color/issues/44
31
+ const normalizedColor = normalizeRgbaAlpha(color);
32
+
33
+ return normalizedColor !== color && validateColor(normalizedColor);
34
+ };
35
+
36
+ function isRgbaAlphaZero(color: string): boolean {
37
+ const layers = color
38
+ .replace("rgba(", "")
39
+ .replace(")", "")
40
+ .split(",")
41
+ .map((layer) => layer.trim());
42
+
43
+ return Number(layers[3]) === 0;
44
+ }
45
+
46
+ export const isTransparentColor = (color: string): boolean => {
47
+ return (
48
+ isValidColor(color) && (color === "transparent" || isRgbaAlphaZero(color))
49
+ );
50
+ };
@@ -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
  });
@@ -1,7 +1,4 @@
1
1
  import { dayjs } from "../index";
2
- import customParseFormat from "dayjs/plugin/customParseFormat";
3
-
4
- dayjs.extend(customParseFormat);
5
2
 
6
3
  describe("dayjs", () => {
7
4
  describe("basic functionality", () => {
@@ -4,12 +4,14 @@ import timezone from "dayjs/plugin/timezone";
4
4
  import isoWeek from "dayjs/plugin/isoWeek";
5
5
  import duration from "dayjs/plugin/duration";
6
6
  import relativeTime from "dayjs/plugin/relativeTime";
7
+ import customParseFormat from "dayjs/plugin/customParseFormat";
7
8
 
8
9
  // Extend dayjs with plugins
9
10
  dayjs.extend(utc);
10
11
  dayjs.extend(timezone);
11
12
  dayjs.extend(isoWeek);
12
13
  dayjs.extend(duration);
14
+ dayjs.extend(customParseFormat);
13
15
 
14
16
  dayjs.extend(relativeTime, {
15
17
  thresholds: [
@@ -49,7 +49,7 @@ export const findSelectedMenuId = (
49
49
  ) => {
50
50
  const sectionName = QUICK_BRICK_NAVBAR_SECTIONS[sectionKey];
51
51
 
52
- return pathOr<string | undefined>(
52
+ return pathOr(
53
53
  undefined,
54
54
  ["children", index, "id"],
55
55
  focusableTree.find(sectionName)
@@ -1,15 +1,6 @@
1
1
  import { appStore } from "@applicaster/zapp-react-native-redux/AppStore";
2
2
  import { getAppDataHeaders } from "../index";
3
3
 
4
- const mockUILanguage = "en-US";
5
-
6
- jest.mock(
7
- "@applicaster/zapp-react-native-utils/appUtils/localizationsHelper",
8
- () => ({
9
- getUILanguage: jest.fn(() => mockUILanguage),
10
- })
11
- );
12
-
13
4
  describe("getAppDataHeaders", () => {
14
5
  const mockAppData = {
15
6
  riversConfigurationId: "test-layout",
@@ -34,7 +25,7 @@ describe("getAppDataHeaders", () => {
34
25
  const expectedHeaders = {
35
26
  "x-applicaster-layout-id": mockAppData.riversConfigurationId,
36
27
  "x-applicaster-screen-id": screenId,
37
- "x-applicaster-language-code": mockUILanguage,
28
+ "x-applicaster-language-code": mockAppData.languageCode,
38
29
  "x-applicaster-version-number": mockAppData.version_name,
39
30
  "x-applicaster-platform": mockAppData.platform,
40
31
  "x-applicaster-country-code": mockAppData.countryCode,
@@ -42,7 +33,6 @@ describe("getAppDataHeaders", () => {
42
33
  mockAppData.signedDeviceInfoToken,
43
34
  "x-applicaster-device-make": mockAppData.deviceMake,
44
35
  "x-applicaster-device-model": mockAppData.deviceModel,
45
- "x-applicaster-uuid": undefined,
46
36
  };
47
37
 
48
38
  const headers = getAppDataHeaders(screenId);
@@ -1,7 +1,6 @@
1
1
  import { appStore } from "@applicaster/zapp-react-native-redux/AppStore";
2
2
  import { getPlatform } from "@applicaster/zapp-react-native-utils/reactUtils";
3
3
  import { utilsLogger } from "../logger";
4
- import { getUILanguage } from "../localizationUtils";
5
4
 
6
5
  const logger = utilsLogger.addSubsystem("headersUtils");
7
6
 
@@ -22,7 +21,7 @@ export const getAppDataHeaders = (screenId: string) => {
22
21
  "x-applicaster-layout-id":
23
22
  appData.riversConfigurationId || appData.rivers_configuration_id,
24
23
  "x-applicaster-screen-id": screenId,
25
- "x-applicaster-language-code": getUILanguage(),
24
+ "x-applicaster-language-code": appData.languageCode,
26
25
  "x-applicaster-version-number": appData.version_name || appData.versionName,
27
26
  "x-applicaster-platform": (platform || appData.platform).toLowerCase(),
28
27
  "x-applicaster-country-code": appData.countryCode,
@@ -123,6 +123,12 @@ function getPlayerConfiguration({ platform, version }) {
123
123
  key: "skip_button_localization_text_skip_intro",
124
124
  initial_value: "Skip Intro",
125
125
  },
126
+ {
127
+ type: "text_input",
128
+ label: "Stream error message",
129
+ key: "stream_error_message",
130
+ initial_value: "Cannot play stream",
131
+ },
126
132
  {
127
133
  type: "text_input",
128
134
  label: "Locked message",
@@ -364,20 +370,6 @@ function getPlayerConfiguration({ platform, version }) {
364
370
  };
365
371
 
366
372
  if (isTV(platform)) {
367
- localizations.fields.push({
368
- key: "back_to_live_label",
369
- label: "Back to live label",
370
- initial_value: "Back To Live",
371
- type: "text_input",
372
- });
373
-
374
- localizations.fields.push({
375
- key: "start_over_label",
376
- label: "Start over label",
377
- initial_value: "Start Over",
378
- type: "text_input",
379
- });
380
-
381
373
  styles.fields.push(
382
374
  fieldsGroup("Always Show Scrub Bar & Timestamp", "", [
383
375
  {
@@ -490,7 +482,7 @@ function getPlayerConfiguration({ platform, version }) {
490
482
  ),
491
483
  fieldsGroup(
492
484
  "Skip Button",
493
- "This section allows you to configure the skip button behaviour",
485
+ "This section allows you to configure the skip button styles for tv",
494
486
  [
495
487
  {
496
488
  type: "switch",
@@ -507,12 +499,6 @@ function getPlayerConfiguration({ platform, version }) {
507
499
  label: "Persistent Button Toggle",
508
500
  initial_value: true,
509
501
  },
510
- ]
511
- ),
512
- fieldsGroup(
513
- "Labeled Button Style",
514
- "This section allows you to configure the labeled button styles",
515
- [
516
502
  {
517
503
  type: "color_picker_rgba",
518
504
  label_tooltip: "",
@@ -668,61 +654,7 @@ function getPlayerConfiguration({ platform, version }) {
668
654
  );
669
655
  }
670
656
 
671
- if (isTV(platform)) {
672
- general.fields.push(
673
- {
674
- key: "liveSeekingEnabled",
675
- label: "Live Seeking Enabled",
676
- initial_value: false,
677
- type: "switch",
678
- label_tooltip: "Enable Live Seek",
679
- },
680
- {
681
- key: "minimumAllowedSeekableDurationInSeconds",
682
- label: "Minimum allowed seekable duration in seconds",
683
- initial_value: 300,
684
- type: "number_input",
685
- label_tooltip:
686
- "If duration less than this value, player will disable 'liveSeekingEnabled' value",
687
- },
688
- {
689
- key: "live_image",
690
- label: "Live badge",
691
- type: "uploader",
692
- label_tooltip: "Override default live badge / icon",
693
- },
694
- {
695
- key: "live_width",
696
- label: "Live badge width",
697
- type: "number_input",
698
- initial_value: 85,
699
- },
700
- {
701
- key: "live_height",
702
- label: "Live badge height",
703
- type: "number_input",
704
- initial_value: 50,
705
- }
706
- );
707
- }
708
-
709
657
  if (isMobile(platform)) {
710
- localizations.fields.push(
711
- {
712
- type: "text_input",
713
- label: "Restrict playback on mobile networks alert title",
714
- key: "mobile_connection_restricted_alert_title",
715
- initial_value: "Restricted Connection Type",
716
- },
717
- {
718
- type: "text_input",
719
- label: "Restrict playback on mobile networks alert message",
720
- key: "mobile_connection_restricted_alert_message",
721
- initial_value:
722
- "This content can only be viewed over a Wi-Fi or LAN network.",
723
- }
724
- );
725
-
726
658
  general.fields.push(
727
659
  {
728
660
  section: "Default Timestamp Type",
@@ -43,6 +43,7 @@ const TV_PLATFORMS = [
43
43
  "tvos_for_quickbrick",
44
44
  "samsung_tv",
45
45
  "lg_tv",
46
+ "vidaa",
46
47
  "vizio",
47
48
  ];
48
49
 
@@ -0,0 +1,14 @@
1
+ function platformIsTV(platform) {
2
+ return [
3
+ "tvos_for_quickbrick",
4
+ "android_tv_for_quickbrick",
5
+ "amazon_fire_tv_for_quickbrick",
6
+ "lg_tv",
7
+ "vidaa",
8
+ "samsung_tv",
9
+ "web",
10
+ "vizio",
11
+ ].includes(platform);
12
+ }
13
+
14
+ module.exports = { platformIsTV };
@@ -38,7 +38,7 @@ function tvActionButtonsContainer({ label, description, defaults }) {
38
38
  generateFieldsFromDefaultsWithoutPrefixedLabel(
39
39
  label,
40
40
  defaults,
41
- tvActionButtonContainerFields(defaults.position)
41
+ tvActionButtonContainerFields(defaults["position"])
42
42
  )
43
43
  );
44
44
 
@@ -11,16 +11,6 @@ describe("toNumber", () => {
11
11
  });
12
12
  });
13
13
 
14
- it("return number if input is BigInt", () => {
15
- const inputs = [5n, -5n];
16
- expect.assertions(inputs.length);
17
-
18
- inputs.forEach((input) => {
19
- const output = toNumber(input);
20
- expect(output).toBe(Number(input));
21
- });
22
- });
23
-
24
14
  it("return number if input is string as number", () => {
25
15
  const inputs = ["-1", "0", "1", "100", "0.2"];
26
16
  expect.assertions(inputs.length);
@@ -42,8 +32,6 @@ describe("toNumber", () => {
42
32
  { test: 1 },
43
33
  [],
44
34
  [1],
45
- "5n",
46
- "-5n",
47
35
  ];
48
36
 
49
37
  expect.assertions(inputs.length);
@@ -8,7 +8,7 @@ export const toNumber = (value: unknown): number | undefined => {
8
8
  return undefined;
9
9
  }
10
10
 
11
- if (R.is(Number, value) || R.is(BigInt, value) || R.is(String, value)) {
11
+ if (R.is(Number, value) || R.is(String, value)) {
12
12
  const numberOrNan = Number(value);
13
13
 
14
14
  return Number.isNaN(numberOrNan) ? undefined : numberOrNan;
@@ -69,24 +69,6 @@ export const isMinusZero = (value: number) => {
69
69
  return 1 / value === -Infinity;
70
70
  };
71
71
 
72
- export const toPositiveNumber = (value: unknown): number | undefined => {
73
- const possibleNumber = toNumber(value);
74
-
75
- if (R.isNil(possibleNumber)) {
76
- return undefined;
77
- }
78
-
79
- if (possibleNumber < 0) {
80
- return undefined;
81
- }
82
-
83
- if (isZero(possibleNumber)) {
84
- return undefined;
85
- }
86
-
87
- return possibleNumber;
88
- };
89
-
90
72
  export const toPositiveNumberWithDefault = (
91
73
  defaultValue: number,
92
74
  value: unknown
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-utils",
3
- "version": "15.0.0-rc.98",
3
+ "version": "15.1.0-alpha.1852552014",
4
4
  "description": "Applicaster Zapp React Native utilities package",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -27,13 +27,13 @@
27
27
  },
28
28
  "homepage": "https://github.com/applicaster/quickbrick#readme",
29
29
  "dependencies": {
30
- "@applicaster/applicaster-types": "15.0.0-rc.98",
30
+ "@applicaster/applicaster-types": "15.1.0-alpha.1852552014",
31
31
  "buffer": "^5.2.1",
32
32
  "camelize": "^1.0.0",
33
33
  "dayjs": "^1.11.10",
34
- "handlebars": "4.7.8",
35
34
  "memoizee": "0.4.15",
36
- "prop-types": "^15.0.0"
35
+ "prop-types": "^15.0.0",
36
+ "react-native-handlebars": "^5.0.0-alpha.1"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "@applicaster/zapp-pipes-v2-client": "*",
@@ -0,0 +1,33 @@
1
+ import { buildUrlWithQuery } from "../withPipesEndpoint";
2
+
3
+ describe("buildUrlWithQuery", () => {
4
+ it("returns the url unchanged when requestParams is null", () => {
5
+ expect(buildUrlWithQuery("https://foo.com/path", null)).toBe(
6
+ "https://foo.com/path"
7
+ );
8
+ });
9
+
10
+ it("returns the url unchanged when requestParams has no params", () => {
11
+ expect(buildUrlWithQuery("https://foo.com/path", { headers: {} })).toBe(
12
+ "https://foo.com/path"
13
+ );
14
+ });
15
+
16
+ it("returns the url unchanged when url is empty", () => {
17
+ expect(buildUrlWithQuery("", { params: { a: "1" } })).toBe("");
18
+ });
19
+
20
+ it("appends params to a url with no existing query", () => {
21
+ expect(
22
+ buildUrlWithQuery("https://foo.com/path", { params: { token: "abc" } })
23
+ ).toBe("https://foo.com/path?token=abc");
24
+ });
25
+
26
+ it("merges params with an existing query string", () => {
27
+ expect(
28
+ buildUrlWithQuery("https://foo.com/path?existing=1", {
29
+ params: { token: "abc" },
30
+ })
31
+ ).toBe("https://foo.com/path?existing=1&token=abc");
32
+ });
33
+ });
@@ -0,0 +1,56 @@
1
+ import * as React from "react";
2
+ import { render } from "@testing-library/react-native";
3
+ import { Text } from "react-native";
4
+
5
+ const mockedUseBuildPipesUrl = jest.fn();
6
+
7
+ jest.mock("@applicaster/zapp-react-native-utils/reactHooks/feed", () => ({
8
+ useBuildPipesUrl: (args) => mockedUseBuildPipesUrl(args),
9
+ }));
10
+
11
+ const { withPipesEndpoint } = require("../withPipesEndpoint");
12
+
13
+ // eslint-disable-next-line react/display-name
14
+ const Wrapped = React.forwardRef((props: any, _ref) => (
15
+ <Text testID="wrapped">{`${props.uri}|${JSON.stringify(props.headers)}`}</Text>
16
+ ));
17
+
18
+ describe("withPipesEndpoint", () => {
19
+ afterEach(() => jest.clearAllMocks());
20
+
21
+ it("renders nothing while the endpoint context is resolving", () => {
22
+ mockedUseBuildPipesUrl.mockReturnValue({ requestParams: null });
23
+
24
+ const Decorated = withPipesEndpoint(Wrapped);
25
+ const { queryByTestId } = render(<Decorated uri="https://foo.com" />);
26
+
27
+ expect(queryByTestId("wrapped")).toBeNull();
28
+ });
29
+
30
+ it("passes the uri through unchanged when there are no params", () => {
31
+ mockedUseBuildPipesUrl.mockReturnValue({ requestParams: {} });
32
+
33
+ const Decorated = withPipesEndpoint(Wrapped);
34
+ const { getByTestId } = render(<Decorated uri="https://foo.com/path" />);
35
+
36
+ expect(getByTestId("wrapped").props.children).toBe(
37
+ "https://foo.com/path|{}"
38
+ );
39
+ });
40
+
41
+ it("merges resolved params into the uri and forwards headers", () => {
42
+ mockedUseBuildPipesUrl.mockReturnValue({
43
+ requestParams: {
44
+ params: { token: "abc" },
45
+ headers: { Authorization: "Bearer xyz" },
46
+ },
47
+ });
48
+
49
+ const Decorated = withPipesEndpoint(Wrapped);
50
+ const { getByTestId } = render(<Decorated uri="https://foo.com/path" />);
51
+
52
+ expect(getByTestId("wrapped").props.children).toBe(
53
+ 'https://foo.com/path?token=abc|{"Authorization":"Bearer xyz"}'
54
+ );
55
+ });
56
+ });
@@ -0,0 +1 @@
1
+ export { withPipesEndpoint, buildUrlWithQuery } from "./withPipesEndpoint";