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
|
@@ -5,6 +5,35 @@
|
|
|
5
5
|
// check other methods that may use them. However, this field is not actually defined
|
|
6
6
|
// nor should be used for anything else as assigning any data to those objects will
|
|
7
7
|
// throw an error.
|
|
8
|
+
export let SensorType;
|
|
9
|
+
|
|
10
|
+
(function (SensorType) {
|
|
11
|
+
SensorType[SensorType["ACCELEROMETER"] = 1] = "ACCELEROMETER";
|
|
12
|
+
SensorType[SensorType["GYROSCOPE"] = 2] = "GYROSCOPE";
|
|
13
|
+
SensorType[SensorType["GRAVITY"] = 3] = "GRAVITY";
|
|
14
|
+
SensorType[SensorType["MAGNETIC_FIELD"] = 4] = "MAGNETIC_FIELD";
|
|
15
|
+
SensorType[SensorType["ROTATION"] = 5] = "ROTATION";
|
|
16
|
+
})(SensorType || (SensorType = {}));
|
|
17
|
+
|
|
18
|
+
export let IOSReferenceFrame;
|
|
19
|
+
|
|
20
|
+
(function (IOSReferenceFrame) {
|
|
21
|
+
IOSReferenceFrame[IOSReferenceFrame["XArbitraryZVertical"] = 0] = "XArbitraryZVertical";
|
|
22
|
+
IOSReferenceFrame[IOSReferenceFrame["XArbitraryCorrectedZVertical"] = 1] = "XArbitraryCorrectedZVertical";
|
|
23
|
+
IOSReferenceFrame[IOSReferenceFrame["XMagneticNorthZVertical"] = 2] = "XMagneticNorthZVertical";
|
|
24
|
+
IOSReferenceFrame[IOSReferenceFrame["XTrueNorthZVertical"] = 3] = "XTrueNorthZVertical";
|
|
25
|
+
IOSReferenceFrame[IOSReferenceFrame["Auto"] = 4] = "Auto";
|
|
26
|
+
})(IOSReferenceFrame || (IOSReferenceFrame = {}));
|
|
27
|
+
|
|
28
|
+
export let InterfaceOrientation;
|
|
29
|
+
|
|
30
|
+
(function (InterfaceOrientation) {
|
|
31
|
+
InterfaceOrientation[InterfaceOrientation["ROTATION_0"] = 0] = "ROTATION_0";
|
|
32
|
+
InterfaceOrientation[InterfaceOrientation["ROTATION_90"] = 90] = "ROTATION_90";
|
|
33
|
+
InterfaceOrientation[InterfaceOrientation["ROTATION_180"] = 180] = "ROTATION_180";
|
|
34
|
+
InterfaceOrientation[InterfaceOrientation["ROTATION_270"] = 270] = "ROTATION_270";
|
|
35
|
+
})(InterfaceOrientation || (InterfaceOrientation = {}));
|
|
36
|
+
|
|
8
37
|
export let KeyboardState;
|
|
9
38
|
|
|
10
39
|
(function (KeyboardState) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["KeyboardState"],"sources":["commonTypes.ts"],"sourcesContent":["import {\n PerpectiveTransform,\n RotateTransform,\n RotateXTransform,\n RotateYTransform,\n RotateZTransform,\n ScaleTransform,\n ScaleXTransform,\n ScaleYTransform,\n TranslateXTransform,\n TranslateYTransform,\n SkewXTransform,\n SkewYTransform,\n MatrixTransform,\n ViewStyle,\n TextStyle,\n} from 'react-native';\n\nexport type TransformProperty =\n | PerpectiveTransform\n | RotateTransform\n | RotateXTransform\n | RotateYTransform\n | RotateZTransform\n | ScaleTransform\n | ScaleXTransform\n | ScaleYTransform\n | TranslateXTransform\n | TranslateYTransform\n | SkewXTransform\n | SkewYTransform\n | MatrixTransform;\n\nexport interface StyleProps extends ViewStyle, TextStyle {\n originX?: number;\n originY?: number;\n [key: string]: any;\n}\n\nexport interface AnimatedStyle\n extends Record<string, Animation<AnimationObject>> {\n [key: string]: any;\n transform?: Array<Record<string, Animation<AnimationObject>>>;\n}\nexport interface SharedValue<T> {\n value: T;\n addListener: (listenerID: number, listener: (value: T) => void) => void;\n removeListener: (listenerID: number) => void;\n modify: (modifier: (value: T) => T) => void;\n}\n\n// The below type is used for HostObjects retured by the JSI API that don't have\n// any accessable fields or methods but can carry data that is accessed from the\n// c++ side. We add a field to the type to make it possible for typescript to recognize\n// which JSI methods accept those types as arguments and to be able to correctly type\n// check other methods that may use them. However, this field is not actually defined\n// nor should be used for anything else as assigning any data to those objects will\n// throw an error.\nexport type ShareableRef<T> = {\n __hostObjectShareableJSRef: T;\n};\n\nexport type ShareableSyncDataHolderRef<T> = {\n __hostObjectShareableJSRefSyncDataHolder: T;\n};\n\nexport type MapperRegistry = {\n start: (\n mapperID: number,\n worklet: () => void,\n inputs: SharedValue<any>[],\n outputs?: SharedValue<any>[]\n ) => void;\n stop: (mapperID: number) => void;\n};\n\nexport type Context = Record<string, unknown>;\n\nexport interface WorkletFunction {\n _closure?: Context;\n __workletHash?: number;\n
|
|
1
|
+
{"version":3,"names":["SensorType","IOSReferenceFrame","InterfaceOrientation","KeyboardState"],"sources":["commonTypes.ts"],"sourcesContent":["import {\n PerpectiveTransform,\n RotateTransform,\n RotateXTransform,\n RotateYTransform,\n RotateZTransform,\n ScaleTransform,\n ScaleXTransform,\n ScaleYTransform,\n TranslateXTransform,\n TranslateYTransform,\n SkewXTransform,\n SkewYTransform,\n MatrixTransform,\n ViewStyle,\n TextStyle,\n} from 'react-native';\n\nexport type TransformProperty =\n | PerpectiveTransform\n | RotateTransform\n | RotateXTransform\n | RotateYTransform\n | RotateZTransform\n | ScaleTransform\n | ScaleXTransform\n | ScaleYTransform\n | TranslateXTransform\n | TranslateYTransform\n | SkewXTransform\n | SkewYTransform\n | MatrixTransform;\n\nexport interface StyleProps extends ViewStyle, TextStyle {\n originX?: number;\n originY?: number;\n [key: string]: any;\n}\n\nexport interface AnimatedStyle\n extends Record<string, Animation<AnimationObject>> {\n [key: string]: any;\n transform?: Array<Record<string, Animation<AnimationObject>>>;\n}\nexport interface SharedValue<T> {\n value: T;\n addListener: (listenerID: number, listener: (value: T) => void) => void;\n removeListener: (listenerID: number) => void;\n modify: (modifier: (value: T) => T) => void;\n}\n\n// The below type is used for HostObjects retured by the JSI API that don't have\n// any accessable fields or methods but can carry data that is accessed from the\n// c++ side. We add a field to the type to make it possible for typescript to recognize\n// which JSI methods accept those types as arguments and to be able to correctly type\n// check other methods that may use them. However, this field is not actually defined\n// nor should be used for anything else as assigning any data to those objects will\n// throw an error.\nexport type ShareableRef<T> = {\n __hostObjectShareableJSRef: T;\n};\n\nexport type ShareableSyncDataHolderRef<T> = {\n __hostObjectShareableJSRefSyncDataHolder: T;\n};\n\nexport type MapperRegistry = {\n start: (\n mapperID: number,\n worklet: () => void,\n inputs: SharedValue<any>[],\n outputs?: SharedValue<any>[]\n ) => void;\n stop: (mapperID: number) => void;\n};\n\nexport type Context = Record<string, unknown>;\n\nexport interface WorkletFunction {\n _closure?: Context;\n __workletHash?: number;\n}\n\nexport interface BasicWorkletFunction<T> extends WorkletFunction {\n (): T;\n}\n\nexport interface BasicWorkletFunctionOptional<T> extends WorkletFunction {\n (): Partial<T>;\n}\n\nexport interface NativeEvent<T> {\n nativeEvent: T;\n}\nexport interface ComplexWorkletFunction<A extends any[], R>\n extends WorkletFunction {\n (...args: A): R;\n __remoteFunction?: (...args: A) => R;\n}\n\nexport interface NestedObject<T> {\n [key: string]: NestedObjectValues<T>;\n}\n\nexport type NestedObjectValues<T> =\n | T\n | Array<NestedObjectValues<T>>\n | NestedObject<T>;\n\nexport interface AdapterWorkletFunction extends WorkletFunction {\n (value: NestedObject<string | number | AnimationObject>): void;\n}\n\nexport type AnimatableValue = number | string | Array<number>;\n\nexport interface AnimationObject {\n [key: string]: any;\n callback: AnimationCallback;\n current?: AnimatableValue;\n toValue?: AnimationObject['current'];\n startValue?: AnimationObject['current'];\n finished?: boolean;\n strippedCurrent?: number;\n cancelled?: boolean;\n\n __prefix?: string;\n __suffix?: string;\n onFrame: (animation: any, timestamp: Timestamp) => boolean;\n onStart: (\n nextAnimation: any,\n current: any,\n timestamp: Timestamp,\n previousAnimation: any\n ) => void;\n}\n\nexport interface Animation<T extends AnimationObject> extends AnimationObject {\n onFrame: (animation: T, timestamp: Timestamp) => boolean;\n onStart: (\n nextAnimation: T,\n current: T extends NumericAnimation ? number : AnimatableValue,\n timestamp: Timestamp,\n previousAnimation: T\n ) => void;\n}\n\nexport enum SensorType {\n ACCELEROMETER = 1,\n GYROSCOPE = 2,\n GRAVITY = 3,\n MAGNETIC_FIELD = 4,\n ROTATION = 5,\n}\nexport enum IOSReferenceFrame {\n XArbitraryZVertical,\n XArbitraryCorrectedZVertical,\n XMagneticNorthZVertical,\n XTrueNorthZVertical,\n Auto,\n}\n\nexport interface NumericAnimation {\n current?: number;\n}\n\nexport type AnimationCallback = (\n finished?: boolean,\n current?: AnimatableValue\n) => void;\n\nexport type Timestamp = number;\n\nexport type Value3D = {\n x: number;\n y: number;\n z: number;\n interfaceOrientation: InterfaceOrientation;\n};\n\nexport type ValueRotation = {\n qw: number;\n qx: number;\n qy: number;\n qz: number;\n yaw: number;\n pitch: number;\n roll: number;\n interfaceOrientation: InterfaceOrientation;\n};\n\nexport enum InterfaceOrientation {\n ROTATION_0 = 0,\n ROTATION_90 = 90,\n ROTATION_180 = 180,\n ROTATION_270 = 270,\n}\n\nexport type ShadowNodeWrapper = object;\n\nexport enum KeyboardState {\n UNKNOWN = 0,\n OPENING = 1,\n OPEN = 2,\n CLOSING = 3,\n CLOSED = 4,\n}\n\nexport type AnimatedKeyboardInfo = {\n height: SharedValue<number>;\n state: SharedValue<KeyboardState>;\n};\n\nexport interface MeasuredDimensions {\n x: number;\n y: number;\n width: number;\n height: number;\n pageX: number;\n pageY: number;\n}\n\nexport interface AnimatedKeyboardOptions {\n isStatusBarTranslucentAndroid?: boolean;\n}\n"],"mappings":"AAmDA;AACA;AACA;AACA;AACA;AACA;AACA;AAyFA,WAAYA,UAAZ;;WAAYA,U;EAAAA,U,CAAAA,U;EAAAA,U,CAAAA,U;EAAAA,U,CAAAA,U;EAAAA,U,CAAAA,U;EAAAA,U,CAAAA,U;GAAAA,U,KAAAA,U;;AAOZ,WAAYC,iBAAZ;;WAAYA,iB;EAAAA,iB,CAAAA,iB;EAAAA,iB,CAAAA,iB;EAAAA,iB,CAAAA,iB;EAAAA,iB,CAAAA,iB;EAAAA,iB,CAAAA,iB;GAAAA,iB,KAAAA,iB;;AAqCZ,WAAYC,oBAAZ;;WAAYA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;GAAAA,oB,KAAAA,oB;;AASZ,WAAYC,aAAZ;;WAAYA,a;EAAAA,a,CAAAA,a;EAAAA,a,CAAAA,a;EAAAA,a,CAAAA,a;EAAAA,a,CAAAA,a;EAAAA,a,CAAAA,a;GAAAA,a,KAAAA,a"}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
2
|
|
|
3
3
|
import React, { forwardRef } from 'react';
|
|
4
|
-
import { FlatList } from 'react-native';
|
|
4
|
+
import { FlatList, StyleSheet } from 'react-native';
|
|
5
5
|
import ReanimatedView from './View';
|
|
6
6
|
import createAnimatedComponent from '../../createAnimatedComponent';
|
|
7
7
|
const AnimatedFlatList = createAnimatedComponent(FlatList);
|
|
8
8
|
|
|
9
|
-
const createCellRenderer = itemLayoutAnimation => {
|
|
9
|
+
const createCellRenderer = (itemLayoutAnimation, cellStyle) => {
|
|
10
10
|
const cellRenderer = props => {
|
|
11
11
|
return /*#__PURE__*/React.createElement(ReanimatedView, {
|
|
12
12
|
layout: itemLayoutAnimation,
|
|
13
|
-
onLayout: props.onLayout
|
|
13
|
+
onLayout: props.onLayout,
|
|
14
|
+
style: cellStyle
|
|
14
15
|
}, props.children);
|
|
15
16
|
};
|
|
16
17
|
|
|
@@ -22,12 +23,25 @@ const ReanimatedFlatlist = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
22
23
|
itemLayoutAnimation,
|
|
23
24
|
...restProps
|
|
24
25
|
} = props;
|
|
25
|
-
const
|
|
26
|
+
const cellStyle = restProps !== null && restProps !== void 0 && restProps.inverted ? restProps !== null && restProps !== void 0 && restProps.horizontal ? styles.horizontallyInverted : styles.verticallyInverted : undefined;
|
|
27
|
+
const cellRenderer = React.useMemo(() => createCellRenderer(itemLayoutAnimation, cellStyle), [cellStyle]);
|
|
26
28
|
return /*#__PURE__*/React.createElement(AnimatedFlatList, _extends({
|
|
27
29
|
ref: ref
|
|
28
30
|
}, restProps, {
|
|
29
31
|
CellRendererComponent: cellRenderer
|
|
30
32
|
}));
|
|
31
33
|
});
|
|
34
|
+
const styles = StyleSheet.create({
|
|
35
|
+
verticallyInverted: {
|
|
36
|
+
transform: [{
|
|
37
|
+
scaleY: -1
|
|
38
|
+
}]
|
|
39
|
+
},
|
|
40
|
+
horizontallyInverted: {
|
|
41
|
+
transform: [{
|
|
42
|
+
scaleX: -1
|
|
43
|
+
}]
|
|
44
|
+
}
|
|
45
|
+
});
|
|
32
46
|
export default ReanimatedFlatlist;
|
|
33
47
|
//# sourceMappingURL=FlatList.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","forwardRef","FlatList","ReanimatedView","createAnimatedComponent","AnimatedFlatList","createCellRenderer","itemLayoutAnimation","cellRenderer","props","onLayout","children","ReanimatedFlatlist","ref","restProps","useMemo"],"sources":["FlatList.tsx"],"sourcesContent":["import React, { ForwardedRef, forwardRef } from 'react';\nimport {
|
|
1
|
+
{"version":3,"names":["React","forwardRef","FlatList","StyleSheet","ReanimatedView","createAnimatedComponent","AnimatedFlatList","createCellRenderer","itemLayoutAnimation","cellStyle","cellRenderer","props","onLayout","children","ReanimatedFlatlist","ref","restProps","inverted","horizontal","styles","horizontallyInverted","verticallyInverted","undefined","useMemo","create","transform","scaleY","scaleX"],"sources":["FlatList.tsx"],"sourcesContent":["import React, { ForwardedRef, forwardRef } from 'react';\nimport {\n FlatList,\n FlatListProps,\n LayoutChangeEvent,\n StyleSheet,\n} from 'react-native';\nimport ReanimatedView from './View';\nimport createAnimatedComponent from '../../createAnimatedComponent';\nimport { ILayoutAnimationBuilder } from '../layoutReanimation/animationBuilder/commonTypes';\nimport { StyleProps } from '../commonTypes';\n\nconst AnimatedFlatList = createAnimatedComponent(FlatList as any) as any;\n\ninterface AnimatedFlatListProps {\n onLayout: (event: LayoutChangeEvent) => void;\n // implicit `children` prop has been removed in @types/react^18.0.0\n children: React.ReactNode;\n inverted?: boolean;\n horizontal?: boolean;\n}\n\nconst createCellRenderer = (\n itemLayoutAnimation?: ILayoutAnimationBuilder,\n cellStyle?: StyleProps\n) => {\n const cellRenderer = (props: AnimatedFlatListProps) => {\n return (\n <ReanimatedView\n layout={itemLayoutAnimation}\n onLayout={props.onLayout}\n style={cellStyle}>\n {props.children}\n </ReanimatedView>\n );\n };\n\n return cellRenderer;\n};\n\nexport interface ReanimatedFlatListProps<ItemT> extends FlatListProps<ItemT> {\n itemLayoutAnimation?: ILayoutAnimationBuilder;\n}\n\ntype ReanimatedFlatListFC<T = any> = React.FC<ReanimatedFlatListProps<T>>;\n\nconst ReanimatedFlatlist: ReanimatedFlatListFC = forwardRef(\n (props: ReanimatedFlatListProps<any>, ref: ForwardedRef<FlatList>) => {\n const { itemLayoutAnimation, ...restProps } = props;\n\n const cellStyle = restProps?.inverted\n ? restProps?.horizontal\n ? styles.horizontallyInverted\n : styles.verticallyInverted\n : undefined;\n\n const cellRenderer = React.useMemo(\n () => createCellRenderer(itemLayoutAnimation, cellStyle),\n [cellStyle]\n );\n\n return (\n <AnimatedFlatList\n ref={ref}\n {...restProps}\n CellRendererComponent={cellRenderer}\n />\n );\n }\n);\n\nconst styles = StyleSheet.create({\n verticallyInverted: { transform: [{ scaleY: -1 }] },\n horizontallyInverted: { transform: [{ scaleX: -1 }] },\n});\n\nexport default ReanimatedFlatlist;\n"],"mappings":";;AAAA,OAAOA,K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AX,CAAD;EAAb,CADW;EAE/BN,oBAAoB,EAAE;IAAEK,SAAS,EAAE,CAAC;MAAEE,MAAM,EAAE,CAAC;IAAX,CAAD;EAAb;AAFS,CAAlB,CAAf;AAKA,eAAeb,kBAAf"}
|
|
@@ -1,19 +1,11 @@
|
|
|
1
|
-
/* global _setGlobalConsole */
|
|
2
1
|
import NativeReanimatedModule from './NativeReanimated';
|
|
3
2
|
import { nativeShouldBeMock, shouldBeUseWeb, isWeb } from './PlatformChecker';
|
|
4
3
|
import { makeShareableCloneRecursive, makeShareable as makeShareableUnwrapped } from './shareables';
|
|
5
|
-
import { runOnUI, runOnJS } from './threads';
|
|
6
4
|
import { startMapper as startMapperUnwrapped } from './mappers';
|
|
7
5
|
import { makeMutable as makeMutableUnwrapped, makeRemote as makeRemoteUnwrapped } from './mutables';
|
|
6
|
+
import { initializeUIRuntime } from './initializers';
|
|
8
7
|
export { stopMapper } from './mappers';
|
|
9
8
|
export { runOnJS, runOnUI } from './threads';
|
|
10
|
-
export { getTimestamp } from './time';
|
|
11
|
-
|
|
12
|
-
if (global._setGlobalConsole === undefined) {
|
|
13
|
-
// it can happen when Reanimated plugin wasn't added, but the user uses the only API from version 1
|
|
14
|
-
global._setGlobalConsole = () => {// noop
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
9
|
|
|
18
10
|
const testWorklet = () => {
|
|
19
11
|
'worklet';
|
|
@@ -74,91 +66,52 @@ export function getViewProp(viewTag, propName) {
|
|
|
74
66
|
});
|
|
75
67
|
});
|
|
76
68
|
}
|
|
69
|
+
export function registerEventHandler(eventHash, eventHandler) {
|
|
70
|
+
function handleAndFlushImmediates(eventTimestamp, event) {
|
|
71
|
+
'worklet';
|
|
77
72
|
|
|
78
|
-
|
|
79
|
-
|
|
73
|
+
global.__frameTimestamp = eventTimestamp;
|
|
74
|
+
eventHandler(event);
|
|
80
75
|
|
|
81
|
-
|
|
82
|
-
let handleCache = global.__handleCache;
|
|
76
|
+
global.__flushAnimationFrame(eventTimestamp);
|
|
83
77
|
|
|
84
|
-
|
|
85
|
-
// init
|
|
86
|
-
workletsCache = global.__workletsCache = new Map();
|
|
87
|
-
handleCache = global.__handleCache = new WeakMap();
|
|
78
|
+
global.__frameTimestamp = undefined;
|
|
88
79
|
}
|
|
89
80
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
objectToUnpack._recur = functionInstance;
|
|
101
|
-
return functionInstance;
|
|
102
|
-
} else if (objectToUnpack.__init) {
|
|
103
|
-
let value = handleCache.get(objectToUnpack);
|
|
104
|
-
|
|
105
|
-
if (value === undefined) {
|
|
106
|
-
value = objectToUnpack.__init();
|
|
107
|
-
handleCache.set(objectToUnpack, value);
|
|
108
|
-
}
|
|
81
|
+
return NativeReanimatedModule.registerEventHandler(eventHash, makeShareableCloneRecursive(handleAndFlushImmediates));
|
|
82
|
+
}
|
|
83
|
+
export function unregisterEventHandler(id) {
|
|
84
|
+
return NativeReanimatedModule.unregisterEventHandler(id);
|
|
85
|
+
}
|
|
86
|
+
export function subscribeForKeyboardEvents(eventHandler, options) {
|
|
87
|
+
// TODO: this should really go with the same code path as other events, that is
|
|
88
|
+
// via registerEventHandler. For now we are copying the code from there.
|
|
89
|
+
function handleAndFlushImmediates(state, height) {
|
|
90
|
+
'worklet';
|
|
109
91
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
throw new Error(`Tried to synchronously call a non-worklet function on the UI thread.
|
|
92
|
+
const now = performance.now();
|
|
93
|
+
global.__frameTimestamp = now;
|
|
94
|
+
eventHandler(state, height);
|
|
114
95
|
|
|
115
|
-
|
|
116
|
-
a) If you want to synchronously execute this method, mark it as a worklet
|
|
117
|
-
b) If you want to execute this function on the JS thread, wrap it using \`runOnJS\``);
|
|
118
|
-
};
|
|
96
|
+
global.__flushAnimationFrame(now);
|
|
119
97
|
|
|
120
|
-
|
|
121
|
-
return fun;
|
|
122
|
-
} else {
|
|
123
|
-
throw new Error('data type not recognized by unpack method');
|
|
98
|
+
global.__frameTimestamp = undefined;
|
|
124
99
|
}
|
|
125
|
-
}
|
|
126
100
|
|
|
127
|
-
|
|
128
|
-
return NativeReanimatedModule.registerEventHandler(eventHash, makeShareableCloneRecursive(eventHandler));
|
|
129
|
-
}
|
|
130
|
-
export function unregisterEventHandler(id) {
|
|
131
|
-
return NativeReanimatedModule.unregisterEventHandler(id);
|
|
132
|
-
}
|
|
133
|
-
export function subscribeForKeyboardEvents(eventHandler) {
|
|
134
|
-
return NativeReanimatedModule.subscribeForKeyboardEvents(makeShareableCloneRecursive(eventHandler));
|
|
101
|
+
return NativeReanimatedModule.subscribeForKeyboardEvents(makeShareableCloneRecursive(handleAndFlushImmediates), options.isStatusBarTranslucentAndroid ?? false);
|
|
135
102
|
}
|
|
136
103
|
export function unsubscribeFromKeyboardEvents(listenerId) {
|
|
137
104
|
return NativeReanimatedModule.unsubscribeFromKeyboardEvents(listenerId);
|
|
138
105
|
}
|
|
139
|
-
export function registerSensor(sensorType, interval, eventHandler) {
|
|
140
|
-
return NativeReanimatedModule.registerSensor(sensorType, interval, makeShareableCloneRecursive(eventHandler));
|
|
106
|
+
export function registerSensor(sensorType, interval, iosReferenceFrame, eventHandler) {
|
|
107
|
+
return NativeReanimatedModule.registerSensor(sensorType, interval, iosReferenceFrame, makeShareableCloneRecursive(eventHandler));
|
|
141
108
|
}
|
|
142
109
|
export function unregisterSensor(listenerId) {
|
|
143
110
|
return NativeReanimatedModule.unregisterSensor(listenerId);
|
|
144
|
-
}
|
|
145
|
-
NativeReanimatedModule.installCoreFunctions(valueUnpacker);
|
|
111
|
+
} // initialize UI runtime if applicable
|
|
146
112
|
|
|
147
113
|
if (!isWeb() && isConfigured()) {
|
|
148
|
-
|
|
149
|
-
runOnUI(() => {
|
|
150
|
-
'worklet';
|
|
151
|
-
|
|
152
|
-
const console = {
|
|
153
|
-
debug: runOnJS(capturableConsole.debug),
|
|
154
|
-
log: runOnJS(capturableConsole.log),
|
|
155
|
-
warn: runOnJS(capturableConsole.warn),
|
|
156
|
-
error: runOnJS(capturableConsole.error),
|
|
157
|
-
info: runOnJS(capturableConsole.info)
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
_setGlobalConsole(console);
|
|
161
|
-
})();
|
|
114
|
+
initializeUIRuntime();
|
|
162
115
|
}
|
|
163
116
|
|
|
164
117
|
let featuresConfig = {
|
|
@@ -180,7 +133,8 @@ export function enableLayoutAnimations(flag) {
|
|
|
180
133
|
}
|
|
181
134
|
}
|
|
182
135
|
export function configureLayoutAnimations(viewTag, type, config) {
|
|
183
|
-
|
|
136
|
+
let sharedTransitionTag = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
|
|
137
|
+
NativeReanimatedModule.configureLayoutAnimation(viewTag, type, sharedTransitionTag, makeShareableCloneRecursive(config));
|
|
184
138
|
}
|
|
185
139
|
export function configureProps(uiProps, nativeProps) {
|
|
186
140
|
if (!nativeShouldBeMock()) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeReanimatedModule","nativeShouldBeMock","shouldBeUseWeb","isWeb","makeShareableCloneRecursive","makeShareable","makeShareableUnwrapped","runOnUI","runOnJS","startMapper","startMapperUnwrapped","makeMutable","makeMutableUnwrapped","makeRemote","makeRemoteUnwrapped","stopMapper","getTimestamp","global","_setGlobalConsole","undefined","testWorklet","throwUninitializedReanimatedException","Error","checkPluginState","throwError","__workletHash","isConfigured","isConfiguredCheck","configurationCheckWrapper","__DEV__","fn","_WORKLET","_log","s","console","log","getViewProp","viewTag","propName","_IS_FABRIC","Promise","resolve","reject","result","substr","valueUnpacker","objectToUnpack","category","workletsCache","__workletsCache","handleCache","__handleCache","Map","WeakMap","workletFun","get","eval","asString","set","functionInstance","bind","_recur","__init","value","fun","__remoteFunction","registerEventHandler","eventHash","eventHandler","unregisterEventHandler","id","subscribeForKeyboardEvents","unsubscribeFromKeyboardEvents","listenerId","registerSensor","sensorType","interval","unregisterSensor","installCoreFunctions","capturableConsole","debug","warn","error","info","featuresConfig","enableLayoutAnimations","setByUser","flag","isCallByUser","configureLayoutAnimations","type","config","configureLayoutAnimation","configureProps","uiProps","nativeProps"],"sources":["core.ts"],"sourcesContent":["/* global _setGlobalConsole */\nimport NativeReanimatedModule from './NativeReanimated';\nimport { nativeShouldBeMock, shouldBeUseWeb, isWeb } from './PlatformChecker';\nimport { BasicWorkletFunction, Value3D, ValueRotation } from './commonTypes';\nimport {\n makeShareableCloneRecursive,\n makeShareable as makeShareableUnwrapped,\n} from './shareables';\nimport { runOnUI, runOnJS } from './threads';\nimport { startMapper as startMapperUnwrapped } from './mappers';\nimport {\n makeMutable as makeMutableUnwrapped,\n makeRemote as makeRemoteUnwrapped,\n} from './mutables';\nimport { LayoutAnimationFunction } from './layoutReanimation';\n\nexport { stopMapper } from './mappers';\nexport { runOnJS, runOnUI } from './threads';\nexport { getTimestamp } from './time';\n\nif (global._setGlobalConsole === undefined) {\n // it can happen when Reanimated plugin wasn't added, but the user uses the only API from version 1\n global._setGlobalConsole = () => {\n // noop\n };\n}\n\nexport type ReanimatedConsole = Pick<\n Console,\n 'debug' | 'log' | 'warn' | 'info' | 'error'\n>;\n\nconst testWorklet: BasicWorkletFunction<void> = () => {\n 'worklet';\n};\n\nconst throwUninitializedReanimatedException = () => {\n throw new Error(\n \"Failed to initialize react-native-reanimated library, make sure you followed installation steps here: https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation/ \\n1) Make sure reanimated's babel plugin is installed in your babel.config.js (you should have 'react-native-reanimated/plugin' listed there - also see the above link for details) \\n2) Make sure you reset build cache after updating the config, run: yarn start --reset-cache\"\n );\n};\n\nexport const checkPluginState: (throwError: boolean) => boolean = (\n throwError = true\n) => {\n if (!testWorklet.__workletHash && !shouldBeUseWeb()) {\n if (throwError) {\n throwUninitializedReanimatedException();\n }\n return false;\n }\n return true;\n};\n\nexport const isConfigured: (throwError?: boolean) => boolean = (\n throwError = false\n) => {\n return checkPluginState(throwError);\n};\n\nexport const isConfiguredCheck: () => void = () => {\n checkPluginState(true);\n};\n\nconst configurationCheckWrapper = __DEV__\n ? <T extends Array<any>, U>(fn: (...args: T) => U) => {\n return (...args: T): U => {\n isConfigured(true);\n return fn(...args);\n };\n }\n : <T extends Array<any>, U>(fn: (...args: T) => U) => fn;\n\nexport const startMapper = __DEV__\n ? configurationCheckWrapper(startMapperUnwrapped)\n : startMapperUnwrapped;\n\nexport const makeShareable = __DEV__\n ? configurationCheckWrapper(makeShareableUnwrapped)\n : makeShareableUnwrapped;\n\nexport const makeMutable = __DEV__\n ? configurationCheckWrapper(makeMutableUnwrapped)\n : makeMutableUnwrapped;\n\nexport const makeRemote = __DEV__\n ? configurationCheckWrapper(makeRemoteUnwrapped)\n : makeRemoteUnwrapped;\n\nglobal._WORKLET = false;\nglobal._log = function (s: string) {\n console.log(s);\n};\n\nexport function getViewProp<T>(viewTag: string, propName: string): Promise<T> {\n if (global._IS_FABRIC) {\n throw new Error(\n '[react-native-reanimated] `getViewProp` is not supported on Fabric yet'\n );\n }\n\n return new Promise((resolve, reject) => {\n return NativeReanimatedModule.getViewProp(\n viewTag,\n propName,\n (result: T) => {\n if (typeof result === 'string' && result.substr(0, 6) === 'error:') {\n reject(result);\n } else {\n resolve(result);\n }\n }\n );\n });\n}\n\nfunction valueUnpacker(objectToUnpack: any, category?: string): any {\n 'worklet';\n let workletsCache = global.__workletsCache;\n let handleCache = global.__handleCache;\n if (workletsCache === undefined) {\n // init\n workletsCache = global.__workletsCache = new Map();\n handleCache = global.__handleCache = new WeakMap();\n }\n if (objectToUnpack.__workletHash) {\n let workletFun = workletsCache.get(objectToUnpack.__workletHash);\n if (workletFun === undefined) {\n // eslint-disable-next-line no-eval\n workletFun = eval('(' + objectToUnpack.asString + '\\n)') as (\n ...args: any[]\n ) => any;\n workletsCache.set(objectToUnpack.__workletHash, workletFun);\n }\n const functionInstance = workletFun.bind(objectToUnpack);\n objectToUnpack._recur = functionInstance;\n return functionInstance;\n } else if (objectToUnpack.__init) {\n let value = handleCache!.get(objectToUnpack);\n if (value === undefined) {\n value = objectToUnpack.__init();\n handleCache!.set(objectToUnpack, value);\n }\n return value;\n } else if (category === 'RemoteFunction') {\n const fun = () => {\n throw new Error(`Tried to synchronously call a non-worklet function on the UI thread.\n\nPossible solutions are:\n a) If you want to synchronously execute this method, mark it as a worklet\n b) If you want to execute this function on the JS thread, wrap it using \\`runOnJS\\``);\n };\n fun.__remoteFunction = objectToUnpack;\n return fun;\n } else {\n throw new Error('data type not recognized by unpack method');\n }\n}\n\nexport function registerEventHandler<T>(\n eventHash: string,\n eventHandler: (event: T) => void\n): string {\n return NativeReanimatedModule.registerEventHandler(\n eventHash,\n makeShareableCloneRecursive(eventHandler)\n );\n}\n\nexport function unregisterEventHandler(id: string): void {\n return NativeReanimatedModule.unregisterEventHandler(id);\n}\n\nexport function subscribeForKeyboardEvents(\n eventHandler: (state: number, height: number) => void\n): number {\n return NativeReanimatedModule.subscribeForKeyboardEvents(\n makeShareableCloneRecursive(eventHandler)\n );\n}\n\nexport function unsubscribeFromKeyboardEvents(listenerId: number): void {\n return NativeReanimatedModule.unsubscribeFromKeyboardEvents(listenerId);\n}\n\nexport function registerSensor(\n sensorType: number,\n interval: number,\n eventHandler: (data: Value3D | ValueRotation) => void\n): number {\n return NativeReanimatedModule.registerSensor(\n sensorType,\n interval,\n makeShareableCloneRecursive(eventHandler)\n );\n}\n\nexport function unregisterSensor(listenerId: number): void {\n return NativeReanimatedModule.unregisterSensor(listenerId);\n}\n\nNativeReanimatedModule.installCoreFunctions(valueUnpacker);\n\nif (!isWeb() && isConfigured()) {\n const capturableConsole = console;\n runOnUI(() => {\n 'worklet';\n const console = {\n debug: runOnJS(capturableConsole.debug),\n log: runOnJS(capturableConsole.log),\n warn: runOnJS(capturableConsole.warn),\n error: runOnJS(capturableConsole.error),\n info: runOnJS(capturableConsole.info),\n };\n _setGlobalConsole(console);\n })();\n}\n\ntype FeaturesConfig = {\n enableLayoutAnimations: boolean;\n setByUser: boolean;\n};\n\nlet featuresConfig: FeaturesConfig = {\n enableLayoutAnimations: false,\n setByUser: false,\n};\n\nexport function enableLayoutAnimations(\n flag: boolean,\n isCallByUser = true\n): void {\n if (isCallByUser) {\n featuresConfig = {\n enableLayoutAnimations: flag,\n setByUser: true,\n };\n NativeReanimatedModule.enableLayoutAnimations(flag);\n } else if (\n !featuresConfig.setByUser &&\n featuresConfig.enableLayoutAnimations !== flag\n ) {\n featuresConfig.enableLayoutAnimations = flag;\n NativeReanimatedModule.enableLayoutAnimations(flag);\n }\n}\n\nexport function configureLayoutAnimations(\n viewTag: number,\n type: string,\n config: LayoutAnimationFunction | Keyframe\n): void {\n NativeReanimatedModule.configureLayoutAnimation(\n viewTag,\n type,\n makeShareableCloneRecursive(config)\n );\n}\n\nexport function configureProps(uiProps: string[], nativeProps: string[]): void {\n if (!nativeShouldBeMock()) {\n NativeReanimatedModule.configureProps(uiProps, nativeProps);\n }\n}\n"],"mappings":"AAAA;AACA,OAAOA,sBAAP,MAAmC,oBAAnC;AACA,SAASC,kBAAT,EAA6BC,cAA7B,EAA6CC,KAA7C,QAA0D,mBAA1D;AAEA,SACEC,2BADF,EAEEC,aAAa,IAAIC,sBAFnB,QAGO,cAHP;AAIA,SAASC,OAAT,EAAkBC,OAAlB,QAAiC,WAAjC;AACA,SAASC,WAAW,IAAIC,oBAAxB,QAAoD,WAApD;AACA,SACEC,WAAW,IAAIC,oBADjB,EAEEC,UAAU,IAAIC,mBAFhB,QAGO,YAHP;AAMA,SAASC,UAAT,QAA2B,WAA3B;AACA,SAASP,OAAT,EAAkBD,OAAlB,QAAiC,WAAjC;AACA,SAASS,YAAT,QAA6B,QAA7B;;AAEA,IAAIC,MAAM,CAACC,iBAAP,KAA6BC,SAAjC,EAA4C;EAC1C;EACAF,MAAM,CAACC,iBAAP,GAA2B,MAAM,CAC/B;EACD,CAFD;AA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,IAA9C;EACD,CAND,MAMO,IACL,CAACH,cAAc,CAACE,SAAhB,IACAF,cAAc,CAACC,sBAAf,KAA0CE,IAFrC,EAGL;IACAH,cAAc,CAACC,sBAAf,GAAwCE,IAAxC;IACAvF,sBAAsB,CAACqF,sBAAvB,CAA8CE,IAA9C;EACD;AACF;AAED,OAAO,SAASE,yBAAT,CACLpD,OADK,EAELqD,IAFK,EAGLC,MAHK,EAIC;EACN3F,sBAAsB,CAAC4F,wBAAvB,CACEvD,OADF,EAEEqD,IAFF,EAGEtF,2BAA2B,CAACuF,MAAD,CAH7B;AAKD;AAED,OAAO,SAASE,cAAT,CAAwBC,OAAxB,EAA2CC,WAA3C,EAAwE;EAC7E,IAAI,CAAC9F,kBAAkB,EAAvB,EAA2B;IACzBD,sBAAsB,CAAC6F,cAAvB,CAAsCC,OAAtC,EAA+CC,WAA/C;EACD;AACF"}
|
|
1
|
+
{"version":3,"names":["NativeReanimatedModule","nativeShouldBeMock","shouldBeUseWeb","isWeb","makeShareableCloneRecursive","makeShareable","makeShareableUnwrapped","startMapper","startMapperUnwrapped","makeMutable","makeMutableUnwrapped","makeRemote","makeRemoteUnwrapped","initializeUIRuntime","stopMapper","runOnJS","runOnUI","testWorklet","throwUninitializedReanimatedException","Error","checkPluginState","throwError","__workletHash","isConfigured","isConfiguredCheck","configurationCheckWrapper","__DEV__","fn","global","_WORKLET","_log","s","console","log","getViewProp","viewTag","propName","_IS_FABRIC","Promise","resolve","reject","result","substr","registerEventHandler","eventHash","eventHandler","handleAndFlushImmediates","eventTimestamp","event","__frameTimestamp","__flushAnimationFrame","undefined","unregisterEventHandler","id","subscribeForKeyboardEvents","options","state","height","now","performance","isStatusBarTranslucentAndroid","unsubscribeFromKeyboardEvents","listenerId","registerSensor","sensorType","interval","iosReferenceFrame","unregisterSensor","featuresConfig","enableLayoutAnimations","setByUser","flag","isCallByUser","configureLayoutAnimations","type","config","sharedTransitionTag","configureLayoutAnimation","configureProps","uiProps","nativeProps"],"sources":["core.ts"],"sourcesContent":["import NativeReanimatedModule from './NativeReanimated';\nimport { nativeShouldBeMock, shouldBeUseWeb, isWeb } from './PlatformChecker';\nimport {\n AnimatedKeyboardOptions,\n BasicWorkletFunction,\n Value3D,\n ValueRotation,\n} from './commonTypes';\nimport {\n makeShareableCloneRecursive,\n makeShareable as makeShareableUnwrapped,\n} from './shareables';\nimport { startMapper as startMapperUnwrapped } from './mappers';\nimport {\n makeMutable as makeMutableUnwrapped,\n makeRemote as makeRemoteUnwrapped,\n} from './mutables';\nimport {\n LayoutAnimationFunction,\n LayoutAnimationType,\n} from './layoutReanimation';\nimport { initializeUIRuntime } from './initializers';\n\nexport { stopMapper } from './mappers';\nexport { runOnJS, runOnUI } from './threads';\n\nexport type ReanimatedConsole = Pick<\n Console,\n 'debug' | 'log' | 'warn' | 'info' | 'error'\n>;\n\nconst testWorklet: BasicWorkletFunction<void> = () => {\n 'worklet';\n};\n\nconst throwUninitializedReanimatedException = () => {\n throw new Error(\n \"Failed to initialize react-native-reanimated library, make sure you followed installation steps here: https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation/ \\n1) Make sure reanimated's babel plugin is installed in your babel.config.js (you should have 'react-native-reanimated/plugin' listed there - also see the above link for details) \\n2) Make sure you reset build cache after updating the config, run: yarn start --reset-cache\"\n );\n};\n\nexport const checkPluginState: (throwError: boolean) => boolean = (\n throwError = true\n) => {\n if (!testWorklet.__workletHash && !shouldBeUseWeb()) {\n if (throwError) {\n throwUninitializedReanimatedException();\n }\n return false;\n }\n return true;\n};\n\nexport const isConfigured: (throwError?: boolean) => boolean = (\n throwError = false\n) => {\n return checkPluginState(throwError);\n};\n\nexport const isConfiguredCheck: () => void = () => {\n checkPluginState(true);\n};\n\nconst configurationCheckWrapper = __DEV__\n ? <T extends Array<any>, U>(fn: (...args: T) => U) => {\n return (...args: T): U => {\n isConfigured(true);\n return fn(...args);\n };\n }\n : <T extends Array<any>, U>(fn: (...args: T) => U) => fn;\n\nexport const startMapper = __DEV__\n ? configurationCheckWrapper(startMapperUnwrapped)\n : startMapperUnwrapped;\n\nexport const makeShareable = __DEV__\n ? configurationCheckWrapper(makeShareableUnwrapped)\n : makeShareableUnwrapped;\n\nexport const makeMutable = __DEV__\n ? configurationCheckWrapper(makeMutableUnwrapped)\n : makeMutableUnwrapped;\n\nexport const makeRemote = __DEV__\n ? configurationCheckWrapper(makeRemoteUnwrapped)\n : makeRemoteUnwrapped;\n\nglobal._WORKLET = false;\nglobal._log = function (s: string) {\n console.log(s);\n};\n\nexport function getViewProp<T>(viewTag: string, propName: string): Promise<T> {\n if (global._IS_FABRIC) {\n throw new Error(\n '[react-native-reanimated] `getViewProp` is not supported on Fabric yet'\n );\n }\n\n return new Promise((resolve, reject) => {\n return NativeReanimatedModule.getViewProp(\n viewTag,\n propName,\n (result: T) => {\n if (typeof result === 'string' && result.substr(0, 6) === 'error:') {\n reject(result);\n } else {\n resolve(result);\n }\n }\n );\n });\n}\n\nexport function registerEventHandler<T>(\n eventHash: string,\n eventHandler: (event: T) => void\n): string {\n function handleAndFlushImmediates(eventTimestamp: number, event: T) {\n 'worklet';\n global.__frameTimestamp = eventTimestamp;\n eventHandler(event);\n global.__flushAnimationFrame(eventTimestamp);\n global.__frameTimestamp = undefined;\n }\n return NativeReanimatedModule.registerEventHandler(\n eventHash,\n makeShareableCloneRecursive(handleAndFlushImmediates)\n );\n}\n\nexport function unregisterEventHandler(id: string): void {\n return NativeReanimatedModule.unregisterEventHandler(id);\n}\n\nexport function subscribeForKeyboardEvents(\n eventHandler: (state: number, height: number) => void,\n options: AnimatedKeyboardOptions\n): number {\n // TODO: this should really go with the same code path as other events, that is\n // via registerEventHandler. For now we are copying the code from there.\n function handleAndFlushImmediates(state: number, height: number) {\n 'worklet';\n const now = performance.now();\n global.__frameTimestamp = now;\n eventHandler(state, height);\n global.__flushAnimationFrame(now);\n global.__frameTimestamp = undefined;\n }\n return NativeReanimatedModule.subscribeForKeyboardEvents(\n makeShareableCloneRecursive(handleAndFlushImmediates),\n options.isStatusBarTranslucentAndroid ?? false\n );\n}\n\nexport function unsubscribeFromKeyboardEvents(listenerId: number): void {\n return NativeReanimatedModule.unsubscribeFromKeyboardEvents(listenerId);\n}\n\nexport function registerSensor(\n sensorType: number,\n interval: number,\n iosReferenceFrame: number,\n eventHandler: (\n data: Value3D | ValueRotation,\n orientationDegrees: number\n ) => void\n): number {\n return NativeReanimatedModule.registerSensor(\n sensorType,\n interval,\n iosReferenceFrame,\n makeShareableCloneRecursive(eventHandler)\n );\n}\n\nexport function unregisterSensor(listenerId: number): void {\n return NativeReanimatedModule.unregisterSensor(listenerId);\n}\n\n// initialize UI runtime if applicable\nif (!isWeb() && isConfigured()) {\n initializeUIRuntime();\n}\n\ntype FeaturesConfig = {\n enableLayoutAnimations: boolean;\n setByUser: boolean;\n};\n\nlet featuresConfig: FeaturesConfig = {\n enableLayoutAnimations: false,\n setByUser: false,\n};\n\nexport function enableLayoutAnimations(\n flag: boolean,\n isCallByUser = true\n): void {\n if (isCallByUser) {\n featuresConfig = {\n enableLayoutAnimations: flag,\n setByUser: true,\n };\n NativeReanimatedModule.enableLayoutAnimations(flag);\n } else if (\n !featuresConfig.setByUser &&\n featuresConfig.enableLayoutAnimations !== flag\n ) {\n featuresConfig.enableLayoutAnimations = flag;\n NativeReanimatedModule.enableLayoutAnimations(flag);\n }\n}\n\nexport function configureLayoutAnimations(\n viewTag: number,\n type: LayoutAnimationType,\n config: LayoutAnimationFunction | Keyframe,\n sharedTransitionTag = ''\n): void {\n NativeReanimatedModule.configureLayoutAnimation(\n viewTag,\n type,\n sharedTransitionTag,\n makeShareableCloneRecursive(config)\n );\n}\n\nexport function configureProps(uiProps: string[], nativeProps: string[]): void {\n if (!nativeShouldBeMock()) {\n NativeReanimatedModule.configureProps(uiProps, nativeProps);\n }\n}\n"],"mappings":"AAAA,OAAOA,sBAAP,MAAmC,oBAAnC;AACA,SAASC,kBAAT,EAA6BC,cAA7B,EAA6CC,KAA7C,QAA0D,mBAA1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AAFwB,CAArC;AAKA,OAAO,SAASD,sBAAT,CACLE,IADK,EAGC;EAAA,IADNC,YACM,uEADS,IACT;;EACN,IAAIA,YAAJ,EAAkB;IAChBJ,cAAc,GAAG;MACfC,sBAAsB,EAAEE,IADT;MAEfD,SAAS,EAAE;IAFI,CAAjB;IAIAtE,sBAAsB,CAACqE,sBAAvB,CAA8CE,IAA9C;EACD,CAND,MAMO,IACL,CAACH,cAAc,CAACE,SAAhB,IACAF,cAAc,CAACC,sBAAf,KAA0CE,IAFrC,EAGL;IACAH,cAAc,CAACC,sBAAf,GAAwCE,IAAxC;IACAvE,sBAAsB,CAACqE,sBAAvB,CAA8CE,IAA9C;EACD;AACF;AAED,OAAO,SAASE,yBAAT,CACLtC,OADK,EAELuC,IAFK,EAGLC,MAHK,EAKC;EAAA,IADNC,mBACM,uEADgB,EAChB;EACN5E,sBAAsB,CAAC6E,wBAAvB,CACE1C,OADF,EAEEuC,IAFF,EAGEE,mBAHF,EAIExE,2BAA2B,CAACuE,MAAD,CAJ7B;AAMD;AAED,OAAO,SAASG,cAAT,CAAwBC,OAAxB,EAA2CC,WAA3C,EAAwE;EAC7E,IAAI,CAAC/E,kBAAkB,EAAvB,EAA2B;IACzBD,sBAAsB,CAAC8E,cAAvB,CAAsCC,OAAtC,EAA+CC,WAA/C;EACD;AACF"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
const _workletStackDetails = new Map();
|
|
2
|
+
|
|
3
|
+
export function registerWorkletStackDetails(hash, stackDetails) {
|
|
4
|
+
_workletStackDetails.set(hash, stackDetails);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function getBundleOffset(error) {
|
|
8
|
+
var _error$stack, _error$stack$split;
|
|
9
|
+
|
|
10
|
+
const frame = (_error$stack = error.stack) === null || _error$stack === void 0 ? void 0 : (_error$stack$split = _error$stack.split('\n')) === null || _error$stack$split === void 0 ? void 0 : _error$stack$split[0];
|
|
11
|
+
|
|
12
|
+
if (frame) {
|
|
13
|
+
const parsedFrame = /@([^@]+):(\d+):(\d+)/.exec(frame);
|
|
14
|
+
|
|
15
|
+
if (parsedFrame) {
|
|
16
|
+
const [, file, line, col] = parsedFrame;
|
|
17
|
+
return [file, Number(line), Number(col)];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return ['unknown', 0, 0];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function processStack(stack) {
|
|
25
|
+
const workletStackEntries = stack.match(/worklet_(\d+):(\d+):(\d+)/g);
|
|
26
|
+
let result = stack;
|
|
27
|
+
workletStackEntries === null || workletStackEntries === void 0 ? void 0 : workletStackEntries.forEach(match => {
|
|
28
|
+
const [, hash, origLine, origCol] = match.split(/:|_/).map(Number);
|
|
29
|
+
|
|
30
|
+
const errorDetails = _workletStackDetails.get(hash);
|
|
31
|
+
|
|
32
|
+
if (!errorDetails) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const [error, lineOffset, colOffset] = errorDetails;
|
|
37
|
+
const [bundleFile, bundleLine, bundleCol] = getBundleOffset(error);
|
|
38
|
+
const line = origLine + bundleLine + lineOffset;
|
|
39
|
+
const col = origCol + bundleCol + colOffset;
|
|
40
|
+
result = result.replace(match, `${bundleFile}:${line}:${col}`);
|
|
41
|
+
});
|
|
42
|
+
return result;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function reportFatalErrorOnJS(_ref) {
|
|
46
|
+
let {
|
|
47
|
+
message,
|
|
48
|
+
stack
|
|
49
|
+
} = _ref;
|
|
50
|
+
const error = new Error();
|
|
51
|
+
error.message = message;
|
|
52
|
+
error.stack = stack ? processStack(stack) : undefined;
|
|
53
|
+
error.name = 'ReanimatedError'; // @ts-ignore React Native's ErrorUtils implementation extends the Error type with jsEngine field
|
|
54
|
+
|
|
55
|
+
error.jsEngine = 'reanimated';
|
|
56
|
+
global.ErrorUtils.reportFatalError(error);
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_workletStackDetails","Map","registerWorkletStackDetails","hash","stackDetails","set","getBundleOffset","error","frame","stack","split","parsedFrame","exec","file","line","col","Number","processStack","workletStackEntries","match","result","forEach","origLine","origCol","map","errorDetails","get","lineOffset","colOffset","bundleFile","bundleLine","bundleCol","replace","reportFatalErrorOnJS","message","Error","undefined","name","jsEngine","global","ErrorUtils","reportFatalError"],"sources":["errors.ts"],"sourcesContent":["type StackDetails = [Error, number, number];\n\nconst _workletStackDetails = new Map<number, StackDetails>();\n\nexport function registerWorkletStackDetails(\n hash: number,\n stackDetails: StackDetails\n) {\n _workletStackDetails.set(hash, stackDetails);\n}\n\nfunction getBundleOffset(error: Error): [string, number, number] {\n const frame = error.stack?.split('\\n')?.[0];\n if (frame) {\n const parsedFrame = /@([^@]+):(\\d+):(\\d+)/.exec(frame);\n if (parsedFrame) {\n const [, file, line, col] = parsedFrame;\n return [file, Number(line), Number(col)];\n }\n }\n return ['unknown', 0, 0];\n}\n\nfunction processStack(stack: string): string {\n const workletStackEntries = stack.match(/worklet_(\\d+):(\\d+):(\\d+)/g);\n let result = stack;\n workletStackEntries?.forEach((match) => {\n const [, hash, origLine, origCol] = match.split(/:|_/).map(Number);\n const errorDetails = _workletStackDetails.get(hash);\n if (!errorDetails) {\n return;\n }\n const [error, lineOffset, colOffset] = errorDetails;\n const [bundleFile, bundleLine, bundleCol] = getBundleOffset(error);\n const line = origLine + bundleLine + lineOffset;\n const col = origCol + bundleCol + colOffset;\n\n result = result.replace(match, `${bundleFile}:${line}:${col}`);\n });\n return result;\n}\n\nexport function reportFatalErrorOnJS({\n message,\n stack,\n}: {\n message: string;\n stack?: string;\n}) {\n const error = new Error();\n error.message = message;\n error.stack = stack ? processStack(stack) : undefined;\n error.name = 'ReanimatedError';\n // @ts-ignore React Native's ErrorUtils implementation extends the Error type with jsEngine field\n error.jsEngine = 'reanimated';\n global.ErrorUtils.reportFatalError(error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SAApB,IAAiCH,YAAvC;IACA,MAAM,CAACI,UAAD,EAAaC,UAAb,EAAyBC,SAAzB,IAAsCzB,eAAe,CAACC,KAAD,CAA3D;IACA,MAAMO,IAAI,GAAGQ,QAAQ,GAAGQ,UAAX,GAAwBH,UAArC;IACA,MAAMZ,GAAG,GAAGQ,OAAO,GAAGQ,SAAV,GAAsBH,SAAlC;IAEAR,MAAM,GAAGA,MAAM,CAACY,OAAP,CAAeb,KAAf,EAAuB,GAAEU,UAAW,IAAGf,IAAK,IAAGC,GAAI,EAAnD,CAAT;EACD,CAZD;EAaA,OAAOK,MAAP;AACD;;AAED,OAAO,SAASa,oBAAT,OAMJ;EAAA,IANkC;IACnCC,OADmC;IAEnCzB;EAFmC,CAMlC;EACD,MAAMF,KAAK,GAAG,IAAI4B,KAAJ,EAAd;EACA5B,KAAK,CAAC2B,OAAN,GAAgBA,OAAhB;EACA3B,KAAK,CAACE,KAAN,GAAcA,KAAK,GAAGQ,YAAY,CAACR,KAAD,CAAf,GAAyB2B,SAA5C;EACA7B,KAAK,CAAC8B,IAAN,GAAa,iBAAb,CAJC,CAKD;;EACA9B,KAAK,CAAC+B,QAAN,GAAiB,YAAjB;EACAC,MAAM,CAACC,UAAP,CAAkBC,gBAAlB,CAAmClC,KAAnC;AACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["runOnUIImmediately","prepareUIRegistry","frameCallbackRegistry","Map","activeFrameCallbacks","Set","previousFrameTimestamp","runCallbacks","loop","timestamp","delta","forEach","callbackId","callbackDetails","get","startTime","callback","timeSincePreviousFrame","timeSinceFirstFrame","size","requestAnimationFrame","registerFrameCallback","set","unregisterFrameCallback","manageStateFrameCallback","delete","state","add","global","_frameCallbackRegistry"],"sources":["FrameCallbackRegistryUI.ts"],"sourcesContent":["import { runOnUIImmediately } from '../threads';\n\ntype CallbackDetails = {\n callback: (frameInfo: FrameInfo) => void;\n startTime: number | null;\n};\n\nexport type FrameInfo = {\n timestamp: number;\n timeSincePreviousFrame: number | null;\n timeSinceFirstFrame: number;\n};\n\nexport interface FrameCallbackRegistryUI {\n frameCallbackRegistry: Map<number, CallbackDetails>;\n activeFrameCallbacks: Set<number>;\n previousFrameTimestamp: number | null;\n runCallbacks: () => void;\n registerFrameCallback: (\n callback: (frameInfo: FrameInfo) => void,\n callbackId: number\n ) => void;\n unregisterFrameCallback: (callbackId: number) => void;\n manageStateFrameCallback: (callbackId: number, state: boolean) => void;\n}\n\nexport const prepareUIRegistry = runOnUIImmediately(() => {\n 'worklet';\n\n const frameCallbackRegistry: FrameCallbackRegistryUI = {\n frameCallbackRegistry: new Map<number, CallbackDetails>(),\n activeFrameCallbacks: new Set<number>(),\n previousFrameTimestamp: null,\n\n runCallbacks() {\n const loop = (timestamp: number) => {\n if (this.previousFrameTimestamp === null) {\n this.previousFrameTimestamp = timestamp;\n }\n\n const delta = timestamp - this.previousFrameTimestamp;\n\n this.activeFrameCallbacks.forEach((callbackId: number) => {\n const callbackDetails = this.frameCallbackRegistry.get(callbackId)!;\n\n const { startTime } = callbackDetails;\n\n if (startTime === null) {\n // First frame\n callbackDetails.startTime = timestamp;\n\n callbackDetails.callback({\n timestamp,\n timeSincePreviousFrame: null,\n timeSinceFirstFrame: 0,\n });\n } else {\n // Next frame\n callbackDetails.callback({\n timestamp,\n timeSincePreviousFrame: delta,\n timeSinceFirstFrame: timestamp - startTime,\n });\n }\n });\n\n if (this.activeFrameCallbacks.size > 0) {\n this.previousFrameTimestamp = timestamp;\n requestAnimationFrame(loop);\n } else {\n this.previousFrameTimestamp = null;\n }\n };\n\n // runCallback() should only be called after registering a callback,\n // so if there is only one active callback, then it means that there were\n // zero previously and the loop isn't running yet.\n if (this.activeFrameCallbacks.size === 1) {\n requestAnimationFrame(loop);\n }\n },\n\n registerFrameCallback(\n callback: (frameInfo: FrameInfo) => void,\n callbackId: number\n ) {\n this.frameCallbackRegistry.set(callbackId, {\n callback: callback,\n startTime: null,\n });\n },\n\n unregisterFrameCallback(callbackId: number) {\n this.manageStateFrameCallback(callbackId, false);\n this.frameCallbackRegistry.delete(callbackId);\n },\n\n manageStateFrameCallback(callbackId: number, state: boolean) {\n if (callbackId === -1) {\n return;\n }\n if (state) {\n this.activeFrameCallbacks.add(callbackId);\n this.runCallbacks();\n } else {\n const callback = this.frameCallbackRegistry.get(callbackId)!;\n callback.startTime = null;\n\n this.activeFrameCallbacks.delete(callbackId);\n }\n },\n };\n\n global._frameCallbackRegistry = frameCallbackRegistry;\n});\n"],"mappings":"AAAA,SAASA,kBAAT,QAAmC,YAAnC;AA0BA,OAAO,MAAMC,iBAAiB,GAAGD,kBAAkB,CAAC,MAAM;EACxD;;EAEA,MAAME,qBAA8C,GAAG;IACrDA,qBAAqB,EAAE,IAAIC,GAAJ,EAD8B;IAErDC,oBAAoB,EAAE,IAAIC,GAAJ,EAF+B;IAGrDC,sBAAsB,EAAE,IAH6B;;IAKrDC,YAAY,GAAG;MACb,MAAMC,IAAI,GAAIC,SAAD,IAAuB;QAClC,IAAI,KAAKH,sBAAL,KAAgC,IAApC,EAA0C;UACxC,KAAKA,sBAAL,GAA8BG,SAA9B;QACD;;QAED,MAAMC,KAAK,GAAGD,SAAS,GAAG,KAAKH,sBAA/B;QAEA,KAAKF,oBAAL,CAA0BO,OAA1B,CAAmCC,UAAD,IAAwB;UACxD,MAAMC,eAAe,GAAG,KAAKX,qBAAL,CAA2BY,GAA3B,CAA+BF,UAA/B,CAAxB;UAEA,MAAM;YAAEG;UAAF,IAAgBF,eAAtB;;UAEA,IAAIE,SAAS,KAAK,IAAlB,EAAwB;YACtB;YACAF,eAAe,CAACE,SAAhB,GAA4BN,SAA5B;YAEAI,eAAe,CAACG,QAAhB,CAAyB;cACvBP,SADuB;cAEvBQ,sBAAsB,EAAE,IAFD;cAGvBC,mBAAmB,EAAE;YAHE,CAAzB;UAKD,CATD,MASO;YACL;YACAL,eAAe,CAACG,QAAhB,CAAyB;cACvBP,SADuB;cAEvBQ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GAAgC3B,qBAAhC;AACD,CAxFkD,CAA5C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["globals.d.ts"],"sourcesContent":["import type {\n AnimatedStyle,\n StyleProps,\n MeasuredDimensions,\n MapperRegistry,\n ShareableRef,\n ShareableSyncDataHolderRef,\n} from './commonTypes';\nimport type {
|
|
1
|
+
{"version":3,"names":[],"sources":["globals.d.ts"],"sourcesContent":["import type {\n AnimatedStyle,\n StyleProps,\n MeasuredDimensions,\n MapperRegistry,\n ShareableRef,\n ShareableSyncDataHolderRef,\n} from './commonTypes';\nimport type { FrameCallbackRegistryUI } from './frameCallback/FrameCallbackRegistryUI';\nimport type { ShadowNodeWrapper } from './hook/commonTypes';\nimport { LayoutAnimationStartFunction } from './layoutReanimation';\nimport type { NativeReanimated } from './NativeReanimated/NativeReanimated';\n\ndeclare global {\n const _WORKLET: boolean;\n const _IS_FABRIC: boolean;\n const _REANIMATED_VERSION_CPP: string;\n const __reanimatedModuleProxy: NativeReanimated;\n const evalWithSourceMap: (\n js: string,\n sourceURL: string,\n sourceMap: string\n ) => any;\n const evalWithSourceUrl: (js: string, sourceURL: string) => any;\n const _log: (s: string) => void;\n const _getCurrentTime: () => number;\n const _notifyAboutProgress: (\n tag: number,\n value: number,\n isSharedTransition: boolean\n ) => void;\n const _notifyAboutEnd: (\n tag: number,\n finished: boolean,\n removeView: boolean\n ) => void;\n const _setGestureState: (handlerTag: number, newState: number) => void;\n const _makeShareableClone: (value: any) => any;\n const _updateDataSynchronously: (\n dataHolder: ShareableSyncDataHolderRef,\n data: ShareableRef\n ) => void;\n const _scheduleOnJS: (fun: ShareableRef, args?: ShareableRef) => void;\n const _updatePropsPaper: (\n tag: number,\n name: string,\n updates: StyleProps | AnimatedStyle\n ) => void;\n const _updatePropsFabric: (\n shadowNodeWrapper: ShadowNodeWrapper,\n props: StyleProps | AnimatedStyle\n ) => void;\n const _removeShadowNodeFromRegistry: (viewTag: number) => void;\n const _measure: (viewTag: number) => MeasuredDimensions;\n const _scrollTo: (\n viewTag: number,\n x: number,\n y: number,\n animated: boolean\n ) => void;\n const _dispatchCommand: (\n shadowNodeWrapper: ShadowNodeWrapper,\n commandName: string,\n args: Array<unknown>\n ) => void;\n const performance: { now: () => number };\n const ReanimatedDataMock: {\n now: () => number;\n };\n const ErrorUtils: {\n reportFatalError: (error: Error) => void;\n };\n const _frameCallbackRegistry: FrameCallbackRegistryUI;\n const requestAnimationFrame: (callback: (time: number) => void) => number;\n const setImmediate: (callback: (time: number) => void) => number;\n const console: Console;\n\n namespace NodeJS {\n interface Global {\n _WORKLET: boolean;\n _IS_FABRIC: boolean;\n _REANIMATED_VERSION_CPP: string;\n __reanimatedModuleProxy: NativeReanimated;\n __frameTimestamp?: number;\n evalWithSourceMap: (\n js: string,\n sourceURL: string,\n sourceMap: string\n ) => any;\n evalWithSourceUrl: (js: string, sourceURL: string) => any;\n _log: (s: string) => void;\n _getCurrentTime: () => number;\n _setGestureState: (handlerTag: number, newState: number) => void;\n _makeShareableClone: (value: any) => any;\n _updateDataSynchronously: (\n ShareableSyncDataHolderRef,\n ShareableRef\n ) => void;\n _scheduleOnJS: (fun: ShareableRef, args?: ShareableRef) => void;\n _updatePropsPaper: (\n tag: number,\n name: string,\n updates: StyleProps | AnimatedStyle\n ) => void;\n _updatePropsFabric: (\n shadowNodeWrapper: ShadowNodeWrapper,\n props: StyleProps | AnimatedStyle\n ) => void;\n _removeShadowNodeFromRegistry: (viewTag: number) => void;\n _measure: (viewTag: number) => MeasuredDimensions;\n _scrollTo: (\n viewTag: number,\n x: number,\n y: number,\n animated: boolean\n ) => void;\n _dispatchCommand: (\n shadowNodeWrapper: ShadowNodeWrapper,\n commandName: string,\n args: Array<unknown>\n ) => void;\n performance: { now: () => number };\n LayoutAnimationsManager: {\n start: LayoutAnimationStartFunction;\n };\n ReanimatedDataMock: {\n now: () => number;\n };\n ErrorUtils: {\n reportFatalError: (error: Error) => void;\n };\n _frameCallbackRegistry: FrameCallbackRegistryUI;\n __workletsCache?: Map<string, (...args: any[]) => any>;\n __handleCache?: WeakMap<any, any>;\n __mapperRegistry?: MapperRegistry;\n __flushImmediates: () => void;\n __flushAnimationFrame: (frameTimestamp: number) => void;\n requestAnimationFrame: (callback: (time: number) => void) => number;\n setImmediate: (callback: (time: number) => void) => number;\n console: Console;\n }\n }\n}\n"],"mappings":""}
|
|
@@ -6,7 +6,7 @@ export { useAnimatedReaction } from './useAnimatedReaction';
|
|
|
6
6
|
export { useAnimatedRef } from './useAnimatedRef';
|
|
7
7
|
export { useAnimatedScrollHandler } from './useAnimatedScrollHandler';
|
|
8
8
|
export { useDerivedValue } from './useDerivedValue';
|
|
9
|
-
export { useAnimatedSensor
|
|
9
|
+
export { useAnimatedSensor } from './useAnimatedSensor';
|
|
10
10
|
export { useFrameCallback } from './useFrameCallback';
|
|
11
11
|
export { useAnimatedKeyboard } from './useAnimatedKeyboard';
|
|
12
12
|
export { useScrollViewOffset } from './useScrollViewOffset';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useAnimatedProps","useEvent","useHandler","useWorkletCallback","useSharedValue","useAnimatedStyle","useAnimatedGestureHandler","useAnimatedReaction","useAnimatedRef","useAnimatedScrollHandler","useDerivedValue","useAnimatedSensor","
|
|
1
|
+
{"version":3,"names":["useAnimatedProps","useEvent","useHandler","useWorkletCallback","useSharedValue","useAnimatedStyle","useAnimatedGestureHandler","useAnimatedReaction","useAnimatedRef","useAnimatedScrollHandler","useDerivedValue","useAnimatedSensor","useFrameCallback","useAnimatedKeyboard","useScrollViewOffset"],"sources":["index.ts"],"sourcesContent":["export type { DependencyList } from './commonTypes';\nexport {\n useAnimatedProps,\n useEvent,\n useHandler,\n useWorkletCallback,\n} from './Hooks';\nexport { useSharedValue } from './useSharedValue';\nexport { useAnimatedStyle } from './useAnimatedStyle';\nexport type { AnimatedStyleResult } from './useAnimatedStyle';\nexport { useAnimatedGestureHandler } from './useAnimatedGestureHandler';\nexport type {\n GestureHandlerEvent,\n GestureHandlers,\n} from './useAnimatedGestureHandler';\nexport { useAnimatedReaction } from './useAnimatedReaction';\nexport type { AnimatedReactionWorkletFunction } from './useAnimatedReaction';\nexport { useAnimatedRef } from './useAnimatedRef';\nexport { useAnimatedScrollHandler } from './useAnimatedScrollHandler';\nexport type { ScrollHandler, ScrollHandlers } from './useAnimatedScrollHandler';\nexport { useDerivedValue } from './useDerivedValue';\nexport type { DerivedValue } from './useDerivedValue';\nexport { useAnimatedSensor } from './useAnimatedSensor';\nexport { useFrameCallback } from './useFrameCallback';\nexport type { FrameCallback } from './useFrameCallback';\nexport { useAnimatedKeyboard } from './useAnimatedKeyboard';\nexport { useScrollViewOffset } from './useScrollViewOffset';\n"],"mappings":"AACA,SACEA,gBADF,EAEEC,QAFF,EAGEC,UAHF,EAIEC,kBAJF,QAKO,SALP;AAMA,SAASC,cAAT,QAA+B,kBAA/B;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AAEA,SAASC,yBAAT,QAA0C,6BAA1C;AAKA,SAASC,mBAAT,QAAoC,uBAApC;AAEA,SAASC,cAAT,QAA+B,kBAA/B;AACA,SAASC,wBAAT,QAAyC,4BAAzC;AAEA,SAASC,eAAT,QAAgC,mBAAhC;AAEA,SAASC,iBAAT,QAAkC,qBAAlC;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AAEA,SAASC,mBAAT,QAAoC,uBAApC;AACA,SAASC,mBAAT,QAAoC,uBAApC"}
|
|
@@ -2,6 +2,9 @@ import { useEffect, useRef } from 'react';
|
|
|
2
2
|
import { makeMutable, subscribeForKeyboardEvents, unsubscribeFromKeyboardEvents } from '../core';
|
|
3
3
|
import { KeyboardState } from '../commonTypes';
|
|
4
4
|
export function useAnimatedKeyboard() {
|
|
5
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
6
|
+
isStatusBarTranslucentAndroid: false
|
|
7
|
+
};
|
|
5
8
|
const ref = useRef(null);
|
|
6
9
|
const listenerId = useRef(-1);
|
|
7
10
|
const isSubscribed = useRef(false);
|
|
@@ -16,7 +19,7 @@ export function useAnimatedKeyboard() {
|
|
|
16
19
|
|
|
17
20
|
keyboardEventData.state.value = state;
|
|
18
21
|
keyboardEventData.height.value = height;
|
|
19
|
-
});
|
|
22
|
+
}, options);
|
|
20
23
|
ref.current = keyboardEventData;
|
|
21
24
|
isSubscribed.current = true;
|
|
22
25
|
}
|
|
@@ -30,7 +33,7 @@ export function useAnimatedKeyboard() {
|
|
|
30
33
|
|
|
31
34
|
keyboardEventData.state.value = state;
|
|
32
35
|
keyboardEventData.height.value = height;
|
|
33
|
-
});
|
|
36
|
+
}, options);
|
|
34
37
|
isSubscribed.current = true;
|
|
35
38
|
}
|
|
36
39
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","useRef","makeMutable","subscribeForKeyboardEvents","unsubscribeFromKeyboardEvents","KeyboardState","useAnimatedKeyboard","ref","listenerId","isSubscribed","current","keyboardEventData","state","UNKNOWN","height","value"],"sources":["useAnimatedKeyboard.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\nimport {\n makeMutable,\n subscribeForKeyboardEvents,\n unsubscribeFromKeyboardEvents,\n} from '../core';\nimport {
|
|
1
|
+
{"version":3,"names":["useEffect","useRef","makeMutable","subscribeForKeyboardEvents","unsubscribeFromKeyboardEvents","KeyboardState","useAnimatedKeyboard","options","isStatusBarTranslucentAndroid","ref","listenerId","isSubscribed","current","keyboardEventData","state","UNKNOWN","height","value"],"sources":["useAnimatedKeyboard.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\nimport {\n makeMutable,\n subscribeForKeyboardEvents,\n unsubscribeFromKeyboardEvents,\n} from '../core';\nimport {\n AnimatedKeyboardInfo,\n AnimatedKeyboardOptions,\n KeyboardState,\n} from '../commonTypes';\n\nexport function useAnimatedKeyboard(\n options: AnimatedKeyboardOptions = { isStatusBarTranslucentAndroid: false }\n): AnimatedKeyboardInfo {\n const ref = useRef<AnimatedKeyboardInfo | null>(null);\n const listenerId = useRef<number>(-1);\n const isSubscribed = useRef<boolean>(false);\n\n if (ref.current === null) {\n const keyboardEventData: AnimatedKeyboardInfo = {\n state: makeMutable<KeyboardState>(KeyboardState.UNKNOWN),\n height: makeMutable(0),\n };\n listenerId.current = subscribeForKeyboardEvents((state, height) => {\n 'worklet';\n keyboardEventData.state.value = state;\n keyboardEventData.height.value = height;\n }, options);\n ref.current = keyboardEventData;\n isSubscribed.current = true;\n }\n useEffect(() => {\n if (isSubscribed.current === false && ref.current !== null) {\n const keyboardEventData = ref.current;\n // subscribe again after Fast Refresh\n listenerId.current = subscribeForKeyboardEvents((state, height) => {\n 'worklet';\n keyboardEventData.state.value = state;\n keyboardEventData.height.value = height;\n }, options);\n isSubscribed.current = true;\n }\n return () => {\n unsubscribeFromKeyboardEvents(listenerId.current);\n isSubscribed.current = false;\n };\n }, []);\n return ref.current;\n}\n"],"mappings":"AAAA,SAASA,SAAT,EAAoBC,MAApB,QAAkC,OAAlC;AACA,SACEC,WADF,EAEEC,0BAFF,EAGEC,6BAHF,QAIO,SAJP;AAKA,SAGEC,aAHF,QAIO,gBAJP;AAMA,OAAO,SAASC,mBAAT,GAEiB;EAAA,IADtBC,OACsB,uEADa;IAAEC,6BAA6B,EAAE;EAAjC,CACb;EACtB,MAAMC,GAAG,GAAGR,MAAM,CAA8B,IAA9B,CAAlB;EACA,MAAMS,UAAU,GAAGT,MAAM,CAAS,CAAC,CAAV,CAAzB;EACA,MAAMU,YAAY,GAAGV,MAAM,CAAU,KAAV,CAA3B;;EAEA,IAAIQ,GAAG,CAACG,OAAJ,KAAgB,IAApB,EAA0B;IACxB,MAAMC,iBAAuC,GAAG;MAC9CC,KAAK,EAAEZ,WAAW,CAAgBG,aAAa,CAACU,OAA9B,CAD4B;MAE9CC,MAAM,EAAEd,WAAW,CAAC,CAAD;IAF2B,CAAhD;IAIAQ,UAAU,CAACE,OAAX,GAAqBT,0BAA0B,CAAC,CAACW,KAAD,EAAQE,MAAR,KAAmB;MACjE;;MACAH,iBAAiB,CAACC,KAAlB,CAAwBG,KAAxB,GAAgCH,KAAhC;MACAD,iBAAiB,CAACG,MAAlB,CAAyBC,KAAzB,GAAiCD,MAAjC;IACD,CAJ8C,EAI5CT,OAJ4C,CAA/C;IAKAE,GAAG,CAACG,OAAJ,GAAcC,iBAAd;IACAF,YAAY,CAACC,OAAb,GAAuB,IAAvB;EACD;;EACDZ,SAAS,CAAC,MAAM;IACd,IAAIW,YAAY,CAACC,OAAb,KAAyB,KAAzB,IAAkCH,GAAG,CAACG,OAAJ,KAAgB,IAAtD,EAA4D;MAC1D,MAAMC,iBAAiB,GAAGJ,GAAG,CAACG,OAA9B,CAD0D,CAE1D;;MACAF,UAAU,CAACE,OAAX,GAAqBT,0BAA0B,CAAC,CAACW,KAAD,EAAQE,MAAR,KAAmB;QACjE;;QACAH,iBAAiB,CAACC,KAAlB,CAAwBG,KAAxB,GAAgCH,KAAhC;QACAD,iBAAiB,CAACG,MAAlB,CAAyBC,KAAzB,GAAiCD,MAAjC;MACD,CAJ8C,EAI5CT,OAJ4C,CAA/C;MAKAI,YAAY,CAACC,OAAb,GAAuB,IAAvB;IACD;;IACD,OAAO,MAAM;MACXR,6BAA6B,CAACM,UAAU,CAACE,OAAZ,CAA7B;MACAD,YAAY,CAACC,OAAb,GAAuB,KAAvB;IACD,CAHD;EAID,CAfQ,EAeN,EAfM,CAAT;EAgBA,OAAOH,GAAG,CAACG,OAAX;AACD"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
2
|
import { startMapper, stopMapper } from '../core';
|
|
3
3
|
import { useSharedValue } from './useSharedValue';
|
|
4
|
+
import { shouldBeUseWeb } from '../PlatformChecker';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* @param prepare - worklet used for data preparation for the second parameter
|
|
@@ -10,6 +11,16 @@ import { useSharedValue } from './useSharedValue';
|
|
|
10
11
|
*/
|
|
11
12
|
export function useAnimatedReaction(prepare, react, dependencies) {
|
|
12
13
|
const previous = useSharedValue(null);
|
|
14
|
+
let inputs = Object.values(prepare._closure ?? {});
|
|
15
|
+
|
|
16
|
+
if (shouldBeUseWeb()) {
|
|
17
|
+
var _dependencies;
|
|
18
|
+
|
|
19
|
+
if (!inputs.length && (_dependencies = dependencies) !== null && _dependencies !== void 0 && _dependencies.length) {
|
|
20
|
+
// let web work without a Babel/SWC plugin
|
|
21
|
+
inputs = dependencies;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
13
24
|
|
|
14
25
|
if (dependencies === undefined) {
|
|
15
26
|
dependencies = [Object.values(prepare._closure ?? {}), Object.values(react._closure ?? {}), prepare.__workletHash, react.__workletHash];
|
|
@@ -26,7 +37,7 @@ export function useAnimatedReaction(prepare, react, dependencies) {
|
|
|
26
37
|
previous.value = input;
|
|
27
38
|
};
|
|
28
39
|
|
|
29
|
-
const mapperId = startMapper(fun,
|
|
40
|
+
const mapperId = startMapper(fun, inputs, []);
|
|
30
41
|
return () => {
|
|
31
42
|
stopMapper(mapperId);
|
|
32
43
|
};
|