react-native-reanimated 2.4.1 → 2.7.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 +72 -0
- package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +30 -1
- package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +64 -39
- package/Common/cpp/SharedItems/ShareableValue.cpp +2 -2
- package/Common/cpp/Tools/RuntimeDecorator.cpp +2 -14
- package/Common/cpp/headers/AnimatedSensor/AnimatedSensorModule.h +41 -0
- package/Common/cpp/headers/NativeModules/NativeReanimatedModule.h +14 -0
- package/Common/cpp/headers/NativeModules/NativeReanimatedModuleSpec.h +14 -0
- package/Common/cpp/headers/SharedItems/MutableValue.h +4 -1
- package/Common/cpp/headers/SharedItems/ShareableValue.h +3 -0
- package/Common/cpp/headers/SharedItems/ValueWrapper.h +3 -0
- package/Common/cpp/headers/Tools/PlatformDepMethodsHolder.h +11 -0
- package/Common/cpp/headers/Tools/RuntimeDecorator.h +2 -0
- package/README.md +2 -2
- package/RNReanimated.podspec +15 -6
- package/android/.gradle/7.2/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/7.2/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/7.2/executionHistory/executionHistory.bin +0 -0
- package/android/.gradle/7.2/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/7.2/fileChanges/last-build.bin +0 -0
- package/android/.gradle/7.2/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/7.2/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.2/fileHashes/resourceHashesCache.bin +0 -0
- package/android/.gradle/7.2/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
- package/android/.gradle/checksums/checksums.lock +0 -0
- package/android/.gradle/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/CMakeLists.txt +198 -0
- package/android/README.md +15 -0
- package/android/build.gradle +676 -73
- package/android/empty.cpp +1 -0
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +5 -0
- package/android/gradle.properties +25 -0
- package/android/gradlew +234 -0
- package/android/gradlew.bat +89 -0
- package/android/react-native-reanimated-64-hermes.aar +0 -0
- package/android/react-native-reanimated-64-jsc.aar +0 -0
- package/android/react-native-reanimated-65-hermes.aar +0 -0
- package/android/react-native-reanimated-65-jsc.aar +0 -0
- package/android/react-native-reanimated-66-hermes.aar +0 -0
- package/android/react-native-reanimated-66-jsc.aar +0 -0
- package/android/react-native-reanimated-67-hermes.aar +0 -0
- package/android/react-native-reanimated-67-jsc.aar +0 -0
- package/android/react-native-reanimated-68-hermes.aar +0 -0
- package/android/react-native-reanimated-68-jsc.aar +0 -0
- package/android/rnVersionPatch/62/layoutReanimation/ReanimatedNativeHierarchyManager.java +412 -0
- package/android/rnVersionPatch/62/layoutReanimation/ReanimatedUIImplementation.java +68 -0
- package/android/rnVersionPatch/63/layoutReanimation/ReanimatedUIImplementation.java +68 -0
- package/android/rnVersionPatch/64/layoutReanimation/ReanimatedUIImplementation.java +68 -0
- package/android/rnVersionPatch/65/.gitkeep +0 -0
- package/android/rnVersionPatch/66/.gitkeep +0 -0
- package/android/rnVersionPatch/67/.gitkeep +0 -0
- package/android/rnVersionPatch/68/.gitkeep +0 -0
- package/android/rnVersionPatch/backup/.gitkeep +0 -0
- package/android/settings.gradle +1 -0
- package/android/spotless.gradle +9 -0
- package/android/src/{AndroidManifest.xml → main/AndroidManifest.xml} +0 -0
- package/android/src/main/cpp/AndroidErrorHandler.cpp +42 -0
- package/android/src/main/cpp/AndroidLogger.cpp +27 -0
- package/android/src/main/cpp/AndroidScheduler.cpp +59 -0
- package/android/src/main/cpp/JNIHelper.cpp +59 -0
- package/android/src/main/cpp/LayoutAnimations.cpp +103 -0
- package/android/src/main/cpp/NativeProxy.cpp +327 -0
- package/android/src/main/cpp/OnLoad.cpp +17 -0
- package/android/src/main/cpp/TurboModule.cpp +44 -0
- package/android/src/main/cpp/headers/AndroidErrorHandler.h +30 -0
- package/android/src/main/cpp/headers/AndroidLogger.h +16 -0
- package/android/src/main/cpp/headers/AndroidScheduler.h +41 -0
- package/android/src/main/cpp/headers/JNIHelper.h +30 -0
- package/android/src/main/cpp/headers/LayoutAnimations.h +42 -0
- package/android/src/main/cpp/headers/NativeProxy.h +170 -0
- package/android/src/main/cpp/headers/TurboModule.h +70 -0
- package/android/src/main/java/com/facebook/react/uimanager/UIManagerReanimatedHelper.java +15 -0
- package/android/src/main/java/com/swmansion/common/GestureHandlerStateManager.java +5 -0
- package/android/src/main/java/com/swmansion/reanimated/AndroidErrorHandler.java +8 -0
- package/android/src/main/java/com/swmansion/reanimated/CopiedEvent.java +43 -0
- package/android/src/main/java/com/swmansion/reanimated/MapUtils.java +26 -0
- package/android/src/main/java/com/swmansion/reanimated/NativeMethodsHelper.java +117 -0
- package/android/src/main/java/com/swmansion/reanimated/NativeProxy.java +288 -0
- package/android/src/main/java/com/swmansion/reanimated/NodesManager.java +682 -0
- package/android/src/main/java/com/swmansion/reanimated/ReanimatedJSIModulePackage.java +29 -0
- package/android/src/main/java/com/swmansion/reanimated/ReanimatedModule.java +251 -0
- package/android/src/main/java/com/swmansion/reanimated/ReanimatedPackage.java +96 -0
- package/android/src/main/java/com/swmansion/reanimated/Scheduler.java +51 -0
- package/android/src/main/java/com/swmansion/reanimated/UpdateContext.java +11 -0
- package/android/src/main/java/com/swmansion/reanimated/Utils.java +32 -0
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/AnimationsManager.java +524 -0
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/LayoutAnimations.java +56 -0
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/NativeMethodsHolder.java +11 -0
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ReanimatedNativeHierarchyManager.java +410 -0
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ReanimatedUIImplementation.java +68 -0
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +292 -0
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/Snapshot.java +121 -0
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ViewHierarchyObserver.java +12 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/AlwaysNode.java +29 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/BezierNode.java +87 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/BlockNode.java +24 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/CallFuncNode.java +49 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/ClockNode.java +38 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/ClockOpNode.java +73 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/ConcatNode.java +36 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/CondNode.java +41 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/DebugNode.java +33 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/EventNode.java +83 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/FinalNode.java +5 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/FunctionNode.java +20 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/JSCallNode.java +41 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/Node.java +139 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/NoopNode.java +37 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/OperatorNode.java +377 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/ParamNode.java +71 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/PropsNode.java +153 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/SetNode.java +32 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/StyleNode.java +40 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/TransformNode.java +84 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/ValueNode.java +40 -0
- package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensor.java +41 -0
- package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorContainer.java +40 -0
- package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorListener.java +31 -0
- package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorType.java +35 -0
- package/android/src/main/java/com/swmansion/reanimated/transitions/ChangeTransition.java +84 -0
- package/android/src/main/java/com/swmansion/reanimated/transitions/SaneSidePropagation.java +25 -0
- package/android/src/main/java/com/swmansion/reanimated/transitions/Scale.java +86 -0
- package/android/src/main/java/com/swmansion/reanimated/transitions/TransitionModule.java +41 -0
- package/android/src/main/java/com/swmansion/reanimated/transitions/TransitionUtils.java +161 -0
- package/ios/LayoutReanimation/REAAnimationsManager.h +1 -1
- package/ios/LayoutReanimation/REAAnimationsManager.m +16 -6
- package/ios/LayoutReanimation/REASnapshot.m +1 -1
- package/ios/LayoutReanimation/REAUIManager.h +1 -1
- package/ios/LayoutReanimation/REAUIManager.mm +4 -5
- package/ios/Nodes/REAAlwaysNode.h +1 -1
- package/ios/Nodes/REAAlwaysNode.m +5 -5
- package/ios/Nodes/REABezierNode.h +1 -1
- package/ios/Nodes/REABezierNode.m +4 -5
- package/ios/Nodes/REABlockNode.h +1 -1
- package/ios/Nodes/REABlockNode.m +2 -2
- package/ios/Nodes/REACallFuncNode.h +1 -1
- package/ios/Nodes/REACallFuncNode.m +5 -5
- package/ios/Nodes/REAClockNodes.h +1 -1
- package/ios/Nodes/REAClockNodes.m +4 -4
- package/ios/Nodes/REAConcatNode.h +1 -1
- package/ios/Nodes/REAConcatNode.m +3 -3
- package/ios/Nodes/REACondNode.h +1 -1
- package/ios/Nodes/REACondNode.m +3 -3
- package/ios/Nodes/READebugNode.h +1 -1
- package/ios/Nodes/READebugNode.m +3 -3
- package/ios/Nodes/REAEventNode.h +1 -2
- package/ios/Nodes/REAEventNode.m +3 -3
- package/ios/Nodes/REAFunctionNode.h +1 -1
- package/ios/Nodes/REAFunctionNode.m +3 -3
- package/ios/Nodes/REAJSCallNode.h +1 -1
- package/ios/Nodes/REAJSCallNode.m +3 -3
- package/ios/Nodes/REANode.m +2 -2
- package/ios/Nodes/REAOperatorNode.h +1 -1
- package/ios/Nodes/REAOperatorNode.m +2 -3
- package/ios/Nodes/REAParamNode.h +1 -1
- package/ios/Nodes/REAParamNode.m +4 -4
- package/ios/Nodes/REAPropsNode.h +1 -1
- package/ios/Nodes/REAPropsNode.m +4 -6
- package/ios/Nodes/REASetNode.h +1 -1
- package/ios/Nodes/REASetNode.m +4 -4
- package/ios/Nodes/REAStyleNode.h +1 -1
- package/ios/Nodes/REAStyleNode.m +2 -3
- package/ios/Nodes/REATransformNode.h +1 -1
- package/ios/Nodes/REATransformNode.m +2 -2
- package/ios/Nodes/REAValueNode.h +1 -3
- package/ios/Nodes/REAValueNode.m +1 -1
- package/ios/REAEventDispatcher.m +1 -1
- package/ios/REAModule.h +1 -1
- package/ios/REAModule.m +12 -14
- package/ios/REANodesManager.h +5 -3
- package/ios/REANodesManager.m +97 -27
- package/ios/Transitioning/RCTConvert+REATransition.h +1 -2
- package/ios/Transitioning/RCTConvert+REATransition.m +1 -1
- package/ios/Transitioning/REAAllTransitions.h +1 -1
- package/ios/Transitioning/REAAllTransitions.m +2 -3
- package/ios/Transitioning/REATransition.h +2 -3
- package/ios/Transitioning/REATransition.m +3 -4
- package/ios/Transitioning/REATransitionAnimation.m +1 -2
- package/ios/Transitioning/REATransitionManager.m +2 -4
- package/ios/Transitioning/REATransitionValues.m +2 -3
- package/ios/native/NativeMethods.h +1 -3
- package/ios/native/NativeMethods.mm +1 -1
- package/ios/native/NativeProxy.h +2 -2
- package/ios/native/NativeProxy.mm +86 -15
- package/ios/native/REAIOSErrorHandler.h +2 -4
- package/ios/native/REAIOSErrorHandler.mm +1 -1
- package/ios/native/REAIOSLogger.h +1 -3
- package/ios/native/REAIOSLogger.mm +1 -1
- package/ios/native/REAIOSScheduler.h +1 -3
- package/ios/native/REAIOSScheduler.mm +2 -2
- package/ios/native/REAInitializer.h +0 -7
- package/ios/native/REAInitializer.mm +2 -2
- package/ios/native/UIResponder+Reanimated.mm +3 -3
- package/ios/sensor/ReanimatedSensor.h +25 -0
- package/ios/sensor/ReanimatedSensor.m +217 -0
- package/ios/sensor/ReanimatedSensorContainer.h +12 -0
- package/ios/sensor/ReanimatedSensorContainer.m +40 -0
- package/ios/sensor/ReanimatedSensorType.h +7 -0
- package/lib/ConfigHelper.js +2 -3
- package/lib/createAnimatedComponent.js +3 -4
- package/lib/reanimated1/core/AnimatedFunction.js +1 -1
- package/lib/reanimated1/derived/interpolate.js +2 -4
- package/lib/reanimated2/Colors.js +2 -1
- package/lib/reanimated2/Easing.js +9 -3
- package/lib/reanimated2/NativeReanimated/NativeReanimated.js +25 -12
- package/lib/reanimated2/NativeReanimated/index.js +0 -4
- package/lib/reanimated2/ViewDescriptorsSet.js +2 -2
- package/lib/reanimated2/animation/styleAnimation.js +2 -1
- package/lib/reanimated2/core.js +30 -60
- package/lib/reanimated2/globals.d.ts +7 -2
- package/lib/reanimated2/hook/index.js +1 -0
- package/lib/reanimated2/hook/useAnimatedSensor.js +66 -0
- package/lib/reanimated2/interpolateColor.js +11 -11
- package/lib/reanimated2/interpolation.js +1 -1
- package/lib/reanimated2/jestUtils.js +9 -4
- package/lib/reanimated2/js-reanimated/JSReanimated.js +23 -2
- package/lib/reanimated2/js-reanimated/index.js +3 -3
- package/lib/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js +8 -0
- package/lib/reanimated2/layoutReanimation/animationBuilder/Keyframe.js +2 -1
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +32 -42
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Fade.js +20 -38
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Flip.js +32 -44
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +8 -16
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js +6 -10
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Roll.js +8 -12
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Rotate.js +20 -36
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Slide.js +16 -20
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Stretch.js +8 -12
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +32 -48
- package/lib/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js +22 -18
- package/lib/reanimated2/mock.js +3 -2
- package/lib/types/lib/ConfigHelper.d.ts +12 -0
- package/lib/types/lib/ReanimatedEventEmitter.d.ts +3 -0
- package/lib/types/lib/ReanimatedModule.d.ts +2 -0
- package/lib/types/lib/ReanimatedModule.macos.d.ts +2 -0
- package/lib/types/lib/ReanimatedModule.native.d.ts +2 -0
- package/lib/types/lib/ReanimatedModule.windows.d.ts +2 -0
- package/lib/types/lib/ReanimatedModuleCompat.d.ts +14 -0
- package/lib/types/lib/createAnimatedComponent.d.ts +33 -0
- package/lib/types/lib/reanimated2/Bezier.d.ts +6 -0
- package/lib/types/lib/reanimated2/Colors.d.ts +31 -0
- package/lib/types/lib/reanimated2/Easing.d.ts +172 -0
- package/lib/types/lib/reanimated2/NativeMethods.d.ts +14 -0
- package/lib/types/lib/reanimated2/NativeReanimated/NativeReanimated.d.ts +20 -0
- package/lib/types/lib/reanimated2/NativeReanimated/index.d.ts +3 -0
- package/lib/types/lib/reanimated2/PlatformChecker.d.ts +5 -0
- package/lib/types/lib/reanimated2/PropAdapters.d.ts +4 -0
- package/lib/types/lib/reanimated2/UpdateProps.d.ts +9 -0
- package/lib/types/lib/reanimated2/ViewDescriptorsSet.d.ts +20 -0
- package/lib/types/lib/reanimated2/WorkletEventHandler.d.ts +13 -0
- package/lib/types/lib/reanimated2/__mocks__/MutableValue.d.ts +5 -0
- package/lib/types/lib/reanimated2/__mocks__/NativeReanimated.d.ts +13 -0
- package/lib/types/lib/reanimated2/__mocks__/NativeReanimated.native.d.ts +13 -0
- package/lib/types/lib/reanimated2/animation/commonTypes.d.ts +27 -0
- package/lib/types/lib/reanimated2/animation/decay.d.ts +19 -0
- package/lib/types/lib/reanimated2/animation/delay.d.ts +7 -0
- package/lib/types/lib/reanimated2/animation/index.d.ts +9 -0
- package/lib/types/lib/reanimated2/animation/repeat.d.ts +12 -0
- package/lib/types/lib/reanimated2/animation/sequence.d.ts +7 -0
- package/lib/types/lib/reanimated2/animation/spring.d.ts +22 -0
- package/lib/types/lib/reanimated2/animation/styleAnimation.d.ts +7 -0
- package/lib/types/lib/reanimated2/animation/timing.d.ts +21 -0
- package/lib/types/lib/reanimated2/animation/util.d.ts +9 -0
- package/lib/types/lib/reanimated2/commonTypes.d.ts +79 -0
- package/lib/types/lib/reanimated2/component/FlatList.d.ts +9 -0
- package/lib/types/lib/reanimated2/component/WrappedComponents.d.ts +8 -0
- package/lib/types/lib/reanimated2/component/index.d.ts +9 -0
- package/lib/types/lib/reanimated2/core.d.ts +24 -0
- package/lib/types/lib/reanimated2/hook/Hooks.d.ts +5 -0
- package/lib/types/lib/reanimated2/hook/commonTypes.d.ts +14 -0
- package/lib/types/lib/reanimated2/hook/index.d.ts +10 -0
- package/lib/types/lib/reanimated2/hook/useAnimatedGestureHandler.d.ts +35 -0
- package/lib/types/lib/reanimated2/hook/useAnimatedReaction.d.ts +12 -0
- package/lib/types/lib/reanimated2/hook/useAnimatedRef.d.ts +3 -0
- package/lib/types/lib/reanimated2/hook/useAnimatedScrollHandler.d.ts +21 -0
- package/lib/types/lib/reanimated2/hook/useAnimatedSensor.d.ts +20 -0
- package/lib/types/lib/reanimated2/hook/useAnimatedStyle.d.ts +11 -0
- package/lib/types/lib/reanimated2/hook/useDerivedValue.d.ts +4 -0
- package/lib/types/lib/reanimated2/hook/useSharedValue.d.ts +2 -0
- package/lib/types/lib/reanimated2/hook/utils.d.ts +28 -0
- package/lib/types/lib/reanimated2/index.d.ts +12 -0
- package/lib/types/lib/reanimated2/interpolateColor.d.ts +26 -0
- package/lib/types/lib/reanimated2/interpolation.d.ts +14 -0
- package/lib/types/lib/reanimated2/jestUtils.d.ts +12 -0
- package/lib/types/lib/reanimated2/js-reanimated/JSReanimated.d.ts +30 -0
- package/lib/types/lib/reanimated2/js-reanimated/Mapper.d.ts +14 -0
- package/lib/types/lib/reanimated2/js-reanimated/MapperRegistry.d.ts +14 -0
- package/lib/types/lib/reanimated2/js-reanimated/MutableValue.d.ts +14 -0
- package/lib/types/lib/reanimated2/js-reanimated/commonTypes.d.ts +44 -0
- package/lib/types/lib/reanimated2/js-reanimated/index.d.ts +15 -0
- package/lib/types/lib/reanimated2/layoutReanimation/LayoutAnimationRepository.d.ts +1 -0
- package/lib/types/lib/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.d.ts +22 -0
- package/lib/types/lib/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.d.ts +38 -0
- package/lib/types/lib/reanimated2/layoutReanimation/animationBuilder/Keyframe.d.ts +25 -0
- package/lib/types/lib/reanimated2/layoutReanimation/animationBuilder/commonTypes.d.ts +77 -0
- package/lib/types/lib/reanimated2/layoutReanimation/animationBuilder/index.d.ts +4 -0
- package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Bounce.d.ts +62 -0
- package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Default.d.ts +4 -0
- package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Fade.d.ts +42 -0
- package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Flip.d.ts +50 -0
- package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.d.ts +18 -0
- package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.d.ts +10 -0
- package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Roll.d.ts +18 -0
- package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Rotate.d.ts +34 -0
- package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Slide.d.ts +34 -0
- package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Stretch.d.ts +18 -0
- package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Zoom.d.ts +66 -0
- package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/index.d.ts +10 -0
- package/lib/types/lib/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.d.ts +19 -0
- package/lib/types/lib/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.d.ts +13 -0
- package/lib/types/lib/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.d.ts +6 -0
- package/lib/types/lib/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.d.ts +6 -0
- package/lib/types/lib/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.d.ts +7 -0
- package/lib/types/lib/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.d.ts +9 -0
- package/lib/types/lib/reanimated2/layoutReanimation/defaultTransitions/index.d.ts +6 -0
- package/lib/types/lib/reanimated2/layoutReanimation/index.d.ts +4 -0
- package/lib/types/lib/reanimated2/mock.d.ts +55 -0
- package/lib/types/lib/reanimated2/platform-specific/RNRenderer.d.ts +1 -0
- package/lib/types/lib/reanimated2/platform-specific/RNRenderer.web.d.ts +0 -0
- package/lib/types/lib/reanimated2/utils.d.ts +7 -0
- package/lib/types/lib/setAndForwardRef.d.ts +40 -0
- package/lib/types/react-native-reanimated-tests.d.ts +1 -0
- package/mock.js +4 -4
- package/package.json +43 -39
- package/plugin.js +3 -12
- package/react-native-reanimated.d.ts +58 -32
- package/src/ConfigHelper.ts +4 -5
- package/src/createAnimatedComponent.tsx +4 -4
- package/src/reanimated1/core/AnimatedFunction.js +1 -1
- package/src/reanimated1/derived/interpolate.js +2 -4
- package/src/reanimated2/Colors.ts +2 -1
- package/src/reanimated2/Easing.ts +9 -3
- package/src/reanimated2/NativeReanimated/NativeReanimated.ts +42 -15
- package/src/reanimated2/NativeReanimated/index.ts +0 -6
- package/src/reanimated2/ViewDescriptorsSet.ts +2 -3
- package/src/reanimated2/animation/index.ts +1 -0
- package/src/reanimated2/animation/styleAnimation.ts +10 -7
- package/src/reanimated2/animation/timing.ts +3 -1
- package/src/reanimated2/animation/util.ts +10 -11
- package/src/reanimated2/commonTypes.ts +20 -1
- package/src/reanimated2/component/FlatList.tsx +3 -2
- package/src/reanimated2/core.ts +34 -73
- package/src/reanimated2/globals.d.ts +7 -2
- package/src/reanimated2/hook/index.ts +1 -0
- package/src/reanimated2/hook/useAnimatedSensor.ts +91 -0
- package/src/reanimated2/hook/utils.ts +2 -1
- package/src/reanimated2/interpolateColor.ts +11 -11
- package/src/reanimated2/interpolation.ts +2 -6
- package/src/reanimated2/jestUtils.ts +20 -4
- package/src/reanimated2/js-reanimated/JSReanimated.ts +25 -2
- package/src/reanimated2/js-reanimated/index.ts +3 -3
- package/src/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.ts +13 -0
- package/src/reanimated2/layoutReanimation/animationBuilder/Keyframe.ts +2 -3
- package/src/reanimated2/layoutReanimation/defaultAnimations/Bounce.ts +51 -21
- package/src/reanimated2/layoutReanimation/defaultAnimations/Fade.ts +40 -10
- package/src/reanimated2/layoutReanimation/defaultAnimations/Flip.ts +48 -12
- package/src/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.ts +16 -4
- package/src/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.ts +8 -2
- package/src/reanimated2/layoutReanimation/defaultAnimations/Roll.ts +16 -4
- package/src/reanimated2/layoutReanimation/defaultAnimations/Rotate.ts +32 -8
- package/src/reanimated2/layoutReanimation/defaultAnimations/Slide.ts +32 -10
- package/src/reanimated2/layoutReanimation/defaultAnimations/Stretch.ts +16 -4
- package/src/reanimated2/layoutReanimation/defaultAnimations/Zoom.ts +64 -16
- package/src/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.ts +2 -1
- package/src/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.ts +26 -19
- package/src/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.ts +2 -1
- package/src/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.ts +2 -1
- package/src/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.ts +2 -1
- package/src/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.ts +2 -1
- package/src/reanimated2/mock.ts +3 -2
- package/android/expo/linking.gradle +0 -46
- package/android/expo/src/main/java/com/swmansion/reanimated/EXReanimatedAdapter.java +0 -12
- package/android/expo/src/main/java/expo/modules/adapters/reanimated/EXReanimatedPackage.java +0 -26
- package/android/react-native-reanimated-63-hermes.aar +0 -0
- package/android/react-native-reanimated-63-jsc.aar +0 -0
- package/android/src/main/java/com/swmansion/reanimated/ReanimatedProxyPackage.java +0 -15
- package/expo-module.config.json +0 -3
- package/libSo/fbjni/jni/arm64-v8a/libfbjni.so +0 -0
- package/libSo/fbjni/jni/armeabi-v7a/libfbjni.so +0 -0
- package/libSo/fbjni/jni/x86/libfbjni.so +0 -0
- package/libSo/fbjni/jni/x86_64/libfbjni.so +0 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#include "AndroidLogger.h"
|
|
2
|
+
#include <android/log.h>
|
|
3
|
+
#include "Logger.h"
|
|
4
|
+
#define APPNAME "NATIVE_REANIMATED"
|
|
5
|
+
|
|
6
|
+
namespace reanimated {
|
|
7
|
+
|
|
8
|
+
std::unique_ptr<LoggerInterface> Logger::instance =
|
|
9
|
+
std::make_unique<AndroidLogger>();
|
|
10
|
+
|
|
11
|
+
void AndroidLogger::log(const char *str) {
|
|
12
|
+
__android_log_print(ANDROID_LOG_VERBOSE, APPNAME, "%s", str);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
void AndroidLogger::log(double d) {
|
|
16
|
+
__android_log_print(ANDROID_LOG_VERBOSE, APPNAME, "%f", d);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
void AndroidLogger::log(int i) {
|
|
20
|
+
__android_log_print(ANDROID_LOG_VERBOSE, APPNAME, "%d", i);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
void AndroidLogger::log(bool b) {
|
|
24
|
+
__android_log_print(ANDROID_LOG_VERBOSE, APPNAME, "%s", b ? "true" : "false");
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
} // namespace reanimated
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#include "AndroidScheduler.h"
|
|
2
|
+
#include <android/log.h>
|
|
3
|
+
#include <fbjni/fbjni.h>
|
|
4
|
+
#include <jsi/jsi.h>
|
|
5
|
+
#include <memory>
|
|
6
|
+
#include <string>
|
|
7
|
+
|
|
8
|
+
namespace reanimated {
|
|
9
|
+
|
|
10
|
+
using namespace facebook;
|
|
11
|
+
using namespace react;
|
|
12
|
+
|
|
13
|
+
class SchedulerWrapper : public Scheduler {
|
|
14
|
+
private:
|
|
15
|
+
jni::global_ref<AndroidScheduler::javaobject> scheduler_;
|
|
16
|
+
|
|
17
|
+
public:
|
|
18
|
+
explicit SchedulerWrapper(
|
|
19
|
+
jni::global_ref<AndroidScheduler::javaobject> scheduler)
|
|
20
|
+
: scheduler_(scheduler) {}
|
|
21
|
+
|
|
22
|
+
void scheduleOnUI(std::function<void()> job) override {
|
|
23
|
+
Scheduler::scheduleOnUI(job);
|
|
24
|
+
if (!scheduledOnUI) {
|
|
25
|
+
scheduledOnUI = true;
|
|
26
|
+
scheduler_->cthis()->scheduleOnUI();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
~SchedulerWrapper() {}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
AndroidScheduler::AndroidScheduler(
|
|
34
|
+
jni::alias_ref<AndroidScheduler::javaobject> jThis)
|
|
35
|
+
: javaPart_(jni::make_global(jThis)),
|
|
36
|
+
scheduler_(new SchedulerWrapper(jni::make_global(jThis))) {}
|
|
37
|
+
|
|
38
|
+
jni::local_ref<AndroidScheduler::jhybriddata> AndroidScheduler::initHybrid(
|
|
39
|
+
jni::alias_ref<jhybridobject> jThis) {
|
|
40
|
+
return makeCxxInstance(jThis);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
void AndroidScheduler::triggerUI() {
|
|
44
|
+
scheduler_->triggerUI();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
void AndroidScheduler::scheduleOnUI() {
|
|
48
|
+
static auto method = javaPart_->getClass()->getMethod<void()>("scheduleOnUI");
|
|
49
|
+
method(javaPart_.get());
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
void AndroidScheduler::registerNatives() {
|
|
53
|
+
registerHybrid({
|
|
54
|
+
makeNativeMethod("initHybrid", AndroidScheduler::initHybrid),
|
|
55
|
+
makeNativeMethod("triggerUI", AndroidScheduler::triggerUI),
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
} // namespace reanimated
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#include "JNIHelper.h"
|
|
2
|
+
|
|
3
|
+
namespace reanimated {
|
|
4
|
+
|
|
5
|
+
using namespace facebook::jni;
|
|
6
|
+
using namespace facebook;
|
|
7
|
+
using namespace react;
|
|
8
|
+
|
|
9
|
+
local_ref<JNIHelper::PropsMap> JNIHelper::PropsMap::create() {
|
|
10
|
+
return newInstance();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
void JNIHelper::PropsMap::put(
|
|
14
|
+
const std::string &key,
|
|
15
|
+
jni::local_ref<JObject> object) {
|
|
16
|
+
static auto method =
|
|
17
|
+
getClass()
|
|
18
|
+
->getMethod<jobject(
|
|
19
|
+
jni::local_ref<JObject>, jni::local_ref<JObject>)>("put");
|
|
20
|
+
method(self(), jni::make_jstring(key), object);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
jni::local_ref<JNIHelper::PropsMap> JNIHelper::ConvertToPropsMap(
|
|
24
|
+
jsi::Runtime &rt,
|
|
25
|
+
const jsi::Object &props) {
|
|
26
|
+
auto map = PropsMap::create();
|
|
27
|
+
|
|
28
|
+
auto propNames = props.getPropertyNames(rt);
|
|
29
|
+
for (size_t i = 0, size = propNames.size(rt); i < size; i++) {
|
|
30
|
+
auto jsiKey = propNames.getValueAtIndex(rt, i).asString(rt);
|
|
31
|
+
auto value = props.getProperty(rt, jsiKey);
|
|
32
|
+
auto key = jsiKey.utf8(rt);
|
|
33
|
+
if (value.isUndefined() || value.isNull()) {
|
|
34
|
+
map->put(key, nullptr);
|
|
35
|
+
} else if (value.isBool()) {
|
|
36
|
+
map->put(key, JBoolean::valueOf(value.getBool()));
|
|
37
|
+
} else if (value.isNumber()) {
|
|
38
|
+
map->put(key, jni::autobox(value.asNumber()));
|
|
39
|
+
} else if (value.isString()) {
|
|
40
|
+
map->put(key, jni::make_jstring(value.asString(rt).utf8(rt)));
|
|
41
|
+
} else if (value.isObject()) {
|
|
42
|
+
if (value.asObject(rt).isArray(rt)) {
|
|
43
|
+
map->put(
|
|
44
|
+
key,
|
|
45
|
+
ReadableNativeArray::newObjectCxxArgs(
|
|
46
|
+
jsi::dynamicFromValue(rt, value)));
|
|
47
|
+
} else {
|
|
48
|
+
map->put(
|
|
49
|
+
key,
|
|
50
|
+
ReadableNativeMap::newObjectCxxArgs(
|
|
51
|
+
jsi::dynamicFromValue(rt, value)));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return map;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
}; // namespace reanimated
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
#include "LayoutAnimations.h"
|
|
2
|
+
#include "FeaturesConfig.h"
|
|
3
|
+
#include "Logger.h"
|
|
4
|
+
|
|
5
|
+
namespace reanimated {
|
|
6
|
+
|
|
7
|
+
LayoutAnimations::LayoutAnimations(
|
|
8
|
+
jni::alias_ref<LayoutAnimations::javaobject> jThis)
|
|
9
|
+
: javaPart_(jni::make_global(jThis)) {}
|
|
10
|
+
|
|
11
|
+
jni::local_ref<LayoutAnimations::jhybriddata> LayoutAnimations::initHybrid(
|
|
12
|
+
jni::alias_ref<jhybridobject> jThis) {
|
|
13
|
+
return makeCxxInstance(jThis);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
void LayoutAnimations::setWeakUIRuntime(std::weak_ptr<jsi::Runtime> wrt) {
|
|
17
|
+
this->weakUIRuntime = wrt;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
void LayoutAnimations::startAnimationForTag(
|
|
21
|
+
int tag,
|
|
22
|
+
alias_ref<JString> type,
|
|
23
|
+
alias_ref<JMap<jstring, jstring>> values) {
|
|
24
|
+
if (auto rt = this->weakUIRuntime.lock()) {
|
|
25
|
+
jsi::Value layoutAnimationRepositoryAsValue =
|
|
26
|
+
rt->global()
|
|
27
|
+
.getPropertyAsObject(*rt, "global")
|
|
28
|
+
.getProperty(*rt, "LayoutAnimationRepository");
|
|
29
|
+
if (!layoutAnimationRepositoryAsValue.isUndefined()) {
|
|
30
|
+
jsi::Function startAnimationForTag =
|
|
31
|
+
layoutAnimationRepositoryAsValue.getObject(*rt).getPropertyAsFunction(
|
|
32
|
+
*rt, "startAnimationForTag");
|
|
33
|
+
jsi::Object target(*rt);
|
|
34
|
+
|
|
35
|
+
for (const auto &entry : *values) {
|
|
36
|
+
target.setProperty(
|
|
37
|
+
*rt,
|
|
38
|
+
entry.first->toStdString().c_str(),
|
|
39
|
+
std::stof(entry.second->toStdString()));
|
|
40
|
+
}
|
|
41
|
+
startAnimationForTag.call(
|
|
42
|
+
*rt,
|
|
43
|
+
jsi::Value(tag),
|
|
44
|
+
jsi::String::createFromUtf8(*rt, type->toStdString()),
|
|
45
|
+
target);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
void LayoutAnimations::removeConfigForTag(int tag) {
|
|
51
|
+
if (auto rt = this->weakUIRuntime.lock()) {
|
|
52
|
+
jsi::Value layoutAnimationRepositoryAsValue =
|
|
53
|
+
rt->global()
|
|
54
|
+
.getPropertyAsObject(*rt, "global")
|
|
55
|
+
.getProperty(*rt, "LayoutAnimationRepository");
|
|
56
|
+
if (!layoutAnimationRepositoryAsValue.isUndefined()) {
|
|
57
|
+
jsi::Function removeConfig =
|
|
58
|
+
layoutAnimationRepositoryAsValue.getObject(*rt).getPropertyAsFunction(
|
|
59
|
+
*rt, "removeConfig");
|
|
60
|
+
removeConfig.call(*rt, jsi::Value(tag));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
void LayoutAnimations::notifyAboutProgress(
|
|
66
|
+
const jsi::Value &progress,
|
|
67
|
+
int tag) {
|
|
68
|
+
if (auto rt = this->weakUIRuntime.lock()) {
|
|
69
|
+
static const auto method =
|
|
70
|
+
javaPart_->getClass()
|
|
71
|
+
->getMethod<void(JMap<JString, JObject>::javaobject, int)>(
|
|
72
|
+
"notifyAboutProgress");
|
|
73
|
+
method(
|
|
74
|
+
javaPart_.get(),
|
|
75
|
+
JNIHelper::ConvertToPropsMap(*rt, progress.asObject(*rt)).get(),
|
|
76
|
+
tag);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
void LayoutAnimations::notifyAboutEnd(int tag, int cancelled) {
|
|
81
|
+
static const auto method =
|
|
82
|
+
javaPart_->getClass()->getMethod<void(int, int)>("notifyAboutEnd");
|
|
83
|
+
method(javaPart_.get(), tag, cancelled);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
bool LayoutAnimations::isLayoutAnimationEnabled() {
|
|
87
|
+
return FeaturesConfig::isLayoutAnimationEnabled();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
void LayoutAnimations::registerNatives() {
|
|
91
|
+
registerHybrid({
|
|
92
|
+
makeNativeMethod("initHybrid", LayoutAnimations::initHybrid),
|
|
93
|
+
makeNativeMethod(
|
|
94
|
+
"startAnimationForTag", LayoutAnimations::startAnimationForTag),
|
|
95
|
+
makeNativeMethod(
|
|
96
|
+
"removeConfigForTag", LayoutAnimations::removeConfigForTag),
|
|
97
|
+
makeNativeMethod(
|
|
98
|
+
"isLayoutAnimationEnabled",
|
|
99
|
+
LayoutAnimations::isLayoutAnimationEnabled),
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
}; // namespace reanimated
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
#include <fbjni/fbjni.h>
|
|
2
|
+
#include <jsi/JSIDynamic.h>
|
|
3
|
+
#include <jsi/jsi.h>
|
|
4
|
+
#include <react/jni/ReadableNativeArray.h>
|
|
5
|
+
#include <react/jni/ReadableNativeMap.h>
|
|
6
|
+
|
|
7
|
+
#include <memory>
|
|
8
|
+
#include <string>
|
|
9
|
+
|
|
10
|
+
#if FOR_HERMES
|
|
11
|
+
#include <hermes/hermes.h>
|
|
12
|
+
#else
|
|
13
|
+
#include <jsi/JSCRuntime.h>
|
|
14
|
+
#endif
|
|
15
|
+
|
|
16
|
+
#include <android/log.h>
|
|
17
|
+
#include "AndroidErrorHandler.h"
|
|
18
|
+
#include "AndroidScheduler.h"
|
|
19
|
+
#include "LayoutAnimationsProxy.h"
|
|
20
|
+
#include "NativeProxy.h"
|
|
21
|
+
#include "PlatformDepMethodsHolder.h"
|
|
22
|
+
|
|
23
|
+
namespace reanimated {
|
|
24
|
+
|
|
25
|
+
using namespace facebook;
|
|
26
|
+
using namespace react;
|
|
27
|
+
|
|
28
|
+
NativeProxy::NativeProxy(
|
|
29
|
+
jni::alias_ref<NativeProxy::javaobject> jThis,
|
|
30
|
+
jsi::Runtime *rt,
|
|
31
|
+
std::shared_ptr<facebook::react::CallInvoker> jsCallInvoker,
|
|
32
|
+
std::shared_ptr<Scheduler> scheduler,
|
|
33
|
+
jni::global_ref<LayoutAnimations::javaobject> _layoutAnimations)
|
|
34
|
+
: javaPart_(jni::make_global(jThis)),
|
|
35
|
+
runtime_(rt),
|
|
36
|
+
jsCallInvoker_(jsCallInvoker),
|
|
37
|
+
scheduler_(scheduler),
|
|
38
|
+
layoutAnimations(std::move(_layoutAnimations)) {}
|
|
39
|
+
|
|
40
|
+
jni::local_ref<NativeProxy::jhybriddata> NativeProxy::initHybrid(
|
|
41
|
+
jni::alias_ref<jhybridobject> jThis,
|
|
42
|
+
jlong jsContext,
|
|
43
|
+
jni::alias_ref<facebook::react::CallInvokerHolder::javaobject>
|
|
44
|
+
jsCallInvokerHolder,
|
|
45
|
+
jni::alias_ref<AndroidScheduler::javaobject> androidScheduler,
|
|
46
|
+
jni::alias_ref<LayoutAnimations::javaobject> layoutAnimations) {
|
|
47
|
+
auto jsCallInvoker = jsCallInvokerHolder->cthis()->getCallInvoker();
|
|
48
|
+
auto scheduler = androidScheduler->cthis()->getScheduler();
|
|
49
|
+
scheduler->setJSCallInvoker(jsCallInvoker);
|
|
50
|
+
return makeCxxInstance(
|
|
51
|
+
jThis,
|
|
52
|
+
(jsi::Runtime *)jsContext,
|
|
53
|
+
jsCallInvoker,
|
|
54
|
+
scheduler,
|
|
55
|
+
make_global(layoutAnimations));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
void NativeProxy::installJSIBindings() {
|
|
59
|
+
auto propUpdater = [this](
|
|
60
|
+
jsi::Runtime &rt,
|
|
61
|
+
int viewTag,
|
|
62
|
+
const jsi::Value &viewName,
|
|
63
|
+
const jsi::Object &props) {
|
|
64
|
+
// viewName is for iOS only, we skip it here
|
|
65
|
+
this->updateProps(rt, viewTag, props);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
auto getCurrentTime = [this]() {
|
|
69
|
+
auto method =
|
|
70
|
+
javaPart_->getClass()->getMethod<local_ref<JString>()>("getUptime");
|
|
71
|
+
local_ref<JString> output = method(javaPart_.get());
|
|
72
|
+
return static_cast<double>(
|
|
73
|
+
std::strtoll(output->toStdString().c_str(), NULL, 10));
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
auto requestRender = [this, getCurrentTime](
|
|
77
|
+
std::function<void(double)> onRender,
|
|
78
|
+
jsi::Runtime &rt) {
|
|
79
|
+
// doNoUse -> NodesManager passes here a timestamp from choreographer which
|
|
80
|
+
// is useless for us as we use diffrent timer to better handle events. The
|
|
81
|
+
// lambda is translated to NodeManager.OnAnimationFrame and treated just
|
|
82
|
+
// like reanimated 1 frame callbacks which make use of the timestamp.
|
|
83
|
+
auto wrappedOnRender = [getCurrentTime, &rt, onRender](double doNotUse) {
|
|
84
|
+
jsi::Object global = rt.global();
|
|
85
|
+
jsi::String frameTimestampName =
|
|
86
|
+
jsi::String::createFromAscii(rt, "_frameTimestamp");
|
|
87
|
+
double frameTimestamp = getCurrentTime();
|
|
88
|
+
global.setProperty(rt, frameTimestampName, frameTimestamp);
|
|
89
|
+
onRender(frameTimestamp);
|
|
90
|
+
global.setProperty(rt, frameTimestampName, jsi::Value::undefined());
|
|
91
|
+
};
|
|
92
|
+
this->requestRender(std::move(wrappedOnRender));
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
auto propObtainer = [this](
|
|
96
|
+
jsi::Runtime &rt,
|
|
97
|
+
const int viewTag,
|
|
98
|
+
const jsi::String &propName) -> jsi::Value {
|
|
99
|
+
auto method =
|
|
100
|
+
javaPart_->getClass()
|
|
101
|
+
->getMethod<jni::local_ref<JString>(int, jni::local_ref<JString>)>(
|
|
102
|
+
"obtainProp");
|
|
103
|
+
local_ref<JString> propNameJStr =
|
|
104
|
+
jni::make_jstring(propName.utf8(rt).c_str());
|
|
105
|
+
auto result = method(javaPart_.get(), viewTag, propNameJStr);
|
|
106
|
+
std::string str = result->toStdString();
|
|
107
|
+
return jsi::Value(rt, jsi::String::createFromAscii(rt, str.c_str()));
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
auto measuringFunction =
|
|
111
|
+
[this](int viewTag) -> std::vector<std::pair<std::string, double>> {
|
|
112
|
+
return measure(viewTag);
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
auto scrollToFunction =
|
|
116
|
+
[this](int viewTag, double x, double y, bool animated) -> void {
|
|
117
|
+
scrollTo(viewTag, x, y, animated);
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
auto registerSensorFunction =
|
|
121
|
+
[this](int sensorType, int interval, std::function<void(double[])> setter)
|
|
122
|
+
-> int {
|
|
123
|
+
return this->registerSensor(sensorType, interval, std::move(setter));
|
|
124
|
+
};
|
|
125
|
+
auto unregisterSensorFunction = [this](int sensorId) {
|
|
126
|
+
unregisterSensor(sensorId);
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
auto setGestureStateFunction = [this](int handlerTag, int newState) -> void {
|
|
130
|
+
setGestureState(handlerTag, newState);
|
|
131
|
+
};
|
|
132
|
+
#if FOR_HERMES
|
|
133
|
+
auto config =
|
|
134
|
+
::hermes::vm::RuntimeConfig::Builder().withEnableSampleProfiling(false);
|
|
135
|
+
std::shared_ptr<jsi::Runtime> animatedRuntime =
|
|
136
|
+
facebook::hermes::makeHermesRuntime(config.build());
|
|
137
|
+
#else
|
|
138
|
+
std::shared_ptr<jsi::Runtime> animatedRuntime =
|
|
139
|
+
facebook::jsc::makeJSCRuntime();
|
|
140
|
+
#endif
|
|
141
|
+
runtime_->global().setProperty(
|
|
142
|
+
*runtime_,
|
|
143
|
+
"_WORKLET_RUNTIME",
|
|
144
|
+
static_cast<double>(
|
|
145
|
+
reinterpret_cast<std::uintptr_t>(animatedRuntime.get())));
|
|
146
|
+
|
|
147
|
+
std::shared_ptr<ErrorHandler> errorHandler =
|
|
148
|
+
std::make_shared<AndroidErrorHandler>(scheduler_);
|
|
149
|
+
|
|
150
|
+
// Layout Animations Start
|
|
151
|
+
|
|
152
|
+
auto notifyAboutProgress = [=](int tag, jsi::Value progress) {
|
|
153
|
+
this->layoutAnimations->cthis()->notifyAboutProgress(progress, tag);
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
auto notifyAboutEnd = [=](int tag, bool isCancelled) {
|
|
157
|
+
this->layoutAnimations->cthis()->notifyAboutEnd(tag, (isCancelled) ? 1 : 0);
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
auto configurePropsFunction = [=](jsi::Runtime &rt,
|
|
161
|
+
const jsi::Value &uiProps,
|
|
162
|
+
const jsi::Value &nativeProps) {
|
|
163
|
+
this->configureProps(rt, uiProps, nativeProps);
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
std::shared_ptr<LayoutAnimationsProxy> layoutAnimationsProxy =
|
|
167
|
+
std::make_shared<LayoutAnimationsProxy>(
|
|
168
|
+
notifyAboutProgress, notifyAboutEnd);
|
|
169
|
+
std::weak_ptr<jsi::Runtime> wrt = animatedRuntime;
|
|
170
|
+
layoutAnimations->cthis()->setWeakUIRuntime(wrt);
|
|
171
|
+
|
|
172
|
+
// Layout Animations End
|
|
173
|
+
|
|
174
|
+
PlatformDepMethodsHolder platformDepMethodsHolder = {
|
|
175
|
+
requestRender,
|
|
176
|
+
propUpdater,
|
|
177
|
+
scrollToFunction,
|
|
178
|
+
measuringFunction,
|
|
179
|
+
getCurrentTime,
|
|
180
|
+
registerSensorFunction,
|
|
181
|
+
unregisterSensorFunction,
|
|
182
|
+
setGestureStateFunction,
|
|
183
|
+
configurePropsFunction};
|
|
184
|
+
|
|
185
|
+
auto module = std::make_shared<NativeReanimatedModule>(
|
|
186
|
+
jsCallInvoker_,
|
|
187
|
+
scheduler_,
|
|
188
|
+
animatedRuntime,
|
|
189
|
+
errorHandler,
|
|
190
|
+
propObtainer,
|
|
191
|
+
layoutAnimationsProxy,
|
|
192
|
+
platformDepMethodsHolder);
|
|
193
|
+
|
|
194
|
+
_nativeReanimatedModule = module;
|
|
195
|
+
|
|
196
|
+
this->registerEventHandler([module, getCurrentTime](
|
|
197
|
+
std::string eventName,
|
|
198
|
+
std::string eventAsString) {
|
|
199
|
+
jsi::Object global = module->runtime->global();
|
|
200
|
+
jsi::String eventTimestampName =
|
|
201
|
+
jsi::String::createFromAscii(*module->runtime, "_eventTimestamp");
|
|
202
|
+
global.setProperty(*module->runtime, eventTimestampName, getCurrentTime());
|
|
203
|
+
module->onEvent(eventName, eventAsString);
|
|
204
|
+
global.setProperty(
|
|
205
|
+
*module->runtime, eventTimestampName, jsi::Value::undefined());
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
runtime_->global().setProperty(
|
|
209
|
+
*runtime_,
|
|
210
|
+
jsi::PropNameID::forAscii(*runtime_, "__reanimatedModuleProxy"),
|
|
211
|
+
jsi::Object::createFromHostObject(*runtime_, module));
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
bool NativeProxy::isAnyHandlerWaitingForEvent(std::string s) {
|
|
215
|
+
return _nativeReanimatedModule->isAnyHandlerWaitingForEvent(s);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
void NativeProxy::registerNatives() {
|
|
219
|
+
registerHybrid(
|
|
220
|
+
{makeNativeMethod("initHybrid", NativeProxy::initHybrid),
|
|
221
|
+
makeNativeMethod("installJSIBindings", NativeProxy::installJSIBindings),
|
|
222
|
+
makeNativeMethod(
|
|
223
|
+
"isAnyHandlerWaitingForEvent",
|
|
224
|
+
NativeProxy::isAnyHandlerWaitingForEvent)});
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
void NativeProxy::requestRender(std::function<void(double)> onRender) {
|
|
228
|
+
static auto method =
|
|
229
|
+
javaPart_->getClass()
|
|
230
|
+
->getMethod<void(AnimationFrameCallback::javaobject)>(
|
|
231
|
+
"requestRender");
|
|
232
|
+
method(
|
|
233
|
+
javaPart_.get(),
|
|
234
|
+
AnimationFrameCallback::newObjectCxxArgs(std::move(onRender)).get());
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
void NativeProxy::registerEventHandler(
|
|
238
|
+
std::function<void(std::string, std::string)> handler) {
|
|
239
|
+
static auto method =
|
|
240
|
+
javaPart_->getClass()->getMethod<void(EventHandler::javaobject)>(
|
|
241
|
+
"registerEventHandler");
|
|
242
|
+
method(
|
|
243
|
+
javaPart_.get(),
|
|
244
|
+
EventHandler::newObjectCxxArgs(std::move(handler)).get());
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
void NativeProxy::updateProps(
|
|
248
|
+
jsi::Runtime &rt,
|
|
249
|
+
int viewTag,
|
|
250
|
+
const jsi::Object &props) {
|
|
251
|
+
auto method = javaPart_->getClass()
|
|
252
|
+
->getMethod<void(int, JMap<JString, JObject>::javaobject)>(
|
|
253
|
+
"updateProps");
|
|
254
|
+
method(
|
|
255
|
+
javaPart_.get(), viewTag, JNIHelper::ConvertToPropsMap(rt, props).get());
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
void NativeProxy::scrollTo(int viewTag, double x, double y, bool animated) {
|
|
259
|
+
auto method =
|
|
260
|
+
javaPart_->getClass()->getMethod<void(int, double, double, bool)>(
|
|
261
|
+
"scrollTo");
|
|
262
|
+
method(javaPart_.get(), viewTag, x, y, animated);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
std::vector<std::pair<std::string, double>> NativeProxy::measure(int viewTag) {
|
|
266
|
+
auto method =
|
|
267
|
+
javaPart_->getClass()->getMethod<local_ref<JArrayFloat>(int)>("measure");
|
|
268
|
+
local_ref<JArrayFloat> output = method(javaPart_.get(), viewTag);
|
|
269
|
+
size_t size = output->size();
|
|
270
|
+
auto elements = output->getRegion(0, size);
|
|
271
|
+
std::vector<std::pair<std::string, double>> result;
|
|
272
|
+
|
|
273
|
+
result.push_back({"x", elements[0]});
|
|
274
|
+
result.push_back({"y", elements[1]});
|
|
275
|
+
|
|
276
|
+
result.push_back({"pageX", elements[2]});
|
|
277
|
+
result.push_back({"pageY", elements[3]});
|
|
278
|
+
|
|
279
|
+
result.push_back({"width", elements[4]});
|
|
280
|
+
result.push_back({"height", elements[5]});
|
|
281
|
+
|
|
282
|
+
return result;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
int NativeProxy::registerSensor(
|
|
286
|
+
int sensorType,
|
|
287
|
+
int interval,
|
|
288
|
+
std::function<void(double[])> setter) {
|
|
289
|
+
static auto method =
|
|
290
|
+
javaPart_->getClass()->getMethod<int(int, int, SensorSetter::javaobject)>(
|
|
291
|
+
"registerSensor");
|
|
292
|
+
return method(
|
|
293
|
+
javaPart_.get(),
|
|
294
|
+
sensorType,
|
|
295
|
+
interval,
|
|
296
|
+
SensorSetter::newObjectCxxArgs(std::move(setter)).get());
|
|
297
|
+
}
|
|
298
|
+
void NativeProxy::unregisterSensor(int sensorId) {
|
|
299
|
+
auto method = javaPart_->getClass()->getMethod<void(int)>("unregisterSensor");
|
|
300
|
+
method(javaPart_.get(), sensorId);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
void NativeProxy::setGestureState(int handlerTag, int newState) {
|
|
304
|
+
auto method =
|
|
305
|
+
javaPart_->getClass()->getMethod<void(int, int)>("setGestureState");
|
|
306
|
+
method(javaPart_.get(), handlerTag, newState);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
void NativeProxy::configureProps(
|
|
310
|
+
jsi::Runtime &rt,
|
|
311
|
+
const jsi::Value &uiProps,
|
|
312
|
+
const jsi::Value &nativeProps) {
|
|
313
|
+
auto method = javaPart_->getClass()
|
|
314
|
+
->getMethod<void(
|
|
315
|
+
ReadableNativeArray::javaobject,
|
|
316
|
+
ReadableNativeArray::javaobject)>("configureProps");
|
|
317
|
+
method(
|
|
318
|
+
javaPart_.get(),
|
|
319
|
+
ReadableNativeArray::newObjectCxxArgs(
|
|
320
|
+
std::move(jsi::dynamicFromValue(rt, uiProps)))
|
|
321
|
+
.get(),
|
|
322
|
+
ReadableNativeArray::newObjectCxxArgs(
|
|
323
|
+
std::move(jsi::dynamicFromValue(rt, nativeProps)))
|
|
324
|
+
.get());
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
} // namespace reanimated
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#include <fbjni/fbjni.h>
|
|
2
|
+
|
|
3
|
+
#include "AndroidScheduler.h"
|
|
4
|
+
#include "LayoutAnimations.h"
|
|
5
|
+
#include "Logger.h"
|
|
6
|
+
#include "NativeProxy.h"
|
|
7
|
+
|
|
8
|
+
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *) {
|
|
9
|
+
return facebook::jni::initialize(vm, [] {
|
|
10
|
+
reanimated::NativeProxy::registerNatives();
|
|
11
|
+
reanimated::AnimationFrameCallback::registerNatives();
|
|
12
|
+
reanimated::EventHandler::registerNatives();
|
|
13
|
+
reanimated::AndroidScheduler::registerNatives();
|
|
14
|
+
reanimated::LayoutAnimations::registerNatives();
|
|
15
|
+
reanimated::SensorSetter::registerNatives();
|
|
16
|
+
});
|
|
17
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#include "TurboModule.h"
|
|
9
|
+
|
|
10
|
+
using namespace facebook;
|
|
11
|
+
|
|
12
|
+
namespace facebook {
|
|
13
|
+
namespace react {
|
|
14
|
+
|
|
15
|
+
TurboModule::TurboModule(
|
|
16
|
+
const std::string &name,
|
|
17
|
+
std::shared_ptr<CallInvoker> jsInvoker)
|
|
18
|
+
: name_(name), jsInvoker_(jsInvoker) {}
|
|
19
|
+
|
|
20
|
+
TurboModule::~TurboModule() {}
|
|
21
|
+
|
|
22
|
+
jsi::Value TurboModule::get(
|
|
23
|
+
jsi::Runtime &runtime,
|
|
24
|
+
const jsi::PropNameID &propName) {
|
|
25
|
+
std::string propNameUtf8 = propName.utf8(runtime);
|
|
26
|
+
auto p = methodMap_.find(propNameUtf8);
|
|
27
|
+
if (p == methodMap_.end()) {
|
|
28
|
+
// Method was not found, let JS decide what to do.
|
|
29
|
+
return jsi::Value::undefined();
|
|
30
|
+
}
|
|
31
|
+
MethodMetadata meta = p->second;
|
|
32
|
+
return jsi::Function::createFromHostFunction(
|
|
33
|
+
runtime,
|
|
34
|
+
propName,
|
|
35
|
+
meta.argCount,
|
|
36
|
+
[this, meta](
|
|
37
|
+
facebook::jsi::Runtime &rt,
|
|
38
|
+
const facebook::jsi::Value &thisVal,
|
|
39
|
+
const facebook::jsi::Value *args,
|
|
40
|
+
size_t count) { return meta.invoker(rt, *this, args, count); });
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
} // namespace react
|
|
44
|
+
} // namespace facebook
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <fbjni/fbjni.h>
|
|
4
|
+
#include <jni.h>
|
|
5
|
+
#include <memory>
|
|
6
|
+
#include <string>
|
|
7
|
+
#include "AndroidScheduler.h"
|
|
8
|
+
#include "ErrorHandler.h"
|
|
9
|
+
#include "Logger.h"
|
|
10
|
+
#include "Scheduler.h"
|
|
11
|
+
|
|
12
|
+
namespace reanimated {
|
|
13
|
+
|
|
14
|
+
class AndroidErrorHandler : public JavaClass<AndroidErrorHandler>,
|
|
15
|
+
public ErrorHandler {
|
|
16
|
+
std::shared_ptr<ErrorWrapper> error;
|
|
17
|
+
std::shared_ptr<Scheduler> scheduler;
|
|
18
|
+
void raiseSpec() override;
|
|
19
|
+
|
|
20
|
+
public:
|
|
21
|
+
static auto constexpr kJavaDescriptor =
|
|
22
|
+
"Lcom/swmansion/reanimated/AndroidErrorHandler;";
|
|
23
|
+
explicit AndroidErrorHandler(std::shared_ptr<Scheduler> scheduler);
|
|
24
|
+
std::shared_ptr<Scheduler> getScheduler() override;
|
|
25
|
+
std::shared_ptr<ErrorWrapper> getError() override;
|
|
26
|
+
void setError(std::string message) override;
|
|
27
|
+
virtual ~AndroidErrorHandler() {}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
} // namespace reanimated
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include "LoggerInterface.h"
|
|
4
|
+
|
|
5
|
+
namespace reanimated {
|
|
6
|
+
|
|
7
|
+
class AndroidLogger : public LoggerInterface {
|
|
8
|
+
public:
|
|
9
|
+
void log(const char *str) override;
|
|
10
|
+
void log(double d) override;
|
|
11
|
+
void log(int i) override;
|
|
12
|
+
void log(bool b) override;
|
|
13
|
+
virtual ~AndroidLogger() {}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
} // namespace reanimated
|