react-native-reanimated 2.7.0 → 2.9.1

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 (83) hide show
  1. package/Common/cpp/Tools/RuntimeDecorator.cpp +17 -11
  2. package/android/.gradle/7.2/dependencies-accessors/dependencies-accessors.lock +0 -0
  3. package/android/.gradle/7.2/executionHistory/executionHistory.bin +0 -0
  4. package/android/.gradle/7.2/executionHistory/executionHistory.lock +0 -0
  5. package/android/.gradle/7.2/fileHashes/fileHashes.bin +0 -0
  6. package/android/.gradle/7.2/fileHashes/fileHashes.lock +0 -0
  7. package/android/.gradle/7.2/fileHashes/resourceHashesCache.bin +0 -0
  8. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  9. package/android/.gradle/buildOutputCleanup/cache.properties +1 -1
  10. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  11. package/android/.gradle/checksums/checksums.lock +0 -0
  12. package/android/.gradle/checksums/md5-checksums.bin +0 -0
  13. package/android/.gradle/checksums/sha1-checksums.bin +0 -0
  14. package/android/CMakeLists.txt +21 -8
  15. package/android/build.gradle +23 -8
  16. package/android/react-native-reanimated-65-hermes.aar +0 -0
  17. package/android/react-native-reanimated-65-jsc.aar +0 -0
  18. package/android/react-native-reanimated-66-hermes.aar +0 -0
  19. package/android/react-native-reanimated-66-jsc.aar +0 -0
  20. package/android/react-native-reanimated-67-hermes.aar +0 -0
  21. package/android/react-native-reanimated-67-jsc.aar +0 -0
  22. package/android/react-native-reanimated-68-hermes.aar +0 -0
  23. package/android/react-native-reanimated-68-jsc.aar +0 -0
  24. package/android/react-native-reanimated-69-hermes.aar +0 -0
  25. package/android/react-native-reanimated-69-jsc.aar +0 -0
  26. package/android/rnVersionPatch/69/.gitkeep +0 -0
  27. package/android/src/main/cpp/NativeProxy.cpp +35 -14
  28. package/android/src/main/cpp/headers/NativeProxy.h +2 -0
  29. package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorListener.java +24 -1
  30. package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorType.java +7 -5
  31. package/ios/native/NativeProxy.mm +6 -2
  32. package/ios/native/REAInitializer.mm +11 -1
  33. package/ios/sensor/ReanimatedSensor.m +2 -2
  34. package/lib/Animated.js +8 -30
  35. package/lib/index.js +5 -30
  36. package/lib/reanimated2/NativeReanimated/NativeReanimated.js +1 -1
  37. package/lib/reanimated2/animation/sequence.js +0 -3
  38. package/lib/reanimated2/component/FlatList.js +3 -3
  39. package/lib/reanimated2/component/Image.js +4 -0
  40. package/lib/reanimated2/component/ScrollView.js +4 -0
  41. package/lib/reanimated2/component/Text.js +4 -0
  42. package/lib/reanimated2/component/View.js +4 -0
  43. package/lib/reanimated2/core.js +0 -5
  44. package/lib/reanimated2/hook/utils.js +0 -5
  45. package/lib/reanimated2/js-reanimated/global.js +25 -0
  46. package/lib/reanimated2/js-reanimated/index.js +0 -24
  47. package/lib/reanimated2/mock.js +6 -0
  48. package/lib/types/lib/Animated.d.ts +8 -0
  49. package/lib/types/lib/index.d.ts +4 -0
  50. package/lib/types/lib/reanimated2/component/Image.d.ts +3 -0
  51. package/lib/types/lib/reanimated2/component/ScrollView.d.ts +3 -0
  52. package/lib/types/lib/reanimated2/component/Text.d.ts +3 -0
  53. package/lib/types/lib/reanimated2/component/View.d.ts +3 -0
  54. package/lib/types/lib/reanimated2/hook/useAnimatedSensor.d.ts +1 -3
  55. package/lib/types/lib/reanimated2/js-reanimated/global.d.ts +1 -0
  56. package/lib/types/lib/reanimated2/mock.d.ts +6 -0
  57. package/package.json +15 -9
  58. package/plugin.js +36 -21
  59. package/react-native-reanimated.d.ts +16 -7
  60. package/src/Animated.ts +13 -0
  61. package/src/index.ts +7 -0
  62. package/src/reanimated2/NativeReanimated/NativeReanimated.ts +1 -1
  63. package/src/reanimated2/animation/sequence.ts +0 -5
  64. package/src/reanimated2/component/FlatList.tsx +3 -6
  65. package/src/reanimated2/component/Image.ts +6 -0
  66. package/src/reanimated2/component/ScrollView.ts +6 -0
  67. package/src/reanimated2/component/Text.ts +6 -0
  68. package/src/reanimated2/component/View.ts +6 -0
  69. package/src/reanimated2/core.ts +0 -5
  70. package/src/reanimated2/hook/useAnimatedSensor.ts +1 -3
  71. package/src/reanimated2/hook/utils.ts +0 -6
  72. package/src/reanimated2/js-reanimated/global.ts +33 -0
  73. package/src/reanimated2/js-reanimated/index.ts +0 -31
  74. package/src/reanimated2/mock.ts +6 -0
  75. package/android/react-native-reanimated-64-hermes.aar +0 -0
  76. package/android/react-native-reanimated-64-jsc.aar +0 -0
  77. package/lib/reanimated2/component/WrappedComponents.js +0 -9
  78. package/lib/reanimated2/component/index.js +0 -4
  79. package/lib/types/lib/reanimated2/component/WrappedComponents.d.ts +0 -8
  80. package/lib/types/lib/reanimated2/component/index.d.ts +0 -9
  81. package/src/Animated.js +0 -31
  82. package/src/reanimated2/component/WrappedComponents.ts +0 -11
  83. package/src/reanimated2/component/index.ts +0 -9
@@ -71,21 +71,27 @@ void RuntimeDecorator::decorateRuntime(
71
71
  1,
72
72
  setGlobalConsole));
73
73
 
74
+ auto chronoNow = [](jsi::Runtime &rt,
75
+ const jsi::Value &thisValue,
76
+ const jsi::Value *args,
77
+ size_t count) -> jsi::Value {
78
+ double now = std::chrono::system_clock::now().time_since_epoch() /
79
+ std::chrono::milliseconds(1);
80
+ return jsi::Value(now);
81
+ };
82
+
74
83
  rt.global().setProperty(
75
84
  rt,
76
85
  "_chronoNow",
77
86
  jsi::Function::createFromHostFunction(
78
- rt,
79
- jsi::PropNameID::forAscii(rt, "_chronoNow"),
80
- 0,
81
- [](jsi::Runtime &rt,
82
- const jsi::Value &thisValue,
83
- const jsi::Value *args,
84
- size_t count) -> jsi::Value {
85
- double now = std::chrono::system_clock::now().time_since_epoch() /
86
- std::chrono::milliseconds(1);
87
- return jsi::Value(now);
88
- }));
87
+ rt, jsi::PropNameID::forAscii(rt, "_chronoNow"), 0, chronoNow));
88
+ jsi::Object performance(rt);
89
+ performance.setProperty(
90
+ rt,
91
+ "now",
92
+ jsi::Function::createFromHostFunction(
93
+ rt, jsi::PropNameID::forAscii(rt, "now"), 0, chronoNow));
94
+ rt.global().setProperty(rt, "performance", performance);
89
95
  }
90
96
 
91
97
  void RuntimeDecorator::decorateUIRuntime(
@@ -1,2 +1,2 @@
1
- #Mon Apr 11 15:37:15 UTC 2022
1
+ #Fri Jul 01 09:56:56 UTC 2022
2
2
  gradle.version=7.2
@@ -1,3 +1,4 @@
1
+ project(Reanimated)
1
2
  cmake_minimum_required(VERSION 3.5.1)
2
3
 
3
4
  set (CMAKE_VERBOSE_MAKEFILE ON)
@@ -13,6 +14,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
13
14
  set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "")
14
15
 
15
16
  set (PACKAGE_NAME "reanimated")
17
+ set (BUILD_DIR ${CMAKE_SOURCE_DIR}/build)
16
18
  set (SRC_DIR ${CMAKE_SOURCE_DIR}/src)
17
19
 
18
20
  if(${CLIENT_SIDE_BUILD})
@@ -119,12 +121,23 @@ find_library(
119
121
  PATHS ${LIBRN_DIR}
120
122
  NO_CMAKE_FIND_ROOT_PATH
121
123
  )
122
- find_library(
123
- FOLLY_JSON_LIB
124
- folly_json
125
- PATHS ${LIBRN_DIR}
126
- NO_CMAKE_FIND_ROOT_PATH
127
- )
124
+
125
+ if(${REACT_NATIVE_TARGET_VERSION} LESS 69)
126
+ find_library(
127
+ FOLLY_LIB
128
+ folly_json
129
+ PATHS ${LIBRN_DIR}
130
+ NO_CMAKE_FIND_ROOT_PATH
131
+ )
132
+ else()
133
+ find_library(
134
+ FOLLY_LIB
135
+ folly_runtime
136
+ PATHS ${LIBRN_DIR}
137
+ NO_CMAKE_FIND_ROOT_PATH
138
+ )
139
+ endif()
140
+
128
141
  find_library(
129
142
  REACT_NATIVE_JNI_LIB
130
143
  reactnativejni
@@ -169,7 +182,7 @@ if(${FOR_HERMES})
169
182
  ${HERMES_LIB}
170
183
  ${GLOG_LIB}
171
184
  ${FBJNI_LIB}
172
- ${FOLLY_JSON_LIB}
185
+ ${FOLLY_LIB}
173
186
  ${REACT_NATIVE_JNI_LIB}
174
187
  android
175
188
  )
@@ -181,7 +194,7 @@ else()
181
194
  ${JSEXECUTOR_LIB}
182
195
  ${GLOG_LIB}
183
196
  ${FBJNI_LIB}
184
- ${FOLLY_JSON_LIB}
197
+ ${FOLLY_LIB}
185
198
  ${REACT_NATIVE_JNI_LIB}
186
199
  android
187
200
  )
@@ -149,10 +149,10 @@ def detectAAR(minor, engine) {
149
149
  println "\n\n\n"
150
150
  println "****************************************************************************************"
151
151
  println "\n\n\n"
152
- println "WARNING reanimated - no version-specific reanimated AAR for react-native version $rnMinorVersion found."
152
+ println "WARNING reanimated - no version-specific reanimated AAR for react-native version $minor found."
153
153
  println "Falling back to AAR for react-native version $rnMinorVersionCopy."
154
154
  println "The react-native JSI interface is not ABI-safe yet, this may result in crashes."
155
- println "Please post a pull request to implement support for react-native version $rnMinorVersion to the reanimated repo."
155
+ println "Please post a pull request to implement support for react-native version $minor to the reanimated repo."
156
156
  println "Thanks!"
157
157
  println "\n\n\n"
158
158
  println "****************************************************************************************"
@@ -351,8 +351,8 @@ buildscript {
351
351
  }
352
352
  }
353
353
  dependencies {
354
- classpath "com.android.tools.build:gradle:4.2.2"
355
- classpath "de.undercouch:gradle-download-task:4.1.2"
354
+ classpath "com.android.tools.build:gradle:7.1.1"
355
+ classpath "de.undercouch:gradle-download-task:5.0.1"
356
356
  classpath "com.diffplug.spotless:spotless-plugin-gradle:5.15.0"
357
357
  }
358
358
  }
@@ -381,8 +381,7 @@ android {
381
381
  "-DBOOST_VERSION=${BOOST_VERSION}",
382
382
  "-DBUILD_DIR=${buildDir}",
383
383
  "-DFOR_HERMES=${FOR_HERMES}",
384
- "-DCLIENT_SIDE_BUILD=${CLIENT_SIDE_BUILD}",
385
- "--clean-first"
384
+ "-DCLIENT_SIDE_BUILD=${CLIENT_SIDE_BUILD}"
386
385
  abiFilters (*reactNativeArchitectures())
387
386
  _stackProtectorFlag ? (cppFlags("-fstack-protector-all")) : null
388
387
  }
@@ -407,6 +406,7 @@ android {
407
406
  "**/libfbjni.so",
408
407
  "**/libjsi.so",
409
408
  "**/libfolly_json.so",
409
+ "**/libfolly_runtime.so",
410
410
  "**/libglog.so",
411
411
  "**/libhermes.so",
412
412
  "**/libreactnativejni.so",
@@ -459,7 +459,12 @@ task createNativeDepsDirectories(dependsOn: applyJavaPatches) {
459
459
  }
460
460
 
461
461
  task downloadBoost(dependsOn: createNativeDepsDirectories, type: Download) {
462
- src("https://github.com/react-native-community/boost-for-react-native/releases/download/v${BOOST_VERSION.replace("_", ".")}-0/boost_${BOOST_VERSION}.tar.gz")
462
+ def transformedVersion = BOOST_VERSION.replace("_", ".")
463
+ def srcUrl = "https://boostorg.jfrog.io/artifactory/main/release/${transformedVersion}/source/boost_${BOOST_VERSION}.tar.gz"
464
+ if (rnMinorVersion < 69) {
465
+ srcUrl = "https://github.com/react-native-community/boost-for-react-native/releases/download/v${transformedVersion}-0/boost_${BOOST_VERSION}.tar.gz"
466
+ }
467
+ src(srcUrl)
463
468
  onlyIfNewer(true)
464
469
  overwrite(false)
465
470
  dest(new File(downloadsDir, "boost_${BOOST_VERSION}.tar.gz"))
@@ -672,7 +677,17 @@ dependencies {
672
677
  extractHeaders("com.facebook.fbjni:fbjni:" + FBJNI_VERSION + ":headers")
673
678
  extractSO("com.facebook.fbjni:fbjni:" + FBJNI_VERSION)
674
679
 
675
- def rnAAR = fileTree("$reactNative/android").matching({ it.include "**/**/*.aar" }).singleFile
680
+ def buildType = "debug"
681
+ tasks.all({ task ->
682
+ if (task.name == "buildCMakeRelease") {
683
+ buildType = "release"
684
+ }
685
+ })
686
+ def rnAarMatcher = "**/react-native/**/*${buildType}.aar"
687
+ if (rnMinorVersion < 69) {
688
+ rnAarMatcher = "**/**/*.aar"
689
+ }
690
+ def rnAAR = fileTree("$reactNative/android").matching({ it.include rnAarMatcher }).singleFile
676
691
  def jscAAR = fileTree("$reactNative/../jsc-android/dist/org/webkit/android-jsc").matching({ it.include "**/**/*.aar" }).singleFile
677
692
  extractSO(files(rnAAR, jscAAR))
678
693
  }
File without changes
@@ -37,6 +37,13 @@ NativeProxy::NativeProxy(
37
37
  scheduler_(scheduler),
38
38
  layoutAnimations(std::move(_layoutAnimations)) {}
39
39
 
40
+ NativeProxy::~NativeProxy() {
41
+ runtime_->global().setProperty(
42
+ *runtime_,
43
+ jsi::PropNameID::forAscii(*runtime_, "__reanimatedModuleProxy"),
44
+ jsi::Value::undefined());
45
+ }
46
+
40
47
  jni::local_ref<NativeProxy::jhybriddata> NativeProxy::initHybrid(
41
48
  jni::alias_ref<jhybridobject> jThis,
42
49
  jlong jsContext,
@@ -138,11 +145,22 @@ void NativeProxy::installJSIBindings() {
138
145
  std::shared_ptr<jsi::Runtime> animatedRuntime =
139
146
  facebook::jsc::makeJSCRuntime();
140
147
  #endif
148
+ auto workletRuntimeValue = runtime_->global()
149
+ .getProperty(*runtime_, "ArrayBuffer")
150
+ .asObject(*runtime_)
151
+ .asFunction(*runtime_)
152
+ .callAsConstructor(*runtime_, {static_cast<double>(sizeof(void*))});
153
+ uintptr_t* workletRuntimeData = reinterpret_cast<uintptr_t*>(
154
+ workletRuntimeValue
155
+ .getObject(*runtime_)
156
+ .getArrayBuffer(*runtime_)
157
+ .data(*runtime_));
158
+ workletRuntimeData[0] = reinterpret_cast<uintptr_t>(animatedRuntime.get());
159
+
141
160
  runtime_->global().setProperty(
142
161
  *runtime_,
143
162
  "_WORKLET_RUNTIME",
144
- static_cast<double>(
145
- reinterpret_cast<std::uintptr_t>(animatedRuntime.get())));
163
+ workletRuntimeValue);
146
164
 
147
165
  std::shared_ptr<ErrorHandler> errorHandler =
148
166
  std::make_shared<AndroidErrorHandler>(scheduler_);
@@ -192,18 +210,21 @@ void NativeProxy::installJSIBindings() {
192
210
  platformDepMethodsHolder);
193
211
 
194
212
  _nativeReanimatedModule = module;
195
-
196
- this->registerEventHandler([module, getCurrentTime](
197
- std::string eventName,
198
- std::string eventAsString) {
199
- jsi::Object global = module->runtime->global();
200
- jsi::String eventTimestampName =
201
- jsi::String::createFromAscii(*module->runtime, "_eventTimestamp");
202
- global.setProperty(*module->runtime, eventTimestampName, getCurrentTime());
203
- module->onEvent(eventName, eventAsString);
204
- global.setProperty(
205
- *module->runtime, eventTimestampName, jsi::Value::undefined());
206
- });
213
+ std::weak_ptr<NativeReanimatedModule> weakModule = module;
214
+ this->registerEventHandler(
215
+ [weakModule, getCurrentTime](
216
+ std::string eventName, std::string eventAsString) {
217
+ if (auto module = weakModule.lock()) {
218
+ jsi::Object global = module->runtime->global();
219
+ jsi::String eventTimestampName =
220
+ jsi::String::createFromAscii(*module->runtime, "_eventTimestamp");
221
+ global.setProperty(
222
+ *module->runtime, eventTimestampName, getCurrentTime());
223
+ module->onEvent(eventName, eventAsString);
224
+ global.setProperty(
225
+ *module->runtime, eventTimestampName, jsi::Value::undefined());
226
+ }
227
+ });
207
228
 
208
229
  runtime_->global().setProperty(
209
230
  *runtime_,
@@ -131,6 +131,8 @@ class NativeProxy : public jni::HybridClass<NativeProxy> {
131
131
  jni::alias_ref<LayoutAnimations::javaobject> layoutAnimations);
132
132
  static void registerNatives();
133
133
 
134
+ ~NativeProxy();
135
+
134
136
  private:
135
137
  friend HybridBase;
136
138
  jni::global_ref<NativeProxy::javaobject> javaPart_;
@@ -3,6 +3,7 @@ package com.swmansion.reanimated.sensor;
3
3
  import android.hardware.Sensor;
4
4
  import android.hardware.SensorEvent;
5
5
  import android.hardware.SensorEventListener;
6
+ import android.hardware.SensorManager;
6
7
  import com.swmansion.reanimated.NativeProxy;
7
8
 
8
9
  public class ReanimatedSensorListener implements SensorEventListener {
@@ -11,6 +12,10 @@ public class ReanimatedSensorListener implements SensorEventListener {
11
12
  private double lastRead = (double) System.currentTimeMillis();
12
13
  private final double interval;
13
14
 
15
+ private float[] rotation = new float[9];
16
+ private float[] orientation = new float[3];
17
+ private float[] quaternion = new float[4];
18
+
14
19
  ReanimatedSensorListener(NativeProxy.SensorSetter setter, double interval) {
15
20
  this.setter = setter;
16
21
  this.interval = interval;
@@ -22,8 +27,26 @@ public class ReanimatedSensorListener implements SensorEventListener {
22
27
  if (current - lastRead < interval) {
23
28
  return;
24
29
  }
30
+ int sensorType = event.sensor.getType();
25
31
  lastRead = current;
26
- setter.sensorSetter(event.values);
32
+ if (sensorType == Sensor.TYPE_ROTATION_VECTOR) {
33
+ SensorManager.getQuaternionFromVector(quaternion, event.values);
34
+ SensorManager.getRotationMatrixFromVector(rotation, event.values);
35
+ SensorManager.getOrientation(rotation, orientation);
36
+ float[] data =
37
+ new float[] {
38
+ quaternion[1], // qx
39
+ quaternion[2], // qy
40
+ quaternion[3], // qz
41
+ quaternion[0], // qw
42
+ orientation[0], // yaw
43
+ orientation[1], // pitch
44
+ orientation[2] // roll
45
+ };
46
+ setter.sensorSetter(data);
47
+ } else {
48
+ setter.sensorSetter(event.values);
49
+ }
27
50
  }
28
51
 
29
52
  @Override
@@ -1,11 +1,13 @@
1
1
  package com.swmansion.reanimated.sensor;
2
2
 
3
+ import android.hardware.Sensor;
4
+
3
5
  public enum ReanimatedSensorType {
4
- ACCELEROMETER(1),
5
- GYROSCOPE(2),
6
- GRAVITY(3),
7
- MAGNETIC_FIELD(4),
8
- ROTATION_VECTOR(5);
6
+ ACCELEROMETER(Sensor.TYPE_ACCELEROMETER),
7
+ GYROSCOPE(Sensor.TYPE_GYROSCOPE),
8
+ GRAVITY(Sensor.TYPE_GRAVITY),
9
+ MAGNETIC_FIELD(Sensor.TYPE_MAGNETIC_FIELD),
10
+ ROTATION_VECTOR(Sensor.TYPE_ROTATION_VECTOR);
9
11
 
10
12
  private final int type;
11
13
 
@@ -162,8 +162,12 @@ std::shared_ptr<NativeReanimatedModule> createReanimatedModule(
162
162
  scrollTo(viewTag, uiManager, x, y, animated);
163
163
  };
164
164
 
165
- id<RNGestureHandlerStateManager> gestureHandlerStateManager = [bridge moduleForName:@"RNGestureHandlerModule"];
166
- auto setGestureStateFunction = [gestureHandlerStateManager](int handlerTag, int newState) {
165
+ id<RNGestureHandlerStateManager> gestureHandlerStateManager = nil;
166
+ auto setGestureStateFunction = [gestureHandlerStateManager, bridge](int handlerTag, int newState) mutable {
167
+ if (gestureHandlerStateManager == nil) {
168
+ gestureHandlerStateManager = [bridge moduleForName:@"RNGestureHandlerModule"];
169
+ }
170
+
167
171
  setGestureState(gestureHandlerStateManager, handlerTag, newState);
168
172
  };
169
173
 
@@ -45,10 +45,20 @@ JSIExecutor::RuntimeInstaller REAJSIExecutorRuntimeInstaller(
45
45
  auto callInvoker = std::make_shared<react::BridgeJSCallInvoker>(bridge.reactInstance);
46
46
  auto reanimatedModule = reanimated::createReanimatedModule(bridge, callInvoker);
47
47
  #endif
48
+ auto workletRuntimeValue = runtime
49
+ .global()
50
+ .getProperty(runtime, "ArrayBuffer")
51
+ .asObject(runtime)
52
+ .asFunction(runtime)
53
+ .callAsConstructor(runtime, {static_cast<double>(sizeof(void*))});
54
+ uintptr_t* workletRuntimeData = reinterpret_cast<uintptr_t*>(
55
+ workletRuntimeValue.getObject(runtime).getArrayBuffer(runtime).data(runtime));
56
+ workletRuntimeData[0] = reinterpret_cast<uintptr_t>(reanimatedModule->runtime.get());
57
+
48
58
  runtime.global().setProperty(
49
59
  runtime,
50
60
  "_WORKLET_RUNTIME",
51
- static_cast<double>(reinterpret_cast<std::uintptr_t>(reanimatedModule->runtime.get())));
61
+ workletRuntimeValue);
52
62
 
53
63
  runtime.global().setProperty(
54
64
  runtime,
@@ -141,9 +141,9 @@
141
141
  attitude.quaternion.y,
142
142
  attitude.quaternion.z,
143
143
  attitude.quaternion.w,
144
- attitude.pitch,
145
- attitude.roll,
146
144
  attitude.yaw,
145
+ attitude.pitch,
146
+ attitude.roll
147
147
  };
148
148
  self->_setter(data);
149
149
  self->_lastTimestamp = currentTime;
package/lib/Animated.js CHANGED
@@ -1,31 +1,9 @@
1
- import { LogBox } from 'react-native';
2
- import createAnimatedComponent from './createAnimatedComponent';
3
- import {
4
- addWhitelistedNativeProps,
5
- addWhitelistedUIProps,
6
- } from './ConfigHelper';
7
- import * as reanimated1 from './reanimated1';
8
- import ReanimatedComponents from './reanimated2/component';
9
-
10
- const Animated = {
11
- // components
12
- ...ReanimatedComponents,
13
- createAnimatedComponent,
14
- // configuration
15
- addWhitelistedNativeProps,
16
- addWhitelistedUIProps,
17
- // reanimated 1
18
- ...reanimated1,
19
- };
20
-
21
- export * from './reanimated2';
1
+ export { default as createAnimatedComponent } from './createAnimatedComponent';
2
+ export { addWhitelistedNativeProps, addWhitelistedUIProps, } from './ConfigHelper';
3
+ export { default as Text } from './reanimated2/component/Text';
4
+ export { default as View } from './reanimated2/component/View';
5
+ export { default as ScrollView } from './reanimated2/component/ScrollView';
6
+ export { default as Image } from './reanimated2/component/Image';
7
+ export { default as FlatList } from './reanimated2/component/FlatList';
8
+ // @ts-ignore backward compatibility with treeshaking
22
9
  export * from './reanimated1';
23
- export default Animated;
24
-
25
- // I think we can ignore this message as long as Gesture Handler doesn't
26
- // try to load the Reanimated module. I figured it should be here instead of
27
- // RNGH because this prevents the message from being displayed for all
28
- // versions of RNGH.
29
- LogBox.ignoreLogs([
30
- 'RCTBridge required dispatch_sync to load RNGestureHandlerModule. This may lead to deadlocks',
31
- ]);
package/lib/index.js CHANGED
@@ -1,31 +1,6 @@
1
- import { LogBox } from 'react-native';
2
- import createAnimatedComponent from './createAnimatedComponent';
3
- import {
4
- addWhitelistedNativeProps,
5
- addWhitelistedUIProps,
6
- } from './ConfigHelper';
7
- import * as reanimated1 from './reanimated1';
8
- import ReanimatedComponents from './reanimated2/component';
9
-
10
- const Animated = {
11
- // components
12
- ...ReanimatedComponents,
13
- createAnimatedComponent,
14
- // configuration
15
- addWhitelistedNativeProps,
16
- addWhitelistedUIProps,
17
- // reanimated 1
18
- ...reanimated1,
19
- };
20
-
21
- export * from './reanimated2';
1
+ // tree-shaken side effects
2
+ import './reanimated2/js-reanimated/global';
3
+ // @ts-ignore backward compatibility with treeshaking
22
4
  export * from './reanimated1';
23
- export default Animated;
24
-
25
- // I think we can ignore this message as long as Gesture Handler doesn't
26
- // try to load the Reanimated module. I figured it should be here instead of
27
- // RNGH because this prevents the message from being displayed for all
28
- // versions of RNGH.
29
- LogBox.ignoreLogs([
30
- 'RCTBridge required dispatch_sync to load RNGestureHandlerModule. This may lead to deadlocks',
31
- ]);
5
+ export * from './reanimated2';
6
+ export * as default from './Animated';
@@ -1,7 +1,7 @@
1
1
  import { NativeModules } from 'react-native';
2
2
  export class NativeReanimated {
3
3
  constructor(native = true) {
4
- if (global.__reanimatedModuleProxy === undefined) {
4
+ if (global.__reanimatedModuleProxy === undefined && native) {
5
5
  const { ReanimatedModule } = NativeModules;
6
6
  ReanimatedModule === null || ReanimatedModule === void 0 ? void 0 : ReanimatedModule.installTurboModule();
7
7
  }
@@ -43,9 +43,6 @@ export function withSequence(..._animations) {
43
43
  return false;
44
44
  }
45
45
  function onStart(animation, value, now, previousAnimation) {
46
- if (animations.length === 1) {
47
- throw Error('withSequence() animation require more than one animation as argument');
48
- }
49
46
  animation.animationIndex = 0;
50
47
  if (previousAnimation === undefined) {
51
48
  previousAnimation = animations[animations.length - 1];
@@ -11,14 +11,14 @@ var __rest = (this && this.__rest) || function (s, e) {
11
11
  };
12
12
  import React from 'react';
13
13
  import { FlatList } from 'react-native';
14
- import WrappedComponents from './WrappedComponents';
14
+ import ReanimatedView from './View';
15
15
  import createAnimatedComponent from '../../createAnimatedComponent';
16
16
  const AnimatedFlatList = createAnimatedComponent(FlatList);
17
17
  const createCellRenderer = (itemLayoutAnimation) => {
18
18
  const cellRenderer = (props) => {
19
- return (<WrappedComponents.View layout={itemLayoutAnimation} onLayout={props.onLayout}>
19
+ return (<ReanimatedView layout={itemLayoutAnimation} onLayout={props.onLayout}>
20
20
  {props.children}
21
- </WrappedComponents.View>);
21
+ </ReanimatedView>);
22
22
  };
23
23
  return cellRenderer;
24
24
  };
@@ -0,0 +1,4 @@
1
+ import { Image } from 'react-native';
2
+ import createAnimatedComponent from '../../createAnimatedComponent';
3
+ const AnimatedImage = createAnimatedComponent(Image);
4
+ export default AnimatedImage;
@@ -0,0 +1,4 @@
1
+ import { ScrollView } from 'react-native';
2
+ import createAnimatedComponent from '../../createAnimatedComponent';
3
+ const AnimatedScrollView = createAnimatedComponent(ScrollView);
4
+ export default AnimatedScrollView;
@@ -0,0 +1,4 @@
1
+ import { Text } from 'react-native';
2
+ import createAnimatedComponent from '../../createAnimatedComponent';
3
+ const AnimatedText = createAnimatedComponent(Text);
4
+ export default AnimatedText;
@@ -0,0 +1,4 @@
1
+ import { View } from 'react-native';
2
+ import createAnimatedComponent from '../../createAnimatedComponent';
3
+ const AnimatedView = createAnimatedComponent(View);
4
+ export default AnimatedView;
@@ -238,11 +238,6 @@ if (!isWeb() && isConfigured()) {
238
238
  info: runOnJS(capturableConsole.info),
239
239
  };
240
240
  _setGlobalConsole(console);
241
- if (global.performance == null) {
242
- global.performance = {
243
- now: global._chronoNow,
244
- }; // due to conflict with lib.dom.d.ts -> Performance
245
- }
246
241
  })();
247
242
  }
248
243
  let featuresConfig = {
@@ -12,11 +12,6 @@ export function useEvent(handler, eventNames = [], rebuild = false) {
12
12
  else if (rebuild) {
13
13
  initRef.current.updateWorklet(handler);
14
14
  }
15
- useEffect(() => {
16
- return () => {
17
- initRef.current = null;
18
- };
19
- }, []);
20
15
  return initRef;
21
16
  }
22
17
  export function useHandler(handlers, dependencies) {
@@ -0,0 +1,25 @@
1
+ // In order to keep bundle size down, we treat this file as a polyfill for Web.
2
+ import { shouldBeUseWeb } from '../PlatformChecker';
3
+ if (shouldBeUseWeb()) {
4
+ global._frameTimestamp = null;
5
+ global._setGlobalConsole = (_val) => {
6
+ // noop
7
+ };
8
+ global._measure = () => {
9
+ console.warn("[Reanimated] You can't use `measure` with Chrome Debugger or with web version");
10
+ return {
11
+ x: 0,
12
+ y: 0,
13
+ width: 0,
14
+ height: 0,
15
+ pageX: 0,
16
+ pageY: 0,
17
+ };
18
+ };
19
+ global._scrollTo = () => {
20
+ console.warn("[Reanimated] You can't use `scrollTo` with Chrome Debugger or with web version");
21
+ };
22
+ global._setGestureState = () => {
23
+ console.warn("[Reanimated] You can't use `setGestureState` with Chrome Debugger or with web version");
24
+ };
25
+ }