@applicaster/zapp-react-native-utils 14.0.0-alpha.6242515303 → 14.0.0-alpha.6391068513

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 (53) hide show
  1. package/actionsExecutor/ActionExecutorContext.tsx +60 -83
  2. package/actionsExecutor/ScreenActions.ts +163 -0
  3. package/actionsExecutor/StorageActions.ts +110 -0
  4. package/actionsExecutor/feedDecorator.ts +171 -0
  5. package/actionsExecutor/screenResolver.ts +11 -0
  6. package/analyticsUtils/AnalyticsEvents/helper.ts +1 -1
  7. package/analyticsUtils/AnalyticsEvents/sendHeaderClickEvent.ts +1 -1
  8. package/analyticsUtils/AnalyticsEvents/sendMenuClickEvent.ts +2 -1
  9. package/analyticsUtils/index.tsx +3 -4
  10. package/analyticsUtils/manager.ts +1 -1
  11. package/appUtils/HooksManager/Hook.ts +4 -4
  12. package/appUtils/HooksManager/index.ts +11 -1
  13. package/appUtils/accessibilityManager/index.ts +3 -3
  14. package/appUtils/contextKeysManager/contextResolver.ts +14 -1
  15. package/appUtils/focusManager/treeDataStructure/Tree/index.js +1 -1
  16. package/arrayUtils/index.ts +1 -1
  17. package/componentsUtils/__tests__/isTabsScreen.test.ts +38 -0
  18. package/componentsUtils/index.ts +4 -1
  19. package/configurationUtils/__tests__/manifestKeyParser.test.ts +547 -0
  20. package/configurationUtils/manifestKeyParser.ts +57 -32
  21. package/index.d.ts +0 -9
  22. package/manifestUtils/defaultManifestConfigurations/player.js +0 -148
  23. package/manifestUtils/keys.js +0 -12
  24. package/manifestUtils/sharedConfiguration/screenPicker/stylesFields.js +0 -6
  25. package/navigationUtils/__tests__/mapContentTypesToRivers.test.ts +130 -0
  26. package/navigationUtils/index.ts +6 -4
  27. package/package.json +2 -2
  28. package/playerUtils/index.ts +51 -0
  29. package/reactHooks/autoscrolling/__tests__/useTrackedView.test.tsx +15 -14
  30. package/reactHooks/cell-click/index.ts +8 -1
  31. package/reactHooks/feed/__tests__/useBatchLoading.test.tsx +39 -88
  32. package/reactHooks/feed/__tests__/useFeedLoader.test.tsx +20 -0
  33. package/reactHooks/feed/useBatchLoading.ts +8 -6
  34. package/reactHooks/feed/useFeedLoader.tsx +25 -12
  35. package/reactHooks/feed/usePipesCacheReset.ts +2 -2
  36. package/reactHooks/flatList/useSequentialRenderItem.tsx +3 -3
  37. package/reactHooks/layout/__tests__/index.test.tsx +3 -1
  38. package/reactHooks/layout/isTablet/index.ts +7 -3
  39. package/reactHooks/layout/useDimensions/__tests__/useDimensions.test.ts +34 -36
  40. package/reactHooks/layout/useDimensions/useDimensions.ts +2 -3
  41. package/reactHooks/layout/useLayoutVersion.ts +5 -5
  42. package/reactHooks/navigation/index.ts +7 -5
  43. package/reactHooks/navigation/useRoute.ts +7 -2
  44. package/reactHooks/navigation/useScreenStateStore.ts +8 -0
  45. package/reactHooks/resolvers/__tests__/useCellResolver.test.tsx +4 -0
  46. package/reactHooks/state/useRivers.ts +7 -8
  47. package/storage/ScreenSingleValueProvider.ts +201 -0
  48. package/storage/ScreenStateMultiSelectProvider.ts +290 -0
  49. package/storage/StorageMultiSelectProvider.ts +192 -0
  50. package/storage/StorageSingleSelectProvider.ts +108 -0
  51. package/testUtils/index.tsx +7 -8
  52. package/time/BackgroundTimer.ts +1 -1
  53. package/utils/index.ts +1 -0
@@ -351,86 +351,6 @@ function getPlayerConfiguration({ platform, version }) {
351
351
  ],
352
352
  },
353
353
  ]),
354
- fieldsGroup(
355
- "Partial Player (Roku only)",
356
- "This section allows you to configure width and height of video player in Partial Player",
357
- [
358
- {
359
- key: "video_theater_width",
360
- label: "Width of player",
361
- type: "number_input",
362
- initial_value: "1420",
363
- placeHolder: "1420",
364
- },
365
- {
366
- key: "video_theater_height",
367
- label: "Height of player",
368
- type: "number_input",
369
- initial_value: "900",
370
- placeHolder: "900",
371
- },
372
- {
373
- key: "full_screen_button_offset_x",
374
- label: "Fullscreen button X",
375
- type: "number_input",
376
- initial_value: 160,
377
- placeHolder: "160",
378
- },
379
- {
380
- key: "full_screen_button_offset_y",
381
- label: "Fullscreen button Y",
382
- type: "number_input",
383
- initial_value: 160,
384
- placeHolder: "160",
385
- },
386
- {
387
- key: "full_screen_button_w",
388
- label: "Fullscreen button width",
389
- type: "number_input",
390
- initial_value: 120,
391
- placeHolder: "120",
392
- },
393
- {
394
- key: "full_screen_button_h",
395
- label: "Fullscreen button height",
396
- type: "number_input",
397
- initial_value: 120,
398
- placeHolder: "120",
399
- },
400
- {
401
- key: "full_screen_button_background_color",
402
- type: "color_picker",
403
- label: "Fullscreen Button background color",
404
- initial_value: "#00000000",
405
- placeHolder: "color",
406
- label_tooltip: "Pick Color",
407
- },
408
- {
409
- key: "full_screen_button_background_url",
410
- type: "text_input",
411
- label: "Fullscreen Button background Url",
412
- initial_value: "pkg:/images/tv_fullscreen.png",
413
- placeHolder: "",
414
- label_tooltip: "",
415
- },
416
- {
417
- key: "full_screen_button_highlighted_background_color",
418
- type: "color_picker",
419
- label: "Fullscreen Button highlighted background color",
420
- initial_value: "#00000000",
421
- placeHolder: "color",
422
- label_tooltip: "Pick Color",
423
- },
424
- {
425
- key: "full_screen_button_highlighted_background_url",
426
- type: "text_input",
427
- label: "Fullscreen Button highlighted Url",
428
- initial_value: "pkg:/images/tv_fullscreen.png",
429
- placeHolder: "",
430
- label_tooltip: "",
431
- },
432
- ]
433
- ),
434
354
  fieldsGroup(
435
355
  "Skip Button",
436
356
  "This section allows you to configure the skip button styles for tv",
@@ -562,20 +482,6 @@ function getPlayerConfiguration({ platform, version }) {
562
482
  key: "skip_button_style_text_android_font_size",
563
483
  initial_value: 24,
564
484
  },
565
- {
566
- type: "roku_font_selector",
567
- label_tooltip: "",
568
- label: "Android Font Family",
569
- key: "skip_button_style_text_roku_font_family",
570
- initial_value: "Ubuntu-Bold",
571
- },
572
- {
573
- type: "number_input",
574
- label_tooltip: "",
575
- label: "Roku Font Size",
576
- key: "skip_button_style_text_roku_font_size",
577
- initial_value: 24,
578
- },
579
485
  {
580
486
  type: "select",
581
487
  options: [
@@ -3424,60 +3330,6 @@ function getPlayerConfiguration({ platform, version }) {
3424
3330
  },
3425
3331
  ]
3426
3332
  ),
3427
- fieldsGroup(
3428
- "Roku only",
3429
- "This section allows you to configure RAF - Roku Ad Framework settings",
3430
- [
3431
- {
3432
- key: "raf_enabled",
3433
- type: "switch",
3434
- initial_value: false,
3435
- },
3436
- {
3437
- key: "raf_url",
3438
- type: "text_input",
3439
- label: "Ad Url",
3440
- label_tooltip:
3441
- "Publisher's ad URL. The default is he roku ad server with single preroll placeholder, with revenue spilt ad sharing by default. TO GET PAID A URL MUST BE PASSED IN HERE. Note: If you are putting ads in child targetted content then your ad url will have to use the ROKU_ADS_KIDS_CONTENT macro value, as per the docs here: developer.roku.com/docs/developer-program/advertising/integrating-roku-advertising-framework.md#url-parameter-macros",
3442
- },
3443
- {
3444
- key: "genre",
3445
- type: "text_input",
3446
- label: "Roku Genre",
3447
- initial_value: "Entertainment",
3448
- label_tooltip:
3449
- "Choose value from Roku genre tags, from developer.roku.com/en-gb/docs/developer-program/advertising/integrating-roku-advertising-framework.md",
3450
- },
3451
- {
3452
- key: "nielsen_enabled",
3453
- type: "checkbox",
3454
- initial_value: false,
3455
- label_tooltip:
3456
- "Required only for apps launched in the US market, See developer.roku.com/en-gb/docs/developer-program/advertising/integrating-roku-advertising-framework.md for details on configuration",
3457
- },
3458
- {
3459
- key: "nielsen_app_id",
3460
- type: "text_input",
3461
- initial_value: "",
3462
- label_tooltip:
3463
- "id of your app for nielsen leave blank if you don't have a specific id (that is almost always the case)",
3464
- },
3465
- {
3466
- key: "nielsen_genre",
3467
- type: "text_input",
3468
- initial_value: "General",
3469
- label_tooltip:
3470
- "genre from developer.roku.com/en-gb/docs/developer-program/advertising/integrating-roku-advertising-framework.md#nielsen-dar-genre-tags",
3471
- },
3472
- {
3473
- key: "is_kids_content",
3474
- type: "checkbox",
3475
- initial_value: false,
3476
- label_tooltip:
3477
- "If your content is directed at kids, this must be checked. See developer.roku.com/docs/developer-program/advertising/raf-api.md#setcontentgenregenres-as-string-kidscontent-as-boolean for more info. Also note your ad urls will have to use the ROKU_ADS_KIDS_CONTENT macro value, as per the docs here: developer.roku.com/docs/developer-program/advertising/integrating-roku-advertising-framework.md#url-parameter-macros",
3478
- },
3479
- ]
3480
- ),
3481
3333
  fieldsGroup(
3482
3334
  "Audio Tracks",
3483
3335
  "This section allows you to configure default audio track behavior for videos with multiple audio tracks",
@@ -485,18 +485,6 @@ const TV_MENU_LABEL_FIELDS = [
485
485
  type: ZAPPIFEST_FIELDS.number_input,
486
486
  suffix: "LG letter spacing",
487
487
  },
488
- {
489
- type: ZAPPIFEST_FIELDS.font_selector.roku,
490
- suffix: "Roku font family",
491
- },
492
- {
493
- type: ZAPPIFEST_FIELDS.number_input,
494
- suffix: "Roku font size",
495
- },
496
- {
497
- type: ZAPPIFEST_FIELDS.number_input,
498
- suffix: "Roku line height",
499
- },
500
488
  {
501
489
  type: ZAPPIFEST_FIELDS.select,
502
490
  suffix: "text transform",
@@ -424,12 +424,6 @@ const titleFields = [
424
424
  key: "vizio_font_family",
425
425
  initial_value: fontFamily,
426
426
  },
427
- {
428
- type: "roku_font_selector",
429
- label: "Roku TV Font Family",
430
- key: "roku_font_family",
431
- initial_value: fontFamily,
432
- },
433
427
  ...generateFontConfiguration(),
434
428
  // text transform
435
429
  {
@@ -0,0 +1,130 @@
1
+ import { mapContentTypesToRivers } from "../index";
2
+
3
+ describe("mapContentTypesToRivers", () => {
4
+ it("should return the correct content types mapped to rivers", () => {
5
+ const state = {
6
+ rivers: {
7
+ "river-1": {
8
+ plugin_type: "river",
9
+ },
10
+ },
11
+ contentTypes: {
12
+ "content-type-1": {
13
+ screen_id: "river-1",
14
+ },
15
+ },
16
+ };
17
+
18
+ const result = mapContentTypesToRivers(state);
19
+
20
+ expect(result).toEqual({
21
+ "content-type-1": {
22
+ screenType: "river",
23
+ screen_id: "river-1",
24
+ },
25
+ });
26
+ });
27
+
28
+ it("should return null if contentTypes is undefined", () => {
29
+ const state = {
30
+ rivers: {
31
+ "river-1": {
32
+ plugin_type: "river",
33
+ },
34
+ },
35
+ // contentTypes is missing
36
+ };
37
+
38
+ const result = mapContentTypesToRivers(state);
39
+
40
+ expect(result).toBeNull();
41
+ });
42
+
43
+ it("should skip content types whose screen does not exist in rivers", () => {
44
+ const state = {
45
+ rivers: {
46
+ "river-1": {
47
+ plugin_type: "river",
48
+ },
49
+ },
50
+ contentTypes: {
51
+ "content-type-1": {
52
+ screen_id: "river-1",
53
+ },
54
+ "content-type-2": {
55
+ screen_id: "river-2", // river-2 does not exist
56
+ },
57
+ },
58
+ };
59
+
60
+ const result = mapContentTypesToRivers(state);
61
+
62
+ expect(result).toEqual({
63
+ "content-type-1": {
64
+ screenType: "river",
65
+ screen_id: "river-1",
66
+ },
67
+ });
68
+
69
+ // result is not null, but may be undefined for missing keys
70
+ expect(result && result["content-type-2"]).toBeUndefined();
71
+ });
72
+
73
+ it("should use 'type' if 'plugin_type' is not present in river", () => {
74
+ const state = {
75
+ rivers: {
76
+ "river-1": {
77
+ type: "custom-type",
78
+ },
79
+ },
80
+ contentTypes: {
81
+ "content-type-1": {
82
+ screen_id: "river-1",
83
+ },
84
+ },
85
+ };
86
+
87
+ const result = mapContentTypesToRivers(state);
88
+
89
+ expect(result).toEqual({
90
+ "content-type-1": {
91
+ screenType: "custom-type",
92
+ screen_id: "river-1",
93
+ },
94
+ });
95
+ });
96
+
97
+ it("should skip content types if neither plugin_type nor type is present in river", () => {
98
+ const state = {
99
+ rivers: {
100
+ "river-1": {
101
+ // no plugin_type or type
102
+ },
103
+ },
104
+ contentTypes: {
105
+ "content-type-1": {
106
+ screen_id: "river-1",
107
+ },
108
+ },
109
+ };
110
+
111
+ const result = mapContentTypesToRivers(state);
112
+
113
+ expect(result).toEqual({});
114
+ });
115
+
116
+ it("should handle empty contentTypes object", () => {
117
+ const state = {
118
+ rivers: {
119
+ "river-1": {
120
+ plugin_type: "river",
121
+ },
122
+ },
123
+ contentTypes: {},
124
+ };
125
+
126
+ const result = mapContentTypesToRivers(state);
127
+
128
+ expect(result).toEqual({});
129
+ });
130
+ });
@@ -13,6 +13,7 @@ import {
13
13
  isPlayable,
14
14
  isV2River,
15
15
  } from "./itemTypeMatchers";
16
+ import { RootState } from "@applicaster/zapp-react-native-redux/store";
16
17
 
17
18
  type PathAttribute = {
18
19
  screenType: string;
@@ -377,10 +378,11 @@ export const usesVideoModal = (
377
378
  return targetScreenConfiguration?.styles?.use_video_modal;
378
379
  };
379
380
 
380
- export const mapContentTypesToRivers = ({
381
- rivers,
382
- contentTypes,
383
- }): ZappContentTypesMapped | null => {
381
+ export const mapContentTypesToRivers = (
382
+ state: Partial<RootState>
383
+ ): ZappContentTypesMapped | null => {
384
+ const { rivers, contentTypes } = state;
385
+
384
386
  if (!contentTypes) {
385
387
  return null;
386
388
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-utils",
3
- "version": "14.0.0-alpha.6242515303",
3
+ "version": "14.0.0-alpha.6391068513",
4
4
  "description": "Applicaster Zapp React Native utilities package",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "homepage": "https://github.com/applicaster/quickbrick#readme",
29
29
  "dependencies": {
30
- "@applicaster/applicaster-types": "14.0.0-alpha.6242515303",
30
+ "@applicaster/applicaster-types": "14.0.0-alpha.6391068513",
31
31
  "buffer": "^5.2.1",
32
32
  "camelize": "^1.0.0",
33
33
  "dayjs": "^1.11.10",
@@ -5,6 +5,7 @@ import { isFilledArray } from "@applicaster/zapp-react-native-utils/arrayUtils";
5
5
  import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
6
6
 
7
7
  import { getBoolFromConfigValue } from "../configurationUtils";
8
+ import { Dimensions } from "react-native";
8
9
 
9
10
  export { getPlayerActionButtons } from "./getPlayerActionButtons";
10
11
 
@@ -97,3 +98,53 @@ export const isAudioItem = (item: Option<ZappEntry>) => {
97
98
  export const isInlineTV = (screenData) => {
98
99
  return isTV() && isFilledArray(screenData?.ui_components);
99
100
  };
101
+
102
+ const isPercentage = (value: string | number): boolean => {
103
+ if (typeof value === "string") {
104
+ return value.includes("%");
105
+ }
106
+
107
+ return false;
108
+ };
109
+
110
+ const getPercentageOf = (percent: string, value: number) => {
111
+ const percentageValue = parseFloat(percent.replace("%", ""));
112
+
113
+ if (isNaN(percentageValue)) {
114
+ return value;
115
+ }
116
+
117
+ return (value * percentageValue) / 100;
118
+ };
119
+
120
+ type DimensionsT = {
121
+ width: number | string;
122
+ height: number | string | undefined;
123
+ aspectRatio?: number;
124
+ };
125
+
126
+ export const getTabletWidth = (
127
+ tablet_landscape_sidebar_width,
128
+ dimensions: DimensionsT
129
+ ) => {
130
+ const { width: SCREEN_WIDTH } = Dimensions.get("screen");
131
+
132
+ const { width } = dimensions;
133
+ let widthValue = Number(width);
134
+
135
+ if (isPercentage(width)) {
136
+ widthValue = getPercentageOf(width.toString(), SCREEN_WIDTH);
137
+ }
138
+
139
+ const sidebarWidth = Number(tablet_landscape_sidebar_width?.replace("%", ""));
140
+
141
+ if (tablet_landscape_sidebar_width?.includes("%")) {
142
+ return widthValue * (1 - sidebarWidth / 100);
143
+ }
144
+
145
+ if (Number.isNaN(sidebarWidth)) {
146
+ return widthValue * 0.65;
147
+ }
148
+
149
+ return widthValue - sidebarWidth;
150
+ };
@@ -1,27 +1,31 @@
1
1
  import React from "react";
2
2
 
3
- import { act, renderHook } from "@testing-library/react-hooks";
3
+ import { renderHook } from "@testing-library/react-hooks";
4
+ import { act, waitFor } from "@testing-library/react-native";
4
5
  import { Provider } from "react-redux";
5
6
  import configureStore from "redux-mock-store";
7
+ import { useTrackedView } from "../useTrackedView";
6
8
 
7
9
  const mockUpdateComponentsPositions = jest.fn();
8
10
 
9
11
  jest.mock(
10
12
  "@applicaster/zapp-react-native-ui-components/Contexts/ScreenTrackedViewPositionsContext",
11
13
  () => ({
12
- useScreenTrackedViewPositionsContext: jest.fn().mockReturnValue({
14
+ useScreenTrackedViewPositionsContext: jest.fn(() => ({
13
15
  updateComponentsPositions: mockUpdateComponentsPositions,
14
16
  value: {
15
17
  "123": { componentId: "123", centerX: 0.4, centerY: 0.5 },
16
18
  "124": { componentId: "124", centerX: 0.2, centerY: 0.3 },
17
19
  },
18
- }),
20
+ })),
19
21
  })
20
22
  );
21
23
 
22
- jest.useFakeTimers({ legacyFakeTimers: true });
24
+ jest.useFakeTimers();
23
25
 
24
- jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation");
26
+ jest.mock(
27
+ "@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation"
28
+ );
25
29
 
26
30
  const mockStore = configureStore();
27
31
 
@@ -32,10 +36,8 @@ const Wrapper = ({ children }: { children: React.ReactChild }) => (
32
36
  <Provider store={store}>{children}</Provider>
33
37
  );
34
38
 
35
- const { useTrackedView } = require("../useTrackedView");
36
-
37
39
  describe("useTrackCurrentAutoScrollingElement", () => {
38
- it("should update position for selected component - onViewportEnter", () => {
40
+ it("should update position for selected component - onViewportEnter", async () => {
39
41
  const { result } = renderHook(() => useTrackedView("123"), {
40
42
  wrapper: Wrapper,
41
43
  });
@@ -46,14 +48,13 @@ describe("useTrackCurrentAutoScrollingElement", () => {
46
48
  rect: { left: 1, right: 1, top: 1, bottom: 1 },
47
49
  };
48
50
 
49
- act(async () => {
50
- await result.current.onPositionUpdated(mockRect);
51
+ act(() => {
52
+ result.current.onPositionUpdated(mockRect);
51
53
  });
52
54
 
53
- // Fast-forward until all timers have been executed
54
- jest.runAllTimers();
55
-
56
- expect(result.current.inViewPort).toBe(true);
55
+ await waitFor(() => {
56
+ expect(result.current.inViewPort).toBe(true);
57
+ });
57
58
 
58
59
  expect(mockUpdateComponentsPositions).toHaveBeenCalledWith(
59
60
  "123",
@@ -16,7 +16,8 @@ import { ActionExecutorContext } from "@applicaster/zapp-react-native-utils/acti
16
16
  import { isFunction, noop } from "../../functionUtils";
17
17
  import { useSendAnalyticsOnPress } from "../analytics";
18
18
  import { logOnPress, warnEmptyContentType } from "./helpers";
19
- import { useCurrentScreenData } from "../screen";
19
+ import { useCurrentScreenData, useScreenContext } from "../screen";
20
+ import { useScreenStateStore } from "../navigation/useScreenStateStore";
20
21
 
21
22
  /**
22
23
  * If onCellTap is defined execute the function and
@@ -42,10 +43,12 @@ export const useCellClick = ({
42
43
  }: Props): onPressReturnFn => {
43
44
  const { push, currentRoute } = useNavigation();
44
45
  const { pathname } = useRoute();
46
+ const screenStateStore = useScreenStateStore();
45
47
 
46
48
  const onCellTap: Option<Function> = React.useContext(CellTapContext);
47
49
  const actionExecutor = React.useContext(ActionExecutorContext);
48
50
  const screenData = useCurrentScreenData();
51
+ const screenState = useScreenContext()?.options;
49
52
 
50
53
  const cellSelectable = toBooleanWithDefaultTrue(
51
54
  component?.rules?.component_cells_selectable
@@ -83,6 +86,9 @@ export const useCellClick = ({
83
86
  await actionExecutor?.handleEntryActions(selectedItem, {
84
87
  component,
85
88
  screenData,
89
+ screenState,
90
+ screenRoute: pathname,
91
+ screenStateStore,
86
92
  });
87
93
  }
88
94
 
@@ -117,6 +123,7 @@ export const useCellClick = ({
117
123
  push,
118
124
  sendAnalyticsOnPress,
119
125
  screenData,
126
+ screenState,
120
127
  ]
121
128
  );
122
129