react-native-reanimated 3.0.0-rc.9 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Common/cpp/AnimatedSensor/AnimatedSensorModule.cpp +30 -12
- package/Common/cpp/AnimatedSensor/AnimatedSensorModule.h +2 -0
- package/Common/cpp/Fabric/FabricUtils.cpp +3 -107
- package/Common/cpp/Fabric/FabricUtils.h +3 -24
- package/Common/cpp/Fabric/ReanimatedUIManagerBinding.cpp +54 -37
- package/Common/cpp/LayoutAnimations/LayoutAnimationType.h +8 -0
- package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.cpp +81 -26
- package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.h +20 -3
- package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +105 -109
- package/Common/cpp/NativeModules/NativeReanimatedModule.h +19 -12
- package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +15 -7
- package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.h +6 -2
- package/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.cpp +20 -1
- package/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.h +9 -0
- package/Common/cpp/ReanimatedRuntime/ReanimatedRuntime.cpp +5 -1
- package/Common/cpp/Registries/EventHandlerRegistry.cpp +8 -34
- package/Common/cpp/Registries/EventHandlerRegistry.h +7 -13
- package/Common/cpp/SharedItems/Shareables.cpp +9 -63
- package/Common/cpp/SharedItems/Shareables.h +77 -72
- package/Common/cpp/Tools/CollectionUtils.h +14 -0
- package/Common/cpp/Tools/JsiUtils.cpp +26 -0
- package/Common/cpp/Tools/JsiUtils.h +176 -0
- package/Common/cpp/Tools/PlatformDepMethodsHolder.h +5 -5
- package/Common/cpp/Tools/ReanimatedVersion.cpp +17 -0
- package/Common/cpp/Tools/ReanimatedVersion.h +11 -0
- package/Common/cpp/Tools/RuntimeDecorator.cpp +49 -230
- package/Common/cpp/Tools/RuntimeDecorator.h +0 -2
- package/Common/cpp/Tools/WorkletEventHandler.cpp +3 -2
- package/Common/cpp/Tools/WorkletEventHandler.h +14 -6
- package/RNReanimated.podspec +2 -1
- package/android/CMakeLists.txt +188 -181
- package/android/build.gradle +362 -311
- package/android/proguard-rules.pro +2 -0
- package/android/src/fabric/java/com/swmansion/reanimated/NativeProxy.java +63 -295
- package/android/src/main/cpp/LayoutAnimations.cpp +35 -5
- package/android/src/main/cpp/LayoutAnimations.h +23 -6
- package/android/src/main/cpp/NativeProxy.cpp +143 -98
- package/android/src/main/cpp/NativeProxy.h +22 -28
- package/android/src/main/java/com/swmansion/reanimated/ReanimatedPackage.java +5 -4
- package/android/src/main/java/com/swmansion/reanimated/Utils.java +7 -1
- package/android/src/main/java/com/swmansion/reanimated/keyboardObserver/ReanimatedKeyboardEventListener.java +10 -3
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/AnimationsManager.java +218 -35
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/LayoutAnimations.java +43 -17
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/NativeMethodsHolder.java +6 -2
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/SharedElement.java +19 -0
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/SharedTransitionManager.java +610 -0
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/Snapshot.java +93 -23
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/AnimationFrameCallback.java +19 -0
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/EventHandler.java +35 -0
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/KeyboardEventDataUpdater.java +16 -0
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/NativeProxyCommon.java +206 -0
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/SensorSetter.java +17 -0
- package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensor.java +9 -3
- package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorContainer.java +3 -4
- package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorListener.java +31 -7
- package/android/src/paper/java/com/swmansion/reanimated/NativeProxy.java +90 -307
- package/android/src/reactNativeVersionPatch/ReanimatedUIManager/70/com/swmansion/reanimated/ReanimatedUIManagerFactory.java +16 -0
- package/android/src/reactNativeVersionPatch/ReanimatedUIManager/latest/com/swmansion/reanimated/ReanimatedUIManagerFactory.java +63 -0
- package/android/src/reactNativeVersionPatch/ReanimatedUIManager/latest/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +271 -0
- package/android/src/reactNativeVersionPatch/nativeHierarchyManager/latest/com/swmansion/reanimated/layoutReanimation/ReanimatedNativeHierarchyManager.java +76 -20
- package/ios/LayoutReanimation/REAAnimationsManager.h +28 -4
- package/ios/LayoutReanimation/REAAnimationsManager.m +216 -61
- package/ios/LayoutReanimation/REAFrame.h +10 -0
- package/ios/LayoutReanimation/REAFrame.m +15 -0
- package/ios/LayoutReanimation/REAScreensHelper.h +19 -0
- package/ios/LayoutReanimation/REAScreensHelper.m +106 -0
- package/ios/LayoutReanimation/REASharedElement.h +15 -0
- package/ios/LayoutReanimation/REASharedElement.m +16 -0
- package/ios/LayoutReanimation/REASharedTransitionManager.h +17 -0
- package/ios/LayoutReanimation/REASharedTransitionManager.m +632 -0
- package/ios/LayoutReanimation/REASnapshot.h +1 -0
- package/ios/LayoutReanimation/REASnapshot.m +96 -11
- package/ios/LayoutReanimation/REAUIManager.mm +64 -17
- package/ios/REAModule.mm +2 -7
- package/ios/REANodesManager.mm +1 -21
- package/ios/keyboardObserver/REAKeyboardEventObserver.m +72 -36
- package/ios/native/NativeProxy.mm +75 -114
- package/ios/native/REAInitializer.mm +2 -7
- package/ios/native/REAJSIUtils.h +60 -2
- package/ios/sensor/ReanimatedSensor.h +6 -2
- package/ios/sensor/ReanimatedSensor.m +43 -7
- package/ios/sensor/ReanimatedSensorContainer.h +4 -1
- package/ios/sensor/ReanimatedSensorContainer.m +8 -2
- package/lib/commonjs/createAnimatedComponent.js +232 -28
- package/lib/commonjs/createAnimatedComponent.js.map +1 -1
- package/lib/commonjs/reanimated2/Colors.js +43 -22
- package/lib/commonjs/reanimated2/Colors.js.map +1 -1
- package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js +16 -33
- package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/styleAnimation.js +5 -1
- package/lib/commonjs/reanimated2/animation/styleAnimation.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/util.js +17 -15
- package/lib/commonjs/reanimated2/animation/util.js.map +1 -1
- package/lib/commonjs/reanimated2/commonTypes.js +33 -1
- package/lib/commonjs/reanimated2/commonTypes.js.map +1 -1
- package/lib/commonjs/reanimated2/core.js +33 -14
- package/lib/commonjs/reanimated2/core.js.map +1 -1
- package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryUI.js +2 -2
- package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryUI.js.map +1 -1
- package/lib/commonjs/reanimated2/globals.d.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/index.js +0 -6
- package/lib/commonjs/reanimated2/hook/index.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js +5 -2
- package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedReaction.js +13 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedReaction.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedRef.js +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedRef.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js +89 -16
- package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js +43 -40
- package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useDerivedValue.js +13 -1
- package/lib/commonjs/reanimated2/hook/useDerivedValue.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useScrollViewOffset.js +2 -2
- package/lib/commonjs/reanimated2/hook/useScrollViewOffset.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/utils.js +18 -65
- package/lib/commonjs/reanimated2/hook/utils.js.map +1 -1
- package/lib/commonjs/reanimated2/index.js +13 -0
- package/lib/commonjs/reanimated2/index.js.map +1 -1
- package/lib/commonjs/reanimated2/initializers.js +71 -32
- package/lib/commonjs/reanimated2/initializers.js.map +1 -1
- package/lib/commonjs/reanimated2/interpolateColor.js +96 -19
- package/lib/commonjs/reanimated2/interpolateColor.js.map +1 -1
- package/lib/commonjs/reanimated2/jestUtils.js +1 -1
- package/lib/commonjs/reanimated2/jestUtils.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js +103 -13
- package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/Mapper.js +22 -0
- package/lib/commonjs/reanimated2/js-reanimated/Mapper.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/WebSensor.js +2 -0
- package/lib/commonjs/reanimated2/js-reanimated/WebSensor.js.map +1 -0
- package/lib/commonjs/reanimated2/js-reanimated/commonTypes.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/global.js +0 -2
- package/lib/commonjs/reanimated2/js-reanimated/global.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/index.js +0 -1
- package/lib/commonjs/reanimated2/js-reanimated/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +11 -0
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/index.js +8 -0
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js +17 -9
- package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +16 -23
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +8 -14
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Roll.js +8 -14
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Slide.js +8 -15
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +16 -23
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/index.js +13 -0
- package/lib/commonjs/reanimated2/layoutReanimation/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/sharedTransitions/index.js +94 -0
- package/lib/commonjs/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -0
- package/lib/commonjs/reanimated2/mappers.js +18 -6
- package/lib/commonjs/reanimated2/mappers.js.map +1 -1
- package/lib/commonjs/reanimated2/mock.js +20 -1
- package/lib/commonjs/reanimated2/mock.js.map +1 -1
- package/lib/commonjs/reanimated2/mutables.js +4 -2
- package/lib/commonjs/reanimated2/mutables.js.map +1 -1
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.js +42 -0
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.js.map +1 -0
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.web.js +15 -0
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.web.js.map +1 -0
- package/lib/commonjs/reanimated2/pluginUtils.js +11 -0
- package/lib/commonjs/reanimated2/pluginUtils.js.map +1 -0
- package/lib/commonjs/reanimated2/shareables.js +36 -15
- package/lib/commonjs/reanimated2/shareables.js.map +1 -1
- package/lib/commonjs/reanimated2/threads.js +114 -4
- package/lib/commonjs/reanimated2/threads.js.map +1 -1
- package/lib/commonjs/reanimated2/utils.js +7 -0
- package/lib/commonjs/reanimated2/utils.js.map +1 -1
- package/lib/commonjs/reanimated2/valueSetter.js +1 -3
- package/lib/commonjs/reanimated2/valueSetter.js.map +1 -1
- package/lib/module/createAnimatedComponent.js +229 -29
- package/lib/module/createAnimatedComponent.js.map +1 -1
- package/lib/module/reanimated2/Colors.js +35 -19
- package/lib/module/reanimated2/Colors.js.map +1 -1
- package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js +16 -32
- package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
- package/lib/module/reanimated2/animation/styleAnimation.js +5 -1
- package/lib/module/reanimated2/animation/styleAnimation.js.map +1 -1
- package/lib/module/reanimated2/animation/util.js +17 -16
- package/lib/module/reanimated2/animation/util.js.map +1 -1
- package/lib/module/reanimated2/commonTypes.js +29 -0
- package/lib/module/reanimated2/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/core.js +32 -7
- package/lib/module/reanimated2/core.js.map +1 -1
- package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js +2 -2
- package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js.map +1 -1
- package/lib/module/reanimated2/globals.d.js.map +1 -1
- package/lib/module/reanimated2/hook/index.js +1 -1
- package/lib/module/reanimated2/hook/index.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedKeyboard.js +5 -2
- package/lib/module/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedReaction.js +12 -1
- package/lib/module/reanimated2/hook/useAnimatedReaction.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedRef.js +2 -2
- package/lib/module/reanimated2/hook/useAnimatedRef.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedSensor.js +88 -13
- package/lib/module/reanimated2/hook/useAnimatedSensor.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedStyle.js +46 -43
- package/lib/module/reanimated2/hook/useAnimatedStyle.js.map +1 -1
- package/lib/module/reanimated2/hook/useDerivedValue.js +12 -1
- package/lib/module/reanimated2/hook/useDerivedValue.js.map +1 -1
- package/lib/module/reanimated2/hook/useScrollViewOffset.js +2 -2
- package/lib/module/reanimated2/hook/useScrollViewOffset.js.map +1 -1
- package/lib/module/reanimated2/hook/utils.js +17 -60
- package/lib/module/reanimated2/hook/utils.js.map +1 -1
- package/lib/module/reanimated2/index.js +1 -0
- package/lib/module/reanimated2/index.js.map +1 -1
- package/lib/module/reanimated2/initializers.js +72 -33
- package/lib/module/reanimated2/initializers.js.map +1 -1
- package/lib/module/reanimated2/interpolateColor.js +96 -19
- package/lib/module/reanimated2/interpolateColor.js.map +1 -1
- package/lib/module/reanimated2/jestUtils.js +1 -1
- package/lib/module/reanimated2/jestUtils.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/JSReanimated.js +103 -13
- package/lib/module/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/Mapper.js +21 -0
- package/lib/module/reanimated2/js-reanimated/Mapper.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/WebSensor.js +2 -0
- package/lib/module/reanimated2/js-reanimated/WebSensor.js.map +1 -0
- package/lib/module/reanimated2/js-reanimated/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/global.js +0 -2
- package/lib/module/reanimated2/js-reanimated/global.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/index.js +0 -1
- package/lib/module/reanimated2/js-reanimated/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +9 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/index.js +1 -0
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationsManager.js +15 -8
- package/lib/module/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +16 -21
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +8 -12
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js +8 -12
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js +8 -13
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +16 -21
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/index.js +1 -0
- package/lib/module/reanimated2/layoutReanimation/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js +82 -0
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -0
- package/lib/module/reanimated2/mappers.js +16 -6
- package/lib/module/reanimated2/mappers.js.map +1 -1
- package/lib/module/reanimated2/mock.js +20 -1
- package/lib/module/reanimated2/mock.js.map +1 -1
- package/lib/module/reanimated2/mutables.js +4 -2
- package/lib/module/reanimated2/mutables.js.map +1 -1
- package/lib/module/reanimated2/platform-specific/checkVersion.js +35 -0
- package/lib/module/reanimated2/platform-specific/checkVersion.js.map +1 -0
- package/lib/module/reanimated2/platform-specific/checkVersion.web.js +8 -0
- package/lib/module/reanimated2/platform-specific/checkVersion.web.js.map +1 -0
- package/lib/module/reanimated2/pluginUtils.js +4 -0
- package/lib/module/reanimated2/pluginUtils.js.map +1 -0
- package/lib/module/reanimated2/shareables.js +36 -12
- package/lib/module/reanimated2/shareables.js.map +1 -1
- package/lib/module/reanimated2/threads.js +105 -4
- package/lib/module/reanimated2/threads.js.map +1 -1
- package/lib/module/reanimated2/utils.js +5 -0
- package/lib/module/reanimated2/utils.js.map +1 -1
- package/lib/module/reanimated2/valueSetter.js +1 -2
- package/lib/module/reanimated2/valueSetter.js.map +1 -1
- package/package.json +10 -10
- package/{plugin.js → plugin/index.js} +128 -249
- package/react-native-reanimated.d.ts +57 -10
- package/scripts/reanimated_utils.rb +15 -2
- package/src/createAnimatedComponent.tsx +238 -28
- package/src/reanimated2/Colors.ts +38 -11
- package/src/reanimated2/NativeReanimated/NativeReanimated.ts +52 -39
- package/src/reanimated2/animation/styleAnimation.ts +8 -1
- package/src/reanimated2/animation/util.ts +29 -16
- package/src/reanimated2/commonTypes.ts +28 -1
- package/src/reanimated2/core.ts +42 -9
- package/src/reanimated2/frameCallback/FrameCallbackRegistryUI.ts +2 -2
- package/src/reanimated2/globals.d.ts +12 -15
- package/src/reanimated2/hook/index.ts +1 -1
- package/src/reanimated2/hook/useAnimatedKeyboard.ts +10 -4
- package/src/reanimated2/hook/useAnimatedReaction.ts +12 -5
- package/src/reanimated2/hook/useAnimatedRef.ts +1 -4
- package/src/reanimated2/hook/useAnimatedSensor.ts +88 -11
- package/src/reanimated2/hook/useAnimatedStyle.ts +44 -36
- package/src/reanimated2/hook/useDerivedValue.ts +8 -1
- package/src/reanimated2/hook/useScrollViewOffset.ts +2 -2
- package/src/reanimated2/hook/utils.ts +15 -61
- package/src/reanimated2/index.ts +1 -0
- package/src/reanimated2/initializers.ts +76 -35
- package/src/reanimated2/interpolateColor.ts +104 -20
- package/src/reanimated2/jestUtils.ts +1 -1
- package/src/reanimated2/js-reanimated/JSReanimated.ts +98 -15
- package/src/reanimated2/js-reanimated/Mapper.ts +32 -0
- package/src/reanimated2/js-reanimated/WebSensor.ts +34 -0
- package/src/reanimated2/js-reanimated/commonTypes.ts +0 -1
- package/src/reanimated2/js-reanimated/global.ts +0 -1
- package/src/reanimated2/js-reanimated/index.ts +0 -1
- package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +13 -1
- package/src/reanimated2/layoutReanimation/animationBuilder/index.ts +1 -0
- package/src/reanimated2/layoutReanimation/animationsManager.ts +17 -9
- package/src/reanimated2/layoutReanimation/defaultAnimations/Bounce.ts +16 -19
- package/src/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.ts +14 -11
- package/src/reanimated2/layoutReanimation/defaultAnimations/Roll.ts +21 -11
- package/src/reanimated2/layoutReanimation/defaultAnimations/Slide.ts +32 -11
- package/src/reanimated2/layoutReanimation/defaultAnimations/Zoom.ts +36 -19
- package/src/reanimated2/layoutReanimation/index.ts +1 -0
- package/src/reanimated2/layoutReanimation/sharedTransitions/index.ts +87 -0
- package/src/reanimated2/mappers.ts +17 -6
- package/src/reanimated2/mock.ts +24 -1
- package/src/reanimated2/mutables.ts +2 -0
- package/src/reanimated2/platform-specific/checkVersion.ts +39 -0
- package/src/reanimated2/platform-specific/checkVersion.web.ts +6 -0
- package/src/reanimated2/pluginUtils.ts +8 -0
- package/src/reanimated2/shareables.ts +45 -16
- package/src/reanimated2/threads.ts +103 -1
- package/src/reanimated2/utils.ts +6 -0
- package/src/reanimated2/valueSetter.ts +1 -2
- package/lib/commonjs/reanimated2/time.js +0 -55
- package/lib/commonjs/reanimated2/time.js.map +0 -1
- package/lib/module/reanimated2/time.js +0 -37
- package/lib/module/reanimated2/time.js.map +0 -1
- package/src/reanimated2/time.ts +0 -30
- /package/android/src/{main/java → reactNativeVersionPatch/ReanimatedUIManager/70}/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Extrapolate","EXTEND","CLAMP","IDENTITY","interpolateColorsHSV","value","inputRange","colors","h","interpolate","s","v","hsvToColor","interpolateColorsRGB","r","g","b","a","rgbaColor","getInterpolateRGB","i","length","color","processedColor","processColor","undefined","push","red","green","blue","opacity","getInterpolateHSV","RGBtoHSV","interpolateColor","outputRange","colorSpace","Error","ColorSpace","useInterpolateConfig","RGB","useSharedValue","cache","makeMutable","interpolateSharableColor","interpolateConfig","HSV"],"sources":["interpolateColor.ts"],"sourcesContent":["import {\n hsvToColor,\n RGBtoHSV,\n rgbaColor,\n processColor,\n red,\n green,\n blue,\n opacity,\n} from './Colors';\nimport { makeMutable } from './core';\nimport { interpolate } from './interpolation';\nimport { SharedValue } from './commonTypes';\nimport { useSharedValue } from './hook/useSharedValue';\n\nexport const Extrapolate = {\n EXTEND: 'extend',\n CLAMP: 'clamp',\n IDENTITY: 'identity',\n};\n\nconst interpolateColorsHSV = (\n value: number,\n inputRange: readonly number[],\n colors: InterpolateHSV\n) => {\n 'worklet';\n const h = interpolate(value, inputRange, colors.h, Extrapolate.CLAMP);\n const s = interpolate(value, inputRange, colors.s, Extrapolate.CLAMP);\n const v = interpolate(value, inputRange, colors.v, Extrapolate.CLAMP);\n return hsvToColor(h, s, v);\n};\n\nconst interpolateColorsRGB = (\n value: number,\n inputRange: readonly number[],\n colors: InterpolateRGB\n) => {\n 'worklet';\n const r = interpolate(value, inputRange, colors.r, Extrapolate.CLAMP);\n const g = interpolate(value, inputRange, colors.g, Extrapolate.CLAMP);\n const b = interpolate(value, inputRange, colors.b, Extrapolate.CLAMP);\n const a = interpolate(value, inputRange, colors.a, Extrapolate.CLAMP);\n return rgbaColor(r, g, b, a);\n};\n\ninterface InterpolateRGB {\n r: number[];\n g: number[];\n b: number[];\n a: number[];\n}\n\nconst getInterpolateRGB = (\n colors: readonly (string | number)[]\n): InterpolateRGB => {\n 'worklet';\n\n const r = [];\n const g = [];\n const b = [];\n const a = [];\n for (let i = 0; i < colors.length; ++i) {\n const color = colors[i];\n const processedColor = processColor(color);\n // explicit check in case if processedColor is 0\n if (processedColor !== null && processedColor !== undefined) {\n r.push(red(processedColor));\n g.push(green(processedColor));\n b.push(blue(processedColor));\n a.push(opacity(processedColor));\n }\n }\n return { r, g, b, a };\n};\n\ninterface InterpolateHSV {\n h: number[];\n s: number[];\n v: number[];\n}\n\nconst getInterpolateHSV = (\n colors: readonly (string | number)[]\n): InterpolateHSV => {\n 'worklet';\n const h = [];\n const s = [];\n const v = [];\n for (let i = 0; i < colors.length; ++i) {\n const color = colors[i];\n const processedColor = RGBtoHSV(processColor(color) as any);\n if (processedColor) {\n h.push(processedColor.h);\n s.push(processedColor.s);\n v.push(processedColor.v);\n }\n }\n return { h, s, v };\n};\n\nexport const interpolateColor = (\n value: number,\n inputRange: readonly number[],\n outputRange: readonly (string | number)[],\n colorSpace: 'RGB' | 'HSV' = 'RGB'\n): string | number => {\n 'worklet';\n if (colorSpace === 'HSV') {\n return interpolateColorsHSV(\n value,\n inputRange,\n getInterpolateHSV(outputRange)\n );\n } else if (colorSpace === 'RGB') {\n return interpolateColorsRGB(\n value,\n inputRange,\n getInterpolateRGB(outputRange)\n );\n }\n throw new Error(\n `Invalid color space provided: ${colorSpace}. Supported values are: ['RGB', 'HSV']`\n );\n};\n\nexport enum ColorSpace {\n RGB = 0,\n HSV = 1,\n}\n\nexport interface InterpolateConfig {\n inputRange: readonly number[];\n outputRange: readonly (string | number)[];\n colorSpace: ColorSpace;\n cache: SharedValue<InterpolateRGB | InterpolateHSV | null>;\n}\n\nexport function useInterpolateConfig(\n inputRange: readonly number[],\n outputRange: readonly (string | number)[],\n colorSpace = ColorSpace.RGB\n): SharedValue<InterpolateConfig> {\n return useSharedValue<InterpolateConfig>({\n inputRange,\n outputRange,\n colorSpace,\n cache: makeMutable<InterpolateRGB | InterpolateHSV | null>(null),\n });\n}\n\nexport const interpolateSharableColor = (\n value: number,\n interpolateConfig: SharedValue<InterpolateConfig>\n): string | number => {\n 'worklet';\n let colors = interpolateConfig.value.cache.value;\n if (interpolateConfig.value.colorSpace === ColorSpace.RGB) {\n if (!colors) {\n colors = getInterpolateRGB(interpolateConfig.value.outputRange);\n interpolateConfig.value.cache.value = colors;\n }\n return interpolateColorsRGB(\n value,\n interpolateConfig.value.inputRange,\n colors as InterpolateRGB\n );\n } else if (interpolateConfig.value.colorSpace === ColorSpace.HSV) {\n if (!colors) {\n colors = getInterpolateHSV(interpolateConfig.value.outputRange);\n interpolateConfig.value.cache.value = colors;\n }\n return interpolateColorsHSV(\n value,\n interpolateConfig.value.inputRange,\n colors as InterpolateHSV\n );\n }\n throw new Error(\n `Invalid color space provided: ${interpolateConfig.value.colorSpace}. Supported values are: ['RGB', 'HSV']`\n );\n};\n"],"mappings":";;;;;;;;AAAA;;AAUA;;AACA;;AAEA;;AAEO,MAAMA,WAAW,GAAG;EACzBC,MAAM,EAAE,QADiB;EAEzBC,KAAK,EAAE,OAFkB;EAGzBC,QAAQ,EAAE;AAHe,CAApB;;;AAMP,MAAMC,oBAAoB,GAAG,CAC3BC,KAD2B,EAE3BC,UAF2B,EAG3BC,MAH2B,KAIxB;EACH;;EACA,MAAMC,CAAC,GAAG,IAAAC,0BAAA,EAAYJ,KAAZ,EAAmBC,UAAnB,EAA+BC,MAAM,CAACC,CAAtC,EAAyCR,WAAW,CAACE,KAArD,CAAV;EACA,MAAMQ,CAAC,GAAG,IAAAD,0BAAA,EAAYJ,KAAZ,EAAmBC,UAAnB,EAA+BC,MAAM,CAACG,CAAtC,EAAyCV,WAAW,CAACE,KAArD,CAAV;EACA,MAAMS,CAAC,GAAG,IAAAF,0BAAA,EAAYJ,KAAZ,EAAmBC,UAAnB,EAA+BC,MAAM,CAACI,CAAtC,EAAyCX,WAAW,CAACE,KAArD,CAAV;EACA,OAAO,IAAAU,kBAAA,EAAWJ,CAAX,EAAcE,CAAd,EAAiBC,CAAjB,CAAP;AACD,CAVD;;AAYA,MAAME,oBAAoB,GAAG,CAC3BR,KAD2B,EAE3BC,UAF2B,EAG3BC,MAH2B,KAIxB;EACH;;EACA,MAAMO,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C,KAAxB,CAA8BpC,KAA9B,GAAsCE,MAAtC;IACD;;IACD,OAAOH,oBAAoB,CACzBC,KADyB,EAEzBuC,iBAAiB,CAACvC,KAAlB,CAAwBC,UAFC,EAGzBC,MAHyB,CAA3B;EAKD;;EACD,MAAM,IAAI6B,KAAJ,CACH,iCAAgCQ,iBAAiB,CAACvC,KAAlB,CAAwB8B,UAAW,wCADhE,CAAN;AAGD,CA9BM"}
|
|
1
|
+
{"version":3,"names":["Extrapolate","EXTEND","CLAMP","IDENTITY","interpolateColorsHSV","value","inputRange","colors","options","h","useCorrectedHSVInterpolation","correctedInputRange","originalH","correctedH","i","length","d","push","interpolate","s","v","a","hsvToColor","toLinearSpace","x","gamma","map","Math","pow","toGammaSpace","round","interpolateColorsRGB","r","outputR","g","outputG","b","outputB","rgbaColor","getInterpolateRGB","color","processedColor","processColor","undefined","red","green","blue","opacity","getInterpolateHSV","processedHSVColor","RGBtoHSV","interpolateColor","outputRange","colorSpace","Error","ColorSpace","useInterpolateConfig","RGB","useSharedValue","cache","makeMutable","interpolateSharableColor","interpolateConfig","HSV"],"sources":["interpolateColor.ts"],"sourcesContent":["import {\n hsvToColor,\n RGBtoHSV,\n rgbaColor,\n processColor,\n red,\n green,\n blue,\n opacity,\n} from './Colors';\nimport { makeMutable } from './core';\nimport { interpolate } from './interpolation';\nimport { SharedValue } from './commonTypes';\nimport { useSharedValue } from './hook/useSharedValue';\n\nexport const Extrapolate = {\n EXTEND: 'extend',\n CLAMP: 'clamp',\n IDENTITY: 'identity',\n};\n\nexport type InterpolationOptions = {\n gamma?: number;\n useCorrectedHSVInterpolation?: boolean;\n};\n\nconst interpolateColorsHSV = (\n value: number,\n inputRange: readonly number[],\n colors: InterpolateHSV,\n options: InterpolationOptions\n) => {\n 'worklet';\n let h = 0;\n const { useCorrectedHSVInterpolation = true } = options;\n if (useCorrectedHSVInterpolation) {\n // if the difference between hues in a range is > 180 deg\n // then move the hue at the right end of the range +/- 360 deg\n // and add the next point in the original place + 0.00001 with original hue\n // to not break the next range\n const correctedInputRange = [inputRange[0]];\n const originalH = colors.h;\n const correctedH = [originalH[0]];\n\n for (let i = 1; i < originalH.length; ++i) {\n const d = originalH[i] - originalH[i - 1];\n if (originalH[i] > originalH[i - 1] && d > 0.5) {\n correctedInputRange.push(inputRange[i]);\n correctedInputRange.push(inputRange[i] + 0.00001);\n correctedH.push(originalH[i] - 1);\n correctedH.push(originalH[i]);\n } else if (originalH[i] < originalH[i - 1] && d < -0.5) {\n correctedInputRange.push(inputRange[i]);\n correctedInputRange.push(inputRange[i] + 0.00001);\n correctedH.push(originalH[i] + 1);\n correctedH.push(originalH[i]);\n } else {\n correctedInputRange.push(inputRange[i]);\n correctedH.push(originalH[i]);\n }\n }\n h =\n (interpolate(value, correctedInputRange, correctedH, Extrapolate.CLAMP) +\n 1) %\n 1;\n } else {\n h = interpolate(value, inputRange, colors.h, Extrapolate.CLAMP);\n }\n const s = interpolate(value, inputRange, colors.s, Extrapolate.CLAMP);\n const v = interpolate(value, inputRange, colors.v, Extrapolate.CLAMP);\n const a = interpolate(value, inputRange, colors.a, Extrapolate.CLAMP);\n return hsvToColor(h, s, v, a);\n};\n\nconst toLinearSpace = (x: number[], gamma: number): number[] => {\n 'worklet';\n return x.map((v) => Math.pow(v / 255, gamma));\n};\n\nconst toGammaSpace = (x: number, gamma: number): number => {\n 'worklet';\n return Math.round(Math.pow(x, 1 / gamma) * 255);\n};\n\nconst interpolateColorsRGB = (\n value: number,\n inputRange: readonly number[],\n colors: InterpolateRGB,\n options: InterpolationOptions\n) => {\n 'worklet';\n const { gamma = 2.2 } = options;\n let { r: outputR, g: outputG, b: outputB } = colors;\n if (gamma !== 1) {\n outputR = toLinearSpace(outputR, gamma);\n outputG = toLinearSpace(outputG, gamma);\n outputB = toLinearSpace(outputB, gamma);\n }\n const r = interpolate(value, inputRange, outputR, Extrapolate.CLAMP);\n const g = interpolate(value, inputRange, outputG, Extrapolate.CLAMP);\n const b = interpolate(value, inputRange, outputB, Extrapolate.CLAMP);\n const a = interpolate(value, inputRange, colors.a, Extrapolate.CLAMP);\n if (gamma === 1) {\n return rgbaColor(r, g, b, a);\n }\n return rgbaColor(\n toGammaSpace(r, gamma),\n toGammaSpace(g, gamma),\n toGammaSpace(b, gamma),\n a\n );\n};\n\ninterface InterpolateRGB {\n r: number[];\n g: number[];\n b: number[];\n a: number[];\n}\n\nconst getInterpolateRGB = (\n colors: readonly (string | number)[]\n): InterpolateRGB => {\n 'worklet';\n\n const r = [];\n const g = [];\n const b = [];\n const a = [];\n for (let i = 0; i < colors.length; ++i) {\n const color = colors[i];\n const processedColor = processColor(color);\n // explicit check in case if processedColor is 0\n if (processedColor !== null && processedColor !== undefined) {\n r.push(red(processedColor));\n g.push(green(processedColor));\n b.push(blue(processedColor));\n a.push(opacity(processedColor));\n }\n }\n return { r, g, b, a };\n};\n\ninterface InterpolateHSV {\n h: number[];\n s: number[];\n v: number[];\n a: number[];\n}\n\nconst getInterpolateHSV = (\n colors: readonly (string | number)[]\n): InterpolateHSV => {\n 'worklet';\n const h = [];\n const s = [];\n const v = [];\n const a = [];\n for (let i = 0; i < colors.length; ++i) {\n const color = colors[i];\n const processedColor = processColor(color) as any;\n if (typeof processedColor === 'number') {\n const processedHSVColor = RGBtoHSV(\n red(processedColor),\n green(processedColor),\n blue(processedColor)\n );\n\n h.push(processedHSVColor.h);\n s.push(processedHSVColor.s);\n v.push(processedHSVColor.v);\n a.push(opacity(processedColor));\n }\n }\n return { h, s, v, a };\n};\n\nexport const interpolateColor = (\n value: number,\n inputRange: readonly number[],\n outputRange: readonly (string | number)[],\n colorSpace: 'RGB' | 'HSV' = 'RGB',\n options: InterpolationOptions = {}\n): string | number => {\n 'worklet';\n if (colorSpace === 'HSV') {\n return interpolateColorsHSV(\n value,\n inputRange,\n getInterpolateHSV(outputRange),\n options\n );\n } else if (colorSpace === 'RGB') {\n return interpolateColorsRGB(\n value,\n inputRange,\n getInterpolateRGB(outputRange),\n options\n );\n }\n throw new Error(\n `Invalid color space provided: ${colorSpace}. Supported values are: ['RGB', 'HSV']`\n );\n};\n\nexport enum ColorSpace {\n RGB = 0,\n HSV = 1,\n}\n\nexport interface InterpolateConfig {\n inputRange: readonly number[];\n outputRange: readonly (string | number)[];\n colorSpace: ColorSpace;\n cache: SharedValue<InterpolateRGB | InterpolateHSV | null>;\n options: InterpolationOptions;\n}\n\nexport function useInterpolateConfig(\n inputRange: readonly number[],\n outputRange: readonly (string | number)[],\n colorSpace = ColorSpace.RGB,\n options: InterpolationOptions = {}\n): SharedValue<InterpolateConfig> {\n return useSharedValue<InterpolateConfig>({\n inputRange,\n outputRange,\n colorSpace,\n cache: makeMutable<InterpolateRGB | InterpolateHSV | null>(null),\n options,\n });\n}\n\nexport const interpolateSharableColor = (\n value: number,\n interpolateConfig: SharedValue<InterpolateConfig>\n): string | number => {\n 'worklet';\n let colors = interpolateConfig.value.cache.value;\n if (interpolateConfig.value.colorSpace === ColorSpace.RGB) {\n if (!colors) {\n colors = getInterpolateRGB(interpolateConfig.value.outputRange);\n interpolateConfig.value.cache.value = colors;\n }\n return interpolateColorsRGB(\n value,\n interpolateConfig.value.inputRange,\n colors as InterpolateRGB,\n interpolateConfig.value.options\n );\n } else if (interpolateConfig.value.colorSpace === ColorSpace.HSV) {\n if (!colors) {\n colors = getInterpolateHSV(interpolateConfig.value.outputRange);\n interpolateConfig.value.cache.value = colors;\n }\n return interpolateColorsHSV(\n value,\n interpolateConfig.value.inputRange,\n colors as InterpolateHSV,\n interpolateConfig.value.options\n );\n }\n throw new Error(\n `Invalid color space provided: ${interpolateConfig.value.colorSpace}. Supported values are: ['RGB', 'HSV']`\n );\n};\n"],"mappings":";;;;;;;;AAAA;;AAUA;;AACA;;AAEA;;AAEO,MAAMA,WAAW,GAAG;EACzBC,MAAM,EAAE,QADiB;EAEzBC,KAAK,EAAE,OAFkB;EAGzBC,QAAQ,EAAE;AAHe,CAApB;;;AAWP,MAAMC,oBAAoB,GAAG,CAC3BC,KAD2B,E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,EAA2D;IAChE,IAAI,CAACxD,MAAL,EAAa;MACXA,MAAM,GAAGyC,iBAAiB,CAACc,iBAAiB,CAACzD,KAAlB,CAAwB+C,WAAzB,CAA1B;MACAU,iBAAiB,CAACzD,KAAlB,CAAwBsD,KAAxB,CAA8BtD,KAA9B,GAAsCE,MAAtC;IACD;;IACD,OAAOH,oBAAoB,CACzBC,KADyB,EAEzByD,iBAAiB,CAACzD,KAAlB,CAAwBC,UAFC,EAGzBC,MAHyB,EAIzBuD,iBAAiB,CAACzD,KAAlB,CAAwBG,OAJC,CAA3B;EAMD;;EACD,MAAM,IAAI8C,KAAJ,CACH,iCAAgCQ,iBAAiB,CAACzD,KAAlB,CAAwBgD,UAAW,wCADhE,CAAN;AAGD,CAhCM"}
|
|
@@ -149,7 +149,7 @@ const afterTest = () => {
|
|
|
149
149
|
};
|
|
150
150
|
|
|
151
151
|
const withReanimatedTimer = animationTest => {
|
|
152
|
-
console.warn('This method is deprecated, you
|
|
152
|
+
console.warn('This method is deprecated, you should define your own before and after test hooks to enable jest.useFakeTimers(). Check out the documentation for details on testing');
|
|
153
153
|
beforeTest();
|
|
154
154
|
animationTest();
|
|
155
155
|
afterTest();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["config","fps","isAnimatedStyle","style","animatedStyle","getAnimatedStyleFromObject","current","value","getCurrentStyle","received","styleObject","props","currentStyle","Array","isArray","forEach","checkEqual","expectStyle","length","i","property","findStyleDiff","expect","requireAllMatch","diffs","isEqual","push","Object","keys","undefined","compareStyle","expectedStyle","message","pass","exact","currentStyleStr","JSON","stringify","expectedStyleStr","differences","map","diff","join","frameTime","beforeTest","jest","useFakeTimers","afterTest","runOnlyPendingTimers","useRealTimers","withReanimatedTimer","animationTest","console","warn","advanceAnimationByTime","time","advanceTimersByTime","advanceAnimationByFrame","count","setUpTests","userConfig","global","expectModule","require","jestGlobals","extend","default","Math","round","toHaveAnimatedStyle","getAnimatedStyle"],"sources":["jestUtils.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-nocheck\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n interface Matchers<R> {\n toHaveAnimatedStyle(\n style: Record<string, unknown>[] | Record<string, unknown>\n ): R;\n }\n }\n}\n\nlet config = {\n fps: 60,\n};\n\nconst isAnimatedStyle = (style) => {\n return !!style.animatedStyle;\n};\n\nconst getAnimatedStyleFromObject = (style) => {\n return style.animatedStyle.current.value;\n};\n\nconst getCurrentStyle = (received) => {\n const styleObject = received.props.style;\n let currentStyle = {};\n if (Array.isArray(styleObject)) {\n received.props.style.forEach((style) => {\n if (isAnimatedStyle(style)) {\n currentStyle = {\n ...currentStyle,\n ...getAnimatedStyleFromObject(style),\n };\n } else {\n currentStyle = {\n ...currentStyle,\n ...style,\n };\n }\n });\n } else {\n if (isAnimatedStyle(styleObject)) {\n currentStyle = getAnimatedStyleFromObject(styleObject);\n } else {\n currentStyle = {\n ...styleObject,\n ...received.props.animatedStyle.value,\n };\n }\n }\n return currentStyle;\n};\n\nconst checkEqual = (currentStyle, expectStyle) => {\n if (Array.isArray(expectStyle)) {\n if (expectStyle.length !== currentStyle.length) return false;\n for (let i = 0; i < currentStyle.length; i++) {\n if (!checkEqual(currentStyle[i], expectStyle[i])) {\n return false;\n }\n }\n } else if (typeof currentStyle === 'object' && currentStyle) {\n for (const property in expectStyle) {\n if (!checkEqual(currentStyle[property], expectStyle[property])) {\n return false;\n }\n }\n } else {\n return currentStyle === expectStyle;\n }\n return true;\n};\n\nconst findStyleDiff = (current, expect, requireAllMatch) => {\n const diffs = [];\n let isEqual = true;\n for (const property in expect) {\n if (!checkEqual(current[property], expect[property])) {\n isEqual = false;\n diffs.push({\n property: property,\n current: current[property],\n expect: expect[property],\n });\n }\n }\n\n if (\n requireAllMatch &&\n Object.keys(current).length !== Object.keys(expect).length\n ) {\n isEqual = false;\n for (const property in current) {\n if (expect[property] === undefined) {\n diffs.push({\n property: property,\n current: current[property],\n expect: expect[property],\n });\n }\n }\n }\n\n return { isEqual, diffs };\n};\n\nconst compareStyle = (received, expectedStyle, config) => {\n if (!received.props.style) {\n return { message: () => message, pass: false };\n }\n const { exact } = config;\n const currentStyle = getCurrentStyle(received);\n const { isEqual, diffs } = findStyleDiff(currentStyle, expectedStyle, exact);\n\n if (isEqual) {\n return { message: () => 'ok', pass: true };\n }\n\n const currentStyleStr = JSON.stringify(currentStyle);\n const expectedStyleStr = JSON.stringify(expectedStyle);\n const differences = diffs\n .map(\n (diff) =>\n `- '${diff.property}' should be ${JSON.stringify(\n diff.expect\n )}, but is ${JSON.stringify(diff.current)}`\n )\n .join('\\n');\n\n return {\n message: () =>\n `Expected: ${expectedStyleStr}\\nReceived: ${currentStyleStr}\\n\\nDifferences:\\n${differences}`,\n pass: false,\n };\n};\n\nlet frameTime = 1000 / config.fps;\n\nconst beforeTest = () => {\n jest.useFakeTimers();\n};\n\nconst afterTest = () => {\n jest.runOnlyPendingTimers();\n jest.useRealTimers();\n};\n\nexport const withReanimatedTimer = (animationTest) => {\n console.warn(\n 'This method is deprecated, you shoulddefine your own before and after test hooks to enable jest.useFakeTimers(). Check out the documentation for details on testing'\n );\n beforeTest();\n animationTest();\n afterTest();\n};\n\nexport const advanceAnimationByTime = (time = frameTime) => {\n console.warn(\n 'This method is deprecated, use jest.advanceTimersByTime directly'\n );\n jest.advanceTimersByTime(time);\n jest.runOnlyPendingTimers();\n};\n\nexport const advanceAnimationByFrame = (count) => {\n console.warn(\n 'This method is deprecated, use jest.advanceTimersByTime directly'\n );\n jest.advanceTimersByTime(count * frameTime);\n jest.runOnlyPendingTimers();\n};\n\nexport const setUpTests = (userConfig = {}) => {\n let expect = global.expect;\n if (expect === undefined) {\n const expectModule = require('expect');\n expect = expectModule;\n // Starting from Jest 28, \"expect\" package uses named exports instead of default export.\n // So, requiring \"expect\" package doesn't give direct access to \"expect\" function anymore.\n // It gives access to the module object instead.\n // We use this info to detect if the project uses Jest 28 or higher.\n if (typeof expect === 'object') {\n const jestGlobals = require('@jest/globals');\n expect = jestGlobals.expect;\n }\n if (expect === undefined || expect.extend === undefined) {\n expect = expectModule.default;\n }\n }\n\n require('setimmediate');\n frameTime = Math.round(1000 / config.fps);\n\n config = {\n ...config,\n ...userConfig,\n };\n\n expect.extend({\n toHaveAnimatedStyle(received, expectedStyle, config = {}) {\n return compareStyle(received, expectedStyle, config);\n },\n });\n};\n\nexport const getAnimatedStyle = (received) => {\n return getCurrentStyle(received);\n};\n"],"mappings":";;;;;;AAAA;AACA;AAYA,IAAIA,MAAM,GAAG;EACXC,GAAG,EAAE;AADM,CAAb;;AAIA,MAAMC,eAAe,GAAIC,KAAD,IAAW;EACjC,OAAO,CAAC,CAACA,KAAK,CAACC,aAAf;AACD,CAFD;;AAIA,MAAMC,0BAA0B,GAAIF,KAAD,IAAW;EAC5C,OAAOA,KAAK,CAACC,aAAN,CAAoBE,OAApB,CAA4BC,KAAnC;AACD,CAFD;;AAIA,MAAMC,eAAe,GAAIC,QAAD,IAAc;EACpC,MAAMC,WAAW,GAAGD,QAAQ,CAACE,KAAT,CAAeR,KAAnC;EACA,IAAIS,YAAY,GAAG,EAAnB;;EACA,IAAIC,KAAK,CAACC,OAAN,CAAcJ,WAAd,CAAJ,EAAgC;IAC9BD,QAAQ,CAACE,KAAT,CAAeR,KAAf,CAAqBY,OAArB,CAA8BZ,KAAD,IAAW;MACtC,IAAID,eAAe,CAACC,KAAD,CAAnB,EAA4B;QAC1BS,YAAY,GAAG,EACb,GAAGA,YADU;UAEb,GAAGP,0BAA0B,CAACF,KAAD;QAFhB,CAAf;MAID,CALD,MAKO;QACLS,YAAY,GAAG,EACb,GAAGA,YADU;UAEb,GAAGT;QAFU,CAAf;MAID;IACF,CAZD;EAaD,CAdD,MAcO;IACL,IAAID,eAAe,CAACQ,WAAD,CAAnB,EAAkC;MAChCE,YAAY,GAAGP,0BAA0B,CAACK,WAAD,CAAzC;IACD,CAFD,MAEO;MACLE,YAAY,GAAG,E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AAItC,MAAM,GAAGuC,MAAM,CAACvC,MAApB;;EACA,IAAIA,MAAM,KAAKO,SAAf,EAA0B;IACxB,MAAMiC,YAAY,GAAGC,OAAO,CAAC,QAAD,CAA5B;;IACAzC,MAAM,GAAGwC,YAAT,CAFwB,CAGxB;IACA;IACA;IACA;;IACA,IAAI,OAAOxC,MAAP,KAAkB,QAAtB,EAAgC;MAC9B,MAAM0C,WAAW,GAAGD,OAAO,CAAC,eAAD,CAA3B;;MACAzC,MAAM,GAAG0C,WAAW,CAAC1C,MAArB;IACD;;IACD,IAAIA,MAAM,KAAKO,SAAX,IAAwBP,MAAM,CAAC2C,MAAP,KAAkBpC,SAA9C,EAAyD;MACvDP,MAAM,GAAGwC,YAAY,CAACI,OAAtB;IACD;EACF;;EAEDH,OAAO,CAAC,cAAD,CAAP;;EACApB,SAAS,GAAGwB,IAAI,CAACC,KAAL,CAAW,OAAOpE,MAAM,CAACC,GAAzB,CAAZ;EAEAD,MAAM,GAAG,EACP,GAAGA,MADI;IAEP,GAAG4D;EAFI,CAAT;EAKAtC,MAAM,CAAC2C,MAAP,CAAc;IACZI,mBAAmB,CAAC5D,QAAD,EAAWsB,aAAX,EAAuC;MAAA,IAAb/B,MAAa,uEAAJ,EAAI;MACxD,OAAO8B,YAAY,CAACrB,QAAD,EAAWsB,aAAX,EAA0B/B,MAA1B,CAAnB;IACD;;EAHW,CAAd;AAKD,CA/BM;;;;AAiCA,MAAMsE,gBAAgB,GAAI7D,QAAD,IAAc;EAC5C,OAAOD,eAAe,CAACC,QAAD,CAAtB;AACD,CAFM"}
|
|
1
|
+
{"version":3,"names":["config","fps","isAnimatedStyle","style","animatedStyle","getAnimatedStyleFromObject","current","value","getCurrentStyle","received","styleObject","props","currentStyle","Array","isArray","forEach","checkEqual","expectStyle","length","i","property","findStyleDiff","expect","requireAllMatch","diffs","isEqual","push","Object","keys","undefined","compareStyle","expectedStyle","message","pass","exact","currentStyleStr","JSON","stringify","expectedStyleStr","differences","map","diff","join","frameTime","beforeTest","jest","useFakeTimers","afterTest","runOnlyPendingTimers","useRealTimers","withReanimatedTimer","animationTest","console","warn","advanceAnimationByTime","time","advanceTimersByTime","advanceAnimationByFrame","count","setUpTests","userConfig","global","expectModule","require","jestGlobals","extend","default","Math","round","toHaveAnimatedStyle","getAnimatedStyle"],"sources":["jestUtils.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-nocheck\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n interface Matchers<R> {\n toHaveAnimatedStyle(\n style: Record<string, unknown>[] | Record<string, unknown>\n ): R;\n }\n }\n}\n\nlet config = {\n fps: 60,\n};\n\nconst isAnimatedStyle = (style) => {\n return !!style.animatedStyle;\n};\n\nconst getAnimatedStyleFromObject = (style) => {\n return style.animatedStyle.current.value;\n};\n\nconst getCurrentStyle = (received) => {\n const styleObject = received.props.style;\n let currentStyle = {};\n if (Array.isArray(styleObject)) {\n received.props.style.forEach((style) => {\n if (isAnimatedStyle(style)) {\n currentStyle = {\n ...currentStyle,\n ...getAnimatedStyleFromObject(style),\n };\n } else {\n currentStyle = {\n ...currentStyle,\n ...style,\n };\n }\n });\n } else {\n if (isAnimatedStyle(styleObject)) {\n currentStyle = getAnimatedStyleFromObject(styleObject);\n } else {\n currentStyle = {\n ...styleObject,\n ...received.props.animatedStyle.value,\n };\n }\n }\n return currentStyle;\n};\n\nconst checkEqual = (currentStyle, expectStyle) => {\n if (Array.isArray(expectStyle)) {\n if (expectStyle.length !== currentStyle.length) return false;\n for (let i = 0; i < currentStyle.length; i++) {\n if (!checkEqual(currentStyle[i], expectStyle[i])) {\n return false;\n }\n }\n } else if (typeof currentStyle === 'object' && currentStyle) {\n for (const property in expectStyle) {\n if (!checkEqual(currentStyle[property], expectStyle[property])) {\n return false;\n }\n }\n } else {\n return currentStyle === expectStyle;\n }\n return true;\n};\n\nconst findStyleDiff = (current, expect, requireAllMatch) => {\n const diffs = [];\n let isEqual = true;\n for (const property in expect) {\n if (!checkEqual(current[property], expect[property])) {\n isEqual = false;\n diffs.push({\n property: property,\n current: current[property],\n expect: expect[property],\n });\n }\n }\n\n if (\n requireAllMatch &&\n Object.keys(current).length !== Object.keys(expect).length\n ) {\n isEqual = false;\n for (const property in current) {\n if (expect[property] === undefined) {\n diffs.push({\n property: property,\n current: current[property],\n expect: expect[property],\n });\n }\n }\n }\n\n return { isEqual, diffs };\n};\n\nconst compareStyle = (received, expectedStyle, config) => {\n if (!received.props.style) {\n return { message: () => message, pass: false };\n }\n const { exact } = config;\n const currentStyle = getCurrentStyle(received);\n const { isEqual, diffs } = findStyleDiff(currentStyle, expectedStyle, exact);\n\n if (isEqual) {\n return { message: () => 'ok', pass: true };\n }\n\n const currentStyleStr = JSON.stringify(currentStyle);\n const expectedStyleStr = JSON.stringify(expectedStyle);\n const differences = diffs\n .map(\n (diff) =>\n `- '${diff.property}' should be ${JSON.stringify(\n diff.expect\n )}, but is ${JSON.stringify(diff.current)}`\n )\n .join('\\n');\n\n return {\n message: () =>\n `Expected: ${expectedStyleStr}\\nReceived: ${currentStyleStr}\\n\\nDifferences:\\n${differences}`,\n pass: false,\n };\n};\n\nlet frameTime = 1000 / config.fps;\n\nconst beforeTest = () => {\n jest.useFakeTimers();\n};\n\nconst afterTest = () => {\n jest.runOnlyPendingTimers();\n jest.useRealTimers();\n};\n\nexport const withReanimatedTimer = (animationTest) => {\n console.warn(\n 'This method is deprecated, you should define your own before and after test hooks to enable jest.useFakeTimers(). Check out the documentation for details on testing'\n );\n beforeTest();\n animationTest();\n afterTest();\n};\n\nexport const advanceAnimationByTime = (time = frameTime) => {\n console.warn(\n 'This method is deprecated, use jest.advanceTimersByTime directly'\n );\n jest.advanceTimersByTime(time);\n jest.runOnlyPendingTimers();\n};\n\nexport const advanceAnimationByFrame = (count) => {\n console.warn(\n 'This method is deprecated, use jest.advanceTimersByTime directly'\n );\n jest.advanceTimersByTime(count * frameTime);\n jest.runOnlyPendingTimers();\n};\n\nexport const setUpTests = (userConfig = {}) => {\n let expect = global.expect;\n if (expect === undefined) {\n const expectModule = require('expect');\n expect = expectModule;\n // Starting from Jest 28, \"expect\" package uses named exports instead of default export.\n // So, requiring \"expect\" package doesn't give direct access to \"expect\" function anymore.\n // It gives access to the module object instead.\n // We use this info to detect if the project uses Jest 28 or higher.\n if (typeof expect === 'object') {\n const jestGlobals = require('@jest/globals');\n expect = jestGlobals.expect;\n }\n if (expect === undefined || expect.extend === undefined) {\n expect = expectModule.default;\n }\n }\n\n require('setimmediate');\n frameTime = Math.round(1000 / config.fps);\n\n config = {\n ...config,\n ...userConfig,\n };\n\n expect.extend({\n toHaveAnimatedStyle(received, expectedStyle, config = {}) {\n return compareStyle(received, expectedStyle, config);\n },\n });\n};\n\nexport const getAnimatedStyle = (received) => {\n return getCurrentStyle(received);\n};\n"],"mappings":";;;;;;AAAA;AACA;AAYA,IAAIA,MAAM,GAAG;EACXC,GAAG,EAAE;AADM,CAAb;;AAIA,MAAMC,eAAe,GAAIC,KAAD,IAAW;EACjC,OAAO,CAAC,CAACA,KAAK,CAACC,aAAf;AACD,CAFD;;AAIA,MAAMC,0BAA0B,GAAIF,KAAD,IAAW;EAC5C,OAAOA,KAAK,CAACC,aAAN,CAAoBE,OAApB,CAA4BC,KAAnC;AACD,CAFD;;AAIA,MAAMC,eAAe,GAAIC,QAAD,IAAc;EACpC,MAAMC,WAAW,GAAGD,QAAQ,CAACE,KAAT,CAAeR,KAAnC;EACA,IAAIS,YAAY,GAAG,EAAnB;;EACA,IAAIC,KAAK,CAACC,OAAN,CAAcJ,WAAd,CAAJ,EAAgC;IAC9BD,QAAQ,CAACE,KAAT,CAAeR,KAAf,CAAqBY,OAArB,CAA8BZ,KAAD,IAAW;MACtC,IAAID,eAAe,CAACC,KAAD,CAAnB,EAA4B;QAC1BS,YAAY,GAAG,EACb,GAAGA,YADU;UAEb,GAAGP,0BAA0B,CAACF,KAAD;QAFhB,CAAf;MAID,CALD,MAKO;QACLS,YA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|
7
7
|
|
|
8
8
|
var _NativeReanimated = require("../NativeReanimated/NativeReanimated");
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _commonTypes = require("../commonTypes");
|
|
11
|
+
|
|
12
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
11
13
|
|
|
12
14
|
class JSReanimated extends _NativeReanimated.NativeReanimated {
|
|
13
15
|
constructor() {
|
|
14
16
|
super(false);
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
// for tests, we use Date.now instead
|
|
20
|
-
this.getTimestamp = () => Date.now();
|
|
21
|
-
} else {
|
|
22
|
-
this.getTimestamp = () => window.performance.now();
|
|
23
|
-
}
|
|
18
|
+
_defineProperty(this, "nextSensorId", 0);
|
|
19
|
+
|
|
20
|
+
_defineProperty(this, "sensors", new Map());
|
|
24
21
|
}
|
|
25
22
|
|
|
26
23
|
makeShareableClone(value) {
|
|
@@ -49,12 +46,61 @@ class JSReanimated extends _NativeReanimated.NativeReanimated {
|
|
|
49
46
|
console.warn('[Reanimated] enableLayoutAnimations is not available for WEB yet');
|
|
50
47
|
}
|
|
51
48
|
|
|
52
|
-
registerSensor() {
|
|
53
|
-
|
|
54
|
-
|
|
49
|
+
registerSensor(sensorType, interval, iosReferenceFrame, eventHandler) {
|
|
50
|
+
if (!(this.getSensorName(sensorType) in window)) {
|
|
51
|
+
return -1;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const sensor = this.initializeSensor(sensorType, interval);
|
|
55
|
+
let callback;
|
|
56
|
+
|
|
57
|
+
if (sensorType === _commonTypes.SensorType.ROTATION) {
|
|
58
|
+
callback = () => {
|
|
59
|
+
const [qw, qx, qy, qz] = sensor.quaternion; // reference: https://stackoverflow.com/questions/5782658/extracting-yaw-from-a-quaternion
|
|
60
|
+
|
|
61
|
+
const yaw = Math.atan2(2.0 * (qy * qz + qw * qx), qw * qw - qx * qx - qy * qy + qz * qz);
|
|
62
|
+
const pitch = Math.sin(-2.0 * (qx * qz - qw * qy));
|
|
63
|
+
const roll = Math.atan2(2.0 * (qx * qy + qw * qz), qw * qw + qx * qx - qy * qy - qz * qz);
|
|
64
|
+
eventHandler({
|
|
65
|
+
qw,
|
|
66
|
+
qx,
|
|
67
|
+
qy,
|
|
68
|
+
qz,
|
|
69
|
+
yaw,
|
|
70
|
+
pitch,
|
|
71
|
+
roll,
|
|
72
|
+
interfaceOrientation: 0
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
} else {
|
|
76
|
+
callback = () => {
|
|
77
|
+
const {
|
|
78
|
+
x,
|
|
79
|
+
y,
|
|
80
|
+
z
|
|
81
|
+
} = sensor;
|
|
82
|
+
eventHandler({
|
|
83
|
+
x,
|
|
84
|
+
y,
|
|
85
|
+
z,
|
|
86
|
+
interfaceOrientation: 0
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
sensor.addEventListener('reading', callback);
|
|
92
|
+
sensor.start();
|
|
93
|
+
this.sensors.set(this.nextSensorId, sensor);
|
|
94
|
+
return this.nextSensorId++;
|
|
55
95
|
}
|
|
56
96
|
|
|
57
|
-
unregisterSensor() {
|
|
97
|
+
unregisterSensor(id) {
|
|
98
|
+
const sensor = this.sensors.get(id);
|
|
99
|
+
|
|
100
|
+
if (sensor !== undefined) {
|
|
101
|
+
sensor.stop();
|
|
102
|
+
this.sensors.delete(id);
|
|
103
|
+
}
|
|
58
104
|
}
|
|
59
105
|
|
|
60
106
|
subscribeForKeyboardEvents(_) {
|
|
@@ -65,6 +111,50 @@ class JSReanimated extends _NativeReanimated.NativeReanimated {
|
|
|
65
111
|
unsubscribeFromKeyboardEvents(_) {// noop
|
|
66
112
|
}
|
|
67
113
|
|
|
114
|
+
initializeSensor(sensorType, interval) {
|
|
115
|
+
const config = interval <= 0 ? {
|
|
116
|
+
referenceFrame: 'device'
|
|
117
|
+
} : {
|
|
118
|
+
frequency: 1000 / interval
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
switch (sensorType) {
|
|
122
|
+
case _commonTypes.SensorType.ACCELEROMETER:
|
|
123
|
+
return new window.Accelerometer(config);
|
|
124
|
+
|
|
125
|
+
case _commonTypes.SensorType.GYROSCOPE:
|
|
126
|
+
return new window.Gyroscope(config);
|
|
127
|
+
|
|
128
|
+
case _commonTypes.SensorType.GRAVITY:
|
|
129
|
+
return new window.GravitySensor(config);
|
|
130
|
+
|
|
131
|
+
case _commonTypes.SensorType.MAGNETIC_FIELD:
|
|
132
|
+
return new window.Magnetometer(config);
|
|
133
|
+
|
|
134
|
+
case _commonTypes.SensorType.ROTATION:
|
|
135
|
+
return new window.AbsoluteOrientationSensor(config);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
getSensorName(sensorType) {
|
|
140
|
+
switch (sensorType) {
|
|
141
|
+
case _commonTypes.SensorType.ACCELEROMETER:
|
|
142
|
+
return 'Accelerometer';
|
|
143
|
+
|
|
144
|
+
case _commonTypes.SensorType.GRAVITY:
|
|
145
|
+
return 'GravitySensor';
|
|
146
|
+
|
|
147
|
+
case _commonTypes.SensorType.GYROSCOPE:
|
|
148
|
+
return 'Gyroscope';
|
|
149
|
+
|
|
150
|
+
case _commonTypes.SensorType.MAGNETIC_FIELD:
|
|
151
|
+
return 'Magnetometer';
|
|
152
|
+
|
|
153
|
+
case _commonTypes.SensorType.ROTATION:
|
|
154
|
+
return 'AbsoluteOrientationSensor';
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
68
158
|
}
|
|
69
159
|
|
|
70
160
|
exports.default = JSReanimated;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["JSReanimated","NativeReanimated","constructor","
|
|
1
|
+
{"version":3,"names":["JSReanimated","NativeReanimated","constructor","Map","makeShareableClone","value","__hostObjectShareableJSRef","installCoreFunctions","_callGuard","_valueUnpacker","scheduleOnUI","worklet","requestAnimationFrame","registerEventHandler","_eventHash","_eventHandler","unregisterEventHandler","_","enableLayoutAnimations","console","warn","registerSensor","sensorType","interval","iosReferenceFrame","eventHandler","getSensorName","window","sensor","initializeSensor","callback","SensorType","ROTATION","qw","qx","qy","qz","quaternion","yaw","Math","atan2","pitch","sin","roll","interfaceOrientation","x","y","z","addEventListener","start","sensors","set","nextSensorId","unregisterSensor","id","get","undefined","stop","delete","subscribeForKeyboardEvents","unsubscribeFromKeyboardEvents","config","referenceFrame","frequency","ACCELEROMETER","Accelerometer","GYROSCOPE","Gyroscope","GRAVITY","GravitySensor","MAGNETIC_FIELD","Magnetometer","AbsoluteOrientationSensor"],"sources":["JSReanimated.ts"],"sourcesContent":["import { NativeReanimated } from '../NativeReanimated/NativeReanimated';\nimport {\n SensorType,\n ShareableRef,\n Value3D,\n ValueRotation,\n} from '../commonTypes';\nimport { WebSensor } from './WebSensor';\n\nexport default class JSReanimated extends NativeReanimated {\n nextSensorId = 0;\n sensors = new Map<number, WebSensor>();\n\n constructor() {\n super(false);\n }\n\n makeShareableClone<T>(value: T): ShareableRef<T> {\n return { __hostObjectShareableJSRef: value };\n }\n\n installCoreFunctions(\n _callGuard: <T extends Array<any>, U>(\n fn: (...args: T) => U,\n ...args: T\n ) => void,\n _valueUnpacker: <T>(value: T) => T\n ): void {\n // noop\n }\n\n scheduleOnUI<T>(worklet: ShareableRef<T>) {\n // @ts-ignore web implementation has still not been updated after the rewrite, this will be addressed once the web implementation updates are ready\n requestAnimationFrame(worklet);\n }\n\n registerEventHandler<T>(\n _eventHash: string,\n _eventHandler: ShareableRef<T>\n ): string {\n // noop\n return '';\n }\n\n unregisterEventHandler(_: string): void {\n // noop\n }\n\n enableLayoutAnimations() {\n console.warn(\n '[Reanimated] enableLayoutAnimations is not available for WEB yet'\n );\n }\n\n registerSensor(\n sensorType: SensorType,\n interval: number,\n iosReferenceFrame: number,\n eventHandler: (data: Value3D | ValueRotation) => void\n ): number {\n if (!(this.getSensorName(sensorType) in window)) {\n return -1;\n }\n\n const sensor: WebSensor = this.initializeSensor(sensorType, interval);\n let callback;\n if (sensorType === SensorType.ROTATION) {\n callback = () => {\n const [qw, qx, qy, qz] = sensor.quaternion;\n\n // reference: https://stackoverflow.com/questions/5782658/extracting-yaw-from-a-quaternion\n const yaw = Math.atan2(\n 2.0 * (qy * qz + qw * qx),\n qw * qw - qx * qx - qy * qy + qz * qz\n );\n const pitch = Math.sin(-2.0 * (qx * qz - qw * qy));\n const roll = Math.atan2(\n 2.0 * (qx * qy + qw * qz),\n qw * qw + qx * qx - qy * qy - qz * qz\n );\n eventHandler({\n qw,\n qx,\n qy,\n qz,\n yaw,\n pitch,\n roll,\n interfaceOrientation: 0,\n });\n };\n } else {\n callback = () => {\n const { x, y, z } = sensor;\n eventHandler({ x, y, z, interfaceOrientation: 0 });\n };\n }\n sensor.addEventListener('reading', callback);\n sensor.start();\n\n this.sensors.set(this.nextSensorId, sensor);\n return this.nextSensorId++;\n }\n\n unregisterSensor(id: number): void {\n const sensor: WebSensor | undefined = this.sensors.get(id);\n if (sensor !== undefined) {\n sensor.stop();\n this.sensors.delete(id);\n }\n }\n\n subscribeForKeyboardEvents(_: ShareableRef<number>): number {\n console.warn(\n '[Reanimated] useAnimatedKeyboard is not available on web yet.'\n );\n return -1;\n }\n\n unsubscribeFromKeyboardEvents(_: number): void {\n // noop\n }\n\n initializeSensor(sensorType: SensorType, interval: number): WebSensor {\n const config =\n interval <= 0\n ? { referenceFrame: 'device' }\n : { frequency: 1000 / interval };\n switch (sensorType) {\n case SensorType.ACCELEROMETER:\n return new window.Accelerometer(config);\n case SensorType.GYROSCOPE:\n return new window.Gyroscope(config);\n case SensorType.GRAVITY:\n return new window.GravitySensor(config);\n case SensorType.MAGNETIC_FIELD:\n return new window.Magnetometer(config);\n case SensorType.ROTATION:\n return new window.AbsoluteOrientationSensor(config);\n }\n }\n\n getSensorName(sensorType: SensorType): string {\n switch (sensorType) {\n case SensorType.ACCELEROMETER:\n return 'Accelerometer';\n case SensorType.GRAVITY:\n return 'GravitySensor';\n case SensorType.GYROSCOPE:\n return 'Gyroscope';\n case SensorType.MAGNETIC_FIELD:\n return 'Magnetometer';\n case SensorType.ROTATION:\n return 'AbsoluteOrientationSensor';\n }\n }\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;;;AAQe,MAAMA,YAAN,SAA2BC,kCAA3B,CAA4C;EAIzDC,WAAW,GAAG;IACZ,MAAM,KAAN;;IADY,sCAHC,CAGD;;IAAA,iCAFJ,IAAIC,GAAJ,EAEI;EAEb;;EAEDC,kBAAkB,CAAIC,KAAJ,EAA+B;IAC/C,OAAO;MAAEC,0BAA0B,EAAED;IAA9B,CAAP;EACD;;EAEDE,oBAAoB,CAClBC,UADkB,EAKlBC,cALkB,EAMZ,CACN;EACD;;EAEDC,YAAY,CAAIC,OAAJ,EAA8B;IACxC;IACAC,qBAAqB,CAACD,OAAD,CAArB;EACD;;EAEDE,oBAAoB,CAClBC,UADkB,EAElBC,aAFkB,EAGV;IACR;IACA,OAAO,EAAP;EACD;;EAEDC,sBAAsB,CAACC,CAAD,EAAkB,CACtC;EACD;;EAEDC,sBAAsB,GAAG;IACvBC,OAAO,CAACC,IAAR,CACE,kEADF;EAGD;;EAEDC,cAAc,CACZC,UADY,EAEZC,QAFY,EAGZC,iBAHY,EAIZC,YAJY,EAKJ;IACR,IAAI,EAAE,KAAKC,aAAL,CAAmBJ,UAAnB,KAAkCK,MAApC,CAAJ,EAAiD;MAC/C,OAAO,CAAC,CAAR;IACD;;IAED,MAAMC,MAAiB,GAAG,KAAKC,gBAAL,CAAsBP,UAAtB,EAAkCC,QAAlC,CAA1B;IACA,IAAIO,QAAJ;;IACA,IAAIR,UAAU,KAAKS,uBAAA,CAAWC,QAA9B,EAAwC;MACtCF,QAAQ,GAAG,MAAM;QACf,MAAM,CAACG,EAAD,EAAKC,EAAL,EAASC,EAAT,EAAaC,EAAb,IAAmBR,MAAM,CAACS,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,CAAWmC,SAAhB;QACE,OAAO,WAAP;;MACF,KAAKnC,uBAAA,CAAWuC,cAAhB;QACE,OAAO,cAAP;;MACF,KAAKvC,uBAAA,CAAWC,QAAhB;QACE,OAAO,2BAAP;IAVJ;EAYD;;AAlJwD"}
|
|
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
+
var _PlatformChecker = require("../PlatformChecker");
|
|
9
|
+
|
|
8
10
|
var _MutableValue = _interopRequireDefault(require("./MutableValue"));
|
|
9
11
|
|
|
10
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -55,6 +57,8 @@ class Mapper {
|
|
|
55
57
|
res.push(value);
|
|
56
58
|
} else if (Array.isArray(value)) {
|
|
57
59
|
value.forEach(v => extractMutables(v));
|
|
60
|
+
} else if (isWebDomElement(value)) {// do nothing on dom elements
|
|
61
|
+
// without this check, we get a "Maximum call size exceeded error"
|
|
58
62
|
} else if (typeof value === 'object') {
|
|
59
63
|
Object.keys(value).forEach(key => {
|
|
60
64
|
extractMutables(value[key]);
|
|
@@ -71,4 +75,22 @@ class Mapper {
|
|
|
71
75
|
exports.default = Mapper;
|
|
72
76
|
|
|
73
77
|
_defineProperty(Mapper, "MAPPER_ID", 1);
|
|
78
|
+
|
|
79
|
+
function isWebDomElement(value) {
|
|
80
|
+
if (!(0, _PlatformChecker.shouldBeUseWeb)()) {
|
|
81
|
+
return false;
|
|
82
|
+
} // https://stackoverflow.com/a/384380/7869175
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
function isWebNode(o) {
|
|
86
|
+
return typeof Node === 'object' ? o instanceof Node : o && typeof o === 'object' && typeof o.nodeType === 'number' && typeof o.nodeName === 'string';
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function isWebElement(o) {
|
|
90
|
+
return typeof HTMLElement === 'object' ? o instanceof HTMLElement // DOM2
|
|
91
|
+
: o && typeof o === 'object' && o !== null && o.nodeType === 1 && typeof o.nodeName === 'string';
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return isWebNode(value) || isWebElement(value);
|
|
95
|
+
}
|
|
74
96
|
//# sourceMappingURL=Mapper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Mapper","constructor","module","mapper","inputs","outputs","id","MAPPER_ID","extractMutablesFromArray","markDirty","dirty","maybeRequestRender","forEach","input","addListener","execute","array","res","extractMutables","value","MutableValue","push","Array","isArray","v","Object","keys","key"],"sources":["Mapper.ts"],"sourcesContent":["import { NestedObjectValues } from '../commonTypes';\nimport { JSReanimated } from './commonTypes';\nimport MutableValue from './MutableValue';\n\nexport default class Mapper<T> {\n static MAPPER_ID = 1;\n id: number;\n inputs: MutableValue<T>[];\n outputs: MutableValue<T>[];\n mapper: () => void;\n\n dirty = true;\n\n constructor(\n module: JSReanimated,\n mapper: () => void,\n inputs: NestedObjectValues<MutableValue<T>>[] = [],\n outputs: NestedObjectValues<MutableValue<T>>[] = []\n ) {\n this.id = Mapper.MAPPER_ID++;\n this.inputs = this.extractMutablesFromArray(inputs);\n this.outputs = this.extractMutablesFromArray(outputs);\n this.mapper = mapper;\n\n const markDirty = () => {\n this.dirty = true;\n module.maybeRequestRender();\n };\n\n this.inputs.forEach((input) => {\n input.addListener(markDirty);\n });\n }\n\n execute(): void {\n this.dirty = false;\n this.mapper();\n }\n\n extractMutablesFromArray<T>(\n array: NestedObjectValues<MutableValue<T>>\n ): MutableValue<T>[] {\n const res: MutableValue<T>[] = [];\n\n function extractMutables(value: NestedObjectValues<MutableValue<T>>) {\n if (value == null) {\n // return;\n } else if (value instanceof MutableValue) {\n res.push(value);\n } else if (Array.isArray(value)) {\n value.forEach((v) => extractMutables(v));\n } else if (typeof value === 'object') {\n Object.keys(value).forEach((key) => {\n extractMutables(value[key]);\n });\n }\n }\n\n extractMutables(array);\n return res;\n }\n}\n"],"mappings":";;;;;;;AAEA;;;;;;AAEe,MAAMA,MAAN,CAAgB;EAS7BC,WAAW,CACTC,MADS,EAETC,MAFS,EAKT;IAAA,IAFAC,MAEA,uEAFgD,EAEhD;IAAA,IADAC,OACA,uEADiD,EACjD;;IAAA;;IAAA;;IAAA;;IAAA;;IAAA,+BAPM,IAON;;IACA,KAAKC,EAAL,GAAUN,MAAM,CAACO,SAAP,EAAV;IACA,KAAKH,MAAL,GAAc,KAAKI,wBAAL,CAA8BJ,MAA9B,CAAd;IACA,KAAKC,OAAL,GAAe,KAAKG,wBAAL,CAA8BH,OAA9B,CAAf;IACA,KAAKF,MAAL,GAAcA,MAAd;;IAEA,MAAMM,SAAS,GAAG,MAAM;MACtB,KAAKC,KAAL,GAAa,IAAb;MACAR,MAAM,CAACS,kBAAP;IACD,CAHD;;IAKA,KAAKP,MAAL,CAAYQ,OAAZ,CAAqBC,KAAD,IAAW;MAC7BA,KAAK,CAACC,WAAN,CAAkBL,SAAlB;IACD,CAFD;EAGD;;EAEDM,OAAO,GAAS;IACd,KAAKL,KAAL,GAAa,KAAb;IACA,KAAKP,MAAL;EACD;;EAEDK,wBAAwB,CACtBQ,KADsB,EAEH;IACnB,MAAMC,GAAsB,GAAG,EAA/B;;IAEA,SAASC,eAAT,CAAyBC,KAAzB,EAAqE;MACnE,IAAIA,KAAK,IAAI,IAAb,EAAmB,CACjB;MACD,CAFD,MAEO,IAAIA,KAAK,YAAYC,qBAArB,EAAmC;QACxCH,GAAG,CAACI,IAAJ,CAASF,KAAT;MACD,CAFM,MAEA,IAAIG,KAAK,CAACC,OAAN,CAAcJ,KAAd,CAAJ,EAA0B;QAC/BA,KAAK,CAACP,OAAN,CAAeY,CAAD,IAAON,eAAe,CAACM,CAAD,CAApC;MACD,CAFM,MAEA,IAAI,
|
|
1
|
+
{"version":3,"names":["Mapper","constructor","module","mapper","inputs","outputs","id","MAPPER_ID","extractMutablesFromArray","markDirty","dirty","maybeRequestRender","forEach","input","addListener","execute","array","res","extractMutables","value","MutableValue","push","Array","isArray","v","isWebDomElement","Object","keys","key","shouldBeUseWeb","isWebNode","o","Node","nodeType","nodeName","isWebElement","HTMLElement"],"sources":["Mapper.ts"],"sourcesContent":["import { NestedObjectValues } from '../commonTypes';\nimport { shouldBeUseWeb } from '../PlatformChecker';\nimport { JSReanimated } from './commonTypes';\nimport MutableValue from './MutableValue';\n\nexport default class Mapper<T> {\n static MAPPER_ID = 1;\n id: number;\n inputs: MutableValue<T>[];\n outputs: MutableValue<T>[];\n mapper: () => void;\n\n dirty = true;\n\n constructor(\n module: JSReanimated,\n mapper: () => void,\n inputs: NestedObjectValues<MutableValue<T>>[] = [],\n outputs: NestedObjectValues<MutableValue<T>>[] = []\n ) {\n this.id = Mapper.MAPPER_ID++;\n this.inputs = this.extractMutablesFromArray(inputs);\n this.outputs = this.extractMutablesFromArray(outputs);\n this.mapper = mapper;\n\n const markDirty = () => {\n this.dirty = true;\n module.maybeRequestRender();\n };\n\n this.inputs.forEach((input) => {\n input.addListener(markDirty);\n });\n }\n\n execute(): void {\n this.dirty = false;\n this.mapper();\n }\n\n extractMutablesFromArray<T>(\n array: NestedObjectValues<MutableValue<T>>\n ): MutableValue<T>[] {\n const res: MutableValue<T>[] = [];\n\n function extractMutables(value: NestedObjectValues<MutableValue<T>>) {\n if (value == null) {\n // return;\n } else if (value instanceof MutableValue) {\n res.push(value);\n } else if (Array.isArray(value)) {\n value.forEach((v) => extractMutables(v));\n } else if (isWebDomElement(value)) {\n // do nothing on dom elements\n // without this check, we get a \"Maximum call size exceeded error\"\n } else if (typeof value === 'object') {\n Object.keys(value).forEach((key) => {\n extractMutables(value[key]);\n });\n }\n }\n\n extractMutables(array);\n return res;\n }\n}\n\nfunction isWebDomElement(value: any) {\n if (!shouldBeUseWeb()) {\n return false;\n }\n\n // https://stackoverflow.com/a/384380/7869175\n function isWebNode(o: any) {\n return typeof Node === 'object'\n ? o instanceof Node\n : o &&\n typeof o === 'object' &&\n typeof o.nodeType === 'number' &&\n typeof o.nodeName === 'string';\n }\n\n function isWebElement(o: any) {\n return typeof HTMLElement === 'object'\n ? o instanceof HTMLElement // DOM2\n : o &&\n typeof o === 'object' &&\n o !== null &&\n o.nodeType === 1 &&\n typeof o.nodeName === 'string';\n }\n\n return isWebNode(value) || isWebElement(value);\n}\n"],"mappings":";;;;;;;AACA;;AAEA;;;;;;AAEe,MAAMA,MAAN,CAAgB;EAS7BC,WAAW,CACTC,MADS,EAETC,MAFS,EAKT;IAAA,IAFAC,MAEA,uEAFgD,EAEhD;IAAA,IADAC,OACA,uEADiD,EACjD;;IAAA;;IAAA;;IAAA;;IAAA;;IAAA,+BAPM,IAON;;IACA,KAAKC,EAAL,GAAUN,MAAM,CAACO,SAAP,EAAV;IACA,KAAKH,MAAL,GAAc,KAAKI,wBAAL,CAA8BJ,MAA9B,CAAd;IACA,KAAKC,OAAL,GAAe,KAAKG,wBAAL,CAA8BH,OAA9B,CAAf;IACA,KAAKF,MAAL,GAAcA,MAAd;;IAEA,MAAMM,SAAS,GAAG,MAAM;MACtB,KAAKC,KAAL,GAAa,IAAb;MACAR,MAAM,CAACS,kBAAP;IACD,CAHD;;IAKA,KAAKP,MAAL,CAAYQ,OAAZ,CAAqBC,KAAD,IAAW;MAC7BA,KAAK,CAACC,WAAN,CAAkBL,SAAlB;IACD,CAFD;EAGD;;EAEDM,OAAO,GAAS;IACd,KAAKL,KAAL,GAAa,KAAb;IACA,KAAKP,MAAL;EACD;;EAEDK,wBAAwB,CACtBQ,KADsB,EAEH;IACnB,MAAMC,GAAsB,GAAG,EAA/B;;IAEA,SAASC,eAAT,CAAyBC,KAAzB,EAAqE;MACnE,IAAIA,KAAK,IAAI,IAAb,EAAmB,CACjB;MACD,CAFD,MAEO,IAAIA,KAAK,YAAYC,qBAArB,EAAmC;QACxCH,GAAG,CAACI,IAAJ,CAASF,KAAT;MACD,CAFM,MAEA,IAAIG,KAAK,CAACC,OAAN,CAAcJ,KAAd,CAAJ,EAA0B;QAC/BA,KAAK,CAACP,OAAN,CAAeY,CAAD,IAAON,eAAe,CAACM,CAAD,CAApC;MACD,CAFM,MAEA,IAAIC,eAAe,CAACN,KAAD,CAAnB,EAA4B,CACjC;QACA;MACD,CAHM,MAGA,IAAI,OAAOA,KAAP,KAAiB,QAArB,EAA+B;QACpCO,MAAM,CAACC,IAAP,CAAYR,KAAZ,EAAmBP,OAAnB,CAA4BgB,GAAD,IAAS;UAClCV,eAAe,CAACC,KAAK,CAACS,GAAD,CAAN,CAAf;QACD,CAFD;MAGD;IACF;;IAEDV,eAAe,CAACF,KAAD,CAAf;IACA,OAAOC,GAAP;EACD;;AA3D4B;;;;gBAAVjB,M,eACA,C;;AA6DrB,SAASyB,eAAT,CAAyBN,KAAzB,EAAqC;EACnC,IAAI,CAAC,IAAAU,+BAAA,GAAL,EAAuB;IACrB,OAAO,KAAP;EACD,CAHkC,CAKnC;;;EACA,SAASC,SAAT,CAAmBC,CAAnB,EAA2B;IACzB,OAAO,OAAOC,IAAP,KAAgB,QAAhB,GACHD,CAAC,YAAYC,IADV,GAEHD,CAAC,IACC,OAAOA,CAAP,KAAa,QADf,IAEE,OAAOA,CAAC,CAACE,QAAT,KAAsB,QAFxB,IAGE,OAAOF,CAAC,CAACG,QAAT,KAAsB,QAL5B;EAMD;;EAED,SAASC,YAAT,CAAsBJ,CAAtB,EAA8B;IAC5B,OAAO,OAAOK,WAAP,KAAuB,QAAvB,GACHL,CAAC,YAAYK,WADV,CACsB;IADtB,EAEHL,CAAC,IACC,OAAOA,CAAP,KAAa,QADf,IAEEA,CAAC,KAAK,IAFR,IAGEA,CAAC,CAACE,QAAF,KAAe,CAHjB,IAIE,OAAOF,CAAC,CAACG,QAAT,KAAsB,QAN5B;EAOD;;EAED,OAAOJ,SAAS,CAACX,KAAD,CAAT,IAAoBgB,YAAY,CAAChB,KAAD,CAAvC;AACD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["WebSensor.ts"],"sourcesContent":["export declare class WebSensor {\n start: () => void;\n stop: () => void;\n addEventListener: (eventType: string, eventHandler: () => void) => void;\n quaternion: [number, number, number, number];\n x: number;\n y: number;\n z: number;\n}\n\ntype configOptions =\n | {\n referenceFrame: string;\n frequency?: undefined;\n }\n | {\n frequency: number;\n referenceFrame?: undefined;\n };\n\ninterface Constructable<T> {\n new (config: configOptions): T;\n}\n\ndeclare global {\n interface Window {\n Accelerometer: Constructable<WebSensor>;\n GravitySensor: Constructable<WebSensor>;\n Gyroscope: Constructable<WebSensor>;\n Magnetometer: Constructable<WebSensor>;\n AbsoluteOrientationSensor: Constructable<WebSensor>;\n Sensor: Constructable<WebSensor>;\n }\n}\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["commonTypes.ts"],"sourcesContent":["import { Timestamp, NestedObjectValues } from '../commonTypes';\nimport MutableValue from './MutableValue';\n\nexport interface Mapper<T> {\n MAPPER_ID?: number;\n id: number;\n inputs: MutableValue<T>[];\n outputs: MutableValue<T>[];\n mapper: () => void;\n dirty: boolean;\n execute(): void;\n extractMutablesFromArray<T>(\n array: NestedObjectValues<MutableValue<T>>\n ): MutableValue<T>[];\n}\n\nexport interface MapperRegistry<T> {\n sortedMappers: Mapper<T>[];\n mappers: Map<number, Mapper<T>>;\n _module: JSReanimated;\n updatedSinceLastExecute: boolean;\n startMapper(mapper: Mapper<T>): number;\n stopMapper(id: number): void;\n execute(): void;\n updateOrder(): void;\n}\n\nexport interface JSReanimated {\n _valueSetter?: <T>(value: T) => void;\n _renderRequested: boolean;\n _mapperRegistry: MapperRegistry<any>;\n _frames: ((timestamp: Timestamp) => void)[];\n timeProvider: { now: () => number };\n pushFrame(frame: (timestamp: Timestamp) => void): void;\n
|
|
1
|
+
{"version":3,"names":[],"sources":["commonTypes.ts"],"sourcesContent":["import { Timestamp, NestedObjectValues } from '../commonTypes';\nimport MutableValue from './MutableValue';\n\nexport interface Mapper<T> {\n MAPPER_ID?: number;\n id: number;\n inputs: MutableValue<T>[];\n outputs: MutableValue<T>[];\n mapper: () => void;\n dirty: boolean;\n execute(): void;\n extractMutablesFromArray<T>(\n array: NestedObjectValues<MutableValue<T>>\n ): MutableValue<T>[];\n}\n\nexport interface MapperRegistry<T> {\n sortedMappers: Mapper<T>[];\n mappers: Map<number, Mapper<T>>;\n _module: JSReanimated;\n updatedSinceLastExecute: boolean;\n startMapper(mapper: Mapper<T>): number;\n stopMapper(id: number): void;\n execute(): void;\n updateOrder(): void;\n}\n\nexport interface JSReanimated {\n _valueSetter?: <T>(value: T) => void;\n _renderRequested: boolean;\n _mapperRegistry: MapperRegistry<any>;\n _frames: ((timestamp: Timestamp) => void)[];\n timeProvider: { now: () => number };\n pushFrame(frame: (timestamp: Timestamp) => void): void;\n maybeRequestRender(): void;\n _onRender(timestampMs: number): void;\n installCoreFunctions(valueSetter: <T>(value: T) => void): void;\n makeShareable<T>(value: T): T;\n makeMutable<T>(value: T): MutableValue<T>;\n makeRemote<T>(object: Record<string, any>): T;\n startMapper(\n mapper: () => void,\n inputs: NestedObjectValues<MutableValue<unknown>>[],\n outputs: NestedObjectValues<MutableValue<unknown>>[]\n ): number;\n stopMapper(mapperId: number): void;\n registerEventHandler<T>(_: string, __: (event: T) => void): string;\n unregisterEventHandler(_: string): void;\n enableLayoutAnimations(): void;\n}\n"],"mappings":""}
|
|
@@ -10,8 +10,6 @@ var _PlatformChecker = require("../PlatformChecker");
|
|
|
10
10
|
// In order to keep bundle size down, we treat this file as a polyfill for Web.
|
|
11
11
|
const initializeGlobalsForWeb = () => {
|
|
12
12
|
if ((0, _PlatformChecker.shouldBeUseWeb)()) {
|
|
13
|
-
global._frameTimestamp = null;
|
|
14
|
-
|
|
15
13
|
global._measure = () => {
|
|
16
14
|
console.warn("[Reanimated] You can't use `measure` with Chrome Debugger or with web version");
|
|
17
15
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["initializeGlobalsForWeb","shouldBeUseWeb","global","
|
|
1
|
+
{"version":3,"names":["initializeGlobalsForWeb","shouldBeUseWeb","global","_measure","console","warn","x","y","width","height","pageX","pageY","_scrollTo","_dispatchCommand","_setGestureState"],"sources":["global.ts"],"sourcesContent":["// In order to keep bundle size down, we treat this file as a polyfill for Web.\n\nimport { shouldBeUseWeb } from '../PlatformChecker';\nconst initializeGlobalsForWeb = () => {\n if (shouldBeUseWeb()) {\n global._measure = () => {\n console.warn(\n \"[Reanimated] You can't use `measure` with Chrome Debugger or with web version\"\n );\n return {\n x: 0,\n y: 0,\n width: 0,\n height: 0,\n pageX: 0,\n pageY: 0,\n };\n };\n global._scrollTo = () => {\n console.warn(\n \"[Reanimated] You can't use `scrollTo` with Chrome Debugger or with web version\"\n );\n };\n global._dispatchCommand = () => {\n console.warn(\n \"[Reanimated] You can't use `scrollTo` or `dispatchCommand` methods with Chrome Debugger or with web version\"\n );\n };\n global._setGestureState = () => {\n console.warn(\n \"[Reanimated] You can't use `setGestureState` with Chrome Debugger or with web version\"\n );\n };\n }\n return true;\n};\n\n/*\n If a file doesn't export anything, tree shaking doesn't pack\n it into the JS bundle. In effect, the code inside of this file\n will never execute. That is why we wrapped initialization code\n into a function, and we call this one during creating\n the module export object.\n*/\n\nexport default initializeGlobalsForWeb();\n"],"mappings":";;;;;;;AAEA;;AAFA;AAGA,MAAMA,uBAAuB,GAAG,MAAM;EACpC,IAAI,IAAAC,+BAAA,GAAJ,EAAsB;IACpBC,MAAM,CAACC,QAAP,GAAkB,MAAM;MACtBC,OAAO,CAACC,IAAR,CACE,+EADF;MAGA,OAAO;QACLC,CAAC,EAAE,CADE;QAELC,CAAC,EAAE,CAFE;QAGLC,KAAK,EAAE,CAHF;QAILC,MAAM,EAAE,CAJH;QAKLC,KAAK,EAAE,CALF;QAMLC,KAAK,EAAE;MANF,CAAP;IAQD,CAZD;;IAaAT,MAAM,CAACU,SAAP,GAAmB,MAAM;MACvBR,OAAO,CAACC,IAAR,CACE,gFADF;IAGD,CAJD;;IAKAH,MAAM,CAACW,gBAAP,GAA0B,MAAM;MAC9BT,OAAO,CAACC,IAAR,CACE,6GADF;IAGD,CAJD;;IAKAH,MAAM,CAACY,gBAAP,GAA0B,MAAM;MAC9BV,OAAO,CAACC,IAAR,CACE,uFADF;IAGD,CAJD;EAKD;;EACD,OAAO,IAAP;AACD,CAhCD;AAkCA;AACA;AACA;AACA;AACA;AACA;AACA;;;eAEeL,uBAAuB,E"}
|
|
@@ -14,7 +14,6 @@ const reanimatedJS = new _JSReanimated.default();
|
|
|
14
14
|
global._makeShareableClone = c => c;
|
|
15
15
|
|
|
16
16
|
global._scheduleOnJS = setImmediate;
|
|
17
|
-
global._getTimestamp = reanimatedJS.getTimestamp.bind(reanimatedJS);
|
|
18
17
|
|
|
19
18
|
const _updatePropsJS = (updates, viewRef) => {
|
|
20
19
|
if (viewRef._component) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["reanimatedJS","JSReanimated","global","_makeShareableClone","c","_scheduleOnJS","setImmediate","
|
|
1
|
+
{"version":3,"names":["reanimatedJS","JSReanimated","global","_makeShareableClone","c","_scheduleOnJS","setImmediate","_updatePropsJS","updates","viewRef","_component","component","rawStyles","Object","keys","reduce","acc","key","value","index","setNativeProps","props","length","forEach","dashedKey","replace","m","toLowerCase","_touchableNode","setAttribute","console","warn","style","previousStyle","currentStyle"],"sources":["index.ts"],"sourcesContent":["import JSReanimated from './JSReanimated';\nimport { AnimatedStyle, StyleProps } from '../commonTypes';\n\nconst reanimatedJS = new JSReanimated();\n\nglobal._makeShareableClone = (c) => c;\nglobal._scheduleOnJS = setImmediate;\n\ninterface JSReanimatedComponent {\n previousStyle: StyleProps;\n setNativeProps: (style: StyleProps) => void;\n props: Record<string, string | number>;\n _touchableNode: {\n setAttribute: (key: string, props: unknown) => void;\n };\n}\n\nexport const _updatePropsJS = (\n updates: StyleProps | AnimatedStyle,\n viewRef: { _component?: JSReanimatedComponent }\n): void => {\n if (viewRef._component) {\n const component = viewRef._component;\n const [rawStyles] = Object.keys(updates).reduce(\n (acc: [StyleProps, AnimatedStyle], key) => {\n const value = updates[key];\n const index = typeof value === 'function' ? 1 : 0;\n acc[index][key] = value;\n return acc;\n },\n [{}, {}]\n );\n\n if (typeof component.setNativeProps === 'function') {\n setNativeProps(component, rawStyles);\n } else if (Object.keys(component.props).length > 0) {\n Object.keys(component.props).forEach((key) => {\n if (!rawStyles[key]) {\n return;\n }\n const dashedKey = key.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase());\n component._touchableNode.setAttribute(dashedKey, rawStyles[key]);\n });\n } else {\n console.warn('It is not possible to manipulate component');\n }\n }\n};\n\nconst setNativeProps = (\n component: JSReanimatedComponent,\n style: StyleProps\n): void => {\n const previousStyle = component.previousStyle ? component.previousStyle : {};\n const currentStyle = { ...previousStyle, ...style };\n component.previousStyle = currentStyle;\n component.setNativeProps({ style: currentStyle });\n};\n\nexport default reanimatedJS;\n"],"mappings":";;;;;;;AAAA;;;;AAGA,MAAMA,YAAY,GAAG,IAAIC,qBAAJ,EAArB;;AAEAC,MAAM,CAACC,mBAAP,GAA8BC,CAAD,IAAOA,CAApC;;AACAF,MAAM,CAACG,aAAP,GAAuBC,YAAvB;;AAWO,MAAMC,cAAc,GAAG,CAC5BC,OAD4B,EAE5BC,OAF4B,KAGnB;EACT,IAAIA,OAAO,CAACC,UAAZ,EAAwB;IACtB,MAAMC,SAAS,GAAGF,OAAO,CAACC,UAA1B;IACA,MAAM,CAACE,SAAD,IAAcC,MAAM,CAACC,IAAP,CAAYN,OAAZ,EAAqBO,MAArB,CAClB,CAACC,GAAD,EAAmCC,GAAnC,KAA2C;MACzC,MAAMC,KAAK,GAAGV,OAAO,CAACS,GAAD,CAArB;MACA,MAAME,KAAK,GAAG,OAAOD,KAAP,KAAiB,UAAjB,GAA8B,CAA9B,GAAkC,CAAhD;MACAF,GAAG,CAACG,KAAD,CAAH,CAAWF,GAAX,IAAkBC,KAAlB;MACA,OAAOF,GAAP;IACD,CANiB,EAOlB,CAAC,EAAD,EAAK,EAAL,CAPkB,CAApB;;IAUA,IAAI,OAAOL,SAAS,CAACS,cAAjB,KAAoC,UAAxC,EAAoD;MAClDA,cAAc,CAACT,SAAD,EAAYC,SAAZ,CAAd;IACD,CAFD,MAEO,IAAIC,MAAM,CAACC,IAAP,CAAYH,SAAS,CAACU,KAAtB,EAA6BC,MAA7B,GAAsC,CAA1C,EAA6C;MAClDT,MAAM,CAACC,IAAP,CAAYH,SAAS,CAACU,KAAtB,EAA6BE,OAA7B,CAAsCN,GAAD,IAAS;QAC5C,IAAI,CAACL,SAAS,CAACK,GAAD,CAAd,EAAqB;UACnB;QACD;;QACD,MAAMO,SAAS,GAAGP,GAAG,CAACQ,OAAJ,CAAY,QAAZ,EAAuBC,CAAD,IAAO,MAAMA,CAAC,CAACC,WAAF,EAAnC,CAAlB;;QACAhB,SAAS,CAACiB,cAAV,CAAyBC,YAAzB,CAAsCL,SAAtC,EAAiDZ,SAAS,CAACK,GAAD,CAA1D;MACD,CAND;IAOD,CARM,MAQA;MACLa,OAAO,CAACC,IAAR,CAAa,4CAAb;IACD;EACF;AACF,CA9BM;;;;AAgCP,MAAMX,cAAc,GAAG,CACrBT,SADqB,EAErBqB,KAFqB,KAGZ;EACT,MAAMC,aAAa,GAAGtB,SAAS,CAACsB,aAAV,GAA0BtB,SAAS,CAACsB,aAApC,GAAoD,EAA1E;EACA,MAAMC,YAAY,GAAG,EAAE,GAAGD,aAAL;IAAoB,GAAGD;EAAvB,CAArB;EACArB,SAAS,CAACsB,aAAV,GAA0BC,YAA1B;EACAvB,SAAS,CAACS,cAAV,CAAyB;IAAEY,KAAK,EAAEE;EAAT,CAAzB;AACD,CARD;;eAUelC,Y"}
|
|
@@ -3,4 +3,15 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.LayoutAnimationType = void 0;
|
|
7
|
+
// this is just a temporary mock
|
|
8
|
+
let LayoutAnimationType;
|
|
9
|
+
exports.LayoutAnimationType = LayoutAnimationType;
|
|
10
|
+
|
|
11
|
+
(function (LayoutAnimationType) {
|
|
12
|
+
LayoutAnimationType[LayoutAnimationType["ENTERING"] = 1] = "ENTERING";
|
|
13
|
+
LayoutAnimationType[LayoutAnimationType["EXITING"] = 2] = "EXITING";
|
|
14
|
+
LayoutAnimationType[LayoutAnimationType["LAYOUT"] = 3] = "LAYOUT";
|
|
15
|
+
LayoutAnimationType[LayoutAnimationType["SHARED_ELEMENT_TRANSITION"] = 4] = "SHARED_ELEMENT_TRANSITION";
|
|
16
|
+
})(LayoutAnimationType || (exports.LayoutAnimationType = LayoutAnimationType = {}));
|
|
6
17
|
//# sourceMappingURL=commonTypes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["commonTypes.ts"],"sourcesContent":["import { EasingFn } from '../../Easing';\nimport { StyleProps } from '../../commonTypes';\n\nexport interface KeyframeProps extends StyleProps {\n easing?: EasingFn;\n [key: string]: any;\n}\n\nexport type LayoutAnimation = {\n initialValues: StyleProps;\n animations: StyleProps;\n callback?: (finished: boolean) => void;\n};\n\nexport type AnimationFunction = (a?: any, b?: any, c?: any) => any; // this is just a temporary mock\n\nexport interface EntryAnimationsValues {\n targetOriginX: number;\n targetOriginY: number;\n targetWidth: number;\n targetHeight: number;\n targetGlobalOriginX: number;\n targetGlobalOriginY: number;\n}\n\nexport interface ExitAnimationsValues {\n currentOriginX: number;\n currentOriginY: number;\n currentWidth: number;\n currentHeight: number;\n currentGlobalOriginX: number;\n currentGlobalOriginY: number;\n}\n\nexport type EntryExitAnimationFunction = (\n targetValues: EntryAnimationsValues | ExitAnimationsValues\n) => LayoutAnimation;\n\nexport type AnimationConfigFunction<T> = (targetValues: T) => LayoutAnimation;\n\nexport interface LayoutAnimationsValues {\n currentOriginX: number;\n currentOriginY: number;\n currentWidth: number;\n currentHeight: number;\n currentGlobalOriginX: number;\n currentGlobalOriginY: number;\n targetOriginX: number;\n targetOriginY: number;\n targetWidth: number;\n targetHeight: number;\n targetGlobalOriginX: number;\n targetGlobalOriginY: number;\n windowWidth: number;\n windowHeight: number;\n}\n\nexport type LayoutAnimationFunction = (\n targetValues: LayoutAnimationsValues\n) => LayoutAnimation;\n\nexport type LayoutAnimationStartFunction = (\n tag: number,\n type:
|
|
1
|
+
{"version":3,"names":["LayoutAnimationType"],"sources":["commonTypes.ts"],"sourcesContent":["import { EasingFn } from '../../Easing';\nimport { StyleProps } from '../../commonTypes';\n\nexport interface KeyframeProps extends StyleProps {\n easing?: EasingFn;\n [key: string]: any;\n}\n\nexport type LayoutAnimation = {\n initialValues: StyleProps;\n animations: StyleProps;\n callback?: (finished: boolean) => void;\n};\n\nexport type AnimationFunction = (a?: any, b?: any, c?: any) => any; // this is just a temporary mock\n\nexport interface EntryAnimationsValues {\n targetOriginX: number;\n targetOriginY: number;\n targetWidth: number;\n targetHeight: number;\n targetGlobalOriginX: number;\n targetGlobalOriginY: number;\n windowWidth: number;\n windowHeight: number;\n}\n\nexport interface ExitAnimationsValues {\n currentOriginX: number;\n currentOriginY: number;\n currentWidth: number;\n currentHeight: number;\n currentGlobalOriginX: number;\n currentGlobalOriginY: number;\n windowWidth: number;\n windowHeight: number;\n}\n\nexport type EntryExitAnimationFunction = (\n targetValues: EntryAnimationsValues | ExitAnimationsValues\n) => LayoutAnimation;\n\nexport type AnimationConfigFunction<T> = (targetValues: T) => LayoutAnimation;\n\nexport interface LayoutAnimationsValues {\n [key: string]: number;\n currentOriginX: number;\n currentOriginY: number;\n currentWidth: number;\n currentHeight: number;\n currentGlobalOriginX: number;\n currentGlobalOriginY: number;\n targetOriginX: number;\n targetOriginY: number;\n targetWidth: number;\n targetHeight: number;\n targetGlobalOriginX: number;\n targetGlobalOriginY: number;\n windowWidth: number;\n windowHeight: number;\n}\n\nexport enum LayoutAnimationType {\n ENTERING = 1,\n EXITING = 2,\n LAYOUT = 3,\n SHARED_ELEMENT_TRANSITION = 4,\n}\n\nexport type LayoutAnimationFunction = (\n targetValues: LayoutAnimationsValues\n) => LayoutAnimation;\n\nexport type LayoutAnimationStartFunction = (\n tag: number,\n type: LayoutAnimationType,\n yogaValues: LayoutAnimationsValues,\n config: LayoutAnimationFunction\n) => void;\n\nexport interface ILayoutAnimationBuilder {\n build: () => LayoutAnimationFunction;\n}\n\nexport interface BaseLayoutAnimationConfig {\n duration?: number;\n easing?: EasingFn;\n type?: AnimationFunction;\n damping?: number;\n mass?: number;\n stiffness?: number;\n overshootClamping?: number;\n restDisplacementThreshold?: number;\n restSpeedThreshold?: number;\n}\n\nexport interface BaseBuilderAnimationConfig extends BaseLayoutAnimationConfig {\n rotate?: number | string;\n}\n\nexport type LayoutAnimationAndConfig = [\n AnimationFunction,\n BaseBuilderAnimationConfig\n];\n\nexport interface IEntryExitAnimationBuilder {\n build: () => EntryExitAnimationFunction;\n}\n\nexport interface IEntryAnimationBuilder {\n build: () => AnimationConfigFunction<EntryAnimationsValues>;\n}\n\nexport interface IExitAnimationBuilder {\n build: () => AnimationConfigFunction<ExitAnimationsValues>;\n}\n"],"mappings":";;;;;;AAcoE;IAgDxDA,mB;;;WAAAA,mB;EAAAA,mB,CAAAA,mB;EAAAA,mB,CAAAA,mB;EAAAA,mB,CAAAA,mB;EAAAA,mB,CAAAA,mB;GAAAA,mB,mCAAAA,mB"}
|
|
@@ -21,10 +21,18 @@ Object.defineProperty(exports, "Keyframe", {
|
|
|
21
21
|
return _Keyframe.Keyframe;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
|
+
Object.defineProperty(exports, "LayoutAnimationType", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _commonTypes.LayoutAnimationType;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
24
30
|
|
|
25
31
|
var _BaseAnimationBuilder = require("./BaseAnimationBuilder");
|
|
26
32
|
|
|
27
33
|
var _ComplexAnimationBuilder = require("./ComplexAnimationBuilder");
|
|
28
34
|
|
|
29
35
|
var _Keyframe = require("./Keyframe");
|
|
36
|
+
|
|
37
|
+
var _commonTypes = require("./commonTypes");
|
|
30
38
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { BaseAnimationBuilder } from './BaseAnimationBuilder';\nexport { ComplexAnimationBuilder } from './ComplexAnimationBuilder';\nexport { Keyframe } from './Keyframe';\nexport type {\n LayoutAnimation,\n AnimationFunction,\n EntryAnimationsValues,\n ExitAnimationsValues,\n EntryExitAnimationFunction,\n AnimationConfigFunction,\n IEntryAnimationBuilder,\n IExitAnimationBuilder,\n LayoutAnimationsValues,\n LayoutAnimationFunction,\n LayoutAnimationStartFunction,\n ILayoutAnimationBuilder,\n BaseLayoutAnimationConfig,\n BaseBuilderAnimationConfig,\n LayoutAnimationAndConfig,\n IEntryExitAnimationBuilder,\n} from './commonTypes';\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { BaseAnimationBuilder } from './BaseAnimationBuilder';\nexport { ComplexAnimationBuilder } from './ComplexAnimationBuilder';\nexport { Keyframe } from './Keyframe';\nexport { LayoutAnimationType } from './commonTypes';\nexport type {\n LayoutAnimation,\n AnimationFunction,\n EntryAnimationsValues,\n ExitAnimationsValues,\n EntryExitAnimationFunction,\n AnimationConfigFunction,\n IEntryAnimationBuilder,\n IExitAnimationBuilder,\n LayoutAnimationsValues,\n LayoutAnimationFunction,\n LayoutAnimationStartFunction,\n ILayoutAnimationBuilder,\n BaseLayoutAnimationConfig,\n BaseBuilderAnimationConfig,\n LayoutAnimationAndConfig,\n IEntryExitAnimationBuilder,\n} from './commonTypes';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA"}
|
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _core = require("../core");
|
|
4
|
-
|
|
5
3
|
var _styleAnimation = require("../animation/styleAnimation");
|
|
6
4
|
|
|
7
5
|
var _mutables = require("../mutables");
|
|
8
6
|
|
|
7
|
+
var _animationBuilder = require("./animationBuilder");
|
|
8
|
+
|
|
9
|
+
var _threads = require("../threads");
|
|
10
|
+
|
|
9
11
|
const TAG_OFFSET = 1e9;
|
|
10
12
|
|
|
11
|
-
function startObservingProgress(tag, sharedValue) {
|
|
13
|
+
function startObservingProgress(tag, sharedValue, animationType) {
|
|
12
14
|
'worklet';
|
|
13
15
|
|
|
16
|
+
const isSharedTransition = animationType === _animationBuilder.LayoutAnimationType.SHARED_ELEMENT_TRANSITION;
|
|
14
17
|
sharedValue.addListener(tag + TAG_OFFSET, () => {
|
|
15
|
-
_notifyAboutProgress(tag, sharedValue.value);
|
|
18
|
+
_notifyAboutProgress(tag, sharedValue.value, isSharedTransition);
|
|
16
19
|
});
|
|
17
20
|
}
|
|
18
21
|
|
|
@@ -34,9 +37,9 @@ function createLayoutAnimationManager() {
|
|
|
34
37
|
const style = config(yogaValues);
|
|
35
38
|
let currentAnimation = style.animations;
|
|
36
39
|
|
|
37
|
-
if (type ===
|
|
40
|
+
if (type === _animationBuilder.LayoutAnimationType.ENTERING) {
|
|
38
41
|
enteringAnimationForTag.set(tag, currentAnimation);
|
|
39
|
-
} else if (type ===
|
|
42
|
+
} else if (type === _animationBuilder.LayoutAnimationType.LAYOUT) {
|
|
40
43
|
// When layout animation is requested, but entering is still running, we merge
|
|
41
44
|
// new layout animation targets into the ongoing animation
|
|
42
45
|
const enteringAnimation = enteringAnimationForTag.get(tag);
|
|
@@ -65,21 +68,26 @@ function createLayoutAnimationManager() {
|
|
|
65
68
|
if (finished) {
|
|
66
69
|
enteringAnimationForTag.delete(tag);
|
|
67
70
|
mutableValuesForTag.delete(tag);
|
|
68
|
-
const shouldRemoveView = type ===
|
|
71
|
+
const shouldRemoveView = type === _animationBuilder.LayoutAnimationType.EXITING;
|
|
69
72
|
stopObservingProgress(tag, value, finished, shouldRemoveView);
|
|
70
73
|
}
|
|
71
74
|
|
|
72
75
|
style.callback && style.callback(finished === undefined ? false : finished);
|
|
73
76
|
};
|
|
74
77
|
|
|
75
|
-
startObservingProgress(tag, value);
|
|
78
|
+
startObservingProgress(tag, value, type);
|
|
76
79
|
value.value = animation;
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
stop(tag) {
|
|
83
|
+
const value = mutableValuesForTag.get(tag);
|
|
84
|
+
stopObservingProgress(tag, value, true, true);
|
|
77
85
|
}
|
|
78
86
|
|
|
79
87
|
};
|
|
80
88
|
}
|
|
81
89
|
|
|
82
|
-
(0,
|
|
90
|
+
(0, _threads.runOnUIImmediately)(() => {
|
|
83
91
|
'worklet';
|
|
84
92
|
|
|
85
93
|
global.LayoutAnimationsManager = createLayoutAnimationManager();
|