@applicaster/zapp-react-native-utils 13.0.0-alpha.4863201005 → 13.0.0-alpha.4951885994

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 (54) hide show
  1. package/README.md +0 -10
  2. package/analyticsUtils/currentScreenProperities.ts +6 -4
  3. package/appUtils/HooksManager/index.ts +1 -1
  4. package/appUtils/contextKeysManager/index.ts +2 -2
  5. package/appUtils/contextKeysManager/utils/index.ts +2 -1
  6. package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +1 -0
  7. package/appUtils/focusManager/index.ts +9 -9
  8. package/appUtils/keyCodes/index.ts +11 -7
  9. package/appUtils/orientationHelper.ts +11 -13
  10. package/appUtils/platform/platformUtils.ts +6 -0
  11. package/appUtils/playerManager/index.ts +1 -1
  12. package/appUtils/playerManager/player.ts +24 -12
  13. package/appUtils/playerManager/playerNative.ts +18 -3
  14. package/equalUtils/__tests__/isEqual/combination.test.ts +263 -0
  15. package/equalUtils/index.ts +49 -30
  16. package/focusManager/FocusManager.ts +11 -1
  17. package/focusManager/index.ts +41 -4
  18. package/functionUtils/index.ts +21 -8
  19. package/manifestUtils/defaultManifestConfigurations/player.js +8 -0
  20. package/manifestUtils/fonts/index.js +5 -6
  21. package/manifestUtils/sharedConfiguration/screenPicker/__tests__/utils.test.js +304 -0
  22. package/manifestUtils/sharedConfiguration/screenPicker/stylesFields.js +875 -0
  23. package/manifestUtils/sharedConfiguration/screenPicker/utils.js +130 -0
  24. package/numberUtils/index.ts +7 -5
  25. package/package.json +4 -9
  26. package/playerUtils/configurationGenerator.ts +8 -0
  27. package/reactHooks/autoscrolling/__tests__/useTrackedView.test.tsx +5 -7
  28. package/reactHooks/autoscrolling/useTrackedView.ts +12 -1
  29. package/reactHooks/navigation/__mocks__/useNavigation.ts +3 -0
  30. package/reactHooks/navigation/__tests__/index.test.tsx +6 -17
  31. package/reactHooks/navigation/index.ts +13 -23
  32. package/reactHooks/navigation/useGetTabBarHeight.ts +1 -3
  33. package/reactHooks/navigation/useProfilerLogging.ts +15 -0
  34. package/reactUtils/__tests__/__snapshots__/reactUtilsHelpers.test.js.snap +16 -4
  35. package/reactUtils/__tests__/reactUtils.test.js +1 -19
  36. package/reactUtils/__tests__/reactUtilsHelpers.test.js +72 -71
  37. package/reactUtils/createContext/__tests__/__snapshots__/helpers.test.js.snap +6 -72
  38. package/reactUtils/createContext/__tests__/__snapshots__/provider.test.js.snap +3 -28
  39. package/reactUtils/createContext/__tests__/__snapshots__/withConsumer.test.js.snap +3 -4
  40. package/reactUtils/createContext/__tests__/__snapshots__/withProvider.test.js.snap +7 -3
  41. package/reactUtils/createContext/__tests__/helpers.test.js +107 -121
  42. package/reactUtils/createContext/__tests__/{index.test.js → index.test.ts} +2 -2
  43. package/reactUtils/createContext/__tests__/provider.test.js +4 -6
  44. package/reactUtils/createContext/__tests__/withConsumer.test.js +12 -12
  45. package/reactUtils/createContext/__tests__/withProvider.test.js +4 -4
  46. package/reactUtils/createContext/helpers.ts +6 -1
  47. package/reactUtils/createContext/index.ts +11 -25
  48. package/reactUtils/index.ts +0 -11
  49. package/services/js2native.ts +673 -0
  50. package/testUtils/index.tsx +0 -10
  51. package/time/BackgroundTimer.ts +55 -0
  52. package/time/Timer.ts +6 -6
  53. package/reactUtils/createContext/__tests__/index-no-react.test.js +0 -27
  54. /package/reactUtils/createContext/__tests__/__snapshots__/{index.test.js.snap → index.test.ts.snap} +0 -0
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable react/prop-types */
2
2
  import * as React from "react";
3
- import { shallow } from "enzyme";
4
- import toJson from "enzyme-to-json";
3
+ import { render } from "@testing-library/react-native";
4
+
5
5
  import { View } from "react-native";
6
6
 
7
7
  import { createWithConsumerDecorator } from "../withConsumer";
@@ -11,21 +11,21 @@ describe("createConsumer", () => {
11
11
  const { Consumer } = ReactContext;
12
12
  const withConsumer = createWithConsumerDecorator(Consumer);
13
13
 
14
- it("returns a function", () => {
15
- expect(withConsumer).toBeFunction();
16
- });
17
-
18
14
  it("creates a context consumer function", () => {
19
- const Child = (props) => <View>{props.context}</View>;
20
- const DecoratedChild = withConsumer(Child);
15
+ expect(withConsumer).toBeFunction();
21
16
  const newContextValue = "newValue";
22
17
 
23
- const wrapper = shallow(<DecoratedChild />);
18
+ const Child = (props) => {
19
+ props.setContext(newContextValue);
20
+
21
+ return <View>{props.context}</View>;
22
+ };
23
+
24
+ const DecoratedChild = withConsumer(Child);
24
25
 
25
- const childWrapper = wrapper.dive();
26
+ const wrapper = render(<DecoratedChild />);
26
27
 
27
- expect(toJson(childWrapper)).toMatchSnapshot();
28
- childWrapper.props().setContext(newContextValue);
28
+ expect(wrapper.toJSON()).toMatchSnapshot();
29
29
 
30
30
  expect(mockContextData.setContext).toHaveBeenCalledWith(newContextValue);
31
31
  });
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable react/prop-types */
2
2
  import * as React from "react";
3
- import { shallow } from "enzyme";
4
- import toJson from "enzyme-to-json";
3
+ import { render } from "@testing-library/react-native";
4
+
5
5
  import { View, Text } from "react-native";
6
6
 
7
7
  import { createWithProviderDecorator } from "../withProvider";
@@ -19,8 +19,8 @@ describe("withProvider", () => {
19
19
 
20
20
  const DecoratedComponent = withProvider(Component);
21
21
 
22
- const wrapper = shallow(<DecoratedComponent />);
22
+ const wrapper = render(<DecoratedComponent />);
23
23
 
24
- expect(toJson(wrapper)).toMatchSnapshot();
24
+ expect(wrapper.toJSON()).toMatchSnapshot();
25
25
  });
26
26
  });
@@ -33,7 +33,12 @@ export const getSetterName: (property: string) => string = R.compose(
33
33
  export function createContextSetters(
34
34
  properties: string[],
35
35
  component: any,
36
- options: any = {}
36
+ options: {
37
+ stateValidator?: (
38
+ obj: { property: string; value: unknown },
39
+ oldValue: unknown
40
+ ) => boolean;
41
+ } = {}
37
42
  ) {
38
43
  const { stateValidator = R.T } = options;
39
44
 
@@ -1,5 +1,4 @@
1
1
  import * as React from "react";
2
- import createReactContext from "create-react-context";
3
2
  import * as R from "ramda";
4
3
 
5
4
  import { getSetterName, NOOP } from "./helpers";
@@ -7,33 +6,20 @@ import { createProvider } from "./provider";
7
6
  import { createWithConsumerDecorator } from "./withConsumer";
8
7
  import { createWithProviderDecorator } from "./withProvider";
9
8
 
10
- const reactContextCreator = React.createContext;
11
-
12
- // Depending on the version of React used, the `createContext` function may not be available
13
- // if this is the case, we fall back to a polyfill library
14
- const contextCreatorFn =
15
- reactContextCreator && typeof reactContextCreator === "function"
16
- ? reactContextCreator
17
- : createReactContext;
18
-
19
- /**
20
- * @typedef Context
21
- * @property {Object} Context.Provider react class component to use as context provider
22
- * @property {Function} Context.Consumer react functional component to use as context consumer
23
- * @property {Function} Context.withProvider HOC to apply the context provider
24
- * @property {function} Context.withConsumer HOC to apply the context consumer. passes the context as props
25
- * @property {React.Context} Context.ReactContext React context object
26
- * to the wrapped component
27
- */
28
-
29
9
  /**
30
10
  * Creates a React Context and returns consumer & providers components & decorators to interact
31
11
  * with this context.
32
- * @param {Object} initialContext map of context properties and their initial values
33
- * @param {Function} stateValidator optional predicate to tell whether the state update is valid or not
34
- * @returns {Context} Object containing the context components & decorators {@link Context}
12
+ * @param initialContext map of context properties and their initial values
13
+ * @param stateValidator optional predicate to tell whether the state update is valid or not
14
+ * @returns Object containing the context components & decorators
35
15
  */
36
- export function createContext(initialContext, stateValidator = R.T) {
16
+ export function createContext(
17
+ initialContext: Record<string, any>,
18
+ stateValidator: (
19
+ obj: { property: string; value: unknown },
20
+ oldValue: unknown
21
+ ) => boolean = R.T
22
+ ) {
37
23
  // first we extract the properties name, and create setters name for those
38
24
  const contextPropertiesNames = R.keys(initialContext);
39
25
  const contextSettersNames = R.map(getSetterName, contextPropertiesNames);
@@ -41,7 +27,7 @@ export function createContext(initialContext, stateValidator = R.T) {
41
27
  // we create a React Context with the properties & their setters, assigning a noop function
42
28
  // temporarily (will be overriden by proper setters in the provider component)
43
29
  const ReactContext = R.compose(
44
- contextCreatorFn,
30
+ React.createContext,
45
31
  R.merge(initialContext),
46
32
  R.zipObj(contextSettersNames),
47
33
  R.map(R.always(NOOP))
@@ -2,7 +2,6 @@
2
2
  import * as R from "ramda";
3
3
  import * as React from "react";
4
4
  import { Platform } from "react-native";
5
- import createRef from "create-react-ref/lib/createRef";
6
5
 
7
6
  import { addLifeCycleMethods, wrapInClass, isClassComponent } from "./helpers";
8
7
 
@@ -19,16 +18,6 @@ export function attachLifeCycleMethods(lifecycleMethods) {
19
18
  );
20
19
  }
21
20
 
22
- /**
23
- * creates a React Ref. if the version of React doesn't
24
- * have this API, will use a polyfill instead
25
- */
26
- export function createReactRef() {
27
- return React.createRef && typeof React.createRef === "function"
28
- ? React.createRef()
29
- : createRef();
30
- }
31
-
32
21
  /**
33
22
  * Clone the children and merge each of the cloned elements with otherProps.
34
23
  * @param {React.Children} children to clone