react-native-reanimated 3.0.2 → 3.1.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/Fabric/FabricUtils.h +1 -1
- package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +38 -27
- package/Common/cpp/SharedItems/Shareables.h +22 -0
- package/Common/cpp/Tools/PlatformDepMethodsHolder.h +2 -0
- package/Common/cpp/Tools/RuntimeDecorator.cpp +4 -1
- package/Common/cpp/Tools/RuntimeDecorator.h +2 -1
- package/Common/cpp/Tools/SingleInstanceChecker.h +14 -2
- package/RNReanimated.podspec +5 -2
- package/android/CMakeLists.txt +4 -0
- package/android/build.gradle +18 -10
- package/android/src/main/cpp/NativeProxy.cpp +316 -337
- package/android/src/main/cpp/NativeProxy.h +53 -11
- package/android/src/main/java/com/swmansion/reanimated/NativeMethodsHelper.java +7 -12
- package/android/src/main/java/com/swmansion/reanimated/NodesManager.java +11 -8
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/NativeProxyCommon.java +21 -14
- package/android/src/paper/java/com/swmansion/reanimated/NativeProxy.java +0 -3
- package/ios/Fabric/REAInitializerRCTFabricSurface.mm +1 -0
- package/ios/REANodesManager.h +1 -0
- package/ios/REANodesManager.mm +30 -4
- package/ios/keyboardObserver/REAKeyboardEventObserver.m +51 -130
- package/ios/native/NativeMethods.mm +1 -1
- package/ios/native/NativeProxy.mm +4 -1
- package/ios/native/REAIOSErrorHandler.mm +1 -1
- package/ios/native/REAIOSLogger.mm +1 -1
- package/ios/native/REAIOSScheduler.mm +1 -1
- package/ios/native/REAInitializer.mm +1 -1
- package/ios/native/REAMessageThread.mm +2 -2
- package/lib/commonjs/Animated.js +0 -8
- package/lib/commonjs/Animated.js.map +1 -1
- package/lib/commonjs/ConfigHelper.js +8 -19
- package/lib/commonjs/ConfigHelper.js.map +1 -1
- package/lib/commonjs/createAnimatedComponent.js +20 -158
- package/lib/commonjs/createAnimatedComponent.js.map +1 -1
- package/lib/commonjs/index.js +0 -9
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/index.web.js +0 -7
- package/lib/commonjs/index.web.js.map +1 -1
- package/lib/commonjs/reanimated2/Bezier.js +14 -34
- package/lib/commonjs/reanimated2/Bezier.js.map +1 -1
- package/lib/commonjs/reanimated2/Colors.js +60 -132
- package/lib/commonjs/reanimated2/Colors.js.map +1 -1
- package/lib/commonjs/reanimated2/Easing.js +81 -34
- package/lib/commonjs/reanimated2/Easing.js.map +1 -1
- package/lib/commonjs/reanimated2/NativeMethods.js +8 -20
- package/lib/commonjs/reanimated2/NativeMethods.js.map +1 -1
- package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js +5 -31
- package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
- package/lib/commonjs/reanimated2/NativeReanimated/index.js +0 -7
- package/lib/commonjs/reanimated2/NativeReanimated/index.js.map +1 -1
- package/lib/commonjs/reanimated2/PlatformChecker.js +0 -6
- package/lib/commonjs/reanimated2/PlatformChecker.js.map +1 -1
- package/lib/commonjs/reanimated2/PropAdapters.js +10 -12
- package/lib/commonjs/reanimated2/PropAdapters.js.map +1 -1
- package/lib/commonjs/reanimated2/UpdateProps.js +3 -12
- package/lib/commonjs/reanimated2/UpdateProps.js.map +1 -1
- package/lib/commonjs/reanimated2/ViewDescriptorsSet.js +0 -10
- package/lib/commonjs/reanimated2/ViewDescriptorsSet.js.map +1 -1
- package/lib/commonjs/reanimated2/WorkletEventHandler.js +5 -22
- package/lib/commonjs/reanimated2/WorkletEventHandler.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/decay.js +7 -18
- package/lib/commonjs/reanimated2/animation/decay.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/delay.js +0 -11
- package/lib/commonjs/reanimated2/animation/delay.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/index.js +0 -8
- package/lib/commonjs/reanimated2/animation/index.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/repeat.js +6 -22
- package/lib/commonjs/reanimated2/animation/repeat.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/sequence.js +3 -20
- package/lib/commonjs/reanimated2/animation/sequence.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/spring.js +11 -23
- package/lib/commonjs/reanimated2/animation/spring.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/styleAnimation.js +3 -35
- package/lib/commonjs/reanimated2/animation/styleAnimation.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/timing.js +0 -11
- package/lib/commonjs/reanimated2/animation/timing.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/util.js +11 -41
- package/lib/commonjs/reanimated2/animation/util.js.map +1 -1
- package/lib/commonjs/reanimated2/commonTypes.js +16 -23
- package/lib/commonjs/reanimated2/commonTypes.js.map +1 -1
- package/lib/commonjs/reanimated2/component/FlatList.js +0 -16
- package/lib/commonjs/reanimated2/component/FlatList.js.map +1 -1
- package/lib/commonjs/reanimated2/component/Image.js +0 -4
- package/lib/commonjs/reanimated2/component/Image.js.map +1 -1
- package/lib/commonjs/reanimated2/component/ScrollView.js +0 -4
- package/lib/commonjs/reanimated2/component/ScrollView.js.map +1 -1
- package/lib/commonjs/reanimated2/component/Text.js +0 -4
- package/lib/commonjs/reanimated2/component/Text.js.map +1 -1
- package/lib/commonjs/reanimated2/component/View.js +0 -4
- package/lib/commonjs/reanimated2/component/View.js.map +1 -1
- package/lib/commonjs/reanimated2/core.js +6 -48
- package/lib/commonjs/reanimated2/core.js.map +1 -1
- package/lib/commonjs/reanimated2/errors.js +3 -14
- package/lib/commonjs/reanimated2/errors.js.map +1 -1
- package/lib/commonjs/reanimated2/fabricUtils.js +3 -5
- package/lib/commonjs/reanimated2/fabricUtils.js.map +1 -1
- package/lib/commonjs/reanimated2/fabricUtils.web.js +1 -3
- package/lib/commonjs/reanimated2/fabricUtils.web.js.map +1 -1
- package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryJS.js +3 -12
- package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryJS.js.map +1 -1
- package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryUI.js +13 -17
- 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/Hooks.js +0 -5
- package/lib/commonjs/reanimated2/hook/Hooks.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/commonTypes.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/index.js +0 -12
- package/lib/commonjs/reanimated2/hook/index.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedGestureHandler.js +4 -17
- package/lib/commonjs/reanimated2/hook/useAnimatedGestureHandler.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js +2 -9
- package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedReaction.js +1 -11
- package/lib/commonjs/reanimated2/hook/useAnimatedReaction.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedRef.js +0 -12
- package/lib/commonjs/reanimated2/hook/useAnimatedRef.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedScrollHandler.js +2 -9
- package/lib/commonjs/reanimated2/hook/useAnimatedScrollHandler.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js +8 -23
- package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js +13 -71
- package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useDerivedValue.js +4 -13
- package/lib/commonjs/reanimated2/hook/useDerivedValue.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useFrameCallback.js +0 -5
- package/lib/commonjs/reanimated2/hook/useFrameCallback.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useScrollViewOffset.js +0 -7
- package/lib/commonjs/reanimated2/hook/useScrollViewOffset.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useSharedValue.js +2 -7
- package/lib/commonjs/reanimated2/hook/useSharedValue.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/utils.js +8 -39
- package/lib/commonjs/reanimated2/hook/utils.js.map +1 -1
- package/lib/commonjs/reanimated2/index.js +0 -26
- package/lib/commonjs/reanimated2/index.js.map +1 -1
- package/lib/commonjs/reanimated2/initializers.js +21 -43
- package/lib/commonjs/reanimated2/initializers.js.map +1 -1
- package/lib/commonjs/reanimated2/interpolateColor.js +6 -43
- package/lib/commonjs/reanimated2/interpolateColor.js.map +1 -1
- package/lib/commonjs/reanimated2/interpolation.js +14 -29
- package/lib/commonjs/reanimated2/interpolation.js.map +1 -1
- package/lib/commonjs/reanimated2/jestUtils.js +11 -44
- package/lib/commonjs/reanimated2/jestUtils.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js +15 -39
- package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/Mapper.js +9 -28
- package/lib/commonjs/reanimated2/js-reanimated/Mapper.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/MapperRegistry.js +7 -37
- package/lib/commonjs/reanimated2/js-reanimated/MapperRegistry.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/MutableValue.js +5 -18
- package/lib/commonjs/reanimated2/js-reanimated/MutableValue.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/global.js +2 -9
- package/lib/commonjs/reanimated2/js-reanimated/global.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/index.js +3 -14
- package/lib/commonjs/reanimated2/js-reanimated/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.js +7 -26
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js +3 -49
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/Keyframe.js +7 -43
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/Keyframe.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +4 -5
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/index.js +0 -4
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js +4 -23
- package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +3 -74
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Fade.js +3 -53
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Fade.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Flip.js +3 -63
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Flip.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +7 -26
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js +3 -13
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Roll.js +3 -23
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Rotate.js +3 -43
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Rotate.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Slide.js +3 -43
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Stretch.js +3 -23
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Stretch.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +3 -83
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/index.js +0 -20
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js +3 -22
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js +5 -29
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js +3 -9
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js +5 -11
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js +3 -8
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js +3 -12
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/index.js +0 -12
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/index.js +0 -9
- package/lib/commonjs/reanimated2/layoutReanimation/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/sharedTransitions/index.js +3 -17
- package/lib/commonjs/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -1
- package/lib/commonjs/reanimated2/mappers.js +26 -32
- package/lib/commonjs/reanimated2/mappers.js.map +1 -1
- package/lib/commonjs/reanimated2/mock.js +5 -15
- package/lib/commonjs/reanimated2/mock.js.map +1 -1
- package/lib/commonjs/reanimated2/mutables.js +2 -28
- package/lib/commonjs/reanimated2/mutables.js.map +1 -1
- package/lib/commonjs/reanimated2/platform-specific/RNRenderer.js +0 -2
- package/lib/commonjs/reanimated2/platform-specific/RNRenderer.js.map +1 -1
- package/lib/commonjs/reanimated2/platform-specific/RNRenderer.web.js.map +1 -1
- package/lib/commonjs/reanimated2/platform-specific/checkCppVersion.js +31 -0
- package/lib/commonjs/reanimated2/platform-specific/checkCppVersion.js.map +1 -0
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.web.js +0 -2
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.web.js.map +1 -1
- package/lib/commonjs/reanimated2/platform-specific/jsVersion.js +14 -0
- package/lib/commonjs/reanimated2/platform-specific/jsVersion.js.map +1 -0
- package/lib/commonjs/reanimated2/pluginUtils.js +0 -1
- package/lib/commonjs/reanimated2/pluginUtils.js.map +1 -1
- package/lib/commonjs/reanimated2/shareables.js +92 -49
- package/lib/commonjs/reanimated2/shareables.js.map +1 -1
- package/lib/commonjs/reanimated2/threads.js +42 -46
- package/lib/commonjs/reanimated2/threads.js.map +1 -1
- package/lib/commonjs/reanimated2/utils.js +0 -5
- package/lib/commonjs/reanimated2/utils.js.map +1 -1
- package/lib/commonjs/reanimated2/valueSetter.js +6 -21
- package/lib/commonjs/reanimated2/valueSetter.js.map +1 -1
- package/lib/commonjs/setAndForwardRef.js +3 -3
- package/lib/commonjs/setAndForwardRef.js.map +1 -1
- package/lib/module/Animated.js.map +1 -1
- package/lib/module/ConfigHelper.js +9 -15
- package/lib/module/ConfigHelper.js.map +1 -1
- package/lib/module/createAnimatedComponent.js +20 -139
- package/lib/module/createAnimatedComponent.js.map +1 -1
- package/lib/module/index.js +0 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.web.js.map +1 -1
- package/lib/module/reanimated2/Bezier.js +14 -33
- package/lib/module/reanimated2/Bezier.js.map +1 -1
- package/lib/module/reanimated2/Colors.js +59 -109
- package/lib/module/reanimated2/Colors.js.map +1 -1
- package/lib/module/reanimated2/Easing.js +37 -33
- package/lib/module/reanimated2/Easing.js.map +1 -1
- package/lib/module/reanimated2/NativeMethods.js +8 -15
- package/lib/module/reanimated2/NativeMethods.js.map +1 -1
- package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js +5 -27
- package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
- package/lib/module/reanimated2/NativeReanimated/index.js +0 -2
- package/lib/module/reanimated2/NativeReanimated/index.js.map +1 -1
- package/lib/module/reanimated2/PlatformChecker.js.map +1 -1
- package/lib/module/reanimated2/PropAdapters.js +12 -10
- package/lib/module/reanimated2/PropAdapters.js.map +1 -1
- package/lib/module/reanimated2/UpdateProps.js +3 -5
- package/lib/module/reanimated2/UpdateProps.js.map +1 -1
- package/lib/module/reanimated2/ViewDescriptorsSet.js +0 -6
- package/lib/module/reanimated2/ViewDescriptorsSet.js.map +1 -1
- package/lib/module/reanimated2/WorkletEventHandler.js +5 -18
- package/lib/module/reanimated2/WorkletEventHandler.js.map +1 -1
- package/lib/module/reanimated2/animation/decay.js +7 -15
- package/lib/module/reanimated2/animation/decay.js.map +1 -1
- package/lib/module/reanimated2/animation/delay.js +0 -9
- package/lib/module/reanimated2/animation/delay.js.map +1 -1
- package/lib/module/reanimated2/animation/index.js.map +1 -1
- package/lib/module/reanimated2/animation/repeat.js +6 -20
- package/lib/module/reanimated2/animation/repeat.js.map +1 -1
- package/lib/module/reanimated2/animation/sequence.js +3 -18
- package/lib/module/reanimated2/animation/sequence.js.map +1 -1
- package/lib/module/reanimated2/animation/spring.js +11 -21
- package/lib/module/reanimated2/animation/spring.js.map +1 -1
- package/lib/module/reanimated2/animation/styleAnimation.js +7 -31
- package/lib/module/reanimated2/animation/styleAnimation.js.map +1 -1
- package/lib/module/reanimated2/animation/timing.js +0 -8
- package/lib/module/reanimated2/animation/timing.js.map +1 -1
- package/lib/module/reanimated2/animation/util.js +10 -33
- package/lib/module/reanimated2/animation/util.js.map +1 -1
- package/lib/module/reanimated2/commonTypes.js +12 -19
- package/lib/module/reanimated2/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/component/FlatList.js +0 -4
- package/lib/module/reanimated2/component/FlatList.js.map +1 -1
- package/lib/module/reanimated2/component/Image.js.map +1 -1
- package/lib/module/reanimated2/component/ScrollView.js.map +1 -1
- package/lib/module/reanimated2/component/Text.js.map +1 -1
- package/lib/module/reanimated2/component/View.js.map +1 -1
- package/lib/module/reanimated2/core.js +6 -22
- package/lib/module/reanimated2/core.js.map +1 -1
- package/lib/module/reanimated2/errors.js +3 -13
- package/lib/module/reanimated2/errors.js.map +1 -1
- package/lib/module/reanimated2/fabricUtils.js +3 -3
- package/lib/module/reanimated2/fabricUtils.js.map +1 -1
- package/lib/module/reanimated2/fabricUtils.web.js +1 -1
- package/lib/module/reanimated2/fabricUtils.web.js.map +1 -1
- package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryJS.js +3 -8
- package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryJS.js.map +1 -1
- package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js +13 -15
- 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/Hooks.js +3 -2
- package/lib/module/reanimated2/hook/Hooks.js.map +1 -1
- package/lib/module/reanimated2/hook/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/hook/index.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedGestureHandler.js +3 -14
- package/lib/module/reanimated2/hook/useAnimatedGestureHandler.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedKeyboard.js +2 -5
- package/lib/module/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedReaction.js +1 -7
- package/lib/module/reanimated2/hook/useAnimatedReaction.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedRef.js +0 -6
- package/lib/module/reanimated2/hook/useAnimatedRef.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedScrollHandler.js +2 -7
- package/lib/module/reanimated2/hook/useAnimatedScrollHandler.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedSensor.js +9 -20
- package/lib/module/reanimated2/hook/useAnimatedSensor.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedStyle.js +13 -59
- package/lib/module/reanimated2/hook/useAnimatedStyle.js.map +1 -1
- package/lib/module/reanimated2/hook/useDerivedValue.js +4 -8
- package/lib/module/reanimated2/hook/useDerivedValue.js.map +1 -1
- package/lib/module/reanimated2/hook/useFrameCallback.js.map +1 -1
- package/lib/module/reanimated2/hook/useScrollViewOffset.js +0 -1
- package/lib/module/reanimated2/hook/useScrollViewOffset.js.map +1 -1
- package/lib/module/reanimated2/hook/useSharedValue.js +2 -3
- package/lib/module/reanimated2/hook/useSharedValue.js.map +1 -1
- package/lib/module/reanimated2/hook/utils.js +8 -21
- package/lib/module/reanimated2/hook/utils.js.map +1 -1
- package/lib/module/reanimated2/index.js.map +1 -1
- package/lib/module/reanimated2/initializers.js +23 -37
- package/lib/module/reanimated2/initializers.js.map +1 -1
- package/lib/module/reanimated2/interpolateColor.js +5 -34
- package/lib/module/reanimated2/interpolateColor.js.map +1 -1
- package/lib/module/reanimated2/interpolation.js +13 -28
- package/lib/module/reanimated2/interpolation.js.map +1 -1
- package/lib/module/reanimated2/jestUtils.js +11 -35
- package/lib/module/reanimated2/jestUtils.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/JSReanimated.js +15 -35
- package/lib/module/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/Mapper.js +9 -23
- package/lib/module/reanimated2/js-reanimated/Mapper.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/MapperRegistry.js +7 -35
- package/lib/module/reanimated2/js-reanimated/MapperRegistry.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/MutableValue.js +5 -16
- package/lib/module/reanimated2/js-reanimated/MutableValue.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/global.js +2 -6
- package/lib/module/reanimated2/js-reanimated/global.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/index.js +3 -9
- package/lib/module/reanimated2/js-reanimated/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.js +7 -23
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js +3 -45
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/Keyframe.js +7 -39
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/Keyframe.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +3 -3
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationsManager.js +4 -19
- package/lib/module/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +3 -52
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Fade.js +3 -32
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Fade.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Flip.js +3 -38
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Flip.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +7 -16
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js +3 -8
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js +3 -14
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Rotate.js +3 -26
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Rotate.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js +3 -26
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Stretch.js +3 -14
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Stretch.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +3 -50
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js +3 -17
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js +5 -23
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js +3 -5
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js +5 -6
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js +3 -5
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js +3 -8
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js +3 -13
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -1
- package/lib/module/reanimated2/mappers.js +26 -25
- package/lib/module/reanimated2/mappers.js.map +1 -1
- package/lib/module/reanimated2/mock.js +5 -15
- package/lib/module/reanimated2/mock.js.map +1 -1
- package/lib/module/reanimated2/mutables.js +2 -19
- package/lib/module/reanimated2/mutables.js.map +1 -1
- package/lib/module/reanimated2/platform-specific/RNRenderer.js.map +1 -1
- package/lib/module/reanimated2/platform-specific/RNRenderer.web.js.map +1 -1
- package/lib/module/reanimated2/platform-specific/checkCppVersion.js +24 -0
- package/lib/module/reanimated2/platform-specific/checkCppVersion.js.map +1 -0
- package/lib/module/reanimated2/platform-specific/checkVersion.web.js +0 -1
- package/lib/module/reanimated2/platform-specific/checkVersion.web.js.map +1 -1
- package/lib/module/reanimated2/platform-specific/jsVersion.js +7 -0
- package/lib/module/reanimated2/platform-specific/jsVersion.js.map +1 -0
- package/lib/module/reanimated2/pluginUtils.js.map +1 -1
- package/lib/module/reanimated2/shareables.js +96 -44
- package/lib/module/reanimated2/shareables.js.map +1 -1
- package/lib/module/reanimated2/threads.js +39 -33
- package/lib/module/reanimated2/threads.js.map +1 -1
- package/lib/module/reanimated2/utils.js +0 -3
- package/lib/module/reanimated2/utils.js.map +1 -1
- package/lib/module/reanimated2/valueSetter.js +6 -19
- package/lib/module/reanimated2/valueSetter.js.map +1 -1
- package/lib/module/setAndForwardRef.js +3 -2
- package/lib/module/setAndForwardRef.js.map +1 -1
- package/package.json +46 -40
- package/plugin/.eslintrc.js +7 -0
- package/plugin/README.md +241 -0
- package/plugin/build/plugin.js +714 -0
- package/plugin/build/plugin.js.map +7 -0
- package/plugin/index.js +1 -807
- package/plugin/package.json +23 -0
- package/plugin/src/buildWorkletString.ts +213 -0
- package/plugin/src/commonObjects.ts +60 -0
- package/plugin/src/injectVersion.ts +37 -0
- package/plugin/src/makeWorklet.ts +375 -0
- package/plugin/src/plugin.ts +49 -0
- package/plugin/src/processForCalleesWorklets.ts +106 -0
- package/plugin/src/processIfGestureHandlerEventCallbackFunctionNode.ts +156 -0
- package/plugin/src/processIfWorkletFunction.ts +55 -0
- package/plugin/src/processIfWorkletNode.ts +44 -0
- package/plugin/src/processInlineStylesWarning.ts +129 -0
- package/plugin/src/processWorkletObjectMethod.ts +31 -0
- package/plugin/src/types.ts +15 -0
- package/plugin/src/utils.ts +6 -0
- package/plugin/tsconfig.json +15 -0
- package/plugin/yarn.lock +2193 -0
- package/react-native-reanimated.d.ts +1 -0
- package/scripts/reanimated_utils.rb +2 -2
- package/src/createAnimatedComponent.tsx +2 -3
- package/src/reanimated2/Easing.ts +19 -0
- package/src/reanimated2/NativeMethods.ts +9 -4
- package/src/reanimated2/NativeReanimated/NativeReanimated.ts +2 -2
- package/src/reanimated2/UpdateProps.ts +2 -2
- package/src/reanimated2/animation/decay.ts +7 -1
- package/src/reanimated2/animation/styleAnimation.ts +5 -1
- package/src/reanimated2/core.ts +4 -4
- package/src/reanimated2/errors.ts +1 -0
- package/src/reanimated2/frameCallback/FrameCallbackRegistryUI.ts +12 -4
- package/src/reanimated2/globals.d.ts +71 -112
- package/src/reanimated2/hook/commonTypes.ts +1 -1
- package/src/reanimated2/hook/useAnimatedReaction.ts +2 -2
- package/src/reanimated2/hook/useAnimatedSensor.ts +2 -2
- package/src/reanimated2/initializers.ts +11 -8
- package/src/reanimated2/jestUtils.ts +0 -1
- package/src/reanimated2/js-reanimated/JSReanimated.ts +5 -1
- package/src/reanimated2/js-reanimated/index.ts +1 -1
- package/src/reanimated2/mappers.ts +26 -4
- package/src/reanimated2/mock.ts +1 -0
- package/src/reanimated2/platform-specific/checkCppVersion.ts +29 -0
- package/src/reanimated2/platform-specific/jsVersion.ts +6 -0
- package/src/reanimated2/shareables.ts +107 -8
- package/src/reanimated2/threads.ts +36 -17
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.js +0 -42
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.js.map +0 -1
- package/lib/module/reanimated2/platform-specific/checkVersion.js +0 -35
- package/lib/module/reanimated2/platform-specific/checkVersion.js.map +0 -1
- package/src/reanimated2/platform-specific/checkVersion.ts +0 -39
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["USE_STUB_IMPLEMENTATION","shouldBeUseWeb","_shareableCache","WeakMap","_shareableFlag","Symbol","MAGIC_KEY","isHostObject","value","registerShareableMapping","shareable","shareableRef","set","makeShareableCloneRecursive","shouldPersistRemote","type","cached","get","undefined","toAdapt","Array","isArray","map","element","__workletHash","__DEV__","registerWorkletStackDetails","__stackDetails","__initData","key","Object","entries","freeze","adopted","NativeReanimatedModule","makeShareableClone","makeShareableCloneOnUIRecursive","cloneRecursive","_makeShareableClone","makeShareable","handle","__init"],"sources":["shareables.ts"],"sourcesContent":["import NativeReanimatedModule from './NativeReanimated';\nimport { ShareableRef } from './commonTypes';\nimport { shouldBeUseWeb } from './PlatformChecker';\nimport { registerWorkletStackDetails } from './errors';\n\n// for web/chrome debugger/jest environments this file provides a stub implementation\n// where no shareable references are used. Instead, the objects themselves are used\n// instead of shareable references, because of the fact that we don't have to deal with\n// runnning the code on separate VMs.\nconst USE_STUB_IMPLEMENTATION = shouldBeUseWeb();\n\nconst _shareableCache = new WeakMap<\n Record<string, unknown>,\n ShareableRef<any> | symbol\n>();\n// the below symbol is used to represent a mapping from the value to itself\n// this is used to allow for a converted shareable to be passed to makeShareableClone\nconst _shareableFlag = Symbol('shareable flag');\n\nconst MAGIC_KEY = 'REANIMATED_MAGIC_KEY';\n\nfunction isHostObject(value: any): boolean {\n // We could use JSI to determine whether an object is a host object, however\n // the below workaround works well and is way faster than an additional JSI call.\n // We use the fact that host objects have broken implementation of `hasOwnProperty`\n // and hence return true for all `in` checks regardless of the key we ask for.\n return MAGIC_KEY in value;\n}\n\nexport function registerShareableMapping(\n shareable: any,\n shareableRef?: ShareableRef<any>\n): void {\n if (USE_STUB_IMPLEMENTATION) {\n return;\n }\n _shareableCache.set(shareable, shareableRef || _shareableFlag);\n}\n\nexport function makeShareableCloneRecursive<T>(\n value: any,\n shouldPersistRemote = false\n): ShareableRef<T> {\n if (USE_STUB_IMPLEMENTATION) {\n return value;\n }\n // This one actually may be worth to be moved to c++, we also need similar logic to run on the UI thread\n const type = typeof value;\n if ((type === 'object' || type === 'function') && value !== null) {\n const cached = _shareableCache.get(value);\n if (cached === _shareableFlag) {\n return value;\n } else if (cached !== undefined) {\n return cached as ShareableRef<T>;\n } else {\n let toAdapt: any;\n if (Array.isArray(value)) {\n toAdapt = value.map((element) => makeShareableCloneRecursive(element));\n } else if (type === 'function' && value.__workletHash === undefined) {\n // this is a remote function\n toAdapt = value;\n } else if (isHostObject(value)) {\n // for host objects we pass the reference to the object as shareable and\n // then recreate new host object wrapping the same instance on the UI thread.\n // there is no point of iterating over keys as we do for regular objects.\n toAdapt = value;\n } else {\n toAdapt = {};\n if (value.__workletHash !== undefined) {\n // we are converting a worklet\n if (__DEV__) {\n registerWorkletStackDetails(\n value.__workletHash,\n value.__stackDetails\n );\n delete value.__stackDetails;\n }\n // to save on transferring static __initData field of worklet structure\n // we request shareable value to persist its UI counterpart. This means\n // that the __initData field that contains long strings represeting the\n // worklet code, source map, and location, will always be\n // serialized/deserialized once.\n toAdapt.__initData = makeShareableCloneRecursive(\n value.__initData,\n true\n );\n delete value.__initData;\n }\n\n for (const [key, element] of Object.entries(value)) {\n toAdapt[key] = makeShareableCloneRecursive(element);\n }\n }\n if (__DEV__) {\n // we freeze objects that are transformed to shareable. This should help\n // detect issues when someone modifies data after it's been converted to\n // shareable. Meaning that they may be doing a faulty assumption in their\n // code expecting that the updates are going to automatically populate to\n // the object sent to the UI thread. If the user really wants some objects\n // to be mutable they should use shared values instead.\n Object.freeze(value);\n }\n const adopted = NativeReanimatedModule.makeShareableClone(\n toAdapt,\n shouldPersistRemote\n );\n _shareableCache.set(value, adopted);\n _shareableCache.set(adopted, _shareableFlag);\n return adopted;\n }\n }\n return NativeReanimatedModule.makeShareableClone(value, shouldPersistRemote);\n}\n\nexport function makeShareableCloneOnUIRecursive<T>(value: T): ShareableRef<T> {\n 'worklet';\n if (USE_STUB_IMPLEMENTATION) {\n // @ts-ignore web is an interesting place where we don't run a secondary VM on the UI thread\n // see more details in the comment where USE_STUB_IMPLEMENTATION is defined.\n return value;\n }\n function cloneRecursive<T>(value: T): ShareableRef<T> {\n const type = typeof value;\n if ((type === 'object' || type === 'function') && value !== null) {\n let toAdapt: any;\n if (Array.isArray(value)) {\n toAdapt = value.map((element) => cloneRecursive(element));\n } else {\n toAdapt = {};\n for (const [key, element] of Object.entries(value)) {\n toAdapt[key] = cloneRecursive(element);\n }\n }\n if (__DEV__) {\n // See the reasoning behind freezing in the other comment above.\n Object.freeze(value);\n }\n return _makeShareableClone(toAdapt);\n }\n return _makeShareableClone(value);\n }\n return cloneRecursive(value);\n}\n\nexport function makeShareable<T>(value: T): T {\n if (USE_STUB_IMPLEMENTATION) {\n return value;\n }\n const handle = makeShareableCloneRecursive({\n __init: () => {\n 'worklet';\n return value;\n },\n });\n registerShareableMapping(value, handle);\n return value;\n}\n"],"mappings":";;;;;;;;;;AAAA;;AAEA;;AACA;;;;AAEA;AACA;AACA;AACA;AACA,MAAMA,uBAAuB,GAAG,IAAAC,+BAAA,GAAhC;;AAEA,MAAMC,eAAe,GAAG,IAAIC,OAAJ,EAAxB,C,CAIA;AACA;;;AACA,MAAMC,cAAc,GAAGC,MAAM,CAAC,gBAAD,CAA7B;;AAEA,MAAMC,SAAS,GAAG,sBAAlB;;AAEA,SAASC,YAAT,CAAsBC,KAAtB,EAA2C;EACzC;EACA;EACA;EACA;EACA,OAAOF,SAAS,IAAIE,KAApB;AACD;;AAEM,SAASC,wBAAT,CACLC,SADK,EAELC,YAFK,EAGC;EACN,IAAIX,uBAAJ,EAA6B;IAC3B;EACD;;EACDE,eAAe,CAACU,GAAhB,CAAoBF,SAApB,EAA+BC,YAAY,IAAIP,cAA/C;AACD;;AAEM,SAASS,2BAAT,CACLL,KADK,EAGY;EAAA,IADjBM,mBACiB,uEADK,KACL;;EACjB,IAAId,uBAAJ,EAA6B;IAC3B,OAAOQ,KAAP;EACD,CAHgB,CAIjB;;;EACA,MAAMO,IAAI,GAAG,OAAOP,KAApB;;EACA,IAAI,CAACO,IAAI,KAAK,QAAT,IAAqBA,IAAI,KAAK,UAA/B,KAA8CP,KAAK,KAAK,IAA5D,EAAkE;IAChE,MAAMQ,MAAM,GAAGd,eAAe,CAACe,GAAhB,CAAoBT,KAApB,CAAf;;IACA,IAAIQ,MAAM,KAAKZ,cAAf,EAA+B;MAC7B,OAAOI,KAAP;IACD,CAFD,MAEO,IAAIQ,MAAM,KAAKE,SAAf,EAA0B;MAC/B,OAAOF,MAAP;IACD,CAFM,MAEA;MACL,IAAIG,OAAJ;;MACA,IAAIC,KAAK,CAACC,OAAN,CAAcb,KAAd,CAAJ,EAA0B;QACxBW,OAAO,GAAGX,KAAK,CAACc,GAAN,CAAWC,OAAD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
|
1
|
+
{"version":3,"names":["_NativeReanimated","_interopRequireDefault","require","_PlatformChecker","_errors","_jsVersion","obj","__esModule","default","USE_STUB_IMPLEMENTATION","shouldBeUseWeb","_shareableCache","WeakMap","_shareableFlag","Symbol","MAGIC_KEY","isHostObject","value","registerShareableMapping","shareable","shareableRef","set","isPlainJSObject","object","Object","getPrototypeOf","prototype","INACCESSIBLE_OBJECT","__init","Proxy","get","_","prop","Error","DETECT_CYCLIC_OBJECT_DEPTH_THRESHOLD","processedObjectAtThresholdDepth","didShowPluginVersionMismatchError","makeShareableCloneRecursive","shouldPersistRemote","arguments","length","undefined","depth","type","isTypeObject","isTypeFunction","cached","toAdapt","Array","isArray","map","element","__workletHash","__DEV__","__version","jsVersion","console","error","registerWorkletStackDetails","__stackDetails","__initData","key","entries","inaccessibleObject","freeze","adopted","NativeReanimatedModule","makeShareableClone","makeShareableCloneOnUIRecursive","cloneRecursive","_makeShareableClone","makeShareable","handle"],"sources":["shareables.ts"],"sourcesContent":["import NativeReanimatedModule from './NativeReanimated';\nimport { ShareableRef } from './commonTypes';\nimport { shouldBeUseWeb } from './PlatformChecker';\nimport { registerWorkletStackDetails } from './errors';\nimport { jsVersion } from './platform-specific/jsVersion';\n\n// for web/chrome debugger/jest environments this file provides a stub implementation\n// where no shareable references are used. Instead, the objects themselves are used\n// instead of shareable references, because of the fact that we don't have to deal with\n// runnning the code on separate VMs.\nconst USE_STUB_IMPLEMENTATION = shouldBeUseWeb();\n\nconst _shareableCache = new WeakMap<\n Record<string, unknown>,\n ShareableRef<any> | symbol\n>();\n// the below symbol is used to represent a mapping from the value to itself\n// this is used to allow for a converted shareable to be passed to makeShareableClone\nconst _shareableFlag = Symbol('shareable flag');\n\nconst MAGIC_KEY = 'REANIMATED_MAGIC_KEY';\n\nfunction isHostObject(value: any): boolean {\n // We could use JSI to determine whether an object is a host object, however\n // the below workaround works well and is way faster than an additional JSI call.\n // We use the fact that host objects have broken implementation of `hasOwnProperty`\n // and hence return true for all `in` checks regardless of the key we ask for.\n return MAGIC_KEY in value;\n}\n\nexport function registerShareableMapping(\n shareable: any,\n shareableRef?: ShareableRef<any>\n): void {\n if (USE_STUB_IMPLEMENTATION) {\n return;\n }\n _shareableCache.set(shareable, shareableRef || _shareableFlag);\n}\n\nfunction isPlainJSObject(object: object) {\n return Object.getPrototypeOf(object) === Object.prototype;\n}\n\n// The below object is used as a replacement for objects that cannot be transferred\n// as shareable values. In makeShareableCloneRecursive we detect if an object is of\n// a plain Object.prototype and only allow such objects to be transferred. This lets\n// us avoid all sorts of react internals from leaking into the UI runtime. To make it\n// possible to catch errors when someone actually tries to access such object on the UI\n// runtime, we use the below Proxy object which is instantiated on the UI runtime and\n// throws whenever someone tries to access its fields.\nconst INACCESSIBLE_OBJECT = {\n __init: () => {\n 'worklet';\n return new Proxy(\n {},\n {\n get: (_: any, prop: string) => {\n if (prop === '_isReanimatedSharedValue') {\n // not very happy about this check here, but we need to allow for\n // \"inaccessible\" objects to be tested with isSharedValue check\n // as it is being used in the mappers when extracing inputs recursively.\n // Apparently we can't check if a key exists there as HostObjects always\n // return true for such tests, so the only possibility for us is to\n // actually access that key and see if it is set to true. We therefore\n // need to allow for this key to be accessed here.\n return false;\n }\n throw new Error(\n `Trying to access property \\`${prop}\\` of an object which cannot be sent to the UI runtime.`\n );\n },\n set: () => {\n throw new Error(\n 'Trying to write to an object which cannot be sent to the UI runtime.'\n );\n },\n }\n );\n },\n};\n\nconst DETECT_CYCLIC_OBJECT_DEPTH_THRESHOLD = 30;\n// Below variable stores object that we process in makeShareableCloneRecursive at the specified depth.\n// We use it to check if later on the function reenters with the same object\nlet processedObjectAtThresholdDepth: any;\n\n// We only want to show mismatch error once so we use this flag to track it\nlet didShowPluginVersionMismatchError = false;\n\nexport function makeShareableCloneRecursive<T>(\n value: any,\n shouldPersistRemote = false,\n depth = 0\n): ShareableRef<T> {\n if (USE_STUB_IMPLEMENTATION) {\n return value;\n }\n if (depth >= DETECT_CYCLIC_OBJECT_DEPTH_THRESHOLD) {\n // if we reach certain recursion depth we suspect that we are dealing with a cyclic object.\n // this type of objects are not supported and cannot be trasferred as shareable, so we\n // implement a simple detection mechanism that remembers the value at a given depth and\n // tests whether we try reenter this method later on with the same value. If that happens\n // we throw an appropriate error.\n if (depth === DETECT_CYCLIC_OBJECT_DEPTH_THRESHOLD) {\n processedObjectAtThresholdDepth = value;\n } else if (value === processedObjectAtThresholdDepth) {\n throw new Error(\n 'Trying to convert a cyclic object to a shareable. This is not supported.'\n );\n }\n } else {\n processedObjectAtThresholdDepth = undefined;\n }\n // This one actually may be worth to be moved to c++, we also need similar logic to run on the UI thread\n const type = typeof value;\n const isTypeObject = type === 'object';\n const isTypeFunction = type === 'function';\n if ((isTypeObject || isTypeFunction) && value !== null) {\n const cached = _shareableCache.get(value);\n if (cached === _shareableFlag) {\n return value;\n } else if (cached !== undefined) {\n return cached as ShareableRef<T>;\n } else {\n let toAdapt: any;\n if (Array.isArray(value)) {\n toAdapt = value.map((element) =>\n makeShareableCloneRecursive(element, shouldPersistRemote, depth + 1)\n );\n } else if (isTypeFunction && value.__workletHash === undefined) {\n // this is a remote function\n toAdapt = value;\n } else if (isHostObject(value)) {\n // for host objects we pass the reference to the object as shareable and\n // then recreate new host object wrapping the same instance on the UI thread.\n // there is no point of iterating over keys as we do for regular objects.\n toAdapt = value;\n } else if (isPlainJSObject(value) || isTypeFunction) {\n toAdapt = {};\n if (value.__workletHash !== undefined) {\n // we are converting a worklet\n if (__DEV__) {\n if (\n // We don't want this error to be logged more than once.\n !didShowPluginVersionMismatchError &&\n value.__version !== jsVersion\n ) {\n didShowPluginVersionMismatchError = true;\n console.error(`[Reanimated] Mismatch between JavaScript code version and Reanimated Babel plugin version (${jsVersion} vs. ${value.__version}). Please clear your Metro bundler cache with \\`yarn start --reset-cache\\`,\n \\`npm start -- --reset-cache\\` or \\`expo start -c\\` and run the app again.`);\n }\n registerWorkletStackDetails(\n value.__workletHash,\n value.__stackDetails\n );\n delete value.__stackDetails;\n }\n // to save on transferring static __initData field of worklet structure\n // we request shareable value to persist its UI counterpart. This means\n // that the __initData field that contains long strings represeting the\n // worklet code, source map, and location, will always be\n // serialized/deserialized once. We don't increase depth when calling\n // this method as these objects have one level anyways.\n toAdapt.__initData = makeShareableCloneRecursive(\n value.__initData,\n true\n );\n delete value.__initData;\n }\n\n for (const [key, element] of Object.entries(value)) {\n toAdapt[key] = makeShareableCloneRecursive(\n element,\n shouldPersistRemote,\n depth + 1\n );\n }\n } else {\n // This is reached for object types that are not of plain Object.prototype.\n // We don't support such objects from being transferred as shareables to\n // the UI runtime and hence we replace them with \"inaccessible object\"\n // which is implemented as a Proxy object that throws on any attempt\n // of accessing its fields. We argue that such objects can sometimes leak\n // as attributes of objects being captured by worklets but should never\n // be used on the UI runtime regardless. If they are being accessed, the user\n // will get an appropriate error message.\n const inaccessibleObject =\n makeShareableCloneRecursive<T>(INACCESSIBLE_OBJECT);\n _shareableCache.set(value, inaccessibleObject);\n return inaccessibleObject;\n }\n if (__DEV__) {\n // we freeze objects that are transformed to shareable. This should help\n // detect issues when someone modifies data after it's been converted to\n // shareable. Meaning that they may be doing a faulty assumption in their\n // code expecting that the updates are going to automatically populate to\n // the object sent to the UI thread. If the user really wants some objects\n // to be mutable they should use shared values instead.\n Object.freeze(value);\n }\n const adopted = NativeReanimatedModule.makeShareableClone(\n toAdapt,\n shouldPersistRemote\n );\n _shareableCache.set(value, adopted);\n _shareableCache.set(adopted, _shareableFlag);\n return adopted;\n }\n }\n return NativeReanimatedModule.makeShareableClone(value, shouldPersistRemote);\n}\n\nexport function makeShareableCloneOnUIRecursive<T>(value: T): ShareableRef<T> {\n 'worklet';\n if (USE_STUB_IMPLEMENTATION) {\n // @ts-ignore web is an interesting place where we don't run a secondary VM on the UI thread\n // see more details in the comment where USE_STUB_IMPLEMENTATION is defined.\n return value;\n }\n function cloneRecursive<T>(value: T): ShareableRef<T> {\n const type = typeof value;\n if ((type === 'object' || type === 'function') && value !== null) {\n let toAdapt: any;\n if (Array.isArray(value)) {\n toAdapt = value.map((element) => cloneRecursive(element));\n } else if (value !== undefined) {\n toAdapt = {};\n for (const [key, element] of Object.entries(value)) {\n toAdapt[key] = cloneRecursive(element);\n }\n }\n if (__DEV__) {\n // See the reasoning behind freezing in the other comment above.\n Object.freeze(value);\n }\n return _makeShareableClone(toAdapt);\n }\n return _makeShareableClone(value);\n }\n return cloneRecursive(value);\n}\n\nexport function makeShareable<T>(value: T): T {\n if (USE_STUB_IMPLEMENTATION) {\n return value;\n }\n const handle = makeShareableCloneRecursive({\n __init: () => {\n 'worklet';\n return value;\n },\n });\n registerShareableMapping(value, handle);\n return value;\n}\n"],"mappings":";;;;;;;;;AAAA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AAA0D,SAAAD,uBAAAK,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAE1D;AACA;AACA;AACA;AACA,MAAMG,uBAAuB,GAAG,IAAAC,+BAAc,GAAE;AAEhD,MAAMC,eAAe,GAAG,IAAIC,OAAO,EAGhC;AACH;AACA;AACA,MAAMC,cAAc,GAAGC,MAAM,CAAC,gBAAgB,CAAC;AAE/C,MAAMC,SAAS,GAAG,sBAAsB;AAExC,SAASC,YAAYA,CAACC,KAAU,EAAW;EACzC;EACA;EACA;EACA;EACA,OAAOF,SAAS,IAAIE,KAAK;AAC3B;AAEO,SAASC,wBAAwBA,CACtCC,SAAc,EACdC,YAAgC,EAC1B;EACN,IAAIX,uBAAuB,EAAE;IAC3B;EACF;EACAE,eAAe,CAACU,GAAG,CAACF,SAAS,EAAEC,YAAY,IAAIP,cAAc,CAAC;AAChE;AAEA,SAASS,eAAeA,CAACC,MAAc,EAAE;EACvC,OAAOC,MAAM,CAACC,cAAc,CAACF,MAA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
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.callMicrotasks = void 0;
|
|
7
7
|
exports.runOnJS = runOnJS;
|
|
8
8
|
exports.runOnUI = runOnUI;
|
|
9
9
|
exports.runOnUIImmediately = runOnUIImmediately;
|
|
10
|
-
exports.
|
|
11
|
-
|
|
10
|
+
exports.setupMicrotasks = setupMicrotasks;
|
|
12
11
|
var _NativeReanimated = _interopRequireDefault(require("./NativeReanimated"));
|
|
13
|
-
|
|
14
12
|
var _PlatformChecker = require("./PlatformChecker");
|
|
15
|
-
|
|
16
13
|
var _shareables = require("./shareables");
|
|
17
|
-
|
|
18
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
-
|
|
20
15
|
const IS_JEST = (0, _PlatformChecker.isJest)();
|
|
21
16
|
const IS_WEB = (0, _PlatformChecker.shouldBeUseWeb)();
|
|
22
17
|
let _runOnUIQueue = [];
|
|
23
|
-
|
|
24
|
-
function setupSetImmediate() {
|
|
18
|
+
function setupMicrotasks() {
|
|
25
19
|
'worklet';
|
|
26
20
|
|
|
27
|
-
let
|
|
21
|
+
let microtasksQueue = [];
|
|
22
|
+
let isExecutingMicrotasksQueue = false;
|
|
28
23
|
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
// @ts-ignore – typescript expects this to conform to NodeJS definition and expects the return value to be NodeJS.Immediate which is an object and not a number
|
|
25
|
+
global.queueMicrotask = callback => {
|
|
26
|
+
microtasksQueue.push(callback);
|
|
31
27
|
return -1;
|
|
32
28
|
};
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
29
|
+
global.__callMicrotasks = () => {
|
|
30
|
+
if (isExecutingMicrotasksQueue) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
isExecutingMicrotasksQueue = true;
|
|
35
|
+
for (let index = 0; index < microtasksQueue.length; index += 1) {
|
|
36
|
+
// we use classic 'for' loop because the size of the currentTasks array may change while executing some of the callbacks due to queueMicrotask calls
|
|
37
|
+
microtasksQueue[index]();
|
|
38
|
+
}
|
|
39
|
+
microtasksQueue = [];
|
|
40
|
+
global._maybeFlushUIUpdatesQueue();
|
|
41
|
+
} finally {
|
|
42
|
+
isExecutingMicrotasksQueue = false;
|
|
38
43
|
}
|
|
39
|
-
|
|
40
|
-
immediateCallbacks = [];
|
|
41
44
|
};
|
|
42
45
|
}
|
|
43
|
-
|
|
44
|
-
function flushImmediatesOnUIThread() {
|
|
46
|
+
function callMicrotasksOnUIThread() {
|
|
45
47
|
'worklet';
|
|
46
48
|
|
|
47
|
-
global.
|
|
49
|
+
global.__callMicrotasks();
|
|
48
50
|
}
|
|
51
|
+
const callMicrotasks = (0, _PlatformChecker.shouldBeUseWeb)() ? () => {
|
|
52
|
+
// on web flushing is a noop as immediates are handled by the browser
|
|
53
|
+
} : callMicrotasksOnUIThread;
|
|
49
54
|
|
|
50
|
-
const flushImmediates = (0, _PlatformChecker.shouldBeUseWeb)() ? () => {// on web flushing is a noop as immediates are handled by the browser
|
|
51
|
-
} : flushImmediatesOnUIThread;
|
|
52
55
|
/**
|
|
53
56
|
* Schedule a worklet to execute on the UI runtime. This method does not schedule the work immediately but instead
|
|
54
|
-
* waits for other worklets to be scheduled within the same JS loop. It uses
|
|
57
|
+
* waits for other worklets to be scheduled within the same JS loop. It uses queueMicrotask to schedule all the worklets
|
|
55
58
|
* at once making sure they will run within the same frame boundaries on the UI thread.
|
|
56
59
|
*/
|
|
57
|
-
|
|
58
|
-
exports.flushImmediates = flushImmediates;
|
|
59
|
-
|
|
60
|
+
exports.callMicrotasks = callMicrotasks;
|
|
60
61
|
function runOnUI(worklet) {
|
|
61
62
|
if (__DEV__ && !IS_WEB && worklet.__workletHash === undefined) {
|
|
62
63
|
throw new Error('runOnUI() can only be used on worklets');
|
|
63
64
|
}
|
|
64
|
-
|
|
65
65
|
return function () {
|
|
66
66
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
67
67
|
args[_key] = arguments[_key];
|
|
68
68
|
}
|
|
69
|
-
|
|
70
69
|
if (IS_JEST) {
|
|
71
|
-
// Mocking time in Jest is tricky as both requestAnimationFrame and
|
|
70
|
+
// Mocking time in Jest is tricky as both requestAnimationFrame and queueMicrotask
|
|
72
71
|
// callbacks run on the same queue and can be interleaved. There is no way
|
|
73
72
|
// to flush particular queue in Jest and the only control over mocked timers
|
|
74
73
|
// is by using jest.advanceTimersByTime() method which advances all types
|
|
@@ -82,17 +81,22 @@ function runOnUI(worklet) {
|
|
|
82
81
|
|
|
83
82
|
worklet(...args);
|
|
84
83
|
}));
|
|
85
|
-
|
|
86
84
|
return;
|
|
87
85
|
}
|
|
88
|
-
|
|
86
|
+
if (__DEV__) {
|
|
87
|
+
// in DEV mode we call shareable conversion here because in case the object
|
|
88
|
+
// can't be converted, we will get a meaningful stack-trace as opposed to the
|
|
89
|
+
// situation when conversion is only done via microtask queue. This does not
|
|
90
|
+
// make the app particularily less efficient as converted objects are cached
|
|
91
|
+
// and for a given worklet the conversion only happens once.
|
|
92
|
+
(0, _shareables.makeShareableCloneRecursive)(worklet);
|
|
93
|
+
(0, _shareables.makeShareableCloneRecursive)(args);
|
|
94
|
+
}
|
|
89
95
|
_runOnUIQueue.push([worklet, args]);
|
|
90
|
-
|
|
91
96
|
if (_runOnUIQueue.length === 1) {
|
|
92
|
-
|
|
97
|
+
queueMicrotask(() => {
|
|
93
98
|
const queue = _runOnUIQueue;
|
|
94
99
|
_runOnUIQueue = [];
|
|
95
|
-
|
|
96
100
|
_NativeReanimated.default.scheduleOnUI((0, _shareables.makeShareableCloneRecursive)(() => {
|
|
97
101
|
'worklet';
|
|
98
102
|
|
|
@@ -100,27 +104,24 @@ function runOnUI(worklet) {
|
|
|
100
104
|
let [worklet, args] = _ref;
|
|
101
105
|
worklet(...args);
|
|
102
106
|
});
|
|
103
|
-
|
|
107
|
+
callMicrotasks();
|
|
104
108
|
}));
|
|
105
109
|
});
|
|
106
110
|
}
|
|
107
111
|
};
|
|
108
112
|
}
|
|
113
|
+
|
|
109
114
|
/**
|
|
110
115
|
* Schedule a worklet to execute on the UI runtime skipping batching mechanism.
|
|
111
116
|
*/
|
|
112
|
-
|
|
113
|
-
|
|
114
117
|
function runOnUIImmediately(worklet) {
|
|
115
118
|
if (__DEV__ && !IS_WEB && worklet.__workletHash === undefined) {
|
|
116
119
|
throw new Error('runOnUI() can only be used on worklets');
|
|
117
120
|
}
|
|
118
|
-
|
|
119
121
|
return function () {
|
|
120
122
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
121
123
|
args[_key2] = arguments[_key2];
|
|
122
124
|
}
|
|
123
|
-
|
|
124
125
|
_NativeReanimated.default.scheduleOnUI((0, _shareables.makeShareableCloneRecursive)(() => {
|
|
125
126
|
'worklet';
|
|
126
127
|
|
|
@@ -128,7 +129,6 @@ function runOnUIImmediately(worklet) {
|
|
|
128
129
|
}));
|
|
129
130
|
};
|
|
130
131
|
}
|
|
131
|
-
|
|
132
132
|
if (__DEV__) {
|
|
133
133
|
try {
|
|
134
134
|
runOnUI(() => {
|
|
@@ -138,7 +138,6 @@ if (__DEV__) {
|
|
|
138
138
|
throw new Error('Failed to create a worklet. Did you forget to add Reanimated Babel plugin in babel.config.js? See installation docs at https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation#babel-plugin.');
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
|
-
|
|
142
141
|
function runOnJS(fun) {
|
|
143
142
|
'worklet';
|
|
144
143
|
|
|
@@ -149,16 +148,13 @@ function runOnJS(fun) {
|
|
|
149
148
|
// reference to the original remote function in the `__remoteFunction` property.
|
|
150
149
|
fun = fun.__remoteFunction;
|
|
151
150
|
}
|
|
152
|
-
|
|
153
151
|
if (!_WORKLET) {
|
|
154
152
|
return fun;
|
|
155
153
|
}
|
|
156
|
-
|
|
157
154
|
return function () {
|
|
158
155
|
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
159
156
|
args[_key3] = arguments[_key3];
|
|
160
157
|
}
|
|
161
|
-
|
|
162
158
|
_scheduleOnJS(fun, args.length > 0 ? (0, _shareables.makeShareableCloneOnUIRecursive)(args) : undefined);
|
|
163
159
|
};
|
|
164
160
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["IS_JEST","isJest","IS_WEB","shouldBeUseWeb","_runOnUIQueue","setupSetImmediate","immediateCallbacks","global","setImmediate","callback","push","__flushImmediates","index","length","flushImmediatesOnUIThread","flushImmediates","runOnUI","worklet","__DEV__","__workletHash","undefined","Error","args","NativeReanimatedModule","scheduleOnUI","makeShareableCloneRecursive","queue","forEach","runOnUIImmediately","e","runOnJS","fun","__remoteFunction","_WORKLET","_scheduleOnJS","makeShareableCloneOnUIRecursive"],"sources":["threads.ts"],"sourcesContent":["import NativeReanimatedModule from './NativeReanimated';\nimport { isJest, shouldBeUseWeb } from './PlatformChecker';\nimport { ComplexWorkletFunction } from './commonTypes';\nimport {\n makeShareableCloneOnUIRecursive,\n makeShareableCloneRecursive,\n} from './shareables';\n\nconst IS_JEST = isJest();\nconst IS_WEB = shouldBeUseWeb();\n\nlet _runOnUIQueue: Array<[ComplexWorkletFunction<any[], any>, any[]]> = [];\n\nexport function setupSetImmediate() {\n 'worklet';\n\n let immediateCallbacks: Array<() => void> = [];\n\n // @ts-ignore – typescript expects this to conform to NodeJS definition and expects the return value to be NodeJS.Immediate which is an object and not a number\n global.setImmediate = (callback: () => void): number => {\n immediateCallbacks.push(callback);\n return -1;\n };\n\n global.__flushImmediates = () => {\n for (let index = 0; index < immediateCallbacks.length; index += 1) {\n // we use classic 'for' loop because the size of the currentTasks array may change while executing some of the callbacks due to setImmediate calls\n immediateCallbacks[index]();\n }\n immediateCallbacks = [];\n };\n}\n\nfunction flushImmediatesOnUIThread() {\n 'worklet';\n global.__flushImmediates();\n}\n\nexport const flushImmediates = shouldBeUseWeb()\n ? () => {\n // on web flushing is a noop as immediates are handled by the browser\n }\n : flushImmediatesOnUIThread;\n\n/**\n * Schedule a worklet to execute on the UI runtime. This method does not schedule the work immediately but instead\n * waits for other worklets to be scheduled within the same JS loop. It uses setImmediate to schedule all the worklets\n * at once making sure they will run within the same frame boundaries on the UI thread.\n */\nexport function runOnUI<A extends any[], R>(\n worklet: ComplexWorkletFunction<A, R>\n): (...args: A) => void {\n if (__DEV__ && !IS_WEB && worklet.__workletHash === undefined) {\n throw new Error('runOnUI() can only be used on worklets');\n }\n return (...args) => {\n if (IS_JEST) {\n // Mocking time in Jest is tricky as both requestAnimationFrame and setImmediate\n // callbacks run on the same queue and can be interleaved. There is no way\n // to flush particular queue in Jest and the only control over mocked timers\n // is by using jest.advanceTimersByTime() method which advances all types\n // of timers including immediate and animation callbacks. Ideally we'd like\n // to have some way here to schedule work along with React updates, but\n // that's not possible, and hence in Jest environment instead of using scheduling\n // mechanism we just schedule the work ommiting the queue. This is ok for the\n // uses that we currently have but may not be ok for future tests that we write.\n NativeReanimatedModule.scheduleOnUI(\n makeShareableCloneRecursive(() => {\n 'worklet';\n worklet(...args);\n })\n );\n return;\n }\n _runOnUIQueue.push([worklet, args]);\n if (_runOnUIQueue.length === 1) {\n setImmediate(() => {\n const queue = _runOnUIQueue;\n _runOnUIQueue = [];\n NativeReanimatedModule.scheduleOnUI(\n makeShareableCloneRecursive(() => {\n 'worklet';\n queue.forEach(([worklet, args]) => {\n worklet(...args);\n });\n flushImmediates();\n })\n );\n });\n }\n };\n}\n\n/**\n * Schedule a worklet to execute on the UI runtime skipping batching mechanism.\n */\nexport function runOnUIImmediately<A extends any[], R>(\n worklet: ComplexWorkletFunction<A, R>\n): (...args: A) => void {\n if (__DEV__ && !IS_WEB && worklet.__workletHash === undefined) {\n throw new Error('runOnUI() can only be used on worklets');\n }\n return (...args) => {\n NativeReanimatedModule.scheduleOnUI(\n makeShareableCloneRecursive(() => {\n 'worklet';\n worklet(...args);\n })\n );\n };\n}\n\nif (__DEV__) {\n try {\n runOnUI(() => {\n 'worklet';\n });\n } catch (e) {\n throw new Error(\n 'Failed to create a worklet. Did you forget to add Reanimated Babel plugin in babel.config.js? See installation docs at https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation#babel-plugin.'\n );\n }\n}\n\nexport function runOnJS<A extends any[], R>(\n fun: ComplexWorkletFunction<A, R>\n): (...args: A) => void {\n 'worklet';\n if (fun.__remoteFunction) {\n // in development mode the function provided as `fun` throws an error message\n // such that when someone accidently calls it directly on the UI runtime, they\n // see that they should use `runOnJS` instead. To facilitate that we purt the\n // reference to the original remote function in the `__remoteFunction` property.\n fun = fun.__remoteFunction;\n }\n if (!_WORKLET) {\n return fun;\n }\n return (...args) => {\n _scheduleOnJS(\n fun,\n args.length > 0 ? makeShareableCloneOnUIRecursive(args) : undefined\n );\n };\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AAEA;;;;AAKA,MAAMA,OAAO,GAAG,IAAAC,uBAAA,GAAhB;AACA,MAAMC,MAAM,GAAG,IAAAC,+BAAA,GAAf;AAEA,IAAIC,aAAiE,GAAG,EAAxE;;AAEO,SAASC,iBAAT,GAA6B;EAClC;;EAEA,IAAIC,kBAAqC,GAAG,EAA5C,CAHkC,CAKlC;;EACAC,MAAM,CAACC,YAAP,GAAuBC,QAAD,IAAkC;IACtDH,kBAAkB,CAACI,IAAnB,CAAwBD,QAAxB;IACA,OAAO,CAAC,CAAR;EACD,CAHD;;EAKAF,MAAM,CAACI,iBAAP,GAA2B,MAAM;IAC/B,KAAK,IAAIC,KAAK,GAAG,CAAjB,EAAoBA,KAAK,GAAGN,kBAAkB,CAACO,MAA/C,EAAuDD,KAAK,IAAI,CAAhE,EAAmE;MACjE;MACAN,kBAAkB,CAACM,KAAD,CAAlB;IACD;;IACDN,kBAAkB,GAAG,EAArB;EACD,CAND;AAOD;;AAED,SAASQ,yBAAT,GAAqC;EACnC;;EACAP,MAAM,CAACI,iBAAP;AAC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;EACD,OAAO,YAAa;IAAA,mCAATC,IAAS;MAATA,IAAS;IAAA;;IAClBC,yBAAA,CAAuBC,YAAvB,CACE,IAAAC,uCAAA,EAA4B,MAAM;MAChC;;MACAR,OAAO,CAAC,GAAGK,IAAJ,CAAP;IACD,CAHD,CADF;EAMD,CAPD;AAQD;;AAED,IAAIJ,OAAJ,EAAa;EACX,IAAI;IACFF,OAAO,CAAC,MAAM;MACZ;IACD,CAFM,CAAP;EAGD,CAJD,CAIE,OAAOa,CAAP,EAAU;IACV,MAAM,IAAIR,KAAJ,CACJ,wNADI,CAAN;EAGD;AACF;;AAEM,SAASS,OAAT,CACLC,GADK,EAEiB;EACtB;;EACA,IAAIA,GAAG,CAACC,gBAAR,EAA0B;IACxB;IACA;IACA;IACA;IACAD,GAAG,GAAGA,GAAG,CAACC,gBAAV;EACD;;EACD,IAAI,CAACC,QAAL,EAAe;IACb,OAAOF,GAAP;EACD;;EACD,OAAO,YAAa;IAAA,mCAATT,IAAS;MAATA,IAAS;IAAA;;IAClBY,aAAa,CACXH,GADW,EAEXT,IAAI,CAACT,MAAL,GAAc,CAAd,GAAkB,IAAAsB,2CAAA,EAAgCb,IAAhC,CAAlB,GAA0DF,SAF/C,CAAb;EAID,CALD;AAMD"}
|
|
1
|
+
{"version":3,"names":["_NativeReanimated","_interopRequireDefault","require","_PlatformChecker","_shareables","obj","__esModule","default","IS_JEST","isJest","IS_WEB","shouldBeUseWeb","_runOnUIQueue","setupMicrotasks","microtasksQueue","isExecutingMicrotasksQueue","global","queueMicrotask","callback","push","__callMicrotasks","index","length","_maybeFlushUIUpdatesQueue","callMicrotasksOnUIThread","callMicrotasks","exports","runOnUI","worklet","__DEV__","__workletHash","undefined","Error","_len","arguments","args","Array","_key","NativeReanimatedModule","scheduleOnUI","makeShareableCloneRecursive","queue","forEach","_ref","runOnUIImmediately","_len2","_key2","e","runOnJS","fun","__remoteFunction","_WORKLET","_len3","_key3","_scheduleOnJS","makeShareableCloneOnUIRecursive"],"sources":["threads.ts"],"sourcesContent":["import NativeReanimatedModule from './NativeReanimated';\nimport { isJest, shouldBeUseWeb } from './PlatformChecker';\nimport { ComplexWorkletFunction } from './commonTypes';\nimport {\n makeShareableCloneOnUIRecursive,\n makeShareableCloneRecursive,\n} from './shareables';\n\nconst IS_JEST = isJest();\nconst IS_WEB = shouldBeUseWeb();\n\nlet _runOnUIQueue: Array<[ComplexWorkletFunction<any[], any>, any[]]> = [];\n\nexport function setupMicrotasks() {\n 'worklet';\n\n let microtasksQueue: Array<() => void> = [];\n let isExecutingMicrotasksQueue = false;\n\n // @ts-ignore – typescript expects this to conform to NodeJS definition and expects the return value to be NodeJS.Immediate which is an object and not a number\n global.queueMicrotask = (callback: () => void): number => {\n microtasksQueue.push(callback);\n return -1;\n };\n\n global.__callMicrotasks = () => {\n if (isExecutingMicrotasksQueue) {\n return;\n }\n try {\n isExecutingMicrotasksQueue = true;\n for (let index = 0; index < microtasksQueue.length; index += 1) {\n // we use classic 'for' loop because the size of the currentTasks array may change while executing some of the callbacks due to queueMicrotask calls\n microtasksQueue[index]();\n }\n microtasksQueue = [];\n global._maybeFlushUIUpdatesQueue();\n } finally {\n isExecutingMicrotasksQueue = false;\n }\n };\n}\n\nfunction callMicrotasksOnUIThread() {\n 'worklet';\n global.__callMicrotasks();\n}\n\nexport const callMicrotasks = shouldBeUseWeb()\n ? () => {\n // on web flushing is a noop as immediates are handled by the browser\n }\n : callMicrotasksOnUIThread;\n\n/**\n * Schedule a worklet to execute on the UI runtime. This method does not schedule the work immediately but instead\n * waits for other worklets to be scheduled within the same JS loop. It uses queueMicrotask to schedule all the worklets\n * at once making sure they will run within the same frame boundaries on the UI thread.\n */\nexport function runOnUI<A extends any[], R>(\n worklet: ComplexWorkletFunction<A, R>\n): (...args: A) => void {\n if (__DEV__ && !IS_WEB && worklet.__workletHash === undefined) {\n throw new Error('runOnUI() can only be used on worklets');\n }\n return (...args) => {\n if (IS_JEST) {\n // Mocking time in Jest is tricky as both requestAnimationFrame and queueMicrotask\n // callbacks run on the same queue and can be interleaved. There is no way\n // to flush particular queue in Jest and the only control over mocked timers\n // is by using jest.advanceTimersByTime() method which advances all types\n // of timers including immediate and animation callbacks. Ideally we'd like\n // to have some way here to schedule work along with React updates, but\n // that's not possible, and hence in Jest environment instead of using scheduling\n // mechanism we just schedule the work ommiting the queue. This is ok for the\n // uses that we currently have but may not be ok for future tests that we write.\n NativeReanimatedModule.scheduleOnUI(\n makeShareableCloneRecursive(() => {\n 'worklet';\n worklet(...args);\n })\n );\n return;\n }\n if (__DEV__) {\n // in DEV mode we call shareable conversion here because in case the object\n // can't be converted, we will get a meaningful stack-trace as opposed to the\n // situation when conversion is only done via microtask queue. This does not\n // make the app particularily less efficient as converted objects are cached\n // and for a given worklet the conversion only happens once.\n makeShareableCloneRecursive(worklet);\n makeShareableCloneRecursive(args);\n }\n _runOnUIQueue.push([worklet, args]);\n if (_runOnUIQueue.length === 1) {\n queueMicrotask(() => {\n const queue = _runOnUIQueue;\n _runOnUIQueue = [];\n NativeReanimatedModule.scheduleOnUI(\n makeShareableCloneRecursive(() => {\n 'worklet';\n queue.forEach(([worklet, args]) => {\n worklet(...args);\n });\n callMicrotasks();\n })\n );\n });\n }\n };\n}\n\n/**\n * Schedule a worklet to execute on the UI runtime skipping batching mechanism.\n */\nexport function runOnUIImmediately<A extends any[], R>(\n worklet: ComplexWorkletFunction<A, R>\n): (...args: A) => void {\n if (__DEV__ && !IS_WEB && worklet.__workletHash === undefined) {\n throw new Error('runOnUI() can only be used on worklets');\n }\n return (...args) => {\n NativeReanimatedModule.scheduleOnUI(\n makeShareableCloneRecursive(() => {\n 'worklet';\n worklet(...args);\n })\n );\n };\n}\n\nif (__DEV__) {\n try {\n runOnUI(() => {\n 'worklet';\n });\n } catch (e) {\n throw new Error(\n 'Failed to create a worklet. Did you forget to add Reanimated Babel plugin in babel.config.js? See installation docs at https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation#babel-plugin.'\n );\n }\n}\n\nexport function runOnJS<A extends any[], R>(\n fun: ComplexWorkletFunction<A, R>\n): (...args: A) => void {\n 'worklet';\n if (fun.__remoteFunction) {\n // in development mode the function provided as `fun` throws an error message\n // such that when someone accidently calls it directly on the UI runtime, they\n // see that they should use `runOnJS` instead. To facilitate that we purt the\n // reference to the original remote function in the `__remoteFunction` property.\n fun = fun.__remoteFunction;\n }\n if (!_WORKLET) {\n return fun;\n }\n return (...args) => {\n _scheduleOnJS(\n fun,\n args.length > 0 ? makeShareableCloneOnUIRecursive(args) : undefined\n );\n };\n}\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AAEA,IAAAE,WAAA,GAAAF,OAAA;AAGsB,SAAAD,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEtB,MAAMG,OAAO,GAAG,IAAAC,uBAAM,GAAE;AACxB,MAAMC,MAAM,GAAG,IAAAC,+BAAc,GAAE;AAE/B,IAAIC,aAAiE,GAAG,EAAE;AAEnE,SAASC,eAAeA,CAAA,EAAG;EAChC,SAAS;;EAET,IAAIC,eAAkC,GAAG,EAAE;EAC3C,IAAIC,0BAA0B,GAAG,KAAK;;EAEtC;EACAC,MAAM,CAACC,cAAc,GAAIC,QAAoB,IAAa;IACxDJ,eAAe,CAACK,IAAI,CAACD,QAAQ,CAAC;IAC9B,OAAO,CAAC,CAAC;EACX,CAAC;EAEDF,MAAM,CAACI,gBAAgB,GAAG,MAAM;IAC9B,IAAIL,0BAA0B,EAAE;MAC9B;IACF;IACA,IAAI;MACFA,0BAA0B,GAAG,IAAI;MACjC,KAAK,IAAIM,KAAK,GAAG,CAAC,EAAEA,KAAK,GAAGP,eAAe,CAACQ,MAAM,EAAED,KAAK,IAAI,CAAC,EAAE;QAC9D;QACAP,eAAe,CAACO,KAAK,CAAC,EAAE;MAC1B;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IACxB;IACA;IACA;IACA;IACAD,GAAG,GAAGA,GAAG,CAACC,gBAAgB;EAC5B;EACA,IAAI,CAACC,QAAQ,EAAE;IACb,OAAOF,GAAG;EACZ;EACA,OAAO,YAAa;IAAA,SAAAG,KAAA,GAAAlB,SAAA,CAAAZ,MAAA,EAATa,IAAI,OAAAC,KAAA,CAAAgB,KAAA,GAAAC,KAAA,MAAAA,KAAA,GAAAD,KAAA,EAAAC,KAAA;MAAJlB,IAAI,CAAAkB,KAAA,IAAAnB,SAAA,CAAAmB,KAAA;IAAA;IACbC,aAAa,CACXL,GAAG,EACHd,IAAI,CAACb,MAAM,GAAG,CAAC,GAAG,IAAAiC,2CAA+B,EAACpB,IAAI,CAAC,GAAGJ,SAAS,CACpE;EACH,CAAC;AACH"}
|
|
@@ -5,9 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.getRelativeCoords = getRelativeCoords;
|
|
7
7
|
exports.isSharedValue = isSharedValue;
|
|
8
|
-
|
|
9
8
|
var _NativeMethods = require("./NativeMethods");
|
|
10
|
-
|
|
11
9
|
/**
|
|
12
10
|
* Given an absolute position and a component ref, returns the relative
|
|
13
11
|
* position in the component's local coordinate space.
|
|
@@ -16,17 +14,14 @@ function getRelativeCoords(parentRef, absoluteX, absoluteY) {
|
|
|
16
14
|
'worklet';
|
|
17
15
|
|
|
18
16
|
const parentCoords = (0, _NativeMethods.measure)(parentRef);
|
|
19
|
-
|
|
20
17
|
if (parentCoords === null) {
|
|
21
18
|
return null;
|
|
22
19
|
}
|
|
23
|
-
|
|
24
20
|
return {
|
|
25
21
|
x: absoluteX - parentCoords.x,
|
|
26
22
|
y: absoluteY - parentCoords.y
|
|
27
23
|
};
|
|
28
24
|
}
|
|
29
|
-
|
|
30
25
|
function isSharedValue(value) {
|
|
31
26
|
'worklet';
|
|
32
27
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getRelativeCoords","parentRef","absoluteX","absoluteY","parentCoords","measure","x","y","isSharedValue","value","_isReanimatedSharedValue"],"sources":["utils.ts"],"sourcesContent":["import { Component } from 'react';\nimport { measure } from './NativeMethods';\nimport { RefObjectFunction } from './hook/commonTypes';\nimport { SharedValue } from './commonTypes';\n\nexport interface ComponentCoords {\n x: number;\n y: number;\n}\n\n/**\n * Given an absolute position and a component ref, returns the relative\n * position in the component's local coordinate space.\n */\nexport function getRelativeCoords(\n parentRef: RefObjectFunction<Component>,\n absoluteX: number,\n absoluteY: number\n): ComponentCoords | null {\n 'worklet';\n const parentCoords = measure(parentRef);\n if (parentCoords === null) {\n return null;\n }\n return {\n x: absoluteX - parentCoords.x,\n y: absoluteY - parentCoords.y,\n };\n}\n\nexport function isSharedValue<T>(value: any): value is SharedValue<T> {\n 'worklet';\n return value?._isReanimatedSharedValue === true;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_NativeMethods","require","getRelativeCoords","parentRef","absoluteX","absoluteY","parentCoords","measure","x","y","isSharedValue","value","_isReanimatedSharedValue"],"sources":["utils.ts"],"sourcesContent":["import { Component } from 'react';\nimport { measure } from './NativeMethods';\nimport { RefObjectFunction } from './hook/commonTypes';\nimport { SharedValue } from './commonTypes';\n\nexport interface ComponentCoords {\n x: number;\n y: number;\n}\n\n/**\n * Given an absolute position and a component ref, returns the relative\n * position in the component's local coordinate space.\n */\nexport function getRelativeCoords(\n parentRef: RefObjectFunction<Component>,\n absoluteX: number,\n absoluteY: number\n): ComponentCoords | null {\n 'worklet';\n const parentCoords = measure(parentRef);\n if (parentCoords === null) {\n return null;\n }\n return {\n x: absoluteX - parentCoords.x,\n y: absoluteY - parentCoords.y,\n };\n}\n\nexport function isSharedValue<T>(value: any): value is SharedValue<T> {\n 'worklet';\n return value?._isReanimatedSharedValue === true;\n}\n"],"mappings":";;;;;;;AACA,IAAAA,cAAA,GAAAC,OAAA;AASA;AACA;AACA;AACA;AACO,SAASC,iBAAiBA,CAC/BC,SAAuC,EACvCC,SAAiB,EACjBC,SAAiB,EACO;EACxB,SAAS;;EACT,MAAMC,YAAY,GAAG,IAAAC,sBAAO,EAACJ,SAAS,CAAC;EACvC,IAAIG,YAAY,KAAK,IAAI,EAAE;IACzB,OAAO,IAAI;EACb;EACA,OAAO;IACLE,CAAC,EAAEJ,SAAS,GAAGE,YAAY,CAACE,CAAC;IAC7BC,CAAC,EAAEJ,SAAS,GAAGC,YAAY,CAACG;EAC9B,CAAC;AACH;AAEO,SAASC,aAAaA,CAAIC,KAAU,EAA2B;EACpE,SAAS;;EACT,OAAO,CAAAA,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEC,wBAAwB,MAAK,IAAI;AACjD"}
|
|
@@ -10,60 +10,46 @@ Object.defineProperty(exports, "stopMapper", {
|
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
12
|
exports.valueSetter = valueSetter;
|
|
13
|
-
|
|
14
13
|
var _mappers = require("./mappers");
|
|
15
|
-
|
|
16
14
|
function valueSetter(sv, value) {
|
|
17
15
|
'worklet';
|
|
18
16
|
|
|
19
17
|
const previousAnimation = sv._animation;
|
|
20
|
-
|
|
21
18
|
if (previousAnimation) {
|
|
22
19
|
previousAnimation.cancelled = true;
|
|
23
20
|
sv._animation = null;
|
|
24
21
|
}
|
|
25
|
-
|
|
26
22
|
if (typeof value === 'function' || value !== null && typeof value === 'object' && value.onFrame !== undefined) {
|
|
27
|
-
const animation = typeof value === 'function' ? value() : value;
|
|
23
|
+
const animation = typeof value === 'function' ? value() : value;
|
|
24
|
+
// prevent setting again to the same value
|
|
28
25
|
// and triggering the mappers that treat this value as an input
|
|
29
26
|
// this happens when the animation's target value(stored in animation.current until animation.onStart is called) is set to the same value as a current one(this._value)
|
|
30
27
|
// built in animations that are not higher order(withTiming, withSpring) hold target value in .current
|
|
31
|
-
|
|
32
28
|
if (sv._value === animation.current && !animation.isHigherOrder) {
|
|
33
29
|
animation.callback && animation.callback(true);
|
|
34
30
|
return;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
}
|
|
32
|
+
// animated set
|
|
38
33
|
const initializeAnimation = timestamp => {
|
|
39
34
|
animation.onStart(animation, sv.value, timestamp, previousAnimation);
|
|
40
35
|
};
|
|
41
|
-
|
|
42
36
|
const currentTimestamp = global.__frameTimestamp || performance.now();
|
|
43
37
|
initializeAnimation(currentTimestamp);
|
|
44
|
-
|
|
45
38
|
const step = timestamp => {
|
|
46
39
|
if (animation.cancelled) {
|
|
47
|
-
animation.callback && animation.callback(false
|
|
48
|
-
/* finished */
|
|
49
|
-
);
|
|
40
|
+
animation.callback && animation.callback(false /* finished */);
|
|
50
41
|
return;
|
|
51
42
|
}
|
|
52
|
-
|
|
53
43
|
const finished = animation.onFrame(animation, timestamp);
|
|
54
44
|
animation.finished = true;
|
|
55
45
|
animation.timestamp = timestamp;
|
|
56
46
|
sv._value = animation.current;
|
|
57
|
-
|
|
58
47
|
if (finished) {
|
|
59
|
-
animation.callback && animation.callback(true
|
|
60
|
-
/* finished */
|
|
61
|
-
);
|
|
48
|
+
animation.callback && animation.callback(true /* finished */);
|
|
62
49
|
} else {
|
|
63
50
|
requestAnimationFrame(step);
|
|
64
51
|
}
|
|
65
52
|
};
|
|
66
|
-
|
|
67
53
|
sv._animation = animation;
|
|
68
54
|
step(currentTimestamp);
|
|
69
55
|
} else {
|
|
@@ -72,7 +58,6 @@ function valueSetter(sv, value) {
|
|
|
72
58
|
if (sv._value === value) {
|
|
73
59
|
return;
|
|
74
60
|
}
|
|
75
|
-
|
|
76
61
|
sv._value = value;
|
|
77
62
|
}
|
|
78
63
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["valueSetter","sv","value","previousAnimation","_animation","cancelled","onFrame","undefined","animation","_value","current","isHigherOrder","callback","initializeAnimation","timestamp","onStart","currentTimestamp","global","__frameTimestamp","performance","now","step","finished","requestAnimationFrame"],"sources":["valueSetter.ts"],"sourcesContent":["import { AnimationObject, AnimatableValue } from './commonTypes';\nimport { Descriptor } from './hook/commonTypes';\nexport { stopMapper } from './mappers';\n\nexport function valueSetter(sv: any, value: any): void {\n 'worklet';\n const previousAnimation = sv._animation;\n if (previousAnimation) {\n previousAnimation.cancelled = true;\n sv._animation = null;\n }\n if (\n typeof value === 'function' ||\n (value !== null &&\n typeof value === 'object' &&\n (value as AnimationObject).onFrame !== undefined)\n ) {\n const animation: AnimationObject =\n typeof value === 'function'\n ? (value as () => AnimationObject)()\n : (value as AnimationObject);\n // prevent setting again to the same value\n // and triggering the mappers that treat this value as an input\n // this happens when the animation's target value(stored in animation.current until animation.onStart is called) is set to the same value as a current one(this._value)\n // built in animations that are not higher order(withTiming, withSpring) hold target value in .current\n if (sv._value === animation.current && !animation.isHigherOrder) {\n animation.callback && animation.callback(true);\n return;\n }\n // animated set\n const initializeAnimation = (timestamp: number) => {\n animation.onStart(animation, sv.value, timestamp, previousAnimation);\n };\n const currentTimestamp = global.__frameTimestamp || performance.now();\n initializeAnimation(currentTimestamp);\n const step = (timestamp: number) => {\n if (animation.cancelled) {\n animation.callback && animation.callback(false /* finished */);\n return;\n }\n const finished = animation.onFrame(animation, timestamp);\n animation.finished = true;\n animation.timestamp = timestamp;\n sv._value = animation.current;\n if (finished) {\n animation.callback && animation.callback(true /* finished */);\n } else {\n requestAnimationFrame(step);\n }\n };\n\n sv._animation = animation;\n\n step(currentTimestamp);\n } else {\n // prevent setting again to the same value\n // and triggering the mappers that treat this value as an input\n if (sv._value === value) {\n return;\n }\n sv._value = value as Descriptor | AnimatableValue;\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_mappers","require","valueSetter","sv","value","previousAnimation","_animation","cancelled","onFrame","undefined","animation","_value","current","isHigherOrder","callback","initializeAnimation","timestamp","onStart","currentTimestamp","global","__frameTimestamp","performance","now","step","finished","requestAnimationFrame"],"sources":["valueSetter.ts"],"sourcesContent":["import { AnimationObject, AnimatableValue } from './commonTypes';\nimport { Descriptor } from './hook/commonTypes';\nexport { stopMapper } from './mappers';\n\nexport function valueSetter(sv: any, value: any): void {\n 'worklet';\n const previousAnimation = sv._animation;\n if (previousAnimation) {\n previousAnimation.cancelled = true;\n sv._animation = null;\n }\n if (\n typeof value === 'function' ||\n (value !== null &&\n typeof value === 'object' &&\n (value as AnimationObject).onFrame !== undefined)\n ) {\n const animation: AnimationObject =\n typeof value === 'function'\n ? (value as () => AnimationObject)()\n : (value as AnimationObject);\n // prevent setting again to the same value\n // and triggering the mappers that treat this value as an input\n // this happens when the animation's target value(stored in animation.current until animation.onStart is called) is set to the same value as a current one(this._value)\n // built in animations that are not higher order(withTiming, withSpring) hold target value in .current\n if (sv._value === animation.current && !animation.isHigherOrder) {\n animation.callback && animation.callback(true);\n return;\n }\n // animated set\n const initializeAnimation = (timestamp: number) => {\n animation.onStart(animation, sv.value, timestamp, previousAnimation);\n };\n const currentTimestamp = global.__frameTimestamp || performance.now();\n initializeAnimation(currentTimestamp);\n const step = (timestamp: number) => {\n if (animation.cancelled) {\n animation.callback && animation.callback(false /* finished */);\n return;\n }\n const finished = animation.onFrame(animation, timestamp);\n animation.finished = true;\n animation.timestamp = timestamp;\n sv._value = animation.current;\n if (finished) {\n animation.callback && animation.callback(true /* finished */);\n } else {\n requestAnimationFrame(step);\n }\n };\n\n sv._animation = animation;\n\n step(currentTimestamp);\n } else {\n // prevent setting again to the same value\n // and triggering the mappers that treat this value as an input\n if (sv._value === value) {\n return;\n }\n sv._value = value as Descriptor | AnimatableValue;\n }\n}\n"],"mappings":";;;;;;;;;;;;AAEA,IAAAA,QAAA,GAAAC,OAAA;AAEO,SAASC,WAAWA,CAACC,EAAO,EAAEC,KAAU,EAAQ;EACrD,SAAS;;EACT,MAAMC,iBAAiB,GAAGF,EAAE,CAACG,UAAU;EACvC,IAAID,iBAAiB,EAAE;IACrBA,iBAAiB,CAACE,SAAS,GAAG,IAAI;IAClCJ,EAAE,CAACG,UAAU,GAAG,IAAI;EACtB;EACA,IACE,OAAOF,KAAK,KAAK,UAAU,IAC1BA,KAAK,KAAK,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a,IAAI,CAACL,gBAAgB,CAAC;EACxB,CAAC,MAAM;IACL;IACA;IACA,IAAIf,EAAE,CAACQ,MAAM,KAAKP,KAAK,EAAE;MACvB;IACF;IACAD,EAAE,CAACQ,MAAM,GAAGP,KAAqC;EACnD;AACF"}
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
/**
|
|
9
8
|
* imported from react-native
|
|
10
9
|
*/
|
|
@@ -39,6 +38,7 @@ exports.default = void 0;
|
|
|
39
38
|
*
|
|
40
39
|
* module.exports = MyViewWithRef;
|
|
41
40
|
*/
|
|
41
|
+
|
|
42
42
|
function setAndForwardRef(_ref) {
|
|
43
43
|
let {
|
|
44
44
|
getForwardedRef,
|
|
@@ -46,8 +46,9 @@ function setAndForwardRef(_ref) {
|
|
|
46
46
|
} = _ref;
|
|
47
47
|
return function forwardRef(ref) {
|
|
48
48
|
const forwardedRef = getForwardedRef();
|
|
49
|
-
setLocalRef(ref);
|
|
49
|
+
setLocalRef(ref);
|
|
50
50
|
|
|
51
|
+
// Forward to user ref prop (if one has been specified)
|
|
51
52
|
if (typeof forwardedRef === 'function') {
|
|
52
53
|
// Handle function-based refs. String-based refs are handled as functions.
|
|
53
54
|
forwardedRef(ref);
|
|
@@ -57,7 +58,6 @@ function setAndForwardRef(_ref) {
|
|
|
57
58
|
}
|
|
58
59
|
};
|
|
59
60
|
}
|
|
60
|
-
|
|
61
61
|
var _default = setAndForwardRef;
|
|
62
62
|
exports.default = _default;
|
|
63
63
|
//# sourceMappingURL=setAndForwardRef.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["setAndForwardRef","getForwardedRef","setLocalRef","forwardRef","ref","forwardedRef","current"],"sources":["setAndForwardRef.ts"],"sourcesContent":["/**\n * imported from react-native\n */\n\nimport { MutableRefObject } from 'react';\n\n/**\n * This is a helper function for when a component needs to be able to forward a ref\n * to a child component, but still needs to have access to that component as part of\n * its implementation.\n *\n * Its main use case is in wrappers for native components.\n *\n * Usage:\n *\n * class MyView extends React.Component {\n * _nativeRef = null;\n *\n * _setNativeRef = setAndForwardRef({\n * getForwardedRef: () => this.props.forwardedRef,\n * setLocalRef: ref => {\n * this._nativeRef = ref;\n * },\n * });\n *\n * render() {\n * return <View ref={this._setNativeRef} />;\n * }\n * }\n *\n * const MyViewWithRef = React.forwardRef((props, ref) => (\n * <MyView {...props} forwardedRef={ref} />\n * ));\n *\n * module.exports = MyViewWithRef;\n */\n\nexport type ForwardedRef<T> = () => MutableRefObject<T> | ((ref: T) => void);\n\nfunction setAndForwardRef<T>({\n getForwardedRef,\n setLocalRef,\n}: {\n getForwardedRef: ForwardedRef<T>;\n setLocalRef: (ref: T) => void;\n}): (ref: T) => void {\n return function forwardRef(ref: T) {\n const forwardedRef = getForwardedRef();\n\n setLocalRef(ref);\n\n // Forward to user ref prop (if one has been specified)\n if (typeof forwardedRef === 'function') {\n // Handle function-based refs. String-based refs are handled as functions.\n forwardedRef(ref);\n } else if (typeof forwardedRef === 'object' && forwardedRef != null) {\n // Handle createRef-based refs\n forwardedRef.current = ref;\n }\n };\n}\n\nexport default setAndForwardRef;\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["setAndForwardRef","_ref","getForwardedRef","setLocalRef","forwardRef","ref","forwardedRef","current","_default","exports","default"],"sources":["setAndForwardRef.ts"],"sourcesContent":["/**\n * imported from react-native\n */\n\nimport { MutableRefObject } from 'react';\n\n/**\n * This is a helper function for when a component needs to be able to forward a ref\n * to a child component, but still needs to have access to that component as part of\n * its implementation.\n *\n * Its main use case is in wrappers for native components.\n *\n * Usage:\n *\n * class MyView extends React.Component {\n * _nativeRef = null;\n *\n * _setNativeRef = setAndForwardRef({\n * getForwardedRef: () => this.props.forwardedRef,\n * setLocalRef: ref => {\n * this._nativeRef = ref;\n * },\n * });\n *\n * render() {\n * return <View ref={this._setNativeRef} />;\n * }\n * }\n *\n * const MyViewWithRef = React.forwardRef((props, ref) => (\n * <MyView {...props} forwardedRef={ref} />\n * ));\n *\n * module.exports = MyViewWithRef;\n */\n\nexport type ForwardedRef<T> = () => MutableRefObject<T> | ((ref: T) => void);\n\nfunction setAndForwardRef<T>({\n getForwardedRef,\n setLocalRef,\n}: {\n getForwardedRef: ForwardedRef<T>;\n setLocalRef: (ref: T) => void;\n}): (ref: T) => void {\n return function forwardRef(ref: T) {\n const forwardedRef = getForwardedRef();\n\n setLocalRef(ref);\n\n // Forward to user ref prop (if one has been specified)\n if (typeof forwardedRef === 'function') {\n // Handle function-based refs. String-based refs are handled as functions.\n forwardedRef(ref);\n } else if (typeof forwardedRef === 'object' && forwardedRef != null) {\n // Handle createRef-based refs\n forwardedRef.current = ref;\n }\n };\n}\n\nexport default setAndForwardRef;\n"],"mappings":";;;;;;AAAA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,SAASA,gBAAgBA,CAAAC,IAAA,EAMJ;EAAA,IANQ;IAC3BC,eAAe;IACfC;EAIF,CAAC,GAAAF,IAAA;EACC,OAAO,SAASG,UAAUA,CAACC,GAAM,EAAE;IACjC,MAAMC,YAAY,GAAGJ,eAAe,EAAE;IAEtCC,WAAW,CAACE,GAAG,CAAC;;IAEhB;IACA,IAAI,OAAOC,YAAY,KAAK,UAAU,EAAE;MACtC;MACAA,YAAY,CAACD,GAAG,CAAC;IACnB,CAAC,MAAM,IAAI,OAAOC,YAAY,KAAK,QAAQ,IAAIA,YAAY,IAAI,IAAI,EAAE;MACnE;MACAA,YAAY,CAACC,OAAO,GAAGF,GAAG;IAC5B;EACF,CAAC;AACH;AAAC,IAAAG,QAAA,GAEcR,gBAAgB;AAAAS,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["default","createAnimatedComponent","addWhitelistedNativeProps","addWhitelistedUIProps","Text","View","ScrollView","Image","FlatList"],"sources":["Animated.ts"],"sourcesContent":["export { default as createAnimatedComponent } from './createAnimatedComponent';\nexport {\n addWhitelistedNativeProps,\n addWhitelistedUIProps,\n} from './ConfigHelper';\n\nexport { default as Text } from './reanimated2/component/Text';\nexport { default as View } from './reanimated2/component/View';\nexport { default as ScrollView } from './reanimated2/component/ScrollView';\nexport { default as Image } from './reanimated2/component/Image';\nexport { default as FlatList } from './reanimated2/component/FlatList';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,
|
|
1
|
+
{"version":3,"names":["default","createAnimatedComponent","addWhitelistedNativeProps","addWhitelistedUIProps","Text","View","ScrollView","Image","FlatList"],"sources":["Animated.ts"],"sourcesContent":["export { default as createAnimatedComponent } from './createAnimatedComponent';\nexport {\n addWhitelistedNativeProps,\n addWhitelistedUIProps,\n} from './ConfigHelper';\n\nexport { default as Text } from './reanimated2/component/Text';\nexport { default as View } from './reanimated2/component/View';\nexport { default as ScrollView } from './reanimated2/component/ScrollView';\nexport { default as Image } from './reanimated2/component/Image';\nexport { default as FlatList } from './reanimated2/component/FlatList';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,uBAAuB,QAAQ,2BAA2B;AAC9E,SACEC,yBAAyB,EACzBC,qBAAqB,QAChB,gBAAgB;AAEvB,SAASH,OAAO,IAAII,IAAI,QAAQ,8BAA8B;AAC9D,SAASJ,OAAO,IAAIK,IAAI,QAAQ,8BAA8B;AAC9D,SAASL,OAAO,IAAIM,UAAU,QAAQ,oCAAoC;AAC1E,SAASN,OAAO,IAAIO,KAAK,QAAQ,+BAA+B;AAChE,SAASP,OAAO,IAAIQ,QAAQ,QAAQ,kCAAkC"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { configureProps as jsiConfigureProps } from './reanimated2/core';
|
|
2
|
+
|
|
2
3
|
/**
|
|
3
4
|
* Styles allowed to be direcly updated in UI thread
|
|
4
5
|
*/
|
|
5
|
-
|
|
6
6
|
let UI_THREAD_PROPS_WHITELIST = {
|
|
7
7
|
opacity: true,
|
|
8
8
|
transform: true,
|
|
9
|
-
|
|
10
9
|
/* colors */
|
|
11
10
|
backgroundColor: true,
|
|
12
11
|
borderRightColor: true,
|
|
@@ -16,21 +15,19 @@ let UI_THREAD_PROPS_WHITELIST = {
|
|
|
16
15
|
borderLeftColor: true,
|
|
17
16
|
borderStartColor: true,
|
|
18
17
|
borderTopColor: true,
|
|
19
|
-
|
|
20
18
|
/* ios styles */
|
|
21
19
|
shadowOpacity: true,
|
|
22
20
|
shadowRadius: true,
|
|
23
|
-
|
|
24
21
|
/* legacy android transform properties */
|
|
25
22
|
scaleX: true,
|
|
26
23
|
scaleY: true,
|
|
27
24
|
translateX: true,
|
|
28
25
|
translateY: true
|
|
29
26
|
};
|
|
27
|
+
|
|
30
28
|
/**
|
|
31
29
|
* Whitelist of view props that can be updated in native thread via UIManagerModule
|
|
32
30
|
*/
|
|
33
|
-
|
|
34
31
|
let NATIVE_THREAD_PROPS_WHITELIST = {
|
|
35
32
|
borderBottomWidth: true,
|
|
36
33
|
borderEndWidth: true,
|
|
@@ -86,7 +83,6 @@ let NATIVE_THREAD_PROPS_WHITELIST = {
|
|
|
86
83
|
lineHeight: true,
|
|
87
84
|
textShadowRadius: true,
|
|
88
85
|
letterSpacing: true,
|
|
89
|
-
|
|
90
86
|
/* strings */
|
|
91
87
|
display: true,
|
|
92
88
|
backfaceVisibility: true,
|
|
@@ -102,48 +98,46 @@ let NATIVE_THREAD_PROPS_WHITELIST = {
|
|
|
102
98
|
textDecorationStyle: true,
|
|
103
99
|
textTransform: true,
|
|
104
100
|
writingDirection: true,
|
|
105
|
-
|
|
106
101
|
/* text color */
|
|
107
102
|
color: true,
|
|
108
103
|
tintColor: true,
|
|
109
104
|
shadowColor: true,
|
|
110
105
|
placeholderTextColor: true
|
|
111
106
|
};
|
|
112
|
-
|
|
113
107
|
function configureProps() {
|
|
114
108
|
jsiConfigureProps(Object.keys(UI_THREAD_PROPS_WHITELIST), Object.keys(NATIVE_THREAD_PROPS_WHITELIST));
|
|
115
109
|
}
|
|
116
|
-
|
|
117
110
|
export function addWhitelistedNativeProps(props) {
|
|
118
111
|
const oldSize = Object.keys(NATIVE_THREAD_PROPS_WHITELIST).length;
|
|
119
|
-
NATIVE_THREAD_PROPS_WHITELIST = {
|
|
112
|
+
NATIVE_THREAD_PROPS_WHITELIST = {
|
|
113
|
+
...NATIVE_THREAD_PROPS_WHITELIST,
|
|
120
114
|
...props
|
|
121
115
|
};
|
|
122
|
-
|
|
123
116
|
if (oldSize !== Object.keys(NATIVE_THREAD_PROPS_WHITELIST).length) {
|
|
124
117
|
configureProps();
|
|
125
118
|
}
|
|
126
119
|
}
|
|
127
120
|
export function addWhitelistedUIProps(props) {
|
|
128
121
|
const oldSize = Object.keys(UI_THREAD_PROPS_WHITELIST).length;
|
|
129
|
-
UI_THREAD_PROPS_WHITELIST = {
|
|
122
|
+
UI_THREAD_PROPS_WHITELIST = {
|
|
123
|
+
...UI_THREAD_PROPS_WHITELIST,
|
|
130
124
|
...props
|
|
131
125
|
};
|
|
132
|
-
|
|
133
126
|
if (oldSize !== Object.keys(UI_THREAD_PROPS_WHITELIST).length) {
|
|
134
127
|
configureProps();
|
|
135
128
|
}
|
|
136
129
|
}
|
|
137
130
|
const PROCESSED_VIEW_NAMES = new Set();
|
|
138
|
-
|
|
139
131
|
/**
|
|
140
132
|
* updates UI props whitelist for given view host instance
|
|
141
133
|
* this will work just once for every view name
|
|
142
134
|
*/
|
|
135
|
+
|
|
143
136
|
export function adaptViewConfig(viewConfig) {
|
|
144
137
|
const viewName = viewConfig.uiViewClassName;
|
|
145
|
-
const props = viewConfig.validAttributes;
|
|
138
|
+
const props = viewConfig.validAttributes;
|
|
146
139
|
|
|
140
|
+
// update whitelist of UI props for this view name only once
|
|
147
141
|
if (!PROCESSED_VIEW_NAMES.has(viewName)) {
|
|
148
142
|
const propsToAdd = {};
|
|
149
143
|
Object.keys(props).forEach(key => {
|