vitest-native 0.2.1 → 0.4.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.
Files changed (54) hide show
  1. package/CHANGELOG.md +86 -0
  2. package/README.md +268 -9
  3. package/dist/chunk-CZWwpsFl.cjs +43 -0
  4. package/dist/helpers.cjs +10 -0
  5. package/dist/helpers.d.cts +7 -1
  6. package/dist/helpers.d.mts +7 -1
  7. package/dist/helpers.mjs +10 -1
  8. package/dist/{index-CJqS-y_M.d.cts → index-CJIhukN_.d.mts} +58 -4
  9. package/dist/{index-h4vpIkQO.d.mts → index-DEB7OFaJ.d.cts} +60 -2
  10. package/dist/index.cjs +296 -35
  11. package/dist/index.d.cts +1 -1
  12. package/dist/index.d.mts +1 -1
  13. package/dist/index.mjs +292 -33
  14. package/dist/jest-compat/interop.mjs +30 -0
  15. package/dist/jest-compat/jest-globals.d.mts +3 -0
  16. package/dist/jest-compat/jest-globals.mjs +9 -0
  17. package/dist/jest-compat/noop.d.mts +3 -0
  18. package/dist/jest-compat/noop.mjs +7 -0
  19. package/dist/jest-compat/setup.d.mts +3 -0
  20. package/dist/jest-compat/setup.mjs +41 -0
  21. package/dist/jest-compat.cjs +109 -0
  22. package/dist/jest-compat.d.cts +38 -0
  23. package/dist/jest-compat.d.mts +38 -0
  24. package/dist/jest-compat.mjs +104 -0
  25. package/dist/matchers.cjs +69 -0
  26. package/dist/matchers.d.cts +51 -0
  27. package/dist/matchers.d.mts +51 -0
  28. package/dist/matchers.mjs +66 -0
  29. package/dist/native/boundary.mjs +225 -0
  30. package/dist/native/globals.mjs +112 -0
  31. package/dist/native/hooks.mjs +85 -0
  32. package/dist/native/loader.mjs +123 -0
  33. package/dist/native/match.mjs +9 -0
  34. package/dist/native/reset.mjs +170 -0
  35. package/dist/native/resolve.mjs +22 -0
  36. package/dist/native/runner.mjs +18 -0
  37. package/dist/native/setup.mjs +134 -0
  38. package/dist/native/transform.mjs +79 -0
  39. package/dist/native/worker.mjs +96 -0
  40. package/dist/pool-B4mWN3N5.cjs +60 -0
  41. package/dist/pool-oPTZiSXU.mjs +58 -0
  42. package/dist/{preset-map-Bt4dXkZO.cjs → preset-map-C3jxnkiX.cjs} +6 -1
  43. package/dist/{preset-map-D224CC5w.mjs → preset-map-OJm5IWuL.mjs} +6 -1
  44. package/dist/{presets-9Y4ssfiH.cjs → presets-2I68Ipyl.cjs} +768 -122
  45. package/dist/{presets-CWH0gtM0.mjs → presets-DOGXQzYT.mjs} +732 -87
  46. package/dist/presets.cjs +5 -1
  47. package/dist/presets.d.cts +2 -2
  48. package/dist/presets.d.mts +2 -2
  49. package/dist/presets.mjs +2 -2
  50. package/dist/setup.cjs +903 -121
  51. package/dist/setup.mjs +899 -118
  52. package/docs/migrating-from-jest.md +123 -0
  53. package/docs/migrating-from-vitest-react-native.md +109 -0
  54. package/package.json +67 -8
@@ -1,38 +1,27 @@
1
- //#region \0rolldown/runtime.js
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __exportAll = (all, no_symbols) => {
9
- let target = {};
10
- for (var name in all) __defProp(target, name, {
11
- get: all[name],
12
- enumerable: true
13
- });
14
- if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
15
- return target;
16
- };
17
- var __copyProps = (to, from, except, desc) => {
18
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
19
- key = keys[i];
20
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
21
- get: ((k) => from[k]).bind(null, key),
22
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
23
- });
24
- }
25
- return to;
26
- };
27
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
28
- value: mod,
29
- enumerable: true
30
- }) : target, mod));
31
- //#endregion
1
+ const require_chunk = require("./chunk-CZWwpsFl.cjs");
2
+ let node_path = require("node:path");
3
+ node_path = require_chunk.__toESM(node_path);
4
+ let node_module = require("node:module");
32
5
  let vitest = require("vitest");
33
6
  let react = require("react");
34
- react = __toESM(react);
7
+ react = require_chunk.__toESM(react);
35
8
  //#region src/presets/reanimated.ts
9
+ /**
10
+ * Resolve the *active* React Native module — the mock under `engine: 'mock'`
11
+ * (intercepted by the CJS bridge) or real RN under `engine: 'native'` (served by
12
+ * the Node loader hooks). Cached. Lets the reanimated mock's `Animated.View`
13
+ * &co. wrap whichever RN component set is live, so the preset is engine-agnostic.
14
+ */
15
+ let _rnCache = null;
16
+ function getRN() {
17
+ if (_rnCache) return _rnCache;
18
+ try {
19
+ _rnCache = (0, node_module.createRequire)(node_path.default.join(process.env.VITEST_NATIVE_PROJECT_ROOT || process.cwd(), "package.json"))("react-native");
20
+ } catch {
21
+ _rnCache = {};
22
+ }
23
+ return _rnCache;
24
+ }
36
25
  function reanimated() {
37
26
  return {
38
27
  name: "reanimated",
@@ -44,6 +33,10 @@ function reanimated() {
44
33
  "useDerivedValue",
45
34
  "useAnimatedScrollHandler",
46
35
  "useAnimatedGestureHandler",
36
+ "useAnimatedReaction",
37
+ "useAnimatedKeyboard",
38
+ "useReducedMotion",
39
+ "useFrameCallback",
47
40
  "withTiming",
48
41
  "withSpring",
49
42
  "withDecay",
@@ -53,18 +46,80 @@ function reanimated() {
53
46
  "runOnJS",
54
47
  "runOnUI",
55
48
  "createAnimatedComponent",
49
+ "addWhitelistedUIProps",
50
+ "addWhitelistedNativeProps",
51
+ "configureProps",
52
+ "View",
53
+ "Text",
54
+ "Image",
55
+ "ScrollView",
56
+ "FlatList",
56
57
  "Easing",
57
58
  "FadeIn",
58
59
  "FadeOut",
60
+ "FadeInDown",
61
+ "FadeInUp",
62
+ "FadeInLeft",
63
+ "FadeInRight",
64
+ "FadeOutDown",
65
+ "FadeOutUp",
66
+ "FadeOutLeft",
67
+ "FadeOutRight",
59
68
  "SlideInRight",
69
+ "SlideInLeft",
70
+ "SlideInUp",
71
+ "SlideInDown",
72
+ "SlideOutRight",
60
73
  "SlideOutLeft",
74
+ "SlideOutUp",
75
+ "SlideOutDown",
76
+ "ZoomIn",
77
+ "ZoomOut",
78
+ "BounceIn",
79
+ "BounceOut",
80
+ "BounceInDown",
81
+ "BounceInUp",
82
+ "BounceInLeft",
83
+ "BounceInRight",
84
+ "FlipInEasyX",
85
+ "FlipInEasyY",
86
+ "FlipOutEasyX",
87
+ "FlipOutEasyY",
88
+ "LightSpeedInLeft",
89
+ "LightSpeedInRight",
90
+ "LightSpeedOutLeft",
91
+ "LightSpeedOutRight",
92
+ "PinwheelIn",
93
+ "PinwheelOut",
94
+ "StretchInX",
95
+ "StretchInY",
96
+ "StretchOutX",
97
+ "StretchOutY",
98
+ "RotateInDownLeft",
99
+ "RotateInDownRight",
100
+ "RotateInUpLeft",
101
+ "RotateInUpRight",
102
+ "RotateOutDownLeft",
103
+ "RotateOutDownRight",
104
+ "RotateOutUpLeft",
105
+ "RotateOutUpRight",
61
106
  "Layout",
107
+ "LinearTransition",
108
+ "SequencedTransition",
109
+ "FadingTransition",
110
+ "JumpingTransition",
111
+ "CurvedTransition",
112
+ "EntryExitTransition",
62
113
  "interpolate",
63
114
  "Extrapolation",
64
115
  "useAnimatedRef",
65
116
  "measure",
66
117
  "scrollTo",
67
- "cancelAnimation"
118
+ "cancelAnimation",
119
+ "makeMutable",
120
+ "SharedTransition",
121
+ "ReduceMotion",
122
+ "KeyboardState"
68
123
  ],
69
124
  factory: () => {
70
125
  function createSharedValue(init) {
@@ -109,6 +164,23 @@ function reanimated() {
109
164
  function useAnimatedGestureHandler(_handler) {
110
165
  return vitest.vi.fn();
111
166
  }
167
+ function useAnimatedReaction(_prepare, _react, _deps) {}
168
+ function useAnimatedKeyboard() {
169
+ return {
170
+ state: createSharedValue(0),
171
+ height: createSharedValue(0)
172
+ };
173
+ }
174
+ function useReducedMotion() {
175
+ return false;
176
+ }
177
+ function useFrameCallback(_callback, _autostart) {
178
+ return {
179
+ setActive: vitest.vi.fn(),
180
+ isActive: false,
181
+ callbackId: 0
182
+ };
183
+ }
112
184
  function withTiming(toValue, _config, callback) {
113
185
  callback?.({
114
186
  finished: true,
@@ -145,6 +217,9 @@ function reanimated() {
145
217
  function runOnUI(fn) {
146
218
  return fn;
147
219
  }
220
+ function addWhitelistedUIProps(_props) {}
221
+ function addWhitelistedNativeProps(_props) {}
222
+ function configureProps() {}
148
223
  function createAnimatedComponent(component) {
149
224
  const Animated = react.default.forwardRef((props, ref) => {
150
225
  return react.default.createElement(component, {
@@ -155,14 +230,71 @@ function reanimated() {
155
230
  Animated.displayName = `Animated(${component.displayName || component.name || "Component"})`;
156
231
  return Animated;
157
232
  }
233
+ function makeAnimatedHost(name) {
234
+ const Comp = react.default.forwardRef((props, ref) => {
235
+ const Base = getRN()[name];
236
+ if (!Base) throw new Error(`[vitest-native] reanimated preset: react-native '${name}' is unavailable`);
237
+ return react.default.createElement(Base, {
238
+ ...props,
239
+ ref
240
+ });
241
+ });
242
+ Comp.displayName = `Animated.${name}`;
243
+ return Comp;
244
+ }
245
+ const View = makeAnimatedHost("View");
246
+ const Text = makeAnimatedHost("Text");
247
+ const Image = makeAnimatedHost("Image");
248
+ const ScrollView = makeAnimatedHost("ScrollView");
249
+ const FlatList = makeAnimatedHost("FlatList");
250
+ function createLayoutAnim() {
251
+ const obj = {};
252
+ obj.duration = vitest.vi.fn().mockReturnValue(obj);
253
+ obj.delay = vitest.vi.fn().mockReturnValue(obj);
254
+ obj.easing = vitest.vi.fn().mockReturnValue(obj);
255
+ obj.damping = vitest.vi.fn().mockReturnValue(obj);
256
+ obj.stiffness = vitest.vi.fn().mockReturnValue(obj);
257
+ obj.mass = vitest.vi.fn().mockReturnValue(obj);
258
+ obj.overshootClamping = vitest.vi.fn().mockReturnValue(obj);
259
+ obj.restDisplacementThreshold = vitest.vi.fn().mockReturnValue(obj);
260
+ obj.restSpeedThreshold = vitest.vi.fn().mockReturnValue(obj);
261
+ obj.springify = vitest.vi.fn().mockReturnValue(obj);
262
+ obj.withCallback = vitest.vi.fn().mockReturnValue(obj);
263
+ obj.withInitialValues = vitest.vi.fn().mockReturnValue(obj);
264
+ obj.randomDelay = vitest.vi.fn().mockReturnValue(obj);
265
+ obj.build = vitest.vi.fn();
266
+ return obj;
267
+ }
158
268
  return {
159
- default: { createAnimatedComponent },
269
+ default: {
270
+ createAnimatedComponent,
271
+ View,
272
+ Text,
273
+ Image,
274
+ ScrollView,
275
+ FlatList,
276
+ addWhitelistedUIProps,
277
+ addWhitelistedNativeProps,
278
+ configureProps
279
+ },
280
+ addWhitelistedUIProps,
281
+ addWhitelistedNativeProps,
282
+ configureProps,
283
+ View,
284
+ Text,
285
+ Image,
286
+ ScrollView,
287
+ FlatList,
160
288
  useSharedValue,
161
289
  useAnimatedStyle,
162
290
  useAnimatedProps,
163
291
  useDerivedValue,
164
292
  useAnimatedScrollHandler,
165
293
  useAnimatedGestureHandler,
294
+ useAnimatedReaction,
295
+ useAnimatedKeyboard,
296
+ useReducedMotion,
297
+ useFrameCallback,
166
298
  withTiming,
167
299
  withSpring,
168
300
  withDecay,
@@ -182,28 +314,61 @@ function reanimated() {
182
314
  out: vitest.vi.fn((fn) => fn),
183
315
  inOut: vitest.vi.fn((fn) => fn)
184
316
  },
185
- FadeIn: {
186
- duration: vitest.vi.fn().mockReturnThis(),
187
- delay: vitest.vi.fn().mockReturnThis(),
188
- build: vitest.vi.fn()
189
- },
190
- FadeOut: {
191
- duration: vitest.vi.fn().mockReturnThis(),
192
- delay: vitest.vi.fn().mockReturnThis(),
193
- build: vitest.vi.fn()
194
- },
195
- SlideInRight: {
196
- duration: vitest.vi.fn().mockReturnThis(),
197
- build: vitest.vi.fn()
198
- },
199
- SlideOutLeft: {
200
- duration: vitest.vi.fn().mockReturnThis(),
201
- build: vitest.vi.fn()
202
- },
203
- Layout: {
204
- duration: vitest.vi.fn().mockReturnThis(),
205
- build: vitest.vi.fn()
206
- },
317
+ FadeIn: createLayoutAnim(),
318
+ FadeOut: createLayoutAnim(),
319
+ FadeInDown: createLayoutAnim(),
320
+ FadeInUp: createLayoutAnim(),
321
+ FadeInLeft: createLayoutAnim(),
322
+ FadeInRight: createLayoutAnim(),
323
+ FadeOutDown: createLayoutAnim(),
324
+ FadeOutUp: createLayoutAnim(),
325
+ FadeOutLeft: createLayoutAnim(),
326
+ FadeOutRight: createLayoutAnim(),
327
+ SlideInRight: createLayoutAnim(),
328
+ SlideInLeft: createLayoutAnim(),
329
+ SlideInUp: createLayoutAnim(),
330
+ SlideInDown: createLayoutAnim(),
331
+ SlideOutRight: createLayoutAnim(),
332
+ SlideOutLeft: createLayoutAnim(),
333
+ SlideOutUp: createLayoutAnim(),
334
+ SlideOutDown: createLayoutAnim(),
335
+ ZoomIn: createLayoutAnim(),
336
+ ZoomOut: createLayoutAnim(),
337
+ BounceIn: createLayoutAnim(),
338
+ BounceOut: createLayoutAnim(),
339
+ BounceInDown: createLayoutAnim(),
340
+ BounceInUp: createLayoutAnim(),
341
+ BounceInLeft: createLayoutAnim(),
342
+ BounceInRight: createLayoutAnim(),
343
+ FlipInEasyX: createLayoutAnim(),
344
+ FlipInEasyY: createLayoutAnim(),
345
+ FlipOutEasyX: createLayoutAnim(),
346
+ FlipOutEasyY: createLayoutAnim(),
347
+ LightSpeedInLeft: createLayoutAnim(),
348
+ LightSpeedInRight: createLayoutAnim(),
349
+ LightSpeedOutLeft: createLayoutAnim(),
350
+ LightSpeedOutRight: createLayoutAnim(),
351
+ PinwheelIn: createLayoutAnim(),
352
+ PinwheelOut: createLayoutAnim(),
353
+ StretchInX: createLayoutAnim(),
354
+ StretchInY: createLayoutAnim(),
355
+ StretchOutX: createLayoutAnim(),
356
+ StretchOutY: createLayoutAnim(),
357
+ RotateInDownLeft: createLayoutAnim(),
358
+ RotateInDownRight: createLayoutAnim(),
359
+ RotateInUpLeft: createLayoutAnim(),
360
+ RotateInUpRight: createLayoutAnim(),
361
+ RotateOutDownLeft: createLayoutAnim(),
362
+ RotateOutDownRight: createLayoutAnim(),
363
+ RotateOutUpLeft: createLayoutAnim(),
364
+ RotateOutUpRight: createLayoutAnim(),
365
+ Layout: createLayoutAnim(),
366
+ LinearTransition: createLayoutAnim(),
367
+ SequencedTransition: createLayoutAnim(),
368
+ FadingTransition: createLayoutAnim(),
369
+ JumpingTransition: createLayoutAnim(),
370
+ CurvedTransition: createLayoutAnim(),
371
+ EntryExitTransition: createLayoutAnim(),
207
372
  interpolate: vitest.vi.fn((_value, input, output) => output[0]),
208
373
  Extrapolation: {
209
374
  CLAMP: "clamp",
@@ -220,13 +385,66 @@ function reanimated() {
220
385
  pageY: 0
221
386
  })),
222
387
  scrollTo: vitest.vi.fn(),
223
- cancelAnimation: vitest.vi.fn()
388
+ cancelAnimation: vitest.vi.fn(),
389
+ makeMutable: vitest.vi.fn((init) => createSharedValue(init)),
390
+ SharedTransition: {
391
+ duration: vitest.vi.fn().mockReturnThis(),
392
+ custom: vitest.vi.fn().mockReturnThis(),
393
+ progressAnimation: vitest.vi.fn().mockReturnThis(),
394
+ defaultTransitionType: vitest.vi.fn().mockReturnThis()
395
+ },
396
+ ReduceMotion: {
397
+ System: "system",
398
+ Always: "always",
399
+ Never: "never"
400
+ },
401
+ KeyboardState: {
402
+ UNKNOWN: 0,
403
+ OPENING: 1,
404
+ OPEN: 2,
405
+ CLOSING: 3,
406
+ CLOSED: 4
407
+ }
224
408
  };
225
409
  }
226
410
  } }
227
411
  };
228
412
  }
229
413
  //#endregion
414
+ //#region src/mocks/components/pressableHost.ts
415
+ function buildPressableHostProps(props, ref) {
416
+ const { disabled, accessibilityState, onPress, onPressIn, onPressOut, onLongPress, ...rest } = props;
417
+ const mergedA11yState = disabled || accessibilityState ? {
418
+ ...accessibilityState,
419
+ ...disabled ? { disabled: true } : {}
420
+ } : void 0;
421
+ return {
422
+ accessible: true,
423
+ ...disabled ? {} : {
424
+ onStartShouldSetResponder: () => true,
425
+ onResponderGrant: (e) => onPressIn?.(e),
426
+ onResponderRelease: (e) => {
427
+ onPress?.(e);
428
+ onPressOut?.(e);
429
+ },
430
+ onPress,
431
+ onPressIn,
432
+ onPressOut,
433
+ onLongPress
434
+ },
435
+ ...rest,
436
+ ...mergedA11yState ? { accessibilityState: mergedA11yState } : {},
437
+ ref
438
+ };
439
+ }
440
+ //#endregion
441
+ //#region src/mocks/components/Pressable.ts
442
+ function createPressableMock() {
443
+ const Pressable = react.default.forwardRef((props, ref) => react.default.createElement("Pressable", buildPressableHostProps(props, ref)));
444
+ Pressable.displayName = "Pressable";
445
+ return Pressable;
446
+ }
447
+ //#endregion
230
448
  //#region src/presets/gesture-handler.ts
231
449
  function gestureHandler() {
232
450
  return {
@@ -254,7 +472,13 @@ function gestureHandler() {
254
472
  "TouchableOpacity",
255
473
  "TouchableHighlight",
256
474
  "TouchableWithoutFeedback",
257
- "TouchableNativeFeedback"
475
+ "TouchableNativeFeedback",
476
+ "Pressable",
477
+ "RectButton",
478
+ "BaseButton",
479
+ "BorderlessButton",
480
+ "RawButton",
481
+ "PureNativeButton"
258
482
  ],
259
483
  factory: () => {
260
484
  const State = {
@@ -372,7 +596,13 @@ function gestureHandler() {
372
596
  TouchableOpacity: createGestureHandler("GH-TouchableOpacity"),
373
597
  TouchableHighlight: createGestureHandler("GH-TouchableHighlight"),
374
598
  TouchableWithoutFeedback: createGestureHandler("GH-TouchableWithoutFeedback"),
375
- TouchableNativeFeedback: createGestureHandler("GH-TouchableNativeFeedback")
599
+ TouchableNativeFeedback: createGestureHandler("GH-TouchableNativeFeedback"),
600
+ Pressable: createPressableMock(),
601
+ RectButton: createGestureHandler("RectButton"),
602
+ BaseButton: createGestureHandler("BaseButton"),
603
+ BorderlessButton: createGestureHandler("BorderlessButton"),
604
+ RawButton: createGestureHandler("RawButton"),
605
+ PureNativeButton: createGestureHandler("PureNativeButton")
376
606
  };
377
607
  }
378
608
  } }
@@ -399,19 +629,25 @@ function safeAreaContext() {
399
629
  "Metrics"
400
630
  ],
401
631
  factory: () => {
632
+ const defaultInsets = {
633
+ top: 47,
634
+ right: 0,
635
+ bottom: 34,
636
+ left: 0
637
+ };
638
+ const defaultFrame = {
639
+ x: 0,
640
+ y: 0,
641
+ width: 390,
642
+ height: 844
643
+ };
644
+ const state = {
645
+ insets: { ...defaultInsets },
646
+ frame: { ...defaultFrame }
647
+ };
402
648
  const initialMetrics = {
403
- frame: {
404
- x: 0,
405
- y: 0,
406
- width: 390,
407
- height: 844
408
- },
409
- insets: {
410
- top: 47,
411
- right: 0,
412
- bottom: 34,
413
- left: 0
414
- }
649
+ frame: state.frame,
650
+ insets: state.insets
415
651
  };
416
652
  const SafeAreaProvider = react.default.forwardRef((props, ref) => react.default.createElement("SafeAreaProvider", {
417
653
  ...props,
@@ -423,19 +659,19 @@ function safeAreaContext() {
423
659
  ref
424
660
  }, props.children));
425
661
  SafeAreaView.displayName = "SafeAreaView";
426
- const SafeAreaInsetsContext = react.default.createContext(initialMetrics.insets);
427
- const SafeAreaFrameContext = react.default.createContext(initialMetrics.frame);
662
+ const SafeAreaInsetsContext = react.default.createContext(state.insets);
663
+ const SafeAreaFrameContext = react.default.createContext(state.frame);
428
664
  function useSafeAreaInsets() {
429
- return initialMetrics.insets;
665
+ return state.insets;
430
666
  }
431
667
  function useSafeAreaFrame() {
432
- return initialMetrics.frame;
668
+ return state.frame;
433
669
  }
434
670
  function withSafeAreaInsets(WrappedComponent) {
435
671
  const WithSafeAreaInsets = react.default.forwardRef((props, ref) => react.default.createElement(WrappedComponent, {
436
672
  ...props,
437
673
  ref,
438
- insets: initialMetrics.insets
674
+ insets: state.insets
439
675
  }));
440
676
  WithSafeAreaInsets.displayName = `withSafeAreaInsets(${WrappedComponent.displayName || WrappedComponent.name || "Component"})`;
441
677
  return WithSafeAreaInsets;
@@ -453,10 +689,17 @@ function safeAreaContext() {
453
689
  useSafeAreaFrame,
454
690
  withSafeAreaInsets,
455
691
  initialWindowMetrics: initialMetrics,
456
- initialWindowSafeAreaInsets: initialMetrics.insets,
692
+ initialWindowSafeAreaInsets: state.insets,
457
693
  EdgeInsets: vitest.vi.fn(),
458
694
  Rect: vitest.vi.fn(),
459
- Metrics: vitest.vi.fn()
695
+ Metrics: vitest.vi.fn(),
696
+ _setInsets: (insets) => {
697
+ Object.assign(state.insets, insets);
698
+ },
699
+ _reset: () => {
700
+ Object.assign(state.insets, defaultInsets);
701
+ Object.assign(state.frame, defaultFrame);
702
+ }
460
703
  };
461
704
  }
462
705
  } }
@@ -464,7 +707,76 @@ function safeAreaContext() {
464
707
  }
465
708
  //#endregion
466
709
  //#region src/presets/navigation.ts
710
+ /** Builds a minimal navigation prop matching useNavigation()'s shape. */
711
+ function createMockNavigation() {
712
+ return {
713
+ navigate: vitest.vi.fn(),
714
+ goBack: vitest.vi.fn(),
715
+ reset: vitest.vi.fn(),
716
+ setParams: vitest.vi.fn(),
717
+ setOptions: vitest.vi.fn(),
718
+ dispatch: vitest.vi.fn(),
719
+ canGoBack: vitest.vi.fn(() => false),
720
+ getParent: vitest.vi.fn(() => void 0),
721
+ getState: vitest.vi.fn(() => ({
722
+ index: 0,
723
+ key: "root",
724
+ routeNames: [],
725
+ routes: [],
726
+ type: "stack",
727
+ stale: false
728
+ })),
729
+ isFocused: vitest.vi.fn(() => true),
730
+ addListener: vitest.vi.fn(() => vitest.vi.fn()),
731
+ removeListener: vitest.vi.fn(),
732
+ getId: vitest.vi.fn(() => void 0)
733
+ };
734
+ }
735
+ /**
736
+ * Creates a Screen component mock that handles all three React Navigation patterns:
737
+ * 1. <Screen component={Comp} /> — renders Comp with route & navigation props
738
+ * 2. <Screen>{(props) => <Comp />}</Screen> — calls render function
739
+ * 3. <Screen><Something /></Screen> — passes children through
740
+ *
741
+ * Accepts NavigationContext and NavigationRouteContext so that hooks like
742
+ * useNavigation() and useRoute() inside the screen component return values
743
+ * consistent with the route/navigation props passed to the component.
744
+ */
745
+ function createMockScreen(NavContext, RouteContext) {
746
+ const Screen = react.default.forwardRef(({ component: Component, children, ...rest }, ref) => {
747
+ const route = {
748
+ key: rest.name ?? "",
749
+ name: rest.name ?? "",
750
+ params: rest.initialParams
751
+ };
752
+ const nav = createMockNavigation();
753
+ const content = Component ? react.default.createElement(Component, {
754
+ route,
755
+ navigation: nav
756
+ }) : typeof children === "function" ? children({
757
+ route,
758
+ navigation: nav
759
+ }) : children;
760
+ return react.default.createElement("Screen", {
761
+ ...rest,
762
+ ref
763
+ }, react.default.createElement(NavContext.Provider, { value: nav }, react.default.createElement(RouteContext.Provider, { value: route }, content)));
764
+ });
765
+ Screen.displayName = "Screen";
766
+ return Screen;
767
+ }
467
768
  function navigation() {
769
+ const NavigationContext = react.default.createContext(null);
770
+ const NavigationRouteContext = react.default.createContext(null);
771
+ const NavigationContainerRefContext = react.default.createContext(null);
772
+ const NavigationHelpersContext = react.default.createContext(null);
773
+ const CurrentRenderContext = react.default.createContext(void 0);
774
+ const ThemeContext = react.default.createContext({
775
+ dark: false,
776
+ colors: {}
777
+ });
778
+ const PreventRemoveContext = react.default.createContext(null);
779
+ const Screen = createMockScreen(NavigationContext, NavigationRouteContext);
468
780
  return {
469
781
  name: "navigation",
470
782
  modules: {
@@ -478,6 +790,7 @@ function navigation() {
478
790
  "useFocusEffect",
479
791
  "useIsFocused",
480
792
  "useNavigationState",
793
+ "useScrollToTop",
481
794
  "useNavigationContainerRef",
482
795
  "createNavigationContainerRef",
483
796
  "createNavigatorFactory",
@@ -534,29 +847,39 @@ function navigation() {
534
847
  type: "stack",
535
848
  stale: false
536
849
  }));
850
+ const defaultNavigation = {
851
+ navigate,
852
+ goBack,
853
+ reset,
854
+ setParams,
855
+ setOptions,
856
+ dispatch,
857
+ canGoBack,
858
+ getParent,
859
+ getState,
860
+ isFocused: vitest.vi.fn(() => true),
861
+ addListener: vitest.vi.fn(() => vitest.vi.fn()),
862
+ removeListener: vitest.vi.fn(),
863
+ getId: vitest.vi.fn(() => void 0)
864
+ };
865
+ const defaultRoute = {
866
+ key: "test-route-key",
867
+ name: "TestScreen",
868
+ params: {}
869
+ };
537
870
  function useNavigation() {
538
- return {
539
- navigate,
540
- goBack,
541
- reset,
542
- setParams,
543
- setOptions,
544
- dispatch,
545
- canGoBack,
546
- getParent,
547
- getState,
548
- isFocused: vitest.vi.fn(() => true),
549
- addListener: vitest.vi.fn(() => vitest.vi.fn()),
550
- removeListener: vitest.vi.fn(),
551
- getId: vitest.vi.fn(() => void 0)
552
- };
871
+ try {
872
+ const ctx = react.default.useContext(NavigationContext);
873
+ if (ctx) return ctx;
874
+ } catch {}
875
+ return defaultNavigation;
553
876
  }
554
877
  function useRoute() {
555
- return {
556
- key: "test-route-key",
557
- name: "TestScreen",
558
- params: {}
559
- };
878
+ try {
879
+ const ctx = react.default.useContext(NavigationRouteContext);
880
+ if (ctx) return ctx;
881
+ } catch {}
882
+ return defaultRoute;
560
883
  }
561
884
  function useFocusEffect(callback) {
562
885
  react.default.useEffect(callback, []);
@@ -589,16 +912,6 @@ function navigation() {
589
912
  function useNavigationContainerRef() {
590
913
  return createNavigationContainerRef();
591
914
  }
592
- const NavigationContext = react.default.createContext(null);
593
- const NavigationRouteContext = react.default.createContext(null);
594
- const NavigationContainerRefContext = react.default.createContext(null);
595
- const NavigationHelpersContext = react.default.createContext(null);
596
- const CurrentRenderContext = react.default.createContext(void 0);
597
- const ThemeContext = react.default.createContext({
598
- dark: false,
599
- colors: {}
600
- });
601
- const PreventRemoveContext = react.default.createContext(null);
602
915
  const defaultTheme = {
603
916
  dark: false,
604
917
  colors: {
@@ -698,6 +1011,7 @@ function navigation() {
698
1011
  getStateForAction: vitest.vi.fn((state) => state),
699
1012
  shouldActionChangeFocus: vitest.vi.fn(() => false)
700
1013
  },
1014
+ useScrollToTop: vitest.vi.fn(),
701
1015
  useLinkTo: vitest.vi.fn(() => vitest.vi.fn()),
702
1016
  Link: react.default.forwardRef((props, ref) => react.default.createElement("Link", {
703
1017
  ...props,
@@ -715,10 +1029,7 @@ function navigation() {
715
1029
  ...props,
716
1030
  ref
717
1031
  }, props.children)),
718
- Screen: react.default.forwardRef((props, ref) => react.default.createElement("Screen", {
719
- ...props,
720
- ref
721
- }, props.children)),
1032
+ Screen,
722
1033
  Group: react.default.forwardRef((props, ref) => react.default.createElement("Group", {
723
1034
  ...props,
724
1035
  ref
@@ -740,10 +1051,29 @@ function navigation() {
740
1051
  ...props,
741
1052
  ref
742
1053
  }, props.children)),
743
- Screen: react.default.forwardRef((props, ref) => react.default.createElement("Screen", {
1054
+ Screen,
1055
+ Group: react.default.forwardRef((props, ref) => react.default.createElement("Group", {
1056
+ ...props,
1057
+ ref
1058
+ }, props.children))
1059
+ };
1060
+ }
1061
+ return {
1062
+ default: { createBottomTabNavigator },
1063
+ createBottomTabNavigator
1064
+ };
1065
+ }
1066
+ },
1067
+ "@react-navigation/drawer": {
1068
+ exports: ["createDrawerNavigator"],
1069
+ factory: () => {
1070
+ function createDrawerNavigator() {
1071
+ return {
1072
+ Navigator: react.default.forwardRef((props, ref) => react.default.createElement("DrawerNavigator", {
744
1073
  ...props,
745
1074
  ref
746
1075
  }, props.children)),
1076
+ Screen,
747
1077
  Group: react.default.forwardRef((props, ref) => react.default.createElement("Group", {
748
1078
  ...props,
749
1079
  ref
@@ -751,8 +1081,8 @@ function navigation() {
751
1081
  };
752
1082
  }
753
1083
  return {
754
- default: { createBottomTabNavigator },
755
- createBottomTabNavigator
1084
+ default: { createDrawerNavigator },
1085
+ createDrawerNavigator
756
1086
  };
757
1087
  }
758
1088
  },
@@ -887,7 +1217,8 @@ function asyncStorage() {
887
1217
  else store.set(key, value);
888
1218
  });
889
1219
  }),
890
- flushGetRequests: vitest.vi.fn(() => {})
1220
+ flushGetRequests: vitest.vi.fn(() => {}),
1221
+ _resetStore: () => store.clear()
891
1222
  };
892
1223
  return {
893
1224
  ...exports,
@@ -1125,27 +1456,324 @@ function expo() {
1125
1456
  };
1126
1457
  }
1127
1458
  //#endregion
1459
+ //#region src/presets/device-info.ts
1460
+ const STRINGS = {
1461
+ getBrand: "Apple",
1462
+ getModel: "iPhone",
1463
+ getDeviceId: "iPhone14,2",
1464
+ getSystemName: "iOS",
1465
+ getSystemVersion: "17.0",
1466
+ getVersion: "1.0.0",
1467
+ getReadableVersion: "1.0.0.1",
1468
+ getBuildNumber: "1",
1469
+ getBundleId: "com.example.app",
1470
+ getApplicationName: "Example",
1471
+ getDeviceName: "iPhone",
1472
+ getUniqueId: "mock-unique-id",
1473
+ getInstallReferrer: "",
1474
+ getDeviceType: "Handset",
1475
+ getUserAgent: "vitest-native",
1476
+ getCarrier: "",
1477
+ getManufacturer: "Apple"
1478
+ };
1479
+ const BOOLEANS = {
1480
+ hasNotch: true,
1481
+ hasDynamicIsland: false,
1482
+ isTablet: false,
1483
+ isEmulator: false,
1484
+ isPinOrFingerprintSet: false,
1485
+ isCameraPresent: true,
1486
+ isLandscape: false,
1487
+ isLowBatteryLevel: false,
1488
+ isHeadphonesConnected: false
1489
+ };
1490
+ const NUMBERS = {
1491
+ getFontScale: 1,
1492
+ getBatteryLevel: 1,
1493
+ getTotalMemory: 4e9,
1494
+ getUsedMemory: 1e9,
1495
+ getApiLevel: 33
1496
+ };
1497
+ function deviceInfo() {
1498
+ const exports = [
1499
+ ...Object.keys(STRINGS),
1500
+ ...Object.keys(BOOLEANS),
1501
+ ...Object.keys(NUMBERS),
1502
+ ...Object.keys(STRINGS).map((k) => k + "Sync"),
1503
+ ...Object.keys(BOOLEANS).map((k) => k + "Sync"),
1504
+ ...Object.keys(NUMBERS).map((k) => k + "Sync")
1505
+ ];
1506
+ return {
1507
+ name: "deviceInfo",
1508
+ modules: { "react-native-device-info": {
1509
+ exports,
1510
+ factory: () => {
1511
+ const api = {};
1512
+ for (const [k, v] of Object.entries({
1513
+ ...STRINGS,
1514
+ ...BOOLEANS,
1515
+ ...NUMBERS
1516
+ })) {
1517
+ api[k] = () => Promise.resolve(v);
1518
+ api[k + "Sync"] = () => v;
1519
+ }
1520
+ for (const k of [
1521
+ "hasNotch",
1522
+ "hasDynamicIsland",
1523
+ "isTablet",
1524
+ "getDeviceType"
1525
+ ]) {
1526
+ const src = {
1527
+ ...STRINGS,
1528
+ ...BOOLEANS
1529
+ };
1530
+ api[k] = () => src[k];
1531
+ }
1532
+ api.getUniqueIdSync = () => STRINGS.getUniqueId;
1533
+ return {
1534
+ __esModule: true,
1535
+ default: api,
1536
+ ...api
1537
+ };
1538
+ }
1539
+ } }
1540
+ };
1541
+ }
1542
+ //#endregion
1543
+ //#region src/presets/mmkv.ts
1544
+ function mmkv() {
1545
+ return {
1546
+ name: "mmkv",
1547
+ modules: { "react-native-mmkv": {
1548
+ exports: [
1549
+ "MMKV",
1550
+ "createMMKV",
1551
+ "useMMKV",
1552
+ "useMMKVString",
1553
+ "useMMKVNumber",
1554
+ "useMMKVBoolean",
1555
+ "useMMKVObject",
1556
+ "useMMKVBuffer",
1557
+ "useMMKVListener",
1558
+ "Mode"
1559
+ ],
1560
+ factory: () => {
1561
+ class MMKV {
1562
+ _store = /* @__PURE__ */ new Map();
1563
+ set(key, value) {
1564
+ this._store.set(key, value);
1565
+ }
1566
+ getString(key) {
1567
+ const v = this._store.get(key);
1568
+ return typeof v === "string" ? v : void 0;
1569
+ }
1570
+ getNumber(key) {
1571
+ const v = this._store.get(key);
1572
+ return typeof v === "number" ? v : void 0;
1573
+ }
1574
+ getBoolean(key) {
1575
+ const v = this._store.get(key);
1576
+ return typeof v === "boolean" ? v : void 0;
1577
+ }
1578
+ getBuffer(key) {
1579
+ const v = this._store.get(key);
1580
+ return v instanceof Uint8Array ? v : void 0;
1581
+ }
1582
+ contains(key) {
1583
+ return this._store.has(key);
1584
+ }
1585
+ delete(key) {
1586
+ this._store.delete(key);
1587
+ }
1588
+ getAllKeys() {
1589
+ return [...this._store.keys()];
1590
+ }
1591
+ clearAll() {
1592
+ this._store.clear();
1593
+ }
1594
+ recrypt() {}
1595
+ addOnValueChangedListener() {
1596
+ return { remove() {} };
1597
+ }
1598
+ }
1599
+ const shared = new MMKV();
1600
+ const createMMKV = () => new MMKV();
1601
+ const useMMKV = () => shared;
1602
+ function makeHook(get) {
1603
+ return (key, instance) => {
1604
+ const m = instance ?? shared;
1605
+ const [value, setValue] = (0, react.useState)(get(m, key));
1606
+ const set = (v) => {
1607
+ if (v === void 0) m.delete(key);
1608
+ else m.set(key, v);
1609
+ setValue(v);
1610
+ };
1611
+ return [value, set];
1612
+ };
1613
+ }
1614
+ return {
1615
+ __esModule: true,
1616
+ MMKV,
1617
+ createMMKV,
1618
+ useMMKV,
1619
+ useMMKVString: makeHook((m, k) => m.getString(k)),
1620
+ useMMKVNumber: makeHook((m, k) => m.getNumber(k)),
1621
+ useMMKVBoolean: makeHook((m, k) => m.getBoolean(k)),
1622
+ useMMKVBuffer: makeHook((m, k) => m.getBuffer(k)),
1623
+ useMMKVObject: (key, instance) => {
1624
+ const m = instance ?? shared;
1625
+ const raw = m.getString(key);
1626
+ const [value, setValue] = (0, react.useState)(raw ? JSON.parse(raw) : void 0);
1627
+ const set = (v) => {
1628
+ if (v === void 0) m.delete(key);
1629
+ else m.set(key, JSON.stringify(v));
1630
+ setValue(v);
1631
+ };
1632
+ return [value, set];
1633
+ },
1634
+ useMMKVListener: () => ({ remove() {} }),
1635
+ Mode: {
1636
+ SINGLE_PROCESS: 0,
1637
+ MULTI_PROCESS: 1
1638
+ }
1639
+ };
1640
+ }
1641
+ } }
1642
+ };
1643
+ }
1644
+ //#endregion
1645
+ //#region src/presets/svg.ts
1646
+ const SVG_COMPONENTS = [
1647
+ "Svg",
1648
+ "Circle",
1649
+ "Ellipse",
1650
+ "G",
1651
+ "Text",
1652
+ "TSpan",
1653
+ "TextPath",
1654
+ "Path",
1655
+ "Polygon",
1656
+ "Polyline",
1657
+ "Line",
1658
+ "Rect",
1659
+ "Use",
1660
+ "Image",
1661
+ "Symbol",
1662
+ "Defs",
1663
+ "LinearGradient",
1664
+ "RadialGradient",
1665
+ "Stop",
1666
+ "ClipPath",
1667
+ "Pattern",
1668
+ "Mask",
1669
+ "Marker",
1670
+ "ForeignObject",
1671
+ "FeBlend",
1672
+ "FeColorMatrix",
1673
+ "FeGaussianBlur",
1674
+ "FeMerge",
1675
+ "FeOffset"
1676
+ ];
1677
+ function svg() {
1678
+ return {
1679
+ name: "svg",
1680
+ modules: { "react-native-svg": {
1681
+ exports: [
1682
+ ...SVG_COMPONENTS,
1683
+ "SvgXml",
1684
+ "SvgUri",
1685
+ "SvgCss",
1686
+ "SvgCssUri"
1687
+ ],
1688
+ factory: () => {
1689
+ const make = (name) => {
1690
+ const C = react.default.forwardRef((props, ref) => react.default.createElement(name, {
1691
+ ...props,
1692
+ ref
1693
+ }, props.children));
1694
+ C.displayName = name;
1695
+ return C;
1696
+ };
1697
+ const out = { __esModule: true };
1698
+ for (const name of SVG_COMPONENTS) out[name] = make(name);
1699
+ out.SvgXml = make("SvgXml");
1700
+ out.SvgUri = make("SvgUri");
1701
+ out.SvgCss = make("SvgCss");
1702
+ out.SvgCssUri = make("SvgCssUri");
1703
+ out.default = out.Svg;
1704
+ return out;
1705
+ }
1706
+ } }
1707
+ };
1708
+ }
1709
+ //#endregion
1710
+ //#region src/presets/webview.ts
1711
+ function webview() {
1712
+ return {
1713
+ name: "webview",
1714
+ modules: { "react-native-webview": {
1715
+ exports: ["WebView"],
1716
+ factory: () => {
1717
+ const WebView = react.default.forwardRef((props, ref) => {
1718
+ react.default.useImperativeHandle(ref, () => ({
1719
+ reload: () => {},
1720
+ stopLoading: () => {},
1721
+ goBack: () => {},
1722
+ goForward: () => {},
1723
+ injectJavaScript: () => {},
1724
+ postMessage: () => {},
1725
+ clearCache: () => {}
1726
+ }));
1727
+ return react.default.createElement("WebView", props, props.children);
1728
+ });
1729
+ WebView.displayName = "WebView";
1730
+ return {
1731
+ __esModule: true,
1732
+ default: WebView,
1733
+ WebView
1734
+ };
1735
+ }
1736
+ } }
1737
+ };
1738
+ }
1739
+ //#endregion
1128
1740
  //#region src/presets/index.ts
1129
- var presets_exports = /* @__PURE__ */ __exportAll({
1741
+ var presets_exports = /* @__PURE__ */ require_chunk.__exportAll({
1130
1742
  asyncStorage: () => asyncStorage,
1743
+ deviceInfo: () => deviceInfo,
1131
1744
  expo: () => expo,
1132
1745
  gestureHandler: () => gestureHandler,
1746
+ mmkv: () => mmkv,
1133
1747
  navigation: () => navigation,
1134
1748
  reanimated: () => reanimated,
1135
1749
  safeAreaContext: () => safeAreaContext,
1136
- screens: () => screens
1750
+ screens: () => screens,
1751
+ svg: () => svg,
1752
+ webview: () => webview
1137
1753
  });
1138
1754
  //#endregion
1139
- Object.defineProperty(exports, "__toESM", {
1755
+ Object.defineProperty(exports, "asyncStorage", {
1140
1756
  enumerable: true,
1141
1757
  get: function() {
1142
- return __toESM;
1758
+ return asyncStorage;
1143
1759
  }
1144
1760
  });
1145
- Object.defineProperty(exports, "asyncStorage", {
1761
+ Object.defineProperty(exports, "buildPressableHostProps", {
1146
1762
  enumerable: true,
1147
1763
  get: function() {
1148
- return asyncStorage;
1764
+ return buildPressableHostProps;
1765
+ }
1766
+ });
1767
+ Object.defineProperty(exports, "createPressableMock", {
1768
+ enumerable: true,
1769
+ get: function() {
1770
+ return createPressableMock;
1771
+ }
1772
+ });
1773
+ Object.defineProperty(exports, "deviceInfo", {
1774
+ enumerable: true,
1775
+ get: function() {
1776
+ return deviceInfo;
1149
1777
  }
1150
1778
  });
1151
1779
  Object.defineProperty(exports, "expo", {
@@ -1160,6 +1788,12 @@ Object.defineProperty(exports, "gestureHandler", {
1160
1788
  return gestureHandler;
1161
1789
  }
1162
1790
  });
1791
+ Object.defineProperty(exports, "mmkv", {
1792
+ enumerable: true,
1793
+ get: function() {
1794
+ return mmkv;
1795
+ }
1796
+ });
1163
1797
  Object.defineProperty(exports, "navigation", {
1164
1798
  enumerable: true,
1165
1799
  get: function() {
@@ -1190,3 +1824,15 @@ Object.defineProperty(exports, "screens", {
1190
1824
  return screens;
1191
1825
  }
1192
1826
  });
1827
+ Object.defineProperty(exports, "svg", {
1828
+ enumerable: true,
1829
+ get: function() {
1830
+ return svg;
1831
+ }
1832
+ });
1833
+ Object.defineProperty(exports, "webview", {
1834
+ enumerable: true,
1835
+ get: function() {
1836
+ return webview;
1837
+ }
1838
+ });