react-native-reanimated 2.7.0 → 2.8.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/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/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/react-native-reanimated-64-hermes.aar +0 -0
- package/android/react-native-reanimated-64-jsc.aar +0 -0
- package/android/react-native-reanimated-65-hermes.aar +0 -0
- package/android/react-native-reanimated-65-jsc.aar +0 -0
- package/android/react-native-reanimated-66-hermes.aar +0 -0
- package/android/react-native-reanimated-66-jsc.aar +0 -0
- package/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/src/main/cpp/NativeProxy.cpp +22 -12
- package/android/src/main/cpp/headers/NativeProxy.h +2 -0
- package/ios/native/NativeProxy.mm +6 -2
- package/lib/Animated.js +0 -9
- package/lib/index.js +0 -9
- package/lib/types/lib/reanimated2/hook/useAnimatedSensor.d.ts +1 -3
- package/package.json +1 -1
- package/plugin.js +25 -20
- package/react-native-reanimated.d.ts +15 -3
- package/src/Animated.js +0 -9
- package/src/reanimated2/hook/useAnimatedSensor.ts +1 -3
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
#
|
|
1
|
+
#Thu Apr 21 15:44:53 UTC 2022
|
|
2
2
|
gradle.version=7.2
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -37,6 +37,13 @@ NativeProxy::NativeProxy(
|
|
|
37
37
|
scheduler_(scheduler),
|
|
38
38
|
layoutAnimations(std::move(_layoutAnimations)) {}
|
|
39
39
|
|
|
40
|
+
NativeProxy::~NativeProxy() {
|
|
41
|
+
runtime_->global().setProperty(
|
|
42
|
+
*runtime_,
|
|
43
|
+
jsi::PropNameID::forAscii(*runtime_, "__reanimatedModuleProxy"),
|
|
44
|
+
jsi::Value::undefined());
|
|
45
|
+
}
|
|
46
|
+
|
|
40
47
|
jni::local_ref<NativeProxy::jhybriddata> NativeProxy::initHybrid(
|
|
41
48
|
jni::alias_ref<jhybridobject> jThis,
|
|
42
49
|
jlong jsContext,
|
|
@@ -192,18 +199,21 @@ void NativeProxy::installJSIBindings() {
|
|
|
192
199
|
platformDepMethodsHolder);
|
|
193
200
|
|
|
194
201
|
_nativeReanimatedModule = module;
|
|
195
|
-
|
|
196
|
-
this->registerEventHandler(
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
202
|
+
std::weak_ptr<NativeReanimatedModule> weakModule = module;
|
|
203
|
+
this->registerEventHandler(
|
|
204
|
+
[weakModule, getCurrentTime](
|
|
205
|
+
std::string eventName, std::string eventAsString) {
|
|
206
|
+
if (auto module = weakModule.lock()) {
|
|
207
|
+
jsi::Object global = module->runtime->global();
|
|
208
|
+
jsi::String eventTimestampName =
|
|
209
|
+
jsi::String::createFromAscii(*module->runtime, "_eventTimestamp");
|
|
210
|
+
global.setProperty(
|
|
211
|
+
*module->runtime, eventTimestampName, getCurrentTime());
|
|
212
|
+
module->onEvent(eventName, eventAsString);
|
|
213
|
+
global.setProperty(
|
|
214
|
+
*module->runtime, eventTimestampName, jsi::Value::undefined());
|
|
215
|
+
}
|
|
216
|
+
});
|
|
207
217
|
|
|
208
218
|
runtime_->global().setProperty(
|
|
209
219
|
*runtime_,
|
|
@@ -131,6 +131,8 @@ class NativeProxy : public jni::HybridClass<NativeProxy> {
|
|
|
131
131
|
jni::alias_ref<LayoutAnimations::javaobject> layoutAnimations);
|
|
132
132
|
static void registerNatives();
|
|
133
133
|
|
|
134
|
+
~NativeProxy();
|
|
135
|
+
|
|
134
136
|
private:
|
|
135
137
|
friend HybridBase;
|
|
136
138
|
jni::global_ref<NativeProxy::javaobject> javaPart_;
|
|
@@ -162,8 +162,12 @@ std::shared_ptr<NativeReanimatedModule> createReanimatedModule(
|
|
|
162
162
|
scrollTo(viewTag, uiManager, x, y, animated);
|
|
163
163
|
};
|
|
164
164
|
|
|
165
|
-
id<RNGestureHandlerStateManager> gestureHandlerStateManager =
|
|
166
|
-
auto setGestureStateFunction = [gestureHandlerStateManager](int handlerTag, int newState) {
|
|
165
|
+
id<RNGestureHandlerStateManager> gestureHandlerStateManager = nil;
|
|
166
|
+
auto setGestureStateFunction = [gestureHandlerStateManager, bridge](int handlerTag, int newState) mutable {
|
|
167
|
+
if (gestureHandlerStateManager == nil) {
|
|
168
|
+
gestureHandlerStateManager = [bridge moduleForName:@"RNGestureHandlerModule"];
|
|
169
|
+
}
|
|
170
|
+
|
|
167
171
|
setGestureState(gestureHandlerStateManager, handlerTag, newState);
|
|
168
172
|
};
|
|
169
173
|
|
package/lib/Animated.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { LogBox } from 'react-native';
|
|
2
1
|
import createAnimatedComponent from './createAnimatedComponent';
|
|
3
2
|
import {
|
|
4
3
|
addWhitelistedNativeProps,
|
|
@@ -21,11 +20,3 @@ const Animated = {
|
|
|
21
20
|
export * from './reanimated2';
|
|
22
21
|
export * from './reanimated1';
|
|
23
22
|
export default Animated;
|
|
24
|
-
|
|
25
|
-
// I think we can ignore this message as long as Gesture Handler doesn't
|
|
26
|
-
// try to load the Reanimated module. I figured it should be here instead of
|
|
27
|
-
// RNGH because this prevents the message from being displayed for all
|
|
28
|
-
// versions of RNGH.
|
|
29
|
-
LogBox.ignoreLogs([
|
|
30
|
-
'RCTBridge required dispatch_sync to load RNGestureHandlerModule. This may lead to deadlocks',
|
|
31
|
-
]);
|
package/lib/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { LogBox } from 'react-native';
|
|
2
1
|
import createAnimatedComponent from './createAnimatedComponent';
|
|
3
2
|
import {
|
|
4
3
|
addWhitelistedNativeProps,
|
|
@@ -21,11 +20,3 @@ const Animated = {
|
|
|
21
20
|
export * from './reanimated2';
|
|
22
21
|
export * from './reanimated1';
|
|
23
22
|
export default Animated;
|
|
24
|
-
|
|
25
|
-
// I think we can ignore this message as long as Gesture Handler doesn't
|
|
26
|
-
// try to load the Reanimated module. I figured it should be here instead of
|
|
27
|
-
// RNGH because this prevents the message from being displayed for all
|
|
28
|
-
// versions of RNGH.
|
|
29
|
-
LogBox.ignoreLogs([
|
|
30
|
-
'RCTBridge required dispatch_sync to load RNGestureHandlerModule. This may lead to deadlocks',
|
|
31
|
-
]);
|
|
@@ -13,8 +13,6 @@ export declare type AnimatedSensor = {
|
|
|
13
13
|
sensor: SensorValue3D | SensorValueRotation | null;
|
|
14
14
|
unregister: () => void;
|
|
15
15
|
isAvailable: boolean;
|
|
16
|
-
config:
|
|
17
|
-
interval: number;
|
|
18
|
-
};
|
|
16
|
+
config: SensorConfig;
|
|
19
17
|
};
|
|
20
18
|
export declare function useAnimatedSensor(sensorType: SensorType, userConfig?: SensorConfig): AnimatedSensor;
|
package/package.json
CHANGED
package/plugin.js
CHANGED
|
@@ -331,7 +331,7 @@ function makeWorkletName(t, fun) {
|
|
|
331
331
|
return '_f'; // fallback for ArrowFunctionExpression and unnamed FunctionExpression
|
|
332
332
|
}
|
|
333
333
|
|
|
334
|
-
function makeWorklet(t, fun,
|
|
334
|
+
function makeWorklet(t, fun, state) {
|
|
335
335
|
// Returns a new FunctionExpression which is a workletized version of provided
|
|
336
336
|
// FunctionDeclaration, FunctionExpression, ArrowFunctionExpression or ObjectMethod.
|
|
337
337
|
|
|
@@ -358,7 +358,7 @@ function makeWorklet(t, fun, fileName) {
|
|
|
358
358
|
'\n(' + (t.isObjectMethod(fun) ? 'function ' : '') + fun.toString() + '\n)';
|
|
359
359
|
|
|
360
360
|
const transformed = transformSync(code, {
|
|
361
|
-
filename:
|
|
361
|
+
filename: state.file.opts.filename,
|
|
362
362
|
presets: ['@babel/preset-typescript'],
|
|
363
363
|
plugins: [
|
|
364
364
|
'@babel/plugin-transform-shorthand-properties',
|
|
@@ -445,11 +445,17 @@ function makeWorklet(t, fun, fileName) {
|
|
|
445
445
|
);
|
|
446
446
|
const workletHash = hash(funString);
|
|
447
447
|
|
|
448
|
+
let location = state.file.opts.filename;
|
|
449
|
+
if (state.opts.relativeSourceLocation) {
|
|
450
|
+
const path = require('path');
|
|
451
|
+
location = path.relative(state.cwd, location);
|
|
452
|
+
}
|
|
453
|
+
|
|
448
454
|
const loc = fun && fun.node && fun.node.loc && fun.node.loc.start;
|
|
449
455
|
if (loc) {
|
|
450
456
|
const { line, column } = loc;
|
|
451
457
|
if (typeof line === 'number' && typeof column === 'number') {
|
|
452
|
-
|
|
458
|
+
location = `${location} (${line}:${column})`;
|
|
453
459
|
}
|
|
454
460
|
}
|
|
455
461
|
|
|
@@ -490,7 +496,7 @@ function makeWorklet(t, fun, fileName) {
|
|
|
490
496
|
t.identifier('__location'),
|
|
491
497
|
false
|
|
492
498
|
),
|
|
493
|
-
t.stringLiteral(
|
|
499
|
+
t.stringLiteral(location)
|
|
494
500
|
)
|
|
495
501
|
),
|
|
496
502
|
];
|
|
@@ -518,7 +524,7 @@ function makeWorklet(t, fun, fileName) {
|
|
|
518
524
|
return newFun;
|
|
519
525
|
}
|
|
520
526
|
|
|
521
|
-
function processWorkletFunction(t, fun,
|
|
527
|
+
function processWorkletFunction(t, fun, state) {
|
|
522
528
|
// Replaces FunctionDeclaration, FunctionExpression or ArrowFunctionExpression
|
|
523
529
|
// with a workletized version of itself.
|
|
524
530
|
|
|
@@ -526,7 +532,7 @@ function processWorkletFunction(t, fun, fileName) {
|
|
|
526
532
|
return;
|
|
527
533
|
}
|
|
528
534
|
|
|
529
|
-
const newFun = makeWorklet(t, fun,
|
|
535
|
+
const newFun = makeWorklet(t, fun, state);
|
|
530
536
|
|
|
531
537
|
const replacement = t.callExpression(newFun, []);
|
|
532
538
|
|
|
@@ -546,14 +552,14 @@ function processWorkletFunction(t, fun, fileName) {
|
|
|
546
552
|
);
|
|
547
553
|
}
|
|
548
554
|
|
|
549
|
-
function processWorkletObjectMethod(t, path,
|
|
555
|
+
function processWorkletObjectMethod(t, path, state) {
|
|
550
556
|
// Replaces ObjectMethod with a workletized version of itself.
|
|
551
557
|
|
|
552
558
|
if (!t.isFunctionParent(path)) {
|
|
553
559
|
return;
|
|
554
560
|
}
|
|
555
561
|
|
|
556
|
-
const newFun = makeWorklet(t, path,
|
|
562
|
+
const newFun = makeWorklet(t, path, state);
|
|
557
563
|
|
|
558
564
|
const replacement = t.objectProperty(
|
|
559
565
|
t.identifier(path.node.key.name),
|
|
@@ -563,7 +569,7 @@ function processWorkletObjectMethod(t, path, fileName) {
|
|
|
563
569
|
path.replaceWith(replacement);
|
|
564
570
|
}
|
|
565
571
|
|
|
566
|
-
function processIfWorkletNode(t, fun,
|
|
572
|
+
function processIfWorkletNode(t, fun, state) {
|
|
567
573
|
fun.traverse({
|
|
568
574
|
DirectiveLiteral(path) {
|
|
569
575
|
const value = path.node.value;
|
|
@@ -581,14 +587,14 @@ function processIfWorkletNode(t, fun, fileName) {
|
|
|
581
587
|
directive.value.value === 'worklet'
|
|
582
588
|
)
|
|
583
589
|
) {
|
|
584
|
-
processWorkletFunction(t, fun,
|
|
590
|
+
processWorkletFunction(t, fun, state);
|
|
585
591
|
}
|
|
586
592
|
}
|
|
587
593
|
},
|
|
588
594
|
});
|
|
589
595
|
}
|
|
590
596
|
|
|
591
|
-
function processIfGestureHandlerEventCallbackFunctionNode(t, fun,
|
|
597
|
+
function processIfGestureHandlerEventCallbackFunctionNode(t, fun, state) {
|
|
592
598
|
// Auto-workletizes React Native Gesture Handler callback functions.
|
|
593
599
|
// Detects `Gesture.Tap().onEnd(<fun>)` or similar, but skips `something.onEnd(<fun>)`.
|
|
594
600
|
// Supports method chaining as well, e.g. `Gesture.Tap().onStart(<fun1>).onUpdate(<fun2>).onEnd(<fun3>)`.
|
|
@@ -641,7 +647,7 @@ function processIfGestureHandlerEventCallbackFunctionNode(t, fun, fileName) {
|
|
|
641
647
|
t.isCallExpression(fun.parent) &&
|
|
642
648
|
isGestureObjectEventCallbackMethod(t, fun.parent.callee)
|
|
643
649
|
) {
|
|
644
|
-
processWorkletFunction(t, fun,
|
|
650
|
+
processWorkletFunction(t, fun, state);
|
|
645
651
|
}
|
|
646
652
|
}
|
|
647
653
|
|
|
@@ -697,7 +703,7 @@ function isGestureObject(t, node) {
|
|
|
697
703
|
);
|
|
698
704
|
}
|
|
699
705
|
|
|
700
|
-
function processWorklets(t, path,
|
|
706
|
+
function processWorklets(t, path, state) {
|
|
701
707
|
const name =
|
|
702
708
|
path.node.callee.type === 'MemberExpression'
|
|
703
709
|
? path.node.callee.property.name
|
|
@@ -709,17 +715,17 @@ function processWorklets(t, path, fileName) {
|
|
|
709
715
|
const properties = path.get('arguments.0.properties');
|
|
710
716
|
for (const property of properties) {
|
|
711
717
|
if (t.isObjectMethod(property)) {
|
|
712
|
-
processWorkletObjectMethod(t, property,
|
|
718
|
+
processWorkletObjectMethod(t, property, state);
|
|
713
719
|
} else {
|
|
714
720
|
const value = property.get('value');
|
|
715
|
-
processWorkletFunction(t, value,
|
|
721
|
+
processWorkletFunction(t, value, state);
|
|
716
722
|
}
|
|
717
723
|
}
|
|
718
724
|
} else {
|
|
719
725
|
const indexes = functionArgsToWorkletize.get(name);
|
|
720
726
|
if (Array.isArray(indexes)) {
|
|
721
727
|
indexes.forEach((index) => {
|
|
722
|
-
processWorkletFunction(t, path.get(`arguments.${index}`),
|
|
728
|
+
processWorkletFunction(t, path.get(`arguments.${index}`), state);
|
|
723
729
|
});
|
|
724
730
|
}
|
|
725
731
|
}
|
|
@@ -764,14 +770,13 @@ module.exports = function ({ types: t }) {
|
|
|
764
770
|
visitor: {
|
|
765
771
|
CallExpression: {
|
|
766
772
|
enter(path, state) {
|
|
767
|
-
processWorklets(t, path, state
|
|
773
|
+
processWorklets(t, path, state);
|
|
768
774
|
},
|
|
769
775
|
},
|
|
770
776
|
'FunctionDeclaration|FunctionExpression|ArrowFunctionExpression': {
|
|
771
777
|
enter(path, state) {
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
processIfGestureHandlerEventCallbackFunctionNode(t, path, fileName);
|
|
778
|
+
processIfWorkletNode(t, path, state);
|
|
779
|
+
processIfGestureHandlerEventCallbackFunctionNode(t, path, state);
|
|
775
780
|
},
|
|
776
781
|
},
|
|
777
782
|
},
|
|
@@ -498,10 +498,17 @@ declare module 'react-native-reanimated' {
|
|
|
498
498
|
interval: number;
|
|
499
499
|
};
|
|
500
500
|
|
|
501
|
+
export type AnimatedSensor = {
|
|
502
|
+
sensor: SensorValue3D | SensorValueRotation | null;
|
|
503
|
+
unregister: () => void;
|
|
504
|
+
isAvailable: boolean;
|
|
505
|
+
config: SensorConfig;
|
|
506
|
+
};
|
|
507
|
+
|
|
501
508
|
export function useAnimatedSensor(
|
|
502
509
|
sensorType: SensorType,
|
|
503
510
|
userConfig?: SensorConfig
|
|
504
|
-
);
|
|
511
|
+
): AnimatedSensor;
|
|
505
512
|
|
|
506
513
|
export interface ExitAnimationsValues {
|
|
507
514
|
currentOriginX: number;
|
|
@@ -614,14 +621,19 @@ declare module 'react-native-reanimated' {
|
|
|
614
621
|
callback?: AnimationCallback
|
|
615
622
|
): number;
|
|
616
623
|
export function cancelAnimation<T>(sharedValue: SharedValue<T>): void;
|
|
617
|
-
export function withDelay<T extends AnimatableValue>(
|
|
624
|
+
export function withDelay<T extends AnimatableValue>(
|
|
625
|
+
delayMS: number,
|
|
626
|
+
delayedAnimation: T
|
|
627
|
+
): T;
|
|
618
628
|
export function withRepeat<T extends AnimatableValue>(
|
|
619
629
|
animation: T,
|
|
620
630
|
numberOfReps?: number,
|
|
621
631
|
reverse?: boolean,
|
|
622
632
|
callback?: AnimationCallback
|
|
623
633
|
): T;
|
|
624
|
-
export function withSequence<T extends AnimatableValue>(
|
|
634
|
+
export function withSequence<T extends AnimatableValue>(
|
|
635
|
+
...animations: [T, ...T[]]
|
|
636
|
+
): T;
|
|
625
637
|
|
|
626
638
|
// reanimated2 functions
|
|
627
639
|
export function runOnUI<A extends any[], R>(
|
package/src/Animated.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { LogBox } from 'react-native';
|
|
2
1
|
import createAnimatedComponent from './createAnimatedComponent';
|
|
3
2
|
import {
|
|
4
3
|
addWhitelistedNativeProps,
|
|
@@ -21,11 +20,3 @@ const Animated = {
|
|
|
21
20
|
export * from './reanimated2';
|
|
22
21
|
export * from './reanimated1';
|
|
23
22
|
export default Animated;
|
|
24
|
-
|
|
25
|
-
// I think we can ignore this message as long as Gesture Handler doesn't
|
|
26
|
-
// try to load the Reanimated module. I figured it should be here instead of
|
|
27
|
-
// RNGH because this prevents the message from being displayed for all
|
|
28
|
-
// versions of RNGH.
|
|
29
|
-
LogBox.ignoreLogs([
|
|
30
|
-
'RCTBridge required dispatch_sync to load RNGestureHandlerModule. This may lead to deadlocks',
|
|
31
|
-
]);
|