@applicaster/zapp-react-native-ui-components 16.0.0-rc.99 → 17.0.0-alpha.1102403272

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 (112) hide show
  1. package/Components/AudioPlayer/index.web.tsx +10 -0
  2. package/Components/Cell/PlatformCellComponent.ts +9 -0
  3. package/Components/Cell/PlatformCellComponent.web.ts +3 -0
  4. package/Components/Cell/index.js +2 -9
  5. package/Components/CellRendererResolver/index.ts +22 -3
  6. package/Components/ComponentResolver/ComponentResolver.ts +6 -2
  7. package/Components/ComponentResolver/__tests__/componentResolver.test.js +13 -5
  8. package/Components/ContentScreen/index.js +2 -2
  9. package/Components/Focusable/index.web.tsx +3 -0
  10. package/Components/FocusableList/hooks/useCheckItemIdsForUnique.ts +2 -7
  11. package/Components/GeneralContentScreen/GeneralContentScreen.tsx +1 -1
  12. package/Components/GeneralContentScreen/hookAdapter/logger.ts +1 -1
  13. package/Components/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +158 -1
  14. package/Components/GeneralContentScreen/utils/index.ts +2 -2
  15. package/Components/GeneralContentScreen/utils/logger.ts +3 -4
  16. package/Components/GeneralContentScreen/utils/useCurationAPI.ts +32 -10
  17. package/Components/HandlePlayable/utils.ts +2 -7
  18. package/Components/HookRenderer/HookRenderer.tsx +2 -2
  19. package/Components/MasterCell/DefaultComponents/ActionButton.tsx +42 -4
  20. package/Components/MasterCell/DefaultComponents/ButtonContainerView/index.android.tv.tsx +7 -4
  21. package/Components/MasterCell/DefaultComponents/ButtonContainerView/types.ts +1 -0
  22. package/Components/MasterCell/DefaultComponents/FocusableView/index.android.tsx +10 -4
  23. package/Components/MasterCell/DefaultComponents/Image/hoc/utils/__tests__/withDimensions.test.ts +1 -1
  24. package/Components/MasterCell/DefaultComponents/Image/hoc/utils/index.ts +2 -4
  25. package/Components/MasterCell/DefaultComponents/Image/hooks/checkTooBigImageSize.ts +2 -7
  26. package/Components/MasterCell/DefaultComponents/Image/index.web.ts +7 -0
  27. package/Components/MasterCell/DefaultComponents/LiveImage/__tests__/prepareEntry.test.ts +30 -0
  28. package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +34 -7
  29. package/Components/MasterCell/DefaultComponents/PressableView.tsx +3 -0
  30. package/Components/MasterCell/DefaultComponents/Text/hooks/useText.ts +2 -7
  31. package/Components/MasterCell/DefaultComponents/__tests__/ActionButton.missingPlugin.test.tsx +66 -0
  32. package/Components/MasterCell/DefaultComponents/__tests__/ActionButton.test.tsx +288 -0
  33. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/ActionButton.tsx +2 -1
  34. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/PressableView.test.tsx +4 -2
  35. package/Components/MasterCell/SharedUI/CollapsibleTextContainer/__tests__/factory.test.ts +2 -2
  36. package/Components/MasterCell/SharedUI/CollapsibleTextContainer/index.ts +2 -1
  37. package/Components/MasterCell/__tests__/masterCell.test.js +116 -0
  38. package/Components/MasterCell/index.tsx +45 -6
  39. package/Components/MasterCell/logger.ts +2 -2
  40. package/Components/MasterCell/utils/__tests__/getFocusableElementId.test.ts +38 -0
  41. package/Components/MasterCell/utils/__tests__/useIsCellSelected.test.ts +91 -0
  42. package/Components/MasterCell/utils/__tests__/withoutFocusedState.test.js +20 -0
  43. package/Components/MasterCell/utils/behaviorProvider.ts +57 -38
  44. package/Components/MasterCell/utils/index.ts +60 -19
  45. package/Components/ModalComponent/ActionsBottomSheet/openActionsBottomSheet.ts +1 -1
  46. package/Components/ModalComponent/AudioPlayer/Components/Button.tsx +7 -3
  47. package/Components/ModalComponent/AudioPlayer/Components/Item.tsx +22 -1
  48. package/Components/ModalComponent/AudioPlayer/Components/__tests__/Item.test.tsx +52 -1
  49. package/Components/ModalComponent/AudioPlayer/utils/__tests__/mergeStyles.test.ts +77 -0
  50. package/Components/ModalComponent/AudioPlayer/utils/mergeStyles.ts +58 -16
  51. package/Components/ModalComponent/BottomSheetDragArea.web.tsx +15 -0
  52. package/Components/ModalComponent/BottomSheetModalContent.tsx +51 -82
  53. package/Components/ModalComponent/Button/index.tsx +3 -1
  54. package/Components/ModalComponent/SortableList.tsx +2 -3
  55. package/Components/ModalComponent/__tests__/BottomSheetDragArea.test.tsx +30 -0
  56. package/Components/ModalComponent/__tests__/BottomSheetModalContent.test.tsx +237 -17
  57. package/Components/ModalComponent/__tests__/showTextInput.test.ts +25 -0
  58. package/Components/ModalComponent/presets/__tests__/getCell.test.ts +29 -2
  59. package/Components/ModalComponent/presets/index.ts +2 -3
  60. package/Components/ModalComponent/showTextInput.ts +2 -0
  61. package/Components/OfflineHandler/__tests__/index.test.tsx +136 -0
  62. package/Components/OfflineHandler/index.tsx +45 -6
  63. package/Components/PlayerContainer/PlayerContainer.tsx +30 -6
  64. package/Components/PlayerContainer/__tests__/PlayerContainer.test.tsx +51 -0
  65. package/Components/PlayerContainer/logger.ts +9 -5
  66. package/Components/River/ComponentsMap/ComponentsMap.tsx +4 -1
  67. package/Components/River/ComponentsMap/index.web.tsx +3 -0
  68. package/Components/River/RiverItem.tsx +4 -0
  69. package/Components/River/TV/River.tsx +7 -1
  70. package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +2 -0
  71. package/Components/ScreenFeedLoader/ScreenFeedLoader.tsx +2 -2
  72. package/Components/ScreenResolver/index.tsx +6 -4
  73. package/Components/Tabs/TV/index.web.tsx +5 -0
  74. package/Components/TopCutoffOverlay/__tests__/TopCutoffOverlay.test.tsx +56 -10
  75. package/Components/TopCutoffOverlay/index.tsx +41 -10
  76. package/Components/Transitioner/AnimationManager.js +1 -1
  77. package/Components/Transitioner/Scene.tsx +4 -3
  78. package/Components/Transitioner/Transitioner.tsx +71 -33
  79. package/Components/Transitioner/__tests__/transitioner.test.js +372 -3
  80. package/Components/VideoLive/LiveImageManager.ts +126 -12
  81. package/Components/VideoLive/MuteUnmuteController.ts +135 -0
  82. package/Components/VideoLive/PlayerLiveImageComponent.tsx +15 -19
  83. package/Components/VideoLive/__tests__/LiveImageManager.test.ts +30 -0
  84. package/Components/VideoLive/__tests__/LiveImageMuteState.test.ts +311 -0
  85. package/Components/VideoLive/__tests__/MuteUnmuteController.test.ts +135 -0
  86. package/Components/VideoLive/__tests__/PlayerLiveImageComponent.test.tsx +63 -1
  87. package/Components/VideoLive/loggerHelper.ts +2 -2
  88. package/Components/VideoModal/PlayerDetails.tsx +27 -2
  89. package/Components/VideoModal/PlayerWrapper.tsx +9 -2
  90. package/Components/VideoModal/__tests__/PlayerDetails.test.tsx +84 -0
  91. package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +1 -0
  92. package/Components/VideoModal/__tests__/playerWrapperStyle.test.ts +263 -0
  93. package/Components/VideoModal/__tests__/playerWrapperUtils.test.ts +125 -0
  94. package/Components/VideoModal/hooks/useModalSize.ts +2 -7
  95. package/Components/VideoModal/playerWrapperStyle.ts +62 -23
  96. package/Components/VideoModal/playerWrapperUtils.ts +141 -1
  97. package/Components/__tests__/webVariants.test.js +73 -0
  98. package/Components/default-cell-renderer/containerStyles/index.web.ts +6 -0
  99. package/Components/default-cell-renderer/viewTrees/index.web.ts +10 -0
  100. package/Contexts/ZappPipesContext/ZappPipesContextFactory.tsx +3 -5
  101. package/Decorators/RiverResolver/__tests__/riverResolver.missingRiver.test.tsx +52 -0
  102. package/Decorators/RiverResolver/index.tsx +25 -0
  103. package/Decorators/ZappPipesDataConnector/__tests__/UrlFeedResolver.test.tsx +4 -3
  104. package/Decorators/ZappPipesDataConnector/__tests__/screenToolbox.test.ts +347 -0
  105. package/Decorators/ZappPipesDataConnector/__tests__/screenToolboxUnavailable.test.ts +53 -0
  106. package/Decorators/ZappPipesDataConnector/index.tsx +19 -4
  107. package/Decorators/ZappPipesDataConnector/resolvers/UrlFeedResolver.tsx +2 -21
  108. package/Decorators/ZappPipesDataConnector/screenToolbox.ts +384 -0
  109. package/Decorators/ZappPipesDataConnector/utils/mongoFilter.ts +1 -1
  110. package/Decorators/ZappPipesDataConnector/utils/useFilter.tsx +1 -1
  111. package/Helpers/logger.js +2 -2
  112. package/package.json +5 -5
@@ -0,0 +1,10 @@
1
+ import * as React from "react";
2
+
3
+ import { AudioPlayerTV } from "./tv";
4
+
5
+ import { Props } from "./types";
6
+
7
+ // isTV() is true on every web platform, so web builds always render the TV audio player and leave the mobile one out.
8
+ export function AudioPlayer(props: Props) {
9
+ return <AudioPlayerTV {...props} />;
10
+ }
@@ -0,0 +1,9 @@
1
+ import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
2
+
3
+ import { CellComponent } from "./Cell";
4
+ import { TvOSCellComponent } from "./TvOSCellComponent";
5
+
6
+ export const PlatformCellComponent = platformSelect({
7
+ tvos: TvOSCellComponent,
8
+ default: CellComponent,
9
+ });
@@ -0,0 +1,3 @@
1
+ // Web builds always select the default cell, so the tvOS one stays out of web
2
+ // bundles.
3
+ export { CellComponent as PlatformCellComponent } from "./Cell";
@@ -1,7 +1,6 @@
1
1
  import * as R from "ramda";
2
2
 
3
3
  import { connectToStore } from "@applicaster/zapp-react-native-redux/utils/connectToStore";
4
- import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
5
4
 
6
5
  import {
7
6
  HorizontalScrollContext,
@@ -9,8 +8,7 @@ import {
9
8
  ScreenScrollingContext,
10
9
  } from "../../Contexts";
11
10
 
12
- import { CellComponent } from "./Cell";
13
- import { TvOSCellComponent } from "./TvOSCellComponent";
11
+ import { PlatformCellComponent } from "./PlatformCellComponent";
14
12
  import { withConsumer } from "../../Contexts/HeaderOffsetContext";
15
13
 
16
14
  import { ScreenLayoutContextConsumer } from "../../Contexts/ScreenLayoutContext";
@@ -23,11 +21,6 @@ export const ScrollInterceptorContext = createContext(
23
21
  (_) => _
24
22
  );
25
23
 
26
- const Component = platformSelect({
27
- tvos: TvOSCellComponent,
28
- default: CellComponent,
29
- });
30
-
31
24
  export const Cell = R.compose(
32
25
  connectToStore(R.pick(["remoteConfigurations", "appData"])),
33
26
  ScrollInterceptorContext.withConsumer,
@@ -37,4 +30,4 @@ export const Cell = R.compose(
37
30
  withConsumer,
38
31
  ScreenLayoutContextConsumer,
39
32
  withComponentsMapOffsetContextConsumer
40
- )(Component);
33
+ )(PlatformCellComponent);
@@ -1,8 +1,8 @@
1
1
  import { findPluginByIdentifier } from "@applicaster/zapp-react-native-utils/pluginUtils";
2
2
  import { isGroup } from "@applicaster/zapp-react-native-utils/componentsUtils";
3
3
 
4
- import { componentsLogger } from "../../Helpers/logger";
5
4
  import defaultCellRenderer from "../default-cell-renderer";
5
+ import { subsystemLogger } from "@applicaster/zapp-react-native-utils/logger";
6
6
 
7
7
  type Props = {
8
8
  component: any;
@@ -13,7 +13,7 @@ type Props = {
13
13
  generateId?: () => string;
14
14
  };
15
15
 
16
- const logger = componentsLogger.addSubsystem("CellRendererResolver");
16
+ const logger = subsystemLogger("ui/cells", "CellRendererResolver");
17
17
 
18
18
  /**
19
19
  * Checks the matching cellPluginConfigurationId in the cellStyles redux store
@@ -82,9 +82,28 @@ export function CellRendererResolver({
82
82
  const cellRendererPlugin = getRendererPlugin(component, plugins, cellStyles);
83
83
 
84
84
  if (!cellRendererPlugin && !isGroup(component)) {
85
+ const cellStyleId = component?.styles?.cell_plugin_configuration_id;
86
+
85
87
  logger.warning({
86
88
  message: `Could not resolve cell builder plugin: ${component?.component_type}`,
87
- data: { component },
89
+ data: {
90
+ // For X-Ray diagnostics: keep when the message is reworded. Only for a component that
91
+ // takes a cell style (the key is in its styles) and once cell styles are loaded.
92
+ ...(component?.id &&
93
+ cellStyles &&
94
+ "cell_plugin_configuration_id" in (component.styles ?? {}) && {
95
+ diagnostic: {
96
+ code: "cell-style",
97
+ case: !cellStyleId
98
+ ? "not_chosen"
99
+ : !cellStyles[cellStyleId]
100
+ ? "deleted"
101
+ : "plugin_missing",
102
+ },
103
+ plugin_id: cellStyles[cellStyleId]?.plugin_identifier,
104
+ }),
105
+ component,
106
+ },
88
107
  });
89
108
  }
90
109
 
@@ -4,7 +4,7 @@ import { useIsRTL } from "@applicaster/zapp-react-native-utils/localizationUtils
4
4
 
5
5
  import { CellRendererResolver } from "../CellRendererResolver";
6
6
 
7
- import { componentsLogger } from "../../Helpers/logger";
7
+ import { subsystemLogger } from "@applicaster/zapp-react-native-utils/logger";
8
8
 
9
9
  type Decorator = (arg: React.ComponentType<any>) => React.ComponentType<any>;
10
10
 
@@ -18,7 +18,7 @@ type Props = {
18
18
  cellStyles: any;
19
19
  };
20
20
 
21
- const logger = componentsLogger.addSubsystem("ComponentResolver");
21
+ const logger = subsystemLogger("ui/components", "ComponentResolver");
22
22
 
23
23
  export function ComponentResolver({
24
24
  component,
@@ -59,6 +59,10 @@ export function ComponentResolver({
59
59
  if (!Component) {
60
60
  logger.warning({
61
61
  message: `Component ${component_type} cannot be found - it is skipped from rendering`,
62
+ data: {
63
+ diagnostic: { code: "component-plugin-missing" },
64
+ component,
65
+ },
62
66
  });
63
67
 
64
68
  return null;
@@ -7,11 +7,19 @@ const mockLogger = {
7
7
  warning: jest.fn(),
8
8
  };
9
9
 
10
- jest.mock("../../../Helpers/logger", () => ({
11
- componentsLogger: {
12
- addSubsystem: jest.fn(() => mockLogger),
13
- },
14
- }));
10
+ jest.mock("@applicaster/zapp-react-native-utils/logger", () => {
11
+ const actual = jest.requireActual(
12
+ "@applicaster/zapp-react-native-utils/logger"
13
+ );
14
+
15
+ return {
16
+ ...actual,
17
+ subsystemLogger: (subsystem, category) =>
18
+ subsystem === "ui/components" || subsystem === "ui/cells"
19
+ ? mockLogger
20
+ : actual.subsystemLogger(subsystem, category),
21
+ };
22
+ });
15
23
 
16
24
  jest.mock("../../default-cell-renderer", () => {
17
25
  const View = jest.requireActual("react-native").View;
@@ -1,6 +1,6 @@
1
- import { componentsLogger } from "../../Helpers/logger";
1
+ import { subsystemLogger } from "@applicaster/zapp-react-native-utils/logger";
2
2
 
3
- const logger = componentsLogger.addSubsystem("unknown-component");
3
+ const logger = subsystemLogger("ui/screens", "ContentScreen");
4
4
 
5
5
  const errorMessage =
6
6
  "Content wasn't resolved properly - please check your datasource";
@@ -0,0 +1,3 @@
1
+ // Web builds always select the default Focusable, so the tvOS and iOS ones stay out
2
+ // of web bundles.
3
+ export { Focusable } from "./Focusable";
@@ -1,15 +1,10 @@
1
1
  import * as React from "react";
2
2
  import { pluck, uniq } from "ramda";
3
- import { quickBrickLogger } from "@applicaster/zapp-react-native-utils/logger";
3
+ import { subsystemLogger } from "@applicaster/zapp-react-native-utils/logger";
4
4
 
5
5
  import { getNonUniqueValues } from "./utils";
6
6
 
7
- const logger = quickBrickLogger
8
- .addSubsystem("packages")
9
- .addSubsystem("zapp-react-native-ui-components")
10
- .addSubsystem("Components")
11
- .addSubsystem("FocusableList")
12
- .addSubsystem("index.tsx");
7
+ const logger = subsystemLogger("ui/focus/list", "FocusableList");
13
8
 
14
9
  const getIds = pluck("id");
15
10
 
@@ -21,7 +21,7 @@ import { ScreenResolverFeedProvider } from "../ScreenResolverFeedProvider/Screen
21
21
 
22
22
  const { log_debug } = createLogger({
23
23
  category: "ScreenContainer",
24
- subsystem: "General",
24
+ subsystem: "ui/screens",
25
25
  });
26
26
 
27
27
  /** Provides screen-feed from general-screen configuration (if defined) */
@@ -2,5 +2,5 @@ import { createLogger } from "@applicaster/zapp-react-native-utils/logger";
2
2
 
3
3
  export const { log_debug, log_error, log_info } = createLogger({
4
4
  category: "runInBackground",
5
- subsystem: "GeneralContentScreenHookAdapter",
5
+ subsystem: "ui/screens",
6
6
  });
@@ -1,5 +1,6 @@
1
1
  import * as React from "react";
2
- import { renderHook } from "@testing-library/react-native";
2
+ import { act, renderHook } from "@testing-library/react-native";
3
+ import { configureStore } from "@reduxjs/toolkit";
3
4
 
4
5
  import {
5
6
  getTransformedPreset,
@@ -12,6 +13,7 @@ import { NavigationContext } from "@applicaster/zapp-react-native-ui-components/
12
13
  import { PathnameContext } from "@applicaster/zapp-react-native-ui-components/Contexts/PathnameContext";
13
14
 
14
15
  import { WrappedWithProviders } from "@applicaster/zapp-react-native-utils/testUtils";
16
+ import * as loadPipesDispatchModule from "@applicaster/zapp-react-native-utils/reactHooks/feed/useLoadPipesDataDispatch";
15
17
 
16
18
  jest.mock(
17
19
  "@applicaster/zapp-react-native-utils/reactHooks/navigation/useRoute",
@@ -22,6 +24,19 @@ jest.mock(
22
24
  })
23
25
  );
24
26
 
27
+ jest.mock("@applicaster/zapp-pipes-v2-client", () => ({
28
+ __esModule: true,
29
+ subscribeForKeyChanges: jest.fn(),
30
+ subscribeForUrlContextKeyChanges: jest.fn(() => () => {}),
31
+ subscribeForUrlScreenKeyChanges: jest.fn(),
32
+ createError: jest.fn(),
33
+ RequestBuilder: jest.fn(),
34
+ findEndpointForUrl: jest.fn(),
35
+ findEndpointForURL: jest.fn(),
36
+ HTTP_METHODS: { GET: "get", POST: "post" },
37
+ default: jest.fn(),
38
+ }));
39
+
25
40
  const homeStack = {
26
41
  route: "/home",
27
42
  state: {
@@ -490,4 +505,146 @@ describe("getTransformedPreset should return the passed components if smartCompo
490
505
 
491
506
  expect(result.current).toEqual(mockTransformedComponents);
492
507
  });
508
+
509
+ describe("observation and refresh coordination for smart components", () => {
510
+ let mockLoadPipesDataDispatcher;
511
+
512
+ const mockSmartComponent = {
513
+ id: "smart-comp-1",
514
+ component_type: "quick-brick-smart-component",
515
+ data: { source: "https://pipes.applicaster.com/v2/curation" },
516
+ rules: {},
517
+ };
518
+
519
+ const mockLayoutPresets = {
520
+ preset_one: {
521
+ id: "",
522
+ component_type: "horizontal-list",
523
+ data: { source: "preset1_src" },
524
+ },
525
+ };
526
+
527
+ const mockPresetEntry = [
528
+ { preset_name: "preset_one", feed_url: "https://preset1.com" },
529
+ ];
530
+
531
+ const mockFeeds = {
532
+ "https://pipes.applicaster.com/v2/curation": {
533
+ loading: false,
534
+ data: { entry: mockPresetEntry },
535
+ },
536
+ };
537
+
538
+ beforeEach(() => {
539
+ jest.clearAllMocks();
540
+
541
+ mockLoadPipesDataDispatcher = jest.fn();
542
+
543
+ jest
544
+ .spyOn(loadPipesDispatchModule, "useLoadPipesDataDispatch")
545
+ .mockReturnValue(mockLoadPipesDataDispatcher);
546
+ });
547
+
548
+ afterEach(() => {
549
+ jest.restoreAllMocks();
550
+ });
551
+
552
+ it("loads uncached smart components", () => {
553
+ renderHook(() => useCurationAPI([mockSmartComponent]), {
554
+ wrapper: getWrapper({
555
+ zappPipes: {},
556
+ presetsMapping: { presets_mappings: mockLayoutPresets },
557
+ }),
558
+ });
559
+
560
+ expect(mockLoadPipesDataDispatcher).toHaveBeenCalledWith(
561
+ "https://pipes.applicaster.com/v2/curation",
562
+ { clearCache: false, silentRefresh: true }
563
+ );
564
+ });
565
+
566
+ it("revalidates mounted smart feeds on invalidation and re-enriches fresh content", () => {
567
+ const state = {
568
+ zappPipes: mockFeeds,
569
+ presetsMapping: { presets_mappings: mockLayoutPresets },
570
+ };
571
+
572
+ const store = configureStore({
573
+ reducer: (current = state, action) =>
574
+ action.type === "SET_FEED"
575
+ ? { ...current, zappPipes: action.payload }
576
+ : current,
577
+ });
578
+
579
+ const Wrapper = getWrapper(state);
580
+ const components = [mockSmartComponent];
581
+
582
+ const { result } = renderHook(() => useCurationAPI(components), {
583
+ wrapper: ({ children }) => (
584
+ <Wrapper>
585
+ <redux.Provider store={store}>{children}</redux.Provider>
586
+ </Wrapper>
587
+ ),
588
+ });
589
+
590
+ mockLoadPipesDataDispatcher.mockClear();
591
+ const url = mockSmartComponent.data.source;
592
+
593
+ act(() =>
594
+ store.dispatch({
595
+ type: "SET_FEED",
596
+ payload: {
597
+ [url]: { ...mockFeeds[url], stale: true, invalidationVersion: 1 },
598
+ },
599
+ })
600
+ );
601
+
602
+ expect(mockLoadPipesDataDispatcher).toHaveBeenCalledTimes(1);
603
+
604
+ expect(mockLoadPipesDataDispatcher).toHaveBeenCalledWith(url, {
605
+ clearCache: false,
606
+ silentRefresh: true,
607
+ });
608
+
609
+ act(() =>
610
+ store.dispatch({
611
+ type: "SET_FEED",
612
+ payload: {
613
+ [url]: {
614
+ loading: false,
615
+ data: {
616
+ entry: [
617
+ {
618
+ preset_name: "preset_one",
619
+ feed_url: "https://updated.example/feed",
620
+ },
621
+ ],
622
+ },
623
+ },
624
+ },
625
+ })
626
+ );
627
+
628
+ expect(result.current[0].data.source).toBe(
629
+ "https://updated.example/feed"
630
+ );
631
+ });
632
+
633
+ it("should not dispatch load when there are no smart components", () => {
634
+ const normalComp = {
635
+ id: "comp1",
636
+ data: { source: "https://test.com" },
637
+ component_type: "horizontal-list",
638
+ };
639
+
640
+ renderHook(() => useCurationAPI([normalComp]), {
641
+ wrapper: getWrapper({
642
+ zappPipes: mockFeeds,
643
+ presetsMapping: { presets_mappings: mockLayoutPresets },
644
+ }),
645
+ });
646
+
647
+ expect(mockLoadPipesDataDispatcher).not.toHaveBeenCalled();
648
+ });
649
+ });
493
650
  });
@@ -1,6 +1,6 @@
1
1
  import * as R from "ramda";
2
- import { componentsLogger } from "../../../Helpers/logger";
2
+ import { subsystemLogger } from "@applicaster/zapp-react-native-utils/logger";
3
3
 
4
- export const logger = componentsLogger.addSubsystem("GeneralContentScreen");
4
+ export const logger = subsystemLogger("ui/screens", "GeneralContentScreen");
5
5
 
6
6
  export const whenMatchingType = (type, value) => R.is(type, value) && value;
@@ -1,12 +1,11 @@
1
- import { getXray } from "@applicaster/zapp-react-native-utils/logger";
2
- const { Logger } = getXray();
1
+ import { subsystemLogger } from "@applicaster/zapp-react-native-utils/logger";
3
2
 
4
- export const Subsystem = "GeneralContentScreen";
3
+ export const Subsystem = "ui/screens";
5
4
 
6
5
  export const Categories = {
7
6
  CURATION_API: "useCurationApi",
8
7
  };
9
8
 
10
9
  export function createLogger({ category = "" }) {
11
- return new Logger(category, Subsystem);
10
+ return subsystemLogger(Subsystem, category);
12
11
  }
@@ -7,7 +7,7 @@ import {
7
7
  useZappPipesFeed,
8
8
  } from "@applicaster/zapp-react-native-redux";
9
9
  import { isEmptyOrNil } from "@applicaster/zapp-react-native-utils/cellUtils";
10
- import { Categories } from "./logger";
10
+ import { Categories, Subsystem } from "./logger";
11
11
  import { createLogger } from "@applicaster/zapp-react-native-utils/logger";
12
12
  import { useScreenContext } from "@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenContext";
13
13
 
@@ -22,7 +22,8 @@ import {
22
22
  } from "@applicaster/zapp-react-native-utils/reactHooks/feed/useInflatedUrl";
23
23
 
24
24
  import { produce } from "immer";
25
- import { useLoadPipesDataDispatch } from "@applicaster/zapp-react-native-utils/reactHooks";
25
+ import { useLoadPipesDataDispatch } from "@applicaster/zapp-react-native-utils/reactHooks/feed/useLoadPipesDataDispatch";
26
+ import { useIsInitialRender } from "@applicaster/zapp-react-native-utils/reactHooks/utils";
26
27
 
27
28
  // types reference
28
29
 
@@ -40,11 +41,15 @@ const QB_TABS_SCREEN_TYPE = "quick-brick-tabs";
40
41
  const SMART_COMPONENT_TYPE = "quick-brick-smart-component";
41
42
  const SOURCE_PATH = ["data", "source"];
42
43
  const MAPPING_PATH = ["data", "mapping"];
44
+ const EMPTY_OBJECT = {};
43
45
 
44
46
  const isSmartComponent = (component) =>
45
47
  component.component_type === SMART_COMPONENT_TYPE;
46
48
 
47
- const logger = createLogger({ category: Categories.CURATION_API });
49
+ const logger = createLogger({
50
+ category: Categories.CURATION_API,
51
+ subsystem: Subsystem,
52
+ });
48
53
 
49
54
  export const getTransformedPreset = (
50
55
  preset: CurationEntry,
@@ -146,10 +151,14 @@ export const useCurationAPI = (
146
151
 
147
152
  const screenContextData = useScreenContext();
148
153
 
149
- const entryContext = ((isNestedScreen && screenContextData?.nested?.entry
150
- ? screenContextData?.nested?.entry
151
- : (screenContextData?.entry?.payload ?? screenContextData?.entry)) ||
152
- {}) as ZappEntry;
154
+ const entryContext = useMemo(
155
+ () =>
156
+ ((isNestedScreen && screenContextData?.nested?.entry
157
+ ? screenContextData?.nested?.entry
158
+ : (screenContextData?.entry?.payload ?? screenContextData?.entry)) ||
159
+ EMPTY_OBJECT) as ZappEntry,
160
+ [isNestedScreen, screenContextData]
161
+ );
153
162
 
154
163
  const urlsMap = useMemo<{ [key: string]: string }>(() => {
155
164
  const map = {};
@@ -175,20 +184,33 @@ export const useCurationAPI = (
175
184
  const urls = useMemo<string[]>(() => Object.values(urlsMap), [urlsMap]);
176
185
 
177
186
  const loadPipesDataDispatcher = useLoadPipesDataDispatch();
187
+ const isInitialRender = useIsInitialRender();
188
+
189
+ const feeds = useZappPipesFeed(urls);
178
190
 
179
191
  useEffect(() => {
180
192
  urls.forEach((url, index) => {
181
193
  if (url) {
182
- loadPipesDataDispatcher(url, { clearCache: false });
194
+ const feed = feeds?.[url];
195
+
196
+ if (
197
+ !feed?.refreshing &&
198
+ (!feed?.error || isInitialRender) &&
199
+ (!feed?.data || feed.stale)
200
+ ) {
201
+ loadPipesDataDispatcher(url, {
202
+ clearCache: false,
203
+ silentRefresh: true,
204
+ });
205
+ }
183
206
  } else {
184
207
  logger.log_error("Curation url is empty", {
185
208
  componentId: smartComponents?.[index]?.id,
186
209
  });
187
210
  }
188
211
  });
189
- }, [urls, loadPipesDataDispatcher]);
212
+ }, [urls, smartComponents, loadPipesDataDispatcher, feeds, isInitialRender]);
190
213
 
191
- const feeds = useZappPipesFeed(urls);
192
214
  const layoutPresets = useLayoutPresets();
193
215
 
194
216
  const enrichedComponents = useMemo(() => {
@@ -5,14 +5,9 @@ import {
5
5
 
6
6
  import { CHROMECAST_PLUGIN_ID, YOUTUBE_PLUGIN_ID } from "./const";
7
7
  import { omit } from "@applicaster/zapp-react-native-utils/utils";
8
- import { getXray } from "@applicaster/zapp-react-native-utils/logger";
8
+ import { subsystemLogger } from "@applicaster/zapp-react-native-utils/logger";
9
9
 
10
- const { Logger } = getXray();
11
-
12
- const logger = new Logger(
13
- "QuickBrick",
14
- "packages/zapp-react-native-ui-components/Components/HandlePlayable"
15
- );
10
+ const logger = subsystemLogger("player/playable", "HandlePlayable");
16
11
 
17
12
  const getPlayerModuleProperties = (PlayerModule: ZappPlugin) => {
18
13
  if (PlayerModule?.Component && typeof PlayerModule.Component === "object") {
@@ -7,9 +7,9 @@ import {
7
7
  import { useHookAnalytics } from "@applicaster/zapp-react-native-utils/analyticsUtils/helpers/hooks";
8
8
  import { useSetNavbarState } from "@applicaster/zapp-react-native-utils/reactHooks";
9
9
 
10
- import { componentsLogger } from "../../Helpers/logger";
10
+ import { subsystemLogger } from "@applicaster/zapp-react-native-utils/logger";
11
11
 
12
- const logger = componentsLogger.addSubsystem("HookRenderer");
12
+ const logger = subsystemLogger("core/plugins/hooks", "HookRenderer");
13
13
 
14
14
  const HOOK_PRESENTATION_TYPE = "Hook";
15
15
 
@@ -4,6 +4,8 @@ import { TouchableOpacity, ViewStyle } from "react-native";
4
4
  import { useActions } from "@applicaster/zapp-react-native-utils/reactHooks/actions";
5
5
  import { useUIComponentContext } from "@applicaster/zapp-react-native-ui-components/Contexts/UIComponentContext";
6
6
 
7
+ import { masterCellLogger } from "../logger";
8
+
7
9
  import Image from "./Image";
8
10
  type Props = {
9
11
  item: ZappEntry | ZappFeed;
@@ -60,23 +62,46 @@ export const ActionButton = React.memo(function ActionButtonComponent(
60
62
  const actionContext = useActions(action?.identifier);
61
63
  const component = useUIComponentContext();
62
64
 
65
+ useEffect(() => {
66
+ if (!actionContext && action?.identifier) {
67
+ masterCellLogger.warning({
68
+ message: `ActionButton: action plugin "${action.identifier}" is not available or not installed - the button is not displayed`,
69
+ data: {
70
+ diagnostic: { code: "action-plugin-missing" },
71
+ identifier: action.identifier,
72
+ entryId: item?.id,
73
+ component_id: component?.id,
74
+ },
75
+ });
76
+ }
77
+ }, [actionContext, action?.identifier, item?.id]);
78
+
63
79
  // TODO: add subscription API for action availability
64
80
  const actionDisabled =
65
81
  typeof actionContext?.isActionAvailable === "function" &&
66
82
  !actionContext.isActionAvailable(item);
67
83
 
68
- // Note: in theory initialization is not needed anymore, we are using useEffect
69
84
  const [actionState, setActionState] = React.useState(
70
- actionDisabled || !actionContext
85
+ actionDisabled ||
86
+ !actionContext ||
87
+ typeof actionContext?.initialEntryState !== "function"
71
88
  ? null
72
89
  : actionContext.initialEntryState(item)
73
90
  );
74
91
 
75
92
  useEffect(() => {
76
- if (!((actionDisabled || !actionContext) && actionState !== null)) {
93
+ if (actionDisabled || !actionContext) {
94
+ if (actionState !== null) {
95
+ setActionState(null);
96
+ }
97
+
98
+ return;
99
+ }
100
+
101
+ if (typeof actionContext?.initialEntryState === "function") {
77
102
  setActionState(actionContext.initialEntryState(item));
78
103
  }
79
- }, [actionDisabled, item?.id, actionContext, action, setActionState]);
104
+ }, [actionDisabled, item?.id, actionContext, action]);
80
105
 
81
106
  const onPress = useCallback(() => {
82
107
  actionContext.invokeAction(item, {
@@ -96,6 +121,14 @@ export const ActionButton = React.memo(function ActionButtonComponent(
96
121
  }, [item?.id, setActionState, actionContext]);
97
122
 
98
123
  if (actionDisabled || !actionContext) return null;
124
+
125
+ if (
126
+ actionState?.visibleInCells &&
127
+ !actionState.visibleInCells.includes(cellUUID)
128
+ ) {
129
+ return null;
130
+ }
131
+
99
132
  const AssetComponent = actionState?.asset;
100
133
 
101
134
  // Default state is not yet ready
@@ -109,6 +142,11 @@ export const ActionButton = React.memo(function ActionButtonComponent(
109
142
  accessibilityLabel={props?.accessibilityLabel || `${item?.id}`}
110
143
  accessibilityHint={props?.accessibilityHint}
111
144
  accessibilityRole="button"
145
+ accessibilityState={
146
+ typeof actionState.checked === "boolean"
147
+ ? { checked: actionState.checked }
148
+ : undefined
149
+ }
112
150
  accessible={!!(props?.testID || props?.accessibilityLabel)}
113
151
  style={props?.style}
114
152
  >
@@ -9,6 +9,7 @@ import {
9
9
 
10
10
  import {
11
11
  cloneChildrenWithIds,
12
+ getFocusableElementId,
12
13
  insertBetween,
13
14
  unwrapDataProviderChild,
14
15
  useFilterChildren,
@@ -17,8 +18,6 @@ import {
17
18
  import type { ContainerProps, ContainerChildren } from "./types";
18
19
  import { HorizontalSeparator } from "./components/HorizontalSeparator";
19
20
 
20
- const generateId = (cellUUID, suffixId) => `${cellUUID}--${suffixId}`;
21
-
22
21
  export function ButtonContainerView({
23
22
  style,
24
23
  children,
@@ -31,9 +30,13 @@ export function ButtonContainerView({
31
30
 
32
31
  const buttonIds = filteredChildren.map((child) => {
33
32
  const wrappedChild = unwrapDataProviderChild(child) as ContainerChildren;
34
- const { cellUUID, suffixId } = wrappedChild.props;
33
+ const { cellUUID, cellInstanceId, suffixId } = wrappedChild.props;
35
34
 
36
- return generateId(cellUUID, suffixId);
35
+ return getFocusableElementId({
36
+ playerId: cellUUID,
37
+ cellInstanceId,
38
+ suffix: suffixId,
39
+ });
37
40
  });
38
41
 
39
42
  useInitialFocus(otherProps.state === "focused", R.head(buttonIds));