react-native-reanimated 2.6.0 → 2.9.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/SharedItems/ShareableValue.cpp +2 -2
- package/Common/cpp/Tools/RuntimeDecorator.cpp +17 -25
- 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 +19 -8
- package/android/build.gradle +22 -8
- 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/react-native-reanimated-69-hermes.aar +0 -0
- package/android/react-native-reanimated-69-jsc.aar +0 -0
- package/android/rnVersionPatch/69/.gitkeep +0 -0
- package/android/src/main/cpp/NativeProxy.cpp +35 -14
- package/android/src/main/cpp/headers/NativeProxy.h +2 -0
- package/android/src/main/java/com/swmansion/reanimated/NativeProxy.java +11 -8
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/AnimationsManager.java +13 -6
- 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/LayoutReanimation/REAAnimationsManager.h +1 -1
- package/ios/LayoutReanimation/REAAnimationsManager.m +2 -2
- package/ios/LayoutReanimation/REASnapshot.m +1 -1
- package/ios/LayoutReanimation/REAUIManager.h +1 -1
- package/ios/LayoutReanimation/REAUIManager.mm +4 -5
- package/ios/Nodes/REAAlwaysNode.h +1 -1
- package/ios/Nodes/REAAlwaysNode.m +5 -5
- package/ios/Nodes/REABezierNode.h +1 -1
- package/ios/Nodes/REABezierNode.m +4 -5
- package/ios/Nodes/REABlockNode.h +1 -1
- package/ios/Nodes/REABlockNode.m +2 -2
- package/ios/Nodes/REACallFuncNode.h +1 -1
- package/ios/Nodes/REACallFuncNode.m +5 -5
- package/ios/Nodes/REAClockNodes.h +1 -1
- package/ios/Nodes/REAClockNodes.m +4 -4
- package/ios/Nodes/REAConcatNode.h +1 -1
- package/ios/Nodes/REAConcatNode.m +3 -3
- package/ios/Nodes/REACondNode.h +1 -1
- package/ios/Nodes/REACondNode.m +3 -3
- package/ios/Nodes/READebugNode.h +1 -1
- package/ios/Nodes/READebugNode.m +3 -3
- package/ios/Nodes/REAEventNode.h +1 -2
- package/ios/Nodes/REAEventNode.m +3 -3
- package/ios/Nodes/REAFunctionNode.h +1 -1
- package/ios/Nodes/REAFunctionNode.m +3 -3
- package/ios/Nodes/REAJSCallNode.h +1 -1
- package/ios/Nodes/REAJSCallNode.m +3 -3
- package/ios/Nodes/REANode.m +2 -2
- package/ios/Nodes/REAOperatorNode.h +1 -1
- package/ios/Nodes/REAOperatorNode.m +2 -3
- package/ios/Nodes/REAParamNode.h +1 -1
- package/ios/Nodes/REAParamNode.m +4 -4
- package/ios/Nodes/REAPropsNode.h +1 -1
- package/ios/Nodes/REAPropsNode.m +4 -6
- package/ios/Nodes/REASetNode.h +1 -1
- package/ios/Nodes/REASetNode.m +4 -4
- package/ios/Nodes/REAStyleNode.h +1 -1
- package/ios/Nodes/REAStyleNode.m +2 -3
- package/ios/Nodes/REATransformNode.h +1 -1
- package/ios/Nodes/REATransformNode.m +2 -2
- package/ios/Nodes/REAValueNode.h +1 -3
- package/ios/Nodes/REAValueNode.m +1 -1
- package/ios/REAEventDispatcher.m +1 -1
- package/ios/REAModule.h +1 -1
- package/ios/REAModule.m +4 -5
- package/ios/REANodesManager.h +1 -2
- package/ios/REANodesManager.m +21 -23
- package/ios/Transitioning/RCTConvert+REATransition.h +1 -2
- package/ios/Transitioning/RCTConvert+REATransition.m +1 -1
- package/ios/Transitioning/REAAllTransitions.h +1 -1
- package/ios/Transitioning/REAAllTransitions.m +2 -3
- package/ios/Transitioning/REATransition.h +2 -3
- package/ios/Transitioning/REATransition.m +3 -4
- package/ios/Transitioning/REATransitionAnimation.m +1 -2
- package/ios/Transitioning/REATransitionManager.m +2 -4
- package/ios/Transitioning/REATransitionValues.m +2 -3
- package/ios/native/NativeMethods.h +1 -3
- package/ios/native/NativeMethods.mm +1 -1
- package/ios/native/NativeProxy.h +2 -2
- package/ios/native/NativeProxy.mm +20 -17
- package/ios/native/REAIOSErrorHandler.h +2 -4
- package/ios/native/REAIOSErrorHandler.mm +1 -1
- package/ios/native/REAIOSLogger.h +1 -3
- package/ios/native/REAIOSLogger.mm +1 -1
- package/ios/native/REAIOSScheduler.h +1 -3
- package/ios/native/REAIOSScheduler.mm +2 -2
- package/ios/native/REAInitializer.h +0 -7
- package/ios/native/REAInitializer.mm +13 -3
- package/ios/native/UIResponder+Reanimated.mm +3 -3
- package/ios/sensor/ReanimatedSensor.h +1 -1
- package/ios/sensor/ReanimatedSensor.m +3 -3
- package/ios/sensor/ReanimatedSensorContainer.h +1 -1
- package/ios/sensor/ReanimatedSensorContainer.m +2 -2
- package/lib/Animated.js +8 -30
- package/lib/ConfigHelper.js +0 -1
- package/lib/index.js +5 -30
- package/lib/reanimated2/Easing.js +9 -3
- package/lib/reanimated2/NativeReanimated/NativeReanimated.js +1 -1
- package/lib/reanimated2/animation/sequence.js +0 -3
- package/lib/reanimated2/component/FlatList.js +3 -3
- 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 +0 -41
- package/lib/reanimated2/globals.d.ts +1 -2
- package/lib/reanimated2/hook/utils.js +0 -5
- package/lib/reanimated2/js-reanimated/global.js +25 -0
- package/lib/reanimated2/js-reanimated/index.js +0 -24
- package/lib/reanimated2/mock.js +6 -0
- package/lib/types/lib/Animated.d.ts +8 -0
- package/lib/types/lib/index.d.ts +4 -0
- package/lib/types/lib/reanimated2/commonTypes.d.ts +0 -1
- package/lib/types/lib/reanimated2/component/Image.d.ts +3 -0
- package/lib/types/lib/reanimated2/component/ScrollView.d.ts +3 -0
- package/lib/types/lib/reanimated2/component/Text.d.ts +3 -0
- package/lib/types/lib/reanimated2/component/View.d.ts +3 -0
- package/lib/types/lib/reanimated2/hook/useAnimatedSensor.d.ts +1 -3
- package/lib/types/lib/reanimated2/js-reanimated/global.d.ts +1 -0
- package/lib/types/lib/reanimated2/mock.d.ts +6 -0
- package/package.json +18 -14
- package/plugin.js +36 -33
- package/react-native-reanimated.d.ts +16 -7
- package/src/Animated.ts +13 -0
- package/src/ConfigHelper.ts +0 -1
- package/src/index.ts +7 -0
- package/src/reanimated2/Easing.ts +9 -3
- package/src/reanimated2/NativeReanimated/NativeReanimated.ts +1 -1
- package/src/reanimated2/animation/sequence.ts +0 -5
- package/src/reanimated2/commonTypes.ts +0 -1
- package/src/reanimated2/component/FlatList.tsx +3 -6
- 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 +0 -52
- package/src/reanimated2/globals.d.ts +1 -2
- package/src/reanimated2/hook/useAnimatedSensor.ts +1 -3
- package/src/reanimated2/hook/utils.ts +0 -6
- package/src/reanimated2/js-reanimated/global.ts +33 -0
- package/src/reanimated2/js-reanimated/index.ts +0 -31
- 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/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/src/Animated.js +0 -31
- package/src/reanimated2/component/WrappedComponents.ts +0 -11
- package/src/reanimated2/component/index.ts +0 -9
package/plugin.js
CHANGED
|
@@ -14,7 +14,6 @@ const functionArgsToWorkletize = new Map([
|
|
|
14
14
|
['useAnimatedScrollHandler', [0]],
|
|
15
15
|
['useAnimatedReaction', [0, 1]],
|
|
16
16
|
['useWorkletCallback', [0]],
|
|
17
|
-
['createWorklet', [0]],
|
|
18
17
|
// animations' callbacks
|
|
19
18
|
['withTiming', [2]],
|
|
20
19
|
['withSpring', [2]],
|
|
@@ -331,7 +330,7 @@ function makeWorkletName(t, fun) {
|
|
|
331
330
|
return '_f'; // fallback for ArrowFunctionExpression and unnamed FunctionExpression
|
|
332
331
|
}
|
|
333
332
|
|
|
334
|
-
function makeWorklet(t, fun,
|
|
333
|
+
function makeWorklet(t, fun, state) {
|
|
335
334
|
// Returns a new FunctionExpression which is a workletized version of provided
|
|
336
335
|
// FunctionDeclaration, FunctionExpression, ArrowFunctionExpression or ObjectMethod.
|
|
337
336
|
|
|
@@ -358,7 +357,7 @@ function makeWorklet(t, fun, fileName) {
|
|
|
358
357
|
'\n(' + (t.isObjectMethod(fun) ? 'function ' : '') + fun.toString() + '\n)';
|
|
359
358
|
|
|
360
359
|
const transformed = transformSync(code, {
|
|
361
|
-
filename:
|
|
360
|
+
filename: state.file.opts.filename,
|
|
362
361
|
presets: ['@babel/preset-typescript'],
|
|
363
362
|
plugins: [
|
|
364
363
|
'@babel/plugin-transform-shorthand-properties',
|
|
@@ -445,11 +444,17 @@ function makeWorklet(t, fun, fileName) {
|
|
|
445
444
|
);
|
|
446
445
|
const workletHash = hash(funString);
|
|
447
446
|
|
|
447
|
+
let location = state.file.opts.filename;
|
|
448
|
+
if (state.opts.relativeSourceLocation) {
|
|
449
|
+
const path = require('path');
|
|
450
|
+
location = path.relative(state.cwd, location);
|
|
451
|
+
}
|
|
452
|
+
|
|
448
453
|
const loc = fun && fun.node && fun.node.loc && fun.node.loc.start;
|
|
449
454
|
if (loc) {
|
|
450
455
|
const { line, column } = loc;
|
|
451
456
|
if (typeof line === 'number' && typeof column === 'number') {
|
|
452
|
-
|
|
457
|
+
location = `${location} (${line}:${column})`;
|
|
453
458
|
}
|
|
454
459
|
}
|
|
455
460
|
|
|
@@ -490,7 +495,7 @@ function makeWorklet(t, fun, fileName) {
|
|
|
490
495
|
t.identifier('__location'),
|
|
491
496
|
false
|
|
492
497
|
),
|
|
493
|
-
t.stringLiteral(
|
|
498
|
+
t.stringLiteral(location)
|
|
494
499
|
)
|
|
495
500
|
),
|
|
496
501
|
];
|
|
@@ -511,18 +516,6 @@ function makeWorklet(t, fun, fileName) {
|
|
|
511
516
|
);
|
|
512
517
|
}
|
|
513
518
|
|
|
514
|
-
statements.push(
|
|
515
|
-
t.expressionStatement(
|
|
516
|
-
t.callExpression(
|
|
517
|
-
t.memberExpression(
|
|
518
|
-
t.identifier('global'),
|
|
519
|
-
t.identifier('__reanimatedWorkletInit'),
|
|
520
|
-
false
|
|
521
|
-
),
|
|
522
|
-
[privateFunctionId]
|
|
523
|
-
)
|
|
524
|
-
)
|
|
525
|
-
);
|
|
526
519
|
statements.push(t.returnStatement(privateFunctionId));
|
|
527
520
|
|
|
528
521
|
const newFun = t.functionExpression(fun.id, [], t.blockStatement(statements));
|
|
@@ -530,7 +523,7 @@ function makeWorklet(t, fun, fileName) {
|
|
|
530
523
|
return newFun;
|
|
531
524
|
}
|
|
532
525
|
|
|
533
|
-
function processWorkletFunction(t, fun,
|
|
526
|
+
function processWorkletFunction(t, fun, state) {
|
|
534
527
|
// Replaces FunctionDeclaration, FunctionExpression or ArrowFunctionExpression
|
|
535
528
|
// with a workletized version of itself.
|
|
536
529
|
|
|
@@ -538,7 +531,7 @@ function processWorkletFunction(t, fun, fileName) {
|
|
|
538
531
|
return;
|
|
539
532
|
}
|
|
540
533
|
|
|
541
|
-
const newFun = makeWorklet(t, fun,
|
|
534
|
+
const newFun = makeWorklet(t, fun, state);
|
|
542
535
|
|
|
543
536
|
const replacement = t.callExpression(newFun, []);
|
|
544
537
|
|
|
@@ -558,14 +551,14 @@ function processWorkletFunction(t, fun, fileName) {
|
|
|
558
551
|
);
|
|
559
552
|
}
|
|
560
553
|
|
|
561
|
-
function processWorkletObjectMethod(t, path,
|
|
554
|
+
function processWorkletObjectMethod(t, path, state) {
|
|
562
555
|
// Replaces ObjectMethod with a workletized version of itself.
|
|
563
556
|
|
|
564
557
|
if (!t.isFunctionParent(path)) {
|
|
565
558
|
return;
|
|
566
559
|
}
|
|
567
560
|
|
|
568
|
-
const newFun = makeWorklet(t, path,
|
|
561
|
+
const newFun = makeWorklet(t, path, state);
|
|
569
562
|
|
|
570
563
|
const replacement = t.objectProperty(
|
|
571
564
|
t.identifier(path.node.key.name),
|
|
@@ -575,7 +568,7 @@ function processWorkletObjectMethod(t, path, fileName) {
|
|
|
575
568
|
path.replaceWith(replacement);
|
|
576
569
|
}
|
|
577
570
|
|
|
578
|
-
function processIfWorkletNode(t, fun,
|
|
571
|
+
function processIfWorkletNode(t, fun, state) {
|
|
579
572
|
fun.traverse({
|
|
580
573
|
DirectiveLiteral(path) {
|
|
581
574
|
const value = path.node.value;
|
|
@@ -593,14 +586,14 @@ function processIfWorkletNode(t, fun, fileName) {
|
|
|
593
586
|
directive.value.value === 'worklet'
|
|
594
587
|
)
|
|
595
588
|
) {
|
|
596
|
-
processWorkletFunction(t, fun,
|
|
589
|
+
processWorkletFunction(t, fun, state);
|
|
597
590
|
}
|
|
598
591
|
}
|
|
599
592
|
},
|
|
600
593
|
});
|
|
601
594
|
}
|
|
602
595
|
|
|
603
|
-
function processIfGestureHandlerEventCallbackFunctionNode(t, fun,
|
|
596
|
+
function processIfGestureHandlerEventCallbackFunctionNode(t, fun, state) {
|
|
604
597
|
// Auto-workletizes React Native Gesture Handler callback functions.
|
|
605
598
|
// Detects `Gesture.Tap().onEnd(<fun>)` or similar, but skips `something.onEnd(<fun>)`.
|
|
606
599
|
// Supports method chaining as well, e.g. `Gesture.Tap().onStart(<fun1>).onUpdate(<fun2>).onEnd(<fun3>)`.
|
|
@@ -653,7 +646,7 @@ function processIfGestureHandlerEventCallbackFunctionNode(t, fun, fileName) {
|
|
|
653
646
|
t.isCallExpression(fun.parent) &&
|
|
654
647
|
isGestureObjectEventCallbackMethod(t, fun.parent.callee)
|
|
655
648
|
) {
|
|
656
|
-
processWorkletFunction(t, fun,
|
|
649
|
+
processWorkletFunction(t, fun, state);
|
|
657
650
|
}
|
|
658
651
|
}
|
|
659
652
|
|
|
@@ -709,7 +702,7 @@ function isGestureObject(t, node) {
|
|
|
709
702
|
);
|
|
710
703
|
}
|
|
711
704
|
|
|
712
|
-
function processWorklets(t, path,
|
|
705
|
+
function processWorklets(t, path, state) {
|
|
713
706
|
const name =
|
|
714
707
|
path.node.callee.type === 'MemberExpression'
|
|
715
708
|
? path.node.callee.property.name
|
|
@@ -721,17 +714,17 @@ function processWorklets(t, path, fileName) {
|
|
|
721
714
|
const properties = path.get('arguments.0.properties');
|
|
722
715
|
for (const property of properties) {
|
|
723
716
|
if (t.isObjectMethod(property)) {
|
|
724
|
-
processWorkletObjectMethod(t, property,
|
|
717
|
+
processWorkletObjectMethod(t, property, state);
|
|
725
718
|
} else {
|
|
726
719
|
const value = property.get('value');
|
|
727
|
-
processWorkletFunction(t, value,
|
|
720
|
+
processWorkletFunction(t, value, state);
|
|
728
721
|
}
|
|
729
722
|
}
|
|
730
723
|
} else {
|
|
731
724
|
const indexes = functionArgsToWorkletize.get(name);
|
|
732
725
|
if (Array.isArray(indexes)) {
|
|
733
726
|
indexes.forEach((index) => {
|
|
734
|
-
processWorkletFunction(t, path.get(`arguments.${index}`),
|
|
727
|
+
processWorkletFunction(t, path.get(`arguments.${index}`), state);
|
|
735
728
|
});
|
|
736
729
|
}
|
|
737
730
|
}
|
|
@@ -763,6 +756,16 @@ function isPossibleOptimization(fun) {
|
|
|
763
756
|
return flags;
|
|
764
757
|
}
|
|
765
758
|
|
|
759
|
+
const pluginProposalExportNamespaceFrom =
|
|
760
|
+
require('@babel/plugin-proposal-export-namespace-from').default;
|
|
761
|
+
const apiMock = {
|
|
762
|
+
assertVersion: () => {
|
|
763
|
+
// do nothing.
|
|
764
|
+
},
|
|
765
|
+
};
|
|
766
|
+
const ExportNamedDeclarationFn =
|
|
767
|
+
pluginProposalExportNamespaceFrom(apiMock).visitor.ExportNamedDeclaration;
|
|
768
|
+
|
|
766
769
|
module.exports = function ({ types: t }) {
|
|
767
770
|
return {
|
|
768
771
|
pre() {
|
|
@@ -776,16 +779,16 @@ module.exports = function ({ types: t }) {
|
|
|
776
779
|
visitor: {
|
|
777
780
|
CallExpression: {
|
|
778
781
|
enter(path, state) {
|
|
779
|
-
processWorklets(t, path, state
|
|
782
|
+
processWorklets(t, path, state);
|
|
780
783
|
},
|
|
781
784
|
},
|
|
782
785
|
'FunctionDeclaration|FunctionExpression|ArrowFunctionExpression': {
|
|
783
786
|
enter(path, state) {
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
processIfGestureHandlerEventCallbackFunctionNode(t, path, fileName);
|
|
787
|
+
processIfWorkletNode(t, path, state);
|
|
788
|
+
processIfGestureHandlerEventCallbackFunctionNode(t, path, state);
|
|
787
789
|
},
|
|
788
790
|
},
|
|
791
|
+
ExportNamedDeclaration: ExportNamedDeclarationFn,
|
|
789
792
|
},
|
|
790
793
|
};
|
|
791
794
|
};
|
|
@@ -156,7 +156,7 @@ declare module 'react-native-reanimated' {
|
|
|
156
156
|
: Record<string, unknown>;
|
|
157
157
|
|
|
158
158
|
export type AnimateProps<P extends object> = {
|
|
159
|
-
[K in keyof P]: P[K] | AnimatedNode<P[K]>;
|
|
159
|
+
[K in keyof Omit<P, 'style'>]: P[K] | AnimatedNode<P[K]>;
|
|
160
160
|
} & {
|
|
161
161
|
style?: StyleProp<AnimateStyle<StylesOrDefault<P>>>;
|
|
162
162
|
} & {
|
|
@@ -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>(
|
|
@@ -638,9 +650,6 @@ declare module 'react-native-reanimated' {
|
|
|
638
650
|
): PropsAdapterFunction;
|
|
639
651
|
|
|
640
652
|
export function processColor(color: number | string): number;
|
|
641
|
-
export function createWorklet<A extends any[], R>(
|
|
642
|
-
fn: (...args: A) => R
|
|
643
|
-
): (...args: Parameters<typeof fn>) => R;
|
|
644
653
|
|
|
645
654
|
export function interpolateColor<T extends string | number>(
|
|
646
655
|
value: number,
|
package/src/Animated.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { default as createAnimatedComponent } from './createAnimatedComponent';
|
|
2
|
+
export {
|
|
3
|
+
addWhitelistedNativeProps,
|
|
4
|
+
addWhitelistedUIProps,
|
|
5
|
+
} from './ConfigHelper';
|
|
6
|
+
|
|
7
|
+
export { default as Text } from './reanimated2/component/Text';
|
|
8
|
+
export { default as View } from './reanimated2/component/View';
|
|
9
|
+
export { default as ScrollView } from './reanimated2/component/ScrollView';
|
|
10
|
+
export { default as Image } from './reanimated2/component/Image';
|
|
11
|
+
export { default as FlatList } from './reanimated2/component/FlatList';
|
|
12
|
+
// @ts-ignore backward compatibility with treeshaking
|
|
13
|
+
export * from './reanimated1';
|
package/src/ConfigHelper.ts
CHANGED
package/src/index.ts
ADDED
|
@@ -109,7 +109,10 @@ function cubic(t: number): number {
|
|
|
109
109
|
*/
|
|
110
110
|
function poly(n: number): EasingFn {
|
|
111
111
|
'worklet';
|
|
112
|
-
return (t) =>
|
|
112
|
+
return (t) => {
|
|
113
|
+
'worklet';
|
|
114
|
+
return Math.pow(t, n);
|
|
115
|
+
};
|
|
113
116
|
}
|
|
114
117
|
|
|
115
118
|
/**
|
|
@@ -171,7 +174,10 @@ function elastic(bounciness = 1): EasingFn {
|
|
|
171
174
|
*/
|
|
172
175
|
function back(s = 1.70158): (t: number) => number {
|
|
173
176
|
'worklet';
|
|
174
|
-
return (t) =>
|
|
177
|
+
return (t) => {
|
|
178
|
+
'worklet';
|
|
179
|
+
return t * t * ((s + 1) * t - s);
|
|
180
|
+
};
|
|
175
181
|
}
|
|
176
182
|
|
|
177
183
|
/**
|
|
@@ -312,7 +318,7 @@ function createChecker(
|
|
|
312
318
|
}
|
|
313
319
|
// @ts-ignore this is implicitly any - TODO
|
|
314
320
|
const res = worklet.apply(this, arguments);
|
|
315
|
-
if (!_WORKLET && res && typeof res === 'function' && res.
|
|
321
|
+
if (!_WORKLET && res && typeof res === 'function' && res.__workletHash) {
|
|
316
322
|
return createChecker(res, workletName, arguments);
|
|
317
323
|
}
|
|
318
324
|
return res;
|
|
@@ -11,7 +11,7 @@ export class NativeReanimated {
|
|
|
11
11
|
private InnerNativeModule: any;
|
|
12
12
|
|
|
13
13
|
constructor(native = true) {
|
|
14
|
-
if (global.__reanimatedModuleProxy === undefined) {
|
|
14
|
+
if (global.__reanimatedModuleProxy === undefined && native) {
|
|
15
15
|
const { ReanimatedModule } = NativeModules;
|
|
16
16
|
ReanimatedModule?.installTurboModule();
|
|
17
17
|
}
|
|
@@ -63,11 +63,6 @@ export function withSequence(
|
|
|
63
63
|
now: Timestamp,
|
|
64
64
|
previousAnimation: SequenceAnimation
|
|
65
65
|
): void {
|
|
66
|
-
if (animations.length === 1) {
|
|
67
|
-
throw Error(
|
|
68
|
-
'withSequence() animation require more than one animation as argument'
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
66
|
animation.animationIndex = 0;
|
|
72
67
|
if (previousAnimation === undefined) {
|
|
73
68
|
previousAnimation = animations[
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { FlatList, FlatListProps, LayoutChangeEvent } from 'react-native';
|
|
3
|
-
import
|
|
3
|
+
import ReanimatedView from './View';
|
|
4
4
|
import createAnimatedComponent from '../../createAnimatedComponent';
|
|
5
5
|
import { ILayoutAnimationBuilder } from '../layoutReanimation/animationBuilder/commonTypes';
|
|
6
6
|
|
|
@@ -11,12 +11,9 @@ const createCellRenderer = (itemLayoutAnimation?: ILayoutAnimationBuilder) => {
|
|
|
11
11
|
onLayout: (event: LayoutChangeEvent) => void;
|
|
12
12
|
}> = (props) => {
|
|
13
13
|
return (
|
|
14
|
-
<
|
|
15
|
-
layout={itemLayoutAnimation}
|
|
16
|
-
onLayout={props.onLayout}
|
|
17
|
-
>
|
|
14
|
+
<ReanimatedView layout={itemLayoutAnimation} onLayout={props.onLayout}>
|
|
18
15
|
{props.children}
|
|
19
|
-
</
|
|
16
|
+
</ReanimatedView>
|
|
20
17
|
);
|
|
21
18
|
};
|
|
22
19
|
|
package/src/reanimated2/core.ts
CHANGED
|
@@ -4,7 +4,6 @@ import { Platform } from 'react-native';
|
|
|
4
4
|
import { nativeShouldBeMock, shouldBeUseWeb, isWeb } from './PlatformChecker';
|
|
5
5
|
import {
|
|
6
6
|
BasicWorkletFunction,
|
|
7
|
-
WorkletFunction,
|
|
8
7
|
ComplexWorkletFunction,
|
|
9
8
|
SharedValue,
|
|
10
9
|
AnimationObject,
|
|
@@ -14,10 +13,6 @@ import {
|
|
|
14
13
|
import { Descriptor } from './hook/commonTypes';
|
|
15
14
|
import JSReanimated from './js-reanimated/JSReanimated';
|
|
16
15
|
|
|
17
|
-
global.__reanimatedWorkletInit = function (worklet: WorkletFunction) {
|
|
18
|
-
worklet.__worklet = true;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
16
|
if (global._setGlobalConsole === undefined) {
|
|
22
17
|
// it can happen when Reanimated plugin wasn't added, but the user uses the only API from version 1
|
|
23
18
|
global._setGlobalConsole = () => {
|
|
@@ -74,48 +69,6 @@ export const isConfiguredCheck: () => void = () => {
|
|
|
74
69
|
}
|
|
75
70
|
};
|
|
76
71
|
|
|
77
|
-
function _toArrayReanimated<T>(object: Iterable<T> | ArrayLike<T> | T[]): T[] {
|
|
78
|
-
'worklet';
|
|
79
|
-
if (Array.isArray(object)) {
|
|
80
|
-
return object;
|
|
81
|
-
}
|
|
82
|
-
if (
|
|
83
|
-
typeof Symbol !== 'undefined' &&
|
|
84
|
-
(typeof Symbol === 'function' ? Symbol.iterator : '@@iterator') in
|
|
85
|
-
Object(object)
|
|
86
|
-
) {
|
|
87
|
-
return Array.from(object);
|
|
88
|
-
}
|
|
89
|
-
throw new Error(
|
|
90
|
-
'Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.'
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
function _mergeObjectsReanimated(): unknown {
|
|
95
|
-
'worklet';
|
|
96
|
-
// we can't use rest parameters in worklets at the moment
|
|
97
|
-
// eslint-disable-next-line prefer-rest-params
|
|
98
|
-
const arr = Array.from(arguments);
|
|
99
|
-
return Object.assign.apply(null, [arr[0], ...arr.slice(1)]);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
global.__reanimatedWorkletInit = function (worklet: WorkletFunction) {
|
|
103
|
-
worklet.__worklet = true;
|
|
104
|
-
|
|
105
|
-
if (worklet._closure) {
|
|
106
|
-
const closure = worklet._closure;
|
|
107
|
-
Object.keys(closure).forEach((key) => {
|
|
108
|
-
if (key === '_toConsumableArray') {
|
|
109
|
-
closure[key] = _toArrayReanimated;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if (key === '_objectSpread') {
|
|
113
|
-
closure[key] = _mergeObjectsReanimated;
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
|
|
119
72
|
function pushFrame(frame: (timestamp: Timestamp) => void): void {
|
|
120
73
|
(NativeReanimatedModule as JSReanimated).pushFrame(frame);
|
|
121
74
|
}
|
|
@@ -380,11 +333,6 @@ if (!isWeb() && isConfigured()) {
|
|
|
380
333
|
info: runOnJS(capturableConsole.info),
|
|
381
334
|
};
|
|
382
335
|
_setGlobalConsole(console);
|
|
383
|
-
if (global.performance == null) {
|
|
384
|
-
global.performance = {
|
|
385
|
-
now: global._chronoNow,
|
|
386
|
-
} as any; // due to conflict with lib.dom.d.ts -> Performance
|
|
387
|
-
}
|
|
388
336
|
})();
|
|
389
337
|
}
|
|
390
338
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnimatedStyle, StyleProps
|
|
1
|
+
import { AnimatedStyle, StyleProps } from './commonTypes';
|
|
2
2
|
import { ReanimatedConsole } from './core';
|
|
3
3
|
import { MeasuredDimensions } from './NativeMethods';
|
|
4
4
|
import { NativeReanimated } from './NativeReanimated/NativeReanimated';
|
|
@@ -32,7 +32,6 @@ declare global {
|
|
|
32
32
|
};
|
|
33
33
|
namespace NodeJS {
|
|
34
34
|
interface Global {
|
|
35
|
-
__reanimatedWorkletInit: (worklet: WorkletFunction) => void;
|
|
36
35
|
_setGlobalConsole: (console?: ReanimatedConsole) => void;
|
|
37
36
|
_log: (s: string) => void;
|
|
38
37
|
_setGestureState: () => void;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// In order to keep bundle size down, we treat this file as a polyfill for Web.
|
|
2
|
+
|
|
3
|
+
import { shouldBeUseWeb } from '../PlatformChecker';
|
|
4
|
+
|
|
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
|
+
}
|
|
@@ -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 }
|
package/src/reanimated2/mock.ts
CHANGED
|
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;
|