react-native-reanimated 3.0.0-rc.8 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Common/cpp/AnimatedSensor/AnimatedSensorModule.cpp +30 -12
- package/Common/cpp/AnimatedSensor/AnimatedSensorModule.h +2 -0
- package/Common/cpp/Fabric/FabricUtils.cpp +3 -107
- package/Common/cpp/Fabric/FabricUtils.h +3 -24
- package/Common/cpp/Fabric/ReanimatedUIManagerBinding.cpp +54 -37
- package/Common/cpp/LayoutAnimations/LayoutAnimationType.h +8 -0
- package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.cpp +81 -26
- package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.h +20 -3
- package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +122 -121
- package/Common/cpp/NativeModules/NativeReanimatedModule.h +21 -14
- package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +15 -7
- package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.h +8 -4
- package/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.cpp +50 -1
- package/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.h +10 -1
- package/Common/cpp/ReanimatedRuntime/ReanimatedRuntime.cpp +5 -1
- package/Common/cpp/Registries/EventHandlerRegistry.cpp +8 -34
- package/Common/cpp/Registries/EventHandlerRegistry.h +7 -13
- package/Common/cpp/SharedItems/Shareables.cpp +11 -63
- package/Common/cpp/SharedItems/Shareables.h +113 -93
- package/Common/cpp/Tools/CollectionUtils.h +14 -0
- package/Common/cpp/Tools/JsiUtils.cpp +26 -0
- package/Common/cpp/Tools/JsiUtils.h +176 -0
- package/Common/cpp/Tools/PlatformDepMethodsHolder.h +5 -5
- package/Common/cpp/Tools/ReanimatedVersion.cpp +17 -0
- package/Common/cpp/Tools/ReanimatedVersion.h +11 -0
- package/Common/cpp/Tools/RuntimeDecorator.cpp +67 -247
- package/Common/cpp/Tools/RuntimeDecorator.h +2 -3
- package/Common/cpp/Tools/WorkletEventHandler.cpp +3 -2
- package/Common/cpp/Tools/WorkletEventHandler.h +14 -6
- package/RNReanimated.podspec +2 -1
- package/android/CMakeLists.txt +188 -181
- package/android/build.gradle +362 -311
- package/android/proguard-rules.pro +2 -0
- package/android/src/fabric/java/com/swmansion/reanimated/NativeProxy.java +63 -295
- package/android/src/main/cpp/LayoutAnimations.cpp +35 -5
- package/android/src/main/cpp/LayoutAnimations.h +23 -6
- package/android/src/main/cpp/NativeProxy.cpp +143 -98
- package/android/src/main/cpp/NativeProxy.h +22 -28
- package/android/src/main/java/com/swmansion/reanimated/ReanimatedPackage.java +5 -4
- package/android/src/main/java/com/swmansion/reanimated/Utils.java +7 -1
- package/android/src/main/java/com/swmansion/reanimated/keyboardObserver/ReanimatedKeyboardEventListener.java +10 -3
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/AnimationsManager.java +218 -35
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/LayoutAnimations.java +43 -17
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/NativeMethodsHolder.java +6 -2
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/SharedElement.java +19 -0
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/SharedTransitionManager.java +610 -0
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/Snapshot.java +93 -23
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/AnimationFrameCallback.java +19 -0
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/EventHandler.java +35 -0
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/KeyboardEventDataUpdater.java +16 -0
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/NativeProxyCommon.java +206 -0
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/SensorSetter.java +17 -0
- package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensor.java +9 -3
- package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorContainer.java +3 -4
- package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorListener.java +31 -7
- package/android/src/paper/java/com/swmansion/reanimated/NativeProxy.java +90 -307
- package/android/src/reactNativeVersionPatch/ReanimatedUIManager/70/com/swmansion/reanimated/ReanimatedUIManagerFactory.java +16 -0
- package/android/src/reactNativeVersionPatch/ReanimatedUIManager/latest/com/swmansion/reanimated/ReanimatedUIManagerFactory.java +63 -0
- package/android/src/reactNativeVersionPatch/ReanimatedUIManager/latest/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +271 -0
- package/android/src/reactNativeVersionPatch/nativeHierarchyManager/latest/com/swmansion/reanimated/layoutReanimation/ReanimatedNativeHierarchyManager.java +76 -20
- package/ios/LayoutReanimation/REAAnimationsManager.h +31 -5
- package/ios/LayoutReanimation/REAAnimationsManager.m +265 -77
- package/ios/LayoutReanimation/REAFrame.h +10 -0
- package/ios/LayoutReanimation/REAFrame.m +15 -0
- package/ios/LayoutReanimation/REAScreensHelper.h +19 -0
- package/ios/LayoutReanimation/REAScreensHelper.m +106 -0
- package/ios/LayoutReanimation/REASharedElement.h +15 -0
- package/ios/LayoutReanimation/REASharedElement.m +16 -0
- package/ios/LayoutReanimation/REASharedTransitionManager.h +17 -0
- package/ios/LayoutReanimation/REASharedTransitionManager.m +632 -0
- package/ios/LayoutReanimation/REASnapshot.h +1 -0
- package/ios/LayoutReanimation/REASnapshot.m +96 -11
- package/ios/LayoutReanimation/REAUIManager.mm +67 -60
- package/ios/REAModule.mm +2 -7
- package/ios/REANodesManager.mm +1 -21
- package/ios/keyboardObserver/REAKeyboardEventObserver.m +72 -36
- package/ios/native/NativeProxy.mm +75 -114
- package/ios/native/REAInitializer.mm +2 -7
- package/ios/native/REAJSIUtils.h +60 -2
- package/ios/sensor/ReanimatedSensor.h +6 -2
- package/ios/sensor/ReanimatedSensor.m +43 -7
- package/ios/sensor/ReanimatedSensorContainer.h +4 -1
- package/ios/sensor/ReanimatedSensorContainer.m +8 -2
- package/lib/commonjs/createAnimatedComponent.js +232 -28
- package/lib/commonjs/createAnimatedComponent.js.map +1 -1
- package/lib/commonjs/reanimated2/Colors.js +43 -22
- package/lib/commonjs/reanimated2/Colors.js.map +1 -1
- package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js +18 -35
- package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/styleAnimation.js +5 -1
- package/lib/commonjs/reanimated2/animation/styleAnimation.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/util.js +17 -15
- package/lib/commonjs/reanimated2/animation/util.js.map +1 -1
- package/lib/commonjs/reanimated2/commonTypes.js +33 -1
- package/lib/commonjs/reanimated2/commonTypes.js.map +1 -1
- package/lib/commonjs/reanimated2/component/FlatList.js +19 -3
- package/lib/commonjs/reanimated2/component/FlatList.js.map +1 -1
- package/lib/commonjs/reanimated2/core.js +34 -83
- package/lib/commonjs/reanimated2/core.js.map +1 -1
- package/lib/commonjs/reanimated2/errors.js +66 -0
- package/lib/commonjs/reanimated2/errors.js.map +1 -0
- package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryUI.js +2 -2
- package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryUI.js.map +1 -1
- package/lib/commonjs/reanimated2/globals.d.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/index.js +0 -6
- package/lib/commonjs/reanimated2/hook/index.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js +5 -2
- package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedReaction.js +13 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedReaction.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedRef.js +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedRef.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js +89 -16
- package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js +43 -50
- package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useDerivedValue.js +13 -1
- package/lib/commonjs/reanimated2/hook/useDerivedValue.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useScrollViewOffset.js +2 -2
- package/lib/commonjs/reanimated2/hook/useScrollViewOffset.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/utils.js +18 -65
- package/lib/commonjs/reanimated2/hook/utils.js.map +1 -1
- package/lib/commonjs/reanimated2/index.js +13 -0
- package/lib/commonjs/reanimated2/index.js.map +1 -1
- package/lib/commonjs/reanimated2/initializers.js +196 -0
- package/lib/commonjs/reanimated2/initializers.js.map +1 -0
- package/lib/commonjs/reanimated2/interpolateColor.js +96 -19
- package/lib/commonjs/reanimated2/interpolateColor.js.map +1 -1
- package/lib/commonjs/reanimated2/jestUtils.js +1 -1
- package/lib/commonjs/reanimated2/jestUtils.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js +101 -16
- package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/Mapper.js +22 -0
- package/lib/commonjs/reanimated2/js-reanimated/Mapper.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/WebSensor.js +2 -0
- package/lib/commonjs/reanimated2/js-reanimated/WebSensor.js.map +1 -0
- package/lib/commonjs/reanimated2/js-reanimated/commonTypes.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/global.js +4 -9
- package/lib/commonjs/reanimated2/js-reanimated/global.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/index.js +0 -1
- package/lib/commonjs/reanimated2/js-reanimated/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +11 -0
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/index.js +8 -0
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js +16 -12
- package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +16 -23
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +8 -14
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Roll.js +8 -14
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Slide.js +8 -15
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +16 -23
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/index.js +13 -0
- package/lib/commonjs/reanimated2/layoutReanimation/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/sharedTransitions/index.js +94 -0
- package/lib/commonjs/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -0
- package/lib/commonjs/reanimated2/mappers.js +18 -6
- package/lib/commonjs/reanimated2/mappers.js.map +1 -1
- package/lib/commonjs/reanimated2/mock.js +45 -0
- package/lib/commonjs/reanimated2/mock.js.map +1 -1
- package/lib/commonjs/reanimated2/mutables.js +4 -2
- package/lib/commonjs/reanimated2/mutables.js.map +1 -1
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.js +42 -0
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.js.map +1 -0
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.web.js +15 -0
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.web.js.map +1 -0
- package/lib/commonjs/reanimated2/pluginUtils.js +11 -0
- package/lib/commonjs/reanimated2/pluginUtils.js.map +1 -0
- package/lib/commonjs/reanimated2/shareables.js +38 -11
- package/lib/commonjs/reanimated2/shareables.js.map +1 -1
- package/lib/commonjs/reanimated2/threads.js +114 -4
- package/lib/commonjs/reanimated2/threads.js.map +1 -1
- package/lib/commonjs/reanimated2/utils.js +7 -0
- package/lib/commonjs/reanimated2/utils.js.map +1 -1
- package/lib/commonjs/reanimated2/valueSetter.js +1 -3
- package/lib/commonjs/reanimated2/valueSetter.js.map +1 -1
- package/lib/module/createAnimatedComponent.js +229 -29
- package/lib/module/createAnimatedComponent.js.map +1 -1
- package/lib/module/reanimated2/Colors.js +35 -19
- package/lib/module/reanimated2/Colors.js.map +1 -1
- package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js +18 -34
- package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
- package/lib/module/reanimated2/animation/styleAnimation.js +5 -1
- package/lib/module/reanimated2/animation/styleAnimation.js.map +1 -1
- package/lib/module/reanimated2/animation/util.js +17 -16
- package/lib/module/reanimated2/animation/util.js.map +1 -1
- package/lib/module/reanimated2/commonTypes.js +29 -0
- package/lib/module/reanimated2/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/component/FlatList.js +18 -4
- package/lib/module/reanimated2/component/FlatList.js.map +1 -1
- package/lib/module/reanimated2/core.js +30 -76
- package/lib/module/reanimated2/core.js.map +1 -1
- package/lib/module/reanimated2/errors.js +58 -0
- package/lib/module/reanimated2/errors.js.map +1 -0
- package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js +2 -2
- package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js.map +1 -1
- package/lib/module/reanimated2/globals.d.js.map +1 -1
- package/lib/module/reanimated2/hook/index.js +1 -1
- package/lib/module/reanimated2/hook/index.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedKeyboard.js +5 -2
- package/lib/module/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedReaction.js +12 -1
- package/lib/module/reanimated2/hook/useAnimatedReaction.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedRef.js +2 -2
- package/lib/module/reanimated2/hook/useAnimatedRef.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedSensor.js +88 -13
- package/lib/module/reanimated2/hook/useAnimatedSensor.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedStyle.js +45 -52
- package/lib/module/reanimated2/hook/useAnimatedStyle.js.map +1 -1
- package/lib/module/reanimated2/hook/useDerivedValue.js +12 -1
- package/lib/module/reanimated2/hook/useDerivedValue.js.map +1 -1
- package/lib/module/reanimated2/hook/useScrollViewOffset.js +2 -2
- package/lib/module/reanimated2/hook/useScrollViewOffset.js.map +1 -1
- package/lib/module/reanimated2/hook/utils.js +17 -60
- package/lib/module/reanimated2/hook/utils.js.map +1 -1
- package/lib/module/reanimated2/index.js +1 -0
- package/lib/module/reanimated2/index.js.map +1 -1
- package/lib/module/reanimated2/initializers.js +182 -0
- package/lib/module/reanimated2/initializers.js.map +1 -0
- package/lib/module/reanimated2/interpolateColor.js +96 -19
- package/lib/module/reanimated2/interpolateColor.js.map +1 -1
- package/lib/module/reanimated2/jestUtils.js +1 -1
- package/lib/module/reanimated2/jestUtils.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/JSReanimated.js +101 -16
- package/lib/module/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/Mapper.js +21 -0
- package/lib/module/reanimated2/js-reanimated/Mapper.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/WebSensor.js +2 -0
- package/lib/module/reanimated2/js-reanimated/WebSensor.js.map +1 -0
- package/lib/module/reanimated2/js-reanimated/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/global.js +4 -9
- package/lib/module/reanimated2/js-reanimated/global.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/index.js +0 -1
- package/lib/module/reanimated2/js-reanimated/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +9 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/index.js +1 -0
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationsManager.js +15 -10
- package/lib/module/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +16 -21
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +8 -12
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js +8 -12
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js +8 -13
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +16 -21
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/index.js +1 -0
- package/lib/module/reanimated2/layoutReanimation/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js +82 -0
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -0
- package/lib/module/reanimated2/mappers.js +16 -6
- package/lib/module/reanimated2/mappers.js.map +1 -1
- package/lib/module/reanimated2/mock.js +45 -0
- package/lib/module/reanimated2/mock.js.map +1 -1
- package/lib/module/reanimated2/mutables.js +4 -2
- package/lib/module/reanimated2/mutables.js.map +1 -1
- package/lib/module/reanimated2/platform-specific/checkVersion.js +35 -0
- package/lib/module/reanimated2/platform-specific/checkVersion.js.map +1 -0
- package/lib/module/reanimated2/platform-specific/checkVersion.web.js +8 -0
- package/lib/module/reanimated2/platform-specific/checkVersion.web.js.map +1 -0
- package/lib/module/reanimated2/pluginUtils.js +4 -0
- package/lib/module/reanimated2/pluginUtils.js.map +1 -0
- package/lib/module/reanimated2/shareables.js +38 -9
- package/lib/module/reanimated2/shareables.js.map +1 -1
- package/lib/module/reanimated2/threads.js +105 -4
- package/lib/module/reanimated2/threads.js.map +1 -1
- package/lib/module/reanimated2/utils.js +5 -0
- package/lib/module/reanimated2/utils.js.map +1 -1
- package/lib/module/reanimated2/valueSetter.js +1 -2
- package/lib/module/reanimated2/valueSetter.js.map +1 -1
- package/package.json +9 -8
- package/{plugin.js → plugin/index.js} +173 -228
- package/react-native-reanimated.d.ts +57 -10
- package/scripts/reanimated_utils.rb +15 -2
- package/src/createAnimatedComponent.tsx +238 -28
- package/src/reanimated2/Colors.ts +38 -11
- package/src/reanimated2/NativeReanimated/NativeReanimated.ts +63 -41
- package/src/reanimated2/animation/styleAnimation.ts +8 -1
- package/src/reanimated2/animation/util.ts +29 -16
- package/src/reanimated2/commonTypes.ts +28 -1
- package/src/reanimated2/component/FlatList.tsx +30 -5
- package/src/reanimated2/core.ts +45 -75
- package/src/reanimated2/errors.ts +57 -0
- package/src/reanimated2/frameCallback/FrameCallbackRegistryUI.ts +2 -2
- package/src/reanimated2/globals.d.ts +34 -18
- package/src/reanimated2/hook/index.ts +1 -1
- package/src/reanimated2/hook/useAnimatedKeyboard.ts +10 -4
- package/src/reanimated2/hook/useAnimatedReaction.ts +12 -5
- package/src/reanimated2/hook/useAnimatedRef.ts +1 -4
- package/src/reanimated2/hook/useAnimatedSensor.ts +88 -11
- package/src/reanimated2/hook/useAnimatedStyle.ts +43 -45
- package/src/reanimated2/hook/useDerivedValue.ts +8 -1
- package/src/reanimated2/hook/useScrollViewOffset.ts +2 -2
- package/src/reanimated2/hook/utils.ts +15 -61
- package/src/reanimated2/index.ts +1 -0
- package/src/reanimated2/initializers.ts +184 -0
- package/src/reanimated2/interpolateColor.ts +104 -20
- package/src/reanimated2/jestUtils.ts +1 -1
- package/src/reanimated2/js-reanimated/JSReanimated.ts +105 -18
- package/src/reanimated2/js-reanimated/Mapper.ts +32 -0
- package/src/reanimated2/js-reanimated/WebSensor.ts +34 -0
- package/src/reanimated2/js-reanimated/commonTypes.ts +0 -1
- package/src/reanimated2/js-reanimated/global.ts +4 -8
- package/src/reanimated2/js-reanimated/index.ts +0 -1
- package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +13 -1
- package/src/reanimated2/layoutReanimation/animationBuilder/index.ts +1 -0
- package/src/reanimated2/layoutReanimation/animationsManager.ts +17 -12
- package/src/reanimated2/layoutReanimation/defaultAnimations/Bounce.ts +16 -19
- package/src/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.ts +14 -11
- package/src/reanimated2/layoutReanimation/defaultAnimations/Roll.ts +21 -11
- package/src/reanimated2/layoutReanimation/defaultAnimations/Slide.ts +32 -11
- package/src/reanimated2/layoutReanimation/defaultAnimations/Zoom.ts +36 -19
- package/src/reanimated2/layoutReanimation/index.ts +1 -0
- package/src/reanimated2/layoutReanimation/sharedTransitions/index.ts +87 -0
- package/src/reanimated2/mappers.ts +17 -6
- package/src/reanimated2/mock.ts +128 -0
- package/src/reanimated2/mutables.ts +2 -0
- package/src/reanimated2/platform-specific/checkVersion.ts +39 -0
- package/src/reanimated2/platform-specific/checkVersion.web.ts +6 -0
- package/src/reanimated2/pluginUtils.ts +8 -0
- package/src/reanimated2/shareables.ts +47 -11
- package/src/reanimated2/threads.ts +103 -1
- package/src/reanimated2/utils.ts +6 -0
- package/src/reanimated2/valueSetter.ts +1 -2
- package/lib/commonjs/reanimated2/time.js +0 -55
- package/lib/commonjs/reanimated2/time.js.map +0 -1
- package/lib/module/reanimated2/time.js +0 -37
- package/lib/module/reanimated2/time.js.map +0 -1
- package/src/reanimated2/time.ts +0 -30
- /package/android/src/{main/java → reactNativeVersionPatch/ReanimatedUIManager/70}/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +0 -0
|
@@ -3,12 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
Object.defineProperty(exports, "SensorType", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _useAnimatedSensor.SensorType;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
6
|
Object.defineProperty(exports, "useAnimatedGestureHandler", {
|
|
13
7
|
enumerable: true,
|
|
14
8
|
get: function () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export type { DependencyList } from './commonTypes';\nexport {\n useAnimatedProps,\n useEvent,\n useHandler,\n useWorkletCallback,\n} from './Hooks';\nexport { useSharedValue } from './useSharedValue';\nexport { useAnimatedStyle } from './useAnimatedStyle';\nexport type { AnimatedStyleResult } from './useAnimatedStyle';\nexport { useAnimatedGestureHandler } from './useAnimatedGestureHandler';\nexport type {\n GestureHandlerEvent,\n GestureHandlers,\n} from './useAnimatedGestureHandler';\nexport { useAnimatedReaction } from './useAnimatedReaction';\nexport type { AnimatedReactionWorkletFunction } from './useAnimatedReaction';\nexport { useAnimatedRef } from './useAnimatedRef';\nexport { useAnimatedScrollHandler } from './useAnimatedScrollHandler';\nexport type { ScrollHandler, ScrollHandlers } from './useAnimatedScrollHandler';\nexport { useDerivedValue } from './useDerivedValue';\nexport type { DerivedValue } from './useDerivedValue';\nexport { useAnimatedSensor
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export type { DependencyList } from './commonTypes';\nexport {\n useAnimatedProps,\n useEvent,\n useHandler,\n useWorkletCallback,\n} from './Hooks';\nexport { useSharedValue } from './useSharedValue';\nexport { useAnimatedStyle } from './useAnimatedStyle';\nexport type { AnimatedStyleResult } from './useAnimatedStyle';\nexport { useAnimatedGestureHandler } from './useAnimatedGestureHandler';\nexport type {\n GestureHandlerEvent,\n GestureHandlers,\n} from './useAnimatedGestureHandler';\nexport { useAnimatedReaction } from './useAnimatedReaction';\nexport type { AnimatedReactionWorkletFunction } from './useAnimatedReaction';\nexport { useAnimatedRef } from './useAnimatedRef';\nexport { useAnimatedScrollHandler } from './useAnimatedScrollHandler';\nexport type { ScrollHandler, ScrollHandlers } from './useAnimatedScrollHandler';\nexport { useDerivedValue } from './useDerivedValue';\nexport type { DerivedValue } from './useDerivedValue';\nexport { useAnimatedSensor } from './useAnimatedSensor';\nexport { useFrameCallback } from './useFrameCallback';\nexport type { FrameCallback } from './useFrameCallback';\nexport { useAnimatedKeyboard } from './useAnimatedKeyboard';\nexport { useScrollViewOffset } from './useScrollViewOffset';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AAMA;;AACA;;AAEA;;AAKA;;AAEA;;AACA;;AAEA;;AAEA;;AACA;;AAEA;;AACA"}
|
|
@@ -12,6 +12,9 @@ var _core = require("../core");
|
|
|
12
12
|
var _commonTypes = require("../commonTypes");
|
|
13
13
|
|
|
14
14
|
function useAnimatedKeyboard() {
|
|
15
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
16
|
+
isStatusBarTranslucentAndroid: false
|
|
17
|
+
};
|
|
15
18
|
const ref = (0, _react.useRef)(null);
|
|
16
19
|
const listenerId = (0, _react.useRef)(-1);
|
|
17
20
|
const isSubscribed = (0, _react.useRef)(false);
|
|
@@ -26,7 +29,7 @@ function useAnimatedKeyboard() {
|
|
|
26
29
|
|
|
27
30
|
keyboardEventData.state.value = state;
|
|
28
31
|
keyboardEventData.height.value = height;
|
|
29
|
-
});
|
|
32
|
+
}, options);
|
|
30
33
|
ref.current = keyboardEventData;
|
|
31
34
|
isSubscribed.current = true;
|
|
32
35
|
}
|
|
@@ -40,7 +43,7 @@ function useAnimatedKeyboard() {
|
|
|
40
43
|
|
|
41
44
|
keyboardEventData.state.value = state;
|
|
42
45
|
keyboardEventData.height.value = height;
|
|
43
|
-
});
|
|
46
|
+
}, options);
|
|
44
47
|
isSubscribed.current = true;
|
|
45
48
|
}
|
|
46
49
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useAnimatedKeyboard","ref","useRef","listenerId","isSubscribed","current","keyboardEventData","state","makeMutable","KeyboardState","UNKNOWN","height","subscribeForKeyboardEvents","value","useEffect","unsubscribeFromKeyboardEvents"],"sources":["useAnimatedKeyboard.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\nimport {\n makeMutable,\n subscribeForKeyboardEvents,\n unsubscribeFromKeyboardEvents,\n} from '../core';\nimport {
|
|
1
|
+
{"version":3,"names":["useAnimatedKeyboard","options","isStatusBarTranslucentAndroid","ref","useRef","listenerId","isSubscribed","current","keyboardEventData","state","makeMutable","KeyboardState","UNKNOWN","height","subscribeForKeyboardEvents","value","useEffect","unsubscribeFromKeyboardEvents"],"sources":["useAnimatedKeyboard.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\nimport {\n makeMutable,\n subscribeForKeyboardEvents,\n unsubscribeFromKeyboardEvents,\n} from '../core';\nimport {\n AnimatedKeyboardInfo,\n AnimatedKeyboardOptions,\n KeyboardState,\n} from '../commonTypes';\n\nexport function useAnimatedKeyboard(\n options: AnimatedKeyboardOptions = { isStatusBarTranslucentAndroid: false }\n): AnimatedKeyboardInfo {\n const ref = useRef<AnimatedKeyboardInfo | null>(null);\n const listenerId = useRef<number>(-1);\n const isSubscribed = useRef<boolean>(false);\n\n if (ref.current === null) {\n const keyboardEventData: AnimatedKeyboardInfo = {\n state: makeMutable<KeyboardState>(KeyboardState.UNKNOWN),\n height: makeMutable(0),\n };\n listenerId.current = subscribeForKeyboardEvents((state, height) => {\n 'worklet';\n keyboardEventData.state.value = state;\n keyboardEventData.height.value = height;\n }, options);\n ref.current = keyboardEventData;\n isSubscribed.current = true;\n }\n useEffect(() => {\n if (isSubscribed.current === false && ref.current !== null) {\n const keyboardEventData = ref.current;\n // subscribe again after Fast Refresh\n listenerId.current = subscribeForKeyboardEvents((state, height) => {\n 'worklet';\n keyboardEventData.state.value = state;\n keyboardEventData.height.value = height;\n }, options);\n isSubscribed.current = true;\n }\n return () => {\n unsubscribeFromKeyboardEvents(listenerId.current);\n isSubscribed.current = false;\n };\n }, []);\n return ref.current;\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;AAKA;;AAMO,SAASA,mBAAT,GAEiB;EAAA,IADtBC,OACsB,uEADa;IAAEC,6BAA6B,EAAE;EAAjC,CACb;EACtB,MAAMC,GAAG,GAAG,IAAAC,aAAA,EAAoC,IAApC,CAAZ;EACA,MAAMC,UAAU,GAAG,IAAAD,aAAA,EAAe,CAAC,CAAhB,CAAnB;EACA,MAAME,YAAY,GAAG,IAAAF,aAAA,EAAgB,KAAhB,CAArB;;EAEA,IAAID,GAAG,CAACI,OAAJ,KAAgB,IAApB,EAA0B;IACxB,MAAMC,iBAAuC,GAAG;MAC9CC,KAAK,EAAE,IAAAC,iBAAA,EAA2BC,0BAAA,CAAcC,OAAzC,CADuC;MAE9CC,MAAM,EAAE,IAAAH,iBAAA,EAAY,CAAZ;IAFsC,CAAhD;IAIAL,UAAU,CAACE,OAAX,GAAqB,IAAAO,gCAAA,EAA2B,CAACL,KAAD,EAAQI,MAAR,KAAmB;MACjE;;MACAL,iBAAiB,CAACC,KAAlB,CAAwBM,KAAxB,GAAgCN,KAAhC;MACAD,iBAAiB,CAACK,MAAlB,CAAyBE,KAAzB,GAAiCF,MAAjC;IACD,CAJoB,EAIlBZ,OAJkB,CAArB;IAKAE,GAAG,CAACI,OAAJ,GAAcC,iBAAd;IACAF,YAAY,CAACC,OAAb,GAAuB,IAAvB;EACD;;EACD,IAAAS,gBAAA,EAAU,MAAM;IACd,IAAIV,YAAY,CAACC,OAAb,KAAyB,KAAzB,IAAkCJ,GAAG,CAACI,OAAJ,KAAgB,IAAtD,EAA4D;MAC1D,MAAMC,iBAAiB,GAAGL,GAAG,CAACI,OAA9B,CAD0D,CAE1D;;MACAF,UAAU,CAACE,OAAX,GAAqB,IAAAO,gCAAA,EAA2B,CAACL,KAAD,EAAQI,MAAR,KAAmB;QACjE;;QACAL,iBAAiB,CAACC,KAAlB,CAAwBM,KAAxB,GAAgCN,KAAhC;QACAD,iBAAiB,CAACK,MAAlB,CAAyBE,KAAzB,GAAiCF,MAAjC;MACD,CAJoB,EAIlBZ,OAJkB,CAArB;MAKAK,YAAY,CAACC,OAAb,GAAuB,IAAvB;IACD;;IACD,OAAO,MAAM;MACX,IAAAU,mCAAA,EAA8BZ,UAAU,CAACE,OAAzC;MACAD,YAAY,CAACC,OAAb,GAAuB,KAAvB;IACD,CAHD;EAID,CAfD,EAeG,EAfH;EAgBA,OAAOJ,GAAG,CAACI,OAAX;AACD"}
|
|
@@ -11,6 +11,8 @@ var _core = require("../core");
|
|
|
11
11
|
|
|
12
12
|
var _useSharedValue = require("./useSharedValue");
|
|
13
13
|
|
|
14
|
+
var _PlatformChecker = require("../PlatformChecker");
|
|
15
|
+
|
|
14
16
|
/**
|
|
15
17
|
* @param prepare - worklet used for data preparation for the second parameter
|
|
16
18
|
* @param react - worklet which takes data prepared by the one in the first parameter and performs certain actions
|
|
@@ -19,6 +21,16 @@ var _useSharedValue = require("./useSharedValue");
|
|
|
19
21
|
*/
|
|
20
22
|
function useAnimatedReaction(prepare, react, dependencies) {
|
|
21
23
|
const previous = (0, _useSharedValue.useSharedValue)(null);
|
|
24
|
+
let inputs = Object.values(prepare._closure ?? {});
|
|
25
|
+
|
|
26
|
+
if ((0, _PlatformChecker.shouldBeUseWeb)()) {
|
|
27
|
+
var _dependencies;
|
|
28
|
+
|
|
29
|
+
if (!inputs.length && (_dependencies = dependencies) !== null && _dependencies !== void 0 && _dependencies.length) {
|
|
30
|
+
// let web work without a Babel/SWC plugin
|
|
31
|
+
inputs = dependencies;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
22
34
|
|
|
23
35
|
if (dependencies === undefined) {
|
|
24
36
|
dependencies = [Object.values(prepare._closure ?? {}), Object.values(react._closure ?? {}), prepare.__workletHash, react.__workletHash];
|
|
@@ -35,7 +47,7 @@ function useAnimatedReaction(prepare, react, dependencies) {
|
|
|
35
47
|
previous.value = input;
|
|
36
48
|
};
|
|
37
49
|
|
|
38
|
-
const mapperId = (0, _core.startMapper)(fun,
|
|
50
|
+
const mapperId = (0, _core.startMapper)(fun, inputs, []);
|
|
39
51
|
return () => {
|
|
40
52
|
(0, _core.stopMapper)(mapperId);
|
|
41
53
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useAnimatedReaction","prepare","react","dependencies","previous","useSharedValue","
|
|
1
|
+
{"version":3,"names":["useAnimatedReaction","prepare","react","dependencies","previous","useSharedValue","inputs","Object","values","_closure","shouldBeUseWeb","length","undefined","__workletHash","push","useEffect","fun","input","value","mapperId","startMapper","stopMapper"],"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;;AAEA;;AAEA;;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,mBAAT,CACLC,OADK,EAELC,KAFK,EAGLC,YAHK,EAIC;EACN,MAAMC,QAAQ,GAAG,IAAAC,8BAAA,EAAyB,IAAzB,CAAjB;EAEA,IAAIC,MAAM,GAAGC,MAAM,CAACC,MAAP,CAAcP,OAAO,CAACQ,QAAR,IAAoB,EAAlC,CAAb;;EAEA,IAAI,IAAAC,+BAAA,GAAJ,EAAsB;IAAA;;IACpB,IAAI,CAACJ,MAAM,CAACK,MAAR,qBAAkBR,YAAlB,0CAAkB,cAAcQ,MAApC,EAA4C;MAC1C;MACAL,MAAM,GAAGH,YAAT;IACD;EACF;;EAED,IAAIA,YAAY,KAAKS,SAArB,EAAgC;IAC9BT,YAAY,GAAG,CACbI,MAAM,CAACC,MAAP,CAAcP,OAAO,CAACQ,QAAR,IAAoB,EAAlC,CADa,EAEbF,MAAM,CAACC,MAAP,CAAcN,KAAK,CAACO,QAAN,IAAkB,EAAhC,CAFa,EAGbR,OAAO,CAACY,aAHK,EAIbX,KAAK,CAACW,aAJO,CAAf;EAMD,CAPD,MAOO;IACLV,YAAY,CAACW,IAAb,CAAkBb,OAAO,CAACY,aAA1B,EAAyCX,KAAK,CAACW,aAA/C;EACD;;EAED,IAAAE,gBAAA,EAAU,MAAM;IACd,MAAMC,GAAG,GAAG,MAAM;MAChB;;MACA,MAAMC,KAAK,GAAGhB,OAAO,EAArB;MACAC,KAAK,CAACe,KAAD,EAAQb,QAAQ,CAACc,KAAjB,CAAL;MACAd,QAAQ,CAACc,KAAT,GAAiBD,KAAjB;IACD,CALD;;IAMA,MAAME,QAAQ,GAAG,IAAAC,iBAAA,EAAYJ,GAAZ,EAAiBV,MAAjB,EAAyB,EAAzB,CAAjB;IACA,OAAO,MAAM;MACX,IAAAe,gBAAA,EAAWF,QAAX;IACD,CAFD;EAGD,CAXD,EAWGhB,YAXH;AAYD"}
|
|
@@ -16,7 +16,7 @@ var _fabricUtils = require("../fabricUtils");
|
|
|
16
16
|
var _shareables = require("../shareables");
|
|
17
17
|
|
|
18
18
|
function getShareableShadowNodeFromComponent(component) {
|
|
19
|
-
return (0,
|
|
19
|
+
return (0, _fabricUtils.getShadowNodeWrapperFromHostInstance)(component);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
const getTagValueFunction = global._IS_FABRIC ? getShareableShadowNodeFromComponent : _NativeMethods.getTag;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getShareableShadowNodeFromComponent","component","
|
|
1
|
+
{"version":3,"names":["getShareableShadowNodeFromComponent","component","getShadowNodeWrapperFromHostInstance","getTagValueFunction","global","_IS_FABRIC","getTag","useAnimatedRef","tag","useSharedValue","ref","useRef","current","fun","value","remoteRef","makeShareableCloneRecursive","__init","registerShareableMapping"],"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;;AACA;;AAGA;;AACA;;AACA;;AAKA,SAASA,mCAAT,CACEC,SADF,EAEqB;EACnB,OAAO,IAAAC,iDAAA,EAAqCD,SAArC,CAAP;AACD;;AAED,MAAME,mBAAmB,GAAGC,MAAM,CAACC,UAAP,GACxBL,mCADwB,GAExBM,qBAFJ;;AAIO,SAASC,cAAT,GAAqE;EAC1E,MAAMC,GAAG,GAAG,IAAAC,8BAAA,EAAkD,CAAC,CAAnD,CAAZ;EACA,MAAMC,GAAG,GAAG,IAAAC,aAAA,GAAZ;;EAEA,IAAI,CAACD,GAAG,CAACE,OAAT,EAAkB;IAChB,MAAMC,GAAyB,GAA2BZ,SAAD,IAAe;MACtE;MACA,IAAIA,SAAJ,EAAe;QACbO,GAAG,CAACM,KAAJ,GAAYX,mBAAmB,CAACF,SAAD,CAA/B;QACAY,GAAG,CAACD,OAAJ,GAAcX,SAAd;MACD;;MACD,OAAOO,GAAG,CAACM,KAAX;IACD,CAPD;;IASAD,GAAG,CAACD,OAAJ,GAAc,IAAd;IAEA,MAAMG,SAAS,GAAG,IAAAC,uCAAA,EAA4B;MAC5CC,MAAM,EAAE,MAAM;QACZ;;QACA,OAAO,MAAMT,GAAG,CAACM,KAAjB;MACD;IAJ2C,CAA5B,CAAlB;IAMA,IAAAI,oCAAA,EAAyBL,GAAzB,EAA8BE,SAA9B;IAEAL,GAAG,CAACE,OAAJ,GAAcC,GAAd;EACD;;EAED,OAAOH,GAAG,CAACE,OAAX;AACD"}
|
|
@@ -3,26 +3,16 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.SensorType = void 0;
|
|
7
6
|
exports.useAnimatedSensor = useAnimatedSensor;
|
|
8
7
|
|
|
9
8
|
var _react = require("react");
|
|
10
9
|
|
|
11
10
|
var _core = require("../core");
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
exports.SensorType = SensorType;
|
|
15
|
-
|
|
16
|
-
(function (SensorType) {
|
|
17
|
-
SensorType[SensorType["ACCELEROMETER"] = 1] = "ACCELEROMETER";
|
|
18
|
-
SensorType[SensorType["GYROSCOPE"] = 2] = "GYROSCOPE";
|
|
19
|
-
SensorType[SensorType["GRAVITY"] = 3] = "GRAVITY";
|
|
20
|
-
SensorType[SensorType["MAGNETIC_FIELD"] = 4] = "MAGNETIC_FIELD";
|
|
21
|
-
SensorType[SensorType["ROTATION"] = 5] = "ROTATION";
|
|
22
|
-
})(SensorType || (exports.SensorType = SensorType = {}));
|
|
12
|
+
var _commonTypes = require("../commonTypes");
|
|
23
13
|
|
|
24
14
|
function initSensorData(sensorType) {
|
|
25
|
-
if (sensorType === SensorType.ROTATION) {
|
|
15
|
+
if (sensorType === _commonTypes.SensorType.ROTATION) {
|
|
26
16
|
return (0, _core.makeMutable)({
|
|
27
17
|
qw: 0,
|
|
28
18
|
qx: 0,
|
|
@@ -30,15 +20,86 @@ function initSensorData(sensorType) {
|
|
|
30
20
|
qz: 0,
|
|
31
21
|
yaw: 0,
|
|
32
22
|
pitch: 0,
|
|
33
|
-
roll: 0
|
|
23
|
+
roll: 0,
|
|
24
|
+
interfaceOrientation: 0
|
|
34
25
|
});
|
|
35
26
|
} else {
|
|
36
27
|
return (0, _core.makeMutable)({
|
|
37
28
|
x: 0,
|
|
38
29
|
y: 0,
|
|
39
|
-
z: 0
|
|
30
|
+
z: 0,
|
|
31
|
+
interfaceOrientation: 0
|
|
40
32
|
});
|
|
41
33
|
}
|
|
34
|
+
} // euler angles are in order ZXY, z = yaw, x = pitch, y = roll
|
|
35
|
+
// https://github.com/mrdoob/three.js/blob/dev/src/math/Quaternion.js#L237
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
function eulerToQuaternion(pitch, roll, yaw) {
|
|
39
|
+
'worklet';
|
|
40
|
+
|
|
41
|
+
const c1 = Math.cos(pitch / 2);
|
|
42
|
+
const s1 = Math.sin(pitch / 2);
|
|
43
|
+
const c2 = Math.cos(roll / 2);
|
|
44
|
+
const s2 = Math.sin(roll / 2);
|
|
45
|
+
const c3 = Math.cos(yaw / 2);
|
|
46
|
+
const s3 = Math.sin(yaw / 2);
|
|
47
|
+
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];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function adjustRotationToInterfaceOrientation(data) {
|
|
51
|
+
'worklet';
|
|
52
|
+
|
|
53
|
+
const {
|
|
54
|
+
interfaceOrientation,
|
|
55
|
+
pitch,
|
|
56
|
+
roll,
|
|
57
|
+
yaw
|
|
58
|
+
} = data;
|
|
59
|
+
|
|
60
|
+
if (interfaceOrientation === 90) {
|
|
61
|
+
data.pitch = roll;
|
|
62
|
+
data.roll = -pitch;
|
|
63
|
+
data.yaw = yaw - Math.PI / 2;
|
|
64
|
+
} else if (interfaceOrientation === 270) {
|
|
65
|
+
data.pitch = -roll;
|
|
66
|
+
data.roll = pitch;
|
|
67
|
+
data.yaw = yaw + Math.PI / 2;
|
|
68
|
+
} else if (interfaceOrientation === 180) {
|
|
69
|
+
data.pitch *= -1;
|
|
70
|
+
data.roll *= -1;
|
|
71
|
+
data.yaw *= -1;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const q = eulerToQuaternion(data.pitch, data.roll, data.yaw);
|
|
75
|
+
data.qx = q[0];
|
|
76
|
+
data.qy = q[1];
|
|
77
|
+
data.qz = q[2];
|
|
78
|
+
data.qw = q[3];
|
|
79
|
+
return data;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function adjustVectorToInterfaceOrientation(data) {
|
|
83
|
+
'worklet';
|
|
84
|
+
|
|
85
|
+
const {
|
|
86
|
+
interfaceOrientation,
|
|
87
|
+
x,
|
|
88
|
+
y
|
|
89
|
+
} = data;
|
|
90
|
+
|
|
91
|
+
if (interfaceOrientation === 90) {
|
|
92
|
+
data.x = -y;
|
|
93
|
+
data.y = x;
|
|
94
|
+
} else if (interfaceOrientation === 270) {
|
|
95
|
+
data.x = y;
|
|
96
|
+
data.y = -x;
|
|
97
|
+
} else if (interfaceOrientation === 180) {
|
|
98
|
+
data.x *= -1;
|
|
99
|
+
data.y *= -1;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return data;
|
|
42
103
|
}
|
|
43
104
|
|
|
44
105
|
function useAnimatedSensor(sensorType, userConfig) {
|
|
@@ -48,18 +109,30 @@ function useAnimatedSensor(sensorType, userConfig) {
|
|
|
48
109
|
},
|
|
49
110
|
isAvailable: false,
|
|
50
111
|
config: {
|
|
51
|
-
interval: 0
|
|
112
|
+
interval: 0,
|
|
113
|
+
adjustToInterfaceOrientation: true,
|
|
114
|
+
iosReferenceFrame: _commonTypes.IOSReferenceFrame.Auto
|
|
52
115
|
}
|
|
53
116
|
});
|
|
54
117
|
(0, _react.useEffect)(() => {
|
|
55
118
|
ref.current.config = {
|
|
56
119
|
interval: 'auto',
|
|
120
|
+
adjustToInterfaceOrientation: true,
|
|
121
|
+
iosReferenceFrame: _commonTypes.IOSReferenceFrame.Auto,
|
|
57
122
|
...userConfig
|
|
58
123
|
};
|
|
59
124
|
const sensorData = ref.current.sensor;
|
|
60
|
-
const id = (0, _core.registerSensor)(sensorType, ref.current.config.interval === 'auto' ? -1 : ref.current.config.interval, data => {
|
|
125
|
+
const id = (0, _core.registerSensor)(sensorType, ref.current.config.interval === 'auto' ? -1 : ref.current.config.interval, ref.current.config.iosReferenceFrame, data => {
|
|
61
126
|
'worklet';
|
|
62
127
|
|
|
128
|
+
if (ref.current.config.adjustToInterfaceOrientation) {
|
|
129
|
+
if (sensorType === _commonTypes.SensorType.ROTATION) {
|
|
130
|
+
data = adjustRotationToInterfaceOrientation(data);
|
|
131
|
+
} else {
|
|
132
|
+
data = adjustVectorToInterfaceOrientation(data);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
63
136
|
sensorData.value = data;
|
|
64
137
|
});
|
|
65
138
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["initSensorData","sensorType","SensorType","ROTATION","makeMutable","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","useRef","sensor","unregister","isAvailable","config","interval","adjustToInterfaceOrientation","iosReferenceFrame","IOSReferenceFrame","Auto","useEffect","current","sensorData","id","registerSensor","value","unregisterSensor"],"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":"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"}
|
|
@@ -29,13 +29,12 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
29
29
|
|
|
30
30
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
function prepareAnimation(animatedProp, lastAnimation, lastValue) {
|
|
32
|
+
function prepareAnimation(frameTimestamp, animatedProp, lastAnimation, lastValue) {
|
|
34
33
|
'worklet';
|
|
35
34
|
|
|
36
35
|
if (Array.isArray(animatedProp)) {
|
|
37
36
|
animatedProp.forEach((prop, index) => {
|
|
38
|
-
prepareAnimation(prop, lastAnimation && lastAnimation[index], lastValue && lastValue[index]);
|
|
37
|
+
prepareAnimation(frameTimestamp, prop, lastAnimation && lastAnimation[index], lastValue && lastValue[index]);
|
|
39
38
|
}); // return animatedProp;
|
|
40
39
|
}
|
|
41
40
|
|
|
@@ -67,11 +66,11 @@ function prepareAnimation(animatedProp, lastAnimation, lastValue) {
|
|
|
67
66
|
animation.onStart(animation, value, timestamp, lastAnimation);
|
|
68
67
|
};
|
|
69
68
|
|
|
70
|
-
animation.callStart(
|
|
69
|
+
animation.callStart(frameTimestamp);
|
|
71
70
|
animation.callStart = null;
|
|
72
71
|
} else if (typeof animatedProp === 'object') {
|
|
73
72
|
// it is an object
|
|
74
|
-
Object.keys(animatedProp).forEach(key => prepareAnimation(animatedProp[key], lastAnimation && lastAnimation[key], lastValue && lastValue[key]));
|
|
73
|
+
Object.keys(animatedProp).forEach(key => prepareAnimation(frameTimestamp, animatedProp[key], lastAnimation && lastAnimation[key], lastValue && lastValue[key]));
|
|
75
74
|
}
|
|
76
75
|
}
|
|
77
76
|
|
|
@@ -134,30 +133,34 @@ function styleUpdater(viewDescriptors, updater, state, maybeViewRef, animationsA
|
|
|
134
133
|
const animations = state.animations ?? {};
|
|
135
134
|
const newValues = updater() ?? {};
|
|
136
135
|
const oldValues = state.last;
|
|
136
|
+
const nonAnimatedNewValues = {};
|
|
137
137
|
let hasAnimations = false;
|
|
138
|
+
let frameTimestamp;
|
|
139
|
+
let hasNonAnimatedValues = false;
|
|
138
140
|
|
|
139
141
|
for (const key in newValues) {
|
|
140
142
|
const value = newValues[key];
|
|
141
143
|
|
|
142
144
|
if ((0, _utils.isAnimated)(value)) {
|
|
143
|
-
|
|
145
|
+
frameTimestamp = global.__frameTimestamp || performance.now();
|
|
146
|
+
prepareAnimation(frameTimestamp, value, animations[key], oldValues[key]);
|
|
144
147
|
animations[key] = value;
|
|
145
148
|
hasAnimations = true;
|
|
146
149
|
} else {
|
|
150
|
+
hasNonAnimatedValues = true;
|
|
151
|
+
nonAnimatedNewValues[key] = value;
|
|
147
152
|
delete animations[key];
|
|
148
153
|
}
|
|
149
154
|
}
|
|
150
155
|
|
|
151
156
|
if (hasAnimations) {
|
|
152
|
-
const frame =
|
|
157
|
+
const frame = timestamp => {
|
|
153
158
|
const {
|
|
154
159
|
animations,
|
|
155
160
|
last,
|
|
156
161
|
isAnimationCancelled
|
|
157
162
|
} = state;
|
|
158
163
|
|
|
159
|
-
const timestamp = _timestamp ?? (0, _core.getTimestamp)();
|
|
160
|
-
|
|
161
164
|
if (isAnimationCancelled) {
|
|
162
165
|
state.isAnimationRunning = false;
|
|
163
166
|
return;
|
|
@@ -193,30 +196,22 @@ function styleUpdater(viewDescriptors, updater, state, maybeViewRef, animationsA
|
|
|
193
196
|
if (!state.isAnimationRunning) {
|
|
194
197
|
state.isAnimationCancelled = false;
|
|
195
198
|
state.isAnimationRunning = true;
|
|
196
|
-
|
|
197
|
-
if (_frameTimestamp) {
|
|
198
|
-
frame(_frameTimestamp);
|
|
199
|
-
} else {
|
|
200
|
-
requestAnimationFrame(frame);
|
|
201
|
-
}
|
|
199
|
+
frame(frameTimestamp);
|
|
202
200
|
}
|
|
203
201
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
if (style) {
|
|
208
|
-
(0, _UpdateProps.default)(viewDescriptors, style, maybeViewRef);
|
|
202
|
+
if (hasNonAnimatedValues) {
|
|
203
|
+
(0, _UpdateProps.default)(viewDescriptors, nonAnimatedNewValues, maybeViewRef);
|
|
209
204
|
}
|
|
210
205
|
} else {
|
|
211
206
|
state.isAnimationCancelled = true;
|
|
212
207
|
state.animations = [];
|
|
213
|
-
const diff = (0, _utils.styleDiff)(oldValues, newValues);
|
|
214
|
-
state.last = Object.assign({}, oldValues, newValues);
|
|
215
208
|
|
|
216
|
-
if (
|
|
209
|
+
if (!(0, _utils.shallowEqual)(oldValues, newValues)) {
|
|
217
210
|
(0, _UpdateProps.default)(viewDescriptors, newValues, maybeViewRef);
|
|
218
211
|
}
|
|
219
212
|
}
|
|
213
|
+
|
|
214
|
+
state.last = newValues;
|
|
220
215
|
}
|
|
221
216
|
|
|
222
217
|
function jestStyleUpdater(viewDescriptors, updater, state, maybeViewRef, animationsActive, animatedStyle) {
|
|
@@ -228,6 +223,7 @@ function jestStyleUpdater(viewDescriptors, updater, state, maybeViewRef, animati
|
|
|
228
223
|
const oldValues = state.last; // extract animated props
|
|
229
224
|
|
|
230
225
|
let hasAnimations = false;
|
|
226
|
+
let frameTimestamp;
|
|
231
227
|
Object.keys(animations).forEach(key => {
|
|
232
228
|
const value = newValues[key];
|
|
233
229
|
|
|
@@ -239,21 +235,20 @@ function jestStyleUpdater(viewDescriptors, updater, state, maybeViewRef, animati
|
|
|
239
235
|
const value = newValues[key];
|
|
240
236
|
|
|
241
237
|
if ((0, _utils.isAnimated)(value)) {
|
|
242
|
-
|
|
238
|
+
frameTimestamp = global.__frameTimestamp || performance.now();
|
|
239
|
+
prepareAnimation(frameTimestamp, value, animations[key], oldValues[key]);
|
|
243
240
|
animations[key] = value;
|
|
244
241
|
hasAnimations = true;
|
|
245
242
|
}
|
|
246
243
|
});
|
|
247
244
|
|
|
248
|
-
function frame(
|
|
245
|
+
function frame(timestamp) {
|
|
249
246
|
const {
|
|
250
247
|
animations,
|
|
251
248
|
last,
|
|
252
249
|
isAnimationCancelled
|
|
253
250
|
} = state;
|
|
254
251
|
|
|
255
|
-
const timestamp = _timestamp ?? (0, _core.getTimestamp)();
|
|
256
|
-
|
|
257
252
|
if (isAnimationCancelled) {
|
|
258
253
|
state.isAnimationRunning = false;
|
|
259
254
|
return;
|
|
@@ -289,12 +284,7 @@ function jestStyleUpdater(viewDescriptors, updater, state, maybeViewRef, animati
|
|
|
289
284
|
if (!state.isAnimationRunning) {
|
|
290
285
|
state.isAnimationCancelled = false;
|
|
291
286
|
state.isAnimationRunning = true;
|
|
292
|
-
|
|
293
|
-
if (_frameTimestamp) {
|
|
294
|
-
frame(_frameTimestamp);
|
|
295
|
-
} else {
|
|
296
|
-
requestAnimationFrame(frame);
|
|
297
|
-
}
|
|
287
|
+
frame(frameTimestamp);
|
|
298
288
|
}
|
|
299
289
|
} else {
|
|
300
290
|
state.isAnimationCancelled = true;
|
|
@@ -302,11 +292,10 @@ function jestStyleUpdater(viewDescriptors, updater, state, maybeViewRef, animati
|
|
|
302
292
|
} // calculate diff
|
|
303
293
|
|
|
304
294
|
|
|
305
|
-
|
|
306
|
-
state.last = Object.assign({}, oldValues, newValues);
|
|
295
|
+
state.last = newValues;
|
|
307
296
|
|
|
308
|
-
if (
|
|
309
|
-
(0, _UpdateProps.updatePropsJestWrapper)(viewDescriptors,
|
|
297
|
+
if (!(0, _utils.shallowEqual)(oldValues, newValues)) {
|
|
298
|
+
(0, _UpdateProps.updatePropsJestWrapper)(viewDescriptors, newValues, maybeViewRef, animatedStyle, adapters);
|
|
310
299
|
}
|
|
311
300
|
} // check for invalid usage of shared values in returned object
|
|
312
301
|
|
|
@@ -331,7 +320,23 @@ function checkSharedValueUsage(prop, currentKey) {
|
|
|
331
320
|
function useAnimatedStyle(updater, dependencies, adapters) {
|
|
332
321
|
const viewsRef = (0, _ViewDescriptorsSet.makeViewsRefSet)();
|
|
333
322
|
const initRef = (0, _react.useRef)();
|
|
334
|
-
|
|
323
|
+
let inputs = Object.values(updater._closure ?? {});
|
|
324
|
+
|
|
325
|
+
if ((0, _PlatformChecker.shouldBeUseWeb)()) {
|
|
326
|
+
var _dependencies;
|
|
327
|
+
|
|
328
|
+
if (!inputs.length && (_dependencies = dependencies) !== null && _dependencies !== void 0 && _dependencies.length) {
|
|
329
|
+
// let web work without a Babel/SWC plugin
|
|
330
|
+
inputs = dependencies;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
if (__DEV__ && !inputs.length && !dependencies && !updater.__workletHash) {
|
|
334
|
+
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.
|
|
335
|
+
|
|
336
|
+
For more, see the docs: https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/web-support#web-without-a-babel-plugin`);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
335
340
|
const adaptersArray = adapters ? Array.isArray(adapters) ? adapters : [adapters] : [];
|
|
336
341
|
const adaptersHash = adapters ? (0, _utils.buildWorkletsHash)(adaptersArray) : null;
|
|
337
342
|
const animationsActive = (0, _useSharedValue.useSharedValue)(true);
|
|
@@ -388,16 +393,6 @@ function useAnimatedStyle(updater, dependencies, adapters) {
|
|
|
388
393
|
};
|
|
389
394
|
}
|
|
390
395
|
|
|
391
|
-
if (!(0, _PlatformChecker.shouldBeUseWeb)()) {
|
|
392
|
-
updaterFn = () => {
|
|
393
|
-
'worklet';
|
|
394
|
-
|
|
395
|
-
const style = updaterFn();
|
|
396
|
-
(0, _utils.parseColors)(style);
|
|
397
|
-
return style;
|
|
398
|
-
};
|
|
399
|
-
}
|
|
400
|
-
|
|
401
396
|
if ((0, _PlatformChecker.isJest)()) {
|
|
402
397
|
fun = () => {
|
|
403
398
|
'worklet';
|
|
@@ -420,8 +415,6 @@ function useAnimatedStyle(updater, dependencies, adapters) {
|
|
|
420
415
|
(0, _react.useEffect)(() => {
|
|
421
416
|
animationsActive.value = true;
|
|
422
417
|
return () => {
|
|
423
|
-
// initRef.current = null;
|
|
424
|
-
// viewsRef = null;
|
|
425
418
|
animationsActive.value = false;
|
|
426
419
|
};
|
|
427
420
|
}, []);
|