react-native-reanimated 3.0.0-rc.9 → 3.0.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.
- package/Common/cpp/AnimatedSensor/AnimatedSensorModule.cpp +30 -12
- package/Common/cpp/AnimatedSensor/AnimatedSensorModule.h +2 -0
- package/Common/cpp/Fabric/FabricUtils.cpp +3 -107
- package/Common/cpp/Fabric/FabricUtils.h +3 -24
- package/Common/cpp/Fabric/ReanimatedUIManagerBinding.cpp +54 -37
- package/Common/cpp/LayoutAnimations/LayoutAnimationType.h +8 -0
- package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.cpp +81 -26
- package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.h +20 -3
- package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +105 -109
- package/Common/cpp/NativeModules/NativeReanimatedModule.h +19 -12
- package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +15 -7
- package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.h +6 -2
- package/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.cpp +20 -1
- package/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.h +9 -0
- package/Common/cpp/ReanimatedRuntime/ReanimatedRuntime.cpp +5 -1
- package/Common/cpp/Registries/EventHandlerRegistry.cpp +8 -34
- package/Common/cpp/Registries/EventHandlerRegistry.h +7 -13
- package/Common/cpp/SharedItems/Shareables.cpp +9 -63
- package/Common/cpp/SharedItems/Shareables.h +77 -72
- package/Common/cpp/Tools/CollectionUtils.h +14 -0
- package/Common/cpp/Tools/JsiUtils.cpp +26 -0
- package/Common/cpp/Tools/JsiUtils.h +176 -0
- package/Common/cpp/Tools/PlatformDepMethodsHolder.h +5 -5
- package/Common/cpp/Tools/ReanimatedVersion.cpp +17 -0
- package/Common/cpp/Tools/ReanimatedVersion.h +11 -0
- package/Common/cpp/Tools/RuntimeDecorator.cpp +49 -230
- package/Common/cpp/Tools/RuntimeDecorator.h +0 -2
- package/Common/cpp/Tools/WorkletEventHandler.cpp +3 -2
- package/Common/cpp/Tools/WorkletEventHandler.h +14 -6
- package/README.md +1 -1
- package/RNReanimated.podspec +2 -1
- package/android/CMakeLists.txt +188 -181
- package/android/build.gradle +362 -311
- package/android/proguard-rules.pro +2 -0
- package/android/src/fabric/java/com/swmansion/reanimated/NativeProxy.java +63 -295
- package/android/src/main/cpp/LayoutAnimations.cpp +35 -5
- package/android/src/main/cpp/LayoutAnimations.h +23 -6
- package/android/src/main/cpp/NativeProxy.cpp +143 -98
- package/android/src/main/cpp/NativeProxy.h +22 -28
- package/android/src/main/java/com/swmansion/reanimated/ReanimatedPackage.java +5 -4
- package/android/src/main/java/com/swmansion/reanimated/Utils.java +7 -1
- package/android/src/main/java/com/swmansion/reanimated/keyboardObserver/ReanimatedKeyboardEventListener.java +10 -3
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/AnimationsManager.java +218 -35
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/LayoutAnimations.java +43 -17
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/NativeMethodsHolder.java +6 -2
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/SharedElement.java +19 -0
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/SharedTransitionManager.java +610 -0
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/Snapshot.java +93 -23
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/AnimationFrameCallback.java +19 -0
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/EventHandler.java +35 -0
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/KeyboardEventDataUpdater.java +16 -0
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/NativeProxyCommon.java +206 -0
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/SensorSetter.java +17 -0
- package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensor.java +9 -3
- package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorContainer.java +3 -4
- package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorListener.java +31 -7
- package/android/src/paper/java/com/swmansion/reanimated/NativeProxy.java +90 -307
- package/android/src/reactNativeVersionPatch/ReanimatedUIManager/70/com/swmansion/reanimated/ReanimatedUIManagerFactory.java +16 -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 +76 -20
- package/ios/LayoutReanimation/REAAnimationsManager.h +28 -4
- package/ios/LayoutReanimation/REAAnimationsManager.m +216 -61
- package/ios/LayoutReanimation/REAFrame.h +10 -0
- package/ios/LayoutReanimation/REAFrame.m +15 -0
- package/ios/LayoutReanimation/REAScreensHelper.h +19 -0
- package/ios/LayoutReanimation/REAScreensHelper.m +106 -0
- package/ios/LayoutReanimation/REASharedElement.h +15 -0
- package/ios/LayoutReanimation/REASharedElement.m +16 -0
- package/ios/LayoutReanimation/REASharedTransitionManager.h +17 -0
- package/ios/LayoutReanimation/REASharedTransitionManager.m +632 -0
- package/ios/LayoutReanimation/REASnapshot.h +1 -0
- package/ios/LayoutReanimation/REASnapshot.m +96 -11
- package/ios/LayoutReanimation/REAUIManager.mm +64 -17
- package/ios/REAModule.mm +2 -7
- package/ios/REANodesManager.mm +1 -21
- package/ios/keyboardObserver/REAKeyboardEventObserver.m +72 -36
- package/ios/native/NativeProxy.mm +75 -114
- package/ios/native/REAInitializer.mm +2 -7
- package/ios/native/REAJSIUtils.h +60 -2
- package/ios/sensor/ReanimatedSensor.h +6 -2
- package/ios/sensor/ReanimatedSensor.m +43 -7
- package/ios/sensor/ReanimatedSensorContainer.h +4 -1
- package/ios/sensor/ReanimatedSensorContainer.m +8 -2
- package/lib/commonjs/createAnimatedComponent.js +244 -28
- package/lib/commonjs/createAnimatedComponent.js.map +1 -1
- package/lib/commonjs/reanimated2/Colors.js +43 -22
- package/lib/commonjs/reanimated2/Colors.js.map +1 -1
- package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js +16 -33
- package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/styleAnimation.js +5 -1
- package/lib/commonjs/reanimated2/animation/styleAnimation.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/util.js +17 -15
- package/lib/commonjs/reanimated2/animation/util.js.map +1 -1
- package/lib/commonjs/reanimated2/commonTypes.js +33 -1
- package/lib/commonjs/reanimated2/commonTypes.js.map +1 -1
- package/lib/commonjs/reanimated2/core.js +33 -14
- package/lib/commonjs/reanimated2/core.js.map +1 -1
- package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryUI.js +2 -2
- package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryUI.js.map +1 -1
- package/lib/commonjs/reanimated2/globals.d.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/index.js +0 -6
- package/lib/commonjs/reanimated2/hook/index.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js +5 -2
- package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedReaction.js +13 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedReaction.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedRef.js +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedRef.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js +91 -15
- package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js +43 -40
- package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useDerivedValue.js +13 -1
- package/lib/commonjs/reanimated2/hook/useDerivedValue.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useScrollViewOffset.js +2 -2
- package/lib/commonjs/reanimated2/hook/useScrollViewOffset.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/utils.js +18 -65
- package/lib/commonjs/reanimated2/hook/utils.js.map +1 -1
- package/lib/commonjs/reanimated2/index.js +13 -0
- package/lib/commonjs/reanimated2/index.js.map +1 -1
- package/lib/commonjs/reanimated2/initializers.js +71 -32
- package/lib/commonjs/reanimated2/initializers.js.map +1 -1
- package/lib/commonjs/reanimated2/interpolateColor.js +96 -19
- package/lib/commonjs/reanimated2/interpolateColor.js.map +1 -1
- package/lib/commonjs/reanimated2/jestUtils.js +1 -1
- package/lib/commonjs/reanimated2/jestUtils.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js +103 -13
- package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/Mapper.js +22 -0
- package/lib/commonjs/reanimated2/js-reanimated/Mapper.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/WebSensor.js +2 -0
- package/lib/commonjs/reanimated2/js-reanimated/WebSensor.js.map +1 -0
- package/lib/commonjs/reanimated2/js-reanimated/commonTypes.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/global.js +0 -2
- package/lib/commonjs/reanimated2/js-reanimated/global.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/index.js +0 -1
- package/lib/commonjs/reanimated2/js-reanimated/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +11 -0
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/index.js +8 -0
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js +22 -9
- package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +16 -23
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +8 -14
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Roll.js +8 -14
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Slide.js +8 -15
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +16 -23
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/index.js +13 -0
- package/lib/commonjs/reanimated2/layoutReanimation/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/sharedTransitions/index.js +94 -0
- package/lib/commonjs/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -0
- package/lib/commonjs/reanimated2/mappers.js +18 -6
- package/lib/commonjs/reanimated2/mappers.js.map +1 -1
- package/lib/commonjs/reanimated2/mock.js +20 -1
- package/lib/commonjs/reanimated2/mock.js.map +1 -1
- package/lib/commonjs/reanimated2/mutables.js +4 -2
- package/lib/commonjs/reanimated2/mutables.js.map +1 -1
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.js +42 -0
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.js.map +1 -0
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.web.js +15 -0
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.web.js.map +1 -0
- package/lib/commonjs/reanimated2/pluginUtils.js +11 -0
- package/lib/commonjs/reanimated2/pluginUtils.js.map +1 -0
- package/lib/commonjs/reanimated2/shareables.js +36 -15
- package/lib/commonjs/reanimated2/shareables.js.map +1 -1
- package/lib/commonjs/reanimated2/threads.js +114 -7
- package/lib/commonjs/reanimated2/threads.js.map +1 -1
- package/lib/commonjs/reanimated2/utils.js +7 -0
- package/lib/commonjs/reanimated2/utils.js.map +1 -1
- package/lib/commonjs/reanimated2/valueSetter.js +1 -3
- package/lib/commonjs/reanimated2/valueSetter.js.map +1 -1
- package/lib/module/createAnimatedComponent.js +241 -29
- package/lib/module/createAnimatedComponent.js.map +1 -1
- package/lib/module/reanimated2/Colors.js +35 -19
- package/lib/module/reanimated2/Colors.js.map +1 -1
- package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js +16 -32
- package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
- package/lib/module/reanimated2/animation/styleAnimation.js +5 -1
- package/lib/module/reanimated2/animation/styleAnimation.js.map +1 -1
- package/lib/module/reanimated2/animation/util.js +17 -16
- package/lib/module/reanimated2/animation/util.js.map +1 -1
- package/lib/module/reanimated2/commonTypes.js +29 -0
- package/lib/module/reanimated2/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/core.js +32 -7
- package/lib/module/reanimated2/core.js.map +1 -1
- package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js +2 -2
- package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js.map +1 -1
- package/lib/module/reanimated2/globals.d.js.map +1 -1
- package/lib/module/reanimated2/hook/index.js +1 -1
- package/lib/module/reanimated2/hook/index.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedKeyboard.js +5 -2
- package/lib/module/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedReaction.js +12 -1
- package/lib/module/reanimated2/hook/useAnimatedReaction.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedRef.js +2 -2
- package/lib/module/reanimated2/hook/useAnimatedRef.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedSensor.js +90 -13
- package/lib/module/reanimated2/hook/useAnimatedSensor.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedStyle.js +46 -43
- package/lib/module/reanimated2/hook/useAnimatedStyle.js.map +1 -1
- package/lib/module/reanimated2/hook/useDerivedValue.js +12 -1
- package/lib/module/reanimated2/hook/useDerivedValue.js.map +1 -1
- package/lib/module/reanimated2/hook/useScrollViewOffset.js +2 -2
- package/lib/module/reanimated2/hook/useScrollViewOffset.js.map +1 -1
- package/lib/module/reanimated2/hook/utils.js +17 -60
- package/lib/module/reanimated2/hook/utils.js.map +1 -1
- package/lib/module/reanimated2/index.js +1 -0
- package/lib/module/reanimated2/index.js.map +1 -1
- package/lib/module/reanimated2/initializers.js +72 -33
- package/lib/module/reanimated2/initializers.js.map +1 -1
- package/lib/module/reanimated2/interpolateColor.js +96 -19
- package/lib/module/reanimated2/interpolateColor.js.map +1 -1
- package/lib/module/reanimated2/jestUtils.js +1 -1
- package/lib/module/reanimated2/jestUtils.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/JSReanimated.js +103 -13
- package/lib/module/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/Mapper.js +21 -0
- package/lib/module/reanimated2/js-reanimated/Mapper.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/WebSensor.js +2 -0
- package/lib/module/reanimated2/js-reanimated/WebSensor.js.map +1 -0
- package/lib/module/reanimated2/js-reanimated/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/global.js +0 -2
- package/lib/module/reanimated2/js-reanimated/global.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/index.js +0 -1
- package/lib/module/reanimated2/js-reanimated/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +9 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/index.js +1 -0
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationsManager.js +20 -8
- package/lib/module/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +16 -21
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +8 -12
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js +8 -12
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js +8 -13
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +16 -21
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/index.js +1 -0
- package/lib/module/reanimated2/layoutReanimation/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js +82 -0
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -0
- package/lib/module/reanimated2/mappers.js +16 -6
- package/lib/module/reanimated2/mappers.js.map +1 -1
- package/lib/module/reanimated2/mock.js +20 -1
- package/lib/module/reanimated2/mock.js.map +1 -1
- package/lib/module/reanimated2/mutables.js +4 -2
- package/lib/module/reanimated2/mutables.js.map +1 -1
- package/lib/module/reanimated2/platform-specific/checkVersion.js +35 -0
- package/lib/module/reanimated2/platform-specific/checkVersion.js.map +1 -0
- package/lib/module/reanimated2/platform-specific/checkVersion.web.js +8 -0
- package/lib/module/reanimated2/platform-specific/checkVersion.web.js.map +1 -0
- package/lib/module/reanimated2/pluginUtils.js +4 -0
- package/lib/module/reanimated2/pluginUtils.js.map +1 -0
- package/lib/module/reanimated2/shareables.js +36 -12
- package/lib/module/reanimated2/shareables.js.map +1 -1
- package/lib/module/reanimated2/threads.js +105 -7
- package/lib/module/reanimated2/threads.js.map +1 -1
- package/lib/module/reanimated2/utils.js +5 -0
- package/lib/module/reanimated2/utils.js.map +1 -1
- package/lib/module/reanimated2/valueSetter.js +1 -2
- package/lib/module/reanimated2/valueSetter.js.map +1 -1
- package/mock.js +1 -211
- package/package.json +10 -10
- package/{plugin.js → plugin/index.js} +128 -249
- package/react-native-reanimated.d.ts +55 -417
- package/scripts/reanimated_utils.rb +15 -2
- package/src/createAnimatedComponent.tsx +247 -28
- package/src/reanimated2/Colors.ts +38 -11
- package/src/reanimated2/NativeReanimated/NativeReanimated.ts +52 -39
- package/src/reanimated2/animation/styleAnimation.ts +8 -1
- package/src/reanimated2/animation/util.ts +29 -16
- package/src/reanimated2/commonTypes.ts +28 -1
- package/src/reanimated2/core.ts +42 -9
- package/src/reanimated2/frameCallback/FrameCallbackRegistryUI.ts +2 -2
- package/src/reanimated2/globals.d.ts +12 -15
- package/src/reanimated2/hook/index.ts +1 -1
- package/src/reanimated2/hook/useAnimatedKeyboard.ts +10 -4
- package/src/reanimated2/hook/useAnimatedReaction.ts +12 -5
- package/src/reanimated2/hook/useAnimatedRef.ts +1 -4
- package/src/reanimated2/hook/useAnimatedSensor.ts +90 -11
- package/src/reanimated2/hook/useAnimatedStyle.ts +44 -36
- package/src/reanimated2/hook/useDerivedValue.ts +8 -1
- package/src/reanimated2/hook/useScrollViewOffset.ts +2 -2
- package/src/reanimated2/hook/utils.ts +15 -61
- package/src/reanimated2/index.ts +1 -0
- package/src/reanimated2/initializers.ts +76 -35
- package/src/reanimated2/interpolateColor.ts +104 -20
- package/src/reanimated2/jestUtils.ts +1 -1
- package/src/reanimated2/js-reanimated/JSReanimated.ts +98 -15
- package/src/reanimated2/js-reanimated/Mapper.ts +32 -0
- package/src/reanimated2/js-reanimated/WebSensor.ts +34 -0
- package/src/reanimated2/js-reanimated/commonTypes.ts +0 -1
- package/src/reanimated2/js-reanimated/global.ts +0 -1
- package/src/reanimated2/js-reanimated/index.ts +0 -1
- package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +13 -1
- package/src/reanimated2/layoutReanimation/animationBuilder/index.ts +1 -0
- package/src/reanimated2/layoutReanimation/animationsManager.ts +20 -9
- 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/layoutReanimation/index.ts +1 -0
- package/src/reanimated2/layoutReanimation/sharedTransitions/index.ts +87 -0
- package/src/reanimated2/mappers.ts +17 -6
- package/src/reanimated2/mock.ts +25 -2
- package/src/reanimated2/mutables.ts +2 -0
- package/src/reanimated2/platform-specific/checkVersion.ts +39 -0
- package/src/reanimated2/platform-specific/checkVersion.web.ts +6 -0
- package/src/reanimated2/pluginUtils.ts +8 -0
- package/src/reanimated2/shareables.ts +45 -16
- package/src/reanimated2/threads.ts +103 -4
- package/src/reanimated2/utils.ts +6 -0
- package/src/reanimated2/valueSetter.ts +1 -2
- package/lib/commonjs/reanimated2/time.js +0 -55
- package/lib/commonjs/reanimated2/time.js.map +0 -1
- package/lib/module/reanimated2/time.js +0 -37
- package/lib/module/reanimated2/time.js.map +0 -1
- package/src/reanimated2/time.ts +0 -30
- /package/android/src/{main/java → reactNativeVersionPatch/ReanimatedUIManager/70}/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +0 -0
|
@@ -10,6 +10,8 @@ import {
|
|
|
10
10
|
configureLayoutAnimations,
|
|
11
11
|
enableLayoutAnimations,
|
|
12
12
|
runOnUI,
|
|
13
|
+
startMapper,
|
|
14
|
+
stopMapper,
|
|
13
15
|
} from './reanimated2/core';
|
|
14
16
|
import {
|
|
15
17
|
isJest,
|
|
@@ -19,9 +21,11 @@ import {
|
|
|
19
21
|
import { initialUpdaterRun } from './reanimated2/animation';
|
|
20
22
|
import {
|
|
21
23
|
BaseAnimationBuilder,
|
|
24
|
+
DefaultSharedTransition,
|
|
22
25
|
EntryExitAnimationFunction,
|
|
23
26
|
ILayoutAnimationBuilder,
|
|
24
27
|
LayoutAnimationFunction,
|
|
28
|
+
LayoutAnimationType,
|
|
25
29
|
} from './reanimated2/layoutReanimation';
|
|
26
30
|
import {
|
|
27
31
|
SharedValue,
|
|
@@ -29,11 +33,14 @@ import {
|
|
|
29
33
|
ShadowNodeWrapper,
|
|
30
34
|
} from './reanimated2/commonTypes';
|
|
31
35
|
import {
|
|
36
|
+
makeViewDescriptorsSet,
|
|
32
37
|
ViewDescriptorsSet,
|
|
33
38
|
ViewRefSet,
|
|
34
39
|
} from './reanimated2/ViewDescriptorsSet';
|
|
35
40
|
import { getShadowNodeWrapperFromRef } from './reanimated2/fabricUtils';
|
|
36
|
-
import
|
|
41
|
+
import updateProps from './reanimated2/UpdateProps';
|
|
42
|
+
import NativeReanimatedModule from './reanimated2/NativeReanimated';
|
|
43
|
+
import { isSharedValue } from './reanimated2';
|
|
37
44
|
|
|
38
45
|
function dummyListener() {
|
|
39
46
|
// empty listener we use to assign to listener properties for which animated
|
|
@@ -108,6 +115,87 @@ const has = <K extends string>(
|
|
|
108
115
|
return false;
|
|
109
116
|
};
|
|
110
117
|
|
|
118
|
+
function isInlineStyleTransform(transform: any): boolean {
|
|
119
|
+
if (!transform) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
return transform.some((t: Record<string, any>) => hasInlineStyles(t));
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function hasInlineStyles(style: StyleProps): boolean {
|
|
126
|
+
if (!style) {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
return Object.keys(style).some((key) => {
|
|
130
|
+
const styleValue = style[key];
|
|
131
|
+
return (
|
|
132
|
+
isSharedValue(styleValue) ||
|
|
133
|
+
(key === 'transform' && isInlineStyleTransform(styleValue))
|
|
134
|
+
);
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function extractSharedValuesMapFromProps(
|
|
139
|
+
props: AnimatedComponentProps<InitialComponentProps>
|
|
140
|
+
): Record<string, any> {
|
|
141
|
+
const inlineProps: Record<string, any> = {};
|
|
142
|
+
|
|
143
|
+
for (const key in props) {
|
|
144
|
+
const value = props[key];
|
|
145
|
+
if (key === 'style') {
|
|
146
|
+
const styles = flattenArray<StyleProps>(props.style ?? []);
|
|
147
|
+
styles.forEach((style) => {
|
|
148
|
+
if (!style) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
for (const [key, styleValue] of Object.entries(style)) {
|
|
152
|
+
if (isSharedValue(styleValue)) {
|
|
153
|
+
inlineProps[key] = styleValue;
|
|
154
|
+
} else if (
|
|
155
|
+
key === 'transform' &&
|
|
156
|
+
isInlineStyleTransform(styleValue)
|
|
157
|
+
) {
|
|
158
|
+
inlineProps[key] = styleValue;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
} else if (isSharedValue(value)) {
|
|
163
|
+
inlineProps[key] = value;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return inlineProps;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function inlinePropsHasChanged(styles1: StyleProps, styles2: StyleProps) {
|
|
171
|
+
if (Object.keys(styles1).length !== Object.keys(styles2).length) {
|
|
172
|
+
return true;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
for (const key of Object.keys(styles1)) {
|
|
176
|
+
if (styles1[key] !== styles2[key]) return true;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return false;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function getInlinePropsUpdate(inlineProps: Record<string, any>) {
|
|
183
|
+
'worklet';
|
|
184
|
+
const update: Record<string, any> = {};
|
|
185
|
+
for (const [key, styleValue] of Object.entries(inlineProps)) {
|
|
186
|
+
if (key === 'transform') {
|
|
187
|
+
update[key] = styleValue.map((transform: Record<string, any>) => {
|
|
188
|
+
return getInlinePropsUpdate(transform);
|
|
189
|
+
});
|
|
190
|
+
} else if (isSharedValue(styleValue)) {
|
|
191
|
+
update[key] = styleValue.value;
|
|
192
|
+
} else {
|
|
193
|
+
update[key] = styleValue;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return update;
|
|
197
|
+
}
|
|
198
|
+
|
|
111
199
|
interface AnimatedProps extends Record<string, unknown> {
|
|
112
200
|
viewDescriptors?: ViewDescriptorsSet;
|
|
113
201
|
viewsRef?: ViewRefSet<unknown>;
|
|
@@ -133,6 +221,8 @@ export type AnimatedComponentProps<P extends Record<string, unknown>> = P & {
|
|
|
133
221
|
| typeof BaseAnimationBuilder
|
|
134
222
|
| EntryExitAnimationFunction
|
|
135
223
|
| Keyframe;
|
|
224
|
+
sharedTransitionTag?: string;
|
|
225
|
+
sharedTransitionStyle?: ILayoutAnimationBuilder;
|
|
136
226
|
};
|
|
137
227
|
|
|
138
228
|
type Options<P> = {
|
|
@@ -170,6 +260,9 @@ export default function createAnimatedComponent(
|
|
|
170
260
|
animatedStyle: { value: StyleProps } = { value: {} };
|
|
171
261
|
initialStyle = {};
|
|
172
262
|
_component: ComponentRef | null = null;
|
|
263
|
+
_inlinePropsViewDescriptors: ViewDescriptorsSet | null = null;
|
|
264
|
+
_inlinePropsMapperId: number | null = null;
|
|
265
|
+
_inlineProps: StyleProps = {};
|
|
173
266
|
static displayName: string;
|
|
174
267
|
|
|
175
268
|
constructor(props: AnimatedComponentProps<InitialComponentProps>) {
|
|
@@ -182,15 +275,27 @@ export default function createAnimatedComponent(
|
|
|
182
275
|
componentWillUnmount() {
|
|
183
276
|
this._detachNativeEvents();
|
|
184
277
|
this._detachStyles();
|
|
278
|
+
this._detachInlineProps();
|
|
185
279
|
}
|
|
186
280
|
|
|
187
281
|
componentDidMount() {
|
|
188
282
|
this._attachNativeEvents();
|
|
189
283
|
this._attachAnimatedStyles();
|
|
284
|
+
this._attachInlineProps();
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
_getEventViewRef() {
|
|
288
|
+
// Make sure to get the scrollable node for components that implement
|
|
289
|
+
// `ScrollResponder.Mixin`.
|
|
290
|
+
return this._component?.getScrollableNode
|
|
291
|
+
? this._component.getScrollableNode()
|
|
292
|
+
: this._component;
|
|
190
293
|
}
|
|
191
294
|
|
|
192
295
|
_attachNativeEvents() {
|
|
193
|
-
const
|
|
296
|
+
const node = this._getEventViewRef();
|
|
297
|
+
const viewTag = findNodeHandle(options?.setNativeProps ? this : node);
|
|
298
|
+
|
|
194
299
|
for (const key in this.props) {
|
|
195
300
|
const prop = this.props[key];
|
|
196
301
|
if (
|
|
@@ -229,10 +334,10 @@ export default function createAnimatedComponent(
|
|
|
229
334
|
this.props.animatedProps.viewDescriptors.remove(this._viewTag);
|
|
230
335
|
}
|
|
231
336
|
if (global._IS_FABRIC) {
|
|
232
|
-
const
|
|
337
|
+
const viewTag = this._viewTag;
|
|
233
338
|
runOnUI(() => {
|
|
234
339
|
'worklet';
|
|
235
|
-
_removeShadowNodeFromRegistry(
|
|
340
|
+
_removeShadowNodeFromRegistry(viewTag);
|
|
236
341
|
})();
|
|
237
342
|
}
|
|
238
343
|
}
|
|
@@ -289,23 +394,16 @@ export default function createAnimatedComponent(
|
|
|
289
394
|
}
|
|
290
395
|
}
|
|
291
396
|
|
|
292
|
-
|
|
293
|
-
const styles = this.props.style
|
|
294
|
-
? onlyAnimatedStyles(flattenArray<StyleProps>(this.props.style))
|
|
295
|
-
: [];
|
|
296
|
-
const prevStyles = this._styles;
|
|
297
|
-
this._styles = styles;
|
|
298
|
-
|
|
299
|
-
const prevAnimatedProps = this._animatedProps;
|
|
300
|
-
this._animatedProps = this.props.animatedProps;
|
|
301
|
-
|
|
397
|
+
_getViewInfo() {
|
|
302
398
|
let viewTag: number | null;
|
|
303
399
|
let viewName: string | null;
|
|
304
400
|
let shadowNodeWrapper: ShadowNodeWrapper | null = null;
|
|
401
|
+
let viewConfig;
|
|
305
402
|
if (Platform.OS === 'web') {
|
|
306
403
|
viewTag = findNodeHandle(this);
|
|
307
404
|
viewName = null;
|
|
308
405
|
shadowNodeWrapper = null;
|
|
406
|
+
viewConfig = null;
|
|
309
407
|
} else {
|
|
310
408
|
// hostInstance can be null for a component that doesn't render anything (render function returns null). Example: svg Stop: https://github.com/react-native-svg/react-native-svg/blob/develop/src/elements/Stop.tsx
|
|
311
409
|
const hostInstance = RNRenderer.findHostInstance_DEPRECATED(this);
|
|
@@ -321,19 +419,36 @@ export default function createAnimatedComponent(
|
|
|
321
419
|
* The name we're looking for is in the field named uiViewClassName.
|
|
322
420
|
*/
|
|
323
421
|
viewName = hostInstance?.viewConfig?.uiViewClassName;
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
this.props.animatedProps?.viewDescriptors || styles.length;
|
|
327
|
-
if (hasReanimated2Props && hostInstance?.viewConfig) {
|
|
328
|
-
adaptViewConfig(hostInstance.viewConfig);
|
|
329
|
-
}
|
|
422
|
+
|
|
423
|
+
viewConfig = hostInstance?.viewConfig;
|
|
330
424
|
|
|
331
425
|
if (global._IS_FABRIC) {
|
|
332
|
-
shadowNodeWrapper =
|
|
333
|
-
getShadowNodeWrapperFromRef(this)
|
|
334
|
-
);
|
|
426
|
+
shadowNodeWrapper = getShadowNodeWrapperFromRef(this);
|
|
335
427
|
}
|
|
336
428
|
}
|
|
429
|
+
return { viewTag, viewName, shadowNodeWrapper, viewConfig };
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
_attachAnimatedStyles() {
|
|
433
|
+
const styles = this.props.style
|
|
434
|
+
? onlyAnimatedStyles(flattenArray<StyleProps>(this.props.style))
|
|
435
|
+
: [];
|
|
436
|
+
const prevStyles = this._styles;
|
|
437
|
+
this._styles = styles;
|
|
438
|
+
|
|
439
|
+
const prevAnimatedProps = this._animatedProps;
|
|
440
|
+
this._animatedProps = this.props.animatedProps;
|
|
441
|
+
|
|
442
|
+
const { viewTag, viewName, shadowNodeWrapper, viewConfig } =
|
|
443
|
+
this._getViewInfo();
|
|
444
|
+
|
|
445
|
+
// update UI props whitelist for this view
|
|
446
|
+
const hasReanimated2Props =
|
|
447
|
+
this.props.animatedProps?.viewDescriptors || styles.length;
|
|
448
|
+
if (hasReanimated2Props && viewConfig) {
|
|
449
|
+
adaptViewConfig(viewConfig);
|
|
450
|
+
}
|
|
451
|
+
|
|
337
452
|
this._viewTag = viewTag as number;
|
|
338
453
|
|
|
339
454
|
// remove old styles
|
|
@@ -399,11 +514,72 @@ export default function createAnimatedComponent(
|
|
|
399
514
|
}
|
|
400
515
|
}
|
|
401
516
|
|
|
517
|
+
_attachInlineProps() {
|
|
518
|
+
const newInlineProps: Record<string, any> =
|
|
519
|
+
extractSharedValuesMapFromProps(this.props);
|
|
520
|
+
const hasChanged = inlinePropsHasChanged(
|
|
521
|
+
newInlineProps,
|
|
522
|
+
this._inlineProps
|
|
523
|
+
);
|
|
524
|
+
|
|
525
|
+
if (hasChanged) {
|
|
526
|
+
if (!this._inlinePropsViewDescriptors) {
|
|
527
|
+
this._inlinePropsViewDescriptors = makeViewDescriptorsSet();
|
|
528
|
+
|
|
529
|
+
const { viewTag, viewName, shadowNodeWrapper, viewConfig } =
|
|
530
|
+
this._getViewInfo();
|
|
531
|
+
|
|
532
|
+
if (Object.keys(newInlineProps).length && viewConfig) {
|
|
533
|
+
adaptViewConfig(viewConfig);
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
this._inlinePropsViewDescriptors.add({
|
|
537
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
538
|
+
tag: viewTag!,
|
|
539
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
540
|
+
name: viewName!,
|
|
541
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
542
|
+
shadowNodeWrapper: shadowNodeWrapper!,
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
const sharableViewDescriptors =
|
|
546
|
+
this._inlinePropsViewDescriptors.sharableViewDescriptors;
|
|
547
|
+
|
|
548
|
+
const maybeViewRef = NativeReanimatedModule.native
|
|
549
|
+
? undefined
|
|
550
|
+
: ({ items: new Set([this]) } as ViewRefSet<any>); // see makeViewsRefSet
|
|
551
|
+
|
|
552
|
+
const updaterFunction = () => {
|
|
553
|
+
'worklet';
|
|
554
|
+
const update = getInlinePropsUpdate(newInlineProps);
|
|
555
|
+
updateProps(sharableViewDescriptors, update, maybeViewRef);
|
|
556
|
+
};
|
|
557
|
+
this._inlineProps = newInlineProps;
|
|
558
|
+
if (this._inlinePropsMapperId) {
|
|
559
|
+
stopMapper(this._inlinePropsMapperId);
|
|
560
|
+
}
|
|
561
|
+
this._inlinePropsMapperId = null;
|
|
562
|
+
if (Object.keys(newInlineProps).length) {
|
|
563
|
+
this._inlinePropsMapperId = startMapper(
|
|
564
|
+
updaterFunction,
|
|
565
|
+
Object.values(newInlineProps)
|
|
566
|
+
);
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
_detachInlineProps() {
|
|
572
|
+
if (this._inlinePropsMapperId) {
|
|
573
|
+
stopMapper(this._inlinePropsMapperId);
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
|
|
402
577
|
componentDidUpdate(
|
|
403
578
|
prevProps: AnimatedComponentProps<InitialComponentProps>
|
|
404
579
|
) {
|
|
405
580
|
this._reattachNativeEvents(prevProps);
|
|
406
581
|
this._attachAnimatedStyles();
|
|
582
|
+
this._attachInlineProps();
|
|
407
583
|
}
|
|
408
584
|
|
|
409
585
|
_setComponentRef = setAndForwardRef<Component>({
|
|
@@ -414,19 +590,44 @@ export default function createAnimatedComponent(
|
|
|
414
590
|
setLocalRef: (ref) => {
|
|
415
591
|
// TODO update config
|
|
416
592
|
const tag = findNodeHandle(ref);
|
|
417
|
-
const { layout, entering, exiting } = this.props;
|
|
418
|
-
if (
|
|
593
|
+
const { layout, entering, exiting, sharedTransitionTag } = this.props;
|
|
594
|
+
if (
|
|
595
|
+
(layout || entering || exiting || sharedTransitionTag) &&
|
|
596
|
+
tag != null
|
|
597
|
+
) {
|
|
419
598
|
if (!shouldBeUseWeb()) {
|
|
420
599
|
enableLayoutAnimations(true, false);
|
|
421
600
|
}
|
|
422
601
|
if (layout) {
|
|
423
|
-
configureLayoutAnimations(
|
|
602
|
+
configureLayoutAnimations(
|
|
603
|
+
tag,
|
|
604
|
+
LayoutAnimationType.LAYOUT,
|
|
605
|
+
maybeBuild(layout)
|
|
606
|
+
);
|
|
424
607
|
}
|
|
425
608
|
if (entering) {
|
|
426
|
-
configureLayoutAnimations(
|
|
609
|
+
configureLayoutAnimations(
|
|
610
|
+
tag,
|
|
611
|
+
LayoutAnimationType.ENTERING,
|
|
612
|
+
maybeBuild(entering)
|
|
613
|
+
);
|
|
427
614
|
}
|
|
428
615
|
if (exiting) {
|
|
429
|
-
configureLayoutAnimations(
|
|
616
|
+
configureLayoutAnimations(
|
|
617
|
+
tag,
|
|
618
|
+
LayoutAnimationType.EXITING,
|
|
619
|
+
maybeBuild(exiting)
|
|
620
|
+
);
|
|
621
|
+
}
|
|
622
|
+
if (sharedTransitionTag) {
|
|
623
|
+
const sharedElementTransition =
|
|
624
|
+
this.props.sharedTransitionStyle ?? DefaultSharedTransition;
|
|
625
|
+
configureLayoutAnimations(
|
|
626
|
+
tag,
|
|
627
|
+
LayoutAnimationType.SHARED_ELEMENT_TRANSITION,
|
|
628
|
+
maybeBuild(sharedElementTransition),
|
|
629
|
+
sharedTransitionTag
|
|
630
|
+
);
|
|
430
631
|
}
|
|
431
632
|
}
|
|
432
633
|
|
|
@@ -456,6 +657,20 @@ export default function createAnimatedComponent(
|
|
|
456
657
|
};
|
|
457
658
|
}
|
|
458
659
|
return this.initialStyle;
|
|
660
|
+
} else if (hasInlineStyles(style)) {
|
|
661
|
+
if (this._isFirstRender) {
|
|
662
|
+
return getInlinePropsUpdate(style);
|
|
663
|
+
}
|
|
664
|
+
const newStyle: StyleProps = {};
|
|
665
|
+
for (const [key, styleValue] of Object.entries(style)) {
|
|
666
|
+
if (
|
|
667
|
+
!isSharedValue(styleValue) &&
|
|
668
|
+
!(key === 'transform' && isInlineStyleTransform(styleValue))
|
|
669
|
+
) {
|
|
670
|
+
newStyle[key] = styleValue;
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
return newStyle;
|
|
459
674
|
} else {
|
|
460
675
|
return style;
|
|
461
676
|
}
|
|
@@ -486,6 +701,10 @@ export default function createAnimatedComponent(
|
|
|
486
701
|
} else {
|
|
487
702
|
props[key] = dummyListener;
|
|
488
703
|
}
|
|
704
|
+
} else if (isSharedValue(value)) {
|
|
705
|
+
if (this._isFirstRender) {
|
|
706
|
+
props[key] = (value as SharedValue<any>).value;
|
|
707
|
+
}
|
|
489
708
|
} else if (
|
|
490
709
|
key !== 'onGestureHandlerStateChange' ||
|
|
491
710
|
!isChromeDebugger()
|
|
@@ -573,11 +573,12 @@ function HSVtoRGB(h: any, s?: any, v?: any) {
|
|
|
573
573
|
export const hsvToColor = (
|
|
574
574
|
h: number,
|
|
575
575
|
s: number,
|
|
576
|
-
v: number
|
|
576
|
+
v: number,
|
|
577
|
+
a: number
|
|
577
578
|
): number | string => {
|
|
578
579
|
'worklet';
|
|
579
580
|
const { r, g, b } = HSVtoRGB(h, s, v);
|
|
580
|
-
return rgbaColor(r, g, b);
|
|
581
|
+
return rgbaColor(r, g, b, a);
|
|
581
582
|
};
|
|
582
583
|
|
|
583
584
|
export function processColorInitially(
|
|
@@ -634,19 +635,45 @@ export function processColor(color: unknown): number | null | undefined {
|
|
|
634
635
|
|
|
635
636
|
export type ParsedColorArray = [number, number, number, number];
|
|
636
637
|
|
|
637
|
-
export function
|
|
638
|
+
export function convertToRGBA(color: unknown): ParsedColorArray {
|
|
638
639
|
'worklet';
|
|
639
640
|
const processedColor = processColorInitially(color)!; // argb;
|
|
640
641
|
const a = (processedColor >>> 24) / 255;
|
|
641
|
-
const r = (processedColor << 8) >>> 24;
|
|
642
|
-
const g = (processedColor << 16) >>> 24;
|
|
643
|
-
const b = (processedColor << 24) >>> 24;
|
|
644
|
-
|
|
645
|
-
return [h, s, v, a];
|
|
642
|
+
const r = ((processedColor << 8) >>> 24) / 255;
|
|
643
|
+
const g = ((processedColor << 16) >>> 24) / 255;
|
|
644
|
+
const b = ((processedColor << 24) >>> 24) / 255;
|
|
645
|
+
return [r, g, b, a];
|
|
646
646
|
}
|
|
647
647
|
|
|
648
|
-
export function
|
|
648
|
+
export function rgbaArrayToRGBAColor(RGBA: ParsedColorArray): string {
|
|
649
649
|
'worklet';
|
|
650
|
-
|
|
651
|
-
|
|
650
|
+
return `rgba(${Math.round(RGBA[0] * 255)}, ${Math.round(
|
|
651
|
+
RGBA[1] * 255
|
|
652
|
+
)}, ${Math.round(RGBA[2] * 255)}, ${RGBA[3]})`;
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
export function toLinearSpace(
|
|
656
|
+
RGBA: ParsedColorArray,
|
|
657
|
+
gamma = 2.2
|
|
658
|
+
): ParsedColorArray {
|
|
659
|
+
'worklet';
|
|
660
|
+
const res = [];
|
|
661
|
+
for (let i = 0; i < 3; ++i) {
|
|
662
|
+
res.push(Math.pow(RGBA[i], gamma));
|
|
663
|
+
}
|
|
664
|
+
res.push(RGBA[3]);
|
|
665
|
+
return res as ParsedColorArray;
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
export function toGammaSpace(
|
|
669
|
+
RGBA: ParsedColorArray,
|
|
670
|
+
gamma = 2.2
|
|
671
|
+
): ParsedColorArray {
|
|
672
|
+
'worklet';
|
|
673
|
+
const res = [];
|
|
674
|
+
for (let i = 0; i < 3; ++i) {
|
|
675
|
+
res.push(Math.pow(RGBA[i], 1 / gamma));
|
|
676
|
+
}
|
|
677
|
+
res.push(RGBA[3]);
|
|
678
|
+
return res as ParsedColorArray;
|
|
652
679
|
}
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import { NativeModules } from 'react-native';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import {
|
|
3
|
+
ShareableRef,
|
|
4
|
+
ShareableSyncDataHolderRef,
|
|
5
|
+
Value3D,
|
|
6
|
+
ValueRotation,
|
|
7
|
+
} from '../commonTypes';
|
|
8
|
+
import {
|
|
9
|
+
LayoutAnimationFunction,
|
|
10
|
+
LayoutAnimationType,
|
|
11
|
+
} from '../layoutReanimation';
|
|
12
|
+
import { checkVersion } from '../platform-specific/checkVersion';
|
|
5
13
|
|
|
6
14
|
export class NativeReanimated {
|
|
7
15
|
native: boolean;
|
|
@@ -15,38 +23,19 @@ export class NativeReanimated {
|
|
|
15
23
|
this.InnerNativeModule = global.__reanimatedModuleProxy;
|
|
16
24
|
this.native = native;
|
|
17
25
|
if (native) {
|
|
18
|
-
this.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
jsVersion.match(/^\d+\.\d+\.\d+$/) &&
|
|
27
|
-
cppVersion.match(/^\d+\.\d+\.\d+$/)
|
|
28
|
-
) {
|
|
29
|
-
// x.y.z, compare only major and minor, skip patch
|
|
30
|
-
const [jsMajor, jsMinor] = jsVersion.split('.');
|
|
31
|
-
const [cppMajor, cppMinor] = cppVersion.split('.');
|
|
32
|
-
return jsMajor === cppMajor && jsMinor === cppMinor;
|
|
33
|
-
} else {
|
|
34
|
-
// alpha, beta or rc, compare everything
|
|
35
|
-
return jsVersion === cppVersion;
|
|
26
|
+
if (this.InnerNativeModule === undefined) {
|
|
27
|
+
console.error(
|
|
28
|
+
`[Reanimated] The native part of Reanimated doesn't seem to be initialized. This could be caused by\n\
|
|
29
|
+
- not rebuilding the app after installing or upgrading Reanimated\n\
|
|
30
|
+
- trying to run Reanimated on an unsupported platform\n\
|
|
31
|
+
- running in a brownfield app without manually initializing the native library`
|
|
32
|
+
);
|
|
33
|
+
return;
|
|
36
34
|
}
|
|
37
|
-
|
|
38
|
-
if (!ok) {
|
|
39
|
-
console.error(
|
|
40
|
-
`[Reanimated] Mismatch between JavaScript part and native part of Reanimated (${jsVersion} vs. ${cppVersion}). Did you forget to re-build the app after upgrading react-native-reanimated? If you use Expo Go, you must downgrade to ${cppVersion} which is bundled into Expo SDK.`
|
|
41
|
-
);
|
|
42
|
-
// TODO: detect Expo managed workflow
|
|
35
|
+
checkVersion();
|
|
43
36
|
}
|
|
44
37
|
}
|
|
45
38
|
|
|
46
|
-
getTimestamp(): number {
|
|
47
|
-
throw new Error('stub implementation, used on the web only');
|
|
48
|
-
}
|
|
49
|
-
|
|
50
39
|
installCoreFunctions(
|
|
51
40
|
callGuard: <T extends Array<any>, U>(
|
|
52
41
|
fn: (...args: T) => U,
|
|
@@ -60,8 +49,14 @@ export class NativeReanimated {
|
|
|
60
49
|
);
|
|
61
50
|
}
|
|
62
51
|
|
|
63
|
-
makeShareableClone<T>(
|
|
64
|
-
|
|
52
|
+
makeShareableClone<T>(
|
|
53
|
+
value: T,
|
|
54
|
+
shouldPersistRemote: boolean
|
|
55
|
+
): ShareableRef<T> {
|
|
56
|
+
return this.InnerNativeModule.makeShareableClone(
|
|
57
|
+
value,
|
|
58
|
+
shouldPersistRemote
|
|
59
|
+
);
|
|
65
60
|
}
|
|
66
61
|
|
|
67
62
|
makeSynchronizedDataHolder<T>(
|
|
@@ -88,9 +83,15 @@ export class NativeReanimated {
|
|
|
88
83
|
registerSensor<T>(
|
|
89
84
|
sensorType: number,
|
|
90
85
|
interval: number,
|
|
91
|
-
|
|
86
|
+
iosReferenceFrame: number,
|
|
87
|
+
handler: ShareableRef<T> | ((data: Value3D | ValueRotation) => void)
|
|
92
88
|
) {
|
|
93
|
-
return this.InnerNativeModule.registerSensor(
|
|
89
|
+
return this.InnerNativeModule.registerSensor(
|
|
90
|
+
sensorType,
|
|
91
|
+
interval,
|
|
92
|
+
iosReferenceFrame,
|
|
93
|
+
handler
|
|
94
|
+
);
|
|
94
95
|
}
|
|
95
96
|
|
|
96
97
|
unregisterSensor(sensorId: number) {
|
|
@@ -118,10 +119,16 @@ export class NativeReanimated {
|
|
|
118
119
|
|
|
119
120
|
configureLayoutAnimation(
|
|
120
121
|
viewTag: number,
|
|
121
|
-
type:
|
|
122
|
+
type: LayoutAnimationType,
|
|
123
|
+
sharedTransitionTag: string,
|
|
122
124
|
config: ShareableRef<Keyframe | LayoutAnimationFunction>
|
|
123
125
|
) {
|
|
124
|
-
this.InnerNativeModule.configureLayoutAnimation(
|
|
126
|
+
this.InnerNativeModule.configureLayoutAnimation(
|
|
127
|
+
viewTag,
|
|
128
|
+
type,
|
|
129
|
+
sharedTransitionTag,
|
|
130
|
+
config
|
|
131
|
+
);
|
|
125
132
|
}
|
|
126
133
|
|
|
127
134
|
enableLayoutAnimations(flag: boolean): void {
|
|
@@ -132,8 +139,14 @@ export class NativeReanimated {
|
|
|
132
139
|
this.InnerNativeModule.configureProps(uiProps, nativeProps);
|
|
133
140
|
}
|
|
134
141
|
|
|
135
|
-
subscribeForKeyboardEvents(
|
|
136
|
-
|
|
142
|
+
subscribeForKeyboardEvents(
|
|
143
|
+
handler: ShareableRef<number>,
|
|
144
|
+
isStatusBarTranslucent: boolean
|
|
145
|
+
): number {
|
|
146
|
+
return this.InnerNativeModule.subscribeForKeyboardEvents(
|
|
147
|
+
handler,
|
|
148
|
+
isStatusBarTranslucent
|
|
149
|
+
);
|
|
137
150
|
}
|
|
138
151
|
|
|
139
152
|
unsubscribeFromKeyboardEvents(listenerId: number): void {
|
|
@@ -46,7 +46,7 @@ export function setPath<T>(
|
|
|
46
46
|
for (let i = 0; i < keys.length - 1; i++) {
|
|
47
47
|
// creates entry if there isn't one
|
|
48
48
|
currObj = currObj as { [key: string]: NestedObjectValues<T> };
|
|
49
|
-
if (!
|
|
49
|
+
if (!(keys[i] in currObj)) {
|
|
50
50
|
// if next key is a number create an array
|
|
51
51
|
if (typeof keys[i + 1] === 'number') {
|
|
52
52
|
currObj[keys[i]] = [];
|
|
@@ -178,6 +178,13 @@ export function withStyleAnimation(
|
|
|
178
178
|
if (prevAnimation && !prevVal) {
|
|
179
179
|
prevVal = prevAnimation.current;
|
|
180
180
|
}
|
|
181
|
+
if (prevVal === undefined) {
|
|
182
|
+
console.warn(
|
|
183
|
+
`Initial values for animation are missing for property ${currentEntry.path.join(
|
|
184
|
+
'.'
|
|
185
|
+
)}`
|
|
186
|
+
);
|
|
187
|
+
}
|
|
181
188
|
setPath(animation.current, currentEntry.path, prevVal);
|
|
182
189
|
let currentAnimation: AnimationObject;
|
|
183
190
|
if (
|