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":["NOOP","ID","t","IMMEDIATE_CB_INVOCATION","cb","BaseAnimationMock","duration","_","delay","withCallback","randomDelay","withInitialValues","ReanimatedV2","useSharedValue","v","value","useDerivedValue","a","useAnimatedScrollHandler","useAnimatedGestureHandler","useAnimatedStyle","useAnimatedRef","current","useAnimatedReaction","useAnimatedProps","withTiming","toValue","withSpring","withDecay","withDelay","animationValue","withSequence","withRepeat","animation","cancelAnimation","measure","x","y","width","height","pageX","pageY","Easing","linear","ease","quad","cubic","poly","sin","circle","exp","elastic","back","bounce","bezier","factory","bezierFn","in","out","inOut","Extrapolation","EXTEND","CLAMP","IDENTITY","runOnJS","fn","runOnUI","forEach","k","Object","assign","module","exports"],"sources":["mock.ts"],"sourcesContent":["/* eslint-disable node/no-callback-literal */\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-nocheck\nconst NOOP = () => {\n // noop\n};\nconst ID = (t) => t;\nconst IMMEDIATE_CB_INVOCATION = (cb: () => unknown) => cb();\n\nclass BaseAnimationMock {\n duration(_: number) {\n return this;\n }\n\n delay(_: number) {\n return this;\n }\n\n withCallback(_: (finsihed: boolean) => void) {\n return this;\n }\n\n randomDelay() {\n return this;\n }\n\n withInitialValues() {\n return this;\n }\n}\n\nconst ReanimatedV2 = {\n useSharedValue: (v) => ({ value: v }),\n useDerivedValue: (a) => ({ value: a() }),\n useAnimatedScrollHandler: () => NOOP,\n useAnimatedGestureHandler: () => NOOP,\n useAnimatedStyle: IMMEDIATE_CB_INVOCATION,\n useAnimatedRef: () => ({ current: null }),\n useAnimatedReaction: NOOP,\n useAnimatedProps: IMMEDIATE_CB_INVOCATION,\n\n withTiming: (toValue, _, cb) => {\n cb && cb(true);\n return toValue;\n },\n withSpring: (toValue, _, cb) => {\n cb && cb(true);\n return toValue;\n },\n withDecay: (_, cb) => {\n cb && cb(true);\n return 0;\n },\n withDelay: (_, animationValue) => {\n return animationValue;\n },\n withSequence: (..._animations) => {\n return 0;\n },\n withRepeat: (animation) => {\n return animation;\n },\n cancelAnimation: NOOP,\n measure: () => ({\n x: 0,\n y: 0,\n width: 0,\n height: 0,\n pageX: 0,\n pageY: 0,\n }),\n Easing: {\n linear: ID,\n ease: ID,\n quad: ID,\n cubic: ID,\n poly: ID,\n sin: ID,\n circle: ID,\n exp: ID,\n elastic: ID,\n back: ID,\n bounce: ID,\n bezier: () => ({ factory: ID }),\n bezierFn: ID,\n in: ID,\n out: ID,\n inOut: ID,\n },\n Extrapolation: {\n EXTEND: 'extend',\n CLAMP: 'clamp',\n IDENTITY: 'identity',\n },\n\n runOnJS: (fn) => fn,\n runOnUI: (fn) => fn,\n};\n\n[\n 'FadeIn',\n 'FadeInRight',\n 'FadeInLeft',\n 'FadeInUp',\n '
|
|
1
|
+
{"version":3,"names":["NOOP","ID","t","IMMEDIATE_CB_INVOCATION","cb","BaseAnimationMock","duration","_","delay","springify","damping","stiffness","withCallback","randomDelay","withInitialValues","build","initialValues","animations","ReanimatedV2","useSharedValue","v","value","useDerivedValue","a","useAnimatedScrollHandler","useAnimatedGestureHandler","useAnimatedStyle","useAnimatedRef","current","useAnimatedReaction","useAnimatedProps","withTiming","toValue","withSpring","withDecay","withDelay","animationValue","withSequence","withRepeat","animation","cancelAnimation","measure","x","y","width","height","pageX","pageY","Easing","linear","ease","quad","cubic","poly","sin","circle","exp","elastic","back","bounce","bezier","factory","bezierFn","in","out","inOut","Extrapolation","EXTEND","CLAMP","IDENTITY","runOnJS","fn","runOnUI","forEach","k","Object","assign","module","exports"],"sources":["mock.ts"],"sourcesContent":["/* eslint-disable node/no-callback-literal */\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-nocheck\nconst NOOP = () => {\n // noop\n};\nconst ID = (t) => t;\nconst IMMEDIATE_CB_INVOCATION = (cb: () => unknown) => cb();\n\nclass BaseAnimationMock {\n duration(_: number) {\n return this;\n }\n\n delay(_: number) {\n return this;\n }\n\n springify(_: number) {\n return this;\n }\n\n damping(_: number) {\n return this;\n }\n\n stiffness(_: number) {\n return this;\n }\n\n withCallback(_: (finsihed: boolean) => void) {\n return this;\n }\n\n randomDelay() {\n return this;\n }\n\n withInitialValues() {\n return this;\n }\n\n build() {\n return () => ({ initialValues: {}, animations: {} });\n }\n}\n\nconst ReanimatedV2 = {\n useSharedValue: (v) => ({ value: v }),\n useDerivedValue: (a) => ({ value: a() }),\n useAnimatedScrollHandler: () => NOOP,\n useAnimatedGestureHandler: () => NOOP,\n useAnimatedStyle: IMMEDIATE_CB_INVOCATION,\n useAnimatedRef: () => ({ current: null }),\n useAnimatedReaction: NOOP,\n useAnimatedProps: IMMEDIATE_CB_INVOCATION,\n\n withTiming: (toValue, _, cb) => {\n cb && cb(true);\n return toValue;\n },\n withSpring: (toValue, _, cb) => {\n cb && cb(true);\n return toValue;\n },\n withDecay: (_, cb) => {\n cb && cb(true);\n return 0;\n },\n withDelay: (_, animationValue) => {\n return animationValue;\n },\n withSequence: (..._animations) => {\n return 0;\n },\n withRepeat: (animation) => {\n return animation;\n },\n cancelAnimation: NOOP,\n measure: () => ({\n x: 0,\n y: 0,\n width: 0,\n height: 0,\n pageX: 0,\n pageY: 0,\n }),\n Easing: {\n linear: ID,\n ease: ID,\n quad: ID,\n cubic: ID,\n poly: ID,\n sin: ID,\n circle: ID,\n exp: ID,\n elastic: ID,\n back: ID,\n bounce: ID,\n bezier: () => ({ factory: ID }),\n bezierFn: ID,\n in: ID,\n out: ID,\n inOut: ID,\n },\n Extrapolation: {\n EXTEND: 'extend',\n CLAMP: 'clamp',\n IDENTITY: 'identity',\n },\n\n runOnJS: (fn) => fn,\n runOnUI: (fn) => fn,\n};\n\n[\n 'FadeIn',\n 'FadeInRight',\n 'FadeInLeft',\n 'FadeInUp',\n 'FadeInDown',\n 'FadeOut',\n 'FadeOutRight',\n 'FadeOutLeft',\n 'FadeOutUp',\n 'FadeOutDown',\n\n 'FlipInYLeft',\n 'FlipInXDown',\n 'FlipInYRight',\n 'FlipInEasyX',\n 'FlipInEasyY',\n 'FlipOutXUp',\n 'FlipOutYLeft',\n 'FlipOutXDown',\n 'FlipOutYRight',\n 'FlipOutEasyX',\n 'FlipOutEasyY',\n\n 'StretchInY',\n 'StretchOutX',\n 'StretchOutY',\n 'SlideInLeft',\n 'SlideOutRight',\n 'SlideOutLeft',\n 'SlideInUp',\n 'SlideInDown',\n 'SlideOutUp',\n\n 'ZoomInRotate',\n 'ZoomInLeft',\n 'ZoomInRight',\n 'ZoomInUp',\n 'ZoomInDown',\n 'ZoomInEasyUp',\n 'ZoomInEasyDown',\n 'ZoomOut',\n 'ZoomOutRotate',\n 'ZoomOutLeft',\n 'ZoomOutRight',\n 'ZoomOutUp',\n 'ZoomOutDown',\n 'ZoomOutEasyUp',\n 'ZoomOutEasyDown',\n\n 'BounceInDown',\n 'BounceInUp',\n 'BounceInLeft',\n 'BounceInRight',\n 'BounceOut',\n 'BounceOutDown',\n 'BounceOutUp',\n 'BounceOutLeft',\n 'BounceOutRight',\n\n 'LightSpeedInLeft',\n 'LightSpeedOutRight',\n 'LightSpeedOutLeft',\n\n 'PinwheelOut',\n\n 'RotateInDownRight',\n 'RotateInUpLeft',\n 'RotateInUpRight',\n 'RotateOutDownLeft',\n 'RotateOutDownRight',\n 'RotateOutUpLeft',\n 'RotateOutUpRight',\n\n 'RollInRight',\n 'RollOutLeft',\n 'RollOutRight',\n\n 'Layout',\n 'CurvedTransition',\n 'JumpingTransition',\n 'SequencedTransition',\n 'FadingTransition',\n 'EntryExitTransition',\n].forEach((k) =>\n Object.assign(ReanimatedV2, {\n [k]: new BaseAnimationMock(),\n })\n);\n\nmodule.exports = {\n ...ReanimatedV2,\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,MAAMA,IAAI,GAAG,MAAM,CACjB;AACD,CAFD;;AAGA,MAAMC,EAAE,GAAIC,CAAD,IAAOA,CAAlB;;AACA,MAAMC,uBAAuB,GAAIC,EAAD,IAAuBA,EAAE,EAAzD;;AAEA,MAAMC,iBAAN,CAAwB;EACtBC,QAAQ,CAACC,CAAD,EAAY;IAClB,OAAO,IAAP;EACD;;EAEDC,KAAK,CA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
|
|
@@ -45,7 +45,8 @@ export function makeUIMutable(initial, syncDataHolder) {
|
|
|
45
45
|
removeListener: id => {
|
|
46
46
|
listeners.delete(id);
|
|
47
47
|
},
|
|
48
|
-
_animation: null
|
|
48
|
+
_animation: null,
|
|
49
|
+
_isReanimatedSharedValue: true
|
|
49
50
|
};
|
|
50
51
|
return self;
|
|
51
52
|
}
|
|
@@ -129,7 +130,8 @@ export function makeMutable(initial) {
|
|
|
129
130
|
}
|
|
130
131
|
|
|
131
132
|
listeners.delete(id);
|
|
132
|
-
}
|
|
133
|
+
},
|
|
134
|
+
_isReanimatedSharedValue: true
|
|
133
135
|
};
|
|
134
136
|
registerShareableMapping(mutable, handle);
|
|
135
137
|
return mutable;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeReanimatedModule","makeShareableCloneOnUIRecursive","makeShareableCloneRecursive","registerShareableMapping","runOnUI","valueSetter","stopMapper","makeUIMutable","initial","syncDataHolder","listeners","Map","value","self","newValue","_value","_updateDataSynchronously","forEach","listener","addListener","id","set","removeListener","delete","_animation","makeMutable","oneWayReadsOnly","native","makeSynchronizedDataHolder","handle","__init","undefined","mutable","getDataSynchronously","Error","modify","modifier","makeRemote"],"sources":["mutables.ts"],"sourcesContent":["import NativeReanimatedModule from './NativeReanimated';\nimport { SharedValue, ShareableSyncDataHolderRef } from './commonTypes';\nimport {\n makeShareableCloneOnUIRecursive,\n makeShareableCloneRecursive,\n registerShareableMapping,\n} from './shareables';\nimport { runOnUI } from './threads';\nimport { valueSetter } from './valueSetter';\nexport { stopMapper } from './mappers';\n\nexport function makeUIMutable<T>(\n initial: T,\n syncDataHolder?: ShareableSyncDataHolderRef<T>\n) {\n 'worklet';\n\n const listeners = new Map();\n let value = initial;\n\n const self = {\n set value(newValue) {\n valueSetter(self, newValue);\n },\n get value() {\n return value;\n },\n /**\n * _value prop should only be accessed by the valueSetter implementation\n * which may make the decision about updating the mutable value depending\n * on the provided new value. All other places should only attempt to modify\n * the mutable by assigning to value prop directly.\n */\n set _value(newValue: T) {\n value = newValue;\n if (syncDataHolder) {\n _updateDataSynchronously(\n syncDataHolder,\n makeShareableCloneOnUIRecursive(newValue)\n );\n }\n listeners.forEach((listener) => {\n listener(newValue);\n });\n },\n get _value(): T {\n return value;\n },\n addListener: (id: number, listener: (newValue: T) => void) => {\n listeners.set(id, listener);\n },\n removeListener: (id: number) => {\n listeners.delete(id);\n },\n _animation: null,\n };\n return self;\n}\n\nexport function makeMutable<T>(\n initial: T,\n oneWayReadsOnly = false\n): SharedValue<T> {\n let value: T = initial;\n let syncDataHolder: ShareableSyncDataHolderRef<T> | undefined;\n if (!oneWayReadsOnly && NativeReanimatedModule.native) {\n // updates are always synchronous when running on web or in Jest environment\n syncDataHolder = NativeReanimatedModule.makeSynchronizedDataHolder(\n makeShareableCloneRecursive(value)\n );\n registerShareableMapping(syncDataHolder);\n }\n const handle = makeShareableCloneRecursive({\n __init: () => {\n 'worklet';\n return makeUIMutable(initial, syncDataHolder);\n },\n });\n // listeners can only work on JS thread on Web and jest environments\n const listeners = NativeReanimatedModule.native ? undefined : new Map();\n const mutable = {\n set value(newValue) {\n if (NativeReanimatedModule.native) {\n runOnUI(() => {\n 'worklet';\n mutable.value = newValue;\n })();\n } else {\n valueSetter(mutable, newValue);\n }\n },\n get value() {\n if (syncDataHolder) {\n return NativeReanimatedModule.getDataSynchronously(syncDataHolder);\n }\n return value;\n },\n set _value(newValue: T) {\n if (NativeReanimatedModule.native) {\n throw new Error(\n 'Setting `_value` directly is only possible on the UI runtime'\n );\n }\n value = newValue;\n listeners!.forEach((listener) => {\n listener(newValue);\n });\n },\n get _value(): T {\n if (NativeReanimatedModule.native) {\n throw new Error(\n 'Reading from `_value` directly is only possible on the UI runtime'\n );\n }\n return value;\n },\n modify: (modifier: (value: T) => T) => {\n runOnUI(() => {\n 'worklet';\n mutable.value = modifier(mutable.value);\n })();\n },\n addListener: (id: number, listener: (value: T) => void) => {\n if (NativeReanimatedModule.native) {\n throw new Error('adding listeners is only possible on the UI runtime');\n }\n listeners!.set(id, listener);\n },\n removeListener: (id: number) => {\n if (NativeReanimatedModule.native) {\n throw new Error(\n 'removing listeners is only possible on the UI runtime'\n );\n }\n listeners!.delete(id);\n },\n };\n registerShareableMapping(mutable, handle);\n return mutable;\n}\n\nexport function makeRemote<T extends object>(initial: T = {} as T): T {\n const handle = makeShareableCloneRecursive({\n __init: () => {\n 'worklet';\n return initial;\n },\n });\n registerShareableMapping(initial, handle);\n return initial;\n}\n"],"mappings":"AAAA,OAAOA,sBAAP,MAAmC,oBAAnC;AAEA,SACEC,+BADF,EAEEC,2BAFF,EAGEC,wBAHF,QAIO,cAJP;AAKA,SAASC,OAAT,QAAwB,WAAxB;AACA,SAASC,WAAT,QAA4B,eAA5B;AACA,SAASC,UAAT,QAA2B,WAA3B;AAEA,OAAO,SAASC,aAAT,CACLC,OADK,EAELC,cAFK,EAGL;EACA;;EAEA,MAAMC,SAAS,GAAG,IAAIC,GAAJ,EAAlB;EACA,IAAIC,KAAK,GAAGJ,OAAZ;EAEA,MAAMK,IAAI,GAAG;IACX,IAAID,KAAJ,CAAUE,QAAV,EAAoB;MAClBT,WAAW,CAACQ,IAAD,EAAOC,QAAP,CAAX;IACD,CAHU;;IAIX,IAAIF,KAAJ,GAAY;MACV,OAAOA,KAAP;IACD,CANU;;IAOX;AACJ;AACA;AACA;AACA;AACA;IACI,IAAIG,MAAJ,CAAWD,QAAX,EAAwB;MACtBF,KAAK,GAAGE,QAAR;;MACA,IAAIL,cAAJ,EAAoB;QAClBO,wBAAwB,CACtBP,cADsB,EAEtBR,+BAA+B,CAACa,QAAD,CAFT,CAAxB;MAID;;MACDJ,SAAS,CAACO,OAAV,CAAmBC,QAAD,IAAc;QAC9BA,QAAQ,CAACJ,QAAD,CAAR;MACD,CAFD;IAGD,CAxBU;;IAyBX,IAAIC,MAAJ,GAAgB;MACd,OAAOH,KAAP;IACD,CA3BU;;IA4BXO,WAAW,EAAE,CAACC,EAAD,EAAaF,QAAb,KAAiD;MAC5DR,SAAS,CAACW,GAAV,CAAcD,EAAd,EAAkBF,QAAlB;IACD,CA9BU;IA+BXI,cAAc,EAAGF,EAAD,IAAgB;MAC9BV,SAAS,CAACa,MAAV,CAAiBH,EAAjB;IACD,CAjCU;IAkCXI,UAAU,EAAE;
|
|
1
|
+
{"version":3,"names":["NativeReanimatedModule","makeShareableCloneOnUIRecursive","makeShareableCloneRecursive","registerShareableMapping","runOnUI","valueSetter","stopMapper","makeUIMutable","initial","syncDataHolder","listeners","Map","value","self","newValue","_value","_updateDataSynchronously","forEach","listener","addListener","id","set","removeListener","delete","_animation","_isReanimatedSharedValue","makeMutable","oneWayReadsOnly","native","makeSynchronizedDataHolder","handle","__init","undefined","mutable","getDataSynchronously","Error","modify","modifier","makeRemote"],"sources":["mutables.ts"],"sourcesContent":["import NativeReanimatedModule from './NativeReanimated';\nimport { SharedValue, ShareableSyncDataHolderRef } from './commonTypes';\nimport {\n makeShareableCloneOnUIRecursive,\n makeShareableCloneRecursive,\n registerShareableMapping,\n} from './shareables';\nimport { runOnUI } from './threads';\nimport { valueSetter } from './valueSetter';\nexport { stopMapper } from './mappers';\n\nexport function makeUIMutable<T>(\n initial: T,\n syncDataHolder?: ShareableSyncDataHolderRef<T>\n) {\n 'worklet';\n\n const listeners = new Map();\n let value = initial;\n\n const self = {\n set value(newValue) {\n valueSetter(self, newValue);\n },\n get value() {\n return value;\n },\n /**\n * _value prop should only be accessed by the valueSetter implementation\n * which may make the decision about updating the mutable value depending\n * on the provided new value. All other places should only attempt to modify\n * the mutable by assigning to value prop directly.\n */\n set _value(newValue: T) {\n value = newValue;\n if (syncDataHolder) {\n _updateDataSynchronously(\n syncDataHolder,\n makeShareableCloneOnUIRecursive(newValue)\n );\n }\n listeners.forEach((listener) => {\n listener(newValue);\n });\n },\n get _value(): T {\n return value;\n },\n addListener: (id: number, listener: (newValue: T) => void) => {\n listeners.set(id, listener);\n },\n removeListener: (id: number) => {\n listeners.delete(id);\n },\n _animation: null,\n _isReanimatedSharedValue: true,\n };\n return self;\n}\n\nexport function makeMutable<T>(\n initial: T,\n oneWayReadsOnly = false\n): SharedValue<T> {\n let value: T = initial;\n let syncDataHolder: ShareableSyncDataHolderRef<T> | undefined;\n if (!oneWayReadsOnly && NativeReanimatedModule.native) {\n // updates are always synchronous when running on web or in Jest environment\n syncDataHolder = NativeReanimatedModule.makeSynchronizedDataHolder(\n makeShareableCloneRecursive(value)\n );\n registerShareableMapping(syncDataHolder);\n }\n const handle = makeShareableCloneRecursive({\n __init: () => {\n 'worklet';\n return makeUIMutable(initial, syncDataHolder);\n },\n });\n // listeners can only work on JS thread on Web and jest environments\n const listeners = NativeReanimatedModule.native ? undefined : new Map();\n const mutable = {\n set value(newValue) {\n if (NativeReanimatedModule.native) {\n runOnUI(() => {\n 'worklet';\n mutable.value = newValue;\n })();\n } else {\n valueSetter(mutable, newValue);\n }\n },\n get value() {\n if (syncDataHolder) {\n return NativeReanimatedModule.getDataSynchronously(syncDataHolder);\n }\n return value;\n },\n set _value(newValue: T) {\n if (NativeReanimatedModule.native) {\n throw new Error(\n 'Setting `_value` directly is only possible on the UI runtime'\n );\n }\n value = newValue;\n listeners!.forEach((listener) => {\n listener(newValue);\n });\n },\n get _value(): T {\n if (NativeReanimatedModule.native) {\n throw new Error(\n 'Reading from `_value` directly is only possible on the UI runtime'\n );\n }\n return value;\n },\n modify: (modifier: (value: T) => T) => {\n runOnUI(() => {\n 'worklet';\n mutable.value = modifier(mutable.value);\n })();\n },\n addListener: (id: number, listener: (value: T) => void) => {\n if (NativeReanimatedModule.native) {\n throw new Error('adding listeners is only possible on the UI runtime');\n }\n listeners!.set(id, listener);\n },\n removeListener: (id: number) => {\n if (NativeReanimatedModule.native) {\n throw new Error(\n 'removing listeners is only possible on the UI runtime'\n );\n }\n listeners!.delete(id);\n },\n _isReanimatedSharedValue: true,\n };\n registerShareableMapping(mutable, handle);\n return mutable;\n}\n\nexport function makeRemote<T extends object>(initial: T = {} as T): T {\n const handle = makeShareableCloneRecursive({\n __init: () => {\n 'worklet';\n return initial;\n },\n });\n registerShareableMapping(initial, handle);\n return initial;\n}\n"],"mappings":"AAAA,OAAOA,sBAAP,MAAmC,oBAAnC;AAEA,SACEC,+BADF,EAEEC,2BAFF,EAGEC,wBAHF,QAIO,cAJP;AAKA,SAASC,OAAT,QAAwB,WAAxB;AACA,SAASC,WAAT,QAA4B,eAA5B;AACA,SAASC,UAAT,QAA2B,WAA3B;AAEA,OAAO,SAASC,aAAT,CACLC,OADK,EAELC,cAFK,EAGL;EACA;;EAEA,MAAMC,SAAS,GAAG,IAAIC,GAAJ,EAAlB;EACA,IAAIC,KAAK,GAAGJ,OAAZ;EAEA,MAAMK,IAAI,GAAG;IACX,IAAID,KAAJ,CAAUE,QAAV,EAAoB;MAClBT,WAAW,CAACQ,IAAD,EAAOC,QAAP,CAAX;IACD,CAHU;;IAIX,IAAIF,KAAJ,GAAY;MACV,OAAOA,KAAP;IACD,CANU;;IAOX;AACJ;AACA;AACA;AACA;AACA;IACI,IAAIG,MAAJ,CAAWD,QAAX,EAAwB;MACtBF,KAAK,GAAGE,QAAR;;MACA,IAAIL,cAAJ,EAAoB;QAClBO,wBAAwB,CACtBP,cADsB,EAEtBR,+BAA+B,CAACa,QAAD,CAFT,CAAxB;MAID;;MACDJ,SAAS,CAACO,OAAV,CAAmBC,QAAD,IAAc;QAC9BA,QAAQ,CAACJ,QAAD,CAAR;MACD,CAFD;IAGD,CAxBU;;IAyBX,IAAIC,MAAJ,GAAgB;MACd,OAAOH,KAAP;IACD,CA3BU;;IA4BXO,WAAW,EAAE,CAACC,EAAD,EAAaF,QAAb,KAAiD;MAC5DR,SAAS,CAACW,GAAV,CAAcD,EAAd,EAAkBF,QAAlB;IACD,CA9BU;IA+BXI,cAAc,EAAGF,EAAD,IAAgB;MAC9BV,SAAS,CAACa,MAAV,CAAiBH,EAAjB;IACD,CAjCU;IAkCXI,UAAU,EAAE,IAlCD;IAmCXC,wBAAw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@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* We hardcode the version of Reanimated here in order to compare it
|
|
3
|
+
* with the version used to build the native part of the library in runtime.
|
|
4
|
+
* Remember to keep this in sync with the version declared in `package.json`
|
|
5
|
+
*/
|
|
6
|
+
const jsVersion = '3.0.0';
|
|
7
|
+
/**
|
|
8
|
+
* Checks that native and js versions of reanimated match.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export function checkVersion() {
|
|
12
|
+
const cppVersion = global._REANIMATED_VERSION_CPP;
|
|
13
|
+
|
|
14
|
+
if (cppVersion === undefined) {
|
|
15
|
+
console.error(`[Reanimated] Couldn't determine the version of the native part of Reanimated. Did you forget to re-build the app after upgrading react-native-reanimated? If you use Expo Go, you must use the exact version which is bundled into Expo SDK.`);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const ok = (() => {
|
|
20
|
+
if (jsVersion.match(/^\d+\.\d+\.\d+$/) && cppVersion.match(/^\d+\.\d+\.\d+$/)) {
|
|
21
|
+
// x.y.z, compare only major and minor, skip patch
|
|
22
|
+
const [jsMajor, jsMinor] = jsVersion.split('.');
|
|
23
|
+
const [cppMajor, cppMinor] = cppVersion.split('.');
|
|
24
|
+
return jsMajor === cppMajor && jsMinor === cppMinor;
|
|
25
|
+
} else {
|
|
26
|
+
// alpha, beta or rc, compare everything
|
|
27
|
+
return jsVersion === cppVersion;
|
|
28
|
+
}
|
|
29
|
+
})();
|
|
30
|
+
|
|
31
|
+
if (!ok) {
|
|
32
|
+
console.error(`[Reanimated] Mismatch between JavaScript part and native part of Reanimated (${jsVersion} vs. ${cppVersion}). Did you forget to re-build the app after upgrading react-native-reanimated? If you use Expo Go, you must downgrade to ${cppVersion} which is bundled into Expo SDK.`); // TODO: detect Expo managed workflow
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=checkVersion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["jsVersion","checkVersion","cppVersion","global","_REANIMATED_VERSION_CPP","undefined","console","error","ok","match","jsMajor","jsMinor","split","cppMajor","cppMinor"],"sources":["checkVersion.ts"],"sourcesContent":["/**\n * We hardcode the version of Reanimated here in order to compare it\n * with the version used to build the native part of the library in runtime.\n * Remember to keep this in sync with the version declared in `package.json`\n */\nconst jsVersion = '3.0.0';\n\n/**\n * Checks that native and js versions of reanimated match.\n */\nexport function checkVersion(): void {\n const cppVersion = global._REANIMATED_VERSION_CPP;\n if (cppVersion === undefined) {\n console.error(\n `[Reanimated] Couldn't determine the version of the native part of Reanimated. Did you forget to re-build the app after upgrading react-native-reanimated? If you use Expo Go, you must use the exact version which is bundled into Expo SDK.`\n );\n return;\n }\n const ok = (() => {\n if (\n jsVersion.match(/^\\d+\\.\\d+\\.\\d+$/) &&\n cppVersion.match(/^\\d+\\.\\d+\\.\\d+$/)\n ) {\n // x.y.z, compare only major and minor, skip patch\n const [jsMajor, jsMinor] = jsVersion.split('.');\n const [cppMajor, cppMinor] = cppVersion.split('.');\n return jsMajor === cppMajor && jsMinor === cppMinor;\n } else {\n // alpha, beta or rc, compare everything\n return jsVersion === cppVersion;\n }\n })();\n if (!ok) {\n console.error(\n `[Reanimated] Mismatch between JavaScript part and native part of Reanimated (${jsVersion} vs. ${cppVersion}). Did you forget to re-build the app after upgrading react-native-reanimated? If you use Expo Go, you must downgrade to ${cppVersion} which is bundled into Expo SDK.`\n );\n // TODO: detect Expo managed workflow\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA,MAAMA,SAAS,GAAG,OAAlB;AAEA;AACA;AACA;;AACA,OAAO,SAASC,YAAT,GAA8B;EACnC,MAAMC,UAAU,GAAGC,MAAM,CAACC,uBAA1B;;EACA,IAAIF,UAAU,KAAKG,SAAnB,EAA8B;IAC5BC,OAAO,CAACC,KAAR,CACG,8OADH;IAGA;EACD;;EACD,MAAMC,EAAE,GAAG,CAAC,MAAM;IAChB,IACER,SAAS,CAACS,KAAV,CAAgB,iBAAhB,KACAP,UAAU,CAACO,KAAX,CAAiB,iBAAjB,CAFF,EAGE;MACA;MACA,MAAM,CAACC,OAAD,EAAUC,OAAV,IAAqBX,SAAS,CAACY,KAAV,CAAgB,GAAhB,CAA3B;MACA,MAAM,CAACC,QAAD,EAAWC,QAAX,IAAuBZ,UAAU,CAACU,KAAX,CAAiB,GAAjB,CAA7B;MACA,OAAOF,OAAO,KAAKG,QAAZ,IAAwBF,OAAO,KAAKG,QAA3C;IACD,CARD,MAQO;MACL;MACA,OAAOd,SAAS,KAAKE,UAArB;IACD;EACF,CAbU,GAAX;;EAcA,IAAI,CAACM,EAAL,EAAS;IACPF,OAAO,CAACC,KAAR,CACG,gFAA+EP,SAAU,QAAOE,UAAW,4HAA2HA,UAAW,kCADpP,EADO,CAIP;EACD;AACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Checks that native and js versions of reanimated match.
|
|
5
|
+
* Stubbed for web, where this check is unnecessary.
|
|
6
|
+
*/
|
|
7
|
+
export function checkVersion() {}
|
|
8
|
+
//# sourceMappingURL=checkVersion.web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["checkVersion"],"sources":["checkVersion.web.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-empty-function */\n/**\n * Checks that native and js versions of reanimated match.\n * Stubbed for web, where this check is unnecessary.\n */\nexport function checkVersion(): void {}\n"],"mappings":"AAAA;;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,YAAT,GAA8B,CAAE"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export function getUseOfValueInStyleWarning() {
|
|
2
|
+
return "It looks like you might be using shared value's .value inside reanimated inline style. " + 'If you want a component to update when shared value changes you should use the shared value' + ' directly instead of its current state represented by `.value`. See documentation here: ' + 'https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/animations#animations-in-inline-styles';
|
|
3
|
+
}
|
|
4
|
+
//# sourceMappingURL=pluginUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getUseOfValueInStyleWarning"],"sources":["pluginUtils.ts"],"sourcesContent":["export function getUseOfValueInStyleWarning() {\n return (\n \"It looks like you might be using shared value's .value inside reanimated inline style. \" +\n 'If you want a component to update when shared value changes you should use the shared value' +\n ' directly instead of its current state represented by `.value`. See documentation here: ' +\n 'https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/animations#animations-in-inline-styles'\n );\n}\n"],"mappings":"AAAA,OAAO,SAASA,2BAAT,GAAuC;EAC5C,OACE,4FACA,6FADA,GAEA,0FAFA,GAGA,6GAJF;AAMD"}
|
|
@@ -13,6 +13,16 @@ const _shareableCache = new WeakMap(); // the below symbol is used to represent
|
|
|
13
13
|
|
|
14
14
|
const _shareableFlag = Symbol('shareable flag');
|
|
15
15
|
|
|
16
|
+
const MAGIC_KEY = 'REANIMATED_MAGIC_KEY';
|
|
17
|
+
|
|
18
|
+
function isHostObject(value) {
|
|
19
|
+
// We could use JSI to determine whether an object is a host object, however
|
|
20
|
+
// the below workaround works well and is way faster than an additional JSI call.
|
|
21
|
+
// We use the fact that host objects have broken implementation of `hasOwnProperty`
|
|
22
|
+
// and hence return true for all `in` checks regardless of the key we ask for.
|
|
23
|
+
return MAGIC_KEY in value;
|
|
24
|
+
}
|
|
25
|
+
|
|
16
26
|
export function registerShareableMapping(shareable, shareableRef) {
|
|
17
27
|
if (USE_STUB_IMPLEMENTATION) {
|
|
18
28
|
return;
|
|
@@ -20,12 +30,9 @@ export function registerShareableMapping(shareable, shareableRef) {
|
|
|
20
30
|
|
|
21
31
|
_shareableCache.set(shareable, shareableRef || _shareableFlag);
|
|
22
32
|
}
|
|
23
|
-
export function makeShareableShadowNodeWrapper(shadowNodeWrapper) {
|
|
24
|
-
const adoptedSNW = NativeReanimatedModule.makeShareableClone(shadowNodeWrapper);
|
|
25
|
-
registerShareableMapping(shadowNodeWrapper, adoptedSNW);
|
|
26
|
-
return shadowNodeWrapper;
|
|
27
|
-
}
|
|
28
33
|
export function makeShareableCloneRecursive(value) {
|
|
34
|
+
let shouldPersistRemote = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
35
|
+
|
|
29
36
|
if (USE_STUB_IMPLEMENTATION) {
|
|
30
37
|
return value;
|
|
31
38
|
} // This one actually may be worth to be moved to c++, we also need similar logic to run on the UI thread
|
|
@@ -48,13 +55,30 @@ export function makeShareableCloneRecursive(value) {
|
|
|
48
55
|
} else if (type === 'function' && value.__workletHash === undefined) {
|
|
49
56
|
// this is a remote function
|
|
50
57
|
toAdapt = value;
|
|
58
|
+
} else if (isHostObject(value)) {
|
|
59
|
+
// for host objects we pass the reference to the object as shareable and
|
|
60
|
+
// then recreate new host object wrapping the same instance on the UI thread.
|
|
61
|
+
// there is no point of iterating over keys as we do for regular objects.
|
|
62
|
+
toAdapt = value;
|
|
51
63
|
} else {
|
|
52
|
-
if (__DEV__ && value.__workletHash !== undefined) {
|
|
53
|
-
registerWorkletStackDetails(value.__workletHash, value.__stackDetails);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
64
|
toAdapt = {};
|
|
57
65
|
|
|
66
|
+
if (value.__workletHash !== undefined) {
|
|
67
|
+
// we are converting a worklet
|
|
68
|
+
if (__DEV__) {
|
|
69
|
+
registerWorkletStackDetails(value.__workletHash, value.__stackDetails);
|
|
70
|
+
delete value.__stackDetails;
|
|
71
|
+
} // to save on transferring static __initData field of worklet structure
|
|
72
|
+
// we request shareable value to persist its UI counterpart. This means
|
|
73
|
+
// that the __initData field that contains long strings represeting the
|
|
74
|
+
// worklet code, source map, and location, will always be
|
|
75
|
+
// serialized/deserialized once.
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
toAdapt.__initData = makeShareableCloneRecursive(value.__initData, true);
|
|
79
|
+
delete value.__initData;
|
|
80
|
+
}
|
|
81
|
+
|
|
58
82
|
for (const [key, element] of Object.entries(value)) {
|
|
59
83
|
toAdapt[key] = makeShareableCloneRecursive(element);
|
|
60
84
|
}
|
|
@@ -66,11 +90,11 @@ export function makeShareableCloneRecursive(value) {
|
|
|
66
90
|
// shareable. Meaning that they may be doing a faulty assumption in their
|
|
67
91
|
// code expecting that the updates are going to automatically populate to
|
|
68
92
|
// the object sent to the UI thread. If the user really wants some objects
|
|
69
|
-
// to be mutable they should use
|
|
93
|
+
// to be mutable they should use shared values instead.
|
|
70
94
|
Object.freeze(value);
|
|
71
95
|
}
|
|
72
96
|
|
|
73
|
-
const adopted = NativeReanimatedModule.makeShareableClone(toAdapt);
|
|
97
|
+
const adopted = NativeReanimatedModule.makeShareableClone(toAdapt, shouldPersistRemote);
|
|
74
98
|
|
|
75
99
|
_shareableCache.set(value, adopted);
|
|
76
100
|
|
|
@@ -80,7 +104,7 @@ export function makeShareableCloneRecursive(value) {
|
|
|
80
104
|
}
|
|
81
105
|
}
|
|
82
106
|
|
|
83
|
-
return NativeReanimatedModule.makeShareableClone(value);
|
|
107
|
+
return NativeReanimatedModule.makeShareableClone(value, shouldPersistRemote);
|
|
84
108
|
}
|
|
85
109
|
export function makeShareableCloneOnUIRecursive(value) {
|
|
86
110
|
'worklet';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeReanimatedModule","shouldBeUseWeb","registerWorkletStackDetails","USE_STUB_IMPLEMENTATION","_shareableCache","WeakMap","_shareableFlag","Symbol","
|
|
1
|
+
{"version":3,"names":["NativeReanimatedModule","shouldBeUseWeb","registerWorkletStackDetails","USE_STUB_IMPLEMENTATION","_shareableCache","WeakMap","_shareableFlag","Symbol","MAGIC_KEY","isHostObject","value","registerShareableMapping","shareable","shareableRef","set","makeShareableCloneRecursive","shouldPersistRemote","type","cached","get","undefined","toAdapt","Array","isArray","map","element","__workletHash","__DEV__","__stackDetails","__initData","key","Object","entries","freeze","adopted","makeShareableClone","makeShareableCloneOnUIRecursive","cloneRecursive","_makeShareableClone","makeShareable","handle","__init"],"sources":["shareables.ts"],"sourcesContent":["import NativeReanimatedModule from './NativeReanimated';\nimport { ShareableRef } from './commonTypes';\nimport { shouldBeUseWeb } from './PlatformChecker';\nimport { registerWorkletStackDetails } from './errors';\n\n// for web/chrome debugger/jest environments this file provides a stub implementation\n// where no shareable references are used. Instead, the objects themselves are used\n// instead of shareable references, because of the fact that we don't have to deal with\n// runnning the code on separate VMs.\nconst USE_STUB_IMPLEMENTATION = shouldBeUseWeb();\n\nconst _shareableCache = new WeakMap<\n Record<string, unknown>,\n ShareableRef<any> | symbol\n>();\n// the below symbol is used to represent a mapping from the value to itself\n// this is used to allow for a converted shareable to be passed to makeShareableClone\nconst _shareableFlag = Symbol('shareable flag');\n\nconst MAGIC_KEY = 'REANIMATED_MAGIC_KEY';\n\nfunction isHostObject(value: any): boolean {\n // We could use JSI to determine whether an object is a host object, however\n // the below workaround works well and is way faster than an additional JSI call.\n // We use the fact that host objects have broken implementation of `hasOwnProperty`\n // and hence return true for all `in` checks regardless of the key we ask for.\n return MAGIC_KEY in value;\n}\n\nexport function registerShareableMapping(\n shareable: any,\n shareableRef?: ShareableRef<any>\n): void {\n if (USE_STUB_IMPLEMENTATION) {\n return;\n }\n _shareableCache.set(shareable, shareableRef || _shareableFlag);\n}\n\nexport function makeShareableCloneRecursive<T>(\n value: any,\n shouldPersistRemote = false\n): ShareableRef<T> {\n if (USE_STUB_IMPLEMENTATION) {\n return value;\n }\n // This one actually may be worth to be moved to c++, we also need similar logic to run on the UI thread\n const type = typeof value;\n if ((type === 'object' || type === 'function') && value !== null) {\n const cached = _shareableCache.get(value);\n if (cached === _shareableFlag) {\n return value;\n } else if (cached !== undefined) {\n return cached as ShareableRef<T>;\n } else {\n let toAdapt: any;\n if (Array.isArray(value)) {\n toAdapt = value.map((element) => makeShareableCloneRecursive(element));\n } else if (type === 'function' && value.__workletHash === undefined) {\n // this is a remote function\n toAdapt = value;\n } else if (isHostObject(value)) {\n // for host objects we pass the reference to the object as shareable and\n // then recreate new host object wrapping the same instance on the UI thread.\n // there is no point of iterating over keys as we do for regular objects.\n toAdapt = value;\n } else {\n toAdapt = {};\n if (value.__workletHash !== undefined) {\n // we are converting a worklet\n if (__DEV__) {\n registerWorkletStackDetails(\n value.__workletHash,\n value.__stackDetails\n );\n delete value.__stackDetails;\n }\n // to save on transferring static __initData field of worklet structure\n // we request shareable value to persist its UI counterpart. This means\n // that the __initData field that contains long strings represeting the\n // worklet code, source map, and location, will always be\n // serialized/deserialized once.\n toAdapt.__initData = makeShareableCloneRecursive(\n value.__initData,\n true\n );\n delete value.__initData;\n }\n\n for (const [key, element] of Object.entries(value)) {\n toAdapt[key] = makeShareableCloneRecursive(element);\n }\n }\n if (__DEV__) {\n // we freeze objects that are transformed to shareable. This should help\n // detect issues when someone modifies data after it's been converted to\n // shareable. Meaning that they may be doing a faulty assumption in their\n // code expecting that the updates are going to automatically populate to\n // the object sent to the UI thread. If the user really wants some objects\n // to be mutable they should use shared values instead.\n Object.freeze(value);\n }\n const adopted = NativeReanimatedModule.makeShareableClone(\n toAdapt,\n shouldPersistRemote\n );\n _shareableCache.set(value, adopted);\n _shareableCache.set(adopted, _shareableFlag);\n return adopted;\n }\n }\n return NativeReanimatedModule.makeShareableClone(value, shouldPersistRemote);\n}\n\nexport function makeShareableCloneOnUIRecursive<T>(value: T): ShareableRef<T> {\n 'worklet';\n if (USE_STUB_IMPLEMENTATION) {\n // @ts-ignore web is an interesting place where we don't run a secondary VM on the UI thread\n // see more details in the comment where USE_STUB_IMPLEMENTATION is defined.\n return value;\n }\n function cloneRecursive<T>(value: T): ShareableRef<T> {\n const type = typeof value;\n if ((type === 'object' || type === 'function') && value !== null) {\n let toAdapt: any;\n if (Array.isArray(value)) {\n toAdapt = value.map((element) => cloneRecursive(element));\n } else {\n toAdapt = {};\n for (const [key, element] of Object.entries(value)) {\n toAdapt[key] = cloneRecursive(element);\n }\n }\n if (__DEV__) {\n // See the reasoning behind freezing in the other comment above.\n Object.freeze(value);\n }\n return _makeShareableClone(toAdapt);\n }\n return _makeShareableClone(value);\n }\n return cloneRecursive(value);\n}\n\nexport function makeShareable<T>(value: T): T {\n if (USE_STUB_IMPLEMENTATION) {\n return value;\n }\n const handle = makeShareableCloneRecursive({\n __init: () => {\n 'worklet';\n return value;\n },\n });\n registerShareableMapping(value, handle);\n return value;\n}\n"],"mappings":"AAAA,OAAOA,sBAAP,MAAmC,oBAAnC;AAEA,SAASC,cAAT,QAA+B,mBAA/B;AACA,SAASC,2BAAT,QAA4C,UAA5C,C,CAEA;AACA;AACA;AACA;;AACA,MAAMC,uBAAuB,GAAGF,cAAc,EAA9C;;AAEA,MAAMG,eAAe,GAAG,IAAIC,OAAJ,EAAxB,C,CAIA;AACA;;;AACA,MAAMC,cAAc,GAAGC,MAAM,CAAC,gBAAD,CAA7B;;AAEA,MAAMC,SAAS,GAAG,sBAAlB;;AAEA,SAASC,YAAT,CAAsBC,KAAtB,EAA2C;EACzC;EACA;EACA;EACA;EACA,OAAOF,SAAS,IAAIE,KAApB;AACD;;AAED,OAAO,SAASC,wBAAT,CACLC,SADK,EAELC,YAFK,EAGC;EACN,IAAIV,uBAAJ,EAA6B;IAC3B;EACD;;EACDC,eAAe,CAACU,GAAhB,CAAoBF,SAApB,EAA+BC,YAAY,IAAIP,cAA/C;AACD;AAED,OAAO,SAASS,2BAAT,CACLL,KADK,EAGY;EAAA,IADjBM,mBACiB,uEADK,KACL;;EACjB,IAAIb,uBAAJ,EAA6B;IAC3B,OAAOO,KAAP;EACD,CAHgB,CAIjB;;;EACA,MAAMO,IAAI,GAAG,OAAOP,KAApB;;EACA,IAAI,CAACO,IAAI,KAAK,QAAT,IAAqBA,IAAI,KAAK,UAA/B,KAA8CP,KAAK,KAAK,IAA5D,EAAkE;IAChE,MAAMQ,MAAM,GAAGd,eAAe,CAACe,GAAhB,CAAoBT,KAApB,CAAf;;IACA,IAAIQ,MAAM,KAAKZ,cAAf,EAA+B;MAC7B,OAAOI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,uBAAJ,EAA6B;IAC3B,OAAOO,KAAP;EACD;;EACD,MAAM8B,MAAM,GAAGzB,2BAA2B,CAAC;IACzC0B,MAAM,EAAE,MAAM;MACZ;;MACA,OAAO/B,KAAP;IACD;EAJwC,CAAD,CAA1C;EAMAC,wBAAwB,CAACD,KAAD,EAAQ8B,MAAR,CAAxB;EACA,OAAO9B,KAAP;AACD"}
|
|
@@ -1,7 +1,44 @@
|
|
|
1
1
|
import NativeReanimatedModule from './NativeReanimated';
|
|
2
|
+
import { isJest, shouldBeUseWeb } from './PlatformChecker';
|
|
2
3
|
import { makeShareableCloneOnUIRecursive, makeShareableCloneRecursive } from './shareables';
|
|
4
|
+
const IS_JEST = isJest();
|
|
5
|
+
let _runOnUIQueue = [];
|
|
6
|
+
export function setupSetImmediate() {
|
|
7
|
+
'worklet';
|
|
8
|
+
|
|
9
|
+
let immediateCalbacks = []; // @ts-ignore – typescript expects this to conform to NodeJS definition and expects the return value to be NodeJS.Immediate which is an object and not a number
|
|
10
|
+
|
|
11
|
+
global.setImmediate = callback => {
|
|
12
|
+
immediateCalbacks.push(callback);
|
|
13
|
+
return -1;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
global.__flushImmediates = () => {
|
|
17
|
+
for (let index = 0; index < immediateCalbacks.length; index += 1) {
|
|
18
|
+
// we use classic 'for' loop because the size of the currentTasks array may change while executing some of the callbacks due to setImmediate calls
|
|
19
|
+
immediateCalbacks[index]();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
immediateCalbacks = [];
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function flushImmediatesOnUIThread() {
|
|
27
|
+
'worklet';
|
|
28
|
+
|
|
29
|
+
global.__flushImmediates();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const flushImmediates = shouldBeUseWeb() ? () => {// on web flushing is a noop as immediates are handled by the browser
|
|
33
|
+
} : flushImmediatesOnUIThread;
|
|
34
|
+
/**
|
|
35
|
+
* Schedule a worklet to execute on the UI runtime. This method does not schedule the work immediately but instead
|
|
36
|
+
* waits for other worklets to be scheduled within the same JS loop. It uses setImmediate to schedule all the worklets
|
|
37
|
+
* at once making sure they will run within the same frame boundaries on the UI thread.
|
|
38
|
+
*/
|
|
39
|
+
|
|
3
40
|
export function runOnUI(worklet) {
|
|
4
|
-
if (__DEV__) {
|
|
41
|
+
if (__DEV__ && !shouldBeUseWeb()) {
|
|
5
42
|
if (worklet.__workletHash === undefined) {
|
|
6
43
|
throw new Error('runOnUI() can only be used on worklets');
|
|
7
44
|
}
|
|
@@ -12,13 +49,77 @@ export function runOnUI(worklet) {
|
|
|
12
49
|
args[_key] = arguments[_key];
|
|
13
50
|
}
|
|
14
51
|
|
|
52
|
+
if (IS_JEST) {
|
|
53
|
+
// Mocking time in Jest is tricky as both requestAnimationFrame and setImmediate
|
|
54
|
+
// callbacks run on the same queue and can be interleaved. There is no way
|
|
55
|
+
// to flush particular queue in Jest and the only control over mocked timers
|
|
56
|
+
// is by using jest.advanceTimersByTime() method which advances all types
|
|
57
|
+
// of timers including immediate and animation callbacks. Ideally we'd like
|
|
58
|
+
// to have some way here to schedule work along with React updates, but
|
|
59
|
+
// that's not possible, and hence in Jest environment instead of using scheduling
|
|
60
|
+
// mechanism we just schedule the work ommiting the queue. This is ok for the
|
|
61
|
+
// uses that we currently have but may not be ok for future tests that we write.
|
|
62
|
+
NativeReanimatedModule.scheduleOnUI(makeShareableCloneRecursive(() => {
|
|
63
|
+
'worklet';
|
|
64
|
+
|
|
65
|
+
worklet(...args);
|
|
66
|
+
}));
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
_runOnUIQueue.push([worklet, args]);
|
|
71
|
+
|
|
72
|
+
if (_runOnUIQueue.length === 1) {
|
|
73
|
+
setImmediate(() => {
|
|
74
|
+
const queue = _runOnUIQueue;
|
|
75
|
+
_runOnUIQueue = [];
|
|
76
|
+
NativeReanimatedModule.scheduleOnUI(makeShareableCloneRecursive(() => {
|
|
77
|
+
'worklet';
|
|
78
|
+
|
|
79
|
+
queue.forEach(_ref => {
|
|
80
|
+
let [worklet, args] = _ref;
|
|
81
|
+
worklet(...args);
|
|
82
|
+
});
|
|
83
|
+
flushImmediates();
|
|
84
|
+
}));
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Schedule a worklet to execute on the UI runtime skipping batching mechanism.
|
|
91
|
+
*/
|
|
92
|
+
|
|
93
|
+
export function runOnUIImmediately(worklet) {
|
|
94
|
+
if (__DEV__) {
|
|
95
|
+
if (worklet.__workletHash === undefined) {
|
|
96
|
+
throw new Error('runOnUI() can only be used on worklets');
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return function () {
|
|
101
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
102
|
+
args[_key2] = arguments[_key2];
|
|
103
|
+
}
|
|
104
|
+
|
|
15
105
|
NativeReanimatedModule.scheduleOnUI(makeShareableCloneRecursive(() => {
|
|
16
106
|
'worklet';
|
|
17
107
|
|
|
18
|
-
|
|
108
|
+
worklet(...args);
|
|
19
109
|
}));
|
|
20
110
|
};
|
|
21
111
|
}
|
|
112
|
+
|
|
113
|
+
if (__DEV__) {
|
|
114
|
+
try {
|
|
115
|
+
runOnUI(() => {
|
|
116
|
+
'worklet';
|
|
117
|
+
});
|
|
118
|
+
} catch (e) {
|
|
119
|
+
throw new Error('Failed to create a worklet. Did you forget to add Reanimated Babel plugin in babel.config.js? See installation docs at https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation#babel-plugin.');
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
22
123
|
export function runOnJS(fun) {
|
|
23
124
|
'worklet';
|
|
24
125
|
|
|
@@ -35,8 +136,8 @@ export function runOnJS(fun) {
|
|
|
35
136
|
}
|
|
36
137
|
|
|
37
138
|
return function () {
|
|
38
|
-
for (var
|
|
39
|
-
args[
|
|
139
|
+
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
140
|
+
args[_key3] = arguments[_key3];
|
|
40
141
|
}
|
|
41
142
|
|
|
42
143
|
_scheduleOnJS(fun, args.length > 0 ? makeShareableCloneOnUIRecursive(args) : undefined);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeReanimatedModule","makeShareableCloneOnUIRecursive","makeShareableCloneRecursive","runOnUI","worklet","__DEV__","__workletHash","undefined","Error","args","scheduleOnUI","runOnJS","fun","__remoteFunction","_WORKLET","_scheduleOnJS"
|
|
1
|
+
{"version":3,"names":["NativeReanimatedModule","isJest","shouldBeUseWeb","makeShareableCloneOnUIRecursive","makeShareableCloneRecursive","IS_JEST","_runOnUIQueue","setupSetImmediate","immediateCalbacks","global","setImmediate","callback","push","__flushImmediates","index","length","flushImmediatesOnUIThread","flushImmediates","runOnUI","worklet","__DEV__","__workletHash","undefined","Error","args","scheduleOnUI","queue","forEach","runOnUIImmediately","e","runOnJS","fun","__remoteFunction","_WORKLET","_scheduleOnJS"],"sources":["threads.ts"],"sourcesContent":["import NativeReanimatedModule from './NativeReanimated';\nimport { isJest, shouldBeUseWeb } from './PlatformChecker';\nimport { ComplexWorkletFunction } from './commonTypes';\nimport {\n makeShareableCloneOnUIRecursive,\n makeShareableCloneRecursive,\n} from './shareables';\n\nconst IS_JEST = isJest();\n\nlet _runOnUIQueue: Array<[ComplexWorkletFunction<any[], any>, any[]]> = [];\n\nexport function setupSetImmediate() {\n 'worklet';\n\n let immediateCalbacks: Array<() => void> = [];\n\n // @ts-ignore – typescript expects this to conform to NodeJS definition and expects the return value to be NodeJS.Immediate which is an object and not a number\n global.setImmediate = (callback: () => void): number => {\n immediateCalbacks.push(callback);\n return -1;\n };\n\n global.__flushImmediates = () => {\n for (let index = 0; index < immediateCalbacks.length; index += 1) {\n // we use classic 'for' loop because the size of the currentTasks array may change while executing some of the callbacks due to setImmediate calls\n immediateCalbacks[index]();\n }\n immediateCalbacks = [];\n };\n}\n\nfunction flushImmediatesOnUIThread() {\n 'worklet';\n global.__flushImmediates();\n}\n\nexport const flushImmediates = shouldBeUseWeb()\n ? () => {\n // on web flushing is a noop as immediates are handled by the browser\n }\n : flushImmediatesOnUIThread;\n\n/**\n * Schedule a worklet to execute on the UI runtime. This method does not schedule the work immediately but instead\n * waits for other worklets to be scheduled within the same JS loop. It uses setImmediate to schedule all the worklets\n * at once making sure they will run within the same frame boundaries on the UI thread.\n */\nexport function runOnUI<A extends any[], R>(\n worklet: ComplexWorkletFunction<A, R>\n): (...args: A) => void {\n if (__DEV__ && !shouldBeUseWeb()) {\n if (worklet.__workletHash === undefined) {\n throw new Error('runOnUI() can only be used on worklets');\n }\n }\n return (...args) => {\n if (IS_JEST) {\n // Mocking time in Jest is tricky as both requestAnimationFrame and setImmediate\n // callbacks run on the same queue and can be interleaved. There is no way\n // to flush particular queue in Jest and the only control over mocked timers\n // is by using jest.advanceTimersByTime() method which advances all types\n // of timers including immediate and animation callbacks. Ideally we'd like\n // to have some way here to schedule work along with React updates, but\n // that's not possible, and hence in Jest environment instead of using scheduling\n // mechanism we just schedule the work ommiting the queue. This is ok for the\n // uses that we currently have but may not be ok for future tests that we write.\n NativeReanimatedModule.scheduleOnUI(\n makeShareableCloneRecursive(() => {\n 'worklet';\n worklet(...args);\n })\n );\n return;\n }\n _runOnUIQueue.push([worklet, args]);\n if (_runOnUIQueue.length === 1) {\n setImmediate(() => {\n const queue = _runOnUIQueue;\n _runOnUIQueue = [];\n NativeReanimatedModule.scheduleOnUI(\n makeShareableCloneRecursive(() => {\n 'worklet';\n queue.forEach(([worklet, args]) => {\n worklet(...args);\n });\n flushImmediates();\n })\n );\n });\n }\n };\n}\n\n/**\n * Schedule a worklet to execute on the UI runtime skipping batching mechanism.\n */\nexport function runOnUIImmediately<A extends any[], R>(\n worklet: ComplexWorkletFunction<A, R>\n): (...args: A) => void {\n if (__DEV__) {\n if (worklet.__workletHash === undefined) {\n throw new Error('runOnUI() can only be used on worklets');\n }\n }\n return (...args) => {\n NativeReanimatedModule.scheduleOnUI(\n makeShareableCloneRecursive(() => {\n 'worklet';\n worklet(...args);\n })\n );\n };\n}\n\nif (__DEV__) {\n try {\n runOnUI(() => {\n 'worklet';\n });\n } catch (e) {\n throw new Error(\n 'Failed to create a worklet. Did you forget to add Reanimated Babel plugin in babel.config.js? See installation docs at https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation#babel-plugin.'\n );\n }\n}\n\nexport function runOnJS<A extends any[], R>(\n fun: ComplexWorkletFunction<A, R>\n): (...args: A) => void {\n 'worklet';\n if (fun.__remoteFunction) {\n // in development mode the function provided as `fun` throws an error message\n // such that when someone accidently calls it directly on the UI runtime, they\n // see that they should use `runOnJS` instead. To facilitate that we purt the\n // reference to the original remote function in the `__remoteFunction` property.\n fun = fun.__remoteFunction;\n }\n if (!_WORKLET) {\n return fun;\n }\n return (...args) => {\n _scheduleOnJS(\n fun,\n args.length > 0 ? makeShareableCloneOnUIRecursive(args) : undefined\n );\n };\n}\n"],"mappings":"AAAA,OAAOA,sBAAP,MAAmC,oBAAnC;AACA,SAASC,MAAT,EAAiBC,cAAjB,QAAuC,mBAAvC;AAEA,SACEC,+BADF,EAEEC,2BAFF,QAGO,cAHP;AAKA,MAAMC,OAAO,GAAGJ,MAAM,EAAtB;AAEA,IAAIK,aAAiE,GAAG,EAAxE;AAEA,OAAO,SAASC,iBAAT,GAA6B;EAClC;;EAEA,IAAIC,iBAAoC,GAAG,EAA3C,CAHkC,CAKlC;;EACAC,MAAM,CAACC,YAAP,GAAuBC,QAAD,IAAkC;IACtDH,iBAAiB,CAACI,IAAlB,CAAuBD,QAAvB;IACA,OAAO,CAAC,CAAR;EACD,CAHD;;EAKAF,MAAM,CAACI,iBAAP,GAA2B,MAAM;IAC/B,KAAK,IAAIC,KAAK,GAAG,CAAjB,EAAoBA,KAAK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CAZW,CAAZ;IAaD;EACF,CAnCD;AAoCD;AAED;AACA;AACA;;AACA,OAAO,SAASW,kBAAT,CACLT,OADK,EAEiB;EACtB,IAAIC,OAAJ,EAAa;IACX,IAAID,OAAO,CAACE,aAAR,KAA0BC,SAA9B,EAAyC;MACvC,MAAM,IAAIC,KAAJ,CAAU,wCAAV,CAAN;IACD;EACF;;EACD,OAAO,YAAa;IAAA,mCAATC,IAAS;MAATA,IAAS;IAAA;;IAClBxB,sBAAsB,CAACyB,YAAvB,CACErB,2BAA2B,CAAC,MAAM;MAChC;;MACAe,OAAO,CAAC,GAAGK,IAAJ,CAAP;IACD,CAH0B,CAD7B;EAMD,CAPD;AAQD;;AAED,IAAIJ,OAAJ,EAAa;EACX,IAAI;IACFF,OAAO,CAAC,MAAM;MACZ;IACD,CAFM,CAAP;EAGD,CAJD,CAIE,OAAOW,CAAP,EAAU;IACV,MAAM,IAAIN,KAAJ,CACJ,wNADI,CAAN;EAGD;AACF;;AAED,OAAO,SAASO,OAAT,CACLC,GADK,EAEiB;EACtB;;EACA,IAAIA,GAAG,CAACC,gBAAR,EAA0B;IACxB;IACA;IACA;IACA;IACAD,GAAG,GAAGA,GAAG,CAACC,gBAAV;EACD;;EACD,IAAI,CAACC,QAAL,EAAe;IACb,OAAOF,GAAP;EACD;;EACD,OAAO,YAAa;IAAA,mCAATP,IAAS;MAATA,IAAS;IAAA;;IAClBU,aAAa,CACXH,GADW,EAEXP,IAAI,CAACT,MAAL,GAAc,CAAd,GAAkBZ,+BAA+B,CAACqB,IAAD,CAAjD,GAA0DF,SAF/C,CAAb;EAID,CALD;AAMD"}
|
|
@@ -18,4 +18,9 @@ export function getRelativeCoords(parentRef, absoluteX, absoluteY) {
|
|
|
18
18
|
y: absoluteY - parentCoords.y
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
|
+
export function isSharedValue(value) {
|
|
22
|
+
'worklet';
|
|
23
|
+
|
|
24
|
+
return typeof value === 'object' && value._isReanimatedSharedValue === true;
|
|
25
|
+
}
|
|
21
26
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["measure","getRelativeCoords","parentRef","absoluteX","absoluteY","parentCoords","x","y"],"sources":["utils.ts"],"sourcesContent":["import { Component } from 'react';\nimport { measure } from './NativeMethods';\nimport { RefObjectFunction } from './hook/commonTypes';\n\nexport interface ComponentCoords {\n x: number;\n y: number;\n}\n\n/**\n * Given an absolute position and a component ref, returns the relative\n * position in the component's local coordinate space.\n */\nexport function getRelativeCoords(\n parentRef: RefObjectFunction<Component>,\n absoluteX: number,\n absoluteY: number\n): ComponentCoords | null {\n 'worklet';\n const parentCoords = measure(parentRef);\n if (parentCoords === null) {\n return null;\n }\n return {\n x: absoluteX - parentCoords.x,\n y: absoluteY - parentCoords.y,\n };\n}\n"],"mappings":"AACA,SAASA,OAAT,QAAwB,iBAAxB;;
|
|
1
|
+
{"version":3,"names":["measure","getRelativeCoords","parentRef","absoluteX","absoluteY","parentCoords","x","y","isSharedValue","value","_isReanimatedSharedValue"],"sources":["utils.ts"],"sourcesContent":["import { Component } from 'react';\nimport { measure } from './NativeMethods';\nimport { RefObjectFunction } from './hook/commonTypes';\nimport { SharedValue } from './commonTypes';\n\nexport interface ComponentCoords {\n x: number;\n y: number;\n}\n\n/**\n * Given an absolute position and a component ref, returns the relative\n * position in the component's local coordinate space.\n */\nexport function getRelativeCoords(\n parentRef: RefObjectFunction<Component>,\n absoluteX: number,\n absoluteY: number\n): ComponentCoords | null {\n 'worklet';\n const parentCoords = measure(parentRef);\n if (parentCoords === null) {\n return null;\n }\n return {\n x: absoluteX - parentCoords.x,\n y: absoluteY - parentCoords.y,\n };\n}\n\nexport function isSharedValue<T>(value: any): value is SharedValue<T> {\n 'worklet';\n return typeof value === 'object' && value._isReanimatedSharedValue === true;\n}\n"],"mappings":"AACA,SAASA,OAAT,QAAwB,iBAAxB;;AASA;AACA;AACA;AACA;AACA,OAAO,SAASC,iBAAT,CACLC,SADK,EAELC,SAFK,EAGLC,SAHK,EAImB;EACxB;;EACA,MAAMC,YAAY,GAAGL,OAAO,CAACE,SAAD,CAA5B;;EACA,IAAIG,YAAY,KAAK,IAArB,EAA2B;IACzB,OAAO,IAAP;EACD;;EACD,OAAO;IACLC,CAAC,EAAEH,SAAS,GAAGE,YAAY,CAACC,CADvB;IAELC,CAAC,EAAEH,SAAS,GAAGC,YAAY,CAACE;EAFvB,CAAP;AAID;AAED,OAAO,SAASC,aAAT,CAA0BC,KAA1B,EAA+D;EACpE;;EACA,OAAO,OAAOA,KAAP,KAAiB,QAAjB,IAA6BA,KAAK,CAACC,wBAAN,KAAmC,IAAvE;AACD"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { getTimestamp } from './time';
|
|
2
1
|
export { stopMapper } from './mappers';
|
|
3
2
|
export function valueSetter(sv, value) {
|
|
4
3
|
'worklet';
|
|
@@ -26,7 +25,7 @@ export function valueSetter(sv, value) {
|
|
|
26
25
|
animation.onStart(animation, sv.value, timestamp, previousAnimation);
|
|
27
26
|
};
|
|
28
27
|
|
|
29
|
-
const currentTimestamp =
|
|
28
|
+
const currentTimestamp = global.__frameTimestamp || performance.now();
|
|
30
29
|
initializeAnimation(currentTimestamp);
|
|
31
30
|
|
|
32
31
|
const step = timestamp => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["stopMapper","valueSetter","sv","value","previousAnimation","_animation","cancelled","onFrame","undefined","animation","_value","current","isHigherOrder","callback","initializeAnimation","timestamp","onStart","currentTimestamp","global","__frameTimestamp","performance","now","step","finished","requestAnimationFrame"],"sources":["valueSetter.ts"],"sourcesContent":["import { AnimationObject, AnimatableValue } from './commonTypes';\nimport { Descriptor } from './hook/commonTypes';\nexport { stopMapper } from './mappers';\n\nexport function valueSetter(sv: any, value: any): void {\n 'worklet';\n const previousAnimation = sv._animation;\n if (previousAnimation) {\n previousAnimation.cancelled = true;\n sv._animation = null;\n }\n if (\n typeof value === 'function' ||\n (value !== null &&\n typeof value === 'object' &&\n (value as AnimationObject).onFrame !== undefined)\n ) {\n const animation: AnimationObject =\n typeof value === 'function'\n ? (value as () => AnimationObject)()\n : (value as AnimationObject);\n // prevent setting again to the same value\n // and triggering the mappers that treat this value as an input\n // this happens when the animation's target value(stored in animation.current until animation.onStart is called) is set to the same value as a current one(this._value)\n // built in animations that are not higher order(withTiming, withSpring) hold target value in .current\n if (sv._value === animation.current && !animation.isHigherOrder) {\n animation.callback && animation.callback(true);\n return;\n }\n // animated set\n const initializeAnimation = (timestamp: number) => {\n animation.onStart(animation, sv.value, timestamp, previousAnimation);\n };\n const currentTimestamp = global.__frameTimestamp || performance.now();\n initializeAnimation(currentTimestamp);\n const step = (timestamp: number) => {\n if (animation.cancelled) {\n animation.callback && animation.callback(false /* finished */);\n return;\n }\n const finished = animation.onFrame(animation, timestamp);\n animation.finished = true;\n animation.timestamp = timestamp;\n sv._value = animation.current;\n if (finished) {\n animation.callback && animation.callback(true /* finished */);\n } else {\n requestAnimationFrame(step);\n }\n };\n\n sv._animation = animation;\n\n step(currentTimestamp);\n } else {\n // prevent setting again to the same value\n // and triggering the mappers that treat this value as an input\n if (sv._value === value) {\n return;\n }\n sv._value = value as Descriptor | AnimatableValue;\n }\n}\n"],"mappings":"AAEA,SAASA,UAAT,QAA2B,WAA3B;AAEA,OAAO,SAASC,WAAT,CAAqBC,EAArB,EAA8BC,KAA9B,EAAgD;EACrD;;EACA,MAAMC,iBAAiB,GAAGF,EAAE,CAACG,UAA7B;;EACA,IAAID,iBAAJ,EAAuB;IACrBA,iBAAiB,CAACE,SAAlB,GAA8B,IAA9B;IACAJ,EAAE,CAACG,UAAH,GAAgB,IAAhB;EACD;;EACD,IACE,OAAOF,KAAP,KAAiB,UAAjB,IACCA,KAAK,KAAK,IAAV,IACC,OAAOA,KAAP,KAAiB,QADlB,IAEEA,KAAD,CAA2BI,OAA3B,KAAuCC,SAJ3C,EAKE;IACA,MAAMC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