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
package/plugin/index.js
CHANGED
|
@@ -1,807 +1 @@
|
|
|
1
|
-
|
|
2
|
-
const generate = require('@babel/generator').default;
|
|
3
|
-
const hash = require('string-hash-64');
|
|
4
|
-
const traverse = require('@babel/traverse').default;
|
|
5
|
-
const { transformSync } = require('@babel/core');
|
|
6
|
-
const fs = require('fs');
|
|
7
|
-
const convertSourceMap = require('convert-source-map');
|
|
8
|
-
/**
|
|
9
|
-
* holds a map of function names as keys and array of argument indexes as values which should be automatically workletized(they have to be functions)(starting from 0)
|
|
10
|
-
*/
|
|
11
|
-
const functionArgsToWorkletize = new Map([
|
|
12
|
-
['useFrameCallback', [0]],
|
|
13
|
-
['useAnimatedStyle', [0]],
|
|
14
|
-
['useAnimatedProps', [0]],
|
|
15
|
-
['createAnimatedPropAdapter', [0]],
|
|
16
|
-
['useDerivedValue', [0]],
|
|
17
|
-
['useAnimatedScrollHandler', [0]],
|
|
18
|
-
['useAnimatedReaction', [0, 1]],
|
|
19
|
-
['useWorkletCallback', [0]],
|
|
20
|
-
// animations' callbacks
|
|
21
|
-
['withTiming', [2]],
|
|
22
|
-
['withSpring', [2]],
|
|
23
|
-
['withDecay', [1]],
|
|
24
|
-
['withRepeat', [3]],
|
|
25
|
-
]);
|
|
26
|
-
|
|
27
|
-
const objectHooks = new Set([
|
|
28
|
-
'useAnimatedGestureHandler',
|
|
29
|
-
'useAnimatedScrollHandler',
|
|
30
|
-
]);
|
|
31
|
-
|
|
32
|
-
const globals = new Set([
|
|
33
|
-
'this',
|
|
34
|
-
'console',
|
|
35
|
-
'performance',
|
|
36
|
-
'Date',
|
|
37
|
-
'Array',
|
|
38
|
-
'ArrayBuffer',
|
|
39
|
-
'Int8Array',
|
|
40
|
-
'Int16Array',
|
|
41
|
-
'Int32Array',
|
|
42
|
-
'Uint8Array',
|
|
43
|
-
'Uint8ClampedArray',
|
|
44
|
-
'Uint16Array',
|
|
45
|
-
'Uint32Array',
|
|
46
|
-
'Float32Array',
|
|
47
|
-
'Float64Array',
|
|
48
|
-
'Date',
|
|
49
|
-
'HermesInternal',
|
|
50
|
-
'JSON',
|
|
51
|
-
'Math',
|
|
52
|
-
'Number',
|
|
53
|
-
'Object',
|
|
54
|
-
'String',
|
|
55
|
-
'Symbol',
|
|
56
|
-
'undefined',
|
|
57
|
-
'null',
|
|
58
|
-
'UIManager',
|
|
59
|
-
'requestAnimationFrame',
|
|
60
|
-
'setImmediate',
|
|
61
|
-
'_WORKLET',
|
|
62
|
-
'arguments',
|
|
63
|
-
'Boolean',
|
|
64
|
-
'parseInt',
|
|
65
|
-
'parseFloat',
|
|
66
|
-
'Map',
|
|
67
|
-
'WeakMap',
|
|
68
|
-
'WeakRef',
|
|
69
|
-
'Set',
|
|
70
|
-
'_log',
|
|
71
|
-
'_scheduleOnJS',
|
|
72
|
-
'_makeShareableClone',
|
|
73
|
-
'_updateDataSynchronously',
|
|
74
|
-
'eval',
|
|
75
|
-
'_updatePropsPaper',
|
|
76
|
-
'_updatePropsFabric',
|
|
77
|
-
'_removeShadowNodeFromRegistry',
|
|
78
|
-
'RegExp',
|
|
79
|
-
'Error',
|
|
80
|
-
'ErrorUtils',
|
|
81
|
-
'global',
|
|
82
|
-
'_measure',
|
|
83
|
-
'_scrollTo',
|
|
84
|
-
'_dispatchCommand',
|
|
85
|
-
'_setGestureState',
|
|
86
|
-
'_getCurrentTime',
|
|
87
|
-
'isNaN',
|
|
88
|
-
'LayoutAnimationRepository',
|
|
89
|
-
'_notifyAboutProgress',
|
|
90
|
-
'_notifyAboutEnd',
|
|
91
|
-
]);
|
|
92
|
-
|
|
93
|
-
const gestureHandlerGestureObjects = new Set([
|
|
94
|
-
// from https://github.com/software-mansion/react-native-gesture-handler/blob/new-api/src/handlers/gestures/gestureObjects.ts
|
|
95
|
-
'Tap',
|
|
96
|
-
'Pan',
|
|
97
|
-
'Pinch',
|
|
98
|
-
'Rotation',
|
|
99
|
-
'Fling',
|
|
100
|
-
'LongPress',
|
|
101
|
-
'ForceTouch',
|
|
102
|
-
'Native',
|
|
103
|
-
'Manual',
|
|
104
|
-
'Race',
|
|
105
|
-
'Simultaneous',
|
|
106
|
-
'Exclusive',
|
|
107
|
-
]);
|
|
108
|
-
|
|
109
|
-
const gestureHandlerBuilderMethods = new Set([
|
|
110
|
-
'onBegin',
|
|
111
|
-
'onStart',
|
|
112
|
-
'onEnd',
|
|
113
|
-
'onFinalize',
|
|
114
|
-
'onUpdate',
|
|
115
|
-
'onChange',
|
|
116
|
-
'onTouchesDown',
|
|
117
|
-
'onTouchesMove',
|
|
118
|
-
'onTouchesUp',
|
|
119
|
-
'onTouchesCancelled',
|
|
120
|
-
]);
|
|
121
|
-
|
|
122
|
-
function isRelease() {
|
|
123
|
-
return ['production', 'release'].includes(process.env.BABEL_ENV);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
function shouldGenerateSourceMap() {
|
|
127
|
-
if (isRelease()) {
|
|
128
|
-
return false;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
if (process.env.REANIMATED_PLUGIN_TESTS === 'jest') {
|
|
132
|
-
// We want to detect this, so we can disable source maps (because they break
|
|
133
|
-
// snapshot tests with jest).
|
|
134
|
-
return false;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
return true;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
function buildWorkletString(t, fun, closureVariables, name, inputMap) {
|
|
141
|
-
function prependClosureVariablesIfNecessary() {
|
|
142
|
-
const closureDeclaration = t.variableDeclaration('const', [
|
|
143
|
-
t.variableDeclarator(
|
|
144
|
-
t.objectPattern(
|
|
145
|
-
closureVariables.map((variable) =>
|
|
146
|
-
t.objectProperty(
|
|
147
|
-
t.identifier(variable.name),
|
|
148
|
-
t.identifier(variable.name),
|
|
149
|
-
false,
|
|
150
|
-
true
|
|
151
|
-
)
|
|
152
|
-
)
|
|
153
|
-
),
|
|
154
|
-
t.memberExpression(t.thisExpression(), t.identifier('_closure'))
|
|
155
|
-
),
|
|
156
|
-
]);
|
|
157
|
-
|
|
158
|
-
function prependClosure(path) {
|
|
159
|
-
if (closureVariables.length === 0 || path.parent.type !== 'Program') {
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
path.node.body.body.unshift(closureDeclaration);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
function prepandRecursiveDeclaration(path) {
|
|
167
|
-
if (path.parent.type === 'Program' && path.node.id && path.scope.parent) {
|
|
168
|
-
const hasRecursiveCalls =
|
|
169
|
-
path.scope.parent.bindings[path.node.id.name]?.references > 0;
|
|
170
|
-
if (hasRecursiveCalls) {
|
|
171
|
-
path.node.body.body.unshift(
|
|
172
|
-
t.variableDeclaration('const', [
|
|
173
|
-
t.variableDeclarator(
|
|
174
|
-
t.identifier(path.node.id.name),
|
|
175
|
-
t.memberExpression(t.thisExpression(), t.identifier('_recur'))
|
|
176
|
-
),
|
|
177
|
-
])
|
|
178
|
-
);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
return {
|
|
184
|
-
visitor: {
|
|
185
|
-
'FunctionDeclaration|FunctionExpression|ArrowFunctionExpression|ObjectMethod':
|
|
186
|
-
(path) => {
|
|
187
|
-
prependClosure(path);
|
|
188
|
-
prepandRecursiveDeclaration(path);
|
|
189
|
-
},
|
|
190
|
-
},
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
const expression =
|
|
195
|
-
fun.program.body.find(({ type }) => type === 'FunctionDeclaration') ||
|
|
196
|
-
fun.program.body.find(({ type }) => type === 'ExpressionStatement')
|
|
197
|
-
.expression;
|
|
198
|
-
|
|
199
|
-
const workletFunction = t.functionExpression(
|
|
200
|
-
t.identifier(name),
|
|
201
|
-
expression.params,
|
|
202
|
-
expression.body
|
|
203
|
-
);
|
|
204
|
-
|
|
205
|
-
const code = generate(workletFunction).code;
|
|
206
|
-
|
|
207
|
-
const includeSourceMap = shouldGenerateSourceMap();
|
|
208
|
-
|
|
209
|
-
if (includeSourceMap) {
|
|
210
|
-
// Clear contents array (should be empty anyways)
|
|
211
|
-
inputMap.sourcesContent = [];
|
|
212
|
-
// Include source contents in source map, because Flipper/iframe is not
|
|
213
|
-
// allowed to read files from disk.
|
|
214
|
-
for (const sourceFile of inputMap.sources) {
|
|
215
|
-
inputMap.sourcesContent.push(
|
|
216
|
-
fs.readFileSync(sourceFile).toString('utf-8')
|
|
217
|
-
);
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
const transformed = transformSync(code, {
|
|
222
|
-
plugins: [prependClosureVariablesIfNecessary()],
|
|
223
|
-
compact: !includeSourceMap,
|
|
224
|
-
sourceMaps: includeSourceMap,
|
|
225
|
-
inputSourceMap: inputMap,
|
|
226
|
-
ast: false,
|
|
227
|
-
babelrc: false,
|
|
228
|
-
configFile: false,
|
|
229
|
-
comments: false,
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
let sourceMap;
|
|
233
|
-
if (includeSourceMap) {
|
|
234
|
-
sourceMap = convertSourceMap.fromObject(transformed.map).toObject();
|
|
235
|
-
// sourcesContent field contains a full source code of the file which contains the worklet
|
|
236
|
-
// and is not needed by the source map interpreter in order to symbolicate a stack trace.
|
|
237
|
-
// Therefore, we remove it to reduce the bandwith and avoid sending it potentially multiple times
|
|
238
|
-
// in files that contain multiple worklets. Along with sourcesContent.
|
|
239
|
-
delete sourceMap.sourcesContent;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
return [transformed.code, JSON.stringify(sourceMap)];
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
function makeWorkletName(t, fun) {
|
|
246
|
-
if (t.isObjectMethod(fun)) {
|
|
247
|
-
return fun.node.key.name;
|
|
248
|
-
}
|
|
249
|
-
if (t.isFunctionDeclaration(fun)) {
|
|
250
|
-
return fun.node.id.name;
|
|
251
|
-
}
|
|
252
|
-
if (t.isFunctionExpression(fun) && t.isIdentifier(fun.node.id)) {
|
|
253
|
-
return fun.node.id.name;
|
|
254
|
-
}
|
|
255
|
-
return 'anonymous'; // fallback for ArrowFunctionExpression and unnamed FunctionExpression
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
function makeWorklet(t, fun, state) {
|
|
259
|
-
// Returns a new FunctionExpression which is a workletized version of provided
|
|
260
|
-
// FunctionDeclaration, FunctionExpression, ArrowFunctionExpression or ObjectMethod.
|
|
261
|
-
|
|
262
|
-
const functionName = makeWorkletName(t, fun);
|
|
263
|
-
|
|
264
|
-
const closure = new Map();
|
|
265
|
-
|
|
266
|
-
// remove 'worklet'; directive before generating string
|
|
267
|
-
fun.traverse({
|
|
268
|
-
DirectiveLiteral(path) {
|
|
269
|
-
if (path.node.value === 'worklet' && path.getFunctionParent() === fun) {
|
|
270
|
-
path.parentPath.remove();
|
|
271
|
-
}
|
|
272
|
-
},
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
// We use copy because some of the plugins don't update bindings and
|
|
276
|
-
// some even break them
|
|
277
|
-
|
|
278
|
-
const codeObject = generate(fun.node, {
|
|
279
|
-
sourceMaps: true,
|
|
280
|
-
sourceFileName: state.file.opts.filename,
|
|
281
|
-
});
|
|
282
|
-
|
|
283
|
-
// We need to add a newline at the end, because there could potentially be a
|
|
284
|
-
// comment after the function that gets included here, and then the closing
|
|
285
|
-
// bracket would become part of the comment thus resulting in an error, since
|
|
286
|
-
// there is a missing closing bracket.
|
|
287
|
-
const code =
|
|
288
|
-
'(' + (t.isObjectMethod(fun) ? 'function ' : '') + codeObject.code + '\n)';
|
|
289
|
-
|
|
290
|
-
const transformed = transformSync(code, {
|
|
291
|
-
filename: state.file.opts.filename,
|
|
292
|
-
presets: ['@babel/preset-typescript'],
|
|
293
|
-
plugins: [
|
|
294
|
-
'@babel/plugin-transform-shorthand-properties',
|
|
295
|
-
'@babel/plugin-transform-arrow-functions',
|
|
296
|
-
'@babel/plugin-proposal-optional-chaining',
|
|
297
|
-
'@babel/plugin-proposal-nullish-coalescing-operator',
|
|
298
|
-
['@babel/plugin-transform-template-literals', { loose: true }],
|
|
299
|
-
],
|
|
300
|
-
ast: true,
|
|
301
|
-
babelrc: false,
|
|
302
|
-
configFile: false,
|
|
303
|
-
inputSourceMap: codeObject.map,
|
|
304
|
-
});
|
|
305
|
-
|
|
306
|
-
traverse(transformed.ast, {
|
|
307
|
-
ReferencedIdentifier(path) {
|
|
308
|
-
const name = path.node.name;
|
|
309
|
-
if (globals.has(name) || (fun.node.id && fun.node.id.name === name)) {
|
|
310
|
-
return;
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
const parentNode = path.parent;
|
|
314
|
-
|
|
315
|
-
if (
|
|
316
|
-
parentNode.type === 'MemberExpression' &&
|
|
317
|
-
parentNode.property === path.node &&
|
|
318
|
-
!parentNode.computed
|
|
319
|
-
) {
|
|
320
|
-
return;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
if (
|
|
324
|
-
parentNode.type === 'ObjectProperty' &&
|
|
325
|
-
path.parentPath.parent.type === 'ObjectExpression' &&
|
|
326
|
-
path.node !== parentNode.value
|
|
327
|
-
) {
|
|
328
|
-
return;
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
let currentScope = path.scope;
|
|
332
|
-
|
|
333
|
-
while (currentScope != null) {
|
|
334
|
-
if (currentScope.bindings[name] != null) {
|
|
335
|
-
return;
|
|
336
|
-
}
|
|
337
|
-
currentScope = currentScope.parent;
|
|
338
|
-
}
|
|
339
|
-
closure.set(name, path.node);
|
|
340
|
-
},
|
|
341
|
-
});
|
|
342
|
-
|
|
343
|
-
const variables = Array.from(closure.values());
|
|
344
|
-
|
|
345
|
-
const privateFunctionId = t.identifier('_f');
|
|
346
|
-
const clone = t.cloneNode(fun.node);
|
|
347
|
-
let funExpression;
|
|
348
|
-
if (clone.body.type === 'BlockStatement') {
|
|
349
|
-
funExpression = t.functionExpression(null, clone.params, clone.body);
|
|
350
|
-
} else {
|
|
351
|
-
funExpression = clone;
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
const [funString, sourceMapString] = buildWorkletString(
|
|
355
|
-
t,
|
|
356
|
-
transformed.ast,
|
|
357
|
-
variables,
|
|
358
|
-
functionName,
|
|
359
|
-
transformed.map
|
|
360
|
-
);
|
|
361
|
-
const workletHash = hash(funString);
|
|
362
|
-
|
|
363
|
-
let location = state.file.opts.filename;
|
|
364
|
-
if (state.opts && state.opts.relativeSourceLocation) {
|
|
365
|
-
const path = require('path');
|
|
366
|
-
location = path.relative(state.cwd, location);
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
let lineOffset = 1;
|
|
370
|
-
if (closure.size > 0) {
|
|
371
|
-
// When worklet captures some variables, we append closure destructing at
|
|
372
|
-
// the beginning of the function body. This effectively results in line
|
|
373
|
-
// numbers shifting by the number of captured variables (size of the
|
|
374
|
-
// closure) + 2 (for the opening and closing brackets of the destruct
|
|
375
|
-
// statement)
|
|
376
|
-
lineOffset -= closure.size + 2;
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
const pathForStringDefinitions = fun.parentPath.isProgram()
|
|
380
|
-
? fun
|
|
381
|
-
: fun.findParent((path) => path.parentPath.isProgram());
|
|
382
|
-
|
|
383
|
-
const initDataId =
|
|
384
|
-
pathForStringDefinitions.parentPath.scope.generateUidIdentifier(
|
|
385
|
-
`worklet_${workletHash}_init_data`
|
|
386
|
-
);
|
|
387
|
-
|
|
388
|
-
const initDataObjectExpression = t.objectExpression([
|
|
389
|
-
t.objectProperty(t.identifier('code'), t.stringLiteral(funString)),
|
|
390
|
-
t.objectProperty(t.identifier('location'), t.stringLiteral(location)),
|
|
391
|
-
]);
|
|
392
|
-
|
|
393
|
-
if (sourceMapString) {
|
|
394
|
-
initDataObjectExpression.properties.push(
|
|
395
|
-
t.objectProperty(
|
|
396
|
-
t.identifier('sourceMap'),
|
|
397
|
-
t.stringLiteral(sourceMapString)
|
|
398
|
-
)
|
|
399
|
-
);
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
pathForStringDefinitions.insertBefore(
|
|
403
|
-
t.variableDeclaration('const', [
|
|
404
|
-
t.variableDeclarator(initDataId, initDataObjectExpression),
|
|
405
|
-
])
|
|
406
|
-
);
|
|
407
|
-
|
|
408
|
-
const statements = [
|
|
409
|
-
t.variableDeclaration('const', [
|
|
410
|
-
t.variableDeclarator(privateFunctionId, funExpression),
|
|
411
|
-
]),
|
|
412
|
-
t.expressionStatement(
|
|
413
|
-
t.assignmentExpression(
|
|
414
|
-
'=',
|
|
415
|
-
t.memberExpression(privateFunctionId, t.identifier('_closure'), false),
|
|
416
|
-
t.objectExpression(
|
|
417
|
-
variables.map((variable) =>
|
|
418
|
-
t.objectProperty(t.identifier(variable.name), variable, false, true)
|
|
419
|
-
)
|
|
420
|
-
)
|
|
421
|
-
)
|
|
422
|
-
),
|
|
423
|
-
t.expressionStatement(
|
|
424
|
-
t.assignmentExpression(
|
|
425
|
-
'=',
|
|
426
|
-
t.memberExpression(
|
|
427
|
-
privateFunctionId,
|
|
428
|
-
t.identifier('__initData'),
|
|
429
|
-
false
|
|
430
|
-
),
|
|
431
|
-
initDataId
|
|
432
|
-
)
|
|
433
|
-
),
|
|
434
|
-
t.expressionStatement(
|
|
435
|
-
t.assignmentExpression(
|
|
436
|
-
'=',
|
|
437
|
-
t.memberExpression(
|
|
438
|
-
privateFunctionId,
|
|
439
|
-
t.identifier('__workletHash'),
|
|
440
|
-
false
|
|
441
|
-
),
|
|
442
|
-
t.numericLiteral(workletHash)
|
|
443
|
-
)
|
|
444
|
-
),
|
|
445
|
-
];
|
|
446
|
-
|
|
447
|
-
if (!isRelease()) {
|
|
448
|
-
statements.unshift(
|
|
449
|
-
t.variableDeclaration('const', [
|
|
450
|
-
t.variableDeclarator(
|
|
451
|
-
t.identifier('_e'),
|
|
452
|
-
t.arrayExpression([
|
|
453
|
-
t.newExpression(t.identifier('Error'), []),
|
|
454
|
-
t.numericLiteral(lineOffset),
|
|
455
|
-
t.numericLiteral(-20), // the placement of opening bracket after Exception in line that defined '_e' variable
|
|
456
|
-
])
|
|
457
|
-
),
|
|
458
|
-
])
|
|
459
|
-
);
|
|
460
|
-
statements.push(
|
|
461
|
-
t.expressionStatement(
|
|
462
|
-
t.assignmentExpression(
|
|
463
|
-
'=',
|
|
464
|
-
t.memberExpression(
|
|
465
|
-
privateFunctionId,
|
|
466
|
-
t.identifier('__stackDetails'),
|
|
467
|
-
false
|
|
468
|
-
),
|
|
469
|
-
t.identifier('_e')
|
|
470
|
-
)
|
|
471
|
-
)
|
|
472
|
-
);
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
statements.push(t.returnStatement(privateFunctionId));
|
|
476
|
-
|
|
477
|
-
const newFun = t.functionExpression(fun.id, [], t.blockStatement(statements));
|
|
478
|
-
|
|
479
|
-
return newFun;
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
function processWorkletFunction(t, fun, state) {
|
|
483
|
-
// Replaces FunctionDeclaration, FunctionExpression or ArrowFunctionExpression
|
|
484
|
-
// with a workletized version of itself.
|
|
485
|
-
|
|
486
|
-
if (!t.isFunctionParent(fun)) {
|
|
487
|
-
return;
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
const newFun = makeWorklet(t, fun, state);
|
|
491
|
-
|
|
492
|
-
const replacement = t.callExpression(newFun, []);
|
|
493
|
-
|
|
494
|
-
// we check if function needs to be assigned to variable declaration.
|
|
495
|
-
// This is needed if function definition directly in a scope. Some other ways
|
|
496
|
-
// where function definition can be used is for example with variable declaration:
|
|
497
|
-
// const ggg = function foo() { }
|
|
498
|
-
// ^ in such a case we don't need to define variable for the function
|
|
499
|
-
const needDeclaration =
|
|
500
|
-
t.isScopable(fun.parent) || t.isExportNamedDeclaration(fun.parent);
|
|
501
|
-
fun.replaceWith(
|
|
502
|
-
fun.node.id && needDeclaration
|
|
503
|
-
? t.variableDeclaration('const', [
|
|
504
|
-
t.variableDeclarator(fun.node.id, replacement),
|
|
505
|
-
])
|
|
506
|
-
: replacement
|
|
507
|
-
);
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
function processWorkletObjectMethod(t, path, state) {
|
|
511
|
-
// Replaces ObjectMethod with a workletized version of itself.
|
|
512
|
-
|
|
513
|
-
if (!t.isFunctionParent(path)) {
|
|
514
|
-
return;
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
const newFun = makeWorklet(t, path, state);
|
|
518
|
-
|
|
519
|
-
const replacement = t.objectProperty(
|
|
520
|
-
t.identifier(path.node.key.name),
|
|
521
|
-
t.callExpression(newFun, [])
|
|
522
|
-
);
|
|
523
|
-
|
|
524
|
-
path.replaceWith(replacement);
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
function processIfWorkletNode(t, fun, state) {
|
|
528
|
-
fun.traverse({
|
|
529
|
-
DirectiveLiteral(path) {
|
|
530
|
-
const value = path.node.value;
|
|
531
|
-
if (value === 'worklet' && path.getFunctionParent() === fun) {
|
|
532
|
-
// make sure "worklet" is listed among directives for the fun
|
|
533
|
-
// this is necessary as because of some bug, babel will attempt to
|
|
534
|
-
// process replaced function if it is nested inside another function
|
|
535
|
-
const directives = fun.node.body.directives;
|
|
536
|
-
if (
|
|
537
|
-
directives &&
|
|
538
|
-
directives.length > 0 &&
|
|
539
|
-
directives.some(
|
|
540
|
-
(directive) =>
|
|
541
|
-
t.isDirectiveLiteral(directive.value) &&
|
|
542
|
-
directive.value.value === 'worklet'
|
|
543
|
-
)
|
|
544
|
-
) {
|
|
545
|
-
processWorkletFunction(t, fun, state);
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
},
|
|
549
|
-
});
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
function processIfGestureHandlerEventCallbackFunctionNode(t, fun, state) {
|
|
553
|
-
// Auto-workletizes React Native Gesture Handler callback functions.
|
|
554
|
-
// Detects `Gesture.Tap().onEnd(<fun>)` or similar, but skips `something.onEnd(<fun>)`.
|
|
555
|
-
// Supports method chaining as well, e.g. `Gesture.Tap().onStart(<fun1>).onUpdate(<fun2>).onEnd(<fun3>)`.
|
|
556
|
-
|
|
557
|
-
// Example #1: `Gesture.Tap().onEnd(<fun>)`
|
|
558
|
-
/*
|
|
559
|
-
CallExpression(
|
|
560
|
-
callee: MemberExpression(
|
|
561
|
-
object: CallExpression(
|
|
562
|
-
callee: MemberExpression(
|
|
563
|
-
object: Identifier('Gesture')
|
|
564
|
-
property: Identifier('Tap')
|
|
565
|
-
)
|
|
566
|
-
)
|
|
567
|
-
property: Identifier('onEnd')
|
|
568
|
-
)
|
|
569
|
-
arguments: [fun]
|
|
570
|
-
)
|
|
571
|
-
*/
|
|
572
|
-
|
|
573
|
-
// Example #2: `Gesture.Tap().onStart(<fun1>).onUpdate(<fun2>).onEnd(<fun3>)`
|
|
574
|
-
/*
|
|
575
|
-
CallExpression(
|
|
576
|
-
callee: MemberExpression(
|
|
577
|
-
object: CallExpression(
|
|
578
|
-
callee: MemberExpression(
|
|
579
|
-
object: CallExpression(
|
|
580
|
-
callee: MemberExpression(
|
|
581
|
-
object: CallExpression(
|
|
582
|
-
callee: MemberExpression(
|
|
583
|
-
object: Identifier('Gesture')
|
|
584
|
-
property: Identifier('Tap')
|
|
585
|
-
)
|
|
586
|
-
)
|
|
587
|
-
property: Identifier('onStart')
|
|
588
|
-
)
|
|
589
|
-
arguments: [fun1]
|
|
590
|
-
)
|
|
591
|
-
property: Identifier('onUpdate')
|
|
592
|
-
)
|
|
593
|
-
arguments: [fun2]
|
|
594
|
-
)
|
|
595
|
-
property: Identifier('onEnd')
|
|
596
|
-
)
|
|
597
|
-
arguments: [fun3]
|
|
598
|
-
)
|
|
599
|
-
*/
|
|
600
|
-
|
|
601
|
-
if (
|
|
602
|
-
t.isCallExpression(fun.parent) &&
|
|
603
|
-
isGestureObjectEventCallbackMethod(t, fun.parent.callee)
|
|
604
|
-
) {
|
|
605
|
-
processWorkletFunction(t, fun, state);
|
|
606
|
-
}
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
function isGestureObjectEventCallbackMethod(t, node) {
|
|
610
|
-
// Checks if node matches the pattern `Gesture.Foo()[*].onBar`
|
|
611
|
-
// where `[*]` represents any number of method calls.
|
|
612
|
-
return (
|
|
613
|
-
t.isMemberExpression(node) &&
|
|
614
|
-
t.isIdentifier(node.property) &&
|
|
615
|
-
gestureHandlerBuilderMethods.has(node.property.name) &&
|
|
616
|
-
containsGestureObject(t, node.object)
|
|
617
|
-
);
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
function containsGestureObject(t, node) {
|
|
621
|
-
// Checks if node matches the pattern `Gesture.Foo()[*]`
|
|
622
|
-
// where `[*]` represents any number of chained method calls, like `.something(42)`.
|
|
623
|
-
|
|
624
|
-
// direct call
|
|
625
|
-
if (isGestureObject(t, node)) {
|
|
626
|
-
return true;
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
// method chaining
|
|
630
|
-
if (
|
|
631
|
-
t.isCallExpression(node) &&
|
|
632
|
-
t.isMemberExpression(node.callee) &&
|
|
633
|
-
containsGestureObject(t, node.callee.object)
|
|
634
|
-
) {
|
|
635
|
-
return true;
|
|
636
|
-
}
|
|
637
|
-
|
|
638
|
-
return false;
|
|
639
|
-
}
|
|
640
|
-
|
|
641
|
-
function isGestureObject(t, node) {
|
|
642
|
-
// Checks if node matches `Gesture.Tap()` or similar.
|
|
643
|
-
/*
|
|
644
|
-
node: CallExpression(
|
|
645
|
-
callee: MemberExpression(
|
|
646
|
-
object: Identifier('Gesture')
|
|
647
|
-
property: Identifier('Tap')
|
|
648
|
-
)
|
|
649
|
-
)
|
|
650
|
-
*/
|
|
651
|
-
return (
|
|
652
|
-
t.isCallExpression(node) &&
|
|
653
|
-
t.isMemberExpression(node.callee) &&
|
|
654
|
-
t.isIdentifier(node.callee.object) &&
|
|
655
|
-
node.callee.object.name === 'Gesture' &&
|
|
656
|
-
t.isIdentifier(node.callee.property) &&
|
|
657
|
-
gestureHandlerGestureObjects.has(node.callee.property.name)
|
|
658
|
-
);
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
function processWorklets(t, path, state) {
|
|
662
|
-
const callee =
|
|
663
|
-
path.node.callee.type === 'SequenceExpression'
|
|
664
|
-
? path.node.callee.expressions[path.node.callee.expressions.length - 1]
|
|
665
|
-
: path.node.callee;
|
|
666
|
-
|
|
667
|
-
const name =
|
|
668
|
-
callee.type === 'MemberExpression' ? callee.property.name : callee.name;
|
|
669
|
-
|
|
670
|
-
if (
|
|
671
|
-
objectHooks.has(name) &&
|
|
672
|
-
path.get('arguments.0').type === 'ObjectExpression'
|
|
673
|
-
) {
|
|
674
|
-
const properties = path.get('arguments.0.properties');
|
|
675
|
-
for (const property of properties) {
|
|
676
|
-
if (t.isObjectMethod(property)) {
|
|
677
|
-
processWorkletObjectMethod(t, property, state);
|
|
678
|
-
} else {
|
|
679
|
-
const value = property.get('value');
|
|
680
|
-
processWorkletFunction(t, value, state);
|
|
681
|
-
}
|
|
682
|
-
}
|
|
683
|
-
} else {
|
|
684
|
-
const indexes = functionArgsToWorkletize.get(name);
|
|
685
|
-
if (Array.isArray(indexes)) {
|
|
686
|
-
indexes.forEach((index) => {
|
|
687
|
-
processWorkletFunction(t, path.get(`arguments.${index}`), state);
|
|
688
|
-
});
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
function generateInlineStylesWarning(t, memberExpression) {
|
|
694
|
-
// replaces `sharedvalue.value` with `(()=>{console.warn(require('react-native-reanimated').getUseOfValueInStyleWarning());return sharedvalue.value;})()`
|
|
695
|
-
return t.callExpression(
|
|
696
|
-
t.arrowFunctionExpression(
|
|
697
|
-
[],
|
|
698
|
-
t.blockStatement([
|
|
699
|
-
t.expressionStatement(
|
|
700
|
-
t.callExpression(
|
|
701
|
-
t.memberExpression(t.identifier('console'), t.identifier('warn')),
|
|
702
|
-
[
|
|
703
|
-
t.callExpression(
|
|
704
|
-
t.memberExpression(
|
|
705
|
-
t.callExpression(t.identifier('require'), [
|
|
706
|
-
t.stringLiteral('react-native-reanimated'),
|
|
707
|
-
]),
|
|
708
|
-
t.identifier('getUseOfValueInStyleWarning')
|
|
709
|
-
),
|
|
710
|
-
[]
|
|
711
|
-
),
|
|
712
|
-
]
|
|
713
|
-
)
|
|
714
|
-
),
|
|
715
|
-
t.returnStatement(memberExpression.node),
|
|
716
|
-
])
|
|
717
|
-
),
|
|
718
|
-
[]
|
|
719
|
-
);
|
|
720
|
-
}
|
|
721
|
-
|
|
722
|
-
function processPropertyValueForInlineStylesWarning(t, path) {
|
|
723
|
-
// if it's something like object.value then raise a warning
|
|
724
|
-
if (t.isMemberExpression(path)) {
|
|
725
|
-
if (path.get('property').node.name === 'value') {
|
|
726
|
-
path.replaceWith(generateInlineStylesWarning(t, path));
|
|
727
|
-
}
|
|
728
|
-
}
|
|
729
|
-
}
|
|
730
|
-
|
|
731
|
-
function processTransformPropertyForInlineStylesWarning(t, path) {
|
|
732
|
-
if (t.isArrayExpression(path)) {
|
|
733
|
-
const elements = path.get('elements');
|
|
734
|
-
for (const element of elements) {
|
|
735
|
-
if (t.isObjectExpression(element)) {
|
|
736
|
-
processStyleObjectForInlineStylesWarning(t, element);
|
|
737
|
-
}
|
|
738
|
-
}
|
|
739
|
-
}
|
|
740
|
-
}
|
|
741
|
-
|
|
742
|
-
function processStyleObjectForInlineStylesWarning(t, path) {
|
|
743
|
-
const properties = path.get('properties');
|
|
744
|
-
for (const property of properties) {
|
|
745
|
-
const value = property.get('value');
|
|
746
|
-
if (t.isProperty(property)) {
|
|
747
|
-
if (property.get('key').node.name === 'transform') {
|
|
748
|
-
processTransformPropertyForInlineStylesWarning(t, value);
|
|
749
|
-
} else {
|
|
750
|
-
processPropertyValueForInlineStylesWarning(t, value);
|
|
751
|
-
}
|
|
752
|
-
}
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
|
|
756
|
-
function processInlineStylesWarning(t, path, state) {
|
|
757
|
-
if (isRelease()) return;
|
|
758
|
-
if (state.opts.disableInlineStylesWarning) return;
|
|
759
|
-
if (path.get('name').node.name !== 'style') return;
|
|
760
|
-
if (!t.isJSXExpressionContainer(path.get('value'))) return;
|
|
761
|
-
|
|
762
|
-
const expression = path.get('value').get('expression');
|
|
763
|
-
// style={[{...}, {...}]}
|
|
764
|
-
if (t.isArrayExpression(expression)) {
|
|
765
|
-
const elements = expression.get('elements');
|
|
766
|
-
for (const element of elements) {
|
|
767
|
-
if (t.isObjectExpression(element)) {
|
|
768
|
-
processStyleObjectForInlineStylesWarning(t, element);
|
|
769
|
-
}
|
|
770
|
-
}
|
|
771
|
-
}
|
|
772
|
-
// style={{...}}
|
|
773
|
-
else if (t.isObjectExpression(expression)) {
|
|
774
|
-
processStyleObjectForInlineStylesWarning(t, expression);
|
|
775
|
-
}
|
|
776
|
-
}
|
|
777
|
-
|
|
778
|
-
module.exports = function ({ types: t }) {
|
|
779
|
-
return {
|
|
780
|
-
pre() {
|
|
781
|
-
// allows adding custom globals such as host-functions
|
|
782
|
-
if (this.opts != null && Array.isArray(this.opts.globals)) {
|
|
783
|
-
this.opts.globals.forEach((name) => {
|
|
784
|
-
globals.add(name);
|
|
785
|
-
});
|
|
786
|
-
}
|
|
787
|
-
},
|
|
788
|
-
visitor: {
|
|
789
|
-
CallExpression: {
|
|
790
|
-
enter(path, state) {
|
|
791
|
-
processWorklets(t, path, state);
|
|
792
|
-
},
|
|
793
|
-
},
|
|
794
|
-
'FunctionDeclaration|FunctionExpression|ArrowFunctionExpression': {
|
|
795
|
-
enter(path, state) {
|
|
796
|
-
processIfWorkletNode(t, path, state);
|
|
797
|
-
processIfGestureHandlerEventCallbackFunctionNode(t, path, state);
|
|
798
|
-
},
|
|
799
|
-
},
|
|
800
|
-
JSXAttribute: {
|
|
801
|
-
enter(path, state) {
|
|
802
|
-
processInlineStylesWarning(t, path, state);
|
|
803
|
-
},
|
|
804
|
-
},
|
|
805
|
-
},
|
|
806
|
-
};
|
|
807
|
-
};
|
|
1
|
+
module.exports = require('./build/plugin.js');
|