UNPKG

49.3 kBJavaScriptView Raw
1/**
2 * React Router v6.4.1
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, resolveTo, joinPaths, matchPath, warning, 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 true if the URL for the given "to" value 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 * When processing relative navigation we want to ignore ancestor routes that
361 * do not contribute to the path, such that index/pathless layout routes don't
362 * interfere.
363 *
364 * For example, when moving a route element into an index route and/or a
365 * pathless layout route, relative link behavior contained within should stay
366 * the same. Both of the following examples should link back to the root:
367 *
368 * <Route path="/">
369 * <Route path="accounts" element={<Link to=".."}>
370 * </Route>
371 *
372 * <Route path="/">
373 * <Route path="accounts">
374 * <Route element={<AccountsLayout />}> // <-- Does not contribute
375 * <Route index element={<Link to=".."} /> // <-- Does not contribute
376 * </Route
377 * </Route>
378 * </Route>
379 */
380function getPathContributingMatches(matches) {
381 return matches.filter((match, index) => index === 0 || !match.route.index && match.pathnameBase !== matches[index - 1].pathnameBase);
382}
383/**
384 * Returns an imperative method for changing the location. Used by <Link>s, but
385 * may also be used by other elements to change the location.
386 *
387 * @see https://reactrouter.com/docs/en/v6/hooks/use-navigate
388 */
389
390
391function useNavigate() {
392 !useInRouterContext() ? process.env.NODE_ENV !== "production" ? invariant(false, // TODO: This error is probably because they somehow have 2 versions of the
393 // router loaded. We can help them understand how to avoid that.
394 "useNavigate() may be used only in the context of a <Router> component.") : invariant(false) : void 0;
395 let {
396 basename,
397 navigator
398 } = React.useContext(NavigationContext);
399 let {
400 matches
401 } = React.useContext(RouteContext);
402 let {
403 pathname: locationPathname
404 } = useLocation();
405 let routePathnamesJson = JSON.stringify(getPathContributingMatches(matches).map(match => match.pathnameBase));
406 let activeRef = React.useRef(false);
407 React.useEffect(() => {
408 activeRef.current = true;
409 });
410 let navigate = React.useCallback(function (to, options) {
411 if (options === void 0) {
412 options = {};
413 }
414
415 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;
416 if (!activeRef.current) return;
417
418 if (typeof to === "number") {
419 navigator.go(to);
420 return;
421 }
422
423 let path = resolveTo(to, JSON.parse(routePathnamesJson), locationPathname, options.relative === "path"); // If we're operating within a basename, prepend it to the pathname prior
424 // to handing off to history. If this is a root navigation, then we
425 // navigate to the raw basename which allows the basename to have full
426 // control over the presence of a trailing slash on root links
427
428 if (basename !== "/") {
429 path.pathname = path.pathname === "/" ? basename : joinPaths([basename, path.pathname]);
430 }
431
432 (!!options.replace ? navigator.replace : navigator.push)(path, options.state, options);
433 }, [basename, navigator, routePathnamesJson, locationPathname]);
434 return navigate;
435}
436const OutletContext = /*#__PURE__*/React.createContext(null);
437/**
438 * Returns the context (if provided) for the child route at this level of the route
439 * hierarchy.
440 * @see https://reactrouter.com/docs/en/v6/hooks/use-outlet-context
441 */
442
443function useOutletContext() {
444 return React.useContext(OutletContext);
445}
446/**
447 * Returns the element for the child route at this level of the route
448 * hierarchy. Used internally by <Outlet> to render child routes.
449 *
450 * @see https://reactrouter.com/docs/en/v6/hooks/use-outlet
451 */
452
453function useOutlet(context) {
454 let outlet = React.useContext(RouteContext).outlet;
455
456 if (outlet) {
457 return /*#__PURE__*/React.createElement(OutletContext.Provider, {
458 value: context
459 }, outlet);
460 }
461
462 return outlet;
463}
464/**
465 * Returns an object of key/value pairs of the dynamic params from the current
466 * URL that were matched by the route path.
467 *
468 * @see https://reactrouter.com/docs/en/v6/hooks/use-params
469 */
470
471function useParams() {
472 let {
473 matches
474 } = React.useContext(RouteContext);
475 let routeMatch = matches[matches.length - 1];
476 return routeMatch ? routeMatch.params : {};
477}
478/**
479 * Resolves the pathname of the given `to` value against the current location.
480 *
481 * @see https://reactrouter.com/docs/en/v6/hooks/use-resolved-path
482 */
483
484function useResolvedPath(to, _temp2) {
485 let {
486 relative
487 } = _temp2 === void 0 ? {} : _temp2;
488 let {
489 matches
490 } = React.useContext(RouteContext);
491 let {
492 pathname: locationPathname
493 } = useLocation();
494 let routePathnamesJson = JSON.stringify(getPathContributingMatches(matches).map(match => match.pathnameBase));
495 return React.useMemo(() => resolveTo(to, JSON.parse(routePathnamesJson), locationPathname, relative === "path"), [to, routePathnamesJson, locationPathname, relative]);
496}
497/**
498 * Returns the element of the route that matched the current location, prepared
499 * with the correct context to render the remainder of the route tree. Route
500 * elements in the tree must render an <Outlet> to render their child route's
501 * element.
502 *
503 * @see https://reactrouter.com/docs/en/v6/hooks/use-routes
504 */
505
506function useRoutes(routes, locationArg) {
507 !useInRouterContext() ? process.env.NODE_ENV !== "production" ? invariant(false, // TODO: This error is probably because they somehow have 2 versions of the
508 // router loaded. We can help them understand how to avoid that.
509 "useRoutes() may be used only in the context of a <Router> component.") : invariant(false) : void 0;
510 let dataRouterStateContext = React.useContext(DataRouterStateContext);
511 let {
512 matches: parentMatches
513 } = React.useContext(RouteContext);
514 let routeMatch = parentMatches[parentMatches.length - 1];
515 let parentParams = routeMatch ? routeMatch.params : {};
516 let parentPathname = routeMatch ? routeMatch.pathname : "/";
517 let parentPathnameBase = routeMatch ? routeMatch.pathnameBase : "/";
518 let parentRoute = routeMatch && routeMatch.route;
519
520 if (process.env.NODE_ENV !== "production") {
521 // You won't get a warning about 2 different <Routes> under a <Route>
522 // without a trailing *, but this is a best-effort warning anyway since we
523 // cannot even give the warning unless they land at the parent route.
524 //
525 // Example:
526 //
527 // <Routes>
528 // {/* This route path MUST end with /* because otherwise
529 // it will never match /blog/post/123 */}
530 // <Route path="blog" element={<Blog />} />
531 // <Route path="blog/feed" element={<BlogFeed />} />
532 // </Routes>
533 //
534 // function Blog() {
535 // return (
536 // <Routes>
537 // <Route path="post/:id" element={<Post />} />
538 // </Routes>
539 // );
540 // }
541 let parentPath = parentRoute && parentRoute.path || "";
542 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 + "/*") + "\">."));
543 }
544
545 let locationFromContext = useLocation();
546 let location;
547
548 if (locationArg) {
549 var _parsedLocationArg$pa;
550
551 let parsedLocationArg = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
552 !(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;
553 location = parsedLocationArg;
554 } else {
555 location = locationFromContext;
556 }
557
558 let pathname = location.pathname || "/";
559 let remainingPathname = parentPathnameBase === "/" ? pathname : pathname.slice(parentPathnameBase.length) || "/";
560 let matches = matchRoutes(routes, {
561 pathname: remainingPathname
562 });
563
564 if (process.env.NODE_ENV !== "production") {
565 process.env.NODE_ENV !== "production" ? warning(parentRoute || matches != null, "No routes matched location \"" + location.pathname + location.search + location.hash + "\" ") : void 0;
566 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;
567 }
568
569 let renderedMatches = _renderMatches(matches && matches.map(match => Object.assign({}, match, {
570 params: Object.assign({}, parentParams, match.params),
571 pathname: joinPaths([parentPathnameBase, match.pathname]),
572 pathnameBase: match.pathnameBase === "/" ? parentPathnameBase : joinPaths([parentPathnameBase, match.pathnameBase])
573 })), parentMatches, dataRouterStateContext || undefined); // When a user passes in a `locationArg`, the associated routes need to
574 // be wrapped in a new `LocationContext.Provider` in order for `useLocation`
575 // to use the scoped location instead of the global location.
576
577
578 if (locationArg) {
579 return /*#__PURE__*/React.createElement(LocationContext.Provider, {
580 value: {
581 location: _extends({
582 pathname: "/",
583 search: "",
584 hash: "",
585 state: null,
586 key: "default"
587 }, location),
588 navigationType: Action.Pop
589 }
590 }, renderedMatches);
591 }
592
593 return renderedMatches;
594}
595
596function DefaultErrorElement() {
597 let error = useRouteError();
598 let message = isRouteErrorResponse(error) ? error.status + " " + error.statusText : error instanceof Error ? error.message : JSON.stringify(error);
599 let stack = error instanceof Error ? error.stack : null;
600 let lightgrey = "rgba(200,200,200, 0.5)";
601 let preStyles = {
602 padding: "0.5rem",
603 backgroundColor: lightgrey
604 };
605 let codeStyles = {
606 padding: "2px 4px",
607 backgroundColor: lightgrey
608 };
609 return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("h2", null, "Unhandled Thrown Error!"), /*#__PURE__*/React.createElement("h3", {
610 style: {
611 fontStyle: "italic"
612 }
613 }, message), stack ? /*#__PURE__*/React.createElement("pre", {
614 style: preStyles
615 }, 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", {
616 style: codeStyles
617 }, "errorElement"), " props on\xA0", /*#__PURE__*/React.createElement("code", {
618 style: codeStyles
619 }, "<Route>")));
620}
621
622class RenderErrorBoundary extends React.Component {
623 constructor(props) {
624 super(props);
625 this.state = {
626 location: props.location,
627 error: props.error
628 };
629 }
630
631 static getDerivedStateFromError(error) {
632 return {
633 error: error
634 };
635 }
636
637 static getDerivedStateFromProps(props, state) {
638 // When we get into an error state, the user will likely click "back" to the
639 // previous page that didn't have an error. Because this wraps the entire
640 // application, that will have no effect--the error page continues to display.
641 // This gives us a mechanism to recover from the error when the location changes.
642 //
643 // Whether we're in an error state or not, we update the location in state
644 // so that when we are in an error state, it gets reset when a new location
645 // comes in and the user recovers from the error.
646 if (state.location !== props.location) {
647 return {
648 error: props.error,
649 location: props.location
650 };
651 } // If we're not changing locations, preserve the location but still surface
652 // any new errors that may come through. We retain the existing error, we do
653 // this because the error provided from the app state may be cleared without
654 // the location changing.
655
656
657 return {
658 error: props.error || state.error,
659 location: state.location
660 };
661 }
662
663 componentDidCatch(error, errorInfo) {
664 console.error("React Router caught the following error during render", error, errorInfo);
665 }
666
667 render() {
668 return this.state.error ? /*#__PURE__*/React.createElement(RouteErrorContext.Provider, {
669 value: this.state.error,
670 children: this.props.component
671 }) : this.props.children;
672 }
673
674}
675
676function RenderedRoute(_ref) {
677 let {
678 routeContext,
679 match,
680 children
681 } = _ref;
682 let dataStaticRouterContext = React.useContext(DataStaticRouterContext); // Track how deep we got in our render pass to emulate SSR componentDidCatch
683 // in a DataStaticRouter
684
685 if (dataStaticRouterContext && match.route.errorElement) {
686 dataStaticRouterContext._deepestRenderedBoundaryId = match.route.id;
687 }
688
689 return /*#__PURE__*/React.createElement(RouteContext.Provider, {
690 value: routeContext
691 }, children);
692}
693
694function _renderMatches(matches, parentMatches, dataRouterState) {
695 if (parentMatches === void 0) {
696 parentMatches = [];
697 }
698
699 if (matches == null) {
700 if (dataRouterState != null && dataRouterState.errors) {
701 // Don't bail if we have data router errors so we can render them in the
702 // boundary. Use the pre-matched (or shimmed) matches
703 matches = dataRouterState.matches;
704 } else {
705 return null;
706 }
707 }
708
709 let renderedMatches = matches; // If we have data errors, trim matches to the highest error boundary
710
711 let errors = dataRouterState == null ? void 0 : dataRouterState.errors;
712
713 if (errors != null) {
714 let errorIndex = renderedMatches.findIndex(m => m.route.id && (errors == null ? void 0 : errors[m.route.id]));
715 !(errorIndex >= 0) ? process.env.NODE_ENV !== "production" ? invariant(false, "Could not find a matching route for the current errors: " + errors) : invariant(false) : void 0;
716 renderedMatches = renderedMatches.slice(0, Math.min(renderedMatches.length, errorIndex + 1));
717 }
718
719 return renderedMatches.reduceRight((outlet, match, index) => {
720 let error = match.route.id ? errors == null ? void 0 : errors[match.route.id] : null; // Only data routers handle errors
721
722 let errorElement = dataRouterState ? match.route.errorElement || /*#__PURE__*/React.createElement(DefaultErrorElement, null) : null;
723
724 let getChildren = () => /*#__PURE__*/React.createElement(RenderedRoute, {
725 match: match,
726 routeContext: {
727 outlet,
728 matches: parentMatches.concat(renderedMatches.slice(0, index + 1))
729 }
730 }, error ? errorElement : match.route.element !== undefined ? match.route.element : outlet); // Only wrap in an error boundary within data router usages when we have an
731 // errorElement on this route. Otherwise let it bubble up to an ancestor
732 // errorElement
733
734
735 return dataRouterState && (match.route.errorElement || index === 0) ? /*#__PURE__*/React.createElement(RenderErrorBoundary, {
736 location: dataRouterState.location,
737 component: errorElement,
738 error: error,
739 children: getChildren()
740 }) : getChildren();
741 }, null);
742}
743var DataRouterHook;
744
745(function (DataRouterHook) {
746 DataRouterHook["UseLoaderData"] = "useLoaderData";
747 DataRouterHook["UseActionData"] = "useActionData";
748 DataRouterHook["UseRouteError"] = "useRouteError";
749 DataRouterHook["UseNavigation"] = "useNavigation";
750 DataRouterHook["UseRouteLoaderData"] = "useRouteLoaderData";
751 DataRouterHook["UseMatches"] = "useMatches";
752 DataRouterHook["UseRevalidator"] = "useRevalidator";
753})(DataRouterHook || (DataRouterHook = {}));
754
755function useDataRouterState(hookName) {
756 let state = React.useContext(DataRouterStateContext);
757 !state ? process.env.NODE_ENV !== "production" ? invariant(false, hookName + " must be used within a DataRouterStateContext") : invariant(false) : void 0;
758 return state;
759}
760/**
761 * Returns the current navigation, defaulting to an "idle" navigation when
762 * no navigation is in progress
763 */
764
765
766function useNavigation() {
767 let state = useDataRouterState(DataRouterHook.UseNavigation);
768 return state.navigation;
769}
770/**
771 * Returns a revalidate function for manually triggering revalidation, as well
772 * as the current state of any manual revalidations
773 */
774
775function useRevalidator() {
776 let dataRouterContext = React.useContext(DataRouterContext);
777 !dataRouterContext ? process.env.NODE_ENV !== "production" ? invariant(false, "useRevalidator must be used within a DataRouterContext") : invariant(false) : void 0;
778 let state = useDataRouterState(DataRouterHook.UseRevalidator);
779 return {
780 revalidate: dataRouterContext.router.revalidate,
781 state: state.revalidation
782 };
783}
784/**
785 * Returns the active route matches, useful for accessing loaderData for
786 * parent/child routes or the route "handle" property
787 */
788
789function useMatches() {
790 let {
791 matches,
792 loaderData
793 } = useDataRouterState(DataRouterHook.UseMatches);
794 return React.useMemo(() => matches.map(match => {
795 let {
796 pathname,
797 params
798 } = match; // Note: This structure matches that created by createUseMatchesMatch
799 // in the @remix-run/router , so if you change this please also change
800 // that :) Eventually we'll DRY this up
801
802 return {
803 id: match.route.id,
804 pathname,
805 params,
806 data: loaderData[match.route.id],
807 handle: match.route.handle
808 };
809 }), [matches, loaderData]);
810}
811/**
812 * Returns the loader data for the nearest ancestor Route loader
813 */
814
815function useLoaderData() {
816 let state = useDataRouterState(DataRouterHook.UseLoaderData);
817 let route = React.useContext(RouteContext);
818 !route ? process.env.NODE_ENV !== "production" ? invariant(false, "useLoaderData must be used inside a RouteContext") : invariant(false) : void 0;
819 let thisRoute = route.matches[route.matches.length - 1];
820 !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;
821 return state.loaderData[thisRoute.route.id];
822}
823/**
824 * Returns the loaderData for the given routeId
825 */
826
827function useRouteLoaderData(routeId) {
828 let state = useDataRouterState(DataRouterHook.UseRouteLoaderData);
829 return state.loaderData[routeId];
830}
831/**
832 * Returns the action data for the nearest ancestor Route action
833 */
834
835function useActionData() {
836 let state = useDataRouterState(DataRouterHook.UseActionData);
837 let route = React.useContext(RouteContext);
838 !route ? process.env.NODE_ENV !== "production" ? invariant(false, "useActionData must be used inside a RouteContext") : invariant(false) : void 0;
839 return Object.values((state == null ? void 0 : state.actionData) || {})[0];
840}
841/**
842 * Returns the nearest ancestor Route error, which could be a loader/action
843 * error or a render error. This is intended to be called from your
844 * errorElement to display a proper error message.
845 */
846
847function useRouteError() {
848 var _state$errors;
849
850 let error = React.useContext(RouteErrorContext);
851 let state = useDataRouterState(DataRouterHook.UseRouteError);
852 let route = React.useContext(RouteContext);
853 let thisRoute = route.matches[route.matches.length - 1]; // If this was a render error, we put it in a RouteError context inside
854 // of RenderErrorBoundary
855
856 if (error) {
857 return error;
858 }
859
860 !route ? process.env.NODE_ENV !== "production" ? invariant(false, "useRouteError must be used inside a RouteContext") : invariant(false) : void 0;
861 !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
862
863 return (_state$errors = state.errors) == null ? void 0 : _state$errors[thisRoute.route.id];
864}
865/**
866 * Returns the happy-path data from the nearest ancestor <Await /> value
867 */
868
869function useAsyncValue() {
870 let value = React.useContext(AwaitContext);
871 return value == null ? void 0 : value._data;
872}
873/**
874 * Returns the error from the nearest ancestor <Await /> value
875 */
876
877function useAsyncError() {
878 let value = React.useContext(AwaitContext);
879 return value == null ? void 0 : value._error;
880}
881const alreadyWarned = {};
882
883function warningOnce(key, cond, message) {
884 if (!cond && !alreadyWarned[key]) {
885 alreadyWarned[key] = true;
886 process.env.NODE_ENV !== "production" ? warning(false, message) : void 0;
887 }
888}
889
890/**
891 * Given a Remix Router instance, render the appropriate UI
892 */
893function RouterProvider(_ref) {
894 let {
895 fallbackElement,
896 router
897 } = _ref;
898 // Sync router state to our component state to force re-renders
899 let state = useSyncExternalStore(router.subscribe, () => router.state, // We have to provide this so React@18 doesn't complain during hydration,
900 // but we pass our serialized hydration data into the router so state here
901 // is already synced with what the server saw
902 () => router.state);
903 let navigator = React.useMemo(() => {
904 return {
905 createHref: router.createHref,
906 go: n => router.navigate(n),
907 push: (to, state, opts) => router.navigate(to, {
908 state,
909 preventScrollReset: opts == null ? void 0 : opts.preventScrollReset
910 }),
911 replace: (to, state, opts) => router.navigate(to, {
912 replace: true,
913 state,
914 preventScrollReset: opts == null ? void 0 : opts.preventScrollReset
915 })
916 };
917 }, [router]);
918 let basename = router.basename || "/";
919 return /*#__PURE__*/React.createElement(DataRouterContext.Provider, {
920 value: {
921 router,
922 navigator,
923 static: false,
924 // Do we need this?
925 basename
926 }
927 }, /*#__PURE__*/React.createElement(DataRouterStateContext.Provider, {
928 value: state
929 }, /*#__PURE__*/React.createElement(Router, {
930 basename: router.basename,
931 location: router.state.location,
932 navigationType: router.state.historyAction,
933 navigator: navigator
934 }, router.state.initialized ? /*#__PURE__*/React.createElement(Routes, null) : fallbackElement)));
935}
936
937/**
938 * A <Router> that stores all entries in memory.
939 *
940 * @see https://reactrouter.com/docs/en/v6/routers/memory-router
941 */
942function MemoryRouter(_ref2) {
943 let {
944 basename,
945 children,
946 initialEntries,
947 initialIndex
948 } = _ref2;
949 let historyRef = React.useRef();
950
951 if (historyRef.current == null) {
952 historyRef.current = createMemoryHistory({
953 initialEntries,
954 initialIndex,
955 v5Compat: true
956 });
957 }
958
959 let history = historyRef.current;
960 let [state, setState] = React.useState({
961 action: history.action,
962 location: history.location
963 });
964 React.useLayoutEffect(() => history.listen(setState), [history]);
965 return /*#__PURE__*/React.createElement(Router, {
966 basename: basename,
967 children: children,
968 location: state.location,
969 navigationType: state.action,
970 navigator: history
971 });
972}
973
974/**
975 * Changes the current location.
976 *
977 * Note: This API is mostly useful in React.Component subclasses that are not
978 * able to use hooks. In functional components, we recommend you use the
979 * `useNavigate` hook instead.
980 *
981 * @see https://reactrouter.com/docs/en/v6/components/navigate
982 */
983function Navigate(_ref3) {
984 let {
985 to,
986 replace,
987 state,
988 relative
989 } = _ref3;
990 !useInRouterContext() ? process.env.NODE_ENV !== "production" ? invariant(false, // TODO: This error is probably because they somehow have 2 versions of
991 // the router loaded. We can help them understand how to avoid that.
992 "<Navigate> may be used only in the context of a <Router> component.") : invariant(false) : void 0;
993 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;
994 let dataRouterState = React.useContext(DataRouterStateContext);
995 let navigate = useNavigate();
996 React.useEffect(() => {
997 // Avoid kicking off multiple navigations if we're in the middle of a
998 // data-router navigation, since components get re-rendered when we enter
999 // a submitting/loading state
1000 if (dataRouterState && dataRouterState.navigation.state !== "idle") {
1001 return;
1002 }
1003
1004 navigate(to, {
1005 replace,
1006 state,
1007 relative
1008 });
1009 });
1010 return null;
1011}
1012
1013/**
1014 * Renders the child route's element, if there is one.
1015 *
1016 * @see https://reactrouter.com/docs/en/v6/components/outlet
1017 */
1018function Outlet(props) {
1019 return useOutlet(props.context);
1020}
1021
1022/**
1023 * Declares an element that should be rendered at a certain URL path.
1024 *
1025 * @see https://reactrouter.com/docs/en/v6/components/route
1026 */
1027function Route(_props) {
1028 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) ;
1029}
1030
1031/**
1032 * Provides location context for the rest of the app.
1033 *
1034 * Note: You usually won't render a <Router> directly. Instead, you'll render a
1035 * router that is more specific to your environment such as a <BrowserRouter>
1036 * in web browsers or a <StaticRouter> for server rendering.
1037 *
1038 * @see https://reactrouter.com/docs/en/v6/routers/router
1039 */
1040function Router(_ref4) {
1041 let {
1042 basename: basenameProp = "/",
1043 children = null,
1044 location: locationProp,
1045 navigationType = Action.Pop,
1046 navigator,
1047 static: staticProp = false
1048 } = _ref4;
1049 !!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
1050 // the enforcement of trailing slashes throughout the app
1051
1052 let basename = basenameProp.replace(/^\/*/, "/");
1053 let navigationContext = React.useMemo(() => ({
1054 basename,
1055 navigator,
1056 static: staticProp
1057 }), [basename, navigator, staticProp]);
1058
1059 if (typeof locationProp === "string") {
1060 locationProp = parsePath(locationProp);
1061 }
1062
1063 let {
1064 pathname = "/",
1065 search = "",
1066 hash = "",
1067 state = null,
1068 key = "default"
1069 } = locationProp;
1070 let location = React.useMemo(() => {
1071 let trailingPathname = stripBasename(pathname, basename);
1072
1073 if (trailingPathname == null) {
1074 return null;
1075 }
1076
1077 return {
1078 pathname: trailingPathname,
1079 search,
1080 hash,
1081 state,
1082 key
1083 };
1084 }, [basename, pathname, search, hash, state, key]);
1085 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;
1086
1087 if (location == null) {
1088 return null;
1089 }
1090
1091 return /*#__PURE__*/React.createElement(NavigationContext.Provider, {
1092 value: navigationContext
1093 }, /*#__PURE__*/React.createElement(LocationContext.Provider, {
1094 children: children,
1095 value: {
1096 location,
1097 navigationType
1098 }
1099 }));
1100}
1101
1102/**
1103 * A container for a nested tree of <Route> elements that renders the branch
1104 * that best matches the current location.
1105 *
1106 * @see https://reactrouter.com/docs/en/v6/components/routes
1107 */
1108function Routes(_ref5) {
1109 let {
1110 children,
1111 location
1112 } = _ref5;
1113 let dataRouterContext = React.useContext(DataRouterContext); // When in a DataRouterContext _without_ children, we use the router routes
1114 // directly. If we have children, then we're in a descendant tree and we
1115 // need to use child routes.
1116
1117 let routes = dataRouterContext && !children ? dataRouterContext.router.routes : createRoutesFromChildren(children);
1118 return useRoutes(routes, location);
1119}
1120
1121/**
1122 * Component to use for rendering lazily loaded data from returning defer()
1123 * in a loader function
1124 */
1125function Await(_ref6) {
1126 let {
1127 children,
1128 errorElement,
1129 resolve
1130 } = _ref6;
1131 return /*#__PURE__*/React.createElement(AwaitErrorBoundary, {
1132 resolve: resolve,
1133 errorElement: errorElement
1134 }, /*#__PURE__*/React.createElement(ResolveAwait, null, children));
1135}
1136var AwaitRenderStatus;
1137
1138(function (AwaitRenderStatus) {
1139 AwaitRenderStatus[AwaitRenderStatus["pending"] = 0] = "pending";
1140 AwaitRenderStatus[AwaitRenderStatus["success"] = 1] = "success";
1141 AwaitRenderStatus[AwaitRenderStatus["error"] = 2] = "error";
1142})(AwaitRenderStatus || (AwaitRenderStatus = {}));
1143
1144const neverSettledPromise = new Promise(() => {});
1145
1146class AwaitErrorBoundary extends React.Component {
1147 constructor(props) {
1148 super(props);
1149 this.state = {
1150 error: null
1151 };
1152 }
1153
1154 static getDerivedStateFromError(error) {
1155 return {
1156 error
1157 };
1158 }
1159
1160 componentDidCatch(error, errorInfo) {
1161 console.error("<Await> caught the following error during render", error, errorInfo);
1162 }
1163
1164 render() {
1165 let {
1166 children,
1167 errorElement,
1168 resolve
1169 } = this.props;
1170 let promise = null;
1171 let status = AwaitRenderStatus.pending;
1172
1173 if (!(resolve instanceof Promise)) {
1174 // Didn't get a promise - provide as a resolved promise
1175 status = AwaitRenderStatus.success;
1176 promise = Promise.resolve();
1177 Object.defineProperty(promise, "_tracked", {
1178 get: () => true
1179 });
1180 Object.defineProperty(promise, "_data", {
1181 get: () => resolve
1182 });
1183 } else if (this.state.error) {
1184 // Caught a render error, provide it as a rejected promise
1185 status = AwaitRenderStatus.error;
1186 let renderError = this.state.error;
1187 promise = Promise.reject().catch(() => {}); // Avoid unhandled rejection warnings
1188
1189 Object.defineProperty(promise, "_tracked", {
1190 get: () => true
1191 });
1192 Object.defineProperty(promise, "_error", {
1193 get: () => renderError
1194 });
1195 } else if (resolve._tracked) {
1196 // Already tracked promise - check contents
1197 promise = resolve;
1198 status = promise._error !== undefined ? AwaitRenderStatus.error : promise._data !== undefined ? AwaitRenderStatus.success : AwaitRenderStatus.pending;
1199 } else {
1200 // Raw (untracked) promise - track it
1201 status = AwaitRenderStatus.pending;
1202 Object.defineProperty(resolve, "_tracked", {
1203 get: () => true
1204 });
1205 promise = resolve.then(data => Object.defineProperty(resolve, "_data", {
1206 get: () => data
1207 }), error => Object.defineProperty(resolve, "_error", {
1208 get: () => error
1209 }));
1210 }
1211
1212 if (status === AwaitRenderStatus.error && promise._error instanceof AbortedDeferredError) {
1213 // Freeze the UI by throwing a never resolved promise
1214 throw neverSettledPromise;
1215 }
1216
1217 if (status === AwaitRenderStatus.error && !errorElement) {
1218 // No errorElement, throw to the nearest route-level error boundary
1219 throw promise._error;
1220 }
1221
1222 if (status === AwaitRenderStatus.error) {
1223 // Render via our errorElement
1224 return /*#__PURE__*/React.createElement(AwaitContext.Provider, {
1225 value: promise,
1226 children: errorElement
1227 });
1228 }
1229
1230 if (status === AwaitRenderStatus.success) {
1231 // Render children with resolved value
1232 return /*#__PURE__*/React.createElement(AwaitContext.Provider, {
1233 value: promise,
1234 children: children
1235 });
1236 } // Throw to the suspense boundary
1237
1238
1239 throw promise;
1240 }
1241
1242}
1243/**
1244 * @private
1245 * Indirection to leverage useAsyncValue for a render-prop API on <Await>
1246 */
1247
1248
1249function ResolveAwait(_ref7) {
1250 let {
1251 children
1252 } = _ref7;
1253 let data = useAsyncValue();
1254
1255 if (typeof children === "function") {
1256 return children(data);
1257 }
1258
1259 return /*#__PURE__*/React.createElement(React.Fragment, null, children);
1260} ///////////////////////////////////////////////////////////////////////////////
1261// UTILS
1262///////////////////////////////////////////////////////////////////////////////
1263
1264/**
1265 * Creates a route config from a React "children" object, which is usually
1266 * either a `<Route>` element or an array of them. Used internally by
1267 * `<Routes>` to create a route config from its children.
1268 *
1269 * @see https://reactrouter.com/docs/en/v6/utils/create-routes-from-children
1270 */
1271
1272
1273function createRoutesFromChildren(children, parentPath) {
1274 if (parentPath === void 0) {
1275 parentPath = [];
1276 }
1277
1278 let routes = [];
1279 React.Children.forEach(children, (element, index) => {
1280 if (! /*#__PURE__*/React.isValidElement(element)) {
1281 // Ignore non-elements. This allows people to more easily inline
1282 // conditionals in their route config.
1283 return;
1284 }
1285
1286 if (element.type === React.Fragment) {
1287 // Transparently support React.Fragment and its children.
1288 routes.push.apply(routes, createRoutesFromChildren(element.props.children, parentPath));
1289 return;
1290 }
1291
1292 !(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;
1293 let treePath = [...parentPath, index];
1294 let route = {
1295 id: element.props.id || treePath.join("-"),
1296 caseSensitive: element.props.caseSensitive,
1297 element: element.props.element,
1298 index: element.props.index,
1299 path: element.props.path,
1300 loader: element.props.loader,
1301 action: element.props.action,
1302 errorElement: element.props.errorElement,
1303 hasErrorBoundary: element.props.errorElement != null,
1304 shouldRevalidate: element.props.shouldRevalidate,
1305 handle: element.props.handle
1306 };
1307
1308 if (element.props.children) {
1309 route.children = createRoutesFromChildren(element.props.children, treePath);
1310 }
1311
1312 routes.push(route);
1313 });
1314 return routes;
1315}
1316/**
1317 * Renders the result of `matchRoutes()` into a React element.
1318 */
1319
1320function renderMatches(matches) {
1321 return _renderMatches(matches);
1322}
1323/**
1324 * @private
1325 * Walk the route tree and add hasErrorBoundary if it's not provided, so that
1326 * users providing manual route arrays can just specify errorElement
1327 */
1328
1329function enhanceManualRouteObjects(routes) {
1330 return routes.map(route => {
1331 let routeClone = _extends({}, route);
1332
1333 if (routeClone.hasErrorBoundary == null) {
1334 routeClone.hasErrorBoundary = routeClone.errorElement != null;
1335 }
1336
1337 if (routeClone.children) {
1338 routeClone.children = enhanceManualRouteObjects(routeClone.children);
1339 }
1340
1341 return routeClone;
1342 });
1343}
1344
1345function createMemoryRouter(routes, opts) {
1346 return createRouter({
1347 basename: opts == null ? void 0 : opts.basename,
1348 history: createMemoryHistory({
1349 initialEntries: opts == null ? void 0 : opts.initialEntries,
1350 initialIndex: opts == null ? void 0 : opts.initialIndex
1351 }),
1352 hydrationData: opts == null ? void 0 : opts.hydrationData,
1353 routes: enhanceManualRouteObjects(routes)
1354 }).initialize();
1355} ///////////////////////////////////////////////////////////////////////////////
1356
1357export { 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 };
1358//# sourceMappingURL=index.js.map