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
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <algorithm>
|
|
4
|
+
|
|
5
|
+
namespace reanimated {
|
|
6
|
+
namespace collection {
|
|
7
|
+
|
|
8
|
+
template <class CollectionType, class ValueType>
|
|
9
|
+
inline bool contains(CollectionType &collection, const ValueType &value) {
|
|
10
|
+
return collection.find(value) != collection.end();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
} // namespace collection
|
|
14
|
+
} // namespace reanimated
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#include "JsiUtils.h"
|
|
2
|
+
#include <vector>
|
|
3
|
+
|
|
4
|
+
using namespace facebook;
|
|
5
|
+
|
|
6
|
+
namespace reanimated::jsi_utils {
|
|
7
|
+
|
|
8
|
+
jsi::Array convertStringToArray(
|
|
9
|
+
jsi::Runtime &rt,
|
|
10
|
+
const std::string &value,
|
|
11
|
+
const unsigned int expectedSize) {
|
|
12
|
+
std::vector<float> transformMatrixList;
|
|
13
|
+
std::istringstream stringStream(value);
|
|
14
|
+
std::copy(
|
|
15
|
+
std::istream_iterator<float>(stringStream),
|
|
16
|
+
std::istream_iterator<float>(),
|
|
17
|
+
std::back_inserter(transformMatrixList));
|
|
18
|
+
assert(transformMatrixList.size() == expectedSize);
|
|
19
|
+
jsi::Array matrix(rt, expectedSize);
|
|
20
|
+
for (int i = 0; i < expectedSize; i++) {
|
|
21
|
+
matrix.setValueAtIndex(rt, i, transformMatrixList[i]);
|
|
22
|
+
}
|
|
23
|
+
return matrix;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
} // namespace reanimated::jsi_utils
|
|
@@ -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;
|
|
@@ -30,69 +44,34 @@ void RuntimeDecorator::decorateRuntime(
|
|
|
30
44
|
rt.global().setProperty(
|
|
31
45
|
rt, "_LABEL", jsi::String::createFromAscii(rt, label));
|
|
32
46
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
Logger::log(value->getString(rt).utf8(rt).c_str());
|
|
46
|
-
} else if (value->isNumber()) {
|
|
47
|
-
Logger::log(value->getNumber());
|
|
48
|
-
} else if (value->isUndefined()) {
|
|
49
|
-
Logger::log("undefined");
|
|
50
|
-
} else {
|
|
51
|
-
Logger::log("unsupported value type");
|
|
47
|
+
rt.global().setProperty(rt, "global", rt.global());
|
|
48
|
+
|
|
49
|
+
#ifdef DEBUG
|
|
50
|
+
auto evalWithSourceUrl = [](jsi::Runtime &rt,
|
|
51
|
+
const jsi::Value &thisValue,
|
|
52
|
+
const jsi::Value *args,
|
|
53
|
+
size_t count) -> jsi::Value {
|
|
54
|
+
auto code = std::make_shared<const jsi::StringBuffer>(
|
|
55
|
+
args[0].asString(rt).utf8(rt));
|
|
56
|
+
std::string url;
|
|
57
|
+
if (count > 1 && args[1].isString()) {
|
|
58
|
+
url = args[1].asString(rt).utf8(rt);
|
|
52
59
|
}
|
|
53
|
-
return jsi::Value::undefined();
|
|
54
|
-
};
|
|
55
|
-
jsi::Value log = jsi::Function::createFromHostFunction(
|
|
56
|
-
rt, jsi::PropNameID::forAscii(rt, "_log"), 1, callback);
|
|
57
|
-
rt.global().setProperty(rt, "_log", log);
|
|
58
60
|
|
|
59
|
-
|
|
60
|
-
const jsi::Value &thisValue,
|
|
61
|
-
const jsi::Value *args,
|
|
62
|
-
size_t count) -> jsi::Value {
|
|
63
|
-
rt.global().setProperty(rt, "console", args[0]);
|
|
64
|
-
return jsi::Value::undefined();
|
|
61
|
+
return rt.evaluateJavaScript(code, url);
|
|
65
62
|
};
|
|
63
|
+
|
|
66
64
|
rt.global().setProperty(
|
|
67
65
|
rt,
|
|
68
|
-
"
|
|
66
|
+
"evalWithSourceUrl",
|
|
69
67
|
jsi::Function::createFromHostFunction(
|
|
70
68
|
rt,
|
|
71
|
-
jsi::PropNameID::forAscii(rt, "
|
|
69
|
+
jsi::PropNameID::forAscii(rt, "evalWithSourceUrl"),
|
|
72
70
|
1,
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
auto chronoNow = [](jsi::Runtime &rt,
|
|
76
|
-
const jsi::Value &thisValue,
|
|
77
|
-
const jsi::Value *args,
|
|
78
|
-
size_t count) -> jsi::Value {
|
|
79
|
-
double now = std::chrono::system_clock::now().time_since_epoch() /
|
|
80
|
-
std::chrono::milliseconds(1);
|
|
81
|
-
return jsi::Value(now);
|
|
82
|
-
};
|
|
71
|
+
evalWithSourceUrl));
|
|
72
|
+
#endif // DEBUG
|
|
83
73
|
|
|
84
|
-
rt
|
|
85
|
-
rt,
|
|
86
|
-
"_chronoNow",
|
|
87
|
-
jsi::Function::createFromHostFunction(
|
|
88
|
-
rt, jsi::PropNameID::forAscii(rt, "_chronoNow"), 0, chronoNow));
|
|
89
|
-
jsi::Object performance(rt);
|
|
90
|
-
performance.setProperty(
|
|
91
|
-
rt,
|
|
92
|
-
"now",
|
|
93
|
-
jsi::Function::createFromHostFunction(
|
|
94
|
-
rt, jsi::PropNameID::forAscii(rt, "now"), 0, chronoNow));
|
|
95
|
-
rt.global().setProperty(rt, "performance", performance);
|
|
74
|
+
jsi_utils::installJsiFunction(rt, "_log", logValue);
|
|
96
75
|
}
|
|
97
76
|
|
|
98
77
|
void RuntimeDecorator::decorateUIRuntime(
|
|
@@ -110,8 +89,6 @@ void RuntimeDecorator::decorateUIRuntime(
|
|
|
110
89
|
const MakeShareableCloneFunction makeShareableClone,
|
|
111
90
|
const UpdateDataSynchronouslyFunction updateDataSynchronously,
|
|
112
91
|
const TimeProviderFunction getCurrentTime,
|
|
113
|
-
const RegisterSensorFunction registerSensor,
|
|
114
|
-
const UnregisterSensorFunction unregisterSensor,
|
|
115
92
|
const SetGestureStateFunction setGestureState,
|
|
116
93
|
const ProgressLayoutAnimationFunction progressLayoutAnimationFunction,
|
|
117
94
|
const EndLayoutAnimationFunction endLayoutAnimationFunction) {
|
|
@@ -119,95 +96,17 @@ void RuntimeDecorator::decorateUIRuntime(
|
|
|
119
96
|
rt.global().setProperty(rt, "_UI", jsi::Value(true));
|
|
120
97
|
|
|
121
98
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
updateProps(rt, args[0], args[1]);
|
|
128
|
-
return jsi::Value::undefined();
|
|
129
|
-
};
|
|
130
|
-
jsi::Value updatePropsHostFunction = jsi::Function::createFromHostFunction(
|
|
131
|
-
rt, jsi::PropNameID::forAscii(rt, "_updatePropsFabric"), 2, clb);
|
|
132
|
-
rt.global().setProperty(rt, "_updatePropsFabric", updatePropsHostFunction);
|
|
133
|
-
|
|
134
|
-
auto _removeShadowNodeFromRegistry = [removeShadowNodeFromRegistry](
|
|
135
|
-
jsi::Runtime &rt,
|
|
136
|
-
const jsi::Value &thisValue,
|
|
137
|
-
const jsi::Value *args,
|
|
138
|
-
const size_t count) -> jsi::Value {
|
|
139
|
-
removeShadowNodeFromRegistry(rt, args[0]);
|
|
140
|
-
return jsi::Value::undefined();
|
|
141
|
-
};
|
|
142
|
-
jsi::Value removeShadowNodeFromRegistryHostFunction =
|
|
143
|
-
jsi::Function::createFromHostFunction(
|
|
144
|
-
rt,
|
|
145
|
-
jsi::PropNameID::forAscii(rt, "_removeShadowNodeFromRegistry"),
|
|
146
|
-
2,
|
|
147
|
-
_removeShadowNodeFromRegistry);
|
|
148
|
-
rt.global().setProperty(
|
|
149
|
-
rt,
|
|
150
|
-
"_removeShadowNodeFromRegistry",
|
|
151
|
-
removeShadowNodeFromRegistryHostFunction);
|
|
152
|
-
|
|
153
|
-
auto clb3 = [dispatchCommand](
|
|
154
|
-
jsi::Runtime &rt,
|
|
155
|
-
const jsi::Value &thisValue,
|
|
156
|
-
const jsi::Value *args,
|
|
157
|
-
const size_t count) -> jsi::Value {
|
|
158
|
-
dispatchCommand(rt, args[0], args[1], args[2]);
|
|
159
|
-
return jsi::Value::undefined();
|
|
160
|
-
};
|
|
161
|
-
jsi::Value dispatchCommandHostFunction =
|
|
162
|
-
jsi::Function::createFromHostFunction(
|
|
163
|
-
rt, jsi::PropNameID::forAscii(rt, "_dispatchCommand"), 3, clb3);
|
|
164
|
-
rt.global().setProperty(rt, "_dispatchCommand", dispatchCommandHostFunction);
|
|
165
|
-
|
|
166
|
-
auto _measure = [measure](
|
|
167
|
-
jsi::Runtime &rt,
|
|
168
|
-
const jsi::Value &thisValue,
|
|
169
|
-
const jsi::Value *args,
|
|
170
|
-
const size_t count) -> jsi::Value {
|
|
171
|
-
return measure(rt, args[0]);
|
|
172
|
-
};
|
|
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);
|
|
173
104
|
#else
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
const jsi::Value &thisValue,
|
|
177
|
-
const jsi::Value *args,
|
|
178
|
-
const size_t count) -> jsi::Value {
|
|
179
|
-
const auto viewTag = args[0].asNumber();
|
|
180
|
-
const jsi::Value *viewName = &args[1];
|
|
181
|
-
const auto params = args[2].asObject(rt);
|
|
182
|
-
updateProps(rt, viewTag, *viewName, params);
|
|
183
|
-
return jsi::Value::undefined();
|
|
184
|
-
};
|
|
185
|
-
jsi::Value updatePropsHostFunction = jsi::Function::createFromHostFunction(
|
|
186
|
-
rt, jsi::PropNameID::forAscii(rt, "_updatePropsPaper"), 3, clb);
|
|
187
|
-
rt.global().setProperty(rt, "_updatePropsPaper", updatePropsHostFunction);
|
|
105
|
+
jsi_utils::installJsiFunction(rt, "_updatePropsPaper", updateProps);
|
|
106
|
+
jsi_utils::installJsiFunction(rt, "_scrollTo", scrollTo);
|
|
188
107
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
const jsi::Value &thisValue,
|
|
192
|
-
const jsi::Value *args,
|
|
193
|
-
const size_t count) -> jsi::Value {
|
|
194
|
-
int viewTag = static_cast<int>(args[0].asNumber());
|
|
195
|
-
double x = args[1].asNumber();
|
|
196
|
-
double y = args[2].asNumber();
|
|
197
|
-
bool animated = args[3].getBool();
|
|
198
|
-
scrollTo(viewTag, x, y, animated);
|
|
199
|
-
return jsi::Value::undefined();
|
|
200
|
-
};
|
|
201
|
-
jsi::Value scrollToFunction = jsi::Function::createFromHostFunction(
|
|
202
|
-
rt, jsi::PropNameID::forAscii(rt, "_scrollTo"), 4, _scrollTo);
|
|
203
|
-
rt.global().setProperty(rt, "_scrollTo", scrollToFunction);
|
|
204
|
-
|
|
205
|
-
auto _measure = [measure](
|
|
206
|
-
jsi::Runtime &rt,
|
|
207
|
-
const jsi::Value &thisValue,
|
|
208
|
-
const jsi::Value *args,
|
|
209
|
-
const size_t count) -> jsi::Value {
|
|
210
|
-
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 {
|
|
211
110
|
auto result = measure(viewTag);
|
|
212
111
|
jsi::Object resultObject(rt);
|
|
213
112
|
for (auto &i : result) {
|
|
@@ -215,117 +114,38 @@ void RuntimeDecorator::decorateUIRuntime(
|
|
|
215
114
|
}
|
|
216
115
|
return resultObject;
|
|
217
116
|
};
|
|
218
|
-
#endif // RCT_NEW_ARCH_ENABLED
|
|
219
|
-
|
|
220
|
-
jsi::Value measureFunction = jsi::Function::createFromHostFunction(
|
|
221
|
-
rt, jsi::PropNameID::forAscii(rt, "_measure"), 1, _measure);
|
|
222
|
-
rt.global().setProperty(rt, "_measure", measureFunction);
|
|
223
117
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
const jsi::Value &thisValue,
|
|
227
|
-
const jsi::Value *args,
|
|
228
|
-
const size_t count) -> jsi::Value {
|
|
229
|
-
auto fun =
|
|
230
|
-
std::make_shared<jsi::Function>(args[0].asObject(rt).asFunction(rt));
|
|
231
|
-
requestFrame([&rt, fun](double timestampMs) {
|
|
232
|
-
fun->call(rt, jsi::Value(timestampMs));
|
|
233
|
-
});
|
|
234
|
-
return jsi::Value::undefined();
|
|
235
|
-
};
|
|
236
|
-
jsi::Value requestAnimationFrame = jsi::Function::createFromHostFunction(
|
|
237
|
-
rt, jsi::PropNameID::forAscii(rt, "requestAnimationFrame"), 1, clb2);
|
|
238
|
-
rt.global().setProperty(rt, "requestAnimationFrame", requestAnimationFrame);
|
|
239
|
-
|
|
240
|
-
auto clb4 = [scheduleOnJS](
|
|
241
|
-
jsi::Runtime &rt,
|
|
242
|
-
const jsi::Value &thisValue,
|
|
243
|
-
const jsi::Value *args,
|
|
244
|
-
const size_t count) -> jsi::Value {
|
|
245
|
-
scheduleOnJS(rt, args[0], args[1]);
|
|
246
|
-
return jsi::Value::undefined();
|
|
247
|
-
};
|
|
248
|
-
jsi::Value scheduleOnJSFun = jsi::Function::createFromHostFunction(
|
|
249
|
-
rt, jsi::PropNameID::forAscii(rt, "_scheduleOnJS"), 2, clb4);
|
|
250
|
-
rt.global().setProperty(rt, "_scheduleOnJS", scheduleOnJSFun);
|
|
251
|
-
|
|
252
|
-
auto clb5 = [makeShareableClone](
|
|
253
|
-
jsi::Runtime &rt,
|
|
254
|
-
const jsi::Value &thisValue,
|
|
255
|
-
const jsi::Value *args,
|
|
256
|
-
const size_t count) -> jsi::Value {
|
|
257
|
-
return makeShareableClone(rt, std::move(args[0]));
|
|
258
|
-
};
|
|
259
|
-
jsi::Value makeShareableCloneFun = jsi::Function::createFromHostFunction(
|
|
260
|
-
rt, jsi::PropNameID::forAscii(rt, "_makeShareableClone"), 1, clb5);
|
|
261
|
-
rt.global().setProperty(rt, "_makeShareableClone", makeShareableCloneFun);
|
|
118
|
+
jsi_utils::installJsiFunction(rt, "_measure", _measure);
|
|
119
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
|
262
120
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
updateDataSynchronously(rt, std::move(args[0]), std::move(args[1]));
|
|
269
|
-
return jsi::Value::undefined();
|
|
270
|
-
};
|
|
271
|
-
jsi::Value updateDataSynchronouslyFun = jsi::Function::createFromHostFunction(
|
|
272
|
-
rt, jsi::PropNameID::forAscii(rt, "_updateDataSynchronously"), 1, clb51);
|
|
273
|
-
rt.global().setProperty(
|
|
274
|
-
rt, "_updateDataSynchronously", updateDataSynchronouslyFun);
|
|
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);
|
|
275
126
|
|
|
276
|
-
auto
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
return getCurrentTime();
|
|
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());
|
|
282
133
|
};
|
|
283
|
-
jsi::
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
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);
|
|
289
141
|
|
|
290
142
|
// layout animation
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
size_t count) -> jsi::Value {
|
|
296
|
-
progressLayoutAnimationFunction(args[0].asNumber(), args[1].asObject(rt));
|
|
297
|
-
return jsi::Value::undefined();
|
|
298
|
-
};
|
|
299
|
-
jsi::Value _notifyAboutProgress = jsi::Function::createFromHostFunction(
|
|
300
|
-
rt, jsi::PropNameID::forAscii(rt, "_notifyAboutProgress"), 2, clb7);
|
|
301
|
-
rt.global().setProperty(rt, "_notifyAboutProgress", _notifyAboutProgress);
|
|
143
|
+
jsi_utils::installJsiFunction(
|
|
144
|
+
rt, "_notifyAboutProgress", progressLayoutAnimationFunction);
|
|
145
|
+
jsi_utils::installJsiFunction(
|
|
146
|
+
rt, "_notifyAboutEnd", endLayoutAnimationFunction);
|
|
302
147
|
|
|
303
|
-
|
|
304
|
-
jsi::Runtime &rt,
|
|
305
|
-
const jsi::Value &thisValue,
|
|
306
|
-
const jsi::Value *args,
|
|
307
|
-
size_t count) -> jsi::Value {
|
|
308
|
-
endLayoutAnimationFunction(
|
|
309
|
-
args[0].asNumber(), args[1].getBool(), args[2].getBool());
|
|
310
|
-
return jsi::Value::undefined();
|
|
311
|
-
};
|
|
312
|
-
jsi::Value _notifyAboutEnd = jsi::Function::createFromHostFunction(
|
|
313
|
-
rt, jsi::PropNameID::forAscii(rt, "_notifyAboutEnd"), 2, clb8);
|
|
314
|
-
rt.global().setProperty(rt, "_notifyAboutEnd", _notifyAboutEnd);
|
|
315
|
-
|
|
316
|
-
auto clb9 = [setGestureState](
|
|
317
|
-
jsi::Runtime &rt,
|
|
318
|
-
const jsi::Value &thisValue,
|
|
319
|
-
const jsi::Value *args,
|
|
320
|
-
size_t count) -> jsi::Value {
|
|
321
|
-
int handlerTag = static_cast<int>(args[0].asNumber());
|
|
322
|
-
int newState = static_cast<int>(args[1].asNumber());
|
|
323
|
-
setGestureState(handlerTag, newState);
|
|
324
|
-
return jsi::Value::undefined();
|
|
325
|
-
};
|
|
326
|
-
jsi::Value setGestureStateFunction = jsi::Function::createFromHostFunction(
|
|
327
|
-
rt, jsi::PropNameID::forAscii(rt, "_setGestureState"), 2, clb9);
|
|
328
|
-
rt.global().setProperty(rt, "_setGestureState", setGestureStateFunction);
|
|
148
|
+
jsi_utils::installJsiFunction(rt, "_setGestureState", setGestureState);
|
|
329
149
|
}
|
|
330
150
|
|
|
331
151
|
} // namespace reanimated
|
|
@@ -11,7 +11,8 @@ using namespace facebook;
|
|
|
11
11
|
|
|
12
12
|
namespace reanimated {
|
|
13
13
|
|
|
14
|
-
using RequestFrameFunction =
|
|
14
|
+
using RequestFrameFunction =
|
|
15
|
+
std::function<void(jsi::Runtime &, const jsi::Value &)>;
|
|
15
16
|
using ScheduleOnJSFunction =
|
|
16
17
|
std::function<void(jsi::Runtime &, const jsi::Value &, const jsi::Value &)>;
|
|
17
18
|
using MakeShareableCloneFunction =
|
|
@@ -49,8 +50,6 @@ class RuntimeDecorator {
|
|
|
49
50
|
const MakeShareableCloneFunction makeShareableClone,
|
|
50
51
|
const UpdateDataSynchronouslyFunction updateDataSynchronously,
|
|
51
52
|
const TimeProviderFunction getCurrentTime,
|
|
52
|
-
const RegisterSensorFunction registerSensor,
|
|
53
|
-
const UnregisterSensorFunction unregisterSensor,
|
|
54
53
|
const SetGestureStateFunction setGestureState,
|
|
55
54
|
const ProgressLayoutAnimationFunction progressLayoutAnimationFunction,
|
|
56
55
|
const EndLayoutAnimationFunction endLayoutAnimationFunction);
|