1 |
|
2 | 'use strict';
|
3 |
|
4 | import { IOSReferenceFrame, InterfaceOrientation, KeyboardState, ReduceMotion, SensorType, ColorSpace, Extrapolation, SharedTransitionType, withReanimatedTimer, advanceAnimationByTime, advanceAnimationByFrame, setUpTests, getAnimatedStyle } from "./index.js";
|
5 | import { View as ViewRN, Text as TextRN, Image as ImageRN, Animated as AnimatedRN, processColor as processColorRN } from 'react-native';
|
6 | const NOOP = () => {};
|
7 | const NOOP_FACTORY = () => NOOP;
|
8 | const ID = t => t;
|
9 | const IMMEDIATE_CALLBACK_INVOCATION = callback => callback();
|
10 | const hook = {
|
11 | useAnimatedProps: IMMEDIATE_CALLBACK_INVOCATION,
|
12 | useEvent: (_handler, _eventNames, _rebuild) => NOOP,
|
13 |
|
14 | useWorkletCallback: ID,
|
15 | useSharedValue: init => ({
|
16 | value: init
|
17 | }),
|
18 |
|
19 | useAnimatedStyle: IMMEDIATE_CALLBACK_INVOCATION,
|
20 | useAnimatedGestureHandler: NOOP_FACTORY,
|
21 | useAnimatedReaction: NOOP,
|
22 | useAnimatedRef: () => ({
|
23 | current: null
|
24 | }),
|
25 | useAnimatedScrollHandler: NOOP_FACTORY,
|
26 | useDerivedValue: processor => ({
|
27 | value: processor()
|
28 | }),
|
29 | useAnimatedSensor: () => ({
|
30 | sensor: {
|
31 | value: {
|
32 | x: 0,
|
33 | y: 0,
|
34 | z: 0,
|
35 | interfaceOrientation: 0,
|
36 | qw: 0,
|
37 | qx: 0,
|
38 | qy: 0,
|
39 | qz: 0,
|
40 | yaw: 0,
|
41 | pitch: 0,
|
42 | roll: 0
|
43 | }
|
44 | },
|
45 | unregister: NOOP,
|
46 | isAvailable: false,
|
47 | config: {
|
48 | interval: 0,
|
49 | adjustToInterfaceOrientation: false,
|
50 | iosReferenceFrame: 0
|
51 | }
|
52 | }),
|
53 |
|
54 | useAnimatedKeyboard: () => ({
|
55 | height: 0,
|
56 | state: 0
|
57 | })
|
58 |
|
59 | };
|
60 | const animation = {
|
61 | cancelAnimation: NOOP,
|
62 |
|
63 |
|
64 | withDecay: (_userConfig, callback) => {
|
65 | callback?.(true);
|
66 | return 0;
|
67 | },
|
68 | withDelay: (_delayMs, nextAnimation) => {
|
69 | return nextAnimation;
|
70 | },
|
71 | withRepeat: ID,
|
72 | withSequence: () => 0,
|
73 | withSpring: (toValue, _userConfig, callback) => {
|
74 | callback?.(true);
|
75 | return toValue;
|
76 | },
|
77 | withTiming: (toValue, _userConfig, callback) => {
|
78 | callback?.(true);
|
79 | return toValue;
|
80 | }
|
81 | };
|
82 | const interpolation = {
|
83 | Extrapolation,
|
84 | interpolate: NOOP,
|
85 | clamp: NOOP
|
86 | };
|
87 | const interpolateColor = {
|
88 | Extrapolate: Extrapolation,
|
89 | Extrapolation,
|
90 | ColorSpace,
|
91 | interpolateColor: NOOP
|
92 |
|
93 | };
|
94 | const Easing = {
|
95 | Easing: {
|
96 | linear: ID,
|
97 | ease: ID,
|
98 | quad: ID,
|
99 | cubic: ID,
|
100 | poly: ID,
|
101 | sin: ID,
|
102 | circle: ID,
|
103 | exp: ID,
|
104 | elastic: ID,
|
105 | back: ID,
|
106 | bounce: ID,
|
107 | bezier: () => ({
|
108 | factory: ID
|
109 | }),
|
110 | bezierFn: ID,
|
111 | steps: ID,
|
112 | in: ID,
|
113 | out: ID,
|
114 | inOut: ID
|
115 | }
|
116 | };
|
117 | const platformFunctions = {
|
118 | measure: () => ({
|
119 | x: 0,
|
120 | y: 0,
|
121 | width: 0,
|
122 | height: 0,
|
123 | pageX: 0,
|
124 | pageY: 0
|
125 | }),
|
126 |
|
127 | scrollTo: NOOP
|
128 |
|
129 |
|
130 |
|
131 | };
|
132 | const Colors = {
|
133 |
|
134 | processColor: processColorRN
|
135 |
|
136 | };
|
137 | const PropAdapters = {
|
138 |
|
139 | };
|
140 | class BaseAnimationMock {
|
141 | duration() {
|
142 | return this;
|
143 | }
|
144 | delay() {
|
145 | return this;
|
146 | }
|
147 | springify() {
|
148 | return this;
|
149 | }
|
150 | damping() {
|
151 | return this;
|
152 | }
|
153 | stiffness() {
|
154 | return this;
|
155 | }
|
156 | withCallback() {
|
157 | return this;
|
158 | }
|
159 | randomDelay() {
|
160 | return this;
|
161 | }
|
162 | withInitialValues() {
|
163 | return this;
|
164 | }
|
165 | easing(_) {
|
166 | return this;
|
167 | }
|
168 | rotate(_) {
|
169 | return this;
|
170 | }
|
171 | mass(_) {
|
172 | return this;
|
173 | }
|
174 | restDisplacementThreshold(_) {
|
175 | return this;
|
176 | }
|
177 | restSpeedThreshold(_) {
|
178 | return this;
|
179 | }
|
180 | overshootClamping(_) {
|
181 | return this;
|
182 | }
|
183 | dampingRatio(_) {
|
184 | return this;
|
185 | }
|
186 | getDelay() {
|
187 | return 0;
|
188 | }
|
189 | getDelayFunction() {
|
190 | return NOOP;
|
191 | }
|
192 | getDuration() {
|
193 | return 300;
|
194 | }
|
195 | getReduceMotion() {
|
196 | return ReduceMotion.System;
|
197 | }
|
198 | getAnimationAndConfig() {
|
199 | return [NOOP, {}];
|
200 | }
|
201 | build() {
|
202 | return () => ({
|
203 | initialValues: {},
|
204 | animations: {}
|
205 | });
|
206 | }
|
207 | reduceMotion() {
|
208 | return this;
|
209 | }
|
210 | }
|
211 | const core = {
|
212 | runOnJS: ID,
|
213 | runOnUI: ID,
|
214 | createWorkletRuntime: NOOP,
|
215 | runOnRuntime: NOOP,
|
216 | makeMutable: ID,
|
217 | makeShareableCloneRecursive: ID,
|
218 | isReanimated3: () => true,
|
219 |
|
220 | enableLayoutAnimations: NOOP
|
221 |
|
222 | };
|
223 | const layoutReanimation = {
|
224 | BaseAnimationBuilder: new BaseAnimationMock(),
|
225 | ComplexAnimationBuilder: new BaseAnimationMock(),
|
226 | Keyframe: new BaseAnimationMock(),
|
227 |
|
228 | FlipInXUp: new BaseAnimationMock(),
|
229 | FlipInYLeft: new BaseAnimationMock(),
|
230 | FlipInXDown: new BaseAnimationMock(),
|
231 | FlipInYRight: new BaseAnimationMock(),
|
232 | FlipInEasyX: new BaseAnimationMock(),
|
233 | FlipInEasyY: new BaseAnimationMock(),
|
234 | FlipOutXUp: new BaseAnimationMock(),
|
235 | FlipOutYLeft: new BaseAnimationMock(),
|
236 | FlipOutXDown: new BaseAnimationMock(),
|
237 | FlipOutYRight: new BaseAnimationMock(),
|
238 | FlipOutEasyX: new BaseAnimationMock(),
|
239 | FlipOutEasyY: new BaseAnimationMock(),
|
240 |
|
241 | StretchInX: new BaseAnimationMock(),
|
242 | StretchInY: new BaseAnimationMock(),
|
243 | StretchOutX: new BaseAnimationMock(),
|
244 | StretchOutY: new BaseAnimationMock(),
|
245 |
|
246 | FadeIn: new BaseAnimationMock(),
|
247 | FadeInRight: new BaseAnimationMock(),
|
248 | FadeInLeft: new BaseAnimationMock(),
|
249 | FadeInUp: new BaseAnimationMock(),
|
250 | FadeInDown: new BaseAnimationMock(),
|
251 | FadeOut: new BaseAnimationMock(),
|
252 | FadeOutRight: new BaseAnimationMock(),
|
253 | FadeOutLeft: new BaseAnimationMock(),
|
254 | FadeOutUp: new BaseAnimationMock(),
|
255 | FadeOutDown: new BaseAnimationMock(),
|
256 |
|
257 | SlideInRight: new BaseAnimationMock(),
|
258 | SlideInLeft: new BaseAnimationMock(),
|
259 | SlideOutRight: new BaseAnimationMock(),
|
260 | SlideOutLeft: new BaseAnimationMock(),
|
261 | SlideInUp: new BaseAnimationMock(),
|
262 | SlideInDown: new BaseAnimationMock(),
|
263 | SlideOutUp: new BaseAnimationMock(),
|
264 | SlideOutDown: new BaseAnimationMock(),
|
265 |
|
266 | ZoomIn: new BaseAnimationMock(),
|
267 | ZoomInRotate: new BaseAnimationMock(),
|
268 | ZoomInLeft: new BaseAnimationMock(),
|
269 | ZoomInRight: new BaseAnimationMock(),
|
270 | ZoomInUp: new BaseAnimationMock(),
|
271 | ZoomInDown: new BaseAnimationMock(),
|
272 | ZoomInEasyUp: new BaseAnimationMock(),
|
273 | ZoomInEasyDown: new BaseAnimationMock(),
|
274 | ZoomOut: new BaseAnimationMock(),
|
275 | ZoomOutRotate: new BaseAnimationMock(),
|
276 | ZoomOutLeft: new BaseAnimationMock(),
|
277 | ZoomOutRight: new BaseAnimationMock(),
|
278 | ZoomOutUp: new BaseAnimationMock(),
|
279 | ZoomOutDown: new BaseAnimationMock(),
|
280 | ZoomOutEasyUp: new BaseAnimationMock(),
|
281 | ZoomOutEasyDown: new BaseAnimationMock(),
|
282 |
|
283 | BounceIn: new BaseAnimationMock(),
|
284 | BounceInDown: new BaseAnimationMock(),
|
285 | BounceInUp: new BaseAnimationMock(),
|
286 | BounceInLeft: new BaseAnimationMock(),
|
287 | BounceInRight: new BaseAnimationMock(),
|
288 | BounceOut: new BaseAnimationMock(),
|
289 | BounceOutDown: new BaseAnimationMock(),
|
290 | BounceOutUp: new BaseAnimationMock(),
|
291 | BounceOutLeft: new BaseAnimationMock(),
|
292 | BounceOutRight: new BaseAnimationMock(),
|
293 |
|
294 | LightSpeedInRight: new BaseAnimationMock(),
|
295 | LightSpeedInLeft: new BaseAnimationMock(),
|
296 | LightSpeedOutRight: new BaseAnimationMock(),
|
297 | LightSpeedOutLeft: new BaseAnimationMock(),
|
298 |
|
299 | PinwheelIn: new BaseAnimationMock(),
|
300 | PinwheelOut: new BaseAnimationMock(),
|
301 |
|
302 | RotateInDownLeft: new BaseAnimationMock(),
|
303 | RotateInDownRight: new BaseAnimationMock(),
|
304 | RotateInUpLeft: new BaseAnimationMock(),
|
305 | RotateInUpRight: new BaseAnimationMock(),
|
306 | RotateOutDownLeft: new BaseAnimationMock(),
|
307 | RotateOutDownRight: new BaseAnimationMock(),
|
308 | RotateOutUpLeft: new BaseAnimationMock(),
|
309 | RotateOutUpRight: new BaseAnimationMock(),
|
310 |
|
311 | RollInLeft: new BaseAnimationMock(),
|
312 | RollInRight: new BaseAnimationMock(),
|
313 | RollOutLeft: new BaseAnimationMock(),
|
314 | RollOutRight: new BaseAnimationMock(),
|
315 |
|
316 | Layout: new BaseAnimationMock(),
|
317 | LinearTransition: new BaseAnimationMock(),
|
318 | FadingTransition: new BaseAnimationMock(),
|
319 | SequencedTransition: new BaseAnimationMock(),
|
320 | JumpingTransition: new BaseAnimationMock(),
|
321 | CurvedTransition: new BaseAnimationMock(),
|
322 | EntryExitTransition: new BaseAnimationMock(),
|
323 |
|
324 |
|
325 |
|
326 | SharedTransitionType
|
327 | };
|
328 | const isSharedValue = {
|
329 |
|
330 | };
|
331 | const commonTypes = {
|
332 | SensorType,
|
333 | IOSReferenceFrame,
|
334 | InterfaceOrientation,
|
335 | KeyboardState,
|
336 | ReduceMotion
|
337 | };
|
338 | const pluginUtils = {
|
339 |
|
340 | };
|
341 | const jestUtils = {
|
342 | withReanimatedTimer,
|
343 | advanceAnimationByTime,
|
344 | advanceAnimationByFrame,
|
345 | setUpTests,
|
346 | getAnimatedStyle
|
347 | };
|
348 | const LayoutAnimationConfig = {
|
349 |
|
350 | };
|
351 | const mappers = {
|
352 |
|
353 |
|
354 | };
|
355 | const Animated = {
|
356 | View: ViewRN,
|
357 | Text: TextRN,
|
358 | Image: ImageRN,
|
359 | ScrollView: AnimatedRN.ScrollView,
|
360 | FlatList: AnimatedRN.FlatList,
|
361 | Extrapolate: Extrapolation,
|
362 | interpolate: NOOP,
|
363 | interpolateColor: NOOP,
|
364 | clamp: NOOP,
|
365 | createAnimatedComponent: ID,
|
366 | addWhitelistedUIProps: NOOP,
|
367 | addWhitelistedNativeProps: NOOP
|
368 | };
|
369 | const Reanimated = {
|
370 | ...core,
|
371 | ...hook,
|
372 | ...animation,
|
373 | ...interpolation,
|
374 | ...interpolateColor,
|
375 | ...Easing,
|
376 | ...platformFunctions,
|
377 | ...Colors,
|
378 | ...PropAdapters,
|
379 | ...layoutReanimation,
|
380 | ...isSharedValue,
|
381 | ...commonTypes,
|
382 | ...pluginUtils,
|
383 | ...jestUtils,
|
384 | ...LayoutAnimationConfig,
|
385 | ...mappers
|
386 | };
|
387 | module.exports = {
|
388 | __esModule: true,
|
389 | ...Reanimated,
|
390 | default: Animated
|
391 | };
|
392 |
|
\ | No newline at end of file |