@applicaster/zapp-react-native-utils 13.0.0-alpha.7330390362 → 13.0.0-alpha.7663846546

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.
@@ -49,9 +49,16 @@ export const isEqual =
49
49
  }
50
50
 
51
51
  if (compareRemainingKeysBySameValue) {
52
- const undeclaredKeys = R.difference(
53
- [...byValue, ...byReference, byComparator.keys],
54
- Object.keys(prev)
52
+ const allKeys = new Set([...Object.keys(prev), ...Object.keys(next)]);
53
+
54
+ const declaredKeys = new Set([
55
+ ...byValue,
56
+ ...byReference,
57
+ ...byComparator.keys,
58
+ ]);
59
+
60
+ const undeclaredKeys = Array.from(allKeys).filter(
61
+ (key) => !declaredKeys.has(key)
55
62
  );
56
63
 
57
64
  const isRestKeysEqualAllBySameValue = undeclaredKeys.every((key) =>
@@ -3,7 +3,7 @@ import { logger } from "@applicaster/zapp-react-native-utils/logger";
3
3
 
4
4
  const numberUtilsLogger = logger?.addSubsystem("NumberUtils");
5
5
 
6
- export const toNumber = (value: unknown): number | undefined => {
6
+ export const toNumber = (value: any): number | undefined => {
7
7
  if (R.isNil(value) || R.isEmpty(value)) {
8
8
  return undefined;
9
9
  }
@@ -17,12 +17,10 @@ export const toNumber = (value: unknown): number | undefined => {
17
17
  return undefined;
18
18
  };
19
19
 
20
- export const toNumberWithDefault = (
21
- defaultValue: number,
22
- value: unknown
23
- ): number => toNumber(value) ?? defaultValue;
20
+ export const toNumberWithDefault = (defaultValue: number, value: any): number =>
21
+ toNumber(value) ?? defaultValue;
24
22
 
25
- export const toNumberWithDefaultZero = (value: unknown): number =>
23
+ export const toNumberWithDefaultZero = (value: any): number =>
26
24
  toNumberWithDefault(0, value);
27
25
 
28
26
  export const requireNumber = (obj, key: string) => {
@@ -41,7 +39,7 @@ export const requireNumber = (obj, key: string) => {
41
39
 
42
40
  export const toFiniteNumberWithDefault = (
43
41
  defaultValue: number,
44
- value: unknown
42
+ value: any
45
43
  ): number => {
46
44
  const possibleNumber = toNumberWithDefault(defaultValue, value);
47
45
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-utils",
3
- "version": "13.0.0-alpha.7330390362",
3
+ "version": "13.0.0-alpha.7663846546",
4
4
  "description": "Applicaster Zapp React Native utilities package",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "homepage": "https://github.com/applicaster/quickbrick#readme",
30
30
  "dependencies": {
31
- "@applicaster/applicaster-types": "13.0.0-alpha.7330390362",
31
+ "@applicaster/applicaster-types": "13.0.0-alpha.7663846546",
32
32
  "buffer": "^5.2.1",
33
33
  "camelize": "^1.0.0",
34
34
  "create-react-context": "^0.2.3",
@@ -35,23 +35,25 @@ const Wrapper = ({ children }: { children: React.ReactChild }) => (
35
35
  const { useTrackedView } = require("../useTrackedView");
36
36
 
37
37
  describe("useTrackCurrentAutoScrollingElement", () => {
38
- it("should update position for selected component - onViewportEnter", () => {
38
+ it("should update position for selected component", async () => {
39
39
  const { result } = renderHook(() => useTrackedView("123"), {
40
40
  wrapper: Wrapper,
41
41
  });
42
42
 
43
+ // Fast-forward until all timers have been executed
44
+ jest.advanceTimersByTime(3000);
45
+
43
46
  expect(result.current.inViewPort).toBe(false);
44
47
 
45
48
  const mockRect = {
46
49
  rect: { left: 1, right: 1, top: 1, bottom: 1 },
47
50
  };
48
51
 
49
- act(async () => {
50
- await result.current.onPositionUpdated(mockRect);
52
+ act(() => {
53
+ result.current.onPositionUpdated(mockRect);
51
54
  });
52
55
 
53
- // Fast-forward until all timers have been executed
54
- jest.runAllTimers();
56
+ jest.advanceTimersByTime(3000);
55
57
 
56
58
  expect(result.current.inViewPort).toBe(true);
57
59
 
@@ -2,10 +2,6 @@ import { useCallback, useEffect, useMemo, useState } from "react";
2
2
  import { useScreenTrackedViewPositionsContext } from "@applicaster/zapp-react-native-ui-components/Contexts/ScreenTrackedViewPositionsContext";
3
3
  import { useDimensions } from "@applicaster/zapp-react-native-utils/reactHooks/layout";
4
4
  import { findTrackedView } from "./utils/findTrackedView";
5
- import { isNil } from "ramda";
6
- import { withTimeout } from "@applicaster/zapp-react-native-utils/idleUtils";
7
-
8
- const TIMEOUT_FOR_DELAY_ON_VIEWPORT_ENTER_EVENT = 500; // ms
9
5
 
10
6
  const getNormalizedRect = (rect, componentId, screenWidth, screenHeight) => {
11
7
  if (!rect) {
@@ -41,16 +37,9 @@ export const useTrackedView = (componentId: string) => {
41
37
  );
42
38
 
43
39
  const onPositionUpdated = useCallback(
44
- async ({ rect }) => {
40
+ ({ rect }) => {
45
41
  const currentPosition = normalizedRect(componentId, rect);
46
42
 
47
- // There is an issue on the native side where they are unable to guarantee
48
- // that the order of onViewportLeave and onViewportEnter events is always correct.
49
- // This workaround/hack delays the onViewportEnter event to ensure it is received last.
50
- if (!isNil(currentPosition)) {
51
- await withTimeout(TIMEOUT_FOR_DELAY_ON_VIEWPORT_ENTER_EVENT);
52
- }
53
-
54
43
  updateComponentsPositions(componentId, currentPosition as any);
55
44
 
56
45
  setInViewPort(!!currentPosition);