react-native-reanimated 3.8.0 → 3.9.0-layout-animation-experimental
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/Fabric/ShadowTreeCloner.cpp +5 -2
- package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.cpp +42 -32
- package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.h +5 -7
- package/Common/cpp/LayoutAnimations/LayoutAnimationsProxy.cpp +565 -0
- package/Common/cpp/LayoutAnimations/LayoutAnimationsProxy.h +74 -0
- package/Common/cpp/LayoutAnimations/LayoutAnimationsUtils.h +140 -0
- package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +216 -58
- package/Common/cpp/NativeModules/NativeReanimatedModule.h +32 -11
- package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +2 -17
- package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.h +6 -8
- package/Common/cpp/ReanimatedRuntime/RNRuntimeDecorator.cpp +3 -0
- package/Common/cpp/ReanimatedRuntime/WorkletRuntime.cpp +3 -4
- package/Common/cpp/ReanimatedRuntime/WorkletRuntimeDecorator.cpp +8 -3
- package/Common/cpp/SharedItems/Shareables.cpp +31 -5
- package/Common/cpp/SharedItems/Shareables.h +18 -2
- package/Common/cpp/Tools/JSScheduler.cpp +29 -5
- package/Common/cpp/Tools/JSScheduler.h +21 -4
- package/Common/cpp/Tools/PlatformDepMethodsHolder.h +6 -2
- package/Common/cpp/Tools/UIRuntimeDecorator.cpp +6 -0
- package/Common/cpp/Tools/UIRuntimeDecorator.h +1 -0
- package/android/CMakeLists.txt +3 -0
- package/android/build.gradle +17 -5
- package/android/src/main/cpp/NativeProxy.cpp +77 -12
- package/android/src/main/cpp/NativeProxy.h +35 -1
- package/android/src/main/java/com/swmansion/reanimated/NodesManager.java +58 -19
- package/android/src/main/java/com/swmansion/reanimated/ReanimatedPackage.java +7 -2
- package/android/src/{reactNativeVersionPatch/ReanimatedUIManager/latest → main/java}/com/swmansion/reanimated/ReanimatedUIManagerFactory.java +5 -5
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/AnimationsManager.java +10 -6
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ReanimatedNativeHierarchyManager.java +18 -1
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/SharedTransitionManager.java +105 -17
- package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensor.java +2 -1
- package/android/src/paper/java/com/swmansion/reanimated/NativeReanimatedModuleSpec.java +37 -0
- package/android/src/{main/java/com/swmansion/reanimated → reactNativeVersionPatch/ReanimatedUIManager/73/com/swmansion}/ReanimatedModule.java +4 -3
- package/android/src/reactNativeVersionPatch/ReanimatedUIManager/{70 → 73}/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +1 -22
- package/android/src/reactNativeVersionPatch/ReanimatedUIManager/latest/com/swmansion/reanimated/ReanimatedModule.java +176 -0
- package/android/src/reactNativeVersionPatch/ReanimatedUIManager/latest/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +0 -26
- package/android/src/{fabric/java → reactNativeVersionPatch/RuntimeExecutor/73}/com/swmansion/reanimated/NativeProxy.java +16 -4
- package/android/src/reactNativeVersionPatch/RuntimeExecutor/latest/com/swmansion/reanimated/NativeProxy.java +143 -0
- package/apple/LayoutReanimation/REAAnimationsManager.h +3 -0
- package/apple/LayoutReanimation/REAAnimationsManager.m +11 -0
- package/apple/LayoutReanimation/REASharedTransitionManager.m +99 -23
- package/apple/LayoutReanimation/REASnapshot.h +1 -0
- package/apple/LayoutReanimation/REASnapshot.m +78 -37
- package/apple/REAModule.h +22 -2
- package/apple/REAModule.mm +97 -46
- package/apple/REANodesManager.h +3 -3
- package/apple/REANodesManager.mm +46 -22
- package/apple/native/NativeProxy.h +28 -2
- package/apple/native/NativeProxy.mm +65 -195
- package/apple/native/PlatformDepMethodsHolderImpl.h +59 -0
- package/apple/native/PlatformDepMethodsHolderImpl.mm +429 -0
- package/apple/sensor/ReanimatedSensor.m +5 -5
- package/lib/module/Animated.js.map +1 -1
- package/lib/module/ConfigHelper.js +1 -1
- package/lib/module/ConfigHelper.js.map +1 -1
- package/lib/module/animationBuilder.js +1 -0
- package/lib/module/animationBuilder.js.map +1 -1
- package/lib/module/createAnimatedComponent/InlinePropManager.js +4 -4
- package/lib/module/createAnimatedComponent/InlinePropManager.js.map +1 -1
- package/lib/module/createAnimatedComponent/JSPropsUpdater.js +9 -6
- package/lib/module/createAnimatedComponent/JSPropsUpdater.js.map +1 -1
- package/lib/module/createAnimatedComponent/JSPropsUpdater.web.js +11 -0
- package/lib/module/createAnimatedComponent/JSPropsUpdater.web.js.map +1 -0
- package/lib/module/createAnimatedComponent/PropsFilter.js +25 -9
- package/lib/module/createAnimatedComponent/PropsFilter.js.map +1 -1
- package/lib/module/createAnimatedComponent/commonTypes.js.map +1 -1
- package/lib/module/createAnimatedComponent/createAnimatedComponent.js +83 -52
- package/lib/module/createAnimatedComponent/createAnimatedComponent.js.map +1 -1
- package/lib/module/createAnimatedComponent/getViewInfo.js +37 -0
- package/lib/module/createAnimatedComponent/getViewInfo.js.map +1 -0
- package/lib/module/createAnimatedComponent/index.js.map +1 -1
- package/lib/module/createAnimatedComponent/setAndForwardRef.js +4 -5
- package/lib/module/createAnimatedComponent/setAndForwardRef.js.map +1 -1
- package/lib/module/createAnimatedComponent/utils.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.web.js +1 -2
- package/lib/module/index.web.js.map +1 -1
- package/lib/module/mock.js +12 -12
- package/lib/module/mock.js.map +1 -1
- package/lib/module/propsAllowlists.js.map +1 -1
- package/lib/module/reanimated2/Bezier.js.map +1 -1
- package/lib/module/reanimated2/Colors.js +4 -11
- package/lib/module/reanimated2/Colors.js.map +1 -1
- package/lib/module/reanimated2/Easing.js +3 -7
- package/lib/module/reanimated2/Easing.js.map +1 -1
- package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js +16 -13
- package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
- package/lib/module/reanimated2/NativeReanimated/index.js.map +1 -1
- package/lib/module/reanimated2/NativeReanimated/index.web.js.map +1 -1
- package/lib/module/reanimated2/PlatformChecker.js +2 -1
- package/lib/module/reanimated2/PlatformChecker.js.map +1 -1
- package/lib/module/reanimated2/PropAdapters.js +1 -1
- package/lib/module/reanimated2/PropAdapters.js.map +1 -1
- package/lib/module/reanimated2/PropsRegistry.js +1 -2
- package/lib/module/reanimated2/PropsRegistry.js.map +1 -1
- package/lib/module/reanimated2/Sensor.js +2 -2
- package/lib/module/reanimated2/Sensor.js.map +1 -1
- package/lib/module/reanimated2/SensorContainer.js +2 -2
- package/lib/module/reanimated2/SensorContainer.js.map +1 -1
- package/lib/module/reanimated2/UpdateLayoutAnimations.js +30 -8
- package/lib/module/reanimated2/UpdateLayoutAnimations.js.map +1 -1
- package/lib/module/reanimated2/UpdateProps.js.map +1 -1
- package/lib/module/reanimated2/ViewDescriptorsSet.js.map +1 -1
- package/lib/module/reanimated2/WorkletEventHandler.js +74 -31
- package/lib/module/reanimated2/WorkletEventHandler.js.map +1 -1
- package/lib/module/reanimated2/animation/clamp.js.map +1 -1
- package/lib/module/reanimated2/animation/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/animation/decay/decay.js.map +1 -1
- package/lib/module/reanimated2/animation/decay/index.js.map +1 -1
- package/lib/module/reanimated2/animation/decay/rigidDecay.js.map +1 -1
- package/lib/module/reanimated2/animation/decay/rubberBandDecay.js.map +1 -1
- package/lib/module/reanimated2/animation/decay/utils.js.map +1 -1
- package/lib/module/reanimated2/animation/delay.js.map +1 -1
- package/lib/module/reanimated2/animation/index.js.map +1 -1
- package/lib/module/reanimated2/animation/repeat.js +1 -6
- package/lib/module/reanimated2/animation/repeat.js.map +1 -1
- package/lib/module/reanimated2/animation/sequence.js +1 -5
- package/lib/module/reanimated2/animation/sequence.js.map +1 -1
- package/lib/module/reanimated2/animation/spring.js.map +1 -1
- package/lib/module/reanimated2/animation/springUtils.js +8 -10
- package/lib/module/reanimated2/animation/springUtils.js.map +1 -1
- package/lib/module/reanimated2/animation/styleAnimation.js +5 -4
- package/lib/module/reanimated2/animation/styleAnimation.js.map +1 -1
- package/lib/module/reanimated2/animation/timing.js +4 -1
- package/lib/module/reanimated2/animation/timing.js.map +1 -1
- package/lib/module/reanimated2/animation/transformationMatrix/matrixUtils.js +1 -2
- package/lib/module/reanimated2/animation/transformationMatrix/matrixUtils.js.map +1 -1
- package/lib/module/reanimated2/animation/util.js +22 -2
- package/lib/module/reanimated2/animation/util.js.map +1 -1
- package/lib/module/reanimated2/commonTypes.js +3 -1
- package/lib/module/reanimated2/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/component/FlatList.js +1 -0
- package/lib/module/reanimated2/component/FlatList.js.map +1 -1
- package/lib/module/reanimated2/component/Image.js +1 -0
- package/lib/module/reanimated2/component/Image.js.map +1 -1
- package/lib/module/reanimated2/component/LayoutAnimationConfig.js +1 -0
- package/lib/module/reanimated2/component/LayoutAnimationConfig.js.map +1 -1
- package/lib/module/reanimated2/component/PerformanceMonitor.js +169 -0
- package/lib/module/reanimated2/component/PerformanceMonitor.js.map +1 -0
- package/lib/module/reanimated2/component/ScrollView.js +1 -0
- package/lib/module/reanimated2/component/ScrollView.js.map +1 -1
- package/lib/module/reanimated2/component/Text.js +1 -0
- package/lib/module/reanimated2/component/Text.js.map +1 -1
- package/lib/module/reanimated2/component/View.js +1 -0
- package/lib/module/reanimated2/component/View.js.map +1 -1
- package/lib/module/reanimated2/core.js +6 -15
- package/lib/module/reanimated2/core.js.map +1 -1
- package/lib/module/reanimated2/errors.js +8 -8
- package/lib/module/reanimated2/errors.js.map +1 -1
- package/lib/module/reanimated2/fabricUtils.js +33 -8
- package/lib/module/reanimated2/fabricUtils.js.map +1 -1
- package/lib/module/reanimated2/fabricUtils.web.js.map +1 -1
- package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryJS.js +2 -2
- package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryJS.js.map +1 -1
- package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js.map +1 -1
- package/lib/module/reanimated2/frameCallback/index.js.map +1 -1
- package/lib/module/reanimated2/globals.d.js.map +1 -1
- package/lib/module/reanimated2/helperTypes.js.map +1 -1
- package/lib/module/reanimated2/hook/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/hook/index.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedGestureHandler.js +1 -0
- package/lib/module/reanimated2/hook/useAnimatedGestureHandler.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedKeyboard.js +3 -4
- package/lib/module/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedProps.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedReaction.js +1 -0
- package/lib/module/reanimated2/hook/useAnimatedReaction.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedRef.js +12 -7
- package/lib/module/reanimated2/hook/useAnimatedRef.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedScrollHandler.js +3 -1
- package/lib/module/reanimated2/hook/useAnimatedScrollHandler.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedSensor.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedStyle.js +3 -6
- package/lib/module/reanimated2/hook/useAnimatedStyle.js.map +1 -1
- package/lib/module/reanimated2/hook/useDerivedValue.js +3 -1
- package/lib/module/reanimated2/hook/useDerivedValue.js.map +1 -1
- package/lib/module/reanimated2/hook/useEvent.js +4 -5
- package/lib/module/reanimated2/hook/useEvent.js.map +1 -1
- package/lib/module/reanimated2/hook/useFrameCallback.js +1 -2
- package/lib/module/reanimated2/hook/useFrameCallback.js.map +1 -1
- package/lib/module/reanimated2/hook/useHandler.js +3 -1
- package/lib/module/reanimated2/hook/useHandler.js.map +1 -1
- package/lib/module/reanimated2/hook/useReducedMotion.js.map +1 -1
- package/lib/module/reanimated2/hook/useScrollViewOffset.js +60 -16
- package/lib/module/reanimated2/hook/useScrollViewOffset.js.map +1 -1
- package/lib/module/reanimated2/hook/useSharedValue.js.map +1 -1
- package/lib/module/reanimated2/hook/useWorkletCallback.js.map +1 -1
- package/lib/module/reanimated2/hook/utils.js.map +1 -1
- package/lib/module/reanimated2/index.js +2 -0
- package/lib/module/reanimated2/index.js.map +1 -1
- package/lib/module/reanimated2/initializers.js +1 -5
- package/lib/module/reanimated2/initializers.js.map +1 -1
- package/lib/module/reanimated2/interpolateColor.js +2 -6
- package/lib/module/reanimated2/interpolateColor.js.map +1 -1
- package/lib/module/reanimated2/interpolation.js +1 -1
- package/lib/module/reanimated2/interpolation.js.map +1 -1
- package/lib/module/reanimated2/isSharedValue.js.map +1 -1
- package/lib/module/reanimated2/jestUtils.js +3 -6
- package/lib/module/reanimated2/jestUtils.js.map +1 -1
- package/lib/module/reanimated2/jestUtils.web.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/JSReanimated.js +5 -9
- package/lib/module/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/WebSensor.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/index.js +2 -2
- package/lib/module/reanimated2/js-reanimated/index.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/react-native-web.d.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.js +4 -2
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js +12 -11
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/Keyframe.js +12 -10
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/Keyframe.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationsManager.js +11 -4
- package/lib/module/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +22 -22
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Fade.js +22 -22
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Fade.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Flip.js +26 -26
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Flip.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +10 -10
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js +6 -6
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js +10 -10
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Rotate.js +18 -18
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Rotate.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js +18 -18
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Stretch.js +10 -10
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Stretch.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +34 -34
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js +17 -4
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js +4 -4
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js +4 -4
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js +4 -4
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js +4 -4
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js +4 -4
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/ProgressTransitionManager.js +16 -12
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/ProgressTransitionManager.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/SharedTransition.js +13 -7
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/SharedTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/SharedTransition.web.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/animation/Bounce.web.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/animation/Fade.web.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/animation/Flip.web.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/animation/Lightspeed.web.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/animation/Pinwheel.web.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/animation/Roll.web.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/animation/Rotate.web.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/animation/Slide.web.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/animation/Stretch.web.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/animation/Zoom.web.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/animationParser.js +0 -2
- package/lib/module/reanimated2/layoutReanimation/web/animationParser.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/animationsManager.js +1 -2
- package/lib/module/reanimated2/layoutReanimation/web/animationsManager.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/componentStyle.js +3 -1
- package/lib/module/reanimated2/layoutReanimation/web/componentStyle.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/componentUtils.js +6 -7
- package/lib/module/reanimated2/layoutReanimation/web/componentUtils.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/config.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/createAnimation.js +2 -2
- package/lib/module/reanimated2/layoutReanimation/web/createAnimation.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/domUtils.js +4 -4
- package/lib/module/reanimated2/layoutReanimation/web/domUtils.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/transition/Fading.web.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/transition/Linear.web.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/transition/Sequenced.web.js.map +1 -1
- package/lib/module/reanimated2/mappers.js +2 -4
- package/lib/module/reanimated2/mappers.js.map +1 -1
- package/lib/module/reanimated2/mockedRequestAnimationFrame.js.map +1 -1
- package/lib/module/reanimated2/mutables.js +2 -4
- package/lib/module/reanimated2/mutables.js.map +1 -1
- package/lib/module/reanimated2/platform-specific/RNRenderer.js.map +1 -1
- package/lib/module/reanimated2/platform-specific/RNRenderer.web.js.map +1 -1
- package/lib/module/reanimated2/platform-specific/checkCppVersion.js.map +1 -1
- package/lib/module/reanimated2/platform-specific/jsVersion.js +1 -1
- package/lib/module/reanimated2/platform-specific/jsVersion.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/dispatchCommand.js +2 -4
- package/lib/module/reanimated2/platformFunctions/dispatchCommand.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/dispatchCommand.web.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/getRelativeCoords.js +2 -2
- package/lib/module/reanimated2/platformFunctions/getRelativeCoords.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/index.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/measure.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/measure.web.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/scrollTo.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/scrollTo.web.js +1 -1
- package/lib/module/reanimated2/platformFunctions/scrollTo.web.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/setGestureState.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/setGestureState.web.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/setNativeProps.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/setNativeProps.web.js.map +1 -1
- package/lib/module/reanimated2/pluginUtils.js.map +1 -1
- package/lib/module/reanimated2/publicGlobals.js.map +1 -1
- package/lib/module/reanimated2/runtimes.js +11 -19
- package/lib/module/reanimated2/runtimes.js.map +1 -1
- package/lib/module/reanimated2/screenTransition/RNScreensTurboModule.js +20 -0
- package/lib/module/reanimated2/screenTransition/RNScreensTurboModule.js.map +1 -0
- package/lib/module/reanimated2/screenTransition/animationManager.js +41 -0
- package/lib/module/reanimated2/screenTransition/animationManager.js.map +1 -0
- package/lib/module/reanimated2/screenTransition/commonTypes.js +4 -0
- package/lib/module/reanimated2/screenTransition/commonTypes.js.map +1 -0
- package/lib/module/reanimated2/screenTransition/index.js +5 -0
- package/lib/module/reanimated2/screenTransition/index.js.map +1 -0
- package/lib/module/reanimated2/screenTransition/presets.js +157 -0
- package/lib/module/reanimated2/screenTransition/presets.js.map +1 -0
- package/lib/module/reanimated2/screenTransition/styleUpdater.js +62 -0
- package/lib/module/reanimated2/screenTransition/styleUpdater.js.map +1 -0
- package/lib/module/reanimated2/screenTransition/swipeSimulator.js +190 -0
- package/lib/module/reanimated2/screenTransition/swipeSimulator.js.map +1 -0
- package/lib/module/reanimated2/shareableMappingCache.js.map +1 -1
- package/lib/module/reanimated2/shareables.js +27 -10
- package/lib/module/reanimated2/shareables.js.map +1 -1
- package/lib/module/reanimated2/threads.js +9 -34
- package/lib/module/reanimated2/threads.js.map +1 -1
- package/lib/module/reanimated2/valueSetter.js +1 -2
- package/lib/module/reanimated2/valueSetter.js.map +1 -1
- package/lib/module/reanimated2/valueUnpacker.js +4 -3
- package/lib/module/reanimated2/valueUnpacker.js.map +1 -1
- package/lib/module/specs/NativeReanimatedModule.js +5 -0
- package/lib/module/specs/NativeReanimatedModule.js.map +1 -0
- package/lib/typescript/ConfigHelper.d.ts +1 -0
- package/lib/typescript/createAnimatedComponent/InlinePropManager.d.ts +1 -1
- package/lib/typescript/createAnimatedComponent/JSPropsUpdater.web.d.ts +6 -0
- package/lib/typescript/createAnimatedComponent/PropsFilter.d.ts +3 -0
- package/lib/typescript/createAnimatedComponent/getViewInfo.d.ts +9 -0
- package/lib/typescript/reanimated2/NativeReanimated/NativeReanimated.d.ts +8 -13
- package/lib/typescript/reanimated2/UpdateLayoutAnimations.d.ts +12 -1
- package/lib/typescript/reanimated2/WorkletEventHandler.d.ts +16 -9
- package/lib/typescript/reanimated2/animation/util.d.ts +2 -0
- package/lib/typescript/reanimated2/component/LayoutAnimationConfig.d.ts +1 -1
- package/lib/typescript/reanimated2/component/PerformanceMonitor.d.ts +2 -0
- package/lib/typescript/reanimated2/core.d.ts +3 -4
- package/lib/typescript/reanimated2/hook/commonTypes.d.ts +6 -0
- package/lib/typescript/reanimated2/hook/useEvent.d.ts +2 -3
- package/lib/typescript/reanimated2/hook/useScrollViewOffset.d.ts +3 -1
- package/lib/typescript/reanimated2/index.d.ts +3 -0
- package/lib/typescript/reanimated2/js-reanimated/JSReanimated.d.ts +2 -2
- package/lib/typescript/reanimated2/layoutReanimation/animationBuilder/commonTypes.d.ts +2 -1
- package/lib/typescript/reanimated2/layoutReanimation/sharedTransitions/ProgressTransitionManager.d.ts +2 -2
- package/lib/typescript/reanimated2/layoutReanimation/sharedTransitions/SharedTransition.d.ts +2 -2
- package/lib/typescript/reanimated2/platform-specific/jsVersion.d.ts +1 -1
- package/lib/typescript/reanimated2/screenTransition/RNScreensTurboModule.d.ts +2 -0
- package/lib/typescript/reanimated2/screenTransition/animationManager.d.ts +3 -0
- package/lib/typescript/reanimated2/screenTransition/commonTypes.d.ts +38 -0
- package/lib/typescript/reanimated2/screenTransition/index.d.ts +3 -0
- package/lib/typescript/reanimated2/screenTransition/presets.d.ts +11 -0
- package/lib/typescript/reanimated2/screenTransition/styleUpdater.d.ts +3 -0
- package/lib/typescript/reanimated2/screenTransition/swipeSimulator.d.ts +2 -0
- package/lib/typescript/specs/NativeReanimatedModule.d.ts +6 -0
- package/package.json +29 -17
- package/plugin/build/plugin.js +7 -2
- package/src/ConfigHelper.ts +1 -1
- package/src/animationBuilder.tsx +2 -0
- package/src/createAnimatedComponent/InlinePropManager.ts +2 -2
- package/src/createAnimatedComponent/JSPropsUpdater.ts +7 -6
- package/src/createAnimatedComponent/JSPropsUpdater.web.ts +26 -0
- package/src/createAnimatedComponent/PropsFilter.tsx +31 -6
- package/src/createAnimatedComponent/createAnimatedComponent.tsx +108 -60
- package/src/createAnimatedComponent/getViewInfo.ts +39 -0
- package/src/mock.ts +13 -1
- package/src/reanimated2/NativeReanimated/NativeReanimated.ts +33 -35
- package/src/reanimated2/PlatformChecker.ts +3 -2
- package/src/reanimated2/PropsRegistry.ts +1 -3
- package/src/reanimated2/UpdateLayoutAnimations.ts +53 -13
- package/src/reanimated2/WorkletEventHandler.ts +98 -39
- package/src/reanimated2/animation/styleAnimation.ts +8 -6
- package/src/reanimated2/animation/timing.ts +9 -1
- package/src/reanimated2/animation/util.ts +28 -3
- package/src/reanimated2/commonTypes.ts +4 -1
- package/src/reanimated2/component/PerformanceMonitor.tsx +216 -0
- package/src/reanimated2/core.ts +9 -31
- package/src/reanimated2/errors.ts +1 -0
- package/src/reanimated2/fabricUtils.ts +43 -18
- package/src/reanimated2/globals.d.ts +11 -1
- package/src/reanimated2/hook/commonTypes.ts +10 -0
- package/src/reanimated2/hook/useAnimatedRef.ts +20 -11
- package/src/reanimated2/hook/useEvent.ts +4 -4
- package/src/reanimated2/hook/useScrollViewOffset.ts +94 -23
- package/src/reanimated2/index.ts +11 -0
- package/src/reanimated2/js-reanimated/JSReanimated.ts +7 -7
- package/src/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.ts +4 -0
- package/src/reanimated2/layoutReanimation/animationBuilder/Keyframe.ts +9 -1
- package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +9 -1
- package/src/reanimated2/layoutReanimation/animationsManager.ts +10 -2
- package/src/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.ts +13 -0
- package/src/reanimated2/layoutReanimation/sharedTransitions/ProgressTransitionManager.ts +17 -8
- package/src/reanimated2/layoutReanimation/sharedTransitions/SharedTransition.ts +26 -7
- package/src/reanimated2/layoutReanimation/web/animationsManager.ts +1 -1
- package/src/reanimated2/layoutReanimation/web/componentStyle.ts +3 -1
- package/src/reanimated2/layoutReanimation/web/componentUtils.ts +1 -1
- package/src/reanimated2/layoutReanimation/web/createAnimation.ts +2 -2
- package/src/reanimated2/platform-specific/jsVersion.ts +1 -1
- package/src/reanimated2/platformFunctions/getRelativeCoords.ts +2 -2
- package/src/reanimated2/screenTransition/RNScreensTurboModule.ts +29 -0
- package/src/reanimated2/screenTransition/animationManager.ts +45 -0
- package/src/reanimated2/screenTransition/commonTypes.ts +63 -0
- package/src/reanimated2/screenTransition/index.ts +12 -0
- package/src/reanimated2/screenTransition/presets.ts +137 -0
- package/src/reanimated2/screenTransition/styleUpdater.ts +73 -0
- package/src/reanimated2/screenTransition/swipeSimulator.ts +238 -0
- package/src/reanimated2/shareables.ts +29 -6
- package/src/reanimated2/valueUnpacker.ts +10 -3
- package/src/specs/NativeReanimatedModule.ts +9 -0
- package/android/src/reactNativeVersionPatch/ReanimatedUIManager/70/com/swmansion/reanimated/ReanimatedUIManagerFactory.java +0 -16
- package/android/src/reactNativeVersionPatch/messageQueueThread/67/com/swmansion/reanimated/ReanimatedMessageQueueThread.java +0 -12
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
import type { NativeSyntheticEvent } from 'react-native';
|
|
3
3
|
import { registerEventHandler, unregisterEventHandler } from './core';
|
|
4
|
-
import type {
|
|
4
|
+
import type {
|
|
5
|
+
EventPayload,
|
|
6
|
+
ReanimatedEvent,
|
|
7
|
+
IWorkletEventHandler,
|
|
8
|
+
} from './hook/commonTypes';
|
|
5
9
|
import { shouldBeUseWeb } from './PlatformChecker';
|
|
6
10
|
|
|
7
11
|
const SHOULD_BE_USE_WEB = shouldBeUseWeb();
|
|
@@ -20,64 +24,119 @@ function jsListener<Event extends object>(
|
|
|
20
24
|
};
|
|
21
25
|
}
|
|
22
26
|
|
|
23
|
-
|
|
27
|
+
class WorkletEventHandlerNative<Event extends object>
|
|
28
|
+
implements IWorkletEventHandler<Event>
|
|
29
|
+
{
|
|
30
|
+
eventNames: string[];
|
|
24
31
|
worklet: (event: ReanimatedEvent<Event>) => void;
|
|
32
|
+
#viewTags: Set<number>;
|
|
33
|
+
#registrations: Map<number, number[]>; // keys are viewTags, values are arrays of registration ID's for each viewTag
|
|
34
|
+
constructor(
|
|
35
|
+
worklet: (event: ReanimatedEvent<Event>) => void,
|
|
36
|
+
eventNames: string[]
|
|
37
|
+
) {
|
|
38
|
+
this.worklet = worklet;
|
|
39
|
+
this.eventNames = eventNames;
|
|
40
|
+
this.#viewTags = new Set<number>();
|
|
41
|
+
this.#registrations = new Map<number, number[]>();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
updateEventHandler(
|
|
45
|
+
newWorklet: (event: ReanimatedEvent<Event>) => void,
|
|
46
|
+
newEvents: string[]
|
|
47
|
+
): void {
|
|
48
|
+
// Update worklet and event names
|
|
49
|
+
this.worklet = newWorklet;
|
|
50
|
+
this.eventNames = newEvents;
|
|
51
|
+
|
|
52
|
+
// Detach all events
|
|
53
|
+
this.#registrations.forEach((registrationIDs) => {
|
|
54
|
+
registrationIDs.forEach((id) => unregisterEventHandler(id));
|
|
55
|
+
// No need to remove registrationIDs from map, since it gets overwritten when attaching
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// Attach new events with new worklet
|
|
59
|
+
Array.from(this.#viewTags).forEach((tag) => {
|
|
60
|
+
const newRegistrations = this.eventNames.map((eventName) =>
|
|
61
|
+
registerEventHandler(this.worklet, eventName, tag)
|
|
62
|
+
);
|
|
63
|
+
this.#registrations.set(tag, newRegistrations);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
registerForEvents(viewTag: number, fallbackEventName?: string): void {
|
|
68
|
+
this.#viewTags.add(viewTag);
|
|
69
|
+
|
|
70
|
+
const newRegistrations = this.eventNames.map((eventName) =>
|
|
71
|
+
registerEventHandler(this.worklet, eventName, viewTag)
|
|
72
|
+
);
|
|
73
|
+
this.#registrations.set(viewTag, newRegistrations);
|
|
74
|
+
|
|
75
|
+
if (this.eventNames.length === 0 && fallbackEventName) {
|
|
76
|
+
const newRegistration = registerEventHandler(
|
|
77
|
+
this.worklet,
|
|
78
|
+
fallbackEventName,
|
|
79
|
+
viewTag
|
|
80
|
+
);
|
|
81
|
+
this.#registrations.set(viewTag, [newRegistration]);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
unregisterFromEvents(viewTag: number): void {
|
|
86
|
+
this.#viewTags.delete(viewTag);
|
|
87
|
+
this.#registrations.get(viewTag)?.forEach((id) => {
|
|
88
|
+
unregisterEventHandler(id);
|
|
89
|
+
});
|
|
90
|
+
this.#registrations.delete(viewTag);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
class WorkletEventHandlerWeb<Event extends object>
|
|
95
|
+
implements IWorkletEventHandler<Event>
|
|
96
|
+
{
|
|
25
97
|
eventNames: string[];
|
|
26
|
-
reattachNeeded: boolean;
|
|
27
98
|
listeners:
|
|
28
99
|
| Record<string, (event: ReanimatedEvent<ReanimatedEvent<Event>>) => void>
|
|
29
100
|
| Record<string, (event: JSEvent<Event>) => void>;
|
|
30
101
|
|
|
31
|
-
|
|
32
|
-
|
|
102
|
+
worklet: (event: ReanimatedEvent<Event>) => void;
|
|
103
|
+
|
|
33
104
|
constructor(
|
|
34
105
|
worklet: (event: ReanimatedEvent<Event>) => void,
|
|
35
106
|
eventNames: string[] = []
|
|
36
107
|
) {
|
|
37
108
|
this.worklet = worklet;
|
|
38
109
|
this.eventNames = eventNames;
|
|
39
|
-
this.reattachNeeded = false;
|
|
40
110
|
this.listeners = {};
|
|
41
|
-
this.
|
|
42
|
-
this.registrations = [];
|
|
43
|
-
|
|
44
|
-
if (SHOULD_BE_USE_WEB) {
|
|
45
|
-
this.listeners = eventNames.reduce(
|
|
46
|
-
(
|
|
47
|
-
acc: Record<string, (event: JSEvent<Event>) => void>,
|
|
48
|
-
eventName: string
|
|
49
|
-
) => {
|
|
50
|
-
acc[eventName] = jsListener(eventName, worklet);
|
|
51
|
-
return acc;
|
|
52
|
-
},
|
|
53
|
-
{}
|
|
54
|
-
);
|
|
55
|
-
}
|
|
111
|
+
this.setupWebListeners();
|
|
56
112
|
}
|
|
57
113
|
|
|
58
|
-
|
|
59
|
-
this.
|
|
60
|
-
this.
|
|
114
|
+
setupWebListeners() {
|
|
115
|
+
this.listeners = {};
|
|
116
|
+
this.eventNames.forEach((eventName) => {
|
|
117
|
+
this.listeners[eventName] = jsListener(eventName, this.worklet);
|
|
118
|
+
});
|
|
61
119
|
}
|
|
62
120
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
);
|
|
72
|
-
}
|
|
121
|
+
updateEventHandler(
|
|
122
|
+
newWorklet: (event: ReanimatedEvent<Event>) => void,
|
|
123
|
+
newEvents: string[]
|
|
124
|
+
): void {
|
|
125
|
+
// Update worklet and event names
|
|
126
|
+
this.worklet = newWorklet;
|
|
127
|
+
this.eventNames = newEvents;
|
|
128
|
+
this.setupWebListeners();
|
|
73
129
|
}
|
|
74
130
|
|
|
75
|
-
|
|
76
|
-
|
|
131
|
+
registerForEvents(_viewTag: number, _fallbackEventName?: string): void {
|
|
132
|
+
// noop
|
|
77
133
|
}
|
|
78
134
|
|
|
79
|
-
unregisterFromEvents(): void {
|
|
80
|
-
|
|
81
|
-
this.registrations = [];
|
|
135
|
+
unregisterFromEvents(_viewTag: number): void {
|
|
136
|
+
// noop
|
|
82
137
|
}
|
|
83
138
|
}
|
|
139
|
+
|
|
140
|
+
export const WorkletEventHandler = SHOULD_BE_USE_WEB
|
|
141
|
+
? WorkletEventHandlerWeb
|
|
142
|
+
: WorkletEventHandlerNative;
|
|
@@ -125,16 +125,18 @@ export function withStyleAnimation(
|
|
|
125
125
|
stillGoing = true;
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
128
|
+
// When working with animations changing colors, we need to make sure that each one of them begins with a rgba, not a processed number.
|
|
129
|
+
// Thus, we only set the path to a processed color, but currentStyleAnimation.current stays as rgba.
|
|
130
|
+
const isAnimatingColorProp = ColorProperties.includes(
|
|
131
|
+
currentEntry.path[0] as string
|
|
132
|
+
);
|
|
133
133
|
|
|
134
134
|
setPath(
|
|
135
135
|
animation.current,
|
|
136
136
|
currentEntry.path,
|
|
137
|
-
|
|
137
|
+
isAnimatingColorProp
|
|
138
|
+
? processColor(currentStyleAnimation.current)
|
|
139
|
+
: currentStyleAnimation.current
|
|
138
140
|
);
|
|
139
141
|
}
|
|
140
142
|
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
import type { EasingFunction, EasingFunctionFactory } from '../Easing';
|
|
3
3
|
import { Easing } from '../Easing';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
assertEasingIsWorklet,
|
|
6
|
+
defineAnimation,
|
|
7
|
+
getReduceMotionForAnimation,
|
|
8
|
+
} from './util';
|
|
5
9
|
import type {
|
|
6
10
|
Animation,
|
|
7
11
|
AnimationCallback,
|
|
@@ -65,6 +69,10 @@ export const withTiming = function (
|
|
|
65
69
|
): Animation<TimingAnimation> {
|
|
66
70
|
'worklet';
|
|
67
71
|
|
|
72
|
+
if (__DEV__ && userConfig?.easing) {
|
|
73
|
+
assertEasingIsWorklet(userConfig.easing);
|
|
74
|
+
}
|
|
75
|
+
|
|
68
76
|
return defineAnimation<TimingAnimation>(toValue, () => {
|
|
69
77
|
'worklet';
|
|
70
78
|
const config: Required<Omit<TimingConfig, 'reduceMotion'>> = {
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
toGammaSpace,
|
|
10
10
|
toLinearSpace,
|
|
11
11
|
} from '../Colors';
|
|
12
|
-
import { ReduceMotion } from '../commonTypes';
|
|
12
|
+
import { ReduceMotion, isWorkletFunction } from '../commonTypes';
|
|
13
13
|
import type {
|
|
14
14
|
SharedValue,
|
|
15
15
|
AnimatableValue,
|
|
@@ -33,9 +33,11 @@ import {
|
|
|
33
33
|
getRotationMatrix,
|
|
34
34
|
} from './transformationMatrix/matrixUtils';
|
|
35
35
|
import { isReducedMotion, shouldBeUseWeb } from '../PlatformChecker';
|
|
36
|
+
import type { EasingFunction, EasingFunctionFactory } from '../Easing';
|
|
36
37
|
|
|
37
38
|
let IN_STYLE_UPDATER = false;
|
|
38
39
|
const IS_REDUCED_MOTION = isReducedMotion();
|
|
40
|
+
const SHOULD_BE_USE_WEB = shouldBeUseWeb();
|
|
39
41
|
|
|
40
42
|
if (__DEV__ && IS_REDUCED_MOTION) {
|
|
41
43
|
console.warn(
|
|
@@ -43,6 +45,31 @@ if (__DEV__ && IS_REDUCED_MOTION) {
|
|
|
43
45
|
);
|
|
44
46
|
}
|
|
45
47
|
|
|
48
|
+
export function assertEasingIsWorklet(
|
|
49
|
+
easing: EasingFunction | EasingFunctionFactory
|
|
50
|
+
): void {
|
|
51
|
+
'worklet';
|
|
52
|
+
if (_WORKLET) {
|
|
53
|
+
// If this is called on UI (for example from gesture handler with worklets), we don't get easing,
|
|
54
|
+
// but its bound copy, which is not a worklet. We don't want to throw any error then.
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (SHOULD_BE_USE_WEB) {
|
|
58
|
+
// It is possible to run reanimated on web without plugin, so let's skip this check on web
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
// @ts-ignore typescript wants us to use `in` instead, which doesn't work with host objects
|
|
62
|
+
if (easing?.factory) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (!isWorkletFunction(easing)) {
|
|
67
|
+
throw new Error(
|
|
68
|
+
'[Reanimated] The easing function is not a worklet. Please make sure you import `Easing` from react-native-reanimated.'
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
46
73
|
export function initialUpdaterRun<T>(updater: () => T) {
|
|
47
74
|
IN_STYLE_UPDATER = true;
|
|
48
75
|
const result = updater();
|
|
@@ -478,8 +505,6 @@ type AnimationToDecoration<
|
|
|
478
505
|
? Record<string, unknown>
|
|
479
506
|
: U | (() => U) | AnimatableValue;
|
|
480
507
|
|
|
481
|
-
const SHOULD_BE_USE_WEB = shouldBeUseWeb();
|
|
482
|
-
|
|
483
508
|
export function defineAnimation<
|
|
484
509
|
T extends AnimationObject | StyleLayoutAnimation, // type that's supposed to be returned
|
|
485
510
|
U extends AnimationObject | StyleLayoutAnimation = T // type that's received
|
|
@@ -131,7 +131,10 @@ export function isWorkletFunction<
|
|
|
131
131
|
'worklet';
|
|
132
132
|
// Since host objects always return true for `in` operator, we have to use dot notation to check if the property exists.
|
|
133
133
|
// See https://github.com/facebook/hermes/blob/340726ef8cf666a7cce75bc60b02fa56b3e54560/lib/VM/JSObject.cpp#L1276.
|
|
134
|
-
return
|
|
134
|
+
return (
|
|
135
|
+
typeof value === 'function' &&
|
|
136
|
+
!!(value as unknown as Record<string, unknown>).__workletHash
|
|
137
|
+
);
|
|
135
138
|
}
|
|
136
139
|
|
|
137
140
|
export type AnimatedPropsAdapterFunction = (
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
import React, { useEffect, useRef } from 'react';
|
|
4
|
+
import { TextInput, StyleSheet, View } from 'react-native';
|
|
5
|
+
|
|
6
|
+
import type { FrameInfo } from '../frameCallback';
|
|
7
|
+
import type { SharedValue } from '../commonTypes';
|
|
8
|
+
import { useSharedValue, useAnimatedProps, useFrameCallback } from '../hook';
|
|
9
|
+
import { createAnimatedComponent } from '../../createAnimatedComponent';
|
|
10
|
+
import { addWhitelistedNativeProps } from '../../ConfigHelper';
|
|
11
|
+
|
|
12
|
+
type CircularBuffer = ReturnType<typeof createCircularDoublesBuffer>;
|
|
13
|
+
function createCircularDoublesBuffer(size: number) {
|
|
14
|
+
'worklet';
|
|
15
|
+
|
|
16
|
+
return {
|
|
17
|
+
next: 0 as number,
|
|
18
|
+
buffer: new Float32Array(size),
|
|
19
|
+
size,
|
|
20
|
+
count: 0 as number,
|
|
21
|
+
|
|
22
|
+
push(value: number): number | null {
|
|
23
|
+
const oldValue = this.buffer[this.next];
|
|
24
|
+
const oldCount = this.count;
|
|
25
|
+
this.buffer[this.next] = value;
|
|
26
|
+
|
|
27
|
+
this.next = (this.next + 1) % this.size;
|
|
28
|
+
this.count = Math.min(this.size, this.count + 1);
|
|
29
|
+
return oldCount === this.size ? oldValue : null;
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
front(): number | null {
|
|
33
|
+
const notEmpty = this.count > 0;
|
|
34
|
+
if (notEmpty) {
|
|
35
|
+
const current = this.next - 1;
|
|
36
|
+
const index = current < 0 ? this.size - 1 : current;
|
|
37
|
+
return this.buffer[index];
|
|
38
|
+
}
|
|
39
|
+
return null;
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
back(): number | null {
|
|
43
|
+
const notEmpty = this.count > 0;
|
|
44
|
+
return notEmpty ? this.buffer[this.next] : null;
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const DEFAULT_BUFFER_SIZE = 60;
|
|
50
|
+
addWhitelistedNativeProps({ text: true });
|
|
51
|
+
const AnimatedTextInput = createAnimatedComponent(TextInput);
|
|
52
|
+
|
|
53
|
+
function loopAnimationFrame(fn: (lastTime: number, time: number) => void) {
|
|
54
|
+
let lastTime = 0;
|
|
55
|
+
|
|
56
|
+
function loop() {
|
|
57
|
+
requestAnimationFrame((time) => {
|
|
58
|
+
if (lastTime > 0) {
|
|
59
|
+
fn(lastTime, time);
|
|
60
|
+
}
|
|
61
|
+
lastTime = time;
|
|
62
|
+
requestAnimationFrame(loop);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
loop();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function getFps(renderTimeInMs: number): number {
|
|
70
|
+
'worklet';
|
|
71
|
+
return 1000 / renderTimeInMs;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function getTimeDelta(
|
|
75
|
+
timestamp: number,
|
|
76
|
+
previousTimestamp: number | null
|
|
77
|
+
): number {
|
|
78
|
+
'worklet';
|
|
79
|
+
return previousTimestamp !== null ? timestamp - previousTimestamp : 0;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function completeBufferRoutine(
|
|
83
|
+
buffer: CircularBuffer,
|
|
84
|
+
timestamp: number,
|
|
85
|
+
previousTimestamp: number,
|
|
86
|
+
totalRenderTime: SharedValue<number>
|
|
87
|
+
): number {
|
|
88
|
+
'worklet';
|
|
89
|
+
timestamp = Math.round(timestamp);
|
|
90
|
+
previousTimestamp = Math.round(previousTimestamp) ?? timestamp;
|
|
91
|
+
|
|
92
|
+
const droppedTimestamp = buffer.push(timestamp);
|
|
93
|
+
const nextToDrop = buffer.back()!;
|
|
94
|
+
|
|
95
|
+
const delta = getTimeDelta(timestamp, previousTimestamp);
|
|
96
|
+
const droppedDelta = getTimeDelta(nextToDrop, droppedTimestamp);
|
|
97
|
+
|
|
98
|
+
totalRenderTime.value += delta - droppedDelta;
|
|
99
|
+
|
|
100
|
+
return getFps(totalRenderTime.value / buffer.count);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function JsPerformance() {
|
|
104
|
+
const jsFps = useSharedValue<string | null>(null);
|
|
105
|
+
const totalRenderTime = useSharedValue(0);
|
|
106
|
+
const circularBuffer = useRef<CircularBuffer>(
|
|
107
|
+
createCircularDoublesBuffer(DEFAULT_BUFFER_SIZE)
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
useEffect(() => {
|
|
111
|
+
loopAnimationFrame((_, timestamp) => {
|
|
112
|
+
timestamp = Math.round(timestamp);
|
|
113
|
+
const previousTimestamp = circularBuffer.current.front() ?? timestamp;
|
|
114
|
+
|
|
115
|
+
const currentFps = completeBufferRoutine(
|
|
116
|
+
circularBuffer.current,
|
|
117
|
+
timestamp,
|
|
118
|
+
previousTimestamp,
|
|
119
|
+
totalRenderTime
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
// JS fps have to be measured every 2nd frame,
|
|
123
|
+
// thus 2x multiplication has to occur here
|
|
124
|
+
jsFps.value = (currentFps * 2).toFixed(0);
|
|
125
|
+
});
|
|
126
|
+
}, []);
|
|
127
|
+
|
|
128
|
+
const animatedProps = useAnimatedProps(() => {
|
|
129
|
+
const text = 'JS: ' + jsFps.value ?? 'N/A';
|
|
130
|
+
return { text, defaultValue: text };
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
return (
|
|
134
|
+
<View style={styles.container}>
|
|
135
|
+
<AnimatedTextInput
|
|
136
|
+
style={styles.text}
|
|
137
|
+
animatedProps={animatedProps}
|
|
138
|
+
editable={false}
|
|
139
|
+
/>
|
|
140
|
+
</View>
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function UiPerformance() {
|
|
145
|
+
const uiFps = useSharedValue<string | null>(null);
|
|
146
|
+
const totalRenderTime = useSharedValue(0);
|
|
147
|
+
const circularBuffer = useSharedValue<CircularBuffer | null>(null);
|
|
148
|
+
|
|
149
|
+
useFrameCallback(({ timestamp }: FrameInfo) => {
|
|
150
|
+
if (circularBuffer.value === null) {
|
|
151
|
+
circularBuffer.value = createCircularDoublesBuffer(DEFAULT_BUFFER_SIZE);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
timestamp = Math.round(timestamp);
|
|
155
|
+
const previousTimestamp = circularBuffer.value.front() ?? timestamp;
|
|
156
|
+
|
|
157
|
+
const currentFps = completeBufferRoutine(
|
|
158
|
+
circularBuffer.value,
|
|
159
|
+
timestamp,
|
|
160
|
+
previousTimestamp,
|
|
161
|
+
totalRenderTime
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
uiFps.value = currentFps.toFixed(0);
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
const animatedProps = useAnimatedProps(() => {
|
|
168
|
+
const text = 'UI: ' + uiFps.value ?? 'N/A';
|
|
169
|
+
return { text, defaultValue: text };
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
return (
|
|
173
|
+
<View style={styles.container}>
|
|
174
|
+
<AnimatedTextInput
|
|
175
|
+
style={styles.text}
|
|
176
|
+
animatedProps={animatedProps}
|
|
177
|
+
editable={false}
|
|
178
|
+
/>
|
|
179
|
+
</View>
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export function PerformanceMonitor() {
|
|
184
|
+
return (
|
|
185
|
+
<View style={styles.monitor}>
|
|
186
|
+
<JsPerformance />
|
|
187
|
+
<UiPerformance />
|
|
188
|
+
</View>
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const styles = StyleSheet.create({
|
|
193
|
+
monitor: {
|
|
194
|
+
flexDirection: 'row',
|
|
195
|
+
position: 'absolute',
|
|
196
|
+
backgroundColor: '#0006',
|
|
197
|
+
zIndex: 1000,
|
|
198
|
+
},
|
|
199
|
+
header: {
|
|
200
|
+
fontSize: 14,
|
|
201
|
+
color: '#ffff',
|
|
202
|
+
paddingHorizontal: 5,
|
|
203
|
+
},
|
|
204
|
+
text: {
|
|
205
|
+
fontSize: 13,
|
|
206
|
+
color: '#ffff',
|
|
207
|
+
fontFamily: 'monospace',
|
|
208
|
+
paddingHorizontal: 3,
|
|
209
|
+
},
|
|
210
|
+
container: {
|
|
211
|
+
alignItems: 'center',
|
|
212
|
+
justifyContent: 'center',
|
|
213
|
+
flexDirection: 'row',
|
|
214
|
+
flexWrap: 'wrap',
|
|
215
|
+
},
|
|
216
|
+
});
|
package/src/reanimated2/core.ts
CHANGED
|
@@ -10,16 +10,8 @@ import type {
|
|
|
10
10
|
ValueRotation,
|
|
11
11
|
} from './commonTypes';
|
|
12
12
|
import { makeShareableCloneRecursive } from './shareables';
|
|
13
|
-
import type {
|
|
14
|
-
LayoutAnimationFunction,
|
|
15
|
-
LayoutAnimationType,
|
|
16
|
-
} from './layoutReanimation';
|
|
17
13
|
import { initializeUIRuntime } from './initializers';
|
|
18
|
-
import type {
|
|
19
|
-
LayoutAnimationBatchItem,
|
|
20
|
-
ProgressAnimationCallback,
|
|
21
|
-
SharedTransitionAnimationsFunction,
|
|
22
|
-
} from './layoutReanimation/animationBuilder/commonTypes';
|
|
14
|
+
import type { LayoutAnimationBatchItem } from './layoutReanimation/animationBuilder/commonTypes';
|
|
23
15
|
import { SensorContainer } from './SensorContainer';
|
|
24
16
|
|
|
25
17
|
export { startMapper, stopMapper } from './mappers';
|
|
@@ -29,7 +21,6 @@ export type { WorkletRuntime } from './runtimes';
|
|
|
29
21
|
export { makeShareable, makeShareableCloneRecursive } from './shareables';
|
|
30
22
|
export { makeMutable } from './mutables';
|
|
31
23
|
|
|
32
|
-
const IS_FABRIC = isFabric();
|
|
33
24
|
const SHOULD_BE_USE_WEB = shouldBeUseWeb();
|
|
34
25
|
|
|
35
26
|
/**
|
|
@@ -55,10 +46,14 @@ if (SHOULD_BE_USE_WEB) {
|
|
|
55
46
|
global._getAnimationTimestamp = () => performance.now();
|
|
56
47
|
}
|
|
57
48
|
|
|
58
|
-
export function getViewProp<T>(
|
|
59
|
-
|
|
49
|
+
export function getViewProp<T>(
|
|
50
|
+
viewTag: number,
|
|
51
|
+
propName: string,
|
|
52
|
+
component?: React.Component // required on Fabric
|
|
53
|
+
): Promise<T> {
|
|
54
|
+
if (isFabric() && !component) {
|
|
60
55
|
throw new Error(
|
|
61
|
-
'[Reanimated] `getViewProp`
|
|
56
|
+
'[Reanimated] Function `getViewProp` requires a component to be passed as an argument on Fabric.'
|
|
62
57
|
);
|
|
63
58
|
}
|
|
64
59
|
|
|
@@ -67,6 +62,7 @@ export function getViewProp<T>(viewTag: number, propName: string): Promise<T> {
|
|
|
67
62
|
return NativeReanimatedModule.getViewProp(
|
|
68
63
|
viewTag,
|
|
69
64
|
propName,
|
|
65
|
+
component,
|
|
70
66
|
(result: T) => {
|
|
71
67
|
if (typeof result === 'string' && result.substr(0, 6) === 'error:') {
|
|
72
68
|
reject(result);
|
|
@@ -194,24 +190,6 @@ export function enableLayoutAnimations(
|
|
|
194
190
|
}
|
|
195
191
|
}
|
|
196
192
|
|
|
197
|
-
export function configureLayoutAnimations(
|
|
198
|
-
viewTag: number | HTMLElement,
|
|
199
|
-
type: LayoutAnimationType,
|
|
200
|
-
config:
|
|
201
|
-
| LayoutAnimationFunction
|
|
202
|
-
| Keyframe
|
|
203
|
-
| SharedTransitionAnimationsFunction
|
|
204
|
-
| ProgressAnimationCallback,
|
|
205
|
-
sharedTransitionTag = ''
|
|
206
|
-
): void {
|
|
207
|
-
NativeReanimatedModule.configureLayoutAnimation(
|
|
208
|
-
viewTag as number, // On web this function is no-op, therefore we can cast viewTag to number
|
|
209
|
-
type,
|
|
210
|
-
sharedTransitionTag,
|
|
211
|
-
makeShareableCloneRecursive(config)
|
|
212
|
-
);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
193
|
export function configureLayoutAnimationBatch(
|
|
216
194
|
layoutAnimationsBatch: LayoutAnimationBatchItem[]
|
|
217
195
|
): void {
|
|
@@ -56,4 +56,5 @@ export function reportFatalErrorOnJS({
|
|
|
56
56
|
error.jsEngine = 'reanimated';
|
|
57
57
|
// @ts-ignore the reportFatalError method is an internal method of ErrorUtils not exposed in the type definitions
|
|
58
58
|
global.ErrorUtils.reportFatalError(error);
|
|
59
|
+
console.error(error.stack);
|
|
59
60
|
}
|
|
@@ -1,33 +1,58 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
/* eslint-disable
|
|
2
|
+
/* eslint-disable */
|
|
3
3
|
|
|
4
|
-
import { isFabric } from './PlatformChecker';
|
|
5
4
|
import type { ShadowNodeWrapper } from './commonTypes';
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
let findHostInstance_DEPRECATED: (ref: React.Component) => HostInstance;
|
|
6
|
+
let findHostInstance_DEPRECATED: (ref: unknown) => void;
|
|
7
|
+
let getInternalInstanceHandleFromPublicInstance: (ref: unknown) => {
|
|
8
|
+
stateNode: { node: unknown };
|
|
9
|
+
};
|
|
16
10
|
|
|
17
11
|
export function getShadowNodeWrapperFromRef(
|
|
18
12
|
ref: React.Component
|
|
19
13
|
): ShadowNodeWrapper {
|
|
20
|
-
|
|
14
|
+
// load findHostInstance_DEPRECATED lazily because it may not be available before render
|
|
15
|
+
if (findHostInstance_DEPRECATED === undefined) {
|
|
21
16
|
try {
|
|
22
17
|
findHostInstance_DEPRECATED =
|
|
23
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
24
18
|
require('react-native/Libraries/Renderer/shims/ReactFabric').findHostInstance_DEPRECATED;
|
|
25
19
|
} catch (e) {
|
|
26
|
-
|
|
27
|
-
'[Reanimated] Cannot import `findHostInstance_DEPRECATED`.'
|
|
28
|
-
);
|
|
20
|
+
findHostInstance_DEPRECATED = (_ref: unknown) => null;
|
|
29
21
|
}
|
|
30
22
|
}
|
|
31
|
-
|
|
32
|
-
|
|
23
|
+
|
|
24
|
+
if (getInternalInstanceHandleFromPublicInstance === undefined) {
|
|
25
|
+
try {
|
|
26
|
+
getInternalInstanceHandleFromPublicInstance =
|
|
27
|
+
require('react-native/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance')
|
|
28
|
+
.getInternalInstanceHandleFromPublicInstance ??
|
|
29
|
+
((_ref: any) => _ref._internalInstanceHandle);
|
|
30
|
+
} catch (e) {
|
|
31
|
+
getInternalInstanceHandleFromPublicInstance = (_ref: any) =>
|
|
32
|
+
_ref._internalInstanceHandle;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// taken from https://github.com/facebook/react-native/commit/803bb16531697233686efd475f004c1643e03617#diff-d8172256c6d63b5d32db10e54d7b10f37a26b337d5280d89f5bfd7bcea778292R196
|
|
37
|
+
// @ts-ignore some weird stuff on RN 0.74 - see examples with scrollView
|
|
38
|
+
const scrollViewRef = ref?.getScrollResponder?.()?.getNativeScrollRef?.();
|
|
39
|
+
// @ts-ignore some weird stuff on RN 0.74 - see examples with scrollView
|
|
40
|
+
const otherScrollViewRef = ref?.getNativeScrollRef?.();
|
|
41
|
+
// @ts-ignore some weird stuff on RN 0.74 - see setNativeProps example
|
|
42
|
+
const textInputRef = ref?.__internalInstanceHandle?.stateNode?.node;
|
|
43
|
+
|
|
44
|
+
let resolvedRef;
|
|
45
|
+
if (scrollViewRef) {
|
|
46
|
+
resolvedRef = scrollViewRef.__internalInstanceHandle.stateNode.node;
|
|
47
|
+
} else if (otherScrollViewRef) {
|
|
48
|
+
resolvedRef = otherScrollViewRef.__internalInstanceHandle.stateNode.node;
|
|
49
|
+
} else if (textInputRef) {
|
|
50
|
+
resolvedRef = textInputRef;
|
|
51
|
+
} else {
|
|
52
|
+
resolvedRef = getInternalInstanceHandleFromPublicInstance(
|
|
53
|
+
findHostInstance_DEPRECATED(ref)
|
|
54
|
+
).stateNode.node;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return resolvedRef;
|
|
33
58
|
}
|