react-native-reanimated 3.0.0-rc.9 → 3.0.1
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/README.md +1 -1
- 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 +244 -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 +91 -15
- 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 +22 -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 -7
- 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 +241 -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 +90 -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 +20 -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 -7
- 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/mock.js +1 -211
- package/package.json +10 -10
- package/{plugin.js → plugin/index.js} +128 -249
- package/react-native-reanimated.d.ts +55 -417
- package/scripts/reanimated_utils.rb +15 -2
- package/src/createAnimatedComponent.tsx +247 -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 +90 -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 +20 -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 +25 -2
- 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 -4
- 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
|
@@ -10,7 +10,7 @@ void EventHandlerRegistry::registerEventHandler(
|
|
|
10
10
|
eventHandlers[eventHandler->id] = eventHandler;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
void EventHandlerRegistry::unregisterEventHandler(
|
|
13
|
+
void EventHandlerRegistry::unregisterEventHandler(uint64_t id) {
|
|
14
14
|
const std::lock_guard<std::mutex> lock(instanceMutex);
|
|
15
15
|
auto handlerIt = eventHandlers.find(id);
|
|
16
16
|
if (handlerIt != eventHandlers.end()) {
|
|
@@ -24,13 +24,9 @@ void EventHandlerRegistry::unregisterEventHandler(unsigned long id) {
|
|
|
24
24
|
|
|
25
25
|
void EventHandlerRegistry::processEvent(
|
|
26
26
|
jsi::Runtime &rt,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
jsi::Value &eventPayload
|
|
30
|
-
#else
|
|
31
|
-
std::string eventPayload
|
|
32
|
-
#endif
|
|
33
|
-
/**/) {
|
|
27
|
+
double eventTimestamp,
|
|
28
|
+
const std::string &eventName,
|
|
29
|
+
const jsi::Value &eventPayload) {
|
|
34
30
|
std::vector<std::shared_ptr<WorkletEventHandler>> handlersForEvent;
|
|
35
31
|
{
|
|
36
32
|
const std::lock_guard<std::mutex> lock(instanceMutex);
|
|
@@ -41,38 +37,16 @@ void EventHandlerRegistry::processEvent(
|
|
|
41
37
|
}
|
|
42
38
|
}
|
|
43
39
|
}
|
|
44
|
-
#ifdef RCT_NEW_ARCH_ENABLED
|
|
45
|
-
eventPayload.asObject(rt).setProperty(
|
|
46
|
-
rt, "eventName", jsi::String::createFromUtf8(rt, eventName));
|
|
47
|
-
for (auto handler : handlersForEvent) {
|
|
48
|
-
handler->process(rt, eventPayload);
|
|
49
|
-
}
|
|
50
|
-
#else
|
|
51
|
-
// We receive here a JS Map with JSON as a value of NativeMap key
|
|
52
|
-
// { NativeMap: { "jsonProp": "json value" } }
|
|
53
|
-
// So we need to extract only JSON part
|
|
54
|
-
std::string delimimter = "NativeMap:";
|
|
55
|
-
auto positionToSplit = eventPayload.find(delimimter) + delimimter.size();
|
|
56
|
-
auto lastBracketCharactedPosition = eventPayload.size() - positionToSplit - 1;
|
|
57
|
-
auto eventJSON =
|
|
58
|
-
eventPayload.substr(positionToSplit, lastBracketCharactedPosition);
|
|
59
40
|
|
|
60
|
-
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
auto eventObject = jsi::Value::createFromJsonUtf8(
|
|
65
|
-
rt, reinterpret_cast<uint8_t *>(&eventJSON[0]), eventJSON.size());
|
|
66
|
-
|
|
67
|
-
eventObject.asObject(rt).setProperty(
|
|
41
|
+
eventPayload.asObject(rt).setProperty(
|
|
68
42
|
rt, "eventName", jsi::String::createFromUtf8(rt, eventName));
|
|
69
43
|
for (auto handler : handlersForEvent) {
|
|
70
|
-
handler->process(
|
|
44
|
+
handler->process(eventTimestamp, eventPayload);
|
|
71
45
|
}
|
|
72
|
-
#endif
|
|
73
46
|
}
|
|
74
47
|
|
|
75
|
-
bool EventHandlerRegistry::isAnyHandlerWaitingForEvent(
|
|
48
|
+
bool EventHandlerRegistry::isAnyHandlerWaitingForEvent(
|
|
49
|
+
const std::string &eventName) {
|
|
76
50
|
const std::lock_guard<std::mutex> lock(instanceMutex);
|
|
77
51
|
auto it = eventMappings.find(eventName);
|
|
78
52
|
return (it != eventMappings.end()) && (!(it->second).empty());
|
|
@@ -18,28 +18,22 @@ class WorkletEventHandler;
|
|
|
18
18
|
class EventHandlerRegistry {
|
|
19
19
|
std::map<
|
|
20
20
|
std::string,
|
|
21
|
-
std::unordered_map<
|
|
21
|
+
std::unordered_map<uint64_t, std::shared_ptr<WorkletEventHandler>>>
|
|
22
22
|
eventMappings;
|
|
23
|
-
std::map<
|
|
23
|
+
std::map<uint64_t, std::shared_ptr<WorkletEventHandler>> eventHandlers;
|
|
24
24
|
std::mutex instanceMutex;
|
|
25
25
|
|
|
26
26
|
public:
|
|
27
27
|
void registerEventHandler(std::shared_ptr<WorkletEventHandler> eventHandler);
|
|
28
|
-
void unregisterEventHandler(
|
|
28
|
+
void unregisterEventHandler(uint64_t id);
|
|
29
29
|
|
|
30
|
-
#ifdef RCT_NEW_ARCH_ENABLED
|
|
31
30
|
void processEvent(
|
|
32
31
|
jsi::Runtime &rt,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
void processEvent(
|
|
37
|
-
jsi::Runtime &rt,
|
|
38
|
-
std::string eventName,
|
|
39
|
-
std::string eventPayload);
|
|
40
|
-
#endif
|
|
32
|
+
double eventTimestamp,
|
|
33
|
+
const std::string &eventName,
|
|
34
|
+
const jsi::Value &eventPayload);
|
|
41
35
|
|
|
42
|
-
bool isAnyHandlerWaitingForEvent(std::string eventName);
|
|
36
|
+
bool isAnyHandlerWaitingForEvent(const std::string &eventName);
|
|
43
37
|
};
|
|
44
38
|
|
|
45
39
|
} // namespace reanimated
|
|
@@ -11,10 +11,12 @@ CoreFunction::CoreFunction(
|
|
|
11
11
|
jsi::Runtime &rt = *runtimeHelper->rnRuntime();
|
|
12
12
|
auto workletObject = workletValue.asObject(rt);
|
|
13
13
|
rnFunction_ = std::make_unique<jsi::Function>(workletObject.asFunction(rt));
|
|
14
|
-
functionBody_ =
|
|
15
|
-
|
|
14
|
+
functionBody_ = workletObject.getPropertyAsObject(rt, "__initData")
|
|
15
|
+
.getProperty(rt, "code")
|
|
16
|
+
.asString(rt)
|
|
17
|
+
.utf8(rt);
|
|
16
18
|
location_ = "worklet_" +
|
|
17
|
-
std::to_string(static_cast<
|
|
19
|
+
std::to_string(static_cast<uint64_t>(
|
|
18
20
|
workletObject.getProperty(rt, "__workletHash").getNumber()));
|
|
19
21
|
}
|
|
20
22
|
|
|
@@ -59,61 +61,8 @@ std::shared_ptr<Shareable> extractShareableOrThrow(
|
|
|
59
61
|
|
|
60
62
|
Shareable::~Shareable() {}
|
|
61
63
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
jsi::Value RetainingShareable::getJSValue(jsi::Runtime &rt) {
|
|
65
|
-
jsi::Value value;
|
|
66
|
-
if (runtimeHelper_->isRNRuntime(rt)) {
|
|
67
|
-
// TODO: it is suboptimal to generate new object every time getJS is called
|
|
68
|
-
// on host runtime – the objects we are generating already exists and we
|
|
69
|
-
// should possibly just grab a hold of such object and use it here instead
|
|
70
|
-
// of creating a new JS representation. As far as I understand the only
|
|
71
|
-
// case where it can be realistically called this way is when a shared
|
|
72
|
-
// value is created and then accessed on the same runtime
|
|
73
|
-
return toJSValue(rt);
|
|
74
|
-
} else if (remoteValue_ == nullptr) {
|
|
75
|
-
value = toJSValue(rt);
|
|
76
|
-
remoteValue_ = std::make_unique<jsi::WeakObject>(rt, value.asObject(rt));
|
|
77
|
-
} else {
|
|
78
|
-
value = remoteValue_->lock(rt);
|
|
79
|
-
if (value.isUndefined()) {
|
|
80
|
-
value = toJSValue(rt);
|
|
81
|
-
remoteValue_ = std::make_unique<jsi::WeakObject>(rt, value.asObject(rt));
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
return value;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
RetainingShareable::~RetainingShareable() {
|
|
88
|
-
if (runtimeHelper_->uiRuntimeDestroyed) {
|
|
89
|
-
// The below use of unique_ptr.release prevents the smart pointer from
|
|
90
|
-
// calling the destructor of the kept object. This effectively results in
|
|
91
|
-
// leaking some memory. We do this on purpose, as sometimes we would keep
|
|
92
|
-
// references to JSI objects past the lifetime of its runtime (e.g., shared
|
|
93
|
-
// values references from the RN VM holds reference to JSI objects on the
|
|
94
|
-
// UI runtime). When the UI runtime is terminated, the orphaned JSI objects
|
|
95
|
-
// would crash the app when their destructors are called, because they
|
|
96
|
-
// call into a memory that's managed by the terminated runtime. We accept
|
|
97
|
-
// the tradeoff of leaking memory here, as it has a limited impact. This
|
|
98
|
-
// scenario can only occur when the React instance is torn down which
|
|
99
|
-
// happens in development mode during app reloads, or in production when the
|
|
100
|
-
// app is being shut down gracefully by the system. An alternative solution
|
|
101
|
-
// would require us to keep track of all JSI values that are in use which
|
|
102
|
-
// would require additional data structure and compute spent on bookkeeping
|
|
103
|
-
// that only for the sake of destroying the values in time before the
|
|
104
|
-
// runtime is terminated. Note that the underlying memory that jsi::Value
|
|
105
|
-
// refers to is managed by the VM and gets freed along with the runtime.
|
|
106
|
-
remoteValue_.release();
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
#endif // HAS_JS_WEAK_OBJECTS
|
|
111
|
-
|
|
112
|
-
ShareableArray::ShareableArray(
|
|
113
|
-
const std::shared_ptr<JSRuntimeHelper> &runtimeHelper,
|
|
114
|
-
jsi::Runtime &rt,
|
|
115
|
-
const jsi::Array &array)
|
|
116
|
-
: RetainingShareable(runtimeHelper, rt, ArrayType) {
|
|
64
|
+
ShareableArray::ShareableArray(jsi::Runtime &rt, const jsi::Array &array)
|
|
65
|
+
: Shareable(ArrayType) {
|
|
117
66
|
auto size = array.size(rt);
|
|
118
67
|
data_.reserve(size);
|
|
119
68
|
for (size_t i = 0; i < size; i++) {
|
|
@@ -121,11 +70,8 @@ ShareableArray::ShareableArray(
|
|
|
121
70
|
}
|
|
122
71
|
}
|
|
123
72
|
|
|
124
|
-
ShareableObject::ShareableObject(
|
|
125
|
-
|
|
126
|
-
jsi::Runtime &rt,
|
|
127
|
-
const jsi::Object &object)
|
|
128
|
-
: RetainingShareable(runtimeHelper, rt, ObjectType) {
|
|
73
|
+
ShareableObject::ShareableObject(jsi::Runtime &rt, const jsi::Object &object)
|
|
74
|
+
: Shareable(ObjectType) {
|
|
129
75
|
auto propertyNames = object.getPropertyNames(rt);
|
|
130
76
|
auto size = propertyNames.size(rt);
|
|
131
77
|
data_.reserve(size);
|
|
@@ -6,16 +6,10 @@
|
|
|
6
6
|
#include <utility>
|
|
7
7
|
#include <vector>
|
|
8
8
|
|
|
9
|
-
#ifdef RCT_NEW_ARCH_ENABLED
|
|
10
|
-
#include <react/renderer/uimanager/primitives.h>
|
|
11
|
-
#endif
|
|
12
|
-
|
|
13
9
|
#include "ReanimatedRuntime.h"
|
|
14
10
|
#include "RuntimeManager.h"
|
|
15
11
|
#include "Scheduler.h"
|
|
16
12
|
|
|
17
|
-
#define HAS_JS_WEAK_OBJECTS (JS_RUNTIME_HERMES || JS_RUNTIME_V8)
|
|
18
|
-
|
|
19
13
|
using namespace facebook;
|
|
20
14
|
|
|
21
15
|
namespace reanimated {
|
|
@@ -57,7 +51,7 @@ class JSRuntimeHelper {
|
|
|
57
51
|
const std::shared_ptr<Scheduler> &scheduler)
|
|
58
52
|
: rnRuntime_(rnRuntime), uiRuntime_(uiRuntime), scheduler_(scheduler) {}
|
|
59
53
|
|
|
60
|
-
volatile bool uiRuntimeDestroyed;
|
|
54
|
+
volatile bool uiRuntimeDestroyed = false;
|
|
61
55
|
std::unique_ptr<CoreFunction> callGuard;
|
|
62
56
|
std::unique_ptr<CoreFunction> valueUnpacker;
|
|
63
57
|
|
|
@@ -121,9 +115,7 @@ class Shareable {
|
|
|
121
115
|
RemoteFunctionType,
|
|
122
116
|
HandleType,
|
|
123
117
|
SynchronizedDataHolder,
|
|
124
|
-
|
|
125
|
-
ShadowNode,
|
|
126
|
-
#endif
|
|
118
|
+
HostObjectType,
|
|
127
119
|
};
|
|
128
120
|
|
|
129
121
|
explicit Shareable(ValueType valueType) : valueType_(valueType) {}
|
|
@@ -141,34 +133,57 @@ class Shareable {
|
|
|
141
133
|
ValueType valueType_;
|
|
142
134
|
};
|
|
143
135
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
std::shared_ptr<JSRuntimeHelper> runtimeHelper_;
|
|
147
|
-
|
|
148
|
-
#if HAS_JS_WEAK_OBJECTS
|
|
149
|
-
|
|
136
|
+
template <typename BaseClass>
|
|
137
|
+
class RetainingShareable : virtual public BaseClass {
|
|
150
138
|
private:
|
|
151
|
-
std::
|
|
152
|
-
|
|
153
|
-
public:
|
|
154
|
-
jsi::Value getJSValue(jsi::Runtime &rt) final;
|
|
155
|
-
|
|
156
|
-
RetainingShareable(
|
|
157
|
-
const std::shared_ptr<JSRuntimeHelper> &runtimeHelper,
|
|
158
|
-
jsi::Runtime &rt,
|
|
159
|
-
ValueType valueType)
|
|
160
|
-
: Shareable(valueType), runtimeHelper_(runtimeHelper) {}
|
|
161
|
-
|
|
162
|
-
~RetainingShareable();
|
|
163
|
-
#else
|
|
139
|
+
std::shared_ptr<JSRuntimeHelper> runtimeHelper_;
|
|
140
|
+
std::unique_ptr<jsi::Value> remoteValue_;
|
|
164
141
|
|
|
165
142
|
public:
|
|
143
|
+
template <typename... Args>
|
|
166
144
|
RetainingShareable(
|
|
167
145
|
const std::shared_ptr<JSRuntimeHelper> &runtimeHelper,
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
146
|
+
Args &&...args)
|
|
147
|
+
: BaseClass(std::forward<Args>(args)...), runtimeHelper_(runtimeHelper) {}
|
|
148
|
+
jsi::Value getJSValue(jsi::Runtime &rt) {
|
|
149
|
+
if (runtimeHelper_->isRNRuntime(rt)) {
|
|
150
|
+
// TODO: it is suboptimal to generate new object every time getJS is
|
|
151
|
+
// called on host runtime – the objects we are generating already exists
|
|
152
|
+
// and we should possibly just grab a hold of such object and use it here
|
|
153
|
+
// instead of creating a new JS representation. As far as I understand the
|
|
154
|
+
// only case where it can be realistically called this way is when a
|
|
155
|
+
// shared value is created and then accessed on the same runtime
|
|
156
|
+
return BaseClass::toJSValue(rt);
|
|
157
|
+
} else if (remoteValue_ == nullptr) {
|
|
158
|
+
auto value = BaseClass::toJSValue(rt);
|
|
159
|
+
remoteValue_ = std::make_unique<jsi::Value>(rt, value);
|
|
160
|
+
return value;
|
|
161
|
+
}
|
|
162
|
+
return jsi::Value(rt, *remoteValue_);
|
|
163
|
+
}
|
|
164
|
+
~RetainingShareable() {
|
|
165
|
+
if (runtimeHelper_->uiRuntimeDestroyed) {
|
|
166
|
+
// The below use of unique_ptr.release prevents the smart pointer from
|
|
167
|
+
// calling the destructor of the kept object. This effectively results in
|
|
168
|
+
// leaking some memory. We do this on purpose, as sometimes we would keep
|
|
169
|
+
// references to JSI objects past the lifetime of its runtime (e.g.,
|
|
170
|
+
// shared values references from the RN VM holds reference to JSI objects
|
|
171
|
+
// on the UI runtime). When the UI runtime is terminated, the orphaned JSI
|
|
172
|
+
// objects would crash the app when their destructors are called, because
|
|
173
|
+
// they call into a memory that's managed by the terminated runtime. We
|
|
174
|
+
// accept the tradeoff of leaking memory here, as it has a limited impact.
|
|
175
|
+
// This scenario can only occur when the React instance is torn down which
|
|
176
|
+
// happens in development mode during app reloads, or in production when
|
|
177
|
+
// the app is being shut down gracefully by the system. An alternative
|
|
178
|
+
// solution would require us to keep track of all JSI values that are in
|
|
179
|
+
// use which would require additional data structure and compute spent on
|
|
180
|
+
// bookkeeping that only for the sake of destroying the values in time
|
|
181
|
+
// before the runtime is terminated. Note that the underlying memory that
|
|
182
|
+
// jsi::Value refers to is managed by the VM and gets freed along with the
|
|
183
|
+
// runtime.
|
|
184
|
+
remoteValue_.release();
|
|
185
|
+
}
|
|
186
|
+
}
|
|
172
187
|
};
|
|
173
188
|
|
|
174
189
|
class ShareableJSRef : public jsi::HostObject {
|
|
@@ -210,12 +225,9 @@ std::shared_ptr<T> extractShareableOrThrow(
|
|
|
210
225
|
return res;
|
|
211
226
|
}
|
|
212
227
|
|
|
213
|
-
class ShareableArray : public
|
|
228
|
+
class ShareableArray : public Shareable {
|
|
214
229
|
public:
|
|
215
|
-
ShareableArray(
|
|
216
|
-
const std::shared_ptr<JSRuntimeHelper> &runtimeHelper,
|
|
217
|
-
jsi::Runtime &rt,
|
|
218
|
-
const jsi::Array &array);
|
|
230
|
+
ShareableArray(jsi::Runtime &rt, const jsi::Array &array);
|
|
219
231
|
|
|
220
232
|
jsi::Value toJSValue(jsi::Runtime &rt) override {
|
|
221
233
|
auto size = data_.size();
|
|
@@ -230,12 +242,9 @@ class ShareableArray : public RetainingShareable {
|
|
|
230
242
|
std::vector<std::shared_ptr<Shareable>> data_;
|
|
231
243
|
};
|
|
232
244
|
|
|
233
|
-
class ShareableObject : public
|
|
245
|
+
class ShareableObject : public Shareable {
|
|
234
246
|
public:
|
|
235
|
-
ShareableObject(
|
|
236
|
-
const std::shared_ptr<JSRuntimeHelper> &runtimeHelper,
|
|
237
|
-
jsi::Runtime &rt,
|
|
238
|
-
const jsi::Object &object);
|
|
247
|
+
ShareableObject(jsi::Runtime &rt, const jsi::Object &object);
|
|
239
248
|
jsi::Value toJSValue(jsi::Runtime &rt) override {
|
|
240
249
|
auto obj = jsi::Object(rt);
|
|
241
250
|
for (size_t i = 0, size = data_.size(); i < size; i++) {
|
|
@@ -249,34 +258,31 @@ class ShareableObject : public RetainingShareable {
|
|
|
249
258
|
std::vector<std::pair<std::string, std::shared_ptr<Shareable>>> data_;
|
|
250
259
|
};
|
|
251
260
|
|
|
252
|
-
|
|
253
|
-
class ShareableShadowNodeWrapper : public Shareable {
|
|
254
|
-
private:
|
|
255
|
-
react::ShadowNode::Shared shadowNode_;
|
|
256
|
-
|
|
261
|
+
class ShareableHostObject : public Shareable {
|
|
257
262
|
public:
|
|
258
|
-
|
|
263
|
+
ShareableHostObject(
|
|
259
264
|
const std::shared_ptr<JSRuntimeHelper> &runtimeHelper,
|
|
260
265
|
jsi::Runtime &rt,
|
|
261
|
-
const jsi::
|
|
262
|
-
: Shareable(
|
|
263
|
-
shadowNode_ =
|
|
264
|
-
wrapperObject.getHostObject<ShadowNodeWrapper>(rt)->shadowNode;
|
|
265
|
-
}
|
|
266
|
+
const std::shared_ptr<jsi::HostObject> &hostObject)
|
|
267
|
+
: Shareable(HostObjectType), hostObject_(hostObject) {}
|
|
266
268
|
jsi::Value toJSValue(jsi::Runtime &rt) override {
|
|
267
|
-
return jsi::Object::createFromHostObject(
|
|
268
|
-
rt, std::make_shared<ShadowNodeWrapper>(shadowNode_));
|
|
269
|
+
return jsi::Object::createFromHostObject(rt, hostObject_);
|
|
269
270
|
}
|
|
271
|
+
|
|
272
|
+
protected:
|
|
273
|
+
std::shared_ptr<jsi::HostObject> hostObject_;
|
|
270
274
|
};
|
|
271
|
-
#endif
|
|
272
275
|
|
|
273
276
|
class ShareableWorklet : public ShareableObject {
|
|
277
|
+
private:
|
|
278
|
+
std::shared_ptr<JSRuntimeHelper> runtimeHelper_;
|
|
279
|
+
|
|
274
280
|
public:
|
|
275
281
|
ShareableWorklet(
|
|
276
282
|
const std::shared_ptr<JSRuntimeHelper> &runtimeHelper,
|
|
277
283
|
jsi::Runtime &rt,
|
|
278
284
|
const jsi::Object &worklet)
|
|
279
|
-
: ShareableObject(
|
|
285
|
+
: ShareableObject(rt, worklet), runtimeHelper_(runtimeHelper) {
|
|
280
286
|
valueType_ = WorkletType;
|
|
281
287
|
}
|
|
282
288
|
jsi::Value toJSValue(jsi::Runtime &rt) override {
|
|
@@ -286,18 +292,20 @@ class ShareableWorklet : public ShareableObject {
|
|
|
286
292
|
};
|
|
287
293
|
|
|
288
294
|
class ShareableRemoteFunction
|
|
289
|
-
: public
|
|
295
|
+
: public Shareable,
|
|
290
296
|
public std::enable_shared_from_this<ShareableRemoteFunction> {
|
|
291
297
|
private:
|
|
292
298
|
jsi::Function function_;
|
|
299
|
+
std::shared_ptr<JSRuntimeHelper> runtimeHelper_;
|
|
293
300
|
|
|
294
301
|
public:
|
|
295
302
|
ShareableRemoteFunction(
|
|
296
303
|
const std::shared_ptr<JSRuntimeHelper> &runtimeHelper,
|
|
297
304
|
jsi::Runtime &rt,
|
|
298
305
|
jsi::Function &&function)
|
|
299
|
-
:
|
|
300
|
-
function_(std::move(function))
|
|
306
|
+
: Shareable(RemoteFunctionType),
|
|
307
|
+
function_(std::move(function)),
|
|
308
|
+
runtimeHelper_(runtimeHelper) {}
|
|
301
309
|
jsi::Value toJSValue(jsi::Runtime &rt) override {
|
|
302
310
|
if (runtimeHelper_->isUIRuntime(rt)) {
|
|
303
311
|
#ifdef DEBUG
|
|
@@ -326,8 +334,7 @@ class ShareableHandle : public Shareable {
|
|
|
326
334
|
jsi::Runtime &rt,
|
|
327
335
|
const jsi::Object &initializerObject)
|
|
328
336
|
: Shareable(HandleType), runtimeHelper_(runtimeHelper) {
|
|
329
|
-
initializer_ =
|
|
330
|
-
std::make_unique<ShareableObject>(runtimeHelper, rt, initializerObject);
|
|
337
|
+
initializer_ = std::make_unique<ShareableObject>(rt, initializerObject);
|
|
331
338
|
}
|
|
332
339
|
~ShareableHandle() {
|
|
333
340
|
if (runtimeHelper_->uiRuntimeDestroyed) {
|
|
@@ -372,7 +379,7 @@ class ShareableSynchronizedDataHolder
|
|
|
372
379
|
std::shared_ptr<Shareable> data_;
|
|
373
380
|
std::shared_ptr<jsi::Value> uiValue_;
|
|
374
381
|
std::shared_ptr<jsi::Value> rnValue_;
|
|
375
|
-
std::mutex
|
|
382
|
+
std::mutex dataAccessMutex_; // Protects `data_`.
|
|
376
383
|
|
|
377
384
|
public:
|
|
378
385
|
ShareableSynchronizedDataHolder(
|
|
@@ -384,7 +391,7 @@ class ShareableSynchronizedDataHolder
|
|
|
384
391
|
data_(extractShareableOrThrow(rt, initialValue)) {}
|
|
385
392
|
|
|
386
393
|
jsi::Value get(jsi::Runtime &rt) {
|
|
387
|
-
std::unique_lock<std::mutex> read_lock(
|
|
394
|
+
std::unique_lock<std::mutex> read_lock(dataAccessMutex_);
|
|
388
395
|
if (runtimeHelper_->isUIRuntime(rt)) {
|
|
389
396
|
if (uiValue_ == nullptr) {
|
|
390
397
|
auto value = data_->getJSValue(rt);
|
|
@@ -405,7 +412,7 @@ class ShareableSynchronizedDataHolder
|
|
|
405
412
|
}
|
|
406
413
|
|
|
407
414
|
void set(jsi::Runtime &rt, const jsi::Value &data) {
|
|
408
|
-
std::unique_lock<std::mutex> write_lock(
|
|
415
|
+
std::unique_lock<std::mutex> write_lock(dataAccessMutex_);
|
|
409
416
|
data_ = extractShareableOrThrow(rt, data);
|
|
410
417
|
uiValue_.reset();
|
|
411
418
|
rnValue_.reset();
|
|
@@ -418,16 +425,14 @@ class ShareableSynchronizedDataHolder
|
|
|
418
425
|
|
|
419
426
|
class ShareableString : public Shareable {
|
|
420
427
|
public:
|
|
421
|
-
ShareableString(
|
|
422
|
-
: Shareable(StringType) {
|
|
423
|
-
data = string.utf8(rt);
|
|
424
|
-
}
|
|
428
|
+
explicit ShareableString(const std::string &string)
|
|
429
|
+
: Shareable(StringType), data_(string) {}
|
|
425
430
|
jsi::Value toJSValue(jsi::Runtime &rt) override {
|
|
426
|
-
return jsi::String::createFromUtf8(rt,
|
|
431
|
+
return jsi::String::createFromUtf8(rt, data_);
|
|
427
432
|
}
|
|
428
433
|
|
|
429
434
|
protected:
|
|
430
|
-
std::string
|
|
435
|
+
std::string data_;
|
|
431
436
|
};
|
|
432
437
|
|
|
433
438
|
class ShareableScalar : public Shareable {
|
|
@@ -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
|