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,7 +1,15 @@
|
|
|
1
1
|
import { NativeModules } from 'react-native';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import {
|
|
3
|
+
ShareableRef,
|
|
4
|
+
ShareableSyncDataHolderRef,
|
|
5
|
+
Value3D,
|
|
6
|
+
ValueRotation,
|
|
7
|
+
} from '../commonTypes';
|
|
8
|
+
import {
|
|
9
|
+
LayoutAnimationFunction,
|
|
10
|
+
LayoutAnimationType,
|
|
11
|
+
} from '../layoutReanimation';
|
|
12
|
+
import { checkVersion } from '../platform-specific/checkVersion';
|
|
5
13
|
|
|
6
14
|
export class NativeReanimated {
|
|
7
15
|
native: boolean;
|
|
@@ -15,44 +23,40 @@ export class NativeReanimated {
|
|
|
15
23
|
this.InnerNativeModule = global.__reanimatedModuleProxy;
|
|
16
24
|
this.native = native;
|
|
17
25
|
if (native) {
|
|
18
|
-
this.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
jsVersion.match(/^\d+\.\d+\.\d+$/) &&
|
|
27
|
-
cppVersion.match(/^\d+\.\d+\.\d+$/)
|
|
28
|
-
) {
|
|
29
|
-
// x.y.z, compare only major and minor, skip patch
|
|
30
|
-
const [jsMajor, jsMinor] = jsVersion.split('.');
|
|
31
|
-
const [cppMajor, cppMinor] = cppVersion.split('.');
|
|
32
|
-
return jsMajor === cppMajor && jsMinor === cppMinor;
|
|
33
|
-
} else {
|
|
34
|
-
// alpha, beta or rc, compare everything
|
|
35
|
-
return jsVersion === cppVersion;
|
|
26
|
+
if (this.InnerNativeModule === undefined) {
|
|
27
|
+
console.error(
|
|
28
|
+
`[Reanimated] The native part of Reanimated doesn't seem to be initialized. This could be caused by\n\
|
|
29
|
+
- not rebuilding the app after installing or upgrading Reanimated\n\
|
|
30
|
+
- trying to run Reanimated on an unsupported platform\n\
|
|
31
|
+
- running in a brownfield app without manually initializing the native library`
|
|
32
|
+
);
|
|
33
|
+
return;
|
|
36
34
|
}
|
|
37
|
-
|
|
38
|
-
if (!ok) {
|
|
39
|
-
console.error(
|
|
40
|
-
`[Reanimated] Mismatch between JavaScript part and native part of Reanimated (${jsVersion} vs. ${cppVersion}). Did you forget to re-build the app after upgrading react-native-reanimated? If you use Expo Go, you must downgrade to ${cppVersion} which is bundled into Expo SDK.`
|
|
41
|
-
);
|
|
42
|
-
// TODO: detect Expo managed workflow
|
|
35
|
+
checkVersion();
|
|
43
36
|
}
|
|
44
37
|
}
|
|
45
38
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
39
|
+
installCoreFunctions(
|
|
40
|
+
callGuard: <T extends Array<any>, U>(
|
|
41
|
+
fn: (...args: T) => U,
|
|
42
|
+
...args: T
|
|
43
|
+
) => void,
|
|
44
|
+
valueUnpacker: <T>(value: T) => T
|
|
45
|
+
): void {
|
|
46
|
+
return this.InnerNativeModule.installCoreFunctions(
|
|
47
|
+
callGuard,
|
|
48
|
+
valueUnpacker
|
|
49
|
+
);
|
|
52
50
|
}
|
|
53
51
|
|
|
54
|
-
makeShareableClone<T>(
|
|
55
|
-
|
|
52
|
+
makeShareableClone<T>(
|
|
53
|
+
value: T,
|
|
54
|
+
shouldPersistRemote: boolean
|
|
55
|
+
): ShareableRef<T> {
|
|
56
|
+
return this.InnerNativeModule.makeShareableClone(
|
|
57
|
+
value,
|
|
58
|
+
shouldPersistRemote
|
|
59
|
+
);
|
|
56
60
|
}
|
|
57
61
|
|
|
58
62
|
makeSynchronizedDataHolder<T>(
|
|
@@ -79,9 +83,15 @@ export class NativeReanimated {
|
|
|
79
83
|
registerSensor<T>(
|
|
80
84
|
sensorType: number,
|
|
81
85
|
interval: number,
|
|
82
|
-
|
|
86
|
+
iosReferenceFrame: number,
|
|
87
|
+
handler: ShareableRef<T> | ((data: Value3D | ValueRotation) => void)
|
|
83
88
|
) {
|
|
84
|
-
return this.InnerNativeModule.registerSensor(
|
|
89
|
+
return this.InnerNativeModule.registerSensor(
|
|
90
|
+
sensorType,
|
|
91
|
+
interval,
|
|
92
|
+
iosReferenceFrame,
|
|
93
|
+
handler
|
|
94
|
+
);
|
|
85
95
|
}
|
|
86
96
|
|
|
87
97
|
unregisterSensor(sensorId: number) {
|
|
@@ -109,10 +119,16 @@ export class NativeReanimated {
|
|
|
109
119
|
|
|
110
120
|
configureLayoutAnimation(
|
|
111
121
|
viewTag: number,
|
|
112
|
-
type:
|
|
122
|
+
type: LayoutAnimationType,
|
|
123
|
+
sharedTransitionTag: string,
|
|
113
124
|
config: ShareableRef<Keyframe | LayoutAnimationFunction>
|
|
114
125
|
) {
|
|
115
|
-
this.InnerNativeModule.configureLayoutAnimation(
|
|
126
|
+
this.InnerNativeModule.configureLayoutAnimation(
|
|
127
|
+
viewTag,
|
|
128
|
+
type,
|
|
129
|
+
sharedTransitionTag,
|
|
130
|
+
config
|
|
131
|
+
);
|
|
116
132
|
}
|
|
117
133
|
|
|
118
134
|
enableLayoutAnimations(flag: boolean): void {
|
|
@@ -123,8 +139,14 @@ export class NativeReanimated {
|
|
|
123
139
|
this.InnerNativeModule.configureProps(uiProps, nativeProps);
|
|
124
140
|
}
|
|
125
141
|
|
|
126
|
-
subscribeForKeyboardEvents(
|
|
127
|
-
|
|
142
|
+
subscribeForKeyboardEvents(
|
|
143
|
+
handler: ShareableRef<number>,
|
|
144
|
+
isStatusBarTranslucent: boolean
|
|
145
|
+
): number {
|
|
146
|
+
return this.InnerNativeModule.subscribeForKeyboardEvents(
|
|
147
|
+
handler,
|
|
148
|
+
isStatusBarTranslucent
|
|
149
|
+
);
|
|
128
150
|
}
|
|
129
151
|
|
|
130
152
|
unsubscribeFromKeyboardEvents(listenerId: number): void {
|
|
@@ -46,7 +46,7 @@ export function setPath<T>(
|
|
|
46
46
|
for (let i = 0; i < keys.length - 1; i++) {
|
|
47
47
|
// creates entry if there isn't one
|
|
48
48
|
currObj = currObj as { [key: string]: NestedObjectValues<T> };
|
|
49
|
-
if (!
|
|
49
|
+
if (!(keys[i] in currObj)) {
|
|
50
50
|
// if next key is a number create an array
|
|
51
51
|
if (typeof keys[i + 1] === 'number') {
|
|
52
52
|
currObj[keys[i]] = [];
|
|
@@ -178,6 +178,13 @@ export function withStyleAnimation(
|
|
|
178
178
|
if (prevAnimation && !prevVal) {
|
|
179
179
|
prevVal = prevAnimation.current;
|
|
180
180
|
}
|
|
181
|
+
if (prevVal === undefined) {
|
|
182
|
+
console.warn(
|
|
183
|
+
`Initial values for animation are missing for property ${currentEntry.path.join(
|
|
184
|
+
'.'
|
|
185
|
+
)}`
|
|
186
|
+
);
|
|
187
|
+
}
|
|
181
188
|
setPath(animation.current, currentEntry.path, prevVal);
|
|
182
189
|
let currentAnimation: AnimationObject;
|
|
183
190
|
if (
|
|
@@ -7,7 +7,14 @@ import {
|
|
|
7
7
|
StyleLayoutAnimation,
|
|
8
8
|
} from './commonTypes';
|
|
9
9
|
/* global _WORKLET */
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
ParsedColorArray,
|
|
12
|
+
isColor,
|
|
13
|
+
convertToRGBA,
|
|
14
|
+
rgbaArrayToRGBAColor,
|
|
15
|
+
toGammaSpace,
|
|
16
|
+
toLinearSpace,
|
|
17
|
+
} from '../Colors';
|
|
11
18
|
|
|
12
19
|
import {
|
|
13
20
|
AnimatedStyle,
|
|
@@ -126,55 +133,59 @@ function decorateAnimation<T extends AnimationObject | StyleLayoutAnimation>(
|
|
|
126
133
|
return res;
|
|
127
134
|
};
|
|
128
135
|
|
|
129
|
-
const tab = ['
|
|
136
|
+
const tab = ['R', 'G', 'B', 'A'];
|
|
130
137
|
const colorOnStart = (
|
|
131
138
|
animation: Animation<AnimationObject>,
|
|
132
139
|
value: string | number,
|
|
133
140
|
timestamp: Timestamp,
|
|
134
141
|
previousAnimation: Animation<AnimationObject>
|
|
135
142
|
): void => {
|
|
136
|
-
let
|
|
137
|
-
let
|
|
138
|
-
let
|
|
143
|
+
let RGBAValue: ParsedColorArray;
|
|
144
|
+
let RGBACurrent: ParsedColorArray;
|
|
145
|
+
let RGBAToValue: ParsedColorArray;
|
|
139
146
|
const res: Array<number> = [];
|
|
140
147
|
if (isColor(value)) {
|
|
141
|
-
|
|
142
|
-
|
|
148
|
+
RGBACurrent = toLinearSpace(convertToRGBA(animation.current));
|
|
149
|
+
RGBAValue = toLinearSpace(convertToRGBA(value));
|
|
143
150
|
if (animation.toValue) {
|
|
144
|
-
|
|
151
|
+
RGBAToValue = toLinearSpace(convertToRGBA(animation.toValue));
|
|
145
152
|
}
|
|
146
153
|
}
|
|
147
154
|
tab.forEach((i, index) => {
|
|
148
155
|
animation[i] = Object.assign({}, animationCopy);
|
|
149
|
-
animation[i].current =
|
|
150
|
-
animation[i].toValue =
|
|
156
|
+
animation[i].current = RGBACurrent[index];
|
|
157
|
+
animation[i].toValue = RGBAToValue ? RGBAToValue[index] : undefined;
|
|
151
158
|
animation[i].onStart(
|
|
152
159
|
animation[i],
|
|
153
|
-
|
|
160
|
+
RGBAValue[index],
|
|
154
161
|
timestamp,
|
|
155
162
|
previousAnimation ? previousAnimation[i] : undefined
|
|
156
163
|
);
|
|
157
164
|
res.push(animation[i].current);
|
|
158
165
|
});
|
|
159
166
|
|
|
160
|
-
animation.current =
|
|
167
|
+
animation.current = rgbaArrayToRGBAColor(
|
|
168
|
+
toGammaSpace(res as ParsedColorArray)
|
|
169
|
+
);
|
|
161
170
|
};
|
|
162
171
|
|
|
163
172
|
const colorOnFrame = (
|
|
164
173
|
animation: Animation<AnimationObject>,
|
|
165
174
|
timestamp: Timestamp
|
|
166
175
|
): boolean => {
|
|
167
|
-
const
|
|
176
|
+
const RGBACurrent = toLinearSpace(convertToRGBA(animation.current));
|
|
168
177
|
const res: Array<number> = [];
|
|
169
178
|
let finished = true;
|
|
170
179
|
tab.forEach((i, index) => {
|
|
171
|
-
animation[i].current =
|
|
180
|
+
animation[i].current = RGBACurrent[index];
|
|
172
181
|
// @ts-ignore: disable-next-line
|
|
173
182
|
finished &= animation[i].onFrame(animation[i], timestamp);
|
|
174
183
|
res.push(animation[i].current);
|
|
175
184
|
});
|
|
176
185
|
|
|
177
|
-
animation.current =
|
|
186
|
+
animation.current = rgbaArrayToRGBAColor(
|
|
187
|
+
toGammaSpace(res as ParsedColorArray)
|
|
188
|
+
);
|
|
178
189
|
return finished;
|
|
179
190
|
};
|
|
180
191
|
|
|
@@ -247,6 +258,8 @@ type AnimationToDecoration<T extends AnimationObject | StyleLayoutAnimation> =
|
|
|
247
258
|
? NextAnimation<SequenceAnimation>
|
|
248
259
|
: AnimatableValue | T;
|
|
249
260
|
|
|
261
|
+
const IS_NATIVE = NativeReanimatedModule.native;
|
|
262
|
+
|
|
250
263
|
export function defineAnimation<
|
|
251
264
|
T extends AnimationObject | StyleLayoutAnimation
|
|
252
265
|
>(starting: AnimationToDecoration<T>, factory: () => T): T {
|
|
@@ -261,7 +274,7 @@ export function defineAnimation<
|
|
|
261
274
|
return animation;
|
|
262
275
|
};
|
|
263
276
|
|
|
264
|
-
if (_WORKLET || !
|
|
277
|
+
if (_WORKLET || !IS_NATIVE) {
|
|
265
278
|
return create();
|
|
266
279
|
}
|
|
267
280
|
// @ts-ignore: eslint-disable-line
|
|
@@ -79,7 +79,6 @@ export type Context = Record<string, unknown>;
|
|
|
79
79
|
export interface WorkletFunction {
|
|
80
80
|
_closure?: Context;
|
|
81
81
|
__workletHash?: number;
|
|
82
|
-
__optimalization?: number;
|
|
83
82
|
}
|
|
84
83
|
|
|
85
84
|
export interface BasicWorkletFunction<T> extends WorkletFunction {
|
|
@@ -145,6 +144,21 @@ export interface Animation<T extends AnimationObject> extends AnimationObject {
|
|
|
145
144
|
) => void;
|
|
146
145
|
}
|
|
147
146
|
|
|
147
|
+
export enum SensorType {
|
|
148
|
+
ACCELEROMETER = 1,
|
|
149
|
+
GYROSCOPE = 2,
|
|
150
|
+
GRAVITY = 3,
|
|
151
|
+
MAGNETIC_FIELD = 4,
|
|
152
|
+
ROTATION = 5,
|
|
153
|
+
}
|
|
154
|
+
export enum IOSReferenceFrame {
|
|
155
|
+
XArbitraryZVertical,
|
|
156
|
+
XArbitraryCorrectedZVertical,
|
|
157
|
+
XMagneticNorthZVertical,
|
|
158
|
+
XTrueNorthZVertical,
|
|
159
|
+
Auto,
|
|
160
|
+
}
|
|
161
|
+
|
|
148
162
|
export interface NumericAnimation {
|
|
149
163
|
current?: number;
|
|
150
164
|
}
|
|
@@ -160,6 +174,7 @@ export type Value3D = {
|
|
|
160
174
|
x: number;
|
|
161
175
|
y: number;
|
|
162
176
|
z: number;
|
|
177
|
+
interfaceOrientation: InterfaceOrientation;
|
|
163
178
|
};
|
|
164
179
|
|
|
165
180
|
export type ValueRotation = {
|
|
@@ -170,8 +185,16 @@ export type ValueRotation = {
|
|
|
170
185
|
yaw: number;
|
|
171
186
|
pitch: number;
|
|
172
187
|
roll: number;
|
|
188
|
+
interfaceOrientation: InterfaceOrientation;
|
|
173
189
|
};
|
|
174
190
|
|
|
191
|
+
export enum InterfaceOrientation {
|
|
192
|
+
ROTATION_0 = 0,
|
|
193
|
+
ROTATION_90 = 90,
|
|
194
|
+
ROTATION_180 = 180,
|
|
195
|
+
ROTATION_270 = 270,
|
|
196
|
+
}
|
|
197
|
+
|
|
175
198
|
export type ShadowNodeWrapper = object;
|
|
176
199
|
|
|
177
200
|
export enum KeyboardState {
|
|
@@ -195,3 +218,7 @@ export interface MeasuredDimensions {
|
|
|
195
218
|
pageX: number;
|
|
196
219
|
pageY: number;
|
|
197
220
|
}
|
|
221
|
+
|
|
222
|
+
export interface AnimatedKeyboardOptions {
|
|
223
|
+
isStatusBarTranslucentAndroid?: boolean;
|
|
224
|
+
}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import React, { ForwardedRef, forwardRef } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
FlatList,
|
|
4
|
+
FlatListProps,
|
|
5
|
+
LayoutChangeEvent,
|
|
6
|
+
StyleSheet,
|
|
7
|
+
} from 'react-native';
|
|
3
8
|
import ReanimatedView from './View';
|
|
4
9
|
import createAnimatedComponent from '../../createAnimatedComponent';
|
|
5
10
|
import { ILayoutAnimationBuilder } from '../layoutReanimation/animationBuilder/commonTypes';
|
|
11
|
+
import { StyleProps } from '../commonTypes';
|
|
6
12
|
|
|
7
13
|
const AnimatedFlatList = createAnimatedComponent(FlatList as any) as any;
|
|
8
14
|
|
|
@@ -10,12 +16,20 @@ interface AnimatedFlatListProps {
|
|
|
10
16
|
onLayout: (event: LayoutChangeEvent) => void;
|
|
11
17
|
// implicit `children` prop has been removed in @types/react^18.0.0
|
|
12
18
|
children: React.ReactNode;
|
|
19
|
+
inverted?: boolean;
|
|
20
|
+
horizontal?: boolean;
|
|
13
21
|
}
|
|
14
22
|
|
|
15
|
-
const createCellRenderer = (
|
|
23
|
+
const createCellRenderer = (
|
|
24
|
+
itemLayoutAnimation?: ILayoutAnimationBuilder,
|
|
25
|
+
cellStyle?: StyleProps
|
|
26
|
+
) => {
|
|
16
27
|
const cellRenderer = (props: AnimatedFlatListProps) => {
|
|
17
28
|
return (
|
|
18
|
-
<ReanimatedView
|
|
29
|
+
<ReanimatedView
|
|
30
|
+
layout={itemLayoutAnimation}
|
|
31
|
+
onLayout={props.onLayout}
|
|
32
|
+
style={cellStyle}>
|
|
19
33
|
{props.children}
|
|
20
34
|
</ReanimatedView>
|
|
21
35
|
);
|
|
@@ -34,9 +48,15 @@ const ReanimatedFlatlist: ReanimatedFlatListFC = forwardRef(
|
|
|
34
48
|
(props: ReanimatedFlatListProps<any>, ref: ForwardedRef<FlatList>) => {
|
|
35
49
|
const { itemLayoutAnimation, ...restProps } = props;
|
|
36
50
|
|
|
51
|
+
const cellStyle = restProps?.inverted
|
|
52
|
+
? restProps?.horizontal
|
|
53
|
+
? styles.horizontallyInverted
|
|
54
|
+
: styles.verticallyInverted
|
|
55
|
+
: undefined;
|
|
56
|
+
|
|
37
57
|
const cellRenderer = React.useMemo(
|
|
38
|
-
() => createCellRenderer(itemLayoutAnimation),
|
|
39
|
-
[]
|
|
58
|
+
() => createCellRenderer(itemLayoutAnimation, cellStyle),
|
|
59
|
+
[cellStyle]
|
|
40
60
|
);
|
|
41
61
|
|
|
42
62
|
return (
|
|
@@ -49,4 +69,9 @@ const ReanimatedFlatlist: ReanimatedFlatListFC = forwardRef(
|
|
|
49
69
|
}
|
|
50
70
|
);
|
|
51
71
|
|
|
72
|
+
const styles = StyleSheet.create({
|
|
73
|
+
verticallyInverted: { transform: [{ scaleY: -1 }] },
|
|
74
|
+
horizontallyInverted: { transform: [{ scaleX: -1 }] },
|
|
75
|
+
});
|
|
76
|
+
|
|
52
77
|
export default ReanimatedFlatlist;
|
package/src/reanimated2/core.ts
CHANGED
|
@@ -1,29 +1,28 @@
|
|
|
1
|
-
/* global _setGlobalConsole */
|
|
2
1
|
import NativeReanimatedModule from './NativeReanimated';
|
|
3
2
|
import { nativeShouldBeMock, shouldBeUseWeb, isWeb } from './PlatformChecker';
|
|
4
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
AnimatedKeyboardOptions,
|
|
5
|
+
BasicWorkletFunction,
|
|
6
|
+
Value3D,
|
|
7
|
+
ValueRotation,
|
|
8
|
+
} from './commonTypes';
|
|
5
9
|
import {
|
|
6
10
|
makeShareableCloneRecursive,
|
|
7
11
|
makeShareable as makeShareableUnwrapped,
|
|
8
12
|
} from './shareables';
|
|
9
|
-
import { runOnUI, runOnJS } from './threads';
|
|
10
13
|
import { startMapper as startMapperUnwrapped } from './mappers';
|
|
11
14
|
import {
|
|
12
15
|
makeMutable as makeMutableUnwrapped,
|
|
13
16
|
makeRemote as makeRemoteUnwrapped,
|
|
14
17
|
} from './mutables';
|
|
15
|
-
import {
|
|
18
|
+
import {
|
|
19
|
+
LayoutAnimationFunction,
|
|
20
|
+
LayoutAnimationType,
|
|
21
|
+
} from './layoutReanimation';
|
|
22
|
+
import { initializeUIRuntime } from './initializers';
|
|
16
23
|
|
|
17
24
|
export { stopMapper } from './mappers';
|
|
18
25
|
export { runOnJS, runOnUI } from './threads';
|
|
19
|
-
export { getTimestamp } from './time';
|
|
20
|
-
|
|
21
|
-
if (global._setGlobalConsole === undefined) {
|
|
22
|
-
// it can happen when Reanimated plugin wasn't added, but the user uses the only API from version 1
|
|
23
|
-
global._setGlobalConsole = () => {
|
|
24
|
-
// noop
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
26
|
|
|
28
27
|
export type ReanimatedConsole = Pick<
|
|
29
28
|
Console,
|
|
@@ -114,56 +113,20 @@ export function getViewProp<T>(viewTag: string, propName: string): Promise<T> {
|
|
|
114
113
|
});
|
|
115
114
|
}
|
|
116
115
|
|
|
117
|
-
function valueUnpacker(objectToUnpack: any, category?: string): any {
|
|
118
|
-
'worklet';
|
|
119
|
-
let workletsCache = global.__workletsCache;
|
|
120
|
-
let handleCache = global.__handleCache;
|
|
121
|
-
if (workletsCache === undefined) {
|
|
122
|
-
// init
|
|
123
|
-
workletsCache = global.__workletsCache = new Map();
|
|
124
|
-
handleCache = global.__handleCache = new WeakMap();
|
|
125
|
-
}
|
|
126
|
-
if (objectToUnpack.__workletHash) {
|
|
127
|
-
let workletFun = workletsCache.get(objectToUnpack.__workletHash);
|
|
128
|
-
if (workletFun === undefined) {
|
|
129
|
-
// eslint-disable-next-line no-eval
|
|
130
|
-
workletFun = eval('(' + objectToUnpack.asString + '\n)') as (
|
|
131
|
-
...args: any[]
|
|
132
|
-
) => any;
|
|
133
|
-
workletsCache.set(objectToUnpack.__workletHash, workletFun);
|
|
134
|
-
}
|
|
135
|
-
const functionInstance = workletFun.bind(objectToUnpack);
|
|
136
|
-
objectToUnpack._recur = functionInstance;
|
|
137
|
-
return functionInstance;
|
|
138
|
-
} else if (objectToUnpack.__init) {
|
|
139
|
-
let value = handleCache!.get(objectToUnpack);
|
|
140
|
-
if (value === undefined) {
|
|
141
|
-
value = objectToUnpack.__init();
|
|
142
|
-
handleCache!.set(objectToUnpack, value);
|
|
143
|
-
}
|
|
144
|
-
return value;
|
|
145
|
-
} else if (category === 'RemoteFunction') {
|
|
146
|
-
const fun = () => {
|
|
147
|
-
throw new Error(`Tried to synchronously call a non-worklet function on the UI thread.
|
|
148
|
-
|
|
149
|
-
Possible solutions are:
|
|
150
|
-
a) If you want to synchronously execute this method, mark it as a worklet
|
|
151
|
-
b) If you want to execute this function on the JS thread, wrap it using \`runOnJS\``);
|
|
152
|
-
};
|
|
153
|
-
fun.__remoteFunction = objectToUnpack;
|
|
154
|
-
return fun;
|
|
155
|
-
} else {
|
|
156
|
-
throw new Error('data type not recognized by unpack method');
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
116
|
export function registerEventHandler<T>(
|
|
161
117
|
eventHash: string,
|
|
162
118
|
eventHandler: (event: T) => void
|
|
163
119
|
): string {
|
|
120
|
+
function handleAndFlushImmediates(eventTimestamp: number, event: T) {
|
|
121
|
+
'worklet';
|
|
122
|
+
global.__frameTimestamp = eventTimestamp;
|
|
123
|
+
eventHandler(event);
|
|
124
|
+
global.__flushAnimationFrame(eventTimestamp);
|
|
125
|
+
global.__frameTimestamp = undefined;
|
|
126
|
+
}
|
|
164
127
|
return NativeReanimatedModule.registerEventHandler(
|
|
165
128
|
eventHash,
|
|
166
|
-
makeShareableCloneRecursive(
|
|
129
|
+
makeShareableCloneRecursive(handleAndFlushImmediates)
|
|
167
130
|
);
|
|
168
131
|
}
|
|
169
132
|
|
|
@@ -172,10 +135,22 @@ export function unregisterEventHandler(id: string): void {
|
|
|
172
135
|
}
|
|
173
136
|
|
|
174
137
|
export function subscribeForKeyboardEvents(
|
|
175
|
-
eventHandler: (state: number, height: number) => void
|
|
138
|
+
eventHandler: (state: number, height: number) => void,
|
|
139
|
+
options: AnimatedKeyboardOptions
|
|
176
140
|
): number {
|
|
141
|
+
// TODO: this should really go with the same code path as other events, that is
|
|
142
|
+
// via registerEventHandler. For now we are copying the code from there.
|
|
143
|
+
function handleAndFlushImmediates(state: number, height: number) {
|
|
144
|
+
'worklet';
|
|
145
|
+
const now = performance.now();
|
|
146
|
+
global.__frameTimestamp = now;
|
|
147
|
+
eventHandler(state, height);
|
|
148
|
+
global.__flushAnimationFrame(now);
|
|
149
|
+
global.__frameTimestamp = undefined;
|
|
150
|
+
}
|
|
177
151
|
return NativeReanimatedModule.subscribeForKeyboardEvents(
|
|
178
|
-
makeShareableCloneRecursive(
|
|
152
|
+
makeShareableCloneRecursive(handleAndFlushImmediates),
|
|
153
|
+
options.isStatusBarTranslucentAndroid ?? false
|
|
179
154
|
);
|
|
180
155
|
}
|
|
181
156
|
|
|
@@ -186,11 +161,16 @@ export function unsubscribeFromKeyboardEvents(listenerId: number): void {
|
|
|
186
161
|
export function registerSensor(
|
|
187
162
|
sensorType: number,
|
|
188
163
|
interval: number,
|
|
189
|
-
|
|
164
|
+
iosReferenceFrame: number,
|
|
165
|
+
eventHandler: (
|
|
166
|
+
data: Value3D | ValueRotation,
|
|
167
|
+
orientationDegrees: number
|
|
168
|
+
) => void
|
|
190
169
|
): number {
|
|
191
170
|
return NativeReanimatedModule.registerSensor(
|
|
192
171
|
sensorType,
|
|
193
172
|
interval,
|
|
173
|
+
iosReferenceFrame,
|
|
194
174
|
makeShareableCloneRecursive(eventHandler)
|
|
195
175
|
);
|
|
196
176
|
}
|
|
@@ -199,21 +179,9 @@ export function unregisterSensor(listenerId: number): void {
|
|
|
199
179
|
return NativeReanimatedModule.unregisterSensor(listenerId);
|
|
200
180
|
}
|
|
201
181
|
|
|
202
|
-
|
|
203
|
-
|
|
182
|
+
// initialize UI runtime if applicable
|
|
204
183
|
if (!isWeb() && isConfigured()) {
|
|
205
|
-
|
|
206
|
-
runOnUI(() => {
|
|
207
|
-
'worklet';
|
|
208
|
-
const console = {
|
|
209
|
-
debug: runOnJS(capturableConsole.debug),
|
|
210
|
-
log: runOnJS(capturableConsole.log),
|
|
211
|
-
warn: runOnJS(capturableConsole.warn),
|
|
212
|
-
error: runOnJS(capturableConsole.error),
|
|
213
|
-
info: runOnJS(capturableConsole.info),
|
|
214
|
-
};
|
|
215
|
-
_setGlobalConsole(console);
|
|
216
|
-
})();
|
|
184
|
+
initializeUIRuntime();
|
|
217
185
|
}
|
|
218
186
|
|
|
219
187
|
type FeaturesConfig = {
|
|
@@ -247,12 +215,14 @@ export function enableLayoutAnimations(
|
|
|
247
215
|
|
|
248
216
|
export function configureLayoutAnimations(
|
|
249
217
|
viewTag: number,
|
|
250
|
-
type:
|
|
251
|
-
config: LayoutAnimationFunction | Keyframe
|
|
218
|
+
type: LayoutAnimationType,
|
|
219
|
+
config: LayoutAnimationFunction | Keyframe,
|
|
220
|
+
sharedTransitionTag = ''
|
|
252
221
|
): void {
|
|
253
222
|
NativeReanimatedModule.configureLayoutAnimation(
|
|
254
223
|
viewTag,
|
|
255
224
|
type,
|
|
225
|
+
sharedTransitionTag,
|
|
256
226
|
makeShareableCloneRecursive(config)
|
|
257
227
|
);
|
|
258
228
|
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
type StackDetails = [Error, number, number];
|
|
2
|
+
|
|
3
|
+
const _workletStackDetails = new Map<number, StackDetails>();
|
|
4
|
+
|
|
5
|
+
export function registerWorkletStackDetails(
|
|
6
|
+
hash: number,
|
|
7
|
+
stackDetails: StackDetails
|
|
8
|
+
) {
|
|
9
|
+
_workletStackDetails.set(hash, stackDetails);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function getBundleOffset(error: Error): [string, number, number] {
|
|
13
|
+
const frame = error.stack?.split('\n')?.[0];
|
|
14
|
+
if (frame) {
|
|
15
|
+
const parsedFrame = /@([^@]+):(\d+):(\d+)/.exec(frame);
|
|
16
|
+
if (parsedFrame) {
|
|
17
|
+
const [, file, line, col] = parsedFrame;
|
|
18
|
+
return [file, Number(line), Number(col)];
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return ['unknown', 0, 0];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function processStack(stack: string): string {
|
|
25
|
+
const workletStackEntries = stack.match(/worklet_(\d+):(\d+):(\d+)/g);
|
|
26
|
+
let result = stack;
|
|
27
|
+
workletStackEntries?.forEach((match) => {
|
|
28
|
+
const [, hash, origLine, origCol] = match.split(/:|_/).map(Number);
|
|
29
|
+
const errorDetails = _workletStackDetails.get(hash);
|
|
30
|
+
if (!errorDetails) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const [error, lineOffset, colOffset] = errorDetails;
|
|
34
|
+
const [bundleFile, bundleLine, bundleCol] = getBundleOffset(error);
|
|
35
|
+
const line = origLine + bundleLine + lineOffset;
|
|
36
|
+
const col = origCol + bundleCol + colOffset;
|
|
37
|
+
|
|
38
|
+
result = result.replace(match, `${bundleFile}:${line}:${col}`);
|
|
39
|
+
});
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function reportFatalErrorOnJS({
|
|
44
|
+
message,
|
|
45
|
+
stack,
|
|
46
|
+
}: {
|
|
47
|
+
message: string;
|
|
48
|
+
stack?: string;
|
|
49
|
+
}) {
|
|
50
|
+
const error = new Error();
|
|
51
|
+
error.message = message;
|
|
52
|
+
error.stack = stack ? processStack(stack) : undefined;
|
|
53
|
+
error.name = 'ReanimatedError';
|
|
54
|
+
// @ts-ignore React Native's ErrorUtils implementation extends the Error type with jsEngine field
|
|
55
|
+
error.jsEngine = 'reanimated';
|
|
56
|
+
global.ErrorUtils.reportFatalError(error);
|
|
57
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { runOnUIImmediately } from '../threads';
|
|
2
2
|
|
|
3
3
|
type CallbackDetails = {
|
|
4
4
|
callback: (frameInfo: FrameInfo) => void;
|
|
@@ -24,7 +24,7 @@ export interface FrameCallbackRegistryUI {
|
|
|
24
24
|
manageStateFrameCallback: (callbackId: number, state: boolean) => void;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
export const prepareUIRegistry =
|
|
27
|
+
export const prepareUIRegistry = runOnUIImmediately(() => {
|
|
28
28
|
'worklet';
|
|
29
29
|
|
|
30
30
|
const frameCallbackRegistry: FrameCallbackRegistryUI = {
|