@applicaster/zapp-react-native-utils 15.0.0-alpha.5170277721 → 15.0.0-alpha.5219062121

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 (138) hide show
  1. package/actionsExecutor/ActionExecutorContext.tsx +3 -6
  2. package/actionsExecutor/feedDecorator.ts +6 -6
  3. package/adsUtils/__tests__/createVMAP.test.ts +419 -0
  4. package/adsUtils/index.ts +2 -2
  5. package/analyticsUtils/README.md +1 -1
  6. package/analyticsUtils/analyticsMapper.ts +10 -2
  7. package/appDataUtils/__tests__/urlScheme.test.ts +678 -0
  8. package/appUtils/HooksManager/__tests__/__snapshots__/hooksManager.test.js.snap +0 -188
  9. package/appUtils/HooksManager/__tests__/hooksManager.test.js +16 -2
  10. package/appUtils/HooksManager/index.ts +10 -10
  11. package/appUtils/RiverFocusManager/{index.js → index.ts} +25 -18
  12. package/appUtils/accessibilityManager/__tests__/utils.test.ts +360 -0
  13. package/appUtils/accessibilityManager/const.ts +4 -0
  14. package/appUtils/accessibilityManager/hooks.ts +20 -13
  15. package/appUtils/accessibilityManager/index.ts +28 -1
  16. package/appUtils/accessibilityManager/utils.ts +59 -8
  17. package/appUtils/contextKeysManager/__tests__/getKeys/failure.test.ts +7 -2
  18. package/appUtils/contextKeysManager/__tests__/getKeys/success.test.ts +48 -0
  19. package/appUtils/contextKeysManager/contextResolver.ts +51 -22
  20. package/appUtils/contextKeysManager/index.ts +65 -10
  21. package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +3 -0
  22. package/appUtils/focusManager/index.ios.ts +43 -4
  23. package/appUtils/focusManager/treeDataStructure/Tree/__tests__/Tree.test.js +46 -0
  24. package/appUtils/focusManager/treeDataStructure/Tree/index.js +18 -18
  25. package/appUtils/focusManagerAux/utils/index.ios.ts +122 -0
  26. package/appUtils/focusManagerAux/utils/index.ts +1 -1
  27. package/appUtils/focusManagerAux/utils/utils.ios.ts +199 -3
  28. package/appUtils/keyCodes/keys/keys.web.ts +1 -4
  29. package/appUtils/orientationHelper.ts +2 -4
  30. package/appUtils/platform/platformUtils.ts +117 -18
  31. package/appUtils/playerManager/OverlayObserver/OverlaysObserver.ts +94 -4
  32. package/appUtils/playerManager/OverlayObserver/utils.ts +32 -20
  33. package/appUtils/playerManager/player.ts +4 -0
  34. package/appUtils/playerManager/playerNative.ts +31 -17
  35. package/appUtils/playerManager/usePlayerState.tsx +14 -2
  36. package/cellUtils/index.ts +32 -0
  37. package/cloudEventsUtils/__tests__/index.test.ts +529 -0
  38. package/cloudEventsUtils/index.ts +65 -1
  39. package/configurationUtils/__tests__/imageSrcFromMediaItem.test.ts +38 -0
  40. package/configurationUtils/__tests__/manifestKeyParser.test.ts +26 -26
  41. package/configurationUtils/index.ts +17 -11
  42. package/dateUtils/__tests__/dayjs.test.ts +330 -0
  43. package/enumUtils/__tests__/getEnumKeyByEnumValue.test.ts +207 -0
  44. package/errorUtils/__tests__/GeneralError.test.ts +97 -0
  45. package/errorUtils/__tests__/HttpStatusCode.test.ts +344 -0
  46. package/errorUtils/__tests__/MissingPluginError.test.ts +113 -0
  47. package/errorUtils/__tests__/NetworkError.test.ts +202 -0
  48. package/errorUtils/__tests__/getParsedResponse.test.ts +188 -0
  49. package/errorUtils/__tests__/invariant.test.ts +112 -0
  50. package/focusManager/aux/index.ts +1 -1
  51. package/headersUtils/__tests__/headersUtils.test.js +11 -1
  52. package/headersUtils/index.ts +2 -1
  53. package/manifestUtils/defaultManifestConfigurations/player.js +109 -11
  54. package/manifestUtils/keys.js +21 -0
  55. package/manifestUtils/platformIsTV.js +13 -0
  56. package/manifestUtils/sharedConfiguration/screenPicker/utils.js +1 -0
  57. package/manifestUtils/tvAction/container/index.js +1 -1
  58. package/navigationUtils/index.ts +15 -5
  59. package/numberUtils/__tests__/toNumber.test.ts +12 -0
  60. package/numberUtils/__tests__/toPositiveNumber.test.ts +165 -0
  61. package/numberUtils/index.ts +19 -1
  62. package/package.json +4 -4
  63. package/playerUtils/usePlayerTTS.ts +8 -3
  64. package/pluginUtils/index.ts +4 -0
  65. package/reactHooks/advertising/index.ts +2 -2
  66. package/reactHooks/analytics/__tests__/useSendAnalyticsOnPress.test.ts +537 -0
  67. package/reactHooks/app/__tests__/useAppState.test.ts +1 -1
  68. package/reactHooks/autoscrolling/__tests__/useTrackCurrentAutoScrollingElement.test.ts +1 -1
  69. package/reactHooks/autoscrolling/__tests__/useTrackedView.test.tsx +1 -2
  70. package/reactHooks/cell-click/__tests__/index.test.js +1 -3
  71. package/reactHooks/configuration/__tests__/index.test.tsx +1 -1
  72. package/reactHooks/connection/__tests__/index.test.js +1 -1
  73. package/reactHooks/debugging/__tests__/index.test.js +4 -4
  74. package/reactHooks/dev/__tests__/useReRenderLog.test.ts +188 -0
  75. package/reactHooks/device/useIsTablet.tsx +14 -19
  76. package/reactHooks/device/useMemoizedIsTablet.ts +3 -3
  77. package/reactHooks/events/index.ts +20 -0
  78. package/reactHooks/feed/__tests__/useBatchLoading.test.tsx +32 -23
  79. package/reactHooks/feed/__tests__/useBuildPipesUrl.test.tsx +19 -19
  80. package/reactHooks/feed/__tests__/useEntryScreenId.test.tsx +4 -1
  81. package/reactHooks/feed/__tests__/useFeedLoader.test.tsx +42 -30
  82. package/reactHooks/feed/__tests__/useFeedRefresh.test.tsx +1 -1
  83. package/reactHooks/feed/__tests__/{useInflatedUrl.test.ts → useInflatedUrl.test.tsx} +62 -7
  84. package/reactHooks/feed/useEntryScreenId.ts +2 -2
  85. package/reactHooks/feed/useInflatedUrl.ts +43 -17
  86. package/reactHooks/flatList/useLoadNextPageIfNeeded.ts +13 -16
  87. package/reactHooks/hookModal/hooks/useHookModalScreenData.ts +12 -8
  88. package/reactHooks/index.ts +2 -0
  89. package/reactHooks/layout/__tests__/index.test.tsx +1 -1
  90. package/reactHooks/layout/__tests__/useLayoutVersion.test.tsx +1 -1
  91. package/reactHooks/layout/useDimensions/__tests__/{useDimensions.test.ts → useDimensions.test.tsx} +105 -25
  92. package/reactHooks/layout/useDimensions/useDimensions.ts +2 -2
  93. package/reactHooks/navigation/__tests__/index.test.tsx +40 -9
  94. package/reactHooks/navigation/index.ts +27 -11
  95. package/reactHooks/navigation/useRoute.ts +11 -7
  96. package/reactHooks/player/TVSeekControlller/TVSeekController.ts +27 -10
  97. package/reactHooks/player/__tests__/useAutoSeek._test.tsx +1 -1
  98. package/reactHooks/player/__tests__/useTapSeek._test.ts +1 -1
  99. package/reactHooks/resolvers/__tests__/useCellResolver.test.tsx +1 -1
  100. package/reactHooks/resolvers/__tests__/useComponentResolver.test.tsx +1 -1
  101. package/reactHooks/resolvers/useCellResolver.ts +6 -2
  102. package/reactHooks/resolvers/useComponentResolver.ts +8 -2
  103. package/reactHooks/screen/__tests__/useCurrentScreenData.test.tsx +2 -2
  104. package/reactHooks/screen/__tests__/useScreenBackgroundColor.test.tsx +1 -1
  105. package/reactHooks/screen/__tests__/useScreenData.test.tsx +1 -1
  106. package/reactHooks/screen/__tests__/useTargetScreenData.test.tsx +12 -4
  107. package/reactHooks/screen/useTargetScreenData.ts +4 -2
  108. package/reactHooks/state/useRefWithInitialValue.ts +10 -0
  109. package/reactHooks/state/useRivers.ts +1 -1
  110. package/reactHooks/ui/__tests__/useFadeOutWhenBlurred.test.ts +580 -0
  111. package/reactHooks/usePluginConfiguration.ts +2 -2
  112. package/reactHooks/utils/__tests__/index.test.js +1 -1
  113. package/rectUtils/__tests__/index.test.ts +549 -0
  114. package/rectUtils/index.ts +2 -2
  115. package/screenPickerUtils/__tests__/index.test.ts +333 -0
  116. package/screenState/__tests__/index.test.ts +1 -1
  117. package/screenUtils/index.ts +3 -0
  118. package/searchUtils/const.ts +7 -0
  119. package/searchUtils/index.ts +3 -0
  120. package/services/storageServiceSync.web.ts +1 -1
  121. package/stringUtils/index.ts +1 -1
  122. package/testUtils/index.tsx +30 -21
  123. package/time/__tests__/BackgroundTimer.test.ts +156 -0
  124. package/time/__tests__/Timer.test.ts +236 -0
  125. package/typeGuards/__tests__/isString.test.ts +21 -0
  126. package/typeGuards/index.ts +4 -0
  127. package/utils/__tests__/mapAccum.test.ts +73 -0
  128. package/utils/__tests__/mergeRight.test.ts +48 -0
  129. package/utils/__tests__/selectors.test.ts +124 -0
  130. package/utils/index.ts +17 -0
  131. package/utils/mapAccum.ts +23 -0
  132. package/utils/mergeRight.ts +5 -0
  133. package/utils/path.ts +6 -3
  134. package/utils/pathOr.ts +5 -1
  135. package/utils/selectors.ts +46 -0
  136. package/zappFrameworkUtils/HookCallback/callbackNavigationAction.ts +34 -11
  137. package/zappFrameworkUtils/HookCallback/hookCallbackManifestExtensions.config.js +1 -1
  138. package/reactHooks/componentsMap/index.ts +0 -55
@@ -1,193 +1,5 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`HooksManager when target route is playable executes the player hook 1`] = `
4
- [
5
- {
6
- "callback": [Function],
7
- "hookPlugin": Hook {
8
- "configuration": {
9
- "config_field": "bar",
10
- },
11
- "identifier": "headless_player_hook",
12
- "lastHook": true,
13
- "manager": {
14
- "executeHook": [Function],
15
- "handleHooks": [Function],
16
- "presentScreenHook": [Function],
17
- "runInBackground": [Function],
18
- "subscriber": {
19
- "handlers": {
20
- "complete": [
21
- [MockFunction] {
22
- "calls": [
23
- [
24
- {
25
- "callback": [Function],
26
- "hookPlugin": [Circular],
27
- "payload": {
28
- "foo": "bar",
29
- },
30
- },
31
- [Function],
32
- ],
33
- ],
34
- "results": [
35
- {
36
- "type": "return",
37
- "value": undefined,
38
- },
39
- ],
40
- },
41
- ],
42
- "presentScreenHook": [
43
- [MockFunction],
44
- ],
45
- "success": [
46
- [MockFunction] {
47
- "calls": [
48
- [Circular],
49
- ],
50
- "results": [
51
- {
52
- "type": "return",
53
- "value": undefined,
54
- },
55
- ],
56
- },
57
- ],
58
- },
59
- "invokeHandler": [Function],
60
- "on": [Function],
61
- "removeHandler": [Function],
62
- },
63
- },
64
- "module": {
65
- "hasPlayerHook": true,
66
- "run": [MockFunction] {
67
- "calls": [
68
- [
69
- {
70
- "foo": "bar",
71
- },
72
- [Function],
73
- {
74
- "config_field": "bar",
75
- },
76
- ],
77
- ],
78
- "results": [
79
- {
80
- "type": "return",
81
- "value": undefined,
82
- },
83
- ],
84
- },
85
- },
86
- "state": 7,
87
- "weight": 1,
88
- },
89
- "payload": {
90
- "foo": "bar",
91
- },
92
- },
93
- [Function],
94
- ]
95
- `;
96
-
97
- exports[`HooksManager when target route is playable executes the player hook 2`] = `
98
- [
99
- {
100
- "callback": [Function],
101
- "hookPlugin": Hook {
102
- "configuration": {
103
- "config_field": "bar",
104
- },
105
- "identifier": "headless_player_hook",
106
- "lastHook": true,
107
- "manager": {
108
- "executeHook": [Function],
109
- "handleHooks": [Function],
110
- "presentScreenHook": [Function],
111
- "runInBackground": [Function],
112
- "subscriber": {
113
- "handlers": {
114
- "complete": [
115
- [MockFunction] {
116
- "calls": [
117
- [Circular],
118
- ],
119
- "results": [
120
- {
121
- "type": "return",
122
- "value": undefined,
123
- },
124
- ],
125
- },
126
- ],
127
- "presentScreenHook": [
128
- [MockFunction],
129
- ],
130
- "success": [
131
- [MockFunction] {
132
- "calls": [
133
- [
134
- {
135
- "callback": [Function],
136
- "hookPlugin": [Circular],
137
- "payload": {
138
- "foo": "bar",
139
- },
140
- },
141
- [Function],
142
- ],
143
- ],
144
- "results": [
145
- {
146
- "type": "return",
147
- "value": undefined,
148
- },
149
- ],
150
- },
151
- ],
152
- },
153
- "invokeHandler": [Function],
154
- "on": [Function],
155
- "removeHandler": [Function],
156
- },
157
- },
158
- "module": {
159
- "hasPlayerHook": true,
160
- "run": [MockFunction] {
161
- "calls": [
162
- [
163
- {
164
- "foo": "bar",
165
- },
166
- [Function],
167
- {
168
- "config_field": "bar",
169
- },
170
- ],
171
- ],
172
- "results": [
173
- {
174
- "type": "return",
175
- "value": undefined,
176
- },
177
- ],
178
- },
179
- },
180
- "state": 7,
181
- "weight": 1,
182
- },
183
- "payload": {
184
- "foo": "bar",
185
- },
186
- },
187
- [Function],
188
- ]
189
- `;
190
-
191
3
  exports[`HooksManager when there are preload hooks hook with screen: executes 1`] = `
192
4
  [
193
5
  {
@@ -116,9 +116,23 @@ describe("HooksManager", () => {
116
116
  headlessPlayerHook.configuration
117
117
  );
118
118
 
119
- expect(successHandler.mock.calls[0]).toMatchSnapshot();
119
+ expect(successHandler).toHaveBeenCalledTimes(1);
120
+ expect(successHandler.mock.calls[0][0].payload).toEqual(payload);
120
121
 
121
- expect(completeHandler.mock.calls[0]).toMatchSnapshot();
122
+ expect(successHandler.mock.calls[0][0].hookPlugin.identifier).toBe(
123
+ "headless_player_hook"
124
+ );
125
+
126
+ expect(typeof successHandler.mock.calls[0][1]).toBe("function");
127
+
128
+ expect(completeHandler).toHaveBeenCalledTimes(1);
129
+ expect(completeHandler.mock.calls[0][0].payload).toEqual(payload);
130
+
131
+ expect(completeHandler.mock.calls[0][0].hookPlugin.identifier).toBe(
132
+ "headless_player_hook"
133
+ );
134
+
135
+ expect(typeof completeHandler.mock.calls[0][1]).toBe("function");
122
136
  });
123
137
  });
124
138
 
@@ -230,7 +230,7 @@ export function HooksManager({
230
230
  function completeHook(hookPlugin, payload, callback) {
231
231
  logHookEvent(
232
232
  hooksManagerLogger.info,
233
- `completeHook: hook sequence completed successfully: ${hookPlugin["identifier"]}`,
233
+ `completeHook: hook sequence completed successfully: ${hookPlugin.identifier}`,
234
234
  {
235
235
  payload,
236
236
  hook: hookPlugin,
@@ -276,7 +276,7 @@ export function HooksManager({
276
276
  if (hookPlugin.isCancelled()) {
277
277
  logHookEvent(
278
278
  hooksManagerLogger.info,
279
- `hookCallback: hook was cancelled: ${hookPlugin["identifier"]}`,
279
+ `hookCallback: hook was cancelled: ${hookPlugin.identifier}`,
280
280
  {}
281
281
  );
282
282
 
@@ -305,7 +305,7 @@ export function HooksManager({
305
305
  if (!success) {
306
306
  logHookEvent(
307
307
  hooksManagerLogger.info,
308
- `hookCallback: hook was cancelled: ${hookPlugin["identifier"]}`,
308
+ `hookCallback: hook was cancelled: ${hookPlugin.identifier}`,
309
309
  {
310
310
  payload,
311
311
  hook: hookPlugin,
@@ -334,7 +334,7 @@ export function HooksManager({
334
334
  if (isHookInHomescreen && isHookFlowBlocker && cancelled) {
335
335
  logHookEvent(
336
336
  hooksManagerLogger.info,
337
- `hookCallback: send app to background, cancelled flow blocker hook ${hookPlugin["identifier"]} on home screen`,
337
+ `hookCallback: send app to background, cancelled flow blocker hook ${hookPlugin.identifier} on home screen`,
338
338
  {
339
339
  payload,
340
340
  hook: hookPlugin,
@@ -349,7 +349,7 @@ export function HooksManager({
349
349
  } else {
350
350
  logHookEvent(
351
351
  hooksManagerLogger.info,
352
- `hookCallback: hook successfully finished: ${hookPlugin["identifier"]}`,
352
+ `hookCallback: hook successfully finished: ${hookPlugin.identifier}`,
353
353
  {
354
354
  payload,
355
355
  hook: hookPlugin,
@@ -359,7 +359,7 @@ export function HooksManager({
359
359
  if (!callback) {
360
360
  logHookEvent(
361
361
  hooksManagerLogger.warn,
362
- `hookCallback: ${hookPlugin["identifier"]} is missing \`callback\`, using hookCallback(default one)`,
362
+ `hookCallback: ${hookPlugin.identifier} is missing \`callback\`, using hookCallback(default one)`,
363
363
  {
364
364
  hookPlugin,
365
365
  }
@@ -401,7 +401,7 @@ export function HooksManager({
401
401
 
402
402
  logHookEvent(
403
403
  hooksManagerLogger.info,
404
- `presentScreenHook: Presenting screen hook: ${hookPlugin["identifier"]}`,
404
+ `presentScreenHook: Presenting screen hook: ${hookPlugin.identifier}`,
405
405
  {
406
406
  hook: hookPlugin,
407
407
  payload,
@@ -421,7 +421,7 @@ export function HooksManager({
421
421
  hooksManager.executeHook = function (hookPlugin, payload, callback) {
422
422
  logHookEvent(
423
423
  hooksManagerLogger.info,
424
- `executeHook: ${hookPlugin["identifier"]}`,
424
+ `executeHook: ${hookPlugin.identifier}`,
425
425
  {
426
426
  hook: hookPlugin,
427
427
  payload,
@@ -433,7 +433,7 @@ export function HooksManager({
433
433
  } catch (error) {
434
434
  logHookEvent(
435
435
  hooksManagerLogger.error,
436
- `executeHook: error executing hook: ${hookPlugin["identifier"]} error: ${error.message}`,
436
+ `executeHook: error executing hook: ${hookPlugin.identifier} error: ${error.message}`,
437
437
  {
438
438
  hook: hookPlugin,
439
439
  payload,
@@ -460,7 +460,7 @@ export function HooksManager({
460
460
  try {
461
461
  logHookEvent(
462
462
  hooksManagerLogger.info,
463
- `runInBackground: Executing hook: ${hookPlugin["identifier"]}`,
463
+ `runInBackground: Executing hook: ${hookPlugin.identifier}`,
464
464
  {
465
465
  hook: hookPlugin,
466
466
  payload,
@@ -1,11 +1,31 @@
1
- import * as R from "ramda";
2
-
3
- import { focusManager } from "../focusManager";
1
+ import { focusManager } from "@applicaster/zapp-react-native-utils/appUtils/focusManager/index.ios";
2
+ import { QUICK_BRICK_CONTENT } from "@applicaster/quick-brick-core/const";
3
+ import { isNil, isEmpty } from "@applicaster/zapp-react-native-utils/utils";
4
+ import { isNotNil } from "@applicaster/zapp-react-native-utils/reactUtils/helpers";
4
5
 
5
6
  let riverFocusData = {};
6
7
  let initialyPresentedScreenFocused = false;
7
8
 
8
9
  export const riverFocusManager = (function () {
10
+ /**
11
+ * Create unique key that will be used for save focused group data inside specific screen
12
+ * @param {{ screenId: string, isInsideContainer: boolean }}
13
+ * screenId Unique Id of the screen from layout.json
14
+ * isInsideContainer If this screen a screen picker child
15
+ *
16
+ */
17
+ function screenFocusableGroupId({
18
+ screenId,
19
+ isInsideContainer,
20
+ }: {
21
+ screenId: string;
22
+ isInsideContainer: Option<boolean>;
23
+ }) {
24
+ return `${QUICK_BRICK_CONTENT}-${screenId}${
25
+ isNil(isInsideContainer) ? "" : "-isInsideContainer"
26
+ }`;
27
+ }
28
+
9
29
  function setScreenFocusableData({
10
30
  screenFocusableGroupId,
11
31
  groupId,
@@ -78,8 +98,8 @@ export const riverFocusManager = (function () {
78
98
  }) {
79
99
  // Check if screen should be focused
80
100
  const shouldFocus =
81
- (initialyPresentedScreenFocused === false && R.isEmpty(riverFocusData)) ||
82
- R.compose(R.not, R.isNil)(riverFocusData[screenFocusableGroupId]) ||
101
+ (initialyPresentedScreenFocused === false && isEmpty(riverFocusData)) ||
102
+ isNotNil(riverFocusData[screenFocusableGroupId]) ||
83
103
  isDeepLink;
84
104
 
85
105
  // TODO: Uncommit it to start fixing bug where selection wrong item
@@ -118,19 +138,6 @@ export const riverFocusManager = (function () {
118
138
  }
119
139
  }
120
140
 
121
- /**
122
- * Create unique key that will be used for save focused group data inside specific screen
123
- * @param {{ screenId: string, isInsideContainer: boolean }}
124
- * screenId Unique Id of the screen from layout.json
125
- * isInsideContainer If this screen a screen picker child
126
- *
127
- */
128
- function screenFocusableGroupId({ screenId, isInsideContainer }) {
129
- return `RiverFocusableGroup-${screenId}${
130
- R.isNil(isInsideContainer) ? "" : "-isInsideContainer"
131
- }`;
132
- }
133
-
134
141
  return {
135
142
  setScreenFocusableData,
136
143
  clearAllScreensData,