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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
#import <RNReanimated/LayoutAnimationsManager.h>
|
|
1
2
|
#import <RNReanimated/NativeMethods.h>
|
|
2
3
|
#import <RNReanimated/NativeProxy.h>
|
|
3
4
|
#import <RNReanimated/REAAnimationsManager.h>
|
|
@@ -75,66 +76,6 @@ static CFTimeInterval calculateTimestampWithSlowAnimations(CFTimeInterval curren
|
|
|
75
76
|
#endif
|
|
76
77
|
}
|
|
77
78
|
|
|
78
|
-
// COPIED FROM RCTTurboModule.mm
|
|
79
|
-
static id convertJSIValueToObjCObject(jsi::Runtime &runtime, const jsi::Value &value);
|
|
80
|
-
|
|
81
|
-
static NSString *convertJSIStringToNSString(jsi::Runtime &runtime, const jsi::String &value)
|
|
82
|
-
{
|
|
83
|
-
return [NSString stringWithUTF8String:value.utf8(runtime).c_str()];
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
static NSDictionary *convertJSIObjectToNSDictionary(jsi::Runtime &runtime, const jsi::Object &value)
|
|
87
|
-
{
|
|
88
|
-
jsi::Array propertyNames = value.getPropertyNames(runtime);
|
|
89
|
-
size_t size = propertyNames.size(runtime);
|
|
90
|
-
NSMutableDictionary *result = [NSMutableDictionary new];
|
|
91
|
-
for (size_t i = 0; i < size; i++) {
|
|
92
|
-
jsi::String name = propertyNames.getValueAtIndex(runtime, i).getString(runtime);
|
|
93
|
-
NSString *k = convertJSIStringToNSString(runtime, name);
|
|
94
|
-
id v = convertJSIValueToObjCObject(runtime, value.getProperty(runtime, name));
|
|
95
|
-
if (v) {
|
|
96
|
-
result[k] = v;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
return [result copy];
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
static NSArray *convertJSIArrayToNSArray(jsi::Runtime &runtime, const jsi::Array &value)
|
|
103
|
-
{
|
|
104
|
-
size_t size = value.size(runtime);
|
|
105
|
-
NSMutableArray *result = [NSMutableArray new];
|
|
106
|
-
for (size_t i = 0; i < size; i++) {
|
|
107
|
-
// Insert kCFNull when it's `undefined` value to preserve the indices.
|
|
108
|
-
[result addObject:convertJSIValueToObjCObject(runtime, value.getValueAtIndex(runtime, i)) ?: (id)kCFNull];
|
|
109
|
-
}
|
|
110
|
-
return [result copy];
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
static id convertJSIValueToObjCObject(jsi::Runtime &runtime, const jsi::Value &value)
|
|
114
|
-
{
|
|
115
|
-
if (value.isUndefined() || value.isNull()) {
|
|
116
|
-
return nil;
|
|
117
|
-
}
|
|
118
|
-
if (value.isBool()) {
|
|
119
|
-
return @(value.getBool());
|
|
120
|
-
}
|
|
121
|
-
if (value.isNumber()) {
|
|
122
|
-
return @(value.getNumber());
|
|
123
|
-
}
|
|
124
|
-
if (value.isString()) {
|
|
125
|
-
return convertJSIStringToNSString(runtime, value.getString(runtime));
|
|
126
|
-
}
|
|
127
|
-
if (value.isObject()) {
|
|
128
|
-
jsi::Object o = value.getObject(runtime);
|
|
129
|
-
if (o.isArray(runtime)) {
|
|
130
|
-
return convertJSIArrayToNSArray(runtime, o.getArray(runtime));
|
|
131
|
-
}
|
|
132
|
-
return convertJSIObjectToNSDictionary(runtime, o);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
throw std::runtime_error("Unsupported jsi::jsi::Value kind");
|
|
136
|
-
}
|
|
137
|
-
|
|
138
79
|
static NSSet *convertProps(jsi::Runtime &rt, const jsi::Value &props)
|
|
139
80
|
{
|
|
140
81
|
NSMutableSet *propsSet = [[NSMutableSet alloc] init];
|
|
@@ -213,11 +154,7 @@ std::shared_ptr<NativeReanimatedModule> createReanimatedModule(
|
|
|
213
154
|
auto requestRender = [nodesManager, &module](std::function<void(double)> onRender, jsi::Runtime &rt) {
|
|
214
155
|
[nodesManager postOnAnimation:^(CADisplayLink *displayLink) {
|
|
215
156
|
double frameTimestamp = calculateTimestampWithSlowAnimations(displayLink.targetTimestamp) * 1000;
|
|
216
|
-
jsi::Object global = rt.global();
|
|
217
|
-
jsi::String frameTimestampName = jsi::String::createFromAscii(rt, "_frameTimestamp");
|
|
218
|
-
global.setProperty(rt, frameTimestampName, frameTimestamp);
|
|
219
157
|
onRender(frameTimestamp);
|
|
220
|
-
global.setProperty(rt, frameTimestampName, jsi::Value::undefined());
|
|
221
158
|
}];
|
|
222
159
|
};
|
|
223
160
|
|
|
@@ -228,7 +165,7 @@ std::shared_ptr<NativeReanimatedModule> createReanimatedModule(
|
|
|
228
165
|
[nodesManager synchronouslyUpdateViewOnUIThread:viewTag props:uiProps];
|
|
229
166
|
};
|
|
230
167
|
|
|
231
|
-
auto progressLayoutAnimation = [=](int tag, const jsi::Object &newStyle) {
|
|
168
|
+
auto progressLayoutAnimation = [=](int tag, const jsi::Object &newStyle, bool isSharedTransition) {
|
|
232
169
|
// noop
|
|
233
170
|
};
|
|
234
171
|
|
|
@@ -254,9 +191,11 @@ std::shared_ptr<NativeReanimatedModule> createReanimatedModule(
|
|
|
254
191
|
__weak REAAnimationsManager *weakAnimationsManager = animationsManager;
|
|
255
192
|
std::weak_ptr<jsi::Runtime> wrt = animatedRuntime;
|
|
256
193
|
|
|
257
|
-
auto progressLayoutAnimation = [=](int tag, const jsi::Object &newStyle) {
|
|
194
|
+
auto progressLayoutAnimation = [=](int tag, const jsi::Object &newStyle, bool isSharedTransition) {
|
|
258
195
|
NSDictionary *propsDict = convertJSIObjectToNSDictionary(*wrt.lock(), newStyle);
|
|
259
|
-
[weakAnimationsManager progressLayoutAnimationWithStyle:propsDict
|
|
196
|
+
[weakAnimationsManager progressLayoutAnimationWithStyle:propsDict
|
|
197
|
+
forTag:@(tag)
|
|
198
|
+
isSharedTransition:isSharedTransition];
|
|
260
199
|
};
|
|
261
200
|
|
|
262
201
|
auto endLayoutAnimation = [=](int tag, bool isCancelled, bool removeView) {
|
|
@@ -277,11 +216,13 @@ std::shared_ptr<NativeReanimatedModule> createReanimatedModule(
|
|
|
277
216
|
|
|
278
217
|
// sensors
|
|
279
218
|
ReanimatedSensorContainer *reanimatedSensorContainer = [[ReanimatedSensorContainer alloc] init];
|
|
280
|
-
auto registerSensorFunction =
|
|
219
|
+
auto registerSensorFunction =
|
|
220
|
+
[=](int sensorType, int interval, int iosReferenceFrame, std::function<void(double[], int)> setter) -> int {
|
|
281
221
|
return [reanimatedSensorContainer registerSensor:(ReanimatedSensorType)sensorType
|
|
282
222
|
interval:interval
|
|
283
|
-
|
|
284
|
-
|
|
223
|
+
iosReferenceFrame:iosReferenceFrame
|
|
224
|
+
setter:^(double *data, int orientationDegrees) {
|
|
225
|
+
setter(data, orientationDegrees);
|
|
285
226
|
}];
|
|
286
227
|
};
|
|
287
228
|
|
|
@@ -290,15 +231,16 @@ std::shared_ptr<NativeReanimatedModule> createReanimatedModule(
|
|
|
290
231
|
|
|
291
232
|
// keyboard events
|
|
292
233
|
|
|
293
|
-
|
|
234
|
+
REAKeyboardEventObserver *keyboardObserver = [[REAKeyboardEventObserver alloc] init];
|
|
294
235
|
auto subscribeForKeyboardEventsFunction =
|
|
295
|
-
[](std::function<void(int keyboardState, int height)> keyboardEventDataUpdater) {
|
|
236
|
+
[=](std::function<void(int keyboardState, int height)> keyboardEventDataUpdater, bool isStatusBarTranslucent) {
|
|
237
|
+
// ignore isStatusBarTranslucent - it's Android only
|
|
296
238
|
return [keyboardObserver subscribeForKeyboardEvents:^(int keyboardState, int height) {
|
|
297
239
|
keyboardEventDataUpdater(keyboardState, height);
|
|
298
240
|
}];
|
|
299
241
|
};
|
|
300
242
|
|
|
301
|
-
auto unsubscribeFromKeyboardEventsFunction = [](int listenerId) {
|
|
243
|
+
auto unsubscribeFromKeyboardEventsFunction = [=](int listenerId) {
|
|
302
244
|
[keyboardObserver unsubscribeFromKeyboardEvents:listenerId];
|
|
303
245
|
};
|
|
304
246
|
// end keyboard events
|
|
@@ -337,37 +279,15 @@ std::shared_ptr<NativeReanimatedModule> createReanimatedModule(
|
|
|
337
279
|
|
|
338
280
|
scheduler->setRuntimeManager(module);
|
|
339
281
|
|
|
340
|
-
#ifdef RCT_NEW_ARCH_ENABLED
|
|
341
282
|
[reanimatedModule.nodesManager registerEventHandler:^(NSString *eventNameNSString, id<RCTEvent> event) {
|
|
342
283
|
// handles RCTEvents from RNGestureHandler
|
|
343
|
-
|
|
344
284
|
std::string eventName = [eventNameNSString UTF8String];
|
|
285
|
+
id eventData = [event arguments][2];
|
|
345
286
|
jsi::Runtime &rt = *module->runtime;
|
|
346
|
-
jsi::Value payload =
|
|
347
|
-
|
|
348
|
-
module->handleEvent(eventName,
|
|
349
|
-
}];
|
|
350
|
-
#else
|
|
351
|
-
[reanimatedModule.nodesManager registerEventHandler:^(NSString *eventName, id<RCTEvent> event) {
|
|
352
|
-
std::string eventNameString([eventName UTF8String]);
|
|
353
|
-
|
|
354
|
-
std::string eventAsString;
|
|
355
|
-
try {
|
|
356
|
-
eventAsString = folly::toJson(convertIdToFollyDynamic([event arguments][2]));
|
|
357
|
-
} catch (std::exception &) {
|
|
358
|
-
// Events from other libraries may contain NaN or INF values which cannot be represented in JSON.
|
|
359
|
-
// See https://github.com/software-mansion/react-native-reanimated/issues/1776 for details.
|
|
360
|
-
return;
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
eventAsString = "{ NativeMap:" + eventAsString + "}";
|
|
364
|
-
jsi::Object global = module->runtime->global();
|
|
365
|
-
jsi::String eventTimestampName = jsi::String::createFromAscii(*module->runtime, "_eventTimestamp");
|
|
366
|
-
global.setProperty(*module->runtime, eventTimestampName, CACurrentMediaTime() * 1000);
|
|
367
|
-
module->onEvent(eventNameString, eventAsString);
|
|
368
|
-
global.setProperty(*module->runtime, eventTimestampName, jsi::Value::undefined());
|
|
287
|
+
jsi::Value payload = convertObjCObjectToJSIValue(rt, eventData);
|
|
288
|
+
double currentTime = CACurrentMediaTime() * 1000;
|
|
289
|
+
module->handleEvent(eventName, payload, currentTime);
|
|
369
290
|
}];
|
|
370
|
-
#endif
|
|
371
291
|
|
|
372
292
|
std::weak_ptr<NativeReanimatedModule> weakModule = module; // to avoid retain cycle
|
|
373
293
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
@@ -378,26 +298,67 @@ std::shared_ptr<NativeReanimatedModule> createReanimatedModule(
|
|
|
378
298
|
}];
|
|
379
299
|
#else
|
|
380
300
|
// Layout Animation callbacks setup
|
|
381
|
-
[animationsManager
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
301
|
+
[animationsManager
|
|
302
|
+
setAnimationStartingBlock:^(
|
|
303
|
+
NSNumber *_Nonnull tag, LayoutAnimationType type, NSDictionary *_Nonnull values, NSNumber *depth) {
|
|
304
|
+
auto reaModule = weakModule.lock();
|
|
305
|
+
if (reaModule == nullptr) {
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
jsi::Runtime &rt = *wrt.lock();
|
|
310
|
+
jsi::Object yogaValues(rt);
|
|
311
|
+
for (NSString *key in values.allKeys) {
|
|
312
|
+
NSObject *value = values[key];
|
|
313
|
+
if ([values[key] isKindOfClass:[NSArray class]]) {
|
|
314
|
+
NSArray *transformArray = (NSArray *)value;
|
|
315
|
+
jsi::Array matrix(rt, 9);
|
|
316
|
+
for (int i = 0; i < 9; i++) {
|
|
317
|
+
matrix.setValueAtIndex(rt, i, [(NSNumber *)transformArray[i] doubleValue]);
|
|
318
|
+
}
|
|
319
|
+
yogaValues.setProperty(rt, [key UTF8String], matrix);
|
|
320
|
+
} else {
|
|
321
|
+
yogaValues.setProperty(rt, [key UTF8String], [(NSNumber *)value doubleValue]);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
reaModule->layoutAnimationsManager().startLayoutAnimation(rt, [tag intValue], type, yogaValues);
|
|
326
|
+
}];
|
|
327
|
+
|
|
328
|
+
[animationsManager setHasAnimationBlock:^(NSNumber *_Nonnull tag, LayoutAnimationType type) {
|
|
329
|
+
auto reaModule = weakModule.lock();
|
|
330
|
+
if (reaModule == nullptr) {
|
|
331
|
+
return NO;
|
|
388
332
|
}
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
rt, [tag intValue], std::string([type UTF8String]), yogaValues);
|
|
333
|
+
bool hasLayoutAnimation = reaModule->layoutAnimationsManager().hasLayoutAnimation([tag intValue], type);
|
|
334
|
+
return hasLayoutAnimation ? YES : NO;
|
|
392
335
|
}];
|
|
393
336
|
|
|
394
|
-
[animationsManager
|
|
395
|
-
|
|
396
|
-
|
|
337
|
+
[animationsManager setAnimationRemovingBlock:^(NSNumber *_Nonnull tag) {
|
|
338
|
+
auto reaModule = weakModule.lock();
|
|
339
|
+
if (reaModule == nullptr) {
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
reaModule->layoutAnimationsManager().clearLayoutAnimationConfig([tag intValue]);
|
|
397
343
|
}];
|
|
398
344
|
|
|
399
|
-
[animationsManager
|
|
400
|
-
|
|
345
|
+
[animationsManager
|
|
346
|
+
setCancelAnimationBlock:^(NSNumber *_Nonnull tag, LayoutAnimationType type, BOOL cancelled, BOOL removeView) {
|
|
347
|
+
if (auto reaModule = weakModule.lock()) {
|
|
348
|
+
if (auto runtime = wrt.lock()) {
|
|
349
|
+
jsi::Runtime &rt = *runtime;
|
|
350
|
+
reaModule->layoutAnimationsManager().cancelLayoutAnimation(
|
|
351
|
+
rt, [tag intValue], type, cancelled == YES, removeView == YES);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}];
|
|
355
|
+
|
|
356
|
+
[animationsManager setFindPrecedingViewTagForTransitionBlock:^NSNumber *_Nullable(NSNumber *_Nonnull tag) {
|
|
357
|
+
if (auto reaModule = weakModule.lock()) {
|
|
358
|
+
int resultTag = reaModule->layoutAnimationsManager().findPrecedingViewTagForTransition([tag intValue]);
|
|
359
|
+
return resultTag == -1 ? nil : @(resultTag);
|
|
360
|
+
}
|
|
361
|
+
return nil;
|
|
401
362
|
}];
|
|
402
363
|
#endif
|
|
403
364
|
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
#import <RNReanimated/REAInitializer.h>
|
|
2
2
|
#import <RNReanimated/REAUIManager.h>
|
|
3
|
-
|
|
4
|
-
#ifdef REANIMATED_VERSION
|
|
5
|
-
#define STRINGIZE(x) #x
|
|
6
|
-
#define STRINGIZE2(x) STRINGIZE(x)
|
|
7
|
-
#define REANIMATED_VERSION_STRING STRINGIZE2(REANIMATED_VERSION)
|
|
8
|
-
#endif // REANIMATED_VERSION
|
|
3
|
+
#import <RNReanimated/ReanimatedVersion.h>
|
|
9
4
|
|
|
10
5
|
@interface RCTEventDispatcher (Reanimated)
|
|
11
6
|
|
|
@@ -64,7 +59,7 @@ JSIExecutor::RuntimeInstaller REAJSIExecutorRuntimeInstaller(
|
|
|
64
59
|
|
|
65
60
|
runtime.global().setProperty(runtime, "_IS_FABRIC", false);
|
|
66
61
|
|
|
67
|
-
auto version =
|
|
62
|
+
auto version = getReanimatedVersionString(runtime);
|
|
68
63
|
runtime.global().setProperty(runtime, "_REANIMATED_VERSION_CPP", version);
|
|
69
64
|
|
|
70
65
|
runtime.global().setProperty(
|
package/ios/native/REAJSIUtils.h
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
#pragma once
|
|
2
|
-
#ifdef RCT_NEW_ARCH_ENABLED
|
|
3
2
|
|
|
4
3
|
#include <jsi/jsi.h>
|
|
5
4
|
|
|
@@ -63,4 +62,63 @@ static jsi::Value convertObjCObjectToJSIValue(jsi::Runtime &runtime, id value)
|
|
|
63
62
|
return jsi::Value::undefined();
|
|
64
63
|
}
|
|
65
64
|
|
|
66
|
-
|
|
65
|
+
// Other
|
|
66
|
+
|
|
67
|
+
static id convertJSIValueToObjCObject(jsi::Runtime &runtime, const jsi::Value &value);
|
|
68
|
+
|
|
69
|
+
static NSString *convertJSIStringToNSString(jsi::Runtime &runtime, const jsi::String &value)
|
|
70
|
+
{
|
|
71
|
+
return [NSString stringWithUTF8String:value.utf8(runtime).c_str()];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
static NSDictionary *convertJSIObjectToNSDictionary(jsi::Runtime &runtime, const jsi::Object &value)
|
|
75
|
+
{
|
|
76
|
+
jsi::Array propertyNames = value.getPropertyNames(runtime);
|
|
77
|
+
size_t size = propertyNames.size(runtime);
|
|
78
|
+
NSMutableDictionary *result = [NSMutableDictionary new];
|
|
79
|
+
for (size_t i = 0; i < size; i++) {
|
|
80
|
+
jsi::String name = propertyNames.getValueAtIndex(runtime, i).getString(runtime);
|
|
81
|
+
NSString *k = convertJSIStringToNSString(runtime, name);
|
|
82
|
+
id v = convertJSIValueToObjCObject(runtime, value.getProperty(runtime, name));
|
|
83
|
+
if (v) {
|
|
84
|
+
result[k] = v;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return [result copy];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
static NSArray *convertJSIArrayToNSArray(jsi::Runtime &runtime, const jsi::Array &value)
|
|
91
|
+
{
|
|
92
|
+
size_t size = value.size(runtime);
|
|
93
|
+
NSMutableArray *result = [NSMutableArray new];
|
|
94
|
+
for (size_t i = 0; i < size; i++) {
|
|
95
|
+
// Insert kCFNull when it's `undefined` value to preserve the indices.
|
|
96
|
+
[result addObject:convertJSIValueToObjCObject(runtime, value.getValueAtIndex(runtime, i)) ?: (id)kCFNull];
|
|
97
|
+
}
|
|
98
|
+
return [result copy];
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
static id convertJSIValueToObjCObject(jsi::Runtime &runtime, const jsi::Value &value)
|
|
102
|
+
{
|
|
103
|
+
if (value.isUndefined() || value.isNull()) {
|
|
104
|
+
return nil;
|
|
105
|
+
}
|
|
106
|
+
if (value.isBool()) {
|
|
107
|
+
return @(value.getBool());
|
|
108
|
+
}
|
|
109
|
+
if (value.isNumber()) {
|
|
110
|
+
return @(value.getNumber());
|
|
111
|
+
}
|
|
112
|
+
if (value.isString()) {
|
|
113
|
+
return convertJSIStringToNSString(runtime, value.getString(runtime));
|
|
114
|
+
}
|
|
115
|
+
if (value.isObject()) {
|
|
116
|
+
jsi::Object o = value.getObject(runtime);
|
|
117
|
+
if (o.isArray(runtime)) {
|
|
118
|
+
return convertJSIArrayToNSArray(runtime, o.getArray(runtime));
|
|
119
|
+
}
|
|
120
|
+
return convertJSIObjectToNSDictionary(runtime, o);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
throw std::runtime_error("Unsupported jsi::Value kind");
|
|
124
|
+
}
|
|
@@ -7,13 +7,17 @@
|
|
|
7
7
|
ReanimatedSensorType _sensorType;
|
|
8
8
|
double _interval;
|
|
9
9
|
double _lastTimestamp;
|
|
10
|
+
int _referenceFrame;
|
|
10
11
|
#if !TARGET_OS_TV
|
|
11
12
|
CMMotionManager *_motionManager;
|
|
12
13
|
#endif
|
|
13
|
-
void (^_setter)(double[]);
|
|
14
|
+
void (^_setter)(double[], int);
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
- (instancetype)init:(ReanimatedSensorType)sensorType
|
|
17
|
+
- (instancetype)init:(ReanimatedSensorType)sensorType
|
|
18
|
+
interval:(int)interval
|
|
19
|
+
iosReferenceFrame:(int)iosReferenceFrame
|
|
20
|
+
setter:(void (^)(double[], int))setter;
|
|
17
21
|
- (bool)initialize;
|
|
18
22
|
- (bool)initializeGyroscope;
|
|
19
23
|
- (bool)initializeAccelerometer;
|
|
@@ -3,7 +3,10 @@
|
|
|
3
3
|
#if __has_include(<CoreMotion/CoreMotion.h>)
|
|
4
4
|
@implementation ReanimatedSensor
|
|
5
5
|
|
|
6
|
-
- (instancetype)init:(ReanimatedSensorType)sensorType
|
|
6
|
+
- (instancetype)init:(ReanimatedSensorType)sensorType
|
|
7
|
+
interval:(int)interval
|
|
8
|
+
iosReferenceFrame:(int)iosReferenceFrame
|
|
9
|
+
setter:(void (^)(double[], int))setter
|
|
7
10
|
{
|
|
8
11
|
self = [super init];
|
|
9
12
|
_sensorType = sensorType;
|
|
@@ -12,6 +15,7 @@
|
|
|
12
15
|
} else {
|
|
13
16
|
_interval = interval / 1000.0; // in seconds
|
|
14
17
|
}
|
|
18
|
+
_referenceFrame = iosReferenceFrame;
|
|
15
19
|
_setter = setter;
|
|
16
20
|
_motionManager = [[CMMotionManager alloc] init];
|
|
17
21
|
return self;
|
|
@@ -49,7 +53,7 @@
|
|
|
49
53
|
return;
|
|
50
54
|
}
|
|
51
55
|
double data[] = {sensorData.rotationRate.x, sensorData.rotationRate.y, sensorData.rotationRate.z};
|
|
52
|
-
self->_setter(data);
|
|
56
|
+
self->_setter(data, [self getInterfaceOrientation]);
|
|
53
57
|
self->_lastTimestamp = currentTime;
|
|
54
58
|
}];
|
|
55
59
|
|
|
@@ -75,7 +79,7 @@
|
|
|
75
79
|
sensorData.acceleration.x * G,
|
|
76
80
|
sensorData.acceleration.y * G,
|
|
77
81
|
sensorData.acceleration.z * G};
|
|
78
|
-
self->_setter(data);
|
|
82
|
+
self->_setter(data, [self getInterfaceOrientation]);
|
|
79
83
|
self->_lastTimestamp = currentTime;
|
|
80
84
|
}];
|
|
81
85
|
|
|
@@ -100,7 +104,7 @@
|
|
|
100
104
|
// convert G to m/s^2
|
|
101
105
|
double data[] = {
|
|
102
106
|
sensorData.gravity.x * G, sensorData.gravity.y * G, sensorData.gravity.z * G};
|
|
103
|
-
self->_setter(data);
|
|
107
|
+
self->_setter(data, [self getInterfaceOrientation]);
|
|
104
108
|
self->_lastTimestamp = currentTime;
|
|
105
109
|
}];
|
|
106
110
|
|
|
@@ -123,7 +127,7 @@
|
|
|
123
127
|
}
|
|
124
128
|
double data[] = {
|
|
125
129
|
sensorData.magneticField.x, sensorData.magneticField.y, sensorData.magneticField.z};
|
|
126
|
-
self->_setter(data);
|
|
130
|
+
self->_setter(data, [self getInterfaceOrientation]);
|
|
127
131
|
self->_lastTimestamp = currentTime;
|
|
128
132
|
}];
|
|
129
133
|
|
|
@@ -138,7 +142,19 @@
|
|
|
138
142
|
[_motionManager setDeviceMotionUpdateInterval:_interval];
|
|
139
143
|
|
|
140
144
|
[_motionManager setShowsDeviceMovementDisplay:YES];
|
|
141
|
-
|
|
145
|
+
|
|
146
|
+
// _referenceFrame = Auto, on devices without magnetometer fall back to `XArbitraryZVertical`,
|
|
147
|
+
// `XArbitraryCorrectedZVertical` otherwise
|
|
148
|
+
if (_referenceFrame == 4) {
|
|
149
|
+
if (![_motionManager isMagnetometerAvailable]) {
|
|
150
|
+
_referenceFrame = 0;
|
|
151
|
+
} else {
|
|
152
|
+
_referenceFrame = 1;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// the binary shift works here because of the definition of CMAttitudeReferenceFrame
|
|
157
|
+
[_motionManager startDeviceMotionUpdatesUsingReferenceFrame:(1 << _referenceFrame)
|
|
142
158
|
toQueue:[NSOperationQueue mainQueue]
|
|
143
159
|
withHandler:^(CMDeviceMotion *sensorData, NSError *error) {
|
|
144
160
|
double currentTime = [[NSProcessInfo processInfo] systemUptime];
|
|
@@ -154,7 +170,7 @@
|
|
|
154
170
|
attitude.yaw,
|
|
155
171
|
attitude.pitch,
|
|
156
172
|
attitude.roll};
|
|
157
|
-
self->_setter(data);
|
|
173
|
+
self->_setter(data, [self getInterfaceOrientation]);
|
|
158
174
|
self->_lastTimestamp = currentTime;
|
|
159
175
|
}];
|
|
160
176
|
|
|
@@ -176,6 +192,26 @@
|
|
|
176
192
|
}
|
|
177
193
|
}
|
|
178
194
|
|
|
195
|
+
- (int)getInterfaceOrientation
|
|
196
|
+
{
|
|
197
|
+
UIInterfaceOrientation orientation = UIInterfaceOrientationPortrait;
|
|
198
|
+
if (@available(iOS 13.0, *)) {
|
|
199
|
+
orientation = UIApplication.sharedApplication.windows.firstObject.windowScene.interfaceOrientation;
|
|
200
|
+
} else {
|
|
201
|
+
orientation = UIApplication.sharedApplication.statusBarOrientation;
|
|
202
|
+
}
|
|
203
|
+
switch (orientation) {
|
|
204
|
+
case UIInterfaceOrientationLandscapeLeft:
|
|
205
|
+
return 270;
|
|
206
|
+
case UIInterfaceOrientationLandscapeRight:
|
|
207
|
+
return 90;
|
|
208
|
+
case UIInterfaceOrientationPortraitUpsideDown:
|
|
209
|
+
return 180;
|
|
210
|
+
default:
|
|
211
|
+
return 0;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
179
215
|
@end
|
|
180
216
|
|
|
181
217
|
#else
|
|
@@ -6,7 +6,10 @@
|
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
- (instancetype)init;
|
|
9
|
-
- (int)registerSensor:(ReanimatedSensorType)sensorType
|
|
9
|
+
- (int)registerSensor:(ReanimatedSensorType)sensorType
|
|
10
|
+
interval:(int)interval
|
|
11
|
+
iosReferenceFrame:(int)iosReferenceFrame
|
|
12
|
+
setter:(void (^)(double[], int))setter;
|
|
10
13
|
- (void)unregisterSensor:(int)sensorId;
|
|
11
14
|
|
|
12
15
|
@end
|
|
@@ -14,9 +14,15 @@ static NSNumber *_nextSensorId = nil;
|
|
|
14
14
|
return self;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
- (int)registerSensor:(ReanimatedSensorType)sensorType
|
|
17
|
+
- (int)registerSensor:(ReanimatedSensorType)sensorType
|
|
18
|
+
interval:(int)interval
|
|
19
|
+
iosReferenceFrame:(int)iosReferenceFrame
|
|
20
|
+
setter:(void (^)(double[], int))setter
|
|
18
21
|
{
|
|
19
|
-
ReanimatedSensor *sensor = [[ReanimatedSensor alloc] init:sensorType
|
|
22
|
+
ReanimatedSensor *sensor = [[ReanimatedSensor alloc] init:sensorType
|
|
23
|
+
interval:interval
|
|
24
|
+
iosReferenceFrame:iosReferenceFrame
|
|
25
|
+
setter:setter];
|
|
20
26
|
if ([sensor initialize]) {
|
|
21
27
|
NSNumber *sensorId = [_nextSensorId copy];
|
|
22
28
|
_nextSensorId = [NSNumber numberWithInt:[_nextSensorId intValue] + 1];
|