UNPKG

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