react-native-reanimated 3.0.0-rc.3 → 3.0.0-rc.4

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 (51) hide show
  1. package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +5 -1
  2. package/Common/cpp/SharedItems/ShareableValue.cpp +0 -2
  3. package/RNReanimated.podspec +19 -85
  4. package/android/CMakeLists.txt +22 -21
  5. package/android/build.gradle +344 -56
  6. package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
  7. package/android/src/main/cpp/AndroidErrorHandler.cpp +3 -4
  8. package/android/src/main/cpp/AndroidErrorHandler.h +1 -4
  9. package/android/src/main/java/com/swmansion/reanimated/{ReanimatedMessageQueueThread.java → ReanimatedMessageQueueThreadBase.java} +3 -8
  10. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +1 -1
  11. package/android/{rnVersionPatch/62 → src/reactNativeVersionPatch/UIImplementation/64/com/swmansion/reanimated}/layoutReanimation/ReanimatedUIImplementation.java +0 -0
  12. package/android/src/{main/java → reactNativeVersionPatch/UIImplementation/latest}/com/swmansion/reanimated/layoutReanimation/ReanimatedUIImplementation.java +0 -0
  13. package/android/src/reactNativeVersionPatch/messageQueueThread/67/com/swmansion/reanimated/ReanimatedMessageQueueThread.java +12 -0
  14. package/android/src/reactNativeVersionPatch/messageQueueThread/latest/com/swmansion/reanimated/ReanimatedMessageQueueThread.java +12 -0
  15. package/android/{rnVersionPatch/62 → src/reactNativeVersionPatch/nativeHierarchyManager/62/com/swmansion/reanimated}/layoutReanimation/ReanimatedNativeHierarchyManager.java +0 -0
  16. package/android/src/{main/java → reactNativeVersionPatch/nativeHierarchyManager/latest}/com/swmansion/reanimated/layoutReanimation/ReanimatedNativeHierarchyManager.java +0 -0
  17. package/ios/REAModule.mm +21 -2
  18. package/ios/keyboardObserver/REAKeyboardEventObserver.m +1 -1
  19. package/ios/native/REAMessageThread.mm +1 -1
  20. package/lib/commonjs/createAnimatedComponent.js +2 -5
  21. package/lib/commonjs/createAnimatedComponent.js.map +1 -1
  22. package/lib/commonjs/reanimated2/NativeMethods.js +66 -26
  23. package/lib/commonjs/reanimated2/NativeMethods.js.map +1 -1
  24. package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryUI.js.map +1 -1
  25. package/lib/commonjs/reanimated2/globals.d.js.map +1 -1
  26. package/lib/commonjs/reanimated2/hook/useScrollViewOffset.js +5 -3
  27. package/lib/commonjs/reanimated2/hook/useScrollViewOffset.js.map +1 -1
  28. package/lib/module/createAnimatedComponent.js +2 -5
  29. package/lib/module/createAnimatedComponent.js.map +1 -1
  30. package/lib/module/reanimated2/NativeMethods.js +67 -25
  31. package/lib/module/reanimated2/NativeMethods.js.map +1 -1
  32. package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js.map +1 -1
  33. package/lib/module/reanimated2/globals.d.js.map +1 -1
  34. package/lib/module/reanimated2/hook/useScrollViewOffset.js +2 -1
  35. package/lib/module/reanimated2/hook/useScrollViewOffset.js.map +1 -1
  36. package/package.json +7 -5
  37. package/plugin.js +1 -1
  38. package/scripts/reanimated_utils.rb +77 -0
  39. package/src/createAnimatedComponent.tsx +2 -3
  40. package/src/reanimated2/NativeMethods.ts +85 -33
  41. package/src/reanimated2/frameCallback/FrameCallbackRegistryUI.ts +1 -1
  42. package/src/reanimated2/globals.d.ts +56 -14
  43. package/src/reanimated2/hook/useScrollViewOffset.ts +4 -3
  44. package/android/rnVersionPatch/63/layoutReanimation/ReanimatedUIImplementation.java +0 -68
  45. package/android/rnVersionPatch/64/layoutReanimation/ReanimatedUIImplementation.java +0 -68
  46. package/android/rnVersionPatch/65/.gitkeep +0 -0
  47. package/android/rnVersionPatch/66/.gitkeep +0 -0
  48. package/android/rnVersionPatch/67/.gitkeep +0 -0
  49. package/android/rnVersionPatch/68/.gitkeep +0 -0
  50. package/android/rnVersionPatch/backup/.gitkeep +0 -0
  51. package/android/src/main/java/com/swmansion/reanimated/AndroidErrorHandler.java +0 -8
@@ -584,7 +584,11 @@ jsi::Value NativeReanimatedModule::measure(
584
584
  uiManager_, *shadowNode, nullptr, {/* .includeTransform = */ true});
585
585
 
586
586
  if (layoutMetrics == EmptyLayoutMetrics) {
587
- return jsi::Value::undefined();
587
+ // Originally, in this case React Native returns `{0, 0, 0, 0, 0, 0}`, most
588
+ // likely due to the type of measure callback function which accepts just an
589
+ // array of numbers (not null). In Reanimated, `measure` returns
590
+ // `MeasuredDimensions | null`.
591
+ return jsi::Value::null();
588
592
  }
589
593
  auto newestCloneOfShadowNode =
590
594
  uiManager_->getNewestCloneOfShadowNode(*shadowNode);
@@ -414,8 +414,6 @@ jsi::Value ShareableValue::toJSValue(jsi::Runtime &rt) {
414
414
  } else {
415
415
  res = funPtr->call(rt, args, count);
416
416
  }
417
- } catch (jsi::JSError &e) {
418
- throw e;
419
417
  } catch (std::exception &e) {
420
418
  std::string str = e.what();
421
419
  runtimeManager->errorHandler->setError(str);
@@ -1,91 +1,23 @@
1
1
  require "json"
2
+ require_relative './scripts/reanimated_utils'
2
3
 
3
- package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
-
5
- reactNativeVersion = '0.0.0'
6
- reactTargetTvOS = false
7
- isUserApp = false
8
- nodeModulesDir = File.join(__dir__, "..", "..", "node_modules")
9
-
10
- begin
11
- # user app
12
- # /appName/node_modules/react-native-reanimated/RNReanimated.podspec
13
- # /appName/node_modules/react-native/package.json
14
- nodeModulesDir = File.join(__dir__, "..", "..", "node_modules")
15
- reactNativePackageJson = JSON.parse(File.read(File.join(nodeModulesDir, "react-native", "package.json")))
16
- reactNativeVersion = reactNativePackageJson["version"]
17
- reactTargetTvOS = reactNativePackageJson["name"] == "react-native-tvos"
18
- isUserApp = true
19
- rescue
20
- begin
21
- # monorepo
22
- # /monorepo/packages/appName/node_modules/react-native-reanimated/RNReanimated.podspec
23
- # /monorepo/node_modules/react-native/package.json
24
- nodeModulesDir = File.join(__dir__, "..", "..", "..", "..", "node_modules")
25
- reactNativePackageJson = JSON.parse(File.read(File.join(nodeModulesDir, "react-native", "package.json")))
26
- reactNativeVersion = reactNativePackageJson["version"]
27
- reactTargetTvOS = reactNativePackageJson["name"] == "react-native-tvos"
28
- rescue
29
- begin
30
- # Example app in reanimated repo
31
- # /react-native-reanimated/RNReanimated.podspec
32
- # /react-native-reanimated/{Example,FabricExample,TVOSExample}/node_modules/react-native/package.json
33
- if ENV["ReanimatedTVOSExample"] == "1" then
34
- appName = "TVOSExample"
35
- elsif ENV["RCT_NEW_ARCH_ENABLED"] == "1" then
36
- appName = "FabricExample"
37
- else
38
- appName = "Example"
39
- end
40
- nodeModulesDir = File.join(__dir__, appName, "node_modules")
41
- reactNativePackageJson = JSON.parse(File.read(File.join(nodeModulesDir, "react-native", "package.json")))
42
- reactNativeVersion = reactNativePackageJson["version"]
43
- reactTargetTvOS = ENV["ReanimatedTVOSExample"] == "1"
44
- rescue
45
- # should never happen
46
- reactNativeVersion = '0.68.0'
47
- puts "[RNReanimated] Unable to recognize your `react-native` version! Default `react-native` version: " + reactNativeVersion
48
- end
49
- end
50
- end
51
-
52
- reactCommonDir = File.join(nodeModulesDir, "react-native", "ReactCommon")
53
-
54
- if isUserApp
55
- libInstances = %x[find ../../ -name "package.json" | grep "/react-native-reanimated/package.json" | grep -v "/.yarn/"]
56
- libInstancesArray = libInstances.split("\n")
57
- if libInstancesArray.length() > 1
58
- parsedLocation = ''
59
- for location in libInstancesArray
60
- location['../../'] = '- '
61
- location['/package.json'] = ''
62
- parsedLocation += location + "\n"
63
- end
64
- 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" + parsedLocation
65
- end
66
- end
67
-
68
- reactNativeMinorVersion = reactNativeVersion.split('.')[1].to_i
4
+ reanimated_package_json = JSON.parse(File.read(File.join(__dir__, "package.json")))
5
+ config = find_config()
6
+ assert_no_multiple_instances(config)
7
+ assert_no_reanimated2_with_new_architecture(reanimated_package_json)
69
8
 
70
9
  fabric_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'
71
-
72
- folly_prefix = ""
73
- if reactNativeMinorVersion >= 64
74
- folly_prefix = "RCT-"
75
- end
76
-
77
- folly_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32 -DREACT_NATIVE_MINOR_VERSION=' + reactNativeMinorVersion.to_s
10
+ folly_prefix = config[:react_native_minor_version] >= 64 ? 'RCT-' : ''
11
+ folly_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32 -DREACT_NATIVE_MINOR_VERSION=' + config[:react_native_minor_version].to_s
78
12
  folly_compiler_flags = folly_flags + ' ' + '-Wno-comma -Wno-shorten-64-to-32'
79
13
  boost_compiler_flags = '-Wno-documentation'
80
- fabric_flags = ''
81
- if fabric_enabled
82
- fabric_flags = '-DRN_FABRIC_ENABLED -DRCT_NEW_ARCH_ENABLED'
83
- end
14
+ fabric_flags = fabric_enabled ? '-DRN_FABRIC_ENABLED -DRCT_NEW_ARCH_ENABLED' : ''
84
15
 
85
16
  Pod::Spec.new do |s|
17
+
86
18
  s.name = "RNReanimated"
87
- s.version = package["version"]
88
- s.summary = package["description"]
19
+ s.version = reanimated_package_json["version"]
20
+ s.summary = reanimated_package_json["description"]
89
21
  s.description = <<-DESC
90
22
  RNReanimated
91
23
  DESC
@@ -105,15 +37,17 @@ Pod::Spec.new do |s|
105
37
  "Common/cpp/hidden_headers/**"
106
38
  ]
107
39
 
108
- s.pod_target_xcconfig = {
40
+ s.pod_target_xcconfig = {
109
41
  "USE_HEADERMAP" => "YES",
110
42
  "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_TARGET_SRCROOT)\" \"$(PODS_ROOT)/#{folly_prefix}Folly\" \"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/Headers/Private/React-Core\"",
43
+ "FRAMEWORK_SEARCH_PATHS" => "\"${PODS_CONFIGURATION_BUILD_DIR}/React-hermes\"",
111
44
  "CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
112
45
  }
113
46
  s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags + ' -DHERMES_ENABLE_DEBUGGER'
114
- s.xcconfig = {
115
- "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/glog\" \"$(PODS_ROOT)/#{folly_prefix}Folly\" \"$(PODS_ROOT)/RCT-Folly\" \"${PODS_ROOT}/Headers/Public/React-hermes\" \"${PODS_ROOT}/Headers/Public/hermes-engine\" \"#{reactCommonDir}\"",
116
- "OTHER_CFLAGS" => "$(inherited)" + " " + folly_flags + " " + fabric_flags }
47
+ s.xcconfig = {
48
+ "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/glog\" \"$(PODS_ROOT)/#{folly_prefix}Folly\" \"$(PODS_ROOT)/Headers/Public/React-hermes\" \"$(PODS_ROOT)/Headers/Public/hermes-engine\" \"$(PODS_ROOT)/#{config[:react_native_common_dir]}\"",
49
+ "OTHER_CFLAGS" => "$(inherited)" + " " + folly_flags + " " + fabric_flags
50
+ }
117
51
 
118
52
  s.requires_arc = true
119
53
 
@@ -133,7 +67,7 @@ Pod::Spec.new do |s|
133
67
  s.dependency 'React-Core'
134
68
  s.dependency 'React-CoreModules'
135
69
  s.dependency 'React-Core/DevSupport'
136
- if !reactTargetTvOS
70
+ if !config[:is_tvos_target]
137
71
  s.dependency 'React-RCTActionSheet'
138
72
  end
139
73
  s.dependency 'React-RCTNetwork'
@@ -152,7 +86,7 @@ Pod::Spec.new do |s|
152
86
  s.dependency 'DoubleConversion'
153
87
  s.dependency 'glog'
154
88
 
155
- if reactNativeMinorVersion == 62
89
+ if config[:react_native_minor_version] == 62
156
90
  s.dependency 'ReactCommon/callinvoker'
157
91
  else
158
92
  s.dependency 'React-callinvoker'
@@ -27,18 +27,19 @@ set (BUILD_DIR ${CMAKE_SOURCE_DIR}/build)
27
27
  set (SRC_DIR ${CMAKE_SOURCE_DIR}/src)
28
28
 
29
29
  set (COMMON_SRC_DIR "${CMAKE_SOURCE_DIR}/../Common")
30
-
31
30
  if(${IS_NEW_ARCHITECTURE_ENABLED})
32
31
  if(${CLIENT_SIDE_BUILD})
33
32
  set (RN_SO_DIR "${CMAKE_SOURCE_DIR}/../../../android/app/build/react-ndk/exported")
34
- set (FBJNI_HEADERS_DIR "${CMAKE_SOURCE_DIR}/../../react-native/ReactAndroid/src/main/jni/first-party/fbjni/headers")
33
+ set (FBJNI_HEADERS_DIR "${REACT_NATIVE_DIR}/ReactAndroid/src/main/jni/first-party/fbjni/headers")
35
34
  else()
35
+ # Reanimated Playground app
36
36
  set (RN_SO_DIR "${CMAKE_SOURCE_DIR}/../${PLAYGROUND_APP_NAME}/android/app/build/react-ndk/exported")
37
- set (FBJNI_HEADERS_DIR "${CMAKE_SOURCE_DIR}/../${PLAYGROUND_APP_NAME}/node_modules/react-native/ReactAndroid/src/main/jni/first-party/fbjni/headers")
37
+ set (FBJNI_HEADERS_DIR "${REACT_NATIVE_DIR}/ReactAndroid/src/main/jni/first-party/fbjni/headers")
38
+
38
39
  endif()
39
40
  else()
40
- set (RN_SO_DIR ${NODE_MODULES_DIR}/react-native/ReactAndroid/src/main/jni/first-party/react/jni)
41
- set (FBJNI_HEADERS_DIR "${NODE_MODULES_DIR}/react-native/ReactAndroid/src/main/jni/first-party/fbjni/headers")
41
+ set (RN_SO_DIR ${REACT_NATIVE_DIR}/ReactAndroid/src/main/jni/first-party/react/jni)
42
+ set (FBJNI_HEADERS_DIR "${REACT_NATIVE_DIR}/ReactAndroid/src/main/jni/first-party/fbjni/headers")
42
43
  endif()
43
44
 
44
45
  file (GLOB LIBRN_DIR "${RN_SO_DIR}/${ANDROID_ABI}")
@@ -49,11 +50,11 @@ file(GLOB_RECURSE SOURCES_ANDROID CONFIGURE_DEPENDS "${SRC_DIR}/main/cpp/**.cpp"
49
50
  if(${REACT_NATIVE_MINOR_VERSION} LESS 66)
50
51
  set (
51
52
  INCLUDE_JSI_CPP
52
- "${NODE_MODULES_DIR}/react-native/ReactCommon/jsi/jsi/jsi.cpp"
53
+ "${REACT_NATIVE_DIR}/ReactCommon/jsi/jsi/jsi.cpp"
53
54
  )
54
55
  set (
55
56
  INCLUDE_JSIDYNAMIC_CPP
56
- "${NODE_MODULES_DIR}/react-native/ReactCommon/jsi/jsi/JSIDynamic.cpp"
57
+ "${REACT_NATIVE_DIR}/ReactCommon/jsi/jsi/JSIDynamic.cpp"
57
58
  )
58
59
  endif()
59
60
 
@@ -78,20 +79,20 @@ target_include_directories(
78
79
  "${BUILD_DIR}/third-party-ndk/double-conversion"
79
80
  "${BUILD_DIR}/third-party-ndk/folly"
80
81
  "${BUILD_DIR}/third-party-ndk/glog/exported"
81
- "${NODE_MODULES_DIR}/react-native/React"
82
- "${NODE_MODULES_DIR}/react-native/React/Base"
83
- "${NODE_MODULES_DIR}/react-native/ReactAndroid/src/main/jni"
84
- "${NODE_MODULES_DIR}/react-native/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni"
85
- "${NODE_MODULES_DIR}/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/jni"
86
- "${NODE_MODULES_DIR}/react-native/ReactCommon"
87
- "${NODE_MODULES_DIR}/react-native/ReactCommon/callinvoker"
88
- "${NODE_MODULES_DIR}/react-native/ReactCommon/jsi"
89
- "${NODE_MODULES_DIR}/react-native/ReactCommon/hermes"
90
- "${NODE_MODULES_DIR}/react-native/ReactCommon/react/renderer/graphics/platform/cxx"
91
- "${NODE_MODULES_DIR}/react-native/ReactCommon/runtimeexecutor"
92
- "${NODE_MODULES_DIR}/react-native/ReactCommon/turbomodule/core"
93
- "${NODE_MODULES_DIR}/react-native/ReactCommon/turbomodule"
94
- "${NODE_MODULES_DIR}/react-native/ReactCommon/yoga"
82
+ "${REACT_NATIVE_DIR}/React"
83
+ "${REACT_NATIVE_DIR}/React/Base"
84
+ "${REACT_NATIVE_DIR}/ReactAndroid/src/main/jni"
85
+ "${REACT_NATIVE_DIR}/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni"
86
+ "${REACT_NATIVE_DIR}/ReactAndroid/src/main/java/com/facebook/react/fabric/jni"
87
+ "${REACT_NATIVE_DIR}/ReactCommon"
88
+ "${REACT_NATIVE_DIR}/ReactCommon/callinvoker"
89
+ "${REACT_NATIVE_DIR}/ReactCommon/jsi"
90
+ "${REACT_NATIVE_DIR}/ReactCommon/hermes"
91
+ "${REACT_NATIVE_DIR}/ReactCommon/react/renderer/graphics/platform/cxx"
92
+ "${REACT_NATIVE_DIR}/ReactCommon/runtimeexecutor"
93
+ "${REACT_NATIVE_DIR}/ReactCommon/turbomodule/core"
94
+ "${REACT_NATIVE_DIR}/ReactCommon/turbomodule"
95
+ "${REACT_NATIVE_DIR}/ReactCommon/yoga"
95
96
  "${COMMON_SRC_DIR}/cpp/Tools"
96
97
  "${COMMON_SRC_DIR}/cpp/SpecTools"
97
98
  "${COMMON_SRC_DIR}/cpp/NativeModules"