react-native-reanimated 3.0.0-rc.8 → 3.0.0-rc.9
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 +17 -12
- package/Common/cpp/NativeModules/NativeReanimatedModule.h +2 -2
- package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.h +2 -2
- package/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.cpp +30 -0
- package/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.h +1 -1
- package/Common/cpp/SharedItems/Shareables.cpp +3 -1
- package/Common/cpp/SharedItems/Shareables.h +37 -22
- package/Common/cpp/Tools/RuntimeDecorator.cpp +26 -25
- package/Common/cpp/Tools/RuntimeDecorator.h +2 -1
- package/ios/LayoutReanimation/REAAnimationsManager.h +3 -1
- package/ios/LayoutReanimation/REAAnimationsManager.m +49 -16
- package/ios/LayoutReanimation/REAUIManager.mm +22 -62
- package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js +2 -2
- package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
- package/lib/commonjs/reanimated2/component/FlatList.js +19 -3
- package/lib/commonjs/reanimated2/component/FlatList.js.map +1 -1
- package/lib/commonjs/reanimated2/core.js +6 -74
- package/lib/commonjs/reanimated2/core.js.map +1 -1
- package/lib/commonjs/reanimated2/errors.js +66 -0
- package/lib/commonjs/reanimated2/errors.js.map +1 -0
- package/lib/commonjs/reanimated2/globals.d.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js +0 -10
- package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js.map +1 -1
- package/lib/commonjs/reanimated2/initializers.js +157 -0
- package/lib/commonjs/reanimated2/initializers.js.map +1 -0
- package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js +1 -6
- package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/global.js +4 -7
- package/lib/commonjs/reanimated2/js-reanimated/global.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js +0 -4
- package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
- package/lib/commonjs/reanimated2/mock.js +26 -0
- package/lib/commonjs/reanimated2/mock.js.map +1 -1
- package/lib/commonjs/reanimated2/shareables.js +6 -0
- package/lib/commonjs/reanimated2/shareables.js.map +1 -1
- package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js +2 -2
- package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
- package/lib/module/reanimated2/component/FlatList.js +18 -4
- package/lib/module/reanimated2/component/FlatList.js.map +1 -1
- package/lib/module/reanimated2/core.js +3 -74
- package/lib/module/reanimated2/core.js.map +1 -1
- package/lib/module/reanimated2/errors.js +58 -0
- package/lib/module/reanimated2/errors.js.map +1 -0
- package/lib/module/reanimated2/globals.d.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedStyle.js +2 -12
- package/lib/module/reanimated2/hook/useAnimatedStyle.js.map +1 -1
- package/lib/module/reanimated2/initializers.js +143 -0
- package/lib/module/reanimated2/initializers.js.map +1 -0
- package/lib/module/reanimated2/js-reanimated/JSReanimated.js +1 -6
- package/lib/module/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/global.js +4 -7
- package/lib/module/reanimated2/js-reanimated/global.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationsManager.js +0 -2
- package/lib/module/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
- package/lib/module/reanimated2/mock.js +26 -0
- package/lib/module/reanimated2/mock.js.map +1 -1
- package/lib/module/reanimated2/shareables.js +6 -1
- package/lib/module/reanimated2/shareables.js.map +1 -1
- package/package.json +3 -2
- package/plugin.js +81 -15
- package/src/reanimated2/NativeReanimated/NativeReanimated.ts +11 -2
- package/src/reanimated2/component/FlatList.tsx +30 -5
- package/src/reanimated2/core.ts +3 -66
- package/src/reanimated2/errors.ts +57 -0
- package/src/reanimated2/globals.d.ts +22 -3
- package/src/reanimated2/hook/useAnimatedStyle.ts +1 -11
- package/src/reanimated2/initializers.ts +143 -0
- package/src/reanimated2/js-reanimated/JSReanimated.ts +8 -4
- package/src/reanimated2/js-reanimated/global.ts +4 -7
- package/src/reanimated2/layoutReanimation/animationsManager.ts +0 -3
- package/src/reanimated2/mock.ts +105 -0
- package/src/reanimated2/shareables.ts +7 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
type StackDetails = [Error, number, number];
|
|
2
|
+
|
|
3
|
+
const _workletStackDetails = new Map<number, StackDetails>();
|
|
4
|
+
|
|
5
|
+
export function registerWorkletStackDetails(
|
|
6
|
+
hash: number,
|
|
7
|
+
stackDetails: StackDetails
|
|
8
|
+
) {
|
|
9
|
+
_workletStackDetails.set(hash, stackDetails);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function getBundleOffset(error: Error): [string, number, number] {
|
|
13
|
+
const frame = error.stack?.split('\n')?.[0];
|
|
14
|
+
if (frame) {
|
|
15
|
+
const parsedFrame = /@([^@]+):(\d+):(\d+)/.exec(frame);
|
|
16
|
+
if (parsedFrame) {
|
|
17
|
+
const [, file, line, col] = parsedFrame;
|
|
18
|
+
return [file, Number(line), Number(col)];
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return ['unknown', 0, 0];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function processStack(stack: string): string {
|
|
25
|
+
const workletStackEntries = stack.match(/worklet_(\d+):(\d+):(\d+)/g);
|
|
26
|
+
let result = stack;
|
|
27
|
+
workletStackEntries?.forEach((match) => {
|
|
28
|
+
const [, hash, origLine, origCol] = match.split(/:|_/).map(Number);
|
|
29
|
+
const errorDetails = _workletStackDetails.get(hash);
|
|
30
|
+
if (!errorDetails) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const [error, lineOffset, colOffset] = errorDetails;
|
|
34
|
+
const [bundleFile, bundleLine, bundleCol] = getBundleOffset(error);
|
|
35
|
+
const line = origLine + bundleLine + lineOffset;
|
|
36
|
+
const col = origCol + bundleCol + colOffset;
|
|
37
|
+
|
|
38
|
+
result = result.replace(match, `${bundleFile}:${line}:${col}`);
|
|
39
|
+
});
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function reportFatalErrorOnJS({
|
|
44
|
+
message,
|
|
45
|
+
stack,
|
|
46
|
+
}: {
|
|
47
|
+
message: string;
|
|
48
|
+
stack?: string;
|
|
49
|
+
}) {
|
|
50
|
+
const error = new Error();
|
|
51
|
+
error.message = message;
|
|
52
|
+
error.stack = stack ? processStack(stack) : undefined;
|
|
53
|
+
error.name = 'ReanimatedError';
|
|
54
|
+
// @ts-ignore React Native's ErrorUtils implementation extends the Error type with jsEngine field
|
|
55
|
+
error.jsEngine = 'reanimated';
|
|
56
|
+
global.ErrorUtils.reportFatalError(error);
|
|
57
|
+
}
|
|
@@ -6,7 +6,6 @@ import type {
|
|
|
6
6
|
ShareableRef,
|
|
7
7
|
ShareableSyncDataHolderRef,
|
|
8
8
|
} from './commonTypes';
|
|
9
|
-
import type { ReanimatedConsole } from './core';
|
|
10
9
|
import type { FrameCallbackRegistryUI } from './frameCallback/FrameCallbackRegistryUI';
|
|
11
10
|
import type { ShadowNodeWrapper } from './hook/commonTypes';
|
|
12
11
|
import { LayoutAnimationStartFunction } from './layoutReanimation';
|
|
@@ -19,7 +18,12 @@ declare global {
|
|
|
19
18
|
const _frameTimestamp: number | null;
|
|
20
19
|
const _eventTimestamp: number;
|
|
21
20
|
const __reanimatedModuleProxy: NativeReanimated;
|
|
22
|
-
const
|
|
21
|
+
const evalWithSourceMap: (
|
|
22
|
+
js: string,
|
|
23
|
+
sourceURL: string,
|
|
24
|
+
sourceMap: string
|
|
25
|
+
) => any;
|
|
26
|
+
const evalWithSourceUrl: (js: string, sourceURL: string) => any;
|
|
23
27
|
const _log: (s: string) => void;
|
|
24
28
|
const _getCurrentTime: () => number;
|
|
25
29
|
const _getTimestamp: () => number;
|
|
@@ -65,7 +69,12 @@ declare global {
|
|
|
65
69
|
const ReanimatedDataMock: {
|
|
66
70
|
now: () => number;
|
|
67
71
|
};
|
|
72
|
+
const ErrorUtils: {
|
|
73
|
+
reportFatalError: (error: Error) => void;
|
|
74
|
+
};
|
|
68
75
|
const _frameCallbackRegistry: FrameCallbackRegistryUI;
|
|
76
|
+
const requestAnimationFrame: (callback: (time: number) => void) => number;
|
|
77
|
+
const console: Console;
|
|
69
78
|
|
|
70
79
|
namespace NodeJS {
|
|
71
80
|
interface Global {
|
|
@@ -75,7 +84,12 @@ declare global {
|
|
|
75
84
|
_frameTimestamp: number | null;
|
|
76
85
|
_eventTimestamp: number;
|
|
77
86
|
__reanimatedModuleProxy: NativeReanimated;
|
|
78
|
-
|
|
87
|
+
evalWithSourceMap: (
|
|
88
|
+
js: string,
|
|
89
|
+
sourceURL: string,
|
|
90
|
+
sourceMap: string
|
|
91
|
+
) => any;
|
|
92
|
+
evalWithSourceUrl: (js: string, sourceURL: string) => any;
|
|
79
93
|
_log: (s: string) => void;
|
|
80
94
|
_getCurrentTime: () => number;
|
|
81
95
|
_getTimestamp: () => number;
|
|
@@ -118,10 +132,15 @@ declare global {
|
|
|
118
132
|
ReanimatedDataMock: {
|
|
119
133
|
now: () => number;
|
|
120
134
|
};
|
|
135
|
+
ErrorUtils: {
|
|
136
|
+
reportFatalError: (error: Error) => void;
|
|
137
|
+
};
|
|
121
138
|
_frameCallbackRegistry: FrameCallbackRegistryUI;
|
|
122
139
|
__workletsCache?: Map<string, (...args: any[]) => any>;
|
|
123
140
|
__handleCache?: WeakMap<any, any>;
|
|
124
141
|
__mapperRegistry?: MapperRegistry;
|
|
142
|
+
requestAnimationFrame: (callback: (time: number) => void) => number;
|
|
143
|
+
console: Console;
|
|
125
144
|
}
|
|
126
145
|
}
|
|
127
146
|
}
|
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
buildWorkletsHash,
|
|
11
11
|
getStyleWithoutAnimations,
|
|
12
12
|
isAnimated,
|
|
13
|
-
parseColors,
|
|
14
13
|
styleDiff,
|
|
15
14
|
validateAnimatedStyles,
|
|
16
15
|
} from './utils';
|
|
@@ -21,7 +20,7 @@ import {
|
|
|
21
20
|
ViewDescriptorsSet,
|
|
22
21
|
ViewRefSet,
|
|
23
22
|
} from '../ViewDescriptorsSet';
|
|
24
|
-
import { isJest
|
|
23
|
+
import { isJest } from '../PlatformChecker';
|
|
25
24
|
import {
|
|
26
25
|
AnimationObject,
|
|
27
26
|
Timestamp,
|
|
@@ -460,15 +459,6 @@ export function useAnimatedStyle<T extends AnimatedStyle>(
|
|
|
460
459
|
};
|
|
461
460
|
}
|
|
462
461
|
|
|
463
|
-
if (!shouldBeUseWeb()) {
|
|
464
|
-
updaterFn = () => {
|
|
465
|
-
'worklet';
|
|
466
|
-
const style = updaterFn();
|
|
467
|
-
parseColors(style);
|
|
468
|
-
return style;
|
|
469
|
-
};
|
|
470
|
-
}
|
|
471
|
-
|
|
472
462
|
if (isJest()) {
|
|
473
463
|
fun = () => {
|
|
474
464
|
'worklet';
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { reportFatalErrorOnJS } from './errors';
|
|
2
|
+
import NativeReanimatedModule from './NativeReanimated';
|
|
3
|
+
import { isJest } from './PlatformChecker';
|
|
4
|
+
import { runOnUI, runOnJS } from './threads';
|
|
5
|
+
|
|
6
|
+
// callGuard is only used with debug builds
|
|
7
|
+
function callGuardDEV<T extends Array<any>, U>(
|
|
8
|
+
fn: (...args: T) => U,
|
|
9
|
+
...args: T
|
|
10
|
+
): void {
|
|
11
|
+
'worklet';
|
|
12
|
+
try {
|
|
13
|
+
fn(...args);
|
|
14
|
+
} catch (e) {
|
|
15
|
+
if (global.ErrorUtils) {
|
|
16
|
+
global.ErrorUtils.reportFatalError(e as Error);
|
|
17
|
+
} else {
|
|
18
|
+
throw e;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function valueUnpacker(objectToUnpack: any, category?: string): any {
|
|
24
|
+
'worklet';
|
|
25
|
+
let workletsCache = global.__workletsCache;
|
|
26
|
+
let handleCache = global.__handleCache;
|
|
27
|
+
if (workletsCache === undefined) {
|
|
28
|
+
// init
|
|
29
|
+
workletsCache = global.__workletsCache = new Map();
|
|
30
|
+
handleCache = global.__handleCache = new WeakMap();
|
|
31
|
+
}
|
|
32
|
+
if (objectToUnpack.__workletHash) {
|
|
33
|
+
let workletFun = workletsCache.get(objectToUnpack.__workletHash);
|
|
34
|
+
if (workletFun === undefined) {
|
|
35
|
+
if (global.evalWithSourceMap) {
|
|
36
|
+
// if the runtime (hermes only for now) supports loading source maps
|
|
37
|
+
// we want to use the proper filename for the location as it guarantees
|
|
38
|
+
// that debugger understands and loads the source code of the file where
|
|
39
|
+
// the worklet is defined.
|
|
40
|
+
workletFun = global.evalWithSourceMap(
|
|
41
|
+
'(' + objectToUnpack.asString + '\n)',
|
|
42
|
+
objectToUnpack.__location,
|
|
43
|
+
objectToUnpack.__sourceMap
|
|
44
|
+
) as (...args: any[]) => any;
|
|
45
|
+
} else if (global.evalWithSourceUrl) {
|
|
46
|
+
// if the runtime doesn't support loading source maps, in dev mode we
|
|
47
|
+
// can pass source url when evaluating the worklet. Now, instead of using
|
|
48
|
+
// the actual file location we use worklet hash, as it the allows us to
|
|
49
|
+
// properly symbolicate traces (see errors.ts for details)
|
|
50
|
+
workletFun = global.evalWithSourceUrl(
|
|
51
|
+
'(' + objectToUnpack.asString + '\n)',
|
|
52
|
+
`worklet_${objectToUnpack.__workletHash}`
|
|
53
|
+
) as (...args: any[]) => any;
|
|
54
|
+
} else {
|
|
55
|
+
// in release we use the regular eval to save on JSI calls
|
|
56
|
+
// eslint-disable-next-line no-eval
|
|
57
|
+
workletFun = eval('(' + objectToUnpack.asString + '\n)') as (
|
|
58
|
+
...args: any[]
|
|
59
|
+
) => any;
|
|
60
|
+
}
|
|
61
|
+
workletsCache.set(objectToUnpack.__workletHash, workletFun);
|
|
62
|
+
}
|
|
63
|
+
const functionInstance = workletFun.bind(objectToUnpack);
|
|
64
|
+
objectToUnpack._recur = functionInstance;
|
|
65
|
+
return functionInstance;
|
|
66
|
+
} else if (objectToUnpack.__init) {
|
|
67
|
+
let value = handleCache!.get(objectToUnpack);
|
|
68
|
+
if (value === undefined) {
|
|
69
|
+
value = objectToUnpack.__init();
|
|
70
|
+
handleCache!.set(objectToUnpack, value);
|
|
71
|
+
}
|
|
72
|
+
return value;
|
|
73
|
+
} else if (category === 'RemoteFunction') {
|
|
74
|
+
const fun = () => {
|
|
75
|
+
throw new Error(`Tried to synchronously call a non-worklet function on the UI thread.
|
|
76
|
+
|
|
77
|
+
Possible solutions are:
|
|
78
|
+
a) If you want to synchronously execute this method, mark it as a worklet
|
|
79
|
+
b) If you want to execute this function on the JS thread, wrap it using \`runOnJS\``);
|
|
80
|
+
};
|
|
81
|
+
fun.__remoteFunction = objectToUnpack;
|
|
82
|
+
return fun;
|
|
83
|
+
} else {
|
|
84
|
+
throw new Error('data type not recognized by unpack method');
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function initializeUIRuntime() {
|
|
89
|
+
NativeReanimatedModule.installCoreFunctions(callGuardDEV, valueUnpacker);
|
|
90
|
+
|
|
91
|
+
const IS_JEST = isJest();
|
|
92
|
+
|
|
93
|
+
const capturableConsole = console;
|
|
94
|
+
runOnUI(() => {
|
|
95
|
+
'worklet';
|
|
96
|
+
// setup error handler
|
|
97
|
+
global.ErrorUtils = {
|
|
98
|
+
reportFatalError: (error: Error) => {
|
|
99
|
+
runOnJS(reportFatalErrorOnJS)({
|
|
100
|
+
message: error.message,
|
|
101
|
+
stack: error.stack,
|
|
102
|
+
});
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
// setup console
|
|
107
|
+
// @ts-ignore TypeScript doesn't like that there are missing methods in console object, but we don't provide all the methods for the UI runtime console version
|
|
108
|
+
global.console = {
|
|
109
|
+
debug: runOnJS(capturableConsole.debug),
|
|
110
|
+
log: runOnJS(capturableConsole.log),
|
|
111
|
+
warn: runOnJS(capturableConsole.warn),
|
|
112
|
+
error: runOnJS(capturableConsole.error),
|
|
113
|
+
info: runOnJS(capturableConsole.info),
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
if (!IS_JEST) {
|
|
117
|
+
// Jest mocks requestAnimationFrame API and it does not like if that mock gets overridden
|
|
118
|
+
// so we avoid doing requestAnimationFrame batching in Jest environment.
|
|
119
|
+
const nativeRequestAnimationFrame = global.requestAnimationFrame;
|
|
120
|
+
let callbacks: Array<(time: number) => void> = [];
|
|
121
|
+
global.requestAnimationFrame = (
|
|
122
|
+
callback: (timestamp: number) => void
|
|
123
|
+
): number => {
|
|
124
|
+
callbacks.push(callback);
|
|
125
|
+
if (callbacks.length === 1) {
|
|
126
|
+
// We schedule native requestAnimationFrame only when the first callback
|
|
127
|
+
// is added and then use it to execute all the enqueued callbacks. Once
|
|
128
|
+
// the callbacks are run, we clear the array.
|
|
129
|
+
nativeRequestAnimationFrame((timestamp) => {
|
|
130
|
+
const currentCallbacks = callbacks;
|
|
131
|
+
callbacks = [];
|
|
132
|
+
currentCallbacks.forEach((f) => f(timestamp));
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
// Reanimated currently does not support cancelling calbacks requested with
|
|
136
|
+
// requestAnimationFrame. We return -1 as identifier which isn't in line
|
|
137
|
+
// with the spec but it should give users better clue in case they actually
|
|
138
|
+
// attempt to store the value returned from rAF and use it for cancelling.
|
|
139
|
+
return -1;
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
})();
|
|
143
|
+
}
|
|
@@ -3,8 +3,6 @@ import { ShareableRef } from '../commonTypes';
|
|
|
3
3
|
import { isJest } from '../PlatformChecker';
|
|
4
4
|
|
|
5
5
|
export default class JSReanimated extends NativeReanimated {
|
|
6
|
-
_valueUnpacker?: <T>(value: T) => void = undefined;
|
|
7
|
-
|
|
8
6
|
constructor() {
|
|
9
7
|
super(false);
|
|
10
8
|
if (isJest()) {
|
|
@@ -21,8 +19,14 @@ export default class JSReanimated extends NativeReanimated {
|
|
|
21
19
|
return { __hostObjectShareableJSRef: value };
|
|
22
20
|
}
|
|
23
21
|
|
|
24
|
-
installCoreFunctions(
|
|
25
|
-
|
|
22
|
+
installCoreFunctions(
|
|
23
|
+
_callGuard: <T extends Array<any>, U>(
|
|
24
|
+
fn: (...args: T) => U,
|
|
25
|
+
...args: T
|
|
26
|
+
) => void,
|
|
27
|
+
_valueUnpacker: <T>(value: T) => T
|
|
28
|
+
): void {
|
|
29
|
+
// noop
|
|
26
30
|
}
|
|
27
31
|
|
|
28
32
|
scheduleOnUI<T>(worklet: ShareableRef<T>) {
|
|
@@ -4,9 +4,6 @@ import { shouldBeUseWeb } from '../PlatformChecker';
|
|
|
4
4
|
const initializeGlobalsForWeb = () => {
|
|
5
5
|
if (shouldBeUseWeb()) {
|
|
6
6
|
global._frameTimestamp = null;
|
|
7
|
-
global._setGlobalConsole = (_val) => {
|
|
8
|
-
// noop
|
|
9
|
-
};
|
|
10
7
|
global._measure = () => {
|
|
11
8
|
console.warn(
|
|
12
9
|
"[Reanimated] You can't use `measure` with Chrome Debugger or with web version"
|
|
@@ -40,10 +37,10 @@ const initializeGlobalsForWeb = () => {
|
|
|
40
37
|
};
|
|
41
38
|
|
|
42
39
|
/*
|
|
43
|
-
If a file doesn't export anything, tree shaking doesn't pack
|
|
44
|
-
it into the JS bundle. In effect, the code inside of this file
|
|
45
|
-
will never execute. That is why we wrapped initialization code
|
|
46
|
-
into a function, and we call this one during creating
|
|
40
|
+
If a file doesn't export anything, tree shaking doesn't pack
|
|
41
|
+
it into the JS bundle. In effect, the code inside of this file
|
|
42
|
+
will never execute. That is why we wrapped initialization code
|
|
43
|
+
into a function, and we call this one during creating
|
|
47
44
|
the module export object.
|
|
48
45
|
*/
|
|
49
46
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { runOnUI } from '../core';
|
|
2
2
|
import { withStyleAnimation } from '../animation/styleAnimation';
|
|
3
|
-
import { LogBox } from 'react-native';
|
|
4
3
|
import { SharedValue } from '../commonTypes';
|
|
5
4
|
import { makeUIMutable } from '../mutables';
|
|
6
5
|
import {
|
|
@@ -8,8 +7,6 @@ import {
|
|
|
8
7
|
LayoutAnimationsValues,
|
|
9
8
|
} from './animationBuilder';
|
|
10
9
|
|
|
11
|
-
LogBox.ignoreLogs(['Overriding previous layout animation with']);
|
|
12
|
-
|
|
13
10
|
const TAG_OFFSET = 1e9;
|
|
14
11
|
|
|
15
12
|
function startObservingProgress(
|
package/src/reanimated2/mock.ts
CHANGED
|
@@ -7,6 +7,28 @@ const NOOP = () => {
|
|
|
7
7
|
const ID = (t) => t;
|
|
8
8
|
const IMMEDIATE_CB_INVOCATION = (cb: () => unknown) => cb();
|
|
9
9
|
|
|
10
|
+
class BaseAnimationMock {
|
|
11
|
+
duration(_: number) {
|
|
12
|
+
return this;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
delay(_: number) {
|
|
16
|
+
return this;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
withCallback(_: (finsihed: boolean) => void) {
|
|
20
|
+
return this;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
randomDelay() {
|
|
24
|
+
return this;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
withInitialValues() {
|
|
28
|
+
return this;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
10
32
|
const ReanimatedV2 = {
|
|
11
33
|
useSharedValue: (v) => ({ value: v }),
|
|
12
34
|
useDerivedValue: (a) => ({ value: a() }),
|
|
@@ -75,6 +97,89 @@ const ReanimatedV2 = {
|
|
|
75
97
|
runOnUI: (fn) => fn,
|
|
76
98
|
};
|
|
77
99
|
|
|
100
|
+
[
|
|
101
|
+
'FadeIn',
|
|
102
|
+
'FadeInRight',
|
|
103
|
+
'FadeInLeft',
|
|
104
|
+
'FadeInUp',
|
|
105
|
+
'FadFadeInDown',
|
|
106
|
+
'FadeOut',
|
|
107
|
+
'FadeOutRight',
|
|
108
|
+
'FadeOutLeft',
|
|
109
|
+
'FadeOutUp',
|
|
110
|
+
'FadeOutDown',
|
|
111
|
+
|
|
112
|
+
'FlipInYLeft',
|
|
113
|
+
'FlipInXDown',
|
|
114
|
+
'FlipInYRight',
|
|
115
|
+
'FlipInEasyX',
|
|
116
|
+
'FlipInEasyY',
|
|
117
|
+
'FlipOutXUp',
|
|
118
|
+
'FlipOutYLeft',
|
|
119
|
+
'FlipOutXDown',
|
|
120
|
+
'FlipOutYRight',
|
|
121
|
+
'FlipOutEasyX',
|
|
122
|
+
'FlipOutEasyY',
|
|
123
|
+
|
|
124
|
+
'StretchInY',
|
|
125
|
+
'StretchOutX',
|
|
126
|
+
'StretchOutY',
|
|
127
|
+
'SlideInLeft',
|
|
128
|
+
'SlideOutRight',
|
|
129
|
+
'SlideOutLeft',
|
|
130
|
+
'SlideInUp',
|
|
131
|
+
'SlideInDown',
|
|
132
|
+
'SlideOutUp',
|
|
133
|
+
|
|
134
|
+
'ZoomInRotate',
|
|
135
|
+
'ZoomInLeft',
|
|
136
|
+
'ZoomInRight',
|
|
137
|
+
'ZoomInUp',
|
|
138
|
+
'ZoomInDown',
|
|
139
|
+
'ZoomInEasyUp',
|
|
140
|
+
'ZoomInEasyDown',
|
|
141
|
+
'ZoomOut',
|
|
142
|
+
'ZoomOutRotate',
|
|
143
|
+
'ZoomOutLeft',
|
|
144
|
+
'ZoomOutRight',
|
|
145
|
+
'ZoomOutUp',
|
|
146
|
+
'ZoomOutDown',
|
|
147
|
+
'ZoomOutEasyUp',
|
|
148
|
+
'ZoomOutEasyDown',
|
|
149
|
+
|
|
150
|
+
'BounceInDown',
|
|
151
|
+
'BounceInUp',
|
|
152
|
+
'BounceInLeft',
|
|
153
|
+
'BounceInRight',
|
|
154
|
+
'BounceOut',
|
|
155
|
+
'BounceOutDown',
|
|
156
|
+
'BounceOutUp',
|
|
157
|
+
'BounceOutLeft',
|
|
158
|
+
'BounceOutRight',
|
|
159
|
+
|
|
160
|
+
'LightSpeedInLeft',
|
|
161
|
+
'LightSpeedOutRight',
|
|
162
|
+
'LightSpeedOutLeft',
|
|
163
|
+
|
|
164
|
+
'PinwheelOut',
|
|
165
|
+
|
|
166
|
+
'RotateInDownRight',
|
|
167
|
+
'RotateInUpLeft',
|
|
168
|
+
'RotateInUpRight',
|
|
169
|
+
'RotateOutDownLeft',
|
|
170
|
+
'RotateOutDownRight',
|
|
171
|
+
'RotateOutUpLeft',
|
|
172
|
+
'RotateOutUpRight',
|
|
173
|
+
|
|
174
|
+
'RollInRight',
|
|
175
|
+
'RollOutLeft',
|
|
176
|
+
'RollOutRight',
|
|
177
|
+
].forEach((k) =>
|
|
178
|
+
Object.assign(ReanimatedV2, {
|
|
179
|
+
[k]: new BaseAnimationMock(),
|
|
180
|
+
})
|
|
181
|
+
);
|
|
182
|
+
|
|
78
183
|
module.exports = {
|
|
79
184
|
...ReanimatedV2,
|
|
80
185
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import NativeReanimatedModule from './NativeReanimated';
|
|
2
2
|
import { ShareableRef } from './commonTypes';
|
|
3
3
|
import { shouldBeUseWeb } from './PlatformChecker';
|
|
4
|
+
import { registerWorkletStackDetails } from './errors';
|
|
4
5
|
|
|
5
6
|
// for web/chrome debugger/jest environments this file provides a stub implementation
|
|
6
7
|
// where no shareable references are used. Instead, the objects themselves are used
|
|
@@ -53,6 +54,12 @@ export function makeShareableCloneRecursive<T>(value: any): ShareableRef<T> {
|
|
|
53
54
|
// this is a remote function
|
|
54
55
|
toAdapt = value;
|
|
55
56
|
} else {
|
|
57
|
+
if (__DEV__ && value.__workletHash !== undefined) {
|
|
58
|
+
registerWorkletStackDetails(
|
|
59
|
+
value.__workletHash,
|
|
60
|
+
value.__stackDetails
|
|
61
|
+
);
|
|
62
|
+
}
|
|
56
63
|
toAdapt = {};
|
|
57
64
|
for (const [key, element] of Object.entries(value)) {
|
|
58
65
|
toAdapt[key] = makeShareableCloneRecursive(element);
|