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
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
2
|
import { startMapper, stopMapper } from '../core';
|
|
3
3
|
import { useSharedValue } from './useSharedValue';
|
|
4
|
+
import { shouldBeUseWeb } from '../PlatformChecker';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* @param prepare - worklet used for data preparation for the second parameter
|
|
@@ -10,6 +11,16 @@ import { useSharedValue } from './useSharedValue';
|
|
|
10
11
|
*/
|
|
11
12
|
export function useAnimatedReaction(prepare, react, dependencies) {
|
|
12
13
|
const previous = useSharedValue(null);
|
|
14
|
+
let inputs = Object.values(prepare._closure ?? {});
|
|
15
|
+
|
|
16
|
+
if (shouldBeUseWeb()) {
|
|
17
|
+
var _dependencies;
|
|
18
|
+
|
|
19
|
+
if (!inputs.length && (_dependencies = dependencies) !== null && _dependencies !== void 0 && _dependencies.length) {
|
|
20
|
+
// let web work without a Babel/SWC plugin
|
|
21
|
+
inputs = dependencies;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
13
24
|
|
|
14
25
|
if (dependencies === undefined) {
|
|
15
26
|
dependencies = [Object.values(prepare._closure ?? {}), Object.values(react._closure ?? {}), prepare.__workletHash, react.__workletHash];
|
|
@@ -26,7 +37,7 @@ export function useAnimatedReaction(prepare, react, dependencies) {
|
|
|
26
37
|
previous.value = input;
|
|
27
38
|
};
|
|
28
39
|
|
|
29
|
-
const mapperId = startMapper(fun,
|
|
40
|
+
const mapperId = startMapper(fun, inputs, []);
|
|
30
41
|
return () => {
|
|
31
42
|
stopMapper(mapperId);
|
|
32
43
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","startMapper","stopMapper","useSharedValue","useAnimatedReaction","prepare","react","dependencies","previous","
|
|
1
|
+
{"version":3,"names":["useEffect","startMapper","stopMapper","useSharedValue","shouldBeUseWeb","useAnimatedReaction","prepare","react","dependencies","previous","inputs","Object","values","_closure","length","undefined","__workletHash","push","fun","input","value","mapperId"],"sources":["useAnimatedReaction.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport { BasicWorkletFunction, WorkletFunction } from '../commonTypes';\nimport { startMapper, stopMapper } from '../core';\nimport { DependencyList } from './commonTypes';\nimport { useSharedValue } from './useSharedValue';\nimport { shouldBeUseWeb } from '../PlatformChecker';\n\nexport interface AnimatedReactionWorkletFunction<T> extends WorkletFunction {\n (prepared: T, previous: T | null): void;\n}\n/**\n * @param prepare - worklet used for data preparation for the second parameter\n * @param react - worklet which takes data prepared by the one in the first parameter and performs certain actions\n * the first worklet defines the inputs, in other words on which shared values change will it be called.\n * the second one can modify any shared values but those which are mentioned in the first worklet. Beware of that, because this may result in endless loop and high cpu usage.\n */\nexport function useAnimatedReaction<T>(\n prepare: BasicWorkletFunction<T>,\n react: AnimatedReactionWorkletFunction<T>,\n dependencies: DependencyList\n): void {\n const previous = useSharedValue<T | null>(null);\n\n let inputs = Object.values(prepare._closure ?? {});\n\n if (shouldBeUseWeb()) {\n if (!inputs.length && dependencies?.length) {\n // let web work without a Babel/SWC plugin\n inputs = dependencies;\n }\n }\n\n if (dependencies === undefined) {\n dependencies = [\n Object.values(prepare._closure ?? {}),\n Object.values(react._closure ?? {}),\n prepare.__workletHash,\n react.__workletHash,\n ];\n } else {\n dependencies.push(prepare.__workletHash, react.__workletHash);\n }\n\n useEffect(() => {\n const fun = () => {\n 'worklet';\n const input = prepare();\n react(input, previous.value);\n previous.value = input;\n };\n const mapperId = startMapper(fun, inputs, []);\n return () => {\n stopMapper(mapperId);\n };\n }, dependencies);\n}\n"],"mappings":"AAAA,SAASA,SAAT,QAA0B,OAA1B;AAEA,SAASC,WAAT,EAAsBC,UAAtB,QAAwC,SAAxC;AAEA,SAASC,cAAT,QAA+B,kBAA/B;AACA,SAASC,cAAT,QAA+B,oBAA/B;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,mBAAT,CACLC,OADK,EAELC,KAFK,EAGLC,YAHK,EAIC;EACN,MAAMC,QAAQ,GAAGN,cAAc,CAAW,IAAX,CAA/B;EAEA,IAAIO,MAAM,GAAGC,MAAM,CAACC,MAAP,CAAcN,OAAO,CAACO,QAAR,IAAoB,EAAlC,CAAb;;EAEA,IAAIT,cAAc,EAAlB,EAAsB;IAAA;;IACpB,IAAI,CAACM,MAAM,CAACI,MAAR,qBAAkBN,YAAlB,0CAAkB,cAAcM,MAApC,EAA4C;MAC1C;MACAJ,MAAM,GAAGF,YAAT;IACD;EACF;;EAED,IAAIA,YAAY,KAAKO,SAArB,EAAgC;IAC9BP,YAAY,GAAG,CACbG,MAAM,CAACC,MAAP,CAAcN,OAAO,CAACO,QAAR,IAAoB,EAAlC,CADa,EAEbF,MAAM,CAACC,MAAP,CAAcL,KAAK,CAACM,QAAN,IAAkB,EAAhC,CAFa,EAGbP,OAAO,CAACU,aAHK,EAIbT,KAAK,CAACS,aAJO,CAAf;EAMD,CAPD,MAOO;IACLR,YAAY,CAACS,IAAb,CAAkBX,OAAO,CAACU,aAA1B,EAAyCT,KAAK,CAACS,aAA/C;EACD;;EAEDhB,SAAS,CAAC,MAAM;IACd,MAAMkB,GAAG,GAAG,MAAM;MAChB;;MACA,MAAMC,KAAK,GAAGb,OAAO,EAArB;MACAC,KAAK,CAACY,KAAD,EAAQV,QAAQ,CAACW,KAAjB,CAAL;MACAX,QAAQ,CAACW,KAAT,GAAiBD,KAAjB;IACD,CALD;;IAMA,MAAME,QAAQ,GAAGpB,WAAW,CAACiB,GAAD,EAAMR,MAAN,EAAc,EAAd,CAA5B;IACA,OAAO,MAAM;MACXR,UAAU,CAACmB,QAAD,CAAV;IACD,CAFD;EAGD,CAXQ,EAWNb,YAXM,CAAT;AAYD"}
|
|
@@ -2,10 +2,10 @@ import { useRef } from 'react';
|
|
|
2
2
|
import { useSharedValue } from './useSharedValue';
|
|
3
3
|
import { getTag } from '../NativeMethods';
|
|
4
4
|
import { getShadowNodeWrapperFromHostInstance } from '../fabricUtils';
|
|
5
|
-
import { makeShareableCloneRecursive,
|
|
5
|
+
import { makeShareableCloneRecursive, registerShareableMapping } from '../shareables';
|
|
6
6
|
|
|
7
7
|
function getShareableShadowNodeFromComponent(component) {
|
|
8
|
-
return
|
|
8
|
+
return getShadowNodeWrapperFromHostInstance(component);
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
const getTagValueFunction = global._IS_FABRIC ? getShareableShadowNodeFromComponent : getTag;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useRef","useSharedValue","getTag","getShadowNodeWrapperFromHostInstance","makeShareableCloneRecursive","
|
|
1
|
+
{"version":3,"names":["useRef","useSharedValue","getTag","getShadowNodeWrapperFromHostInstance","makeShareableCloneRecursive","registerShareableMapping","getShareableShadowNodeFromComponent","component","getTagValueFunction","global","_IS_FABRIC","useAnimatedRef","tag","ref","current","fun","value","remoteRef","__init"],"sources":["useAnimatedRef.ts"],"sourcesContent":["import { Component, useRef } from 'react';\nimport { useSharedValue } from './useSharedValue';\nimport { RefObjectFunction } from './commonTypes';\nimport { ShadowNodeWrapper } from '../commonTypes';\nimport { getTag } from '../NativeMethods';\nimport { getShadowNodeWrapperFromHostInstance } from '../fabricUtils';\nimport {\n makeShareableCloneRecursive,\n registerShareableMapping,\n} from '../shareables';\n\nfunction getShareableShadowNodeFromComponent(\n component: Component\n): ShadowNodeWrapper {\n return getShadowNodeWrapperFromHostInstance(component);\n}\n\nconst getTagValueFunction = global._IS_FABRIC\n ? getShareableShadowNodeFromComponent\n : getTag;\n\nexport function useAnimatedRef<T extends Component>(): RefObjectFunction<T> {\n const tag = useSharedValue<number | ShadowNodeWrapper | null>(-1);\n const ref = useRef<RefObjectFunction<T>>();\n\n if (!ref.current) {\n const fun: RefObjectFunction<T> = <RefObjectFunction<T>>((component) => {\n // enters when ref is set by attaching to a component\n if (component) {\n tag.value = getTagValueFunction(component);\n fun.current = component;\n }\n return tag.value;\n });\n\n fun.current = null;\n\n const remoteRef = makeShareableCloneRecursive({\n __init: () => {\n 'worklet';\n return () => tag.value;\n },\n });\n registerShareableMapping(fun, remoteRef);\n\n ref.current = fun;\n }\n\n return ref.current;\n}\n"],"mappings":"AAAA,SAAoBA,MAApB,QAAkC,OAAlC;AACA,SAASC,cAAT,QAA+B,kBAA/B;AAGA,SAASC,MAAT,QAAuB,kBAAvB;AACA,SAASC,oCAAT,QAAqD,gBAArD;AACA,SACEC,2BADF,EAEEC,wBAFF,QAGO,eAHP;;AAKA,SAASC,mCAAT,CACEC,SADF,EAEqB;EACnB,OAAOJ,oCAAoC,CAACI,SAAD,CAA3C;AACD;;AAED,MAAMC,mBAAmB,GAAGC,MAAM,CAACC,UAAP,GACxBJ,mCADwB,GAExBJ,MAFJ;AAIA,OAAO,SAASS,cAAT,GAAqE;EAC1E,MAAMC,GAAG,GAAGX,cAAc,CAAoC,CAAC,CAArC,CAA1B;EACA,MAAMY,GAAG,GAAGb,MAAM,EAAlB;;EAEA,IAAI,CAACa,GAAG,CAACC,OAAT,EAAkB;IAChB,MAAMC,GAAyB,GAA2BR,SAAD,IAAe;MACtE;MACA,IAAIA,SAAJ,EAAe;QACbK,GAAG,CAACI,KAAJ,GAAYR,mBAAmB,CAACD,SAAD,CAA/B;QACAQ,GAAG,CAACD,OAAJ,GAAcP,SAAd;MACD;;MACD,OAAOK,GAAG,CAACI,KAAX;IACD,CAPD;;IASAD,GAAG,CAACD,OAAJ,GAAc,IAAd;IAEA,MAAMG,SAAS,GAAGb,2BAA2B,CAAC;MAC5Cc,MAAM,EAAE,MAAM;QACZ;;QACA,OAAO,MAAMN,GAAG,CAACI,KAAjB;MACD;IAJ2C,CAAD,CAA7C;IAMAX,wBAAwB,CAACU,GAAD,EAAME,SAAN,CAAxB;IAEAJ,GAAG,CAACC,OAAJ,GAAcC,GAAd;EACD;;EAED,OAAOF,GAAG,CAACC,OAAX;AACD"}
|
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
import { useEffect, useRef } from 'react';
|
|
2
2
|
import { makeMutable, registerSensor, unregisterSensor } from '../core';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
(function (SensorType) {
|
|
6
|
-
SensorType[SensorType["ACCELEROMETER"] = 1] = "ACCELEROMETER";
|
|
7
|
-
SensorType[SensorType["GYROSCOPE"] = 2] = "GYROSCOPE";
|
|
8
|
-
SensorType[SensorType["GRAVITY"] = 3] = "GRAVITY";
|
|
9
|
-
SensorType[SensorType["MAGNETIC_FIELD"] = 4] = "MAGNETIC_FIELD";
|
|
10
|
-
SensorType[SensorType["ROTATION"] = 5] = "ROTATION";
|
|
11
|
-
})(SensorType || (SensorType = {}));
|
|
3
|
+
import { SensorType, IOSReferenceFrame } from '../commonTypes';
|
|
12
4
|
|
|
13
5
|
function initSensorData(sensorType) {
|
|
14
6
|
if (sensorType === SensorType.ROTATION) {
|
|
@@ -19,15 +11,86 @@ function initSensorData(sensorType) {
|
|
|
19
11
|
qz: 0,
|
|
20
12
|
yaw: 0,
|
|
21
13
|
pitch: 0,
|
|
22
|
-
roll: 0
|
|
14
|
+
roll: 0,
|
|
15
|
+
interfaceOrientation: 0
|
|
23
16
|
});
|
|
24
17
|
} else {
|
|
25
18
|
return makeMutable({
|
|
26
19
|
x: 0,
|
|
27
20
|
y: 0,
|
|
28
|
-
z: 0
|
|
21
|
+
z: 0,
|
|
22
|
+
interfaceOrientation: 0
|
|
29
23
|
});
|
|
30
24
|
}
|
|
25
|
+
} // euler angles are in order ZXY, z = yaw, x = pitch, y = roll
|
|
26
|
+
// https://github.com/mrdoob/three.js/blob/dev/src/math/Quaternion.js#L237
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
function eulerToQuaternion(pitch, roll, yaw) {
|
|
30
|
+
'worklet';
|
|
31
|
+
|
|
32
|
+
const c1 = Math.cos(pitch / 2);
|
|
33
|
+
const s1 = Math.sin(pitch / 2);
|
|
34
|
+
const c2 = Math.cos(roll / 2);
|
|
35
|
+
const s2 = Math.sin(roll / 2);
|
|
36
|
+
const c3 = Math.cos(yaw / 2);
|
|
37
|
+
const s3 = Math.sin(yaw / 2);
|
|
38
|
+
return [s1 * c2 * c3 - c1 * s2 * s3, c1 * s2 * c3 + s1 * c2 * s3, c1 * c2 * s3 + s1 * s2 * c3, c1 * c2 * c3 - s1 * s2 * s3];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function adjustRotationToInterfaceOrientation(data) {
|
|
42
|
+
'worklet';
|
|
43
|
+
|
|
44
|
+
const {
|
|
45
|
+
interfaceOrientation,
|
|
46
|
+
pitch,
|
|
47
|
+
roll,
|
|
48
|
+
yaw
|
|
49
|
+
} = data;
|
|
50
|
+
|
|
51
|
+
if (interfaceOrientation === 90) {
|
|
52
|
+
data.pitch = roll;
|
|
53
|
+
data.roll = -pitch;
|
|
54
|
+
data.yaw = yaw - Math.PI / 2;
|
|
55
|
+
} else if (interfaceOrientation === 270) {
|
|
56
|
+
data.pitch = -roll;
|
|
57
|
+
data.roll = pitch;
|
|
58
|
+
data.yaw = yaw + Math.PI / 2;
|
|
59
|
+
} else if (interfaceOrientation === 180) {
|
|
60
|
+
data.pitch *= -1;
|
|
61
|
+
data.roll *= -1;
|
|
62
|
+
data.yaw *= -1;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const q = eulerToQuaternion(data.pitch, data.roll, data.yaw);
|
|
66
|
+
data.qx = q[0];
|
|
67
|
+
data.qy = q[1];
|
|
68
|
+
data.qz = q[2];
|
|
69
|
+
data.qw = q[3];
|
|
70
|
+
return data;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function adjustVectorToInterfaceOrientation(data) {
|
|
74
|
+
'worklet';
|
|
75
|
+
|
|
76
|
+
const {
|
|
77
|
+
interfaceOrientation,
|
|
78
|
+
x,
|
|
79
|
+
y
|
|
80
|
+
} = data;
|
|
81
|
+
|
|
82
|
+
if (interfaceOrientation === 90) {
|
|
83
|
+
data.x = -y;
|
|
84
|
+
data.y = x;
|
|
85
|
+
} else if (interfaceOrientation === 270) {
|
|
86
|
+
data.x = y;
|
|
87
|
+
data.y = -x;
|
|
88
|
+
} else if (interfaceOrientation === 180) {
|
|
89
|
+
data.x *= -1;
|
|
90
|
+
data.y *= -1;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return data;
|
|
31
94
|
}
|
|
32
95
|
|
|
33
96
|
export function useAnimatedSensor(sensorType, userConfig) {
|
|
@@ -37,18 +100,30 @@ export function useAnimatedSensor(sensorType, userConfig) {
|
|
|
37
100
|
},
|
|
38
101
|
isAvailable: false,
|
|
39
102
|
config: {
|
|
40
|
-
interval: 0
|
|
103
|
+
interval: 0,
|
|
104
|
+
adjustToInterfaceOrientation: true,
|
|
105
|
+
iosReferenceFrame: IOSReferenceFrame.Auto
|
|
41
106
|
}
|
|
42
107
|
});
|
|
43
108
|
useEffect(() => {
|
|
44
109
|
ref.current.config = {
|
|
45
110
|
interval: 'auto',
|
|
111
|
+
adjustToInterfaceOrientation: true,
|
|
112
|
+
iosReferenceFrame: IOSReferenceFrame.Auto,
|
|
46
113
|
...userConfig
|
|
47
114
|
};
|
|
48
115
|
const sensorData = ref.current.sensor;
|
|
49
|
-
const id = registerSensor(sensorType, ref.current.config.interval === 'auto' ? -1 : ref.current.config.interval, data => {
|
|
116
|
+
const id = registerSensor(sensorType, ref.current.config.interval === 'auto' ? -1 : ref.current.config.interval, ref.current.config.iosReferenceFrame, data => {
|
|
50
117
|
'worklet';
|
|
51
118
|
|
|
119
|
+
if (ref.current.config.adjustToInterfaceOrientation) {
|
|
120
|
+
if (sensorType === SensorType.ROTATION) {
|
|
121
|
+
data = adjustRotationToInterfaceOrientation(data);
|
|
122
|
+
} else {
|
|
123
|
+
data = adjustVectorToInterfaceOrientation(data);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
52
127
|
sensorData.value = data;
|
|
53
128
|
});
|
|
54
129
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","useRef","makeMutable","registerSensor","unregisterSensor","SensorType","initSensorData","sensorType","ROTATION","qw","qx","qy","qz","yaw","pitch","roll","x","y","z","useAnimatedSensor","userConfig","ref","sensor","unregister","isAvailable","config","interval","current","sensorData","id","
|
|
1
|
+
{"version":3,"names":["useEffect","useRef","makeMutable","registerSensor","unregisterSensor","SensorType","IOSReferenceFrame","initSensorData","sensorType","ROTATION","qw","qx","qy","qz","yaw","pitch","roll","interfaceOrientation","x","y","z","eulerToQuaternion","c1","Math","cos","s1","sin","c2","s2","c3","s3","adjustRotationToInterfaceOrientation","data","PI","q","adjustVectorToInterfaceOrientation","useAnimatedSensor","userConfig","ref","sensor","unregister","isAvailable","config","interval","adjustToInterfaceOrientation","iosReferenceFrame","Auto","current","sensorData","id","value"],"sources":["useAnimatedSensor.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\nimport { makeMutable, registerSensor, unregisterSensor } from '../core';\nimport {\n SensorType,\n SharedValue,\n Value3D,\n ValueRotation,\n IOSReferenceFrame,\n} from '../commonTypes';\n\nexport type SensorConfig = {\n interval: number | 'auto';\n adjustToInterfaceOrientation: boolean;\n iosReferenceFrame: IOSReferenceFrame;\n};\n\nexport type AnimatedSensor = {\n sensor: SharedValue<Value3D | ValueRotation>;\n unregister: () => void;\n isAvailable: boolean;\n config: SensorConfig;\n};\n\nfunction initSensorData(\n sensorType: SensorType\n): SharedValue<Value3D | ValueRotation> {\n if (sensorType === SensorType.ROTATION) {\n return makeMutable<Value3D | ValueRotation>({\n qw: 0,\n qx: 0,\n qy: 0,\n qz: 0,\n yaw: 0,\n pitch: 0,\n roll: 0,\n interfaceOrientation: 0,\n });\n } else {\n return makeMutable<Value3D | ValueRotation>({\n x: 0,\n y: 0,\n z: 0,\n interfaceOrientation: 0,\n });\n }\n}\n\n// euler angles are in order ZXY, z = yaw, x = pitch, y = roll\n// https://github.com/mrdoob/three.js/blob/dev/src/math/Quaternion.js#L237\nfunction eulerToQuaternion(pitch: number, roll: number, yaw: number) {\n 'worklet';\n const c1 = Math.cos(pitch / 2);\n const s1 = Math.sin(pitch / 2);\n const c2 = Math.cos(roll / 2);\n const s2 = Math.sin(roll / 2);\n const c3 = Math.cos(yaw / 2);\n const s3 = Math.sin(yaw / 2);\n\n return [\n s1 * c2 * c3 - c1 * s2 * s3,\n c1 * s2 * c3 + s1 * c2 * s3,\n c1 * c2 * s3 + s1 * s2 * c3,\n c1 * c2 * c3 - s1 * s2 * s3,\n ];\n}\n\nfunction adjustRotationToInterfaceOrientation(data: ValueRotation) {\n 'worklet';\n const { interfaceOrientation, pitch, roll, yaw } = data;\n if (interfaceOrientation === 90) {\n data.pitch = roll;\n data.roll = -pitch;\n data.yaw = yaw - Math.PI / 2;\n } else if (interfaceOrientation === 270) {\n data.pitch = -roll;\n data.roll = pitch;\n data.yaw = yaw + Math.PI / 2;\n } else if (interfaceOrientation === 180) {\n data.pitch *= -1;\n data.roll *= -1;\n data.yaw *= -1;\n }\n\n const q = eulerToQuaternion(data.pitch, data.roll, data.yaw);\n data.qx = q[0];\n data.qy = q[1];\n data.qz = q[2];\n data.qw = q[3];\n return data;\n}\n\nfunction adjustVectorToInterfaceOrientation(data: Value3D) {\n 'worklet';\n const { interfaceOrientation, x, y } = data;\n if (interfaceOrientation === 90) {\n data.x = -y;\n data.y = x;\n } else if (interfaceOrientation === 270) {\n data.x = y;\n data.y = -x;\n } else if (interfaceOrientation === 180) {\n data.x *= -1;\n data.y *= -1;\n }\n return data;\n}\n\nexport function useAnimatedSensor(\n sensorType: SensorType,\n userConfig?: Partial<SensorConfig>\n): AnimatedSensor {\n const ref = useRef<AnimatedSensor>({\n sensor: initSensorData(sensorType),\n unregister: () => {\n // NOOP\n },\n isAvailable: false,\n config: {\n interval: 0,\n adjustToInterfaceOrientation: true,\n iosReferenceFrame: IOSReferenceFrame.Auto,\n },\n });\n\n useEffect(() => {\n ref.current.config = {\n interval: 'auto',\n adjustToInterfaceOrientation: true,\n iosReferenceFrame: IOSReferenceFrame.Auto,\n ...userConfig,\n };\n const sensorData = ref.current.sensor!;\n const id = registerSensor(\n sensorType,\n ref.current.config.interval === 'auto' ? -1 : ref.current.config.interval,\n ref.current.config.iosReferenceFrame,\n (data) => {\n 'worklet';\n if (ref.current.config.adjustToInterfaceOrientation) {\n if (sensorType === SensorType.ROTATION) {\n data = adjustRotationToInterfaceOrientation(data as ValueRotation);\n } else {\n data = adjustVectorToInterfaceOrientation(data as Value3D);\n }\n }\n sensorData.value = data;\n }\n );\n\n if (id !== -1) {\n // if sensor is available\n ref.current.unregister = () => unregisterSensor(id);\n ref.current.isAvailable = true;\n } else {\n // if sensor is unavailable\n ref.current.unregister = () => {\n // NOOP\n };\n ref.current.isAvailable = false;\n }\n\n return () => {\n ref.current.unregister();\n };\n }, [sensorType, userConfig]);\n\n return ref.current;\n}\n"],"mappings":"AAAA,SAASA,SAAT,EAAoBC,MAApB,QAAkC,OAAlC;AACA,SAASC,WAAT,EAAsBC,cAAtB,EAAsCC,gBAAtC,QAA8D,SAA9D;AACA,SACEC,UADF,EAKEC,iBALF,QAMO,gBANP;;AAqBA,SAASC,cAAT,CACEC,UADF,EAEwC;EACtC,IAAIA,UAAU,KAAKH,UAAU,CAACI,QAA9B,EAAwC;IACtC,OAAOP,WAAW,CAA0B;MAC1CQ,EAAE,EAAE,CADsC;MAE1CC,EAAE,EAAE,CAFsC;MAG1CC,EAAE,EAAE,CAHsC;MAI1CC,EAAE,EAAE,CAJsC;MAK1CC,GAAG,EAAE,CALqC;MAM1CC,KAAK,EAAE,CANmC;MAO1CC,IAAI,EAAE,CAPoC;MAQ1CC,oBAAoB,EAAE;IARoB,CAA1B,CAAlB;EAUD,CAXD,MAWO;IACL,OAAOf,WAAW,CAA0B;MAC1CgB,CAAC,EAAE,CADuC;MAE1CC,CAAC,EAAE,CAFuC;MAG1CC,CAAC,EAAE,CAHuC;MAI1CH,oBAAoB,EAAE;IAJoB,CAA1B,CAAlB;EAMD;AACF,C,CAED;AACA;;;AACA,SAASI,iBAAT,CAA2BN,KAA3B,EAA0CC,IAA1C,EAAwDF,GAAxD,EAAqE;EACnE;;EACA,MAAMQ,EAAE,GAAGC,IAAI,CAACC,GAAL,CAAST,KAAK,GAAG,CAAjB,CAAX;EACA,MAAMU,EAA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C,gBAAgB,CAAC6C,EAAD,CAA/C;;MACAX,GAAG,CAACS,OAAJ,CAAYN,WAAZ,GAA0B,IAA1B;IACD,CAJD,MAIO;MACL;MACAH,GAAG,CAACS,OAAJ,CAAYP,UAAZ,GAAyB,MAAM,CAC7B;MACD,CAFD;;MAGAF,GAAG,CAACS,OAAJ,CAAYN,WAAZ,GAA0B,KAA1B;IACD;;IAED,OAAO,MAAM;MACXH,GAAG,CAACS,OAAJ,CAAYP,UAAZ;IACD,CAFD;EAGD,CAxCQ,EAwCN,CAAChC,UAAD,EAAa6B,UAAb,CAxCM,CAAT;EA0CA,OAAOC,GAAG,CAACS,OAAX;AACD"}
|
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
/* global _frameTimestamp */
|
|
2
1
|
import { useEffect, useRef } from 'react';
|
|
3
|
-
import { startMapper, stopMapper, makeRemote
|
|
2
|
+
import { startMapper, stopMapper, makeRemote } from '../core';
|
|
4
3
|
import updateProps, { updatePropsJestWrapper } from '../UpdateProps';
|
|
5
4
|
import { initialUpdaterRun } from '../animation';
|
|
6
5
|
import NativeReanimatedModule from '../NativeReanimated';
|
|
7
6
|
import { useSharedValue } from './useSharedValue';
|
|
8
|
-
import { buildWorkletsHash,
|
|
7
|
+
import { buildWorkletsHash, isAnimated, shallowEqual, validateAnimatedStyles } from './utils';
|
|
9
8
|
import { makeViewDescriptorsSet, makeViewsRefSet } from '../ViewDescriptorsSet';
|
|
10
|
-
import { isJest } from '../PlatformChecker';
|
|
9
|
+
import { isJest, shouldBeUseWeb } from '../PlatformChecker';
|
|
11
10
|
|
|
12
|
-
function prepareAnimation(animatedProp, lastAnimation, lastValue) {
|
|
11
|
+
function prepareAnimation(frameTimestamp, animatedProp, lastAnimation, lastValue) {
|
|
13
12
|
'worklet';
|
|
14
13
|
|
|
15
14
|
if (Array.isArray(animatedProp)) {
|
|
16
15
|
animatedProp.forEach((prop, index) => {
|
|
17
|
-
prepareAnimation(prop, lastAnimation && lastAnimation[index], lastValue && lastValue[index]);
|
|
16
|
+
prepareAnimation(frameTimestamp, prop, lastAnimation && lastAnimation[index], lastValue && lastValue[index]);
|
|
18
17
|
}); // return animatedProp;
|
|
19
18
|
}
|
|
20
19
|
|
|
@@ -46,11 +45,11 @@ function prepareAnimation(animatedProp, lastAnimation, lastValue) {
|
|
|
46
45
|
animation.onStart(animation, value, timestamp, lastAnimation);
|
|
47
46
|
};
|
|
48
47
|
|
|
49
|
-
animation.callStart(
|
|
48
|
+
animation.callStart(frameTimestamp);
|
|
50
49
|
animation.callStart = null;
|
|
51
50
|
} else if (typeof animatedProp === 'object') {
|
|
52
51
|
// it is an object
|
|
53
|
-
Object.keys(animatedProp).forEach(key => prepareAnimation(animatedProp[key], lastAnimation && lastAnimation[key], lastValue && lastValue[key]));
|
|
52
|
+
Object.keys(animatedProp).forEach(key => prepareAnimation(frameTimestamp, animatedProp[key], lastAnimation && lastAnimation[key], lastValue && lastValue[key]));
|
|
54
53
|
}
|
|
55
54
|
}
|
|
56
55
|
|
|
@@ -113,30 +112,34 @@ function styleUpdater(viewDescriptors, updater, state, maybeViewRef, animationsA
|
|
|
113
112
|
const animations = state.animations ?? {};
|
|
114
113
|
const newValues = updater() ?? {};
|
|
115
114
|
const oldValues = state.last;
|
|
115
|
+
const nonAnimatedNewValues = {};
|
|
116
116
|
let hasAnimations = false;
|
|
117
|
+
let frameTimestamp;
|
|
118
|
+
let hasNonAnimatedValues = false;
|
|
117
119
|
|
|
118
120
|
for (const key in newValues) {
|
|
119
121
|
const value = newValues[key];
|
|
120
122
|
|
|
121
123
|
if (isAnimated(value)) {
|
|
122
|
-
|
|
124
|
+
frameTimestamp = global.__frameTimestamp || performance.now();
|
|
125
|
+
prepareAnimation(frameTimestamp, value, animations[key], oldValues[key]);
|
|
123
126
|
animations[key] = value;
|
|
124
127
|
hasAnimations = true;
|
|
125
128
|
} else {
|
|
129
|
+
hasNonAnimatedValues = true;
|
|
130
|
+
nonAnimatedNewValues[key] = value;
|
|
126
131
|
delete animations[key];
|
|
127
132
|
}
|
|
128
133
|
}
|
|
129
134
|
|
|
130
135
|
if (hasAnimations) {
|
|
131
|
-
const frame =
|
|
136
|
+
const frame = timestamp => {
|
|
132
137
|
const {
|
|
133
138
|
animations,
|
|
134
139
|
last,
|
|
135
140
|
isAnimationCancelled
|
|
136
141
|
} = state;
|
|
137
142
|
|
|
138
|
-
const timestamp = _timestamp ?? getTimestamp();
|
|
139
|
-
|
|
140
143
|
if (isAnimationCancelled) {
|
|
141
144
|
state.isAnimationRunning = false;
|
|
142
145
|
return;
|
|
@@ -172,30 +175,22 @@ function styleUpdater(viewDescriptors, updater, state, maybeViewRef, animationsA
|
|
|
172
175
|
if (!state.isAnimationRunning) {
|
|
173
176
|
state.isAnimationCancelled = false;
|
|
174
177
|
state.isAnimationRunning = true;
|
|
175
|
-
|
|
176
|
-
if (_frameTimestamp) {
|
|
177
|
-
frame(_frameTimestamp);
|
|
178
|
-
} else {
|
|
179
|
-
requestAnimationFrame(frame);
|
|
180
|
-
}
|
|
178
|
+
frame(frameTimestamp);
|
|
181
179
|
}
|
|
182
180
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
if (style) {
|
|
187
|
-
updateProps(viewDescriptors, style, maybeViewRef);
|
|
181
|
+
if (hasNonAnimatedValues) {
|
|
182
|
+
updateProps(viewDescriptors, nonAnimatedNewValues, maybeViewRef);
|
|
188
183
|
}
|
|
189
184
|
} else {
|
|
190
185
|
state.isAnimationCancelled = true;
|
|
191
186
|
state.animations = [];
|
|
192
|
-
const diff = styleDiff(oldValues, newValues);
|
|
193
|
-
state.last = Object.assign({}, oldValues, newValues);
|
|
194
187
|
|
|
195
|
-
if (
|
|
188
|
+
if (!shallowEqual(oldValues, newValues)) {
|
|
196
189
|
updateProps(viewDescriptors, newValues, maybeViewRef);
|
|
197
190
|
}
|
|
198
191
|
}
|
|
192
|
+
|
|
193
|
+
state.last = newValues;
|
|
199
194
|
}
|
|
200
195
|
|
|
201
196
|
function jestStyleUpdater(viewDescriptors, updater, state, maybeViewRef, animationsActive, animatedStyle) {
|
|
@@ -207,6 +202,7 @@ function jestStyleUpdater(viewDescriptors, updater, state, maybeViewRef, animati
|
|
|
207
202
|
const oldValues = state.last; // extract animated props
|
|
208
203
|
|
|
209
204
|
let hasAnimations = false;
|
|
205
|
+
let frameTimestamp;
|
|
210
206
|
Object.keys(animations).forEach(key => {
|
|
211
207
|
const value = newValues[key];
|
|
212
208
|
|
|
@@ -218,21 +214,20 @@ function jestStyleUpdater(viewDescriptors, updater, state, maybeViewRef, animati
|
|
|
218
214
|
const value = newValues[key];
|
|
219
215
|
|
|
220
216
|
if (isAnimated(value)) {
|
|
221
|
-
|
|
217
|
+
frameTimestamp = global.__frameTimestamp || performance.now();
|
|
218
|
+
prepareAnimation(frameTimestamp, value, animations[key], oldValues[key]);
|
|
222
219
|
animations[key] = value;
|
|
223
220
|
hasAnimations = true;
|
|
224
221
|
}
|
|
225
222
|
});
|
|
226
223
|
|
|
227
|
-
function frame(
|
|
224
|
+
function frame(timestamp) {
|
|
228
225
|
const {
|
|
229
226
|
animations,
|
|
230
227
|
last,
|
|
231
228
|
isAnimationCancelled
|
|
232
229
|
} = state;
|
|
233
230
|
|
|
234
|
-
const timestamp = _timestamp ?? getTimestamp();
|
|
235
|
-
|
|
236
231
|
if (isAnimationCancelled) {
|
|
237
232
|
state.isAnimationRunning = false;
|
|
238
233
|
return;
|
|
@@ -268,12 +263,7 @@ function jestStyleUpdater(viewDescriptors, updater, state, maybeViewRef, animati
|
|
|
268
263
|
if (!state.isAnimationRunning) {
|
|
269
264
|
state.isAnimationCancelled = false;
|
|
270
265
|
state.isAnimationRunning = true;
|
|
271
|
-
|
|
272
|
-
if (_frameTimestamp) {
|
|
273
|
-
frame(_frameTimestamp);
|
|
274
|
-
} else {
|
|
275
|
-
requestAnimationFrame(frame);
|
|
276
|
-
}
|
|
266
|
+
frame(frameTimestamp);
|
|
277
267
|
}
|
|
278
268
|
} else {
|
|
279
269
|
state.isAnimationCancelled = true;
|
|
@@ -281,11 +271,10 @@ function jestStyleUpdater(viewDescriptors, updater, state, maybeViewRef, animati
|
|
|
281
271
|
} // calculate diff
|
|
282
272
|
|
|
283
273
|
|
|
284
|
-
|
|
285
|
-
state.last = Object.assign({}, oldValues, newValues);
|
|
274
|
+
state.last = newValues;
|
|
286
275
|
|
|
287
|
-
if (
|
|
288
|
-
updatePropsJestWrapper(viewDescriptors,
|
|
276
|
+
if (!shallowEqual(oldValues, newValues)) {
|
|
277
|
+
updatePropsJestWrapper(viewDescriptors, newValues, maybeViewRef, animatedStyle, adapters);
|
|
289
278
|
}
|
|
290
279
|
} // check for invalid usage of shared values in returned object
|
|
291
280
|
|
|
@@ -310,7 +299,23 @@ function checkSharedValueUsage(prop, currentKey) {
|
|
|
310
299
|
export function useAnimatedStyle(updater, dependencies, adapters) {
|
|
311
300
|
const viewsRef = makeViewsRefSet();
|
|
312
301
|
const initRef = useRef();
|
|
313
|
-
|
|
302
|
+
let inputs = Object.values(updater._closure ?? {});
|
|
303
|
+
|
|
304
|
+
if (shouldBeUseWeb()) {
|
|
305
|
+
var _dependencies;
|
|
306
|
+
|
|
307
|
+
if (!inputs.length && (_dependencies = dependencies) !== null && _dependencies !== void 0 && _dependencies.length) {
|
|
308
|
+
// let web work without a Babel/SWC plugin
|
|
309
|
+
inputs = dependencies;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
if (__DEV__ && !inputs.length && !dependencies && !updater.__workletHash) {
|
|
313
|
+
throw new Error(`useAnimatedStyle was used without a dependency array or Babel plugin. Please explicitly pass a dependency array, or enable the Babel/SWC plugin.
|
|
314
|
+
|
|
315
|
+
For more, see the docs: https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/web-support#web-without-a-babel-plugin`);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
314
319
|
const adaptersArray = adapters ? Array.isArray(adapters) ? adapters : [adapters] : [];
|
|
315
320
|
const adaptersHash = adapters ? buildWorkletsHash(adaptersArray) : null;
|
|
316
321
|
const animationsActive = useSharedValue(true);
|
|
@@ -389,8 +394,6 @@ export function useAnimatedStyle(updater, dependencies, adapters) {
|
|
|
389
394
|
useEffect(() => {
|
|
390
395
|
animationsActive.value = true;
|
|
391
396
|
return () => {
|
|
392
|
-
// initRef.current = null;
|
|
393
|
-
// viewsRef = null;
|
|
394
397
|
animationsActive.value = false;
|
|
395
398
|
};
|
|
396
399
|
}, []);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","useRef","startMapper","stopMapper","makeRemote","getTimestamp","updateProps","updatePropsJestWrapper","initialUpdaterRun","NativeReanimatedModule","useSharedValue","buildWorkletsHash","getStyleWithoutAnimations","isAnimated","styleDiff","validateAnimatedStyles","makeViewDescriptorsSet","makeViewsRefSet","isJest","prepareAnimation","animatedProp","lastAnimation","lastValue","Array","isArray","forEach","prop","index","onFrame","animation","value","current","undefined","callStart","timestamp","onStart","Object","keys","key","runAnimations","result","animationsActive","allFinished","entry","finished","callback","k","styleUpdater","viewDescriptors","updater","state","maybeViewRef","animations","newValues","oldValues","last","hasAnimations","frame","_timestamp","isAnimationCancelled","isAnimationRunning","updates","propName","requestAnimationFrame","_frameTimestamp","assign","style","diff","jestStyleUpdater","animatedStyle","adapters","length","checkSharedValueUsage","currentKey","element","Error","useAnimatedStyle","dependencies","viewsRef","initRef","inputs","values","_closure","adaptersArray","adaptersHash","__workletHash","push","initialStyle","initial","remoteState","sharableViewDescriptors","native","fun","updaterFn","adapter","mapperId","process","env","JEST_WORKER_ID"],"sources":["useAnimatedStyle.ts"],"sourcesContent":["/* global _frameTimestamp */\nimport { MutableRefObject, useEffect, useRef } from 'react';\n\nimport { startMapper, stopMapper, makeRemote, getTimestamp } from '../core';\nimport updateProps, { updatePropsJestWrapper } from '../UpdateProps';\nimport { initialUpdaterRun } from '../animation';\nimport NativeReanimatedModule from '../NativeReanimated';\nimport { useSharedValue } from './useSharedValue';\nimport {\n buildWorkletsHash,\n getStyleWithoutAnimations,\n isAnimated,\n styleDiff,\n validateAnimatedStyles,\n} from './utils';\nimport { DependencyList, Descriptor } from './commonTypes';\nimport {\n makeViewDescriptorsSet,\n makeViewsRefSet,\n ViewDescriptorsSet,\n ViewRefSet,\n} from '../ViewDescriptorsSet';\nimport { isJest } from '../PlatformChecker';\nimport {\n AnimationObject,\n Timestamp,\n AdapterWorkletFunction,\n AnimatedStyle,\n BasicWorkletFunction,\n BasicWorkletFunctionOptional,\n NestedObjectValues,\n SharedValue,\n} from '../commonTypes';\nexport interface AnimatedStyleResult {\n viewDescriptors: ViewDescriptorsSet;\n initial: AnimatedStyle;\n viewsRef: ViewRefSet<any>;\n animatedStyle?: MutableRefObject<AnimatedStyle>;\n}\n\ninterface AnimatedState {\n last: AnimatedStyle;\n animations: AnimatedStyle;\n isAnimationRunning: boolean;\n isAnimationCancelled: boolean;\n}\n\ninterface AnimationRef {\n initial: {\n value: AnimatedStyle;\n updater: () => AnimatedStyle;\n };\n remoteState: AnimatedState;\n viewDescriptors: ViewDescriptorsSet;\n}\n\nfunction prepareAnimation(\n animatedProp: AnimatedStyle,\n lastAnimation: AnimatedStyle,\n lastValue: AnimatedStyle\n): void {\n 'worklet';\n if (Array.isArray(animatedProp)) {\n animatedProp.forEach((prop, index) => {\n prepareAnimation(\n prop,\n lastAnimation && lastAnimation[index],\n lastValue && lastValue[index]\n );\n });\n // return animatedProp;\n }\n if (typeof animatedProp === 'object' && animatedProp.onFrame) {\n const animation = animatedProp;\n\n let value = animation.current;\n if (lastValue !== undefined) {\n if (typeof lastValue === 'object') {\n if (lastValue.value !== undefined) {\n // previously it was a shared value\n value = lastValue.value;\n } else if (lastValue.onFrame !== undefined) {\n if (lastAnimation?.current !== undefined) {\n // it was an animation before, copy its state\n value = lastAnimation.current;\n } else if (lastValue?.current !== undefined) {\n // it was initialized\n value = lastValue.current;\n }\n }\n } else {\n // previously it was a plain value, just set it as starting point\n value = lastValue;\n }\n }\n\n animation.callStart = (timestamp: Timestamp) => {\n animation.onStart(animation, value, timestamp, lastAnimation);\n };\n animation.callStart(getTimestamp());\n animation.callStart = null;\n } else if (typeof animatedProp === 'object') {\n // it is an object\n Object.keys(animatedProp).forEach((key) =>\n prepareAnimation(\n animatedProp[key],\n lastAnimation && lastAnimation[key],\n lastValue && lastValue[key]\n )\n );\n }\n}\n\nfunction runAnimations(\n animation: AnimatedStyle,\n timestamp: Timestamp,\n key: number | string,\n result: AnimatedStyle,\n animationsActive: SharedValue<boolean>\n): boolean {\n 'worklet';\n if (!animationsActive.value) {\n return true;\n }\n if (Array.isArray(animation)) {\n result[key] = [];\n let allFinished = true;\n animation.forEach((entry, index) => {\n if (\n !runAnimations(entry, timestamp, index, result[key], animationsActive)\n ) {\n allFinished = false;\n }\n });\n return allFinished;\n } else if (typeof animation === 'object' && animation.onFrame) {\n let finished = true;\n if (!animation.finished) {\n if (animation.callStart) {\n animation.callStart(timestamp);\n animation.callStart = null;\n }\n finished = animation.onFrame(animation, timestamp);\n animation.timestamp = timestamp;\n if (finished) {\n animation.finished = true;\n animation.callback && animation.callback(true /* finished */);\n }\n }\n result[key] = animation.current;\n return finished;\n } else if (typeof animation === 'object') {\n result[key] = {};\n let allFinished = true;\n Object.keys(animation).forEach((k) => {\n if (\n !runAnimations(\n animation[k],\n timestamp,\n k,\n result[key],\n animationsActive\n )\n ) {\n allFinished = false;\n }\n });\n return allFinished;\n } else {\n result[key] = animation;\n return true;\n }\n}\n\nfunction styleUpdater(\n viewDescriptors: SharedValue<Descriptor[]>,\n updater: BasicWorkletFunction<AnimatedStyle>,\n state: AnimatedState,\n maybeViewRef: ViewRefSet<any> | undefined,\n animationsActive: SharedValue<boolean>\n): void {\n 'worklet';\n const animations = state.animations ?? {};\n const newValues = updater() ?? {};\n const oldValues = state.last;\n\n let hasAnimations = false;\n for (const key in newValues) {\n const value = newValues[key];\n if (isAnimated(value)) {\n prepareAnimation(value, animations[key], oldValues[key]);\n animations[key] = value;\n hasAnimations = true;\n } else {\n delete animations[key];\n }\n }\n\n if (hasAnimations) {\n const frame = (_timestamp?: Timestamp) => {\n const { animations, last, isAnimationCancelled } = state;\n const timestamp = _timestamp ?? getTimestamp();\n if (isAnimationCancelled) {\n state.isAnimationRunning = false;\n return;\n }\n\n const updates: AnimatedStyle = {};\n let allFinished = true;\n for (const propName in animations) {\n const finished = runAnimations(\n animations[propName],\n timestamp,\n propName,\n updates,\n animationsActive\n );\n if (finished) {\n last[propName] = updates[propName];\n delete animations[propName];\n } else {\n allFinished = false;\n }\n }\n\n if (updates) {\n updateProps(viewDescriptors, updates, maybeViewRef);\n }\n\n if (!allFinished) {\n requestAnimationFrame(frame);\n } else {\n state.isAnimationRunning = false;\n }\n };\n\n state.animations = animations;\n if (!state.isAnimationRunning) {\n state.isAnimationCancelled = false;\n state.isAnimationRunning = true;\n if (_frameTimestamp) {\n frame(_frameTimestamp);\n } else {\n requestAnimationFrame(frame);\n }\n }\n state.last = Object.assign({}, oldValues, newValues);\n const style = getStyleWithoutAnimations(state.last);\n if (style) {\n updateProps(viewDescriptors, style, maybeViewRef);\n }\n } else {\n state.isAnimationCancelled = true;\n state.animations = [];\n\n const diff = styleDiff(oldValues, newValues);\n state.last = Object.assign({}, oldValues, newValues);\n if (diff) {\n updateProps(viewDescriptors, newValues, maybeViewRef);\n }\n }\n}\n\nfunction jestStyleUpdater(\n viewDescriptors: SharedValue<Descriptor[]>,\n updater: BasicWorkletFunction<AnimatedStyle>,\n state: AnimatedState,\n maybeViewRef: ViewRefSet<any> | undefined,\n animationsActive: SharedValue<boolean>,\n animatedStyle: MutableRefObject<AnimatedStyle>,\n adapters: AdapterWorkletFunction[] = []\n): void {\n 'worklet';\n const animations: AnimatedStyle = state.animations ?? {};\n const newValues = updater() ?? {};\n const oldValues = state.last;\n\n // extract animated props\n let hasAnimations = false;\n Object.keys(animations).forEach((key) => {\n const value = newValues[key];\n if (!isAnimated(value)) {\n delete animations[key];\n }\n });\n Object.keys(newValues).forEach((key) => {\n const value = newValues[key];\n if (isAnimated(value)) {\n prepareAnimation(value, animations[key], oldValues[key]);\n animations[key] = value;\n hasAnimations = true;\n }\n });\n\n function frame(_timestamp?: Timestamp) {\n const { animations, last, isAnimationCancelled } = state;\n const timestamp = _timestamp ?? getTimestamp();\n if (isAnimationCancelled) {\n state.isAnimationRunning = false;\n return;\n }\n\n const updates: AnimatedStyle = {};\n let allFinished = true;\n Object.keys(animations).forEach((propName) => {\n const finished = runAnimations(\n animations[propName],\n timestamp,\n propName,\n updates,\n animationsActive\n );\n if (finished) {\n last[propName] = updates[propName];\n delete animations[propName];\n } else {\n allFinished = false;\n }\n });\n\n if (Object.keys(updates).length) {\n updatePropsJestWrapper(\n viewDescriptors,\n updates,\n maybeViewRef,\n animatedStyle,\n adapters\n );\n }\n\n if (!allFinished) {\n requestAnimationFrame(frame);\n } else {\n state.isAnimationRunning = false;\n }\n }\n\n if (hasAnimations) {\n state.animations = animations;\n if (!state.isAnimationRunning) {\n state.isAnimationCancelled = false;\n state.isAnimationRunning = true;\n if (_frameTimestamp) {\n frame(_frameTimestamp);\n } else {\n requestAnimationFrame(frame);\n }\n }\n } else {\n state.isAnimationCancelled = true;\n state.animations = [];\n }\n\n // calculate diff\n const diff = styleDiff(oldValues, newValues);\n state.last = Object.assign({}, oldValues, newValues);\n\n if (Object.keys(diff).length !== 0) {\n updatePropsJestWrapper(\n viewDescriptors,\n diff,\n maybeViewRef,\n animatedStyle,\n adapters\n );\n }\n}\n\n// check for invalid usage of shared values in returned object\nfunction checkSharedValueUsage(\n prop: NestedObjectValues<AnimationObject>,\n currentKey?: string\n): void {\n if (Array.isArray(prop)) {\n // if it's an array (i.ex. transform) validate all its elements\n for (const element of prop) {\n checkSharedValueUsage(element, currentKey);\n }\n } else if (typeof prop === 'object' && prop.value === undefined) {\n // if it's a nested object, run validation for all its props\n for (const key of Object.keys(prop)) {\n checkSharedValueUsage(prop[key], key);\n }\n } else if (\n currentKey !== undefined &&\n typeof prop === 'object' &&\n prop.value !== undefined\n ) {\n // if shared value is passed insted of its value, throw an error\n throw new Error(\n `invalid value passed to \\`${currentKey}\\`, maybe you forgot to use \\`.value\\`?`\n );\n }\n}\n\nexport function useAnimatedStyle<T extends AnimatedStyle>(\n updater: BasicWorkletFunction<T>,\n dependencies?: DependencyList,\n adapters?: AdapterWorkletFunction | AdapterWorkletFunction[]\n): AnimatedStyleResult {\n const viewsRef: ViewRefSet<any> = makeViewsRefSet();\n const initRef = useRef<AnimationRef>();\n const inputs = Object.values(updater._closure ?? {});\n const adaptersArray: AdapterWorkletFunction[] = adapters\n ? Array.isArray(adapters)\n ? adapters\n : [adapters]\n : [];\n const adaptersHash = adapters ? buildWorkletsHash(adaptersArray) : null;\n const animationsActive = useSharedValue<boolean>(true);\n const animatedStyle: MutableRefObject<AnimatedStyle> = useRef<AnimatedStyle>(\n {}\n );\n\n // build dependencies\n if (!dependencies) {\n dependencies = [...inputs, updater.__workletHash];\n } else {\n dependencies.push(updater.__workletHash);\n }\n adaptersHash && dependencies.push(adaptersHash);\n\n if (!initRef.current) {\n const initialStyle: AnimatedStyle = initialUpdaterRun(updater);\n validateAnimatedStyles(initialStyle);\n initRef.current = {\n initial: {\n value: initialStyle,\n updater: updater,\n },\n remoteState: makeRemote<AnimatedState>({\n last: initialStyle,\n animations: {},\n isAnimationCancelled: false,\n isAnimationRunning: false,\n }),\n viewDescriptors: makeViewDescriptorsSet(),\n };\n }\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const { initial, remoteState, viewDescriptors } = initRef.current!;\n const sharableViewDescriptors = viewDescriptors.sharableViewDescriptors;\n const maybeViewRef = NativeReanimatedModule.native ? undefined : viewsRef;\n\n dependencies.push(sharableViewDescriptors);\n\n useEffect(() => {\n let fun;\n let updaterFn = updater as BasicWorkletFunctionOptional<T>;\n if (adapters) {\n updaterFn = () => {\n 'worklet';\n const newValues = updater();\n adaptersArray.forEach((adapter) => {\n adapter(newValues);\n });\n return newValues;\n };\n }\n\n if (isJest()) {\n fun = () => {\n 'worklet';\n jestStyleUpdater(\n sharableViewDescriptors,\n updater,\n remoteState,\n maybeViewRef,\n animationsActive,\n animatedStyle,\n adaptersArray\n );\n };\n } else {\n fun = () => {\n 'worklet';\n styleUpdater(\n sharableViewDescriptors,\n updaterFn,\n remoteState,\n maybeViewRef,\n animationsActive\n );\n };\n }\n const mapperId = startMapper(fun, inputs);\n return () => {\n stopMapper(mapperId);\n };\n }, dependencies);\n\n useEffect(() => {\n animationsActive.value = true;\n return () => {\n // initRef.current = null;\n // viewsRef = null;\n animationsActive.value = false;\n };\n }, []);\n\n checkSharedValueUsage(initial.value);\n\n if (process.env.JEST_WORKER_ID) {\n return { viewDescriptors, initial: initial, viewsRef, animatedStyle };\n } else {\n return { viewDescriptors, initial: initial, viewsRef };\n }\n}\n"],"mappings":"AAAA;AACA,SAA2BA,SAA3B,EAAsCC,MAAtC,QAAoD,OAApD;AAEA,SAASC,WAAT,EAAsBC,UAAtB,EAAkCC,UAAlC,EAA8CC,YAA9C,QAAkE,SAAlE;AACA,OAAOC,WAAP,IAAsBC,sBAAtB,QAAoD,gBAApD;AACA,SAASC,iBAAT,QAAkC,cAAlC;AACA,OAAOC,sBAAP,MAAmC,qBAAnC;AACA,SAASC,cAAT,QAA+B,kBAA/B;AACA,SACEC,iBADF,EAEEC,yBAFF,EAGEC,UAHF,EAIEC,SAJF,EAKEC,sBALF,QAMO,SANP;AAQA,SACEC,sBADF,EAEEC,eAFF,QAKO,uBALP;AAMA,SAASC,MAAT,QAAuB,oBAAvB;;AAkCA,SAASC,gBAAT,CACEC,YADF,EAEEC,aAFF,EAGEC,SAHF,EAIQ;EACN;;EACA,IAAIC,KAAK,CAACC,OAAN,CAAcJ,YAAd,CAAJ,EAAiC;IAC/BA,YAAY,CAACK,OAAb,CAAqB,CAACC,IAAD,EAAOC,KAAP,KAAiB;MACpCR,gBAAgB,CACdO,IADc,EAEdL,aAAa,IAAIA,aAAa,CAACM,KAAD,CAFhB,EAGdL,SAAS,IA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EAKdV,gBALc,EAMd4B,aANc,EAOdc,aAPc,CAAhB;MASD,CAXD;IAYD,CAbD,MAaO;MACLS,GAAG,GAAG,MAAM;QACV;;QACA7C,YAAY,CACV2C,uBADU,EAEVG,SAFU,EAGVJ,WAHU,EAIVtC,YAJU,EAKVV,gBALU,CAAZ;MAOD,CATD;IAUD;;IACD,MAAMsD,QAAQ,GAAG7F,WAAW,CAAC0F,GAAD,EAAMZ,MAAN,CAA5B;IACA,OAAO,MAAM;MACX7E,UAAU,CAAC4F,QAAD,CAAV;IACD,CAFD;EAGD,CA3CQ,EA2CNlB,YA3CM,CAAT;EA6CA7E,SAAS,CAAC,MAAM;IACdyC,gBAAgB,CAACX,KAAjB,GAAyB,IAAzB;IACA,OAAO,MAAM;MACX;MACA;MACAW,gBAAgB,CAACX,KAAjB,GAAyB,KAAzB;IACD,CAJD;EAKD,CAPQ,EAON,EAPM,CAAT;EASA0C,qBAAqB,CAACgB,OAAO,CAAC1D,KAAT,CAArB;;EAEA,IAAIkE,OAAO,CAACC,GAAR,CAAYC,cAAhB,EAAgC;IAC9B,OAAO;MAAElD,eAAF;MAAmBwC,OAAO,EAAEA,OAA5B;MAAqCV,QAArC;MAA+CT;IAA/C,CAAP;EACD,CAFD,MAEO;IACL,OAAO;MAAErB,eAAF;MAAmBwC,OAAO,EAAEA,OAA5B;MAAqCV;IAArC,CAAP;EACD;AACF"}
|
|
1
|
+
{"version":3,"names":["useEffect","useRef","startMapper","stopMapper","makeRemote","updateProps","updatePropsJestWrapper","initialUpdaterRun","NativeReanimatedModule","useSharedValue","buildWorkletsHash","isAnimated","shallowEqual","validateAnimatedStyles","makeViewDescriptorsSet","makeViewsRefSet","isJest","shouldBeUseWeb","prepareAnimation","frameTimestamp","animatedProp","lastAnimation","lastValue","Array","isArray","forEach","prop","index","onFrame","animation","value","current","undefined","callStart","timestamp","onStart","Object","keys","key","runAnimations","result","animationsActive","allFinished","entry","finished","callback","k","styleUpdater","viewDescriptors","updater","state","maybeViewRef","animations","newValues","oldValues","last","nonAnimatedNewValues","hasAnimations","hasNonAnimatedValues","global","__frameTimestamp","performance","now","frame","isAnimationCancelled","isAnimationRunning","updates","propName","requestAnimationFrame","jestStyleUpdater","animatedStyle","adapters","length","checkSharedValueUsage","currentKey","element","Error","useAnimatedStyle","dependencies","viewsRef","initRef","inputs","values","_closure","__DEV__","__workletHash","adaptersArray","adaptersHash","push","initialStyle","initial","remoteState","sharableViewDescriptors","native","fun","updaterFn","adapter","mapperId","process","env","JEST_WORKER_ID"],"sources":["useAnimatedStyle.ts"],"sourcesContent":["import { MutableRefObject, useEffect, useRef } from 'react';\n\nimport { startMapper, stopMapper, makeRemote } from '../core';\nimport updateProps, { updatePropsJestWrapper } from '../UpdateProps';\nimport { initialUpdaterRun } from '../animation';\nimport NativeReanimatedModule from '../NativeReanimated';\nimport { useSharedValue } from './useSharedValue';\nimport {\n buildWorkletsHash,\n isAnimated,\n shallowEqual,\n validateAnimatedStyles,\n} from './utils';\nimport { DependencyList, Descriptor } from './commonTypes';\nimport {\n makeViewDescriptorsSet,\n makeViewsRefSet,\n ViewDescriptorsSet,\n ViewRefSet,\n} from '../ViewDescriptorsSet';\nimport { isJest, shouldBeUseWeb } from '../PlatformChecker';\nimport {\n AnimationObject,\n Timestamp,\n AdapterWorkletFunction,\n AnimatedStyle,\n BasicWorkletFunction,\n BasicWorkletFunctionOptional,\n NestedObjectValues,\n SharedValue,\n StyleProps,\n} from '../commonTypes';\nexport interface AnimatedStyleResult {\n viewDescriptors: ViewDescriptorsSet;\n initial: AnimatedStyle;\n viewsRef: ViewRefSet<any>;\n animatedStyle?: MutableRefObject<AnimatedStyle>;\n}\n\ninterface AnimatedState {\n last: AnimatedStyle;\n animations: AnimatedStyle;\n isAnimationRunning: boolean;\n isAnimationCancelled: boolean;\n}\n\ninterface AnimationRef {\n initial: {\n value: AnimatedStyle;\n updater: () => AnimatedStyle;\n };\n remoteState: AnimatedState;\n viewDescriptors: ViewDescriptorsSet;\n}\n\nfunction prepareAnimation(\n frameTimestamp: number,\n animatedProp: AnimatedStyle,\n lastAnimation: AnimatedStyle,\n lastValue: AnimatedStyle\n): void {\n 'worklet';\n if (Array.isArray(animatedProp)) {\n animatedProp.forEach((prop, index) => {\n prepareAnimation(\n frameTimestamp,\n prop,\n lastAnimation && lastAnimation[index],\n lastValue && lastValue[index]\n );\n });\n // return animatedProp;\n }\n if (typeof animatedProp === 'object' && animatedProp.onFrame) {\n const animation = animatedProp;\n\n let value = animation.current;\n if (lastValue !== undefined) {\n if (typeof lastValue === 'object') {\n if (lastValue.value !== undefined) {\n // previously it was a shared value\n value = lastValue.value;\n } else if (lastValue.onFrame !== undefined) {\n if (lastAnimation?.current !== undefined) {\n // it was an animation before, copy its state\n value = lastAnimation.current;\n } else if (lastValue?.current !== undefined) {\n // it was initialized\n value = lastValue.current;\n }\n }\n } else {\n // previously it was a plain value, just set it as starting point\n value = lastValue;\n }\n }\n\n animation.callStart = (timestamp: Timestamp) => {\n animation.onStart(animation, value, timestamp, lastAnimation);\n };\n animation.callStart(frameTimestamp);\n animation.callStart = null;\n } else if (typeof animatedProp === 'object') {\n // it is an object\n Object.keys(animatedProp).forEach((key) =>\n prepareAnimation(\n frameTimestamp,\n animatedProp[key],\n lastAnimation && lastAnimation[key],\n lastValue && lastValue[key]\n )\n );\n }\n}\n\nfunction runAnimations(\n animation: AnimatedStyle,\n timestamp: Timestamp,\n key: number | string,\n result: AnimatedStyle,\n animationsActive: SharedValue<boolean>\n): boolean {\n 'worklet';\n if (!animationsActive.value) {\n return true;\n }\n if (Array.isArray(animation)) {\n result[key] = [];\n let allFinished = true;\n animation.forEach((entry, index) => {\n if (\n !runAnimations(entry, timestamp, index, result[key], animationsActive)\n ) {\n allFinished = false;\n }\n });\n return allFinished;\n } else if (typeof animation === 'object' && animation.onFrame) {\n let finished = true;\n if (!animation.finished) {\n if (animation.callStart) {\n animation.callStart(timestamp);\n animation.callStart = null;\n }\n finished = animation.onFrame(animation, timestamp);\n animation.timestamp = timestamp;\n if (finished) {\n animation.finished = true;\n animation.callback && animation.callback(true /* finished */);\n }\n }\n result[key] = animation.current;\n return finished;\n } else if (typeof animation === 'object') {\n result[key] = {};\n let allFinished = true;\n Object.keys(animation).forEach((k) => {\n if (\n !runAnimations(\n animation[k],\n timestamp,\n k,\n result[key],\n animationsActive\n )\n ) {\n allFinished = false;\n }\n });\n return allFinished;\n } else {\n result[key] = animation;\n return true;\n }\n}\n\nfunction styleUpdater(\n viewDescriptors: SharedValue<Descriptor[]>,\n updater: BasicWorkletFunction<AnimatedStyle>,\n state: AnimatedState,\n maybeViewRef: ViewRefSet<any> | undefined,\n animationsActive: SharedValue<boolean>\n): void {\n 'worklet';\n const animations = state.animations ?? {};\n const newValues = updater() ?? {};\n const oldValues = state.last;\n const nonAnimatedNewValues: StyleProps = {};\n\n let hasAnimations = false;\n let frameTimestamp: number | undefined;\n let hasNonAnimatedValues = false;\n for (const key in newValues) {\n const value = newValues[key];\n if (isAnimated(value)) {\n frameTimestamp = global.__frameTimestamp || performance.now();\n prepareAnimation(frameTimestamp, value, animations[key], oldValues[key]);\n animations[key] = value;\n hasAnimations = true;\n } else {\n hasNonAnimatedValues = true;\n nonAnimatedNewValues[key] = value;\n delete animations[key];\n }\n }\n\n if (hasAnimations) {\n const frame = (timestamp: Timestamp) => {\n const { animations, last, isAnimationCancelled } = state;\n if (isAnimationCancelled) {\n state.isAnimationRunning = false;\n return;\n }\n\n const updates: AnimatedStyle = {};\n let allFinished = true;\n for (const propName in animations) {\n const finished = runAnimations(\n animations[propName],\n timestamp,\n propName,\n updates,\n animationsActive\n );\n if (finished) {\n last[propName] = updates[propName];\n delete animations[propName];\n } else {\n allFinished = false;\n }\n }\n\n if (updates) {\n updateProps(viewDescriptors, updates, maybeViewRef);\n }\n\n if (!allFinished) {\n requestAnimationFrame(frame);\n } else {\n state.isAnimationRunning = false;\n }\n };\n\n state.animations = animations;\n if (!state.isAnimationRunning) {\n state.isAnimationCancelled = false;\n state.isAnimationRunning = true;\n frame(frameTimestamp!);\n }\n\n if (hasNonAnimatedValues) {\n updateProps(viewDescriptors, nonAnimatedNewValues, maybeViewRef);\n }\n } else {\n state.isAnimationCancelled = true;\n state.animations = [];\n\n if (!shallowEqual(oldValues, newValues)) {\n updateProps(viewDescriptors, newValues, maybeViewRef);\n }\n }\n state.last = newValues;\n}\n\nfunction jestStyleUpdater(\n viewDescriptors: SharedValue<Descriptor[]>,\n updater: BasicWorkletFunction<AnimatedStyle>,\n state: AnimatedState,\n maybeViewRef: ViewRefSet<any> | undefined,\n animationsActive: SharedValue<boolean>,\n animatedStyle: MutableRefObject<AnimatedStyle>,\n adapters: AdapterWorkletFunction[] = []\n): void {\n 'worklet';\n const animations: AnimatedStyle = state.animations ?? {};\n const newValues = updater() ?? {};\n const oldValues = state.last;\n\n // extract animated props\n let hasAnimations = false;\n let frameTimestamp: number | undefined;\n Object.keys(animations).forEach((key) => {\n const value = newValues[key];\n if (!isAnimated(value)) {\n delete animations[key];\n }\n });\n Object.keys(newValues).forEach((key) => {\n const value = newValues[key];\n if (isAnimated(value)) {\n frameTimestamp = global.__frameTimestamp || performance.now();\n prepareAnimation(frameTimestamp, value, animations[key], oldValues[key]);\n animations[key] = value;\n hasAnimations = true;\n }\n });\n\n function frame(timestamp: Timestamp) {\n const { animations, last, isAnimationCancelled } = state;\n if (isAnimationCancelled) {\n state.isAnimationRunning = false;\n return;\n }\n\n const updates: AnimatedStyle = {};\n let allFinished = true;\n Object.keys(animations).forEach((propName) => {\n const finished = runAnimations(\n animations[propName],\n timestamp,\n propName,\n updates,\n animationsActive\n );\n if (finished) {\n last[propName] = updates[propName];\n delete animations[propName];\n } else {\n allFinished = false;\n }\n });\n\n if (Object.keys(updates).length) {\n updatePropsJestWrapper(\n viewDescriptors,\n updates,\n maybeViewRef,\n animatedStyle,\n adapters\n );\n }\n\n if (!allFinished) {\n requestAnimationFrame(frame);\n } else {\n state.isAnimationRunning = false;\n }\n }\n\n if (hasAnimations) {\n state.animations = animations;\n if (!state.isAnimationRunning) {\n state.isAnimationCancelled = false;\n state.isAnimationRunning = true;\n frame(frameTimestamp!);\n }\n } else {\n state.isAnimationCancelled = true;\n state.animations = [];\n }\n\n // calculate diff\n state.last = newValues;\n\n if (!shallowEqual(oldValues, newValues)) {\n updatePropsJestWrapper(\n viewDescriptors,\n newValues,\n maybeViewRef,\n animatedStyle,\n adapters\n );\n }\n}\n\n// check for invalid usage of shared values in returned object\nfunction checkSharedValueUsage(\n prop: NestedObjectValues<AnimationObject>,\n currentKey?: string\n): void {\n if (Array.isArray(prop)) {\n // if it's an array (i.ex. transform) validate all its elements\n for (const element of prop) {\n checkSharedValueUsage(element, currentKey);\n }\n } else if (typeof prop === 'object' && prop.value === undefined) {\n // if it's a nested object, run validation for all its props\n for (const key of Object.keys(prop)) {\n checkSharedValueUsage(prop[key], key);\n }\n } else if (\n currentKey !== undefined &&\n typeof prop === 'object' &&\n prop.value !== undefined\n ) {\n // if shared value is passed insted of its value, throw an error\n throw new Error(\n `invalid value passed to \\`${currentKey}\\`, maybe you forgot to use \\`.value\\`?`\n );\n }\n}\n\nexport function useAnimatedStyle<T extends AnimatedStyle>(\n updater: BasicWorkletFunction<T>,\n dependencies?: DependencyList,\n adapters?: AdapterWorkletFunction | AdapterWorkletFunction[]\n): AnimatedStyleResult {\n const viewsRef: ViewRefSet<any> = makeViewsRefSet();\n const initRef = useRef<AnimationRef>();\n let inputs = Object.values(updater._closure ?? {});\n if (shouldBeUseWeb()) {\n if (!inputs.length && dependencies?.length) {\n // let web work without a Babel/SWC plugin\n inputs = dependencies;\n }\n if (__DEV__ && !inputs.length && !dependencies && !updater.__workletHash) {\n throw new Error(\n `useAnimatedStyle was used without a dependency array or Babel plugin. Please explicitly pass a dependency array, or enable the Babel/SWC plugin.\n\nFor more, see the docs: https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/web-support#web-without-a-babel-plugin`\n );\n }\n }\n const adaptersArray: AdapterWorkletFunction[] = adapters\n ? Array.isArray(adapters)\n ? adapters\n : [adapters]\n : [];\n const adaptersHash = adapters ? buildWorkletsHash(adaptersArray) : null;\n const animationsActive = useSharedValue<boolean>(true);\n const animatedStyle: MutableRefObject<AnimatedStyle> = useRef<AnimatedStyle>(\n {}\n );\n\n // build dependencies\n if (!dependencies) {\n dependencies = [...inputs, updater.__workletHash];\n } else {\n dependencies.push(updater.__workletHash);\n }\n adaptersHash && dependencies.push(adaptersHash);\n\n if (!initRef.current) {\n const initialStyle: AnimatedStyle = initialUpdaterRun(updater);\n validateAnimatedStyles(initialStyle);\n initRef.current = {\n initial: {\n value: initialStyle,\n updater: updater,\n },\n remoteState: makeRemote<AnimatedState>({\n last: initialStyle,\n animations: {},\n isAnimationCancelled: false,\n isAnimationRunning: false,\n }),\n viewDescriptors: makeViewDescriptorsSet(),\n };\n }\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const { initial, remoteState, viewDescriptors } = initRef.current!;\n const sharableViewDescriptors = viewDescriptors.sharableViewDescriptors;\n const maybeViewRef = NativeReanimatedModule.native ? undefined : viewsRef;\n\n dependencies.push(sharableViewDescriptors);\n\n useEffect(() => {\n let fun;\n let updaterFn = updater as BasicWorkletFunctionOptional<T>;\n if (adapters) {\n updaterFn = () => {\n 'worklet';\n const newValues = updater();\n adaptersArray.forEach((adapter) => {\n adapter(newValues);\n });\n return newValues;\n };\n }\n\n if (isJest()) {\n fun = () => {\n 'worklet';\n jestStyleUpdater(\n sharableViewDescriptors,\n updater,\n remoteState,\n maybeViewRef,\n animationsActive,\n animatedStyle,\n adaptersArray\n );\n };\n } else {\n fun = () => {\n 'worklet';\n styleUpdater(\n sharableViewDescriptors,\n updaterFn,\n remoteState,\n maybeViewRef,\n animationsActive\n );\n };\n }\n const mapperId = startMapper(fun, inputs);\n return () => {\n stopMapper(mapperId);\n };\n }, dependencies);\n\n useEffect(() => {\n animationsActive.value = true;\n return () => {\n animationsActive.value = false;\n };\n }, []);\n\n checkSharedValueUsage(initial.value);\n\n if (process.env.JEST_WORKER_ID) {\n return { viewDescriptors, initial: initial, viewsRef, animatedStyle };\n } else {\n return { viewDescriptors, initial: initial, viewsRef };\n }\n}\n"],"mappings":"AAAA,SAA2BA,SAA3B,EAAsCC,MAAtC,QAAoD,OAApD;AAEA,SAASC,WAAT,EAAsBC,UAAtB,EAAkCC,UAAlC,QAAoD,SAApD;AACA,OAAOC,WAAP,IAAsBC,sBAAtB,QAAoD,gBAApD;AACA,SAASC,iBAAT,QAAkC,cAAlC;AACA,OAAOC,sBAAP,MAAmC,qBAAnC;AACA,SAASC,cAAT,QAA+B,kBAA/B;AACA,SACEC,iBADF,EAEEC,UAFF,EAGEC,YAHF,EAIEC,sBAJF,QAKO,SALP;AAOA,SACEC,sBADF,EAEEC,eAFF,QAKO,uBALP;AAMA,SAASC,MAAT,EAAiBC,cAAjB,QAAuC,oBAAvC;;AAmCA,SAASC,gBAAT,CACEC,cADF,EAEEC,YAFF,EAGEC,aAHF,EAIEC,SAJF,EAKQ;EACN;;EACA,IAAIC,KAAK,CAACC,OAAN,CAAcJ,YAAd,CAAJ,EAAiC;IAC/BA,YAAY,CAACK,OAAb,CAAqB,CAACC,IAAD,EAAOC,KAAP,KAAiB;MACpCT,gBAAgB,CACdC,cADc,EAEdO,IAFc,EAGdL,aAAa,IAAIA,aAAa,CAACM,KAAD,CAHhB,EAIdL,SAAS,IAAIA,SAAS,CAACK,KAAD,CAJR,CAAhB;IAMD,CAPD,EAD+B,CAS/B;EACD;;EACD,IAAI,OAAOP,YAAP,KAAwB,QAAxB,IAAoCA,YAAY,CAACQ,OAArD,EAA8D;IAC5D,MAAMC,SAAS,GAAGT,YAAlB;IAEA,IAAIU,KAAK,GAAGD,SAAS,CAACE,OAAtB;;IACA,IAAIT,SAAS,KAAKU,SAAlB,EAA6B;MAC3B,IAAI,OAAOV,SAAP,KAAqB,QAAzB,EAAmC;QACjC,IAAIA,SAAS,CAACQ,KAAV,KAAoBE,SAAxB,EAAmC;UACjC;UACAF,KAAK,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CAAC8F,QAAD,CAAV;IACD,CAFD;EAGD,CA3CQ,EA2CNnB,YA3CM,CAAT;EA6CA9E,SAAS,CAAC,MAAM;IACdyC,gBAAgB,CAACX,KAAjB,GAAyB,IAAzB;IACA,OAAO,MAAM;MACXW,gBAAgB,CAACX,KAAjB,GAAyB,KAAzB;IACD,CAFD;EAGD,CALQ,EAKN,EALM,CAAT;EAOA2C,qBAAqB,CAACiB,OAAO,CAAC5D,KAAT,CAArB;;EAEA,IAAIoE,OAAO,CAACC,GAAR,CAAYC,cAAhB,EAAgC;IAC9B,OAAO;MAAEpD,eAAF;MAAmB0C,OAAO,EAAEA,OAA5B;MAAqCX,QAArC;MAA+CT;IAA/C,CAAP;EACD,CAFD,MAEO;IACL,OAAO;MAAEtB,eAAF;MAAmB0C,OAAO,EAAEA,OAA5B;MAAqCX;IAArC,CAAP;EACD;AACF"}
|
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
import { useEffect, useRef } from 'react';
|
|
2
2
|
import { initialUpdaterRun } from '../animation';
|
|
3
3
|
import { makeMutable, startMapper, stopMapper } from '../core';
|
|
4
|
+
import { shouldBeUseWeb } from '../PlatformChecker';
|
|
4
5
|
export function useDerivedValue(processor, dependencies) {
|
|
5
6
|
const initRef = useRef(null);
|
|
6
|
-
|
|
7
|
+
let inputs = Object.values(processor._closure ?? {});
|
|
8
|
+
|
|
9
|
+
if (shouldBeUseWeb()) {
|
|
10
|
+
var _dependencies;
|
|
11
|
+
|
|
12
|
+
if (!inputs.length && (_dependencies = dependencies) !== null && _dependencies !== void 0 && _dependencies.length) {
|
|
13
|
+
// let web work without a Babel/SWC plugin
|
|
14
|
+
inputs = dependencies;
|
|
15
|
+
}
|
|
16
|
+
} // build dependencies
|
|
17
|
+
|
|
7
18
|
|
|
8
19
|
if (dependencies === undefined) {
|
|
9
20
|
dependencies = [...inputs, processor.__workletHash];
|