react-native-reanimated 2.13.0 → 2.14.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.
- package/Common/cpp/Tools/ReanimatedVersion.cpp +17 -0
- package/Common/cpp/Tools/ReanimatedVersion.h +11 -0
- package/RNReanimated.podspec +2 -1
- package/android/.gradle/7.5.1/checksums/checksums.lock +0 -0
- package/android/.gradle/7.5.1/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/7.5.1/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/7.5.1/executionHistory/executionHistory.bin +0 -0
- package/android/.gradle/7.5.1/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/7.5.1/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/7.5.1/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.5.1/fileHashes/resourceHashesCache.bin +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +1 -1
- package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
- package/android/.gradle/file-system.probe +0 -0
- package/android/CMakeLists.txt +191 -188
- package/android/build.gradle +386 -316
- package/android/react-native-reanimated-67-hermes.aar +0 -0
- package/android/react-native-reanimated-67-jsc.aar +0 -0
- package/android/react-native-reanimated-68-hermes.aar +0 -0
- package/android/react-native-reanimated-68-jsc.aar +0 -0
- package/android/react-native-reanimated-69-hermes.aar +0 -0
- package/android/react-native-reanimated-69-jsc.aar +0 -0
- package/android/react-native-reanimated-70-hermes.aar +0 -0
- package/android/react-native-reanimated-70-jsc.aar +0 -0
- package/android/react-native-reanimated-71-hermes.aar +0 -0
- package/android/react-native-reanimated-71-jsc.aar +0 -0
- package/android/src/main/cpp/NativeProxy.cpp +8 -0
- package/android/src/main/java/com/swmansion/reanimated/ReanimatedPackage.java +5 -4
- package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorContainer.java +1 -1
- package/android/src/reactNativeVersionPatch/ReanimatedUIManager/70/com/swmansion/reanimated/ReanimatedUIManagerFactory.java +16 -0
- package/android/src/{main/java → reactNativeVersionPatch/ReanimatedUIManager/70}/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +0 -0
- package/android/src/reactNativeVersionPatch/ReanimatedUIManager/latest/com/swmansion/reanimated/ReanimatedUIManagerFactory.java +63 -0
- package/android/src/reactNativeVersionPatch/ReanimatedUIManager/latest/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +271 -0
- package/android/src/reactNativeVersionPatch/nativeHierarchyManager/latest/com/swmansion/reanimated/layoutReanimation/ReanimatedNativeHierarchyManager.java +3 -30
- package/ios/REAModule.mm +2 -0
- package/ios/native/REAInitializer.mm +4 -0
- package/lib/createAnimatedComponent.js +5 -0
- package/lib/reanimated2/Colors.js +27 -11
- package/lib/reanimated2/NativeReanimated/NativeReanimated.js +4 -0
- package/lib/reanimated2/animation/util.js +15 -15
- package/lib/reanimated2/globals.d.ts +2 -0
- package/lib/reanimated2/interpolateColor.js +79 -20
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +16 -18
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +8 -10
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Roll.js +15 -10
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Slide.js +8 -10
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +24 -18
- package/lib/reanimated2/platform-specific/checkVersion.js +24 -0
- package/lib/reanimated2/platform-specific/checkVersion.web.js +6 -0
- package/lib/types/{Animated.d.ts → lib/Animated.d.ts} +0 -0
- package/lib/types/{ConfigHelper.d.ts → lib/ConfigHelper.d.ts} +0 -0
- package/lib/types/{ReanimatedEventEmitter.d.ts → lib/ReanimatedEventEmitter.d.ts} +0 -0
- package/lib/types/{ReanimatedModule.d.ts → lib/ReanimatedModule.d.ts} +0 -0
- package/lib/types/{ReanimatedModule.macos.d.ts → lib/ReanimatedModule.macos.d.ts} +0 -0
- package/lib/types/{ReanimatedModule.native.d.ts → lib/ReanimatedModule.native.d.ts} +0 -0
- package/lib/types/{ReanimatedModule.windows.d.ts → lib/ReanimatedModule.windows.d.ts} +0 -0
- package/lib/types/{ReanimatedModuleCompat.d.ts → lib/ReanimatedModuleCompat.d.ts} +0 -0
- package/lib/types/{createAnimatedComponent.d.ts → lib/createAnimatedComponent.d.ts} +0 -0
- package/lib/types/{index.d.ts → lib/index.d.ts} +0 -0
- package/lib/types/{index.web.d.ts → lib/index.web.d.ts} +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/Bezier.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/Colors.d.ts +5 -3
- package/lib/types/{reanimated2 → lib/reanimated2}/Easing.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/NativeMethods.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/NativeReanimated/NativeReanimated.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/NativeReanimated/index.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/PlatformChecker.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/PropAdapters.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/UpdateProps.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/ViewDescriptorsSet.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/WorkletEventHandler.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/__mocks__/MutableValue.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/__mocks__/NativeReanimated.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/animation/commonTypes.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/animation/decay.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/animation/delay.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/animation/index.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/animation/repeat.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/animation/sequence.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/animation/spring.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/animation/styleAnimation.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/animation/timing.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/animation/util.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/commonTypes.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/component/FlatList.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/component/Image.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/component/ScrollView.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/component/Text.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/component/View.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/core.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/frameCallback/FrameCallbackRegistryJS.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/frameCallback/FrameCallbackRegistryUI.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/hook/Hooks.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/hook/commonTypes.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/hook/index.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/hook/useAnimatedGestureHandler.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/hook/useAnimatedKeyboard.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/hook/useAnimatedReaction.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/hook/useAnimatedRef.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/hook/useAnimatedScrollHandler.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/hook/useAnimatedSensor.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/hook/useAnimatedStyle.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/hook/useDerivedValue.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/hook/useFrameCallback.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/hook/useScrollViewOffset.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/hook/useSharedValue.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/hook/utils.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/index.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/interpolateColor.d.ts +8 -2
- package/lib/types/{reanimated2 → lib/reanimated2}/interpolation.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/jestUtils.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/js-reanimated/JSReanimated.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/js-reanimated/Mapper.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/js-reanimated/MapperRegistry.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/js-reanimated/MutableValue.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/js-reanimated/commonTypes.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/js-reanimated/global.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/js-reanimated/index.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/LayoutAnimationRepository.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/animationBuilder/BaseAnimationBuilder.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/animationBuilder/ComplexAnimationBuilder.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/animationBuilder/Keyframe.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/animationBuilder/commonTypes.d.ts +4 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/animationBuilder/index.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultAnimations/Bounce.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultAnimations/Default.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultAnimations/Fade.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultAnimations/Flip.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultAnimations/Lightspeed.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultAnimations/Pinwheel.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultAnimations/Roll.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultAnimations/Rotate.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultAnimations/Slide.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultAnimations/Stretch.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultAnimations/Zoom.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultAnimations/index.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultTransitions/CurvedTransition.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultTransitions/EntryExitTransition.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultTransitions/FadingTransition.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultTransitions/JumpingTransition.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultTransitions/LinearTransition.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultTransitions/SequencedTransition.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultTransitions/index.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/index.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/mock.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/platform-specific/RNRenderer.d.ts +0 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/platform-specific/RNRenderer.web.d.ts +0 -0
- package/lib/types/lib/reanimated2/platform-specific/checkVersion.d.ts +4 -0
- package/lib/types/lib/reanimated2/platform-specific/checkVersion.web.d.ts +5 -0
- package/lib/types/{reanimated2 → lib/reanimated2}/utils.d.ts +0 -0
- package/lib/types/{setAndForwardRef.d.ts → lib/setAndForwardRef.d.ts} +0 -0
- package/package.json +6 -6
- package/plugin.js +7 -3
- package/react-native-reanimated.d.ts +11 -2
- package/scripts/reanimated_utils.rb +7 -3
- package/src/createAnimatedComponent.tsx +7 -0
- package/src/reanimated2/Colors.ts +38 -11
- package/src/reanimated2/NativeReanimated/NativeReanimated.ts +4 -0
- package/src/reanimated2/animation/util.ts +26 -15
- package/src/reanimated2/globals.d.ts +2 -0
- package/src/reanimated2/interpolateColor.ts +105 -21
- package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +4 -0
- package/src/reanimated2/layoutReanimation/defaultAnimations/Bounce.ts +16 -19
- package/src/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.ts +14 -11
- package/src/reanimated2/layoutReanimation/defaultAnimations/Roll.ts +21 -11
- package/src/reanimated2/layoutReanimation/defaultAnimations/Slide.ts +32 -11
- package/src/reanimated2/layoutReanimation/defaultAnimations/Zoom.ts +36 -19
- package/src/reanimated2/platform-specific/checkVersion.ts +28 -0
- package/src/reanimated2/platform-specific/checkVersion.web.ts +6 -0
- package/android/react-native-reanimated-66-hermes.aar +0 -0
- package/android/react-native-reanimated-66-jsc.aar +0 -0
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -12,7 +12,11 @@
|
|
|
12
12
|
#elif JS_RUNTIME_V8
|
|
13
13
|
#include <v8runtime/V8RuntimeFactory.h>
|
|
14
14
|
#else
|
|
15
|
+
#if REACT_NATIVE_MINOR_VERSION >= 71
|
|
16
|
+
#include <jsc/JSCRuntime.h>
|
|
17
|
+
#else
|
|
15
18
|
#include <jsi/JSCRuntime.h>
|
|
19
|
+
#endif // REACT_NATIVE_MINOR_VERSION
|
|
16
20
|
#endif
|
|
17
21
|
|
|
18
22
|
#include <android/log.h>
|
|
@@ -21,6 +25,7 @@
|
|
|
21
25
|
#include "LayoutAnimationsProxy.h"
|
|
22
26
|
#include "NativeProxy.h"
|
|
23
27
|
#include "PlatformDepMethodsHolder.h"
|
|
28
|
+
#include "ReanimatedVersion.h"
|
|
24
29
|
|
|
25
30
|
namespace reanimated {
|
|
26
31
|
|
|
@@ -174,6 +179,9 @@ void NativeProxy::installJSIBindings() {
|
|
|
174
179
|
runtime_->global().setProperty(
|
|
175
180
|
*runtime_, "_WORKLET_RUNTIME", workletRuntimeValue);
|
|
176
181
|
|
|
182
|
+
auto version = getReanimatedVersionString(*runtime_);
|
|
183
|
+
runtime_->global().setProperty(*runtime_, "_REANIMATED_VERSION_CPP", version);
|
|
184
|
+
|
|
177
185
|
std::shared_ptr<ErrorHandler> errorHandler =
|
|
178
186
|
std::make_shared<AndroidErrorHandler>(scheduler_);
|
|
179
187
|
|
|
@@ -16,8 +16,10 @@ import com.facebook.react.module.model.ReactModuleInfoProvider;
|
|
|
16
16
|
import com.facebook.react.turbomodule.core.interfaces.TurboModule;
|
|
17
17
|
import com.facebook.react.uimanager.ReanimatedUIManager;
|
|
18
18
|
import com.facebook.react.uimanager.UIManagerModule;
|
|
19
|
+
import com.facebook.react.uimanager.ViewManager;
|
|
19
20
|
import com.facebook.systrace.Systrace;
|
|
20
21
|
import java.util.HashMap;
|
|
22
|
+
import java.util.List;
|
|
21
23
|
import java.util.Map;
|
|
22
24
|
|
|
23
25
|
public class ReanimatedPackage extends TurboReactPackage implements ReactPackage {
|
|
@@ -68,12 +70,11 @@ public class ReanimatedPackage extends TurboReactPackage implements ReactPackage
|
|
|
68
70
|
ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_START);
|
|
69
71
|
Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "createUIManagerModule");
|
|
70
72
|
final ReactInstanceManager reactInstanceManager = getReactInstanceManager(reactContext);
|
|
73
|
+
List<ViewManager> viewManagers = reactInstanceManager.getOrCreateViewManagers(reactContext);
|
|
71
74
|
int minTimeLeftInFrameForNonBatchedOperationMs = -1;
|
|
72
75
|
try {
|
|
73
|
-
return
|
|
74
|
-
reactContext,
|
|
75
|
-
reactInstanceManager.getOrCreateViewManagers(reactContext),
|
|
76
|
-
minTimeLeftInFrameForNonBatchedOperationMs);
|
|
76
|
+
return ReanimatedUIManagerFactory.create(
|
|
77
|
+
reactContext, viewManagers, minTimeLeftInFrameForNonBatchedOperationMs);
|
|
77
78
|
} finally {
|
|
78
79
|
Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
|
|
79
80
|
ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_END);
|
package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorContainer.java
CHANGED
|
@@ -23,7 +23,7 @@ public class ReanimatedSensorContainer {
|
|
|
23
23
|
if (sensor.initialize()) {
|
|
24
24
|
sensorId = nextSensorId;
|
|
25
25
|
nextSensorId++;
|
|
26
|
-
sensors.put(sensorId,
|
|
26
|
+
sensors.put(sensorId, sensor);
|
|
27
27
|
}
|
|
28
28
|
return sensorId;
|
|
29
29
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
package com.swmansion.reanimated;
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
4
|
+
import com.facebook.react.uimanager.ReanimatedUIManager;
|
|
5
|
+
import com.facebook.react.uimanager.UIManagerModule;
|
|
6
|
+
import com.facebook.react.uimanager.ViewManager;
|
|
7
|
+
|
|
8
|
+
import java.util.List;
|
|
9
|
+
|
|
10
|
+
public class ReanimatedUIManagerFactory {
|
|
11
|
+
|
|
12
|
+
static UIManagerModule create(ReactApplicationContext reactContext, List<ViewManager> viewManagers, int minTimeLeftInFrameForNonBatchedOperationMs) {
|
|
13
|
+
return new ReanimatedUIManager(reactContext, viewManagers, minTimeLeftInFrameForNonBatchedOperationMs);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
package com.swmansion.reanimated;
|
|
2
|
+
|
|
3
|
+
import android.os.Build;
|
|
4
|
+
import android.util.Log;
|
|
5
|
+
|
|
6
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
7
|
+
import com.facebook.react.uimanager.ReanimatedUIImplementation;
|
|
8
|
+
import com.facebook.react.uimanager.ReanimatedUIManager;
|
|
9
|
+
import com.facebook.react.uimanager.UIImplementation;
|
|
10
|
+
import com.facebook.react.uimanager.UIManagerModule;
|
|
11
|
+
import com.facebook.react.uimanager.ViewManager;
|
|
12
|
+
import com.facebook.react.uimanager.ViewManagerRegistry;
|
|
13
|
+
|
|
14
|
+
import java.lang.reflect.Field;
|
|
15
|
+
import java.lang.reflect.Modifier;
|
|
16
|
+
import java.util.List;
|
|
17
|
+
|
|
18
|
+
public class ReanimatedUIManagerFactory {
|
|
19
|
+
|
|
20
|
+
static UIManagerModule create(ReactApplicationContext reactContext, List<ViewManager> viewManagers, int minTimeLeftInFrameForNonBatchedOperationMs) {
|
|
21
|
+
ViewManagerRegistry viewManagerRegistry = new ViewManagerRegistry(viewManagers);
|
|
22
|
+
|
|
23
|
+
UIManagerModule uiManagerModule =
|
|
24
|
+
new ReanimatedUIManager(
|
|
25
|
+
reactContext, viewManagers, minTimeLeftInFrameForNonBatchedOperationMs);
|
|
26
|
+
|
|
27
|
+
UIImplementation uiImplementation =
|
|
28
|
+
new ReanimatedUIImplementation(
|
|
29
|
+
reactContext,
|
|
30
|
+
viewManagerRegistry,
|
|
31
|
+
uiManagerModule.getEventDispatcher(),
|
|
32
|
+
minTimeLeftInFrameForNonBatchedOperationMs);
|
|
33
|
+
|
|
34
|
+
Class clazz = uiManagerModule.getClass().getSuperclass();
|
|
35
|
+
if (clazz == null) {
|
|
36
|
+
Log.e("reanimated", "unable to resolve super class of ReanimatedUIManager");
|
|
37
|
+
return uiManagerModule;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
try {
|
|
41
|
+
Field uiImplementationField = clazz.getDeclaredField("mUIImplementation");
|
|
42
|
+
uiImplementationField.setAccessible(true);
|
|
43
|
+
|
|
44
|
+
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
45
|
+
try {
|
|
46
|
+
// accessFlags is supported only by API >=23
|
|
47
|
+
Field modifiersField = Field.class.getDeclaredField("accessFlags");
|
|
48
|
+
modifiersField.setAccessible(true);
|
|
49
|
+
modifiersField.setInt(
|
|
50
|
+
uiImplementationField, uiImplementationField.getModifiers() & ~Modifier.FINAL);
|
|
51
|
+
} catch (NoSuchFieldException | IllegalAccessException e) {
|
|
52
|
+
e.printStackTrace();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
uiImplementationField.set(uiManagerModule, uiImplementation);
|
|
56
|
+
} catch (NoSuchFieldException | IllegalAccessException e) {
|
|
57
|
+
e.printStackTrace();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return uiManagerModule;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
}
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
package com.facebook.react.uimanager;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.Nullable;
|
|
4
|
+
import com.facebook.react.bridge.Callback;
|
|
5
|
+
import com.facebook.react.bridge.Dynamic;
|
|
6
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
7
|
+
import com.facebook.react.bridge.ReactMethod;
|
|
8
|
+
import com.facebook.react.bridge.ReadableArray;
|
|
9
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
10
|
+
import com.facebook.react.bridge.WritableMap;
|
|
11
|
+
import com.facebook.react.module.annotations.ReactModule;
|
|
12
|
+
import java.util.List;
|
|
13
|
+
|
|
14
|
+
@ReactModule(name = UIManagerModule.NAME)
|
|
15
|
+
public class ReanimatedUIManager extends UIManagerModule {
|
|
16
|
+
|
|
17
|
+
public ReanimatedUIManager(
|
|
18
|
+
ReactApplicationContext reactContext,
|
|
19
|
+
List<ViewManager> viewManagersList,
|
|
20
|
+
int minTimeLeftInFrameForNonBatchedOperationMs) {
|
|
21
|
+
super(reactContext, viewManagersList, minTimeLeftInFrameForNonBatchedOperationMs);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public void onBatchComplete() {
|
|
25
|
+
super.onBatchComplete();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@Override
|
|
29
|
+
public boolean canOverrideExistingModule() {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
34
|
+
public @Nullable WritableMap getConstantsForViewManager(@Nullable String viewManagerName) {
|
|
35
|
+
return super.getConstantsForViewManager(viewManagerName);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
39
|
+
public WritableMap getDefaultEventTypes() {
|
|
40
|
+
return super.getDefaultEventTypes();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Unregisters a new root view. */
|
|
44
|
+
@ReactMethod
|
|
45
|
+
public void removeRootView(int rootViewTag) {
|
|
46
|
+
super.removeRootView(rootViewTag);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@ReactMethod
|
|
50
|
+
public void createView(int tag, String className, int rootViewTag, ReadableMap props) {
|
|
51
|
+
super.createView(tag, className, rootViewTag, props);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@ReactMethod
|
|
55
|
+
public void updateView(final int tag, final String className, final ReadableMap props) {
|
|
56
|
+
super.updateView(tag, className, props);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Interface for adding/removing/moving views within a parent view from JS.
|
|
61
|
+
*
|
|
62
|
+
* @param viewTag the view tag of the parent view
|
|
63
|
+
* @param moveFrom a list of indices in the parent view to move views from
|
|
64
|
+
* @param moveTo parallel to moveFrom, a list of indices in the parent view to move views to
|
|
65
|
+
* @param addChildTags a list of tags of views to add to the parent
|
|
66
|
+
* @param addAtIndices parallel to addChildTags, a list of indices to insert those children at
|
|
67
|
+
* @param removeFrom a list of indices of views to permanently remove. The memory for the
|
|
68
|
+
* corresponding views and data structures should be reclaimed.
|
|
69
|
+
*/
|
|
70
|
+
@ReactMethod
|
|
71
|
+
public void manageChildren(
|
|
72
|
+
int viewTag,
|
|
73
|
+
@Nullable ReadableArray moveFrom,
|
|
74
|
+
@Nullable ReadableArray moveTo,
|
|
75
|
+
@Nullable ReadableArray addChildTags,
|
|
76
|
+
@Nullable ReadableArray addAtIndices,
|
|
77
|
+
@Nullable ReadableArray removeFrom) {
|
|
78
|
+
super.manageChildren(viewTag, moveFrom, moveTo, addChildTags, addAtIndices, removeFrom);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Interface for fast tracking the initial adding of views. Children view tags are assumed to be
|
|
83
|
+
* in order
|
|
84
|
+
*
|
|
85
|
+
* @param viewTag the view tag of the parent view
|
|
86
|
+
* @param childrenTags An array of tags to add to the parent in order
|
|
87
|
+
*/
|
|
88
|
+
@ReactMethod
|
|
89
|
+
public void setChildren(int viewTag, ReadableArray childrenTags) {
|
|
90
|
+
super.setChildren(viewTag, childrenTags);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Replaces the View specified by oldTag with the View specified by newTag within oldTag's parent.
|
|
95
|
+
* This resolves to a simple {@link #manageChildren} call, but React doesn't have enough info in
|
|
96
|
+
* JS to formulate it itself.
|
|
97
|
+
*
|
|
98
|
+
* @deprecated This method will not be available in Fabric UIManager class.
|
|
99
|
+
*/
|
|
100
|
+
@ReactMethod
|
|
101
|
+
@Deprecated
|
|
102
|
+
public void replaceExistingNonRootView(int oldTag, int newTag) {
|
|
103
|
+
super.replaceExistingNonRootView(oldTag, newTag);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Method which takes a container tag and then releases all subviews for that container upon
|
|
108
|
+
* receipt.
|
|
109
|
+
*
|
|
110
|
+
* @param containerTag the tag of the container for which the subviews must be removed
|
|
111
|
+
* @deprecated This method will not be available in Fabric UIManager class.
|
|
112
|
+
*/
|
|
113
|
+
@ReactMethod
|
|
114
|
+
@Deprecated
|
|
115
|
+
public void removeSubviewsFromContainerWithID(int containerTag) {
|
|
116
|
+
super.removeSubviewsFromContainerWithID(containerTag);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Determines the location on screen, width, and height of the given view and returns the values
|
|
121
|
+
* via an async callback.
|
|
122
|
+
*/
|
|
123
|
+
@ReactMethod
|
|
124
|
+
public void measure(int reactTag, Callback callback) {
|
|
125
|
+
super.measure(reactTag, callback);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Determines the location on screen, width, and height of the given view relative to the device
|
|
130
|
+
* screen and returns the values via an async callback. This is the absolute position including
|
|
131
|
+
* things like the status bar
|
|
132
|
+
*/
|
|
133
|
+
@ReactMethod
|
|
134
|
+
public void measureInWindow(int reactTag, Callback callback) {
|
|
135
|
+
super.measureInWindow(reactTag, callback);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Measures the view specified by tag relative to the given ancestorTag. This means that the
|
|
140
|
+
* returned x, y are relative to the origin x, y of the ancestor view. Results are stored in the
|
|
141
|
+
* given outputBuffer. We allow ancestor view and measured view to be the same, in which case the
|
|
142
|
+
* position always will be (0, 0) and method will only measure the view dimensions.
|
|
143
|
+
*
|
|
144
|
+
* <p>NB: Unlike {@link #measure}, this will measure relative to the view layout, not the visible
|
|
145
|
+
* window which can cause unexpected results when measuring relative to things like ScrollViews
|
|
146
|
+
* that can have offset content on the screen.
|
|
147
|
+
*/
|
|
148
|
+
@ReactMethod
|
|
149
|
+
public void measureLayout(
|
|
150
|
+
int tag, int ancestorTag, Callback errorCallback, Callback successCallback) {
|
|
151
|
+
super.measureLayout(tag, ancestorTag, errorCallback, successCallback);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Like {@link #measure} and {@link #measureLayout} but measures relative to the immediate parent.
|
|
156
|
+
*
|
|
157
|
+
* <p>NB: Unlike {@link #measure}, this will measure relative to the view layout, not the visible
|
|
158
|
+
* window which can cause unexpected results when measuring relative to things like ScrollViews
|
|
159
|
+
* that can have offset content on the screen.
|
|
160
|
+
*
|
|
161
|
+
* @deprecated this method will not be available in FabricUIManager class.
|
|
162
|
+
*/
|
|
163
|
+
@ReactMethod
|
|
164
|
+
@Deprecated
|
|
165
|
+
public void measureLayoutRelativeToParent(
|
|
166
|
+
int tag, Callback errorCallback, Callback successCallback) {
|
|
167
|
+
super.measureLayoutRelativeToParent(tag, errorCallback, successCallback);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Find the touch target child native view in the supplied root view hierarchy, given a react
|
|
172
|
+
* target location.
|
|
173
|
+
*
|
|
174
|
+
* <p>This method is currently used only by Element Inspector DevTool.
|
|
175
|
+
*
|
|
176
|
+
* @param reactTag the tag of the root view to traverse
|
|
177
|
+
* @param point an array containing both X and Y target location
|
|
178
|
+
* @param callback will be called if with the identified child view react ID, and measurement
|
|
179
|
+
* info. If no view was found, callback will be invoked with no data.
|
|
180
|
+
*/
|
|
181
|
+
@ReactMethod
|
|
182
|
+
public void findSubviewIn(
|
|
183
|
+
final int reactTag, final ReadableArray point, final Callback callback) {
|
|
184
|
+
super.findSubviewIn(reactTag, point, callback);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Check if the first shadow node is the descendant of the second shadow node
|
|
189
|
+
*
|
|
190
|
+
* @deprecated this method will not be available in FabricUIManager class.
|
|
191
|
+
*/
|
|
192
|
+
@ReactMethod
|
|
193
|
+
@Deprecated
|
|
194
|
+
public void viewIsDescendantOf(
|
|
195
|
+
final int reactTag, final int ancestorReactTag, final Callback callback) {
|
|
196
|
+
super.viewIsDescendantOf(reactTag, ancestorReactTag, callback);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
@ReactMethod
|
|
200
|
+
public void setJSResponder(int reactTag, boolean blockNativeResponder) {
|
|
201
|
+
super.setJSResponder(reactTag, blockNativeResponder);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
@ReactMethod
|
|
205
|
+
public void clearJSResponder() {
|
|
206
|
+
super.clearJSResponder();
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
@ReactMethod
|
|
210
|
+
public void dispatchViewManagerCommand(
|
|
211
|
+
int reactTag, Dynamic commandId, @Nullable ReadableArray commandArgs) {
|
|
212
|
+
super.dispatchViewManagerCommand(reactTag, commandId, commandArgs);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Show a PopupMenu.
|
|
217
|
+
*
|
|
218
|
+
* @param reactTag the tag of the anchor view (the PopupMenu is displayed next to this view); this
|
|
219
|
+
* needs to be the tag of a native view (shadow views can not be anchors)
|
|
220
|
+
* @param items the menu items as an array of strings
|
|
221
|
+
* @param error will be called if there is an error displaying the menu
|
|
222
|
+
* @param success will be called with the position of the selected item as the first argument, or
|
|
223
|
+
* no arguments if the menu is dismissed
|
|
224
|
+
*/
|
|
225
|
+
@ReactMethod
|
|
226
|
+
public void showPopupMenu(int reactTag, ReadableArray items, Callback error, Callback success) {
|
|
227
|
+
super.showPopupMenu(reactTag, items, error, success);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
@ReactMethod
|
|
231
|
+
public void dismissPopupMenu() {
|
|
232
|
+
super.dismissPopupMenu();
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* LayoutAnimation API on Android is currently experimental. Therefore, it needs to be enabled
|
|
237
|
+
* explicitly in order to avoid regression in existing application written for iOS using this API.
|
|
238
|
+
*
|
|
239
|
+
* <p>Warning : This method will be removed in future version of React Native, and layout
|
|
240
|
+
* animation will be enabled by default, so always check for its existence before invoking it.
|
|
241
|
+
*
|
|
242
|
+
* <p>TODO(9139831) : remove this method once layout animation is fully stable.
|
|
243
|
+
*
|
|
244
|
+
* @param enabled whether layout animation is enabled or not
|
|
245
|
+
*/
|
|
246
|
+
@ReactMethod
|
|
247
|
+
public void setLayoutAnimationEnabledExperimental(boolean enabled) {
|
|
248
|
+
super.setLayoutAnimationEnabledExperimental(enabled);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Configure an animation to be used for the native layout changes, and native views creation. The
|
|
253
|
+
* animation will only apply during the current batch operations.
|
|
254
|
+
*
|
|
255
|
+
* <p>TODO(7728153) : animating view deletion is currently not supported.
|
|
256
|
+
*
|
|
257
|
+
* @param config the configuration of the animation for view addition/removal/update.
|
|
258
|
+
* @param success will be called when the animation completes, or when the animation get
|
|
259
|
+
* interrupted. In this case, callback parameter will be false.
|
|
260
|
+
* @param error will be called if there was an error processing the animation
|
|
261
|
+
*/
|
|
262
|
+
@ReactMethod
|
|
263
|
+
public void configureNextLayoutAnimation(ReadableMap config, Callback success, Callback error) {
|
|
264
|
+
super.configureNextLayoutAnimation(config, success, error);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
@ReactMethod
|
|
268
|
+
public void sendAccessibilityEvent(int tag, int eventType) {
|
|
269
|
+
super.sendAccessibilityEvent(tag, eventType);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
@@ -87,9 +87,9 @@ class ReaLayoutAnimator extends LayoutAnimationController {
|
|
|
87
87
|
view.layout(x, y, x + width, y + height);
|
|
88
88
|
if (view.getId() != -1) {
|
|
89
89
|
mAnimationsManager.onViewCreate(
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
view,
|
|
91
|
+
(ViewGroup) view.getParent(),
|
|
92
|
+
new Snapshot(view, mWeakNativeViewHierarchyManage.get()));
|
|
93
93
|
}
|
|
94
94
|
} else {
|
|
95
95
|
Snapshot before = new Snapshot(view, mWeakNativeViewHierarchyManage.get());
|
|
@@ -269,33 +269,6 @@ public class ReanimatedNativeHierarchyManager extends NativeViewHierarchyManager
|
|
|
269
269
|
return !initOk || !((ReaLayoutAnimator) mReaLayoutAnimator).isLayoutAnimationEnabled();
|
|
270
270
|
}
|
|
271
271
|
|
|
272
|
-
public synchronized void updateLayout(
|
|
273
|
-
int parentTag, int tag, int x, int y, int width, int height) {
|
|
274
|
-
super.updateLayout(parentTag, tag, x, y, width, height);
|
|
275
|
-
if (isLayoutAnimationDisabled()) {
|
|
276
|
-
return;
|
|
277
|
-
}
|
|
278
|
-
try {
|
|
279
|
-
View viewToUpdate = this.resolveView(tag);
|
|
280
|
-
ViewManager viewManager = this.resolveViewManager(tag);
|
|
281
|
-
String viewManagerName = viewManager.getName();
|
|
282
|
-
View container = resolveView(parentTag);
|
|
283
|
-
if (container != null
|
|
284
|
-
&& viewManagerName.equals("RNSScreen")
|
|
285
|
-
&& this.mReaLayoutAnimator != null) {
|
|
286
|
-
this.mReaLayoutAnimator.applyLayoutUpdate(
|
|
287
|
-
viewToUpdate,
|
|
288
|
-
(int) container.getX(),
|
|
289
|
-
(int) container.getY(),
|
|
290
|
-
container.getWidth(),
|
|
291
|
-
container.getHeight());
|
|
292
|
-
}
|
|
293
|
-
} catch (IllegalViewOperationException e) {
|
|
294
|
-
// (IllegalViewOperationException) == (vm == null)
|
|
295
|
-
e.printStackTrace();
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
|
|
299
272
|
@Override
|
|
300
273
|
public synchronized void manageChildren(
|
|
301
274
|
int tag,
|
package/ios/REAModule.mm
CHANGED
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
#import <RNReanimated/REAModule.h>
|
|
3
3
|
#import <RNReanimated/REANodesManager.h>
|
|
4
4
|
#import <RNReanimated/REATransitionManager.h>
|
|
5
|
+
#import <RNReanimated/ReanimatedVersion.h>
|
|
5
6
|
#import <RNReanimated/SingleInstanceChecker.h>
|
|
6
7
|
|
|
8
|
+
using namespace facebook::react;
|
|
7
9
|
using namespace reanimated;
|
|
8
10
|
|
|
9
11
|
typedef void (^AnimatedOperation)(REANodesManager *nodesManager);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#import <RNReanimated/REAInitializer.h>
|
|
2
2
|
#import <RNReanimated/REAUIManager.h>
|
|
3
|
+
#import <RNReanimated/ReanimatedVersion.h>
|
|
3
4
|
|
|
4
5
|
@interface RCTEventDispatcher (Reanimated)
|
|
5
6
|
|
|
@@ -56,6 +57,9 @@ JSIExecutor::RuntimeInstaller REAJSIExecutorRuntimeInstaller(
|
|
|
56
57
|
|
|
57
58
|
runtime.global().setProperty(runtime, "_WORKLET_RUNTIME", workletRuntimeValue);
|
|
58
59
|
|
|
60
|
+
auto version = getReanimatedVersionString(runtime);
|
|
61
|
+
runtime.global().setProperty(runtime, "_REANIMATED_VERSION_CPP", version);
|
|
62
|
+
|
|
59
63
|
runtime.global().setProperty(
|
|
60
64
|
runtime,
|
|
61
65
|
jsi::PropNameID::forAscii(runtime, "__reanimatedModuleProxy"),
|
|
@@ -190,6 +190,11 @@ export default function createAnimatedComponent(Component, options) {
|
|
|
190
190
|
_attachNativeEvents() {
|
|
191
191
|
const node = this._getEventViewRef();
|
|
192
192
|
const viewTag = findNodeHandle((options === null || options === void 0 ? void 0 : options.setNativeProps) ? this : node);
|
|
193
|
+
const componentName = Component.displayName || Component.name;
|
|
194
|
+
if ((componentName === null || componentName === void 0 ? void 0 : componentName.endsWith('FlashList')) && this._component) {
|
|
195
|
+
// @ts-ignore it's FlashList specific: https://github.com/Shopify/flash-list/blob/218f314e63806b4fe926741ef73f8b9cd6ebc7eb/src/FlashList.tsx#L824
|
|
196
|
+
viewTag = findNodeHandle(this._component.recyclerlistview_unsafe);
|
|
197
|
+
}
|
|
193
198
|
for (const key in this.props) {
|
|
194
199
|
const prop = this.props[key];
|
|
195
200
|
if (prop instanceof AnimatedEvent) {
|
|
@@ -460,10 +460,10 @@ function HSVtoRGB(h, s, v) {
|
|
|
460
460
|
};
|
|
461
461
|
/* eslint-enable */
|
|
462
462
|
}
|
|
463
|
-
export const hsvToColor = (h, s, v) => {
|
|
463
|
+
export const hsvToColor = (h, s, v, a) => {
|
|
464
464
|
'worklet';
|
|
465
465
|
const { r, g, b } = HSVtoRGB(h, s, v);
|
|
466
|
-
return rgbaColor(r, g, b);
|
|
466
|
+
return rgbaColor(r, g, b, a);
|
|
467
467
|
};
|
|
468
468
|
export function processColorInitially(color) {
|
|
469
469
|
'worklet';
|
|
@@ -505,18 +505,34 @@ export function processColor(color) {
|
|
|
505
505
|
}
|
|
506
506
|
return normalizedColor;
|
|
507
507
|
}
|
|
508
|
-
export function
|
|
508
|
+
export function convertToRGBA(color) {
|
|
509
509
|
'worklet';
|
|
510
510
|
const processedColor = processColorInitially(color); // argb;
|
|
511
511
|
const a = (processedColor >>> 24) / 255;
|
|
512
|
-
const r = (processedColor << 8) >>> 24;
|
|
513
|
-
const g = (processedColor << 16) >>> 24;
|
|
514
|
-
const b = (processedColor << 24) >>> 24;
|
|
515
|
-
|
|
516
|
-
return [h, s, v, a];
|
|
512
|
+
const r = ((processedColor << 8) >>> 24) / 255;
|
|
513
|
+
const g = ((processedColor << 16) >>> 24) / 255;
|
|
514
|
+
const b = ((processedColor << 24) >>> 24) / 255;
|
|
515
|
+
return [r, g, b, a];
|
|
517
516
|
}
|
|
518
|
-
export function
|
|
517
|
+
export function rgbaArrayToRGBAColor(RGBA) {
|
|
519
518
|
'worklet';
|
|
520
|
-
|
|
521
|
-
|
|
519
|
+
return `rgba(${Math.round(RGBA[0] * 255)}, ${Math.round(RGBA[1] * 255)}, ${Math.round(RGBA[2] * 255)}, ${RGBA[3]})`;
|
|
520
|
+
}
|
|
521
|
+
export function toLinearSpace(RGBA, gamma = 2.2) {
|
|
522
|
+
'worklet';
|
|
523
|
+
const res = [];
|
|
524
|
+
for (let i = 0; i < 3; ++i) {
|
|
525
|
+
res.push(Math.pow(RGBA[i], gamma));
|
|
526
|
+
}
|
|
527
|
+
res.push(RGBA[3]);
|
|
528
|
+
return res;
|
|
529
|
+
}
|
|
530
|
+
export function toGammaSpace(RGBA, gamma = 2.2) {
|
|
531
|
+
'worklet';
|
|
532
|
+
const res = [];
|
|
533
|
+
for (let i = 0; i < 3; ++i) {
|
|
534
|
+
res.push(Math.pow(RGBA[i], 1 / gamma));
|
|
535
|
+
}
|
|
536
|
+
res.push(RGBA[3]);
|
|
537
|
+
return res;
|
|
522
538
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { NativeModules } from 'react-native';
|
|
2
|
+
import { checkVersion } from '../platform-specific/checkVersion';
|
|
2
3
|
export class NativeReanimated {
|
|
3
4
|
constructor(native = true) {
|
|
4
5
|
if (global.__reanimatedModuleProxy === undefined && native) {
|
|
@@ -7,6 +8,9 @@ export class NativeReanimated {
|
|
|
7
8
|
}
|
|
8
9
|
this.InnerNativeModule = global.__reanimatedModuleProxy;
|
|
9
10
|
this.native = native;
|
|
11
|
+
if (native) {
|
|
12
|
+
checkVersion();
|
|
13
|
+
}
|
|
10
14
|
}
|
|
11
15
|
installCoreFunctions(valueSetter) {
|
|
12
16
|
return this.InnerNativeModule.installCoreFunctions(valueSetter);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* global _WORKLET */
|
|
2
|
-
import {
|
|
2
|
+
import { isColor, convertToRGBA, rgbaArrayToRGBAColor, toGammaSpace, toLinearSpace, } from '../Colors';
|
|
3
3
|
import NativeReanimatedModule from '../NativeReanimated';
|
|
4
4
|
let IN_STYLE_UPDATER = false;
|
|
5
5
|
export function initialUpdaterRun(updater) {
|
|
@@ -75,39 +75,39 @@ function decorateAnimation(animation) {
|
|
|
75
75
|
((_b = animation.__suffix) !== null && _b !== void 0 ? _b : '');
|
|
76
76
|
return res;
|
|
77
77
|
};
|
|
78
|
-
const tab = ['
|
|
78
|
+
const tab = ['R', 'G', 'B', 'A'];
|
|
79
79
|
const colorOnStart = (animation, value, timestamp, previousAnimation) => {
|
|
80
|
-
let
|
|
81
|
-
let
|
|
82
|
-
let
|
|
80
|
+
let RGBAValue;
|
|
81
|
+
let RGBACurrent;
|
|
82
|
+
let RGBAToValue;
|
|
83
83
|
const res = [];
|
|
84
84
|
if (isColor(value)) {
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
RGBACurrent = toLinearSpace(convertToRGBA(animation.current));
|
|
86
|
+
RGBAValue = toLinearSpace(convertToRGBA(value));
|
|
87
87
|
if (animation.toValue) {
|
|
88
|
-
|
|
88
|
+
RGBAToValue = toLinearSpace(convertToRGBA(animation.toValue));
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
tab.forEach((i, index) => {
|
|
92
92
|
animation[i] = Object.assign({}, animationCopy);
|
|
93
|
-
animation[i].current =
|
|
94
|
-
animation[i].toValue =
|
|
95
|
-
animation[i].onStart(animation[i],
|
|
93
|
+
animation[i].current = RGBACurrent[index];
|
|
94
|
+
animation[i].toValue = RGBAToValue ? RGBAToValue[index] : undefined;
|
|
95
|
+
animation[i].onStart(animation[i], RGBAValue[index], timestamp, previousAnimation ? previousAnimation[i] : undefined);
|
|
96
96
|
res.push(animation[i].current);
|
|
97
97
|
});
|
|
98
|
-
animation.current =
|
|
98
|
+
animation.current = rgbaArrayToRGBAColor(toGammaSpace(res));
|
|
99
99
|
};
|
|
100
100
|
const colorOnFrame = (animation, timestamp) => {
|
|
101
|
-
const
|
|
101
|
+
const RGBACurrent = toLinearSpace(convertToRGBA(animation.current));
|
|
102
102
|
const res = [];
|
|
103
103
|
let finished = true;
|
|
104
104
|
tab.forEach((i, index) => {
|
|
105
|
-
animation[i].current =
|
|
105
|
+
animation[i].current = RGBACurrent[index];
|
|
106
106
|
// @ts-ignore: disable-next-line
|
|
107
107
|
finished &= animation[i].onFrame(animation[i], timestamp);
|
|
108
108
|
res.push(animation[i].current);
|
|
109
109
|
});
|
|
110
|
-
animation.current =
|
|
110
|
+
animation.current = rgbaArrayToRGBAColor(toGammaSpace(res));
|
|
111
111
|
return finished;
|
|
112
112
|
};
|
|
113
113
|
const arrayOnStart = (animation, value, timestamp, previousAnimation) => {
|