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
|
@@ -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
|
|
|
6
5
|
let exportedModule;
|
|
@@ -8,11 +7,6 @@ if (shouldBeUseWeb()) {
|
|
|
8
7
|
exportedModule = reanimatedJS;
|
|
9
8
|
} else {
|
|
10
9
|
exportedModule = new NativeReanimated();
|
|
11
|
-
if (exportedModule.useOnlyV1 && Platform.OS === 'android') {
|
|
12
|
-
console.warn(
|
|
13
|
-
`If you want to use Reanimated 2 then go through our installation steps https://docs.swmansion.com/react-native-reanimated/docs/installation`
|
|
14
|
-
);
|
|
15
|
-
}
|
|
16
10
|
}
|
|
17
11
|
|
|
18
12
|
export default exportedModule as NativeReanimated;
|
|
@@ -2,7 +2,7 @@ import { useRef } from 'react';
|
|
|
2
2
|
import { makeMutable } from './core';
|
|
3
3
|
import { SharedValue } from './commonTypes';
|
|
4
4
|
import { Descriptor } from './hook/commonTypes';
|
|
5
|
-
import {
|
|
5
|
+
import { shouldBeUseWeb } from './PlatformChecker';
|
|
6
6
|
|
|
7
7
|
export interface ViewRefSet<T> {
|
|
8
8
|
items: Set<T>;
|
|
@@ -24,8 +24,7 @@ export interface ViewDescriptorsSet {
|
|
|
24
24
|
) => void;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
const scheduleUpdates =
|
|
28
|
-
Platform.OS === 'web' ? requestAnimationFrame : setImmediate;
|
|
27
|
+
const scheduleUpdates = shouldBeUseWeb() ? requestAnimationFrame : setImmediate;
|
|
29
28
|
|
|
30
29
|
export function makeViewDescriptorsSet(): ViewDescriptorsSet {
|
|
31
30
|
const ref = useRef<ViewDescriptorsSet | null>(null);
|
|
@@ -57,9 +57,8 @@ export function setPath<T>(
|
|
|
57
57
|
currObj = currObj[keys[i]];
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
(currObj as { [key: string]: NestedObjectValues<T> })[
|
|
61
|
-
|
|
62
|
-
] = value;
|
|
60
|
+
(currObj as { [key: string]: NestedObjectValues<T> })[keys[keys.length - 1]] =
|
|
61
|
+
value;
|
|
63
62
|
}
|
|
64
63
|
|
|
65
64
|
interface NestedObjectEntry<T> {
|
|
@@ -83,7 +82,8 @@ export function withStyleAnimation(
|
|
|
83
82
|
{ value: animation.styleAnimations, path: [] },
|
|
84
83
|
];
|
|
85
84
|
while (entriesToCheck.length > 0) {
|
|
86
|
-
const currentEntry: NestedObjectEntry<AnimationObject> =
|
|
85
|
+
const currentEntry: NestedObjectEntry<AnimationObject> =
|
|
86
|
+
entriesToCheck.pop() as NestedObjectEntry<AnimationObject>;
|
|
87
87
|
if (Array.isArray(currentEntry.value)) {
|
|
88
88
|
for (let index = 0; index < currentEntry.value.length; index++) {
|
|
89
89
|
entriesToCheck.push({
|
|
@@ -103,7 +103,8 @@ export function withStyleAnimation(
|
|
|
103
103
|
});
|
|
104
104
|
}
|
|
105
105
|
} else {
|
|
106
|
-
const currentStyleAnimation: AnimationObject =
|
|
106
|
+
const currentStyleAnimation: AnimationObject =
|
|
107
|
+
currentEntry.value as AnimationObject;
|
|
107
108
|
if (currentStyleAnimation.finished) {
|
|
108
109
|
continue;
|
|
109
110
|
}
|
|
@@ -211,7 +212,8 @@ export function withStyleAnimation(
|
|
|
211
212
|
styleAnimations,
|
|
212
213
|
];
|
|
213
214
|
while (animationsToCheck.length > 0) {
|
|
214
|
-
const currentAnimation: NestedObjectValues<AnimationObject> =
|
|
215
|
+
const currentAnimation: NestedObjectValues<AnimationObject> =
|
|
216
|
+
animationsToCheck.pop() as NestedObjectValues<AnimationObject>;
|
|
215
217
|
if (Array.isArray(currentAnimation)) {
|
|
216
218
|
for (const element of currentAnimation) {
|
|
217
219
|
animationsToCheck.push(element);
|
|
@@ -224,7 +226,8 @@ export function withStyleAnimation(
|
|
|
224
226
|
animationsToCheck.push(value);
|
|
225
227
|
}
|
|
226
228
|
} else {
|
|
227
|
-
const currentStyleAnimation: AnimationObject =
|
|
229
|
+
const currentStyleAnimation: AnimationObject =
|
|
230
|
+
currentAnimation as AnimationObject;
|
|
228
231
|
if (
|
|
229
232
|
!currentStyleAnimation.finished &&
|
|
230
233
|
currentStyleAnimation.callback
|
|
@@ -80,7 +80,9 @@ export function withTiming(
|
|
|
80
80
|
// new timing over the old one with the same parameters. If so, we want
|
|
81
81
|
// to copy animation timeline properties
|
|
82
82
|
animation.startTime = (previousAnimation as TimingAnimation).startTime;
|
|
83
|
-
animation.startValue = (
|
|
83
|
+
animation.startValue = (
|
|
84
|
+
previousAnimation as TimingAnimation
|
|
85
|
+
).startValue;
|
|
84
86
|
} else {
|
|
85
87
|
animation.startTime = now;
|
|
86
88
|
animation.startValue = value;
|
|
@@ -228,17 +228,16 @@ function decorateAnimation<T extends AnimationObject | StyleLayoutAnimation>(
|
|
|
228
228
|
};
|
|
229
229
|
}
|
|
230
230
|
|
|
231
|
-
type AnimationToDecoration<
|
|
232
|
-
T extends
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
: AnimatableValue | T;
|
|
231
|
+
type AnimationToDecoration<T extends AnimationObject | StyleLayoutAnimation> =
|
|
232
|
+
T extends StyleLayoutAnimation
|
|
233
|
+
? Record<string, unknown>
|
|
234
|
+
: T extends DelayAnimation
|
|
235
|
+
? NextAnimation<DelayAnimation>
|
|
236
|
+
: T extends RepeatAnimation
|
|
237
|
+
? NextAnimation<RepeatAnimation>
|
|
238
|
+
: T extends SequenceAnimation
|
|
239
|
+
? NextAnimation<SequenceAnimation>
|
|
240
|
+
: AnimatableValue | T;
|
|
242
241
|
|
|
243
242
|
export function defineAnimation<
|
|
244
243
|
T extends AnimationObject | StyleLayoutAnimation
|
|
@@ -51,7 +51,6 @@ export interface WorkletFunction {
|
|
|
51
51
|
_closure?: Context;
|
|
52
52
|
__workletHash?: number;
|
|
53
53
|
__optimalization?: number;
|
|
54
|
-
__worklet?: boolean;
|
|
55
54
|
}
|
|
56
55
|
|
|
57
56
|
export interface BasicWorkletFunction<T> extends WorkletFunction {
|
|
@@ -126,3 +125,23 @@ export type AnimationCallback = (
|
|
|
126
125
|
) => void;
|
|
127
126
|
|
|
128
127
|
export type Timestamp = number;
|
|
128
|
+
|
|
129
|
+
export type Value3D = {
|
|
130
|
+
x: number;
|
|
131
|
+
y: number;
|
|
132
|
+
z: number;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
export type SensorValue3D = SharedValue<Value3D>;
|
|
136
|
+
|
|
137
|
+
export type ValueRotation = {
|
|
138
|
+
qw: number;
|
|
139
|
+
qx: number;
|
|
140
|
+
qy: number;
|
|
141
|
+
qz: number;
|
|
142
|
+
yaw: number;
|
|
143
|
+
pitch: number;
|
|
144
|
+
roll: number;
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
export type SensorValueRotation = SharedValue<ValueRotation>;
|
|
@@ -13,7 +13,8 @@ const createCellRenderer = (itemLayoutAnimation?: ILayoutAnimationBuilder) => {
|
|
|
13
13
|
return (
|
|
14
14
|
<WrappedComponents.View
|
|
15
15
|
layout={itemLayoutAnimation}
|
|
16
|
-
onLayout={props.onLayout}
|
|
16
|
+
onLayout={props.onLayout}
|
|
17
|
+
>
|
|
17
18
|
{props.children}
|
|
18
19
|
</WrappedComponents.View>
|
|
19
20
|
);
|
|
@@ -22,7 +23,7 @@ const createCellRenderer = (itemLayoutAnimation?: ILayoutAnimationBuilder) => {
|
|
|
22
23
|
return cellRenderer;
|
|
23
24
|
};
|
|
24
25
|
|
|
25
|
-
interface ReanimatedFlatlistProps<ItemT> extends FlatListProps<ItemT> {
|
|
26
|
+
export interface ReanimatedFlatlistProps<ItemT> extends FlatListProps<ItemT> {
|
|
26
27
|
itemLayoutAnimation?: ILayoutAnimationBuilder;
|
|
27
28
|
}
|
|
28
29
|
|
package/src/reanimated2/core.ts
CHANGED
|
@@ -4,7 +4,6 @@ import { Platform } from 'react-native';
|
|
|
4
4
|
import { nativeShouldBeMock, shouldBeUseWeb, isWeb } from './PlatformChecker';
|
|
5
5
|
import {
|
|
6
6
|
BasicWorkletFunction,
|
|
7
|
-
WorkletFunction,
|
|
8
7
|
ComplexWorkletFunction,
|
|
9
8
|
SharedValue,
|
|
10
9
|
AnimationObject,
|
|
@@ -14,10 +13,6 @@ import {
|
|
|
14
13
|
import { Descriptor } from './hook/commonTypes';
|
|
15
14
|
import JSReanimated from './js-reanimated/JSReanimated';
|
|
16
15
|
|
|
17
|
-
global.__reanimatedWorkletInit = function (worklet: WorkletFunction) {
|
|
18
|
-
worklet.__worklet = true;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
16
|
if (global._setGlobalConsole === undefined) {
|
|
22
17
|
// it can happen when Reanimated plugin wasn't added, but the user uses the only API from version 1
|
|
23
18
|
global._setGlobalConsole = () => {
|
|
@@ -63,7 +58,7 @@ export const checkPluginState: (throwError: boolean) => boolean = (
|
|
|
63
58
|
export const isConfigured: (throwError?: boolean) => boolean = (
|
|
64
59
|
throwError = false
|
|
65
60
|
) => {
|
|
66
|
-
return checkPluginState(throwError)
|
|
61
|
+
return checkPluginState(throwError);
|
|
67
62
|
};
|
|
68
63
|
|
|
69
64
|
export const isConfiguredCheck: () => void = () => {
|
|
@@ -74,48 +69,6 @@ export const isConfiguredCheck: () => void = () => {
|
|
|
74
69
|
}
|
|
75
70
|
};
|
|
76
71
|
|
|
77
|
-
function _toArrayReanimated<T>(object: Iterable<T> | ArrayLike<T> | T[]): T[] {
|
|
78
|
-
'worklet';
|
|
79
|
-
if (Array.isArray(object)) {
|
|
80
|
-
return object;
|
|
81
|
-
}
|
|
82
|
-
if (
|
|
83
|
-
typeof Symbol !== 'undefined' &&
|
|
84
|
-
(typeof Symbol === 'function' ? Symbol.iterator : '@@iterator') in
|
|
85
|
-
Object(object)
|
|
86
|
-
) {
|
|
87
|
-
return Array.from(object);
|
|
88
|
-
}
|
|
89
|
-
throw new Error(
|
|
90
|
-
'Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.'
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
function _mergeObjectsReanimated(): unknown {
|
|
95
|
-
'worklet';
|
|
96
|
-
// we can't use rest parameters in worklets at the moment
|
|
97
|
-
// eslint-disable-next-line prefer-rest-params
|
|
98
|
-
const arr = Array.from(arguments);
|
|
99
|
-
return Object.assign.apply(null, [arr[0], ...arr.slice(1)]);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
global.__reanimatedWorkletInit = function (worklet: WorkletFunction) {
|
|
103
|
-
worklet.__worklet = true;
|
|
104
|
-
|
|
105
|
-
if (worklet._closure) {
|
|
106
|
-
const closure = worklet._closure;
|
|
107
|
-
Object.keys(closure).forEach((key) => {
|
|
108
|
-
if (key === '_toConsumableArray') {
|
|
109
|
-
closure[key] = _toArrayReanimated;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if (key === '_objectSpread') {
|
|
113
|
-
closure[key] = _mergeObjectsReanimated;
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
|
|
119
72
|
function pushFrame(frame: (timestamp: Timestamp) => void): void {
|
|
120
73
|
(NativeReanimatedModule as JSReanimated).pushFrame(frame);
|
|
121
74
|
}
|
|
@@ -362,32 +315,30 @@ export function runOnJS<A extends any[], R>(
|
|
|
362
315
|
}
|
|
363
316
|
}
|
|
364
317
|
|
|
365
|
-
|
|
366
|
-
NativeReanimatedModule.
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
);
|
|
318
|
+
NativeReanimatedModule.installCoreFunctions(
|
|
319
|
+
NativeReanimatedModule.native
|
|
320
|
+
? (workletValueSetter as <T>(value: T) => void)
|
|
321
|
+
: (workletValueSetterJS as <T>(value: T) => void)
|
|
322
|
+
);
|
|
371
323
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
}
|
|
324
|
+
if (!isWeb() && isConfigured()) {
|
|
325
|
+
const capturableConsole = console;
|
|
326
|
+
runOnUI(() => {
|
|
327
|
+
'worklet';
|
|
328
|
+
const console = {
|
|
329
|
+
debug: runOnJS(capturableConsole.debug),
|
|
330
|
+
log: runOnJS(capturableConsole.log),
|
|
331
|
+
warn: runOnJS(capturableConsole.warn),
|
|
332
|
+
error: runOnJS(capturableConsole.error),
|
|
333
|
+
info: runOnJS(capturableConsole.info),
|
|
334
|
+
};
|
|
335
|
+
_setGlobalConsole(console);
|
|
336
|
+
if (global.performance == null) {
|
|
337
|
+
global.performance = {
|
|
338
|
+
now: global._chronoNow,
|
|
339
|
+
} as any; // due to conflict with lib.dom.d.ts -> Performance
|
|
340
|
+
}
|
|
341
|
+
})();
|
|
391
342
|
}
|
|
392
343
|
|
|
393
344
|
type FeaturesConfig = {
|
|
@@ -418,3 +369,13 @@ export function enableLayoutAnimations(
|
|
|
418
369
|
NativeReanimatedModule.enableLayoutAnimations(flag);
|
|
419
370
|
}
|
|
420
371
|
}
|
|
372
|
+
|
|
373
|
+
export function configureProps(uiProps: string[], nativeProps: string[]): void {
|
|
374
|
+
if (!nativeShouldBeMock()) {
|
|
375
|
+
NativeReanimatedModule.configureProps(uiProps, nativeProps);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
export function jestResetJsReanimatedModule() {
|
|
380
|
+
(NativeReanimatedModule as JSReanimated).jestResetModule();
|
|
381
|
+
}
|
|
@@ -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
|
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
import { makeMutable } from '../core';
|
|
3
|
+
import NativeReanimated from '../NativeReanimated';
|
|
4
|
+
import { SensorValue3D, SensorValueRotation } from '../commonTypes';
|
|
5
|
+
|
|
6
|
+
export enum SensorType {
|
|
7
|
+
ACCELEROMETER = 1,
|
|
8
|
+
GYROSCOPE = 2,
|
|
9
|
+
GRAVITY = 3,
|
|
10
|
+
MAGNETIC_FIELD = 4,
|
|
11
|
+
ROTATION = 5,
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type SensorConfig = {
|
|
15
|
+
interval: number;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type AnimatedSensor = {
|
|
19
|
+
sensor: SensorValue3D | SensorValueRotation | null;
|
|
20
|
+
unregister: () => void;
|
|
21
|
+
isAvailable: boolean;
|
|
22
|
+
config: {
|
|
23
|
+
interval: number;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export function useAnimatedSensor(
|
|
28
|
+
sensorType: SensorType,
|
|
29
|
+
userConfig?: SensorConfig
|
|
30
|
+
): AnimatedSensor {
|
|
31
|
+
const ref = useRef({
|
|
32
|
+
sensor: null,
|
|
33
|
+
unregister: () => {
|
|
34
|
+
// NOOP
|
|
35
|
+
},
|
|
36
|
+
isAvailable: false,
|
|
37
|
+
config: {
|
|
38
|
+
interval: 0,
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
if (ref.current.sensor === null) {
|
|
43
|
+
ref.current.config = { interval: 10, ...userConfig };
|
|
44
|
+
let sensorData;
|
|
45
|
+
if (sensorType === SensorType.ROTATION) {
|
|
46
|
+
sensorData = {
|
|
47
|
+
qw: 0,
|
|
48
|
+
qx: 0,
|
|
49
|
+
qy: 0,
|
|
50
|
+
qz: 0,
|
|
51
|
+
yaw: 0,
|
|
52
|
+
pitch: 0,
|
|
53
|
+
roll: 0,
|
|
54
|
+
};
|
|
55
|
+
} else {
|
|
56
|
+
sensorData = {
|
|
57
|
+
x: 0,
|
|
58
|
+
y: 0,
|
|
59
|
+
z: 0,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
ref.current.sensor = makeMutable(sensorData) as any;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
ref.current.config = { interval: 10, ...userConfig };
|
|
67
|
+
const id = NativeReanimated.registerSensor(
|
|
68
|
+
sensorType,
|
|
69
|
+
ref.current.config.interval,
|
|
70
|
+
ref.current.sensor as any
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
if (id !== -1) {
|
|
74
|
+
// if sensor is available
|
|
75
|
+
ref.current.unregister = () => NativeReanimated.unregisterSensor(id);
|
|
76
|
+
ref.current.isAvailable = true;
|
|
77
|
+
} else {
|
|
78
|
+
// if sensor is unavailable
|
|
79
|
+
ref.current.unregister = () => {
|
|
80
|
+
// NOOP
|
|
81
|
+
};
|
|
82
|
+
ref.current.isAvailable = false;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return () => {
|
|
86
|
+
ref.current.unregister();
|
|
87
|
+
};
|
|
88
|
+
}, [sensorType, userConfig]);
|
|
89
|
+
|
|
90
|
+
return ref.current;
|
|
91
|
+
}
|
|
@@ -187,7 +187,8 @@ export function isAnimated(prop: NestedObjectValues<AnimationObject>): boolean {
|
|
|
187
187
|
'worklet';
|
|
188
188
|
const propsToCheck: NestedObjectValues<AnimationObject>[] = [prop];
|
|
189
189
|
while (propsToCheck.length > 0) {
|
|
190
|
-
const currentProp: NestedObjectValues<AnimationObject> =
|
|
190
|
+
const currentProp: NestedObjectValues<AnimationObject> =
|
|
191
|
+
propsToCheck.pop() as NestedObjectValues<AnimationObject>;
|
|
191
192
|
if (Array.isArray(currentProp)) {
|
|
192
193
|
for (const item of currentProp) {
|
|
193
194
|
propsToCheck.push(item);
|
|
@@ -58,13 +58,13 @@ const getInterpolateRGB = (
|
|
|
58
58
|
const a = [];
|
|
59
59
|
for (let i = 0; i < colors.length; ++i) {
|
|
60
60
|
const color = colors[i];
|
|
61
|
-
const
|
|
61
|
+
const processedColor = processColor(color);
|
|
62
62
|
// explicit check in case if processedColor is 0
|
|
63
|
-
if (
|
|
64
|
-
r.push(red(
|
|
65
|
-
g.push(green(
|
|
66
|
-
b.push(blue(
|
|
67
|
-
a.push(opacity(
|
|
63
|
+
if (processedColor !== null && processedColor !== undefined) {
|
|
64
|
+
r.push(red(processedColor));
|
|
65
|
+
g.push(green(processedColor));
|
|
66
|
+
b.push(blue(processedColor));
|
|
67
|
+
a.push(opacity(processedColor));
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
return { r, g, b, a };
|
|
@@ -85,11 +85,11 @@ const getInterpolateHSV = (
|
|
|
85
85
|
const v = [];
|
|
86
86
|
for (let i = 0; i < colors.length; ++i) {
|
|
87
87
|
const color = colors[i];
|
|
88
|
-
const
|
|
89
|
-
if (
|
|
90
|
-
h.push(
|
|
91
|
-
s.push(
|
|
92
|
-
v.push(
|
|
88
|
+
const processedColor = RGBtoHSV(processColor(color) as any);
|
|
89
|
+
if (processedColor) {
|
|
90
|
+
h.push(processedColor.h);
|
|
91
|
+
s.push(processedColor.s);
|
|
92
|
+
v.push(processedColor.v);
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
return { h, s, v };
|
|
@@ -123,12 +123,8 @@ function internalInterpolate(
|
|
|
123
123
|
extrapolationConfig: RequiredExtrapolationConfig
|
|
124
124
|
) {
|
|
125
125
|
'worklet';
|
|
126
|
-
const {
|
|
127
|
-
|
|
128
|
-
rightEdgeInput,
|
|
129
|
-
leftEdgeOutput,
|
|
130
|
-
rightEdgeOutput,
|
|
131
|
-
} = narrowedInput;
|
|
126
|
+
const { leftEdgeInput, rightEdgeInput, leftEdgeOutput, rightEdgeOutput } =
|
|
127
|
+
narrowedInput;
|
|
132
128
|
if (rightEdgeInput - leftEdgeInput === 0) return leftEdgeOutput;
|
|
133
129
|
const progress = (x - leftEdgeInput) / (rightEdgeInput - leftEdgeInput);
|
|
134
130
|
const val = leftEdgeOutput + progress * (rightEdgeOutput - leftEdgeOutput);
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2
2
|
// @ts-nocheck
|
|
3
|
-
|
|
3
|
+
import { jestResetJsReanimatedModule } from './core';
|
|
4
|
+
|
|
5
|
+
declare global {
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
7
|
+
namespace jest {
|
|
8
|
+
interface Matchers<R> {
|
|
9
|
+
toHaveAnimatedStyle(
|
|
10
|
+
style: Record<string, unknown>[] | Record<string, unknown>
|
|
11
|
+
): R;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
4
15
|
|
|
5
16
|
let config = {
|
|
6
17
|
fps: 60,
|
|
@@ -129,26 +140,30 @@ const compareStyle = (received, expectedStyle, config) => {
|
|
|
129
140
|
|
|
130
141
|
let frameTime = 1000 / config.fps;
|
|
131
142
|
let requestAnimationFrameCopy;
|
|
143
|
+
let currentTimestamp = 0;
|
|
132
144
|
|
|
133
145
|
const requestAnimationFrame = (callback) => {
|
|
134
146
|
setTimeout(callback, frameTime);
|
|
135
147
|
};
|
|
136
148
|
|
|
137
149
|
const beforeTest = () => {
|
|
150
|
+
jestResetJsReanimatedModule();
|
|
138
151
|
requestAnimationFrameCopy = global.requestAnimationFrame;
|
|
139
152
|
global.requestAnimationFrame = requestAnimationFrame;
|
|
140
|
-
|
|
153
|
+
global.ReanimatedDataMock = {
|
|
154
|
+
now: () => currentTimestamp,
|
|
155
|
+
};
|
|
156
|
+
currentTimestamp = 0;
|
|
141
157
|
jest.useFakeTimers();
|
|
142
158
|
};
|
|
143
159
|
|
|
144
160
|
const afterTest = () => {
|
|
145
|
-
MockDate.reset();
|
|
146
161
|
jest.useRealTimers();
|
|
147
162
|
global.requestAnimationFrame = requestAnimationFrameCopy;
|
|
148
163
|
};
|
|
149
164
|
|
|
150
165
|
const tickTravel = () => {
|
|
151
|
-
|
|
166
|
+
currentTimestamp += frameTime;
|
|
152
167
|
jest.advanceTimersByTime(frameTime);
|
|
153
168
|
};
|
|
154
169
|
|
|
@@ -174,6 +189,7 @@ export const advanceAnimationByFrame = (count) => {
|
|
|
174
189
|
|
|
175
190
|
export const setUpTests = (userConfig = {}) => {
|
|
176
191
|
const expect = require('expect');
|
|
192
|
+
require('setimmediate');
|
|
177
193
|
frameTime = Math.round(1000 / config.fps);
|
|
178
194
|
|
|
179
195
|
config = {
|
|
@@ -3,6 +3,7 @@ import Mapper from './Mapper';
|
|
|
3
3
|
import MutableValue from './MutableValue';
|
|
4
4
|
import { NativeReanimated } from '../NativeReanimated/NativeReanimated';
|
|
5
5
|
import { Timestamp, NestedObjectValues } from '../commonTypes';
|
|
6
|
+
import { isJest } from '../PlatformChecker';
|
|
6
7
|
|
|
7
8
|
export default class JSReanimated extends NativeReanimated {
|
|
8
9
|
_valueSetter?: <T>(value: T) => void = undefined;
|
|
@@ -14,8 +15,8 @@ export default class JSReanimated extends NativeReanimated {
|
|
|
14
15
|
|
|
15
16
|
constructor() {
|
|
16
17
|
super(false);
|
|
17
|
-
if (
|
|
18
|
-
this.timeProvider = { now: () =>
|
|
18
|
+
if (isJest()) {
|
|
19
|
+
this.timeProvider = { now: () => global.ReanimatedDataMock.now() };
|
|
19
20
|
} else {
|
|
20
21
|
this.timeProvider = { now: () => window.performance.now() };
|
|
21
22
|
}
|
|
@@ -103,4 +104,26 @@ export default class JSReanimated extends NativeReanimated {
|
|
|
103
104
|
'[Reanimated] enableLayoutAnimations is not available for WEB yet'
|
|
104
105
|
);
|
|
105
106
|
}
|
|
107
|
+
|
|
108
|
+
registerSensor(): number {
|
|
109
|
+
console.warn('[Reanimated] useAnimatedSensor is not available on web yet.');
|
|
110
|
+
return -1;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
unregisterSensor(): void {
|
|
114
|
+
// noop
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
jestResetModule() {
|
|
118
|
+
if (isJest()) {
|
|
119
|
+
/**
|
|
120
|
+
* If someone used timers to stop animation before the end,
|
|
121
|
+
* then _renderRequested was set as true
|
|
122
|
+
* and any new update from another test wasn't applied.
|
|
123
|
+
*/
|
|
124
|
+
this._renderRequested = false;
|
|
125
|
+
} else {
|
|
126
|
+
throw Error('This method can be only use in Jest testing.');
|
|
127
|
+
}
|
|
128
|
+
}
|
|
106
129
|
}
|
|
@@ -20,7 +20,7 @@ if (shouldBeUseWeb()) {
|
|
|
20
20
|
};
|
|
21
21
|
global._measure = () => {
|
|
22
22
|
console.warn(
|
|
23
|
-
"[Reanimated] You can't use
|
|
23
|
+
"[Reanimated] You can't use `measure` with Chrome Debugger or with web version"
|
|
24
24
|
);
|
|
25
25
|
return {
|
|
26
26
|
x: 0,
|
|
@@ -33,12 +33,12 @@ if (shouldBeUseWeb()) {
|
|
|
33
33
|
};
|
|
34
34
|
global._scrollTo = () => {
|
|
35
35
|
console.warn(
|
|
36
|
-
"[Reanimated] You can't use
|
|
36
|
+
"[Reanimated] You can't use `scrollTo` with Chrome Debugger or with web version"
|
|
37
37
|
);
|
|
38
38
|
};
|
|
39
39
|
global._setGestureState = () => {
|
|
40
40
|
console.warn(
|
|
41
|
-
"[Reanimated] You can't use
|
|
41
|
+
"[Reanimated] You can't use `setGestureState` with Chrome Debugger or with web version"
|
|
42
42
|
);
|
|
43
43
|
};
|
|
44
44
|
}
|