@applicaster/zapp-react-native-utils 15.0.0-alpha.1257410812 → 15.0.0-alpha.1283350001

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 (61) hide show
  1. package/README.md +0 -6
  2. package/adsUtils/__tests__/createVMAP.test.ts +419 -0
  3. package/appDataUtils/__tests__/urlScheme.test.ts +678 -0
  4. package/appUtils/HooksManager/__tests__/__snapshots__/hooksManager.test.js.snap +0 -188
  5. package/appUtils/HooksManager/__tests__/hooksManager.test.js +16 -2
  6. package/appUtils/focusManager/treeDataStructure/Tree/__tests__/Tree.test.js +46 -0
  7. package/appUtils/focusManager/treeDataStructure/Tree/index.js +18 -18
  8. package/appUtils/focusManagerAux/utils/index.ts +2 -4
  9. package/appUtils/focusManagerAux/utils/utils.ios.ts +6 -3
  10. package/appUtils/localizationsHelper.ts +4 -0
  11. package/appUtils/playerManager/playerNative.ts +2 -1
  12. package/cloudEventsUtils/__tests__/index.test.ts +529 -0
  13. package/cloudEventsUtils/index.ts +65 -1
  14. package/dateUtils/__tests__/dayjs.test.ts +330 -0
  15. package/enumUtils/__tests__/getEnumKeyByEnumValue.test.ts +207 -0
  16. package/errorUtils/__tests__/GeneralError.test.ts +97 -0
  17. package/errorUtils/__tests__/HttpStatusCode.test.ts +344 -0
  18. package/errorUtils/__tests__/MissingPluginError.test.ts +113 -0
  19. package/errorUtils/__tests__/NetworkError.test.ts +202 -0
  20. package/errorUtils/__tests__/getParsedResponse.test.ts +188 -0
  21. package/errorUtils/__tests__/invariant.test.ts +112 -0
  22. package/headersUtils/__tests__/headersUtils.test.js +11 -1
  23. package/headersUtils/index.ts +2 -1
  24. package/manifestUtils/defaultManifestConfigurations/player.js +6 -16
  25. package/manifestUtils/platformIsTV.js +13 -0
  26. package/numberUtils/__tests__/toNumber.test.ts +27 -0
  27. package/numberUtils/__tests__/toPositiveNumber.test.ts +193 -0
  28. package/numberUtils/index.ts +23 -1
  29. package/package.json +2 -2
  30. package/reactHooks/analytics/__tests__/useSendAnalyticsOnPress.test.ts +537 -0
  31. package/reactHooks/dev/__tests__/useReRenderLog.test.ts +188 -0
  32. package/reactHooks/device/useIsTablet.tsx +14 -19
  33. package/reactHooks/events/index.ts +20 -0
  34. package/reactHooks/feed/index.ts +0 -2
  35. package/reactHooks/feed/useInflatedUrl.ts +1 -1
  36. package/reactHooks/index.ts +2 -0
  37. package/reactHooks/resolvers/useComponentResolver.ts +11 -1
  38. package/reactHooks/state/__tests__/useComponentScreenState.test.ts +246 -0
  39. package/reactHooks/state/index.ts +2 -0
  40. package/reactHooks/state/useComponentScreenState.ts +45 -0
  41. package/reactHooks/ui/__tests__/useFadeOutWhenBlurred.test.ts +580 -0
  42. package/rectUtils/__tests__/index.test.ts +549 -0
  43. package/rectUtils/index.ts +2 -2
  44. package/refreshUtils/RefreshCoordinator/__tests__/refreshCoordinator.test.ts +161 -0
  45. package/refreshUtils/RefreshCoordinator/index.ts +216 -0
  46. package/refreshUtils/RefreshCoordinator/utils/__tests__/getDataRefreshConfig.test.ts +104 -0
  47. package/refreshUtils/RefreshCoordinator/utils/index.ts +29 -0
  48. package/screenPickerUtils/__tests__/index.test.ts +333 -0
  49. package/screenPickerUtils/index.ts +5 -0
  50. package/screenUtils/index.ts +3 -0
  51. package/time/__tests__/BackgroundTimer.test.ts +156 -0
  52. package/time/__tests__/Timer.test.ts +236 -0
  53. package/typeGuards/__tests__/isString.test.ts +21 -0
  54. package/typeGuards/index.ts +4 -0
  55. package/utils/__tests__/clone.test.ts +158 -0
  56. package/utils/__tests__/path.test.ts +7 -0
  57. package/utils/clone.ts +7 -0
  58. package/utils/index.ts +2 -1
  59. package/reactHooks/componentsMap/index.ts +0 -55
  60. package/reactHooks/feed/__tests__/useFeedRefresh.test.tsx +0 -75
  61. package/reactHooks/feed/useFeedRefresh.tsx +0 -65
@@ -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
 
@@ -373,3 +373,49 @@ describe("addNode", () => {
373
373
  checkParents(tree.root);
374
374
  });
375
375
  });
376
+
377
+ describe("findInTree", () => {
378
+ function createNode(id, children) {
379
+ return {
380
+ id,
381
+ children,
382
+ };
383
+ }
384
+
385
+ it("returns a direct child match from root children", () => {
386
+ const tree = new Tree(treeLoaded);
387
+ const direct = createNode("direct-node");
388
+
389
+ tree.root.children = [direct];
390
+
391
+ expect(tree.findInTree("direct-node")).toEqual(direct);
392
+ });
393
+
394
+ it("returns a nested descendant match", () => {
395
+ const tree = new Tree(treeLoaded);
396
+ const nested = createNode("nested-node");
397
+ const intermediate = createNode("intermediate-node", [nested]);
398
+ const rootNode = createNode("root-node", [intermediate]);
399
+
400
+ tree.root.children = [rootNode];
401
+
402
+ expect(tree.findInTree("nested-node")).toEqual(nested);
403
+ });
404
+
405
+ it("returns null when node id does not exist", () => {
406
+ const tree = new Tree(treeLoaded);
407
+ const leaf = createNode("leaf-node");
408
+ const rootNode = createNode("root-node", [leaf]);
409
+
410
+ tree.root.children = [rootNode];
411
+
412
+ expect(tree.findInTree("missing-node")).toEqual(null);
413
+ });
414
+
415
+ it("returns null when tree has no children", () => {
416
+ const tree = new Tree(treeLoaded);
417
+ tree.root.children = null;
418
+
419
+ expect(tree.findInTree("any-node")).toEqual(null);
420
+ });
421
+ });
@@ -205,31 +205,31 @@ export class Tree {
205
205
  * @returns founded node or null
206
206
  */
207
207
  findInTree(id) {
208
- const retVal = null;
209
-
210
- return this.findInArray(id, this.root.children, retVal);
208
+ return this.findInArray(id, this.root.children);
211
209
  }
212
210
 
213
- findInArray(id, children, retVal) {
214
- if (!retVal && children) {
215
- retVal = children.find((obj) => obj.id === id);
211
+ findInArray(id, children) {
212
+ if (!children) {
213
+ return null;
214
+ }
216
215
 
217
- if (!retVal) {
218
- children.forEach((child) => {
219
- if (child.children) {
220
- retVal = this.findInArray(id, child.children, retVal);
216
+ const directMatch = children.find((obj) => obj.id === id);
221
217
 
222
- if (retVal) {
223
- return retVal;
224
- }
225
- }
226
- });
227
- } else {
228
- return retVal;
218
+ if (directMatch) {
219
+ return directMatch;
220
+ }
221
+
222
+ for (const child of children) {
223
+ if (child.children) {
224
+ const nestedMatch = this.findInArray(id, child.children);
225
+
226
+ if (nestedMatch) {
227
+ return nestedMatch;
228
+ }
229
229
  }
230
230
  }
231
231
 
232
- return retVal;
232
+ return null;
233
233
  }
234
234
 
235
235
  /**
@@ -13,7 +13,7 @@ import {
13
13
 
14
14
  import {
15
15
  getFocusableId,
16
- SCREEN_PICKER_CONTAINER,
16
+ isTabsScreenContentContainerId,
17
17
  } from "@applicaster/zapp-react-native-utils/screenPickerUtils";
18
18
 
19
19
  // run check each 300 ms
@@ -24,8 +24,6 @@ const isTopMenu = (node) => startsWith(QUICK_BRICK_NAVBAR, node?.id);
24
24
  const isContent = (node) => startsWith(QUICK_BRICK_CONTENT, node?.id);
25
25
  const isRoot = (node) => node?.id === "root";
26
26
 
27
- const isScrenPicker = (node) => startsWith(SCREEN_PICKER_CONTAINER, node?.id);
28
-
29
27
  type Props = {
30
28
  maxTimeout: number;
31
29
  conditionFn: () => boolean;
@@ -136,7 +134,7 @@ export const isTabsScreenOnContentFocused = (node) => {
136
134
  return false;
137
135
  }
138
136
 
139
- if (isScrenPicker(node)) {
137
+ if (isTabsScreenContentContainerId(node?.id)) {
140
138
  return true;
141
139
  }
142
140
 
@@ -106,9 +106,8 @@ const focusableNativeViewRegistration = ({ focusableView, focusableGroup }) => {
106
106
  );
107
107
  };
108
108
 
109
- export const firstFocusableViewRegistrationFactory = () =>
109
+ export const firstFocusableViewInContentRegistrationFactory = () =>
110
110
  focusableViewRegistrationSubject$.pipe(
111
- take(1), // we care about only first FocusableView registration
112
111
  switchMap((focusableView) =>
113
112
  // start waiting registration of its parent FocusableGroup
114
113
  focusableGroupRegistrationSubject$.pipe(
@@ -126,7 +125,11 @@ export const firstFocusableViewRegistrationFactory = () =>
126
125
  focusableView,
127
126
  focusableGroup,
128
127
  })
129
- )
128
+ ),
129
+ filter(({ focusableView }) =>
130
+ isPartOfContent(focusManager.focusableTree, focusableView.id)
131
+ ),
132
+ take(1) // we care about only first FocusableView registration
130
133
  );
131
134
 
132
135
  // registration on RN level(into RN focusManager)
@@ -85,6 +85,10 @@ export const toDayJSLocaleMap = (code) => {
85
85
  tt: null,
86
86
  "es-LA": "es",
87
87
  "en-UK": "en-gb",
88
+ "en-ZA": null,
89
+ "en-NG": null,
90
+ "en-ZW": null,
91
+ "en-ZM": null,
88
92
  };
89
93
 
90
94
  if (map[code] === null) {
@@ -229,8 +229,9 @@ export class PlayerNative extends Player {
229
229
  };
230
230
 
231
231
  closeNativePlayer = () => {
232
- // TODO: Delete does not work
232
+ // TODO: Delete, does not work (component is null)
233
233
  this.currentPlayerComponent()?.closeNativePlayer?.();
234
+ this.getPlayerModule()?.stopBackgroundPlayback?.();
234
235
  };
235
236
 
236
237
  togglePlayPause = () => {