@applicaster/zapp-react-native-utils 13.0.0-alpha.1744140354 → 13.0.0-alpha.1756731121

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 (117) hide show
  1. package/README.md +0 -10
  2. package/actionsExecutor/ActionExecutorContext.tsx +130 -7
  3. package/actionsExecutor/consts.ts +4 -0
  4. package/analyticsUtils/currentScreenProperities.ts +6 -4
  5. package/appUtils/HooksManager/Hook.ts +6 -2
  6. package/appUtils/HooksManager/index.ts +3 -1
  7. package/appUtils/HooksManager/types.ts +2 -2
  8. package/appUtils/__tests__/__snapshots__/localizationsHelper.test.ts.snap +151 -0
  9. package/appUtils/__tests__/allZappLocales.ts +79 -0
  10. package/appUtils/__tests__/{localizationsHelper.test.js → localizationsHelper.test.ts} +11 -0
  11. package/appUtils/contextKeysManager/contextResolver.ts +7 -14
  12. package/appUtils/contextKeysManager/index.ts +2 -2
  13. package/appUtils/contextKeysManager/utils/index.ts +2 -1
  14. package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +3 -0
  15. package/appUtils/focusManager/index.ios.ts +14 -4
  16. package/appUtils/focusManager/index.ts +24 -12
  17. package/appUtils/focusManager/utils/__tests__/findChild.test.ts +35 -0
  18. package/appUtils/focusManager/utils/index.ts +5 -0
  19. package/appUtils/keyCodes/index.ts +11 -7
  20. package/appUtils/localizationsHelper.ts +31 -0
  21. package/appUtils/orientationHelper.ts +11 -13
  22. package/appUtils/platform/platformUtils.ts +30 -3
  23. package/appUtils/playerManager/index.ts +1 -1
  24. package/appUtils/playerManager/player.ts +26 -14
  25. package/appUtils/playerManager/playerHooks/usePlayerCurrentTime.tsx +11 -7
  26. package/appUtils/playerManager/playerNative.ts +18 -3
  27. package/appUtils/playerManager/usePlayerTitleSummaryOverlay.tsx +7 -1
  28. package/cellUtils/index.ts +9 -5
  29. package/componentsUtils/__tests__/isFirstComponentGallery.test.ts +33 -0
  30. package/componentsUtils/__tests__/isFirstComponentScreenPicker.test.ts +33 -0
  31. package/componentsUtils/__tests__/isGallery.test.ts +33 -0
  32. package/componentsUtils/__tests__/isScreenPicker.test.ts +33 -0
  33. package/componentsUtils/index.ts +39 -0
  34. package/dateUtils/index.ts +19 -0
  35. package/equalUtils/__tests__/isEqual/combination.test.ts +263 -0
  36. package/equalUtils/index.ts +49 -30
  37. package/focusManager/FocusManager.ts +14 -2
  38. package/focusManager/index.ts +23 -4
  39. package/functionUtils/index.ts +46 -8
  40. package/idleUtils/__tests__/withTimeout$.test.ts +37 -0
  41. package/idleUtils/index.ts +1 -1
  42. package/idleUtils/withTimeout.ts +15 -2
  43. package/index.d.ts +0 -12
  44. package/localizationUtils/index.ts +8 -13
  45. package/manifestUtils/__tests__/createConfig.test.js +0 -2
  46. package/manifestUtils/defaultManifestConfigurations/generalContent.js +13 -0
  47. package/manifestUtils/defaultManifestConfigurations/player.js +10 -4
  48. package/manifestUtils/fonts/index.js +5 -6
  49. package/manifestUtils/index.js +2 -0
  50. package/manifestUtils/keys.js +27 -2
  51. package/manifestUtils/sharedConfiguration/screenPicker/__tests__/utils.test.js +304 -0
  52. package/manifestUtils/sharedConfiguration/screenPicker/stylesFields.js +875 -0
  53. package/manifestUtils/sharedConfiguration/screenPicker/utils.js +130 -0
  54. package/modalState/__tests__/index.test.ts +51 -0
  55. package/modalState/index.ts +32 -2
  56. package/navigationUtils/__tests__/__snapshots__/navigationUtils.test.js.snap +1 -0
  57. package/navigationUtils/index.ts +6 -4
  58. package/numberUtils/__tests__/toPositiveNumberWithDefault.test.ts +23 -3
  59. package/numberUtils/index.ts +11 -5
  60. package/package.json +4 -10
  61. package/playerUtils/configurationGenerator.ts +9 -11
  62. package/reactHooks/advertising/index.ts +5 -5
  63. package/reactHooks/autoscrolling/__tests__/useTrackedView.test.tsx +5 -7
  64. package/reactHooks/autoscrolling/useTrackedView.ts +12 -1
  65. package/reactHooks/feed/useBatchLoading.ts +10 -12
  66. package/reactHooks/feed/useFeedLoader.tsx +17 -8
  67. package/reactHooks/hookModal/hooks/useHookModalScreenData.ts +39 -0
  68. package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.test.js +1 -1
  69. package/reactHooks/layout/useDimensions/useDimensions.ts +8 -0
  70. package/reactHooks/navigation/__mocks__/useNavigation.ts +3 -0
  71. package/reactHooks/navigation/__tests__/index.test.tsx +6 -17
  72. package/reactHooks/navigation/{useGetTabBarHeight.ts → getTabBarHeight.ts} +2 -4
  73. package/reactHooks/navigation/index.ts +13 -23
  74. package/reactHooks/navigation/useGetBottomTabBarHeight.ts +10 -3
  75. package/reactHooks/navigation/useNavigationPluginData.ts +8 -4
  76. package/reactHooks/navigation/useNavigationType.ts +4 -2
  77. package/reactHooks/navigation/useProfilerLogging.ts +15 -0
  78. package/reactHooks/navigation/useRoute.ts +4 -6
  79. package/reactHooks/screen/__tests__/useScreenBackgroundColor.test.tsx +69 -0
  80. package/reactHooks/screen/useScreenBackgroundColor.ts +3 -15
  81. package/reactHooks/state/useRefWithInitialValue.ts +14 -0
  82. package/reactHooks/state/useStateFromSubscribe.ts +23 -0
  83. package/reactHooks/useListenEventBusEvent.ts +1 -1
  84. package/reactHooks/usePluginConfiguration.ts +1 -1
  85. package/reactHooks/useSubscriberFor.ts +4 -3
  86. package/reactUtils/__tests__/__snapshots__/reactUtilsHelpers.test.js.snap +16 -4
  87. package/reactUtils/__tests__/reactUtils.test.js +1 -19
  88. package/reactUtils/__tests__/reactUtilsHelpers.test.js +72 -71
  89. package/reactUtils/createContext/__tests__/__snapshots__/helpers.test.js.snap +6 -72
  90. package/reactUtils/createContext/__tests__/__snapshots__/provider.test.js.snap +3 -28
  91. package/reactUtils/createContext/__tests__/__snapshots__/withConsumer.test.js.snap +3 -4
  92. package/reactUtils/createContext/__tests__/__snapshots__/withProvider.test.js.snap +7 -3
  93. package/reactUtils/createContext/__tests__/helpers.test.js +107 -121
  94. package/reactUtils/createContext/__tests__/{index.test.js → index.test.ts} +2 -2
  95. package/reactUtils/createContext/__tests__/provider.test.js +4 -6
  96. package/reactUtils/createContext/__tests__/withConsumer.test.js +12 -12
  97. package/reactUtils/createContext/__tests__/withProvider.test.js +4 -4
  98. package/reactUtils/createContext/helpers.ts +6 -1
  99. package/reactUtils/createContext/index.ts +11 -25
  100. package/reactUtils/index.ts +9 -11
  101. package/screenState/index.ts +24 -10
  102. package/services/js2native.ts +673 -0
  103. package/testUtils/index.tsx +0 -10
  104. package/theme/index.ts +1 -1
  105. package/time/BackgroundTimer.ts +55 -0
  106. package/time/Timer.ts +9 -6
  107. package/types.ts +1 -0
  108. package/utils/README.md +30 -0
  109. package/utils/chunk.ts +5 -0
  110. package/utils/index.ts +5 -0
  111. package/utils/times.ts +5 -0
  112. package/zappFrameworkUtils/localStorageHelper.ts +6 -0
  113. package/zappFrameworkUtils/loginPluginUtils.ts +6 -2
  114. package/zappFrameworkUtils/presentPluginOneTime.ts +2 -3
  115. package/zappFrameworkUtils/types.ts +11 -0
  116. package/reactUtils/createContext/__tests__/index-no-react.test.js +0 -27
  117. /package/reactUtils/createContext/__tests__/__snapshots__/{index.test.js.snap → index.test.ts.snap} +0 -0
package/README.md CHANGED
@@ -376,16 +376,6 @@ useEffect(() => {
376
376
  }, []);
377
377
  ```
378
378
 
379
- ### testUtils
380
-
381
- `@applicaster/zapp-react-native-utils/testUtils`
382
-
383
- - `testIDEquals: (testId: any) => boolean | { width: number, height: number }` - Function to be used in tandem with enzyme findWhere
384
-
385
- ```javascript
386
- wrapper.findWhere(testIDEquals("text"));
387
- ```
388
-
389
379
  ### appUtils - contextKeysManager
390
380
 
391
381
  `@applicaster/zapp-react-native-utils/appUtils/contextKeyManager`
@@ -1,6 +1,6 @@
1
1
  /// <reference types="@applicaster/applicaster-types" />
2
2
  import { localStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/LocalStorage";
3
- import React, { createContext, useMemo } from "react";
3
+ import React, { createContext, useEffect, useMemo } from "react";
4
4
  import {
5
5
  actionExecutor as _actionExecutor,
6
6
  ActionResult,
@@ -19,8 +19,17 @@ import {
19
19
  EntryResolver,
20
20
  resolveObjectValues,
21
21
  } from "../appUtils/contextKeysManager/contextResolver";
22
+ import { useNavigation } from "../reactHooks";
23
+ import { get } from "lodash";
22
24
 
23
- const { log_error, log_info } = createLogger({
25
+ import {
26
+ useContentTypes,
27
+ usePickFromState,
28
+ } from "@applicaster/zapp-react-native-redux/hooks";
29
+ import { TOGGLE_FLAG_MAX_ITEMS_REACHED_EVENT } from "./consts";
30
+ import { postEvent } from "../reactHooks/useSubscriberFor";
31
+
32
+ export const { log_error, log_info, log_debug } = createLogger({
24
33
  subsystem: "ActionExecutorContext",
25
34
  category: "General",
26
35
  });
@@ -51,6 +60,35 @@ type Props = {
51
60
  children: React.ReactNode;
52
61
  };
53
62
 
63
+ function findParentComponent(
64
+ childId: string,
65
+ parent: ZappRiver | ZappUIComponent
66
+ ): ZappRiver | ZappUIComponent | null {
67
+ for (const child of parent.ui_components) {
68
+ if (child.id === childId) return parent;
69
+
70
+ if (child.ui_components) {
71
+ const found = findParentComponent(childId, child);
72
+ if (found) return found;
73
+ }
74
+ }
75
+
76
+ return null;
77
+ }
78
+
79
+ // send all data just in case (like for message string formatting)
80
+ // Type is not exported for now
81
+ type MaxTagsReachedEvent = {
82
+ selectedItems: string[];
83
+ maxItems: number;
84
+ tag: string;
85
+ keyNamespace: string;
86
+ };
87
+
88
+ async function onMaxTagsReached(data: MaxTagsReachedEvent) {
89
+ postEvent(TOGGLE_FLAG_MAX_ITEMS_REACHED_EVENT, [data]);
90
+ }
91
+
54
92
  const prepareDefaultActions = (actionExecutor) => {
55
93
  actionExecutor.registerAction("localStorageSet", async (action) => {
56
94
  const namespaces = action.options.content;
@@ -65,11 +103,13 @@ const prepareDefaultActions = (actionExecutor) => {
65
103
  async (_action, context) => {
66
104
  const dispatch = appStore.getDispatch();
67
105
 
68
- log_info("handleAction: refreshComponent event");
106
+ const dataSource =
107
+ context?.component?.data?.source ||
108
+ findParentComponent(context?.component.id, context?.screenData)?.data
109
+ ?.source;
69
110
 
70
- const dataSource = context?.component?.data?.source;
111
+ log_info(`handleAction: refreshComponent for dataSource:${dataSource}`);
71
112
 
72
- // TODO: Later we can pass component ids to do refresh instead of current one
73
113
  // TODO: In theory we should wait callback to complete, before completing the action, but now it's not needed
74
114
  // TODO: handle focused item removal
75
115
  dispatch(
@@ -165,9 +205,33 @@ const prepareDefaultActions = (actionExecutor) => {
165
205
 
166
206
  actionExecutor.registerAction(
167
207
  "localStorageToggleFlag",
168
- async (action: ActionType, entry?: ZappEntry): Promise<ActionResult> => {
208
+ async (
209
+ action: ActionType,
210
+ context?: Record<string, any>
211
+ ): Promise<ActionResult> => {
212
+ if (!context) {
213
+ log_error(
214
+ "handleAction: localStorageToggleFlag action missing context"
215
+ );
216
+
217
+ return ActionResult.Error;
218
+ }
219
+
220
+ const entry = context?.entry as ZappEntry;
221
+
222
+ if (!entry) {
223
+ log_error(
224
+ "handleAction: localStorageToggleFlag action missing entry. Entry is required to get the tag."
225
+ );
226
+
227
+ return ActionResult.Error;
228
+ }
229
+
230
+ const tag = action.options?.selector
231
+ ? get(entry, action.options.selector)
232
+ : (entry.extensions?.tag ?? entry.id);
233
+
169
234
  const keyNamespace = action.options?.key;
170
- const tag = entry?.extensions?.tag;
171
235
 
172
236
  if (keyNamespace && tag) {
173
237
  const multiSelectProvider =
@@ -185,6 +249,23 @@ const prepareDefaultActions = (actionExecutor) => {
185
249
  if (selectedItems.includes(tag)) {
186
250
  await multiSelectProvider.removeItem(tag);
187
251
  } else {
252
+ const maxItems = action.options?.max_items;
253
+
254
+ if (maxItems && selectedItems.length >= maxItems) {
255
+ log_info(
256
+ `handleAction: localStorageToggleFlag event reached max items limit: ${maxItems}, cannot add tag: ${tag}`
257
+ );
258
+
259
+ await onMaxTagsReached({
260
+ selectedItems,
261
+ maxItems,
262
+ tag,
263
+ keyNamespace,
264
+ });
265
+
266
+ return ActionResult.Cancel;
267
+ }
268
+
188
269
  await multiSelectProvider.addItem(tag);
189
270
  }
190
271
  } else {
@@ -208,6 +289,10 @@ export function withActionExecutor(Component) {
208
289
  prepareDefaultActions(_actionExecutor);
209
290
 
210
291
  return function ActionExecutorComponent(props: Props) {
292
+ const navigator = useNavigation();
293
+ const { rivers } = usePickFromState(["rivers"]);
294
+ const contentTypes = useContentTypes();
295
+
211
296
  const handlers = useMemo(() => {
212
297
  return {
213
298
  unregisterAction: _actionExecutor.unregisterAction,
@@ -218,6 +303,44 @@ export function withActionExecutor(Component) {
218
303
  };
219
304
  }, []);
220
305
 
306
+ useEffect(() => {
307
+ return _actionExecutor.registerAction(
308
+ "navigateToScreen",
309
+ async (action: ActionType, context?: Record<string, any>) => {
310
+ const screenType = action.options?.typeMapping;
311
+
312
+ if (!screenType) {
313
+ log_error("navigateToScreen: typeMapping option is missing");
314
+
315
+ return ActionResult.Error;
316
+ }
317
+
318
+ const screenId = contentTypes?.[screenType]?.screen_id || null;
319
+
320
+ if (!screenId) {
321
+ log_error(
322
+ `navigateToScreen: can not resolve screen type mapping: ${screenType}`
323
+ );
324
+
325
+ return ActionResult.Error;
326
+ }
327
+
328
+ const river = rivers[screenId];
329
+
330
+ if (!river) {
331
+ log_error("navigateToScreen: can not resolve river");
332
+
333
+ return ActionResult.Error;
334
+ }
335
+
336
+ context?.callback?.({ success: false, error: null, abort: true });
337
+ navigator.replace(river);
338
+
339
+ return ActionResult.Success;
340
+ }
341
+ );
342
+ }, [navigator, rivers, contentTypes]);
343
+
221
344
  return (
222
345
  <ActionExecutorContext.Provider value={handlers}>
223
346
  <Component {...props} />
@@ -0,0 +1,4 @@
1
+ export const TOGGLE_FLAG_MAX_ITEMS_REACHED_EVENT =
2
+ "action.localStorageToggleFlag.maxItemsReached";
3
+
4
+ export const ACTION_EXECUTOR_EVENT_SOURCE = "ActionExecutor";
@@ -72,12 +72,14 @@ const mappedScreenPropertiesScreen = (
72
72
  screenData
73
73
  ): AnalyticsScreenProperties => {
74
74
  return {
75
- screen_name: screenData?.targetScreen?.name,
75
+ screen_name: screenData?.targetScreen?.name || screenData?.name,
76
76
  screen_entry_title: screenData?.title,
77
77
  screen_entry_id: R.isNil(screenData?.type) ? null : screenData?.id,
78
- screen_layout_id: screenData?.targetScreen?.id,
79
- screen_type: screenData?.targetScreen?.type,
80
- home_screen: screenData?.targetScreen?.home,
78
+ screen_layout_id: screenData?.targetScreen?.id || screenData?.id,
79
+ screen_type: screenData?.targetScreen?.type || screenData?.type,
80
+ home_screen: !R.isNil(screenData?.targetScreen?.home)
81
+ ? screenData?.targetScreen?.home
82
+ : screenData?.home,
81
83
  };
82
84
  };
83
85
 
@@ -16,7 +16,7 @@ const BASE_HOOK_PROPERTIES = ["screen_id", "identifier", "weight"];
16
16
  * @returns {number} index
17
17
  */
18
18
  const hookState: (
19
- arg0: typeof HOOKS_EVENTS[keyof typeof HOOKS_EVENTS]
19
+ arg0: (typeof HOOKS_EVENTS)[keyof typeof HOOKS_EVENTS]
20
20
  ) => number = R.indexOf(R.__, R.values(HOOKS_EVENTS));
21
21
 
22
22
  /**
@@ -62,9 +62,13 @@ export class Hook implements HookInterface {
62
62
  * @param {Array<Any>} args variadic arguments to invoke the handler with
63
63
  */
64
64
  setStateAndNotify(
65
- event: typeof HOOKS_EVENTS[keyof typeof HOOKS_EVENTS],
65
+ event: (typeof HOOKS_EVENTS)[keyof typeof HOOKS_EVENTS],
66
66
  ...args
67
67
  ) {
68
+ if (this.state === hookState(HOOKS_EVENTS.CANCEL)) {
69
+ return;
70
+ }
71
+
68
72
  this.state = hookState(event);
69
73
  this.manager.subscriber.invokeHandler(event, ...args);
70
74
  }
@@ -84,7 +84,7 @@ export function HooksManager({
84
84
  plugins,
85
85
  startUpHooksData = {},
86
86
  }: HookManagerArgs): HookManager {
87
- hooksManagerLogger.addContext({ targetScreen });
87
+ hooksManagerLogger.addContext({ targetScreenId: targetScreen.id });
88
88
 
89
89
  function logHookEvent(func, message, data) {
90
90
  func({
@@ -269,6 +269,7 @@ export function HooksManager({
269
269
  payload = initialPayload,
270
270
  callback: callbackArg,
271
271
  cancelled,
272
+ abort,
272
273
  }) {
273
274
  let callback = callbackArg;
274
275
 
@@ -308,6 +309,7 @@ export function HooksManager({
308
309
  hookPlugin.setStateAndNotify(HOOKS_EVENTS.CANCEL, {
309
310
  hookPlugin,
310
311
  payload,
312
+ abort,
311
313
  });
312
314
 
313
315
  const isHookInHomescreen = payload?.home;
@@ -103,7 +103,7 @@ export interface Hook<T extends HookModule = HookModule> {
103
103
  identifier: string;
104
104
  configuration: T["configuration"];
105
105
  setStateAndNotify(
106
- event: typeof HOOKS_EVENTS[keyof typeof HOOKS_EVENTS],
106
+ event: (typeof HOOKS_EVENTS)[keyof typeof HOOKS_EVENTS],
107
107
  opts: {
108
108
  error?: typeof Error;
109
109
  route?: string;
@@ -112,7 +112,7 @@ export interface Hook<T extends HookModule = HookModule> {
112
112
  }
113
113
  );
114
114
  general?: {
115
- transition_type: typeof HOOKS_EVENTS[keyof typeof HOOKS_EVENTS];
115
+ transition_type: (typeof HOOKS_EVENTS)[keyof typeof HOOKS_EVENTS];
116
116
  allow_screen_plugin_presentation: boolean;
117
117
  is_flow_blocker: boolean;
118
118
  };
@@ -0,0 +1,151 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`toDayJSLocaleMap [af] returns a valid dayjs locale 1`] = `"af"`;
4
+
5
+ exports[`toDayJSLocaleMap [ar] returns a valid dayjs locale 1`] = `"ar"`;
6
+
7
+ exports[`toDayJSLocaleMap [bg] returns a valid dayjs locale 1`] = `"bg"`;
8
+
9
+ exports[`toDayJSLocaleMap [bn] returns a valid dayjs locale 1`] = `"bn"`;
10
+
11
+ exports[`toDayJSLocaleMap [bo] returns a valid dayjs locale 1`] = `"bo"`;
12
+
13
+ exports[`toDayJSLocaleMap [ca] returns a valid dayjs locale 1`] = `"ca"`;
14
+
15
+ exports[`toDayJSLocaleMap [cs] returns a valid dayjs locale 1`] = `"cs"`;
16
+
17
+ exports[`toDayJSLocaleMap [da] returns a valid dayjs locale 1`] = `"da"`;
18
+
19
+ exports[`toDayJSLocaleMap [de] returns a valid dayjs locale 1`] = `"de"`;
20
+
21
+ exports[`toDayJSLocaleMap [el] returns a valid dayjs locale 1`] = `"el"`;
22
+
23
+ exports[`toDayJSLocaleMap [en] returns a valid dayjs locale 1`] = `"en"`;
24
+
25
+ exports[`toDayJSLocaleMap [en-GB] returns a valid dayjs locale 1`] = `"en-gb"`;
26
+
27
+ exports[`toDayJSLocaleMap [en-UK] returns a valid dayjs locale 1`] = `"en-gb"`;
28
+
29
+ exports[`toDayJSLocaleMap [es] returns a valid dayjs locale 1`] = `"es"`;
30
+
31
+ exports[`toDayJSLocaleMap [es-LA] returns a valid dayjs locale 1`] = `"es"`;
32
+
33
+ exports[`toDayJSLocaleMap [es-MX] returns a valid dayjs locale 1`] = `"es-mx"`;
34
+
35
+ exports[`toDayJSLocaleMap [es-US] returns a valid dayjs locale 1`] = `"es-us"`;
36
+
37
+ exports[`toDayJSLocaleMap [et] returns a valid dayjs locale 1`] = `"et"`;
38
+
39
+ exports[`toDayJSLocaleMap [eu] returns a valid dayjs locale 1`] = `"eu"`;
40
+
41
+ exports[`toDayJSLocaleMap [fa] returns a valid dayjs locale 1`] = `"fa"`;
42
+
43
+ exports[`toDayJSLocaleMap [fi] returns a valid dayjs locale 1`] = `"fi"`;
44
+
45
+ exports[`toDayJSLocaleMap [fj] returns a valid dayjs locale 1`] = `"en"`;
46
+
47
+ exports[`toDayJSLocaleMap [fr] returns a valid dayjs locale 1`] = `"fr"`;
48
+
49
+ exports[`toDayJSLocaleMap [ga] returns a valid dayjs locale 1`] = `"ga"`;
50
+
51
+ exports[`toDayJSLocaleMap [gu] returns a valid dayjs locale 1`] = `"gu"`;
52
+
53
+ exports[`toDayJSLocaleMap [he] returns a valid dayjs locale 1`] = `"he"`;
54
+
55
+ exports[`toDayJSLocaleMap [hi] returns a valid dayjs locale 1`] = `"hi"`;
56
+
57
+ exports[`toDayJSLocaleMap [hr] returns a valid dayjs locale 1`] = `"hr"`;
58
+
59
+ exports[`toDayJSLocaleMap [hu] returns a valid dayjs locale 1`] = `"hu"`;
60
+
61
+ exports[`toDayJSLocaleMap [hy] returns a valid dayjs locale 1`] = `"hy-am"`;
62
+
63
+ exports[`toDayJSLocaleMap [id] returns a valid dayjs locale 1`] = `"id"`;
64
+
65
+ exports[`toDayJSLocaleMap [is] returns a valid dayjs locale 1`] = `"is"`;
66
+
67
+ exports[`toDayJSLocaleMap [it] returns a valid dayjs locale 1`] = `"it"`;
68
+
69
+ exports[`toDayJSLocaleMap [ja] returns a valid dayjs locale 1`] = `"ja"`;
70
+
71
+ exports[`toDayJSLocaleMap [ka] returns a valid dayjs locale 1`] = `"ka"`;
72
+
73
+ exports[`toDayJSLocaleMap [km] returns a valid dayjs locale 1`] = `"km"`;
74
+
75
+ exports[`toDayJSLocaleMap [ko] returns a valid dayjs locale 1`] = `"ko"`;
76
+
77
+ exports[`toDayJSLocaleMap [la] returns a valid dayjs locale 1`] = `"en"`;
78
+
79
+ exports[`toDayJSLocaleMap [lt] returns a valid dayjs locale 1`] = `"lt"`;
80
+
81
+ exports[`toDayJSLocaleMap [lv] returns a valid dayjs locale 1`] = `"lv"`;
82
+
83
+ exports[`toDayJSLocaleMap [mi] returns a valid dayjs locale 1`] = `"mi"`;
84
+
85
+ exports[`toDayJSLocaleMap [mk] returns a valid dayjs locale 1`] = `"mk"`;
86
+
87
+ exports[`toDayJSLocaleMap [ml] returns a valid dayjs locale 1`] = `"ml"`;
88
+
89
+ exports[`toDayJSLocaleMap [mn] returns a valid dayjs locale 1`] = `"mn"`;
90
+
91
+ exports[`toDayJSLocaleMap [mr] returns a valid dayjs locale 1`] = `"mr"`;
92
+
93
+ exports[`toDayJSLocaleMap [ms] returns a valid dayjs locale 1`] = `"ms"`;
94
+
95
+ exports[`toDayJSLocaleMap [mt] returns a valid dayjs locale 1`] = `"mt"`;
96
+
97
+ exports[`toDayJSLocaleMap [ne] returns a valid dayjs locale 1`] = `"ne"`;
98
+
99
+ exports[`toDayJSLocaleMap [nl] returns a valid dayjs locale 1`] = `"nl"`;
100
+
101
+ exports[`toDayJSLocaleMap [no] returns a valid dayjs locale 1`] = `"en"`;
102
+
103
+ exports[`toDayJSLocaleMap [pa] returns a valid dayjs locale 1`] = `"pa-in"`;
104
+
105
+ exports[`toDayJSLocaleMap [pl] returns a valid dayjs locale 1`] = `"pl"`;
106
+
107
+ exports[`toDayJSLocaleMap [pt] returns a valid dayjs locale 1`] = `"pt"`;
108
+
109
+ exports[`toDayJSLocaleMap [pt-BR] returns a valid dayjs locale 1`] = `"pt-br"`;
110
+
111
+ exports[`toDayJSLocaleMap [qu] returns a valid dayjs locale 1`] = `"en"`;
112
+
113
+ exports[`toDayJSLocaleMap [ro] returns a valid dayjs locale 1`] = `"ro"`;
114
+
115
+ exports[`toDayJSLocaleMap [ru] returns a valid dayjs locale 1`] = `"ru"`;
116
+
117
+ exports[`toDayJSLocaleMap [sk] returns a valid dayjs locale 1`] = `"sk"`;
118
+
119
+ exports[`toDayJSLocaleMap [sl] returns a valid dayjs locale 1`] = `"sl"`;
120
+
121
+ exports[`toDayJSLocaleMap [sm] returns a valid dayjs locale 1`] = `"en"`;
122
+
123
+ exports[`toDayJSLocaleMap [sq] returns a valid dayjs locale 1`] = `"sq"`;
124
+
125
+ exports[`toDayJSLocaleMap [sr] returns a valid dayjs locale 1`] = `"sr"`;
126
+
127
+ exports[`toDayJSLocaleMap [sv] returns a valid dayjs locale 1`] = `"sv"`;
128
+
129
+ exports[`toDayJSLocaleMap [sw] returns a valid dayjs locale 1`] = `"sw"`;
130
+
131
+ exports[`toDayJSLocaleMap [ta] returns a valid dayjs locale 1`] = `"ta"`;
132
+
133
+ exports[`toDayJSLocaleMap [te] returns a valid dayjs locale 1`] = `"te"`;
134
+
135
+ exports[`toDayJSLocaleMap [th] returns a valid dayjs locale 1`] = `"th"`;
136
+
137
+ exports[`toDayJSLocaleMap [to] returns a valid dayjs locale 1`] = `"en"`;
138
+
139
+ exports[`toDayJSLocaleMap [tr] returns a valid dayjs locale 1`] = `"tr"`;
140
+
141
+ exports[`toDayJSLocaleMap [tt] returns a valid dayjs locale 1`] = `"en"`;
142
+
143
+ exports[`toDayJSLocaleMap [uk] returns a valid dayjs locale 1`] = `"uk"`;
144
+
145
+ exports[`toDayJSLocaleMap [ur] returns a valid dayjs locale 1`] = `"ur"`;
146
+
147
+ exports[`toDayJSLocaleMap [uz] returns a valid dayjs locale 1`] = `"uz"`;
148
+
149
+ exports[`toDayJSLocaleMap [vi] returns a valid dayjs locale 1`] = `"vi"`;
150
+
151
+ exports[`toDayJSLocaleMap [zh] returns a valid dayjs locale 1`] = `"zh"`;
@@ -0,0 +1,79 @@
1
+ export default [
2
+ // common locales from https://rubygems.org/gems/language_list
3
+ "en",
4
+ "fr",
5
+ "de",
6
+ "nl",
7
+ "ru",
8
+ "es",
9
+ "he",
10
+ "hy",
11
+ "sq",
12
+ "af",
13
+ "ar",
14
+ "eu",
15
+ "bn",
16
+ "bg",
17
+ "zh",
18
+ "cs",
19
+ "km",
20
+ "ca",
21
+ "hr",
22
+ "da",
23
+ "et",
24
+ "fj",
25
+ "fi",
26
+ "gu",
27
+ "ka",
28
+ "hu",
29
+ "hi",
30
+ "it",
31
+ "is",
32
+ "id",
33
+ "ga",
34
+ "ja",
35
+ "ko",
36
+ "la",
37
+ "lv",
38
+ "lt",
39
+ "ms",
40
+ "mi",
41
+ "mn",
42
+ "mt",
43
+ "mk",
44
+ "el",
45
+ "mr",
46
+ "ml",
47
+ "ne",
48
+ "no",
49
+ "pa",
50
+ "pl",
51
+ "pt",
52
+ "fa",
53
+ "qu",
54
+ "ro",
55
+ "sk",
56
+ "sm",
57
+ "sr",
58
+ "sw",
59
+ "sv",
60
+ "sl",
61
+ "to",
62
+ "tr",
63
+ "th",
64
+ "te",
65
+ "bo",
66
+ "tt",
67
+ "ta",
68
+ "uk",
69
+ "ur",
70
+ "uz",
71
+ "vi",
72
+ // Extra locales https://github.com/applicaster/zapp/blob/5604794f15cfd270ae494b0db85e542de4cebfaa/config/additional_languages.yml
73
+ "en-UK",
74
+ "en-GB",
75
+ "es-LA",
76
+ "pt-BR",
77
+ "es-MX",
78
+ "es-US",
79
+ ];
@@ -8,6 +8,7 @@ const {
8
8
  getLocale,
9
9
  getLanguageCode,
10
10
  getCountryCode,
11
+ toDayJSLocaleMap,
11
12
  } = require("../localizationsHelper");
12
13
 
13
14
  describe("getLocale", () => {
@@ -69,3 +70,13 @@ describe("getCountryCode", () => {
69
70
  expect(currentValue).toEqual(expectedValue);
70
71
  });
71
72
  });
73
+
74
+ describe("toDayJSLocaleMap", () => {
75
+ const allZappLocales: string[] = require("./allZappLocales").default;
76
+
77
+ it.each(allZappLocales)("[%s] returns a valid dayjs locale", (locale) => {
78
+ const dayJSLocale = toDayJSLocaleMap(locale);
79
+ expect(dayJSLocale).toBeDefined();
80
+ expect(dayJSLocale).toMatchSnapshot();
81
+ });
82
+ });
@@ -1,12 +1,6 @@
1
- import { createLogger } from "../../logger";
2
1
  import { ContextKeysManager } from "./index";
3
2
  import * as R from "ramda";
4
3
 
5
- const { log_error } = createLogger({
6
- subsystem: "contextResolver",
7
- category: "General",
8
- });
9
-
10
4
  interface IResolver {
11
5
  resolve: (string) => Promise<string | number | object>;
12
6
  }
@@ -42,12 +36,16 @@ export const resolveObjectValues = async (
42
36
 
43
37
  const resolvedEntries = await Promise.all(
44
38
  entries.map(async ([key, value]) => {
45
- const regex = /@{([^/]+)\/([^}]*)}/;
46
-
47
39
  if (typeof value !== "string") {
48
40
  return [key, value];
49
41
  }
50
42
 
43
+ if (!value.startsWith("@")) {
44
+ return [key, value];
45
+ }
46
+
47
+ const regex = /@{([^/]+)\/([^}]*)}/;
48
+
51
49
  const match = (value as string).match(regex);
52
50
 
53
51
  if (match) {
@@ -60,12 +58,7 @@ export const resolveObjectValues = async (
60
58
  return [key, resolvedValue];
61
59
  }
62
60
 
63
- log_error("resolveObjectValues: invalid context string", {
64
- key,
65
- value,
66
- });
67
-
68
- return [key, null];
61
+ return [key, value];
69
62
  })
70
63
  );
71
64
 
@@ -16,12 +16,12 @@ import {
16
16
 
17
17
  export { StorageLevel };
18
18
 
19
- type KeyNameObj = {
19
+ export type KeyNameObj = {
20
20
  namespace: string;
21
21
  key: string;
22
22
  };
23
23
 
24
- type KeyName = string | KeyNameObj;
24
+ export type KeyName = string | KeyNameObj;
25
25
 
26
26
  type ParsedKeyAndNamespace = {
27
27
  namespace?: string;
@@ -1,10 +1,11 @@
1
1
  import * as R from "ramda";
2
2
  import { DEFAULT_NAMESPACE } from "../consts";
3
+ import { KeyName, KeyNameObj } from "../index";
3
4
 
4
5
  const lastDotRegex = /\.([^.]+)$/;
5
6
  const splitByLastDot = R.compose(R.init, R.split(lastDotRegex));
6
7
 
7
- export function getNamespaceAndKey(namespacedKey) {
8
+ export function getNamespaceAndKey(namespacedKey: KeyName): KeyNameObj {
8
9
  if (typeof namespacedKey !== "string") return namespacedKey;
9
10
 
10
11
  const namespacedKeyProps = namespacedKey.includes(".")
@@ -5,6 +5,7 @@ exports[`focusManager should be defined 1`] = `
5
5
  "blur": [Function],
6
6
  "disableFocus": [Function],
7
7
  "enableFocus": [Function],
8
+ "findPreferredFocusChild": [Function],
8
9
  "focusableTree": Tree {
9
10
  "loadingCounter": 0,
10
11
  "root": {
@@ -28,6 +29,7 @@ exports[`focusManager should be defined 1`] = `
28
29
  "moveFocus": [Function],
29
30
  "on": [Function],
30
31
  "press": [Function],
32
+ "pressIn": [Function],
31
33
  "pressOut": [Function],
32
34
  "recoverFocus": [Function],
33
35
  "register": [Function],
@@ -59,6 +61,7 @@ exports[`focusManagerIOS should be defined 1`] = `
59
61
  "getCurrentGroup": [Function],
60
62
  "getGroupById": [Function],
61
63
  "getGroupRootById": [Function],
64
+ "getPreferredFocusChild": [Function],
62
65
  "invokeHandler": [Function],
63
66
  "isGroupItemFocused": [Function],
64
67
  "moveFocus": [Function],