1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | import * as React from 'react';
|
12 | import { UNSAFE_invariant, joinPaths, matchPath, UNSAFE_getPathContributingMatches, UNSAFE_warning, resolveTo, parsePath, matchRoutes, Action, isRouteErrorResponse, createMemoryHistory, stripBasename, AbortedDeferredError, createRouter } from '@remix-run/router';
|
13 | export { AbortedDeferredError, Action as NavigationType, createPath, defer, generatePath, isRouteErrorResponse, json, matchPath, matchRoutes, parsePath, redirect, resolvePath } from '@remix-run/router';
|
14 |
|
15 | function _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 | for (var key in source) {
|
20 | if (Object.prototype.hasOwnProperty.call(source, key)) {
|
21 | target[key] = source[key];
|
22 | }
|
23 | }
|
24 | }
|
25 | return target;
|
26 | };
|
27 | return _extends.apply(this, arguments);
|
28 | }
|
29 |
|
30 |
|
31 |
|
32 | const DataRouterContext = React.createContext(null);
|
33 | if (process.env.NODE_ENV !== "production") {
|
34 | DataRouterContext.displayName = "DataRouter";
|
35 | }
|
36 | const DataRouterStateContext = React.createContext(null);
|
37 | if (process.env.NODE_ENV !== "production") {
|
38 | DataRouterStateContext.displayName = "DataRouterState";
|
39 | }
|
40 | const AwaitContext = React.createContext(null);
|
41 | if (process.env.NODE_ENV !== "production") {
|
42 | AwaitContext.displayName = "Await";
|
43 | }
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 | const NavigationContext = React.createContext(null);
|
56 | if (process.env.NODE_ENV !== "production") {
|
57 | NavigationContext.displayName = "Navigation";
|
58 | }
|
59 | const LocationContext = React.createContext(null);
|
60 | if (process.env.NODE_ENV !== "production") {
|
61 | LocationContext.displayName = "Location";
|
62 | }
|
63 | const RouteContext = React.createContext({
|
64 | outlet: null,
|
65 | matches: [],
|
66 | isDataRoute: false
|
67 | });
|
68 | if (process.env.NODE_ENV !== "production") {
|
69 | RouteContext.displayName = "Route";
|
70 | }
|
71 | const RouteErrorContext = React.createContext(null);
|
72 | if (process.env.NODE_ENV !== "production") {
|
73 | RouteErrorContext.displayName = "RouteError";
|
74 | }
|
75 |
|
76 |
|
77 |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 | function useHref(to, _temp) {
|
83 | let {
|
84 | relative
|
85 | } = _temp === void 0 ? {} : _temp;
|
86 | !useInRouterContext() ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false,
|
87 |
|
88 | "useHref() may be used only in the context of a <Router> component.") : UNSAFE_invariant(false) : void 0;
|
89 | let {
|
90 | basename,
|
91 | navigator
|
92 | } = React.useContext(NavigationContext);
|
93 | let {
|
94 | hash,
|
95 | pathname,
|
96 | search
|
97 | } = useResolvedPath(to, {
|
98 | relative
|
99 | });
|
100 | let joinedPathname = pathname;
|
101 |
|
102 |
|
103 |
|
104 |
|
105 |
|
106 | if (basename !== "/") {
|
107 | joinedPathname = pathname === "/" ? basename : joinPaths([basename, pathname]);
|
108 | }
|
109 | return navigator.createHref({
|
110 | pathname: joinedPathname,
|
111 | search,
|
112 | hash
|
113 | });
|
114 | }
|
115 |
|
116 |
|
117 |
|
118 |
|
119 |
|
120 |
|
121 | function useInRouterContext() {
|
122 | return React.useContext(LocationContext) != null;
|
123 | }
|
124 |
|
125 |
|
126 |
|
127 |
|
128 |
|
129 |
|
130 |
|
131 |
|
132 |
|
133 |
|
134 |
|
135 | function useLocation() {
|
136 | !useInRouterContext() ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false,
|
137 |
|
138 | "useLocation() may be used only in the context of a <Router> component.") : UNSAFE_invariant(false) : void 0;
|
139 | return React.useContext(LocationContext).location;
|
140 | }
|
141 |
|
142 |
|
143 |
|
144 |
|
145 |
|
146 |
|
147 |
|
148 | function useNavigationType() {
|
149 | return React.useContext(LocationContext).navigationType;
|
150 | }
|
151 |
|
152 |
|
153 |
|
154 |
|
155 |
|
156 |
|
157 |
|
158 |
|
159 | function useMatch(pattern) {
|
160 | !useInRouterContext() ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false,
|
161 |
|
162 | "useMatch() may be used only in the context of a <Router> component.") : UNSAFE_invariant(false) : void 0;
|
163 | let {
|
164 | pathname
|
165 | } = useLocation();
|
166 | return React.useMemo(() => matchPath(pattern, pathname), [pathname, pattern]);
|
167 | }
|
168 |
|
169 |
|
170 |
|
171 |
|
172 |
|
173 | const navigateEffectWarning = "You should call navigate() in a React.useEffect(), not when " + "your component is first rendered.";
|
174 |
|
175 |
|
176 | function useIsomorphicLayoutEffect(cb) {
|
177 | let isStatic = React.useContext(NavigationContext).static;
|
178 | if (!isStatic) {
|
179 |
|
180 |
|
181 |
|
182 | React.useLayoutEffect(cb);
|
183 | }
|
184 | }
|
185 |
|
186 |
|
187 |
|
188 |
|
189 |
|
190 |
|
191 |
|
192 | function useNavigate() {
|
193 | let {
|
194 | isDataRoute
|
195 | } = React.useContext(RouteContext);
|
196 |
|
197 |
|
198 | return isDataRoute ? useNavigateStable() : useNavigateUnstable();
|
199 | }
|
200 | function useNavigateUnstable() {
|
201 | !useInRouterContext() ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false,
|
202 |
|
203 | "useNavigate() may be used only in the context of a <Router> component.") : UNSAFE_invariant(false) : void 0;
|
204 | let dataRouterContext = React.useContext(DataRouterContext);
|
205 | let {
|
206 | basename,
|
207 | navigator
|
208 | } = React.useContext(NavigationContext);
|
209 | let {
|
210 | matches
|
211 | } = React.useContext(RouteContext);
|
212 | let {
|
213 | pathname: locationPathname
|
214 | } = useLocation();
|
215 | let routePathnamesJson = JSON.stringify(UNSAFE_getPathContributingMatches(matches).map(match => match.pathnameBase));
|
216 | let activeRef = React.useRef(false);
|
217 | useIsomorphicLayoutEffect(() => {
|
218 | activeRef.current = true;
|
219 | });
|
220 | let navigate = React.useCallback(function (to, options) {
|
221 | if (options === void 0) {
|
222 | options = {};
|
223 | }
|
224 | process.env.NODE_ENV !== "production" ? UNSAFE_warning(activeRef.current, navigateEffectWarning) : void 0;
|
225 |
|
226 |
|
227 |
|
228 | if (!activeRef.current) return;
|
229 | if (typeof to === "number") {
|
230 | navigator.go(to);
|
231 | return;
|
232 | }
|
233 | let path = resolveTo(to, JSON.parse(routePathnamesJson), locationPathname, options.relative === "path");
|
234 |
|
235 |
|
236 |
|
237 |
|
238 |
|
239 |
|
240 |
|
241 | if (dataRouterContext == null && basename !== "/") {
|
242 | path.pathname = path.pathname === "/" ? basename : joinPaths([basename, path.pathname]);
|
243 | }
|
244 | (!!options.replace ? navigator.replace : navigator.push)(path, options.state, options);
|
245 | }, [basename, navigator, routePathnamesJson, locationPathname, dataRouterContext]);
|
246 | return navigate;
|
247 | }
|
248 | const OutletContext = React.createContext(null);
|
249 |
|
250 |
|
251 |
|
252 |
|
253 |
|
254 |
|
255 | function useOutletContext() {
|
256 | return React.useContext(OutletContext);
|
257 | }
|
258 |
|
259 |
|
260 |
|
261 |
|
262 |
|
263 |
|
264 |
|
265 | function useOutlet(context) {
|
266 | let outlet = React.useContext(RouteContext).outlet;
|
267 | if (outlet) {
|
268 | return React.createElement(OutletContext.Provider, {
|
269 | value: context
|
270 | }, outlet);
|
271 | }
|
272 | return outlet;
|
273 | }
|
274 |
|
275 |
|
276 |
|
277 |
|
278 |
|
279 |
|
280 |
|
281 | function useParams() {
|
282 | let {
|
283 | matches
|
284 | } = React.useContext(RouteContext);
|
285 | let routeMatch = matches[matches.length - 1];
|
286 | return routeMatch ? routeMatch.params : {};
|
287 | }
|
288 |
|
289 |
|
290 |
|
291 |
|
292 |
|
293 |
|
294 | function useResolvedPath(to, _temp2) {
|
295 | let {
|
296 | relative
|
297 | } = _temp2 === void 0 ? {} : _temp2;
|
298 | let {
|
299 | matches
|
300 | } = React.useContext(RouteContext);
|
301 | let {
|
302 | pathname: locationPathname
|
303 | } = useLocation();
|
304 | let routePathnamesJson = JSON.stringify(UNSAFE_getPathContributingMatches(matches).map(match => match.pathnameBase));
|
305 | return React.useMemo(() => resolveTo(to, JSON.parse(routePathnamesJson), locationPathname, relative === "path"), [to, routePathnamesJson, locationPathname, relative]);
|
306 | }
|
307 |
|
308 |
|
309 |
|
310 |
|
311 |
|
312 |
|
313 |
|
314 |
|
315 |
|
316 | function useRoutes(routes, locationArg) {
|
317 | return useRoutesImpl(routes, locationArg);
|
318 | }
|
319 |
|
320 |
|
321 | function useRoutesImpl(routes, locationArg, dataRouterState) {
|
322 | !useInRouterContext() ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false,
|
323 |
|
324 | "useRoutes() may be used only in the context of a <Router> component.") : UNSAFE_invariant(false) : void 0;
|
325 | let {
|
326 | navigator
|
327 | } = React.useContext(NavigationContext);
|
328 | let {
|
329 | matches: parentMatches
|
330 | } = React.useContext(RouteContext);
|
331 | let routeMatch = parentMatches[parentMatches.length - 1];
|
332 | let parentParams = routeMatch ? routeMatch.params : {};
|
333 | let parentPathname = routeMatch ? routeMatch.pathname : "/";
|
334 | let parentPathnameBase = routeMatch ? routeMatch.pathnameBase : "/";
|
335 | let parentRoute = routeMatch && routeMatch.route;
|
336 | if (process.env.NODE_ENV !== "production") {
|
337 |
|
338 |
|
339 |
|
340 |
|
341 |
|
342 |
|
343 |
|
344 |
|
345 |
|
346 |
|
347 |
|
348 |
|
349 |
|
350 |
|
351 |
|
352 |
|
353 |
|
354 |
|
355 |
|
356 |
|
357 | let parentPath = parentRoute && parentRoute.path || "";
|
358 | 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 + "/*") + "\">."));
|
359 | }
|
360 | let locationFromContext = useLocation();
|
361 | let location;
|
362 | if (locationArg) {
|
363 | var _parsedLocationArg$pa;
|
364 | let parsedLocationArg = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
|
365 | !(parentPathnameBase === "/" || ((_parsedLocationArg$pa = parsedLocationArg.pathname) == null ? void 0 : _parsedLocationArg$pa.startsWith(parentPathnameBase))) ? process.env.NODE_ENV !== "production" ? UNSAFE_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.")) : UNSAFE_invariant(false) : void 0;
|
366 | location = parsedLocationArg;
|
367 | } else {
|
368 | location = locationFromContext;
|
369 | }
|
370 | let pathname = location.pathname || "/";
|
371 | let remainingPathname = parentPathnameBase === "/" ? pathname : pathname.slice(parentPathnameBase.length) || "/";
|
372 | let matches = matchRoutes(routes, {
|
373 | pathname: remainingPathname
|
374 | });
|
375 | if (process.env.NODE_ENV !== "production") {
|
376 | process.env.NODE_ENV !== "production" ? UNSAFE_warning(parentRoute || matches != null, "No routes matched location \"" + location.pathname + location.search + location.hash + "\" ") : void 0;
|
377 | process.env.NODE_ENV !== "production" ? UNSAFE_warning(matches == null || matches[matches.length - 1].route.element !== undefined || matches[matches.length - 1].route.Component !== undefined, "Matched leaf route at location \"" + location.pathname + location.search + location.hash + "\" " + "does not have an element or Component. This means it will render an <Outlet /> with a " + "null value by default resulting in an \"empty\" page.") : void 0;
|
378 | }
|
379 | let renderedMatches = _renderMatches(matches && matches.map(match => Object.assign({}, match, {
|
380 | params: Object.assign({}, parentParams, match.params),
|
381 | pathname: joinPaths([parentPathnameBase,
|
382 |
|
383 | navigator.encodeLocation ? navigator.encodeLocation(match.pathname).pathname : match.pathname]),
|
384 | pathnameBase: match.pathnameBase === "/" ? parentPathnameBase : joinPaths([parentPathnameBase,
|
385 |
|
386 | navigator.encodeLocation ? navigator.encodeLocation(match.pathnameBase).pathname : match.pathnameBase])
|
387 | })), parentMatches, dataRouterState);
|
388 |
|
389 |
|
390 |
|
391 |
|
392 | if (locationArg && renderedMatches) {
|
393 | return React.createElement(LocationContext.Provider, {
|
394 | value: {
|
395 | location: _extends({
|
396 | pathname: "/",
|
397 | search: "",
|
398 | hash: "",
|
399 | state: null,
|
400 | key: "default"
|
401 | }, location),
|
402 | navigationType: Action.Pop
|
403 | }
|
404 | }, renderedMatches);
|
405 | }
|
406 | return renderedMatches;
|
407 | }
|
408 | function DefaultErrorComponent() {
|
409 | let error = useRouteError();
|
410 | let message = isRouteErrorResponse(error) ? error.status + " " + error.statusText : error instanceof Error ? error.message : JSON.stringify(error);
|
411 | let stack = error instanceof Error ? error.stack : null;
|
412 | let lightgrey = "rgba(200,200,200, 0.5)";
|
413 | let preStyles = {
|
414 | padding: "0.5rem",
|
415 | backgroundColor: lightgrey
|
416 | };
|
417 | let codeStyles = {
|
418 | padding: "2px 4px",
|
419 | backgroundColor: lightgrey
|
420 | };
|
421 | let devInfo = null;
|
422 | if (process.env.NODE_ENV !== "production") {
|
423 | console.error("Error handled by React Router default ErrorBoundary:", error);
|
424 | devInfo = React.createElement(React.Fragment, null, React.createElement("p", null, "\uD83D\uDCBF Hey developer \uD83D\uDC4B"), React.createElement("p", null, "You can provide a way better UX than this when your app throws errors by providing your own ", React.createElement("code", {
|
425 | style: codeStyles
|
426 | }, "ErrorBoundary"), " or", " ", React.createElement("code", {
|
427 | style: codeStyles
|
428 | }, "errorElement"), " prop on your route."));
|
429 | }
|
430 | return React.createElement(React.Fragment, null, React.createElement("h2", null, "Unexpected Application Error!"), React.createElement("h3", {
|
431 | style: {
|
432 | fontStyle: "italic"
|
433 | }
|
434 | }, message), stack ? React.createElement("pre", {
|
435 | style: preStyles
|
436 | }, stack) : null, devInfo);
|
437 | }
|
438 | const defaultErrorElement = React.createElement(DefaultErrorComponent, null);
|
439 | class RenderErrorBoundary extends React.Component {
|
440 | constructor(props) {
|
441 | super(props);
|
442 | this.state = {
|
443 | location: props.location,
|
444 | revalidation: props.revalidation,
|
445 | error: props.error
|
446 | };
|
447 | }
|
448 | static getDerivedStateFromError(error) {
|
449 | return {
|
450 | error: error
|
451 | };
|
452 | }
|
453 | static getDerivedStateFromProps(props, state) {
|
454 |
|
455 |
|
456 |
|
457 |
|
458 |
|
459 |
|
460 |
|
461 |
|
462 | if (state.location !== props.location || state.revalidation !== "idle" && props.revalidation === "idle") {
|
463 | return {
|
464 | error: props.error,
|
465 | location: props.location,
|
466 | revalidation: props.revalidation
|
467 | };
|
468 | }
|
469 |
|
470 |
|
471 |
|
472 |
|
473 |
|
474 | return {
|
475 | error: props.error || state.error,
|
476 | location: state.location,
|
477 | revalidation: props.revalidation || state.revalidation
|
478 | };
|
479 | }
|
480 | componentDidCatch(error, errorInfo) {
|
481 | console.error("React Router caught the following error during render", error, errorInfo);
|
482 | }
|
483 | render() {
|
484 | return this.state.error ? React.createElement(RouteContext.Provider, {
|
485 | value: this.props.routeContext
|
486 | }, React.createElement(RouteErrorContext.Provider, {
|
487 | value: this.state.error,
|
488 | children: this.props.component
|
489 | })) : this.props.children;
|
490 | }
|
491 | }
|
492 | function RenderedRoute(_ref) {
|
493 | let {
|
494 | routeContext,
|
495 | match,
|
496 | children
|
497 | } = _ref;
|
498 | let dataRouterContext = React.useContext(DataRouterContext);
|
499 |
|
500 |
|
501 |
|
502 | if (dataRouterContext && dataRouterContext.static && dataRouterContext.staticContext && (match.route.errorElement || match.route.ErrorBoundary)) {
|
503 | dataRouterContext.staticContext._deepestRenderedBoundaryId = match.route.id;
|
504 | }
|
505 | return React.createElement(RouteContext.Provider, {
|
506 | value: routeContext
|
507 | }, children);
|
508 | }
|
509 | function _renderMatches(matches, parentMatches, dataRouterState) {
|
510 | var _dataRouterState2;
|
511 | if (parentMatches === void 0) {
|
512 | parentMatches = [];
|
513 | }
|
514 | if (dataRouterState === void 0) {
|
515 | dataRouterState = null;
|
516 | }
|
517 | if (matches == null) {
|
518 | var _dataRouterState;
|
519 | if ((_dataRouterState = dataRouterState) != null && _dataRouterState.errors) {
|
520 |
|
521 |
|
522 | matches = dataRouterState.matches;
|
523 | } else {
|
524 | return null;
|
525 | }
|
526 | }
|
527 | let renderedMatches = matches;
|
528 |
|
529 |
|
530 | let errors = (_dataRouterState2 = dataRouterState) == null ? void 0 : _dataRouterState2.errors;
|
531 | if (errors != null) {
|
532 | let errorIndex = renderedMatches.findIndex(m => m.route.id && (errors == null ? void 0 : errors[m.route.id]));
|
533 | !(errorIndex >= 0) ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false, "Could not find a matching route for errors on route IDs: " + Object.keys(errors).join(",")) : UNSAFE_invariant(false) : void 0;
|
534 | renderedMatches = renderedMatches.slice(0, Math.min(renderedMatches.length, errorIndex + 1));
|
535 | }
|
536 | return renderedMatches.reduceRight((outlet, match, index) => {
|
537 | let error = match.route.id ? errors == null ? void 0 : errors[match.route.id] : null;
|
538 |
|
539 | let errorElement = null;
|
540 | if (dataRouterState) {
|
541 | errorElement = match.route.errorElement || defaultErrorElement;
|
542 | }
|
543 | let matches = parentMatches.concat(renderedMatches.slice(0, index + 1));
|
544 | let getChildren = () => {
|
545 | let children;
|
546 | if (error) {
|
547 | children = errorElement;
|
548 | } else if (match.route.Component) {
|
549 |
|
550 |
|
551 |
|
552 |
|
553 |
|
554 |
|
555 | children = React.createElement(match.route.Component, null);
|
556 | } else if (match.route.element) {
|
557 | children = match.route.element;
|
558 | } else {
|
559 | children = outlet;
|
560 | }
|
561 | return React.createElement(RenderedRoute, {
|
562 | match: match,
|
563 | routeContext: {
|
564 | outlet,
|
565 | matches,
|
566 | isDataRoute: dataRouterState != null
|
567 | },
|
568 | children: children
|
569 | });
|
570 | };
|
571 |
|
572 |
|
573 |
|
574 | return dataRouterState && (match.route.ErrorBoundary || match.route.errorElement || index === 0) ? React.createElement(RenderErrorBoundary, {
|
575 | location: dataRouterState.location,
|
576 | revalidation: dataRouterState.revalidation,
|
577 | component: errorElement,
|
578 | error: error,
|
579 | children: getChildren(),
|
580 | routeContext: {
|
581 | outlet: null,
|
582 | matches,
|
583 | isDataRoute: true
|
584 | }
|
585 | }) : getChildren();
|
586 | }, null);
|
587 | }
|
588 | var DataRouterHook;
|
589 | (function (DataRouterHook) {
|
590 | DataRouterHook["UseBlocker"] = "useBlocker";
|
591 | DataRouterHook["UseRevalidator"] = "useRevalidator";
|
592 | DataRouterHook["UseNavigateStable"] = "useNavigate";
|
593 | })(DataRouterHook || (DataRouterHook = {}));
|
594 | var DataRouterStateHook;
|
595 | (function (DataRouterStateHook) {
|
596 | DataRouterStateHook["UseBlocker"] = "useBlocker";
|
597 | DataRouterStateHook["UseLoaderData"] = "useLoaderData";
|
598 | DataRouterStateHook["UseActionData"] = "useActionData";
|
599 | DataRouterStateHook["UseRouteError"] = "useRouteError";
|
600 | DataRouterStateHook["UseNavigation"] = "useNavigation";
|
601 | DataRouterStateHook["UseRouteLoaderData"] = "useRouteLoaderData";
|
602 | DataRouterStateHook["UseMatches"] = "useMatches";
|
603 | DataRouterStateHook["UseRevalidator"] = "useRevalidator";
|
604 | DataRouterStateHook["UseNavigateStable"] = "useNavigate";
|
605 | DataRouterStateHook["UseRouteId"] = "useRouteId";
|
606 | })(DataRouterStateHook || (DataRouterStateHook = {}));
|
607 | function getDataRouterConsoleError(hookName) {
|
608 | return hookName + " must be used within a data router. See https://reactrouter.com/routers/picking-a-router.";
|
609 | }
|
610 | function useDataRouterContext(hookName) {
|
611 | let ctx = React.useContext(DataRouterContext);
|
612 | !ctx ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false, getDataRouterConsoleError(hookName)) : UNSAFE_invariant(false) : void 0;
|
613 | return ctx;
|
614 | }
|
615 | function useDataRouterState(hookName) {
|
616 | let state = React.useContext(DataRouterStateContext);
|
617 | !state ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false, getDataRouterConsoleError(hookName)) : UNSAFE_invariant(false) : void 0;
|
618 | return state;
|
619 | }
|
620 | function useRouteContext(hookName) {
|
621 | let route = React.useContext(RouteContext);
|
622 | !route ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false, getDataRouterConsoleError(hookName)) : UNSAFE_invariant(false) : void 0;
|
623 | return route;
|
624 | }
|
625 |
|
626 |
|
627 | function useCurrentRouteId(hookName) {
|
628 | let route = useRouteContext(hookName);
|
629 | let thisRoute = route.matches[route.matches.length - 1];
|
630 | !thisRoute.route.id ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false, hookName + " can only be used on routes that contain a unique \"id\"") : UNSAFE_invariant(false) : void 0;
|
631 | return thisRoute.route.id;
|
632 | }
|
633 |
|
634 |
|
635 |
|
636 |
|
637 | function useRouteId() {
|
638 | return useCurrentRouteId(DataRouterStateHook.UseRouteId);
|
639 | }
|
640 |
|
641 |
|
642 |
|
643 |
|
644 |
|
645 | function useNavigation() {
|
646 | let state = useDataRouterState(DataRouterStateHook.UseNavigation);
|
647 | return state.navigation;
|
648 | }
|
649 |
|
650 |
|
651 |
|
652 |
|
653 |
|
654 | function useRevalidator() {
|
655 | let dataRouterContext = useDataRouterContext(DataRouterHook.UseRevalidator);
|
656 | let state = useDataRouterState(DataRouterStateHook.UseRevalidator);
|
657 | return {
|
658 | revalidate: dataRouterContext.router.revalidate,
|
659 | state: state.revalidation
|
660 | };
|
661 | }
|
662 |
|
663 |
|
664 |
|
665 |
|
666 |
|
667 | function useMatches() {
|
668 | let {
|
669 | matches,
|
670 | loaderData
|
671 | } = useDataRouterState(DataRouterStateHook.UseMatches);
|
672 | return React.useMemo(() => matches.map(match => {
|
673 | let {
|
674 | pathname,
|
675 | params
|
676 | } = match;
|
677 |
|
678 |
|
679 |
|
680 | return {
|
681 | id: match.route.id,
|
682 | pathname,
|
683 | params,
|
684 | data: loaderData[match.route.id],
|
685 | handle: match.route.handle
|
686 | };
|
687 | }), [matches, loaderData]);
|
688 | }
|
689 |
|
690 |
|
691 |
|
692 |
|
693 | function useLoaderData() {
|
694 | let state = useDataRouterState(DataRouterStateHook.UseLoaderData);
|
695 | let routeId = useCurrentRouteId(DataRouterStateHook.UseLoaderData);
|
696 | if (state.errors && state.errors[routeId] != null) {
|
697 | console.error("You cannot `useLoaderData` in an errorElement (routeId: " + routeId + ")");
|
698 | return undefined;
|
699 | }
|
700 | return state.loaderData[routeId];
|
701 | }
|
702 |
|
703 |
|
704 |
|
705 |
|
706 | function useRouteLoaderData(routeId) {
|
707 | let state = useDataRouterState(DataRouterStateHook.UseRouteLoaderData);
|
708 | return state.loaderData[routeId];
|
709 | }
|
710 |
|
711 |
|
712 |
|
713 |
|
714 | function useActionData() {
|
715 | let state = useDataRouterState(DataRouterStateHook.UseActionData);
|
716 | let route = React.useContext(RouteContext);
|
717 | !route ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false, "useActionData must be used inside a RouteContext") : UNSAFE_invariant(false) : void 0;
|
718 | return Object.values((state == null ? void 0 : state.actionData) || {})[0];
|
719 | }
|
720 |
|
721 |
|
722 |
|
723 |
|
724 |
|
725 |
|
726 | function useRouteError() {
|
727 | var _state$errors;
|
728 | let error = React.useContext(RouteErrorContext);
|
729 | let state = useDataRouterState(DataRouterStateHook.UseRouteError);
|
730 | let routeId = useCurrentRouteId(DataRouterStateHook.UseRouteError);
|
731 |
|
732 |
|
733 |
|
734 | if (error) {
|
735 | return error;
|
736 | }
|
737 |
|
738 |
|
739 | return (_state$errors = state.errors) == null ? void 0 : _state$errors[routeId];
|
740 | }
|
741 |
|
742 |
|
743 |
|
744 |
|
745 | function useAsyncValue() {
|
746 | let value = React.useContext(AwaitContext);
|
747 | return value == null ? void 0 : value._data;
|
748 | }
|
749 |
|
750 |
|
751 |
|
752 |
|
753 | function useAsyncError() {
|
754 | let value = React.useContext(AwaitContext);
|
755 | return value == null ? void 0 : value._error;
|
756 | }
|
757 | let blockerId = 0;
|
758 |
|
759 |
|
760 |
|
761 |
|
762 |
|
763 |
|
764 |
|
765 | function useBlocker(shouldBlock) {
|
766 | let {
|
767 | router
|
768 | } = useDataRouterContext(DataRouterHook.UseBlocker);
|
769 | let state = useDataRouterState(DataRouterStateHook.UseBlocker);
|
770 | let [blockerKey] = React.useState(() => String(++blockerId));
|
771 | let blockerFunction = React.useCallback(args => {
|
772 | return typeof shouldBlock === "function" ? !!shouldBlock(args) : !!shouldBlock;
|
773 | }, [shouldBlock]);
|
774 | let blocker = router.getBlocker(blockerKey, blockerFunction);
|
775 |
|
776 |
|
777 | React.useEffect(() => () => router.deleteBlocker(blockerKey), [router, blockerKey]);
|
778 |
|
779 |
|
780 |
|
781 | return state.blockers.get(blockerKey) || blocker;
|
782 | }
|
783 |
|
784 |
|
785 |
|
786 |
|
787 |
|
788 | function useNavigateStable() {
|
789 | let {
|
790 | router
|
791 | } = useDataRouterContext(DataRouterHook.UseNavigateStable);
|
792 | let id = useCurrentRouteId(DataRouterStateHook.UseNavigateStable);
|
793 | let activeRef = React.useRef(false);
|
794 | useIsomorphicLayoutEffect(() => {
|
795 | activeRef.current = true;
|
796 | });
|
797 | let navigate = React.useCallback(function (to, options) {
|
798 | if (options === void 0) {
|
799 | options = {};
|
800 | }
|
801 | process.env.NODE_ENV !== "production" ? UNSAFE_warning(activeRef.current, navigateEffectWarning) : void 0;
|
802 |
|
803 |
|
804 |
|
805 | if (!activeRef.current) return;
|
806 | if (typeof to === "number") {
|
807 | router.navigate(to);
|
808 | } else {
|
809 | router.navigate(to, _extends({
|
810 | fromRouteId: id
|
811 | }, options));
|
812 | }
|
813 | }, [router, id]);
|
814 | return navigate;
|
815 | }
|
816 | const alreadyWarned = {};
|
817 | function warningOnce(key, cond, message) {
|
818 | if (!cond && !alreadyWarned[key]) {
|
819 | alreadyWarned[key] = true;
|
820 | process.env.NODE_ENV !== "production" ? UNSAFE_warning(false, message) : void 0;
|
821 | }
|
822 | }
|
823 |
|
824 |
|
825 |
|
826 |
|
827 | const START_TRANSITION = "startTransition";
|
828 |
|
829 |
|
830 |
|
831 |
|
832 | function RouterProvider(_ref) {
|
833 | let {
|
834 | fallbackElement,
|
835 | router
|
836 | } = _ref;
|
837 |
|
838 |
|
839 | let [state, setStateImpl] = React.useState(router.state);
|
840 | let setState = React.useCallback(newState => {
|
841 | START_TRANSITION in React ? React[START_TRANSITION](() => setStateImpl(newState)) : setStateImpl(newState);
|
842 | }, [setStateImpl]);
|
843 | React.useLayoutEffect(() => router.subscribe(setState), [router, setState]);
|
844 | let navigator = React.useMemo(() => {
|
845 | return {
|
846 | createHref: router.createHref,
|
847 | encodeLocation: router.encodeLocation,
|
848 | go: n => router.navigate(n),
|
849 | push: (to, state, opts) => router.navigate(to, {
|
850 | state,
|
851 | preventScrollReset: opts == null ? void 0 : opts.preventScrollReset
|
852 | }),
|
853 | replace: (to, state, opts) => router.navigate(to, {
|
854 | replace: true,
|
855 | state,
|
856 | preventScrollReset: opts == null ? void 0 : opts.preventScrollReset
|
857 | })
|
858 | };
|
859 | }, [router]);
|
860 | let basename = router.basename || "/";
|
861 | let dataRouterContext = React.useMemo(() => ({
|
862 | router,
|
863 | navigator,
|
864 | static: false,
|
865 | basename
|
866 | }), [router, navigator, basename]);
|
867 |
|
868 |
|
869 |
|
870 |
|
871 |
|
872 |
|
873 |
|
874 | return React.createElement(React.Fragment, null, React.createElement(DataRouterContext.Provider, {
|
875 | value: dataRouterContext
|
876 | }, React.createElement(DataRouterStateContext.Provider, {
|
877 | value: state
|
878 | }, React.createElement(Router, {
|
879 | basename: basename,
|
880 | location: state.location,
|
881 | navigationType: state.historyAction,
|
882 | navigator: navigator
|
883 | }, state.initialized ? React.createElement(DataRoutes, {
|
884 | routes: router.routes,
|
885 | state: state
|
886 | }) : fallbackElement))), null);
|
887 | }
|
888 | function DataRoutes(_ref2) {
|
889 | let {
|
890 | routes,
|
891 | state
|
892 | } = _ref2;
|
893 | return useRoutesImpl(routes, undefined, state);
|
894 | }
|
895 |
|
896 |
|
897 |
|
898 |
|
899 |
|
900 | function MemoryRouter(_ref3) {
|
901 | let {
|
902 | basename,
|
903 | children,
|
904 | initialEntries,
|
905 | initialIndex
|
906 | } = _ref3;
|
907 | let historyRef = React.useRef();
|
908 | if (historyRef.current == null) {
|
909 | historyRef.current = createMemoryHistory({
|
910 | initialEntries,
|
911 | initialIndex,
|
912 | v5Compat: true
|
913 | });
|
914 | }
|
915 | let history = historyRef.current;
|
916 | let [state, setStateImpl] = React.useState({
|
917 | action: history.action,
|
918 | location: history.location
|
919 | });
|
920 | let setState = React.useCallback(newState => {
|
921 | START_TRANSITION in React ? React[START_TRANSITION](() => setStateImpl(newState)) : setStateImpl(newState);
|
922 | }, [setStateImpl]);
|
923 | React.useLayoutEffect(() => history.listen(setState), [history, setState]);
|
924 | return React.createElement(Router, {
|
925 | basename: basename,
|
926 | children: children,
|
927 | location: state.location,
|
928 | navigationType: state.action,
|
929 | navigator: history
|
930 | });
|
931 | }
|
932 |
|
933 |
|
934 |
|
935 |
|
936 |
|
937 |
|
938 |
|
939 |
|
940 |
|
941 | function Navigate(_ref4) {
|
942 | let {
|
943 | to,
|
944 | replace,
|
945 | state,
|
946 | relative
|
947 | } = _ref4;
|
948 | !useInRouterContext() ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false,
|
949 |
|
950 | "<Navigate> may be used only in the context of a <Router> component.") : UNSAFE_invariant(false) : void 0;
|
951 | process.env.NODE_ENV !== "production" ? UNSAFE_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;
|
952 | let {
|
953 | matches
|
954 | } = React.useContext(RouteContext);
|
955 | let {
|
956 | pathname: locationPathname
|
957 | } = useLocation();
|
958 | let navigate = useNavigate();
|
959 |
|
960 |
|
961 |
|
962 | let path = resolveTo(to, UNSAFE_getPathContributingMatches(matches).map(match => match.pathnameBase), locationPathname, relative === "path");
|
963 | let jsonPath = JSON.stringify(path);
|
964 | React.useEffect(() => navigate(JSON.parse(jsonPath), {
|
965 | replace,
|
966 | state,
|
967 | relative
|
968 | }), [navigate, jsonPath, relative, replace, state]);
|
969 | return null;
|
970 | }
|
971 |
|
972 |
|
973 |
|
974 |
|
975 |
|
976 | function Outlet(props) {
|
977 | return useOutlet(props.context);
|
978 | }
|
979 |
|
980 |
|
981 |
|
982 |
|
983 |
|
984 | function Route(_props) {
|
985 | process.env.NODE_ENV !== "production" ? UNSAFE_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>.") : UNSAFE_invariant(false) ;
|
986 | }
|
987 |
|
988 |
|
989 |
|
990 |
|
991 |
|
992 |
|
993 |
|
994 |
|
995 |
|
996 | function Router(_ref5) {
|
997 | let {
|
998 | basename: basenameProp = "/",
|
999 | children = null,
|
1000 | location: locationProp,
|
1001 | navigationType = Action.Pop,
|
1002 | navigator,
|
1003 | static: staticProp = false
|
1004 | } = _ref5;
|
1005 | !!useInRouterContext() ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false, "You cannot render a <Router> inside another <Router>." + " You should never have more than one in your app.") : UNSAFE_invariant(false) : void 0;
|
1006 |
|
1007 |
|
1008 |
|
1009 | let basename = basenameProp.replace(/^\/*/, "/");
|
1010 | let navigationContext = React.useMemo(() => ({
|
1011 | basename,
|
1012 | navigator,
|
1013 | static: staticProp
|
1014 | }), [basename, navigator, staticProp]);
|
1015 | if (typeof locationProp === "string") {
|
1016 | locationProp = parsePath(locationProp);
|
1017 | }
|
1018 | let {
|
1019 | pathname = "/",
|
1020 | search = "",
|
1021 | hash = "",
|
1022 | state = null,
|
1023 | key = "default"
|
1024 | } = locationProp;
|
1025 | let locationContext = React.useMemo(() => {
|
1026 | let trailingPathname = stripBasename(pathname, basename);
|
1027 | if (trailingPathname == null) {
|
1028 | return null;
|
1029 | }
|
1030 | return {
|
1031 | location: {
|
1032 | pathname: trailingPathname,
|
1033 | search,
|
1034 | hash,
|
1035 | state,
|
1036 | key
|
1037 | },
|
1038 | navigationType
|
1039 | };
|
1040 | }, [basename, pathname, search, hash, state, key, navigationType]);
|
1041 | process.env.NODE_ENV !== "production" ? UNSAFE_warning(locationContext != 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;
|
1042 | if (locationContext == null) {
|
1043 | return null;
|
1044 | }
|
1045 | return React.createElement(NavigationContext.Provider, {
|
1046 | value: navigationContext
|
1047 | }, React.createElement(LocationContext.Provider, {
|
1048 | children: children,
|
1049 | value: locationContext
|
1050 | }));
|
1051 | }
|
1052 |
|
1053 |
|
1054 |
|
1055 |
|
1056 |
|
1057 |
|
1058 | function Routes(_ref6) {
|
1059 | let {
|
1060 | children,
|
1061 | location
|
1062 | } = _ref6;
|
1063 | return useRoutes(createRoutesFromChildren(children), location);
|
1064 | }
|
1065 |
|
1066 |
|
1067 |
|
1068 |
|
1069 | function Await(_ref7) {
|
1070 | let {
|
1071 | children,
|
1072 | errorElement,
|
1073 | resolve
|
1074 | } = _ref7;
|
1075 | return React.createElement(AwaitErrorBoundary, {
|
1076 | resolve: resolve,
|
1077 | errorElement: errorElement
|
1078 | }, React.createElement(ResolveAwait, null, children));
|
1079 | }
|
1080 | var AwaitRenderStatus;
|
1081 | (function (AwaitRenderStatus) {
|
1082 | AwaitRenderStatus[AwaitRenderStatus["pending"] = 0] = "pending";
|
1083 | AwaitRenderStatus[AwaitRenderStatus["success"] = 1] = "success";
|
1084 | AwaitRenderStatus[AwaitRenderStatus["error"] = 2] = "error";
|
1085 | })(AwaitRenderStatus || (AwaitRenderStatus = {}));
|
1086 | const neverSettledPromise = new Promise(() => {});
|
1087 | class AwaitErrorBoundary extends React.Component {
|
1088 | constructor(props) {
|
1089 | super(props);
|
1090 | this.state = {
|
1091 | error: null
|
1092 | };
|
1093 | }
|
1094 | static getDerivedStateFromError(error) {
|
1095 | return {
|
1096 | error
|
1097 | };
|
1098 | }
|
1099 | componentDidCatch(error, errorInfo) {
|
1100 | console.error("<Await> caught the following error during render", error, errorInfo);
|
1101 | }
|
1102 | render() {
|
1103 | let {
|
1104 | children,
|
1105 | errorElement,
|
1106 | resolve
|
1107 | } = this.props;
|
1108 | let promise = null;
|
1109 | let status = AwaitRenderStatus.pending;
|
1110 | if (!(resolve instanceof Promise)) {
|
1111 |
|
1112 | status = AwaitRenderStatus.success;
|
1113 | promise = Promise.resolve();
|
1114 | Object.defineProperty(promise, "_tracked", {
|
1115 | get: () => true
|
1116 | });
|
1117 | Object.defineProperty(promise, "_data", {
|
1118 | get: () => resolve
|
1119 | });
|
1120 | } else if (this.state.error) {
|
1121 |
|
1122 | status = AwaitRenderStatus.error;
|
1123 | let renderError = this.state.error;
|
1124 | promise = Promise.reject().catch(() => {});
|
1125 | Object.defineProperty(promise, "_tracked", {
|
1126 | get: () => true
|
1127 | });
|
1128 | Object.defineProperty(promise, "_error", {
|
1129 | get: () => renderError
|
1130 | });
|
1131 | } else if (resolve._tracked) {
|
1132 |
|
1133 | promise = resolve;
|
1134 | status = promise._error !== undefined ? AwaitRenderStatus.error : promise._data !== undefined ? AwaitRenderStatus.success : AwaitRenderStatus.pending;
|
1135 | } else {
|
1136 |
|
1137 | status = AwaitRenderStatus.pending;
|
1138 | Object.defineProperty(resolve, "_tracked", {
|
1139 | get: () => true
|
1140 | });
|
1141 | promise = resolve.then(data => Object.defineProperty(resolve, "_data", {
|
1142 | get: () => data
|
1143 | }), error => Object.defineProperty(resolve, "_error", {
|
1144 | get: () => error
|
1145 | }));
|
1146 | }
|
1147 | if (status === AwaitRenderStatus.error && promise._error instanceof AbortedDeferredError) {
|
1148 |
|
1149 | throw neverSettledPromise;
|
1150 | }
|
1151 | if (status === AwaitRenderStatus.error && !errorElement) {
|
1152 |
|
1153 | throw promise._error;
|
1154 | }
|
1155 | if (status === AwaitRenderStatus.error) {
|
1156 |
|
1157 | return React.createElement(AwaitContext.Provider, {
|
1158 | value: promise,
|
1159 | children: errorElement
|
1160 | });
|
1161 | }
|
1162 | if (status === AwaitRenderStatus.success) {
|
1163 |
|
1164 | return React.createElement(AwaitContext.Provider, {
|
1165 | value: promise,
|
1166 | children: children
|
1167 | });
|
1168 | }
|
1169 |
|
1170 |
|
1171 | throw promise;
|
1172 | }
|
1173 | }
|
1174 |
|
1175 |
|
1176 |
|
1177 |
|
1178 |
|
1179 | function ResolveAwait(_ref8) {
|
1180 | let {
|
1181 | children
|
1182 | } = _ref8;
|
1183 | let data = useAsyncValue();
|
1184 | let toRender = typeof children === "function" ? children(data) : children;
|
1185 | return React.createElement(React.Fragment, null, toRender);
|
1186 | }
|
1187 |
|
1188 |
|
1189 |
|
1190 |
|
1191 |
|
1192 |
|
1193 |
|
1194 |
|
1195 |
|
1196 |
|
1197 |
|
1198 |
|
1199 | function createRoutesFromChildren(children, parentPath) {
|
1200 | if (parentPath === void 0) {
|
1201 | parentPath = [];
|
1202 | }
|
1203 | let routes = [];
|
1204 | React.Children.forEach(children, (element, index) => {
|
1205 | if (! React.isValidElement(element)) {
|
1206 |
|
1207 |
|
1208 | return;
|
1209 | }
|
1210 | let treePath = [...parentPath, index];
|
1211 | if (element.type === React.Fragment) {
|
1212 |
|
1213 | routes.push.apply(routes, createRoutesFromChildren(element.props.children, treePath));
|
1214 | return;
|
1215 | }
|
1216 | !(element.type === Route) ? process.env.NODE_ENV !== "production" ? UNSAFE_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>") : UNSAFE_invariant(false) : void 0;
|
1217 | !(!element.props.index || !element.props.children) ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false, "An index route cannot have child routes.") : UNSAFE_invariant(false) : void 0;
|
1218 | let route = {
|
1219 | id: element.props.id || treePath.join("-"),
|
1220 | caseSensitive: element.props.caseSensitive,
|
1221 | element: element.props.element,
|
1222 | Component: element.props.Component,
|
1223 | index: element.props.index,
|
1224 | path: element.props.path,
|
1225 | loader: element.props.loader,
|
1226 | action: element.props.action,
|
1227 | errorElement: element.props.errorElement,
|
1228 | ErrorBoundary: element.props.ErrorBoundary,
|
1229 | hasErrorBoundary: element.props.ErrorBoundary != null || element.props.errorElement != null,
|
1230 | shouldRevalidate: element.props.shouldRevalidate,
|
1231 | handle: element.props.handle,
|
1232 | lazy: element.props.lazy
|
1233 | };
|
1234 | if (element.props.children) {
|
1235 | route.children = createRoutesFromChildren(element.props.children, treePath);
|
1236 | }
|
1237 | routes.push(route);
|
1238 | });
|
1239 | return routes;
|
1240 | }
|
1241 |
|
1242 |
|
1243 |
|
1244 |
|
1245 | function renderMatches(matches) {
|
1246 | return _renderMatches(matches);
|
1247 | }
|
1248 |
|
1249 | function mapRouteProperties(route) {
|
1250 | let updates = {
|
1251 |
|
1252 |
|
1253 | hasErrorBoundary: route.ErrorBoundary != null || route.errorElement != null
|
1254 | };
|
1255 | if (route.Component) {
|
1256 | if (process.env.NODE_ENV !== "production") {
|
1257 | if (route.element) {
|
1258 | process.env.NODE_ENV !== "production" ? UNSAFE_warning(false, "You should not include both `Component` and `element` on your route - " + "`Component` will be used.") : void 0;
|
1259 | }
|
1260 | }
|
1261 | Object.assign(updates, {
|
1262 | element: React.createElement(route.Component),
|
1263 | Component: undefined
|
1264 | });
|
1265 | }
|
1266 | if (route.ErrorBoundary) {
|
1267 | if (process.env.NODE_ENV !== "production") {
|
1268 | if (route.errorElement) {
|
1269 | process.env.NODE_ENV !== "production" ? UNSAFE_warning(false, "You should not include both `ErrorBoundary` and `errorElement` on your route - " + "`ErrorBoundary` will be used.") : void 0;
|
1270 | }
|
1271 | }
|
1272 | Object.assign(updates, {
|
1273 | errorElement: React.createElement(route.ErrorBoundary),
|
1274 | ErrorBoundary: undefined
|
1275 | });
|
1276 | }
|
1277 | return updates;
|
1278 | }
|
1279 | function createMemoryRouter(routes, opts) {
|
1280 | return createRouter({
|
1281 | basename: opts == null ? void 0 : opts.basename,
|
1282 | future: _extends({}, opts == null ? void 0 : opts.future, {
|
1283 | v7_prependBasename: true
|
1284 | }),
|
1285 | history: createMemoryHistory({
|
1286 | initialEntries: opts == null ? void 0 : opts.initialEntries,
|
1287 | initialIndex: opts == null ? void 0 : opts.initialIndex
|
1288 | }),
|
1289 | hydrationData: opts == null ? void 0 : opts.hydrationData,
|
1290 | routes,
|
1291 | mapRouteProperties
|
1292 | }).initialize();
|
1293 | }
|
1294 |
|
1295 | export { Await, MemoryRouter, Navigate, Outlet, Route, Router, RouterProvider, Routes, DataRouterContext as UNSAFE_DataRouterContext, DataRouterStateContext as UNSAFE_DataRouterStateContext, LocationContext as UNSAFE_LocationContext, NavigationContext as UNSAFE_NavigationContext, RouteContext as UNSAFE_RouteContext, mapRouteProperties as UNSAFE_mapRouteProperties, useRouteId as UNSAFE_useRouteId, useRoutesImpl as UNSAFE_useRoutesImpl, createMemoryRouter, createRoutesFromChildren, createRoutesFromChildren as createRoutesFromElements, renderMatches, useBlocker as unstable_useBlocker, useActionData, useAsyncError, useAsyncValue, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes };
|
1296 |
|