@applicaster/zapp-react-native-utils 15.0.0-rc.99 → 15.1.0-rc.2

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 (137) hide show
  1. package/actionsExecutor/ActionExecutorContext.tsx +51 -5
  2. package/actionsExecutor/feedDecorator.ts +6 -6
  3. package/adsUtils/index.ts +2 -2
  4. package/analyticsUtils/README.md +1 -1
  5. package/appUtils/HooksManager/__tests__/__snapshots__/hooksManager.test.js.snap +188 -0
  6. package/appUtils/HooksManager/__tests__/hooksManager.test.js +2 -16
  7. package/appUtils/HooksManager/index.ts +45 -10
  8. package/appUtils/RiverFocusManager/{index.ts → index.js} +18 -25
  9. package/appUtils/accessibilityManager/const.ts +0 -4
  10. package/appUtils/accessibilityManager/utils.ts +1 -0
  11. package/appUtils/contextKeysManager/__tests__/getKeys/failure.test.ts +2 -7
  12. package/appUtils/contextKeysManager/__tests__/getKeys/success.test.ts +0 -48
  13. package/appUtils/contextKeysManager/contextResolver.ts +22 -51
  14. package/appUtils/contextKeysManager/index.ts +10 -65
  15. package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +0 -3
  16. package/appUtils/focusManager/index.ios.ts +4 -43
  17. package/appUtils/focusManagerAux/utils/index.ts +3 -5
  18. package/appUtils/focusManagerAux/utils/utils.ios.ts +3 -199
  19. package/appUtils/keyCodes/keys/keys.web.ts +4 -1
  20. package/appUtils/localizationsHelper.ts +4 -0
  21. package/appUtils/orientationHelper.ts +4 -2
  22. package/appUtils/platform/platformUtils.ts +1 -1
  23. package/appUtils/playerManager/index.ts +9 -0
  24. package/appUtils/playerManager/player.ts +1 -5
  25. package/appUtils/playerManager/playerNative.ts +22 -30
  26. package/appUtils/playerManager/usePlayer.tsx +5 -3
  27. package/appUtils/playerManager/usePlayerState.tsx +2 -14
  28. package/cellUtils/__tests__/cellUtils.test.ts +39 -0
  29. package/cellUtils/index.ts +11 -1
  30. package/cloudEventsUtils/index.ts +1 -65
  31. package/configurationUtils/__tests__/manifestKeyParser.test.ts +26 -26
  32. package/dateUtils/__tests__/dayjs.test.ts +0 -3
  33. package/dateUtils/index.ts +2 -0
  34. package/focusManager/aux/index.ts +1 -1
  35. package/headersUtils/__tests__/headersUtils.test.js +1 -11
  36. package/headersUtils/index.ts +1 -2
  37. package/manifestUtils/defaultManifestConfigurations/player.js +7 -75
  38. package/manifestUtils/tvAction/container/index.js +1 -1
  39. package/numberUtils/__tests__/toNumber.test.ts +0 -12
  40. package/numberUtils/index.ts +1 -19
  41. package/package.json +4 -4
  42. package/pluginUtils/index.ts +4 -9
  43. package/reactHooks/advertising/index.ts +2 -2
  44. package/reactHooks/app/__tests__/useAppState.test.ts +1 -1
  45. package/reactHooks/autoscrolling/__tests__/useTrackCurrentAutoScrollingElement.test.ts +1 -1
  46. package/reactHooks/autoscrolling/__tests__/useTrackedView.test.tsx +2 -1
  47. package/reactHooks/casting/index.ts +1 -0
  48. package/reactHooks/casting/useIsCasting.tsx +57 -0
  49. package/reactHooks/cell-click/__tests__/index.test.js +3 -1
  50. package/reactHooks/componentsMap/index.ts +55 -0
  51. package/reactHooks/configuration/__tests__/index.test.tsx +1 -1
  52. package/reactHooks/connection/__tests__/index.test.js +1 -1
  53. package/reactHooks/debugging/__tests__/index.test.js +4 -4
  54. package/reactHooks/device/useIsTablet.tsx +19 -14
  55. package/reactHooks/device/useMemoizedIsTablet.ts +3 -3
  56. package/reactHooks/feed/__tests__/useBatchLoading.test.tsx +23 -32
  57. package/reactHooks/feed/__tests__/useBuildPipesUrl.test.tsx +19 -19
  58. package/reactHooks/feed/__tests__/useEntryScreenId.test.tsx +1 -4
  59. package/reactHooks/feed/__tests__/useFeedLoader.test.tsx +30 -42
  60. package/reactHooks/feed/__tests__/useFeedRefresh.test.tsx +1 -1
  61. package/reactHooks/feed/__tests__/useInflatedUrl.test.tsx +1 -1
  62. package/reactHooks/feed/useBatchLoading.ts +1 -7
  63. package/reactHooks/feed/useEntryScreenId.ts +2 -2
  64. package/reactHooks/feed/useInflatedUrl.ts +1 -1
  65. package/reactHooks/feed/usePipesCacheReset.ts +1 -3
  66. package/reactHooks/flatList/useLoadNextPageIfNeeded.ts +16 -13
  67. package/reactHooks/layout/__tests__/index.test.tsx +1 -1
  68. package/reactHooks/layout/__tests__/useLayoutVersion.test.tsx +1 -1
  69. package/reactHooks/layout/useDimensions/__tests__/{useDimensions.test.tsx → useDimensions.test.ts} +25 -105
  70. package/reactHooks/layout/useDimensions/useDimensions.ts +2 -2
  71. package/reactHooks/navigation/__tests__/index.test.tsx +4 -2
  72. package/reactHooks/navigation/index.ts +6 -7
  73. package/reactHooks/navigation/useRoute.ts +6 -8
  74. package/reactHooks/player/TVSeekControlller/TVSeekController.ts +10 -27
  75. package/reactHooks/player/__tests__/useAutoSeek._test.tsx +1 -1
  76. package/reactHooks/player/__tests__/useTapSeek._test.ts +1 -1
  77. package/reactHooks/resolvers/__tests__/useCellResolver.test.tsx +1 -1
  78. package/reactHooks/resolvers/__tests__/useComponentResolver.test.tsx +1 -1
  79. package/reactHooks/resolvers/useCellResolver.ts +2 -6
  80. package/reactHooks/resolvers/useComponentResolver.ts +13 -9
  81. package/reactHooks/screen/__tests__/useCurrentScreenData.test.tsx +2 -2
  82. package/reactHooks/screen/__tests__/useCurrentScreenIsHook.test.ts +103 -0
  83. package/reactHooks/screen/__tests__/useCurrentScreenIsStartupHook.test.ts +94 -0
  84. package/reactHooks/screen/__tests__/useScreenBackgroundColor.test.tsx +1 -1
  85. package/reactHooks/screen/__tests__/useScreenData.test.tsx +1 -1
  86. package/reactHooks/screen/__tests__/useTargetScreenData.test.tsx +4 -12
  87. package/reactHooks/screen/index.ts +6 -0
  88. package/reactHooks/screen/useCurrentScreenIsHook.ts +9 -0
  89. package/reactHooks/screen/useCurrentScreenIsStartupHook.ts +8 -0
  90. package/reactHooks/screen/useIsStandaloneFullscreen.ts +12 -0
  91. package/reactHooks/screen/useTargetScreenData.ts +2 -4
  92. package/reactHooks/state/__tests__/useComponentScreenState.test.ts +246 -0
  93. package/reactHooks/state/index.ts +2 -0
  94. package/reactHooks/state/useComponentScreenState.ts +45 -0
  95. package/reactHooks/state/useRivers.ts +1 -1
  96. package/reactHooks/usePluginConfiguration.ts +2 -2
  97. package/reactHooks/utils/__tests__/index.test.js +1 -1
  98. package/rectUtils/index.ts +2 -2
  99. package/screenPickerUtils/index.ts +5 -0
  100. package/screenState/__tests__/index.test.ts +1 -1
  101. package/stringUtils/index.ts +1 -1
  102. package/testUtils/index.tsx +21 -30
  103. package/typeGuards/index.ts +0 -4
  104. package/utils/__tests__/clone.test.ts +158 -0
  105. package/utils/clone.ts +7 -0
  106. package/utils/index.ts +1 -13
  107. package/utils/path.ts +3 -6
  108. package/utils/pathOr.ts +1 -5
  109. package/zappFrameworkUtils/HookCallback/callbackNavigationAction.ts +1 -1
  110. package/zappFrameworkUtils/HookCallback/hookCallbackManifestExtensions.config.js +1 -1
  111. package/zappFrameworkUtils/loginPluginUtils.ts +1 -1
  112. package/adsUtils/__tests__/createVMAP.test.ts +0 -419
  113. package/appDataUtils/__tests__/urlScheme.test.ts +0 -678
  114. package/appUtils/focusManagerAux/utils/index.ios.ts +0 -122
  115. package/cloudEventsUtils/__tests__/index.test.ts +0 -529
  116. package/enumUtils/__tests__/getEnumKeyByEnumValue.test.ts +0 -207
  117. package/errorUtils/__tests__/GeneralError.test.ts +0 -97
  118. package/errorUtils/__tests__/HttpStatusCode.test.ts +0 -344
  119. package/errorUtils/__tests__/MissingPluginError.test.ts +0 -113
  120. package/errorUtils/__tests__/NetworkError.test.ts +0 -202
  121. package/errorUtils/__tests__/getParsedResponse.test.ts +0 -188
  122. package/errorUtils/__tests__/invariant.test.ts +0 -112
  123. package/numberUtils/__tests__/toPositiveNumber.test.ts +0 -165
  124. package/reactHooks/analytics/__tests__/useSendAnalyticsOnPress.test.ts +0 -537
  125. package/reactHooks/dev/__tests__/useReRenderLog.test.ts +0 -188
  126. package/reactHooks/ui/__tests__/useFadeOutWhenBlurred.test.ts +0 -580
  127. package/rectUtils/__tests__/index.test.ts +0 -549
  128. package/screenPickerUtils/__tests__/index.test.ts +0 -333
  129. package/searchUtils/const.ts +0 -7
  130. package/searchUtils/index.ts +0 -3
  131. package/time/__tests__/BackgroundTimer.test.ts +0 -156
  132. package/time/__tests__/Timer.test.ts +0 -236
  133. package/typeGuards/__tests__/isString.test.ts +0 -21
  134. package/utils/__tests__/mergeRight.test.ts +0 -48
  135. package/utils/__tests__/selectors.test.ts +0 -124
  136. package/utils/mergeRight.ts +0 -5
  137. package/utils/selectors.ts +0 -46
@@ -1,11 +1,6 @@
1
- import { NativeModules } from "react-native";
2
1
  import { ContextKeysManager } from "../..";
3
2
 
4
3
  describe("Context Keys Manager - getKeys", () => {
5
- beforeEach(() => {
6
- delete NativeModules.ContextResolverBridge;
7
- });
8
-
9
4
  it("returns value if found by getKey", async () => {
10
5
  // setup
11
6
  const keys = ["namespace.key"];
@@ -170,47 +165,4 @@ describe("Context Keys Manager - getKeys", () => {
170
165
  expect(getKey).toHaveBeenCalledTimes(2);
171
166
  expect(getKey.mock.calls).toEqual([[keys[0]], [keys[1]]]);
172
167
  });
173
-
174
- it("returns values from native bridge when available", async () => {
175
- // setup
176
- const keys = ["namespace.key1", "namespace.key2"];
177
-
178
- const contextObj = [
179
- { key: keys[0], required: true },
180
- { key: keys[1], required: false },
181
- ];
182
-
183
- const resolved = {
184
- [keys[0]]: "value1",
185
- [keys[1]]: "value2",
186
- };
187
-
188
- const reactNative = require("react-native");
189
-
190
- const bridgeMock = {
191
- resolveContextKeys: jest.fn().mockResolvedValue(resolved),
192
- };
193
-
194
- reactNative.__setContextResolverBridgeMock(bridgeMock);
195
-
196
- const contextManager = new ContextKeysManager({});
197
- const getKey = jest.spyOn(contextManager, "getKey");
198
-
199
- // run
200
- const result = await contextManager.getKeys(keys, contextObj);
201
-
202
- // verify
203
- const map = new Map();
204
- map.set(keys[0], "value1");
205
- map.set(keys[1], "value2");
206
-
207
- expect(result).toEqual(map);
208
-
209
- expect(bridgeMock.resolveContextKeys).toHaveBeenCalledWith({
210
- [keys[0]]: true,
211
- [keys[1]]: false,
212
- });
213
-
214
- expect(getKey).not.toHaveBeenCalled();
215
- });
216
168
  });
@@ -1,10 +1,8 @@
1
1
  import { ContextKeysManager } from "./index";
2
- import { get, values } from "@applicaster/zapp-react-native-utils/utils";
2
+ import * as R from "ramda";
3
+ import * as _ from "lodash";
3
4
  import { useScreenStateStore } from "../../reactHooks/navigation/useScreenStateStore";
4
5
 
5
- const contextKeyPattern = /@{([^/]+)\/([^}]*)}/;
6
- const contextVariablePattern = /@\{([^}]*)\}/g;
7
-
8
6
  export interface IResolver {
9
7
  resolve: (string) => Promise<string | number | object>;
10
8
  }
@@ -22,7 +20,7 @@ export class EntryResolver implements IResolver {
22
20
  return this.entry;
23
21
  }
24
22
 
25
- return get(this.entry, key.split("."));
23
+ return R.view(R.lensPath(key.split(".")), this.entry);
26
24
  }
27
25
  }
28
26
 
@@ -41,7 +39,7 @@ export class ScreenStateResolver implements IResolver {
41
39
  }
42
40
 
43
41
  if (key.includes(".")) {
44
- return get(screenState, key.split("."));
42
+ return R.view(R.lensPath(key.split(".")), screenState);
45
43
  }
46
44
 
47
45
  return screenState?.[key];
@@ -63,16 +61,21 @@ export const resolveObjectValues = async (
63
61
 
64
62
  const resolvedEntries = await Promise.all(
65
63
  entries.map(async ([key, value]) => {
66
- if (typeof value !== "string" || !value.startsWith("@")) {
64
+ if (typeof value !== "string") {
67
65
  return [key, value];
68
66
  }
69
67
 
70
- const regex = contextKeyPattern;
68
+ if (!value.startsWith("@")) {
69
+ return [key, value];
70
+ }
71
+
72
+ const regex = /@{([^/]+)\/([^}]*)}/;
71
73
 
72
74
  const match = (value as string).match(regex);
73
75
 
74
76
  if (match) {
75
- const [_, contextResolverName, compositeKey] = match;
77
+ const contextResolverName = match[1];
78
+ const compositeKey = match[2];
76
79
 
77
80
  const resolver = exResolvers[contextResolverName] || exResolvers.ctx;
78
81
  const resolvedValue = await resolver.resolve(compositeKey);
@@ -87,50 +90,18 @@ export const resolveObjectValues = async (
87
90
  return Object.fromEntries(resolvedEntries);
88
91
  };
89
92
 
90
- // Simple memoization cache
91
- const extractAtValuesCache = new Map<any, string[]>();
92
-
93
- const flatMapDeep = <T, U>(arr: T[], fn: (value: T) => U | U[]): U[] => {
94
- const result: U[] = [];
93
+ export const extractAtValues = _.memoize((input: any): string[] => {
94
+ return _.flatMapDeep(input, (value: any) => {
95
+ if (_.isString(value)) {
96
+ const matches = value.match(/@\{([^}]*)\}/g);
95
97
 
96
- const flatten = (items: any) => {
97
- for (const item of items) {
98
- if (Array.isArray(item)) {
99
- flatten(item);
100
- } else {
101
- result.push(item);
102
- }
98
+ return matches ? matches.map((match) => match.slice(2, -1)) : [];
103
99
  }
104
- };
105
-
106
- flatten(arr.map(fn));
107
100
 
108
- return result;
109
- };
110
-
111
- export const extractAtValues = (input: any): string[] => {
112
- if (extractAtValuesCache.has(input)) {
113
- return extractAtValuesCache.get(input)!;
114
- }
115
-
116
- const result = flatMapDeep(
117
- Array.isArray(input) ? input : [input],
118
- (value: any) => {
119
- if (typeof value === "string") {
120
- const matches = value.match(contextVariablePattern);
121
-
122
- return matches ? matches.map((match) => match.slice(2, -1)) : [];
123
- }
124
-
125
- if (typeof value === "object" && value !== null) {
126
- return extractAtValues(values(value));
127
- }
128
-
129
- return [];
101
+ if (_.isObject(value)) {
102
+ return extractAtValues(_.values(value));
130
103
  }
131
- );
132
104
 
133
- extractAtValuesCache.set(input, result);
134
-
135
- return result;
136
- };
105
+ return [];
106
+ });
107
+ });
@@ -1,4 +1,4 @@
1
- import { isNil } from "@applicaster/zapp-react-native-utils/utils";
1
+ import * as R from "ramda";
2
2
 
3
3
  import { StorageLevel, StorageType } from "./consts";
4
4
  import {
@@ -13,7 +13,6 @@ import {
13
13
  localStorage as LocalStorage,
14
14
  secureStorage as SecureStorage,
15
15
  } from "./storage";
16
- import { NativeModules } from "react-native";
17
16
 
18
17
  export { StorageLevel };
19
18
 
@@ -155,65 +154,11 @@ export class ContextKeysManager {
155
154
  }
156
155
 
157
156
  public async getKeys(
158
- keys: Array<KeyName>,
159
- contextObj?: { key: string; required?: boolean }[]
157
+ keys: Array<KeyName>
160
158
  ): Promise<Map<KeyName, ValueOrNothing>> {
161
- if (NativeModules.ContextResolverBridge) {
162
- const keysObj: Record<string, boolean> = {};
159
+ const values = await Promise.all(keys.map((key) => this.getKey(key)));
163
160
 
164
- const requiredByKey = new Map(
165
- contextObj?.map((item) => [item.key, item.required ?? false]) ?? []
166
- );
167
-
168
- let hasResolvableKeys = false;
169
-
170
- const normalizedKeys: Array<{
171
- original: KeyName;
172
- normalized: string | null;
173
- }> = [];
174
-
175
- for (const key of keys) {
176
- const {
177
- isValid: isValidKey,
178
- key: parsedKey,
179
- namespace: parsedNamespace,
180
- } = this.parseKey(key);
181
-
182
- if (!isValidKey) {
183
- normalizedKeys.push({ original: key, normalized: null });
184
- continue;
185
- }
186
-
187
- const normalized = buildNamespaceKey(parsedKey, parsedNamespace);
188
-
189
- keysObj[normalized] = requiredByKey.get(normalized) ?? false;
190
- hasResolvableKeys = true;
191
- normalizedKeys.push({ original: key, normalized });
192
- }
193
-
194
- if (!hasResolvableKeys) {
195
- return new Map(
196
- normalizedKeys.map(({ original }) => [original, NOTHING])
197
- );
198
- }
199
-
200
- const res =
201
- await NativeModules.ContextResolverBridge.resolveContextKeys(keysObj);
202
-
203
- const resolved = res ?? {};
204
-
205
- return new Map(
206
- normalizedKeys.map(({ original, normalized }) => {
207
- if (!normalized) return [original, NOTHING];
208
-
209
- return [original, resolved[normalized] ?? NOTHING];
210
- })
211
- );
212
- } else {
213
- const values = await Promise.all(keys.map((key) => this.getKey(key)));
214
-
215
- return new Map(keys.map((key, index) => [key, values[index]]));
216
- }
161
+ return new Map(R.zip(keys, values));
217
162
  }
218
163
 
219
164
  public async getKey(key: KeyName): Promise<ValueOrNothing> {
@@ -236,7 +181,7 @@ export class ContextKeysManager {
236
181
  parsedNamespace
237
182
  );
238
183
 
239
- if (!isNil(resultByReference)) {
184
+ if (!R.isNil(resultByReference)) {
240
185
  return resultByReference;
241
186
  }
242
187
 
@@ -247,7 +192,7 @@ export class ContextKeysManager {
247
192
  parsedNamespace
248
193
  );
249
194
 
250
- if (!isNil(resultFromSessionStorage)) {
195
+ if (!R.isNil(resultFromSessionStorage)) {
251
196
  return resultFromSessionStorage;
252
197
  }
253
198
 
@@ -256,7 +201,7 @@ export class ContextKeysManager {
256
201
  parsedNamespace
257
202
  );
258
203
 
259
- if (!isNil(resultFromLocalStorage)) {
204
+ if (!R.isNil(resultFromLocalStorage)) {
260
205
  return resultFromLocalStorage;
261
206
  }
262
207
 
@@ -265,7 +210,7 @@ export class ContextKeysManager {
265
210
  parsedNamespace
266
211
  );
267
212
 
268
- if (!isNil(resultFromSecureStorage)) {
213
+ if (!R.isNil(resultFromSecureStorage)) {
269
214
  return resultFromSecureStorage;
270
215
  }
271
216
 
@@ -330,7 +275,7 @@ export class ContextKeysManager {
330
275
  keysProp.map((keyProp) => this.setKey(keyProp))
331
276
  );
332
277
 
333
- return new Map(keys.map((key, index) => [key, values[index]]));
278
+ return new Map(R.zip(keys, values));
334
279
  }
335
280
 
336
281
  // when succeed saving - return true
@@ -439,7 +384,7 @@ export class ContextKeysManager {
439
384
  public async removeKeys(keys: KeyName[]): Promise<Map<KeyName, boolean>> {
440
385
  const values = await Promise.all(keys.map((key) => this.removeKey(key)));
441
386
 
442
- return new Map(keys.map((key, index) => [key, values[index]]));
387
+ return new Map(R.zip(keys, values));
443
388
  }
444
389
  // REMOVE
445
390
  }
@@ -71,9 +71,6 @@ exports[`focusManagerIOS should be defined 1`] = `
71
71
  "invokeHandler": [Function],
72
72
  "isChildOf": [Function],
73
73
  "isFocusOn": [Function],
74
- "isFocusOnContent": [Function],
75
- "isFocusOnMenu": [Function],
76
- "isFocusOnTabsScreenContent": [Function],
77
74
  "isGroupItemFocused": [Function],
78
75
  "moveFocus": [Function],
79
76
  "on": [Function],
@@ -4,11 +4,7 @@ import * as R from "ramda";
4
4
  import {
5
5
  isCurrentFocusOn,
6
6
  isChildOf as isChildOfUtils,
7
- isPartOfMenu,
8
- isPartOfContent,
9
- isPartOfTabsScreenContent,
10
- } from "../focusManagerAux/utils/index.ios";
11
-
7
+ } from "../focusManagerAux/utils";
12
8
  import { Tree } from "./treeDataStructure/Tree";
13
9
  import { findFocusableNode } from "./treeDataStructure/Utils";
14
10
  import { subscriber } from "../../functionUtils";
@@ -192,15 +188,9 @@ export const focusManager = (function () {
192
188
  function register({ id, component }) {
193
189
  const { isGroup = false } = component;
194
190
 
195
- if (isGroup) {
196
- registerGroup(id, component);
197
- } else {
198
- registerItem(id, component);
199
- }
191
+ emitRegistered(id);
200
192
 
201
- const groupId = component?.props?.groupId;
202
-
203
- emitRegistered({ id, groupId, isGroup });
193
+ return isGroup ? registerGroup(id, component) : registerItem(id, component);
204
194
  }
205
195
 
206
196
  function unregister(id, { group = false } = {}) {
@@ -283,9 +273,7 @@ export const focusManager = (function () {
283
273
  function setFocus(
284
274
  id: string,
285
275
  direction?: FocusManager.IOS.Direction,
286
- options?: Partial<{
287
- groupFocusedChanged: boolean;
288
- }>,
276
+ options?: Partial<{ groupFocusedChanged: boolean }>,
289
277
  callback?: any
290
278
  ) {
291
279
  blur(direction);
@@ -424,30 +412,6 @@ export const focusManager = (function () {
424
412
  return id && isCurrentFocusOn(id, currentFocusNode);
425
413
  }
426
414
 
427
- function isFocusOnMenu(): boolean {
428
- const currentFocusable = getCurrentFocus();
429
-
430
- return isPartOfMenu(focusableTree, currentFocusable?.props?.id);
431
- }
432
-
433
- function isFocusOnContent(): boolean {
434
- const currentFocusable = getCurrentFocus();
435
-
436
- return isPartOfContent(focusableTree, currentFocusable?.props?.id);
437
- }
438
-
439
- function isFocusOnTabsScreenContent(
440
- screenPickerContentContainerId: string
441
- ): boolean {
442
- const currentFocusable = getCurrentFocus();
443
-
444
- return isPartOfTabsScreenContent(
445
- focusableTree,
446
- screenPickerContentContainerId,
447
- currentFocusable?.props?.id
448
- );
449
- }
450
-
451
415
  function isChildOf(childId, parentId): boolean {
452
416
  return isChildOfUtils(focusableTree, childId, parentId);
453
417
  }
@@ -474,9 +438,6 @@ export const focusManager = (function () {
474
438
  isGroupItemFocused,
475
439
  getPreferredFocusChild,
476
440
  isFocusOn,
477
- isFocusOnMenu,
478
- isFocusOnContent,
479
- isFocusOnTabsScreenContent,
480
441
  isChildOf,
481
442
  };
482
443
  })();
@@ -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;
@@ -102,7 +100,7 @@ export const getNavbarNode = (focusableTree) => {
102
100
 
103
101
  export const waitForContent = (focusableTree) => {
104
102
  const contentHasAnyChildren = (): boolean => {
105
- const countOfChildren = pathOr<number>(
103
+ const countOfChildren = pathOr(
106
104
  0,
107
105
  ["children", "length"],
108
106
  getContentNode(focusableTree)
@@ -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
 
@@ -1,9 +1,7 @@
1
- import { ReplaySubject, Subject } from "rxjs";
2
- import { filter, switchMap, take, withLatestFrom, map } from "rxjs/operators";
3
-
1
+ import { ReplaySubject } from "rxjs";
2
+ import { filter } from "rxjs/operators";
4
3
  import { BUTTON_PREFIX } from "@applicaster/zapp-react-native-ui-components/Components/MasterCell/DefaultComponents/tv/TvActionButtons/const";
5
4
  import { focusManager } from "@applicaster/zapp-react-native-utils/appUtils/focusManager/index.ios";
6
- import { isPartOfMenu, isPartOfContent } from "./index.ios";
7
5
 
8
6
  type FocusableID = string;
9
7
  type RegistrationEvent = {
@@ -11,25 +9,6 @@ type RegistrationEvent = {
11
9
  registered: boolean;
12
10
  };
13
11
 
14
- let focusableViewRegistrationSubject$ = new Subject<{
15
- id: FocusableID;
16
- groupId: FocusableID;
17
- }>();
18
-
19
- let focusableGroupRegistrationSubject$ = new ReplaySubject<{
20
- id: FocusableID;
21
- }>();
22
-
23
- let focusableNativeViewRegistrationSubject$ = new Subject<{
24
- id: FocusableID;
25
- groupId: FocusableID;
26
- }>();
27
-
28
- let focusableNativeGroupRegistrationSubject$ = new ReplaySubject<{
29
- id: FocusableID;
30
- groupId: FocusableID;
31
- }>();
32
-
33
12
  const isFocusableButton = (id: Option<FocusableID>): boolean =>
34
13
  id && id.includes?.(BUTTON_PREFIX);
35
14
 
@@ -43,189 +22,14 @@ export const focusableButtonsRegistration$ = (focusableGroupId: string) =>
43
22
  )
44
23
  );
45
24
 
46
- export const resetFocusableRegistration = () => {
47
- // complete the old subject so subscribers are notified and resources are freed
48
- if (!focusableViewRegistrationSubject$.closed) {
49
- focusableViewRegistrationSubject$.complete();
50
- }
51
-
52
- if (!focusableGroupRegistrationSubject$.closed) {
53
- focusableGroupRegistrationSubject$.complete();
54
- }
55
-
56
- if (!focusableNativeViewRegistrationSubject$.closed) {
57
- focusableNativeViewRegistrationSubject$.complete();
58
- }
59
-
60
- if (!focusableNativeGroupRegistrationSubject$.closed) {
61
- focusableNativeGroupRegistrationSubject$.complete();
62
- }
63
-
64
- focusableViewRegistrationSubject$ = new Subject<{
65
- id: FocusableID;
66
- groupId: FocusableID;
67
- }>();
68
-
69
- focusableGroupRegistrationSubject$ = new ReplaySubject<{
70
- id: FocusableID;
71
- }>();
72
-
73
- focusableNativeViewRegistrationSubject$ = new Subject<{
74
- id: FocusableID;
75
- groupId: FocusableID;
76
- }>();
77
-
78
- focusableNativeGroupRegistrationSubject$ = new ReplaySubject<{
79
- id: FocusableID;
80
- groupId: FocusableID;
81
- }>();
82
- };
83
-
84
- const focusableNativeViewRegistration = ({ focusableView, focusableGroup }) => {
85
- return focusableNativeViewRegistrationSubject$.pipe(
86
- filter(
87
- (focusableNativeView) => focusableNativeView.id === focusableView.id
88
- ),
89
- take(1),
90
- switchMap((focusableNativeView) =>
91
- // start waiting registration of its parent FocusableNativeGroup
92
- focusableNativeGroupRegistrationSubject$.pipe(
93
- filter(
94
- (focusableNativeGroup) =>
95
- focusableNativeGroup.id === focusableNativeView.groupId
96
- ),
97
- take(1),
98
- map((focusableNativeGroup) => ({
99
- focusableNativeGroup,
100
- focusableNativeView,
101
- focusableView,
102
- focusableGroup,
103
- }))
104
- )
105
- )
106
- );
107
- };
108
-
109
- export const firstFocusableViewRegistrationFactory = () =>
110
- focusableViewRegistrationSubject$.pipe(
111
- take(1), // we care about only first FocusableView registration
112
- switchMap((focusableView) =>
113
- // start waiting registration of its parent FocusableGroup
114
- focusableGroupRegistrationSubject$.pipe(
115
- filter((focusableGroup) => focusableGroup.id === focusableView.groupId),
116
- take(1),
117
- map((focusableGroup) => ({
118
- focusableView,
119
- focusableGroup,
120
- }))
121
- )
122
- ),
123
- // start waiting registration for FocusableNativeView and its parent FocusableNativeGroup
124
- switchMap(({ focusableView, focusableGroup }) =>
125
- focusableNativeViewRegistration({
126
- focusableView,
127
- focusableGroup,
128
- })
129
- )
130
- );
131
-
132
- // registration on RN level(into RN focusManager)
133
- export const emitRegistered = ({
134
- id,
135
- groupId,
136
- isGroup,
137
- }: {
138
- id: Option<FocusableID>;
139
- groupId: Option<FocusableID>;
140
- isGroup: boolean;
141
- }): void => {
25
+ export const emitRegistered = (id: Option<FocusableID>): void => {
142
26
  if (isFocusableButton(id)) {
143
27
  registeredSubject$.next({ id, registered: true });
144
28
  }
145
-
146
- if (isGroup && id) {
147
- focusableGroupRegistrationSubject$.next({ id });
148
- }
149
-
150
- if (!isGroup && id && groupId) {
151
- focusableViewRegistrationSubject$.next({ id, groupId });
152
- }
153
29
  };
154
30
 
155
- // unregistration on RN level(into RN focusManager)
156
31
  export const emitUnregistered = (id: Option<FocusableID>): void => {
157
32
  if (isFocusableButton(id)) {
158
33
  registeredSubject$.next({ id, registered: false });
159
34
  }
160
35
  };
161
-
162
- // registration focusableNativeView and focusableNativeGroup
163
- export const emitNativeRegistered = ({
164
- id,
165
- groupId,
166
- isGroup,
167
- }: {
168
- id: Option<FocusableID>;
169
- groupId: Option<FocusableID>;
170
- isGroup: boolean;
171
- }): void => {
172
- if (!isGroup && id && groupId) {
173
- focusableNativeViewRegistrationSubject$.next({ id, groupId });
174
- }
175
-
176
- if (isGroup && id && groupId) {
177
- focusableNativeGroupRegistrationSubject$.next({ id, groupId });
178
- }
179
- };
180
-
181
- // /////
182
-
183
- const focusedSubject$ = new Subject<FocusableID>();
184
-
185
- const focused$ = focusedSubject$.asObservable();
186
-
187
- export const emitFocused = (id: FocusableID): void => {
188
- focusedSubject$.next(id);
189
- };
190
-
191
- export const topMenuItemFocused$ = focused$.pipe(
192
- filter((id) => id && isPartOfMenu(focusManager.focusableTree, id))
193
- );
194
-
195
- export const contentFocused$ = focused$.pipe(
196
- filter((id) => {
197
- const isContent = isPartOfContent(focusManager.focusableTree, id);
198
-
199
- return id && isContent;
200
- })
201
- );
202
-
203
- const createFocusableRegistry = () => {
204
- const subject$ = new ReplaySubject<FocusableID | undefined>(1);
205
-
206
- return {
207
- observable$: subject$.asObservable(),
208
- register: (id: FocusableID) => {
209
- // save focusable_id on registration
210
- subject$.next(id);
211
- },
212
- unregister: () => {
213
- // reset focusable_id on unregistration
214
- subject$.next(undefined);
215
- },
216
- };
217
- };
218
-
219
- /// HOME_TOP_MENU_ITEM
220
- export const HomeTopMenuItemRegistry = createFocusableRegistry();
221
-
222
- export const homeTopMenuItemFocused$ = topMenuItemFocused$.pipe(
223
- withLatestFrom(HomeTopMenuItemRegistry.observable$),
224
- filter(([id, homeId]) => id === homeId)
225
- );
226
-
227
- /// SCREEN_PICKER
228
- export const ScreenPickerContentContainerRegistry = createFocusableRegistry();
229
-
230
- /// SEARCH_INPUT
231
- export const SearchInputRegistry = createFocusableRegistry();
@@ -10,7 +10,10 @@ import { Platform } from "react-native";
10
10
  * platformKeys[Platform.OS] should only include keys
11
11
  * that are unique to that platform, i.e. Exit: { keyCode: 10182 }
12
12
  */
13
- export const KEYS = Object.assign(platformKeys.web, platformKeys[Platform.OS]);
13
+ export const KEYS = Object.assign(
14
+ platformKeys["web"],
15
+ platformKeys[Platform.OS]
16
+ );
14
17
 
15
18
  export const ARROW_KEYS = [
16
19
  KEYS.ArrowUp,
@@ -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) {