react-native-reanimated 2.3.0-beta.1 → 2.3.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/NativeModules/NativeReanimatedModule.cpp +12 -3
- package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +13 -0
- package/Common/cpp/Registries/EventHandlerRegistry.cpp +2 -2
- package/Common/cpp/Registries/MapperRegistry.cpp +5 -5
- package/Common/cpp/SharedItems/FrozenObject.cpp +1 -3
- package/Common/cpp/SharedItems/ShareableValue.cpp +8 -10
- package/Common/cpp/Tools/FeaturesConfig.cpp +5 -0
- package/Common/cpp/Tools/JSIStoreValueUser.cpp +8 -8
- package/Common/cpp/Tools/Mapper.cpp +1 -1
- package/Common/cpp/Tools/RuntimeDecorator.cpp +40 -4
- package/Common/cpp/Tools/WorkletEventHandler.cpp +3 -1
- package/Common/cpp/headers/NativeModules/NativeReanimatedModule.h +5 -0
- package/Common/cpp/headers/NativeModules/NativeReanimatedModuleSpec.h +6 -1
- package/Common/cpp/headers/Registries/EventHandlerRegistry.h +1 -0
- package/Common/cpp/headers/Registries/MapperRegistry.h +1 -0
- package/Common/cpp/headers/SharedItems/FrozenObject.h +4 -0
- package/Common/cpp/headers/SharedItems/HostFunctionHandler.h +2 -0
- package/Common/cpp/headers/SharedItems/MutableValue.h +2 -0
- package/Common/cpp/headers/SharedItems/MutableValueSetterProxy.h +3 -1
- package/Common/cpp/headers/SharedItems/RemoteObject.h +4 -1
- package/Common/cpp/headers/SharedItems/ShareableValue.h +2 -0
- package/Common/cpp/headers/SharedItems/SharedParent.h +9 -9
- package/Common/cpp/headers/SharedItems/ValueWrapper.h +32 -28
- package/Common/cpp/headers/SpecTools/ErrorHandler.h +1 -0
- package/Common/cpp/headers/Tools/FeaturesConfig.h +19 -0
- package/Common/cpp/headers/Tools/JSIStoreValueUser.h +2 -5
- package/Common/cpp/headers/Tools/Mapper.h +2 -0
- package/Common/cpp/headers/Tools/PlatformDepMethodsHolder.h +5 -0
- package/Common/cpp/headers/Tools/ReanimatedHiddenHeaders.h +1 -5
- package/Common/cpp/headers/Tools/RuntimeDecorator.h +10 -7
- package/Common/cpp/headers/Tools/Scheduler.h +2 -0
- package/Common/cpp/headers/Tools/WorkletEventHandler.h +2 -1
- package/Common/cpp/hidden_headers/Logger.h +2 -2
- package/Common/cpp/hidden_headers/LoggerInterface.h +1 -1
- package/RNReanimated.podspec +24 -6
- package/android/build.gradle +33 -13
- package/android/expo/linking.gradle +34 -0
- package/android/expo/src/main/java/com/swmansion/reanimated/EXReanimatedAdapter.java +12 -0
- package/android/expo/src/main/java/expo/modules/adapters/reanimated/EXReanimatedPackage.java +26 -0
- package/android/react-native-reanimated-63-hermes.aar +0 -0
- package/android/react-native-reanimated-63-jsc.aar +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/expo-module.config.json +3 -0
- package/ios/LayoutReanimation/REAAnimationsManager.m +65 -19
- package/ios/LayoutReanimation/REAUIManager.mm +114 -70
- package/ios/REAEventDispatcher.m +1 -1
- package/ios/REAModule.h +0 -2
- package/ios/REAModule.m +0 -3
- package/ios/REANodesManager.m +1 -0
- package/ios/RNGestureHandlerStateManager.h +5 -0
- package/ios/native/NativeMethods.h +5 -0
- package/ios/native/NativeMethods.mm +14 -6
- package/ios/native/NativeProxy.h +1 -0
- package/ios/native/NativeProxy.mm +84 -63
- package/ios/native/REAIOSErrorHandler.mm +19 -15
- package/ios/native/REAIOSLogger.mm +10 -6
- package/ios/native/REAIOSScheduler.mm +17 -10
- package/ios/native/REAInitializer.mm +42 -31
- package/ios/native/UIResponder+Reanimated.mm +2 -2
- package/lib/Animated.js +11 -5
- package/lib/ConfigHelper.js +121 -138
- package/lib/ReanimatedEventEmitter.js +0 -1
- package/lib/ReanimatedModule.js +0 -1
- package/lib/ReanimatedModule.macos.js +0 -1
- package/lib/ReanimatedModule.native.js +5 -6
- package/lib/ReanimatedModule.windows.js +0 -1
- package/lib/ReanimatedModuleCompat.js +64 -35
- package/lib/createAnimatedComponent.js +469 -499
- package/lib/index.js +11 -5
- package/lib/reanimated1/core/Core.test.js +1 -1
- package/lib/reanimated2/NativeMethods.js +7 -0
- package/lib/reanimated2/NativeReanimated/NativeReanimated.js +3 -0
- package/lib/reanimated2/PropAdapters.js +0 -1
- package/lib/reanimated2/UpdateProps.js +1 -1
- package/lib/reanimated2/ViewDescriptorsSet.js +4 -2
- package/lib/reanimated2/animation/spring.js +2 -0
- package/lib/reanimated2/animation/styleAnimation.js +5 -1
- package/lib/reanimated2/animation/util.js +23 -0
- package/lib/reanimated2/component/FlatList.js +30 -0
- package/lib/reanimated2/component/WrappedComponents.js +9 -0
- package/lib/reanimated2/component/index.js +4 -0
- package/lib/reanimated2/core.js +30 -3
- package/lib/reanimated2/globals.d.ts +8 -0
- package/lib/reanimated2/index.js +1 -0
- package/lib/reanimated2/js-reanimated/JSReanimated.js +4 -0
- package/lib/reanimated2/js-reanimated/Mapper.js +4 -3
- package/lib/reanimated2/js-reanimated/MapperRegistry.js +3 -6
- package/lib/reanimated2/js-reanimated/MutableValue.js +0 -2
- package/lib/reanimated2/js-reanimated/index.js +10 -8
- package/lib/reanimated2/layoutReanimation/LayoutAnimationRepository.js +14 -5
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Default.js +14 -14
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Flip.js +8 -8
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +4 -2
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Rotate.js +16 -16
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Slide.js +16 -16
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +4 -4
- package/lib/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js +20 -8
- package/lib/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js +3 -3
- package/lib/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js +8 -8
- package/lib/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js +10 -10
- package/lib/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js +8 -8
- package/lib/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js +8 -8
- package/lib/reanimated2/mock.js +3 -1
- package/lib/reanimated2/utils.js +9 -0
- package/lib/setAndForwardRef.js +14 -48
- package/mock.js +1 -1
- package/package.json +27 -23
- package/plugin.js +111 -110
- package/react-native-reanimated.d.ts +63 -25
- package/src/Animated.js +11 -5
- package/src/{ConfigHelper.js → ConfigHelper.ts} +15 -7
- package/src/{ReanimatedEventEmitter.js → ReanimatedEventEmitter.ts} +0 -0
- package/src/{ReanimatedModule.js → ReanimatedModule.macos.ts} +0 -0
- package/src/{ReanimatedModule.native.js → ReanimatedModule.native.ts} +0 -0
- package/src/{ReanimatedModule.macos.js → ReanimatedModule.ts} +0 -0
- package/src/{ReanimatedModule.windows.js → ReanimatedModule.windows.ts} +0 -0
- package/src/ReanimatedModuleCompat.ts +51 -0
- package/src/{createAnimatedComponent.js → createAnimatedComponent.tsx} +278 -124
- package/src/reanimated1/core/Core.test.js +1 -1
- package/src/reanimated2/NativeMethods.ts +13 -1
- package/src/reanimated2/NativeReanimated/NativeReanimated.ts +5 -11
- package/src/reanimated2/PropAdapters.ts +0 -1
- package/src/reanimated2/UpdateProps.ts +1 -1
- package/src/reanimated2/ViewDescriptorsSet.ts +6 -2
- package/src/reanimated2/animation/commonTypes.ts +4 -4
- package/src/reanimated2/animation/decay.ts +2 -2
- package/src/reanimated2/animation/delay.ts +3 -3
- package/src/reanimated2/animation/index.ts +7 -7
- package/src/reanimated2/animation/repeat.ts +4 -4
- package/src/reanimated2/animation/sequence.ts +2 -2
- package/src/reanimated2/animation/spring.ts +6 -5
- package/src/reanimated2/animation/styleAnimation.ts +24 -12
- package/src/reanimated2/animation/timing.ts +5 -5
- package/src/reanimated2/animation/util.ts +45 -6
- package/src/reanimated2/component/FlatList.tsx +44 -0
- package/src/reanimated2/component/WrappedComponents.ts +11 -0
- package/src/reanimated2/component/index.ts +9 -0
- package/src/reanimated2/core.ts +58 -14
- package/src/reanimated2/globals.d.ts +8 -0
- package/src/reanimated2/hook/useAnimatedStyle.ts +2 -2
- package/src/reanimated2/index.ts +1 -0
- package/src/reanimated2/js-reanimated/JSReanimated.ts +15 -26
- package/src/reanimated2/js-reanimated/Mapper.ts +22 -9
- package/src/reanimated2/js-reanimated/MapperRegistry.ts +22 -19
- package/src/reanimated2/js-reanimated/MutableValue.ts +11 -11
- package/src/reanimated2/js-reanimated/index.ts +31 -14
- package/src/reanimated2/layoutReanimation/{LayoutAnimationRepository.tsx → LayoutAnimationRepository.ts} +18 -5
- package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +39 -20
- package/src/reanimated2/layoutReanimation/animationBuilder/index.ts +5 -1
- package/src/reanimated2/layoutReanimation/defaultAnimations/Default.ts +21 -15
- package/src/reanimated2/layoutReanimation/defaultAnimations/Flip.ts +29 -24
- package/src/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.ts +10 -2
- package/src/reanimated2/layoutReanimation/defaultAnimations/Rotate.ts +61 -34
- package/src/reanimated2/layoutReanimation/defaultAnimations/Slide.ts +49 -34
- package/src/reanimated2/layoutReanimation/defaultAnimations/Zoom.ts +17 -12
- package/src/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.ts +20 -8
- package/src/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.ts +9 -9
- package/src/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.ts +8 -8
- package/src/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.ts +20 -14
- package/src/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.ts +14 -8
- package/src/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.ts +24 -12
- package/src/reanimated2/mock.ts +3 -1
- package/src/reanimated2/utils.ts +21 -0
- package/src/{setAndForwardRef.js → setAndForwardRef.ts} +12 -2
- package/android/react-native-reanimated-62-hermes.aar +0 -0
- package/android/react-native-reanimated-62-jsc.aar +0 -0
- package/src/ReanimatedModuleCompat.js +0 -37
package/plugin.js
CHANGED
|
@@ -69,6 +69,7 @@ const globals = new Set([
|
|
|
69
69
|
'global',
|
|
70
70
|
'_measure',
|
|
71
71
|
'_scrollTo',
|
|
72
|
+
'_setGestureState',
|
|
72
73
|
'_getCurrentTime',
|
|
73
74
|
'_eventTimestamp',
|
|
74
75
|
'_frameTimestamp',
|
|
@@ -145,61 +146,22 @@ const gestureHandlerGestureObjects = new Set([
|
|
|
145
146
|
'LongPress',
|
|
146
147
|
'ForceTouch',
|
|
147
148
|
'Native',
|
|
149
|
+
'Manual',
|
|
148
150
|
'Race',
|
|
149
151
|
'Simultaneous',
|
|
150
152
|
'Exclusive',
|
|
151
153
|
]);
|
|
152
154
|
|
|
153
155
|
const gestureHandlerBuilderMethods = new Set([
|
|
154
|
-
|
|
155
|
-
'withRef',
|
|
156
|
-
'onBegan',
|
|
156
|
+
'onBegin',
|
|
157
157
|
'onStart',
|
|
158
158
|
'onEnd',
|
|
159
|
-
'
|
|
160
|
-
'shouldCancelWhenOutside',
|
|
161
|
-
'hitSlop',
|
|
162
|
-
'simultaneousWithExternalGesture',
|
|
163
|
-
'requireExternalGestureToFail',
|
|
164
|
-
|
|
165
|
-
// ContinousBaseGesture
|
|
159
|
+
'onFinalize',
|
|
166
160
|
'onUpdate',
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
'
|
|
170
|
-
'
|
|
171
|
-
'maxDistance',
|
|
172
|
-
'maxDuration',
|
|
173
|
-
'maxDelay',
|
|
174
|
-
'maxDeltaX',
|
|
175
|
-
'maxDeltaY',
|
|
176
|
-
|
|
177
|
-
// PanGesture
|
|
178
|
-
'activeOffsetY',
|
|
179
|
-
'activeOffsetX',
|
|
180
|
-
'failOffsetY',
|
|
181
|
-
'failOffsetX',
|
|
182
|
-
'minPointers',
|
|
183
|
-
'minDistance',
|
|
184
|
-
'averageTouches',
|
|
185
|
-
'enableTrackpadTwoFingerGesture',
|
|
186
|
-
|
|
187
|
-
// FlingGesture
|
|
188
|
-
'numberOfPointers',
|
|
189
|
-
'direction',
|
|
190
|
-
|
|
191
|
-
// LongPress
|
|
192
|
-
'minDuration',
|
|
193
|
-
'maxDistance',
|
|
194
|
-
|
|
195
|
-
// ForceTouchGesture:
|
|
196
|
-
'minForce',
|
|
197
|
-
'maxForce',
|
|
198
|
-
'feedbackOnActivation',
|
|
199
|
-
|
|
200
|
-
// NativeGesture
|
|
201
|
-
'shouldActivateOnStart',
|
|
202
|
-
'disallowInterruption',
|
|
161
|
+
'onTouchesDown',
|
|
162
|
+
'onTouchesMove',
|
|
163
|
+
'onTouchesUp',
|
|
164
|
+
'onTouchesCancelled',
|
|
203
165
|
]);
|
|
204
166
|
|
|
205
167
|
class ClosureGenerator {
|
|
@@ -352,20 +314,45 @@ function buildWorkletString(t, fun, closureVariables, name) {
|
|
|
352
314
|
return generate(workletFunction, { compact: true }).code;
|
|
353
315
|
}
|
|
354
316
|
|
|
355
|
-
function
|
|
356
|
-
if (
|
|
357
|
-
return;
|
|
317
|
+
function makeWorkletName(t, fun) {
|
|
318
|
+
if (t.isObjectMethod(fun)) {
|
|
319
|
+
return fun.node.key.name;
|
|
358
320
|
}
|
|
359
|
-
|
|
321
|
+
if (t.isFunctionDeclaration(fun)) {
|
|
322
|
+
return fun.node.id.name;
|
|
323
|
+
}
|
|
324
|
+
if (t.isFunctionExpression(fun) && t.isIdentifier(fun.node.id)) {
|
|
325
|
+
return fun.node.id.name;
|
|
326
|
+
}
|
|
327
|
+
return '_f'; // fallback for ArrowFunctionExpression and unnamed FunctionExpression
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
function makeWorklet(t, fun, fileName) {
|
|
331
|
+
// Returns a new FunctionExpression which is a workletized version of provided
|
|
332
|
+
// FunctionDeclaration, FunctionExpression, ArrowFunctionExpression or ObjectMethod.
|
|
333
|
+
|
|
334
|
+
const functionName = makeWorkletName(t, fun);
|
|
360
335
|
|
|
361
336
|
const closure = new Map();
|
|
362
337
|
const outputs = new Set();
|
|
363
338
|
const closureGenerator = new ClosureGenerator();
|
|
364
339
|
const options = {};
|
|
365
340
|
|
|
341
|
+
// remove 'worklet'; directive before calling .toString()
|
|
342
|
+
fun.traverse({
|
|
343
|
+
DirectiveLiteral(path) {
|
|
344
|
+
if (path.node.value === 'worklet' && path.getFunctionParent() === fun) {
|
|
345
|
+
path.parentPath.remove();
|
|
346
|
+
}
|
|
347
|
+
},
|
|
348
|
+
});
|
|
349
|
+
|
|
366
350
|
// We use copy because some of the plugins don't update bindings and
|
|
367
351
|
// some even break them
|
|
368
|
-
|
|
352
|
+
|
|
353
|
+
const code =
|
|
354
|
+
'\n(' + (t.isObjectMethod(fun) ? 'function ' : '') + fun.toString() + '\n)';
|
|
355
|
+
|
|
369
356
|
const transformed = transformSync(code, {
|
|
370
357
|
filename: fileName,
|
|
371
358
|
presets: ['@babel/preset-typescript'],
|
|
@@ -424,7 +411,7 @@ function processWorkletFunction(t, fun, fileName) {
|
|
|
424
411
|
closureGenerator.addPath(name, path);
|
|
425
412
|
},
|
|
426
413
|
AssignmentExpression(path) {
|
|
427
|
-
// test for <
|
|
414
|
+
// test for <something>.value = <something> expressions
|
|
428
415
|
const left = path.node.left;
|
|
429
416
|
if (
|
|
430
417
|
t.isMemberExpression(left) &&
|
|
@@ -436,13 +423,6 @@ function processWorkletFunction(t, fun, fileName) {
|
|
|
436
423
|
},
|
|
437
424
|
});
|
|
438
425
|
|
|
439
|
-
fun.traverse({
|
|
440
|
-
DirectiveLiteral(path) {
|
|
441
|
-
if (path.node.value === 'worklet' && path.getFunctionParent() === fun) {
|
|
442
|
-
path.parentPath.remove();
|
|
443
|
-
}
|
|
444
|
-
},
|
|
445
|
-
});
|
|
446
426
|
const variables = Array.from(closure.values());
|
|
447
427
|
|
|
448
428
|
const privateFunctionId = t.identifier('_f');
|
|
@@ -458,7 +438,7 @@ function processWorkletFunction(t, fun, fileName) {
|
|
|
458
438
|
transformed.ast,
|
|
459
439
|
variables,
|
|
460
440
|
functionName
|
|
461
|
-
)
|
|
441
|
+
);
|
|
462
442
|
const workletHash = hash(funString);
|
|
463
443
|
|
|
464
444
|
const loc = fun && fun.node && fun.node.loc && fun.node.loc.start;
|
|
@@ -469,7 +449,7 @@ function processWorkletFunction(t, fun, fileName) {
|
|
|
469
449
|
}
|
|
470
450
|
}
|
|
471
451
|
|
|
472
|
-
const
|
|
452
|
+
const statements = [
|
|
473
453
|
t.variableDeclaration('const', [
|
|
474
454
|
t.variableDeclarator(privateFunctionId, funExpression),
|
|
475
455
|
]),
|
|
@@ -512,7 +492,7 @@ function processWorkletFunction(t, fun, fileName) {
|
|
|
512
492
|
];
|
|
513
493
|
|
|
514
494
|
if (options && options.optFlags) {
|
|
515
|
-
|
|
495
|
+
statements.push(
|
|
516
496
|
t.expressionStatement(
|
|
517
497
|
t.assignmentExpression(
|
|
518
498
|
'=',
|
|
@@ -527,7 +507,7 @@ function processWorkletFunction(t, fun, fileName) {
|
|
|
527
507
|
);
|
|
528
508
|
}
|
|
529
509
|
|
|
530
|
-
|
|
510
|
+
statements.push(
|
|
531
511
|
t.expressionStatement(
|
|
532
512
|
t.callExpression(
|
|
533
513
|
t.memberExpression(
|
|
@@ -539,20 +519,30 @@ function processWorkletFunction(t, fun, fileName) {
|
|
|
539
519
|
)
|
|
540
520
|
)
|
|
541
521
|
);
|
|
542
|
-
|
|
522
|
+
statements.push(t.returnStatement(privateFunctionId));
|
|
543
523
|
|
|
544
|
-
const newFun = t.functionExpression(
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
524
|
+
const newFun = t.functionExpression(fun.id, [], t.blockStatement(statements));
|
|
525
|
+
|
|
526
|
+
return newFun;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
function processWorkletFunction(t, fun, fileName) {
|
|
530
|
+
// Replaces FunctionDeclaration, FunctionExpression or ArrowFunctionExpression
|
|
531
|
+
// with a workletized version of itself.
|
|
532
|
+
|
|
533
|
+
if (!t.isFunctionParent(fun)) {
|
|
534
|
+
return;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
const newFun = makeWorklet(t, fun, fileName);
|
|
549
538
|
|
|
550
539
|
const replacement = t.callExpression(newFun, []);
|
|
540
|
+
|
|
551
541
|
// we check if function needs to be assigned to variable declaration.
|
|
552
542
|
// This is needed if function definition directly in a scope. Some other ways
|
|
553
543
|
// where function definition can be used is for example with variable declaration:
|
|
554
544
|
// const ggg = function foo() { }
|
|
555
|
-
// ^ in such a case we don't need to
|
|
545
|
+
// ^ in such a case we don't need to define variable for the function
|
|
556
546
|
const needDeclaration =
|
|
557
547
|
t.isScopable(fun.parent) || t.isExportNamedDeclaration(fun.parent);
|
|
558
548
|
fun.replaceWith(
|
|
@@ -564,6 +554,23 @@ function processWorkletFunction(t, fun, fileName) {
|
|
|
564
554
|
);
|
|
565
555
|
}
|
|
566
556
|
|
|
557
|
+
function processWorkletObjectMethod(t, path, fileName) {
|
|
558
|
+
// Replaces ObjectMethod with a workletized version of itself.
|
|
559
|
+
|
|
560
|
+
if (!t.isFunctionParent(path)) {
|
|
561
|
+
return;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
const newFun = makeWorklet(t, path, fileName);
|
|
565
|
+
|
|
566
|
+
const replacement = t.objectProperty(
|
|
567
|
+
t.identifier(path.node.key.name),
|
|
568
|
+
t.callExpression(newFun, [])
|
|
569
|
+
);
|
|
570
|
+
|
|
571
|
+
path.replaceWith(replacement);
|
|
572
|
+
}
|
|
573
|
+
|
|
567
574
|
function processIfWorkletNode(t, fun, fileName) {
|
|
568
575
|
fun.traverse({
|
|
569
576
|
DirectiveLiteral(path) {
|
|
@@ -648,36 +655,33 @@ function processIfGestureHandlerEventCallbackFunctionNode(t, fun, fileName) {
|
|
|
648
655
|
|
|
649
656
|
function isGestureObjectEventCallbackMethod(t, node) {
|
|
650
657
|
// Checks if node matches the pattern `Gesture.Foo()[*].onBar`
|
|
651
|
-
// where `[*]` represents any number of
|
|
652
|
-
|
|
653
|
-
node: MemberExpression(
|
|
654
|
-
object: CallExpression(
|
|
655
|
-
callee: MemberExpression(
|
|
656
|
-
object: Identifier('Gesture')
|
|
657
|
-
property: Identifier('Tap')
|
|
658
|
-
)
|
|
659
|
-
)
|
|
660
|
-
property: Identifier('onEnd')
|
|
661
|
-
)
|
|
662
|
-
*/
|
|
663
|
-
if (
|
|
658
|
+
// where `[*]` represents any number of method calls.
|
|
659
|
+
return (
|
|
664
660
|
t.isMemberExpression(node) &&
|
|
665
661
|
t.isIdentifier(node.property) &&
|
|
666
|
-
gestureHandlerBuilderMethods.has(node.property.name)
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
return true;
|
|
671
|
-
}
|
|
662
|
+
gestureHandlerBuilderMethods.has(node.property.name) &&
|
|
663
|
+
containsGestureObject(t, node.object)
|
|
664
|
+
);
|
|
665
|
+
}
|
|
672
666
|
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
667
|
+
function containsGestureObject(t, node) {
|
|
668
|
+
// Checks if node matches the pattern `Gesture.Foo()[*]`
|
|
669
|
+
// where `[*]` represents any number of chained method calls, like `.something(42)`.
|
|
670
|
+
|
|
671
|
+
// direct call
|
|
672
|
+
if (isGestureObject(t, node)) {
|
|
673
|
+
return true;
|
|
680
674
|
}
|
|
675
|
+
|
|
676
|
+
// method chaining
|
|
677
|
+
if (
|
|
678
|
+
t.isCallExpression(node) &&
|
|
679
|
+
t.isMemberExpression(node.callee) &&
|
|
680
|
+
containsGestureObject(t, node.callee.object)
|
|
681
|
+
) {
|
|
682
|
+
return true;
|
|
683
|
+
}
|
|
684
|
+
|
|
681
685
|
return false;
|
|
682
686
|
}
|
|
683
687
|
|
|
@@ -710,17 +714,14 @@ function processWorklets(t, path, fileName) {
|
|
|
710
714
|
objectHooks.has(name) &&
|
|
711
715
|
path.get('arguments.0').type === 'ObjectExpression'
|
|
712
716
|
) {
|
|
713
|
-
const
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
objectPath.getSibling(i).get('value'),
|
|
722
|
-
fileName
|
|
723
|
-
);
|
|
717
|
+
const properties = path.get('arguments.0.properties');
|
|
718
|
+
for (const property of properties) {
|
|
719
|
+
if (t.isObjectMethod(property)) {
|
|
720
|
+
processWorkletObjectMethod(t, property, fileName);
|
|
721
|
+
} else {
|
|
722
|
+
const value = property.get('value');
|
|
723
|
+
processWorkletFunction(t, value, fileName);
|
|
724
|
+
}
|
|
724
725
|
}
|
|
725
726
|
} else {
|
|
726
727
|
const indexes = functionArgsToWorkletize.get(name);
|
|
@@ -737,7 +738,7 @@ const STATEMENTLESS_FLAG = 0b00000010;
|
|
|
737
738
|
|
|
738
739
|
function isPossibleOptimization(fun) {
|
|
739
740
|
let isFunctionCall = false;
|
|
740
|
-
let
|
|
741
|
+
let isStatement = false;
|
|
741
742
|
traverse(fun, {
|
|
742
743
|
CallExpression(path) {
|
|
743
744
|
if (!possibleOptFunction.has(path.node.callee.name)) {
|
|
@@ -745,14 +746,14 @@ function isPossibleOptimization(fun) {
|
|
|
745
746
|
}
|
|
746
747
|
},
|
|
747
748
|
IfStatement() {
|
|
748
|
-
|
|
749
|
+
isStatement = true;
|
|
749
750
|
},
|
|
750
751
|
});
|
|
751
752
|
let flags = 0;
|
|
752
753
|
if (!isFunctionCall) {
|
|
753
754
|
flags = flags | FUNCTIONLESS_FLAG;
|
|
754
755
|
}
|
|
755
|
-
if (!
|
|
756
|
+
if (!isStatement) {
|
|
756
757
|
flags = flags | STATEMENTLESS_FLAG;
|
|
757
758
|
}
|
|
758
759
|
return flags;
|
|
@@ -26,6 +26,7 @@ declare module 'react-native-reanimated' {
|
|
|
26
26
|
Text as ReactNativeText,
|
|
27
27
|
Image as ReactNativeImage,
|
|
28
28
|
ScrollView as ReactNativeScrollView,
|
|
29
|
+
FlatList as ReactNativeFlatList,
|
|
29
30
|
NativeScrollEvent,
|
|
30
31
|
NativeSyntheticEvent,
|
|
31
32
|
ColorValue,
|
|
@@ -36,6 +37,18 @@ declare module 'react-native-reanimated' {
|
|
|
36
37
|
GestureHandlerGestureEvent,
|
|
37
38
|
PanGestureHandlerGestureEvent,
|
|
38
39
|
} from 'react-native-gesture-handler';
|
|
40
|
+
|
|
41
|
+
export {
|
|
42
|
+
Animation,
|
|
43
|
+
TimingAnimation,
|
|
44
|
+
SpringAnimation,
|
|
45
|
+
DecayAnimation,
|
|
46
|
+
DelayAnimation,
|
|
47
|
+
RepeatAnimation,
|
|
48
|
+
SequenceAnimation,
|
|
49
|
+
StyleLayoutAnimation,
|
|
50
|
+
} from './src/reanimated2/animation/index';
|
|
51
|
+
|
|
39
52
|
namespace Animated {
|
|
40
53
|
type Nullable<T> = T | null | undefined;
|
|
41
54
|
class AnimatedNode<T> {
|
|
@@ -244,6 +257,10 @@ declare module 'react-native-reanimated' {
|
|
|
244
257
|
getNode(): ReactNativeScrollView;
|
|
245
258
|
}
|
|
246
259
|
export class Code extends Component<CodeProps> {}
|
|
260
|
+
export class FlatList extends Component<AnimateProps<FlatList>> {
|
|
261
|
+
itemLayoutAnimation: ILayoutAnimationBuilder;
|
|
262
|
+
getNode(): ReactNativeFlatList;
|
|
263
|
+
}
|
|
247
264
|
|
|
248
265
|
type Options<P> = {
|
|
249
266
|
setNativeProps: (ref: any, props: P) => void;
|
|
@@ -439,34 +456,45 @@ declare module 'react-native-reanimated' {
|
|
|
439
456
|
animations: AnimateStyle;
|
|
440
457
|
};
|
|
441
458
|
|
|
442
|
-
export
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
}
|
|
459
|
+
export interface EntryAnimationsValues {
|
|
460
|
+
targetOriginX: number;
|
|
461
|
+
targetOriginY: number;
|
|
462
|
+
targetWidth: number;
|
|
463
|
+
targetHeight: number;
|
|
464
|
+
targetGlobalOriginX: number;
|
|
465
|
+
targetGlobalOriginY: number;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
export interface ExitAnimationsValues {
|
|
469
|
+
currentOriginX: number;
|
|
470
|
+
currentOriginY: number;
|
|
471
|
+
currentWidth: number;
|
|
472
|
+
currentHeight: number;
|
|
473
|
+
currentGlobalOriginX: number;
|
|
474
|
+
currentGlobalOriginY: number;
|
|
475
|
+
}
|
|
476
|
+
|
|
450
477
|
export type EntryExitAnimationFunction = (
|
|
451
|
-
targetValues:
|
|
478
|
+
targetValues: EntryAnimationsValues | ExitAnimationsValues
|
|
452
479
|
) => LayoutAnimation;
|
|
453
480
|
|
|
454
481
|
export type LayoutAnimationsValues = {
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
482
|
+
currentOriginX: number;
|
|
483
|
+
currentOriginY: number;
|
|
484
|
+
currentWidth: number;
|
|
485
|
+
currentHeight: number;
|
|
486
|
+
currentGlobalOriginX: number;
|
|
487
|
+
currentGlobalOriginY: number;
|
|
488
|
+
targetOriginX: number;
|
|
489
|
+
targetOriginY: number;
|
|
490
|
+
targetWidth: number;
|
|
491
|
+
targetHeight: number;
|
|
492
|
+
targetGlobalOriginX: number;
|
|
493
|
+
targetGlobalOriginY: number;
|
|
467
494
|
windowWidth: number;
|
|
468
495
|
windowHeight: number;
|
|
469
496
|
};
|
|
497
|
+
|
|
470
498
|
export type LayoutAnimationFunction = (
|
|
471
499
|
targetValues: LayoutAnimationsValues
|
|
472
500
|
) => LayoutAnimation;
|
|
@@ -479,7 +507,7 @@ declare module 'react-native-reanimated' {
|
|
|
479
507
|
build: () => EntryExitAnimationFunction;
|
|
480
508
|
}
|
|
481
509
|
|
|
482
|
-
export type
|
|
510
|
+
export type AnimatableValue = number | string | Array<number>;
|
|
483
511
|
|
|
484
512
|
// reanimated2 derived operations
|
|
485
513
|
export enum Extrapolation {
|
|
@@ -511,7 +539,7 @@ declare module 'react-native-reanimated' {
|
|
|
511
539
|
// reanimated2 animations
|
|
512
540
|
export type AnimationCallback = (
|
|
513
541
|
finished?: boolean,
|
|
514
|
-
current?:
|
|
542
|
+
current?: AnimatableValue
|
|
515
543
|
) => void;
|
|
516
544
|
export interface WithTimingConfig {
|
|
517
545
|
duration?: number;
|
|
@@ -533,12 +561,12 @@ declare module 'react-native-reanimated' {
|
|
|
533
561
|
velocity?: number;
|
|
534
562
|
}
|
|
535
563
|
export function withTiming(
|
|
536
|
-
toValue:
|
|
564
|
+
toValue: AnimatableValue,
|
|
537
565
|
userConfig?: WithTimingConfig,
|
|
538
566
|
callback?: AnimationCallback
|
|
539
567
|
): number;
|
|
540
568
|
export function withSpring(
|
|
541
|
-
toValue:
|
|
569
|
+
toValue: AnimatableValue,
|
|
542
570
|
userConfig?: WithSpringConfig,
|
|
543
571
|
callback?: AnimationCallback
|
|
544
572
|
): number;
|
|
@@ -649,6 +677,15 @@ declare module 'react-native-reanimated' {
|
|
|
649
677
|
pageY: number;
|
|
650
678
|
};
|
|
651
679
|
|
|
680
|
+
export function getRelativeCoords(
|
|
681
|
+
ref: RefObject<Component>,
|
|
682
|
+
x: number,
|
|
683
|
+
y: number
|
|
684
|
+
): {
|
|
685
|
+
x: number;
|
|
686
|
+
y: number;
|
|
687
|
+
};
|
|
688
|
+
|
|
652
689
|
export function scrollTo(
|
|
653
690
|
ref: RefObject<ReactNativeScrollView | ScrollView>,
|
|
654
691
|
x: number,
|
|
@@ -1050,4 +1087,5 @@ declare module 'react-native-reanimated' {
|
|
|
1050
1087
|
export const SpringUtils: typeof Animated.SpringUtils;
|
|
1051
1088
|
export const useValue: typeof Animated.useValue;
|
|
1052
1089
|
export const ReverseAnimation: typeof Animated.ReverseAnimation;
|
|
1090
|
+
export function enableLayoutAnimations(flag: boolean): void;
|
|
1053
1091
|
}
|
package/src/Animated.js
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LogBox } from 'react-native';
|
|
2
2
|
import createAnimatedComponent from './createAnimatedComponent';
|
|
3
3
|
import {
|
|
4
4
|
addWhitelistedNativeProps,
|
|
5
5
|
addWhitelistedUIProps,
|
|
6
6
|
} from './ConfigHelper';
|
|
7
7
|
import * as reanimated1 from './reanimated1';
|
|
8
|
+
import ReanimatedComponents from './reanimated2/component';
|
|
8
9
|
|
|
9
10
|
const Animated = {
|
|
10
11
|
// components
|
|
11
|
-
|
|
12
|
-
Text: createAnimatedComponent(Text),
|
|
13
|
-
Image: createAnimatedComponent(Image),
|
|
14
|
-
ScrollView: createAnimatedComponent(ScrollView),
|
|
12
|
+
...ReanimatedComponents,
|
|
15
13
|
createAnimatedComponent,
|
|
16
14
|
// configuration
|
|
17
15
|
addWhitelistedNativeProps,
|
|
@@ -23,3 +21,11 @@ const Animated = {
|
|
|
23
21
|
export * from './reanimated2';
|
|
24
22
|
export * from './reanimated1';
|
|
25
23
|
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
|
+
]);
|
|
@@ -3,7 +3,7 @@ import ReanimatedModule from './ReanimatedModule';
|
|
|
3
3
|
/**
|
|
4
4
|
* Styles allowed to be direcly updated in UI thread
|
|
5
5
|
*/
|
|
6
|
-
let UI_THREAD_PROPS_WHITELIST = {
|
|
6
|
+
let UI_THREAD_PROPS_WHITELIST: Record<string, boolean> = {
|
|
7
7
|
opacity: true,
|
|
8
8
|
transform: true,
|
|
9
9
|
/* colors */
|
|
@@ -28,7 +28,7 @@ let UI_THREAD_PROPS_WHITELIST = {
|
|
|
28
28
|
/**
|
|
29
29
|
* Whitelist of view props that can be updated in native thread via UIManagerModule
|
|
30
30
|
*/
|
|
31
|
-
let NATIVE_THREAD_PROPS_WHITELIST = {
|
|
31
|
+
let NATIVE_THREAD_PROPS_WHITELIST: Record<string, boolean> = {
|
|
32
32
|
borderBottomWidth: true,
|
|
33
33
|
borderEndWidth: true,
|
|
34
34
|
borderLeftWidth: true,
|
|
@@ -106,14 +106,16 @@ let NATIVE_THREAD_PROPS_WHITELIST = {
|
|
|
106
106
|
placeholderTextColor: true,
|
|
107
107
|
};
|
|
108
108
|
|
|
109
|
-
function configureProps() {
|
|
109
|
+
function configureProps(): void {
|
|
110
110
|
ReanimatedModule.configureProps(
|
|
111
111
|
Object.keys(NATIVE_THREAD_PROPS_WHITELIST),
|
|
112
112
|
Object.keys(UI_THREAD_PROPS_WHITELIST)
|
|
113
113
|
);
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
export function addWhitelistedNativeProps(
|
|
116
|
+
export function addWhitelistedNativeProps(
|
|
117
|
+
props: Record<string, boolean>
|
|
118
|
+
): void {
|
|
117
119
|
const oldSize = Object.keys(NATIVE_THREAD_PROPS_WHITELIST).length;
|
|
118
120
|
NATIVE_THREAD_PROPS_WHITELIST = {
|
|
119
121
|
...NATIVE_THREAD_PROPS_WHITELIST,
|
|
@@ -124,7 +126,7 @@ export function addWhitelistedNativeProps(props) {
|
|
|
124
126
|
}
|
|
125
127
|
}
|
|
126
128
|
|
|
127
|
-
export function addWhitelistedUIProps(props) {
|
|
129
|
+
export function addWhitelistedUIProps(props: Record<string, boolean>): void {
|
|
128
130
|
const oldSize = Object.keys(UI_THREAD_PROPS_WHITELIST).length;
|
|
129
131
|
UI_THREAD_PROPS_WHITELIST = { ...UI_THREAD_PROPS_WHITELIST, ...props };
|
|
130
132
|
if (oldSize !== Object.keys(UI_THREAD_PROPS_WHITELIST).length) {
|
|
@@ -133,17 +135,23 @@ export function addWhitelistedUIProps(props) {
|
|
|
133
135
|
}
|
|
134
136
|
|
|
135
137
|
const PROCESSED_VIEW_NAMES = new Set();
|
|
138
|
+
|
|
139
|
+
interface ViewConfig {
|
|
140
|
+
uiViewClassName: string;
|
|
141
|
+
validAttributes: Record<string, unknown>;
|
|
142
|
+
}
|
|
136
143
|
/**
|
|
137
144
|
* updates UI props whitelist for given view host instance
|
|
138
145
|
* this will work just once for every view name
|
|
139
146
|
*/
|
|
140
|
-
|
|
147
|
+
|
|
148
|
+
export function adaptViewConfig(viewConfig: ViewConfig): void {
|
|
141
149
|
const viewName = viewConfig.uiViewClassName;
|
|
142
150
|
const props = viewConfig.validAttributes;
|
|
143
151
|
|
|
144
152
|
// update whitelist of UI props for this view name only once
|
|
145
153
|
if (!PROCESSED_VIEW_NAMES.has(viewName)) {
|
|
146
|
-
const propsToAdd = {};
|
|
154
|
+
const propsToAdd: Record<string, boolean> = {};
|
|
147
155
|
Object.keys(props).forEach((key) => {
|
|
148
156
|
// we don't want to add native props as they affect layout
|
|
149
157
|
// we also skip props which repeat here
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
async disconnectNodeFromView(): Promise<void> {
|
|
3
|
+
// noop
|
|
4
|
+
},
|
|
5
|
+
async attachEvent(
|
|
6
|
+
_viewTag: number,
|
|
7
|
+
_eventName: string,
|
|
8
|
+
_nodeID: number
|
|
9
|
+
): Promise<void> {
|
|
10
|
+
// noop
|
|
11
|
+
},
|
|
12
|
+
async detachEvent(
|
|
13
|
+
_viewTag: number,
|
|
14
|
+
_eventName: string,
|
|
15
|
+
_nodeID: number
|
|
16
|
+
): Promise<void> {
|
|
17
|
+
// noop
|
|
18
|
+
},
|
|
19
|
+
async createNode(
|
|
20
|
+
_nodeID: number,
|
|
21
|
+
_config: Record<string, unknown>
|
|
22
|
+
): Promise<void> {
|
|
23
|
+
// noop
|
|
24
|
+
},
|
|
25
|
+
async dropNode(_nodeID: number): Promise<void> {
|
|
26
|
+
// noop
|
|
27
|
+
},
|
|
28
|
+
async configureProps(
|
|
29
|
+
_nativeProps: string[],
|
|
30
|
+
_uiProps: string[]
|
|
31
|
+
): Promise<void> {
|
|
32
|
+
// noop
|
|
33
|
+
},
|
|
34
|
+
async disconnectNodes(): Promise<void> {
|
|
35
|
+
// noop
|
|
36
|
+
},
|
|
37
|
+
async addListener(): Promise<void> {
|
|
38
|
+
// noop
|
|
39
|
+
},
|
|
40
|
+
async removeListeners(): Promise<void> {
|
|
41
|
+
// noop
|
|
42
|
+
},
|
|
43
|
+
async removeAllListeners(): Promise<void> {
|
|
44
|
+
// noop
|
|
45
|
+
},
|
|
46
|
+
async animateNextTransition(): Promise<void> {
|
|
47
|
+
console.warn(
|
|
48
|
+
'Reanimated: animateNextTransition is unimplemented on current platform'
|
|
49
|
+
);
|
|
50
|
+
},
|
|
51
|
+
};
|