react-native-reanimated 3.0.0-rc.7 → 3.0.0-rc.8
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 +32 -37
- package/Common/cpp/AnimatedSensor/AnimatedSensorModule.h +4 -3
- package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.cpp +76 -0
- package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.h +41 -0
- package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +161 -165
- package/Common/cpp/NativeModules/NativeReanimatedModule.h +36 -34
- package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +22 -34
- package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.h +13 -14
- package/Common/cpp/SharedItems/RuntimeManager.h +1 -34
- package/Common/cpp/SharedItems/Shareables.cpp +142 -0
- package/Common/cpp/SharedItems/Shareables.h +455 -0
- package/Common/cpp/Tools/PlatformDepMethodsHolder.h +6 -0
- package/Common/cpp/Tools/RuntimeDecorator.cpp +54 -26
- package/Common/cpp/Tools/RuntimeDecorator.h +11 -2
- package/Common/cpp/Tools/Scheduler.cpp +10 -0
- package/Common/cpp/Tools/SingleInstanceChecker.h +1 -1
- package/android/src/main/cpp/LayoutAnimations.cpp +6 -16
- package/android/src/main/cpp/LayoutAnimations.h +4 -4
- package/android/src/main/cpp/NativeProxy.cpp +50 -63
- package/ios/native/NativeProxy.mm +26 -42
- package/lib/commonjs/createAnimatedComponent.js +7 -11
- package/lib/commonjs/createAnimatedComponent.js.map +1 -1
- package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js +24 -25
- package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
- package/lib/commonjs/reanimated2/ViewDescriptorsSet.js +27 -55
- package/lib/commonjs/reanimated2/ViewDescriptorsSet.js.map +1 -1
- package/lib/commonjs/reanimated2/WorkletEventHandler.js +5 -3
- package/lib/commonjs/reanimated2/WorkletEventHandler.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/util.js.map +1 -1
- package/lib/commonjs/reanimated2/commonTypes.js +7 -0
- package/lib/commonjs/reanimated2/commonTypes.js.map +1 -1
- package/lib/commonjs/reanimated2/core.js +111 -209
- package/lib/commonjs/reanimated2/core.js.map +1 -1
- package/lib/commonjs/reanimated2/globals.d.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js +15 -9
- package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedRef.js +18 -8
- package/lib/commonjs/reanimated2/hook/useAnimatedRef.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js +27 -36
- package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js +24 -50
- package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useSharedValue.js +3 -2
- package/lib/commonjs/reanimated2/hook/useSharedValue.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/utils.js.map +1 -1
- package/lib/commonjs/reanimated2/interpolateColor.js.map +1 -1
- package/lib/commonjs/reanimated2/jestUtils.js +8 -33
- package/lib/commonjs/reanimated2/jestUtils.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js +16 -100
- package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/index.js +5 -0
- package/lib/commonjs/reanimated2/js-reanimated/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js +91 -0
- package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js.map +1 -0
- package/lib/commonjs/reanimated2/layoutReanimation/index.js +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/index.js.map +1 -1
- package/lib/commonjs/reanimated2/mappers.js +186 -0
- package/lib/commonjs/reanimated2/mappers.js.map +1 -0
- package/lib/commonjs/reanimated2/mutables.js +173 -0
- package/lib/commonjs/reanimated2/mutables.js.map +1 -0
- package/lib/commonjs/reanimated2/shareables.js +153 -0
- package/lib/commonjs/reanimated2/shareables.js.map +1 -0
- package/lib/commonjs/reanimated2/threads.js +58 -0
- package/lib/commonjs/reanimated2/threads.js.map +1 -0
- package/lib/commonjs/reanimated2/time.js +55 -0
- package/lib/commonjs/reanimated2/time.js.map +1 -0
- package/lib/commonjs/reanimated2/valueSetter.js +81 -0
- package/lib/commonjs/reanimated2/valueSetter.js.map +1 -0
- package/lib/module/createAnimatedComponent.js +7 -12
- package/lib/module/createAnimatedComponent.js.map +1 -1
- package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js +24 -25
- package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
- package/lib/module/reanimated2/ViewDescriptorsSet.js +27 -53
- package/lib/module/reanimated2/ViewDescriptorsSet.js.map +1 -1
- package/lib/module/reanimated2/WorkletEventHandler.js +4 -3
- package/lib/module/reanimated2/WorkletEventHandler.js.map +1 -1
- package/lib/module/reanimated2/animation/util.js.map +1 -1
- package/lib/module/reanimated2/commonTypes.js +7 -0
- package/lib/module/reanimated2/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/core.js +66 -188
- package/lib/module/reanimated2/core.js.map +1 -1
- package/lib/module/reanimated2/globals.d.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedKeyboard.js +16 -6
- package/lib/module/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedRef.js +17 -8
- package/lib/module/reanimated2/hook/useAnimatedRef.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedSensor.js +29 -34
- package/lib/module/reanimated2/hook/useAnimatedSensor.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedStyle.js +26 -52
- package/lib/module/reanimated2/hook/useAnimatedStyle.js.map +1 -1
- package/lib/module/reanimated2/hook/useSharedValue.js +3 -2
- package/lib/module/reanimated2/hook/useSharedValue.js.map +1 -1
- package/lib/module/reanimated2/hook/utils.js.map +1 -1
- package/lib/module/reanimated2/interpolateColor.js.map +1 -1
- package/lib/module/reanimated2/jestUtils.js +8 -31
- package/lib/module/reanimated2/jestUtils.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/JSReanimated.js +16 -95
- package/lib/module/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/index.js +5 -0
- package/lib/module/reanimated2/js-reanimated/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationsManager.js +84 -0
- package/lib/module/reanimated2/layoutReanimation/animationsManager.js.map +1 -0
- package/lib/module/reanimated2/layoutReanimation/index.js +1 -1
- package/lib/module/reanimated2/layoutReanimation/index.js.map +1 -1
- package/lib/module/reanimated2/mappers.js +173 -0
- package/lib/module/reanimated2/mappers.js.map +1 -0
- package/lib/module/reanimated2/mutables.js +149 -0
- package/lib/module/reanimated2/mutables.js.map +1 -0
- package/lib/module/reanimated2/shareables.js +133 -0
- package/lib/module/reanimated2/shareables.js.map +1 -0
- package/lib/module/reanimated2/threads.js +45 -0
- package/lib/module/reanimated2/threads.js.map +1 -0
- package/lib/module/reanimated2/time.js +37 -0
- package/lib/module/reanimated2/time.js.map +1 -0
- package/lib/module/reanimated2/valueSetter.js +66 -0
- package/lib/module/reanimated2/valueSetter.js.map +1 -0
- package/package.json +1 -1
- package/plugin.js +31 -15
- package/src/createAnimatedComponent.tsx +8 -24
- package/src/reanimated2/NativeReanimated/NativeReanimated.ts +34 -53
- package/src/reanimated2/ViewDescriptorsSet.ts +30 -69
- package/src/reanimated2/WorkletEventHandler.ts +4 -11
- package/src/reanimated2/animation/util.ts +1 -0
- package/src/reanimated2/commonTypes.ts +29 -4
- package/src/reanimated2/core.ts +103 -230
- package/src/reanimated2/globals.d.ts +26 -26
- package/src/reanimated2/hook/useAnimatedKeyboard.ts +18 -9
- package/src/reanimated2/hook/useAnimatedRef.ts +27 -9
- package/src/reanimated2/hook/useAnimatedSensor.ts +33 -31
- package/src/reanimated2/hook/useAnimatedStyle.ts +26 -64
- package/src/reanimated2/hook/useSharedValue.ts +6 -3
- package/src/reanimated2/hook/utils.ts +1 -1
- package/src/reanimated2/interpolateColor.ts +2 -2
- package/src/reanimated2/jestUtils.ts +14 -29
- package/src/reanimated2/js-reanimated/JSReanimated.ts +19 -93
- package/src/reanimated2/js-reanimated/index.ts +4 -0
- package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +7 -0
- package/src/reanimated2/layoutReanimation/animationBuilder/index.ts +1 -0
- package/src/reanimated2/layoutReanimation/animationsManager.ts +94 -0
- package/src/reanimated2/layoutReanimation/index.ts +1 -1
- package/src/reanimated2/mappers.ts +179 -0
- package/src/reanimated2/mutables.ts +151 -0
- package/src/reanimated2/shareables.ts +121 -0
- package/src/reanimated2/threads.ts +46 -0
- package/src/reanimated2/time.ts +30 -0
- package/src/reanimated2/valueSetter.ts +64 -0
- package/Common/cpp/LayoutAnimations/LayoutAnimationsProxy.cpp +0 -127
- package/Common/cpp/LayoutAnimations/LayoutAnimationsProxy.h +0 -56
- package/Common/cpp/Registries/MapperRegistry.cpp +0 -147
- package/Common/cpp/Registries/MapperRegistry.h +0 -29
- package/Common/cpp/Registries/WorkletsCache.cpp +0 -45
- package/Common/cpp/Registries/WorkletsCache.h +0 -24
- package/Common/cpp/SharedItems/FrozenObject.cpp +0 -35
- package/Common/cpp/SharedItems/FrozenObject.h +0 -36
- package/Common/cpp/SharedItems/HostFunctionHandler.h +0 -28
- package/Common/cpp/SharedItems/MutableValue.cpp +0 -134
- package/Common/cpp/SharedItems/MutableValue.h +0 -54
- package/Common/cpp/SharedItems/MutableValueSetterProxy.cpp +0 -47
- package/Common/cpp/SharedItems/MutableValueSetterProxy.h +0 -25
- package/Common/cpp/SharedItems/RemoteObject.cpp +0 -45
- package/Common/cpp/SharedItems/RemoteObject.h +0 -35
- package/Common/cpp/SharedItems/ShareableValue.cpp +0 -529
- package/Common/cpp/SharedItems/ShareableValue.h +0 -63
- package/Common/cpp/SharedItems/ValueWrapper.h +0 -183
- package/Common/cpp/Tools/JSIStoreValueUser.cpp +0 -55
- package/Common/cpp/Tools/JSIStoreValueUser.h +0 -37
- package/Common/cpp/Tools/Mapper.cpp +0 -86
- package/Common/cpp/Tools/Mapper.h +0 -51
- package/lib/commonjs/reanimated2/layoutReanimation/LayoutAnimationRepository.js +0 -58
- package/lib/commonjs/reanimated2/layoutReanimation/LayoutAnimationRepository.js.map +0 -1
- package/lib/module/reanimated2/layoutReanimation/LayoutAnimationRepository.js +0 -52
- package/lib/module/reanimated2/layoutReanimation/LayoutAnimationRepository.js.map +0 -1
- package/src/reanimated2/layoutReanimation/LayoutAnimationRepository.ts +0 -49
|
@@ -7,28 +7,57 @@ exports.checkPluginState = void 0;
|
|
|
7
7
|
exports.configureLayoutAnimations = configureLayoutAnimations;
|
|
8
8
|
exports.configureProps = configureProps;
|
|
9
9
|
exports.enableLayoutAnimations = enableLayoutAnimations;
|
|
10
|
-
exports
|
|
10
|
+
Object.defineProperty(exports, "getTimestamp", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _time.getTimestamp;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
11
16
|
exports.getViewProp = getViewProp;
|
|
12
|
-
exports.isConfiguredCheck = exports.isConfigured = void 0;
|
|
13
|
-
exports.
|
|
14
|
-
exports.
|
|
15
|
-
exports
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
exports
|
|
17
|
+
exports.makeShareable = exports.makeRemote = exports.makeMutable = exports.isConfiguredCheck = exports.isConfigured = void 0;
|
|
18
|
+
exports.registerEventHandler = registerEventHandler;
|
|
19
|
+
exports.registerSensor = registerSensor;
|
|
20
|
+
Object.defineProperty(exports, "runOnJS", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function () {
|
|
23
|
+
return _threads.runOnJS;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
Object.defineProperty(exports, "runOnUI", {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
get: function () {
|
|
29
|
+
return _threads.runOnUI;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
exports.startMapper = void 0;
|
|
33
|
+
Object.defineProperty(exports, "stopMapper", {
|
|
34
|
+
enumerable: true,
|
|
35
|
+
get: function () {
|
|
36
|
+
return _mappers.stopMapper;
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
exports.subscribeForKeyboardEvents = subscribeForKeyboardEvents;
|
|
40
|
+
exports.unregisterEventHandler = unregisterEventHandler;
|
|
41
|
+
exports.unregisterSensor = unregisterSensor;
|
|
42
|
+
exports.unsubscribeFromKeyboardEvents = unsubscribeFromKeyboardEvents;
|
|
22
43
|
|
|
23
44
|
var _NativeReanimated = _interopRequireDefault(require("./NativeReanimated"));
|
|
24
45
|
|
|
25
|
-
var _reactNative = require("react-native");
|
|
26
|
-
|
|
27
46
|
var _PlatformChecker = require("./PlatformChecker");
|
|
28
47
|
|
|
48
|
+
var _shareables = require("./shareables");
|
|
49
|
+
|
|
50
|
+
var _threads = require("./threads");
|
|
51
|
+
|
|
52
|
+
var _mappers = require("./mappers");
|
|
53
|
+
|
|
54
|
+
var _mutables = require("./mutables");
|
|
55
|
+
|
|
56
|
+
var _time = require("./time");
|
|
57
|
+
|
|
29
58
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
30
59
|
|
|
31
|
-
/* global
|
|
60
|
+
/* global _setGlobalConsole */
|
|
32
61
|
if (global._setGlobalConsole === undefined) {
|
|
33
62
|
// it can happen when Reanimated plugin wasn't added, but the user uses the only API from version 1
|
|
34
63
|
global._setGlobalConsole = () => {// noop
|
|
@@ -71,36 +100,26 @@ const isConfiguredCheck = () => {
|
|
|
71
100
|
};
|
|
72
101
|
|
|
73
102
|
exports.isConfiguredCheck = isConfiguredCheck;
|
|
74
|
-
|
|
75
|
-
function
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
103
|
+
const configurationCheckWrapper = __DEV__ ? fn => {
|
|
104
|
+
return function () {
|
|
105
|
+
isConfigured(true);
|
|
106
|
+
return fn(...arguments);
|
|
107
|
+
};
|
|
108
|
+
} : fn => fn;
|
|
109
|
+
const startMapper = __DEV__ ? configurationCheckWrapper(_mappers.startMapper) : _mappers.startMapper;
|
|
110
|
+
exports.startMapper = startMapper;
|
|
111
|
+
const makeShareable = __DEV__ ? configurationCheckWrapper(_shareables.makeShareable) : _shareables.makeShareable;
|
|
112
|
+
exports.makeShareable = makeShareable;
|
|
113
|
+
const makeMutable = __DEV__ ? configurationCheckWrapper(_mutables.makeMutable) : _mutables.makeMutable;
|
|
114
|
+
exports.makeMutable = makeMutable;
|
|
115
|
+
const makeRemote = __DEV__ ? configurationCheckWrapper(_mutables.makeRemote) : _mutables.makeRemote;
|
|
116
|
+
exports.makeRemote = makeRemote;
|
|
89
117
|
global._WORKLET = false;
|
|
90
118
|
|
|
91
119
|
global._log = function (s) {
|
|
92
120
|
console.log(s);
|
|
93
121
|
};
|
|
94
122
|
|
|
95
|
-
function runOnUI(worklet) {
|
|
96
|
-
return makeShareable(worklet);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function makeShareable(value) {
|
|
100
|
-
isConfiguredCheck();
|
|
101
|
-
return _NativeReanimated.default.makeShareable(value);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
123
|
function getViewProp(viewTag, propName) {
|
|
105
124
|
if (global._IS_FABRIC) {
|
|
106
125
|
throw new Error('[react-native-reanimated] `getViewProp` is not supported on Fabric yet');
|
|
@@ -117,205 +136,92 @@ function getViewProp(viewTag, propName) {
|
|
|
117
136
|
});
|
|
118
137
|
}
|
|
119
138
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
if ((0, _PlatformChecker.nativeShouldBeMock)()) {
|
|
123
|
-
_getTimestamp = () => {
|
|
124
|
-
return _NativeReanimated.default.getTimestamp();
|
|
125
|
-
};
|
|
126
|
-
} else {
|
|
127
|
-
_getTimestamp = () => {
|
|
128
|
-
'worklet';
|
|
129
|
-
|
|
130
|
-
if (_frameTimestamp) {
|
|
131
|
-
return _frameTimestamp;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
if (_eventTimestamp) {
|
|
135
|
-
return _eventTimestamp;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
return _getCurrentTime();
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
function getTimestamp() {
|
|
143
|
-
'worklet';
|
|
144
|
-
|
|
145
|
-
if (_reactNative.Platform.OS === 'web') {
|
|
146
|
-
return _NativeReanimated.default.getTimestamp();
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
return _getTimestamp();
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
function workletValueSetter(value) {
|
|
139
|
+
function valueUnpacker(objectToUnpack, category) {
|
|
153
140
|
'worklet';
|
|
154
141
|
|
|
155
|
-
|
|
142
|
+
let workletsCache = global.__workletsCache;
|
|
143
|
+
let handleCache = global.__handleCache;
|
|
156
144
|
|
|
157
|
-
if (
|
|
158
|
-
|
|
159
|
-
|
|
145
|
+
if (workletsCache === undefined) {
|
|
146
|
+
// init
|
|
147
|
+
workletsCache = global.__workletsCache = new Map();
|
|
148
|
+
handleCache = global.__handleCache = new WeakMap();
|
|
160
149
|
}
|
|
161
150
|
|
|
162
|
-
if (
|
|
163
|
-
|
|
164
|
-
// and triggering the mappers that treat this value as an input
|
|
165
|
-
// 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)
|
|
166
|
-
// built in animations that are not higher order(withTiming, withSpring) hold target value in .current
|
|
167
|
-
|
|
168
|
-
if (this._value === animation.current && !animation.isHigherOrder) {
|
|
169
|
-
animation.callback && animation.callback(true);
|
|
170
|
-
return;
|
|
171
|
-
} // animated set
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
const initializeAnimation = timestamp => {
|
|
175
|
-
animation.onStart(animation, this.value, timestamp, previousAnimation);
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
const currentTimestamp = getTimestamp();
|
|
179
|
-
initializeAnimation(currentTimestamp);
|
|
151
|
+
if (objectToUnpack.__workletHash) {
|
|
152
|
+
let workletFun = workletsCache.get(objectToUnpack.__workletHash);
|
|
180
153
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
);
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
const finished = animation.onFrame(animation, timestamp);
|
|
190
|
-
animation.finished = true;
|
|
191
|
-
animation.timestamp = timestamp;
|
|
192
|
-
this._value = animation.current;
|
|
193
|
-
|
|
194
|
-
if (finished) {
|
|
195
|
-
animation.callback && animation.callback(true
|
|
196
|
-
/* finished */
|
|
197
|
-
);
|
|
198
|
-
} else {
|
|
199
|
-
requestAnimationFrame(step);
|
|
200
|
-
}
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
this._animation = animation;
|
|
204
|
-
step(currentTimestamp);
|
|
205
|
-
} else {
|
|
206
|
-
// prevent setting again to the same value
|
|
207
|
-
// and triggering the mappers that treat this value as an input
|
|
208
|
-
if (this._value === value) {
|
|
209
|
-
return;
|
|
154
|
+
if (workletFun === undefined) {
|
|
155
|
+
// eslint-disable-next-line no-eval
|
|
156
|
+
workletFun = eval('(' + objectToUnpack.asString + '\n)');
|
|
157
|
+
workletsCache.set(objectToUnpack.__workletHash, workletFun);
|
|
210
158
|
}
|
|
211
159
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
function workletValueSetterJS(value) {
|
|
219
|
-
const previousAnimation = this._animation;
|
|
160
|
+
const functionInstance = workletFun.bind(objectToUnpack);
|
|
161
|
+
objectToUnpack._recur = functionInstance;
|
|
162
|
+
return functionInstance;
|
|
163
|
+
} else if (objectToUnpack.__init) {
|
|
164
|
+
let value = handleCache.get(objectToUnpack);
|
|
220
165
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
if (typeof value === 'function' || value !== null && typeof value === 'object' && value.onFrame) {
|
|
227
|
-
// animated set
|
|
228
|
-
const animation = typeof value === 'function' ? value() : value;
|
|
229
|
-
|
|
230
|
-
let initializeAnimation = timestamp => {
|
|
231
|
-
animation.onStart(animation, this.value, timestamp, previousAnimation);
|
|
232
|
-
};
|
|
233
|
-
|
|
234
|
-
const step = timestamp => {
|
|
235
|
-
if (animation.cancelled) {
|
|
236
|
-
animation.callback && animation.callback(false
|
|
237
|
-
/* finished */
|
|
238
|
-
);
|
|
239
|
-
return;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
if (initializeAnimation) {
|
|
243
|
-
initializeAnimation(timestamp);
|
|
244
|
-
initializeAnimation = null; // prevent closure from keeping ref to previous animation
|
|
245
|
-
}
|
|
166
|
+
if (value === undefined) {
|
|
167
|
+
value = objectToUnpack.__init();
|
|
168
|
+
handleCache.set(objectToUnpack, value);
|
|
169
|
+
}
|
|
246
170
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
171
|
+
return value;
|
|
172
|
+
} else if (category === 'RemoteFunction') {
|
|
173
|
+
const fun = () => {
|
|
174
|
+
throw new Error(`Tried to synchronously call a non-worklet function on the UI thread.
|
|
250
175
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
);
|
|
255
|
-
} else {
|
|
256
|
-
requestFrame(step);
|
|
257
|
-
}
|
|
176
|
+
Possible solutions are:
|
|
177
|
+
a) If you want to synchronously execute this method, mark it as a worklet
|
|
178
|
+
b) If you want to execute this function on the JS thread, wrap it using \`runOnJS\``);
|
|
258
179
|
};
|
|
259
180
|
|
|
260
|
-
|
|
261
|
-
|
|
181
|
+
fun.__remoteFunction = objectToUnpack;
|
|
182
|
+
return fun;
|
|
262
183
|
} else {
|
|
263
|
-
|
|
184
|
+
throw new Error('data type not recognized by unpack method');
|
|
264
185
|
}
|
|
265
186
|
}
|
|
266
187
|
|
|
267
|
-
function
|
|
268
|
-
|
|
269
|
-
return _NativeReanimated.default.makeMutable(value);
|
|
188
|
+
function registerEventHandler(eventHash, eventHandler) {
|
|
189
|
+
return _NativeReanimated.default.registerEventHandler(eventHash, (0, _shareables.makeShareableCloneRecursive)(eventHandler));
|
|
270
190
|
}
|
|
271
191
|
|
|
272
|
-
function
|
|
273
|
-
|
|
274
|
-
isConfiguredCheck();
|
|
275
|
-
return _NativeReanimated.default.makeRemote(object);
|
|
192
|
+
function unregisterEventHandler(id) {
|
|
193
|
+
return _NativeReanimated.default.unregisterEventHandler(id);
|
|
276
194
|
}
|
|
277
195
|
|
|
278
|
-
function
|
|
279
|
-
|
|
280
|
-
let outputs = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
281
|
-
let updater = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : () => {// noop
|
|
282
|
-
};
|
|
283
|
-
let viewDescriptors = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
|
|
284
|
-
isConfiguredCheck();
|
|
285
|
-
return _NativeReanimated.default.startMapper(mapper, inputs, outputs, updater, viewDescriptors);
|
|
196
|
+
function subscribeForKeyboardEvents(eventHandler) {
|
|
197
|
+
return _NativeReanimated.default.subscribeForKeyboardEvents((0, _shareables.makeShareableCloneRecursive)(eventHandler));
|
|
286
198
|
}
|
|
287
199
|
|
|
288
|
-
function
|
|
289
|
-
_NativeReanimated.default.
|
|
200
|
+
function unsubscribeFromKeyboardEvents(listenerId) {
|
|
201
|
+
return _NativeReanimated.default.unsubscribeFromKeyboardEvents(listenerId);
|
|
290
202
|
}
|
|
291
203
|
|
|
292
|
-
function
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
if (!_WORKLET) {
|
|
296
|
-
return fun;
|
|
297
|
-
}
|
|
204
|
+
function registerSensor(sensorType, interval, eventHandler) {
|
|
205
|
+
return _NativeReanimated.default.registerSensor(sensorType, interval, (0, _shareables.makeShareableCloneRecursive)(eventHandler));
|
|
206
|
+
}
|
|
298
207
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
} else {
|
|
302
|
-
return fun.__callAsync;
|
|
303
|
-
}
|
|
208
|
+
function unregisterSensor(listenerId) {
|
|
209
|
+
return _NativeReanimated.default.unregisterSensor(listenerId);
|
|
304
210
|
}
|
|
305
211
|
|
|
306
|
-
_NativeReanimated.default.installCoreFunctions(
|
|
212
|
+
_NativeReanimated.default.installCoreFunctions(valueUnpacker);
|
|
307
213
|
|
|
308
214
|
if (!(0, _PlatformChecker.isWeb)() && isConfigured()) {
|
|
309
215
|
const capturableConsole = console;
|
|
310
|
-
runOnUI(() => {
|
|
216
|
+
(0, _threads.runOnUI)(() => {
|
|
311
217
|
'worklet';
|
|
312
218
|
|
|
313
219
|
const console = {
|
|
314
|
-
debug: runOnJS(capturableConsole.debug),
|
|
315
|
-
log: runOnJS(capturableConsole.log),
|
|
316
|
-
warn: runOnJS(capturableConsole.warn),
|
|
317
|
-
error: runOnJS(capturableConsole.error),
|
|
318
|
-
info: runOnJS(capturableConsole.info)
|
|
220
|
+
debug: (0, _threads.runOnJS)(capturableConsole.debug),
|
|
221
|
+
log: (0, _threads.runOnJS)(capturableConsole.log),
|
|
222
|
+
warn: (0, _threads.runOnJS)(capturableConsole.warn),
|
|
223
|
+
error: (0, _threads.runOnJS)(capturableConsole.error),
|
|
224
|
+
info: (0, _threads.runOnJS)(capturableConsole.info)
|
|
319
225
|
};
|
|
320
226
|
|
|
321
227
|
_setGlobalConsole(console);
|
|
@@ -344,8 +250,8 @@ function enableLayoutAnimations(flag) {
|
|
|
344
250
|
}
|
|
345
251
|
}
|
|
346
252
|
|
|
347
|
-
function configureLayoutAnimations(viewTag, type, config
|
|
348
|
-
_NativeReanimated.default.configureLayoutAnimation(viewTag, type,
|
|
253
|
+
function configureLayoutAnimations(viewTag, type, config) {
|
|
254
|
+
_NativeReanimated.default.configureLayoutAnimation(viewTag, type, (0, _shareables.makeShareableCloneRecursive)(config));
|
|
349
255
|
}
|
|
350
256
|
|
|
351
257
|
function configureProps(uiProps, nativeProps) {
|
|
@@ -353,8 +259,4 @@ function configureProps(uiProps, nativeProps) {
|
|
|
353
259
|
_NativeReanimated.default.configureProps(uiProps, nativeProps);
|
|
354
260
|
}
|
|
355
261
|
}
|
|
356
|
-
|
|
357
|
-
function jestResetJsReanimatedModule() {
|
|
358
|
-
_NativeReanimated.default.jestResetModule();
|
|
359
|
-
}
|
|
360
262
|
//# sourceMappingURL=core.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["global","_setGlobalConsole","undefined","testWorklet","throwUninitializedReanimatedException","Error","checkPluginState","throwError","__workletHash","shouldBeUseWeb","isConfigured","isConfiguredCheck","pushFrame","frame","NativeReanimatedModule","requestFrame","native","requestAnimationFrame","_WORKLET","_log","s","console","log","runOnUI","worklet","makeShareable","value","getViewProp","viewTag","propName","_IS_FABRIC","Promise","resolve","reject","result","substr","_getTimestamp","nativeShouldBeMock","getTimestamp","_frameTimestamp","_eventTimestamp","_getCurrentTime","Platform","OS","workletValueSetter","previousAnimation","_animation","cancelled","onFrame","animation","_value","current","isHigherOrder","callback","initializeAnimation","timestamp","onStart","currentTimestamp","step","finished","workletValueSetterJS","_setValue","makeMutable","makeRemote","object","startMapper","mapper","inputs","outputs","updater","viewDescriptors","stopMapper","mapperId","runOnJS","fun","__callAsync","installCoreFunctions","isWeb","capturableConsole","debug","warn","error","info","featuresConfig","enableLayoutAnimations","setByUser","flag","isCallByUser","configureLayoutAnimations","type","config","viewSharedValue","configureLayoutAnimation","configureProps","uiProps","nativeProps","jestResetJsReanimatedModule","jestResetModule"],"sources":["core.ts"],"sourcesContent":["/* global _WORKLET _getCurrentTime _frameTimestamp _eventTimestamp _setGlobalConsole */\nimport NativeReanimatedModule from './NativeReanimated';\nimport { Platform } from 'react-native';\nimport { nativeShouldBeMock, shouldBeUseWeb, isWeb } from './PlatformChecker';\nimport {\n BasicWorkletFunction,\n ComplexWorkletFunction,\n SharedValue,\n AnimationObject,\n AnimatableValue,\n Timestamp,\n} from './commonTypes';\nimport { Descriptor } from './hook/commonTypes';\nimport JSReanimated from './js-reanimated/JSReanimated';\nimport { LayoutAnimationFunction } from './layoutReanimation';\n\nif (global._setGlobalConsole === undefined) {\n // it can happen when Reanimated plugin wasn't added, but the user uses the only API from version 1\n global._setGlobalConsole = () => {\n // noop\n };\n}\n\nexport type ReanimatedConsole = Pick<\n Console,\n 'debug' | 'log' | 'warn' | 'info' | 'error'\n>;\n\nexport type WorkletValue =\n | (() => AnimationObject)\n | AnimationObject\n | AnimatableValue\n | Descriptor;\ninterface WorkletValueSetterContext {\n _animation?: AnimationObject | null;\n _value?: AnimatableValue | Descriptor;\n value?: AnimatableValue;\n _setValue?: (val: AnimatableValue | Descriptor) => void;\n}\n\nconst testWorklet: BasicWorkletFunction<void> = () => {\n 'worklet';\n};\n\nconst throwUninitializedReanimatedException = () => {\n throw new Error(\n \"Failed to initialize react-native-reanimated library, make sure you followed installation steps here: https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation/ \\n1) Make sure reanimated's babel plugin is installed in your babel.config.js (you should have 'react-native-reanimated/plugin' listed there - also see the above link for details) \\n2) Make sure you reset build cache after updating the config, run: yarn start --reset-cache\"\n );\n};\n\nexport const checkPluginState: (throwError: boolean) => boolean = (\n throwError = true\n) => {\n if (!testWorklet.__workletHash && !shouldBeUseWeb()) {\n if (throwError) {\n throwUninitializedReanimatedException();\n }\n return false;\n }\n return true;\n};\n\nexport const isConfigured: (throwError?: boolean) => boolean = (\n throwError = false\n) => {\n return checkPluginState(throwError);\n};\n\nexport const isConfiguredCheck: () => void = () => {\n checkPluginState(true);\n};\n\nfunction pushFrame(frame: (timestamp: Timestamp) => void): void {\n (NativeReanimatedModule as JSReanimated).pushFrame(frame);\n}\n\nexport function requestFrame(frame: (timestamp: Timestamp) => void): void {\n 'worklet';\n if (NativeReanimatedModule.native) {\n requestAnimationFrame(frame);\n } else {\n pushFrame(frame);\n }\n}\n\nglobal._WORKLET = false;\nglobal._log = function (s: string) {\n console.log(s);\n};\n\nexport function runOnUI<A extends any[], R>(\n worklet: ComplexWorkletFunction<A, R>\n): (...args: A) => void {\n return makeShareable(worklet);\n}\n\nexport function makeShareable<T>(value: T): T {\n isConfiguredCheck();\n return NativeReanimatedModule.makeShareable(value);\n}\n\nexport function getViewProp<T>(viewTag: string, propName: string): Promise<T> {\n if (global._IS_FABRIC) {\n throw new Error(\n '[react-native-reanimated] `getViewProp` is not supported on Fabric yet'\n );\n }\n\n return new Promise((resolve, reject) => {\n return NativeReanimatedModule.getViewProp(\n viewTag,\n propName,\n (result: T) => {\n if (typeof result === 'string' && result.substr(0, 6) === 'error:') {\n reject(result);\n } else {\n resolve(result);\n }\n }\n );\n });\n}\n\nlet _getTimestamp: () => number;\nif (nativeShouldBeMock()) {\n _getTimestamp = () => {\n return (NativeReanimatedModule as JSReanimated).getTimestamp();\n };\n} else {\n _getTimestamp = () => {\n 'worklet';\n if (_frameTimestamp) {\n return _frameTimestamp;\n }\n if (_eventTimestamp) {\n return _eventTimestamp;\n }\n return _getCurrentTime();\n };\n}\n\nexport function getTimestamp(): number {\n 'worklet';\n if (Platform.OS === 'web') {\n return (NativeReanimatedModule as JSReanimated).getTimestamp();\n }\n return _getTimestamp();\n}\n\nfunction workletValueSetter<T extends WorkletValue>(\n this: WorkletValueSetterContext,\n value: T\n): void {\n 'worklet';\n const previousAnimation = this._animation;\n if (previousAnimation) {\n previousAnimation.cancelled = true;\n this._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 (this._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, this.value, timestamp, previousAnimation);\n };\n const currentTimestamp = getTimestamp();\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 this._value = animation.current;\n if (finished) {\n animation.callback && animation.callback(true /* finished */);\n } else {\n requestAnimationFrame(step);\n }\n };\n\n this._animation = animation;\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 (this._value === value) {\n return;\n }\n this._value = value as Descriptor | AnimatableValue;\n }\n}\n\n// We cannot use pushFrame\n// so we use own implementation for js\nfunction workletValueSetterJS<T extends WorkletValue>(\n this: WorkletValueSetterContext,\n value: T\n): void {\n const previousAnimation = this._animation;\n if (previousAnimation) {\n previousAnimation.cancelled = true;\n this._animation = null;\n }\n if (\n typeof value === 'function' ||\n (value !== null &&\n typeof value === 'object' &&\n (value as AnimationObject).onFrame)\n ) {\n // animated set\n const animation: AnimationObject =\n typeof value === 'function'\n ? (value as () => AnimationObject)()\n : (value as AnimationObject);\n let initializeAnimation: ((timestamp: number) => void) | null = (\n timestamp: number\n ) => {\n animation.onStart(animation, this.value, timestamp, previousAnimation);\n };\n const step = (timestamp: number) => {\n if (animation.cancelled) {\n animation.callback && animation.callback(false /* finished */);\n return;\n }\n if (initializeAnimation) {\n initializeAnimation(timestamp);\n initializeAnimation = null; // prevent closure from keeping ref to previous animation\n }\n const finished = animation.onFrame(animation, timestamp);\n animation.timestamp = timestamp;\n this._setValue && this._setValue(animation.current as AnimatableValue);\n if (finished) {\n animation.callback && animation.callback(true /* finished */);\n } else {\n requestFrame(step);\n }\n };\n\n this._animation = animation;\n step(getTimestamp());\n } else {\n this._setValue && this._setValue(value as AnimatableValue | Descriptor);\n }\n}\n\nexport function makeMutable<T>(value: T): SharedValue<T> {\n isConfiguredCheck();\n return NativeReanimatedModule.makeMutable(value);\n}\n\nexport function makeRemote<T>(object = {}): T {\n isConfiguredCheck();\n return NativeReanimatedModule.makeRemote(object);\n}\n\nexport function startMapper(\n mapper: () => void,\n inputs: any[] = [],\n outputs: any[] = [],\n updater: () => void = () => {\n // noop\n },\n viewDescriptors: Descriptor[] | SharedValue<Descriptor[]> = []\n): number {\n isConfiguredCheck();\n return NativeReanimatedModule.startMapper(\n mapper,\n inputs,\n outputs,\n updater,\n viewDescriptors\n );\n}\n\nexport function stopMapper(mapperId: number): void {\n NativeReanimatedModule.stopMapper(mapperId);\n}\n\nexport interface RunOnJSFunction<A extends any[], R> {\n __callAsync?: (...args: A) => void;\n (...args: A): R;\n}\n\nexport function runOnJS<A extends any[], R>(\n fun: RunOnJSFunction<A, R>\n): () => void {\n 'worklet';\n if (!_WORKLET) {\n return fun;\n }\n if (!fun.__callAsync) {\n throw new Error(\n \"Attempting to call runOnJS with an object that is not a host function. Using runOnJS is only possible with methods that are defined on the main React-Native Javascript thread and that aren't marked as worklets\"\n );\n } else {\n return fun.__callAsync;\n }\n}\n\nNativeReanimatedModule.installCoreFunctions(\n NativeReanimatedModule.native\n ? (workletValueSetter as <T>(value: T) => void)\n : (workletValueSetterJS as <T>(value: T) => void)\n);\n\nif (!isWeb() && isConfigured()) {\n const capturableConsole = console;\n runOnUI(() => {\n 'worklet';\n const console = {\n debug: runOnJS(capturableConsole.debug),\n log: runOnJS(capturableConsole.log),\n warn: runOnJS(capturableConsole.warn),\n error: runOnJS(capturableConsole.error),\n info: runOnJS(capturableConsole.info),\n };\n _setGlobalConsole(console);\n })();\n}\n\ntype FeaturesConfig = {\n enableLayoutAnimations: boolean;\n setByUser: boolean;\n};\n\nlet featuresConfig: FeaturesConfig = {\n enableLayoutAnimations: false,\n setByUser: false,\n};\n\nexport function enableLayoutAnimations(\n flag: boolean,\n isCallByUser = true\n): void {\n if (isCallByUser) {\n featuresConfig = {\n enableLayoutAnimations: flag,\n setByUser: true,\n };\n NativeReanimatedModule.enableLayoutAnimations(flag);\n } else if (\n !featuresConfig.setByUser &&\n featuresConfig.enableLayoutAnimations !== flag\n ) {\n featuresConfig.enableLayoutAnimations = flag;\n NativeReanimatedModule.enableLayoutAnimations(flag);\n }\n}\n\nexport function configureLayoutAnimations(\n viewTag: number,\n type: string,\n config: LayoutAnimationFunction | Keyframe,\n viewSharedValue: SharedValue<null | Record<string, unknown>> | null\n): void {\n NativeReanimatedModule.configureLayoutAnimation(\n viewTag,\n type,\n config,\n viewSharedValue\n );\n}\n\nexport function configureProps(uiProps: string[], nativeProps: string[]): void {\n if (!nativeShouldBeMock()) {\n NativeReanimatedModule.configureProps(uiProps, nativeProps);\n }\n}\n\nexport function jestResetJsReanimatedModule() {\n (NativeReanimatedModule as JSReanimated).jestResetModule();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AACA;;;;AAHA;AAgBA,IAAIA,MAAM,CAACC,iBAAP,KAA6BC,SAAjC,EAA4C;EAC1C;EACAF,MAAM,CAACC,iBAAP,GAA2B,MAAM,CAC/B;EACD,CAFD;AAGD;;AAmBD,MAAME,WAAuC,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AAuB8E,wBAAvB,CACEhE,OADF,EAEE6D,IAFF,EAGEC,MAHF,EAIEC,eAJF;AAMD;;AAEM,SAASE,cAAT,CAAwBC,OAAxB,EAA2CC,WAA3C,EAAwE;EAC7E,IAAI,CAAC,IAAA1D,mCAAA,GAAL,EAA2B;IACzBvB,yBAAA,CAAuB+E,cAAvB,CAAsCC,OAAtC,EAA+CC,WAA/C;EACD;AACF;;AAEM,SAASC,2BAAT,GAAuC;EAC3ClF,yBAAD,CAAyCmF,eAAzC;AACD"}
|
|
1
|
+
{"version":3,"names":["global","_setGlobalConsole","undefined","testWorklet","throwUninitializedReanimatedException","Error","checkPluginState","throwError","__workletHash","shouldBeUseWeb","isConfigured","isConfiguredCheck","configurationCheckWrapper","__DEV__","fn","startMapper","startMapperUnwrapped","makeShareable","makeShareableUnwrapped","makeMutable","makeMutableUnwrapped","makeRemote","makeRemoteUnwrapped","_WORKLET","_log","s","console","log","getViewProp","viewTag","propName","_IS_FABRIC","Promise","resolve","reject","NativeReanimatedModule","result","substr","valueUnpacker","objectToUnpack","category","workletsCache","__workletsCache","handleCache","__handleCache","Map","WeakMap","workletFun","get","eval","asString","set","functionInstance","bind","_recur","__init","value","fun","__remoteFunction","registerEventHandler","eventHash","eventHandler","makeShareableCloneRecursive","unregisterEventHandler","id","subscribeForKeyboardEvents","unsubscribeFromKeyboardEvents","listenerId","registerSensor","sensorType","interval","unregisterSensor","installCoreFunctions","isWeb","capturableConsole","runOnUI","debug","runOnJS","warn","error","info","featuresConfig","enableLayoutAnimations","setByUser","flag","isCallByUser","configureLayoutAnimations","type","config","configureLayoutAnimation","configureProps","uiProps","nativeProps","nativeShouldBeMock"],"sources":["core.ts"],"sourcesContent":["/* global _setGlobalConsole */\nimport NativeReanimatedModule from './NativeReanimated';\nimport { nativeShouldBeMock, shouldBeUseWeb, isWeb } from './PlatformChecker';\nimport { BasicWorkletFunction, Value3D, ValueRotation } from './commonTypes';\nimport {\n makeShareableCloneRecursive,\n makeShareable as makeShareableUnwrapped,\n} from './shareables';\nimport { runOnUI, runOnJS } from './threads';\nimport { startMapper as startMapperUnwrapped } from './mappers';\nimport {\n makeMutable as makeMutableUnwrapped,\n makeRemote as makeRemoteUnwrapped,\n} from './mutables';\nimport { LayoutAnimationFunction } from './layoutReanimation';\n\nexport { stopMapper } from './mappers';\nexport { runOnJS, runOnUI } from './threads';\nexport { getTimestamp } from './time';\n\nif (global._setGlobalConsole === undefined) {\n // it can happen when Reanimated plugin wasn't added, but the user uses the only API from version 1\n global._setGlobalConsole = () => {\n // noop\n };\n}\n\nexport type ReanimatedConsole = Pick<\n Console,\n 'debug' | 'log' | 'warn' | 'info' | 'error'\n>;\n\nconst testWorklet: BasicWorkletFunction<void> = () => {\n 'worklet';\n};\n\nconst throwUninitializedReanimatedException = () => {\n throw new Error(\n \"Failed to initialize react-native-reanimated library, make sure you followed installation steps here: https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation/ \\n1) Make sure reanimated's babel plugin is installed in your babel.config.js (you should have 'react-native-reanimated/plugin' listed there - also see the above link for details) \\n2) Make sure you reset build cache after updating the config, run: yarn start --reset-cache\"\n );\n};\n\nexport const checkPluginState: (throwError: boolean) => boolean = (\n throwError = true\n) => {\n if (!testWorklet.__workletHash && !shouldBeUseWeb()) {\n if (throwError) {\n throwUninitializedReanimatedException();\n }\n return false;\n }\n return true;\n};\n\nexport const isConfigured: (throwError?: boolean) => boolean = (\n throwError = false\n) => {\n return checkPluginState(throwError);\n};\n\nexport const isConfiguredCheck: () => void = () => {\n checkPluginState(true);\n};\n\nconst configurationCheckWrapper = __DEV__\n ? <T extends Array<any>, U>(fn: (...args: T) => U) => {\n return (...args: T): U => {\n isConfigured(true);\n return fn(...args);\n };\n }\n : <T extends Array<any>, U>(fn: (...args: T) => U) => fn;\n\nexport const startMapper = __DEV__\n ? configurationCheckWrapper(startMapperUnwrapped)\n : startMapperUnwrapped;\n\nexport const makeShareable = __DEV__\n ? configurationCheckWrapper(makeShareableUnwrapped)\n : makeShareableUnwrapped;\n\nexport const makeMutable = __DEV__\n ? configurationCheckWrapper(makeMutableUnwrapped)\n : makeMutableUnwrapped;\n\nexport const makeRemote = __DEV__\n ? configurationCheckWrapper(makeRemoteUnwrapped)\n : makeRemoteUnwrapped;\n\nglobal._WORKLET = false;\nglobal._log = function (s: string) {\n console.log(s);\n};\n\nexport function getViewProp<T>(viewTag: string, propName: string): Promise<T> {\n if (global._IS_FABRIC) {\n throw new Error(\n '[react-native-reanimated] `getViewProp` is not supported on Fabric yet'\n );\n }\n\n return new Promise((resolve, reject) => {\n return NativeReanimatedModule.getViewProp(\n viewTag,\n propName,\n (result: T) => {\n if (typeof result === 'string' && result.substr(0, 6) === 'error:') {\n reject(result);\n } else {\n resolve(result);\n }\n }\n );\n });\n}\n\nfunction valueUnpacker(objectToUnpack: any, category?: string): any {\n 'worklet';\n let workletsCache = global.__workletsCache;\n let handleCache = global.__handleCache;\n if (workletsCache === undefined) {\n // init\n workletsCache = global.__workletsCache = new Map();\n handleCache = global.__handleCache = new WeakMap();\n }\n if (objectToUnpack.__workletHash) {\n let workletFun = workletsCache.get(objectToUnpack.__workletHash);\n if (workletFun === undefined) {\n // eslint-disable-next-line no-eval\n workletFun = eval('(' + objectToUnpack.asString + '\\n)') as (\n ...args: any[]\n ) => any;\n workletsCache.set(objectToUnpack.__workletHash, workletFun);\n }\n const functionInstance = workletFun.bind(objectToUnpack);\n objectToUnpack._recur = functionInstance;\n return functionInstance;\n } else if (objectToUnpack.__init) {\n let value = handleCache!.get(objectToUnpack);\n if (value === undefined) {\n value = objectToUnpack.__init();\n handleCache!.set(objectToUnpack, value);\n }\n return value;\n } else if (category === 'RemoteFunction') {\n const fun = () => {\n throw new Error(`Tried to synchronously call a non-worklet function on the UI thread.\n\nPossible solutions are:\n a) If you want to synchronously execute this method, mark it as a worklet\n b) If you want to execute this function on the JS thread, wrap it using \\`runOnJS\\``);\n };\n fun.__remoteFunction = objectToUnpack;\n return fun;\n } else {\n throw new Error('data type not recognized by unpack method');\n }\n}\n\nexport function registerEventHandler<T>(\n eventHash: string,\n eventHandler: (event: T) => void\n): string {\n return NativeReanimatedModule.registerEventHandler(\n eventHash,\n makeShareableCloneRecursive(eventHandler)\n );\n}\n\nexport function unregisterEventHandler(id: string): void {\n return NativeReanimatedModule.unregisterEventHandler(id);\n}\n\nexport function subscribeForKeyboardEvents(\n eventHandler: (state: number, height: number) => void\n): number {\n return NativeReanimatedModule.subscribeForKeyboardEvents(\n makeShareableCloneRecursive(eventHandler)\n );\n}\n\nexport function unsubscribeFromKeyboardEvents(listenerId: number): void {\n return NativeReanimatedModule.unsubscribeFromKeyboardEvents(listenerId);\n}\n\nexport function registerSensor(\n sensorType: number,\n interval: number,\n eventHandler: (data: Value3D | ValueRotation) => void\n): number {\n return NativeReanimatedModule.registerSensor(\n sensorType,\n interval,\n makeShareableCloneRecursive(eventHandler)\n );\n}\n\nexport function unregisterSensor(listenerId: number): void {\n return NativeReanimatedModule.unregisterSensor(listenerId);\n}\n\nNativeReanimatedModule.installCoreFunctions(valueUnpacker);\n\nif (!isWeb() && isConfigured()) {\n const capturableConsole = console;\n runOnUI(() => {\n 'worklet';\n const console = {\n debug: runOnJS(capturableConsole.debug),\n log: runOnJS(capturableConsole.log),\n warn: runOnJS(capturableConsole.warn),\n error: runOnJS(capturableConsole.error),\n info: runOnJS(capturableConsole.info),\n };\n _setGlobalConsole(console);\n })();\n}\n\ntype FeaturesConfig = {\n enableLayoutAnimations: boolean;\n setByUser: boolean;\n};\n\nlet featuresConfig: FeaturesConfig = {\n enableLayoutAnimations: false,\n setByUser: false,\n};\n\nexport function enableLayoutAnimations(\n flag: boolean,\n isCallByUser = true\n): void {\n if (isCallByUser) {\n featuresConfig = {\n enableLayoutAnimations: flag,\n setByUser: true,\n };\n NativeReanimatedModule.enableLayoutAnimations(flag);\n } else if (\n !featuresConfig.setByUser &&\n featuresConfig.enableLayoutAnimations !== flag\n ) {\n featuresConfig.enableLayoutAnimations = flag;\n NativeReanimatedModule.enableLayoutAnimations(flag);\n }\n}\n\nexport function configureLayoutAnimations(\n viewTag: number,\n type: string,\n config: LayoutAnimationFunction | Keyframe\n): void {\n NativeReanimatedModule.configureLayoutAnimation(\n viewTag,\n type,\n makeShareableCloneRecursive(config)\n );\n}\n\nexport function configureProps(uiProps: string[], nativeProps: string[]): void {\n if (!nativeShouldBeMock()) {\n NativeReanimatedModule.configureProps(uiProps, nativeProps);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AAEA;;AAIA;;AACA;;AACA;;AAQA;;;;AAlBA;AAoBA,IAAIA,MAAM,CAACC,iBAAP,KAA6BC,SAAjC,EAA4C;EAC1C;EACAF,MAAM,CAACC,iBAAP,GAA2B,MAAM,CAC/B;EACD,CAFD;AAGD;;AAOD,MAAME,WAAuC,GAAG,MAAM;EACpD;AACD,CAFD;;AAIA,MAAMC,qCAAqC,GAAG,MAAM;EAClD,MAAM,IAAIC,KAAJ,CACJ,4cADI,CAAN;AAGD,CAJD;;AAMO,MAAMC,gBAAkD,GAAG,YAE7D;EAAA,IADHC,UACG,uEADU,IACV;;EACH,IAAI,CAACJ,WAAW,CAACK,aAAb,IAA8B,CAAC,IAAAC,+BAAA,GAAnC,EAAqD;IACnD,IAAIF,UAAJ,EAAgB;MACdH,qCAAqC;IACtC;;IACD,OAAO,KAAP;EACD;;EACD,OAAO,IAAP;AACD,CAVM;;;;AAYA,MAAMM,YAA+C,GAAG,YAE1D;EAAA,IADHH,UACG,uEADU,KACV;EACH,OAAOD,gBAAgB,CAACC,UAAD,CAAvB;AACD,CAJM;;;;AAMA,MAAMI,iBAA6B,GAAG,MAAM;EACjDL,gBAAgB,CAAC,IAAD,CAAhB;AACD,CAFM;;;AAIP,MAAMM,yBAAyB,GAAGC,OAAO,GACXC,EAA1B,IAAoD;EAClD,OAAO,YAAmB;IACxBJ,YAAY,CAAC,IAAD,CAAZ;IACA,OAAOI,EAAE,CAA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iBAAiB,CAACI,IAA1B,CAHQ;MAIdC,KAAK,EAAE,IAAAF,gBAAA,EAAQH,iBAAiB,CAACK,KAA1B,CAJO;MAKdC,IAAI,EAAE,IAAAH,gBAAA,EAAQH,iBAAiB,CAACM,IAA1B;IALQ,CAAhB;;IAOA/E,iBAAiB,CAACyB,OAAD,CAAjB;EACD,CAVD;AAWD;;AAOD,IAAIuD,cAA8B,GAAG;EACnCC,sBAAsB,EAAE,KADW;EAEnCC,SAAS,EAAE;AAFwB,CAArC;;AAKO,SAASD,sBAAT,CACLE,IADK,EAGC;EAAA,IADNC,YACM,uEADS,IACT;;EACN,IAAIA,YAAJ,EAAkB;IAChBJ,cAAc,GAAG;MACfC,sBAAsB,EAAEE,IADT;MAEfD,SAAS,EAAE;IAFI,CAAjB;;IAIAhD,yBAAA,CAAuB+C,sBAAvB,CAA8CE,IAA9C;EACD,CAND,MAMO,IACL,CAACH,cAAc,CAACE,SAAhB,IACAF,cAAc,CAACC,sBAAf,KAA0CE,IAFrC,EAGL;IACAH,cAAc,CAACC,sBAAf,GAAwCE,IAAxC;;IACAjD,yBAAA,CAAuB+C,sBAAvB,CAA8CE,IAA9C;EACD;AACF;;AAEM,SAASE,yBAAT,CACLzD,OADK,EAEL0D,IAFK,EAGLC,MAHK,EAIC;EACNrD,yBAAA,CAAuBsD,wBAAvB,CACE5D,OADF,EAEE0D,IAFF,EAGE,IAAAzB,uCAAA,EAA4B0B,MAA5B,CAHF;AAKD;;AAEM,SAASE,cAAT,CAAwBC,OAAxB,EAA2CC,WAA3C,EAAwE;EAC7E,IAAI,CAAC,IAAAC,mCAAA,GAAL,EAA2B;IACzB1D,yBAAA,CAAuBuD,cAAvB,CAAsCC,OAAtC,EAA+CC,WAA/C;EACD;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["globals.d.ts"],"sourcesContent":["import type {\n AnimatedStyle,\n StyleProps,\n MeasuredDimensions,\n} from './commonTypes';\nimport type { ReanimatedConsole } from './core';\nimport type { FrameCallbackRegistryUI } from './frameCallback/FrameCallbackRegistryUI';\nimport type { ShadowNodeWrapper } from './hook/commonTypes';\nimport type { NativeReanimated } from './NativeReanimated/NativeReanimated';\n\ndeclare global {\n const _WORKLET: boolean;\n const _IS_FABRIC: boolean;\n const _REANIMATED_VERSION_CPP: string;\n const _frameTimestamp: number | null;\n const _eventTimestamp: number;\n const __reanimatedModuleProxy: NativeReanimated;\n const _setGlobalConsole: (console?: ReanimatedConsole) => void;\n const _log: (s: string) => void;\n const _getCurrentTime: () => number;\n const
|
|
1
|
+
{"version":3,"names":[],"sources":["globals.d.ts"],"sourcesContent":["import type {\n AnimatedStyle,\n StyleProps,\n MeasuredDimensions,\n MapperRegistry,\n ShareableRef,\n ShareableSyncDataHolderRef,\n} from './commonTypes';\nimport type { ReanimatedConsole } from './core';\nimport type { FrameCallbackRegistryUI } from './frameCallback/FrameCallbackRegistryUI';\nimport type { ShadowNodeWrapper } from './hook/commonTypes';\nimport { LayoutAnimationStartFunction } from './layoutReanimation';\nimport type { NativeReanimated } from './NativeReanimated/NativeReanimated';\n\ndeclare global {\n const _WORKLET: boolean;\n const _IS_FABRIC: boolean;\n const _REANIMATED_VERSION_CPP: string;\n const _frameTimestamp: number | null;\n const _eventTimestamp: number;\n const __reanimatedModuleProxy: NativeReanimated;\n const _setGlobalConsole: (console?: ReanimatedConsole) => void;\n const _log: (s: string) => void;\n const _getCurrentTime: () => number;\n const _getTimestamp: () => number;\n const _notifyAboutProgress: (tag: number, value: number) => void;\n const _notifyAboutEnd: (\n tag: number,\n finished: boolean,\n removeView: boolean\n ) => void;\n const _setGestureState: (handlerTag: number, newState: number) => void;\n const _makeShareableClone: (value: any) => any;\n const _updateDataSynchronously: (\n dataHolder: ShareableSyncDataHolderRef,\n data: ShareableRef\n ) => void;\n const _scheduleOnJS: (fun: ShareableRef, args?: ShareableRef) => void;\n const _updatePropsPaper: (\n tag: number,\n name: string,\n updates: StyleProps | AnimatedStyle\n ) => void;\n const _updatePropsFabric: (\n shadowNodeWrapper: ShadowNodeWrapper,\n props: StyleProps | AnimatedStyle\n ) => void;\n const _removeShadowNodeFromRegistry: (\n shadowNodeWrapper: ShadowNodeWrapper\n ) => void;\n const _measure: (viewTag: number) => MeasuredDimensions;\n const _scrollTo: (\n viewTag: number,\n x: number,\n y: number,\n animated: boolean\n ) => void;\n const _dispatchCommand: (\n shadowNodeWrapper: ShadowNodeWrapper,\n commandName: string,\n args: Array<unknown>\n ) => void;\n const _chronoNow: () => number;\n const performance: { now: () => number };\n const ReanimatedDataMock: {\n now: () => number;\n };\n const _frameCallbackRegistry: FrameCallbackRegistryUI;\n\n namespace NodeJS {\n interface Global {\n _WORKLET: boolean;\n _IS_FABRIC: boolean;\n _REANIMATED_VERSION_CPP: string;\n _frameTimestamp: number | null;\n _eventTimestamp: number;\n __reanimatedModuleProxy: NativeReanimated;\n _setGlobalConsole: (console?: ReanimatedConsole) => void;\n _log: (s: string) => void;\n _getCurrentTime: () => number;\n _getTimestamp: () => number;\n _setGestureState: (handlerTag: number, newState: number) => void;\n _makeShareableClone: (value: any) => any;\n _updateDataSynchronously: (\n ShareableSyncDataHolderRef,\n ShareableRef\n ) => void;\n _scheduleOnJS: (fun: ShareableRef, args?: ShareableRef) => void;\n _updatePropsPaper: (\n tag: number,\n name: string,\n updates: StyleProps | AnimatedStyle\n ) => void;\n _updatePropsFabric: (\n shadowNodeWrapper: ShadowNodeWrapper,\n props: StyleProps | AnimatedStyle\n ) => void;\n _removeShadowNodeFromRegistry: (\n shadowNodeWrapper: ShadowNodeWrapper\n ) => void;\n _measure: (viewTag: number) => MeasuredDimensions;\n _scrollTo: (\n viewTag: number,\n x: number,\n y: number,\n animated: boolean\n ) => void;\n _dispatchCommand: (\n shadowNodeWrapper: ShadowNodeWrapper,\n commandName: string,\n args: Array<unknown>\n ) => void;\n _chronoNow: () => number;\n performance: { now: () => number };\n LayoutAnimationsManager: {\n start: LayoutAnimationStartFunction;\n };\n ReanimatedDataMock: {\n now: () => number;\n };\n _frameCallbackRegistry: FrameCallbackRegistryUI;\n __workletsCache?: Map<string, (...args: any[]) => any>;\n __handleCache?: WeakMap<any, any>;\n __mapperRegistry?: MapperRegistry;\n }\n }\n}\n"],"mappings":""}
|
|
@@ -7,14 +7,10 @@ exports.useAnimatedKeyboard = useAnimatedKeyboard;
|
|
|
7
7
|
|
|
8
8
|
var _react = require("react");
|
|
9
9
|
|
|
10
|
-
var _NativeReanimated = _interopRequireDefault(require("../NativeReanimated"));
|
|
11
|
-
|
|
12
10
|
var _core = require("../core");
|
|
13
11
|
|
|
14
12
|
var _commonTypes = require("../commonTypes");
|
|
15
13
|
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
14
|
function useAnimatedKeyboard() {
|
|
19
15
|
const ref = (0, _react.useRef)(null);
|
|
20
16
|
const listenerId = (0, _react.useRef)(-1);
|
|
@@ -25,21 +21,31 @@ function useAnimatedKeyboard() {
|
|
|
25
21
|
state: (0, _core.makeMutable)(_commonTypes.KeyboardState.UNKNOWN),
|
|
26
22
|
height: (0, _core.makeMutable)(0)
|
|
27
23
|
};
|
|
28
|
-
listenerId.current =
|
|
24
|
+
listenerId.current = (0, _core.subscribeForKeyboardEvents)((state, height) => {
|
|
25
|
+
'worklet';
|
|
26
|
+
|
|
27
|
+
keyboardEventData.state.value = state;
|
|
28
|
+
keyboardEventData.height.value = height;
|
|
29
|
+
});
|
|
29
30
|
ref.current = keyboardEventData;
|
|
30
31
|
isSubscribed.current = true;
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
(0, _react.useEffect)(() => {
|
|
34
35
|
if (isSubscribed.current === false && ref.current !== null) {
|
|
35
|
-
// subscribe again after Fast Refresh
|
|
36
|
-
|
|
36
|
+
const keyboardEventData = ref.current; // subscribe again after Fast Refresh
|
|
37
|
+
|
|
38
|
+
listenerId.current = (0, _core.subscribeForKeyboardEvents)((state, height) => {
|
|
39
|
+
'worklet';
|
|
40
|
+
|
|
41
|
+
keyboardEventData.state.value = state;
|
|
42
|
+
keyboardEventData.height.value = height;
|
|
43
|
+
});
|
|
37
44
|
isSubscribed.current = true;
|
|
38
45
|
}
|
|
39
46
|
|
|
40
47
|
return () => {
|
|
41
|
-
|
|
42
|
-
|
|
48
|
+
(0, _core.unsubscribeFromKeyboardEvents)(listenerId.current);
|
|
43
49
|
isSubscribed.current = false;
|
|
44
50
|
};
|
|
45
51
|
}, []);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useAnimatedKeyboard","ref","useRef","listenerId","isSubscribed","current","keyboardEventData","state","makeMutable","KeyboardState","UNKNOWN","height","
|
|
1
|
+
{"version":3,"names":["useAnimatedKeyboard","ref","useRef","listenerId","isSubscribed","current","keyboardEventData","state","makeMutable","KeyboardState","UNKNOWN","height","subscribeForKeyboardEvents","value","useEffect","unsubscribeFromKeyboardEvents"],"sources":["useAnimatedKeyboard.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\nimport {\n makeMutable,\n subscribeForKeyboardEvents,\n unsubscribeFromKeyboardEvents,\n} from '../core';\nimport { AnimatedKeyboardInfo, KeyboardState } from '../commonTypes';\n\nexport function useAnimatedKeyboard(): AnimatedKeyboardInfo {\n const ref = useRef<AnimatedKeyboardInfo | null>(null);\n const listenerId = useRef<number>(-1);\n const isSubscribed = useRef<boolean>(false);\n\n if (ref.current === null) {\n const keyboardEventData: AnimatedKeyboardInfo = {\n state: makeMutable<KeyboardState>(KeyboardState.UNKNOWN),\n height: makeMutable(0),\n };\n listenerId.current = subscribeForKeyboardEvents((state, height) => {\n 'worklet';\n keyboardEventData.state.value = state;\n keyboardEventData.height.value = height;\n });\n ref.current = keyboardEventData;\n isSubscribed.current = true;\n }\n useEffect(() => {\n if (isSubscribed.current === false && ref.current !== null) {\n const keyboardEventData = ref.current;\n // subscribe again after Fast Refresh\n listenerId.current = subscribeForKeyboardEvents((state, height) => {\n 'worklet';\n keyboardEventData.state.value = state;\n keyboardEventData.height.value = height;\n });\n isSubscribed.current = true;\n }\n return () => {\n unsubscribeFromKeyboardEvents(listenerId.current);\n isSubscribed.current = false;\n };\n }, []);\n return ref.current;\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;AAKA;;AAEO,SAASA,mBAAT,GAAqD;EAC1D,MAAMC,GAAG,GAAG,IAAAC,aAAA,EAAoC,IAApC,CAAZ;EACA,MAAMC,UAAU,GAAG,IAAAD,aAAA,EAAe,CAAC,CAAhB,CAAnB;EACA,MAAME,YAAY,GAAG,IAAAF,aAAA,EAAgB,KAAhB,CAArB;;EAEA,IAAID,GAAG,CAACI,OAAJ,KAAgB,IAApB,EAA0B;IACxB,MAAMC,iBAAuC,GAAG;MAC9CC,KAAK,EAAE,IAAAC,iBAAA,EAA2BC,0BAAA,CAAcC,OAAzC,CADuC;MAE9CC,MAAM,EAAE,IAAAH,iBAAA,EAAY,CAAZ;IAFsC,CAAhD;IAIAL,UAAU,CAACE,OAAX,GAAqB,IAAAO,gCAAA,EAA2B,CAACL,KAAD,EAAQI,MAAR,KAAmB;MACjE;;MACAL,iBAAiB,CAACC,KAAlB,CAAwBM,KAAxB,GAAgCN,KAAhC;MACAD,iBAAiB,CAACK,MAAlB,CAAyBE,KAAzB,GAAiCF,MAAjC;IACD,CAJoB,CAArB;IAKAV,GAAG,CAACI,OAAJ,GAAcC,iBAAd;IACAF,YAAY,CAACC,OAAb,GAAuB,IAAvB;EACD;;EACD,IAAAS,gBAAA,EAAU,MAAM;IACd,IAAIV,YAAY,CAACC,OAAb,KAAyB,KAAzB,IAAkCJ,GAAG,CAACI,OAAJ,KAAgB,IAAtD,EAA4D;MAC1D,MAAMC,iBAAiB,GAAGL,GAAG,CAACI,OAA9B,CAD0D,CAE1D;;MACAF,UAAU,CAACE,OAAX,GAAqB,IAAAO,gCAAA,EAA2B,CAACL,KAAD,EAAQI,MAAR,KAAmB;QACjE;;QACAL,iBAAiB,CAACC,KAAlB,CAAwBM,KAAxB,GAAgCN,KAAhC;QACAD,iBAAiB,CAACK,MAAlB,CAAyBE,KAAzB,GAAiCF,MAAjC;MACD,CAJoB,CAArB;MAKAP,YAAY,CAACC,OAAb,GAAuB,IAAvB;IACD;;IACD,OAAO,MAAM;MACX,IAAAU,mCAAA,EAA8BZ,UAAU,CAACE,OAAzC;MACAD,YAAY,CAACC,OAAb,GAAuB,KAAvB;IACD,CAHD;EAID,CAfD,EAeG,EAfH;EAgBA,OAAOJ,GAAG,CAACI,OAAX;AACD"}
|
|
@@ -13,28 +13,38 @@ var _NativeMethods = require("../NativeMethods");
|
|
|
13
13
|
|
|
14
14
|
var _fabricUtils = require("../fabricUtils");
|
|
15
15
|
|
|
16
|
+
var _shareables = require("../shareables");
|
|
17
|
+
|
|
18
|
+
function getShareableShadowNodeFromComponent(component) {
|
|
19
|
+
return (0, _shareables.makeShareableShadowNodeWrapper)((0, _fabricUtils.getShadowNodeWrapperFromHostInstance)(component));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const getTagValueFunction = global._IS_FABRIC ? getShareableShadowNodeFromComponent : _NativeMethods.getTag;
|
|
23
|
+
|
|
16
24
|
function useAnimatedRef() {
|
|
17
25
|
const tag = (0, _useSharedValue.useSharedValue)(-1);
|
|
18
26
|
const ref = (0, _react.useRef)();
|
|
19
|
-
const isFabric = global._IS_FABRIC;
|
|
20
27
|
|
|
21
28
|
if (!ref.current) {
|
|
22
29
|
const fun = component => {
|
|
23
|
-
|
|
24
|
-
|
|
30
|
+
// enters when ref is set by attaching to a component
|
|
25
31
|
if (component) {
|
|
26
|
-
tag.value =
|
|
32
|
+
tag.value = getTagValueFunction(component);
|
|
27
33
|
fun.current = component;
|
|
28
34
|
}
|
|
29
35
|
|
|
30
36
|
return tag.value;
|
|
31
37
|
};
|
|
32
38
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
fun.current = null;
|
|
40
|
+
const remoteRef = (0, _shareables.makeShareableCloneRecursive)({
|
|
41
|
+
__init: () => {
|
|
42
|
+
'worklet';
|
|
43
|
+
|
|
44
|
+
return () => tag.value;
|
|
45
|
+
}
|
|
37
46
|
});
|
|
47
|
+
(0, _shareables.registerShareableMapping)(fun, remoteRef);
|
|
38
48
|
ref.current = fun;
|
|
39
49
|
}
|
|
40
50
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["getShareableShadowNodeFromComponent","component","makeShareableShadowNodeWrapper","getShadowNodeWrapperFromHostInstance","getTagValueFunction","global","_IS_FABRIC","getTag","useAnimatedRef","tag","useSharedValue","ref","useRef","current","fun","value","remoteRef","makeShareableCloneRecursive","__init","registerShareableMapping"],"sources":["useAnimatedRef.ts"],"sourcesContent":["import { Component, useRef } from 'react';\nimport { useSharedValue } from './useSharedValue';\nimport { RefObjectFunction } from './commonTypes';\nimport { ShadowNodeWrapper } from '../commonTypes';\nimport { getTag } from '../NativeMethods';\nimport { getShadowNodeWrapperFromHostInstance } from '../fabricUtils';\nimport {\n makeShareableCloneRecursive,\n makeShareableShadowNodeWrapper,\n registerShareableMapping,\n} from '../shareables';\n\nfunction getShareableShadowNodeFromComponent(\n component: Component\n): ShadowNodeWrapper {\n return makeShareableShadowNodeWrapper(\n getShadowNodeWrapperFromHostInstance(component)\n );\n}\n\nconst getTagValueFunction = global._IS_FABRIC\n ? getShareableShadowNodeFromComponent\n : getTag;\n\nexport function useAnimatedRef<T extends Component>(): RefObjectFunction<T> {\n const tag = useSharedValue<number | ShadowNodeWrapper | null>(-1);\n const ref = useRef<RefObjectFunction<T>>();\n\n if (!ref.current) {\n const fun: RefObjectFunction<T> = <RefObjectFunction<T>>((component) => {\n // enters when ref is set by attaching to a component\n if (component) {\n tag.value = getTagValueFunction(component);\n fun.current = component;\n }\n return tag.value;\n });\n\n fun.current = null;\n\n const remoteRef = makeShareableCloneRecursive({\n __init: () => {\n 'worklet';\n return () => tag.value;\n },\n });\n registerShareableMapping(fun, remoteRef);\n\n ref.current = fun;\n }\n\n return ref.current;\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;AAGA;;AACA;;AACA;;AAMA,SAASA,mCAAT,CACEC,SADF,EAEqB;EACnB,OAAO,IAAAC,0CAAA,EACL,IAAAC,iDAAA,EAAqCF,SAArC,CADK,CAAP;AAGD;;AAED,MAAMG,mBAAmB,GAAGC,MAAM,CAACC,UAAP,GACxBN,mCADwB,GAExBO,qBAFJ;;AAIO,SAASC,cAAT,GAAqE;EAC1E,MAAMC,GAAG,GAAG,IAAAC,8BAAA,EAAkD,CAAC,CAAnD,CAAZ;EACA,MAAMC,GAAG,GAAG,IAAAC,aAAA,GAAZ;;EAEA,IAAI,CAACD,GAAG,CAACE,OAAT,EAAkB;IAChB,MAAMC,GAAyB,GAA2Bb,SAAD,IAAe;MACtE;MACA,IAAIA,SAAJ,EAAe;QACbQ,GAAG,CAACM,KAAJ,GAAYX,mBAAmB,CAACH,SAAD,CAA/B;QACAa,GAAG,CAACD,OAAJ,GAAcZ,SAAd;MACD;;MACD,OAAOQ,GAAG,CAACM,KAAX;IACD,CAPD;;IASAD,GAAG,CAACD,OAAJ,GAAc,IAAd;IAEA,MAAMG,SAAS,GAAG,IAAAC,uCAAA,EAA4B;MAC5CC,MAAM,EAAE,MAAM;QACZ;;QACA,OAAO,MAAMT,GAAG,CAACM,KAAjB;MACD;IAJ2C,CAA5B,CAAlB;IAMA,IAAAI,oCAAA,EAAyBL,GAAzB,EAA8BE,SAA9B;IAEAL,GAAG,CAACE,OAAJ,GAAcC,GAAd;EACD;;EAED,OAAOH,GAAG,CAACE,OAAX;AACD"}
|