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
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"devDependencies": {
|
|
3
|
+
"@react-native/eslint-config": "^0.72.1",
|
|
4
|
+
"@types/node": "^18.15.11",
|
|
5
|
+
"esbuild": "^0.17.11",
|
|
6
|
+
"eslint": "^8.35.0",
|
|
7
|
+
"prettier": "^2.5.1",
|
|
8
|
+
"tsc-watch": "^6.0.0",
|
|
9
|
+
"typescript": "^4.1.3"
|
|
10
|
+
},
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"readmeFilename": "README.md",
|
|
13
|
+
"scripts": {
|
|
14
|
+
"prepare": "yarn generate",
|
|
15
|
+
"generate": "yarn tsc && yarn bundle && yarn clean",
|
|
16
|
+
"clean": "rm -f lib/*",
|
|
17
|
+
"bundle": "esbuild ./lib/plugin.js --bundle --external:@babel --external:convert-source-map --external:fs --external:'../../package.json' --log-level=warning --platform=node --sourcemap=linked --outfile=build/plugin.js",
|
|
18
|
+
"format": "prettier --write --list-different **/*.ts",
|
|
19
|
+
"watch": "tsc-watch --onSuccess \"yarn bundle\"",
|
|
20
|
+
"lint": "eslint --max-warnings=0 --ext .ts .",
|
|
21
|
+
"type:check": "tsc --noEmit"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BabelFileResult,
|
|
3
|
+
NodePath,
|
|
4
|
+
transformSync,
|
|
5
|
+
PluginItem,
|
|
6
|
+
} from '@babel/core';
|
|
7
|
+
import generate from '@babel/generator';
|
|
8
|
+
import {
|
|
9
|
+
ObjectMethod,
|
|
10
|
+
isObjectMethod,
|
|
11
|
+
FunctionDeclaration,
|
|
12
|
+
FunctionExpression,
|
|
13
|
+
ArrowFunctionExpression,
|
|
14
|
+
identifier,
|
|
15
|
+
Identifier,
|
|
16
|
+
objectProperty,
|
|
17
|
+
isArrowFunctionExpression,
|
|
18
|
+
variableDeclaration,
|
|
19
|
+
variableDeclarator,
|
|
20
|
+
isBlockStatement,
|
|
21
|
+
functionExpression,
|
|
22
|
+
isFunctionDeclaration,
|
|
23
|
+
VariableDeclaration,
|
|
24
|
+
ExpressionStatement,
|
|
25
|
+
isProgram,
|
|
26
|
+
memberExpression,
|
|
27
|
+
File as BabelFile,
|
|
28
|
+
objectPattern,
|
|
29
|
+
thisExpression,
|
|
30
|
+
isExpression,
|
|
31
|
+
isExpressionStatement,
|
|
32
|
+
} from '@babel/types';
|
|
33
|
+
import * as fs from 'fs';
|
|
34
|
+
import * as convertSourceMap from 'convert-source-map';
|
|
35
|
+
import { strict as assert } from 'assert';
|
|
36
|
+
import { isRelease } from './utils';
|
|
37
|
+
|
|
38
|
+
export function buildWorkletString(
|
|
39
|
+
fun: BabelFile,
|
|
40
|
+
closureVariables: Array<Identifier>,
|
|
41
|
+
name: string,
|
|
42
|
+
inputMap: BabelFileResult['map']
|
|
43
|
+
): Array<string | null | undefined> {
|
|
44
|
+
const draftExpression = (fun.program.body.find((obj) =>
|
|
45
|
+
isFunctionDeclaration(obj)
|
|
46
|
+
) ||
|
|
47
|
+
fun.program.body.find((obj) => isExpressionStatement(obj)) ||
|
|
48
|
+
undefined) as FunctionDeclaration | ExpressionStatement | undefined;
|
|
49
|
+
|
|
50
|
+
assert(draftExpression, "'draftExpression' is undefined");
|
|
51
|
+
|
|
52
|
+
const expression = isFunctionDeclaration(draftExpression)
|
|
53
|
+
? draftExpression
|
|
54
|
+
: draftExpression.expression;
|
|
55
|
+
|
|
56
|
+
assert(
|
|
57
|
+
'params' in expression,
|
|
58
|
+
"'params' property is undefined in 'expression'"
|
|
59
|
+
);
|
|
60
|
+
assert(
|
|
61
|
+
isBlockStatement(expression.body),
|
|
62
|
+
"'expression.body' is not a 'BlockStatement'"
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
const workletFunction = functionExpression(
|
|
66
|
+
identifier(name),
|
|
67
|
+
expression.params,
|
|
68
|
+
expression.body
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
const code = generate(workletFunction).code;
|
|
72
|
+
|
|
73
|
+
assert(inputMap, "'inputMap' is undefined");
|
|
74
|
+
|
|
75
|
+
const includeSourceMap = shouldGenerateSourceMap();
|
|
76
|
+
|
|
77
|
+
if (includeSourceMap) {
|
|
78
|
+
// Clear contents array (should be empty anyways)
|
|
79
|
+
inputMap.sourcesContent = [];
|
|
80
|
+
// Include source contents in source map, because Flipper/iframe is not
|
|
81
|
+
// allowed to read files from disk.
|
|
82
|
+
for (const sourceFile of inputMap.sources) {
|
|
83
|
+
inputMap.sourcesContent.push(
|
|
84
|
+
fs.readFileSync(sourceFile).toString('utf-8')
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const transformed = transformSync(code, {
|
|
90
|
+
plugins: [prependClosureVariablesIfNecessary(closureVariables)],
|
|
91
|
+
compact: !includeSourceMap,
|
|
92
|
+
sourceMaps: includeSourceMap,
|
|
93
|
+
inputSourceMap: inputMap,
|
|
94
|
+
ast: false,
|
|
95
|
+
babelrc: false,
|
|
96
|
+
configFile: false,
|
|
97
|
+
comments: false,
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
assert(transformed, "'transformed' is null");
|
|
101
|
+
|
|
102
|
+
let sourceMap;
|
|
103
|
+
if (includeSourceMap) {
|
|
104
|
+
sourceMap = convertSourceMap.fromObject(transformed.map).toObject();
|
|
105
|
+
// sourcesContent field contains a full source code of the file which contains the worklet
|
|
106
|
+
// and is not needed by the source map interpreter in order to symbolicate a stack trace.
|
|
107
|
+
// Therefore, we remove it to reduce the bandwith and avoid sending it potentially multiple times
|
|
108
|
+
// in files that contain multiple worklets. Along with sourcesContent.
|
|
109
|
+
delete sourceMap.sourcesContent;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return [transformed.code, JSON.stringify(sourceMap)];
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function shouldGenerateSourceMap() {
|
|
116
|
+
if (isRelease()) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// We want to detect this, so we can disable source maps (because they break
|
|
121
|
+
// snapshot tests with jest).
|
|
122
|
+
if (process.env.REANIMATED_JEST_DISABLE_SOURCEMAP === 'jest') {
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function prependClosure(
|
|
130
|
+
path: NodePath<
|
|
131
|
+
| FunctionDeclaration
|
|
132
|
+
| FunctionExpression
|
|
133
|
+
| ArrowFunctionExpression
|
|
134
|
+
| ObjectMethod
|
|
135
|
+
>,
|
|
136
|
+
closureVariables: Array<Identifier>,
|
|
137
|
+
closureDeclaration: VariableDeclaration
|
|
138
|
+
) {
|
|
139
|
+
if (closureVariables.length === 0 || !isProgram(path.parent)) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (!isExpression(path.node.body)) {
|
|
144
|
+
path.node.body.body.unshift(closureDeclaration);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function prependRecursiveDeclaration(
|
|
149
|
+
path: NodePath<
|
|
150
|
+
| FunctionDeclaration
|
|
151
|
+
| FunctionExpression
|
|
152
|
+
| ArrowFunctionExpression
|
|
153
|
+
| ObjectMethod
|
|
154
|
+
>
|
|
155
|
+
) {
|
|
156
|
+
if (
|
|
157
|
+
isProgram(path.parent) &&
|
|
158
|
+
!isArrowFunctionExpression(path.node) &&
|
|
159
|
+
!isObjectMethod(path.node) &&
|
|
160
|
+
path.node.id &&
|
|
161
|
+
path.scope.parent
|
|
162
|
+
) {
|
|
163
|
+
const hasRecursiveCalls =
|
|
164
|
+
path.scope.parent.bindings[path.node.id.name]?.references > 0;
|
|
165
|
+
if (hasRecursiveCalls) {
|
|
166
|
+
path.node.body.body.unshift(
|
|
167
|
+
variableDeclaration('const', [
|
|
168
|
+
variableDeclarator(
|
|
169
|
+
identifier(path.node.id.name),
|
|
170
|
+
memberExpression(thisExpression(), identifier('_recur'))
|
|
171
|
+
),
|
|
172
|
+
])
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function prependClosureVariablesIfNecessary(
|
|
179
|
+
closureVariables: Array<Identifier>
|
|
180
|
+
): PluginItem {
|
|
181
|
+
const closureDeclaration = variableDeclaration('const', [
|
|
182
|
+
variableDeclarator(
|
|
183
|
+
objectPattern(
|
|
184
|
+
closureVariables.map((variable) =>
|
|
185
|
+
objectProperty(
|
|
186
|
+
identifier(variable.name),
|
|
187
|
+
identifier(variable.name),
|
|
188
|
+
false,
|
|
189
|
+
true
|
|
190
|
+
)
|
|
191
|
+
)
|
|
192
|
+
),
|
|
193
|
+
memberExpression(thisExpression(), identifier('_closure'))
|
|
194
|
+
),
|
|
195
|
+
]);
|
|
196
|
+
|
|
197
|
+
return {
|
|
198
|
+
visitor: {
|
|
199
|
+
'FunctionDeclaration|FunctionExpression|ArrowFunctionExpression|ObjectMethod':
|
|
200
|
+
(
|
|
201
|
+
path: NodePath<
|
|
202
|
+
| FunctionDeclaration
|
|
203
|
+
| FunctionExpression
|
|
204
|
+
| ArrowFunctionExpression
|
|
205
|
+
| ObjectMethod
|
|
206
|
+
>
|
|
207
|
+
) => {
|
|
208
|
+
prependClosure(path, closureVariables, closureDeclaration);
|
|
209
|
+
prependRecursiveDeclaration(path);
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
};
|
|
213
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export const globals = new Set([
|
|
2
|
+
'this',
|
|
3
|
+
'console',
|
|
4
|
+
'performance',
|
|
5
|
+
'Date',
|
|
6
|
+
'Array',
|
|
7
|
+
'ArrayBuffer',
|
|
8
|
+
'Int8Array',
|
|
9
|
+
'Int16Array',
|
|
10
|
+
'Int32Array',
|
|
11
|
+
'Uint8Array',
|
|
12
|
+
'Uint8ClampedArray',
|
|
13
|
+
'Uint16Array',
|
|
14
|
+
'Uint32Array',
|
|
15
|
+
'Float32Array',
|
|
16
|
+
'Float64Array',
|
|
17
|
+
'HermesInternal',
|
|
18
|
+
'JSON',
|
|
19
|
+
'Math',
|
|
20
|
+
'Number',
|
|
21
|
+
'Object',
|
|
22
|
+
'String',
|
|
23
|
+
'Symbol',
|
|
24
|
+
'undefined',
|
|
25
|
+
'null',
|
|
26
|
+
'UIManager',
|
|
27
|
+
'requestAnimationFrame',
|
|
28
|
+
'setImmediate',
|
|
29
|
+
'queueMicrotask',
|
|
30
|
+
'_WORKLET',
|
|
31
|
+
'arguments',
|
|
32
|
+
'Boolean',
|
|
33
|
+
'parseInt',
|
|
34
|
+
'parseFloat',
|
|
35
|
+
'Map',
|
|
36
|
+
'WeakMap',
|
|
37
|
+
'Proxy',
|
|
38
|
+
'WeakRef',
|
|
39
|
+
'Set',
|
|
40
|
+
'_log',
|
|
41
|
+
'_scheduleOnJS',
|
|
42
|
+
'_makeShareableClone',
|
|
43
|
+
'_updateDataSynchronously',
|
|
44
|
+
'eval',
|
|
45
|
+
'_updatePropsPaper',
|
|
46
|
+
'_updatePropsFabric',
|
|
47
|
+
'_removeShadowNodeFromRegistry',
|
|
48
|
+
'RegExp',
|
|
49
|
+
'Error',
|
|
50
|
+
'__ErrorUtils',
|
|
51
|
+
'global',
|
|
52
|
+
'_measure',
|
|
53
|
+
'_scrollTo',
|
|
54
|
+
'_dispatchCommand',
|
|
55
|
+
'_setGestureState',
|
|
56
|
+
'isNaN',
|
|
57
|
+
'LayoutAnimationRepository',
|
|
58
|
+
'_notifyAboutProgress',
|
|
59
|
+
'_notifyAboutEnd',
|
|
60
|
+
]);
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { NodePath } from '@babel/core';
|
|
2
|
+
import {
|
|
3
|
+
DirectiveLiteral,
|
|
4
|
+
expressionStatement,
|
|
5
|
+
assignmentExpression,
|
|
6
|
+
memberExpression,
|
|
7
|
+
identifier,
|
|
8
|
+
stringLiteral,
|
|
9
|
+
FunctionDeclaration,
|
|
10
|
+
} from '@babel/types';
|
|
11
|
+
|
|
12
|
+
export function injectVersion(path: NodePath<DirectiveLiteral>) {
|
|
13
|
+
// We want to inject plugin's version only once,
|
|
14
|
+
// hence we have a Directive Literal line in Reanimated code.
|
|
15
|
+
// See src/reanimated2/platform-specific/checkPluginVersion.ts
|
|
16
|
+
// to see the details of this implementation.
|
|
17
|
+
if (path.node.value !== 'inject Reanimated Babel plugin version') {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const injectedName = '_REANIMATED_VERSION_BABEL_PLUGIN';
|
|
21
|
+
const versionString = require('../../package.json').version;
|
|
22
|
+
const pluginVersionNode = expressionStatement(
|
|
23
|
+
assignmentExpression(
|
|
24
|
+
'=',
|
|
25
|
+
memberExpression(identifier('global'), identifier(injectedName)),
|
|
26
|
+
stringLiteral(versionString)
|
|
27
|
+
)
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
// Function that contains injection directive literal is a FunctionDeclaration.
|
|
31
|
+
const functionParent = (
|
|
32
|
+
path.getFunctionParent() as NodePath<FunctionDeclaration>
|
|
33
|
+
).node;
|
|
34
|
+
// DirectiveLiteral is in property of its function parent 'directives' hence we cannot just replace it.
|
|
35
|
+
functionParent.body.directives = [];
|
|
36
|
+
functionParent.body.body.unshift(pluginVersionNode);
|
|
37
|
+
}
|
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
import { NodePath, transformSync, traverse } from '@babel/core';
|
|
2
|
+
import generate from '@babel/generator';
|
|
3
|
+
import {
|
|
4
|
+
ObjectMethod,
|
|
5
|
+
isObjectMethod,
|
|
6
|
+
FunctionDeclaration,
|
|
7
|
+
FunctionExpression,
|
|
8
|
+
ArrowFunctionExpression,
|
|
9
|
+
identifier,
|
|
10
|
+
Identifier,
|
|
11
|
+
objectProperty,
|
|
12
|
+
variableDeclaration,
|
|
13
|
+
variableDeclarator,
|
|
14
|
+
cloneNode,
|
|
15
|
+
isBlockStatement,
|
|
16
|
+
functionExpression,
|
|
17
|
+
objectExpression,
|
|
18
|
+
stringLiteral,
|
|
19
|
+
isFunctionDeclaration,
|
|
20
|
+
VariableDeclaration,
|
|
21
|
+
ExpressionStatement,
|
|
22
|
+
ReturnStatement,
|
|
23
|
+
isProgram,
|
|
24
|
+
isObjectProperty,
|
|
25
|
+
isMemberExpression,
|
|
26
|
+
isObjectExpression,
|
|
27
|
+
expressionStatement,
|
|
28
|
+
assignmentExpression,
|
|
29
|
+
memberExpression,
|
|
30
|
+
numericLiteral,
|
|
31
|
+
arrayExpression,
|
|
32
|
+
newExpression,
|
|
33
|
+
returnStatement,
|
|
34
|
+
blockStatement,
|
|
35
|
+
isFunctionExpression,
|
|
36
|
+
isIdentifier,
|
|
37
|
+
File as BabelFile,
|
|
38
|
+
} from '@babel/types';
|
|
39
|
+
import { ReanimatedPluginPass } from './types';
|
|
40
|
+
import { isRelease } from './utils';
|
|
41
|
+
import { strict as assert } from 'assert';
|
|
42
|
+
import { globals } from './commonObjects';
|
|
43
|
+
import { relative } from 'path';
|
|
44
|
+
import { buildWorkletString } from './buildWorkletString';
|
|
45
|
+
|
|
46
|
+
const version = require('../../package.json').version;
|
|
47
|
+
|
|
48
|
+
export function makeWorklet(
|
|
49
|
+
fun: NodePath<
|
|
50
|
+
| FunctionDeclaration
|
|
51
|
+
| FunctionExpression
|
|
52
|
+
| ObjectMethod
|
|
53
|
+
| ArrowFunctionExpression
|
|
54
|
+
>,
|
|
55
|
+
state: ReanimatedPluginPass
|
|
56
|
+
): FunctionExpression {
|
|
57
|
+
// Returns a new FunctionExpression which is a workletized version of provided
|
|
58
|
+
// FunctionDeclaration, FunctionExpression, ArrowFunctionExpression or ObjectMethod.
|
|
59
|
+
|
|
60
|
+
const functionName = makeWorkletName(fun);
|
|
61
|
+
|
|
62
|
+
// remove 'worklet'; directive before generating string
|
|
63
|
+
fun.traverse({
|
|
64
|
+
DirectiveLiteral(path) {
|
|
65
|
+
if (path.node.value === 'worklet' && path.getFunctionParent() === fun) {
|
|
66
|
+
path.parentPath.remove();
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
// We use copy because some of the plugins don't update bindings and
|
|
72
|
+
// some even break them
|
|
73
|
+
assert(state.file.opts.filename, "'state.file.opts.filename' is undefined");
|
|
74
|
+
|
|
75
|
+
const codeObject = generate(fun.node, {
|
|
76
|
+
sourceMaps: true,
|
|
77
|
+
sourceFileName: state.file.opts.filename,
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
// We need to add a newline at the end, because there could potentially be a
|
|
81
|
+
// comment after the function that gets included here, and then the closing
|
|
82
|
+
// bracket would become part of the comment thus resulting in an error, since
|
|
83
|
+
// there is a missing closing bracket.
|
|
84
|
+
codeObject.code =
|
|
85
|
+
'(' + (isObjectMethod(fun) ? 'function ' : '') + codeObject.code + '\n)';
|
|
86
|
+
|
|
87
|
+
const transformed = transformSync(codeObject.code, {
|
|
88
|
+
filename: state.file.opts.filename,
|
|
89
|
+
presets: ['@babel/preset-typescript'],
|
|
90
|
+
plugins: [
|
|
91
|
+
'@babel/plugin-transform-shorthand-properties',
|
|
92
|
+
'@babel/plugin-transform-arrow-functions',
|
|
93
|
+
'@babel/plugin-proposal-optional-chaining',
|
|
94
|
+
'@babel/plugin-proposal-nullish-coalescing-operator',
|
|
95
|
+
['@babel/plugin-transform-template-literals', { loose: true }],
|
|
96
|
+
],
|
|
97
|
+
ast: true,
|
|
98
|
+
babelrc: false,
|
|
99
|
+
configFile: false,
|
|
100
|
+
inputSourceMap: codeObject.map,
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
assert(transformed, "'transformed' is undefined");
|
|
104
|
+
assert(transformed.ast, "'transformed.ast' is undefined");
|
|
105
|
+
|
|
106
|
+
const variables = makeArrayFromCapturedBindings(transformed.ast, fun);
|
|
107
|
+
|
|
108
|
+
const privateFunctionId = identifier('_f');
|
|
109
|
+
const clone = cloneNode(fun.node);
|
|
110
|
+
const funExpression = isBlockStatement(clone.body)
|
|
111
|
+
? functionExpression(null, clone.params, clone.body)
|
|
112
|
+
: clone;
|
|
113
|
+
|
|
114
|
+
const [funString, sourceMapString] = buildWorkletString(
|
|
115
|
+
transformed.ast,
|
|
116
|
+
variables,
|
|
117
|
+
functionName,
|
|
118
|
+
transformed.map
|
|
119
|
+
);
|
|
120
|
+
assert(funString, "'funString' is undefined");
|
|
121
|
+
const workletHash = hash(funString);
|
|
122
|
+
|
|
123
|
+
let location = state.file.opts.filename;
|
|
124
|
+
if (state.opts.relativeSourceLocation) {
|
|
125
|
+
location = relative(state.cwd, location);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
let lineOffset = 1;
|
|
129
|
+
if (variables.length > 0) {
|
|
130
|
+
// When worklet captures some variables, we append closure destructing at
|
|
131
|
+
// the beginning of the function body. This effectively results in line
|
|
132
|
+
// numbers shifting by the number of captured variables (size of the
|
|
133
|
+
// closure) + 2 (for the opening and closing brackets of the destruct
|
|
134
|
+
// statement)
|
|
135
|
+
lineOffset -= variables.length + 2;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const pathForStringDefinitions = fun.parentPath.isProgram()
|
|
139
|
+
? fun
|
|
140
|
+
: fun.findParent((path) => isProgram(path.parentPath));
|
|
141
|
+
assert(pathForStringDefinitions, "'pathForStringDefinitions' is null");
|
|
142
|
+
assert(
|
|
143
|
+
pathForStringDefinitions.parentPath,
|
|
144
|
+
"'pathForStringDefinitions.parentPath' is null"
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
const initDataId =
|
|
148
|
+
pathForStringDefinitions.parentPath.scope.generateUidIdentifier(
|
|
149
|
+
`worklet_${workletHash}_init_data`
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
const initDataObjectExpression = objectExpression([
|
|
153
|
+
objectProperty(identifier('code'), stringLiteral(funString)),
|
|
154
|
+
objectProperty(identifier('location'), stringLiteral(location)),
|
|
155
|
+
]);
|
|
156
|
+
|
|
157
|
+
if (sourceMapString) {
|
|
158
|
+
initDataObjectExpression.properties.push(
|
|
159
|
+
objectProperty(identifier('sourceMap'), stringLiteral(sourceMapString))
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
pathForStringDefinitions.insertBefore(
|
|
164
|
+
variableDeclaration('const', [
|
|
165
|
+
variableDeclarator(initDataId, initDataObjectExpression),
|
|
166
|
+
])
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
assert(
|
|
170
|
+
!isFunctionDeclaration(funExpression),
|
|
171
|
+
"'funExpression' is a 'FunctionDeclaration'"
|
|
172
|
+
);
|
|
173
|
+
assert(
|
|
174
|
+
!isObjectMethod(funExpression),
|
|
175
|
+
"'funExpression' is an 'ObjectMethod'"
|
|
176
|
+
);
|
|
177
|
+
|
|
178
|
+
const statements: Array<
|
|
179
|
+
VariableDeclaration | ExpressionStatement | ReturnStatement
|
|
180
|
+
> = [
|
|
181
|
+
variableDeclaration('const', [
|
|
182
|
+
variableDeclarator(privateFunctionId, funExpression),
|
|
183
|
+
]),
|
|
184
|
+
expressionStatement(
|
|
185
|
+
assignmentExpression(
|
|
186
|
+
'=',
|
|
187
|
+
memberExpression(privateFunctionId, identifier('_closure'), false),
|
|
188
|
+
objectExpression(
|
|
189
|
+
variables.map((variable) =>
|
|
190
|
+
objectProperty(identifier(variable.name), variable, false, true)
|
|
191
|
+
)
|
|
192
|
+
)
|
|
193
|
+
)
|
|
194
|
+
),
|
|
195
|
+
expressionStatement(
|
|
196
|
+
assignmentExpression(
|
|
197
|
+
'=',
|
|
198
|
+
memberExpression(privateFunctionId, identifier('__initData'), false),
|
|
199
|
+
initDataId
|
|
200
|
+
)
|
|
201
|
+
),
|
|
202
|
+
expressionStatement(
|
|
203
|
+
assignmentExpression(
|
|
204
|
+
'=',
|
|
205
|
+
memberExpression(privateFunctionId, identifier('__workletHash'), false),
|
|
206
|
+
numericLiteral(workletHash)
|
|
207
|
+
)
|
|
208
|
+
),
|
|
209
|
+
];
|
|
210
|
+
|
|
211
|
+
if (!isRelease()) {
|
|
212
|
+
statements.unshift(
|
|
213
|
+
variableDeclaration('const', [
|
|
214
|
+
variableDeclarator(
|
|
215
|
+
identifier('_e'),
|
|
216
|
+
arrayExpression([
|
|
217
|
+
newExpression(
|
|
218
|
+
memberExpression(identifier('global'), identifier('Error')),
|
|
219
|
+
[]
|
|
220
|
+
),
|
|
221
|
+
numericLiteral(lineOffset),
|
|
222
|
+
numericLiteral(-27), // the placement of opening bracket after Exception in line that defined '_e' variable
|
|
223
|
+
])
|
|
224
|
+
),
|
|
225
|
+
])
|
|
226
|
+
);
|
|
227
|
+
statements.push(
|
|
228
|
+
expressionStatement(
|
|
229
|
+
assignmentExpression(
|
|
230
|
+
'=',
|
|
231
|
+
memberExpression(
|
|
232
|
+
privateFunctionId,
|
|
233
|
+
identifier('__stackDetails'),
|
|
234
|
+
false
|
|
235
|
+
),
|
|
236
|
+
identifier('_e')
|
|
237
|
+
)
|
|
238
|
+
)
|
|
239
|
+
);
|
|
240
|
+
if (shouldInjectVersion()) {
|
|
241
|
+
statements.push(
|
|
242
|
+
expressionStatement(
|
|
243
|
+
assignmentExpression(
|
|
244
|
+
'=',
|
|
245
|
+
memberExpression(privateFunctionId, identifier('__version'), false),
|
|
246
|
+
stringLiteral(version)
|
|
247
|
+
)
|
|
248
|
+
)
|
|
249
|
+
);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
statements.push(returnStatement(privateFunctionId));
|
|
254
|
+
|
|
255
|
+
const newFun = functionExpression(undefined, [], blockStatement(statements));
|
|
256
|
+
|
|
257
|
+
return newFun;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
function shouldInjectVersion() {
|
|
261
|
+
// We don't inject version in release since cache is reset there anyway
|
|
262
|
+
if (isRelease()) {
|
|
263
|
+
return false;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// We don't want to pollute tests with current version number so we disable it
|
|
267
|
+
// for all tests (except one)
|
|
268
|
+
if (process.env.REANIMATED_JEST_DISABLE_VERSION === 'jest') {
|
|
269
|
+
return false;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
return true;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
function hash(str: string) {
|
|
276
|
+
let i = str.length;
|
|
277
|
+
let hash1 = 5381;
|
|
278
|
+
let hash2 = 52711;
|
|
279
|
+
|
|
280
|
+
while (i--) {
|
|
281
|
+
const char = str.charCodeAt(i);
|
|
282
|
+
// eslint-disable-next-line no-bitwise
|
|
283
|
+
hash1 = (hash1 * 33) ^ char;
|
|
284
|
+
// eslint-disable-next-line no-bitwise
|
|
285
|
+
hash2 = (hash2 * 33) ^ char;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// eslint-disable-next-line no-bitwise
|
|
289
|
+
return (hash1 >>> 0) * 4096 + (hash2 >>> 0);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function makeWorkletName(
|
|
293
|
+
fun: NodePath<
|
|
294
|
+
| FunctionDeclaration
|
|
295
|
+
| FunctionExpression
|
|
296
|
+
| ObjectMethod
|
|
297
|
+
| ArrowFunctionExpression
|
|
298
|
+
>
|
|
299
|
+
) {
|
|
300
|
+
if (isObjectMethod(fun.node) && 'name' in fun.node.key) {
|
|
301
|
+
return fun.node.key.name;
|
|
302
|
+
}
|
|
303
|
+
if (isFunctionDeclaration(fun.node) && fun.node.id) {
|
|
304
|
+
return fun.node.id.name;
|
|
305
|
+
}
|
|
306
|
+
if (isFunctionExpression(fun.node) && isIdentifier(fun.node.id)) {
|
|
307
|
+
return fun.node.id.name;
|
|
308
|
+
}
|
|
309
|
+
return 'anonymous'; // fallback for ArrowFunctionExpression and unnamed FunctionExpression
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
function makeArrayFromCapturedBindings(
|
|
313
|
+
ast: BabelFile,
|
|
314
|
+
fun: NodePath<
|
|
315
|
+
| FunctionDeclaration
|
|
316
|
+
| FunctionExpression
|
|
317
|
+
| ObjectMethod
|
|
318
|
+
| ArrowFunctionExpression
|
|
319
|
+
>
|
|
320
|
+
) {
|
|
321
|
+
const closure = new Map<string, Identifier>();
|
|
322
|
+
|
|
323
|
+
// this traversal looks for variables to capture
|
|
324
|
+
traverse(ast, {
|
|
325
|
+
Identifier(path) {
|
|
326
|
+
// we only capture variables that were declared outside of the scope
|
|
327
|
+
if (!path.isReferencedIdentifier()) {
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
const name = path.node.name;
|
|
331
|
+
// if the function is named and was added to globals we don't want to add it to closure
|
|
332
|
+
// hence we check if identifier has that name
|
|
333
|
+
if (globals.has(name)) {
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
if (
|
|
337
|
+
'id' in fun.node &&
|
|
338
|
+
fun.node.id &&
|
|
339
|
+
fun.node.id.name === name // we don't want to capture function's own name
|
|
340
|
+
) {
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
const parentNode = path.parent;
|
|
345
|
+
|
|
346
|
+
if (
|
|
347
|
+
isMemberExpression(parentNode) &&
|
|
348
|
+
parentNode.property === path.node &&
|
|
349
|
+
!parentNode.computed
|
|
350
|
+
) {
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
if (
|
|
355
|
+
isObjectProperty(parentNode) &&
|
|
356
|
+
isObjectExpression(path.parentPath.parent) &&
|
|
357
|
+
path.node !== parentNode.value
|
|
358
|
+
) {
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
let currentScope = path.scope;
|
|
363
|
+
|
|
364
|
+
while (currentScope != null) {
|
|
365
|
+
if (currentScope.bindings[name] != null) {
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
currentScope = currentScope.parent;
|
|
369
|
+
}
|
|
370
|
+
closure.set(name, path.node);
|
|
371
|
+
},
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
return Array.from(closure.values());
|
|
375
|
+
}
|