react-native-reanimated 3.0.0-rc.8 → 3.0.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/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 +122 -121
- package/Common/cpp/NativeModules/NativeReanimatedModule.h +21 -14
- package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +15 -7
- package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.h +8 -4
- package/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.cpp +50 -1
- package/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.h +10 -1
- 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 +11 -63
- package/Common/cpp/SharedItems/Shareables.h +113 -93
- 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 +67 -247
- package/Common/cpp/Tools/RuntimeDecorator.h +2 -3
- package/Common/cpp/Tools/WorkletEventHandler.cpp +3 -2
- package/Common/cpp/Tools/WorkletEventHandler.h +14 -6
- 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 +31 -5
- package/ios/LayoutReanimation/REAAnimationsManager.m +265 -77
- 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 +67 -60
- 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 +232 -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 +18 -35
- 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/component/FlatList.js +19 -3
- package/lib/commonjs/reanimated2/component/FlatList.js.map +1 -1
- package/lib/commonjs/reanimated2/core.js +34 -83
- package/lib/commonjs/reanimated2/core.js.map +1 -1
- package/lib/commonjs/reanimated2/errors.js +66 -0
- package/lib/commonjs/reanimated2/errors.js.map +1 -0
- 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 +89 -16
- package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js +43 -50
- 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 +196 -0
- package/lib/commonjs/reanimated2/initializers.js.map +1 -0
- 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 +101 -16
- 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 +4 -9
- 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 +16 -12
- 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 +45 -0
- 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 +38 -11
- package/lib/commonjs/reanimated2/shareables.js.map +1 -1
- package/lib/commonjs/reanimated2/threads.js +114 -4
- 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 +229 -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 +18 -34
- 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/component/FlatList.js +18 -4
- package/lib/module/reanimated2/component/FlatList.js.map +1 -1
- package/lib/module/reanimated2/core.js +30 -76
- package/lib/module/reanimated2/core.js.map +1 -1
- package/lib/module/reanimated2/errors.js +58 -0
- package/lib/module/reanimated2/errors.js.map +1 -0
- 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 +88 -13
- package/lib/module/reanimated2/hook/useAnimatedSensor.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedStyle.js +45 -52
- 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 +182 -0
- package/lib/module/reanimated2/initializers.js.map +1 -0
- 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 +101 -16
- 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 +4 -9
- 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 +15 -10
- 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 +45 -0
- 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 +38 -9
- package/lib/module/reanimated2/shareables.js.map +1 -1
- package/lib/module/reanimated2/threads.js +105 -4
- 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/package.json +9 -8
- package/{plugin.js → plugin/index.js} +173 -228
- package/react-native-reanimated.d.ts +57 -10
- package/scripts/reanimated_utils.rb +15 -2
- package/src/createAnimatedComponent.tsx +238 -28
- package/src/reanimated2/Colors.ts +38 -11
- package/src/reanimated2/NativeReanimated/NativeReanimated.ts +63 -41
- 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/component/FlatList.tsx +30 -5
- package/src/reanimated2/core.ts +45 -75
- package/src/reanimated2/errors.ts +57 -0
- package/src/reanimated2/frameCallback/FrameCallbackRegistryUI.ts +2 -2
- package/src/reanimated2/globals.d.ts +34 -18
- 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 +88 -11
- package/src/reanimated2/hook/useAnimatedStyle.ts +43 -45
- 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 +184 -0
- package/src/reanimated2/interpolateColor.ts +104 -20
- package/src/reanimated2/jestUtils.ts +1 -1
- package/src/reanimated2/js-reanimated/JSReanimated.ts +105 -18
- 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 +4 -8
- 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 +17 -12
- 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 +128 -0
- 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 +47 -11
- package/src/reanimated2/threads.ts +103 -1
- 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
|
@@ -114,7 +114,8 @@ declare module 'react-native-reanimated' {
|
|
|
114
114
|
export type Adaptable<T> =
|
|
115
115
|
| T
|
|
116
116
|
| AnimatedNode<T>
|
|
117
|
-
| ReadonlyArray<T | AnimatedNode<T> | ReadonlyArray<T | AnimatedNode<T
|
|
117
|
+
| ReadonlyArray<T | AnimatedNode<T> | ReadonlyArray<T | AnimatedNode<T>>>
|
|
118
|
+
| SharedValue<T>;
|
|
118
119
|
type BinaryOperator<T = number> = (
|
|
119
120
|
left: Adaptable<number>,
|
|
120
121
|
right: Adaptable<number>
|
|
@@ -150,7 +151,8 @@ declare module 'react-native-reanimated' {
|
|
|
150
151
|
| AnimatedNode<
|
|
151
152
|
// allow `number` where `string` normally is to support colors
|
|
152
153
|
S[K] extends ColorValue | undefined ? S[K] | number : S[K]
|
|
153
|
-
|
|
154
|
+
>
|
|
155
|
+
| SharedValue<AnimatableValue>;
|
|
154
156
|
};
|
|
155
157
|
|
|
156
158
|
export type StylesOrDefault<T> = 'style' extends keyof T
|
|
@@ -158,7 +160,7 @@ declare module 'react-native-reanimated' {
|
|
|
158
160
|
: Record<string, unknown>;
|
|
159
161
|
|
|
160
162
|
export type AnimateProps<P extends object> = {
|
|
161
|
-
[K in keyof Omit<P, 'style'>]: P[K] | AnimatedNode<P[K]>;
|
|
163
|
+
[K in keyof Omit<P, 'style'>]: P[K] | AnimatedNode<P[K]> | SharedValue<P[K]>;
|
|
162
164
|
} & {
|
|
163
165
|
style?: StyleProp<AnimateStyle<StylesOrDefault<P>>>;
|
|
164
166
|
} & {
|
|
@@ -177,6 +179,8 @@ declare module 'react-native-reanimated' {
|
|
|
177
179
|
| typeof BaseAnimationBuilder
|
|
178
180
|
| EntryExitAnimationFunction
|
|
179
181
|
| Keyframe;
|
|
182
|
+
sharedTransitionTag?: string;
|
|
183
|
+
sharedTransitionStyle?: ILayoutAnimationBuilder;
|
|
180
184
|
};
|
|
181
185
|
|
|
182
186
|
export interface PhysicsAnimationState extends AnimationState {
|
|
@@ -278,8 +282,12 @@ declare module 'react-native-reanimated' {
|
|
|
278
282
|
export interface ScrollView extends ReactNativeScrollView {}
|
|
279
283
|
|
|
280
284
|
export class Code extends Component<CodeProps> {}
|
|
281
|
-
export
|
|
282
|
-
itemLayoutAnimation
|
|
285
|
+
export interface FlatListPropsWithLayout<T> extends FlatListProps<T> {
|
|
286
|
+
itemLayoutAnimation?: ILayoutAnimationBuilder;
|
|
287
|
+
}
|
|
288
|
+
export class FlatList<T> extends Component<
|
|
289
|
+
AnimateProps<FlatListPropsWithLayout<T>>
|
|
290
|
+
> {
|
|
283
291
|
getNode(): ReactNativeFlatList;
|
|
284
292
|
}
|
|
285
293
|
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
@@ -496,14 +504,25 @@ declare module 'react-native-reanimated' {
|
|
|
496
504
|
ROTATION = 5,
|
|
497
505
|
}
|
|
498
506
|
|
|
499
|
-
export
|
|
507
|
+
export enum IOSReferenceFrame {
|
|
508
|
+
XArbitraryZVertical = 0,
|
|
509
|
+
XArbitraryCorrectedZVertical = 1,
|
|
510
|
+
XMagneticNorthZVertical = 2,
|
|
511
|
+
XTrueNorthZVertical = 3,
|
|
512
|
+
Auto = 4,
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
export type SensorConfig = Partial<{
|
|
500
516
|
interval: number | 'auto';
|
|
501
|
-
|
|
517
|
+
adjustToInterfaceOrientation: boolean;
|
|
518
|
+
iosReferenceFrame: IOSReferenceFrame;
|
|
519
|
+
}>;
|
|
502
520
|
|
|
503
521
|
export type Value3D = {
|
|
504
522
|
x: number;
|
|
505
523
|
y: number;
|
|
506
524
|
z: number;
|
|
525
|
+
interfaceOrientation: InterfaceOrientation;
|
|
507
526
|
};
|
|
508
527
|
|
|
509
528
|
export type SensorValue3D = SharedValue<Value3D>;
|
|
@@ -516,6 +535,7 @@ declare module 'react-native-reanimated' {
|
|
|
516
535
|
yaw: number;
|
|
517
536
|
pitch: number;
|
|
518
537
|
roll: number;
|
|
538
|
+
interfaceOrientation: InterfaceOrientation;
|
|
519
539
|
};
|
|
520
540
|
|
|
521
541
|
export type SensorValueRotation = SharedValue<ValueRotation>;
|
|
@@ -566,7 +586,14 @@ declare module 'react-native-reanimated' {
|
|
|
566
586
|
height: SharedValue<number>;
|
|
567
587
|
state: SharedValue<KeyboardState>;
|
|
568
588
|
};
|
|
569
|
-
|
|
589
|
+
|
|
590
|
+
export interface AnimatedKeyboardOptions {
|
|
591
|
+
isStatusBarTranslucentAndroid?: boolean;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
export function useAnimatedKeyboard(
|
|
595
|
+
options?: AnimatedKeyboardOptions
|
|
596
|
+
): AnimatedKeyboardInfo;
|
|
570
597
|
|
|
571
598
|
export function useScrollViewOffset(
|
|
572
599
|
aref: RefObject<Animated.ScrollView>
|
|
@@ -715,11 +742,19 @@ declare module 'react-native-reanimated' {
|
|
|
715
742
|
|
|
716
743
|
export function processColor(color: number | string): number;
|
|
717
744
|
|
|
745
|
+
export type InterpolationOptions = {
|
|
746
|
+
gamma?: number;
|
|
747
|
+
useCorrectedHSVInterpolation?: boolean;
|
|
748
|
+
};
|
|
749
|
+
|
|
750
|
+
export function isColor(value: unknown): boolean;
|
|
751
|
+
|
|
718
752
|
export function interpolateColor<T extends string | number>(
|
|
719
753
|
value: number,
|
|
720
754
|
inputRange: readonly number[],
|
|
721
755
|
outputRange: readonly T[],
|
|
722
|
-
colorSpace?: 'RGB' | 'HSV'
|
|
756
|
+
colorSpace?: 'RGB' | 'HSV',
|
|
757
|
+
options?: InterpolationOptions
|
|
723
758
|
): T;
|
|
724
759
|
|
|
725
760
|
export enum ColorSpace {
|
|
@@ -750,7 +785,8 @@ declare module 'react-native-reanimated' {
|
|
|
750
785
|
export function useInterpolateConfig(
|
|
751
786
|
inputRange: readonly number[],
|
|
752
787
|
outputRange: readonly (string | number)[],
|
|
753
|
-
colorSpace?: ColorSpace
|
|
788
|
+
colorSpace?: ColorSpace,
|
|
789
|
+
options?: InterpolationOptions
|
|
754
790
|
): SharedValue<InterpolateConfig>;
|
|
755
791
|
|
|
756
792
|
export function interpolateSharableColor(
|
|
@@ -1238,4 +1274,15 @@ declare module 'react-native-reanimated' {
|
|
|
1238
1274
|
export const useValue: typeof Animated.useValue;
|
|
1239
1275
|
export const ReverseAnimation: typeof Animated.ReverseAnimation;
|
|
1240
1276
|
export function enableLayoutAnimations(flag: boolean): void;
|
|
1277
|
+
|
|
1278
|
+
type AnimationFactoryType = (values: LayoutAnimationsValues) => StyleProps;
|
|
1279
|
+
|
|
1280
|
+
export class SharedTransition implements ILayoutAnimationBuilder {
|
|
1281
|
+
animationFactory: AnimationFactoryType | null = null;
|
|
1282
|
+
static createInstance(): SharedTransition;
|
|
1283
|
+
static custom(animationFactory: AnimationFactoryType): SharedTransition;
|
|
1284
|
+
custom(animationFactory: AnimationFactoryType): SharedTransition;
|
|
1285
|
+
static build(): LayoutAnimationFunction;
|
|
1286
|
+
build(): LayoutAnimationFunction;
|
|
1287
|
+
}
|
|
1241
1288
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
def try_to_parse_react_native_package_json(node_modules_dir)
|
|
2
2
|
react_native_package_json_path = File.join(node_modules_dir, 'react-native/package.json')
|
|
3
|
-
if !File.
|
|
3
|
+
if !File.exist?(react_native_package_json_path)
|
|
4
4
|
return nil
|
|
5
5
|
end
|
|
6
6
|
return JSON.parse(File.read(react_native_package_json_path))
|
|
@@ -34,6 +34,9 @@ def find_config()
|
|
|
34
34
|
result[:is_tvos_target] = react_native_json['name'] == 'react-native-tvos'
|
|
35
35
|
result[:react_native_version] = react_native_json['version']
|
|
36
36
|
result[:react_native_minor_version] = react_native_json['version'].split('.')[1].to_i
|
|
37
|
+
if result[:react_native_minor_version] == 0 # nightly
|
|
38
|
+
result[:react_native_minor_version] = 1000
|
|
39
|
+
end
|
|
37
40
|
result[:react_native_node_modules_dir] = File.expand_path(react_native_node_modules_dir)
|
|
38
41
|
result[:reanimated_node_modules_dir] = File.expand_path(File.join(__dir__, '..', '..'))
|
|
39
42
|
|
|
@@ -65,7 +68,7 @@ def assert_no_multiple_instances(react_native_info)
|
|
|
65
68
|
location['/package.json'] = ''
|
|
66
69
|
parsed_location += "- " + location + "\n"
|
|
67
70
|
end
|
|
68
|
-
raise "[react-native-reanimated] Multiple versions of Reanimated were detected. Only one instance of react-native-reanimated can be installed in a project. You need to resolve the conflict manually. Check out the documentation: https://docs.swmansion.com/react-native-reanimated/docs/
|
|
71
|
+
raise "[react-native-reanimated] Multiple versions of Reanimated were detected. Only one instance of react-native-reanimated can be installed in a project. You need to resolve the conflict manually. Check out the documentation: https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/troubleshooting/#multiple-versions-of-reanimated-were-detected \n\nConflict between: \n" + parsed_location
|
|
69
72
|
end
|
|
70
73
|
end
|
|
71
74
|
|
|
@@ -76,3 +79,13 @@ def assert_no_reanimated2_with_new_architecture(reanimated_package_json)
|
|
|
76
79
|
raise "[react-native-reanimated] Reanimated 2.x does not support Fabric. Please upgrade to 3.x to use Reanimated with the New Architecture. For details, see https://blog.swmansion.com/announcing-reanimated-3-16167428c5f7"
|
|
77
80
|
end
|
|
78
81
|
end
|
|
82
|
+
|
|
83
|
+
def assert_latest_react_native_with_new_architecture(config, reanimated_package_json)
|
|
84
|
+
reanimated_version = reanimated_package_json['version']
|
|
85
|
+
reanimated_major_version = reanimated_version.split('.')[0].to_i
|
|
86
|
+
react_native_minor_version = config[:react_native_minor_version]
|
|
87
|
+
fabric_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'
|
|
88
|
+
if fabric_enabled && reanimated_major_version == 3 && react_native_minor_version < 71
|
|
89
|
+
raise "[react-native-reanimated] Reanimated " + reanimated_version + " supports the New Architecture only on the latest minor release of React Native. Please upgrade to React Native 0.71.0+ or downgrade to an older version of Reanimated v3"
|
|
90
|
+
end
|
|
91
|
+
end
|
|
@@ -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,78 @@ const has = <K extends string>(
|
|
|
108
115
|
return false;
|
|
109
116
|
};
|
|
110
117
|
|
|
118
|
+
function isInlineStyleTransform(transform: any): boolean {
|
|
119
|
+
return transform.some((t: Record<string, any>) => hasInlineStyles(t));
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function hasInlineStyles(style: StyleProps): boolean {
|
|
123
|
+
return Object.keys(style).some((key) => {
|
|
124
|
+
const styleValue = style[key];
|
|
125
|
+
return (
|
|
126
|
+
isSharedValue(styleValue) ||
|
|
127
|
+
(key === 'transform' && isInlineStyleTransform(styleValue))
|
|
128
|
+
);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function extractSharedValuesMapFromProps(
|
|
133
|
+
props: AnimatedComponentProps<InitialComponentProps>
|
|
134
|
+
): Record<string, any> {
|
|
135
|
+
const inlineProps: Record<string, any> = {};
|
|
136
|
+
|
|
137
|
+
for (const key in props) {
|
|
138
|
+
const value = props[key];
|
|
139
|
+
if (key === 'style') {
|
|
140
|
+
const styles = flattenArray<StyleProps>(props.style ?? []);
|
|
141
|
+
styles.forEach((style) => {
|
|
142
|
+
for (const [key, styleValue] of Object.entries(style)) {
|
|
143
|
+
if (isSharedValue(styleValue)) {
|
|
144
|
+
inlineProps[key] = styleValue;
|
|
145
|
+
} else if (
|
|
146
|
+
key === 'transform' &&
|
|
147
|
+
isInlineStyleTransform(styleValue)
|
|
148
|
+
) {
|
|
149
|
+
inlineProps[key] = styleValue;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
} else if (isSharedValue(value)) {
|
|
154
|
+
inlineProps[key] = value;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return inlineProps;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function inlinePropsHasChanged(styles1: StyleProps, styles2: StyleProps) {
|
|
162
|
+
if (Object.keys(styles1).length !== Object.keys(styles2).length) {
|
|
163
|
+
return true;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
for (const key of Object.keys(styles1)) {
|
|
167
|
+
if (styles1[key] !== styles2[key]) return true;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function getInlinePropsUpdate(inlineProps: Record<string, any>) {
|
|
174
|
+
'worklet';
|
|
175
|
+
const update: Record<string, any> = {};
|
|
176
|
+
for (const [key, styleValue] of Object.entries(inlineProps)) {
|
|
177
|
+
if (key === 'transform') {
|
|
178
|
+
update[key] = styleValue.map((transform: Record<string, any>) => {
|
|
179
|
+
return getInlinePropsUpdate(transform);
|
|
180
|
+
});
|
|
181
|
+
} else if (isSharedValue(styleValue)) {
|
|
182
|
+
update[key] = styleValue.value;
|
|
183
|
+
} else {
|
|
184
|
+
update[key] = styleValue;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return update;
|
|
188
|
+
}
|
|
189
|
+
|
|
111
190
|
interface AnimatedProps extends Record<string, unknown> {
|
|
112
191
|
viewDescriptors?: ViewDescriptorsSet;
|
|
113
192
|
viewsRef?: ViewRefSet<unknown>;
|
|
@@ -133,6 +212,8 @@ export type AnimatedComponentProps<P extends Record<string, unknown>> = P & {
|
|
|
133
212
|
| typeof BaseAnimationBuilder
|
|
134
213
|
| EntryExitAnimationFunction
|
|
135
214
|
| Keyframe;
|
|
215
|
+
sharedTransitionTag?: string;
|
|
216
|
+
sharedTransitionStyle?: ILayoutAnimationBuilder;
|
|
136
217
|
};
|
|
137
218
|
|
|
138
219
|
type Options<P> = {
|
|
@@ -170,6 +251,9 @@ export default function createAnimatedComponent(
|
|
|
170
251
|
animatedStyle: { value: StyleProps } = { value: {} };
|
|
171
252
|
initialStyle = {};
|
|
172
253
|
_component: ComponentRef | null = null;
|
|
254
|
+
_inlinePropsViewDescriptors: ViewDescriptorsSet | null = null;
|
|
255
|
+
_inlinePropsMapperId: number | null = null;
|
|
256
|
+
_inlineProps: StyleProps = {};
|
|
173
257
|
static displayName: string;
|
|
174
258
|
|
|
175
259
|
constructor(props: AnimatedComponentProps<InitialComponentProps>) {
|
|
@@ -182,15 +266,27 @@ export default function createAnimatedComponent(
|
|
|
182
266
|
componentWillUnmount() {
|
|
183
267
|
this._detachNativeEvents();
|
|
184
268
|
this._detachStyles();
|
|
269
|
+
this._detachInlineProps();
|
|
185
270
|
}
|
|
186
271
|
|
|
187
272
|
componentDidMount() {
|
|
188
273
|
this._attachNativeEvents();
|
|
189
274
|
this._attachAnimatedStyles();
|
|
275
|
+
this._attachInlineProps();
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
_getEventViewRef() {
|
|
279
|
+
// Make sure to get the scrollable node for components that implement
|
|
280
|
+
// `ScrollResponder.Mixin`.
|
|
281
|
+
return this._component?.getScrollableNode
|
|
282
|
+
? this._component.getScrollableNode()
|
|
283
|
+
: this._component;
|
|
190
284
|
}
|
|
191
285
|
|
|
192
286
|
_attachNativeEvents() {
|
|
193
|
-
const
|
|
287
|
+
const node = this._getEventViewRef();
|
|
288
|
+
const viewTag = findNodeHandle(options?.setNativeProps ? this : node);
|
|
289
|
+
|
|
194
290
|
for (const key in this.props) {
|
|
195
291
|
const prop = this.props[key];
|
|
196
292
|
if (
|
|
@@ -229,10 +325,10 @@ export default function createAnimatedComponent(
|
|
|
229
325
|
this.props.animatedProps.viewDescriptors.remove(this._viewTag);
|
|
230
326
|
}
|
|
231
327
|
if (global._IS_FABRIC) {
|
|
232
|
-
const
|
|
328
|
+
const viewTag = this._viewTag;
|
|
233
329
|
runOnUI(() => {
|
|
234
330
|
'worklet';
|
|
235
|
-
_removeShadowNodeFromRegistry(
|
|
331
|
+
_removeShadowNodeFromRegistry(viewTag);
|
|
236
332
|
})();
|
|
237
333
|
}
|
|
238
334
|
}
|
|
@@ -289,23 +385,16 @@ export default function createAnimatedComponent(
|
|
|
289
385
|
}
|
|
290
386
|
}
|
|
291
387
|
|
|
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
|
-
|
|
388
|
+
_getViewInfo() {
|
|
302
389
|
let viewTag: number | null;
|
|
303
390
|
let viewName: string | null;
|
|
304
391
|
let shadowNodeWrapper: ShadowNodeWrapper | null = null;
|
|
392
|
+
let viewConfig;
|
|
305
393
|
if (Platform.OS === 'web') {
|
|
306
394
|
viewTag = findNodeHandle(this);
|
|
307
395
|
viewName = null;
|
|
308
396
|
shadowNodeWrapper = null;
|
|
397
|
+
viewConfig = null;
|
|
309
398
|
} else {
|
|
310
399
|
// 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
400
|
const hostInstance = RNRenderer.findHostInstance_DEPRECATED(this);
|
|
@@ -321,19 +410,36 @@ export default function createAnimatedComponent(
|
|
|
321
410
|
* The name we're looking for is in the field named uiViewClassName.
|
|
322
411
|
*/
|
|
323
412
|
viewName = hostInstance?.viewConfig?.uiViewClassName;
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
this.props.animatedProps?.viewDescriptors || styles.length;
|
|
327
|
-
if (hasReanimated2Props && hostInstance?.viewConfig) {
|
|
328
|
-
adaptViewConfig(hostInstance.viewConfig);
|
|
329
|
-
}
|
|
413
|
+
|
|
414
|
+
viewConfig = hostInstance?.viewConfig;
|
|
330
415
|
|
|
331
416
|
if (global._IS_FABRIC) {
|
|
332
|
-
shadowNodeWrapper =
|
|
333
|
-
getShadowNodeWrapperFromRef(this)
|
|
334
|
-
);
|
|
417
|
+
shadowNodeWrapper = getShadowNodeWrapperFromRef(this);
|
|
335
418
|
}
|
|
336
419
|
}
|
|
420
|
+
return { viewTag, viewName, shadowNodeWrapper, viewConfig };
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
_attachAnimatedStyles() {
|
|
424
|
+
const styles = this.props.style
|
|
425
|
+
? onlyAnimatedStyles(flattenArray<StyleProps>(this.props.style))
|
|
426
|
+
: [];
|
|
427
|
+
const prevStyles = this._styles;
|
|
428
|
+
this._styles = styles;
|
|
429
|
+
|
|
430
|
+
const prevAnimatedProps = this._animatedProps;
|
|
431
|
+
this._animatedProps = this.props.animatedProps;
|
|
432
|
+
|
|
433
|
+
const { viewTag, viewName, shadowNodeWrapper, viewConfig } =
|
|
434
|
+
this._getViewInfo();
|
|
435
|
+
|
|
436
|
+
// update UI props whitelist for this view
|
|
437
|
+
const hasReanimated2Props =
|
|
438
|
+
this.props.animatedProps?.viewDescriptors || styles.length;
|
|
439
|
+
if (hasReanimated2Props && viewConfig) {
|
|
440
|
+
adaptViewConfig(viewConfig);
|
|
441
|
+
}
|
|
442
|
+
|
|
337
443
|
this._viewTag = viewTag as number;
|
|
338
444
|
|
|
339
445
|
// remove old styles
|
|
@@ -399,11 +505,72 @@ export default function createAnimatedComponent(
|
|
|
399
505
|
}
|
|
400
506
|
}
|
|
401
507
|
|
|
508
|
+
_attachInlineProps() {
|
|
509
|
+
const newInlineProps: Record<string, any> =
|
|
510
|
+
extractSharedValuesMapFromProps(this.props);
|
|
511
|
+
const hasChanged = inlinePropsHasChanged(
|
|
512
|
+
newInlineProps,
|
|
513
|
+
this._inlineProps
|
|
514
|
+
);
|
|
515
|
+
|
|
516
|
+
if (hasChanged) {
|
|
517
|
+
if (!this._inlinePropsViewDescriptors) {
|
|
518
|
+
this._inlinePropsViewDescriptors = makeViewDescriptorsSet();
|
|
519
|
+
|
|
520
|
+
const { viewTag, viewName, shadowNodeWrapper, viewConfig } =
|
|
521
|
+
this._getViewInfo();
|
|
522
|
+
|
|
523
|
+
if (Object.keys(newInlineProps).length && viewConfig) {
|
|
524
|
+
adaptViewConfig(viewConfig);
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
this._inlinePropsViewDescriptors.add({
|
|
528
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
529
|
+
tag: viewTag!,
|
|
530
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
531
|
+
name: viewName!,
|
|
532
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
533
|
+
shadowNodeWrapper: shadowNodeWrapper!,
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
const sharableViewDescriptors =
|
|
537
|
+
this._inlinePropsViewDescriptors.sharableViewDescriptors;
|
|
538
|
+
|
|
539
|
+
const maybeViewRef = NativeReanimatedModule.native
|
|
540
|
+
? undefined
|
|
541
|
+
: ({ items: new Set([this]) } as ViewRefSet<any>); // see makeViewsRefSet
|
|
542
|
+
|
|
543
|
+
const updaterFunction = () => {
|
|
544
|
+
'worklet';
|
|
545
|
+
const update = getInlinePropsUpdate(newInlineProps);
|
|
546
|
+
updateProps(sharableViewDescriptors, update, maybeViewRef);
|
|
547
|
+
};
|
|
548
|
+
this._inlineProps = newInlineProps;
|
|
549
|
+
if (this._inlinePropsMapperId) {
|
|
550
|
+
stopMapper(this._inlinePropsMapperId);
|
|
551
|
+
}
|
|
552
|
+
this._inlinePropsMapperId = null;
|
|
553
|
+
if (Object.keys(newInlineProps).length) {
|
|
554
|
+
this._inlinePropsMapperId = startMapper(
|
|
555
|
+
updaterFunction,
|
|
556
|
+
Object.values(newInlineProps)
|
|
557
|
+
);
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
_detachInlineProps() {
|
|
563
|
+
if (this._inlinePropsMapperId) {
|
|
564
|
+
stopMapper(this._inlinePropsMapperId);
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
|
|
402
568
|
componentDidUpdate(
|
|
403
569
|
prevProps: AnimatedComponentProps<InitialComponentProps>
|
|
404
570
|
) {
|
|
405
571
|
this._reattachNativeEvents(prevProps);
|
|
406
572
|
this._attachAnimatedStyles();
|
|
573
|
+
this._attachInlineProps();
|
|
407
574
|
}
|
|
408
575
|
|
|
409
576
|
_setComponentRef = setAndForwardRef<Component>({
|
|
@@ -414,19 +581,44 @@ export default function createAnimatedComponent(
|
|
|
414
581
|
setLocalRef: (ref) => {
|
|
415
582
|
// TODO update config
|
|
416
583
|
const tag = findNodeHandle(ref);
|
|
417
|
-
const { layout, entering, exiting } = this.props;
|
|
418
|
-
if (
|
|
584
|
+
const { layout, entering, exiting, sharedTransitionTag } = this.props;
|
|
585
|
+
if (
|
|
586
|
+
(layout || entering || exiting || sharedTransitionTag) &&
|
|
587
|
+
tag != null
|
|
588
|
+
) {
|
|
419
589
|
if (!shouldBeUseWeb()) {
|
|
420
590
|
enableLayoutAnimations(true, false);
|
|
421
591
|
}
|
|
422
592
|
if (layout) {
|
|
423
|
-
configureLayoutAnimations(
|
|
593
|
+
configureLayoutAnimations(
|
|
594
|
+
tag,
|
|
595
|
+
LayoutAnimationType.LAYOUT,
|
|
596
|
+
maybeBuild(layout)
|
|
597
|
+
);
|
|
424
598
|
}
|
|
425
599
|
if (entering) {
|
|
426
|
-
configureLayoutAnimations(
|
|
600
|
+
configureLayoutAnimations(
|
|
601
|
+
tag,
|
|
602
|
+
LayoutAnimationType.ENTERING,
|
|
603
|
+
maybeBuild(entering)
|
|
604
|
+
);
|
|
427
605
|
}
|
|
428
606
|
if (exiting) {
|
|
429
|
-
configureLayoutAnimations(
|
|
607
|
+
configureLayoutAnimations(
|
|
608
|
+
tag,
|
|
609
|
+
LayoutAnimationType.EXITING,
|
|
610
|
+
maybeBuild(exiting)
|
|
611
|
+
);
|
|
612
|
+
}
|
|
613
|
+
if (sharedTransitionTag) {
|
|
614
|
+
const sharedElementTransition =
|
|
615
|
+
this.props.sharedTransitionStyle ?? DefaultSharedTransition;
|
|
616
|
+
configureLayoutAnimations(
|
|
617
|
+
tag,
|
|
618
|
+
LayoutAnimationType.SHARED_ELEMENT_TRANSITION,
|
|
619
|
+
maybeBuild(sharedElementTransition),
|
|
620
|
+
sharedTransitionTag
|
|
621
|
+
);
|
|
430
622
|
}
|
|
431
623
|
}
|
|
432
624
|
|
|
@@ -456,6 +648,20 @@ export default function createAnimatedComponent(
|
|
|
456
648
|
};
|
|
457
649
|
}
|
|
458
650
|
return this.initialStyle;
|
|
651
|
+
} else if (hasInlineStyles(style)) {
|
|
652
|
+
if (this._isFirstRender) {
|
|
653
|
+
return getInlinePropsUpdate(style);
|
|
654
|
+
}
|
|
655
|
+
const newStyle: StyleProps = {};
|
|
656
|
+
for (const [key, styleValue] of Object.entries(style)) {
|
|
657
|
+
if (
|
|
658
|
+
!isSharedValue(styleValue) &&
|
|
659
|
+
!(key === 'transform' && isInlineStyleTransform(styleValue))
|
|
660
|
+
) {
|
|
661
|
+
newStyle[key] = styleValue;
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
return newStyle;
|
|
459
665
|
} else {
|
|
460
666
|
return style;
|
|
461
667
|
}
|
|
@@ -486,6 +692,10 @@ export default function createAnimatedComponent(
|
|
|
486
692
|
} else {
|
|
487
693
|
props[key] = dummyListener;
|
|
488
694
|
}
|
|
695
|
+
} else if (isSharedValue(value)) {
|
|
696
|
+
if (this._isFirstRender) {
|
|
697
|
+
props[key] = (value as SharedValue<any>).value;
|
|
698
|
+
}
|
|
489
699
|
} else if (
|
|
490
700
|
key !== 'onGestureHandlerStateChange' ||
|
|
491
701
|
!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
|
}
|