react-native-reanimated 3.0.0-rc.9 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Common/cpp/AnimatedSensor/AnimatedSensorModule.cpp +30 -12
- package/Common/cpp/AnimatedSensor/AnimatedSensorModule.h +2 -0
- package/Common/cpp/Fabric/FabricUtils.cpp +3 -107
- package/Common/cpp/Fabric/FabricUtils.h +3 -24
- package/Common/cpp/Fabric/ReanimatedUIManagerBinding.cpp +54 -37
- package/Common/cpp/LayoutAnimations/LayoutAnimationType.h +8 -0
- package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.cpp +81 -26
- package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.h +20 -3
- package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +105 -109
- package/Common/cpp/NativeModules/NativeReanimatedModule.h +19 -12
- package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +15 -7
- package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.h +6 -2
- package/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.cpp +20 -1
- package/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.h +9 -0
- package/Common/cpp/ReanimatedRuntime/ReanimatedRuntime.cpp +5 -1
- package/Common/cpp/Registries/EventHandlerRegistry.cpp +8 -34
- package/Common/cpp/Registries/EventHandlerRegistry.h +7 -13
- package/Common/cpp/SharedItems/Shareables.cpp +9 -63
- package/Common/cpp/SharedItems/Shareables.h +77 -72
- package/Common/cpp/Tools/CollectionUtils.h +14 -0
- package/Common/cpp/Tools/JsiUtils.cpp +26 -0
- package/Common/cpp/Tools/JsiUtils.h +176 -0
- package/Common/cpp/Tools/PlatformDepMethodsHolder.h +5 -5
- package/Common/cpp/Tools/ReanimatedVersion.cpp +17 -0
- package/Common/cpp/Tools/ReanimatedVersion.h +11 -0
- package/Common/cpp/Tools/RuntimeDecorator.cpp +49 -230
- package/Common/cpp/Tools/RuntimeDecorator.h +0 -2
- package/Common/cpp/Tools/WorkletEventHandler.cpp +3 -2
- package/Common/cpp/Tools/WorkletEventHandler.h +14 -6
- package/RNReanimated.podspec +2 -1
- package/android/CMakeLists.txt +188 -181
- package/android/build.gradle +362 -311
- package/android/proguard-rules.pro +2 -0
- package/android/src/fabric/java/com/swmansion/reanimated/NativeProxy.java +63 -295
- package/android/src/main/cpp/LayoutAnimations.cpp +35 -5
- package/android/src/main/cpp/LayoutAnimations.h +23 -6
- package/android/src/main/cpp/NativeProxy.cpp +143 -98
- package/android/src/main/cpp/NativeProxy.h +22 -28
- package/android/src/main/java/com/swmansion/reanimated/ReanimatedPackage.java +5 -4
- package/android/src/main/java/com/swmansion/reanimated/Utils.java +7 -1
- package/android/src/main/java/com/swmansion/reanimated/keyboardObserver/ReanimatedKeyboardEventListener.java +10 -3
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/AnimationsManager.java +218 -35
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/LayoutAnimations.java +43 -17
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/NativeMethodsHolder.java +6 -2
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/SharedElement.java +19 -0
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/SharedTransitionManager.java +610 -0
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/Snapshot.java +93 -23
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/AnimationFrameCallback.java +19 -0
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/EventHandler.java +35 -0
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/KeyboardEventDataUpdater.java +16 -0
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/NativeProxyCommon.java +206 -0
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/SensorSetter.java +17 -0
- package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensor.java +9 -3
- package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorContainer.java +3 -4
- package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorListener.java +31 -7
- package/android/src/paper/java/com/swmansion/reanimated/NativeProxy.java +90 -307
- package/android/src/reactNativeVersionPatch/ReanimatedUIManager/70/com/swmansion/reanimated/ReanimatedUIManagerFactory.java +16 -0
- package/android/src/reactNativeVersionPatch/ReanimatedUIManager/latest/com/swmansion/reanimated/ReanimatedUIManagerFactory.java +63 -0
- package/android/src/reactNativeVersionPatch/ReanimatedUIManager/latest/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +271 -0
- package/android/src/reactNativeVersionPatch/nativeHierarchyManager/latest/com/swmansion/reanimated/layoutReanimation/ReanimatedNativeHierarchyManager.java +76 -20
- package/ios/LayoutReanimation/REAAnimationsManager.h +28 -4
- package/ios/LayoutReanimation/REAAnimationsManager.m +216 -61
- package/ios/LayoutReanimation/REAFrame.h +10 -0
- package/ios/LayoutReanimation/REAFrame.m +15 -0
- package/ios/LayoutReanimation/REAScreensHelper.h +19 -0
- package/ios/LayoutReanimation/REAScreensHelper.m +106 -0
- package/ios/LayoutReanimation/REASharedElement.h +15 -0
- package/ios/LayoutReanimation/REASharedElement.m +16 -0
- package/ios/LayoutReanimation/REASharedTransitionManager.h +17 -0
- package/ios/LayoutReanimation/REASharedTransitionManager.m +632 -0
- package/ios/LayoutReanimation/REASnapshot.h +1 -0
- package/ios/LayoutReanimation/REASnapshot.m +96 -11
- package/ios/LayoutReanimation/REAUIManager.mm +64 -17
- package/ios/REAModule.mm +2 -7
- package/ios/REANodesManager.mm +1 -21
- package/ios/keyboardObserver/REAKeyboardEventObserver.m +72 -36
- package/ios/native/NativeProxy.mm +75 -114
- package/ios/native/REAInitializer.mm +2 -7
- package/ios/native/REAJSIUtils.h +60 -2
- package/ios/sensor/ReanimatedSensor.h +6 -2
- package/ios/sensor/ReanimatedSensor.m +43 -7
- package/ios/sensor/ReanimatedSensorContainer.h +4 -1
- package/ios/sensor/ReanimatedSensorContainer.m +8 -2
- package/lib/commonjs/createAnimatedComponent.js +232 -28
- package/lib/commonjs/createAnimatedComponent.js.map +1 -1
- package/lib/commonjs/reanimated2/Colors.js +43 -22
- package/lib/commonjs/reanimated2/Colors.js.map +1 -1
- package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js +16 -33
- package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/styleAnimation.js +5 -1
- package/lib/commonjs/reanimated2/animation/styleAnimation.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/util.js +17 -15
- package/lib/commonjs/reanimated2/animation/util.js.map +1 -1
- package/lib/commonjs/reanimated2/commonTypes.js +33 -1
- package/lib/commonjs/reanimated2/commonTypes.js.map +1 -1
- package/lib/commonjs/reanimated2/core.js +33 -14
- package/lib/commonjs/reanimated2/core.js.map +1 -1
- package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryUI.js +2 -2
- package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryUI.js.map +1 -1
- package/lib/commonjs/reanimated2/globals.d.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/index.js +0 -6
- package/lib/commonjs/reanimated2/hook/index.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js +5 -2
- package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedReaction.js +13 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedReaction.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedRef.js +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedRef.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js +89 -16
- package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js +43 -40
- package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useDerivedValue.js +13 -1
- package/lib/commonjs/reanimated2/hook/useDerivedValue.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useScrollViewOffset.js +2 -2
- package/lib/commonjs/reanimated2/hook/useScrollViewOffset.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/utils.js +18 -65
- package/lib/commonjs/reanimated2/hook/utils.js.map +1 -1
- package/lib/commonjs/reanimated2/index.js +13 -0
- package/lib/commonjs/reanimated2/index.js.map +1 -1
- package/lib/commonjs/reanimated2/initializers.js +71 -32
- package/lib/commonjs/reanimated2/initializers.js.map +1 -1
- package/lib/commonjs/reanimated2/interpolateColor.js +96 -19
- package/lib/commonjs/reanimated2/interpolateColor.js.map +1 -1
- package/lib/commonjs/reanimated2/jestUtils.js +1 -1
- package/lib/commonjs/reanimated2/jestUtils.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js +103 -13
- package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/Mapper.js +22 -0
- package/lib/commonjs/reanimated2/js-reanimated/Mapper.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/WebSensor.js +2 -0
- package/lib/commonjs/reanimated2/js-reanimated/WebSensor.js.map +1 -0
- package/lib/commonjs/reanimated2/js-reanimated/commonTypes.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/global.js +0 -2
- package/lib/commonjs/reanimated2/js-reanimated/global.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/index.js +0 -1
- package/lib/commonjs/reanimated2/js-reanimated/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +11 -0
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/index.js +8 -0
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js +17 -9
- package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +16 -23
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +8 -14
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Roll.js +8 -14
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Slide.js +8 -15
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +16 -23
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/index.js +13 -0
- package/lib/commonjs/reanimated2/layoutReanimation/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/sharedTransitions/index.js +94 -0
- package/lib/commonjs/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -0
- package/lib/commonjs/reanimated2/mappers.js +18 -6
- package/lib/commonjs/reanimated2/mappers.js.map +1 -1
- package/lib/commonjs/reanimated2/mock.js +20 -1
- package/lib/commonjs/reanimated2/mock.js.map +1 -1
- package/lib/commonjs/reanimated2/mutables.js +4 -2
- package/lib/commonjs/reanimated2/mutables.js.map +1 -1
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.js +42 -0
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.js.map +1 -0
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.web.js +15 -0
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.web.js.map +1 -0
- package/lib/commonjs/reanimated2/pluginUtils.js +11 -0
- package/lib/commonjs/reanimated2/pluginUtils.js.map +1 -0
- package/lib/commonjs/reanimated2/shareables.js +36 -15
- package/lib/commonjs/reanimated2/shareables.js.map +1 -1
- package/lib/commonjs/reanimated2/threads.js +114 -4
- package/lib/commonjs/reanimated2/threads.js.map +1 -1
- package/lib/commonjs/reanimated2/utils.js +7 -0
- package/lib/commonjs/reanimated2/utils.js.map +1 -1
- package/lib/commonjs/reanimated2/valueSetter.js +1 -3
- package/lib/commonjs/reanimated2/valueSetter.js.map +1 -1
- package/lib/module/createAnimatedComponent.js +229 -29
- package/lib/module/createAnimatedComponent.js.map +1 -1
- package/lib/module/reanimated2/Colors.js +35 -19
- package/lib/module/reanimated2/Colors.js.map +1 -1
- package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js +16 -32
- package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
- package/lib/module/reanimated2/animation/styleAnimation.js +5 -1
- package/lib/module/reanimated2/animation/styleAnimation.js.map +1 -1
- package/lib/module/reanimated2/animation/util.js +17 -16
- package/lib/module/reanimated2/animation/util.js.map +1 -1
- package/lib/module/reanimated2/commonTypes.js +29 -0
- package/lib/module/reanimated2/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/core.js +32 -7
- package/lib/module/reanimated2/core.js.map +1 -1
- package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js +2 -2
- package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js.map +1 -1
- package/lib/module/reanimated2/globals.d.js.map +1 -1
- package/lib/module/reanimated2/hook/index.js +1 -1
- package/lib/module/reanimated2/hook/index.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedKeyboard.js +5 -2
- package/lib/module/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedReaction.js +12 -1
- package/lib/module/reanimated2/hook/useAnimatedReaction.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedRef.js +2 -2
- package/lib/module/reanimated2/hook/useAnimatedRef.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedSensor.js +88 -13
- package/lib/module/reanimated2/hook/useAnimatedSensor.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedStyle.js +46 -43
- package/lib/module/reanimated2/hook/useAnimatedStyle.js.map +1 -1
- package/lib/module/reanimated2/hook/useDerivedValue.js +12 -1
- package/lib/module/reanimated2/hook/useDerivedValue.js.map +1 -1
- package/lib/module/reanimated2/hook/useScrollViewOffset.js +2 -2
- package/lib/module/reanimated2/hook/useScrollViewOffset.js.map +1 -1
- package/lib/module/reanimated2/hook/utils.js +17 -60
- package/lib/module/reanimated2/hook/utils.js.map +1 -1
- package/lib/module/reanimated2/index.js +1 -0
- package/lib/module/reanimated2/index.js.map +1 -1
- package/lib/module/reanimated2/initializers.js +72 -33
- package/lib/module/reanimated2/initializers.js.map +1 -1
- package/lib/module/reanimated2/interpolateColor.js +96 -19
- package/lib/module/reanimated2/interpolateColor.js.map +1 -1
- package/lib/module/reanimated2/jestUtils.js +1 -1
- package/lib/module/reanimated2/jestUtils.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/JSReanimated.js +103 -13
- package/lib/module/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/Mapper.js +21 -0
- package/lib/module/reanimated2/js-reanimated/Mapper.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/WebSensor.js +2 -0
- package/lib/module/reanimated2/js-reanimated/WebSensor.js.map +1 -0
- package/lib/module/reanimated2/js-reanimated/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/global.js +0 -2
- package/lib/module/reanimated2/js-reanimated/global.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/index.js +0 -1
- package/lib/module/reanimated2/js-reanimated/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +9 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/index.js +1 -0
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationsManager.js +15 -8
- package/lib/module/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +16 -21
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +8 -12
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js +8 -12
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js +8 -13
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +16 -21
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/index.js +1 -0
- package/lib/module/reanimated2/layoutReanimation/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js +82 -0
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -0
- package/lib/module/reanimated2/mappers.js +16 -6
- package/lib/module/reanimated2/mappers.js.map +1 -1
- package/lib/module/reanimated2/mock.js +20 -1
- package/lib/module/reanimated2/mock.js.map +1 -1
- package/lib/module/reanimated2/mutables.js +4 -2
- package/lib/module/reanimated2/mutables.js.map +1 -1
- package/lib/module/reanimated2/platform-specific/checkVersion.js +35 -0
- package/lib/module/reanimated2/platform-specific/checkVersion.js.map +1 -0
- package/lib/module/reanimated2/platform-specific/checkVersion.web.js +8 -0
- package/lib/module/reanimated2/platform-specific/checkVersion.web.js.map +1 -0
- package/lib/module/reanimated2/pluginUtils.js +4 -0
- package/lib/module/reanimated2/pluginUtils.js.map +1 -0
- package/lib/module/reanimated2/shareables.js +36 -12
- package/lib/module/reanimated2/shareables.js.map +1 -1
- package/lib/module/reanimated2/threads.js +105 -4
- package/lib/module/reanimated2/threads.js.map +1 -1
- package/lib/module/reanimated2/utils.js +5 -0
- package/lib/module/reanimated2/utils.js.map +1 -1
- package/lib/module/reanimated2/valueSetter.js +1 -2
- package/lib/module/reanimated2/valueSetter.js.map +1 -1
- package/package.json +10 -10
- package/{plugin.js → plugin/index.js} +128 -249
- package/react-native-reanimated.d.ts +57 -10
- package/scripts/reanimated_utils.rb +15 -2
- package/src/createAnimatedComponent.tsx +238 -28
- package/src/reanimated2/Colors.ts +38 -11
- package/src/reanimated2/NativeReanimated/NativeReanimated.ts +52 -39
- package/src/reanimated2/animation/styleAnimation.ts +8 -1
- package/src/reanimated2/animation/util.ts +29 -16
- package/src/reanimated2/commonTypes.ts +28 -1
- package/src/reanimated2/core.ts +42 -9
- package/src/reanimated2/frameCallback/FrameCallbackRegistryUI.ts +2 -2
- package/src/reanimated2/globals.d.ts +12 -15
- package/src/reanimated2/hook/index.ts +1 -1
- package/src/reanimated2/hook/useAnimatedKeyboard.ts +10 -4
- package/src/reanimated2/hook/useAnimatedReaction.ts +12 -5
- package/src/reanimated2/hook/useAnimatedRef.ts +1 -4
- package/src/reanimated2/hook/useAnimatedSensor.ts +88 -11
- package/src/reanimated2/hook/useAnimatedStyle.ts +44 -36
- package/src/reanimated2/hook/useDerivedValue.ts +8 -1
- package/src/reanimated2/hook/useScrollViewOffset.ts +2 -2
- package/src/reanimated2/hook/utils.ts +15 -61
- package/src/reanimated2/index.ts +1 -0
- package/src/reanimated2/initializers.ts +76 -35
- package/src/reanimated2/interpolateColor.ts +104 -20
- package/src/reanimated2/jestUtils.ts +1 -1
- package/src/reanimated2/js-reanimated/JSReanimated.ts +98 -15
- package/src/reanimated2/js-reanimated/Mapper.ts +32 -0
- package/src/reanimated2/js-reanimated/WebSensor.ts +34 -0
- package/src/reanimated2/js-reanimated/commonTypes.ts +0 -1
- package/src/reanimated2/js-reanimated/global.ts +0 -1
- package/src/reanimated2/js-reanimated/index.ts +0 -1
- package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +13 -1
- package/src/reanimated2/layoutReanimation/animationBuilder/index.ts +1 -0
- package/src/reanimated2/layoutReanimation/animationsManager.ts +17 -9
- package/src/reanimated2/layoutReanimation/defaultAnimations/Bounce.ts +16 -19
- package/src/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.ts +14 -11
- package/src/reanimated2/layoutReanimation/defaultAnimations/Roll.ts +21 -11
- package/src/reanimated2/layoutReanimation/defaultAnimations/Slide.ts +32 -11
- package/src/reanimated2/layoutReanimation/defaultAnimations/Zoom.ts +36 -19
- package/src/reanimated2/layoutReanimation/index.ts +1 -0
- package/src/reanimated2/layoutReanimation/sharedTransitions/index.ts +87 -0
- package/src/reanimated2/mappers.ts +17 -6
- package/src/reanimated2/mock.ts +24 -1
- package/src/reanimated2/mutables.ts +2 -0
- package/src/reanimated2/platform-specific/checkVersion.ts +39 -0
- package/src/reanimated2/platform-specific/checkVersion.web.ts +6 -0
- package/src/reanimated2/pluginUtils.ts +8 -0
- package/src/reanimated2/shareables.ts +45 -16
- package/src/reanimated2/threads.ts +103 -1
- package/src/reanimated2/utils.ts +6 -0
- package/src/reanimated2/valueSetter.ts +1 -2
- package/lib/commonjs/reanimated2/time.js +0 -55
- package/lib/commonjs/reanimated2/time.js.map +0 -1
- package/lib/module/reanimated2/time.js +0 -37
- package/lib/module/reanimated2/time.js.map +0 -1
- package/src/reanimated2/time.ts +0 -30
- /package/android/src/{main/java → reactNativeVersionPatch/ReanimatedUIManager/70}/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-reanimated",
|
|
3
|
-
"version": "3.0.0
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "More powerful alternative to Animated library for React Native.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "yarn run format:js && yarn run lint:js && yarn run test:unit",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"scripts/reanimated_utils.rb",
|
|
55
55
|
"README.md",
|
|
56
56
|
"mock.js",
|
|
57
|
-
"plugin
|
|
57
|
+
"plugin/",
|
|
58
58
|
"!__snapshots__",
|
|
59
59
|
"!*.test.js",
|
|
60
60
|
"!*.test.js.map"
|
|
@@ -76,11 +76,11 @@
|
|
|
76
76
|
"dependencies": {
|
|
77
77
|
"@babel/plugin-transform-object-assign": "^7.16.7",
|
|
78
78
|
"@babel/preset-typescript": "^7.16.7",
|
|
79
|
+
"convert-source-map": "^1.7.0",
|
|
79
80
|
"invariant": "^2.2.4",
|
|
80
81
|
"lodash.isequal": "^4.5.0",
|
|
81
82
|
"setimmediate": "^1.0.5",
|
|
82
|
-
"string-hash-64": "^1.0.3"
|
|
83
|
-
"convert-source-map": "^1.7.0"
|
|
83
|
+
"string-hash-64": "^1.0.3"
|
|
84
84
|
},
|
|
85
85
|
"peerDependencies": {
|
|
86
86
|
"@babel/core": "^7.0.0-0",
|
|
@@ -89,11 +89,11 @@
|
|
|
89
89
|
},
|
|
90
90
|
"devDependencies": {
|
|
91
91
|
"@babel/cli": "^7.17.6",
|
|
92
|
-
"@babel/core": "^7.
|
|
92
|
+
"@babel/core": "^7.20.0",
|
|
93
93
|
"@babel/plugin-proposal-class-properties": "^7.16.7",
|
|
94
94
|
"@babel/plugin-proposal-optional-chaining": "^7.16.7",
|
|
95
|
-
"@babel/preset-env": "^7.
|
|
96
|
-
"@react-native-community/eslint-config": "^
|
|
95
|
+
"@babel/preset-env": "^7.20.0",
|
|
96
|
+
"@react-native-community/eslint-config": "^3.2.0",
|
|
97
97
|
"@testing-library/jest-native": "^4.0.4",
|
|
98
98
|
"@testing-library/react-hooks": "^8.0.0",
|
|
99
99
|
"@testing-library/react-native": "^7.1.0",
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
"@types/babel__traverse": "^7.14.2",
|
|
104
104
|
"@types/invariant": "^2.2.35",
|
|
105
105
|
"@types/jest": "^27.4.0",
|
|
106
|
-
"@types/react
|
|
106
|
+
"@types/react": "^18.0.26",
|
|
107
107
|
"@typescript-eslint/eslint-plugin": "^5.11.0",
|
|
108
108
|
"@typescript-eslint/parser": "^5.11.0",
|
|
109
109
|
"babel-eslint": "^10.1.0",
|
|
@@ -115,6 +115,7 @@
|
|
|
115
115
|
"eslint-config-standard": "^16.0.3",
|
|
116
116
|
"eslint-import-resolver-babel-module": "^5.3.1",
|
|
117
117
|
"eslint-plugin-import": "^2.25.4",
|
|
118
|
+
"eslint-plugin-jest": "^27.2.1",
|
|
118
119
|
"eslint-plugin-node": "^11.1.0",
|
|
119
120
|
"eslint-plugin-promise": "^6.0.0",
|
|
120
121
|
"eslint-plugin-standard": "^5.0.0",
|
|
@@ -124,9 +125,8 @@
|
|
|
124
125
|
"madge": "^5.0.1",
|
|
125
126
|
"prettier": "^2.5.1",
|
|
126
127
|
"react": "17.0.2",
|
|
127
|
-
"react-native": "0.
|
|
128
|
+
"react-native": "0.71.3",
|
|
128
129
|
"react-native-builder-bob": "^0.18.3",
|
|
129
|
-
"react-native-codegen": "^0.0.7",
|
|
130
130
|
"react-native-gesture-handler": "^2.4.2",
|
|
131
131
|
"react-test-renderer": "17.0.2",
|
|
132
132
|
"release-it": "^13.7.2",
|
|
@@ -33,7 +33,6 @@ const globals = new Set([
|
|
|
33
33
|
'this',
|
|
34
34
|
'console',
|
|
35
35
|
'performance',
|
|
36
|
-
'_chronoNow',
|
|
37
36
|
'Date',
|
|
38
37
|
'Array',
|
|
39
38
|
'ArrayBuffer',
|
|
@@ -58,6 +57,7 @@ const globals = new Set([
|
|
|
58
57
|
'null',
|
|
59
58
|
'UIManager',
|
|
60
59
|
'requestAnimationFrame',
|
|
60
|
+
'setImmediate',
|
|
61
61
|
'_WORKLET',
|
|
62
62
|
'arguments',
|
|
63
63
|
'Boolean',
|
|
@@ -84,72 +84,12 @@ const globals = new Set([
|
|
|
84
84
|
'_dispatchCommand',
|
|
85
85
|
'_setGestureState',
|
|
86
86
|
'_getCurrentTime',
|
|
87
|
-
'_eventTimestamp',
|
|
88
|
-
'_frameTimestamp',
|
|
89
87
|
'isNaN',
|
|
90
88
|
'LayoutAnimationRepository',
|
|
91
89
|
'_notifyAboutProgress',
|
|
92
90
|
'_notifyAboutEnd',
|
|
93
91
|
]);
|
|
94
92
|
|
|
95
|
-
// leaving way to avoid deep capturing by adding 'stopCapturing' to the blacklist
|
|
96
|
-
const blacklistedFunctions = new Set([
|
|
97
|
-
'stopCapturing',
|
|
98
|
-
'toString',
|
|
99
|
-
'map',
|
|
100
|
-
'filter',
|
|
101
|
-
'findIndex',
|
|
102
|
-
'forEach',
|
|
103
|
-
'valueOf',
|
|
104
|
-
'toPrecision',
|
|
105
|
-
'toExponential',
|
|
106
|
-
'constructor',
|
|
107
|
-
'toFixed',
|
|
108
|
-
'toLocaleString',
|
|
109
|
-
'toSource',
|
|
110
|
-
'charAt',
|
|
111
|
-
'charCodeAt',
|
|
112
|
-
'concat',
|
|
113
|
-
'indexOf',
|
|
114
|
-
'lastIndexOf',
|
|
115
|
-
'localeCompare',
|
|
116
|
-
'length',
|
|
117
|
-
'match',
|
|
118
|
-
'replace',
|
|
119
|
-
'search',
|
|
120
|
-
'slice',
|
|
121
|
-
'split',
|
|
122
|
-
'substr',
|
|
123
|
-
'substring',
|
|
124
|
-
'toLocaleLowerCase',
|
|
125
|
-
'toLocaleUpperCase',
|
|
126
|
-
'toLowerCase',
|
|
127
|
-
'toUpperCase',
|
|
128
|
-
'every',
|
|
129
|
-
'join',
|
|
130
|
-
'pop',
|
|
131
|
-
'push',
|
|
132
|
-
'reduce',
|
|
133
|
-
'reduceRight',
|
|
134
|
-
'reverse',
|
|
135
|
-
'shift',
|
|
136
|
-
'slice',
|
|
137
|
-
'some',
|
|
138
|
-
'sort',
|
|
139
|
-
'splice',
|
|
140
|
-
'unshift',
|
|
141
|
-
'hasOwnProperty',
|
|
142
|
-
'isPrototypeOf',
|
|
143
|
-
'propertyIsEnumerable',
|
|
144
|
-
'bind',
|
|
145
|
-
'apply',
|
|
146
|
-
'call',
|
|
147
|
-
'__callAsync',
|
|
148
|
-
'includes',
|
|
149
|
-
]);
|
|
150
|
-
|
|
151
|
-
const possibleOptFunction = new Set(['interpolate']);
|
|
152
|
-
|
|
153
93
|
const gestureHandlerGestureObjects = new Set([
|
|
154
94
|
// from https://github.com/software-mansion/react-native-gesture-handler/blob/new-api/src/handlers/gestures/gestureObjects.ts
|
|
155
95
|
'Tap',
|
|
@@ -179,112 +119,6 @@ const gestureHandlerBuilderMethods = new Set([
|
|
|
179
119
|
'onTouchesCancelled',
|
|
180
120
|
]);
|
|
181
121
|
|
|
182
|
-
class ClosureGenerator {
|
|
183
|
-
constructor() {
|
|
184
|
-
this.trie = [{}, false];
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
mergeAns(oldAns, newAns) {
|
|
188
|
-
const [purePath, node] = oldAns;
|
|
189
|
-
const [purePathUp, nodeUp] = newAns;
|
|
190
|
-
if (purePathUp.length !== 0) {
|
|
191
|
-
return [purePath.concat(purePathUp), nodeUp];
|
|
192
|
-
} else {
|
|
193
|
-
return [purePath, node];
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
findPrefixRec(path) {
|
|
198
|
-
const notFound = [[], null];
|
|
199
|
-
if (!path || path.node.type !== 'MemberExpression') {
|
|
200
|
-
return notFound;
|
|
201
|
-
}
|
|
202
|
-
const memberExpressionNode = path.node;
|
|
203
|
-
if (memberExpressionNode.property.type !== 'Identifier') {
|
|
204
|
-
return notFound;
|
|
205
|
-
}
|
|
206
|
-
if (
|
|
207
|
-
memberExpressionNode.computed ||
|
|
208
|
-
memberExpressionNode.property.name === 'value' ||
|
|
209
|
-
blacklistedFunctions.has(memberExpressionNode.property.name)
|
|
210
|
-
) {
|
|
211
|
-
// a.b[w] -> a.b.w in babel nodes
|
|
212
|
-
// a.v.value
|
|
213
|
-
// sth.map(() => )
|
|
214
|
-
return notFound;
|
|
215
|
-
}
|
|
216
|
-
if (
|
|
217
|
-
path.parent &&
|
|
218
|
-
path.parent.type === 'AssignmentExpression' &&
|
|
219
|
-
path.parent.left === path.node
|
|
220
|
-
) {
|
|
221
|
-
/// captured.newProp = 5;
|
|
222
|
-
return notFound;
|
|
223
|
-
}
|
|
224
|
-
const purePath = [memberExpressionNode.property.name];
|
|
225
|
-
const node = memberExpressionNode;
|
|
226
|
-
const upAns = this.findPrefixRec(path.parentPath);
|
|
227
|
-
return this.mergeAns([purePath, node], upAns);
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
findPrefix(base, babelPath) {
|
|
231
|
-
const purePath = [base];
|
|
232
|
-
const node = babelPath.node;
|
|
233
|
-
const upAns = this.findPrefixRec(babelPath.parentPath);
|
|
234
|
-
return this.mergeAns([purePath, node], upAns);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
addPath(base, babelPath) {
|
|
238
|
-
const [purePath, node] = this.findPrefix(base, babelPath);
|
|
239
|
-
let parent = this.trie;
|
|
240
|
-
let index = -1;
|
|
241
|
-
for (const current of purePath) {
|
|
242
|
-
index++;
|
|
243
|
-
if (parent[1]) {
|
|
244
|
-
continue;
|
|
245
|
-
}
|
|
246
|
-
if (!parent[0][current]) {
|
|
247
|
-
parent[0][current] = [{}, false];
|
|
248
|
-
}
|
|
249
|
-
if (index === purePath.length - 1) {
|
|
250
|
-
parent[0][current] = [node, true];
|
|
251
|
-
}
|
|
252
|
-
parent = parent[0][current];
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
generateNodeForBase(t, current, parent) {
|
|
257
|
-
const currentNode = parent[0][current];
|
|
258
|
-
if (currentNode[1]) {
|
|
259
|
-
return currentNode[0];
|
|
260
|
-
}
|
|
261
|
-
return t.objectExpression(
|
|
262
|
-
Object.keys(currentNode[0]).map((propertyName) =>
|
|
263
|
-
t.objectProperty(
|
|
264
|
-
t.identifier(propertyName),
|
|
265
|
-
this.generateNodeForBase(t, propertyName, currentNode),
|
|
266
|
-
false,
|
|
267
|
-
true
|
|
268
|
-
)
|
|
269
|
-
)
|
|
270
|
-
);
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
generate(t, variables, names) {
|
|
274
|
-
const arrayOfKeys = [...names];
|
|
275
|
-
return t.objectExpression(
|
|
276
|
-
variables.map((variable, index) =>
|
|
277
|
-
t.objectProperty(
|
|
278
|
-
t.identifier(variable.name),
|
|
279
|
-
this.generateNodeForBase(t, arrayOfKeys[index], this.trie),
|
|
280
|
-
false,
|
|
281
|
-
true
|
|
282
|
-
)
|
|
283
|
-
)
|
|
284
|
-
);
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
|
|
288
122
|
function isRelease() {
|
|
289
123
|
return ['production', 'release'].includes(process.env.BABEL_ENV);
|
|
290
124
|
}
|
|
@@ -370,7 +204,9 @@ function buildWorkletString(t, fun, closureVariables, name, inputMap) {
|
|
|
370
204
|
|
|
371
205
|
const code = generate(workletFunction).code;
|
|
372
206
|
|
|
373
|
-
|
|
207
|
+
const includeSourceMap = shouldGenerateSourceMap();
|
|
208
|
+
|
|
209
|
+
if (includeSourceMap) {
|
|
374
210
|
// Clear contents array (should be empty anyways)
|
|
375
211
|
inputMap.sourcesContent = [];
|
|
376
212
|
// Include source contents in source map, because Flipper/iframe is not
|
|
@@ -382,8 +218,6 @@ function buildWorkletString(t, fun, closureVariables, name, inputMap) {
|
|
|
382
218
|
}
|
|
383
219
|
}
|
|
384
220
|
|
|
385
|
-
const includeSourceMap = shouldGenerateSourceMap();
|
|
386
|
-
|
|
387
221
|
const transformed = transformSync(code, {
|
|
388
222
|
plugins: [prependClosureVariablesIfNecessary()],
|
|
389
223
|
compact: !includeSourceMap,
|
|
@@ -428,8 +262,6 @@ function makeWorklet(t, fun, state) {
|
|
|
428
262
|
const functionName = makeWorkletName(t, fun);
|
|
429
263
|
|
|
430
264
|
const closure = new Map();
|
|
431
|
-
const closureGenerator = new ClosureGenerator();
|
|
432
|
-
const options = {};
|
|
433
265
|
|
|
434
266
|
// remove 'worklet'; directive before generating string
|
|
435
267
|
fun.traverse({
|
|
@@ -471,13 +303,6 @@ function makeWorklet(t, fun, state) {
|
|
|
471
303
|
inputSourceMap: codeObject.map,
|
|
472
304
|
});
|
|
473
305
|
|
|
474
|
-
if (
|
|
475
|
-
fun.parent &&
|
|
476
|
-
fun.parent.callee &&
|
|
477
|
-
fun.parent.callee.name === 'useAnimatedStyle'
|
|
478
|
-
) {
|
|
479
|
-
options.optFlags = isPossibleOptimization(transformed.ast);
|
|
480
|
-
}
|
|
481
306
|
traverse(transformed.ast, {
|
|
482
307
|
ReferencedIdentifier(path) {
|
|
483
308
|
const name = path.node.name;
|
|
@@ -512,7 +337,6 @@ function makeWorklet(t, fun, state) {
|
|
|
512
337
|
currentScope = currentScope.parent;
|
|
513
338
|
}
|
|
514
339
|
closure.set(name, path.node);
|
|
515
|
-
closureGenerator.addPath(name, path);
|
|
516
340
|
},
|
|
517
341
|
});
|
|
518
342
|
|
|
@@ -552,6 +376,35 @@ function makeWorklet(t, fun, state) {
|
|
|
552
376
|
lineOffset -= closure.size + 2;
|
|
553
377
|
}
|
|
554
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
|
+
|
|
555
408
|
const statements = [
|
|
556
409
|
t.variableDeclaration('const', [
|
|
557
410
|
t.variableDeclarator(privateFunctionId, funExpression),
|
|
@@ -560,14 +413,11 @@ function makeWorklet(t, fun, state) {
|
|
|
560
413
|
t.assignmentExpression(
|
|
561
414
|
'=',
|
|
562
415
|
t.memberExpression(privateFunctionId, t.identifier('_closure'), false),
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
'=',
|
|
569
|
-
t.memberExpression(privateFunctionId, t.identifier('asString'), false),
|
|
570
|
-
t.stringLiteral(funString)
|
|
416
|
+
t.objectExpression(
|
|
417
|
+
variables.map((variable) =>
|
|
418
|
+
t.objectProperty(t.identifier(variable.name), variable, false, true)
|
|
419
|
+
)
|
|
420
|
+
)
|
|
571
421
|
)
|
|
572
422
|
),
|
|
573
423
|
t.expressionStatement(
|
|
@@ -575,10 +425,10 @@ function makeWorklet(t, fun, state) {
|
|
|
575
425
|
'=',
|
|
576
426
|
t.memberExpression(
|
|
577
427
|
privateFunctionId,
|
|
578
|
-
t.identifier('
|
|
428
|
+
t.identifier('__initData'),
|
|
579
429
|
false
|
|
580
430
|
),
|
|
581
|
-
|
|
431
|
+
initDataId
|
|
582
432
|
)
|
|
583
433
|
),
|
|
584
434
|
t.expressionStatement(
|
|
@@ -586,30 +436,14 @@ function makeWorklet(t, fun, state) {
|
|
|
586
436
|
'=',
|
|
587
437
|
t.memberExpression(
|
|
588
438
|
privateFunctionId,
|
|
589
|
-
t.identifier('
|
|
439
|
+
t.identifier('__workletHash'),
|
|
590
440
|
false
|
|
591
441
|
),
|
|
592
|
-
t.
|
|
442
|
+
t.numericLiteral(workletHash)
|
|
593
443
|
)
|
|
594
444
|
),
|
|
595
445
|
];
|
|
596
446
|
|
|
597
|
-
if (sourceMapString) {
|
|
598
|
-
statements.push(
|
|
599
|
-
t.expressionStatement(
|
|
600
|
-
t.assignmentExpression(
|
|
601
|
-
'=',
|
|
602
|
-
t.memberExpression(
|
|
603
|
-
privateFunctionId,
|
|
604
|
-
t.identifier('__sourceMap'),
|
|
605
|
-
false
|
|
606
|
-
),
|
|
607
|
-
t.stringLiteral(sourceMapString)
|
|
608
|
-
)
|
|
609
|
-
)
|
|
610
|
-
);
|
|
611
|
-
}
|
|
612
|
-
|
|
613
447
|
if (!isRelease()) {
|
|
614
448
|
statements.unshift(
|
|
615
449
|
t.variableDeclaration('const', [
|
|
@@ -638,22 +472,6 @@ function makeWorklet(t, fun, state) {
|
|
|
638
472
|
);
|
|
639
473
|
}
|
|
640
474
|
|
|
641
|
-
if (options && options.optFlags) {
|
|
642
|
-
statements.push(
|
|
643
|
-
t.expressionStatement(
|
|
644
|
-
t.assignmentExpression(
|
|
645
|
-
'=',
|
|
646
|
-
t.memberExpression(
|
|
647
|
-
privateFunctionId,
|
|
648
|
-
t.identifier('__optimalization'),
|
|
649
|
-
false
|
|
650
|
-
),
|
|
651
|
-
t.numericLiteral(options.optFlags)
|
|
652
|
-
)
|
|
653
|
-
)
|
|
654
|
-
);
|
|
655
|
-
}
|
|
656
|
-
|
|
657
475
|
statements.push(t.returnStatement(privateFunctionId));
|
|
658
476
|
|
|
659
477
|
const newFun = t.functionExpression(fun.id, [], t.blockStatement(statements));
|
|
@@ -841,17 +659,14 @@ function isGestureObject(t, node) {
|
|
|
841
659
|
}
|
|
842
660
|
|
|
843
661
|
function processWorklets(t, path, state) {
|
|
844
|
-
|
|
845
662
|
const callee =
|
|
846
663
|
path.node.callee.type === 'SequenceExpression'
|
|
847
664
|
? path.node.callee.expressions[path.node.callee.expressions.length - 1]
|
|
848
665
|
: path.node.callee;
|
|
849
666
|
|
|
850
667
|
const name =
|
|
851
|
-
callee.type === 'MemberExpression'
|
|
852
|
-
|
|
853
|
-
: callee.name;
|
|
854
|
-
|
|
668
|
+
callee.type === 'MemberExpression' ? callee.property.name : callee.name;
|
|
669
|
+
|
|
855
670
|
if (
|
|
856
671
|
objectHooks.has(name) &&
|
|
857
672
|
path.get('arguments.0').type === 'ObjectExpression'
|
|
@@ -875,30 +690,89 @@ function processWorklets(t, path, state) {
|
|
|
875
690
|
}
|
|
876
691
|
}
|
|
877
692
|
|
|
878
|
-
|
|
879
|
-
|
|
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
|
+
}
|
|
880
721
|
|
|
881
|
-
function
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
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);
|
|
888
737
|
}
|
|
889
|
-
}
|
|
890
|
-
IfStatement() {
|
|
891
|
-
isStatement = true;
|
|
892
|
-
},
|
|
893
|
-
});
|
|
894
|
-
let flags = 0;
|
|
895
|
-
if (!isFunctionCall) {
|
|
896
|
-
flags = flags | FUNCTIONLESS_FLAG;
|
|
738
|
+
}
|
|
897
739
|
}
|
|
898
|
-
|
|
899
|
-
|
|
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);
|
|
900
775
|
}
|
|
901
|
-
return flags;
|
|
902
776
|
}
|
|
903
777
|
|
|
904
778
|
module.exports = function ({ types: t }) {
|
|
@@ -923,6 +797,11 @@ module.exports = function ({ types: t }) {
|
|
|
923
797
|
processIfGestureHandlerEventCallbackFunctionNode(t, path, state);
|
|
924
798
|
},
|
|
925
799
|
},
|
|
800
|
+
JSXAttribute: {
|
|
801
|
+
enter(path, state) {
|
|
802
|
+
processInlineStylesWarning(t, path, state);
|
|
803
|
+
},
|
|
804
|
+
},
|
|
926
805
|
},
|
|
927
806
|
};
|
|
928
807
|
};
|