forked from software-mansion/react-native-reanimated
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNativeReanimated.ts
70 lines (56 loc) · 1.84 KB
/
NativeReanimated.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-nocheck
import { Platform } from 'react-native';
import reanimatedJS from './js-reanimated';
import { nativeShouldBeMock } from './PlatformChecker';
let exportedModule;
if (nativeShouldBeMock()) {
exportedModule = reanimatedJS;
} else {
const InnerNativeModule = global.__reanimatedModuleProxy;
const NativeReanimated = {
native: true,
useOnlyV1: InnerNativeModule == null,
installCoreFunctions(valueSetter) {
return InnerNativeModule.installCoreFunctions(valueSetter);
},
makeShareable(value) {
return InnerNativeModule.makeShareable(value);
},
makeMutable(value) {
return InnerNativeModule.makeMutable(value);
},
makeRemote(object) {
return InnerNativeModule.makeRemote(object);
},
startMapper(mapper, inputs = [], outputs = [], updater, tag, name) {
return InnerNativeModule.startMapper(
mapper,
inputs,
outputs,
updater,
tag,
name
);
},
stopMapper(mapperId) {
return InnerNativeModule.stopMapper(mapperId);
},
registerEventHandler(eventHash, eventHandler) {
return InnerNativeModule.registerEventHandler(eventHash, eventHandler);
},
unregisterEventHandler(registrationId) {
return InnerNativeModule.unregisterEventHandler(registrationId);
},
getViewProp(viewTag, propName, callback) {
return InnerNativeModule.getViewProp(viewTag, propName, callback);
},
};
if (NativeReanimated.useOnlyV1 && Platform.OS === 'android') {
console.warn(
`If you want to use Reanimated 2 then go through our installation steps https://docs.swmansion.com/react-native-reanimated/docs/installation`
);
}
exportedModule = NativeReanimated;
}
export default exportedModule as any; // TODO: just temporary type