react-native-reanimated 2.11.0 → 2.13.0

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 (50) hide show
  1. package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +1 -0
  2. package/RNReanimated.podspec +7 -4
  3. package/android/.gradle/7.5.1/checksums/checksums.lock +0 -0
  4. package/android/.gradle/7.5.1/checksums/md5-checksums.bin +0 -0
  5. package/android/.gradle/7.5.1/checksums/sha1-checksums.bin +0 -0
  6. package/android/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock +0 -0
  7. package/android/.gradle/7.5.1/executionHistory/executionHistory.bin +0 -0
  8. package/android/.gradle/7.5.1/executionHistory/executionHistory.lock +0 -0
  9. package/android/.gradle/7.5.1/fileHashes/fileHashes.bin +0 -0
  10. package/android/.gradle/7.5.1/fileHashes/fileHashes.lock +0 -0
  11. package/android/.gradle/7.5.1/fileHashes/resourceHashesCache.bin +0 -0
  12. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  13. package/android/.gradle/buildOutputCleanup/cache.properties +1 -1
  14. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  15. package/android/.gradle/file-system.probe +0 -0
  16. package/android/CMakeLists.txt +1 -1
  17. package/android/build.gradle +72 -36
  18. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +1 -1
  19. package/android/{rnVersionPatch/62 → src/reactNativeVersionPatch/UIImplementation/64/com/swmansion/reanimated}/layoutReanimation/ReanimatedUIImplementation.java +0 -0
  20. package/android/src/{main/java → reactNativeVersionPatch/UIImplementation/latest}/com/swmansion/reanimated/layoutReanimation/ReanimatedUIImplementation.java +0 -0
  21. package/android/src/reactNativeVersionPatch/messageQueueThread/67/com/swmansion/reanimated/ReanimatedMessageQueueThread.java +12 -0
  22. package/android/src/reactNativeVersionPatch/messageQueueThread/latest/com/swmansion/reanimated/ReanimatedMessageQueueThread.java +12 -0
  23. package/android/{rnVersionPatch/62 → src/reactNativeVersionPatch/nativeHierarchyManager/62/com/swmansion/reanimated}/layoutReanimation/ReanimatedNativeHierarchyManager.java +0 -0
  24. package/android/src/{main/java → reactNativeVersionPatch/nativeHierarchyManager/latest}/com/swmansion/reanimated/layoutReanimation/ReanimatedNativeHierarchyManager.java +0 -0
  25. package/ios/REAModule.mm +21 -2
  26. package/ios/keyboardObserver/REAKeyboardEventObserver.m +1 -1
  27. package/lib/createAnimatedComponent.js +3 -4
  28. package/lib/reanimated2/NativeMethods.js +78 -43
  29. package/lib/reanimated2/globals.d.ts +39 -13
  30. package/lib/reanimated2/hook/useScrollViewOffset.js +2 -1
  31. package/lib/reanimated2/jestUtils.js +14 -7
  32. package/lib/types/reanimated2/NativeMethods.d.ts +2 -2
  33. package/lib/types/reanimated2/frameCallback/FrameCallbackRegistryUI.d.ts +14 -0
  34. package/package.json +6 -5
  35. package/scripts/reanimated_utils.rb +14 -2
  36. package/src/createAnimatedComponent.tsx +2 -3
  37. package/src/reanimated2/NativeMethods.ts +98 -54
  38. package/src/reanimated2/frameCallback/FrameCallbackRegistryUI.ts +1 -1
  39. package/src/reanimated2/globals.d.ts +39 -13
  40. package/src/reanimated2/hook/useScrollViewOffset.ts +4 -3
  41. package/src/reanimated2/jestUtils.ts +14 -6
  42. package/android/rnVersionPatch/63/layoutReanimation/ReanimatedUIImplementation.java +0 -68
  43. package/android/rnVersionPatch/64/layoutReanimation/ReanimatedUIImplementation.java +0 -68
  44. package/android/rnVersionPatch/65/.gitkeep +0 -0
  45. package/android/rnVersionPatch/66/.gitkeep +0 -0
  46. package/android/rnVersionPatch/67/.gitkeep +0 -0
  47. package/android/rnVersionPatch/68/.gitkeep +0 -0
  48. package/android/rnVersionPatch/69/.gitkeep +0 -0
  49. package/android/rnVersionPatch/70/.gitkeep +0 -0
  50. package/android/rnVersionPatch/backup/.gitkeep +0 -0
@@ -2,6 +2,6 @@ import { Component } from 'react';
2
2
  import { MeasuredDimensions } from './commonTypes';
3
3
  import { RefObjectFunction } from './hook/commonTypes';
4
4
  export declare function getTag(view: null | number | React.Component<any, any> | React.ComponentClass<any>): null | number;
5
- export declare function measure(animatedRef: RefObjectFunction<Component>): MeasuredDimensions | null;
6
- export declare function scrollTo(animatedRef: RefObjectFunction<Component>, x: number, y: number, animated: boolean): void;
5
+ export declare let measure: (animatedRef: RefObjectFunction<Component>) => MeasuredDimensions | null;
6
+ export declare let scrollTo: (animatedRef: RefObjectFunction<Component>, x: number, y: number, animated: boolean) => void;
7
7
  export declare function setGestureState(handlerTag: number, newState: number): void;
@@ -1,6 +1,20 @@
1
+ declare type CallbackDetails = {
2
+ callback: (frameInfo: FrameInfo) => void;
3
+ startTime: number | null;
4
+ };
1
5
  export declare type FrameInfo = {
2
6
  timestamp: number;
3
7
  timeSincePreviousFrame: number | null;
4
8
  timeSinceFirstFrame: number;
5
9
  };
10
+ export interface FrameCallbackRegistryUI {
11
+ frameCallbackRegistry: Map<number, CallbackDetails>;
12
+ activeFrameCallbacks: Set<number>;
13
+ previousFrameTimestamp: number | null;
14
+ runCallbacks: () => void;
15
+ registerFrameCallback: (callback: (frameInfo: FrameInfo) => void, callbackId: number) => void;
16
+ unregisterFrameCallback: (callbackId: number) => void;
17
+ manageStateFrameCallback: (callbackId: number, state: boolean) => void;
18
+ }
6
19
  export declare const prepareUIRegistry: () => void;
20
+ export {};
package/package.json CHANGED
@@ -1,18 +1,19 @@
1
1
  {
2
2
  "name": "react-native-reanimated",
3
- "version": "2.11.0",
3
+ "version": "2.13.0",
4
4
  "description": "More powerful alternative to Animated library for React Native.",
5
5
  "scripts": {
6
6
  "test": "yarn run format:js && yarn run lint:js && yarn run test:unit",
7
7
  "test:unit": "jest",
8
- "lint": "yarn lint:js && yarn lint:cpp && yarn lint:java",
8
+ "lint": "yarn lint:js && yarn lint:cpp && yarn lint:java && yarn lint:ios && yarn lint:docs",
9
9
  "lint:js": "eslint --ext '.js,.ts,.tsx' src/ && yarn prettier --check src/",
10
10
  "lint:java": "./android/gradlew -p android spotlessCheck -q",
11
11
  "lint:cpp": "./scripts/cpplint.sh",
12
+ "lint:ios": "./scripts/validate-ios.sh && yarn format:ios --dry-run",
12
13
  "format": "yarn format:js && yarn format:java && yarn format:ios && yarn format:android && yarn format:common",
13
14
  "format:js": "prettier --write --list-different './src/'",
14
15
  "format:java": "node ./scripts/format-java.js",
15
- "format:ios": "find ios/ -iname *.h -o -iname *.m -o -iname *.mm -o -iname *.cpp | xargs clang-format -i",
16
+ "format:ios": "find ios/ -iname *.h -o -iname *.m -o -iname *.mm -o -iname *.cpp | xargs clang-format -i --Werror",
16
17
  "format:android": "find android/src/ -iname *.h -o -iname *.cpp | xargs clang-format -i",
17
18
  "format:common": "find Common/ -iname *.h -o -iname *.cpp | xargs clang-format -i",
18
19
  "release": "npm login && release-it",
@@ -26,7 +27,7 @@
26
27
  "type:generate:remove.tsx": "find ./lib -type f -name \"*.tsx\" -and -not -name \"*.d.ts\" -delete",
27
28
  "type:generate:remove.js:from-src": "find ./src/reanimated2 -type f -name \"*.js\" -delete",
28
29
  "prepare": "husky install",
29
- "circular_dependency_check": "yarn madge --extensions js,ts,tsx --circular ./src",
30
+ "circular_dependency_check": "yarn madge --extensions js,ts,tsx --circular src lib",
30
31
  "setup": "yarn && cd Example && yarn && cd ios && pod install --verbose && cd ../..",
31
32
  "clean": "rm -rf node_modules && cd Example && rm -rf node_modules && cd ios && pod deintegrate && cd ../..",
32
33
  "reset": "yarn clean && yarn setup",
@@ -122,7 +123,7 @@
122
123
  "madge": "^5.0.1",
123
124
  "prettier": "^2.5.1",
124
125
  "react": "17.0.2",
125
- "react-native": "0.70.2",
126
+ "react-native": "0.70",
126
127
  "react-native-builder-bob": "^0.18.3",
127
128
  "react-native-codegen": "^0.0.7",
128
129
  "react-native-gesture-handler": "^1.6.1",
@@ -36,7 +36,11 @@ def find_config()
36
36
  result[:react_native_minor_version] = react_native_json['version'].split('.')[1].to_i
37
37
  result[:react_native_node_modules_dir] = File.expand_path(react_native_node_modules_dir)
38
38
  result[:reanimated_node_modules_dir] = File.expand_path(File.join(__dir__, '..', '..'))
39
- result[:react_native_common_dir] = File.join(react_native_node_modules_dir, 'react-native', 'ReactCommon')
39
+
40
+ pods_root = Pod::Config.instance.project_pods_root
41
+ react_native_common_dir_absolute = File.join(react_native_node_modules_dir, 'react-native', 'ReactCommon')
42
+ react_native_common_dir_relative = Pathname.new(react_native_common_dir_absolute).relative_path_from(pods_root).to_s
43
+ result[:react_native_common_dir] = react_native_common_dir_relative
40
44
 
41
45
  return result
42
46
  end
@@ -60,6 +64,14 @@ def assert_no_multiple_instances(react_native_info)
60
64
  location['/package.json'] = ''
61
65
  parsed_location += "- " + location + "\n"
62
66
  end
63
- raise "[Reanimated] Multiple versions of Reanimated were detected. Only one instance of react-native-reanimated can be installed in a project. You need to resolve the conflict manually. Check out the documentation: https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/troubleshooting#multiple-versions-of-reanimated-were-detected \n\nConflict between: \n" + parsed_location
67
+ raise "[react-native-reanimated] Multiple versions of Reanimated were detected. Only one instance of react-native-reanimated can be installed in a project. You need to resolve the conflict manually. Check out the documentation: https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/troubleshooting#multiple-versions-of-reanimated-were-detected \n\nConflict between: \n" + parsed_location
68
+ end
69
+ end
70
+
71
+ def assert_no_reanimated2_with_new_architecture(reanimated_package_json)
72
+ reanimated_major_version = reanimated_package_json['version'].split('.')[0].to_i
73
+ fabric_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'
74
+ if fabric_enabled && reanimated_major_version == 2
75
+ raise "[react-native-reanimated] Reanimated 2.x does not support Fabric. Please upgrade to 3.x to use Reanimated with the New Architecture. For details, see https://blog.swmansion.com/announcing-reanimated-3-16167428c5f7"
64
76
  end
65
77
  end
@@ -534,12 +534,11 @@ export default function createAnimatedComponent(
534
534
  // TODO update config
535
535
  const tag = findNodeHandle(ref);
536
536
  if (
537
+ !shouldBeUseWeb() &&
537
538
  (this.props.layout || this.props.entering || this.props.exiting) &&
538
539
  tag != null
539
540
  ) {
540
- if (!shouldBeUseWeb()) {
541
- enableLayoutAnimations(true, false);
542
- }
541
+ enableLayoutAnimations(true, false);
543
542
  let layout = this.props.layout ? this.props.layout : DefaultLayout;
544
543
  let entering = this.props.entering
545
544
  ? this.props.entering
@@ -3,7 +3,7 @@ import { Component } from 'react';
3
3
  import { findNodeHandle } from 'react-native';
4
4
  import { MeasuredDimensions } from './commonTypes';
5
5
  import { RefObjectFunction } from './hook/commonTypes';
6
- import { shouldBeUseWeb } from './PlatformChecker';
6
+ import { isChromeDebugger, isWeb, shouldBeUseWeb } from './PlatformChecker';
7
7
 
8
8
  export function getTag(
9
9
  view: null | number | React.Component<any, any> | React.ComponentClass<any>
@@ -13,70 +13,114 @@ export function getTag(
13
13
 
14
14
  const isNative = !shouldBeUseWeb();
15
15
 
16
- export function measure(
16
+ export let measure: (
17
17
  animatedRef: RefObjectFunction<Component>
18
- ): MeasuredDimensions | null {
19
- 'worklet';
20
- if (!isNative) {
21
- console.warn(
22
- '[Reanimated] measure() cannot be used on web or Chrome Debugger'
23
- );
24
- return null;
25
- }
18
+ ) => MeasuredDimensions | null;
26
19
 
27
- if (!_WORKLET) {
28
- console.warn(
29
- '[Reanimated] measure() was called from the main JS context. Measure is ' +
30
- 'only available in the UI runtime. This may also happen if measure() ' +
31
- 'was called by a worklet in the useAnimatedStyle hook, because useAnimatedStyle ' +
32
- 'calls the given worklet on the JS runtime during render. If you want to ' +
33
- 'prevent this warning then wrap the call with `if (_WORKLET)`. Then it will ' +
34
- 'only be called on the UI runtime after the render has been completed.'
35
- );
20
+ if (isWeb()) {
21
+ measure = (animatedRef: RefObjectFunction<Component>) => {
22
+ const element = animatedRef() as unknown as HTMLElement; // TODO: fix typing of animated refs on web
23
+ const viewportOffset = element.getBoundingClientRect();
24
+ return {
25
+ width: element.offsetWidth,
26
+ height: element.offsetHeight,
27
+ x: element.offsetLeft,
28
+ y: element.offsetTop,
29
+ pageX: viewportOffset.left,
30
+ pageY: viewportOffset.top,
31
+ };
32
+ };
33
+ } else if (isChromeDebugger()) {
34
+ measure = (_animatedRef: RefObjectFunction<Component>) => {
35
+ console.warn('[Reanimated] measure() cannot be used with Chrome Debugger.');
36
36
  return null;
37
- }
37
+ };
38
+ } else {
39
+ measure = (animatedRef: RefObjectFunction<Component>) => {
40
+ 'worklet';
41
+ if (!_WORKLET) {
42
+ console.warn(
43
+ '[Reanimated] measure() was called from the main JS context. Measure is ' +
44
+ 'only available in the UI runtime. This may also happen if measure() ' +
45
+ 'was called by a worklet in the useAnimatedStyle hook, because useAnimatedStyle ' +
46
+ 'calls the given worklet on the JS runtime during render. If you want to ' +
47
+ 'prevent this warning then wrap the call with `if (_WORKLET)`. Then it will ' +
48
+ 'only be called on the UI runtime after the render has been completed.'
49
+ );
50
+ return null;
51
+ }
38
52
 
39
- const viewTag = animatedRef();
40
- if (viewTag === -1) {
41
- console.warn(
42
- `[Reanimated] The view with tag ${viewTag} is not a valid argument for measure(). This may be because the view is not currently rendered, which may not be a bug (e.g. an off-screen FlatList item).`
43
- );
44
- return null;
45
- }
53
+ const viewTag = animatedRef();
54
+ if (viewTag === -1) {
55
+ console.warn(
56
+ `[Reanimated] The view with tag ${viewTag} is not a valid argument for measure(). This may be because the view is not currently rendered, which may not be a bug (e.g. an off-screen FlatList item).`
57
+ );
58
+ return null;
59
+ }
46
60
 
47
- const measured = _measure(viewTag);
48
- if (measured === null) {
49
- console.warn(
50
- `[Reanimated] The view with tag ${viewTag} has some undefined, not-yet-computed or meaningless value of \`LayoutMetrics\` type. This may be because the view is not currently rendered, which may not be a bug (e.g. an off-screen FlatList item).`
51
- );
52
- return null;
53
- } else if (measured.x === -1234567) {
54
- console.warn(
55
- `[Reanimated] The view with tag ${viewTag} returned an invalid measurement response`
56
- );
57
- return null;
58
- } else if (isNaN(measured.x)) {
59
- console.warn(
60
- `[Reanimated] The view with tag ${viewTag} gets view-flattened on Android. To disable view-flattening, set \`collapsable={false}\` on this component.`
61
- );
62
- return null;
63
- } else {
64
- return measured;
65
- }
61
+ const measured = _measure(viewTag);
62
+ if (measured === null) {
63
+ console.warn(
64
+ `[Reanimated] The view with tag ${viewTag} has some undefined, not-yet-computed or meaningless value of \`LayoutMetrics\` type. This may be because the view is not currently rendered, which may not be a bug (e.g. an off-screen FlatList item).`
65
+ );
66
+ return null;
67
+ } else if (measured.x === -1234567) {
68
+ console.warn(
69
+ `[Reanimated] The view with tag ${viewTag} returned an invalid measurement response.`
70
+ );
71
+ return null;
72
+ } else if (isNaN(measured.x)) {
73
+ console.warn(
74
+ `[Reanimated] The view with tag ${viewTag} gets view-flattened on Android. To disable view-flattening, set \`collapsable={false}\` on this component.`
75
+ );
76
+ return null;
77
+ } else {
78
+ return measured;
79
+ }
80
+ };
66
81
  }
67
82
 
68
- export function scrollTo(
83
+ export let scrollTo: (
69
84
  animatedRef: RefObjectFunction<Component>,
70
85
  x: number,
71
86
  y: number,
72
87
  animated: boolean
73
- ): void {
74
- 'worklet';
75
- if (!_WORKLET || !isNative) {
76
- return;
77
- }
78
- const viewTag = animatedRef();
79
- _scrollTo(viewTag, x, y, animated);
88
+ ) => void;
89
+
90
+ if (isWeb()) {
91
+ scrollTo = (
92
+ animatedRef: RefObjectFunction<Component>,
93
+ x: number,
94
+ y: number,
95
+ animated: boolean
96
+ ) => {
97
+ 'worklet';
98
+ const element = animatedRef() as unknown as HTMLElement;
99
+ // @ts-ignore same call as in react-native-web
100
+ element.scrollTo({ x, y, animated });
101
+ };
102
+ } else if (isNative) {
103
+ scrollTo = (
104
+ animatedRef: RefObjectFunction<Component>,
105
+ x: number,
106
+ y: number,
107
+ animated: boolean
108
+ ) => {
109
+ 'worklet';
110
+ if (!_WORKLET) {
111
+ return;
112
+ }
113
+ const viewTag = animatedRef();
114
+ _scrollTo(viewTag, x, y, animated);
115
+ };
116
+ } else {
117
+ scrollTo = (
118
+ _animatedRef: RefObjectFunction<Component>,
119
+ _x: number,
120
+ _y: number
121
+ ) => {
122
+ // no-op
123
+ };
80
124
  }
81
125
 
82
126
  export function setGestureState(handlerTag: number, newState: number): void {
@@ -11,7 +11,7 @@ export type FrameInfo = {
11
11
  timeSinceFirstFrame: number;
12
12
  };
13
13
 
14
- interface FrameCallbackRegistryUI {
14
+ export interface FrameCallbackRegistryUI {
15
15
  frameCallbackRegistry: Map<number, CallbackDetails>;
16
16
  activeFrameCallbacks: Set<number>;
17
17
  previousFrameTimestamp: number | null;
@@ -1,13 +1,19 @@
1
- import { AnimatedStyle, StyleProps } from './commonTypes';
2
- import { ReanimatedConsole } from './core';
3
- import FrameCallbackRegistryUI from './frameCallback/FrameCallbackRegistryUI';
4
- import { MeasuredDimensions } from './NativeMethods';
5
- import { NativeReanimated } from './NativeReanimated/NativeReanimated';
1
+ import type {
2
+ AnimatedStyle,
3
+ StyleProps,
4
+ MeasuredDimensions,
5
+ } from './commonTypes';
6
+ import type { ReanimatedConsole } from './core';
7
+ import type { NativeReanimated } from './NativeReanimated/NativeReanimated';
8
+ import type { FrameCallbackRegistryUI } from './frameCallback/FrameCallbackRegistryUI';
9
+
6
10
  declare global {
7
11
  const _WORKLET: boolean;
8
- const _frameTimestamp: number;
12
+ const _frameTimestamp: number | null;
9
13
  const _eventTimestamp: number;
14
+ const __reanimatedModuleProxy: NativeReanimated;
10
15
  const _setGlobalConsole: (console?: ReanimatedConsole) => void;
16
+ const _log: (s: string) => void;
11
17
  const _getCurrentTime: () => number;
12
18
  const _stopObservingProgress: (tag: number, flag: boolean) => void;
13
19
  const _startObservingProgress: (
@@ -20,7 +26,7 @@ declare global {
20
26
  name: string,
21
27
  updates: StyleProps | AnimatedStyle
22
28
  ) => void;
23
- const _measure: (viewTag: number) => MeasuredDimensions | null;
29
+ const _measure: (viewTag: number) => MeasuredDimensions;
24
30
  const _scrollTo: (
25
31
  viewTag: number,
26
32
  x: number,
@@ -28,20 +34,40 @@ declare global {
28
34
  animated: boolean
29
35
  ) => void;
30
36
  const _chronoNow: () => number;
37
+ const performance: { now: () => number };
38
+ const LayoutAnimationRepository: {
39
+ configs: Record<string, unknown>;
40
+ registerConfig(tag: number, config: Record<string, unknown>): void;
41
+ removeConfig(tag: number): void;
42
+ startAnimationForTag(tag: number, type: string, yogaValues: unknown): void;
43
+ };
31
44
  const ReanimatedDataMock: {
32
45
  now: () => number;
33
46
  };
34
47
  const _frameCallbackRegistry: FrameCallbackRegistryUI;
35
48
  namespace NodeJS {
36
49
  interface Global {
37
- _setGlobalConsole: (console?: ReanimatedConsole) => void;
38
- _log: (s: string) => void;
39
- _setGestureState: () => void;
40
50
  _WORKLET: boolean;
41
- __reanimatedModuleProxy: NativeReanimated;
51
+ _IS_FABRIC: boolean;
42
52
  _frameTimestamp: number | null;
43
- _measure: () => MeasuredDimensions | null;
44
- _scrollTo: () => void;
53
+ _eventTimestamp: number;
54
+ __reanimatedModuleProxy: NativeReanimated;
55
+ _setGlobalConsole: (console?: ReanimatedConsole) => void;
56
+ _log: (s: string) => void;
57
+ _getCurrentTime: () => number;
58
+ _stopObservingProgress: (tag: number, flag: boolean) => void;
59
+ _startObservingProgress: (
60
+ tag: number,
61
+ flag: { value: boolean; _value: boolean }
62
+ ) => void;
63
+ _setGestureState: (handlerTag: number, newState: number) => void;
64
+ _measure: (viewTag: number) => MeasuredDimensions;
65
+ _scrollTo: (
66
+ viewTag: number,
67
+ x: number,
68
+ y: number,
69
+ animated: boolean
70
+ ) => void;
45
71
  _chronoNow: () => number;
46
72
  performance: { now: () => number };
47
73
  LayoutAnimationRepository: {
@@ -1,10 +1,11 @@
1
1
  import { RefObject, useEffect, useRef } from 'react';
2
2
 
3
- import { findNodeHandle } from 'react-native';
4
3
  import type Animated from 'react-native-reanimated';
5
- import { useEvent, useSharedValue } from '.';
6
- import { SharedValue } from '../commonTypes';
7
4
  import { ScrollEvent } from './useAnimatedScrollHandler';
5
+ import { SharedValue } from '../commonTypes';
6
+ import { findNodeHandle } from 'react-native';
7
+ import { useEvent } from './utils';
8
+ import { useSharedValue } from './useSharedValue';
8
9
 
9
10
  const subscribeForEvents = [
10
11
  'onScroll',
@@ -188,13 +188,21 @@ export const advanceAnimationByFrame = (count) => {
188
188
  };
189
189
 
190
190
  export const setUpTests = (userConfig = {}) => {
191
- let expect;
192
- try {
193
- expect = require('expect');
194
- } catch (_) {
195
- // for Jest in version 28+
196
- const { expect: expectModule } = require('@jest/globals');
191
+ let expect = global.expect;
192
+ if (expect === undefined) {
193
+ const expectModule = require('expect');
197
194
  expect = expectModule;
195
+ // Starting from Jest 28, "expect" package uses named exports instead of default export.
196
+ // So, requiring "expect" package doesn't give direct access to "expect" function anymore.
197
+ // It gives access to the module object instead.
198
+ // We use this info to detect if the project uses Jest 28 or higher.
199
+ if (typeof expect === 'object') {
200
+ const jestGlobals = require('@jest/globals');
201
+ expect = jestGlobals.expect;
202
+ }
203
+ if (expect === undefined || expect.extend === undefined) {
204
+ expect = expectModule.default;
205
+ }
198
206
  }
199
207
 
200
208
  require('setimmediate');
@@ -1,68 +0,0 @@
1
- package com.facebook.react.uimanager;
2
-
3
- import androidx.annotation.Nullable;
4
- import com.facebook.react.bridge.ReactApplicationContext;
5
- import com.facebook.react.bridge.ReadableArray;
6
- import com.facebook.react.uimanager.events.EventDispatcher;
7
- import com.swmansion.reanimated.layoutReanimation.ReanimatedNativeHierarchyManager;
8
- import java.util.List;
9
-
10
- public class ReanimatedUIImplementation extends UIImplementation {
11
- public ReanimatedUIImplementation(
12
- ReactApplicationContext reactContext,
13
- UIManagerModule.ViewManagerResolver viewManagerResolver,
14
- EventDispatcher eventDispatcher,
15
- int minTimeLeftInFrameForNonBatchedOperationMs) {
16
- this(
17
- reactContext,
18
- new ViewManagerRegistry(viewManagerResolver),
19
- eventDispatcher,
20
- minTimeLeftInFrameForNonBatchedOperationMs);
21
- }
22
-
23
- public ReanimatedUIImplementation(
24
- ReactApplicationContext reactContext,
25
- List<ViewManager> viewManagerList,
26
- EventDispatcher eventDispatcher,
27
- int minTimeLeftInFrameForNonBatchedOperationMs) {
28
- this(
29
- reactContext,
30
- new ViewManagerRegistry(viewManagerList),
31
- eventDispatcher,
32
- minTimeLeftInFrameForNonBatchedOperationMs);
33
- }
34
-
35
- public ReanimatedUIImplementation(
36
- ReactApplicationContext reactContext,
37
- ViewManagerRegistry viewManagerRegistry,
38
- EventDispatcher eventDispatcher,
39
- int minTimeLeftInFrameForNonBatchedOperationMs) {
40
- super(
41
- reactContext,
42
- viewManagerRegistry,
43
- new UIViewOperationQueue(
44
- reactContext,
45
- new ReanimatedNativeHierarchyManager(viewManagerRegistry, reactContext),
46
- minTimeLeftInFrameForNonBatchedOperationMs),
47
- eventDispatcher);
48
- }
49
-
50
- /**
51
- * Invoked when there is a mutation in a node tree.
52
- *
53
- * @param tag react tag of the node we want to manage
54
- * @param indicesToRemove ordered (asc) list of indicies at which view should be removed
55
- * @param viewsToAdd ordered (asc based on mIndex property) list of tag-index pairs that represent
56
- * a view which should be added at the specified index
57
- * @param tagsToDelete list of tags corresponding to views that should be removed
58
- */
59
- public void manageChildren(
60
- int viewTag,
61
- @Nullable ReadableArray moveFrom,
62
- @Nullable ReadableArray moveTo,
63
- @Nullable ReadableArray addChildTags,
64
- @Nullable ReadableArray addAtIndices,
65
- @Nullable ReadableArray removeFrom) {
66
- super.manageChildren(viewTag, moveFrom, moveTo, addChildTags, addAtIndices, removeFrom);
67
- }
68
- }
@@ -1,68 +0,0 @@
1
- package com.facebook.react.uimanager;
2
-
3
- import androidx.annotation.Nullable;
4
- import com.facebook.react.bridge.ReactApplicationContext;
5
- import com.facebook.react.bridge.ReadableArray;
6
- import com.facebook.react.uimanager.events.EventDispatcher;
7
- import com.swmansion.reanimated.layoutReanimation.ReanimatedNativeHierarchyManager;
8
- import java.util.List;
9
-
10
- public class ReanimatedUIImplementation extends UIImplementation {
11
- public ReanimatedUIImplementation(
12
- ReactApplicationContext reactContext,
13
- UIManagerModule.ViewManagerResolver viewManagerResolver,
14
- EventDispatcher eventDispatcher,
15
- int minTimeLeftInFrameForNonBatchedOperationMs) {
16
- this(
17
- reactContext,
18
- new ViewManagerRegistry(viewManagerResolver),
19
- eventDispatcher,
20
- minTimeLeftInFrameForNonBatchedOperationMs);
21
- }
22
-
23
- public ReanimatedUIImplementation(
24
- ReactApplicationContext reactContext,
25
- List<ViewManager> viewManagerList,
26
- EventDispatcher eventDispatcher,
27
- int minTimeLeftInFrameForNonBatchedOperationMs) {
28
- this(
29
- reactContext,
30
- new ViewManagerRegistry(viewManagerList),
31
- eventDispatcher,
32
- minTimeLeftInFrameForNonBatchedOperationMs);
33
- }
34
-
35
- public ReanimatedUIImplementation(
36
- ReactApplicationContext reactContext,
37
- ViewManagerRegistry viewManagerRegistry,
38
- EventDispatcher eventDispatcher,
39
- int minTimeLeftInFrameForNonBatchedOperationMs) {
40
- super(
41
- reactContext,
42
- viewManagerRegistry,
43
- new UIViewOperationQueue(
44
- reactContext,
45
- new ReanimatedNativeHierarchyManager(viewManagerRegistry, reactContext),
46
- minTimeLeftInFrameForNonBatchedOperationMs),
47
- eventDispatcher);
48
- }
49
-
50
- /**
51
- * Invoked when there is a mutation in a node tree.
52
- *
53
- * @param tag react tag of the node we want to manage
54
- * @param indicesToRemove ordered (asc) list of indicies at which view should be removed
55
- * @param viewsToAdd ordered (asc based on mIndex property) list of tag-index pairs that represent
56
- * a view which should be added at the specified index
57
- * @param tagsToDelete list of tags corresponding to views that should be removed
58
- */
59
- public void manageChildren(
60
- int viewTag,
61
- @Nullable ReadableArray moveFrom,
62
- @Nullable ReadableArray moveTo,
63
- @Nullable ReadableArray addChildTags,
64
- @Nullable ReadableArray addAtIndices,
65
- @Nullable ReadableArray removeFrom) {
66
- super.manageChildren(viewTag, moveFrom, moveTo, addChildTags, addAtIndices, removeFrom);
67
- }
68
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes