react-native-reanimated 3.0.0-rc.9 → 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 +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/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 +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 +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 +89 -16
- 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 +17 -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 -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 +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 +88 -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 +15 -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 -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 +10 -10
- package/{plugin.js → plugin/index.js} +128 -249
- 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 +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 +88 -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 +17 -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 +24 -1
- 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 -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
|
@@ -14,11 +14,7 @@ AnimatedSensorModule::AnimatedSensorModule(
|
|
|
14
14
|
platformDepMethodsHolder.unregisterSensor) {}
|
|
15
15
|
|
|
16
16
|
AnimatedSensorModule::~AnimatedSensorModule() {
|
|
17
|
-
|
|
18
|
-
// unmounting
|
|
19
|
-
for (auto sensorId : sensorsIds_) {
|
|
20
|
-
platformUnregisterSensorFunction_(sensorId);
|
|
21
|
-
}
|
|
17
|
+
assert(sensorsIds_.empty());
|
|
22
18
|
}
|
|
23
19
|
|
|
24
20
|
jsi::Value AnimatedSensorModule::registerSensor(
|
|
@@ -26,19 +22,32 @@ jsi::Value AnimatedSensorModule::registerSensor(
|
|
|
26
22
|
const std::shared_ptr<JSRuntimeHelper> &runtimeHelper,
|
|
27
23
|
const jsi::Value &sensorTypeValue,
|
|
28
24
|
const jsi::Value &interval,
|
|
25
|
+
const jsi::Value &iosReferenceFrame,
|
|
29
26
|
const jsi::Value &sensorDataHandler) {
|
|
30
27
|
SensorType sensorType = static_cast<SensorType>(sensorTypeValue.asNumber());
|
|
31
28
|
|
|
32
29
|
auto shareableHandler = extractShareableOrThrow(rt, sensorDataHandler);
|
|
33
|
-
auto uiRuntime = runtimeHelper->uiRuntime();
|
|
34
30
|
|
|
35
31
|
int sensorId = platformRegisterSensorFunction_(
|
|
36
|
-
sensorType,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
32
|
+
sensorType,
|
|
33
|
+
interval.asNumber(),
|
|
34
|
+
iosReferenceFrame.asNumber(),
|
|
35
|
+
[sensorType,
|
|
36
|
+
shareableHandler,
|
|
37
|
+
weakRuntimeHelper = std::weak_ptr<JSRuntimeHelper>(runtimeHelper)](
|
|
38
|
+
double newValues[], int orientationDegrees) {
|
|
39
|
+
auto runtimeHelper = weakRuntimeHelper.lock();
|
|
40
|
+
if (runtimeHelper == nullptr || runtimeHelper->uiRuntimeDestroyed) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
auto &rt = *runtimeHelper->uiRuntime();
|
|
45
|
+
auto handler = shareableHandler->getJSValue(rt);
|
|
40
46
|
if (sensorType == SensorType::ROTATION_VECTOR) {
|
|
41
47
|
jsi::Object value(rt);
|
|
48
|
+
// TODO: timestamp should be provided by the platform implementation
|
|
49
|
+
// such that the native side has a chance of providing a true event
|
|
50
|
+
// timestamp
|
|
42
51
|
value.setProperty(rt, "qx", newValues[0]);
|
|
43
52
|
value.setProperty(rt, "qy", newValues[1]);
|
|
44
53
|
value.setProperty(rt, "qz", newValues[2]);
|
|
@@ -46,13 +55,15 @@ jsi::Value AnimatedSensorModule::registerSensor(
|
|
|
46
55
|
value.setProperty(rt, "yaw", newValues[4]);
|
|
47
56
|
value.setProperty(rt, "pitch", newValues[5]);
|
|
48
57
|
value.setProperty(rt, "roll", newValues[6]);
|
|
49
|
-
|
|
58
|
+
value.setProperty(rt, "interfaceOrientation", orientationDegrees);
|
|
59
|
+
runtimeHelper->runOnUIGuarded(handler, value);
|
|
50
60
|
} else {
|
|
51
61
|
jsi::Object value(rt);
|
|
52
62
|
value.setProperty(rt, "x", newValues[0]);
|
|
53
63
|
value.setProperty(rt, "y", newValues[1]);
|
|
54
64
|
value.setProperty(rt, "z", newValues[2]);
|
|
55
|
-
|
|
65
|
+
value.setProperty(rt, "interfaceOrientation", orientationDegrees);
|
|
66
|
+
runtimeHelper->runOnUIGuarded(handler, value);
|
|
56
67
|
}
|
|
57
68
|
});
|
|
58
69
|
if (sensorId != -1) {
|
|
@@ -67,4 +78,11 @@ void AnimatedSensorModule::unregisterSensor(const jsi::Value &sensorId) {
|
|
|
67
78
|
platformUnregisterSensorFunction_(sensorId.asNumber());
|
|
68
79
|
}
|
|
69
80
|
|
|
81
|
+
void AnimatedSensorModule::unregisterAllSensors() {
|
|
82
|
+
for (auto sensorId : sensorsIds_) {
|
|
83
|
+
platformUnregisterSensorFunction_(sensorId);
|
|
84
|
+
}
|
|
85
|
+
sensorsIds_.clear();
|
|
86
|
+
}
|
|
87
|
+
|
|
70
88
|
} // namespace reanimated
|
|
@@ -35,8 +35,10 @@ class AnimatedSensorModule {
|
|
|
35
35
|
const std::shared_ptr<JSRuntimeHelper> &runtimeHelper,
|
|
36
36
|
const jsi::Value &sensorType,
|
|
37
37
|
const jsi::Value &interval,
|
|
38
|
+
const jsi::Value &iosReferenceFrame,
|
|
38
39
|
const jsi::Value &sensorDataContainer);
|
|
39
40
|
void unregisterSensor(const jsi::Value &sensorId);
|
|
41
|
+
void unregisterAllSensors();
|
|
40
42
|
};
|
|
41
43
|
|
|
42
44
|
} // namespace reanimated
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
2
2
|
|
|
3
|
-
#if REACT_NATIVE_MINOR_VERSION < 69
|
|
4
|
-
#error \
|
|
5
|
-
"Reanimated 3 does not support React Native 0.68.x when Fabric is enabled. Please upgrade to React Native 0.69.0 or newer if you want to use Reanimated with the new architecture."
|
|
6
|
-
#endif
|
|
7
|
-
|
|
8
3
|
#include "FabricUtils.h"
|
|
9
4
|
|
|
5
|
+
#include <react/renderer/debug/SystraceSection.h>
|
|
10
6
|
#include <react/renderer/uimanager/UIManagerBinding.h>
|
|
11
7
|
|
|
12
8
|
using namespace facebook::react;
|
|
@@ -22,110 +18,10 @@ RuntimeExecutor getRuntimeExecutorFromBinding(Binding *binding) {
|
|
|
22
18
|
}
|
|
23
19
|
#endif
|
|
24
20
|
|
|
25
|
-
inline static const UIManagerPublic *getUIManagerPublic(
|
|
26
|
-
const UIManager *uiManager) {
|
|
27
|
-
return reinterpret_cast<const UIManagerPublic *>(uiManager);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
21
|
std::shared_ptr<const ContextContainer> getContextContainerFromUIManager(
|
|
31
22
|
const UIManager *uiManager) {
|
|
32
|
-
return
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
inline static UIManagerDelegate *getDelegateFromUIManager(
|
|
36
|
-
const UIManager *uiManager) {
|
|
37
|
-
return getUIManagerPublic(uiManager)->delegate_;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
void UIManager_dispatchCommand(
|
|
41
|
-
const std::shared_ptr<UIManager> &uiManager,
|
|
42
|
-
const ShadowNode::Shared &shadowNode,
|
|
43
|
-
std::string const &commandName,
|
|
44
|
-
folly::dynamic const &args) {
|
|
45
|
-
auto delegate_ = getDelegateFromUIManager(&*uiManager);
|
|
46
|
-
|
|
47
|
-
// copied from UIManager.cpp
|
|
48
|
-
if (delegate_) {
|
|
49
|
-
delegate_->uiManagerDidDispatchCommand(shadowNode, commandName, args);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
LayoutMetrics UIManager_getRelativeLayoutMetrics(
|
|
54
|
-
const std::shared_ptr<UIManager> &uiManager,
|
|
55
|
-
ShadowNode const &shadowNode,
|
|
56
|
-
ShadowNode const *ancestorShadowNode,
|
|
57
|
-
LayoutableShadowNode::LayoutInspectingPolicy policy) {
|
|
58
|
-
// based on implementation from UIManager.cpp
|
|
59
|
-
const auto &shadowTreeRegistry = uiManager->getShadowTreeRegistry();
|
|
60
|
-
|
|
61
|
-
// We might store here an owning pointer to `ancestorShadowNode` to ensure
|
|
62
|
-
// that the node is not deallocated during method execution lifetime.
|
|
63
|
-
auto owningAncestorShadowNode = ShadowNode::Shared{};
|
|
64
|
-
|
|
65
|
-
if (!ancestorShadowNode) {
|
|
66
|
-
shadowTreeRegistry.visit(
|
|
67
|
-
shadowNode.getSurfaceId(), [&](ShadowTree const &shadowTree) {
|
|
68
|
-
owningAncestorShadowNode =
|
|
69
|
-
shadowTree.getCurrentRevision().rootShadowNode;
|
|
70
|
-
ancestorShadowNode = owningAncestorShadowNode.get();
|
|
71
|
-
});
|
|
72
|
-
} else {
|
|
73
|
-
// It is possible for JavaScript (or other callers) to have a reference
|
|
74
|
-
// to a previous version of ShadowNodes, but we enforce that
|
|
75
|
-
// metrics are only calculated on most recently committed versions.
|
|
76
|
-
owningAncestorShadowNode =
|
|
77
|
-
uiManager->getNewestCloneOfShadowNode(*ancestorShadowNode);
|
|
78
|
-
ancestorShadowNode = owningAncestorShadowNode.get();
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
auto layoutableAncestorShadowNode =
|
|
82
|
-
traitCast<LayoutableShadowNode const *>(ancestorShadowNode);
|
|
83
|
-
|
|
84
|
-
if (!layoutableAncestorShadowNode) {
|
|
85
|
-
return EmptyLayoutMetrics;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return LayoutableShadowNode::computeRelativeLayoutMetrics(
|
|
89
|
-
shadowNode.getFamily(), *layoutableAncestorShadowNode, policy);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
ShadowNode::Shared UIManager_cloneNode(
|
|
93
|
-
const UIManager *uiManager,
|
|
94
|
-
const ShadowNode::Shared &shadowNode,
|
|
95
|
-
const ShadowNode::SharedListOfShared &children,
|
|
96
|
-
const RawProps *rawProps) {
|
|
97
|
-
auto delegate_ = getDelegateFromUIManager(uiManager);
|
|
98
|
-
auto contextContainer_ = getContextContainerFromUIManager(uiManager);
|
|
99
|
-
|
|
100
|
-
// copied from UIManager.cpp
|
|
101
|
-
PropsParserContext propsParserContext{
|
|
102
|
-
shadowNode->getFamily().getSurfaceId(), *contextContainer_.get()};
|
|
103
|
-
|
|
104
|
-
auto &componentDescriptor = shadowNode->getComponentDescriptor();
|
|
105
|
-
auto clonedShadowNode = componentDescriptor.cloneShadowNode(
|
|
106
|
-
*shadowNode,
|
|
107
|
-
{
|
|
108
|
-
/* .props = */
|
|
109
|
-
rawProps ? componentDescriptor.cloneProps(
|
|
110
|
-
propsParserContext, shadowNode->getProps(), *rawProps)
|
|
111
|
-
: ShadowNodeFragment::propsPlaceholder(),
|
|
112
|
-
/* .children = */ children,
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
if (delegate_) {
|
|
116
|
-
delegate_->uiManagerDidCloneShadowNode(
|
|
117
|
-
*shadowNode.get(), *clonedShadowNode);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
return clonedShadowNode;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
void UIManager_appendChild(
|
|
124
|
-
const ShadowNode::Shared &parentShadowNode,
|
|
125
|
-
const ShadowNode::Shared &childShadowNode) {
|
|
126
|
-
// copied from UIManager.cpp
|
|
127
|
-
auto &componentDescriptor = parentShadowNode->getComponentDescriptor();
|
|
128
|
-
componentDescriptor.appendChild(parentShadowNode, childShadowNode);
|
|
23
|
+
return reinterpret_cast<const UIManagerPublic *>(uiManager)
|
|
24
|
+
->contextContainer_;
|
|
129
25
|
}
|
|
130
26
|
|
|
131
27
|
} // namespace reanimated
|
|
@@ -2,15 +2,16 @@
|
|
|
2
2
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
3
3
|
|
|
4
4
|
#ifdef ANDROID
|
|
5
|
-
#include <Binding.h>
|
|
6
5
|
#include <fbjni/fbjni.h>
|
|
6
|
+
#include <react/fabric/Binding.h>
|
|
7
7
|
#endif
|
|
8
8
|
#include <react/renderer/uimanager/UIManager.h>
|
|
9
9
|
|
|
10
10
|
#include <memory>
|
|
11
11
|
#include <string>
|
|
12
12
|
|
|
13
|
-
using namespace facebook
|
|
13
|
+
using namespace facebook;
|
|
14
|
+
using namespace react;
|
|
14
15
|
|
|
15
16
|
namespace reanimated {
|
|
16
17
|
|
|
@@ -52,28 +53,6 @@ RuntimeExecutor getRuntimeExecutorFromBinding(Binding *binding);
|
|
|
52
53
|
std::shared_ptr<const ContextContainer> getContextContainerFromUIManager(
|
|
53
54
|
const UIManager *uiManager);
|
|
54
55
|
|
|
55
|
-
void UIManager_dispatchCommand(
|
|
56
|
-
const std::shared_ptr<UIManager> &uiManager,
|
|
57
|
-
const ShadowNode::Shared &shadowNode,
|
|
58
|
-
std::string const &commandName,
|
|
59
|
-
folly::dynamic const &args);
|
|
60
|
-
|
|
61
|
-
LayoutMetrics UIManager_getRelativeLayoutMetrics(
|
|
62
|
-
const std::shared_ptr<UIManager> &uiManager,
|
|
63
|
-
ShadowNode const &shadowNode,
|
|
64
|
-
ShadowNode const *ancestorShadowNode,
|
|
65
|
-
LayoutableShadowNode::LayoutInspectingPolicy policy);
|
|
66
|
-
|
|
67
|
-
ShadowNode::Shared UIManager_cloneNode(
|
|
68
|
-
const UIManager *uiManager,
|
|
69
|
-
const ShadowNode::Shared &shadowNode,
|
|
70
|
-
const ShadowNode::SharedListOfShared &children = nullptr,
|
|
71
|
-
const RawProps *rawProps = nullptr);
|
|
72
|
-
|
|
73
|
-
void UIManager_appendChild(
|
|
74
|
-
const ShadowNode::Shared &parentShadowNode,
|
|
75
|
-
const ShadowNode::Shared &childShadowNode);
|
|
76
|
-
|
|
77
56
|
} // namespace reanimated
|
|
78
57
|
|
|
79
58
|
#endif // RCT_NEW_ARCH_ENABLED
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
#include "FabricUtils.h"
|
|
5
5
|
#include "NewestShadowNodesRegistry.h"
|
|
6
6
|
|
|
7
|
+
#include <react/renderer/debug/SystraceSection.h>
|
|
8
|
+
|
|
7
9
|
#include <utility>
|
|
8
10
|
|
|
9
11
|
using namespace facebook;
|
|
@@ -51,7 +53,7 @@ ReanimatedUIManagerBinding::ReanimatedUIManagerBinding(
|
|
|
51
53
|
RuntimeExecutor runtimeExecutor,
|
|
52
54
|
std::unique_ptr<EventHandler const> eventHandler,
|
|
53
55
|
std::shared_ptr<NewestShadowNodesRegistry> newestShadowNodesRegistry)
|
|
54
|
-
: UIManagerBinding(uiManager
|
|
56
|
+
: UIManagerBinding(uiManager),
|
|
55
57
|
uiManager_(std::move(uiManager)),
|
|
56
58
|
newestShadowNodesRegistry_(newestShadowNodesRegistry) {
|
|
57
59
|
if (eventHandler != nullptr) {
|
|
@@ -62,25 +64,44 @@ ReanimatedUIManagerBinding::ReanimatedUIManagerBinding(
|
|
|
62
64
|
|
|
63
65
|
ReanimatedUIManagerBinding::~ReanimatedUIManagerBinding() {}
|
|
64
66
|
|
|
65
|
-
static inline ShadowNode::Shared
|
|
67
|
+
static inline ShadowNode::Shared cloneNodeUsingNewest(
|
|
66
68
|
UIManager *uiManager,
|
|
67
69
|
NewestShadowNodesRegistry *newestShadowNodesRegistry,
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
const
|
|
70
|
+
ShadowNode const &shadowNode,
|
|
71
|
+
ShadowNode::SharedListOfShared const &children = nullptr,
|
|
72
|
+
RawProps const *rawProps = nullptr) {
|
|
71
73
|
{
|
|
72
74
|
auto lock = newestShadowNodesRegistry->createLock();
|
|
73
|
-
auto newest = newestShadowNodesRegistry->get(shadowNode
|
|
75
|
+
auto newest = newestShadowNodesRegistry->get(shadowNode.getTag());
|
|
74
76
|
if (newest != nullptr) {
|
|
75
77
|
// ShadowNode managed by Reanimated, use newest ShadowNode from registry
|
|
76
|
-
auto clone =
|
|
78
|
+
auto clone = uiManager->cloneNode(*newest, children, rawProps);
|
|
77
79
|
newestShadowNodesRegistry->update(clone);
|
|
78
80
|
return clone;
|
|
79
81
|
}
|
|
80
82
|
} // release lock since we don't need registry anymore
|
|
81
83
|
|
|
82
84
|
// ShadowNode not managed by Reanimated (yet?)
|
|
83
|
-
return
|
|
85
|
+
return uiManager->cloneNode(shadowNode, children, rawProps);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
static inline void appendChildUsingNewest(
|
|
89
|
+
UIManager *uiManager,
|
|
90
|
+
NewestShadowNodesRegistry *newestShadowNodesRegistry,
|
|
91
|
+
const ShadowNode::Shared &parentShadowNode,
|
|
92
|
+
const ShadowNode::Shared &childShadowNode) {
|
|
93
|
+
{
|
|
94
|
+
auto lock = newestShadowNodesRegistry->createLock();
|
|
95
|
+
auto newestChildShadowNode =
|
|
96
|
+
newestShadowNodesRegistry->get(childShadowNode->getTag());
|
|
97
|
+
if (newestChildShadowNode != nullptr) {
|
|
98
|
+
uiManager->appendChild(parentShadowNode, newestChildShadowNode);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
} // release lock since we don't need registry anymore
|
|
102
|
+
|
|
103
|
+
// child ShadowNode not managed by Reanimated (yet?)
|
|
104
|
+
uiManager->appendChild(parentShadowNode, childShadowNode);
|
|
84
105
|
}
|
|
85
106
|
|
|
86
107
|
jsi::Value ReanimatedUIManagerBinding::get(
|
|
@@ -94,6 +115,7 @@ jsi::Value ReanimatedUIManagerBinding::get(
|
|
|
94
115
|
|
|
95
116
|
// based on implementation from UIManagerBinding.cpp
|
|
96
117
|
auto methodName = name.utf8(runtime);
|
|
118
|
+
SystraceSection s("ReanimatedUIManagerBinding::get", "name", methodName);
|
|
97
119
|
UIManager *uiManager = uiManager_.get();
|
|
98
120
|
NewestShadowNodesRegistry *newestShadowNodesRegistry =
|
|
99
121
|
newestShadowNodesRegistry_.get();
|
|
@@ -106,15 +128,15 @@ jsi::Value ReanimatedUIManagerBinding::get(
|
|
|
106
128
|
1,
|
|
107
129
|
[uiManager, newestShadowNodesRegistry](
|
|
108
130
|
jsi::Runtime &runtime,
|
|
109
|
-
jsi::Value const &thisValue
|
|
131
|
+
jsi::Value const & /*thisValue*/,
|
|
110
132
|
jsi::Value const *arguments,
|
|
111
|
-
size_t count) noexcept -> jsi::Value {
|
|
133
|
+
size_t /*count*/) noexcept -> jsi::Value {
|
|
112
134
|
return valueFromShadowNode(
|
|
113
135
|
runtime,
|
|
114
|
-
|
|
136
|
+
cloneNodeUsingNewest(
|
|
115
137
|
uiManager,
|
|
116
138
|
newestShadowNodesRegistry,
|
|
117
|
-
shadowNodeFromValue(runtime, arguments[0])));
|
|
139
|
+
*shadowNodeFromValue(runtime, arguments[0])));
|
|
118
140
|
});
|
|
119
141
|
}
|
|
120
142
|
|
|
@@ -126,15 +148,15 @@ jsi::Value ReanimatedUIManagerBinding::get(
|
|
|
126
148
|
1,
|
|
127
149
|
[uiManager, newestShadowNodesRegistry](
|
|
128
150
|
jsi::Runtime &runtime,
|
|
129
|
-
jsi::Value const &thisValue
|
|
151
|
+
jsi::Value const & /*thisValue*/,
|
|
130
152
|
jsi::Value const *arguments,
|
|
131
|
-
size_t count) noexcept -> jsi::Value {
|
|
153
|
+
size_t /*count*/) noexcept -> jsi::Value {
|
|
132
154
|
return valueFromShadowNode(
|
|
133
155
|
runtime,
|
|
134
|
-
|
|
156
|
+
cloneNodeUsingNewest(
|
|
135
157
|
uiManager,
|
|
136
158
|
newestShadowNodesRegistry,
|
|
137
|
-
shadowNodeFromValue(runtime, arguments[0]),
|
|
159
|
+
*shadowNodeFromValue(runtime, arguments[0]),
|
|
138
160
|
ShadowNode::emptySharedShadowNodeSharedList()));
|
|
139
161
|
});
|
|
140
162
|
}
|
|
@@ -147,16 +169,16 @@ jsi::Value ReanimatedUIManagerBinding::get(
|
|
|
147
169
|
2,
|
|
148
170
|
[uiManager, newestShadowNodesRegistry](
|
|
149
171
|
jsi::Runtime &runtime,
|
|
150
|
-
jsi::Value const &thisValue
|
|
172
|
+
jsi::Value const & /*thisValue*/,
|
|
151
173
|
jsi::Value const *arguments,
|
|
152
|
-
size_t count) noexcept -> jsi::Value {
|
|
174
|
+
size_t /*count*/) noexcept -> jsi::Value {
|
|
153
175
|
auto const &rawProps = RawProps(runtime, arguments[1]);
|
|
154
176
|
return valueFromShadowNode(
|
|
155
177
|
runtime,
|
|
156
|
-
|
|
178
|
+
cloneNodeUsingNewest(
|
|
157
179
|
uiManager,
|
|
158
180
|
newestShadowNodesRegistry,
|
|
159
|
-
shadowNodeFromValue(runtime, arguments[0]),
|
|
181
|
+
*shadowNodeFromValue(runtime, arguments[0]),
|
|
160
182
|
nullptr,
|
|
161
183
|
&rawProps));
|
|
162
184
|
});
|
|
@@ -170,16 +192,16 @@ jsi::Value ReanimatedUIManagerBinding::get(
|
|
|
170
192
|
2,
|
|
171
193
|
[uiManager, newestShadowNodesRegistry](
|
|
172
194
|
jsi::Runtime &runtime,
|
|
173
|
-
jsi::Value const &thisValue
|
|
195
|
+
jsi::Value const & /*thisValue*/,
|
|
174
196
|
jsi::Value const *arguments,
|
|
175
|
-
size_t count) noexcept -> jsi::Value {
|
|
197
|
+
size_t /*count*/) noexcept -> jsi::Value {
|
|
176
198
|
auto const &rawProps = RawProps(runtime, arguments[1]);
|
|
177
199
|
return valueFromShadowNode(
|
|
178
200
|
runtime,
|
|
179
|
-
|
|
201
|
+
cloneNodeUsingNewest(
|
|
180
202
|
uiManager,
|
|
181
203
|
newestShadowNodesRegistry,
|
|
182
|
-
shadowNodeFromValue(runtime, arguments[0]),
|
|
204
|
+
*shadowNodeFromValue(runtime, arguments[0]),
|
|
183
205
|
ShadowNode::emptySharedShadowNodeSharedList(),
|
|
184
206
|
&rawProps));
|
|
185
207
|
});
|
|
@@ -190,21 +212,16 @@ jsi::Value ReanimatedUIManagerBinding::get(
|
|
|
190
212
|
runtime,
|
|
191
213
|
name,
|
|
192
214
|
2,
|
|
193
|
-
[newestShadowNodesRegistry](
|
|
215
|
+
[uiManager, newestShadowNodesRegistry](
|
|
194
216
|
jsi::Runtime &runtime,
|
|
195
|
-
jsi::Value const &thisValue
|
|
217
|
+
jsi::Value const & /*thisValue*/,
|
|
196
218
|
jsi::Value const *arguments,
|
|
197
|
-
size_t count) noexcept -> jsi::Value {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
if (newest != nullptr) {
|
|
204
|
-
child = newest;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
UIManager_appendChild(parent, child);
|
|
219
|
+
size_t /*count*/) noexcept -> jsi::Value {
|
|
220
|
+
appendChildUsingNewest(
|
|
221
|
+
uiManager,
|
|
222
|
+
newestShadowNodesRegistry,
|
|
223
|
+
shadowNodeFromValue(runtime, arguments[0]),
|
|
224
|
+
shadowNodeFromValue(runtime, arguments[1]));
|
|
208
225
|
return jsi::Value::undefined();
|
|
209
226
|
});
|
|
210
227
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#include "LayoutAnimationsManager.h"
|
|
2
|
+
#include "CollectionUtils.h"
|
|
2
3
|
#include "Shareables.h"
|
|
3
4
|
|
|
4
5
|
#include <utility>
|
|
@@ -7,30 +8,22 @@ namespace reanimated {
|
|
|
7
8
|
|
|
8
9
|
void LayoutAnimationsManager::configureAnimation(
|
|
9
10
|
int tag,
|
|
10
|
-
|
|
11
|
+
LayoutAnimationType type,
|
|
12
|
+
const std::string &sharedTransitionTag,
|
|
11
13
|
std::shared_ptr<Shareable> config) {
|
|
12
14
|
auto lock = std::unique_lock<std::mutex>(animationsMutex_);
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
} else if (type == "layout") {
|
|
18
|
-
layoutAnimations_[tag] = config;
|
|
15
|
+
getConfigsForType(type)[tag] = config;
|
|
16
|
+
if (type == SHARED_ELEMENT_TRANSITION) {
|
|
17
|
+
sharedTransitionGroups_[sharedTransitionTag].push_back(tag);
|
|
18
|
+
viewTagToSharedTag_[tag] = sharedTransitionTag;
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
bool LayoutAnimationsManager::hasLayoutAnimation(
|
|
23
23
|
int tag,
|
|
24
|
-
|
|
24
|
+
LayoutAnimationType type) {
|
|
25
25
|
auto lock = std::unique_lock<std::mutex>(animationsMutex_);
|
|
26
|
-
|
|
27
|
-
return enteringAnimations_.find(tag) != enteringAnimations_.end();
|
|
28
|
-
} else if (type == "exiting") {
|
|
29
|
-
return exitingAnimations_.find(tag) != exitingAnimations_.end();
|
|
30
|
-
} else if (type == "layout") {
|
|
31
|
-
return layoutAnimations_.find(tag) != layoutAnimations_.end();
|
|
32
|
-
}
|
|
33
|
-
return false;
|
|
26
|
+
return collection::contains(getConfigsForType(type), tag);
|
|
34
27
|
}
|
|
35
28
|
|
|
36
29
|
void LayoutAnimationsManager::clearLayoutAnimationConfig(int tag) {
|
|
@@ -38,25 +31,30 @@ void LayoutAnimationsManager::clearLayoutAnimationConfig(int tag) {
|
|
|
38
31
|
enteringAnimations_.erase(tag);
|
|
39
32
|
exitingAnimations_.erase(tag);
|
|
40
33
|
layoutAnimations_.erase(tag);
|
|
34
|
+
|
|
35
|
+
sharedTransitionAnimations_.erase(tag);
|
|
36
|
+
auto const &groupName = viewTagToSharedTag_[tag];
|
|
37
|
+
auto &group = sharedTransitionGroups_[groupName];
|
|
38
|
+
auto position = std::find(group.begin(), group.end(), tag);
|
|
39
|
+
if (position != group.end()) {
|
|
40
|
+
group.erase(position);
|
|
41
|
+
}
|
|
42
|
+
if (group.size() == 0) {
|
|
43
|
+
sharedTransitionGroups_.erase(groupName);
|
|
44
|
+
}
|
|
45
|
+
viewTagToSharedTag_.erase(tag);
|
|
41
46
|
}
|
|
42
47
|
|
|
43
48
|
void LayoutAnimationsManager::startLayoutAnimation(
|
|
44
49
|
jsi::Runtime &rt,
|
|
45
50
|
int tag,
|
|
46
|
-
|
|
51
|
+
LayoutAnimationType type,
|
|
47
52
|
const jsi::Object &values) {
|
|
48
53
|
std::shared_ptr<Shareable> config, viewShareable;
|
|
49
54
|
{
|
|
50
55
|
auto lock = std::unique_lock<std::mutex>(animationsMutex_);
|
|
51
|
-
|
|
52
|
-
config = enteringAnimations_[tag];
|
|
53
|
-
} else if (type == "exiting") {
|
|
54
|
-
config = exitingAnimations_[tag];
|
|
55
|
-
} else if (type == "layout") {
|
|
56
|
-
config = layoutAnimations_[tag];
|
|
57
|
-
}
|
|
56
|
+
config = getConfigsForType(type)[tag];
|
|
58
57
|
}
|
|
59
|
-
|
|
60
58
|
// TODO: cache the following!!
|
|
61
59
|
jsi::Value layoutAnimationRepositoryAsValue =
|
|
62
60
|
rt.global()
|
|
@@ -68,9 +66,66 @@ void LayoutAnimationsManager::startLayoutAnimation(
|
|
|
68
66
|
startAnimationForTag.call(
|
|
69
67
|
rt,
|
|
70
68
|
jsi::Value(tag),
|
|
71
|
-
jsi::
|
|
69
|
+
jsi::Value(static_cast<int>(type)),
|
|
72
70
|
values,
|
|
73
71
|
config->getJSValue(rt));
|
|
74
72
|
}
|
|
75
73
|
|
|
74
|
+
void LayoutAnimationsManager::cancelLayoutAnimation(
|
|
75
|
+
jsi::Runtime &rt,
|
|
76
|
+
int tag,
|
|
77
|
+
LayoutAnimationType type,
|
|
78
|
+
bool cancelled = true,
|
|
79
|
+
bool removeView = true) {
|
|
80
|
+
jsi::Value layoutAnimationRepositoryAsValue =
|
|
81
|
+
rt.global()
|
|
82
|
+
.getPropertyAsObject(rt, "global")
|
|
83
|
+
.getProperty(rt, "LayoutAnimationsManager");
|
|
84
|
+
jsi::Function cancelLayoutAnimation =
|
|
85
|
+
layoutAnimationRepositoryAsValue.getObject(rt).getPropertyAsFunction(
|
|
86
|
+
rt, "stop");
|
|
87
|
+
std::shared_ptr<Shareable> config;
|
|
88
|
+
{
|
|
89
|
+
auto lock = std::unique_lock<std::mutex>(animationsMutex_);
|
|
90
|
+
config = sharedTransitionAnimations_[tag];
|
|
91
|
+
}
|
|
92
|
+
if (config != nullptr) {
|
|
93
|
+
cancelLayoutAnimation.call(
|
|
94
|
+
rt, jsi::Value(tag), config->getJSValue(rt), cancelled, removeView);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/*
|
|
99
|
+
The top screen on the stack triggers the animation, so we need to find
|
|
100
|
+
the sibling view registered in the past. This method finds view
|
|
101
|
+
registered in the same transition group (with the same transition tag)
|
|
102
|
+
which has been added to that group directly before the one that we
|
|
103
|
+
provide as an argument.
|
|
104
|
+
*/
|
|
105
|
+
int LayoutAnimationsManager::findPrecedingViewTagForTransition(int tag) {
|
|
106
|
+
auto const &groupName = viewTagToSharedTag_[tag];
|
|
107
|
+
auto const &group = sharedTransitionGroups_[groupName];
|
|
108
|
+
auto position = std::find(group.begin(), group.end(), tag);
|
|
109
|
+
if (position != group.end() && position != group.begin()) {
|
|
110
|
+
return *std::prev(position);
|
|
111
|
+
}
|
|
112
|
+
return -1;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
std::unordered_map<int, std::shared_ptr<Shareable>>
|
|
116
|
+
&LayoutAnimationsManager::getConfigsForType(LayoutAnimationType type) {
|
|
117
|
+
switch (type) {
|
|
118
|
+
case ENTERING:
|
|
119
|
+
return enteringAnimations_;
|
|
120
|
+
case EXITING:
|
|
121
|
+
return exitingAnimations_;
|
|
122
|
+
case LAYOUT:
|
|
123
|
+
return layoutAnimations_;
|
|
124
|
+
case SHARED_ELEMENT_TRANSITION:
|
|
125
|
+
return sharedTransitionAnimations_;
|
|
126
|
+
default:
|
|
127
|
+
assert(false);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
76
131
|
} // namespace reanimated
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
3
|
#include "ErrorHandler.h"
|
|
4
|
+
#include "LayoutAnimationType.h"
|
|
4
5
|
#include "Shareables.h"
|
|
5
6
|
|
|
6
7
|
#include <jsi/jsi.h>
|
|
@@ -10,6 +11,7 @@
|
|
|
10
11
|
#include <mutex>
|
|
11
12
|
#include <string>
|
|
12
13
|
#include <unordered_map>
|
|
14
|
+
#include <vector>
|
|
13
15
|
|
|
14
16
|
namespace reanimated {
|
|
15
17
|
|
|
@@ -19,20 +21,35 @@ class LayoutAnimationsManager {
|
|
|
19
21
|
public:
|
|
20
22
|
void configureAnimation(
|
|
21
23
|
int tag,
|
|
22
|
-
|
|
24
|
+
LayoutAnimationType type,
|
|
25
|
+
const std::string &sharedTransitionTag,
|
|
23
26
|
std::shared_ptr<Shareable> config);
|
|
24
|
-
bool hasLayoutAnimation(int tag,
|
|
27
|
+
bool hasLayoutAnimation(int tag, LayoutAnimationType type);
|
|
25
28
|
void startLayoutAnimation(
|
|
26
29
|
jsi::Runtime &rt,
|
|
27
30
|
int tag,
|
|
28
|
-
|
|
31
|
+
LayoutAnimationType type,
|
|
29
32
|
const jsi::Object &values);
|
|
30
33
|
void clearLayoutAnimationConfig(int tag);
|
|
34
|
+
void cancelLayoutAnimation(
|
|
35
|
+
jsi::Runtime &rt,
|
|
36
|
+
int tag,
|
|
37
|
+
LayoutAnimationType type,
|
|
38
|
+
bool cancelled /* = true */,
|
|
39
|
+
bool removeView /* = true */);
|
|
40
|
+
int findPrecedingViewTagForTransition(int tag);
|
|
31
41
|
|
|
32
42
|
private:
|
|
43
|
+
std::unordered_map<int, std::shared_ptr<Shareable>> &getConfigsForType(
|
|
44
|
+
LayoutAnimationType type);
|
|
45
|
+
|
|
33
46
|
std::unordered_map<int, std::shared_ptr<Shareable>> enteringAnimations_;
|
|
34
47
|
std::unordered_map<int, std::shared_ptr<Shareable>> exitingAnimations_;
|
|
35
48
|
std::unordered_map<int, std::shared_ptr<Shareable>> layoutAnimations_;
|
|
49
|
+
std::unordered_map<int, std::shared_ptr<Shareable>>
|
|
50
|
+
sharedTransitionAnimations_;
|
|
51
|
+
std::unordered_map<std::string, std::vector<int>> sharedTransitionGroups_;
|
|
52
|
+
std::unordered_map<int, std::string> viewTagToSharedTag_;
|
|
36
53
|
mutable std::mutex
|
|
37
54
|
animationsMutex_; // Protects `enteringAnimations_`, `exitingAnimations_`,
|
|
38
55
|
// `layoutAnimations_` and `viewSharedValues_`.
|