@applicaster/zapp-react-native-utils 13.0.0-alpha.7223526501 → 13.0.0-alpha.7429912110

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 (79) hide show
  1. package/actionsExecutor/ActionExecutorContext.tsx +159 -12
  2. package/actionsExecutor/consts.ts +4 -0
  3. package/appUtils/HooksManager/Hook.ts +4 -0
  4. package/appUtils/HooksManager/index.ts +3 -1
  5. package/appUtils/__tests__/__snapshots__/localizationsHelper.test.ts.snap +151 -0
  6. package/appUtils/__tests__/allZappLocales.ts +79 -0
  7. package/appUtils/__tests__/{localizationsHelper.test.js → localizationsHelper.test.ts} +11 -0
  8. package/appUtils/accessibilityManager/const.ts +18 -0
  9. package/appUtils/contextKeysManager/contextResolver.ts +1 -12
  10. package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +2 -0
  11. package/appUtils/focusManager/index.ios.ts +14 -4
  12. package/appUtils/focusManager/index.ts +14 -10
  13. package/appUtils/focusManager/utils/__tests__/findChild.test.ts +35 -0
  14. package/appUtils/focusManager/utils/index.ts +5 -0
  15. package/appUtils/localizationsHelper.ts +31 -0
  16. package/appUtils/orientationHelper.ts +11 -13
  17. package/appUtils/playerManager/player.ts +24 -12
  18. package/appUtils/playerManager/playerHooks/usePlayerCurrentTime.tsx +11 -7
  19. package/appUtils/playerManager/playerNative.ts +18 -3
  20. package/appUtils/playerManager/usePlayerTitleSummaryOverlay.tsx +7 -1
  21. package/cellUtils/index.ts +9 -5
  22. package/componentsUtils/__tests__/isFirstComponentGallery.test.ts +33 -0
  23. package/componentsUtils/__tests__/isFirstComponentScreenPicker.test.ts +33 -0
  24. package/componentsUtils/__tests__/isGallery.test.ts +33 -0
  25. package/componentsUtils/__tests__/isScreenPicker.test.ts +33 -0
  26. package/componentsUtils/index.ts +39 -0
  27. package/dateUtils/index.ts +19 -0
  28. package/focusManager/FocusManager.ts +3 -1
  29. package/focusManager/index.ts +3 -21
  30. package/functionUtils/index.ts +46 -8
  31. package/index.d.ts +0 -12
  32. package/localizationUtils/index.ts +8 -13
  33. package/manifestUtils/defaultManifestConfigurations/generalContent.js +13 -0
  34. package/manifestUtils/defaultManifestConfigurations/player.js +9 -3
  35. package/manifestUtils/fonts/index.js +5 -6
  36. package/manifestUtils/index.js +2 -0
  37. package/manifestUtils/keys.js +27 -2
  38. package/modalState/__tests__/index.test.ts +51 -0
  39. package/modalState/index.ts +32 -2
  40. package/navigationUtils/__tests__/__snapshots__/navigationUtils.test.js.snap +1 -0
  41. package/navigationUtils/index.ts +3 -1
  42. package/numberUtils/__tests__/toPositiveNumberWithDefault.test.ts +23 -3
  43. package/numberUtils/index.ts +11 -5
  44. package/package.json +2 -6
  45. package/playerUtils/configurationGenerator.ts +9 -11
  46. package/playerUtils/index.ts +23 -0
  47. package/reactHooks/advertising/index.ts +5 -5
  48. package/reactHooks/app/useAppState.ts +2 -2
  49. package/reactHooks/autoscrolling/__tests__/useTrackedView.test.tsx +5 -7
  50. package/reactHooks/autoscrolling/useTrackedView.ts +12 -1
  51. package/reactHooks/feed/useBatchLoading.ts +10 -12
  52. package/reactHooks/feed/useFeedLoader.tsx +17 -8
  53. package/reactHooks/hookModal/hooks/useHookModalScreenData.ts +39 -0
  54. package/reactHooks/navigation/__tests__/index.test.tsx +6 -17
  55. package/reactHooks/navigation/{useGetTabBarHeight.ts → getTabBarHeight.ts} +1 -1
  56. package/reactHooks/navigation/index.ts +6 -4
  57. package/reactHooks/navigation/useGetBottomTabBarHeight.ts +10 -3
  58. package/reactHooks/navigation/useNavigationPluginData.ts +8 -4
  59. package/reactHooks/navigation/useNavigationType.ts +4 -2
  60. package/reactHooks/navigation/useRoute.ts +4 -6
  61. package/reactHooks/screen/__tests__/useScreenBackgroundColor.test.tsx +69 -0
  62. package/reactHooks/screen/useScreenBackgroundColor.ts +3 -15
  63. package/reactHooks/state/README.md +79 -0
  64. package/reactHooks/state/ZStoreProvider.tsx +71 -0
  65. package/reactHooks/state/__tests__/ZStoreProvider.test.tsx +66 -0
  66. package/reactHooks/state/index.ts +2 -0
  67. package/reactHooks/useListenEventBusEvent.ts +1 -1
  68. package/reactUtils/index.ts +9 -0
  69. package/services/js2native.ts +673 -0
  70. package/time/BackgroundTimer.ts +55 -0
  71. package/time/Timer.ts +6 -6
  72. package/typeGuards/index.ts +3 -0
  73. package/utils/README.md +30 -0
  74. package/utils/chunk.ts +5 -0
  75. package/utils/index.ts +5 -0
  76. package/utils/times.ts +5 -0
  77. package/zappFrameworkUtils/localStorageHelper.ts +38 -10
  78. package/zappFrameworkUtils/loginPluginUtils.ts +6 -2
  79. package/zappFrameworkUtils/types.ts +11 -0
@@ -0,0 +1,66 @@
1
+ import React from "react";
2
+ import { render, screen } from "@testing-library/react-native";
3
+ import { Text } from "react-native";
4
+ import { ZStoreProvider, useZStore } from "../ZStoreProvider";
5
+ import { useStore } from "zustand";
6
+
7
+ interface TestState {
8
+ value: string;
9
+ }
10
+
11
+ // Test component that uses the store
12
+ const TestComponent = ({ storeName }: { storeName: string }) => {
13
+ const store = useZStore(storeName);
14
+ const value = useStore(store, (state: any) => (state as TestState).value);
15
+
16
+ return <Text testID="test-value">{value}</Text>;
17
+ };
18
+
19
+ // Test component that provides a store
20
+ const TestProvider = ({ children }: { children: React.ReactNode }) => {
21
+ return (
22
+ <ZStoreProvider name="testStore" value={{ value: "test-value" }}>
23
+ {children}
24
+ </ZStoreProvider>
25
+ );
26
+ };
27
+
28
+ describe("ZStoreProvider and useZStore", () => {
29
+ it("should provide a store and allow access via useZStore", () => {
30
+ render(
31
+ <TestProvider>
32
+ <TestComponent storeName="testStore" />
33
+ </TestProvider>
34
+ );
35
+
36
+ expect(screen.getByTestId("test-value").props.children).toBe("test-value");
37
+ });
38
+
39
+ it("should throw error when useZStore is used outside provider", () => {
40
+ // Suppress console.error for this test
41
+ const originalError = console.error;
42
+ console.error = jest.fn();
43
+
44
+ expect(() => {
45
+ render(<TestComponent storeName="testStore" />);
46
+ }).toThrow("useZStore must be used within a ZStoreProvider");
47
+
48
+ console.error = originalError;
49
+ });
50
+
51
+ it("should throw error when store name is not found", () => {
52
+ // Suppress console.error for this test
53
+ const originalError = console.error;
54
+ console.error = jest.fn();
55
+
56
+ expect(() => {
57
+ render(
58
+ <TestProvider>
59
+ <TestComponent storeName="nonExistentStore" />
60
+ </TestProvider>
61
+ );
62
+ }).toThrow('Store with name "nonExistentStore" not found');
63
+
64
+ console.error = originalError;
65
+ });
66
+ });
@@ -1,3 +1,5 @@
1
1
  export { useRivers } from "./useRivers";
2
2
 
3
3
  export { useHomeRiver } from "./useHomeRiver";
4
+
5
+ export { ZStoreProvider, useZStore } from "./ZStoreProvider";
@@ -23,5 +23,5 @@ export const useListenEventBusEvent = (
23
23
  sub.remove(); // stop listening to DeviceEventEmitter
24
24
  };
25
25
  }
26
- }, []);
26
+ }, [handler, subscriptionID, source, events]);
27
27
  };
@@ -187,3 +187,12 @@ export const hasVizioAPIs = () => {
187
187
 
188
188
  return hasAPIs;
189
189
  };
190
+
191
+ /**
192
+ * Checks if the Android version is at least the expected version
193
+ * @param expectedVersion The version to compare against
194
+ * @returns True if the current Android version is at least the expected version, false otherwise
195
+ */
196
+ export const isAndroidVersionAtLeast = (expectedVersion: number) => {
197
+ return parseFloat(Platform.Version.toString()) >= expectedVersion;
198
+ };