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,217 @@
|
|
|
1
|
+
#import <RNReanimated/ReanimatedSensor.h>
|
|
2
|
+
|
|
3
|
+
#if __has_include(<CoreMotion/CoreMotion.h>)
|
|
4
|
+
@implementation ReanimatedSensor
|
|
5
|
+
|
|
6
|
+
- (instancetype)init:(ReanimatedSensorType)sensorType interval:(int)interval setter:(void (^)(double[]))setter
|
|
7
|
+
{
|
|
8
|
+
self = [super init];
|
|
9
|
+
_sensorType = sensorType;
|
|
10
|
+
_interval = interval / 1000; // in seconds
|
|
11
|
+
_setter = setter;
|
|
12
|
+
_motionManager = [[CMMotionManager alloc] init];
|
|
13
|
+
return self;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
- (bool)initialize
|
|
17
|
+
{
|
|
18
|
+
if (_sensorType == ACCELEROMETER) {
|
|
19
|
+
return [self initializeAccelerometer];
|
|
20
|
+
} else if (_sensorType == GYROSCOPE) {
|
|
21
|
+
return [self initializeGyroscope];
|
|
22
|
+
} else if (_sensorType == GRAVITY) {
|
|
23
|
+
return [self initializeGravity];
|
|
24
|
+
} else if (_sensorType == MAGNETIC_FIELD) {
|
|
25
|
+
return [self initializeMagnetometer];
|
|
26
|
+
} else if (_sensorType == ROTATION_VECTOR) {
|
|
27
|
+
return [self initializeOrientation];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
- (bool)initializeGyroscope
|
|
34
|
+
{
|
|
35
|
+
if (![_motionManager isGyroAvailable]) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
[_motionManager setGyroUpdateInterval:_interval];
|
|
39
|
+
[_motionManager startGyroUpdates];
|
|
40
|
+
[_motionManager
|
|
41
|
+
startGyroUpdatesToQueue:[NSOperationQueue mainQueue]
|
|
42
|
+
withHandler:^(CMGyroData *sensorData, NSError *error) {
|
|
43
|
+
double currentTime = [[NSProcessInfo processInfo] systemUptime];
|
|
44
|
+
if (currentTime - self->_lastTimestamp < self->_interval) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
double data[] = {sensorData.rotationRate.x, sensorData.rotationRate.y, sensorData.rotationRate.z};
|
|
48
|
+
self->_setter(data);
|
|
49
|
+
self->_lastTimestamp = currentTime;
|
|
50
|
+
}];
|
|
51
|
+
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
- (bool)initializeAccelerometer
|
|
56
|
+
{
|
|
57
|
+
if (![_motionManager isAccelerometerAvailable]) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
[_motionManager setAccelerometerUpdateInterval:_interval];
|
|
61
|
+
[_motionManager startAccelerometerUpdates];
|
|
62
|
+
[_motionManager
|
|
63
|
+
startAccelerometerUpdatesToQueue:[NSOperationQueue mainQueue]
|
|
64
|
+
withHandler:^(CMAccelerometerData *sensorData, NSError *error) {
|
|
65
|
+
double currentTime = [[NSProcessInfo processInfo] systemUptime];
|
|
66
|
+
if (currentTime - self->_lastTimestamp < self->_interval) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
double data[] = {
|
|
70
|
+
sensorData.acceleration.x, sensorData.acceleration.y, sensorData.acceleration.z};
|
|
71
|
+
self->_setter(data);
|
|
72
|
+
self->_lastTimestamp = currentTime;
|
|
73
|
+
}];
|
|
74
|
+
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
- (bool)initializeGravity
|
|
79
|
+
{
|
|
80
|
+
if (![_motionManager isDeviceMotionAvailable]) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
[_motionManager setDeviceMotionUpdateInterval:_interval];
|
|
84
|
+
[_motionManager setShowsDeviceMovementDisplay:YES];
|
|
85
|
+
[_motionManager
|
|
86
|
+
startDeviceMotionUpdatesToQueue:[NSOperationQueue mainQueue]
|
|
87
|
+
withHandler:^(CMDeviceMotion *sensorData, NSError *error) {
|
|
88
|
+
double currentTime = [[NSProcessInfo processInfo] systemUptime];
|
|
89
|
+
if (currentTime - self->_lastTimestamp < self->_interval) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
double data[] = {sensorData.gravity.x, sensorData.gravity.y, sensorData.gravity.z};
|
|
93
|
+
self->_setter(data);
|
|
94
|
+
self->_lastTimestamp = currentTime;
|
|
95
|
+
}];
|
|
96
|
+
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
- (bool)initializeMagnetometer
|
|
101
|
+
{
|
|
102
|
+
if (![_motionManager isMagnetometerAvailable]) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
[_motionManager setMagnetometerUpdateInterval:_interval];
|
|
106
|
+
[_motionManager startMagnetometerUpdates];
|
|
107
|
+
[_motionManager
|
|
108
|
+
startMagnetometerUpdatesToQueue:[NSOperationQueue mainQueue]
|
|
109
|
+
withHandler:^(CMMagnetometerData *sensorData, NSError *error) {
|
|
110
|
+
double currentTime = [[NSProcessInfo processInfo] systemUptime];
|
|
111
|
+
if (currentTime - self->_lastTimestamp < self->_interval) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
double data[] = {
|
|
115
|
+
sensorData.magneticField.x, sensorData.magneticField.y, sensorData.magneticField.z};
|
|
116
|
+
self->_setter(data);
|
|
117
|
+
self->_lastTimestamp = currentTime;
|
|
118
|
+
}];
|
|
119
|
+
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
- (bool)initializeOrientation
|
|
124
|
+
{
|
|
125
|
+
if (![_motionManager isDeviceMotionAvailable]) {
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
[_motionManager setDeviceMotionUpdateInterval:_interval];
|
|
129
|
+
|
|
130
|
+
[_motionManager setShowsDeviceMovementDisplay:YES];
|
|
131
|
+
[_motionManager startDeviceMotionUpdatesUsingReferenceFrame:CMAttitudeReferenceFrameXTrueNorthZVertical
|
|
132
|
+
toQueue:[NSOperationQueue mainQueue]
|
|
133
|
+
withHandler:^(CMDeviceMotion *sensorData, NSError *error) {
|
|
134
|
+
double currentTime = [[NSProcessInfo processInfo] systemUptime];
|
|
135
|
+
if (currentTime - self->_lastTimestamp < self->_interval) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
CMAttitude *attitude = sensorData.attitude;
|
|
139
|
+
double data[] = {
|
|
140
|
+
attitude.quaternion.x,
|
|
141
|
+
attitude.quaternion.y,
|
|
142
|
+
attitude.quaternion.z,
|
|
143
|
+
attitude.quaternion.w,
|
|
144
|
+
attitude.pitch,
|
|
145
|
+
attitude.roll,
|
|
146
|
+
attitude.yaw,
|
|
147
|
+
};
|
|
148
|
+
self->_setter(data);
|
|
149
|
+
self->_lastTimestamp = currentTime;
|
|
150
|
+
}];
|
|
151
|
+
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
- (void)cancel
|
|
156
|
+
{
|
|
157
|
+
if (_sensorType == ACCELEROMETER) {
|
|
158
|
+
[_motionManager stopAccelerometerUpdates];
|
|
159
|
+
} else if (_sensorType == GYROSCOPE) {
|
|
160
|
+
[_motionManager stopGyroUpdates];
|
|
161
|
+
} else if (_sensorType == GRAVITY) {
|
|
162
|
+
[_motionManager stopDeviceMotionUpdates];
|
|
163
|
+
} else if (_sensorType == MAGNETIC_FIELD) {
|
|
164
|
+
[_motionManager stopMagnetometerUpdates];
|
|
165
|
+
} else if (_sensorType == ROTATION_VECTOR) {
|
|
166
|
+
[_motionManager stopDeviceMotionUpdates];
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
@end
|
|
171
|
+
|
|
172
|
+
#else
|
|
173
|
+
|
|
174
|
+
@implementation ReanimatedSensor
|
|
175
|
+
|
|
176
|
+
- (instancetype)init:(ReanimatedSensorType)sensorType interval:(int)interval setter:(void (^)(double[]))setter
|
|
177
|
+
{
|
|
178
|
+
self = [super init];
|
|
179
|
+
return self;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
- (bool)initialize
|
|
183
|
+
{
|
|
184
|
+
return false;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
- (bool)initializeGyroscope
|
|
188
|
+
{
|
|
189
|
+
return false;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
- (bool)initializeAccelerometer
|
|
193
|
+
{
|
|
194
|
+
return false;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
- (bool)initializeGravity
|
|
198
|
+
{
|
|
199
|
+
return false;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
- (bool)initializeMagnetometer
|
|
203
|
+
{
|
|
204
|
+
return false;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
- (bool)initializeOrientation
|
|
208
|
+
{
|
|
209
|
+
return false;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
- (void)cancel
|
|
213
|
+
{
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
@end
|
|
217
|
+
#endif
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#import <RNReanimated/ReanimatedSensorType.h>
|
|
2
|
+
|
|
3
|
+
@interface ReanimatedSensorContainer : NSObject {
|
|
4
|
+
NSNumber *_nextSensorId;
|
|
5
|
+
NSMutableDictionary *_sensors;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
- (instancetype)init;
|
|
9
|
+
- (int)registerSensor:(ReanimatedSensorType)sensorType interval:(int)interval setter:(void (^)(double[]))setter;
|
|
10
|
+
- (void)unregisterSensor:(int)sensorId;
|
|
11
|
+
|
|
12
|
+
@end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#import <Foundation/Foundation.h>
|
|
2
|
+
#import <RNReanimated/ReanimatedSensor.h>
|
|
3
|
+
#import <RNReanimated/ReanimatedSensorContainer.h>
|
|
4
|
+
|
|
5
|
+
static NSNumber *_nextSensorId = nil;
|
|
6
|
+
|
|
7
|
+
@implementation ReanimatedSensorContainer
|
|
8
|
+
|
|
9
|
+
- (instancetype)init
|
|
10
|
+
{
|
|
11
|
+
self = [super init];
|
|
12
|
+
_sensors = [[NSMutableDictionary alloc] init];
|
|
13
|
+
_nextSensorId = @0;
|
|
14
|
+
return self;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
- (int)registerSensor:(ReanimatedSensorType)sensorType interval:(int)interval setter:(void (^)(double[]))setter
|
|
18
|
+
{
|
|
19
|
+
ReanimatedSensor *sensor = [[ReanimatedSensor alloc] init:sensorType interval:interval setter:setter];
|
|
20
|
+
if ([sensor initialize]) {
|
|
21
|
+
NSNumber *sensorId = [_nextSensorId copy];
|
|
22
|
+
_nextSensorId = [NSNumber numberWithInt:[_nextSensorId intValue] + 1];
|
|
23
|
+
[_sensors setObject:sensor forKey:sensorId];
|
|
24
|
+
return [sensorId intValue];
|
|
25
|
+
} else {
|
|
26
|
+
return -1;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
- (void)unregisterSensor:(int)sensorId
|
|
31
|
+
{
|
|
32
|
+
NSNumber *_sensorId = [NSNumber numberWithInt:sensorId];
|
|
33
|
+
if (_sensors[_sensorId] == nil) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
[_sensors[_sensorId] cancel];
|
|
37
|
+
[_sensors removeObjectForKey:_sensorId];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@end
|
package/lib/ConfigHelper.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { configureProps as jsiConfigureProps } from './reanimated2/core';
|
|
2
2
|
/**
|
|
3
3
|
* Styles allowed to be direcly updated in UI thread
|
|
4
4
|
*/
|
|
@@ -76,7 +76,6 @@ let NATIVE_THREAD_PROPS_WHITELIST = {
|
|
|
76
76
|
borderTopLeftRadius: true,
|
|
77
77
|
borderTopRightRadius: true,
|
|
78
78
|
borderTopStartRadius: true,
|
|
79
|
-
opacity: true,
|
|
80
79
|
elevation: true,
|
|
81
80
|
fontSize: true,
|
|
82
81
|
lineHeight: true,
|
|
@@ -104,7 +103,7 @@ let NATIVE_THREAD_PROPS_WHITELIST = {
|
|
|
104
103
|
placeholderTextColor: true,
|
|
105
104
|
};
|
|
106
105
|
function configureProps() {
|
|
107
|
-
|
|
106
|
+
jsiConfigureProps(Object.keys(UI_THREAD_PROPS_WHITELIST), Object.keys(NATIVE_THREAD_PROPS_WHITELIST));
|
|
108
107
|
}
|
|
109
108
|
export function addWhitelistedNativeProps(props) {
|
|
110
109
|
const oldSize = Object.keys(NATIVE_THREAD_PROPS_WHITELIST).length;
|
|
@@ -90,6 +90,7 @@ export default function createAnimatedComponent(Component, options) {
|
|
|
90
90
|
this._viewTag = -1;
|
|
91
91
|
this._isFirstRender = true;
|
|
92
92
|
this.animatedStyle = { value: {} };
|
|
93
|
+
this.initialStyle = {};
|
|
93
94
|
this._component = null;
|
|
94
95
|
// The system is best designed when setNativeProps is implemented. It is
|
|
95
96
|
// able to avoid re-rendering and directly set the attributes that changed.
|
|
@@ -438,11 +439,9 @@ export default function createAnimatedComponent(Component, options) {
|
|
|
438
439
|
// this is how we recognize styles returned by useAnimatedStyle
|
|
439
440
|
style.viewsRef.add(this);
|
|
440
441
|
if (this._isFirstRender) {
|
|
441
|
-
|
|
442
|
-
}
|
|
443
|
-
else {
|
|
444
|
-
return style.initial.value;
|
|
442
|
+
this.initialStyle = Object.assign(Object.assign({}, style.initial.value), initialUpdaterRun(style.initial.updater));
|
|
445
443
|
}
|
|
444
|
+
return this.initialStyle;
|
|
446
445
|
}
|
|
447
446
|
else {
|
|
448
447
|
return style;
|
|
@@ -37,7 +37,7 @@ export function createAnimatedFunction(cb) {
|
|
|
37
37
|
for (let i = 0; i < params.length; i++) {
|
|
38
38
|
params[i] = createAnimatedParam();
|
|
39
39
|
}
|
|
40
|
-
// eslint-disable-next-line
|
|
40
|
+
// eslint-disable-next-line node/no-callback-literal
|
|
41
41
|
const what = cb(...params);
|
|
42
42
|
const func = new AnimatedFunction(what, ...params);
|
|
43
43
|
return (...args) => {
|
|
@@ -128,15 +128,13 @@ export default function interpolate(value, config) {
|
|
|
128
128
|
const right = extrapolateRight || extrapolate;
|
|
129
129
|
let output = interpolateInternal(value, inputRange, outputRange);
|
|
130
130
|
|
|
131
|
-
if (left === Extrapolate.
|
|
132
|
-
} else if (left === Extrapolate.CLAMP) {
|
|
131
|
+
if (left === Extrapolate.CLAMP) {
|
|
133
132
|
output = cond(lessThan(value, inputRange[0]), outputRange[0], output);
|
|
134
133
|
} else if (left === Extrapolate.IDENTITY) {
|
|
135
134
|
output = cond(lessThan(value, inputRange[0]), value, output);
|
|
136
135
|
}
|
|
137
136
|
|
|
138
|
-
if (right === Extrapolate.
|
|
139
|
-
} else if (right === Extrapolate.CLAMP) {
|
|
137
|
+
if (right === Extrapolate.CLAMP) {
|
|
140
138
|
output = cond(
|
|
141
139
|
greaterThan(value, inputRange[inputRange.length - 1]),
|
|
142
140
|
outputRange[outputRange.length - 1],
|
|
@@ -31,7 +31,8 @@ function getMatchers() {
|
|
|
31
31
|
cachedMatchers.hsl = new RegExp('hsl' + call(NUMBER, PERCENTAGE, PERCENTAGE));
|
|
32
32
|
cachedMatchers.hsla = new RegExp('hsla' + call(NUMBER, PERCENTAGE, PERCENTAGE, NUMBER));
|
|
33
33
|
cachedMatchers.hex3 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
|
|
34
|
-
cachedMatchers.hex4 =
|
|
34
|
+
cachedMatchers.hex4 =
|
|
35
|
+
/^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
|
|
35
36
|
cachedMatchers.hex6 = /^#([0-9a-fA-F]{6})$/;
|
|
36
37
|
cachedMatchers.hex8 = /^#([0-9a-fA-F]{8})$/;
|
|
37
38
|
}
|
|
@@ -53,7 +53,10 @@ function cubic(t) {
|
|
|
53
53
|
*/
|
|
54
54
|
function poly(n) {
|
|
55
55
|
'worklet';
|
|
56
|
-
return (t) =>
|
|
56
|
+
return (t) => {
|
|
57
|
+
'worklet';
|
|
58
|
+
return Math.pow(t, n);
|
|
59
|
+
};
|
|
57
60
|
}
|
|
58
61
|
/**
|
|
59
62
|
* A sinusoidal function.
|
|
@@ -110,7 +113,10 @@ function elastic(bounciness = 1) {
|
|
|
110
113
|
*/
|
|
111
114
|
function back(s = 1.70158) {
|
|
112
115
|
'worklet';
|
|
113
|
-
return (t) =>
|
|
116
|
+
return (t) => {
|
|
117
|
+
'worklet';
|
|
118
|
+
return t * t * ((s + 1) * t - s);
|
|
119
|
+
};
|
|
114
120
|
}
|
|
115
121
|
/**
|
|
116
122
|
* Provides a simple bouncing effect.
|
|
@@ -224,7 +230,7 @@ function createChecker(worklet, workletName, prevArgs) {
|
|
|
224
230
|
}
|
|
225
231
|
// @ts-ignore this is implicitly any - TODO
|
|
226
232
|
const res = worklet.apply(this, arguments);
|
|
227
|
-
if (!_WORKLET && res && typeof res === 'function' && res.
|
|
233
|
+
if (!_WORKLET && res && typeof res === 'function' && res.__workletHash) {
|
|
228
234
|
return createChecker(res, workletName, arguments);
|
|
229
235
|
}
|
|
230
236
|
return res;
|
|
@@ -1,37 +1,50 @@
|
|
|
1
|
-
|
|
1
|
+
import { NativeModules } from 'react-native';
|
|
2
2
|
export class NativeReanimated {
|
|
3
3
|
constructor(native = true) {
|
|
4
|
+
if (global.__reanimatedModuleProxy === undefined) {
|
|
5
|
+
const { ReanimatedModule } = NativeModules;
|
|
6
|
+
ReanimatedModule === null || ReanimatedModule === void 0 ? void 0 : ReanimatedModule.installTurboModule();
|
|
7
|
+
}
|
|
8
|
+
this.InnerNativeModule = global.__reanimatedModuleProxy;
|
|
4
9
|
this.native = native;
|
|
5
|
-
this.useOnlyV1 = InnerNativeModule === null;
|
|
6
10
|
}
|
|
7
11
|
installCoreFunctions(valueSetter) {
|
|
8
|
-
return InnerNativeModule.installCoreFunctions(valueSetter);
|
|
12
|
+
return this.InnerNativeModule.installCoreFunctions(valueSetter);
|
|
9
13
|
}
|
|
10
14
|
makeShareable(value) {
|
|
11
|
-
return InnerNativeModule.makeShareable(value);
|
|
15
|
+
return this.InnerNativeModule.makeShareable(value);
|
|
12
16
|
}
|
|
13
17
|
makeMutable(value) {
|
|
14
|
-
return InnerNativeModule.makeMutable(value);
|
|
18
|
+
return this.InnerNativeModule.makeMutable(value);
|
|
15
19
|
}
|
|
16
20
|
makeRemote(object = {}) {
|
|
17
|
-
return InnerNativeModule.makeRemote(object);
|
|
21
|
+
return this.InnerNativeModule.makeRemote(object);
|
|
22
|
+
}
|
|
23
|
+
registerSensor(sensorType, interval, sensorData) {
|
|
24
|
+
return this.InnerNativeModule.registerSensor(sensorType, interval, sensorData);
|
|
25
|
+
}
|
|
26
|
+
unregisterSensor(sensorId) {
|
|
27
|
+
return this.InnerNativeModule.unregisterSensor(sensorId);
|
|
18
28
|
}
|
|
19
29
|
startMapper(mapper, inputs = [], outputs = [], updater, viewDescriptors) {
|
|
20
|
-
return InnerNativeModule.startMapper(mapper, inputs, outputs, updater, viewDescriptors);
|
|
30
|
+
return this.InnerNativeModule.startMapper(mapper, inputs, outputs, updater, viewDescriptors);
|
|
21
31
|
}
|
|
22
32
|
stopMapper(mapperId) {
|
|
23
|
-
return InnerNativeModule.stopMapper(mapperId);
|
|
33
|
+
return this.InnerNativeModule.stopMapper(mapperId);
|
|
24
34
|
}
|
|
25
35
|
registerEventHandler(eventHash, eventHandler) {
|
|
26
|
-
return InnerNativeModule.registerEventHandler(eventHash, eventHandler);
|
|
36
|
+
return this.InnerNativeModule.registerEventHandler(eventHash, eventHandler);
|
|
27
37
|
}
|
|
28
38
|
unregisterEventHandler(id) {
|
|
29
|
-
return InnerNativeModule.unregisterEventHandler(id);
|
|
39
|
+
return this.InnerNativeModule.unregisterEventHandler(id);
|
|
30
40
|
}
|
|
31
41
|
getViewProp(viewTag, propName, callback) {
|
|
32
|
-
return InnerNativeModule.getViewProp(viewTag, propName, callback);
|
|
42
|
+
return this.InnerNativeModule.getViewProp(viewTag, propName, callback);
|
|
33
43
|
}
|
|
34
44
|
enableLayoutAnimations(flag) {
|
|
35
|
-
InnerNativeModule.enableLayoutAnimations(flag);
|
|
45
|
+
this.InnerNativeModule.enableLayoutAnimations(flag);
|
|
46
|
+
}
|
|
47
|
+
configureProps(uiProps, nativeProps) {
|
|
48
|
+
this.InnerNativeModule.configureProps(uiProps, nativeProps);
|
|
36
49
|
}
|
|
37
50
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import reanimatedJS from '../js-reanimated';
|
|
2
2
|
import { shouldBeUseWeb } from '../PlatformChecker';
|
|
3
|
-
import { Platform } from 'react-native';
|
|
4
3
|
import { NativeReanimated } from './NativeReanimated';
|
|
5
4
|
let exportedModule;
|
|
6
5
|
if (shouldBeUseWeb()) {
|
|
@@ -8,8 +7,5 @@ if (shouldBeUseWeb()) {
|
|
|
8
7
|
}
|
|
9
8
|
else {
|
|
10
9
|
exportedModule = new NativeReanimated();
|
|
11
|
-
if (exportedModule.useOnlyV1 && Platform.OS === 'android') {
|
|
12
|
-
console.warn(`If you want to use Reanimated 2 then go through our installation steps https://docs.swmansion.com/react-native-reanimated/docs/installation`);
|
|
13
|
-
}
|
|
14
10
|
}
|
|
15
11
|
export default exportedModule;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useRef } from 'react';
|
|
2
2
|
import { makeMutable } from './core';
|
|
3
|
-
import {
|
|
4
|
-
const scheduleUpdates =
|
|
3
|
+
import { shouldBeUseWeb } from './PlatformChecker';
|
|
4
|
+
const scheduleUpdates = shouldBeUseWeb() ? requestAnimationFrame : setImmediate;
|
|
5
5
|
export function makeViewDescriptorsSet() {
|
|
6
6
|
const ref = useRef(null);
|
|
7
7
|
if (ref.current === null) {
|
package/lib/reanimated2/core.js
CHANGED
|
@@ -2,9 +2,6 @@
|
|
|
2
2
|
import NativeReanimatedModule from './NativeReanimated';
|
|
3
3
|
import { Platform } from 'react-native';
|
|
4
4
|
import { nativeShouldBeMock, shouldBeUseWeb, isWeb } from './PlatformChecker';
|
|
5
|
-
global.__reanimatedWorkletInit = function (worklet) {
|
|
6
|
-
worklet.__worklet = true;
|
|
7
|
-
};
|
|
8
5
|
if (global._setGlobalConsole === undefined) {
|
|
9
6
|
// it can happen when Reanimated plugin wasn't added, but the user uses the only API from version 1
|
|
10
7
|
global._setGlobalConsole = () => {
|
|
@@ -24,46 +21,13 @@ export const checkPluginState = (throwError = true) => {
|
|
|
24
21
|
return true;
|
|
25
22
|
};
|
|
26
23
|
export const isConfigured = (throwError = false) => {
|
|
27
|
-
return checkPluginState(throwError)
|
|
24
|
+
return checkPluginState(throwError);
|
|
28
25
|
};
|
|
29
26
|
export const isConfiguredCheck = () => {
|
|
30
27
|
if (!isConfigured(true)) {
|
|
31
28
|
throw new Error('If you want to use Reanimated 2 then go through our installation steps https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation');
|
|
32
29
|
}
|
|
33
30
|
};
|
|
34
|
-
function _toArrayReanimated(object) {
|
|
35
|
-
'worklet';
|
|
36
|
-
if (Array.isArray(object)) {
|
|
37
|
-
return object;
|
|
38
|
-
}
|
|
39
|
-
if (typeof Symbol !== 'undefined' &&
|
|
40
|
-
(typeof Symbol === 'function' ? Symbol.iterator : '@@iterator') in
|
|
41
|
-
Object(object)) {
|
|
42
|
-
return Array.from(object);
|
|
43
|
-
}
|
|
44
|
-
throw new Error('Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.');
|
|
45
|
-
}
|
|
46
|
-
function _mergeObjectsReanimated() {
|
|
47
|
-
'worklet';
|
|
48
|
-
// we can't use rest parameters in worklets at the moment
|
|
49
|
-
// eslint-disable-next-line prefer-rest-params
|
|
50
|
-
const arr = Array.from(arguments);
|
|
51
|
-
return Object.assign.apply(null, [arr[0], ...arr.slice(1)]);
|
|
52
|
-
}
|
|
53
|
-
global.__reanimatedWorkletInit = function (worklet) {
|
|
54
|
-
worklet.__worklet = true;
|
|
55
|
-
if (worklet._closure) {
|
|
56
|
-
const closure = worklet._closure;
|
|
57
|
-
Object.keys(closure).forEach((key) => {
|
|
58
|
-
if (key === '_toConsumableArray') {
|
|
59
|
-
closure[key] = _toArrayReanimated;
|
|
60
|
-
}
|
|
61
|
-
if (key === '_objectSpread') {
|
|
62
|
-
closure[key] = _mergeObjectsReanimated;
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
31
|
function pushFrame(frame) {
|
|
68
32
|
NativeReanimatedModule.pushFrame(frame);
|
|
69
33
|
}
|
|
@@ -259,29 +223,27 @@ export function runOnJS(fun) {
|
|
|
259
223
|
return fun.__callAsync;
|
|
260
224
|
}
|
|
261
225
|
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
global.
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
})();
|
|
284
|
-
}
|
|
226
|
+
NativeReanimatedModule.installCoreFunctions(NativeReanimatedModule.native
|
|
227
|
+
? workletValueSetter
|
|
228
|
+
: workletValueSetterJS);
|
|
229
|
+
if (!isWeb() && isConfigured()) {
|
|
230
|
+
const capturableConsole = console;
|
|
231
|
+
runOnUI(() => {
|
|
232
|
+
'worklet';
|
|
233
|
+
const console = {
|
|
234
|
+
debug: runOnJS(capturableConsole.debug),
|
|
235
|
+
log: runOnJS(capturableConsole.log),
|
|
236
|
+
warn: runOnJS(capturableConsole.warn),
|
|
237
|
+
error: runOnJS(capturableConsole.error),
|
|
238
|
+
info: runOnJS(capturableConsole.info),
|
|
239
|
+
};
|
|
240
|
+
_setGlobalConsole(console);
|
|
241
|
+
if (global.performance == null) {
|
|
242
|
+
global.performance = {
|
|
243
|
+
now: global._chronoNow,
|
|
244
|
+
}; // due to conflict with lib.dom.d.ts -> Performance
|
|
245
|
+
}
|
|
246
|
+
})();
|
|
285
247
|
}
|
|
286
248
|
let featuresConfig = {
|
|
287
249
|
enableLayoutAnimations: false,
|
|
@@ -301,3 +263,11 @@ export function enableLayoutAnimations(flag, isCallByUser = true) {
|
|
|
301
263
|
NativeReanimatedModule.enableLayoutAnimations(flag);
|
|
302
264
|
}
|
|
303
265
|
}
|
|
266
|
+
export function configureProps(uiProps, nativeProps) {
|
|
267
|
+
if (!nativeShouldBeMock()) {
|
|
268
|
+
NativeReanimatedModule.configureProps(uiProps, nativeProps);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
export function jestResetJsReanimatedModule() {
|
|
272
|
+
NativeReanimatedModule.jestResetModule();
|
|
273
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnimatedStyle, StyleProps
|
|
1
|
+
import { AnimatedStyle, StyleProps } from './commonTypes';
|
|
2
2
|
import { ReanimatedConsole } from './core';
|
|
3
3
|
import { MeasuredDimensions } from './NativeMethods';
|
|
4
4
|
import { NativeReanimated } from './NativeReanimated/NativeReanimated';
|
|
@@ -27,9 +27,11 @@ declare global {
|
|
|
27
27
|
animated: boolean
|
|
28
28
|
) => void;
|
|
29
29
|
const _chronoNow: () => number;
|
|
30
|
+
const ReanimatedDataMock: {
|
|
31
|
+
now: () => number;
|
|
32
|
+
};
|
|
30
33
|
namespace NodeJS {
|
|
31
34
|
interface Global {
|
|
32
|
-
__reanimatedWorkletInit: (worklet: WorkletFunction) => void;
|
|
33
35
|
_setGlobalConsole: (console?: ReanimatedConsole) => void;
|
|
34
36
|
_log: (s: string) => void;
|
|
35
37
|
_setGestureState: () => void;
|
|
@@ -50,6 +52,9 @@ declare global {
|
|
|
50
52
|
yogaValues: unknown
|
|
51
53
|
): void;
|
|
52
54
|
};
|
|
55
|
+
ReanimatedDataMock: {
|
|
56
|
+
now: () => number;
|
|
57
|
+
};
|
|
53
58
|
}
|
|
54
59
|
}
|
|
55
60
|
}
|
|
@@ -6,3 +6,4 @@ export { useAnimatedReaction, } from './useAnimatedReaction';
|
|
|
6
6
|
export { useAnimatedRef } from './useAnimatedRef';
|
|
7
7
|
export { useAnimatedScrollHandler, } from './useAnimatedScrollHandler';
|
|
8
8
|
export { useDerivedValue } from './useDerivedValue';
|
|
9
|
+
export { useAnimatedSensor, SensorType } from './useAnimatedSensor';
|