UNPKG

49.5 kBJavaScriptView Raw
1/**
2 * React Router v6.4.4
3 *
4 * Copyright (c) Remix Software Inc.
5 *
6 * This source code is licensed under the MIT license found in the
7 * LICENSE.md file in the root directory of this source tree.
8 *
9 * @license MIT
10 */
11import { invariant, joinPaths, matchPath, UNSAFE_getPathContributingMatches, warning, resolveTo, parsePath, matchRoutes, Action, isRouteErrorResponse, createMemoryHistory, stripBasename, AbortedDeferredError, createRouter } from '@remix-run/router';
12export { AbortedDeferredError, Action as NavigationType, createPath, defer, generatePath, isRouteErrorResponse, json, matchPath, matchRoutes, parsePath, redirect, resolvePath } from '@remix-run/router';
13import * as React from 'react';
14
15function _extends() {
16 _extends = Object.assign ? Object.assign.bind() : function (target) {
17 for (var i = 1; i < arguments.length; i++) {
18 var source = arguments[i];
19
20 for (var key in source) {
21 if (Object.prototype.hasOwnProperty.call(source, key)) {
22 target[key] = source[key];
23 }
24 }
25 }
26
27 return target;
28 };
29 return _extends.apply(this, arguments);
30}
31
32/**
33 * Copyright (c) Facebook, Inc. and its affiliates.
34 *
35 * This source code is licensed under the MIT license found in the
36 * LICENSE file in the root directory of this source tree.
37 */
38/**
39 * inlined Object.is polyfill to avoid requiring consumers ship their own
40 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
41 */
42
43function isPolyfill(x, y) {
44 return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare
45 ;
46}
47
48const is = typeof Object.is === "function" ? Object.is : isPolyfill; // Intentionally not using named imports because Rollup uses dynamic
49// dispatch for CommonJS interop named imports.
50
51const {
52 useState,
53 useEffect,
54 useLayoutEffect,
55 useDebugValue
56} = React;
57let didWarnOld18Alpha = false;
58let didWarnUncachedGetSnapshot = false; // Disclaimer: This shim breaks many of the rules of React, and only works
59// because of a very particular set of implementation details and assumptions
60// -- change any one of them and it will break. The most important assumption
61// is that updates are always synchronous, because concurrent rendering is
62// only available in versions of React that also have a built-in
63// useSyncExternalStore API. And we only use this shim when the built-in API
64// does not exist.
65//
66// Do not assume that the clever hacks used by this hook also work in general.
67// The point of this shim is to replace the need for hacks by other libraries.
68
69function useSyncExternalStore$2(subscribe, getSnapshot, // Note: The shim does not use getServerSnapshot, because pre-18 versions of
70// React do not expose a way to check if we're hydrating. So users of the shim
71// will need to track that themselves and return the correct value
72// from `getSnapshot`.
73getServerSnapshot) {
74 if (process.env.NODE_ENV !== "production") {
75 if (!didWarnOld18Alpha) {
76 if ("startTransition" in React) {
77 didWarnOld18Alpha = true;
78 console.error("You are using an outdated, pre-release alpha of React 18 that " + "does not support useSyncExternalStore. The " + "use-sync-external-store shim will not work correctly. Upgrade " + "to a newer pre-release.");
79 }
80 }
81 } // Read the current snapshot from the store on every render. Again, this
82 // breaks the rules of React, and only works here because of specific
83 // implementation details, most importantly that updates are
84 // always synchronous.
85
86
87 const value = getSnapshot();
88
89 if (process.env.NODE_ENV !== "production") {
90 if (!didWarnUncachedGetSnapshot) {
91 const cachedValue = getSnapshot();
92
93 if (!is(value, cachedValue)) {
94 console.error("The result of getSnapshot should be cached to avoid an infinite loop");
95 didWarnUncachedGetSnapshot = true;
96 }
97 }
98 } // Because updates are synchronous, we don't queue them. Instead we force a
99 // re-render whenever the subscribed state changes by updating an some
100 // arbitrary useState hook. Then, during render, we call getSnapshot to read
101 // the current value.
102 //
103 // Because we don't actually use the state returned by the useState hook, we
104 // can save a bit of memory by storing other stuff in that slot.
105 //
106 // To implement the early bailout, we need to track some things on a mutable
107 // object. Usually, we would put that in a useRef hook, but we can stash it in
108 // our useState hook instead.
109 //
110 // To force a re-render, we call forceUpdate({inst}). That works because the
111 // new object always fails an equality check.
112
113
114 const [{
115 inst
116 }, forceUpdate] = useState({
117 inst: {
118 value,
119 getSnapshot
120 }
121 }); // Track the latest getSnapshot function with a ref. This needs to be updated
122 // in the layout phase so we can access it during the tearing check that
123 // happens on subscribe.
124
125 useLayoutEffect(() => {
126 inst.value = value;
127 inst.getSnapshot = getSnapshot; // Whenever getSnapshot or subscribe changes, we need to check in the
128 // commit phase if there was an interleaved mutation. In concurrent mode
129 // this can happen all the time, but even in synchronous mode, an earlier
130 // effect may have mutated the store.
131
132 if (checkIfSnapshotChanged(inst)) {
133 // Force a re-render.
134 forceUpdate({
135 inst
136 });
137 } // eslint-disable-next-line react-hooks/exhaustive-deps
138
139 }, [subscribe, value, getSnapshot]);
140 useEffect(() => {
141 // Check for changes right before subscribing. Subsequent changes will be
142 // detected in the subscription handler.
143 if (checkIfSnapshotChanged(inst)) {
144 // Force a re-render.
145 forceUpdate({
146 inst
147 });
148 }
149
150 const handleStoreChange = () => {
151 // TODO: Because there is no cross-renderer API for batching updates, it's
152 // up to the consumer of this library to wrap their subscription event
153 // with unstable_batchedUpdates. Should we try to detect when this isn't
154 // the case and print a warning in development?
155 // The store changed. Check if the snapshot changed since the last time we
156 // read from the store.
157 if (checkIfSnapshotChanged(inst)) {
158 // Force a re-render.
159 forceUpdate({
160 inst
161 });
162 }
163 }; // Subscribe to the store and return a clean-up function.
164
165
166 return subscribe(handleStoreChange); // eslint-disable-next-line react-hooks/exhaustive-deps
167 }, [subscribe]);
168 useDebugValue(value);
169 return value;
170}
171
172function checkIfSnapshotChanged(inst) {
173 const latestGetSnapshot = inst.getSnapshot;
174 const prevValue = inst.value;
175
176 try {
177 const nextValue = latestGetSnapshot();
178 return !is(prevValue, nextValue);
179 } catch (error) {
180 return true;
181 }
182}
183
184/**
185 * Copyright (c) Facebook, Inc. and its affiliates.
186 *
187 * This source code is licensed under the MIT license found in the
188 * LICENSE file in the root directory of this source tree.
189 *
190 * @flow
191 */
192function useSyncExternalStore$1(subscribe, getSnapshot, getServerSnapshot) {
193 // Note: The shim does not use getServerSnapshot, because pre-18 versions of
194 // React do not expose a way to check if we're hydrating. So users of the shim
195 // will need to track that themselves and return the correct value
196 // from `getSnapshot`.
197 return getSnapshot();
198}
199
200/**
201 * Inlined into the react-router repo since use-sync-external-store does not
202 * provide a UMD-compatible package, so we need this to be able to distribute
203 * UMD react-router bundles
204 */
205const canUseDOM = !!(typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined");
206const isServerEnvironment = !canUseDOM;
207const shim = isServerEnvironment ? useSyncExternalStore$1 : useSyncExternalStore$2;
208const useSyncExternalStore = "useSyncExternalStore" in React ? (module => module.useSyncExternalStore)(React) : shim;
209
210// Contexts for data routers
211const DataStaticRouterContext = /*#__PURE__*/React.createContext(null);
212
213if (process.env.NODE_ENV !== "production") {
214 DataStaticRouterContext.displayName = "DataStaticRouterContext";
215}
216
217const DataRouterContext = /*#__PURE__*/React.createContext(null);
218
219if (process.env.NODE_ENV !== "production") {
220 DataRouterContext.displayName = "DataRouter";
221}
222
223const DataRouterStateContext = /*#__PURE__*/React.createContext(null);
224
225if (process.env.NODE_ENV !== "production") {
226 DataRouterStateContext.displayName = "DataRouterState";
227}
228
229const AwaitContext = /*#__PURE__*/React.createContext(null);
230
231if (process.env.NODE_ENV !== "production") {
232 AwaitContext.displayName = "Await";
233}
234
235const NavigationContext = /*#__PURE__*/React.createContext(null);
236
237if (process.env.NODE_ENV !== "production") {
238 NavigationContext.displayName = "Navigation";
239}
240
241const LocationContext = /*#__PURE__*/React.createContext(null);
242
243if (process.env.NODE_ENV !== "production") {
244 LocationContext.displayName = "Location";
245}
246
247const RouteContext = /*#__PURE__*/React.createContext({
248 outlet: null,
249 matches: []
250});
251
252if (process.env.NODE_ENV !== "production") {
253 RouteContext.displayName = "Route";
254}
255
256const RouteErrorContext = /*#__PURE__*/React.createContext(null);
257
258if (process.env.NODE_ENV !== "production") {
259 RouteErrorContext.displayName = "RouteError";
260}
261
262/**
263 * Returns the full href for the given "to" value. This is useful for building
264 * custom links that are also accessible and preserve right-click behavior.
265 *
266 * @see https://reactrouter.com/docs/en/v6/hooks/use-href
267 */
268
269function useHref(to, _temp) {
270 let {
271 relative
272 } = _temp === void 0 ? {} : _temp;
273 !useInRouterContext() ? process.env.NODE_ENV !== "production" ? invariant(false, // TODO: This error is probably because they somehow have 2 versions of the
274 // router loaded. We can help them understand how to avoid that.
275 "useHref() may be used only in the context of a <Router> component.") : invariant(false) : void 0;
276 let {
277 basename,
278 navigator
279 } = React.useContext(NavigationContext);
280 let {
281 hash,
282 pathname,
283 search
284 } = useResolvedPath(to, {
285 relative
286 });
287 let joinedPathname = pathname; // If we're operating within a basename, prepend it to the pathname prior
288 // to creating the href. If this is a root navigation, then just use the raw
289 // basename which allows the basename to have full control over the presence
290 // of a trailing slash on root links
291
292 if (basename !== "/") {
293 joinedPathname = pathname === "/" ? basename : joinPaths([basename, pathname]);
294 }
295
296 return navigator.createHref({
297 pathname: joinedPathname,
298 search,
299 hash
300 });
301}
302/**
303 * Returns true if this component is a descendant of a <Router>.
304 *
305 * @see https://reactrouter.com/docs/en/v6/hooks/use-in-router-context
306 */
307
308function useInRouterContext() {
309 return React.useContext(LocationContext) != null;
310}
311/**
312 * Returns the current location object, which represents the current URL in web
313 * browsers.
314 *
315 * Note: If you're using this it may mean you're doing some of your own
316 * "routing" in your app, and we'd like to know what your use case is. We may
317 * be able to provide something higher-level to better suit your needs.
318 *
319 * @see https://reactrouter.com/docs/en/v6/hooks/use-location
320 */
321
322function useLocation() {
323 !useInRouterContext() ? process.env.NODE_ENV !== "production" ? invariant(false, // TODO: This error is probably because they somehow have 2 versions of the
324 // router loaded. We can help them understand how to avoid that.
325 "useLocation() may be used only in the context of a <Router> component.") : invariant(false) : void 0;
326 return React.useContext(LocationContext).location;
327}
328/**
329 * Returns the current navigation action which describes how the router came to
330 * the current location, either by a pop, push, or replace on the history stack.
331 *
332 * @see https://reactrouter.com/docs/en/v6/hooks/use-navigation-type
333 */
334
335function useNavigationType() {
336 return React.useContext(LocationContext).navigationType;
337}
338/**
339 * Returns a PathMatch object if the given pattern matches the current URL.
340 * This is useful for components that need to know "active" state, e.g.
341 * <NavLink>.
342 *
343 * @see https://reactrouter.com/docs/en/v6/hooks/use-match
344 */
345
346function useMatch(pattern) {
347 !useInRouterContext() ? process.env.NODE_ENV !== "production" ? invariant(false, // TODO: This error is probably because they somehow have 2 versions of the
348 // router loaded. We can help them understand how to avoid that.
349 "useMatch() may be used only in the context of a <Router> component.") : invariant(false) : void 0;
350 let {
351 pathname
352 } = useLocation();
353 return React.useMemo(() => matchPath(pattern, pathname), [pathname, pattern]);
354}
355/**
356 * The interface for the navigate() function returned from useNavigate().
357 */
358
359/**
360 * Returns an imperative method for changing the location. Used by <Link>s, but
361 * may also be used by other elements to change the location.
362 *
363 * @see https://reactrouter.com/docs/en/v6/hooks/use-navigate
364 */
365function useNavigate() {
366 !useInRouterContext() ? process.env.NODE_ENV !== "production" ? invariant(false, // TODO: This error is probably because they somehow have 2 versions of the
367 // router loaded. We can help them understand how to avoid that.
368 "useNavigate() may be used only in the context of a <Router> component.") : invariant(false) : void 0;
369 let {
370 basename,
371 navigator
372 } = React.useContext(NavigationContext);
373 let {
374 matches
375 } = React.useContext(RouteContext);
376 let {
377 pathname: locationPathname
378 } = useLocation();
379 let routePathnamesJson = JSON.stringify(UNSAFE_getPathContributingMatches(matches).map(match => match.pathnameBase));
380 let activeRef = React.useRef(false);
381 React.useEffect(() => {
382 activeRef.current = true;
383 });
384 let navigate = React.useCallback(function (to, options) {
385 if (options === void 0) {
386 options = {};
387 }
388
389 process.env.NODE_ENV !== "production" ? warning(activeRef.current, "You should call navigate() in a React.useEffect(), not when " + "your component is first rendered.") : void 0;
390 if (!activeRef.current) return;
391
392 if (typeof to === "number") {
393 navigator.go(to);
394 return;
395 }
396
397 let path = resolveTo(to, JSON.parse(routePathnamesJson), locationPathname, options.relative === "path"); // If we're operating within a basename, prepend it to the pathname prior
398 // to handing off to history. If this is a root navigation, then we
399 // navigate to the raw basename which allows the basename to have full
400 // control over the presence of a trailing slash on root links
401
402 if (basename !== "/") {
403 path.pathname = path.pathname === "/" ? basename : joinPaths([basename, path.pathname]);
404 }
405
406 (!!options.replace ? navigator.replace : navigator.push)(path, options.state, options);
407 }, [basename, navigator, routePathnamesJson, locationPathname]);
408 return navigate;
409}
410const OutletContext = /*#__PURE__*/React.createContext(null);
411/**
412 * Returns the context (if provided) for the child route at this level of the route
413 * hierarchy.
414 * @see https://reactrouter.com/docs/en/v6/hooks/use-outlet-context
415 */
416
417function useOutletContext() {
418 return React.useContext(OutletContext);
419}
420/**
421 * Returns the element for the child route at this level of the route
422 * hierarchy. Used internally by <Outlet> to render child routes.
423 *
424 * @see https://reactrouter.com/docs/en/v6/hooks/use-outlet
425 */
426
427function useOutlet(context) {
428 let outlet = React.useContext(RouteContext).outlet;
429
430 if (outlet) {
431 return /*#__PURE__*/React.createElement(OutletContext.Provider, {
432 value: context
433 }, outlet);
434 }
435
436 return outlet;
437}
438/**
439 * Returns an object of key/value pairs of the dynamic params from the current
440 * URL that were matched by the route path.
441 *
442 * @see https://reactrouter.com/docs/en/v6/hooks/use-params
443 */
444
445function useParams() {
446 let {
447 matches
448 } = React.useContext(RouteContext);
449 let routeMatch = matches[matches.length - 1];
450 return routeMatch ? routeMatch.params : {};
451}
452/**
453 * Resolves the pathname of the given `to` value against the current location.
454 *
455 * @see https://reactrouter.com/docs/en/v6/hooks/use-resolved-path
456 */
457
458function useResolvedPath(to, _temp2) {
459 let {
460 relative
461 } = _temp2 === void 0 ? {} : _temp2;
462 let {
463 matches
464 } = React.useContext(RouteContext);
465 let {
466 pathname: locationPathname
467 } = useLocation();
468 let routePathnamesJson = JSON.stringify(UNSAFE_getPathContributingMatches(matches).map(match => match.pathnameBase));
469 return React.useMemo(() => resolveTo(to, JSON.parse(routePathnamesJson), locationPathname, relative === "path"), [to, routePathnamesJson, locationPathname, relative]);
470}
471/**
472 * Returns the element of the route that matched the current location, prepared
473 * with the correct context to render the remainder of the route tree. Route
474 * elements in the tree must render an <Outlet> to render their child route's
475 * element.
476 *
477 * @see https://reactrouter.com/docs/en/v6/hooks/use-routes
478 */
479
480function useRoutes(routes, locationArg) {
481 !useInRouterContext() ? process.env.NODE_ENV !== "production" ? invariant(false, // TODO: This error is probably because they somehow have 2 versions of the
482 // router loaded. We can help them understand how to avoid that.
483 "useRoutes() may be used only in the context of a <Router> component.") : invariant(false) : void 0;
484 let {
485 navigator
486 } = React.useContext(NavigationContext);
487 let dataRouterStateContext = React.useContext(DataRouterStateContext);
488 let {
489 matches: parentMatches
490 } = React.useContext(RouteContext);
491 let routeMatch = parentMatches[parentMatches.length - 1];
492 let parentParams = routeMatch ? routeMatch.params : {};
493 let parentPathname = routeMatch ? routeMatch.pathname : "/";
494 let parentPathnameBase = routeMatch ? routeMatch.pathnameBase : "/";
495 let parentRoute = routeMatch && routeMatch.route;
496
497 if (process.env.NODE_ENV !== "production") {
498 // You won't get a warning about 2 different <Routes> under a <Route>
499 // without a trailing *, but this is a best-effort warning anyway since we
500 // cannot even give the warning unless they land at the parent route.
501 //
502 // Example:
503 //
504 // <Routes>
505 // {/* This route path MUST end with /* because otherwise
506 // it will never match /blog/post/123 */}
507 // <Route path="blog" element={<Blog />} />
508 // <Route path="blog/feed" element={<BlogFeed />} />
509 // </Routes>
510 //
511 // function Blog() {
512 // return (
513 // <Routes>
514 // <Route path="post/:id" element={<Post />} />
515 // </Routes>
516 // );
517 // }
518 let parentPath = parentRoute && parentRoute.path || "";
519 warningOnce(parentPathname, !parentRoute || parentPath.endsWith("*"), "You rendered descendant <Routes> (or called `useRoutes()`) at " + ("\"" + parentPathname + "\" (under <Route path=\"" + parentPath + "\">) but the ") + "parent route path has no trailing \"*\". This means if you navigate " + "deeper, the parent won't match anymore and therefore the child " + "routes will never render.\n\n" + ("Please change the parent <Route path=\"" + parentPath + "\"> to <Route ") + ("path=\"" + (parentPath === "/" ? "*" : parentPath + "/*") + "\">."));
520 }
521
522 let locationFromContext = useLocation();
523 let location;
524
525 if (locationArg) {
526 var _parsedLocationArg$pa;
527
528 let parsedLocationArg = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
529 !(parentPathnameBase === "/" || ((_parsedLocationArg$pa = parsedLocationArg.pathname) == null ? void 0 : _parsedLocationArg$pa.startsWith(parentPathnameBase))) ? process.env.NODE_ENV !== "production" ? invariant(false, "When overriding the location using `<Routes location>` or `useRoutes(routes, location)`, " + "the location pathname must begin with the portion of the URL pathname that was " + ("matched by all parent routes. The current pathname base is \"" + parentPathnameBase + "\" ") + ("but pathname \"" + parsedLocationArg.pathname + "\" was given in the `location` prop.")) : invariant(false) : void 0;
530 location = parsedLocationArg;
531 } else {
532 location = locationFromContext;
533 }
534
535 let pathname = location.pathname || "/";
536 let remainingPathname = parentPathnameBase === "/" ? pathname : pathname.slice(parentPathnameBase.length) || "/";
537 let matches = matchRoutes(routes, {
538 pathname: remainingPathname
539 });
540
541 if (process.env.NODE_ENV !== "production") {
542 process.env.NODE_ENV !== "production" ? warning(parentRoute || matches != null, "No routes matched location \"" + location.pathname + location.search + location.hash + "\" ") : void 0;
543 process.env.NODE_ENV !== "production" ? warning(matches == null || matches[matches.length - 1].route.element !== undefined, "Matched leaf route at location \"" + location.pathname + location.search + location.hash + "\" does not have an element. " + "This means it will render an <Outlet /> with a null value by default resulting in an \"empty\" page.") : void 0;
544 }
545
546 let renderedMatches = _renderMatches(matches && matches.map(match => Object.assign({}, match, {
547 params: Object.assign({}, parentParams, match.params),
548 pathname: joinPaths([parentPathnameBase, // Re-encode pathnames that were decoded inside matchRoutes
549 navigator.encodeLocation ? navigator.encodeLocation(match.pathname).pathname : match.pathname]),
550 pathnameBase: match.pathnameBase === "/" ? parentPathnameBase : joinPaths([parentPathnameBase, // Re-encode pathnames that were decoded inside matchRoutes
551 navigator.encodeLocation ? navigator.encodeLocation(match.pathnameBase).pathname : match.pathnameBase])
552 })), parentMatches, dataRouterStateContext || undefined); // When a user passes in a `locationArg`, the associated routes need to
553 // be wrapped in a new `LocationContext.Provider` in order for `useLocation`
554 // to use the scoped location instead of the global location.
555
556
557 if (locationArg && renderedMatches) {
558 return /*#__PURE__*/React.createElement(LocationContext.Provider, {
559 value: {
560 location: _extends({
561 pathname: "/",
562 search: "",
563 hash: "",
564 state: null,
565 key: "default"
566 }, location),
567 navigationType: Action.Pop
568 }
569 }, renderedMatches);
570 }
571
572 return renderedMatches;
573}
574
575function DefaultErrorElement() {
576 let error = useRouteError();
577 let message = isRouteErrorResponse(error) ? error.status + " " + error.statusText : error instanceof Error ? error.message : JSON.stringify(error);
578 let stack = error instanceof Error ? error.stack : null;
579 let lightgrey = "rgba(200,200,200, 0.5)";
580 let preStyles = {
581 padding: "0.5rem",
582 backgroundColor: lightgrey
583 };
584 let codeStyles = {
585 padding: "2px 4px",
586 backgroundColor: lightgrey
587 };
588 return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("h2", null, "Unhandled Thrown Error!"), /*#__PURE__*/React.createElement("h3", {
589 style: {
590 fontStyle: "italic"
591 }
592 }, message), stack ? /*#__PURE__*/React.createElement("pre", {
593 style: preStyles
594 }, stack) : null, /*#__PURE__*/React.createElement("p", null, "\uD83D\uDCBF Hey developer \uD83D\uDC4B"), /*#__PURE__*/React.createElement("p", null, "You can provide a way better UX than this when your app throws errors by providing your own\xA0", /*#__PURE__*/React.createElement("code", {
595 style: codeStyles
596 }, "errorElement"), " props on\xA0", /*#__PURE__*/React.createElement("code", {
597 style: codeStyles
598 }, "<Route>")));
599}
600
601class RenderErrorBoundary extends React.Component {
602 constructor(props) {
603 super(props);
604 this.state = {
605 location: props.location,
606 error: props.error
607 };
608 }
609
610 static getDerivedStateFromError(error) {
611 return {
612 error: error
613 };
614 }
615
616 static getDerivedStateFromProps(props, state) {
617 // When we get into an error state, the user will likely click "back" to the
618 // previous page that didn't have an error. Because this wraps the entire
619 // application, that will have no effect--the error page continues to display.
620 // This gives us a mechanism to recover from the error when the location changes.
621 //
622 // Whether we're in an error state or not, we update the location in state
623 // so that when we are in an error state, it gets reset when a new location
624 // comes in and the user recovers from the error.
625 if (state.location !== props.location) {
626 return {
627 error: props.error,
628 location: props.location
629 };
630 } // If we're not changing locations, preserve the location but still surface
631 // any new errors that may come through. We retain the existing error, we do
632 // this because the error provided from the app state may be cleared without
633 // the location changing.
634
635
636 return {
637 error: props.error || state.error,
638 location: state.location
639 };
640 }
641
642 componentDidCatch(error, errorInfo) {
643 console.error("React Router caught the following error during render", error, errorInfo);
644 }
645
646 render() {
647 return this.state.error ? /*#__PURE__*/React.createElement(RouteErrorContext.Provider, {
648 value: this.state.error,
649 children: this.props.component
650 }) : this.props.children;
651 }
652
653}
654
655function RenderedRoute(_ref) {
656 let {
657 routeContext,
658 match,
659 children
660 } = _ref;
661 let dataStaticRouterContext = React.useContext(DataStaticRouterContext); // Track how deep we got in our render pass to emulate SSR componentDidCatch
662 // in a DataStaticRouter
663
664 if (dataStaticRouterContext && match.route.errorElement) {
665 dataStaticRouterContext._deepestRenderedBoundaryId = match.route.id;
666 }
667
668 return /*#__PURE__*/React.createElement(RouteContext.Provider, {
669 value: routeContext
670 }, children);
671}
672
673function _renderMatches(matches, parentMatches, dataRouterState) {
674 if (parentMatches === void 0) {
675 parentMatches = [];
676 }
677
678 if (matches == null) {
679 if (dataRouterState != null && dataRouterState.errors) {
680 // Don't bail if we have data router errors so we can render them in the
681 // boundary. Use the pre-matched (or shimmed) matches
682 matches = dataRouterState.matches;
683 } else {
684 return null;
685 }
686 }
687
688 let renderedMatches = matches; // If we have data errors, trim matches to the highest error boundary
689
690 let errors = dataRouterState == null ? void 0 : dataRouterState.errors;
691
692 if (errors != null) {
693 let errorIndex = renderedMatches.findIndex(m => m.route.id && (errors == null ? void 0 : errors[m.route.id]));
694 !(errorIndex >= 0) ? process.env.NODE_ENV !== "production" ? invariant(false, "Could not find a matching route for the current errors: " + errors) : invariant(false) : void 0;
695 renderedMatches = renderedMatches.slice(0, Math.min(renderedMatches.length, errorIndex + 1));
696 }
697
698 return renderedMatches.reduceRight((outlet, match, index) => {
699 let error = match.route.id ? errors == null ? void 0 : errors[match.route.id] : null; // Only data routers handle errors
700
701 let errorElement = dataRouterState ? match.route.errorElement || /*#__PURE__*/React.createElement(DefaultErrorElement, null) : null;
702
703 let getChildren = () => /*#__PURE__*/React.createElement(RenderedRoute, {
704 match: match,
705 routeContext: {
706 outlet,
707 matches: parentMatches.concat(renderedMatches.slice(0, index + 1))
708 }
709 }, error ? errorElement : match.route.element !== undefined ? match.route.element : outlet); // Only wrap in an error boundary within data router usages when we have an
710 // errorElement on this route. Otherwise let it bubble up to an ancestor
711 // errorElement
712
713
714 return dataRouterState && (match.route.errorElement || index === 0) ? /*#__PURE__*/React.createElement(RenderErrorBoundary, {
715 location: dataRouterState.location,
716 component: errorElement,
717 error: error,
718 children: getChildren()
719 }) : getChildren();
720 }, null);
721}
722var DataRouterHook;
723
724(function (DataRouterHook) {
725 DataRouterHook["UseRevalidator"] = "useRevalidator";
726})(DataRouterHook || (DataRouterHook = {}));
727
728var DataRouterStateHook;
729
730(function (DataRouterStateHook) {
731 DataRouterStateHook["UseLoaderData"] = "useLoaderData";
732 DataRouterStateHook["UseActionData"] = "useActionData";
733 DataRouterStateHook["UseRouteError"] = "useRouteError";
734 DataRouterStateHook["UseNavigation"] = "useNavigation";
735 DataRouterStateHook["UseRouteLoaderData"] = "useRouteLoaderData";
736 DataRouterStateHook["UseMatches"] = "useMatches";
737 DataRouterStateHook["UseRevalidator"] = "useRevalidator";
738})(DataRouterStateHook || (DataRouterStateHook = {}));
739
740function getDataRouterConsoleError(hookName) {
741 return hookName + " must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.";
742}
743
744function useDataRouterContext(hookName) {
745 let ctx = React.useContext(DataRouterContext);
746 !ctx ? process.env.NODE_ENV !== "production" ? invariant(false, getDataRouterConsoleError(hookName)) : invariant(false) : void 0;
747 return ctx;
748}
749
750function useDataRouterState(hookName) {
751 let state = React.useContext(DataRouterStateContext);
752 !state ? process.env.NODE_ENV !== "production" ? invariant(false, getDataRouterConsoleError(hookName)) : invariant(false) : void 0;
753 return state;
754}
755/**
756 * Returns the current navigation, defaulting to an "idle" navigation when
757 * no navigation is in progress
758 */
759
760
761function useNavigation() {
762 let state = useDataRouterState(DataRouterStateHook.UseNavigation);
763 return state.navigation;
764}
765/**
766 * Returns a revalidate function for manually triggering revalidation, as well
767 * as the current state of any manual revalidations
768 */
769
770function useRevalidator() {
771 let dataRouterContext = useDataRouterContext(DataRouterHook.UseRevalidator);
772 let state = useDataRouterState(DataRouterStateHook.UseRevalidator);
773 return {
774 revalidate: dataRouterContext.router.revalidate,
775 state: state.revalidation
776 };
777}
778/**
779 * Returns the active route matches, useful for accessing loaderData for
780 * parent/child routes or the route "handle" property
781 */
782
783function useMatches() {
784 let {
785 matches,
786 loaderData
787 } = useDataRouterState(DataRouterStateHook.UseMatches);
788 return React.useMemo(() => matches.map(match => {
789 let {
790 pathname,
791 params
792 } = match; // Note: This structure matches that created by createUseMatchesMatch
793 // in the @remix-run/router , so if you change this please also change
794 // that :) Eventually we'll DRY this up
795
796 return {
797 id: match.route.id,
798 pathname,
799 params,
800 data: loaderData[match.route.id],
801 handle: match.route.handle
802 };
803 }), [matches, loaderData]);
804}
805/**
806 * Returns the loader data for the nearest ancestor Route loader
807 */
808
809function useLoaderData() {
810 let state = useDataRouterState(DataRouterStateHook.UseLoaderData);
811 let route = React.useContext(RouteContext);
812 !route ? process.env.NODE_ENV !== "production" ? invariant(false, "useLoaderData must be used inside a RouteContext") : invariant(false) : void 0;
813 let thisRoute = route.matches[route.matches.length - 1];
814 !thisRoute.route.id ? process.env.NODE_ENV !== "production" ? invariant(false, "useLoaderData can only be used on routes that contain a unique \"id\"") : invariant(false) : void 0;
815 return state.loaderData[thisRoute.route.id];
816}
817/**
818 * Returns the loaderData for the given routeId
819 */
820
821function useRouteLoaderData(routeId) {
822 let state = useDataRouterState(DataRouterStateHook.UseRouteLoaderData);
823 return state.loaderData[routeId];
824}
825/**
826 * Returns the action data for the nearest ancestor Route action
827 */
828
829function useActionData() {
830 let state = useDataRouterState(DataRouterStateHook.UseActionData);
831 let route = React.useContext(RouteContext);
832 !route ? process.env.NODE_ENV !== "production" ? invariant(false, "useActionData must be used inside a RouteContext") : invariant(false) : void 0;
833 return Object.values((state == null ? void 0 : state.actionData) || {})[0];
834}
835/**
836 * Returns the nearest ancestor Route error, which could be a loader/action
837 * error or a render error. This is intended to be called from your
838 * errorElement to display a proper error message.
839 */
840
841function useRouteError() {
842 var _state$errors;
843
844 let error = React.useContext(RouteErrorContext);
845 let state = useDataRouterState(DataRouterStateHook.UseRouteError);
846 let route = React.useContext(RouteContext);
847 let thisRoute = route.matches[route.matches.length - 1]; // If this was a render error, we put it in a RouteError context inside
848 // of RenderErrorBoundary
849
850 if (error) {
851 return error;
852 }
853
854 !route ? process.env.NODE_ENV !== "production" ? invariant(false, "useRouteError must be used inside a RouteContext") : invariant(false) : void 0;
855 !thisRoute.route.id ? process.env.NODE_ENV !== "production" ? invariant(false, "useRouteError can only be used on routes that contain a unique \"id\"") : invariant(false) : void 0; // Otherwise look for errors from our data router state
856
857 return (_state$errors = state.errors) == null ? void 0 : _state$errors[thisRoute.route.id];
858}
859/**
860 * Returns the happy-path data from the nearest ancestor <Await /> value
861 */
862
863function useAsyncValue() {
864 let value = React.useContext(AwaitContext);
865 return value == null ? void 0 : value._data;
866}
867/**
868 * Returns the error from the nearest ancestor <Await /> value
869 */
870
871function useAsyncError() {
872 let value = React.useContext(AwaitContext);
873 return value == null ? void 0 : value._error;
874}
875const alreadyWarned = {};
876
877function warningOnce(key, cond, message) {
878 if (!cond && !alreadyWarned[key]) {
879 alreadyWarned[key] = true;
880 process.env.NODE_ENV !== "production" ? warning(false, message) : void 0;
881 }
882}
883
884/**
885 * Given a Remix Router instance, render the appropriate UI
886 */
887function RouterProvider(_ref) {
888 let {
889 fallbackElement,
890 router
891 } = _ref;
892 // Sync router state to our component state to force re-renders
893 let state = useSyncExternalStore(router.subscribe, () => router.state, // We have to provide this so React@18 doesn't complain during hydration,
894 // but we pass our serialized hydration data into the router so state here
895 // is already synced with what the server saw
896 () => router.state);
897 let navigator = React.useMemo(() => {
898 return {
899 createHref: router.createHref,
900 encodeLocation: router.encodeLocation,
901 go: n => router.navigate(n),
902 push: (to, state, opts) => router.navigate(to, {
903 state,
904 preventScrollReset: opts == null ? void 0 : opts.preventScrollReset
905 }),
906 replace: (to, state, opts) => router.navigate(to, {
907 replace: true,
908 state,
909 preventScrollReset: opts == null ? void 0 : opts.preventScrollReset
910 })
911 };
912 }, [router]);
913 let basename = router.basename || "/";
914 return /*#__PURE__*/React.createElement(DataRouterContext.Provider, {
915 value: {
916 router,
917 navigator,
918 static: false,
919 // Do we need this?
920 basename
921 }
922 }, /*#__PURE__*/React.createElement(DataRouterStateContext.Provider, {
923 value: state
924 }, /*#__PURE__*/React.createElement(Router, {
925 basename: router.basename,
926 location: router.state.location,
927 navigationType: router.state.historyAction,
928 navigator: navigator
929 }, router.state.initialized ? /*#__PURE__*/React.createElement(Routes, null) : fallbackElement)));
930}
931
932/**
933 * A <Router> that stores all entries in memory.
934 *
935 * @see https://reactrouter.com/docs/en/v6/routers/memory-router
936 */
937function MemoryRouter(_ref2) {
938 let {
939 basename,
940 children,
941 initialEntries,
942 initialIndex
943 } = _ref2;
944 let historyRef = React.useRef();
945
946 if (historyRef.current == null) {
947 historyRef.current = createMemoryHistory({
948 initialEntries,
949 initialIndex,
950 v5Compat: true
951 });
952 }
953
954 let history = historyRef.current;
955 let [state, setState] = React.useState({
956 action: history.action,
957 location: history.location
958 });
959 React.useLayoutEffect(() => history.listen(setState), [history]);
960 return /*#__PURE__*/React.createElement(Router, {
961 basename: basename,
962 children: children,
963 location: state.location,
964 navigationType: state.action,
965 navigator: history
966 });
967}
968
969/**
970 * Changes the current location.
971 *
972 * Note: This API is mostly useful in React.Component subclasses that are not
973 * able to use hooks. In functional components, we recommend you use the
974 * `useNavigate` hook instead.
975 *
976 * @see https://reactrouter.com/docs/en/v6/components/navigate
977 */
978function Navigate(_ref3) {
979 let {
980 to,
981 replace,
982 state,
983 relative
984 } = _ref3;
985 !useInRouterContext() ? process.env.NODE_ENV !== "production" ? invariant(false, // TODO: This error is probably because they somehow have 2 versions of
986 // the router loaded. We can help them understand how to avoid that.
987 "<Navigate> may be used only in the context of a <Router> component.") : invariant(false) : void 0;
988 process.env.NODE_ENV !== "production" ? warning(!React.useContext(NavigationContext).static, "<Navigate> must not be used on the initial render in a <StaticRouter>. " + "This is a no-op, but you should modify your code so the <Navigate> is " + "only ever rendered in response to some user interaction or state change.") : void 0;
989 let dataRouterState = React.useContext(DataRouterStateContext);
990 let navigate = useNavigate();
991 React.useEffect(() => {
992 // Avoid kicking off multiple navigations if we're in the middle of a
993 // data-router navigation, since components get re-rendered when we enter
994 // a submitting/loading state
995 if (dataRouterState && dataRouterState.navigation.state !== "idle") {
996 return;
997 }
998
999 navigate(to, {
1000 replace,
1001 state,
1002 relative
1003 });
1004 });
1005 return null;
1006}
1007
1008/**
1009 * Renders the child route's element, if there is one.
1010 *
1011 * @see https://reactrouter.com/docs/en/v6/components/outlet
1012 */
1013function Outlet(props) {
1014 return useOutlet(props.context);
1015}
1016
1017/**
1018 * Declares an element that should be rendered at a certain URL path.
1019 *
1020 * @see https://reactrouter.com/docs/en/v6/components/route
1021 */
1022function Route(_props) {
1023 process.env.NODE_ENV !== "production" ? invariant(false, "A <Route> is only ever to be used as the child of <Routes> element, " + "never rendered directly. Please wrap your <Route> in a <Routes>.") : invariant(false) ;
1024}
1025
1026/**
1027 * Provides location context for the rest of the app.
1028 *
1029 * Note: You usually won't render a <Router> directly. Instead, you'll render a
1030 * router that is more specific to your environment such as a <BrowserRouter>
1031 * in web browsers or a <StaticRouter> for server rendering.
1032 *
1033 * @see https://reactrouter.com/docs/en/v6/routers/router
1034 */
1035function Router(_ref4) {
1036 let {
1037 basename: basenameProp = "/",
1038 children = null,
1039 location: locationProp,
1040 navigationType = Action.Pop,
1041 navigator,
1042 static: staticProp = false
1043 } = _ref4;
1044 !!useInRouterContext() ? process.env.NODE_ENV !== "production" ? invariant(false, "You cannot render a <Router> inside another <Router>." + " You should never have more than one in your app.") : invariant(false) : void 0; // Preserve trailing slashes on basename, so we can let the user control
1045 // the enforcement of trailing slashes throughout the app
1046
1047 let basename = basenameProp.replace(/^\/*/, "/");
1048 let navigationContext = React.useMemo(() => ({
1049 basename,
1050 navigator,
1051 static: staticProp
1052 }), [basename, navigator, staticProp]);
1053
1054 if (typeof locationProp === "string") {
1055 locationProp = parsePath(locationProp);
1056 }
1057
1058 let {
1059 pathname = "/",
1060 search = "",
1061 hash = "",
1062 state = null,
1063 key = "default"
1064 } = locationProp;
1065 let location = React.useMemo(() => {
1066 let trailingPathname = stripBasename(pathname, basename);
1067
1068 if (trailingPathname == null) {
1069 return null;
1070 }
1071
1072 return {
1073 pathname: trailingPathname,
1074 search,
1075 hash,
1076 state,
1077 key
1078 };
1079 }, [basename, pathname, search, hash, state, key]);
1080 process.env.NODE_ENV !== "production" ? warning(location != null, "<Router basename=\"" + basename + "\"> is not able to match the URL " + ("\"" + pathname + search + hash + "\" because it does not start with the ") + "basename, so the <Router> won't render anything.") : void 0;
1081
1082 if (location == null) {
1083 return null;
1084 }
1085
1086 return /*#__PURE__*/React.createElement(NavigationContext.Provider, {
1087 value: navigationContext
1088 }, /*#__PURE__*/React.createElement(LocationContext.Provider, {
1089 children: children,
1090 value: {
1091 location,
1092 navigationType
1093 }
1094 }));
1095}
1096
1097/**
1098 * A container for a nested tree of <Route> elements that renders the branch
1099 * that best matches the current location.
1100 *
1101 * @see https://reactrouter.com/docs/en/v6/components/routes
1102 */
1103function Routes(_ref5) {
1104 let {
1105 children,
1106 location
1107 } = _ref5;
1108 let dataRouterContext = React.useContext(DataRouterContext); // When in a DataRouterContext _without_ children, we use the router routes
1109 // directly. If we have children, then we're in a descendant tree and we
1110 // need to use child routes.
1111
1112 let routes = dataRouterContext && !children ? dataRouterContext.router.routes : createRoutesFromChildren(children);
1113 return useRoutes(routes, location);
1114}
1115
1116/**
1117 * Component to use for rendering lazily loaded data from returning defer()
1118 * in a loader function
1119 */
1120function Await(_ref6) {
1121 let {
1122 children,
1123 errorElement,
1124 resolve
1125 } = _ref6;
1126 return /*#__PURE__*/React.createElement(AwaitErrorBoundary, {
1127 resolve: resolve,
1128 errorElement: errorElement
1129 }, /*#__PURE__*/React.createElement(ResolveAwait, null, children));
1130}
1131var AwaitRenderStatus;
1132
1133(function (AwaitRenderStatus) {
1134 AwaitRenderStatus[AwaitRenderStatus["pending"] = 0] = "pending";
1135 AwaitRenderStatus[AwaitRenderStatus["success"] = 1] = "success";
1136 AwaitRenderStatus[AwaitRenderStatus["error"] = 2] = "error";
1137})(AwaitRenderStatus || (AwaitRenderStatus = {}));
1138
1139const neverSettledPromise = new Promise(() => {});
1140
1141class AwaitErrorBoundary extends React.Component {
1142 constructor(props) {
1143 super(props);
1144 this.state = {
1145 error: null
1146 };
1147 }
1148
1149 static getDerivedStateFromError(error) {
1150 return {
1151 error
1152 };
1153 }
1154
1155 componentDidCatch(error, errorInfo) {
1156 console.error("<Await> caught the following error during render", error, errorInfo);
1157 }
1158
1159 render() {
1160 let {
1161 children,
1162 errorElement,
1163 resolve
1164 } = this.props;
1165 let promise = null;
1166 let status = AwaitRenderStatus.pending;
1167
1168 if (!(resolve instanceof Promise)) {
1169 // Didn't get a promise - provide as a resolved promise
1170 status = AwaitRenderStatus.success;
1171 promise = Promise.resolve();
1172 Object.defineProperty(promise, "_tracked", {
1173 get: () => true
1174 });
1175 Object.defineProperty(promise, "_data", {
1176 get: () => resolve
1177 });
1178 } else if (this.state.error) {
1179 // Caught a render error, provide it as a rejected promise
1180 status = AwaitRenderStatus.error;
1181 let renderError = this.state.error;
1182 promise = Promise.reject().catch(() => {}); // Avoid unhandled rejection warnings
1183
1184 Object.defineProperty(promise, "_tracked", {
1185 get: () => true
1186 });
1187 Object.defineProperty(promise, "_error", {
1188 get: () => renderError
1189 });
1190 } else if (resolve._tracked) {
1191 // Already tracked promise - check contents
1192 promise = resolve;
1193 status = promise._error !== undefined ? AwaitRenderStatus.error : promise._data !== undefined ? AwaitRenderStatus.success : AwaitRenderStatus.pending;
1194 } else {
1195 // Raw (untracked) promise - track it
1196 status = AwaitRenderStatus.pending;
1197 Object.defineProperty(resolve, "_tracked", {
1198 get: () => true
1199 });
1200 promise = resolve.then(data => Object.defineProperty(resolve, "_data", {
1201 get: () => data
1202 }), error => Object.defineProperty(resolve, "_error", {
1203 get: () => error
1204 }));
1205 }
1206
1207 if (status === AwaitRenderStatus.error && promise._error instanceof AbortedDeferredError) {
1208 // Freeze the UI by throwing a never resolved promise
1209 throw neverSettledPromise;
1210 }
1211
1212 if (status === AwaitRenderStatus.error && !errorElement) {
1213 // No errorElement, throw to the nearest route-level error boundary
1214 throw promise._error;
1215 }
1216
1217 if (status === AwaitRenderStatus.error) {
1218 // Render via our errorElement
1219 return /*#__PURE__*/React.createElement(AwaitContext.Provider, {
1220 value: promise,
1221 children: errorElement
1222 });
1223 }
1224
1225 if (status === AwaitRenderStatus.success) {
1226 // Render children with resolved value
1227 return /*#__PURE__*/React.createElement(AwaitContext.Provider, {
1228 value: promise,
1229 children: children
1230 });
1231 } // Throw to the suspense boundary
1232
1233
1234 throw promise;
1235 }
1236
1237}
1238/**
1239 * @private
1240 * Indirection to leverage useAsyncValue for a render-prop API on <Await>
1241 */
1242
1243
1244function ResolveAwait(_ref7) {
1245 let {
1246 children
1247 } = _ref7;
1248 let data = useAsyncValue();
1249
1250 if (typeof children === "function") {
1251 return children(data);
1252 }
1253
1254 return /*#__PURE__*/React.createElement(React.Fragment, null, children);
1255} ///////////////////////////////////////////////////////////////////////////////
1256// UTILS
1257///////////////////////////////////////////////////////////////////////////////
1258
1259/**
1260 * Creates a route config from a React "children" object, which is usually
1261 * either a `<Route>` element or an array of them. Used internally by
1262 * `<Routes>` to create a route config from its children.
1263 *
1264 * @see https://reactrouter.com/docs/en/v6/utils/create-routes-from-children
1265 */
1266
1267
1268function createRoutesFromChildren(children, parentPath) {
1269 if (parentPath === void 0) {
1270 parentPath = [];
1271 }
1272
1273 let routes = [];
1274 React.Children.forEach(children, (element, index) => {
1275 if (! /*#__PURE__*/React.isValidElement(element)) {
1276 // Ignore non-elements. This allows people to more easily inline
1277 // conditionals in their route config.
1278 return;
1279 }
1280
1281 if (element.type === React.Fragment) {
1282 // Transparently support React.Fragment and its children.
1283 routes.push.apply(routes, createRoutesFromChildren(element.props.children, parentPath));
1284 return;
1285 }
1286
1287 !(element.type === Route) ? process.env.NODE_ENV !== "production" ? invariant(false, "[" + (typeof element.type === "string" ? element.type : element.type.name) + "] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>") : invariant(false) : void 0;
1288 !(!element.props.index || !element.props.children) ? process.env.NODE_ENV !== "production" ? invariant(false, "An index route cannot have child routes.") : invariant(false) : void 0;
1289 let treePath = [...parentPath, index];
1290 let route = {
1291 id: element.props.id || treePath.join("-"),
1292 caseSensitive: element.props.caseSensitive,
1293 element: element.props.element,
1294 index: element.props.index,
1295 path: element.props.path,
1296 loader: element.props.loader,
1297 action: element.props.action,
1298 errorElement: element.props.errorElement,
1299 hasErrorBoundary: element.props.errorElement != null,
1300 shouldRevalidate: element.props.shouldRevalidate,
1301 handle: element.props.handle
1302 };
1303
1304 if (element.props.children) {
1305 route.children = createRoutesFromChildren(element.props.children, treePath);
1306 }
1307
1308 routes.push(route);
1309 });
1310 return routes;
1311}
1312/**
1313 * Renders the result of `matchRoutes()` into a React element.
1314 */
1315
1316function renderMatches(matches) {
1317 return _renderMatches(matches);
1318}
1319/**
1320 * @private
1321 * Walk the route tree and add hasErrorBoundary if it's not provided, so that
1322 * users providing manual route arrays can just specify errorElement
1323 */
1324
1325function enhanceManualRouteObjects(routes) {
1326 return routes.map(route => {
1327 let routeClone = _extends({}, route);
1328
1329 if (routeClone.hasErrorBoundary == null) {
1330 routeClone.hasErrorBoundary = routeClone.errorElement != null;
1331 }
1332
1333 if (routeClone.children) {
1334 routeClone.children = enhanceManualRouteObjects(routeClone.children);
1335 }
1336
1337 return routeClone;
1338 });
1339}
1340
1341function createMemoryRouter(routes, opts) {
1342 return createRouter({
1343 basename: opts == null ? void 0 : opts.basename,
1344 history: createMemoryHistory({
1345 initialEntries: opts == null ? void 0 : opts.initialEntries,
1346 initialIndex: opts == null ? void 0 : opts.initialIndex
1347 }),
1348 hydrationData: opts == null ? void 0 : opts.hydrationData,
1349 routes: enhanceManualRouteObjects(routes)
1350 }).initialize();
1351} ///////////////////////////////////////////////////////////////////////////////
1352
1353export { Await, MemoryRouter, Navigate, Outlet, Route, Router, RouterProvider, Routes, DataRouterContext as UNSAFE_DataRouterContext, DataRouterStateContext as UNSAFE_DataRouterStateContext, DataStaticRouterContext as UNSAFE_DataStaticRouterContext, LocationContext as UNSAFE_LocationContext, NavigationContext as UNSAFE_NavigationContext, RouteContext as UNSAFE_RouteContext, enhanceManualRouteObjects as UNSAFE_enhanceManualRouteObjects, createMemoryRouter, createRoutesFromChildren, createRoutesFromChildren as createRoutesFromElements, renderMatches, useActionData, useAsyncError, useAsyncValue, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes };
1354//# sourceMappingURL=index.js.map