@applicaster/zapp-react-native-utils 12.0.0-rc.14 → 12.0.0-rc.141

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 (133) hide show
  1. package/actionsExecutor/ActionExecutorContext.tsx +16 -8
  2. package/analyticsUtils/AnalyticPlayerListener.ts +141 -0
  3. package/analyticsUtils/AnalyticsEvents/index.ts +13 -0
  4. package/analyticsUtils/AnalyticsEvents/searchEvents.ts +21 -0
  5. package/analyticsUtils/AnalyticsEvents/sendShareEvent.ts +21 -0
  6. package/analyticsUtils/PlayerAnalyticsManager.ts +90 -0
  7. package/analyticsUtils/__tests__/analyticsManager.test.js +75 -73
  8. package/analyticsUtils/analyticsPlugins.ts +25 -0
  9. package/analyticsUtils/events.ts +12 -0
  10. package/analyticsUtils/helpers/hooks.ts +1 -1
  11. package/analyticsUtils/index.tsx +12 -0
  12. package/analyticsUtils/{analyticsTracker.ts → playerAnalyticsTracker.ts} +19 -10
  13. package/appUtils/HooksManager/index.js +3 -1
  14. package/appUtils/accessibilityManager/const.ts +50 -0
  15. package/appUtils/accessibilityManager/hooks.ts +40 -0
  16. package/appUtils/accessibilityManager/index.ts +155 -0
  17. package/appUtils/accessibilityManager/logger.ts +5 -0
  18. package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +2 -3
  19. package/appUtils/focusManager/__tests__/focusManager.test.js +4 -24
  20. package/appUtils/focusManager/__tests__/index.test.ts +2 -3
  21. package/appUtils/focusManager/index.ts +76 -57
  22. package/appUtils/focusManager/treeDataStructure/Utils/index.js +75 -35
  23. package/appUtils/focusManager/utils/index.ts +100 -0
  24. package/appUtils/focusManagerAux/index.ts +76 -0
  25. package/appUtils/focusManagerAux/utils/index.ts +100 -0
  26. package/appUtils/index.js +2 -0
  27. package/appUtils/keyCodes/__tests__/__snapshots__/keyCodes.test.js.snap +1 -1
  28. package/appUtils/keyCodes/__tests__/keyCodes.test.js +80 -85
  29. package/appUtils/keyCodes/keys.web.js +9 -0
  30. package/appUtils/keyCodes/keysByPlatform.js +11 -1
  31. package/appUtils/platform/const.ts +25 -0
  32. package/appUtils/platform/index.ts +3 -0
  33. package/appUtils/platform/platformUtils.ts +218 -0
  34. package/appUtils/playerManager/OverlayObserver/OverlaysObserver.ts +53 -0
  35. package/appUtils/playerManager/conts.ts +6 -0
  36. package/appUtils/playerManager/index.ts +20 -32
  37. package/appUtils/playerManager/nativePlayerManager.ts +12 -0
  38. package/appUtils/playerManager/player.ts +56 -7
  39. package/appUtils/playerManager/playerFactory.ts +20 -5
  40. package/appUtils/playerManager/playerHooks/usePlayerCurrentTime.tsx +57 -0
  41. package/appUtils/playerManager/playerNative.ts +41 -15
  42. package/appUtils/playerManager/usePlayerControllerSetup.tsx +8 -2
  43. package/appUtils/playerManager/usePlayerState.tsx +20 -23
  44. package/appUtils/playerManager/usePlayerTitleSummaryOverlay.tsx +50 -0
  45. package/arrayUtils/__tests__/isFilledArray.test.ts +63 -0
  46. package/arrayUtils/index.ts +16 -0
  47. package/booleanUtils/index.ts +4 -4
  48. package/cellUtils/__tests__/cellUtils.test.ts +48 -0
  49. package/cellUtils/__tests__/fixtures.ts +13 -0
  50. package/cellUtils/index.ts +78 -7
  51. package/dateUtils/index.ts +11 -0
  52. package/focusManager/FocusManager.ts +20 -5
  53. package/focusManager/__tests__/FocusManager.test.ts +0 -1
  54. package/focusManager/index.ts +1 -1
  55. package/functionUtils/__tests__/__snapshots__/functionUtils.test.js.snap +2 -2
  56. package/functionUtils/__tests__/functionUtils.test.js +244 -248
  57. package/functionUtils/index.ts +38 -0
  58. package/headersUtils/index.ts +1 -0
  59. package/index.d.ts +15 -0
  60. package/inflatedUrlUtils/index.ts +4 -4
  61. package/keyboardState/index.ts +0 -0
  62. package/localizationUtils/__tests__/localizationUtils.test.ts +78 -55
  63. package/localizationUtils/index.ts +13 -19
  64. package/logger/index.ts +1 -1
  65. package/manifestUtils/defaultManifestConfigurations/generalContent.js +6 -0
  66. package/manifestUtils/defaultManifestConfigurations/player.js +131 -1
  67. package/manifestUtils/index.js +5 -1
  68. package/manifestUtils/keys.js +2 -1
  69. package/manifestUtils/secondaryImage/index.js +18 -15
  70. package/modalState/index.ts +57 -0
  71. package/navigationUtils/index.ts +105 -8
  72. package/numberUtils/__tests__/isLikeNumber.test.ts +18 -0
  73. package/numberUtils/__tests__/toNumber.test.ts +2 -2
  74. package/numberUtils/__tests__/toPositiveNumberWithDefault.test.ts +66 -0
  75. package/numberUtils/__tests__/toPositiveNumberWithDefaultZero.test.ts +66 -0
  76. package/numberUtils/index.ts +27 -16
  77. package/package.json +3 -2
  78. package/playerUtils/configurationGenerator.ts +131 -1
  79. package/playerUtils/imaScriptDom.ts +59 -0
  80. package/pluginUtils/index.ts +20 -7
  81. package/reactHooks/autoscrolling/__tests__/useTrackCurrentAutoScrollingElement.test.ts +2 -0
  82. package/reactHooks/autoscrolling/__tests__/{useTrackedView.test.ts → useTrackedView.test.tsx} +18 -1
  83. package/reactHooks/cell-click/__tests__/index.test.js +16 -3
  84. package/reactHooks/cell-click/index.ts +30 -16
  85. package/reactHooks/debugging/__tests__/index.test.js +81 -11
  86. package/reactHooks/feed/__tests__/useBatchLoading.test.tsx +69 -6
  87. package/reactHooks/feed/__tests__/useBuildPipesUrl.test.tsx +30 -70
  88. package/reactHooks/feed/__tests__/useFeedRefresh.test.tsx +6 -2
  89. package/reactHooks/feed/__tests__/useInflatedUrl.test.ts +18 -3
  90. package/reactHooks/feed/useBatchLoading.ts +52 -28
  91. package/reactHooks/feed/useBuildPipesUrl.ts +7 -10
  92. package/reactHooks/feed/useFeedRefresh.tsx +9 -7
  93. package/reactHooks/feed/useInflatedUrl.ts +44 -15
  94. package/reactHooks/flatList/useLoadNextPageIfNeeded.ts +16 -9
  95. package/reactHooks/index.ts +2 -0
  96. package/reactHooks/layout/__tests__/{index.test.js → index.test.tsx} +66 -59
  97. package/reactHooks/layout/getDeviceInfo/index.ts +4 -2
  98. package/reactHooks/layout/types/index.ts +2 -0
  99. package/reactHooks/layout/useDimensions/__tests__/useDimensions.test.ts +134 -0
  100. package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.native.test.js +11 -16
  101. package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.test.js +12 -14
  102. package/reactHooks/layout/useDimensions/useDimensions.ts +15 -7
  103. package/reactHooks/navigation/__mocks__/index.ts +15 -0
  104. package/reactHooks/navigation/__mocks__/useNavigation.ts +7 -0
  105. package/reactHooks/navigation/__tests__/index.test.tsx +240 -81
  106. package/reactHooks/navigation/index.ts +240 -81
  107. package/reactHooks/player/useAutoSeek.tsx +9 -7
  108. package/reactHooks/resolvers/__tests__/useCellResolver.test.tsx +3 -1
  109. package/reactHooks/resolvers/useCellResolver.ts +5 -1
  110. package/reactHooks/screen/__mocks__/useScreenContext.ts +3 -1
  111. package/reactHooks/screen/__tests__/useCurrentScreenData.test.tsx +21 -23
  112. package/reactHooks/screen/index.ts +4 -0
  113. package/reactHooks/screen/useScreenBackgroundColor.ts +23 -0
  114. package/reactHooks/screen/useScreenContext.ts +4 -4
  115. package/reactHooks/screen/useScreenData.ts +1 -1
  116. package/reactHooks/screen/useTargetScreenData.ts +7 -0
  117. package/reactHooks/state/useRivers.ts +3 -1
  118. package/reactHooks/useConfiguration.ts +2 -2
  119. package/reactHooks/useListenEventBusEvent.ts +1 -4
  120. package/reactHooks/videoModal/hooks/useVideoModalScreenData.tsx +10 -9
  121. package/reactUtils/index.ts +104 -0
  122. package/riverComponetsMeasurementProvider/index.tsx +2 -2
  123. package/services/localStorageServiceSync.web.ts +48 -0
  124. package/services/sessionStorageServiceSync.web.ts +32 -0
  125. package/services/storageServiceSync.web.ts +24 -0
  126. package/services/storageWebUtils.web.ts +10 -0
  127. package/stringUtils/index.ts +5 -0
  128. package/testUtils/getByTestId.ts +14 -0
  129. package/testUtils/index.tsx +71 -23
  130. package/types.ts +4 -0
  131. package/appUtils/focusManager/FocusableEvents.ts +0 -8
  132. package/appUtils/focusManager/treeDataStructure/Utils/__tests__/Utils_android.test.js +0 -1094
  133. package/appUtils/focusManager/treeDataStructure/Utils/index.android.js +0 -261
@@ -18,6 +18,7 @@ class FocusManager {
18
18
  private static instance: FocusManager;
19
19
 
20
20
  private _focusedId: string | null = null;
21
+ private _prevFocusedId: string | null = null;
21
22
  public previousNavigationDirection: FocusManager.Android.NavDir = null;
22
23
 
23
24
  /**
@@ -47,10 +48,22 @@ class FocusManager {
47
48
  return focusedRef?.current;
48
49
  }
49
50
 
51
+ get prevFocused() {
52
+ const focusedRef = this.prevFocusedId
53
+ ? FocusManager.findFocusable(this.prevFocusedId)
54
+ : { current: null };
55
+
56
+ return focusedRef?.current;
57
+ }
58
+
50
59
  get focusedId() {
51
60
  return FocusManager.instance._focusedId;
52
61
  }
53
62
 
63
+ get prevFocusedId() {
64
+ return FocusManager.instance._prevFocusedId;
65
+ }
66
+
54
67
  public static getInstance(): FocusManager {
55
68
  if (!FocusManager.instance) {
56
69
  FocusManager.instance = new FocusManager();
@@ -151,9 +164,8 @@ class FocusManager {
151
164
  }
152
165
 
153
166
  private setFocusLocal(nextFocus: FocusManager.TouchableReactRef) {
167
+ FocusManager.instance._prevFocusedId = FocusManager.instance._focusedId;
154
168
  FocusManager.instance._focusedId = nextFocus?.current?.props?.id ?? null;
155
-
156
- this.eventHandler?.invokeHandler?.(FOCUS_EVENTS.FOCUS, nextFocus);
157
169
  }
158
170
 
159
171
  private setPreviousNavigationDirection(
@@ -217,8 +229,11 @@ class FocusManager {
217
229
 
218
230
  FocusManager.instance.setFocus(nextNextFocus, options);
219
231
  } else {
220
- FocusManager.instance.blurPrevious(options);
221
232
  FocusManager.instance.setFocusLocal(nextFocus);
233
+
234
+ FocusManager.instance.blurPrevious(options);
235
+ this.eventHandler?.invokeHandler?.(FOCUS_EVENTS.FOCUS, nextFocus);
236
+
222
237
  FocusManager.instance.setPreviousNavigationDirection(options ?? null);
223
238
 
224
239
  nextFocus?.current?.onFocus?.(nextFocus.current, options ?? {});
@@ -227,8 +242,8 @@ class FocusManager {
227
242
 
228
243
  blurPrevious(options?: FocusManager.Android.CallbackOptions) {
229
244
  if (options) {
230
- FocusManager.instance.focused?.onBlur?.(
231
- FocusManager.instance.focused,
245
+ FocusManager.instance.prevFocused?.onBlur?.(
246
+ FocusManager.instance.prevFocused,
232
247
  options
233
248
  );
234
249
  }
@@ -156,7 +156,6 @@ describe("FocusManager", () => {
156
156
  child1.current.onBlur.mockClear();
157
157
  focusManager.setFocus(child1.current.props.id);
158
158
  focusManager.blurPrevious({ direction: "down" });
159
- expect(child1.current.onBlur).toBeCalled();
160
159
  });
161
160
 
162
161
  it("focusManager - focus shouldn't change if nextFocus has blockFocus", () => {
@@ -86,7 +86,7 @@ export const isFocusable = (component: ZappEntry | ZappUIComponent | any) =>
86
86
 
87
87
  type Props = {
88
88
  component: ZappUIComponent;
89
- zappPipesData: ZappPipesData;
89
+ zappPipesData?: ZappPipesData;
90
90
  } & Record<string, any>;
91
91
 
92
92
  export const useIsFocusable = (props: Props): void => {
@@ -1,6 +1,6 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`subscriber can be invoked without args 1`] = `
3
+ exports[`functionUtils subscriber can be invoked without args 1`] = `
4
4
  Object {
5
5
  "handlers": Object {},
6
6
  "invokeHandler": [Function],
@@ -9,7 +9,7 @@ Object {
9
9
  }
10
10
  `;
11
11
 
12
- exports[`subscriber returns the original object with additional methods 1`] = `
12
+ exports[`functionUtils subscriber returns the original object with additional methods 1`] = `
13
13
  Object {
14
14
  "foo": "bar",
15
15
  "handlers": Object {},