@yahoo/uds-mobile 2.2.0 → 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/README.md +92 -0
- package/dist/_virtual/_rolldown/runtime.cjs +14 -0
- package/dist/_virtual/_rolldown/runtime.js +19 -0
- package/dist/jest/index.cjs +27 -0
- package/dist/jest/index.d.cts +19 -0
- package/dist/jest/index.d.cts.map +1 -0
- package/dist/jest/index.d.ts +19 -0
- package/dist/jest/index.d.ts.map +1 -0
- package/dist/jest/index.js +25 -0
- package/dist/jest/index.js.map +1 -0
- package/dist/jest/mocks/icons.cjs +56 -0
- package/dist/jest/mocks/icons.d.cts +24 -0
- package/dist/jest/mocks/icons.d.cts.map +1 -0
- package/dist/jest/mocks/icons.d.ts +24 -0
- package/dist/jest/mocks/icons.d.ts.map +1 -0
- package/dist/jest/mocks/icons.js +46 -0
- package/dist/jest/mocks/icons.js.map +1 -0
- package/dist/jest/mocks/react-native.cjs +212 -0
- package/dist/jest/mocks/react-native.d.cts +293 -0
- package/dist/jest/mocks/react-native.d.cts.map +1 -0
- package/dist/jest/mocks/react-native.d.ts +293 -0
- package/dist/jest/mocks/react-native.d.ts.map +1 -0
- package/dist/jest/mocks/react-native.js +180 -0
- package/dist/jest/mocks/react-native.js.map +1 -0
- package/dist/jest/mocks/reanimated.cjs +249 -0
- package/dist/jest/mocks/reanimated.d.cts +150 -0
- package/dist/jest/mocks/reanimated.d.cts.map +1 -0
- package/dist/jest/mocks/reanimated.d.ts +150 -0
- package/dist/jest/mocks/reanimated.d.ts.map +1 -0
- package/dist/jest/mocks/reanimated.js +210 -0
- package/dist/jest/mocks/reanimated.js.map +1 -0
- package/dist/jest/mocks/styles.cjs +327 -0
- package/dist/jest/mocks/styles.d.cts +33 -0
- package/dist/jest/mocks/styles.d.cts.map +1 -0
- package/dist/jest/mocks/styles.d.ts +33 -0
- package/dist/jest/mocks/styles.d.ts.map +1 -0
- package/dist/jest/mocks/styles.js +310 -0
- package/dist/jest/mocks/styles.js.map +1 -0
- package/dist/jest/mocks/svg.cjs +133 -0
- package/dist/jest/mocks/svg.d.cts +137 -0
- package/dist/jest/mocks/svg.d.cts.map +1 -0
- package/dist/jest/mocks/svg.d.ts +137 -0
- package/dist/jest/mocks/svg.d.ts.map +1 -0
- package/dist/jest/mocks/svg.js +100 -0
- package/dist/jest/mocks/svg.js.map +1 -0
- package/dist/jest/mocks/unistyles.cjs +143 -0
- package/dist/jest/mocks/unistyles.d.cts +197 -0
- package/dist/jest/mocks/unistyles.d.cts.map +1 -0
- package/dist/jest/mocks/unistyles.d.ts +197 -0
- package/dist/jest/mocks/unistyles.d.ts.map +1 -0
- package/dist/jest/mocks/unistyles.js +132 -0
- package/dist/jest/mocks/unistyles.js.map +1 -0
- package/dist/jest/setup.cjs +40 -0
- package/dist/jest/setup.d.cts +11 -0
- package/dist/jest/setup.d.cts.map +1 -0
- package/dist/jest/setup.d.ts +11 -0
- package/dist/jest/setup.d.ts.map +1 -0
- package/dist/jest/setup.js +39 -0
- package/dist/jest/setup.js.map +1 -0
- package/package.json +11 -1
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
|
|
2
|
+
import React, { ComponentType, PropsWithChildren, ReactNode } from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/jest/mocks/reanimated.d.ts
|
|
5
|
+
declare namespace reanimated_d_exports {
|
|
6
|
+
export { Animated, Easing, FadeIn, FadeOut, SlideInRight, SlideOutLeft, ZoomIn, ZoomOut, cancelAnimation, convertToRGBA, createAnimatedComponent, Animated as default, interpolate, interpolateColor, isWorklet, measure, runOnJS, runOnUI, scrollTo, useAnimatedGestureHandler, useAnimatedProps, useAnimatedReaction, useAnimatedRef, useAnimatedScrollHandler, useAnimatedStyle, useDerivedValue, useSharedValue, withDecay, withDelay, withRepeat, withSequence, withSpring, withTiming };
|
|
7
|
+
}
|
|
8
|
+
declare function useSharedValue<T>(initialValue: T): {
|
|
9
|
+
value: T;
|
|
10
|
+
addListener: jest.Mock<any, any, any>;
|
|
11
|
+
removeListener: jest.Mock<any, any, any>;
|
|
12
|
+
modify: jest.Mock<any, any, any>;
|
|
13
|
+
};
|
|
14
|
+
declare function useDerivedValue<T>(derivedFn: () => T): {
|
|
15
|
+
value: T;
|
|
16
|
+
};
|
|
17
|
+
declare function useAnimatedStyle<T extends object>(styleWorklet: () => T): T;
|
|
18
|
+
declare function withTiming<T>(toValue: T): T;
|
|
19
|
+
declare function withSpring<T>(toValue: T): T;
|
|
20
|
+
declare function withDelay<T>(_delay: number, animation: T): T;
|
|
21
|
+
declare function withSequence<T>(...animations: T[]): T;
|
|
22
|
+
declare function withRepeat<T>(animation: T): T;
|
|
23
|
+
declare function withDecay(config: {
|
|
24
|
+
velocity?: number;
|
|
25
|
+
deceleration?: number;
|
|
26
|
+
}): number;
|
|
27
|
+
declare function interpolate(value: number, inputRange: readonly number[], outputRange: readonly number[], _extrapolation?: 'clamp' | 'extend' | {
|
|
28
|
+
extrapolateLeft?: string;
|
|
29
|
+
extrapolateRight?: string;
|
|
30
|
+
}): number;
|
|
31
|
+
declare function interpolateColor(value: number, inputRange: readonly number[], outputRange: readonly string[]): string;
|
|
32
|
+
declare const Easing: {
|
|
33
|
+
linear: (t: number) => number;
|
|
34
|
+
ease: (t: number) => number;
|
|
35
|
+
quad: (t: number) => number;
|
|
36
|
+
cubic: (t: number) => number;
|
|
37
|
+
poly: (_n: number) => (t: number) => number;
|
|
38
|
+
sin: (t: number) => number;
|
|
39
|
+
circle: (t: number) => number;
|
|
40
|
+
exp: (t: number) => number;
|
|
41
|
+
elastic: (_bounciness?: number) => (t: number) => number;
|
|
42
|
+
back: (_s?: number) => (t: number) => number;
|
|
43
|
+
bounce: (t: number) => number;
|
|
44
|
+
bezier: () => (t: number) => number;
|
|
45
|
+
bezierFn: () => (t: number) => number;
|
|
46
|
+
in: (easing: (t: number) => number) => (t: number) => number;
|
|
47
|
+
out: (easing: (t: number) => number) => (t: number) => number;
|
|
48
|
+
inOut: (easing: (t: number) => number) => (t: number) => number;
|
|
49
|
+
};
|
|
50
|
+
declare function useAnimatedGestureHandler(): Record<string, unknown>;
|
|
51
|
+
declare function useAnimatedScrollHandler(): Record<string, unknown>;
|
|
52
|
+
declare function useAnimatedProps<T extends object>(propsWorklet: () => T): T;
|
|
53
|
+
declare function useAnimatedRef<T>(): {
|
|
54
|
+
current: T | null;
|
|
55
|
+
};
|
|
56
|
+
declare function useAnimatedReaction(): void;
|
|
57
|
+
interface MockViewProps {
|
|
58
|
+
children?: ReactNode;
|
|
59
|
+
style?: object;
|
|
60
|
+
testID?: string;
|
|
61
|
+
[key: string]: unknown;
|
|
62
|
+
}
|
|
63
|
+
declare function MockView({
|
|
64
|
+
children,
|
|
65
|
+
style,
|
|
66
|
+
testID,
|
|
67
|
+
...props
|
|
68
|
+
}: MockViewProps): React.ReactElement<{
|
|
69
|
+
style: object | undefined;
|
|
70
|
+
testID: string | undefined;
|
|
71
|
+
}, string | React.JSXElementConstructor<any>>;
|
|
72
|
+
declare function MockText({
|
|
73
|
+
children,
|
|
74
|
+
style,
|
|
75
|
+
testID,
|
|
76
|
+
...props
|
|
77
|
+
}: MockViewProps): React.ReactElement<{
|
|
78
|
+
style: object | undefined;
|
|
79
|
+
testID: string | undefined;
|
|
80
|
+
}, string | React.JSXElementConstructor<any>>;
|
|
81
|
+
declare function MockScrollView({
|
|
82
|
+
children,
|
|
83
|
+
style,
|
|
84
|
+
testID,
|
|
85
|
+
...props
|
|
86
|
+
}: MockViewProps): React.ReactElement<{
|
|
87
|
+
style: object | undefined;
|
|
88
|
+
testID: string | undefined;
|
|
89
|
+
}, string | React.JSXElementConstructor<any>>;
|
|
90
|
+
declare function MockImage({
|
|
91
|
+
style,
|
|
92
|
+
testID,
|
|
93
|
+
...props
|
|
94
|
+
}: MockViewProps): React.DOMElement<{
|
|
95
|
+
children?: ReactNode;
|
|
96
|
+
style: object | undefined;
|
|
97
|
+
testID: string;
|
|
98
|
+
}, Element>;
|
|
99
|
+
declare function createAnimatedComponent<T extends ComponentType<object>>(Component: T): {
|
|
100
|
+
({
|
|
101
|
+
children,
|
|
102
|
+
style,
|
|
103
|
+
...props
|
|
104
|
+
}: PropsWithChildren<{
|
|
105
|
+
style?: object;
|
|
106
|
+
}>): React.JSX.Element;
|
|
107
|
+
displayName: string;
|
|
108
|
+
};
|
|
109
|
+
declare const Animated: {
|
|
110
|
+
View: typeof MockView;
|
|
111
|
+
Text: typeof MockText;
|
|
112
|
+
Image: typeof MockImage;
|
|
113
|
+
ScrollView: typeof MockScrollView;
|
|
114
|
+
createAnimatedComponent: typeof createAnimatedComponent;
|
|
115
|
+
};
|
|
116
|
+
declare const FadeIn: {
|
|
117
|
+
duration: jest.Mock<any, any, any>;
|
|
118
|
+
};
|
|
119
|
+
declare const FadeOut: {
|
|
120
|
+
duration: jest.Mock<any, any, any>;
|
|
121
|
+
};
|
|
122
|
+
declare const SlideInRight: {
|
|
123
|
+
duration: jest.Mock<any, any, any>;
|
|
124
|
+
};
|
|
125
|
+
declare const SlideOutLeft: {
|
|
126
|
+
duration: jest.Mock<any, any, any>;
|
|
127
|
+
};
|
|
128
|
+
declare const ZoomIn: {
|
|
129
|
+
duration: jest.Mock<any, any, any>;
|
|
130
|
+
};
|
|
131
|
+
declare const ZoomOut: {
|
|
132
|
+
duration: jest.Mock<any, any, any>;
|
|
133
|
+
};
|
|
134
|
+
declare function convertToRGBA(color: string | number): string;
|
|
135
|
+
declare function runOnJS<T extends (...args: unknown[]) => unknown>(fn: T): T;
|
|
136
|
+
declare function runOnUI<T extends (...args: unknown[]) => unknown>(fn: T): T;
|
|
137
|
+
declare function isWorklet(): boolean;
|
|
138
|
+
declare const cancelAnimation: jest.Mock<any, any, any>;
|
|
139
|
+
declare const measure: jest.Mock<{
|
|
140
|
+
x: number;
|
|
141
|
+
y: number;
|
|
142
|
+
width: number;
|
|
143
|
+
height: number;
|
|
144
|
+
pageX: number;
|
|
145
|
+
pageY: number;
|
|
146
|
+
}, [], any>;
|
|
147
|
+
declare const scrollTo: jest.Mock<any, any, any>;
|
|
148
|
+
//#endregion
|
|
149
|
+
export { Animated, Animated as default, Easing, FadeIn, FadeOut, SlideInRight, SlideOutLeft, ZoomIn, ZoomOut, cancelAnimation, convertToRGBA, createAnimatedComponent, interpolate, interpolateColor, isWorklet, measure, reanimated_d_exports, runOnJS, runOnUI, scrollTo, useAnimatedGestureHandler, useAnimatedProps, useAnimatedReaction, useAnimatedRef, useAnimatedScrollHandler, useAnimatedStyle, useDerivedValue, useSharedValue, withDecay, withDelay, withRepeat, withSequence, withSpring, withTiming };
|
|
150
|
+
//# sourceMappingURL=reanimated.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reanimated.d.ts","names":[],"sources":["../../../src/jest/mocks/reanimated.tsx"],"mappings":";;;;;;;iBAaS,cAAA,GAAA,CAAkB,YAAA,EAAc,CAAA;;;;;;iBAUhC,eAAA,GAAA,CAAmB,SAAA,QAAiB,CAAA;EAAM,KAAA,EAAO,CAAA;AAAA;AAAA,iBASjD,gBAAA,kBAAA,CAAmC,YAAA,QAAoB,CAAA,GAAI,CAAA;AAAA,iBAS3D,UAAA,GAAA,CAAc,OAAA,EAAS,CAAA,GAAI,CAAA;AAAA,iBAI3B,UAAA,GAAA,CAAc,OAAA,EAAS,CAAA,GAAI,CAAA;AAAA,iBAI3B,SAAA,GAAA,CAAa,MAAA,UAAgB,SAAA,EAAW,CAAA,GAAI,CAAA;AAAA,iBAI5C,YAAA,GAAA,CAAA,GAAmB,UAAA,EAAY,CAAA,KAAM,CAAA;AAAA,iBAIrC,UAAA,GAAA,CAAc,SAAA,EAAW,CAAA,GAAI,CAAA;AAAA,iBAI7B,SAAA,CAAU,MAAA;EAAU,QAAA;EAAmB,YAAA;AAAA;AAAA,iBAKvC,WAAA,CACP,KAAA,UACA,UAAA,qBACA,WAAA,qBACA,cAAA;EAAwC,eAAA;EAA0B,gBAAA;AAAA;AAAA,iBAqB3D,gBAAA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YAAkD,IAAA,CAAA,IAAA;AAAA;AAAA,cAClD,YAAA;YAAuD,IAAA,CAAA,IAAA;AAAA;AAAA,cACvD,YAAA;YAAuD,IAAA,CAAA,IAAA;AAAA;AAAA,cACvD,MAAA;YAAiD,IAAA,CAAA,IAAA;AAAA;AAAA,cACjD,OAAA;YAAkD,IAAA,CAAA,IAAA;AAAA;AAAA,iBAG/C,aAAA,CAAc,KAAA;AAAA,iBAQd,OAAA,eAAsB,IAAA,wBAAA,CAA6B,EAAA,EAAI,CAAA,GAAI,CAAA;AAAA,iBAI3D,OAAA,eAAsB,IAAA,wBAAA,CAA6B,EAAA,EAAI,CAAA,GAAI,CAAA;AAAA,iBAK3D,SAAA,CAAA;AAAA,cAKH,eAAA,EAAe,IAAA,CAAA,IAAA;AAAA,cAGf,OAAA,EAAO,IAAA,CAAA,IAAA;;;;;;;;cAUP,QAAA,EAAQ,IAAA,CAAA,IAAA"}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
import { __exportAll } from "../../_virtual/_rolldown/runtime.js";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
|
|
6
|
+
//#region src/jest/mocks/reanimated.tsx
|
|
7
|
+
var reanimated_exports = /* @__PURE__ */ __exportAll({
|
|
8
|
+
Animated: () => Animated,
|
|
9
|
+
Easing: () => Easing,
|
|
10
|
+
FadeIn: () => FadeIn,
|
|
11
|
+
FadeOut: () => FadeOut,
|
|
12
|
+
SlideInRight: () => SlideInRight,
|
|
13
|
+
SlideOutLeft: () => SlideOutLeft,
|
|
14
|
+
ZoomIn: () => ZoomIn,
|
|
15
|
+
ZoomOut: () => ZoomOut,
|
|
16
|
+
cancelAnimation: () => cancelAnimation,
|
|
17
|
+
convertToRGBA: () => convertToRGBA,
|
|
18
|
+
createAnimatedComponent: () => createAnimatedComponent,
|
|
19
|
+
default: () => Animated,
|
|
20
|
+
interpolate: () => interpolate,
|
|
21
|
+
interpolateColor: () => interpolateColor,
|
|
22
|
+
isWorklet: () => isWorklet,
|
|
23
|
+
measure: () => measure,
|
|
24
|
+
runOnJS: () => runOnJS,
|
|
25
|
+
runOnUI: () => runOnUI,
|
|
26
|
+
scrollTo: () => scrollTo,
|
|
27
|
+
useAnimatedGestureHandler: () => useAnimatedGestureHandler,
|
|
28
|
+
useAnimatedProps: () => useAnimatedProps,
|
|
29
|
+
useAnimatedReaction: () => useAnimatedReaction,
|
|
30
|
+
useAnimatedRef: () => useAnimatedRef,
|
|
31
|
+
useAnimatedScrollHandler: () => useAnimatedScrollHandler,
|
|
32
|
+
useAnimatedStyle: () => useAnimatedStyle,
|
|
33
|
+
useDerivedValue: () => useDerivedValue,
|
|
34
|
+
useSharedValue: () => useSharedValue,
|
|
35
|
+
withDecay: () => withDecay,
|
|
36
|
+
withDelay: () => withDelay,
|
|
37
|
+
withRepeat: () => withRepeat,
|
|
38
|
+
withSequence: () => withSequence,
|
|
39
|
+
withSpring: () => withSpring,
|
|
40
|
+
withTiming: () => withTiming
|
|
41
|
+
});
|
|
42
|
+
function useSharedValue(initialValue) {
|
|
43
|
+
return {
|
|
44
|
+
value: initialValue,
|
|
45
|
+
addListener: jest.fn(),
|
|
46
|
+
removeListener: jest.fn(),
|
|
47
|
+
modify: jest.fn()
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function useDerivedValue(derivedFn) {
|
|
51
|
+
try {
|
|
52
|
+
return { value: derivedFn() };
|
|
53
|
+
} catch {
|
|
54
|
+
return { value: void 0 };
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function useAnimatedStyle(styleWorklet) {
|
|
58
|
+
try {
|
|
59
|
+
return styleWorklet();
|
|
60
|
+
} catch {
|
|
61
|
+
return {};
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function withTiming(toValue) {
|
|
65
|
+
return toValue;
|
|
66
|
+
}
|
|
67
|
+
function withSpring(toValue) {
|
|
68
|
+
return toValue;
|
|
69
|
+
}
|
|
70
|
+
function withDelay(_delay, animation) {
|
|
71
|
+
return animation;
|
|
72
|
+
}
|
|
73
|
+
function withSequence(...animations) {
|
|
74
|
+
return animations[animations.length - 1];
|
|
75
|
+
}
|
|
76
|
+
function withRepeat(animation) {
|
|
77
|
+
return animation;
|
|
78
|
+
}
|
|
79
|
+
function withDecay(config) {
|
|
80
|
+
return config.velocity ?? 0;
|
|
81
|
+
}
|
|
82
|
+
function interpolate(value, inputRange, outputRange, _extrapolation) {
|
|
83
|
+
if (value <= inputRange[0]) return outputRange[0];
|
|
84
|
+
if (value >= inputRange[inputRange.length - 1]) return outputRange[outputRange.length - 1];
|
|
85
|
+
for (let i = 0; i < inputRange.length - 1; i++) if (value >= inputRange[i] && value <= inputRange[i + 1]) {
|
|
86
|
+
const progress = (value - inputRange[i]) / (inputRange[i + 1] - inputRange[i]);
|
|
87
|
+
return outputRange[i] + progress * (outputRange[i + 1] - outputRange[i]);
|
|
88
|
+
}
|
|
89
|
+
return outputRange[outputRange.length - 1];
|
|
90
|
+
}
|
|
91
|
+
function interpolateColor(value, inputRange, outputRange) {
|
|
92
|
+
if (value <= inputRange[0]) return outputRange[0];
|
|
93
|
+
if (value >= inputRange[inputRange.length - 1]) return outputRange[outputRange.length - 1];
|
|
94
|
+
const index = Math.round((value - inputRange[0]) / (inputRange[inputRange.length - 1] - inputRange[0]) * (outputRange.length - 1));
|
|
95
|
+
return outputRange[Math.min(index, outputRange.length - 1)];
|
|
96
|
+
}
|
|
97
|
+
const Easing = {
|
|
98
|
+
linear: (t) => t,
|
|
99
|
+
ease: (t) => t,
|
|
100
|
+
quad: (t) => t * t,
|
|
101
|
+
cubic: (t) => t * t * t,
|
|
102
|
+
poly: (_n) => (t) => t,
|
|
103
|
+
sin: (t) => t,
|
|
104
|
+
circle: (t) => t,
|
|
105
|
+
exp: (t) => t,
|
|
106
|
+
elastic: (_bounciness) => (t) => t,
|
|
107
|
+
back: (_s) => (t) => t,
|
|
108
|
+
bounce: (t) => t,
|
|
109
|
+
bezier: () => (t) => t,
|
|
110
|
+
bezierFn: () => (t) => t,
|
|
111
|
+
in: (easing) => easing,
|
|
112
|
+
out: (easing) => easing,
|
|
113
|
+
inOut: (easing) => easing
|
|
114
|
+
};
|
|
115
|
+
function useAnimatedGestureHandler() {
|
|
116
|
+
return {};
|
|
117
|
+
}
|
|
118
|
+
function useAnimatedScrollHandler() {
|
|
119
|
+
return {};
|
|
120
|
+
}
|
|
121
|
+
function useAnimatedProps(propsWorklet) {
|
|
122
|
+
try {
|
|
123
|
+
return propsWorklet();
|
|
124
|
+
} catch {
|
|
125
|
+
return {};
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
function useAnimatedRef() {
|
|
129
|
+
return { current: null };
|
|
130
|
+
}
|
|
131
|
+
function useAnimatedReaction() {}
|
|
132
|
+
function MockView({ children, style, testID, ...props }) {
|
|
133
|
+
return React.createElement("View", {
|
|
134
|
+
style,
|
|
135
|
+
testID,
|
|
136
|
+
...props
|
|
137
|
+
}, children);
|
|
138
|
+
}
|
|
139
|
+
function MockText({ children, style, testID, ...props }) {
|
|
140
|
+
return React.createElement("Text", {
|
|
141
|
+
style,
|
|
142
|
+
testID,
|
|
143
|
+
...props
|
|
144
|
+
}, children);
|
|
145
|
+
}
|
|
146
|
+
function MockScrollView({ children, style, testID, ...props }) {
|
|
147
|
+
return React.createElement("ScrollView", {
|
|
148
|
+
style,
|
|
149
|
+
testID,
|
|
150
|
+
...props
|
|
151
|
+
}, children);
|
|
152
|
+
}
|
|
153
|
+
function MockImage({ style, testID = "AnimatedImage", ...props }) {
|
|
154
|
+
return React.createElement("Image", {
|
|
155
|
+
style,
|
|
156
|
+
testID,
|
|
157
|
+
...props
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
function createAnimatedComponent(Component) {
|
|
161
|
+
function AnimatedComponent({ children, style, ...props }) {
|
|
162
|
+
return /* @__PURE__ */ jsx(Component, {
|
|
163
|
+
style: Array.isArray(style) ? Object.assign({}, ...style) : style,
|
|
164
|
+
...props,
|
|
165
|
+
children
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
AnimatedComponent.displayName = `Animated(${Component.displayName || Component.name || "Component"})`;
|
|
169
|
+
return AnimatedComponent;
|
|
170
|
+
}
|
|
171
|
+
const Animated = {
|
|
172
|
+
View: MockView,
|
|
173
|
+
Text: MockText,
|
|
174
|
+
Image: MockImage,
|
|
175
|
+
ScrollView: MockScrollView,
|
|
176
|
+
createAnimatedComponent
|
|
177
|
+
};
|
|
178
|
+
const FadeIn = { duration: jest.fn().mockReturnThis() };
|
|
179
|
+
const FadeOut = { duration: jest.fn().mockReturnThis() };
|
|
180
|
+
const SlideInRight = { duration: jest.fn().mockReturnThis() };
|
|
181
|
+
const SlideOutLeft = { duration: jest.fn().mockReturnThis() };
|
|
182
|
+
const ZoomIn = { duration: jest.fn().mockReturnThis() };
|
|
183
|
+
const ZoomOut = { duration: jest.fn().mockReturnThis() };
|
|
184
|
+
function convertToRGBA(color) {
|
|
185
|
+
if (typeof color === "string") return color;
|
|
186
|
+
return `rgba(${color >> 16 & 255}, ${color >> 8 & 255}, ${color & 255}, 1)`;
|
|
187
|
+
}
|
|
188
|
+
function runOnJS(fn) {
|
|
189
|
+
return fn;
|
|
190
|
+
}
|
|
191
|
+
function runOnUI(fn) {
|
|
192
|
+
return fn;
|
|
193
|
+
}
|
|
194
|
+
function isWorklet() {
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
const cancelAnimation = jest.fn();
|
|
198
|
+
const measure = jest.fn(() => ({
|
|
199
|
+
x: 0,
|
|
200
|
+
y: 0,
|
|
201
|
+
width: 100,
|
|
202
|
+
height: 100,
|
|
203
|
+
pageX: 0,
|
|
204
|
+
pageY: 0
|
|
205
|
+
}));
|
|
206
|
+
const scrollTo = jest.fn();
|
|
207
|
+
|
|
208
|
+
//#endregion
|
|
209
|
+
export { Animated, Animated as default, Easing, FadeIn, FadeOut, SlideInRight, SlideOutLeft, ZoomIn, ZoomOut, cancelAnimation, convertToRGBA, createAnimatedComponent, interpolate, interpolateColor, isWorklet, measure, reanimated_exports, runOnJS, runOnUI, scrollTo, useAnimatedGestureHandler, useAnimatedProps, useAnimatedReaction, useAnimatedRef, useAnimatedScrollHandler, useAnimatedStyle, useDerivedValue, useSharedValue, withDecay, withDelay, withRepeat, withSequence, withSpring, withTiming };
|
|
210
|
+
//# sourceMappingURL=reanimated.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reanimated.js","names":[],"sources":["../../../src/jest/mocks/reanimated.tsx"],"sourcesContent":["/**\n * Jest mock for react-native-reanimated.\n *\n * Provides minimal implementations for testing components\n * that use Reanimated animations.\n */\n\n/// <reference types=\"jest\" />\n\nimport type { ComponentType, PropsWithChildren, ReactNode } from 'react';\nimport React from 'react';\n\n// Shared value mock\nfunction useSharedValue<T>(initialValue: T) {\n return {\n value: initialValue,\n addListener: jest.fn(),\n removeListener: jest.fn(),\n modify: jest.fn(),\n };\n}\n\n// Derived value mock\nfunction useDerivedValue<T>(derivedFn: () => T): { value: T } {\n try {\n return { value: derivedFn() };\n } catch {\n return { value: undefined as T };\n }\n}\n\n// Animated style mock - returns empty object for snapshots\nfunction useAnimatedStyle<T extends object>(styleWorklet: () => T): T {\n try {\n return styleWorklet();\n } catch {\n return {} as T;\n }\n}\n\n// Animation timing functions - return the target value immediately\nfunction withTiming<T>(toValue: T): T {\n return toValue;\n}\n\nfunction withSpring<T>(toValue: T): T {\n return toValue;\n}\n\nfunction withDelay<T>(_delay: number, animation: T): T {\n return animation;\n}\n\nfunction withSequence<T>(...animations: T[]): T {\n return animations[animations.length - 1];\n}\n\nfunction withRepeat<T>(animation: T): T {\n return animation;\n}\n\nfunction withDecay(config: { velocity?: number; deceleration?: number }): number {\n return config.velocity ?? 0;\n}\n\n// Interpolation mock\nfunction interpolate(\n value: number,\n inputRange: readonly number[],\n outputRange: readonly number[],\n _extrapolation?: 'clamp' | 'extend' | { extrapolateLeft?: string; extrapolateRight?: string },\n): number {\n // Simple linear interpolation for testing\n if (value <= inputRange[0]) {\n return outputRange[0];\n }\n if (value >= inputRange[inputRange.length - 1]) {\n return outputRange[outputRange.length - 1];\n }\n\n // Find the segment\n for (let i = 0; i < inputRange.length - 1; i++) {\n if (value >= inputRange[i] && value <= inputRange[i + 1]) {\n const progress = (value - inputRange[i]) / (inputRange[i + 1] - inputRange[i]);\n return outputRange[i] + progress * (outputRange[i + 1] - outputRange[i]);\n }\n }\n\n return outputRange[outputRange.length - 1];\n}\n\nfunction interpolateColor(\n value: number,\n inputRange: readonly number[],\n outputRange: readonly string[],\n): string {\n if (value <= inputRange[0]) {\n return outputRange[0];\n }\n if (value >= inputRange[inputRange.length - 1]) {\n return outputRange[outputRange.length - 1];\n }\n // For testing, just return the closest color\n const index = Math.round(\n ((value - inputRange[0]) / (inputRange[inputRange.length - 1] - inputRange[0])) *\n (outputRange.length - 1),\n );\n return outputRange[Math.min(index, outputRange.length - 1)];\n}\n\n// Easing mock\nconst Easing = {\n linear: (t: number) => t,\n ease: (t: number) => t,\n quad: (t: number) => t * t,\n cubic: (t: number) => t * t * t,\n poly: (_n: number) => (t: number) => t,\n sin: (t: number) => t,\n circle: (t: number) => t,\n exp: (t: number) => t,\n elastic: (_bounciness?: number) => (t: number) => t,\n back: (_s?: number) => (t: number) => t,\n bounce: (t: number) => t,\n bezier: () => (t: number) => t,\n bezierFn: () => (t: number) => t,\n in: (easing: (t: number) => number) => easing,\n out: (easing: (t: number) => number) => easing,\n inOut: (easing: (t: number) => number) => easing,\n};\n\n// Gesture handler event hooks\nfunction useAnimatedGestureHandler(): Record<string, unknown> {\n return {};\n}\n\nfunction useAnimatedScrollHandler(): Record<string, unknown> {\n return {};\n}\n\n// Animated props\nfunction useAnimatedProps<T extends object>(propsWorklet: () => T): T {\n try {\n return propsWorklet();\n } catch {\n return {} as T;\n }\n}\n\n// Refs\nfunction useAnimatedRef<T>(): { current: T | null } {\n return { current: null };\n}\n\n// Reactions\nfunction useAnimatedReaction(): void {\n // no-op\n}\n\n// Simple mock components that don't depend on react-native imports\n// (to avoid issues with React Native's Jest mock initialization order)\ninterface MockViewProps {\n children?: ReactNode;\n style?: object;\n testID?: string;\n [key: string]: unknown;\n}\n\nfunction MockView({ children, style, testID, ...props }: MockViewProps) {\n // Use a simple div-like structure for Jest\n return React.createElement('View', { style, testID, ...props }, children);\n}\n\nfunction MockText({ children, style, testID, ...props }: MockViewProps) {\n return React.createElement('Text', { style, testID, ...props }, children);\n}\n\nfunction MockScrollView({ children, style, testID, ...props }: MockViewProps) {\n return React.createElement('ScrollView', { style, testID, ...props }, children);\n}\n\nfunction MockImage({ style, testID = 'AnimatedImage', ...props }: MockViewProps) {\n return React.createElement('Image', { style, testID, ...props });\n}\n\n// Animated component factory - creates a pass-through wrapper\nfunction createAnimatedComponent<T extends ComponentType<object>>(Component: T) {\n function AnimatedComponent({ children, style, ...props }: PropsWithChildren<{ style?: object }>) {\n // Flatten animated styles for rendering\n const flatStyle = Array.isArray(style) ? Object.assign({}, ...style) : style;\n const Comp = Component as ComponentType<{ style?: object; children?: ReactNode }>;\n return (\n <Comp style={flatStyle} {...props}>\n {children}\n </Comp>\n );\n }\n AnimatedComponent.displayName = `Animated(${(Component as { displayName?: string }).displayName || Component.name || 'Component'})`;\n return AnimatedComponent;\n}\n\n// Animated namespace with pre-created mock components\nconst Animated = {\n View: MockView,\n Text: MockText,\n Image: MockImage,\n ScrollView: MockScrollView,\n createAnimatedComponent,\n};\n\n// Layout animations\nconst FadeIn = { duration: jest.fn().mockReturnThis() };\nconst FadeOut = { duration: jest.fn().mockReturnThis() };\nconst SlideInRight = { duration: jest.fn().mockReturnThis() };\nconst SlideOutLeft = { duration: jest.fn().mockReturnThis() };\nconst ZoomIn = { duration: jest.fn().mockReturnThis() };\nconst ZoomOut = { duration: jest.fn().mockReturnThis() };\n\n// Color conversion\nfunction convertToRGBA(color: string | number): string {\n if (typeof color === 'string') {\n return color;\n }\n return `rgba(${(color >> 16) & 255}, ${(color >> 8) & 255}, ${color & 255}, 1)`;\n}\n\n// Run on JS/UI\nfunction runOnJS<T extends (...args: unknown[]) => unknown>(fn: T): T {\n return fn;\n}\n\nfunction runOnUI<T extends (...args: unknown[]) => unknown>(fn: T): T {\n return fn;\n}\n\n// Worklet helper\nfunction isWorklet(): boolean {\n return false;\n}\n\n// Cancel animation\nconst cancelAnimation = jest.fn();\n\n// Measure\nconst measure = jest.fn(() => ({\n x: 0,\n y: 0,\n width: 100,\n height: 100,\n pageX: 0,\n pageY: 0,\n}));\n\n// Scroll to\nconst scrollTo = jest.fn();\n\nexport default Animated;\n\nexport {\n Animated,\n cancelAnimation,\n convertToRGBA,\n createAnimatedComponent,\n Easing,\n FadeIn,\n FadeOut,\n interpolate,\n interpolateColor,\n isWorklet,\n measure,\n runOnJS,\n runOnUI,\n scrollTo,\n SlideInRight,\n SlideOutLeft,\n useAnimatedGestureHandler,\n useAnimatedProps,\n useAnimatedReaction,\n useAnimatedRef,\n useAnimatedScrollHandler,\n useAnimatedStyle,\n useDerivedValue,\n useSharedValue,\n withDecay,\n withDelay,\n withRepeat,\n withSequence,\n withSpring,\n withTiming,\n ZoomIn,\n ZoomOut,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,SAAS,eAAkB,cAAiB;AAC1C,QAAO;EACL,OAAO;EACP,aAAa,KAAK,IAAI;EACtB,gBAAgB,KAAK,IAAI;EACzB,QAAQ,KAAK,IAAI;EAClB;;AAIH,SAAS,gBAAmB,WAAkC;AAC5D,KAAI;AACF,SAAO,EAAE,OAAO,WAAW,EAAE;SACvB;AACN,SAAO,EAAE,OAAO,QAAgB;;;AAKpC,SAAS,iBAAmC,cAA0B;AACpE,KAAI;AACF,SAAO,cAAc;SACf;AACN,SAAO,EAAE;;;AAKb,SAAS,WAAc,SAAe;AACpC,QAAO;;AAGT,SAAS,WA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