react-native-reanimated 3.0.0-rc.8 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Common/cpp/AnimatedSensor/AnimatedSensorModule.cpp +30 -12
- package/Common/cpp/AnimatedSensor/AnimatedSensorModule.h +2 -0
- package/Common/cpp/Fabric/FabricUtils.cpp +3 -107
- package/Common/cpp/Fabric/FabricUtils.h +3 -24
- package/Common/cpp/Fabric/ReanimatedUIManagerBinding.cpp +54 -37
- package/Common/cpp/LayoutAnimations/LayoutAnimationType.h +8 -0
- package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.cpp +81 -26
- package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.h +20 -3
- package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +122 -121
- package/Common/cpp/NativeModules/NativeReanimatedModule.h +21 -14
- package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +15 -7
- package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.h +8 -4
- package/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.cpp +50 -1
- package/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.h +10 -1
- package/Common/cpp/ReanimatedRuntime/ReanimatedRuntime.cpp +5 -1
- package/Common/cpp/Registries/EventHandlerRegistry.cpp +8 -34
- package/Common/cpp/Registries/EventHandlerRegistry.h +7 -13
- package/Common/cpp/SharedItems/Shareables.cpp +11 -63
- package/Common/cpp/SharedItems/Shareables.h +113 -93
- package/Common/cpp/Tools/CollectionUtils.h +14 -0
- package/Common/cpp/Tools/JsiUtils.cpp +26 -0
- package/Common/cpp/Tools/JsiUtils.h +176 -0
- package/Common/cpp/Tools/PlatformDepMethodsHolder.h +5 -5
- package/Common/cpp/Tools/ReanimatedVersion.cpp +17 -0
- package/Common/cpp/Tools/ReanimatedVersion.h +11 -0
- package/Common/cpp/Tools/RuntimeDecorator.cpp +67 -247
- package/Common/cpp/Tools/RuntimeDecorator.h +2 -3
- package/Common/cpp/Tools/WorkletEventHandler.cpp +3 -2
- package/Common/cpp/Tools/WorkletEventHandler.h +14 -6
- package/RNReanimated.podspec +2 -1
- package/android/CMakeLists.txt +188 -181
- package/android/build.gradle +362 -311
- package/android/proguard-rules.pro +2 -0
- package/android/src/fabric/java/com/swmansion/reanimated/NativeProxy.java +63 -295
- package/android/src/main/cpp/LayoutAnimations.cpp +35 -5
- package/android/src/main/cpp/LayoutAnimations.h +23 -6
- package/android/src/main/cpp/NativeProxy.cpp +143 -98
- package/android/src/main/cpp/NativeProxy.h +22 -28
- package/android/src/main/java/com/swmansion/reanimated/ReanimatedPackage.java +5 -4
- package/android/src/main/java/com/swmansion/reanimated/Utils.java +7 -1
- package/android/src/main/java/com/swmansion/reanimated/keyboardObserver/ReanimatedKeyboardEventListener.java +10 -3
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/AnimationsManager.java +218 -35
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/LayoutAnimations.java +43 -17
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/NativeMethodsHolder.java +6 -2
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/SharedElement.java +19 -0
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/SharedTransitionManager.java +610 -0
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/Snapshot.java +93 -23
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/AnimationFrameCallback.java +19 -0
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/EventHandler.java +35 -0
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/KeyboardEventDataUpdater.java +16 -0
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/NativeProxyCommon.java +206 -0
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/SensorSetter.java +17 -0
- package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensor.java +9 -3
- package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorContainer.java +3 -4
- package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorListener.java +31 -7
- package/android/src/paper/java/com/swmansion/reanimated/NativeProxy.java +90 -307
- package/android/src/reactNativeVersionPatch/ReanimatedUIManager/70/com/swmansion/reanimated/ReanimatedUIManagerFactory.java +16 -0
- package/android/src/reactNativeVersionPatch/ReanimatedUIManager/latest/com/swmansion/reanimated/ReanimatedUIManagerFactory.java +63 -0
- package/android/src/reactNativeVersionPatch/ReanimatedUIManager/latest/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +271 -0
- package/android/src/reactNativeVersionPatch/nativeHierarchyManager/latest/com/swmansion/reanimated/layoutReanimation/ReanimatedNativeHierarchyManager.java +76 -20
- package/ios/LayoutReanimation/REAAnimationsManager.h +31 -5
- package/ios/LayoutReanimation/REAAnimationsManager.m +265 -77
- package/ios/LayoutReanimation/REAFrame.h +10 -0
- package/ios/LayoutReanimation/REAFrame.m +15 -0
- package/ios/LayoutReanimation/REAScreensHelper.h +19 -0
- package/ios/LayoutReanimation/REAScreensHelper.m +106 -0
- package/ios/LayoutReanimation/REASharedElement.h +15 -0
- package/ios/LayoutReanimation/REASharedElement.m +16 -0
- package/ios/LayoutReanimation/REASharedTransitionManager.h +17 -0
- package/ios/LayoutReanimation/REASharedTransitionManager.m +632 -0
- package/ios/LayoutReanimation/REASnapshot.h +1 -0
- package/ios/LayoutReanimation/REASnapshot.m +96 -11
- package/ios/LayoutReanimation/REAUIManager.mm +67 -60
- package/ios/REAModule.mm +2 -7
- package/ios/REANodesManager.mm +1 -21
- package/ios/keyboardObserver/REAKeyboardEventObserver.m +72 -36
- package/ios/native/NativeProxy.mm +75 -114
- package/ios/native/REAInitializer.mm +2 -7
- package/ios/native/REAJSIUtils.h +60 -2
- package/ios/sensor/ReanimatedSensor.h +6 -2
- package/ios/sensor/ReanimatedSensor.m +43 -7
- package/ios/sensor/ReanimatedSensorContainer.h +4 -1
- package/ios/sensor/ReanimatedSensorContainer.m +8 -2
- package/lib/commonjs/createAnimatedComponent.js +232 -28
- package/lib/commonjs/createAnimatedComponent.js.map +1 -1
- package/lib/commonjs/reanimated2/Colors.js +43 -22
- package/lib/commonjs/reanimated2/Colors.js.map +1 -1
- package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js +18 -35
- package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/styleAnimation.js +5 -1
- package/lib/commonjs/reanimated2/animation/styleAnimation.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/util.js +17 -15
- package/lib/commonjs/reanimated2/animation/util.js.map +1 -1
- package/lib/commonjs/reanimated2/commonTypes.js +33 -1
- package/lib/commonjs/reanimated2/commonTypes.js.map +1 -1
- package/lib/commonjs/reanimated2/component/FlatList.js +19 -3
- package/lib/commonjs/reanimated2/component/FlatList.js.map +1 -1
- package/lib/commonjs/reanimated2/core.js +34 -83
- package/lib/commonjs/reanimated2/core.js.map +1 -1
- package/lib/commonjs/reanimated2/errors.js +66 -0
- package/lib/commonjs/reanimated2/errors.js.map +1 -0
- package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryUI.js +2 -2
- package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryUI.js.map +1 -1
- package/lib/commonjs/reanimated2/globals.d.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/index.js +0 -6
- package/lib/commonjs/reanimated2/hook/index.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js +5 -2
- package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedReaction.js +13 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedReaction.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedRef.js +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedRef.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js +89 -16
- package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js +43 -50
- package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useDerivedValue.js +13 -1
- package/lib/commonjs/reanimated2/hook/useDerivedValue.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useScrollViewOffset.js +2 -2
- package/lib/commonjs/reanimated2/hook/useScrollViewOffset.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/utils.js +18 -65
- package/lib/commonjs/reanimated2/hook/utils.js.map +1 -1
- package/lib/commonjs/reanimated2/index.js +13 -0
- package/lib/commonjs/reanimated2/index.js.map +1 -1
- package/lib/commonjs/reanimated2/initializers.js +196 -0
- package/lib/commonjs/reanimated2/initializers.js.map +1 -0
- package/lib/commonjs/reanimated2/interpolateColor.js +96 -19
- package/lib/commonjs/reanimated2/interpolateColor.js.map +1 -1
- package/lib/commonjs/reanimated2/jestUtils.js +1 -1
- package/lib/commonjs/reanimated2/jestUtils.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js +101 -16
- package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/Mapper.js +22 -0
- package/lib/commonjs/reanimated2/js-reanimated/Mapper.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/WebSensor.js +2 -0
- package/lib/commonjs/reanimated2/js-reanimated/WebSensor.js.map +1 -0
- package/lib/commonjs/reanimated2/js-reanimated/commonTypes.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/global.js +4 -9
- package/lib/commonjs/reanimated2/js-reanimated/global.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/index.js +0 -1
- package/lib/commonjs/reanimated2/js-reanimated/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +11 -0
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/index.js +8 -0
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js +16 -12
- package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +16 -23
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +8 -14
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Roll.js +8 -14
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Slide.js +8 -15
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +16 -23
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/index.js +13 -0
- package/lib/commonjs/reanimated2/layoutReanimation/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/sharedTransitions/index.js +94 -0
- package/lib/commonjs/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -0
- package/lib/commonjs/reanimated2/mappers.js +18 -6
- package/lib/commonjs/reanimated2/mappers.js.map +1 -1
- package/lib/commonjs/reanimated2/mock.js +45 -0
- package/lib/commonjs/reanimated2/mock.js.map +1 -1
- package/lib/commonjs/reanimated2/mutables.js +4 -2
- package/lib/commonjs/reanimated2/mutables.js.map +1 -1
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.js +42 -0
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.js.map +1 -0
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.web.js +15 -0
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.web.js.map +1 -0
- package/lib/commonjs/reanimated2/pluginUtils.js +11 -0
- package/lib/commonjs/reanimated2/pluginUtils.js.map +1 -0
- package/lib/commonjs/reanimated2/shareables.js +38 -11
- package/lib/commonjs/reanimated2/shareables.js.map +1 -1
- package/lib/commonjs/reanimated2/threads.js +114 -4
- package/lib/commonjs/reanimated2/threads.js.map +1 -1
- package/lib/commonjs/reanimated2/utils.js +7 -0
- package/lib/commonjs/reanimated2/utils.js.map +1 -1
- package/lib/commonjs/reanimated2/valueSetter.js +1 -3
- package/lib/commonjs/reanimated2/valueSetter.js.map +1 -1
- package/lib/module/createAnimatedComponent.js +229 -29
- package/lib/module/createAnimatedComponent.js.map +1 -1
- package/lib/module/reanimated2/Colors.js +35 -19
- package/lib/module/reanimated2/Colors.js.map +1 -1
- package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js +18 -34
- package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
- package/lib/module/reanimated2/animation/styleAnimation.js +5 -1
- package/lib/module/reanimated2/animation/styleAnimation.js.map +1 -1
- package/lib/module/reanimated2/animation/util.js +17 -16
- package/lib/module/reanimated2/animation/util.js.map +1 -1
- package/lib/module/reanimated2/commonTypes.js +29 -0
- package/lib/module/reanimated2/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/component/FlatList.js +18 -4
- package/lib/module/reanimated2/component/FlatList.js.map +1 -1
- package/lib/module/reanimated2/core.js +30 -76
- package/lib/module/reanimated2/core.js.map +1 -1
- package/lib/module/reanimated2/errors.js +58 -0
- package/lib/module/reanimated2/errors.js.map +1 -0
- package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js +2 -2
- package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js.map +1 -1
- package/lib/module/reanimated2/globals.d.js.map +1 -1
- package/lib/module/reanimated2/hook/index.js +1 -1
- package/lib/module/reanimated2/hook/index.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedKeyboard.js +5 -2
- package/lib/module/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedReaction.js +12 -1
- package/lib/module/reanimated2/hook/useAnimatedReaction.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedRef.js +2 -2
- package/lib/module/reanimated2/hook/useAnimatedRef.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedSensor.js +88 -13
- package/lib/module/reanimated2/hook/useAnimatedSensor.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedStyle.js +45 -52
- package/lib/module/reanimated2/hook/useAnimatedStyle.js.map +1 -1
- package/lib/module/reanimated2/hook/useDerivedValue.js +12 -1
- package/lib/module/reanimated2/hook/useDerivedValue.js.map +1 -1
- package/lib/module/reanimated2/hook/useScrollViewOffset.js +2 -2
- package/lib/module/reanimated2/hook/useScrollViewOffset.js.map +1 -1
- package/lib/module/reanimated2/hook/utils.js +17 -60
- package/lib/module/reanimated2/hook/utils.js.map +1 -1
- package/lib/module/reanimated2/index.js +1 -0
- package/lib/module/reanimated2/index.js.map +1 -1
- package/lib/module/reanimated2/initializers.js +182 -0
- package/lib/module/reanimated2/initializers.js.map +1 -0
- package/lib/module/reanimated2/interpolateColor.js +96 -19
- package/lib/module/reanimated2/interpolateColor.js.map +1 -1
- package/lib/module/reanimated2/jestUtils.js +1 -1
- package/lib/module/reanimated2/jestUtils.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/JSReanimated.js +101 -16
- package/lib/module/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/Mapper.js +21 -0
- package/lib/module/reanimated2/js-reanimated/Mapper.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/WebSensor.js +2 -0
- package/lib/module/reanimated2/js-reanimated/WebSensor.js.map +1 -0
- package/lib/module/reanimated2/js-reanimated/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/global.js +4 -9
- package/lib/module/reanimated2/js-reanimated/global.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/index.js +0 -1
- package/lib/module/reanimated2/js-reanimated/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +9 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/index.js +1 -0
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationsManager.js +15 -10
- package/lib/module/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +16 -21
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +8 -12
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js +8 -12
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js +8 -13
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +16 -21
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/index.js +1 -0
- package/lib/module/reanimated2/layoutReanimation/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js +82 -0
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -0
- package/lib/module/reanimated2/mappers.js +16 -6
- package/lib/module/reanimated2/mappers.js.map +1 -1
- package/lib/module/reanimated2/mock.js +45 -0
- package/lib/module/reanimated2/mock.js.map +1 -1
- package/lib/module/reanimated2/mutables.js +4 -2
- package/lib/module/reanimated2/mutables.js.map +1 -1
- package/lib/module/reanimated2/platform-specific/checkVersion.js +35 -0
- package/lib/module/reanimated2/platform-specific/checkVersion.js.map +1 -0
- package/lib/module/reanimated2/platform-specific/checkVersion.web.js +8 -0
- package/lib/module/reanimated2/platform-specific/checkVersion.web.js.map +1 -0
- package/lib/module/reanimated2/pluginUtils.js +4 -0
- package/lib/module/reanimated2/pluginUtils.js.map +1 -0
- package/lib/module/reanimated2/shareables.js +38 -9
- package/lib/module/reanimated2/shareables.js.map +1 -1
- package/lib/module/reanimated2/threads.js +105 -4
- package/lib/module/reanimated2/threads.js.map +1 -1
- package/lib/module/reanimated2/utils.js +5 -0
- package/lib/module/reanimated2/utils.js.map +1 -1
- package/lib/module/reanimated2/valueSetter.js +1 -2
- package/lib/module/reanimated2/valueSetter.js.map +1 -1
- package/package.json +9 -8
- package/{plugin.js → plugin/index.js} +173 -228
- package/react-native-reanimated.d.ts +57 -10
- package/scripts/reanimated_utils.rb +15 -2
- package/src/createAnimatedComponent.tsx +238 -28
- package/src/reanimated2/Colors.ts +38 -11
- package/src/reanimated2/NativeReanimated/NativeReanimated.ts +63 -41
- package/src/reanimated2/animation/styleAnimation.ts +8 -1
- package/src/reanimated2/animation/util.ts +29 -16
- package/src/reanimated2/commonTypes.ts +28 -1
- package/src/reanimated2/component/FlatList.tsx +30 -5
- package/src/reanimated2/core.ts +45 -75
- package/src/reanimated2/errors.ts +57 -0
- package/src/reanimated2/frameCallback/FrameCallbackRegistryUI.ts +2 -2
- package/src/reanimated2/globals.d.ts +34 -18
- package/src/reanimated2/hook/index.ts +1 -1
- package/src/reanimated2/hook/useAnimatedKeyboard.ts +10 -4
- package/src/reanimated2/hook/useAnimatedReaction.ts +12 -5
- package/src/reanimated2/hook/useAnimatedRef.ts +1 -4
- package/src/reanimated2/hook/useAnimatedSensor.ts +88 -11
- package/src/reanimated2/hook/useAnimatedStyle.ts +43 -45
- package/src/reanimated2/hook/useDerivedValue.ts +8 -1
- package/src/reanimated2/hook/useScrollViewOffset.ts +2 -2
- package/src/reanimated2/hook/utils.ts +15 -61
- package/src/reanimated2/index.ts +1 -0
- package/src/reanimated2/initializers.ts +184 -0
- package/src/reanimated2/interpolateColor.ts +104 -20
- package/src/reanimated2/jestUtils.ts +1 -1
- package/src/reanimated2/js-reanimated/JSReanimated.ts +105 -18
- package/src/reanimated2/js-reanimated/Mapper.ts +32 -0
- package/src/reanimated2/js-reanimated/WebSensor.ts +34 -0
- package/src/reanimated2/js-reanimated/commonTypes.ts +0 -1
- package/src/reanimated2/js-reanimated/global.ts +4 -8
- package/src/reanimated2/js-reanimated/index.ts +0 -1
- package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +13 -1
- package/src/reanimated2/layoutReanimation/animationBuilder/index.ts +1 -0
- package/src/reanimated2/layoutReanimation/animationsManager.ts +17 -12
- package/src/reanimated2/layoutReanimation/defaultAnimations/Bounce.ts +16 -19
- package/src/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.ts +14 -11
- package/src/reanimated2/layoutReanimation/defaultAnimations/Roll.ts +21 -11
- package/src/reanimated2/layoutReanimation/defaultAnimations/Slide.ts +32 -11
- package/src/reanimated2/layoutReanimation/defaultAnimations/Zoom.ts +36 -19
- package/src/reanimated2/layoutReanimation/index.ts +1 -0
- package/src/reanimated2/layoutReanimation/sharedTransitions/index.ts +87 -0
- package/src/reanimated2/mappers.ts +17 -6
- package/src/reanimated2/mock.ts +128 -0
- package/src/reanimated2/mutables.ts +2 -0
- package/src/reanimated2/platform-specific/checkVersion.ts +39 -0
- package/src/reanimated2/platform-specific/checkVersion.web.ts +6 -0
- package/src/reanimated2/pluginUtils.ts +8 -0
- package/src/reanimated2/shareables.ts +47 -11
- package/src/reanimated2/threads.ts +103 -1
- package/src/reanimated2/utils.ts +6 -0
- package/src/reanimated2/valueSetter.ts +1 -2
- package/lib/commonjs/reanimated2/time.js +0 -55
- package/lib/commonjs/reanimated2/time.js.map +0 -1
- package/lib/module/reanimated2/time.js +0 -37
- package/lib/module/reanimated2/time.js.map +0 -1
- package/src/reanimated2/time.ts +0 -30
- /package/android/src/{main/java → reactNativeVersionPatch/ReanimatedUIManager/70}/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +0 -0
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { getTimestamp } from './time';
|
|
2
1
|
export { stopMapper } from './mappers';
|
|
3
2
|
export function valueSetter(sv, value) {
|
|
4
3
|
'worklet';
|
|
@@ -26,7 +25,7 @@ export function valueSetter(sv, value) {
|
|
|
26
25
|
animation.onStart(animation, sv.value, timestamp, previousAnimation);
|
|
27
26
|
};
|
|
28
27
|
|
|
29
|
-
const currentTimestamp =
|
|
28
|
+
const currentTimestamp = global.__frameTimestamp || performance.now();
|
|
30
29
|
initializeAnimation(currentTimestamp);
|
|
31
30
|
|
|
32
31
|
const step = timestamp => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["stopMapper","valueSetter","sv","value","previousAnimation","_animation","cancelled","onFrame","undefined","animation","_value","current","isHigherOrder","callback","initializeAnimation","timestamp","onStart","currentTimestamp","global","__frameTimestamp","performance","now","step","finished","requestAnimationFrame"],"sources":["valueSetter.ts"],"sourcesContent":["import { AnimationObject, AnimatableValue } from './commonTypes';\nimport { Descriptor } from './hook/commonTypes';\nexport { stopMapper } from './mappers';\n\nexport function valueSetter(sv: any, value: any): void {\n 'worklet';\n const previousAnimation = sv._animation;\n if (previousAnimation) {\n previousAnimation.cancelled = true;\n sv._animation = null;\n }\n if (\n typeof value === 'function' ||\n (value !== null &&\n typeof value === 'object' &&\n (value as AnimationObject).onFrame !== undefined)\n ) {\n const animation: AnimationObject =\n typeof value === 'function'\n ? (value as () => AnimationObject)()\n : (value as AnimationObject);\n // prevent setting again to the same value\n // and triggering the mappers that treat this value as an input\n // this happens when the animation's target value(stored in animation.current until animation.onStart is called) is set to the same value as a current one(this._value)\n // built in animations that are not higher order(withTiming, withSpring) hold target value in .current\n if (sv._value === animation.current && !animation.isHigherOrder) {\n animation.callback && animation.callback(true);\n return;\n }\n // animated set\n const initializeAnimation = (timestamp: number) => {\n animation.onStart(animation, sv.value, timestamp, previousAnimation);\n };\n const currentTimestamp = global.__frameTimestamp || performance.now();\n initializeAnimation(currentTimestamp);\n const step = (timestamp: number) => {\n if (animation.cancelled) {\n animation.callback && animation.callback(false /* finished */);\n return;\n }\n const finished = animation.onFrame(animation, timestamp);\n animation.finished = true;\n animation.timestamp = timestamp;\n sv._value = animation.current;\n if (finished) {\n animation.callback && animation.callback(true /* finished */);\n } else {\n requestAnimationFrame(step);\n }\n };\n\n sv._animation = animation;\n\n step(currentTimestamp);\n } else {\n // prevent setting again to the same value\n // and triggering the mappers that treat this value as an input\n if (sv._value === value) {\n return;\n }\n sv._value = value as Descriptor | AnimatableValue;\n }\n}\n"],"mappings":"AAEA,SAASA,UAAT,QAA2B,WAA3B;AAEA,OAAO,SAASC,WAAT,CAAqBC,EAArB,EAA8BC,KAA9B,EAAgD;EACrD;;EACA,MAAMC,iBAAiB,GAAGF,EAAE,CAACG,UAA7B;;EACA,IAAID,iBAAJ,EAAuB;IACrBA,iBAAiB,CAACE,SAAlB,GAA8B,IAA9B;IACAJ,EAAE,CAACG,UAAH,GAAgB,IAAhB;EACD;;EACD,IACE,OAAOF,KAAP,KAAiB,UAAjB,IACCA,KAAK,KAAK,IAAV,IACC,OAAOA,KAAP,KAAiB,QADlB,IAEEA,KAAD,CAA2BI,OAA3B,KAAuCC,SAJ3C,EAKE;IACA,MAAMC,SAA0B,GAC9B,OAAON,KAAP,KAAiB,UAAjB,GACKA,KAAD,EADJ,GAEKA,KAHP,CADA,CAKA;IACA;IACA;IACA;;IACA,IAAID,EAAE,CAACQ,MAAH,KAAcD,SAAS,CAACE,OAAxB,IAAmC,CAACF,SAAS,CAACG,aAAlD,EAAiE;MAC/DH,SAAS,CAACI,QAAV,IAAsBJ,SAAS,CAACI,QAAV,CAAmB,IAAnB,CAAtB;MACA;IACD,CAZD,CAaA;;;IACA,MAAMC,mBAAmB,GAAIC,SAAD,IAAuB;MACjDN,SAAS,CAACO,OAAV,CAAkBP,SAAlB,EAA6BP,EAAE,CAACC,KAAhC,EAAuCY,SAAvC,EAAkDX,iBAAlD;IACD,CAFD;;IAGA,MAAMa,gBAAgB,GAAGC,MAAM,CAACC,gBAAP,IAA2BC,WAAW,CAACC,GAAZ,EAApD;IACAP,mBAAmB,CAACG,gBAAD,CAAnB;;IACA,MAAMK,IAAI,GAAIP,SAAD,IAAuB;MAClC,IAAIN,SAAS,CAACH,SAAd,EAAyB;QACvBG,SAAS,CAACI,QAAV,IAAsBJ,SAAS,CAACI,QAAV,CAAmB;QAAM;QAAzB,CAAtB;QACA;MACD;;MACD,MAAMU,QAAQ,GAAGd,SAAS,CAACF,OAAV,CAAkBE,SAAlB,EAA6BM,SAA7B,CAAjB;MACAN,SAAS,CAACc,QAAV,GAAqB,IAArB;MACAd,SAAS,CAACM,SAAV,GAAsBA,SAAtB;MACAb,EAAE,CAACQ,MAAH,GAAYD,SAAS,CAACE,OAAtB;;MACA,IAAIY,QAAJ,EAAc;QACZd,SAAS,CAACI,QAAV,IAAsBJ,SAAS,CAACI,QAAV,CAAmB;QAAK;QAAxB,CAAtB;MACD,CAFD,MAEO;QACLW,qBAAqB,CAACF,IAAD,CAArB;MACD;IACF,CAdD;;IAgBApB,EAAE,CAACG,UAAH,GAAgBI,SAAhB;IAEAa,IAAI,CAACL,gBAAD,CAAJ;EACD,CA3CD,MA2CO;IACL;IACA;IACA,IAAIf,EAAE,CAACQ,MAAH,KAAcP,KAAlB,EAAyB;MACvB;IACD;;IACDD,EAAE,CAACQ,MAAH,GAAYP,KAAZ;EACD;AACF"}
|
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,6 +76,7 @@
|
|
|
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",
|
|
@@ -88,11 +89,11 @@
|
|
|
88
89
|
},
|
|
89
90
|
"devDependencies": {
|
|
90
91
|
"@babel/cli": "^7.17.6",
|
|
91
|
-
"@babel/core": "^7.
|
|
92
|
+
"@babel/core": "^7.20.0",
|
|
92
93
|
"@babel/plugin-proposal-class-properties": "^7.16.7",
|
|
93
94
|
"@babel/plugin-proposal-optional-chaining": "^7.16.7",
|
|
94
|
-
"@babel/preset-env": "^7.
|
|
95
|
-
"@react-native-community/eslint-config": "^
|
|
95
|
+
"@babel/preset-env": "^7.20.0",
|
|
96
|
+
"@react-native-community/eslint-config": "^3.2.0",
|
|
96
97
|
"@testing-library/jest-native": "^4.0.4",
|
|
97
98
|
"@testing-library/react-hooks": "^8.0.0",
|
|
98
99
|
"@testing-library/react-native": "^7.1.0",
|
|
@@ -102,7 +103,7 @@
|
|
|
102
103
|
"@types/babel__traverse": "^7.14.2",
|
|
103
104
|
"@types/invariant": "^2.2.35",
|
|
104
105
|
"@types/jest": "^27.4.0",
|
|
105
|
-
"@types/react
|
|
106
|
+
"@types/react": "^18.0.26",
|
|
106
107
|
"@typescript-eslint/eslint-plugin": "^5.11.0",
|
|
107
108
|
"@typescript-eslint/parser": "^5.11.0",
|
|
108
109
|
"babel-eslint": "^10.1.0",
|
|
@@ -114,6 +115,7 @@
|
|
|
114
115
|
"eslint-config-standard": "^16.0.3",
|
|
115
116
|
"eslint-import-resolver-babel-module": "^5.3.1",
|
|
116
117
|
"eslint-plugin-import": "^2.25.4",
|
|
118
|
+
"eslint-plugin-jest": "^27.2.1",
|
|
117
119
|
"eslint-plugin-node": "^11.1.0",
|
|
118
120
|
"eslint-plugin-promise": "^6.0.0",
|
|
119
121
|
"eslint-plugin-standard": "^5.0.0",
|
|
@@ -123,9 +125,8 @@
|
|
|
123
125
|
"madge": "^5.0.1",
|
|
124
126
|
"prettier": "^2.5.1",
|
|
125
127
|
"react": "17.0.2",
|
|
126
|
-
"react-native": "0.
|
|
128
|
+
"react-native": "0.71.3",
|
|
127
129
|
"react-native-builder-bob": "^0.18.3",
|
|
128
|
-
"react-native-codegen": "^0.0.7",
|
|
129
130
|
"react-native-gesture-handler": "^2.4.2",
|
|
130
131
|
"react-test-renderer": "17.0.2",
|
|
131
132
|
"release-it": "^13.7.2",
|
|
@@ -4,6 +4,7 @@ const hash = require('string-hash-64');
|
|
|
4
4
|
const traverse = require('@babel/traverse').default;
|
|
5
5
|
const { transformSync } = require('@babel/core');
|
|
6
6
|
const fs = require('fs');
|
|
7
|
+
const convertSourceMap = require('convert-source-map');
|
|
7
8
|
/**
|
|
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)
|
|
9
10
|
*/
|
|
@@ -32,8 +33,6 @@ const globals = new Set([
|
|
|
32
33
|
'this',
|
|
33
34
|
'console',
|
|
34
35
|
'performance',
|
|
35
|
-
'_setGlobalConsole',
|
|
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',
|
|
@@ -77,78 +77,19 @@ const globals = new Set([
|
|
|
77
77
|
'_removeShadowNodeFromRegistry',
|
|
78
78
|
'RegExp',
|
|
79
79
|
'Error',
|
|
80
|
+
'ErrorUtils',
|
|
80
81
|
'global',
|
|
81
82
|
'_measure',
|
|
82
83
|
'_scrollTo',
|
|
83
84
|
'_dispatchCommand',
|
|
84
85
|
'_setGestureState',
|
|
85
86
|
'_getCurrentTime',
|
|
86
|
-
'_eventTimestamp',
|
|
87
|
-
'_frameTimestamp',
|
|
88
87
|
'isNaN',
|
|
89
88
|
'LayoutAnimationRepository',
|
|
90
89
|
'_notifyAboutProgress',
|
|
91
90
|
'_notifyAboutEnd',
|
|
92
91
|
]);
|
|
93
92
|
|
|
94
|
-
// leaving way to avoid deep capturing by adding 'stopCapturing' to the blacklist
|
|
95
|
-
const blacklistedFunctions = new Set([
|
|
96
|
-
'stopCapturing',
|
|
97
|
-
'toString',
|
|
98
|
-
'map',
|
|
99
|
-
'filter',
|
|
100
|
-
'findIndex',
|
|
101
|
-
'forEach',
|
|
102
|
-
'valueOf',
|
|
103
|
-
'toPrecision',
|
|
104
|
-
'toExponential',
|
|
105
|
-
'constructor',
|
|
106
|
-
'toFixed',
|
|
107
|
-
'toLocaleString',
|
|
108
|
-
'toSource',
|
|
109
|
-
'charAt',
|
|
110
|
-
'charCodeAt',
|
|
111
|
-
'concat',
|
|
112
|
-
'indexOf',
|
|
113
|
-
'lastIndexOf',
|
|
114
|
-
'localeCompare',
|
|
115
|
-
'length',
|
|
116
|
-
'match',
|
|
117
|
-
'replace',
|
|
118
|
-
'search',
|
|
119
|
-
'slice',
|
|
120
|
-
'split',
|
|
121
|
-
'substr',
|
|
122
|
-
'substring',
|
|
123
|
-
'toLocaleLowerCase',
|
|
124
|
-
'toLocaleUpperCase',
|
|
125
|
-
'toLowerCase',
|
|
126
|
-
'toUpperCase',
|
|
127
|
-
'every',
|
|
128
|
-
'join',
|
|
129
|
-
'pop',
|
|
130
|
-
'push',
|
|
131
|
-
'reduce',
|
|
132
|
-
'reduceRight',
|
|
133
|
-
'reverse',
|
|
134
|
-
'shift',
|
|
135
|
-
'slice',
|
|
136
|
-
'some',
|
|
137
|
-
'sort',
|
|
138
|
-
'splice',
|
|
139
|
-
'unshift',
|
|
140
|
-
'hasOwnProperty',
|
|
141
|
-
'isPrototypeOf',
|
|
142
|
-
'propertyIsEnumerable',
|
|
143
|
-
'bind',
|
|
144
|
-
'apply',
|
|
145
|
-
'call',
|
|
146
|
-
'__callAsync',
|
|
147
|
-
'includes',
|
|
148
|
-
]);
|
|
149
|
-
|
|
150
|
-
const possibleOptFunction = new Set(['interpolate']);
|
|
151
|
-
|
|
152
93
|
const gestureHandlerGestureObjects = new Set([
|
|
153
94
|
// from https://github.com/software-mansion/react-native-gesture-handler/blob/new-api/src/handlers/gestures/gestureObjects.ts
|
|
154
95
|
'Tap',
|
|
@@ -178,112 +119,6 @@ const gestureHandlerBuilderMethods = new Set([
|
|
|
178
119
|
'onTouchesCancelled',
|
|
179
120
|
]);
|
|
180
121
|
|
|
181
|
-
class ClosureGenerator {
|
|
182
|
-
constructor() {
|
|
183
|
-
this.trie = [{}, false];
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
mergeAns(oldAns, newAns) {
|
|
187
|
-
const [purePath, node] = oldAns;
|
|
188
|
-
const [purePathUp, nodeUp] = newAns;
|
|
189
|
-
if (purePathUp.length !== 0) {
|
|
190
|
-
return [purePath.concat(purePathUp), nodeUp];
|
|
191
|
-
} else {
|
|
192
|
-
return [purePath, node];
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
findPrefixRec(path) {
|
|
197
|
-
const notFound = [[], null];
|
|
198
|
-
if (!path || path.node.type !== 'MemberExpression') {
|
|
199
|
-
return notFound;
|
|
200
|
-
}
|
|
201
|
-
const memberExpressionNode = path.node;
|
|
202
|
-
if (memberExpressionNode.property.type !== 'Identifier') {
|
|
203
|
-
return notFound;
|
|
204
|
-
}
|
|
205
|
-
if (
|
|
206
|
-
memberExpressionNode.computed ||
|
|
207
|
-
memberExpressionNode.property.name === 'value' ||
|
|
208
|
-
blacklistedFunctions.has(memberExpressionNode.property.name)
|
|
209
|
-
) {
|
|
210
|
-
// a.b[w] -> a.b.w in babel nodes
|
|
211
|
-
// a.v.value
|
|
212
|
-
// sth.map(() => )
|
|
213
|
-
return notFound;
|
|
214
|
-
}
|
|
215
|
-
if (
|
|
216
|
-
path.parent &&
|
|
217
|
-
path.parent.type === 'AssignmentExpression' &&
|
|
218
|
-
path.parent.left === path.node
|
|
219
|
-
) {
|
|
220
|
-
/// captured.newProp = 5;
|
|
221
|
-
return notFound;
|
|
222
|
-
}
|
|
223
|
-
const purePath = [memberExpressionNode.property.name];
|
|
224
|
-
const node = memberExpressionNode;
|
|
225
|
-
const upAns = this.findPrefixRec(path.parentPath);
|
|
226
|
-
return this.mergeAns([purePath, node], upAns);
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
findPrefix(base, babelPath) {
|
|
230
|
-
const purePath = [base];
|
|
231
|
-
const node = babelPath.node;
|
|
232
|
-
const upAns = this.findPrefixRec(babelPath.parentPath);
|
|
233
|
-
return this.mergeAns([purePath, node], upAns);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
addPath(base, babelPath) {
|
|
237
|
-
const [purePath, node] = this.findPrefix(base, babelPath);
|
|
238
|
-
let parent = this.trie;
|
|
239
|
-
let index = -1;
|
|
240
|
-
for (const current of purePath) {
|
|
241
|
-
index++;
|
|
242
|
-
if (parent[1]) {
|
|
243
|
-
continue;
|
|
244
|
-
}
|
|
245
|
-
if (!parent[0][current]) {
|
|
246
|
-
parent[0][current] = [{}, false];
|
|
247
|
-
}
|
|
248
|
-
if (index === purePath.length - 1) {
|
|
249
|
-
parent[0][current] = [node, true];
|
|
250
|
-
}
|
|
251
|
-
parent = parent[0][current];
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
generateNodeForBase(t, current, parent) {
|
|
256
|
-
const currentNode = parent[0][current];
|
|
257
|
-
if (currentNode[1]) {
|
|
258
|
-
return currentNode[0];
|
|
259
|
-
}
|
|
260
|
-
return t.objectExpression(
|
|
261
|
-
Object.keys(currentNode[0]).map((propertyName) =>
|
|
262
|
-
t.objectProperty(
|
|
263
|
-
t.identifier(propertyName),
|
|
264
|
-
this.generateNodeForBase(t, propertyName, currentNode),
|
|
265
|
-
false,
|
|
266
|
-
true
|
|
267
|
-
)
|
|
268
|
-
)
|
|
269
|
-
);
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
generate(t, variables, names) {
|
|
273
|
-
const arrayOfKeys = [...names];
|
|
274
|
-
return t.objectExpression(
|
|
275
|
-
variables.map((variable, index) =>
|
|
276
|
-
t.objectProperty(
|
|
277
|
-
t.identifier(variable.name),
|
|
278
|
-
this.generateNodeForBase(t, arrayOfKeys[index], this.trie),
|
|
279
|
-
false,
|
|
280
|
-
true
|
|
281
|
-
)
|
|
282
|
-
)
|
|
283
|
-
);
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
|
|
287
122
|
function isRelease() {
|
|
288
123
|
return ['production', 'release'].includes(process.env.BABEL_ENV);
|
|
289
124
|
}
|
|
@@ -369,7 +204,9 @@ function buildWorkletString(t, fun, closureVariables, name, inputMap) {
|
|
|
369
204
|
|
|
370
205
|
const code = generate(workletFunction).code;
|
|
371
206
|
|
|
372
|
-
|
|
207
|
+
const includeSourceMap = shouldGenerateSourceMap();
|
|
208
|
+
|
|
209
|
+
if (includeSourceMap) {
|
|
373
210
|
// Clear contents array (should be empty anyways)
|
|
374
211
|
inputMap.sourcesContent = [];
|
|
375
212
|
// Include source contents in source map, because Flipper/iframe is not
|
|
@@ -383,8 +220,8 @@ function buildWorkletString(t, fun, closureVariables, name, inputMap) {
|
|
|
383
220
|
|
|
384
221
|
const transformed = transformSync(code, {
|
|
385
222
|
plugins: [prependClosureVariablesIfNecessary()],
|
|
386
|
-
compact: !
|
|
387
|
-
sourceMaps:
|
|
223
|
+
compact: !includeSourceMap,
|
|
224
|
+
sourceMaps: includeSourceMap,
|
|
388
225
|
inputSourceMap: inputMap,
|
|
389
226
|
ast: false,
|
|
390
227
|
babelrc: false,
|
|
@@ -392,7 +229,17 @@ function buildWorkletString(t, fun, closureVariables, name, inputMap) {
|
|
|
392
229
|
comments: false,
|
|
393
230
|
});
|
|
394
231
|
|
|
395
|
-
|
|
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)];
|
|
396
243
|
}
|
|
397
244
|
|
|
398
245
|
function makeWorkletName(t, fun) {
|
|
@@ -405,7 +252,7 @@ function makeWorkletName(t, fun) {
|
|
|
405
252
|
if (t.isFunctionExpression(fun) && t.isIdentifier(fun.node.id)) {
|
|
406
253
|
return fun.node.id.name;
|
|
407
254
|
}
|
|
408
|
-
return '
|
|
255
|
+
return 'anonymous'; // fallback for ArrowFunctionExpression and unnamed FunctionExpression
|
|
409
256
|
}
|
|
410
257
|
|
|
411
258
|
function makeWorklet(t, fun, state) {
|
|
@@ -415,8 +262,6 @@ function makeWorklet(t, fun, state) {
|
|
|
415
262
|
const functionName = makeWorkletName(t, fun);
|
|
416
263
|
|
|
417
264
|
const closure = new Map();
|
|
418
|
-
const closureGenerator = new ClosureGenerator();
|
|
419
|
-
const options = {};
|
|
420
265
|
|
|
421
266
|
// remove 'worklet'; directive before generating string
|
|
422
267
|
fun.traverse({
|
|
@@ -458,13 +303,6 @@ function makeWorklet(t, fun, state) {
|
|
|
458
303
|
inputSourceMap: codeObject.map,
|
|
459
304
|
});
|
|
460
305
|
|
|
461
|
-
if (
|
|
462
|
-
fun.parent &&
|
|
463
|
-
fun.parent.callee &&
|
|
464
|
-
fun.parent.callee.name === 'useAnimatedStyle'
|
|
465
|
-
) {
|
|
466
|
-
options.optFlags = isPossibleOptimization(transformed.ast);
|
|
467
|
-
}
|
|
468
306
|
traverse(transformed.ast, {
|
|
469
307
|
ReferencedIdentifier(path) {
|
|
470
308
|
const name = path.node.name;
|
|
@@ -499,7 +337,6 @@ function makeWorklet(t, fun, state) {
|
|
|
499
337
|
currentScope = currentScope.parent;
|
|
500
338
|
}
|
|
501
339
|
closure.set(name, path.node);
|
|
502
|
-
closureGenerator.addPath(name, path);
|
|
503
340
|
},
|
|
504
341
|
});
|
|
505
342
|
|
|
@@ -514,7 +351,7 @@ function makeWorklet(t, fun, state) {
|
|
|
514
351
|
funExpression = clone;
|
|
515
352
|
}
|
|
516
353
|
|
|
517
|
-
const funString = buildWorkletString(
|
|
354
|
+
const [funString, sourceMapString] = buildWorkletString(
|
|
518
355
|
t,
|
|
519
356
|
transformed.ast,
|
|
520
357
|
variables,
|
|
@@ -529,14 +366,45 @@ function makeWorklet(t, fun, state) {
|
|
|
529
366
|
location = path.relative(state.cwd, location);
|
|
530
367
|
}
|
|
531
368
|
|
|
532
|
-
|
|
533
|
-
if (
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
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;
|
|
538
377
|
}
|
|
539
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
|
+
|
|
540
408
|
const statements = [
|
|
541
409
|
t.variableDeclaration('const', [
|
|
542
410
|
t.variableDeclarator(privateFunctionId, funExpression),
|
|
@@ -545,14 +413,11 @@ function makeWorklet(t, fun, state) {
|
|
|
545
413
|
t.assignmentExpression(
|
|
546
414
|
'=',
|
|
547
415
|
t.memberExpression(privateFunctionId, t.identifier('_closure'), false),
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
'=',
|
|
554
|
-
t.memberExpression(privateFunctionId, t.identifier('asString'), false),
|
|
555
|
-
t.stringLiteral(funString)
|
|
416
|
+
t.objectExpression(
|
|
417
|
+
variables.map((variable) =>
|
|
418
|
+
t.objectProperty(t.identifier(variable.name), variable, false, true)
|
|
419
|
+
)
|
|
420
|
+
)
|
|
556
421
|
)
|
|
557
422
|
),
|
|
558
423
|
t.expressionStatement(
|
|
@@ -560,10 +425,10 @@ function makeWorklet(t, fun, state) {
|
|
|
560
425
|
'=',
|
|
561
426
|
t.memberExpression(
|
|
562
427
|
privateFunctionId,
|
|
563
|
-
t.identifier('
|
|
428
|
+
t.identifier('__initData'),
|
|
564
429
|
false
|
|
565
430
|
),
|
|
566
|
-
|
|
431
|
+
initDataId
|
|
567
432
|
)
|
|
568
433
|
),
|
|
569
434
|
t.expressionStatement(
|
|
@@ -571,25 +436,37 @@ function makeWorklet(t, fun, state) {
|
|
|
571
436
|
'=',
|
|
572
437
|
t.memberExpression(
|
|
573
438
|
privateFunctionId,
|
|
574
|
-
t.identifier('
|
|
439
|
+
t.identifier('__workletHash'),
|
|
575
440
|
false
|
|
576
441
|
),
|
|
577
|
-
t.
|
|
442
|
+
t.numericLiteral(workletHash)
|
|
578
443
|
)
|
|
579
444
|
),
|
|
580
445
|
];
|
|
581
446
|
|
|
582
|
-
if (
|
|
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
|
+
);
|
|
583
460
|
statements.push(
|
|
584
461
|
t.expressionStatement(
|
|
585
462
|
t.assignmentExpression(
|
|
586
463
|
'=',
|
|
587
464
|
t.memberExpression(
|
|
588
465
|
privateFunctionId,
|
|
589
|
-
t.identifier('
|
|
466
|
+
t.identifier('__stackDetails'),
|
|
590
467
|
false
|
|
591
468
|
),
|
|
592
|
-
t.
|
|
469
|
+
t.identifier('_e')
|
|
593
470
|
)
|
|
594
471
|
)
|
|
595
472
|
);
|
|
@@ -782,10 +659,14 @@ function isGestureObject(t, node) {
|
|
|
782
659
|
}
|
|
783
660
|
|
|
784
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
|
+
|
|
785
667
|
const name =
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
: path.node.callee.name;
|
|
668
|
+
callee.type === 'MemberExpression' ? callee.property.name : callee.name;
|
|
669
|
+
|
|
789
670
|
if (
|
|
790
671
|
objectHooks.has(name) &&
|
|
791
672
|
path.get('arguments.0').type === 'ObjectExpression'
|
|
@@ -809,30 +690,89 @@ function processWorklets(t, path, state) {
|
|
|
809
690
|
}
|
|
810
691
|
}
|
|
811
692
|
|
|
812
|
-
|
|
813
|
-
|
|
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
|
+
}
|
|
814
730
|
|
|
815
|
-
function
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
isFunctionCall = true;
|
|
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);
|
|
822
737
|
}
|
|
823
|
-
}
|
|
824
|
-
IfStatement() {
|
|
825
|
-
isStatement = true;
|
|
826
|
-
},
|
|
827
|
-
});
|
|
828
|
-
let flags = 0;
|
|
829
|
-
if (!isFunctionCall) {
|
|
830
|
-
flags = flags | FUNCTIONLESS_FLAG;
|
|
738
|
+
}
|
|
831
739
|
}
|
|
832
|
-
|
|
833
|
-
|
|
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);
|
|
834
775
|
}
|
|
835
|
-
return flags;
|
|
836
776
|
}
|
|
837
777
|
|
|
838
778
|
module.exports = function ({ types: t }) {
|
|
@@ -857,6 +797,11 @@ module.exports = function ({ types: t }) {
|
|
|
857
797
|
processIfGestureHandlerEventCallbackFunctionNode(t, path, state);
|
|
858
798
|
},
|
|
859
799
|
},
|
|
800
|
+
JSXAttribute: {
|
|
801
|
+
enter(path, state) {
|
|
802
|
+
processInlineStylesWarning(t, path, state);
|
|
803
|
+
},
|
|
804
|
+
},
|
|
860
805
|
},
|
|
861
806
|
};
|
|
862
807
|
};
|