react-native-reanimated 2.3.0-alpha.1 → 2.3.0-beta.2
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/LayoutAnimations/LayoutAnimationsProxy.cpp +15 -8
- package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +170 -166
- package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +36 -34
- package/Common/cpp/Registries/EventHandlerRegistry.cpp +13 -6
- package/Common/cpp/Registries/MapperRegistry.cpp +19 -15
- package/Common/cpp/Registries/WorkletsCache.cpp +19 -9
- package/Common/cpp/SharedItems/FrozenObject.cpp +19 -8
- package/Common/cpp/SharedItems/MutableValue.cpp +38 -25
- package/Common/cpp/SharedItems/MutableValueSetterProxy.cpp +11 -7
- package/Common/cpp/SharedItems/RemoteObject.cpp +9 -5
- package/Common/cpp/SharedItems/ShareableValue.cpp +216 -143
- package/Common/cpp/Tools/JSIStoreValueUser.cpp +36 -24
- package/Common/cpp/Tools/Mapper.cpp +41 -29
- package/Common/cpp/Tools/RuntimeDecorator.cpp +103 -84
- package/Common/cpp/Tools/Scheduler.cpp +14 -6
- package/Common/cpp/Tools/WorkletEventHandler.cpp +1 -1
- package/Common/cpp/headers/LayoutAnimations/LayoutAnimationsProxy.h +12 -11
- package/Common/cpp/headers/NativeModules/NativeReanimatedModule.h +45 -34
- package/Common/cpp/headers/NativeModules/NativeReanimatedModuleSpec.h +28 -16
- package/Common/cpp/headers/Registries/EventHandlerRegistry.h +14 -8
- package/Common/cpp/headers/Registries/MapperRegistry.h +4 -4
- package/Common/cpp/headers/Registries/WorkletsCache.h +9 -7
- package/Common/cpp/headers/SharedItems/FrozenObject.h +15 -11
- package/Common/cpp/headers/SharedItems/HostFunctionHandler.h +6 -4
- package/Common/cpp/headers/SharedItems/MutableValue.h +21 -12
- package/Common/cpp/headers/SharedItems/MutableValueSetterProxy.h +10 -7
- package/Common/cpp/headers/SharedItems/RemoteObject.h +16 -8
- package/Common/cpp/headers/SharedItems/RuntimeManager.h +39 -21
- package/Common/cpp/headers/SharedItems/ShareableValue.h +31 -27
- package/Common/cpp/headers/SharedItems/SharedParent.h +7 -4
- package/Common/cpp/headers/SharedItems/ValueWrapper.h +80 -61
- package/Common/cpp/headers/SpecTools/ErrorHandler.h +17 -19
- package/Common/cpp/headers/Tools/JSIStoreValueUser.h +18 -13
- package/Common/cpp/headers/Tools/Mapper.h +24 -18
- package/Common/cpp/headers/Tools/PlatformDepMethodsHolder.h +12 -7
- package/Common/cpp/headers/Tools/ReanimatedHiddenHeaders.h +7 -7
- package/Common/cpp/headers/Tools/RuntimeDecorator.h +29 -23
- package/Common/cpp/headers/Tools/Scheduler.h +28 -33
- package/Common/cpp/headers/Tools/WorkletEventHandler.h +9 -7
- package/Common/cpp/hidden_headers/Logger.h +14 -14
- package/Common/cpp/hidden_headers/LoggerInterface.h +8 -9
- package/Common/cpp/hidden_headers/SpeedChecker.h +7 -8
- package/README.md +1 -1
- package/RNReanimated.podspec +4 -4
- package/android/build.gradle +80 -3
- package/android/react-native-reanimated-63-hermes.aar +0 -0
- package/android/react-native-reanimated-63-jsc.aar +0 -0
- package/android/react-native-reanimated-64-hermes.aar +0 -0
- package/android/react-native-reanimated-64-jsc.aar +0 -0
- package/android/react-native-reanimated-65-hermes.aar +0 -0
- package/android/react-native-reanimated-65-jsc.aar +0 -0
- package/android/react-native-reanimated-66-hermes.aar +0 -0
- package/android/react-native-reanimated-66-jsc.aar +0 -0
- package/ios/LayoutReanimation/REAAnimationsManager.h +19 -10
- package/ios/LayoutReanimation/REAAnimationsManager.m +195 -200
- package/ios/LayoutReanimation/REASnapshot.h +13 -0
- package/ios/LayoutReanimation/REASnapshot.m +29 -0
- package/ios/LayoutReanimation/REAUIManager.h +16 -0
- package/ios/LayoutReanimation/REAUIManager.mm +348 -0
- package/ios/Nodes/REAAlwaysNode.m +14 -15
- package/ios/Nodes/REABezierNode.m +8 -7
- package/ios/Nodes/REABlockNode.m +1 -1
- package/ios/Nodes/REACallFuncNode.h +0 -1
- package/ios/Nodes/REACallFuncNode.m +10 -8
- package/ios/Nodes/REAClockNodes.m +22 -20
- package/ios/Nodes/REAConcatNode.h +0 -1
- package/ios/Nodes/REAConcatNode.m +2 -2
- package/ios/Nodes/REACondNode.m +7 -5
- package/ios/Nodes/READebugNode.m +5 -4
- package/ios/Nodes/REAEventNode.m +1 -1
- package/ios/Nodes/REAFunctionNode.h +0 -1
- package/ios/Nodes/REAFunctionNode.m +2 -2
- package/ios/Nodes/REAJSCallNode.m +4 -5
- package/ios/Nodes/REANode.h +3 -4
- package/ios/Nodes/REANode.m +9 -11
- package/ios/Nodes/REAOperatorNode.m +68 -67
- package/ios/Nodes/REAParamNode.h +1 -3
- package/ios/Nodes/REAParamNode.m +15 -17
- package/ios/Nodes/REAPropsNode.h +1 -3
- package/ios/Nodes/REAPropsNode.m +19 -22
- package/ios/Nodes/REASetNode.h +0 -1
- package/ios/Nodes/REASetNode.m +7 -5
- package/ios/Nodes/REAStyleNode.h +0 -1
- package/ios/Nodes/REAStyleNode.m +2 -4
- package/ios/Nodes/REATransformNode.h +0 -1
- package/ios/Nodes/REATransformNode.m +3 -5
- package/ios/Nodes/REAValueNode.m +5 -7
- package/ios/REAEventDispatcher.m +3 -3
- package/ios/REAModule.h +0 -2
- package/ios/REAModule.m +29 -40
- package/ios/REANodesManager.h +11 -19
- package/ios/REANodesManager.m +105 -130
- package/ios/REAUtils.h +5 -3
- package/ios/Transitioning/RCTConvert+REATransition.m +45 -29
- package/ios/Transitioning/REAAllTransitions.h +2 -2
- package/ios/Transitioning/REAAllTransitions.m +14 -25
- package/ios/Transitioning/REATransition.h +8 -7
- package/ios/Transitioning/REATransition.m +19 -16
- package/ios/Transitioning/REATransitionAnimation.h +1 -1
- package/ios/Transitioning/REATransitionAnimation.m +2 -3
- package/ios/Transitioning/REATransitionManager.m +3 -3
- package/ios/native/NativeMethods.h +15 -5
- package/ios/native/NativeProxy.h +4 -3
- package/ios/native/NativeProxy.mm +19 -5
- package/ios/native/REAIOSErrorHandler.h +13 -10
- package/ios/native/REAIOSLogger.h +8 -8
- package/ios/native/REAIOSScheduler.h +5 -5
- package/ios/native/REAIOSScheduler.mm +7 -5
- package/ios/native/REAInitializer.h +37 -0
- package/ios/native/REAInitializer.mm +63 -0
- package/ios/native/UIResponder+Reanimated.mm +9 -48
- package/lib/ConfigHelper.js +1 -0
- package/lib/ReanimatedModule.native.js +10 -2
- package/lib/createAnimatedComponent.js +64 -30
- package/lib/reanimated1/core/AnimatedAlways.js +1 -1
- package/lib/reanimated1/core/AnimatedBezier.js +1 -1
- package/lib/reanimated1/core/AnimatedBlock.js +1 -1
- package/lib/reanimated1/core/AnimatedCall.js +1 -1
- package/lib/reanimated1/core/AnimatedCallFunc.js +1 -1
- package/lib/reanimated1/core/AnimatedConcat.js +1 -1
- package/lib/reanimated1/core/AnimatedCond.js +1 -1
- package/lib/reanimated1/core/AnimatedDebug.js +1 -1
- package/lib/reanimated1/core/AnimatedEvent.js +1 -1
- package/lib/reanimated1/core/AnimatedFunction.js +1 -1
- package/lib/reanimated1/core/AnimatedOperator.js +1 -1
- package/lib/reanimated1/core/AnimatedParam.js +1 -1
- package/lib/reanimated1/core/AnimatedProps.js +2 -2
- package/lib/reanimated1/core/AnimatedSet.js +1 -1
- package/lib/reanimated1/core/AnimatedStartClock.js +1 -1
- package/lib/reanimated1/core/AnimatedStopClock.js +1 -1
- package/lib/reanimated1/core/AnimatedStyle.js +1 -1
- package/lib/reanimated1/core/AnimatedTransform.js +1 -1
- package/lib/reanimated1/core/Core.test.js +30 -0
- package/lib/reanimated1/core/InternalAnimatedValue.js +1 -1
- package/lib/reanimated1/core/__mocks__/AnimatedProps.js +1 -1
- package/lib/reanimated1/derived/interpolate.js +1 -1
- package/lib/reanimated2/Colors.js +16 -12
- package/lib/reanimated2/NativeMethods.js +3 -14
- package/lib/reanimated2/{NativeReanimated.native.js → NativeReanimated/NativeReanimated.js} +19 -24
- package/lib/reanimated2/NativeReanimated/index.js +15 -0
- package/lib/reanimated2/PlatformChecker.js +16 -0
- package/lib/reanimated2/PropAdapters.js +14 -4
- package/lib/reanimated2/UpdateProps.js +14 -11
- package/lib/reanimated2/ViewDescriptorsSet.js +73 -0
- package/lib/reanimated2/WorkletEventHandler.js +15 -13
- package/lib/reanimated2/animation/commonTypes.js +1 -0
- package/lib/reanimated2/animation/decay.js +71 -0
- package/lib/reanimated2/animation/delay.js +64 -0
- package/lib/reanimated2/animation/index.js +8 -0
- package/lib/reanimated2/animation/repeat.js +69 -0
- package/lib/reanimated2/animation/sequence.js +72 -0
- package/lib/reanimated2/animation/spring.js +101 -0
- package/lib/reanimated2/animation/styleAnimation.js +166 -0
- package/lib/reanimated2/animation/timing.js +64 -0
- package/lib/reanimated2/animation/util.js +157 -0
- package/lib/reanimated2/commonTypes.js +1 -0
- package/lib/reanimated2/core.js +35 -39
- package/lib/reanimated2/globals.d.ts +47 -1
- package/lib/reanimated2/hook/Hooks.js +9 -0
- package/lib/reanimated2/hook/commonTypes.js +1 -0
- package/lib/reanimated2/hook/index.js +8 -0
- package/lib/reanimated2/hook/useAnimatedGestureHandler.js +50 -0
- package/lib/reanimated2/hook/useAnimatedReaction.js +37 -0
- package/lib/reanimated2/hook/useAnimatedRef.js +25 -0
- package/lib/reanimated2/hook/useAnimatedScrollHandler.js +41 -0
- package/lib/reanimated2/hook/useAnimatedStyle.js +376 -0
- package/lib/reanimated2/hook/useDerivedValue.js +36 -0
- package/lib/reanimated2/hook/useSharedValue.js +17 -0
- package/lib/reanimated2/hook/utils.js +175 -0
- package/lib/reanimated2/index.js +3 -2
- package/lib/reanimated2/interpolation.js +95 -86
- package/lib/reanimated2/jestUtils.js +0 -12
- package/lib/reanimated2/js-reanimated/JSReanimated.js +9 -10
- package/lib/reanimated2/js-reanimated/index.js +57 -1
- package/lib/reanimated2/layoutReanimation/LayoutAnimationRepository.js +58 -0
- package/lib/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.js +69 -0
- package/lib/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js +125 -0
- package/lib/reanimated2/layoutReanimation/animationBuilder/Keyframe.js +193 -0
- package/lib/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +1 -0
- package/lib/reanimated2/layoutReanimation/animationBuilder/index.js +3 -0
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +325 -207
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Default.js +36 -0
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Fade.js +235 -187
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Flip.js +327 -269
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +146 -0
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js +85 -0
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Roll.js +119 -0
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Rotate.js +289 -0
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Slide.js +159 -121
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Stretch.js +83 -65
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +371 -277
- package/lib/reanimated2/layoutReanimation/defaultAnimations/index.js +4 -0
- package/lib/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js +78 -0
- package/lib/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js +128 -0
- package/lib/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js +37 -0
- package/lib/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js +41 -0
- package/lib/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js +34 -0
- package/lib/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js +46 -0
- package/lib/reanimated2/layoutReanimation/defaultTransitions/index.js +6 -0
- package/lib/reanimated2/layoutReanimation/index.js +3 -2
- package/lib/reanimated2/platform-specific/RNRenderer.web.js +2 -0
- package/lib/reanimated2/utils.js +9 -0
- package/libSo/fbjni/jni/arm64-v8a/libfbjni.so +0 -0
- package/libSo/fbjni/jni/armeabi-v7a/libfbjni.so +0 -0
- package/libSo/fbjni/jni/x86/libfbjni.so +0 -0
- package/libSo/fbjni/jni/x86_64/libfbjni.so +0 -0
- package/package.json +21 -10
- package/plugin.js +244 -85
- package/react-native-reanimated.d.ts +531 -453
- package/src/ConfigHelper.js +1 -0
- package/src/ReanimatedModule.native.js +10 -2
- package/src/createAnimatedComponent.js +64 -30
- package/src/reanimated1/core/AnimatedAlways.js +1 -1
- package/src/reanimated1/core/AnimatedBezier.js +1 -1
- package/src/reanimated1/core/AnimatedBlock.js +1 -1
- package/src/reanimated1/core/AnimatedCall.js +1 -1
- package/src/reanimated1/core/AnimatedCallFunc.js +1 -1
- package/src/reanimated1/core/AnimatedConcat.js +1 -1
- package/src/reanimated1/core/AnimatedCond.js +1 -1
- package/src/reanimated1/core/AnimatedDebug.js +1 -1
- package/src/reanimated1/core/AnimatedEvent.js +1 -1
- package/src/reanimated1/core/AnimatedFunction.js +1 -1
- package/src/reanimated1/core/AnimatedOperator.js +1 -1
- package/src/reanimated1/core/AnimatedParam.js +1 -1
- package/src/reanimated1/core/AnimatedProps.js +2 -2
- package/src/reanimated1/core/AnimatedSet.js +1 -1
- package/src/reanimated1/core/AnimatedStartClock.js +1 -1
- package/src/reanimated1/core/AnimatedStopClock.js +1 -1
- package/src/reanimated1/core/AnimatedStyle.js +1 -1
- package/src/reanimated1/core/AnimatedTransform.js +1 -1
- package/src/reanimated1/core/Core.test.js +30 -0
- package/src/reanimated1/core/InternalAnimatedValue.js +1 -1
- package/src/reanimated1/core/__mocks__/AnimatedProps.js +1 -1
- package/src/reanimated1/derived/interpolate.js +1 -1
- package/src/reanimated2/Colors.ts +30 -27
- package/src/reanimated2/Easing.ts +3 -1
- package/src/reanimated2/NativeMethods.ts +26 -16
- package/src/reanimated2/NativeReanimated/NativeReanimated.ts +78 -0
- package/src/reanimated2/NativeReanimated/index.ts +18 -0
- package/src/reanimated2/PlatformChecker.ts +21 -0
- package/src/reanimated2/PropAdapters.ts +52 -34
- package/src/reanimated2/UpdateProps.ts +40 -20
- package/src/reanimated2/ViewDescriptorsSet.ts +108 -0
- package/src/reanimated2/WorkletEventHandler.ts +41 -23
- package/src/reanimated2/animation/commonTypes.ts +48 -0
- package/src/reanimated2/animation/decay.ts +141 -0
- package/src/reanimated2/animation/delay.ts +103 -0
- package/src/reanimated2/animation/index.ts +16 -0
- package/src/reanimated2/animation/repeat.ts +128 -0
- package/src/reanimated2/animation/sequence.ts +110 -0
- package/src/reanimated2/animation/spring.ts +165 -0
- package/src/reanimated2/animation/styleAnimation.ts +253 -0
- package/src/reanimated2/animation/timing.ts +109 -0
- package/src/reanimated2/animation/util.ts +242 -0
- package/src/reanimated2/commonTypes.ts +81 -0
- package/src/reanimated2/core.ts +128 -82
- package/src/reanimated2/globals.d.ts +47 -1
- package/src/reanimated2/hook/Hooks.ts +16 -0
- package/src/reanimated2/hook/commonTypes.ts +12 -0
- package/src/reanimated2/hook/index.ts +25 -0
- package/src/reanimated2/hook/useAnimatedGestureHandler.ts +110 -0
- package/src/reanimated2/hook/useAnimatedReaction.ts +49 -0
- package/src/reanimated2/hook/useAnimatedRef.ts +34 -0
- package/src/reanimated2/hook/useAnimatedScrollHandler.ts +83 -0
- package/src/reanimated2/hook/useAnimatedStyle.ts +538 -0
- package/src/reanimated2/hook/useDerivedValue.ts +48 -0
- package/src/reanimated2/hook/useSharedValue.ts +22 -0
- package/src/reanimated2/hook/utils.ts +259 -0
- package/src/reanimated2/index.ts +3 -2
- package/src/reanimated2/interpolation.ts +170 -101
- package/src/reanimated2/jestUtils.ts +0 -12
- package/src/reanimated2/js-reanimated/JSReanimated.ts +47 -22
- package/src/reanimated2/js-reanimated/Mapper.ts +1 -1
- package/src/reanimated2/js-reanimated/index.ts +71 -0
- package/src/reanimated2/layoutReanimation/LayoutAnimationRepository.tsx +62 -0
- package/src/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.ts +91 -0
- package/src/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.ts +169 -0
- package/src/reanimated2/layoutReanimation/animationBuilder/Keyframe.ts +263 -0
- package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +78 -0
- package/src/reanimated2/layoutReanimation/animationBuilder/index.ts +16 -0
- package/src/reanimated2/layoutReanimation/defaultAnimations/Bounce.ts +243 -121
- package/src/reanimated2/layoutReanimation/defaultAnimations/Default.ts +43 -0
- package/src/reanimated2/layoutReanimation/defaultAnimations/Fade.ts +95 -53
- package/src/reanimated2/layoutReanimation/defaultAnimations/Flip.ts +114 -64
- package/src/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.ts +179 -0
- package/src/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.ts +93 -0
- package/src/reanimated2/layoutReanimation/defaultAnimations/Roll.ts +132 -0
- package/src/reanimated2/layoutReanimation/defaultAnimations/Rotate.ts +333 -0
- package/src/reanimated2/layoutReanimation/defaultAnimations/Slide.ts +84 -50
- package/src/reanimated2/layoutReanimation/defaultAnimations/Stretch.ts +41 -23
- package/src/reanimated2/layoutReanimation/defaultAnimations/Zoom.ts +234 -154
- package/src/reanimated2/layoutReanimation/defaultAnimations/index.ts +4 -0
- package/src/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.ts +104 -0
- package/src/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.ts +213 -0
- package/src/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.ts +60 -0
- package/src/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.ts +58 -0
- package/src/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.ts +41 -0
- package/src/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.ts +78 -0
- package/src/reanimated2/layoutReanimation/defaultTransitions/index.ts +6 -0
- package/src/reanimated2/layoutReanimation/index.ts +3 -2
- package/src/reanimated2/platform-specific/RNRenderer.web.ts +2 -0
- package/src/reanimated2/utils.ts +21 -0
- package/android/react-native-reanimated-62-hermes.aar +0 -0
- package/android/react-native-reanimated-62-jsc.aar +0 -0
- package/ios/LayoutReanimation/REAAnimationRootView.h +0 -12
- package/ios/LayoutReanimation/REAAnimationRootView.m +0 -16
- package/ios/LayoutReanimation/REAAnimationRootViewManager.h +0 -9
- package/ios/LayoutReanimation/REAAnimationRootViewManager.m +0 -49
- package/ios/LayoutReanimation/REAReactBatchObserver.h +0 -20
- package/ios/LayoutReanimation/REAReactBatchObserver.m +0 -125
- package/ios/LayoutReanimation/REASnapshooter.h +0 -19
- package/ios/LayoutReanimation/REASnapshooter.m +0 -64
- package/ios/LayoutReanimation/REAViewTraverser.h +0 -13
- package/ios/LayoutReanimation/REAViewTraverser.m +0 -40
- package/lib/reanimated2/Hooks.js +0 -732
- package/lib/reanimated2/NativeReanimated.js +0 -4
- package/lib/reanimated2/animations.js +0 -713
- package/lib/reanimated2/js-reanimated/index.web.js +0 -20
- package/lib/reanimated2/layoutReanimation/AnimatedRoot.js +0 -55
- package/lib/reanimated2/layoutReanimation/defaultAnimationsBuilder.js +0 -374
- package/src/reanimated2/Hooks.ts +0 -918
- package/src/reanimated2/NativeReanimated.native.ts +0 -61
- package/src/reanimated2/NativeReanimated.ts +0 -5
- package/src/reanimated2/animations.ts +0 -868
- package/src/reanimated2/js-reanimated/index.js +0 -0
- package/src/reanimated2/js-reanimated/index.web.ts +0 -29
- package/src/reanimated2/layoutReanimation/AnimatedRoot.tsx +0 -68
- package/src/reanimated2/layoutReanimation/defaultAnimationsBuilder.ts +0 -440
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
#import "REAUIManager.h"
|
|
2
|
+
#import <Foundation/Foundation.h>
|
|
3
|
+
#import "RCTComponentData.h"
|
|
4
|
+
#import "RCTUIManagerObserverCoordinator.h"
|
|
5
|
+
#import "RCTRootShadowView.h"
|
|
6
|
+
#import "RCTRootViewInternal.h"
|
|
7
|
+
#import "RCTLayoutAnimation.h"
|
|
8
|
+
#import "RCTLayoutAnimationGroup.h"
|
|
9
|
+
#import "REAIOSScheduler.h"
|
|
10
|
+
#include "Scheduler.h"
|
|
11
|
+
|
|
12
|
+
#if __has_include(<RNScreens/RNSScreen.h>)
|
|
13
|
+
#import <RNScreens/RNSScreen.h>
|
|
14
|
+
#endif
|
|
15
|
+
|
|
16
|
+
@interface RCTUIManager(REA)
|
|
17
|
+
- (void)_manageChildren:(NSNumber *)containerTag
|
|
18
|
+
moveFromIndices:(NSArray<NSNumber *> *)moveFromIndices
|
|
19
|
+
moveToIndices:(NSArray<NSNumber *> *)moveToIndices
|
|
20
|
+
addChildReactTags:(NSArray<NSNumber *> *)addChildReactTags
|
|
21
|
+
addAtIndices:(NSArray<NSNumber *> *)addAtIndices
|
|
22
|
+
removeAtIndices:(NSArray<NSNumber *> *)removeAtIndices
|
|
23
|
+
registry:(NSMutableDictionary<NSNumber *, id<RCTComponent>> *)registry;
|
|
24
|
+
|
|
25
|
+
- (NSArray<id<RCTComponent>> *)_childrenToRemoveFromContainer:(id<RCTComponent>)container
|
|
26
|
+
atIndices:(NSArray<NSNumber *> *)atIndices;
|
|
27
|
+
@end
|
|
28
|
+
|
|
29
|
+
@implementation REAUIManager
|
|
30
|
+
|
|
31
|
+
BOOL blockSetter = false;
|
|
32
|
+
NSMutableDictionary<NSNumber*, NSMutableSet<id<RCTComponent>>*>* _toBeRemovedRegister;
|
|
33
|
+
NSMutableDictionary<NSNumber*, NSNumber*>* _parentMapper;
|
|
34
|
+
REAAnimationsManager* _animationsManager;
|
|
35
|
+
std::weak_ptr<reanimated::Scheduler> _scheduler;
|
|
36
|
+
|
|
37
|
+
+ (NSString*)moduleName
|
|
38
|
+
{
|
|
39
|
+
return NSStringFromClass([RCTUIManager class]);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
- (void)setBridge:(RCTBridge *)bridge
|
|
43
|
+
{
|
|
44
|
+
if(!_blockSetter) {
|
|
45
|
+
_blockSetter = true;
|
|
46
|
+
|
|
47
|
+
self.bridge = bridge;
|
|
48
|
+
[super setValue:bridge forKey:@"_bridge"];
|
|
49
|
+
[self setValue:[bridge.uiManager valueForKey:@"_shadowViewRegistry"] forKey:@"_shadowViewRegistry"];
|
|
50
|
+
[self setValue:[bridge.uiManager valueForKey:@"_viewRegistry"] forKey:@"_viewRegistry"];
|
|
51
|
+
[self setValue:[bridge.uiManager valueForKey:@"_nativeIDRegistry"] forKey:@"_nativeIDRegistry"];
|
|
52
|
+
[self setValue:[bridge.uiManager valueForKey:@"_shadowViewsWithUpdatedProps"] forKey:@"_shadowViewsWithUpdatedProps"];
|
|
53
|
+
[self setValue:[bridge.uiManager valueForKey:@"_shadowViewsWithUpdatedChildren"] forKey:@"_shadowViewsWithUpdatedChildren"];
|
|
54
|
+
[self setValue:[bridge.uiManager valueForKey:@"_pendingUIBlocks"] forKey:@"_pendingUIBlocks"];
|
|
55
|
+
[self setValue:[bridge.uiManager valueForKey:@"_rootViewTags"] forKey:@"_rootViewTags"];
|
|
56
|
+
[self setValue:[bridge.uiManager valueForKey:@"_observerCoordinator"] forKey:@"_observerCoordinator"];
|
|
57
|
+
[self setValue:[bridge.uiManager valueForKey:@"_componentDataByName"] forKey:@"_componentDataByName"];
|
|
58
|
+
|
|
59
|
+
_blockSetter = false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
- (void)_manageChildren:(NSNumber *)containerTag
|
|
64
|
+
moveFromIndices:(NSArray<NSNumber *> *)moveFromIndices
|
|
65
|
+
moveToIndices:(NSArray<NSNumber *> *)moveToIndices
|
|
66
|
+
addChildReactTags:(NSArray<NSNumber *> *)addChildReactTags
|
|
67
|
+
addAtIndices:(NSArray<NSNumber *> *)addAtIndices
|
|
68
|
+
removeAtIndices:(NSArray<NSNumber *> *)removeAtIndices
|
|
69
|
+
registry:(NSMutableDictionary<NSNumber *, id<RCTComponent>> *)registry
|
|
70
|
+
{
|
|
71
|
+
BOOL isUIViewRegistry = ((id)registry == (id)[self valueForKey:@"_viewRegistry"]);
|
|
72
|
+
id<RCTComponent> container;
|
|
73
|
+
NSArray<id<RCTComponent>> *permanentlyRemovedChildren;
|
|
74
|
+
if(isUIViewRegistry) {
|
|
75
|
+
container = registry[containerTag];
|
|
76
|
+
for(id<RCTComponent> toRemoveChild in _toBeRemovedRegister[containerTag]) {
|
|
77
|
+
[container removeReactSubview:toRemoveChild];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
permanentlyRemovedChildren = [super _childrenToRemoveFromContainer:container atIndices:removeAtIndices];
|
|
81
|
+
if(permanentlyRemovedChildren != nil) {
|
|
82
|
+
for(id<RCTComponent> permanentlyRemovedChild in permanentlyRemovedChildren) {
|
|
83
|
+
if(_toBeRemovedRegister[containerTag] == nil) {
|
|
84
|
+
_toBeRemovedRegister[containerTag] = [[NSMutableSet<id<RCTComponent>> alloc] init];
|
|
85
|
+
}
|
|
86
|
+
[_toBeRemovedRegister[containerTag] addObject:permanentlyRemovedChild];
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
[super _manageChildren:containerTag
|
|
92
|
+
moveFromIndices:moveFromIndices
|
|
93
|
+
moveToIndices:moveToIndices
|
|
94
|
+
addChildReactTags:addChildReactTags
|
|
95
|
+
addAtIndices:addAtIndices
|
|
96
|
+
removeAtIndices:removeAtIndices
|
|
97
|
+
registry:registry];
|
|
98
|
+
|
|
99
|
+
if(isUIViewRegistry) {
|
|
100
|
+
NSMutableDictionary<NSNumber *, id<RCTComponent>> *viewRegistry = [self valueForKey:@"_viewRegistry"];
|
|
101
|
+
for(id<RCTComponent> toRemoveChild in _toBeRemovedRegister[containerTag]) {
|
|
102
|
+
NSInteger lastIndex = [container reactSubviews].count - 1;
|
|
103
|
+
if(lastIndex < 0) {
|
|
104
|
+
lastIndex = 0;
|
|
105
|
+
}
|
|
106
|
+
[container insertReactSubview:toRemoveChild atIndex:lastIndex];
|
|
107
|
+
viewRegistry[toRemoveChild.reactTag] = toRemoveChild;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
for (UIView *removedChild in permanentlyRemovedChildren) {
|
|
111
|
+
[self callAnimationForTree: removedChild parentTag:containerTag];
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
- (void) callAnimationForTree:(UIView*) view parentTag:(NSNumber*) parentTag
|
|
117
|
+
{
|
|
118
|
+
REASnapshot* snapshot = [[REASnapshot alloc] init:view];
|
|
119
|
+
_parentMapper[view.reactTag] = parentTag;
|
|
120
|
+
[_animationsManager onViewRemoval:view before:snapshot];
|
|
121
|
+
|
|
122
|
+
for(UIView* subView in view.reactSubviews) {
|
|
123
|
+
[self callAnimationForTree:subView parentTag:view.reactTag];
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Overrided https://github.com/facebook/react-native/blob/v0.65.0/React/Modules/RCTUIManager.m#L530
|
|
128
|
+
- (RCTViewManagerUIBlock)uiBlockWithLayoutUpdateForRootView:(RCTRootShadowView *)rootShadowView
|
|
129
|
+
{
|
|
130
|
+
NSHashTable<RCTShadowView *> *affectedShadowViews = [NSHashTable weakObjectsHashTable];
|
|
131
|
+
[rootShadowView layoutWithAffectedShadowViews:affectedShadowViews];
|
|
132
|
+
|
|
133
|
+
if (!affectedShadowViews.count) {
|
|
134
|
+
// no frame change results in no UI update block
|
|
135
|
+
return nil;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
typedef struct {
|
|
139
|
+
CGRect frame;
|
|
140
|
+
UIUserInterfaceLayoutDirection layoutDirection;
|
|
141
|
+
BOOL isNew;
|
|
142
|
+
BOOL parentIsNew;
|
|
143
|
+
RCTDisplayType displayType;
|
|
144
|
+
} RCTFrameData;
|
|
145
|
+
|
|
146
|
+
// Construct arrays then hand off to main thread
|
|
147
|
+
NSUInteger count = affectedShadowViews.count;
|
|
148
|
+
NSMutableArray *reactTags = [[NSMutableArray alloc] initWithCapacity:count];
|
|
149
|
+
NSMutableData *framesData = [[NSMutableData alloc] initWithLength:sizeof(RCTFrameData) * count];
|
|
150
|
+
{
|
|
151
|
+
NSUInteger index = 0;
|
|
152
|
+
RCTFrameData *frameDataArray = (RCTFrameData *)framesData.mutableBytes;
|
|
153
|
+
for (RCTShadowView *shadowView in affectedShadowViews) {
|
|
154
|
+
reactTags[index] = shadowView.reactTag;
|
|
155
|
+
RCTLayoutMetrics layoutMetrics = shadowView.layoutMetrics;
|
|
156
|
+
frameDataArray[index++] = (RCTFrameData){layoutMetrics.frame,
|
|
157
|
+
layoutMetrics.layoutDirection,
|
|
158
|
+
shadowView.isNewView,
|
|
159
|
+
shadowView.superview.isNewView,
|
|
160
|
+
layoutMetrics.displayType};
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
for (RCTShadowView *shadowView in affectedShadowViews) {
|
|
165
|
+
// We have to do this after we build the parentsAreNew array.
|
|
166
|
+
shadowView.newView = NO;
|
|
167
|
+
|
|
168
|
+
NSNumber *reactTag = shadowView.reactTag;
|
|
169
|
+
|
|
170
|
+
if (shadowView.onLayout) {
|
|
171
|
+
CGRect frame = shadowView.layoutMetrics.frame;
|
|
172
|
+
shadowView.onLayout(@{
|
|
173
|
+
@"layout" : @{
|
|
174
|
+
@"x" : @(frame.origin.x),
|
|
175
|
+
@"y" : @(frame.origin.y),
|
|
176
|
+
@"width" : @(frame.size.width),
|
|
177
|
+
@"height" : @(frame.size.height),
|
|
178
|
+
},
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (RCTIsReactRootView(reactTag) && [shadowView isKindOfClass:[RCTRootShadowView class]]) {
|
|
183
|
+
CGSize contentSize = shadowView.layoutMetrics.frame.size;
|
|
184
|
+
|
|
185
|
+
RCTExecuteOnMainQueue(^{
|
|
186
|
+
NSMutableDictionary<NSNumber *, UIView *>* viewRegistry = [self valueForKey:@"_viewRegistry"];
|
|
187
|
+
UIView *view = viewRegistry[reactTag];
|
|
188
|
+
RCTAssert(view != nil, @"view (for ID %@) not found", reactTag);
|
|
189
|
+
|
|
190
|
+
RCTRootView *rootView = (RCTRootView *)[view superview];
|
|
191
|
+
if ([rootView isKindOfClass:[RCTRootView class]]) {
|
|
192
|
+
rootView.intrinsicContentSize = contentSize;
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// Perform layout (possibly animated)
|
|
199
|
+
return ^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
200
|
+
const RCTFrameData *frameDataArray = (const RCTFrameData *)framesData.bytes;
|
|
201
|
+
RCTLayoutAnimationGroup *layoutAnimationGroup = [uiManager valueForKey:@"_layoutAnimationGroup"];
|
|
202
|
+
|
|
203
|
+
__block NSUInteger completionsCalled = 0;
|
|
204
|
+
|
|
205
|
+
NSInteger index = 0;
|
|
206
|
+
for (NSNumber *reactTag in reactTags) {
|
|
207
|
+
RCTFrameData frameData = frameDataArray[index++];
|
|
208
|
+
|
|
209
|
+
UIView *view = viewRegistry[reactTag];
|
|
210
|
+
CGRect frame = frameData.frame;
|
|
211
|
+
|
|
212
|
+
UIUserInterfaceLayoutDirection layoutDirection = frameData.layoutDirection;
|
|
213
|
+
BOOL isNew = frameData.isNew;
|
|
214
|
+
RCTLayoutAnimation *updatingLayoutAnimation = isNew ? nil : layoutAnimationGroup.updatingLayoutAnimation;
|
|
215
|
+
BOOL shouldAnimateCreation = isNew && !frameData.parentIsNew;
|
|
216
|
+
RCTLayoutAnimation *creatingLayoutAnimation =
|
|
217
|
+
shouldAnimateCreation ? layoutAnimationGroup.creatingLayoutAnimation : nil;
|
|
218
|
+
BOOL isHidden = frameData.displayType == RCTDisplayTypeNone;
|
|
219
|
+
|
|
220
|
+
void (^completion)(BOOL) = ^(BOOL finished) {
|
|
221
|
+
completionsCalled++;
|
|
222
|
+
if (layoutAnimationGroup.callback && completionsCalled == count) {
|
|
223
|
+
layoutAnimationGroup.callback(@[ @(finished) ]);
|
|
224
|
+
|
|
225
|
+
// It's unsafe to call this callback more than once, so we nil it out here
|
|
226
|
+
// to make sure that doesn't happen.
|
|
227
|
+
layoutAnimationGroup.callback = nil;
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
if (view.reactLayoutDirection != layoutDirection) {
|
|
232
|
+
view.reactLayoutDirection = layoutDirection;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
if (view.isHidden != isHidden) {
|
|
236
|
+
view.hidden = isHidden;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
REASnapshot* snapshotBefore = [[REASnapshot alloc] init:view];
|
|
240
|
+
if (creatingLayoutAnimation) {
|
|
241
|
+
// Animate view creation
|
|
242
|
+
[view reactSetFrame:frame];
|
|
243
|
+
|
|
244
|
+
CATransform3D finalTransform = view.layer.transform;
|
|
245
|
+
CGFloat finalOpacity = view.layer.opacity;
|
|
246
|
+
|
|
247
|
+
NSString *property = creatingLayoutAnimation.property;
|
|
248
|
+
if ([property isEqualToString:@"scaleXY"]) {
|
|
249
|
+
view.layer.transform = CATransform3DMakeScale(0, 0, 0);
|
|
250
|
+
} else if ([property isEqualToString:@"scaleX"]) {
|
|
251
|
+
view.layer.transform = CATransform3DMakeScale(0, 1, 0);
|
|
252
|
+
} else if ([property isEqualToString:@"scaleY"]) {
|
|
253
|
+
view.layer.transform = CATransform3DMakeScale(1, 0, 0);
|
|
254
|
+
} else if ([property isEqualToString:@"opacity"]) {
|
|
255
|
+
view.layer.opacity = 0.0;
|
|
256
|
+
} else {
|
|
257
|
+
RCTLogError(@"Unsupported layout animation createConfig property %@", creatingLayoutAnimation.property);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
[creatingLayoutAnimation
|
|
261
|
+
performAnimations:^{
|
|
262
|
+
if ([property isEqualToString:@"scaleX"] || [property isEqualToString:@"scaleY"] ||
|
|
263
|
+
[property isEqualToString:@"scaleXY"]) {
|
|
264
|
+
view.layer.transform = finalTransform;
|
|
265
|
+
} else if ([property isEqualToString:@"opacity"]) {
|
|
266
|
+
view.layer.opacity = finalOpacity;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
withCompletionBlock:completion];
|
|
270
|
+
|
|
271
|
+
} else if (updatingLayoutAnimation) {
|
|
272
|
+
// Animate view update
|
|
273
|
+
[updatingLayoutAnimation
|
|
274
|
+
performAnimations:^{
|
|
275
|
+
[view reactSetFrame:frame];
|
|
276
|
+
}
|
|
277
|
+
withCompletionBlock:completion];
|
|
278
|
+
|
|
279
|
+
} else {
|
|
280
|
+
// Update without animation
|
|
281
|
+
[view reactSetFrame:frame];
|
|
282
|
+
completion(YES);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
if(isNew) {
|
|
286
|
+
REASnapshot* snapshot = [[REASnapshot alloc] init:view];
|
|
287
|
+
[_animationsManager onViewCreate:view after:snapshot];
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
REASnapshot* snapshotAfter = [[REASnapshot alloc] init:view];
|
|
291
|
+
[_animationsManager onViewUpdate:view before:snapshotBefore after:snapshotAfter];
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
[_animationsManager removeLeftovers];
|
|
297
|
+
// Clean up
|
|
298
|
+
[uiManager setValue:nil forKey:@"_layoutAnimationGroup"];
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
- (Class)class
|
|
303
|
+
{
|
|
304
|
+
return [RCTUIManager class];
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
+ (Class)class
|
|
308
|
+
{
|
|
309
|
+
return [RCTUIManager class];
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
- (void)setUp:(REAAnimationsManager*) animationsManager
|
|
313
|
+
{
|
|
314
|
+
_animationsManager = animationsManager;
|
|
315
|
+
_toBeRemovedRegister = [[NSMutableDictionary<NSNumber*, NSMutableSet<id<RCTComponent>>*> alloc] init];
|
|
316
|
+
_parentMapper = [[NSMutableDictionary<NSNumber*, NSNumber*> alloc] init];
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
- (void)unregisterView:(id<RCTComponent>) view
|
|
320
|
+
{
|
|
321
|
+
NSNumber* tag = _parentMapper[view.reactTag];
|
|
322
|
+
if(tag == nil) {
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
[_toBeRemovedRegister[tag] removeObject:view];
|
|
327
|
+
if(_toBeRemovedRegister[tag].count == 0) {
|
|
328
|
+
[_toBeRemovedRegister removeObjectForKey:tag];
|
|
329
|
+
}
|
|
330
|
+
NSMutableDictionary<NSNumber *, id<RCTComponent>> *viewRegistry = [self valueForKey:@"_viewRegistry"];
|
|
331
|
+
[view.reactSuperview removeReactSubview:view];
|
|
332
|
+
id<RCTComponent> parentView = viewRegistry[tag];
|
|
333
|
+
[parentView removeReactSubview:view];
|
|
334
|
+
#if __has_include(<RNScreens/RNSScreen.h>)
|
|
335
|
+
if ([view isKindOfClass:[RNSScreenView class]]) {
|
|
336
|
+
[parentView didUpdateReactSubviews];
|
|
337
|
+
}
|
|
338
|
+
#endif
|
|
339
|
+
[viewRegistry removeObjectForKey:view.reactTag];
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
- (void)batchDidComplete
|
|
343
|
+
{
|
|
344
|
+
self.flushUiOperations();
|
|
345
|
+
[super batchDidComplete];
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
@end
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
#import "REAAlwaysNode.h"
|
|
2
|
-
#import "REAUtils.h"
|
|
3
|
-
#import "REANodesManager.h"
|
|
4
|
-
#import "REAStyleNode.h"
|
|
5
|
-
#import "REAModule.h"
|
|
6
|
-
#import <React/RCTLog.h>
|
|
7
2
|
#import <React/RCTConvert.h>
|
|
3
|
+
#import <React/RCTLog.h>
|
|
8
4
|
#import <React/RCTUIManager.h>
|
|
5
|
+
#import "REAModule.h"
|
|
6
|
+
#import "REANodesManager.h"
|
|
7
|
+
#import "REAStyleNode.h"
|
|
8
|
+
#import "REAUtils.h"
|
|
9
9
|
|
|
10
|
-
@implementation REAAlwaysNode
|
|
11
|
-
|
|
12
|
-
NSNumber * _nodeToBeEvaluated;
|
|
10
|
+
@implementation REAAlwaysNode {
|
|
11
|
+
NSNumber *_nodeToBeEvaluated;
|
|
13
12
|
}
|
|
14
13
|
|
|
15
|
-
- (instancetype)initWithID:(REANodeID)nodeID config:(NSDictionary<NSString *,id> *)config
|
|
14
|
+
- (instancetype)initWithID:(REANodeID)nodeID config:(NSDictionary<NSString *, id> *)config
|
|
16
15
|
{
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
if ((self = [super initWithID:nodeID config:config])) {
|
|
17
|
+
_nodeToBeEvaluated = [RCTConvert NSNumber:config[@"what"]];
|
|
18
|
+
REA_LOG_ERROR_IF_NIL(
|
|
19
|
+
_nodeToBeEvaluated, @"Reanimated: First argument passed to always node is either of wrong type or is missing.");
|
|
20
|
+
}
|
|
21
|
+
return self;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
- (id)evaluate
|
|
@@ -33,4 +33,3 @@
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
@end
|
|
36
|
-
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#include <tgmath.h>
|
|
2
2
|
|
|
3
|
-
#import "REABezierNode.h"
|
|
4
|
-
#import "REAUtils.h"
|
|
5
|
-
#import "REANodesManager.h"
|
|
6
3
|
#import <React/RCTConvert.h>
|
|
7
4
|
#import <React/RCTLog.h>
|
|
5
|
+
#import "REABezierNode.h"
|
|
6
|
+
#import "REANodesManager.h"
|
|
7
|
+
#import "REAUtils.h"
|
|
8
8
|
|
|
9
9
|
#define EPS 1e-5
|
|
10
10
|
|
|
@@ -13,11 +13,12 @@
|
|
|
13
13
|
NSNumber *_inputNodeID;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
- (instancetype)initWithID:(REANodeID)nodeID config:(NSDictionary<NSString *,id> *)config
|
|
16
|
+
- (instancetype)initWithID:(REANodeID)nodeID config:(NSDictionary<NSString *, id> *)config
|
|
17
17
|
{
|
|
18
18
|
if ((self = [super initWithID:nodeID config:config])) {
|
|
19
19
|
_inputNodeID = [RCTConvert NSNumber:config[@"input"]];
|
|
20
|
-
REA_LOG_ERROR_IF_NIL(
|
|
20
|
+
REA_LOG_ERROR_IF_NIL(
|
|
21
|
+
_inputNodeID, @"Reanimated: First argument passed to bezier node is either of wrong type or is missing.");
|
|
21
22
|
|
|
22
23
|
CGFloat mX1 = [config[@"mX1"] doubleValue];
|
|
23
24
|
CGFloat mY1 = [config[@"mY1"] doubleValue];
|
|
@@ -27,7 +28,7 @@
|
|
|
27
28
|
// Calculate the polynomial coefficients, implicit first and last control points are (0,0) and (1,1).
|
|
28
29
|
cx = 3.0 * mX1;
|
|
29
30
|
bx = 3.0 * (mX2 - mX1) - cx;
|
|
30
|
-
ax = 1.0 - cx -bx;
|
|
31
|
+
ax = 1.0 - cx - bx;
|
|
31
32
|
|
|
32
33
|
cy = 3.0 * mY1;
|
|
33
34
|
by = 3.0 * (mY2 - mY1) - cy;
|
|
@@ -60,7 +61,7 @@
|
|
|
60
61
|
// First try a few iterations of Newton's method -- normally very fast.
|
|
61
62
|
for (t2 = x, i = 0; i < 8; i++) {
|
|
62
63
|
x2 = [self sampleCurveX:t2] - x;
|
|
63
|
-
if (fabs
|
|
64
|
+
if (fabs(x2) < epsilon)
|
|
64
65
|
return t2;
|
|
65
66
|
d2 = [self sampleCurveDerivativeX:t2];
|
|
66
67
|
if (fabs(d2) < 1e-6)
|
package/ios/Nodes/REABlockNode.m
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
NSArray<NSNumber *> *_block;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
- (instancetype)initWithID:(REANodeID)nodeID config:(NSDictionary<NSString *,id> *)config
|
|
8
|
+
- (instancetype)initWithID:(REANodeID)nodeID config:(NSDictionary<NSString *, id> *)config
|
|
9
9
|
{
|
|
10
10
|
if ((self = [super initWithID:nodeID config:config])) {
|
|
11
11
|
_block = config[@"block"];
|
|
@@ -2,22 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
#import "REACallFuncNode.h"
|
|
4
4
|
#import "REAFunctionNode.h"
|
|
5
|
-
#import "REAUtils.h"
|
|
6
|
-
#import "REAParamNode.h"
|
|
7
5
|
#import "REANodesManager.h"
|
|
6
|
+
#import "REAParamNode.h"
|
|
7
|
+
#import "REAUtils.h"
|
|
8
8
|
|
|
9
9
|
@implementation REACallFuncNode {
|
|
10
10
|
NSNumber *_whatNodeID;
|
|
11
11
|
NSArray<NSNumber *> *_args;
|
|
12
12
|
NSArray<NSNumber *> *_params;
|
|
13
|
-
NSString*
|
|
13
|
+
NSString *_prevCallID;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
- (instancetype)initWithID:(REANodeID)nodeID config:(NSDictionary<NSString *,id> *)config
|
|
16
|
+
- (instancetype)initWithID:(REANodeID)nodeID config:(NSDictionary<NSString *, id> *)config
|
|
17
17
|
{
|
|
18
18
|
if ((self = [super initWithID:nodeID config:config])) {
|
|
19
19
|
_whatNodeID = config[@"what"];
|
|
20
|
-
REA_LOG_ERROR_IF_NIL(
|
|
20
|
+
REA_LOG_ERROR_IF_NIL(
|
|
21
|
+
_whatNodeID, @"Reanimated: First argument passed to callFunc node is either of wrong type or is missing.");
|
|
21
22
|
_args = config[@"args"];
|
|
22
23
|
_params = config[@"params"];
|
|
23
24
|
_prevCallID = NULL;
|
|
@@ -27,13 +28,14 @@
|
|
|
27
28
|
|
|
28
29
|
- (void)beginContext
|
|
29
30
|
{
|
|
30
|
-
// To ensure that functions can be called multiple times in the same animation frame
|
|
31
|
+
// To ensure that functions can be called multiple times in the same animation frame
|
|
31
32
|
// (functions might have different parameters and might be called multiple times)
|
|
32
33
|
// we inform the current update context about where we are called from by setting the
|
|
33
34
|
// current call id - this will ensure that memoization is correct for function nodes.
|
|
34
35
|
_prevCallID = self.updateContext.callID;
|
|
35
|
-
self.updateContext.callID =
|
|
36
|
-
|
|
36
|
+
self.updateContext.callID =
|
|
37
|
+
[NSString stringWithFormat:@"%@/%@", self.updateContext.callID, [self.nodeID stringValue]];
|
|
38
|
+
|
|
37
39
|
// A CallFuncNode has a reference to a function node which holds the node graph that should
|
|
38
40
|
// be updated. A Function node has a list of ParamNodes which are basically nodes that can
|
|
39
41
|
// reference other nodes. When we start a new function call we update the parameter nodes
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#import "REAClockNodes.h"
|
|
2
|
-
#import "REAUtils.h"
|
|
3
|
-
#import "REANodesManager.h"
|
|
4
|
-
#import "REAParamNode.h"
|
|
5
2
|
#import <React/RCTConvert.h>
|
|
6
3
|
#import <React/RCTLog.h>
|
|
4
|
+
#import "REANodesManager.h"
|
|
5
|
+
#import "REAParamNode.h"
|
|
6
|
+
#import "REAUtils.h"
|
|
7
7
|
|
|
8
8
|
@interface REAClockNode ()
|
|
9
9
|
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
@implementation REAClockNode
|
|
15
15
|
|
|
16
|
-
- (instancetype)initWithID:(REANodeID)nodeID config:(NSDictionary<NSString *,id> *)config
|
|
16
|
+
- (instancetype)initWithID:(REANodeID)nodeID config:(NSDictionary<NSString *, id> *)config
|
|
17
17
|
{
|
|
18
18
|
if ((self = [super initWithID:nodeID config:config])) {
|
|
19
19
|
_isRunning = NO;
|
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
|
|
24
24
|
- (void)start
|
|
25
25
|
{
|
|
26
|
-
if (_isRunning)
|
|
26
|
+
if (_isRunning)
|
|
27
|
+
return;
|
|
27
28
|
_isRunning = YES;
|
|
28
29
|
|
|
29
30
|
__block __weak void (^weak_animationClb)(CADisplayLink *displayLink);
|
|
@@ -31,7 +32,8 @@
|
|
|
31
32
|
__weak REAClockNode *weakSelf = self;
|
|
32
33
|
|
|
33
34
|
weak_animationClb = animationClb = ^(CADisplayLink *displayLink) {
|
|
34
|
-
if (!weakSelf.isRunning)
|
|
35
|
+
if (!weakSelf.isRunning)
|
|
36
|
+
return;
|
|
35
37
|
[weakSelf markUpdated];
|
|
36
38
|
[weakSelf.nodesManager postOnAnimation:weak_animationClb];
|
|
37
39
|
};
|
|
@@ -55,18 +57,19 @@
|
|
|
55
57
|
NSNumber *_clockNodeID;
|
|
56
58
|
}
|
|
57
59
|
|
|
58
|
-
- (instancetype)initWithID:(REANodeID)nodeID config:(NSDictionary<NSString *,id> *)config
|
|
60
|
+
- (instancetype)initWithID:(REANodeID)nodeID config:(NSDictionary<NSString *, id> *)config
|
|
59
61
|
{
|
|
60
62
|
if ((self = [super initWithID:nodeID config:config])) {
|
|
61
63
|
_clockNodeID = [RCTConvert NSNumber:config[@"clock"]];
|
|
62
|
-
REA_LOG_ERROR_IF_NIL(
|
|
64
|
+
REA_LOG_ERROR_IF_NIL(
|
|
65
|
+
_clockNodeID, @"Reanimated: First argument passed to clock node is either of wrong type or is missing.");
|
|
63
66
|
}
|
|
64
67
|
return self;
|
|
65
68
|
}
|
|
66
69
|
|
|
67
|
-
- (REANode*)clockNode
|
|
70
|
+
- (REANode *)clockNode
|
|
68
71
|
{
|
|
69
|
-
return (REANode*)[self.nodesManager findNodeByID:_clockNodeID];
|
|
72
|
+
return (REANode *)[self.nodesManager findNodeByID:_clockNodeID];
|
|
70
73
|
}
|
|
71
74
|
|
|
72
75
|
@end
|
|
@@ -75,11 +78,11 @@
|
|
|
75
78
|
|
|
76
79
|
- (id)evaluate
|
|
77
80
|
{
|
|
78
|
-
REANode*
|
|
81
|
+
REANode *node = [self clockNode];
|
|
79
82
|
if ([node isKindOfClass:[REAParamNode class]]) {
|
|
80
|
-
[(REAParamNode*
|
|
83
|
+
[(REAParamNode *)node start];
|
|
81
84
|
} else {
|
|
82
|
-
[(REAClockNode*
|
|
85
|
+
[(REAClockNode *)node start];
|
|
83
86
|
}
|
|
84
87
|
return @(0);
|
|
85
88
|
}
|
|
@@ -90,27 +93,26 @@
|
|
|
90
93
|
|
|
91
94
|
- (id)evaluate
|
|
92
95
|
{
|
|
93
|
-
REANode*
|
|
96
|
+
REANode *node = [self clockNode];
|
|
94
97
|
if ([node isKindOfClass:[REAParamNode class]]) {
|
|
95
|
-
[(REAParamNode*
|
|
98
|
+
[(REAParamNode *)node stop];
|
|
96
99
|
} else {
|
|
97
|
-
[(REAClockNode*
|
|
100
|
+
[(REAClockNode *)node stop];
|
|
98
101
|
}
|
|
99
102
|
return @(0);
|
|
100
103
|
}
|
|
101
104
|
|
|
102
|
-
|
|
103
105
|
@end
|
|
104
106
|
|
|
105
107
|
@implementation REAClockTestNode
|
|
106
108
|
|
|
107
109
|
- (id)evaluate
|
|
108
110
|
{
|
|
109
|
-
REANode*
|
|
111
|
+
REANode *node = [self clockNode];
|
|
110
112
|
if ([node isKindOfClass:[REAParamNode class]]) {
|
|
111
|
-
return @(((REAParamNode*
|
|
113
|
+
return @(((REAParamNode *)node).isRunning ? 1 : 0);
|
|
112
114
|
}
|
|
113
|
-
return @([(REAClockNode*
|
|
115
|
+
return @([(REAClockNode *)node isRunning] ? 1 : 0);
|
|
114
116
|
}
|
|
115
117
|
|
|
116
118
|
@end
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#import "REAConcatNode.h"
|
|
2
|
-
#import "REAValueNode.h"
|
|
3
2
|
#import "REANodesManager.h"
|
|
3
|
+
#import "REAValueNode.h"
|
|
4
4
|
|
|
5
5
|
@implementation REAConcatNode {
|
|
6
6
|
NSArray<NSNumber *> *_input;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
- (instancetype)initWithID:(REANodeID)nodeID config:(NSDictionary<NSString *,id> *)config
|
|
9
|
+
- (instancetype)initWithID:(REANodeID)nodeID config:(NSDictionary<NSString *, id> *)config
|
|
10
10
|
{
|
|
11
11
|
if ((self = [super initWithID:nodeID config:config])) {
|
|
12
12
|
_input = config[@"input"];
|
package/ios/Nodes/REACondNode.m
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#import "REACondNode.h"
|
|
2
|
-
#import "REANodesManager.h"
|
|
3
2
|
#import <React/RCTConvert.h>
|
|
4
|
-
#import "REAUtils.h"
|
|
5
3
|
#import <React/RCTLog.h>
|
|
4
|
+
#import "REANodesManager.h"
|
|
5
|
+
#import "REAUtils.h"
|
|
6
6
|
|
|
7
7
|
@implementation REACondNode {
|
|
8
8
|
NSNumber *_condNodeID;
|
|
@@ -10,13 +10,15 @@
|
|
|
10
10
|
NSNumber *_elseBlockID;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
- (instancetype)initWithID:(REANodeID)nodeID config:(NSDictionary<NSString *,id> *)config
|
|
13
|
+
- (instancetype)initWithID:(REANodeID)nodeID config:(NSDictionary<NSString *, id> *)config
|
|
14
14
|
{
|
|
15
15
|
if ((self = [super initWithID:nodeID config:config])) {
|
|
16
16
|
_condNodeID = [RCTConvert NSNumber:config[@"cond"]];
|
|
17
|
-
REA_LOG_ERROR_IF_NIL(
|
|
17
|
+
REA_LOG_ERROR_IF_NIL(
|
|
18
|
+
_condNodeID, @"Reanimated: First argument passed to cond node is either of wrong type or is missing.");
|
|
18
19
|
_ifBlockID = [RCTConvert NSNumber:config[@"ifBlock"]];
|
|
19
|
-
REA_LOG_ERROR_IF_NIL(
|
|
20
|
+
REA_LOG_ERROR_IF_NIL(
|
|
21
|
+
_ifBlockID, @"Reanimated: Second argument passed to cond node is either of wrong type or is missing.");
|
|
20
22
|
_elseBlockID = [RCTConvert NSNumber:config[@"elseBlock"]];
|
|
21
23
|
}
|
|
22
24
|
return self;
|