react-native-reanimated 2.8.0 → 2.10.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 +4 -4
- package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +38 -0
- package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +23 -0
- package/Common/cpp/Tools/RuntimeDecorator.cpp +17 -11
- package/Common/cpp/headers/NativeModules/NativeReanimatedModule.h +8 -0
- package/Common/cpp/headers/NativeModules/NativeReanimatedModuleSpec.h +8 -0
- package/Common/cpp/headers/Tools/PlatformDepMethodsHolder.h +5 -0
- package/RNReanimated.podspec +22 -3
- package/android/.gradle/7.2/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/7.2/executionHistory/executionHistory.bin +0 -0
- package/android/.gradle/7.2/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/7.2/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/7.2/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.2/fileHashes/resourceHashesCache.bin +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +1 -1
- package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
- package/android/.gradle/checksums/checksums.lock +0 -0
- package/android/.gradle/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/checksums/sha1-checksums.bin +0 -0
- package/android/CMakeLists.txt +216 -84
- package/android/build.gradle +255 -229
- package/android/react-native-reanimated-66-hermes.aar +0 -0
- package/android/react-native-reanimated-66-jsc.aar +0 -0
- package/android/react-native-reanimated-67-hermes.aar +0 -0
- package/android/react-native-reanimated-67-jsc.aar +0 -0
- package/android/react-native-reanimated-68-hermes.aar +0 -0
- package/android/react-native-reanimated-68-jsc.aar +0 -0
- package/android/react-native-reanimated-69-hermes.aar +0 -0
- package/android/react-native-reanimated-69-jsc.aar +0 -0
- package/android/react-native-reanimated-70-hermes.aar +0 -0
- package/android/react-native-reanimated-70-jsc.aar +0 -0
- package/{lib/types/lib/reanimated2/platform-specific/RNRenderer.web.d.ts → android/rnVersionPatch/69/.gitkeep} +0 -0
- package/android/rnVersionPatch/70/.gitkeep +0 -0
- package/android/src/main/cpp/NativeProxy.cpp +56 -11
- package/android/src/main/cpp/OnLoad.cpp +1 -0
- package/android/src/main/cpp/headers/NativeProxy.h +29 -0
- package/android/src/main/java/com/swmansion/reanimated/NativeProxy.java +25 -0
- package/android/src/main/java/com/swmansion/reanimated/NodesManager.java +3 -1
- package/android/src/main/java/com/swmansion/reanimated/keyboardObserver/ReanimatedKeyboardEventListener.java +165 -0
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/AnimationsManager.java +19 -16
- package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensor.java +5 -1
- package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorListener.java +24 -1
- package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorType.java +7 -5
- package/ios/REANodesManager.m +31 -8
- package/ios/keyboardObserver/REAKeyboardEventObserver.h +17 -0
- package/ios/keyboardObserver/REAKeyboardEventObserver.m +198 -0
- package/ios/native/NativeProxy.mm +20 -1
- package/ios/native/REAInitializer.mm +10 -4
- package/ios/sensor/ReanimatedSensor.m +27 -18
- package/lib/Animated.js +8 -21
- package/lib/index.js +12 -20
- package/lib/index.web.js +4 -0
- package/lib/reanimated2/Colors.js +1 -1
- package/lib/reanimated2/NativeMethods.js +3 -0
- package/lib/reanimated2/NativeReanimated/NativeReanimated.js +7 -1
- package/lib/reanimated2/animation/sequence.js +0 -3
- package/lib/reanimated2/animation/util.js +4 -1
- package/lib/reanimated2/commonTypes.js +8 -1
- package/lib/reanimated2/component/FlatList.js +8 -8
- package/lib/reanimated2/component/Image.js +4 -0
- package/lib/reanimated2/component/ScrollView.js +4 -0
- package/lib/reanimated2/component/Text.js +4 -0
- package/lib/reanimated2/component/View.js +4 -0
- package/lib/reanimated2/core.js +5 -9
- package/lib/reanimated2/frameCallback/FrameCallbackRegistryJS.js +32 -0
- package/lib/reanimated2/frameCallback/FrameCallbackRegistryUI.js +47 -0
- package/lib/reanimated2/globals.d.ts +3 -0
- package/lib/reanimated2/hook/index.js +2 -0
- package/lib/reanimated2/hook/useAnimatedKeyboard.js +31 -0
- package/lib/reanimated2/hook/useAnimatedSensor.js +3 -3
- package/lib/reanimated2/hook/useFrameCallback.js +23 -0
- package/lib/reanimated2/hook/utils.js +0 -5
- package/lib/reanimated2/jestUtils.js +11 -3
- package/lib/reanimated2/js-reanimated/JSReanimated.js +7 -0
- package/lib/reanimated2/js-reanimated/global.js +36 -0
- package/lib/reanimated2/js-reanimated/index.js +0 -24
- package/lib/reanimated2/layoutReanimation/LayoutAnimationRepository.js +1 -1
- package/lib/reanimated2/mock.js +6 -0
- package/lib/types/Animated.d.ts +8 -0
- package/lib/types/{lib/ConfigHelper.d.ts → ConfigHelper.d.ts} +0 -0
- package/lib/types/{lib/ReanimatedEventEmitter.d.ts → ReanimatedEventEmitter.d.ts} +0 -0
- package/lib/types/{lib/ReanimatedModule.d.ts → ReanimatedModule.d.ts} +0 -0
- package/lib/types/{lib/ReanimatedModule.macos.d.ts → ReanimatedModule.macos.d.ts} +0 -0
- package/lib/types/{lib/ReanimatedModule.native.d.ts → ReanimatedModule.native.d.ts} +0 -0
- package/lib/types/{lib/ReanimatedModule.windows.d.ts → ReanimatedModule.windows.d.ts} +0 -0
- package/lib/types/{lib/ReanimatedModuleCompat.d.ts → ReanimatedModuleCompat.d.ts} +0 -0
- package/lib/types/{lib/createAnimatedComponent.d.ts → createAnimatedComponent.d.ts} +0 -0
- package/lib/types/index.d.ts +4 -0
- package/lib/types/index.web.d.ts +3 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/Bezier.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/Colors.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/Easing.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/NativeMethods.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/NativeReanimated/NativeReanimated.d.ts +3 -1
- package/lib/types/{lib/reanimated2 → reanimated2}/NativeReanimated/index.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/PlatformChecker.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/PropAdapters.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/UpdateProps.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/ViewDescriptorsSet.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/WorkletEventHandler.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/__mocks__/MutableValue.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/__mocks__/NativeReanimated.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/__mocks__/NativeReanimated.native.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/animation/commonTypes.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/animation/decay.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/animation/delay.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/animation/index.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/animation/repeat.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/animation/sequence.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/animation/spring.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/animation/styleAnimation.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/animation/timing.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/animation/util.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/commonTypes.d.ts +12 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/component/FlatList.d.ts +2 -2
- package/lib/types/reanimated2/component/Image.d.ts +3 -0
- package/lib/types/reanimated2/component/ScrollView.d.ts +3 -0
- package/lib/types/reanimated2/component/Text.d.ts +3 -0
- package/lib/types/reanimated2/component/View.d.ts +3 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/core.d.ts +0 -0
- package/lib/types/reanimated2/frameCallback/FrameCallbackRegistryJS.d.ts +7 -0
- package/lib/types/reanimated2/frameCallback/FrameCallbackRegistryUI.d.ts +10 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/hook/Hooks.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/hook/commonTypes.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/hook/index.d.ts +3 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/hook/useAnimatedGestureHandler.d.ts +0 -0
- package/lib/types/reanimated2/hook/useAnimatedKeyboard.d.ts +2 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/hook/useAnimatedReaction.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/hook/useAnimatedRef.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/hook/useAnimatedScrollHandler.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/hook/useAnimatedSensor.d.ts +1 -1
- package/lib/types/{lib/reanimated2 → reanimated2}/hook/useAnimatedStyle.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/hook/useDerivedValue.d.ts +0 -0
- package/lib/types/reanimated2/hook/useFrameCallback.d.ts +6 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/hook/useSharedValue.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/hook/utils.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/index.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/interpolateColor.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/interpolation.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/jestUtils.d.ts +1 -1
- package/lib/types/{lib/reanimated2 → reanimated2}/js-reanimated/JSReanimated.d.ts +3 -1
- package/lib/types/{lib/reanimated2 → reanimated2}/js-reanimated/Mapper.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/js-reanimated/MapperRegistry.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/js-reanimated/MutableValue.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/js-reanimated/commonTypes.d.ts +0 -0
- package/lib/types/reanimated2/js-reanimated/global.d.ts +2 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/js-reanimated/index.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/LayoutAnimationRepository.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/animationBuilder/BaseAnimationBuilder.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/animationBuilder/ComplexAnimationBuilder.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/animationBuilder/Keyframe.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/animationBuilder/commonTypes.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/animationBuilder/index.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Bounce.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Default.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Fade.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Flip.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Lightspeed.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Pinwheel.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Roll.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Rotate.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Slide.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Stretch.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Zoom.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/index.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/CurvedTransition.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/EntryExitTransition.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/FadingTransition.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/JumpingTransition.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/LinearTransition.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/SequencedTransition.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/index.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/index.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/mock.d.ts +6 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/platform-specific/RNRenderer.d.ts +0 -0
- package/lib/types/reanimated2/platform-specific/RNRenderer.web.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/utils.d.ts +0 -0
- package/lib/types/{lib/setAndForwardRef.d.ts → setAndForwardRef.d.ts} +0 -0
- package/mock.js +1 -0
- package/package.json +15 -10
- package/plugin.js +7 -6
- package/react-native-reanimated.d.ts +56 -8
- package/src/Animated.ts +13 -0
- package/src/index.ts +15 -0
- package/src/index.web.ts +5 -0
- package/src/reanimated2/Colors.ts +1 -1
- package/src/reanimated2/NativeMethods.ts +5 -0
- package/src/reanimated2/NativeReanimated/NativeReanimated.ts +10 -1
- package/src/reanimated2/animation/sequence.ts +0 -5
- package/src/reanimated2/animation/util.ts +8 -1
- package/src/reanimated2/commonTypes.ts +15 -0
- package/src/reanimated2/component/FlatList.tsx +32 -25
- package/src/reanimated2/component/Image.ts +6 -0
- package/src/reanimated2/component/ScrollView.ts +6 -0
- package/src/reanimated2/component/Text.ts +6 -0
- package/src/reanimated2/component/View.ts +6 -0
- package/src/reanimated2/core.ts +8 -13
- package/src/reanimated2/frameCallback/FrameCallbackRegistryJS.ts +43 -0
- package/src/reanimated2/frameCallback/FrameCallbackRegistryUI.ts +64 -0
- package/src/reanimated2/globals.d.ts +3 -0
- package/src/reanimated2/hook/index.ts +3 -0
- package/src/reanimated2/hook/useAnimatedKeyboard.ts +35 -0
- package/src/reanimated2/hook/useAnimatedSensor.ts +5 -5
- package/src/reanimated2/hook/useFrameCallback.ts +39 -0
- package/src/reanimated2/hook/utils.ts +0 -6
- package/src/reanimated2/jestUtils.ts +11 -3
- package/src/reanimated2/js-reanimated/JSReanimated.ts +16 -1
- package/src/reanimated2/js-reanimated/global.ts +45 -0
- package/src/reanimated2/js-reanimated/index.ts +0 -31
- package/src/reanimated2/layoutReanimation/LayoutAnimationRepository.ts +1 -1
- package/src/reanimated2/mock.ts +6 -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/lib/reanimated2/component/WrappedComponents.js +0 -9
- package/lib/reanimated2/component/index.js +0 -4
- package/lib/types/lib/reanimated2/component/WrappedComponents.d.ts +0 -8
- package/lib/types/lib/reanimated2/component/index.d.ts +0 -9
- package/lib/types/react-native-reanimated-tests.d.ts +0 -1
- package/src/Animated.js +0 -22
- package/src/reanimated2/component/WrappedComponents.ts +0 -11
- package/src/reanimated2/component/index.ts +0 -9
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { runOnUI } from '../core';
|
|
2
|
+
|
|
3
|
+
export default interface FrameCallbackRegistryUI {
|
|
4
|
+
frameCallbackRegistry: Map<number, () => void>;
|
|
5
|
+
frameCallbackActive: Set<number>;
|
|
6
|
+
isFrameCallbackRunning: boolean;
|
|
7
|
+
runCallbacks: () => void;
|
|
8
|
+
registerFrameCallback: (callback: () => void, callbackId: number) => void;
|
|
9
|
+
unregisterFrameCallback: (frameCallbackId: number) => void;
|
|
10
|
+
manageStateFrameCallback: (frameCallbackId: number, state: boolean) => void;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const prepareUIRegistry = runOnUI(() => {
|
|
14
|
+
'worklet';
|
|
15
|
+
|
|
16
|
+
const frameCallbackRegistry: FrameCallbackRegistryUI = {
|
|
17
|
+
frameCallbackRegistry: new Map<number, () => void>(),
|
|
18
|
+
frameCallbackActive: new Set<number>(),
|
|
19
|
+
isFrameCallbackRunning: false,
|
|
20
|
+
|
|
21
|
+
runCallbacks() {
|
|
22
|
+
const loop = () => {
|
|
23
|
+
this.frameCallbackActive.forEach((key: number) => {
|
|
24
|
+
const callback = this.frameCallbackRegistry.get(key);
|
|
25
|
+
callback!();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
if (this.frameCallbackActive.size > 0) {
|
|
29
|
+
requestAnimationFrame(loop);
|
|
30
|
+
} else {
|
|
31
|
+
this.isFrameCallbackRunning = false;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
if (!this.isFrameCallbackRunning) {
|
|
36
|
+
requestAnimationFrame(loop);
|
|
37
|
+
this.isFrameCallbackRunning = true;
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
registerFrameCallback(callback: () => void, callbackId: number) {
|
|
42
|
+
this.frameCallbackRegistry.set(callbackId, callback);
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
unregisterFrameCallback(frameCallbackId: number) {
|
|
46
|
+
this.manageStateFrameCallback(frameCallbackId, false);
|
|
47
|
+
this.frameCallbackRegistry.delete(frameCallbackId);
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
manageStateFrameCallback(frameCallbackId: number, state: boolean) {
|
|
51
|
+
if (frameCallbackId === -1) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (state) {
|
|
55
|
+
this.frameCallbackActive.add(frameCallbackId);
|
|
56
|
+
this.runCallbacks();
|
|
57
|
+
} else {
|
|
58
|
+
this.frameCallbackActive.delete(frameCallbackId);
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
global._frameCallbackRegistry = frameCallbackRegistry;
|
|
64
|
+
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AnimatedStyle, StyleProps } from './commonTypes';
|
|
2
2
|
import { ReanimatedConsole } from './core';
|
|
3
|
+
import FrameCallbackRegistryUI from './frameCallback/FrameCallbackRegistryUI';
|
|
3
4
|
import { MeasuredDimensions } from './NativeMethods';
|
|
4
5
|
import { NativeReanimated } from './NativeReanimated/NativeReanimated';
|
|
5
6
|
declare global {
|
|
@@ -30,6 +31,7 @@ declare global {
|
|
|
30
31
|
const ReanimatedDataMock: {
|
|
31
32
|
now: () => number;
|
|
32
33
|
};
|
|
34
|
+
const _frameCallbackRegistry: FrameCallbackRegistryUI;
|
|
33
35
|
namespace NodeJS {
|
|
34
36
|
interface Global {
|
|
35
37
|
_setGlobalConsole: (console?: ReanimatedConsole) => void;
|
|
@@ -55,6 +57,7 @@ declare global {
|
|
|
55
57
|
ReanimatedDataMock: {
|
|
56
58
|
now: () => number;
|
|
57
59
|
};
|
|
60
|
+
_frameCallbackRegistry: FrameCallbackRegistryUI;
|
|
58
61
|
}
|
|
59
62
|
}
|
|
60
63
|
}
|
|
@@ -24,3 +24,6 @@ export {
|
|
|
24
24
|
} from './useAnimatedScrollHandler';
|
|
25
25
|
export { useDerivedValue, DerivedValue } from './useDerivedValue';
|
|
26
26
|
export { useAnimatedSensor, SensorType } from './useAnimatedSensor';
|
|
27
|
+
export { useFrameCallback } from './useFrameCallback';
|
|
28
|
+
export type { FrameCallback } from './useFrameCallback';
|
|
29
|
+
export { useAnimatedKeyboard } from './useAnimatedKeyboard';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
import NativeReanimated from '../NativeReanimated';
|
|
3
|
+
import { makeMutable } from '../core';
|
|
4
|
+
import { AnimatedKeyboardInfo, KeyboardState } from '../commonTypes';
|
|
5
|
+
|
|
6
|
+
export function useAnimatedKeyboard(): AnimatedKeyboardInfo {
|
|
7
|
+
const ref = useRef<AnimatedKeyboardInfo | null>(null);
|
|
8
|
+
const listenerId = useRef<number>(-1);
|
|
9
|
+
const isSubscribed = useRef<boolean>(false);
|
|
10
|
+
|
|
11
|
+
if (ref.current === null) {
|
|
12
|
+
const keyboardEventData: AnimatedKeyboardInfo = {
|
|
13
|
+
state: makeMutable(KeyboardState.UNKNOWN),
|
|
14
|
+
height: makeMutable(0),
|
|
15
|
+
};
|
|
16
|
+
listenerId.current =
|
|
17
|
+
NativeReanimated.subscribeForKeyboardEvents(keyboardEventData);
|
|
18
|
+
ref.current = keyboardEventData;
|
|
19
|
+
isSubscribed.current = true;
|
|
20
|
+
}
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (isSubscribed.current === false && ref.current !== null) {
|
|
23
|
+
// subscribe again after Fast Refresh
|
|
24
|
+
listenerId.current = NativeReanimated.subscribeForKeyboardEvents(
|
|
25
|
+
ref.current
|
|
26
|
+
);
|
|
27
|
+
isSubscribed.current = true;
|
|
28
|
+
}
|
|
29
|
+
return () => {
|
|
30
|
+
NativeReanimated.unsubscribeFromKeyboardEvents(listenerId.current);
|
|
31
|
+
isSubscribed.current = false;
|
|
32
|
+
};
|
|
33
|
+
}, []);
|
|
34
|
+
return ref.current;
|
|
35
|
+
}
|
|
@@ -12,7 +12,7 @@ export enum SensorType {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export type SensorConfig = {
|
|
15
|
-
interval: number;
|
|
15
|
+
interval: number | 'auto';
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
export type AnimatedSensor = {
|
|
@@ -26,7 +26,7 @@ export function useAnimatedSensor(
|
|
|
26
26
|
sensorType: SensorType,
|
|
27
27
|
userConfig?: SensorConfig
|
|
28
28
|
): AnimatedSensor {
|
|
29
|
-
const ref = useRef({
|
|
29
|
+
const ref = useRef<AnimatedSensor>({
|
|
30
30
|
sensor: null,
|
|
31
31
|
unregister: () => {
|
|
32
32
|
// NOOP
|
|
@@ -38,7 +38,7 @@ export function useAnimatedSensor(
|
|
|
38
38
|
});
|
|
39
39
|
|
|
40
40
|
if (ref.current.sensor === null) {
|
|
41
|
-
ref.current.config = { interval:
|
|
41
|
+
ref.current.config = { interval: 'auto', ...userConfig };
|
|
42
42
|
let sensorData;
|
|
43
43
|
if (sensorType === SensorType.ROTATION) {
|
|
44
44
|
sensorData = {
|
|
@@ -61,10 +61,10 @@ export function useAnimatedSensor(
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
useEffect(() => {
|
|
64
|
-
ref.current.config = { interval:
|
|
64
|
+
ref.current.config = { interval: 'auto', ...userConfig };
|
|
65
65
|
const id = NativeReanimated.registerSensor(
|
|
66
66
|
sensorType,
|
|
67
|
-
ref.current.config.interval,
|
|
67
|
+
ref.current.config.interval === 'auto' ? -1 : ref.current.config.interval,
|
|
68
68
|
ref.current.sensor as any
|
|
69
69
|
);
|
|
70
70
|
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
import FrameCallbackRegistryJS from '../frameCallback/FrameCallbackRegistryJS';
|
|
3
|
+
|
|
4
|
+
export type FrameCallback = {
|
|
5
|
+
setActive: (isActive: boolean) => void;
|
|
6
|
+
isActive: boolean;
|
|
7
|
+
callbackId: number;
|
|
8
|
+
};
|
|
9
|
+
const frameCallbackRegistry = new FrameCallbackRegistryJS();
|
|
10
|
+
|
|
11
|
+
export function useFrameCallback(
|
|
12
|
+
callback: () => void,
|
|
13
|
+
autostart = true
|
|
14
|
+
): FrameCallback {
|
|
15
|
+
const ref = useRef<FrameCallback>({
|
|
16
|
+
setActive: (isActive: boolean) => {
|
|
17
|
+
frameCallbackRegistry.manageStateFrameCallback(
|
|
18
|
+
ref.current.callbackId,
|
|
19
|
+
isActive
|
|
20
|
+
);
|
|
21
|
+
ref.current.isActive = isActive;
|
|
22
|
+
},
|
|
23
|
+
isActive: autostart,
|
|
24
|
+
callbackId: -1,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
ref.current.callbackId =
|
|
29
|
+
frameCallbackRegistry.registerFrameCallback(callback);
|
|
30
|
+
ref.current.setActive(ref.current.isActive);
|
|
31
|
+
|
|
32
|
+
return () => {
|
|
33
|
+
frameCallbackRegistry.unregisterFrameCallback(ref.current.callbackId);
|
|
34
|
+
ref.current.callbackId = -1;
|
|
35
|
+
};
|
|
36
|
+
}, [callback, autostart]);
|
|
37
|
+
|
|
38
|
+
return ref.current;
|
|
39
|
+
}
|
|
@@ -167,9 +167,9 @@ const tickTravel = () => {
|
|
|
167
167
|
jest.advanceTimersByTime(frameTime);
|
|
168
168
|
};
|
|
169
169
|
|
|
170
|
-
export const withReanimatedTimer = (
|
|
170
|
+
export const withReanimatedTimer = (animationTest) => {
|
|
171
171
|
beforeTest();
|
|
172
|
-
|
|
172
|
+
animationTest();
|
|
173
173
|
afterTest();
|
|
174
174
|
};
|
|
175
175
|
|
|
@@ -188,7 +188,15 @@ export const advanceAnimationByFrame = (count) => {
|
|
|
188
188
|
};
|
|
189
189
|
|
|
190
190
|
export const setUpTests = (userConfig = {}) => {
|
|
191
|
-
|
|
191
|
+
let expect;
|
|
192
|
+
try {
|
|
193
|
+
expect = require('expect');
|
|
194
|
+
} catch (_) {
|
|
195
|
+
// for Jest in version 28+
|
|
196
|
+
const { expect: expectModule } = require('@jest/globals');
|
|
197
|
+
expect = expectModule;
|
|
198
|
+
}
|
|
199
|
+
|
|
192
200
|
require('setimmediate');
|
|
193
201
|
frameTime = Math.round(1000 / config.fps);
|
|
194
202
|
|
|
@@ -2,7 +2,11 @@ import MapperRegistry from './MapperRegistry';
|
|
|
2
2
|
import Mapper from './Mapper';
|
|
3
3
|
import MutableValue from './MutableValue';
|
|
4
4
|
import { NativeReanimated } from '../NativeReanimated/NativeReanimated';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
Timestamp,
|
|
7
|
+
NestedObjectValues,
|
|
8
|
+
AnimatedKeyboardInfo,
|
|
9
|
+
} from '../commonTypes';
|
|
6
10
|
import { isJest } from '../PlatformChecker';
|
|
7
11
|
|
|
8
12
|
export default class JSReanimated extends NativeReanimated {
|
|
@@ -126,4 +130,15 @@ export default class JSReanimated extends NativeReanimated {
|
|
|
126
130
|
throw Error('This method can be only use in Jest testing.');
|
|
127
131
|
}
|
|
128
132
|
}
|
|
133
|
+
|
|
134
|
+
subscribeForKeyboardEvents(_: AnimatedKeyboardInfo): number {
|
|
135
|
+
console.warn(
|
|
136
|
+
'[Reanimated] useAnimatedKeyboard is not available on web yet.'
|
|
137
|
+
);
|
|
138
|
+
return -1;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
unsubscribeFromKeyboardEvents(_: number): void {
|
|
142
|
+
// noop
|
|
143
|
+
}
|
|
129
144
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// In order to keep bundle size down, we treat this file as a polyfill for Web.
|
|
2
|
+
|
|
3
|
+
import { shouldBeUseWeb } from '../PlatformChecker';
|
|
4
|
+
const initializeGlobalsForWeb = () => {
|
|
5
|
+
if (shouldBeUseWeb()) {
|
|
6
|
+
global._frameTimestamp = null;
|
|
7
|
+
global._setGlobalConsole = (_val) => {
|
|
8
|
+
// noop
|
|
9
|
+
};
|
|
10
|
+
global._measure = () => {
|
|
11
|
+
console.warn(
|
|
12
|
+
"[Reanimated] You can't use `measure` with Chrome Debugger or with web version"
|
|
13
|
+
);
|
|
14
|
+
return {
|
|
15
|
+
x: 0,
|
|
16
|
+
y: 0,
|
|
17
|
+
width: 0,
|
|
18
|
+
height: 0,
|
|
19
|
+
pageX: 0,
|
|
20
|
+
pageY: 0,
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
global._scrollTo = () => {
|
|
24
|
+
console.warn(
|
|
25
|
+
"[Reanimated] You can't use `scrollTo` with Chrome Debugger or with web version"
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
global._setGestureState = () => {
|
|
29
|
+
console.warn(
|
|
30
|
+
"[Reanimated] You can't use `setGestureState` with Chrome Debugger or with web version"
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
return true;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/*
|
|
38
|
+
If a file doesn't export anything, tree shaking doesn't pack
|
|
39
|
+
it into the JS bundle. In effect, the code inside of this file
|
|
40
|
+
will never execute. That is why we wrapped initialization code
|
|
41
|
+
into a function, and we call this one during creating
|
|
42
|
+
the module export object.
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
export default initializeGlobalsForWeb();
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import JSReanimated from './JSReanimated';
|
|
2
|
-
import { shouldBeUseWeb } from '../PlatformChecker';
|
|
3
2
|
import { AnimatedStyle, StyleProps } from '../commonTypes';
|
|
4
3
|
|
|
5
4
|
const reanimatedJS = new JSReanimated();
|
|
@@ -13,36 +12,6 @@ interface JSReanimatedComponent {
|
|
|
13
12
|
};
|
|
14
13
|
}
|
|
15
14
|
|
|
16
|
-
if (shouldBeUseWeb()) {
|
|
17
|
-
global._frameTimestamp = null;
|
|
18
|
-
global._setGlobalConsole = (_val) => {
|
|
19
|
-
// noop
|
|
20
|
-
};
|
|
21
|
-
global._measure = () => {
|
|
22
|
-
console.warn(
|
|
23
|
-
"[Reanimated] You can't use `measure` with Chrome Debugger or with web version"
|
|
24
|
-
);
|
|
25
|
-
return {
|
|
26
|
-
x: 0,
|
|
27
|
-
y: 0,
|
|
28
|
-
width: 0,
|
|
29
|
-
height: 0,
|
|
30
|
-
pageX: 0,
|
|
31
|
-
pageY: 0,
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
global._scrollTo = () => {
|
|
35
|
-
console.warn(
|
|
36
|
-
"[Reanimated] You can't use `scrollTo` with Chrome Debugger or with web version"
|
|
37
|
-
);
|
|
38
|
-
};
|
|
39
|
-
global._setGestureState = () => {
|
|
40
|
-
console.warn(
|
|
41
|
-
"[Reanimated] You can't use `setGestureState` with Chrome Debugger or with web version"
|
|
42
|
-
);
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
15
|
export const _updatePropsJS = (
|
|
47
16
|
updates: StyleProps | AnimatedStyle,
|
|
48
17
|
viewRef: { _component?: JSReanimatedComponent }
|
|
@@ -7,7 +7,7 @@ import { processColor } from '../Colors';
|
|
|
7
7
|
runOnUI(() => {
|
|
8
8
|
'worklet';
|
|
9
9
|
|
|
10
|
-
const configs: Record<string, any> =
|
|
10
|
+
const configs: Record<string, any> = Object.create(null);
|
|
11
11
|
const enteringAnimationForTag: Record<string, any> = {};
|
|
12
12
|
|
|
13
13
|
global.LayoutAnimationRepository = {
|
package/src/reanimated2/mock.ts
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Image, ScrollView, Text, View } from 'react-native';
|
|
2
|
-
import createAnimatedComponent from '../../createAnimatedComponent';
|
|
3
|
-
const WrappedComponents = {
|
|
4
|
-
View: createAnimatedComponent(View),
|
|
5
|
-
Text: createAnimatedComponent(Text),
|
|
6
|
-
Image: createAnimatedComponent(Image),
|
|
7
|
-
ScrollView: createAnimatedComponent(ScrollView),
|
|
8
|
-
};
|
|
9
|
-
export default WrappedComponents;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
declare const WrappedComponents: {
|
|
3
|
-
View: import("react").ComponentType<import("../../createAnimatedComponent").AnimatedComponentProps<import("../../createAnimatedComponent").InitialComponentProps>>;
|
|
4
|
-
Text: import("react").ComponentType<import("../../createAnimatedComponent").AnimatedComponentProps<import("../../createAnimatedComponent").InitialComponentProps>>;
|
|
5
|
-
Image: import("react").ComponentType<import("../../createAnimatedComponent").AnimatedComponentProps<import("../../createAnimatedComponent").InitialComponentProps>>;
|
|
6
|
-
ScrollView: import("react").ComponentType<import("../../createAnimatedComponent").AnimatedComponentProps<import("../../createAnimatedComponent").InitialComponentProps>>;
|
|
7
|
-
};
|
|
8
|
-
export default WrappedComponents;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
declare const ReanimatedComponents: {
|
|
3
|
-
FlatList: import("react").FC<import("./FlatList").ReanimatedFlatlistProps<any>>;
|
|
4
|
-
View: import("react").ComponentType<import("../../createAnimatedComponent").AnimatedComponentProps<import("../../createAnimatedComponent").InitialComponentProps>>;
|
|
5
|
-
Text: import("react").ComponentType<import("../../createAnimatedComponent").AnimatedComponentProps<import("../../createAnimatedComponent").InitialComponentProps>>;
|
|
6
|
-
Image: import("react").ComponentType<import("../../createAnimatedComponent").AnimatedComponentProps<import("../../createAnimatedComponent").InitialComponentProps>>;
|
|
7
|
-
ScrollView: import("react").ComponentType<import("../../createAnimatedComponent").AnimatedComponentProps<import("../../createAnimatedComponent").InitialComponentProps>>;
|
|
8
|
-
};
|
|
9
|
-
export default ReanimatedComponents;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/src/Animated.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import createAnimatedComponent from './createAnimatedComponent';
|
|
2
|
-
import {
|
|
3
|
-
addWhitelistedNativeProps,
|
|
4
|
-
addWhitelistedUIProps,
|
|
5
|
-
} from './ConfigHelper';
|
|
6
|
-
import * as reanimated1 from './reanimated1';
|
|
7
|
-
import ReanimatedComponents from './reanimated2/component';
|
|
8
|
-
|
|
9
|
-
const Animated = {
|
|
10
|
-
// components
|
|
11
|
-
...ReanimatedComponents,
|
|
12
|
-
createAnimatedComponent,
|
|
13
|
-
// configuration
|
|
14
|
-
addWhitelistedNativeProps,
|
|
15
|
-
addWhitelistedUIProps,
|
|
16
|
-
// reanimated 1
|
|
17
|
-
...reanimated1,
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export * from './reanimated2';
|
|
21
|
-
export * from './reanimated1';
|
|
22
|
-
export default Animated;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Image, ScrollView, Text, View } from 'react-native';
|
|
2
|
-
import createAnimatedComponent from '../../createAnimatedComponent';
|
|
3
|
-
|
|
4
|
-
const WrappedComponents = {
|
|
5
|
-
View: createAnimatedComponent(View),
|
|
6
|
-
Text: createAnimatedComponent(Text as any),
|
|
7
|
-
Image: createAnimatedComponent(Image as any),
|
|
8
|
-
ScrollView: createAnimatedComponent(ScrollView),
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export default WrappedComponents;
|