vitest-native 0.2.0 → 0.2.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # vitest-native
2
2
 
3
+ ## 0.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Add missing `@react-navigation/core` re-exports to navigation preset, including `useNavigationContainerRef`, `useTheme`, `ThemeProvider`, `NavigationIndependentTree`, `useNavigationBuilder`, `BaseRouter`, and 20+ other exports. Fixes tests that depend on these being available from `@react-navigation/native`.
8
+
3
9
  ## 0.2.0
4
10
 
5
11
  ### Minor Changes
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_presets = require("./presets-D4jrt194.cjs");
2
+ const require_presets = require("./presets-9Y4ssfiH.cjs");
3
3
  const require_preset_map = require("./preset-map-Bt4dXkZO.cjs");
4
4
  let node_url = require("node:url");
5
5
  let node_path = require("node:path");
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { t as AUTO_DETECT_PRESETS } from "./preset-map-D224CC5w.mjs";
2
- import { t as presets_exports } from "./presets-C9tAPD15.mjs";
2
+ import { t as presets_exports } from "./presets-CWH0gtM0.mjs";
3
3
  import { createRequire } from "node:module";
4
4
  import { fileURLToPath } from "node:url";
5
5
  import path from "node:path";
@@ -471,20 +471,46 @@ function navigation() {
471
471
  "@react-navigation/native": {
472
472
  exports: [
473
473
  "NavigationContainer",
474
+ "useLinkTo",
475
+ "Link",
474
476
  "useNavigation",
475
477
  "useRoute",
476
478
  "useFocusEffect",
477
479
  "useIsFocused",
478
480
  "useNavigationState",
481
+ "useNavigationContainerRef",
479
482
  "createNavigationContainerRef",
483
+ "createNavigatorFactory",
484
+ "useNavigationBuilder",
480
485
  "NavigationContext",
481
486
  "NavigationRouteContext",
487
+ "NavigationContainerRefContext",
488
+ "NavigationHelpersContext",
489
+ "CurrentRenderContext",
490
+ "ThemeContext",
491
+ "ThemeProvider",
492
+ "useTheme",
493
+ "NavigationIndependentTree",
494
+ "useNavigationIndependentTree",
495
+ "PreventRemoveContext",
496
+ "PreventRemoveProvider",
497
+ "usePreventRemove",
498
+ "usePreventRemoveContext",
482
499
  "CommonActions",
483
500
  "StackActions",
484
501
  "TabActions",
485
502
  "DrawerActions",
486
- "useLinkTo",
487
- "Link"
503
+ "findFocusedRoute",
504
+ "getFocusedRouteNameFromRoute",
505
+ "getActionFromState",
506
+ "getPathFromState",
507
+ "getStateFromPath",
508
+ "useStateForPath",
509
+ "validatePathConfig",
510
+ "BaseNavigationContainer",
511
+ "createComponentForStaticNavigation",
512
+ "createPathConfigForStaticNavigation",
513
+ "BaseRouter"
488
514
  ],
489
515
  factory: () => {
490
516
  const NavigationContainer = react.default.forwardRef((props, ref) => react.default.createElement("NavigationContainer", {
@@ -560,8 +586,50 @@ function navigation() {
560
586
  addListener: vitest.vi.fn(() => vitest.vi.fn())
561
587
  };
562
588
  }
589
+ function useNavigationContainerRef() {
590
+ return createNavigationContainerRef();
591
+ }
563
592
  const NavigationContext = react.default.createContext(null);
564
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
+ const defaultTheme = {
603
+ dark: false,
604
+ colors: {
605
+ primary: "rgb(0, 122, 255)",
606
+ background: "rgb(242, 242, 242)",
607
+ card: "rgb(255, 255, 255)",
608
+ text: "rgb(28, 28, 30)",
609
+ border: "rgb(216, 216, 216)",
610
+ notification: "rgb(255, 59, 48)"
611
+ }
612
+ };
613
+ function ThemeProvider({ value, children }) {
614
+ return react.default.createElement(ThemeContext.Provider, { value: value ?? defaultTheme }, children);
615
+ }
616
+ function useTheme() {
617
+ return defaultTheme;
618
+ }
619
+ function NavigationIndependentTree({ children }) {
620
+ return children;
621
+ }
622
+ function useNavigationIndependentTree() {
623
+ return true;
624
+ }
625
+ function PreventRemoveProvider({ children }) {
626
+ return children;
627
+ }
628
+ const BaseNavigationContainer = react.default.forwardRef((props, ref) => react.default.createElement("BaseNavigationContainer", {
629
+ ...props,
630
+ ref
631
+ }, props.children));
632
+ BaseNavigationContainer.displayName = "BaseNavigationContainer";
565
633
  return {
566
634
  default: { NavigationContainer },
567
635
  NavigationContainer,
@@ -570,9 +638,29 @@ function navigation() {
570
638
  useFocusEffect,
571
639
  useIsFocused,
572
640
  useNavigationState,
641
+ useNavigationContainerRef,
573
642
  createNavigationContainerRef,
643
+ createNavigatorFactory: vitest.vi.fn(() => vitest.vi.fn()),
644
+ useNavigationBuilder: vitest.vi.fn(() => ({
645
+ state: getState(),
646
+ navigation: useNavigation(),
647
+ descriptors: {},
648
+ NavigationContent: ({ children }) => children
649
+ })),
574
650
  NavigationContext,
575
651
  NavigationRouteContext,
652
+ NavigationContainerRefContext,
653
+ NavigationHelpersContext,
654
+ CurrentRenderContext,
655
+ ThemeContext,
656
+ ThemeProvider,
657
+ useTheme,
658
+ NavigationIndependentTree,
659
+ useNavigationIndependentTree,
660
+ PreventRemoveContext,
661
+ PreventRemoveProvider,
662
+ usePreventRemove: vitest.vi.fn(),
663
+ usePreventRemoveContext: vitest.vi.fn(() => null),
576
664
  CommonActions: {
577
665
  navigate: vitest.vi.fn(),
578
666
  reset: vitest.vi.fn(),
@@ -592,6 +680,24 @@ function navigation() {
592
680
  toggleDrawer: vitest.vi.fn(),
593
681
  jumpTo: vitest.vi.fn()
594
682
  },
683
+ findFocusedRoute: vitest.vi.fn((state) => state?.routes?.[state?.index ?? 0]),
684
+ getFocusedRouteNameFromRoute: vitest.vi.fn((route) => route?.state?.routes?.[route?.state?.index ?? 0]?.name),
685
+ getActionFromState: vitest.vi.fn(() => void 0),
686
+ getPathFromState: vitest.vi.fn(() => "/"),
687
+ getStateFromPath: vitest.vi.fn(() => void 0),
688
+ useStateForPath: vitest.vi.fn(() => void 0),
689
+ validatePathConfig: vitest.vi.fn(),
690
+ BaseNavigationContainer,
691
+ createComponentForStaticNavigation: vitest.vi.fn(() => () => null),
692
+ createPathConfigForStaticNavigation: vitest.vi.fn(() => ({})),
693
+ BaseRouter: {
694
+ getInitialState: vitest.vi.fn(() => getState()),
695
+ getRehydratedState: vitest.vi.fn((state) => state),
696
+ getStateForRouteNamesChange: vitest.vi.fn((state) => state),
697
+ getStateForRouteFocus: vitest.vi.fn((state) => state),
698
+ getStateForAction: vitest.vi.fn((state) => state),
699
+ shouldActionChangeFocus: vitest.vi.fn(() => false)
700
+ },
595
701
  useLinkTo: vitest.vi.fn(() => vitest.vi.fn()),
596
702
  Link: react.default.forwardRef((props, ref) => react.default.createElement("Link", {
597
703
  ...props,
@@ -440,20 +440,46 @@ function navigation() {
440
440
  "@react-navigation/native": {
441
441
  exports: [
442
442
  "NavigationContainer",
443
+ "useLinkTo",
444
+ "Link",
443
445
  "useNavigation",
444
446
  "useRoute",
445
447
  "useFocusEffect",
446
448
  "useIsFocused",
447
449
  "useNavigationState",
450
+ "useNavigationContainerRef",
448
451
  "createNavigationContainerRef",
452
+ "createNavigatorFactory",
453
+ "useNavigationBuilder",
449
454
  "NavigationContext",
450
455
  "NavigationRouteContext",
456
+ "NavigationContainerRefContext",
457
+ "NavigationHelpersContext",
458
+ "CurrentRenderContext",
459
+ "ThemeContext",
460
+ "ThemeProvider",
461
+ "useTheme",
462
+ "NavigationIndependentTree",
463
+ "useNavigationIndependentTree",
464
+ "PreventRemoveContext",
465
+ "PreventRemoveProvider",
466
+ "usePreventRemove",
467
+ "usePreventRemoveContext",
451
468
  "CommonActions",
452
469
  "StackActions",
453
470
  "TabActions",
454
471
  "DrawerActions",
455
- "useLinkTo",
456
- "Link"
472
+ "findFocusedRoute",
473
+ "getFocusedRouteNameFromRoute",
474
+ "getActionFromState",
475
+ "getPathFromState",
476
+ "getStateFromPath",
477
+ "useStateForPath",
478
+ "validatePathConfig",
479
+ "BaseNavigationContainer",
480
+ "createComponentForStaticNavigation",
481
+ "createPathConfigForStaticNavigation",
482
+ "BaseRouter"
457
483
  ],
458
484
  factory: () => {
459
485
  const NavigationContainer = React.forwardRef((props, ref) => React.createElement("NavigationContainer", {
@@ -529,8 +555,50 @@ function navigation() {
529
555
  addListener: vi.fn(() => vi.fn())
530
556
  };
531
557
  }
558
+ function useNavigationContainerRef() {
559
+ return createNavigationContainerRef();
560
+ }
532
561
  const NavigationContext = React.createContext(null);
533
562
  const NavigationRouteContext = React.createContext(null);
563
+ const NavigationContainerRefContext = React.createContext(null);
564
+ const NavigationHelpersContext = React.createContext(null);
565
+ const CurrentRenderContext = React.createContext(void 0);
566
+ const ThemeContext = React.createContext({
567
+ dark: false,
568
+ colors: {}
569
+ });
570
+ const PreventRemoveContext = React.createContext(null);
571
+ const defaultTheme = {
572
+ dark: false,
573
+ colors: {
574
+ primary: "rgb(0, 122, 255)",
575
+ background: "rgb(242, 242, 242)",
576
+ card: "rgb(255, 255, 255)",
577
+ text: "rgb(28, 28, 30)",
578
+ border: "rgb(216, 216, 216)",
579
+ notification: "rgb(255, 59, 48)"
580
+ }
581
+ };
582
+ function ThemeProvider({ value, children }) {
583
+ return React.createElement(ThemeContext.Provider, { value: value ?? defaultTheme }, children);
584
+ }
585
+ function useTheme() {
586
+ return defaultTheme;
587
+ }
588
+ function NavigationIndependentTree({ children }) {
589
+ return children;
590
+ }
591
+ function useNavigationIndependentTree() {
592
+ return true;
593
+ }
594
+ function PreventRemoveProvider({ children }) {
595
+ return children;
596
+ }
597
+ const BaseNavigationContainer = React.forwardRef((props, ref) => React.createElement("BaseNavigationContainer", {
598
+ ...props,
599
+ ref
600
+ }, props.children));
601
+ BaseNavigationContainer.displayName = "BaseNavigationContainer";
534
602
  return {
535
603
  default: { NavigationContainer },
536
604
  NavigationContainer,
@@ -539,9 +607,29 @@ function navigation() {
539
607
  useFocusEffect,
540
608
  useIsFocused,
541
609
  useNavigationState,
610
+ useNavigationContainerRef,
542
611
  createNavigationContainerRef,
612
+ createNavigatorFactory: vi.fn(() => vi.fn()),
613
+ useNavigationBuilder: vi.fn(() => ({
614
+ state: getState(),
615
+ navigation: useNavigation(),
616
+ descriptors: {},
617
+ NavigationContent: ({ children }) => children
618
+ })),
543
619
  NavigationContext,
544
620
  NavigationRouteContext,
621
+ NavigationContainerRefContext,
622
+ NavigationHelpersContext,
623
+ CurrentRenderContext,
624
+ ThemeContext,
625
+ ThemeProvider,
626
+ useTheme,
627
+ NavigationIndependentTree,
628
+ useNavigationIndependentTree,
629
+ PreventRemoveContext,
630
+ PreventRemoveProvider,
631
+ usePreventRemove: vi.fn(),
632
+ usePreventRemoveContext: vi.fn(() => null),
545
633
  CommonActions: {
546
634
  navigate: vi.fn(),
547
635
  reset: vi.fn(),
@@ -561,6 +649,24 @@ function navigation() {
561
649
  toggleDrawer: vi.fn(),
562
650
  jumpTo: vi.fn()
563
651
  },
652
+ findFocusedRoute: vi.fn((state) => state?.routes?.[state?.index ?? 0]),
653
+ getFocusedRouteNameFromRoute: vi.fn((route) => route?.state?.routes?.[route?.state?.index ?? 0]?.name),
654
+ getActionFromState: vi.fn(() => void 0),
655
+ getPathFromState: vi.fn(() => "/"),
656
+ getStateFromPath: vi.fn(() => void 0),
657
+ useStateForPath: vi.fn(() => void 0),
658
+ validatePathConfig: vi.fn(),
659
+ BaseNavigationContainer,
660
+ createComponentForStaticNavigation: vi.fn(() => () => null),
661
+ createPathConfigForStaticNavigation: vi.fn(() => ({})),
662
+ BaseRouter: {
663
+ getInitialState: vi.fn(() => getState()),
664
+ getRehydratedState: vi.fn((state) => state),
665
+ getStateForRouteNamesChange: vi.fn((state) => state),
666
+ getStateForRouteFocus: vi.fn((state) => state),
667
+ getStateForAction: vi.fn((state) => state),
668
+ shouldActionChangeFocus: vi.fn(() => false)
669
+ },
564
670
  useLinkTo: vi.fn(() => vi.fn()),
565
671
  Link: React.forwardRef((props, ref) => React.createElement("Link", {
566
672
  ...props,
package/dist/presets.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_presets = require("./presets-D4jrt194.cjs");
2
+ const require_presets = require("./presets-9Y4ssfiH.cjs");
3
3
  exports.asyncStorage = require_presets.asyncStorage;
4
4
  exports.expo = require_presets.expo;
5
5
  exports.gestureHandler = require_presets.gestureHandler;
package/dist/presets.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { a as navigation, c as reanimated, i as asyncStorage, n as expo, o as safeAreaContext, r as screens, s as gestureHandler } from "./presets-C9tAPD15.mjs";
1
+ import { a as navigation, c as reanimated, i as asyncStorage, n as expo, o as safeAreaContext, r as screens, s as gestureHandler } from "./presets-CWH0gtM0.mjs";
2
2
  export { asyncStorage, expo, gestureHandler, navigation, reanimated, safeAreaContext, screens };
package/dist/setup.cjs CHANGED
@@ -1,4 +1,4 @@
1
- const require_presets = require("./presets-D4jrt194.cjs");
1
+ const require_presets = require("./presets-9Y4ssfiH.cjs");
2
2
  const require_preset_map = require("./preset-map-Bt4dXkZO.cjs");
3
3
  const require_serializer = require("./serializer.cjs");
4
4
  let node_path = require("node:path");
package/dist/setup.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { n as __require } from "./chunk-CjcI7cDX.mjs";
2
2
  import { t as AUTO_DETECT_PRESETS } from "./preset-map-D224CC5w.mjs";
3
- import { t as presets_exports } from "./presets-C9tAPD15.mjs";
3
+ import { t as presets_exports } from "./presets-CWH0gtM0.mjs";
4
4
  import { serializer } from "./serializer.mjs";
5
5
  import { createRequire } from "node:module";
6
6
  import path from "node:path";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitest-native",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "type": "module",
5
5
  "description": "A Vitest plugin for React Native. One install, zero config.",
6
6
  "license": "MIT",