vitest-native 0.15.0 → 0.15.1

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.
@@ -4,9 +4,8 @@ import { Module, createRequire } from "node:module";
4
4
  import path from "node:path";
5
5
  import fs from "node:fs";
6
6
  import { VitestNativeError } from "./errors.mjs";
7
- import { vi } from "vitest";
8
- import React, { useState } from "react";
9
7
  import { projectContext } from "./context.mjs";
8
+ import { vi } from "vitest";
10
9
  // src/presets/built-in.ts
11
10
  /**
12
11
  * Marks the presets vitest-native's own factories return. A test worker rebuilds a
@@ -21,74 +20,55 @@ function builtInPreset(preset) {
21
20
  Object.defineProperty(preset, BUILT_IN_PRESET, { value: preset.name });
22
21
  return preset;
23
22
  }
24
- // src/mocks/host.ts
23
+ // src/mocks/host-classes.ts
25
24
  /**
26
- * The mock engine's host components, one class per host name.
25
+ * The host classes of one React, by host name.
27
26
  *
28
27
  * A mock that rendered its host as a bare name (`createElement("View", { ...props, ref })`)
29
28
  * gave React 19 the `ref` as a host prop, so the test renderer's `toJSON()` (snapshots,
30
29
  * RNTL) printed `ref={null}` or the ref object, and the ref itself was the renderer's
31
- * node. Rendered through this class, React attaches the ref to the class instance and
32
- * leaves it out of the props the host receives, as the native engine's boundary does for
33
- * React Native's own host components (src/native/boundary.mjs). The instance carries the
34
- * native methods a host ref has on a device and under Jest's component mocks; each is a
35
- * no-op, as at the native engine's boundary.
30
+ * node. Rendered through a class, React attaches the ref to the class instance and leaves
31
+ * it out of the props the host receives, as the native engine's boundary does for React
32
+ * Native's own host components (src/native/boundary.mjs). The instance carries the native
33
+ * methods a host ref has on a device and under Jest's component mocks; each is a no-op,
34
+ * as at the native engine's boundary.
35
+ *
36
+ * Keyed by the React module, which this file does not import: a preset's mock is built
37
+ * with the test file's React (under the hot runtime's freshRuntime, each file has its
38
+ * own), and a class extending another file's React.Component would render with that one.
36
39
  */
37
- const classes = /* @__PURE__ */ new Map();
38
- function hostComponent(name) {
39
- let Host = classes.get(name);
40
- if (!Host) {
41
- Host = class extends React.Component {
42
- static displayName = name;
43
- render() {
44
- return React.createElement(name, this.props);
45
- }
46
- blur() {}
47
- focus() {}
48
- measure() {}
49
- measureInWindow() {}
50
- measureLayout() {}
51
- setNativeProps() {}
52
- };
53
- classes.set(name, Host);
40
+ const byReact = /* @__PURE__ */ new WeakMap();
41
+ /** The host helpers bound to `React`. */
42
+ function hosts(React) {
43
+ let classes = byReact.get(React);
44
+ if (!classes) {
45
+ classes = /* @__PURE__ */ new Map();
46
+ byReact.set(React, classes);
54
47
  }
55
- return Host;
56
- }
57
- /**
58
- * A type for createElement: a host name through its class (as hostComponent), anything
59
- * else, a component, as it is. For mocks whose host type is a variable.
60
- */
61
- function asHost(type) {
62
- return typeof type === "string" ? hostComponent(type) : type;
63
- }
64
- // src/mocks/components/View.ts
65
- function createViewMock() {
66
- const View = React.forwardRef((props, ref) => {
67
- return React.createElement(hostComponent("View"), {
68
- ...props,
69
- ref
70
- });
71
- });
72
- View.displayName = "View";
73
- return View;
74
- }
75
- // src/mocks/components/ScrollView.ts
76
- function createScrollViewMock() {
77
- const ScrollView = React.forwardRef((props, ref) => {
78
- const { children, refreshControl, ...rest } = props;
79
- const instanceMethods = {
80
- scrollTo: vi.fn(),
81
- scrollToEnd: vi.fn(),
82
- flashScrollIndicators: vi.fn(),
83
- getScrollResponder: vi.fn(() => ({})),
84
- getInnerViewNode: vi.fn(),
85
- setNativeProps: vi.fn()
86
- };
87
- React.useImperativeHandle(ref, () => instanceMethods);
88
- return React.createElement("RCTScrollView", rest, refreshControl, React.createElement("View", null, children));
89
- });
90
- ScrollView.displayName = "ScrollView";
91
- return ScrollView;
48
+ const known = classes;
49
+ const hostComponent = (name) => {
50
+ let Host = known.get(name);
51
+ if (!Host) {
52
+ Host = class extends React.Component {
53
+ static displayName = name;
54
+ render() {
55
+ return React.createElement(name, this.props);
56
+ }
57
+ blur() {}
58
+ focus() {}
59
+ measure() {}
60
+ measureInWindow() {}
61
+ measureLayout() {}
62
+ setNativeProps() {}
63
+ };
64
+ known.set(name, Host);
65
+ }
66
+ return Host;
67
+ };
68
+ return {
69
+ hostComponent,
70
+ asHost: (type) => typeof type === "string" ? hostComponent(type) : type
71
+ };
92
72
  }
93
73
  // src/presets/esm-export-names.ts
94
74
  /** Metro's order for a module path without an extension: platform files first. */
@@ -228,17 +208,17 @@ function libraryMockModule(mock, fallback) {
228
208
  }
229
209
  return fallback.exportsFor ? fallback.exportsFor(context) : fallback.exports;
230
210
  },
231
- factory() {
211
+ factory(context) {
232
212
  const root = workerRoot$1();
233
213
  const dir = underNativeEngine() ? libraryMockDir(mock, root) : null;
234
214
  if (dir) {
235
215
  const loaded = createRequire(path.join(root, "package.json"))(`${mock.pkg}/${mock.entry ?? mock.file}`);
236
216
  const module = mock.exportKey ? loaded?.[mock.exportKey] : loaded;
237
- if (module === void 0) return fallback.factory();
238
- const extended = mock.extend ? mock.extend(module, dir) : module;
239
- return mock.keepsPresetNames ? withPresetNames(extended, fallback) : extended;
217
+ if (module === void 0) return fallback.factory(context);
218
+ const extended = mock.extend ? mock.extend(module, dir, context) : module;
219
+ return mock.keepsPresetNames ? withPresetNames(extended, fallback, context) : extended;
240
220
  }
241
- return fallback.factory();
221
+ return fallback.factory(context);
242
222
  }
243
223
  };
244
224
  }
@@ -250,7 +230,7 @@ function presetNames(fallback, context) {
250
230
  * `module` with the preset's own names it lacks, read from the preset's module when one
251
231
  * is first read (it is built once, then). The library's mock object is left as it is.
252
232
  */
253
- function withPresetNames(module, fallback) {
233
+ function withPresetNames(module, fallback, context) {
254
234
  if (module === null || typeof module !== "object") return module;
255
235
  const missing = (Array.isArray(fallback.exports) ? fallback.exports : []).filter((name) => name !== "default" && !(name in module));
256
236
  if (missing.length === 0) return module;
@@ -259,7 +239,7 @@ function withPresetNames(module, fallback) {
259
239
  for (const name of missing) Object.defineProperty(merged, name, {
260
240
  enumerable: true,
261
241
  configurable: true,
262
- get: () => (own ??= fallback.factory())[name]
242
+ get: () => (own ??= fallback.factory(context))[name]
263
243
  });
264
244
  return merged;
265
245
  }
@@ -272,294 +252,6 @@ function namesIn(file) {
272
252
  return [];
273
253
  }
274
254
  }
275
- // src/presets/keyboard-controller.ts
276
- const KEYBOARD_CONTROLLER_MOCK = {
277
- pkg: "react-native-keyboard-controller",
278
- entry: "jest",
279
- file: "jest/index.js"
280
- };
281
- function keyboardController() {
282
- return builtInPreset({
283
- name: "keyboardController",
284
- modules: { "react-native-keyboard-controller": libraryMockModule(KEYBOARD_CONTROLLER_MOCK, {
285
- exports: [
286
- "KeyboardProvider",
287
- "KeyboardControllerView",
288
- "KeyboardGestureArea",
289
- "OverKeyboardView",
290
- "KeyboardBackgroundView",
291
- "KeyboardExtender",
292
- "KeyboardStickyView",
293
- "KeyboardAvoidingView",
294
- "KeyboardAwareScrollView",
295
- "KeyboardChatScrollView",
296
- "KeyboardToolbar",
297
- "KeyboardController",
298
- "KeyboardEvents",
299
- "AndroidSoftInputModes",
300
- "DefaultKeyboardToolbarTheme",
301
- "useKeyboardAnimation",
302
- "useReanimatedKeyboardAnimation",
303
- "useResizeMode",
304
- "useGenericKeyboardHandler",
305
- "useKeyboardHandler",
306
- "useKeyboardContext",
307
- "useKeyboardState",
308
- "useReanimatedFocusedInput",
309
- "useFocusedInputHandler",
310
- "useKeyboardController",
311
- "useWindowDimensions"
312
- ],
313
- factory: () => {
314
- function hostComponent(name) {
315
- const Component = React.forwardRef((props, ref) => React.createElement(asHost(name), {
316
- ...props,
317
- ref
318
- }, props.children));
319
- Component.displayName = name;
320
- return Component;
321
- }
322
- const sharedValue = (value) => ({
323
- value,
324
- get: () => value,
325
- set: () => {}
326
- });
327
- const animationValues = {
328
- animated: {
329
- progress: sharedValue(0),
330
- height: sharedValue(0)
331
- },
332
- reanimated: {
333
- progress: sharedValue(0),
334
- height: sharedValue(0)
335
- }
336
- };
337
- const lastKeyboardEvent = {
338
- height: 0,
339
- duration: 0,
340
- timestamp: 0,
341
- target: 0,
342
- type: "default",
343
- appearance: "default"
344
- };
345
- const keyboardState = {
346
- ...lastKeyboardEvent,
347
- isVisible: false
348
- };
349
- const focusedInput = { input: sharedValue({
350
- target: 1,
351
- parentScrollViewTarget: -1,
352
- layout: {
353
- x: 0,
354
- y: 0,
355
- width: 200,
356
- height: 40,
357
- absoluteX: 0,
358
- absoluteY: 100
359
- }
360
- }) };
361
- const KeyboardToolbar = Object.assign(createViewMock(), {
362
- Background: hostComponent("KeyboardToolbar.Background"),
363
- Content: hostComponent("KeyboardToolbar.Content"),
364
- Prev: hostComponent("KeyboardToolbar.Prev"),
365
- Next: hostComponent("KeyboardToolbar.Next"),
366
- Done: hostComponent("KeyboardToolbar.Done"),
367
- Group: hostComponent("KeyboardToolbar.Group")
368
- });
369
- return {
370
- KeyboardProvider: hostComponent("KeyboardProvider"),
371
- KeyboardControllerView: hostComponent("KeyboardControllerView"),
372
- KeyboardGestureArea: hostComponent("KeyboardGestureArea"),
373
- OverKeyboardView: hostComponent("OverKeyboardView"),
374
- KeyboardBackgroundView: hostComponent("KeyboardBackgroundView"),
375
- KeyboardExtender: hostComponent("KeyboardExtender"),
376
- KeyboardStickyView: createViewMock(),
377
- KeyboardAvoidingView: createViewMock(),
378
- KeyboardAwareScrollView: createScrollViewMock(),
379
- KeyboardChatScrollView: createScrollViewMock(),
380
- KeyboardToolbar,
381
- KeyboardController: {
382
- setInputMode: vi.fn(),
383
- setDefaultMode: vi.fn(),
384
- preload: vi.fn(),
385
- dismiss: vi.fn(() => Promise.resolve()),
386
- setFocusTo: vi.fn(),
387
- isVisible: vi.fn(() => false),
388
- state: vi.fn(() => lastKeyboardEvent),
389
- viewPositionInWindow: vi.fn(() => Promise.resolve({
390
- x: 0,
391
- y: 0,
392
- width: 0,
393
- height: 0
394
- }))
395
- },
396
- KeyboardEvents: { addListener: vi.fn(() => ({ remove: vi.fn() })) },
397
- AndroidSoftInputModes: {
398
- SOFT_INPUT_ADJUST_NOTHING: 48,
399
- SOFT_INPUT_ADJUST_PAN: 32,
400
- SOFT_INPUT_ADJUST_RESIZE: 16,
401
- SOFT_INPUT_ADJUST_UNSPECIFIED: 0,
402
- SOFT_INPUT_IS_FORWARD_NAVIGATION: 256,
403
- SOFT_INPUT_MASK_ADJUST: 240,
404
- SOFT_INPUT_MASK_STATE: 15,
405
- SOFT_INPUT_MODE_CHANGED: 512,
406
- SOFT_INPUT_STATE_ALWAYS_HIDDEN: 3,
407
- SOFT_INPUT_STATE_ALWAYS_VISIBLE: 5,
408
- SOFT_INPUT_STATE_HIDDEN: 2,
409
- SOFT_INPUT_STATE_UNCHANGED: 1,
410
- SOFT_INPUT_STATE_UNSPECIFIED: 0,
411
- SOFT_INPUT_STATE_VISIBLE: 4
412
- },
413
- DefaultKeyboardToolbarTheme: {
414
- light: {
415
- primary: "#2c2c2c",
416
- disabled: "#B0BEC5",
417
- background: "#f3f3f4",
418
- ripple: "#bcbcbcbc"
419
- },
420
- dark: {
421
- primary: "#fafafa",
422
- disabled: "#707070",
423
- background: "#2C2C2E",
424
- ripple: "#F8F8F888"
425
- }
426
- },
427
- useKeyboardAnimation: () => animationValues.animated,
428
- useReanimatedKeyboardAnimation: () => animationValues.reanimated,
429
- useResizeMode: () => {},
430
- useGenericKeyboardHandler: () => {},
431
- useKeyboardHandler: () => {},
432
- useKeyboardContext: () => animationValues,
433
- useKeyboardState: (selector) => selector ? selector(keyboardState) : keyboardState,
434
- useReanimatedFocusedInput: () => focusedInput,
435
- useFocusedInputHandler: () => {},
436
- useKeyboardController: () => ({
437
- enabled: true,
438
- setEnabled: vi.fn()
439
- }),
440
- useWindowDimensions: () => ({
441
- width: 390,
442
- height: 844,
443
- scale: 3,
444
- fontScale: 1
445
- })
446
- };
447
- }
448
- }) }
449
- });
450
- }
451
- // src/presets/safe-area.ts
452
- const SAFE_AREA_MOCK = {
453
- pkg: "react-native-safe-area-context",
454
- entry: "jest/mock",
455
- file: "lib/module/jest/mock.js",
456
- exportKey: "default"
457
- };
458
- function safeAreaContext() {
459
- return builtInPreset({
460
- name: "safeAreaContext",
461
- modules: { "react-native-safe-area-context": libraryMockModule(SAFE_AREA_MOCK, {
462
- exports: [
463
- "SafeAreaProvider",
464
- "SafeAreaView",
465
- "SafeAreaInsetsContext",
466
- "SafeAreaFrameContext",
467
- "SafeAreaCornerAdaptedInsetsContext",
468
- "useSafeAreaInsets",
469
- "useSafeAreaFrame",
470
- "withSafeAreaInsets",
471
- "initialWindowMetrics",
472
- "initialWindowSafeAreaInsets"
473
- ],
474
- factory: () => {
475
- const defaultInsets = {
476
- top: 47,
477
- right: 0,
478
- bottom: 34,
479
- left: 0
480
- };
481
- const defaultFrame = {
482
- x: 0,
483
- y: 0,
484
- width: 390,
485
- height: 844
486
- };
487
- const state = {
488
- insets: { ...defaultInsets },
489
- frame: { ...defaultFrame }
490
- };
491
- const initialMetrics = {
492
- frame: state.frame,
493
- insets: state.insets
494
- };
495
- const SafeAreaProvider = React.forwardRef((props, ref) => {
496
- const host = React.createElement(hostComponent("SafeAreaProvider"), {
497
- ...props,
498
- ref
499
- }, props.children);
500
- const metrics = props.initialMetrics;
501
- if (!metrics) return host;
502
- return React.createElement(SafeAreaFrameContext.Provider, { value: metrics.frame ?? state.frame }, React.createElement(SafeAreaInsetsContext.Provider, { value: metrics.insets ?? state.insets }, host));
503
- });
504
- SafeAreaProvider.displayName = "SafeAreaProvider";
505
- const SafeAreaView = React.forwardRef((props, ref) => React.createElement(hostComponent("SafeAreaView"), {
506
- ...props,
507
- ref
508
- }, props.children));
509
- SafeAreaView.displayName = "SafeAreaView";
510
- const SafeAreaInsetsContext = React.createContext(state.insets);
511
- const SafeAreaFrameContext = React.createContext(state.frame);
512
- const SafeAreaCornerAdaptedInsetsContext = React.createContext(null);
513
- function useSafeAreaInsets(options) {
514
- const insets = React.useContext(SafeAreaInsetsContext) ?? state.insets;
515
- const corner = React.useContext(SafeAreaCornerAdaptedInsetsContext);
516
- const axis = options?.cornerAdaptation;
517
- return (axis != null ? corner?.[axis] : void 0) ?? insets;
518
- }
519
- function useSafeAreaFrame() {
520
- return React.useContext(SafeAreaFrameContext) ?? state.frame;
521
- }
522
- function withSafeAreaInsets(WrappedComponent) {
523
- const WithSafeAreaInsets = React.forwardRef((props, ref) => React.createElement(asHost(WrappedComponent), {
524
- ...props,
525
- ref,
526
- insets: useSafeAreaInsets()
527
- }));
528
- WithSafeAreaInsets.displayName = `withSafeAreaInsets(${WrappedComponent.displayName || WrappedComponent.name || "Component"})`;
529
- return WithSafeAreaInsets;
530
- }
531
- return {
532
- default: {
533
- SafeAreaProvider,
534
- SafeAreaView
535
- },
536
- SafeAreaProvider,
537
- SafeAreaView,
538
- SafeAreaInsetsContext,
539
- SafeAreaFrameContext,
540
- SafeAreaCornerAdaptedInsetsContext,
541
- useSafeAreaInsets,
542
- useSafeAreaFrame,
543
- withSafeAreaInsets,
544
- initialWindowMetrics: initialMetrics,
545
- initialWindowSafeAreaInsets: state.insets,
546
- EdgeInsets: vi.fn(),
547
- Rect: vi.fn(),
548
- Metrics: vi.fn(),
549
- /** Internal: update insets. Called by setInsets() helper. */
550
- _setInsets: (insets) => {
551
- Object.assign(state.insets, insets);
552
- },
553
- /** Internal: reset insets to defaults. Called by resetAllMocks(). */
554
- _reset: () => {
555
- Object.assign(state.insets, defaultInsets);
556
- Object.assign(state.frame, defaultFrame);
557
- }
558
- };
559
- }
560
- }) }
561
- });
562
- }
563
255
  // src/presets/reanimated.ts
564
256
  /**
565
257
  * Whether reanimated's own mock can run: it loads the real package, whose JS
@@ -573,7 +265,7 @@ const REANIMATED_MOCK = {
573
265
  file: "lib/module/mock.js",
574
266
  alsoFiles: ["lib/module/mock-svg.js"],
575
267
  available: (_dir, root) => libraryMockUsable(root),
576
- extend: (mock, dir) => mockCorrections(mock, dir, true)
268
+ extend: (mock, dir, { React }) => mockCorrections(React, mock, dir, true)
577
269
  };
578
270
  /** Whether `probe` returns `undefined` (a no-op), without throwing. */
579
271
  function returnsNothing(probe) {
@@ -727,16 +419,22 @@ let derivedReads = null;
727
419
  * mount, as Reanimated's mapper runs when it starts. Listeners hear a changed result, and
728
420
  * the subscriptions end when the component unmounts.
729
421
  */
730
- function derivedValue(updater) {
731
- const rendering = useRefOrNull();
422
+ function derivedValue(React, updater) {
423
+ const rendering = useRefOrNull(React);
732
424
  const state = rendering?.current ?? derivedState(updater);
733
425
  if (rendering && rendering.current === null) rendering.current = state;
734
426
  state.updater = updater;
735
- state.run();
736
- if (rendering) React.useEffect(() => {
737
- state.run();
738
- return () => state.stop();
739
- }, [state]);
427
+ state.run(rendering === null);
428
+ if (rendering) {
429
+ React.useEffect(() => {
430
+ state.followRendered();
431
+ });
432
+ React.useEffect(() => {
433
+ state.started = true;
434
+ state.run();
435
+ return () => state.stop();
436
+ }, [state]);
437
+ }
740
438
  return state.derived;
741
439
  }
742
440
  function derivedState(updater) {
@@ -744,9 +442,17 @@ function derivedState(updater) {
744
442
  derived: sharedValue(void 0),
745
443
  updater,
746
444
  inputs: /* @__PURE__ */ new Set(),
445
+ /** What the last render read, followed when it commits (followRendered). */
446
+ rendered: null,
447
+ /** Between the mount effect and unmount. */
448
+ started: false,
449
+ /** Whether the updater is running: a write it makes to its own input waits. */
450
+ running: false,
747
451
  ran: false,
748
452
  last: void 0,
749
- run() {
453
+ run(follow = true) {
454
+ if (held.running) return;
455
+ held.running = true;
750
456
  const outer = derivedReads;
751
457
  const read = /* @__PURE__ */ new Set();
752
458
  derivedReads = read;
@@ -755,18 +461,39 @@ function derivedState(updater) {
755
461
  next = held.updater();
756
462
  } finally {
757
463
  derivedReads = outer;
464
+ held.running = false;
758
465
  }
759
466
  read.delete(held.derived);
760
- for (const input of held.inputs) if (!read.has(input)) input.removeListener(held);
761
- for (const input of read) if (!held.inputs.has(input)) input.addListener(held, held.run);
762
- held.inputs = read;
467
+ if (follow) held.follow(read);
468
+ else held.rendered = read;
763
469
  if (!held.ran || !Object.is(held.last, next)) {
764
470
  held.ran = true;
765
471
  held.last = next;
766
472
  held.derived.value = next;
767
473
  }
768
474
  },
475
+ /** Listen to `read`, and to nothing else. */
476
+ follow(read) {
477
+ for (const input of held.inputs) if (!read.has(input)) input.removeListener(held);
478
+ for (const input of read) if (!held.inputs.has(input)) input.addListener(held, () => held.run());
479
+ held.inputs = read;
480
+ },
481
+ /**
482
+ * After a commit: follow what its render read. On an update that reads an input not
483
+ * followed before, run again, as Reanimated restarts a mapper whose closure changed:
484
+ * a child's effects run before this one, and a write they made to that input in this
485
+ * commit was not heard. The first commit's run is the mount effect's.
486
+ */
487
+ followRendered() {
488
+ const rendered = held.rendered;
489
+ held.rendered = null;
490
+ if (!rendered) return;
491
+ const added = [...rendered].some((input) => !held.inputs.has(input));
492
+ held.follow(rendered);
493
+ if (held.started && added) held.run();
494
+ },
769
495
  stop() {
496
+ held.started = false;
770
497
  for (const input of held.inputs) input.removeListener(held);
771
498
  held.inputs.clear();
772
499
  }
@@ -779,8 +506,8 @@ function derivedState(updater) {
779
506
  * write made through a later render's value. Outside a render, which the mock allows, a
780
507
  * new one each call.
781
508
  */
782
- function perComponent(create) {
783
- const held = useRefOrNull();
509
+ function perComponent(React, create) {
510
+ const held = useRefOrNull(React);
784
511
  if (held === null) return create();
785
512
  if (held.current === null) held.current = create();
786
513
  return held.current;
@@ -789,7 +516,7 @@ function perComponent(create) {
789
516
  * Reanimated's mock, with the names it answers with a no-op replaced (see
790
517
  * REANIMATED_MOCK). Exported for its tests.
791
518
  */
792
- function mockCorrections(mock, dir, fromRegistry = false, helpers = ownHelpers(dir, fromRegistry), real = ownIndex(dir, fromRegistry)) {
519
+ function mockCorrections(React, mock, dir, fromRegistry = false, helpers = ownHelpers(dir, fromRegistry), real = ownIndex(dir, fromRegistry)) {
793
520
  const probes = {
794
521
  interpolate: (f) => f(5, [0, 10], [0, 100]),
795
522
  clamp: (f) => f(5, 0, 3),
@@ -804,7 +531,7 @@ function mockCorrections(mock, dir, fromRegistry = false, helpers = ownHelpers(d
804
531
  }
805
532
  return fixed;
806
533
  };
807
- const handlers = scrollHandlers(mock.useSharedValue);
534
+ const handlers = scrollHandlers(React, mock.useSharedValue);
808
535
  const fixed = { ...fixHelpers(mock) };
809
536
  const scrollFixed = neverCalls((h) => mock.useAnimatedScrollHandler?.({ onScroll: h }));
810
537
  if (scrollFixed) fixed.useAnimatedScrollHandler = handlers.useAnimatedScrollHandler;
@@ -818,18 +545,18 @@ function mockCorrections(mock, dir, fromRegistry = false, helpers = ownHelpers(d
818
545
  const given = gives(name, call);
819
546
  return given !== NEEDS_RENDER && !isSharedValueShaped(given);
820
547
  };
821
- if (wrong("useSharedValue", (hook) => hook(0))) fixed.useSharedValue = (init) => perComponent(() => sharedValue(init));
548
+ if (wrong("useSharedValue", (hook) => hook(0))) fixed.useSharedValue = (init) => perComponent(React, () => sharedValue(init));
822
549
  if (wrong("makeMutable", (hook) => hook(0))) fixed.makeMutable = (init) => sharedValue(init);
823
- if (wrong("useDerivedValue", (hook) => hook(() => 0))) fixed.useDerivedValue = derivedValue;
550
+ if (wrong("useDerivedValue", (hook) => hook(() => 0))) fixed.useDerivedValue = (updater) => derivedValue(React, updater);
824
551
  for (const name of [
825
552
  "useScrollOffset",
826
553
  "useScrollViewOffset",
827
554
  "useTimestamp"
828
- ]) if (wrong(name, (hook) => hook())) fixed[name] = () => perComponent(() => sharedValue(0));
555
+ ]) if (wrong(name, (hook) => hook())) fixed[name] = () => perComponent(React, () => sharedValue(0));
829
556
  const keyboard = gives("useAnimatedKeyboard", (hook) => hook());
830
557
  if (typeof mock.useAnimatedKeyboard === "function" && keyboard !== NEEDS_RENDER && !(isSharedValueShaped(keyboard?.height) && isSharedValueShaped(keyboard?.state))) {
831
558
  const own = mock.useAnimatedKeyboard;
832
- fixed.useAnimatedKeyboard = (...args) => perComponent(() => ({
559
+ fixed.useAnimatedKeyboard = (...args) => perComponent(React, () => ({
833
560
  ...own(...args),
834
561
  height: sharedValue(0),
835
562
  state: sharedValue(0)
@@ -838,7 +565,7 @@ function mockCorrections(mock, dir, fromRegistry = false, helpers = ownHelpers(d
838
565
  const sensor = gives("useAnimatedSensor", (hook) => hook(0));
839
566
  if (typeof mock.useAnimatedSensor === "function" && sensor !== NEEDS_RENDER && !isSharedValueShaped(sensor?.sensor)) {
840
567
  const own = mock.useAnimatedSensor;
841
- fixed.useAnimatedSensor = (...args) => perComponent(() => {
568
+ fixed.useAnimatedSensor = (...args) => perComponent(React, () => {
842
569
  const given = own(...args) ?? {};
843
570
  const reading = given.sensor?.value ?? given.sensor;
844
571
  return {
@@ -851,7 +578,7 @@ function mockCorrections(mock, dir, fromRegistry = false, helpers = ownHelpers(d
851
578
  const base = real.BaseAnimationBuilder;
852
579
  for (const [name, own] of Object.entries(real)) if (typeof own === "function" && (own === base || typeof base === "function" && own.prototype instanceof base || name === "Keyframe") && name in mock && mock[name] !== own) fixed[name] = own;
853
580
  }
854
- if (typeof mock.useAnimatedRef === "function" && typeof gives("useAnimatedRef", (hook) => hook()) === "object") fixed.useAnimatedRef = () => perComponent(() => {
581
+ if (typeof mock.useAnimatedRef === "function" && typeof gives("useAnimatedRef", (hook) => hook()) === "object") fixed.useAnimatedRef = () => perComponent(React, () => {
855
582
  const ref = (node) => {
856
583
  if (node !== void 0) ref.current = node;
857
584
  return ref.current;
@@ -890,7 +617,7 @@ function mockCorrections(mock, dir, fromRegistry = false, helpers = ownHelpers(d
890
617
  ...fixHelpers(mock.default)
891
618
  };
892
619
  if (scrollFixed) {
893
- for (const name of ["ScrollView", "FlatList"]) if (defaults[name]) defaults[name] = withScrollEvents(defaults[name]);
620
+ for (const name of ["ScrollView", "FlatList"]) if (defaults[name]) defaults[name] = withScrollEvents(React, defaults[name]);
894
621
  }
895
622
  return {
896
623
  ...mock,
@@ -917,6 +644,97 @@ function loadOwnFile(file, stubbed, stub) {
917
644
  mod.loaded = true;
918
645
  return mod.exports;
919
646
  }
647
+ /** `load()`, or null when it throws: a package the project may not have. */
648
+ function optional(load) {
649
+ try {
650
+ return load();
651
+ } catch {
652
+ return null;
653
+ }
654
+ }
655
+ /**
656
+ * The project's `@babel/core` and `@babel/plugin-transform-modules-commonjs`, or null when
657
+ * either is missing. A React Native app has both through `@react-native/babel-preset` (or
658
+ * `babel-preset-expo`); an isolated install (pnpm, bun) puts the plugin beside the preset
659
+ * rather than at the project root, so it is looked for there too.
660
+ */
661
+ function projectBabel(root) {
662
+ const fromRoot = createRequire(path.join(root, "package.json"));
663
+ const core = optional(() => fromRoot("@babel/core"));
664
+ if (!core) return null;
665
+ const places = [fromRoot, ...["@react-native/babel-preset", "babel-preset-expo"].flatMap((preset) => {
666
+ const manifest = optional(() => fromRoot.resolve(`${preset}/package.json`));
667
+ return manifest ? [createRequire(manifest)] : [];
668
+ })];
669
+ for (const from of places) {
670
+ const plugin = optional(() => from("@babel/plugin-transform-modules-commonjs"));
671
+ if (plugin) return {
672
+ transformSync: core.transformSync,
673
+ version: core.version,
674
+ plugin
675
+ };
676
+ }
677
+ return null;
678
+ }
679
+ /** Compiled sources, by file, reanimated version and Babel version: the same in every file. */
680
+ const compiledSources = /* @__PURE__ */ new Map();
681
+ /**
682
+ * Loads one of reanimated's ES module files, and the files it imports, as CommonJS the
683
+ * project's Babel compiles (projectBabel). For the mock engine, which runs no transform:
684
+ * interpolateColor.js reaches React Native's `Platform` (common/constants/platform.js),
685
+ * and an ES module's `import` of React Native goes to its Flow source, which Node cannot
686
+ * run (#857). Compiled to CommonJS, it is a `require`, which the mock engine answers with
687
+ * its React Native as it does every other. Each load has its own module cache, outside
688
+ * Node's, so a file imported twice runs once. Throws when the project has no Babel.
689
+ */
690
+ function loadCompiledGraph(dir, entry, babelRoot) {
691
+ const babel = projectBabel(babelRoot);
692
+ if (!babel) throw new VitestNativeError("PRESET_UNAVAILABLE", `no @babel/core and @babel/plugin-transform-modules-commonjs resolve from ${babelRoot}`);
693
+ const { version } = JSON.parse(fs.readFileSync(path.join(dir, "package.json"), "utf8"));
694
+ const loaded = /* @__PURE__ */ new Map();
695
+ const compiled = (file) => {
696
+ const key = `${file}\0${version}\0${babel.version}`;
697
+ let code = compiledSources.get(key);
698
+ if (code === void 0) {
699
+ code = babel.transformSync(fs.readFileSync(file, "utf8"), {
700
+ filename: file,
701
+ babelrc: false,
702
+ configFile: false,
703
+ sourceType: "module",
704
+ plugins: [babel.plugin]
705
+ })?.code ?? "";
706
+ compiledSources.set(key, code);
707
+ }
708
+ return code;
709
+ };
710
+ const load = (file) => {
711
+ const known = loaded.get(file);
712
+ if (known) return known.exports;
713
+ const mod = new Module(file);
714
+ mod.filename = file;
715
+ mod.paths = Module._nodeModulePaths(path.dirname(file));
716
+ mod.require = function(request) {
717
+ if (request.startsWith(".")) return load(path.resolve(path.dirname(file), request));
718
+ return Module.prototype.require.call(this, request);
719
+ };
720
+ loaded.set(file, mod);
721
+ mod._compile(compiled(file), file);
722
+ mod.loaded = true;
723
+ return mod.exports;
724
+ };
725
+ return load(path.join(dir, entry));
726
+ }
727
+ /**
728
+ * The stand-in for a helper of reanimated's (`interpolateColor`, `clamp`) that did not
729
+ * load from `installedDir`: it throws, saying why and what to do.
730
+ */
731
+ function unavailableHelper(name, installedDir) {
732
+ return () => {
733
+ throw new VitestNativeError("PRESET_UNAVAILABLE", `reanimated's ${name} did not load from ${installedDir ?? "react-native-reanimated (not installed)"}. ` + (underNativeEngine() ? "Its file is missing or failed to load; please report this with your reanimated version." : "The mock engine runs no transform, and its file needs one: it imports React Native, which the engine compiles it against with the project's @babel/core and @babel/plugin-transform-modules-commonjs. Install them, or use the native engine (engine: 'native'). Before reanimated 4.5 its imports have no file extension, and it does not load under the mock engine."));
734
+ };
735
+ }
736
+ /** The file of reanimated's interpolateColor, which reaches React Native. */
737
+ const COLOR_FILE = "lib/module/interpolateColor.js";
920
738
  /** What interpolateColor.js's core imports become (see loadOwnFile). */
921
739
  const NOT_LOADED = new Proxy({}, { get: (_target, name) => name === "__esModule" ? true : () => {
922
740
  throw new VitestNativeError("PRESET_UNAVAILABLE", `reanimated's ${String(name)} is not available to interpolateColor here.`);
@@ -925,12 +743,13 @@ const NOT_LOADED = new Proxy({}, { get: (_target, name) => name === "__esModule"
925
743
  * Reanimated's own `interpolate`, `clamp` and `interpolateColor`, loaded from the
926
744
  * installed package's files (by name, the preset answers): plain functions, which
927
745
  * reanimated also runs on the JS thread. A file that does not load is left out, and
928
- * its names keep what the module had. Under the native engine both load from 3.17 on;
929
- * under the mock engine, which runs no transform, interpolateColor.js does not load
930
- * (it imports React Native's Flow source), nor, before 4.5, does interpolation.js
931
- * (its imports have no file extension, which Node's ES module loader rejects).
746
+ * its names keep what the module had. Under the native engine both load from 3.17 on.
747
+ * Under the mock engine, which runs no transform, Node cannot load interpolateColor.js
748
+ * (it imports React Native's Flow source) nor, before 4.5, interpolation.js (its imports
749
+ * have no file extension). From 4.5 on, interpolateColor.js is compiled with the
750
+ * project's Babel (loadCompiledGraph), and stays out where the project has none.
932
751
  */
933
- function ownHelpers(dir, fromRegistry = false) {
752
+ function ownHelpers(dir, fromRegistry = false, babelRoot = workerRoot$1()) {
934
753
  const helpers = {};
935
754
  const required = createRequire(path.join(dir, "package.json"));
936
755
  for (const [file, names] of Object.entries({
@@ -941,6 +760,14 @@ function ownHelpers(dir, fromRegistry = false) {
941
760
  const own = () => loadOwnFile(path.join(dir, file), /^\.\/(core|hook\/useSharedValue)(\.js)?$/, NOT_LOADED);
942
761
  const loaded = (fromRegistry && registryHolds(source) ? loadOrNull(() => required(source)) : null) ?? loadOrNull(own);
943
762
  for (const name of names) if (typeof loaded?.[name] === "function") helpers[name] = loaded[name];
763
+ if (!loaded && file === COLOR_FILE && !underNativeEngine()) {
764
+ let graph;
765
+ for (const name of names) helpers[name] = (...args) => {
766
+ if (graph === void 0) graph = loadOrNull(() => loadCompiledGraph(dir, file, babelRoot));
767
+ const helper = graph?.[name];
768
+ return typeof helper === "function" ? helper(...args) : unavailableHelper(name, dir)();
769
+ };
770
+ }
944
771
  }
945
772
  return helpers;
946
773
  }
@@ -953,7 +780,7 @@ const EVENT_PROPS = {
953
780
  onMomentumScrollEnd: "onMomentumEnd"
954
781
  };
955
782
  /** React's `useRef` in a render, or null outside one (where hooks cannot run). */
956
- function useRefOrNull() {
783
+ function useRefOrNull(React) {
957
784
  try {
958
785
  return React.useRef(null);
959
786
  } catch {
@@ -991,7 +818,8 @@ function loadOrNull(load) {
991
818
  * drag and momentum events, as reanimated's animated scroll views do (they subscribe
992
819
  * a handler to every event it handles). A prop the test gives itself still runs.
993
820
  */
994
- function withScrollEvents(Component) {
821
+ function withScrollEvents(React, Component) {
822
+ const { asHost } = hosts(React);
995
823
  const Wrapped = React.forwardRef((props, ref) => {
996
824
  const events = props.onScroll?.[SCROLL_EVENTS];
997
825
  if (!events) return React.createElement(asHost(Component), {
@@ -1026,7 +854,7 @@ function withScrollEvents(Component) {
1026
854
  * and so the drag and momentum events of the scroll handlers among them. The offset
1027
855
  * hooks return a shared value (`useSharedValue(0)`, kept across renders).
1028
856
  */
1029
- function scrollHandlers(useSharedValue) {
857
+ function scrollHandlers(React, useSharedValue) {
1030
858
  function useAnimatedScrollHandler(handlers) {
1031
859
  const latest = React.useRef({});
1032
860
  latest.current = typeof handlers === "function" ? { onScroll: handlers } : handlers ?? {};
@@ -1066,19 +894,17 @@ function scrollHandlers(useSharedValue) {
1066
894
  /**
1067
895
  * Resolve the *active* React Native module — the mock under `engine: 'mock'`
1068
896
  * (intercepted by the CJS bridge) or real RN under `engine: 'native'` (served by
1069
- * the Node loader hooks). Cached. Lets the reanimated mock's `Animated.View`
1070
- * &co. wrap whichever RN component set is live, so the preset is engine-agnostic.
897
+ * the Node loader hooks). Lets the reanimated mock's `Animated.View` &co. wrap whichever
898
+ * RN component set is live, so the preset is engine-agnostic. Required on each call, a
899
+ * module-cache hit: a copy kept for the worker would be the first file's components,
900
+ * built with its React (freshRuntime, #719).
1071
901
  */
1072
- let _rnCache = null;
1073
902
  function getRN$1() {
1074
- if (_rnCache) return _rnCache;
1075
903
  try {
1076
- const base = path.join(workerRoot$1(), "package.json");
1077
- _rnCache = createRequire(base)("react-native");
904
+ return createRequire(path.join(workerRoot$1(), "package.json"))("react-native");
1078
905
  } catch {
1079
- _rnCache = {};
906
+ return {};
1080
907
  }
1081
- return _rnCache;
1082
908
  }
1083
909
  function reanimated() {
1084
910
  return builtInPreset({
@@ -1185,7 +1011,8 @@ function reanimated() {
1185
1011
  "ReduceMotion",
1186
1012
  "KeyboardState"
1187
1013
  ],
1188
- factory: () => {
1014
+ factory: ({ React }) => {
1015
+ const { asHost } = hosts(React);
1189
1016
  const createSharedValue = (init) => sharedValue(init);
1190
1017
  function useSharedValue(init) {
1191
1018
  return React.useRef(createSharedValue(init)).current;
@@ -1196,13 +1023,11 @@ function reanimated() {
1196
1023
  function useAnimatedProps(updater) {
1197
1024
  return updater();
1198
1025
  }
1199
- const useDerivedValue = derivedValue;
1200
- const { useAnimatedScrollHandler, useComposedEventHandler, useScrollOffset } = scrollHandlers(createSharedValue);
1026
+ const useDerivedValue = (updater) => derivedValue(React, updater);
1027
+ const { useAnimatedScrollHandler, useComposedEventHandler, useScrollOffset } = scrollHandlers(React, createSharedValue);
1201
1028
  const installedDir = reanimatedDir(workerRoot$1());
1202
1029
  const helpers = installedDir ? ownHelpers(installedDir) : {};
1203
- const unavailable = (name) => () => {
1204
- throw new VitestNativeError("PRESET_UNAVAILABLE", `reanimated's ${name} did not load from ${installedDir ?? "react-native-reanimated (not installed)"}. ` + (underNativeEngine() ? "Its file is missing or failed to load; please report this with your reanimated version." : "The mock engine runs no transform, and its file needs one (it imports React Native, or, before reanimated 4.5, modules without a file extension). It works under the native engine (engine: 'native')."));
1205
- };
1030
+ const unavailable = (name) => unavailableHelper(name, installedDir);
1206
1031
  const interpolate = vi.fn(helpers.interpolate ?? ((_value, _input, output) => output[0]));
1207
1032
  const interpolateColor = vi.fn(helpers.interpolateColor ?? unavailable("interpolateColor"));
1208
1033
  const clamp = vi.fn(helpers.clamp ?? unavailable("clamp"));
@@ -1300,9 +1125,16 @@ function reanimated() {
1300
1125
  Animated.displayName = `Animated(${component.displayName || component.name || "Component"})`;
1301
1126
  return Animated;
1302
1127
  }
1128
+ let activeRN;
1129
+ const rn = () => {
1130
+ if (activeRN) return activeRN;
1131
+ const found = getRN$1();
1132
+ if (Object.keys(found).length > 0) activeRN = found;
1133
+ return found;
1134
+ };
1303
1135
  function makeAnimatedHost(name) {
1304
1136
  const Comp = React.forwardRef((props, ref) => {
1305
- const Base = getRN$1()[name];
1137
+ const Base = rn()[name];
1306
1138
  if (!Base) throw new VitestNativeError("PRESET_UNAVAILABLE", `The reanimated preset needs React Native's '${name}' component to build Animated.${name}, and react-native did not provide it.\nThis usually means react-native resolved to something unexpected — a partially installed copy, or a mock replacing the whole module. Check that 'react-native' resolves in your project and that no vi.mock replaces it wholesale.`);
1307
1139
  return React.createElement(asHost(Base), {
1308
1140
  ...props,
@@ -1315,8 +1147,8 @@ function reanimated() {
1315
1147
  const View = makeAnimatedHost("View");
1316
1148
  const Text = makeAnimatedHost("Text");
1317
1149
  const Image = makeAnimatedHost("Image");
1318
- const ScrollView = withScrollEvents(makeAnimatedHost("ScrollView"));
1319
- const FlatList = withScrollEvents(makeAnimatedHost("FlatList"));
1150
+ const ScrollView = withScrollEvents(React, makeAnimatedHost("ScrollView"));
1151
+ const FlatList = withScrollEvents(React, makeAnimatedHost("FlatList"));
1320
1152
  function createLayoutAnim() {
1321
1153
  const obj = {};
1322
1154
  obj.duration = vi.fn(() => obj);
@@ -1521,7 +1353,8 @@ function buildPressableHostProps(props, ref) {
1521
1353
  };
1522
1354
  }
1523
1355
  // src/mocks/components/Pressable.ts
1524
- function createPressableMock() {
1356
+ function createPressableMock(React) {
1357
+ const { hostComponent } = hosts(React);
1525
1358
  const Pressable = React.forwardRef((props, ref) => {
1526
1359
  const { style, children, onPressIn, onPressOut, ...rest } = props;
1527
1360
  const [pressed, setPressed] = React.useState(false);
@@ -1580,7 +1413,8 @@ function gestureHandler() {
1580
1413
  "RawButton",
1581
1414
  "PureNativeButton"
1582
1415
  ],
1583
- factory: () => {
1416
+ factory: ({ React }) => {
1417
+ const { hostComponent: hostClass, asHost } = hosts(React);
1584
1418
  const State = {
1585
1419
  UNDETERMINED: 0,
1586
1420
  FAILED: 1,
@@ -1603,17 +1437,17 @@ function gestureHandler() {
1603
1437
  Handler.displayName = name;
1604
1438
  return Handler;
1605
1439
  }
1606
- const GestureHandlerRootView = React.forwardRef((props, ref) => React.createElement(hostComponent("GestureHandlerRootView"), {
1440
+ const GestureHandlerRootView = React.forwardRef((props, ref) => React.createElement(hostClass("GestureHandlerRootView"), {
1607
1441
  ...props,
1608
1442
  ref
1609
1443
  }, props.children));
1610
1444
  GestureHandlerRootView.displayName = "GestureHandlerRootView";
1611
- const Swipeable = React.forwardRef((props, ref) => React.createElement(hostComponent("Swipeable"), {
1445
+ const Swipeable = React.forwardRef((props, ref) => React.createElement(hostClass("Swipeable"), {
1612
1446
  ...props,
1613
1447
  ref
1614
1448
  }, props.children));
1615
1449
  Swipeable.displayName = "Swipeable";
1616
- const DrawerLayout = React.forwardRef((props, ref) => React.createElement(hostComponent("DrawerLayout"), {
1450
+ const DrawerLayout = React.forwardRef((props, ref) => React.createElement(hostClass("DrawerLayout"), {
1617
1451
  ...props,
1618
1452
  ref
1619
1453
  }, props.children));
@@ -1667,7 +1501,7 @@ function gestureHandler() {
1667
1501
  Exclusive: vi.fn((..._gestures) => ({})),
1668
1502
  Race: vi.fn((..._gestures) => ({}))
1669
1503
  };
1670
- const GestureDetector = React.forwardRef((props, ref) => React.createElement(hostComponent("GestureDetector"), {
1504
+ const GestureDetector = React.forwardRef((props, ref) => React.createElement(hostClass("GestureDetector"), {
1671
1505
  ...props,
1672
1506
  ref
1673
1507
  }, props.children));
@@ -1700,7 +1534,7 @@ function gestureHandler() {
1700
1534
  TouchableHighlight: createGestureHandler("GH-TouchableHighlight"),
1701
1535
  TouchableWithoutFeedback: createGestureHandler("GH-TouchableWithoutFeedback"),
1702
1536
  TouchableNativeFeedback: createGestureHandler("GH-TouchableNativeFeedback"),
1703
- Pressable: createPressableMock(),
1537
+ Pressable: createPressableMock(React),
1704
1538
  RectButton: createGestureHandler("RectButton"),
1705
1539
  BaseButton: createGestureHandler("BaseButton"),
1706
1540
  BorderlessButton: createGestureHandler("BorderlessButton"),
@@ -1708,9 +1542,136 @@ function gestureHandler() {
1708
1542
  PureNativeButton: createGestureHandler("PureNativeButton")
1709
1543
  };
1710
1544
  }
1711
- } }
1545
+ } }
1546
+ });
1547
+ }
1548
+ // src/presets/safe-area.ts
1549
+ const SAFE_AREA_MOCK = {
1550
+ pkg: "react-native-safe-area-context",
1551
+ entry: "jest/mock",
1552
+ file: "lib/module/jest/mock.js",
1553
+ exportKey: "default"
1554
+ };
1555
+ function safeAreaContext() {
1556
+ return builtInPreset({
1557
+ name: "safeAreaContext",
1558
+ modules: { "react-native-safe-area-context": libraryMockModule(SAFE_AREA_MOCK, {
1559
+ exports: [
1560
+ "SafeAreaProvider",
1561
+ "SafeAreaView",
1562
+ "SafeAreaInsetsContext",
1563
+ "SafeAreaFrameContext",
1564
+ "SafeAreaCornerAdaptedInsetsContext",
1565
+ "useSafeAreaInsets",
1566
+ "useSafeAreaFrame",
1567
+ "withSafeAreaInsets",
1568
+ "initialWindowMetrics",
1569
+ "initialWindowSafeAreaInsets"
1570
+ ],
1571
+ factory: ({ React }) => {
1572
+ const { hostComponent: hostClass, asHost } = hosts(React);
1573
+ const defaultInsets = {
1574
+ top: 47,
1575
+ right: 0,
1576
+ bottom: 34,
1577
+ left: 0
1578
+ };
1579
+ const defaultFrame = {
1580
+ x: 0,
1581
+ y: 0,
1582
+ width: 390,
1583
+ height: 844
1584
+ };
1585
+ const state = {
1586
+ insets: { ...defaultInsets },
1587
+ frame: { ...defaultFrame }
1588
+ };
1589
+ const initialMetrics = {
1590
+ frame: state.frame,
1591
+ insets: state.insets
1592
+ };
1593
+ const SafeAreaProvider = React.forwardRef((props, ref) => {
1594
+ const host = React.createElement(hostClass("SafeAreaProvider"), {
1595
+ ...props,
1596
+ ref
1597
+ }, props.children);
1598
+ const metrics = props.initialMetrics;
1599
+ if (!metrics) return host;
1600
+ return React.createElement(SafeAreaFrameContext.Provider, { value: metrics.frame ?? state.frame }, React.createElement(SafeAreaInsetsContext.Provider, { value: metrics.insets ?? state.insets }, host));
1601
+ });
1602
+ SafeAreaProvider.displayName = "SafeAreaProvider";
1603
+ const SafeAreaView = React.forwardRef((props, ref) => React.createElement(hostClass("SafeAreaView"), {
1604
+ ...props,
1605
+ ref
1606
+ }, props.children));
1607
+ SafeAreaView.displayName = "SafeAreaView";
1608
+ const SafeAreaInsetsContext = React.createContext(state.insets);
1609
+ const SafeAreaFrameContext = React.createContext(state.frame);
1610
+ const SafeAreaCornerAdaptedInsetsContext = React.createContext(null);
1611
+ function useSafeAreaInsets(options) {
1612
+ const insets = React.useContext(SafeAreaInsetsContext) ?? state.insets;
1613
+ const corner = React.useContext(SafeAreaCornerAdaptedInsetsContext);
1614
+ const axis = options?.cornerAdaptation;
1615
+ return (axis != null ? corner?.[axis] : void 0) ?? insets;
1616
+ }
1617
+ function useSafeAreaFrame() {
1618
+ return React.useContext(SafeAreaFrameContext) ?? state.frame;
1619
+ }
1620
+ function withSafeAreaInsets(WrappedComponent) {
1621
+ const WithSafeAreaInsets = React.forwardRef((props, ref) => React.createElement(asHost(WrappedComponent), {
1622
+ ...props,
1623
+ ref,
1624
+ insets: useSafeAreaInsets()
1625
+ }));
1626
+ WithSafeAreaInsets.displayName = `withSafeAreaInsets(${WrappedComponent.displayName || WrappedComponent.name || "Component"})`;
1627
+ return WithSafeAreaInsets;
1628
+ }
1629
+ return {
1630
+ default: {
1631
+ SafeAreaProvider,
1632
+ SafeAreaView
1633
+ },
1634
+ SafeAreaProvider,
1635
+ SafeAreaView,
1636
+ SafeAreaInsetsContext,
1637
+ SafeAreaFrameContext,
1638
+ SafeAreaCornerAdaptedInsetsContext,
1639
+ useSafeAreaInsets,
1640
+ useSafeAreaFrame,
1641
+ withSafeAreaInsets,
1642
+ initialWindowMetrics: initialMetrics,
1643
+ initialWindowSafeAreaInsets: state.insets,
1644
+ EdgeInsets: vi.fn(),
1645
+ Rect: vi.fn(),
1646
+ Metrics: vi.fn(),
1647
+ /** Internal: update insets. Called by setInsets() helper. */
1648
+ _setInsets: (insets) => {
1649
+ Object.assign(state.insets, insets);
1650
+ },
1651
+ /** Internal: reset insets to defaults. Called by resetAllMocks(). */
1652
+ _reset: () => {
1653
+ Object.assign(state.insets, defaultInsets);
1654
+ Object.assign(state.frame, defaultFrame);
1655
+ }
1656
+ };
1657
+ }
1658
+ }) }
1712
1659
  });
1713
1660
  }
1661
+ // src/presets/per-react.ts
1662
+ /**
1663
+ * `build`, run once per React module. For what a preset's module factories share, such
1664
+ * as contexts one module provides and another reads: built from the test file's React
1665
+ * (under the hot runtime's freshRuntime, each file has its own), and shared by every
1666
+ * module of the preset built with that React.
1667
+ */
1668
+ function perReact(build) {
1669
+ const built = /* @__PURE__ */ new WeakMap();
1670
+ return (React) => {
1671
+ if (!built.has(React)) built.set(React, build(React));
1672
+ return built.get(React);
1673
+ };
1674
+ }
1714
1675
  // src/presets/navigation.ts
1715
1676
  /** Builds a minimal navigation prop matching useNavigation()'s shape. */
1716
1677
  function createMockNavigation() {
@@ -1734,7 +1695,10 @@ function createMockNavigation() {
1734
1695
  isFocused: vi.fn(() => true),
1735
1696
  addListener: vi.fn(() => vi.fn()),
1736
1697
  removeListener: vi.fn(),
1737
- getId: vi.fn(() => void 0)
1698
+ getId: vi.fn(() => void 0),
1699
+ preload: vi.fn(),
1700
+ replaceParams: vi.fn(),
1701
+ navigateDeprecated: vi.fn()
1738
1702
  };
1739
1703
  }
1740
1704
  /**
@@ -1747,7 +1711,8 @@ function createMockNavigation() {
1747
1711
  * useNavigation() and useRoute() inside the screen component return values
1748
1712
  * consistent with the route/navigation props passed to the component.
1749
1713
  */
1750
- function createMockScreen(NavContext, RouteContext, defaultRouteParams) {
1714
+ function createMockScreen(React, NavContext, RouteContext, defaultRouteParams) {
1715
+ const { hostComponent: hostClass } = hosts(React);
1751
1716
  const Screen = React.forwardRef(({ component: Component, children, ...rest }, ref) => {
1752
1717
  const route = {
1753
1718
  key: rest.name ?? "",
@@ -1762,7 +1727,7 @@ function createMockScreen(NavContext, RouteContext, defaultRouteParams) {
1762
1727
  route,
1763
1728
  navigation: nav
1764
1729
  }) : children;
1765
- return React.createElement(hostComponent("Screen"), {
1730
+ return React.createElement(hostClass("Screen"), {
1766
1731
  ...rest,
1767
1732
  ref
1768
1733
  }, React.createElement(NavContext.Provider, { value: nav }, React.createElement(RouteContext.Provider, { value: route }, content)));
@@ -1772,18 +1737,6 @@ function createMockScreen(NavContext, RouteContext, defaultRouteParams) {
1772
1737
  }
1773
1738
  function navigation(presetOptions = {}) {
1774
1739
  const defaultRouteParams = presetOptions.defaultRouteParams ?? {};
1775
- const NavigationContext = React.createContext(null);
1776
- const NavigationRouteContext = React.createContext(null);
1777
- const NavigationContainerRefContext = React.createContext(null);
1778
- const NavigationHelpersContext = React.createContext(null);
1779
- const CurrentRenderContext = React.createContext(void 0);
1780
- const PreventRemoveContext = React.createContext(null);
1781
- const LinkingContext = React.createContext({ options: void 0 });
1782
- const LocaleDirContext = React.createContext("ltr");
1783
- const UNSTABLE_UnhandledLinkingContext = React.createContext({
1784
- lastUnhandledLink: void 0,
1785
- setLastUnhandledLink: () => {}
1786
- });
1787
1740
  const themeFonts = (() => {
1788
1741
  return projectContext()?.platform !== "android" ? {
1789
1742
  regular: {
@@ -1845,8 +1798,26 @@ function navigation(presetOptions = {}) {
1845
1798
  },
1846
1799
  fonts: themeFonts
1847
1800
  };
1848
- const ThemeContext = React.createContext(DefaultTheme);
1849
- const Screen = createMockScreen(NavigationContext, NavigationRouteContext, defaultRouteParams);
1801
+ const shared = perReact((React) => {
1802
+ const NavigationContext = React.createContext(null);
1803
+ const NavigationRouteContext = React.createContext(null);
1804
+ return {
1805
+ NavigationContext,
1806
+ NavigationRouteContext,
1807
+ NavigationContainerRefContext: React.createContext(null),
1808
+ NavigationHelpersContext: React.createContext(null),
1809
+ CurrentRenderContext: React.createContext(void 0),
1810
+ PreventRemoveContext: React.createContext(null),
1811
+ LinkingContext: React.createContext({ options: void 0 }),
1812
+ LocaleDirContext: React.createContext("ltr"),
1813
+ UNSTABLE_UnhandledLinkingContext: React.createContext({
1814
+ lastUnhandledLink: void 0,
1815
+ setLastUnhandledLink: () => {}
1816
+ }),
1817
+ ThemeContext: React.createContext(DefaultTheme),
1818
+ Screen: createMockScreen(React, NavigationContext, NavigationRouteContext, defaultRouteParams)
1819
+ };
1820
+ });
1850
1821
  return builtInPreset({
1851
1822
  name: "navigation",
1852
1823
  config: { defaultRouteParams },
@@ -1905,10 +1876,18 @@ function navigation(presetOptions = {}) {
1905
1876
  "useRoutePath",
1906
1877
  "createComponentForStaticNavigation",
1907
1878
  "createPathConfigForStaticNavigation",
1908
- "BaseRouter"
1879
+ "createScreenFactory",
1880
+ "NavigationProvider",
1881
+ "createStandardNavigationFactories",
1882
+ "BaseRouter",
1883
+ "StackRouter",
1884
+ "TabRouter",
1885
+ "DrawerRouter"
1909
1886
  ],
1910
- factory: () => {
1911
- const NavigationContainer = React.forwardRef((props, ref) => React.createElement(hostComponent("NavigationContainer"), {
1887
+ factory: ({ React }) => {
1888
+ const { hostComponent: hostClass } = hosts(React);
1889
+ const { NavigationContext, NavigationRouteContext, NavigationContainerRefContext, NavigationHelpersContext, CurrentRenderContext, PreventRemoveContext, LinkingContext, LocaleDirContext, UNSTABLE_UnhandledLinkingContext, ThemeContext, Screen } = shared(React);
1890
+ const NavigationContainer = React.forwardRef((props, ref) => React.createElement(hostClass("NavigationContainer"), {
1912
1891
  ...props,
1913
1892
  ref
1914
1893
  }, props.children));
@@ -1929,6 +1908,10 @@ function navigation(presetOptions = {}) {
1929
1908
  type: "stack",
1930
1909
  stale: false
1931
1910
  }));
1911
+ const preload = vi.fn();
1912
+ const replaceParams = vi.fn();
1913
+ const navigateDeprecated = vi.fn();
1914
+ const emit = vi.fn(() => ({ defaultPrevented: false }));
1932
1915
  const defaultNavigation = {
1933
1916
  navigate,
1934
1917
  goBack,
@@ -1942,7 +1925,10 @@ function navigation(presetOptions = {}) {
1942
1925
  isFocused: vi.fn(() => true),
1943
1926
  addListener: vi.fn(() => vi.fn()),
1944
1927
  removeListener: vi.fn(),
1945
- getId: vi.fn(() => void 0)
1928
+ getId: vi.fn(() => void 0),
1929
+ preload,
1930
+ replaceParams,
1931
+ navigateDeprecated
1946
1932
  };
1947
1933
  const defaultRoute = {
1948
1934
  key: "test-route-key",
@@ -1988,7 +1974,18 @@ function navigation(presetOptions = {}) {
1988
1974
  name: "TestScreen"
1989
1975
  })),
1990
1976
  getCurrentOptions: vi.fn(() => ({})),
1991
- addListener: vi.fn(() => vi.fn())
1977
+ addListener: vi.fn(() => vi.fn()),
1978
+ removeListener: vi.fn(),
1979
+ resetRoot: vi.fn(),
1980
+ setParams,
1981
+ setOptions,
1982
+ replaceParams,
1983
+ preload,
1984
+ navigateDeprecated,
1985
+ emit,
1986
+ isFocused: vi.fn(() => true),
1987
+ getId: vi.fn(() => void 0),
1988
+ getParent
1992
1989
  };
1993
1990
  }
1994
1991
  function useNavigationContainerRef() {
@@ -2013,7 +2010,84 @@ function navigation(presetOptions = {}) {
2013
2010
  function PreventRemoveProvider({ children }) {
2014
2011
  return children;
2015
2012
  }
2016
- const BaseNavigationContainer = React.forwardRef((props, ref) => React.createElement(hostComponent("BaseNavigationContainer"), {
2013
+ const CommonActions = {
2014
+ navigate: vi.fn(),
2015
+ reset: vi.fn(),
2016
+ goBack: vi.fn(),
2017
+ setParams: vi.fn(),
2018
+ preload: vi.fn((name, params) => ({
2019
+ type: "PRELOAD",
2020
+ payload: {
2021
+ name,
2022
+ params
2023
+ }
2024
+ })),
2025
+ replaceParams: vi.fn((params) => ({
2026
+ type: "REPLACE_PARAMS",
2027
+ payload: { params }
2028
+ })),
2029
+ navigateDeprecated: vi.fn((name, params) => {
2030
+ if (typeof name === "string") return {
2031
+ type: "NAVIGATE_DEPRECATED",
2032
+ payload: {
2033
+ name,
2034
+ params
2035
+ }
2036
+ };
2037
+ const payload = name || {};
2038
+ if (!("name" in payload)) throw new Error("You need to specify a name when calling navigateDeprecated with an object as the argument. See https://reactnavigation.org/docs/navigation-actions#navigatelegacy for usage.");
2039
+ return {
2040
+ type: "NAVIGATE_DEPRECATED",
2041
+ payload
2042
+ };
2043
+ })
2044
+ };
2045
+ const StackActions = {
2046
+ push: vi.fn(),
2047
+ pop: vi.fn(),
2048
+ popToTop: vi.fn(),
2049
+ replace: vi.fn(),
2050
+ popTo: vi.fn((name, params, options) => {
2051
+ if (typeof options === "boolean") console.warn("Passing a boolean as the third argument to 'popTo' is deprecated. Pass '{ merge: true }' instead.");
2052
+ return {
2053
+ type: "POP_TO",
2054
+ payload: {
2055
+ name,
2056
+ params,
2057
+ merge: typeof options === "boolean" ? options : options?.merge
2058
+ }
2059
+ };
2060
+ })
2061
+ };
2062
+ const TabActions = { jumpTo: vi.fn() };
2063
+ const DrawerActions = {
2064
+ openDrawer: vi.fn(),
2065
+ closeDrawer: vi.fn(),
2066
+ toggleDrawer: vi.fn(),
2067
+ jumpTo: vi.fn()
2068
+ };
2069
+ function NavigationProvider({ route, navigation: helpers, children }) {
2070
+ return React.createElement(NavigationRouteContext.Provider, { value: route }, React.createElement(NavigationContext.Provider, { value: helpers }, children));
2071
+ }
2072
+ const BaseRouter = {
2073
+ getInitialState: vi.fn(() => getState()),
2074
+ getRehydratedState: vi.fn((state) => state),
2075
+ getStateForRouteNamesChange: vi.fn((state) => state),
2076
+ getStateForRouteFocus: vi.fn((state) => state),
2077
+ getStateForAction: vi.fn((state) => state),
2078
+ shouldActionChangeFocus: vi.fn(() => false)
2079
+ };
2080
+ /** A router factory: `StackRouter(options)` and the rest return a Router. */
2081
+ const routerFactory = (type, actionCreators) => vi.fn((_options) => ({
2082
+ ...BaseRouter,
2083
+ type,
2084
+ getInitialState: vi.fn(() => ({
2085
+ ...getState(),
2086
+ type
2087
+ })),
2088
+ actionCreators
2089
+ }));
2090
+ const BaseNavigationContainer = React.forwardRef((props, ref) => React.createElement(hostClass("BaseNavigationContainer"), {
2017
2091
  ...props,
2018
2092
  ref
2019
2093
  }, props.children));
@@ -2029,12 +2103,12 @@ function navigation(presetOptions = {}) {
2029
2103
  useNavigationContainerRef,
2030
2104
  createNavigationContainerRef,
2031
2105
  createNavigatorFactory: vi.fn((Navigator) => () => ({
2032
- Navigator: Navigator ?? React.forwardRef((props, ref) => React.createElement(hostComponent("Navigator"), {
2106
+ Navigator: Navigator ?? React.forwardRef((props, ref) => React.createElement(hostClass("Navigator"), {
2033
2107
  ...props,
2034
2108
  ref
2035
2109
  }, props.children)),
2036
2110
  Screen,
2037
- Group: React.forwardRef((props, ref) => React.createElement(hostComponent("Group"), {
2111
+ Group: React.forwardRef((props, ref) => React.createElement(hostClass("Group"), {
2038
2112
  ...props,
2039
2113
  ref
2040
2114
  }, props.children))
@@ -2043,6 +2117,13 @@ function navigation(presetOptions = {}) {
2043
2117
  state: getState(),
2044
2118
  navigation: useNavigation(),
2045
2119
  descriptors: {},
2120
+ describe: vi.fn((route) => ({
2121
+ route,
2122
+ navigation: useNavigation(),
2123
+ options: {},
2124
+ render: () => null
2125
+ })),
2126
+ render: vi.fn(() => null),
2046
2127
  NavigationContent: ({ children }) => children
2047
2128
  })),
2048
2129
  NavigationContext,
@@ -2059,25 +2140,10 @@ function navigation(presetOptions = {}) {
2059
2140
  PreventRemoveProvider,
2060
2141
  usePreventRemove: vi.fn(),
2061
2142
  usePreventRemoveContext: vi.fn(() => null),
2062
- CommonActions: {
2063
- navigate: vi.fn(),
2064
- reset: vi.fn(),
2065
- goBack: vi.fn(),
2066
- setParams: vi.fn()
2067
- },
2068
- StackActions: {
2069
- push: vi.fn(),
2070
- pop: vi.fn(),
2071
- popToTop: vi.fn(),
2072
- replace: vi.fn()
2073
- },
2074
- TabActions: { jumpTo: vi.fn() },
2075
- DrawerActions: {
2076
- openDrawer: vi.fn(),
2077
- closeDrawer: vi.fn(),
2078
- toggleDrawer: vi.fn(),
2079
- jumpTo: vi.fn()
2080
- },
2143
+ CommonActions,
2144
+ StackActions,
2145
+ TabActions,
2146
+ DrawerActions,
2081
2147
  findFocusedRoute: vi.fn((state) => state?.routes?.[state?.index ?? 0]),
2082
2148
  getFocusedRouteNameFromRoute: vi.fn((route) => route?.state?.routes?.[route?.state?.index ?? 0]?.name),
2083
2149
  getActionFromState: vi.fn(() => void 0),
@@ -2088,6 +2154,22 @@ function navigation(presetOptions = {}) {
2088
2154
  BaseNavigationContainer,
2089
2155
  createComponentForStaticNavigation: vi.fn(() => () => null),
2090
2156
  createPathConfigForStaticNavigation: vi.fn(() => ({})),
2157
+ createScreenFactory: () => (config) => config,
2158
+ NavigationProvider,
2159
+ createStandardNavigationFactories: vi.fn(() => ({
2160
+ createNavigator: () => ({
2161
+ Navigator: React.forwardRef((props, ref) => React.createElement(hostClass("Navigator"), {
2162
+ ...props,
2163
+ ref
2164
+ }, props.children)),
2165
+ Screen,
2166
+ Group: React.forwardRef((props, ref) => React.createElement(hostClass("Group"), {
2167
+ ...props,
2168
+ ref
2169
+ }, props.children))
2170
+ }),
2171
+ createScreen: (config) => config
2172
+ })),
2091
2173
  LinkingContext,
2092
2174
  LocaleDirContext,
2093
2175
  UNSTABLE_UnhandledLinkingContext,
@@ -2109,17 +2191,13 @@ function navigation(presetOptions = {}) {
2109
2191
  })),
2110
2192
  useLocale: vi.fn(() => ({ direction: "ltr" })),
2111
2193
  useRoutePath: vi.fn(() => void 0),
2112
- BaseRouter: {
2113
- getInitialState: vi.fn(() => getState()),
2114
- getRehydratedState: vi.fn((state) => state),
2115
- getStateForRouteNamesChange: vi.fn((state) => state),
2116
- getStateForRouteFocus: vi.fn((state) => state),
2117
- getStateForAction: vi.fn((state) => state),
2118
- shouldActionChangeFocus: vi.fn(() => false)
2119
- },
2194
+ BaseRouter,
2195
+ StackRouter: routerFactory("stack", StackActions),
2196
+ TabRouter: routerFactory("tab", TabActions),
2197
+ DrawerRouter: routerFactory("drawer", DrawerActions),
2120
2198
  useScrollToTop: vi.fn(),
2121
2199
  useLinkTo: vi.fn(() => vi.fn()),
2122
- Link: React.forwardRef((props, ref) => React.createElement(hostComponent("Link"), {
2200
+ Link: React.forwardRef((props, ref) => React.createElement(hostClass("Link"), {
2123
2201
  ...props,
2124
2202
  ref
2125
2203
  }, props.children))
@@ -2127,38 +2205,53 @@ function navigation(presetOptions = {}) {
2127
2205
  }
2128
2206
  },
2129
2207
  "@react-navigation/native-stack": {
2130
- exports: ["createNativeStackNavigator"],
2131
- factory: () => {
2208
+ exports: [
2209
+ "createNativeStackNavigator",
2210
+ "createNativeStackScreen",
2211
+ "NativeStackView"
2212
+ ],
2213
+ factory: ({ React }) => {
2214
+ const { hostComponent: hostClass } = hosts(React);
2215
+ const { Screen } = shared(React);
2132
2216
  function createNativeStackNavigator() {
2133
2217
  return {
2134
- Navigator: React.forwardRef((props, ref) => React.createElement(hostComponent("NativeStackNavigator"), {
2218
+ Navigator: React.forwardRef((props, ref) => React.createElement(hostClass("NativeStackNavigator"), {
2135
2219
  ...props,
2136
2220
  ref
2137
2221
  }, props.children)),
2138
2222
  Screen,
2139
- Group: React.forwardRef((props, ref) => React.createElement(hostComponent("Group"), {
2223
+ Group: React.forwardRef((props, ref) => React.createElement(hostClass("Group"), {
2140
2224
  ...props,
2141
2225
  ref
2142
2226
  }, props.children))
2143
2227
  };
2144
2228
  }
2229
+ const NativeStackView = React.forwardRef((props, ref) => React.createElement(hostClass("NativeStackView"), {
2230
+ ...props,
2231
+ ref
2232
+ }, props.children));
2233
+ NativeStackView.displayName = "NativeStackView";
2145
2234
  return {
2146
2235
  default: { createNativeStackNavigator },
2147
- createNativeStackNavigator
2236
+ createNativeStackNavigator,
2237
+ createNativeStackScreen: (config) => config,
2238
+ NativeStackView
2148
2239
  };
2149
2240
  }
2150
2241
  },
2151
2242
  "@react-navigation/bottom-tabs": {
2152
2243
  exports: ["createBottomTabNavigator"],
2153
- factory: () => {
2244
+ factory: ({ React }) => {
2245
+ const { hostComponent: hostClass } = hosts(React);
2246
+ const { Screen } = shared(React);
2154
2247
  function createBottomTabNavigator() {
2155
2248
  return {
2156
- Navigator: React.forwardRef((props, ref) => React.createElement(hostComponent("BottomTabNavigator"), {
2249
+ Navigator: React.forwardRef((props, ref) => React.createElement(hostClass("BottomTabNavigator"), {
2157
2250
  ...props,
2158
2251
  ref
2159
2252
  }, props.children)),
2160
2253
  Screen,
2161
- Group: React.forwardRef((props, ref) => React.createElement(hostComponent("Group"), {
2254
+ Group: React.forwardRef((props, ref) => React.createElement(hostClass("Group"), {
2162
2255
  ...props,
2163
2256
  ref
2164
2257
  }, props.children))
@@ -2172,15 +2265,17 @@ function navigation(presetOptions = {}) {
2172
2265
  },
2173
2266
  "@react-navigation/drawer": {
2174
2267
  exports: ["createDrawerNavigator"],
2175
- factory: () => {
2268
+ factory: ({ React }) => {
2269
+ const { hostComponent: hostClass } = hosts(React);
2270
+ const { Screen } = shared(React);
2176
2271
  function createDrawerNavigator() {
2177
2272
  return {
2178
- Navigator: React.forwardRef((props, ref) => React.createElement(hostComponent("DrawerNavigator"), {
2273
+ Navigator: React.forwardRef((props, ref) => React.createElement(hostClass("DrawerNavigator"), {
2179
2274
  ...props,
2180
2275
  ref
2181
2276
  }, props.children)),
2182
2277
  Screen,
2183
- Group: React.forwardRef((props, ref) => React.createElement(hostComponent("Group"), {
2278
+ Group: React.forwardRef((props, ref) => React.createElement(hostClass("Group"), {
2184
2279
  ...props,
2185
2280
  ref
2186
2281
  }, props.children))
@@ -2205,23 +2300,24 @@ function navigation(presetOptions = {}) {
2205
2300
  "getDefaultHeaderHeight",
2206
2301
  "getHeaderTitle"
2207
2302
  ],
2208
- factory: () => {
2209
- const Header = React.forwardRef((props, ref) => React.createElement(hostComponent("Header"), {
2303
+ factory: ({ React }) => {
2304
+ const { hostComponent: hostClass } = hosts(React);
2305
+ const Header = React.forwardRef((props, ref) => React.createElement(hostClass("Header"), {
2210
2306
  ...props,
2211
2307
  ref
2212
2308
  }, props.children));
2213
2309
  Header.displayName = "Header";
2214
- const HeaderBackground = React.forwardRef((props, ref) => React.createElement(hostComponent("HeaderBackground"), {
2310
+ const HeaderBackground = React.forwardRef((props, ref) => React.createElement(hostClass("HeaderBackground"), {
2215
2311
  ...props,
2216
2312
  ref
2217
2313
  }, props.children));
2218
2314
  HeaderBackground.displayName = "HeaderBackground";
2219
- const HeaderBackButton = React.forwardRef((props, ref) => React.createElement(hostComponent("HeaderBackButton"), {
2315
+ const HeaderBackButton = React.forwardRef((props, ref) => React.createElement(hostClass("HeaderBackButton"), {
2220
2316
  ...props,
2221
2317
  ref
2222
2318
  }));
2223
2319
  HeaderBackButton.displayName = "HeaderBackButton";
2224
- const HeaderTitle = React.forwardRef((props, ref) => React.createElement(hostComponent("HeaderTitle"), {
2320
+ const HeaderTitle = React.forwardRef((props, ref) => React.createElement(hostClass("HeaderTitle"), {
2225
2321
  ...props,
2226
2322
  ref
2227
2323
  }, props.children));
@@ -2370,7 +2466,8 @@ function screens() {
2370
2466
  "NativeScreen",
2371
2467
  "NativeScreenContainer"
2372
2468
  ],
2373
- factory: () => {
2469
+ factory: ({ React }) => {
2470
+ const { hostComponent: hostClass, asHost } = hosts(React);
2374
2471
  let screensEnabledFlag = true;
2375
2472
  let freezeEnabledFlag = false;
2376
2473
  const enableScreens = vi.fn((shouldEnableScreens) => {
@@ -2400,7 +2497,7 @@ function screens() {
2400
2497
  const InnerScreen = createScreenComponent("InnerScreen");
2401
2498
  const ScreenContentWrapper = createScreenComponent("ScreenContentWrapper");
2402
2499
  const ScreenFooter = createScreenComponent("ScreenFooter");
2403
- const ScreenStackItem = React.forwardRef(({ headerConfig, children, ...props }, ref) => React.createElement(hostComponent("ScreenStackItem"), {
2500
+ const ScreenStackItem = React.forwardRef(({ headerConfig, children, ...props }, ref) => React.createElement(hostClass("ScreenStackItem"), {
2404
2501
  ...props,
2405
2502
  ref
2406
2503
  }, children, React.createElement(ScreenStackHeaderConfig, headerConfig)));
@@ -2629,8 +2726,9 @@ function expo() {
2629
2726
  "setStatusBarTranslucent",
2630
2727
  "setStatusBarNetworkActivityIndicatorVisible"
2631
2728
  ],
2632
- factory: () => {
2633
- const StatusBar = React.forwardRef((props, ref) => React.createElement(hostComponent("StatusBar"), {
2729
+ factory: ({ React }) => {
2730
+ const { hostComponent: hostClass } = hosts(React);
2731
+ const StatusBar = React.forwardRef((props, ref) => React.createElement(hostClass("StatusBar"), {
2634
2732
  ...props,
2635
2733
  ref
2636
2734
  }, props.children));
@@ -2753,7 +2851,8 @@ function mmkv() {
2753
2851
  "useMMKVListener",
2754
2852
  "Mode"
2755
2853
  ],
2756
- factory: () => {
2854
+ factory: ({ React }) => {
2855
+ const { useState } = React;
2757
2856
  class MMKV {
2758
2857
  _store = /* @__PURE__ */ new Map();
2759
2858
  set(key, value) {
@@ -3002,7 +3101,8 @@ function svg() {
3002
3101
  "SvgCss",
3003
3102
  "SvgCssUri"
3004
3103
  ],
3005
- factory: () => {
3104
+ factory: ({ React }) => {
3105
+ const { asHost } = hosts(React);
3006
3106
  const make = (name) => {
3007
3107
  const C = React.forwardRef((props, ref) => React.createElement(asHost(name), {
3008
3108
  ...props,
@@ -3029,7 +3129,7 @@ function webview() {
3029
3129
  name: "webview",
3030
3130
  modules: { "react-native-webview": {
3031
3131
  exports: ["WebView"],
3032
- factory: () => {
3132
+ factory: ({ React }) => {
3033
3133
  const WebView = React.forwardRef((props, ref) => {
3034
3134
  React.useImperativeHandle(ref, () => ({
3035
3135
  reload: () => {},
@@ -3068,7 +3168,7 @@ function vectorIcons() {
3068
3168
  "setDynamicLoadingEnabled",
3069
3169
  "setDynamicLoadingErrorCallback"
3070
3170
  ],
3071
- factory: () => {
3171
+ factory: ({ React }) => {
3072
3172
  const createIconSet = (_glyphMap, _options) => {
3073
3173
  const Icon = React.forwardRef((props, ref) => {
3074
3174
  const { size = DEFAULT_ICON_SIZE, color = DEFAULT_ICON_COLOR, style, children, ...rest } = props;
@@ -3126,7 +3226,8 @@ function flashList() {
3126
3226
  "useFlashListContext",
3127
3227
  "useBenchmark"
3128
3228
  ],
3129
- factory: () => {
3229
+ factory: ({ React }) => {
3230
+ const { hostComponent: hostClass } = hosts(React);
3130
3231
  const renderElement = (Component) => {
3131
3232
  if (Component == null) return null;
3132
3233
  if (React.isValidElement(Component)) return Component;
@@ -3166,7 +3267,7 @@ function flashList() {
3166
3267
  return List;
3167
3268
  }
3168
3269
  const FlashList = createFlashList("FlashList");
3169
- const LayoutCommitObserver = React.forwardRef((props, ref) => React.createElement(hostComponent("LayoutCommitObserver"), {
3270
+ const LayoutCommitObserver = React.forwardRef((props, ref) => React.createElement(hostClass("LayoutCommitObserver"), {
3170
3271
  ...props,
3171
3272
  ref
3172
3273
  }, props.children));
@@ -3194,7 +3295,7 @@ function flashList() {
3194
3295
  });
3195
3296
  }
3196
3297
  // src/mocks/components/TextInput.ts
3197
- function createTextInputMock() {
3298
+ function createTextInputMock(React) {
3198
3299
  const TextInput = React.forwardRef((props, ref) => {
3199
3300
  const instanceMethods = {
3200
3301
  focus: vi.fn(),
@@ -3212,8 +3313,27 @@ function createTextInputMock() {
3212
3313
  TextInput.displayName = "TextInput";
3213
3314
  return TextInput;
3214
3315
  }
3316
+ // src/mocks/components/ScrollView.ts
3317
+ function createScrollViewMock(React) {
3318
+ const ScrollView = React.forwardRef((props, ref) => {
3319
+ const { children, refreshControl, ...rest } = props;
3320
+ const instanceMethods = {
3321
+ scrollTo: vi.fn(),
3322
+ scrollToEnd: vi.fn(),
3323
+ flashScrollIndicators: vi.fn(),
3324
+ getScrollResponder: vi.fn(() => ({})),
3325
+ getInnerViewNode: vi.fn(),
3326
+ setNativeProps: vi.fn()
3327
+ };
3328
+ React.useImperativeHandle(ref, () => instanceMethods);
3329
+ return React.createElement("RCTScrollView", rest, refreshControl, React.createElement("View", null, children));
3330
+ });
3331
+ ScrollView.displayName = "ScrollView";
3332
+ return ScrollView;
3333
+ }
3215
3334
  // src/mocks/components/FlatList.ts
3216
- function createFlatListMock() {
3335
+ function createFlatListMock(React) {
3336
+ const { hostComponent } = hosts(React);
3217
3337
  const FlatList = React.forwardRef((props, ref) => {
3218
3338
  const { data, renderItem, keyExtractor, ListHeaderComponent, ListFooterComponent, ListEmptyComponent, ItemSeparatorComponent, refreshControl, ...rest } = props;
3219
3339
  const instanceMethods = {
@@ -3256,7 +3376,8 @@ function createFlatListMock() {
3256
3376
  return FlatList;
3257
3377
  }
3258
3378
  // src/mocks/components/SectionList.ts
3259
- function createSectionListMock() {
3379
+ function createSectionListMock(React) {
3380
+ const { hostComponent } = hosts(React);
3260
3381
  const SectionList = React.forwardRef((props, ref) => {
3261
3382
  const { sections, renderItem, renderSectionHeader, renderSectionFooter, keyExtractor, refreshControl, ListEmptyComponent, ListHeaderComponent, ListFooterComponent, ItemSeparatorComponent, SectionSeparatorComponent, ...rest } = props;
3262
3383
  const instanceMethods = {
@@ -3304,7 +3425,8 @@ function createSectionListMock() {
3304
3425
  return SectionList;
3305
3426
  }
3306
3427
  // src/mocks/components/VirtualizedList.ts
3307
- function createVirtualizedListMock() {
3428
+ function createVirtualizedListMock(React) {
3429
+ const { hostComponent } = hosts(React);
3308
3430
  const VirtualizedList = React.forwardRef((props, ref) => {
3309
3431
  const { data, renderItem, keyExtractor, getItemCount, getItem, ListHeaderComponent, ListFooterComponent, ListEmptyComponent, ...rest } = props;
3310
3432
  const instanceMethods = {
@@ -3343,19 +3465,22 @@ function createVirtualizedListMock() {
3343
3465
  return VirtualizedList;
3344
3466
  }
3345
3467
  // src/mocks/components/TouchableOpacity.ts
3346
- function createTouchableOpacityMock() {
3468
+ function createTouchableOpacityMock(React) {
3469
+ const { hostComponent } = hosts(React);
3347
3470
  const TouchableOpacity = React.forwardRef((props, ref) => React.createElement(hostComponent("TouchableOpacity"), buildPressableHostProps(props, ref)));
3348
3471
  TouchableOpacity.displayName = "TouchableOpacity";
3349
3472
  return TouchableOpacity;
3350
3473
  }
3351
3474
  // src/mocks/components/TouchableHighlight.ts
3352
- function createTouchableHighlightMock() {
3475
+ function createTouchableHighlightMock(React) {
3476
+ const { hostComponent } = hosts(React);
3353
3477
  const TouchableHighlight = React.forwardRef((props, ref) => React.createElement(hostComponent("TouchableHighlight"), buildPressableHostProps(props, ref)));
3354
3478
  TouchableHighlight.displayName = "TouchableHighlight";
3355
3479
  return TouchableHighlight;
3356
3480
  }
3357
3481
  // src/mocks/components/TouchableWithoutFeedback.ts
3358
- function createTouchableWithoutFeedbackMock() {
3482
+ function createTouchableWithoutFeedbackMock(React) {
3483
+ const { hostComponent } = hosts(React);
3359
3484
  const TouchableWithoutFeedback = React.forwardRef((props, ref) => React.createElement(hostComponent("TouchableWithoutFeedback"), buildPressableHostProps(props, ref)));
3360
3485
  TouchableWithoutFeedback.displayName = "TouchableWithoutFeedback";
3361
3486
  return TouchableWithoutFeedback;
@@ -3408,7 +3533,7 @@ function bottomSheet() {
3408
3533
  "KEYBOARD_STATUS",
3409
3534
  "GESTURE_SOURCE"
3410
3535
  ],
3411
- factory: () => {
3536
+ factory: ({ React }) => {
3412
3537
  function container(name, methods = {}) {
3413
3538
  const Component = React.forwardRef((props, ref) => {
3414
3539
  React.useImperativeHandle(ref, () => methods);
@@ -3441,15 +3566,15 @@ function bottomSheet() {
3441
3566
  BottomSheetFooter: container("BottomSheetFooter"),
3442
3567
  BottomSheetFooterContainer: container("BottomSheetFooterContainer"),
3443
3568
  BottomSheetHandle: container("BottomSheetHandle"),
3444
- BottomSheetScrollView: createScrollViewMock(),
3445
- BottomSheetFlatList: createFlatListMock(),
3446
- BottomSheetSectionList: createSectionListMock(),
3447
- BottomSheetVirtualizedList: createVirtualizedListMock(),
3448
- BottomSheetFlashList: createFlatListMock(),
3449
- BottomSheetTextInput: createTextInputMock(),
3450
- TouchableOpacity: createTouchableOpacityMock(),
3451
- TouchableHighlight: createTouchableHighlightMock(),
3452
- TouchableWithoutFeedback: createTouchableWithoutFeedbackMock(),
3569
+ BottomSheetScrollView: createScrollViewMock(React),
3570
+ BottomSheetFlatList: createFlatListMock(React),
3571
+ BottomSheetSectionList: createSectionListMock(React),
3572
+ BottomSheetVirtualizedList: createVirtualizedListMock(React),
3573
+ BottomSheetFlashList: createFlatListMock(React),
3574
+ BottomSheetTextInput: createTextInputMock(React),
3575
+ TouchableOpacity: createTouchableOpacityMock(React),
3576
+ TouchableHighlight: createTouchableHighlightMock(React),
3577
+ TouchableWithoutFeedback: createTouchableWithoutFeedbackMock(React),
3453
3578
  useBottomSheet: () => ({
3454
3579
  ...sheetMethods,
3455
3580
  animatedIndex: { value: 0 },
@@ -3469,7 +3594,7 @@ function bottomSheet() {
3469
3594
  animatedContentHeight: { value: 0 },
3470
3595
  handleContentLayout: vi.fn()
3471
3596
  }),
3472
- createBottomSheetScrollableComponent: vi.fn(() => createScrollViewMock()),
3597
+ createBottomSheetScrollableComponent: vi.fn(() => createScrollViewMock(React)),
3473
3598
  enableLogging: vi.fn(),
3474
3599
  SNAP_POINT_TYPE: {
3475
3600
  PROVIDED: 0,
@@ -3530,6 +3655,195 @@ function bottomSheet() {
3530
3655
  }) }
3531
3656
  });
3532
3657
  }
3658
+ // src/mocks/components/View.ts
3659
+ function createViewMock(React) {
3660
+ const { hostComponent } = hosts(React);
3661
+ const View = React.forwardRef((props, ref) => {
3662
+ return React.createElement(hostComponent("View"), {
3663
+ ...props,
3664
+ ref
3665
+ });
3666
+ });
3667
+ View.displayName = "View";
3668
+ return View;
3669
+ }
3670
+ // src/presets/keyboard-controller.ts
3671
+ const KEYBOARD_CONTROLLER_MOCK = {
3672
+ pkg: "react-native-keyboard-controller",
3673
+ entry: "jest",
3674
+ file: "jest/index.js"
3675
+ };
3676
+ function keyboardController() {
3677
+ return builtInPreset({
3678
+ name: "keyboardController",
3679
+ modules: { "react-native-keyboard-controller": libraryMockModule(KEYBOARD_CONTROLLER_MOCK, {
3680
+ exports: [
3681
+ "KeyboardProvider",
3682
+ "KeyboardControllerView",
3683
+ "KeyboardGestureArea",
3684
+ "OverKeyboardView",
3685
+ "KeyboardBackgroundView",
3686
+ "KeyboardExtender",
3687
+ "KeyboardStickyView",
3688
+ "KeyboardAvoidingView",
3689
+ "KeyboardAwareScrollView",
3690
+ "KeyboardChatScrollView",
3691
+ "KeyboardToolbar",
3692
+ "KeyboardController",
3693
+ "KeyboardEvents",
3694
+ "AndroidSoftInputModes",
3695
+ "DefaultKeyboardToolbarTheme",
3696
+ "useKeyboardAnimation",
3697
+ "useReanimatedKeyboardAnimation",
3698
+ "useResizeMode",
3699
+ "useGenericKeyboardHandler",
3700
+ "useKeyboardHandler",
3701
+ "useKeyboardContext",
3702
+ "useKeyboardState",
3703
+ "useReanimatedFocusedInput",
3704
+ "useFocusedInputHandler",
3705
+ "useKeyboardController",
3706
+ "useWindowDimensions"
3707
+ ],
3708
+ factory: ({ React }) => {
3709
+ const { asHost } = hosts(React);
3710
+ function hostComponent(name) {
3711
+ const Component = React.forwardRef((props, ref) => React.createElement(asHost(name), {
3712
+ ...props,
3713
+ ref
3714
+ }, props.children));
3715
+ Component.displayName = name;
3716
+ return Component;
3717
+ }
3718
+ const sharedValue = (value) => ({
3719
+ value,
3720
+ get: () => value,
3721
+ set: () => {}
3722
+ });
3723
+ const animationValues = {
3724
+ animated: {
3725
+ progress: sharedValue(0),
3726
+ height: sharedValue(0)
3727
+ },
3728
+ reanimated: {
3729
+ progress: sharedValue(0),
3730
+ height: sharedValue(0)
3731
+ }
3732
+ };
3733
+ const lastKeyboardEvent = {
3734
+ height: 0,
3735
+ duration: 0,
3736
+ timestamp: 0,
3737
+ target: 0,
3738
+ type: "default",
3739
+ appearance: "default"
3740
+ };
3741
+ const keyboardState = {
3742
+ ...lastKeyboardEvent,
3743
+ isVisible: false
3744
+ };
3745
+ const focusedInput = { input: sharedValue({
3746
+ target: 1,
3747
+ parentScrollViewTarget: -1,
3748
+ layout: {
3749
+ x: 0,
3750
+ y: 0,
3751
+ width: 200,
3752
+ height: 40,
3753
+ absoluteX: 0,
3754
+ absoluteY: 100
3755
+ }
3756
+ }) };
3757
+ const KeyboardToolbar = Object.assign(createViewMock(React), {
3758
+ Background: hostComponent("KeyboardToolbar.Background"),
3759
+ Content: hostComponent("KeyboardToolbar.Content"),
3760
+ Prev: hostComponent("KeyboardToolbar.Prev"),
3761
+ Next: hostComponent("KeyboardToolbar.Next"),
3762
+ Done: hostComponent("KeyboardToolbar.Done"),
3763
+ Group: hostComponent("KeyboardToolbar.Group")
3764
+ });
3765
+ return {
3766
+ KeyboardProvider: hostComponent("KeyboardProvider"),
3767
+ KeyboardControllerView: hostComponent("KeyboardControllerView"),
3768
+ KeyboardGestureArea: hostComponent("KeyboardGestureArea"),
3769
+ OverKeyboardView: hostComponent("OverKeyboardView"),
3770
+ KeyboardBackgroundView: hostComponent("KeyboardBackgroundView"),
3771
+ KeyboardExtender: hostComponent("KeyboardExtender"),
3772
+ KeyboardStickyView: createViewMock(React),
3773
+ KeyboardAvoidingView: createViewMock(React),
3774
+ KeyboardAwareScrollView: createScrollViewMock(React),
3775
+ KeyboardChatScrollView: createScrollViewMock(React),
3776
+ KeyboardToolbar,
3777
+ KeyboardController: {
3778
+ setInputMode: vi.fn(),
3779
+ setDefaultMode: vi.fn(),
3780
+ preload: vi.fn(),
3781
+ dismiss: vi.fn(() => Promise.resolve()),
3782
+ setFocusTo: vi.fn(),
3783
+ isVisible: vi.fn(() => false),
3784
+ state: vi.fn(() => lastKeyboardEvent),
3785
+ viewPositionInWindow: vi.fn(() => Promise.resolve({
3786
+ x: 0,
3787
+ y: 0,
3788
+ width: 0,
3789
+ height: 0
3790
+ }))
3791
+ },
3792
+ KeyboardEvents: { addListener: vi.fn(() => ({ remove: vi.fn() })) },
3793
+ AndroidSoftInputModes: {
3794
+ SOFT_INPUT_ADJUST_NOTHING: 48,
3795
+ SOFT_INPUT_ADJUST_PAN: 32,
3796
+ SOFT_INPUT_ADJUST_RESIZE: 16,
3797
+ SOFT_INPUT_ADJUST_UNSPECIFIED: 0,
3798
+ SOFT_INPUT_IS_FORWARD_NAVIGATION: 256,
3799
+ SOFT_INPUT_MASK_ADJUST: 240,
3800
+ SOFT_INPUT_MASK_STATE: 15,
3801
+ SOFT_INPUT_MODE_CHANGED: 512,
3802
+ SOFT_INPUT_STATE_ALWAYS_HIDDEN: 3,
3803
+ SOFT_INPUT_STATE_ALWAYS_VISIBLE: 5,
3804
+ SOFT_INPUT_STATE_HIDDEN: 2,
3805
+ SOFT_INPUT_STATE_UNCHANGED: 1,
3806
+ SOFT_INPUT_STATE_UNSPECIFIED: 0,
3807
+ SOFT_INPUT_STATE_VISIBLE: 4
3808
+ },
3809
+ DefaultKeyboardToolbarTheme: {
3810
+ light: {
3811
+ primary: "#2c2c2c",
3812
+ disabled: "#B0BEC5",
3813
+ background: "#f3f3f4",
3814
+ ripple: "#bcbcbcbc"
3815
+ },
3816
+ dark: {
3817
+ primary: "#fafafa",
3818
+ disabled: "#707070",
3819
+ background: "#2C2C2E",
3820
+ ripple: "#F8F8F888"
3821
+ }
3822
+ },
3823
+ useKeyboardAnimation: () => animationValues.animated,
3824
+ useReanimatedKeyboardAnimation: () => animationValues.reanimated,
3825
+ useResizeMode: () => {},
3826
+ useGenericKeyboardHandler: () => {},
3827
+ useKeyboardHandler: () => {},
3828
+ useKeyboardContext: () => animationValues,
3829
+ useKeyboardState: (selector) => selector ? selector(keyboardState) : keyboardState,
3830
+ useReanimatedFocusedInput: () => focusedInput,
3831
+ useFocusedInputHandler: () => {},
3832
+ useKeyboardController: () => ({
3833
+ enabled: true,
3834
+ setEnabled: vi.fn()
3835
+ }),
3836
+ useWindowDimensions: () => ({
3837
+ width: 390,
3838
+ height: 844,
3839
+ scale: 3,
3840
+ fontScale: 1
3841
+ })
3842
+ };
3843
+ }
3844
+ }) }
3845
+ });
3846
+ }
3533
3847
  // src/presets/worklets.ts
3534
3848
  const RuntimeKind = {
3535
3849
  ReactNative: 1,
@@ -3635,17 +3949,18 @@ function worklets() {
3635
3949
  });
3636
3950
  }
3637
3951
  // src/presets/unistyles.ts
3638
- let rnCache = null;
3639
- /** The active React Native: the mock engine's, or real RN under the native engine. */
3952
+ /**
3953
+ * The active React Native: the mock engine's, or real RN under the native engine.
3954
+ * Required on each call, a module-cache hit: a copy kept for the worker would be the
3955
+ * first file's components, built with its React (freshRuntime, #719).
3956
+ */
3640
3957
  function getRN() {
3641
- if (rnCache) return rnCache;
3642
3958
  try {
3643
3959
  const base = path.join(projectContext()?.projectRoot ?? process.cwd(), "package.json");
3644
- rnCache = createRequire(base)("react-native");
3960
+ return createRequire(base)("react-native");
3645
3961
  } catch {
3646
- rnCache = {};
3962
+ return {};
3647
3963
  }
3648
- return rnCache;
3649
3964
  }
3650
3965
  const isObject = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
3651
3966
  /** src/utils.ts `deepMergeObjects` (withUnistyles' merge). */
@@ -3835,7 +4150,7 @@ function unistyles() {
3835
4150
  "getServerUnistyles",
3836
4151
  "resetServerUnistyles"
3837
4152
  ],
3838
- factory: () => buildUnistyles()
4153
+ factory: ({ React }) => buildUnistyles(React)
3839
4154
  },
3840
4155
  "react-native-unistyles/reanimated": {
3841
4156
  exports: ["useAnimatedTheme", "useAnimatedVariantColor"],
@@ -3858,7 +4173,8 @@ function unistyles() {
3858
4173
  }
3859
4174
  });
3860
4175
  }
3861
- function buildUnistyles() {
4176
+ function buildUnistyles(React) {
4177
+ const { asHost } = hosts(React);
3862
4178
  const configured = () => ({
3863
4179
  themes: {},
3864
4180
  sortedBreakpoints: [],
@@ -4445,4 +4761,4 @@ var presets_exports = /* @__PURE__ */ __exportAll({
4445
4761
  webview: () => webview,
4446
4762
  worklets: () => worklets
4447
4763
  });
4448
- export { KEYBOARD_CONTROLLER_MOCK as A, navigation as C, reanimated as D, buildPressableHostProps as E, BUILT_IN_PRESET as F, createScrollViewMock as M, createViewMock as N, SAFE_AREA_MOCK as O, hostComponent as P, asyncStorage as S, createPressableMock as T, netInfo as _, bottomSheet as a, expo as b, createTouchableOpacityMock as c, createFlatListMock as d, createTextInputMock as f, svg as g, webview as h, worklets as i, keyboardController as j, safeAreaContext as k, createVirtualizedListMock as l, vectorIcons as m, skia as n, createTouchableWithoutFeedbackMock as o, flashList as p, unistyles as r, createTouchableHighlightMock as s, presets_exports as t, createSectionListMock as u, mmkv as v, gestureHandler as w, screens as x, deviceInfo as y };
4764
+ export { buildPressableHostProps as A, expo as C, safeAreaContext as D, navigation as E, hosts as M, BUILT_IN_PRESET as N, gestureHandler as O, deviceInfo as S, asyncStorage as T, vectorIcons as _, keyboardController as a, netInfo as b, createTouchableWithoutFeedbackMock as c, createVirtualizedListMock as d, createSectionListMock as f, flashList as g, createTextInputMock as h, worklets as i, reanimated as j, createPressableMock as k, createTouchableHighlightMock as l, createScrollViewMock as m, skia as n, createViewMock as o, createFlatListMock as p, unistyles as r, bottomSheet as s, presets_exports as t, createTouchableOpacityMock as u, webview as v, screens as w, mmkv as x, svg as y };