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
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <jsi/jsi.h>
|
|
4
|
+
#include <sstream>
|
|
5
|
+
#include <string>
|
|
6
|
+
#include <tuple>
|
|
7
|
+
#include <utility>
|
|
8
|
+
|
|
9
|
+
using namespace facebook;
|
|
10
|
+
|
|
11
|
+
namespace reanimated {
|
|
12
|
+
namespace jsi_utils {
|
|
13
|
+
|
|
14
|
+
// `get` functions take a pointer to `jsi::Value` and
|
|
15
|
+
// call an appropriate method to cast to the native type
|
|
16
|
+
template <typename T>
|
|
17
|
+
inline T get(jsi::Runtime &rt, const jsi::Value *value);
|
|
18
|
+
|
|
19
|
+
template <>
|
|
20
|
+
inline double get<double>(jsi::Runtime &rt, const jsi::Value *value) {
|
|
21
|
+
return value->asNumber();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
template <>
|
|
25
|
+
inline int get<int>(jsi::Runtime &rt, const jsi::Value *value) {
|
|
26
|
+
return value->asNumber();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
template <>
|
|
30
|
+
inline bool get<bool>(jsi::Runtime &rt, const jsi::Value *value) {
|
|
31
|
+
if (!value->isBool()) {
|
|
32
|
+
throw jsi::JSINativeException("Expected a boolean");
|
|
33
|
+
}
|
|
34
|
+
return value->getBool();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
template <>
|
|
38
|
+
inline jsi::Object get<jsi::Object>(jsi::Runtime &rt, const jsi::Value *value) {
|
|
39
|
+
return value->asObject(rt);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
template <>
|
|
43
|
+
inline jsi::Value const &get<jsi::Value const &>(
|
|
44
|
+
jsi::Runtime &rt,
|
|
45
|
+
const jsi::Value *value) {
|
|
46
|
+
return *value;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// `convertArgs` functions take a variadic template parameter of target (C++)
|
|
50
|
+
// argument types `Targs` and a `jsi::Value` array `args`, and converts `args`
|
|
51
|
+
// to a tuple of typed C++ arguments to be passed to the native implementation.
|
|
52
|
+
// This is accomplished by dispatching (at compile time) to the correct
|
|
53
|
+
// implementation based on the first type of `Targs`, using SFINAE to select the
|
|
54
|
+
// correct specialization, and concatenating with the result of recursion on the
|
|
55
|
+
// rest of `Targs`
|
|
56
|
+
|
|
57
|
+
// BEGIN implementations for `convertArgs` specializations.
|
|
58
|
+
// specialization for empty `Targs` - returns an empty tuple
|
|
59
|
+
template <typename... Args>
|
|
60
|
+
inline std::enable_if_t<(sizeof...(Args) == 0), std::tuple<>> convertArgs(
|
|
61
|
+
jsi::Runtime &rt,
|
|
62
|
+
const jsi::Value *args) {
|
|
63
|
+
return std::make_tuple();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// calls `get<First>` on the first argument to retrieve the native type,
|
|
67
|
+
// then calls recursively on the rest of `args`
|
|
68
|
+
// and returns the concatenation of results
|
|
69
|
+
template <typename T, typename... Rest>
|
|
70
|
+
inline std::tuple<T, Rest...> convertArgs(
|
|
71
|
+
jsi::Runtime &rt,
|
|
72
|
+
const jsi::Value *args) {
|
|
73
|
+
auto arg = std::tuple<T>(get<T>(rt, args));
|
|
74
|
+
auto rest = convertArgs<Rest...>(rt, std::next(args));
|
|
75
|
+
return std::tuple_cat(std::move(arg), std::move(rest));
|
|
76
|
+
}
|
|
77
|
+
// END implementations for `convertArgs` specializations.
|
|
78
|
+
|
|
79
|
+
// returns a tuple with the result of casting `args` to appropriate
|
|
80
|
+
// native C++ types needed to call `function`
|
|
81
|
+
template <typename Ret, typename... Args>
|
|
82
|
+
std::tuple<Args...> getArgsForFunction(
|
|
83
|
+
std::function<Ret(Args...)> function,
|
|
84
|
+
jsi::Runtime &rt,
|
|
85
|
+
const jsi::Value *args,
|
|
86
|
+
const size_t count) {
|
|
87
|
+
assert(sizeof...(Args) == count);
|
|
88
|
+
return convertArgs<Args...>(rt, args);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// returns a tuple with the result of casting `args` to appropriate
|
|
92
|
+
// native C++ types needed to call `function`,
|
|
93
|
+
// passing `rt` as the first argument
|
|
94
|
+
template <typename Ret, typename... Args>
|
|
95
|
+
std::tuple<jsi::Runtime &, Args...> getArgsForFunction(
|
|
96
|
+
std::function<Ret(jsi::Runtime &, Args...)> function,
|
|
97
|
+
jsi::Runtime &rt,
|
|
98
|
+
const jsi::Value *args,
|
|
99
|
+
const size_t count) {
|
|
100
|
+
assert(sizeof...(Args) == count);
|
|
101
|
+
return std::tuple_cat(std::tie(rt), convertArgs<Args...>(rt, args));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// calls `function` with `args`
|
|
105
|
+
template <typename Ret, typename... Args>
|
|
106
|
+
inline jsi::Value apply(
|
|
107
|
+
std::function<Ret(Args...)> function,
|
|
108
|
+
std::tuple<Args...> args) {
|
|
109
|
+
return std::apply(function, std::move(args));
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// calls void-returning `function` with `args`,
|
|
113
|
+
// and returns `undefined`
|
|
114
|
+
template <typename... Args>
|
|
115
|
+
inline jsi::Value apply(
|
|
116
|
+
std::function<void(Args...)> function,
|
|
117
|
+
std::tuple<Args...> args) {
|
|
118
|
+
std::apply(function, std::move(args));
|
|
119
|
+
return jsi::Value::undefined();
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// returns a function with JSI calling convention
|
|
123
|
+
// from a native function `function`
|
|
124
|
+
template <typename Fun>
|
|
125
|
+
jsi::HostFunctionType createHostFunction(Fun function) {
|
|
126
|
+
return [function](
|
|
127
|
+
jsi::Runtime &rt,
|
|
128
|
+
const jsi::Value &thisValue,
|
|
129
|
+
const jsi::Value *args,
|
|
130
|
+
const size_t count) {
|
|
131
|
+
auto argz = getArgsForFunction(function, rt, args, count);
|
|
132
|
+
return apply(function, std::move(argz));
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// used to determine if `function<Ret(Args...)>`
|
|
137
|
+
// takes `Runtime &` as its first argument
|
|
138
|
+
template <typename... Args>
|
|
139
|
+
struct takes_runtime {
|
|
140
|
+
static constexpr size_t value = 0;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
// specialization for `function<Ret(Runtime &, Rest...)`
|
|
144
|
+
template <typename... Rest>
|
|
145
|
+
struct takes_runtime<jsi::Runtime &, Rest...> {
|
|
146
|
+
static constexpr size_t value = 1;
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
// creates a JSI compatible function from `function`
|
|
150
|
+
// and installs it as a global function named `name`
|
|
151
|
+
// in the `rt` JS runtime
|
|
152
|
+
template <typename Ret, typename... Args>
|
|
153
|
+
void installJsiFunction(
|
|
154
|
+
jsi::Runtime &rt,
|
|
155
|
+
std::string_view name,
|
|
156
|
+
std::function<Ret(Args...)> function) {
|
|
157
|
+
auto clb = createHostFunction(function);
|
|
158
|
+
auto argsCount = sizeof...(Args) - takes_runtime<Args...>::value;
|
|
159
|
+
jsi::Value jsiFunction = jsi::Function::createFromHostFunction(
|
|
160
|
+
rt, jsi::PropNameID::forAscii(rt, name.data()), argsCount, clb);
|
|
161
|
+
rt.global().setProperty(rt, name.data(), jsiFunction);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// this should take care of passing types convertible to `function`
|
|
165
|
+
template <typename Fun>
|
|
166
|
+
void installJsiFunction(jsi::Runtime &rt, std::string_view name, Fun function) {
|
|
167
|
+
installJsiFunction(rt, name, std::function(std::forward<Fun>(function)));
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
jsi::Array convertStringToArray(
|
|
171
|
+
jsi::Runtime &rt,
|
|
172
|
+
const std::string &value,
|
|
173
|
+
const unsigned int expectedSize);
|
|
174
|
+
|
|
175
|
+
} // namespace jsi_utils
|
|
176
|
+
} // namespace reanimated
|
|
@@ -27,7 +27,7 @@ using UpdatePropsFunction = std::function<void(
|
|
|
27
27
|
const jsi::Value &shadowNodeValue,
|
|
28
28
|
const jsi::Value &props)>;
|
|
29
29
|
using RemoveShadowNodeFromRegistryFunction =
|
|
30
|
-
std::function<void(jsi::Runtime &rt, const jsi::Value &
|
|
30
|
+
std::function<void(jsi::Runtime &rt, const jsi::Value &tag)>;
|
|
31
31
|
using DispatchCommandFunction = std::function<void(
|
|
32
32
|
jsi::Runtime &rt,
|
|
33
33
|
const jsi::Value &shadowNodeValue,
|
|
@@ -42,7 +42,7 @@ using UpdatePropsFunction = std::function<void(
|
|
|
42
42
|
jsi::Runtime &rt,
|
|
43
43
|
int viewTag,
|
|
44
44
|
const jsi::Value &viewName,
|
|
45
|
-
|
|
45
|
+
jsi::Object object)>;
|
|
46
46
|
using ScrollToFunction = std::function<void(int, double, double, bool)>;
|
|
47
47
|
using MeasureFunction =
|
|
48
48
|
std::function<std::vector<std::pair<std::string, double>>(int)>;
|
|
@@ -54,11 +54,11 @@ using RequestRender =
|
|
|
54
54
|
using TimeProviderFunction = std::function<double(void)>;
|
|
55
55
|
|
|
56
56
|
using ProgressLayoutAnimationFunction =
|
|
57
|
-
std::function<void(int,
|
|
57
|
+
std::function<void(int, jsi::Object newProps, bool isSharedTransition)>;
|
|
58
58
|
using EndLayoutAnimationFunction = std::function<void(int, bool, bool)>;
|
|
59
59
|
|
|
60
60
|
using RegisterSensorFunction =
|
|
61
|
-
std::function<int(int, int, std::function<void(double[])>)>;
|
|
61
|
+
std::function<int(int, int, int, std::function<void(double[], int)>)>;
|
|
62
62
|
using UnregisterSensorFunction = std::function<void(int)>;
|
|
63
63
|
using SetGestureStateFunction = std::function<void(int, int)>;
|
|
64
64
|
using ConfigurePropsFunction = std::function<void(
|
|
@@ -66,7 +66,7 @@ using ConfigurePropsFunction = std::function<void(
|
|
|
66
66
|
const jsi::Value &uiProps,
|
|
67
67
|
const jsi::Value &nativeProps)>;
|
|
68
68
|
using KeyboardEventSubscribeFunction =
|
|
69
|
-
std::function<int(std::function<void(int, int)
|
|
69
|
+
std::function<int(std::function<void(int, int)>, bool)>;
|
|
70
70
|
using KeyboardEventUnsubscribeFunction = std::function<void(int)>;
|
|
71
71
|
|
|
72
72
|
struct PlatformDepMethodsHolder {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#include "ReanimatedVersion.h"
|
|
2
|
+
|
|
3
|
+
#ifdef REANIMATED_VERSION
|
|
4
|
+
#define STRINGIZE(x) #x
|
|
5
|
+
#define STRINGIZE2(x) STRINGIZE(x)
|
|
6
|
+
#define REANIMATED_VERSION_STRING STRINGIZE2(REANIMATED_VERSION)
|
|
7
|
+
#endif // REANIMATED_VERSION
|
|
8
|
+
|
|
9
|
+
using namespace facebook;
|
|
10
|
+
|
|
11
|
+
namespace reanimated {
|
|
12
|
+
|
|
13
|
+
jsi::String getReanimatedVersionString(jsi::Runtime &rt) {
|
|
14
|
+
return jsi::String::createFromUtf8(rt, REANIMATED_VERSION_STRING);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
}; // namespace reanimated
|
|
@@ -4,10 +4,24 @@
|
|
|
4
4
|
#include <memory>
|
|
5
5
|
#include <unordered_map>
|
|
6
6
|
#include <utility>
|
|
7
|
+
#include "JsiUtils.h"
|
|
7
8
|
#include "ReanimatedHiddenHeaders.h"
|
|
8
9
|
|
|
9
10
|
namespace reanimated {
|
|
10
11
|
|
|
12
|
+
static const std::function<void(jsi::Runtime &, jsi::Value const &)> logValue =
|
|
13
|
+
[](jsi::Runtime &rt, jsi::Value const &value) {
|
|
14
|
+
if (value.isString()) {
|
|
15
|
+
Logger::log(value.getString(rt).utf8(rt).c_str());
|
|
16
|
+
} else if (value.isNumber()) {
|
|
17
|
+
Logger::log(value.getNumber());
|
|
18
|
+
} else if (value.isUndefined()) {
|
|
19
|
+
Logger::log("undefined");
|
|
20
|
+
} else {
|
|
21
|
+
Logger::log("unsupported value type");
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
11
25
|
std::unordered_map<RuntimePointer, RuntimeType>
|
|
12
26
|
&RuntimeDecorator::runtimeRegistry() {
|
|
13
27
|
static std::unordered_map<RuntimePointer, RuntimeType> runtimeRegistry;
|
|
@@ -57,47 +71,7 @@ void RuntimeDecorator::decorateRuntime(
|
|
|
57
71
|
evalWithSourceUrl));
|
|
58
72
|
#endif // DEBUG
|
|
59
73
|
|
|
60
|
-
|
|
61
|
-
const jsi::Value &thisValue,
|
|
62
|
-
const jsi::Value *args,
|
|
63
|
-
size_t count) -> jsi::Value {
|
|
64
|
-
const jsi::Value *value = &args[0];
|
|
65
|
-
if (value->isString()) {
|
|
66
|
-
Logger::log(value->getString(rt).utf8(rt).c_str());
|
|
67
|
-
} else if (value->isNumber()) {
|
|
68
|
-
Logger::log(value->getNumber());
|
|
69
|
-
} else if (value->isUndefined()) {
|
|
70
|
-
Logger::log("undefined");
|
|
71
|
-
} else {
|
|
72
|
-
Logger::log("unsupported value type");
|
|
73
|
-
}
|
|
74
|
-
return jsi::Value::undefined();
|
|
75
|
-
};
|
|
76
|
-
jsi::Value log = jsi::Function::createFromHostFunction(
|
|
77
|
-
rt, jsi::PropNameID::forAscii(rt, "_log"), 1, callback);
|
|
78
|
-
rt.global().setProperty(rt, "_log", log);
|
|
79
|
-
|
|
80
|
-
auto chronoNow = [](jsi::Runtime &rt,
|
|
81
|
-
const jsi::Value &thisValue,
|
|
82
|
-
const jsi::Value *args,
|
|
83
|
-
size_t count) -> jsi::Value {
|
|
84
|
-
double now = std::chrono::system_clock::now().time_since_epoch() /
|
|
85
|
-
std::chrono::milliseconds(1);
|
|
86
|
-
return jsi::Value(now);
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
rt.global().setProperty(
|
|
90
|
-
rt,
|
|
91
|
-
"_chronoNow",
|
|
92
|
-
jsi::Function::createFromHostFunction(
|
|
93
|
-
rt, jsi::PropNameID::forAscii(rt, "_chronoNow"), 0, chronoNow));
|
|
94
|
-
jsi::Object performance(rt);
|
|
95
|
-
performance.setProperty(
|
|
96
|
-
rt,
|
|
97
|
-
"now",
|
|
98
|
-
jsi::Function::createFromHostFunction(
|
|
99
|
-
rt, jsi::PropNameID::forAscii(rt, "now"), 0, chronoNow));
|
|
100
|
-
rt.global().setProperty(rt, "performance", performance);
|
|
74
|
+
jsi_utils::installJsiFunction(rt, "_log", logValue);
|
|
101
75
|
}
|
|
102
76
|
|
|
103
77
|
void RuntimeDecorator::decorateUIRuntime(
|
|
@@ -115,8 +89,6 @@ void RuntimeDecorator::decorateUIRuntime(
|
|
|
115
89
|
const MakeShareableCloneFunction makeShareableClone,
|
|
116
90
|
const UpdateDataSynchronouslyFunction updateDataSynchronously,
|
|
117
91
|
const TimeProviderFunction getCurrentTime,
|
|
118
|
-
const RegisterSensorFunction registerSensor,
|
|
119
|
-
const UnregisterSensorFunction unregisterSensor,
|
|
120
92
|
const SetGestureStateFunction setGestureState,
|
|
121
93
|
const ProgressLayoutAnimationFunction progressLayoutAnimationFunction,
|
|
122
94
|
const EndLayoutAnimationFunction endLayoutAnimationFunction) {
|
|
@@ -124,95 +96,17 @@ void RuntimeDecorator::decorateUIRuntime(
|
|
|
124
96
|
rt.global().setProperty(rt, "_UI", jsi::Value(true));
|
|
125
97
|
|
|
126
98
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
updateProps(rt, args[0], args[1]);
|
|
133
|
-
return jsi::Value::undefined();
|
|
134
|
-
};
|
|
135
|
-
jsi::Value updatePropsHostFunction = jsi::Function::createFromHostFunction(
|
|
136
|
-
rt, jsi::PropNameID::forAscii(rt, "_updatePropsFabric"), 2, clb);
|
|
137
|
-
rt.global().setProperty(rt, "_updatePropsFabric", updatePropsHostFunction);
|
|
138
|
-
|
|
139
|
-
auto _removeShadowNodeFromRegistry = [removeShadowNodeFromRegistry](
|
|
140
|
-
jsi::Runtime &rt,
|
|
141
|
-
const jsi::Value &thisValue,
|
|
142
|
-
const jsi::Value *args,
|
|
143
|
-
const size_t count) -> jsi::Value {
|
|
144
|
-
removeShadowNodeFromRegistry(rt, args[0]);
|
|
145
|
-
return jsi::Value::undefined();
|
|
146
|
-
};
|
|
147
|
-
jsi::Value removeShadowNodeFromRegistryHostFunction =
|
|
148
|
-
jsi::Function::createFromHostFunction(
|
|
149
|
-
rt,
|
|
150
|
-
jsi::PropNameID::forAscii(rt, "_removeShadowNodeFromRegistry"),
|
|
151
|
-
2,
|
|
152
|
-
_removeShadowNodeFromRegistry);
|
|
153
|
-
rt.global().setProperty(
|
|
154
|
-
rt,
|
|
155
|
-
"_removeShadowNodeFromRegistry",
|
|
156
|
-
removeShadowNodeFromRegistryHostFunction);
|
|
157
|
-
|
|
158
|
-
auto clb3 = [dispatchCommand](
|
|
159
|
-
jsi::Runtime &rt,
|
|
160
|
-
const jsi::Value &thisValue,
|
|
161
|
-
const jsi::Value *args,
|
|
162
|
-
const size_t count) -> jsi::Value {
|
|
163
|
-
dispatchCommand(rt, args[0], args[1], args[2]);
|
|
164
|
-
return jsi::Value::undefined();
|
|
165
|
-
};
|
|
166
|
-
jsi::Value dispatchCommandHostFunction =
|
|
167
|
-
jsi::Function::createFromHostFunction(
|
|
168
|
-
rt, jsi::PropNameID::forAscii(rt, "_dispatchCommand"), 3, clb3);
|
|
169
|
-
rt.global().setProperty(rt, "_dispatchCommand", dispatchCommandHostFunction);
|
|
170
|
-
|
|
171
|
-
auto _measure = [measure](
|
|
172
|
-
jsi::Runtime &rt,
|
|
173
|
-
const jsi::Value &thisValue,
|
|
174
|
-
const jsi::Value *args,
|
|
175
|
-
const size_t count) -> jsi::Value {
|
|
176
|
-
return measure(rt, args[0]);
|
|
177
|
-
};
|
|
99
|
+
jsi_utils::installJsiFunction(rt, "_updatePropsFabric", updateProps);
|
|
100
|
+
jsi_utils::installJsiFunction(
|
|
101
|
+
rt, "_removeShadowNodeFromRegistry", removeShadowNodeFromRegistry);
|
|
102
|
+
jsi_utils::installJsiFunction(rt, "_dispatchCommand", dispatchCommand);
|
|
103
|
+
jsi_utils::installJsiFunction(rt, "_measure", measure);
|
|
178
104
|
#else
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
const jsi::Value &thisValue,
|
|
182
|
-
const jsi::Value *args,
|
|
183
|
-
const size_t count) -> jsi::Value {
|
|
184
|
-
const auto viewTag = args[0].asNumber();
|
|
185
|
-
const jsi::Value *viewName = &args[1];
|
|
186
|
-
const auto params = args[2].asObject(rt);
|
|
187
|
-
updateProps(rt, viewTag, *viewName, params);
|
|
188
|
-
return jsi::Value::undefined();
|
|
189
|
-
};
|
|
190
|
-
jsi::Value updatePropsHostFunction = jsi::Function::createFromHostFunction(
|
|
191
|
-
rt, jsi::PropNameID::forAscii(rt, "_updatePropsPaper"), 3, clb);
|
|
192
|
-
rt.global().setProperty(rt, "_updatePropsPaper", updatePropsHostFunction);
|
|
193
|
-
|
|
194
|
-
auto _scrollTo = [scrollTo](
|
|
195
|
-
jsi::Runtime &rt,
|
|
196
|
-
const jsi::Value &thisValue,
|
|
197
|
-
const jsi::Value *args,
|
|
198
|
-
const size_t count) -> jsi::Value {
|
|
199
|
-
int viewTag = static_cast<int>(args[0].asNumber());
|
|
200
|
-
double x = args[1].asNumber();
|
|
201
|
-
double y = args[2].asNumber();
|
|
202
|
-
bool animated = args[3].getBool();
|
|
203
|
-
scrollTo(viewTag, x, y, animated);
|
|
204
|
-
return jsi::Value::undefined();
|
|
205
|
-
};
|
|
206
|
-
jsi::Value scrollToFunction = jsi::Function::createFromHostFunction(
|
|
207
|
-
rt, jsi::PropNameID::forAscii(rt, "_scrollTo"), 4, _scrollTo);
|
|
208
|
-
rt.global().setProperty(rt, "_scrollTo", scrollToFunction);
|
|
105
|
+
jsi_utils::installJsiFunction(rt, "_updatePropsPaper", updateProps);
|
|
106
|
+
jsi_utils::installJsiFunction(rt, "_scrollTo", scrollTo);
|
|
209
107
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
const jsi::Value &thisValue,
|
|
213
|
-
const jsi::Value *args,
|
|
214
|
-
const size_t count) -> jsi::Value {
|
|
215
|
-
int viewTag = static_cast<int>(args[0].asNumber());
|
|
108
|
+
std::function<jsi::Value(jsi::Runtime &, int)> _measure =
|
|
109
|
+
[measure](jsi::Runtime &rt, int viewTag) -> jsi::Value {
|
|
216
110
|
auto result = measure(viewTag);
|
|
217
111
|
jsi::Object resultObject(rt);
|
|
218
112
|
for (auto &i : result) {
|
|
@@ -220,113 +114,38 @@ void RuntimeDecorator::decorateUIRuntime(
|
|
|
220
114
|
}
|
|
221
115
|
return resultObject;
|
|
222
116
|
};
|
|
223
|
-
#endif // RCT_NEW_ARCH_ENABLED
|
|
224
|
-
|
|
225
|
-
jsi::Value measureFunction = jsi::Function::createFromHostFunction(
|
|
226
|
-
rt, jsi::PropNameID::forAscii(rt, "_measure"), 1, _measure);
|
|
227
|
-
rt.global().setProperty(rt, "_measure", measureFunction);
|
|
228
117
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
const jsi::Value &thisValue,
|
|
232
|
-
const jsi::Value *args,
|
|
233
|
-
const size_t count) -> jsi::Value {
|
|
234
|
-
requestFrame(rt, std::move(args[0]));
|
|
235
|
-
return jsi::Value::undefined();
|
|
236
|
-
};
|
|
237
|
-
jsi::Value requestAnimationFrame = jsi::Function::createFromHostFunction(
|
|
238
|
-
rt, jsi::PropNameID::forAscii(rt, "requestAnimationFrame"), 1, clb2);
|
|
239
|
-
rt.global().setProperty(rt, "requestAnimationFrame", requestAnimationFrame);
|
|
240
|
-
|
|
241
|
-
auto clb4 = [scheduleOnJS](
|
|
242
|
-
jsi::Runtime &rt,
|
|
243
|
-
const jsi::Value &thisValue,
|
|
244
|
-
const jsi::Value *args,
|
|
245
|
-
const size_t count) -> jsi::Value {
|
|
246
|
-
scheduleOnJS(rt, args[0], args[1]);
|
|
247
|
-
return jsi::Value::undefined();
|
|
248
|
-
};
|
|
249
|
-
jsi::Value scheduleOnJSFun = jsi::Function::createFromHostFunction(
|
|
250
|
-
rt, jsi::PropNameID::forAscii(rt, "_scheduleOnJS"), 2, clb4);
|
|
251
|
-
rt.global().setProperty(rt, "_scheduleOnJS", scheduleOnJSFun);
|
|
118
|
+
jsi_utils::installJsiFunction(rt, "_measure", _measure);
|
|
119
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
|
252
120
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
return makeShareableClone(rt, std::move(args[0]));
|
|
259
|
-
};
|
|
260
|
-
jsi::Value makeShareableCloneFun = jsi::Function::createFromHostFunction(
|
|
261
|
-
rt, jsi::PropNameID::forAscii(rt, "_makeShareableClone"), 1, clb5);
|
|
262
|
-
rt.global().setProperty(rt, "_makeShareableClone", makeShareableCloneFun);
|
|
121
|
+
jsi_utils::installJsiFunction(rt, "requestAnimationFrame", requestFrame);
|
|
122
|
+
jsi_utils::installJsiFunction(rt, "_scheduleOnJS", scheduleOnJS);
|
|
123
|
+
jsi_utils::installJsiFunction(rt, "_makeShareableClone", makeShareableClone);
|
|
124
|
+
jsi_utils::installJsiFunction(
|
|
125
|
+
rt, "_updateDataSynchronously", updateDataSynchronously);
|
|
263
126
|
|
|
264
|
-
auto
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
return jsi::Value::undefined();
|
|
127
|
+
auto performanceNow = [getCurrentTime](
|
|
128
|
+
jsi::Runtime &rt,
|
|
129
|
+
const jsi::Value &thisValue,
|
|
130
|
+
const jsi::Value *args,
|
|
131
|
+
size_t count) -> jsi::Value {
|
|
132
|
+
return jsi::Value(getCurrentTime());
|
|
271
133
|
};
|
|
272
|
-
jsi::
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
const jsi::Value &thisValue,
|
|
280
|
-
const jsi::Value *args,
|
|
281
|
-
const size_t count) -> jsi::Value {
|
|
282
|
-
return getCurrentTime();
|
|
283
|
-
};
|
|
284
|
-
jsi::Value timeFun = jsi::Function::createFromHostFunction(
|
|
285
|
-
rt, jsi::PropNameID::forAscii(rt, "_getCurrentTime"), 0, clb6);
|
|
286
|
-
rt.global().setProperty(rt, "_getCurrentTime", timeFun);
|
|
287
|
-
|
|
288
|
-
rt.global().setProperty(rt, "_frameTimestamp", jsi::Value::undefined());
|
|
289
|
-
rt.global().setProperty(rt, "_eventTimestamp", jsi::Value::undefined());
|
|
134
|
+
jsi::Object performance(rt);
|
|
135
|
+
performance.setProperty(
|
|
136
|
+
rt,
|
|
137
|
+
"now",
|
|
138
|
+
jsi::Function::createFromHostFunction(
|
|
139
|
+
rt, jsi::PropNameID::forAscii(rt, "now"), 0, performanceNow));
|
|
140
|
+
rt.global().setProperty(rt, "performance", performance);
|
|
290
141
|
|
|
291
142
|
// layout animation
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
size_t count) -> jsi::Value {
|
|
297
|
-
progressLayoutAnimationFunction(args[0].asNumber(), args[1].asObject(rt));
|
|
298
|
-
return jsi::Value::undefined();
|
|
299
|
-
};
|
|
300
|
-
jsi::Value _notifyAboutProgress = jsi::Function::createFromHostFunction(
|
|
301
|
-
rt, jsi::PropNameID::forAscii(rt, "_notifyAboutProgress"), 2, clb7);
|
|
302
|
-
rt.global().setProperty(rt, "_notifyAboutProgress", _notifyAboutProgress);
|
|
143
|
+
jsi_utils::installJsiFunction(
|
|
144
|
+
rt, "_notifyAboutProgress", progressLayoutAnimationFunction);
|
|
145
|
+
jsi_utils::installJsiFunction(
|
|
146
|
+
rt, "_notifyAboutEnd", endLayoutAnimationFunction);
|
|
303
147
|
|
|
304
|
-
|
|
305
|
-
jsi::Runtime &rt,
|
|
306
|
-
const jsi::Value &thisValue,
|
|
307
|
-
const jsi::Value *args,
|
|
308
|
-
size_t count) -> jsi::Value {
|
|
309
|
-
endLayoutAnimationFunction(
|
|
310
|
-
args[0].asNumber(), args[1].getBool(), args[2].getBool());
|
|
311
|
-
return jsi::Value::undefined();
|
|
312
|
-
};
|
|
313
|
-
jsi::Value _notifyAboutEnd = jsi::Function::createFromHostFunction(
|
|
314
|
-
rt, jsi::PropNameID::forAscii(rt, "_notifyAboutEnd"), 2, clb8);
|
|
315
|
-
rt.global().setProperty(rt, "_notifyAboutEnd", _notifyAboutEnd);
|
|
316
|
-
|
|
317
|
-
auto clb9 = [setGestureState](
|
|
318
|
-
jsi::Runtime &rt,
|
|
319
|
-
const jsi::Value &thisValue,
|
|
320
|
-
const jsi::Value *args,
|
|
321
|
-
size_t count) -> jsi::Value {
|
|
322
|
-
int handlerTag = static_cast<int>(args[0].asNumber());
|
|
323
|
-
int newState = static_cast<int>(args[1].asNumber());
|
|
324
|
-
setGestureState(handlerTag, newState);
|
|
325
|
-
return jsi::Value::undefined();
|
|
326
|
-
};
|
|
327
|
-
jsi::Value setGestureStateFunction = jsi::Function::createFromHostFunction(
|
|
328
|
-
rt, jsi::PropNameID::forAscii(rt, "_setGestureState"), 2, clb9);
|
|
329
|
-
rt.global().setProperty(rt, "_setGestureState", setGestureStateFunction);
|
|
148
|
+
jsi_utils::installJsiFunction(rt, "_setGestureState", setGestureState);
|
|
330
149
|
}
|
|
331
150
|
|
|
332
151
|
} // namespace reanimated
|
|
@@ -50,8 +50,6 @@ class RuntimeDecorator {
|
|
|
50
50
|
const MakeShareableCloneFunction makeShareableClone,
|
|
51
51
|
const UpdateDataSynchronouslyFunction updateDataSynchronously,
|
|
52
52
|
const TimeProviderFunction getCurrentTime,
|
|
53
|
-
const RegisterSensorFunction registerSensor,
|
|
54
|
-
const UnregisterSensorFunction unregisterSensor,
|
|
55
53
|
const SetGestureStateFunction setGestureState,
|
|
56
54
|
const ProgressLayoutAnimationFunction progressLayoutAnimationFunction,
|
|
57
55
|
const EndLayoutAnimationFunction endLayoutAnimationFunction);
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
namespace reanimated {
|
|
4
4
|
|
|
5
5
|
void WorkletEventHandler::process(
|
|
6
|
-
|
|
6
|
+
double eventTimestamp,
|
|
7
7
|
const jsi::Value &eventValue) {
|
|
8
|
-
|
|
8
|
+
_runtimeHelper->runOnUIGuarded(
|
|
9
|
+
_handlerFunction, jsi::Value(eventTimestamp), eventValue);
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
} // namespace reanimated
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
3
|
#include <jsi/jsi.h>
|
|
4
|
+
#include <memory>
|
|
4
5
|
#include <string>
|
|
5
6
|
#include <utility>
|
|
6
7
|
|
|
8
|
+
#include "Shareables.h"
|
|
9
|
+
|
|
7
10
|
using namespace facebook;
|
|
8
11
|
|
|
9
12
|
namespace reanimated {
|
|
@@ -14,17 +17,22 @@ class WorkletEventHandler {
|
|
|
14
17
|
friend EventHandlerRegistry;
|
|
15
18
|
|
|
16
19
|
private:
|
|
17
|
-
|
|
20
|
+
std::shared_ptr<JSRuntimeHelper> _runtimeHelper;
|
|
21
|
+
uint64_t id;
|
|
18
22
|
std::string eventName;
|
|
19
|
-
jsi::
|
|
23
|
+
jsi::Value _handlerFunction;
|
|
20
24
|
|
|
21
25
|
public:
|
|
22
26
|
WorkletEventHandler(
|
|
23
|
-
|
|
27
|
+
const std::shared_ptr<JSRuntimeHelper> &runtimeHelper,
|
|
28
|
+
uint64_t id,
|
|
24
29
|
std::string eventName,
|
|
25
|
-
jsi::
|
|
26
|
-
:
|
|
27
|
-
|
|
30
|
+
jsi::Value &&handlerFunction)
|
|
31
|
+
: _runtimeHelper(runtimeHelper),
|
|
32
|
+
id(id),
|
|
33
|
+
eventName(eventName),
|
|
34
|
+
_handlerFunction(std::move(handlerFunction)) {}
|
|
35
|
+
void process(double eventTimestamp, const jsi::Value &eventValue);
|
|
28
36
|
};
|
|
29
37
|
|
|
30
38
|
} // namespace reanimated
|
package/RNReanimated.podspec
CHANGED
|
@@ -5,13 +5,14 @@ reanimated_package_json = JSON.parse(File.read(File.join(__dir__, "package.json"
|
|
|
5
5
|
config = find_config()
|
|
6
6
|
assert_no_multiple_instances(config)
|
|
7
7
|
assert_no_reanimated2_with_new_architecture(reanimated_package_json)
|
|
8
|
+
assert_latest_react_native_with_new_architecture(config, reanimated_package_json)
|
|
8
9
|
|
|
9
10
|
fabric_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'
|
|
10
11
|
folly_prefix = config[:react_native_minor_version] >= 64 ? 'RCT-' : ''
|
|
11
12
|
folly_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32 -DREACT_NATIVE_MINOR_VERSION=' + config[:react_native_minor_version].to_s
|
|
12
13
|
folly_compiler_flags = folly_flags + ' ' + '-Wno-comma -Wno-shorten-64-to-32'
|
|
13
14
|
boost_compiler_flags = '-Wno-documentation'
|
|
14
|
-
fabric_flags = fabric_enabled ? '-
|
|
15
|
+
fabric_flags = fabric_enabled ? '-DRCT_NEW_ARCH_ENABLED' : ''
|
|
15
16
|
version_flag = '-DREANIMATED_VERSION=' + reanimated_package_json["version"]
|
|
16
17
|
|
|
17
18
|
Pod::Spec.new do |s|
|